@cosmicdrift/kumiko-bundled-features 0.406.0 → 0.409.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (333) hide show
  1. package/dist/account-security/feature.js +9 -1
  2. package/dist/admin-shell/feature.d.ts +3 -0
  3. package/dist/admin-shell/feature.js +1 -1
  4. package/dist/agent-tools/agent-manifest.js +1 -0
  5. package/dist/agent-tools/tool-catalog.js +1 -0
  6. package/dist/agent-tools/types.d.ts +4 -1
  7. package/dist/audit/event-classification.js +1 -0
  8. package/dist/auth-email-password/bootstrap.js +1 -0
  9. package/dist/auth-email-password/errors.js +16 -41
  10. package/dist/auth-email-password/web/auth-client.d.ts +8 -32
  11. package/dist/auth-email-password/web/auth-client.js +18 -52
  12. package/dist/auth-email-password/web/auth-redirect.js +2 -2
  13. package/dist/auth-email-password/web/confirm-account-unlock-screen.d.ts +2 -2
  14. package/dist/auth-email-password/web/confirm-account-unlock-screen.js +14 -35
  15. package/dist/auth-email-password/web/index.d.ts +1 -0
  16. package/dist/auth-email-password/web/index.js +1 -0
  17. package/dist/auth-email-password/web/read-path-param.d.ts +1 -0
  18. package/dist/auth-email-password/web/read-path-param.js +4 -0
  19. package/dist/auth-email-password/web/return-path.js +2 -2
  20. package/dist/auth-email-password/web/token-confirm-screen.d.ts +20 -0
  21. package/dist/auth-email-password/web/token-confirm-screen.js +38 -0
  22. package/dist/auth-email-password/web/verify-email-screen.d.ts +2 -2
  23. package/dist/auth-email-password/web/verify-email-screen.js +14 -37
  24. package/dist/auth-foundation/boot-checks.js +24 -12
  25. package/dist/auth-foundation/boot-rules.d.ts +27 -0
  26. package/dist/auth-foundation/boot-rules.js +27 -0
  27. package/dist/auth-mfa/errors.d.ts +1 -1
  28. package/dist/auth-mfa/errors.js +11 -24
  29. package/dist/auth-mfa/feature-exports.js +6 -45
  30. package/dist/auth-mfa/feature.js +7 -18
  31. package/dist/auth-mfa/web/mfa-client.js +11 -25
  32. package/dist/billing-foundation/consumer-protection/termination-notify.js +1 -0
  33. package/dist/billing-foundation/web/plan-price.js +7 -8
  34. package/dist/cap-counter/stock-cap-guard.js +1 -0
  35. package/dist/channel-in-app/constants.d.ts +1 -0
  36. package/dist/channel-in-app/feature.js +2 -0
  37. package/dist/channel-in-app/handlers/read-state-by-keys.query.d.ts +9 -0
  38. package/dist/channel-in-app/handlers/read-state-by-keys.query.js +21 -0
  39. package/dist/channel-in-app/in-app-channel.js +1 -0
  40. package/dist/channel-in-app/tables.js +5 -1
  41. package/dist/contact/challenge.d.ts +14 -0
  42. package/dist/contact/challenge.js +30 -0
  43. package/dist/contact/client/contact-client-source.d.ts +1 -0
  44. package/dist/contact/client/contact-client-source.js +203 -0
  45. package/dist/contact/entity.d.ts +777 -0
  46. package/dist/contact/entity.js +145 -0
  47. package/dist/contact/feature.d.ts +3 -0
  48. package/dist/contact/feature.js +130 -0
  49. package/dist/contact/handlers/access.d.ts +7 -0
  50. package/dist/contact/handlers/access.js +9 -0
  51. package/dist/contact/handlers/attempts.d.ts +14 -0
  52. package/dist/contact/handlers/attempts.js +54 -0
  53. package/dist/contact/handlers/challenge.query.d.ts +9 -0
  54. package/dist/contact/handlers/challenge.query.js +35 -0
  55. package/dist/contact/handlers/forward-request.write.d.ts +9 -0
  56. package/dist/contact/handlers/forward-request.write.js +61 -0
  57. package/dist/contact/handlers/mark-done.write.d.ts +7 -0
  58. package/dist/contact/handlers/mark-done.write.js +30 -0
  59. package/dist/contact/handlers/notify-reporter-in-app.write.d.ts +10 -0
  60. package/dist/contact/handlers/notify-reporter-in-app.write.js +36 -0
  61. package/dist/contact/handlers/open-count.d.ts +2 -0
  62. package/dist/contact/handlers/open-count.js +11 -0
  63. package/dist/contact/handlers/open-count.query.d.ts +3 -0
  64. package/dist/contact/handlers/open-count.query.js +13 -0
  65. package/dist/contact/handlers/replies.query.d.ts +11 -0
  66. package/dist/contact/handlers/replies.query.js +28 -0
  67. package/dist/contact/handlers/reply.write.d.ts +12 -0
  68. package/dist/contact/handlers/reply.write.js +118 -0
  69. package/dist/contact/handlers/report.write.d.ts +16 -0
  70. package/dist/contact/handlers/report.write.js +90 -0
  71. package/dist/contact/handlers/request-delivery.query.d.ts +16 -0
  72. package/dist/contact/handlers/request-delivery.query.js +85 -0
  73. package/dist/contact/handlers/request-detail.query.d.ts +41 -0
  74. package/dist/contact/handlers/request-detail.query.js +32 -0
  75. package/dist/contact/handlers/request-list.query.d.ts +2 -0
  76. package/dist/contact/handlers/request-list.query.js +9 -0
  77. package/dist/contact/handlers/send-reply-mail.write.d.ts +8 -0
  78. package/dist/contact/handlers/send-reply-mail.write.js +82 -0
  79. package/dist/contact/handlers/send-test.write.d.ts +5 -0
  80. package/dist/contact/handlers/send-test.write.js +36 -0
  81. package/dist/contact/handlers/submit.write.d.ts +20 -0
  82. package/dist/contact/handlers/submit.write.js +137 -0
  83. package/dist/contact/handlers/take-over-uploads.d.ts +9 -0
  84. package/dist/contact/handlers/take-over-uploads.js +33 -0
  85. package/dist/contact/i18n.d.ts +6 -0
  86. package/dist/contact/i18n.js +186 -0
  87. package/dist/contact/index.d.ts +5 -0
  88. package/dist/contact/index.js +4 -0
  89. package/dist/contact/lib.d.ts +101 -0
  90. package/dist/contact/lib.js +109 -0
  91. package/dist/contact/mail.d.ts +91 -0
  92. package/dist/contact/mail.js +279 -0
  93. package/dist/contact/options.d.ts +51 -0
  94. package/dist/contact/options.js +32 -0
  95. package/dist/contact/panels.d.ts +2 -0
  96. package/dist/contact/panels.js +21 -0
  97. package/dist/contact/payloads.d.ts +56 -0
  98. package/dist/contact/payloads.js +82 -0
  99. package/dist/contact/pow.d.ts +6 -0
  100. package/dist/contact/pow.js +19 -0
  101. package/dist/contact/screens.d.ts +5 -0
  102. package/dist/contact/screens.js +464 -0
  103. package/dist/contact/subject.d.ts +1 -0
  104. package/dist/contact/subject.js +13 -0
  105. package/dist/contact/user-agent.d.ts +1 -0
  106. package/dist/contact/user-agent.js +35 -0
  107. package/dist/contact/user-data-hooks.d.ts +3 -0
  108. package/dist/contact/user-data-hooks.js +129 -0
  109. package/dist/contact/web/constants.d.ts +127 -0
  110. package/dist/contact/web/constants.js +126 -0
  111. package/dist/contact/web/index.d.ts +1 -0
  112. package/dist/contact/web/index.js +1 -0
  113. package/dist/crypto-shredding/handlers/forget-subject.write.js +5 -13
  114. package/dist/data-retention/feature.js +16 -2
  115. package/dist/data-retention/index.d.ts +1 -0
  116. package/dist/data-retention/index.js +1 -0
  117. package/dist/data-retention/run-retention-cleanup.d.ts +14 -2
  118. package/dist/data-retention/run-retention-cleanup.js +102 -36
  119. package/dist/data-retention/tenant-destruction-hold.d.ts +23 -0
  120. package/dist/data-retention/tenant-destruction-hold.js +132 -0
  121. package/dist/delivery/address-opt-out.js +1 -0
  122. package/dist/delivery/channel-context.d.ts +1 -1
  123. package/dist/delivery/channel-context.js +2 -1
  124. package/dist/delivery/delivery-service.js +18 -8
  125. package/dist/delivery/events.d.ts +1 -0
  126. package/dist/delivery/events.js +2 -0
  127. package/dist/delivery/feature.js +3 -0
  128. package/dist/delivery/handlers/attempts-by-keys.query.d.ts +15 -0
  129. package/dist/delivery/handlers/attempts-by-keys.query.js +35 -0
  130. package/dist/delivery/handlers/log.query.d.ts +1 -0
  131. package/dist/delivery/handlers/log.query.js +1 -1
  132. package/dist/delivery/jobs.js +5 -2
  133. package/dist/delivery/tables.js +12 -2
  134. package/dist/delivery/types.d.ts +2 -0
  135. package/dist/delivery/unsubscribe-page.js +2 -0
  136. package/dist/delivery/web/delivery-channel-cell.js +1 -1
  137. package/dist/delivery/web/delivery-error-cell.js +1 -1
  138. package/dist/delivery/web/delivery-status-cell.js +1 -1
  139. package/dist/delivery/web/delivery-time-cell.js +3 -2
  140. package/dist/delivery/web/delivery-type-cell.js +1 -1
  141. package/dist/delivery/web/public-names.d.ts +1 -0
  142. package/dist/delivery/web/public-names.js +1 -0
  143. package/dist/document-ingest-foundation/boot-checks.js +19 -11
  144. package/dist/document-ingest-foundation/boot-rules.d.ts +17 -0
  145. package/dist/document-ingest-foundation/boot-rules.js +17 -0
  146. package/dist/document-ingest-foundation/events.d.ts +8 -0
  147. package/dist/document-ingest-foundation/events.js +12 -0
  148. package/dist/document-ingest-foundation/feature.js +30 -2
  149. package/dist/document-ingest-foundation/index.d.ts +3 -1
  150. package/dist/document-ingest-foundation/index.js +3 -1
  151. package/dist/document-ingest-foundation/report-ingest-progress.d.ts +14 -0
  152. package/dist/document-ingest-foundation/report-ingest-progress.js +20 -0
  153. package/dist/document-ingest-foundation/tables.d.ts +3 -0
  154. package/dist/document-ingest-foundation/tables.js +26 -0
  155. package/dist/files-tenant-data/hooks.js +4 -1
  156. package/dist/folders/web/folder-manager.js +3 -10
  157. package/dist/folders/web/folder-section.js +1 -1
  158. package/dist/form-draft-user-data/index.js +4 -1
  159. package/dist/inbound-mail-foundation/entities.d.ts +3 -0
  160. package/dist/inbound-mail-foundation/entities.js +2 -0
  161. package/dist/inbound-mail-foundation/events.d.ts +2 -0
  162. package/dist/inbound-mail-foundation/events.js +2 -0
  163. package/dist/inbound-mail-foundation/feature.js +6 -6
  164. package/dist/inbound-mail-foundation/handlers/attach-message-content.write.js +3 -1
  165. package/dist/inbound-mail-foundation/handlers/ingest-message.write.js +5 -0
  166. package/dist/inbound-mail-foundation/handlers/list-messages.query.js +4 -2
  167. package/dist/inbound-mail-foundation/handlers/message-content.d.ts +1 -0
  168. package/dist/inbound-mail-foundation/handlers/message-content.js +8 -0
  169. package/dist/inbound-mail-foundation/handlers/message-content.query.d.ts +2 -0
  170. package/dist/inbound-mail-foundation/handlers/message-content.query.js +1 -0
  171. package/dist/inbound-mail-foundation/projection.d.ts +3 -0
  172. package/dist/inbound-mail-foundation/projection.js +2 -0
  173. package/dist/inbound-mail-foundation/sanitize-inbound-html.d.ts +2 -0
  174. package/dist/inbound-mail-foundation/sanitize-inbound-html.js +135 -0
  175. package/dist/inbound-mail-foundation/types.js +1 -0
  176. package/dist/jobs/job-run-logger.js +16 -20
  177. package/dist/ledger/handlers/reports.query.js +25 -27
  178. package/dist/ledger/recurring.js +1 -0
  179. package/dist/notes-history/web/notes-section.js +3 -2
  180. package/dist/personal-access-tokens/feature.js +5 -18
  181. package/dist/personal-access-tokens/handlers/create.write.js +2 -5
  182. package/dist/secrets/handlers/delete.write.d.ts +4 -0
  183. package/dist/secrets/handlers/delete.write.js +9 -4
  184. package/dist/secrets/handlers/list.query.d.ts +6 -1
  185. package/dist/secrets/handlers/list.query.js +7 -3
  186. package/dist/secrets/handlers/set.write.d.ts +4 -0
  187. package/dist/secrets/handlers/set.write.js +10 -4
  188. package/dist/secrets/secret-scope.d.ts +17 -0
  189. package/dist/secrets/secret-scope.js +18 -0
  190. package/dist/sessions/feature.d.ts +3 -0
  191. package/dist/sessions/feature.js +13 -19
  192. package/dist/sessions/handlers/last-activity-probe.query.d.ts +7 -0
  193. package/dist/sessions/handlers/last-activity-probe.query.js +40 -0
  194. package/dist/sessions/handlers/last-activity-probe.route.d.ts +2 -0
  195. package/dist/sessions/handlers/last-activity-probe.route.js +30 -0
  196. package/dist/sessions/screens.js +1 -0
  197. package/dist/sessions/session-callbacks.d.ts +2 -0
  198. package/dist/sessions/session-callbacks.js +9 -7
  199. package/dist/sessions/web/i18n.js +4 -1
  200. package/dist/shared/assert-billing-live.d.ts +2 -0
  201. package/dist/shared/assert-billing-live.js +7 -0
  202. package/dist/shared/collect-extension-options.d.ts +1 -0
  203. package/dist/shared/collect-extension-options.js +8 -0
  204. package/dist/shared/index.d.ts +7 -1
  205. package/dist/shared/index.js +7 -1
  206. package/dist/shared/late-bound-slot.d.ts +5 -0
  207. package/dist/shared/late-bound-slot.js +13 -0
  208. package/dist/shared/mail-locale-templates.d.ts +1 -0
  209. package/dist/shared/mail-locale-templates.js +1 -1
  210. package/dist/shared/price-env-shape.d.ts +11 -0
  211. package/dist/shared/price-env-shape.js +15 -0
  212. package/dist/shared/purge-row-file-refs.d.ts +1 -0
  213. package/dist/shared/purge-row-file-refs.js +1 -1
  214. package/dist/shared/read-feature-export-fn.d.ts +2 -0
  215. package/dist/shared/read-feature-export-fn.js +11 -0
  216. package/dist/shared/signup-handover.js +3 -5
  217. package/dist/shared/tenant-destruction-hold.d.ts +23 -0
  218. package/dist/shared/tenant-destruction-hold.js +15 -0
  219. package/dist/shared/unprocessable.d.ts +4 -0
  220. package/dist/shared/unprocessable.js +4 -0
  221. package/dist/shared/web/index.d.ts +3 -0
  222. package/dist/shared/web/index.js +3 -0
  223. package/dist/subscription-paddle/feature.d.ts +1 -5
  224. package/dist/subscription-paddle/feature.js +7 -9
  225. package/dist/subscription-paddle/runtime.js +3 -7
  226. package/dist/subscription-stripe/feature.d.ts +1 -5
  227. package/dist/subscription-stripe/feature.js +7 -9
  228. package/dist/subscription-stripe/runtime.js +3 -7
  229. package/dist/tags/entity.js +1 -0
  230. package/dist/tags/web/tag-chip.d.ts +7 -0
  231. package/dist/tags/web/tag-chip.js +4 -0
  232. package/dist/tags/web/tag-filter.js +2 -5
  233. package/dist/tags/web/tag-manager.js +1 -1
  234. package/dist/tags/web/tag-section.js +3 -6
  235. package/dist/tags/web/tags-cell.js +2 -5
  236. package/dist/template-resolver/compile-document-body.js +12 -17
  237. package/dist/template-resolver/handlers/by-tenant.query.js +3 -1
  238. package/dist/template-resolver/handlers/discard-draft.write.js +1 -0
  239. package/dist/template-resolver/handlers/overview.query.js +3 -1
  240. package/dist/template-resolver/handlers/send-test.write.js +2 -4
  241. package/dist/template-resolver/handlers/toggle-status.write.js +3 -0
  242. package/dist/template-resolver/linked-resources.js +6 -5
  243. package/dist/template-resolver/store-template-resource.js +5 -10
  244. package/dist/template-resolver/web/document-images.js +6 -6
  245. package/dist/template-resolver/web/document-insert-fields.js +22 -4
  246. package/dist/template-resolver/web/document-schema.js +11 -12
  247. package/dist/template-resolver/web/tiptap-attribute-parse-rule.d.ts +15 -0
  248. package/dist/template-resolver/web/tiptap-attribute-parse-rule.js +11 -0
  249. package/dist/tenant/i18n.js +3 -0
  250. package/dist/tenant/schema/tenant.d.ts +9 -7
  251. package/dist/tenant/schema/tenant.js +1 -0
  252. package/dist/tenant/web/member-roles-cell.js +1 -1
  253. package/dist/tenant/web/member-status-cell.js +1 -1
  254. package/dist/tenant-inactivity/check-inactive-tenants.d.ts +3 -0
  255. package/dist/tenant-inactivity/check-inactive-tenants.js +184 -0
  256. package/dist/tenant-inactivity/constants.d.ts +10 -0
  257. package/dist/tenant-inactivity/constants.js +10 -0
  258. package/dist/tenant-inactivity/email-templates.d.ts +3 -0
  259. package/dist/tenant-inactivity/email-templates.js +16 -0
  260. package/dist/tenant-inactivity/feature.d.ts +8 -0
  261. package/dist/tenant-inactivity/feature.js +45 -0
  262. package/dist/tenant-inactivity/handlers/inactivity-state.query.d.ts +11 -0
  263. package/dist/tenant-inactivity/handlers/inactivity-state.query.js +45 -0
  264. package/dist/tenant-inactivity/handlers/keep-account.write.d.ts +8 -0
  265. package/dist/tenant-inactivity/handlers/keep-account.write.js +48 -0
  266. package/dist/tenant-inactivity/inactivity-plan.d.ts +51 -0
  267. package/dist/tenant-inactivity/inactivity-plan.js +113 -0
  268. package/dist/tenant-inactivity/index.d.ts +5 -0
  269. package/dist/tenant-inactivity/index.js +3 -0
  270. package/dist/tenant-inactivity/keep-token.d.ts +16 -0
  271. package/dist/tenant-inactivity/keep-token.js +24 -0
  272. package/dist/tenant-inactivity/mail-notifications.d.ts +4 -0
  273. package/dist/tenant-inactivity/mail-notifications.js +42 -0
  274. package/dist/tenant-inactivity/options.d.ts +27 -0
  275. package/dist/tenant-inactivity/options.js +5 -0
  276. package/dist/tenant-inactivity/remote-activity.d.ts +15 -0
  277. package/dist/tenant-inactivity/remote-activity.js +24 -0
  278. package/dist/tenant-inactivity/state-store.d.ts +10 -0
  279. package/dist/tenant-inactivity/state-store.js +50 -0
  280. package/dist/tenant-inactivity/state-table.d.ts +109 -0
  281. package/dist/tenant-inactivity/state-table.js +38 -0
  282. package/dist/tenant-lifecycle/boot-checks.js +8 -3
  283. package/dist/tenant-lifecycle/boot-rules.d.ts +12 -0
  284. package/dist/tenant-lifecycle/boot-rules.js +12 -0
  285. package/dist/tenant-lifecycle/feature.js +17 -2
  286. package/dist/tenant-lifecycle/handlers/request-destruction.write.js +11 -67
  287. package/dist/tenant-lifecycle/index.d.ts +1 -0
  288. package/dist/tenant-lifecycle/index.js +1 -0
  289. package/dist/tenant-lifecycle/request-tenant-destruction.d.ts +20 -0
  290. package/dist/tenant-lifecycle/request-tenant-destruction.js +66 -0
  291. package/dist/tenant-lifecycle/retention-config-destroy-hooks.d.ts +5 -0
  292. package/dist/tenant-lifecycle/retention-config-destroy-hooks.js +29 -0
  293. package/dist/tenant-lifecycle/run-tenant-destroy.d.ts +3 -0
  294. package/dist/tenant-lifecycle/run-tenant-destroy.js +43 -5
  295. package/dist/tenant-lifecycle/stages.d.ts +2 -0
  296. package/dist/tenant-lifecycle/stages.js +23 -2
  297. package/dist/tenant-lifecycle/testing.js +1 -1
  298. package/dist/tier-engine/caps-for-tier-from-map.d.ts +5 -0
  299. package/dist/tier-engine/caps-for-tier-from-map.js +12 -0
  300. package/dist/tier-engine/compose-app.d.ts +0 -22
  301. package/dist/tier-engine/compose-app.js +9 -16
  302. package/dist/tier-engine/index.d.ts +1 -0
  303. package/dist/tier-engine/index.js +1 -0
  304. package/dist/user/handlers/detail.query.d.ts +1 -1
  305. package/dist/user-data-rights/feature.js +2 -0
  306. package/dist/user-data-rights/run-forget-cleanup.js +2 -0
  307. package/dist/user-data-rights/web/privacy-center-screen.js +1 -1
  308. package/dist/user-data-rights/zip-path.js +1 -0
  309. package/dist/user-data-rights-defaults/hooks/config-value.userdata-hook.d.ts +1 -1
  310. package/dist/user-data-rights-defaults/hooks/config-value.userdata-hook.js +7 -20
  311. package/dist/user-data-rights-defaults/hooks/delivery-attempt.userdata-hook.js +3 -1
  312. package/dist/user-data-rights-defaults/hooks/forget-own-rows-delete-hook.d.ts +10 -0
  313. package/dist/user-data-rights-defaults/hooks/forget-own-rows-delete-hook.js +26 -0
  314. package/dist/user-data-rights-defaults/hooks/notification-preference.userdata-hook.d.ts +1 -1
  315. package/dist/user-data-rights-defaults/hooks/notification-preference.userdata-hook.js +7 -20
  316. package/dist/user-profile/handlers/change-email.write.js +2 -4
  317. package/dist/user-profile/web/profile-screen.js +2 -3
  318. package/kumiko-es-tables.json +12 -0
  319. package/package.json +46 -12
  320. package/src/admin-shell/changes.json +6 -0
  321. package/src/agent-tools/changes.json +6 -0
  322. package/src/channel-in-app/changes.json +7 -0
  323. package/src/contact/changes.json +27 -0
  324. package/src/data-retention/changes.json +6 -0
  325. package/src/delivery/changes.json +7 -0
  326. package/src/document-ingest-foundation/changes.json +6 -0
  327. package/src/files-tenant-data/changes.json +6 -0
  328. package/src/inbound-mail-foundation/changes.json +13 -0
  329. package/src/secrets/changes.json +6 -0
  330. package/src/sessions/changes.json +6 -0
  331. package/src/tenant-inactivity/changes.json +8 -0
  332. package/src/tenant-lifecycle/changes.json +18 -0
  333. package/src/tier-engine/changes.json +6 -0
@@ -11,6 +11,7 @@ import { featureWithEnvSchema } from "@cosmicdrift/kumiko-framework/env";
11
11
  import { egress } from "@cosmicdrift/kumiko-framework/http";
12
12
  import { Temporal } from "@cosmicdrift/kumiko-types/temporal";
13
13
  import * as z from "zod";
14
+ import { priceEnvSchema } from "../shared/index.js";
14
15
  import { makeCheckoutConfigQuery } from "./checkout-config.query.js";
15
16
  import { createPaddleCancelSubscription, createPaddleCheckoutSession, createPaddlePortalSession, createPaddleResumeSubscription, } from "./checkout-methods.js";
16
17
  import { servePaddleCheckoutPage } from "./checkout-page.js";
@@ -45,21 +46,18 @@ export const subscriptionPaddleEnvSchema = z.object({
45
46
  .describe("Paddle.js client-side token (public). Bridge-fallback for the config key.")
46
47
  .optional(),
47
48
  });
49
+ const PADDLE_PRICE_ENV = {
50
+ envPrefix: "PADDLE",
51
+ label: "Paddle",
52
+ priceIdPrefix: "pri_",
53
+ };
48
54
  /** Paddle env block plus one `PADDLE_PRICE_<NAME>` slot per plan price the app
49
55
  * maps to a tier, e.g. `paddleEnvSchema({ prices: ["PRO", "TEAM"] })`.
50
56
  * Shares its bridge fields with `subscriptionPaddleEnvSchema`, so spreading
51
57
  * it into `composeEnvSchema({ extend })` next to the mounted feature is no
52
58
  * key clash. */
53
59
  export function paddleEnvSchema(options) {
54
- const priceShape = Object.fromEntries(options.prices.map((price) => [
55
- `PADDLE_PRICE_${price}`,
56
- z
57
- .string()
58
- .regex(/^pri_/, `PADDLE_PRICE_${price} must start with 'pri_'`)
59
- .optional()
60
- .describe(`Paddle price id (\`pri_...\`) of the ${price} plan.`),
61
- ]));
62
- return z.object({ ...subscriptionPaddleEnvSchema.shape, ...priceShape });
60
+ return priceEnvSchema(subscriptionPaddleEnvSchema, PADDLE_PRICE_ENV, options.prices);
63
61
  }
64
62
  export function createSubscriptionPaddleFeature(options = {}) {
65
63
  validateOneOffPriceIds("subscription-paddle", options.oneOffPriceIds ?? []);
@@ -9,7 +9,8 @@
9
9
  import { parseStoredSecret, } from "@cosmicdrift/kumiko-bundled-features/billing-foundation";
10
10
  import { requireSecretsContext } from "@cosmicdrift/kumiko-bundled-features/secrets";
11
11
  import { SYSTEM_TENANT_ID, } from "@cosmicdrift/kumiko-framework/engine";
12
- import { FeatureDisabledError, UnconfiguredError } from "@cosmicdrift/kumiko-framework/errors";
12
+ import { UnconfiguredError } from "@cosmicdrift/kumiko-framework/errors";
13
+ import { assertBillingLive } from "../shared/index.js";
13
14
  import { createPaddleHttp } from "./client.js";
14
15
  import { PADDLE_BASE_URLS, PaddleEnvironments, SUBSCRIPTION_PADDLE_FEATURE, } from "./constants.js";
15
16
  function hintFor(shortName) {
@@ -67,12 +68,7 @@ export function createPaddleRuntimes(deps) {
67
68
  baseUrl: await baseUrlFor(ctx),
68
69
  apiKey: await ctxSecret(ctx, deps.apiKeyHandle, deps.fallback.apiKey, "api-key"),
69
70
  }, request),
70
- assertBillingLive: async (ctx, handlerName = "create-checkout-session") => {
71
- const live = ctx.config ? await ctx.config(deps.billingLiveHandle) : undefined;
72
- if (live !== true) {
73
- throw new FeatureDisabledError(SUBSCRIPTION_PADDLE_FEATURE, handlerName);
74
- }
75
- },
71
+ assertBillingLive: (ctx, handlerName = "create-checkout-session") => assertBillingLive(ctx, deps.billingLiveHandle, SUBSCRIPTION_PADDLE_FEATURE, handlerName),
76
72
  isBillingEnabled: async (ctx) => {
77
73
  const live = ctx.config ? await ctx.config(deps.billingLiveHandle) : undefined;
78
74
  if (live !== true)
@@ -13,9 +13,6 @@ export declare const subscriptionStripeEnvSchema: z.ZodObject<{
13
13
  STRIPE_WEBHOOK_SECRET: z.ZodOptional<z.ZodString>;
14
14
  STRIPE_API_KEY: z.ZodOptional<z.ZodString>;
15
15
  }, z.core.$strip>;
16
- type StripePriceEnvShape<TPrice extends string> = {
17
- [Key in `STRIPE_PRICE_${TPrice}`]: z.ZodOptional<z.ZodString>;
18
- };
19
16
  /** Stripe env block plus one `STRIPE_PRICE_<NAME>` slot per price the app
20
17
  * maps to a tier, e.g. `stripeEnvSchema({ prices: ["PRO", "TEAM"] })`.
21
18
  * Shares its bridge fields with `subscriptionStripeEnvSchema`, so spreading
@@ -26,7 +23,7 @@ export declare function stripeEnvSchema<const TPrice extends string>(options: {
26
23
  }): z.ZodObject<{
27
24
  STRIPE_WEBHOOK_SECRET: z.ZodOptional<z.ZodString>;
28
25
  STRIPE_API_KEY: z.ZodOptional<z.ZodString>;
29
- } & StripePriceEnvShape<TPrice> extends infer T ? { -readonly [P in keyof T]: T[P]; } : never, z.core.$strip>;
26
+ } & import("../shared/price-env-shape.ts").PriceEnvShape<"STRIPE", TPrice> extends infer T ? { -readonly [P in keyof T]: T[P]; } : never, z.core.$strip>;
30
27
  export type SubscriptionStripeOptions = {
31
28
  /** Bridge-fallback webhook secret. Optional: v2 reads from the
32
29
  * `subscription-stripe:config:webhook-secret` key (backing:"secrets").
@@ -63,4 +60,3 @@ export type SubscriptionStripeOptions = {
63
60
  * extension with entityName "stripe".
64
61
  */
65
62
  export declare function createSubscriptionStripeFeature(options?: SubscriptionStripeOptions): FeatureWithEnvSchema<FeatureDefinition, typeof subscriptionStripeEnvSchema.shape>;
66
- export {};
@@ -35,6 +35,7 @@ import { validateOneOffPriceIds, } from "@cosmicdrift/kumiko-bundled-features/bi
35
35
  import { access, createSystemConfig, defineFeature, } from "@cosmicdrift/kumiko-framework/engine";
36
36
  import { featureWithEnvSchema } from "@cosmicdrift/kumiko-framework/env";
37
37
  import * as z from "zod";
38
+ import { priceEnvSchema } from "../shared/index.js";
38
39
  import { STRIPE_API_KEY_CONFIG, STRIPE_BILLING_LIVE_CONFIG, STRIPE_PROVIDER_NAME, STRIPE_WEBHOOK_SECRET_CONFIG, SUBSCRIPTION_STRIPE_FEATURE, } from "./constants.js";
39
40
  import { createStripeCancelSubscription, createStripeCheckoutSession, createStripePlanSwitchSession, createStripePortalSession, createStripePriceCache, createStripeResumeSubscription, createStripeRetrievePrices, createStripeRetrieveSubscription, } from "./plugin-methods.js";
40
41
  import { createStripeRuntimes } from "./runtime.js";
@@ -61,21 +62,18 @@ export const subscriptionStripeEnvSchema = z.object({
61
62
  .meta({ kumiko: { pulumi: { secret: true } } })
62
63
  .optional(),
63
64
  });
65
+ const STRIPE_PRICE_ENV = {
66
+ envPrefix: "STRIPE",
67
+ label: "Stripe",
68
+ priceIdPrefix: "price_",
69
+ };
64
70
  /** Stripe env block plus one `STRIPE_PRICE_<NAME>` slot per price the app
65
71
  * maps to a tier, e.g. `stripeEnvSchema({ prices: ["PRO", "TEAM"] })`.
66
72
  * Shares its bridge fields with `subscriptionStripeEnvSchema`, so spreading
67
73
  * it into `composeEnvSchema({ extend })` next to the mounted feature is no
68
74
  * key clash. */
69
75
  export function stripeEnvSchema(options) {
70
- const priceShape = Object.fromEntries(options.prices.map((price) => [
71
- `STRIPE_PRICE_${price}`,
72
- z
73
- .string()
74
- .regex(/^price_/, `STRIPE_PRICE_${price} must start with 'price_'`)
75
- .optional()
76
- .describe(`Stripe price id (\`price_...\`) of the ${price} plan.`),
77
- ]));
78
- return z.object({ ...subscriptionStripeEnvSchema.shape, ...priceShape });
76
+ return priceEnvSchema(subscriptionStripeEnvSchema, STRIPE_PRICE_ENV, options.prices);
79
77
  }
80
78
  /**
81
79
  * Factory for the subscription-stripe feature. Always mounts (no
@@ -27,8 +27,9 @@
27
27
  import { parseStoredSecret } from "@cosmicdrift/kumiko-bundled-features/billing-foundation";
28
28
  import { requireSecretsContext } from "@cosmicdrift/kumiko-bundled-features/secrets";
29
29
  import { SYSTEM_TENANT_ID, } from "@cosmicdrift/kumiko-framework/engine";
30
- import { FeatureDisabledError, UnconfiguredError } from "@cosmicdrift/kumiko-framework/errors";
30
+ import { UnconfiguredError } from "@cosmicdrift/kumiko-framework/errors";
31
31
  import Stripe from "stripe";
32
+ import { assertBillingLive } from "../shared/index.js";
32
33
  import { SUBSCRIPTION_STRIPE_FEATURE } from "./constants.js";
33
34
  const API_KEY_HINT = "Set the Stripe API key via config:write:set on `subscription-stripe:config:api-key` (or seed it from STRIPE_API_KEY during the env bridge).";
34
35
  /** Memoize Stripe clients by api-key string — a fresh client is built only
@@ -82,12 +83,7 @@ export function createStripeRuntimes(deps) {
82
83
  ctx: {
83
84
  // @wrapper-known semantic-alias
84
85
  clientForCtx: async (ctx) => clientFor(await ctxApiKey(ctx)),
85
- assertBillingLive: async (ctx, handlerName = "create-checkout-session") => {
86
- const live = ctx.config ? await ctx.config(deps.billingLiveHandle) : undefined;
87
- if (live !== true) {
88
- throw new FeatureDisabledError(SUBSCRIPTION_STRIPE_FEATURE, handlerName);
89
- }
90
- },
86
+ assertBillingLive: (ctx, handlerName = "create-checkout-session") => assertBillingLive(ctx, deps.billingLiveHandle, SUBSCRIPTION_STRIPE_FEATURE, handlerName),
91
87
  isBillingEnabled: async (ctx) => {
92
88
  const live = ctx.config ? await ctx.config(deps.billingLiveHandle) : undefined;
93
89
  if (live !== true)
@@ -48,6 +48,7 @@ export const tagEntity = createEntity({
48
48
  // Cross-entity views compose in the read-layer (no JOIN):
49
49
  // - tags of an entity → list assignments filter { field: "entityId", op: "eq" }
50
50
  // - entities with a tag → list assignments filter { field: "tagId", op: "eq" }
51
+ // guard:dup-ok own table and fields; a shared definition would couple the schemas and migrations of tags and folders
51
52
  export function createTagAssignmentEntity(access, parents) {
52
53
  return createEntity({
53
54
  table: "read_tag_assignments",
@@ -1,5 +1,12 @@
1
1
  import type { ReactNode } from "react";
2
2
  export declare function contrastText(color: string): "#000000" | "#ffffff" | null;
3
+ export declare function TagChipById({ id, byId, }: {
4
+ readonly id: string;
5
+ readonly byId: ReadonlyMap<string, {
6
+ readonly name: string;
7
+ readonly color?: string | null | undefined;
8
+ }>;
9
+ }): ReactNode;
3
10
  export declare function TagChip({ name, color, }: {
4
11
  readonly name: string;
5
12
  readonly color?: string | null;
@@ -37,6 +37,10 @@ const BASE_STYLE = {
37
37
  whiteSpace: "nowrap",
38
38
  };
39
39
  const NEUTRAL = { backgroundColor: "#e5e7eb", color: "#374151" };
40
+ export function TagChipById({ id, byId, }) {
41
+ const tag = byId.get(id);
42
+ return _jsx(TagChip, { name: tag?.name ?? id, color: tag?.color });
43
+ }
40
44
  export function TagChip({ name, color, }) {
41
45
  const fg = color != null && color !== "" ? contrastText(color) : null;
42
46
  const palette = fg !== null && color != null ? { backgroundColor: color, color: fg } : NEUTRAL;
@@ -15,7 +15,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
15
15
  import { useListUrlState, usePrimitives, useQuery, useTranslation, } from "@cosmicdrift/kumiko-renderer";
16
16
  import { useState } from "react";
17
17
  import { TagsQueries } from "./constants.js";
18
- import { TagChip } from "./tag-chip.js";
18
+ import { TagChipById } from "./tag-chip.js";
19
19
  import { TagPicker } from "./tag-picker.js";
20
20
  // Tags chosen but zero matching entities → filter to a value that matches no row
21
21
  // (so the list shows empty), instead of clearing the filter (which shows all).
@@ -47,8 +47,5 @@ export function TagFilter({ entityName, screenId, }) {
47
47
  urlState.setFilter("id", ids.length > 0 ? ids : [NO_MATCH]);
48
48
  };
49
49
  const byId = new Map((catalog.data?.rows ?? []).map((tg) => [tg.id, tg]));
50
- return (_jsxs("div", { className: "flex flex-wrap items-center gap-1", children: [_jsx(Button, { variant: "secondary", onClick: () => setOpen(true), testId: "tag-filter-open", children: t("tags.filter.label") }), selected.map((id) => {
51
- const tag = byId.get(id);
52
- return _jsx(TagChip, { name: tag?.name ?? id, color: tag?.color }, id);
53
- }), selected.length > 0 && (_jsx(Button, { variant: "secondary", onClick: () => applyFilter([]), testId: "tag-filter-clear", children: t("tags.filter.clear") })), _jsx(TagPicker, { entityType: entityName, value: selected, onChange: applyFilter, open: open, onOpenChange: setOpen })] }));
50
+ return (_jsxs("div", { className: "flex flex-wrap items-center gap-1", children: [_jsx(Button, { variant: "secondary", onClick: () => setOpen(true), testId: "tag-filter-open", children: t("tags.filter.label") }), selected.map((id) => (_jsx(TagChipById, { id: id, byId: byId }, id))), selected.length > 0 && (_jsx(Button, { variant: "secondary", onClick: () => applyFilter([]), testId: "tag-filter-clear", children: t("tags.filter.clear") })), _jsx(TagPicker, { entityType: entityName, value: selected, onChange: applyFilter, open: open, onOpenChange: setOpen })] }));
54
51
  }
@@ -12,7 +12,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
12
12
  import { useDispatcher, usePrimitives, useQuery, useTranslation, } from "@cosmicdrift/kumiko-renderer";
13
13
  import { pluralKey } from "@cosmicdrift/kumiko-renderer/headless";
14
14
  import { useState } from "react";
15
- import { useDispatchedWrites } from "../../shared/web/use-dispatched-writes.js";
15
+ import { useDispatchedWrites } from "../../shared/web/index.js";
16
16
  import { TagsHandlers, TagsQueries } from "./constants.js";
17
17
  import { TagChip } from "./tag-chip.js";
18
18
  // A small fixed palette so labels stay visually distinct without a color-wheel
@@ -13,9 +13,9 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
13
  // (RenderEdit passes { entityName, entityId }).
14
14
  import { usePrimitives, useQuery, useTranslation } from "@cosmicdrift/kumiko-renderer";
15
15
  import { useState } from "react";
16
- import { useDispatchedWrites } from "../../shared/web/use-dispatched-writes.js";
16
+ import { useDispatchedWrites } from "../../shared/web/index.js";
17
17
  import { TagsHandlers, TagsQueries } from "./constants.js";
18
- import { TagChip } from "./tag-chip.js";
18
+ import { TagChipById } from "./tag-chip.js";
19
19
  import { TagPicker } from "./tag-picker.js";
20
20
  // What changed between the entity's current tags and the picker's new selection.
21
21
  export function tagSelectionDelta(prev, next) {
@@ -83,8 +83,5 @@ export function TagSection({ entityName, entityId, }) {
83
83
  }
84
84
  })();
85
85
  };
86
- return (_jsxs("div", { "data-testid": "tags-section", className: "flex flex-col gap-2", children: [_jsxs("div", { className: "flex flex-wrap items-center gap-1", children: [assignedIds.length === 0 ? (_jsx(Text, { variant: "small", children: t("tags.section.none") })) : (assignedIds.map((id) => {
87
- const tag = byId.get(id);
88
- return _jsx(TagChip, { name: tag?.name ?? id, color: tag?.color }, id);
89
- })), _jsx(Button, { variant: "secondary", disabled: busy, onClick: () => setPickerOpen(true), testId: "tags-section-edit", children: busy ? t("tags.section.working") : t("tags.section.edit") })] }), _jsx(TagPicker, { entityType: entityName, value: assignedIds, onChange: onPicked, open: pickerOpen, onOpenChange: setPickerOpen }), errorKey !== null && (_jsx(Banner, { variant: "error", testId: "tags-section-action-error", children: _jsx(Text, { children: t(errorKey) }) }))] }));
86
+ return (_jsxs("div", { "data-testid": "tags-section", className: "flex flex-col gap-2", children: [_jsxs("div", { className: "flex flex-wrap items-center gap-1", children: [assignedIds.length === 0 ? (_jsx(Text, { variant: "small", children: t("tags.section.none") })) : (assignedIds.map((id) => _jsx(TagChipById, { id: id, byId: byId }, id))), _jsx(Button, { variant: "secondary", disabled: busy, onClick: () => setPickerOpen(true), testId: "tags-section-edit", children: busy ? t("tags.section.working") : t("tags.section.edit") })] }), _jsx(TagPicker, { entityType: entityName, value: assignedIds, onChange: onPicked, open: pickerOpen, onOpenChange: setPickerOpen }), errorKey !== null && (_jsx(Banner, { variant: "error", testId: "tags-section-action-error", children: _jsx(Text, { children: t(errorKey) }) }))] }));
90
87
  }
@@ -16,7 +16,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
16
16
  // assignment sets add a server-side entitiesByTag query + join filter.
17
17
  import { useQuery } from "@cosmicdrift/kumiko-renderer";
18
18
  import { TagsQueries } from "./constants.js";
19
- import { TagChip } from "./tag-chip.js";
19
+ import { TagChipById } from "./tag-chip.js";
20
20
  export function TagsCell({ row }) {
21
21
  const entityId = String(row["id"] ?? "");
22
22
  const catalog = useQuery(TagsQueries.tagList, {});
@@ -31,8 +31,5 @@ export function TagsCell({ row }) {
31
31
  .map((a) => a.tagId);
32
32
  if (tagIds.length === 0)
33
33
  return null;
34
- return (_jsx("div", { className: "flex flex-wrap gap-1", "data-testid": "tags-cell", children: tagIds.map((id) => {
35
- const tag = byId.get(id);
36
- return _jsx(TagChip, { name: tag?.name ?? id, color: tag?.color }, id);
37
- }) }));
34
+ return (_jsx("div", { className: "flex flex-wrap gap-1", "data-testid": "tags-cell", children: tagIds.map((id) => (_jsx(TagChipById, { id: id, byId: byId }, id))) }));
38
35
  }
@@ -175,29 +175,24 @@ function appendStyle(element, style) {
175
175
  const existing = element.getAttribute("style");
176
176
  element.setAttribute("style", existing === null ? style : `${existing};${style}`);
177
177
  }
178
- // Unique valid resource keys in document order.
179
- export function collectDocumentResourceKeys(html) {
178
+ function collectUniqueValidAttributes(html, selector, attribute, isValid) {
180
179
  return withParsedDocument(html, (root) => {
181
- const keys = new Set();
182
- for (const element of Array.from(root.querySelectorAll("img[data-resource]"))) {
183
- const key = element.getAttribute("data-resource") ?? "";
184
- if (isDocumentResourceKey(key))
185
- keys.add(key);
180
+ const values = new Set();
181
+ for (const element of Array.from(root.querySelectorAll(selector))) {
182
+ const value = element.getAttribute(attribute) ?? "";
183
+ if (isValid(value))
184
+ values.add(value);
186
185
  }
187
- return [...keys];
186
+ return [...values];
188
187
  });
189
188
  }
189
+ // Unique valid resource keys in document order.
190
+ export function collectDocumentResourceKeys(html) {
191
+ return collectUniqueValidAttributes(html, "img[data-resource]", "data-resource", isDocumentResourceKey);
192
+ }
190
193
  // Unique valid names of the images blocks in document order.
191
194
  export function collectDocumentImageVariables(html) {
192
- return withParsedDocument(html, (root) => {
193
- const names = new Set();
194
- for (const element of Array.from(root.querySelectorAll("div[data-images]"))) {
195
- const name = element.getAttribute("data-images") ?? "";
196
- if (isDocumentReferenceName(name))
197
- names.add(name);
198
- }
199
- return [...names];
200
- });
195
+ return collectUniqueValidAttributes(html, "div[data-images]", "data-images", isDocumentReferenceName);
201
196
  }
202
197
  function rewriteImagesBlock(element, state, options) {
203
198
  const name = element.getAttribute("data-images") ?? "";
@@ -21,7 +21,9 @@ export const byTenantQuery = defineQueryHandler({
21
21
  const policy = deliveryPolicyOf(ctx.registry);
22
22
  const served = await filterDeliveredTo(ctx.db, policy, query.user, rows);
23
23
  return {
24
- blocks: served.map((row) => ({
24
+ blocks: served.map(
25
+ // guard:dup-ok block field selection; only the object-literal shape matches other mappers
26
+ (row) => ({
25
27
  slug: row.slug,
26
28
  locale: row.locale,
27
29
  title: row.title,
@@ -44,6 +44,7 @@ function createDiscardDraftHandler(policy, name, target, description) {
44
44
  export function makeDiscardDraftWrite(policy) {
45
45
  return createDiscardDraftHandler(policy, "discard-draft", "own", "Throws away the open draft of one template resource of the caller's tenant so the editor shows the active version again; the served version is untouched. Refused with no_draft when there is no draft. Outside the templates the app lists in tenantEditable only a SystemAdmin may use it.");
46
46
  }
47
+ // guard:dup-ok one configured createDiscardDraftHandler instance; only name, scope and description differ
47
48
  export function makeDiscardDraftSystemWrite(policy) {
48
49
  return createDiscardDraftHandler(policy, "discard-draft-system", "system", "Throws away the open draft of one system-default template; the served version stays. SystemAdmin only, refused with no_draft when there is no draft.");
49
50
  }
@@ -180,7 +180,9 @@ function buildDrafts(groups, user, policy) {
180
180
  function withUsage(draft, layoutSlugByDocument, registry, effectiveLayouts) {
181
181
  let usedBy = [];
182
182
  if (draft.kind === "mail" || draft.kind === "mail-layout") {
183
- usedBy = collectTemplateUsage(registry, draft.slug, draft.kind, effectiveLayouts).map((entry) => ({
183
+ usedBy = collectTemplateUsage(registry, draft.slug, draft.kind, effectiveLayouts).map(
184
+ // guard:dup-ok usage field selection; only the object-literal shape matches other mappers
185
+ (entry) => ({
184
186
  qualifiedName: entry.qualifiedName,
185
187
  feature: entry.feature,
186
188
  notification: entry.notification,
@@ -1,6 +1,7 @@
1
1
  import { defineWriteHandler } from "@cosmicdrift/kumiko-framework/engine";
2
2
  import { UnprocessableError, writeFailure } from "@cosmicdrift/kumiko-framework/errors";
3
3
  import * as z from "zod";
4
+ import { unprocessable } from "../../shared/index.js";
4
5
  import { refuseTemplateEdit, templateEditAccess, } from "../template-edit-policy.js";
5
6
  import { renderTemplatePreview } from "../template-preview.js";
6
7
  import { TEST_MAIL_SUBJECT_PREFIX } from "../web/constants.js";
@@ -10,10 +11,7 @@ import { localeSchema, templateSlugSchema } from "./shared.js";
10
11
  const TEST_MAIL_RATE_LIMIT = { limit: 10, windowSeconds: 3600 };
11
12
  // Transport errors can carry provider responses or the address, so the client only gets a fixed code.
12
13
  function testMailFailed(code) {
13
- return writeFailure(new UnprocessableError(TemplateResolverErrors.testMailFailed, {
14
- i18nKey: "templateResolver.errors.testMail.failed",
15
- details: { code },
16
- }));
14
+ return unprocessable(TemplateResolverErrors.testMailFailed, "templateResolver.errors.testMail.failed", { code });
17
15
  }
18
16
  function errorCodeOf(error) {
19
17
  const code = error instanceof Error ? Reflect.get(error, "code") : undefined;
@@ -69,12 +69,15 @@ function createStatusUpdateHandler(policy, name, target, status, description) {
69
69
  export function makeArchiveWrite(policy) {
70
70
  return createStatusUpdateHandler(policy, "archive", "own", "archived", "Sets one template resource of the caller's tenant to archived so the resolver stops serving it while the row and its content survive; use it to retire a template reversibly instead of deleting it. An open draft stays. Outside the templates the app lists in tenantEditable only a SystemAdmin may use it.");
71
71
  }
72
+ // guard:dup-ok one configured createStatusUpdateHandler instance; only name, scope, status and description differ
72
73
  export function makePublishWrite(policy) {
73
74
  return createStatusUpdateHandler(policy, "publish", "own", "active", "Sets one template resource of the caller's tenant to active so the resolver starts serving it; use it to release a draft written by upsert-tenant (a draft saved beside an active version replaces it), or to bring an archived template back; a version with unknown placeholders or unused required variables is refused and the served version stays. Outside the templates the app lists in tenantEditable only a SystemAdmin may use it.");
74
75
  }
76
+ // guard:dup-ok one configured createStatusUpdateHandler instance; only name, scope, status and description differ
75
77
  export function makeArchiveSystemWrite(policy) {
76
78
  return createStatusUpdateHandler(policy, "archive-system", "system", "archived", "Sets one system-default template to archived so the resolver stops serving it to every tenant that has no override; SystemAdmin only, reversible with publish-system.");
77
79
  }
80
+ // guard:dup-ok one configured createStatusUpdateHandler instance; only name, scope, status and description differ
78
81
  export function makePublishSystemWrite(policy) {
79
82
  return createStatusUpdateHandler(policy, "publish-system", "system", "active", "Sets one system-default template to active so the resolver serves it again to every tenant that has no override; an open draft beside the active version replaces it; SystemAdmin only, a version with unknown placeholders or unused required variables is refused.");
80
83
  }
@@ -57,15 +57,16 @@ export function imageLinksOf(entries) {
57
57
  }
58
58
  return images;
59
59
  }
60
- export function fileAttachmentsOf(entries) {
60
+ function entriesOfKind(entries, isKind) {
61
61
  return Object.entries(entries)
62
62
  .sort(([a], [b]) => a.localeCompare(b))
63
- .flatMap(([, entry]) => (isFileAttachmentEntry(entry) ? [entry] : []));
63
+ .flatMap(([, entry]) => (isKind(entry) ? [entry] : []));
64
+ }
65
+ export function fileAttachmentsOf(entries) {
66
+ return entriesOfKind(entries, isFileAttachmentEntry);
64
67
  }
65
68
  export function pdfAttachmentLinksOf(entries) {
66
- return Object.entries(entries)
67
- .sort(([a], [b]) => a.localeCompare(b))
68
- .flatMap(([, entry]) => (isPdfAttachmentLink(entry) ? [entry] : []));
69
+ return entriesOfKind(entries, isPdfAttachmentLink);
69
70
  }
70
71
  export function attachmentEntriesOf(entries) {
71
72
  return Object.entries(entries).flatMap(([key, entry]) => typeof entry === "string" ? [] : [[key, entry]]);
@@ -2,7 +2,7 @@ import { fetchOne, selectMany } from "@cosmicdrift/kumiko-framework/db";
2
2
  import { NotFoundError, UnprocessableError, writeFailure, } from "@cosmicdrift/kumiko-framework/errors";
3
3
  import { createFileRefFromUploadedBytes, uploadFileBytesBeforeTransaction, } from "@cosmicdrift/kumiko-framework/files";
4
4
  import { fileContextForTenant, readFileRefContent } from "../file-foundation/index.js";
5
- import { extensionForResourceContentType, requireForTenant } from "../shared/index.js";
5
+ import { extensionForResourceContentType, requireForTenant, unprocessable, } from "../shared/index.js";
6
6
  import { DEFAULT_RESOURCE_MAX_BYTES, MAX_FILE_ATTACHMENTS_PER_TEMPLATE, RESOURCE_MAX_BYTES_CONFIG_KEY, } from "./handlers/resource-shared.js";
7
7
  import { executor } from "./handlers/shared.js";
8
8
  import { attachmentEntriesOf, isFileAttachmentEntry, parseLinkedResourceEntries, templatePdfAttachmentLinkSchema, } from "./linked-resources.js";
@@ -150,9 +150,7 @@ function copiedFileName(key, entry, contentType) {
150
150
  return `${key}.${extensionForResourceContentType(contentType) ?? "bin"}`;
151
151
  }
152
152
  function sourceUnreadable() {
153
- return writeFailure(new UnprocessableError(TemplateResolverErrors.resourceSourceUnreadable, {
154
- i18nKey: "templateResolver.errors.resource.sourceUnreadable",
155
- }));
153
+ return unprocessable(TemplateResolverErrors.resourceSourceUnreadable, "templateResolver.errors.resource.sourceUnreadable");
156
154
  }
157
155
  // Undefined: the fileRef row exists but its bytes cannot be read, which must not look like a
158
156
  // deleted file. The provider is chosen by the tenant of the fileRef, not by the caller's.
@@ -413,12 +411,9 @@ export async function storePreparedTemplateAttachment(args) {
413
411
  },
414
412
  };
415
413
  }
416
- function pdfAttachmentInvalid(code) {
417
- return writeFailure(new UnprocessableError(TemplateResolverErrors.attachmentInvalid, {
418
- i18nKey: "templateResolver.errors.attachment.invalid",
419
- details: { code },
420
- }));
421
- }
414
+ const pdfAttachmentInvalid = (code) => unprocessable(TemplateResolverErrors.attachmentInvalid, "templateResolver.errors.attachment.invalid", {
415
+ code,
416
+ });
422
417
  // Links a PDF that is rendered from a document template at send time into a mail template of the
423
418
  // target tenant. Nothing is stored besides the link entry. The caller authorizes tenantId.
424
419
  export async function linkTemplatePdfAttachment(args) {
@@ -1,6 +1,7 @@
1
1
  // The record's photos: a block bound to an `images` variable whose FileRef ids the
2
2
  // app passes at render time. Universal like document-schema.ts.
3
3
  import { Node } from "@tiptap/core";
4
+ import { attributeParseRule } from "./tiptap-attribute-parse-rule.js";
4
5
  export function createDocumentImagesNode(isReferenceName) {
5
6
  return Node.create({
6
7
  name: "images",
@@ -11,13 +12,12 @@ export function createDocumentImagesNode(isReferenceName) {
11
12
  },
12
13
  parseHTML() {
13
14
  return [
14
- {
15
+ attributeParseRule({
15
16
  tag: "div[data-images]",
16
- getAttrs: (element) => {
17
- const variable = element.getAttribute("data-images");
18
- return variable !== null && isReferenceName(variable) ? { variable } : false;
19
- },
20
- },
17
+ attribute: "data-images",
18
+ key: "variable",
19
+ isValid: isReferenceName,
20
+ }),
21
21
  ];
22
22
  },
23
23
  renderHTML({ node }) {
@@ -43,9 +43,20 @@ function renderImageFields(m) {
43
43
  const { t, Field, Input, idPrefix } = m;
44
44
  return (_jsxs(_Fragment, { children: [_jsx(Field, { id: `${idPrefix}-resource`, label: t("template-resolver.documentEditor.resourceKey"), children: _jsx(Input, { kind: "text", id: `${idPrefix}-resource`, name: "resource", value: m.resource, onChange: m.setResource }) }), _jsx(Field, { id: `${idPrefix}-alt`, label: t("template-resolver.documentEditor.imageAlt"), children: _jsx(Input, { kind: "text", id: `${idPrefix}-alt`, name: "alt", value: m.alt, onChange: m.setAlt }) })] }));
45
45
  }
46
+ function renderVariableAndTextFields(m, fields) {
47
+ const { Field, Input, idPrefix } = m;
48
+ return (!m.noVariables && (_jsxs(_Fragment, { children: [_jsx(NameSelect, { id: `${idPrefix}-${fields.variableIdSuffix}`, label: fields.variableLabel, names: m.selectable, labels: m.variableLabels, value: m.selectedName, onChange: m.setChosenName }), _jsx(Field, { id: `${idPrefix}-${fields.textIdSuffix}`, label: fields.textLabel, children: _jsx(Input, { kind: "text", id: `${idPrefix}-${fields.textIdSuffix}`, name: fields.textName, value: fields.textValue, onChange: fields.onTextChange }) })] })));
49
+ }
46
50
  function renderButtonFields(m) {
47
- const { t, Field, Input, idPrefix } = m;
48
- return (!m.noVariables && (_jsxs(_Fragment, { children: [_jsx(NameSelect, { id: `${idPrefix}-target`, label: t("template-resolver.documentEditor.buttonTarget"), names: m.selectable, labels: m.variableLabels, value: m.selectedName, onChange: m.setChosenName }), _jsx(Field, { id: `${idPrefix}-text`, label: t("template-resolver.documentEditor.buttonText"), children: _jsx(Input, { kind: "text", id: `${idPrefix}-text`, name: "text", value: m.buttonText, onChange: m.setButtonText }) })] })));
51
+ return renderVariableAndTextFields(m, {
52
+ variableIdSuffix: "target",
53
+ variableLabel: m.t("template-resolver.documentEditor.buttonTarget"),
54
+ textIdSuffix: "text",
55
+ textLabel: m.t("template-resolver.documentEditor.buttonText"),
56
+ textName: "text",
57
+ textValue: m.buttonText,
58
+ onTextChange: m.setButtonText,
59
+ });
49
60
  }
50
61
  function renderRepeatFields(m) {
51
62
  return (!m.noVariables && (_jsx(NameSelect, { id: `${m.idPrefix}-list`, label: m.t("template-resolver.documentEditor.repeatList"), names: m.selectable, labels: m.variableLabels, value: m.selectedName, onChange: m.setChosenName })));
@@ -54,8 +65,15 @@ function renderImagesFields(m) {
54
65
  return (!m.noVariables && (_jsx(NameSelect, { id: `${m.idPrefix}-images-variable`, label: m.t("template-resolver.documentEditor.imagesVariable"), names: m.selectable, labels: m.variableLabels, value: m.selectedName, onChange: m.setChosenName })));
55
66
  }
56
67
  function renderStepsFields(m) {
57
- const { t, Field, Input, idPrefix } = m;
58
- return (!m.noVariables && (_jsxs(_Fragment, { children: [_jsx(NameSelect, { id: `${idPrefix}-steps-variable`, label: t("template-resolver.documentEditor.stepsVariable"), names: m.selectable, labels: m.variableLabels, value: m.selectedName, onChange: m.setChosenName }), _jsx(Field, { id: `${idPrefix}-steps-list`, label: t("template-resolver.documentEditor.stepsList"), children: _jsx(Input, { kind: "text", id: `${idPrefix}-steps-list`, name: "steps", value: m.stepsText, onChange: m.setStepsText }) })] })));
68
+ return renderVariableAndTextFields(m, {
69
+ variableIdSuffix: "steps-variable",
70
+ variableLabel: m.t("template-resolver.documentEditor.stepsVariable"),
71
+ textIdSuffix: "steps-list",
72
+ textLabel: m.t("template-resolver.documentEditor.stepsList"),
73
+ textName: "steps",
74
+ textValue: m.stepsText,
75
+ onTextChange: m.setStepsText,
76
+ });
59
77
  }
60
78
  export const PANEL_FIELDS = {
61
79
  link: renderLinkFields,
@@ -10,6 +10,7 @@ import StarterKit from "@tiptap/starter-kit";
10
10
  import { createDocumentImagesNode } from "./document-images.js";
11
11
  import { isDocumentReferenceName } from "./document-reference-name.js";
12
12
  import { createDocumentStepsNode } from "./document-steps.js";
13
+ import { attributeParseRule } from "./tiptap-attribute-parse-rule.js";
13
14
  const PLACEHOLDER_HREF = /^\{\{(.+)\}\}$/;
14
15
  const RESOURCE_KEY = /^[A-Za-z0-9][A-Za-z0-9_.-]*$/;
15
16
  const ALLOWED_LINK_SCHEMES = ["https://", "http://", "mailto:", "tel:"];
@@ -86,13 +87,12 @@ export const DocumentVariable = Node.create({
86
87
  },
87
88
  parseHTML() {
88
89
  return [
89
- {
90
+ attributeParseRule({
90
91
  tag: "span[data-variable]",
91
- getAttrs: (element) => {
92
- const name = element.getAttribute("data-variable");
93
- return name !== null && isDocumentReferenceName(name) ? { name } : false;
94
- },
95
- },
92
+ attribute: "data-variable",
93
+ key: "name",
94
+ isValid: isDocumentReferenceName,
95
+ }),
96
96
  ];
97
97
  },
98
98
  renderHTML({ node }) {
@@ -142,15 +142,14 @@ export const DocumentButton = Node.create({
142
142
  },
143
143
  parseHTML() {
144
144
  return [
145
- {
145
+ attributeParseRule({
146
146
  tag: "a[data-button]",
147
+ attribute: "href",
148
+ key: "href",
149
+ isValid: isDocumentPlaceholderHref,
147
150
  // Must win against the Link mark's `a[href]` rule.
148
151
  priority: 1000,
149
- getAttrs: (element) => {
150
- const href = element.getAttribute("href");
151
- return href !== null && isDocumentPlaceholderHref(href) ? { href } : false;
152
- },
153
- },
152
+ }),
154
153
  ];
155
154
  },
156
155
  renderHTML({ node }) {
@@ -0,0 +1,15 @@
1
+ type AttributeSource = {
2
+ getAttribute(name: string): string | null;
3
+ };
4
+ export declare function attributeParseRule(rule: {
5
+ readonly tag: string;
6
+ readonly attribute: string;
7
+ readonly key: string;
8
+ readonly isValid: (value: string) => boolean;
9
+ readonly priority?: number;
10
+ }): {
11
+ tag: string;
12
+ priority?: number | undefined;
13
+ getAttrs: (element: AttributeSource) => Record<string, string> | false;
14
+ };
15
+ export {};
@@ -0,0 +1,11 @@
1
+ export function attributeParseRule(rule) {
2
+ const { tag, attribute, key, isValid, priority } = rule;
3
+ return {
4
+ tag,
5
+ ...(priority === undefined ? {} : { priority }),
6
+ getAttrs: (element) => {
7
+ const value = element.getAttribute(attribute);
8
+ return value !== null && isValid(value) ? { [key]: value } : false;
9
+ },
10
+ };
11
+ }
@@ -50,6 +50,9 @@ export const TENANT_I18N = {
50
50
  "tenant:entity:tenant:field:status:option:destroying": {
51
51
  en: "Destroying",
52
52
  },
53
+ "tenant:entity:tenant:field:status:option:destroyHeld": {
54
+ en: "Destroy held by retention",
55
+ },
53
56
  "tenant:entity:tenant:field:status:option:destroyFailed": {
54
57
  en: "Destroy failed",
55
58
  },