@cosmicdrift/kumiko-samples 0.413.0 → 0.414.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/packages/bundled-features/package.json +16 -1
- package/packages/bundled-features/src/admin-shell/changes.json +6 -0
- package/packages/bundled-features/src/admin-shell/feature.ts +8 -7
- package/packages/bundled-features/src/agent-tools/agent-doc-lint.ts +5 -1
- package/packages/bundled-features/src/agent-tools/agent-manifest.ts +36 -27
- package/packages/bundled-features/src/agent-tools/api-docs/collect-events.ts +8 -1
- package/packages/bundled-features/src/agent-tools/api-docs/collect.ts +3 -2
- package/packages/bundled-features/src/agent-tools/api-docs/generate.ts +6 -0
- package/packages/bundled-features/src/agent-tools/api-docs/index.ts +1 -0
- package/packages/bundled-features/src/agent-tools/api-docs/problems.ts +38 -1
- package/packages/bundled-features/src/agent-tools/api-docs/render-openapi.ts +1 -0
- package/packages/bundled-features/src/agent-tools/api-docs/resolve-config.ts +17 -0
- package/packages/bundled-features/src/agent-tools/api-docs/scope-slug-collisions.ts +17 -0
- package/packages/bundled-features/src/agent-tools/api-docs/translation-gaps.ts +42 -0
- package/packages/bundled-features/src/agent-tools/api-docs/webhook-example-problems.ts +30 -0
- package/packages/bundled-features/src/agent-tools/changes.json +12 -0
- package/packages/bundled-features/src/agent-tools/index.ts +1 -0
- package/packages/bundled-features/src/agent-tools/labels.ts +19 -6
- package/packages/bundled-features/src/agent-tools/tool-catalog.ts +18 -7
- package/packages/bundled-features/src/agent-tools/tool-dispatch.ts +14 -1
- package/packages/bundled-features/src/agent-tools/types.ts +4 -0
- package/packages/bundled-features/src/audit/event-classification.ts +6 -0
- package/packages/bundled-features/src/audit/web/i18n.ts +1 -0
- package/packages/bundled-features/src/auth-email-password/changes.json +18 -0
- package/packages/bundled-features/src/auth-email-password/errors.ts +0 -13
- package/packages/bundled-features/src/auth-email-password/handlers/invite-signup-complete.write.ts +147 -121
- package/packages/bundled-features/src/auth-email-password/handlers/login-options.query.ts +1 -1
- package/packages/bundled-features/src/auth-email-password/handlers/request-account-unlock.write.ts +1 -1
- package/packages/bundled-features/src/auth-email-password/handlers/request-email-verification.write.ts +0 -1
- package/packages/bundled-features/src/auth-email-password/handlers/request-password-reset.write.ts +0 -1
- package/packages/bundled-features/src/auth-email-password/handlers/self-registration-status.query.ts +1 -1
- package/packages/bundled-features/src/auth-email-password/reset-token.ts +0 -2
- package/packages/bundled-features/src/auth-email-password/seeding.ts +39 -7
- package/packages/bundled-features/src/auth-email-password/unlock-token.ts +0 -2
- package/packages/bundled-features/src/auth-email-password/verification-token.ts +0 -2
- package/packages/bundled-features/src/auth-email-password/web/auth-form-primitives.tsx +2 -2
- package/packages/bundled-features/src/auth-email-password/web/auth-gate.tsx +2 -2
- package/packages/bundled-features/src/auth-email-password/web/auth-redirect.ts +5 -0
- package/packages/bundled-features/src/auth-email-password/web/forgot-password-screen.tsx +1 -6
- package/packages/bundled-features/src/auth-email-password/web/invite-accept-screen.tsx +1 -1
- package/packages/bundled-features/src/auth-email-password/web/return-path.ts +2 -1
- package/packages/bundled-features/src/auth-email-password/web/session.tsx +10 -12
- package/packages/bundled-features/src/auth-email-password/web/signup-screen.tsx +1 -6
- package/packages/bundled-features/src/auth-email-password/web/static-account.ts +6 -1
- package/packages/bundled-features/src/auth-email-password/web/tenant-switcher.tsx +1 -1
- package/packages/bundled-features/src/auth-email-password/web/token-confirm-screen.tsx +4 -5
- package/packages/bundled-features/src/auth-email-password/web/user-menu.tsx +1 -1
- package/packages/bundled-features/src/auth-mfa/web/mfa-code-or-recovery-field.tsx +17 -1
- package/packages/bundled-features/src/auth-mfa/web/mfa-disable-dialog.tsx +1 -1
- package/packages/bundled-features/src/auth-mfa/web/mfa-regenerate-recovery-dialog.tsx +1 -1
- package/packages/bundled-features/src/auth-mfa/web/mfa-setup-preauth-screen.tsx +1 -1
- package/packages/bundled-features/src/auth-mfa/web/mfa-verify-screen.tsx +16 -47
- package/packages/bundled-features/src/auth-mfa-user-data/index.ts +5 -6
- package/packages/bundled-features/src/billing-foundation/aggregate-id.ts +0 -4
- package/packages/bundled-features/src/billing-foundation/changes.json +37 -0
- package/packages/bundled-features/src/billing-foundation/checkout-core.ts +8 -1
- package/packages/bundled-features/src/billing-foundation/checkout-ledger.ts +59 -0
- package/packages/bundled-features/src/billing-foundation/consumer-protection/consent-gate.ts +2 -1
- package/packages/bundled-features/src/billing-foundation/consumer-protection/consent-text.ts +49 -2
- package/packages/bundled-features/src/billing-foundation/consumer-protection/termination-open-cancels.ts +5 -0
- package/packages/bundled-features/src/billing-foundation/consumer-protection/termination-provider-timeout.ts +23 -0
- package/packages/bundled-features/src/billing-foundation/consumer-protection/termination-record.ts +12 -7
- package/packages/bundled-features/src/billing-foundation/consumer-protection/termination-revoke.ts +1 -1
- package/packages/bundled-features/src/billing-foundation/events.ts +49 -10
- package/packages/bundled-features/src/billing-foundation/feature.ts +15 -1
- package/packages/bundled-features/src/billing-foundation/handlers/billing-plans.query.ts +47 -14
- package/packages/bundled-features/src/billing-foundation/handlers/create-checkout-session.write.ts +7 -1
- package/packages/bundled-features/src/billing-foundation/handlers/process-event.write.ts +124 -10
- package/packages/bundled-features/src/billing-foundation/handlers/process-payment-event.write.ts +33 -9
- package/packages/bundled-features/src/billing-foundation/handlers/record-checkout-opened.write.ts +25 -0
- package/packages/bundled-features/src/billing-foundation/handlers/start-plan-checkout.write.ts +7 -1
- package/packages/bundled-features/src/billing-foundation/handlers/switch-plan.write.ts +16 -4
- package/packages/bundled-features/src/billing-foundation/i18n.ts +3 -0
- package/packages/bundled-features/src/billing-foundation/pending-plan-switch.ts +80 -0
- package/packages/bundled-features/src/billing-foundation/scrub-raw-payload-headers.ts +50 -0
- package/packages/bundled-features/src/billing-foundation/types.ts +47 -30
- package/packages/bundled-features/src/billing-foundation/validate-options.ts +18 -0
- package/packages/bundled-features/src/billing-foundation/web/billing-plans-panel.tsx +10 -5
- package/packages/bundled-features/src/billing-foundation/web/cancel-contract-dialog.tsx +1 -1
- package/packages/bundled-features/src/billing-foundation/web/checkout-consent-dialog.tsx +1 -1
- package/packages/bundled-features/src/billing-foundation/web/constants.ts +5 -2
- package/packages/bundled-features/src/billing-foundation/web/plan-switch-confirm-dialog.tsx +1 -1
- package/packages/bundled-features/src/billing-foundation/webhook-handler.ts +65 -17
- package/packages/bundled-features/src/cap-counter/aggregate-id.ts +0 -2
- package/packages/bundled-features/src/cap-counter/changes.json +6 -0
- package/packages/bundled-features/src/cap-counter/stock-cap-guard.ts +19 -4
- package/packages/bundled-features/src/cap-overview/changes.json +6 -0
- package/packages/bundled-features/src/cap-overview/handlers/tenant-caps-list.query.ts +22 -6
- package/packages/bundled-features/src/cap-overview/i18n.ts +1 -0
- package/packages/bundled-features/src/cap-overview/index.ts +1 -0
- package/packages/bundled-features/src/cap-overview/types.ts +11 -1
- package/packages/bundled-features/src/cap-overview/web/cap-cards-panel.tsx +6 -2
- package/packages/bundled-features/src/cap-overview/web/cap-usage-bar.tsx +10 -1
- package/packages/bundled-features/src/cap-overview/web/usage-math.ts +5 -0
- package/packages/bundled-features/src/channel-in-app/changes.json +6 -0
- package/packages/bundled-features/src/channel-in-app/handlers/read-state-by-keys.query.ts +2 -2
- package/packages/bundled-features/src/channel-whatsapp/aggregate-id.ts +29 -0
- package/packages/bundled-features/src/channel-whatsapp/changes.json +8 -0
- package/packages/bundled-features/src/channel-whatsapp/constants.ts +46 -0
- package/packages/bundled-features/src/channel-whatsapp/events.ts +93 -0
- package/packages/bundled-features/src/channel-whatsapp/feature.ts +72 -0
- package/packages/bundled-features/src/channel-whatsapp/graph-client.ts +398 -0
- package/packages/bundled-features/src/channel-whatsapp/in-memory-meta.ts +300 -0
- package/packages/bundled-features/src/channel-whatsapp/inbound-handlers.ts +189 -0
- package/packages/bundled-features/src/channel-whatsapp/index.ts +66 -0
- package/packages/bundled-features/src/channel-whatsapp/meta-signature.ts +26 -0
- package/packages/bundled-features/src/channel-whatsapp/options.ts +149 -0
- package/packages/bundled-features/src/channel-whatsapp/pii.ts +109 -0
- package/packages/bundled-features/src/channel-whatsapp/webhook-normalize.ts +226 -0
- package/packages/bundled-features/src/channel-whatsapp/webhook-routes.ts +185 -0
- package/packages/bundled-features/src/compliance-profiles/handlers/sub-processors.query.ts +1 -1
- package/packages/bundled-features/src/config/changes.json +12 -0
- package/packages/bundled-features/src/config/handlers/set.write.ts +7 -0
- package/packages/bundled-features/src/config/handlers/values.query.ts +8 -1
- package/packages/bundled-features/src/config/index.ts +1 -0
- package/packages/bundled-features/src/config/read-redaction.ts +6 -3
- package/packages/bundled-features/src/config/table.ts +1 -0
- package/packages/bundled-features/src/config/write-helpers.ts +3 -2
- package/packages/bundled-features/src/crypto-shredding/changes.json +18 -0
- package/packages/bundled-features/src/crypto-shredding/constants.ts +2 -0
- package/packages/bundled-features/src/crypto-shredding/handlers/forget-subject.write.ts +38 -18
- package/packages/bundled-features/src/crypto-shredding/index.ts +4 -0
- package/packages/bundled-features/src/crypto-shredding/subject-forget-after-delete-hook.ts +49 -0
- package/packages/bundled-features/src/custom-fields/aggregate-id.ts +0 -1
- package/packages/bundled-features/src/custom-fields/entity.ts +1 -0
- package/packages/bundled-features/src/custom-fields/wire-for-entity.ts +0 -1
- package/packages/bundled-features/src/data-retention/changes.json +18 -0
- package/packages/bundled-features/src/data-retention/erase-notes-of-deleted-row.ts +23 -0
- package/packages/bundled-features/src/data-retention/feature.ts +4 -7
- package/packages/bundled-features/src/data-retention/run-retention-cleanup.ts +38 -18
- package/packages/bundled-features/src/data-retention/tenant-destruction-hold.ts +9 -0
- package/packages/bundled-features/src/delivery/attempt-log-factory.ts +11 -0
- package/packages/bundled-features/src/delivery/attempt-log.ts +3 -3
- package/packages/bundled-features/src/delivery/changes.json +6 -0
- package/packages/bundled-features/src/delivery/channel-context.ts +6 -3
- package/packages/bundled-features/src/delivery/db/queries/preferences.ts +0 -1
- package/packages/bundled-features/src/delivery/delivery-service.ts +3 -0
- package/packages/bundled-features/src/delivery/feature.ts +4 -13
- package/packages/bundled-features/src/delivery/handlers/opted-in-user-ids.query.ts +45 -0
- package/packages/bundled-features/src/delivery/handlers/preferences.query.ts +2 -20
- package/packages/bundled-features/src/delivery/handlers/resubscribe-user.write.ts +2 -25
- package/packages/bundled-features/src/delivery/handlers/unsubscribe-page-chrome.query.ts +2 -0
- package/packages/bundled-features/src/delivery/handlers/unsubscribe-user.write.ts +2 -27
- package/packages/bundled-features/src/delivery/index.ts +3 -1
- package/packages/bundled-features/src/delivery/options.ts +11 -0
- package/packages/bundled-features/src/delivery/preference-rows.ts +33 -0
- package/packages/bundled-features/src/delivery/set-preference-enabled.ts +40 -0
- package/packages/bundled-features/src/delivery/testing.ts +3 -1
- package/packages/bundled-features/src/delivery/types.ts +1 -0
- package/packages/bundled-features/src/delivery/unsubscribe-page.ts +7 -1
- package/packages/bundled-features/src/delivery/upsert-preference.ts +0 -1
- package/packages/bundled-features/src/delivery/web/public-names.ts +1 -0
- package/packages/bundled-features/src/derivatives-sharp/render.ts +9 -9
- package/packages/bundled-features/src/document-ingest-foundation/aggregate-id.ts +0 -1
- package/packages/bundled-features/src/document-ingest-foundation/append-missing-extract-event.ts +37 -25
- package/packages/bundled-features/src/document-ingest-foundation/report-ingest-progress.ts +32 -14
- package/packages/bundled-features/src/documents/aggregate-id.ts +0 -2
- package/packages/bundled-features/src/documents/changes.json +18 -0
- package/packages/bundled-features/src/documents/constants.ts +10 -2
- package/packages/bundled-features/src/documents/ensure-link.ts +3 -4
- package/packages/bundled-features/src/documents/feature.ts +28 -6
- package/packages/bundled-features/src/documents/handlers/import.write.ts +2 -2
- package/packages/bundled-features/src/documents/queries/expiry-overview.query.ts +2 -1
- package/packages/bundled-features/src/documents/queries/for-record.query.ts +3 -4
- package/packages/bundled-features/src/documents/queries/list-page.ts +11 -3
- package/packages/bundled-features/src/documents/queries/overview.query.ts +2 -2
- package/packages/bundled-features/src/documents/screens.ts +8 -3
- package/packages/bundled-features/src/documents/tab.ts +1 -1
- package/packages/bundled-features/src/feature-toggles/toggle-sync-signal.ts +6 -3
- package/packages/bundled-features/src/file-derivatives/handlers/public-variant-by-file-ref.query.ts +1 -1
- package/packages/bundled-features/src/file-derivatives/handlers/public-variant.query.ts +1 -1
- package/packages/bundled-features/src/file-foundation/probe.ts +9 -3
- package/packages/bundled-features/src/file-foundation/read-file-ref-content.ts +24 -11
- package/packages/bundled-features/src/file-provider-inmemory/feature.ts +1 -1
- package/packages/bundled-features/src/file-provider-s3/changes.json +14 -0
- package/packages/bundled-features/src/file-provider-s3/env-feature.ts +1 -1
- package/packages/bundled-features/src/file-provider-s3/env-named-feature.ts +1 -1
- package/packages/bundled-features/src/file-provider-s3/env-schema.ts +24 -7
- package/packages/bundled-features/src/file-provider-s3/feature.ts +1 -1
- package/packages/bundled-features/src/file-provider-s3/index.ts +7 -1
- package/packages/bundled-features/src/file-provider-s3/lib/env-helper.ts +21 -13
- package/packages/bundled-features/src/file-provider-s3/lib/s3-provider.ts +8 -1
- package/packages/bundled-features/src/files/changes.json +7 -0
- package/packages/bundled-features/src/folders/aggregate-id.ts +0 -1
- package/packages/bundled-features/src/folders/web/folder-manager.tsx +6 -6
- package/packages/bundled-features/src/folders-user-data/index.ts +12 -14
- package/packages/bundled-features/src/helpdesk/changes.json +62 -0
- package/packages/bundled-features/src/helpdesk/entity.ts +4 -1
- package/packages/bundled-features/src/helpdesk/feature.ts +41 -0
- package/packages/bundled-features/src/helpdesk/handlers/access.ts +0 -10
- package/packages/bundled-features/src/helpdesk/handlers/attempts.ts +7 -14
- package/packages/bundled-features/src/helpdesk/handlers/challenge.query.ts +1 -2
- package/packages/bundled-features/src/helpdesk/handlers/reply.write.ts +2 -9
- package/packages/bundled-features/src/helpdesk/handlers/report.write.ts +2 -9
- package/packages/bundled-features/src/helpdesk/handlers/submit.write.ts +3 -11
- package/packages/bundled-features/src/helpdesk/index.ts +1 -0
- package/packages/bundled-features/src/helpdesk/legacy-contact-config.ts +61 -0
- package/packages/bundled-features/src/helpdesk/legacy-contact-erasure.ts +45 -0
- package/packages/bundled-features/src/helpdesk/legacy-contact-retention.ts +65 -0
- package/packages/bundled-features/src/helpdesk/legacy-contact-streams.ts +185 -0
- package/packages/bundled-features/src/helpdesk/legacy-contact-user-data.ts +84 -0
- package/packages/bundled-features/src/helpdesk/lib.ts +47 -34
- package/packages/bundled-features/src/helpdesk/user-data-hooks.ts +89 -48
- package/packages/bundled-features/src/helpdesk/web/constants.ts +0 -1
- package/packages/bundled-features/src/inbound-mail-foundation/account-health.ts +1 -1
- package/packages/bundled-features/src/inbound-mail-foundation/account-poll.ts +5 -1
- package/packages/bundled-features/src/inbound-mail-foundation/aggregate-id.ts +0 -2
- package/packages/bundled-features/src/inbound-mail-foundation/changes.json +48 -0
- package/packages/bundled-features/src/inbound-mail-foundation/constants.ts +6 -0
- package/packages/bundled-features/src/inbound-mail-foundation/content-refetch.ts +15 -1
- package/packages/bundled-features/src/inbound-mail-foundation/entities.ts +64 -15
- package/packages/bundled-features/src/inbound-mail-foundation/events.ts +15 -16
- package/packages/bundled-features/src/inbound-mail-foundation/feature.ts +3 -1
- package/packages/bundled-features/src/inbound-mail-foundation/handlers/account-address.ts +16 -2
- package/packages/bundled-features/src/inbound-mail-foundation/handlers/attach-message-content.write.ts +10 -3
- package/packages/bundled-features/src/inbound-mail-foundation/handlers/connect-account.write.ts +21 -8
- package/packages/bundled-features/src/inbound-mail-foundation/handlers/forget-message.write.ts +73 -0
- package/packages/bundled-features/src/inbound-mail-foundation/i18n.ts +3 -0
- package/packages/bundled-features/src/inbound-mail-foundation/index.ts +1 -0
- package/packages/bundled-features/src/inbound-mail-foundation/oauth-access-token.ts +1 -1
- package/packages/bundled-features/src/inbound-mail-foundation/outbound-mail.ts +2 -0
- package/packages/bundled-features/src/inbound-mail-foundation/personal-address.ts +20 -0
- package/packages/bundled-features/src/inbound-mail-foundation/purge-messages.ts +54 -0
- package/packages/bundled-features/src/inbound-mail-foundation/quarantine.ts +15 -5
- package/packages/bundled-features/src/inbound-mail-foundation/retention-job.ts +1 -5
- package/packages/bundled-features/src/inbound-mail-foundation/retention-sweep.ts +21 -34
- package/packages/bundled-features/src/inbound-mail-foundation/send-from-account.ts +9 -1
- package/packages/bundled-features/src/inbound-mail-foundation/supervisor-ingest.ts +7 -1
- package/packages/bundled-features/src/inbound-mail-foundation/sync-account-now.ts +1 -1
- package/packages/bundled-features/src/inbound-mail-foundation/tenant-destroy-hook.ts +14 -17
- package/packages/bundled-features/src/inbound-mail-foundation/watch-supervisor.ts +1 -1
- package/packages/bundled-features/src/inbound-provider-imap/byte-budget.ts +80 -0
- package/packages/bundled-features/src/inbound-provider-imap/changes.json +13 -0
- package/packages/bundled-features/src/inbound-provider-imap/connect-mailbox.ts +8 -4
- package/packages/bundled-features/src/inbound-provider-imap/connect-my-mailbox.ts +23 -6
- package/packages/bundled-features/src/inbound-provider-imap/connect-target-rate-limit.ts +46 -0
- package/packages/bundled-features/src/inbound-provider-imap/download-batch.ts +47 -10
- package/packages/bundled-features/src/inbound-provider-imap/feature.ts +7 -4
- package/packages/bundled-features/src/inbound-provider-imap/fetch-content.ts +43 -29
- package/packages/bundled-features/src/inbound-provider-imap/i18n.ts +2 -2
- package/packages/bundled-features/src/inbound-provider-imap/parse-message.ts +14 -0
- package/packages/bundled-features/src/inbound-provider-imap/reconnect-mailbox.ts +5 -4
- package/packages/bundled-features/src/inbound-provider-imap/send-mail.ts +39 -7
- package/packages/bundled-features/src/inbound-provider-imap/smtp-client.ts +19 -4
- package/packages/bundled-features/src/inbound-provider-imap/watch-mailbox.ts +8 -23
- package/packages/bundled-features/src/inbound-provider-inmemory/feature.ts +1 -1
- package/packages/bundled-features/src/jobs/events.ts +10 -0
- package/packages/bundled-features/src/jobs/feature.ts +2 -0
- package/packages/bundled-features/src/jobs/handlers/consumer.write.ts +41 -16
- package/packages/bundled-features/src/jobs/web/constants.ts +4 -0
- package/packages/bundled-features/src/mail-foundation/changes.json +6 -0
- package/packages/bundled-features/src/mail-transport-inmemory/feature.ts +1 -1
- package/packages/bundled-features/src/mail-transport-smtp/feature.ts +3 -2
- package/packages/bundled-features/src/managed-pages/changes.json +12 -0
- package/packages/bundled-features/src/managed-pages/handlers/branding.query.ts +1 -1
- package/packages/bundled-features/src/managed-pages/handlers/by-slug.query.ts +1 -1
- package/packages/bundled-features/src/managed-pages/handlers/by-tenant-published.query.ts +1 -1
- package/packages/bundled-features/src/managed-pages/render-page-body.ts +18 -10
- package/packages/bundled-features/src/managed-pages/screens/page-screens.ts +18 -38
- package/packages/bundled-features/src/managed-pages/table.ts +1 -0
- package/packages/bundled-features/src/managed-pages/web/client-plugin.tsx +8 -6
- package/packages/bundled-features/src/managed-pages/web/constants.ts +8 -1
- package/packages/bundled-features/src/managed-pages/web/i18n.ts +11 -3
- package/packages/bundled-features/src/managed-pages/web/markdown-to-document.ts +1 -1
- package/packages/bundled-features/src/managed-pages/web/page-edit-draft.ts +108 -0
- package/packages/bundled-features/src/managed-pages/web/page-edit-screen.tsx +198 -0
- package/packages/bundled-features/src/managed-pages/web/page-settings-rail.tsx +117 -0
- package/packages/bundled-features/src/notes-history-user-data/index.ts +8 -14
- package/packages/bundled-features/src/personal-access-tokens/boot-rules.ts +5 -0
- package/packages/bundled-features/src/personal-access-tokens/handlers/create.write.ts +0 -1
- package/packages/bundled-features/src/personal-access-tokens/scope-events-check.ts +31 -5
- package/packages/bundled-features/src/presence/changes.json +6 -0
- package/packages/bundled-features/src/presence/handlers/list.query.ts +28 -11
- package/packages/bundled-features/src/presence/room.ts +21 -7
- package/packages/bundled-features/src/presence/store.ts +79 -21
- package/packages/bundled-features/src/readiness/changes.json +25 -0
- package/packages/bundled-features/src/readiness/handlers/latest-summary.query.ts +11 -6
- package/packages/bundled-features/src/readiness/handlers/run-probes.write.ts +35 -5
- package/packages/bundled-features/src/readiness/handlers/run-tone.ts +3 -2
- package/packages/bundled-features/src/readiness/handlers/status.query.ts +15 -1
- package/packages/bundled-features/src/readiness/probe-context.ts +11 -10
- package/packages/bundled-features/src/readiness/screens.ts +4 -4
- package/packages/bundled-features/src/readiness/visible-results.ts +5 -3
- package/packages/bundled-features/src/renderer-foundation/api.ts +6 -13
- package/packages/bundled-features/src/renderer-foundation/types.ts +2 -2
- package/packages/bundled-features/src/secrets/changes.json +7 -0
- package/packages/bundled-features/src/secrets/db/queries/read.ts +18 -4
- package/packages/bundled-features/src/secrets/handlers/list.query.ts +8 -2
- package/packages/bundled-features/src/secrets/secret-scope.ts +2 -3
- package/packages/bundled-features/src/secrets/secrets-context.ts +6 -4
- package/packages/bundled-features/src/secrets/write-gate.ts +4 -2
- package/packages/bundled-features/src/seo/handlers/seo-config.query.ts +1 -1
- package/packages/bundled-features/src/shared/acknowledged-system-db.ts +20 -0
- package/packages/bundled-features/src/shared/assert-billing-live.ts +9 -2
- package/packages/bundled-features/src/shared/changes.json +6 -0
- package/packages/bundled-features/src/shared/index.ts +6 -1
- package/packages/bundled-features/src/shared/parent-visibility.ts +25 -1
- package/packages/bundled-features/src/shared/password-hashing.ts +0 -1
- package/packages/bundled-features/src/shared/price-env-shape.ts +1 -4
- package/packages/bundled-features/src/shared/register-user-data-hooks.ts +29 -0
- package/packages/bundled-features/src/shared/require-bootstrap-extension.ts +26 -0
- package/packages/bundled-features/src/shared/send-best-effort.ts +19 -0
- package/packages/bundled-features/src/shared/stream-tenant-backfill.ts +22 -1
- package/packages/bundled-features/src/shared/stream-tenant-derived-state.ts +31 -1
- package/packages/bundled-features/src/step-dispatcher/changes.json +12 -0
- package/packages/bundled-features/src/step-dispatcher/constants.ts +13 -0
- package/packages/bundled-features/src/step-dispatcher/deliver-dispatch-request.ts +47 -2
- package/packages/bundled-features/src/step-dispatcher/feature.ts +28 -1
- package/packages/bundled-features/src/step-dispatcher/mail-runner.ts +0 -1
- package/packages/bundled-features/src/step-dispatcher/sweep-abandoned.ts +57 -0
- package/packages/bundled-features/src/subscription-mollie/changes.json +7 -0
- package/packages/bundled-features/src/subscription-mollie/plugin-methods.ts +5 -3
- package/packages/bundled-features/src/subscription-mollie/verify-webhook.ts +5 -5
- package/packages/bundled-features/src/subscription-paddle/backfill-checkout-ledger.ts +159 -0
- package/packages/bundled-features/src/subscription-paddle/changes.json +13 -0
- package/packages/bundled-features/src/subscription-paddle/checkout-config.query.ts +1 -1
- package/packages/bundled-features/src/subscription-paddle/checkout-methods.ts +2 -8
- package/packages/bundled-features/src/subscription-paddle/constants.ts +1 -2
- package/packages/bundled-features/src/subscription-paddle/feature.ts +26 -24
- package/packages/bundled-features/src/subscription-paddle/ledger-backfill-marker.ts +70 -0
- package/packages/bundled-features/src/subscription-paddle/plan-switch-methods.ts +2 -8
- package/packages/bundled-features/src/subscription-paddle/redeliver-legacy-checkout.ts +36 -0
- package/packages/bundled-features/src/subscription-paddle/runtime.ts +13 -24
- package/packages/bundled-features/src/subscription-paddle/subscription-state.ts +1 -0
- package/packages/bundled-features/src/subscription-paddle/webhook-events.ts +68 -21
- package/packages/bundled-features/src/subscription-stripe/changes.json +7 -0
- package/packages/bundled-features/src/subscription-stripe/feature.ts +5 -0
- package/packages/bundled-features/src/subscription-stripe/plugin-methods.ts +6 -6
- package/packages/bundled-features/src/subscription-stripe/runtime.ts +8 -7
- package/packages/bundled-features/src/subscription-stripe/verify-webhook.ts +24 -6
- package/packages/bundled-features/src/tags/aggregate-id.ts +0 -1
- package/packages/bundled-features/src/tags/web/tag-chip.tsx +4 -5
- package/packages/bundled-features/src/tags/web/tag-manager.tsx +2 -1
- package/packages/bundled-features/src/template-resolver/api.ts +6 -13
- package/packages/bundled-features/src/template-resolver/changes.json +36 -0
- package/packages/bundled-features/src/template-resolver/document-sanitizer.ts +25 -0
- package/packages/bundled-features/src/template-resolver/feature.ts +2 -0
- package/packages/bundled-features/src/template-resolver/handlers/body-preview.query.ts +41 -0
- package/packages/bundled-features/src/template-resolver/handlers/by-slug.query.ts +1 -1
- package/packages/bundled-features/src/template-resolver/handlers/by-tenant.query.ts +1 -1
- package/packages/bundled-features/src/template-resolver/handlers/collection-shared.ts +5 -11
- package/packages/bundled-features/src/template-resolver/handlers/overview.query.ts +3 -2
- package/packages/bundled-features/src/template-resolver/handlers/send-test.write.ts +37 -8
- package/packages/bundled-features/src/template-resolver/linked-resources.ts +2 -5
- package/packages/bundled-features/src/template-resolver/seeding.ts +77 -0
- package/packages/bundled-features/src/template-resolver/table.ts +1 -0
- package/packages/bundled-features/src/template-resolver/template-draft.ts +2 -1
- package/packages/bundled-features/src/template-resolver/template-preview.ts +14 -3
- package/packages/bundled-features/src/template-resolver/testing.ts +0 -2
- package/packages/bundled-features/src/template-resolver/web/client-plugin.tsx +3 -0
- package/packages/bundled-features/src/template-resolver/web/collection-entry-create-form.tsx +33 -33
- package/packages/bundled-features/src/template-resolver/web/constants.ts +7 -0
- package/packages/bundled-features/src/template-resolver/web/content-tree-provider.ts +0 -1
- package/packages/bundled-features/src/template-resolver/web/content-workbench.tsx +142 -0
- package/packages/bundled-features/src/template-resolver/web/document-insert-model.ts +3 -8
- package/packages/bundled-features/src/template-resolver/web/document-link-policy.ts +58 -0
- package/packages/bundled-features/src/template-resolver/web/document-schema.ts +11 -57
- package/packages/bundled-features/src/template-resolver/web/document-tiptap-bubble.tsx +2 -4
- package/packages/bundled-features/src/template-resolver/web/document-tiptap-context.ts +4 -5
- package/packages/bundled-features/src/template-resolver/web/document-tiptap-editor.tsx +2 -2
- package/packages/bundled-features/src/template-resolver/web/document-tiptap-helpers.ts +6 -3
- package/packages/bundled-features/src/template-resolver/web/document-tiptap-toolbar-groups.tsx +2 -3
- package/packages/bundled-features/src/template-resolver/web/editor-handle.ts +1 -0
- package/packages/bundled-features/src/template-resolver/web/fill-document-variables.ts +24 -0
- package/packages/bundled-features/src/template-resolver/web/i18n.ts +14 -0
- package/packages/bundled-features/src/template-resolver/web/index.ts +3 -0
- package/packages/bundled-features/src/template-resolver/web/preview-targets.ts +25 -0
- package/packages/bundled-features/src/template-resolver/web/qualified-names.ts +1 -0
- package/packages/bundled-features/src/template-resolver/web/snippet-preview-renderer.tsx +24 -0
- package/packages/bundled-features/src/template-resolver/web/string-values.ts +7 -0
- package/packages/bundled-features/src/template-resolver/web/text-block-editor.tsx +38 -50
- package/packages/bundled-features/src/template-resolver/web/use-collection-entry-create.ts +7 -0
- package/packages/bundled-features/src/template-resolver/web/use-content-write.ts +1 -3
- package/packages/bundled-features/src/template-resolver/web/use-document-tiptap-model.ts +1 -2
- package/packages/bundled-features/src/template-resolver/web/use-text-block-editor.ts +28 -7
- package/packages/bundled-features/src/template-resolver/web/web-preview-renderer.tsx +126 -0
- package/packages/bundled-features/src/template-resolver-user-data/index.ts +11 -10
- package/packages/bundled-features/src/tenant/changes.json +6 -0
- package/packages/bundled-features/src/tenant/handlers/create.write.ts +7 -8
- package/packages/bundled-features/src/tenant/handlers/list.query.ts +7 -9
- package/packages/bundled-features/src/tenant/handlers/member-directory.query.ts +10 -4
- package/packages/bundled-features/src/tenant/handlers/toggle-enabled.write.ts +1 -1
- package/packages/bundled-features/src/tenant/invited-membership.ts +10 -1
- package/packages/bundled-features/src/tenant/seeding.ts +4 -2
- package/packages/bundled-features/src/tenant/stream-tenant-backfill.ts +5 -1
- package/packages/bundled-features/src/tenant/testing.ts +1 -1
- package/packages/bundled-features/src/tenant-inactivity/check-inactive-tenants.ts +4 -3
- package/packages/bundled-features/src/tenant-inactivity/constants.ts +1 -2
- package/packages/bundled-features/src/tenant-inactivity/handlers/keep-account.write.ts +1 -2
- package/packages/bundled-features/src/tenant-inactivity/state-store.ts +10 -1
- package/packages/bundled-features/src/tenant-lifecycle/changes.json +18 -0
- package/packages/bundled-features/src/tenant-lifecycle/constants.ts +4 -0
- package/packages/bundled-features/src/tenant-lifecycle/run-tenant-destroy.ts +43 -6
- package/packages/bundled-features/src/tenant-lifecycle/stages.ts +15 -2
- package/packages/bundled-features/src/tier-engine/aggregate-id.ts +0 -1
- package/packages/bundled-features/src/tier-engine/changes.json +6 -0
- package/packages/bundled-features/src/tier-engine/feature.ts +8 -2
- package/packages/bundled-features/src/user/changes.json +6 -0
- package/packages/bundled-features/src/user/db/queries/stream-tenant-backfill.ts +2 -1
- package/packages/bundled-features/src/user/handlers/me.query.ts +3 -1
- package/packages/bundled-features/src/user/index.ts +1 -0
- package/packages/bundled-features/src/user/resolve-verified-user-email.ts +17 -0
- package/packages/bundled-features/src/user-data-rights/db/queries/export-jobs.ts +0 -1
- package/packages/bundled-features/src/user-data-rights/handlers/confirm-deletion-by-token.write.ts +1 -1
- package/packages/bundled-features/src/user-data-rights/handlers/download-by-token.query.ts +1 -1
- package/packages/bundled-features/src/user-data-rights/handlers/request-deletion-by-email.write.ts +1 -1
- package/packages/bundled-features/src/user-data-rights/run-export-jobs.ts +0 -2
- package/packages/bundled-features/src/user-data-rights/run-forget-cleanup.ts +3 -3
- package/packages/bundled-features/src/user-data-rights/schema/download-attempt.ts +3 -2
- package/packages/bundled-features/src/user-data-rights/web/confirm-deletion-screen.tsx +1 -1
- package/packages/bundled-features/src/user-data-rights/web/privacy-center-screen.tsx +1 -1
- package/packages/bundled-features/src/user-data-rights/web/request-deletion-screen.tsx +1 -1
- package/packages/bundled-features/src/user-data-rights-defaults/hooks/api-token.userdata-hook.ts +5 -5
- package/packages/bundled-features/src/user-data-rights-defaults/hooks/hard-delete-own-rows-hook.ts +17 -0
- package/packages/bundled-features/src/user-data-rights-defaults/hooks/in-app-message.userdata-hook.ts +5 -5
- package/packages/bundled-features/src/user-data-rights-defaults/hooks/job-run.userdata-hook.ts +2 -1
- package/packages/bundled-features/src/user-data-rights-defaults/hooks/user-session.userdata-hook.ts +5 -5
- package/packages/bundled-features/src/user-profile/handlers/change-email.write.ts +0 -1
- package/packages/bundled-features/src/waitlist/changes.json +6 -0
- package/packages/bundled-features/src/waitlist/handlers/submit.write.ts +4 -28
- package/packages/bundled-features/src/waitlist/lib.ts +2 -7
- package/packages/bundled-features/src/waitlist/user-data-hooks.ts +6 -19
- package/packages/bundled-features/src/workflow-runner/aggregate-id.ts +0 -1
- package/packages/bundled-features/src/workflow-runner/event-trigger.ts +6 -2
- package/packages/bundled-features/src/workflow-runner/feature.ts +1 -5
- package/packages/bundled-features/src/workflow-runner/handlers/resume-run.write.ts +5 -4
- package/packages/bundled-features/src/workflow-runner/runner.ts +2 -0
- package/samples/apps/showcase/src/features/demos/web/pages/dialog.tsx +0 -1
- package/samples/apps/showcase/src/features/demos/web/pages/layout.tsx +1 -1
- package/samples/apps/showcase/src/features/demos/web/pages/sidebar-panel.tsx +0 -1
- package/samples/apps/styleguide/src/features/gallery/web/Gallery.tsx +1 -4
- package/samples/apps/ui-walkthrough/src/features/subscription-plans/feature.ts +6 -2
- package/samples/apps/use-all-bundled/e2e-billing-gallery/gallery-features.ts +12 -14
- package/samples/apps/use-all-bundled/feature-manifest.json +60 -29
- package/samples/apps/use-all-bundled/playwright.billing-docs.config.ts +1 -1
- package/samples/apps/use-all-bundled/playwright.config.ts +1 -0
- package/samples/apps/use-all-bundled/src/app/seed.ts +1 -1
- package/samples/apps/use-all-bundled/src/run-config.ts +2 -1
- package/samples/recipes/auth-mfa/src/web/confirmation-code-step.tsx +32 -10
- package/samples/recipes/chat-channels/README.md +2 -0
- package/samples/recipes/currencies-global/src/entities/currency.ts +1 -0
- package/samples/recipes/helpdesk/README.md +9 -5
- package/samples/recipes/helpdesk/src/feature.ts +6 -3
- package/samples/recipes/managed-pages/README.md +5 -1
- package/samples/recipes/managed-pages/package.json +3 -2
- package/samples/recipes/managed-pages/src/web/branded-preview.tsx +21 -0
- package/samples/recipes/managed-pages/tsconfig.json +8 -0
- package/samples/recipes/pwa-shell/README.md +52 -0
- package/samples/recipes/pwa-shell/bin/server.ts +12 -0
- package/samples/recipes/pwa-shell/package.json +13 -0
- package/samples/recipes/pwa-shell/src/app.ts +34 -0
- package/samples/recipes/rate-limiting/README.md +3 -3
- package/samples/recipes/record-detail-layout/README.md +33 -0
- package/samples/recipes/record-detail-layout/src/feature.ts +525 -44
- package/samples/recipes/record-detail-layout/src/order-board.ts +521 -0
- package/packages/bundled-features/src/managed-pages/web/page-body-section.tsx +0 -72
- package/packages/bundled-features/src/subscription-paddle/tenant-binding.ts +0 -34
- package/packages/bundled-features/src/template-resolver/web/content-field.tsx +0 -61
|
@@ -35,7 +35,7 @@ import {
|
|
|
35
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
|
+
import { assertBillingLive, isBillingLive } from "../shared/index.ts";
|
|
39
39
|
import { SUBSCRIPTION_STRIPE_FEATURE } from "./constants.ts";
|
|
40
40
|
|
|
41
41
|
const API_KEY_HINT =
|
|
@@ -44,14 +44,16 @@ const API_KEY_HINT =
|
|
|
44
44
|
/** Memoize Stripe clients by api-key string — a fresh client is built only
|
|
45
45
|
* when the key actually changes (rotation), so steady-state calls reuse one
|
|
46
46
|
* connection-pooled instance per key. */
|
|
47
|
-
export function createStripeClientCache(
|
|
47
|
+
export function createStripeClientCache(
|
|
48
|
+
clientConfig?: Stripe.StripeConfig,
|
|
49
|
+
): (apiKey: string) => Stripe {
|
|
48
50
|
const cache = new Map<string, Stripe>();
|
|
49
51
|
return (apiKey) => {
|
|
50
52
|
const cached = cache.get(apiKey);
|
|
51
53
|
if (cached) return cached;
|
|
52
54
|
// No apiVersion pin — a string literal breaks consumers' typecheck on newer
|
|
53
55
|
// stripe SDKs; the SDK's own default keeps wire-version and types aligned.
|
|
54
|
-
const client = new Stripe(apiKey);
|
|
56
|
+
const client = new Stripe(apiKey, clientConfig);
|
|
55
57
|
cache.set(apiKey, client);
|
|
56
58
|
return client;
|
|
57
59
|
};
|
|
@@ -62,6 +64,7 @@ export type StripeRuntimeDeps = {
|
|
|
62
64
|
readonly webhookSecretHandle: ConfigKeyHandle<"text">;
|
|
63
65
|
readonly billingLiveHandle: ConfigKeyHandle<"boolean">;
|
|
64
66
|
readonly fallback: { readonly apiKey?: string; readonly webhookSecret?: string };
|
|
67
|
+
readonly clientConfig?: Stripe.StripeConfig;
|
|
65
68
|
};
|
|
66
69
|
|
|
67
70
|
/** Post-tenant runtime: used by checkout/portal/cancel which carry a full
|
|
@@ -95,7 +98,7 @@ export type StripeRuntimes = {
|
|
|
95
98
|
};
|
|
96
99
|
|
|
97
100
|
export function createStripeRuntimes(deps: StripeRuntimeDeps): StripeRuntimes {
|
|
98
|
-
const clientFor = createStripeClientCache();
|
|
101
|
+
const clientFor = createStripeClientCache(deps.clientConfig);
|
|
99
102
|
|
|
100
103
|
async function ctxApiKey(ctx: HandlerContext): Promise<string> {
|
|
101
104
|
let key: string | undefined;
|
|
@@ -136,13 +139,11 @@ export function createStripeRuntimes(deps: StripeRuntimeDeps): StripeRuntimes {
|
|
|
136
139
|
|
|
137
140
|
return {
|
|
138
141
|
ctx: {
|
|
139
|
-
// @wrapper-known semantic-alias
|
|
140
142
|
clientForCtx: async (ctx) => clientFor(await ctxApiKey(ctx)),
|
|
141
143
|
assertBillingLive: (ctx, handlerName = "create-checkout-session") =>
|
|
142
144
|
assertBillingLive(ctx, deps.billingLiveHandle, SUBSCRIPTION_STRIPE_FEATURE, handlerName),
|
|
143
145
|
isBillingEnabled: async (ctx) => {
|
|
144
|
-
|
|
145
|
-
if (live !== true) return false;
|
|
146
|
+
if (!(await isBillingLive(ctx, deps.billingLiveHandle))) return false;
|
|
146
147
|
const hasFallbackKey =
|
|
147
148
|
deps.fallback.apiKey !== undefined && deps.fallback.apiKey.length > 0;
|
|
148
149
|
if (hasFallbackKey) return true;
|
|
@@ -37,7 +37,6 @@ import type {
|
|
|
37
37
|
} from "@cosmicdrift/kumiko-bundled-features/billing-foundation";
|
|
38
38
|
import {
|
|
39
39
|
BillingEventKinds,
|
|
40
|
-
parseProviderConsentId,
|
|
41
40
|
type SubscriptionEventType,
|
|
42
41
|
SubscriptionEventTypes,
|
|
43
42
|
type SubscriptionStatus,
|
|
@@ -165,13 +164,17 @@ export function verifyAndParseStripeWebhook(
|
|
|
165
164
|
return null;
|
|
166
165
|
}
|
|
167
166
|
|
|
168
|
-
|
|
167
|
+
// Only the checkout ledger can vouch for a new subscription, so `created` must name its session.
|
|
168
|
+
const providerCheckoutId =
|
|
169
|
+
normalizedType === SubscriptionEventTypes.created
|
|
170
|
+
? await findCheckoutSessionId(stripe, sub.id)
|
|
171
|
+
: undefined;
|
|
169
172
|
return {
|
|
170
173
|
providerEventId: event.id,
|
|
171
174
|
providerName: STRIPE_PROVIDER_NAME,
|
|
172
175
|
type: normalizedType,
|
|
173
176
|
tenantId,
|
|
174
|
-
...(
|
|
177
|
+
...(providerCheckoutId !== undefined && { providerCheckoutId }),
|
|
175
178
|
providerCustomerId: typeof sub.customer === "string" ? sub.customer : sub.customer.id,
|
|
176
179
|
providerSubscriptionId: sub.id,
|
|
177
180
|
providerEventAt: Temporal.Instant.fromEpochMilliseconds(event.created * 1000).toString(),
|
|
@@ -180,6 +183,24 @@ export function verifyAndParseStripeWebhook(
|
|
|
180
183
|
};
|
|
181
184
|
}
|
|
182
185
|
|
|
186
|
+
// Only a failing Stripe API call is answered with 503 so Stripe redelivers. A successful empty
|
|
187
|
+
// list means the subscription has no checkout session: the created event then carries no
|
|
188
|
+
// checkout id and the foundation ignores it as not in the ledger.
|
|
189
|
+
async function findCheckoutSessionId(
|
|
190
|
+
stripe: Stripe,
|
|
191
|
+
subscriptionId: string,
|
|
192
|
+
): Promise<string | undefined> {
|
|
193
|
+
try {
|
|
194
|
+
const sessions = await stripe.checkout.sessions.list({
|
|
195
|
+
subscription: subscriptionId,
|
|
196
|
+
limit: 1,
|
|
197
|
+
});
|
|
198
|
+
return sessions.data[0]?.id;
|
|
199
|
+
} catch (error) {
|
|
200
|
+
throw transientProviderRejection(error);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
183
204
|
// =============================================================================
|
|
184
205
|
// Shared subscription-state mapping (webhook + retrieveSubscription)
|
|
185
206
|
// =============================================================================
|
|
@@ -294,7 +315,6 @@ export function mapStripeStatus(stripeStatus: Stripe.Subscription.Status): Subsc
|
|
|
294
315
|
/** Gets the subscription from the event. Subscription events include it
|
|
295
316
|
* directly in data.object; invoice events include only the subscription ID
|
|
296
317
|
* and require a lazy fetch via stripe.subscriptions.retrieve. */
|
|
297
|
-
// @wrapper-known semantic-alias
|
|
298
318
|
async function extractSubscriptionFromEvent(
|
|
299
319
|
event: Stripe.Event,
|
|
300
320
|
stripe: Stripe,
|
|
@@ -423,13 +443,11 @@ async function parsePaymentEvent(
|
|
|
423
443
|
return dropPaidSession(event, session, "missing_customer");
|
|
424
444
|
}
|
|
425
445
|
|
|
426
|
-
const consentId = parseProviderConsentId(paymentIntent.metadata?.["consentId"]);
|
|
427
446
|
return {
|
|
428
447
|
kind: BillingEventKinds.payment,
|
|
429
448
|
providerEventId: event.id,
|
|
430
449
|
providerName: STRIPE_PROVIDER_NAME,
|
|
431
450
|
tenantId,
|
|
432
|
-
...(consentId !== undefined && { consentId }),
|
|
433
451
|
providerCheckoutId: session.id,
|
|
434
452
|
providerCustomerId,
|
|
435
453
|
priceId,
|
|
@@ -12,7 +12,6 @@ const TAG_ASSIGNMENT_NAMESPACE = "a7f3c9d2-1b4e-4c8a-9f6d-2e5b8a1c3f7d";
|
|
|
12
12
|
* stream → version_conflict instead of a duplicate row. The assign handler
|
|
13
13
|
* pre-checks existence to keep re-assign idempotent (TX-safe).
|
|
14
14
|
*/
|
|
15
|
-
// @wrapper-known uuid-domain
|
|
16
15
|
export function tagAssignmentAggregateId(
|
|
17
16
|
tenantId: string,
|
|
18
17
|
tagId: string,
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// styles (pattern from config-source-badge.tsx) so it renders the same in the
|
|
6
6
|
// picker, on cards and in screenshots without depending on Tailwind tokens.
|
|
7
7
|
|
|
8
|
-
import type {
|
|
8
|
+
import type { ReactNode } from "react";
|
|
9
9
|
|
|
10
10
|
// YIQ perceived brightness → black text on light backgrounds, white on dark.
|
|
11
11
|
// Returns null for anything that isn't a #rgb/#rrggbb hex so the caller can use
|
|
@@ -33,8 +33,7 @@ function hexToRgb(color: string): { r: number; g: number; b: number } | null {
|
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
const BASE_STYLE: CSSProperties = {
|
|
36
|
+
const BASE_STYLE = {
|
|
38
37
|
display: "inline-flex",
|
|
39
38
|
alignItems: "center",
|
|
40
39
|
padding: "0 8px",
|
|
@@ -43,7 +42,7 @@ const BASE_STYLE: CSSProperties = {
|
|
|
43
42
|
lineHeight: "20px",
|
|
44
43
|
borderRadius: "9999px",
|
|
45
44
|
whiteSpace: "nowrap",
|
|
46
|
-
};
|
|
45
|
+
} as const;
|
|
47
46
|
|
|
48
47
|
const NEUTRAL = { backgroundColor: "#e5e7eb", color: "#374151" } as const;
|
|
49
48
|
|
|
@@ -71,7 +70,7 @@ export function TagChip({
|
|
|
71
70
|
const fg = color != null && color !== "" ? contrastText(color) : null;
|
|
72
71
|
const palette = fg !== null && color != null ? { backgroundColor: color, color: fg } : NEUTRAL;
|
|
73
72
|
return (
|
|
74
|
-
//
|
|
73
|
+
// biome-ignore lint/style/noInlineStyles: Tag color is user-defined (hex from the DB), no finite token palette possible
|
|
75
74
|
<span data-testid="tag-chip" style={{ ...BASE_STYLE, ...palette }}>
|
|
76
75
|
{name}
|
|
77
76
|
</span>
|
|
@@ -64,13 +64,14 @@ function ColorPicker({
|
|
|
64
64
|
<div className="flex items-center gap-2">
|
|
65
65
|
<div className="flex flex-wrap gap-1">
|
|
66
66
|
{PRESET_COLORS.map((c) => (
|
|
67
|
-
//
|
|
67
|
+
// biome-ignore lint/plugin: color swatch needs a raw colored button — Button is variant-styled.
|
|
68
68
|
<button
|
|
69
69
|
key={c}
|
|
70
70
|
type="button"
|
|
71
71
|
aria-label={c}
|
|
72
72
|
data-testid={`${idPrefix}-swatch-${c}`}
|
|
73
73
|
onClick={() => onChange(c)}
|
|
74
|
+
// biome-ignore lint/style/noInlineStyles: Preset swatch color is user-defined (hex), no finite token palette possible
|
|
74
75
|
style={{
|
|
75
76
|
width: 22,
|
|
76
77
|
height: 22,
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
import type { DbRunner, TenantDb } from "@cosmicdrift/kumiko-framework/db";
|
|
6
6
|
import { selectMany } from "@cosmicdrift/kumiko-framework/db";
|
|
7
7
|
import type { Registry, SessionUser, TenantId } from "@cosmicdrift/kumiko-framework/engine";
|
|
8
|
-
import { InternalError } from "@cosmicdrift/kumiko-framework/errors";
|
|
9
8
|
import type { Temporal } from "@cosmicdrift/kumiko-types/temporal";
|
|
10
9
|
import type { FileAttachmentRef } from "../renderer-foundation/index.ts";
|
|
10
|
+
import { requireBootstrapExtension } from "../shared/index.ts";
|
|
11
11
|
import {
|
|
12
12
|
fileAttachmentsOf,
|
|
13
13
|
imageLinksOf,
|
|
@@ -335,18 +335,11 @@ export function requireTemplateResolver(
|
|
|
335
335
|
ctx: { readonly services: { readonly extensions: Readonly<Record<string, unknown>> } },
|
|
336
336
|
callerName: string,
|
|
337
337
|
): TemplateResolverApi {
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
message:
|
|
344
|
-
`[${callerName}] ctx.templateResolver missing — App-Bootstrap muss ` +
|
|
345
|
-
`extraContext: { templateResolver: createTemplateResolverApi(db, registry) } setzen ` +
|
|
346
|
-
`(siehe template-resolver/README.md).`,
|
|
347
|
-
});
|
|
348
|
-
}
|
|
349
|
-
return api;
|
|
338
|
+
return requireBootstrapExtension<TemplateResolverApi>(ctx, callerName, {
|
|
339
|
+
key: "templateResolver",
|
|
340
|
+
bootstrapExample: "templateResolver: createTemplateResolverApi(db, registry)",
|
|
341
|
+
readme: "template-resolver/README.md",
|
|
342
|
+
});
|
|
350
343
|
}
|
|
351
344
|
|
|
352
345
|
export type { SessionUser };
|
|
@@ -1,4 +1,40 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"version": "0.414.0",
|
|
4
|
+
"type": "improvement",
|
|
5
|
+
"title": "text-block and collection-entry masks on the editor workbench, the preview toggle under the field is gone",
|
|
6
|
+
"detail": "The text-block editor and the collection-entry create form open on `EditorWorkbench` with an edit and a preview mode and the placeholder example values in the right rail. `previewTargetOfKind` and `previewTargetOfCollectionKind` map a template kind to its preview target: text-block previews as `web`, snippet and ai-prompt as `text`. New query `template-resolver:query:body-preview` (roles that may write a body: SystemAdmin, the `tenantEditable` roles and TenantAdmin) renders an unsaved body (`body`, optional `bodyFormat` markdown or document) to the HTML the public page serves, without saving; a document body the write rules reject answers with the field errors of a save. `WebPreviewRenderer` is exported from `template-resolver/web` and registered as `contentPreviews.web`; `contentPreviews.text` shows document-format entries with the example values filled in client-side (escaped, in the sandboxed mail frame, no server call), other formats stay plain text. Legal text previews work in apps that mount legal-pages without managed-pages. A text without placeholders shows no example-values section. `ContentField` and its inline Vorschau toggle are removed. New keys `template-resolver.editor.{infoEdit,infoPreview,localeLabel,rail*}` in all locale packages."
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
"version": "0.414.0",
|
|
10
|
+
"type": "fix",
|
|
11
|
+
"title": "Collection entries via decryptStoredPii",
|
|
12
|
+
"detail": "template-resolver reads collection entries via decryptStoredPii."
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"version": "0.414.0",
|
|
16
|
+
"type": "fix",
|
|
17
|
+
"title": "Seeding removes system templates of notifications that no longer exist",
|
|
18
|
+
"detail": "`seedNotificationTemplates` deletes, through the event-based delete write, the system mail templates `<feature>:notify:<name>` whose feature is mounted but whose notification is gone, and those stored under a `renamedFrom` name. Tenant overrides of such slugs are kept and reported once per slug with a warning (slug and count only). Templates of features that are not mounted stay untouched."
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"version": "0.414.0",
|
|
22
|
+
"type": "improvement",
|
|
23
|
+
"title": "A template test mail is logged as a delivery attempt",
|
|
24
|
+
"detail": "`send-test` now writes one delivery attempt per test mail (notification type `template-resolver:test-mail`, channel `email`, the caller as recipient, status and error code of the send, address masked like every attempt), also when the send fails, so test mails show up in the delivery log. The attempt is written on the outside-transaction connection through the delivery attempt log, which the delivery feature now exports as `logAttempt`."
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"version": "0.414.0",
|
|
28
|
+
"type": "fix",
|
|
29
|
+
"title": "Test mail attempt log works from agent tool calls",
|
|
30
|
+
"detail": "send-test drops its unsafeRaw escapeHatch, which the agent tool-call scope refuses. The attempt row is written by delivery (createDeliveryAttemptLogFactory, bound per call as ctx.services._logOwnDeliveryAttempt) on the outside-transaction connection, so a failed test mail stays logged after the handler transaction rolls back. Apps that build their own extraContext without createDeliveryTestContext or the prod boot must set _deliveryAttemptLogFactory, otherwise send-test fails closed before sending."
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"version": "0.414.0",
|
|
34
|
+
"type": "improvement",
|
|
35
|
+
"title": "Overview query filters by slug",
|
|
36
|
+
"detail": "`template-resolver:query:overview` accepts `slug` as a filter field next to kindGroup, kind, origin and status, so a client can fetch the one row of an open template instead of paging through its kind."
|
|
37
|
+
},
|
|
2
38
|
{
|
|
3
39
|
"version": "0.402.0",
|
|
4
40
|
"type": "improvement",
|
|
@@ -22,6 +22,7 @@ export type DocumentViolationCode =
|
|
|
22
22
|
| "script_element"
|
|
23
23
|
| "event_handler_attribute"
|
|
24
24
|
| "disallowed_link_href"
|
|
25
|
+
| "relative_link_without_base"
|
|
25
26
|
| "external_image_source"
|
|
26
27
|
| "image_without_resource"
|
|
27
28
|
| "invalid_reference_name"
|
|
@@ -355,6 +356,25 @@ function imagesBlockViolation(input: SanitizeBodyInput): DocumentViolation | nul
|
|
|
355
356
|
: null;
|
|
356
357
|
}
|
|
357
358
|
|
|
359
|
+
// Mails and PDFs have no base address, so compileDocumentBody turns a relative href into "#"; refuse it
|
|
360
|
+
// on save instead of losing the admin's input silently. Managed pages resolve it against their host.
|
|
361
|
+
function relativeLinkViolations(html: string): DocumentViolation[] {
|
|
362
|
+
return withParsedDocument(html, (body) =>
|
|
363
|
+
Array.from(body.querySelectorAll("a[href]")).flatMap((anchor) => {
|
|
364
|
+
const href = anchor.getAttribute("href") ?? "";
|
|
365
|
+
return isAllowedDocumentLinkHref(href) && !isAllowedDocumentUrlHref(href)
|
|
366
|
+
? [
|
|
367
|
+
violation(
|
|
368
|
+
"relative_link_without_base",
|
|
369
|
+
href,
|
|
370
|
+
`Link target "${href}" is relative, but mails and PDF documents have no base address; use an absolute https link`,
|
|
371
|
+
),
|
|
372
|
+
]
|
|
373
|
+
: [];
|
|
374
|
+
}),
|
|
375
|
+
);
|
|
376
|
+
}
|
|
377
|
+
|
|
358
378
|
export function sanitizeTemplateBody(input: SanitizeBodyInput): SanitizeBodyResult {
|
|
359
379
|
const formatViolation = requiredFormatViolation(input.kind, input.contentFormat);
|
|
360
380
|
if (formatViolation !== null) return { ok: false, violations: [formatViolation] };
|
|
@@ -363,6 +383,10 @@ export function sanitizeTemplateBody(input: SanitizeBodyInput): SanitizeBodyResu
|
|
|
363
383
|
if (!isSanitizedBody(input) || input.contentFormat !== "html" || input.content === null) {
|
|
364
384
|
return { ok: true, content: input.content };
|
|
365
385
|
}
|
|
386
|
+
if (HTML_ONLY_KINDS.has(input.kind)) {
|
|
387
|
+
const relativeLinks = relativeLinkViolations(input.content);
|
|
388
|
+
if (relativeLinks.length > 0) return { ok: false, violations: relativeLinks };
|
|
389
|
+
}
|
|
366
390
|
const result = sanitizeDocumentHtml(input.content);
|
|
367
391
|
return result.ok ? { ok: true, content: result.html } : result;
|
|
368
392
|
}
|
|
@@ -371,6 +395,7 @@ const VIOLATION_I18N_KEYS: Readonly<Record<DocumentViolationCode, string>> = {
|
|
|
371
395
|
script_element: "templateResolver.errors.document.scriptElement",
|
|
372
396
|
event_handler_attribute: "templateResolver.errors.document.eventHandlerAttribute",
|
|
373
397
|
disallowed_link_href: "templateResolver.errors.document.disallowedLinkHref",
|
|
398
|
+
relative_link_without_base: "templateResolver.errors.document.relativeLinkWithoutBase",
|
|
374
399
|
external_image_source: "templateResolver.errors.document.externalImageSource",
|
|
375
400
|
image_without_resource: "templateResolver.errors.document.imageWithoutResource",
|
|
376
401
|
invalid_reference_name: "templateResolver.errors.document.invalidReferenceName",
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
type TreeAction,
|
|
7
7
|
} from "@cosmicdrift/kumiko-framework/engine";
|
|
8
8
|
import { TEMPLATE_RESOLVER_BOOT_RULES } from "./boot-rules.ts";
|
|
9
|
+
import { makeBodyPreviewQuery } from "./handlers/body-preview.query.ts";
|
|
9
10
|
import { bySlugQuery } from "./handlers/by-slug.query.ts";
|
|
10
11
|
import { byTenantQuery } from "./handlers/by-tenant.query.ts";
|
|
11
12
|
import { makeCollectionItemQuery } from "./handlers/collection-item.query.ts";
|
|
@@ -202,6 +203,7 @@ export function createTemplateResolverFeature(opts: TemplateResolverOptions = {}
|
|
|
202
203
|
diffToSystem: r.queryHandler(diffToSystemQuery),
|
|
203
204
|
validate: r.queryHandler(validateQuery),
|
|
204
205
|
preview: r.queryHandler(previewQuery),
|
|
206
|
+
bodyPreview: r.queryHandler(makeBodyPreviewQuery(policy)),
|
|
205
207
|
documentBlocks: r.queryHandler(documentBlocksQuery),
|
|
206
208
|
exportBundle: r.queryHandler(exportBundleQuery),
|
|
207
209
|
sendTestStatus: r.queryHandler(makeSendTestStatusQuery(policy)),
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { defineQueryHandler } from "@cosmicdrift/kumiko-framework/engine";
|
|
2
|
+
import { ValidationError } from "@cosmicdrift/kumiko-framework/errors";
|
|
3
|
+
import * as z from "zod";
|
|
4
|
+
import { renderSafeMarkdown } from "../../page-render/index.ts";
|
|
5
|
+
import { documentViolationsToFieldIssues, sanitizeDocumentHtml } from "../document-sanitizer.ts";
|
|
6
|
+
import { type TemplateEditPolicy, templateEditAccess } from "../template-edit-policy.ts";
|
|
7
|
+
|
|
8
|
+
const BODY_PREVIEW_FORMATS = ["markdown", "document"] as const;
|
|
9
|
+
|
|
10
|
+
// One query behind the editors' "web" preview (page bodies and legal texts): both render
|
|
11
|
+
// through the same page-render markdown core and the document sanitizer. Nothing is cached, so a
|
|
12
|
+
// draft is always rendered fresh. The access is everyone who may write either kind of body: the
|
|
13
|
+
// roles editing text blocks (SystemAdmin plus the tenantEditable roles) and the TenantAdmin who
|
|
14
|
+
// writes managed pages.
|
|
15
|
+
export function makeBodyPreviewQuery(policy: TemplateEditPolicy) {
|
|
16
|
+
return defineQueryHandler({
|
|
17
|
+
name: "body-preview",
|
|
18
|
+
schema: z.object({
|
|
19
|
+
body: z.string().max(100_000).nullable(),
|
|
20
|
+
bodyFormat: z.enum(BODY_PREVIEW_FORMATS).default("markdown"),
|
|
21
|
+
}),
|
|
22
|
+
access: {
|
|
23
|
+
roles: [...new Set([...templateEditAccess(policy.tenantEditable).roles, "TenantAdmin"])],
|
|
24
|
+
},
|
|
25
|
+
description:
|
|
26
|
+
"Renders an unsaved body (Markdown or editor document, per bodyFormat) to the sanitized HTML a public page serves for it, without saving anything and without the site's header and footer; a document body the write rules reject is answered with the same field errors on body as a save.",
|
|
27
|
+
handler: async (query) => {
|
|
28
|
+
const { body, bodyFormat } = query.payload;
|
|
29
|
+
if (body === null || body === "") return { html: "" };
|
|
30
|
+
if (bodyFormat === "markdown") return { html: renderSafeMarkdown(body) };
|
|
31
|
+
const sanitized = sanitizeDocumentHtml(body);
|
|
32
|
+
if (sanitized.ok) return { html: sanitized.html };
|
|
33
|
+
throw new ValidationError({
|
|
34
|
+
fields: documentViolationsToFieldIssues(sanitized.violations).map((issue) => ({
|
|
35
|
+
...issue,
|
|
36
|
+
path: "body",
|
|
37
|
+
})),
|
|
38
|
+
});
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
}
|
|
@@ -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"
|
|
29
|
+
access: { roles: ["anonymous"], 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.",
|
|
@@ -31,7 +31,7 @@ export const byTenantQuery = defineQueryHandler({
|
|
|
31
31
|
/** Optional cross-tenant read — SystemAdmin only. Symmetric to by-slug. */
|
|
32
32
|
tenantIdOverride: z.string().min(1).optional(),
|
|
33
33
|
}),
|
|
34
|
-
access: { roles: ["anonymous"
|
|
34
|
+
access: { roles: ["anonymous"], anySignedIn: true },
|
|
35
35
|
rateLimit: { per: "ip+handler", limit: 60, windowSeconds: 60 },
|
|
36
36
|
description:
|
|
37
37
|
"Lists every text-block of a tenant with slug, locale, title and body so a public content tree can be rendered in one call; use it for the whole sidebar, and by-slug when only one block is needed.",
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
import { requestContext } from "@cosmicdrift/kumiko-framework/api";
|
|
2
|
-
import {
|
|
3
|
-
configuredPiiSubjectKms,
|
|
4
|
-
decryptPiiFieldValues,
|
|
5
|
-
} from "@cosmicdrift/kumiko-framework/crypto";
|
|
6
1
|
import type { EventStoreExecutor } from "@cosmicdrift/kumiko-framework/db";
|
|
7
2
|
import { createEventStoreExecutor } from "@cosmicdrift/kumiko-framework/db";
|
|
8
3
|
import type {
|
|
@@ -12,6 +7,7 @@ import type {
|
|
|
12
7
|
} from "@cosmicdrift/kumiko-framework/engine";
|
|
13
8
|
import { SYSTEM_TENANT_ID } from "@cosmicdrift/kumiko-framework/engine";
|
|
14
9
|
import type { Temporal } from "@cosmicdrift/kumiko-types/temporal";
|
|
10
|
+
import { decryptStoredPii } from "../../shared/index.ts";
|
|
15
11
|
import { templateResourceEntity, templateResourcesTable } from "../table.ts";
|
|
16
12
|
import { userContentEntriesTable, userContentEntryEntity } from "../user-content-table.ts";
|
|
17
13
|
import type { ContentFormat } from "../web/constants.ts";
|
|
@@ -88,13 +84,11 @@ export async function readableCollectionEntry(
|
|
|
88
84
|
store: CollectionStore,
|
|
89
85
|
fallbackRequestId: string,
|
|
90
86
|
) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
87
|
+
if (!store.contentIsPii || row.content === null) return toCollectionEntry(row);
|
|
88
|
+
return toCollectionEntry({
|
|
89
|
+
...row,
|
|
90
|
+
content: await decryptStoredPii(row.content, "content", fallbackRequestId),
|
|
95
91
|
});
|
|
96
|
-
const content = decrypted["content"];
|
|
97
|
-
return toCollectionEntry({ ...row, content: typeof content === "string" ? content : null });
|
|
98
92
|
}
|
|
99
93
|
|
|
100
94
|
export function toCollectionEntry(row: CollectionEntryRow) {
|
|
@@ -226,8 +226,9 @@ function isSortField(value: string): value is SortField {
|
|
|
226
226
|
}
|
|
227
227
|
|
|
228
228
|
type OverviewDraft = Omit<OverviewRow, "usedBy" | "usedByCount">;
|
|
229
|
+
const OVERVIEW_FILTER_FIELDS = ["kindGroup", "kind", "origin", "status", "slug"] as const;
|
|
229
230
|
type OverviewFilter = {
|
|
230
|
-
readonly field:
|
|
231
|
+
readonly field: (typeof OVERVIEW_FILTER_FIELDS)[number];
|
|
231
232
|
readonly value: readonly string[];
|
|
232
233
|
};
|
|
233
234
|
|
|
@@ -381,7 +382,7 @@ function filterRows(
|
|
|
381
382
|
}
|
|
382
383
|
|
|
383
384
|
const filterSchema = z.object({
|
|
384
|
-
field: z.enum(
|
|
385
|
+
field: z.enum(OVERVIEW_FILTER_FIELDS),
|
|
385
386
|
op: z.literal("in"),
|
|
386
387
|
value: z.array(z.string()),
|
|
387
388
|
});
|
|
@@ -1,6 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
type DeliveryErrorCode,
|
|
3
|
+
defineWriteHandler,
|
|
4
|
+
type NotifyDeliveryStatus,
|
|
5
|
+
} from "@cosmicdrift/kumiko-framework/engine";
|
|
6
|
+
import {
|
|
7
|
+
InternalError,
|
|
8
|
+
UnprocessableError,
|
|
9
|
+
writeFailure,
|
|
10
|
+
} from "@cosmicdrift/kumiko-framework/errors";
|
|
3
11
|
import * as z from "zod";
|
|
12
|
+
import { type ChannelResult, EMAIL_CHANNEL_NAME } from "../../delivery/index.ts";
|
|
4
13
|
import { unprocessable } from "../../shared/index.ts";
|
|
5
14
|
import {
|
|
6
15
|
refuseTemplateEdit,
|
|
@@ -8,7 +17,7 @@ import {
|
|
|
8
17
|
templateEditAccess,
|
|
9
18
|
} from "../template-edit-policy.ts";
|
|
10
19
|
import { renderTemplatePreview } from "../template-preview.ts";
|
|
11
|
-
import { TEST_MAIL_SUBJECT_PREFIX } from "../web/constants.ts";
|
|
20
|
+
import { TEST_MAIL_NOTIFICATION_TYPE, TEST_MAIL_SUBJECT_PREFIX } from "../web/constants.ts";
|
|
12
21
|
import { TemplateResolverErrors } from "../web/qualified-names.ts";
|
|
13
22
|
import {
|
|
14
23
|
emailChannelOf,
|
|
@@ -77,6 +86,14 @@ export function makeSendTestWrite(policy: TemplateEditPolicy) {
|
|
|
77
86
|
}),
|
|
78
87
|
);
|
|
79
88
|
}
|
|
89
|
+
// Fail closed before sending: a test mail must never leave without its attempt row.
|
|
90
|
+
const logOwnDeliveryAttempt = ctx.services._logOwnDeliveryAttempt;
|
|
91
|
+
if (logOwnDeliveryAttempt === undefined) {
|
|
92
|
+
throw new InternalError({
|
|
93
|
+
message:
|
|
94
|
+
"template test mail: no delivery attempt log wired; the delivery boot context (createDeliveryTestContext in tests) sets _deliveryAttemptLogFactory",
|
|
95
|
+
});
|
|
96
|
+
}
|
|
80
97
|
const channelContext = testMailChannelContext(ctx, event.user);
|
|
81
98
|
const address = await resolveTestMailAddress(channel, channelContext, event.user);
|
|
82
99
|
if (address === null) {
|
|
@@ -88,9 +105,19 @@ export function makeSendTestWrite(policy: TemplateEditPolicy) {
|
|
|
88
105
|
}
|
|
89
106
|
|
|
90
107
|
const subject = `${prefixSubject ? TEST_MAIL_SUBJECT_PREFIX : ""}${preview.subject ?? ""}`;
|
|
91
|
-
|
|
108
|
+
// Delivery logs on its own connection, so a failed send stays logged although this handler's transaction rolls back.
|
|
109
|
+
const logTestMail = (status: NotifyDeliveryStatus, error: DeliveryErrorCode | null) =>
|
|
110
|
+
logOwnDeliveryAttempt({
|
|
111
|
+
notificationType: TEST_MAIL_NOTIFICATION_TYPE,
|
|
112
|
+
channel: EMAIL_CHANNEL_NAME,
|
|
113
|
+
recipientAddress: address,
|
|
114
|
+
status,
|
|
115
|
+
error,
|
|
116
|
+
priority: "normal",
|
|
117
|
+
});
|
|
118
|
+
let result: ChannelResult;
|
|
92
119
|
try {
|
|
93
|
-
|
|
120
|
+
result = await channel.send(
|
|
94
121
|
address,
|
|
95
122
|
{
|
|
96
123
|
// The template slug is the notification name, so the test mail takes the transport the real mail takes.
|
|
@@ -109,7 +136,6 @@ export function makeSendTestWrite(policy: TemplateEditPolicy) {
|
|
|
109
136
|
attachments: mailAttachments,
|
|
110
137
|
},
|
|
111
138
|
);
|
|
112
|
-
sentStatus = result.status;
|
|
113
139
|
} catch (error) {
|
|
114
140
|
// Class and code only: the message can carry the address or a provider response body.
|
|
115
141
|
ctx.obs.log?.warn("template test mail: channel threw", {
|
|
@@ -117,15 +143,18 @@ export function makeSendTestWrite(policy: TemplateEditPolicy) {
|
|
|
117
143
|
errorClass: error instanceof Error ? error.name : typeof error,
|
|
118
144
|
errorCode: errorCodeOf(error),
|
|
119
145
|
});
|
|
146
|
+
await logTestMail("failed", "channel_error");
|
|
120
147
|
return testMailFailed("channel_error");
|
|
121
148
|
}
|
|
122
|
-
if (
|
|
149
|
+
if (result.status !== "sent") {
|
|
123
150
|
ctx.obs.log?.warn("template test mail: channel did not send", {
|
|
124
151
|
tenantId: event.user.tenantId,
|
|
125
|
-
status:
|
|
152
|
+
status: result.status,
|
|
126
153
|
});
|
|
154
|
+
await logTestMail(result.status, result.error ?? "send_failed");
|
|
127
155
|
return testMailFailed("not_sent");
|
|
128
156
|
}
|
|
157
|
+
await logTestMail("sent", null);
|
|
129
158
|
return { isSuccess: true as const, data: { subject, checks: preview.checks } };
|
|
130
159
|
},
|
|
131
160
|
});
|
|
@@ -2,6 +2,7 @@ import { isPlainObject } from "@cosmicdrift/kumiko-types/type-guards";
|
|
|
2
2
|
import * as z from "zod";
|
|
3
3
|
import type { FileAttachmentRef } from "../renderer-foundation/index.ts";
|
|
4
4
|
import { pdfAttachmentFileNamePatternSchema, templateSlugSchema } from "./template-meta.ts";
|
|
5
|
+
import { stringValuesOf } from "./web/string-values.ts";
|
|
5
6
|
|
|
6
7
|
export const templatePdfAttachmentLinkSchema = z
|
|
7
8
|
.object({
|
|
@@ -66,11 +67,7 @@ export function parseLinkedResourceEntries(
|
|
|
66
67
|
export function imageLinksOf(
|
|
67
68
|
entries: Readonly<Record<string, LinkedResourceEntry>>,
|
|
68
69
|
): Record<string, string> {
|
|
69
|
-
|
|
70
|
-
for (const [key, entry] of Object.entries(entries)) {
|
|
71
|
-
if (typeof entry === "string") images[key] = entry;
|
|
72
|
-
}
|
|
73
|
-
return images;
|
|
70
|
+
return stringValuesOf(entries);
|
|
74
71
|
}
|
|
75
72
|
|
|
76
73
|
function entriesOfKind<TEntry extends LinkedResourceEntry>(
|