@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,145 @@
1
+ import { buildEntityTable } from "@cosmicdrift/kumiko-framework/db";
2
+ import { createEntity, createFilesField, createLongTextField, createNumberField, createSelectField, createTextField, createTimestampField, } from "@cosmicdrift/kumiko-framework/engine";
3
+ import { DEFAULT_RETENTION_KEEP_FOR } from "./options.js";
4
+ import { CONTACT_KIND, CONTACT_MAX_FILES, CONTACT_REPLY_CHANNELS, CONTACT_SOURCE, CONTACT_STATUS, } from "./web/constants.js";
5
+ const KIND_OPTIONS = [
6
+ CONTACT_KIND.Question,
7
+ CONTACT_KIND.Contact,
8
+ CONTACT_KIND.Bug,
9
+ CONTACT_KIND.Wish,
10
+ ];
11
+ const STATUS_OPTIONS = [CONTACT_STATUS.Open, CONTACT_STATUS.Answered, CONTACT_STATUS.Done];
12
+ const SOURCE_OPTIONS = [CONTACT_SOURCE.Website, CONTACT_SOURCE.Admin];
13
+ const REPLY_CHANNEL_OPTIONS = [
14
+ CONTACT_REPLY_CHANNELS.Email,
15
+ CONTACT_REPLY_CHANNELS.EmailAndInApp,
16
+ ];
17
+ // A signed-in reporter is the data subject; an anonymous reporter has no user id, so the row
18
+ // itself is the crypto-shredding subject.
19
+ const REPORTER_SUBJECT = { of: "reporterUserId", whenAbsent: "self" };
20
+ const MAX_FILE_SIZE = "10MB";
21
+ export function createContactRequestEntity(retentionKeepFor = DEFAULT_RETENTION_KEEP_FOR) {
22
+ return createEntity({
23
+ table: "read_contact_requests",
24
+ description: "A message from a website visitor or a signed-in user to the platform operators (question, contact request, bug report or wish), tracked through open, answered and done as SystemAdmins process it; name, email, phone, subject and message are the reporter's personal data.",
25
+ systemStream: true,
26
+ tenancy: "global",
27
+ retention: { keepFor: retentionKeepFor, strategy: "hardDelete", reference: "submittedAt" },
28
+ fields: {
29
+ kind: createSelectField({
30
+ options: KIND_OPTIONS,
31
+ required: true,
32
+ filterable: true,
33
+ sortable: true,
34
+ optionTones: {
35
+ [CONTACT_KIND.Bug]: "bad",
36
+ [CONTACT_KIND.Question]: "accent",
37
+ [CONTACT_KIND.Contact]: "accent",
38
+ [CONTACT_KIND.Wish]: "neutral",
39
+ },
40
+ }),
41
+ status: createSelectField({
42
+ options: STATUS_OPTIONS,
43
+ required: true,
44
+ default: CONTACT_STATUS.Open,
45
+ filterable: true,
46
+ sortable: true,
47
+ optionTones: {
48
+ [CONTACT_STATUS.Open]: "warn",
49
+ [CONTACT_STATUS.Answered]: "accent",
50
+ [CONTACT_STATUS.Done]: "ok",
51
+ },
52
+ }),
53
+ source: createSelectField({
54
+ options: SOURCE_OPTIONS,
55
+ required: true,
56
+ filterable: true,
57
+ }),
58
+ subject: createTextField({
59
+ required: true,
60
+ personal: REPORTER_SUBJECT,
61
+ find: "none",
62
+ searchable: true,
63
+ }),
64
+ message: createLongTextField({ required: true, personal: REPORTER_SUBJECT, find: "none" }),
65
+ name: createTextField({
66
+ required: true,
67
+ personal: REPORTER_SUBJECT,
68
+ find: "fuzzy",
69
+ searchable: true,
70
+ }),
71
+ email: createTextField({
72
+ required: true,
73
+ personal: REPORTER_SUBJECT,
74
+ find: "fuzzy",
75
+ searchable: true,
76
+ }),
77
+ phone: createTextField({ personal: REPORTER_SUBJECT, find: "none" }),
78
+ reporterUserId: createTextField({ personal: false, reason: "pseudonymous_fk" }),
79
+ // Not named tenantId: that is the framework's physical tenant column.
80
+ reporterTenantId: createTextField({ personal: false, reason: "is_tenant_reference" }),
81
+ reporterTenantName: createTextField({ personal: false, reason: "is_business_data" }),
82
+ reporterTenantPlan: createTextField({ personal: false, reason: "is_business_data" }),
83
+ page: createTextField({ personal: false, reason: "is_page_path" }),
84
+ appVersion: createTextField({ personal: false, reason: "is_app_build_version" }),
85
+ browser: createTextField({ personal: false, reason: "is_browser_summary" }),
86
+ locale: createTextField({ personal: false, reason: "is_ui_language_preference" }),
87
+ fileIds: createFilesField({
88
+ maxCount: CONTACT_MAX_FILES,
89
+ maxSize: MAX_FILE_SIZE,
90
+ personal: REPORTER_SUBJECT,
91
+ }),
92
+ fileCount: createNumberField({ default: 0 }),
93
+ submittedAt: createTimestampField({
94
+ personal: false,
95
+ sortable: true,
96
+ required: true,
97
+ reason: "is_submission_timestamp",
98
+ }),
99
+ answeredAt: createTimestampField(),
100
+ closedAt: createTimestampField(),
101
+ replyCount: createNumberField({ default: 0 }),
102
+ },
103
+ });
104
+ }
105
+ export function createContactReplyEntity(retentionKeepFor = DEFAULT_RETENTION_KEEP_FOR) {
106
+ return createEntity({
107
+ table: "read_contact_replies",
108
+ description: "A SystemAdmin's answer to a contact request, with the channels it went out on; the message is the reporter's personal data because it quotes and addresses them.",
109
+ systemStream: true,
110
+ tenancy: "global",
111
+ retention: { keepFor: retentionKeepFor, strategy: "hardDelete", reference: "sentAt" },
112
+ fields: {
113
+ requestId: createTextField({
114
+ required: true,
115
+ personal: false,
116
+ reason: "technical_reference",
117
+ }),
118
+ reporterUserId: createTextField({ personal: false, reason: "pseudonymous_fk" }),
119
+ message: createLongTextField({ required: true, personal: REPORTER_SUBJECT, find: "none" }),
120
+ authorUserId: createTextField({
121
+ required: true,
122
+ personal: false,
123
+ reason: "is_admin_audit_id",
124
+ }),
125
+ authorName: createTextField({ required: true, personal: false, reason: "is_admin_label" }),
126
+ fileIds: createFilesField({
127
+ maxCount: CONTACT_MAX_FILES,
128
+ maxSize: MAX_FILE_SIZE,
129
+ personal: false,
130
+ reason: "is_business_data",
131
+ }),
132
+ channels: createSelectField({ options: REPLY_CHANNEL_OPTIONS, required: true }),
133
+ sentAt: createTimestampField({
134
+ personal: false,
135
+ sortable: true,
136
+ required: true,
137
+ reason: "is_submission_timestamp",
138
+ }),
139
+ },
140
+ });
141
+ }
142
+ export const contactRequestEntity = createContactRequestEntity();
143
+ export const contactReplyEntity = createContactReplyEntity();
144
+ export const contactRequestTable = buildEntityTable("contact-request", contactRequestEntity);
145
+ export const contactReplyTable = buildEntityTable("contact-reply", contactReplyEntity);
@@ -0,0 +1,3 @@
1
+ import { type FeatureDefinition } from "@cosmicdrift/kumiko-framework/engine";
2
+ import { type ContactOptions } from "./options.ts";
3
+ export declare function createContactFeature(opts: ContactOptions): FeatureDefinition;
@@ -0,0 +1,134 @@
1
+ import { access, createSystemConfig, defineFeature, EXT_USER_DATA, } from "@cosmicdrift/kumiko-framework/engine";
2
+ import { CONTACT_CLIENT_SOURCE } from "./client/contact-client-source.js";
3
+ import { contactReplyEntity, contactRequestEntity, createContactReplyEntity, createContactRequestEntity, } from "./entity.js";
4
+ import { createChallengeQuery } from "./handlers/challenge.query.js";
5
+ import { createForwardRequestHandler } from "./handlers/forward-request.write.js";
6
+ import { markDoneHandler } from "./handlers/mark-done.write.js";
7
+ import { notifyReporterInAppHandler } from "./handlers/notify-reporter-in-app.write.js";
8
+ import { openCountQuery } from "./handlers/open-count.query.js";
9
+ import { repliesQuery } from "./handlers/replies.query.js";
10
+ import { createReplyHandler } from "./handlers/reply.write.js";
11
+ import { createReportHandler } from "./handlers/report.write.js";
12
+ import { createRequestDeliveryQuery } from "./handlers/request-delivery.query.js";
13
+ import { createRequestDetailQuery } from "./handlers/request-detail.query.js";
14
+ import { createRequestListQuery } from "./handlers/request-list.query.js";
15
+ import { createSendReplyMailHandler } from "./handlers/send-reply-mail.write.js";
16
+ import { createSendTestHandler } from "./handlers/send-test.write.js";
17
+ import { createSubmitHandler } from "./handlers/submit.write.js";
18
+ import { createContactI18n } from "./i18n.js";
19
+ import { TELEGRAM_FEATURE } from "./lib.js";
20
+ import { CONTACT_ACKNOWLEDGEMENT_VARIABLES, CONTACT_CONFIRMATION_VARIABLES, CONTACT_NEW_REQUEST_VARIABLES, CONTACT_REPLY_VARIABLES, CONTACT_TEST_VARIABLES, contactAcknowledgementTemplate, contactConfirmationTemplate, contactNewRequestTemplate, contactReplyTemplate, contactTestTemplate, inAppTemplate, telegramTemplate, } from "./mail.js";
21
+ import { DEFAULT_RETENTION_KEEP_FOR, resolveContactSettings, } from "./options.js";
22
+ import { createContactScreens } from "./screens.js";
23
+ import { contactDeleteHook, contactExportHook } from "./user-data-hooks.js";
24
+ import { CONTACT_FEATURE } from "./web/constants.js";
25
+ const REPLY_CONTEXT_FIELDS = ["name", "email", "replyTo"];
26
+ export function createContactFeature(opts) {
27
+ const settings = resolveContactSettings(opts);
28
+ const telegram = opts.telegram === true;
29
+ const keepFor = opts.retentionKeepFor ?? DEFAULT_RETENTION_KEEP_FOR;
30
+ const requestEntity = keepFor === DEFAULT_RETENTION_KEEP_FOR
31
+ ? contactRequestEntity
32
+ : createContactRequestEntity(keepFor);
33
+ const replyEntity = keepFor === DEFAULT_RETENTION_KEEP_FOR ? contactReplyEntity : createContactReplyEntity(keepFor);
34
+ return defineFeature(CONTACT_FEATURE, (r) => {
35
+ r.describe("Contact inbox: an anonymous browser client (GET /contact/client.js) submits questions, contact requests, bug reports and wishes behind a honeypot, a minimum submit time and a single-use proof-of-work challenge; signed-in users file reports from the admin. Every request is stored platform-wide and every SystemAdmin is notified by mail, optionally also in a Telegram chat (option `telegram`, off by default); the notification names only the kind, the app and a link, never name, address, phone, subject or message, because mail and Telegram cannot be shredded. SystemAdmins reply by mail (Reply-To set, attachments, quoting the original) and mark requests done; a website sender gets a fixed acknowledgement, a signed-in reporter a copy and an in-app note. Personal data is crypto-shredding-ready and the EXT_USER_DATA hooks export and erase a user's requests.");
36
+ r.uiHints({ displayLabel: "Contact", category: "communication", recommended: false });
37
+ r.systemScope();
38
+ r.requires({ features: ["config", "delivery", "user-data-rights", "files", "notes-history"] });
39
+ // The feature manifest and reference are built from one mounted instance, so the off
40
+ // default still names Telegram as an optional dependency.
41
+ if (telegram)
42
+ r.requires({ features: [TELEGRAM_FEATURE] });
43
+ else
44
+ r.optionalRequires(TELEGRAM_FEATURE);
45
+ r.adoptsBundledLists();
46
+ r.translations({ keys: createContactI18n() });
47
+ r.config({
48
+ keys: {
49
+ replyTo: createSystemConfig("text", {
50
+ default: "",
51
+ write: access.systemAdmin,
52
+ read: access.systemAdmin,
53
+ pattern: { regex: "^$|^[^\\s@<>]{1,64}@[^\\s@<>]{1,200}\\.[^\\s@<>]{2,24}$" },
54
+ }),
55
+ },
56
+ });
57
+ if (telegram) {
58
+ r.config({
59
+ keys: {
60
+ telegramChat: createSystemConfig("text", {
61
+ default: "",
62
+ write: access.systemAdmin,
63
+ read: access.systemAdmin,
64
+ pattern: { regex: "^$|^(-?[0-9]{1,20}|@[A-Za-z0-9_]{5,32})$" },
65
+ }),
66
+ },
67
+ });
68
+ }
69
+ r.notification("new-request", {
70
+ variables: CONTACT_NEW_REQUEST_VARIABLES,
71
+ localizedTemplate: contactNewRequestTemplate,
72
+ ...(telegram && { templates: { telegram: telegramTemplate } }),
73
+ });
74
+ r.notification("confirmation", {
75
+ variables: CONTACT_CONFIRMATION_VARIABLES,
76
+ localizedTemplate: contactConfirmationTemplate,
77
+ });
78
+ r.notification("acknowledgement", {
79
+ variables: CONTACT_ACKNOWLEDGEMENT_VARIABLES,
80
+ localizedTemplate: contactAcknowledgementTemplate,
81
+ });
82
+ r.notification("reply", {
83
+ variables: CONTACT_REPLY_VARIABLES,
84
+ localizedTemplate: contactReplyTemplate,
85
+ });
86
+ r.notification("reply-in-app", { templates: { inApp: inAppTemplate } });
87
+ if (telegram) {
88
+ r.notification("test", {
89
+ variables: CONTACT_TEST_VARIABLES,
90
+ localizedTemplate: contactTestTemplate,
91
+ templates: { telegram: telegramTemplate },
92
+ });
93
+ }
94
+ r.entity({ name: "contact-request", ...requestEntity });
95
+ r.entity({ name: "contact-reply", ...replyEntity });
96
+ r.writeHandler(createSubmitHandler(opts, settings));
97
+ r.writeHandler(createReportHandler(opts, settings));
98
+ r.writeHandler(createForwardRequestHandler(opts));
99
+ // The detail drawer prefills these for the form summary only; the form never sends them.
100
+ r.writeHandler({ ...createReplyHandler(), excludedFields: REPLY_CONTEXT_FIELDS });
101
+ r.writeHandler(createSendReplyMailHandler(opts));
102
+ r.writeHandler(notifyReporterInAppHandler);
103
+ r.writeHandler(markDoneHandler);
104
+ if (telegram)
105
+ r.writeHandler(createSendTestHandler(opts));
106
+ r.queryHandler(createChallengeQuery(settings));
107
+ r.queryHandler(openCountQuery);
108
+ r.queryHandler(createRequestListQuery(requestEntity));
109
+ r.queryHandler(createRequestDetailQuery(opts));
110
+ r.queryHandler(repliesQuery);
111
+ r.queryHandler(createRequestDeliveryQuery(opts));
112
+ for (const screen of createContactScreens(opts, settings))
113
+ r.screen(screen);
114
+ r.httpRoute({
115
+ method: "GET",
116
+ // A literal, not CONTACT_CLIENT_PATH: the feature-AST extractor only reads string literals.
117
+ path: "/contact/client.js",
118
+ anonymous: true,
119
+ handler: async (c) => c.body(CONTACT_CLIENT_SOURCE, 200, {
120
+ "content-type": "application/javascript; charset=utf-8",
121
+ "cache-control": "public, max-age=300",
122
+ }),
123
+ });
124
+ r.useExtension(EXT_USER_DATA, "contact-request", {
125
+ export: contactExportHook,
126
+ delete: contactDeleteHook,
127
+ });
128
+ // Replies are exported nested under their request and erased with it (contactDeleteHook).
129
+ r.useExtension(EXT_USER_DATA, "contact-reply", {
130
+ export: async () => null,
131
+ delete: async () => { },
132
+ });
133
+ });
134
+ }
@@ -0,0 +1,7 @@
1
+ export declare const SUBMIT_ROLES: readonly string[];
2
+ export declare const REPORT_ACCESS: {
3
+ readonly openToAll: {
4
+ readonly reason: "every signed-in user may report a problem; name, email and tenant come from the session and the request is bound to the caller's own userId";
5
+ readonly personalData: "tenant-members";
6
+ };
7
+ };
@@ -0,0 +1,9 @@
1
+ import { access } from "@cosmicdrift/kumiko-framework/engine";
2
+ // The website client sends without a session (credentials: "omit"), so it arrives as anonymous; other callers that carry a session pass through anySignedIn on the handlers.
3
+ export const SUBMIT_ROLES = access.roles(...access.anonymous, ...access.authenticated, "Member", "TenantAdmin");
4
+ export const REPORT_ACCESS = {
5
+ openToAll: {
6
+ reason: "every signed-in user may report a problem; name, email and tenant come from the session and the request is bound to the caller's own userId",
7
+ personalData: "tenant-members",
8
+ },
9
+ };
@@ -0,0 +1,14 @@
1
+ import { type HandlerContext, type SessionUser, type TenantId } from "@cosmicdrift/kumiko-framework/engine";
2
+ import { Temporal } from "@cosmicdrift/kumiko-types/temporal";
3
+ import * as z from "zod";
4
+ declare const attemptSchema: z.ZodObject<{
5
+ key: z.ZodString;
6
+ channel: z.ZodString;
7
+ recipientId: z.ZodNullable<z.ZodString>;
8
+ status: z.ZodString;
9
+ createdAt: z.ZodCustom<globalThis.Temporal.Instant, globalThis.Temporal.Instant>;
10
+ }, z.core.$strip>;
11
+ export type ContactAttempt = z.infer<typeof attemptSchema>;
12
+ export declare function loadAttemptsByKey(ctx: Pick<HandlerContext, "dispatch">, user: SessionUser, keys: readonly string[]): Promise<readonly ContactAttempt[]>;
13
+ export declare function loadReadAtByKey(ctx: Pick<HandlerContext, "dispatch" | "registry">, reporterTenantId: TenantId, keys: readonly string[]): Promise<ReadonlyMap<string, Temporal.Instant | null>>;
14
+ export {};
@@ -0,0 +1,54 @@
1
+ import { createSystemUser, } from "@cosmicdrift/kumiko-framework/engine";
2
+ import { IN_APP_NOTIFICATION_QUERIES } from "@cosmicdrift/kumiko-types/in-app-notification-types";
3
+ import { Temporal } from "@cosmicdrift/kumiko-types/temporal";
4
+ import * as z from "zod";
5
+ import { DeliveryQueries } from "../../delivery/index.js";
6
+ import { SYSTEM_ADMIN_ROLE } from "../lib.js";
7
+ // Both queries accept at most this many keys per call.
8
+ const MAX_KEYS_PER_QUERY = 50;
9
+ const instant = z.custom((value) => value instanceof Temporal.Instant);
10
+ const attemptSchema = z.object({
11
+ key: z.string(),
12
+ channel: z.string(),
13
+ recipientId: z.string().nullable(),
14
+ status: z.string(),
15
+ createdAt: instant,
16
+ });
17
+ const attemptsResultSchema = z.object({ rows: z.array(attemptSchema) });
18
+ const readStateResultSchema = z.object({
19
+ rows: z.array(z.object({ key: z.string(), readAt: instant.nullable() })),
20
+ });
21
+ function chunked(keys) {
22
+ const chunks = [];
23
+ for (let start = 0; start < keys.length; start += MAX_KEYS_PER_QUERY) {
24
+ chunks.push(keys.slice(start, start + MAX_KEYS_PER_QUERY));
25
+ }
26
+ return chunks;
27
+ }
28
+ export async function loadAttemptsByKey(ctx, user, keys) {
29
+ const rows = [];
30
+ for (const chunk of chunked(keys)) {
31
+ const result = await ctx.dispatch.queryAs(user, DeliveryQueries.attemptsByKeys, {
32
+ keys: chunk,
33
+ });
34
+ rows.push(...attemptsResultSchema.parse(result).rows);
35
+ }
36
+ return rows;
37
+ }
38
+ // The in-app notes of a request live in the reporter's tenant, so the read state is asked there.
39
+ // Empty when channel-in-app is not mounted: nothing can have been read then.
40
+ export async function loadReadAtByKey(ctx, reporterTenantId, keys) {
41
+ const readAtByKey = new Map();
42
+ if (ctx.registry.getQueryHandler(IN_APP_NOTIFICATION_QUERIES.readStateByKeys) === undefined) {
43
+ return readAtByKey;
44
+ }
45
+ const user = createSystemUser(reporterTenantId, [SYSTEM_ADMIN_ROLE]);
46
+ for (const chunk of chunked(keys)) {
47
+ const result = await ctx.dispatch.queryAs(user, IN_APP_NOTIFICATION_QUERIES.readStateByKeys, {
48
+ keys: chunk,
49
+ });
50
+ for (const row of readStateResultSchema.parse(result).rows)
51
+ readAtByKey.set(row.key, row.readAt);
52
+ }
53
+ return readAtByKey;
54
+ }
@@ -0,0 +1,9 @@
1
+ import { type ContactSettings } from "../options.ts";
2
+ import { type ContactPhoneMode } from "../web/constants.ts";
3
+ export type ContactChallengeData = {
4
+ readonly challenge: string;
5
+ readonly bits: number;
6
+ readonly phone: ContactPhoneMode;
7
+ readonly kinds: readonly string[];
8
+ };
9
+ export declare function createChallengeQuery(settings: ContactSettings): import("@cosmicdrift/kumiko-types/define-handler").QueryHandlerDefinition<"challenge", import("zod").ZodObject<{}, import("zod/v4/core").$strict>, ContactChallengeData, import("@cosmicdrift/kumiko-types/event-type-map").KumikoEventTypeMap>;
@@ -0,0 +1,35 @@
1
+ import { defineQueryHandler } from "@cosmicdrift/kumiko-framework/engine";
2
+ import { InternalError } from "@cosmicdrift/kumiko-framework/errors";
3
+ import { issueChallenge } from "../challenge.js";
4
+ import { CHALLENGE_RATE_LIMIT } from "../options.js";
5
+ import { ContactEmptySchema } from "../payloads.js";
6
+ import { CONTACT_WEBSITE_KINDS } from "../web/constants.js";
7
+ import { SUBMIT_ROLES } from "./access.js";
8
+ export function createChallengeQuery(settings) {
9
+ return defineQueryHandler({
10
+ name: "challenge",
11
+ schema: ContactEmptySchema,
12
+ access: { roles: SUBMIT_ROLES, personalData: "public-intake", anySignedIn: true },
13
+ rateLimit: CHALLENGE_RATE_LIMIT,
14
+ agent: { expose: false },
15
+ description: "Public contact form bootstrap: issues a single-use proof-of-work challenge and reports which fields the form shows (phone mode, request kinds).",
16
+ handler: async (_event, ctx) => {
17
+ if (!ctx.services.redis) {
18
+ throw new InternalError({
19
+ message: "contact:challenge requires ctx.services.redis for the challenge store",
20
+ });
21
+ }
22
+ const challenge = await issueChallenge(ctx.services.redis, {
23
+ bits: settings.proofOfWorkBits,
24
+ ttlSeconds: settings.challengeTtlSeconds,
25
+ nowMs: ctx.tz.now().epochMilliseconds,
26
+ });
27
+ return {
28
+ challenge,
29
+ bits: settings.proofOfWorkBits,
30
+ phone: settings.phone,
31
+ kinds: CONTACT_WEBSITE_KINDS,
32
+ };
33
+ },
34
+ });
35
+ }
@@ -0,0 +1,9 @@
1
+ import type { ContactOptions } from "../options.ts";
2
+ export type ContactForwardData = {
3
+ readonly kind: "forwarded";
4
+ readonly adminCount: number;
5
+ readonly telegram: boolean;
6
+ };
7
+ export declare function createForwardRequestHandler(opts: ContactOptions): import("@cosmicdrift/kumiko-types/define-handler").WriteHandlerDefinition<"forward-request", import("zod").ZodObject<{
8
+ requestId: import("zod").ZodUUID;
9
+ }, import("zod/v4/core").$strict>, ContactForwardData, import("@cosmicdrift/kumiko-types/event-type-map").KumikoEventTypeMap, undefined, undefined>;
@@ -0,0 +1,61 @@
1
+ import { defineWriteHandler } from "@cosmicdrift/kumiko-framework/engine";
2
+ import { NotFoundError, writeFailure } from "@cosmicdrift/kumiko-framework/errors";
3
+ import { contactDb, internalAccess, listSystemAdminIds, platformActor, requestExecutor, sendBestEffort, } from "../lib.js";
4
+ import { contactNewRequestVariables, resolveContactMailLocale } from "../mail.js";
5
+ import { ContactForwardRequestSchema } from "../payloads.js";
6
+ import { CONTACT_NOTIFICATION_TYPES, CONTACT_REQUEST_ENTITY, ContactConfigKeys, contactIdempotencyKeys, } from "../web/constants.js";
7
+ const EMAIL_CHANNEL = "email";
8
+ // Runs as the platform identity so the notification, the config and the bot token secret are
9
+ // read in the system tenant, whoever filed the request.
10
+ export function createForwardRequestHandler(opts) {
11
+ return defineWriteHandler({
12
+ name: "forward-request",
13
+ schema: ContactForwardRequestSchema,
14
+ access: internalAccess,
15
+ agent: { expose: false },
16
+ description: "Internal: forwards a stored contact request to every SystemAdmin by mail and, when a Telegram chat is configured, to that chat. Only the platform identity can call it.",
17
+ handler: async (event, ctx) => {
18
+ const db = contactDb(ctx);
19
+ const request = await requestExecutor.detail({ id: event.payload.requestId }, platformActor(), db);
20
+ if (!request) {
21
+ return writeFailure(new NotFoundError(CONTACT_REQUEST_ENTITY, event.payload.requestId));
22
+ }
23
+ const requestId = event.payload.requestId;
24
+ const adminLocale = opts.adminLocale;
25
+ const link = opts.requestLink?.(requestId);
26
+ const data = contactNewRequestVariables({
27
+ kind: request.kind,
28
+ appName: opts.appName,
29
+ link,
30
+ locale: adminLocale,
31
+ });
32
+ const adminIds = await listSystemAdminIds(db);
33
+ if (adminIds.length > 0) {
34
+ await sendBestEffort(ctx, "admin mail", (notify) => notify(CONTACT_NOTIFICATION_TYPES.newRequest, {
35
+ to: adminIds,
36
+ channels: [EMAIL_CHANNEL],
37
+ data,
38
+ idempotencyKey: contactIdempotencyKeys.admins(requestId),
39
+ priority: "normal",
40
+ locale: resolveContactMailLocale(adminLocale),
41
+ }));
42
+ }
43
+ const chatId = opts.telegram ? await ctx.config?.(ContactConfigKeys.telegramChat) : undefined;
44
+ const telegram = opts.telegram === true && typeof chatId === "string" && chatId.trim() !== "";
45
+ if (telegram) {
46
+ await sendBestEffort(ctx, "telegram", (notify) => notify(CONTACT_NOTIFICATION_TYPES.newRequest, {
47
+ route: { telegram: chatId.trim() },
48
+ recipientId: requestId,
49
+ data,
50
+ idempotencyKey: contactIdempotencyKeys.telegram(requestId),
51
+ priority: "normal",
52
+ locale: resolveContactMailLocale(adminLocale),
53
+ }));
54
+ }
55
+ return {
56
+ isSuccess: true,
57
+ data: { kind: "forwarded", adminCount: adminIds.length, telegram },
58
+ };
59
+ },
60
+ });
61
+ }
@@ -0,0 +1,7 @@
1
+ export type ContactMarkDoneData = {
2
+ readonly kind: "marked";
3
+ readonly changed: number;
4
+ };
5
+ export declare const markDoneHandler: import("@cosmicdrift/kumiko-types/define-handler").WriteHandlerDefinition<"mark-done", import("zod").ZodObject<{
6
+ id: import("zod").ZodUUID;
7
+ }, import("zod/v4/core").$strict>, ContactMarkDoneData, import("@cosmicdrift/kumiko-types/event-type-map").KumikoEventTypeMap, undefined, undefined>;
@@ -0,0 +1,30 @@
1
+ import { defineWriteHandler } from "@cosmicdrift/kumiko-framework/engine";
2
+ import { NotFoundError, writeFailure } from "@cosmicdrift/kumiko-framework/errors";
3
+ import { adminAccess, contactDb, platformActor, requestExecutor } from "../lib.js";
4
+ import { ContactMarkDoneSchema } from "../payloads.js";
5
+ import { CONTACT_REQUEST_ENTITY, CONTACT_STATUS } from "../web/constants.js";
6
+ export const markDoneHandler = defineWriteHandler({
7
+ name: "mark-done",
8
+ schema: ContactMarkDoneSchema,
9
+ access: adminAccess,
10
+ agent: { expose: false },
11
+ description: "Marks one contact request as done without sending a reply; a finished request is left as it is.",
12
+ handler: async (event, ctx) => {
13
+ const db = contactDb(ctx);
14
+ const { id } = event.payload;
15
+ const request = await requestExecutor.detail({ id }, platformActor(), db);
16
+ if (!request)
17
+ return writeFailure(new NotFoundError(CONTACT_REQUEST_ENTITY, id));
18
+ if (request.status === CONTACT_STATUS.Done) {
19
+ return { isSuccess: true, data: { kind: "marked", changed: 0 } };
20
+ }
21
+ const updated = await requestExecutor.update({
22
+ id,
23
+ version: request.version,
24
+ changes: { status: CONTACT_STATUS.Done, closedAt: ctx.tz.now() },
25
+ }, platformActor(), db);
26
+ if (!updated.isSuccess)
27
+ return updated;
28
+ return { isSuccess: true, data: { kind: "marked", changed: 1 } };
29
+ },
30
+ });
@@ -0,0 +1,10 @@
1
+ export type ContactNotifyReporterData = {
2
+ readonly kind: "notified" | "skipped";
3
+ };
4
+ export declare const notifyReporterInAppHandler: import("@cosmicdrift/kumiko-types/define-handler").WriteHandlerDefinition<"notify-reporter-in-app", import("zod").ZodObject<{
5
+ replyId: import("zod").ZodUUID;
6
+ requestId: import("zod").ZodUUID;
7
+ userId: import("zod").ZodUUID;
8
+ authorName: import("zod").ZodString;
9
+ locale: import("zod").ZodOptional<import("zod").ZodString>;
10
+ }, import("zod/v4/core").$strict>, ContactNotifyReporterData, import("@cosmicdrift/kumiko-types/event-type-map").KumikoEventTypeMap, undefined, undefined>;
@@ -0,0 +1,36 @@
1
+ import { fetchOne } from "@cosmicdrift/kumiko-framework/db";
2
+ import { defineWriteHandler } from "@cosmicdrift/kumiko-framework/engine";
3
+ import { tenantMembershipsTable } from "../../tenant/index.js";
4
+ import { contactDb, IN_APP_FEATURE, internalAccess, sendBestEffort } from "../lib.js";
5
+ import { contactReplyInAppData, resolveContactMailLocale } from "../mail.js";
6
+ import { ContactNotifyReporterInAppSchema } from "../payloads.js";
7
+ import { CONTACT_NOTIFICATION_TYPES, contactIdempotencyKeys } from "../web/constants.js";
8
+ // Runs as the platform identity of the reporter's tenant, so the in-app note lands in that
9
+ // tenant's inbox. The note names the author only; the answer itself goes by mail.
10
+ export const notifyReporterInAppHandler = defineWriteHandler({
11
+ name: "notify-reporter-in-app",
12
+ schema: ContactNotifyReporterInAppSchema,
13
+ access: internalAccess,
14
+ agent: { expose: false },
15
+ description: "Internal: adds an in-app note about a contact reply to a signed-in reporter in the reporter's own tenant; skipped when the reporter is no longer a member or in-app delivery is not mounted.",
16
+ handler: async (event, ctx) => {
17
+ const { userId, replyId, authorName, locale } = event.payload;
18
+ if (!(await ctx.hasFeature(IN_APP_FEATURE)))
19
+ return { isSuccess: true, data: { kind: "skipped" } };
20
+ const membership = await fetchOne(contactDb(ctx), tenantMembershipsTable, {
21
+ userId,
22
+ tenantId: event.user.tenantId,
23
+ });
24
+ if (!membership)
25
+ return { isSuccess: true, data: { kind: "skipped" } };
26
+ await sendBestEffort(ctx, "reply in-app note", (notify) => notify(CONTACT_NOTIFICATION_TYPES.replyInApp, {
27
+ route: { inApp: userId },
28
+ recipientId: userId,
29
+ data: contactReplyInAppData({ authorName, locale }),
30
+ idempotencyKey: contactIdempotencyKeys.replyInApp(replyId),
31
+ priority: "normal",
32
+ locale: resolveContactMailLocale(locale),
33
+ }));
34
+ return { isSuccess: true, data: { kind: "notified" } };
35
+ },
36
+ });
@@ -0,0 +1,2 @@
1
+ import type { TenantDb } from "@cosmicdrift/kumiko-framework/db";
2
+ export declare function countOpenRequests(db: TenantDb): Promise<number>;
@@ -0,0 +1,11 @@
1
+ import { platformActor, requestExecutor } from "../lib.js";
2
+ import { CONTACT_STATUS } from "../web/constants.js";
3
+ // Open means no answer yet; an answered request counts as handled even before it is marked done.
4
+ export async function countOpenRequests(db) {
5
+ const found = await requestExecutor.list({
6
+ filter: { field: "status", op: "eq", value: CONTACT_STATUS.Open },
7
+ limit: 1,
8
+ totalCount: true,
9
+ }, platformActor(), db);
10
+ return found.total ?? 0;
11
+ }
@@ -0,0 +1,3 @@
1
+ export declare const openCountQuery: import("@cosmicdrift/kumiko-types/define-handler").QueryHandlerDefinition<"open-count", import("zod").ZodObject<{}, import("zod/v4/core").$strict>, {
2
+ count: number;
3
+ }, import("@cosmicdrift/kumiko-types/event-type-map").KumikoEventTypeMap>;
@@ -0,0 +1,13 @@
1
+ import { defineQueryHandler } from "@cosmicdrift/kumiko-framework/engine";
2
+ import { adminAccess, contactDb } from "../lib.js";
3
+ import { ContactEmptySchema } from "../payloads.js";
4
+ import { countOpenRequests } from "./open-count.js";
5
+ export const openCountQuery = defineQueryHandler({
6
+ name: "open-count",
7
+ schema: ContactEmptySchema,
8
+ access: adminAccess,
9
+ description: "Counts the contact requests that still wait for a first answer, for the dashboard tile.",
10
+ handler: async (_event, ctx) => {
11
+ return { count: await countOpenRequests(contactDb(ctx)) };
12
+ },
13
+ });
@@ -0,0 +1,11 @@
1
+ export declare const repliesQuery: import("@cosmicdrift/kumiko-types/define-handler").QueryHandlerDefinition<"replies", import("zod").ZodObject<{
2
+ id: import("zod").ZodUUID;
3
+ }, import("zod/v4/core").$strict>, {
4
+ rows: {
5
+ id: string;
6
+ sentAt: string;
7
+ authorName: string;
8
+ message: string;
9
+ }[];
10
+ nextCursor: null;
11
+ }, import("@cosmicdrift/kumiko-types/event-type-map").KumikoEventTypeMap>;