@cosmicdrift/kumiko-samples 0.385.0 → 0.387.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 (395) hide show
  1. package/LICENSE +21 -57
  2. package/README.md +1 -1
  3. package/package.json +2 -2
  4. package/packages/bundled-features/package.json +2 -2
  5. package/packages/bundled-features/src/agent-tools/tool-catalog.ts +1 -1
  6. package/packages/bundled-features/src/agent-tools/tool-dispatch.ts +0 -2
  7. package/packages/bundled-features/src/audit/screens.ts +1 -1
  8. package/packages/bundled-features/src/auth-email-password/auth-user-row.ts +10 -10
  9. package/packages/bundled-features/src/auth-email-password/feature.ts +6 -6
  10. package/packages/bundled-features/src/auth-email-password/handlers/change-password.write.ts +3 -3
  11. package/packages/bundled-features/src/auth-email-password/handlers/confirm-token-flow.ts +5 -5
  12. package/packages/bundled-features/src/auth-email-password/handlers/invite-accept-with-login.write.ts +1 -1
  13. package/packages/bundled-features/src/auth-email-password/handlers/invite-accept.write.ts +18 -18
  14. package/packages/bundled-features/src/auth-email-password/handlers/invite-create.write.ts +12 -12
  15. package/packages/bundled-features/src/auth-email-password/handlers/invite-info.query.ts +1 -1
  16. package/packages/bundled-features/src/auth-email-password/handlers/invite-signup-complete.write.ts +24 -26
  17. package/packages/bundled-features/src/auth-email-password/handlers/login.write.ts +1 -1
  18. package/packages/bundled-features/src/auth-email-password/handlers/self-registration-status.query.ts +1 -1
  19. package/packages/bundled-features/src/auth-email-password/handlers/signup-confirm.write.ts +34 -37
  20. package/packages/bundled-features/src/auth-email-password/handlers/signup-request.write.ts +6 -7
  21. package/packages/bundled-features/src/auth-email-password/handlers/switch-tenant-mfa-gate.write.ts +1 -5
  22. package/packages/bundled-features/src/auth-email-password/index.ts +5 -5
  23. package/packages/bundled-features/src/auth-email-password/lockout-store.ts +1 -1
  24. package/packages/bundled-features/src/auth-email-password/seeding.ts +63 -66
  25. package/packages/bundled-features/src/auth-email-password/signup-token-store.ts +8 -8
  26. package/packages/bundled-features/src/auth-email-password/testing.ts +3 -3
  27. package/packages/bundled-features/src/auth-email-password/web/auth-client.ts +57 -57
  28. package/packages/bundled-features/src/auth-email-password/web/auth-form-primitives.tsx +14 -14
  29. package/packages/bundled-features/src/auth-email-password/web/auth-gate.tsx +15 -16
  30. package/packages/bundled-features/src/auth-email-password/web/client-plugin.ts +11 -12
  31. package/packages/bundled-features/src/auth-email-password/web/confirm-account-unlock-screen.tsx +1 -1
  32. package/packages/bundled-features/src/auth-email-password/web/constants.ts +3 -3
  33. package/packages/bundled-features/src/auth-email-password/web/default-topbar-actions.tsx +14 -14
  34. package/packages/bundled-features/src/auth-email-password/web/forgot-password-screen.tsx +11 -11
  35. package/packages/bundled-features/src/auth-email-password/web/index.ts +5 -5
  36. package/packages/bundled-features/src/auth-email-password/web/invite-accept-screen.tsx +17 -17
  37. package/packages/bundled-features/src/auth-email-password/web/login-screen.tsx +3 -4
  38. package/packages/bundled-features/src/auth-email-password/web/reset-password-screen.tsx +16 -17
  39. package/packages/bundled-features/src/auth-email-password/web/session.tsx +34 -34
  40. package/packages/bundled-features/src/auth-email-password/web/signup-complete-screen.tsx +3 -3
  41. package/packages/bundled-features/src/auth-email-password/web/signup-screen.tsx +14 -14
  42. package/packages/bundled-features/src/auth-email-password/web/tenant-switcher.tsx +26 -27
  43. package/packages/bundled-features/src/auth-email-password/web/use-shell-user.ts +12 -13
  44. package/packages/bundled-features/src/auth-email-password/web/user-menu.tsx +17 -18
  45. package/packages/bundled-features/src/auth-email-password/web/verify-email-screen.tsx +11 -12
  46. package/packages/bundled-features/src/auth-foundation/boot-checks.ts +4 -4
  47. package/packages/bundled-features/src/auth-foundation/resolve-anonymous-access.ts +4 -4
  48. package/packages/bundled-features/src/auth-foundation/types.ts +2 -2
  49. package/packages/bundled-features/src/auth-mfa/handlers/disable.write.ts +3 -3
  50. package/packages/bundled-features/src/auth-mfa/handlers/enable-confirm-preauth.write.ts +4 -4
  51. package/packages/bundled-features/src/auth-mfa/handlers/enable-confirm.write.ts +2 -2
  52. package/packages/bundled-features/src/auth-mfa/handlers/enable-start-preauth.write.ts +1 -1
  53. package/packages/bundled-features/src/auth-mfa/handlers/reencrypt.job.ts +1 -1
  54. package/packages/bundled-features/src/auth-mfa/handlers/regenerate-recovery.write.ts +5 -5
  55. package/packages/bundled-features/src/auth-mfa/handlers/verify.write.ts +1 -1
  56. package/packages/bundled-features/src/auth-mfa/token-secrets.ts +1 -1
  57. package/packages/bundled-features/src/auth-mfa/web/client-plugin.ts +2 -2
  58. package/packages/bundled-features/src/auth-mfa/web/i18n.ts +3 -3
  59. package/packages/bundled-features/src/auth-mfa/web/index.ts +4 -4
  60. package/packages/bundled-features/src/auth-mfa/web/mfa-client.ts +17 -16
  61. package/packages/bundled-features/src/auth-mfa/web/mfa-verify-screen.tsx +6 -6
  62. package/packages/bundled-features/src/billing-foundation/aggregate-id.ts +10 -11
  63. package/packages/bundled-features/src/billing-foundation/entities.ts +27 -27
  64. package/packages/bundled-features/src/billing-foundation/events.ts +22 -21
  65. package/packages/bundled-features/src/billing-foundation/feature.ts +42 -43
  66. package/packages/bundled-features/src/billing-foundation/get-subscription-for-tenant.ts +3 -5
  67. package/packages/bundled-features/src/billing-foundation/handlers/create-checkout-session.write.ts +18 -17
  68. package/packages/bundled-features/src/billing-foundation/handlers/create-portal-session.write.ts +11 -12
  69. package/packages/bundled-features/src/billing-foundation/handlers/list-subscriptions.query.ts +4 -4
  70. package/packages/bundled-features/src/billing-foundation/handlers/process-event.write.ts +20 -20
  71. package/packages/bundled-features/src/billing-foundation/projection.ts +38 -37
  72. package/packages/bundled-features/src/billing-foundation/subscription-tier-sync.ts +3 -3
  73. package/packages/bundled-features/src/billing-foundation/tenant-destroy-hook.ts +7 -8
  74. package/packages/bundled-features/src/billing-foundation/types.ts +64 -65
  75. package/packages/bundled-features/src/billing-foundation/web/billing-plans-panel.tsx +4 -4
  76. package/packages/bundled-features/src/billing-foundation/webhook-handler.ts +1 -1
  77. package/packages/bundled-features/src/cap-counter/aggregate-id.ts +8 -9
  78. package/packages/bundled-features/src/cap-counter/constants.ts +11 -12
  79. package/packages/bundled-features/src/cap-counter/enforce-cap.ts +64 -67
  80. package/packages/bundled-features/src/cap-counter/entity.ts +29 -29
  81. package/packages/bundled-features/src/cap-counter/feature.ts +34 -35
  82. package/packages/bundled-features/src/cap-counter/handlers/increment-rolling.write.ts +31 -31
  83. package/packages/bundled-features/src/cap-counter/handlers/mark-soft-warned.write.ts +4 -5
  84. package/packages/bundled-features/src/cap-counter/stock-cap-guard.ts +1 -1
  85. package/packages/bundled-features/src/cap-counter/with-cap-enforcement.ts +3 -5
  86. package/packages/bundled-features/src/cap-overview/handlers/caps-usage.query.ts +1 -3
  87. package/packages/bundled-features/src/cap-overview/handlers/tenant-caps-list.query.ts +1 -1
  88. package/packages/bundled-features/src/channel-email/smtp-transport.ts +34 -31
  89. package/packages/bundled-features/src/channel-in-app/handlers/unread-count.query.ts +3 -4
  90. package/packages/bundled-features/src/compliance-profiles/feature.ts +15 -16
  91. package/packages/bundled-features/src/compliance-profiles/handlers/for-tenant.query.ts +3 -6
  92. package/packages/bundled-features/src/compliance-profiles/handlers/list-profiles.query.ts +5 -5
  93. package/packages/bundled-features/src/compliance-profiles/handlers/needs-profile.query.ts +4 -4
  94. package/packages/bundled-features/src/compliance-profiles/handlers/set-profile.write.ts +13 -14
  95. package/packages/bundled-features/src/compliance-profiles/handlers/sub-processors.query.ts +9 -11
  96. package/packages/bundled-features/src/compliance-profiles/resolve-for-tenant.ts +7 -7
  97. package/packages/bundled-features/src/compliance-profiles/schema/profile-selection.ts +18 -23
  98. package/packages/bundled-features/src/compliance-profiles/seeding.ts +14 -15
  99. package/packages/bundled-features/src/compliance-profiles-ops/handlers/tenants-missing-profile.query.ts +3 -3
  100. package/packages/bundled-features/src/compliance-profiles-ops/index.ts +2 -2
  101. package/packages/bundled-features/src/config/handlers/readiness.query.ts +7 -7
  102. package/packages/bundled-features/src/config/handlers/reencrypt.job.ts +4 -5
  103. package/packages/bundled-features/src/config/handlers/set.write.ts +4 -4
  104. package/packages/bundled-features/src/config/resolver.ts +4 -4
  105. package/packages/bundled-features/src/config/table.ts +10 -10
  106. package/packages/bundled-features/src/config/write-helpers.ts +1 -1
  107. package/packages/bundled-features/src/crypto-shredding/handlers/forget-subject.write.ts +13 -12
  108. package/packages/bundled-features/src/custom-fields/aggregate-id.ts +16 -17
  109. package/packages/bundled-features/src/custom-fields/entity.ts +49 -47
  110. package/packages/bundled-features/src/custom-fields/events.ts +7 -8
  111. package/packages/bundled-features/src/custom-fields/feature.ts +70 -72
  112. package/packages/bundled-features/src/custom-fields/handlers/clear-custom-field.write.ts +9 -8
  113. package/packages/bundled-features/src/custom-fields/handlers/define-tenant-field.write.ts +28 -26
  114. package/packages/bundled-features/src/custom-fields/handlers/delete-system-field.write.ts +6 -7
  115. package/packages/bundled-features/src/custom-fields/handlers/delete-tenant-field.write.ts +12 -13
  116. package/packages/bundled-features/src/custom-fields/handlers/set-custom-field.write.ts +25 -28
  117. package/packages/bundled-features/src/custom-fields/handlers/update-tenant-field.write.ts +6 -6
  118. package/packages/bundled-features/src/custom-fields/lib/field-access.ts +2 -2
  119. package/packages/bundled-features/src/custom-fields/lib/parse-serialized-field.ts +1 -1
  120. package/packages/bundled-features/src/custom-fields/lib/quota.ts +1 -1
  121. package/packages/bundled-features/src/custom-fields/lib/value-schema.ts +10 -12
  122. package/packages/bundled-features/src/custom-fields/run-retention.ts +3 -3
  123. package/packages/bundled-features/src/custom-fields/schemas.ts +14 -14
  124. package/packages/bundled-features/src/custom-fields/web/client-plugin.tsx +2 -5
  125. package/packages/bundled-features/src/custom-fields/web/constants.ts +2 -2
  126. package/packages/bundled-features/src/custom-fields/web/custom-fields-form-section.tsx +26 -26
  127. package/packages/bundled-features/src/custom-fields/wire-for-entity.ts +65 -67
  128. package/packages/bundled-features/src/custom-fields/wire-user-data-rights.ts +3 -3
  129. package/packages/bundled-features/src/data-retention/_internal/parse-override.ts +2 -3
  130. package/packages/bundled-features/src/data-retention/feature.ts +11 -18
  131. package/packages/bundled-features/src/data-retention/handlers/policy-for.query.ts +6 -6
  132. package/packages/bundled-features/src/data-retention/keep-for.ts +17 -17
  133. package/packages/bundled-features/src/data-retention/override-schema.ts +13 -15
  134. package/packages/bundled-features/src/data-retention/presets.ts +18 -23
  135. package/packages/bundled-features/src/data-retention/resolve-for-tenant.ts +1 -1
  136. package/packages/bundled-features/src/data-retention/resolve-tenant-preset.ts +17 -16
  137. package/packages/bundled-features/src/data-retention/resolver.ts +33 -32
  138. package/packages/bundled-features/src/data-retention/run-retention-cleanup.ts +71 -58
  139. package/packages/bundled-features/src/data-retention/schema/tenant-retention-override.ts +13 -11
  140. package/packages/bundled-features/src/delivery/feature.ts +3 -3
  141. package/packages/bundled-features/src/delivery/handlers/log.query.ts +1 -1
  142. package/packages/bundled-features/src/delivery/tables.ts +9 -8
  143. package/packages/bundled-features/src/delivery/unsubscribe.ts +4 -4
  144. package/packages/bundled-features/src/delivery/upsert-preference.ts +3 -4
  145. package/packages/bundled-features/src/document-ingest-foundation/entity.ts +5 -5
  146. package/packages/bundled-features/src/document-ingest-foundation/events.ts +2 -2
  147. package/packages/bundled-features/src/document-ingest-foundation/feature.ts +2 -2
  148. package/packages/bundled-features/src/document-ingest-foundation/pages.ts +1 -1
  149. package/packages/bundled-features/src/document-ingest-foundation/tenant-destroy-hook.ts +4 -4
  150. package/packages/bundled-features/src/feature-toggles/compose-tier-resolver.ts +1 -1
  151. package/packages/bundled-features/src/feature-toggles/feature.ts +1 -1
  152. package/packages/bundled-features/src/feature-toggles/global-feature-state-table.ts +1 -1
  153. package/packages/bundled-features/src/feature-toggles/handlers/registered.query.ts +5 -5
  154. package/packages/bundled-features/src/feature-toggles/toggle-runtime.ts +1 -1
  155. package/packages/bundled-features/src/feature-toggles/toggle-sync-signal.ts +1 -1
  156. package/packages/bundled-features/src/feature-toggles/web/constants.ts +1 -1
  157. package/packages/bundled-features/src/file-derivatives/feature.ts +2 -2
  158. package/packages/bundled-features/src/file-derivatives/handlers/public-variant.query.ts +1 -1
  159. package/packages/bundled-features/src/file-derivatives/presets.ts +1 -1
  160. package/packages/bundled-features/src/file-foundation/feature.ts +6 -6
  161. package/packages/bundled-features/src/file-provider-inmemory/feature.ts +16 -16
  162. package/packages/bundled-features/src/file-provider-s3/feature.ts +16 -16
  163. package/packages/bundled-features/src/file-provider-s3/lib/s3-provider.ts +6 -6
  164. package/packages/bundled-features/src/files/feature.ts +6 -6
  165. package/packages/bundled-features/src/files-tenant-data/handlers/sweep-orphaned-derivatives.job.ts +5 -5
  166. package/packages/bundled-features/src/files-tenant-data/hooks.ts +24 -26
  167. package/packages/bundled-features/src/files-tenant-data/index.ts +1 -1
  168. package/packages/bundled-features/src/folders/feature.ts +1 -1
  169. package/packages/bundled-features/src/folders/web/folder-manager.tsx +2 -2
  170. package/packages/bundled-features/src/folders/web/tree.ts +5 -5
  171. package/packages/bundled-features/src/form-draft/db/queries/cleanup.ts +1 -1
  172. package/packages/bundled-features/src/form-draft/db/queries/owned-file-refs.ts +1 -1
  173. package/packages/bundled-features/src/form-draft/entity.ts +3 -3
  174. package/packages/bundled-features/src/form-draft/feature.ts +4 -5
  175. package/packages/bundled-features/src/form-draft/handlers/discard.write.ts +1 -1
  176. package/packages/bundled-features/src/form-draft/release-file-refs.ts +6 -6
  177. package/packages/bundled-features/src/form-draft/schemas.ts +3 -3
  178. package/packages/bundled-features/src/form-draft/web/constants.ts +0 -2
  179. package/packages/bundled-features/src/inbound-mail-foundation/aggregate-id.ts +19 -19
  180. package/packages/bundled-features/src/inbound-mail-foundation/connect-routes.ts +4 -3
  181. package/packages/bundled-features/src/inbound-mail-foundation/constants.ts +30 -33
  182. package/packages/bundled-features/src/inbound-mail-foundation/entities.ts +47 -48
  183. package/packages/bundled-features/src/inbound-mail-foundation/events.ts +54 -50
  184. package/packages/bundled-features/src/inbound-mail-foundation/feature.ts +39 -39
  185. package/packages/bundled-features/src/inbound-mail-foundation/handlers/account-state.ts +8 -8
  186. package/packages/bundled-features/src/inbound-mail-foundation/handlers/connect-account.write.ts +25 -26
  187. package/packages/bundled-features/src/inbound-mail-foundation/handlers/disconnect-account.write.ts +7 -7
  188. package/packages/bundled-features/src/inbound-mail-foundation/handlers/ingest-message.write.ts +50 -51
  189. package/packages/bundled-features/src/inbound-mail-foundation/handlers/list-accounts.query.ts +8 -8
  190. package/packages/bundled-features/src/inbound-mail-foundation/handlers/list-messages.query.ts +10 -10
  191. package/packages/bundled-features/src/inbound-mail-foundation/handlers/scope-visibility.ts +3 -4
  192. package/packages/bundled-features/src/inbound-mail-foundation/handlers/update-account.write.ts +11 -11
  193. package/packages/bundled-features/src/inbound-mail-foundation/oauth-state.ts +16 -15
  194. package/packages/bundled-features/src/inbound-mail-foundation/projection.ts +31 -29
  195. package/packages/bundled-features/src/inbound-mail-foundation/provider-factory.ts +9 -9
  196. package/packages/bundled-features/src/inbound-mail-foundation/retention-sweep.ts +45 -41
  197. package/packages/bundled-features/src/inbound-mail-foundation/tenant-destroy-hook.ts +14 -16
  198. package/packages/bundled-features/src/inbound-mail-foundation/types.ts +66 -67
  199. package/packages/bundled-features/src/inbound-mail-foundation/watch-supervisor.ts +69 -68
  200. package/packages/bundled-features/src/inbound-provider-imap/credential-document.ts +13 -13
  201. package/packages/bundled-features/src/inbound-provider-imap/feature.ts +42 -40
  202. package/packages/bundled-features/src/inbound-provider-imap/imap-client.ts +20 -19
  203. package/packages/bundled-features/src/inbound-provider-inmemory/feature.ts +21 -21
  204. package/packages/bundled-features/src/jobs/db/queries/retention.ts +2 -2
  205. package/packages/bundled-features/src/jobs/db/queries/stale-run-sweep.ts +3 -3
  206. package/packages/bundled-features/src/jobs/events.ts +1 -1
  207. package/packages/bundled-features/src/jobs/feature.ts +6 -7
  208. package/packages/bundled-features/src/jobs/handlers/detail.query.ts +4 -4
  209. package/packages/bundled-features/src/jobs/handlers/list.query.ts +1 -1
  210. package/packages/bundled-features/src/jobs/handlers/projection-rebuild.job.ts +1 -1
  211. package/packages/bundled-features/src/jobs/handlers/reindex-entity.job.ts +1 -1
  212. package/packages/bundled-features/src/jobs/handlers/retry.write.ts +1 -1
  213. package/packages/bundled-features/src/jobs/job-instant.ts +1 -1
  214. package/packages/bundled-features/src/jobs/job-run-logger.ts +14 -15
  215. package/packages/bundled-features/src/jobs/job-run-table.ts +3 -3
  216. package/packages/bundled-features/src/jobs/screens.ts +1 -1
  217. package/packages/bundled-features/src/jobs/tenant-job-failure-table.ts +1 -1
  218. package/packages/bundled-features/src/jobs/tenant-job-run-table.ts +1 -1
  219. package/packages/bundled-features/src/ledger/entity.ts +5 -5
  220. package/packages/bundled-features/src/ledger/feature.ts +3 -3
  221. package/packages/bundled-features/src/ledger/handlers/confirm-schedule-period.write.ts +3 -3
  222. package/packages/bundled-features/src/ledger/recurring.ts +12 -12
  223. package/packages/bundled-features/src/ledger/schemas.ts +1 -1
  224. package/packages/bundled-features/src/ledger/web/constants.ts +2 -2
  225. package/packages/bundled-features/src/ledger/web/index.ts +7 -7
  226. package/packages/bundled-features/src/legal-pages/feature.ts +40 -41
  227. package/packages/bundled-features/src/legal-pages/markdown.ts +3 -3
  228. package/packages/bundled-features/src/legal-pages/web/client-plugin.ts +23 -24
  229. package/packages/bundled-features/src/legal-pages/web/index.ts +0 -2
  230. package/packages/bundled-features/src/mail-foundation/feature.ts +26 -27
  231. package/packages/bundled-features/src/mail-transport-inmemory/feature.ts +27 -28
  232. package/packages/bundled-features/src/mail-transport-smtp/feature.ts +20 -20
  233. package/packages/bundled-features/src/managed-pages/branding.ts +6 -6
  234. package/packages/bundled-features/src/managed-pages/feature.ts +62 -62
  235. package/packages/bundled-features/src/managed-pages/handlers/by-slug.query.ts +5 -6
  236. package/packages/bundled-features/src/managed-pages/handlers/by-tenant-published.query.ts +8 -8
  237. package/packages/bundled-features/src/managed-pages/handlers/set.write.ts +5 -7
  238. package/packages/bundled-features/src/managed-pages/screens/page-screens.ts +11 -11
  239. package/packages/bundled-features/src/managed-pages/seeding.ts +8 -8
  240. package/packages/bundled-features/src/managed-pages/table.ts +16 -15
  241. package/packages/bundled-features/src/managed-pages/web/client-plugin.tsx +6 -6
  242. package/packages/bundled-features/src/managed-pages/web/i18n.ts +1 -1
  243. package/packages/bundled-features/src/notes-history/entity.ts +4 -4
  244. package/packages/bundled-features/src/notes-history/feature.ts +2 -2
  245. package/packages/bundled-features/src/notes-history-user-data/hooks.ts +1 -1
  246. package/packages/bundled-features/src/page-render/layout.ts +9 -9
  247. package/packages/bundled-features/src/page-render/markdown.ts +11 -11
  248. package/packages/bundled-features/src/page-render/security-headers.ts +7 -6
  249. package/packages/bundled-features/src/personal-access-tokens/feature.ts +5 -5
  250. package/packages/bundled-features/src/personal-access-tokens/roles.ts +2 -2
  251. package/packages/bundled-features/src/readiness/handlers/status.query.ts +3 -3
  252. package/packages/bundled-features/src/renderer-foundation/api.ts +12 -13
  253. package/packages/bundled-features/src/renderer-foundation/constants.ts +2 -2
  254. package/packages/bundled-features/src/renderer-foundation/feature.ts +7 -7
  255. package/packages/bundled-features/src/renderer-foundation/types.ts +11 -12
  256. package/packages/bundled-features/src/secrets/feature.ts +9 -9
  257. package/packages/bundled-features/src/secrets/web/constants.ts +2 -2
  258. package/packages/bundled-features/src/seo/feature.ts +3 -3
  259. package/packages/bundled-features/src/sessions/constants.ts +1 -1
  260. package/packages/bundled-features/src/sessions/feature.ts +9 -9
  261. package/packages/bundled-features/src/sessions/handlers/revoke-all-for-user.write.ts +2 -2
  262. package/packages/bundled-features/src/sessions/handlers/revoke-all-others.write.ts +2 -2
  263. package/packages/bundled-features/src/sessions/handlers/revoke.write.ts +1 -1
  264. package/packages/bundled-features/src/sessions/schema/user-session.ts +4 -4
  265. package/packages/bundled-features/src/sessions/screens.ts +2 -2
  266. package/packages/bundled-features/src/sessions/session-callbacks.ts +2 -2
  267. package/packages/bundled-features/src/sessions/session-revoked-event.ts +2 -2
  268. package/packages/bundled-features/src/shared/assert-no-where-rule-in-ownership-write.ts +1 -1
  269. package/packages/bundled-features/src/shared/decrypt-stored-pii.ts +1 -1
  270. package/packages/bundled-features/src/shared/encrypt-for-direct-write.ts +1 -1
  271. package/packages/bundled-features/src/shared/map-with-concurrency.ts +5 -4
  272. package/packages/bundled-features/src/shared/parent-visibility.ts +2 -2
  273. package/packages/bundled-features/src/shared/password-hashing.ts +1 -1
  274. package/packages/bundled-features/src/shared/signup-handover.ts +1 -2
  275. package/packages/bundled-features/src/shared/single-use-token-store.ts +1 -1
  276. package/packages/bundled-features/src/subscription-mollie/constants.ts +15 -17
  277. package/packages/bundled-features/src/subscription-mollie/feature.ts +41 -42
  278. package/packages/bundled-features/src/subscription-mollie/index.ts +3 -3
  279. package/packages/bundled-features/src/subscription-mollie/plugin-methods.ts +17 -16
  280. package/packages/bundled-features/src/subscription-mollie/verify-webhook.ts +34 -34
  281. package/packages/bundled-features/src/subscription-stripe/constants.ts +4 -6
  282. package/packages/bundled-features/src/subscription-stripe/feature.ts +44 -43
  283. package/packages/bundled-features/src/subscription-stripe/index.ts +6 -6
  284. package/packages/bundled-features/src/subscription-stripe/plugin-methods.ts +22 -27
  285. package/packages/bundled-features/src/subscription-stripe/runtime.ts +2 -2
  286. package/packages/bundled-features/src/subscription-stripe/verify-webhook.ts +62 -64
  287. package/packages/bundled-features/src/tags/feature.ts +3 -3
  288. package/packages/bundled-features/src/tags/screens.ts +1 -1
  289. package/packages/bundled-features/src/template-resolver/api.ts +10 -10
  290. package/packages/bundled-features/src/template-resolver/handlers/find-by-id.query.ts +5 -5
  291. package/packages/bundled-features/src/template-resolver/handlers/list.query.ts +1 -1
  292. package/packages/bundled-features/src/template-resolver/handlers/shared.ts +2 -2
  293. package/packages/bundled-features/src/template-resolver/handlers/template-write.ts +3 -3
  294. package/packages/bundled-features/src/template-resolver/handlers/upsert-system.write.ts +3 -4
  295. package/packages/bundled-features/src/template-resolver/handlers/upsert-tenant.write.ts +4 -5
  296. package/packages/bundled-features/src/template-resolver/seeding.ts +4 -4
  297. package/packages/bundled-features/src/template-resolver/table.ts +13 -14
  298. package/packages/bundled-features/src/template-resolver/web/client-plugin.tsx +2 -2
  299. package/packages/bundled-features/src/tenant/feature.ts +7 -7
  300. package/packages/bundled-features/src/tenant/handlers/member-directory.query.ts +1 -1
  301. package/packages/bundled-features/src/tenant/handlers/members.query.ts +1 -1
  302. package/packages/bundled-features/src/tenant/handlers/memberships.query.ts +1 -1
  303. package/packages/bundled-features/src/tenant/handlers/team-list.query.ts +1 -1
  304. package/packages/bundled-features/src/tenant/handlers/tenant-directory.query.ts +1 -1
  305. package/packages/bundled-features/src/tenant/invitation-table.ts +37 -40
  306. package/packages/bundled-features/src/tenant/membership-table.ts +3 -3
  307. package/packages/bundled-features/src/tenant/schema/tenant.ts +7 -9
  308. package/packages/bundled-features/src/tenant/screens.ts +1 -1
  309. package/packages/bundled-features/src/tenant/seeding.ts +19 -18
  310. package/packages/bundled-features/src/tenant/testing.ts +5 -6
  311. package/packages/bundled-features/src/tenant/web/constants.ts +2 -2
  312. package/packages/bundled-features/src/tenant-handover/events.ts +5 -7
  313. package/packages/bundled-features/src/tenant-handover/feature.ts +1 -1
  314. package/packages/bundled-features/src/tenant-handover/grant.ts +1 -1
  315. package/packages/bundled-features/src/tenant-handover/handlers/claim.write.ts +1 -1
  316. package/packages/bundled-features/src/tenant-handover/move-entity-graph.ts +8 -9
  317. package/packages/bundled-features/src/tenant-handover/signup-handover-provider.ts +1 -2
  318. package/packages/bundled-features/src/tenant-handover/transfer-graph.ts +4 -5
  319. package/packages/bundled-features/src/tenant-lifecycle/boot-checks.ts +1 -1
  320. package/packages/bundled-features/src/tenant-lifecycle/feature.ts +1 -1
  321. package/packages/bundled-features/src/tenant-lifecycle/run-tenant-destroy.ts +2 -2
  322. package/packages/bundled-features/src/tenant-lifecycle/stages.ts +1 -1
  323. package/packages/bundled-features/src/tenant-settings/constants.ts +1 -1
  324. package/packages/bundled-features/src/tenant-settings/tenant-defaults.ts +12 -5
  325. package/packages/bundled-features/src/tier-engine/aggregate-id.ts +15 -16
  326. package/packages/bundled-features/src/tier-engine/compose-app.ts +14 -14
  327. package/packages/bundled-features/src/tier-engine/entity.ts +18 -19
  328. package/packages/bundled-features/src/tier-engine/feature.ts +88 -87
  329. package/packages/bundled-features/src/tier-engine/handlers/active-tier.query.ts +6 -7
  330. package/packages/bundled-features/src/tier-engine/handlers/get-tenant-tier.query.ts +4 -4
  331. package/packages/bundled-features/src/tier-engine/handlers/set-tenant-tier.write.ts +8 -8
  332. package/packages/bundled-features/src/tier-engine/tier-resolver.ts +2 -2
  333. package/packages/bundled-features/src/tier-engine/trial.ts +13 -13
  334. package/packages/bundled-features/src/tier-engine/web/index.ts +4 -4
  335. package/packages/bundled-features/src/user/db/queries/stream-tenant-backfill.ts +8 -8
  336. package/packages/bundled-features/src/user/handlers/create.write.ts +4 -4
  337. package/packages/bundled-features/src/user/schema/user.ts +45 -44
  338. package/packages/bundled-features/src/user/seeding.ts +40 -40
  339. package/packages/bundled-features/src/user/testing.ts +3 -3
  340. package/packages/bundled-features/src/user-data-rights/audit-download.ts +27 -28
  341. package/packages/bundled-features/src/user-data-rights/boot-checks.ts +1 -1
  342. package/packages/bundled-features/src/user-data-rights/deletion-token.ts +1 -1
  343. package/packages/bundled-features/src/user-data-rights/feature.ts +112 -113
  344. package/packages/bundled-features/src/user-data-rights/handlers/cancel-deletion.write.ts +9 -9
  345. package/packages/bundled-features/src/user-data-rights/handlers/confirm-deletion-by-token.write.ts +8 -8
  346. package/packages/bundled-features/src/user-data-rights/handlers/download-by-job.query.ts +29 -30
  347. package/packages/bundled-features/src/user-data-rights/handlers/download-by-token.query.ts +40 -42
  348. package/packages/bundled-features/src/user-data-rights/handlers/export-status.query.ts +8 -9
  349. package/packages/bundled-features/src/user-data-rights/handlers/lift-restriction.write.ts +7 -8
  350. package/packages/bundled-features/src/user-data-rights/handlers/list-download-attempts.query.ts +2 -2
  351. package/packages/bundled-features/src/user-data-rights/handlers/my-audit-log.query.ts +4 -4
  352. package/packages/bundled-features/src/user-data-rights/handlers/request-deletion-by-email.write.ts +30 -29
  353. package/packages/bundled-features/src/user-data-rights/handlers/request-deletion.write.ts +15 -18
  354. package/packages/bundled-features/src/user-data-rights/handlers/request-export.write.ts +42 -41
  355. package/packages/bundled-features/src/user-data-rights/handlers/restrict-account.write.ts +22 -19
  356. package/packages/bundled-features/src/user-data-rights/handlers/run-forget-cleanup.write.ts +8 -8
  357. package/packages/bundled-features/src/user-data-rights/index.ts +8 -10
  358. package/packages/bundled-features/src/user-data-rights/lib/default-mailers.ts +3 -3
  359. package/packages/bundled-features/src/user-data-rights/lib/update-user-lifecycle.ts +24 -27
  360. package/packages/bundled-features/src/user-data-rights/run-export-jobs.ts +166 -276
  361. package/packages/bundled-features/src/user-data-rights/run-forget-cleanup.ts +85 -107
  362. package/packages/bundled-features/src/user-data-rights/run-user-export.ts +67 -69
  363. package/packages/bundled-features/src/user-data-rights/schema/download-attempt.ts +11 -11
  364. package/packages/bundled-features/src/user-data-rights/schema/download-token.ts +37 -41
  365. package/packages/bundled-features/src/user-data-rights/schema/export-job.ts +65 -67
  366. package/packages/bundled-features/src/user-data-rights/token-helpers.ts +21 -25
  367. package/packages/bundled-features/src/user-data-rights/web/client-plugin.tsx +6 -6
  368. package/packages/bundled-features/src/user-data-rights/web/confirm-deletion-screen.tsx +6 -5
  369. package/packages/bundled-features/src/user-data-rights/web/constants.ts +1 -1
  370. package/packages/bundled-features/src/user-data-rights/web/index.ts +5 -5
  371. package/packages/bundled-features/src/user-data-rights/web/privacy-center-screen.tsx +14 -13
  372. package/packages/bundled-features/src/user-data-rights/web/public-deletion-gate.tsx +13 -12
  373. package/packages/bundled-features/src/user-data-rights/web/request-deletion-screen.tsx +6 -6
  374. package/packages/bundled-features/src/user-data-rights/zip-path.ts +41 -40
  375. package/packages/bundled-features/src/user-data-rights-defaults/feature.ts +15 -15
  376. package/packages/bundled-features/src/user-data-rights-defaults/hooks/delivery-attempt.userdata-hook.ts +3 -5
  377. package/packages/bundled-features/src/user-data-rights-defaults/hooks/file-ref.userdata-hook.ts +45 -51
  378. package/packages/bundled-features/src/user-data-rights-defaults/hooks/job-run.userdata-hook.ts +2 -2
  379. package/packages/bundled-features/src/user-data-rights-defaults/hooks/notification-preference.userdata-hook.ts +1 -1
  380. package/packages/bundled-features/src/user-data-rights-defaults/hooks/user-session.userdata-hook.ts +3 -3
  381. package/packages/bundled-features/src/user-data-rights-defaults/hooks/user.userdata-hook.ts +32 -31
  382. package/packages/bundled-features/src/user-profile/handlers/change-email.write.ts +13 -13
  383. package/packages/bundled-features/src/user-profile/index.ts +3 -3
  384. package/packages/bundled-features/src/user-profile/web/client-plugin.ts +1 -1
  385. package/packages/bundled-features/src/user-profile/web/constants.ts +1 -1
  386. package/packages/bundled-features/src/user-profile/web/profile-screen.tsx +1 -1
  387. package/packages/bundled-features/src/workflow-runner/aggregate-id.ts +1 -1
  388. package/packages/bundled-features/src/workflow-runner/event-subscriber.ts +4 -5
  389. package/packages/bundled-features/src/workflow-runner/event-trigger.ts +4 -15
  390. package/packages/bundled-features/src/workflow-runner/feature.ts +2 -2
  391. package/packages/bundled-features/src/workflow-runner/handlers/resume-run.write.ts +4 -4
  392. package/packages/bundled-features/src/workflow-runner/pending-projection.ts +6 -7
  393. package/packages/bundled-features/src/workflow-runner/runner.ts +6 -6
  394. package/packages/bundled-features/src/workflow-runner/tables.ts +6 -6
  395. package/packages/bundled-features/src/workflow-runner/workflow-registry.ts +1 -1
@@ -13,10 +13,9 @@ import {
13
13
  import { GLOBAL_ROLE_OPTIONS } from "../web/constants.ts";
14
14
 
15
15
  /**
16
- * User-Lifecycle-Status (S2.U1). Single source of truth — Auth-Middleware
17
- * (S2.U6), Forget-Job (S2.U5) und Restriction-Handler nutzen diese
18
- * Constants statt Magic-Strings (Memory feedback_role_naming_drift —
19
- * gleiches Pattern wie ROLES.SystemAdmin).
16
+ * User lifecycle status. This is the single source of truth used by the
17
+ * auth middleware, forget job, and restriction handler instead of duplicated
18
+ * magic strings, following the same pattern as ROLES.SystemAdmin.
20
19
  */
21
20
  export const USER_STATUS = {
22
21
  Active: "active",
@@ -28,26 +27,27 @@ export const USER_STATUS = {
28
27
  export type UserStatus = (typeof USER_STATUS)[keyof typeof USER_STATUS];
29
28
 
30
29
  /**
31
- * Anonymize-Display-Strings fuer userDeleteHook (S2.H1). Constants statt
32
- * Magic-Strings damit i18n-Mapping moeglich + drift-fest. Default-DE,
33
- * App-Author kann via i18n-System uebersetzen wenn gewuenscht.
30
+ * Display strings anonymized by userDeleteHook. Constants keep i18n mapping
31
+ * possible and prevent drift. The default is German; app authors can
32
+ * translate it through the i18n system if desired.
34
33
  */
35
34
  export const USER_DELETED_DISPLAY_NAME = "[Geloescht]";
36
35
  export const USER_ANONYMIZED_DISPLAY_NAME = "[Anonymisiert]";
37
36
 
38
37
  /**
39
- * Email-Pseudonyme nach Forget. `<prefix>-<userId>@anonymized.invalid`
40
- * — der userId-Suffix ist als Pseudo-Audit-Marker fuer Operator
41
- * (Tracing-fall) erlaubt; user-id selbst ist UUID, kein PII.
42
- * `.invalid`-TLD ist RFC2606-reserviert — niemals deliverbare Email.
38
+ * Email pseudonyms used after forgetting. `<prefix>-<userId>@anonymized.invalid`
39
+ * — the userId suffix is permitted as a pseudo-audit marker for operator
40
+ * tracing; the user ID itself is a UUID, not PII.
41
+ * The `.invalid` TLD is reserved by RFC2606, so the address can never be
42
+ * delivered.
43
43
  */
44
44
  export const USER_DELETED_EMAIL_PREFIX = "deleted";
45
45
  export const USER_ANONYMIZED_EMAIL_PREFIX = "anonymized";
46
46
  export const USER_ANONYMIZED_EMAIL_DOMAIN = "anonymized.invalid";
47
47
 
48
- // Tuple form fuer createSelectField (erfordert non-empty readonly tuple).
49
- // Object.values(USER_STATUS) waere string[] — statisches Tuple ist
50
- // type-sicher.
48
+ // Tuple form for createSelectField (requires a non-empty readonly tuple).
49
+ // Object.values(USER_STATUS) would be string[]; the static tuple preserves
50
+ // type safety.
51
51
  const USER_STATUS_OPTIONS = [
52
52
  USER_STATUS.Active,
53
53
  USER_STATUS.Restricted,
@@ -63,10 +63,10 @@ export const userEntity = createEntity({
63
63
  table: "read_users",
64
64
  softDelete: true,
65
65
  // Tenant-independent identity aggregate — its event stream lives on
66
- // SYSTEM_TENANT_ID instead of whichever tenant happened to create it (#497).
66
+ // SYSTEM_TENANT_ID instead of whichever tenant happened to create it.
67
67
  systemStream: true,
68
68
  // Every row lives on SYSTEM_TENANT_ID; writes with another tenantId are
69
- // rejected (fw#2858).
69
+ // rejected.
70
70
  tenancy: "global",
71
71
  fields: {
72
72
  // Identity — anyone who can see the user can read the email, but only
@@ -101,17 +101,17 @@ export const userEntity = createEntity({
101
101
  }),
102
102
 
103
103
  // Profile — user-editable. Real name in most apps → PII. Searchable via
104
- // the derived Meili index; events/projection stay ciphertext (#1610).
104
+ // the derived Meili index; events/projection stay ciphertext.
105
105
  displayName: createTextField({
106
106
  required: true,
107
107
  maxLength: 100,
108
108
  personal: "self",
109
109
  find: "fuzzy",
110
110
  }),
111
- // No default here — tenant-settings owns the app-wide locale default; see #1637.
111
+ // No default here — tenant-settings owns the app-wide locale default.
112
112
  locale: createTextField({ maxLength: 10, personal: false, reason: "technical_reference" }),
113
113
  // No default here — mirrors locale: ctx.tz falls back to tenant.timezone
114
- // (then "UTC") when unset, see buildHandlerContext (fw#1636).
114
+ // (then "UTC") when unset, see buildHandlerContext.
115
115
  timezone: createTzField(),
116
116
 
117
117
  // Which tenant should this user land in on next login. Set by the login
@@ -145,21 +145,22 @@ export const userEntity = createEntity({
145
145
  access: { write: access.privileged },
146
146
  }),
147
147
 
148
- // S2.U1: User-Lifecycle-Status für user-data-rights (Sprint 2).
149
- // - "active": Normaler State, alle Operationen erlaubt
150
- // - "restricted": Art. 18 Restriction — Login blockiert + jede
151
- // Live-Session wird vom sessionChecker abgewiesen
148
+ // User lifecycle status for user-data-rights.
149
+ // - "active": Normal state; all operations are allowed.
150
+ // - "restricted": Art. 18 restriction — login is blocked and every
151
+ // live session is rejected by sessionChecker
152
152
  // ("blocked"). Recovery via lift-restriction
153
- // (openToAll, session-unabhängig).
154
- // - "deletionRequested": delete-account aufgerufen, gracePeriodEnd gesetzt,
155
- // Login blockiert. Bestehende Session bleibt LIVE
156
- // (reversibel) — User kann via cancel-deletion
157
- // zurück auf "active".
158
- // - "deleted": Forget executed nach Grace, Row anonymisiert via
159
- // softDelete. Login blockiert + Session "blocked".
153
+ // (openToAll, independent of the session).
154
+ // - "deletionRequested": delete-account was called and gracePeriodEnd set;
155
+ // login is blocked. Existing sessions remain LIVE
156
+ // (reversible), so the user can return to "active"
157
+ // via cancel-deletion.
158
+ // - "deleted": Forget was executed after the grace period; the row
159
+ // was anonymized via softDelete. Login is blocked and
160
+ // the session is "blocked".
160
161
  //
161
- // Schreibrecht privileged: nur die request-deletion / restrict / lift /
162
- // execute-forget-Handler (alle SYSTEM-context) duerfen status flippen.
162
+ // Write access is privileged: only the request-deletion / restrict / lift /
163
+ // execute-forget handlers (all in SYSTEM context) may change the status.
163
164
  status: createSelectField({
164
165
  required: true,
165
166
  default: USER_STATUS.Active,
@@ -168,22 +169,22 @@ export const userEntity = createEntity({
168
169
  access: { write: access.privileged },
169
170
  }),
170
171
 
171
- // Wann darf der pending-Forget tatsaechlich ausgefuehrt werden?
172
- // Cron-Job in user-data-rights checkt taeglich gracePeriodEnd < now()
173
- // und triggert dann die EXT_USER_DATA-Hooks. NULL solange kein
174
- // Forget pending — wird beim delete-account-Call gesetzt
175
- // (= now() + Compliance-Profile.userRights.gracePeriod), beim
176
- // cancel-deletion zurueckgesetzt.
172
+ // When a pending forget may actually be executed.
173
+ // The user-data-rights cron job checks daily whether gracePeriodEnd < now()
174
+ // and then triggers the EXT_USER_DATA hooks. NULL means no forget is pending;
175
+ // delete-account sets it to
176
+ // (= now() + Compliance-Profile.userRights.gracePeriod), and
177
+ // cancel-deletion resets it.
177
178
  gracePeriodEnd: createTimestampField({
178
179
  access: { write: access.privileged },
179
180
  }),
180
181
 
181
- // Replay-Schutz für den anonymen email-Token-Deletion-Flow (#354/1).
182
- // Gesetzt von request-deletion-by-email (eine UUID pro Mail-Antrag),
183
- // genullt von cancel-deletion. confirm-deletion-by-token faltet diese ID
184
- // in die HMAC-Purpose des Tokens — ein nach einem Cancel nachgespieltes
185
- // (noch TTL-gültiges) Token verifiziert gegen die genullte/erneuerte ID
186
- // nicht mehr. NULL solange kein email-Antrag offen ist.
182
+ // Replay protection for the anonymous email-token deletion flow.
183
+ // request-deletion-by-email sets one UUID per email request, and
184
+ // cancel-deletion clears it. confirm-deletion-by-token incorporates this ID
185
+ // into the token's HMAC purpose, so a token replayed after cancellation
186
+ // (while still within its TTL) no longer verifies against the cleared or
187
+ // renewed ID. NULL means no email request is pending.
187
188
  pendingDeletionRequestId: createTextField({
188
189
  maxLength: 36,
189
190
  access: { write: access.privileged },
@@ -1,14 +1,14 @@
1
- // Testing-Helper fürs user-Feature. `seedUser` legt einen User direkt
2
- // über den Event-Store-Executor an — gleicher Pfad wie der echte
3
- // `UserHandlers.create`, aber ohne Access-Check und ohne ConflictError
4
- // bei Duplikaten. Idempotent add-only über die `email`-Spalte: ein
5
- // existierender User → return ohne Event. Kein update-Pfad — Profilfelder
6
- // ändern läuft über den regulären Handler.
1
+ // Testing helper for the user feature. `seedUser` creates a user directly
2
+ // through the event-store executor—the same path as the real
3
+ // `UserHandlers.create`, but without access checks or ConflictError on
4
+ // duplicates. It is idempotent and add-only via the `email` column: an
5
+ // existing user returns without emitting an event. There is no update path;
6
+ // profile changes go through the regular handler.
7
7
  //
8
- // Warum nicht direkt `db.insert(userTable)`: das würde den Event-Store
9
- // umgehen, also kein `user.created`-Event und keine MSP-Konsumenten
10
- // (audit, search-index) sehen den Seed. Der Executor-Pfad emittiert
11
- // das Event UND schreibt die Projection-Zeile in einer TX.
8
+ // Directly calling `db.insert(userTable)` would bypass the event store, so no
9
+ // `user.created` event would be emitted and no MSP consumers (audit,
10
+ // search-index) would see the seed. The executor path emits the event and
11
+ // writes the projection row in one transaction.
12
12
 
13
13
  import { computeBlindIndex, configuredBlindIndexKey } from "@cosmicdrift/kumiko-framework/crypto";
14
14
  import {
@@ -19,7 +19,7 @@ import {
19
19
  } from "@cosmicdrift/kumiko-framework/db";
20
20
  import type { SessionUser } from "@cosmicdrift/kumiko-framework/engine";
21
21
  import { TestUsers } from "@cosmicdrift/kumiko-framework/seeding";
22
- // kumiko-lint-ignore cross-feature-import shares the postSave-hooks fixture contract with tenant/seeding (#1478)
22
+ // kumiko-lint-ignore cross-feature-import shares the postSave-hooks fixture contract with tenant/seeding
23
23
  import { fireEntityPostSave, type SeedTenantHooks } from "../tenant/seeding.ts";
24
24
  import { userEntity, userTable } from "./schema/user.ts";
25
25
 
@@ -28,48 +28,48 @@ const userExecutor = createEventStoreExecutor(userTable, userEntity, { entityNam
28
28
  export type SeedUserOptions = {
29
29
  readonly email: string;
30
30
  readonly displayName: string;
31
- /** Optional bereits-gehashtes Passwort. Für plain-password-Tests
32
- * besser den Convenience-Wrapper aus
33
- * `@cosmicdrift/kumiko-bundled-features/auth-email-password/seeding` nutzen,
34
- * der argon2-Hashing übernimmt. */
31
+ /** Optional pre-hashed password. For plain-password tests, prefer the
32
+ * convenience wrapper from
33
+ * `@cosmicdrift/kumiko-bundled-features/auth-email-password/seeding`,
34
+ * which performs argon2 hashing. */
35
35
  readonly passwordHash?: string;
36
36
  readonly locale?: string;
37
- /** Global roles — land in users.roles as jsonb string[].
38
- * Werden vom login-handler in die Session-Roles parallel zu tenant-
39
- * membership-roles gemerged. Default: leer-array. Typisches Beispiel:
40
- * `["SystemAdmin"]` für den Plattform-Operator. */
37
+ /** Global roles—stored in users.roles as jsonb string[].
38
+ * The login handler merges them into the session roles alongside tenant-
39
+ * membership roles. Default: empty array. Typical example:
40
+ * `["SystemAdmin"]` for the platform operator. */
41
41
  readonly roles?: readonly string[];
42
- /** Initial-State für emailVerified. Default false (Pflicht-Verify-Flow
43
- * muss explizit "true" setzen wenn Email-Ownership schon bewiesen ist —
44
- * z.B. Magic-Link-Signup, wo der User den Mail-Link klicken musste
45
- * bevor sein Account überhaupt entsteht). */
42
+ /** Initial state for emailVerified. Default: false. The required
43
+ * verification flow must explicitly set "true" when email ownership has
44
+ * already been proven—for example, in a Magic-Link signup where the user
45
+ * clicked the email link before the account was created. */
46
46
  readonly emailVerified?: boolean;
47
47
  readonly by?: SessionUser;
48
48
  };
49
49
 
50
50
  /**
51
- * Seed a user. Returns the userId (existing oder neu angelegt).
52
- * Idempotent add-only über die `email`-Spalte: wenn ein User mit dieser
53
- * Email existiert, kommt seine ID zurück ohne neuen Insert.
51
+ * Seeds a user. Returns the userId (existing or newly created).
52
+ * Idempotent and add-only via the `email` column: if a user with this
53
+ * email exists, its ID is returned without a new insert.
54
54
  */
55
55
  export async function seedUser(
56
56
  db: DbConnection,
57
57
  options: SeedUserOptions,
58
58
  // Optional, append-only — same rationale as tenant/seeding's seedTenant
59
- // hooks param (#1478): fires user's postSave hooks (e.g. a Welcome-
59
+ // hooks param: fires user's postSave hooks (e.g. a Welcome-
60
60
  // notification hook keyed off `allOf: "user"`) for fixtures/self-signup
61
61
  // that opt in. Omit to keep today's hook-less behavior.
62
62
  hooks?: SeedTenantHooks,
63
63
  ): Promise<{ id: string }> {
64
64
  const by = options.by ?? TestUsers.systemAdmin;
65
- // executor.create erwartet eine TenantDb (mit .insert()-API). User
66
- // ist zwar tenant-agnostic (kein tenant_id-Spalte), aber das runtime-
67
- // Interface braucht den Wrap.
65
+ // executor.create expects a TenantDb (with an .insert() API). Although
66
+ // User is tenant-agnostic (it has no tenant_id column), the runtime
67
+ // interface requires this wrapper.
68
68
  const tdb = createTenantDb({ db, tenantId: by.tenantId, mode: "system" });
69
69
 
70
70
  const existing = await fetchOne(db, userTable, { email: options.email, isDeleted: false });
71
- // @cast-boundary db-row: users.id ist uuid-Spalte (string), fetchOne
72
- // liefert die Projection-Row als Record<string, unknown>.
71
+ // @cast-boundary db-row: users.id is a uuid column (string), and fetchOne
72
+ // returns the projection row as Record<string, unknown>.
73
73
  if (existing) {
74
74
  const id = existing["id"] as string;
75
75
  if (options.emailVerified === true) {
@@ -100,7 +100,7 @@ export async function seedUser(
100
100
  }
101
101
 
102
102
  // A re-run seed onto a row created before emailVerified flipped to true must
103
- // still set it (#1687) — via the executor, so it lands as a real `.updated` event.
103
+ // still set it — via the executor, so it lands as a real `.updated` event.
104
104
  export async function reconcileSeededUserEmailVerified(
105
105
  db: DbConnection,
106
106
  existingRow: Record<string, unknown>,
@@ -108,8 +108,8 @@ export async function reconcileSeededUserEmailVerified(
108
108
  ): Promise<void> {
109
109
  // skip: already verified, nothing to reconcile
110
110
  if (existingRow["emailVerified"] === true) return;
111
- // @cast-boundary db-row: users.id ist uuid-Spalte (string), fetchOne
112
- // liefert die Projection-Row als Record<string, unknown>.
111
+ // @cast-boundary db-row: users.id is a uuid column (string), and fetchOne
112
+ // returns the projection row as Record<string, unknown>.
113
113
  const id = existingRow["id"] as string;
114
114
  const tdb = createTenantDb({ db, tenantId: by.tenantId, mode: "system" });
115
115
  const result = await userExecutor.update(
@@ -173,11 +173,11 @@ export async function rewriteSeededUserEmail(
173
173
  }
174
174
  }
175
175
 
176
- // Extrahiert die `id`-Spalte aus dem executor.create-Result. Der
177
- // Executor liefert ein Record<string, unknown> (die Projection-Row), in
178
- // das die DB die Aggregat-id reinschreibt — wir prüfen runtime statt
179
- // blindem `as { id: string }`-Cast, damit ein API-Vertragsbruch sofort
180
- // als ehrlicher Throw rauskommt statt downstream als undefined-Bug.
176
+ // Extracts the `id` column from the executor.create result. The executor
177
+ // returns a Record<string, unknown> (the projection row), into which the DB
178
+ // writes the aggregate ID. We validate it at runtime instead of using a
179
+ // blind `as { id: string }` cast, so an API contract violation throws an
180
+ // explicit error rather than surfacing downstream as an undefined-value bug.
181
181
  function extractId(data: unknown, who: string): string {
182
182
  if (typeof data === "object" && data !== null && "id" in data) {
183
183
  const id = (data as { id: unknown }).id; // @cast-boundary engine-bridge
@@ -1,5 +1,5 @@
1
- // /testing re-exportiert /seeding. Siehe ../tenant/testing.ts für die
2
- // Begründung — Helpers sind shared zwischen Tests und Dev-Server-
3
- // Bootstrap, /seeding ist die stabile Heimat.
1
+ // /testing re-exports /seeding. See ../tenant/testing.ts for the
2
+ // reason: helpers are shared between tests and Dev-Server bootstrap,
3
+ // and /seeding is the stable home.
4
4
 
5
5
  export * from "./seeding.ts";
@@ -1,19 +1,18 @@
1
- // Audit-Helper fuer Download-Endpoint (S2.U3 Atom 4b).
1
+ // Audit helper for the download endpoint.
2
2
  //
3
- // Beim Download (Token-Pfad oder Job-Pfad) werden Audit-Felder am
4
- // Token-Row aktualisiert:
3
+ // During a download (token path or job path), audit fields on the token row
4
+ // are updated:
5
5
  // - useCount + 1
6
6
  // - lastUsedAt = now
7
- // - lastUsedFromIp = caller-IP (X-Forwarded-For oder Connection-IP)
8
- // - lastUsedUserAgent = UA-Header
7
+ // - lastUsedFromIp = caller IP (X-Forwarded-For or connection IP)
8
+ // - lastUsedUserAgent = UA header
9
9
  //
10
- // **Best-Effort-Update:** version-conflicts (zwei parallel-Downloads
11
- // raceen um den update) werden silent geswallowt — Audit ist "letzter
12
- // Use", nicht "alle Uses". Der zweite Download succeeded trotzdem
13
- // (kein download-block bei race).
10
+ // **Best-effort update:** version conflicts (two downloads racing to update)
11
+ // are silently swallowed — the audit records the "last use", not "all uses".
12
+ // The second download still succeeds (a race does not block the download).
14
13
  //
15
- // **ES via tokenCrud.update:** kein direct-UPDATE. Memory
16
- // `feedback_no_fake_dispatcher` + `feedback_event_store_tenant_consistency`.
14
+ // **ES via tokenCrud.update:** no direct UPDATE, so the event-store and tenant
15
+ // consistency rules remain in effect.
17
16
 
18
17
  import type { DbRunner } from "@cosmicdrift/kumiko-framework/db";
19
18
  import { createEventStoreExecutor, createTenantDb } from "@cosmicdrift/kumiko-framework/db";
@@ -34,11 +33,11 @@ export interface RecordDownloadUseArgs {
34
33
  readonly tokenVersion: number;
35
34
  readonly tokenUseCount: number;
36
35
  /**
37
- * Tenant fuer die system-mode-TenantDb. ExportDownloadToken ist
38
- * tenant-agnostisch (1:1 zum tenant-agnostic Job), aber der event-
39
- * store-Stream-Lookup braucht einen Tenant-Context. Wir nutzen
40
- * job.requestedFromTenantId — dieselbe Identitaet wie beim
41
- * Token-Create im Worker (Atom 4a).
36
+ * Tenant for the system-mode TenantDb. ExportDownloadToken is
37
+ * tenant-agnostic (1:1 with the tenant-agnostic job), but the event-store
38
+ * stream lookup requires a tenant context. We use
39
+ * job.requestedFromTenantId — the same identity used when creating the
40
+ * token in the worker.
42
41
  */
43
42
  readonly tenantId: TenantId;
44
43
  readonly now: Instant;
@@ -47,9 +46,9 @@ export interface RecordDownloadUseArgs {
47
46
  }
48
47
 
49
48
  /**
50
- * Audit-Update: useCount, lastUsedAt, IP, UA. Best-effort —
51
- * version-conflicts (parallel-downloads) werden swallowed, Download
52
- * succeeded trotzdem.
49
+ * Audit update: useCount, lastUsedAt, IP, and UA. Best-effort —
50
+ * version conflicts (parallel downloads) are swallowed, so the download
51
+ * still succeeds.
53
52
  */
54
53
  export async function recordDownloadUse(args: RecordDownloadUseArgs): Promise<void> {
55
54
  const { db, tokenId, tokenVersion, tokenUseCount, tenantId, now, ip, userAgent } = args;
@@ -72,15 +71,15 @@ export async function recordDownloadUse(args: RecordDownloadUseArgs): Promise<vo
72
71
  tdb,
73
72
  )
74
73
  .catch(() => {
75
- // version-conflict bei parallelen Downloads → der erste hat
76
- // bereits useCount inkrementiert. Wir behalten den Audit-Eintrag
77
- // des ersten Downloads (lastUsedAt etc.). Kein download-block.
74
+ // A version conflict means a parallel download already incremented
75
+ // useCount. Keep the first download's audit entry (lastUsedAt, etc.);
76
+ // do not block the download.
78
77
  });
79
78
  }
80
79
 
81
- // extractCallerIp lebt in feature.ts (extractAuditMeta) — query-handler
82
- // haben keinen direkten Header-Zugriff (transport-agnostic), httpRoute-
83
- // Wrapper extrahiert + steckt in payload.auditMeta.
80
+ // extractCallerIp lives in feature.ts (extractAuditMeta) — query handlers
81
+ // have no direct header access because they are transport-agnostic. The
82
+ // httpRoute wrapper extracts it and places it in payload.auditMeta.
84
83
 
85
84
  export type DownloadAttemptResult = "notFound" | "expired" | "failed" | "signedUrlNotSupported";
86
85
 
@@ -97,9 +96,9 @@ export interface RecordInvalidAttemptArgs {
97
96
  readonly userAgent: string | null;
98
97
  }
99
98
 
100
- // Best-effort INSERT in read_download_attempts. Throws im Audit-Pfad
101
- // duerfen den Download-Endpoint nicht killen (User soll seinen 404
102
- // bekommen, nicht 500); failures werden silent geswallowt.
99
+ // Best-effort INSERT into read_download_attempts. Errors in the audit path
100
+ // must not kill the download endpoint: the user should receive their 404,
101
+ // not a 500; failures are silently swallowed.
103
102
  export async function recordInvalidAttempt(args: RecordInvalidAttemptArgs): Promise<void> {
104
103
  const { db, tenantId, now } = args;
105
104
  const executor = createSystemUser(tenantId);
@@ -12,7 +12,7 @@ import { entitiesOf } from "../shared/index.ts";
12
12
  // only; runtime no-ops (a delete hook that silently skips) are not detectable
13
13
  // here — those are covered by the export/forget integration tests.
14
14
  //
15
- // Registered as an `r.bootCheck()` by this feature (#1314) — EXT_USER_DATA is
15
+ // Registered as an `r.bootCheck()` by this feature — EXT_USER_DATA is
16
16
  // owned by user-data-rights (r.extendsRegistrar(EXT_USER_DATA, {})), so any
17
17
  // r.useExtension(EXT_USER_DATA, ...) usage across the app already requires
18
18
  // user-data-rights to be mounted (boot-validator's extension-provider check
@@ -2,7 +2,7 @@
2
2
  // subject is the user, the anchor is the pending request id stored on the
3
3
  // user row. Minting and verification both run through
4
4
  // shared/row-bound-grant, so a token from a cancelled cycle (id nulled) or a
5
- // superseded one (row holds a newer id) fails verification — see #354/1.
5
+ // superseded one (row holds a newer id) fails verification.
6
6
  //
7
7
  // The purpose string and the anchoring are unchanged from the hand-rolled
8
8
  // version this replaced, so tokens stay byte-compatible.