@cosmicdrift/kumiko-samples 0.413.0 → 0.414.0

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 (459) hide show
  1. package/package.json +1 -1
  2. package/packages/bundled-features/package.json +16 -1
  3. package/packages/bundled-features/src/admin-shell/changes.json +6 -0
  4. package/packages/bundled-features/src/admin-shell/feature.ts +8 -7
  5. package/packages/bundled-features/src/agent-tools/agent-doc-lint.ts +5 -1
  6. package/packages/bundled-features/src/agent-tools/agent-manifest.ts +36 -27
  7. package/packages/bundled-features/src/agent-tools/api-docs/collect-events.ts +8 -1
  8. package/packages/bundled-features/src/agent-tools/api-docs/collect.ts +3 -2
  9. package/packages/bundled-features/src/agent-tools/api-docs/generate.ts +6 -0
  10. package/packages/bundled-features/src/agent-tools/api-docs/index.ts +1 -0
  11. package/packages/bundled-features/src/agent-tools/api-docs/problems.ts +38 -1
  12. package/packages/bundled-features/src/agent-tools/api-docs/render-openapi.ts +1 -0
  13. package/packages/bundled-features/src/agent-tools/api-docs/resolve-config.ts +17 -0
  14. package/packages/bundled-features/src/agent-tools/api-docs/scope-slug-collisions.ts +17 -0
  15. package/packages/bundled-features/src/agent-tools/api-docs/translation-gaps.ts +42 -0
  16. package/packages/bundled-features/src/agent-tools/api-docs/webhook-example-problems.ts +30 -0
  17. package/packages/bundled-features/src/agent-tools/changes.json +12 -0
  18. package/packages/bundled-features/src/agent-tools/index.ts +1 -0
  19. package/packages/bundled-features/src/agent-tools/labels.ts +19 -6
  20. package/packages/bundled-features/src/agent-tools/tool-catalog.ts +18 -7
  21. package/packages/bundled-features/src/agent-tools/tool-dispatch.ts +14 -1
  22. package/packages/bundled-features/src/agent-tools/types.ts +4 -0
  23. package/packages/bundled-features/src/audit/event-classification.ts +6 -0
  24. package/packages/bundled-features/src/audit/web/i18n.ts +1 -0
  25. package/packages/bundled-features/src/auth-email-password/changes.json +18 -0
  26. package/packages/bundled-features/src/auth-email-password/errors.ts +0 -13
  27. package/packages/bundled-features/src/auth-email-password/handlers/invite-signup-complete.write.ts +147 -121
  28. package/packages/bundled-features/src/auth-email-password/handlers/login-options.query.ts +1 -1
  29. package/packages/bundled-features/src/auth-email-password/handlers/request-account-unlock.write.ts +1 -1
  30. package/packages/bundled-features/src/auth-email-password/handlers/request-email-verification.write.ts +0 -1
  31. package/packages/bundled-features/src/auth-email-password/handlers/request-password-reset.write.ts +0 -1
  32. package/packages/bundled-features/src/auth-email-password/handlers/self-registration-status.query.ts +1 -1
  33. package/packages/bundled-features/src/auth-email-password/reset-token.ts +0 -2
  34. package/packages/bundled-features/src/auth-email-password/seeding.ts +39 -7
  35. package/packages/bundled-features/src/auth-email-password/unlock-token.ts +0 -2
  36. package/packages/bundled-features/src/auth-email-password/verification-token.ts +0 -2
  37. package/packages/bundled-features/src/auth-email-password/web/auth-form-primitives.tsx +2 -2
  38. package/packages/bundled-features/src/auth-email-password/web/auth-gate.tsx +2 -2
  39. package/packages/bundled-features/src/auth-email-password/web/auth-redirect.ts +5 -0
  40. package/packages/bundled-features/src/auth-email-password/web/forgot-password-screen.tsx +1 -6
  41. package/packages/bundled-features/src/auth-email-password/web/invite-accept-screen.tsx +1 -1
  42. package/packages/bundled-features/src/auth-email-password/web/return-path.ts +2 -1
  43. package/packages/bundled-features/src/auth-email-password/web/session.tsx +10 -12
  44. package/packages/bundled-features/src/auth-email-password/web/signup-screen.tsx +1 -6
  45. package/packages/bundled-features/src/auth-email-password/web/static-account.ts +6 -1
  46. package/packages/bundled-features/src/auth-email-password/web/tenant-switcher.tsx +1 -1
  47. package/packages/bundled-features/src/auth-email-password/web/token-confirm-screen.tsx +4 -5
  48. package/packages/bundled-features/src/auth-email-password/web/user-menu.tsx +1 -1
  49. package/packages/bundled-features/src/auth-mfa/web/mfa-code-or-recovery-field.tsx +17 -1
  50. package/packages/bundled-features/src/auth-mfa/web/mfa-disable-dialog.tsx +1 -1
  51. package/packages/bundled-features/src/auth-mfa/web/mfa-regenerate-recovery-dialog.tsx +1 -1
  52. package/packages/bundled-features/src/auth-mfa/web/mfa-setup-preauth-screen.tsx +1 -1
  53. package/packages/bundled-features/src/auth-mfa/web/mfa-verify-screen.tsx +16 -47
  54. package/packages/bundled-features/src/auth-mfa-user-data/index.ts +5 -6
  55. package/packages/bundled-features/src/billing-foundation/aggregate-id.ts +0 -4
  56. package/packages/bundled-features/src/billing-foundation/changes.json +37 -0
  57. package/packages/bundled-features/src/billing-foundation/checkout-core.ts +8 -1
  58. package/packages/bundled-features/src/billing-foundation/checkout-ledger.ts +59 -0
  59. package/packages/bundled-features/src/billing-foundation/consumer-protection/consent-gate.ts +2 -1
  60. package/packages/bundled-features/src/billing-foundation/consumer-protection/consent-text.ts +49 -2
  61. package/packages/bundled-features/src/billing-foundation/consumer-protection/termination-open-cancels.ts +5 -0
  62. package/packages/bundled-features/src/billing-foundation/consumer-protection/termination-provider-timeout.ts +23 -0
  63. package/packages/bundled-features/src/billing-foundation/consumer-protection/termination-record.ts +12 -7
  64. package/packages/bundled-features/src/billing-foundation/consumer-protection/termination-revoke.ts +1 -1
  65. package/packages/bundled-features/src/billing-foundation/events.ts +49 -10
  66. package/packages/bundled-features/src/billing-foundation/feature.ts +15 -1
  67. package/packages/bundled-features/src/billing-foundation/handlers/billing-plans.query.ts +47 -14
  68. package/packages/bundled-features/src/billing-foundation/handlers/create-checkout-session.write.ts +7 -1
  69. package/packages/bundled-features/src/billing-foundation/handlers/process-event.write.ts +124 -10
  70. package/packages/bundled-features/src/billing-foundation/handlers/process-payment-event.write.ts +33 -9
  71. package/packages/bundled-features/src/billing-foundation/handlers/record-checkout-opened.write.ts +25 -0
  72. package/packages/bundled-features/src/billing-foundation/handlers/start-plan-checkout.write.ts +7 -1
  73. package/packages/bundled-features/src/billing-foundation/handlers/switch-plan.write.ts +16 -4
  74. package/packages/bundled-features/src/billing-foundation/i18n.ts +3 -0
  75. package/packages/bundled-features/src/billing-foundation/pending-plan-switch.ts +80 -0
  76. package/packages/bundled-features/src/billing-foundation/scrub-raw-payload-headers.ts +50 -0
  77. package/packages/bundled-features/src/billing-foundation/types.ts +47 -30
  78. package/packages/bundled-features/src/billing-foundation/validate-options.ts +18 -0
  79. package/packages/bundled-features/src/billing-foundation/web/billing-plans-panel.tsx +10 -5
  80. package/packages/bundled-features/src/billing-foundation/web/cancel-contract-dialog.tsx +1 -1
  81. package/packages/bundled-features/src/billing-foundation/web/checkout-consent-dialog.tsx +1 -1
  82. package/packages/bundled-features/src/billing-foundation/web/constants.ts +5 -2
  83. package/packages/bundled-features/src/billing-foundation/web/plan-switch-confirm-dialog.tsx +1 -1
  84. package/packages/bundled-features/src/billing-foundation/webhook-handler.ts +65 -17
  85. package/packages/bundled-features/src/cap-counter/aggregate-id.ts +0 -2
  86. package/packages/bundled-features/src/cap-counter/changes.json +6 -0
  87. package/packages/bundled-features/src/cap-counter/stock-cap-guard.ts +19 -4
  88. package/packages/bundled-features/src/cap-overview/changes.json +6 -0
  89. package/packages/bundled-features/src/cap-overview/handlers/tenant-caps-list.query.ts +22 -6
  90. package/packages/bundled-features/src/cap-overview/i18n.ts +1 -0
  91. package/packages/bundled-features/src/cap-overview/index.ts +1 -0
  92. package/packages/bundled-features/src/cap-overview/types.ts +11 -1
  93. package/packages/bundled-features/src/cap-overview/web/cap-cards-panel.tsx +6 -2
  94. package/packages/bundled-features/src/cap-overview/web/cap-usage-bar.tsx +10 -1
  95. package/packages/bundled-features/src/cap-overview/web/usage-math.ts +5 -0
  96. package/packages/bundled-features/src/channel-in-app/changes.json +6 -0
  97. package/packages/bundled-features/src/channel-in-app/handlers/read-state-by-keys.query.ts +2 -2
  98. package/packages/bundled-features/src/channel-whatsapp/aggregate-id.ts +29 -0
  99. package/packages/bundled-features/src/channel-whatsapp/changes.json +8 -0
  100. package/packages/bundled-features/src/channel-whatsapp/constants.ts +46 -0
  101. package/packages/bundled-features/src/channel-whatsapp/events.ts +93 -0
  102. package/packages/bundled-features/src/channel-whatsapp/feature.ts +72 -0
  103. package/packages/bundled-features/src/channel-whatsapp/graph-client.ts +398 -0
  104. package/packages/bundled-features/src/channel-whatsapp/in-memory-meta.ts +300 -0
  105. package/packages/bundled-features/src/channel-whatsapp/inbound-handlers.ts +189 -0
  106. package/packages/bundled-features/src/channel-whatsapp/index.ts +66 -0
  107. package/packages/bundled-features/src/channel-whatsapp/meta-signature.ts +26 -0
  108. package/packages/bundled-features/src/channel-whatsapp/options.ts +149 -0
  109. package/packages/bundled-features/src/channel-whatsapp/pii.ts +109 -0
  110. package/packages/bundled-features/src/channel-whatsapp/webhook-normalize.ts +226 -0
  111. package/packages/bundled-features/src/channel-whatsapp/webhook-routes.ts +185 -0
  112. package/packages/bundled-features/src/compliance-profiles/handlers/sub-processors.query.ts +1 -1
  113. package/packages/bundled-features/src/config/changes.json +12 -0
  114. package/packages/bundled-features/src/config/handlers/set.write.ts +7 -0
  115. package/packages/bundled-features/src/config/handlers/values.query.ts +8 -1
  116. package/packages/bundled-features/src/config/index.ts +1 -0
  117. package/packages/bundled-features/src/config/read-redaction.ts +6 -3
  118. package/packages/bundled-features/src/config/table.ts +1 -0
  119. package/packages/bundled-features/src/config/write-helpers.ts +3 -2
  120. package/packages/bundled-features/src/crypto-shredding/changes.json +18 -0
  121. package/packages/bundled-features/src/crypto-shredding/constants.ts +2 -0
  122. package/packages/bundled-features/src/crypto-shredding/handlers/forget-subject.write.ts +38 -18
  123. package/packages/bundled-features/src/crypto-shredding/index.ts +4 -0
  124. package/packages/bundled-features/src/crypto-shredding/subject-forget-after-delete-hook.ts +49 -0
  125. package/packages/bundled-features/src/custom-fields/aggregate-id.ts +0 -1
  126. package/packages/bundled-features/src/custom-fields/entity.ts +1 -0
  127. package/packages/bundled-features/src/custom-fields/wire-for-entity.ts +0 -1
  128. package/packages/bundled-features/src/data-retention/changes.json +18 -0
  129. package/packages/bundled-features/src/data-retention/erase-notes-of-deleted-row.ts +23 -0
  130. package/packages/bundled-features/src/data-retention/feature.ts +4 -7
  131. package/packages/bundled-features/src/data-retention/run-retention-cleanup.ts +38 -18
  132. package/packages/bundled-features/src/data-retention/tenant-destruction-hold.ts +9 -0
  133. package/packages/bundled-features/src/delivery/attempt-log-factory.ts +11 -0
  134. package/packages/bundled-features/src/delivery/attempt-log.ts +3 -3
  135. package/packages/bundled-features/src/delivery/changes.json +6 -0
  136. package/packages/bundled-features/src/delivery/channel-context.ts +6 -3
  137. package/packages/bundled-features/src/delivery/db/queries/preferences.ts +0 -1
  138. package/packages/bundled-features/src/delivery/delivery-service.ts +3 -0
  139. package/packages/bundled-features/src/delivery/feature.ts +4 -13
  140. package/packages/bundled-features/src/delivery/handlers/opted-in-user-ids.query.ts +45 -0
  141. package/packages/bundled-features/src/delivery/handlers/preferences.query.ts +2 -20
  142. package/packages/bundled-features/src/delivery/handlers/resubscribe-user.write.ts +2 -25
  143. package/packages/bundled-features/src/delivery/handlers/unsubscribe-page-chrome.query.ts +2 -0
  144. package/packages/bundled-features/src/delivery/handlers/unsubscribe-user.write.ts +2 -27
  145. package/packages/bundled-features/src/delivery/index.ts +3 -1
  146. package/packages/bundled-features/src/delivery/options.ts +11 -0
  147. package/packages/bundled-features/src/delivery/preference-rows.ts +33 -0
  148. package/packages/bundled-features/src/delivery/set-preference-enabled.ts +40 -0
  149. package/packages/bundled-features/src/delivery/testing.ts +3 -1
  150. package/packages/bundled-features/src/delivery/types.ts +1 -0
  151. package/packages/bundled-features/src/delivery/unsubscribe-page.ts +7 -1
  152. package/packages/bundled-features/src/delivery/upsert-preference.ts +0 -1
  153. package/packages/bundled-features/src/delivery/web/public-names.ts +1 -0
  154. package/packages/bundled-features/src/derivatives-sharp/render.ts +9 -9
  155. package/packages/bundled-features/src/document-ingest-foundation/aggregate-id.ts +0 -1
  156. package/packages/bundled-features/src/document-ingest-foundation/append-missing-extract-event.ts +37 -25
  157. package/packages/bundled-features/src/document-ingest-foundation/report-ingest-progress.ts +32 -14
  158. package/packages/bundled-features/src/documents/aggregate-id.ts +0 -2
  159. package/packages/bundled-features/src/documents/changes.json +18 -0
  160. package/packages/bundled-features/src/documents/constants.ts +10 -2
  161. package/packages/bundled-features/src/documents/ensure-link.ts +3 -4
  162. package/packages/bundled-features/src/documents/feature.ts +28 -6
  163. package/packages/bundled-features/src/documents/handlers/import.write.ts +2 -2
  164. package/packages/bundled-features/src/documents/queries/expiry-overview.query.ts +2 -1
  165. package/packages/bundled-features/src/documents/queries/for-record.query.ts +3 -4
  166. package/packages/bundled-features/src/documents/queries/list-page.ts +11 -3
  167. package/packages/bundled-features/src/documents/queries/overview.query.ts +2 -2
  168. package/packages/bundled-features/src/documents/screens.ts +8 -3
  169. package/packages/bundled-features/src/documents/tab.ts +1 -1
  170. package/packages/bundled-features/src/feature-toggles/toggle-sync-signal.ts +6 -3
  171. package/packages/bundled-features/src/file-derivatives/handlers/public-variant-by-file-ref.query.ts +1 -1
  172. package/packages/bundled-features/src/file-derivatives/handlers/public-variant.query.ts +1 -1
  173. package/packages/bundled-features/src/file-foundation/probe.ts +9 -3
  174. package/packages/bundled-features/src/file-foundation/read-file-ref-content.ts +24 -11
  175. package/packages/bundled-features/src/file-provider-inmemory/feature.ts +1 -1
  176. package/packages/bundled-features/src/file-provider-s3/changes.json +14 -0
  177. package/packages/bundled-features/src/file-provider-s3/env-feature.ts +1 -1
  178. package/packages/bundled-features/src/file-provider-s3/env-named-feature.ts +1 -1
  179. package/packages/bundled-features/src/file-provider-s3/env-schema.ts +24 -7
  180. package/packages/bundled-features/src/file-provider-s3/feature.ts +1 -1
  181. package/packages/bundled-features/src/file-provider-s3/index.ts +7 -1
  182. package/packages/bundled-features/src/file-provider-s3/lib/env-helper.ts +21 -13
  183. package/packages/bundled-features/src/file-provider-s3/lib/s3-provider.ts +8 -1
  184. package/packages/bundled-features/src/files/changes.json +7 -0
  185. package/packages/bundled-features/src/folders/aggregate-id.ts +0 -1
  186. package/packages/bundled-features/src/folders/web/folder-manager.tsx +6 -6
  187. package/packages/bundled-features/src/folders-user-data/index.ts +12 -14
  188. package/packages/bundled-features/src/helpdesk/changes.json +62 -0
  189. package/packages/bundled-features/src/helpdesk/entity.ts +4 -1
  190. package/packages/bundled-features/src/helpdesk/feature.ts +41 -0
  191. package/packages/bundled-features/src/helpdesk/handlers/access.ts +0 -10
  192. package/packages/bundled-features/src/helpdesk/handlers/attempts.ts +7 -14
  193. package/packages/bundled-features/src/helpdesk/handlers/challenge.query.ts +1 -2
  194. package/packages/bundled-features/src/helpdesk/handlers/reply.write.ts +2 -9
  195. package/packages/bundled-features/src/helpdesk/handlers/report.write.ts +2 -9
  196. package/packages/bundled-features/src/helpdesk/handlers/submit.write.ts +3 -11
  197. package/packages/bundled-features/src/helpdesk/index.ts +1 -0
  198. package/packages/bundled-features/src/helpdesk/legacy-contact-config.ts +61 -0
  199. package/packages/bundled-features/src/helpdesk/legacy-contact-erasure.ts +45 -0
  200. package/packages/bundled-features/src/helpdesk/legacy-contact-retention.ts +65 -0
  201. package/packages/bundled-features/src/helpdesk/legacy-contact-streams.ts +185 -0
  202. package/packages/bundled-features/src/helpdesk/legacy-contact-user-data.ts +84 -0
  203. package/packages/bundled-features/src/helpdesk/lib.ts +47 -34
  204. package/packages/bundled-features/src/helpdesk/user-data-hooks.ts +89 -48
  205. package/packages/bundled-features/src/helpdesk/web/constants.ts +0 -1
  206. package/packages/bundled-features/src/inbound-mail-foundation/account-health.ts +1 -1
  207. package/packages/bundled-features/src/inbound-mail-foundation/account-poll.ts +5 -1
  208. package/packages/bundled-features/src/inbound-mail-foundation/aggregate-id.ts +0 -2
  209. package/packages/bundled-features/src/inbound-mail-foundation/changes.json +48 -0
  210. package/packages/bundled-features/src/inbound-mail-foundation/constants.ts +6 -0
  211. package/packages/bundled-features/src/inbound-mail-foundation/content-refetch.ts +15 -1
  212. package/packages/bundled-features/src/inbound-mail-foundation/entities.ts +64 -15
  213. package/packages/bundled-features/src/inbound-mail-foundation/events.ts +15 -16
  214. package/packages/bundled-features/src/inbound-mail-foundation/feature.ts +3 -1
  215. package/packages/bundled-features/src/inbound-mail-foundation/handlers/account-address.ts +16 -2
  216. package/packages/bundled-features/src/inbound-mail-foundation/handlers/attach-message-content.write.ts +10 -3
  217. package/packages/bundled-features/src/inbound-mail-foundation/handlers/connect-account.write.ts +21 -8
  218. package/packages/bundled-features/src/inbound-mail-foundation/handlers/forget-message.write.ts +73 -0
  219. package/packages/bundled-features/src/inbound-mail-foundation/i18n.ts +3 -0
  220. package/packages/bundled-features/src/inbound-mail-foundation/index.ts +1 -0
  221. package/packages/bundled-features/src/inbound-mail-foundation/oauth-access-token.ts +1 -1
  222. package/packages/bundled-features/src/inbound-mail-foundation/outbound-mail.ts +2 -0
  223. package/packages/bundled-features/src/inbound-mail-foundation/personal-address.ts +20 -0
  224. package/packages/bundled-features/src/inbound-mail-foundation/purge-messages.ts +54 -0
  225. package/packages/bundled-features/src/inbound-mail-foundation/quarantine.ts +15 -5
  226. package/packages/bundled-features/src/inbound-mail-foundation/retention-job.ts +1 -5
  227. package/packages/bundled-features/src/inbound-mail-foundation/retention-sweep.ts +21 -34
  228. package/packages/bundled-features/src/inbound-mail-foundation/send-from-account.ts +9 -1
  229. package/packages/bundled-features/src/inbound-mail-foundation/supervisor-ingest.ts +7 -1
  230. package/packages/bundled-features/src/inbound-mail-foundation/sync-account-now.ts +1 -1
  231. package/packages/bundled-features/src/inbound-mail-foundation/tenant-destroy-hook.ts +14 -17
  232. package/packages/bundled-features/src/inbound-mail-foundation/watch-supervisor.ts +1 -1
  233. package/packages/bundled-features/src/inbound-provider-imap/byte-budget.ts +80 -0
  234. package/packages/bundled-features/src/inbound-provider-imap/changes.json +13 -0
  235. package/packages/bundled-features/src/inbound-provider-imap/connect-mailbox.ts +8 -4
  236. package/packages/bundled-features/src/inbound-provider-imap/connect-my-mailbox.ts +23 -6
  237. package/packages/bundled-features/src/inbound-provider-imap/connect-target-rate-limit.ts +46 -0
  238. package/packages/bundled-features/src/inbound-provider-imap/download-batch.ts +47 -10
  239. package/packages/bundled-features/src/inbound-provider-imap/feature.ts +7 -4
  240. package/packages/bundled-features/src/inbound-provider-imap/fetch-content.ts +43 -29
  241. package/packages/bundled-features/src/inbound-provider-imap/i18n.ts +2 -2
  242. package/packages/bundled-features/src/inbound-provider-imap/parse-message.ts +14 -0
  243. package/packages/bundled-features/src/inbound-provider-imap/reconnect-mailbox.ts +5 -4
  244. package/packages/bundled-features/src/inbound-provider-imap/send-mail.ts +39 -7
  245. package/packages/bundled-features/src/inbound-provider-imap/smtp-client.ts +19 -4
  246. package/packages/bundled-features/src/inbound-provider-imap/watch-mailbox.ts +8 -23
  247. package/packages/bundled-features/src/inbound-provider-inmemory/feature.ts +1 -1
  248. package/packages/bundled-features/src/jobs/events.ts +10 -0
  249. package/packages/bundled-features/src/jobs/feature.ts +2 -0
  250. package/packages/bundled-features/src/jobs/handlers/consumer.write.ts +41 -16
  251. package/packages/bundled-features/src/jobs/web/constants.ts +4 -0
  252. package/packages/bundled-features/src/mail-foundation/changes.json +6 -0
  253. package/packages/bundled-features/src/mail-transport-inmemory/feature.ts +1 -1
  254. package/packages/bundled-features/src/mail-transport-smtp/feature.ts +3 -2
  255. package/packages/bundled-features/src/managed-pages/changes.json +12 -0
  256. package/packages/bundled-features/src/managed-pages/handlers/branding.query.ts +1 -1
  257. package/packages/bundled-features/src/managed-pages/handlers/by-slug.query.ts +1 -1
  258. package/packages/bundled-features/src/managed-pages/handlers/by-tenant-published.query.ts +1 -1
  259. package/packages/bundled-features/src/managed-pages/render-page-body.ts +18 -10
  260. package/packages/bundled-features/src/managed-pages/screens/page-screens.ts +18 -38
  261. package/packages/bundled-features/src/managed-pages/table.ts +1 -0
  262. package/packages/bundled-features/src/managed-pages/web/client-plugin.tsx +8 -6
  263. package/packages/bundled-features/src/managed-pages/web/constants.ts +8 -1
  264. package/packages/bundled-features/src/managed-pages/web/i18n.ts +11 -3
  265. package/packages/bundled-features/src/managed-pages/web/markdown-to-document.ts +1 -1
  266. package/packages/bundled-features/src/managed-pages/web/page-edit-draft.ts +108 -0
  267. package/packages/bundled-features/src/managed-pages/web/page-edit-screen.tsx +198 -0
  268. package/packages/bundled-features/src/managed-pages/web/page-settings-rail.tsx +117 -0
  269. package/packages/bundled-features/src/notes-history-user-data/index.ts +8 -14
  270. package/packages/bundled-features/src/personal-access-tokens/boot-rules.ts +5 -0
  271. package/packages/bundled-features/src/personal-access-tokens/handlers/create.write.ts +0 -1
  272. package/packages/bundled-features/src/personal-access-tokens/scope-events-check.ts +31 -5
  273. package/packages/bundled-features/src/presence/changes.json +6 -0
  274. package/packages/bundled-features/src/presence/handlers/list.query.ts +28 -11
  275. package/packages/bundled-features/src/presence/room.ts +21 -7
  276. package/packages/bundled-features/src/presence/store.ts +79 -21
  277. package/packages/bundled-features/src/readiness/changes.json +25 -0
  278. package/packages/bundled-features/src/readiness/handlers/latest-summary.query.ts +11 -6
  279. package/packages/bundled-features/src/readiness/handlers/run-probes.write.ts +35 -5
  280. package/packages/bundled-features/src/readiness/handlers/run-tone.ts +3 -2
  281. package/packages/bundled-features/src/readiness/handlers/status.query.ts +15 -1
  282. package/packages/bundled-features/src/readiness/probe-context.ts +11 -10
  283. package/packages/bundled-features/src/readiness/screens.ts +4 -4
  284. package/packages/bundled-features/src/readiness/visible-results.ts +5 -3
  285. package/packages/bundled-features/src/renderer-foundation/api.ts +6 -13
  286. package/packages/bundled-features/src/renderer-foundation/types.ts +2 -2
  287. package/packages/bundled-features/src/secrets/changes.json +7 -0
  288. package/packages/bundled-features/src/secrets/db/queries/read.ts +18 -4
  289. package/packages/bundled-features/src/secrets/handlers/list.query.ts +8 -2
  290. package/packages/bundled-features/src/secrets/secret-scope.ts +2 -3
  291. package/packages/bundled-features/src/secrets/secrets-context.ts +6 -4
  292. package/packages/bundled-features/src/secrets/write-gate.ts +4 -2
  293. package/packages/bundled-features/src/seo/handlers/seo-config.query.ts +1 -1
  294. package/packages/bundled-features/src/shared/acknowledged-system-db.ts +20 -0
  295. package/packages/bundled-features/src/shared/assert-billing-live.ts +9 -2
  296. package/packages/bundled-features/src/shared/changes.json +6 -0
  297. package/packages/bundled-features/src/shared/index.ts +6 -1
  298. package/packages/bundled-features/src/shared/parent-visibility.ts +25 -1
  299. package/packages/bundled-features/src/shared/password-hashing.ts +0 -1
  300. package/packages/bundled-features/src/shared/price-env-shape.ts +1 -4
  301. package/packages/bundled-features/src/shared/register-user-data-hooks.ts +29 -0
  302. package/packages/bundled-features/src/shared/require-bootstrap-extension.ts +26 -0
  303. package/packages/bundled-features/src/shared/send-best-effort.ts +19 -0
  304. package/packages/bundled-features/src/shared/stream-tenant-backfill.ts +22 -1
  305. package/packages/bundled-features/src/shared/stream-tenant-derived-state.ts +31 -1
  306. package/packages/bundled-features/src/step-dispatcher/changes.json +12 -0
  307. package/packages/bundled-features/src/step-dispatcher/constants.ts +13 -0
  308. package/packages/bundled-features/src/step-dispatcher/deliver-dispatch-request.ts +47 -2
  309. package/packages/bundled-features/src/step-dispatcher/feature.ts +28 -1
  310. package/packages/bundled-features/src/step-dispatcher/mail-runner.ts +0 -1
  311. package/packages/bundled-features/src/step-dispatcher/sweep-abandoned.ts +57 -0
  312. package/packages/bundled-features/src/subscription-mollie/changes.json +7 -0
  313. package/packages/bundled-features/src/subscription-mollie/plugin-methods.ts +5 -3
  314. package/packages/bundled-features/src/subscription-mollie/verify-webhook.ts +5 -5
  315. package/packages/bundled-features/src/subscription-paddle/backfill-checkout-ledger.ts +159 -0
  316. package/packages/bundled-features/src/subscription-paddle/changes.json +13 -0
  317. package/packages/bundled-features/src/subscription-paddle/checkout-config.query.ts +1 -1
  318. package/packages/bundled-features/src/subscription-paddle/checkout-methods.ts +2 -8
  319. package/packages/bundled-features/src/subscription-paddle/constants.ts +1 -2
  320. package/packages/bundled-features/src/subscription-paddle/feature.ts +26 -24
  321. package/packages/bundled-features/src/subscription-paddle/ledger-backfill-marker.ts +70 -0
  322. package/packages/bundled-features/src/subscription-paddle/plan-switch-methods.ts +2 -8
  323. package/packages/bundled-features/src/subscription-paddle/redeliver-legacy-checkout.ts +36 -0
  324. package/packages/bundled-features/src/subscription-paddle/runtime.ts +13 -24
  325. package/packages/bundled-features/src/subscription-paddle/subscription-state.ts +1 -0
  326. package/packages/bundled-features/src/subscription-paddle/webhook-events.ts +68 -21
  327. package/packages/bundled-features/src/subscription-stripe/changes.json +7 -0
  328. package/packages/bundled-features/src/subscription-stripe/feature.ts +5 -0
  329. package/packages/bundled-features/src/subscription-stripe/plugin-methods.ts +6 -6
  330. package/packages/bundled-features/src/subscription-stripe/runtime.ts +8 -7
  331. package/packages/bundled-features/src/subscription-stripe/verify-webhook.ts +24 -6
  332. package/packages/bundled-features/src/tags/aggregate-id.ts +0 -1
  333. package/packages/bundled-features/src/tags/web/tag-chip.tsx +4 -5
  334. package/packages/bundled-features/src/tags/web/tag-manager.tsx +2 -1
  335. package/packages/bundled-features/src/template-resolver/api.ts +6 -13
  336. package/packages/bundled-features/src/template-resolver/changes.json +36 -0
  337. package/packages/bundled-features/src/template-resolver/document-sanitizer.ts +25 -0
  338. package/packages/bundled-features/src/template-resolver/feature.ts +2 -0
  339. package/packages/bundled-features/src/template-resolver/handlers/body-preview.query.ts +41 -0
  340. package/packages/bundled-features/src/template-resolver/handlers/by-slug.query.ts +1 -1
  341. package/packages/bundled-features/src/template-resolver/handlers/by-tenant.query.ts +1 -1
  342. package/packages/bundled-features/src/template-resolver/handlers/collection-shared.ts +5 -11
  343. package/packages/bundled-features/src/template-resolver/handlers/overview.query.ts +3 -2
  344. package/packages/bundled-features/src/template-resolver/handlers/send-test.write.ts +37 -8
  345. package/packages/bundled-features/src/template-resolver/linked-resources.ts +2 -5
  346. package/packages/bundled-features/src/template-resolver/seeding.ts +77 -0
  347. package/packages/bundled-features/src/template-resolver/table.ts +1 -0
  348. package/packages/bundled-features/src/template-resolver/template-draft.ts +2 -1
  349. package/packages/bundled-features/src/template-resolver/template-preview.ts +14 -3
  350. package/packages/bundled-features/src/template-resolver/testing.ts +0 -2
  351. package/packages/bundled-features/src/template-resolver/web/client-plugin.tsx +3 -0
  352. package/packages/bundled-features/src/template-resolver/web/collection-entry-create-form.tsx +33 -33
  353. package/packages/bundled-features/src/template-resolver/web/constants.ts +7 -0
  354. package/packages/bundled-features/src/template-resolver/web/content-tree-provider.ts +0 -1
  355. package/packages/bundled-features/src/template-resolver/web/content-workbench.tsx +142 -0
  356. package/packages/bundled-features/src/template-resolver/web/document-insert-model.ts +3 -8
  357. package/packages/bundled-features/src/template-resolver/web/document-link-policy.ts +58 -0
  358. package/packages/bundled-features/src/template-resolver/web/document-schema.ts +11 -57
  359. package/packages/bundled-features/src/template-resolver/web/document-tiptap-bubble.tsx +2 -4
  360. package/packages/bundled-features/src/template-resolver/web/document-tiptap-context.ts +4 -5
  361. package/packages/bundled-features/src/template-resolver/web/document-tiptap-editor.tsx +2 -2
  362. package/packages/bundled-features/src/template-resolver/web/document-tiptap-helpers.ts +6 -3
  363. package/packages/bundled-features/src/template-resolver/web/document-tiptap-toolbar-groups.tsx +2 -3
  364. package/packages/bundled-features/src/template-resolver/web/editor-handle.ts +1 -0
  365. package/packages/bundled-features/src/template-resolver/web/fill-document-variables.ts +24 -0
  366. package/packages/bundled-features/src/template-resolver/web/i18n.ts +14 -0
  367. package/packages/bundled-features/src/template-resolver/web/index.ts +3 -0
  368. package/packages/bundled-features/src/template-resolver/web/preview-targets.ts +25 -0
  369. package/packages/bundled-features/src/template-resolver/web/qualified-names.ts +1 -0
  370. package/packages/bundled-features/src/template-resolver/web/snippet-preview-renderer.tsx +24 -0
  371. package/packages/bundled-features/src/template-resolver/web/string-values.ts +7 -0
  372. package/packages/bundled-features/src/template-resolver/web/text-block-editor.tsx +38 -50
  373. package/packages/bundled-features/src/template-resolver/web/use-collection-entry-create.ts +7 -0
  374. package/packages/bundled-features/src/template-resolver/web/use-content-write.ts +1 -3
  375. package/packages/bundled-features/src/template-resolver/web/use-document-tiptap-model.ts +1 -2
  376. package/packages/bundled-features/src/template-resolver/web/use-text-block-editor.ts +28 -7
  377. package/packages/bundled-features/src/template-resolver/web/web-preview-renderer.tsx +126 -0
  378. package/packages/bundled-features/src/template-resolver-user-data/index.ts +11 -10
  379. package/packages/bundled-features/src/tenant/changes.json +6 -0
  380. package/packages/bundled-features/src/tenant/handlers/create.write.ts +7 -8
  381. package/packages/bundled-features/src/tenant/handlers/list.query.ts +7 -9
  382. package/packages/bundled-features/src/tenant/handlers/member-directory.query.ts +10 -4
  383. package/packages/bundled-features/src/tenant/handlers/toggle-enabled.write.ts +1 -1
  384. package/packages/bundled-features/src/tenant/invited-membership.ts +10 -1
  385. package/packages/bundled-features/src/tenant/seeding.ts +4 -2
  386. package/packages/bundled-features/src/tenant/stream-tenant-backfill.ts +5 -1
  387. package/packages/bundled-features/src/tenant/testing.ts +1 -1
  388. package/packages/bundled-features/src/tenant-inactivity/check-inactive-tenants.ts +4 -3
  389. package/packages/bundled-features/src/tenant-inactivity/constants.ts +1 -2
  390. package/packages/bundled-features/src/tenant-inactivity/handlers/keep-account.write.ts +1 -2
  391. package/packages/bundled-features/src/tenant-inactivity/state-store.ts +10 -1
  392. package/packages/bundled-features/src/tenant-lifecycle/changes.json +18 -0
  393. package/packages/bundled-features/src/tenant-lifecycle/constants.ts +4 -0
  394. package/packages/bundled-features/src/tenant-lifecycle/run-tenant-destroy.ts +43 -6
  395. package/packages/bundled-features/src/tenant-lifecycle/stages.ts +15 -2
  396. package/packages/bundled-features/src/tier-engine/aggregate-id.ts +0 -1
  397. package/packages/bundled-features/src/tier-engine/changes.json +6 -0
  398. package/packages/bundled-features/src/tier-engine/feature.ts +8 -2
  399. package/packages/bundled-features/src/user/changes.json +6 -0
  400. package/packages/bundled-features/src/user/db/queries/stream-tenant-backfill.ts +2 -1
  401. package/packages/bundled-features/src/user/handlers/me.query.ts +3 -1
  402. package/packages/bundled-features/src/user/index.ts +1 -0
  403. package/packages/bundled-features/src/user/resolve-verified-user-email.ts +17 -0
  404. package/packages/bundled-features/src/user-data-rights/db/queries/export-jobs.ts +0 -1
  405. package/packages/bundled-features/src/user-data-rights/handlers/confirm-deletion-by-token.write.ts +1 -1
  406. package/packages/bundled-features/src/user-data-rights/handlers/download-by-token.query.ts +1 -1
  407. package/packages/bundled-features/src/user-data-rights/handlers/request-deletion-by-email.write.ts +1 -1
  408. package/packages/bundled-features/src/user-data-rights/run-export-jobs.ts +0 -2
  409. package/packages/bundled-features/src/user-data-rights/run-forget-cleanup.ts +3 -3
  410. package/packages/bundled-features/src/user-data-rights/schema/download-attempt.ts +3 -2
  411. package/packages/bundled-features/src/user-data-rights/web/confirm-deletion-screen.tsx +1 -1
  412. package/packages/bundled-features/src/user-data-rights/web/privacy-center-screen.tsx +1 -1
  413. package/packages/bundled-features/src/user-data-rights/web/request-deletion-screen.tsx +1 -1
  414. package/packages/bundled-features/src/user-data-rights-defaults/hooks/api-token.userdata-hook.ts +5 -5
  415. package/packages/bundled-features/src/user-data-rights-defaults/hooks/hard-delete-own-rows-hook.ts +17 -0
  416. package/packages/bundled-features/src/user-data-rights-defaults/hooks/in-app-message.userdata-hook.ts +5 -5
  417. package/packages/bundled-features/src/user-data-rights-defaults/hooks/job-run.userdata-hook.ts +2 -1
  418. package/packages/bundled-features/src/user-data-rights-defaults/hooks/user-session.userdata-hook.ts +5 -5
  419. package/packages/bundled-features/src/user-profile/handlers/change-email.write.ts +0 -1
  420. package/packages/bundled-features/src/waitlist/changes.json +6 -0
  421. package/packages/bundled-features/src/waitlist/handlers/submit.write.ts +4 -28
  422. package/packages/bundled-features/src/waitlist/lib.ts +2 -7
  423. package/packages/bundled-features/src/waitlist/user-data-hooks.ts +6 -19
  424. package/packages/bundled-features/src/workflow-runner/aggregate-id.ts +0 -1
  425. package/packages/bundled-features/src/workflow-runner/event-trigger.ts +6 -2
  426. package/packages/bundled-features/src/workflow-runner/feature.ts +1 -5
  427. package/packages/bundled-features/src/workflow-runner/handlers/resume-run.write.ts +5 -4
  428. package/packages/bundled-features/src/workflow-runner/runner.ts +2 -0
  429. package/samples/apps/showcase/src/features/demos/web/pages/dialog.tsx +0 -1
  430. package/samples/apps/showcase/src/features/demos/web/pages/layout.tsx +1 -1
  431. package/samples/apps/showcase/src/features/demos/web/pages/sidebar-panel.tsx +0 -1
  432. package/samples/apps/styleguide/src/features/gallery/web/Gallery.tsx +1 -4
  433. package/samples/apps/ui-walkthrough/src/features/subscription-plans/feature.ts +6 -2
  434. package/samples/apps/use-all-bundled/e2e-billing-gallery/gallery-features.ts +12 -14
  435. package/samples/apps/use-all-bundled/feature-manifest.json +60 -29
  436. package/samples/apps/use-all-bundled/playwright.billing-docs.config.ts +1 -1
  437. package/samples/apps/use-all-bundled/playwright.config.ts +1 -0
  438. package/samples/apps/use-all-bundled/src/app/seed.ts +1 -1
  439. package/samples/apps/use-all-bundled/src/run-config.ts +2 -1
  440. package/samples/recipes/auth-mfa/src/web/confirmation-code-step.tsx +32 -10
  441. package/samples/recipes/chat-channels/README.md +2 -0
  442. package/samples/recipes/currencies-global/src/entities/currency.ts +1 -0
  443. package/samples/recipes/helpdesk/README.md +9 -5
  444. package/samples/recipes/helpdesk/src/feature.ts +6 -3
  445. package/samples/recipes/managed-pages/README.md +5 -1
  446. package/samples/recipes/managed-pages/package.json +3 -2
  447. package/samples/recipes/managed-pages/src/web/branded-preview.tsx +21 -0
  448. package/samples/recipes/managed-pages/tsconfig.json +8 -0
  449. package/samples/recipes/pwa-shell/README.md +52 -0
  450. package/samples/recipes/pwa-shell/bin/server.ts +12 -0
  451. package/samples/recipes/pwa-shell/package.json +13 -0
  452. package/samples/recipes/pwa-shell/src/app.ts +34 -0
  453. package/samples/recipes/rate-limiting/README.md +3 -3
  454. package/samples/recipes/record-detail-layout/README.md +33 -0
  455. package/samples/recipes/record-detail-layout/src/feature.ts +525 -44
  456. package/samples/recipes/record-detail-layout/src/order-board.ts +521 -0
  457. package/packages/bundled-features/src/managed-pages/web/page-body-section.tsx +0 -72
  458. package/packages/bundled-features/src/subscription-paddle/tenant-binding.ts +0 -34
  459. package/packages/bundled-features/src/template-resolver/web/content-field.tsx +0 -61
@@ -0,0 +1,185 @@
1
+ import {
2
+ collectPiiEncryptedFields,
3
+ configuredPiiSubjectKms,
4
+ decryptPiiFieldValues,
5
+ isPiiCiphertext,
6
+ PII_ERASED_SENTINEL,
7
+ } from "@cosmicdrift/kumiko-framework/crypto";
8
+ import type { TenantDb } from "@cosmicdrift/kumiko-framework/db";
9
+ import { SYSTEM_TENANT_ID } from "@cosmicdrift/kumiko-framework/engine";
10
+ import {
11
+ archiveStream,
12
+ isStreamArchived,
13
+ streamAllEventsByType,
14
+ } from "@cosmicdrift/kumiko-framework/event-store";
15
+ import {
16
+ systemTenantReadRunner,
17
+ systemTenantWriteRunner,
18
+ } from "@cosmicdrift/kumiko-framework/internal/row-level-security";
19
+ import { helpdeskReplyEntity, helpdeskRequestEntity } from "./entity.ts";
20
+
21
+ // Data stored before the contact -> helpdesk rename stays under the old aggregate names. The old
22
+ // read tables are dropped in the apps, so the streams are folded straight from the event log.
23
+ export const LEGACY_CONTACT_REQUEST_ENTITY = "contact-request";
24
+ export const LEGACY_CONTACT_REPLY_ENTITY = "contact-reply";
25
+
26
+ const PII_DECRYPT_REASON = "helpdesk:legacy-contact-streams";
27
+ const ARCHIVED_BY = "helpdesk:legacy-contact";
28
+ const ARCHIVE_WRITE_REASON =
29
+ "archives the legacy contact streams of an erased subject in the system tenant";
30
+ export const LEGACY_ARCHIVE_REASON = "legacy contact data erased";
31
+
32
+ export type LegacyAggregate = {
33
+ readonly id: string;
34
+ // Plaintext after decryption; a field whose subject key is shredded holds PII_ERASED_SENTINEL.
35
+ readonly fields: Readonly<Record<string, unknown>>;
36
+ // True when a personal field could not be read, so the content is gone for good.
37
+ readonly erased: boolean;
38
+ };
39
+
40
+ const PII_FIELDS_BY_TYPE: Readonly<Record<string, readonly string[]>> = {
41
+ [LEGACY_CONTACT_REQUEST_ENTITY]: collectPiiEncryptedFields(helpdeskRequestEntity),
42
+ [LEGACY_CONTACT_REPLY_ENTITY]: collectPiiEncryptedFields(helpdeskReplyEntity),
43
+ };
44
+
45
+ function isRecord(value: unknown): value is Record<string, unknown> {
46
+ return typeof value === "object" && value !== null && !Array.isArray(value);
47
+ }
48
+
49
+ async function readableFields(
50
+ aggregateType: string,
51
+ fields: Record<string, unknown>,
52
+ onlyFields?: readonly string[],
53
+ ): Promise<LegacyAggregate["fields"]> {
54
+ const piiFields = PII_FIELDS_BY_TYPE[aggregateType] ?? [];
55
+ const kms = configuredPiiSubjectKms();
56
+ if (kms === undefined) return fields;
57
+ return decryptPiiFieldValues(
58
+ fields,
59
+ onlyFields ? piiFields.filter((name) => onlyFields.includes(name)) : piiFields,
60
+ kms,
61
+ { requestId: PII_DECRYPT_REASON },
62
+ );
63
+ }
64
+
65
+ function hasUnreadablePersonalField(aggregateType: string, fields: LegacyAggregate["fields"]) {
66
+ return (PII_FIELDS_BY_TYPE[aggregateType] ?? []).some((name) => {
67
+ const value = fields[name];
68
+ return value === PII_ERASED_SENTINEL || isPiiCiphertext(value);
69
+ });
70
+ }
71
+
72
+ type RawFields = Record<string, unknown>;
73
+
74
+ // Folds created and updated events per aggregate; a deleted or forgotten stream is gone for good.
75
+ async function foldLegacyStreams(
76
+ runner: ReturnType<typeof systemTenantReadRunner>,
77
+ aggregateType: string,
78
+ ): Promise<Map<string, RawFields>> {
79
+ const folded = new Map<string, RawFields>();
80
+ const gone = new Set<string>();
81
+ for await (const event of streamAllEventsByType(runner, aggregateType)) {
82
+ const id = event.aggregateId;
83
+ if (gone.has(id)) continue;
84
+ switch (event.type) {
85
+ case `${aggregateType}.created`:
86
+ folded.set(id, { ...event.payload });
87
+ break;
88
+ case `${aggregateType}.updated`: {
89
+ const current = folded.get(id);
90
+ const changes = event.payload["changes"];
91
+ if (current && isRecord(changes)) Object.assign(current, changes);
92
+ break;
93
+ }
94
+ case `${aggregateType}.deleted`:
95
+ case `${aggregateType}.forgotten`:
96
+ folded.delete(id);
97
+ gone.add(id);
98
+ break;
99
+ }
100
+ }
101
+ return folded;
102
+ }
103
+
104
+ export type LegacyReadOptions = {
105
+ // Retention compares plaintext timestamps only, so it skips the KMS round trips.
106
+ readonly decrypt?: boolean;
107
+ // Narrows by plaintext fields before any archive lookup or decryption.
108
+ readonly isCandidate?: (raw: Readonly<Record<string, unknown>>) => boolean;
109
+ };
110
+
111
+ // Archived streams are skipped, so an erased aggregate is never read again. The archive lookup
112
+ // is per aggregate (the framework has no bulk query for it), after the candidate filter.
113
+ export async function readLegacyAggregates(
114
+ db: TenantDb,
115
+ aggregateType: string,
116
+ options: LegacyReadOptions = {},
117
+ ): Promise<readonly LegacyAggregate[]> {
118
+ const runner = systemTenantReadRunner(db);
119
+ const aggregates: LegacyAggregate[] = [];
120
+ for (const [id, raw] of await foldLegacyStreams(runner, aggregateType)) {
121
+ if (options.isCandidate && !options.isCandidate(raw)) continue;
122
+ if (await isStreamArchived(runner, SYSTEM_TENANT_ID, id)) continue;
123
+ if (options.decrypt === false) {
124
+ aggregates.push({ id, fields: raw, erased: false });
125
+ continue;
126
+ }
127
+ const fields = await readableFields(aggregateType, raw);
128
+ aggregates.push({ id, fields, erased: hasUnreadablePersonalField(aggregateType, fields) });
129
+ }
130
+ return aggregates;
131
+ }
132
+
133
+ // A signed-in request carries the plaintext user id; an anonymous one is matched by the email,
134
+ // which is the only field decrypted for the rest. Only the matches are fully decrypted.
135
+ export async function findLegacyRequestsOfSubject(
136
+ db: TenantDb,
137
+ subject: { readonly userId: string; readonly email: string | undefined },
138
+ ): Promise<readonly LegacyAggregate[]> {
139
+ const runner = systemTenantReadRunner(db);
140
+ const matches: LegacyAggregate[] = [];
141
+ for (const [id, raw] of await foldLegacyStreams(runner, LEGACY_CONTACT_REQUEST_ENTITY)) {
142
+ if (!(await isSubjectRequest(raw, subject))) continue;
143
+ if (await isStreamArchived(runner, SYSTEM_TENANT_ID, id)) continue;
144
+ const fields = await readableFields(LEGACY_CONTACT_REQUEST_ENTITY, raw);
145
+ matches.push({
146
+ id,
147
+ fields,
148
+ erased: hasUnreadablePersonalField(LEGACY_CONTACT_REQUEST_ENTITY, fields),
149
+ });
150
+ }
151
+ return matches;
152
+ }
153
+
154
+ async function isSubjectRequest(
155
+ raw: RawFields,
156
+ subject: { readonly userId: string; readonly email: string | undefined },
157
+ ): Promise<boolean> {
158
+ if (raw["reporterUserId"] === subject.userId) return true;
159
+ if (subject.email === undefined) return false;
160
+ const { email } = await readableFields(LEGACY_CONTACT_REQUEST_ENTITY, { email: raw["email"] }, [
161
+ "email",
162
+ ]);
163
+ return typeof email === "string" && email.toLowerCase() === subject.email;
164
+ }
165
+
166
+ export async function archiveLegacyStream(
167
+ db: TenantDb,
168
+ aggregateType: string,
169
+ aggregateId: string,
170
+ ): Promise<void> {
171
+ await archiveStream(systemTenantWriteRunner(db, ARCHIVE_WRITE_REASON), {
172
+ tenantId: SYSTEM_TENANT_ID,
173
+ aggregateId,
174
+ aggregateType,
175
+ archivedBy: ARCHIVED_BY,
176
+ reason: LEGACY_ARCHIVE_REASON,
177
+ });
178
+ }
179
+
180
+ export function repliesOf(
181
+ replies: readonly LegacyAggregate[],
182
+ requestId: string,
183
+ ): readonly LegacyAggregate[] {
184
+ return replies.filter((reply) => reply.fields["requestId"] === requestId);
185
+ }
@@ -0,0 +1,84 @@
1
+ import type {
2
+ UserDataDeleteHook,
3
+ UserDataExportHook,
4
+ UserDataHookCtx,
5
+ } from "@cosmicdrift/kumiko-framework/engine";
6
+ import { resolveVerifiedUserEmail } from "../user/index.ts";
7
+ import { eraseLegacyRequest } from "./legacy-contact-erasure.ts";
8
+ import {
9
+ findLegacyRequestsOfSubject,
10
+ LEGACY_CONTACT_REPLY_ENTITY,
11
+ LEGACY_CONTACT_REQUEST_ENTITY,
12
+ type LegacyAggregate,
13
+ readLegacyAggregates,
14
+ repliesOf,
15
+ } from "./legacy-contact-streams.ts";
16
+ import { findAttachments, purgeAttachments } from "./user-data-hooks.ts";
17
+
18
+ export { LEGACY_CONTACT_REPLY_ENTITY, LEGACY_CONTACT_REQUEST_ENTITY };
19
+
20
+ const PII_DECRYPT_REASON = "helpdesk:legacy-contact-user-data";
21
+
22
+ async function findLegacyRequests(ctx: UserDataHookCtx): Promise<readonly LegacyAggregate[]> {
23
+ const email = (await resolveVerifiedUserEmail(ctx, PII_DECRYPT_REASON))?.toLowerCase();
24
+ return findLegacyRequestsOfSubject(ctx.db, { userId: ctx.userId, email });
25
+ }
26
+
27
+ // Replies are linked by the plaintext request id, so only those of the matched requests are read.
28
+ function repliesOfRequests(ctx: UserDataHookCtx, requests: readonly LegacyAggregate[]) {
29
+ const requestIds = new Set(requests.map((request) => request.id));
30
+ return readLegacyAggregates(ctx.db, LEGACY_CONTACT_REPLY_ENTITY, {
31
+ isCandidate: (raw) => typeof raw["requestId"] === "string" && requestIds.has(raw["requestId"]),
32
+ });
33
+ }
34
+
35
+ export const legacyContactExportHook: UserDataExportHook = async (ctx) => {
36
+ const requests = (await findLegacyRequests(ctx)).filter((request) => !request.erased);
37
+ if (requests.length === 0) return null;
38
+ const replies = await repliesOfRequests(ctx, requests);
39
+ const rows = [];
40
+ for (const request of requests) {
41
+ const { fields } = request;
42
+ rows.push({
43
+ kind: fields["kind"],
44
+ status: fields["status"],
45
+ source: fields["source"],
46
+ subject: fields["subject"],
47
+ message: fields["message"],
48
+ name: fields["name"],
49
+ email: fields["email"],
50
+ phone: fields["phone"],
51
+ page: fields["page"],
52
+ submittedAt: String(fields["submittedAt"]),
53
+ attachments: (await findAttachments(ctx, LEGACY_CONTACT_REQUEST_ENTITY, request.id)).map(
54
+ (file) => file.fileName,
55
+ ),
56
+ replies: repliesOf(replies, request.id)
57
+ .filter((reply) => !reply.erased)
58
+ .map((reply) => ({
59
+ message: reply.fields["message"],
60
+ authorName: reply.fields["authorName"],
61
+ sentAt: String(reply.fields["sentAt"]),
62
+ })),
63
+ });
64
+ }
65
+ return { entity: LEGACY_CONTACT_REQUEST_ENTITY, rows };
66
+ };
67
+
68
+ export const legacyContactDeleteHook: UserDataDeleteHook = async (ctx) => {
69
+ const requests = await findLegacyRequests(ctx);
70
+ // skip: user has no pre-rename contact data to erase
71
+ if (requests.length === 0) return;
72
+ const replies = await repliesOfRequests(ctx, requests);
73
+ for (const request of requests) {
74
+ await eraseLegacyRequest(
75
+ {
76
+ db: ctx.db,
77
+ erasedBy: ctx.userId,
78
+ purgeAttachments: (entity, id) => purgeAttachments(ctx, entity, id),
79
+ },
80
+ request,
81
+ repliesOf(replies, request.id),
82
+ );
83
+ }
84
+ };
@@ -1,3 +1,4 @@
1
+ import { ROLES } from "@cosmicdrift/kumiko-framework/auth";
1
2
  import {
2
3
  createEventStoreExecutor,
3
4
  fetchOne,
@@ -12,9 +13,12 @@ import {
12
13
  type SessionUser,
13
14
  SYSTEM_TENANT_ID,
14
15
  } from "@cosmicdrift/kumiko-framework/engine";
15
- import { InternalError } from "@cosmicdrift/kumiko-framework/errors";
16
16
  import { propertyOf } from "@cosmicdrift/kumiko-types/type-guards";
17
- import { decryptStoredPii } from "../shared/index.ts";
17
+ import {
18
+ acknowledgedSystemDb,
19
+ decryptStoredPii,
20
+ sendBestEffort as sendSharedBestEffort,
21
+ } from "../shared/index.ts";
18
22
  import { tenantTable } from "../tenant/index.ts";
19
23
  import { TierEngineQueries } from "../tier-engine/index.ts";
20
24
  import { USER_STATUS, userTable } from "../user/index.ts";
@@ -29,6 +33,7 @@ import {
29
33
  HELPDESK_REPLY_ENTITY,
30
34
  HELPDESK_REQUEST_ENTITY,
31
35
  HelpdeskErrors,
36
+ HelpdeskHandlers,
32
37
  type HelpdeskPhoneMode,
33
38
  type HelpdeskReplyChannels,
34
39
  } from "./web/constants.ts";
@@ -38,7 +43,6 @@ export const TELEGRAM_FEATURE = "channel-telegram";
38
43
 
39
44
  export const HELPDESK_CROSS_TENANT_REASON = "helpdesk is platform-wide (systemScope)";
40
45
 
41
- export const SYSTEM_ADMIN_ROLE = "SystemAdmin";
42
46
  const PII_DECRYPT_REASON = "helpdesk:user-lookup";
43
47
 
44
48
  export const adminAccess = { roles: access.systemAdmin } as const;
@@ -56,20 +60,33 @@ export const replyExecutor = createEventStoreExecutor(helpdeskReplyTable, helpde
56
60
  entityName: HELPDESK_REPLY_ENTITY,
57
61
  });
58
62
 
59
- const MAX_REPLIES_PER_REQUEST = 200;
60
-
61
- export async function listRepliesOf(db: TenantDb, requestId: string) {
62
- const found = await replyExecutor.list(
63
- {
64
- filter: { field: "requestId", op: "eq", value: requestId },
65
- sort: "sentAt",
66
- sortDirection: "asc",
67
- limit: MAX_REPLIES_PER_REQUEST,
68
- },
69
- platformActor(),
70
- db,
63
+ // Equals the executor's MAX_LIST_LIMIT, so every page is filled until the last one.
64
+ const LIST_PAGE_SIZE = 200;
65
+
66
+ export async function listAllPages<Row>(
67
+ fetchPage: (page: { limit: number; offset: number }) => Promise<{ rows: readonly Row[] }>,
68
+ ): Promise<Row[]> {
69
+ const all: Row[] = [];
70
+ for (;;) {
71
+ const { rows } = await fetchPage({ limit: LIST_PAGE_SIZE, offset: all.length });
72
+ all.push(...rows);
73
+ if (rows.length < LIST_PAGE_SIZE) return all;
74
+ }
75
+ }
76
+
77
+ export function listRepliesOf(db: TenantDb, requestId: string) {
78
+ return listAllPages((page) =>
79
+ replyExecutor.list(
80
+ {
81
+ filter: { field: "requestId", op: "eq", value: requestId },
82
+ sort: "sentAt",
83
+ sortDirection: "asc",
84
+ ...page,
85
+ },
86
+ platformActor(),
87
+ db,
88
+ ),
71
89
  );
72
- return found.rows;
73
90
  }
74
91
 
75
92
  export function normalizeEmail(email: string): string {
@@ -77,12 +94,7 @@ export function normalizeEmail(email: string): string {
77
94
  }
78
95
 
79
96
  export function helpdeskDb(ctx: Pick<AppContext, "systemDb">): TenantDb {
80
- if (!ctx.systemDb) {
81
- throw new InternalError({
82
- message: "helpdesk requires ctx.systemDb — is r.systemScope() set on the feature?",
83
- });
84
- }
85
- return ctx.systemDb.acknowledgeCrossTenant(HELPDESK_CROSS_TENANT_REASON);
97
+ return acknowledgedSystemDb(ctx, "helpdesk", HELPDESK_CROSS_TENANT_REASON);
86
98
  }
87
99
 
88
100
  // Requests and replies are systemStream rows, so every write targets the system tenant's stream.
@@ -94,7 +106,7 @@ export async function listSystemAdminIds(db: TenantDb): Promise<readonly string[
94
106
  const rows = await selectMany<{ readonly id: string }>(
95
107
  db,
96
108
  userTable,
97
- { isDeleted: false, status: USER_STATUS.Active, roles: SYSTEM_ADMIN_ROLE },
109
+ { isDeleted: false, status: USER_STATUS.Active, roles: ROLES.SystemAdmin },
98
110
  { fields: ["id"], orderBy: { col: "id" } },
99
111
  );
100
112
  return rows.map((r) => r.id);
@@ -117,16 +129,17 @@ export async function sendBestEffort(
117
129
  label: string,
118
130
  send: (notify: NonNullable<HandlerContext["notify"]>) => Promise<unknown>,
119
131
  ): Promise<void> {
120
- try {
121
- if (!ctx.notify) {
122
- throw new InternalError({ message: "ctx.notify unavailable — mount the delivery feature" });
123
- }
124
- await send(ctx.notify);
125
- } catch (err) {
126
- ctx.obs.log?.warn(`[helpdesk] ${label} failed`, {
127
- error: err instanceof Error ? err.message : String(err),
128
- });
129
- }
132
+ return sendSharedBestEffort(ctx, `[helpdesk] ${label} failed`, send);
133
+ }
134
+
135
+ export async function forwardHelpdeskRequest(
136
+ ctx: Pick<HandlerContext, "dispatch">,
137
+ requestId: string,
138
+ ): Promise<void> {
139
+ const forwarded = await ctx.dispatch.writeAs(platformActor(), HelpdeskHandlers.forwardRequest, {
140
+ requestId,
141
+ });
142
+ if (!forwarded.isSuccess) throw new Error(forwarded.error.message);
130
143
  }
131
144
 
132
145
  export async function pickReplyChannels(
@@ -165,7 +178,7 @@ export async function loadTenantPlan(
165
178
  if (ctx.registry.getQueryHandler(TierEngineQueries.getTenantTier) === undefined) return null;
166
179
  try {
167
180
  const assignment = await ctx.dispatch.queryAs(
168
- createSystemUser(SYSTEM_TENANT_ID, [SYSTEM_ADMIN_ROLE]),
181
+ createSystemUser(SYSTEM_TENANT_ID, [ROLES.SystemAdmin]),
169
182
  TierEngineQueries.getTenantTier,
170
183
  { tenantId },
171
184
  );
@@ -9,9 +9,14 @@ import type {
9
9
  import { SYSTEM_TENANT_ID } from "@cosmicdrift/kumiko-framework/engine";
10
10
  import { InternalError } from "@cosmicdrift/kumiko-framework/errors";
11
11
  import { fileRefEntity, fileRefsTable } from "@cosmicdrift/kumiko-framework/files";
12
- import { collectErasureFailure, decryptStoredPii, throwIfErasureFailed } from "../shared/index.ts";
13
- import { userTable } from "../user/index.ts";
14
- import { normalizeEmail, platformActor, replyExecutor, requestExecutor } from "./lib.ts";
12
+ import {
13
+ systemTenantReadDb,
14
+ systemTenantWriteRunner,
15
+ } from "@cosmicdrift/kumiko-framework/internal/row-level-security";
16
+ import { eraseNoteBodiesReachingSubject } from "../notes-history-user-data/index.ts";
17
+ import { collectErasureFailure, throwIfErasureFailed } from "../shared/index.ts";
18
+ import { resolveVerifiedUserEmail } from "../user/index.ts";
19
+ import { listAllPages, platformActor, replyExecutor, requestExecutor } from "./lib.ts";
15
20
  import {
16
21
  HELPDESK_REPLY_ENTITY,
17
22
  HELPDESK_REQUEST_ENTITY,
@@ -20,35 +25,29 @@ import {
20
25
 
21
26
  const PII_DECRYPT_REASON = "helpdesk:user-data";
22
27
  const ERASE_REASON = "helpdesk:user-data-forget";
23
- const LOOKUP_LIMIT = 200;
24
-
25
- // Anonymous requests are matched by email, so the user must have proven they own it: otherwise
26
- // registering with someone else's address would expose or erase that person's requests.
27
- async function resolveVerifiedUserEmail(ctx: UserDataHookCtx): Promise<string | null> {
28
- const row = await ctx.db.fetchOne<{ email: string; emailVerified: boolean }>(userTable, {
29
- id: ctx.userId,
30
- });
31
- if (row?.emailVerified !== true) return null;
32
- if (ctx.userEmailBeforeDelete) return normalizeEmail(ctx.userEmailBeforeDelete);
33
- return normalizeEmail(await decryptStoredPii(row.email, "email", PII_DECRYPT_REASON));
34
- }
28
+ const NOTE_ERASE_WRITE_REASON =
29
+ "erases the note bodies SystemAdmins wrote in the system tenant on a request of an erased subject";
35
30
 
36
31
  async function findRequests(ctx: UserDataHookCtx) {
37
- const byUser = await requestExecutor.list(
38
- { filter: { field: "reporterUserId", op: "eq", value: ctx.userId }, limit: LOOKUP_LIMIT },
39
- platformActor(),
40
- ctx.db,
32
+ const byUser = await listAllPages((page) =>
33
+ requestExecutor.list(
34
+ { filter: { field: "reporterUserId", op: "eq", value: ctx.userId }, ...page },
35
+ platformActor(),
36
+ ctx.db,
37
+ ),
41
38
  );
42
- const email = await resolveVerifiedUserEmail(ctx);
39
+ const email = await resolveVerifiedUserEmail(ctx, PII_DECRYPT_REASON);
43
40
  const byEmail = email
44
- ? await requestExecutor.list(
45
- { filter: { field: "email", op: "eq", value: email }, limit: LOOKUP_LIMIT },
46
- platformActor(),
47
- ctx.db,
41
+ ? await listAllPages((page) =>
42
+ requestExecutor.list(
43
+ { filter: { field: "email", op: "eq", value: email }, ...page },
44
+ platformActor(),
45
+ ctx.db,
46
+ ),
48
47
  )
49
- : { rows: [] };
50
- const unique = new Map(byUser.rows.map((row) => [row.id, row]));
51
- for (const row of byEmail.rows) unique.set(row.id, row);
48
+ : [];
49
+ const unique = new Map(byUser.map((row) => [row.id, row]));
50
+ for (const row of byEmail) unique.set(row.id, row);
52
51
  return [...unique.values()];
53
52
  }
54
53
 
@@ -56,9 +55,18 @@ const fileRefExecutor = createEventStoreExecutor(fileRefsTable, fileRefEntity, {
56
55
  entityName: "fileRef",
57
56
  });
58
57
 
59
- // Attachments are copied into the system tenant and bound to the request or reply row.
60
- async function findAttachments(ctx: UserDataHookCtx, entity: string, id: string) {
61
- return ctx.db.selectMany<{ id: string; storageKey: string; fileName: string }>(fileRefsTable, {
58
+ // Attachments are copied into the system tenant and bound to the request or reply row; a tenant
59
+ // session cannot read those file_refs, so the lookup uses the system-tenant read handle.
60
+ export async function findAttachments(
61
+ ctx: Pick<UserDataHookCtx, "db">,
62
+ entity: string,
63
+ id: string,
64
+ ) {
65
+ return systemTenantReadDb(ctx.db).selectMany<{
66
+ id: string;
67
+ storageKey: string;
68
+ fileName: string;
69
+ }>(fileRefsTable, {
62
70
  tenantId: SYSTEM_TENANT_ID,
63
71
  entityType: entity,
64
72
  entityId: id,
@@ -66,24 +74,23 @@ async function findAttachments(ctx: UserDataHookCtx, entity: string, id: string)
66
74
  });
67
75
  }
68
76
 
77
+ export type AttachmentByteDeleter = (storageKey: string) => Promise<readonly string[]>;
78
+
69
79
  // Bytes first, then the fileRef row: a crash in between leaves a row whose delete converges on the
70
80
  // next run, never bytes without a row. A failing byte delete aborts, like the generic fileRef hook.
71
- async function purgeAttachments(ctx: UserDataHookCtx, entity: string, id: string): Promise<void> {
81
+ // The deleter is resolved lazily, so a row without attachments needs no storage provider.
82
+ export async function purgeAttachmentsWith(
83
+ ctx: Pick<UserDataHookCtx, "db">,
84
+ entity: string,
85
+ id: string,
86
+ resolveByteDeleter: () => Promise<AttachmentByteDeleter>,
87
+ ): Promise<void> {
72
88
  const attachments = await findAttachments(ctx, entity, id);
73
89
  // skip: a row without attachments has no bytes to erase and needs no storage provider
74
90
  if (attachments.length === 0) return;
75
- const provider = await ctx.buildStorageProvider?.(SYSTEM_TENANT_ID);
76
- if (!provider) {
77
- throw new InternalError({
78
- message: `[helpdesk:user-data] no file storage resolvable, attachments of ${entity} ${id} cannot be erased`,
79
- });
80
- }
91
+ const deleteBytes = await resolveByteDeleter();
81
92
  for (const attachment of attachments) {
82
- const failed = await deleteStoredFileAndDerivatives(
83
- attachment.storageKey,
84
- provider,
85
- "helpdesk:user-data",
86
- );
93
+ const failed = await deleteBytes(attachment.storageKey);
87
94
  if (failed.length > 0) {
88
95
  throw new InternalError({
89
96
  message: `[helpdesk:user-data] ${failed.length} attachment byte delete(s) failed for ${entity} ${id}`,
@@ -102,13 +109,46 @@ async function purgeAttachments(ctx: UserDataHookCtx, entity: string, id: string
102
109
  throwIfErasureFailed(failures);
103
110
  }
104
111
 
105
- async function findReplies(ctx: UserDataHookCtx, requestId: string) {
106
- const found = await replyExecutor.list(
107
- { filter: { field: "requestId", op: "eq", value: requestId }, limit: LOOKUP_LIMIT },
108
- platformActor(),
109
- ctx.db,
112
+ export function purgeAttachments(ctx: UserDataHookCtx, entity: string, id: string): Promise<void> {
113
+ return purgeAttachmentsWith(ctx, entity, id, async () => {
114
+ const provider = await ctx.buildStorageProvider?.(SYSTEM_TENANT_ID);
115
+ if (!provider) {
116
+ throw new InternalError({
117
+ message: `[helpdesk:user-data] no file storage resolvable, attachments of ${entity} ${id} cannot be erased`,
118
+ });
119
+ }
120
+ return (storageKey) =>
121
+ deleteStoredFileAndDerivatives(storageKey, provider, "helpdesk:user-data");
122
+ });
123
+ }
124
+
125
+ // Note bodies hang on the request as host. Notes written by SystemAdmins live in the system tenant,
126
+ // which a tenant-scoped hook db cannot see, so both handles are swept.
127
+ export async function eraseNotesOnRequest(
128
+ ctx: Pick<UserDataHookCtx, "db">,
129
+ entity: string,
130
+ id: string,
131
+ erasedBy: string,
132
+ ): Promise<void> {
133
+ for (const db of [ctx.db, systemTenantWriteRunner(ctx.db, NOTE_ERASE_WRITE_REASON)]) {
134
+ await eraseNoteBodiesReachingSubject({
135
+ db,
136
+ subject: { kind: "record", entity, id },
137
+ erasedBy,
138
+ requestId: ERASE_REASON,
139
+ });
140
+ }
141
+ }
142
+
143
+ // guard:dup-ok executor and foreign-key field differ; a generic executor abstraction would obscure row types.
144
+ function findReplies(ctx: UserDataHookCtx, requestId: string) {
145
+ return listAllPages((page) =>
146
+ replyExecutor.list(
147
+ { filter: { field: "requestId", op: "eq", value: requestId }, ...page },
148
+ platformActor(),
149
+ ctx.db,
150
+ ),
110
151
  );
111
- return found.rows;
112
152
  }
113
153
 
114
154
  export const helpdeskExportHook: UserDataExportHook = async (ctx) => {
@@ -169,6 +209,7 @@ export const helpdeskDeleteHook: UserDataDeleteHook = async (ctx) => {
169
209
  await replyExecutor.forget({ id: reply.id }, platformActor(), ctx.db),
170
210
  );
171
211
  }
212
+ await eraseNotesOnRequest(ctx, HELPDESK_REQUEST_ENTITY, request.id, ctx.userId);
172
213
  await purgeAttachments(ctx, HELPDESK_REQUEST_ENTITY, request.id);
173
214
  await erase(
174
215
  HELPDESK_REQUEST_ENTITY,
@@ -112,7 +112,6 @@ export const HelpdeskErrors = {
112
112
  phoneNotAllowed: "helpdesk_phone_not_allowed",
113
113
  phoneRequired: "helpdesk_phone_required",
114
114
  reporterEmailMissing: "helpdesk_reporter_email_missing",
115
- attachmentNotFound: "helpdesk_attachment_not_found",
116
115
  } as const;
117
116
 
118
117
  export const HELPDESK_NOTIFICATION_TYPES = {
@@ -86,7 +86,7 @@ export function createAccountHealth(deps: {
86
86
  }
87
87
 
88
88
  async function lastErrorWithoutOutage(account: AccountHealthRef) {
89
- if (await hasOpenQuarantine(deps.db, account.id)) {
89
+ if (await hasOpenQuarantine(deps.db, { tenantId: account.tenantId, accountId: account.id })) {
90
90
  return InboundMailLastErrors.messageQuarantined;
91
91
  }
92
92
  if (storageUnavailable.has(account.id)) return InboundMailLastErrors.fileStorageUnavailable;
@@ -84,7 +84,11 @@ export function createAccountPoller(deps: AccountPollerDeps): {
84
84
  for (const row of seen) seenIds.add(row.providerMessageId);
85
85
  }
86
86
  // A quarantined message counts as seen: re-fetching it would only fail the same way again.
87
- for (const id of await quarantinedMessageIds(systemDb, account.id, providerMessageIds)) {
87
+ for (const id of await quarantinedMessageIds(
88
+ systemDb,
89
+ { tenantId: account.tenantId, accountId: account.id },
90
+ providerMessageIds,
91
+ )) {
88
92
  seenIds.add(id);
89
93
  }
90
94
  return new Set(providerMessageIds.filter((id) => !seenIds.has(id)));
@@ -22,7 +22,6 @@ const MAIL_THREAD_NAMESPACE = "b48d1e72-5c9a-4f36-8e0d-6a3f9b2c7e15";
22
22
  * the same tenant can receive the same email (CC'd to both inboxes); these
23
23
  * are two distinct inbound messages.
24
24
  */
25
- // @wrapper-known uuid-domain
26
25
  export function inboundMessageAggregateId(accountId: string, providerMessageId: string): string {
27
26
  return uuidv5(`${accountId}:${providerMessageId}`, INBOUND_MESSAGE_NAMESPACE);
28
27
  }
@@ -34,7 +33,6 @@ export function inboundMessageAggregateId(accountId: string, providerMessageId:
34
33
  * normalized by the provider (References/In-Reply-To chain or provider
35
34
  * thread ID).
36
35
  */
37
- // @wrapper-known uuid-domain
38
36
  export function mailThreadAggregateId(tenantId: string, threadKey: string): string {
39
37
  return uuidv5(`${tenantId}:${threadKey}`, MAIL_THREAD_NAMESPACE);
40
38
  }