@cosmicdrift/kumiko-samples 0.413.1 → 0.415.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/signup-token-store.ts +2 -3
- 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 +12 -13
- 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/changes.json +6 -0
- 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 +61 -0
- package/packages/bundled-features/src/billing-foundation/checkout-core.ts +19 -1
- package/packages/bundled-features/src/billing-foundation/checkout-ledger.ts +67 -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 +51 -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 +9 -1
- package/packages/bundled-features/src/billing-foundation/handlers/process-event.write.ts +183 -17
- package/packages/bundled-features/src/billing-foundation/handlers/process-payment-event.write.ts +35 -10
- 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 +9 -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 +32 -0
- package/packages/bundled-features/src/channel-whatsapp/constants.ts +46 -0
- package/packages/bundled-features/src/channel-whatsapp/events.ts +94 -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 +210 -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 +247 -0
- package/packages/bundled-features/src/channel-whatsapp/webhook-routes.ts +185 -0
- package/packages/bundled-features/src/compliance-profiles/changes.json +5 -0
- package/packages/bundled-features/src/compliance-profiles/handlers/set-profile.write.ts +2 -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 +2 -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 +12 -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 +54 -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/changes.json +6 -0
- package/packages/bundled-features/src/document-ingest-foundation/feature.ts +1 -0
- package/packages/bundled-features/src/document-ingest-foundation/report-ingest-progress.ts +34 -14
- package/packages/bundled-features/src/documents/aggregate-id.ts +0 -2
- package/packages/bundled-features/src/documents/changes.json +24 -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 +33 -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/form-draft/feature.ts +1 -0
- package/packages/bundled-features/src/helpdesk/changes.json +56 -0
- package/packages/bundled-features/src/helpdesk/entity.ts +4 -1
- package/packages/bundled-features/src/helpdesk/feature.ts +42 -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 +5 -12
- package/packages/bundled-features/src/helpdesk/handlers/report.write.ts +4 -10
- package/packages/bundled-features/src/helpdesk/handlers/submit.write.ts +5 -12
- 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 +187 -0
- package/packages/bundled-features/src/helpdesk/legacy-contact-user-data.ts +84 -0
- package/packages/bundled-features/src/helpdesk/lib.ts +55 -37
- 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 +9 -2
- package/packages/bundled-features/src/inbound-mail-foundation/aggregate-id.ts +0 -2
- package/packages/bundled-features/src/inbound-mail-foundation/changes.json +54 -0
- package/packages/bundled-features/src/inbound-mail-foundation/constants.ts +6 -0
- package/packages/bundled-features/src/inbound-mail-foundation/content-refetch.ts +23 -2
- package/packages/bundled-features/src/inbound-mail-foundation/entities.ts +73 -15
- package/packages/bundled-features/src/inbound-mail-foundation/events.ts +24 -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 +23 -9
- package/packages/bundled-features/src/inbound-mail-foundation/handlers/forget-message.write.ts +79 -0
- package/packages/bundled-features/src/inbound-mail-foundation/handlers/ingest-message-schema.ts +18 -5
- 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/normalize-inbound-message.ts +22 -8
- 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/sanitize-inbound-html.ts +2 -5
- 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 +204 -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 +12 -0
- package/packages/bundled-features/src/shared/hmac-signature.ts +4 -2
- package/packages/bundled-features/src/shared/index.ts +7 -1
- package/packages/bundled-features/src/shared/normalize-email.ts +3 -0
- 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 +29 -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 +18 -0
- package/packages/bundled-features/src/step-dispatcher/constants.ts +13 -0
- package/packages/bundled-features/src/step-dispatcher/deliver-dispatch-request.ts +50 -2
- package/packages/bundled-features/src/step-dispatcher/feature.ts +42 -1
- package/packages/bundled-features/src/step-dispatcher/mail-runner.ts +0 -1
- package/packages/bundled-features/src/step-dispatcher/sweep-abandoned.ts +61 -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 +161 -0
- package/packages/bundled-features/src/subscription-paddle/changes.json +19 -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 +57 -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 +13 -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 +38 -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 +48 -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 +107 -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 +132 -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/changes.json +6 -0
- package/packages/bundled-features/src/tenant-inactivity/check-inactive-tenants.ts +36 -17
- package/packages/bundled-features/src/tenant-inactivity/constants.ts +1 -2
- package/packages/bundled-features/src/tenant-inactivity/handlers/keep-account.write.ts +7 -2
- package/packages/bundled-features/src/tenant-inactivity/state-store.ts +22 -2
- package/packages/bundled-features/src/tenant-lifecycle/changes.json +24 -0
- package/packages/bundled-features/src/tenant-lifecycle/constants.ts +4 -0
- package/packages/bundled-features/src/tenant-lifecycle/feature.ts +1 -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/feature.ts +1 -0
- 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/reject.write.ts +1 -1
- package/packages/bundled-features/src/waitlist/handlers/submit.write.ts +5 -29
- package/packages/bundled-features/src/waitlist/import.ts +2 -1
- package/packages/bundled-features/src/waitlist/lib.ts +2 -11
- package/packages/bundled-features/src/waitlist/link-on-signup.ts +2 -2
- 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/changes.json +6 -0
- 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 +7 -4
- package/packages/bundled-features/src/workflow-runner/runner.ts +2 -0
- package/samples/apps/admin-console/src/app/shell.tsx +1 -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/crypto-shredding-hr/README.md +11 -0
- package/samples/recipes/crypto-shredding-hr/src/feature.ts +27 -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 +556 -44
- package/samples/recipes/record-detail-layout/src/order-board.ts +529 -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
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
import type { ConfigKeyHandle, HandlerContext } from "@cosmicdrift/kumiko-framework/engine";
|
|
2
2
|
import { FeatureDisabledError } from "@cosmicdrift/kumiko-framework/errors";
|
|
3
3
|
|
|
4
|
+
export async function isBillingLive(
|
|
5
|
+
ctx: HandlerContext,
|
|
6
|
+
billingLiveHandle: ConfigKeyHandle<"boolean">,
|
|
7
|
+
): Promise<boolean> {
|
|
8
|
+
const live = ctx.config ? await ctx.config(billingLiveHandle) : undefined;
|
|
9
|
+
return live === true;
|
|
10
|
+
}
|
|
11
|
+
|
|
4
12
|
export async function assertBillingLive(
|
|
5
13
|
ctx: HandlerContext,
|
|
6
14
|
billingLiveHandle: ConfigKeyHandle<"boolean">,
|
|
7
15
|
featureName: string,
|
|
8
16
|
handlerName: string,
|
|
9
17
|
): Promise<void> {
|
|
10
|
-
|
|
11
|
-
if (live !== true) {
|
|
18
|
+
if (!(await isBillingLive(ctx, billingLiveHandle))) {
|
|
12
19
|
throw new FeatureDisabledError(featureName, handlerName);
|
|
13
20
|
}
|
|
14
21
|
}
|
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"version": "0.415.0",
|
|
4
|
+
"type": "fix",
|
|
5
|
+
"title": "One normalizeEmail for helpdesk, waitlist, signup tokens and user-data lookups",
|
|
6
|
+
"detail": "The copies in helpdesk, waitlist, signup-token-store and the inline toLowerCase in resolveVerifiedUserEmail now use shared/normalizeEmail, so a changed normalization cannot make export and erasure miss stored rows."
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
"version": "0.414.0",
|
|
10
|
+
"type": "fix",
|
|
11
|
+
"title": "Stream-tenant backfill reindexes the old search bucket",
|
|
12
|
+
"detail": "The stream-tenant backfill reindexes the old search bucket when a candidate fails after its docs were removed (createSearchBucketCleanup takes a row source and exposes onMoveFailed). A failed candidate reindexes only its own document in the old bucket, not the whole bucket."
|
|
13
|
+
},
|
|
2
14
|
{
|
|
3
15
|
"version": "0.405.0",
|
|
4
16
|
"type": "improvement",
|
|
@@ -8,8 +8,10 @@ export function hmacSignatureMatches(
|
|
|
8
8
|
expectedBase64Url: string,
|
|
9
9
|
providedBase64Url: string,
|
|
10
10
|
): boolean {
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
// The text is compared, not the decoded bytes: decoding ignores the unused trailing bits of the
|
|
12
|
+
// last character, so one signature would have several accepted spellings.
|
|
13
|
+
const expectedBuf = Buffer.from(expectedBase64Url);
|
|
14
|
+
const providedBuf = Buffer.from(providedBase64Url);
|
|
13
15
|
// timingSafeEqual throws on a length mismatch, and the throw itself is a timing signal.
|
|
14
16
|
return expectedBuf.length === providedBuf.length && timingSafeEqual(expectedBuf, providedBuf);
|
|
15
17
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { acknowledgedSystemDb } from "./acknowledged-system-db.ts";
|
|
2
|
+
export { assertBillingLive, isBillingLive } from "./assert-billing-live.ts";
|
|
2
3
|
export { collectErasureFailure, throwIfErasureFailed } from "./assert-erased.ts";
|
|
3
4
|
export { assertNoWhereRuleInOwnershipWrite } from "./assert-no-where-rule-in-ownership-write.ts";
|
|
4
5
|
export {
|
|
@@ -35,11 +36,13 @@ export {
|
|
|
35
36
|
mailRepeatedRows,
|
|
36
37
|
} from "./mail-template-body.ts";
|
|
37
38
|
export { mapWithConcurrency } from "./map-with-concurrency.ts";
|
|
39
|
+
export { normalizeEmail } from "./normalize-email.ts";
|
|
38
40
|
export {
|
|
39
41
|
denyUnlessJoinRowParentVisible,
|
|
40
42
|
hostRowIsGone,
|
|
41
43
|
joinRowParentIsVisible,
|
|
42
44
|
parentRowIsVisible,
|
|
45
|
+
visibleParentRowIds,
|
|
43
46
|
} from "./parent-visibility.ts";
|
|
44
47
|
export { hashPassword, verifyDummyPassword, verifyPassword } from "./password-hashing.ts";
|
|
45
48
|
export {
|
|
@@ -72,6 +75,8 @@ export {
|
|
|
72
75
|
redactUrls,
|
|
73
76
|
} from "./redact.ts";
|
|
74
77
|
export { REDACTED_PII_PLACEHOLDER, redactPiiCiphertext } from "./redact-pii-ciphertext.ts";
|
|
78
|
+
export { registerUserDataHooks } from "./register-user-data-hooks.ts";
|
|
79
|
+
export { requireBootstrapExtension } from "./require-bootstrap-extension.ts";
|
|
75
80
|
export { requireForTenant } from "./require-for-tenant.ts";
|
|
76
81
|
export { resolveFeatureAccess } from "./resolve-feature-access.ts";
|
|
77
82
|
export {
|
|
@@ -88,6 +93,7 @@ export {
|
|
|
88
93
|
signRowBoundGrant,
|
|
89
94
|
} from "./row-bound-grant.ts";
|
|
90
95
|
export { runInSubTransaction } from "./run-in-sub-transaction.ts";
|
|
96
|
+
export { runBestEffort, sendBestEffort } from "./send-best-effort.ts";
|
|
91
97
|
export { registrationLocaleFromRequest, sessionLocaleField } from "./session-locale-field.ts";
|
|
92
98
|
export { sessionTimezoneField } from "./session-timezone-field.ts";
|
|
93
99
|
export { assertNotSvg, MAX_INPUT_PIXELS, SHARP_INPUT_OPTIONS } from "./sharp-input-limits.ts";
|
|
@@ -56,13 +56,37 @@ export async function parentRowIsVisible(
|
|
|
56
56
|
// the executor.
|
|
57
57
|
if (!idShapeMatchesEntity(entity, entityId)) return false;
|
|
58
58
|
|
|
59
|
+
return (await executorFor(entityType, entity).detail({ id: entityId }, user, db)) !== null;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function executorFor(entityType: string, entity: EntityDefinition): EventStoreExecutor {
|
|
59
63
|
let executor = executorsByEntity.get(entity);
|
|
60
64
|
if (!executor) {
|
|
61
65
|
executor = createEntityExecutor(entityType, entity).executor;
|
|
62
66
|
executorsByEntity.set(entity, executor);
|
|
63
67
|
}
|
|
68
|
+
return executor;
|
|
69
|
+
}
|
|
64
70
|
|
|
65
|
-
|
|
71
|
+
// Batch form of parentRowIsVisible: one list query for all ids instead of one detail lookup each.
|
|
72
|
+
// Same gates and the same default-deny; the caller keeps ids it was given that are not returned out.
|
|
73
|
+
export async function visibleParentRowIds(
|
|
74
|
+
registry: Registry,
|
|
75
|
+
entityType: string,
|
|
76
|
+
entityIds: readonly string[],
|
|
77
|
+
user: SessionUser,
|
|
78
|
+
db: TenantDb,
|
|
79
|
+
): Promise<ReadonlySet<string>> {
|
|
80
|
+
const entity = registry.getEntity(entityType);
|
|
81
|
+
if (!entity || entity.parentRef !== undefined) return new Set();
|
|
82
|
+
const wellFormed = entityIds.filter((entityId) => idShapeMatchesEntity(entity, entityId));
|
|
83
|
+
if (wellFormed.length === 0) return new Set();
|
|
84
|
+
const page = await executorFor(entityType, entity).list(
|
|
85
|
+
{ filters: [{ field: "id", op: "in", value: wellFormed }], limit: wellFormed.length },
|
|
86
|
+
user,
|
|
87
|
+
db,
|
|
88
|
+
);
|
|
89
|
+
return new Set(page.rows.map((row) => String(row["id"])));
|
|
66
90
|
}
|
|
67
91
|
|
|
68
92
|
const hostTablesByEntity = new WeakMap<EntityDefinition, ReturnType<typeof buildEntityTable>>();
|
|
@@ -20,10 +20,7 @@ export function priceEnvShape<const TEnvPrefix extends string, const TPrice exte
|
|
|
20
20
|
`${envPrefix}_PRICE_${price}`,
|
|
21
21
|
z
|
|
22
22
|
.string()
|
|
23
|
-
.
|
|
24
|
-
new RegExp(`^${priceIdPrefix}`),
|
|
25
|
-
`${envPrefix}_PRICE_${price} must start with '${priceIdPrefix}'`,
|
|
26
|
-
)
|
|
23
|
+
.startsWith(priceIdPrefix, `${envPrefix}_PRICE_${price} must start with '${priceIdPrefix}'`)
|
|
27
24
|
.optional()
|
|
28
25
|
.describe(`${label} price id (\`${priceIdPrefix}...\`) of the ${price} plan.`),
|
|
29
26
|
]),
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import {
|
|
2
|
+
EXT_USER_DATA,
|
|
3
|
+
type FeatureRegistrar,
|
|
4
|
+
type UserDataDeleteHook,
|
|
5
|
+
type UserDataExportHook,
|
|
6
|
+
} from "@cosmicdrift/kumiko-framework/engine";
|
|
7
|
+
|
|
8
|
+
type UserDataEntityHooks = {
|
|
9
|
+
readonly entity: string;
|
|
10
|
+
readonly export: UserDataExportHook;
|
|
11
|
+
readonly delete: UserDataDeleteHook;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
// The source feature is optionalRequires, not requires: a source mounted toggleable(default=false)
|
|
15
|
+
// would otherwise trip the "effectively disabled" boot warning although its entities exist and the
|
|
16
|
+
// hooks work. defineFeature itself stays literal in each feature so the AST doc generator sees it.
|
|
17
|
+
export function registerUserDataHooks(
|
|
18
|
+
r: FeatureRegistrar,
|
|
19
|
+
config: {
|
|
20
|
+
readonly sourceFeature: string;
|
|
21
|
+
readonly entities: readonly UserDataEntityHooks[];
|
|
22
|
+
},
|
|
23
|
+
): void {
|
|
24
|
+
r.requires({ features: ["user-data-rights"] });
|
|
25
|
+
r.optionalRequires(config.sourceFeature);
|
|
26
|
+
config.entities.forEach(({ entity, export: exportHook, delete: deleteHook }) => {
|
|
27
|
+
r.useExtension(EXT_USER_DATA, entity, { export: exportHook, delete: deleteHook });
|
|
28
|
+
});
|
|
29
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { InternalError } from "@cosmicdrift/kumiko-framework/errors";
|
|
2
|
+
|
|
3
|
+
// Handlers that need a feature API wired through the app bootstrap's `extraContext` read it from
|
|
4
|
+
// `services.extensions`; the missing case is a bootstrap mistake and gets one consistent message.
|
|
5
|
+
export function requireBootstrapExtension<TApi>(
|
|
6
|
+
ctx: { readonly services: { readonly extensions: Readonly<Record<string, unknown>> } },
|
|
7
|
+
callerName: string,
|
|
8
|
+
extension: {
|
|
9
|
+
readonly key: string;
|
|
10
|
+
readonly bootstrapExample: string;
|
|
11
|
+
readonly readme: string;
|
|
12
|
+
},
|
|
13
|
+
): TApi {
|
|
14
|
+
// @cast-boundary engine-bridge — the extension arrives per extraContext from the app bootstrap
|
|
15
|
+
// and lands in services.extensions; the framework does not know its type.
|
|
16
|
+
const api = ctx.services.extensions[extension.key] as TApi | undefined;
|
|
17
|
+
if (!api) {
|
|
18
|
+
throw new InternalError({
|
|
19
|
+
message:
|
|
20
|
+
`[${callerName}] ctx.${extension.key} missing — App-Bootstrap muss ` +
|
|
21
|
+
`extraContext: { ${extension.bootstrapExample} } setzen ` +
|
|
22
|
+
`(siehe ${extension.readme}).`,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
return api;
|
|
26
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { HandlerContext } from "@cosmicdrift/kumiko-framework/engine";
|
|
2
|
+
import { InternalError } from "@cosmicdrift/kumiko-framework/errors";
|
|
3
|
+
|
|
4
|
+
export async function runBestEffort(
|
|
5
|
+
ctx: Pick<HandlerContext, "obs">,
|
|
6
|
+
logMessage: string,
|
|
7
|
+
run: () => Promise<unknown>,
|
|
8
|
+
): Promise<void> {
|
|
9
|
+
try {
|
|
10
|
+
await run();
|
|
11
|
+
} catch (err) {
|
|
12
|
+
ctx.obs.log?.warn(logMessage, {
|
|
13
|
+
error: err instanceof Error ? err.message : String(err),
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export async function sendBestEffort(
|
|
19
|
+
ctx: Pick<HandlerContext, "notify" | "obs">,
|
|
20
|
+
logMessage: string,
|
|
21
|
+
send: (notify: NonNullable<HandlerContext["notify"]>) => Promise<unknown>,
|
|
22
|
+
): Promise<void> {
|
|
23
|
+
await runBestEffort(ctx, logMessage, async () => {
|
|
24
|
+
if (!ctx.notify) {
|
|
25
|
+
throw new InternalError({ message: "ctx.notify unavailable — mount the delivery feature" });
|
|
26
|
+
}
|
|
27
|
+
await send(ctx.notify);
|
|
28
|
+
});
|
|
29
|
+
}
|
|
@@ -55,6 +55,8 @@ export type StreamBackfillOptions = {
|
|
|
55
55
|
// Runs per candidate before its events move; a throw skips the aggregate
|
|
56
56
|
// and lands in `failed` (search cleanup must not be lost by a move).
|
|
57
57
|
readonly beforeMove?: (candidate: StreamBackfillCandidate) => Promise<void>;
|
|
58
|
+
// Runs when beforeMove or the move failed, to restore what beforeMove may have removed.
|
|
59
|
+
readonly onMoveFailed?: (candidate: StreamBackfillCandidate) => Promise<void>;
|
|
58
60
|
// Restricts the candidate scan to events on these tenants, which lets Postgres use
|
|
59
61
|
// events_tenant_type_idx instead of grouping every event of the type. Streams on a tenant
|
|
60
62
|
// outside the list are not found; omit it for the full scan.
|
|
@@ -86,6 +88,7 @@ export async function backfillAggregateStreamTenants(
|
|
|
86
88
|
const failed: StreamBackfillFailure[] = [];
|
|
87
89
|
|
|
88
90
|
for (const row of rows) {
|
|
91
|
+
let beforeMoveStarted: StreamBackfillCandidate | undefined;
|
|
89
92
|
try {
|
|
90
93
|
if (!row.target_tenant_id) {
|
|
91
94
|
throw new Error(`earliest event of the aggregate carries no payload.tenantId`);
|
|
@@ -95,19 +98,37 @@ export async function backfillAggregateStreamTenants(
|
|
|
95
98
|
targetTenantId: row.target_tenant_id,
|
|
96
99
|
sourceTenantIds: row.source_tenant_ids,
|
|
97
100
|
};
|
|
101
|
+
beforeMoveStarted = candidate;
|
|
98
102
|
await options.beforeMove?.(candidate);
|
|
99
103
|
eventsMigrated += await migrateAggregate(db, options.aggregateType, candidate);
|
|
100
104
|
aggregatesMigrated++;
|
|
101
105
|
} catch (e) {
|
|
106
|
+
const moveError = e instanceof Error ? e.message : String(e);
|
|
102
107
|
failed.push({
|
|
103
108
|
aggregateId: row.aggregate_id,
|
|
104
|
-
error:
|
|
109
|
+
error: await withRestoreOutcome(options, beforeMoveStarted, moveError),
|
|
105
110
|
});
|
|
106
111
|
}
|
|
107
112
|
}
|
|
108
113
|
return { aggregatesMigrated, eventsMigrated, failed };
|
|
109
114
|
}
|
|
110
115
|
|
|
116
|
+
// The move rolled back, so the aggregate stays where it was and must keep its pre-move derived state.
|
|
117
|
+
async function withRestoreOutcome(
|
|
118
|
+
options: StreamBackfillOptions,
|
|
119
|
+
candidate: StreamBackfillCandidate | undefined,
|
|
120
|
+
moveError: string,
|
|
121
|
+
): Promise<string> {
|
|
122
|
+
if (candidate === undefined || options.onMoveFailed === undefined) return moveError;
|
|
123
|
+
try {
|
|
124
|
+
await options.onMoveFailed(candidate);
|
|
125
|
+
return moveError;
|
|
126
|
+
} catch (restoreError) {
|
|
127
|
+
const detail = restoreError instanceof Error ? restoreError.message : String(restoreError);
|
|
128
|
+
return `${moveError}; restoring the pre-move derived state failed: ${detail}`;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
111
132
|
async function readCandidateRows(
|
|
112
133
|
db: DbConnection,
|
|
113
134
|
options: StreamBackfillOptions,
|
|
@@ -3,7 +3,11 @@
|
|
|
3
3
|
// in stream-tenant-backfill.ts; this part is repeatable and safe to run without moves.
|
|
4
4
|
|
|
5
5
|
import type { DbConnection } from "@cosmicdrift/kumiko-framework/db";
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
parseTenantId,
|
|
8
|
+
type Registry,
|
|
9
|
+
SYSTEM_TENANT_ID,
|
|
10
|
+
} from "@cosmicdrift/kumiko-framework/engine";
|
|
7
11
|
import { rebuildProjection } from "@cosmicdrift/kumiko-framework/pipeline";
|
|
8
12
|
import {
|
|
9
13
|
isEntitySearchable,
|
|
@@ -21,13 +25,39 @@ export type DerivedStateMode = "if-moved" | "always";
|
|
|
21
25
|
export function createSearchBucketCleanup(
|
|
22
26
|
searchAdapter: SearchAdapter | undefined,
|
|
23
27
|
entityType: string,
|
|
28
|
+
rowSource: { readonly db: DbConnection; readonly registry: Registry },
|
|
24
29
|
): {
|
|
25
30
|
readonly beforeMove: (candidate: StreamBackfillCandidate) => Promise<void>;
|
|
31
|
+
readonly onMoveFailed: (candidate: StreamBackfillCandidate) => Promise<void>;
|
|
26
32
|
readonly cleanedAggregates: () => number;
|
|
27
33
|
} {
|
|
28
34
|
let cleaned = 0;
|
|
29
35
|
return {
|
|
30
36
|
cleanedAggregates: () => cleaned,
|
|
37
|
+
// The rolled-back move leaves the row in its old bucket, so reindexing that row brings the doc
|
|
38
|
+
// back; the rest of the bucket was not touched by this candidate.
|
|
39
|
+
onMoveFailed: async (candidate) => {
|
|
40
|
+
// skip: no adapter means no search docs were removed
|
|
41
|
+
if (!searchAdapter || !isEntitySearchable(rowSource.registry, entityType)) return;
|
|
42
|
+
const oldBuckets = candidate.sourceTenantIds.filter((id) => id !== candidate.targetTenantId);
|
|
43
|
+
for (const bucket of oldBuckets) {
|
|
44
|
+
const bucketTenantId = parseTenantId(bucket);
|
|
45
|
+
if (bucketTenantId === null) throw new Error(`source bucket ${bucket} is not a tenant id`);
|
|
46
|
+
const reindex = await reindexEntity(
|
|
47
|
+
rowSource.db,
|
|
48
|
+
rowSource.registry,
|
|
49
|
+
searchAdapter,
|
|
50
|
+
entityType,
|
|
51
|
+
bucketTenantId,
|
|
52
|
+
{ onlyEntityId: candidate.aggregateId },
|
|
53
|
+
);
|
|
54
|
+
if (reindex.failures.length > 0) {
|
|
55
|
+
throw new Error(
|
|
56
|
+
`reindex of ${candidate.aggregateId} in bucket ${bucket} failed for ${reindex.failures.length} rows: ${reindex.failures[0]?.reason}`,
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
},
|
|
31
61
|
beforeMove: async (candidate) => {
|
|
32
62
|
// skip: no adapter means no search docs to clean
|
|
33
63
|
if (!searchAdapter) return;
|
|
@@ -1,4 +1,22 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"version": "0.415.0",
|
|
4
|
+
"type": "fix",
|
|
5
|
+
"title": "Abandoned-dispatch sweep skips live deliver jobs and cannot overwrite a concurrent outcome",
|
|
6
|
+
"detail": "Before closing a request older than 24 h the sweep asks the job runner whether its deliver job is still waiting, delayed, active, paused or prioritized and skips it until a later run. A runner that cannot report job state makes the sweep skip everything and warn. The failure event is appended with the stream version that was loaded, so a delivery recording its outcome in between causes a version conflict (reported through the close-failure log) and the payload key is not erased. `JobRunner` and `JobRunnerRef` gain an optional `isJobPending(jobName, jobId)`, and `MultiStreamApplyContext.unsafeAppendEvent` accepts an optional `expectedVersion`."
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
"version": "0.414.0",
|
|
10
|
+
"type": "fix",
|
|
11
|
+
"title": "Final step-delivery attempt erases the dispatch key",
|
|
12
|
+
"detail": "A final step-delivery attempt whose outcome cannot be recorded still erases the dispatch key."
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"version": "0.414.0",
|
|
16
|
+
"type": "fix",
|
|
17
|
+
"title": "A sweeper closes dispatch streams that never got an outcome",
|
|
18
|
+
"detail": "The daily job `step-dispatcher:job:sweep-abandoned` pages through all `step-dispatch` streams older than 24 hours that have neither a dispatched nor a failed event (a lost deliver job, a worker that died after the request was written), appends `step-dispatch.failed` with the error `dispatch abandoned without a recorded outcome` and erases the stream's PII key, so the personal data of a request nobody delivers no longer stays readable forever. Streams that already have an outcome are not swept. A late deliver job for a swept stream sends nothing. The job declares an `escapeHatch` for the cross-tenant read of open streams. Framework: `selectOpenStreamsStartedBefore` (event-store) lists open streams of one aggregate type across tenants."
|
|
19
|
+
},
|
|
2
20
|
{
|
|
3
21
|
"version": "0.389.0",
|
|
4
22
|
"type": "fix",
|
|
@@ -4,10 +4,12 @@ export const STEP_DISPATCHER_FEATURE = "step-dispatcher";
|
|
|
4
4
|
|
|
5
5
|
export const StepDispatcherJobNames = {
|
|
6
6
|
deliver: "deliver",
|
|
7
|
+
sweepAbandoned: "sweep-abandoned",
|
|
7
8
|
} as const;
|
|
8
9
|
|
|
9
10
|
export const StepDispatcherJobs = {
|
|
10
11
|
deliver: qn(STEP_DISPATCHER_FEATURE, QnTypes.job, StepDispatcherJobNames.deliver),
|
|
12
|
+
sweepAbandoned: qn(STEP_DISPATCHER_FEATURE, QnTypes.job, StepDispatcherJobNames.sweepAbandoned),
|
|
11
13
|
} as const;
|
|
12
14
|
|
|
13
15
|
// Stable per dispatch stream: BullMQ ignores a second add() with the same id,
|
|
@@ -20,3 +22,14 @@ export function deliverJobId(aggregateId: string): string {
|
|
|
20
22
|
// cannot occupy every worker slot.
|
|
21
23
|
export const DELIVER_MAX_PER_TENANT = 2;
|
|
22
24
|
export const DELIVER_RETRIES = 3;
|
|
25
|
+
|
|
26
|
+
// A deliver job spends at most DELIVER_RETRIES exponential retries (1 s base: 1 + 2 + 4 s) plus
|
|
27
|
+
// 100 per-tenant defers (maxDefers default, each capped at 30 s + 1 s jitter, about 52 min), so a
|
|
28
|
+
// live job is done long before this. Only a stalled or lost job leaves a request older than it
|
|
29
|
+
// without an outcome; 24 h also covers a worker lane that was down for a night.
|
|
30
|
+
export const ABANDON_DISPATCH_AFTER_HOURS = 24;
|
|
31
|
+
|
|
32
|
+
// Page size of the daily sweep. The open-stream query filters kumiko_events by aggregate type and
|
|
33
|
+
// event type without a matching index (the only index starts with tenant_id), so it is a seq
|
|
34
|
+
// scan: the cron runs once a day, not hourly.
|
|
35
|
+
export const SWEEP_ABANDONED_BATCH_SIZE = 500;
|
|
@@ -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;
|
|
@@ -125,6 +141,7 @@ function createOutcomeRecorder(
|
|
|
125
141
|
ctx: MultiStreamApplyContext,
|
|
126
142
|
aggregateId: string,
|
|
127
143
|
attempt: number,
|
|
144
|
+
expectedVersion?: number,
|
|
128
145
|
): OutcomeRecorder {
|
|
129
146
|
const record: OutcomeRecorder["record"] = async (type, payload) => {
|
|
130
147
|
await ctx.unsafeAppendEvent({
|
|
@@ -132,6 +149,7 @@ function createOutcomeRecorder(
|
|
|
132
149
|
aggregateType: STEP_DISPATCH_AGGREGATE_TYPE,
|
|
133
150
|
type,
|
|
134
151
|
payload,
|
|
152
|
+
...(expectedVersion !== undefined && { expectedVersion }),
|
|
135
153
|
});
|
|
136
154
|
await eraseDispatchKey(aggregateId);
|
|
137
155
|
};
|
|
@@ -142,6 +160,27 @@ function createOutcomeRecorder(
|
|
|
142
160
|
};
|
|
143
161
|
}
|
|
144
162
|
|
|
163
|
+
// For a deliver job that ended terminally without an outcome (BullMQ stall, lost job): the
|
|
164
|
+
// request is closed as failed and its key erased. A stream that already has an outcome only
|
|
165
|
+
// repeats the erase. The failure is pinned to the loaded version: a delivery that records its
|
|
166
|
+
// outcome in between makes the append throw VersionConflictError and the key stays.
|
|
167
|
+
export async function closeAbandonedDispatch(
|
|
168
|
+
ctx: MultiStreamApplyContext,
|
|
169
|
+
aggregateId: string,
|
|
170
|
+
): Promise<"closed" | "already-closed"> {
|
|
171
|
+
const stream = await ctx.loadAggregate(aggregateId);
|
|
172
|
+
if (stream.some(isDispatchOutcome)) {
|
|
173
|
+
await eraseDispatchKey(aggregateId);
|
|
174
|
+
return "already-closed";
|
|
175
|
+
}
|
|
176
|
+
const requested = stream.find((e) => e.type === STEP_DISPATCH_REQUESTED_TYPE);
|
|
177
|
+
await createOutcomeRecorder(ctx, aggregateId, 0, stream.at(-1)?.version).recordFailure(
|
|
178
|
+
rawStepKindOf(requested?.payload),
|
|
179
|
+
DISPATCH_ABANDONED_ERROR,
|
|
180
|
+
);
|
|
181
|
+
return "closed";
|
|
182
|
+
}
|
|
183
|
+
|
|
145
184
|
type RequestedEvent = Awaited<ReturnType<MultiStreamApplyContext["loadAggregate"]>>[number];
|
|
146
185
|
|
|
147
186
|
async function deliverRequested(
|
|
@@ -214,11 +253,12 @@ async function sendDispatch(
|
|
|
214
253
|
errorName: err instanceof Error ? err.name : "unknown",
|
|
215
254
|
});
|
|
216
255
|
// 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)
|
|
256
|
+
// would send it again, so only the webhook (which carries one) and mail that failed before
|
|
257
|
+
// the connection was established are retried.
|
|
218
258
|
return {
|
|
219
259
|
ok: false,
|
|
220
260
|
error: DISPATCH_THREW_ERROR,
|
|
221
|
-
retryable: dispatchSpec.stepKind === "webhook.send",
|
|
261
|
+
retryable: dispatchSpec.stepKind === "webhook.send" || isThrownBeforeProviderAccepted(err),
|
|
222
262
|
};
|
|
223
263
|
}
|
|
224
264
|
}
|
|
@@ -245,6 +285,14 @@ async function abortOnFinalAttempt(
|
|
|
245
285
|
await recorder.recordFailure(rawStepKindOf(requestedPayload), FINAL_ATTEMPT_ABORTED_ERROR);
|
|
246
286
|
}
|
|
247
287
|
} catch {
|
|
288
|
+
// No outcome and no further retry: the request payload must not stay decryptable. A later
|
|
289
|
+
// redelivery then ends as "payload erased" instead of sending again.
|
|
290
|
+
await eraseDispatchKey(aggregateId).catch((eraseErr: unknown) => {
|
|
291
|
+
log.warn("dispatch key erase failed after an unrecorded final attempt", {
|
|
292
|
+
aggregateId,
|
|
293
|
+
errorName: eraseErr instanceof Error ? eraseErr.name : "unknown",
|
|
294
|
+
});
|
|
295
|
+
});
|
|
248
296
|
throw new Error(FINAL_ATTEMPT_UNRECORDED_ERROR);
|
|
249
297
|
}
|
|
250
298
|
}
|
|
@@ -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({
|
|
@@ -72,6 +77,7 @@ export function createStepDispatcherFeature(): FeatureDefinition {
|
|
|
72
77
|
"deliver",
|
|
73
78
|
{
|
|
74
79
|
trigger: { manual: true },
|
|
80
|
+
irreversibleWithoutEntryHandler: "per-dispatch-record-key",
|
|
75
81
|
retries: DELIVER_RETRIES,
|
|
76
82
|
backoff: "exponential",
|
|
77
83
|
maxPerTenant: { limit: DELIVER_MAX_PER_TENANT, onLimit: "defer" },
|
|
@@ -100,8 +106,43 @@ export function createStepDispatcherFeature(): FeatureDefinition {
|
|
|
100
106
|
},
|
|
101
107
|
);
|
|
102
108
|
|
|
109
|
+
// Literal name, mirrored by StepDispatcherJobNames.sweepAbandoned (pinned in feature.boot.test.ts).
|
|
110
|
+
r.job(
|
|
111
|
+
"sweep-abandoned",
|
|
112
|
+
{
|
|
113
|
+
trigger: { cron: "17 3 * * *", wakesSleepingApp: false },
|
|
114
|
+
irreversibleWithoutEntryHandler: "per-dispatch-record-key",
|
|
115
|
+
concurrency: "skip",
|
|
116
|
+
escapeHatch: { reason: SWEEP_ESCAPE_HATCH_REASON },
|
|
117
|
+
},
|
|
118
|
+
async (_payload, ctx) => {
|
|
119
|
+
const runner = ctx.services.jobRunner;
|
|
120
|
+
const isJobPending = runner?.isJobPending?.bind(runner);
|
|
121
|
+
if (!isJobPending) {
|
|
122
|
+
// Fail closed: closing would erase the PII key of a delivery that may still run.
|
|
123
|
+
ctx.obs.log.warn(
|
|
124
|
+
"job runner cannot report job state, abandoned dispatches are not swept",
|
|
125
|
+
);
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
await sweepAbandonedDispatches({
|
|
129
|
+
db: ctx.db.unsafeRaw(),
|
|
130
|
+
registry: ctx.registry,
|
|
131
|
+
isDeliverJobPending: (aggregateId) =>
|
|
132
|
+
isJobPending(StepDispatcherJobs.deliver, deliverJobId(aggregateId)),
|
|
133
|
+
startedBeforeIso: ctx.tz
|
|
134
|
+
.now()
|
|
135
|
+
.subtract({ hours: ABANDON_DISPATCH_AFTER_HOURS })
|
|
136
|
+
.toString(),
|
|
137
|
+
onCloseFailure: (aggregateId, errorName) =>
|
|
138
|
+
ctx.obs.log.warn("abandoned dispatch could not be closed", { aggregateId, errorName }),
|
|
139
|
+
});
|
|
140
|
+
},
|
|
141
|
+
);
|
|
142
|
+
|
|
103
143
|
r.multiStreamProjection({
|
|
104
144
|
name: "step-dispatcher",
|
|
145
|
+
irreversibleWithoutEntryHandler: "per-dispatch-record-key",
|
|
105
146
|
apply: {
|
|
106
147
|
[STEP_DISPATCH_REQUESTED_TYPE]: async (event, _tx, ctx) => {
|
|
107
148
|
const stream = await ctx.loadAggregate(event.aggregateId);
|
|
@@ -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
|
}
|