@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
package/dist/helpdesk/lib.js
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
|
+
import { ROLES } from "@cosmicdrift/kumiko-framework/auth";
|
|
1
2
|
import { createEventStoreExecutor, fetchOne, selectMany, } from "@cosmicdrift/kumiko-framework/db";
|
|
2
3
|
import { access, createSystemUser, SYSTEM_TENANT_ID, } from "@cosmicdrift/kumiko-framework/engine";
|
|
3
|
-
import { InternalError } from "@cosmicdrift/kumiko-framework/errors";
|
|
4
4
|
import { propertyOf } from "@cosmicdrift/kumiko-types/type-guards";
|
|
5
|
-
import { decryptStoredPii } from "../shared/index.js";
|
|
5
|
+
import { acknowledgedSystemDb, decryptStoredPii, sendBestEffort as sendSharedBestEffort, } from "../shared/index.js";
|
|
6
6
|
import { tenantTable } from "../tenant/index.js";
|
|
7
7
|
import { TierEngineQueries } from "../tier-engine/index.js";
|
|
8
8
|
import { USER_STATUS, userTable } from "../user/index.js";
|
|
9
9
|
import { helpdeskReplyEntity, helpdeskReplyTable, helpdeskRequestEntity, helpdeskRequestTable, } from "./entity.js";
|
|
10
|
-
import { HELPDESK_REPLY_CHANNELS, HELPDESK_REPLY_ENTITY, HELPDESK_REQUEST_ENTITY, HelpdeskErrors, } from "./web/constants.js";
|
|
10
|
+
import { HELPDESK_REPLY_CHANNELS, HELPDESK_REPLY_ENTITY, HELPDESK_REQUEST_ENTITY, HelpdeskErrors, HelpdeskHandlers, } from "./web/constants.js";
|
|
11
11
|
export const IN_APP_FEATURE = "channel-in-app";
|
|
12
12
|
export const TELEGRAM_FEATURE = "channel-telegram";
|
|
13
13
|
export const HELPDESK_CROSS_TENANT_REASON = "helpdesk is platform-wide (systemScope)";
|
|
14
|
-
export const SYSTEM_ADMIN_ROLE = "SystemAdmin";
|
|
15
14
|
const PII_DECRYPT_REASON = "helpdesk:user-lookup";
|
|
16
15
|
export const adminAccess = { roles: access.systemAdmin };
|
|
17
16
|
export const internalAccess = { roles: access.system };
|
|
@@ -21,33 +20,37 @@ export const requestExecutor = createEventStoreExecutor(helpdeskRequestTable, he
|
|
|
21
20
|
export const replyExecutor = createEventStoreExecutor(helpdeskReplyTable, helpdeskReplyEntity, {
|
|
22
21
|
entityName: HELPDESK_REPLY_ENTITY,
|
|
23
22
|
});
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
// Equals the executor's MAX_LIST_LIMIT, so every page is filled until the last one.
|
|
24
|
+
const LIST_PAGE_SIZE = 200;
|
|
25
|
+
export async function listAllPages(fetchPage) {
|
|
26
|
+
const all = [];
|
|
27
|
+
for (;;) {
|
|
28
|
+
const { rows } = await fetchPage({ limit: LIST_PAGE_SIZE, offset: all.length });
|
|
29
|
+
all.push(...rows);
|
|
30
|
+
if (rows.length < LIST_PAGE_SIZE)
|
|
31
|
+
return all;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
export function listRepliesOf(db, requestId) {
|
|
35
|
+
return listAllPages((page) => replyExecutor.list({
|
|
27
36
|
filter: { field: "requestId", op: "eq", value: requestId },
|
|
28
37
|
sort: "sentAt",
|
|
29
38
|
sortDirection: "asc",
|
|
30
|
-
|
|
31
|
-
}, platformActor(), db);
|
|
32
|
-
return found.rows;
|
|
39
|
+
...page,
|
|
40
|
+
}, platformActor(), db));
|
|
33
41
|
}
|
|
34
42
|
export function normalizeEmail(email) {
|
|
35
43
|
return email.toLowerCase();
|
|
36
44
|
}
|
|
37
45
|
export function helpdeskDb(ctx) {
|
|
38
|
-
|
|
39
|
-
throw new InternalError({
|
|
40
|
-
message: "helpdesk requires ctx.systemDb — is r.systemScope() set on the feature?",
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
return ctx.systemDb.acknowledgeCrossTenant(HELPDESK_CROSS_TENANT_REASON);
|
|
46
|
+
return acknowledgedSystemDb(ctx, "helpdesk", HELPDESK_CROSS_TENANT_REASON);
|
|
44
47
|
}
|
|
45
48
|
// Requests and replies are systemStream rows, so every write targets the system tenant's stream.
|
|
46
49
|
export function platformActor() {
|
|
47
50
|
return createSystemUser(SYSTEM_TENANT_ID);
|
|
48
51
|
}
|
|
49
52
|
export async function listSystemAdminIds(db) {
|
|
50
|
-
const rows = await selectMany(db, userTable, { isDeleted: false, status: USER_STATUS.Active, roles:
|
|
53
|
+
const rows = await selectMany(db, userTable, { isDeleted: false, status: USER_STATUS.Active, roles: ROLES.SystemAdmin }, { fields: ["id"], orderBy: { col: "id" } });
|
|
51
54
|
return rows.map((r) => r.id);
|
|
52
55
|
}
|
|
53
56
|
export async function loadUserLabel(db, userId) {
|
|
@@ -59,17 +62,14 @@ export async function loadUserLabel(db, userId) {
|
|
|
59
62
|
return { name, email };
|
|
60
63
|
}
|
|
61
64
|
export async function sendBestEffort(ctx, label, send) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
error: err instanceof Error ? err.message : String(err),
|
|
71
|
-
});
|
|
72
|
-
}
|
|
65
|
+
return sendSharedBestEffort(ctx, `[helpdesk] ${label} failed`, send);
|
|
66
|
+
}
|
|
67
|
+
export async function forwardHelpdeskRequest(ctx, requestId) {
|
|
68
|
+
const forwarded = await ctx.dispatch.writeAs(platformActor(), HelpdeskHandlers.forwardRequest, {
|
|
69
|
+
requestId,
|
|
70
|
+
});
|
|
71
|
+
if (!forwarded.isSuccess)
|
|
72
|
+
throw new Error(forwarded.error.message);
|
|
73
73
|
}
|
|
74
74
|
export async function pickReplyChannels(ctx, reporterUserId) {
|
|
75
75
|
const hasInApp = reporterUserId && (await ctx.hasFeature(IN_APP_FEATURE));
|
|
@@ -96,7 +96,7 @@ export async function loadTenantPlan(ctx, tenantId) {
|
|
|
96
96
|
if (ctx.registry.getQueryHandler(TierEngineQueries.getTenantTier) === undefined)
|
|
97
97
|
return null;
|
|
98
98
|
try {
|
|
99
|
-
const assignment = await ctx.dispatch.queryAs(createSystemUser(SYSTEM_TENANT_ID, [
|
|
99
|
+
const assignment = await ctx.dispatch.queryAs(createSystemUser(SYSTEM_TENANT_ID, [ROLES.SystemAdmin]), TierEngineQueries.getTenantTier, { tenantId });
|
|
100
100
|
const tier = propertyOf(assignment, "tier");
|
|
101
101
|
return typeof tier === "string" && tier !== "" ? planDisplayName(tier) : null;
|
|
102
102
|
}
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
-
import type { UserDataDeleteHook, UserDataExportHook } from "@cosmicdrift/kumiko-framework/engine";
|
|
1
|
+
import type { UserDataDeleteHook, UserDataExportHook, UserDataHookCtx } from "@cosmicdrift/kumiko-framework/engine";
|
|
2
|
+
export declare function findAttachments(ctx: Pick<UserDataHookCtx, "db">, entity: string, id: string): Promise<readonly {
|
|
3
|
+
id: string;
|
|
4
|
+
storageKey: string;
|
|
5
|
+
fileName: string;
|
|
6
|
+
}[]>;
|
|
7
|
+
export type AttachmentByteDeleter = (storageKey: string) => Promise<readonly string[]>;
|
|
8
|
+
export declare function purgeAttachmentsWith(ctx: Pick<UserDataHookCtx, "db">, entity: string, id: string, resolveByteDeleter: () => Promise<AttachmentByteDeleter>): Promise<void>;
|
|
9
|
+
export declare function purgeAttachments(ctx: UserDataHookCtx, entity: string, id: string): Promise<void>;
|
|
10
|
+
export declare function eraseNotesOnRequest(ctx: Pick<UserDataHookCtx, "db">, entity: string, id: string, erasedBy: string): Promise<void>;
|
|
2
11
|
export declare const helpdeskExportHook: UserDataExportHook;
|
|
3
12
|
export declare const helpdeskDeleteHook: UserDataDeleteHook;
|
|
@@ -4,42 +4,33 @@ import { deleteStoredFileAndDerivatives } from "@cosmicdrift/kumiko-framework/de
|
|
|
4
4
|
import { SYSTEM_TENANT_ID } from "@cosmicdrift/kumiko-framework/engine";
|
|
5
5
|
import { InternalError } from "@cosmicdrift/kumiko-framework/errors";
|
|
6
6
|
import { fileRefEntity, fileRefsTable } from "@cosmicdrift/kumiko-framework/files";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
7
|
+
import { systemTenantReadDb, systemTenantWriteRunner, } from "@cosmicdrift/kumiko-framework/internal/row-level-security";
|
|
8
|
+
import { eraseNoteBodiesReachingSubject } from "../notes-history-user-data/index.js";
|
|
9
|
+
import { collectErasureFailure, throwIfErasureFailed } from "../shared/index.js";
|
|
10
|
+
import { resolveVerifiedUserEmail } from "../user/index.js";
|
|
11
|
+
import { listAllPages, platformActor, replyExecutor, requestExecutor } from "./lib.js";
|
|
10
12
|
import { HELPDESK_REPLY_ENTITY, HELPDESK_REQUEST_ENTITY, HELPDESK_UPLOAD_FIELD, } from "./web/constants.js";
|
|
11
13
|
const PII_DECRYPT_REASON = "helpdesk:user-data";
|
|
12
14
|
const ERASE_REASON = "helpdesk:user-data-forget";
|
|
13
|
-
const
|
|
14
|
-
// Anonymous requests are matched by email, so the user must have proven they own it: otherwise
|
|
15
|
-
// registering with someone else's address would expose or erase that person's requests.
|
|
16
|
-
async function resolveVerifiedUserEmail(ctx) {
|
|
17
|
-
const row = await ctx.db.fetchOne(userTable, {
|
|
18
|
-
id: ctx.userId,
|
|
19
|
-
});
|
|
20
|
-
if (row?.emailVerified !== true)
|
|
21
|
-
return null;
|
|
22
|
-
if (ctx.userEmailBeforeDelete)
|
|
23
|
-
return normalizeEmail(ctx.userEmailBeforeDelete);
|
|
24
|
-
return normalizeEmail(await decryptStoredPii(row.email, "email", PII_DECRYPT_REASON));
|
|
25
|
-
}
|
|
15
|
+
const NOTE_ERASE_WRITE_REASON = "erases the note bodies SystemAdmins wrote in the system tenant on a request of an erased subject";
|
|
26
16
|
async function findRequests(ctx) {
|
|
27
|
-
const byUser = await requestExecutor.list({ filter: { field: "reporterUserId", op: "eq", value: ctx.userId },
|
|
28
|
-
const email = await resolveVerifiedUserEmail(ctx);
|
|
17
|
+
const byUser = await listAllPages((page) => requestExecutor.list({ filter: { field: "reporterUserId", op: "eq", value: ctx.userId }, ...page }, platformActor(), ctx.db));
|
|
18
|
+
const email = await resolveVerifiedUserEmail(ctx, PII_DECRYPT_REASON);
|
|
29
19
|
const byEmail = email
|
|
30
|
-
? await requestExecutor.list({ filter: { field: "email", op: "eq", value: email },
|
|
31
|
-
:
|
|
32
|
-
const unique = new Map(byUser.
|
|
33
|
-
for (const row of byEmail
|
|
20
|
+
? await listAllPages((page) => requestExecutor.list({ filter: { field: "email", op: "eq", value: email }, ...page }, platformActor(), ctx.db))
|
|
21
|
+
: [];
|
|
22
|
+
const unique = new Map(byUser.map((row) => [row.id, row]));
|
|
23
|
+
for (const row of byEmail)
|
|
34
24
|
unique.set(row.id, row);
|
|
35
25
|
return [...unique.values()];
|
|
36
26
|
}
|
|
37
27
|
const fileRefExecutor = createEventStoreExecutor(fileRefsTable, fileRefEntity, {
|
|
38
28
|
entityName: "fileRef",
|
|
39
29
|
});
|
|
40
|
-
// Attachments are copied into the system tenant and bound to the request or reply row
|
|
41
|
-
|
|
42
|
-
|
|
30
|
+
// Attachments are copied into the system tenant and bound to the request or reply row; a tenant
|
|
31
|
+
// session cannot read those file_refs, so the lookup uses the system-tenant read handle.
|
|
32
|
+
export async function findAttachments(ctx, entity, id) {
|
|
33
|
+
return systemTenantReadDb(ctx.db).selectMany(fileRefsTable, {
|
|
43
34
|
tenantId: SYSTEM_TENANT_ID,
|
|
44
35
|
entityType: entity,
|
|
45
36
|
entityId: id,
|
|
@@ -48,19 +39,15 @@ async function findAttachments(ctx, entity, id) {
|
|
|
48
39
|
}
|
|
49
40
|
// Bytes first, then the fileRef row: a crash in between leaves a row whose delete converges on the
|
|
50
41
|
// next run, never bytes without a row. A failing byte delete aborts, like the generic fileRef hook.
|
|
51
|
-
|
|
42
|
+
// The deleter is resolved lazily, so a row without attachments needs no storage provider.
|
|
43
|
+
export async function purgeAttachmentsWith(ctx, entity, id, resolveByteDeleter) {
|
|
52
44
|
const attachments = await findAttachments(ctx, entity, id);
|
|
53
45
|
// skip: a row without attachments has no bytes to erase and needs no storage provider
|
|
54
46
|
if (attachments.length === 0)
|
|
55
47
|
return;
|
|
56
|
-
const
|
|
57
|
-
if (!provider) {
|
|
58
|
-
throw new InternalError({
|
|
59
|
-
message: `[helpdesk:user-data] no file storage resolvable, attachments of ${entity} ${id} cannot be erased`,
|
|
60
|
-
});
|
|
61
|
-
}
|
|
48
|
+
const deleteBytes = await resolveByteDeleter();
|
|
62
49
|
for (const attachment of attachments) {
|
|
63
|
-
const failed = await
|
|
50
|
+
const failed = await deleteBytes(attachment.storageKey);
|
|
64
51
|
if (failed.length > 0) {
|
|
65
52
|
throw new InternalError({
|
|
66
53
|
message: `[helpdesk:user-data] ${failed.length} attachment byte delete(s) failed for ${entity} ${id}`,
|
|
@@ -73,9 +60,32 @@ async function purgeAttachments(ctx, entity, id) {
|
|
|
73
60
|
}
|
|
74
61
|
throwIfErasureFailed(failures);
|
|
75
62
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
63
|
+
export function purgeAttachments(ctx, entity, id) {
|
|
64
|
+
return purgeAttachmentsWith(ctx, entity, id, async () => {
|
|
65
|
+
const provider = await ctx.buildStorageProvider?.(SYSTEM_TENANT_ID);
|
|
66
|
+
if (!provider) {
|
|
67
|
+
throw new InternalError({
|
|
68
|
+
message: `[helpdesk:user-data] no file storage resolvable, attachments of ${entity} ${id} cannot be erased`,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
return (storageKey) => deleteStoredFileAndDerivatives(storageKey, provider, "helpdesk:user-data");
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
// Note bodies hang on the request as host. Notes written by SystemAdmins live in the system tenant,
|
|
75
|
+
// which a tenant-scoped hook db cannot see, so both handles are swept.
|
|
76
|
+
export async function eraseNotesOnRequest(ctx, entity, id, erasedBy) {
|
|
77
|
+
for (const db of [ctx.db, systemTenantWriteRunner(ctx.db, NOTE_ERASE_WRITE_REASON)]) {
|
|
78
|
+
await eraseNoteBodiesReachingSubject({
|
|
79
|
+
db,
|
|
80
|
+
subject: { kind: "record", entity, id },
|
|
81
|
+
erasedBy,
|
|
82
|
+
requestId: ERASE_REASON,
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
// guard:dup-ok executor and foreign-key field differ; a generic executor abstraction would obscure row types.
|
|
87
|
+
function findReplies(ctx, requestId) {
|
|
88
|
+
return listAllPages((page) => replyExecutor.list({ filter: { field: "requestId", op: "eq", value: requestId }, ...page }, platformActor(), ctx.db));
|
|
79
89
|
}
|
|
80
90
|
export const helpdeskExportHook = async (ctx) => {
|
|
81
91
|
const requests = await findRequests(ctx);
|
|
@@ -122,6 +132,7 @@ export const helpdeskDeleteHook = async (ctx) => {
|
|
|
122
132
|
await purgeAttachments(ctx, HELPDESK_REPLY_ENTITY, reply.id);
|
|
123
133
|
await erase(HELPDESK_REPLY_ENTITY, reply.id, await replyExecutor.forget({ id: reply.id }, platformActor(), ctx.db));
|
|
124
134
|
}
|
|
135
|
+
await eraseNotesOnRequest(ctx, HELPDESK_REQUEST_ENTITY, request.id, ctx.userId);
|
|
125
136
|
await purgeAttachments(ctx, HELPDESK_REQUEST_ENTITY, request.id);
|
|
126
137
|
await erase(HELPDESK_REQUEST_ENTITY, request.id, await requestExecutor.forget({ id: request.id }, platformActor(), ctx.db));
|
|
127
138
|
}
|
|
@@ -83,7 +83,6 @@ export declare const HelpdeskErrors: {
|
|
|
83
83
|
readonly phoneNotAllowed: "helpdesk_phone_not_allowed";
|
|
84
84
|
readonly phoneRequired: "helpdesk_phone_required";
|
|
85
85
|
readonly reporterEmailMissing: "helpdesk_reporter_email_missing";
|
|
86
|
-
readonly attachmentNotFound: "helpdesk_attachment_not_found";
|
|
87
86
|
};
|
|
88
87
|
export declare const HELPDESK_NOTIFICATION_TYPES: {
|
|
89
88
|
readonly newRequest: "helpdesk:notify:new-request";
|
|
@@ -86,7 +86,6 @@ export const HelpdeskErrors = {
|
|
|
86
86
|
phoneNotAllowed: "helpdesk_phone_not_allowed",
|
|
87
87
|
phoneRequired: "helpdesk_phone_required",
|
|
88
88
|
reporterEmailMissing: "helpdesk_reporter_email_missing",
|
|
89
|
-
attachmentNotFound: "helpdesk_attachment_not_found",
|
|
90
89
|
};
|
|
91
90
|
export const HELPDESK_NOTIFICATION_TYPES = {
|
|
92
91
|
newRequest: "helpdesk:notify:new-request",
|
|
@@ -39,7 +39,7 @@ export function createAccountHealth(deps) {
|
|
|
39
39
|
applied.set(account.id, { status, lastError });
|
|
40
40
|
}
|
|
41
41
|
async function lastErrorWithoutOutage(account) {
|
|
42
|
-
if (await hasOpenQuarantine(deps.db, account.id)) {
|
|
42
|
+
if (await hasOpenQuarantine(deps.db, { tenantId: account.tenantId, accountId: account.id })) {
|
|
43
43
|
return InboundMailLastErrors.messageQuarantined;
|
|
44
44
|
}
|
|
45
45
|
if (storageUnavailable.has(account.id))
|
|
@@ -26,7 +26,7 @@ export function createAccountPoller(deps) {
|
|
|
26
26
|
seenIds.add(row.providerMessageId);
|
|
27
27
|
}
|
|
28
28
|
// 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)) {
|
|
29
|
+
for (const id of await quarantinedMessageIds(systemDb, { tenantId: account.tenantId, accountId: account.id }, providerMessageIds)) {
|
|
30
30
|
seenIds.add(id);
|
|
31
31
|
}
|
|
32
32
|
return new Set(providerMessageIds.filter((id) => !seenIds.has(id)));
|
|
@@ -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",
|
|
@@ -2,6 +2,7 @@ import type { DbConnection } from "@cosmicdrift/kumiko-framework/db";
|
|
|
2
2
|
import type { DispatchWrite } from "./supervisor-ingest.ts";
|
|
3
3
|
import type { InboundMailContext, InboundMailProviderPlugin, MailAccountRecord } from "./types.ts";
|
|
4
4
|
export declare const CONTENT_REFETCH_BUDGET_PER_TICK = 50;
|
|
5
|
+
export declare const CONTENT_REFETCH_SCAN_ROWS_PER_TICK: number;
|
|
5
6
|
export declare function refetchSnippetOnlyMessages(args: {
|
|
6
7
|
readonly db: DbConnection;
|
|
7
8
|
readonly dispatchWrite: DispatchWrite;
|
|
@@ -12,6 +12,11 @@ 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;
|
|
16
|
+
// Where the previous tick stopped scanning, per account. Without it every tick re-reads the newest
|
|
17
|
+
// rows and snippet-only mails further back would never be reached. Lost on restart, which only
|
|
18
|
+
// means the scan starts at the newest mail again.
|
|
19
|
+
const scanResumePoint = new Map();
|
|
15
20
|
function needsContent(row) {
|
|
16
21
|
const bodyMissing = row.bodyRef === undefined || row.bodyRef === null || row.bodyRef === "";
|
|
17
22
|
return bodyMissing && (row.contentState == null || row.contentState === "snippet");
|
|
@@ -19,7 +24,8 @@ function needsContent(row) {
|
|
|
19
24
|
async function findSnippetOnlyMessageIds(db, account, windowDays) {
|
|
20
25
|
const cutoff = Temporal.Now.instant().subtract({ hours: windowDays * 24 });
|
|
21
26
|
const found = [];
|
|
22
|
-
let before;
|
|
27
|
+
let before = scanResumePoint.get(account.id);
|
|
28
|
+
scanResumePoint.delete(account.id);
|
|
23
29
|
for (let page = 0; page < SEEN_MAX_PAGES && found.length < CONTENT_REFETCH_BUDGET_PER_TICK; page++) {
|
|
24
30
|
const seen = await selectMany(db, seenMessageTable, {
|
|
25
31
|
tenantId: account.tenantId,
|
|
@@ -32,6 +38,7 @@ async function findSnippetOnlyMessageIds(db, account, windowDays) {
|
|
|
32
38
|
});
|
|
33
39
|
if (seen.length === 0)
|
|
34
40
|
break;
|
|
41
|
+
const pageStart = before;
|
|
35
42
|
const aggregateToProvider = new Map(seen.map((row) => [
|
|
36
43
|
inboundMessageAggregateId(account.id, row.providerMessageId),
|
|
37
44
|
row.providerMessageId,
|
|
@@ -45,7 +52,14 @@ async function findSnippetOnlyMessageIds(db, account, windowDays) {
|
|
|
45
52
|
const oldest = seen[seen.length - 1];
|
|
46
53
|
if (seen.length < SEEN_PAGE_SIZE || !oldest)
|
|
47
54
|
break;
|
|
55
|
+
if (found.length >= CONTENT_REFETCH_BUDGET_PER_TICK) {
|
|
56
|
+
// Reloaded mails stop being candidates, so the page can be read again without looping.
|
|
57
|
+
if (pageStart)
|
|
58
|
+
scanResumePoint.set(account.id, pageStart);
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
48
61
|
before = oldest.seenAt;
|
|
62
|
+
scanResumePoint.set(account.id, before);
|
|
49
63
|
}
|
|
50
64
|
return found.slice(0, CONTENT_REFETCH_BUDGET_PER_TICK);
|
|
51
65
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
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
5
|
// ============================================================================
|
|
@@ -14,8 +14,8 @@ import { DEFAULT_INBOUND_MAIL_ADMIN_ROLES, DEFAULT_INBOUND_MAIL_USER_ROLES } fro
|
|
|
14
14
|
// **PII convention:** `personal: "tenant"` (not `encrypted`): fields must
|
|
15
15
|
// be crypto-shredded when eraseSubjectKeys deletes the tenant subject key on
|
|
16
16
|
// tenant destruction (pattern from billing-foundation).
|
|
17
|
-
//
|
|
18
|
-
// <
|
|
17
|
+
// The projection holds ciphertext, so these fields' maxLength comes from
|
|
18
|
+
// piiCiphertextMaxLengthFor(<plaintext limit>).
|
|
19
19
|
//
|
|
20
20
|
// **Design decision:** The PII subject of an inbound mail is currently the
|
|
21
21
|
// TENANT (mailbox owner), not the external sender. A sender-forget flow would
|
|
@@ -50,7 +50,12 @@ export const mailAccountEntity = createEntity({
|
|
|
50
50
|
reason: "tenant_config_not_personal",
|
|
51
51
|
}),
|
|
52
52
|
// Mailbox address — tenant PII.
|
|
53
|
-
address: createTextField({
|
|
53
|
+
address: createTextField({
|
|
54
|
+
required: true,
|
|
55
|
+
maxLength: piiCiphertextMaxLengthFor(320),
|
|
56
|
+
personal: "tenant",
|
|
57
|
+
find: "none",
|
|
58
|
+
}),
|
|
54
59
|
status: createTextField({
|
|
55
60
|
required: true,
|
|
56
61
|
maxLength: 30,
|
|
@@ -76,6 +81,9 @@ function ownMailboxOrSharedRead(memberRoles) {
|
|
|
76
81
|
const rule = {
|
|
77
82
|
kind: "where",
|
|
78
83
|
where: (user, ctx) => {
|
|
84
|
+
if (!isSchemaTable(ctx.table)) {
|
|
85
|
+
throw new Error(`${ctx.tableName}: ownership rule received a table not built by table()`);
|
|
86
|
+
}
|
|
79
87
|
const owner = `"${ctx.tableName}"."${physicalColumnName(ctx.table, "ownerUserId")}"`;
|
|
80
88
|
return {
|
|
81
89
|
sqlText: `(${owner} IS NULL OR ${owner} = '' OR ${owner} = $${ctx.paramStart})`,
|
|
@@ -114,21 +122,51 @@ export function createInboundMessageEntity(memberRoles) {
|
|
|
114
122
|
personal: false,
|
|
115
123
|
reason: "technical_reference",
|
|
116
124
|
}),
|
|
117
|
-
from: createTextField({
|
|
125
|
+
from: createTextField({
|
|
126
|
+
required: true,
|
|
127
|
+
maxLength: piiCiphertextMaxLengthFor(2000),
|
|
128
|
+
personal: "tenant",
|
|
129
|
+
find: "none",
|
|
130
|
+
}),
|
|
118
131
|
// JSON-stringified string[] — als Ganzes encrypted.
|
|
119
|
-
to: createTextField({
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
132
|
+
to: createTextField({
|
|
133
|
+
maxLength: piiCiphertextMaxLengthFor(8000),
|
|
134
|
+
personal: "tenant",
|
|
135
|
+
find: "none",
|
|
136
|
+
}),
|
|
137
|
+
cc: createTextField({
|
|
138
|
+
maxLength: piiCiphertextMaxLengthFor(8000),
|
|
139
|
+
personal: "tenant",
|
|
140
|
+
find: "none",
|
|
141
|
+
}),
|
|
142
|
+
subject: createTextField({
|
|
143
|
+
maxLength: piiCiphertextMaxLengthFor(4000),
|
|
144
|
+
personal: "tenant",
|
|
145
|
+
find: "none",
|
|
146
|
+
}),
|
|
147
|
+
snippet: createTextField({
|
|
148
|
+
maxLength: piiCiphertextMaxLengthFor(4000),
|
|
149
|
+
personal: "tenant",
|
|
150
|
+
find: "none",
|
|
151
|
+
}),
|
|
123
152
|
receivedAt: createTimestampField({ required: true }),
|
|
124
153
|
bodyRef: createTextField({ maxLength: 500, personal: false, reason: "technical_reference" }),
|
|
125
154
|
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
155
|
// Null on rows from before the column; list-messages never selects it.
|
|
128
|
-
|
|
156
|
+
// Plaintext is clipped to INBOUND_BODY_TEXT_MAX_CHARS (32_000) before encryption.
|
|
157
|
+
bodyText: createLongTextField({
|
|
158
|
+
maxLength: piiCiphertextMaxLengthFor(32_000),
|
|
159
|
+
personal: "tenant",
|
|
160
|
+
find: "none",
|
|
161
|
+
}),
|
|
129
162
|
bodyTextTruncated: createBooleanField(),
|
|
130
|
-
// Sanitized HTML of the mail
|
|
131
|
-
|
|
163
|
+
// Sanitized HTML of the mail, null when the mail has none or it was too large: sanitizeInboundHtml
|
|
164
|
+
// drops anything over 500_000 bytes after sanitizing, before encryption.
|
|
165
|
+
bodyHtml: createLongTextField({
|
|
166
|
+
maxLength: piiCiphertextMaxLengthFor(500_000),
|
|
167
|
+
personal: "tenant",
|
|
168
|
+
find: "none",
|
|
169
|
+
}),
|
|
132
170
|
// Bound to the message (entityType = the aggregate type), so the file guard answers with the
|
|
133
171
|
// mail's visibility. The fileRefs are bound at ingest, the projection copies the ids.
|
|
134
172
|
attachmentFileIds: createFilesField({ personal: false, reason: "technical_reference" }),
|
|
@@ -177,7 +215,11 @@ export const mailThreadEntity = createEntity({
|
|
|
177
215
|
personal: false,
|
|
178
216
|
reason: "technical_reference",
|
|
179
217
|
}),
|
|
180
|
-
subject: createTextField({
|
|
218
|
+
subject: createTextField({
|
|
219
|
+
maxLength: piiCiphertextMaxLengthFor(4000),
|
|
220
|
+
personal: "tenant",
|
|
221
|
+
find: "none",
|
|
222
|
+
}),
|
|
181
223
|
lastMessageAt: createTimestampField({ required: true }),
|
|
182
224
|
messageCount: createNumberField({ required: true, integer: true }),
|
|
183
225
|
},
|
|
@@ -19,6 +19,7 @@
|
|
|
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";
|
|
24
25
|
import { senderAuthenticationFieldSchema } from "./sender-auth.js";
|
|
@@ -51,9 +52,7 @@ const accountStatusEnum = z.enum([
|
|
|
51
52
|
// ============================================================================
|
|
52
53
|
//
|
|
53
54
|
// 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).
|
|
55
|
+
// address is PII ciphertext; its plaintext is capped at 320 characters by connect-account.write.ts.
|
|
57
56
|
export const mailAccountEventPayloadSchema = z.object({
|
|
58
57
|
provider: z.string().min(1).max(50),
|
|
59
58
|
/** "password" | "xoauth2" | "oauth" (InboundMailAuthMethods) — deliberately
|
|
@@ -63,7 +62,7 @@ export const mailAccountEventPayloadSchema = z.object({
|
|
|
63
62
|
/** null = shared by the tenant; otherwise, this user's personal mailbox. */
|
|
64
63
|
ownerUserId: z.string().max(36).nullable(),
|
|
65
64
|
displayName: z.string().max(200),
|
|
66
|
-
address: z.string().min(1).max(
|
|
65
|
+
address: z.string().min(1).max(piiCiphertextMaxLengthFor(320)),
|
|
67
66
|
status: accountStatusEnum,
|
|
68
67
|
/** Provider-agnostic watch state ("idle", "watching", "backoff:3", ...)
|
|
69
68
|
* — an operational signal only, not PII. */
|
|
@@ -94,12 +93,12 @@ export const skippedAttachmentSchema = z.object({
|
|
|
94
93
|
]),
|
|
95
94
|
});
|
|
96
95
|
// Shared by inbound-message-received (v2+) and inbound-message-content-fetched.
|
|
97
|
-
// bodyText is ciphertext
|
|
96
|
+
// bodyText is ciphertext of at most INBOUND_BODY_TEXT_MAX_CHARS (32_000) characters.
|
|
98
97
|
const inboundMessageContentShape = {
|
|
99
|
-
bodyText: z.string().max(
|
|
98
|
+
bodyText: z.string().max(piiCiphertextMaxLengthFor(32_000)),
|
|
100
99
|
bodyTextTruncated: z.boolean(),
|
|
101
|
-
/** Sanitized HTML body
|
|
102
|
-
bodyHtml: z.string().max(
|
|
100
|
+
/** Sanitized HTML body as PII ciphertext. sanitizeInboundHtml drops anything over 500_000 bytes after sanitizing. Null: none or too large. */
|
|
101
|
+
bodyHtml: z.string().max(piiCiphertextMaxLengthFor(500_000)).nullable(),
|
|
103
102
|
/** file-foundation FileRef ids (plaintext uuids). Attachments outlive the mail: apps turn them
|
|
104
103
|
* into documents, so the retention sweep never deletes them. */
|
|
105
104
|
attachmentFileIds: z.array(z.uuid()).max(50),
|
|
@@ -114,8 +113,8 @@ const inboundMessageContentShape = {
|
|
|
114
113
|
// aggregateId = inboundMessageAggregateId(accountId, providerMessageId)
|
|
115
114
|
// → deterministic, so provider replays collide on the same stream.
|
|
116
115
|
//
|
|
117
|
-
// PII fields (from/to/cc/subject/snippet):
|
|
118
|
-
//
|
|
116
|
+
// PII fields (from/to/cc/subject/snippet): the maxima are the ciphertext
|
|
117
|
+
// size of the plaintext limits in ingest-message-schema.ts. to/cc are JSON-stringified string[] BEFORE encryption;
|
|
119
118
|
// the payload contains the ciphertext string, not the array (primitives only,
|
|
120
119
|
// upcaster-safe).
|
|
121
120
|
export const inboundMessageEventPayloadSchema = z.object({
|
|
@@ -128,13 +127,13 @@ export const inboundMessageEventPayloadSchema = z.object({
|
|
|
128
127
|
/** Normalized thread key (References-chain root or provider thread ID,
|
|
129
128
|
* prefixed by the provider). */
|
|
130
129
|
threadKey: z.string().min(1).max(500),
|
|
131
|
-
from: z.string().min(1).max(2000),
|
|
130
|
+
from: z.string().min(1).max(piiCiphertextMaxLengthFor(2000)),
|
|
132
131
|
/** JSON-stringified string[], dann PII-encrypted. */
|
|
133
|
-
to: z.string().max(8000),
|
|
132
|
+
to: z.string().max(piiCiphertextMaxLengthFor(8000)),
|
|
134
133
|
/** JSON-stringified string[], dann PII-encrypted. */
|
|
135
|
-
cc: z.string().max(8000),
|
|
136
|
-
subject: z.string().max(4000),
|
|
137
|
-
snippet: z.string().max(4000),
|
|
134
|
+
cc: z.string().max(piiCiphertextMaxLengthFor(8000)),
|
|
135
|
+
subject: z.string().max(piiCiphertextMaxLengthFor(4000)),
|
|
136
|
+
snippet: z.string().max(piiCiphertextMaxLengthFor(4000)),
|
|
138
137
|
/** ISO instant — receipt time reported by the provider (INTERNALDATE or
|
|
139
138
|
* receivedDateTime), not ingest time. */
|
|
140
139
|
receivedAtIso: z.string().min(1),
|
|
@@ -166,7 +165,7 @@ export const inboundMessageContentFetchedEventPayloadSchema = z.object({
|
|
|
166
165
|
// ============================================================================
|
|
167
166
|
export const mailThreadEventPayloadSchema = z.object({
|
|
168
167
|
threadKey: z.string().min(1).max(500),
|
|
169
|
-
subject: z.string().max(4000),
|
|
168
|
+
subject: z.string().max(piiCiphertextMaxLengthFor(4000)),
|
|
170
169
|
lastMessageAtIso: z.string().min(1),
|
|
171
170
|
messageCount: z.number().int().min(1),
|
|
172
171
|
});
|
|
@@ -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);
|