@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,113 @@
1
+ import { addDurationSpec, } from "@cosmicdrift/kumiko-framework/compliance";
2
+ import { Temporal } from "@cosmicdrift/kumiko-types/temporal";
3
+ const EPOCH = Temporal.Instant.fromEpochMilliseconds(0);
4
+ export function addRetentionSpec(from, spec) {
5
+ if ("months" in spec) {
6
+ return from.toZonedDateTimeISO("UTC").add({ months: spec.months }).toInstant();
7
+ }
8
+ if ("years" in spec) {
9
+ return from.toZonedDateTimeISO("UTC").add({ years: spec.years }).toInstant();
10
+ }
11
+ return addDurationSpec(from, spec);
12
+ }
13
+ function leadMs(spec) {
14
+ return addDurationSpec(EPOCH, spec).epochMilliseconds;
15
+ }
16
+ // Longest lead first, so index 0 is the earliest warning.
17
+ export function sortedWarnings(rule) {
18
+ return [...rule.warnings].sort((a, b) => leadMs(b) - leadMs(a));
19
+ }
20
+ function laterOf(instants) {
21
+ let latest = null;
22
+ for (const instant of instants) {
23
+ if (instant !== null && (latest === null || Temporal.Instant.compare(instant, latest) > 0)) {
24
+ latest = instant;
25
+ }
26
+ }
27
+ return latest;
28
+ }
29
+ export function activityBase(state) {
30
+ return (laterOf([state.firstSeenAt, state.lastActivityAt, state.lastExemptAt]) ?? state.firstSeenAt);
31
+ }
32
+ // Activity after the last warning starts a new cycle.
33
+ export function isNewCycle(state) {
34
+ return (state.warningsSent > 0 &&
35
+ state.lastWarnedAt !== null &&
36
+ Temporal.Instant.compare(activityBase(state), state.lastWarnedAt) > 0);
37
+ }
38
+ export function resetWarnings(state) {
39
+ return { ...state, warningsSent: 0, lastWarnedAt: null, postponedDueAt: null };
40
+ }
41
+ export function dueAt(state, rule) {
42
+ const regular = addRetentionSpec(activityBase(state), rule.after);
43
+ return laterOf([regular, state.postponedDueAt]) ?? regular;
44
+ }
45
+ // Expects a state that already went through the new-cycle reset.
46
+ export function planNextStep(state, rule) {
47
+ const due = dueAt(state, rule);
48
+ const warnings = sortedWarnings(rule);
49
+ const nextWarning = warnings[state.warningsSent];
50
+ if (nextWarning === undefined)
51
+ return { step: "destructionRequest", at: due };
52
+ const warnAt = Temporal.Instant.fromEpochMilliseconds(due.epochMilliseconds - leadMs(nextWarning));
53
+ return { step: "warning", at: warnAt };
54
+ }
55
+ // At most one warning per run: the latest one that is due. A deadline that passed with warnings
56
+ // missing sends the final warning late and moves the deletion request behind it.
57
+ export function decideInactivityAction(state, rule, now) {
58
+ const due = dueAt(state, rule);
59
+ const warnings = sortedWarnings(rule);
60
+ const total = warnings.length;
61
+ if (state.warningsSent >= total) {
62
+ return Temporal.Instant.compare(now, due) >= 0 ? { kind: "destroy" } : { kind: "none" };
63
+ }
64
+ const finalLead = warnings[total - 1];
65
+ if (finalLead !== undefined && Temporal.Instant.compare(now, due) >= 0) {
66
+ const postponedDueAt = addDurationSpec(now, finalLead);
67
+ return {
68
+ kind: "warn",
69
+ warningsSentAfter: total,
70
+ deadline: postponedDueAt,
71
+ postponedDueAt,
72
+ };
73
+ }
74
+ let lastDue = -1;
75
+ for (let index = state.warningsSent; index < total; index++) {
76
+ const lead = warnings[index];
77
+ if (lead !== undefined && now.epochMilliseconds >= due.epochMilliseconds - leadMs(lead)) {
78
+ lastDue = index;
79
+ }
80
+ }
81
+ if (lastDue < 0)
82
+ return { kind: "none" };
83
+ return { kind: "warn", warningsSentAfter: lastDue + 1, deadline: due, postponedDueAt: null };
84
+ }
85
+ // Raises lastActivityAt to the newest known activity; activity after the last warning starts a
86
+ // new cycle, which also drops a postponed deadline.
87
+ export function foldActivity(state, newest) {
88
+ const lastActivityAt = laterOf([state.lastActivityAt, newest]);
89
+ const raised = { ...state, lastActivityAt };
90
+ if (!isNewCycle(raised))
91
+ return { state: raised, newCycle: false };
92
+ return { state: resetWarnings(raised), newCycle: true };
93
+ }
94
+ // Shared by the daily job and the state query so both name the same next step.
95
+ export function describeOutlook(state, rule) {
96
+ if (rule === null || state === null) {
97
+ return {
98
+ exempt: rule === null,
99
+ lastActivityAt: state?.lastActivityAt ?? null,
100
+ warningsSent: state?.warningsSent ?? 0,
101
+ nextStep: null,
102
+ nextStepAt: null,
103
+ };
104
+ }
105
+ const plan = planNextStep(state, rule);
106
+ return {
107
+ exempt: false,
108
+ lastActivityAt: state.lastActivityAt,
109
+ warningsSent: state.warningsSent,
110
+ nextStep: plan.step,
111
+ nextStepAt: plan.at,
112
+ };
113
+ }
@@ -0,0 +1,5 @@
1
+ export { TenantInactivityHandlers, TenantInactivityJobs } from "./constants.ts";
2
+ export { createTenantInactivityFeature } from "./feature.ts";
3
+ export type { InactivityRule } from "./inactivity-plan.ts";
4
+ export type { TenantActivitySource, TenantInactivityOptions } from "./options.ts";
5
+ export { fetchRemoteAppLastActivity } from "./remote-activity.ts";
@@ -0,0 +1,3 @@
1
+ export { TenantInactivityHandlers, TenantInactivityJobs } from "./constants.js";
2
+ export { createTenantInactivityFeature } from "./feature.js";
3
+ export { fetchRemoteAppLastActivity } from "./remote-activity.js";
@@ -0,0 +1,16 @@
1
+ import type { Temporal } from "@cosmicdrift/kumiko-types/temporal";
2
+ import { type RowBoundGrantResult } from "../shared/index.ts";
3
+ export declare function signKeepAccountToken(args: {
4
+ readonly tenantId: string;
5
+ readonly cycleId: string;
6
+ readonly ttlMinutes: number;
7
+ readonly secret: string;
8
+ readonly now: Temporal.Instant;
9
+ }): string;
10
+ export declare function redeemKeepAccountToken(args: {
11
+ readonly token: string;
12
+ readonly secret: string | undefined;
13
+ readonly loadCycleId: (tenantId: string) => Promise<string | null>;
14
+ readonly commitKeep: (tenantId: string, cycleId: string) => Promise<boolean>;
15
+ readonly now: Temporal.Instant;
16
+ }): Promise<RowBoundGrantResult>;
@@ -0,0 +1,24 @@
1
+ import { redeemRowBoundGrant, signRowBoundGrant, } from "../shared/index.js";
2
+ const KEEP_ACCOUNT_PURPOSE = "keep-account";
3
+ // Subject is the tenant, anchor the state row's cycleId: any activity or a redeemed link rotates
4
+ // the cycleId, so every earlier link stops verifying.
5
+ export function signKeepAccountToken(args) {
6
+ return signRowBoundGrant({
7
+ subject: args.tenantId,
8
+ purpose: KEEP_ACCOUNT_PURPOSE,
9
+ anchor: args.cycleId,
10
+ ttlMinutes: args.ttlMinutes,
11
+ secret: args.secret,
12
+ now: args.now,
13
+ }).token;
14
+ }
15
+ export function redeemKeepAccountToken(args) {
16
+ return redeemRowBoundGrant({
17
+ token: args.token,
18
+ purpose: KEEP_ACCOUNT_PURPOSE,
19
+ secret: args.secret,
20
+ loadAnchor: args.loadCycleId,
21
+ commitAnchor: args.commitKeep,
22
+ now: args.now,
23
+ });
24
+ }
@@ -0,0 +1,4 @@
1
+ import { type FeatureRegistrar } from "@cosmicdrift/kumiko-framework/engine";
2
+ export declare const InactivityWarningNotificationType: string;
3
+ export declare const inactivityMailTemplateLocale: (notificationType: string, requestedLocale: string) => string;
4
+ export declare function registerInactivityMails(r: FeatureRegistrar): void;
@@ -0,0 +1,42 @@
1
+ import { QnTypes, qn, templateVariable, } from "@cosmicdrift/kumiko-framework/engine";
2
+ import { mailT } from "@cosmicdrift/kumiko-framework/i18n";
3
+ import { escapeHtml } from "@cosmicdrift/kumiko-renderer/headless";
4
+ import { createMailLocaleTemplates, mailParagraph } from "../shared/index.js";
5
+ import { TENANT_INACTIVITY_FEATURE } from "./constants.js";
6
+ const WARNING_MAIL_NAME = "warning";
7
+ export const InactivityWarningNotificationType = qn(TENANT_INACTIVITY_FEATURE, QnTypes.notify, WARNING_MAIL_NAME);
8
+ const WARNING_SUBJECT_KEY = "inactivity.mail.warning.subject";
9
+ // Translation placeholder -> template variable.
10
+ // The translation slot is named account because locale-de rejects the word tenant in values.
11
+ const SLOTS = { app: "{app}", account: "{tenant}", when: "{when}" };
12
+ const SUBJECT_SLOTS = { app: "{{app}}", account: "{{tenant}}", when: "{{when}}" };
13
+ const WARNING_VARIABLES = {
14
+ app: templateVariable.text({ required: true }),
15
+ tenant: templateVariable.text({ required: true }),
16
+ when: templateVariable.text({ required: true }),
17
+ keepUrl: templateVariable.link({ required: true }),
18
+ };
19
+ function warningBody(locale) {
20
+ const paragraph = (part) => mailParagraph(mailT(locale, `inactivity.mail.warning.${part}`, SLOTS));
21
+ return [
22
+ mailParagraph(mailT(locale, "gdpr.mail.greeting")),
23
+ paragraph("intro"),
24
+ paragraph("keep"),
25
+ `<p><a data-button href="{{keepUrl}}">${escapeHtml(mailT(locale, "inactivity.mail.warning.button"))}</a></p>`,
26
+ paragraph("after"),
27
+ ].join("");
28
+ }
29
+ const mailLocaleTemplates = createMailLocaleTemplates({
30
+ kinds: [WARNING_MAIL_NAME],
31
+ notificationTypes: { [WARNING_MAIL_NAME]: InactivityWarningNotificationType },
32
+ subjectKey: () => WARNING_SUBJECT_KEY,
33
+ bodyFor: (_kind, locale) => warningBody(locale),
34
+ subjectSlots: () => SUBJECT_SLOTS,
35
+ });
36
+ export const inactivityMailTemplateLocale = mailLocaleTemplates.templateLocale;
37
+ export function registerInactivityMails(r) {
38
+ r.notification(WARNING_MAIL_NAME, {
39
+ variables: WARNING_VARIABLES,
40
+ localizedTemplate: mailLocaleTemplates.localizedTemplate(WARNING_MAIL_NAME),
41
+ });
42
+ }
@@ -0,0 +1,27 @@
1
+ import type { TenantDb } from "@cosmicdrift/kumiko-framework/db";
2
+ import type { TenantId } from "@cosmicdrift/kumiko-framework/engine";
3
+ import type { Temporal } from "@cosmicdrift/kumiko-types/temporal";
4
+ import type { InactivityRule } from "./inactivity-plan.ts";
5
+ /** Newest activity an app knows outside this app's sessions (for example a sibling app); null when none. */
6
+ export type TenantActivitySource = (args: {
7
+ readonly tenantId: TenantId;
8
+ readonly now: Temporal.Instant;
9
+ }) => Promise<Temporal.Instant | null>;
10
+ type SharedOptions = {
11
+ /** HMAC key of the keep-account links. Unset: mails link to keepAccountUrl without a token. */
12
+ readonly keepAccountTokenSecret?: string;
13
+ /** App page that reads the `#token=` fragment and calls the keep-account handler. */
14
+ readonly keepAccountUrl: string;
15
+ /** Name shown in the mails; defaults to a generic word per locale. */
16
+ readonly appName?: string;
17
+ readonly activitySources?: readonly TenantActivitySource[];
18
+ };
19
+ export type TenantInactivityOptions<TTier extends string = string> = SharedOptions & ({
20
+ readonly rule: InactivityRule;
21
+ } | {
22
+ readonly resolveTier: (db: TenantDb) => Promise<TTier>;
23
+ /** null exempts the tier (paid plans). */
24
+ readonly rulesByTier: Readonly<Record<TTier, InactivityRule | null>>;
25
+ });
26
+ export declare function resolveInactivityRule<TTier extends string>(options: TenantInactivityOptions<TTier>, db: TenantDb): Promise<InactivityRule | null>;
27
+ export {};
@@ -0,0 +1,5 @@
1
+ export async function resolveInactivityRule(options, db) {
2
+ if ("rule" in options)
3
+ return options.rule;
4
+ return options.rulesByTier[await options.resolveTier(db)];
5
+ }
@@ -0,0 +1,15 @@
1
+ import { Temporal } from "@cosmicdrift/kumiko-types/temporal";
2
+ type SendRequest = (url: string, init: RequestInit) => Promise<Response>;
3
+ /**
4
+ * Asks a sibling app for its newest session activity (the sessions `lastActivityProbeSecret`
5
+ * route). Use it inside a `TenantActivitySource` so a user active in the other app keeps the
6
+ * account alive. Fails closed: any error throws, and the job then sends no mail and files no
7
+ * deletion request for that run. `send` exists for tests; production uses the internal egress
8
+ * pinned to the origin of `url`.
9
+ */
10
+ export declare function fetchRemoteAppLastActivity(args: {
11
+ readonly url: string;
12
+ readonly secret: string;
13
+ readonly send?: SendRequest;
14
+ }): Promise<Temporal.Instant | null>;
15
+ export {};
@@ -0,0 +1,24 @@
1
+ import { egress } from "@cosmicdrift/kumiko-framework/http";
2
+ import { Temporal } from "@cosmicdrift/kumiko-types/temporal";
3
+ import * as z from "zod";
4
+ const probeResponseSchema = z.object({ lastActivityAt: z.string().nullable() });
5
+ /**
6
+ * Asks a sibling app for its newest session activity (the sessions `lastActivityProbeSecret`
7
+ * route). Use it inside a `TenantActivitySource` so a user active in the other app keeps the
8
+ * account alive. Fails closed: any error throws, and the job then sends no mail and files no
9
+ * deletion request for that run. `send` exists for tests; production uses the internal egress
10
+ * pinned to the origin of `url`.
11
+ */
12
+ export async function fetchRemoteAppLastActivity(args) {
13
+ // Sibling apps sit in the same cluster on private addresses, which the external policy blocks.
14
+ const send = args.send ?? egress({ kind: "internal", allowOrigins: [new URL(args.url).origin] });
15
+ const response = await send(args.url, {
16
+ method: "GET",
17
+ headers: { authorization: `Bearer ${args.secret}` },
18
+ });
19
+ if (!response.ok) {
20
+ throw new Error(`remote activity probe answered ${response.status}`);
21
+ }
22
+ const body = probeResponseSchema.parse(await response.json());
23
+ return body.lastActivityAt === null ? null : Temporal.Instant.from(body.lastActivityAt);
24
+ }
@@ -0,0 +1,10 @@
1
+ import type { TenantDb } from "@cosmicdrift/kumiko-framework/db";
2
+ import { Temporal } from "@cosmicdrift/kumiko-types/temporal";
3
+ import type { InactivityState } from "./inactivity-plan.ts";
4
+ export type StoredInactivityState = InactivityState & {
5
+ readonly cycleId: string;
6
+ };
7
+ export declare function loadInactivityState(db: TenantDb): Promise<StoredInactivityState | null>;
8
+ export declare function isSameInactivityState(a: StoredInactivityState | null, b: StoredInactivityState): boolean;
9
+ export declare function saveInactivityState(db: TenantDb, previous: StoredInactivityState | null, next: StoredInactivityState): Promise<void>;
10
+ export declare function loadNewestSessionActivity(db: TenantDb): Promise<Temporal.Instant | null>;
@@ -0,0 +1,50 @@
1
+ import { Temporal } from "@cosmicdrift/kumiko-types/temporal";
2
+ import { userSessionTable } from "../sessions/index.js";
3
+ import { tenantInactivityStateTable } from "./state-table.js";
4
+ const EPOCH = Temporal.Instant.fromEpochMilliseconds(0);
5
+ export async function loadInactivityState(db) {
6
+ const row = await db.fetchOne(tenantInactivityStateTable, { tenantId: db.tenantId });
7
+ if (!row)
8
+ return null;
9
+ return {
10
+ cycleId: row.cycleId,
11
+ firstSeenAt: row.firstSeenAt,
12
+ lastActivityAt: row.lastActivityAt,
13
+ lastExemptAt: row.lastExemptAt,
14
+ lastWarnedAt: row.lastWarnedAt,
15
+ postponedDueAt: row.postponedDueAt,
16
+ warningsSent: row.warningsSent,
17
+ };
18
+ }
19
+ function sameInstant(a, b) {
20
+ if (a === null || b === null)
21
+ return a === b;
22
+ return a.epochMilliseconds === b.epochMilliseconds;
23
+ }
24
+ export function isSameInactivityState(a, b) {
25
+ return (a !== null &&
26
+ a.cycleId === b.cycleId &&
27
+ a.warningsSent === b.warningsSent &&
28
+ sameInstant(a.firstSeenAt, b.firstSeenAt) &&
29
+ sameInstant(a.lastActivityAt, b.lastActivityAt) &&
30
+ sameInstant(a.lastExemptAt, b.lastExemptAt) &&
31
+ sameInstant(a.lastWarnedAt, b.lastWarnedAt) &&
32
+ sameInstant(a.postponedDueAt, b.postponedDueAt));
33
+ }
34
+ // Writes only when something changed, so a run that decides nothing stays read-only.
35
+ export async function saveInactivityState(db, previous, next) {
36
+ // skip: nothing changed, so the run stays read-only
37
+ if (isSameInactivityState(previous, next))
38
+ return;
39
+ if (previous === null) {
40
+ await db.insertOne(tenantInactivityStateTable, { tenantId: db.tenantId, ...next });
41
+ }
42
+ else {
43
+ await db.updateMany(tenantInactivityStateTable, next, { tenantId: db.tenantId });
44
+ }
45
+ }
46
+ // The sessions table keeps the activity marker; reading it here avoids a write per request.
47
+ export async function loadNewestSessionActivity(db) {
48
+ const [newest] = await db.selectMany(userSessionTable, { tenantId: db.tenantId, lastSeenAt: { gte: EPOCH } }, { limit: 1, orderBy: { col: "lastSeenAt", direction: "desc" } });
49
+ return newest?.lastSeenAt ?? null;
50
+ }
@@ -0,0 +1,109 @@
1
+ export declare const tenantInactivityStateEntity: import("@cosmicdrift/kumiko-types/fields").EntityDefinition<{
2
+ readonly tenantId: import("@cosmicdrift/kumiko-types/fields").EntityTextFieldDef & {
3
+ required: true;
4
+ };
5
+ readonly cycleId: import("@cosmicdrift/kumiko-types/fields").EntityTextFieldDef & {
6
+ required: true;
7
+ };
8
+ readonly firstSeenAt: {
9
+ readonly type: "timestamp";
10
+ readonly description?: string;
11
+ readonly required?: boolean;
12
+ readonly sortable?: boolean;
13
+ readonly sortNulls?: import("@cosmicdrift/kumiko-types/fields").SortNulls;
14
+ readonly filterable?: boolean;
15
+ readonly sensitive?: boolean;
16
+ readonly access?: import("@cosmicdrift/kumiko-types/fields").FieldAccess;
17
+ readonly locatedBy?: string;
18
+ readonly min?: string;
19
+ readonly max?: string;
20
+ readonly locale?: string;
21
+ } & import("@cosmicdrift/kumiko-types/fields").ResolvedPiiFlags & import("@cosmicdrift/kumiko-types/fields").FieldStateConditions & {
22
+ required: true;
23
+ };
24
+ readonly lastActivityAt: {
25
+ readonly type: "timestamp";
26
+ readonly description?: string;
27
+ readonly required?: boolean;
28
+ readonly sortable?: boolean;
29
+ readonly sortNulls?: import("@cosmicdrift/kumiko-types/fields").SortNulls;
30
+ readonly filterable?: boolean;
31
+ readonly sensitive?: boolean;
32
+ readonly access?: import("@cosmicdrift/kumiko-types/fields").FieldAccess;
33
+ readonly locatedBy?: string;
34
+ readonly min?: string;
35
+ readonly max?: string;
36
+ readonly locale?: string;
37
+ } & import("@cosmicdrift/kumiko-types/fields").ResolvedPiiFlags & import("@cosmicdrift/kumiko-types/fields").FieldStateConditions & {
38
+ required: false;
39
+ };
40
+ readonly lastExemptAt: {
41
+ readonly type: "timestamp";
42
+ readonly description?: string;
43
+ readonly required?: boolean;
44
+ readonly sortable?: boolean;
45
+ readonly sortNulls?: import("@cosmicdrift/kumiko-types/fields").SortNulls;
46
+ readonly filterable?: boolean;
47
+ readonly sensitive?: boolean;
48
+ readonly access?: import("@cosmicdrift/kumiko-types/fields").FieldAccess;
49
+ readonly locatedBy?: string;
50
+ readonly min?: string;
51
+ readonly max?: string;
52
+ readonly locale?: string;
53
+ } & import("@cosmicdrift/kumiko-types/fields").ResolvedPiiFlags & import("@cosmicdrift/kumiko-types/fields").FieldStateConditions & {
54
+ required: false;
55
+ };
56
+ readonly lastWarnedAt: {
57
+ readonly type: "timestamp";
58
+ readonly description?: string;
59
+ readonly required?: boolean;
60
+ readonly sortable?: boolean;
61
+ readonly sortNulls?: import("@cosmicdrift/kumiko-types/fields").SortNulls;
62
+ readonly filterable?: boolean;
63
+ readonly sensitive?: boolean;
64
+ readonly access?: import("@cosmicdrift/kumiko-types/fields").FieldAccess;
65
+ readonly locatedBy?: string;
66
+ readonly min?: string;
67
+ readonly max?: string;
68
+ readonly locale?: string;
69
+ } & import("@cosmicdrift/kumiko-types/fields").ResolvedPiiFlags & import("@cosmicdrift/kumiko-types/fields").FieldStateConditions & {
70
+ required: false;
71
+ };
72
+ readonly postponedDueAt: {
73
+ readonly type: "timestamp";
74
+ readonly description?: string;
75
+ readonly required?: boolean;
76
+ readonly sortable?: boolean;
77
+ readonly sortNulls?: import("@cosmicdrift/kumiko-types/fields").SortNulls;
78
+ readonly filterable?: boolean;
79
+ readonly sensitive?: boolean;
80
+ readonly access?: import("@cosmicdrift/kumiko-types/fields").FieldAccess;
81
+ readonly locatedBy?: string;
82
+ readonly min?: string;
83
+ readonly max?: string;
84
+ readonly locale?: string;
85
+ } & import("@cosmicdrift/kumiko-types/fields").ResolvedPiiFlags & import("@cosmicdrift/kumiko-types/fields").FieldStateConditions & {
86
+ required: false;
87
+ };
88
+ readonly warningsSent: {
89
+ readonly type: "number";
90
+ readonly description?: string;
91
+ readonly required?: boolean;
92
+ readonly sortable?: boolean;
93
+ readonly sortNulls?: import("@cosmicdrift/kumiko-types/fields").SortNulls;
94
+ readonly filterable?: boolean;
95
+ readonly sensitive?: boolean;
96
+ readonly default?: number;
97
+ readonly access?: import("@cosmicdrift/kumiko-types/fields").FieldAccess;
98
+ readonly min?: number;
99
+ readonly max?: number;
100
+ readonly integer?: boolean;
101
+ readonly unit?: string | {
102
+ readonly field: string;
103
+ };
104
+ readonly grouping?: boolean;
105
+ } & import("@cosmicdrift/kumiko-types/fields").ResolvedPiiFlags & import("@cosmicdrift/kumiko-types/fields").FieldStateConditions & {
106
+ required: true;
107
+ };
108
+ }, "tenant">;
109
+ export declare const tenantInactivityStateTable: import("@cosmicdrift/kumiko-types/entity-table-meta-types").EntityTableMeta & import("@cosmicdrift/kumiko-types/executor-brand").Writable;
@@ -0,0 +1,38 @@
1
+ import { deriveEntityTableMeta } from "@cosmicdrift/kumiko-framework/db";
2
+ import { access, createEntity, createNumberField, createTextField, createTimestampField, } from "@cosmicdrift/kumiko-framework/engine";
3
+ import { TENANT_INACTIVITY_STATE_ENTITY } from "./constants.js";
4
+ // One row per tenant. Direct-write store: the daily job and the keep-account handler mutate
5
+ // columns, there is no aggregate or event stream behind it.
6
+ export const tenantInactivityStateEntity = createEntity({
7
+ table: "store_tenant_inactivity_state",
8
+ softDelete: false,
9
+ fields: {
10
+ tenantId: createTextField({
11
+ required: true,
12
+ maxLength: 36,
13
+ access: { write: access.privileged },
14
+ personal: false,
15
+ reason: "pseudonymous_fk",
16
+ }),
17
+ cycleId: createTextField({
18
+ required: true,
19
+ maxLength: 36,
20
+ access: { write: access.privileged },
21
+ personal: false,
22
+ reason: "technical_reference",
23
+ }),
24
+ firstSeenAt: createTimestampField({ required: true, access: { write: access.privileged } }),
25
+ lastActivityAt: createTimestampField({ access: { write: access.privileged } }),
26
+ lastExemptAt: createTimestampField({ access: { write: access.privileged } }),
27
+ lastWarnedAt: createTimestampField({ access: { write: access.privileged } }),
28
+ postponedDueAt: createTimestampField({ access: { write: access.privileged } }),
29
+ warningsSent: createNumberField({
30
+ required: true,
31
+ integer: true,
32
+ min: 0,
33
+ access: { write: access.privileged },
34
+ }),
35
+ },
36
+ indexes: [{ unique: true, columns: ["tenantId"], name: "store_tenant_inactivity_state_tenant" }],
37
+ });
38
+ export const tenantInactivityStateTable = deriveEntityTableMeta(TENANT_INACTIVITY_STATE_ENTITY, tenantInactivityStateEntity, { source: "unmanaged" });
@@ -1,6 +1,7 @@
1
- import { EXT_EXTERNAL_RESOURCE, EXT_INFRA_RESOURCE, EXT_SEARCH_ADAPTER, EXT_STORAGE_PROVIDER, EXT_TENANT_DATA, isTenantDataExtensionHooks, isTenantResourceExtensionHooks, } from "@cosmicdrift/kumiko-framework/engine";
1
+ import { bootRuleError, EXT_EXTERNAL_RESOURCE, EXT_INFRA_RESOURCE, EXT_SEARCH_ADAPTER, EXT_STORAGE_PROVIDER, EXT_TENANT_DATA, isTenantDataExtensionHooks, isTenantResourceExtensionHooks, } from "@cosmicdrift/kumiko-framework/engine";
2
2
  import { createFallbackLogger } from "@cosmicdrift/kumiko-framework/logging";
3
3
  import { entitiesOf } from "../shared/index.js";
4
+ import { TENANT_LIFECYCLE_BOOT_RULES } from "./boot-rules.js";
4
5
  const log = createFallbackLogger("kumiko:boot");
5
6
  // V4: tenantOwned-entity-without-hook gate. Mirrors user-data-rights' V3
6
7
  // (validateGdprPiiHookCoverage) but for EXT_TENANT_DATA. Registered as this
@@ -32,7 +33,9 @@ export function validateTenantDataHookCoverage(features) {
32
33
  .map(([name]) => name);
33
34
  if (tenantSubjectFields.length === 0)
34
35
  continue;
35
- throw new Error(`[kumiko:boot] Entity "${entityName}" (feature "${feature.name}") has tenant-subject fields (${tenantSubjectFields.join(", ")}) but no feature registers an EXT_TENANT_DATA destroy hook for it — tenant destroy never erases this data. Register r.useExtension(EXT_TENANT_DATA, "${entityName}", { destroy }) or a documented no-op if crypto-shredding covers it.`);
36
+ throw bootRuleError(TENANT_LIFECYCLE_BOOT_RULES.tenantSubjectWithoutDestroyHook, {
37
+ message: `[kumiko:boot] Entity "${entityName}" (feature "${feature.name}") has tenant-subject fields (${tenantSubjectFields.join(", ")}) but no feature registers an EXT_TENANT_DATA destroy hook for it — tenant destroy never erases this data. Register r.useExtension(EXT_TENANT_DATA, "${entityName}", { destroy }) or a documented no-op if crypto-shredding covers it.`,
38
+ });
36
39
  }
37
40
  }
38
41
  }
@@ -58,7 +61,9 @@ export function validateTenantDestroyHookShapes(features) {
58
61
  if (isValid)
59
62
  continue;
60
63
  const requiredFn = isTenantData ? "destroy" : "destroyTenant";
61
- throw new Error(`[kumiko:boot] ${usage.extensionName} registration for "${usage.entityName}" (feature "${feature.name}") has no ${requiredFn} function — tenant destroy would fail at this stage.`);
64
+ throw bootRuleError(TENANT_LIFECYCLE_BOOT_RULES.destroyFunctionMissing, {
65
+ message: `[kumiko:boot] ${usage.extensionName} registration for "${usage.entityName}" (feature "${feature.name}") has no ${requiredFn} function — tenant destroy would fail at this stage.`,
66
+ });
62
67
  }
63
68
  }
64
69
  }
@@ -0,0 +1,12 @@
1
+ export declare const TENANT_LIFECYCLE_BOOT_RULES: {
2
+ readonly tenantSubjectWithoutDestroyHook: {
3
+ readonly id: "tenant-lifecycle/tenant-subject-without-destroy-hook";
4
+ readonly summary: "An entity with tenant-subject fields has an EXT_TENANT_DATA destroy hook, so tenant destroy erases its data.";
5
+ readonly fix: 'Register r.useExtension(EXT_TENANT_DATA, "<entity>", { destroy }) or a documented no-op if crypto-shredding covers it.';
6
+ };
7
+ readonly destroyFunctionMissing: {
8
+ readonly id: "tenant-lifecycle/destroy-function-missing";
9
+ readonly summary: "A tenant data or tenant resource extension registration provides its destroy function, otherwise tenant destroy fails at that stage.";
10
+ readonly fix: "Provide destroy (EXT_TENANT_DATA) or destroyTenant (tenant resource extensions) in the registration options.";
11
+ };
12
+ };
@@ -0,0 +1,12 @@
1
+ export const TENANT_LIFECYCLE_BOOT_RULES = {
2
+ tenantSubjectWithoutDestroyHook: {
3
+ id: "tenant-lifecycle/tenant-subject-without-destroy-hook",
4
+ summary: "An entity with tenant-subject fields has an EXT_TENANT_DATA destroy hook, so tenant destroy erases its data.",
5
+ fix: 'Register r.useExtension(EXT_TENANT_DATA, "<entity>", { destroy }) or a documented no-op if crypto-shredding covers it.',
6
+ },
7
+ destroyFunctionMissing: {
8
+ id: "tenant-lifecycle/destroy-function-missing",
9
+ summary: "A tenant data or tenant resource extension registration provides its destroy function, otherwise tenant destroy fails at that stage.",
10
+ fix: "Provide destroy (EXT_TENANT_DATA) or destroyTenant (tenant resource extensions) in the registration options.",
11
+ },
12
+ };
@@ -1,10 +1,12 @@
1
1
  import { defineFeature, EXT_EXTERNAL_RESOURCE, EXT_INFRA_RESOURCE, EXT_SEARCH_ADAPTER, EXT_STORAGE_PROVIDER, EXT_TENANT_DATA, EXT_TENANT_LIFECYCLE_STATUS, } from "@cosmicdrift/kumiko-framework/engine";
2
+ import { EXT_TENANT_DESTRUCTION_HOLD } from "../shared/index.js";
2
3
  import { validateTenantDataHookCoverage, validateTenantDestroyHookShapes, warnIfFilesMountedWithoutTenantData, } from "./boot-checks.js";
3
4
  import { DESTRUCTION_CANCELLED_EVENT_SHORT, DESTRUCTION_REQUESTED_EVENT_SHORT, TENANT_DESTRUCTION_COMPLETED_EVENT_SHORT, TENANT_DESTRUCTION_FAILED_EVENT_SHORT, TENANT_DESTRUCTION_STAGE_ABANDONED_EVENT_SHORT, TENANT_DESTRUCTION_STAGE_FAILED_EVENT_SHORT, TENANT_DESTRUCTION_STAGE_PROGRESSED_EVENT_SHORT, TENANT_DESTRUCTION_STAGE_STARTED_EVENT_SHORT, TENANT_DESTRUCTION_STAGE_SUCCEEDED_EVENT_SHORT, TENANT_DESTRUCTION_STARTED_EVENT_SHORT, } from "./constants.js";
4
5
  import { destructionCancelledSchema, destructionRequestedSchema, tenantDestructionCompletedSchema, tenantDestructionFailedSchema, tenantDestructionStageAbandonedSchema, tenantDestructionStageFailedSchema, tenantDestructionStageProgressedSchema, tenantDestructionStageStartedSchema, tenantDestructionStageSucceededSchema, tenantDestructionStartedSchema, } from "./events.js";
5
6
  import { cancelDestructionWrite } from "./handlers/cancel-destruction.write.js";
6
7
  import { requestDestructionWrite } from "./handlers/request-destruction.write.js";
7
- import { hasTenantDestructionWork, resolveTenantLifecycleGate, runTenantDestructionSweep, } from "./run-tenant-destroy.js";
8
+ import { COMPLIANCE_PROFILE_ENTITY_NAME, complianceProfileTenantDestroyHook, RETENTION_OVERRIDE_ENTITY_NAME, retentionOverrideTenantDestroyHook, } from "./retention-config-destroy-hooks.js";
9
+ import { hasTenantDestructionWork, resolveTenantLifecycleGate, runTenantDestructionSweep, tenantDestructionHoldProvider, } from "./run-tenant-destroy.js";
8
10
  const tenantLifecycleStatusPlugin = {
9
11
  async resolveStatus(tenantId, { db }) {
10
12
  const gate = await resolveTenantLifecycleGate(db, tenantId);
@@ -20,13 +22,26 @@ export function createTenantLifecycleFeature() {
20
22
  recommended: false,
21
23
  });
22
24
  r.requires({ features: ["tenant", "compliance-profiles"] });
23
- r.optionalRequires("sessions");
25
+ r.optionalRequires("sessions", "data-retention");
24
26
  r.usesApi("compliance.forTenant");
25
27
  r.extendsRegistrar(EXT_TENANT_DATA, {});
26
28
  r.extendsRegistrar(EXT_SEARCH_ADAPTER, {});
27
29
  r.extendsRegistrar(EXT_EXTERNAL_RESOURCE, {});
28
30
  r.extendsRegistrar(EXT_STORAGE_PROVIDER, {});
29
31
  r.extendsRegistrar(EXT_INFRA_RESOURCE, {});
32
+ // Self-extension: data-retention hands a parked tenant back through this, see shared/tenant-destruction-hold.ts.
33
+ r.extendsRegistrar(EXT_TENANT_DESTRUCTION_HOLD, {});
34
+ r.useExtension(EXT_TENANT_DESTRUCTION_HOLD, "tenant-lifecycle", tenantDestructionHoldProvider);
35
+ // Registered here because the hosts of these entities cannot require tenant-lifecycle (cycle,
36
+ // resp. standalone use); the override hook no-ops without data-retention.
37
+ r.useExtension(EXT_TENANT_DATA, COMPLIANCE_PROFILE_ENTITY_NAME, {
38
+ destroy: complianceProfileTenantDestroyHook,
39
+ phase: "tenant-row",
40
+ });
41
+ r.useExtension(EXT_TENANT_DATA, RETENTION_OVERRIDE_ENTITY_NAME, {
42
+ destroy: retentionOverrideTenantDestroyHook,
43
+ phase: "tenant-row",
44
+ });
30
45
  // Self-extension, same pattern as `user`/EXT_PRINCIPAL_STATUS — declares
31
46
  // AND fulfils tenantLifecycleStatus so teardown state is visible with no per-app wiring.
32
47
  r.extendsRegistrar(EXT_TENANT_LIFECYCLE_STATUS, {});