@cosmicdrift/kumiko-samples 0.413.1 → 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 +12 -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 +1 -5
- 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 +50 -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/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
package/packages/bundled-features/src/billing-foundation/handlers/process-payment-event.write.ts
CHANGED
|
@@ -6,7 +6,9 @@
|
|
|
6
6
|
// 1. Idempotency-check: loads the payment-stream and scans for an
|
|
7
7
|
// already-seen `metadata.providerEventId`. A provider-replay with
|
|
8
8
|
// the same event-id → duplicate=true, no second append.
|
|
9
|
-
// 2.
|
|
9
|
+
// 2. Ledger check: the payment must name a checkout the server opened itself
|
|
10
|
+
// (same provider, same price); anything else is ignored.
|
|
11
|
+
// 3. ctx.events.unsafeAppend — inline-projection materializes a new
|
|
10
12
|
// `read_payments`-row (INSERT-once, not UPSERT — every payment is
|
|
11
13
|
// its own fact, not a state-update).
|
|
12
14
|
|
|
@@ -17,6 +19,7 @@ import {
|
|
|
17
19
|
import type { WriteHandlerDef } from "@cosmicdrift/kumiko-framework/engine";
|
|
18
20
|
import * as z from "zod";
|
|
19
21
|
import { paymentAggregateId } from "../aggregate-id.ts";
|
|
22
|
+
import { findCheckoutOpened } from "../checkout-ledger.ts";
|
|
20
23
|
import { PAYMENT_PII_FIELDS, paymentEntity } from "../entities.ts";
|
|
21
24
|
import {
|
|
22
25
|
PAYMENT_AGGREGATE_TYPE,
|
|
@@ -29,11 +32,10 @@ import { hasSeenProviderEvent } from "../provider-event-seen.ts";
|
|
|
29
32
|
export const processPaymentEventSchema = z.object({
|
|
30
33
|
providerEventId: z.string().min(1).max(200),
|
|
31
34
|
providerName: z.string().min(1).max(50),
|
|
32
|
-
providerCheckoutId: z.string().min(1).max(200)
|
|
35
|
+
providerCheckoutId: z.string().min(1).max(200),
|
|
33
36
|
providerCustomerId: z.string().min(1).max(200),
|
|
34
37
|
priceId: z.string().min(1).max(200),
|
|
35
38
|
quantity: z.number().int().positive().optional(),
|
|
36
|
-
consentId: z.string().min(1).max(100).optional(),
|
|
37
39
|
});
|
|
38
40
|
type ProcessPaymentEventPayload = z.infer<typeof processPaymentEventSchema>;
|
|
39
41
|
|
|
@@ -66,7 +68,31 @@ export const processPaymentEventHandler: WriteHandlerDef = {
|
|
|
66
68
|
}
|
|
67
69
|
|
|
68
70
|
// ---------------------------------------------------------------
|
|
69
|
-
// 2.
|
|
71
|
+
// 2. Ledger: only checkouts this server opened may produce a payment.
|
|
72
|
+
// ---------------------------------------------------------------
|
|
73
|
+
const entry = findCheckoutOpened(existingEvents, {
|
|
74
|
+
providerName: payload.providerName,
|
|
75
|
+
providerCheckoutId: payload.providerCheckoutId,
|
|
76
|
+
mode: "payment",
|
|
77
|
+
});
|
|
78
|
+
const rejection =
|
|
79
|
+
entry === undefined
|
|
80
|
+
? "checkout_not_in_ledger"
|
|
81
|
+
: entry.priceId !== payload.priceId
|
|
82
|
+
? "price_mismatch"
|
|
83
|
+
: undefined;
|
|
84
|
+
if (rejection !== undefined) {
|
|
85
|
+
ctx.obs.log?.warn(
|
|
86
|
+
`[billing-foundation:process-payment-event] ignored ${payload.providerEventId} (${rejection}): checkout ${payload.providerCheckoutId} of provider ${payload.providerName}`,
|
|
87
|
+
);
|
|
88
|
+
return {
|
|
89
|
+
isSuccess: true as const,
|
|
90
|
+
data: { ignored: true as const, reason: rejection, paymentAggregateId: aggId },
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// ---------------------------------------------------------------
|
|
95
|
+
// 3. Encrypt the provider-subject PII field before it touches storage
|
|
70
96
|
// — same rationale as process-event.write.ts's step 3.
|
|
71
97
|
// ---------------------------------------------------------------
|
|
72
98
|
const piiKms = configuredPiiSubjectKms();
|
|
@@ -85,7 +111,7 @@ export const processPaymentEventHandler: WriteHandlerDef = {
|
|
|
85
111
|
: { providerCustomerId: payload.providerCustomerId };
|
|
86
112
|
|
|
87
113
|
// ---------------------------------------------------------------
|
|
88
|
-
//
|
|
114
|
+
// 4. Append event on the payment-stream. Inline-projection
|
|
89
115
|
// materializes a new read_payments-row in the same TX.
|
|
90
116
|
// ---------------------------------------------------------------
|
|
91
117
|
const eventPayload: PaymentEventPayload = {
|
|
@@ -93,14 +119,12 @@ export const processPaymentEventHandler: WriteHandlerDef = {
|
|
|
93
119
|
providerCustomerId: encryptedFields.providerCustomerId,
|
|
94
120
|
priceId: payload.priceId,
|
|
95
121
|
...(payload.quantity !== undefined && { quantity: payload.quantity }),
|
|
96
|
-
...(
|
|
122
|
+
...(entry?.consentId !== undefined && { consentId: entry.consentId }),
|
|
97
123
|
};
|
|
98
124
|
const headers: PaymentEventHeaders = {
|
|
99
125
|
providerEventId: payload.providerEventId,
|
|
100
126
|
providerName: payload.providerName,
|
|
101
|
-
|
|
102
|
-
providerCheckoutId: payload.providerCheckoutId,
|
|
103
|
-
}),
|
|
127
|
+
providerCheckoutId: payload.providerCheckoutId,
|
|
104
128
|
};
|
|
105
129
|
await ctx.events.unsafeAppend({
|
|
106
130
|
aggregateId: aggId,
|
package/packages/bundled-features/src/billing-foundation/handlers/record-checkout-opened.write.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// record-checkout-opened — ledgers a checkout that was opened before the
|
|
2
|
+
// ledger existed (provider migration jobs). Idempotent: an existing entry is
|
|
3
|
+
// left alone.
|
|
4
|
+
|
|
5
|
+
import type { WriteHandlerDef } from "@cosmicdrift/kumiko-framework/engine";
|
|
6
|
+
import { appendCheckoutOpened, findCheckoutOpened, ledgerAggregateId } from "../checkout-ledger.ts";
|
|
7
|
+
import { type CheckoutOpenedPayload, checkoutOpenedPayloadSchema } from "../events.ts";
|
|
8
|
+
|
|
9
|
+
export const recordCheckoutOpenedHandler: WriteHandlerDef = {
|
|
10
|
+
name: "record-checkout-opened",
|
|
11
|
+
agent: { expose: false },
|
|
12
|
+
schema: checkoutOpenedPayloadSchema,
|
|
13
|
+
access: { roles: ["SystemAdmin"] },
|
|
14
|
+
handler: async (event, ctx) => {
|
|
15
|
+
// @cast-boundary engine-payload — dispatcher-zod-validated payload
|
|
16
|
+
const entry = event.payload as CheckoutOpenedPayload;
|
|
17
|
+
const tenantId = event.user.tenantId;
|
|
18
|
+
const existing = await ctx.events.load(ledgerAggregateId(tenantId, entry.mode));
|
|
19
|
+
if (findCheckoutOpened(existing, entry) !== undefined) {
|
|
20
|
+
return { isSuccess: true as const, data: { recorded: false as const } };
|
|
21
|
+
}
|
|
22
|
+
await appendCheckoutOpened(ctx, tenantId, entry);
|
|
23
|
+
return { isSuccess: true as const, data: { recorded: true as const } };
|
|
24
|
+
},
|
|
25
|
+
};
|
package/packages/bundled-features/src/billing-foundation/handlers/start-plan-checkout.write.ts
CHANGED
|
@@ -103,7 +103,13 @@ export function createStartPlanCheckoutHandler(
|
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
const consent = consumerProtection
|
|
106
|
-
? await prepareConsent(
|
|
106
|
+
? await prepareConsent(
|
|
107
|
+
ctx,
|
|
108
|
+
consumerProtection,
|
|
109
|
+
payload.consent,
|
|
110
|
+
"subscription",
|
|
111
|
+
providerName,
|
|
112
|
+
)
|
|
107
113
|
: undefined;
|
|
108
114
|
|
|
109
115
|
const baseUrl = options.baseUrl ?? "";
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
prepareConsent,
|
|
15
15
|
recordConsent,
|
|
16
16
|
} from "../consumer-protection/consent-gate.ts";
|
|
17
|
+
import { assertNoPendingPlanSwitch, recordPlanSwitchRequested } from "../pending-plan-switch.ts";
|
|
17
18
|
import { purchaseRolesOf } from "../plan-catalog.ts";
|
|
18
19
|
import { type PreparedPlanSwitch, preparePlanSwitch } from "../plan-switch.ts";
|
|
19
20
|
import type { BillingPlanCatalog, ResolvedBillingFoundationOptions } from "../types.ts";
|
|
@@ -64,8 +65,8 @@ export function createSwitchPlanHandler(
|
|
|
64
65
|
};
|
|
65
66
|
}
|
|
66
67
|
|
|
67
|
-
// Consent
|
|
68
|
-
//
|
|
68
|
+
// Consent and the pending marker are recorded before the provider call, and a failing apply rolls
|
|
69
|
+
// the whole handler back. The webhook later picks the consent up again through pendingSwitchConsentId.
|
|
69
70
|
async function applyInApp(
|
|
70
71
|
prepared: PreparedPlanSwitch,
|
|
71
72
|
payload: { readonly tier: string; readonly consent?: ConsentPayload },
|
|
@@ -78,8 +79,15 @@ async function applyInApp(
|
|
|
78
79
|
message: `billing-foundation: provider "${providerName}" has neither createPlanSwitchSession nor applyPlanSwitch`,
|
|
79
80
|
});
|
|
80
81
|
}
|
|
82
|
+
await assertNoPendingPlanSwitch(ctx, options.now());
|
|
81
83
|
const consent = options.consumerProtection
|
|
82
|
-
? await prepareConsent(
|
|
84
|
+
? await prepareConsent(
|
|
85
|
+
ctx,
|
|
86
|
+
options.consumerProtection,
|
|
87
|
+
payload.consent,
|
|
88
|
+
"subscription",
|
|
89
|
+
providerName,
|
|
90
|
+
)
|
|
83
91
|
: undefined;
|
|
84
92
|
if (consent) {
|
|
85
93
|
await recordConsent(ctx, consent, {
|
|
@@ -89,11 +97,15 @@ async function applyInApp(
|
|
|
89
97
|
providerName,
|
|
90
98
|
});
|
|
91
99
|
}
|
|
100
|
+
await recordPlanSwitchRequested(ctx, {
|
|
101
|
+
tier: payload.tier,
|
|
102
|
+
priceId: prepared.target.priceId,
|
|
103
|
+
now: options.now(),
|
|
104
|
+
});
|
|
92
105
|
await plugin.applyPlanSwitch(ctx, {
|
|
93
106
|
providerSubscriptionId: prepared.subscription.providerSubscriptionId,
|
|
94
107
|
targetPriceId: prepared.target.priceId,
|
|
95
108
|
tenantId: ctx.user.tenantId,
|
|
96
|
-
...(consent && { consentId: consent.consentId }),
|
|
97
109
|
});
|
|
98
110
|
return { isSuccess: true as const, data: { applied: true as const } };
|
|
99
111
|
}
|
|
@@ -138,6 +138,9 @@ export const BILLING_FOUNDATION_I18N: Readonly<Record<string, LocalizedString>>
|
|
|
138
138
|
en: "This subscription is scheduled to end. Reactivate it before switching plans.",
|
|
139
139
|
},
|
|
140
140
|
"billing-foundation.errors.alreadyOnPlan": { en: "This tenant is already on that plan." },
|
|
141
|
+
"billing-foundation.errors.planSwitchPending": {
|
|
142
|
+
en: "A plan switch is already being processed. Wait a moment for it to complete.",
|
|
143
|
+
},
|
|
141
144
|
"billing-foundation.errors.planSwitchNotSupported": {
|
|
142
145
|
en: "This provider does not support switching plans.",
|
|
143
146
|
},
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// An in-app plan switch changes the tier only when the provider's webhook arrives. Until then a
|
|
2
|
+
// second submit (double click, retry after a timeout) would pass the pre-checks and switch again.
|
|
3
|
+
|
|
4
|
+
import type { HandlerContext } from "@cosmicdrift/kumiko-framework/engine";
|
|
5
|
+
import { ConflictError } from "@cosmicdrift/kumiko-framework/errors";
|
|
6
|
+
import { subscriptionAggregateId } from "./aggregate-id.ts";
|
|
7
|
+
import {
|
|
8
|
+
PLAN_SWITCH_REQUESTED_EVENT_QN,
|
|
9
|
+
type PlanSwitchRequestedPayload,
|
|
10
|
+
planSwitchRequestedPayloadSchema,
|
|
11
|
+
SUBSCRIPTION_AGGREGATE_TYPE,
|
|
12
|
+
SUBSCRIPTION_CANCELED_EVENT_QN,
|
|
13
|
+
SUBSCRIPTION_CREATED_EVENT_QN,
|
|
14
|
+
SUBSCRIPTION_UPDATED_EVENT_QN,
|
|
15
|
+
} from "./events.ts";
|
|
16
|
+
|
|
17
|
+
// A webhook that never arrives must not block switching forever.
|
|
18
|
+
const PENDING_PLAN_SWITCH_WINDOW_SECONDS = 30 * 60;
|
|
19
|
+
// 'bfps': serializes the pending check and the append per tenant.
|
|
20
|
+
const PLAN_SWITCH_LOCK_NAMESPACE = 0x62667073;
|
|
21
|
+
|
|
22
|
+
const STATE_EVENT_QNS: ReadonlySet<string> = new Set([
|
|
23
|
+
SUBSCRIPTION_CREATED_EVENT_QN,
|
|
24
|
+
SUBSCRIPTION_UPDATED_EVENT_QN,
|
|
25
|
+
SUBSCRIPTION_CANCELED_EVENT_QN,
|
|
26
|
+
]);
|
|
27
|
+
|
|
28
|
+
export function pendingPlanSwitchOf(
|
|
29
|
+
storedEvents: readonly { readonly type: string; readonly payload: unknown }[],
|
|
30
|
+
now: Temporal.Instant,
|
|
31
|
+
): PlanSwitchRequestedPayload | undefined {
|
|
32
|
+
for (let index = storedEvents.length - 1; index >= 0; index--) {
|
|
33
|
+
const stored = storedEvents[index];
|
|
34
|
+
if (stored === undefined) continue;
|
|
35
|
+
if (STATE_EVENT_QNS.has(stored.type)) return undefined;
|
|
36
|
+
if (stored.type !== PLAN_SWITCH_REQUESTED_EVENT_QN) continue;
|
|
37
|
+
const parsed = planSwitchRequestedPayloadSchema.safeParse(stored.payload);
|
|
38
|
+
if (!parsed.success) continue;
|
|
39
|
+
const ageSeconds = now
|
|
40
|
+
.since(Temporal.Instant.from(parsed.data.requestedAtIso))
|
|
41
|
+
.total("seconds");
|
|
42
|
+
return ageSeconds < PENDING_PLAN_SWITCH_WINDOW_SECONDS ? parsed.data : undefined;
|
|
43
|
+
}
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export async function assertNoPendingPlanSwitch(
|
|
48
|
+
ctx: HandlerContext,
|
|
49
|
+
now: Temporal.Instant,
|
|
50
|
+
): Promise<void> {
|
|
51
|
+
const tenantId = ctx.user.tenantId;
|
|
52
|
+
await ctx.db.advisoryXactLock(PLAN_SWITCH_LOCK_NAMESPACE, tenantId);
|
|
53
|
+
const pending = pendingPlanSwitchOf(
|
|
54
|
+
await ctx.events.load(subscriptionAggregateId(tenantId)),
|
|
55
|
+
now,
|
|
56
|
+
);
|
|
57
|
+
if (pending !== undefined) {
|
|
58
|
+
throw new ConflictError({
|
|
59
|
+
i18nKey: "billing-foundation.errors.planSwitchPending",
|
|
60
|
+
message: `a switch to plan "${pending.tier}" is still waiting for the provider's confirmation`,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export async function recordPlanSwitchRequested(
|
|
66
|
+
ctx: HandlerContext,
|
|
67
|
+
request: { readonly tier: string; readonly priceId: string; readonly now: Temporal.Instant },
|
|
68
|
+
): Promise<void> {
|
|
69
|
+
const payload: PlanSwitchRequestedPayload = {
|
|
70
|
+
tier: request.tier,
|
|
71
|
+
priceId: request.priceId,
|
|
72
|
+
requestedAtIso: request.now.toString(),
|
|
73
|
+
};
|
|
74
|
+
await ctx.events.unsafeAppend({
|
|
75
|
+
aggregateId: subscriptionAggregateId(ctx.user.tenantId),
|
|
76
|
+
aggregateType: SUBSCRIPTION_AGGREGATE_TYPE,
|
|
77
|
+
type: PLAN_SWITCH_REQUESTED_EVENT_QN,
|
|
78
|
+
payload,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { DbRunner } from "@cosmicdrift/kumiko-framework/db";
|
|
2
|
+
import type { FeatureRegistrar } from "@cosmicdrift/kumiko-framework/engine";
|
|
3
|
+
import { scrubEventHeaderKeys } from "@cosmicdrift/kumiko-framework/migrations";
|
|
4
|
+
import {
|
|
5
|
+
INVOICE_PAID_EVENT_QN,
|
|
6
|
+
INVOICE_PAYMENT_FAILED_EVENT_QN,
|
|
7
|
+
SUBSCRIPTION_CANCELED_EVENT_QN,
|
|
8
|
+
SUBSCRIPTION_CREATED_EVENT_QN,
|
|
9
|
+
SUBSCRIPTION_UPDATED_EVENT_QN,
|
|
10
|
+
} from "./events.ts";
|
|
11
|
+
|
|
12
|
+
const SCRUB_RAW_PAYLOAD_HEADERS_ESCAPE_HATCH_REASON =
|
|
13
|
+
"removes the legacy rawPayload header from billing events of every tenant";
|
|
14
|
+
|
|
15
|
+
const RAW_PAYLOAD_HEADER = "rawPayload";
|
|
16
|
+
|
|
17
|
+
const SCRUB_REASON =
|
|
18
|
+
"billing events written before the provider payload was dropped carry it as a plaintext header, which crypto-shredding cannot reach";
|
|
19
|
+
|
|
20
|
+
// Safe to repeat: only events that still carry the header are touched.
|
|
21
|
+
export async function scrubLegacyRawPayloadHeaders(db: DbRunner): Promise<number> {
|
|
22
|
+
const { removedKeys } = await scrubEventHeaderKeys(db, {
|
|
23
|
+
eventTypes: [
|
|
24
|
+
SUBSCRIPTION_CREATED_EVENT_QN,
|
|
25
|
+
SUBSCRIPTION_UPDATED_EVENT_QN,
|
|
26
|
+
SUBSCRIPTION_CANCELED_EVENT_QN,
|
|
27
|
+
INVOICE_PAID_EVENT_QN,
|
|
28
|
+
INVOICE_PAYMENT_FAILED_EVENT_QN,
|
|
29
|
+
],
|
|
30
|
+
keys: [RAW_PAYLOAD_HEADER],
|
|
31
|
+
reason: SCRUB_REASON,
|
|
32
|
+
});
|
|
33
|
+
return removedKeys;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Boot-time one-off (runOnBoot is marker-deduped per Redis dataset) and idempotent by itself.
|
|
37
|
+
export function registerScrubRawPayloadHeadersJob(r: FeatureRegistrar): void {
|
|
38
|
+
r.job({
|
|
39
|
+
name: "scrub-raw-payload-headers",
|
|
40
|
+
trigger: { manual: true },
|
|
41
|
+
runOnBoot: true,
|
|
42
|
+
escapeHatch: { reason: SCRUB_RAW_PAYLOAD_HEADERS_ESCAPE_HATCH_REASON },
|
|
43
|
+
handler: async (_payload, ctx) => {
|
|
44
|
+
const removedKeys = await scrubLegacyRawPayloadHeaders(ctx.db.unsafeRaw());
|
|
45
|
+
ctx.obs.log.info(
|
|
46
|
+
`[billing-foundation:scrub-raw-payload-headers] removed ${removedKeys} legacy rawPayload headers`,
|
|
47
|
+
);
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
}
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
// proration, multi-currency, coupons, etc. remain provider-specific and
|
|
26
26
|
// are available through the Customer Portal link.
|
|
27
27
|
|
|
28
|
+
import type { SignatureExtraRouteDeps } from "@cosmicdrift/kumiko-framework/api";
|
|
28
29
|
import type { TenantDb } from "@cosmicdrift/kumiko-framework/db";
|
|
29
30
|
import type { HandlerContext, TenantId } from "@cosmicdrift/kumiko-framework/engine";
|
|
30
31
|
import type { SecretsContext } from "@cosmicdrift/kumiko-framework/secrets";
|
|
@@ -66,9 +67,11 @@ export type SubscriptionEvent = {
|
|
|
66
67
|
/** Platform tenant ID (provider-customer metadata or lookup via
|
|
67
68
|
* providerCustomerId). The plugin performs the resolution. */
|
|
68
69
|
readonly tenantId: string;
|
|
69
|
-
/**
|
|
70
|
-
*
|
|
71
|
-
|
|
70
|
+
/** Checkout that created this subscription (Paddle transaction id, Stripe
|
|
71
|
+
* session id, Mollie first-payment id). `created` events are only accepted
|
|
72
|
+
* when the checkout is in the server's checkout ledger; later events of the
|
|
73
|
+
* same subscription do not need it. */
|
|
74
|
+
readonly providerCheckoutId?: string;
|
|
72
75
|
/** Provider-owned customer ID for later lookup when events lack
|
|
73
76
|
* metadata. */
|
|
74
77
|
readonly providerCustomerId: string;
|
|
@@ -119,12 +122,10 @@ export type PaymentEvent = {
|
|
|
119
122
|
* create time) — never from a freely-choosable payload field, or an
|
|
120
123
|
* attacker could attribute payments to someone else's tenant. */
|
|
121
124
|
readonly tenantId: string;
|
|
122
|
-
/**
|
|
123
|
-
*
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
* lets consumers key their own grants without the raw provider payload. */
|
|
127
|
-
readonly providerCheckoutId?: string;
|
|
125
|
+
/** Provider's checkout/payment object id (Stripe checkout session id,
|
|
126
|
+
* Paddle transaction id). Must name a checkout the server opened itself,
|
|
127
|
+
* otherwise the payment is ignored. */
|
|
128
|
+
readonly providerCheckoutId: string;
|
|
128
129
|
/** Provider's own customer-id. */
|
|
129
130
|
readonly providerCustomerId: string;
|
|
130
131
|
/** Provider's own price/plan-ID of the purchased item. */
|
|
@@ -208,15 +209,12 @@ export type SubscriptionProviderPlugin = {
|
|
|
208
209
|
* credit top-ups). Optional with default `"subscription"` — existing
|
|
209
210
|
* callers are unaffected. */
|
|
210
211
|
readonly mode?: "subscription" | "payment";
|
|
211
|
-
/** Id of the consumer-protection consent recorded for this checkout.
|
|
212
|
-
* Travels as provider metadata and comes back on the webhook event. */
|
|
213
|
-
readonly consentId?: string;
|
|
214
212
|
/** App locale (BCP-47-ish, e.g. "de", "de-DE") for the hosted page. */
|
|
215
213
|
readonly locale?: string;
|
|
216
214
|
/** Text shown next to the submit button on the hosted page. */
|
|
217
215
|
readonly submitMessage?: string;
|
|
218
216
|
},
|
|
219
|
-
) => Promise<{ readonly url: string }>;
|
|
217
|
+
) => Promise<{ readonly url: string; readonly providerCheckoutId: string }>;
|
|
220
218
|
|
|
221
219
|
/**
|
|
222
220
|
* **Post-tenant-resolution** — called from a write handler with a
|
|
@@ -340,7 +338,6 @@ export type SubscriptionProviderPlugin = {
|
|
|
340
338
|
readonly providerSubscriptionId: string;
|
|
341
339
|
readonly targetPriceId: string;
|
|
342
340
|
readonly tenantId: string;
|
|
343
|
-
readonly consentId?: string;
|
|
344
341
|
},
|
|
345
342
|
) => Promise<void>;
|
|
346
343
|
|
|
@@ -355,6 +352,18 @@ export type SubscriptionProviderPlugin = {
|
|
|
355
352
|
* app's config (e.g. Stripe's price-to-tier — same silent-drop the
|
|
356
353
|
* webhook path already applies to an unmapped price).
|
|
357
354
|
*/
|
|
355
|
+
/**
|
|
356
|
+
* Asked when billing-foundation ignored a verified event because its checkout is not in
|
|
357
|
+
* the ledger. Answering true makes the webhook route reply with a retryable 503 instead
|
|
358
|
+
* of 200, for providers that can still ledger the checkout shortly after (migration
|
|
359
|
+
* sweeps). Absent = never redeliver.
|
|
360
|
+
*/
|
|
361
|
+
readonly shouldRedeliverIgnoredEvent?: (args: {
|
|
362
|
+
readonly event: SubscriptionEvent | PaymentEvent;
|
|
363
|
+
readonly reason: string;
|
|
364
|
+
readonly deps: SignatureExtraRouteDeps;
|
|
365
|
+
}) => Promise<boolean>;
|
|
366
|
+
|
|
358
367
|
readonly retrieveSubscription?: (
|
|
359
368
|
ctx: HandlerContext,
|
|
360
369
|
providerSubscriptionId: string,
|
|
@@ -484,13 +493,17 @@ export type ConsumerProtectionOptions = {
|
|
|
484
493
|
/** Per-provider texts keyed by provider name, e.g. for a merchant-of-record
|
|
485
494
|
* provider that issues the invoice and VAT itself. `vatNote` here replaces
|
|
486
495
|
* the global one in that provider's confirmation mail; `checkoutNote` is
|
|
487
|
-
* shown under the provider choice. de and en are required for each text.
|
|
496
|
+
* shown under the provider choice. de and en are required for each text.
|
|
497
|
+
* `refundLink` replaces `legalLinks.refund` for that provider (one link for
|
|
498
|
+
* every locale, or one per consent locale); a provider without it falls back
|
|
499
|
+
* to `legalLinks.refund`. */
|
|
488
500
|
readonly providerTexts?: Readonly<
|
|
489
501
|
Record<
|
|
490
502
|
string,
|
|
491
503
|
{
|
|
492
504
|
readonly vatNote?: Readonly<Record<string, string>>;
|
|
493
505
|
readonly checkoutNote?: Readonly<Record<string, string>>;
|
|
506
|
+
readonly refundLink?: string | Readonly<Record<ConsentLocale, string>>;
|
|
494
507
|
}
|
|
495
508
|
>
|
|
496
509
|
>;
|
|
@@ -574,10 +587,28 @@ export type BillingPlanView = {
|
|
|
574
587
|
readonly action: BillingPlanAction;
|
|
575
588
|
};
|
|
576
589
|
|
|
590
|
+
export type BillingConsumerProtectionView = {
|
|
591
|
+
readonly consentTexts: Readonly<
|
|
592
|
+
Record<
|
|
593
|
+
"de" | "en",
|
|
594
|
+
{
|
|
595
|
+
readonly earlyPerformance: string;
|
|
596
|
+
readonly withdrawalLoss: string;
|
|
597
|
+
/** Present only when `documentsAcknowledgement` is on. */
|
|
598
|
+
readonly documentsAcknowledgement?: string;
|
|
599
|
+
readonly consentTextVersion: string;
|
|
600
|
+
}
|
|
601
|
+
>
|
|
602
|
+
>;
|
|
603
|
+
readonly legalLinks: Readonly<Record<ConsentLocale, LegalLinkSet>>;
|
|
604
|
+
};
|
|
605
|
+
|
|
577
606
|
export type BillingProviderView = {
|
|
578
607
|
readonly name: string;
|
|
579
608
|
readonly displayName: string;
|
|
580
609
|
readonly note?: Readonly<Record<string, string>>;
|
|
610
|
+
/** Only set when the provider has its own `providerTexts.refundLink`; replaces the top-level `consumerProtection` while this provider is selected. */
|
|
611
|
+
readonly consumerProtection?: BillingConsumerProtectionView;
|
|
581
612
|
readonly plans: readonly BillingPlanView[];
|
|
582
613
|
};
|
|
583
614
|
|
|
@@ -619,21 +650,7 @@ export type BillingPlansResult = {
|
|
|
619
650
|
/** Present only when `catalog.priceNoteKey` is configured. */
|
|
620
651
|
readonly priceNoteKey?: string;
|
|
621
652
|
/** Present only when `consumerProtection` is configured. */
|
|
622
|
-
readonly consumerProtection?:
|
|
623
|
-
readonly consentTexts: Readonly<
|
|
624
|
-
Record<
|
|
625
|
-
"de" | "en",
|
|
626
|
-
{
|
|
627
|
-
readonly earlyPerformance: string;
|
|
628
|
-
readonly withdrawalLoss: string;
|
|
629
|
-
/** Present only when `documentsAcknowledgement` is on. */
|
|
630
|
-
readonly documentsAcknowledgement?: string;
|
|
631
|
-
readonly consentTextVersion: string;
|
|
632
|
-
}
|
|
633
|
-
>
|
|
634
|
-
>;
|
|
635
|
-
readonly legalLinks: Readonly<Record<ConsentLocale, LegalLinkSet>>;
|
|
636
|
-
};
|
|
653
|
+
readonly consumerProtection?: BillingConsumerProtectionView;
|
|
637
654
|
};
|
|
638
655
|
|
|
639
656
|
// r.useExtension options-shape, co-located since the framework never imports upward.
|
|
@@ -30,8 +30,26 @@ function isRootRelativeOrHttpsUrl(link: string): boolean {
|
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
function validateProviderRefundLink(
|
|
34
|
+
providerName: string,
|
|
35
|
+
refundLink: string | Readonly<Record<ConsentLocale, string>>,
|
|
36
|
+
): void {
|
|
37
|
+
const links =
|
|
38
|
+
typeof refundLink === "string"
|
|
39
|
+
? [["refundLink", refundLink] as const]
|
|
40
|
+
: CONSENT_LOCALES.map((locale) => [`refundLink.${locale}`, refundLink[locale]] as const);
|
|
41
|
+
for (const [path, link] of links) {
|
|
42
|
+
if (typeof link !== "string" || !isRootRelativeOrHttpsUrl(link)) {
|
|
43
|
+
throw bootRuleError(BILLING_FOUNDATION_BOOT_RULES.consumerProtectionInvalid, {
|
|
44
|
+
message: `createBillingFoundationFeature: consumerProtection.providerTexts.${providerName}.${path} "${link}" must be a root-relative path ("/..." not "//") or an absolute https URL.`,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
33
50
|
function validateProviderTexts(cp: ConsumerProtectionOptions): void {
|
|
34
51
|
for (const [providerName, texts] of Object.entries(cp.providerTexts ?? {})) {
|
|
52
|
+
if (texts.refundLink !== undefined) validateProviderRefundLink(providerName, texts.refundLink);
|
|
35
53
|
for (const [textName, text] of [
|
|
36
54
|
["vatNote", texts.vatNote],
|
|
37
55
|
["checkoutNote", texts.checkoutNote],
|
|
@@ -52,7 +52,7 @@ function manageOrReactivateAction(
|
|
|
52
52
|
canManage: boolean,
|
|
53
53
|
subscription: BillingPlansResult["subscription"],
|
|
54
54
|
t: UseTranslation,
|
|
55
|
-
onManage: () => void
|
|
55
|
+
onManage: () => Promise<void>,
|
|
56
56
|
redirecting: boolean,
|
|
57
57
|
): PlanCardActionSlot | undefined {
|
|
58
58
|
if (!canManage) return undefined;
|
|
@@ -62,7 +62,9 @@ function manageOrReactivateAction(
|
|
|
62
62
|
? "billing-foundation.plans.reactivate"
|
|
63
63
|
: "billing-foundation.plans.manage",
|
|
64
64
|
),
|
|
65
|
-
onClick:
|
|
65
|
+
onClick: () => {
|
|
66
|
+
void onManage();
|
|
67
|
+
},
|
|
66
68
|
disabled: redirecting,
|
|
67
69
|
};
|
|
68
70
|
}
|
|
@@ -76,7 +78,7 @@ function planCta(
|
|
|
76
78
|
plan: BillingPlanView,
|
|
77
79
|
result: BillingPlansResult,
|
|
78
80
|
t: UseTranslation,
|
|
79
|
-
onAction: (tier: string, kind: "checkout" | "switch") => void
|
|
81
|
+
onAction: (tier: string, kind: "checkout" | "switch") => Promise<void>,
|
|
80
82
|
redirecting: boolean,
|
|
81
83
|
): PlanCardActionSlot | undefined {
|
|
82
84
|
if (plan.action === BillingPlanActions.current) return undefined;
|
|
@@ -96,7 +98,9 @@ function planCta(
|
|
|
96
98
|
}
|
|
97
99
|
return {
|
|
98
100
|
label,
|
|
99
|
-
onClick: () =>
|
|
101
|
+
onClick: () => {
|
|
102
|
+
void onAction(plan.tier, kind);
|
|
103
|
+
},
|
|
100
104
|
disabled: redirecting,
|
|
101
105
|
};
|
|
102
106
|
}
|
|
@@ -264,6 +268,7 @@ export function BillingPlansPanel(_props: ExtensionSectionProps): ReactNode {
|
|
|
264
268
|
const switchPlan =
|
|
265
269
|
switchTier !== null ? shownPlans.find((plan) => plan.tier === switchTier) : undefined;
|
|
266
270
|
const consumerProtection = result.consumerProtection;
|
|
271
|
+
const checkoutConsumerProtection = activeProvider?.consumerProtection ?? consumerProtection;
|
|
267
272
|
const noteLocale = resolveConsentLocale(locale);
|
|
268
273
|
const noteOf = (provider: { readonly note?: Readonly<Record<string, string>> }) =>
|
|
269
274
|
provider.note?.[noteLocale] ?? provider.note?.["en"];
|
|
@@ -385,7 +390,7 @@ export function BillingPlansPanel(_props: ExtensionSectionProps): ReactNode {
|
|
|
385
390
|
renewalKey: renewalKey(consentPlan.price),
|
|
386
391
|
count: new Intl.NumberFormat(locale).format(consentPlan.price.intervalCount ?? 1),
|
|
387
392
|
}}
|
|
388
|
-
consumerProtection={
|
|
393
|
+
consumerProtection={checkoutConsumerProtection}
|
|
389
394
|
providerChoice={providerChoiceFor(consentPlan.tier)}
|
|
390
395
|
note={singleProviderNote}
|
|
391
396
|
onOrder={(consent) => orderWithConsent(consentPlan.tier, consent)}
|
|
@@ -30,7 +30,7 @@ const DECLARATION_TYPES: readonly ContractTerminationDeclarationType[] = [
|
|
|
30
30
|
];
|
|
31
31
|
const TERMINATION_KINDS: readonly ContractTerminationKind[] = ["ordinary", "extraordinary"];
|
|
32
32
|
|
|
33
|
-
//
|
|
33
|
+
// biome-ignore lint/plugin: Uses usePrimitives().Modal internally, name is a billing domain action, not a primitive reimplementation
|
|
34
34
|
export function CancelContractDialog({
|
|
35
35
|
open,
|
|
36
36
|
onOpenChange,
|
|
@@ -48,7 +48,7 @@ export type CheckoutConsentDialogProps = {
|
|
|
48
48
|
readonly onConsentTextOutdated: () => void;
|
|
49
49
|
};
|
|
50
50
|
|
|
51
|
-
//
|
|
51
|
+
// biome-ignore lint/plugin: Uses usePrimitives().Modal internally, name is a billing domain action, not a primitive reimplementation
|
|
52
52
|
export function CheckoutConsentDialog({
|
|
53
53
|
open,
|
|
54
54
|
onOpenChange,
|
|
@@ -68,6 +68,9 @@ export const SubscriptionFoundationHandlers = {
|
|
|
68
68
|
/** Tenant-Admin terminates or withdraws from the contract of their own
|
|
69
69
|
* tenant (consumerProtection only). */
|
|
70
70
|
terminateContract: "billing-foundation:write:terminate-contract",
|
|
71
|
+
/** System-only: puts a checkout the server opened earlier into the checkout
|
|
72
|
+
* ledger (idempotent). Used by provider migration jobs. */
|
|
73
|
+
recordCheckoutOpened: "billing-foundation:write:record-checkout-opened",
|
|
71
74
|
/** Tenant-Admin/purchase-role picks a plan tier from the catalog with no
|
|
72
75
|
* existing non-terminal subscription — starts a hosted checkout for the
|
|
73
76
|
* matching price. Only registered when `createBillingFoundationFeature`
|
|
@@ -148,8 +151,8 @@ export const SubscriptionCancelTimings = {
|
|
|
148
151
|
export type SubscriptionCancelTiming =
|
|
149
152
|
(typeof SubscriptionCancelTimings)[keyof typeof SubscriptionCancelTimings];
|
|
150
153
|
|
|
151
|
-
//
|
|
152
|
-
// untrusted
|
|
154
|
+
// Only the legacy-checkout migration reads a consentId back from provider
|
|
155
|
+
// metadata; that value is untrusted: bounded length, id-ish charset only.
|
|
153
156
|
const CONSENT_ID_PATTERN = /^[A-Za-z0-9_-]{1,100}$/;
|
|
154
157
|
|
|
155
158
|
export function parseProviderConsentId(raw: unknown): string | undefined {
|
|
@@ -38,7 +38,7 @@ export type PlanSwitchConfirmDialogProps = {
|
|
|
38
38
|
readonly onConsentTextOutdated: () => void;
|
|
39
39
|
};
|
|
40
40
|
|
|
41
|
-
//
|
|
41
|
+
// biome-ignore lint/plugin: Uses usePrimitives().Modal internally, name is a billing domain action, not a primitive reimplementation
|
|
42
42
|
export function PlanSwitchConfirmDialog({
|
|
43
43
|
open,
|
|
44
44
|
onOpenChange,
|