@aglyn/shared-util-email 1.0.0-beta.203 → 1.0.0-beta.205
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 +3 -3
- package/src/index.d.ts +3 -0
- package/src/index.js +9 -0
- package/src/index.js.map +1 -1
- package/src/lib/email-design-chrome.d.ts +61 -0
- package/src/lib/email-design-chrome.js +99 -0
- package/src/lib/email-design-chrome.js.map +1 -0
- package/src/lib/email-linkify.d.ts +3 -1
- package/src/lib/email-linkify.js +2 -2
- package/src/lib/email-linkify.js.map +1 -1
- package/src/lib/email-palette.d.ts +137 -0
- package/src/lib/email-palette.js +756 -0
- package/src/lib/email-palette.js.map +1 -0
- package/src/lib/email-render.d.ts +25 -0
- package/src/lib/email-render.js +27 -9
- package/src/lib/email-render.js.map +1 -1
- package/src/lib/held-page.d.ts +117 -0
- package/src/lib/held-page.js +172 -0
- package/src/lib/held-page.js.map +1 -0
- package/src/lib/host-email-render.d.ts +34 -7
- package/src/lib/host-email-render.js +69 -25
- package/src/lib/host-email-render.js.map +1 -1
- package/src/lib/hosted-page-screen.js +8 -6
- package/src/lib/hosted-page-screen.js.map +1 -1
- package/src/lib/outbound-phishing-screen.d.ts +24 -0
- package/src/lib/outbound-phishing-screen.js +81 -2
- package/src/lib/outbound-phishing-screen.js.map +1 -1
- package/src/lib/risk-notice-catalog.d.ts +204 -0
- package/src/lib/risk-notice-catalog.js +1702 -0
- package/src/lib/risk-notice-catalog.js.map +1 -0
- package/src/lib/risk-notice-emails.d.ts +25 -0
- package/src/lib/risk-notice-emails.js +182 -0
- package/src/lib/risk-notice-emails.js.map +1 -0
- package/src/lib/sender-readiness.d.ts +155 -0
- package/src/lib/sender-readiness.js +432 -0
- package/src/lib/sender-readiness.js.map +1 -0
- package/src/lib/system-email-catalog.js +50 -1
- package/src/lib/system-email-catalog.js.map +1 -1
- package/src/lib/tenant-email-catalog.d.ts +7 -0
- package/src/lib/tenant-email-catalog.js +183 -13
- package/src/lib/tenant-email-catalog.js.map +1 -1
- package/src/lib/text-email-html.d.ts +26 -0
- package/src/lib/text-email-html.js +56 -1
- package/src/lib/text-email-html.js.map +1 -1
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
/** Every kind of risk event the platform tells people about. */
|
|
18
|
+
export declare const RISK_EVENT_KINDS: readonly ["email-held", "email-released", "email-rejected", "page-held", "page-released", "page-rejected", "page-flagged", "listing-held", "listing-released", "listing-rejected", "domain-flagged", "domain-cleared", "domain-rejected", "billing-payment-flagged", "link-blocked", "card-testing", "gift-card-hold", "sale-fraud-warning", "sale-payment-review", "sale-dispute", "seller-review", "marketplace-sale-review", "marketplace-sale-warning", "publisher-payouts-held", "publisher-payouts-standard", "review-cleared", "review-upheld", "workspace-locked", "workspace-unlocked", "site-locked", "site-unlocked", "domain-locked", "domain-unlocked", "account-locked", "account-unlocked", "feature-locked", "feature-unlocked", "subscription-canceled"];
|
|
19
|
+
export type RiskEventKind = (typeof RISK_EVENT_KINDS)[number];
|
|
20
|
+
/** How loud a notice is. `urgent` kinds are emailed and alert staff at once. */
|
|
21
|
+
export type RiskNoticeSeverity = 'info' | 'warning' | 'urgent';
|
|
22
|
+
/** The actions an OWNER or ADMIN is offered. None of them releases anything. */
|
|
23
|
+
export declare const RISK_OWNER_ACTION_IDS: readonly ["view-details", "edit-and-resubmit", "request-review", "refund-order", "keep-order", "answer-dispute", "update-payment-method", "view-billing", "view-holds", "view-marketplace-sales", "release-gift-cards", "contact-support"];
|
|
24
|
+
export type RiskOwnerActionId = (typeof RISK_OWNER_ACTION_IDS)[number];
|
|
25
|
+
/** The actions STAFF are offered: the real controls, deep-linked. */
|
|
26
|
+
export declare const RISK_STAFF_ACTION_IDS: readonly ["staff-open-row", "staff-release", "staff-reject", "staff-lock-workspace", "staff-lock-site", "staff-unlock", "staff-cancel-subscription", "staff-open-stripe", "staff-view-workspace"];
|
|
27
|
+
export type RiskStaffActionId = (typeof RISK_STAFF_ACTION_IDS)[number];
|
|
28
|
+
/**
|
|
29
|
+
* Where each action goes, as a console path TEMPLATE. `{name}` placeholders
|
|
30
|
+
* are filled by {@link resolveRiskActionHref} from the event; an action whose
|
|
31
|
+
* placeholder has no value is dropped rather than rendered dead.
|
|
32
|
+
*
|
|
33
|
+
* Owner paths are in the stored-notification shape the console's
|
|
34
|
+
* `normalizeNotificationLink` rewrites when followed: `/org/…` becomes the
|
|
35
|
+
* reader's `/{orgSlug}/…` and `/{hostId}/…` becomes `/{orgSlug}/hosts/{sub}/…`.
|
|
36
|
+
* `{itemPath}` is the held item's own page, supplied by the signal source.
|
|
37
|
+
*
|
|
38
|
+
* `risk-notice-routes.spec.ts` (console) resolves every template to a page
|
|
39
|
+
* that exists under `apps/console/app`.
|
|
40
|
+
*/
|
|
41
|
+
export interface RiskActionDefinition {
|
|
42
|
+
label: string;
|
|
43
|
+
/** What happens when it is followed, for the help page and a tooltip. */
|
|
44
|
+
hint: string;
|
|
45
|
+
href: string;
|
|
46
|
+
}
|
|
47
|
+
export declare const RISK_OWNER_ACTIONS: Record<RiskOwnerActionId, RiskActionDefinition>;
|
|
48
|
+
export declare const RISK_STAFF_ACTIONS: Record<RiskStaffActionId, RiskActionDefinition>;
|
|
49
|
+
/** One audience's half of a kind. */
|
|
50
|
+
export interface RiskNoticeCopy {
|
|
51
|
+
/** Short and specific. Also the email subject. */
|
|
52
|
+
title: string;
|
|
53
|
+
/** What we saw, on what, and when. */
|
|
54
|
+
summary: string;
|
|
55
|
+
/** What it means for them. */
|
|
56
|
+
meaning: string;
|
|
57
|
+
/** What to do next, in order. */
|
|
58
|
+
steps: readonly string[];
|
|
59
|
+
}
|
|
60
|
+
export interface RiskNoticeDefinition {
|
|
61
|
+
kind: RiskEventKind;
|
|
62
|
+
severity: RiskNoticeSeverity;
|
|
63
|
+
/**
|
|
64
|
+
* Whether the owners and admins are emailed as well as notified in the
|
|
65
|
+
* console. The email is transactional account mail from the platform's own
|
|
66
|
+
* sender: it ignores notification preferences and marketing consent, and
|
|
67
|
+
* it reaches a locked workspace.
|
|
68
|
+
*/
|
|
69
|
+
emailOwners: boolean;
|
|
70
|
+
/** Whether staff are alerted. False for events staff themselves caused. */
|
|
71
|
+
alertStaff: boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Whether the notice always goes out, even while the workspace is over its
|
|
74
|
+
* burst allowance. Locks, lifts and cancellations are never folded into a
|
|
75
|
+
* digest: each one changes what the owner can do.
|
|
76
|
+
*/
|
|
77
|
+
neverDigest: boolean;
|
|
78
|
+
/**
|
|
79
|
+
* An owner can ask for a review. Only kinds with an abuse-queue row to
|
|
80
|
+
* append to are reviewable.
|
|
81
|
+
*/
|
|
82
|
+
reviewable: boolean;
|
|
83
|
+
/** The kinds staff decisions on this kind's row close it with. */
|
|
84
|
+
closesWith?: {
|
|
85
|
+
released: RiskEventKind;
|
|
86
|
+
rejected: RiskEventKind;
|
|
87
|
+
};
|
|
88
|
+
/** Also tell the managers of the site the event is on, not just the workspace's. */
|
|
89
|
+
includeSiteManagers: boolean;
|
|
90
|
+
/** The help page section that explains it. */
|
|
91
|
+
helpAnchor: string;
|
|
92
|
+
owner: RiskNoticeCopy & {
|
|
93
|
+
actions: readonly RiskOwnerActionId[];
|
|
94
|
+
};
|
|
95
|
+
staff: Pick<RiskNoticeCopy, 'title' | 'summary'> & {
|
|
96
|
+
actions: readonly RiskStaffActionId[];
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* The customer help page every notice links to. A path on the docs site;
|
|
101
|
+
* the server prefixes the docs origin.
|
|
102
|
+
*/
|
|
103
|
+
export declare const RISK_NOTICE_HELP_PATH = "/help/holds-and-reviews";
|
|
104
|
+
/**
|
|
105
|
+
* Merge tokens a notice may use. The server fills each from the event; a
|
|
106
|
+
* token the event does not carry renders as the fallback noted here, never
|
|
107
|
+
* as a hole in a sentence.
|
|
108
|
+
*/
|
|
109
|
+
export declare const RISK_NOTICE_TOKENS: {
|
|
110
|
+
readonly 'workspace.name': "The workspace name, or \"your workspace\".";
|
|
111
|
+
readonly 'item.label': "What the notice is about, in the owner's words: the campaign \"Spring sale\", the page /pricing, order 1042.";
|
|
112
|
+
readonly 'item.url': "The absolute console link to the item.";
|
|
113
|
+
readonly occurredAt: "When it happened, in UTC.";
|
|
114
|
+
readonly reference: "The case reference staff know it by (HS-…, PF-…).";
|
|
115
|
+
readonly 'holds.url': "The workspace's Holds & reviews page.";
|
|
116
|
+
readonly 'help.url': "The help page for holds and reviews.";
|
|
117
|
+
readonly 'support.email': "The operator's support address.";
|
|
118
|
+
readonly 'lock.message': "The message staff wrote when they applied the lock.";
|
|
119
|
+
readonly 'lock.affected': "What the lock or pause covers: sites, sessions, billing.";
|
|
120
|
+
readonly amount: "The payment amount, when there is one.";
|
|
121
|
+
readonly 'evidence.dueBy': "The date dispute evidence is due, when Stripe gave one.";
|
|
122
|
+
readonly 'staff.evidence': "Staff only: what the screen or Stripe reported.";
|
|
123
|
+
};
|
|
124
|
+
export type RiskNoticeToken = keyof typeof RISK_NOTICE_TOKENS;
|
|
125
|
+
export declare const RISK_NOTICE_CATALOG: Readonly<Record<RiskEventKind, RiskNoticeDefinition>>;
|
|
126
|
+
/**
|
|
127
|
+
* The kinds whose email wears the WORKSPACE's brand: routine notices about
|
|
128
|
+
* the workspace's own customers' payments, which read as the workspace's own
|
|
129
|
+
* operations. Every other kind — a hold, a lock, a lift, a cancellation, a
|
|
130
|
+
* review — is the platform acting, and is sent in the platform's brand.
|
|
131
|
+
*/
|
|
132
|
+
export declare const RISK_NOTICE_WORKSPACE_BRANDED: ReadonlySet<RiskEventKind>;
|
|
133
|
+
/**
|
|
134
|
+
* The kinds that CLOSE another: a release, a rejection, a review's end. A
|
|
135
|
+
* closing notice never re-stamps its row, so the row keeps naming the kind
|
|
136
|
+
* it was opened as — and a second decision closes it again correctly.
|
|
137
|
+
*/
|
|
138
|
+
export declare const RISK_NOTICE_CLOSING_KINDS: ReadonlySet<RiskEventKind>;
|
|
139
|
+
/** The catalog entry for a kind. */
|
|
140
|
+
export declare function riskNoticeDefinition(kind: RiskEventKind): RiskNoticeDefinition;
|
|
141
|
+
export declare function isRiskEventKind(value: unknown): value is RiskEventKind;
|
|
142
|
+
/** The values a notice is rendered with. Every value is optional. */
|
|
143
|
+
export type RiskNoticeValues = Partial<Record<RiskNoticeToken | 'brand.productName', string | null | undefined>>;
|
|
144
|
+
/** Fill `{{token}}`s from `values`, falling back to words, never to a hole. */
|
|
145
|
+
export declare function renderRiskNoticeText(template: string, values: RiskNoticeValues): string;
|
|
146
|
+
/** The values an action href may use. */
|
|
147
|
+
export interface RiskActionParams {
|
|
148
|
+
itemPath?: string | null;
|
|
149
|
+
noticeId?: string | null;
|
|
150
|
+
reviewId?: string | null;
|
|
151
|
+
orgId?: string | null;
|
|
152
|
+
hostId?: string | null;
|
|
153
|
+
stripeUrl?: string | null;
|
|
154
|
+
lockScope?: string | null;
|
|
155
|
+
lockTargetId?: string | null;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* An action's href with its placeholders filled, or null when one of them
|
|
159
|
+
* has no value — an action that would lead nowhere is not offered.
|
|
160
|
+
*/
|
|
161
|
+
export declare function resolveRiskActionHref(action: RiskActionDefinition, params: RiskActionParams): string | null;
|
|
162
|
+
/** One action, ready to render. */
|
|
163
|
+
export interface ResolvedRiskAction {
|
|
164
|
+
id: RiskOwnerActionId | RiskStaffActionId;
|
|
165
|
+
label: string;
|
|
166
|
+
hint: string;
|
|
167
|
+
href: string;
|
|
168
|
+
}
|
|
169
|
+
/** A kind's owner actions that lead somewhere, in catalog order. */
|
|
170
|
+
export declare function resolveOwnerRiskActions(kind: RiskEventKind, params: RiskActionParams): ResolvedRiskAction[];
|
|
171
|
+
/** A kind's staff actions that lead somewhere, in catalog order. */
|
|
172
|
+
export declare function resolveStaffRiskActions(kind: RiskEventKind, params: RiskActionParams): ResolvedRiskAction[];
|
|
173
|
+
/** An owner notice as plain text: title, summary, meaning, numbered steps. */
|
|
174
|
+
export declare function renderOwnerRiskNotice(kind: RiskEventKind, values: RiskNoticeValues): {
|
|
175
|
+
title: string;
|
|
176
|
+
summary: string;
|
|
177
|
+
meaning: string;
|
|
178
|
+
steps: string[];
|
|
179
|
+
};
|
|
180
|
+
/** A staff alert as plain text. */
|
|
181
|
+
export declare function renderStaffRiskNotice(kind: RiskEventKind, values: RiskNoticeValues): {
|
|
182
|
+
title: string;
|
|
183
|
+
summary: string;
|
|
184
|
+
};
|
|
185
|
+
/** The System emails catalog key a kind's owner email is designed under. */
|
|
186
|
+
export declare function riskNoticeEmailKey(kind: RiskEventKind): string;
|
|
187
|
+
/** The key the burst digest is designed under. */
|
|
188
|
+
export declare const RISK_NOTICE_DIGEST_EMAIL_KEY = "risk-digest";
|
|
189
|
+
/**
|
|
190
|
+
* The kind an abuse-queue row is about, so the staff queue renders the
|
|
191
|
+
* catalog's text for EVERY row a risk source filed — including rows filed
|
|
192
|
+
* before the row carried its notice. The stamp `notifyRiskEvent` writes
|
|
193
|
+
* (`riskNotice.kind`) wins; otherwise the row's own shape says it. Null for
|
|
194
|
+
* a row from the public report form, which is not a risk event.
|
|
195
|
+
*/
|
|
196
|
+
export declare function riskKindForAbuseRow(row: {
|
|
197
|
+
source?: unknown;
|
|
198
|
+
heldSend?: {
|
|
199
|
+
kind?: unknown;
|
|
200
|
+
} | null;
|
|
201
|
+
riskNotice?: {
|
|
202
|
+
kind?: unknown;
|
|
203
|
+
} | null;
|
|
204
|
+
}): RiskEventKind | null;
|