@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
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
import { createFallbackLogger } from "@cosmicdrift/kumiko-framework/logging";
|
|
10
10
|
import type { MultiStreamApplyContext } from "@cosmicdrift/kumiko-framework/pipeline";
|
|
11
11
|
import { SYSTEM_USER_ID, type TenantId } from "@cosmicdrift/kumiko-types/identifiers";
|
|
12
|
+
import { propertyOf } from "@cosmicdrift/kumiko-types/type-guards";
|
|
12
13
|
import { redactEmailAddresses } from "../shared/index.ts";
|
|
13
14
|
import {
|
|
14
15
|
buildDispatchSpec,
|
|
@@ -35,6 +36,7 @@ const DELIVERY_RETRY_ERROR = "step delivery failed, retrying";
|
|
|
35
36
|
const DISPATCH_THREW_ERROR = "delivery attempt threw unexpectedly";
|
|
36
37
|
const FINAL_ATTEMPT_ABORTED_ERROR = "delivery aborted on the final attempt";
|
|
37
38
|
const FINAL_ATTEMPT_UNRECORDED_ERROR = "step delivery failed and its outcome could not be recorded";
|
|
39
|
+
const DISPATCH_ABANDONED_ERROR = "dispatch abandoned without a recorded outcome";
|
|
38
40
|
|
|
39
41
|
export function isDispatchOutcome(e: { readonly type: string }): boolean {
|
|
40
42
|
return e.type === STEP_DISPATCHED_TYPE || e.type === STEP_DISPATCH_FAILED_TYPE;
|
|
@@ -67,6 +69,20 @@ function mailResultAsDelivery(result: MailDispatchResult): DeliveryResult {
|
|
|
67
69
|
return { ok: false, error: result.error, retryable: !isPermanent };
|
|
68
70
|
}
|
|
69
71
|
|
|
72
|
+
// Socket errors raised before any byte reached the provider: nothing can have been accepted.
|
|
73
|
+
const PRE_ACCEPT_NETWORK_ERROR_CODES: ReadonlySet<string> = new Set([
|
|
74
|
+
"ECONNREFUSED",
|
|
75
|
+
"ENOTFOUND",
|
|
76
|
+
"EAI_AGAIN",
|
|
77
|
+
"EHOSTUNREACH",
|
|
78
|
+
"ENETUNREACH",
|
|
79
|
+
]);
|
|
80
|
+
|
|
81
|
+
function isThrownBeforeProviderAccepted(err: unknown): boolean {
|
|
82
|
+
const code = propertyOf(err, "code");
|
|
83
|
+
return typeof code === "string" && PRE_ACCEPT_NETWORK_ERROR_CODES.has(code);
|
|
84
|
+
}
|
|
85
|
+
|
|
70
86
|
export type DeliverDispatchRequestArgs = {
|
|
71
87
|
readonly aggregateId: string;
|
|
72
88
|
readonly tenantId: TenantId;
|
|
@@ -142,6 +158,26 @@ function createOutcomeRecorder(
|
|
|
142
158
|
};
|
|
143
159
|
}
|
|
144
160
|
|
|
161
|
+
// For a deliver job that ended terminally without an outcome (BullMQ stall, lost job): the
|
|
162
|
+
// request is closed as failed and its key erased. A stream that already has an outcome only
|
|
163
|
+
// repeats the erase.
|
|
164
|
+
export async function closeAbandonedDispatch(
|
|
165
|
+
ctx: MultiStreamApplyContext,
|
|
166
|
+
aggregateId: string,
|
|
167
|
+
): Promise<"closed" | "already-closed"> {
|
|
168
|
+
const stream = await ctx.loadAggregate(aggregateId);
|
|
169
|
+
if (stream.some(isDispatchOutcome)) {
|
|
170
|
+
await eraseDispatchKey(aggregateId);
|
|
171
|
+
return "already-closed";
|
|
172
|
+
}
|
|
173
|
+
const requested = stream.find((e) => e.type === STEP_DISPATCH_REQUESTED_TYPE);
|
|
174
|
+
await createOutcomeRecorder(ctx, aggregateId, 0).recordFailure(
|
|
175
|
+
rawStepKindOf(requested?.payload),
|
|
176
|
+
DISPATCH_ABANDONED_ERROR,
|
|
177
|
+
);
|
|
178
|
+
return "closed";
|
|
179
|
+
}
|
|
180
|
+
|
|
145
181
|
type RequestedEvent = Awaited<ReturnType<MultiStreamApplyContext["loadAggregate"]>>[number];
|
|
146
182
|
|
|
147
183
|
async function deliverRequested(
|
|
@@ -214,11 +250,12 @@ async function sendDispatch(
|
|
|
214
250
|
errorName: err instanceof Error ? err.name : "unknown",
|
|
215
251
|
});
|
|
216
252
|
// A mail adapter has no idempotency key: a throw after the provider accepted the message
|
|
217
|
-
// would send it again, so only the webhook (which carries one)
|
|
253
|
+
// would send it again, so only the webhook (which carries one) and mail that failed before
|
|
254
|
+
// the connection was established are retried.
|
|
218
255
|
return {
|
|
219
256
|
ok: false,
|
|
220
257
|
error: DISPATCH_THREW_ERROR,
|
|
221
|
-
retryable: dispatchSpec.stepKind === "webhook.send",
|
|
258
|
+
retryable: dispatchSpec.stepKind === "webhook.send" || isThrownBeforeProviderAccepted(err),
|
|
222
259
|
};
|
|
223
260
|
}
|
|
224
261
|
}
|
|
@@ -245,6 +282,14 @@ async function abortOnFinalAttempt(
|
|
|
245
282
|
await recorder.recordFailure(rawStepKindOf(requestedPayload), FINAL_ATTEMPT_ABORTED_ERROR);
|
|
246
283
|
}
|
|
247
284
|
} catch {
|
|
285
|
+
// No outcome and no further retry: the request payload must not stay decryptable. A later
|
|
286
|
+
// redelivery then ends as "payload erased" instead of sending again.
|
|
287
|
+
await eraseDispatchKey(aggregateId).catch((eraseErr: unknown) => {
|
|
288
|
+
log.warn("dispatch key erase failed after an unrecorded final attempt", {
|
|
289
|
+
aggregateId,
|
|
290
|
+
errorName: eraseErr instanceof Error ? eraseErr.name : "unknown",
|
|
291
|
+
});
|
|
292
|
+
});
|
|
248
293
|
throw new Error(FINAL_ATTEMPT_UNRECORDED_ERROR);
|
|
249
294
|
}
|
|
250
295
|
}
|
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
import { createMultiStreamApplyContext } from "@cosmicdrift/kumiko-framework/pipeline";
|
|
20
20
|
import * as z from "zod";
|
|
21
21
|
import {
|
|
22
|
+
ABANDON_DISPATCH_AFTER_HOURS,
|
|
22
23
|
DELIVER_MAX_PER_TENANT,
|
|
23
24
|
DELIVER_RETRIES,
|
|
24
25
|
deliverJobId,
|
|
@@ -30,6 +31,7 @@ import {
|
|
|
30
31
|
eraseDispatchKey,
|
|
31
32
|
isDispatchOutcome,
|
|
32
33
|
} from "./deliver-dispatch-request.ts";
|
|
34
|
+
import { sweepAbandonedDispatches } from "./sweep-abandoned.ts";
|
|
33
35
|
import {
|
|
34
36
|
WEBHOOK_ALLOWED_PRIVATE_HOSTS_ENV_VAR,
|
|
35
37
|
WEBHOOK_AUTH_SECRET_NAMESPACE_OPTIONS,
|
|
@@ -50,12 +52,15 @@ const NEEDS_JOB_RUNNER_ERROR = "step-dispatcher needs a job runner (Redis) to de
|
|
|
50
52
|
const DELIVER_ESCAPE_HATCH_REASON =
|
|
51
53
|
"reads the dispatch stream and appends its outcome event, which needs a raw connection";
|
|
52
54
|
|
|
55
|
+
const SWEEP_ESCAPE_HATCH_REASON =
|
|
56
|
+
"finds dispatch streams without an outcome across every tenant and appends their failure event";
|
|
57
|
+
|
|
53
58
|
const deliverJobPayloadSchema = z.object({ aggregateId: z.string() });
|
|
54
59
|
|
|
55
60
|
export function createStepDispatcherFeature(): FeatureDefinition {
|
|
56
61
|
return defineFeature("step-dispatcher", (r) => {
|
|
57
62
|
r.describe(
|
|
58
|
-
"Internal system feature that drains deferred Tier-2 side-effects (currently `webhook.send` and `mail.send`) after their originating transaction commits. An `r.multiStreamProjection` on the `kumiko:system:step.dispatch-requested` system event enqueues one `step-dispatcher:job:deliver` BullMQ job per dispatch (Redis carries only the stream id and tenant, never the request payload). The job performs the actual HTTP or mail delivery and appends `kumiko:system:step.dispatched` or `kumiko:system:step.dispatch-failed` back onto the same stream, so the outcome is recorded in the event log without a separate status table. Transient failures (network error, timeout, 5xx, 408, 429, any mail adapter failure) are retried 3 times with exponential backoff; the outcome is recorded after the final attempt and the payload key is erased only then. Permanent failures (invalid url, blocked host, other 4xx, unavailable auth secret) are recorded immediately. At most 2 deliveries per tenant run at once (`maxPerTenant` with `onLimit: \"defer\"`), so a slow receiver of one tenant does not delay other tenants. Requires a job runner (Redis) and a worker consuming the job's default `worker` lane; without a job runner the projection fails loudly. Mount this feature explicitly via `createStepDispatcherFeature()` in your app's feature list alongside any features that use `r.step.webhook.send` or `r.step.mail.send`. Requires the `secrets` feature (`createSecretsFeature()`) to be mounted — `webhook.send` auth resolves per-tenant through it, under `step-dispatcher:webhook-auth.<name>`. Every `webhook.send` request carries `Idempotency-Key: <dispatch stream id>`, stable across retries and redeliveries of the same dispatch request; an explicit `Idempotency-Key` in `headers` takes precedence.",
|
|
63
|
+
"Internal system feature that drains deferred Tier-2 side-effects (currently `webhook.send` and `mail.send`) after their originating transaction commits. An `r.multiStreamProjection` on the `kumiko:system:step.dispatch-requested` system event enqueues one `step-dispatcher:job:deliver` BullMQ job per dispatch (Redis carries only the stream id and tenant, never the request payload). The job performs the actual HTTP or mail delivery and appends `kumiko:system:step.dispatched` or `kumiko:system:step.dispatch-failed` back onto the same stream, so the outcome is recorded in the event log without a separate status table. Transient failures (network error, timeout, 5xx, 408, 429, any mail adapter failure) are retried 3 times with exponential backoff; the outcome is recorded after the final attempt and the payload key is erased only then. A request that still has no outcome after 24 hours (job stalled or lost, or its final attempt could not record one) is closed by the daily `step-dispatcher:job:sweep-abandoned` cron (it pages through all such requests; requests that already have an outcome are not swept) with a generic `dispatch-failed` event and its payload key is erased. Permanent failures (invalid url, blocked host, other 4xx, unavailable auth secret) are recorded immediately. At most 2 deliveries per tenant run at once (`maxPerTenant` with `onLimit: \"defer\"`), so a slow receiver of one tenant does not delay other tenants. Requires a job runner (Redis) and a worker consuming the job's default `worker` lane; without a job runner the projection fails loudly. Mount this feature explicitly via `createStepDispatcherFeature()` in your app's feature list alongside any features that use `r.step.webhook.send` or `r.step.mail.send`. Requires the `secrets` feature (`createSecretsFeature()`) to be mounted — `webhook.send` auth resolves per-tenant through it, under `step-dispatcher:webhook-auth.<name>`. Every `webhook.send` request carries `Idempotency-Key: <dispatch stream id>`, stable across retries and redeliveries of the same dispatch request; an explicit `Idempotency-Key` in `headers` takes precedence.",
|
|
59
64
|
);
|
|
60
65
|
r.secretNamespace("webhook-auth", WEBHOOK_AUTH_SECRET_NAMESPACE_OPTIONS);
|
|
61
66
|
r.uiHints({
|
|
@@ -100,6 +105,28 @@ export function createStepDispatcherFeature(): FeatureDefinition {
|
|
|
100
105
|
},
|
|
101
106
|
);
|
|
102
107
|
|
|
108
|
+
// Literal name, mirrored by StepDispatcherJobNames.sweepAbandoned (pinned in feature.boot.test.ts).
|
|
109
|
+
r.job(
|
|
110
|
+
"sweep-abandoned",
|
|
111
|
+
{
|
|
112
|
+
trigger: { cron: "17 3 * * *", wakesSleepingApp: false },
|
|
113
|
+
concurrency: "skip",
|
|
114
|
+
escapeHatch: { reason: SWEEP_ESCAPE_HATCH_REASON },
|
|
115
|
+
},
|
|
116
|
+
async (_payload, ctx) => {
|
|
117
|
+
await sweepAbandonedDispatches({
|
|
118
|
+
db: ctx.db.unsafeRaw(),
|
|
119
|
+
registry: ctx.registry,
|
|
120
|
+
startedBeforeIso: ctx.tz
|
|
121
|
+
.now()
|
|
122
|
+
.subtract({ hours: ABANDON_DISPATCH_AFTER_HOURS })
|
|
123
|
+
.toString(),
|
|
124
|
+
onCloseFailure: (aggregateId, errorName) =>
|
|
125
|
+
ctx.obs.log.warn("abandoned dispatch could not be closed", { aggregateId, errorName }),
|
|
126
|
+
});
|
|
127
|
+
},
|
|
128
|
+
);
|
|
129
|
+
|
|
103
130
|
r.multiStreamProjection({
|
|
104
131
|
name: "step-dispatcher",
|
|
105
132
|
apply: {
|
|
@@ -28,7 +28,6 @@ export function setMailRunner(fn: (spec: MailSpec) => Promise<MailDispatchResult
|
|
|
28
28
|
mailRunner = fn;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
// @wrapper-known entry-point
|
|
32
31
|
export async function performMailDispatch(spec: MailSpec): Promise<MailDispatchResult> {
|
|
33
32
|
return mailRunner(spec);
|
|
34
33
|
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { DbRunner } from "@cosmicdrift/kumiko-framework/db";
|
|
2
|
+
import {
|
|
3
|
+
type Registry,
|
|
4
|
+
STEP_DISPATCH_AGGREGATE_TYPE,
|
|
5
|
+
STEP_DISPATCH_FAILED_TYPE,
|
|
6
|
+
STEP_DISPATCH_REQUESTED_TYPE,
|
|
7
|
+
STEP_DISPATCHED_TYPE,
|
|
8
|
+
} from "@cosmicdrift/kumiko-framework/engine";
|
|
9
|
+
import { selectOpenStreamsStartedBefore } from "@cosmicdrift/kumiko-framework/event-store";
|
|
10
|
+
import { createMultiStreamApplyContext } from "@cosmicdrift/kumiko-framework/pipeline";
|
|
11
|
+
import { SYSTEM_USER_ID } from "@cosmicdrift/kumiko-types/identifiers";
|
|
12
|
+
import { STEP_DISPATCHER_FEATURE, SWEEP_ABANDONED_BATCH_SIZE } from "./constants.ts";
|
|
13
|
+
import { closeAbandonedDispatch } from "./deliver-dispatch-request.ts";
|
|
14
|
+
|
|
15
|
+
export type SweepAbandonedArgs = {
|
|
16
|
+
readonly db: DbRunner;
|
|
17
|
+
readonly registry: Registry;
|
|
18
|
+
readonly startedBeforeIso: string;
|
|
19
|
+
readonly onCloseFailure: (aggregateId: string, errorName: string) => void;
|
|
20
|
+
readonly batchSize?: number;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
// Pages by id until a short page: a stream that fails permanently stays open and would otherwise
|
|
24
|
+
// occupy the front of every run, starving the streams behind it.
|
|
25
|
+
export async function sweepAbandonedDispatches(args: SweepAbandonedArgs): Promise<void> {
|
|
26
|
+
const batchSize = args.batchSize ?? SWEEP_ABANDONED_BATCH_SIZE;
|
|
27
|
+
let afterId: string | undefined;
|
|
28
|
+
for (;;) {
|
|
29
|
+
const page = await selectOpenStreamsStartedBefore(args.db, {
|
|
30
|
+
aggregateType: STEP_DISPATCH_AGGREGATE_TYPE,
|
|
31
|
+
startedType: STEP_DISPATCH_REQUESTED_TYPE,
|
|
32
|
+
closingTypes: [STEP_DISPATCHED_TYPE, STEP_DISPATCH_FAILED_TYPE],
|
|
33
|
+
startedBeforeIso: args.startedBeforeIso,
|
|
34
|
+
limit: batchSize,
|
|
35
|
+
...(afterId !== undefined && { afterId }),
|
|
36
|
+
});
|
|
37
|
+
for (const { tenantId, aggregateId } of page) {
|
|
38
|
+
const applyContext = createMultiStreamApplyContext({
|
|
39
|
+
registry: args.registry,
|
|
40
|
+
db: args.db,
|
|
41
|
+
tenantId,
|
|
42
|
+
userId: SYSTEM_USER_ID,
|
|
43
|
+
callerFeature: STEP_DISPATCHER_FEATURE,
|
|
44
|
+
});
|
|
45
|
+
try {
|
|
46
|
+
await closeAbandonedDispatch(applyContext, aggregateId);
|
|
47
|
+
} catch (err) {
|
|
48
|
+
// One broken stream must not keep the others open; the next run retries it.
|
|
49
|
+
args.onCloseFailure(aggregateId, err instanceof Error ? err.name : "unknown");
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
const last = page.at(-1);
|
|
53
|
+
// skip: a short page is the last one
|
|
54
|
+
if (page.length < batchSize || last === undefined) return;
|
|
55
|
+
afterId = last.id;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"version": "0.414.0",
|
|
4
|
+
"type": "breaking",
|
|
5
|
+
"title": "Mollie first payments are matched by payment id, consentId metadata is gone",
|
|
6
|
+
"detail": "`createCheckoutSession` returns the first payment's id as `providerCheckoutId`; the created event of the subscription made from that mandate payment carries it. Payment and subscription metadata no longer hold a consentId.",
|
|
7
|
+
"migration": "First payments created before the upgrade are not in the ledger and their webhook is ignored; let open mandate checkouts finish first."
|
|
8
|
+
},
|
|
2
9
|
{
|
|
3
10
|
"version": "0.338.0",
|
|
4
11
|
"type": "improvement",
|
|
@@ -40,7 +40,10 @@ export function createMollieCheckoutSession(
|
|
|
40
40
|
priceToConfig: Readonly<Record<string, MolliePriceConfig>>,
|
|
41
41
|
appWebhookUrl: string,
|
|
42
42
|
) {
|
|
43
|
-
return async (
|
|
43
|
+
return async (
|
|
44
|
+
_ctx: HandlerContext,
|
|
45
|
+
options: MollieCheckoutOptions,
|
|
46
|
+
): Promise<{ url: string; providerCheckoutId: string }> => {
|
|
44
47
|
const priceCfg = priceToConfig[options.priceId];
|
|
45
48
|
if (!priceCfg) {
|
|
46
49
|
throw new Error(`subscription-mollie: priceId "${options.priceId}" not in priceToConfig-Map`);
|
|
@@ -81,7 +84,6 @@ export function createMollieCheckoutSession(
|
|
|
81
84
|
metadata: {
|
|
82
85
|
tenantId: options.tenantId,
|
|
83
86
|
priceId: options.priceId,
|
|
84
|
-
...(options.consentId && { consentId: options.consentId }),
|
|
85
87
|
},
|
|
86
88
|
}) as Promise<Payment>)) satisfies Payment; // @cast-boundary engine-bridge
|
|
87
89
|
|
|
@@ -93,6 +95,6 @@ export function createMollieCheckoutSession(
|
|
|
93
95
|
`subscription-mollie: payment.getCheckoutUrl() returned null (sequenceType=${sequenceType})${mandateHint}`,
|
|
94
96
|
);
|
|
95
97
|
}
|
|
96
|
-
return { url: checkoutHref };
|
|
98
|
+
return { url: checkoutHref, providerCheckoutId: payment.id };
|
|
97
99
|
};
|
|
98
100
|
}
|
|
@@ -15,7 +15,6 @@
|
|
|
15
15
|
// with a subscription id.
|
|
16
16
|
|
|
17
17
|
import {
|
|
18
|
-
parseProviderConsentId,
|
|
19
18
|
type SubscriptionEvent,
|
|
20
19
|
type SubscriptionEventType,
|
|
21
20
|
SubscriptionEventTypes,
|
|
@@ -129,13 +128,15 @@ export function verifyAndParseMollieWebhook(
|
|
|
129
128
|
}
|
|
130
129
|
const currentPeriodEnd = mollieDateStringToInstantIso(periodEndSource);
|
|
131
130
|
|
|
132
|
-
|
|
131
|
+
// The first payment is the checkout the foundation ledgered at createCheckoutSession.
|
|
132
|
+
const providerCheckoutId =
|
|
133
|
+
triggerPayment?.sequenceType === "first" ? triggerPayment.id : undefined;
|
|
133
134
|
return {
|
|
134
135
|
providerEventId: id,
|
|
135
136
|
providerName: MOLLIE_PROVIDER_NAME,
|
|
136
137
|
type,
|
|
137
138
|
tenantId,
|
|
138
|
-
...(
|
|
139
|
+
...(providerCheckoutId !== undefined && { providerCheckoutId }),
|
|
139
140
|
providerCustomerId: subscription.customerId,
|
|
140
141
|
providerSubscriptionId: subscription.id,
|
|
141
142
|
status,
|
|
@@ -162,7 +163,6 @@ async function ensureSubscriptionForMandate(
|
|
|
162
163
|
const paymentMetadata = (payment.metadata as Record<string, string> | null) ?? {}; // @cast-boundary engine-bridge
|
|
163
164
|
const tenantId = paymentMetadata["tenantId"];
|
|
164
165
|
const priceId = paymentMetadata["priceId"];
|
|
165
|
-
const consentId = parseProviderConsentId(paymentMetadata["consentId"]);
|
|
166
166
|
if (!tenantId || !priceId) return null;
|
|
167
167
|
const priceCfg = options.priceToConfig[priceId];
|
|
168
168
|
if (!priceCfg) return null;
|
|
@@ -183,7 +183,7 @@ async function ensureSubscriptionForMandate(
|
|
|
183
183
|
amount: { currency: priceCfg.amountCurrency, value: priceCfg.amountValue },
|
|
184
184
|
interval: priceCfg.interval,
|
|
185
185
|
description: priceCfg.description,
|
|
186
|
-
metadata: { tenantId, priceId
|
|
186
|
+
metadata: { tenantId, priceId },
|
|
187
187
|
});
|
|
188
188
|
}
|
|
189
189
|
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
// Takes over Paddle checkouts that were opened before the checkout ledger
|
|
2
|
+
// existed: their custom_data still carries the old tenantBinding. Once the
|
|
3
|
+
// first sweep is done the job keeps sweeping for an hour (checkouts opened by
|
|
4
|
+
// the previous release can still be paid), then does nothing.
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
parseProviderConsentId,
|
|
8
|
+
SubscriptionFoundationHandlers,
|
|
9
|
+
} from "@cosmicdrift/kumiko-bundled-features/billing-foundation";
|
|
10
|
+
import {
|
|
11
|
+
createSystemUser,
|
|
12
|
+
type JobContext,
|
|
13
|
+
parseTenantId,
|
|
14
|
+
} from "@cosmicdrift/kumiko-framework/engine";
|
|
15
|
+
import { Temporal } from "@cosmicdrift/kumiko-types/temporal";
|
|
16
|
+
import * as z from "zod";
|
|
17
|
+
import { PADDLE_PROVIDER_NAME } from "./constants.ts";
|
|
18
|
+
import {
|
|
19
|
+
LEDGER_BACKFILL_MARKER_HANDLER_QN,
|
|
20
|
+
type LedgerBackfillMarkerResult,
|
|
21
|
+
} from "./ledger-backfill-marker.ts";
|
|
22
|
+
import type { PaddleCallSource, PaddleCtxRuntime } from "./runtime.ts";
|
|
23
|
+
import { tenantIdOf } from "./webhook-events.ts";
|
|
24
|
+
|
|
25
|
+
const TAKEOVER_WINDOW_MS = 60 * 60 * 1000;
|
|
26
|
+
const PAGE_SIZE = "200";
|
|
27
|
+
const MAX_PAGES = 100;
|
|
28
|
+
// A checkout that completed between the deploy and the first sweep is no longer draft/ready,
|
|
29
|
+
// but its webhook is still pending, so completed ones are listed too, for a week back.
|
|
30
|
+
const LISTED_STATUSES = "draft,ready,billed,paid,completed";
|
|
31
|
+
const LOOKBACK_DAYS = 7;
|
|
32
|
+
|
|
33
|
+
const transactionListSchema = z.object({
|
|
34
|
+
data: z.array(
|
|
35
|
+
z.object({
|
|
36
|
+
id: z.string().min(1),
|
|
37
|
+
custom_data: z.record(z.string(), z.unknown()).nullish(),
|
|
38
|
+
items: z.array(z.object({ price: z.object({ id: z.string().min(1) }) })),
|
|
39
|
+
}),
|
|
40
|
+
),
|
|
41
|
+
meta: z
|
|
42
|
+
.object({ pagination: z.object({ has_more: z.boolean().optional() }).optional() })
|
|
43
|
+
.optional(),
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
type ListedTransaction = z.infer<typeof transactionListSchema>["data"][number];
|
|
47
|
+
|
|
48
|
+
export type BackfillDeps = {
|
|
49
|
+
readonly runtime: PaddleCtxRuntime;
|
|
50
|
+
readonly priceToTier: Readonly<Record<string, string>>;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
function isLegacyCheckout(transaction: ListedTransaction): boolean {
|
|
54
|
+
return typeof transaction.custom_data?.["tenantBinding"] === "string";
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function paddleCallSourceOf(ctx: JobContext): PaddleCallSource {
|
|
58
|
+
return {
|
|
59
|
+
services: ctx.services,
|
|
60
|
+
user: ctx.systemUser,
|
|
61
|
+
...(ctx.config && { config: ctx.config }),
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
async function readMarker(
|
|
66
|
+
ctx: JobContext,
|
|
67
|
+
markCompleted: boolean,
|
|
68
|
+
): Promise<LedgerBackfillMarkerResult> {
|
|
69
|
+
const result = await ctx.dispatch.write(LEDGER_BACKFILL_MARKER_HANDLER_QN, { markCompleted });
|
|
70
|
+
if (!result.isSuccess) {
|
|
71
|
+
throw new Error(`backfill-checkout-ledger: marker handler failed (${result.error.code})`);
|
|
72
|
+
}
|
|
73
|
+
return result.data as LedgerBackfillMarkerResult; // @cast-boundary engine-payload
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export function isTakeoverWindowOver(completedAt: string, now: Temporal.Instant): boolean {
|
|
77
|
+
const elapsed = now.epochMilliseconds - Temporal.Instant.from(completedAt).epochMilliseconds;
|
|
78
|
+
return elapsed >= TAKEOVER_WINDOW_MS;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
async function listOpenApiTransactions(
|
|
82
|
+
ctx: JobContext,
|
|
83
|
+
runtime: PaddleCtxRuntime,
|
|
84
|
+
after: string | undefined,
|
|
85
|
+
createdSince: string,
|
|
86
|
+
) {
|
|
87
|
+
const raw = await runtime.call(paddleCallSourceOf(ctx), {
|
|
88
|
+
method: "GET",
|
|
89
|
+
path: "/transactions",
|
|
90
|
+
query: {
|
|
91
|
+
status: LISTED_STATUSES,
|
|
92
|
+
origin: "api",
|
|
93
|
+
"created_at[GTE]": createdSince,
|
|
94
|
+
order_by: "id[ASC]",
|
|
95
|
+
per_page: PAGE_SIZE,
|
|
96
|
+
...(after !== undefined && { after }),
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
return transactionListSchema.parse(raw);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
async function ledgerTransaction(
|
|
103
|
+
ctx: JobContext,
|
|
104
|
+
priceToTier: BackfillDeps["priceToTier"],
|
|
105
|
+
transaction: ListedTransaction,
|
|
106
|
+
): Promise<void> {
|
|
107
|
+
const tenantId = parseTenantId(tenantIdOf(transaction.custom_data));
|
|
108
|
+
const priceId = transaction.items[0]?.price.id;
|
|
109
|
+
// skip: a transaction without tenant or price cannot be ledgered
|
|
110
|
+
if (tenantId === null || !priceId) return;
|
|
111
|
+
const consentId = parseProviderConsentId(transaction.custom_data?.["consentId"]);
|
|
112
|
+
const result = await ctx.dispatch.writeAs(
|
|
113
|
+
createSystemUser(tenantId, ["SystemAdmin"]),
|
|
114
|
+
SubscriptionFoundationHandlers.recordCheckoutOpened,
|
|
115
|
+
{
|
|
116
|
+
providerName: PADDLE_PROVIDER_NAME,
|
|
117
|
+
providerCheckoutId: transaction.id,
|
|
118
|
+
priceId,
|
|
119
|
+
mode: priceId in priceToTier ? "subscription" : "payment",
|
|
120
|
+
...(consentId !== undefined && { consentId }),
|
|
121
|
+
},
|
|
122
|
+
);
|
|
123
|
+
if (!result.isSuccess) {
|
|
124
|
+
throw new Error(
|
|
125
|
+
`backfill-checkout-ledger: ledgering ${transaction.id} failed (${result.error.code})`,
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export async function runBackfillCheckoutLedger(
|
|
131
|
+
ctx: JobContext,
|
|
132
|
+
deps: BackfillDeps,
|
|
133
|
+
): Promise<void> {
|
|
134
|
+
// skip: without an API key there is no Paddle account to sweep
|
|
135
|
+
if (!(await deps.runtime.hasApiKey(paddleCallSourceOf(ctx)))) return;
|
|
136
|
+
const marker = await readMarker(ctx, false);
|
|
137
|
+
if (marker.completedAt !== null && isTakeoverWindowOver(marker.completedAt, ctx.tz.now())) {
|
|
138
|
+
// skip: the takeover window is over
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const createdSince = ctx.tz
|
|
143
|
+
.now()
|
|
144
|
+
.subtract({ hours: LOOKBACK_DAYS * 24 })
|
|
145
|
+
.toString();
|
|
146
|
+
let after: string | undefined;
|
|
147
|
+
for (let page = 0; page < MAX_PAGES; page++) {
|
|
148
|
+
const listed = await listOpenApiTransactions(ctx, deps.runtime, after, createdSince);
|
|
149
|
+
for (const transaction of listed.data) {
|
|
150
|
+
if (isLegacyCheckout(transaction))
|
|
151
|
+
await ledgerTransaction(ctx, deps.priceToTier, transaction);
|
|
152
|
+
}
|
|
153
|
+
const last = listed.data.at(-1);
|
|
154
|
+
if (listed.meta?.pagination?.has_more !== true || last === undefined) break;
|
|
155
|
+
after = last.id;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
if (marker.completedAt === null) await readMarker(ctx, true);
|
|
159
|
+
}
|
|
@@ -1,4 +1,17 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"version": "0.414.0",
|
|
4
|
+
"type": "breaking",
|
|
5
|
+
"title": "Paddle checkouts are bound by the checkout ledger, the tenant binding key is gone",
|
|
6
|
+
"detail": "The HMAC `tenantBinding` in custom_data and the PADDLE_TENANT_BINDING_KEY / `tenant-binding-key` setting are removed; a webhook is accepted when its transaction id is in the checkout ledger. The new job `backfill-checkout-ledger` (cron every 5 minutes, no-op without an API key) lists open Paddle transactions created through the API, ledgers the ones that still carry a `tenantBinding`, keeps sweeping for one hour after its first completed sweep and then does nothing. The sweep also lists billed, paid and completed transactions of the last 7 days, and while the takeover window is open (no completed sweep yet, or one younger than an hour) a webhook of a legacy checkout (custom_data still has `tenantBinding`) that is not in the ledger yet answers 503, so Paddle redelivers it after the sweep ledgered the checkout.",
|
|
7
|
+
"migration": "Remove PADDLE_TENANT_BINDING_KEY from the environment and the `subscription-paddle:config:tenant-binding-key` value from the secrets; nothing reads them any more. Checkouts that customers opened before the upgrade are taken over by the `backfill-checkout-ledger` job within about five minutes, so no manual step is needed. The job needs a worker that runs the system-identity jobs."
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"version": "0.414.0",
|
|
11
|
+
"type": "fix",
|
|
12
|
+
"title": "paddle webhook drops one-off payments for prices outside oneOffPriceIds",
|
|
13
|
+
"detail": "`transaction.completed` became a payment event for any price with a valid tenant binding. Paddle.js can open a checkout in the browser with arbitrary customData and price, so the server-side `oneOffPriceIds` / `authorizeOneOffCheckout` gate was bypassable. `PaddleWebhookOptions` now takes `oneOffPriceIds` (the feature passes `options.oneOffPriceIds ?? []`) and an event for any other price is dropped with a warning carrying only the provider event id and price id. Apps selling one-off credits must list those prices in `oneOffPriceIds`."
|
|
14
|
+
},
|
|
2
15
|
{
|
|
3
16
|
"version": "0.394.0",
|
|
4
17
|
"type": "improvement",
|
|
@@ -8,7 +8,7 @@ export function makeCheckoutConfigQuery(readCheckoutConfig: PaddleRuntimes["read
|
|
|
8
8
|
return defineQueryHandler({
|
|
9
9
|
name: "checkout-config",
|
|
10
10
|
schema: z.object({}),
|
|
11
|
-
access: { roles: ["anonymous"
|
|
11
|
+
access: { roles: ["anonymous"], anySignedIn: true },
|
|
12
12
|
rateLimit: { per: "ip+handler", limit: 60, windowSeconds: 60 },
|
|
13
13
|
description:
|
|
14
14
|
"Answers the public Paddle.js client token and the Paddle environment for the checkout page; the client token is public by design and no other config leaves this handler.",
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
import { SubscriptionCancelTimings } from "@cosmicdrift/kumiko-bundled-features/billing-foundation";
|
|
5
5
|
import * as z from "zod";
|
|
6
6
|
import type { PaddleCtxRuntime, PaddlePluginMethod } from "./runtime.ts";
|
|
7
|
-
import { signTenantBinding } from "./tenant-binding.ts";
|
|
8
7
|
|
|
9
8
|
export function paddleSubscriptionPath(providerSubscriptionId: string): string {
|
|
10
9
|
return `/subscriptions/${encodeURIComponent(providerSubscriptionId)}`;
|
|
@@ -28,7 +27,6 @@ export function createPaddleCheckoutSession(
|
|
|
28
27
|
return async (ctx, options) => {
|
|
29
28
|
// No Paddle transaction may be created while billing is not live.
|
|
30
29
|
await runtime.assertBillingLive(ctx);
|
|
31
|
-
const bindingKey = await runtime.tenantBindingKey(ctx);
|
|
32
30
|
// No `checkout.url` in the body: Paddle rejects unapproved domains and otherwise
|
|
33
31
|
// answers with the dashboard's Default Payment Link plus `?_ptxn=`.
|
|
34
32
|
const { data } = checkoutResponseSchema.parse(
|
|
@@ -38,11 +36,7 @@ export function createPaddleCheckoutSession(
|
|
|
38
36
|
body: {
|
|
39
37
|
items: [{ price_id: options.priceId, quantity: 1 }],
|
|
40
38
|
...(options.providerCustomerId && { customer_id: options.providerCustomerId }),
|
|
41
|
-
custom_data: {
|
|
42
|
-
tenantId: options.tenantId,
|
|
43
|
-
tenantBinding: signTenantBinding(bindingKey, options.tenantId),
|
|
44
|
-
...(options.consentId && { consentId: options.consentId }),
|
|
45
|
-
},
|
|
39
|
+
custom_data: { tenantId: options.tenantId },
|
|
46
40
|
},
|
|
47
41
|
}),
|
|
48
42
|
);
|
|
@@ -53,7 +47,7 @@ export function createPaddleCheckoutSession(
|
|
|
53
47
|
url.searchParams.set("success", relativeTarget(options.successUrl));
|
|
54
48
|
url.searchParams.set("cancel", relativeTarget(options.cancelUrl));
|
|
55
49
|
if (options.locale) url.searchParams.set("locale", options.locale);
|
|
56
|
-
return { url: url.href };
|
|
50
|
+
return { url: url.href, providerCheckoutId: data.id };
|
|
57
51
|
};
|
|
58
52
|
}
|
|
59
53
|
|
|
@@ -8,10 +8,9 @@ export const PADDLE_PROVIDER_NAME = "paddle" as const;
|
|
|
8
8
|
export const PADDLE_CHECKOUT_PATH = "/billing/paddle-checkout" as const;
|
|
9
9
|
|
|
10
10
|
// Config-key short-names, qualified to `subscription-paddle:config:<name>` at
|
|
11
|
-
// registry-build. api-key
|
|
11
|
+
// registry-build. api-key and webhook-secret are backing:"secrets".
|
|
12
12
|
export const PADDLE_API_KEY_CONFIG = "api-key" as const;
|
|
13
13
|
export const PADDLE_WEBHOOK_SECRET_CONFIG = "webhook-secret" as const;
|
|
14
|
-
export const PADDLE_TENANT_BINDING_KEY_CONFIG = "tenant-binding-key" as const;
|
|
15
14
|
export const PADDLE_CLIENT_TOKEN_CONFIG = "client-token" as const;
|
|
16
15
|
export const PADDLE_ENVIRONMENT_CONFIG = "environment" as const;
|
|
17
16
|
export const PADDLE_BILLING_LIVE_CONFIG = "billingLive" as const;
|