@aglyn/plugins-email 1.0.0-beta.199 → 1.0.0-beta.201

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 (29) hide show
  1. package/package.json +17 -17
  2. package/src/lib/components/email-screens-card.d.ts +8 -9
  3. package/src/lib/components/email-screens-card.js +83 -100
  4. package/src/lib/components/email-screens-card.js.map +1 -1
  5. package/src/lib/components/email-template-detail.js +3 -2
  6. package/src/lib/components/email-template-detail.js.map +1 -1
  7. package/src/lib/components/list-edit-card.js +2 -2
  8. package/src/lib/components/list-edit-card.js.map +1 -1
  9. package/src/lib/components/list-members-panel.js +72 -93
  10. package/src/lib/components/list-members-panel.js.map +1 -1
  11. package/src/lib/components/lists-card.js +70 -77
  12. package/src/lib/components/lists-card.js.map +1 -1
  13. package/src/lib/components/org-email-templates-card.d.ts +10 -6
  14. package/src/lib/components/org-email-templates-card.js +145 -90
  15. package/src/lib/components/org-email-templates-card.js.map +1 -1
  16. package/src/lib/components/suppressions-card.js +73 -69
  17. package/src/lib/components/suppressions-card.js.map +1 -1
  18. package/src/lib/constants/list-queries.d.ts +34 -0
  19. package/src/lib/constants/list-queries.js +256 -0
  20. package/src/lib/constants/list-queries.js.map +1 -0
  21. package/src/lib/server-email-drafts.js +6 -4
  22. package/src/lib/server-email-drafts.js.map +1 -1
  23. package/src/lib/server-suppressions.js +3 -1
  24. package/src/lib/server-suppressions.js.map +1 -1
  25. package/src/lib/server.js +3 -1
  26. package/src/lib/server.js.map +1 -1
  27. package/src/lib/utils/email-template-soft-delete.d.ts +39 -0
  28. package/src/lib/utils/email-template-soft-delete.js +41 -0
  29. package/src/lib/utils/email-template-soft-delete.js.map +1 -0
@@ -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 { pluginDocsHelp } from '@aglyn/aglyn'\nimport { ICON_VARIANT_CLOSE } from '@aglyn/shared-data-enums'\nimport { mdiEmailCheckOutline } 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 {\n ListRowActions,\n ListTable,\n listActionsColumn,\n} from '@aglyn/shared-ui-jsx/components/list-table.component'\nimport { inMemoryListField } from '@aglyn/shared-ui-jsx/const/list-grid-filter'\nimport { TABLE_ROW_HEIGHT } from '@aglyn/shared-ui-jsx/const/table-pagination'\nimport { usePagedRowsFilter } from '@aglyn/shared-ui-jsx/hooks/use-paged-rows-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 {\n collection,\n deleteDoc,\n doc,\n limit,\n orderBy,\n query,\n} from 'firebase/firestore'\nimport { useCallback, useEffect, useMemo, useState } from 'react'\nimport {\n useFirestore,\n usePagedCollection,\n useUser,\n} from '@aglyn/tenant-feature-instance'\nimport { authorizedFetch } from '@aglyn/shared-util-http/authorized-token'\nimport {\n describeSuppressionReason as describeReason,\n readSuppressionTotals,\n SUPPRESSION_REASONS,\n type SuppressionTotals,\n} from './suppression-totals'\nimport { orgSiteName, useEmailOrgMount } from './email-org-mount'\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 (AGL-3317). The list is a\n * paged listener, so a filter matches over what its window has read, which\n * the first filter widens (`usePagedRowsFilter`). Reason reads `reasonKey`,\n * the stored reason with an absent one read as an unsubscribe, which is how\n * the column and the breakdown describe it.\n */\nconst SUPPRESSION_FILTER_FIELDS = [\n inMemoryListField('email', 'text'),\n inMemoryListField('reason', 'select', 'reasonKey'),\n]\nconst SUPPRESSION_FILTER_HEADERS: Readonly<Record<string, string>> = {\n email: 'Address',\n reason: 'Reason',\n}\nconst SUPPRESSION_FILTER_OPTIONS = {\n reason: Object.entries(SUPPRESSION_REASONS).map(([value, described]) => ({\n value,\n label: described.label,\n })),\n}\nconst SUPPRESSION_SEARCH_FIELDS = ['email'] as const\n\ntype FilterableSuppressionRow = SuppressionRow & { reasonKey: string }\n\nconst withReasonKey = (row: SuppressionRow): FilterableSuppressionRow => ({\n ...row,\n reasonKey: String(row.reason ?? 'unsubscribe'),\n})\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 window IS the query, ordered by the server (AGL-2501, AGL-2292).\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 {\n data: entryData,\n rows: entryRows,\n hasMore,\n page,\n setPage,\n pageSize,\n setPageSize,\n } = usePagedCollection<SuppressionRow>(\n (pageLimit) =>\n query(\n collection(firestore, 'hosts', hostId, 'suppressions'),\n orderBy('createdAt', 'desc'),\n limit(pageLimit),\n ),\n [firestore, hostId],\n { idField: '$id' },\n )\n const entryWindow = useMemo(() => entryData?.map(withReasonKey), [entryData])\n const entryPage = useMemo(() => entryRows.map(withReasonKey), [entryRows])\n const entryFilter = usePagedRowsFilter<FilterableSuppressionRow>(\n {\n data: entryWindow,\n rows: entryPage,\n hasMore,\n page,\n setPage,\n pageSize,\n setPageSize,\n },\n {\n fields: SUPPRESSION_FILTER_FIELDS,\n options: SUPPRESSION_FILTER_OPTIONS,\n headers: SUPPRESSION_FILTER_HEADERS,\n search: SUPPRESSION_SEARCH_FIELDS,\n },\n )\n // The rows on screen: the page, or the page of the matches.\n const entries = entryFilter.rows\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<FilterableSuppressionRow>[] = [\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 valueGetter: (_value, row) => row.reasonKey,\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 <Button\n size=\"small\"\n variant=\"contained\"\n onClick={() => setAdding(true)}\n >\n {'Add'}\n </Button>\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 {entryRows.length === 0 && !hasMore && !entryFilter.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 {...entryFilter.chipsProps} />\n {entryFilter.filtering && hasMore ? (\n <Typography variant=\"caption\" color=\"text.secondary\">\n {`Filtering the ${entryFilter.read} suppressions read so far — the next page reads more.`}\n </Typography>\n ) : null}\n <ListTable\n aria-label=\"Suppressed addresses\"\n rows={entries}\n columns={entryFilter.filterColumns(columns as GridColDef[])}\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 are the grid's; the card answers\n // them over what its window read.\n {...entryFilter.gridProps}\n noRowsLabel=\"No suppressions match these filters\"\n />\n <ListPagination\n {...entryFilter.pagination}\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 && !entryFilter.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":["pluginDocsHelp","ICON_VARIANT_CLOSE","mdiEmailCheckOutline","CardDisplay","Container","MdiIcon","SrOnly","useConfirmationContext","ListFilterChips","ListPagination","ListRowActions","ListTable","listActionsColumn","inMemoryListField","TABLE_ROW_HEIGHT","usePagedRowsFilter","NavigationDrawerComponent","useSnackbar","Alert","Chip","IconButton","Stack","TextField","Tooltip","Typography","Button","collection","deleteDoc","doc","limit","orderBy","query","useCallback","useEffect","useMemo","useState","useFirestore","usePagedCollection","useUser","authorizedFetch","describeSuppressionReason","describeReason","readSuppressionTotals","SUPPRESSION_REASONS","orgSiteName","useEmailOrgMount","SUPPRESSION_FILTER_FIELDS","SUPPRESSION_FILTER_HEADERS","email","reason","SUPPRESSION_FILTER_OPTIONS","Object","entries","map","value","described","label","SUPPRESSION_SEARCH_FIELDS","withReasonKey","row","reasonKey","String","onDate","seconds","createdAt","suppressedAt","Date","toISOString","slice","SuppressionsCard","props","hostId","firestore","data","user","enqueueSnackbar","confirm","orgMount","adding","setAdding","addInput","setAddInput","addNote","setAddNote","busy","setBusy","entryData","rows","entryRows","hasMore","page","setPage","pageSize","setPageSize","pageLimit","idField","entryWindow","entryPage","entryFilter","fields","options","headers","search","totalsEpoch","setTotalsEpoch","totals","setTotals","active","then","read","catch","handleAdd","typed","trim","response","method","body","JSON","stringify","emails","note","payload","json","ok","error","variant","results","added","Number","rejected","filter","result","refusal","length","input","join","persist","epoch","console","isBlockedPlatformWide","platform","handleRemove","toLowerCase","alsoPlatform","accepted","title","description","confirmationText","confirmationButtonProps","color","$id","columns","field","headerName","flex","minWidth","renderCell","width","valueGetter","_value","direction","spacing","sx","alignItems","height","size","carriedFromHostId","items","key","icon","path","destructive","onClick","header","help","anchor","contentGutterX","contentGutterY","contentBordered","HeaderProps","action","filtering","flexWrap","total","chipsProps","aria-label","filterColumns","rowHeight","hideFooter","gridProps","noRowsLabel","pagination","count","values","reduce","a","b","undefined","open","onClose","AppBarProps","appBarLeft","edge","mr","component","appBarRight","gutterY","onChange","event","target","multiline","minRows","fullWidth","autoFocus","helperText","slotProps","htmlInput","maxLength","severity","justifyContent","disabled","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAEA,SAASA,cAAc,QAAQ,eAAc;AAC7C,SAASC,kBAAkB,QAAQ,2BAA0B;AAC7D,SAASC,oBAAoB,QAAQ,yBAAwB;AAC7D,SACEC,WAAW,EACXC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,sBAAsB,QACjB,uBAAsB;AAC7B,OAAOC,qBAAqB,8DAA6D;AACzF,SAASC,cAAc,QAAQ,4DAA2D;AAC1F,SACEC,cAAc,EACdC,SAAS,EACTC,iBAAiB,QACZ,uDAAsD;AAC7D,SAASC,iBAAiB,QAAQ,8CAA6C;AAC/E,SAASC,gBAAgB,QAAQ,8CAA6C;AAC9E,SAASC,kBAAkB,QAAQ,mDAAkD;AACrF;;;;;;;;;;CAUC,GACD,SAASC,yBAAyB,QAAQ,8DAA6D;AACvG,SAASC,WAAW,QAAQ,8BAA6B;AACzD,SACEC,KAAK,EACLC,IAAI,EACJC,UAAU,EACVC,KAAK,EACLC,SAAS,EACTC,OAAO,EACPC,UAAU,QACL,gBAAe;AACtB,OAAOC,YAAY,uBAAsB;AAEzC,SACEC,UAAU,EACVC,SAAS,EACTC,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AAgB;gCAAW;0CAClE,cAAA,KAAClM;oCACCoG,SAAQ;oCACR+F,UAAUxI,QAAQ,CAACJ,SAASiC,IAAI;oCAChC2D,SAAS,IAAM,KAAK7D;8CAEnB;;;;;;;;;AAQjB;AACA1C,iBAAiBwJ,WAAW,GAAG;AAE/B,eAAexJ,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 { pluginDocsHelp } from '@aglyn/aglyn'\nimport { ICON_VARIANT_CLOSE } from '@aglyn/shared-data-enums'\nimport { mdiEmailCheckOutline } 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'\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 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 <Button\n size=\"small\"\n variant=\"contained\"\n onClick={() => setAdding(true)}\n >\n {'Add'}\n </Button>\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":["pluginDocsHelp","ICON_VARIANT_CLOSE","mdiEmailCheckOutline","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","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","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","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","target","multiline","minRows","fullWidth","autoFocus","helperText","slotProps","htmlInput","maxLength","severity","justifyContent","disabled","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;AAEA,SAASA,cAAc,QAAQ,eAAc;AAC7C,SAASC,kBAAkB,QAAQ,2BAA0B;AAC7D,SAASC,oBAAoB,QAAQ,yBAAwB;AAC7D,SACEC,WAAW,EACXC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,sBAAsB,QACjB,uBAAsB;AAC7B,OAAOC,qBAAqB,8DAA6D;AACzF,SAASC,cAAc,QAAQ,4DAA2D;AAC1F,OAAOC,oB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,OAAM;0CAC/B,8DACC,gEACA,iEACA;;0CAEJ,KAAChI;gCACC8B,OAAM;gCACNF,OAAOuB;gCACPgH,UAAU,CAAC8B,QAAU7I,YAAY6I,MAAMC,MAAM,CAACtK,KAAK;gCACnDuK,SAAS;gCACTC,SAAS;gCACTC,SAAS;gCACTC,SAAS;gCACTC,YACE;;0CAGJ,KAACvM;gCACC8B,OAAM;gCACNF,OAAOyB;gCACP8G,UAAU,CAAC8B,QAAU3I,WAAW2I,MAAMC,MAAM,CAACtK,KAAK;gCAClDyK,SAAS;gCACTE,YACE,6DACA;gCAEFC,WAAW;oCAAEC,WAAW;wCAAEC,WAAW;oCAAI;gCAAE;;0CAE7C,KAAC9M;gCAAM+M,UAAS;0CACb,gEACC,6DACA;;0CAEJ,KAAC5M;gCAAM6I,WAAU;gCAAMC,SAAS;gCAAGC,IAAI;oCAAE8D,gBAAgB;gCAAW;0CAClE,cAAA,KAACzM;oCACCqG,SAAQ;oCACRqG,UAAUtJ,QAAQ,CAACJ,SAAS0B,IAAI;oCAChC2E,SAAS,IAAM,KAAK7D;8CAEnB;;;;;;;;;AAQjB;AACAnD,iBAAiBsK,WAAW,GAAG;AAE/B,eAAetK,iBAAgB"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import type { ListFilterOption } from '@aglyn/shared-ui-jsx/const/list-grid-filter';
18
+ import type { ListQueryDeclaration } from '@aglyn/shared-ui-jsx/const/list-query-plan';
19
+ export declare const SUPPRESSION_LIST_QUERY: ListQueryDeclaration;
20
+ export declare const SUPPRESSION_FILTER_HEADERS: Readonly<Record<string, string>>;
21
+ export declare const EMAIL_LIST_QUERY: ListQueryDeclaration;
22
+ export declare const EMAIL_LIST_FILTER_HEADERS: Readonly<Record<string, string>>;
23
+ export declare const EMAIL_LIST_FILTER_OPTIONS: Readonly<Record<string, readonly ListFilterOption[]>>;
24
+ export declare const LIST_MEMBER_QUERY: ListQueryDeclaration;
25
+ export declare const LIST_MEMBER_FILTER_HEADERS: Readonly<Record<string, string>>;
26
+ export declare const LIST_MEMBER_FILTER_OPTIONS: Readonly<Record<string, readonly ListFilterOption[]>>;
27
+ export declare const EMAIL_TEMPLATE_QUERY: ListQueryDeclaration;
28
+ /** The template list's scope: email screens only. */
29
+ export declare const EMAIL_TEMPLATE_BASE: {
30
+ path: string;
31
+ op: "==";
32
+ value: string;
33
+ }[];
34
+ export declare const EMAIL_TEMPLATE_FILTER_HEADERS: Readonly<Record<string, string>>;
@@ -0,0 +1,256 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */ /*
17
+ * WHAT EACH EMAILS LIST CAN BE ASKED, ON ITS FIRESTORE QUERY (AGL-3321).
18
+ *
19
+ * Every clause the Filters panel offers and every quick-search word is a
20
+ * predicate on the list's query, planned by `planListQuery`, so each page is a
21
+ * page of the answer. A question no query can answer is not offered. Each
22
+ * list's spec holds `cloud/firebase-firestore.indexes.json` to
23
+ * `listQueryIndexes` of its declaration.
24
+ */ /*==========================================
25
+ * SUPPRESSIONS — `hosts/{hostId}/suppressions`, newest first.
26
+ *
27
+ * `emailTokens` is `emailSearchTokens(email)`, stamped by every writer (the
28
+ * unsubscribe link, the bounce and complaint webhook, the Add drawer, the
29
+ * consent-group carry) and by `backfill-host-suppression-filters.mjs` on
30
+ * the rows written before it. `reason` is written by every writer, and the
31
+ * same backfill stamps `unsubscribe` on the pre-AGL-2408 rows that carry
32
+ * none, which is what an absent reason has always meant.
33
+ *
34
+ * `Since` is `createdAt`, the list's own order, so a date range on it
35
+ * keeps that order and needs no index of its own.
36
+ *=========================================*/ export const SUPPRESSION_LIST_QUERY = {
37
+ fields: [
38
+ {
39
+ column: 'email',
40
+ kind: 'text',
41
+ path: 'email',
42
+ tokensPath: 'emailTokens',
43
+ operators: [
44
+ 'contains'
45
+ ]
46
+ },
47
+ {
48
+ column: 'reason',
49
+ kind: 'exact',
50
+ path: 'reason',
51
+ operators: [
52
+ 'equals',
53
+ 'isAnyOf'
54
+ ]
55
+ },
56
+ {
57
+ column: 'since',
58
+ kind: 'date',
59
+ path: 'createdAt',
60
+ presence: 'always'
61
+ }
62
+ ],
63
+ sorts: [
64
+ {
65
+ path: 'createdAt',
66
+ direction: 'desc',
67
+ column: 'since'
68
+ }
69
+ ],
70
+ search: {
71
+ tokensPath: 'emailTokens'
72
+ }
73
+ };
74
+ export const SUPPRESSION_FILTER_HEADERS = {
75
+ email: 'Address',
76
+ reason: 'Reason',
77
+ since: 'Since'
78
+ };
79
+ /*==========================================
80
+ * EMAIL LISTS — `orgs/{orgId}/lists`, by name.
81
+ *
82
+ * `nameLower` and `nameTokens` travel with `name` (`nameSearchFields`) on
83
+ * the two writers — the card's create and the edit page's rename — and
84
+ * `backfill-email-list-filters.mjs` stamps the lists written before them.
85
+ * `kind` is written on every create; the same backfill stamps `manual` on a
86
+ * list that predates the field, which is what an absent kind has always
87
+ * meant.
88
+ *=========================================*/ export const EMAIL_LIST_QUERY = {
89
+ fields: [
90
+ {
91
+ column: 'name',
92
+ kind: 'text',
93
+ path: 'name',
94
+ lowerPath: 'nameLower',
95
+ tokensPath: 'nameTokens',
96
+ operators: [
97
+ 'contains',
98
+ 'equals'
99
+ ]
100
+ },
101
+ {
102
+ column: 'kind',
103
+ kind: 'exact',
104
+ path: 'kind',
105
+ operators: [
106
+ 'equals'
107
+ ]
108
+ }
109
+ ],
110
+ sorts: [
111
+ {
112
+ path: 'name',
113
+ direction: 'asc',
114
+ column: 'name'
115
+ }
116
+ ],
117
+ search: {
118
+ tokensPath: 'nameTokens'
119
+ }
120
+ };
121
+ export const EMAIL_LIST_FILTER_HEADERS = {
122
+ name: 'List',
123
+ kind: 'Membership'
124
+ };
125
+ export const EMAIL_LIST_FILTER_OPTIONS = {
126
+ kind: [
127
+ {
128
+ value: 'manual',
129
+ label: 'Manual'
130
+ },
131
+ {
132
+ value: 'dynamic',
133
+ label: 'Rule'
134
+ }
135
+ ]
136
+ };
137
+ /*==========================================
138
+ * A LIST'S MEMBERS — `orgs/{orgId}/lists/{listId}/members`, by document id.
139
+ *
140
+ * `__name__` is the order because it is the one key every row has (see the
141
+ * panel), and under it equalities and one array clause merge on Firestore's
142
+ * automatic single-field indexes: no composite at all.
143
+ *
144
+ * `searchTokens` is the name's word prefixes and the address's
145
+ * (`listMemberSearchTokens`), stamped by `enrollListMember` — the
146
+ * collection's only writer — and by `backfill-email-list-filters.mjs`.
147
+ * `email` is normalized before every write, so `equals` asks for the
148
+ * normalized address. `via` is written on every new row and stamped
149
+ * `manual` where it is absent, which is what absent has always meant.
150
+ *
151
+ * ⛔ Consent is NOT filterable. It is read per viewing consent group
152
+ * (`readMarketingBasis`), so no stored value answers it for every reader.
153
+ *=========================================*/ export const LIST_MEMBER_QUERY = {
154
+ fields: [
155
+ {
156
+ column: 'email',
157
+ kind: 'text',
158
+ path: 'email',
159
+ lowerPath: 'email',
160
+ presence: 'always',
161
+ operators: [
162
+ 'equals'
163
+ ]
164
+ },
165
+ {
166
+ column: 'via',
167
+ kind: 'exact',
168
+ path: 'via',
169
+ operators: [
170
+ 'equals'
171
+ ]
172
+ }
173
+ ],
174
+ sorts: [
175
+ {
176
+ path: '__name__',
177
+ direction: 'asc'
178
+ }
179
+ ],
180
+ search: {
181
+ tokensPath: 'searchTokens'
182
+ }
183
+ };
184
+ export const LIST_MEMBER_FILTER_HEADERS = {
185
+ email: 'Address',
186
+ via: 'How'
187
+ };
188
+ export const LIST_MEMBER_FILTER_OPTIONS = {
189
+ via: [
190
+ {
191
+ value: 'rule',
192
+ label: 'Rule'
193
+ },
194
+ {
195
+ value: 'manual',
196
+ label: 'Added'
197
+ }
198
+ ]
199
+ };
200
+ /*==========================================
201
+ * EMAIL TEMPLATES — `hosts/{hostId}/screens` where `kind == 'email'`, by
202
+ * name.
203
+ *
204
+ * The screen search keys — `nameLower` and `nameTokens`, both from
205
+ * `displayName` (`displayNameSearchFields`) — are what every screen writer
206
+ * stamps on a create and a rename, and what the site artifacts backfill
207
+ * stamps on the screens written before them. The order is `nameLower`, so a
208
+ * screen without it is not listed: a deleted template clears its keys with
209
+ * the delete (`emailTemplateSoftDelete`), which is how the list leaves
210
+ * tombstones out without a clause no query could hold ("deletedAt is
211
+ * absent").
212
+ *
213
+ * ⛔ Origin (yours or installed) is NOT filterable: "installed" is the
214
+ * presence of the install provenance and "yours" its absence, and a query
215
+ * cannot ask for a field to be absent.
216
+ *=========================================*/ export const EMAIL_TEMPLATE_QUERY = {
217
+ fields: [
218
+ {
219
+ column: 'displayName',
220
+ kind: 'text',
221
+ path: 'displayName',
222
+ lowerPath: 'nameLower',
223
+ tokensPath: 'nameTokens',
224
+ // `startsWith` ranges over `nameLower`, the list's own order. No
225
+ // `endsWith`: it would range over `nameReversed` and reorder the list
226
+ // by it, an order's worth of indexes for one operator.
227
+ operators: [
228
+ 'contains',
229
+ 'equals',
230
+ 'startsWith'
231
+ ]
232
+ }
233
+ ],
234
+ sorts: [
235
+ {
236
+ path: 'nameLower',
237
+ direction: 'asc',
238
+ column: 'displayName'
239
+ }
240
+ ],
241
+ search: {
242
+ tokensPath: 'nameTokens'
243
+ }
244
+ };
245
+ /** The template list's scope: email screens only. */ export const EMAIL_TEMPLATE_BASE = [
246
+ {
247
+ path: 'kind',
248
+ op: '==',
249
+ value: 'email'
250
+ }
251
+ ];
252
+ export const EMAIL_TEMPLATE_FILTER_HEADERS = {
253
+ displayName: 'Template'
254
+ };
255
+
256
+ //# sourceMappingURL=list-queries.js.map
@@ -0,0 +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","value","label","LIST_MEMBER_QUERY","LIST_MEMBER_FILTER_HEADERS","via","LIST_MEMBER_FILTER_OPTIONS","EMAIL_TEMPLATE_QUERY","EMAIL_TEMPLATE_BASE","op","EMAIL_TEMPLATE_FILTER_HEADERS","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAKD;;;;;;;;CAQC,GAED;;;;;;;;;;;;2CAY2C,GAC3C,OAAO,MAAMA,yBAA+C;IAC1DC,QAAQ;QACN;YACEC,QAAQ;YACRC,MAAM;YACNC,MAAM;YACNC,YAAY;YACZC,WAAW;gBAAC;aAAW;QACzB;QACA;YAAEJ,QAAQ;YAAUC,MAAM;YAASC,MAAM;YAAUE,WAAW;gBAAC;gBAAU;aAAU;QAAC;QACpF;YAAEJ,QAAQ;YAASC,MAAM;YAAQC,MAAM;YAAaG,UAAU;QAAS;KACxE;IACDC,OAAO;QAAC;YAAEJ,MAAM;YAAaK,WAAW;YAAQP,QAAQ;QAAQ;KAAE;IAClEQ,QAAQ;QAAEL,YAAY;IA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AAED;;;;;;;;;;;;;;;;2CAgB2C,GAC3C,OAAO,MAAMK,uBAA6C;IACxDzB,QAAQ;QACN;YACEC,QAAQ;YACRC,MAAM;YACNC,MAAM;YACNY,WAAW;YACXX,YAAY;YACZ,iEAAiE;YACjE,sEAAsE;YACtE,uDAAuD;YACvDC,WAAW;gBAAC;gBAAY;gBAAU;aAAa;QACjD;KACD;IACDE,OAAO;QAAC;YAAEJ,MAAM;YAAaK,WAAW;YAAOP,QAAQ;QAAc;KAAE;IACvEQ,QAAQ;QAAEL,YAAY;IAAa;AACrC,EAAC;AAED,mDAAmD,GACnD,OAAO,MAAMsB,sBAAsB;IAAC;QAAEvB,MAAM;QAAQwB,IAAI;QAAeR,OAAO;IAAQ;CAAE,CAAA;AAExF,OAAO,MAAMS,gCAAkE;IAC7EC,aAAa;AACf,EAAC"}
@@ -16,7 +16,7 @@ import { _ as _extends } from "@swc/helpers/_/_extends";
16
16
  * limitations under the License.
17
17
  */ import { createResourceUid } from "@aglyn/aglyn/app-utils/create-resource-uid";
18
18
  import { uniqueDuplicateName } from "@aglyn/aglyn/app-utils/duplicate-resource";
19
- import { nameSearchKey } from "@aglyn/aglyn/app-utils/name-search";
19
+ import { artifactCreateListKeys } from "@aglyn/aglyn/app-utils/artifact-list-keys";
20
20
  import { hostRoleCanWrite } from "@aglyn/aglyn/app-utils/organizations";
21
21
  import { NON_PAGE_SCREEN_MAX_PER_HOST, nonPageScreenIds, SCREEN_KIND_EMAIL } from "@aglyn/aglyn/app-utils/screen-route";
22
22
  import { encodeStoredNodes } from "@aglyn/aglyn/app-utils/stored-nodes";
@@ -363,9 +363,11 @@ export function createEmailDesignDraftWriter(deps = {}) {
363
363
  createdBy: request.uid
364
364
  };
365
365
  const copy = copyFields(read.value);
366
- tx.create(screenRef, _extends({}, screen, {
367
- nameLower: nameSearchKey(name)
368
- }, copy, stamps));
366
+ // The keys the email templates list finds it by, and the stored
367
+ // `deletedAt: null` a campaign's screens list asks for (AGL-3321).
368
+ tx.create(screenRef, _extends({}, screen, artifactCreateListKeys('screens', {
369
+ displayName: name
370
+ }), copy, stamps));
369
371
  tx.create(screenRef.collection('versions').doc(versionId), _extends({}, version, {
370
372
  nodes: Buffer.from(packed),
371
373
  hostId: request.hostId