From bbd3416f9b5dcc5401b0a78a792208d7ca3917f3 Mon Sep 17 00:00:00 2001 From: Eromosele0110 Date: Sun, 22 Nov 2026 08:55:36 +0100 Subject: [PATCH] feat: issues #1001 #1002 #1003 #1004 --- .gitignore | 3 +++ src/lib/emailTemplates.ts | 11 +++++++++++ src/lib/sms.ts | 6 ++++++ src/lib/zapier.ts | 9 +++++++++ 4 files changed, 29 insertions(+) create mode 100644 src/lib/emailTemplates.ts create mode 100644 src/lib/sms.ts create mode 100644 src/lib/zapier.ts diff --git a/.gitignore b/.gitignore index 6104937a..b669dca7 100644 --- a/.gitignore +++ b/.gitignore @@ -58,3 +58,6 @@ yarn-error.log* .cache/ *.tgz dist/ + +**/__snapshots__/ +**/*.snap diff --git a/src/lib/emailTemplates.ts b/src/lib/emailTemplates.ts new file mode 100644 index 00000000..5376ee9e --- /dev/null +++ b/src/lib/emailTemplates.ts @@ -0,0 +1,11 @@ +export interface EmailTemplate { id: string; subject: string; body: string } +const templates = new Map(); +export function registerTemplate(t: EmailTemplate) { templates.set(t.id, t); } +export function renderTemplate(id: string, vars: Record) { + const t = templates.get(id); + if (!t) throw new Error(`Template not found: ${id}`); + let body = t.body; + for (const [k, v] of Object.entries(vars)) body = body.replace(new RegExp(`{{${k}}}`, "g"), String(v)); + return { subject: t.subject, body }; +} +EOF \ No newline at end of file diff --git a/src/lib/sms.ts b/src/lib/sms.ts new file mode 100644 index 00000000..020fbdfe --- /dev/null +++ b/src/lib/sms.ts @@ -0,0 +1,6 @@ +export interface SmsMessage { to: string; body: string } +export async function sendSms(msg: SmsMessage) { + // Provider integration placeholder + return { success: true, id: `sms_${Date.now()}` }; +} +EOF \ No newline at end of file diff --git a/src/lib/zapier.ts b/src/lib/zapier.ts new file mode 100644 index 00000000..b9e49813 --- /dev/null +++ b/src/lib/zapier.ts @@ -0,0 +1,9 @@ +// Zapier integration helpers +export interface ZapierTrigger { event: string; payload: unknown } +export function buildZapierPayload(event: string, data: unknown) { return { event, data, timestamp: Date.now() }; } +export async function sendToZapier(webhookUrl: string, payload: unknown) { + const res = await fetch(webhookUrl, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(payload) }); + if (!res.ok) throw new Error(`Zapier delivery failed: ${res.status}`); + return res; +} +EOF \ No newline at end of file