@aglyn/plugins-email 1.0.0-beta.143
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/LICENSE +201 -0
- package/README.md +7 -0
- package/package.json +58 -0
- package/src/index.d.ts +35 -0
- package/src/index.js +35 -0
- package/src/index.js.map +1 -0
- package/src/lib/components/campaign-design-create-widget.d.ts +21 -0
- package/src/lib/components/campaign-design-create-widget.js +61 -0
- package/src/lib/components/campaign-design-create-widget.js.map +1 -0
- package/src/lib/components/campaign-sender-editor-widget.d.ts +18 -0
- package/src/lib/components/campaign-sender-editor-widget.js +39 -0
- package/src/lib/components/campaign-sender-editor-widget.js.map +1 -0
- package/src/lib/components/campaign-topic-options-widget.d.ts +19 -0
- package/src/lib/components/campaign-topic-options-widget.js +48 -0
- package/src/lib/components/campaign-topic-options-widget.js.map +1 -0
- package/src/lib/components/campaign-topic-select.d.ts +32 -0
- package/src/lib/components/campaign-topic-select.js +87 -0
- package/src/lib/components/campaign-topic-select.js.map +1 -0
- package/src/lib/components/dynamic-list-rule-fields.d.ts +173 -0
- package/src/lib/components/dynamic-list-rule-fields.js +1473 -0
- package/src/lib/components/dynamic-list-rule-fields.js.map +1 -0
- package/src/lib/components/email-blocks.d.ts +111 -0
- package/src/lib/components/email-blocks.js +875 -0
- package/src/lib/components/email-blocks.js.map +1 -0
- package/src/lib/components/email-design-preview.d.ts +62 -0
- package/src/lib/components/email-design-preview.js +174 -0
- package/src/lib/components/email-design-preview.js.map +1 -0
- package/src/lib/components/email-screens-card.d.ts +42 -0
- package/src/lib/components/email-screens-card.js +277 -0
- package/src/lib/components/email-screens-card.js.map +1 -0
- package/src/lib/components/email-template-detail.d.ts +48 -0
- package/src/lib/components/email-template-detail.js +681 -0
- package/src/lib/components/email-template-detail.js.map +1 -0
- package/src/lib/components/email-topic-detail.d.ts +32 -0
- package/src/lib/components/email-topic-detail.js +293 -0
- package/src/lib/components/email-topic-detail.js.map +1 -0
- package/src/lib/components/email-topics-card.d.ts +46 -0
- package/src/lib/components/email-topics-card.js +327 -0
- package/src/lib/components/email-topics-card.js.map +1 -0
- package/src/lib/components/email-zones.d.ts +28 -0
- package/src/lib/components/email-zones.js +20 -0
- package/src/lib/components/email-zones.js.map +1 -0
- package/src/lib/components/emails-console-page.d.ts +32 -0
- package/src/lib/components/emails-console-page.js +229 -0
- package/src/lib/components/emails-console-page.js.map +1 -0
- package/src/lib/components/emails-console-sections.d.ts +36 -0
- package/src/lib/components/emails-console-sections.js +108 -0
- package/src/lib/components/emails-console-sections.js.map +1 -0
- package/src/lib/components/list-detail-card.d.ts +47 -0
- package/src/lib/components/list-detail-card.js +273 -0
- package/src/lib/components/list-detail-card.js.map +1 -0
- package/src/lib/components/list-edit-card.d.ts +11 -0
- package/src/lib/components/list-edit-card.js +287 -0
- package/src/lib/components/list-edit-card.js.map +1 -0
- package/src/lib/components/list-import-drawer.d.ts +22 -0
- package/src/lib/components/list-import-drawer.js +662 -0
- package/src/lib/components/list-import-drawer.js.map +1 -0
- package/src/lib/components/list-members-panel.d.ts +94 -0
- package/src/lib/components/list-members-panel.js +686 -0
- package/src/lib/components/list-members-panel.js.map +1 -0
- package/src/lib/components/lists-card.d.ts +28 -0
- package/src/lib/components/lists-card.js +377 -0
- package/src/lib/components/lists-card.js.map +1 -0
- package/src/lib/components/sending-domain-detail.d.ts +26 -0
- package/src/lib/components/sending-domain-detail.js +496 -0
- package/src/lib/components/sending-domain-detail.js.map +1 -0
- package/src/lib/components/sending-domains-card.d.ts +33 -0
- package/src/lib/components/sending-domains-card.js +962 -0
- package/src/lib/components/sending-domains-card.js.map +1 -0
- package/src/lib/components/sending-sender-drawer.d.ts +94 -0
- package/src/lib/components/sending-sender-drawer.js +543 -0
- package/src/lib/components/sending-sender-drawer.js.map +1 -0
- package/src/lib/components/suppressions-card.d.ts +49 -0
- package/src/lib/components/suppressions-card.js +639 -0
- package/src/lib/components/suppressions-card.js.map +1 -0
- package/src/lib/components/use-org-email-topics.d.ts +79 -0
- package/src/lib/components/use-org-email-topics.js +111 -0
- package/src/lib/components/use-org-email-topics.js.map +1 -0
- package/src/lib/constants/bundle-common.d.ts +18 -0
- package/src/lib/constants/bundle-common.js +18 -0
- package/src/lib/constants/bundle-common.js.map +1 -0
- package/src/lib/hooks/use-org-company-options.d.ts +20 -0
- package/src/lib/hooks/use-org-company-options.js +138 -0
- package/src/lib/hooks/use-org-company-options.js.map +1 -0
- package/src/lib/hooks/use-org-contact-fields.d.ts +40 -0
- package/src/lib/hooks/use-org-contact-fields.js +91 -0
- package/src/lib/hooks/use-org-contact-fields.js.map +1 -0
- package/src/lib/hooks/use-org-contact-segments.d.ts +16 -0
- package/src/lib/hooks/use-org-contact-segments.js +55 -0
- package/src/lib/hooks/use-org-contact-segments.js.map +1 -0
- package/src/lib/hooks/use-org-crm-views.d.ts +8 -0
- package/src/lib/hooks/use-org-crm-views.js +74 -0
- package/src/lib/hooks/use-org-crm-views.js.map +1 -0
- package/src/lib/hooks/use-org-lists.d.ts +8 -0
- package/src/lib/hooks/use-org-lists.js +47 -0
- package/src/lib/hooks/use-org-lists.js.map +1 -0
- package/src/lib/model/email-design-document.d.ts +52 -0
- package/src/lib/model/email-design-document.js +62 -0
- package/src/lib/model/email-design-document.js.map +1 -0
- package/src/lib/model/index.d.ts +64 -0
- package/src/lib/model/index.js +71 -0
- package/src/lib/model/index.js.map +1 -0
- package/src/lib/model/sending-domain-status.d.ts +99 -0
- package/src/lib/model/sending-domain-status.js +196 -0
- package/src/lib/model/sending-domain-status.js.map +1 -0
- package/src/lib/model/template-provenance.d.ts +113 -0
- package/src/lib/model/template-provenance.js +107 -0
- package/src/lib/model/template-provenance.js.map +1 -0
- package/src/lib/model/template-report.d.ts +158 -0
- package/src/lib/model/template-report.js +249 -0
- package/src/lib/model/template-report.js.map +1 -0
- package/src/lib/plugin.d.ts +27 -0
- package/src/lib/plugin.js +163 -0
- package/src/lib/plugin.js.map +1 -0
- package/src/lib/server-console.d.ts +116 -0
- package/src/lib/server-console.js +422 -0
- package/src/lib/server-console.js.map +1 -0
- package/src/lib/server-email-drafts.d.ts +104 -0
- package/src/lib/server-email-drafts.js +381 -0
- package/src/lib/server-email-drafts.js.map +1 -0
- package/src/lib/server-list-gate.d.ts +183 -0
- package/src/lib/server-list-gate.js +365 -0
- package/src/lib/server-list-gate.js.map +1 -0
- package/src/lib/server-list-import.d.ts +199 -0
- package/src/lib/server-list-import.js +632 -0
- package/src/lib/server-list-import.js.map +1 -0
- package/src/lib/server-suppressions.d.ts +135 -0
- package/src/lib/server-suppressions.js +295 -0
- package/src/lib/server-suppressions.js.map +1 -0
- package/src/lib/server.d.ts +19 -0
- package/src/lib/server.js +834 -0
- package/src/lib/server.js.map +1 -0
- package/src/lib/site.d.ts +26 -0
- package/src/lib/site.js +81 -0
- package/src/lib/site.js.map +1 -0
- package/src/lib/unsubscribe-link.d.ts +311 -0
- package/src/lib/unsubscribe-link.js +398 -0
- package/src/lib/unsubscribe-link.js.map +1 -0
- package/src/lib/utils/create-email-screen.d.ts +59 -0
- package/src/lib/utils/create-email-screen.js +59 -0
- package/src/lib/utils/create-email-screen.js.map +1 -0
- package/src/lib/utils/generate-preset-id.d.ts +19 -0
- package/src/lib/utils/generate-preset-id.js +25 -0
- package/src/lib/utils/generate-preset-id.js.map +1 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../libs/plugins/email/src/lib/plugin.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport * as Aglyn from '@aglyn/aglyn'\nimport { registerPluginZone } from '@aglyn/aglyn/plugin-manager/plugin-zones'\nimport { mdiEmailOutline } from '@aglyn/shared-data-mdi'\nimport { lazy } from 'react'\nimport {\n EMAIL_MESSAGES_ZONE,\n EMAIL_TEMPLATE_RECIPIENTS_ZONE,\n} from './components/email-zones'\nimport { EMAILS_CONSOLE_SECTIONS } from './components/emails-console-sections'\nimport { BUNDLE_ID } from './constants/bundle-common'\n\n/** Code-split: the Emails console page only loads when opened. */\nconst EmailsConsolePage = lazy(() => import('./components/emails-console-page'))\n\n/*\n * What this plugin draws inside a campaign's own pages, each loaded only where\n * the campaign owner's zone is on screen.\n */\nconst CampaignTopicSelect = lazy(\n () => import('./components/campaign-topic-select'),\n)\nconst CampaignTopicOptionsWidget = lazy(\n () => import('./components/campaign-topic-options-widget'),\n)\nconst CampaignSenderEditorWidget = lazy(\n () => import('./components/campaign-sender-editor-widget'),\n)\nconst CampaignDesignCreateWidget = lazy(\n () => import('./components/campaign-design-create-widget'),\n)\nconst EmailDesignPreview = lazy(\n () => import('./components/email-design-preview'),\n)\n\n/**\n * Console half (AGL-395): registers the Emails nav item + page in the\n * ConsoleExtension registry. Safe to call at console app load — the page is\n * lazy, so no besigner/canvas code loads. The shell renders the Emails nav\n * item and, via its generic plugin route, the page (the messages and their\n * composer, the templates, the audience lists, the topic catalog, the sending\n * identities and the suppression list) — with no edit to the console's own\n * nav or page files.\n */\nexport function registerEmailConsole(): void {\n /*\n * The two places this plugin's pages hand over to whichever plugin owns\n * campaigns. A message is one send of a campaign and every action on it is\n * that plugin's route, so the Messages section is a zone this page hosts\n * rather than pages this plugin imports; the same holds for the recipients\n * table under a template's report. Named, because a spec calls this\n * registrar without the loader.\n */\n registerPluginZone(\n {\n zone: EMAIL_MESSAGES_ZONE,\n label: 'The Emails page’s Messages section',\n surface: 'console',\n layout: 'bare',\n description:\n 'The whole body of `/emails/messages` and the routes under it. A widget here is handed the site, the Emails page’s base path and the segments under `messages`, and draws the list, one message’s report or its composer.',\n },\n { pluginId: BUNDLE_ID },\n )\n registerPluginZone(\n {\n zone: EMAIL_TEMPLATE_RECIPIENTS_ZONE,\n label: 'Who received a template’s emails',\n surface: 'console',\n description:\n 'On one template’s page, under its report. A widget here lists the recipients of every send built from that template; it is handed the site and the template’s screen id.',\n },\n { pluginId: BUNDLE_ID },\n )\n Aglyn.registerConsoleExtension({\n pluginId: BUNDLE_ID,\n displayName: 'Email',\n /*\n * WHO may open the email console, declared so the shell enforces it.\n *\n * The audiences section reads `orgs/{orgId}/lists/{listId}/members`, and\n * those members are enrolled CONTACTS — an address, a name, and the\n * consent basis recording why the person may be mailed. That is the same\n * org-shared people data the CRM holds, reached from a different page.\n *\n * The rules gate those reads on `isOrgWideMember()` ALONE, with no role\n * condition, so org-wide membership of any role is enough to list every\n * audience the organization has and everybody on it. An org VIEWER — the\n * role that exists to read and change nothing — therefore reads the whole\n * marketing audience today. `data.manage` is what closes that: it\n * defaults to owner, admin and editor, so the population it admits is\n * exactly the one `server-list-gate.ts` accepts a list write from, and\n * the viewer it excludes is the reader the rules never excluded.\n *\n * `data.manage` rather than a key of this plugin's own for the reason the\n * catalog gives for refusing a `marketing.manage`: campaigns are written\n * client-direct against rules that gate on the HOST role, so a new\n * org-level key would name an action with no org-level boundary under it.\n * `data.manage` is not in that position — it already governs the\n * org-shared data this surface exposes, and the list gate already reads\n * the roles it defaults to.\n *\n * A SITE COLLABORATOR holding it opens the page, and the answer is NOT\n * the one Contacts reached. There the listener is scoped and the rules\n * prove the same predicate per document; here the audiences read demands\n * `isOrgWideMember()`, which a collaborator is not, so the org-shared\n * half is already refused beneath the console and the half that remains —\n * this site's own messages, templates and sending identities — is theirs.\n * Refusing the surface outright would take that away to close nothing.\n */\n permission: 'data.manage',\n /*\n * The mail a campaign rides on is this plugin's — the topic catalog, the\n * sending identities, the design document and its renderer — so each is\n * drawn here, in a zone the campaign owner's composer and message page\n * host. Every one reports through a callback; none writes a campaign.\n */\n widgets: [\n {\n slot: 'campaignTopicSelect',\n widgetId: 'email-campaign-topic-select',\n title: 'Topic',\n Component: CampaignTopicSelect,\n },\n {\n slot: 'campaignTopicOptions',\n widgetId: 'email-campaign-topic-options',\n title: 'Topics',\n Component: CampaignTopicOptionsWidget,\n },\n {\n slot: 'campaignSenderEditor',\n widgetId: 'email-campaign-sender-editor',\n title: 'Add a sender',\n Component: CampaignSenderEditorWidget,\n },\n {\n slot: 'campaignDesignCreate',\n widgetId: 'email-campaign-design-create',\n title: 'Design this email',\n Component: CampaignDesignCreateWidget,\n },\n {\n slot: 'campaignDesignPreview',\n widgetId: 'email-campaign-design-preview',\n title: 'Preview',\n Component: EmailDesignPreview,\n },\n ],\n navItems: [\n {\n label: 'Emails',\n href: '/emails',\n icon: { path: mdiEmailOutline.path },\n // Sections as ROUTES (AGL-2501): `/emails/messages` and friends are\n // real URLs the shell resolves and gates, so the page mounts the one\n // being read instead of subscribing all six.\n sections: EMAILS_CONSOLE_SECTIONS,\n header: {\n title: 'Emails',\n icon: { path: mdiEmailOutline.path },\n docsTopic: 'emailCampaigns',\n },\n Component: EmailsConsolePage,\n },\n ],\n })\n}\n\nexport * from './site'\n"],"names":["Aglyn","registerPluginZone","mdiEmailOutline","lazy","EMAIL_MESSAGES_ZONE","EMAIL_TEMPLATE_RECIPIENTS_ZONE","EMAILS_CONSOLE_SECTIONS","BUNDLE_ID","EmailsConsolePage","CampaignTopicSelect","CampaignTopicOptionsWidget","CampaignSenderEditorWidget","CampaignDesignCreateWidget","EmailDesignPreview","registerEmailConsole","zone","label","surface","layout","description","pluginId","registerConsoleExtension","displayName","permission","widgets","slot","widgetId","title","Component","navItems","href","icon","path","sections","header","docsTopic"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,YAAYA,WAAW,eAAc;AACrC,SAASC,kBAAkB,QAAQ,2CAA0C;AAC7E,SAASC,eAAe,QAAQ,yBAAwB;AACxD,SAASC,IAAI,QAAQ,QAAO;AAC5B,SACEC,mBAAmB,EACnBC,8BAA8B,QACzB,8BAA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gBACpE,qEAAqE;gBACrE,6CAA6C;gBAC7CC,UAAU3B;gBACV4B,QAAQ;oBACNP,OAAO;oBACPI,MAAM;wBAAEC,MAAM9B,gBAAgB8B,IAAI;oBAAC;oBACnCG,WAAW;gBACb;gBACAP,WAAWpB;YACb;SACD;IACH;AACF;AAEA,cAAc,YAAQ"}
|
|
@@ -0,0 +1,116 @@
|
|
|
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
|
+
import { type PluginApiHandler } from '@aglyn/aglyn/server';
|
|
18
|
+
/** `source` stamped on every membership these routes write. */
|
|
19
|
+
export declare const CONSOLE_ADD_SOURCE = "console:list-add";
|
|
20
|
+
export { LIST_MEMBER_BATCH_MAX, resolveAddresses, resolveListContext, type AddressResolution, type AddressVerdict, type ListContext, type ResolvedBatch, } from './server-list-gate';
|
|
21
|
+
/**
|
|
22
|
+
* `POST email/list-members-preview` — what adding these addresses would do.
|
|
23
|
+
*
|
|
24
|
+
* Reads only, and reached by an explicit act — typing an address or pasting a
|
|
25
|
+
* column — never on mount. It exists because the answer needs three things
|
|
26
|
+
* the browser cannot have: the org's contacts (rules put them behind org-wide
|
|
27
|
+
* membership, which the acting console session may not hold) and both
|
|
28
|
+
* suppression lists. Computing any of it client-side would be a second copy
|
|
29
|
+
* of the rule, on the surface whose whole job is to tell the operator the
|
|
30
|
+
* truth about what is about to happen.
|
|
31
|
+
*
|
|
32
|
+
* It takes no attestation and has nowhere to put one. The preview answers
|
|
33
|
+
* what is TRUE about each person, which is the input to the operator's
|
|
34
|
+
* decision rather than a function of it — a preview whose numbers moved as
|
|
35
|
+
* the box was ticked would not be a count anybody could stand behind.
|
|
36
|
+
*/
|
|
37
|
+
export declare const emailListMembersPreviewHandler: PluginApiHandler;
|
|
38
|
+
/**
|
|
39
|
+
* `POST email/list-members-add` — put these addresses on the list.
|
|
40
|
+
*
|
|
41
|
+
* Body: `{ hostId, listId, email | emails[], name?, attestConsent? }`.
|
|
42
|
+
* `attestConsent` is the operator STATING that they have these people's
|
|
43
|
+
* permission; it is not a way to name a basis, because the pass-through basis
|
|
44
|
+
* is derived server-side from each person's own record.
|
|
45
|
+
*
|
|
46
|
+
* ## One attestation, for the count the operator was shown
|
|
47
|
+
*
|
|
48
|
+
* The batch carries a single assertion because it is a single act: an
|
|
49
|
+
* operator pasting a column is making one claim about where that column came
|
|
50
|
+
* from. What makes that safe is that the claim is applied per address by the
|
|
51
|
+
* same function the preview ran, so it reaches only the addresses that
|
|
52
|
+
* actually need it — an address with a stored opt-in keeps its own basis and
|
|
53
|
+
* its own date, and an address nothing can enroll is refused with the
|
|
54
|
+
* attestation on the table.
|
|
55
|
+
*
|
|
56
|
+
* ## Partial success is the honest answer
|
|
57
|
+
*
|
|
58
|
+
* A batch where one address is suppressed and forty are fine is not a failed
|
|
59
|
+
* request. Every address comes back with what happened to it, so 200 here
|
|
60
|
+
* means "the request was processed", never "everybody was added" — the caller
|
|
61
|
+
* reads the per-address verdicts, which is why they are returned rather than
|
|
62
|
+
* a count.
|
|
63
|
+
*/
|
|
64
|
+
export declare const emailListMembersAddHandler: PluginApiHandler;
|
|
65
|
+
/**
|
|
66
|
+
* WHO A SET OF FILTERS FINDS, and what would happen if you added them.
|
|
67
|
+
*
|
|
68
|
+
* ## The gap it fills
|
|
69
|
+
*
|
|
70
|
+
* The filters behind a list could only ever be MATERIALIZED — the sweep wrote
|
|
71
|
+
* the matching people straight into the membership. A merchant could not ask
|
|
72
|
+
* "who is this" without committing to it, and a fixed list could not use the
|
|
73
|
+
* filters at all: its only way to gain a member was somebody typing or pasting
|
|
74
|
+
* an address. This answers the question without writing anything.
|
|
75
|
+
*
|
|
76
|
+
* ## It is the same consent gate, not a second one
|
|
77
|
+
*
|
|
78
|
+
* The addresses the scan finds are put through {@link resolveAddresses} — the
|
|
79
|
+
* exact function `email/list-members-preview` uses — so a suppressed address
|
|
80
|
+
* is reported as refused here, and somebody with no opt-in on record is
|
|
81
|
+
* reported as needing an attestation here, before any of them is offered for
|
|
82
|
+
* adding. That is deliberate and load-bearing: a bulk path that skipped the
|
|
83
|
+
* check would be a way to fill a list with people the one-at-a-time path
|
|
84
|
+
* refuses, which is the defect class this product already has a register entry
|
|
85
|
+
* for. The ADD still goes through `email/list-members-add`, which re-runs
|
|
86
|
+
* every check server-side, so this preview is an honest readout rather than a
|
|
87
|
+
* permission.
|
|
88
|
+
*
|
|
89
|
+
* ## What it will not do
|
|
90
|
+
*
|
|
91
|
+
* It writes nothing, it enrolls nobody, and it compares no count against any
|
|
92
|
+
* limit. The batch cap below bounds how many addresses it hands back for a
|
|
93
|
+
* single add — the scan itself still reports how many people it MATCHED, so a
|
|
94
|
+
* merchant is told the audience is larger than one batch rather than shown a
|
|
95
|
+
* truncated number as if it were the whole.
|
|
96
|
+
*/
|
|
97
|
+
export declare const emailListRulePreviewHandler: PluginApiHandler;
|
|
98
|
+
/**
|
|
99
|
+
* Console API registration.
|
|
100
|
+
*
|
|
101
|
+
* None of these is on the machine-path exemption list in
|
|
102
|
+
* `plugin-api-rate-limit.ts`, so each is counted against the console
|
|
103
|
+
* dispatcher's per-subject budget — the ceiling that bounds a surface which
|
|
104
|
+
* puts a person into a marketing audience, and which scans a whole contact
|
|
105
|
+
* silo to work out who that would be.
|
|
106
|
+
*
|
|
107
|
+
* The limiter these are counted by is the CONSOLE one,
|
|
108
|
+
* `consoleApiRateLimitRefusal`. The visitor limiter is a different limiter on
|
|
109
|
+
* a different dispatcher: `visitorWriteRateLimitRefusal` is installed only in
|
|
110
|
+
* `apps/tenant`, and no request to these routes has ever passed through it.
|
|
111
|
+
* The two share a counter and an exemption list and nothing else — the console
|
|
112
|
+
* key is the authenticated subject, because on an authenticated surface a
|
|
113
|
+
* per-(site, IP) bucket both isolates nothing the identity has not already
|
|
114
|
+
* isolated and hands one operator a fresh budget per site.
|
|
115
|
+
*/
|
|
116
|
+
export declare function registerEmailConsoleApi(): void;
|
|
@@ -0,0 +1,422 @@
|
|
|
1
|
+
import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright 2026 Aglyn LLC
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/ /**
|
|
18
|
+
* Putting somebody on an email list from the Emails console.
|
|
19
|
+
*
|
|
20
|
+
* The audience card could create a list and delete a list and nothing else:
|
|
21
|
+
* no way to see who was on one, no way to add anybody, no way to take anybody
|
|
22
|
+
* off. Every member document in production arrived from a capture surface —
|
|
23
|
+
* the newsletter handler, the workflow `enrollList` step, the dynamic-list
|
|
24
|
+
* materializer, the Inbox assignment — so the one act a merchant most expects
|
|
25
|
+
* of a list, "add this person", was the one act the product refused.
|
|
26
|
+
*
|
|
27
|
+
* ## Why this is a route and not a client write
|
|
28
|
+
*
|
|
29
|
+
* Rules put `orgs/{orgId}/lists/{listId}/members` behind org-wide membership,
|
|
30
|
+
* and until now that block allowed a client CREATE. Nothing used it, and it
|
|
31
|
+
* was the whole feature waiting to be built wrong: a browser that can write a
|
|
32
|
+
* member document can write `marketingConsent: true` beside an address it has
|
|
33
|
+
* never checked, which is a consent record minted by pressing a button. The
|
|
34
|
+
* rules now deny client create and update on that collection, and this route
|
|
35
|
+
* is the writer — through `enrollListMember`, which owns the document id, and
|
|
36
|
+
* through the shared `list-assignment-policy`, which owns the basis.
|
|
37
|
+
*
|
|
38
|
+
* ## The same policy the Inbox uses, not a second one
|
|
39
|
+
*
|
|
40
|
+
* `assignmentBasis` and `assignmentReadout` are imported from the framework,
|
|
41
|
+
* where they moved when this became their second caller. There is no third
|
|
42
|
+
* consent basis and no console-only override: a stored `declined` refuses
|
|
43
|
+
* here exactly as it refuses there, an attestation is recorded with the
|
|
44
|
+
* account that made it, and a stored opt-in is carried across with the date
|
|
45
|
+
* the PERSON set rather than the date somebody pressed Add.
|
|
46
|
+
*
|
|
47
|
+
* ## Reads only, until the operator has seen the count
|
|
48
|
+
*
|
|
49
|
+
* `email/list-members-preview` writes nothing. It answers, per address, what
|
|
50
|
+
* would happen and why, so the attestation the operator gives on the second
|
|
51
|
+
* call is given with the numbers in front of them. Both routes run the SAME
|
|
52
|
+
* resolution over the SAME inputs — `resolveAddresses` — so the summary they
|
|
53
|
+
* were shown is the summary that acts.
|
|
54
|
+
*
|
|
55
|
+
* ## Finding people is a read, and it uses the same gate
|
|
56
|
+
*
|
|
57
|
+
* `email/list-rule-preview` answers "who do these filters select" without
|
|
58
|
+
* writing anything, so a fixed list can be filled from a search rather than
|
|
59
|
+
* from somebody typing addresses one at a time. It runs the addresses it finds
|
|
60
|
+
* through `resolveAddresses` as well — a bulk path that reached the membership
|
|
61
|
+
* without the suppression check and the attestation would be a way to enroll
|
|
62
|
+
* exactly the people the single-address path refuses.
|
|
63
|
+
*
|
|
64
|
+
* ## The gate itself is `server-list-gate.ts`
|
|
65
|
+
*
|
|
66
|
+
* Who may change a list's membership, and what is true about each address, are
|
|
67
|
+
* asked by three route modules now: these two, and the file importer in
|
|
68
|
+
* `server-list-import.ts`. They live in a module of their own so the importer
|
|
69
|
+
* shares this file's answer rather than importing this file — which would be a
|
|
70
|
+
* cycle, and a cycle whose module-level constants would evaluate in whichever
|
|
71
|
+
* order the loader happened to reach them.
|
|
72
|
+
*/ import { registerEmailDesignDraftWriter } from "./server-email-drafts.js";
|
|
73
|
+
import { registerEmailSuppressionsApi } from "./server-suppressions.js";
|
|
74
|
+
import { registerEmailListImportApi } from "./server-list-import.js";
|
|
75
|
+
import { LIST_MEMBER_BATCH_MAX, readAddresses, resolveAddresses, resolveListContext } from "./server-list-gate.js";
|
|
76
|
+
import { ASSIGNMENT_REFUSAL_MESSAGES, assignmentBasis, dynamicListRuleIsEmpty, normalizeDynamicListRule, readMarketingBasis, registerPluginApiRoute } from "@aglyn/aglyn/server";
|
|
77
|
+
import { collectDynamicListCandidates, enrollListMember } from "@aglyn/tenant-data-admin";
|
|
78
|
+
/** `source` stamped on every membership these routes write. */ export const CONSOLE_ADD_SOURCE = 'console:list-add';
|
|
79
|
+
/*
|
|
80
|
+
* Re-exported, not redefined. `@aglyn/plugins-email/server` has published
|
|
81
|
+
* these names since the add path shipped, and the console panel and its specs
|
|
82
|
+
* import them from there; moving the gate must not move the plugin's public
|
|
83
|
+
* surface with it.
|
|
84
|
+
*/ export { LIST_MEMBER_BATCH_MAX, resolveAddresses, resolveListContext } from "./server-list-gate.js";
|
|
85
|
+
/**
|
|
86
|
+
* `POST email/list-members-preview` — what adding these addresses would do.
|
|
87
|
+
*
|
|
88
|
+
* Reads only, and reached by an explicit act — typing an address or pasting a
|
|
89
|
+
* column — never on mount. It exists because the answer needs three things
|
|
90
|
+
* the browser cannot have: the org's contacts (rules put them behind org-wide
|
|
91
|
+
* membership, which the acting console session may not hold) and both
|
|
92
|
+
* suppression lists. Computing any of it client-side would be a second copy
|
|
93
|
+
* of the rule, on the surface whose whole job is to tell the operator the
|
|
94
|
+
* truth about what is about to happen.
|
|
95
|
+
*
|
|
96
|
+
* It takes no attestation and has nowhere to put one. The preview answers
|
|
97
|
+
* what is TRUE about each person, which is the input to the operator's
|
|
98
|
+
* decision rather than a function of it — a preview whose numbers moved as
|
|
99
|
+
* the box was ticked would not be a count anybody could stand behind.
|
|
100
|
+
*/ export const emailListMembersPreviewHandler = async (req, res)=>{
|
|
101
|
+
if (req.method !== 'POST') {
|
|
102
|
+
return res.status(405).json({
|
|
103
|
+
error: 'Method not allowed'
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
const requested = readAddresses(req);
|
|
107
|
+
if ('error' in requested) {
|
|
108
|
+
return res.status(400).json({
|
|
109
|
+
error: requested.error
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
try {
|
|
113
|
+
const context = await resolveListContext(req);
|
|
114
|
+
if (context.ok === false) {
|
|
115
|
+
return res.status(context.status).json(context.body);
|
|
116
|
+
}
|
|
117
|
+
const { verdicts, optedIn, needAttestation, refused } = await resolveAddresses({
|
|
118
|
+
hostId: context.hostId,
|
|
119
|
+
inputs: requested.emails
|
|
120
|
+
});
|
|
121
|
+
/*
|
|
122
|
+
* Named fields rather than a spread of the resolution.
|
|
123
|
+
*
|
|
124
|
+
* The resolution carries the consent RECORDS it was computed from, for the
|
|
125
|
+
* write path's use — raw stored basis, provenance, the account behind an
|
|
126
|
+
* operator assertion. None of that is the browser's, and a spread would
|
|
127
|
+
* put all of it on the wire the moment a field was added to the internal
|
|
128
|
+
* shape. What the surface needs is the verdicts and the counts.
|
|
129
|
+
*/ return res.status(200).json({
|
|
130
|
+
listName: context.listName,
|
|
131
|
+
verdicts,
|
|
132
|
+
optedIn,
|
|
133
|
+
needAttestation,
|
|
134
|
+
refused
|
|
135
|
+
});
|
|
136
|
+
} catch (error) {
|
|
137
|
+
console.error('[email] list member preview failed', error);
|
|
138
|
+
return res.status(500).json({
|
|
139
|
+
error: 'The addresses could not be checked.'
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
/**
|
|
144
|
+
* `POST email/list-members-add` — put these addresses on the list.
|
|
145
|
+
*
|
|
146
|
+
* Body: `{ hostId, listId, email | emails[], name?, attestConsent? }`.
|
|
147
|
+
* `attestConsent` is the operator STATING that they have these people's
|
|
148
|
+
* permission; it is not a way to name a basis, because the pass-through basis
|
|
149
|
+
* is derived server-side from each person's own record.
|
|
150
|
+
*
|
|
151
|
+
* ## One attestation, for the count the operator was shown
|
|
152
|
+
*
|
|
153
|
+
* The batch carries a single assertion because it is a single act: an
|
|
154
|
+
* operator pasting a column is making one claim about where that column came
|
|
155
|
+
* from. What makes that safe is that the claim is applied per address by the
|
|
156
|
+
* same function the preview ran, so it reaches only the addresses that
|
|
157
|
+
* actually need it — an address with a stored opt-in keeps its own basis and
|
|
158
|
+
* its own date, and an address nothing can enroll is refused with the
|
|
159
|
+
* attestation on the table.
|
|
160
|
+
*
|
|
161
|
+
* ## Partial success is the honest answer
|
|
162
|
+
*
|
|
163
|
+
* A batch where one address is suppressed and forty are fine is not a failed
|
|
164
|
+
* request. Every address comes back with what happened to it, so 200 here
|
|
165
|
+
* means "the request was processed", never "everybody was added" — the caller
|
|
166
|
+
* reads the per-address verdicts, which is why they are returned rather than
|
|
167
|
+
* a count.
|
|
168
|
+
*/ export const emailListMembersAddHandler = async (req, res)=>{
|
|
169
|
+
var _ref;
|
|
170
|
+
var _req_body, _req_body1;
|
|
171
|
+
if (req.method !== 'POST') {
|
|
172
|
+
return res.status(405).json({
|
|
173
|
+
error: 'Method not allowed'
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
const requested = readAddresses(req);
|
|
177
|
+
if ('error' in requested) {
|
|
178
|
+
return res.status(400).json({
|
|
179
|
+
error: requested.error
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
const attested = ((_req_body = req.body) == null ? void 0 : _req_body.attestConsent) === true;
|
|
183
|
+
const name = String((_ref = (_req_body1 = req.body) == null ? void 0 : _req_body1.name) != null ? _ref : '').trim();
|
|
184
|
+
try {
|
|
185
|
+
const context = await resolveListContext(req);
|
|
186
|
+
if (context.ok === false) {
|
|
187
|
+
return res.status(context.status).json(context.body);
|
|
188
|
+
}
|
|
189
|
+
const nowMs = Date.now();
|
|
190
|
+
const resolution = await resolveAddresses({
|
|
191
|
+
hostId: context.hostId,
|
|
192
|
+
inputs: requested.emails
|
|
193
|
+
});
|
|
194
|
+
const results = [];
|
|
195
|
+
for (const verdict of resolution.verdicts){
|
|
196
|
+
var _resolution_stored_get;
|
|
197
|
+
if (verdict.refusal || !verdict.email) {
|
|
198
|
+
results.push({
|
|
199
|
+
input: verdict.input,
|
|
200
|
+
email: verdict.email,
|
|
201
|
+
enrolled: false,
|
|
202
|
+
reason: verdict.refusal,
|
|
203
|
+
error: verdict.summary
|
|
204
|
+
});
|
|
205
|
+
continue;
|
|
206
|
+
}
|
|
207
|
+
/*
|
|
208
|
+
* The ONE place a basis is decided, and the only place the attestation
|
|
209
|
+
* is consulted.
|
|
210
|
+
*
|
|
211
|
+
* `resolveAddresses` has already answered the questions that are facts
|
|
212
|
+
* about the person; this answers the question that is about the
|
|
213
|
+
* operator, per address, from the consent record that resolution read.
|
|
214
|
+
* `no-basis` — an address with nothing on record and nobody asserting
|
|
215
|
+
* anything — is refused HERE and only here.
|
|
216
|
+
*/ const decision = assignmentBasis({
|
|
217
|
+
stored: (_resolution_stored_get = resolution.stored.get(verdict.email)) != null ? _resolution_stored_get : readMarketingBasis(null, resolution.group),
|
|
218
|
+
attested,
|
|
219
|
+
actingUid: context.uid,
|
|
220
|
+
nowMs
|
|
221
|
+
});
|
|
222
|
+
if ('refusal' in decision) {
|
|
223
|
+
results.push({
|
|
224
|
+
input: verdict.input,
|
|
225
|
+
email: verdict.email,
|
|
226
|
+
enrolled: false,
|
|
227
|
+
reason: decision.refusal,
|
|
228
|
+
error: ASSIGNMENT_REFUSAL_MESSAGES[decision.refusal]
|
|
229
|
+
});
|
|
230
|
+
continue;
|
|
231
|
+
}
|
|
232
|
+
const enrollment = await enrollListMember(_extends({
|
|
233
|
+
listRef: context.listRef,
|
|
234
|
+
group: resolution.group,
|
|
235
|
+
email: verdict.email
|
|
236
|
+
}, name && requested.emails.length === 1 ? {
|
|
237
|
+
name
|
|
238
|
+
} : {}, {
|
|
239
|
+
source: CONSOLE_ADD_SOURCE,
|
|
240
|
+
// Never `'rule'`: the dynamic-list materializer reconciles its own
|
|
241
|
+
// rows away when a person stops matching, and a decision somebody
|
|
242
|
+
// made by hand is not a rule match that lapsed.
|
|
243
|
+
via: 'manual',
|
|
244
|
+
consent: decision
|
|
245
|
+
}));
|
|
246
|
+
if (enrollment.enrolled === false) {
|
|
247
|
+
/*
|
|
248
|
+
* The membership itself records a refusal the CRM record did not.
|
|
249
|
+
* `enrollListMember` is the only writer of the collection and holds
|
|
250
|
+
* the row, so it is the backstop for every enrollment route; reaching
|
|
251
|
+
* it here means the two records disagree, and the refusal wins.
|
|
252
|
+
*/ const reason = enrollment.refusal === 'declined' ? 'declined' : 'unroutable-address';
|
|
253
|
+
results.push({
|
|
254
|
+
input: verdict.input,
|
|
255
|
+
email: verdict.email,
|
|
256
|
+
enrolled: false,
|
|
257
|
+
reason,
|
|
258
|
+
error: ASSIGNMENT_REFUSAL_MESSAGES[reason]
|
|
259
|
+
});
|
|
260
|
+
continue;
|
|
261
|
+
}
|
|
262
|
+
results.push({
|
|
263
|
+
input: verdict.input,
|
|
264
|
+
email: verdict.email,
|
|
265
|
+
enrolled: true,
|
|
266
|
+
memberId: enrollment.memberId,
|
|
267
|
+
created: enrollment.created,
|
|
268
|
+
basis: decision.basis
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
return res.status(200).json({
|
|
272
|
+
listName: context.listName,
|
|
273
|
+
added: results.filter((result)=>result.enrolled).length,
|
|
274
|
+
results
|
|
275
|
+
});
|
|
276
|
+
} catch (error) {
|
|
277
|
+
console.error('[email] list member add failed', error);
|
|
278
|
+
return res.status(500).json({
|
|
279
|
+
error: 'The addresses could not be added.'
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
/**
|
|
284
|
+
* WHO A SET OF FILTERS FINDS, and what would happen if you added them.
|
|
285
|
+
*
|
|
286
|
+
* ## The gap it fills
|
|
287
|
+
*
|
|
288
|
+
* The filters behind a list could only ever be MATERIALIZED — the sweep wrote
|
|
289
|
+
* the matching people straight into the membership. A merchant could not ask
|
|
290
|
+
* "who is this" without committing to it, and a fixed list could not use the
|
|
291
|
+
* filters at all: its only way to gain a member was somebody typing or pasting
|
|
292
|
+
* an address. This answers the question without writing anything.
|
|
293
|
+
*
|
|
294
|
+
* ## It is the same consent gate, not a second one
|
|
295
|
+
*
|
|
296
|
+
* The addresses the scan finds are put through {@link resolveAddresses} — the
|
|
297
|
+
* exact function `email/list-members-preview` uses — so a suppressed address
|
|
298
|
+
* is reported as refused here, and somebody with no opt-in on record is
|
|
299
|
+
* reported as needing an attestation here, before any of them is offered for
|
|
300
|
+
* adding. That is deliberate and load-bearing: a bulk path that skipped the
|
|
301
|
+
* check would be a way to fill a list with people the one-at-a-time path
|
|
302
|
+
* refuses, which is the defect class this product already has a register entry
|
|
303
|
+
* for. The ADD still goes through `email/list-members-add`, which re-runs
|
|
304
|
+
* every check server-side, so this preview is an honest readout rather than a
|
|
305
|
+
* permission.
|
|
306
|
+
*
|
|
307
|
+
* ## What it will not do
|
|
308
|
+
*
|
|
309
|
+
* It writes nothing, it enrolls nobody, and it compares no count against any
|
|
310
|
+
* limit. The batch cap below bounds how many addresses it hands back for a
|
|
311
|
+
* single add — the scan itself still reports how many people it MATCHED, so a
|
|
312
|
+
* merchant is told the audience is larger than one batch rather than shown a
|
|
313
|
+
* truncated number as if it were the whole.
|
|
314
|
+
*/ export const emailListRulePreviewHandler = async (req, res)=>{
|
|
315
|
+
if (req.method !== 'POST') {
|
|
316
|
+
return res.status(405).json({
|
|
317
|
+
error: 'Method not allowed'
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
try {
|
|
321
|
+
var _req_body;
|
|
322
|
+
const context = await resolveListContext(req);
|
|
323
|
+
if (context.ok === false) {
|
|
324
|
+
return res.status(context.status).json(context.body);
|
|
325
|
+
}
|
|
326
|
+
const rule = normalizeDynamicListRule((_req_body = req.body) == null ? void 0 : _req_body.rule);
|
|
327
|
+
if (dynamicListRuleIsEmpty(rule)) {
|
|
328
|
+
/*
|
|
329
|
+
* Not an error, and not an empty result either. A rule with no source
|
|
330
|
+
* matches nobody by construction, and reporting that as "0 people" is
|
|
331
|
+
* indistinguishable from a rule that ran and found none — which is the
|
|
332
|
+
* confusion the `empty` flag exists to prevent everywhere else.
|
|
333
|
+
*/ return res.status(200).json({
|
|
334
|
+
matched: 0,
|
|
335
|
+
truncated: false,
|
|
336
|
+
complete: true,
|
|
337
|
+
empty: true,
|
|
338
|
+
emails: [],
|
|
339
|
+
verdicts: [],
|
|
340
|
+
optedIn: 0,
|
|
341
|
+
needAttestation: 0,
|
|
342
|
+
refused: 0
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
const scan = await collectDynamicListCandidates({
|
|
346
|
+
hostId: context.hostId,
|
|
347
|
+
rule
|
|
348
|
+
});
|
|
349
|
+
/*
|
|
350
|
+
* The addresses, in the scan's own order, capped at what one add can
|
|
351
|
+
* carry. `matched` is reported separately and is NOT this length: a
|
|
352
|
+
* merchant looking at a 400-person audience must be told it is 400 even
|
|
353
|
+
* when the button in front of them adds 100.
|
|
354
|
+
*/ const emails = scan.candidates.map((candidate)=>candidate.email).filter(Boolean);
|
|
355
|
+
const batch = emails.slice(0, LIST_MEMBER_BATCH_MAX);
|
|
356
|
+
const resolution = await resolveAddresses({
|
|
357
|
+
hostId: context.hostId,
|
|
358
|
+
inputs: batch
|
|
359
|
+
});
|
|
360
|
+
return res.status(200).json({
|
|
361
|
+
listName: context.listName,
|
|
362
|
+
matched: emails.length,
|
|
363
|
+
/*
|
|
364
|
+
* Two different reasons a readout can be short of the truth, reported
|
|
365
|
+
* apart: `truncated` is this batch being smaller than the match, and
|
|
366
|
+
* `complete: false` is the SCAN having run out of budget, so `matched`
|
|
367
|
+
* is itself a floor.
|
|
368
|
+
*/ truncated: emails.length > batch.length,
|
|
369
|
+
complete: scan.complete,
|
|
370
|
+
empty: false,
|
|
371
|
+
emails: batch,
|
|
372
|
+
verdicts: resolution.verdicts,
|
|
373
|
+
optedIn: resolution.optedIn,
|
|
374
|
+
needAttestation: resolution.needAttestation,
|
|
375
|
+
refused: resolution.refused
|
|
376
|
+
});
|
|
377
|
+
} catch (error) {
|
|
378
|
+
console.error('[email] list rule preview failed', error);
|
|
379
|
+
return res.status(500).json({
|
|
380
|
+
error: 'The audience could not be worked out.'
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
};
|
|
384
|
+
/**
|
|
385
|
+
* Console API registration.
|
|
386
|
+
*
|
|
387
|
+
* None of these is on the machine-path exemption list in
|
|
388
|
+
* `plugin-api-rate-limit.ts`, so each is counted against the console
|
|
389
|
+
* dispatcher's per-subject budget — the ceiling that bounds a surface which
|
|
390
|
+
* puts a person into a marketing audience, and which scans a whole contact
|
|
391
|
+
* silo to work out who that would be.
|
|
392
|
+
*
|
|
393
|
+
* The limiter these are counted by is the CONSOLE one,
|
|
394
|
+
* `consoleApiRateLimitRefusal`. The visitor limiter is a different limiter on
|
|
395
|
+
* a different dispatcher: `visitorWriteRateLimitRefusal` is installed only in
|
|
396
|
+
* `apps/tenant`, and no request to these routes has ever passed through it.
|
|
397
|
+
* The two share a counter and an exemption list and nothing else — the console
|
|
398
|
+
* key is the authenticated subject, because on an authenticated surface a
|
|
399
|
+
* per-(site, IP) bucket both isolates nothing the identity has not already
|
|
400
|
+
* isolated and hands one operator a fresh budget per site.
|
|
401
|
+
*/ export function registerEmailConsoleApi() {
|
|
402
|
+
// The email design writer another plugin reaches through the core's
|
|
403
|
+
// resource-drafts seam (AGL-2912). Registered here alone: the AI jobs that
|
|
404
|
+
// write through it run only on the console, inline and on the beat
|
|
405
|
+
// (AGL-3026).
|
|
406
|
+
registerEmailDesignDraftWriter();
|
|
407
|
+
registerPluginApiRoute('email/list-rule-preview', emailListRulePreviewHandler);
|
|
408
|
+
registerPluginApiRoute('email/list-members-preview', emailListMembersPreviewHandler);
|
|
409
|
+
registerPluginApiRoute('email/list-members-add', emailListMembersAddHandler);
|
|
410
|
+
// The importer is four routes over one staged job, so it has its own
|
|
411
|
+
// module — but not its own gate: it reaches this file's `resolveListContext`
|
|
412
|
+
// and `resolveAddresses` rather than a bulk-shaped copy of them, which is
|
|
413
|
+
// the whole reason an import cannot enroll somebody the add path refuses.
|
|
414
|
+
registerEmailListImportApi();
|
|
415
|
+
// Suppressions live in their own module: they are a per-SITE list gated on
|
|
416
|
+
// the site role, where list membership is an ORG audience gated on org-wide
|
|
417
|
+
// access, and one file holding both gates is one file for the wrong one to
|
|
418
|
+
// be copied out of.
|
|
419
|
+
registerEmailSuppressionsApi();
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
//# sourceMappingURL=server-console.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../libs/plugins/email/src/lib/server-console.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Putting somebody on an email list from the Emails console.\n *\n * The audience card could create a list and delete a list and nothing else:\n * no way to see who was on one, no way to add anybody, no way to take anybody\n * off. Every member document in production arrived from a capture surface —\n * the newsletter handler, the workflow `enrollList` step, the dynamic-list\n * materializer, the Inbox assignment — so the one act a merchant most expects\n * of a list, \"add this person\", was the one act the product refused.\n *\n * ## Why this is a route and not a client write\n *\n * Rules put `orgs/{orgId}/lists/{listId}/members` behind org-wide membership,\n * and until now that block allowed a client CREATE. Nothing used it, and it\n * was the whole feature waiting to be built wrong: a browser that can write a\n * member document can write `marketingConsent: true` beside an address it has\n * never checked, which is a consent record minted by pressing a button. The\n * rules now deny client create and update on that collection, and this route\n * is the writer — through `enrollListMember`, which owns the document id, and\n * through the shared `list-assignment-policy`, which owns the basis.\n *\n * ## The same policy the Inbox uses, not a second one\n *\n * `assignmentBasis` and `assignmentReadout` are imported from the framework,\n * where they moved when this became their second caller. There is no third\n * consent basis and no console-only override: a stored `declined` refuses\n * here exactly as it refuses there, an attestation is recorded with the\n * account that made it, and a stored opt-in is carried across with the date\n * the PERSON set rather than the date somebody pressed Add.\n *\n * ## Reads only, until the operator has seen the count\n *\n * `email/list-members-preview` writes nothing. It answers, per address, what\n * would happen and why, so the attestation the operator gives on the second\n * call is given with the numbers in front of them. Both routes run the SAME\n * resolution over the SAME inputs — `resolveAddresses` — so the summary they\n * were shown is the summary that acts.\n *\n * ## Finding people is a read, and it uses the same gate\n *\n * `email/list-rule-preview` answers \"who do these filters select\" without\n * writing anything, so a fixed list can be filled from a search rather than\n * from somebody typing addresses one at a time. It runs the addresses it finds\n * through `resolveAddresses` as well — a bulk path that reached the membership\n * without the suppression check and the attestation would be a way to enroll\n * exactly the people the single-address path refuses.\n *\n * ## The gate itself is `server-list-gate.ts`\n *\n * Who may change a list's membership, and what is true about each address, are\n * asked by three route modules now: these two, and the file importer in\n * `server-list-import.ts`. They live in a module of their own so the importer\n * shares this file's answer rather than importing this file — which would be a\n * cycle, and a cycle whose module-level constants would evaluate in whichever\n * order the loader happened to reach them.\n */\n\nimport { registerEmailDesignDraftWriter } from './server-email-drafts'\nimport { registerEmailSuppressionsApi } from './server-suppressions'\nimport { registerEmailListImportApi } from './server-list-import'\nimport {\n LIST_MEMBER_BATCH_MAX,\n readAddresses,\n resolveAddresses,\n resolveListContext,\n} from './server-list-gate'\nimport {\n ASSIGNMENT_REFUSAL_MESSAGES,\n assignmentBasis,\n dynamicListRuleIsEmpty,\n normalizeDynamicListRule,\n readMarketingBasis,\n registerPluginApiRoute,\n type AssignmentRefusal,\n type PluginApiHandler,\n} from '@aglyn/aglyn/server'\nimport {\n collectDynamicListCandidates,\n enrollListMember,\n} from '@aglyn/tenant-data-admin'\n\n/** `source` stamped on every membership these routes write. */\nexport const CONSOLE_ADD_SOURCE = 'console:list-add'\n\n/*\n * Re-exported, not redefined. `@aglyn/plugins-email/server` has published\n * these names since the add path shipped, and the console panel and its specs\n * import them from there; moving the gate must not move the plugin's public\n * surface with it.\n */\nexport {\n LIST_MEMBER_BATCH_MAX,\n resolveAddresses,\n resolveListContext,\n type AddressResolution,\n type AddressVerdict,\n type ListContext,\n type ResolvedBatch,\n} from './server-list-gate'\n\n\n/**\n * `POST email/list-members-preview` — what adding these addresses would do.\n *\n * Reads only, and reached by an explicit act — typing an address or pasting a\n * column — never on mount. It exists because the answer needs three things\n * the browser cannot have: the org's contacts (rules put them behind org-wide\n * membership, which the acting console session may not hold) and both\n * suppression lists. Computing any of it client-side would be a second copy\n * of the rule, on the surface whose whole job is to tell the operator the\n * truth about what is about to happen.\n *\n * It takes no attestation and has nowhere to put one. The preview answers\n * what is TRUE about each person, which is the input to the operator's\n * decision rather than a function of it — a preview whose numbers moved as\n * the box was ticked would not be a count anybody could stand behind.\n */\nexport const emailListMembersPreviewHandler: PluginApiHandler = async (\n req,\n res,\n) => {\n if (req.method !== 'POST') {\n return res.status(405).json({ error: 'Method not allowed' })\n }\n const requested = readAddresses(req)\n if ('error' in requested) {\n return res.status(400).json({ error: requested.error })\n }\n try {\n const context = await resolveListContext(req)\n if (context.ok === false) {\n return res.status(context.status).json(context.body)\n }\n const { verdicts, optedIn, needAttestation, refused } =\n await resolveAddresses({\n hostId: context.hostId,\n inputs: requested.emails,\n })\n /*\n * Named fields rather than a spread of the resolution.\n *\n * The resolution carries the consent RECORDS it was computed from, for the\n * write path's use — raw stored basis, provenance, the account behind an\n * operator assertion. None of that is the browser's, and a spread would\n * put all of it on the wire the moment a field was added to the internal\n * shape. What the surface needs is the verdicts and the counts.\n */\n return res.status(200).json({\n listName: context.listName,\n verdicts,\n optedIn,\n needAttestation,\n refused,\n })\n } catch (error) {\n console.error('[email] list member preview failed', error)\n return res.status(500).json({ error: 'The addresses could not be checked.' })\n }\n}\n\n/**\n * `POST email/list-members-add` — put these addresses on the list.\n *\n * Body: `{ hostId, listId, email | emails[], name?, attestConsent? }`.\n * `attestConsent` is the operator STATING that they have these people's\n * permission; it is not a way to name a basis, because the pass-through basis\n * is derived server-side from each person's own record.\n *\n * ## One attestation, for the count the operator was shown\n *\n * The batch carries a single assertion because it is a single act: an\n * operator pasting a column is making one claim about where that column came\n * from. What makes that safe is that the claim is applied per address by the\n * same function the preview ran, so it reaches only the addresses that\n * actually need it — an address with a stored opt-in keeps its own basis and\n * its own date, and an address nothing can enroll is refused with the\n * attestation on the table.\n *\n * ## Partial success is the honest answer\n *\n * A batch where one address is suppressed and forty are fine is not a failed\n * request. Every address comes back with what happened to it, so 200 here\n * means \"the request was processed\", never \"everybody was added\" — the caller\n * reads the per-address verdicts, which is why they are returned rather than\n * a count.\n */\nexport const emailListMembersAddHandler: PluginApiHandler = async (\n req,\n res,\n) => {\n if (req.method !== 'POST') {\n return res.status(405).json({ error: 'Method not allowed' })\n }\n const requested = readAddresses(req)\n if ('error' in requested) {\n return res.status(400).json({ error: requested.error })\n }\n const attested = req.body?.attestConsent === true\n const name = String(req.body?.name ?? '').trim()\n\n try {\n const context = await resolveListContext(req)\n if (context.ok === false) {\n return res.status(context.status).json(context.body)\n }\n const nowMs = Date.now()\n const resolution = await resolveAddresses({\n hostId: context.hostId,\n inputs: requested.emails,\n })\n\n const results = []\n for (const verdict of resolution.verdicts) {\n if (verdict.refusal || !verdict.email) {\n results.push({\n input: verdict.input,\n email: verdict.email,\n enrolled: false,\n reason: verdict.refusal,\n error: verdict.summary,\n })\n continue\n }\n /*\n * The ONE place a basis is decided, and the only place the attestation\n * is consulted.\n *\n * `resolveAddresses` has already answered the questions that are facts\n * about the person; this answers the question that is about the\n * operator, per address, from the consent record that resolution read.\n * `no-basis` — an address with nothing on record and nobody asserting\n * anything — is refused HERE and only here.\n */\n const decision = assignmentBasis({\n stored: resolution.stored.get(verdict.email) ?? readMarketingBasis(null, resolution.group),\n attested,\n actingUid: context.uid,\n nowMs,\n })\n if ('refusal' in decision) {\n results.push({\n input: verdict.input,\n email: verdict.email,\n enrolled: false,\n reason: decision.refusal,\n error: ASSIGNMENT_REFUSAL_MESSAGES[decision.refusal],\n })\n continue\n }\n const enrollment = await enrollListMember({\n listRef: context.listRef,\n group: resolution.group,\n email: verdict.email,\n ...(name && requested.emails.length === 1 ? { name } : {}),\n source: CONSOLE_ADD_SOURCE,\n // Never `'rule'`: the dynamic-list materializer reconciles its own\n // rows away when a person stops matching, and a decision somebody\n // made by hand is not a rule match that lapsed.\n via: 'manual',\n consent: decision,\n })\n if (enrollment.enrolled === false) {\n /*\n * The membership itself records a refusal the CRM record did not.\n * `enrollListMember` is the only writer of the collection and holds\n * the row, so it is the backstop for every enrollment route; reaching\n * it here means the two records disagree, and the refusal wins.\n */\n const reason: AssignmentRefusal =\n enrollment.refusal === 'declined' ? 'declined' : 'unroutable-address'\n results.push({\n input: verdict.input,\n email: verdict.email,\n enrolled: false,\n reason,\n error: ASSIGNMENT_REFUSAL_MESSAGES[reason],\n })\n continue\n }\n results.push({\n input: verdict.input,\n email: verdict.email,\n enrolled: true,\n memberId: enrollment.memberId,\n created: enrollment.created,\n basis: decision.basis,\n })\n }\n\n return res.status(200).json({\n listName: context.listName,\n added: results.filter((result) => result.enrolled).length,\n results,\n })\n } catch (error) {\n console.error('[email] list member add failed', error)\n return res.status(500).json({ error: 'The addresses could not be added.' })\n }\n}\n\n/**\n * WHO A SET OF FILTERS FINDS, and what would happen if you added them.\n *\n * ## The gap it fills\n *\n * The filters behind a list could only ever be MATERIALIZED — the sweep wrote\n * the matching people straight into the membership. A merchant could not ask\n * \"who is this\" without committing to it, and a fixed list could not use the\n * filters at all: its only way to gain a member was somebody typing or pasting\n * an address. This answers the question without writing anything.\n *\n * ## It is the same consent gate, not a second one\n *\n * The addresses the scan finds are put through {@link resolveAddresses} — the\n * exact function `email/list-members-preview` uses — so a suppressed address\n * is reported as refused here, and somebody with no opt-in on record is\n * reported as needing an attestation here, before any of them is offered for\n * adding. That is deliberate and load-bearing: a bulk path that skipped the\n * check would be a way to fill a list with people the one-at-a-time path\n * refuses, which is the defect class this product already has a register entry\n * for. The ADD still goes through `email/list-members-add`, which re-runs\n * every check server-side, so this preview is an honest readout rather than a\n * permission.\n *\n * ## What it will not do\n *\n * It writes nothing, it enrolls nobody, and it compares no count against any\n * limit. The batch cap below bounds how many addresses it hands back for a\n * single add — the scan itself still reports how many people it MATCHED, so a\n * merchant is told the audience is larger than one batch rather than shown a\n * truncated number as if it were the whole.\n */\nexport const emailListRulePreviewHandler: PluginApiHandler = async (\n req,\n res,\n) => {\n if (req.method !== 'POST') {\n return res.status(405).json({ error: 'Method not allowed' })\n }\n try {\n const context = await resolveListContext(req)\n if (context.ok === false) {\n return res.status(context.status).json(context.body)\n }\n const rule = normalizeDynamicListRule(req.body?.rule)\n if (dynamicListRuleIsEmpty(rule)) {\n /*\n * Not an error, and not an empty result either. A rule with no source\n * matches nobody by construction, and reporting that as \"0 people\" is\n * indistinguishable from a rule that ran and found none — which is the\n * confusion the `empty` flag exists to prevent everywhere else.\n */\n return res.status(200).json({\n matched: 0,\n truncated: false,\n complete: true,\n empty: true,\n emails: [],\n verdicts: [],\n optedIn: 0,\n needAttestation: 0,\n refused: 0,\n })\n }\n const scan = await collectDynamicListCandidates({\n hostId: context.hostId,\n rule,\n })\n /*\n * The addresses, in the scan's own order, capped at what one add can\n * carry. `matched` is reported separately and is NOT this length: a\n * merchant looking at a 400-person audience must be told it is 400 even\n * when the button in front of them adds 100.\n */\n const emails = scan.candidates\n .map((candidate) => candidate.email)\n .filter(Boolean)\n const batch = emails.slice(0, LIST_MEMBER_BATCH_MAX)\n const resolution = await resolveAddresses({\n hostId: context.hostId,\n inputs: batch,\n })\n return res.status(200).json({\n listName: context.listName,\n matched: emails.length,\n /*\n * Two different reasons a readout can be short of the truth, reported\n * apart: `truncated` is this batch being smaller than the match, and\n * `complete: false` is the SCAN having run out of budget, so `matched`\n * is itself a floor.\n */\n truncated: emails.length > batch.length,\n complete: scan.complete,\n empty: false,\n emails: batch,\n verdicts: resolution.verdicts,\n optedIn: resolution.optedIn,\n needAttestation: resolution.needAttestation,\n refused: resolution.refused,\n })\n } catch (error) {\n console.error('[email] list rule preview failed', error)\n return res\n .status(500)\n .json({ error: 'The audience could not be worked out.' })\n }\n}\n\n/**\n * Console API registration.\n *\n * None of these is on the machine-path exemption list in\n * `plugin-api-rate-limit.ts`, so each is counted against the console\n * dispatcher's per-subject budget — the ceiling that bounds a surface which\n * puts a person into a marketing audience, and which scans a whole contact\n * silo to work out who that would be.\n *\n * The limiter these are counted by is the CONSOLE one,\n * `consoleApiRateLimitRefusal`. The visitor limiter is a different limiter on\n * a different dispatcher: `visitorWriteRateLimitRefusal` is installed only in\n * `apps/tenant`, and no request to these routes has ever passed through it.\n * The two share a counter and an exemption list and nothing else — the console\n * key is the authenticated subject, because on an authenticated surface a\n * per-(site, IP) bucket both isolates nothing the identity has not already\n * isolated and hands one operator a fresh budget per site.\n */\nexport function registerEmailConsoleApi(): void {\n // The email design writer another plugin reaches through the core's\n // resource-drafts seam (AGL-2912). Registered here alone: the AI jobs that\n // write through it run only on the console, inline and on the beat\n // (AGL-3026).\n registerEmailDesignDraftWriter()\n registerPluginApiRoute('email/list-rule-preview', emailListRulePreviewHandler)\n registerPluginApiRoute(\n 'email/list-members-preview',\n emailListMembersPreviewHandler,\n )\n registerPluginApiRoute('email/list-members-add', emailListMembersAddHandler)\n // The importer is four routes over one staged job, so it has its own\n // module — but not its own gate: it reaches this file's `resolveListContext`\n // and `resolveAddresses` rather than a bulk-shaped copy of them, which is\n // the whole reason an import cannot enroll somebody the add path refuses.\n registerEmailListImportApi()\n // Suppressions live in their own module: they are a per-SITE list gated on\n // the site role, where list membership is an ORG audience gated on org-wide\n // access, and one file holding both gates is one file for the wrong one to\n // be copied out of.\n registerEmailSuppressionsApi()\n}\n"],"names":["registerEmailDesignDraftWriter","registerEmailSuppressionsApi","registerEmailListImportApi","LIST_MEMBER_BATCH_MAX","readAddresses","resolveAddresses","resolveListContext","ASSIGNMENT_REFUSAL_MESSAGES","assignmentBasis","dynamicListRuleIsEmpty","normalizeDynamicListRule","readMarketingBasis","registerPluginApiRoute","collectDynamicListCandidates","enrollListMember","CONSOLE_ADD_SOURCE","emailListMembersPreviewHandler","req","res","method","status","json","error","requested","context","ok","body","verdicts","optedIn","needAttestation","refused","hostId","inputs","emails","listName","console","emailListMembersAddHandler","attested","attestConsent","name","String","trim","nowMs","Date","now","resolution","results","verdict","refusal","email","push","input","enrolled","reason","summary","decision","stored","get","group","actingUid","uid","enrollment","listRef","length","source","via","consent","memberId","created","basis","added","filter","result","emailListRulePreviewHandler","rule","matched","truncated","complete","empty","scan","candidates","map","candidate","Boolean","batch","slice","registerEmailConsoleApi"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuDC,GAED,SAASA,8BAA8B,QAAQ,2BAAuB;AACtE,SAASC,4BAA4B,QAAQ,2BAAuB;AACpE,SAASC,0BAA0B,QAAQ,0BAAsB;AACjE,SACEC,qBAAqB,EACrBC,aAAa,EACbC,gBAAgB,EAChBC,kBAAkB,QACb,wBAAoB;AAC3B,SACEC,2BAA2B,EAC3BC,eAAe,EACfC,sBAAsB,EACtBC,wBAAwB,EACxBC,kBAAkB,EAClBC,sBAAsB,QAGjB,s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