@aglyn/tenant-data-admin 1.0.0-beta.275 → 1.0.0-beta.282

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 (34) hide show
  1. package/package.json +7 -7
  2. package/src/lib/server/account-emails.js +18 -4
  3. package/src/lib/server/account-emails.js.map +1 -1
  4. package/src/lib/server/bundle-links.d.ts +5 -0
  5. package/src/lib/server/bundle-links.js +4 -2
  6. package/src/lib/server/bundle-links.js.map +1 -1
  7. package/src/lib/server/erase.js +9 -0
  8. package/src/lib/server/erase.js.map +1 -1
  9. package/src/lib/server/media-strong-digest.js +33 -5
  10. package/src/lib/server/media-strong-digest.js.map +1 -1
  11. package/src/lib/server/organizations.js +20 -0
  12. package/src/lib/server/organizations.js.map +1 -1
  13. package/src/lib/server/owner-handoff-emails.d.ts +43 -0
  14. package/src/lib/server/owner-handoff-emails.js +134 -0
  15. package/src/lib/server/owner-handoff-emails.js.map +1 -0
  16. package/src/lib/server/personal-data-export.js +18 -4
  17. package/src/lib/server/personal-data-export.js.map +1 -1
  18. package/src/lib/server/render-monitor.d.ts +8 -4
  19. package/src/lib/server/render-monitor.js +12 -8
  20. package/src/lib/server/render-monitor.js.map +1 -1
  21. package/src/lib/server/site-care-inbound.d.ts +75 -4
  22. package/src/lib/server/site-care-inbound.js +236 -26
  23. package/src/lib/server/site-care-inbound.js.map +1 -1
  24. package/src/lib/server/site-care-reconcile.d.ts +36 -2
  25. package/src/lib/server/site-care-reconcile.js +219 -54
  26. package/src/lib/server/site-care-reconcile.js.map +1 -1
  27. package/src/lib/server/site-care-requests.d.ts +43 -1
  28. package/src/lib/server/site-care-requests.js +117 -6
  29. package/src/lib/server/site-care-requests.js.map +1 -1
  30. package/src/lib/server/upgrade-proposal.d.ts +6 -1
  31. package/src/lib/server/upgrade-proposal.js.map +1 -1
  32. package/src/lib/server/upload-cors-reconcile.d.ts +2 -2
  33. package/src/lib/server/upload-cors-reconcile.js +2 -2
  34. package/src/lib/server/upload-cors-reconcile.js.map +1 -1
@@ -0,0 +1,43 @@
1
+ export interface OwnerHandoffEmailsOptions {
2
+ orgId: string;
3
+ newOwner: {
4
+ email: string;
5
+ displayName?: string | null;
6
+ };
7
+ previousOwner: {
8
+ email: string | null;
9
+ displayName?: string | null;
10
+ };
11
+ /** `stay` keeps the previous owner on as an admin; `leave` removes them. */
12
+ previousOwnerStays: boolean;
13
+ }
14
+ /**
15
+ * The two emails a completed workspace handoff sends (AGL-4023): one to the
16
+ * new owner, one to the person who handed it over.
17
+ *
18
+ * A handoff changes who holds the workspace, every site in it and its
19
+ * billing, and both sides need to hear it from the platform, not only from
20
+ * a console notification one of them may never open: the new owner because
21
+ * an invitation now takes effect on its own, with nothing for them to press,
22
+ * and the previous owner because it is the moment their workspace stopped
23
+ * being theirs.
24
+ *
25
+ * Sent after the handoff's transaction has committed, from
26
+ * `acceptOwnerHandoff`, so every way a handoff completes sends them. Never
27
+ * throws: the handoff has happened whether or not the mail goes.
28
+ */
29
+ export declare function sendOwnerHandoffEmails(options: OwnerHandoffEmailsOptions): Promise<void>;
30
+ /** One message {@link buildOwnerHandoffEmails} renders, ready for `sendEmail`. */
31
+ export interface OwnerHandoffEmail {
32
+ to: string;
33
+ subject: string;
34
+ text: string;
35
+ html?: string;
36
+ fromName?: string;
37
+ context: string;
38
+ }
39
+ /**
40
+ * The two messages, rendered in the workspace's brand and not sent: the new
41
+ * owner's, then the previous owner's when they have an address.
42
+ */
43
+ export declare function buildOwnerHandoffEmails(options: OwnerHandoffEmailsOptions): Promise<OwnerHandoffEmail[]>;
@@ -0,0 +1,134 @@
1
+ import { _ as _extends } from "@swc/helpers/_/_extends";
2
+ /**
3
+ * @license
4
+ * Copyright 2026 Aglyn LLC
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */ import { platformConsoleOrigin } from "@aglyn/aglyn/app-utils/platform-brand";
18
+ import { standingUpgradeProposal, upgradeProposalDestination, upgradeProposalSummary } from "@aglyn/aglyn/app-utils/upgrade-proposal";
19
+ import { PLAN_LABELS } from "@aglyn/aglyn/app-utils/plan-entitlements";
20
+ import { isEmailConfigured, sendEmail } from "@aglyn/shared-util-email";
21
+ import { meterOrgEmail } from "./email-metering.js";
22
+ import { firebaseAdmin } from "./firebase-admin.js";
23
+ import { renderSystemEmailContent, systemEmailBrand } from "./render-system-email.js";
24
+ /**
25
+ * The two emails a completed workspace handoff sends (AGL-4023): one to the
26
+ * new owner, one to the person who handed it over.
27
+ *
28
+ * A handoff changes who holds the workspace, every site in it and its
29
+ * billing, and both sides need to hear it from the platform, not only from
30
+ * a console notification one of them may never open: the new owner because
31
+ * an invitation now takes effect on its own, with nothing for them to press,
32
+ * and the previous owner because it is the moment their workspace stopped
33
+ * being theirs.
34
+ *
35
+ * Sent after the handoff's transaction has committed, from
36
+ * `acceptOwnerHandoff`, so every way a handoff completes sends them. Never
37
+ * throws: the handoff has happened whether or not the mail goes.
38
+ */ export async function sendOwnerHandoffEmails(options) {
39
+ if (!isEmailConfigured()) return;
40
+ try {
41
+ for (const message of (await buildOwnerHandoffEmails(options))){
42
+ await sendEmail(message);
43
+ await meterOrgEmail(options.orgId);
44
+ }
45
+ } catch (error) {
46
+ console.error('owner handoff emails failed', error);
47
+ }
48
+ }
49
+ /**
50
+ * The two messages, rendered in the workspace's brand and not sent: the new
51
+ * owner's, then the previous owner's when they have an address.
52
+ */ export async function buildOwnerHandoffEmails(options) {
53
+ const { orgId, newOwner, previousOwner, previousOwnerStays } = options;
54
+ const messages = [];
55
+ {
56
+ var _orgSnapshot_data, _org_name, _org_slug, _orgSnapshot_data1, _PLAN_LABELS_proposal_plan;
57
+ var _newOwner_displayName, _previousOwner_displayName;
58
+ const orgSnapshot = await firebaseAdmin.app().firestore().collection('orgs').doc(orgId).get();
59
+ const org = (_orgSnapshot_data = orgSnapshot.data()) != null ? _orgSnapshot_data : {};
60
+ const orgName = String((_org_name = org.name) != null ? _org_name : 'your workspace');
61
+ const slug = String((_org_slug = org.slug) != null ? _org_slug : '');
62
+ const origin = platformConsoleOrigin();
63
+ const brand = systemEmailBrand(orgSnapshot.exists ? (_orgSnapshot_data1 = orgSnapshot.data()) != null ? _orgSnapshot_data1 : null : null);
64
+ const newOwnerName = ((_newOwner_displayName = newOwner.displayName) == null ? void 0 : _newOwner_displayName.trim()) || newOwner.email;
65
+ const previousOwnerName = ((_previousOwner_displayName = previousOwner.displayName) == null ? void 0 : _previousOwner_displayName.trim()) || previousOwner.email || 'The previous owner';
66
+ // The new owner: theirs now, and the next step. A handoff that proposed
67
+ // its plan (AGL-3956) still has it standing, so the button is Billing
68
+ // with that plan chosen; otherwise it opens the workspace.
69
+ const proposal = standingUpgradeProposal(org);
70
+ const planLabel = proposal ? (_PLAN_LABELS_proposal_plan = PLAN_LABELS[proposal.plan]) != null ? _PLAN_LABELS_proposal_plan : proposal.plan : '';
71
+ const nextStep = proposal ? `Your plan is ready to start: ${upgradeProposalSummary(proposal, {
72
+ brand: brand.merge['brand.productName']
73
+ })}. Billing opens with it already chosen, and nothing is charged ` + 'until you confirm.' : 'Open the workspace to see its sites, its team and Billing.';
74
+ const newOwnerCta = proposal && slug ? {
75
+ label: `Start the ${planLabel} plan`,
76
+ url: `${origin}${upgradeProposalDestination(slug, proposal)}`
77
+ } : {
78
+ label: `Open ${orgName}`,
79
+ url: slug ? `${origin}/${slug}` : origin
80
+ };
81
+ const previousOwnerLine = previousOwnerStays ? `${previousOwnerName} stays on as an admin.` : `${previousOwnerName} has left the workspace.`;
82
+ const toNewOwner = await renderSystemEmailContent('org-owner-handoff-new-owner', {
83
+ 'org.name': orgName,
84
+ 'handoff.previousOwner': previousOwnerLine,
85
+ nextStep,
86
+ 'cta.label': newOwnerCta.label,
87
+ 'cta.url': newOwnerCta.url
88
+ }, brand, {
89
+ subject: `${orgName} is yours`,
90
+ text: `You now own ${orgName}: the workspace, every site in it, and its ` + `billing. ${previousOwnerLine}\n\n${nextStep}\n\n${newOwnerCta.url}`
91
+ });
92
+ messages.push(_extends({
93
+ to: newOwner.email
94
+ }, toNewOwner, brand.fromName ? {
95
+ fromName: brand.fromName
96
+ } : {}, {
97
+ context: 'org-owner-handoff-new-owner'
98
+ }));
99
+ // The person who handed it over: who holds it now, and where that
100
+ // leaves them.
101
+ if (previousOwner.email) {
102
+ const outcome = previousOwnerStays ? 'You stay on as an admin, so you can keep helping with the workspace and its sites.' : 'You have left the workspace and no longer have access to it.';
103
+ const previousOwnerCta = previousOwnerStays && slug ? {
104
+ label: 'Open the team',
105
+ url: `${origin}/${slug}/team`
106
+ } : {
107
+ label: 'Open your workspaces',
108
+ url: origin
109
+ };
110
+ const toPreviousOwner = await renderSystemEmailContent('org-owner-handoff-previous-owner', {
111
+ 'org.name': orgName,
112
+ 'newOwner.name': newOwnerName,
113
+ 'newOwner.email': newOwner.email,
114
+ 'previousOwner.role': previousOwnerStays ? 'Admin' : 'Left the workspace',
115
+ 'previousOwner.outcome': outcome,
116
+ 'cta.label': previousOwnerCta.label,
117
+ 'cta.url': previousOwnerCta.url
118
+ }, brand, {
119
+ subject: `${newOwnerName} now owns ${orgName}`,
120
+ text: `${newOwnerName} took over ${orgName}. They now hold the ` + `workspace, every site in it, and its billing.\n\n${outcome}\n\n` + previousOwnerCta.url
121
+ });
122
+ messages.push(_extends({
123
+ to: previousOwner.email
124
+ }, toPreviousOwner, brand.fromName ? {
125
+ fromName: brand.fromName
126
+ } : {}, {
127
+ context: 'org-owner-handoff-previous-owner'
128
+ }));
129
+ }
130
+ }
131
+ return messages;
132
+ }
133
+
134
+ //# sourceMappingURL=owner-handoff-emails.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../../libs/tenant/data/admin/src/lib/server/owner-handoff-emails.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 */\nimport { platformConsoleOrigin } from '@aglyn/aglyn/app-utils/platform-brand'\nimport {\n standingUpgradeProposal,\n upgradeProposalDestination,\n upgradeProposalSummary,\n} from '@aglyn/aglyn/app-utils/upgrade-proposal'\nimport { PLAN_LABELS } from '@aglyn/aglyn/app-utils/plan-entitlements'\nimport type { AglynOrgBilling } from '@aglyn/aglyn/server'\nimport { isEmailConfigured, sendEmail } from '@aglyn/shared-util-email'\nimport { meterOrgEmail } from './email-metering'\nimport { firebaseAdmin } from './firebase-admin'\nimport {\n renderSystemEmailContent,\n systemEmailBrand,\n} from './render-system-email'\n\nexport interface OwnerHandoffEmailsOptions {\n orgId: string\n newOwner: { email: string; displayName?: string | null }\n previousOwner: { email: string | null; displayName?: string | null }\n /** `stay` keeps the previous owner on as an admin; `leave` removes them. */\n previousOwnerStays: boolean\n}\n\n/**\n * The two emails a completed workspace handoff sends (AGL-4023): one to the\n * new owner, one to the person who handed it over.\n *\n * A handoff changes who holds the workspace, every site in it and its\n * billing, and both sides need to hear it from the platform, not only from\n * a console notification one of them may never open: the new owner because\n * an invitation now takes effect on its own, with nothing for them to press,\n * and the previous owner because it is the moment their workspace stopped\n * being theirs.\n *\n * Sent after the handoff's transaction has committed, from\n * `acceptOwnerHandoff`, so every way a handoff completes sends them. Never\n * throws: the handoff has happened whether or not the mail goes.\n */\nexport async function sendOwnerHandoffEmails(\n options: OwnerHandoffEmailsOptions,\n): Promise<void> {\n if (!isEmailConfigured()) return\n try {\n for (const message of await buildOwnerHandoffEmails(options)) {\n await sendEmail(message)\n await meterOrgEmail(options.orgId)\n }\n } catch (error) {\n console.error('owner handoff emails failed', error)\n }\n}\n\n/** One message {@link buildOwnerHandoffEmails} renders, ready for `sendEmail`. */\nexport interface OwnerHandoffEmail {\n to: string\n subject: string\n text: string\n html?: string\n fromName?: string\n context: string\n}\n\n/**\n * The two messages, rendered in the workspace's brand and not sent: the new\n * owner's, then the previous owner's when they have an address.\n */\nexport async function buildOwnerHandoffEmails(\n options: OwnerHandoffEmailsOptions,\n): Promise<OwnerHandoffEmail[]> {\n const { orgId, newOwner, previousOwner, previousOwnerStays } = options\n const messages: OwnerHandoffEmail[] = []\n {\n const orgSnapshot = await firebaseAdmin\n .app()\n .firestore()\n .collection('orgs')\n .doc(orgId)\n .get()\n const org = (orgSnapshot.data() ?? {}) as Partial<AglynOrgBilling> & {\n name?: string\n slug?: string\n }\n const orgName = String(org.name ?? 'your workspace')\n const slug = String(org.slug ?? '')\n const origin = platformConsoleOrigin()\n const brand = systemEmailBrand(\n orgSnapshot.exists ? (orgSnapshot.data() ?? null) : null,\n )\n const newOwnerName = newOwner.displayName?.trim() || newOwner.email\n const previousOwnerName =\n previousOwner.displayName?.trim() ||\n previousOwner.email ||\n 'The previous owner'\n\n // The new owner: theirs now, and the next step. A handoff that proposed\n // its plan (AGL-3956) still has it standing, so the button is Billing\n // with that plan chosen; otherwise it opens the workspace.\n const proposal = standingUpgradeProposal(org)\n const planLabel = proposal\n ? (PLAN_LABELS[proposal.plan] ?? proposal.plan)\n : ''\n const nextStep = proposal\n ? `Your plan is ready to start: ${upgradeProposalSummary(proposal, {\n brand: brand.merge['brand.productName'],\n })}. Billing opens with it already chosen, and nothing is charged ` +\n 'until you confirm.'\n : 'Open the workspace to see its sites, its team and Billing.'\n const newOwnerCta =\n proposal && slug\n ? {\n label: `Start the ${planLabel} plan`,\n url: `${origin}${upgradeProposalDestination(slug, proposal)}`,\n }\n : { label: `Open ${orgName}`, url: slug ? `${origin}/${slug}` : origin }\n const previousOwnerLine = previousOwnerStays\n ? `${previousOwnerName} stays on as an admin.`\n : `${previousOwnerName} has left the workspace.`\n const toNewOwner = await renderSystemEmailContent(\n 'org-owner-handoff-new-owner',\n {\n 'org.name': orgName,\n 'handoff.previousOwner': previousOwnerLine,\n nextStep,\n 'cta.label': newOwnerCta.label,\n 'cta.url': newOwnerCta.url,\n },\n brand,\n {\n subject: `${orgName} is yours`,\n text:\n `You now own ${orgName}: the workspace, every site in it, and its ` +\n `billing. ${previousOwnerLine}\\n\\n${nextStep}\\n\\n${newOwnerCta.url}`,\n },\n )\n messages.push({\n to: newOwner.email,\n ...toNewOwner,\n ...(brand.fromName ? { fromName: brand.fromName } : {}),\n context: 'org-owner-handoff-new-owner',\n })\n\n // The person who handed it over: who holds it now, and where that\n // leaves them.\n if (previousOwner.email) {\n const outcome = previousOwnerStays\n ? 'You stay on as an admin, so you can keep helping with the workspace and its sites.'\n : 'You have left the workspace and no longer have access to it.'\n const previousOwnerCta =\n previousOwnerStays && slug\n ? { label: 'Open the team', url: `${origin}/${slug}/team` }\n : { label: 'Open your workspaces', url: origin }\n const toPreviousOwner = await renderSystemEmailContent(\n 'org-owner-handoff-previous-owner',\n {\n 'org.name': orgName,\n 'newOwner.name': newOwnerName,\n 'newOwner.email': newOwner.email,\n 'previousOwner.role': previousOwnerStays\n ? 'Admin'\n : 'Left the workspace',\n 'previousOwner.outcome': outcome,\n 'cta.label': previousOwnerCta.label,\n 'cta.url': previousOwnerCta.url,\n },\n brand,\n {\n subject: `${newOwnerName} now owns ${orgName}`,\n text:\n `${newOwnerName} took over ${orgName}. They now hold the ` +\n `workspace, every site in it, and its billing.\\n\\n${outcome}\\n\\n` +\n previousOwnerCta.url,\n },\n )\n messages.push({\n to: previousOwner.email,\n ...toPreviousOwner,\n ...(brand.fromName ? { fromName: brand.fromName } : {}),\n context: 'org-owner-handoff-previous-owner',\n })\n }\n }\n return messages\n}\n"],"names":["platformConsoleOrigin","standingUpgradeProposal","upgradeProposalDestination","upgradeProposalSummary","PLAN_LABELS","isEmailConfigured","sendEmail","meterOrgEmail","firebaseAdmin","renderSystemEmailContent","systemEmailBrand","sendOwnerHandoffEmails","options","message","buildOwnerHandoffEmails","orgId","error","console","newOwner","previousOwner","previousOwnerStays","messages","orgSnapshot","org","app","firestore","collection","doc","get","data","orgName","String","name","slug","origin","brand","exists","newOwnerName","displayName","trim","email","previousOwnerName","proposal","planLabel","plan","nextStep","merge","newOwnerCta","label","url","previousOwnerLine","toNewOwner","subject","text","push","to","fromName","context","outcome","previousOwnerCta","toPreviousOwner"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GACD,SAASA,qBAAqB,QAAQ,wCAAuC;AAC7E,SACEC,uBAAuB,EACvBC,0BAA0B,EAC1BC,sBAAsB,QACjB,0CAAyC;AAChD,SAASC,WAAW,QAAQ,2CAA0C;AAEtE,SAASC,iBAAiB,EAAEC,SAAS,QAAQ,2BAA0B;AACvE,SAASC,aAAa,QAAQ,sBAAkB;AAChD,SAASC,aAAa,QAAQ,sBAAkB;AAChD,SACEC,wBAAwB,EACxBC,gBAAgB,QACX,2BAAuB;AAU9B;;;;;;;;;;;;;;CAcC,GACD,OAAO,eAAeC,uBACpBC,OAAkC;IAElC,IAAI,CAACP,qBAAqB;IAC1B,IAAI;QACF,KAAK,MAAMQ,WAAW,CAAA,MAAMC,wBAAwBF,QAAO,EAAG;YAC5D,MAAMN,UAAUO;YAChB,MAAMN,cAAcK,QAAQG,KAAK;QACnC;IACF,EAAE,OAAOC,OAAO;QACdC,QAAQD,KAAK,CAAC,+BAA+BA;IAC/C;AACF;AAYA;;;CAGC,GACD,OAAO,eAAeF,wBACpBF,OAAkC;IAElC,MAAM,EAAEG,KAAK,EAAEG,QAAQ,EAAEC,aAAa,EAAEC,kBAAkB,EAAE,GAAGR;IAC/D,MAAMS,WAAg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CAAC,iDAAiD,EAAE4B,QAAQ,IAAI,CAAC,GACjEC,iBAAiBV,GAAG;YACxB;YAEF5B,SAASiC,IAAI,CAAC;gBACZC,IAAIpC,cAAcqB,KAAK;eACpBoB,iBACCzB,MAAMqB,QAAQ,GAAG;gBAAEA,UAAUrB,MAAMqB,QAAQ;YAAC,IAAI,CAAC;gBACrDC,SAAS;;QAEb;IACF;IACA,OAAOpC;AACT"}
@@ -72,7 +72,8 @@ import { _ as _extends } from "@swc/helpers/_/_extends";
72
72
  * header says it never includes bookings, leads, submissions or secrets, and
73
73
  * offering it as a portability answer would be misdescribing it. Not the
74
74
  * `firestore-export` cron, which is an unscoped DR snapshot. Not the audit CSV.
75
- */ import { firebaseAdmin } from "./firebase-admin.js";
75
+ */ import { SITE_CARE_STAFF_COLLECTION } from "@aglyn/aglyn/app-utils/site-care";
76
+ import { firebaseAdmin } from "./firebase-admin.js";
76
77
  import { CONSOLE_DOMAINS_COLLECTION } from "./console-domains.js";
77
78
  const firestoreApp = ()=>firebaseAdmin.app().firestore();
78
79
  /**
@@ -534,7 +535,7 @@ const firestoreApp = ()=>firebaseAdmin.app().firestore();
534
535
  'user'
535
536
  ],
536
537
  exported: true,
537
- note: 'For an ORG: every thread and its messages. For a PERSON: only the messages they themselves authored — a thread has other authors, and handing a member the whole conversation would disclose colleagues’ words to them.'
538
+ note: 'For an ORG: every thread and its messages, except a Site Care request’s staff-only intake (the other workspaces its sender belongs to, AGL-4031). For a PERSON: only the messages they themselves authored — a thread has other authors, and handing a member the whole conversation would disclose colleagues’ words to them.'
538
539
  },
539
540
  // ── Retained past erasure on statutory grounds ────────────────────────
540
541
  {
@@ -555,6 +556,15 @@ const firestoreApp = ()=>firebaseAdmin.app().firestore();
555
556
  exported: true,
556
557
  note: 'Sales tax charged to shoppers on the org’s storefront (AGL-1904). Same statutory retention, same access obligation.'
557
558
  },
559
+ {
560
+ collection: 'posHardwareSales',
561
+ keyedBy: 'field',
562
+ subjects: [
563
+ 'org'
564
+ ],
565
+ exported: true,
566
+ note: 'The platform’s record of each card reader order the org bought from the hardware shop (AGL-4038): lines, amounts, tax, Stripe ids, status dates and the country, state and postal code it shipped to — never the buyer. Kept past ERASURE as a tax and accounting record, GDPR Art. 17(3)(b); disclosed on ACCESS like the other two.'
567
+ },
558
568
  // ── Records of our own handling ───────────────────────────────────────
559
569
  {
560
570
  collection: 'adminAudit',
@@ -1112,7 +1122,8 @@ function sourcesFor(subject) {
1112
1122
  'orgSlugs',
1113
1123
  'publisherHandles',
1114
1124
  'platformRevenue',
1115
- 'storefrontTaxCollected'
1125
+ 'storefrontTaxCollected',
1126
+ 'posHardwareSales'
1116
1127
  ]){
1117
1128
  data[collection] = await readByField(db, collection, 'orgId', orgId);
1118
1129
  }
@@ -1172,7 +1183,10 @@ function sourcesFor(subject) {
1172
1183
  const tickets = await db.collection('supportTickets').where('orgId', '==', orgId).get();
1173
1184
  const ticketDocs = [];
1174
1185
  for (const ticket of tickets.docs){
1175
- ticketDocs.push(...await readSubtree(db, ticket.ref, 0, 2));
1186
+ // Not a Site Care request's staff-only intake (AGL-4031): which other
1187
+ // workspaces its sender belongs to is the sender's, not this org's.
1188
+ const staffOnly = `/${SITE_CARE_STAFF_COLLECTION}/`;
1189
+ ticketDocs.push(...(await readSubtree(db, ticket.ref, 0, 2)).filter((found)=>!found.path.includes(staffOnly)));
1176
1190
  }
1177
1191
  data['supportTickets'] = ticketDocs;
1178
1192
  // Withheld, but counted — see the note on this function.