@cosmicdrift/kumiko-samples 0.405.0 → 0.409.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 (242) hide show
  1. package/package.json +1 -1
  2. package/packages/bundled-features/package.json +26 -4
  3. package/packages/bundled-features/src/account-security/feature.ts +9 -1
  4. package/packages/bundled-features/src/admin-shell/changes.json +6 -0
  5. package/packages/bundled-features/src/admin-shell/feature.ts +4 -1
  6. package/packages/bundled-features/src/agent-tools/agent-manifest.ts +1 -0
  7. package/packages/bundled-features/src/agent-tools/changes.json +6 -0
  8. package/packages/bundled-features/src/agent-tools/tool-catalog.ts +1 -0
  9. package/packages/bundled-features/src/agent-tools/types.ts +4 -0
  10. package/packages/bundled-features/src/audit/event-classification.ts +1 -0
  11. package/packages/bundled-features/src/auth-email-password/bootstrap.ts +1 -0
  12. package/packages/bundled-features/src/auth-email-password/errors.ts +18 -66
  13. package/packages/bundled-features/src/auth-email-password/web/auth-client.ts +30 -64
  14. package/packages/bundled-features/src/auth-email-password/web/auth-redirect.ts +2 -2
  15. package/packages/bundled-features/src/auth-email-password/web/confirm-account-unlock-screen.tsx +20 -66
  16. package/packages/bundled-features/src/auth-email-password/web/index.ts +1 -0
  17. package/packages/bundled-features/src/auth-email-password/web/read-path-param.ts +8 -0
  18. package/packages/bundled-features/src/auth-email-password/web/return-path.ts +3 -2
  19. package/packages/bundled-features/src/auth-email-password/web/token-confirm-screen.tsx +97 -0
  20. package/packages/bundled-features/src/auth-email-password/web/verify-email-screen.tsx +20 -68
  21. package/packages/bundled-features/src/auth-foundation/boot-checks.ts +22 -15
  22. package/packages/bundled-features/src/auth-foundation/boot-rules.ts +33 -0
  23. package/packages/bundled-features/src/auth-mfa/errors.ts +12 -42
  24. package/packages/bundled-features/src/auth-mfa/feature-exports.ts +6 -45
  25. package/packages/bundled-features/src/auth-mfa/feature.ts +8 -19
  26. package/packages/bundled-features/src/auth-mfa/web/mfa-client.ts +19 -33
  27. package/packages/bundled-features/src/billing-foundation/consumer-protection/termination-notify.ts +1 -0
  28. package/packages/bundled-features/src/billing-foundation/web/plan-price.ts +20 -7
  29. package/packages/bundled-features/src/cap-counter/stock-cap-guard.ts +1 -0
  30. package/packages/bundled-features/src/channel-in-app/changes.json +7 -0
  31. package/packages/bundled-features/src/channel-in-app/feature.ts +2 -0
  32. package/packages/bundled-features/src/channel-in-app/handlers/read-state-by-keys.query.ts +35 -0
  33. package/packages/bundled-features/src/channel-in-app/in-app-channel.ts +1 -0
  34. package/packages/bundled-features/src/channel-in-app/tables.ts +5 -1
  35. package/packages/bundled-features/src/contact/challenge.ts +41 -0
  36. package/packages/bundled-features/src/contact/changes.json +27 -0
  37. package/packages/bundled-features/src/contact/client/contact-client-source.ts +203 -0
  38. package/packages/bundled-features/src/contact/entity.ts +168 -0
  39. package/packages/bundled-features/src/contact/feature.ts +171 -0
  40. package/packages/bundled-features/src/contact/handlers/access.ts +17 -0
  41. package/packages/bundled-features/src/contact/handlers/attempts.ts +76 -0
  42. package/packages/bundled-features/src/contact/handlers/challenge.query.ts +44 -0
  43. package/packages/bundled-features/src/contact/handlers/forward-request.write.ts +98 -0
  44. package/packages/bundled-features/src/contact/handlers/mark-done.write.ts +40 -0
  45. package/packages/bundled-features/src/contact/handlers/notify-reporter-in-app.write.ts +48 -0
  46. package/packages/bundled-features/src/contact/handlers/open-count.query.ts +15 -0
  47. package/packages/bundled-features/src/contact/handlers/open-count.ts +17 -0
  48. package/packages/bundled-features/src/contact/handlers/replies.query.ts +29 -0
  49. package/packages/bundled-features/src/contact/handlers/reply.write.ts +197 -0
  50. package/packages/bundled-features/src/contact/handlers/report.write.ts +126 -0
  51. package/packages/bundled-features/src/contact/handlers/request-delivery.query.ts +143 -0
  52. package/packages/bundled-features/src/contact/handlers/request-detail.query.ts +50 -0
  53. package/packages/bundled-features/src/contact/handlers/request-list.query.ts +14 -0
  54. package/packages/bundled-features/src/contact/handlers/send-reply-mail.write.ts +124 -0
  55. package/packages/bundled-features/src/contact/handlers/send-test.write.ts +45 -0
  56. package/packages/bundled-features/src/contact/handlers/submit.write.ts +194 -0
  57. package/packages/bundled-features/src/contact/handlers/take-over-uploads.ts +47 -0
  58. package/packages/bundled-features/src/contact/i18n.ts +189 -0
  59. package/packages/bundled-features/src/contact/index.ts +29 -0
  60. package/packages/bundled-features/src/contact/lib.ts +176 -0
  61. package/packages/bundled-features/src/contact/mail.ts +401 -0
  62. package/packages/bundled-features/src/contact/options.ts +95 -0
  63. package/packages/bundled-features/src/contact/panels.ts +28 -0
  64. package/packages/bundled-features/src/contact/payloads.ts +106 -0
  65. package/packages/bundled-features/src/contact/pow.ts +22 -0
  66. package/packages/bundled-features/src/contact/screens.ts +506 -0
  67. package/packages/bundled-features/src/contact/subject.ts +13 -0
  68. package/packages/bundled-features/src/contact/user-agent.ts +39 -0
  69. package/packages/bundled-features/src/contact/user-data-hooks.ts +180 -0
  70. package/packages/bundled-features/src/contact/web/constants.ts +160 -0
  71. package/packages/bundled-features/src/contact/web/index.ts +29 -0
  72. package/packages/bundled-features/src/crypto-shredding/handlers/forget-subject.write.ts +5 -16
  73. package/packages/bundled-features/src/data-retention/changes.json +6 -0
  74. package/packages/bundled-features/src/data-retention/feature.ts +16 -2
  75. package/packages/bundled-features/src/data-retention/index.ts +5 -0
  76. package/packages/bundled-features/src/data-retention/run-retention-cleanup.ts +138 -41
  77. package/packages/bundled-features/src/data-retention/tenant-destruction-hold.ts +196 -0
  78. package/packages/bundled-features/src/delivery/address-opt-out.ts +1 -0
  79. package/packages/bundled-features/src/delivery/changes.json +7 -0
  80. package/packages/bundled-features/src/delivery/channel-context.ts +2 -0
  81. package/packages/bundled-features/src/delivery/delivery-service.ts +29 -5
  82. package/packages/bundled-features/src/delivery/events.ts +2 -0
  83. package/packages/bundled-features/src/delivery/feature.ts +3 -2
  84. package/packages/bundled-features/src/delivery/handlers/attempts-by-keys.query.ts +55 -0
  85. package/packages/bundled-features/src/delivery/handlers/log.query.ts +1 -1
  86. package/packages/bundled-features/src/delivery/jobs.ts +5 -0
  87. package/packages/bundled-features/src/delivery/tables.ts +13 -2
  88. package/packages/bundled-features/src/delivery/types.ts +3 -0
  89. package/packages/bundled-features/src/delivery/unsubscribe-page.ts +2 -0
  90. package/packages/bundled-features/src/delivery/web/delivery-channel-cell.tsx +1 -1
  91. package/packages/bundled-features/src/delivery/web/delivery-error-cell.tsx +1 -1
  92. package/packages/bundled-features/src/delivery/web/delivery-status-cell.tsx +1 -1
  93. package/packages/bundled-features/src/delivery/web/delivery-time-cell.tsx +3 -2
  94. package/packages/bundled-features/src/delivery/web/delivery-type-cell.tsx +1 -1
  95. package/packages/bundled-features/src/delivery/web/public-names.ts +1 -0
  96. package/packages/bundled-features/src/document-ingest-foundation/boot-checks.ts +14 -9
  97. package/packages/bundled-features/src/document-ingest-foundation/boot-rules.ts +22 -0
  98. package/packages/bundled-features/src/document-ingest-foundation/changes.json +6 -0
  99. package/packages/bundled-features/src/document-ingest-foundation/events.ts +17 -0
  100. package/packages/bundled-features/src/document-ingest-foundation/feature.ts +39 -1
  101. package/packages/bundled-features/src/document-ingest-foundation/index.ts +10 -0
  102. package/packages/bundled-features/src/document-ingest-foundation/report-ingest-progress.ts +43 -0
  103. package/packages/bundled-features/src/document-ingest-foundation/tables.ts +43 -0
  104. package/packages/bundled-features/src/files-tenant-data/changes.json +6 -0
  105. package/packages/bundled-features/src/files-tenant-data/hooks.ts +4 -1
  106. package/packages/bundled-features/src/folders/web/folder-manager.tsx +8 -9
  107. package/packages/bundled-features/src/folders/web/folder-section.tsx +1 -1
  108. package/packages/bundled-features/src/form-draft-user-data/index.ts +2 -0
  109. package/packages/bundled-features/src/inbound-mail-foundation/changes.json +13 -0
  110. package/packages/bundled-features/src/inbound-mail-foundation/entities.ts +2 -0
  111. package/packages/bundled-features/src/inbound-mail-foundation/events.ts +2 -0
  112. package/packages/bundled-features/src/inbound-mail-foundation/feature.ts +6 -6
  113. package/packages/bundled-features/src/inbound-mail-foundation/handlers/attach-message-content.write.ts +7 -0
  114. package/packages/bundled-features/src/inbound-mail-foundation/handlers/ingest-message.write.ts +6 -0
  115. package/packages/bundled-features/src/inbound-mail-foundation/handlers/list-messages.query.ts +6 -2
  116. package/packages/bundled-features/src/inbound-mail-foundation/handlers/message-content.query.ts +3 -0
  117. package/packages/bundled-features/src/inbound-mail-foundation/handlers/message-content.ts +19 -0
  118. package/packages/bundled-features/src/inbound-mail-foundation/projection.ts +2 -0
  119. package/packages/bundled-features/src/inbound-mail-foundation/sanitize-inbound-html.ts +150 -0
  120. package/packages/bundled-features/src/inbound-mail-foundation/types.ts +1 -0
  121. package/packages/bundled-features/src/jobs/job-run-logger.ts +24 -25
  122. package/packages/bundled-features/src/ledger/handlers/reports.query.ts +46 -31
  123. package/packages/bundled-features/src/ledger/recurring.ts +1 -0
  124. package/packages/bundled-features/src/notes-history/web/notes-section.tsx +3 -1
  125. package/packages/bundled-features/src/personal-access-tokens/feature.ts +9 -17
  126. package/packages/bundled-features/src/personal-access-tokens/handlers/create.write.ts +2 -7
  127. package/packages/bundled-features/src/secrets/changes.json +6 -0
  128. package/packages/bundled-features/src/secrets/handlers/delete.write.ts +8 -4
  129. package/packages/bundled-features/src/secrets/handlers/list.query.ts +6 -3
  130. package/packages/bundled-features/src/secrets/handlers/set.write.ts +9 -4
  131. package/packages/bundled-features/src/secrets/secret-scope.ts +33 -0
  132. package/packages/bundled-features/src/sessions/changes.json +6 -0
  133. package/packages/bundled-features/src/sessions/feature.ts +21 -18
  134. package/packages/bundled-features/src/sessions/handlers/last-activity-probe.query.ts +53 -0
  135. package/packages/bundled-features/src/sessions/handlers/last-activity-probe.route.ts +39 -0
  136. package/packages/bundled-features/src/sessions/screens.ts +1 -0
  137. package/packages/bundled-features/src/sessions/session-callbacks.ts +13 -12
  138. package/packages/bundled-features/src/sessions/web/i18n.ts +4 -1
  139. package/packages/bundled-features/src/shared/assert-billing-live.ts +14 -0
  140. package/packages/bundled-features/src/shared/collect-extension-options.ts +12 -0
  141. package/packages/bundled-features/src/shared/index.ts +16 -0
  142. package/packages/bundled-features/src/shared/late-bound-slot.ts +19 -0
  143. package/packages/bundled-features/src/shared/mail-locale-templates.ts +7 -1
  144. package/packages/bundled-features/src/shared/price-env-shape.ts +44 -0
  145. package/packages/bundled-features/src/shared/purge-row-file-refs.ts +1 -1
  146. package/packages/bundled-features/src/shared/read-feature-export-fn.ts +16 -0
  147. package/packages/bundled-features/src/shared/signup-handover.ts +3 -4
  148. package/packages/bundled-features/src/shared/tenant-destruction-hold.ts +49 -0
  149. package/packages/bundled-features/src/shared/unprocessable.ts +19 -0
  150. package/packages/bundled-features/src/shared/web/index.ts +3 -0
  151. package/packages/bundled-features/src/subscription-paddle/feature.ts +7 -15
  152. package/packages/bundled-features/src/subscription-paddle/runtime.ts +4 -7
  153. package/packages/bundled-features/src/subscription-stripe/feature.ts +7 -15
  154. package/packages/bundled-features/src/subscription-stripe/runtime.ts +4 -7
  155. package/packages/bundled-features/src/tags/entity.ts +1 -0
  156. package/packages/bundled-features/src/tags/web/tag-chip.tsx +14 -0
  157. package/packages/bundled-features/src/tags/web/tag-filter.tsx +4 -5
  158. package/packages/bundled-features/src/tags/web/tag-manager.tsx +1 -1
  159. package/packages/bundled-features/src/tags/web/tag-section.tsx +3 -6
  160. package/packages/bundled-features/src/tags/web/tags-cell.tsx +4 -5
  161. package/packages/bundled-features/src/template-resolver/compile-document-body.ts +27 -15
  162. package/packages/bundled-features/src/template-resolver/handlers/by-tenant.query.ts +11 -8
  163. package/packages/bundled-features/src/template-resolver/handlers/discard-draft.write.ts +1 -0
  164. package/packages/bundled-features/src/template-resolver/handlers/overview.query.ts +1 -0
  165. package/packages/bundled-features/src/template-resolver/handlers/send-test.write.ts +5 -5
  166. package/packages/bundled-features/src/template-resolver/handlers/toggle-status.write.ts +3 -0
  167. package/packages/bundled-features/src/template-resolver/linked-resources.ts +11 -6
  168. package/packages/bundled-features/src/template-resolver/store-template-resource.ts +15 -12
  169. package/packages/bundled-features/src/template-resolver/web/document-images.ts +6 -6
  170. package/packages/bundled-features/src/template-resolver/web/document-insert-fields.tsx +41 -36
  171. package/packages/bundled-features/src/template-resolver/web/document-schema.ts +11 -12
  172. package/packages/bundled-features/src/template-resolver/web/tiptap-attribute-parse-rule.ts +19 -0
  173. package/packages/bundled-features/src/tenant/i18n.ts +3 -0
  174. package/packages/bundled-features/src/tenant/schema/tenant.ts +1 -0
  175. package/packages/bundled-features/src/tenant/web/member-roles-cell.tsx +1 -1
  176. package/packages/bundled-features/src/tenant/web/member-status-cell.tsx +1 -1
  177. package/packages/bundled-features/src/tenant-inactivity/changes.json +8 -0
  178. package/packages/bundled-features/src/tenant-inactivity/check-inactive-tenants.ts +260 -0
  179. package/packages/bundled-features/src/tenant-inactivity/constants.ts +12 -0
  180. package/packages/bundled-features/src/tenant-inactivity/email-templates.ts +24 -0
  181. package/packages/bundled-features/src/tenant-inactivity/feature.ts +66 -0
  182. package/packages/bundled-features/src/tenant-inactivity/handlers/inactivity-state.query.ts +49 -0
  183. package/packages/bundled-features/src/tenant-inactivity/handlers/keep-account.write.ts +56 -0
  184. package/packages/bundled-features/src/tenant-inactivity/inactivity-plan.ts +187 -0
  185. package/packages/bundled-features/src/tenant-inactivity/index.ts +5 -0
  186. package/packages/bundled-features/src/tenant-inactivity/keep-token.ts +44 -0
  187. package/packages/bundled-features/src/tenant-inactivity/mail-notifications.ts +62 -0
  188. package/packages/bundled-features/src/tenant-inactivity/options.ts +38 -0
  189. package/packages/bundled-features/src/tenant-inactivity/remote-activity.ts +32 -0
  190. package/packages/bundled-features/src/tenant-inactivity/state-store.ts +71 -0
  191. package/packages/bundled-features/src/tenant-inactivity/state-table.ts +50 -0
  192. package/packages/bundled-features/src/tenant-lifecycle/boot-checks.ts +8 -6
  193. package/packages/bundled-features/src/tenant-lifecycle/boot-rules.ts +16 -0
  194. package/packages/bundled-features/src/tenant-lifecycle/changes.json +30 -0
  195. package/packages/bundled-features/src/tenant-lifecycle/constants.ts +6 -0
  196. package/packages/bundled-features/src/tenant-lifecycle/events.ts +2 -0
  197. package/packages/bundled-features/src/tenant-lifecycle/feature.ts +25 -2
  198. package/packages/bundled-features/src/tenant-lifecycle/handlers/request-destruction.write.ts +12 -87
  199. package/packages/bundled-features/src/tenant-lifecycle/index.ts +6 -0
  200. package/packages/bundled-features/src/tenant-lifecycle/request-tenant-destruction.ts +108 -0
  201. package/packages/bundled-features/src/tenant-lifecycle/retention-config-destroy-hooks.ts +62 -0
  202. package/packages/bundled-features/src/tenant-lifecycle/run-tenant-destroy.ts +131 -11
  203. package/packages/bundled-features/src/tenant-lifecycle/stages.ts +39 -4
  204. package/packages/bundled-features/src/tenant-lifecycle/testing.ts +1 -1
  205. package/packages/bundled-features/src/tier-engine/caps-for-tier-from-map.ts +16 -0
  206. package/packages/bundled-features/src/tier-engine/changes.json +6 -0
  207. package/packages/bundled-features/src/tier-engine/compose-app.ts +21 -20
  208. package/packages/bundled-features/src/tier-engine/index.ts +1 -0
  209. package/packages/bundled-features/src/user-data-rights/feature.ts +2 -0
  210. package/packages/bundled-features/src/user-data-rights/run-forget-cleanup.ts +2 -0
  211. package/packages/bundled-features/src/user-data-rights/web/privacy-center-screen.tsx +1 -1
  212. package/packages/bundled-features/src/user-data-rights/zip-path.ts +1 -0
  213. package/packages/bundled-features/src/user-data-rights-defaults/hooks/config-value.userdata-hook.ts +8 -27
  214. package/packages/bundled-features/src/user-data-rights-defaults/hooks/delivery-attempt.userdata-hook.ts +11 -8
  215. package/packages/bundled-features/src/user-data-rights-defaults/hooks/forget-own-rows-delete-hook.ts +42 -0
  216. package/packages/bundled-features/src/user-data-rights-defaults/hooks/notification-preference.userdata-hook.ts +8 -27
  217. package/packages/bundled-features/src/user-profile/handlers/change-email.write.ts +2 -6
  218. package/packages/bundled-features/src/user-profile/web/profile-screen.tsx +2 -3
  219. package/samples/apps/styleguide/src/features/widgets/i18n.ts +6 -0
  220. package/samples/apps/styleguide/src/features/widgets/web/InboxReaderExamples.tsx +158 -0
  221. package/samples/apps/styleguide/src/features/widgets/web/Widgets.tsx +2 -0
  222. package/samples/apps/styleguide/src/features/widgets/web/sample-pdf.ts +28 -0
  223. package/samples/apps/use-all-bundled/feature-manifest.json +134 -2
  224. package/samples/apps/use-all-bundled/kumiko/migrations/0063_contact.rebuild.json +4 -0
  225. package/samples/apps/use-all-bundled/package.json +1 -0
  226. package/samples/apps/use-all-bundled/playwright.config.ts +2 -0
  227. package/samples/apps/use-all-bundled/src/app/client.tsx +3 -0
  228. package/samples/apps/use-all-bundled/src/app/screens-feature.ts +46 -2
  229. package/samples/apps/use-all-bundled/src/run-config.ts +38 -4
  230. package/samples/recipes/contact/README.md +46 -0
  231. package/samples/recipes/contact/package.json +12 -0
  232. package/samples/recipes/contact/src/feature.ts +27 -0
  233. package/samples/recipes/delivery-notifications/src/feature.ts +3 -0
  234. package/samples/recipes/lane-routing/README.md +1 -0
  235. package/samples/recipes/lane-routing/src/feature.ts +8 -0
  236. package/samples/recipes/record-detail-layout/src/feature.ts +9 -1
  237. package/samples/recipes/search/README.md +2 -0
  238. package/samples/recipes/search/src/feature.ts +27 -2
  239. package/samples/recipes/secrets-demo/README.md +1 -0
  240. package/samples/recipes/secrets-demo/src/feature.ts +56 -0
  241. package/samples/recipes/tenant-inactivity/README.md +21 -0
  242. package/samples/recipes/tenant-inactivity/package.json +12 -0
@@ -119,6 +119,7 @@ export function makeArchiveWrite(policy: TemplateEditPolicy) {
119
119
  "Sets one template resource of the caller's tenant to archived so the resolver stops serving it while the row and its content survive; use it to retire a template reversibly instead of deleting it. An open draft stays. Outside the templates the app lists in tenantEditable only a SystemAdmin may use it.",
120
120
  );
121
121
  }
122
+ // guard:dup-ok one configured createStatusUpdateHandler instance; only name, scope, status and description differ
122
123
  export function makePublishWrite(policy: TemplateEditPolicy) {
123
124
  return createStatusUpdateHandler(
124
125
  policy,
@@ -128,6 +129,7 @@ export function makePublishWrite(policy: TemplateEditPolicy) {
128
129
  "Sets one template resource of the caller's tenant to active so the resolver starts serving it; use it to release a draft written by upsert-tenant (a draft saved beside an active version replaces it), or to bring an archived template back; a version with unknown placeholders or unused required variables is refused and the served version stays. Outside the templates the app lists in tenantEditable only a SystemAdmin may use it.",
129
130
  );
130
131
  }
132
+ // guard:dup-ok one configured createStatusUpdateHandler instance; only name, scope, status and description differ
131
133
  export function makeArchiveSystemWrite(policy: TemplateEditPolicy) {
132
134
  return createStatusUpdateHandler(
133
135
  policy,
@@ -137,6 +139,7 @@ export function makeArchiveSystemWrite(policy: TemplateEditPolicy) {
137
139
  "Sets one system-default template to archived so the resolver stops serving it to every tenant that has no override; SystemAdmin only, reversible with publish-system.",
138
140
  );
139
141
  }
142
+ // guard:dup-ok one configured createStatusUpdateHandler instance; only name, scope, status and description differ
140
143
  export function makePublishSystemWrite(policy: TemplateEditPolicy) {
141
144
  return createStatusUpdateHandler(
142
145
  policy,
@@ -73,20 +73,25 @@ export function imageLinksOf(
73
73
  return images;
74
74
  }
75
75
 
76
- export function fileAttachmentsOf(
76
+ function entriesOfKind<TEntry extends LinkedResourceEntry>(
77
77
  entries: Readonly<Record<string, LinkedResourceEntry>>,
78
- ): FileAttachmentRef[] {
78
+ isKind: (entry: LinkedResourceEntry) => entry is TEntry,
79
+ ): TEntry[] {
79
80
  return Object.entries(entries)
80
81
  .sort(([a], [b]) => a.localeCompare(b))
81
- .flatMap(([, entry]) => (isFileAttachmentEntry(entry) ? [entry] : []));
82
+ .flatMap(([, entry]) => (isKind(entry) ? [entry] : []));
83
+ }
84
+
85
+ export function fileAttachmentsOf(
86
+ entries: Readonly<Record<string, LinkedResourceEntry>>,
87
+ ): FileAttachmentRef[] {
88
+ return entriesOfKind(entries, isFileAttachmentEntry);
82
89
  }
83
90
 
84
91
  export function pdfAttachmentLinksOf(
85
92
  entries: Readonly<Record<string, LinkedResourceEntry>>,
86
93
  ): TemplatePdfAttachmentLink[] {
87
- return Object.entries(entries)
88
- .sort(([a], [b]) => a.localeCompare(b))
89
- .flatMap(([, entry]) => (isPdfAttachmentLink(entry) ? [entry] : []));
94
+ return entriesOfKind(entries, isPdfAttachmentLink);
90
95
  }
91
96
 
92
97
  export function attachmentEntriesOf(
@@ -21,7 +21,11 @@ import {
21
21
  uploadFileBytesBeforeTransaction,
22
22
  } from "@cosmicdrift/kumiko-framework/files";
23
23
  import { fileContextForTenant, readFileRefContent } from "../file-foundation/index.ts";
24
- import { extensionForResourceContentType, requireForTenant } from "../shared/index.ts";
24
+ import {
25
+ extensionForResourceContentType,
26
+ requireForTenant,
27
+ unprocessable,
28
+ } from "../shared/index.ts";
25
29
  import {
26
30
  DEFAULT_RESOURCE_MAX_BYTES,
27
31
  MAX_FILE_ATTACHMENTS_PER_TEMPLATE,
@@ -303,10 +307,9 @@ function copiedFileName(key: string, entry: LinkedResourceEntry, contentType: st
303
307
  }
304
308
 
305
309
  function sourceUnreadable(): WriteResult<never> {
306
- return writeFailure(
307
- new UnprocessableError(TemplateResolverErrors.resourceSourceUnreadable, {
308
- i18nKey: "templateResolver.errors.resource.sourceUnreadable",
309
- }),
310
+ return unprocessable(
311
+ TemplateResolverErrors.resourceSourceUnreadable,
312
+ "templateResolver.errors.resource.sourceUnreadable",
310
313
  );
311
314
  }
312
315
 
@@ -667,14 +670,14 @@ export type LinkedTemplatePdfAttachment = {
667
670
  readonly fileName: string;
668
671
  };
669
672
 
670
- function pdfAttachmentInvalid(code: string): WriteResult<never> {
671
- return writeFailure(
672
- new UnprocessableError(TemplateResolverErrors.attachmentInvalid, {
673
- i18nKey: "templateResolver.errors.attachment.invalid",
674
- details: { code },
675
- }),
673
+ const pdfAttachmentInvalid = (code: string): WriteResult<never> =>
674
+ unprocessable(
675
+ TemplateResolverErrors.attachmentInvalid,
676
+ "templateResolver.errors.attachment.invalid",
677
+ {
678
+ code,
679
+ },
676
680
  );
677
- }
678
681
 
679
682
  // Links a PDF that is rendered from a document template at send time into a mail template of the
680
683
  // target tenant. Nothing is stored besides the link entry. The caller authorizes tenantId.
@@ -1,6 +1,7 @@
1
1
  // The record's photos: a block bound to an `images` variable whose FileRef ids the
2
2
  // app passes at render time. Universal like document-schema.ts.
3
3
  import { Node } from "@tiptap/core";
4
+ import { attributeParseRule } from "./tiptap-attribute-parse-rule.ts";
4
5
 
5
6
  export function createDocumentImagesNode(isReferenceName: (value: string) => boolean) {
6
7
  return Node.create({
@@ -12,13 +13,12 @@ export function createDocumentImagesNode(isReferenceName: (value: string) => boo
12
13
  },
13
14
  parseHTML() {
14
15
  return [
15
- {
16
+ attributeParseRule({
16
17
  tag: "div[data-images]",
17
- getAttrs: (element) => {
18
- const variable = element.getAttribute("data-images");
19
- return variable !== null && isReferenceName(variable) ? { variable } : false;
20
- },
21
- },
18
+ attribute: "data-images",
19
+ key: "variable",
20
+ isValid: isReferenceName,
21
+ }),
22
22
  ];
23
23
  },
24
24
  renderHTML({ node }) {
@@ -123,26 +123,37 @@ function renderImageFields(m: PanelModel): ReactNode {
123
123
  );
124
124
  }
125
125
 
126
- function renderButtonFields(m: PanelModel): ReactNode {
127
- const { t, Field, Input, idPrefix } = m;
126
+ function renderVariableAndTextFields(
127
+ m: PanelModel,
128
+ fields: {
129
+ readonly variableIdSuffix: string;
130
+ readonly variableLabel: string;
131
+ readonly textIdSuffix: string;
132
+ readonly textLabel: string;
133
+ readonly textName: string;
134
+ readonly textValue: string;
135
+ readonly onTextChange: (value: string) => void;
136
+ },
137
+ ): ReactNode {
138
+ const { Field, Input, idPrefix } = m;
128
139
  return (
129
140
  !m.noVariables && (
130
141
  <>
131
142
  <NameSelect
132
- id={`${idPrefix}-target`}
133
- label={t("template-resolver.documentEditor.buttonTarget")}
143
+ id={`${idPrefix}-${fields.variableIdSuffix}`}
144
+ label={fields.variableLabel}
134
145
  names={m.selectable}
135
146
  labels={m.variableLabels}
136
147
  value={m.selectedName}
137
148
  onChange={m.setChosenName}
138
149
  />
139
- <Field id={`${idPrefix}-text`} label={t("template-resolver.documentEditor.buttonText")}>
150
+ <Field id={`${idPrefix}-${fields.textIdSuffix}`} label={fields.textLabel}>
140
151
  <Input
141
152
  kind="text"
142
- id={`${idPrefix}-text`}
143
- name="text"
144
- value={m.buttonText}
145
- onChange={m.setButtonText}
153
+ id={`${idPrefix}-${fields.textIdSuffix}`}
154
+ name={fields.textName}
155
+ value={fields.textValue}
156
+ onChange={fields.onTextChange}
146
157
  />
147
158
  </Field>
148
159
  </>
@@ -150,6 +161,18 @@ function renderButtonFields(m: PanelModel): ReactNode {
150
161
  );
151
162
  }
152
163
 
164
+ function renderButtonFields(m: PanelModel): ReactNode {
165
+ return renderVariableAndTextFields(m, {
166
+ variableIdSuffix: "target",
167
+ variableLabel: m.t("template-resolver.documentEditor.buttonTarget"),
168
+ textIdSuffix: "text",
169
+ textLabel: m.t("template-resolver.documentEditor.buttonText"),
170
+ textName: "text",
171
+ textValue: m.buttonText,
172
+ onTextChange: m.setButtonText,
173
+ });
174
+ }
175
+
153
176
  function renderRepeatFields(m: PanelModel): ReactNode {
154
177
  return (
155
178
  !m.noVariables && (
@@ -181,33 +204,15 @@ function renderImagesFields(m: PanelModel): ReactNode {
181
204
  }
182
205
 
183
206
  function renderStepsFields(m: PanelModel): ReactNode {
184
- const { t, Field, Input, idPrefix } = m;
185
- return (
186
- !m.noVariables && (
187
- <>
188
- <NameSelect
189
- id={`${idPrefix}-steps-variable`}
190
- label={t("template-resolver.documentEditor.stepsVariable")}
191
- names={m.selectable}
192
- labels={m.variableLabels}
193
- value={m.selectedName}
194
- onChange={m.setChosenName}
195
- />
196
- <Field
197
- id={`${idPrefix}-steps-list`}
198
- label={t("template-resolver.documentEditor.stepsList")}
199
- >
200
- <Input
201
- kind="text"
202
- id={`${idPrefix}-steps-list`}
203
- name="steps"
204
- value={m.stepsText}
205
- onChange={m.setStepsText}
206
- />
207
- </Field>
208
- </>
209
- )
210
- );
207
+ return renderVariableAndTextFields(m, {
208
+ variableIdSuffix: "steps-variable",
209
+ variableLabel: m.t("template-resolver.documentEditor.stepsVariable"),
210
+ textIdSuffix: "steps-list",
211
+ textLabel: m.t("template-resolver.documentEditor.stepsList"),
212
+ textName: "steps",
213
+ textValue: m.stepsText,
214
+ onTextChange: m.setStepsText,
215
+ });
211
216
  }
212
217
 
213
218
  export const PANEL_FIELDS: Readonly<Record<PanelKind, (m: PanelModel) => ReactNode>> = {
@@ -10,6 +10,7 @@ import StarterKit from "@tiptap/starter-kit";
10
10
  import { createDocumentImagesNode } from "./document-images.ts";
11
11
  import { isDocumentReferenceName } from "./document-reference-name.ts";
12
12
  import { createDocumentStepsNode } from "./document-steps.ts";
13
+ import { attributeParseRule } from "./tiptap-attribute-parse-rule.ts";
13
14
 
14
15
  const PLACEHOLDER_HREF = /^\{\{(.+)\}\}$/;
15
16
  const RESOURCE_KEY = /^[A-Za-z0-9][A-Za-z0-9_.-]*$/;
@@ -95,13 +96,12 @@ export const DocumentVariable = Node.create({
95
96
  },
96
97
  parseHTML() {
97
98
  return [
98
- {
99
+ attributeParseRule({
99
100
  tag: "span[data-variable]",
100
- getAttrs: (element) => {
101
- const name = element.getAttribute("data-variable");
102
- return name !== null && isDocumentReferenceName(name) ? { name } : false;
103
- },
104
- },
101
+ attribute: "data-variable",
102
+ key: "name",
103
+ isValid: isDocumentReferenceName,
104
+ }),
105
105
  ];
106
106
  },
107
107
  renderHTML({ node }) {
@@ -152,15 +152,14 @@ export const DocumentButton = Node.create({
152
152
  },
153
153
  parseHTML() {
154
154
  return [
155
- {
155
+ attributeParseRule({
156
156
  tag: "a[data-button]",
157
+ attribute: "href",
158
+ key: "href",
159
+ isValid: isDocumentPlaceholderHref,
157
160
  // Must win against the Link mark's `a[href]` rule.
158
161
  priority: 1000,
159
- getAttrs: (element) => {
160
- const href = element.getAttribute("href");
161
- return href !== null && isDocumentPlaceholderHref(href) ? { href } : false;
162
- },
163
- },
162
+ }),
164
163
  ];
165
164
  },
166
165
  renderHTML({ node }) {
@@ -0,0 +1,19 @@
1
+ type AttributeSource = { getAttribute(name: string): string | null };
2
+
3
+ export function attributeParseRule(rule: {
4
+ readonly tag: string;
5
+ readonly attribute: string;
6
+ readonly key: string;
7
+ readonly isValid: (value: string) => boolean;
8
+ readonly priority?: number;
9
+ }) {
10
+ const { tag, attribute, key, isValid, priority } = rule;
11
+ return {
12
+ tag,
13
+ ...(priority === undefined ? {} : { priority }),
14
+ getAttrs: (element: AttributeSource): Record<string, string> | false => {
15
+ const value = element.getAttribute(attribute);
16
+ return value !== null && isValid(value) ? { [key]: value } : false;
17
+ },
18
+ };
19
+ }
@@ -52,6 +52,9 @@ export const TENANT_I18N: Readonly<Record<string, LocalizedString>> = {
52
52
  "tenant:entity:tenant:field:status:option:destroying": {
53
53
  en: "Destroying",
54
54
  },
55
+ "tenant:entity:tenant:field:status:option:destroyHeld": {
56
+ en: "Destroy held by retention",
57
+ },
55
58
  "tenant:entity:tenant:field:status:option:destroyFailed": {
56
59
  en: "Destroy failed",
57
60
  },
@@ -11,6 +11,7 @@ export const TENANT_LIFECYCLE_STATUSES = [
11
11
  "active",
12
12
  "destroyRequested",
13
13
  "destroying",
14
+ "destroyHeld",
14
15
  "destroyFailed",
15
16
  "destroyed",
16
17
  ] as const;
@@ -4,7 +4,7 @@
4
4
 
5
5
  import { type ColumnRendererProps, useTranslation } from "@cosmicdrift/kumiko-renderer";
6
6
  import type { ReactNode } from "react";
7
- import { translateOrRaw } from "../../shared/web/translate-or-raw.ts";
7
+ import { translateOrRaw } from "../../shared/web/index.ts";
8
8
 
9
9
  export function MemberRolesCell({ row }: ColumnRendererProps): ReactNode {
10
10
  const t = useTranslation();
@@ -6,7 +6,7 @@
6
6
  import { type ColumnRendererProps, useTranslation } from "@cosmicdrift/kumiko-renderer";
7
7
  import { StatusBadge, type StatusTone } from "@cosmicdrift/kumiko-renderer/web";
8
8
  import type { ReactNode } from "react";
9
- import { translateOrRaw } from "../../shared/web/translate-or-raw.ts";
9
+ import { translateOrRaw } from "../../shared/web/index.ts";
10
10
 
11
11
  const STATUS_TONE: Readonly<Record<string, StatusTone>> = {
12
12
  active: "ok",
@@ -0,0 +1,8 @@
1
+ [
2
+ {
3
+ "version": "0.407.0",
4
+ "type": "improvement",
5
+ "title": "Warn and delete inactive free accounts",
6
+ "detail": "createTenantInactivityFeature({ rule } or { resolveTier, rulesByTier }, keepAccountUrl, keepAccountTokenSecret?, activitySources?) mounts a daily maintenance job that warns the tenant owners by mail before the deadline (rule.warnings, for example 30 and 7 days) and then files the normal tenant-lifecycle deletion request, with the wait period of the compliance profile. A new session, an activity source or the keep-account link in the mail restarts the period; a tier whose rule is null is exempt. The query tenant-inactivity:query:state (optional field tenantIdOverride, only for a SystemAdmin, to read another tenant) shows exempt, lastActivityAt, warningsSent, nextStep and nextStepAt. The feature requires sessions, tenant, tenant-lifecycle and delivery, and erases its state with the tenant data. Mail texts exist in en, de, es, fr and it."
7
+ }
8
+ ]
@@ -0,0 +1,260 @@
1
+ import { fetchOne } from "@cosmicdrift/kumiko-framework/db";
2
+ import type { JobContext, TenantId } from "@cosmicdrift/kumiko-framework/engine";
3
+ import { hasMailTranslations, mailT } from "@cosmicdrift/kumiko-framework/i18n";
4
+ import { parseRoles } from "@cosmicdrift/kumiko-framework/utils";
5
+ import { Temporal } from "@cosmicdrift/kumiko-types/temporal";
6
+ import {
7
+ decryptTenantNames,
8
+ type TenantLifecycleStatus,
9
+ tenantMembershipsTable,
10
+ tenantTable,
11
+ } from "../tenant/index.ts";
12
+ import { requestTenantDestruction } from "../tenant-lifecycle/index.ts";
13
+ import { userTable } from "../user/index.ts";
14
+ import { TENANT_OWNER_ROLE } from "./constants.ts";
15
+ import { formatInactivityMailDate } from "./email-templates.ts";
16
+ import {
17
+ activityBase,
18
+ decideInactivityAction,
19
+ foldActivity,
20
+ type InactivityRule,
21
+ resetWarnings,
22
+ } from "./inactivity-plan.ts";
23
+ import { signKeepAccountToken } from "./keep-token.ts";
24
+ import {
25
+ InactivityWarningNotificationType,
26
+ inactivityMailTemplateLocale,
27
+ } from "./mail-notifications.ts";
28
+ import { resolveInactivityRule, type TenantInactivityOptions } from "./options.ts";
29
+ import {
30
+ loadInactivityState,
31
+ loadNewestSessionActivity,
32
+ type StoredInactivityState,
33
+ saveInactivityState,
34
+ } from "./state-store.ts";
35
+
36
+ // Links outlive the deadline a little so a late click still counts as a reaction.
37
+ const KEEP_LINK_GRACE_MINUTES = 14 * 24 * 60;
38
+ const MS_PER_MINUTE = 60_000;
39
+
40
+ function emptyState(now: Temporal.Instant): StoredInactivityState {
41
+ return {
42
+ cycleId: crypto.randomUUID(),
43
+ firstSeenAt: now,
44
+ lastActivityAt: null,
45
+ lastExemptAt: null,
46
+ lastWarnedAt: null,
47
+ postponedDueAt: null,
48
+ warningsSent: 0,
49
+ };
50
+ }
51
+
52
+ function startNewCycle(state: StoredInactivityState): StoredInactivityState {
53
+ return { ...resetWarnings(state), cycleId: crypto.randomUUID() };
54
+ }
55
+
56
+ function latestOf(instants: readonly (Temporal.Instant | null)[]): Temporal.Instant | null {
57
+ let latest: Temporal.Instant | null = null;
58
+ for (const instant of instants) {
59
+ if (instant !== null && (latest === null || Temporal.Instant.compare(instant, latest) > 0)) {
60
+ latest = instant;
61
+ }
62
+ }
63
+ return latest;
64
+ }
65
+
66
+ async function newestExternalActivity(
67
+ options: TenantInactivityOptions,
68
+ tenantId: TenantId,
69
+ now: Temporal.Instant,
70
+ ): Promise<Temporal.Instant | null> {
71
+ const found = await Promise.all(
72
+ (options.activitySources ?? []).map((source) => source({ tenantId, now })),
73
+ );
74
+ return latestOf(found);
75
+ }
76
+
77
+ function isNewerThanBase(
78
+ activity: Temporal.Instant | null,
79
+ state: StoredInactivityState,
80
+ ): activity is Temporal.Instant {
81
+ return activity !== null && Temporal.Instant.compare(activity, activityBase(state)) > 0;
82
+ }
83
+
84
+ type OwnerRecipient = { readonly userId: string; readonly locale: string | null };
85
+
86
+ async function loadOwners(ctx: JobContext): Promise<readonly OwnerRecipient[]> {
87
+ const memberships = await ctx.db.selectMany<{ userId: string; roles: unknown }>(
88
+ tenantMembershipsTable,
89
+ {},
90
+ );
91
+ const owners: OwnerRecipient[] = [];
92
+ for (const membership of memberships) {
93
+ if (!parseRoles(membership.roles).includes(TENANT_OWNER_ROLE)) continue;
94
+ const user = await ctx.db
95
+ .global(userTable)
96
+ .fetchOne<{ locale: string | null }>({ id: membership.userId });
97
+ owners.push({ userId: membership.userId, locale: user?.locale ?? null });
98
+ }
99
+ return owners;
100
+ }
101
+
102
+ function mailLocaleFor(userLocale: string | null): string {
103
+ const root = userLocale?.toLowerCase().split("-")[0];
104
+ const preferred = root !== undefined && hasMailTranslations(root) ? root : "en";
105
+ return inactivityMailTemplateLocale(InactivityWarningNotificationType, preferred);
106
+ }
107
+
108
+ async function readTenantName(ctx: JobContext, tenantId: TenantId): Promise<string> {
109
+ const row = await fetchOne<{ name?: unknown }>(ctx.db.unsafeRaw(), tenantTable, {
110
+ id: tenantId,
111
+ });
112
+ const [named] = await decryptTenantNames(row ? [row] : [], tenantId);
113
+ return typeof named?.name === "string" ? named.name : tenantId;
114
+ }
115
+
116
+ function keepLinkFor(args: {
117
+ readonly options: TenantInactivityOptions;
118
+ readonly tenantId: TenantId;
119
+ readonly state: StoredInactivityState;
120
+ readonly deadline: Temporal.Instant;
121
+ readonly now: Temporal.Instant;
122
+ }): string {
123
+ const { options, tenantId, state, deadline, now } = args;
124
+ if (options.keepAccountTokenSecret === undefined) return options.keepAccountUrl;
125
+ const untilDeadline = Math.ceil(
126
+ (deadline.epochMilliseconds - now.epochMilliseconds) / MS_PER_MINUTE,
127
+ );
128
+ const token = signKeepAccountToken({
129
+ tenantId,
130
+ cycleId: state.cycleId,
131
+ ttlMinutes: Math.max(0, untilDeadline) + KEEP_LINK_GRACE_MINUTES,
132
+ secret: options.keepAccountTokenSecret,
133
+ now,
134
+ });
135
+ return `${options.keepAccountUrl}#token=${token}`;
136
+ }
137
+
138
+ // True when at least one owner got the mail. A failed delivery must not count as a sent warning,
139
+ // or the deletion request would follow without the owner ever having been told.
140
+ async function sendWarningMails(args: {
141
+ readonly ctx: JobContext;
142
+ readonly options: TenantInactivityOptions;
143
+ readonly tenantId: TenantId;
144
+ readonly state: StoredInactivityState;
145
+ readonly deadline: Temporal.Instant;
146
+ readonly now: Temporal.Instant;
147
+ }): Promise<boolean> {
148
+ const { ctx, options, tenantId, deadline } = args;
149
+ if (!ctx.notify) throw new Error("tenant-inactivity: ctx.notify missing, mount delivery");
150
+ const tenantName = await readTenantName(ctx, tenantId);
151
+ const keepUrl = keepLinkFor(args);
152
+
153
+ let delivered = false;
154
+ for (const owner of await loadOwners(ctx)) {
155
+ const locale = mailLocaleFor(owner.locale);
156
+ // immediate: the keep-account token must not land in a delivery job payload.
157
+ const result = await ctx.notify(InactivityWarningNotificationType, {
158
+ to: owner.userId,
159
+ locale,
160
+ immediate: true,
161
+ data: {
162
+ app: options.appName ?? mailT(locale, "gdpr.mail.appNameDefault"),
163
+ tenant: tenantName,
164
+ when: formatInactivityMailDate(deadline),
165
+ keepUrl,
166
+ },
167
+ });
168
+ if (result.deliveries.some((delivery) => delivery.status !== "failed")) delivered = true;
169
+ }
170
+ return delivered;
171
+ }
172
+
173
+ async function evaluate(
174
+ ctx: JobContext,
175
+ options: TenantInactivityOptions,
176
+ tenantId: TenantId,
177
+ rule: InactivityRule,
178
+ stored: StoredInactivityState | null,
179
+ now: Temporal.Instant,
180
+ ): Promise<StoredInactivityState> {
181
+ const initial = stored ?? emptyState(now);
182
+ const folded = foldActivity(initial, await loadNewestSessionActivity(ctx.db));
183
+ const merged: StoredInactivityState = { ...initial, ...folded.state };
184
+ const state = folded.newCycle ? startNewCycle(merged) : merged;
185
+
186
+ const decision = decideInactivityAction(state, rule, now);
187
+ if (decision.kind === "none") return state;
188
+
189
+ // Steps with consequences ask other apps first: activity there counts too.
190
+ const external = await newestExternalActivity(options, tenantId, now);
191
+ if (isNewerThanBase(external, state)) {
192
+ return startNewCycle({ ...state, lastActivityAt: external });
193
+ }
194
+
195
+ if (decision.kind === "warn") {
196
+ const delivered = await sendWarningMails({
197
+ ctx,
198
+ options,
199
+ tenantId,
200
+ state,
201
+ deadline: decision.deadline,
202
+ now,
203
+ });
204
+ if (!delivered) return state;
205
+ return {
206
+ ...state,
207
+ warningsSent: decision.warningsSentAfter,
208
+ lastWarnedAt: now,
209
+ postponedDueAt: decision.postponedDueAt ?? state.postponedDueAt,
210
+ };
211
+ }
212
+
213
+ if (!ctx.registry) throw new Error("tenant-inactivity: ctx.registry required");
214
+ const result = await requestTenantDestruction({
215
+ tenantId,
216
+ actor: ctx.systemUser,
217
+ now,
218
+ db: ctx.db,
219
+ runner: ctx.db.unsafeRaw(),
220
+ registry: ctx.registry,
221
+ revokeSessions: true,
222
+ });
223
+ if (!result.isSuccess) {
224
+ throw new Error(`tenant-inactivity: destruction request for ${tenantId} failed`);
225
+ }
226
+ // If the owner cancels the request, a fresh cycle starts instead of an instant second request.
227
+ return startNewCycle({ ...state, lastActivityAt: now });
228
+ }
229
+
230
+ export async function checkTenantInactivity(
231
+ ctx: JobContext,
232
+ options: TenantInactivityOptions,
233
+ ): Promise<void> {
234
+ const tenantId = ctx.systemUser.tenantId ?? ctx._tenantId;
235
+ // skip: a job without a tenant scope has nothing to evaluate
236
+ if (tenantId === undefined) return;
237
+ const now = ctx.tz.now();
238
+ const tenant = await fetchOne<{ status: TenantLifecycleStatus }>(
239
+ ctx.db.unsafeRaw(),
240
+ tenantTable,
241
+ { id: tenantId },
242
+ );
243
+ // skip: only active tenants are evaluated; others are already in a lifecycle step
244
+ if (tenant?.status !== "active") return;
245
+
246
+ const rule = await resolveInactivityRule(options, ctx.db);
247
+ const stored = await loadInactivityState(ctx.db);
248
+ if (rule === null) {
249
+ const state = stored ?? emptyState(now);
250
+ // A tier change back to a rule starts its period at the last exempt run.
251
+ const exempt = state.warningsSent > 0 ? startNewCycle(state) : state;
252
+ await saveInactivityState(ctx.db, stored, { ...exempt, lastExemptAt: now });
253
+ } else {
254
+ await saveInactivityState(
255
+ ctx.db,
256
+ stored,
257
+ await evaluate(ctx, options, tenantId, rule, stored, now),
258
+ );
259
+ }
260
+ }
@@ -0,0 +1,12 @@
1
+ export const TENANT_INACTIVITY_FEATURE = "tenant-inactivity";
2
+ export const TENANT_INACTIVITY_STATE_ENTITY = "tenant-inactivity-state";
3
+ export const TENANT_OWNER_ROLE = "TenantOwner";
4
+
5
+ export const TenantInactivityJobs = {
6
+ check: `${TENANT_INACTIVITY_FEATURE}:job:check-inactive-tenants`,
7
+ } as const;
8
+
9
+ export const TenantInactivityHandlers = {
10
+ keepAccount: `${TENANT_INACTIVITY_FEATURE}:write:keep-account`,
11
+ state: `${TENANT_INACTIVITY_FEATURE}:query:state`,
12
+ } as const;
@@ -0,0 +1,24 @@
1
+ // English defaults of the inactivity warning mail; other languages register through
2
+ // @cosmicdrift/kumiko-locale-* (same pattern as the GDPR mails).
3
+
4
+ import { registerMailTranslations } from "@cosmicdrift/kumiko-framework/i18n";
5
+ import type { Temporal } from "@cosmicdrift/kumiko-types/temporal";
6
+
7
+ export const INACTIVITY_MAIL_EN: Readonly<Record<string, string>> = {
8
+ "inactivity.mail.warning.subject": "{app}: Deletion request for your account {account} on {when}",
9
+ "inactivity.mail.warning.intro":
10
+ "nobody has signed in to your {app} account {account} for a long time. If that does not change, we will request deletion of the account and all its data on {when}.",
11
+ "inactivity.mail.warning.keep":
12
+ "To keep the account, sign in or click the button. The period then starts over.",
13
+ "inactivity.mail.warning.button": "Keep account",
14
+ "inactivity.mail.warning.after":
15
+ "Even after the deletion request you can cancel it in the account settings until the waiting period ends.",
16
+ };
17
+
18
+ registerMailTranslations("en", INACTIVITY_MAIL_EN);
19
+
20
+ export function formatInactivityMailDate(instant: Temporal.Instant): string {
21
+ const zoned = instant.toZonedDateTimeISO("UTC");
22
+ const pad = (value: number) => String(value).padStart(2, "0");
23
+ return `${zoned.year}-${pad(zoned.month)}-${pad(zoned.day)}`;
24
+ }