@aglyn/plugins-email 1.0.0-beta.231 → 1.0.0-beta.233

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.
Files changed (30) hide show
  1. package/package.json +16 -16
  2. package/src/lib/components/consent-group-change-progress.js +4 -0
  3. package/src/lib/components/consent-group-change-progress.js.map +1 -1
  4. package/src/lib/components/consent-group-site-picker.js +1 -0
  5. package/src/lib/components/consent-group-site-picker.js.map +1 -1
  6. package/src/lib/components/email-screens-card.js +33 -6
  7. package/src/lib/components/email-screens-card.js.map +1 -1
  8. package/src/lib/components/email-template-detail.js +3 -1
  9. package/src/lib/components/email-template-detail.js.map +1 -1
  10. package/src/lib/components/email-topics-card.js +1 -0
  11. package/src/lib/components/email-topics-card.js.map +1 -1
  12. package/src/lib/components/list-detail-card.js +4 -0
  13. package/src/lib/components/list-detail-card.js.map +1 -1
  14. package/src/lib/components/list-members-panel.js +38 -7
  15. package/src/lib/components/list-members-panel.js.map +1 -1
  16. package/src/lib/components/lists-card.js +35 -7
  17. package/src/lib/components/lists-card.js.map +1 -1
  18. package/src/lib/components/org-email-templates-card.js +34 -7
  19. package/src/lib/components/org-email-templates-card.js.map +1 -1
  20. package/src/lib/components/org-sending-domain-detail.js +1 -0
  21. package/src/lib/components/org-sending-domain-detail.js.map +1 -1
  22. package/src/lib/components/sending-domain-detail.js +1 -0
  23. package/src/lib/components/sending-domain-detail.js.map +1 -1
  24. package/src/lib/components/suppressions-card.js +25 -6
  25. package/src/lib/components/suppressions-card.js.map +1 -1
  26. package/src/lib/constants/list-queries.js +73 -9
  27. package/src/lib/constants/list-queries.js.map +1 -1
  28. package/src/lib/model/email-design-document.d.ts +1 -1
  29. package/src/lib/model/email-design-document.js +1 -1
  30. package/src/lib/model/email-design-document.js.map +1 -1
@@ -47,6 +47,7 @@ import { collection, deleteDoc, doc } from "firebase/firestore";
47
47
  import { useCallback, useEffect, useMemo, useState } from "react";
48
48
  import { useFirestore, useUser } from "@aglyn/tenant-feature-instance";
49
49
  import { useListQuery } from "@aglyn/tenant-feature-instance/hooks/use-list-query";
50
+ import { useListColumnSort } from "@aglyn/shared-ui-jsx/hooks/use-list-column-sort";
50
51
  import { authorizedFetch } from "@aglyn/shared-util-http/authorized-token";
51
52
  import { SUPPRESSION_FILTER_HEADERS, SUPPRESSION_LIST_QUERY } from "../constants/list-queries.js";
52
53
  import { describeSuppressionReason as describeReason, readSuppressionTotals, SUPPRESSION_REASONS } from "./suppression-totals.js";
@@ -157,12 +158,18 @@ const SUPPRESSION_SELECT_FIELDS = [
157
158
  */ const gridFilter = useListGridFilter({
158
159
  selectFields: SUPPRESSION_SELECT_FIELDS
159
160
  });
161
+ /*
162
+ * EVERY HEADER SORTS ON THE QUERY (AGL-3680): Since, Address and Reason
163
+ * are stored on every entry (see `SUPPRESSION_LIST_QUERY`). Newest first
164
+ * until a header is clicked.
165
+ */ const [askedSort, setAskedSort] = useState(SUPPRESSION_LIST_QUERY.sorts[0]);
160
166
  const { rows: entries, hasMore, page, setPage, pageSize, setPageSize, plan } = useListQuery({
161
167
  collection: collection(firestore, 'hosts', hostId, 'suppressions'),
162
168
  declaration: SUPPRESSION_LIST_QUERY,
163
169
  request: {
164
170
  clauses: gridFilter.clauses,
165
- search: gridFilter.searchWords
171
+ search: gridFilter.searchWords,
172
+ sort: askedSort
166
173
  },
167
174
  deps: [
168
175
  firestore,
@@ -170,6 +177,14 @@ const SUPPRESSION_SELECT_FIELDS = [
170
177
  ],
171
178
  idField: '$id'
172
179
  });
180
+ const columnSort = useListColumnSort({
181
+ sorts: SUPPRESSION_LIST_QUERY.sorts,
182
+ defaultSort: SUPPRESSION_LIST_QUERY.sorts[0],
183
+ sort: askedSort,
184
+ onSortChange: setAskedSort,
185
+ orderBy: plan.orderBy,
186
+ rows: entries
187
+ });
173
188
  const filtering = gridFilter.clauses.length > 0 || gridFilter.searchWords.some((word)=>word.trim());
174
189
  /*
175
190
  * IMPORT AND EXPORT (AGL-3529) open the console's transfer wizard and
@@ -551,6 +566,7 @@ const SUPPRESSION_SELECT_FIELDS = [
551
566
  }) : /*#__PURE__*/ _jsxs(_Fragment, {
552
567
  children: [
553
568
  /*#__PURE__*/ _jsx(Stack, {
569
+ useFlexGap: true,
554
570
  direction: "row",
555
571
  spacing: 1,
556
572
  sx: {
@@ -581,22 +597,25 @@ const SUPPRESSION_SELECT_FIELDS = [
581
597
  }),
582
598
  /*#__PURE__*/ _jsx(ListQueryNotices, {
583
599
  refused: refusals,
584
- notices: plan.notices
600
+ notices: [
601
+ ...plan.notices,
602
+ ...columnSort.notices
603
+ ]
585
604
  }),
586
605
  /*#__PURE__*/ _jsx(ListTable, {
587
606
  "aria-label": "Suppressed addresses",
588
- rows: entries,
607
+ rows: columnSort.rows,
608
+ columnSort: columnSort,
589
609
  columns: listFilterGridColumns(columns, SUPPRESSION_LIST_QUERY.fields, SUPPRESSION_FILTER_OPTIONS, SUPPRESSION_FILTER_HEADERS),
590
610
  rowHeight: TABLE_ROW_HEIGHT,
591
611
  // Paged by the footer below, so the grid must not also slice.
592
612
  hideFooter: true,
593
- // The panel and the search go to the query; the grid neither
594
- // filters nor sorts the page it holds.
613
+ // The panel, the search and the headers go to the query; the
614
+ // grid neither filters nor sorts the page it holds.
595
615
  filterMode: "server",
596
616
  filterModel: gridFilter.filterModel,
597
617
  onFilterModelChange: gridFilter.onFilterModelChange,
598
618
  quickFilter: true,
599
- disableColumnSorting: true,
600
619
  noRowsLabel: "No suppressions match these filters"
601
620
  }),
602
621
  /*#__PURE__*/ _jsx(ListPagination, {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/plugins/email/src/lib/components/suppressions-card.tsx"],"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'use client'\n\nimport { TransferResumeImport } from '@aglyn/aglyn/app-utils/transfer-resume-import'\nimport { pluginDocsHelp } from '@aglyn/aglyn'\nimport { useTransferLauncher } from '@aglyn/aglyn/app-utils/transfer-launcher-context'\nimport { ICON_VARIANT_CLOSE } from '@aglyn/shared-data-enums'\nimport {\n mdiEmailCheckOutline,\n mdiTrayArrowDown,\n mdiTrayArrowUp,\n} from '@aglyn/shared-data-mdi'\nimport {\n CardDisplay,\n Container,\n MdiIcon,\n SrOnly,\n useConfirmationContext,\n} from '@aglyn/shared-ui-jsx'\nimport ListFilterChips from '@aglyn/shared-ui-jsx/components/list-filter-chips.component'\nimport { ListPagination } from '@aglyn/shared-ui-jsx/components/list-pagination.component'\nimport ListQueryNotices, {\n listQueryRefusals,\n} from '@aglyn/shared-ui-jsx/components/list-query-notices.component'\nimport {\n ListRowActions,\n ListTable,\n listActionsColumn,\n} from '@aglyn/shared-ui-jsx/components/list-table.component'\nimport { listFilterGridColumns } from '@aglyn/shared-ui-jsx/const/list-grid-filter'\nimport { TABLE_ROW_HEIGHT } from '@aglyn/shared-ui-jsx/const/table-pagination'\nimport { useListGridFilter } from '@aglyn/shared-ui-jsx/hooks/use-list-grid-filter'\n/*\n * The shared drawer, reached by its own path.\n *\n * `@aglyn/shared-ui-jsx`'s barrel deliberately does not re-export this one, so\n * a deep import is the supported way in rather than an escape hatch. The\n * console's `CreateArtifactDrawer` — what Screens, Components, Layouts and\n * Templates create through — is this same component with a form inside it,\n * and it lives in `apps/console`, which a plugin library may not import. So\n * the chrome is composed from the same primitive rather than duplicated from\n * the wrapper.\n */\nimport { NavigationDrawerComponent } from '@aglyn/shared-ui-jsx/components/navigation-drawer.component'\nimport { useSnackbar } from '@aglyn/shared-ui-snackstack'\nimport {\n Alert,\n Chip,\n IconButton,\n Stack,\n TextField,\n Tooltip,\n Typography,\n} from '@mui/material'\nimport Button from '@mui/material/Button'\nimport type { GridColDef } from '@mui/x-data-grid'\nimport { collection, deleteDoc, doc } from 'firebase/firestore'\nimport { useCallback, useEffect, useMemo, useState } from 'react'\nimport { useFirestore, useUser } from '@aglyn/tenant-feature-instance'\nimport { useListQuery } from '@aglyn/tenant-feature-instance/hooks/use-list-query'\nimport { authorizedFetch } from '@aglyn/shared-util-http/authorized-token'\nimport {\n SUPPRESSION_FILTER_HEADERS,\n SUPPRESSION_LIST_QUERY,\n} from '../constants/list-queries'\nimport {\n describeSuppressionReason as describeReason,\n readSuppressionTotals,\n SUPPRESSION_REASONS,\n type SuppressionTotals,\n} from './suppression-totals'\nimport { orgSiteName, useEmailOrgMount } from './email-org-mount'\nimport { SUPPRESSIONS_RESOURCE } from '../transfer/email-transfer-catalog'\n\nexport interface SuppressionsCardProps {\n hostId: string\n}\n\n/** A stored entry. `reason` is absent on anything written before AGL-2408. */\ninterface SuppressionRow {\n $id: string\n email?: string\n reason?: string\n suppressedAt?: { seconds?: number } | null\n createdAt?: { seconds?: number } | null\n /**\n * The site this entry was copied from when the two stopped being one\n * sender (AGL-3320). The copy keeps the original's reason and dates.\n */\n carriedFromHostId?: string\n}\n\n/*\n * What the suppressions grid's Filters panel offers, every clause and the\n * search on the list's query (AGL-3321): see `SUPPRESSION_LIST_QUERY`. The\n * Reason choices are the stored reasons, by the words the column uses.\n */\nconst SUPPRESSION_FILTER_OPTIONS = {\n reason: Object.entries(SUPPRESSION_REASONS).map(([value, described]) => ({\n value,\n label: described.label,\n })),\n}\nconst SUPPRESSION_SELECT_FIELDS = ['reason']\n\n/**\n * `YYYY-MM-DD` from a Firestore timestamp shape, or an em dash.\n *\n * `createdAt` first, and that ordering is the column's meaning rather than a\n * preference. Both writers restamp `suppressedAt` on every touch and write\n * `createdAt` only when the document is new, precisely so that a bounce\n * arriving after an unsubscribe does not move the date the person actually\n * unsubscribed. Reading `suppressedAt` first put the restamp on screen under a\n * heading that says \"Since\", and it is also the field the list is ordered by,\n * so a re-touched row would have sorted by one date and displayed another.\n */\nfunction onDate(row: SuppressionRow): string {\n const seconds = row.createdAt?.seconds ?? row.suppressedAt?.seconds\n if (!seconds) return '—'\n return new Date(seconds * 1000).toISOString().slice(0, 10)\n}\n\n/**\n * Suppressions (AGL-2410): who is not being emailed, and why.\n *\n * ## What was missing\n *\n * `hosts/{hostId}/suppressions` was written by two paths — the unsubscribe\n * handler and, since AGL-1918, the Resend webhook on a permanent bounce or a\n * complaint — and read by exactly one: `campaign-send.ts`, to filter an\n * audience. Nothing in the console displayed it. So a merchant could not\n * answer any of:\n *\n * - *\"My campaign says 500 recipients and 480 sent — who were the other\n * 20?\"* The send returns `{recipients, sent}` and the difference was\n * unexplained.\n * - *\"Is my list going stale?\"* A bounce rate is the single most useful\n * number about a list and there was nowhere to see it.\n * - *\"This address was suppressed by mistake.\"* There was no way to remove\n * an entry — and a link prescanner unsubscribing someone (AGL-2408 §2) was\n * therefore unrecoverable from inside the product.\n *\n * ## Why a surface and not another counter\n *\n * AGL-1918 deliberately did NOT write a `stats.bounces` counter alongside its\n * fix, because a number with no screen to show it is the written-but-never-\n * read shape this issue is about, one level up. So the fix is the READER, and\n * the breakdown here is derived from the rows on screen rather than from a\n * second stored figure that could disagree with them.\n *\n * ## Removing an entry\n *\n * A plain client `deleteDoc`, and that is a decision. The list belongs to the\n * merchant, host admins already read it through the same rules, and removing\n * a row does nothing except make an address targetable again — there is no\n * counter to launder and no money attached, which is the AGL-1367 test for\n * whether a write has to move server-side.\n *\n * The confirmation is not decoration either: for a `bounce` the address very\n * likely does not exist, and mailing it again is what a provider scores the\n * sending domain on. So the dialog says which reason is being overridden\n * rather than asking a generic \"are you sure\".\n */\nexport function SuppressionsCard(props: SuppressionsCardProps) {\n const { hostId } = props\n const firestore = useFirestore()\n const { data: user } = useUser()\n const { enqueueSnackbar } = useSnackbar()\n const { confirm } = useConfirmationContext()\n // Present on the organization's page, which can name the other site.\n const orgMount = useEmailOrgMount()\n const [adding, setAdding] = useState(false)\n\n const [addInput, setAddInput] = useState('')\n const [addNote, setAddNote] = useState('')\n const [busy, setBusy] = useState(false)\n\n /*\n * The page IS the query, ordered by the server (AGL-2501, AGL-2292), and\n * every filter and search word is a predicate on it (AGL-3321).\n *\n * This was `limit(500)` with no `orderBy`, sorted by date in the browser.\n * Firestore answers an unordered limit in DOCUMENT-ID order, and an entry\n * here is keyed by `sha256(email)` — so the window was five hundred\n * addresses chosen by the hash of the address, and the client sort dressed\n * that sample up as the newest five hundred. A list past the ceiling\n * therefore hid whoever bounced this morning behind whoever happened to\n * hash low, with no gap on screen to notice and no control asking for more.\n *\n * `createdAt` is the safe field to order on, and that is checked rather\n * than assumed: both writers — the unsubscribe handler and the Resend\n * bounce/complaint webhook — stamp it when the document is created, the\n * pre-AGL-2408 handler wrote `{ email, createdAt }`, and `suppressions` is\n * not in `IMPORTABLE_FIELDS`, so no restore path can produce a row without\n * one. `suppressedAt` would NOT be safe: it is absent on every entry\n * written before AGL-1918, and `orderBy` drops documents that lack the\n * field rather than mis-sorting them.\n */\n const gridFilter = useListGridFilter({ selectFields: SUPPRESSION_SELECT_FIELDS })\n const {\n rows: entries,\n hasMore,\n page,\n setPage,\n pageSize,\n setPageSize,\n plan,\n } = useListQuery<SuppressionRow>({\n collection: collection(firestore, 'hosts', hostId, 'suppressions'),\n declaration: SUPPRESSION_LIST_QUERY,\n request: { clauses: gridFilter.clauses, search: gridFilter.searchWords },\n deps: [firestore, hostId],\n idField: '$id',\n })\n const filtering =\n gridFilter.clauses.length > 0 || gridFilter.searchWords.some((word) => word.trim())\n /*\n * IMPORT AND EXPORT (AGL-3529) open the console's transfer wizard and\n * export dialog on this site's list. An import only ever adds: an address\n * already here keeps its entry, and nothing removes one. The export's\n * \"current filter\" is this table's own query.\n */\n const transfer = useTransferLauncher()\n const exportFilter = filtering\n ? {\n label: 'Entries matching the table’s filters',\n value: { filters: plan.filters },\n }\n : null\n const refusals = useMemo(\n () =>\n listQueryRefusals(plan.refused, {\n fields: SUPPRESSION_LIST_QUERY.fields,\n headers: SUPPRESSION_FILTER_HEADERS,\n options: SUPPRESSION_FILTER_OPTIONS,\n }),\n [plan.refused],\n )\n\n /*==========================================\n * THE BREAKDOWN IS A SERVER AGGREGATE, not a tally of the page.\n *\n * These chips answer \"is my list going stale?\", and they were a `reduce`\n * over whatever the listener had fetched — so on a site past the old\n * ceiling \"Bounced: 140\" meant 140 of an arbitrary five hundred, and under\n * a ten-row page it would have meant 140 of ten. A bounce rate computed\n * from a sample is not a bounce rate, and nothing on screen said it was one.\n *\n * `readSuppressionTotals` holds the four reads and the remainder rule for\n * unsubscribes, and the organization's summary of every site's list asks\n * the same function, so a site's figures read the same on both pages.\n *=========================================*/\n const [totalsEpoch, setTotalsEpoch] = useState(0)\n const [totals, setTotals] = useState<SuppressionTotals | null>(null)\n useEffect(() => {\n let active = true\n void readSuppressionTotals(firestore, hostId)\n .then((read) => {\n if (active) setTotals(read)\n })\n .catch(() => {\n // Held at null rather than zeroed. \"Bounced: 0\" is a confident wrong\n // number in the reassuring direction, and this card exists to warn.\n if (active) setTotals(null)\n })\n return () => {\n active = false\n }\n // The list is a live listener and refreshes itself; an aggregate is a\n // one-shot read and would otherwise keep reporting the breakdown from\n // before the address was put back.\n }, [firestore, hostId, totalsEpoch])\n\n /*\n * The ADD, through a route rather than a client write.\n *\n * The Remove button below writes straight from the browser, and this does\n * not, which looks inconsistent until the document id is considered: an\n * entry is keyed by `sha256` of the normalized address, and a browser\n * computing that itself would be a second derivation of the key every\n * reader shares. Getting it wrong is silent and one-directional — the\n * merchant is told the person is suppressed and the mail keeps going. A\n * removal has no such hazard: it names a row that is already on screen.\n */\n const handleAdd = useCallback(async () => {\n const typed = addInput.trim()\n if (!typed || busy) return\n setBusy(true)\n try {\n const response = await authorizedFetch(\n user,\n '/api/email/suppression-add',\n {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ hostId, emails: typed, note: addNote.trim() }),\n },\n )\n const payload = await response.json().catch(() => ({}))\n if (!response.ok) {\n return void enqueueSnackbar(\n payload?.error ?? 'The address could not be suppressed.',\n { variant: 'error' },\n )\n }\n const results = (payload?.results ?? []) as Array<{\n input: string\n added: boolean\n refusal?: string\n }>\n const added = Number(payload?.added ?? 0)\n const rejected = results.filter(\n (result) => result.refusal === 'not-an-address',\n )\n // The refusals are NAMED, because \"3 of 5 added\" leaves an operator to\n // work out which two, and the two that failed are the ones somebody\n // asked to stop being emailed.\n if (rejected.length) {\n enqueueSnackbar(\n `Not an email address: ${rejected\n .map((result) => result.input)\n .join(', ')}`,\n { variant: 'warning' },\n )\n }\n if (added) {\n enqueueSnackbar(\n added === 1\n ? 'Added to the suppression list'\n : `${added} addresses added to the suppression list`,\n { variant: 'success', persist: false },\n )\n } else if (!rejected.length) {\n enqueueSnackbar('Already on the suppression list', { variant: 'info' })\n }\n if (added) {\n setAddInput('')\n setAddNote('')\n setAdding(false)\n setTotalsEpoch((epoch) => epoch + 1)\n }\n } catch (error) {\n console.error(error)\n enqueueSnackbar('An error has occurred', { variant: 'error' })\n } finally {\n setBusy(false)\n }\n }, [addInput, addNote, busy, user, hostId, enqueueSnackbar])\n\n /**\n * Whether one address is ALSO on the platform-wide list.\n *\n * The two lists are consulted together at send time and were visible\n * separately, so a merchant who removed their own entry could still find\n * the address was never mailed, with nothing anywhere saying why. The\n * platform entry is invisible to them and cannot be lifted by them, which\n * is precisely why it has to be said before the click rather than\n * discovered from a recipient count that stays short.\n */\n const isBlockedPlatformWide = useCallback(\n async (email: string): Promise<boolean> => {\n try {\n const response = await authorizedFetch(\n user,\n '/api/email/suppression-status',\n {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ hostId, emails: email }),\n },\n )\n if (!response.ok) return false\n const payload = await response.json().catch(() => ({}))\n return ((payload?.platform ?? []) as string[]).length > 0\n } catch (error) {\n console.error(error)\n return false\n }\n },\n [user, hostId],\n )\n\n const handleRemove = async (row: SuppressionRow) => {\n const reason = describeReason(row.reason).label.toLowerCase()\n // The platform entry is invisible to a merchant and cannot be lifted by\n // one, so removing the site's row here changes nothing about whether the\n // address is mailed. Saying so BEFORE the click is the whole point: the\n // alternative is a merchant who removes the row, sends again, and sees a\n // recipient count that is still short with nothing explaining it.\n /*\n * ASKED, NOT MOUNTED.\n *\n * One keyed read for the one address the merchant is acting on, at the\n * moment they act. Fetching this for every visible row on mount would be\n * a request per page render for an answer that is only ever needed on a\n * click, and this card is one tab of a page a merchant opens to read.\n *\n * A failed check answers \"not blocked\", which is the ordinary case: the\n * dialog then reads exactly as it did before, and the removal still\n * works. Refusing to open the dialog because a supplementary lookup\n * failed would make an outage on an explanation into an outage on the\n * control it explains.\n */\n const alsoPlatform = row.email\n ? await isBlockedPlatformWide(row.email)\n : false\n const accepted = await confirm({\n title: alsoPlatform\n ? 'This address will still be skipped'\n : 'Put this address back on your list?',\n description: alsoPlatform\n ? `${row.email ?? 'This address'} bounced permanently or reported ` +\n 'spam somewhere else in Aglyn, so it is on the platform-wide list ' +\n 'as well as yours. Removing your entry will not start mail ' +\n 'reaching it — contact support to have the platform entry lifted.'\n : `${row.email ?? 'This address'} is suppressed because it ` +\n `${reason === 'bounced' ? 'bounced permanently' : reason === 'marked as spam' ? 'was marked as spam' : reason === 'added by hand' ? 'was added by hand' : 'unsubscribed'}. ` +\n 'Removing the entry means your next campaign will email it again.',\n confirmationText: 'Remove',\n confirmationButtonProps: { color: 'error' },\n })\n // `confirm` resolves with NO VALUE and REJECTS on cancel, so gating on\n // the resolved value alone makes this always return (AGL-950).\n .then(() => true)\n .catch(() => false)\n if (!accepted) return\n try {\n await deleteDoc(\n doc(firestore, 'hosts', hostId, 'suppressions', row.$id),\n )\n enqueueSnackbar('Removed from the suppression list', {\n variant: 'success',\n persist: false,\n })\n setTotalsEpoch((epoch) => epoch + 1)\n } catch (error) {\n console.error(error)\n enqueueSnackbar('An error has occurred', { variant: 'error' })\n }\n }\n\n const columns: GridColDef<SuppressionRow>[] = [\n {\n field: 'email',\n headerName: 'Address',\n flex: 1,\n minWidth: 240,\n /*\n Entries are keyed by `sha256(email)` because addresses are PII, and the\n address itself is stored in the document. An older row written before\n the address was stored has only its hash — which tells a merchant\n nothing, so it says so rather than displaying 64 hex characters.\n */\n renderCell: ({ row }) =>\n row.email || (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'(address not recorded)'}\n </Typography>\n ),\n },\n {\n field: 'reason',\n headerName: 'Reason',\n width: 230,\n // An absent reason is an unsubscribe, as the chip says.\n valueGetter: (_value, row) => String(row.reason ?? 'unsubscribe'),\n renderCell: ({ row }) => {\n const described = describeReason(row.reason)\n return (\n <Stack\n direction=\"row\"\n spacing={0.5}\n sx={{ alignItems: 'center', height: '100%' }}\n >\n <Chip\n size=\"small\"\n color={described.color}\n variant=\"outlined\"\n label={described.label}\n />\n {/*\n A copy made when sites stopped being one sender. It is an\n entry like any other; the marker says why an address nobody\n on this site acted on is on its list.\n */}\n {row.carriedFromHostId ? (\n <Tooltip\n title={`Copied from ${\n orgMount\n ? orgSiteName(orgMount, row.carriedFromHostId)\n : 'another site'\n } when the two stopped being one sender`}\n >\n <Chip size=\"small\" variant=\"outlined\" label=\"Copied\" />\n </Tooltip>\n ) : null}\n </Stack>\n )\n },\n },\n {\n field: 'since',\n headerName: 'Since',\n width: 140,\n valueGetter: (_value, row) => onDate(row),\n },\n /*\n A SUPPRESSION HAS NO PAGE, so the row does not open one — this is the\n surface's one list whose rows are not a way in to anything. What it does\n have is the one act a merchant performs on an entry, and the trailing\n cluster is where every other list on this surface keeps that: a bare\n `Remove` in the row is a click that puts an address back into mailing\n range, sitting where the reader's eye is running along the row.\n */\n listActionsColumn(\n (row: SuppressionRow) => (\n <ListRowActions\n label={row.email || 'this entry'}\n items={[\n {\n key: 'remove',\n label: 'Remove from the list',\n icon: <MdiIcon path={mdiEmailCheckOutline.path} size={0.8} />,\n destructive: true,\n onClick: () => void handleRemove(row),\n },\n ]}\n />\n ),\n { width: 72 },\n ),\n ]\n\n return (\n <CardDisplay\n header=\"Suppressions\"\n help={pluginDocsHelp('emailCampaigns', { anchor: '#compliance' })}\n contentGutterX\n contentGutterY\n contentBordered=\"all\"\n HeaderProps={{\n action: (\n <Stack direction=\"row\" spacing={1}>\n {/* Each only for whom the route takes it (AGL-3554). */}\n {transfer?.can('export', { resource: SUPPRESSIONS_RESOURCE, scope: 'host', hostId }) ? (\n <Button\n size=\"small\"\n variant=\"outlined\"\n startIcon={<MdiIcon path={mdiTrayArrowDown.path} size={0.8} />}\n onClick={() =>\n transfer.openExport({\n resource: SUPPRESSIONS_RESOURCE,\n scope: 'host',\n hostId,\n ...(exportFilter ? { filter: exportFilter } : {}),\n })\n }\n >\n {'Export'}\n </Button>\n ) : null}\n {/* An import left unfinished, reopened where it stopped (AGL-3549). */}\n <TransferResumeImport\n target={{ resource: SUPPRESSIONS_RESOURCE, scope: 'host', hostId }}\n onFinished={() => setTotalsEpoch((epoch) => epoch + 1)}\n />\n {transfer?.can('import', { resource: SUPPRESSIONS_RESOURCE, scope: 'host', hostId }) ? (\n <Button\n size=\"small\"\n variant=\"outlined\"\n startIcon={<MdiIcon path={mdiTrayArrowUp.path} size={0.8} />}\n onClick={() =>\n transfer.openImport({\n resource: SUPPRESSIONS_RESOURCE,\n scope: 'host',\n hostId,\n onFinished: () => setTotalsEpoch((epoch) => epoch + 1),\n })\n }\n >\n {'Import'}\n </Button>\n ) : null}\n <Button\n size=\"small\"\n variant=\"contained\"\n onClick={() => setAdding(true)}\n >\n {'Add'}\n </Button>\n </Stack>\n ),\n }}\n >\n <Stack spacing={1.5}>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Addresses this site’s marketing email skips. Someone lands here ' +\n 'by clicking unsubscribe, by bouncing permanently, by marking a ' +\n 'message as spam, or because you added them — this is where the ' +\n 'gap between a campaign’s recipient count and what it actually ' +\n 'sent comes from.'}\n </Typography>\n {entries.length === 0 && !hasMore && !filtering ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Nobody is suppressed. Every address in your audiences is ' +\n 'currently mailable.'}\n </Typography>\n ) : (\n <>\n <Stack direction=\"row\" spacing={1} sx={{ flexWrap: 'wrap' }}>\n {totals === null ? (\n <Typography variant=\"caption\" color=\"text.secondary\">\n {'Could not read the breakdown. This is not the same as ' +\n 'nobody having bounced.'}\n </Typography>\n ) : (\n Object.entries(totals)\n // A reason nobody has hit is not news, and three chips\n // reading zero make the two that matter harder to find.\n .filter(([, total]) => total > 0)\n .map(([reason, total]) => {\n const described = describeReason(reason)\n return (\n <Chip\n key={reason}\n size=\"small\"\n color={described.color}\n variant=\"outlined\"\n label={`${described.label}: ${total}`}\n />\n )\n })\n )}\n </Stack>\n <ListFilterChips\n fields={SUPPRESSION_LIST_QUERY.fields}\n headers={SUPPRESSION_FILTER_HEADERS}\n clauses={gridFilter.clauses}\n onChange={gridFilter.setClauses}\n options={SUPPRESSION_FILTER_OPTIONS}\n />\n <ListQueryNotices refused={refusals} notices={plan.notices} />\n <ListTable\n aria-label=\"Suppressed addresses\"\n rows={entries}\n columns={listFilterGridColumns(\n columns as GridColDef[],\n SUPPRESSION_LIST_QUERY.fields,\n SUPPRESSION_FILTER_OPTIONS,\n SUPPRESSION_FILTER_HEADERS,\n )}\n rowHeight={TABLE_ROW_HEIGHT}\n // Paged by the footer below, so the grid must not also slice.\n hideFooter\n // The panel and the search go to the query; the grid neither\n // filters nor sorts the page it holds.\n filterMode=\"server\"\n filterModel={gridFilter.filterModel}\n onFilterModelChange={gridFilter.onFilterModelChange}\n quickFilter\n disableColumnSorting\n noRowsLabel=\"No suppressions match these filters\"\n />\n <ListPagination\n page={page}\n pageSize={pageSize}\n rowCount={entries.length}\n hasMore={hasMore}\n onPageChange={setPage}\n onPageSizeChange={setPageSize}\n // The collection's real size, so the footer's count line says\n // \"1–10 of 812\" rather than \"of more than 10\" — the aggregate\n // above already knows it, and it is the same number the chips\n // are a breakdown of. A filtered list's size is unknown.\n count={\n totals && !filtering\n ? Object.values(totals).reduce((a, b) => a + b, 0)\n : undefined\n }\n />\n </>\n )}\n </Stack>\n {/*\n A DRAWER, not a form stacked above the table.\n Creating is a drawer and picking is a dialog, which is how Screens,\n Components, Layouts and Templates all take a name before they create\n one; the chrome here is the same `NavigationDrawerComponent` those go\n through, composed directly because the console's wrapper around it\n lives in an application a plugin library may not import.\n */}\n <NavigationDrawerComponent\n open={adding}\n anchor=\"right\"\n variant=\"temporary\"\n onClose={() => setAdding(false)}\n AppBarProps={{ color: 'surface' }}\n appBarLeft={\n <>\n <IconButton\n color=\"inherit\"\n edge=\"start\"\n onClick={() => setAdding(false)}\n sx={{ mr: 2 }}\n >\n <MdiIcon path={ICON_VARIANT_CLOSE.path} />\n <SrOnly>{'close drawer'}</SrOnly>\n </IconButton>\n <Typography variant=\"h6\" component=\"div\">\n {'Stop emailing an address'}\n </Typography>\n </>\n }\n appBarRight={\n <Button\n variant=\"outlined\"\n color=\"inherit\"\n onClick={() => setAdding(false)}\n >\n {'Cancel'}\n </Button>\n }\n >\n <Container gutterY>\n <Stack spacing={2}>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Use this when somebody asks you to stop emailing them by ' +\n 'reply, by phone, or in person. They stay on your audiences ' +\n 'and keep every record you hold about them — this only stops ' +\n 'this site’s marketing email reaching them.'}\n </Typography>\n <TextField\n label=\"Email addresses\"\n value={addInput}\n onChange={(event) => setAddInput(event.target.value)}\n multiline\n minRows={3}\n fullWidth\n autoFocus\n helperText={\n 'One per line, or separated by commas. Up to 50 at a time.'\n }\n />\n <TextField\n label=\"Note (optional)\"\n value={addNote}\n onChange={(event) => setAddNote(event.target.value)}\n fullWidth\n helperText={\n 'How the request reached you. Kept with the entry as the ' +\n 'record that it was honored.'\n }\n slotProps={{ htmlInput: { maxLength: 200 } }}\n />\n <Alert severity=\"info\">\n {'Order confirmations, booking reminders and password resets ' +\n 'are unaffected. Somebody who asked to stop hearing from ' +\n 'your marketing still gets their receipt.'}\n </Alert>\n <Stack direction=\"row\" spacing={1} sx={{ justifyContent: 'flex-end' }}>\n <Button\n variant=\"contained\"\n disabled={busy || !addInput.trim()}\n onClick={() => void handleAdd()}\n >\n {'Add to suppression list'}\n </Button>\n </Stack>\n </Stack>\n </Container>\n </NavigationDrawerComponent>\n </CardDisplay>\n )\n}\nSuppressionsCard.displayName = 'SuppressionsCard'\n\nexport default SuppressionsCard\n"],"names":["TransferResumeImport","pluginDocsHelp","useTransferLauncher","ICON_VARIANT_CLOSE","mdiEmailCheckOutline","mdiTrayArrowDown","mdiTrayArrowUp","CardDisplay","Container","MdiIcon","SrOnly","useConfirmationContext","ListFilterChips","ListPagination","ListQueryNotices","listQueryRefusals","ListRowActions","ListTable","listActionsColumn","listFilterGridColumns","TABLE_ROW_HEIGHT","useListGridFilter","NavigationDrawerComponent","useSnackbar","Alert","Chip","IconButton","Stack","TextField","Tooltip","Typography","Button","collection","deleteDoc","doc","useCallback","useEffect","useMemo","useState","useFirestore","useUser","useListQuery","authorizedFetch","SUPPRESSION_FILTER_HEADERS","SUPPRESSION_LIST_QUERY","describeSuppressionReason","describeReason","readSuppressionTotals","SUPPRESSION_REASONS","orgSiteName","useEmailOrgMount","SUPPRESSIONS_RESOURCE","SUPPRESSION_FILTER_OPTIONS","reason","Object","entries","map","value","described","label","SUPPRESSION_SELECT_FIELDS","onDate","row","seconds","createdAt","suppressedAt","Date","toISOString","slice","SuppressionsCard","props","hostId","firestore","data","user","enqueueSnackbar","confirm","orgMount","adding","setAdding","addInput","setAddInput","addNote","setAddNote","busy","setBusy","gridFilter","selectFields","rows","hasMore","page","setPage","pageSize","setPageSize","plan","declaration","request","clauses","search","searchWords","deps","idField","filtering","length","some","word","trim","transfer","exportFilter","filters","refusals","refused","fields","headers","options","totalsEpoch","setTotalsEpoch","totals","setTotals","active","then","read","catch","handleAdd","typed","response","method","body","JSON","stringify","emails","note","payload","json","ok","error","variant","results","added","Number","rejected","filter","result","refusal","input","join","persist","epoch","console","isBlockedPlatformWide","email","platform","handleRemove","toLowerCase","alsoPlatform","accepted","title","description","confirmationText","confirmationButtonProps","color","$id","columns","field","headerName","flex","minWidth","renderCell","width","valueGetter","_value","String","direction","spacing","sx","alignItems","height","size","carriedFromHostId","items","key","icon","path","destructive","onClick","header","help","anchor","contentGutterX","contentGutterY","contentBordered","HeaderProps","action","can","resource","scope","startIcon","openExport","target","onFinished","openImport","flexWrap","total","onChange","setClauses","notices","aria-label","rowHeight","hideFooter","filterMode","filterModel","onFilterModelChange","quickFilter","disableColumnSorting","noRowsLabel","rowCount","onPageChange","onPageSizeChange","count","values","reduce","a","b","undefined","open","onClose","AppBarProps","appBarLeft","edge","mr","component","appBarRight","gutterY","event","multiline","minRows","fullWidth","autoFocus","helperText","slotProps","htmlInput","maxLength","severity","justifyContent","disabled","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAEA,SAASA,oBAAoB,QAAQ,gDAA+C;AACpF,SAASC,cAAc,QAAQ,eAAc;AAC7C,SAASC,mBAAmB,QAAQ,mDAAkD;AACtF,SAASC,kBAAkB,QAAQ,2BAA0B;AAC7D,SACEC,oBAAoB,EACpBC,gBAAgB,EAChBC,cAAc,QACT,yBAAwB;AAC/B,SACEC,WAAW,EACXC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,sBAAsB,QACjB,uBAAsB;AAC7B,OAAOC,qBAAqB,8DAA6D;AACzF,SAASC,cAAc,QAAQ,4DAA2D;AAC1F,OAAOC,oBACLC,iBAAiB,QACZ,+DAA8D;AACrE,SACEC,cAAc,EACdC,SAAS,EACTC,iBAAiB,QACZ,uDAAsD;AAC7D,SAASC,qBAAqB,QAAQ,8CAA6C;AACnF,SAASC,gBAAgB,QAAQ,8CAA6C;AAC9E,SAASC,iBAAiB,QAAQ,kDAAiD;AACnF;;;;;;;;;;CAUC,GACD,SAASC,yBAAyB,QAAQ,8DAA6D;AACvG,SAASC,WAAW,QAAQ,8BAA6B;AACzD,SACEC,KAAK,EACLC,I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AEC,WAAW;oCAAI;gCAAE;;0CAE7C,KAACzN;gCAAM0N,UAAS;0CACb,gEACC,6DACA;;0CAEJ,KAACvN;gCAAMiJ,WAAU;gCAAMC,SAAS;gCAAGC,IAAI;oCAAEqE,gBAAgB;gCAAW;0CAClE,cAAA,KAACpN;oCACCyG,SAAQ;oCACR4G,UAAUhK,QAAQ,CAACJ,SAAS0B,IAAI;oCAChC8E,SAAS,IAAM,KAAK7D;8CAEnB;;;;;;;;;AAQjB;AACAtD,iBAAiBgL,WAAW,GAAG;AAE/B,eAAehL,iBAAgB"}
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/email/src/lib/components/suppressions-card.tsx"],"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'use client'\n\nimport { TransferResumeImport } from '@aglyn/aglyn/app-utils/transfer-resume-import'\nimport { pluginDocsHelp } from '@aglyn/aglyn'\nimport { useTransferLauncher } from '@aglyn/aglyn/app-utils/transfer-launcher-context'\nimport { ICON_VARIANT_CLOSE } from '@aglyn/shared-data-enums'\nimport {\n mdiEmailCheckOutline,\n mdiTrayArrowDown,\n mdiTrayArrowUp,\n} from '@aglyn/shared-data-mdi'\nimport {\n CardDisplay,\n Container,\n MdiIcon,\n SrOnly,\n useConfirmationContext,\n} from '@aglyn/shared-ui-jsx'\nimport ListFilterChips from '@aglyn/shared-ui-jsx/components/list-filter-chips.component'\nimport { ListPagination } from '@aglyn/shared-ui-jsx/components/list-pagination.component'\nimport ListQueryNotices, {\n listQueryRefusals,\n} from '@aglyn/shared-ui-jsx/components/list-query-notices.component'\nimport {\n ListRowActions,\n ListTable,\n listActionsColumn,\n} from '@aglyn/shared-ui-jsx/components/list-table.component'\nimport { listFilterGridColumns } from '@aglyn/shared-ui-jsx/const/list-grid-filter'\nimport { TABLE_ROW_HEIGHT } from '@aglyn/shared-ui-jsx/const/table-pagination'\nimport { useListGridFilter } from '@aglyn/shared-ui-jsx/hooks/use-list-grid-filter'\n/*\n * The shared drawer, reached by its own path.\n *\n * `@aglyn/shared-ui-jsx`'s barrel deliberately does not re-export this one, so\n * a deep import is the supported way in rather than an escape hatch. The\n * console's `CreateArtifactDrawer` — what Screens, Components, Layouts and\n * Templates create through — is this same component with a form inside it,\n * and it lives in `apps/console`, which a plugin library may not import. So\n * the chrome is composed from the same primitive rather than duplicated from\n * the wrapper.\n */\nimport { NavigationDrawerComponent } from '@aglyn/shared-ui-jsx/components/navigation-drawer.component'\nimport { useSnackbar } from '@aglyn/shared-ui-snackstack'\nimport {\n Alert,\n Chip,\n IconButton,\n Stack,\n TextField,\n Tooltip,\n Typography,\n} from '@mui/material'\nimport Button from '@mui/material/Button'\nimport type { GridColDef } from '@mui/x-data-grid'\nimport { collection, deleteDoc, doc } from 'firebase/firestore'\nimport { useCallback, useEffect, useMemo, useState } from 'react'\nimport { useFirestore, useUser } from '@aglyn/tenant-feature-instance'\nimport { useListQuery } from '@aglyn/tenant-feature-instance/hooks/use-list-query'\nimport { useListColumnSort } from '@aglyn/shared-ui-jsx/hooks/use-list-column-sort'\nimport type { ListQuerySort } from '@aglyn/shared-ui-jsx/const/list-query-plan'\nimport { authorizedFetch } from '@aglyn/shared-util-http/authorized-token'\nimport {\n SUPPRESSION_FILTER_HEADERS,\n SUPPRESSION_LIST_QUERY,\n} from '../constants/list-queries'\nimport {\n describeSuppressionReason as describeReason,\n readSuppressionTotals,\n SUPPRESSION_REASONS,\n type SuppressionTotals,\n} from './suppression-totals'\nimport { orgSiteName, useEmailOrgMount } from './email-org-mount'\nimport { SUPPRESSIONS_RESOURCE } from '../transfer/email-transfer-catalog'\n\nexport interface SuppressionsCardProps {\n hostId: string\n}\n\n/** A stored entry. `reason` is absent on anything written before AGL-2408. */\ninterface SuppressionRow {\n $id: string\n email?: string\n reason?: string\n suppressedAt?: { seconds?: number } | null\n createdAt?: { seconds?: number } | null\n /**\n * The site this entry was copied from when the two stopped being one\n * sender (AGL-3320). The copy keeps the original's reason and dates.\n */\n carriedFromHostId?: string\n}\n\n/*\n * What the suppressions grid's Filters panel offers, every clause and the\n * search on the list's query (AGL-3321): see `SUPPRESSION_LIST_QUERY`. The\n * Reason choices are the stored reasons, by the words the column uses.\n */\nconst SUPPRESSION_FILTER_OPTIONS = {\n reason: Object.entries(SUPPRESSION_REASONS).map(([value, described]) => ({\n value,\n label: described.label,\n })),\n}\nconst SUPPRESSION_SELECT_FIELDS = ['reason']\n\n/**\n * `YYYY-MM-DD` from a Firestore timestamp shape, or an em dash.\n *\n * `createdAt` first, and that ordering is the column's meaning rather than a\n * preference. Both writers restamp `suppressedAt` on every touch and write\n * `createdAt` only when the document is new, precisely so that a bounce\n * arriving after an unsubscribe does not move the date the person actually\n * unsubscribed. Reading `suppressedAt` first put the restamp on screen under a\n * heading that says \"Since\", and it is also the field the list is ordered by,\n * so a re-touched row would have sorted by one date and displayed another.\n */\nfunction onDate(row: SuppressionRow): string {\n const seconds = row.createdAt?.seconds ?? row.suppressedAt?.seconds\n if (!seconds) return '—'\n return new Date(seconds * 1000).toISOString().slice(0, 10)\n}\n\n/**\n * Suppressions (AGL-2410): who is not being emailed, and why.\n *\n * ## What was missing\n *\n * `hosts/{hostId}/suppressions` was written by two paths — the unsubscribe\n * handler and, since AGL-1918, the Resend webhook on a permanent bounce or a\n * complaint — and read by exactly one: `campaign-send.ts`, to filter an\n * audience. Nothing in the console displayed it. So a merchant could not\n * answer any of:\n *\n * - *\"My campaign says 500 recipients and 480 sent — who were the other\n * 20?\"* The send returns `{recipients, sent}` and the difference was\n * unexplained.\n * - *\"Is my list going stale?\"* A bounce rate is the single most useful\n * number about a list and there was nowhere to see it.\n * - *\"This address was suppressed by mistake.\"* There was no way to remove\n * an entry — and a link prescanner unsubscribing someone (AGL-2408 §2) was\n * therefore unrecoverable from inside the product.\n *\n * ## Why a surface and not another counter\n *\n * AGL-1918 deliberately did NOT write a `stats.bounces` counter alongside its\n * fix, because a number with no screen to show it is the written-but-never-\n * read shape this issue is about, one level up. So the fix is the READER, and\n * the breakdown here is derived from the rows on screen rather than from a\n * second stored figure that could disagree with them.\n *\n * ## Removing an entry\n *\n * A plain client `deleteDoc`, and that is a decision. The list belongs to the\n * merchant, host admins already read it through the same rules, and removing\n * a row does nothing except make an address targetable again — there is no\n * counter to launder and no money attached, which is the AGL-1367 test for\n * whether a write has to move server-side.\n *\n * The confirmation is not decoration either: for a `bounce` the address very\n * likely does not exist, and mailing it again is what a provider scores the\n * sending domain on. So the dialog says which reason is being overridden\n * rather than asking a generic \"are you sure\".\n */\nexport function SuppressionsCard(props: SuppressionsCardProps) {\n const { hostId } = props\n const firestore = useFirestore()\n const { data: user } = useUser()\n const { enqueueSnackbar } = useSnackbar()\n const { confirm } = useConfirmationContext()\n // Present on the organization's page, which can name the other site.\n const orgMount = useEmailOrgMount()\n const [adding, setAdding] = useState(false)\n\n const [addInput, setAddInput] = useState('')\n const [addNote, setAddNote] = useState('')\n const [busy, setBusy] = useState(false)\n\n /*\n * The page IS the query, ordered by the server (AGL-2501, AGL-2292), and\n * every filter and search word is a predicate on it (AGL-3321).\n *\n * This was `limit(500)` with no `orderBy`, sorted by date in the browser.\n * Firestore answers an unordered limit in DOCUMENT-ID order, and an entry\n * here is keyed by `sha256(email)` — so the window was five hundred\n * addresses chosen by the hash of the address, and the client sort dressed\n * that sample up as the newest five hundred. A list past the ceiling\n * therefore hid whoever bounced this morning behind whoever happened to\n * hash low, with no gap on screen to notice and no control asking for more.\n *\n * `createdAt` is the safe field to order on, and that is checked rather\n * than assumed: both writers — the unsubscribe handler and the Resend\n * bounce/complaint webhook — stamp it when the document is created, the\n * pre-AGL-2408 handler wrote `{ email, createdAt }`, and `suppressions` is\n * not in `IMPORTABLE_FIELDS`, so no restore path can produce a row without\n * one. `suppressedAt` would NOT be safe: it is absent on every entry\n * written before AGL-1918, and `orderBy` drops documents that lack the\n * field rather than mis-sorting them.\n */\n const gridFilter = useListGridFilter({ selectFields: SUPPRESSION_SELECT_FIELDS })\n /*\n * EVERY HEADER SORTS ON THE QUERY (AGL-3680): Since, Address and Reason\n * are stored on every entry (see `SUPPRESSION_LIST_QUERY`). Newest first\n * until a header is clicked.\n */\n const [askedSort, setAskedSort] = useState<ListQuerySort | null>(\n SUPPRESSION_LIST_QUERY.sorts[0],\n )\n const {\n rows: entries,\n hasMore,\n page,\n setPage,\n pageSize,\n setPageSize,\n plan,\n } = useListQuery<SuppressionRow>({\n collection: collection(firestore, 'hosts', hostId, 'suppressions'),\n declaration: SUPPRESSION_LIST_QUERY,\n request: {\n clauses: gridFilter.clauses,\n search: gridFilter.searchWords,\n sort: askedSort,\n },\n deps: [firestore, hostId],\n idField: '$id',\n })\n const columnSort = useListColumnSort<SuppressionRow>({\n sorts: SUPPRESSION_LIST_QUERY.sorts,\n defaultSort: SUPPRESSION_LIST_QUERY.sorts[0],\n sort: askedSort,\n onSortChange: setAskedSort,\n orderBy: plan.orderBy,\n rows: entries,\n })\n const filtering =\n gridFilter.clauses.length > 0 || gridFilter.searchWords.some((word) => word.trim())\n /*\n * IMPORT AND EXPORT (AGL-3529) open the console's transfer wizard and\n * export dialog on this site's list. An import only ever adds: an address\n * already here keeps its entry, and nothing removes one. The export's\n * \"current filter\" is this table's own query.\n */\n const transfer = useTransferLauncher()\n const exportFilter = filtering\n ? {\n label: 'Entries matching the table’s filters',\n value: { filters: plan.filters },\n }\n : null\n const refusals = useMemo(\n () =>\n listQueryRefusals(plan.refused, {\n fields: SUPPRESSION_LIST_QUERY.fields,\n headers: SUPPRESSION_FILTER_HEADERS,\n options: SUPPRESSION_FILTER_OPTIONS,\n }),\n [plan.refused],\n )\n\n /*==========================================\n * THE BREAKDOWN IS A SERVER AGGREGATE, not a tally of the page.\n *\n * These chips answer \"is my list going stale?\", and they were a `reduce`\n * over whatever the listener had fetched — so on a site past the old\n * ceiling \"Bounced: 140\" meant 140 of an arbitrary five hundred, and under\n * a ten-row page it would have meant 140 of ten. A bounce rate computed\n * from a sample is not a bounce rate, and nothing on screen said it was one.\n *\n * `readSuppressionTotals` holds the four reads and the remainder rule for\n * unsubscribes, and the organization's summary of every site's list asks\n * the same function, so a site's figures read the same on both pages.\n *=========================================*/\n const [totalsEpoch, setTotalsEpoch] = useState(0)\n const [totals, setTotals] = useState<SuppressionTotals | null>(null)\n useEffect(() => {\n let active = true\n void readSuppressionTotals(firestore, hostId)\n .then((read) => {\n if (active) setTotals(read)\n })\n .catch(() => {\n // Held at null rather than zeroed. \"Bounced: 0\" is a confident wrong\n // number in the reassuring direction, and this card exists to warn.\n if (active) setTotals(null)\n })\n return () => {\n active = false\n }\n // The list is a live listener and refreshes itself; an aggregate is a\n // one-shot read and would otherwise keep reporting the breakdown from\n // before the address was put back.\n }, [firestore, hostId, totalsEpoch])\n\n /*\n * The ADD, through a route rather than a client write.\n *\n * The Remove button below writes straight from the browser, and this does\n * not, which looks inconsistent until the document id is considered: an\n * entry is keyed by `sha256` of the normalized address, and a browser\n * computing that itself would be a second derivation of the key every\n * reader shares. Getting it wrong is silent and one-directional — the\n * merchant is told the person is suppressed and the mail keeps going. A\n * removal has no such hazard: it names a row that is already on screen.\n */\n const handleAdd = useCallback(async () => {\n const typed = addInput.trim()\n if (!typed || busy) return\n setBusy(true)\n try {\n const response = await authorizedFetch(\n user,\n '/api/email/suppression-add',\n {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ hostId, emails: typed, note: addNote.trim() }),\n },\n )\n const payload = await response.json().catch(() => ({}))\n if (!response.ok) {\n return void enqueueSnackbar(\n payload?.error ?? 'The address could not be suppressed.',\n { variant: 'error' },\n )\n }\n const results = (payload?.results ?? []) as Array<{\n input: string\n added: boolean\n refusal?: string\n }>\n const added = Number(payload?.added ?? 0)\n const rejected = results.filter(\n (result) => result.refusal === 'not-an-address',\n )\n // The refusals are NAMED, because \"3 of 5 added\" leaves an operator to\n // work out which two, and the two that failed are the ones somebody\n // asked to stop being emailed.\n if (rejected.length) {\n enqueueSnackbar(\n `Not an email address: ${rejected\n .map((result) => result.input)\n .join(', ')}`,\n { variant: 'warning' },\n )\n }\n if (added) {\n enqueueSnackbar(\n added === 1\n ? 'Added to the suppression list'\n : `${added} addresses added to the suppression list`,\n { variant: 'success', persist: false },\n )\n } else if (!rejected.length) {\n enqueueSnackbar('Already on the suppression list', { variant: 'info' })\n }\n if (added) {\n setAddInput('')\n setAddNote('')\n setAdding(false)\n setTotalsEpoch((epoch) => epoch + 1)\n }\n } catch (error) {\n console.error(error)\n enqueueSnackbar('An error has occurred', { variant: 'error' })\n } finally {\n setBusy(false)\n }\n }, [addInput, addNote, busy, user, hostId, enqueueSnackbar])\n\n /**\n * Whether one address is ALSO on the platform-wide list.\n *\n * The two lists are consulted together at send time and were visible\n * separately, so a merchant who removed their own entry could still find\n * the address was never mailed, with nothing anywhere saying why. The\n * platform entry is invisible to them and cannot be lifted by them, which\n * is precisely why it has to be said before the click rather than\n * discovered from a recipient count that stays short.\n */\n const isBlockedPlatformWide = useCallback(\n async (email: string): Promise<boolean> => {\n try {\n const response = await authorizedFetch(\n user,\n '/api/email/suppression-status',\n {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ hostId, emails: email }),\n },\n )\n if (!response.ok) return false\n const payload = await response.json().catch(() => ({}))\n return ((payload?.platform ?? []) as string[]).length > 0\n } catch (error) {\n console.error(error)\n return false\n }\n },\n [user, hostId],\n )\n\n const handleRemove = async (row: SuppressionRow) => {\n const reason = describeReason(row.reason).label.toLowerCase()\n // The platform entry is invisible to a merchant and cannot be lifted by\n // one, so removing the site's row here changes nothing about whether the\n // address is mailed. Saying so BEFORE the click is the whole point: the\n // alternative is a merchant who removes the row, sends again, and sees a\n // recipient count that is still short with nothing explaining it.\n /*\n * ASKED, NOT MOUNTED.\n *\n * One keyed read for the one address the merchant is acting on, at the\n * moment they act. Fetching this for every visible row on mount would be\n * a request per page render for an answer that is only ever needed on a\n * click, and this card is one tab of a page a merchant opens to read.\n *\n * A failed check answers \"not blocked\", which is the ordinary case: the\n * dialog then reads exactly as it did before, and the removal still\n * works. Refusing to open the dialog because a supplementary lookup\n * failed would make an outage on an explanation into an outage on the\n * control it explains.\n */\n const alsoPlatform = row.email\n ? await isBlockedPlatformWide(row.email)\n : false\n const accepted = await confirm({\n title: alsoPlatform\n ? 'This address will still be skipped'\n : 'Put this address back on your list?',\n description: alsoPlatform\n ? `${row.email ?? 'This address'} bounced permanently or reported ` +\n 'spam somewhere else in Aglyn, so it is on the platform-wide list ' +\n 'as well as yours. Removing your entry will not start mail ' +\n 'reaching it — contact support to have the platform entry lifted.'\n : `${row.email ?? 'This address'} is suppressed because it ` +\n `${reason === 'bounced' ? 'bounced permanently' : reason === 'marked as spam' ? 'was marked as spam' : reason === 'added by hand' ? 'was added by hand' : 'unsubscribed'}. ` +\n 'Removing the entry means your next campaign will email it again.',\n confirmationText: 'Remove',\n confirmationButtonProps: { color: 'error' },\n })\n // `confirm` resolves with NO VALUE and REJECTS on cancel, so gating on\n // the resolved value alone makes this always return (AGL-950).\n .then(() => true)\n .catch(() => false)\n if (!accepted) return\n try {\n await deleteDoc(\n doc(firestore, 'hosts', hostId, 'suppressions', row.$id),\n )\n enqueueSnackbar('Removed from the suppression list', {\n variant: 'success',\n persist: false,\n })\n setTotalsEpoch((epoch) => epoch + 1)\n } catch (error) {\n console.error(error)\n enqueueSnackbar('An error has occurred', { variant: 'error' })\n }\n }\n\n const columns: GridColDef<SuppressionRow>[] = [\n {\n field: 'email',\n headerName: 'Address',\n flex: 1,\n minWidth: 240,\n /*\n Entries are keyed by `sha256(email)` because addresses are PII, and the\n address itself is stored in the document. An older row written before\n the address was stored has only its hash — which tells a merchant\n nothing, so it says so rather than displaying 64 hex characters.\n */\n renderCell: ({ row }) =>\n row.email || (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'(address not recorded)'}\n </Typography>\n ),\n },\n {\n field: 'reason',\n headerName: 'Reason',\n width: 230,\n // An absent reason is an unsubscribe, as the chip says.\n valueGetter: (_value, row) => String(row.reason ?? 'unsubscribe'),\n renderCell: ({ row }) => {\n const described = describeReason(row.reason)\n return (\n <Stack\n direction=\"row\"\n spacing={0.5}\n sx={{ alignItems: 'center', height: '100%' }}\n >\n <Chip\n size=\"small\"\n color={described.color}\n variant=\"outlined\"\n label={described.label}\n />\n {/*\n A copy made when sites stopped being one sender. It is an\n entry like any other; the marker says why an address nobody\n on this site acted on is on its list.\n */}\n {row.carriedFromHostId ? (\n <Tooltip\n title={`Copied from ${\n orgMount\n ? orgSiteName(orgMount, row.carriedFromHostId)\n : 'another site'\n } when the two stopped being one sender`}\n >\n <Chip size=\"small\" variant=\"outlined\" label=\"Copied\" />\n </Tooltip>\n ) : null}\n </Stack>\n )\n },\n },\n {\n field: 'since',\n headerName: 'Since',\n width: 140,\n valueGetter: (_value, row) => onDate(row),\n },\n /*\n A SUPPRESSION HAS NO PAGE, so the row does not open one — this is the\n surface's one list whose rows are not a way in to anything. What it does\n have is the one act a merchant performs on an entry, and the trailing\n cluster is where every other list on this surface keeps that: a bare\n `Remove` in the row is a click that puts an address back into mailing\n range, sitting where the reader's eye is running along the row.\n */\n listActionsColumn(\n (row: SuppressionRow) => (\n <ListRowActions\n label={row.email || 'this entry'}\n items={[\n {\n key: 'remove',\n label: 'Remove from the list',\n icon: <MdiIcon path={mdiEmailCheckOutline.path} size={0.8} />,\n destructive: true,\n onClick: () => void handleRemove(row),\n },\n ]}\n />\n ),\n { width: 72 },\n ),\n ]\n\n return (\n <CardDisplay\n header=\"Suppressions\"\n help={pluginDocsHelp('emailCampaigns', { anchor: '#compliance' })}\n contentGutterX\n contentGutterY\n contentBordered=\"all\"\n HeaderProps={{\n action: (\n <Stack direction=\"row\" spacing={1}>\n {/* Each only for whom the route takes it (AGL-3554). */}\n {transfer?.can('export', { resource: SUPPRESSIONS_RESOURCE, scope: 'host', hostId }) ? (\n <Button\n size=\"small\"\n variant=\"outlined\"\n startIcon={<MdiIcon path={mdiTrayArrowDown.path} size={0.8} />}\n onClick={() =>\n transfer.openExport({\n resource: SUPPRESSIONS_RESOURCE,\n scope: 'host',\n hostId,\n ...(exportFilter ? { filter: exportFilter } : {}),\n })\n }\n >\n {'Export'}\n </Button>\n ) : null}\n {/* An import left unfinished, reopened where it stopped (AGL-3549). */}\n <TransferResumeImport\n target={{ resource: SUPPRESSIONS_RESOURCE, scope: 'host', hostId }}\n onFinished={() => setTotalsEpoch((epoch) => epoch + 1)}\n />\n {transfer?.can('import', { resource: SUPPRESSIONS_RESOURCE, scope: 'host', hostId }) ? (\n <Button\n size=\"small\"\n variant=\"outlined\"\n startIcon={<MdiIcon path={mdiTrayArrowUp.path} size={0.8} />}\n onClick={() =>\n transfer.openImport({\n resource: SUPPRESSIONS_RESOURCE,\n scope: 'host',\n hostId,\n onFinished: () => setTotalsEpoch((epoch) => epoch + 1),\n })\n }\n >\n {'Import'}\n </Button>\n ) : null}\n <Button\n size=\"small\"\n variant=\"contained\"\n onClick={() => setAdding(true)}\n >\n {'Add'}\n </Button>\n </Stack>\n ),\n }}\n >\n <Stack spacing={1.5}>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Addresses this site’s marketing email skips. Someone lands here ' +\n 'by clicking unsubscribe, by bouncing permanently, by marking a ' +\n 'message as spam, or because you added them — this is where the ' +\n 'gap between a campaign’s recipient count and what it actually ' +\n 'sent comes from.'}\n </Typography>\n {entries.length === 0 && !hasMore && !filtering ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Nobody is suppressed. Every address in your audiences is ' +\n 'currently mailable.'}\n </Typography>\n ) : (\n <>\n <Stack useFlexGap direction=\"row\" spacing={1} sx={{ flexWrap: 'wrap' }}>\n {totals === null ? (\n <Typography variant=\"caption\" color=\"text.secondary\">\n {'Could not read the breakdown. This is not the same as ' +\n 'nobody having bounced.'}\n </Typography>\n ) : (\n Object.entries(totals)\n // A reason nobody has hit is not news, and three chips\n // reading zero make the two that matter harder to find.\n .filter(([, total]) => total > 0)\n .map(([reason, total]) => {\n const described = describeReason(reason)\n return (\n <Chip\n key={reason}\n size=\"small\"\n color={described.color}\n variant=\"outlined\"\n label={`${described.label}: ${total}`}\n />\n )\n })\n )}\n </Stack>\n <ListFilterChips\n fields={SUPPRESSION_LIST_QUERY.fields}\n headers={SUPPRESSION_FILTER_HEADERS}\n clauses={gridFilter.clauses}\n onChange={gridFilter.setClauses}\n options={SUPPRESSION_FILTER_OPTIONS}\n />\n <ListQueryNotices\n refused={refusals}\n notices={[...plan.notices, ...columnSort.notices]}\n />\n <ListTable\n aria-label=\"Suppressed addresses\"\n rows={columnSort.rows}\n columnSort={columnSort}\n columns={listFilterGridColumns(\n columns as GridColDef[],\n SUPPRESSION_LIST_QUERY.fields,\n SUPPRESSION_FILTER_OPTIONS,\n SUPPRESSION_FILTER_HEADERS,\n )}\n rowHeight={TABLE_ROW_HEIGHT}\n // Paged by the footer below, so the grid must not also slice.\n hideFooter\n // The panel, the search and the headers go to the query; the\n // grid neither filters nor sorts the page it holds.\n filterMode=\"server\"\n filterModel={gridFilter.filterModel}\n onFilterModelChange={gridFilter.onFilterModelChange}\n quickFilter\n noRowsLabel=\"No suppressions match these filters\"\n />\n <ListPagination\n page={page}\n pageSize={pageSize}\n rowCount={entries.length}\n hasMore={hasMore}\n onPageChange={setPage}\n onPageSizeChange={setPageSize}\n // The collection's real size, so the footer's count line says\n // \"1–10 of 812\" rather than \"of more than 10\" — the aggregate\n // above already knows it, and it is the same number the chips\n // are a breakdown of. A filtered list's size is unknown.\n count={\n totals && !filtering\n ? Object.values(totals).reduce((a, b) => a + b, 0)\n : undefined\n }\n />\n </>\n )}\n </Stack>\n {/*\n A DRAWER, not a form stacked above the table.\n Creating is a drawer and picking is a dialog, which is how Screens,\n Components, Layouts and Templates all take a name before they create\n one; the chrome here is the same `NavigationDrawerComponent` those go\n through, composed directly because the console's wrapper around it\n lives in an application a plugin library may not import.\n */}\n <NavigationDrawerComponent\n open={adding}\n anchor=\"right\"\n variant=\"temporary\"\n onClose={() => setAdding(false)}\n AppBarProps={{ color: 'surface' }}\n appBarLeft={\n <>\n <IconButton\n color=\"inherit\"\n edge=\"start\"\n onClick={() => setAdding(false)}\n sx={{ mr: 2 }}\n >\n <MdiIcon path={ICON_VARIANT_CLOSE.path} />\n <SrOnly>{'close drawer'}</SrOnly>\n </IconButton>\n <Typography variant=\"h6\" component=\"div\">\n {'Stop emailing an address'}\n </Typography>\n </>\n }\n appBarRight={\n <Button\n variant=\"outlined\"\n color=\"inherit\"\n onClick={() => setAdding(false)}\n >\n {'Cancel'}\n </Button>\n }\n >\n <Container gutterY>\n <Stack spacing={2}>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Use this when somebody asks you to stop emailing them by ' +\n 'reply, by phone, or in person. They stay on your audiences ' +\n 'and keep every record you hold about them — this only stops ' +\n 'this site’s marketing email reaching them.'}\n </Typography>\n <TextField\n label=\"Email addresses\"\n value={addInput}\n onChange={(event) => setAddInput(event.target.value)}\n multiline\n minRows={3}\n fullWidth\n autoFocus\n helperText={\n 'One per line, or separated by commas. Up to 50 at a time.'\n }\n />\n <TextField\n label=\"Note (optional)\"\n value={addNote}\n onChange={(event) => setAddNote(event.target.value)}\n fullWidth\n helperText={\n 'How the request reached you. Kept with the entry as the ' +\n 'record that it was honored.'\n }\n slotProps={{ htmlInput: { maxLength: 200 } }}\n />\n <Alert severity=\"info\">\n {'Order confirmations, booking reminders and password resets ' +\n 'are unaffected. Somebody who asked to stop hearing from ' +\n 'your marketing still gets their receipt.'}\n </Alert>\n <Stack direction=\"row\" spacing={1} sx={{ justifyContent: 'flex-end' }}>\n <Button\n variant=\"contained\"\n disabled={busy || !addInput.trim()}\n onClick={() => void handleAdd()}\n >\n {'Add to suppression list'}\n </Button>\n </Stack>\n </Stack>\n </Container>\n </NavigationDrawerComponent>\n </CardDisplay>\n )\n}\nSuppressionsCard.displayName = 'SuppressionsCard'\n\nexport default SuppressionsCard\n"],"names":["TransferResumeImport","pluginDocsHelp","useTransferLauncher","ICON_VARIANT_CLOSE","mdiEmailCheckOutline","mdiTrayArrowDown","mdiTrayArrowUp","CardDisplay","Container","MdiIcon","SrOnly","useConfirmationContext","ListFilterChips","ListPagination","ListQueryNotices","listQueryRefusals","ListRowActions","ListTable","listActionsColumn","listFilterGridColumns","TABLE_ROW_HEIGHT","useListGridFilter","NavigationDrawerComponent","useSnackbar","Alert","Chip","IconButton","Stack","TextField","Tooltip","Typography","Button","collection","deleteDoc","doc","useCallback","useEffect","useMemo","useState","useFirestore","useUser","useListQuery","useListColumnSort","authorizedFetch","SUPPRESSION_FILTER_HEADERS","SUPPRESSION_LIST_QUERY","describeSuppressionReason","describeReason","readSuppressionTotals","SUPPRESSION_REASONS","orgSiteName","useEmailOrgMount","SUPPRESSIONS_RESOURCE","SUPPRESSION_FILTER_OPTIONS","reason","Object","entries","map","value","described","label","SUPPRESSION_SELECT_FIELDS","onDate","row","seconds","createdAt","suppressedAt","Date","toISOString","slice","SuppressionsCard","props","hostId","firestore","data","user","enqueueSnackbar","confirm","orgMount","adding","setAdding","addInput","setAddInput","addNote","setAddNote","busy","setBusy","gridFilter","selectFields","askedSort","setAskedSort","sorts","rows","hasMore","page","setPage","pageSize","setPageSize","plan","declaration","request","clauses","search","searchWords","sort","deps","idField","columnSort","defaultSort","onSortChange","orderBy","filtering","length","some","word","trim","transfer","exportFilter","filters","refusals","refused","fields","headers","options","totalsEpoch","setTotalsEpoch","totals","setTotals","active","then","read","catch","handleAdd","typed","response","method","body","JSON","stringify","emails","note","payload","json","ok","error","variant","results","added","Number","rejected","filter","result","refusal","input","join","persist","epoch","console","isBlockedPlatformWide","email","platform","handleRemove","toLowerCase","alsoPlatform","accepted","title","description","confirmationText","confirmationButtonProps","color","$id","columns","field","headerName","flex","minWidth","renderCell","width","valueGetter","_value","String","direction","spacing","sx","alignItems","height","size","carriedFromHostId","items","key","icon","path","destructive","onClick","header","help","anchor","contentGutterX","contentGutterY","contentBordered","HeaderProps","action","can","resource","scope","startIcon","openExport","target","onFinished","openImport","useFlexGap","flexWrap","total","onChange","setClauses","notices","aria-label","rowHeight","hideFooter","filterMode","filterModel","onFilterModelChange","quickFilter","noRowsLabel","rowCount","onPageChange","onPageSizeChange","count","values","reduce","a","b","undefined","open","onClose","AppBarProps","appBarLeft","edge","mr","component","appBarRight","gutterY","event","multiline","minRows","fullWidth","autoFocus","helperText","slotProps","htmlInput","maxLength","severity","justifyContent","disabled","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAEA,SAASA,oBAAoB,QAAQ,gDAA+C;AACpF,SAASC,cAAc,QAAQ,eAAc;AAC7C,SAASC,mBAAmB,QAAQ,mDAAkD;AACtF,SAASC,kBAAkB,QAAQ,2BAA0B;AAC7D,SACEC,oBAAoB,EACpBC,gBAAgB,EAChBC,cAAc,QACT,yBAAwB;AAC/B,SACEC,WAAW,EACXC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,sBAAsB,QACjB,uBAAsB;AAC7B,OAAOC,qBAAqB,8DAA6D;AACzF,SAASC,cAAc,QAAQ,4DAA2D;AAC1F,OAAOC,oBACLC,iBAAiB,QACZ,+DAA8D;AACrE,SACEC,cAAc,EACdC,SAAS,EACTC,iBAAiB,QACZ,uDAAsD;AAC7D,SAASC,qBAAqB,QAAQ,8CAA6C;AACnF,SAASC,gBAAgB,QAAQ,8CAA6C;AAC9E,SAASC,iBAAiB,QAAQ,kDAAiD;AACnF;;;;;;;;;;CAUC,GACD,SAASC,yBAAyB,QAAQ,8DAA6D;AACvG,SAASC,WAAW,QAAQ,8BAA6B;AACzD,SACEC,KAAK,EACLC,IAAI,EACJC,UAAU,EACVC,KAAK,EACLC,SAAS,EACTC,OAAO,EACP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B,QAAUhK,YAAYgK,MAAMnC,MAAM,CAACrJ,KAAK;gCACnDyL,SAAS;gCACTC,SAAS;gCACTC,SAAS;gCACTC,SAAS;gCACTC,YACE;;0CAGJ,KAAC3N;gCACCgC,OAAM;gCACNF,OAAOyB;gCACPkI,UAAU,CAAC6B,QAAU9J,WAAW8J,MAAMnC,MAAM,CAACrJ,KAAK;gCAClD2L,SAAS;gCACTE,YACE,6DACA;gCAEFC,WAAW;oCAAEC,WAAW;wCAAEC,WAAW;oCAAI;gCAAE;;0CAE7C,KAAClO;gCAAMmO,UAAS;0CACb,gEACC,6DACA;;0CAEJ,KAAChO;gCAAM0J,WAAU;gCAAMC,SAAS;gCAAGC,IAAI;oCAAEqE,gBAAgB;gCAAW;0CAClE,cAAA,KAAC7N;oCACCkH,SAAQ;oCACR4G,UAAUxK,QAAQ,CAACJ,SAASkC,IAAI;oCAChC8E,SAAS,IAAM,KAAK7D;8CAEnB;;;;;;;;;AAQjB;AACA9D,iBAAiBwL,WAAW,GAAG;AAE/B,eAAexL,iBAAgB"}
@@ -21,7 +21,28 @@
21
21
  * page of the answer. A question no query can answer is not offered. Each
22
22
  * list's spec holds `cloud/firebase-firestore.indexes.json` to
23
23
  * `listQueryIndexes` of its declaration.
24
- */ /*==========================================
24
+ */ /**
25
+ * A header's two orders, both `alone` (AGL-3680): served while nothing
26
+ * narrows the list, so on these subcollection lists they cost no composite.
27
+ * Asked under a filter or the search, the plan falls back to the list's
28
+ * default order and its notices say so.
29
+ */ const aloneSorts = (column, path, label)=>[
30
+ {
31
+ path,
32
+ direction: 'asc',
33
+ column,
34
+ label,
35
+ alone: true
36
+ },
37
+ {
38
+ path,
39
+ direction: 'desc',
40
+ column,
41
+ label,
42
+ alone: true
43
+ }
44
+ ];
45
+ /*==========================================
25
46
  * SUPPRESSIONS — `hosts/{hostId}/suppressions`, newest first.
26
47
  *
27
48
  * `emailTokens` is `emailSearchTokens(email)`, stamped by every writer (the
@@ -33,6 +54,10 @@
33
54
  *
34
55
  * `Since` is `createdAt`, the list's own order, so a date range on it
35
56
  * keeps that order and needs no index of its own.
57
+ *
58
+ * Every header sorts the query (AGL-3680). `email` is on every row — the
59
+ * address, or `null` for an erasure — and the same backfill stamps `null` on
60
+ * a row from before addresses were stored, so an Address order drops none.
36
61
  *=========================================*/ export const SUPPRESSION_LIST_QUERY = {
37
62
  fields: [
38
63
  {
@@ -64,8 +89,18 @@
64
89
  {
65
90
  path: 'createdAt',
66
91
  direction: 'desc',
67
- column: 'since'
68
- }
92
+ column: 'since',
93
+ label: 'Since'
94
+ },
95
+ {
96
+ path: 'createdAt',
97
+ direction: 'asc',
98
+ column: 'since',
99
+ label: 'Since',
100
+ alone: true
101
+ },
102
+ ...aloneSorts('email', 'email', 'Address'),
103
+ ...aloneSorts('reason', 'reason', 'Reason')
69
104
  ],
70
105
  search: {
71
106
  tokensPath: 'emailTokens'
@@ -84,7 +119,8 @@ export const SUPPRESSION_FILTER_HEADERS = {
84
119
  * `backfill-email-list-filters.mjs` stamps the lists written before them.
85
120
  * `kind` is written on every create; the same backfill stamps `manual` on a
86
121
  * list that predates the field, which is what an absent kind has always
87
- * meant.
122
+ * meant. The materializer writes `dynamic`, so Membership sorts the query
123
+ * (AGL-3680). Subscribers is a count read per row: it sorts the page.
88
124
  *=========================================*/ export const EMAIL_LIST_QUERY = {
89
125
  fields: [
90
126
  {
@@ -111,8 +147,17 @@ export const SUPPRESSION_FILTER_HEADERS = {
111
147
  {
112
148
  path: 'name',
113
149
  direction: 'asc',
114
- column: 'name'
115
- }
150
+ column: 'name',
151
+ label: 'List'
152
+ },
153
+ {
154
+ path: 'name',
155
+ direction: 'desc',
156
+ column: 'name',
157
+ label: 'List',
158
+ alone: true
159
+ },
160
+ ...aloneSorts('kind', 'kind', 'Membership')
116
161
  ],
117
162
  search: {
118
163
  tokensPath: 'nameTokens'
@@ -149,7 +194,14 @@ export const EMAIL_LIST_FILTER_OPTIONS = {
149
194
  * `manual` where it is absent, which is what absent has always meant.
150
195
  *
151
196
  * ⛔ Consent is NOT filterable. It is read per viewing consent group
152
- * (`readMarketingBasis`), so no stored value answers it for every reader.
197
+ * (`readMarketingBasis`), so no stored value answers it for every reader —
198
+ * its header sorts the page.
199
+ *
200
+ * Address, Name, Joined and How sort the query (AGL-3680), each `alone`.
201
+ * `enrollListMember` stamps `name` (null without one) and `addedAt` on every
202
+ * row it writes — a legacy row lacking `addedAt` gets its document's create
203
+ * time — and `backfill-list-member-sort-fields.mjs` stamps both on the rows
204
+ * written before, so neither order drops a member.
153
205
  *=========================================*/ export const LIST_MEMBER_QUERY = {
154
206
  fields: [
155
207
  {
@@ -175,7 +227,11 @@ export const EMAIL_LIST_FILTER_OPTIONS = {
175
227
  {
176
228
  path: '__name__',
177
229
  direction: 'asc'
178
- }
230
+ },
231
+ ...aloneSorts('email', 'email', 'Address'),
232
+ ...aloneSorts('name', 'name', 'Name'),
233
+ ...aloneSorts('addedAt', 'addedAt', 'Joined'),
234
+ ...aloneSorts('via', 'via', 'How')
179
235
  ],
180
236
  search: {
181
237
  tokensPath: 'searchTokens'
@@ -235,7 +291,15 @@ export const LIST_MEMBER_FILTER_OPTIONS = {
235
291
  {
236
292
  path: 'nameLower',
237
293
  direction: 'asc',
238
- column: 'displayName'
294
+ column: 'displayName',
295
+ label: 'Template'
296
+ },
297
+ {
298
+ path: 'nameLower',
299
+ direction: 'desc',
300
+ column: 'displayName',
301
+ label: 'Template',
302
+ alone: true
239
303
  }
240
304
  ],
241
305
  search: {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/plugins/email/src/lib/constants/list-queries.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 type { ListFilterOption } from '@aglyn/shared-ui-jsx/const/list-grid-filter'\nimport type { ListQueryDeclaration } from '@aglyn/shared-ui-jsx/const/list-query-plan'\n\n/*\n * WHAT EACH EMAILS LIST CAN BE ASKED, ON ITS FIRESTORE QUERY (AGL-3321).\n *\n * Every clause the Filters panel offers and every quick-search word is a\n * predicate on the list's query, planned by `planListQuery`, so each page is a\n * page of the answer. A question no query can answer is not offered. Each\n * list's spec holds `cloud/firebase-firestore.indexes.json` to\n * `listQueryIndexes` of its declaration.\n */\n\n/*==========================================\n * SUPPRESSIONS — `hosts/{hostId}/suppressions`, newest first.\n *\n * `emailTokens` is `emailSearchTokens(email)`, stamped by every writer (the\n * unsubscribe link, the bounce and complaint webhook, the Add drawer, the\n * consent-group carry) and by `backfill-host-suppression-filters.mjs` on\n * the rows written before it. `reason` is written by every writer, and the\n * same backfill stamps `unsubscribe` on the pre-AGL-2408 rows that carry\n * none, which is what an absent reason has always meant.\n *\n * `Since` is `createdAt`, the list's own order, so a date range on it\n * keeps that order and needs no index of its own.\n *=========================================*/\nexport const SUPPRESSION_LIST_QUERY: ListQueryDeclaration = {\n fields: [\n {\n column: 'email',\n kind: 'text',\n path: 'email',\n tokensPath: 'emailTokens',\n operators: ['contains'],\n },\n { column: 'reason', kind: 'exact', path: 'reason', operators: ['equals', 'isAnyOf'] },\n { column: 'since', kind: 'date', path: 'createdAt', presence: 'always' },\n ],\n sorts: [{ path: 'createdAt', direction: 'desc', column: 'since' }],\n search: { tokensPath: 'emailTokens' },\n}\n\nexport const SUPPRESSION_FILTER_HEADERS: Readonly<Record<string, string>> = {\n email: 'Address',\n reason: 'Reason',\n since: 'Since',\n}\n\n/*==========================================\n * EMAIL LISTS — `orgs/{orgId}/lists`, by name.\n *\n * `nameLower` and `nameTokens` travel with `name` (`nameSearchFields`) on\n * the two writers — the card's create and the edit page's rename — and\n * `backfill-email-list-filters.mjs` stamps the lists written before them.\n * `kind` is written on every create; the same backfill stamps `manual` on a\n * list that predates the field, which is what an absent kind has always\n * meant.\n *=========================================*/\nexport const EMAIL_LIST_QUERY: ListQueryDeclaration = {\n fields: [\n {\n column: 'name',\n kind: 'text',\n path: 'name',\n lowerPath: 'nameLower',\n tokensPath: 'nameTokens',\n operators: ['contains', 'equals'],\n },\n { column: 'kind', kind: 'exact', path: 'kind', operators: ['equals'] },\n ],\n sorts: [{ path: 'name', direction: 'asc', column: 'name' }],\n search: { tokensPath: 'nameTokens' },\n}\n\nexport const EMAIL_LIST_FILTER_HEADERS: Readonly<Record<string, string>> = {\n name: 'List',\n kind: 'Membership',\n}\n\nexport const EMAIL_LIST_FILTER_OPTIONS: Readonly<Record<string, readonly ListFilterOption[]>> = {\n kind: [\n { value: 'manual', label: 'Manual' },\n { value: 'dynamic', label: 'Rule' },\n ],\n}\n\n/*==========================================\n * A LIST'S MEMBERS — `orgs/{orgId}/lists/{listId}/members`, by document id.\n *\n * `__name__` is the order because it is the one key every row has (see the\n * panel), and under it equalities and one array clause merge on Firestore's\n * automatic single-field indexes: no composite at all.\n *\n * `searchTokens` is the name's word prefixes and the address's\n * (`listMemberSearchTokens`), stamped by `enrollListMember` — the\n * collection's only writer — and by `backfill-email-list-filters.mjs`.\n * `email` is normalized before every write, so `equals` asks for the\n * normalized address. `via` is written on every new row and stamped\n * `manual` where it is absent, which is what absent has always meant.\n *\n * ⛔ Consent is NOT filterable. It is read per viewing consent group\n * (`readMarketingBasis`), so no stored value answers it for every reader.\n *=========================================*/\nexport const LIST_MEMBER_QUERY: ListQueryDeclaration = {\n fields: [\n {\n column: 'email',\n kind: 'text',\n path: 'email',\n lowerPath: 'email',\n presence: 'always',\n operators: ['equals'],\n },\n { column: 'via', kind: 'exact', path: 'via', operators: ['equals'] },\n ],\n sorts: [{ path: '__name__', direction: 'asc' }],\n search: { tokensPath: 'searchTokens' },\n}\n\nexport const LIST_MEMBER_FILTER_HEADERS: Readonly<Record<string, string>> = {\n email: 'Address',\n via: 'How',\n}\n\nexport const LIST_MEMBER_FILTER_OPTIONS: Readonly<Record<string, readonly ListFilterOption[]>> = {\n via: [\n { value: 'rule', label: 'Rule' },\n { value: 'manual', label: 'Added' },\n ],\n}\n\n/*==========================================\n * EMAIL TEMPLATES — `hosts/{hostId}/screens` where `kind == 'email'`, by\n * name.\n *\n * The screen search keys — `nameLower` and `nameTokens`, both from\n * `displayName` (`displayNameSearchFields`) — are what every screen writer\n * stamps on a create and a rename, and what the site artifacts backfill\n * stamps on the screens written before them. The order is `nameLower`, so a\n * screen without it is not listed: a deleted template clears its keys with\n * the delete (`emailTemplateSoftDelete`), which is how the list leaves\n * tombstones out without a clause no query could hold (\"deletedAt is\n * absent\").\n *\n * ⛔ Origin (yours or installed) is NOT filterable: \"installed\" is the\n * presence of the install provenance and \"yours\" its absence, and a query\n * cannot ask for a field to be absent.\n *=========================================*/\nexport const EMAIL_TEMPLATE_QUERY: ListQueryDeclaration = {\n fields: [\n {\n column: 'displayName',\n kind: 'text',\n path: 'displayName',\n lowerPath: 'nameLower',\n tokensPath: 'nameTokens',\n // `startsWith` ranges over `nameLower`, the list's own order. No\n // `endsWith`: it would range over `nameReversed` and reorder the list\n // by it, an order's worth of indexes for one operator.\n operators: ['contains', 'equals', 'startsWith'],\n },\n ],\n sorts: [{ path: 'nameLower', direction: 'asc', column: 'displayName' }],\n search: { tokensPath: 'nameTokens' },\n}\n\n/** The template list's scope: email screens only. */\nexport const EMAIL_TEMPLATE_BASE = [{ path: 'kind', op: '==' as const, value: 'email' }]\n\nexport const EMAIL_TEMPLATE_FILTER_HEADERS: Readonly<Record<string, string>> = {\n displayName: 'Template',\n}\n"],"names":["SUPPRESSION_LIST_QUERY","fields","column","kind","path","tokensPath","operators","presence","sorts","direction","search","SUPPRESSION_FILTER_HEADERS","email","reason","since","EMAIL_LIST_QUERY","lowerPath","EMAIL_LIST_FILTER_HEADERS","name","EMAIL_LIST_FILTER_OPTIONS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* @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 type { ListFilterOption } from '@aglyn/shared-ui-jsx/const/list-grid-filter'\nimport type {\n ListQueryDeclaration,\n ListQuerySort,\n} from '@aglyn/shared-ui-jsx/const/list-query-plan'\n\n/*\n * WHAT EACH EMAILS LIST CAN BE ASKED, ON ITS FIRESTORE QUERY (AGL-3321).\n *\n * Every clause the Filters panel offers and every quick-search word is a\n * predicate on the list's query, planned by `planListQuery`, so each page is a\n * page of the answer. A question no query can answer is not offered. Each\n * list's spec holds `cloud/firebase-firestore.indexes.json` to\n * `listQueryIndexes` of its declaration.\n */\n\n/**\n * A header's two orders, both `alone` (AGL-3680): served while nothing\n * narrows the list, so on these subcollection lists they cost no composite.\n * Asked under a filter or the search, the plan falls back to the list's\n * default order and its notices say so.\n */\nconst aloneSorts = (column: string, path: string, label: string): ListQuerySort[] => [\n { path, direction: 'asc', column, label, alone: true },\n { path, direction: 'desc', column, label, alone: true },\n]\n\n/*==========================================\n * SUPPRESSIONS — `hosts/{hostId}/suppressions`, newest first.\n *\n * `emailTokens` is `emailSearchTokens(email)`, stamped by every writer (the\n * unsubscribe link, the bounce and complaint webhook, the Add drawer, the\n * consent-group carry) and by `backfill-host-suppression-filters.mjs` on\n * the rows written before it. `reason` is written by every writer, and the\n * same backfill stamps `unsubscribe` on the pre-AGL-2408 rows that carry\n * none, which is what an absent reason has always meant.\n *\n * `Since` is `createdAt`, the list's own order, so a date range on it\n * keeps that order and needs no index of its own.\n *\n * Every header sorts the query (AGL-3680). `email` is on every row — the\n * address, or `null` for an erasure — and the same backfill stamps `null` on\n * a row from before addresses were stored, so an Address order drops none.\n *=========================================*/\nexport const SUPPRESSION_LIST_QUERY: ListQueryDeclaration = {\n fields: [\n {\n column: 'email',\n kind: 'text',\n path: 'email',\n tokensPath: 'emailTokens',\n operators: ['contains'],\n },\n { column: 'reason', kind: 'exact', path: 'reason', operators: ['equals', 'isAnyOf'] },\n { column: 'since', kind: 'date', path: 'createdAt', presence: 'always' },\n ],\n sorts: [\n { path: 'createdAt', direction: 'desc', column: 'since', label: 'Since' },\n { path: 'createdAt', direction: 'asc', column: 'since', label: 'Since', alone: true },\n ...aloneSorts('email', 'email', 'Address'),\n ...aloneSorts('reason', 'reason', 'Reason'),\n ],\n search: { tokensPath: 'emailTokens' },\n}\n\nexport const SUPPRESSION_FILTER_HEADERS: Readonly<Record<string, string>> = {\n email: 'Address',\n reason: 'Reason',\n since: 'Since',\n}\n\n/*==========================================\n * EMAIL LISTS — `orgs/{orgId}/lists`, by name.\n *\n * `nameLower` and `nameTokens` travel with `name` (`nameSearchFields`) on\n * the two writers — the card's create and the edit page's rename — and\n * `backfill-email-list-filters.mjs` stamps the lists written before them.\n * `kind` is written on every create; the same backfill stamps `manual` on a\n * list that predates the field, which is what an absent kind has always\n * meant. The materializer writes `dynamic`, so Membership sorts the query\n * (AGL-3680). Subscribers is a count read per row: it sorts the page.\n *=========================================*/\nexport const EMAIL_LIST_QUERY: ListQueryDeclaration = {\n fields: [\n {\n column: 'name',\n kind: 'text',\n path: 'name',\n lowerPath: 'nameLower',\n tokensPath: 'nameTokens',\n operators: ['contains', 'equals'],\n },\n { column: 'kind', kind: 'exact', path: 'kind', operators: ['equals'] },\n ],\n sorts: [\n { path: 'name', direction: 'asc', column: 'name', label: 'List' },\n { path: 'name', direction: 'desc', column: 'name', label: 'List', alone: true },\n ...aloneSorts('kind', 'kind', 'Membership'),\n ],\n search: { tokensPath: 'nameTokens' },\n}\n\nexport const EMAIL_LIST_FILTER_HEADERS: Readonly<Record<string, string>> = {\n name: 'List',\n kind: 'Membership',\n}\n\nexport const EMAIL_LIST_FILTER_OPTIONS: Readonly<Record<string, readonly ListFilterOption[]>> = {\n kind: [\n { value: 'manual', label: 'Manual' },\n { value: 'dynamic', label: 'Rule' },\n ],\n}\n\n/*==========================================\n * A LIST'S MEMBERS — `orgs/{orgId}/lists/{listId}/members`, by document id.\n *\n * `__name__` is the order because it is the one key every row has (see the\n * panel), and under it equalities and one array clause merge on Firestore's\n * automatic single-field indexes: no composite at all.\n *\n * `searchTokens` is the name's word prefixes and the address's\n * (`listMemberSearchTokens`), stamped by `enrollListMember` — the\n * collection's only writer — and by `backfill-email-list-filters.mjs`.\n * `email` is normalized before every write, so `equals` asks for the\n * normalized address. `via` is written on every new row and stamped\n * `manual` where it is absent, which is what absent has always meant.\n *\n * ⛔ Consent is NOT filterable. It is read per viewing consent group\n * (`readMarketingBasis`), so no stored value answers it for every reader —\n * its header sorts the page.\n *\n * Address, Name, Joined and How sort the query (AGL-3680), each `alone`.\n * `enrollListMember` stamps `name` (null without one) and `addedAt` on every\n * row it writes — a legacy row lacking `addedAt` gets its document's create\n * time — and `backfill-list-member-sort-fields.mjs` stamps both on the rows\n * written before, so neither order drops a member.\n *=========================================*/\nexport const LIST_MEMBER_QUERY: ListQueryDeclaration = {\n fields: [\n {\n column: 'email',\n kind: 'text',\n path: 'email',\n lowerPath: 'email',\n presence: 'always',\n operators: ['equals'],\n },\n { column: 'via', kind: 'exact', path: 'via', operators: ['equals'] },\n ],\n sorts: [\n { path: '__name__', direction: 'asc' },\n ...aloneSorts('email', 'email', 'Address'),\n ...aloneSorts('name', 'name', 'Name'),\n ...aloneSorts('addedAt', 'addedAt', 'Joined'),\n ...aloneSorts('via', 'via', 'How'),\n ],\n search: { tokensPath: 'searchTokens' },\n}\n\nexport const LIST_MEMBER_FILTER_HEADERS: Readonly<Record<string, string>> = {\n email: 'Address',\n via: 'How',\n}\n\nexport const LIST_MEMBER_FILTER_OPTIONS: Readonly<Record<string, readonly ListFilterOption[]>> = {\n via: [\n { value: 'rule', label: 'Rule' },\n { value: 'manual', label: 'Added' },\n ],\n}\n\n/*==========================================\n * EMAIL TEMPLATES — `hosts/{hostId}/screens` where `kind == 'email'`, by\n * name.\n *\n * The screen search keys — `nameLower` and `nameTokens`, both from\n * `displayName` (`displayNameSearchFields`) — are what every screen writer\n * stamps on a create and a rename, and what the site artifacts backfill\n * stamps on the screens written before them. The order is `nameLower`, so a\n * screen without it is not listed: a deleted template clears its keys with\n * the delete (`emailTemplateSoftDelete`), which is how the list leaves\n * tombstones out without a clause no query could hold (\"deletedAt is\n * absent\").\n *\n * ⛔ Origin (yours or installed) is NOT filterable: \"installed\" is the\n * presence of the install provenance and \"yours\" its absence, and a query\n * cannot ask for a field to be absent.\n *=========================================*/\nexport const EMAIL_TEMPLATE_QUERY: ListQueryDeclaration = {\n fields: [\n {\n column: 'displayName',\n kind: 'text',\n path: 'displayName',\n lowerPath: 'nameLower',\n tokensPath: 'nameTokens',\n // `startsWith` ranges over `nameLower`, the list's own order. No\n // `endsWith`: it would range over `nameReversed` and reorder the list\n // by it, an order's worth of indexes for one operator.\n operators: ['contains', 'equals', 'startsWith'],\n },\n ],\n sorts: [\n { path: 'nameLower', direction: 'asc', column: 'displayName', label: 'Template' },\n {\n path: 'nameLower',\n direction: 'desc',\n column: 'displayName',\n label: 'Template',\n alone: true,\n },\n ],\n search: { tokensPath: 'nameTokens' },\n}\n\n/** The template list's scope: email screens only. */\nexport const EMAIL_TEMPLATE_BASE = [{ path: 'kind', op: '==' as const, value: 'email' }]\n\nexport const EMAIL_TEMPLATE_FILTER_HEADERS: Readonly<Record<string, string>> = {\n displayName: 'Template',\n}\n"],"names":["aloneSorts","column","path","label","direction","alone","SUPPRESSION_LIST_QUERY","fields","kind","tokensPath","operators","presence","sorts","search","SUPPRESSION_FILTER_HEADERS","email","reason","since","EMAIL_LIST_QUERY","lowerPath","EMAIL_LIST_FILTER_HEADERS","name","EMAIL_LIST_FILTER_OPTIONS","value","LIST_MEMB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MyB,uBAA6C;IACxDrB,QAAQ;QACN;YACEN,QAAQ;YACRO,MAAM;YACNN,MAAM;YACNiB,WAAW;YACXV,YAAY;YACZ,iEAAiE;YACjE,sEAAsE;YACtE,uDAAuD;YACvDC,WAAW;gBAAC;gBAAY;gBAAU;aAAa;QACjD;KACD;IACDE,OAAO;QACL;YAAEV,MAAM;YAAaE,WAAW;YAAOH,QAAQ;YAAeE,OAAO;QAAW;QAChF;YACED,MAAM;YACNE,WAAW;YACXH,QAAQ;YACRE,OAAO;YACPE,OAAO;QACT;KACD;IACDQ,QAAQ;QAAEJ,YAAY;IAAa;AACrC,EAAC;AAED,mDAAmD,GACnD,OAAO,MAAMoB,sBAAsB;IAAC;QAAE3B,MAAM;QAAQ4B,IAAI;QAAeP,OAAO;IAAQ;CAAE,CAAA;AAExF,OAAO,MAAMQ,gCAAkE;IAC7EC,aAAa;AACf,EAAC"}
@@ -14,7 +14,7 @@
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */
17
- import { SCREEN_KIND_EMAIL } from '@aglyn/aglyn/app-utils/screen-route';
17
+ import { SCREEN_KIND_EMAIL } from '@aglyn/aglyn/app-utils/screen-kind';
18
18
  /**
19
19
  * THE TWO DOCUMENTS AN EMAIL DESIGN IS: a screen with `kind: 'email'`, and its
20
20
  * first version holding the node map.
@@ -13,7 +13,7 @@
13
13
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
- */ import { SCREEN_KIND_EMAIL } from "@aglyn/aglyn/app-utils/screen-route";
16
+ */ import { SCREEN_KIND_EMAIL } from "@aglyn/aglyn/app-utils/screen-kind";
17
17
  import { CANVAS_ROOT_ELEMENT_ID } from "@aglyn/aglyn/foundation/constants/canvas";
18
18
  /** A new design's first canvas: one email section holding a greeting. */ export function emailDesignStarterNodes(ids) {
19
19
  return {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/plugins/email/src/lib/model/email-design-document.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 { SCREEN_KIND_EMAIL } from '@aglyn/aglyn/app-utils/screen-route'\nimport { CANVAS_ROOT_ELEMENT_ID } from '@aglyn/aglyn/foundation/constants/canvas'\n\n/**\n * THE TWO DOCUMENTS AN EMAIL DESIGN IS: a screen with `kind: 'email'`, and its\n * first version holding the node map.\n *\n * Leaf modules only, so the console's create (a client component) and the\n * server's draft writer build the same pair from one function: a design made\n * on either side opens in the same besigner, lists on the same Templates tab,\n * and is picked up by the same campaign composer.\n */\n\n/** The screen document of a new email design. */\nexport interface EmailDesignScreenDocument {\n displayName: string\n kind: typeof SCREEN_KIND_EMAIL\n versionId: string\n}\n\n/** The first version of a new email design. */\nexport interface EmailDesignVersionDocument {\n screenId: string\n nodes: Record<string, unknown>\n}\n\n/** A new design's first canvas: one email section holding a greeting. */\nexport function emailDesignStarterNodes(ids: {\n sectionId: string\n textId: string\n}): Record<string, unknown> {\n return {\n [CANVAS_ROOT_ELEMENT_ID]: {\n $id: CANVAS_ROOT_ELEMENT_ID,\n componentId: 'div',\n nodes: [ids.sectionId],\n },\n [ids.sectionId]: {\n $id: ids.sectionId,\n componentId: 'emailSection',\n pluginId: 'email',\n parentId: CANVAS_ROOT_ELEMENT_ID,\n nodes: [ids.textId],\n },\n [ids.textId]: {\n $id: ids.textId,\n componentId: 'emailText',\n pluginId: 'email',\n parentId: ids.sectionId,\n props: {\n children: 'Hello {{contact.firstName}},',\n variant: 'body',\n },\n },\n }\n}\n\n/** The screen and first version a design with these ids and this canvas is stored as. */\nexport function emailDesignDocuments(input: {\n screenId: string\n versionId: string\n displayName: string\n nodes: Record<string, unknown>\n}): { screen: EmailDesignScreenDocument; version: EmailDesignVersionDocument } {\n return {\n screen: {\n displayName: input.displayName,\n kind: SCREEN_KIND_EMAIL,\n versionId: input.versionId,\n },\n version: { screenId: input.screenId, nodes: input.nodes },\n }\n}\n"],"names":["SCREEN_KIND_EMAIL","CANVAS_ROOT_ELEMENT_ID","emailDesignStarterNodes","ids","$id","componentId","nodes","sectionId","pluginId","parentId","textId","props","children","variant","emailDesignDocuments","input","screen","displayName","kind","versionId","version","screenId"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,iBAAiB,QAAQ,sCAAqC;AACvE,SAASC,sBAAsB,QAAQ,2CAA0C;AAyBjF,uEAAuE,GACvE,OAAO,SAASC,wBAAwBC,GAGvC;IACC,OAAO;QACL,CAACF,uBAAuB,EAAE;YACxBG,KAAKH;YACLI,aAAa;YACbC,OAAO;gBAACH,IAAII,SAAS;aAAC;QACxB;QACA,CAACJ,IAAII,SAAS,CAAC,EAAE;YACfH,KAAKD,IAAII,SAAS;YAClBF,aAAa;YACbG,UAAU;YACVC,UAAUR;YACVK,OAAO;gBAACH,IAAIO,MAAM;aAAC;QACrB;QACA,CAACP,IAAIO,MAAM,CAAC,EAAE;YACZN,KAAKD,IAAIO,MAAM;YACfL,aAAa;YACbG,UAAU;YACVC,UAAUN,IAAII,SAAS;YACvBI,OAAO;gBACLC,UAAU;gBACVC,SAAS;YACX;QACF;IACF;AACF;AAEA,uFAAuF,GACvF,OAAO,SAASC,qBAAqBC,KAKpC;IACC,OAAO;QACLC,QAAQ;YACNC,aAAaF,MAAME,WAAW;YAC9BC,MAAMlB;YACNmB,WAAWJ,MAAMI,SAAS;QAC5B;QACAC,SAAS;YAAEC,UAAUN,MAAMM,QAAQ;YAAEf,OAAOS,MAAMT,KAAK;QAAC;IAC1D;AACF"}
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/email/src/lib/model/email-design-document.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 { SCREEN_KIND_EMAIL } from '@aglyn/aglyn/app-utils/screen-kind'\nimport { CANVAS_ROOT_ELEMENT_ID } from '@aglyn/aglyn/foundation/constants/canvas'\n\n/**\n * THE TWO DOCUMENTS AN EMAIL DESIGN IS: a screen with `kind: 'email'`, and its\n * first version holding the node map.\n *\n * Leaf modules only, so the console's create (a client component) and the\n * server's draft writer build the same pair from one function: a design made\n * on either side opens in the same besigner, lists on the same Templates tab,\n * and is picked up by the same campaign composer.\n */\n\n/** The screen document of a new email design. */\nexport interface EmailDesignScreenDocument {\n displayName: string\n kind: typeof SCREEN_KIND_EMAIL\n versionId: string\n}\n\n/** The first version of a new email design. */\nexport interface EmailDesignVersionDocument {\n screenId: string\n nodes: Record<string, unknown>\n}\n\n/** A new design's first canvas: one email section holding a greeting. */\nexport function emailDesignStarterNodes(ids: {\n sectionId: string\n textId: string\n}): Record<string, unknown> {\n return {\n [CANVAS_ROOT_ELEMENT_ID]: {\n $id: CANVAS_ROOT_ELEMENT_ID,\n componentId: 'div',\n nodes: [ids.sectionId],\n },\n [ids.sectionId]: {\n $id: ids.sectionId,\n componentId: 'emailSection',\n pluginId: 'email',\n parentId: CANVAS_ROOT_ELEMENT_ID,\n nodes: [ids.textId],\n },\n [ids.textId]: {\n $id: ids.textId,\n componentId: 'emailText',\n pluginId: 'email',\n parentId: ids.sectionId,\n props: {\n children: 'Hello {{contact.firstName}},',\n variant: 'body',\n },\n },\n }\n}\n\n/** The screen and first version a design with these ids and this canvas is stored as. */\nexport function emailDesignDocuments(input: {\n screenId: string\n versionId: string\n displayName: string\n nodes: Record<string, unknown>\n}): { screen: EmailDesignScreenDocument; version: EmailDesignVersionDocument } {\n return {\n screen: {\n displayName: input.displayName,\n kind: SCREEN_KIND_EMAIL,\n versionId: input.versionId,\n },\n version: { screenId: input.screenId, nodes: input.nodes },\n }\n}\n"],"names":["SCREEN_KIND_EMAIL","CANVAS_ROOT_ELEMENT_ID","emailDesignStarterNodes","ids","$id","componentId","nodes","sectionId","pluginId","parentId","textId","props","children","variant","emailDesignDocuments","input","screen","displayName","kind","versionId","version","screenId"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,iBAAiB,QAAQ,qCAAoC;AACtE,SAASC,sBAAsB,QAAQ,2CAA0C;AAyBjF,uEAAuE,GACvE,OAAO,SAASC,wBAAwBC,GAGvC;IACC,OAAO;QACL,CAACF,uBAAuB,EAAE;YACxBG,KAAKH;YACLI,aAAa;YACbC,OAAO;gBAACH,IAAII,SAAS;aAAC;QACxB;QACA,CAACJ,IAAII,SAAS,CAAC,EAAE;YACfH,KAAKD,IAAII,SAAS;YAClBF,aAAa;YACbG,UAAU;YACVC,UAAUR;YACVK,OAAO;gBAACH,IAAIO,MAAM;aAAC;QACrB;QACA,CAACP,IAAIO,MAAM,CAAC,EAAE;YACZN,KAAKD,IAAIO,MAAM;YACfL,aAAa;YACbG,UAAU;YACVC,UAAUN,IAAII,SAAS;YACvBI,OAAO;gBACLC,UAAU;gBACVC,SAAS;YACX;QACF;IACF;AACF;AAEA,uFAAuF,GACvF,OAAO,SAASC,qBAAqBC,KAKpC;IACC,OAAO;QACLC,QAAQ;YACNC,aAAaF,MAAME,WAAW;YAC9BC,MAAMlB;YACNmB,WAAWJ,MAAMI,SAAS;QAC5B;QACAC,SAAS;YAAEC,UAAUN,MAAMM,QAAQ;YAAEf,OAAOS,MAAMT,KAAK;QAAC;IAC1D;AACF"}