37407cb0af
TemplateSeeder (OnModuleInit) seeds repo file defaults as global (scopeId NULL) templates if absent. Idempotent per (key,channel,locale,version): re-boot inserts nothing; a bumped version adds a new row and keeps the old for audit. Seeds: welcome (email), payment.receipt (email+sms), onboarding.reminder (email) — placeholder copy for marketing to replace. 3 tests. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
80 lines
2.8 KiB
TypeScript
80 lines
2.8 KiB
TypeScript
import type { IiosTemplateChannel } from '@prisma/client';
|
|
|
|
/** A platform-default template shipped in the repo and seeded at boot (scopeId NULL). */
|
|
export interface TemplateSeed {
|
|
key: string;
|
|
channel: IiosTemplateChannel;
|
|
locale: string;
|
|
version: number;
|
|
subject?: string;
|
|
bodyHtml?: string;
|
|
bodyText?: string;
|
|
variables: string[];
|
|
}
|
|
|
|
// Placeholder copy — marketing (Nikita/Himanshu) owns the words, Gautam the HTML. These are
|
|
// functional defaults so the pipeline works end-to-end before final copy lands; bump `version`
|
|
// when the content changes (the old version stays for audit/replay).
|
|
|
|
const WELCOME_EMAIL: TemplateSeed = {
|
|
key: 'welcome',
|
|
channel: 'EMAIL',
|
|
locale: 'en',
|
|
version: 1,
|
|
subject: 'Welcome to the Founders Club, {{firstName}}',
|
|
bodyHtml:
|
|
'<p>Hi {{firstName}},</p>' +
|
|
'<p>Thanks for joining the Founders Club. Your account is ready to set up.</p>' +
|
|
'<p><a href="{{signupLink}}">Create your account</a></p>' +
|
|
'<p>We are launching soon — we will keep you posted.</p>',
|
|
bodyText:
|
|
'Hi {{firstName}},\n\nThanks for joining the Founders Club. Create your account: {{signupLink}}\n\nWe are launching soon.',
|
|
variables: ['firstName', 'signupLink'],
|
|
};
|
|
|
|
const PAYMENT_RECEIPT_EMAIL: TemplateSeed = {
|
|
key: 'payment.receipt',
|
|
channel: 'EMAIL',
|
|
locale: 'en',
|
|
version: 1,
|
|
subject: 'Thanks for your payment, {{firstName}}',
|
|
bodyHtml:
|
|
'<p>Hi {{firstName}},</p>' +
|
|
'<p>We have received your payment of <strong>{{amount}}</strong> for {{licenseCount}} license(s).</p>' +
|
|
'<p>A separate tax receipt from our payment processor will follow.</p>',
|
|
bodyText:
|
|
'Hi {{firstName}},\n\nWe have received your payment of {{amount}} for {{licenseCount}} license(s).\nA separate tax receipt will follow.',
|
|
variables: ['firstName', 'amount', 'licenseCount'],
|
|
};
|
|
|
|
const PAYMENT_RECEIPT_SMS: TemplateSeed = {
|
|
key: 'payment.receipt',
|
|
channel: 'SMS',
|
|
locale: 'en',
|
|
version: 1,
|
|
bodyText: 'Thanks {{firstName}}! We received your payment of {{amount}}. A receipt is on its way to your email.',
|
|
variables: ['firstName', 'amount'],
|
|
};
|
|
|
|
const ONBOARDING_REMINDER_EMAIL: TemplateSeed = {
|
|
key: 'onboarding.reminder',
|
|
channel: 'EMAIL',
|
|
locale: 'en',
|
|
version: 1,
|
|
subject: 'Looks like you have not finished setting up',
|
|
bodyHtml:
|
|
'<p>Hi {{firstName}},</p>' +
|
|
'<p>You paid but have not created your account yet. It only takes a minute.</p>' +
|
|
'<p><a href="{{signupLink}}">Finish creating your account</a></p>',
|
|
bodyText:
|
|
'Hi {{firstName}},\n\nYou paid but have not created your account yet. Finish here: {{signupLink}}',
|
|
variables: ['firstName', 'signupLink'],
|
|
};
|
|
|
|
export const TEMPLATE_SEEDS: TemplateSeed[] = [
|
|
WELCOME_EMAIL,
|
|
PAYMENT_RECEIPT_EMAIL,
|
|
PAYMENT_RECEIPT_SMS,
|
|
ONBOARDING_REMINDER_EMAIL,
|
|
];
|