@cosmicdrift/kumiko-samples 0.413.0 → 0.414.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 (459) hide show
  1. package/package.json +1 -1
  2. package/packages/bundled-features/package.json +16 -1
  3. package/packages/bundled-features/src/admin-shell/changes.json +6 -0
  4. package/packages/bundled-features/src/admin-shell/feature.ts +8 -7
  5. package/packages/bundled-features/src/agent-tools/agent-doc-lint.ts +5 -1
  6. package/packages/bundled-features/src/agent-tools/agent-manifest.ts +36 -27
  7. package/packages/bundled-features/src/agent-tools/api-docs/collect-events.ts +8 -1
  8. package/packages/bundled-features/src/agent-tools/api-docs/collect.ts +3 -2
  9. package/packages/bundled-features/src/agent-tools/api-docs/generate.ts +6 -0
  10. package/packages/bundled-features/src/agent-tools/api-docs/index.ts +1 -0
  11. package/packages/bundled-features/src/agent-tools/api-docs/problems.ts +38 -1
  12. package/packages/bundled-features/src/agent-tools/api-docs/render-openapi.ts +1 -0
  13. package/packages/bundled-features/src/agent-tools/api-docs/resolve-config.ts +17 -0
  14. package/packages/bundled-features/src/agent-tools/api-docs/scope-slug-collisions.ts +17 -0
  15. package/packages/bundled-features/src/agent-tools/api-docs/translation-gaps.ts +42 -0
  16. package/packages/bundled-features/src/agent-tools/api-docs/webhook-example-problems.ts +30 -0
  17. package/packages/bundled-features/src/agent-tools/changes.json +12 -0
  18. package/packages/bundled-features/src/agent-tools/index.ts +1 -0
  19. package/packages/bundled-features/src/agent-tools/labels.ts +19 -6
  20. package/packages/bundled-features/src/agent-tools/tool-catalog.ts +18 -7
  21. package/packages/bundled-features/src/agent-tools/tool-dispatch.ts +14 -1
  22. package/packages/bundled-features/src/agent-tools/types.ts +4 -0
  23. package/packages/bundled-features/src/audit/event-classification.ts +6 -0
  24. package/packages/bundled-features/src/audit/web/i18n.ts +1 -0
  25. package/packages/bundled-features/src/auth-email-password/changes.json +18 -0
  26. package/packages/bundled-features/src/auth-email-password/errors.ts +0 -13
  27. package/packages/bundled-features/src/auth-email-password/handlers/invite-signup-complete.write.ts +147 -121
  28. package/packages/bundled-features/src/auth-email-password/handlers/login-options.query.ts +1 -1
  29. package/packages/bundled-features/src/auth-email-password/handlers/request-account-unlock.write.ts +1 -1
  30. package/packages/bundled-features/src/auth-email-password/handlers/request-email-verification.write.ts +0 -1
  31. package/packages/bundled-features/src/auth-email-password/handlers/request-password-reset.write.ts +0 -1
  32. package/packages/bundled-features/src/auth-email-password/handlers/self-registration-status.query.ts +1 -1
  33. package/packages/bundled-features/src/auth-email-password/reset-token.ts +0 -2
  34. package/packages/bundled-features/src/auth-email-password/seeding.ts +39 -7
  35. package/packages/bundled-features/src/auth-email-password/unlock-token.ts +0 -2
  36. package/packages/bundled-features/src/auth-email-password/verification-token.ts +0 -2
  37. package/packages/bundled-features/src/auth-email-password/web/auth-form-primitives.tsx +2 -2
  38. package/packages/bundled-features/src/auth-email-password/web/auth-gate.tsx +2 -2
  39. package/packages/bundled-features/src/auth-email-password/web/auth-redirect.ts +5 -0
  40. package/packages/bundled-features/src/auth-email-password/web/forgot-password-screen.tsx +1 -6
  41. package/packages/bundled-features/src/auth-email-password/web/invite-accept-screen.tsx +1 -1
  42. package/packages/bundled-features/src/auth-email-password/web/return-path.ts +2 -1
  43. package/packages/bundled-features/src/auth-email-password/web/session.tsx +10 -12
  44. package/packages/bundled-features/src/auth-email-password/web/signup-screen.tsx +1 -6
  45. package/packages/bundled-features/src/auth-email-password/web/static-account.ts +6 -1
  46. package/packages/bundled-features/src/auth-email-password/web/tenant-switcher.tsx +1 -1
  47. package/packages/bundled-features/src/auth-email-password/web/token-confirm-screen.tsx +4 -5
  48. package/packages/bundled-features/src/auth-email-password/web/user-menu.tsx +1 -1
  49. package/packages/bundled-features/src/auth-mfa/web/mfa-code-or-recovery-field.tsx +17 -1
  50. package/packages/bundled-features/src/auth-mfa/web/mfa-disable-dialog.tsx +1 -1
  51. package/packages/bundled-features/src/auth-mfa/web/mfa-regenerate-recovery-dialog.tsx +1 -1
  52. package/packages/bundled-features/src/auth-mfa/web/mfa-setup-preauth-screen.tsx +1 -1
  53. package/packages/bundled-features/src/auth-mfa/web/mfa-verify-screen.tsx +16 -47
  54. package/packages/bundled-features/src/auth-mfa-user-data/index.ts +5 -6
  55. package/packages/bundled-features/src/billing-foundation/aggregate-id.ts +0 -4
  56. package/packages/bundled-features/src/billing-foundation/changes.json +37 -0
  57. package/packages/bundled-features/src/billing-foundation/checkout-core.ts +8 -1
  58. package/packages/bundled-features/src/billing-foundation/checkout-ledger.ts +59 -0
  59. package/packages/bundled-features/src/billing-foundation/consumer-protection/consent-gate.ts +2 -1
  60. package/packages/bundled-features/src/billing-foundation/consumer-protection/consent-text.ts +49 -2
  61. package/packages/bundled-features/src/billing-foundation/consumer-protection/termination-open-cancels.ts +5 -0
  62. package/packages/bundled-features/src/billing-foundation/consumer-protection/termination-provider-timeout.ts +23 -0
  63. package/packages/bundled-features/src/billing-foundation/consumer-protection/termination-record.ts +12 -7
  64. package/packages/bundled-features/src/billing-foundation/consumer-protection/termination-revoke.ts +1 -1
  65. package/packages/bundled-features/src/billing-foundation/events.ts +49 -10
  66. package/packages/bundled-features/src/billing-foundation/feature.ts +15 -1
  67. package/packages/bundled-features/src/billing-foundation/handlers/billing-plans.query.ts +47 -14
  68. package/packages/bundled-features/src/billing-foundation/handlers/create-checkout-session.write.ts +7 -1
  69. package/packages/bundled-features/src/billing-foundation/handlers/process-event.write.ts +124 -10
  70. package/packages/bundled-features/src/billing-foundation/handlers/process-payment-event.write.ts +33 -9
  71. package/packages/bundled-features/src/billing-foundation/handlers/record-checkout-opened.write.ts +25 -0
  72. package/packages/bundled-features/src/billing-foundation/handlers/start-plan-checkout.write.ts +7 -1
  73. package/packages/bundled-features/src/billing-foundation/handlers/switch-plan.write.ts +16 -4
  74. package/packages/bundled-features/src/billing-foundation/i18n.ts +3 -0
  75. package/packages/bundled-features/src/billing-foundation/pending-plan-switch.ts +80 -0
  76. package/packages/bundled-features/src/billing-foundation/scrub-raw-payload-headers.ts +50 -0
  77. package/packages/bundled-features/src/billing-foundation/types.ts +47 -30
  78. package/packages/bundled-features/src/billing-foundation/validate-options.ts +18 -0
  79. package/packages/bundled-features/src/billing-foundation/web/billing-plans-panel.tsx +10 -5
  80. package/packages/bundled-features/src/billing-foundation/web/cancel-contract-dialog.tsx +1 -1
  81. package/packages/bundled-features/src/billing-foundation/web/checkout-consent-dialog.tsx +1 -1
  82. package/packages/bundled-features/src/billing-foundation/web/constants.ts +5 -2
  83. package/packages/bundled-features/src/billing-foundation/web/plan-switch-confirm-dialog.tsx +1 -1
  84. package/packages/bundled-features/src/billing-foundation/webhook-handler.ts +65 -17
  85. package/packages/bundled-features/src/cap-counter/aggregate-id.ts +0 -2
  86. package/packages/bundled-features/src/cap-counter/changes.json +6 -0
  87. package/packages/bundled-features/src/cap-counter/stock-cap-guard.ts +19 -4
  88. package/packages/bundled-features/src/cap-overview/changes.json +6 -0
  89. package/packages/bundled-features/src/cap-overview/handlers/tenant-caps-list.query.ts +22 -6
  90. package/packages/bundled-features/src/cap-overview/i18n.ts +1 -0
  91. package/packages/bundled-features/src/cap-overview/index.ts +1 -0
  92. package/packages/bundled-features/src/cap-overview/types.ts +11 -1
  93. package/packages/bundled-features/src/cap-overview/web/cap-cards-panel.tsx +6 -2
  94. package/packages/bundled-features/src/cap-overview/web/cap-usage-bar.tsx +10 -1
  95. package/packages/bundled-features/src/cap-overview/web/usage-math.ts +5 -0
  96. package/packages/bundled-features/src/channel-in-app/changes.json +6 -0
  97. package/packages/bundled-features/src/channel-in-app/handlers/read-state-by-keys.query.ts +2 -2
  98. package/packages/bundled-features/src/channel-whatsapp/aggregate-id.ts +29 -0
  99. package/packages/bundled-features/src/channel-whatsapp/changes.json +8 -0
  100. package/packages/bundled-features/src/channel-whatsapp/constants.ts +46 -0
  101. package/packages/bundled-features/src/channel-whatsapp/events.ts +93 -0
  102. package/packages/bundled-features/src/channel-whatsapp/feature.ts +72 -0
  103. package/packages/bundled-features/src/channel-whatsapp/graph-client.ts +398 -0
  104. package/packages/bundled-features/src/channel-whatsapp/in-memory-meta.ts +300 -0
  105. package/packages/bundled-features/src/channel-whatsapp/inbound-handlers.ts +189 -0
  106. package/packages/bundled-features/src/channel-whatsapp/index.ts +66 -0
  107. package/packages/bundled-features/src/channel-whatsapp/meta-signature.ts +26 -0
  108. package/packages/bundled-features/src/channel-whatsapp/options.ts +149 -0
  109. package/packages/bundled-features/src/channel-whatsapp/pii.ts +109 -0
  110. package/packages/bundled-features/src/channel-whatsapp/webhook-normalize.ts +226 -0
  111. package/packages/bundled-features/src/channel-whatsapp/webhook-routes.ts +185 -0
  112. package/packages/bundled-features/src/compliance-profiles/handlers/sub-processors.query.ts +1 -1
  113. package/packages/bundled-features/src/config/changes.json +12 -0
  114. package/packages/bundled-features/src/config/handlers/set.write.ts +7 -0
  115. package/packages/bundled-features/src/config/handlers/values.query.ts +8 -1
  116. package/packages/bundled-features/src/config/index.ts +1 -0
  117. package/packages/bundled-features/src/config/read-redaction.ts +6 -3
  118. package/packages/bundled-features/src/config/table.ts +1 -0
  119. package/packages/bundled-features/src/config/write-helpers.ts +3 -2
  120. package/packages/bundled-features/src/crypto-shredding/changes.json +18 -0
  121. package/packages/bundled-features/src/crypto-shredding/constants.ts +2 -0
  122. package/packages/bundled-features/src/crypto-shredding/handlers/forget-subject.write.ts +38 -18
  123. package/packages/bundled-features/src/crypto-shredding/index.ts +4 -0
  124. package/packages/bundled-features/src/crypto-shredding/subject-forget-after-delete-hook.ts +49 -0
  125. package/packages/bundled-features/src/custom-fields/aggregate-id.ts +0 -1
  126. package/packages/bundled-features/src/custom-fields/entity.ts +1 -0
  127. package/packages/bundled-features/src/custom-fields/wire-for-entity.ts +0 -1
  128. package/packages/bundled-features/src/data-retention/changes.json +18 -0
  129. package/packages/bundled-features/src/data-retention/erase-notes-of-deleted-row.ts +23 -0
  130. package/packages/bundled-features/src/data-retention/feature.ts +4 -7
  131. package/packages/bundled-features/src/data-retention/run-retention-cleanup.ts +38 -18
  132. package/packages/bundled-features/src/data-retention/tenant-destruction-hold.ts +9 -0
  133. package/packages/bundled-features/src/delivery/attempt-log-factory.ts +11 -0
  134. package/packages/bundled-features/src/delivery/attempt-log.ts +3 -3
  135. package/packages/bundled-features/src/delivery/changes.json +6 -0
  136. package/packages/bundled-features/src/delivery/channel-context.ts +6 -3
  137. package/packages/bundled-features/src/delivery/db/queries/preferences.ts +0 -1
  138. package/packages/bundled-features/src/delivery/delivery-service.ts +3 -0
  139. package/packages/bundled-features/src/delivery/feature.ts +4 -13
  140. package/packages/bundled-features/src/delivery/handlers/opted-in-user-ids.query.ts +45 -0
  141. package/packages/bundled-features/src/delivery/handlers/preferences.query.ts +2 -20
  142. package/packages/bundled-features/src/delivery/handlers/resubscribe-user.write.ts +2 -25
  143. package/packages/bundled-features/src/delivery/handlers/unsubscribe-page-chrome.query.ts +2 -0
  144. package/packages/bundled-features/src/delivery/handlers/unsubscribe-user.write.ts +2 -27
  145. package/packages/bundled-features/src/delivery/index.ts +3 -1
  146. package/packages/bundled-features/src/delivery/options.ts +11 -0
  147. package/packages/bundled-features/src/delivery/preference-rows.ts +33 -0
  148. package/packages/bundled-features/src/delivery/set-preference-enabled.ts +40 -0
  149. package/packages/bundled-features/src/delivery/testing.ts +3 -1
  150. package/packages/bundled-features/src/delivery/types.ts +1 -0
  151. package/packages/bundled-features/src/delivery/unsubscribe-page.ts +7 -1
  152. package/packages/bundled-features/src/delivery/upsert-preference.ts +0 -1
  153. package/packages/bundled-features/src/delivery/web/public-names.ts +1 -0
  154. package/packages/bundled-features/src/derivatives-sharp/render.ts +9 -9
  155. package/packages/bundled-features/src/document-ingest-foundation/aggregate-id.ts +0 -1
  156. package/packages/bundled-features/src/document-ingest-foundation/append-missing-extract-event.ts +37 -25
  157. package/packages/bundled-features/src/document-ingest-foundation/report-ingest-progress.ts +32 -14
  158. package/packages/bundled-features/src/documents/aggregate-id.ts +0 -2
  159. package/packages/bundled-features/src/documents/changes.json +18 -0
  160. package/packages/bundled-features/src/documents/constants.ts +10 -2
  161. package/packages/bundled-features/src/documents/ensure-link.ts +3 -4
  162. package/packages/bundled-features/src/documents/feature.ts +28 -6
  163. package/packages/bundled-features/src/documents/handlers/import.write.ts +2 -2
  164. package/packages/bundled-features/src/documents/queries/expiry-overview.query.ts +2 -1
  165. package/packages/bundled-features/src/documents/queries/for-record.query.ts +3 -4
  166. package/packages/bundled-features/src/documents/queries/list-page.ts +11 -3
  167. package/packages/bundled-features/src/documents/queries/overview.query.ts +2 -2
  168. package/packages/bundled-features/src/documents/screens.ts +8 -3
  169. package/packages/bundled-features/src/documents/tab.ts +1 -1
  170. package/packages/bundled-features/src/feature-toggles/toggle-sync-signal.ts +6 -3
  171. package/packages/bundled-features/src/file-derivatives/handlers/public-variant-by-file-ref.query.ts +1 -1
  172. package/packages/bundled-features/src/file-derivatives/handlers/public-variant.query.ts +1 -1
  173. package/packages/bundled-features/src/file-foundation/probe.ts +9 -3
  174. package/packages/bundled-features/src/file-foundation/read-file-ref-content.ts +24 -11
  175. package/packages/bundled-features/src/file-provider-inmemory/feature.ts +1 -1
  176. package/packages/bundled-features/src/file-provider-s3/changes.json +14 -0
  177. package/packages/bundled-features/src/file-provider-s3/env-feature.ts +1 -1
  178. package/packages/bundled-features/src/file-provider-s3/env-named-feature.ts +1 -1
  179. package/packages/bundled-features/src/file-provider-s3/env-schema.ts +24 -7
  180. package/packages/bundled-features/src/file-provider-s3/feature.ts +1 -1
  181. package/packages/bundled-features/src/file-provider-s3/index.ts +7 -1
  182. package/packages/bundled-features/src/file-provider-s3/lib/env-helper.ts +21 -13
  183. package/packages/bundled-features/src/file-provider-s3/lib/s3-provider.ts +8 -1
  184. package/packages/bundled-features/src/files/changes.json +7 -0
  185. package/packages/bundled-features/src/folders/aggregate-id.ts +0 -1
  186. package/packages/bundled-features/src/folders/web/folder-manager.tsx +6 -6
  187. package/packages/bundled-features/src/folders-user-data/index.ts +12 -14
  188. package/packages/bundled-features/src/helpdesk/changes.json +62 -0
  189. package/packages/bundled-features/src/helpdesk/entity.ts +4 -1
  190. package/packages/bundled-features/src/helpdesk/feature.ts +41 -0
  191. package/packages/bundled-features/src/helpdesk/handlers/access.ts +0 -10
  192. package/packages/bundled-features/src/helpdesk/handlers/attempts.ts +7 -14
  193. package/packages/bundled-features/src/helpdesk/handlers/challenge.query.ts +1 -2
  194. package/packages/bundled-features/src/helpdesk/handlers/reply.write.ts +2 -9
  195. package/packages/bundled-features/src/helpdesk/handlers/report.write.ts +2 -9
  196. package/packages/bundled-features/src/helpdesk/handlers/submit.write.ts +3 -11
  197. package/packages/bundled-features/src/helpdesk/index.ts +1 -0
  198. package/packages/bundled-features/src/helpdesk/legacy-contact-config.ts +61 -0
  199. package/packages/bundled-features/src/helpdesk/legacy-contact-erasure.ts +45 -0
  200. package/packages/bundled-features/src/helpdesk/legacy-contact-retention.ts +65 -0
  201. package/packages/bundled-features/src/helpdesk/legacy-contact-streams.ts +185 -0
  202. package/packages/bundled-features/src/helpdesk/legacy-contact-user-data.ts +84 -0
  203. package/packages/bundled-features/src/helpdesk/lib.ts +47 -34
  204. package/packages/bundled-features/src/helpdesk/user-data-hooks.ts +89 -48
  205. package/packages/bundled-features/src/helpdesk/web/constants.ts +0 -1
  206. package/packages/bundled-features/src/inbound-mail-foundation/account-health.ts +1 -1
  207. package/packages/bundled-features/src/inbound-mail-foundation/account-poll.ts +5 -1
  208. package/packages/bundled-features/src/inbound-mail-foundation/aggregate-id.ts +0 -2
  209. package/packages/bundled-features/src/inbound-mail-foundation/changes.json +48 -0
  210. package/packages/bundled-features/src/inbound-mail-foundation/constants.ts +6 -0
  211. package/packages/bundled-features/src/inbound-mail-foundation/content-refetch.ts +15 -1
  212. package/packages/bundled-features/src/inbound-mail-foundation/entities.ts +64 -15
  213. package/packages/bundled-features/src/inbound-mail-foundation/events.ts +15 -16
  214. package/packages/bundled-features/src/inbound-mail-foundation/feature.ts +3 -1
  215. package/packages/bundled-features/src/inbound-mail-foundation/handlers/account-address.ts +16 -2
  216. package/packages/bundled-features/src/inbound-mail-foundation/handlers/attach-message-content.write.ts +10 -3
  217. package/packages/bundled-features/src/inbound-mail-foundation/handlers/connect-account.write.ts +21 -8
  218. package/packages/bundled-features/src/inbound-mail-foundation/handlers/forget-message.write.ts +73 -0
  219. package/packages/bundled-features/src/inbound-mail-foundation/i18n.ts +3 -0
  220. package/packages/bundled-features/src/inbound-mail-foundation/index.ts +1 -0
  221. package/packages/bundled-features/src/inbound-mail-foundation/oauth-access-token.ts +1 -1
  222. package/packages/bundled-features/src/inbound-mail-foundation/outbound-mail.ts +2 -0
  223. package/packages/bundled-features/src/inbound-mail-foundation/personal-address.ts +20 -0
  224. package/packages/bundled-features/src/inbound-mail-foundation/purge-messages.ts +54 -0
  225. package/packages/bundled-features/src/inbound-mail-foundation/quarantine.ts +15 -5
  226. package/packages/bundled-features/src/inbound-mail-foundation/retention-job.ts +1 -5
  227. package/packages/bundled-features/src/inbound-mail-foundation/retention-sweep.ts +21 -34
  228. package/packages/bundled-features/src/inbound-mail-foundation/send-from-account.ts +9 -1
  229. package/packages/bundled-features/src/inbound-mail-foundation/supervisor-ingest.ts +7 -1
  230. package/packages/bundled-features/src/inbound-mail-foundation/sync-account-now.ts +1 -1
  231. package/packages/bundled-features/src/inbound-mail-foundation/tenant-destroy-hook.ts +14 -17
  232. package/packages/bundled-features/src/inbound-mail-foundation/watch-supervisor.ts +1 -1
  233. package/packages/bundled-features/src/inbound-provider-imap/byte-budget.ts +80 -0
  234. package/packages/bundled-features/src/inbound-provider-imap/changes.json +13 -0
  235. package/packages/bundled-features/src/inbound-provider-imap/connect-mailbox.ts +8 -4
  236. package/packages/bundled-features/src/inbound-provider-imap/connect-my-mailbox.ts +23 -6
  237. package/packages/bundled-features/src/inbound-provider-imap/connect-target-rate-limit.ts +46 -0
  238. package/packages/bundled-features/src/inbound-provider-imap/download-batch.ts +47 -10
  239. package/packages/bundled-features/src/inbound-provider-imap/feature.ts +7 -4
  240. package/packages/bundled-features/src/inbound-provider-imap/fetch-content.ts +43 -29
  241. package/packages/bundled-features/src/inbound-provider-imap/i18n.ts +2 -2
  242. package/packages/bundled-features/src/inbound-provider-imap/parse-message.ts +14 -0
  243. package/packages/bundled-features/src/inbound-provider-imap/reconnect-mailbox.ts +5 -4
  244. package/packages/bundled-features/src/inbound-provider-imap/send-mail.ts +39 -7
  245. package/packages/bundled-features/src/inbound-provider-imap/smtp-client.ts +19 -4
  246. package/packages/bundled-features/src/inbound-provider-imap/watch-mailbox.ts +8 -23
  247. package/packages/bundled-features/src/inbound-provider-inmemory/feature.ts +1 -1
  248. package/packages/bundled-features/src/jobs/events.ts +10 -0
  249. package/packages/bundled-features/src/jobs/feature.ts +2 -0
  250. package/packages/bundled-features/src/jobs/handlers/consumer.write.ts +41 -16
  251. package/packages/bundled-features/src/jobs/web/constants.ts +4 -0
  252. package/packages/bundled-features/src/mail-foundation/changes.json +6 -0
  253. package/packages/bundled-features/src/mail-transport-inmemory/feature.ts +1 -1
  254. package/packages/bundled-features/src/mail-transport-smtp/feature.ts +3 -2
  255. package/packages/bundled-features/src/managed-pages/changes.json +12 -0
  256. package/packages/bundled-features/src/managed-pages/handlers/branding.query.ts +1 -1
  257. package/packages/bundled-features/src/managed-pages/handlers/by-slug.query.ts +1 -1
  258. package/packages/bundled-features/src/managed-pages/handlers/by-tenant-published.query.ts +1 -1
  259. package/packages/bundled-features/src/managed-pages/render-page-body.ts +18 -10
  260. package/packages/bundled-features/src/managed-pages/screens/page-screens.ts +18 -38
  261. package/packages/bundled-features/src/managed-pages/table.ts +1 -0
  262. package/packages/bundled-features/src/managed-pages/web/client-plugin.tsx +8 -6
  263. package/packages/bundled-features/src/managed-pages/web/constants.ts +8 -1
  264. package/packages/bundled-features/src/managed-pages/web/i18n.ts +11 -3
  265. package/packages/bundled-features/src/managed-pages/web/markdown-to-document.ts +1 -1
  266. package/packages/bundled-features/src/managed-pages/web/page-edit-draft.ts +108 -0
  267. package/packages/bundled-features/src/managed-pages/web/page-edit-screen.tsx +198 -0
  268. package/packages/bundled-features/src/managed-pages/web/page-settings-rail.tsx +117 -0
  269. package/packages/bundled-features/src/notes-history-user-data/index.ts +8 -14
  270. package/packages/bundled-features/src/personal-access-tokens/boot-rules.ts +5 -0
  271. package/packages/bundled-features/src/personal-access-tokens/handlers/create.write.ts +0 -1
  272. package/packages/bundled-features/src/personal-access-tokens/scope-events-check.ts +31 -5
  273. package/packages/bundled-features/src/presence/changes.json +6 -0
  274. package/packages/bundled-features/src/presence/handlers/list.query.ts +28 -11
  275. package/packages/bundled-features/src/presence/room.ts +21 -7
  276. package/packages/bundled-features/src/presence/store.ts +79 -21
  277. package/packages/bundled-features/src/readiness/changes.json +25 -0
  278. package/packages/bundled-features/src/readiness/handlers/latest-summary.query.ts +11 -6
  279. package/packages/bundled-features/src/readiness/handlers/run-probes.write.ts +35 -5
  280. package/packages/bundled-features/src/readiness/handlers/run-tone.ts +3 -2
  281. package/packages/bundled-features/src/readiness/handlers/status.query.ts +15 -1
  282. package/packages/bundled-features/src/readiness/probe-context.ts +11 -10
  283. package/packages/bundled-features/src/readiness/screens.ts +4 -4
  284. package/packages/bundled-features/src/readiness/visible-results.ts +5 -3
  285. package/packages/bundled-features/src/renderer-foundation/api.ts +6 -13
  286. package/packages/bundled-features/src/renderer-foundation/types.ts +2 -2
  287. package/packages/bundled-features/src/secrets/changes.json +7 -0
  288. package/packages/bundled-features/src/secrets/db/queries/read.ts +18 -4
  289. package/packages/bundled-features/src/secrets/handlers/list.query.ts +8 -2
  290. package/packages/bundled-features/src/secrets/secret-scope.ts +2 -3
  291. package/packages/bundled-features/src/secrets/secrets-context.ts +6 -4
  292. package/packages/bundled-features/src/secrets/write-gate.ts +4 -2
  293. package/packages/bundled-features/src/seo/handlers/seo-config.query.ts +1 -1
  294. package/packages/bundled-features/src/shared/acknowledged-system-db.ts +20 -0
  295. package/packages/bundled-features/src/shared/assert-billing-live.ts +9 -2
  296. package/packages/bundled-features/src/shared/changes.json +6 -0
  297. package/packages/bundled-features/src/shared/index.ts +6 -1
  298. package/packages/bundled-features/src/shared/parent-visibility.ts +25 -1
  299. package/packages/bundled-features/src/shared/password-hashing.ts +0 -1
  300. package/packages/bundled-features/src/shared/price-env-shape.ts +1 -4
  301. package/packages/bundled-features/src/shared/register-user-data-hooks.ts +29 -0
  302. package/packages/bundled-features/src/shared/require-bootstrap-extension.ts +26 -0
  303. package/packages/bundled-features/src/shared/send-best-effort.ts +19 -0
  304. package/packages/bundled-features/src/shared/stream-tenant-backfill.ts +22 -1
  305. package/packages/bundled-features/src/shared/stream-tenant-derived-state.ts +31 -1
  306. package/packages/bundled-features/src/step-dispatcher/changes.json +12 -0
  307. package/packages/bundled-features/src/step-dispatcher/constants.ts +13 -0
  308. package/packages/bundled-features/src/step-dispatcher/deliver-dispatch-request.ts +47 -2
  309. package/packages/bundled-features/src/step-dispatcher/feature.ts +28 -1
  310. package/packages/bundled-features/src/step-dispatcher/mail-runner.ts +0 -1
  311. package/packages/bundled-features/src/step-dispatcher/sweep-abandoned.ts +57 -0
  312. package/packages/bundled-features/src/subscription-mollie/changes.json +7 -0
  313. package/packages/bundled-features/src/subscription-mollie/plugin-methods.ts +5 -3
  314. package/packages/bundled-features/src/subscription-mollie/verify-webhook.ts +5 -5
  315. package/packages/bundled-features/src/subscription-paddle/backfill-checkout-ledger.ts +159 -0
  316. package/packages/bundled-features/src/subscription-paddle/changes.json +13 -0
  317. package/packages/bundled-features/src/subscription-paddle/checkout-config.query.ts +1 -1
  318. package/packages/bundled-features/src/subscription-paddle/checkout-methods.ts +2 -8
  319. package/packages/bundled-features/src/subscription-paddle/constants.ts +1 -2
  320. package/packages/bundled-features/src/subscription-paddle/feature.ts +26 -24
  321. package/packages/bundled-features/src/subscription-paddle/ledger-backfill-marker.ts +70 -0
  322. package/packages/bundled-features/src/subscription-paddle/plan-switch-methods.ts +2 -8
  323. package/packages/bundled-features/src/subscription-paddle/redeliver-legacy-checkout.ts +36 -0
  324. package/packages/bundled-features/src/subscription-paddle/runtime.ts +13 -24
  325. package/packages/bundled-features/src/subscription-paddle/subscription-state.ts +1 -0
  326. package/packages/bundled-features/src/subscription-paddle/webhook-events.ts +68 -21
  327. package/packages/bundled-features/src/subscription-stripe/changes.json +7 -0
  328. package/packages/bundled-features/src/subscription-stripe/feature.ts +5 -0
  329. package/packages/bundled-features/src/subscription-stripe/plugin-methods.ts +6 -6
  330. package/packages/bundled-features/src/subscription-stripe/runtime.ts +8 -7
  331. package/packages/bundled-features/src/subscription-stripe/verify-webhook.ts +24 -6
  332. package/packages/bundled-features/src/tags/aggregate-id.ts +0 -1
  333. package/packages/bundled-features/src/tags/web/tag-chip.tsx +4 -5
  334. package/packages/bundled-features/src/tags/web/tag-manager.tsx +2 -1
  335. package/packages/bundled-features/src/template-resolver/api.ts +6 -13
  336. package/packages/bundled-features/src/template-resolver/changes.json +36 -0
  337. package/packages/bundled-features/src/template-resolver/document-sanitizer.ts +25 -0
  338. package/packages/bundled-features/src/template-resolver/feature.ts +2 -0
  339. package/packages/bundled-features/src/template-resolver/handlers/body-preview.query.ts +41 -0
  340. package/packages/bundled-features/src/template-resolver/handlers/by-slug.query.ts +1 -1
  341. package/packages/bundled-features/src/template-resolver/handlers/by-tenant.query.ts +1 -1
  342. package/packages/bundled-features/src/template-resolver/handlers/collection-shared.ts +5 -11
  343. package/packages/bundled-features/src/template-resolver/handlers/overview.query.ts +3 -2
  344. package/packages/bundled-features/src/template-resolver/handlers/send-test.write.ts +37 -8
  345. package/packages/bundled-features/src/template-resolver/linked-resources.ts +2 -5
  346. package/packages/bundled-features/src/template-resolver/seeding.ts +77 -0
  347. package/packages/bundled-features/src/template-resolver/table.ts +1 -0
  348. package/packages/bundled-features/src/template-resolver/template-draft.ts +2 -1
  349. package/packages/bundled-features/src/template-resolver/template-preview.ts +14 -3
  350. package/packages/bundled-features/src/template-resolver/testing.ts +0 -2
  351. package/packages/bundled-features/src/template-resolver/web/client-plugin.tsx +3 -0
  352. package/packages/bundled-features/src/template-resolver/web/collection-entry-create-form.tsx +33 -33
  353. package/packages/bundled-features/src/template-resolver/web/constants.ts +7 -0
  354. package/packages/bundled-features/src/template-resolver/web/content-tree-provider.ts +0 -1
  355. package/packages/bundled-features/src/template-resolver/web/content-workbench.tsx +142 -0
  356. package/packages/bundled-features/src/template-resolver/web/document-insert-model.ts +3 -8
  357. package/packages/bundled-features/src/template-resolver/web/document-link-policy.ts +58 -0
  358. package/packages/bundled-features/src/template-resolver/web/document-schema.ts +11 -57
  359. package/packages/bundled-features/src/template-resolver/web/document-tiptap-bubble.tsx +2 -4
  360. package/packages/bundled-features/src/template-resolver/web/document-tiptap-context.ts +4 -5
  361. package/packages/bundled-features/src/template-resolver/web/document-tiptap-editor.tsx +2 -2
  362. package/packages/bundled-features/src/template-resolver/web/document-tiptap-helpers.ts +6 -3
  363. package/packages/bundled-features/src/template-resolver/web/document-tiptap-toolbar-groups.tsx +2 -3
  364. package/packages/bundled-features/src/template-resolver/web/editor-handle.ts +1 -0
  365. package/packages/bundled-features/src/template-resolver/web/fill-document-variables.ts +24 -0
  366. package/packages/bundled-features/src/template-resolver/web/i18n.ts +14 -0
  367. package/packages/bundled-features/src/template-resolver/web/index.ts +3 -0
  368. package/packages/bundled-features/src/template-resolver/web/preview-targets.ts +25 -0
  369. package/packages/bundled-features/src/template-resolver/web/qualified-names.ts +1 -0
  370. package/packages/bundled-features/src/template-resolver/web/snippet-preview-renderer.tsx +24 -0
  371. package/packages/bundled-features/src/template-resolver/web/string-values.ts +7 -0
  372. package/packages/bundled-features/src/template-resolver/web/text-block-editor.tsx +38 -50
  373. package/packages/bundled-features/src/template-resolver/web/use-collection-entry-create.ts +7 -0
  374. package/packages/bundled-features/src/template-resolver/web/use-content-write.ts +1 -3
  375. package/packages/bundled-features/src/template-resolver/web/use-document-tiptap-model.ts +1 -2
  376. package/packages/bundled-features/src/template-resolver/web/use-text-block-editor.ts +28 -7
  377. package/packages/bundled-features/src/template-resolver/web/web-preview-renderer.tsx +126 -0
  378. package/packages/bundled-features/src/template-resolver-user-data/index.ts +11 -10
  379. package/packages/bundled-features/src/tenant/changes.json +6 -0
  380. package/packages/bundled-features/src/tenant/handlers/create.write.ts +7 -8
  381. package/packages/bundled-features/src/tenant/handlers/list.query.ts +7 -9
  382. package/packages/bundled-features/src/tenant/handlers/member-directory.query.ts +10 -4
  383. package/packages/bundled-features/src/tenant/handlers/toggle-enabled.write.ts +1 -1
  384. package/packages/bundled-features/src/tenant/invited-membership.ts +10 -1
  385. package/packages/bundled-features/src/tenant/seeding.ts +4 -2
  386. package/packages/bundled-features/src/tenant/stream-tenant-backfill.ts +5 -1
  387. package/packages/bundled-features/src/tenant/testing.ts +1 -1
  388. package/packages/bundled-features/src/tenant-inactivity/check-inactive-tenants.ts +4 -3
  389. package/packages/bundled-features/src/tenant-inactivity/constants.ts +1 -2
  390. package/packages/bundled-features/src/tenant-inactivity/handlers/keep-account.write.ts +1 -2
  391. package/packages/bundled-features/src/tenant-inactivity/state-store.ts +10 -1
  392. package/packages/bundled-features/src/tenant-lifecycle/changes.json +18 -0
  393. package/packages/bundled-features/src/tenant-lifecycle/constants.ts +4 -0
  394. package/packages/bundled-features/src/tenant-lifecycle/run-tenant-destroy.ts +43 -6
  395. package/packages/bundled-features/src/tenant-lifecycle/stages.ts +15 -2
  396. package/packages/bundled-features/src/tier-engine/aggregate-id.ts +0 -1
  397. package/packages/bundled-features/src/tier-engine/changes.json +6 -0
  398. package/packages/bundled-features/src/tier-engine/feature.ts +8 -2
  399. package/packages/bundled-features/src/user/changes.json +6 -0
  400. package/packages/bundled-features/src/user/db/queries/stream-tenant-backfill.ts +2 -1
  401. package/packages/bundled-features/src/user/handlers/me.query.ts +3 -1
  402. package/packages/bundled-features/src/user/index.ts +1 -0
  403. package/packages/bundled-features/src/user/resolve-verified-user-email.ts +17 -0
  404. package/packages/bundled-features/src/user-data-rights/db/queries/export-jobs.ts +0 -1
  405. package/packages/bundled-features/src/user-data-rights/handlers/confirm-deletion-by-token.write.ts +1 -1
  406. package/packages/bundled-features/src/user-data-rights/handlers/download-by-token.query.ts +1 -1
  407. package/packages/bundled-features/src/user-data-rights/handlers/request-deletion-by-email.write.ts +1 -1
  408. package/packages/bundled-features/src/user-data-rights/run-export-jobs.ts +0 -2
  409. package/packages/bundled-features/src/user-data-rights/run-forget-cleanup.ts +3 -3
  410. package/packages/bundled-features/src/user-data-rights/schema/download-attempt.ts +3 -2
  411. package/packages/bundled-features/src/user-data-rights/web/confirm-deletion-screen.tsx +1 -1
  412. package/packages/bundled-features/src/user-data-rights/web/privacy-center-screen.tsx +1 -1
  413. package/packages/bundled-features/src/user-data-rights/web/request-deletion-screen.tsx +1 -1
  414. package/packages/bundled-features/src/user-data-rights-defaults/hooks/api-token.userdata-hook.ts +5 -5
  415. package/packages/bundled-features/src/user-data-rights-defaults/hooks/hard-delete-own-rows-hook.ts +17 -0
  416. package/packages/bundled-features/src/user-data-rights-defaults/hooks/in-app-message.userdata-hook.ts +5 -5
  417. package/packages/bundled-features/src/user-data-rights-defaults/hooks/job-run.userdata-hook.ts +2 -1
  418. package/packages/bundled-features/src/user-data-rights-defaults/hooks/user-session.userdata-hook.ts +5 -5
  419. package/packages/bundled-features/src/user-profile/handlers/change-email.write.ts +0 -1
  420. package/packages/bundled-features/src/waitlist/changes.json +6 -0
  421. package/packages/bundled-features/src/waitlist/handlers/submit.write.ts +4 -28
  422. package/packages/bundled-features/src/waitlist/lib.ts +2 -7
  423. package/packages/bundled-features/src/waitlist/user-data-hooks.ts +6 -19
  424. package/packages/bundled-features/src/workflow-runner/aggregate-id.ts +0 -1
  425. package/packages/bundled-features/src/workflow-runner/event-trigger.ts +6 -2
  426. package/packages/bundled-features/src/workflow-runner/feature.ts +1 -5
  427. package/packages/bundled-features/src/workflow-runner/handlers/resume-run.write.ts +5 -4
  428. package/packages/bundled-features/src/workflow-runner/runner.ts +2 -0
  429. package/samples/apps/showcase/src/features/demos/web/pages/dialog.tsx +0 -1
  430. package/samples/apps/showcase/src/features/demos/web/pages/layout.tsx +1 -1
  431. package/samples/apps/showcase/src/features/demos/web/pages/sidebar-panel.tsx +0 -1
  432. package/samples/apps/styleguide/src/features/gallery/web/Gallery.tsx +1 -4
  433. package/samples/apps/ui-walkthrough/src/features/subscription-plans/feature.ts +6 -2
  434. package/samples/apps/use-all-bundled/e2e-billing-gallery/gallery-features.ts +12 -14
  435. package/samples/apps/use-all-bundled/feature-manifest.json +60 -29
  436. package/samples/apps/use-all-bundled/playwright.billing-docs.config.ts +1 -1
  437. package/samples/apps/use-all-bundled/playwright.config.ts +1 -0
  438. package/samples/apps/use-all-bundled/src/app/seed.ts +1 -1
  439. package/samples/apps/use-all-bundled/src/run-config.ts +2 -1
  440. package/samples/recipes/auth-mfa/src/web/confirmation-code-step.tsx +32 -10
  441. package/samples/recipes/chat-channels/README.md +2 -0
  442. package/samples/recipes/currencies-global/src/entities/currency.ts +1 -0
  443. package/samples/recipes/helpdesk/README.md +9 -5
  444. package/samples/recipes/helpdesk/src/feature.ts +6 -3
  445. package/samples/recipes/managed-pages/README.md +5 -1
  446. package/samples/recipes/managed-pages/package.json +3 -2
  447. package/samples/recipes/managed-pages/src/web/branded-preview.tsx +21 -0
  448. package/samples/recipes/managed-pages/tsconfig.json +8 -0
  449. package/samples/recipes/pwa-shell/README.md +52 -0
  450. package/samples/recipes/pwa-shell/bin/server.ts +12 -0
  451. package/samples/recipes/pwa-shell/package.json +13 -0
  452. package/samples/recipes/pwa-shell/src/app.ts +34 -0
  453. package/samples/recipes/rate-limiting/README.md +3 -3
  454. package/samples/recipes/record-detail-layout/README.md +33 -0
  455. package/samples/recipes/record-detail-layout/src/feature.ts +525 -44
  456. package/samples/recipes/record-detail-layout/src/order-board.ts +521 -0
  457. package/packages/bundled-features/src/managed-pages/web/page-body-section.tsx +0 -72
  458. package/packages/bundled-features/src/subscription-paddle/tenant-binding.ts +0 -34
  459. package/packages/bundled-features/src/template-resolver/web/content-field.tsx +0 -61
@@ -4,7 +4,7 @@
4
4
  // The pattern mirrors ai-foundation's `createLLMProviderForTenant`.
5
5
 
6
6
  import type { TenantId } from "@cosmicdrift/kumiko-framework/engine";
7
- import { InternalError } from "@cosmicdrift/kumiko-framework/errors";
7
+ import { requireBootstrapExtension } from "../shared/index.ts";
8
8
  import { DEFAULT_PLUGIN_BY_KIND, type RenderKind } from "./constants.ts";
9
9
  import { RendererError, type RendererPlugin } from "./types.ts";
10
10
 
@@ -90,16 +90,9 @@ export function requireRendererFoundation(
90
90
  ctx: { readonly services: { readonly extensions: Readonly<Record<string, unknown>> } },
91
91
  callerName: string,
92
92
  ): RendererFoundationApi {
93
- // @cast-boundary engine-bridge — rendererFoundation kommt per extraContext
94
- // from the app bootstrap and lands in services.extensions; the framework does not know its type.
95
- const api = ctx.services.extensions["rendererFoundation"] as RendererFoundationApi | undefined;
96
- if (!api) {
97
- throw new InternalError({
98
- message:
99
- `[${callerName}] ctx.rendererFoundation missing — App-Bootstrap muss ` +
100
- `extraContext: { rendererFoundation: createRendererFoundationApi(plugins) } setzen ` +
101
- `(siehe renderer-foundation/README.md).`,
102
- });
103
- }
104
- return api;
93
+ return requireBootstrapExtension<RendererFoundationApi>(ctx, callerName, {
94
+ key: "rendererFoundation",
95
+ bootstrapExample: "rendererFoundation: createRendererFoundationApi(plugins)",
96
+ readme: "renderer-foundation/README.md",
97
+ });
105
98
  }
@@ -191,8 +191,8 @@ export type RendererContext = {
191
191
  export type MailChromeLink = { readonly label: string; readonly url: string };
192
192
 
193
193
  /** The tenant's mail look with every text resolved for one locale, for pages a
194
- * recipient reaches from a mail link. URLs are http(s) only, the logo https only,
195
- * the accent color a #rrggbb hex. */
194
+ * recipient reaches from a mail link. URLs are http(s) only, the logo an https URL or a
195
+ * base64 raster data URI, the accent color a #rrggbb hex. */
196
196
  export type MailChrome = {
197
197
  readonly tenantName: string;
198
198
  readonly brandSuffix: string;
@@ -1,4 +1,11 @@
1
1
  [
2
+ {
3
+ "version": "0.414.0",
4
+ "type": "breaking",
5
+ "title": "SystemAdmin checks use ROLES.SystemAdmin",
6
+ "detail": "The exported SYSTEM_ADMIN_ROLE constant of secrets is removed; SystemAdmin checks use ROLES.SystemAdmin.",
7
+ "migration": "Replace imports of SYSTEM_ADMIN_ROLE from secrets by ROLES.SystemAdmin."
8
+ },
2
9
  {
3
10
  "version": "0.409.0",
4
11
  "type": "improvement",
@@ -1,16 +1,30 @@
1
1
  import type { DbRunner } from "@cosmicdrift/kumiko-framework/db";
2
2
  import { asRawClient } from "@cosmicdrift/kumiko-framework/db";
3
- import type { TenantId } from "@cosmicdrift/kumiko-framework/engine";
3
+ import { SYSTEM_TENANT_ID, type TenantId } from "@cosmicdrift/kumiko-framework/engine";
4
+ import {
5
+ runInRowLevelSecurityScope,
6
+ tenantRowLevelSecurityScope,
7
+ } from "@cosmicdrift/kumiko-framework/internal/row-level-security";
4
8
  import type { StoredEnvelope } from "../../table.ts";
5
9
 
10
+ // Platform-wide secrets are system tenant rows, which another tenant's scope does not read. The
11
+ // read runs in the system tenant's own scope, so RLS passes only its rows and never a third tenant's.
12
+ export function readingSecretsOf<T>(tenantId: string, read: () => Promise<T>): Promise<T> {
13
+ return tenantId === SYSTEM_TENANT_ID
14
+ ? runInRowLevelSecurityScope(tenantRowLevelSecurityScope(SYSTEM_TENANT_ID), read)
15
+ : read();
16
+ }
17
+
6
18
  export async function selectTenantSecretEnvelope(
7
19
  db: DbRunner,
8
20
  tenantId: TenantId,
9
21
  key: string,
10
22
  ): Promise<StoredEnvelope | undefined> {
11
- const rows = await asRawClient(db).unsafe<{ envelope: StoredEnvelope }>(
12
- `SELECT envelope FROM read_tenant_secrets WHERE tenant_id = $1 AND key = $2 LIMIT 1`,
13
- [tenantId, key],
23
+ const rows = await readingSecretsOf(tenantId, () =>
24
+ asRawClient(db).unsafe<{ envelope: StoredEnvelope }>(
25
+ `SELECT envelope FROM read_tenant_secrets WHERE tenant_id = $1 AND key = $2 LIMIT 1`,
26
+ [tenantId, key],
27
+ ),
14
28
  );
15
29
  return rows[0]?.envelope;
16
30
  }
@@ -1,4 +1,9 @@
1
- import { type AccessRule, defineQueryHandler } from "@cosmicdrift/kumiko-framework/engine";
1
+ import {
2
+ type AccessRule,
3
+ defineQueryHandler,
4
+ SYSTEM_TENANT_ID,
5
+ } from "@cosmicdrift/kumiko-framework/engine";
6
+ import { systemTenantReadDb } from "@cosmicdrift/kumiko-framework/internal/row-level-security";
2
7
  import * as z from "zod";
3
8
  import { resolveSecretTarget, secretScopeSchema } from "../secret-scope.ts";
4
9
  import { tenantSecretsTable } from "../table.ts";
@@ -17,7 +22,8 @@ export function createListHandler(access: AccessRule = DEFAULT_SECRETS_ACCESS) {
17
22
  handler: async (event, ctx) => {
18
23
  const target = resolveSecretTarget(event.user, event.payload.scope);
19
24
  if (!target.ok) throw target.error;
20
- const rows = await ctx.db.selectMany<{
25
+ const readDb = target.tenantId === SYSTEM_TENANT_ID ? systemTenantReadDb(ctx.db) : ctx.db;
26
+ const rows = await readDb.selectMany<{
21
27
  key: string;
22
28
  kekVersion: number;
23
29
  metadata: { redactedPreview?: string; hint?: string };
@@ -1,3 +1,4 @@
1
+ import { ROLES } from "@cosmicdrift/kumiko-framework/auth";
1
2
  import {
2
3
  type SessionUser,
3
4
  SYSTEM_TENANT_ID,
@@ -6,8 +7,6 @@ import {
6
7
  import { AccessDeniedError } from "@cosmicdrift/kumiko-framework/errors";
7
8
  import * as z from "zod";
8
9
 
9
- export const SYSTEM_ADMIN_ROLE = "SystemAdmin";
10
-
11
10
  // "system" targets the platform-wide secrets under SYSTEM_TENANT_ID (settings a SystemAdmin
12
11
  // edits for the whole app). The target is never taken from the payload, only chosen here.
13
12
  export const secretScopeSchema = z.enum(["tenant", "system"]).optional();
@@ -23,7 +22,7 @@ export function resolveSecretTarget(
23
22
  scope: SecretScope,
24
23
  ): SecretTarget {
25
24
  if (scope !== "system") return { ok: true, tenantId: user.tenantId };
26
- if (!user.roles.includes(SYSTEM_ADMIN_ROLE)) {
25
+ if (!user.roles.includes(ROLES.SystemAdmin)) {
27
26
  return {
28
27
  ok: false,
29
28
  error: new AccessDeniedError({ message: "system-scope secrets need the SystemAdmin role" }),
@@ -37,7 +37,7 @@ import {
37
37
  } from "@cosmicdrift/kumiko-framework/secrets";
38
38
  import { generateId } from "@cosmicdrift/kumiko-framework/utils";
39
39
  import * as z from "zod";
40
- import { selectTenantSecretEnvelope } from "./db/queries/read.ts";
40
+ import { readingSecretsOf, selectTenantSecretEnvelope } from "./db/queries/read.ts";
41
41
  import {
42
42
  type StoredEnvelope,
43
43
  type StoredMetadata,
@@ -115,7 +115,9 @@ function buildSecretsContext(
115
115
  };
116
116
 
117
117
  async function lookup(tenantId: string, key: string): Promise<SecretLookupRow | undefined> {
118
- return fetchOne<SecretLookupRow>(db, tenantSecretsTable, { tenantId, key });
118
+ return readingSecretsOf(tenantId, () =>
119
+ fetchOne<SecretLookupRow>(db, tenantSecretsTable, { tenantId, key }),
120
+ );
119
121
  }
120
122
 
121
123
  return {
@@ -210,7 +212,7 @@ function buildSecretsContext(
210
212
  db,
211
213
  tenantId,
212
214
  mode: "system",
213
- reason: "secrets API writes for a caller-named tenant, outside a request scope",
215
+ reason: "secrets API writes the row of a caller-named tenant",
214
216
  });
215
217
 
216
218
  const existing = await lookup(tenantId, key);
@@ -280,7 +282,7 @@ function buildSecretsContext(
280
282
  db,
281
283
  tenantId,
282
284
  mode: "system",
283
- reason: "secrets API writes for a caller-named tenant, outside a request scope",
285
+ reason: "secrets API writes the row of a caller-named tenant",
284
286
  });
285
287
  const result = await executor.delete({ id: existing.id }, actor, tdb);
286
288
  return result.isSuccess;
@@ -1,3 +1,4 @@
1
+ import { ROLES } from "@cosmicdrift/kumiko-framework/auth";
1
2
  import type {
2
3
  Registry,
3
4
  SecretKeyDefinition,
@@ -45,7 +46,7 @@ function namespaceAcceptsKey(namespace: SecretNamespaceDefinition, key: string):
45
46
  // further for a key or a whole namespace. Delete passes allowUndeclared: it
46
47
  // creates nothing, and legacy rows under since-undeclared keys must stay removable,
47
48
  // unless the key sits under a mounted feature's prefix: those rows belong to the
48
- // feature and must not be removable by a tenant admin outside its writeRoles.
49
+ // feature, so only a SystemAdmin may remove them (e.g. after the feature dropped the key).
49
50
  export function checkSecretKeyWrite(
50
51
  registry: Registry,
51
52
  userRoles: readonly string[],
@@ -57,7 +58,8 @@ export function checkSecretKeyWrite(
57
58
  if (
58
59
  !keyDef &&
59
60
  !(namespace && namespaceAcceptsKey(namespace, key)) &&
60
- (options.allowUndeclared !== true || isUnderMountedFeaturePrefix(registry, key))
61
+ (options.allowUndeclared !== true ||
62
+ (isUnderMountedFeaturePrefix(registry, key) && !userRoles.includes(ROLES.SystemAdmin)))
61
63
  ) {
62
64
  return unknownKeyFailure(key);
63
65
  }
@@ -17,7 +17,7 @@ import { SEO_CONFIG_QN } from "../constants.ts";
17
17
  export const seoConfigQuery = defineQueryHandler({
18
18
  name: "config",
19
19
  schema: z.object({}),
20
- access: { roles: ["anonymous", "User", "TenantAdmin", "SystemAdmin"], anySignedIn: true },
20
+ access: { roles: ["anonymous"], anySignedIn: true },
21
21
  rateLimit: { per: "ip+handler", limit: 60, windowSeconds: 60 },
22
22
  description:
23
23
  "Reads the tenant's SEO metadata settings — organization name and logo URL, Twitter site handle, LLMs summary and default OG image — as plain strings; use it to inspect what the sitemap, llms.txt and page meta tags will publish.",
@@ -0,0 +1,20 @@
1
+ import type { TenantDb } from "@cosmicdrift/kumiko-framework/db";
2
+ import type { AppContext } from "@cosmicdrift/kumiko-framework/engine";
3
+ import { InternalError } from "@cosmicdrift/kumiko-framework/errors";
4
+
5
+ type CrossTenantReason = Parameters<
6
+ NonNullable<AppContext["systemDb"]>["acknowledgeCrossTenant"]
7
+ >[0];
8
+
9
+ export function acknowledgedSystemDb(
10
+ ctx: Pick<AppContext, "systemDb">,
11
+ featureName: string,
12
+ crossTenantReason: CrossTenantReason,
13
+ ): TenantDb {
14
+ if (!ctx.systemDb) {
15
+ throw new InternalError({
16
+ message: `${featureName} requires ctx.systemDb — is r.systemScope() set on the feature?`,
17
+ });
18
+ }
19
+ return ctx.systemDb.acknowledgeCrossTenant(crossTenantReason);
20
+ }
@@ -1,14 +1,21 @@
1
1
  import type { ConfigKeyHandle, HandlerContext } from "@cosmicdrift/kumiko-framework/engine";
2
2
  import { FeatureDisabledError } from "@cosmicdrift/kumiko-framework/errors";
3
3
 
4
+ export async function isBillingLive(
5
+ ctx: HandlerContext,
6
+ billingLiveHandle: ConfigKeyHandle<"boolean">,
7
+ ): Promise<boolean> {
8
+ const live = ctx.config ? await ctx.config(billingLiveHandle) : undefined;
9
+ return live === true;
10
+ }
11
+
4
12
  export async function assertBillingLive(
5
13
  ctx: HandlerContext,
6
14
  billingLiveHandle: ConfigKeyHandle<"boolean">,
7
15
  featureName: string,
8
16
  handlerName: string,
9
17
  ): Promise<void> {
10
- const live = ctx.config ? await ctx.config(billingLiveHandle) : undefined;
11
- if (live !== true) {
18
+ if (!(await isBillingLive(ctx, billingLiveHandle))) {
12
19
  throw new FeatureDisabledError(featureName, handlerName);
13
20
  }
14
21
  }
@@ -1,4 +1,10 @@
1
1
  [
2
+ {
3
+ "version": "0.414.0",
4
+ "type": "fix",
5
+ "title": "Stream-tenant backfill reindexes the old search bucket",
6
+ "detail": "The stream-tenant backfill reindexes the old search bucket when a candidate fails after its docs were removed (createSearchBucketCleanup takes a row source and exposes onMoveFailed). A failed candidate reindexes only its own document in the old bucket, not the whole bucket."
7
+ },
2
8
  {
3
9
  "version": "0.405.0",
4
10
  "type": "improvement",
@@ -1,4 +1,5 @@
1
- export { assertBillingLive } from "./assert-billing-live.ts";
1
+ export { acknowledgedSystemDb } from "./acknowledged-system-db.ts";
2
+ export { assertBillingLive, isBillingLive } from "./assert-billing-live.ts";
2
3
  export { collectErasureFailure, throwIfErasureFailed } from "./assert-erased.ts";
3
4
  export { assertNoWhereRuleInOwnershipWrite } from "./assert-no-where-rule-in-ownership-write.ts";
4
5
  export {
@@ -40,6 +41,7 @@ export {
40
41
  hostRowIsGone,
41
42
  joinRowParentIsVisible,
42
43
  parentRowIsVisible,
44
+ visibleParentRowIds,
43
45
  } from "./parent-visibility.ts";
44
46
  export { hashPassword, verifyDummyPassword, verifyPassword } from "./password-hashing.ts";
45
47
  export {
@@ -72,6 +74,8 @@ export {
72
74
  redactUrls,
73
75
  } from "./redact.ts";
74
76
  export { REDACTED_PII_PLACEHOLDER, redactPiiCiphertext } from "./redact-pii-ciphertext.ts";
77
+ export { registerUserDataHooks } from "./register-user-data-hooks.ts";
78
+ export { requireBootstrapExtension } from "./require-bootstrap-extension.ts";
75
79
  export { requireForTenant } from "./require-for-tenant.ts";
76
80
  export { resolveFeatureAccess } from "./resolve-feature-access.ts";
77
81
  export {
@@ -88,6 +92,7 @@ export {
88
92
  signRowBoundGrant,
89
93
  } from "./row-bound-grant.ts";
90
94
  export { runInSubTransaction } from "./run-in-sub-transaction.ts";
95
+ export { sendBestEffort } from "./send-best-effort.ts";
91
96
  export { registrationLocaleFromRequest, sessionLocaleField } from "./session-locale-field.ts";
92
97
  export { sessionTimezoneField } from "./session-timezone-field.ts";
93
98
  export { assertNotSvg, MAX_INPUT_PIXELS, SHARP_INPUT_OPTIONS } from "./sharp-input-limits.ts";
@@ -56,13 +56,37 @@ export async function parentRowIsVisible(
56
56
  // the executor.
57
57
  if (!idShapeMatchesEntity(entity, entityId)) return false;
58
58
 
59
+ return (await executorFor(entityType, entity).detail({ id: entityId }, user, db)) !== null;
60
+ }
61
+
62
+ function executorFor(entityType: string, entity: EntityDefinition): EventStoreExecutor {
59
63
  let executor = executorsByEntity.get(entity);
60
64
  if (!executor) {
61
65
  executor = createEntityExecutor(entityType, entity).executor;
62
66
  executorsByEntity.set(entity, executor);
63
67
  }
68
+ return executor;
69
+ }
64
70
 
65
- return (await executor.detail({ id: entityId }, user, db)) !== null;
71
+ // Batch form of parentRowIsVisible: one list query for all ids instead of one detail lookup each.
72
+ // Same gates and the same default-deny; the caller keeps ids it was given that are not returned out.
73
+ export async function visibleParentRowIds(
74
+ registry: Registry,
75
+ entityType: string,
76
+ entityIds: readonly string[],
77
+ user: SessionUser,
78
+ db: TenantDb,
79
+ ): Promise<ReadonlySet<string>> {
80
+ const entity = registry.getEntity(entityType);
81
+ if (!entity || entity.parentRef !== undefined) return new Set();
82
+ const wellFormed = entityIds.filter((entityId) => idShapeMatchesEntity(entity, entityId));
83
+ if (wellFormed.length === 0) return new Set();
84
+ const page = await executorFor(entityType, entity).list(
85
+ { filters: [{ field: "id", op: "in", value: wellFormed }], limit: wellFormed.length },
86
+ user,
87
+ db,
88
+ );
89
+ return new Set(page.rows.map((row) => String(row["id"])));
66
90
  }
67
91
 
68
92
  const hostTablesByEntity = new WeakMap<EntityDefinition, ReturnType<typeof buildEntityTable>>();
@@ -17,7 +17,6 @@ const HASH_OPTIONS = {
17
17
  parallelism: 1,
18
18
  } as const;
19
19
 
20
- // @wrapper-known semantic-alias
21
20
  export async function hashPassword(password: string): Promise<string> {
22
21
  return argonHash(password, HASH_OPTIONS);
23
22
  }
@@ -20,10 +20,7 @@ export function priceEnvShape<const TEnvPrefix extends string, const TPrice exte
20
20
  `${envPrefix}_PRICE_${price}`,
21
21
  z
22
22
  .string()
23
- .regex(
24
- new RegExp(`^${priceIdPrefix}`),
25
- `${envPrefix}_PRICE_${price} must start with '${priceIdPrefix}'`,
26
- )
23
+ .startsWith(priceIdPrefix, `${envPrefix}_PRICE_${price} must start with '${priceIdPrefix}'`)
27
24
  .optional()
28
25
  .describe(`${label} price id (\`${priceIdPrefix}...\`) of the ${price} plan.`),
29
26
  ]),
@@ -0,0 +1,29 @@
1
+ import {
2
+ EXT_USER_DATA,
3
+ type FeatureRegistrar,
4
+ type UserDataDeleteHook,
5
+ type UserDataExportHook,
6
+ } from "@cosmicdrift/kumiko-framework/engine";
7
+
8
+ type UserDataEntityHooks = {
9
+ readonly entity: string;
10
+ readonly export: UserDataExportHook;
11
+ readonly delete: UserDataDeleteHook;
12
+ };
13
+
14
+ // The source feature is optionalRequires, not requires: a source mounted toggleable(default=false)
15
+ // would otherwise trip the "effectively disabled" boot warning although its entities exist and the
16
+ // hooks work. defineFeature itself stays literal in each feature so the AST doc generator sees it.
17
+ export function registerUserDataHooks(
18
+ r: FeatureRegistrar,
19
+ config: {
20
+ readonly sourceFeature: string;
21
+ readonly entities: readonly UserDataEntityHooks[];
22
+ },
23
+ ): void {
24
+ r.requires({ features: ["user-data-rights"] });
25
+ r.optionalRequires(config.sourceFeature);
26
+ config.entities.forEach(({ entity, export: exportHook, delete: deleteHook }) => {
27
+ r.useExtension(EXT_USER_DATA, entity, { export: exportHook, delete: deleteHook });
28
+ });
29
+ }
@@ -0,0 +1,26 @@
1
+ import { InternalError } from "@cosmicdrift/kumiko-framework/errors";
2
+
3
+ // Handlers that need a feature API wired through the app bootstrap's `extraContext` read it from
4
+ // `services.extensions`; the missing case is a bootstrap mistake and gets one consistent message.
5
+ export function requireBootstrapExtension<TApi>(
6
+ ctx: { readonly services: { readonly extensions: Readonly<Record<string, unknown>> } },
7
+ callerName: string,
8
+ extension: {
9
+ readonly key: string;
10
+ readonly bootstrapExample: string;
11
+ readonly readme: string;
12
+ },
13
+ ): TApi {
14
+ // @cast-boundary engine-bridge — the extension arrives per extraContext from the app bootstrap
15
+ // and lands in services.extensions; the framework does not know its type.
16
+ const api = ctx.services.extensions[extension.key] as TApi | undefined;
17
+ if (!api) {
18
+ throw new InternalError({
19
+ message:
20
+ `[${callerName}] ctx.${extension.key} missing — App-Bootstrap muss ` +
21
+ `extraContext: { ${extension.bootstrapExample} } setzen ` +
22
+ `(siehe ${extension.readme}).`,
23
+ });
24
+ }
25
+ return api;
26
+ }
@@ -0,0 +1,19 @@
1
+ import type { HandlerContext } from "@cosmicdrift/kumiko-framework/engine";
2
+ import { InternalError } from "@cosmicdrift/kumiko-framework/errors";
3
+
4
+ export async function sendBestEffort(
5
+ ctx: Pick<HandlerContext, "notify" | "obs">,
6
+ logMessage: string,
7
+ send: (notify: NonNullable<HandlerContext["notify"]>) => Promise<unknown>,
8
+ ): Promise<void> {
9
+ try {
10
+ if (!ctx.notify) {
11
+ throw new InternalError({ message: "ctx.notify unavailable — mount the delivery feature" });
12
+ }
13
+ await send(ctx.notify);
14
+ } catch (err) {
15
+ ctx.obs.log?.warn(logMessage, {
16
+ error: err instanceof Error ? err.message : String(err),
17
+ });
18
+ }
19
+ }
@@ -55,6 +55,8 @@ export type StreamBackfillOptions = {
55
55
  // Runs per candidate before its events move; a throw skips the aggregate
56
56
  // and lands in `failed` (search cleanup must not be lost by a move).
57
57
  readonly beforeMove?: (candidate: StreamBackfillCandidate) => Promise<void>;
58
+ // Runs when beforeMove or the move failed, to restore what beforeMove may have removed.
59
+ readonly onMoveFailed?: (candidate: StreamBackfillCandidate) => Promise<void>;
58
60
  // Restricts the candidate scan to events on these tenants, which lets Postgres use
59
61
  // events_tenant_type_idx instead of grouping every event of the type. Streams on a tenant
60
62
  // outside the list are not found; omit it for the full scan.
@@ -86,6 +88,7 @@ export async function backfillAggregateStreamTenants(
86
88
  const failed: StreamBackfillFailure[] = [];
87
89
 
88
90
  for (const row of rows) {
91
+ let beforeMoveStarted: StreamBackfillCandidate | undefined;
89
92
  try {
90
93
  if (!row.target_tenant_id) {
91
94
  throw new Error(`earliest event of the aggregate carries no payload.tenantId`);
@@ -95,19 +98,37 @@ export async function backfillAggregateStreamTenants(
95
98
  targetTenantId: row.target_tenant_id,
96
99
  sourceTenantIds: row.source_tenant_ids,
97
100
  };
101
+ beforeMoveStarted = candidate;
98
102
  await options.beforeMove?.(candidate);
99
103
  eventsMigrated += await migrateAggregate(db, options.aggregateType, candidate);
100
104
  aggregatesMigrated++;
101
105
  } catch (e) {
106
+ const moveError = e instanceof Error ? e.message : String(e);
102
107
  failed.push({
103
108
  aggregateId: row.aggregate_id,
104
- error: e instanceof Error ? e.message : String(e),
109
+ error: await withRestoreOutcome(options, beforeMoveStarted, moveError),
105
110
  });
106
111
  }
107
112
  }
108
113
  return { aggregatesMigrated, eventsMigrated, failed };
109
114
  }
110
115
 
116
+ // The move rolled back, so the aggregate stays where it was and must keep its pre-move derived state.
117
+ async function withRestoreOutcome(
118
+ options: StreamBackfillOptions,
119
+ candidate: StreamBackfillCandidate | undefined,
120
+ moveError: string,
121
+ ): Promise<string> {
122
+ if (candidate === undefined || options.onMoveFailed === undefined) return moveError;
123
+ try {
124
+ await options.onMoveFailed(candidate);
125
+ return moveError;
126
+ } catch (restoreError) {
127
+ const detail = restoreError instanceof Error ? restoreError.message : String(restoreError);
128
+ return `${moveError}; restoring the pre-move derived state failed: ${detail}`;
129
+ }
130
+ }
131
+
111
132
  async function readCandidateRows(
112
133
  db: DbConnection,
113
134
  options: StreamBackfillOptions,
@@ -3,7 +3,11 @@
3
3
  // in stream-tenant-backfill.ts; this part is repeatable and safe to run without moves.
4
4
 
5
5
  import type { DbConnection } from "@cosmicdrift/kumiko-framework/db";
6
- import { type Registry, SYSTEM_TENANT_ID } from "@cosmicdrift/kumiko-framework/engine";
6
+ import {
7
+ parseTenantId,
8
+ type Registry,
9
+ SYSTEM_TENANT_ID,
10
+ } from "@cosmicdrift/kumiko-framework/engine";
7
11
  import { rebuildProjection } from "@cosmicdrift/kumiko-framework/pipeline";
8
12
  import {
9
13
  isEntitySearchable,
@@ -21,13 +25,39 @@ export type DerivedStateMode = "if-moved" | "always";
21
25
  export function createSearchBucketCleanup(
22
26
  searchAdapter: SearchAdapter | undefined,
23
27
  entityType: string,
28
+ rowSource: { readonly db: DbConnection; readonly registry: Registry },
24
29
  ): {
25
30
  readonly beforeMove: (candidate: StreamBackfillCandidate) => Promise<void>;
31
+ readonly onMoveFailed: (candidate: StreamBackfillCandidate) => Promise<void>;
26
32
  readonly cleanedAggregates: () => number;
27
33
  } {
28
34
  let cleaned = 0;
29
35
  return {
30
36
  cleanedAggregates: () => cleaned,
37
+ // The rolled-back move leaves the row in its old bucket, so reindexing that row brings the doc
38
+ // back; the rest of the bucket was not touched by this candidate.
39
+ onMoveFailed: async (candidate) => {
40
+ // skip: no adapter means no search docs were removed
41
+ if (!searchAdapter || !isEntitySearchable(rowSource.registry, entityType)) return;
42
+ const oldBuckets = candidate.sourceTenantIds.filter((id) => id !== candidate.targetTenantId);
43
+ for (const bucket of oldBuckets) {
44
+ const bucketTenantId = parseTenantId(bucket);
45
+ if (bucketTenantId === null) throw new Error(`source bucket ${bucket} is not a tenant id`);
46
+ const reindex = await reindexEntity(
47
+ rowSource.db,
48
+ rowSource.registry,
49
+ searchAdapter,
50
+ entityType,
51
+ bucketTenantId,
52
+ { onlyEntityId: candidate.aggregateId },
53
+ );
54
+ if (reindex.failures.length > 0) {
55
+ throw new Error(
56
+ `reindex of ${candidate.aggregateId} in bucket ${bucket} failed for ${reindex.failures.length} rows: ${reindex.failures[0]?.reason}`,
57
+ );
58
+ }
59
+ }
60
+ },
31
61
  beforeMove: async (candidate) => {
32
62
  // skip: no adapter means no search docs to clean
33
63
  if (!searchAdapter) return;
@@ -1,4 +1,16 @@
1
1
  [
2
+ {
3
+ "version": "0.414.0",
4
+ "type": "fix",
5
+ "title": "Final step-delivery attempt erases the dispatch key",
6
+ "detail": "A final step-delivery attempt whose outcome cannot be recorded still erases the dispatch key."
7
+ },
8
+ {
9
+ "version": "0.414.0",
10
+ "type": "fix",
11
+ "title": "A sweeper closes dispatch streams that never got an outcome",
12
+ "detail": "The daily job `step-dispatcher:job:sweep-abandoned` pages through all `step-dispatch` streams older than 24 hours that have neither a dispatched nor a failed event (a lost deliver job, a worker that died after the request was written), appends `step-dispatch.failed` with the error `dispatch abandoned without a recorded outcome` and erases the stream's PII key, so the personal data of a request nobody delivers no longer stays readable forever. Streams that already have an outcome are not swept. A late deliver job for a swept stream sends nothing. The job declares an `escapeHatch` for the cross-tenant read of open streams. Framework: `selectOpenStreamsStartedBefore` (event-store) lists open streams of one aggregate type across tenants."
13
+ },
2
14
  {
3
15
  "version": "0.389.0",
4
16
  "type": "fix",
@@ -4,10 +4,12 @@ export const STEP_DISPATCHER_FEATURE = "step-dispatcher";
4
4
 
5
5
  export const StepDispatcherJobNames = {
6
6
  deliver: "deliver",
7
+ sweepAbandoned: "sweep-abandoned",
7
8
  } as const;
8
9
 
9
10
  export const StepDispatcherJobs = {
10
11
  deliver: qn(STEP_DISPATCHER_FEATURE, QnTypes.job, StepDispatcherJobNames.deliver),
12
+ sweepAbandoned: qn(STEP_DISPATCHER_FEATURE, QnTypes.job, StepDispatcherJobNames.sweepAbandoned),
11
13
  } as const;
12
14
 
13
15
  // Stable per dispatch stream: BullMQ ignores a second add() with the same id,
@@ -20,3 +22,14 @@ export function deliverJobId(aggregateId: string): string {
20
22
  // cannot occupy every worker slot.
21
23
  export const DELIVER_MAX_PER_TENANT = 2;
22
24
  export const DELIVER_RETRIES = 3;
25
+
26
+ // A deliver job spends at most DELIVER_RETRIES exponential retries (1 s base: 1 + 2 + 4 s) plus
27
+ // 100 per-tenant defers (maxDefers default, each capped at 30 s + 1 s jitter, about 52 min), so a
28
+ // live job is done long before this. Only a stalled or lost job leaves a request older than it
29
+ // without an outcome; 24 h also covers a worker lane that was down for a night.
30
+ export const ABANDON_DISPATCH_AFTER_HOURS = 24;
31
+
32
+ // Page size of the daily sweep. The open-stream query filters kumiko_events by aggregate type and
33
+ // event type without a matching index (the only index starts with tenant_id), so it is a seq
34
+ // scan: the cron runs once a day, not hourly.
35
+ export const SWEEP_ABANDONED_BATCH_SIZE = 500;