@cosmicdrift/kumiko-bundled-features 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/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/signup-token-store.d.ts +2 -2
- package/dist/auth-email-password/signup-token-store.js +2 -4
- 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 +13 -13
- 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.d.ts +2 -0
- package/dist/billing-foundation/checkout-core.js +17 -1
- package/dist/billing-foundation/checkout-ledger.d.ts +22 -0
- package/dist/billing-foundation/checkout-ledger.js +38 -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 +23 -0
- package/dist/billing-foundation/events.js +39 -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 +3 -2
- package/dist/billing-foundation/handlers/process-event.write.d.ts +4 -2
- package/dist/billing-foundation/handlers/process-event.write.js +132 -25
- package/dist/billing-foundation/handlers/process-payment-event.write.d.ts +1 -2
- package/dist/billing-foundation/handlers/process-payment-event.write.js +31 -11
- 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 +3 -2
- 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 +90 -0
- package/dist/channel-whatsapp/events.js +71 -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 +148 -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 +200 -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/set-profile.write.js +2 -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 +2 -5
- 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 +50 -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/feature.js +1 -0
- package/dist/document-ingest-foundation/report-ingest-progress.d.ts +1 -1
- package/dist/document-ingest-foundation/report-ingest-progress.js +32 -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 +29 -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/form-draft/feature.js +1 -0
- package/dist/helpdesk/entity.js +4 -1
- package/dist/helpdesk/feature.js +37 -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 +7 -8
- package/dist/helpdesk/handlers/report.write.js +4 -7
- package/dist/helpdesk/handlers/submit.write.js +5 -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 +124 -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 +8 -2
- package/dist/helpdesk/lib.js +32 -32
- 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 +3 -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 +4 -0
- package/dist/inbound-mail-foundation/content-refetch.js +13 -3
- package/dist/inbound-mail-foundation/entities.js +58 -15
- package/dist/inbound-mail-foundation/events.js +16 -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 +14 -8
- package/dist/inbound-mail-foundation/handlers/forget-message.write.d.ts +7 -0
- package/dist/inbound-mail-foundation/handlers/forget-message.write.js +58 -0
- package/dist/inbound-mail-foundation/handlers/ingest-message-schema.js +12 -5
- 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/normalize-inbound-message.d.ts +6 -0
- package/dist/inbound-mail-foundation/normalize-inbound-message.js +21 -8
- 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/sanitize-inbound-html.d.ts +0 -1
- package/dist/inbound-mail-foundation/sanitize-inbound-html.js +2 -4
- 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 +113 -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/hmac-signature.js +4 -2
- package/dist/shared/index.d.ts +7 -2
- package/dist/shared/index.js +7 -2
- package/dist/shared/normalize-email.d.ts +1 -0
- package/dist/shared/normalize-email.js +3 -0
- 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 +3 -0
- package/dist/shared/send-best-effort.js +19 -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 +41 -3
- package/dist/step-dispatcher/feature.js +31 -2
- package/dist/step-dispatcher/mail-runner.js +0 -1
- package/dist/step-dispatcher/sweep-abandoned.d.ts +11 -0
- package/dist/step-dispatcher/sweep-abandoned.js +46 -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 +112 -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 +43 -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 +31 -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 +92 -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 +45 -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 +29 -18
- package/dist/tenant-inactivity/constants.js +1 -2
- package/dist/tenant-inactivity/handlers/keep-account.write.js +8 -2
- package/dist/tenant-inactivity/state-store.d.ts +3 -1
- package/dist/tenant-inactivity/state-store.js +16 -1
- package/dist/tenant-lifecycle/constants.d.ts +1 -0
- package/dist/tenant-lifecycle/constants.js +3 -0
- package/dist/tenant-lifecycle/feature.js +1 -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/feature.js +1 -0
- 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/reject.write.js +2 -1
- package/dist/waitlist/handlers/submit.write.js +6 -19
- package/dist/waitlist/import.js +2 -1
- package/dist/waitlist/lib.d.ts +0 -1
- package/dist/waitlist/lib.js +2 -10
- package/dist/waitlist/link-on-signup.js +2 -2
- 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 +6 -4
- 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/auth-mfa/changes.json +6 -0
- package/src/billing-foundation/changes.json +61 -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 +32 -0
- package/src/compliance-profiles/changes.json +5 -0
- package/src/config/changes.json +12 -0
- package/src/crypto-shredding/changes.json +18 -0
- package/src/data-retention/changes.json +12 -0
- package/src/delivery/changes.json +12 -0
- package/src/document-ingest-foundation/changes.json +6 -0
- package/src/documents/changes.json +24 -0
- package/src/file-provider-s3/changes.json +14 -0
- package/src/files/changes.json +7 -0
- package/src/helpdesk/changes.json +56 -0
- package/src/inbound-mail-foundation/changes.json +54 -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 +12 -0
- package/src/step-dispatcher/changes.json +18 -0
- package/src/subscription-mollie/changes.json +7 -0
- package/src/subscription-paddle/changes.json +19 -0
- package/src/subscription-stripe/changes.json +13 -0
- package/src/template-resolver/changes.json +48 -0
- package/src/tenant/changes.json +6 -0
- package/src/tenant-inactivity/changes.json +6 -0
- package/src/tenant-lifecycle/changes.json +24 -0
- package/src/tier-engine/changes.json +6 -0
- package/src/user/changes.json +6 -0
- package/src/waitlist/changes.json +6 -0
- package/src/workflow-runner/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
|
@@ -8,6 +8,7 @@ import { retryQuarantinedMessages } from "./quarantine-retry.js";
|
|
|
8
8
|
const SEEN_LOOKUP_CHUNK_SIZE = 1000;
|
|
9
9
|
export function createAccountPoller(deps) {
|
|
10
10
|
const { systemDb, cursors, ingester, health, providerCtx, backfillWindowDays, maxMessagesPerPoll, resolveAccessToken, handleSyncError, log, } = deps;
|
|
11
|
+
const scanResumePoint = new Map();
|
|
11
12
|
function unknownMessageIdsFilterFor(account) {
|
|
12
13
|
return async (providerMessageIds) => {
|
|
13
14
|
if (providerMessageIds.length === 0)
|
|
@@ -26,7 +27,7 @@ export function createAccountPoller(deps) {
|
|
|
26
27
|
seenIds.add(row.providerMessageId);
|
|
27
28
|
}
|
|
28
29
|
// A quarantined message counts as seen: re-fetching it would only fail the same way again.
|
|
29
|
-
for (const id of await quarantinedMessageIds(systemDb, account.id, providerMessageIds)) {
|
|
30
|
+
for (const id of await quarantinedMessageIds(systemDb, { tenantId: account.tenantId, accountId: account.id }, providerMessageIds)) {
|
|
30
31
|
seenIds.add(id);
|
|
31
32
|
}
|
|
32
33
|
return new Set(providerMessageIds.filter((id) => !seenIds.has(id)));
|
|
@@ -45,6 +46,7 @@ export function createAccountPoller(deps) {
|
|
|
45
46
|
const accessToken = await resolveAccessToken(account, plugin);
|
|
46
47
|
await refetchSnippetOnlyMessages({
|
|
47
48
|
db: systemDb,
|
|
49
|
+
scanResumePoint,
|
|
48
50
|
dispatchWrite: deps.dispatchWrite,
|
|
49
51
|
providerCtx,
|
|
50
52
|
account,
|
|
@@ -18,7 +18,6 @@ const MAIL_THREAD_NAMESPACE = "b48d1e72-5c9a-4f36-8e0d-6a3f9b2c7e15";
|
|
|
18
18
|
* the same tenant can receive the same email (CC'd to both inboxes); these
|
|
19
19
|
* are two distinct inbound messages.
|
|
20
20
|
*/
|
|
21
|
-
// @wrapper-known uuid-domain
|
|
22
21
|
export function inboundMessageAggregateId(accountId, providerMessageId) {
|
|
23
22
|
return uuidv5(`${accountId}:${providerMessageId}`, INBOUND_MESSAGE_NAMESPACE);
|
|
24
23
|
}
|
|
@@ -29,7 +28,6 @@ export function inboundMessageAggregateId(accountId, providerMessageId) {
|
|
|
29
28
|
* normalized by the provider (References/In-Reply-To chain or provider
|
|
30
29
|
* thread ID).
|
|
31
30
|
*/
|
|
32
|
-
// @wrapper-known uuid-domain
|
|
33
31
|
export function mailThreadAggregateId(tenantId, threadKey) {
|
|
34
32
|
return uuidv5(`${tenantId}:${threadKey}`, MAIL_THREAD_NAMESPACE);
|
|
35
33
|
}
|
|
@@ -22,6 +22,8 @@ export declare const InboundMailFoundationHandlers: {
|
|
|
22
22
|
readonly retryQuarantinedMessage: "inbound-mail-foundation:write:retry-quarantined-message";
|
|
23
23
|
/** Marks all open quarantine entries of a mailbox as acknowledged. */
|
|
24
24
|
readonly acknowledgeQuarantine: "inbound-mail-foundation:write:acknowledge-quarantine";
|
|
25
|
+
/** Permanently removes one imported mail with its original and attachments. */
|
|
26
|
+
readonly forgetMessage: "inbound-mail-foundation:write:forget-message";
|
|
25
27
|
/** Supervisor-only: stores the content of an already imported snippet mail. */
|
|
26
28
|
readonly attachMessageContent: "inbound-mail-foundation:write:attach-message-content";
|
|
27
29
|
/** OAuth callback only: the refresh token is stored now, so an active account can sync. */
|
|
@@ -67,6 +69,10 @@ export declare const InboundMailConnectErrors: {
|
|
|
67
69
|
readonly reason: "address_disconnected";
|
|
68
70
|
readonly i18nKey: "inboundMail.accounts.errors.addressDisconnected";
|
|
69
71
|
};
|
|
72
|
+
readonly personalAddressNotOwn: {
|
|
73
|
+
readonly reason: "personal_address_not_own";
|
|
74
|
+
readonly i18nKey: "inboundMail.accounts.errors.personalAddressNotOwn";
|
|
75
|
+
};
|
|
70
76
|
readonly credentialRequired: {
|
|
71
77
|
readonly reason: "credential_required";
|
|
72
78
|
readonly i18nKey: "inboundMail.accounts.errors.credentialRequired";
|
|
@@ -26,6 +26,8 @@ export const InboundMailFoundationHandlers = {
|
|
|
26
26
|
retryQuarantinedMessage: "inbound-mail-foundation:write:retry-quarantined-message",
|
|
27
27
|
/** Marks all open quarantine entries of a mailbox as acknowledged. */
|
|
28
28
|
acknowledgeQuarantine: "inbound-mail-foundation:write:acknowledge-quarantine",
|
|
29
|
+
/** Permanently removes one imported mail with its original and attachments. */
|
|
30
|
+
forgetMessage: "inbound-mail-foundation:write:forget-message",
|
|
29
31
|
/** Supervisor-only: stores the content of an already imported snippet mail. */
|
|
30
32
|
attachMessageContent: "inbound-mail-foundation:write:attach-message-content",
|
|
31
33
|
/** OAuth callback only: the refresh token is stored now, so an active account can sync. */
|
|
@@ -73,6 +75,10 @@ export const InboundMailConnectErrors = {
|
|
|
73
75
|
reason: "address_disconnected",
|
|
74
76
|
i18nKey: "inboundMail.accounts.errors.addressDisconnected",
|
|
75
77
|
},
|
|
78
|
+
personalAddressNotOwn: {
|
|
79
|
+
reason: "personal_address_not_own",
|
|
80
|
+
i18nKey: "inboundMail.accounts.errors.personalAddressNotOwn",
|
|
81
|
+
},
|
|
76
82
|
credentialRequired: {
|
|
77
83
|
reason: "credential_required",
|
|
78
84
|
i18nKey: "inboundMail.accounts.errors.credentialRequired",
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import type { DbConnection } from "@cosmicdrift/kumiko-framework/db";
|
|
2
|
+
import { Temporal } from "@cosmicdrift/kumiko-types/temporal";
|
|
2
3
|
import type { DispatchWrite } from "./supervisor-ingest.ts";
|
|
3
4
|
import type { InboundMailContext, InboundMailProviderPlugin, MailAccountRecord } from "./types.ts";
|
|
4
5
|
export declare const CONTENT_REFETCH_BUDGET_PER_TICK = 50;
|
|
6
|
+
export declare const CONTENT_REFETCH_SCAN_ROWS_PER_TICK: number;
|
|
7
|
+
export type ScanResumePoints = Map<string, Temporal.Instant>;
|
|
5
8
|
export declare function refetchSnippetOnlyMessages(args: {
|
|
6
9
|
readonly db: DbConnection;
|
|
10
|
+
readonly scanResumePoint: ScanResumePoints;
|
|
7
11
|
readonly dispatchWrite: DispatchWrite;
|
|
8
12
|
readonly providerCtx: InboundMailContext;
|
|
9
13
|
readonly account: MailAccountRecord;
|
|
@@ -12,14 +12,16 @@ import { inboundMessagesProjectionTable } from "./projection.js";
|
|
|
12
12
|
export const CONTENT_REFETCH_BUDGET_PER_TICK = 50;
|
|
13
13
|
const SEEN_PAGE_SIZE = 250;
|
|
14
14
|
const SEEN_MAX_PAGES = 4;
|
|
15
|
+
export const CONTENT_REFETCH_SCAN_ROWS_PER_TICK = SEEN_PAGE_SIZE * SEEN_MAX_PAGES;
|
|
15
16
|
function needsContent(row) {
|
|
16
17
|
const bodyMissing = row.bodyRef === undefined || row.bodyRef === null || row.bodyRef === "";
|
|
17
18
|
return bodyMissing && (row.contentState == null || row.contentState === "snippet");
|
|
18
19
|
}
|
|
19
|
-
async function findSnippetOnlyMessageIds(db, account, windowDays) {
|
|
20
|
+
async function findSnippetOnlyMessageIds(db, scanResumePoint, account, windowDays) {
|
|
20
21
|
const cutoff = Temporal.Now.instant().subtract({ hours: windowDays * 24 });
|
|
21
22
|
const found = [];
|
|
22
|
-
let before;
|
|
23
|
+
let before = scanResumePoint.get(account.id);
|
|
24
|
+
scanResumePoint.delete(account.id);
|
|
23
25
|
for (let page = 0; page < SEEN_MAX_PAGES && found.length < CONTENT_REFETCH_BUDGET_PER_TICK; page++) {
|
|
24
26
|
const seen = await selectMany(db, seenMessageTable, {
|
|
25
27
|
tenantId: account.tenantId,
|
|
@@ -32,6 +34,7 @@ async function findSnippetOnlyMessageIds(db, account, windowDays) {
|
|
|
32
34
|
});
|
|
33
35
|
if (seen.length === 0)
|
|
34
36
|
break;
|
|
37
|
+
const pageStart = before;
|
|
35
38
|
const aggregateToProvider = new Map(seen.map((row) => [
|
|
36
39
|
inboundMessageAggregateId(account.id, row.providerMessageId),
|
|
37
40
|
row.providerMessageId,
|
|
@@ -45,7 +48,14 @@ async function findSnippetOnlyMessageIds(db, account, windowDays) {
|
|
|
45
48
|
const oldest = seen[seen.length - 1];
|
|
46
49
|
if (seen.length < SEEN_PAGE_SIZE || !oldest)
|
|
47
50
|
break;
|
|
51
|
+
if (found.length >= CONTENT_REFETCH_BUDGET_PER_TICK) {
|
|
52
|
+
// Reloaded mails stop being candidates, so the page can be read again without looping.
|
|
53
|
+
if (pageStart)
|
|
54
|
+
scanResumePoint.set(account.id, pageStart);
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
48
57
|
before = oldest.seenAt;
|
|
58
|
+
scanResumePoint.set(account.id, before);
|
|
49
59
|
}
|
|
50
60
|
return found.slice(0, CONTENT_REFETCH_BUDGET_PER_TICK);
|
|
51
61
|
}
|
|
@@ -54,7 +64,7 @@ export async function refetchSnippetOnlyMessages(args) {
|
|
|
54
64
|
// skip: the provider cannot reload content.
|
|
55
65
|
if (!plugin.fetchContent)
|
|
56
66
|
return;
|
|
57
|
-
const ids = await findSnippetOnlyMessageIds(args.db, account, args.windowDays);
|
|
67
|
+
const ids = await findSnippetOnlyMessageIds(args.db, args.scanResumePoint, account, args.windowDays);
|
|
58
68
|
// skip: no snippet-only mail to reload.
|
|
59
69
|
if (ids.length === 0)
|
|
60
70
|
return;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { collectPiiSubjectFields } from "@cosmicdrift/kumiko-framework/crypto";
|
|
2
|
-
import { deriveEntityTableMeta, physicalColumnName } from "@cosmicdrift/kumiko-framework/db";
|
|
1
|
+
import { collectPiiSubjectFields, piiCiphertextMaxLengthFor, } from "@cosmicdrift/kumiko-framework/crypto";
|
|
2
|
+
import { deriveEntityTableMeta, isSchemaTable, physicalColumnName, } from "@cosmicdrift/kumiko-framework/db";
|
|
3
3
|
import { access, createBooleanField, createEntity, createFilesField, createLongTextField, createNumberField, createTextField, createTimestampField, } from "@cosmicdrift/kumiko-framework/engine";
|
|
4
4
|
import { DEFAULT_INBOUND_MAIL_ADMIN_ROLES, DEFAULT_INBOUND_MAIL_USER_ROLES } from "./mail-roles.js";
|
|
5
|
+
import { INBOUND_ADDRESS_LIST_JSON_MAX_CHARS, INBOUND_BODY_HTML_MAX_BYTES, INBOUND_BODY_TEXT_MAX_CHARS, INBOUND_FROM_MAX_CHARS, INBOUND_MAIL_ADDRESS_MAX_CHARS, INBOUND_SNIPPET_MAX_CHARS, INBOUND_SUBJECT_MAX_CHARS, } from "./normalize-inbound-message.js";
|
|
5
6
|
// ============================================================================
|
|
6
7
|
// Read models for the three event-sourced aggregates
|
|
7
8
|
// ============================================================================
|
|
@@ -14,8 +15,8 @@ import { DEFAULT_INBOUND_MAIL_ADMIN_ROLES, DEFAULT_INBOUND_MAIL_USER_ROLES } fro
|
|
|
14
15
|
// **PII convention:** `personal: "tenant"` (not `encrypted`): fields must
|
|
15
16
|
// be crypto-shredded when eraseSubjectKeys deletes the tenant subject key on
|
|
16
17
|
// tenant destruction (pattern from billing-foundation).
|
|
17
|
-
//
|
|
18
|
-
// <
|
|
18
|
+
// The projection holds ciphertext, so these fields' maxLength comes from
|
|
19
|
+
// piiCiphertextMaxLengthFor(<plaintext limit>).
|
|
19
20
|
//
|
|
20
21
|
// **Design decision:** The PII subject of an inbound mail is currently the
|
|
21
22
|
// TENANT (mailbox owner), not the external sender. A sender-forget flow would
|
|
@@ -50,7 +51,12 @@ export const mailAccountEntity = createEntity({
|
|
|
50
51
|
reason: "tenant_config_not_personal",
|
|
51
52
|
}),
|
|
52
53
|
// Mailbox address — tenant PII.
|
|
53
|
-
address: createTextField({
|
|
54
|
+
address: createTextField({
|
|
55
|
+
required: true,
|
|
56
|
+
maxLength: piiCiphertextMaxLengthFor(INBOUND_MAIL_ADDRESS_MAX_CHARS),
|
|
57
|
+
personal: "tenant",
|
|
58
|
+
find: "none",
|
|
59
|
+
}),
|
|
54
60
|
status: createTextField({
|
|
55
61
|
required: true,
|
|
56
62
|
maxLength: 30,
|
|
@@ -76,6 +82,9 @@ function ownMailboxOrSharedRead(memberRoles) {
|
|
|
76
82
|
const rule = {
|
|
77
83
|
kind: "where",
|
|
78
84
|
where: (user, ctx) => {
|
|
85
|
+
if (!isSchemaTable(ctx.table)) {
|
|
86
|
+
throw new Error(`${ctx.tableName}: ownership rule received a table not built by table()`);
|
|
87
|
+
}
|
|
79
88
|
const owner = `"${ctx.tableName}"."${physicalColumnName(ctx.table, "ownerUserId")}"`;
|
|
80
89
|
return {
|
|
81
90
|
sqlText: `(${owner} IS NULL OR ${owner} = '' OR ${owner} = $${ctx.paramStart})`,
|
|
@@ -114,21 +123,51 @@ export function createInboundMessageEntity(memberRoles) {
|
|
|
114
123
|
personal: false,
|
|
115
124
|
reason: "technical_reference",
|
|
116
125
|
}),
|
|
117
|
-
from: createTextField({
|
|
126
|
+
from: createTextField({
|
|
127
|
+
required: true,
|
|
128
|
+
maxLength: piiCiphertextMaxLengthFor(INBOUND_FROM_MAX_CHARS),
|
|
129
|
+
personal: "tenant",
|
|
130
|
+
find: "none",
|
|
131
|
+
}),
|
|
118
132
|
// JSON-stringified string[] — als Ganzes encrypted.
|
|
119
|
-
to: createTextField({
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
133
|
+
to: createTextField({
|
|
134
|
+
maxLength: piiCiphertextMaxLengthFor(INBOUND_ADDRESS_LIST_JSON_MAX_CHARS),
|
|
135
|
+
personal: "tenant",
|
|
136
|
+
find: "none",
|
|
137
|
+
}),
|
|
138
|
+
cc: createTextField({
|
|
139
|
+
maxLength: piiCiphertextMaxLengthFor(INBOUND_ADDRESS_LIST_JSON_MAX_CHARS),
|
|
140
|
+
personal: "tenant",
|
|
141
|
+
find: "none",
|
|
142
|
+
}),
|
|
143
|
+
subject: createTextField({
|
|
144
|
+
maxLength: piiCiphertextMaxLengthFor(INBOUND_SUBJECT_MAX_CHARS),
|
|
145
|
+
personal: "tenant",
|
|
146
|
+
find: "none",
|
|
147
|
+
}),
|
|
148
|
+
snippet: createTextField({
|
|
149
|
+
maxLength: piiCiphertextMaxLengthFor(INBOUND_SNIPPET_MAX_CHARS),
|
|
150
|
+
personal: "tenant",
|
|
151
|
+
find: "none",
|
|
152
|
+
}),
|
|
123
153
|
receivedAt: createTimestampField({ required: true }),
|
|
124
154
|
bodyRef: createTextField({ maxLength: 500, personal: false, reason: "technical_reference" }),
|
|
125
155
|
scope: createTextField({ maxLength: 200, personal: false, reason: "technical_reference" }),
|
|
126
|
-
// Full plaintext, capped at 32_000 characters before encryption (ciphertext is ~2.3x plus envelope).
|
|
127
156
|
// Null on rows from before the column; list-messages never selects it.
|
|
128
|
-
|
|
157
|
+
// Plaintext is clipped to INBOUND_BODY_TEXT_MAX_CHARS (32_000) before encryption.
|
|
158
|
+
bodyText: createLongTextField({
|
|
159
|
+
maxLength: piiCiphertextMaxLengthFor(INBOUND_BODY_TEXT_MAX_CHARS),
|
|
160
|
+
personal: "tenant",
|
|
161
|
+
find: "none",
|
|
162
|
+
}),
|
|
129
163
|
bodyTextTruncated: createBooleanField(),
|
|
130
|
-
// Sanitized HTML of the mail
|
|
131
|
-
|
|
164
|
+
// Sanitized HTML of the mail, null when the mail has none or it was too large: sanitizeInboundHtml
|
|
165
|
+
// drops anything over 500_000 bytes after sanitizing, before encryption.
|
|
166
|
+
bodyHtml: createLongTextField({
|
|
167
|
+
maxLength: piiCiphertextMaxLengthFor(INBOUND_BODY_HTML_MAX_BYTES),
|
|
168
|
+
personal: "tenant",
|
|
169
|
+
find: "none",
|
|
170
|
+
}),
|
|
132
171
|
// Bound to the message (entityType = the aggregate type), so the file guard answers with the
|
|
133
172
|
// mail's visibility. The fileRefs are bound at ingest, the projection copies the ids.
|
|
134
173
|
attachmentFileIds: createFilesField({ personal: false, reason: "technical_reference" }),
|
|
@@ -177,7 +216,11 @@ export const mailThreadEntity = createEntity({
|
|
|
177
216
|
personal: false,
|
|
178
217
|
reason: "technical_reference",
|
|
179
218
|
}),
|
|
180
|
-
subject: createTextField({
|
|
219
|
+
subject: createTextField({
|
|
220
|
+
maxLength: piiCiphertextMaxLengthFor(INBOUND_SUBJECT_MAX_CHARS),
|
|
221
|
+
personal: "tenant",
|
|
222
|
+
find: "none",
|
|
223
|
+
}),
|
|
181
224
|
lastMessageAt: createTimestampField({ required: true }),
|
|
182
225
|
messageCount: createNumberField({ required: true, integer: true }),
|
|
183
226
|
},
|
|
@@ -19,8 +19,10 @@
|
|
|
19
19
|
// write handler — the subject key is the tenant, and tenant destruction's
|
|
20
20
|
// eraseSubjectKeys makes both the event log and projection unreadable
|
|
21
21
|
// (crypto-shredding, the billing-foundation pattern).
|
|
22
|
+
import { piiCiphertextMaxLengthFor } from "@cosmicdrift/kumiko-framework/crypto";
|
|
22
23
|
import * as z from "zod";
|
|
23
24
|
import { INBOUND_MAIL_FOUNDATION_FEATURE, InboundMailAccountStatuses } from "./constants.js";
|
|
25
|
+
import { INBOUND_ADDRESS_LIST_JSON_MAX_CHARS, INBOUND_BODY_HTML_MAX_BYTES, INBOUND_BODY_TEXT_MAX_CHARS, INBOUND_FROM_MAX_CHARS, INBOUND_MAIL_ADDRESS_MAX_CHARS, INBOUND_SNIPPET_MAX_CHARS, INBOUND_SUBJECT_MAX_CHARS, } from "./normalize-inbound-message.js";
|
|
24
26
|
import { senderAuthenticationFieldSchema } from "./sender-auth.js";
|
|
25
27
|
// Aggregate types for the event store.
|
|
26
28
|
export const MAIL_ACCOUNT_AGGREGATE_TYPE = "mail-account";
|
|
@@ -51,9 +53,7 @@ const accountStatusEnum = z.enum([
|
|
|
51
53
|
// ============================================================================
|
|
52
54
|
//
|
|
53
55
|
// One stream per mailbox (aggregateId = accountId, random UUID on connect).
|
|
54
|
-
// address is PII
|
|
55
|
-
// (a 200-character plaintext becomes ~460+ characters in a JSON envelope;
|
|
56
|
-
// see billing-foundation events.ts).
|
|
56
|
+
// address is PII ciphertext; its plaintext is capped at 320 characters by connect-account.write.ts.
|
|
57
57
|
export const mailAccountEventPayloadSchema = z.object({
|
|
58
58
|
provider: z.string().min(1).max(50),
|
|
59
59
|
/** "password" | "xoauth2" | "oauth" (InboundMailAuthMethods) — deliberately
|
|
@@ -63,7 +63,7 @@ export const mailAccountEventPayloadSchema = z.object({
|
|
|
63
63
|
/** null = shared by the tenant; otherwise, this user's personal mailbox. */
|
|
64
64
|
ownerUserId: z.string().max(36).nullable(),
|
|
65
65
|
displayName: z.string().max(200),
|
|
66
|
-
address: z.string().min(1).max(
|
|
66
|
+
address: z.string().min(1).max(piiCiphertextMaxLengthFor(INBOUND_MAIL_ADDRESS_MAX_CHARS)),
|
|
67
67
|
status: accountStatusEnum,
|
|
68
68
|
/** Provider-agnostic watch state ("idle", "watching", "backoff:3", ...)
|
|
69
69
|
* — an operational signal only, not PII. */
|
|
@@ -94,12 +94,12 @@ export const skippedAttachmentSchema = z.object({
|
|
|
94
94
|
]),
|
|
95
95
|
});
|
|
96
96
|
// Shared by inbound-message-received (v2+) and inbound-message-content-fetched.
|
|
97
|
-
// bodyText is ciphertext
|
|
97
|
+
// bodyText is ciphertext of at most INBOUND_BODY_TEXT_MAX_CHARS (32_000) characters.
|
|
98
98
|
const inboundMessageContentShape = {
|
|
99
|
-
bodyText: z.string().max(
|
|
99
|
+
bodyText: z.string().max(piiCiphertextMaxLengthFor(INBOUND_BODY_TEXT_MAX_CHARS)),
|
|
100
100
|
bodyTextTruncated: z.boolean(),
|
|
101
|
-
/** Sanitized HTML body
|
|
102
|
-
bodyHtml: z.string().max(
|
|
101
|
+
/** Sanitized HTML body as PII ciphertext. sanitizeInboundHtml drops anything over 500_000 bytes after sanitizing. Null: none or too large. */
|
|
102
|
+
bodyHtml: z.string().max(piiCiphertextMaxLengthFor(INBOUND_BODY_HTML_MAX_BYTES)).nullable(),
|
|
103
103
|
/** file-foundation FileRef ids (plaintext uuids). Attachments outlive the mail: apps turn them
|
|
104
104
|
* into documents, so the retention sweep never deletes them. */
|
|
105
105
|
attachmentFileIds: z.array(z.uuid()).max(50),
|
|
@@ -114,8 +114,8 @@ const inboundMessageContentShape = {
|
|
|
114
114
|
// aggregateId = inboundMessageAggregateId(accountId, providerMessageId)
|
|
115
115
|
// → deterministic, so provider replays collide on the same stream.
|
|
116
116
|
//
|
|
117
|
-
// PII fields (from/to/cc/subject/snippet):
|
|
118
|
-
//
|
|
117
|
+
// PII fields (from/to/cc/subject/snippet): the maxima are the ciphertext
|
|
118
|
+
// size of the plaintext limits in ingest-message-schema.ts. to/cc are JSON-stringified string[] BEFORE encryption;
|
|
119
119
|
// the payload contains the ciphertext string, not the array (primitives only,
|
|
120
120
|
// upcaster-safe).
|
|
121
121
|
export const inboundMessageEventPayloadSchema = z.object({
|
|
@@ -128,13 +128,13 @@ export const inboundMessageEventPayloadSchema = z.object({
|
|
|
128
128
|
/** Normalized thread key (References-chain root or provider thread ID,
|
|
129
129
|
* prefixed by the provider). */
|
|
130
130
|
threadKey: z.string().min(1).max(500),
|
|
131
|
-
from: z.string().min(1).max(
|
|
131
|
+
from: z.string().min(1).max(piiCiphertextMaxLengthFor(INBOUND_FROM_MAX_CHARS)),
|
|
132
132
|
/** JSON-stringified string[], dann PII-encrypted. */
|
|
133
|
-
to: z.string().max(
|
|
133
|
+
to: z.string().max(piiCiphertextMaxLengthFor(INBOUND_ADDRESS_LIST_JSON_MAX_CHARS)),
|
|
134
134
|
/** JSON-stringified string[], dann PII-encrypted. */
|
|
135
|
-
cc: z.string().max(
|
|
136
|
-
subject: z.string().max(
|
|
137
|
-
snippet: z.string().max(
|
|
135
|
+
cc: z.string().max(piiCiphertextMaxLengthFor(INBOUND_ADDRESS_LIST_JSON_MAX_CHARS)),
|
|
136
|
+
subject: z.string().max(piiCiphertextMaxLengthFor(INBOUND_SUBJECT_MAX_CHARS)),
|
|
137
|
+
snippet: z.string().max(piiCiphertextMaxLengthFor(INBOUND_SNIPPET_MAX_CHARS)),
|
|
138
138
|
/** ISO instant — receipt time reported by the provider (INTERNALDATE or
|
|
139
139
|
* receivedDateTime), not ingest time. */
|
|
140
140
|
receivedAtIso: z.string().min(1),
|
|
@@ -166,7 +166,7 @@ export const inboundMessageContentFetchedEventPayloadSchema = z.object({
|
|
|
166
166
|
// ============================================================================
|
|
167
167
|
export const mailThreadEventPayloadSchema = z.object({
|
|
168
168
|
threadKey: z.string().min(1).max(500),
|
|
169
|
-
subject: z.string().max(
|
|
169
|
+
subject: z.string().max(piiCiphertextMaxLengthFor(INBOUND_SUBJECT_MAX_CHARS)),
|
|
170
170
|
lastMessageAtIso: z.string().min(1),
|
|
171
171
|
messageCount: z.number().int().min(1),
|
|
172
172
|
});
|
|
@@ -28,6 +28,7 @@ import { createAcknowledgeQuarantineHandler } from "./handlers/acknowledge-quara
|
|
|
28
28
|
import { attachMessageContentHandler } from "./handlers/attach-message-content.write.js";
|
|
29
29
|
import { createConnectAccountHandler } from "./handlers/connect-account.write.js";
|
|
30
30
|
import { createDisconnectAccountHandler } from "./handlers/disconnect-account.write.js";
|
|
31
|
+
import { createForgetMessageHandler } from "./handlers/forget-message.write.js";
|
|
31
32
|
import { ingestMessageHandler } from "./handlers/ingest-message.write.js";
|
|
32
33
|
import { createListAccountsQuery } from "./handlers/list-accounts.query.js";
|
|
33
34
|
import { createListMessagesQuery } from "./handlers/list-messages.query.js";
|
|
@@ -54,7 +55,7 @@ export function createInboundMailFoundationFeature(options = {}) {
|
|
|
54
55
|
const roles = resolveInboundMailRoles(options);
|
|
55
56
|
return defineFeature(INBOUND_MAIL_FOUNDATION_FEATURE, (r) => {
|
|
56
57
|
r.adoptsBundledLists();
|
|
57
|
-
r.describe("Plugin host for inbound e-mail (inbox federation) — provider plugins (inbound-provider-imap, later M365 Graph / Gmail REST) register at the `inboundMailProvider` extension point with verify/fetch and optional oauth/watch (live push) and send. `sendMailFromAccount(ctx, { accountId, message })` sends from a connected mailbox through its provider (From = the mailbox address, no fallback to the app sender) and answers typed failures (not configured, login rejected, server unreachable, rejected, invalid message); app write handlers call it, it is no endpoint of its own. The foundation owns three event-sourced streams (mail-account lifecycle, inbound-message with exactly-once ingest via deterministic aggregate ids, mail-thread rollup) and their projections `read_mail_accounts`/`read_inbound_messages`/`read_mail_threads`; PII fields are envelope-encrypted per tenant subject key before every append (crypto-shredding on tenant destroy). Wire `createInboundMailConnectRoutes` (OAuth connect + anonymous callback outside /api) and `createInboundMailSupervisor` (IDLE watch with backoff + reconciliation poll) in bin/server.ts. Consume `inbound-mail-foundation:event:inbound-message-received` from app features to attach business processes.");
|
|
58
|
+
r.describe("Plugin host for inbound e-mail (inbox federation) — provider plugins (inbound-provider-imap, later M365 Graph / Gmail REST) register at the `inboundMailProvider` extension point with verify/fetch and optional oauth/watch (live push) and send. `sendMailFromAccount(ctx, { accountId, message })` sends from a connected mailbox through its provider (From = the mailbox address, no fallback to the app sender) and answers typed failures (not configured, login rejected, server unreachable, rejected, invalid message); app write handlers call it from `beforeTransaction` (it sends at once and a rollback cannot recall the mail), it is no endpoint of its own. The foundation owns three event-sourced streams (mail-account lifecycle, inbound-message with exactly-once ingest via deterministic aggregate ids, mail-thread rollup) and their projections `read_mail_accounts`/`read_inbound_messages`/`read_mail_threads`; PII fields are envelope-encrypted per tenant subject key before every append (crypto-shredding on tenant destroy). Wire `createInboundMailConnectRoutes` (OAuth connect + anonymous callback outside /api) and `createInboundMailSupervisor` (IDLE watch with backoff + reconciliation poll) in bin/server.ts. Consume `inbound-mail-foundation:event:inbound-message-received` from app features to attach business processes.");
|
|
58
59
|
r.uiHints({
|
|
59
60
|
displayLabel: "Inbound Mail · Foundation",
|
|
60
61
|
category: "notifications",
|
|
@@ -194,6 +195,7 @@ export function createInboundMailFoundationFeature(options = {}) {
|
|
|
194
195
|
r.writeHandler(createReactivateAccountHandler(roles));
|
|
195
196
|
r.writeHandler(createSetTrustedAuthservIdHandler(roles));
|
|
196
197
|
r.writeHandler(createAcknowledgeQuarantineHandler(roles));
|
|
198
|
+
r.writeHandler(createForgetMessageHandler(roles));
|
|
197
199
|
r.writeHandler(createRetryQuarantinedMessageHandler(roles));
|
|
198
200
|
r.writeHandler(attachMessageContentHandler);
|
|
199
201
|
r.writeHandler(markCredentialStoredHandler);
|
|
@@ -7,8 +7,8 @@ export type AddressMatch = {
|
|
|
7
7
|
readonly status: string;
|
|
8
8
|
};
|
|
9
9
|
export declare function normalizeMailAddress(address: string): string;
|
|
10
|
-
export declare function findMailboxByAddress(ctx: Pick<HandlerContext, "db">, tenantId: string, address: string): Promise<AddressMatch | undefined>;
|
|
11
|
-
export type ConnectConflict = "already_connected" | "address_disconnected" | "reopen_in_place";
|
|
10
|
+
export declare function findMailboxByAddress(ctx: Pick<HandlerContext, "db">, tenantId: string, address: string, wantedOwnerUserId: string | null): Promise<AddressMatch | undefined>;
|
|
11
|
+
export type ConnectConflict = "already_connected" | "address_disconnected" | "reopen_in_place" | "replace_disconnected_personal";
|
|
12
12
|
export declare function connectConflictOf(existing: AddressMatch, wanted: {
|
|
13
13
|
readonly authMethod: string;
|
|
14
14
|
readonly provider: string;
|
|
@@ -11,7 +11,9 @@ function textOf(value) {
|
|
|
11
11
|
return typeof value === "string" ? value : "";
|
|
12
12
|
}
|
|
13
13
|
// A live mailbox wins over a disconnected one: connecting next to a live mailbox is always a duplicate.
|
|
14
|
-
|
|
14
|
+
// Among equals the mailbox of the wanted owner kind (shared or personal) wins, then the smallest id,
|
|
15
|
+
// so the outcome does not depend on projection row order.
|
|
16
|
+
export async function findMailboxByAddress(ctx, tenantId, address, wantedOwnerUserId) {
|
|
15
17
|
const wanted = normalizeMailAddress(address);
|
|
16
18
|
const rows = await ctx.db.selectMany(mailAccountsProjectionTable, { tenantId });
|
|
17
19
|
const piiKms = configuredPiiSubjectKms();
|
|
@@ -32,7 +34,9 @@ export async function findMailboxByAddress(ctx, tenantId, address) {
|
|
|
32
34
|
status: textOf(row["status"]),
|
|
33
35
|
});
|
|
34
36
|
}
|
|
35
|
-
|
|
37
|
+
const rank = (m) => (m.status === InboundMailAccountStatuses.disconnected ? 2 : 0) +
|
|
38
|
+
((m.ownerUserId === null) === (wantedOwnerUserId === null) ? 0 : 1);
|
|
39
|
+
return [...matches].sort((a, b) => rank(a) - rank(b) || a.id.localeCompare(b.id))[0];
|
|
36
40
|
}
|
|
37
41
|
// A disconnected or sign-in-failed OAuth mailbox of the same provider and owner is reopened (the
|
|
38
42
|
// callback writes the new token into the same slot); everything else must not silently create a second stream for one address.
|
|
@@ -42,6 +46,10 @@ export function connectConflictOf(existing, wanted) {
|
|
|
42
46
|
const signInFailed = existing.status === InboundMailAccountStatuses.authError;
|
|
43
47
|
if (!disconnected && !signInFailed)
|
|
44
48
|
return "already_connected";
|
|
49
|
+
// A member's disconnected personal mailbox must not lock the address for the team's shared one.
|
|
50
|
+
if (disconnected && wanted.ownerUserId === null && existing.ownerUserId !== null) {
|
|
51
|
+
return "replace_disconnected_personal";
|
|
52
|
+
}
|
|
45
53
|
const bothOauth = wanted.authMethod === InboundMailAuthMethods.oauth &&
|
|
46
54
|
existing.authMethod === InboundMailAuthMethods.oauth &&
|
|
47
55
|
existing.provider === wanted.provider;
|
|
@@ -28,10 +28,12 @@ function hasContentAlready(events) {
|
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
30
|
const receivedOwnerSchema = z.object({ ownerUserId: z.string().nullable() });
|
|
31
|
-
|
|
31
|
+
// `null` inside the result means a shared mailbox; an unreadable stream has no result at all, so a
|
|
32
|
+
// personal mail can never fall through to the shared routing.
|
|
33
|
+
function ownerOfStream(events) {
|
|
32
34
|
const received = events.find((e) => e.type === INBOUND_MESSAGE_RECEIVED_EVENT_QN);
|
|
33
35
|
const parsed = receivedOwnerSchema.safeParse(received?.payload);
|
|
34
|
-
return parsed.success ? parsed.data.ownerUserId :
|
|
36
|
+
return parsed.success ? { ownerUserId: parsed.data.ownerUserId } : undefined;
|
|
35
37
|
}
|
|
36
38
|
// Read before the transaction, so it can only skip work: a row that already shows attached content
|
|
37
39
|
// spares parallel refetches the upload. The event check under the message lock stays authoritative.
|
|
@@ -108,12 +110,15 @@ export const attachMessageContentHandler = defineWriteHandler({
|
|
|
108
110
|
if (hasContentAlready(events)) {
|
|
109
111
|
return { isSuccess: true, data: { duplicate: true } };
|
|
110
112
|
}
|
|
113
|
+
const owner = ownerOfStream(events);
|
|
114
|
+
if (owner === undefined)
|
|
115
|
+
return failNotFound("inbound-message-received-event", messageAggId);
|
|
111
116
|
const content = payload.outcome !== "fetched"
|
|
112
117
|
? undefined
|
|
113
118
|
: prepared
|
|
114
119
|
? await finalizePreparedContent(ctx, prepared)
|
|
115
120
|
: await storeInboundMessageContent(ctx, contentInputOf(payload, messageAggId));
|
|
116
|
-
const eventPayload = await contentEventPayloadOf(payload, content, tenantId, messageAggId,
|
|
121
|
+
const eventPayload = await contentEventPayloadOf(payload, content, tenantId, messageAggId, owner.ownerUserId);
|
|
117
122
|
const appended = await ctx.events.tryAppend({
|
|
118
123
|
aggregateId: messageAggId,
|
|
119
124
|
aggregateType: INBOUND_MESSAGE_AGGREGATE_TYPE,
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
// stays fast and offline-capable (the test result arrives asynchronously
|
|
13
13
|
// as a status transition).
|
|
14
14
|
// - No second account for one address: a live or disconnected address is
|
|
15
|
-
// refused (409 reasons in InboundMailConnectErrors); only a disconnected or
|
|
15
|
+
// refused (a disconnected personal mailbox gives way to a shared one) (409 reasons in InboundMailConnectErrors); only a disconnected or
|
|
16
16
|
// sign-in-failed OAuth mailbox is reopened in place, keeping its account id and cursor.
|
|
17
17
|
// The reopen returns the existing id and changes nothing yet; the callback re-arms it.
|
|
18
18
|
import { configuredPiiSubjectKms, encryptPiiFieldValues, } from "@cosmicdrift/kumiko-framework/crypto";
|
|
@@ -22,7 +22,10 @@ import { InboundMailAccountStatuses, InboundMailAuthMethods, InboundMailConnectE
|
|
|
22
22
|
import { MAIL_ACCOUNT_PII_FIELDS, mailAccountEntity } from "../entities.js";
|
|
23
23
|
import { MAIL_ACCOUNT_AGGREGATE_TYPE, MAIL_ACCOUNT_CONNECTED_EVENT_QN, } from "../events.js";
|
|
24
24
|
import { accessRolesOf } from "../mail-roles.js";
|
|
25
|
-
import {
|
|
25
|
+
import { INBOUND_MAIL_ADDRESS_MAX_CHARS } from "../normalize-inbound-message.js";
|
|
26
|
+
import { connectConflictOf, findMailboxByAddress, normalizeMailAddress, } from "./account-address.js";
|
|
27
|
+
// 'inma': serializes the duplicate-address check and the append per tenant and address (the lock key is tenant-scoped).
|
|
28
|
+
const CONNECT_ADDRESS_LOCK_NAMESPACE = 0x696e6d61;
|
|
26
29
|
export const connectAccountSchema = z
|
|
27
30
|
.object({
|
|
28
31
|
/** Provider key registered with the extension ("imap",
|
|
@@ -35,7 +38,7 @@ export const connectAccountSchema = z
|
|
|
35
38
|
]),
|
|
36
39
|
displayName: z.string().trim().max(200),
|
|
37
40
|
/** Mailbox address in plaintext; it is encrypted here. */
|
|
38
|
-
address: z.string().min(1).max(
|
|
41
|
+
address: z.string().min(1).max(INBOUND_MAIL_ADDRESS_MAX_CHARS),
|
|
39
42
|
/** "shared" = shared across the tenant (info@) · "user" = the caller's
|
|
40
43
|
* personal mailbox (ownerUserId is taken from the session, never from
|
|
41
44
|
* the payload—preventing claims on another user's mailbox). */
|
|
@@ -70,7 +73,8 @@ export function createConnectAccountHandler({ adminRoles }) {
|
|
|
70
73
|
: payload.scope === "user"
|
|
71
74
|
? event.user.id
|
|
72
75
|
: null;
|
|
73
|
-
|
|
76
|
+
await ctx.db.advisoryXactLock(CONNECT_ADDRESS_LOCK_NAMESPACE, normalizeMailAddress(payload.address));
|
|
77
|
+
const existing = await findMailboxByAddress(ctx, tenantId, payload.address, ownerUserId);
|
|
74
78
|
if (existing) {
|
|
75
79
|
const matched = connectConflictOf(existing, {
|
|
76
80
|
authMethod: payload.authMethod,
|
|
@@ -90,10 +94,12 @@ export function createConnectAccountHandler({ adminRoles }) {
|
|
|
90
94
|
data: { accountId: existing.id, reconnected: true },
|
|
91
95
|
};
|
|
92
96
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
+
if (conflict !== "replace_disconnected_personal") {
|
|
98
|
+
const { reason, i18nKey } = conflict === "address_disconnected"
|
|
99
|
+
? InboundMailConnectErrors.addressDisconnected
|
|
100
|
+
: InboundMailConnectErrors.addressAlreadyConnected;
|
|
101
|
+
return writeFailure(new UnprocessableError(reason, { i18nKey }));
|
|
102
|
+
}
|
|
97
103
|
}
|
|
98
104
|
// PII-encrypt the address before the append. This is the only write path to
|
|
99
105
|
// the stream, so it covers both the event log and the projection.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { WriteHandlerDef } from "@cosmicdrift/kumiko-framework/engine";
|
|
2
|
+
import * as z from "zod";
|
|
3
|
+
import type { InboundMailRoles } from "../mail-roles.ts";
|
|
4
|
+
export declare const forgetMessageSchema: z.ZodObject<{
|
|
5
|
+
messageId: z.ZodUUID;
|
|
6
|
+
}, z.core.$strip>;
|
|
7
|
+
export declare function createForgetMessageHandler({ memberRoles, adminRoles, }: InboundMailRoles): WriteHandlerDef;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { AccessDeniedError, failNotFound, writeFailure, } from "@cosmicdrift/kumiko-framework/errors";
|
|
2
|
+
import { deleteFileRefsBoundToRecord } from "@cosmicdrift/kumiko-framework/files";
|
|
3
|
+
import * as z from "zod";
|
|
4
|
+
import { INBOUND_MESSAGE_AGGREGATE_TYPE } from "../events.js";
|
|
5
|
+
import { inboundMessagesProjectionTable } from "../projection.js";
|
|
6
|
+
import { purgeInboundMessages } from "../purge-messages.js";
|
|
7
|
+
import { isVisibleToCaller, mayReactivateMailbox } from "./scope-visibility.js";
|
|
8
|
+
export const forgetMessageSchema = z.object({ messageId: z.uuid() });
|
|
9
|
+
const FORGET_REASON = "forgotten_by_user";
|
|
10
|
+
export function createForgetMessageHandler({ memberRoles, adminRoles, }) {
|
|
11
|
+
return {
|
|
12
|
+
name: "forget-message",
|
|
13
|
+
schema: forgetMessageSchema,
|
|
14
|
+
access: { roles: [...memberRoles] },
|
|
15
|
+
agent: { risk: "high" },
|
|
16
|
+
description: "Permanently removes one imported mail: the read row, the stored original and its attachment files; the mail cannot be restored and a later sync does not import it again. The owner of a personal mailbox or, for a shared one, an admin may call it; a mail of someone else's personal mailbox is reported as not found.",
|
|
17
|
+
handler: async (event, ctx) => {
|
|
18
|
+
const { messageId } = forgetMessageSchema.parse(event.payload);
|
|
19
|
+
const [row] = await ctx.db.selectMany(inboundMessagesProjectionTable, { id: messageId });
|
|
20
|
+
if (!row || !isVisibleToCaller(row, event.user)) {
|
|
21
|
+
return failNotFound("inbound-message", messageId);
|
|
22
|
+
}
|
|
23
|
+
if (!mayReactivateMailbox(row.ownerUserId, event.user, adminRoles)) {
|
|
24
|
+
return writeFailure(new AccessDeniedError({ details: { reason: "not_mailbox_owner" } }));
|
|
25
|
+
}
|
|
26
|
+
const { files } = ctx.services;
|
|
27
|
+
// Without file storage the original could not be deleted, and the row held its only reference.
|
|
28
|
+
if (row.bodyRef && !files) {
|
|
29
|
+
throw new Error(`forget-message: no file storage to delete the stored original of ${messageId}`);
|
|
30
|
+
}
|
|
31
|
+
const purged = await purgeInboundMessages({
|
|
32
|
+
db: ctx.db,
|
|
33
|
+
tenantId: event.user.tenantId,
|
|
34
|
+
rows: [row],
|
|
35
|
+
archive: (id) => ctx.events.archive(id, {
|
|
36
|
+
aggregateType: INBOUND_MESSAGE_AGGREGATE_TYPE,
|
|
37
|
+
reason: FORGET_REASON,
|
|
38
|
+
}),
|
|
39
|
+
deleteBodyObject: files
|
|
40
|
+
? (bodyRef) => files.refFromFileRef({ storageKey: bodyRef }).delete()
|
|
41
|
+
: undefined,
|
|
42
|
+
deleteAttachments: async (id) => {
|
|
43
|
+
await deleteFileRefsBoundToRecord({
|
|
44
|
+
db: ctx.db,
|
|
45
|
+
user: event.user,
|
|
46
|
+
entityType: INBOUND_MESSAGE_AGGREGATE_TYPE,
|
|
47
|
+
entityId: id,
|
|
48
|
+
});
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
// Rolls the archive back: a half-deleted mail must stay retryable.
|
|
52
|
+
if (purged.failedIds.length > 0) {
|
|
53
|
+
throw new Error(`forget-message: the stored files of ${messageId} could not be deleted`);
|
|
54
|
+
}
|
|
55
|
+
return { isSuccess: true, data: { forgotten: true } };
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as z from "zod";
|
|
2
|
+
import { INBOUND_ADDRESS_LIST_JSON_MAX_CHARS, INBOUND_FROM_MAX_CHARS, INBOUND_SNIPPET_MAX_CHARS, INBOUND_SUBJECT_MAX_CHARS, } from "../normalize-inbound-message.js";
|
|
2
3
|
import { senderAuthenticationFieldSchema } from "../sender-auth.js";
|
|
3
4
|
import { inboundContentPayloadShape } from "./message-content.js";
|
|
4
5
|
// =============================================================================
|
|
@@ -7,6 +8,12 @@ import { inboundContentPayloadShape } from "./message-content.js";
|
|
|
7
8
|
// original and attachments ride in-process as bytes and are persisted to file
|
|
8
9
|
// storage here; the event itself stays blob-free (references only).
|
|
9
10
|
// =============================================================================
|
|
11
|
+
const addressListSchema = z
|
|
12
|
+
.array(z.string().max(2000))
|
|
13
|
+
.max(200)
|
|
14
|
+
.refine((list) => JSON.stringify(list).length <= INBOUND_ADDRESS_LIST_JSON_MAX_CHARS, {
|
|
15
|
+
message: "serialized address list too long",
|
|
16
|
+
});
|
|
10
17
|
export const ingestMessageSchema = z.object({
|
|
11
18
|
accountId: z.uuid(),
|
|
12
19
|
/** Scope inherited from the account — the supervisor knows the
|
|
@@ -20,11 +27,11 @@ export const ingestMessageSchema = z.object({
|
|
|
20
27
|
providerThreadId: z.string().min(1).max(500).nullable(),
|
|
21
28
|
/** References/In-Reply-To chain, oldest first. */
|
|
22
29
|
references: z.array(z.string().min(1).max(500)).max(200),
|
|
23
|
-
from: z.string().min(1).max(
|
|
24
|
-
to:
|
|
25
|
-
cc:
|
|
26
|
-
subject: z.string().max(
|
|
27
|
-
snippet: z.string().max(
|
|
30
|
+
from: z.string().min(1).max(INBOUND_FROM_MAX_CHARS),
|
|
31
|
+
to: addressListSchema,
|
|
32
|
+
cc: addressListSchema,
|
|
33
|
+
subject: z.string().max(INBOUND_SUBJECT_MAX_CHARS),
|
|
34
|
+
snippet: z.string().max(INBOUND_SNIPPET_MAX_CHARS),
|
|
28
35
|
receivedAtIso: z.string().min(1),
|
|
29
36
|
/** From the app's storeBody hook; empty lets the handler store the original itself. */
|
|
30
37
|
bodyRef: z.string().max(500),
|