@cosmicdrift/kumiko-samples 0.406.0 → 0.410.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (257) hide show
  1. package/package.json +1 -1
  2. package/packages/bundled-features/package.json +31 -4
  3. package/packages/bundled-features/src/account-security/feature.ts +9 -1
  4. package/packages/bundled-features/src/admin-shell/changes.json +6 -0
  5. package/packages/bundled-features/src/admin-shell/feature.ts +4 -1
  6. package/packages/bundled-features/src/agent-tools/agent-manifest.ts +1 -0
  7. package/packages/bundled-features/src/agent-tools/changes.json +6 -0
  8. package/packages/bundled-features/src/agent-tools/tool-catalog.ts +1 -0
  9. package/packages/bundled-features/src/agent-tools/types.ts +4 -0
  10. package/packages/bundled-features/src/audit/event-classification.ts +1 -0
  11. package/packages/bundled-features/src/auth-email-password/bootstrap.ts +1 -0
  12. package/packages/bundled-features/src/auth-email-password/errors.ts +18 -66
  13. package/packages/bundled-features/src/auth-email-password/handlers/login-options.query.ts +1 -1
  14. package/packages/bundled-features/src/auth-email-password/handlers/self-registration-status.query.ts +1 -1
  15. package/packages/bundled-features/src/auth-email-password/web/auth-client.ts +30 -64
  16. package/packages/bundled-features/src/auth-email-password/web/auth-redirect.ts +2 -2
  17. package/packages/bundled-features/src/auth-email-password/web/confirm-account-unlock-screen.tsx +20 -66
  18. package/packages/bundled-features/src/auth-email-password/web/index.ts +1 -0
  19. package/packages/bundled-features/src/auth-email-password/web/read-path-param.ts +8 -0
  20. package/packages/bundled-features/src/auth-email-password/web/return-path.ts +3 -2
  21. package/packages/bundled-features/src/auth-email-password/web/token-confirm-screen.tsx +97 -0
  22. package/packages/bundled-features/src/auth-email-password/web/verify-email-screen.tsx +20 -68
  23. package/packages/bundled-features/src/auth-foundation/boot-checks.ts +22 -15
  24. package/packages/bundled-features/src/auth-foundation/boot-rules.ts +33 -0
  25. package/packages/bundled-features/src/auth-mfa/errors.ts +12 -42
  26. package/packages/bundled-features/src/auth-mfa/feature-exports.ts +6 -45
  27. package/packages/bundled-features/src/auth-mfa/feature.ts +8 -19
  28. package/packages/bundled-features/src/auth-mfa/web/mfa-client.ts +19 -33
  29. package/packages/bundled-features/src/billing-foundation/consumer-protection/termination-notify.ts +1 -0
  30. package/packages/bundled-features/src/billing-foundation/web/plan-price.ts +20 -7
  31. package/packages/bundled-features/src/cap-counter/stock-cap-guard.ts +1 -0
  32. package/packages/bundled-features/src/channel-in-app/changes.json +7 -0
  33. package/packages/bundled-features/src/channel-in-app/feature.ts +2 -0
  34. package/packages/bundled-features/src/channel-in-app/handlers/read-state-by-keys.query.ts +35 -0
  35. package/packages/bundled-features/src/channel-in-app/in-app-channel.ts +1 -0
  36. package/packages/bundled-features/src/channel-in-app/tables.ts +5 -1
  37. package/packages/bundled-features/src/compliance-profiles/handlers/sub-processors.query.ts +4 -1
  38. package/packages/bundled-features/src/contact/challenge.ts +41 -0
  39. package/packages/bundled-features/src/contact/changes.json +33 -0
  40. package/packages/bundled-features/src/contact/client/contact-client-source.ts +203 -0
  41. package/packages/bundled-features/src/contact/client/contact-website-client.ts +29 -0
  42. package/packages/bundled-features/src/contact/client/index.ts +9 -0
  43. package/packages/bundled-features/src/contact/entity.ts +168 -0
  44. package/packages/bundled-features/src/contact/feature.ts +174 -0
  45. package/packages/bundled-features/src/contact/handlers/access.ts +17 -0
  46. package/packages/bundled-features/src/contact/handlers/attempts.ts +76 -0
  47. package/packages/bundled-features/src/contact/handlers/challenge.query.ts +44 -0
  48. package/packages/bundled-features/src/contact/handlers/forward-request.write.ts +98 -0
  49. package/packages/bundled-features/src/contact/handlers/mark-done.write.ts +40 -0
  50. package/packages/bundled-features/src/contact/handlers/notify-reporter-in-app.write.ts +48 -0
  51. package/packages/bundled-features/src/contact/handlers/open-count.query.ts +15 -0
  52. package/packages/bundled-features/src/contact/handlers/open-count.ts +17 -0
  53. package/packages/bundled-features/src/contact/handlers/replies.query.ts +29 -0
  54. package/packages/bundled-features/src/contact/handlers/reply.write.ts +197 -0
  55. package/packages/bundled-features/src/contact/handlers/report.write.ts +126 -0
  56. package/packages/bundled-features/src/contact/handlers/request-delivery.query.ts +143 -0
  57. package/packages/bundled-features/src/contact/handlers/request-detail.query.ts +50 -0
  58. package/packages/bundled-features/src/contact/handlers/request-list.query.ts +14 -0
  59. package/packages/bundled-features/src/contact/handlers/send-reply-mail.write.ts +124 -0
  60. package/packages/bundled-features/src/contact/handlers/send-test.write.ts +45 -0
  61. package/packages/bundled-features/src/contact/handlers/submit.write.ts +194 -0
  62. package/packages/bundled-features/src/contact/handlers/take-over-uploads.ts +47 -0
  63. package/packages/bundled-features/src/contact/i18n.ts +192 -0
  64. package/packages/bundled-features/src/contact/index.ts +29 -0
  65. package/packages/bundled-features/src/contact/lib.ts +176 -0
  66. package/packages/bundled-features/src/contact/mail.ts +401 -0
  67. package/packages/bundled-features/src/contact/options.ts +95 -0
  68. package/packages/bundled-features/src/contact/panels.ts +28 -0
  69. package/packages/bundled-features/src/contact/payloads.ts +106 -0
  70. package/packages/bundled-features/src/contact/pow.ts +22 -0
  71. package/packages/bundled-features/src/contact/screens.ts +507 -0
  72. package/packages/bundled-features/src/contact/subject.ts +13 -0
  73. package/packages/bundled-features/src/contact/user-agent.ts +39 -0
  74. package/packages/bundled-features/src/contact/user-data-hooks.ts +180 -0
  75. package/packages/bundled-features/src/contact/web/constants.ts +160 -0
  76. package/packages/bundled-features/src/contact/web/index.ts +29 -0
  77. package/packages/bundled-features/src/crypto-shredding/handlers/forget-subject.write.ts +5 -16
  78. package/packages/bundled-features/src/data-retention/changes.json +6 -0
  79. package/packages/bundled-features/src/data-retention/feature.ts +16 -2
  80. package/packages/bundled-features/src/data-retention/index.ts +5 -0
  81. package/packages/bundled-features/src/data-retention/run-retention-cleanup.ts +138 -41
  82. package/packages/bundled-features/src/data-retention/tenant-destruction-hold.ts +196 -0
  83. package/packages/bundled-features/src/delivery/address-opt-out.ts +1 -0
  84. package/packages/bundled-features/src/delivery/changes.json +7 -0
  85. package/packages/bundled-features/src/delivery/channel-context.ts +2 -0
  86. package/packages/bundled-features/src/delivery/delivery-service.ts +29 -5
  87. package/packages/bundled-features/src/delivery/events.ts +2 -0
  88. package/packages/bundled-features/src/delivery/feature.ts +3 -2
  89. package/packages/bundled-features/src/delivery/handlers/attempts-by-keys.query.ts +55 -0
  90. package/packages/bundled-features/src/delivery/handlers/log.query.ts +1 -1
  91. package/packages/bundled-features/src/delivery/jobs.ts +5 -0
  92. package/packages/bundled-features/src/delivery/tables.ts +13 -2
  93. package/packages/bundled-features/src/delivery/types.ts +3 -0
  94. package/packages/bundled-features/src/delivery/unsubscribe-page.ts +2 -0
  95. package/packages/bundled-features/src/delivery/web/delivery-channel-cell.tsx +1 -1
  96. package/packages/bundled-features/src/delivery/web/delivery-error-cell.tsx +1 -1
  97. package/packages/bundled-features/src/delivery/web/delivery-status-cell.tsx +1 -1
  98. package/packages/bundled-features/src/delivery/web/delivery-time-cell.tsx +3 -2
  99. package/packages/bundled-features/src/delivery/web/delivery-type-cell.tsx +1 -1
  100. package/packages/bundled-features/src/delivery/web/public-names.ts +1 -0
  101. package/packages/bundled-features/src/document-ingest-foundation/boot-checks.ts +14 -9
  102. package/packages/bundled-features/src/document-ingest-foundation/boot-rules.ts +22 -0
  103. package/packages/bundled-features/src/document-ingest-foundation/changes.json +6 -0
  104. package/packages/bundled-features/src/document-ingest-foundation/events.ts +17 -0
  105. package/packages/bundled-features/src/document-ingest-foundation/feature.ts +39 -1
  106. package/packages/bundled-features/src/document-ingest-foundation/index.ts +10 -0
  107. package/packages/bundled-features/src/document-ingest-foundation/report-ingest-progress.ts +43 -0
  108. package/packages/bundled-features/src/document-ingest-foundation/tables.ts +43 -0
  109. package/packages/bundled-features/src/file-derivatives/handlers/public-variant-by-file-ref.query.ts +1 -1
  110. package/packages/bundled-features/src/file-derivatives/handlers/public-variant.query.ts +1 -1
  111. package/packages/bundled-features/src/files-tenant-data/changes.json +6 -0
  112. package/packages/bundled-features/src/files-tenant-data/hooks.ts +4 -1
  113. package/packages/bundled-features/src/folders/web/folder-manager.tsx +8 -9
  114. package/packages/bundled-features/src/folders/web/folder-section.tsx +1 -1
  115. package/packages/bundled-features/src/form-draft-user-data/index.ts +2 -0
  116. package/packages/bundled-features/src/inbound-mail-foundation/changes.json +13 -0
  117. package/packages/bundled-features/src/inbound-mail-foundation/entities.ts +2 -0
  118. package/packages/bundled-features/src/inbound-mail-foundation/events.ts +2 -0
  119. package/packages/bundled-features/src/inbound-mail-foundation/feature.ts +6 -6
  120. package/packages/bundled-features/src/inbound-mail-foundation/handlers/attach-message-content.write.ts +7 -0
  121. package/packages/bundled-features/src/inbound-mail-foundation/handlers/ingest-message.write.ts +6 -0
  122. package/packages/bundled-features/src/inbound-mail-foundation/handlers/list-messages.query.ts +6 -2
  123. package/packages/bundled-features/src/inbound-mail-foundation/handlers/message-content.query.ts +3 -0
  124. package/packages/bundled-features/src/inbound-mail-foundation/handlers/message-content.ts +19 -0
  125. package/packages/bundled-features/src/inbound-mail-foundation/projection.ts +2 -0
  126. package/packages/bundled-features/src/inbound-mail-foundation/sanitize-inbound-html.ts +150 -0
  127. package/packages/bundled-features/src/inbound-mail-foundation/types.ts +1 -0
  128. package/packages/bundled-features/src/jobs/job-run-logger.ts +24 -25
  129. package/packages/bundled-features/src/ledger/handlers/reports.query.ts +46 -31
  130. package/packages/bundled-features/src/ledger/recurring.ts +1 -0
  131. package/packages/bundled-features/src/managed-pages/handlers/branding.query.ts +1 -1
  132. package/packages/bundled-features/src/managed-pages/handlers/by-slug.query.ts +1 -1
  133. package/packages/bundled-features/src/managed-pages/handlers/by-tenant-published.query.ts +1 -1
  134. package/packages/bundled-features/src/notes-history/web/notes-section.tsx +3 -1
  135. package/packages/bundled-features/src/personal-access-tokens/feature.ts +9 -17
  136. package/packages/bundled-features/src/personal-access-tokens/handlers/create.write.ts +2 -7
  137. package/packages/bundled-features/src/secrets/changes.json +6 -0
  138. package/packages/bundled-features/src/secrets/handlers/delete.write.ts +8 -4
  139. package/packages/bundled-features/src/secrets/handlers/list.query.ts +6 -3
  140. package/packages/bundled-features/src/secrets/handlers/set.write.ts +9 -4
  141. package/packages/bundled-features/src/secrets/secret-scope.ts +33 -0
  142. package/packages/bundled-features/src/seo/handlers/seo-config.query.ts +1 -1
  143. package/packages/bundled-features/src/sessions/changes.json +6 -0
  144. package/packages/bundled-features/src/sessions/feature.ts +21 -18
  145. package/packages/bundled-features/src/sessions/handlers/last-activity-probe.query.ts +53 -0
  146. package/packages/bundled-features/src/sessions/handlers/last-activity-probe.route.ts +39 -0
  147. package/packages/bundled-features/src/sessions/screens.ts +1 -0
  148. package/packages/bundled-features/src/sessions/session-callbacks.ts +13 -12
  149. package/packages/bundled-features/src/sessions/web/i18n.ts +4 -1
  150. package/packages/bundled-features/src/shared/assert-billing-live.ts +14 -0
  151. package/packages/bundled-features/src/shared/collect-extension-options.ts +12 -0
  152. package/packages/bundled-features/src/shared/index.ts +16 -0
  153. package/packages/bundled-features/src/shared/late-bound-slot.ts +19 -0
  154. package/packages/bundled-features/src/shared/mail-locale-templates.ts +7 -1
  155. package/packages/bundled-features/src/shared/price-env-shape.ts +44 -0
  156. package/packages/bundled-features/src/shared/purge-row-file-refs.ts +1 -1
  157. package/packages/bundled-features/src/shared/read-feature-export-fn.ts +16 -0
  158. package/packages/bundled-features/src/shared/signup-handover.ts +3 -4
  159. package/packages/bundled-features/src/shared/tenant-destruction-hold.ts +49 -0
  160. package/packages/bundled-features/src/shared/unprocessable.ts +19 -0
  161. package/packages/bundled-features/src/shared/web/index.ts +3 -0
  162. package/packages/bundled-features/src/subscription-paddle/checkout-config.query.ts +1 -1
  163. package/packages/bundled-features/src/subscription-paddle/feature.ts +7 -15
  164. package/packages/bundled-features/src/subscription-paddle/runtime.ts +4 -7
  165. package/packages/bundled-features/src/subscription-stripe/feature.ts +7 -15
  166. package/packages/bundled-features/src/subscription-stripe/runtime.ts +4 -7
  167. package/packages/bundled-features/src/tags/entity.ts +1 -0
  168. package/packages/bundled-features/src/tags/web/tag-chip.tsx +14 -0
  169. package/packages/bundled-features/src/tags/web/tag-filter.tsx +4 -5
  170. package/packages/bundled-features/src/tags/web/tag-manager.tsx +1 -1
  171. package/packages/bundled-features/src/tags/web/tag-section.tsx +3 -6
  172. package/packages/bundled-features/src/tags/web/tags-cell.tsx +4 -5
  173. package/packages/bundled-features/src/template-resolver/compile-document-body.ts +27 -15
  174. package/packages/bundled-features/src/template-resolver/handlers/by-slug.query.ts +1 -1
  175. package/packages/bundled-features/src/template-resolver/handlers/by-tenant.query.ts +12 -9
  176. package/packages/bundled-features/src/template-resolver/handlers/discard-draft.write.ts +1 -0
  177. package/packages/bundled-features/src/template-resolver/handlers/overview.query.ts +1 -0
  178. package/packages/bundled-features/src/template-resolver/handlers/send-test.write.ts +5 -5
  179. package/packages/bundled-features/src/template-resolver/handlers/toggle-status.write.ts +3 -0
  180. package/packages/bundled-features/src/template-resolver/linked-resources.ts +11 -6
  181. package/packages/bundled-features/src/template-resolver/store-template-resource.ts +15 -12
  182. package/packages/bundled-features/src/template-resolver/web/document-images.ts +6 -6
  183. package/packages/bundled-features/src/template-resolver/web/document-insert-fields.tsx +41 -36
  184. package/packages/bundled-features/src/template-resolver/web/document-schema.ts +11 -12
  185. package/packages/bundled-features/src/template-resolver/web/tiptap-attribute-parse-rule.ts +19 -0
  186. package/packages/bundled-features/src/tenant/i18n.ts +3 -0
  187. package/packages/bundled-features/src/tenant/schema/tenant.ts +1 -0
  188. package/packages/bundled-features/src/tenant/web/member-roles-cell.tsx +1 -1
  189. package/packages/bundled-features/src/tenant/web/member-status-cell.tsx +1 -1
  190. package/packages/bundled-features/src/tenant-inactivity/changes.json +8 -0
  191. package/packages/bundled-features/src/tenant-inactivity/check-inactive-tenants.ts +260 -0
  192. package/packages/bundled-features/src/tenant-inactivity/constants.ts +12 -0
  193. package/packages/bundled-features/src/tenant-inactivity/email-templates.ts +24 -0
  194. package/packages/bundled-features/src/tenant-inactivity/feature.ts +66 -0
  195. package/packages/bundled-features/src/tenant-inactivity/handlers/inactivity-state.query.ts +49 -0
  196. package/packages/bundled-features/src/tenant-inactivity/handlers/keep-account.write.ts +59 -0
  197. package/packages/bundled-features/src/tenant-inactivity/inactivity-plan.ts +187 -0
  198. package/packages/bundled-features/src/tenant-inactivity/index.ts +5 -0
  199. package/packages/bundled-features/src/tenant-inactivity/keep-token.ts +44 -0
  200. package/packages/bundled-features/src/tenant-inactivity/mail-notifications.ts +62 -0
  201. package/packages/bundled-features/src/tenant-inactivity/options.ts +38 -0
  202. package/packages/bundled-features/src/tenant-inactivity/remote-activity.ts +32 -0
  203. package/packages/bundled-features/src/tenant-inactivity/state-store.ts +71 -0
  204. package/packages/bundled-features/src/tenant-inactivity/state-table.ts +50 -0
  205. package/packages/bundled-features/src/tenant-lifecycle/boot-checks.ts +8 -6
  206. package/packages/bundled-features/src/tenant-lifecycle/boot-rules.ts +16 -0
  207. package/packages/bundled-features/src/tenant-lifecycle/changes.json +18 -0
  208. package/packages/bundled-features/src/tenant-lifecycle/feature.ts +24 -1
  209. package/packages/bundled-features/src/tenant-lifecycle/handlers/request-destruction.write.ts +12 -87
  210. package/packages/bundled-features/src/tenant-lifecycle/index.ts +4 -0
  211. package/packages/bundled-features/src/tenant-lifecycle/request-tenant-destruction.ts +108 -0
  212. package/packages/bundled-features/src/tenant-lifecycle/retention-config-destroy-hooks.ts +62 -0
  213. package/packages/bundled-features/src/tenant-lifecycle/run-tenant-destroy.ts +58 -5
  214. package/packages/bundled-features/src/tenant-lifecycle/stages.ts +31 -2
  215. package/packages/bundled-features/src/tenant-lifecycle/testing.ts +1 -1
  216. package/packages/bundled-features/src/tier-engine/caps-for-tier-from-map.ts +16 -0
  217. package/packages/bundled-features/src/tier-engine/changes.json +6 -0
  218. package/packages/bundled-features/src/tier-engine/compose-app.ts +21 -20
  219. package/packages/bundled-features/src/tier-engine/index.ts +1 -0
  220. package/packages/bundled-features/src/user-data-rights/feature.ts +2 -0
  221. package/packages/bundled-features/src/user-data-rights/handlers/confirm-deletion-by-token.write.ts +4 -1
  222. package/packages/bundled-features/src/user-data-rights/handlers/download-by-token.query.ts +1 -0
  223. package/packages/bundled-features/src/user-data-rights/handlers/request-deletion-by-email.write.ts +4 -1
  224. package/packages/bundled-features/src/user-data-rights/run-forget-cleanup.ts +2 -0
  225. package/packages/bundled-features/src/user-data-rights/web/privacy-center-screen.tsx +1 -1
  226. package/packages/bundled-features/src/user-data-rights/zip-path.ts +1 -0
  227. package/packages/bundled-features/src/user-data-rights-defaults/hooks/config-value.userdata-hook.ts +8 -27
  228. package/packages/bundled-features/src/user-data-rights-defaults/hooks/delivery-attempt.userdata-hook.ts +11 -8
  229. package/packages/bundled-features/src/user-data-rights-defaults/hooks/forget-own-rows-delete-hook.ts +42 -0
  230. package/packages/bundled-features/src/user-data-rights-defaults/hooks/notification-preference.userdata-hook.ts +8 -27
  231. package/packages/bundled-features/src/user-profile/handlers/change-email.write.ts +2 -6
  232. package/packages/bundled-features/src/user-profile/web/profile-screen.tsx +2 -3
  233. package/packages/bundled-features/src/waitlist/changes.json +6 -0
  234. package/packages/bundled-features/src/waitlist/handlers/submit.write.ts +1 -2
  235. package/samples/apps/styleguide/src/features/widgets/i18n.ts +6 -0
  236. package/samples/apps/styleguide/src/features/widgets/web/InboxReaderExamples.tsx +158 -0
  237. package/samples/apps/styleguide/src/features/widgets/web/Widgets.tsx +2 -0
  238. package/samples/apps/styleguide/src/features/widgets/web/sample-pdf.ts +28 -0
  239. package/samples/apps/use-all-bundled/feature-manifest.json +113 -2
  240. package/samples/apps/use-all-bundled/kumiko/migrations/0063_contact.rebuild.json +4 -0
  241. package/samples/apps/use-all-bundled/package.json +1 -0
  242. package/samples/apps/use-all-bundled/src/app/client.tsx +3 -0
  243. package/samples/apps/use-all-bundled/src/app/screens-feature.ts +46 -2
  244. package/samples/apps/use-all-bundled/src/run-config.ts +23 -1
  245. package/samples/recipes/anonymous-access/README.md +2 -0
  246. package/samples/recipes/anonymous-access/src/feature.ts +7 -1
  247. package/samples/recipes/contact/README.md +52 -0
  248. package/samples/recipes/contact/package.json +12 -0
  249. package/samples/recipes/contact/src/feature.ts +27 -0
  250. package/samples/recipes/delivery-notifications/src/feature.ts +3 -0
  251. package/samples/recipes/record-detail-layout/src/feature.ts +9 -1
  252. package/samples/recipes/search/README.md +2 -0
  253. package/samples/recipes/search/src/feature.ts +27 -2
  254. package/samples/recipes/secrets-demo/README.md +1 -0
  255. package/samples/recipes/secrets-demo/src/feature.ts +56 -0
  256. package/samples/recipes/tenant-inactivity/README.md +21 -0
  257. package/samples/recipes/tenant-inactivity/package.json +12 -0
@@ -12,3 +12,15 @@ export function collectExtensionOptions<TOptions extends object>(
12
12
  return { name: usage.entityName, ...usage.options };
13
13
  });
14
14
  }
15
+
16
+ // Optional single-provider extension points: a usage with foreign options is skipped, not an error.
17
+ export function findExtensionOptions<TOptions extends object>(
18
+ registry: Registry,
19
+ extension: string,
20
+ isOptions: (candidate: unknown) => candidate is TOptions,
21
+ ): TOptions | undefined {
22
+ for (const usage of registry.getExtensionUsages(extension)) {
23
+ if (isOptions(usage.options)) return usage.options;
24
+ }
25
+ return undefined;
26
+ }
@@ -1,3 +1,4 @@
1
+ export { assertBillingLive } from "./assert-billing-live.ts";
1
2
  export { collectErasureFailure, throwIfErasureFailed } from "./assert-erased.ts";
2
3
  export { assertNoWhereRuleInOwnershipWrite } from "./assert-no-where-rule-in-ownership-write.ts";
3
4
  export {
@@ -24,6 +25,7 @@ export { hmacSignatureMatches, signHmacSha256Base64Url } from "./hmac-signature.
24
25
  export { isIdentityV3Hash, verifyIdentityV3Hash } from "./identity-v3-hash.ts";
25
26
  export { isTenantDb } from "./is-tenant-db.ts";
26
27
  export { isUniqueConstraintFailure } from "./is-unique-constraint-failure.ts";
28
+ export { createLateBoundSlot, type LateBoundSlot } from "./late-bound-slot.ts";
27
29
  export { createLockoutCounter, type LockoutCounterState } from "./lockout-counter.ts";
28
30
  export { createMailLocaleTemplates } from "./mail-locale-templates.ts";
29
31
  export {
@@ -40,6 +42,12 @@ export {
40
42
  parentRowIsVisible,
41
43
  } from "./parent-visibility.ts";
42
44
  export { hashPassword, verifyDummyPassword, verifyPassword } from "./password-hashing.ts";
45
+ export {
46
+ type PriceEnvProvider,
47
+ type PriceEnvShape,
48
+ priceEnvSchema,
49
+ priceEnvShape,
50
+ } from "./price-env-shape.ts";
43
51
  export {
44
52
  type DeleteFileBytes,
45
53
  FileSweepError,
@@ -47,6 +55,7 @@ export {
47
55
  purgeFilesReachingSubject,
48
56
  } from "./purge-files-reaching-subject.ts";
49
57
  export {
58
+ collectFileRefIds,
50
59
  collectSingleFileHolders,
51
60
  type FileFieldPlan,
52
61
  type FileRefPurgeOutcome,
@@ -55,6 +64,7 @@ export {
55
64
  type SingleFileHolder,
56
65
  } from "./purge-row-file-refs.ts";
57
66
  export { rateLimitedTextResponse } from "./rate-limited-text-response.ts";
67
+ export { readFeatureExportFn } from "./read-feature-export-fn.ts";
58
68
  export {
59
69
  redactBotTokens,
60
70
  redactEmailAddresses,
@@ -114,4 +124,10 @@ export {
114
124
  } from "./stream-tenant-derived-state.ts";
115
125
  export type { SystemQueryFn } from "./system-query.ts";
116
126
  export { createTenantDbCache } from "./tenant-db-cache.ts";
127
+ export {
128
+ EXT_TENANT_DESTRUCTION_HOLD,
129
+ findTenantDestructionHoldProvider,
130
+ type TenantDestructionHoldProvider,
131
+ } from "./tenant-destruction-hold.ts";
117
132
  export { type BurnResult, burnToken, unburnToken } from "./token-burn-store.ts";
133
+ export { unprocessable } from "./unprocessable.ts";
@@ -0,0 +1,19 @@
1
+ // The unbind only clears the slot while it still holds this value, so a stack that stops later
2
+ // cannot unbind a newer stack sharing the same feature instance.
3
+ export type LateBoundSlot<TValue> = {
4
+ readonly bind: (value: TValue) => () => void;
5
+ readonly current: () => TValue | undefined;
6
+ };
7
+
8
+ export function createLateBoundSlot<TValue>(): LateBoundSlot<TValue> {
9
+ let bound: TValue | undefined;
10
+ return {
11
+ bind: (value) => {
12
+ bound = value;
13
+ return () => {
14
+ if (bound === value) bound = undefined;
15
+ };
16
+ },
17
+ current: () => bound,
18
+ };
19
+ }
@@ -11,6 +11,8 @@ type MailLocaleTemplateConfig<Kind extends string> = {
11
11
  readonly notificationTypes: Readonly<Record<Kind, string>>;
12
12
  readonly subjectKey: (kind: Kind) => string;
13
13
  readonly bodyFor: (kind: Kind, locale: string) => string;
14
+ // Subject placeholder -> template variable; defaults to the app name only.
15
+ readonly subjectSlots?: (kind: Kind) => Readonly<Record<string, string>>;
14
16
  };
15
17
 
16
18
  export function createMailLocaleTemplates<Kind extends string>(
@@ -51,7 +53,11 @@ export function createMailLocaleTemplates<Kind extends string>(
51
53
  {
52
54
  body: config.bodyFor(kind, locale),
53
55
  meta: {
54
- subject: mailT(locale, kindSubjectKey, { app: "{{appName}}" }),
56
+ subject: mailT(
57
+ locale,
58
+ kindSubjectKey,
59
+ config.subjectSlots?.(kind) ?? { app: "{{appName}}" },
60
+ ),
55
61
  category: "transactional" as const,
56
62
  },
57
63
  },
@@ -0,0 +1,44 @@
1
+ import * as z from "zod";
2
+
3
+ export type PriceEnvProvider<TEnvPrefix extends string> = {
4
+ readonly envPrefix: TEnvPrefix;
5
+ readonly label: string;
6
+ readonly priceIdPrefix: string;
7
+ };
8
+
9
+ export type PriceEnvShape<TEnvPrefix extends string, TPrice extends string> = {
10
+ [Key in `${TEnvPrefix}_PRICE_${TPrice}`]: z.ZodOptional<z.ZodString>;
11
+ };
12
+
13
+ export function priceEnvShape<const TEnvPrefix extends string, const TPrice extends string>(
14
+ provider: PriceEnvProvider<TEnvPrefix>,
15
+ prices: readonly TPrice[],
16
+ ): PriceEnvShape<TEnvPrefix, TPrice> {
17
+ const { envPrefix, label, priceIdPrefix } = provider;
18
+ return Object.fromEntries(
19
+ prices.map((price) => [
20
+ `${envPrefix}_PRICE_${price}`,
21
+ z
22
+ .string()
23
+ .regex(
24
+ new RegExp(`^${priceIdPrefix}`),
25
+ `${envPrefix}_PRICE_${price} must start with '${priceIdPrefix}'`,
26
+ )
27
+ .optional()
28
+ .describe(`${label} price id (\`${priceIdPrefix}...\`) of the ${price} plan.`),
29
+ ]),
30
+ // @cast-boundary schema-walk — Object.fromEntries widens to an index signature; the entries are exactly one optional string per listed price.
31
+ ) as PriceEnvShape<TEnvPrefix, TPrice>;
32
+ }
33
+
34
+ export function priceEnvSchema<
35
+ TBaseShape extends z.ZodRawShape,
36
+ const TEnvPrefix extends string,
37
+ const TPrice extends string,
38
+ >(
39
+ base: z.ZodObject<TBaseShape>,
40
+ provider: PriceEnvProvider<TEnvPrefix>,
41
+ prices: readonly TPrice[],
42
+ ) {
43
+ return z.object({ ...base.shape, ...priceEnvShape(provider, prices) });
44
+ }
@@ -66,7 +66,7 @@ export function collectSingleFileHolders(registry: Registry): readonly SingleFil
66
66
  // Every fileRef-id a row's file-fields reference: single fields hold the id in
67
67
  // their own column, plural fields resolve via file_refs (tenantId, entityType,
68
68
  // entityId, fieldName).
69
- async function collectFileRefIds(
69
+ export async function collectFileRefIds(
70
70
  db: DbRunner,
71
71
  tenantId: TenantId,
72
72
  entityName: string,
@@ -0,0 +1,16 @@
1
+ import type { FeatureDefinition } from "@cosmicdrift/kumiko-framework/engine";
2
+
3
+ export function readFeatureExportFn<TFn extends (...args: never[]) => unknown>(
4
+ feature: FeatureDefinition,
5
+ exportName: string,
6
+ ): TFn | undefined {
7
+ const exports = feature.exports;
8
+ if (exports && typeof exports === "object" && exportName in exports) {
9
+ const candidate = Reflect.get(exports, exportName);
10
+ if (typeof candidate === "function") {
11
+ // @cast-boundary feature-exports — feature.exports is untyped by design
12
+ return candidate as TFn;
13
+ }
14
+ }
15
+ return undefined;
16
+ }
@@ -13,6 +13,7 @@
13
13
  import type { DbRunner } from "@cosmicdrift/kumiko-framework/db";
14
14
  import type { Registry } from "@cosmicdrift/kumiko-framework/engine";
15
15
  import { isPlainObject } from "@cosmicdrift/kumiko-types/type-guards";
16
+ import { findExtensionOptions } from "./collect-extension-options.ts";
16
17
 
17
18
  export const EXT_SIGNUP_HANDOVER = "signupHandover" as const;
18
19
 
@@ -44,6 +45,7 @@ export type SignupHandoverProvider = {
44
45
  };
45
46
  };
46
47
 
48
+ // guard:dup-ok type guard over this provider's own two members; only the guard shape is shared
47
49
  export function isSignupHandoverProvider(options: unknown): options is SignupHandoverProvider {
48
50
  return (
49
51
  isPlainObject(options) &&
@@ -53,10 +55,7 @@ export function isSignupHandoverProvider(options: unknown): options is SignupHan
53
55
  }
54
56
 
55
57
  export function findSignupHandoverProvider(registry: Registry): SignupHandoverProvider | undefined {
56
- for (const usage of registry.getExtensionUsages(EXT_SIGNUP_HANDOVER)) {
57
- if (isSignupHandoverProvider(usage.options)) return usage.options;
58
- }
59
- return undefined;
58
+ return findExtensionOptions(registry, EXT_SIGNUP_HANDOVER, isSignupHandoverProvider);
60
59
  }
61
60
 
62
61
  declare module "@cosmicdrift/kumiko-framework/engine" {
@@ -0,0 +1,49 @@
1
+ // data-retention deletes the last retention-held rows of a tenant whose destruction is parked, and
2
+ // has to hand the tenant back to the destroy sweep afterwards. The status belongs to
3
+ // tenant-lifecycle, which already imports data-retention, so data-retention reaches it through this
4
+ // extension point instead of importing it back.
5
+
6
+ import type { DbRunner } from "@cosmicdrift/kumiko-framework/db";
7
+ import type { Registry, TenantId } from "@cosmicdrift/kumiko-framework/engine";
8
+ import type { Temporal } from "@cosmicdrift/kumiko-types/temporal";
9
+ import { isPlainObject } from "@cosmicdrift/kumiko-types/type-guards";
10
+ import { findExtensionOptions } from "./collect-extension-options.ts";
11
+
12
+ export const EXT_TENANT_DESTRUCTION_HOLD = "tenantDestructionHold" as const;
13
+
14
+ export type TenantDestructionHoldProvider = {
15
+ isParked(args: { readonly db: DbRunner; readonly tenantId: TenantId }): Promise<boolean>;
16
+ /** Hands a parked tenant back to the destroy sweep once nothing holds it; true only when it did. */
17
+ releaseIfFree(args: {
18
+ readonly db: DbRunner;
19
+ readonly registry: Registry;
20
+ readonly tenantId: TenantId;
21
+ readonly now: Temporal.Instant;
22
+ }): Promise<boolean>;
23
+ };
24
+
25
+ function isTenantDestructionHoldProvider(
26
+ options: unknown,
27
+ ): options is TenantDestructionHoldProvider {
28
+ return (
29
+ isPlainObject(options) &&
30
+ typeof options["isParked"] === "function" &&
31
+ typeof options["releaseIfFree"] === "function"
32
+ );
33
+ }
34
+
35
+ export function findTenantDestructionHoldProvider(
36
+ registry: Registry,
37
+ ): TenantDestructionHoldProvider | undefined {
38
+ return findExtensionOptions(
39
+ registry,
40
+ EXT_TENANT_DESTRUCTION_HOLD,
41
+ isTenantDestructionHoldProvider,
42
+ );
43
+ }
44
+
45
+ declare module "@cosmicdrift/kumiko-framework/engine" {
46
+ interface KumikoExtensionOptionsMap {
47
+ [EXT_TENANT_DESTRUCTION_HOLD]: TenantDestructionHoldProvider;
48
+ }
49
+ }
@@ -0,0 +1,19 @@
1
+ import {
2
+ UnprocessableError,
3
+ type WriteFailure,
4
+ writeFailure,
5
+ } from "@cosmicdrift/kumiko-framework/errors";
6
+
7
+ type UnprocessableDetails = NonNullable<
8
+ ConstructorParameters<typeof UnprocessableError>[1]
9
+ >["details"];
10
+
11
+ export function unprocessable(
12
+ reason: string,
13
+ i18nKey: string,
14
+ details?: UnprocessableDetails,
15
+ ): WriteFailure {
16
+ return writeFailure(
17
+ new UnprocessableError(reason, details === undefined ? { i18nKey } : { i18nKey, details }),
18
+ );
19
+ }
@@ -0,0 +1,3 @@
1
+ export { type SectionStatus, StatusBanner } from "./status-banner.tsx";
2
+ export { translateOrRaw } from "./translate-or-raw.ts";
3
+ export { useDispatchedWrites } from "./use-dispatched-writes.ts";
@@ -8,7 +8,7 @@ export function makeCheckoutConfigQuery(readCheckoutConfig: PaddleRuntimes["read
8
8
  return defineQueryHandler({
9
9
  name: "checkout-config",
10
10
  schema: z.object({}),
11
- access: { roles: ["anonymous", "User", "TenantAdmin", "SystemAdmin"] },
11
+ access: { roles: ["anonymous", "User", "TenantAdmin", "SystemAdmin"], anySignedIn: true },
12
12
  rateLimit: { per: "ip+handler", limit: 60, windowSeconds: 60 },
13
13
  description:
14
14
  "Answers the public Paddle.js client token and the Paddle environment for the checkout page; the client token is public by design and no other config leaves this handler.",
@@ -20,6 +20,7 @@ import { type FeatureWithEnvSchema, featureWithEnvSchema } from "@cosmicdrift/ku
20
20
  import { egress } from "@cosmicdrift/kumiko-framework/http";
21
21
  import { Temporal } from "@cosmicdrift/kumiko-types/temporal";
22
22
  import * as z from "zod";
23
+ import { priceEnvSchema } from "../shared/index.ts";
23
24
  import { makeCheckoutConfigQuery } from "./checkout-config.query.ts";
24
25
  import {
25
26
  createPaddleCancelSubscription,
@@ -78,9 +79,11 @@ export const subscriptionPaddleEnvSchema = z.object({
78
79
  .optional(),
79
80
  });
80
81
 
81
- type PaddlePriceEnvShape<TPrice extends string> = {
82
- [Key in `PADDLE_PRICE_${TPrice}`]: z.ZodOptional<z.ZodString>;
83
- };
82
+ const PADDLE_PRICE_ENV = {
83
+ envPrefix: "PADDLE",
84
+ label: "Paddle",
85
+ priceIdPrefix: "pri_",
86
+ } as const;
84
87
 
85
88
  /** Paddle env block plus one `PADDLE_PRICE_<NAME>` slot per plan price the app
86
89
  * maps to a tier, e.g. `paddleEnvSchema({ prices: ["PRO", "TEAM"] })`.
@@ -90,18 +93,7 @@ type PaddlePriceEnvShape<TPrice extends string> = {
90
93
  export function paddleEnvSchema<const TPrice extends string>(options: {
91
94
  readonly prices: readonly TPrice[];
92
95
  }) {
93
- const priceShape = Object.fromEntries(
94
- options.prices.map((price) => [
95
- `PADDLE_PRICE_${price}`,
96
- z
97
- .string()
98
- .regex(/^pri_/, `PADDLE_PRICE_${price} must start with 'pri_'`)
99
- .optional()
100
- .describe(`Paddle price id (\`pri_...\`) of the ${price} plan.`),
101
- ]),
102
- // @cast-boundary schema-walk — Object.fromEntries widens to an index signature; the entries are exactly one optional string per listed price.
103
- ) as PaddlePriceEnvShape<TPrice>;
104
- return z.object({ ...subscriptionPaddleEnvSchema.shape, ...priceShape });
96
+ return priceEnvSchema(subscriptionPaddleEnvSchema, PADDLE_PRICE_ENV, options.prices);
105
97
  }
106
98
 
107
99
  export type SubscriptionPaddleOptions = {
@@ -17,8 +17,9 @@ import {
17
17
  type HandlerContext,
18
18
  SYSTEM_TENANT_ID,
19
19
  } from "@cosmicdrift/kumiko-framework/engine";
20
- import { FeatureDisabledError, UnconfiguredError } from "@cosmicdrift/kumiko-framework/errors";
20
+ import { UnconfiguredError } from "@cosmicdrift/kumiko-framework/errors";
21
21
  import type { SecretsContext } from "@cosmicdrift/kumiko-framework/secrets";
22
+ import { assertBillingLive } from "../shared/index.ts";
22
23
  import { createPaddleHttp, type PaddleRequest, type PaddleSend } from "./client.ts";
23
24
  import {
24
25
  PADDLE_BASE_URLS,
@@ -154,12 +155,8 @@ export function createPaddleRuntimes(deps: PaddleRuntimeDeps): PaddleRuntimes {
154
155
  },
155
156
  request,
156
157
  ),
157
- assertBillingLive: async (ctx, handlerName = "create-checkout-session") => {
158
- const live = ctx.config ? await ctx.config(deps.billingLiveHandle) : undefined;
159
- if (live !== true) {
160
- throw new FeatureDisabledError(SUBSCRIPTION_PADDLE_FEATURE, handlerName);
161
- }
162
- },
158
+ assertBillingLive: (ctx, handlerName = "create-checkout-session") =>
159
+ assertBillingLive(ctx, deps.billingLiveHandle, SUBSCRIPTION_PADDLE_FEATURE, handlerName),
163
160
  isBillingEnabled: async (ctx) => {
164
161
  const live = ctx.config ? await ctx.config(deps.billingLiveHandle) : undefined;
165
162
  if (live !== true) return false;
@@ -44,6 +44,7 @@ import {
44
44
  } from "@cosmicdrift/kumiko-framework/engine";
45
45
  import { type FeatureWithEnvSchema, featureWithEnvSchema } from "@cosmicdrift/kumiko-framework/env";
46
46
  import * as z from "zod";
47
+ import { priceEnvSchema } from "../shared/index.ts";
47
48
  import {
48
49
  STRIPE_API_KEY_CONFIG,
49
50
  STRIPE_BILLING_LIVE_CONFIG,
@@ -92,9 +93,11 @@ export const subscriptionStripeEnvSchema = z.object({
92
93
  .optional(),
93
94
  });
94
95
 
95
- type StripePriceEnvShape<TPrice extends string> = {
96
- [Key in `STRIPE_PRICE_${TPrice}`]: z.ZodOptional<z.ZodString>;
97
- };
96
+ const STRIPE_PRICE_ENV = {
97
+ envPrefix: "STRIPE",
98
+ label: "Stripe",
99
+ priceIdPrefix: "price_",
100
+ } as const;
98
101
 
99
102
  /** Stripe env block plus one `STRIPE_PRICE_<NAME>` slot per price the app
100
103
  * maps to a tier, e.g. `stripeEnvSchema({ prices: ["PRO", "TEAM"] })`.
@@ -104,18 +107,7 @@ type StripePriceEnvShape<TPrice extends string> = {
104
107
  export function stripeEnvSchema<const TPrice extends string>(options: {
105
108
  readonly prices: readonly TPrice[];
106
109
  }) {
107
- const priceShape = Object.fromEntries(
108
- options.prices.map((price) => [
109
- `STRIPE_PRICE_${price}`,
110
- z
111
- .string()
112
- .regex(/^price_/, `STRIPE_PRICE_${price} must start with 'price_'`)
113
- .optional()
114
- .describe(`Stripe price id (\`price_...\`) of the ${price} plan.`),
115
- ]),
116
- // @cast-boundary schema-walk — Object.fromEntries widens to an index signature; the entries are exactly one optional string per listed price.
117
- ) as StripePriceEnvShape<TPrice>;
118
- return z.object({ ...subscriptionStripeEnvSchema.shape, ...priceShape });
110
+ return priceEnvSchema(subscriptionStripeEnvSchema, STRIPE_PRICE_ENV, options.prices);
119
111
  }
120
112
 
121
113
  export type SubscriptionStripeOptions = {
@@ -32,9 +32,10 @@ import {
32
32
  type HandlerContext,
33
33
  SYSTEM_TENANT_ID,
34
34
  } from "@cosmicdrift/kumiko-framework/engine";
35
- import { FeatureDisabledError, UnconfiguredError } from "@cosmicdrift/kumiko-framework/errors";
35
+ import { UnconfiguredError } from "@cosmicdrift/kumiko-framework/errors";
36
36
  import type { SecretsContext } from "@cosmicdrift/kumiko-framework/secrets";
37
37
  import Stripe from "stripe";
38
+ import { assertBillingLive } from "../shared/index.ts";
38
39
  import { SUBSCRIPTION_STRIPE_FEATURE } from "./constants.ts";
39
40
 
40
41
  const API_KEY_HINT =
@@ -137,12 +138,8 @@ export function createStripeRuntimes(deps: StripeRuntimeDeps): StripeRuntimes {
137
138
  ctx: {
138
139
  // @wrapper-known semantic-alias
139
140
  clientForCtx: async (ctx) => clientFor(await ctxApiKey(ctx)),
140
- assertBillingLive: async (ctx, handlerName = "create-checkout-session") => {
141
- const live = ctx.config ? await ctx.config(deps.billingLiveHandle) : undefined;
142
- if (live !== true) {
143
- throw new FeatureDisabledError(SUBSCRIPTION_STRIPE_FEATURE, handlerName);
144
- }
145
- },
141
+ assertBillingLive: (ctx, handlerName = "create-checkout-session") =>
142
+ assertBillingLive(ctx, deps.billingLiveHandle, SUBSCRIPTION_STRIPE_FEATURE, handlerName),
146
143
  isBillingEnabled: async (ctx) => {
147
144
  const live = ctx.config ? await ctx.config(deps.billingLiveHandle) : undefined;
148
145
  if (live !== true) return false;
@@ -55,6 +55,7 @@ export const tagEntity = createEntity({
55
55
  // Cross-entity views compose in the read-layer (no JOIN):
56
56
  // - tags of an entity → list assignments filter { field: "entityId", op: "eq" }
57
57
  // - entities with a tag → list assignments filter { field: "tagId", op: "eq" }
58
+ // guard:dup-ok own table and fields; a shared definition would couple the schemas and migrations of tags and folders
58
59
  export function createTagAssignmentEntity(
59
60
  access?: EntityDefinition["access"],
60
61
  parents?: readonly string[],
@@ -47,6 +47,20 @@ const BASE_STYLE: CSSProperties = {
47
47
 
48
48
  const NEUTRAL = { backgroundColor: "#e5e7eb", color: "#374151" } as const;
49
49
 
50
+ export function TagChipById({
51
+ id,
52
+ byId,
53
+ }: {
54
+ readonly id: string;
55
+ readonly byId: ReadonlyMap<
56
+ string,
57
+ { readonly name: string; readonly color?: string | null | undefined }
58
+ >;
59
+ }): ReactNode {
60
+ const tag = byId.get(id);
61
+ return <TagChip name={tag?.name ?? id} color={tag?.color} />;
62
+ }
63
+
50
64
  export function TagChip({
51
65
  name,
52
66
  color,
@@ -20,7 +20,7 @@ import {
20
20
  } from "@cosmicdrift/kumiko-renderer";
21
21
  import { type ReactNode, useState } from "react";
22
22
  import { TagsQueries } from "./constants.ts";
23
- import { TagChip } from "./tag-chip.tsx";
23
+ import { TagChipById } from "./tag-chip.tsx";
24
24
  import { TagPicker } from "./tag-picker.tsx";
25
25
 
26
26
  // Tags chosen but zero matching entities → filter to a value that matches no row
@@ -78,10 +78,9 @@ export function TagFilter({
78
78
  <Button variant="secondary" onClick={() => setOpen(true)} testId="tag-filter-open">
79
79
  {t("tags.filter.label")}
80
80
  </Button>
81
- {selected.map((id) => {
82
- const tag = byId.get(id);
83
- return <TagChip key={id} name={tag?.name ?? id} color={tag?.color} />;
84
- })}
81
+ {selected.map((id) => (
82
+ <TagChipById key={id} id={id} byId={byId} />
83
+ ))}
85
84
  {selected.length > 0 && (
86
85
  <Button variant="secondary" onClick={() => applyFilter([])} testId="tag-filter-clear">
87
86
  {t("tags.filter.clear")}
@@ -17,7 +17,7 @@ import {
17
17
  } from "@cosmicdrift/kumiko-renderer";
18
18
  import { pluralKey } from "@cosmicdrift/kumiko-renderer/headless";
19
19
  import { type ReactNode, useState } from "react";
20
- import { useDispatchedWrites } from "../../shared/web/use-dispatched-writes.ts";
20
+ import { useDispatchedWrites } from "../../shared/web/index.ts";
21
21
  import { TagsHandlers, TagsQueries } from "./constants.ts";
22
22
  import { TagChip } from "./tag-chip.tsx";
23
23
 
@@ -13,9 +13,9 @@
13
13
 
14
14
  import { usePrimitives, useQuery, useTranslation } from "@cosmicdrift/kumiko-renderer";
15
15
  import { type ReactNode, useState } from "react";
16
- import { useDispatchedWrites } from "../../shared/web/use-dispatched-writes.ts";
16
+ import { useDispatchedWrites } from "../../shared/web/index.ts";
17
17
  import { TagsHandlers, TagsQueries } from "./constants.ts";
18
- import { TagChip } from "./tag-chip.tsx";
18
+ import { TagChipById } from "./tag-chip.tsx";
19
19
  import { TagPicker } from "./tag-picker.tsx";
20
20
 
21
21
  type TagRow = { readonly id: string; readonly name: string; readonly color?: string | null };
@@ -130,10 +130,7 @@ export function TagSection({
130
130
  {assignedIds.length === 0 ? (
131
131
  <Text variant="small">{t("tags.section.none")}</Text>
132
132
  ) : (
133
- assignedIds.map((id) => {
134
- const tag = byId.get(id);
135
- return <TagChip key={id} name={tag?.name ?? id} color={tag?.color} />;
136
- })
133
+ assignedIds.map((id) => <TagChipById key={id} id={id} byId={byId} />)
137
134
  )}
138
135
  <Button
139
136
  variant="secondary"
@@ -17,7 +17,7 @@
17
17
  import { type ColumnRendererProps, useQuery } from "@cosmicdrift/kumiko-renderer";
18
18
  import type { ReactNode } from "react";
19
19
  import { TagsQueries } from "./constants.ts";
20
- import { TagChip } from "./tag-chip.tsx";
20
+ import { TagChipById } from "./tag-chip.tsx";
21
21
 
22
22
  type TagRow = { readonly id: string; readonly name: string; readonly color?: string | null };
23
23
  type AssignmentRow = { readonly tagId: string; readonly entityId: string };
@@ -36,10 +36,9 @@ export function TagsCell({ row }: ColumnRendererProps): ReactNode {
36
36
  if (tagIds.length === 0) return null;
37
37
  return (
38
38
  <div className="flex flex-wrap gap-1" data-testid="tags-cell">
39
- {tagIds.map((id) => {
40
- const tag = byId.get(id);
41
- return <TagChip key={id} name={tag?.name ?? id} color={tag?.color} />;
42
- })}
39
+ {tagIds.map((id) => (
40
+ <TagChipById key={id} id={id} byId={byId} />
41
+ ))}
43
42
  </div>
44
43
  );
45
44
  }
@@ -259,28 +259,40 @@ function appendStyle(element: ScanElement, style: string): void {
259
259
  element.setAttribute("style", existing === null ? style : `${existing};${style}`);
260
260
  }
261
261
 
262
- // Unique valid resource keys in document order.
263
- export function collectDocumentResourceKeys(html: string): readonly string[] {
262
+ function collectUniqueValidAttributes(
263
+ html: string,
264
+ selector: string,
265
+ attribute: string,
266
+ isValid: (value: string) => boolean,
267
+ ): readonly string[] {
264
268
  return withParsedDocument(html, (root) => {
265
- const keys = new Set<string>();
266
- for (const element of Array.from(root.querySelectorAll("img[data-resource]"))) {
267
- const key = element.getAttribute("data-resource") ?? "";
268
- if (isDocumentResourceKey(key)) keys.add(key);
269
+ const values = new Set<string>();
270
+ for (const element of Array.from(root.querySelectorAll(selector))) {
271
+ const value = element.getAttribute(attribute) ?? "";
272
+ if (isValid(value)) values.add(value);
269
273
  }
270
- return [...keys];
274
+ return [...values];
271
275
  });
272
276
  }
273
277
 
278
+ // Unique valid resource keys in document order.
279
+ export function collectDocumentResourceKeys(html: string): readonly string[] {
280
+ return collectUniqueValidAttributes(
281
+ html,
282
+ "img[data-resource]",
283
+ "data-resource",
284
+ isDocumentResourceKey,
285
+ );
286
+ }
287
+
274
288
  // Unique valid names of the images blocks in document order.
275
289
  export function collectDocumentImageVariables(html: string): readonly string[] {
276
- return withParsedDocument(html, (root) => {
277
- const names = new Set<string>();
278
- for (const element of Array.from(root.querySelectorAll("div[data-images]"))) {
279
- const name = element.getAttribute("data-images") ?? "";
280
- if (isDocumentReferenceName(name)) names.add(name);
281
- }
282
- return [...names];
283
- });
290
+ return collectUniqueValidAttributes(
291
+ html,
292
+ "div[data-images]",
293
+ "data-images",
294
+ isDocumentReferenceName,
295
+ );
284
296
  }
285
297
 
286
298
  function rewriteImagesBlock(
@@ -26,7 +26,7 @@ export const bySlugQuery = defineQueryHandler({
26
26
  /** Optional cross-tenant read — SystemAdmin only. See set.write.ts. */
27
27
  tenantIdOverride: z.string().min(1).optional(),
28
28
  }),
29
- access: { roles: ["anonymous", "User", "TenantAdmin", "SystemAdmin"] },
29
+ access: { roles: ["anonymous", "User", "TenantAdmin", "SystemAdmin"], anySignedIn: true },
30
30
  rateLimit: { per: "ip+handler", limit: 60, windowSeconds: 60 },
31
31
  description:
32
32
  "Reads one text-block of a tenant by slug and locale together with its body and format; it is pinned to the text-block kind so mail templates and AI prompts in the same table stay unreachable through this anonymous-capable path.",