@simplelayer/graniteer-core 0.0.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +169 -15
- package/src/adminBookingCredit.test.ts +451 -0
- package/src/adminBookingCredit.ts +239 -0
- package/src/agreementCheckout.ts +250 -0
- package/src/agreementPortalEmail.ts +128 -0
- package/src/availability.test.ts +25 -0
- package/src/availability.ts +201 -0
- package/src/billingPortalLinkEmail.ts +117 -0
- package/src/bookingAgreementEmail.ts +149 -0
- package/src/bookingEffects.ts +388 -0
- package/src/bookingHoldReclaim.ts +94 -0
- package/src/busClient.ts +268 -0
- package/src/busSignature.ts +71 -0
- package/src/checkoutCoupon.test.ts +675 -0
- package/src/checkoutCoupon.ts +455 -0
- package/src/checkoutSessionParams.ts +56 -0
- package/src/commonsContract.ts +175 -0
- package/src/commonsDeposit.ts +298 -0
- package/src/commonsDepositWebhook.ts +237 -0
- package/src/conductorAdmin.ts +141 -0
- package/src/dayPassConfirmation.ts +230 -0
- package/src/dunningEmails.test.ts +263 -0
- package/src/dunningEmails.ts +203 -0
- package/src/email-templates/brand.ts +93 -0
- package/src/email-templates/email-change.tsx +92 -0
- package/src/email-templates/invite.tsx +79 -0
- package/src/email-templates/magic-link.tsx +59 -0
- package/src/email-templates/reauthentication.tsx +60 -0
- package/src/email-templates/recovery.tsx +59 -0
- package/src/email-templates/signup.tsx +67 -0
- package/src/functions/admin-cancel-membership.ts +311 -0
- package/src/functions/admin-change-membership-plan.ts +312 -0
- package/src/functions/admin-charge-guest-print.ts +229 -0
- package/src/functions/admin-correct-booking.ts +333 -0
- package/src/functions/admin-create-booking.ts +460 -0
- package/src/functions/admin-create-commons-event.ts +244 -0
- package/src/functions/admin-debug-boldsign-doc.ts +93 -0
- package/src/functions/admin-door-write.ts +272 -0
- package/src/functions/admin-issue-day-pass.ts +231 -0
- package/src/functions/admin-mark-booking-paid.ts +203 -0
- package/src/functions/admin-mint-billing-portal-link.ts +168 -0
- package/src/functions/admin-mint-portal-link.ts +62 -0
- package/src/functions/admin-photo-upload.ts +128 -0
- package/src/functions/admin-remove-team-member.ts +150 -0
- package/src/functions/admin-request-trial.ts +366 -0
- package/src/functions/admin-resend-commons-deposit-link.ts +323 -0
- package/src/functions/admin-reset-mfa.ts +138 -0
- package/src/functions/admin-retry-invoice-payment.test.ts +567 -0
- package/src/functions/admin-retry-invoice-payment.ts +333 -0
- package/src/functions/admin-reverse-coupon-redemption.ts +98 -0
- package/src/functions/admin-revoke-agreement.ts +467 -0
- package/src/functions/admin-send-commons-agreement.ts +214 -0
- package/src/functions/admin-set-credit-amount.ts +123 -0
- package/src/functions/admin-skip-commons-contract.ts +165 -0
- package/src/functions/admin-undo-membership-cancel.ts +144 -0
- package/src/functions/admin-wall-photo-write.ts +141 -0
- package/src/functions/auth-email-hook.ts +259 -0
- package/src/functions/boldsign-sender-identity.ts +114 -0
- package/src/functions/booking-availability.ts +419 -0
- package/src/functions/booking-member-preview.ts +136 -0
- package/src/functions/booking-status.ts +149 -0
- package/src/functions/conductor.ts +505 -0
- package/src/functions/create-agreement.ts +537 -0
- package/src/functions/create-booking.ts +648 -0
- package/src/functions/create-day-pass-checkout.ts +218 -0
- package/src/functions/create-portal-session.ts +142 -0
- package/src/functions/create-subscription-checkout.test.ts +222 -0
- package/src/functions/create-subscription-checkout.ts +440 -0
- package/src/functions/day-pass-status.ts +89 -0
- package/src/functions/dayStatus.ts +71 -0
- package/src/functions/diag-webpush-test.ts +45 -0
- package/src/functions/event-access-admin.ts +277 -0
- package/src/functions/event-access-store.ts +309 -0
- package/src/functions/ezeep-print-webhook.ts +213 -0
- package/src/functions/ezeep-usage-reconcile.ts +299 -0
- package/src/functions/fetch-avatar-original.ts +457 -0
- package/src/functions/get-provider-sign-link.ts +155 -0
- package/src/functions/get-signing-link.ts +211 -0
- package/src/functions/guest-print-setup-confirm.ts +128 -0
- package/src/functions/guest-print-submit.ts +149 -0
- package/src/functions/luma-webhook.ts +165 -0
- package/src/functions/manage-booking.ts +472 -0
- package/src/functions/mcp.ts +67 -0
- package/src/functions/member-door-action.test.ts +1248 -0
- package/src/functions/member-door-action.ts +863 -0
- package/src/functions/member-unifi-mapping.test.ts +516 -0
- package/src/functions/member-unifi-mapping.ts +206 -0
- package/src/functions/membership-door-sync.ts +956 -0
- package/src/functions/migration-collision-alert.copy.ts +232 -0
- package/src/functions/migration-collision-alert.test.ts +349 -0
- package/src/functions/migration-collision-alert.ts +232 -0
- package/src/functions/office-assignment-end.ts +146 -0
- package/src/functions/portal-booking-access.ts +95 -0
- package/src/functions/portal-list-invoices.ts +99 -0
- package/src/functions/portal-request-login.ts +192 -0
- package/src/functions/portal-resend-invite.ts +248 -0
- package/src/functions/portal-submit-event.ts +168 -0
- package/src/functions/print-billing-recover.ts +97 -0
- package/src/functions/print-billing-run.ts +183 -0
- package/src/functions/public-facts.ts +168 -0
- package/src/functions/push-send.ts +348 -0
- package/src/functions/push-test.ts +234 -0
- package/src/functions/request-portal-link.ts +211 -0
- package/src/functions/reschedule-booking.ts +649 -0
- package/src/functions/review-ratings.ts +113 -0
- package/src/functions/space-availability-range.acceptance.test.ts +161 -0
- package/src/functions/space-availability-range.ts +142 -0
- package/src/functions/stripe-db-reconcile.ts +319 -0
- package/src/functions/stripe-webhook.moved-regression.test.ts +78 -0
- package/src/functions/stripe-webhook.ts +2595 -0
- package/src/functions/sync-gcal-blackouts.ts +298 -0
- package/src/functions/timetable-event-register.ts +162 -0
- package/src/functions/timetable-event-status.ts +90 -0
- package/src/functions/timetable-spaces.ts +219 -0
- package/src/functions/touch-pass-reconciler.ts +689 -0
- package/src/functions/touch-pass-signup.ts +478 -0
- package/src/functions/upload-booking-display-image.ts +179 -0
- package/src/functions/virtual-onboarding-purge.ts +134 -0
- package/src/functions/virtual-onboarding-submit.ts +315 -0
- package/src/functions/voice-booking.ts +453 -0
- package/src/functions/voice-day-pass.ts +346 -0
- package/src/functions/voice-inquiry.test.ts +301 -0
- package/src/functions/voice-inquiry.ts +198 -0
- package/src/functions/voice-membership-signup.ts +355 -0
- package/src/functions/voice-tour-availability.ts +204 -0
- package/src/functions/voice-tour-booking.ts +429 -0
- package/src/gcalSync.ts +142 -0
- package/src/ghlEventInquiry.ts +143 -0
- package/src/ghlNote.ts +34 -0
- package/src/ghlTask.ts +48 -0
- package/src/ghlVoiceInquiry.ts +90 -0
- package/src/guestPrintCapture.test.ts +722 -0
- package/src/guestPrintCapture.ts +538 -0
- package/src/lumaGhl.ts +195 -0
- package/src/mailArrivalEmail.ts +121 -0
- package/src/manageToken.ts +363 -0
- package/src/membership.ts +109 -0
- package/src/membershipBusClient.ts +537 -0
- package/src/membershipWelcome.ts +683 -0
- package/src/migrationCheckout.ts +366 -0
- package/src/money.ts +36 -0
- package/src/ops.ts +97 -0
- package/src/pacificDate.ts +88 -0
- package/src/paymentLinkEmail.ts +123 -0
- package/src/policyAcknowledgment.test.ts +50 -0
- package/src/policyAcknowledgment.ts +96 -0
- package/src/portalSession.ts +46 -0
- package/src/pricing.test.ts +660 -0
- package/src/pricing.ts +1025 -0
- package/src/printBilling.test.ts +750 -0
- package/src/printBilling.ts +891 -0
- package/src/printBillingAdapters.ts +169 -0
- package/src/printCorrections.test.ts +348 -0
- package/src/printCorrections.ts +496 -0
- package/src/rateLimit.ts +82 -0
- package/src/referralCredits.test.ts +31 -0
- package/src/referralCredits.ts +34 -0
- package/src/referralGrant.ts +321 -0
- package/src/rescheduleCredit.test.ts +521 -0
- package/src/rescheduleCredit.ts +337 -0
- package/src/reservationWifiCode.test.ts +69 -0
- package/src/reservationWifiCode.ts +81 -0
- package/src/retellCallAnalyzed.test.ts +167 -0
- package/src/retellCallAnalyzed.ts +113 -0
- package/src/retellSignature.test.ts +137 -0
- package/src/retellSignature.ts +82 -0
- package/src/signedUnpaidReminderEmail.test.ts +246 -0
- package/src/signedUnpaidReminderEmail.ts +132 -0
- package/src/slackAlert.ts +38 -0
- package/src/stripeCoworkingPortal.ts +91 -0
- package/src/supabaseTestFakes.ts +131 -0
- package/src/supportTicketEmail.ts +119 -0
- package/src/tier1Agreement.ts +125 -0
- package/src/unifiAccessPolicies.ts +228 -0
- package/src/unifiGroups.ts +129 -0
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
// Payment-failed dunning sequence: 3 emails riding the existing 5-day
|
|
2
|
+
// pricing_grace_ends_at window that stripe-webhook/index.ts opens on
|
|
3
|
+
// past_due/canceled/unpaid (see membership.ts's computeEntitlement -- the
|
|
4
|
+
// grace end flips both member pricing AND door/WiFi access off via
|
|
5
|
+
// membership-door-sync; this module changes none of that timing).
|
|
6
|
+
//
|
|
7
|
+
// Follows membershipWelcome.ts's exact GHL upsert+send pattern. esc() and
|
|
8
|
+
// classifyError() are reused verbatim (byte-identical) from that file.
|
|
9
|
+
//
|
|
10
|
+
// Stage naming:
|
|
11
|
+
// grace_start -- fired directly from stripe-webhook the instant the grace
|
|
12
|
+
// window is first opened. NOT decided by stageForGraceWindow
|
|
13
|
+
// below -- see stripe-webhook/index.ts's
|
|
14
|
+
// `isRevoked && !wasRevoked` branch.
|
|
15
|
+
// day_3 -- <=2 days remaining in the grace window.
|
|
16
|
+
// final_notice -- <=1 day remaining.
|
|
17
|
+
|
|
18
|
+
import type { SupabaseClient } from 'npm:@supabase/supabase-js@2';
|
|
19
|
+
import { logOps } from './ops.ts';
|
|
20
|
+
|
|
21
|
+
type SupabaseLike = SupabaseClient<any, 'public', any>;
|
|
22
|
+
|
|
23
|
+
export type DunningStage = 'grace_start' | 'day_3' | 'final_notice';
|
|
24
|
+
export type DunningResult = 'sent' | 'skipped' | 'failed_retryable' | 'failed_permanent';
|
|
25
|
+
|
|
26
|
+
/** Escape untrusted values interpolated into outbound HTML. Identical to membershipWelcome.ts's esc(). */
|
|
27
|
+
function esc(v: unknown): string {
|
|
28
|
+
return String(v ?? '')
|
|
29
|
+
.replace(/&/g, '&')
|
|
30
|
+
.replace(/</g, '<')
|
|
31
|
+
.replace(/>/g, '>')
|
|
32
|
+
.replace(/"/g, '"')
|
|
33
|
+
.replace(/'/g, ''');
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** Classify a caught error as transient (worth another event) or hopeless. Identical to membershipWelcome.ts's classifyError(). */
|
|
37
|
+
function classifyError(e: unknown): 'failed_retryable' | 'failed_permanent' {
|
|
38
|
+
const name = e instanceof Error ? e.name : '';
|
|
39
|
+
if (name === 'AbortError' || name === 'TimeoutError') return 'failed_retryable';
|
|
40
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
41
|
+
const m = msg.match(/^ghl_(?:upsert|email)_(\d{3})/);
|
|
42
|
+
if (m) {
|
|
43
|
+
const code = Number(m[1]);
|
|
44
|
+
if (code === 429 || code >= 500) return 'failed_retryable';
|
|
45
|
+
}
|
|
46
|
+
return 'failed_permanent';
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Pure day-band classifier for the dunning cadence. Given the grace window's
|
|
51
|
+
* end instant and "now", decides which of the two LATER stages is due:
|
|
52
|
+
*
|
|
53
|
+
* <= 1 day remaining -> 'final_notice'
|
|
54
|
+
* <= 2 days remaining -> 'day_3'
|
|
55
|
+
* otherwise -> null (too early; grace_start already covers day 0
|
|
56
|
+
* and fires from stripe-webhook directly, not here)
|
|
57
|
+
*
|
|
58
|
+
* Boundaries are inclusive of "<=" so a row checked exactly at the 1-day or
|
|
59
|
+
* 2-day mark is not skipped by a daily cron's timing jitter. An unparsable
|
|
60
|
+
* graceEndsAtIso returns null (fail closed -- never guess a stage).
|
|
61
|
+
*/
|
|
62
|
+
export function stageForGraceWindow(
|
|
63
|
+
graceEndsAtIso: string,
|
|
64
|
+
now: Date = new Date(),
|
|
65
|
+
): DunningStage | null {
|
|
66
|
+
const endMs = Date.parse(graceEndsAtIso);
|
|
67
|
+
if (!Number.isFinite(endMs)) return null;
|
|
68
|
+
const ONE_DAY_MS = 24 * 60 * 60 * 1000;
|
|
69
|
+
const msRemaining = endMs - now.getTime();
|
|
70
|
+
if (msRemaining <= ONE_DAY_MS) return 'final_notice';
|
|
71
|
+
if (msRemaining <= 2 * ONE_DAY_MS) return 'day_3';
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Pure skip-logic for dunning-email-check's per-row loop: a stage is only
|
|
77
|
+
* ever sent once. Extracted out of the Deno.serve handler (which cannot be
|
|
78
|
+
* unit-tested in isolation without a live network/DB) so this decision is
|
|
79
|
+
* independently testable. `stage: null` (too early for either later stage --
|
|
80
|
+
* see stageForGraceWindow) always means "don't send".
|
|
81
|
+
*/
|
|
82
|
+
export function shouldSendDunningStage(
|
|
83
|
+
stage: DunningStage | null,
|
|
84
|
+
dunningEmailsSent: Record<string, boolean> | null | undefined,
|
|
85
|
+
): boolean {
|
|
86
|
+
if (!stage) return false;
|
|
87
|
+
return dunningEmailsSent?.[stage] !== true;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function stageCopy(stage: DunningStage, endLabel: string, p: (t: string) => string) {
|
|
91
|
+
if (stage === 'grace_start') {
|
|
92
|
+
return {
|
|
93
|
+
subject: `We couldn't process your payment -- action needed by ${endLabel}`,
|
|
94
|
+
bodyLines: [
|
|
95
|
+
p(`We were unable to process your most recent membership payment.`),
|
|
96
|
+
p(`Please update your payment method before <strong>${esc(endLabel)}</strong> to keep your door and WiFi access active. No action is needed if you've already fixed this.`),
|
|
97
|
+
],
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
if (stage === 'day_3') {
|
|
101
|
+
return {
|
|
102
|
+
subject: `Reminder: update your payment by ${endLabel}`,
|
|
103
|
+
bodyLines: [
|
|
104
|
+
p(`This is a reminder that your membership payment is still unresolved.`),
|
|
105
|
+
p(`Your door and WiFi access will be turned off on <strong>${esc(endLabel)}</strong> if payment isn't updated before then.`),
|
|
106
|
+
],
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
return {
|
|
110
|
+
subject: `Final notice: access ends ${endLabel}`,
|
|
111
|
+
bodyLines: [
|
|
112
|
+
p(`This is a final notice -- your membership payment is still unresolved.`),
|
|
113
|
+
p(`Your door and WiFi access will be turned off on <strong>${esc(endLabel)}</strong> unless payment is updated before then.`),
|
|
114
|
+
],
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Send one dunning-sequence email via GHL (contacts/upsert + conversations/
|
|
120
|
+
* messages), mirroring sendMembershipWelcome's exact pattern. Never throws --
|
|
121
|
+
* every failure is caught, logged via logOps, and classified into a result
|
|
122
|
+
* the caller (dunning-email-check, or stripe-webhook for grace_start) uses
|
|
123
|
+
* to decide whether dunning_emails_sent may be stamped true.
|
|
124
|
+
*/
|
|
125
|
+
export async function sendDunningEmail(
|
|
126
|
+
supabase: SupabaseLike,
|
|
127
|
+
email: string,
|
|
128
|
+
membershipId: string,
|
|
129
|
+
stage: DunningStage,
|
|
130
|
+
graceEndsAtIso: string,
|
|
131
|
+
operator: { name: string; shortName: string; domain: string; supportEmail: string },
|
|
132
|
+
): Promise<DunningResult> {
|
|
133
|
+
try {
|
|
134
|
+
if (!email) return 'skipped';
|
|
135
|
+
|
|
136
|
+
const apiKey = Deno.env.get('GHL_API_KEY');
|
|
137
|
+
const locationId = Deno.env.get('GHL_LOCATION_ID');
|
|
138
|
+
if (!apiKey || !locationId) {
|
|
139
|
+
console.log('[dunningEmails] GHL not configured; skip dunning email', { stage });
|
|
140
|
+
await logOps(supabase, 'dunning_email_skipped',
|
|
141
|
+
{ email, membership_id: membershipId, stage, reason: 'ghl_not_configured' },
|
|
142
|
+
{ severity: 'warning' }).catch(() => {});
|
|
143
|
+
return 'skipped';
|
|
144
|
+
}
|
|
145
|
+
const GHL_BASE = 'https://services.leadconnectorhq.com';
|
|
146
|
+
const headers = {
|
|
147
|
+
Authorization: `Bearer ${apiKey}`,
|
|
148
|
+
Version: '2021-07-28',
|
|
149
|
+
'Content-Type': 'application/json',
|
|
150
|
+
Accept: 'application/json',
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
const upRes = await fetch(`${GHL_BASE}/contacts/upsert`, {
|
|
154
|
+
method: 'POST', headers,
|
|
155
|
+
signal: AbortSignal.timeout(8000),
|
|
156
|
+
body: JSON.stringify({
|
|
157
|
+
locationId, email,
|
|
158
|
+
source: `${operator.shortName} Website — Dunning`,
|
|
159
|
+
tags: ['Dunning', `dunning:${stage}`, operator.domain],
|
|
160
|
+
}),
|
|
161
|
+
});
|
|
162
|
+
if (!upRes.ok) throw new Error(`ghl_upsert_${upRes.status}: ${await upRes.text()}`);
|
|
163
|
+
const upJson = await upRes.json();
|
|
164
|
+
const contactId = upJson.contact?.id || upJson.id || null;
|
|
165
|
+
if (!contactId) throw new Error('ghl_upsert_no_contact_id');
|
|
166
|
+
|
|
167
|
+
const p = (t: string) =>
|
|
168
|
+
`<p style="margin:0 0 8px 0;color:#22263B;font-family:Inter,Arial,sans-serif;font-size:14px;line-height:22px">${t}</p>`;
|
|
169
|
+
|
|
170
|
+
const endInstant = new Date(graceEndsAtIso);
|
|
171
|
+
const endLabel = Number.isFinite(endInstant.getTime())
|
|
172
|
+
? endInstant.toLocaleDateString('en-US', {
|
|
173
|
+
timeZone: 'America/Los_Angeles', weekday: 'long', month: 'long', day: 'numeric',
|
|
174
|
+
})
|
|
175
|
+
: 'the end of your grace period';
|
|
176
|
+
|
|
177
|
+
const { subject, bodyLines } = stageCopy(stage, endLabel, p);
|
|
178
|
+
|
|
179
|
+
const html = `<div style="background:#F6F6F6;padding:24px 0;margin:0"><table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0" style="border-collapse:collapse;background:#F6F6F6"><tr><td align="center" style="padding:0 12px"><table role="presentation" width="560" cellpadding="0" cellspacing="0" border="0" style="border-collapse:collapse;max-width:560px;width:100%;background:#FFFFFF;border-radius:10px"><tr><td style="padding:24px">
|
|
180
|
+
<h2 style="margin:0 0 12px 0;color:#22263B;font-family:Inter,Arial,sans-serif;font-size:22px">${esc(subject)}</h2>
|
|
181
|
+
${bodyLines.join('')}
|
|
182
|
+
${p(`Questions? Just reply to this email — it reaches a real person here. You can also write to <a href="mailto:${operator.supportEmail}" style="color:#C98A5E">${operator.supportEmail}</a>.`)}
|
|
183
|
+
<p style="margin:24px 0 0 0;color:#748272;font-family:Inter,Arial,sans-serif;font-size:13px;line-height:20px">${operator.name}</p>
|
|
184
|
+
</td></tr></table></td></tr></table></div>`;
|
|
185
|
+
|
|
186
|
+
const emailRes = await fetch(`${GHL_BASE}/conversations/messages`, {
|
|
187
|
+
method: 'POST', headers,
|
|
188
|
+
signal: AbortSignal.timeout(8000),
|
|
189
|
+
body: JSON.stringify({ type: 'Email', contactId, subject, html }),
|
|
190
|
+
});
|
|
191
|
+
if (!emailRes.ok) throw new Error(`ghl_email_${emailRes.status}: ${await emailRes.text()}`);
|
|
192
|
+
|
|
193
|
+
await logOps(supabase, 'dunning_email_sent',
|
|
194
|
+
{ email, membership_id: membershipId, stage }, { severity: 'info' }).catch(() => {});
|
|
195
|
+
return 'sent';
|
|
196
|
+
} catch (e) {
|
|
197
|
+
const classification = classifyError(e);
|
|
198
|
+
await logOps(supabase, 'dunning_email_failed',
|
|
199
|
+
{ email, membership_id: membershipId, stage, message: e instanceof Error ? e.message : String(e) },
|
|
200
|
+
{ severity: classification === 'failed_permanent' ? 'error' : 'warning' }).catch(() => {});
|
|
201
|
+
return classification;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/** Email brand tokens (mirrors tailwind.config.ts for the tenant calling this). */
|
|
2
|
+
export interface BrandColors {
|
|
3
|
+
navy: string;
|
|
4
|
+
sage: string;
|
|
5
|
+
sageDark: string;
|
|
6
|
+
cream: string;
|
|
7
|
+
border: string;
|
|
8
|
+
inkSecondary: string;
|
|
9
|
+
inkMuted: string;
|
|
10
|
+
white: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function buildBrandStyles(colors: BrandColors) {
|
|
14
|
+
const brand = colors;
|
|
15
|
+
|
|
16
|
+
const main = {
|
|
17
|
+
backgroundColor: brand.cream,
|
|
18
|
+
fontFamily: "Georgia, 'Times New Roman', serif",
|
|
19
|
+
margin: 0,
|
|
20
|
+
padding: "32px 0",
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const container = {
|
|
24
|
+
backgroundColor: brand.white,
|
|
25
|
+
border: `1px solid ${brand.border}`,
|
|
26
|
+
borderRadius: "12px",
|
|
27
|
+
padding: "36px 32px",
|
|
28
|
+
maxWidth: "560px",
|
|
29
|
+
margin: "0 auto",
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const brandMark = {
|
|
33
|
+
fontSize: "13px",
|
|
34
|
+
letterSpacing: "1.5px",
|
|
35
|
+
textTransform: "uppercase" as const,
|
|
36
|
+
color: brand.sage,
|
|
37
|
+
fontFamily: "Helvetica, Arial, sans-serif",
|
|
38
|
+
margin: "0 0 24px",
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const h1 = {
|
|
42
|
+
fontSize: "24px",
|
|
43
|
+
fontWeight: "bold" as const,
|
|
44
|
+
color: brand.navy,
|
|
45
|
+
margin: "0 0 16px",
|
|
46
|
+
lineHeight: "1.25",
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const text = {
|
|
50
|
+
fontSize: "15px",
|
|
51
|
+
color: brand.inkSecondary,
|
|
52
|
+
lineHeight: "1.6",
|
|
53
|
+
fontFamily: "Helvetica, Arial, sans-serif",
|
|
54
|
+
margin: "0 0 24px",
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const button = {
|
|
58
|
+
backgroundColor: brand.navy,
|
|
59
|
+
color: brand.white,
|
|
60
|
+
fontSize: "15px",
|
|
61
|
+
fontWeight: "bold" as const,
|
|
62
|
+
fontFamily: "Helvetica, Arial, sans-serif",
|
|
63
|
+
borderRadius: "8px",
|
|
64
|
+
padding: "14px 26px",
|
|
65
|
+
textDecoration: "none",
|
|
66
|
+
display: "inline-block",
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const codeBox = {
|
|
70
|
+
fontSize: "26px",
|
|
71
|
+
letterSpacing: "6px",
|
|
72
|
+
fontWeight: "bold" as const,
|
|
73
|
+
color: brand.navy,
|
|
74
|
+
backgroundColor: brand.cream,
|
|
75
|
+
border: `1px solid ${brand.border}`,
|
|
76
|
+
borderRadius: "8px",
|
|
77
|
+
padding: "16px",
|
|
78
|
+
textAlign: "center" as const,
|
|
79
|
+
margin: "0 0 24px",
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const footer = {
|
|
83
|
+
fontSize: "12px",
|
|
84
|
+
color: brand.inkMuted,
|
|
85
|
+
fontFamily: "Helvetica, Arial, sans-serif",
|
|
86
|
+
lineHeight: "1.6",
|
|
87
|
+
borderTop: `1px solid ${brand.border}`,
|
|
88
|
+
paddingTop: "20px",
|
|
89
|
+
margin: "32px 0 0",
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
return { brand, main, container, brandMark, h1, text, button, codeBox, footer };
|
|
93
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/// <reference types="npm:@types/react@18.3.1" />
|
|
2
|
+
|
|
3
|
+
import * as React from 'npm:react@18.3.1'
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
Body,
|
|
7
|
+
Button,
|
|
8
|
+
Container,
|
|
9
|
+
Head,
|
|
10
|
+
Heading,
|
|
11
|
+
Html,
|
|
12
|
+
Link,
|
|
13
|
+
Preview,
|
|
14
|
+
Text,
|
|
15
|
+
} from 'npm:@react-email/components@0.0.22'
|
|
16
|
+
|
|
17
|
+
interface EmailChangeEmailProps {
|
|
18
|
+
siteName: string
|
|
19
|
+
// oldEmail is the user's current address (HookData.OldEmail). For the
|
|
20
|
+
// NEW-recipient half of a secure email_change fanout, `email` equals the
|
|
21
|
+
// recipient (NEW), so the "from" line must render oldEmail to read
|
|
22
|
+
// "from OLD to NEW" instead of "from NEW to NEW".
|
|
23
|
+
oldEmail: string
|
|
24
|
+
email: string
|
|
25
|
+
newEmail: string
|
|
26
|
+
confirmationUrl: string
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const EmailChangeEmail = ({
|
|
30
|
+
siteName,
|
|
31
|
+
oldEmail,
|
|
32
|
+
newEmail,
|
|
33
|
+
confirmationUrl,
|
|
34
|
+
}: EmailChangeEmailProps) => (
|
|
35
|
+
<Html lang="en" dir="ltr">
|
|
36
|
+
<Head />
|
|
37
|
+
<Preview>Confirm your email change for {siteName}</Preview>
|
|
38
|
+
<Body style={main}>
|
|
39
|
+
<Container style={container}>
|
|
40
|
+
<Heading style={h1}>Confirm your email change</Heading>
|
|
41
|
+
<Text style={text}>
|
|
42
|
+
You requested to change your email address for {siteName} from{' '}
|
|
43
|
+
<Link href={`mailto:${oldEmail}`} style={link}>
|
|
44
|
+
{oldEmail}
|
|
45
|
+
</Link>{' '}
|
|
46
|
+
to{' '}
|
|
47
|
+
<Link href={`mailto:${newEmail}`} style={link}>
|
|
48
|
+
{newEmail}
|
|
49
|
+
</Link>
|
|
50
|
+
.
|
|
51
|
+
</Text>
|
|
52
|
+
<Text style={text}>
|
|
53
|
+
Click the button below to confirm this change:
|
|
54
|
+
</Text>
|
|
55
|
+
<Button style={button} href={confirmationUrl}>
|
|
56
|
+
Confirm Email Change
|
|
57
|
+
</Button>
|
|
58
|
+
<Text style={footer}>
|
|
59
|
+
If you didn't request this change, please secure your account
|
|
60
|
+
immediately.
|
|
61
|
+
</Text>
|
|
62
|
+
</Container>
|
|
63
|
+
</Body>
|
|
64
|
+
</Html>
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
export default EmailChangeEmail
|
|
68
|
+
|
|
69
|
+
const main = { backgroundColor: '#ffffff', fontFamily: 'Arial, sans-serif' }
|
|
70
|
+
const container = { padding: '20px 25px' }
|
|
71
|
+
const h1 = {
|
|
72
|
+
fontSize: '22px',
|
|
73
|
+
fontWeight: 'bold' as const,
|
|
74
|
+
color: '#000000',
|
|
75
|
+
margin: '0 0 20px',
|
|
76
|
+
}
|
|
77
|
+
const text = {
|
|
78
|
+
fontSize: '14px',
|
|
79
|
+
color: '#55575d',
|
|
80
|
+
lineHeight: '1.5',
|
|
81
|
+
margin: '0 0 25px',
|
|
82
|
+
}
|
|
83
|
+
const link = { color: 'inherit', textDecoration: 'underline' }
|
|
84
|
+
const button = {
|
|
85
|
+
backgroundColor: '#000000',
|
|
86
|
+
color: '#ffffff',
|
|
87
|
+
fontSize: '14px',
|
|
88
|
+
borderRadius: '8px',
|
|
89
|
+
padding: '12px 20px',
|
|
90
|
+
textDecoration: 'none',
|
|
91
|
+
}
|
|
92
|
+
const footer = { fontSize: '12px', color: '#999999', margin: '30px 0 0' }
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/// <reference types="npm:@types/react@18.3.1" />
|
|
2
|
+
|
|
3
|
+
import * as React from 'npm:react@18.3.1'
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
Body,
|
|
7
|
+
Button,
|
|
8
|
+
Container,
|
|
9
|
+
Head,
|
|
10
|
+
Heading,
|
|
11
|
+
Html,
|
|
12
|
+
Link,
|
|
13
|
+
Preview,
|
|
14
|
+
Text,
|
|
15
|
+
} from 'npm:@react-email/components@0.0.22'
|
|
16
|
+
|
|
17
|
+
interface InviteEmailProps {
|
|
18
|
+
siteName: string
|
|
19
|
+
siteUrl: string
|
|
20
|
+
confirmationUrl: string
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const InviteEmail = ({
|
|
24
|
+
siteName,
|
|
25
|
+
siteUrl,
|
|
26
|
+
confirmationUrl,
|
|
27
|
+
}: InviteEmailProps) => (
|
|
28
|
+
<Html lang="en" dir="ltr">
|
|
29
|
+
<Head />
|
|
30
|
+
<Preview>You've been invited to join {siteName}</Preview>
|
|
31
|
+
<Body style={main}>
|
|
32
|
+
<Container style={container}>
|
|
33
|
+
<Heading style={h1}>You've been invited</Heading>
|
|
34
|
+
<Text style={text}>
|
|
35
|
+
You've been invited to join{' '}
|
|
36
|
+
<Link href={siteUrl} style={link}>
|
|
37
|
+
<strong>{siteName}</strong>
|
|
38
|
+
</Link>
|
|
39
|
+
. Click the button below to accept the invitation and create your
|
|
40
|
+
account.
|
|
41
|
+
</Text>
|
|
42
|
+
<Button style={button} href={confirmationUrl}>
|
|
43
|
+
Accept Invitation
|
|
44
|
+
</Button>
|
|
45
|
+
<Text style={footer}>
|
|
46
|
+
If you weren't expecting this invitation, you can safely ignore this
|
|
47
|
+
email.
|
|
48
|
+
</Text>
|
|
49
|
+
</Container>
|
|
50
|
+
</Body>
|
|
51
|
+
</Html>
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
export default InviteEmail
|
|
55
|
+
|
|
56
|
+
const main = { backgroundColor: '#ffffff', fontFamily: 'Arial, sans-serif' }
|
|
57
|
+
const container = { padding: '20px 25px' }
|
|
58
|
+
const h1 = {
|
|
59
|
+
fontSize: '22px',
|
|
60
|
+
fontWeight: 'bold' as const,
|
|
61
|
+
color: '#000000',
|
|
62
|
+
margin: '0 0 20px',
|
|
63
|
+
}
|
|
64
|
+
const text = {
|
|
65
|
+
fontSize: '14px',
|
|
66
|
+
color: '#55575d',
|
|
67
|
+
lineHeight: '1.5',
|
|
68
|
+
margin: '0 0 25px',
|
|
69
|
+
}
|
|
70
|
+
const link = { color: 'inherit', textDecoration: 'underline' }
|
|
71
|
+
const button = {
|
|
72
|
+
backgroundColor: '#000000',
|
|
73
|
+
color: '#ffffff',
|
|
74
|
+
fontSize: '14px',
|
|
75
|
+
borderRadius: '8px',
|
|
76
|
+
padding: '12px 20px',
|
|
77
|
+
textDecoration: 'none',
|
|
78
|
+
}
|
|
79
|
+
const footer = { fontSize: '12px', color: '#999999', margin: '30px 0 0' }
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/// <reference types="npm:@types/react@18.3.1" />
|
|
2
|
+
|
|
3
|
+
import * as React from 'npm:react@18.3.1'
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
Body,
|
|
7
|
+
Button,
|
|
8
|
+
Container,
|
|
9
|
+
Head,
|
|
10
|
+
Heading,
|
|
11
|
+
Html,
|
|
12
|
+
Preview,
|
|
13
|
+
Text,
|
|
14
|
+
} from 'npm:@react-email/components@0.0.22'
|
|
15
|
+
|
|
16
|
+
import { buildBrandStyles, type BrandColors } from './brand.ts'
|
|
17
|
+
|
|
18
|
+
interface MagicLinkEmailProps {
|
|
19
|
+
siteName: string
|
|
20
|
+
confirmationUrl: string
|
|
21
|
+
colors: BrandColors
|
|
22
|
+
footerLine: string
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const MagicLinkEmail = ({
|
|
26
|
+
siteName,
|
|
27
|
+
confirmationUrl,
|
|
28
|
+
colors,
|
|
29
|
+
footerLine,
|
|
30
|
+
}: MagicLinkEmailProps) => {
|
|
31
|
+
const { brandMark, button, container, footer, h1, main, text } = buildBrandStyles(colors)
|
|
32
|
+
return (
|
|
33
|
+
<Html lang="en" dir="ltr">
|
|
34
|
+
<Head />
|
|
35
|
+
<Preview>Your member login link for {siteName}</Preview>
|
|
36
|
+
<Body style={main}>
|
|
37
|
+
<Container style={container}>
|
|
38
|
+
<Text style={brandMark}>{siteName}</Text>
|
|
39
|
+
<Heading style={h1}>Your member login link</Heading>
|
|
40
|
+
<Text style={text}>
|
|
41
|
+
Use the button below to sign in to your {siteName} member portal. For your
|
|
42
|
+
security, this link expires shortly and can only be used once.
|
|
43
|
+
</Text>
|
|
44
|
+
<Button style={button} href={confirmationUrl}>
|
|
45
|
+
Sign in to the portal
|
|
46
|
+
</Button>
|
|
47
|
+
<Text style={footer}>
|
|
48
|
+
If you didn't request this link, you can safely ignore this email — no one can
|
|
49
|
+
access your account without it.
|
|
50
|
+
<br />
|
|
51
|
+
{footerLine}
|
|
52
|
+
</Text>
|
|
53
|
+
</Container>
|
|
54
|
+
</Body>
|
|
55
|
+
</Html>
|
|
56
|
+
)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export default MagicLinkEmail
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/// <reference types="npm:@types/react@18.3.1" />
|
|
2
|
+
|
|
3
|
+
import * as React from 'npm:react@18.3.1'
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
Body,
|
|
7
|
+
Container,
|
|
8
|
+
Head,
|
|
9
|
+
Heading,
|
|
10
|
+
Html,
|
|
11
|
+
Preview,
|
|
12
|
+
Text,
|
|
13
|
+
} from 'npm:@react-email/components@0.0.22'
|
|
14
|
+
|
|
15
|
+
interface ReauthenticationEmailProps {
|
|
16
|
+
token: string
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const ReauthenticationEmail = ({ token }: ReauthenticationEmailProps) => (
|
|
20
|
+
<Html lang="en" dir="ltr">
|
|
21
|
+
<Head />
|
|
22
|
+
<Preview>Your verification code</Preview>
|
|
23
|
+
<Body style={main}>
|
|
24
|
+
<Container style={container}>
|
|
25
|
+
<Heading style={h1}>Confirm reauthentication</Heading>
|
|
26
|
+
<Text style={text}>Use the code below to confirm your identity:</Text>
|
|
27
|
+
<Text style={codeStyle}>{token}</Text>
|
|
28
|
+
<Text style={footer}>
|
|
29
|
+
This code will expire shortly. If you didn't request this, you can
|
|
30
|
+
safely ignore this email.
|
|
31
|
+
</Text>
|
|
32
|
+
</Container>
|
|
33
|
+
</Body>
|
|
34
|
+
</Html>
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
export default ReauthenticationEmail
|
|
38
|
+
|
|
39
|
+
const main = { backgroundColor: '#ffffff', fontFamily: 'Arial, sans-serif' }
|
|
40
|
+
const container = { padding: '20px 25px' }
|
|
41
|
+
const h1 = {
|
|
42
|
+
fontSize: '22px',
|
|
43
|
+
fontWeight: 'bold' as const,
|
|
44
|
+
color: '#000000',
|
|
45
|
+
margin: '0 0 20px',
|
|
46
|
+
}
|
|
47
|
+
const text = {
|
|
48
|
+
fontSize: '14px',
|
|
49
|
+
color: '#55575d',
|
|
50
|
+
lineHeight: '1.5',
|
|
51
|
+
margin: '0 0 25px',
|
|
52
|
+
}
|
|
53
|
+
const codeStyle = {
|
|
54
|
+
fontFamily: 'Courier, monospace',
|
|
55
|
+
fontSize: '22px',
|
|
56
|
+
fontWeight: 'bold' as const,
|
|
57
|
+
color: '#000000',
|
|
58
|
+
margin: '0 0 30px',
|
|
59
|
+
}
|
|
60
|
+
const footer = { fontSize: '12px', color: '#999999', margin: '30px 0 0' }
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/// <reference types="npm:@types/react@18.3.1" />
|
|
2
|
+
|
|
3
|
+
import * as React from 'npm:react@18.3.1'
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
Body,
|
|
7
|
+
Button,
|
|
8
|
+
Container,
|
|
9
|
+
Head,
|
|
10
|
+
Heading,
|
|
11
|
+
Html,
|
|
12
|
+
Preview,
|
|
13
|
+
Text,
|
|
14
|
+
} from 'npm:@react-email/components@0.0.22'
|
|
15
|
+
|
|
16
|
+
import { buildBrandStyles, type BrandColors } from './brand.ts'
|
|
17
|
+
|
|
18
|
+
interface RecoveryEmailProps {
|
|
19
|
+
siteName: string
|
|
20
|
+
confirmationUrl: string
|
|
21
|
+
colors: BrandColors
|
|
22
|
+
footerLine: string
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const RecoveryEmail = ({
|
|
26
|
+
siteName,
|
|
27
|
+
confirmationUrl,
|
|
28
|
+
colors,
|
|
29
|
+
footerLine,
|
|
30
|
+
}: RecoveryEmailProps) => {
|
|
31
|
+
const { brandMark, button, container, footer, h1, main, text } = buildBrandStyles(colors)
|
|
32
|
+
return (
|
|
33
|
+
<Html lang="en" dir="ltr">
|
|
34
|
+
<Head />
|
|
35
|
+
<Preview>Reset your password for {siteName}</Preview>
|
|
36
|
+
<Body style={main}>
|
|
37
|
+
<Container style={container}>
|
|
38
|
+
<Text style={brandMark}>{siteName}</Text>
|
|
39
|
+
<Heading style={h1}>Reset your password</Heading>
|
|
40
|
+
<Text style={text}>
|
|
41
|
+
We received a request to reset the password for your {siteName} account.
|
|
42
|
+
Choose a new one using the button below. This link expires shortly.
|
|
43
|
+
</Text>
|
|
44
|
+
<Button style={button} href={confirmationUrl}>
|
|
45
|
+
Reset password
|
|
46
|
+
</Button>
|
|
47
|
+
<Text style={footer}>
|
|
48
|
+
If you didn't request this, you can safely ignore this email — your password
|
|
49
|
+
will not be changed.
|
|
50
|
+
<br />
|
|
51
|
+
{footerLine}
|
|
52
|
+
</Text>
|
|
53
|
+
</Container>
|
|
54
|
+
</Body>
|
|
55
|
+
</Html>
|
|
56
|
+
)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export default RecoveryEmail
|