@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,28 @@
1
+ import { defineQueryHandler } from "@cosmicdrift/kumiko-framework/engine";
2
+ import { NotFoundError } from "@cosmicdrift/kumiko-framework/errors";
3
+ import { adminAccess, contactDb, listRepliesOf, platformActor, requestExecutor } from "../lib.js";
4
+ import { ContactIdSchema } from "../payloads.js";
5
+ import { CONTACT_REQUEST_ENTITY } from "../web/constants.js";
6
+ export const repliesQuery = defineQueryHandler({
7
+ name: "replies",
8
+ schema: ContactIdSchema,
9
+ access: adminAccess,
10
+ description: "Returns the answers SystemAdmins sent to one contact request (id, sent time, author name, message), oldest first, as flat rows for a related list; the request itself is not part of it.",
11
+ handler: async (event, ctx) => {
12
+ const db = contactDb(ctx);
13
+ const { id } = event.payload;
14
+ const request = await requestExecutor.detail({ id }, platformActor(), db);
15
+ if (!request)
16
+ throw new NotFoundError(CONTACT_REQUEST_ENTITY, id);
17
+ const replies = await listRepliesOf(db, id);
18
+ return {
19
+ rows: replies.map((reply) => ({
20
+ id: reply.id,
21
+ sentAt: reply.sentAt.toString(),
22
+ authorName: reply.authorName,
23
+ message: reply.message,
24
+ })),
25
+ nextCursor: null,
26
+ };
27
+ },
28
+ });
@@ -0,0 +1,12 @@
1
+ import { CONTACT_STATUS } from "../web/constants.ts";
2
+ export type ContactReplyData = {
3
+ readonly kind: "replied";
4
+ readonly id: string;
5
+ readonly status: typeof CONTACT_STATUS.Answered | typeof CONTACT_STATUS.Done;
6
+ };
7
+ export declare function createReplyHandler(): import("@cosmicdrift/kumiko-types/define-handler").WriteHandlerDefinition<"reply", import("zod").ZodObject<{
8
+ requestId: import("zod").ZodUUID;
9
+ message: import("zod").ZodString;
10
+ fileIds: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodUUID>>;
11
+ markDone: import("zod").ZodDefault<import("zod").ZodBoolean>;
12
+ }, import("zod/v4/core").$strict>, ContactReplyData, import("@cosmicdrift/kumiko-types/event-type-map").KumikoEventTypeMap, undefined, undefined>;
@@ -0,0 +1,118 @@
1
+ import { createSystemUser, defineWriteHandler, } from "@cosmicdrift/kumiko-framework/engine";
2
+ import { NotFoundError, UnprocessableError, writeFailure, } from "@cosmicdrift/kumiko-framework/errors";
3
+ import { generateId } from "@cosmicdrift/kumiko-framework/utils";
4
+ import { parseTenantId } from "@cosmicdrift/kumiko-types/identifiers";
5
+ import { adminAccess, contactDb, loadUserLabel, pickReplyChannels, platformActor, replyExecutor, requestExecutor, sendBestEffort, } from "../lib.js";
6
+ import { ContactReplySchema } from "../payloads.js";
7
+ import { CONTACT_REPLY_CHANNELS, CONTACT_REPLY_ENTITY, CONTACT_REQUEST_ENTITY, CONTACT_STATUS, ContactErrors, ContactHandlers, ContactScreens, } from "../web/constants.js";
8
+ import { takeOverUploads } from "./take-over-uploads.js";
9
+ async function noteReporterInApp(ctx, args) {
10
+ const { request } = args;
11
+ const tenantId = parseTenantId(request.reporterTenantId);
12
+ // skip: the in-app note needs a signed-in reporter whose tenant id is still valid
13
+ if (!request.reporterUserId || tenantId === null)
14
+ return;
15
+ await sendBestEffort(ctx, "reply in-app note", async () => {
16
+ const noted = await ctx.dispatch.writeAs(createSystemUser(tenantId), ContactHandlers.notifyReporterInApp, {
17
+ replyId: args.replyId,
18
+ requestId: request.id,
19
+ userId: request.reporterUserId,
20
+ authorName: args.authorName,
21
+ locale: request.locale ?? undefined,
22
+ });
23
+ if (!noted.isSuccess)
24
+ throw new Error(noted.error.message);
25
+ });
26
+ }
27
+ // Returns the failing write result, or null when reply and request update both succeeded.
28
+ async function persistReply(ctx, db, args) {
29
+ const { request } = args;
30
+ const sentAt = ctx.tz.now();
31
+ const createdReply = await replyExecutor.create({
32
+ id: args.replyId,
33
+ requestId: request.id,
34
+ ...(request.reporterUserId && { reporterUserId: request.reporterUserId }),
35
+ message: args.message,
36
+ authorUserId: args.authorUserId,
37
+ authorName: args.authorName,
38
+ ...(args.fileIds.length > 0 && { fileIds: args.fileIds }),
39
+ channels: args.channels,
40
+ sentAt,
41
+ }, platformActor(), db);
42
+ if (!createdReply.isSuccess)
43
+ return createdReply;
44
+ const updated = await requestExecutor.update({
45
+ id: request.id,
46
+ version: request.version,
47
+ changes: {
48
+ status: args.status,
49
+ answeredAt: sentAt,
50
+ ...(args.status === CONTACT_STATUS.Done && { closedAt: sentAt }),
51
+ replyCount: (request.replyCount ?? 0) + 1,
52
+ },
53
+ }, platformActor(), db);
54
+ return updated.isSuccess ? null : updated;
55
+ }
56
+ // The drawer variant the admin used is chosen by the reply channels, and pending uploads hang under that screen.
57
+ function replyScreenFor(channels) {
58
+ return channels === CONTACT_REPLY_CHANNELS.EmailAndInApp
59
+ ? ContactScreens.reply
60
+ : ContactScreens.replyMail;
61
+ }
62
+ export function createReplyHandler() {
63
+ return defineWriteHandler({
64
+ name: "reply",
65
+ schema: ContactReplySchema,
66
+ access: adminAccess,
67
+ description: "A SystemAdmin answers a contact request: stores the reply (uploaded files are taken over into the system tenant), mails it to the reporter (Reply-To set, optional attachments, quoting the original request) and, for a signed-in reporter, adds an in-app note in the reporter's tenant. Marks the request answered, or done when markDone is set.",
68
+ // The reply mail leaves the platform and cannot be recalled; reporter text may carry prompt injection.
69
+ agent: { expose: false },
70
+ handler: async (event, ctx) => {
71
+ const { requestId, message, markDone } = event.payload;
72
+ const db = contactDb(ctx);
73
+ const request = await requestExecutor.detail({ id: requestId }, platformActor(), db);
74
+ if (!request)
75
+ return writeFailure(new NotFoundError(CONTACT_REQUEST_ENTITY, requestId));
76
+ const replyId = generateId();
77
+ const reporterUserId = request.reporterUserId ?? undefined;
78
+ const channels = await pickReplyChannels(ctx, reporterUserId);
79
+ const uploaded = await takeOverUploads(ctx, {
80
+ user: event.user,
81
+ screen: replyScreenFor(channels),
82
+ entityType: CONTACT_REPLY_ENTITY,
83
+ entityId: replyId,
84
+ fileIds: event.payload.fileIds ?? [],
85
+ });
86
+ if (!uploaded.isSuccess) {
87
+ return writeFailure(new UnprocessableError(ContactErrors.attachmentNotFound));
88
+ }
89
+ const fileIds = uploaded.data;
90
+ const author = await loadUserLabel(db, event.user.id);
91
+ const authorName = author?.name ?? event.user.id;
92
+ const status = markDone ? CONTACT_STATUS.Done : CONTACT_STATUS.Answered;
93
+ const failed = await persistReply(ctx, db, {
94
+ replyId,
95
+ request,
96
+ message,
97
+ authorUserId: event.user.id,
98
+ authorName,
99
+ fileIds,
100
+ channels,
101
+ status,
102
+ });
103
+ if (failed !== null)
104
+ return failed;
105
+ await sendBestEffort(ctx, "reply mail", async () => {
106
+ const sent = await ctx.dispatch.writeAs(platformActor(), ContactHandlers.sendReplyMail, {
107
+ replyId,
108
+ });
109
+ if (!sent.isSuccess)
110
+ throw new Error(sent.error.message);
111
+ });
112
+ if (channels === CONTACT_REPLY_CHANNELS.EmailAndInApp) {
113
+ await noteReporterInApp(ctx, { replyId, request, authorName });
114
+ }
115
+ return { isSuccess: true, data: { kind: "replied", id: replyId, status } };
116
+ },
117
+ });
118
+ }
@@ -0,0 +1,16 @@
1
+ import { type ContactOptions, type ContactSettings } from "../options.ts";
2
+ export type ContactReportData = {
3
+ readonly kind: "reported";
4
+ readonly id: string;
5
+ };
6
+ export declare function createReportHandler(opts: ContactOptions, settings: ContactSettings): import("@cosmicdrift/kumiko-types/define-handler").WriteHandlerDefinition<"report", import("zod").ZodObject<{
7
+ kind: import("zod").ZodEnum<{
8
+ bug: "bug";
9
+ question: "question";
10
+ wish: "wish";
11
+ }>;
12
+ subject: import("zod").ZodString;
13
+ message: import("zod").ZodString;
14
+ phone: import("zod").ZodOptional<import("zod").ZodString>;
15
+ fileIds: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodUUID>>;
16
+ }, import("zod/v4/core").$strict>, ContactReportData, import("@cosmicdrift/kumiko-types/event-type-map").KumikoEventTypeMap, undefined, undefined>;
@@ -0,0 +1,90 @@
1
+ import { requestContext } from "@cosmicdrift/kumiko-framework/api";
2
+ import { defineWriteHandler } from "@cosmicdrift/kumiko-framework/engine";
3
+ import { UnprocessableError, writeFailure } from "@cosmicdrift/kumiko-framework/errors";
4
+ import { generateId } from "@cosmicdrift/kumiko-framework/utils";
5
+ import { contactDb, loadTenantName, loadTenantPlan, loadUserLabel, normalizeEmail, phoneProblem, platformActor, requestExecutor, sendBestEffort, } from "../lib.js";
6
+ import { contactConfirmationVariables, resolveContactMailLocale } from "../mail.js";
7
+ import { REPORT_RATE_LIMIT } from "../options.js";
8
+ import { ContactReportSchema } from "../payloads.js";
9
+ import { summarizeUserAgent } from "../user-agent.js";
10
+ import { CONTACT_NOTIFICATION_TYPES, CONTACT_REQUEST_ENTITY, CONTACT_SOURCE, CONTACT_STATUS, CONTACT_UPLOAD_FIELD, ContactErrors, ContactHandlers, ContactScreens, contactIdempotencyKeys, } from "../web/constants.js";
11
+ import { REPORT_ACCESS } from "./access.js";
12
+ import { takeOverUploads } from "./take-over-uploads.js";
13
+ export function createReportHandler(opts, settings) {
14
+ return defineWriteHandler({
15
+ name: "report",
16
+ schema: ContactReportSchema,
17
+ access: REPORT_ACCESS,
18
+ rateLimit: REPORT_RATE_LIMIT,
19
+ agent: { expose: false },
20
+ description: "A signed-in user reports a problem, asks a question or voices a wish to the platform operators; name, email and tenant come from the session, never from the payload. Forwards the request to the SystemAdmins and mails the reporter a copy.",
21
+ handler: async (event, ctx) => {
22
+ const payload = event.payload;
23
+ const phoneIssue = phoneProblem(settings.phone, payload.phone);
24
+ if (phoneIssue !== null)
25
+ return writeFailure(new UnprocessableError(phoneIssue));
26
+ const db = contactDb(ctx);
27
+ const reporter = await loadUserLabel(db, event.user.id);
28
+ if (!reporter?.email) {
29
+ return writeFailure(new UnprocessableError(ContactErrors.reporterEmailMissing));
30
+ }
31
+ const tenantName = await loadTenantName(db, event.user.tenantId);
32
+ const email = normalizeEmail(reporter.email);
33
+ const browser = summarizeUserAgent(requestContext.get()?.userAgent, ctx.locale);
34
+ const tenantPlan = await loadTenantPlan(ctx, event.user.tenantId);
35
+ const requestId = generateId();
36
+ const uploaded = await takeOverUploads(ctx, {
37
+ user: event.user,
38
+ screen: ContactScreens.report,
39
+ entityType: CONTACT_REQUEST_ENTITY,
40
+ entityId: requestId,
41
+ fileIds: payload.fileIds ?? [],
42
+ });
43
+ if (!uploaded.isSuccess)
44
+ return uploaded;
45
+ const fileIds = uploaded.data;
46
+ const created = await requestExecutor.create({
47
+ id: requestId,
48
+ kind: payload.kind,
49
+ status: CONTACT_STATUS.Open,
50
+ source: CONTACT_SOURCE.Admin,
51
+ subject: payload.subject,
52
+ message: payload.message,
53
+ name: reporter.name,
54
+ email,
55
+ locale: ctx.locale,
56
+ reporterUserId: event.user.id,
57
+ reporterTenantId: event.user.tenantId,
58
+ ...(tenantName !== null && { reporterTenantName: tenantName }),
59
+ ...(tenantPlan !== null && { reporterTenantPlan: tenantPlan }),
60
+ ...(payload.phone !== undefined && payload.phone !== "" && { phone: payload.phone }),
61
+ ...(opts.appVersion !== undefined && { appVersion: opts.appVersion }),
62
+ ...(browser !== null && { browser }),
63
+ submittedAt: ctx.tz.now(),
64
+ ...(fileIds.length > 0 && { [CONTACT_UPLOAD_FIELD]: fileIds }),
65
+ fileCount: fileIds.length,
66
+ replyCount: 0,
67
+ }, platformActor(), db);
68
+ if (!created.isSuccess)
69
+ return created;
70
+ await sendBestEffort(ctx, "forward request", async () => {
71
+ const forwarded = await ctx.dispatch.writeAs(platformActor(), ContactHandlers.forwardRequest, { requestId });
72
+ if (!forwarded.isSuccess)
73
+ throw new Error(forwarded.error.message);
74
+ });
75
+ await sendBestEffort(ctx, "confirmation mail", (notify) => notify(CONTACT_NOTIFICATION_TYPES.confirmation, {
76
+ route: { email },
77
+ recipientId: requestId,
78
+ data: contactConfirmationVariables({
79
+ appName: opts.appName,
80
+ message: payload.message,
81
+ locale: ctx.locale,
82
+ }),
83
+ idempotencyKey: contactIdempotencyKeys.confirmation(requestId),
84
+ priority: "normal",
85
+ locale: resolveContactMailLocale(ctx.locale),
86
+ }));
87
+ return { isSuccess: true, data: { kind: "reported", id: requestId } };
88
+ },
89
+ });
90
+ }
@@ -0,0 +1,16 @@
1
+ import type { ContactOptions } from "../options.ts";
2
+ import { type ContactDeliveryChannel, type ContactDeliveryStatus } from "../web/constants.ts";
3
+ type DeliveryRow = {
4
+ readonly id: string;
5
+ readonly channel: ContactDeliveryChannel;
6
+ readonly recipient: string;
7
+ readonly at: string;
8
+ readonly status: ContactDeliveryStatus;
9
+ };
10
+ export declare function createRequestDeliveryQuery(opts: ContactOptions): import("@cosmicdrift/kumiko-types/define-handler").QueryHandlerDefinition<"request-delivery", import("zod").ZodObject<{
11
+ id: import("zod").ZodUUID;
12
+ }, import("zod/v4/core").$strict>, {
13
+ rows: DeliveryRow[];
14
+ nextCursor: null;
15
+ }, import("@cosmicdrift/kumiko-types/event-type-map").KumikoEventTypeMap>;
16
+ export {};
@@ -0,0 +1,85 @@
1
+ import { defineQueryHandler } from "@cosmicdrift/kumiko-framework/engine";
2
+ import { NotFoundError } from "@cosmicdrift/kumiko-framework/errors";
3
+ import { parseTenantId } from "@cosmicdrift/kumiko-types/identifiers";
4
+ import { adminAccess, contactDb, listRepliesOf, loadUserLabel, platformActor, requestExecutor, } from "../lib.js";
5
+ import { ContactIdSchema } from "../payloads.js";
6
+ import { CONTACT_DELIVERY_CHANNEL, CONTACT_DELIVERY_STATUS, CONTACT_REQUEST_ENTITY, ContactConfigKeys, contactIdempotencyKeys, } from "../web/constants.js";
7
+ import { loadAttemptsByKey, loadReadAtByKey } from "./attempts.js";
8
+ function displayStatus(attemptStatus) {
9
+ switch (attemptStatus) {
10
+ case "sent":
11
+ return CONTACT_DELIVERY_STATUS.Delivered;
12
+ case "failed":
13
+ return CONTACT_DELIVERY_STATUS.Failed;
14
+ case "skipped":
15
+ return CONTACT_DELIVERY_STATUS.Skipped;
16
+ default:
17
+ return CONTACT_DELIVERY_STATUS.Pending;
18
+ }
19
+ }
20
+ function attemptsOf(attempts, key) {
21
+ return attempts.filter((attempt) => attempt.key === key);
22
+ }
23
+ function rowOf(attempt, channel, recipient, readAt) {
24
+ const read = readAt !== undefined && readAt !== null;
25
+ return {
26
+ id: `${attempt.key}:${attempt.channel}:${attempt.recipientId ?? ""}`,
27
+ channel,
28
+ recipient,
29
+ at: (read ? readAt : attempt.createdAt).toString(),
30
+ status: read ? CONTACT_DELIVERY_STATUS.Read : displayStatus(attempt.status),
31
+ };
32
+ }
33
+ async function adminRows(db, attempts, requestId) {
34
+ const rows = [];
35
+ for (const attempt of attemptsOf(attempts, contactIdempotencyKeys.admins(requestId))) {
36
+ const admin = attempt.recipientId ? await loadUserLabel(db, attempt.recipientId) : null;
37
+ rows.push(rowOf(attempt, CONTACT_DELIVERY_CHANNEL.Email, `${admin?.name ?? "?"} (SystemAdmin)`, null));
38
+ }
39
+ return rows;
40
+ }
41
+ export function createRequestDeliveryQuery(opts) {
42
+ return defineQueryHandler({
43
+ name: "request-delivery",
44
+ schema: ContactIdSchema,
45
+ access: adminAccess,
46
+ description: "Returns where one contact request went and how: the admin mails, the Telegram message and each answer as mail and in-app note, each with channel, recipient, time and delivery status (an in-app note shows as read with the time it was opened), as flat rows for a related list.",
47
+ handler: async (event, ctx) => {
48
+ const db = contactDb(ctx);
49
+ const { id } = event.payload;
50
+ const request = await requestExecutor.detail({ id }, platformActor(), db);
51
+ if (!request)
52
+ throw new NotFoundError(CONTACT_REQUEST_ENTITY, id);
53
+ const replies = await listRepliesOf(db, id);
54
+ const replyInAppKeys = replies.map((reply) => contactIdempotencyKeys.replyInApp(reply.id));
55
+ const attempts = await loadAttemptsByKey(ctx, event.user, [
56
+ contactIdempotencyKeys.admins(id),
57
+ contactIdempotencyKeys.telegram(id),
58
+ ...replies.map((reply) => contactIdempotencyKeys.reply(reply.id)),
59
+ ...replyInAppKeys,
60
+ ]);
61
+ const reporterTenantId = parseTenantId(request.reporterTenantId);
62
+ const readAtByKey = reporterTenantId === null
63
+ ? new Map()
64
+ : await loadReadAtByKey(ctx, reporterTenantId, replyInAppKeys);
65
+ const rows = [...(await adminRows(db, attempts, id))];
66
+ if (opts.telegram) {
67
+ const chat = await ctx.config?.(ContactConfigKeys.telegramChat);
68
+ for (const attempt of attemptsOf(attempts, contactIdempotencyKeys.telegram(id))) {
69
+ rows.push(rowOf(attempt, CONTACT_DELIVERY_CHANNEL.Telegram, typeof chat === "string" ? chat : "", null));
70
+ }
71
+ }
72
+ for (const reply of replies) {
73
+ const mailKey = contactIdempotencyKeys.reply(reply.id);
74
+ for (const attempt of attemptsOf(attempts, mailKey)) {
75
+ rows.push(rowOf(attempt, CONTACT_DELIVERY_CHANNEL.ReplyEmail, request.name, null));
76
+ }
77
+ const inAppKey = contactIdempotencyKeys.replyInApp(reply.id);
78
+ for (const attempt of attemptsOf(attempts, inAppKey)) {
79
+ rows.push(rowOf(attempt, CONTACT_DELIVERY_CHANNEL.ReplyInApp, request.name, readAtByKey.get(inAppKey)));
80
+ }
81
+ }
82
+ return { rows, nextCursor: null };
83
+ },
84
+ });
85
+ }
@@ -0,0 +1,41 @@
1
+ import type { ContactOptions } from "../options.ts";
2
+ export declare function createRequestDetailQuery(opts: ContactOptions): import("@cosmicdrift/kumiko-types/define-handler").QueryHandlerDefinition<"request-detail", import("zod").ZodObject<{
3
+ id: import("zod").ZodUUID;
4
+ }, import("zod/v4/core").$strict>, {
5
+ id: string;
6
+ tenantId: string;
7
+ version: number;
8
+ insertedAt: Temporal.Instant;
9
+ modifiedAt: Temporal.Instant | null;
10
+ insertedById: string | null;
11
+ modifiedById: string | null;
12
+ isDeleted?: boolean | undefined;
13
+ deletedAt?: Temporal.Instant | null | undefined;
14
+ deletedById?: string | null | undefined;
15
+ replyTo: string | null;
16
+ replyChannels: import("../web/constants.ts").ContactReplyChannels;
17
+ versionLabel: string | null;
18
+ origin: "admin-report" | "website";
19
+ answeredAt: Temporal.Instant | null;
20
+ appVersion: string | null;
21
+ browser: string | null;
22
+ closedAt: Temporal.Instant | null;
23
+ email: string;
24
+ fileCount: number | null;
25
+ fileIds: readonly string[];
26
+ kind: string;
27
+ locale: string | null;
28
+ message: string;
29
+ name: string;
30
+ page: string | null;
31
+ phone: string | null;
32
+ replyCount: number | null;
33
+ reporterTenantId: string | null;
34
+ reporterTenantName: string | null;
35
+ reporterTenantPlan: string | null;
36
+ reporterUserId: string | null;
37
+ source: string;
38
+ status: string;
39
+ subject: string;
40
+ submittedAt: Temporal.Instant;
41
+ }, import("@cosmicdrift/kumiko-types/event-type-map").KumikoEventTypeMap>;
@@ -0,0 +1,32 @@
1
+ import { defineQueryHandler } from "@cosmicdrift/kumiko-framework/engine";
2
+ import { NotFoundError } from "@cosmicdrift/kumiko-framework/errors";
3
+ import { adminAccess, contactDb, loadUserLabel, pickReplyChannels, platformActor, requestExecutor, } from "../lib.js";
4
+ import { ContactIdSchema } from "../payloads.js";
5
+ import { CONTACT_ORIGIN, CONTACT_REQUEST_ENTITY, CONTACT_SOURCE, ContactConfigKeys, } from "../web/constants.js";
6
+ export function createRequestDetailQuery(opts) {
7
+ return defineQueryHandler({
8
+ name: "request-detail",
9
+ schema: ContactIdSchema,
10
+ access: adminAccess,
11
+ description: "Returns one contact request with its origin fields plus what the detail screen shows around it: the Reply-To address a reply goes out with (the caller's own email while none is configured), the channels a reply reaches the reporter on, the app version label and whether the request came from the website or the admin.",
12
+ handler: async (event, ctx) => {
13
+ const db = contactDb(ctx);
14
+ const request = await requestExecutor.detail({ id: event.payload.id }, platformActor(), db);
15
+ if (!request)
16
+ throw new NotFoundError(CONTACT_REQUEST_ENTITY, event.payload.id);
17
+ const configuredReplyTo = await ctx.config?.(ContactConfigKeys.replyTo);
18
+ const replyTo = typeof configuredReplyTo === "string" && configuredReplyTo !== ""
19
+ ? configuredReplyTo
20
+ : ((await loadUserLabel(db, event.user.id))?.email ?? null);
21
+ return {
22
+ ...request,
23
+ replyTo,
24
+ replyChannels: await pickReplyChannels(ctx, request.reporterUserId),
25
+ versionLabel: opts.appVersion !== undefined ? `${opts.appName} ${opts.appVersion}` : null,
26
+ origin: request.source === CONTACT_SOURCE.Admin
27
+ ? CONTACT_ORIGIN.AdminReport
28
+ : CONTACT_ORIGIN.Website,
29
+ };
30
+ },
31
+ });
32
+ }
@@ -0,0 +1,2 @@
1
+ import { type EntityDefinition } from "@cosmicdrift/kumiko-framework/engine";
2
+ export declare function createRequestListQuery(requestEntity: EntityDefinition): import("@cosmicdrift/kumiko-types/handlers").QueryHandlerDef;
@@ -0,0 +1,9 @@
1
+ import { defineEntityListHandler, } from "@cosmicdrift/kumiko-framework/engine";
2
+ import { adminAccess } from "../lib.js";
3
+ import { CONTACT_REQUEST_ENTITY } from "../web/constants.js";
4
+ export function createRequestListQuery(requestEntity) {
5
+ return defineEntityListHandler(CONTACT_REQUEST_ENTITY, requestEntity, {
6
+ access: adminAccess,
7
+ description: "Lists contact requests for the SystemAdmin inbox: searchable, filterable by status, kind and source, newest first; the open named filter backs the dashboard tile.",
8
+ });
9
+ }
@@ -0,0 +1,8 @@
1
+ import type { ContactOptions } from "../options.ts";
2
+ export type ContactSendReplyMailData = {
3
+ readonly kind: "sent";
4
+ readonly attachmentCount: number;
5
+ };
6
+ export declare function createSendReplyMailHandler(opts: ContactOptions): import("@cosmicdrift/kumiko-types/define-handler").WriteHandlerDefinition<"send-reply-mail", import("zod").ZodObject<{
7
+ replyId: import("zod").ZodUUID;
8
+ }, import("zod/v4/core").$strict>, ContactSendReplyMailData, import("@cosmicdrift/kumiko-types/event-type-map").KumikoEventTypeMap, undefined, undefined>;
@@ -0,0 +1,82 @@
1
+ import { fetchOne } from "@cosmicdrift/kumiko-framework/db";
2
+ import { defineWriteHandler, SYSTEM_TENANT_ID, } from "@cosmicdrift/kumiko-framework/engine";
3
+ import { NotFoundError, writeFailure } from "@cosmicdrift/kumiko-framework/errors";
4
+ import { fileRefsTable } from "@cosmicdrift/kumiko-framework/files";
5
+ import { decryptStoredPii } from "../../shared/index.js";
6
+ import { contactDb, internalAccess, loadUserLabel, platformActor, replyExecutor, requestExecutor, sendBestEffort, } from "../lib.js";
7
+ import { contactReplyVariables, resolveContactMailLocale } from "../mail.js";
8
+ import { ContactSendReplyMailSchema } from "../payloads.js";
9
+ import { CONTACT_NOTIFICATION_TYPES, CONTACT_REPLY_ENTITY, CONTACT_REQUEST_ENTITY, ContactConfigKeys, contactIdempotencyKeys, } from "../web/constants.js";
10
+ const ATTACHMENT_LOOKUP_REASON = "contact:reply-attachment";
11
+ async function resolveAttachments(ctx, fileIds) {
12
+ const db = contactDb(ctx);
13
+ const attachments = [];
14
+ for (const fileRefId of fileIds) {
15
+ const row = await fetchOne(db, fileRefsTable, {
16
+ id: fileRefId,
17
+ tenantId: SYSTEM_TENANT_ID,
18
+ });
19
+ // skip: a file that vanished since the reply was stored cannot be attached
20
+ if (!row)
21
+ continue;
22
+ const fileName = await decryptStoredPii(row.fileName, "fileName", ATTACHMENT_LOOKUP_REASON);
23
+ attachments.push({ kind: "file", fileRefId, fileName });
24
+ }
25
+ return attachments;
26
+ }
27
+ async function resolveReplyTo(ctx, authorEmail) {
28
+ const configured = await ctx.config?.(ContactConfigKeys.replyTo);
29
+ return typeof configured === "string" && configured.trim() !== ""
30
+ ? configured.trim()
31
+ : authorEmail;
32
+ }
33
+ // Runs as the platform identity: the delivery channel reads attachments of the sending tenant,
34
+ // and the reply files live in the system tenant, whichever tenant the answering admin is in.
35
+ export function createSendReplyMailHandler(opts) {
36
+ return defineWriteHandler({
37
+ name: "send-reply-mail",
38
+ schema: ContactSendReplyMailSchema,
39
+ access: internalAccess,
40
+ agent: { expose: false },
41
+ description: "Internal: mails a stored reply to the reporter with Reply-To, the quoted request and the reply files attached. Only the platform identity can call it.",
42
+ handler: async (event, ctx) => {
43
+ const db = contactDb(ctx);
44
+ const { replyId } = event.payload;
45
+ const reply = await replyExecutor.detail({ id: replyId }, platformActor(), db);
46
+ if (!reply)
47
+ return writeFailure(new NotFoundError(CONTACT_REPLY_ENTITY, replyId));
48
+ const request = await requestExecutor.detail({ id: reply.requestId }, platformActor(), db);
49
+ if (!request) {
50
+ return writeFailure(new NotFoundError(CONTACT_REQUEST_ENTITY, reply.requestId));
51
+ }
52
+ const author = await loadUserLabel(db, reply.authorUserId);
53
+ const reporterUserId = request.reporterUserId ?? undefined;
54
+ const reporter = reporterUserId ? await loadUserLabel(db, reporterUserId) : null;
55
+ const recipientEmail = reporter?.email ?? request.email;
56
+ const replyTo = await resolveReplyTo(ctx, author?.email ?? undefined);
57
+ const attachments = await resolveAttachments(ctx, reply.fileIds ?? []);
58
+ const locale = request.locale ?? undefined;
59
+ await sendBestEffort(ctx, "reply mail", (notify) => notify(CONTACT_NOTIFICATION_TYPES.reply, {
60
+ route: { email: recipientEmail },
61
+ recipientId: request.id,
62
+ data: {
63
+ ...contactReplyVariables({
64
+ requestSubject: request.subject,
65
+ requestMessage: request.message,
66
+ requestSubmittedAt: Number(request.submittedAt.epochMilliseconds),
67
+ replyMessage: reply.message,
68
+ authorName: reply.authorName,
69
+ appName: opts.appName,
70
+ locale,
71
+ }),
72
+ ...(replyTo !== undefined && { replyTo }),
73
+ ...(attachments.length > 0 && { attachments }),
74
+ },
75
+ idempotencyKey: contactIdempotencyKeys.reply(replyId),
76
+ priority: "normal",
77
+ locale: resolveContactMailLocale(locale),
78
+ }));
79
+ return { isSuccess: true, data: { kind: "sent", attachmentCount: attachments.length } };
80
+ },
81
+ });
82
+ }
@@ -0,0 +1,5 @@
1
+ import type { ContactOptions } from "../options.ts";
2
+ export type ContactSendTestData = {
3
+ readonly kind: "sent";
4
+ };
5
+ export declare function createSendTestHandler(opts: ContactOptions): import("@cosmicdrift/kumiko-types/define-handler").WriteHandlerDefinition<"send-test", import("zod").ZodObject<{}, import("zod/v4/core").$strict>, ContactSendTestData, import("@cosmicdrift/kumiko-types/event-type-map").KumikoEventTypeMap, undefined, undefined>;
@@ -0,0 +1,36 @@
1
+ import { defineWriteHandler } from "@cosmicdrift/kumiko-framework/engine";
2
+ import { InternalError, UnprocessableError, writeFailure, } from "@cosmicdrift/kumiko-framework/errors";
3
+ import { adminAccess } from "../lib.js";
4
+ import { contactTestVariables, resolveContactMailLocale } from "../mail.js";
5
+ import { ContactEmptySchema } from "../payloads.js";
6
+ import { CONTACT_NOTIFICATION_TYPES, ContactConfigKeys, ContactErrors } from "../web/constants.js";
7
+ export function createSendTestHandler(opts) {
8
+ return defineWriteHandler({
9
+ name: "send-test",
10
+ schema: ContactEmptySchema,
11
+ access: adminAccess,
12
+ agent: { expose: false },
13
+ description: "Sends a test message to the configured Telegram chat; fails with a typed error when no chat is configured or the provider does not accept the message, so a SystemAdmin can verify bot token and chat id.",
14
+ handler: async (event, ctx) => {
15
+ const chatId = await ctx.config?.(ContactConfigKeys.telegramChat);
16
+ if (typeof chatId !== "string" || chatId.trim() === "") {
17
+ return writeFailure(new UnprocessableError(ContactErrors.telegramChatMissing));
18
+ }
19
+ if (!ctx.notify) {
20
+ throw new InternalError({ message: "ctx.notify unavailable — mount the delivery feature" });
21
+ }
22
+ const locale = opts.adminLocale ?? "en";
23
+ const result = await ctx.notify(CONTACT_NOTIFICATION_TYPES.test, {
24
+ route: { telegram: chatId.trim() },
25
+ recipientId: event.user.id,
26
+ data: contactTestVariables({ appName: opts.appName, locale }),
27
+ immediate: true,
28
+ locale: resolveContactMailLocale(locale),
29
+ });
30
+ if (result.deliveries.some((d) => d.status === "failed")) {
31
+ return writeFailure(new UnprocessableError(ContactErrors.telegramTestFailed));
32
+ }
33
+ return { isSuccess: true, data: { kind: "sent" } };
34
+ },
35
+ });
36
+ }
@@ -0,0 +1,20 @@
1
+ import { type ContactOptions, type ContactSettings } from "../options.ts";
2
+ export type ContactSubmitData = {
3
+ readonly kind: "submitted";
4
+ };
5
+ export declare function createSubmitHandler(opts: ContactOptions, settings: ContactSettings): import("@cosmicdrift/kumiko-types/define-handler").WriteHandlerDefinition<"submit", import("zod").ZodObject<{
6
+ kind: import("zod").ZodEnum<{
7
+ bug: "bug";
8
+ contact: "contact";
9
+ question: "question";
10
+ }>;
11
+ name: import("zod").ZodString;
12
+ email: import("zod").ZodEmail;
13
+ phone: import("zod").ZodOptional<import("zod").ZodString>;
14
+ message: import("zod").ZodString;
15
+ locale: import("zod").ZodPipe<import("zod").ZodString, import("zod").ZodTransform<string, string>>;
16
+ website: import("zod").ZodOptional<import("zod").ZodString>;
17
+ challenge: import("zod").ZodString;
18
+ nonce: import("zod").ZodString;
19
+ page: import("zod").ZodOptional<import("zod").ZodPipe<import("zod").ZodString, import("zod").ZodTransform<string, string>>>;
20
+ }, import("zod/v4/core").$strict>, ContactSubmitData, import("@cosmicdrift/kumiko-types/event-type-map").KumikoEventTypeMap, undefined, undefined>;