@cosmicdrift/kumiko-bundled-features 0.406.0 → 0.410.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 (353) hide show
  1. package/dist/account-security/feature.js +9 -1
  2. package/dist/admin-shell/feature.d.ts +3 -0
  3. package/dist/admin-shell/feature.js +1 -1
  4. package/dist/agent-tools/agent-manifest.js +1 -0
  5. package/dist/agent-tools/tool-catalog.js +1 -0
  6. package/dist/agent-tools/types.d.ts +4 -1
  7. package/dist/audit/event-classification.js +1 -0
  8. package/dist/auth-email-password/bootstrap.js +1 -0
  9. package/dist/auth-email-password/errors.js +16 -41
  10. package/dist/auth-email-password/handlers/login-options.query.js +1 -1
  11. package/dist/auth-email-password/handlers/self-registration-status.query.js +1 -1
  12. package/dist/auth-email-password/web/auth-client.d.ts +8 -32
  13. package/dist/auth-email-password/web/auth-client.js +18 -52
  14. package/dist/auth-email-password/web/auth-redirect.js +2 -2
  15. package/dist/auth-email-password/web/confirm-account-unlock-screen.d.ts +2 -2
  16. package/dist/auth-email-password/web/confirm-account-unlock-screen.js +14 -35
  17. package/dist/auth-email-password/web/index.d.ts +1 -0
  18. package/dist/auth-email-password/web/index.js +1 -0
  19. package/dist/auth-email-password/web/read-path-param.d.ts +1 -0
  20. package/dist/auth-email-password/web/read-path-param.js +4 -0
  21. package/dist/auth-email-password/web/return-path.js +2 -2
  22. package/dist/auth-email-password/web/token-confirm-screen.d.ts +20 -0
  23. package/dist/auth-email-password/web/token-confirm-screen.js +38 -0
  24. package/dist/auth-email-password/web/verify-email-screen.d.ts +2 -2
  25. package/dist/auth-email-password/web/verify-email-screen.js +14 -37
  26. package/dist/auth-foundation/boot-checks.js +24 -12
  27. package/dist/auth-foundation/boot-rules.d.ts +27 -0
  28. package/dist/auth-foundation/boot-rules.js +27 -0
  29. package/dist/auth-mfa/errors.d.ts +1 -1
  30. package/dist/auth-mfa/errors.js +11 -24
  31. package/dist/auth-mfa/feature-exports.js +6 -45
  32. package/dist/auth-mfa/feature.js +7 -18
  33. package/dist/auth-mfa/web/mfa-client.js +11 -25
  34. package/dist/billing-foundation/consumer-protection/termination-notify.js +1 -0
  35. package/dist/billing-foundation/web/plan-price.js +7 -8
  36. package/dist/cap-counter/stock-cap-guard.js +1 -0
  37. package/dist/channel-in-app/constants.d.ts +1 -0
  38. package/dist/channel-in-app/feature.js +2 -0
  39. package/dist/channel-in-app/handlers/read-state-by-keys.query.d.ts +9 -0
  40. package/dist/channel-in-app/handlers/read-state-by-keys.query.js +21 -0
  41. package/dist/channel-in-app/in-app-channel.js +1 -0
  42. package/dist/channel-in-app/tables.js +5 -1
  43. package/dist/compliance-profiles/handlers/sub-processors.query.js +4 -1
  44. package/dist/contact/challenge.d.ts +14 -0
  45. package/dist/contact/challenge.js +30 -0
  46. package/dist/contact/client/contact-client-source.d.ts +1 -0
  47. package/dist/contact/client/contact-client-source.js +203 -0
  48. package/dist/contact/client/contact-website-client.d.ts +26 -0
  49. package/dist/contact/client/contact-website-client.js +1 -0
  50. package/dist/contact/client/index.d.ts +2 -0
  51. package/dist/contact/client/index.js +1 -0
  52. package/dist/contact/entity.d.ts +777 -0
  53. package/dist/contact/entity.js +145 -0
  54. package/dist/contact/feature.d.ts +3 -0
  55. package/dist/contact/feature.js +134 -0
  56. package/dist/contact/handlers/access.d.ts +7 -0
  57. package/dist/contact/handlers/access.js +9 -0
  58. package/dist/contact/handlers/attempts.d.ts +14 -0
  59. package/dist/contact/handlers/attempts.js +54 -0
  60. package/dist/contact/handlers/challenge.query.d.ts +9 -0
  61. package/dist/contact/handlers/challenge.query.js +35 -0
  62. package/dist/contact/handlers/forward-request.write.d.ts +9 -0
  63. package/dist/contact/handlers/forward-request.write.js +61 -0
  64. package/dist/contact/handlers/mark-done.write.d.ts +7 -0
  65. package/dist/contact/handlers/mark-done.write.js +30 -0
  66. package/dist/contact/handlers/notify-reporter-in-app.write.d.ts +10 -0
  67. package/dist/contact/handlers/notify-reporter-in-app.write.js +36 -0
  68. package/dist/contact/handlers/open-count.d.ts +2 -0
  69. package/dist/contact/handlers/open-count.js +11 -0
  70. package/dist/contact/handlers/open-count.query.d.ts +3 -0
  71. package/dist/contact/handlers/open-count.query.js +13 -0
  72. package/dist/contact/handlers/replies.query.d.ts +11 -0
  73. package/dist/contact/handlers/replies.query.js +28 -0
  74. package/dist/contact/handlers/reply.write.d.ts +12 -0
  75. package/dist/contact/handlers/reply.write.js +118 -0
  76. package/dist/contact/handlers/report.write.d.ts +16 -0
  77. package/dist/contact/handlers/report.write.js +90 -0
  78. package/dist/contact/handlers/request-delivery.query.d.ts +16 -0
  79. package/dist/contact/handlers/request-delivery.query.js +85 -0
  80. package/dist/contact/handlers/request-detail.query.d.ts +41 -0
  81. package/dist/contact/handlers/request-detail.query.js +32 -0
  82. package/dist/contact/handlers/request-list.query.d.ts +2 -0
  83. package/dist/contact/handlers/request-list.query.js +9 -0
  84. package/dist/contact/handlers/send-reply-mail.write.d.ts +8 -0
  85. package/dist/contact/handlers/send-reply-mail.write.js +82 -0
  86. package/dist/contact/handlers/send-test.write.d.ts +5 -0
  87. package/dist/contact/handlers/send-test.write.js +36 -0
  88. package/dist/contact/handlers/submit.write.d.ts +20 -0
  89. package/dist/contact/handlers/submit.write.js +137 -0
  90. package/dist/contact/handlers/take-over-uploads.d.ts +9 -0
  91. package/dist/contact/handlers/take-over-uploads.js +33 -0
  92. package/dist/contact/i18n.d.ts +6 -0
  93. package/dist/contact/i18n.js +189 -0
  94. package/dist/contact/index.d.ts +5 -0
  95. package/dist/contact/index.js +4 -0
  96. package/dist/contact/lib.d.ts +101 -0
  97. package/dist/contact/lib.js +109 -0
  98. package/dist/contact/mail.d.ts +91 -0
  99. package/dist/contact/mail.js +279 -0
  100. package/dist/contact/options.d.ts +51 -0
  101. package/dist/contact/options.js +32 -0
  102. package/dist/contact/panels.d.ts +2 -0
  103. package/dist/contact/panels.js +21 -0
  104. package/dist/contact/payloads.d.ts +56 -0
  105. package/dist/contact/payloads.js +82 -0
  106. package/dist/contact/pow.d.ts +6 -0
  107. package/dist/contact/pow.js +19 -0
  108. package/dist/contact/screens.d.ts +5 -0
  109. package/dist/contact/screens.js +465 -0
  110. package/dist/contact/subject.d.ts +1 -0
  111. package/dist/contact/subject.js +13 -0
  112. package/dist/contact/user-agent.d.ts +1 -0
  113. package/dist/contact/user-agent.js +35 -0
  114. package/dist/contact/user-data-hooks.d.ts +3 -0
  115. package/dist/contact/user-data-hooks.js +129 -0
  116. package/dist/contact/web/constants.d.ts +127 -0
  117. package/dist/contact/web/constants.js +126 -0
  118. package/dist/contact/web/index.d.ts +1 -0
  119. package/dist/contact/web/index.js +1 -0
  120. package/dist/crypto-shredding/handlers/forget-subject.write.js +5 -13
  121. package/dist/data-retention/feature.js +16 -2
  122. package/dist/data-retention/index.d.ts +1 -0
  123. package/dist/data-retention/index.js +1 -0
  124. package/dist/data-retention/run-retention-cleanup.d.ts +14 -2
  125. package/dist/data-retention/run-retention-cleanup.js +102 -36
  126. package/dist/data-retention/tenant-destruction-hold.d.ts +23 -0
  127. package/dist/data-retention/tenant-destruction-hold.js +132 -0
  128. package/dist/delivery/address-opt-out.js +1 -0
  129. package/dist/delivery/channel-context.d.ts +1 -1
  130. package/dist/delivery/channel-context.js +2 -1
  131. package/dist/delivery/delivery-service.js +18 -8
  132. package/dist/delivery/events.d.ts +1 -0
  133. package/dist/delivery/events.js +2 -0
  134. package/dist/delivery/feature.js +3 -0
  135. package/dist/delivery/handlers/attempts-by-keys.query.d.ts +15 -0
  136. package/dist/delivery/handlers/attempts-by-keys.query.js +35 -0
  137. package/dist/delivery/handlers/log.query.d.ts +1 -0
  138. package/dist/delivery/handlers/log.query.js +1 -1
  139. package/dist/delivery/jobs.js +5 -2
  140. package/dist/delivery/tables.js +12 -2
  141. package/dist/delivery/types.d.ts +2 -0
  142. package/dist/delivery/unsubscribe-page.js +2 -0
  143. package/dist/delivery/web/delivery-channel-cell.js +1 -1
  144. package/dist/delivery/web/delivery-error-cell.js +1 -1
  145. package/dist/delivery/web/delivery-status-cell.js +1 -1
  146. package/dist/delivery/web/delivery-time-cell.js +3 -2
  147. package/dist/delivery/web/delivery-type-cell.js +1 -1
  148. package/dist/delivery/web/public-names.d.ts +1 -0
  149. package/dist/delivery/web/public-names.js +1 -0
  150. package/dist/document-ingest-foundation/boot-checks.js +19 -11
  151. package/dist/document-ingest-foundation/boot-rules.d.ts +17 -0
  152. package/dist/document-ingest-foundation/boot-rules.js +17 -0
  153. package/dist/document-ingest-foundation/events.d.ts +8 -0
  154. package/dist/document-ingest-foundation/events.js +12 -0
  155. package/dist/document-ingest-foundation/feature.js +30 -2
  156. package/dist/document-ingest-foundation/index.d.ts +3 -1
  157. package/dist/document-ingest-foundation/index.js +3 -1
  158. package/dist/document-ingest-foundation/report-ingest-progress.d.ts +14 -0
  159. package/dist/document-ingest-foundation/report-ingest-progress.js +20 -0
  160. package/dist/document-ingest-foundation/tables.d.ts +3 -0
  161. package/dist/document-ingest-foundation/tables.js +26 -0
  162. package/dist/file-derivatives/handlers/public-variant-by-file-ref.query.js +1 -1
  163. package/dist/file-derivatives/handlers/public-variant.query.js +1 -1
  164. package/dist/files-tenant-data/hooks.js +4 -1
  165. package/dist/folders/web/folder-manager.js +3 -10
  166. package/dist/folders/web/folder-section.js +1 -1
  167. package/dist/form-draft-user-data/index.js +4 -1
  168. package/dist/inbound-mail-foundation/entities.d.ts +3 -0
  169. package/dist/inbound-mail-foundation/entities.js +2 -0
  170. package/dist/inbound-mail-foundation/events.d.ts +2 -0
  171. package/dist/inbound-mail-foundation/events.js +2 -0
  172. package/dist/inbound-mail-foundation/feature.js +6 -6
  173. package/dist/inbound-mail-foundation/handlers/attach-message-content.write.js +3 -1
  174. package/dist/inbound-mail-foundation/handlers/ingest-message.write.js +5 -0
  175. package/dist/inbound-mail-foundation/handlers/list-messages.query.js +4 -2
  176. package/dist/inbound-mail-foundation/handlers/message-content.d.ts +1 -0
  177. package/dist/inbound-mail-foundation/handlers/message-content.js +8 -0
  178. package/dist/inbound-mail-foundation/handlers/message-content.query.d.ts +2 -0
  179. package/dist/inbound-mail-foundation/handlers/message-content.query.js +1 -0
  180. package/dist/inbound-mail-foundation/projection.d.ts +3 -0
  181. package/dist/inbound-mail-foundation/projection.js +2 -0
  182. package/dist/inbound-mail-foundation/sanitize-inbound-html.d.ts +2 -0
  183. package/dist/inbound-mail-foundation/sanitize-inbound-html.js +135 -0
  184. package/dist/inbound-mail-foundation/types.js +1 -0
  185. package/dist/jobs/job-run-logger.js +16 -20
  186. package/dist/ledger/handlers/reports.query.js +25 -27
  187. package/dist/ledger/recurring.js +1 -0
  188. package/dist/managed-pages/handlers/branding.query.js +1 -1
  189. package/dist/managed-pages/handlers/by-slug.query.js +1 -1
  190. package/dist/managed-pages/handlers/by-tenant-published.query.js +1 -1
  191. package/dist/notes-history/web/notes-section.js +3 -2
  192. package/dist/personal-access-tokens/feature.js +5 -18
  193. package/dist/personal-access-tokens/handlers/create.write.js +2 -5
  194. package/dist/secrets/handlers/delete.write.d.ts +4 -0
  195. package/dist/secrets/handlers/delete.write.js +9 -4
  196. package/dist/secrets/handlers/list.query.d.ts +6 -1
  197. package/dist/secrets/handlers/list.query.js +7 -3
  198. package/dist/secrets/handlers/set.write.d.ts +4 -0
  199. package/dist/secrets/handlers/set.write.js +10 -4
  200. package/dist/secrets/secret-scope.d.ts +17 -0
  201. package/dist/secrets/secret-scope.js +18 -0
  202. package/dist/seo/handlers/seo-config.query.js +1 -1
  203. package/dist/sessions/feature.d.ts +3 -0
  204. package/dist/sessions/feature.js +13 -19
  205. package/dist/sessions/handlers/last-activity-probe.query.d.ts +7 -0
  206. package/dist/sessions/handlers/last-activity-probe.query.js +40 -0
  207. package/dist/sessions/handlers/last-activity-probe.route.d.ts +2 -0
  208. package/dist/sessions/handlers/last-activity-probe.route.js +30 -0
  209. package/dist/sessions/screens.js +1 -0
  210. package/dist/sessions/session-callbacks.d.ts +2 -0
  211. package/dist/sessions/session-callbacks.js +9 -7
  212. package/dist/sessions/web/i18n.js +4 -1
  213. package/dist/shared/assert-billing-live.d.ts +2 -0
  214. package/dist/shared/assert-billing-live.js +7 -0
  215. package/dist/shared/collect-extension-options.d.ts +1 -0
  216. package/dist/shared/collect-extension-options.js +8 -0
  217. package/dist/shared/index.d.ts +7 -1
  218. package/dist/shared/index.js +7 -1
  219. package/dist/shared/late-bound-slot.d.ts +5 -0
  220. package/dist/shared/late-bound-slot.js +13 -0
  221. package/dist/shared/mail-locale-templates.d.ts +1 -0
  222. package/dist/shared/mail-locale-templates.js +1 -1
  223. package/dist/shared/price-env-shape.d.ts +11 -0
  224. package/dist/shared/price-env-shape.js +15 -0
  225. package/dist/shared/purge-row-file-refs.d.ts +1 -0
  226. package/dist/shared/purge-row-file-refs.js +1 -1
  227. package/dist/shared/read-feature-export-fn.d.ts +2 -0
  228. package/dist/shared/read-feature-export-fn.js +11 -0
  229. package/dist/shared/signup-handover.js +3 -5
  230. package/dist/shared/tenant-destruction-hold.d.ts +23 -0
  231. package/dist/shared/tenant-destruction-hold.js +15 -0
  232. package/dist/shared/unprocessable.d.ts +4 -0
  233. package/dist/shared/unprocessable.js +4 -0
  234. package/dist/shared/web/index.d.ts +3 -0
  235. package/dist/shared/web/index.js +3 -0
  236. package/dist/subscription-paddle/checkout-config.query.js +1 -1
  237. package/dist/subscription-paddle/feature.d.ts +1 -5
  238. package/dist/subscription-paddle/feature.js +7 -9
  239. package/dist/subscription-paddle/runtime.js +3 -7
  240. package/dist/subscription-stripe/feature.d.ts +1 -5
  241. package/dist/subscription-stripe/feature.js +7 -9
  242. package/dist/subscription-stripe/runtime.js +3 -7
  243. package/dist/tags/entity.js +1 -0
  244. package/dist/tags/web/tag-chip.d.ts +7 -0
  245. package/dist/tags/web/tag-chip.js +4 -0
  246. package/dist/tags/web/tag-filter.js +2 -5
  247. package/dist/tags/web/tag-manager.js +1 -1
  248. package/dist/tags/web/tag-section.js +3 -6
  249. package/dist/tags/web/tags-cell.js +2 -5
  250. package/dist/template-resolver/compile-document-body.js +12 -17
  251. package/dist/template-resolver/handlers/by-slug.query.js +1 -1
  252. package/dist/template-resolver/handlers/by-tenant.query.js +4 -2
  253. package/dist/template-resolver/handlers/discard-draft.write.js +1 -0
  254. package/dist/template-resolver/handlers/overview.query.js +3 -1
  255. package/dist/template-resolver/handlers/send-test.write.js +2 -4
  256. package/dist/template-resolver/handlers/toggle-status.write.js +3 -0
  257. package/dist/template-resolver/linked-resources.js +6 -5
  258. package/dist/template-resolver/store-template-resource.js +5 -10
  259. package/dist/template-resolver/web/document-images.js +6 -6
  260. package/dist/template-resolver/web/document-insert-fields.js +22 -4
  261. package/dist/template-resolver/web/document-schema.js +11 -12
  262. package/dist/template-resolver/web/tiptap-attribute-parse-rule.d.ts +15 -0
  263. package/dist/template-resolver/web/tiptap-attribute-parse-rule.js +11 -0
  264. package/dist/tenant/i18n.js +3 -0
  265. package/dist/tenant/schema/tenant.d.ts +9 -7
  266. package/dist/tenant/schema/tenant.js +1 -0
  267. package/dist/tenant/web/member-roles-cell.js +1 -1
  268. package/dist/tenant/web/member-status-cell.js +1 -1
  269. package/dist/tenant-inactivity/check-inactive-tenants.d.ts +3 -0
  270. package/dist/tenant-inactivity/check-inactive-tenants.js +184 -0
  271. package/dist/tenant-inactivity/constants.d.ts +10 -0
  272. package/dist/tenant-inactivity/constants.js +10 -0
  273. package/dist/tenant-inactivity/email-templates.d.ts +3 -0
  274. package/dist/tenant-inactivity/email-templates.js +16 -0
  275. package/dist/tenant-inactivity/feature.d.ts +8 -0
  276. package/dist/tenant-inactivity/feature.js +45 -0
  277. package/dist/tenant-inactivity/handlers/inactivity-state.query.d.ts +11 -0
  278. package/dist/tenant-inactivity/handlers/inactivity-state.query.js +45 -0
  279. package/dist/tenant-inactivity/handlers/keep-account.write.d.ts +8 -0
  280. package/dist/tenant-inactivity/handlers/keep-account.write.js +51 -0
  281. package/dist/tenant-inactivity/inactivity-plan.d.ts +51 -0
  282. package/dist/tenant-inactivity/inactivity-plan.js +113 -0
  283. package/dist/tenant-inactivity/index.d.ts +5 -0
  284. package/dist/tenant-inactivity/index.js +3 -0
  285. package/dist/tenant-inactivity/keep-token.d.ts +16 -0
  286. package/dist/tenant-inactivity/keep-token.js +24 -0
  287. package/dist/tenant-inactivity/mail-notifications.d.ts +4 -0
  288. package/dist/tenant-inactivity/mail-notifications.js +42 -0
  289. package/dist/tenant-inactivity/options.d.ts +27 -0
  290. package/dist/tenant-inactivity/options.js +5 -0
  291. package/dist/tenant-inactivity/remote-activity.d.ts +15 -0
  292. package/dist/tenant-inactivity/remote-activity.js +24 -0
  293. package/dist/tenant-inactivity/state-store.d.ts +10 -0
  294. package/dist/tenant-inactivity/state-store.js +50 -0
  295. package/dist/tenant-inactivity/state-table.d.ts +109 -0
  296. package/dist/tenant-inactivity/state-table.js +38 -0
  297. package/dist/tenant-lifecycle/boot-checks.js +8 -3
  298. package/dist/tenant-lifecycle/boot-rules.d.ts +12 -0
  299. package/dist/tenant-lifecycle/boot-rules.js +12 -0
  300. package/dist/tenant-lifecycle/feature.js +17 -2
  301. package/dist/tenant-lifecycle/handlers/request-destruction.write.js +11 -67
  302. package/dist/tenant-lifecycle/index.d.ts +1 -0
  303. package/dist/tenant-lifecycle/index.js +1 -0
  304. package/dist/tenant-lifecycle/request-tenant-destruction.d.ts +20 -0
  305. package/dist/tenant-lifecycle/request-tenant-destruction.js +66 -0
  306. package/dist/tenant-lifecycle/retention-config-destroy-hooks.d.ts +5 -0
  307. package/dist/tenant-lifecycle/retention-config-destroy-hooks.js +29 -0
  308. package/dist/tenant-lifecycle/run-tenant-destroy.d.ts +3 -0
  309. package/dist/tenant-lifecycle/run-tenant-destroy.js +43 -5
  310. package/dist/tenant-lifecycle/stages.d.ts +2 -0
  311. package/dist/tenant-lifecycle/stages.js +23 -2
  312. package/dist/tenant-lifecycle/testing.js +1 -1
  313. package/dist/tier-engine/caps-for-tier-from-map.d.ts +5 -0
  314. package/dist/tier-engine/caps-for-tier-from-map.js +12 -0
  315. package/dist/tier-engine/compose-app.d.ts +0 -22
  316. package/dist/tier-engine/compose-app.js +9 -16
  317. package/dist/tier-engine/index.d.ts +1 -0
  318. package/dist/tier-engine/index.js +1 -0
  319. package/dist/user/handlers/detail.query.d.ts +1 -1
  320. package/dist/user-data-rights/feature.js +2 -0
  321. package/dist/user-data-rights/handlers/confirm-deletion-by-token.write.js +4 -1
  322. package/dist/user-data-rights/handlers/download-by-token.query.js +1 -0
  323. package/dist/user-data-rights/handlers/request-deletion-by-email.write.js +4 -1
  324. package/dist/user-data-rights/run-forget-cleanup.js +2 -0
  325. package/dist/user-data-rights/web/privacy-center-screen.js +1 -1
  326. package/dist/user-data-rights/zip-path.js +1 -0
  327. package/dist/user-data-rights-defaults/hooks/config-value.userdata-hook.d.ts +1 -1
  328. package/dist/user-data-rights-defaults/hooks/config-value.userdata-hook.js +7 -20
  329. package/dist/user-data-rights-defaults/hooks/delivery-attempt.userdata-hook.js +3 -1
  330. package/dist/user-data-rights-defaults/hooks/forget-own-rows-delete-hook.d.ts +10 -0
  331. package/dist/user-data-rights-defaults/hooks/forget-own-rows-delete-hook.js +26 -0
  332. package/dist/user-data-rights-defaults/hooks/notification-preference.userdata-hook.d.ts +1 -1
  333. package/dist/user-data-rights-defaults/hooks/notification-preference.userdata-hook.js +7 -20
  334. package/dist/user-profile/handlers/change-email.write.js +2 -4
  335. package/dist/user-profile/web/profile-screen.js +2 -3
  336. package/dist/waitlist/handlers/submit.write.js +1 -2
  337. package/kumiko-es-tables.json +12 -0
  338. package/package.json +54 -12
  339. package/src/admin-shell/changes.json +6 -0
  340. package/src/agent-tools/changes.json +6 -0
  341. package/src/channel-in-app/changes.json +7 -0
  342. package/src/contact/changes.json +33 -0
  343. package/src/data-retention/changes.json +6 -0
  344. package/src/delivery/changes.json +7 -0
  345. package/src/document-ingest-foundation/changes.json +6 -0
  346. package/src/files-tenant-data/changes.json +6 -0
  347. package/src/inbound-mail-foundation/changes.json +13 -0
  348. package/src/secrets/changes.json +6 -0
  349. package/src/sessions/changes.json +6 -0
  350. package/src/tenant-inactivity/changes.json +8 -0
  351. package/src/tenant-lifecycle/changes.json +18 -0
  352. package/src/tier-engine/changes.json +6 -0
  353. package/src/waitlist/changes.json +6 -0
@@ -0,0 +1,465 @@
1
+ import { access, createFilesField, createTextField } from "@cosmicdrift/kumiko-framework/engine";
2
+ import { DELIVERY_LOG_SCREEN_ID } from "../delivery/index.js";
3
+ import { REPORT_ACCESS } from "./handlers/access.js";
4
+ import { CONTACT_ADMIN_KINDS, CONTACT_DELIVERY_STATUS, CONTACT_FEATURE, CONTACT_MAX_FILES, CONTACT_ORIGIN, CONTACT_REPLY_CHANNELS, CONTACT_STATUS, CONTACT_UPLOAD_FIELD, ContactConfigKeys, ContactHandlers, ContactQueries, } from "./web/constants.js";
5
+ const MAX_FILE_SIZE = "10MB";
6
+ const REQUEST_FIELD = `${CONTACT_FEATURE}:entity:contact-request:field`;
7
+ const DELIVERY_FIELD = `${CONTACT_FEATURE}:entity:contact-delivery:field`;
8
+ const TELEGRAM_BOT_TOKEN_SECRET = "channel-telegram:secret:bot-token";
9
+ export const REPORT_FIELD_LABEL = `${CONTACT_FEATURE}:report.field`;
10
+ export const REPLY_FIELD_LABEL = `${CONTACT_FEATURE}:reply.field`;
11
+ function attachmentsField() {
12
+ return createFilesField({
13
+ personal: false,
14
+ reason: "is_business_data",
15
+ maxCount: CONTACT_MAX_FILES,
16
+ maxSize: MAX_FILE_SIZE,
17
+ display: "dropzone",
18
+ });
19
+ }
20
+ // The files the form uploads stay pending under this screen's QN until the handler takes them
21
+ // over (copyPendingFileRefsToTenant).
22
+ function createReportScreen(opts, settings) {
23
+ const withPhone = settings.phone !== "off";
24
+ return {
25
+ id: "report",
26
+ type: "actionForm",
27
+ dormant: true,
28
+ handler: ContactHandlers.report,
29
+ summary: {
30
+ title: `${CONTACT_FEATURE}:report.hint`,
31
+ subtitle: `${CONTACT_FEATURE}:report.summary`,
32
+ params: { appName: opts.appName },
33
+ },
34
+ fields: {
35
+ kind: { type: "select", options: CONTACT_ADMIN_KINDS, required: true, display: "radio" },
36
+ ...(withPhone && {
37
+ phone: { type: "text", format: "phone", required: settings.phone === "required" },
38
+ }),
39
+ subject: { type: "text", required: true },
40
+ message: { type: "longText", required: true },
41
+ [CONTACT_UPLOAD_FIELD]: attachmentsField(),
42
+ },
43
+ layout: {
44
+ sections: [
45
+ {
46
+ title: `${CONTACT_FEATURE}:report.section`,
47
+ description: `${CONTACT_FEATURE}:report.section.description`,
48
+ fields: [
49
+ "kind",
50
+ ...(withPhone ? ["phone"] : []),
51
+ { field: "subject", span: 2 },
52
+ "message",
53
+ CONTACT_UPLOAD_FIELD,
54
+ ],
55
+ },
56
+ ],
57
+ },
58
+ fieldLabels: {
59
+ kind: `${REPORT_FIELD_LABEL}.kind`,
60
+ phone: `${REPORT_FIELD_LABEL}.phone`,
61
+ subject: `${REPORT_FIELD_LABEL}.subject`,
62
+ message: `${REPORT_FIELD_LABEL}.message`,
63
+ [CONTACT_UPLOAD_FIELD]: `${REPORT_FIELD_LABEL}.files`,
64
+ },
65
+ submitLabel: `${CONTACT_FEATURE}:report.submit`,
66
+ ...(opts.reportCancelTarget !== undefined && { cancelTarget: opts.reportCancelTarget }),
67
+ successMessage: `${CONTACT_FEATURE}:report.success`,
68
+ access: REPORT_ACCESS,
69
+ };
70
+ }
71
+ // The two reply screens differ only in the summary text: the screen QN is also the entityType the
72
+ // pending uploads hang under, so reply.write picks the variant by the reporter's reply channels.
73
+ function createReplyScreen(id, summarySubtitle) {
74
+ return {
75
+ id,
76
+ type: "actionForm",
77
+ dormant: true,
78
+ handler: ContactHandlers.reply,
79
+ summary: { title: `${CONTACT_FEATURE}:reply.title`, subtitle: summarySubtitle },
80
+ fields: {
81
+ requestId: { type: "text", required: true },
82
+ message: { type: "longText", required: true },
83
+ [CONTACT_UPLOAD_FIELD]: attachmentsField(),
84
+ markDone: { type: "boolean" },
85
+ name: { type: "text" },
86
+ email: { type: "text" },
87
+ replyTo: { type: "text" },
88
+ },
89
+ layout: {
90
+ sections: [
91
+ {
92
+ title: `${CONTACT_FEATURE}:reply.section`,
93
+ description: `${CONTACT_FEATURE}:reply.section.description`,
94
+ fields: [
95
+ { field: "requestId", visible: false },
96
+ { field: "name", visible: false },
97
+ { field: "email", visible: false },
98
+ { field: "replyTo", visible: false },
99
+ "message",
100
+ CONTACT_UPLOAD_FIELD,
101
+ "markDone",
102
+ ],
103
+ },
104
+ ],
105
+ },
106
+ fieldLabels: {
107
+ message: `${REPLY_FIELD_LABEL}.message`,
108
+ [CONTACT_UPLOAD_FIELD]: `${REPLY_FIELD_LABEL}.files`,
109
+ markDone: `${REPLY_FIELD_LABEL}.mark-done`,
110
+ },
111
+ submitLabel: `${CONTACT_FEATURE}:reply.submit`,
112
+ access: { roles: access.systemAdmin },
113
+ };
114
+ }
115
+ const requestListScreen = {
116
+ id: "request-list",
117
+ type: "entityList",
118
+ entity: "contact-request",
119
+ dormant: true,
120
+ allowCreate: false,
121
+ searchable: true,
122
+ columns: [
123
+ { field: "submittedAt", display: "datetime" },
124
+ "kind",
125
+ { field: "name", label: `${CONTACT_FEATURE}:list.from` },
126
+ { field: "reporterTenantName", label: `${REQUEST_FIELD}:reporterTenantName` },
127
+ { field: "subject", hideOnNarrow: true },
128
+ {
129
+ field: "source",
130
+ hideOnNarrow: true,
131
+ renderer: { format: "enumOption", keyPrefix: `${REQUEST_FIELD}:source:option:` },
132
+ },
133
+ { field: "fileCount", label: `${REQUEST_FIELD}:fileCount`, hideOnNarrow: true },
134
+ "status",
135
+ ],
136
+ facets: {
137
+ status: {
138
+ display: "chips",
139
+ showCounts: true,
140
+ extraOptions: [
141
+ { id: "all", label: `${CONTACT_FEATURE}:filter.all`, values: [], position: "start" },
142
+ ],
143
+ },
144
+ kind: { display: "select" },
145
+ source: { display: "select" },
146
+ },
147
+ defaultFilters: { status: [CONTACT_STATUS.Open] },
148
+ defaultSort: { field: "submittedAt", dir: "desc" },
149
+ rowActions: [
150
+ {
151
+ kind: "navigate",
152
+ id: "open",
153
+ label: `${CONTACT_FEATURE}:action.open`,
154
+ screen: "request-detail",
155
+ entityId: "id",
156
+ rowClick: true,
157
+ },
158
+ {
159
+ kind: "writeHandler",
160
+ id: "mark-done",
161
+ label: `${CONTACT_FEATURE}:action.mark-done`,
162
+ handler: ContactHandlers.markDone,
163
+ payload: { pick: ["id"] },
164
+ visible: { field: "status", ne: CONTACT_STATUS.Done },
165
+ },
166
+ ],
167
+ bulkActions: [{ id: "mark-done", rowAction: "mark-done" }],
168
+ access: { roles: access.systemAdmin },
169
+ };
170
+ const deliveryStatusTones = {
171
+ [CONTACT_DELIVERY_STATUS.Pending]: "warn",
172
+ [CONTACT_DELIVERY_STATUS.Delivered]: "ok",
173
+ [CONTACT_DELIVERY_STATUS.Failed]: "bad",
174
+ [CONTACT_DELIVERY_STATUS.Skipped]: "neutral",
175
+ [CONTACT_DELIVERY_STATUS.Read]: "accent",
176
+ };
177
+ function detailLinkTarget(link, defaultScreen) {
178
+ if (link === false)
179
+ return undefined;
180
+ return link ?? defaultScreen;
181
+ }
182
+ function createRequestDetailScreen(opts, settings) {
183
+ const userScreen = detailLinkTarget(opts.detailLinks?.user, "user-edit");
184
+ const tenantScreen = detailLinkTarget(opts.detailLinks?.tenant, "tenant-edit");
185
+ return {
186
+ id: "request-detail",
187
+ type: "projectionDetail",
188
+ dormant: true,
189
+ query: ContactQueries.requestDetail,
190
+ listScreenId: "request-list",
191
+ header: {
192
+ title: "subject",
193
+ subtitle: [
194
+ {
195
+ field: "kind",
196
+ format: { format: "enumOption", keyPrefix: `${REQUEST_FIELD}:kind:option:` },
197
+ },
198
+ {
199
+ field: "name",
200
+ ...(userScreen !== undefined && {
201
+ navigate: { screen: userScreen, entityId: "reporterUserId" },
202
+ }),
203
+ },
204
+ {
205
+ field: "reporterTenantName",
206
+ ...(tenantScreen !== undefined && {
207
+ navigate: { screen: tenantScreen, entityId: "reporterTenantId" },
208
+ }),
209
+ },
210
+ {
211
+ field: "submittedAt",
212
+ format: { format: "timestamp", dateStyle: "medium", timeStyle: "short" },
213
+ },
214
+ ],
215
+ status: "status",
216
+ statusFormat: { format: "enumOption", keyPrefix: `${REQUEST_FIELD}:status:option:` },
217
+ statusTones: {
218
+ [CONTACT_STATUS.Open]: "warn",
219
+ [CONTACT_STATUS.Answered]: "accent",
220
+ [CONTACT_STATUS.Done]: "ok",
221
+ },
222
+ },
223
+ actions: [
224
+ {
225
+ kind: "writeHandler",
226
+ id: "mark-done",
227
+ label: `${CONTACT_FEATURE}:action.mark-done`,
228
+ handler: ContactHandlers.markDone,
229
+ icon: "check-circle",
230
+ style: "secondary",
231
+ payload: { pick: ["id"] },
232
+ visible: { field: "status", ne: CONTACT_STATUS.Done },
233
+ },
234
+ {
235
+ kind: "drawer",
236
+ id: "reply",
237
+ icon: "mail",
238
+ style: "primary",
239
+ label: `${CONTACT_FEATURE}:action.reply`,
240
+ screen: "reply",
241
+ params: { map: { requestId: "id", name: "name", email: "email", replyTo: "replyTo" } },
242
+ title: "screen:reply.title",
243
+ visible: { field: "replyChannels", eq: CONTACT_REPLY_CHANNELS.EmailAndInApp },
244
+ },
245
+ {
246
+ kind: "drawer",
247
+ id: "reply-mail",
248
+ icon: "mail",
249
+ style: "primary",
250
+ label: `${CONTACT_FEATURE}:action.reply`,
251
+ screen: "reply-mail",
252
+ params: { map: { requestId: "id", name: "name", email: "email", replyTo: "replyTo" } },
253
+ title: "screen:reply-mail.title",
254
+ visible: { field: "replyChannels", eq: CONTACT_REPLY_CHANNELS.Email },
255
+ },
256
+ ],
257
+ primaryAction: "reply",
258
+ inlineActions: ["mark-done"],
259
+ fieldLabels: {
260
+ message: `${REQUEST_FIELD}:message`,
261
+ fileIds: `${CONTACT_FEATURE}:detail.attachments`,
262
+ name: `${REQUEST_FIELD}:name`,
263
+ email: `${REQUEST_FIELD}:email`,
264
+ phone: `${REQUEST_FIELD}:phone`,
265
+ reporterTenantPlan: `${REQUEST_FIELD}:reporterTenantPlan`,
266
+ origin: `${REQUEST_FIELD}:origin`,
267
+ page: `${REQUEST_FIELD}:page`,
268
+ versionLabel: `${REQUEST_FIELD}:versionLabel`,
269
+ browser: `${REQUEST_FIELD}:browser`,
270
+ },
271
+ layout: {
272
+ sections: [
273
+ { title: `${CONTACT_FEATURE}:detail.section.message`, fields: ["message"] },
274
+ {
275
+ kind: "relatedList",
276
+ readOnly: true,
277
+ title: `${CONTACT_FEATURE}:detail.section.replies`,
278
+ query: ContactQueries.replies,
279
+ columns: [
280
+ {
281
+ field: "sentAt",
282
+ renderer: { format: "timestamp", dateStyle: "medium", timeStyle: "short" },
283
+ label: `${CONTACT_FEATURE}:entity:contact-reply:field:sentAt`,
284
+ },
285
+ {
286
+ field: "authorName",
287
+ label: `${CONTACT_FEATURE}:entity:contact-reply:field:authorName`,
288
+ },
289
+ { field: "message", label: `${CONTACT_FEATURE}:entity:contact-reply:field:message` },
290
+ ],
291
+ },
292
+ {
293
+ title: `${CONTACT_FEATURE}:detail.section.files`,
294
+ fields: [
295
+ {
296
+ field: CONTACT_UPLOAD_FIELD,
297
+ renderer: { format: "file" },
298
+ visible: { field: "fileCount", ne: 0 },
299
+ },
300
+ ],
301
+ },
302
+ {
303
+ title: `${CONTACT_FEATURE}:detail.section.sender`,
304
+ fields: [
305
+ "name",
306
+ { field: "email", format: "email" },
307
+ ...(settings.phone !== "off"
308
+ ? [
309
+ {
310
+ field: "phone",
311
+ format: "phone",
312
+ visible: { field: "phone", notIn: [null, ""] },
313
+ },
314
+ ]
315
+ : []),
316
+ "reporterTenantPlan",
317
+ ],
318
+ },
319
+ {
320
+ title: `${CONTACT_FEATURE}:detail.section.origin`,
321
+ fields: [
322
+ {
323
+ field: "origin",
324
+ renderer: { format: "enumOption", keyPrefix: `${REQUEST_FIELD}:origin:option:` },
325
+ },
326
+ { field: "page", visible: { field: "origin", eq: CONTACT_ORIGIN.Website } },
327
+ "versionLabel",
328
+ "browser",
329
+ ],
330
+ },
331
+ {
332
+ kind: "relatedList",
333
+ readOnly: true,
334
+ title: `${CONTACT_FEATURE}:detail.section.delivery`,
335
+ query: ContactQueries.requestDelivery,
336
+ toolbarActions: [
337
+ {
338
+ kind: "navigate",
339
+ id: "delivery-log",
340
+ label: `${CONTACT_FEATURE}:detail.delivery-log`,
341
+ screen: DELIVERY_LOG_SCREEN_ID,
342
+ },
343
+ ],
344
+ columns: [
345
+ {
346
+ field: "channel",
347
+ label: `${DELIVERY_FIELD}:channel`,
348
+ renderer: { format: "enumOption", keyPrefix: `${DELIVERY_FIELD}:channel:option:` },
349
+ },
350
+ { field: "recipient", label: `${DELIVERY_FIELD}:recipient` },
351
+ {
352
+ field: "at",
353
+ renderer: { format: "timestamp", dateStyle: "medium", timeStyle: "short" },
354
+ label: `${DELIVERY_FIELD}:at`,
355
+ },
356
+ {
357
+ field: "status",
358
+ label: `${DELIVERY_FIELD}:status`,
359
+ renderer: {
360
+ format: "enumOption",
361
+ keyPrefix: `${DELIVERY_FIELD}:status:option:`,
362
+ tones: deliveryStatusTones,
363
+ },
364
+ },
365
+ ],
366
+ },
367
+ {
368
+ kind: "extension",
369
+ title: `${CONTACT_FEATURE}:detail.section.notes`,
370
+ component: { react: { __component: "NotesSection" } },
371
+ entityName: "contact-request",
372
+ },
373
+ ],
374
+ },
375
+ access: { roles: access.systemAdmin },
376
+ };
377
+ }
378
+ function createForwardingScreen(telegram) {
379
+ return {
380
+ id: "forwarding",
381
+ type: "configEdit",
382
+ dormant: true,
383
+ scope: "system",
384
+ configKeys: {
385
+ replyTo: ContactConfigKeys.replyTo,
386
+ ...(telegram && { telegramChat: ContactConfigKeys.telegramChat }),
387
+ },
388
+ ...(telegram && { secretKeys: { botToken: TELEGRAM_BOT_TOKEN_SECRET } }),
389
+ fields: {
390
+ replyTo: createTextField({
391
+ format: "email",
392
+ maxLength: 254,
393
+ personal: false,
394
+ reason: "is_business_data",
395
+ }),
396
+ ...(telegram && {
397
+ telegramChat: createTextField({
398
+ maxLength: 64,
399
+ personal: false,
400
+ reason: "is_business_data",
401
+ }),
402
+ botToken: createTextField({
403
+ writeOnly: true,
404
+ maxLength: 200,
405
+ personal: false,
406
+ reason: "is_business_data",
407
+ }),
408
+ }),
409
+ },
410
+ layout: {
411
+ variant: "settings-list",
412
+ sections: [
413
+ {
414
+ title: `${CONTACT_FEATURE}:forwarding.email`,
415
+ description: `${CONTACT_FEATURE}:forwarding.email.description`,
416
+ fields: ["replyTo"],
417
+ },
418
+ ...(telegram
419
+ ? [
420
+ {
421
+ title: `${CONTACT_FEATURE}:forwarding.telegram`,
422
+ description: `${CONTACT_FEATURE}:forwarding.telegram.description`,
423
+ fields: ["telegramChat", "botToken"],
424
+ },
425
+ ]
426
+ : []),
427
+ ],
428
+ },
429
+ fieldLabels: {
430
+ replyTo: `${CONTACT_FEATURE}:config.reply-to.label`,
431
+ telegramChat: `${CONTACT_FEATURE}:config.telegram-chat.label`,
432
+ botToken: `${CONTACT_FEATURE}:config.bot-token.label`,
433
+ },
434
+ fieldDescriptions: {
435
+ replyTo: `${CONTACT_FEATURE}:config.reply-to.description`,
436
+ telegramChat: `${CONTACT_FEATURE}:config.telegram-chat.description`,
437
+ botToken: `${CONTACT_FEATURE}:config.bot-token.description`,
438
+ },
439
+ submitLabel: `${CONTACT_FEATURE}:forwarding.submit`,
440
+ ...(telegram && {
441
+ actions: [
442
+ {
443
+ id: "send-test",
444
+ handler: ContactHandlers.sendTest,
445
+ label: `${CONTACT_FEATURE}:config.send-test.label`,
446
+ description: `${CONTACT_FEATURE}:config.send-test.description`,
447
+ buttonLabel: `${CONTACT_FEATURE}:config.send-test.button`,
448
+ afterField: "botToken",
449
+ successMessage: `${CONTACT_FEATURE}:config.send-test.success`,
450
+ },
451
+ ],
452
+ }),
453
+ access: { roles: access.systemAdmin },
454
+ };
455
+ }
456
+ export function createContactScreens(opts, settings) {
457
+ return [
458
+ createReportScreen(opts, settings),
459
+ requestListScreen,
460
+ createRequestDetailScreen(opts, settings),
461
+ createReplyScreen("reply", `${CONTACT_FEATURE}:reply.summary.in-app`),
462
+ createReplyScreen("reply-mail", `${CONTACT_FEATURE}:reply.summary.mail`),
463
+ createForwardingScreen(opts.telegram === true),
464
+ ];
465
+ }
@@ -0,0 +1 @@
1
+ export declare function deriveSubjectFromMessage(message: string): string;
@@ -0,0 +1,13 @@
1
+ import { CONTACT_SUBJECT_MAX_CHARS } from "./web/constants.js";
2
+ // The website form has no subject field; the first non-empty line of the message stands in for it.
3
+ export function deriveSubjectFromMessage(message) {
4
+ const firstLine = message.split(/[\r\n]/).find((line) => line.trim() !== "") ?? "";
5
+ const trimmed = firstLine.trim();
6
+ const chars = [...trimmed];
7
+ if (chars.length <= CONTACT_SUBJECT_MAX_CHARS)
8
+ return trimmed;
9
+ return `${chars
10
+ .slice(0, CONTACT_SUBJECT_MAX_CHARS - 1)
11
+ .join("")
12
+ .trimEnd()}…`;
13
+ }
@@ -0,0 +1 @@
1
+ export declare function summarizeUserAgent(userAgent: string | undefined, locale: string): string | null;
@@ -0,0 +1,35 @@
1
+ // Order matters: Edge and Opera also say "Chrome", Chrome also says "Safari".
2
+ const BROWSER_PATTERNS = [
3
+ ["Edge", /\bEdg(?:e|A|iOS)?\/(\d+)/],
4
+ ["Opera", /\b(?:OPR|Opera)\/(\d+)/],
5
+ ["Firefox", /\b(?:Firefox|FxiOS)\/(\d+)/],
6
+ ["Chrome", /\b(?:Chrome|CriOS)\/(\d+)/],
7
+ ["Safari", /\bVersion\/(\d+)[\s\S]*\bSafari\//],
8
+ ];
9
+ // iOS and Android UAs also contain "Mac OS X" / "Linux", so they are tested first.
10
+ const OS_PATTERNS = [
11
+ ["iOS", /\b(?:iPhone|iPad|iPod)\b/],
12
+ ["Android", /\bAndroid\b/],
13
+ ["Windows", /\bWindows\b/],
14
+ ["macOS", /\bMac OS X\b|\bMacintosh\b/],
15
+ ["Linux", /\b(?:Linux|X11)\b/],
16
+ ];
17
+ const CONNECTOR_BY_LANGUAGE = { de: "auf", en: "on" };
18
+ function languageOf(locale) {
19
+ return locale.split("-")[0]?.toLowerCase() ?? "en";
20
+ }
21
+ // Null when the UA names no known browser; the browser column is a hint for operators, not an identity.
22
+ export function summarizeUserAgent(userAgent, locale) {
23
+ if (userAgent === undefined)
24
+ return null;
25
+ const browser = BROWSER_PATTERNS.map(([name, pattern]) => {
26
+ const version = pattern.exec(userAgent)?.[1];
27
+ return version === undefined ? undefined : `${name} ${version}`;
28
+ }).find((summary) => summary !== undefined);
29
+ if (browser === undefined)
30
+ return null;
31
+ const os = OS_PATTERNS.find(([, pattern]) => pattern.test(userAgent))?.[0];
32
+ if (os === undefined)
33
+ return browser;
34
+ return `${browser} ${CONNECTOR_BY_LANGUAGE[languageOf(locale)] ?? "on"} ${os}`;
35
+ }
@@ -0,0 +1,3 @@
1
+ import type { UserDataDeleteHook, UserDataExportHook } from "@cosmicdrift/kumiko-framework/engine";
2
+ export declare const contactExportHook: UserDataExportHook;
3
+ export declare const contactDeleteHook: UserDataDeleteHook;
@@ -0,0 +1,129 @@
1
+ import { configuredPiiSubjectKms } from "@cosmicdrift/kumiko-framework/crypto";
2
+ import { createEventStoreExecutor } from "@cosmicdrift/kumiko-framework/db";
3
+ import { deleteStoredFileAndDerivatives } from "@cosmicdrift/kumiko-framework/derivatives";
4
+ import { SYSTEM_TENANT_ID } from "@cosmicdrift/kumiko-framework/engine";
5
+ import { InternalError } from "@cosmicdrift/kumiko-framework/errors";
6
+ import { fileRefEntity, fileRefsTable } from "@cosmicdrift/kumiko-framework/files";
7
+ import { collectErasureFailure, decryptStoredPii, throwIfErasureFailed } from "../shared/index.js";
8
+ import { userTable } from "../user/index.js";
9
+ import { normalizeEmail, platformActor, replyExecutor, requestExecutor } from "./lib.js";
10
+ import { CONTACT_REPLY_ENTITY, CONTACT_REQUEST_ENTITY, CONTACT_UPLOAD_FIELD, } from "./web/constants.js";
11
+ const PII_DECRYPT_REASON = "contact:user-data";
12
+ const ERASE_REASON = "contact:user-data-forget";
13
+ const LOOKUP_LIMIT = 200;
14
+ // Anonymous requests are matched by email, so the user must have proven they own it: otherwise
15
+ // registering with someone else's address would expose or erase that person's requests.
16
+ async function resolveVerifiedUserEmail(ctx) {
17
+ const row = await ctx.db.fetchOne(userTable, {
18
+ id: ctx.userId,
19
+ });
20
+ if (row?.emailVerified !== true)
21
+ return null;
22
+ if (ctx.userEmailBeforeDelete)
23
+ return normalizeEmail(ctx.userEmailBeforeDelete);
24
+ return normalizeEmail(await decryptStoredPii(row.email, "email", PII_DECRYPT_REASON));
25
+ }
26
+ async function findRequests(ctx) {
27
+ const byUser = await requestExecutor.list({ filter: { field: "reporterUserId", op: "eq", value: ctx.userId }, limit: LOOKUP_LIMIT }, platformActor(), ctx.db);
28
+ const email = await resolveVerifiedUserEmail(ctx);
29
+ const byEmail = email
30
+ ? await requestExecutor.list({ filter: { field: "email", op: "eq", value: email }, limit: LOOKUP_LIMIT }, platformActor(), ctx.db)
31
+ : { rows: [] };
32
+ const unique = new Map(byUser.rows.map((row) => [row.id, row]));
33
+ for (const row of byEmail.rows)
34
+ unique.set(row.id, row);
35
+ return [...unique.values()];
36
+ }
37
+ const fileRefExecutor = createEventStoreExecutor(fileRefsTable, fileRefEntity, {
38
+ entityName: "fileRef",
39
+ });
40
+ // Attachments are copied into the system tenant and bound to the request or reply row.
41
+ async function findAttachments(ctx, entity, id) {
42
+ return ctx.db.selectMany(fileRefsTable, {
43
+ tenantId: SYSTEM_TENANT_ID,
44
+ entityType: entity,
45
+ entityId: id,
46
+ fieldName: CONTACT_UPLOAD_FIELD,
47
+ });
48
+ }
49
+ // Bytes first, then the fileRef row: a crash in between leaves a row whose delete converges on the
50
+ // next run, never bytes without a row. A failing byte delete aborts, like the generic fileRef hook.
51
+ async function purgeAttachments(ctx, entity, id) {
52
+ const attachments = await findAttachments(ctx, entity, id);
53
+ // skip: a row without attachments has no bytes to erase and needs no storage provider
54
+ if (attachments.length === 0)
55
+ return;
56
+ const provider = await ctx.buildStorageProvider?.(SYSTEM_TENANT_ID);
57
+ if (!provider) {
58
+ throw new InternalError({
59
+ message: `[contact:user-data] no file storage resolvable, attachments of ${entity} ${id} cannot be erased`,
60
+ });
61
+ }
62
+ for (const attachment of attachments) {
63
+ const failed = await deleteStoredFileAndDerivatives(attachment.storageKey, provider, "contact:user-data");
64
+ if (failed.length > 0) {
65
+ throw new InternalError({
66
+ message: `[contact:user-data] ${failed.length} attachment byte delete(s) failed for ${entity} ${id}`,
67
+ });
68
+ }
69
+ }
70
+ const failures = [];
71
+ for (const attachment of attachments) {
72
+ collectErasureFailure(await fileRefExecutor.forget({ id: attachment.id }, platformActor(), ctx.db), "fileRef", attachment.id, failures);
73
+ }
74
+ throwIfErasureFailed(failures);
75
+ }
76
+ async function findReplies(ctx, requestId) {
77
+ const found = await replyExecutor.list({ filter: { field: "requestId", op: "eq", value: requestId }, limit: LOOKUP_LIMIT }, platformActor(), ctx.db);
78
+ return found.rows;
79
+ }
80
+ export const contactExportHook = async (ctx) => {
81
+ const requests = await findRequests(ctx);
82
+ if (requests.length === 0)
83
+ return null;
84
+ const rows = [];
85
+ for (const request of requests) {
86
+ const replies = await findReplies(ctx, request.id);
87
+ rows.push({
88
+ kind: request.kind,
89
+ status: request.status,
90
+ source: request.source,
91
+ subject: request.subject,
92
+ message: request.message,
93
+ name: request.name,
94
+ email: request.email,
95
+ phone: request.phone,
96
+ page: request.page,
97
+ submittedAt: String(request.submittedAt),
98
+ attachments: (await findAttachments(ctx, CONTACT_REQUEST_ENTITY, request.id)).map((file) => file.fileName),
99
+ replies: replies.map((reply) => ({
100
+ message: reply.message,
101
+ authorName: reply.authorName,
102
+ sentAt: String(reply.sentAt),
103
+ })),
104
+ });
105
+ }
106
+ return { entity: CONTACT_REQUEST_ENTITY, rows };
107
+ };
108
+ // Requests and replies carry no statutory retention duty, so both strategies erase: rows are
109
+ // purged through the executor (replays on rebuild) and the record subject keys are shredded so
110
+ // the event log's ciphertext becomes unreadable. Replies go with their request.
111
+ export const contactDeleteHook = async (ctx) => {
112
+ const kms = configuredPiiSubjectKms();
113
+ const failures = [];
114
+ const erase = async (entity, id, forgotten) => {
115
+ collectErasureFailure(forgotten, entity, id, failures);
116
+ if (forgotten.isSuccess && kms) {
117
+ await kms.eraseKey({ kind: "record", entity, id }, { requestId: ERASE_REASON, userId: ctx.userId, eraseReason: ERASE_REASON });
118
+ }
119
+ };
120
+ for (const request of await findRequests(ctx)) {
121
+ for (const reply of await findReplies(ctx, request.id)) {
122
+ await purgeAttachments(ctx, CONTACT_REPLY_ENTITY, reply.id);
123
+ await erase(CONTACT_REPLY_ENTITY, reply.id, await replyExecutor.forget({ id: reply.id }, platformActor(), ctx.db));
124
+ }
125
+ await purgeAttachments(ctx, CONTACT_REQUEST_ENTITY, request.id);
126
+ await erase(CONTACT_REQUEST_ENTITY, request.id, await requestExecutor.forget({ id: request.id }, platformActor(), ctx.db));
127
+ }
128
+ throwIfErasureFailed(failures);
129
+ };