@cosmicdrift/kumiko-bundled-features 0.413.0 → 0.414.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/admin-shell/feature.js +2 -2
- package/dist/agent-tools/agent-doc-lint.js +2 -1
- package/dist/agent-tools/agent-manifest.js +33 -25
- package/dist/agent-tools/api-docs/collect-events.js +4 -1
- package/dist/agent-tools/api-docs/collect.js +3 -3
- package/dist/agent-tools/api-docs/generate.js +4 -1
- package/dist/agent-tools/api-docs/index.d.ts +1 -0
- package/dist/agent-tools/api-docs/index.js +1 -0
- package/dist/agent-tools/api-docs/problems.d.ts +21 -0
- package/dist/agent-tools/api-docs/problems.js +11 -1
- package/dist/agent-tools/api-docs/render-openapi.js +2 -0
- package/dist/agent-tools/api-docs/resolve-config.d.ts +9 -0
- package/dist/agent-tools/api-docs/resolve-config.js +11 -0
- package/dist/agent-tools/api-docs/scope-slug-collisions.d.ts +4 -0
- package/dist/agent-tools/api-docs/scope-slug-collisions.js +10 -0
- package/dist/agent-tools/api-docs/translation-gaps.d.ts +4 -0
- package/dist/agent-tools/api-docs/translation-gaps.js +29 -0
- package/dist/agent-tools/api-docs/webhook-example-problems.d.ts +6 -0
- package/dist/agent-tools/api-docs/webhook-example-problems.js +25 -0
- package/dist/agent-tools/index.d.ts +1 -1
- package/dist/agent-tools/index.js +1 -1
- package/dist/agent-tools/labels.d.ts +3 -2
- package/dist/agent-tools/labels.js +21 -4
- package/dist/agent-tools/tool-catalog.d.ts +5 -5
- package/dist/agent-tools/tool-catalog.js +12 -10
- package/dist/agent-tools/tool-dispatch.js +11 -1
- package/dist/agent-tools/types.d.ts +4 -0
- package/dist/audit/event-classification.js +6 -0
- package/dist/audit/web/i18n.js +1 -0
- package/dist/auth-email-password/errors.js +0 -13
- package/dist/auth-email-password/handlers/invite-signup-complete.write.js +101 -84
- package/dist/auth-email-password/handlers/login-options.query.js +1 -1
- package/dist/auth-email-password/handlers/request-account-unlock.write.js +1 -1
- package/dist/auth-email-password/handlers/request-email-verification.write.js +0 -1
- package/dist/auth-email-password/handlers/request-password-reset.write.js +0 -1
- package/dist/auth-email-password/handlers/self-registration-status.query.js +1 -1
- package/dist/auth-email-password/reset-token.js +0 -2
- package/dist/auth-email-password/seeding.js +34 -8
- package/dist/auth-email-password/unlock-token.js +0 -2
- package/dist/auth-email-password/verification-token.js +0 -2
- package/dist/auth-email-password/web/auth-form-primitives.js +2 -2
- package/dist/auth-email-password/web/auth-gate.js +2 -2
- package/dist/auth-email-password/web/auth-redirect.d.ts +1 -0
- package/dist/auth-email-password/web/auth-redirect.js +4 -0
- package/dist/auth-email-password/web/forgot-password-screen.js +1 -5
- package/dist/auth-email-password/web/invite-accept-screen.js +1 -1
- package/dist/auth-email-password/web/return-path.d.ts +2 -1
- package/dist/auth-email-password/web/return-path.js +2 -1
- package/dist/auth-email-password/web/session.js +11 -12
- package/dist/auth-email-password/web/signup-screen.js +1 -5
- package/dist/auth-email-password/web/static-account.js +6 -2
- package/dist/auth-email-password/web/token-confirm-screen.js +4 -5
- package/dist/auth-mfa/web/mfa-code-or-recovery-field.d.ts +6 -1
- package/dist/auth-mfa/web/mfa-code-or-recovery-field.js +4 -2
- package/dist/auth-mfa/web/mfa-disable-dialog.js +1 -1
- package/dist/auth-mfa/web/mfa-regenerate-recovery-dialog.js +1 -1
- package/dist/auth-mfa/web/mfa-setup-preauth-screen.js +1 -1
- package/dist/auth-mfa/web/mfa-verify-screen.js +7 -11
- package/dist/auth-mfa-user-data/index.js +5 -6
- package/dist/billing-foundation/aggregate-id.js +0 -4
- package/dist/billing-foundation/checkout-core.js +8 -1
- package/dist/billing-foundation/checkout-ledger.d.ts +15 -0
- package/dist/billing-foundation/checkout-ledger.js +32 -0
- package/dist/billing-foundation/consumer-protection/consent-gate.d.ts +1 -1
- package/dist/billing-foundation/consumer-protection/consent-gate.js +2 -2
- package/dist/billing-foundation/consumer-protection/consent-text.d.ts +6 -2
- package/dist/billing-foundation/consumer-protection/consent-text.js +29 -3
- package/dist/billing-foundation/consumer-protection/termination-open-cancels.d.ts +2 -1
- package/dist/billing-foundation/consumer-protection/termination-open-cancels.js +5 -1
- package/dist/billing-foundation/consumer-protection/termination-provider-timeout.d.ts +2 -0
- package/dist/billing-foundation/consumer-protection/termination-provider-timeout.js +17 -0
- package/dist/billing-foundation/consumer-protection/termination-record.js +5 -4
- package/dist/billing-foundation/consumer-protection/termination-revoke.js +1 -1
- package/dist/billing-foundation/events.d.ts +22 -0
- package/dist/billing-foundation/events.js +38 -10
- package/dist/billing-foundation/feature.js +12 -1
- package/dist/billing-foundation/handlers/billing-plans.query.js +25 -15
- package/dist/billing-foundation/handlers/create-checkout-session.write.js +1 -1
- package/dist/billing-foundation/handlers/process-event.write.d.ts +2 -2
- package/dist/billing-foundation/handlers/process-event.write.js +94 -12
- package/dist/billing-foundation/handlers/process-payment-event.write.d.ts +1 -2
- package/dist/billing-foundation/handlers/process-payment-event.write.js +29 -9
- package/dist/billing-foundation/handlers/record-checkout-opened.write.d.ts +2 -0
- package/dist/billing-foundation/handlers/record-checkout-opened.write.js +22 -0
- package/dist/billing-foundation/handlers/start-plan-checkout.write.js +1 -1
- package/dist/billing-foundation/handlers/switch-plan.write.js +10 -4
- package/dist/billing-foundation/i18n.js +3 -0
- package/dist/billing-foundation/pending-plan-switch.d.ts +12 -0
- package/dist/billing-foundation/pending-plan-switch.js +57 -0
- package/dist/billing-foundation/scrub-raw-payload-headers.d.ts +4 -0
- package/dist/billing-foundation/scrub-raw-payload-headers.js +33 -0
- package/dist/billing-foundation/types.d.ts +40 -24
- package/dist/billing-foundation/validate-options.js +14 -0
- package/dist/billing-foundation/web/billing-plans-panel.js +8 -3
- package/dist/billing-foundation/web/cancel-contract-dialog.js +1 -1
- package/dist/billing-foundation/web/checkout-consent-dialog.js +1 -1
- package/dist/billing-foundation/web/constants.d.ts +3 -0
- package/dist/billing-foundation/web/constants.js +5 -2
- package/dist/billing-foundation/web/plan-switch-confirm-dialog.js +1 -1
- package/dist/billing-foundation/webhook-handler.js +53 -11
- package/dist/cap-counter/aggregate-id.js +0 -2
- package/dist/cap-counter/stock-cap-guard.d.ts +1 -0
- package/dist/cap-counter/stock-cap-guard.js +18 -4
- package/dist/cap-overview/handlers/tenant-caps-list.query.js +18 -4
- package/dist/cap-overview/i18n.js +1 -0
- package/dist/cap-overview/index.d.ts +1 -1
- package/dist/cap-overview/types.d.ts +4 -0
- package/dist/cap-overview/web/cap-cards-panel.js +6 -2
- package/dist/cap-overview/web/cap-usage-bar.js +6 -1
- package/dist/cap-overview/web/usage-math.d.ts +1 -0
- package/dist/cap-overview/web/usage-math.js +4 -0
- package/dist/channel-in-app/handlers/read-state-by-keys.query.js +2 -2
- package/dist/channel-whatsapp/aggregate-id.d.ts +8 -0
- package/dist/channel-whatsapp/aggregate-id.js +18 -0
- package/dist/channel-whatsapp/constants.d.ts +25 -0
- package/dist/channel-whatsapp/constants.js +36 -0
- package/dist/channel-whatsapp/events.d.ts +87 -0
- package/dist/channel-whatsapp/events.js +70 -0
- package/dist/channel-whatsapp/feature.d.ts +3 -0
- package/dist/channel-whatsapp/feature.js +56 -0
- package/dist/channel-whatsapp/graph-client.d.ts +85 -0
- package/dist/channel-whatsapp/graph-client.js +272 -0
- package/dist/channel-whatsapp/in-memory-meta.d.ts +83 -0
- package/dist/channel-whatsapp/in-memory-meta.js +181 -0
- package/dist/channel-whatsapp/inbound-handlers.d.ts +39 -0
- package/dist/channel-whatsapp/inbound-handlers.js +127 -0
- package/dist/channel-whatsapp/index.d.ts +10 -0
- package/dist/channel-whatsapp/index.js +10 -0
- package/dist/channel-whatsapp/meta-signature.d.ts +5 -0
- package/dist/channel-whatsapp/meta-signature.js +19 -0
- package/dist/channel-whatsapp/options.d.ts +32 -0
- package/dist/channel-whatsapp/options.js +83 -0
- package/dist/channel-whatsapp/pii.d.ts +32 -0
- package/dist/channel-whatsapp/pii.js +61 -0
- package/dist/channel-whatsapp/webhook-normalize.d.ts +7 -0
- package/dist/channel-whatsapp/webhook-normalize.js +185 -0
- package/dist/channel-whatsapp/webhook-routes.d.ts +10 -0
- package/dist/channel-whatsapp/webhook-routes.js +118 -0
- package/dist/compliance-profiles/handlers/sub-processors.query.js +1 -1
- package/dist/config/handlers/set.write.js +7 -0
- package/dist/config/handlers/values.query.js +8 -1
- package/dist/config/index.d.ts +1 -1
- package/dist/config/index.js +1 -1
- package/dist/config/read-redaction.d.ts +1 -0
- package/dist/config/read-redaction.js +5 -2
- package/dist/config/table.js +1 -0
- package/dist/config/write-helpers.js +3 -2
- package/dist/crypto-shredding/constants.d.ts +1 -0
- package/dist/crypto-shredding/constants.js +1 -0
- package/dist/crypto-shredding/handlers/forget-subject.write.js +34 -13
- package/dist/crypto-shredding/index.d.ts +1 -0
- package/dist/crypto-shredding/index.js +1 -0
- package/dist/crypto-shredding/subject-forget-after-delete-hook.d.ts +12 -0
- package/dist/crypto-shredding/subject-forget-after-delete-hook.js +38 -0
- package/dist/custom-fields/aggregate-id.js +0 -1
- package/dist/custom-fields/entity.js +1 -0
- package/dist/custom-fields/wire-for-entity.js +0 -1
- package/dist/data-retention/erase-notes-of-deleted-row.d.ts +9 -0
- package/dist/data-retention/erase-notes-of-deleted-row.js +15 -0
- package/dist/data-retention/feature.js +4 -7
- package/dist/data-retention/run-retention-cleanup.d.ts +1 -0
- package/dist/data-retention/run-retention-cleanup.js +39 -19
- package/dist/data-retention/tenant-destruction-hold.js +7 -0
- package/dist/delivery/attempt-log-factory.d.ts +3 -0
- package/dist/delivery/attempt-log-factory.js +5 -0
- package/dist/delivery/attempt-log.d.ts +2 -2
- package/dist/delivery/channel-context.d.ts +1 -1
- package/dist/delivery/channel-context.js +5 -2
- package/dist/delivery/db/queries/preferences.js +0 -1
- package/dist/delivery/delivery-service.js +3 -0
- package/dist/delivery/feature.d.ts +1 -4
- package/dist/delivery/feature.js +3 -1
- package/dist/delivery/handlers/attempts-by-keys.query.d.ts +1 -1
- package/dist/delivery/handlers/opted-in-user-ids.query.d.ts +7 -0
- package/dist/delivery/handlers/opted-in-user-ids.query.js +41 -0
- package/dist/delivery/handlers/preferences.query.js +2 -20
- package/dist/delivery/handlers/resubscribe-user.write.d.ts +2 -2
- package/dist/delivery/handlers/resubscribe-user.write.js +2 -24
- package/dist/delivery/handlers/unsubscribe-page-chrome.query.js +2 -0
- package/dist/delivery/handlers/unsubscribe-user.write.d.ts +2 -2
- package/dist/delivery/handlers/unsubscribe-user.write.js +2 -26
- package/dist/delivery/index.d.ts +3 -1
- package/dist/delivery/index.js +1 -0
- package/dist/delivery/options.d.ts +4 -0
- package/dist/delivery/options.js +1 -0
- package/dist/delivery/preference-rows.d.ts +9 -0
- package/dist/delivery/preference-rows.js +22 -0
- package/dist/delivery/set-preference-enabled.d.ts +17 -0
- package/dist/delivery/set-preference-enabled.js +26 -0
- package/dist/delivery/tables.d.ts +2 -2
- package/dist/delivery/testing.d.ts +1 -1
- package/dist/delivery/testing.js +3 -1
- package/dist/delivery/types.d.ts +1 -0
- package/dist/delivery/unsubscribe-page.js +5 -1
- package/dist/delivery/upsert-preference.js +0 -1
- package/dist/delivery/web/public-names.d.ts +1 -0
- package/dist/delivery/web/public-names.js +1 -0
- package/dist/derivatives-sharp/render.js +9 -9
- package/dist/document-ingest-foundation/aggregate-id.js +0 -1
- package/dist/document-ingest-foundation/append-missing-extract-event.d.ts +0 -1
- package/dist/document-ingest-foundation/append-missing-extract-event.js +32 -21
- package/dist/document-ingest-foundation/report-ingest-progress.d.ts +1 -1
- package/dist/document-ingest-foundation/report-ingest-progress.js +29 -13
- package/dist/documents/aggregate-id.js +0 -2
- package/dist/documents/constants.d.ts +6 -0
- package/dist/documents/constants.js +8 -2
- package/dist/documents/ensure-link.d.ts +5 -8
- package/dist/documents/ensure-link.js +4 -2
- package/dist/documents/feature.d.ts +3 -1
- package/dist/documents/feature.js +24 -5
- package/dist/documents/handlers/import.write.js +2 -2
- package/dist/documents/queries/expiry-overview.query.js +2 -1
- package/dist/documents/queries/for-record.query.js +3 -4
- package/dist/documents/queries/list-page.js +11 -3
- package/dist/documents/queries/overview.query.js +2 -2
- package/dist/documents/screens.js +3 -3
- package/dist/documents/tab.js +1 -1
- package/dist/feature-toggles/toggle-sync-signal.d.ts +2 -2
- package/dist/feature-toggles/toggle-sync-signal.js +3 -2
- package/dist/file-derivatives/handlers/public-variant-by-file-ref.query.js +1 -1
- package/dist/file-derivatives/handlers/public-variant.query.js +1 -1
- package/dist/file-foundation/probe.js +9 -3
- package/dist/file-foundation/read-file-ref-content.js +23 -11
- package/dist/file-provider-inmemory/feature.js +1 -1
- package/dist/file-provider-s3/env-feature.js +1 -1
- package/dist/file-provider-s3/env-named-feature.js +1 -1
- package/dist/file-provider-s3/env-schema.d.ts +10 -1
- package/dist/file-provider-s3/env-schema.js +20 -7
- package/dist/file-provider-s3/feature.js +1 -1
- package/dist/file-provider-s3/index.d.ts +1 -1
- package/dist/file-provider-s3/index.js +1 -1
- package/dist/file-provider-s3/lib/env-helper.d.ts +3 -2
- package/dist/file-provider-s3/lib/env-helper.js +13 -12
- package/dist/file-provider-s3/lib/s3-provider.js +10 -2
- package/dist/folders/aggregate-id.js +0 -1
- package/dist/folders/web/folder-manager.js +1 -1
- package/dist/folders-user-data/index.js +12 -14
- package/dist/helpdesk/entity.js +4 -1
- package/dist/helpdesk/feature.js +36 -0
- package/dist/helpdesk/handlers/access.d.ts +0 -1
- package/dist/helpdesk/handlers/access.js +0 -3
- package/dist/helpdesk/handlers/attempts.js +7 -13
- package/dist/helpdesk/handlers/challenge.query.js +1 -2
- package/dist/helpdesk/handlers/reply.write.js +4 -5
- package/dist/helpdesk/handlers/report.write.js +3 -7
- package/dist/helpdesk/handlers/submit.write.js +4 -9
- package/dist/helpdesk/index.d.ts +1 -1
- package/dist/helpdesk/index.js +1 -1
- package/dist/helpdesk/legacy-contact-config.d.ts +3 -0
- package/dist/helpdesk/legacy-contact-config.js +57 -0
- package/dist/helpdesk/legacy-contact-erasure.d.ts +9 -0
- package/dist/helpdesk/legacy-contact-erasure.js +19 -0
- package/dist/helpdesk/legacy-contact-retention.d.ts +2 -0
- package/dist/helpdesk/legacy-contact-retention.js +53 -0
- package/dist/helpdesk/legacy-contact-streams.d.ts +20 -0
- package/dist/helpdesk/legacy-contact-streams.js +121 -0
- package/dist/helpdesk/legacy-contact-user-data.d.ts +5 -0
- package/dist/helpdesk/legacy-contact-user-data.js +62 -0
- package/dist/helpdesk/lib.d.ts +7 -1
- package/dist/helpdesk/lib.js +29 -29
- package/dist/helpdesk/user-data-hooks.d.ts +10 -1
- package/dist/helpdesk/user-data-hooks.js +47 -36
- package/dist/helpdesk/web/constants.d.ts +0 -1
- package/dist/helpdesk/web/constants.js +0 -1
- package/dist/inbound-mail-foundation/account-health.js +1 -1
- package/dist/inbound-mail-foundation/account-poll.js +1 -1
- package/dist/inbound-mail-foundation/aggregate-id.js +0 -2
- package/dist/inbound-mail-foundation/constants.d.ts +6 -0
- package/dist/inbound-mail-foundation/constants.js +6 -0
- package/dist/inbound-mail-foundation/content-refetch.d.ts +1 -0
- package/dist/inbound-mail-foundation/content-refetch.js +15 -1
- package/dist/inbound-mail-foundation/entities.js +57 -15
- package/dist/inbound-mail-foundation/events.js +15 -16
- package/dist/inbound-mail-foundation/feature.js +3 -1
- package/dist/inbound-mail-foundation/handlers/account-address.d.ts +2 -2
- package/dist/inbound-mail-foundation/handlers/account-address.js +10 -2
- package/dist/inbound-mail-foundation/handlers/attach-message-content.write.js +8 -3
- package/dist/inbound-mail-foundation/handlers/connect-account.write.js +12 -7
- package/dist/inbound-mail-foundation/handlers/forget-message.write.d.ts +7 -0
- package/dist/inbound-mail-foundation/handlers/forget-message.write.js +54 -0
- package/dist/inbound-mail-foundation/i18n.js +3 -0
- package/dist/inbound-mail-foundation/index.d.ts +1 -0
- package/dist/inbound-mail-foundation/index.js +1 -0
- package/dist/inbound-mail-foundation/oauth-access-token.js +1 -1
- package/dist/inbound-mail-foundation/outbound-mail.d.ts +2 -0
- package/dist/inbound-mail-foundation/personal-address.d.ts +1 -0
- package/dist/inbound-mail-foundation/personal-address.js +16 -0
- package/dist/inbound-mail-foundation/purge-messages.d.ts +20 -0
- package/dist/inbound-mail-foundation/purge-messages.js +33 -0
- package/dist/inbound-mail-foundation/quarantine.d.ts +3 -2
- package/dist/inbound-mail-foundation/quarantine.js +9 -5
- package/dist/inbound-mail-foundation/retention-job.js +1 -5
- package/dist/inbound-mail-foundation/retention-sweep.js +17 -28
- package/dist/inbound-mail-foundation/send-from-account.js +9 -1
- package/dist/inbound-mail-foundation/supervisor-ingest.js +4 -1
- package/dist/inbound-mail-foundation/sync-account-now.js +1 -1
- package/dist/inbound-mail-foundation/tenant-destroy-hook.js +3 -6
- package/dist/inbound-mail-foundation/watch-supervisor.js +1 -1
- package/dist/inbound-provider-imap/byte-budget.d.ts +14 -0
- package/dist/inbound-provider-imap/byte-budget.js +53 -0
- package/dist/inbound-provider-imap/connect-mailbox.d.ts +2 -4
- package/dist/inbound-provider-imap/connect-mailbox.js +8 -3
- package/dist/inbound-provider-imap/connect-my-mailbox.d.ts +1 -1
- package/dist/inbound-provider-imap/connect-my-mailbox.js +15 -4
- package/dist/inbound-provider-imap/connect-target-rate-limit.d.ts +3 -0
- package/dist/inbound-provider-imap/connect-target-rate-limit.js +37 -0
- package/dist/inbound-provider-imap/download-batch.d.ts +10 -0
- package/dist/inbound-provider-imap/download-batch.js +21 -6
- package/dist/inbound-provider-imap/feature.js +7 -4
- package/dist/inbound-provider-imap/fetch-content.js +35 -30
- package/dist/inbound-provider-imap/i18n.js +2 -2
- package/dist/inbound-provider-imap/parse-message.d.ts +7 -0
- package/dist/inbound-provider-imap/parse-message.js +8 -0
- package/dist/inbound-provider-imap/reconnect-mailbox.js +5 -4
- package/dist/inbound-provider-imap/send-mail.d.ts +2 -0
- package/dist/inbound-provider-imap/send-mail.js +32 -6
- package/dist/inbound-provider-imap/smtp-client.d.ts +9 -2
- package/dist/inbound-provider-imap/smtp-client.js +15 -3
- package/dist/inbound-provider-imap/watch-mailbox.js +3 -24
- package/dist/inbound-provider-inmemory/feature.js +1 -1
- package/dist/jobs/events.d.ts +13 -0
- package/dist/jobs/events.js +8 -0
- package/dist/jobs/feature.js +2 -0
- package/dist/jobs/handlers/consumer.write.js +31 -20
- package/dist/jobs/web/constants.d.ts +3 -0
- package/dist/jobs/web/constants.js +3 -0
- package/dist/mail-transport-inmemory/feature.js +1 -1
- package/dist/mail-transport-smtp/feature.js +3 -2
- package/dist/managed-pages/handlers/branding.query.js +1 -1
- package/dist/managed-pages/handlers/by-slug.query.js +1 -1
- package/dist/managed-pages/handlers/by-tenant-published.query.js +1 -1
- package/dist/managed-pages/render-page-body.d.ts +2 -0
- package/dist/managed-pages/render-page-body.js +12 -8
- package/dist/managed-pages/screens/page-screens.d.ts +3 -2
- package/dist/managed-pages/screens/page-screens.js +14 -33
- package/dist/managed-pages/table.js +1 -0
- package/dist/managed-pages/web/client-plugin.js +8 -6
- package/dist/managed-pages/web/constants.d.ts +5 -1
- package/dist/managed-pages/web/constants.js +6 -1
- package/dist/managed-pages/web/i18n.js +11 -3
- package/dist/managed-pages/web/markdown-to-document.js +1 -1
- package/dist/managed-pages/web/page-edit-draft.d.ts +32 -0
- package/dist/managed-pages/web/page-edit-draft.js +76 -0
- package/dist/managed-pages/web/page-edit-screen.d.ts +2 -0
- package/dist/managed-pages/web/page-edit-screen.js +106 -0
- package/dist/managed-pages/web/page-settings-rail.d.ts +11 -0
- package/dist/managed-pages/web/page-settings-rail.js +14 -0
- package/dist/notes-history-user-data/index.js +8 -14
- package/dist/personal-access-tokens/boot-rules.d.ts +5 -0
- package/dist/personal-access-tokens/boot-rules.js +5 -0
- package/dist/personal-access-tokens/handlers/create.write.js +0 -1
- package/dist/personal-access-tokens/scope-events-check.js +26 -6
- package/dist/presence/handlers/list.query.js +18 -8
- package/dist/presence/room.d.ts +2 -0
- package/dist/presence/room.js +8 -5
- package/dist/presence/store.d.ts +2 -0
- package/dist/presence/store.js +62 -26
- package/dist/readiness/handlers/latest-summary.query.js +10 -6
- package/dist/readiness/handlers/run-probes.write.js +24 -4
- package/dist/readiness/handlers/run-tone.js +3 -2
- package/dist/readiness/handlers/status.query.js +11 -3
- package/dist/readiness/probe-context.js +7 -10
- package/dist/readiness/screens.js +4 -4
- package/dist/readiness/visible-results.d.ts +1 -1
- package/dist/readiness/visible-results.js +5 -2
- package/dist/renderer-foundation/api.js +6 -12
- package/dist/renderer-foundation/types.d.ts +2 -2
- package/dist/secrets/db/queries/read.d.ts +2 -1
- package/dist/secrets/db/queries/read.js +10 -1
- package/dist/secrets/handlers/list.query.js +4 -2
- package/dist/secrets/secret-scope.d.ts +0 -1
- package/dist/secrets/secret-scope.js +2 -2
- package/dist/secrets/secrets-context.js +4 -4
- package/dist/secrets/table.d.ts +1 -1
- package/dist/secrets/write-gate.js +4 -2
- package/dist/seo/handlers/seo-config.query.js +1 -1
- package/dist/shared/acknowledged-system-db.d.ts +5 -0
- package/dist/shared/acknowledged-system-db.js +9 -0
- package/dist/shared/assert-billing-live.d.ts +1 -0
- package/dist/shared/assert-billing-live.js +5 -2
- package/dist/shared/index.d.ts +6 -2
- package/dist/shared/index.js +6 -2
- package/dist/shared/parent-visibility.d.ts +1 -0
- package/dist/shared/parent-visibility.js +16 -1
- package/dist/shared/password-hashing.js +0 -1
- package/dist/shared/price-env-shape.js +1 -1
- package/dist/shared/register-user-data-hooks.d.ts +11 -0
- package/dist/shared/register-user-data-hooks.js +11 -0
- package/dist/shared/require-bootstrap-extension.d.ts +9 -0
- package/dist/shared/require-bootstrap-extension.js +16 -0
- package/dist/shared/send-best-effort.d.ts +2 -0
- package/dist/shared/send-best-effort.js +14 -0
- package/dist/shared/stream-tenant-backfill.d.ts +1 -0
- package/dist/shared/stream-tenant-backfill.js +17 -1
- package/dist/shared/stream-tenant-derived-state.d.ts +5 -1
- package/dist/shared/stream-tenant-derived-state.js +19 -2
- package/dist/step-dispatcher/constants.d.ts +4 -0
- package/dist/step-dispatcher/constants.js +11 -0
- package/dist/step-dispatcher/deliver-dispatch-request.d.ts +1 -0
- package/dist/step-dispatcher/deliver-dispatch-request.js +38 -2
- package/dist/step-dispatcher/feature.js +20 -2
- package/dist/step-dispatcher/mail-runner.js +0 -1
- package/dist/step-dispatcher/sweep-abandoned.d.ts +10 -0
- package/dist/step-dispatcher/sweep-abandoned.js +43 -0
- package/dist/subscription-mollie/plugin-methods.d.ts +1 -0
- package/dist/subscription-mollie/plugin-methods.js +1 -2
- package/dist/subscription-mollie/verify-webhook.js +5 -5
- package/dist/subscription-paddle/backfill-checkout-ledger.d.ts +9 -0
- package/dist/subscription-paddle/backfill-checkout-ledger.js +110 -0
- package/dist/subscription-paddle/checkout-config.query.js +1 -1
- package/dist/subscription-paddle/checkout-methods.js +2 -8
- package/dist/subscription-paddle/constants.d.ts +0 -1
- package/dist/subscription-paddle/constants.js +1 -2
- package/dist/subscription-paddle/feature.d.ts +0 -4
- package/dist/subscription-paddle/feature.js +21 -20
- package/dist/subscription-paddle/ledger-backfill-marker.d.ts +17 -0
- package/dist/subscription-paddle/ledger-backfill-marker.js +53 -0
- package/dist/subscription-paddle/plan-switch-methods.js +2 -8
- package/dist/subscription-paddle/redeliver-legacy-checkout.d.ts +11 -0
- package/dist/subscription-paddle/redeliver-legacy-checkout.js +26 -0
- package/dist/subscription-paddle/runtime.d.ts +3 -5
- package/dist/subscription-paddle/runtime.js +4 -7
- package/dist/subscription-paddle/subscription-state.d.ts +1 -0
- package/dist/subscription-paddle/subscription-state.js +1 -0
- package/dist/subscription-paddle/webhook-events.d.ts +4 -0
- package/dist/subscription-paddle/webhook-events.js +40 -22
- package/dist/subscription-stripe/feature.d.ts +4 -0
- package/dist/subscription-stripe/feature.js +1 -0
- package/dist/subscription-stripe/plugin-methods.d.ts +1 -0
- package/dist/subscription-stripe/plugin-methods.js +2 -5
- package/dist/subscription-stripe/runtime.d.ts +2 -1
- package/dist/subscription-stripe/runtime.js +5 -7
- package/dist/subscription-stripe/verify-webhook.js +21 -6
- package/dist/tags/aggregate-id.js +0 -1
- package/dist/tags/web/tag-chip.js +0 -1
- package/dist/tags/web/tag-manager.js +3 -1
- package/dist/template-resolver/api.js +6 -12
- package/dist/template-resolver/document-sanitizer.d.ts +1 -1
- package/dist/template-resolver/document-sanitizer.js +18 -0
- package/dist/template-resolver/feature.d.ts +1 -0
- package/dist/template-resolver/feature.js +2 -0
- package/dist/template-resolver/handlers/body-preview.query.d.ts +11 -0
- package/dist/template-resolver/handlers/body-preview.query.js +41 -0
- package/dist/template-resolver/handlers/by-slug.query.js +1 -1
- package/dist/template-resolver/handlers/by-tenant.query.js +1 -1
- package/dist/template-resolver/handlers/collection-shared.js +5 -8
- package/dist/template-resolver/handlers/overview.query.d.ts +1 -0
- package/dist/template-resolver/handlers/overview.query.js +2 -1
- package/dist/template-resolver/handlers/send-test.write.js +27 -8
- package/dist/template-resolver/linked-resources.js +2 -6
- package/dist/template-resolver/seeding.js +67 -1
- package/dist/template-resolver/table.js +1 -0
- package/dist/template-resolver/template-draft.js +2 -1
- package/dist/template-resolver/template-preview.js +12 -3
- package/dist/template-resolver/testing.js +0 -2
- package/dist/template-resolver/web/client-plugin.js +3 -0
- package/dist/template-resolver/web/collection-entry-create-form.js +19 -9
- package/dist/template-resolver/web/constants.d.ts +2 -0
- package/dist/template-resolver/web/constants.js +2 -0
- package/dist/template-resolver/web/content-tree-provider.js +0 -1
- package/dist/template-resolver/web/content-workbench.d.ts +22 -0
- package/dist/template-resolver/web/content-workbench.js +32 -0
- package/dist/template-resolver/web/document-insert-model.d.ts +2 -4
- package/dist/template-resolver/web/document-insert-model.js +1 -2
- package/dist/template-resolver/web/document-link-policy.d.ts +3 -0
- package/dist/template-resolver/web/document-link-policy.js +53 -0
- package/dist/template-resolver/web/document-schema.d.ts +2 -4
- package/dist/template-resolver/web/document-schema.js +2 -53
- package/dist/template-resolver/web/document-tiptap-context.d.ts +2 -5
- package/dist/template-resolver/web/document-tiptap-context.js +2 -2
- package/dist/template-resolver/web/document-tiptap-editor.js +2 -2
- package/dist/template-resolver/web/document-tiptap-helpers.d.ts +7 -4
- package/dist/template-resolver/web/document-tiptap-toolbar-groups.js +3 -3
- package/dist/template-resolver/web/editor-handle.js +1 -0
- package/dist/template-resolver/web/fill-document-variables.d.ts +1 -0
- package/dist/template-resolver/web/fill-document-variables.js +22 -0
- package/dist/template-resolver/web/i18n.js +10 -0
- package/dist/template-resolver/web/index.d.ts +3 -0
- package/dist/template-resolver/web/index.js +2 -0
- package/dist/template-resolver/web/preview-targets.d.ts +5 -0
- package/dist/template-resolver/web/preview-targets.js +21 -0
- package/dist/template-resolver/web/qualified-names.d.ts +1 -0
- package/dist/template-resolver/web/qualified-names.js +1 -0
- package/dist/template-resolver/web/snippet-preview-renderer.d.ts +2 -0
- package/dist/template-resolver/web/snippet-preview-renderer.js +15 -0
- package/dist/template-resolver/web/string-values.d.ts +1 -0
- package/dist/template-resolver/web/string-values.js +8 -0
- package/dist/template-resolver/web/text-block-editor.js +18 -11
- package/dist/template-resolver/web/use-collection-entry-create.d.ts +1 -0
- package/dist/template-resolver/web/use-collection-entry-create.js +6 -0
- package/dist/template-resolver/web/use-document-tiptap-model.d.ts +2 -6
- package/dist/template-resolver/web/use-text-block-editor.d.ts +3 -0
- package/dist/template-resolver/web/use-text-block-editor.js +26 -5
- package/dist/template-resolver/web/web-preview-renderer.d.ts +12 -0
- package/dist/template-resolver/web/web-preview-renderer.js +41 -0
- package/dist/template-resolver-user-data/index.js +11 -10
- package/dist/tenant/handlers/create.write.js +3 -7
- package/dist/tenant/handlers/list.query.js +3 -8
- package/dist/tenant/handlers/member-directory.query.js +10 -5
- package/dist/tenant/handlers/toggle-enabled.write.js +1 -1
- package/dist/tenant/invited-membership.js +9 -1
- package/dist/tenant/seeding.d.ts +3 -0
- package/dist/tenant/seeding.js +3 -1
- package/dist/tenant/stream-tenant-backfill.js +5 -1
- package/dist/tenant/testing.js +1 -1
- package/dist/tenant-inactivity/check-inactive-tenants.js +5 -5
- package/dist/tenant-inactivity/constants.js +1 -2
- package/dist/tenant-inactivity/handlers/keep-account.write.js +1 -2
- package/dist/tenant-inactivity/state-store.d.ts +1 -0
- package/dist/tenant-inactivity/state-store.js +9 -1
- package/dist/tenant-lifecycle/constants.d.ts +1 -0
- package/dist/tenant-lifecycle/constants.js +3 -0
- package/dist/tenant-lifecycle/run-tenant-destroy.js +38 -5
- package/dist/tenant-lifecycle/stages.js +14 -2
- package/dist/tier-engine/aggregate-id.js +0 -1
- package/dist/tier-engine/feature.js +9 -2
- package/dist/user/db/queries/stream-tenant-backfill.js +2 -1
- package/dist/user/handlers/me.query.js +4 -1
- package/dist/user/index.d.ts +1 -0
- package/dist/user/index.js +1 -0
- package/dist/user/resolve-verified-user-email.d.ts +2 -0
- package/dist/user/resolve-verified-user-email.js +14 -0
- package/dist/user-data-rights/db/queries/export-jobs.js +0 -1
- package/dist/user-data-rights/handlers/confirm-deletion-by-token.write.js +1 -1
- package/dist/user-data-rights/handlers/download-by-token.query.js +1 -1
- package/dist/user-data-rights/handlers/request-deletion-by-email.write.js +1 -1
- package/dist/user-data-rights/run-export-jobs.js +0 -2
- package/dist/user-data-rights/run-forget-cleanup.js +2 -2
- package/dist/user-data-rights/schema/download-attempt.js +3 -2
- package/dist/user-data-rights/web/confirm-deletion-screen.js +2 -2
- package/dist/user-data-rights/web/privacy-center-screen.js +1 -1
- package/dist/user-data-rights/web/request-deletion-screen.js +2 -2
- package/dist/user-data-rights-defaults/hooks/api-token.userdata-hook.js +5 -6
- package/dist/user-data-rights-defaults/hooks/hard-delete-own-rows-hook.d.ts +7 -0
- package/dist/user-data-rights-defaults/hooks/hard-delete-own-rows-hook.js +11 -0
- package/dist/user-data-rights-defaults/hooks/in-app-message.userdata-hook.js +5 -6
- package/dist/user-data-rights-defaults/hooks/job-run.userdata-hook.js +2 -1
- package/dist/user-data-rights-defaults/hooks/user-session.userdata-hook.js +5 -6
- package/dist/user-profile/handlers/change-email.write.js +0 -1
- package/dist/waitlist/handlers/submit.write.js +5 -18
- package/dist/waitlist/lib.js +2 -7
- package/dist/waitlist/user-data-hooks.js +6 -20
- package/dist/workflow-runner/aggregate-id.js +0 -1
- package/dist/workflow-runner/event-trigger.js +6 -2
- package/dist/workflow-runner/feature.js +1 -5
- package/dist/workflow-runner/handlers/resume-run.write.js +4 -3
- package/dist/workflow-runner/runner.d.ts +1 -0
- package/package.json +35 -11
- package/src/admin-shell/changes.json +6 -0
- package/src/agent-tools/changes.json +12 -0
- package/src/auth-email-password/changes.json +18 -0
- package/src/billing-foundation/changes.json +37 -0
- package/src/cap-counter/changes.json +6 -0
- package/src/cap-overview/changes.json +6 -0
- package/src/channel-in-app/changes.json +6 -0
- package/src/channel-whatsapp/changes.json +8 -0
- package/src/config/changes.json +12 -0
- package/src/crypto-shredding/changes.json +18 -0
- package/src/data-retention/changes.json +18 -0
- package/src/delivery/changes.json +6 -0
- package/src/documents/changes.json +18 -0
- package/src/file-provider-s3/changes.json +14 -0
- package/src/files/changes.json +7 -0
- package/src/helpdesk/changes.json +62 -0
- package/src/inbound-mail-foundation/changes.json +48 -0
- package/src/inbound-provider-imap/changes.json +13 -0
- package/src/mail-foundation/changes.json +6 -0
- package/src/managed-pages/changes.json +12 -0
- package/src/presence/changes.json +6 -0
- package/src/readiness/changes.json +25 -0
- package/src/secrets/changes.json +7 -0
- package/src/shared/changes.json +6 -0
- package/src/step-dispatcher/changes.json +12 -0
- package/src/subscription-mollie/changes.json +7 -0
- package/src/subscription-paddle/changes.json +13 -0
- package/src/subscription-stripe/changes.json +7 -0
- package/src/template-resolver/changes.json +36 -0
- package/src/tenant/changes.json +6 -0
- package/src/tenant-lifecycle/changes.json +18 -0
- package/src/tier-engine/changes.json +6 -0
- package/src/user/changes.json +6 -0
- package/src/waitlist/changes.json +6 -0
- package/dist/managed-pages/web/page-body-section.d.ts +0 -3
- package/dist/managed-pages/web/page-body-section.js +0 -40
- package/dist/subscription-paddle/tenant-binding.d.ts +0 -8
- package/dist/subscription-paddle/tenant-binding.js +0 -26
- package/dist/template-resolver/web/content-field.d.ts +0 -9
- package/dist/template-resolver/web/content-field.js +0 -14
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { SubjectId } from "@cosmicdrift/kumiko-framework/crypto";
|
|
2
|
+
import type { HookDefinition } from "@cosmicdrift/kumiko-types/feature-registrar";
|
|
3
|
+
export type SubjectForgetAfterDeleteOptions = {
|
|
4
|
+
readonly target: Extract<HookDefinition, {
|
|
5
|
+
type: "postDelete";
|
|
6
|
+
}>["target"];
|
|
7
|
+
readonly subjectsOf: (deletedId: string) => readonly SubjectId[];
|
|
8
|
+
readonly reason: string;
|
|
9
|
+
};
|
|
10
|
+
export declare function subjectForgetAfterDeleteHook(options: SubjectForgetAfterDeleteOptions): Extract<HookDefinition, {
|
|
11
|
+
type: "postDelete";
|
|
12
|
+
}>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ROLES } from "@cosmicdrift/kumiko-framework/auth";
|
|
2
|
+
import { createSystemUser, parseTenantId } from "@cosmicdrift/kumiko-framework/engine";
|
|
3
|
+
import { InternalError, reraiseAsKumikoError } from "@cosmicdrift/kumiko-framework/errors";
|
|
4
|
+
import { FORGET_SUBJECT_QUALIFIED_NAME } from "./constants.js";
|
|
5
|
+
// A postDelete hook, not a step inside the delete handler: preDelete hooks run after the handler
|
|
6
|
+
// returns, and the key erase cannot be rolled back. Run here, in the delete's own transaction, the
|
|
7
|
+
// erase only happens once every preDelete hook has accepted the delete; a failed forget throws and
|
|
8
|
+
// rolls the delete back. The escalation stays in the tenant of the deleted row's own event.
|
|
9
|
+
// forget-subject is irreversible (assertIrreversibleOperationAllowed), so the consumer's delete
|
|
10
|
+
// handler (the entry handler) must resolve to agent risk "high", otherwise the hook fails.
|
|
11
|
+
export function subjectForgetAfterDeleteHook(options) {
|
|
12
|
+
return {
|
|
13
|
+
type: "postDelete",
|
|
14
|
+
target: options.target,
|
|
15
|
+
phase: "inTransaction",
|
|
16
|
+
escapeHatch: {
|
|
17
|
+
reason: `deleting the row escalates to the system identity to run crypto-shredding:forget-subject (DPO/SystemAdmin-only) for the subjects of the row just deleted in its own tenant: ${options.reason}`,
|
|
18
|
+
grants: ["systemIdentity"],
|
|
19
|
+
},
|
|
20
|
+
handler: async (deleted, ctx) => {
|
|
21
|
+
const tenantId = parseTenantId(deleted.event.tenantId);
|
|
22
|
+
if (tenantId === null) {
|
|
23
|
+
throw new InternalError({
|
|
24
|
+
message: "[crypto-shredding] subjectForgetAfterDeleteHook: deleted row has no tenant",
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
const systemAdmin = createSystemUser(tenantId, [ROLES.SystemAdmin]);
|
|
28
|
+
for (const subject of options.subjectsOf(String(deleted.id))) {
|
|
29
|
+
const forgotten = await ctx.dispatch.writeAs(systemAdmin, FORGET_SUBJECT_QUALIFIED_NAME, {
|
|
30
|
+
subject,
|
|
31
|
+
reason: options.reason,
|
|
32
|
+
});
|
|
33
|
+
if (!forgotten.isSuccess)
|
|
34
|
+
throw reraiseAsKumikoError(forgotten.error);
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
}
|
|
@@ -21,7 +21,6 @@ const FIELD_DEFINITION_NAMESPACE = "f1d3b2c7-4e5a-4b9c-8d1f-2a3b4c5d6e7f";
|
|
|
21
21
|
* define its own `customer.internalNumber` (422 `fieldKey_conflict`). This
|
|
22
22
|
* prevents ambiguity when resolving the field during reads.
|
|
23
23
|
*/
|
|
24
|
-
// @wrapper-known uuid-domain
|
|
25
24
|
export function fieldDefinitionAggregateId(tenantId, entityName, fieldKey) {
|
|
26
25
|
return uuidv5(`${tenantId}|${entityName}|${fieldKey}`, FIELD_DEFINITION_NAMESPACE);
|
|
27
26
|
}
|
|
@@ -31,6 +31,7 @@ import { createBooleanField, createEntity, createNumberField, createTextField, }
|
|
|
31
31
|
// columns and events.
|
|
32
32
|
export const fieldDefinitionEntity = createEntity({
|
|
33
33
|
table: "read_custom_field_definitions",
|
|
34
|
+
systemRowsReadable: true,
|
|
34
35
|
description: "One custom-field definition: the host entity it extends, the field key, its type and required/searchable flags, a display order, and the serialized field builder that carries the type options, default value and labels. Rows owned by the system tenant apply to every tenant; all others belong to the tenant that defined them.",
|
|
35
36
|
// softDelete is required, NOT cosmetic: the aggregate-id is deterministic
|
|
36
37
|
// (uuidv5(tenantId|entityName|fieldKey)), so deleting a definition leaves a
|
|
@@ -14,7 +14,6 @@ import { CUSTOM_FIELDS_EXTENSION, FIELD_DEFINITION_AGGREGATE_TYPE } from "./web/
|
|
|
14
14
|
//
|
|
15
15
|
// `customFields` follows the same contract as regular fields: default `{}` and
|
|
16
16
|
// NOT NULL, like embedded columns.
|
|
17
|
-
// @wrapper-known semantic-alias
|
|
18
17
|
export function customFieldsField() {
|
|
19
18
|
return createJsonbField();
|
|
20
19
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { DbRunner } from "@cosmicdrift/kumiko-framework/db";
|
|
2
|
+
import type { Registry } from "@cosmicdrift/kumiko-framework/engine";
|
|
3
|
+
export declare function eraseNotesOfDeletedRow(args: {
|
|
4
|
+
readonly registry: Registry;
|
|
5
|
+
readonly tx: DbRunner;
|
|
6
|
+
readonly entityName: string;
|
|
7
|
+
readonly rowId: string;
|
|
8
|
+
readonly erasedBy: string;
|
|
9
|
+
}): Promise<void>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { NOTES_HISTORY_FEATURE_NAME } from "../notes-history/index.js";
|
|
2
|
+
import { eraseNoteBodiesReachingSubject } from "../notes-history-user-data/index.js";
|
|
3
|
+
// Note bodies are keyed per note, so a hardDeleted parent's own key never reaches them. The runner
|
|
4
|
+
// is the retention job's unfiltered one: notes of a global parent sit in whichever tenant wrote them.
|
|
5
|
+
export async function eraseNotesOfDeletedRow(args) {
|
|
6
|
+
// skip: without notes-history there are no notes hanging on the row
|
|
7
|
+
if (!args.registry.features.has(NOTES_HISTORY_FEATURE_NAME))
|
|
8
|
+
return;
|
|
9
|
+
await eraseNoteBodiesReachingSubject({
|
|
10
|
+
db: args.tx,
|
|
11
|
+
subject: { kind: "record", entity: args.entityName, id: args.rowId },
|
|
12
|
+
erasedBy: args.erasedBy,
|
|
13
|
+
requestId: `data-retention:hardDelete:${args.entityName}:${args.rowId}`,
|
|
14
|
+
});
|
|
15
|
+
}
|
|
@@ -35,8 +35,8 @@ export function createDataRetentionFeature() {
|
|
|
35
35
|
// Cross-feature API for the forget flow and cleanup job
|
|
36
36
|
r.exposesApi("retention.policyFor");
|
|
37
37
|
r.queryHandler(policyForQuery);
|
|
38
|
-
// Autonomous retention cleanup. perTenant fan-out (one run per
|
|
39
|
-
//
|
|
38
|
+
// Autonomous retention cleanup. perTenant fan-out (one run per active
|
|
39
|
+
// tenant plus the system tenant, like soft-delete-cleanup): runRetentionCleanup's raw
|
|
40
40
|
// query helpers need the unfiltered runner, so the handler declares
|
|
41
41
|
// escapeHatch and reaches for ctx.db.unsafeRaw(). Without this cron,
|
|
42
42
|
// retention rules are configured but never enforced.
|
|
@@ -44,6 +44,7 @@ export function createDataRetentionFeature() {
|
|
|
44
44
|
name: "retention-cleanup",
|
|
45
45
|
trigger: { maintenance: true },
|
|
46
46
|
perTenant: true,
|
|
47
|
+
includeSystemTenant: true,
|
|
47
48
|
concurrency: "skip",
|
|
48
49
|
escapeHatch: {
|
|
49
50
|
reason: "retention cleanup runs raw deletes and preset lookups; every statement filters by this run's tenantId",
|
|
@@ -52,11 +53,7 @@ export function createDataRetentionFeature() {
|
|
|
52
53
|
if (!ctx.registry) {
|
|
53
54
|
throw new Error("retention-cleanup: ctx.registry required (JobContext incomplete)");
|
|
54
55
|
}
|
|
55
|
-
const tenantId = ctx.systemUser
|
|
56
|
-
if (tenantId === undefined) {
|
|
57
|
-
// skip: cron fired without a perTenant fan-out tenant — nothing scoped
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
56
|
+
const tenantId = ctx.systemUser.tenantId;
|
|
60
57
|
const cleanupDb = ctx.db.unsafeRaw(); // @cast-boundary db-operator — jobs never run inside a DbTx
|
|
61
58
|
const tenantPreset = await resolveTenantRetentionPreset({
|
|
62
59
|
db: cleanupDb,
|
|
@@ -47,6 +47,7 @@ export interface RunRetentionCleanupResult {
|
|
|
47
47
|
readonly skipped: readonly RetentionCleanupSkip[];
|
|
48
48
|
}
|
|
49
49
|
export declare function resolveAnonymizeTargets(fields: Readonly<Record<string, unknown>>): Promise<Record<string, unknown> | null>;
|
|
50
|
+
export declare function sameAnonymizedValue(current: unknown, target: unknown): boolean;
|
|
50
51
|
export declare function anonymizeMatchingRows(db: DbRunner, table: Parameters<typeof selectMany>[1], where: WhereObject, batchLimit: number, targets: Record<string, unknown>, op: (id: EntityId, changes: Record<string, unknown>) => Promise<{
|
|
51
52
|
readonly isSuccess: boolean;
|
|
52
53
|
}>): Promise<number>;
|
|
@@ -39,12 +39,13 @@
|
|
|
39
39
|
import { collectPiiSubjectFields, configuredPiiSubjectKms, isPiiCiphertext, isRecordKeyedField, isSelfPiiField, PII_ERASED_SENTINEL, resolveSubjectForField, subjectIdToKey, } from "@cosmicdrift/kumiko-framework/crypto";
|
|
40
40
|
import { createEventStoreExecutor, createTenantDb, nullBlindIndexesForSubject, selectMany, WritePurposes, } from "@cosmicdrift/kumiko-framework/db";
|
|
41
41
|
import { deleteFileRefBytes } from "@cosmicdrift/kumiko-framework/derivatives";
|
|
42
|
-
import { createSystemUser, entityHasAnonymizableSubjectField, } from "@cosmicdrift/kumiko-framework/engine";
|
|
42
|
+
import { createSystemUser, entityHasAnonymizableSubjectField, isUnchangedValue, } from "@cosmicdrift/kumiko-framework/engine";
|
|
43
43
|
import { InternalError } from "@cosmicdrift/kumiko-framework/errors";
|
|
44
44
|
import { fileRefEntity, fileRefsTable, } from "@cosmicdrift/kumiko-framework/files";
|
|
45
45
|
import { createFallbackLogger } from "@cosmicdrift/kumiko-framework/logging";
|
|
46
46
|
import { propertyOf } from "@cosmicdrift/kumiko-types/type-guards";
|
|
47
47
|
import { collectSingleFileHolders, decryptStoredPii, planFileFields, purgeRowFileRefs, runInSubTransaction, } from "../shared/index.js";
|
|
48
|
+
import { eraseNotesOfDeletedRow } from "./erase-notes-of-deleted-row.js";
|
|
48
49
|
import { computeCutoff } from "./keep-for.js";
|
|
49
50
|
import { resolveRetentionPolicyForTenant } from "./resolve-for-tenant.js";
|
|
50
51
|
import { tenantRetentionOverrideTable } from "./schema/tenant-retention-override.js";
|
|
@@ -156,6 +157,13 @@ async function forgetRowAndEraseKeys(args) {
|
|
|
156
157
|
tenantId: args.tenantId,
|
|
157
158
|
row: args.row,
|
|
158
159
|
});
|
|
160
|
+
await eraseNotesOfDeletedRow({
|
|
161
|
+
registry: args.registry,
|
|
162
|
+
tx: sp,
|
|
163
|
+
entityName: args.entityName,
|
|
164
|
+
rowId: String(args.rowId),
|
|
165
|
+
erasedBy: args.systemUser.id,
|
|
166
|
+
});
|
|
159
167
|
return { isSuccess: true };
|
|
160
168
|
});
|
|
161
169
|
}
|
|
@@ -299,11 +307,20 @@ async function rowNeedsAnonymize(row, targets) {
|
|
|
299
307
|
const current = isPiiCiphertext(stored)
|
|
300
308
|
? await decryptStoredPii(stored, field, "retention-anonymize")
|
|
301
309
|
: stored;
|
|
302
|
-
if (current !== PII_ERASED_SENTINEL && current
|
|
310
|
+
if (current !== PII_ERASED_SENTINEL && !sameAnonymizedValue(current, target))
|
|
303
311
|
return true;
|
|
304
312
|
}
|
|
305
313
|
return false;
|
|
306
314
|
}
|
|
315
|
+
// Objects and arrays (JSON fields) are never identical by reference, so they compare by content;
|
|
316
|
+
// jsonb returns keys in its own order, so the comparison must not depend on key order.
|
|
317
|
+
export function sameAnonymizedValue(current, target) {
|
|
318
|
+
if (current === target)
|
|
319
|
+
return true;
|
|
320
|
+
if (typeof target !== "object" || target === null)
|
|
321
|
+
return false;
|
|
322
|
+
return isUnchangedValue(current, target);
|
|
323
|
+
}
|
|
307
324
|
// Anonymize every matching row via the executor (event → rebuild-safe).
|
|
308
325
|
// id-Cursor-paged because the where keeps matching already-anonymized rows;
|
|
309
326
|
// the diff-check keeps the daily re-run event-free. batchLimit bounds the
|
|
@@ -485,23 +502,26 @@ export async function runRetentionCleanup(args) {
|
|
|
485
502
|
// A tenant held in destroyHeld has its expired blockDelete rows removed for good;
|
|
486
503
|
// anonymizing them would keep the account's data stored for nothing.
|
|
487
504
|
if (policy.strategy === "blockDelete" && args.purgeExpiredBlockDelete === true) {
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
+
// A row whose reference was never set has no running keepFor, so it would block the release forever.
|
|
506
|
+
for (const expired of [where, { ...where, [referenceField]: null }]) {
|
|
507
|
+
hardDeleted += await hardDeleteMatchingRows({
|
|
508
|
+
db,
|
|
509
|
+
table: proj.table,
|
|
510
|
+
where: expired,
|
|
511
|
+
batchLimit,
|
|
512
|
+
tenantId,
|
|
513
|
+
entityName,
|
|
514
|
+
entity,
|
|
515
|
+
files: args.files,
|
|
516
|
+
systemUser,
|
|
517
|
+
tdb,
|
|
518
|
+
kms,
|
|
519
|
+
registry,
|
|
520
|
+
fileHolders,
|
|
521
|
+
deleteWithoutFileStorage: true,
|
|
522
|
+
skipped,
|
|
523
|
+
});
|
|
524
|
+
}
|
|
505
525
|
break;
|
|
506
526
|
}
|
|
507
527
|
const targets = await resolveAnonymizeTargets(entity.fields);
|
|
@@ -114,9 +114,16 @@ export async function holdBlockDeleteRowsForDestruction(args) {
|
|
|
114
114
|
if (!targets)
|
|
115
115
|
continue;
|
|
116
116
|
const executor = createEventStoreExecutor(table, entity, { entityName });
|
|
117
|
+
// Every page restarts at the first row, so a row that is anonymized twice means the update does
|
|
118
|
+
// not converge (the loop would never see a short page).
|
|
119
|
+
const anonymizedIds = new Set();
|
|
117
120
|
let updated = ANONYMIZE_PAGE_SIZE;
|
|
118
121
|
while (updated === ANONYMIZE_PAGE_SIZE) {
|
|
119
122
|
updated = await anonymizeMatchingRows(args.db, table, { tenantId: args.tenantId }, ANONYMIZE_PAGE_SIZE, targets, async (id, changes) => {
|
|
123
|
+
if (anonymizedIds.has(String(id))) {
|
|
124
|
+
throw new Error(`data-retention: anonymizing held ${entityName} row ${String(id)} does not converge, the anonymized value differs from the stored one`);
|
|
125
|
+
}
|
|
126
|
+
anonymizedIds.add(String(id));
|
|
120
127
|
const result = await executor.update({ id, changes }, systemUser, tdb, {
|
|
121
128
|
skipOptimisticLock: true,
|
|
122
129
|
writePurpose: WritePurposes.retention,
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { DeliveryAttemptLogFactory } from "@cosmicdrift/kumiko-framework/engine";
|
|
2
|
+
import type { DeliveryService } from "./types.ts";
|
|
3
|
+
export declare function createDeliveryAttemptLogFactory(deliveryService: Pick<DeliveryService, "logAttempt">): DeliveryAttemptLogFactory;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// Tenant and recipient come from the binding, never from the entry, so a handler cannot log an
|
|
2
|
+
// attempt for another tenant or another recipient.
|
|
3
|
+
export function createDeliveryAttemptLogFactory(deliveryService) {
|
|
4
|
+
return (user, tenantId, deliveryDb) => (entry) => deliveryService.logAttempt({ ...entry, tenantId, recipientId: user.id }, deliveryDb);
|
|
5
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { DbConnection } from "@cosmicdrift/kumiko-framework/db";
|
|
1
|
+
import type { DbConnection, DbRunner } from "@cosmicdrift/kumiko-framework/db";
|
|
2
2
|
import type { Registry } from "@cosmicdrift/kumiko-framework/engine";
|
|
3
3
|
import { type DeliveryLogEntry } from "./types.ts";
|
|
4
4
|
export declare function rememberConnectionNameChannel(connectionNameChannels: Set<string>, channelName: string, channelOptions: unknown): void;
|
|
5
5
|
export declare function projectedAttemptAddress(connectionNameChannels: ReadonlySet<string>, channel: string, recipientAddress: string | null): string | null;
|
|
6
6
|
export declare function appendAttemptEvent(db: DbConnection, registry: Registry, attemptId: string, entry: DeliveryLogEntry): Promise<void>;
|
|
7
|
-
export declare function logAttempt(db:
|
|
7
|
+
export declare function logAttempt(db: DbRunner, registry: Registry, entry: DeliveryLogEntry): Promise<string>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { SseBroker } from "@cosmicdrift/kumiko-framework/api";
|
|
2
2
|
import { type DbConnection, type TenantDb } from "@cosmicdrift/kumiko-framework/db";
|
|
3
3
|
import type { ConfigAccessor, Registry, TenantId } from "@cosmicdrift/kumiko-framework/engine";
|
|
4
|
-
import type
|
|
4
|
+
import { type FileContext } from "@cosmicdrift/kumiko-framework/files";
|
|
5
5
|
import type { SecretsContext } from "@cosmicdrift/kumiko-framework/secrets";
|
|
6
6
|
import { type MailPayload } from "../renderer-foundation/index.ts";
|
|
7
7
|
import type { ChannelContext, RenderedMail } from "./types.ts";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createTenantDb } from "@cosmicdrift/kumiko-framework/db";
|
|
2
2
|
import { SYSTEM_TENANT_ID } from "@cosmicdrift/kumiko-framework/engine";
|
|
3
|
+
import { FileObjectMissingError } from "@cosmicdrift/kumiko-framework/files";
|
|
3
4
|
import { createFallbackLogger } from "@cosmicdrift/kumiko-framework/logging";
|
|
4
5
|
import { FileStorageUnavailableError, readFileRefContent, } from "../file-foundation/index.js";
|
|
5
6
|
import { collectRendererPlugins, createRendererFoundationApi, RendererError, } from "../renderer-foundation/index.js";
|
|
@@ -45,14 +46,16 @@ function createPdfRenderer(db, registry, tenantId, config, filesForTenant) {
|
|
|
45
46
|
};
|
|
46
47
|
}
|
|
47
48
|
// A decorative inline image (logo) of a tenant without file storage must not fail the whole mail;
|
|
48
|
-
//
|
|
49
|
+
// a file ref whose object is gone is permanent, so it is skipped too; transient read errors rethrow
|
|
50
|
+
// so the send job retries.
|
|
49
51
|
async function readInlineImageOrNull(fileRefId, read) {
|
|
50
52
|
try {
|
|
51
53
|
return await read();
|
|
52
54
|
}
|
|
53
55
|
catch (err) {
|
|
54
|
-
if (!(err instanceof FileStorageUnavailableError))
|
|
56
|
+
if (!(err instanceof FileStorageUnavailableError || err instanceof FileObjectMissingError)) {
|
|
55
57
|
throw err;
|
|
58
|
+
}
|
|
56
59
|
createFallbackLogger("delivery").warn("inline image could not be read, sending without it", {
|
|
57
60
|
fileRefId,
|
|
58
61
|
errorName: err.name,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { toPostgresArrayLiteral, unsafeReadRetrying } from "@cosmicdrift/kumiko-framework/db";
|
|
2
|
-
// @wrapper-known semantic-alias
|
|
3
2
|
export async function selectNotificationPreferences(db, tenantId, userId, notificationTypeNames, channelName) {
|
|
4
3
|
return unsafeReadRetrying(db, `SELECT notification_type AS "notificationType", channel, enabled
|
|
5
4
|
FROM read_notification_preferences
|
|
@@ -666,5 +666,8 @@ export function createDeliveryService(options) {
|
|
|
666
666
|
await releaseIdempotencyIfNothingDelivered(tenantId, idempotencyKey, run, notificationType);
|
|
667
667
|
return dispatched(run);
|
|
668
668
|
},
|
|
669
|
+
async logAttempt(entry, deliveryDb) {
|
|
670
|
+
await logAttempt(deliveryDb ?? db, registry, entry);
|
|
671
|
+
},
|
|
669
672
|
};
|
|
670
673
|
}
|
|
@@ -1,6 +1,3 @@
|
|
|
1
1
|
import { type FeatureDefinition } from "@cosmicdrift/kumiko-framework/engine";
|
|
2
|
-
|
|
3
|
-
readonly access?: readonly string[];
|
|
4
|
-
readonly attemptLogRetentionDays?: number | false;
|
|
5
|
-
};
|
|
2
|
+
import type { DeliveryFeatureOptions } from "./options.ts";
|
|
6
3
|
export declare function createDeliveryFeature(options?: DeliveryFeatureOptions): FeatureDefinition;
|
package/dist/delivery/feature.js
CHANGED
|
@@ -7,6 +7,7 @@ import { DELIVERY_ATTEMPT_ADDRESS_ERASED_EVENT, DELIVERY_ATTEMPT_EVENT, DELIVERY
|
|
|
7
7
|
import { deliveryAttemptAddressErasedSchema, deliveryAttemptSchema } from "./events.js";
|
|
8
8
|
import { attemptsByKeysQuery } from "./handlers/attempts-by-keys.query.js";
|
|
9
9
|
import { logQuery } from "./handlers/log.query.js";
|
|
10
|
+
import { optedInUserIdsQuery } from "./handlers/opted-in-user-ids.query.js";
|
|
10
11
|
import { preferencesQuery } from "./handlers/preferences.query.js";
|
|
11
12
|
import { resubscribeAddressWrite } from "./handlers/resubscribe-address.write.js";
|
|
12
13
|
import { resubscribeUserWrite } from "./handlers/resubscribe-user.write.js";
|
|
@@ -23,7 +24,7 @@ export function createDeliveryFeature(options) {
|
|
|
23
24
|
const attemptLogRetentionDays = resolveAttemptLogRetentionDays(options?.attemptLogRetentionDays);
|
|
24
25
|
return defineFeature("delivery", (r) => {
|
|
25
26
|
r.adoptsBundledLists();
|
|
26
|
-
r.describe("The notification dispatch core: call `ctx.notify(notificationType, { to, route, data, priority, idempotencyKey })` from any handler to fan out a notification across all registered channels (email, in-app, push). Inside a write handler the delivery runs after the write has committed (the call returns `{ kind: \"deferred\" }`, a rolled-back write sends nothing); `immediate: true` delivers synchronously and returns `{ kind: \"dispatched\", deliveries }`. It stores per-user channel preferences in the `notification-preference` entity, opt-outs for no-account recipient addresses in `notification-address-opt-out` (keyed by a blind-index hash, never the plaintext address), logs every attempt to `store_delivery_attempts`, and enforces idempotency and rate-limiting \u2014 add `channel-email`, `channel-in-app`, or `channel-push` on top to actually send anything. Unsubscribe/resubscribe links are served by `createUnsubscribeRoutes({ secret })` mounted via the app's `extraRoutes` at `/api/delivery/unsubscribe` and `/api/delivery/resubscribe`: `GET /unsubscribe?token=` renders a confirmation page (no write), `POST /unsubscribe` performs the opt-out (RFC 8058 one-click, token from the form body or query), `POST /resubscribe` undoes it (JSON `{token}` or form body only, never the query — reachable by a mail-client link prefetcher) — sign links with `signUnsubscribeToken` / `signAddressUnsubscribeToken` using the same secret. `channel-email` sets `List-Unsubscribe` / `List-Unsubscribe-Post` automatically when a message's `data.unsubscribeUrl` points at the unsubscribe route. A notification declared with `unsubscribe: true` gets that link from delivery itself when the service has `unsubscribeLinks` (the `runProdApp` and `runDevApp` option `unsubscribe: { secret }` mounts the routes and wires it; base URL from `auth.publicOrigin`, `auth.mail.baseUrl` or `APP_BASE_URL`): user recipients get a user token, `route` recipients an address token (needs a blind-index key, otherwise no link); a `data.unsubscribeUrl` from the caller wins. `unsubscribe.tenantOrigin: (ctx) => origin | null` points the link at the tenant's own host (subdomain or custom domain, must serve this app's `/api`); null, a throw or a non-https value fall back to the app origin. The token carries the mail's locale, so the confirmation and result pages render in the mail's language. An app serving its own (e.g. legacy) unsubscribe links renders the same result page with `renderUnsubscribeResultPage({ kind, locale })`. To react to a no-account opt-out (e.g. remove the app's own subscriber row), declare `r.job(name, { trigger: { on: DeliveryHandlers.unsubscribeAddress } }, handler)` on a lane the app consumes: it runs after each committed opt-out, also an idempotent repeat, with `unsubscribeAddressPayloadSchema` (`addressHash`, `notificationType`, `channel`) as payload and the tenant in `ctx.triggeredBy.tenantId`; match the subscriber via `hashUnsubscribeAddress(email)`. Declare `unsubscribeUrl` as an optional template variable if the mail body shows it.");
|
|
27
|
+
r.describe("The notification dispatch core: call `ctx.notify(notificationType, { to, route, data, priority, idempotencyKey })` from any handler to fan out a notification across all registered channels (email, in-app, push). Inside a write handler the delivery runs after the write has committed (the call returns `{ kind: \"deferred\" }`, a rolled-back write sends nothing); `immediate: true` delivers synchronously and returns `{ kind: \"dispatched\", deliveries }`. It stores per-user channel preferences in the `notification-preference` entity, opt-outs for no-account recipient addresses in `notification-address-opt-out` (keyed by a blind-index hash, never the plaintext address), logs every attempt to `store_delivery_attempts`, and enforces idempotency and rate-limiting \u2014 add `channel-email`, `channel-in-app`, or `channel-push` on top to actually send anything. Unsubscribe/resubscribe links are served by `createUnsubscribeRoutes({ secret })` mounted via the app's `extraRoutes` at `/api/delivery/unsubscribe` and `/api/delivery/resubscribe`: `GET /unsubscribe?token=` renders a confirmation page (no write), `POST /unsubscribe` performs the opt-out (RFC 8058 one-click, token from the form body or query), `POST /resubscribe` undoes it (JSON `{token}` or form body only, never the query — reachable by a mail-client link prefetcher) — sign links with `signUnsubscribeToken` / `signAddressUnsubscribeToken` using the same secret. `channel-email` sets `List-Unsubscribe` / `List-Unsubscribe-Post` automatically when a message's `data.unsubscribeUrl` points at the unsubscribe route. A notification declared with `unsubscribe: true` gets that link from delivery itself when the service has `unsubscribeLinks` (the `runProdApp` and `runDevApp` option `unsubscribe: { secret }` mounts the routes and wires it; base URL from `auth.publicOrigin`, `auth.mail.baseUrl` or `APP_BASE_URL`): user recipients get a user token, `route` recipients an address token (needs a blind-index key, otherwise no link); a `data.unsubscribeUrl` from the caller wins. `unsubscribe.tenantOrigin: (ctx) => origin | null` points the link at the tenant's own host (subdomain or custom domain, must serve this app's `/api`); null, a throw or a non-https value fall back to the app origin. The token carries the mail's locale, so the confirmation and result pages render in the mail's language. An app serving its own (e.g. legacy) unsubscribe links renders the same result page with `renderUnsubscribeResultPage({ kind, locale })`. To react to a no-account opt-out (e.g. remove the app's own subscriber row), declare `r.job(name, { trigger: { on: DeliveryHandlers.unsubscribeAddress } }, handler)` on a lane the app consumes: it runs after each committed opt-out, also an idempotent repeat, with `unsubscribeAddressPayloadSchema` (`addressHash`, `notificationType`, `channel`) as payload and the tenant in `ctx.triggeredBy.tenantId`; match the subscriber via `hashUnsubscribeAddress(email)`. Declare `unsubscribeUrl` as an optional template variable if the mail body shows it. A job that sends an opt-in notification (e.g. a daily digest) reads the members who switched it on from the job-only query `delivery:query:opted-in-user-ids` (`{ notificationType, channel }` answers `{ userIds }`).");
|
|
27
28
|
r.uiHints({
|
|
28
29
|
displayLabel: "Notifications \u00b7 Dispatch Core",
|
|
29
30
|
category: "notifications",
|
|
@@ -159,6 +160,7 @@ export function createDeliveryFeature(options) {
|
|
|
159
160
|
log: r.queryHandler({ ...logQuery, access: { roles: resolvedAccess } }),
|
|
160
161
|
preferences: r.queryHandler(preferencesQuery),
|
|
161
162
|
attemptsByKeys: r.queryHandler(attemptsByKeysQuery),
|
|
163
|
+
optedInUserIds: r.queryHandler(optedInUserIdsQuery),
|
|
162
164
|
unsubscribePageChrome: r.queryHandler(unsubscribePageChromeQuery),
|
|
163
165
|
};
|
|
164
166
|
r.screen({
|
|
@@ -9,7 +9,7 @@ export declare const attemptsByKeysQuery: import("@cosmicdrift/kumiko-types/defi
|
|
|
9
9
|
channel: string;
|
|
10
10
|
recipientId: string | null;
|
|
11
11
|
status: string;
|
|
12
|
-
error: import("@cosmicdrift/kumiko-
|
|
12
|
+
error: import("@cosmicdrift/kumiko-framework/engine").DeliveryErrorCode | null;
|
|
13
13
|
createdAt: globalThis.Temporal.Instant;
|
|
14
14
|
}[];
|
|
15
15
|
}, import("@cosmicdrift/kumiko-types/event-type-map").KumikoEventTypeMap>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
export declare const optedInUserIdsQuery: import("@cosmicdrift/kumiko-types/define-handler").QueryHandlerDefinition<"opted-in-user-ids", z.ZodObject<{
|
|
3
|
+
notificationType: z.ZodString;
|
|
4
|
+
channel: z.ZodString;
|
|
5
|
+
}, z.core.$strict>, {
|
|
6
|
+
userIds: string[];
|
|
7
|
+
}, import("@cosmicdrift/kumiko-types/event-type-map").KumikoEventTypeMap>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { selectMany } from "@cosmicdrift/kumiko-framework/db";
|
|
2
|
+
import { defineQueryHandler, SYSTEM_ROLE } from "@cosmicdrift/kumiko-framework/engine";
|
|
3
|
+
import { InternalError } from "@cosmicdrift/kumiko-framework/errors";
|
|
4
|
+
import * as z from "zod";
|
|
5
|
+
import { tenantMembershipsTable } from "../../tenant/index.js";
|
|
6
|
+
import { notificationTypeNames } from "../notification-type-aliases.js";
|
|
7
|
+
import { collapsePreferenceRows } from "../preference-rows.js";
|
|
8
|
+
import { notificationPreferencesTable } from "../tables.js";
|
|
9
|
+
export const optedInUserIdsQuery = defineQueryHandler({
|
|
10
|
+
name: "opted-in-user-ids",
|
|
11
|
+
schema: z.object({ notificationType: z.string().min(1), channel: z.string().min(1) }).strict(),
|
|
12
|
+
access: { roles: [SYSTEM_ROLE] },
|
|
13
|
+
agent: { expose: false },
|
|
14
|
+
description: "Job-only: returns the ids of the calling tenant's members who explicitly switched this notification type on for exactly this channel (a preference row with enabled = true), so a job sending an opt-in notification such as a daily digest addresses only the members who ordered it.",
|
|
15
|
+
handler: async (query, ctx) => {
|
|
16
|
+
if (!ctx.systemDb) {
|
|
17
|
+
throw new InternalError({
|
|
18
|
+
message: "opted-in-user-ids: ctx.systemDb missing on a system-scoped handler",
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
const db = ctx.systemDb.assertTenantMatch(query.user.tenantId);
|
|
22
|
+
const { notificationType, channel } = query.payload;
|
|
23
|
+
const rows = await selectMany(db, notificationPreferencesTable, {
|
|
24
|
+
tenantId: query.user.tenantId,
|
|
25
|
+
channel,
|
|
26
|
+
notificationType: { in: [...notificationTypeNames(ctx.registry, notificationType)] },
|
|
27
|
+
});
|
|
28
|
+
const userIds = collapsePreferenceRows(ctx.registry, rows)
|
|
29
|
+
.filter((row) => row.notificationType === notificationType && row.enabled === true)
|
|
30
|
+
.map((row) => row.userId);
|
|
31
|
+
const candidateIds = [...new Set(userIds)];
|
|
32
|
+
if (candidateIds.length === 0)
|
|
33
|
+
return { userIds: [] };
|
|
34
|
+
// Removed members keep their preference rows; only live memberships may receive tenant data.
|
|
35
|
+
const memberships = await selectMany(db, tenantMembershipsTable, {
|
|
36
|
+
tenantId: query.user.tenantId,
|
|
37
|
+
userId: { in: candidateIds },
|
|
38
|
+
});
|
|
39
|
+
return { userIds: memberships.map((membership) => membership.userId).sort() };
|
|
40
|
+
},
|
|
41
|
+
});
|
|
@@ -2,7 +2,7 @@ import { selectMany } from "@cosmicdrift/kumiko-framework/db";
|
|
|
2
2
|
import { defineQueryHandler } from "@cosmicdrift/kumiko-framework/engine";
|
|
3
3
|
import { InternalError } from "@cosmicdrift/kumiko-framework/errors";
|
|
4
4
|
import * as z from "zod";
|
|
5
|
-
import {
|
|
5
|
+
import { collapsePreferenceRows } from "../preference-rows.js";
|
|
6
6
|
import { notificationPreferencesTable } from "../tables.js";
|
|
7
7
|
export const preferencesQuery = defineQueryHandler({
|
|
8
8
|
name: "preferences",
|
|
@@ -32,24 +32,6 @@ export const preferencesQuery = defineQueryHandler({
|
|
|
32
32
|
tenantId: query.user.tenantId,
|
|
33
33
|
userId: query.user.id,
|
|
34
34
|
});
|
|
35
|
-
|
|
36
|
-
// one, collapsed with the same precedence as delivery: an exact row wins,
|
|
37
|
-
// otherwise any disabled former-name row disables.
|
|
38
|
-
const collapsed = new Map();
|
|
39
|
-
for (const row of rows) {
|
|
40
|
-
const notificationType = currentNotificationType(ctx.registry, row.notificationType);
|
|
41
|
-
const key = `${notificationType}\u0000${row.channel}`;
|
|
42
|
-
const isExact = row.notificationType === notificationType;
|
|
43
|
-
const existing = collapsed.get(key);
|
|
44
|
-
if (existing?.isExact)
|
|
45
|
-
continue;
|
|
46
|
-
const formerNameRowDisablesAlready = existing !== undefined &&
|
|
47
|
-
!isExact &&
|
|
48
|
-
(existing.row.enabled === false || row.enabled !== false);
|
|
49
|
-
if (formerNameRowDisablesAlready)
|
|
50
|
-
continue;
|
|
51
|
-
collapsed.set(key, { row: { ...row, notificationType }, isExact });
|
|
52
|
-
}
|
|
53
|
-
return { rows: [...collapsed.values()].map((entry) => entry.row) };
|
|
35
|
+
return { rows: collapsePreferenceRows(ctx.registry, rows) };
|
|
54
36
|
},
|
|
55
37
|
});
|
|
@@ -4,6 +4,6 @@ export declare const resubscribeUserWrite: import("@cosmicdrift/kumiko-types/def
|
|
|
4
4
|
notificationType: z.ZodString;
|
|
5
5
|
channel: z.ZodString;
|
|
6
6
|
}, z.core.$strip>, {
|
|
7
|
-
notificationType: string;
|
|
8
|
-
channel: string;
|
|
7
|
+
readonly notificationType: string;
|
|
8
|
+
readonly channel: string;
|
|
9
9
|
}, import("@cosmicdrift/kumiko-types/event-type-map").KumikoEventTypeMap, undefined, undefined>;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { access, defineWriteHandler } from "@cosmicdrift/kumiko-framework/engine";
|
|
2
|
-
import { InternalError } from "@cosmicdrift/kumiko-framework/errors";
|
|
3
2
|
import * as z from "zod";
|
|
4
|
-
import {
|
|
5
|
-
import { upsertPreference } from "../upsert-preference.js";
|
|
3
|
+
import { setPreferenceEnabled } from "../set-preference-enabled.js";
|
|
6
4
|
export const resubscribeUserWrite = defineWriteHandler({
|
|
7
5
|
name: "resubscribeUser",
|
|
8
6
|
schema: z.object({
|
|
@@ -16,25 +14,5 @@ export const resubscribeUserWrite = defineWriteHandler({
|
|
|
16
14
|
// signature — not a surface for the agent tool-picker to offer directly.
|
|
17
15
|
agent: { expose: false },
|
|
18
16
|
description: "Re-enables one notification type and channel combination for the userId carried in a verified unsubscribe token; dispatched by the signed resubscribe route, not meant for UI callers.",
|
|
19
|
-
handler:
|
|
20
|
-
const { userId, channel } = event.payload;
|
|
21
|
-
const notificationType = currentNotificationType(ctx.registry, event.payload.notificationType);
|
|
22
|
-
const { tenantId } = event.user;
|
|
23
|
-
if (!ctx.systemDb) {
|
|
24
|
-
throw new InternalError({
|
|
25
|
-
message: "resubscribeUser: ctx.systemDb missing on a system-scoped handler",
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
const db = ctx.systemDb.assertTenantMatch(tenantId);
|
|
29
|
-
const result = await upsertPreference(db, event.user, {
|
|
30
|
-
tenantId,
|
|
31
|
-
userId,
|
|
32
|
-
notificationType,
|
|
33
|
-
channel,
|
|
34
|
-
enabled: true,
|
|
35
|
-
});
|
|
36
|
-
if (!result.isSuccess)
|
|
37
|
-
return result;
|
|
38
|
-
return { isSuccess: true, data: { notificationType, channel } };
|
|
39
|
-
},
|
|
17
|
+
handler: (event, ctx) => setPreferenceEnabled("resubscribeUser", event, ctx, true),
|
|
40
18
|
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { access, defineQueryHandler } from "@cosmicdrift/kumiko-framework/engine";
|
|
2
2
|
import { InternalError } from "@cosmicdrift/kumiko-framework/errors";
|
|
3
3
|
import * as z from "zod";
|
|
4
|
+
import { fileContextForTenant } from "../../file-foundation/index.js";
|
|
4
5
|
import { collectRendererPlugins, createRendererFoundationApi, RendererError, } from "../../renderer-foundation/index.js";
|
|
5
6
|
function mailChromePlugin(plugins, tenantId) {
|
|
6
7
|
try {
|
|
@@ -39,6 +40,7 @@ export const unsubscribePageChromeQuery = defineQueryHandler({
|
|
|
39
40
|
registry: ctx.registry,
|
|
40
41
|
tenantId,
|
|
41
42
|
...(ctx.config !== undefined && { config: ctx.config }),
|
|
43
|
+
filesForTenant: (fileTenantId) => fileContextForTenant(ctx, tenantId, fileTenantId),
|
|
42
44
|
});
|
|
43
45
|
},
|
|
44
46
|
});
|
|
@@ -4,6 +4,6 @@ export declare const unsubscribeUserWrite: import("@cosmicdrift/kumiko-types/def
|
|
|
4
4
|
notificationType: z.ZodString;
|
|
5
5
|
channel: z.ZodString;
|
|
6
6
|
}, z.core.$strip>, {
|
|
7
|
-
notificationType: string;
|
|
8
|
-
channel: string;
|
|
7
|
+
readonly notificationType: string;
|
|
8
|
+
readonly channel: string;
|
|
9
9
|
}, import("@cosmicdrift/kumiko-types/event-type-map").KumikoEventTypeMap, undefined, undefined>;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { access, defineWriteHandler } from "@cosmicdrift/kumiko-framework/engine";
|
|
2
|
-
import { InternalError } from "@cosmicdrift/kumiko-framework/errors";
|
|
3
2
|
import * as z from "zod";
|
|
4
|
-
import {
|
|
5
|
-
import { upsertPreference } from "../upsert-preference.js";
|
|
3
|
+
import { setPreferenceEnabled } from "../set-preference-enabled.js";
|
|
6
4
|
export const unsubscribeUserWrite = defineWriteHandler({
|
|
7
5
|
name: "unsubscribeUser",
|
|
8
6
|
schema: z.object({
|
|
@@ -16,27 +14,5 @@ export const unsubscribeUserWrite = defineWriteHandler({
|
|
|
16
14
|
// the agent tool-picker to offer a user directly.
|
|
17
15
|
agent: { expose: false },
|
|
18
16
|
description: "Disables one notification type and channel combination for the userId carried in a verified unsubscribe token; dispatched by the signed unsubscribe route, not meant for UI callers.",
|
|
19
|
-
handler:
|
|
20
|
-
// userId comes from the payload, not event.user.id — the caller here is
|
|
21
|
-
// the system user dispatchSystemWrite runs as, not the user unsubscribing.
|
|
22
|
-
const { userId, channel } = event.payload;
|
|
23
|
-
const notificationType = currentNotificationType(ctx.registry, event.payload.notificationType);
|
|
24
|
-
const { tenantId } = event.user;
|
|
25
|
-
if (!ctx.systemDb) {
|
|
26
|
-
throw new InternalError({
|
|
27
|
-
message: "unsubscribeUser: ctx.systemDb missing on a system-scoped handler",
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
const db = ctx.systemDb.assertTenantMatch(tenantId);
|
|
31
|
-
const result = await upsertPreference(db, event.user, {
|
|
32
|
-
tenantId,
|
|
33
|
-
userId,
|
|
34
|
-
notificationType,
|
|
35
|
-
channel,
|
|
36
|
-
enabled: false,
|
|
37
|
-
});
|
|
38
|
-
if (!result.isSuccess)
|
|
39
|
-
return result;
|
|
40
|
-
return { isSuccess: true, data: { notificationType, channel } };
|
|
41
|
-
},
|
|
17
|
+
handler: (event, ctx) => setPreferenceEnabled("unsubscribeUser", event, ctx, false),
|
|
42
18
|
});
|
package/dist/delivery/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { sanitizePdfAttachmentFileName } from "../shared/index.ts";
|
|
2
2
|
export { hashUnsubscribeAddress } from "./address-opt-out.ts";
|
|
3
3
|
export { DELIVERY_ENVELOPE_DATA_KEYS, type EmailAttachmentRef, emailAttachmentRefSchema, type FileAttachmentRef, fileAttachmentRefSchema, type InlineAttachmentRef, inlineAttachmentRefSchema, MAX_EMAIL_ATTACHMENTS, MAX_RENDERED_PDF_VARIABLES_BYTES, type RenderedPdfAttachmentRef, renderedPdfAttachmentRefSchema, toAttachmentRef, withoutDeliveryEnvelopeKeys, } from "./attachment-ref.ts";
|
|
4
|
+
export { createDeliveryAttemptLogFactory } from "./attempt-log-factory.ts";
|
|
4
5
|
export { type AttemptLogRetentionOptions, DEFAULT_ATTEMPT_LOG_RETENTION_DAYS, runAttemptLogRetention, } from "./attempt-log-retention.ts";
|
|
5
6
|
export { buildChannelContext, createEmailAttachmentReader, createTemplateMailRenderer, } from "./channel-context.ts";
|
|
6
7
|
export { type ChatWebhookChannelOptions, chatMessageText, createChatWebhookChannel, resolveChatWebhookTarget, toChannelResult, } from "./chat-webhook-channel.ts";
|
|
@@ -8,10 +9,11 @@ export { type ChatSendFailureCode, type ChatSendResult, type ChatWebhookRequest,
|
|
|
8
9
|
export type { DeliveryStatusValue } from "./constants.ts";
|
|
9
10
|
export { DELIVERY_ATTEMPT_ADDRESS_ERASED_EVENT, DELIVERY_CHANNEL_EXTENSION, DELIVERY_FEATURE, DELIVERY_LOG_SCREEN_ID, DELIVERY_UNSUBSCRIBE_PATH, DeliveryErrors, DeliveryHandlers, DeliveryJobs, DeliveryQueries, DeliveryStatus, EMAIL_CHANNEL_NAME, } from "./constants.ts";
|
|
10
11
|
export { collectChannels, createDeliveryService, type DeliveryServiceOptions, type KillSwitchResolver, type RateLimitConfig, } from "./delivery-service.ts";
|
|
11
|
-
export { createDeliveryFeature
|
|
12
|
+
export { createDeliveryFeature } from "./feature.ts";
|
|
12
13
|
export { type UnsubscribeAddressPayload, unsubscribeAddressPayloadSchema, } from "./handlers/unsubscribe-address.write.ts";
|
|
13
14
|
export { currentNotificationType } from "./notification-type-aliases.ts";
|
|
14
15
|
export { createDeliveryNotifyFactory } from "./notify-factory.ts";
|
|
16
|
+
export type { DeliveryFeatureOptions } from "./options.ts";
|
|
15
17
|
export { buildSystemChannelContext, type SystemChannelContextDeps, type SystemChannelContextOptions, } from "./system-channel-context.ts";
|
|
16
18
|
export { deliveryAttemptsTable, notificationAddressOptOutEntity, notificationAddressOptOutsTable, notificationPreferenceEntity, notificationPreferencesTable, } from "./tables.ts";
|
|
17
19
|
export { type CreateDeliveryTestContextOptions, createDeliveryTestContext } from "./testing.ts";
|