@cosmicdrift/kumiko-samples 0.413.1 → 0.415.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/packages/bundled-features/package.json +16 -1
- package/packages/bundled-features/src/admin-shell/changes.json +6 -0
- package/packages/bundled-features/src/admin-shell/feature.ts +8 -7
- package/packages/bundled-features/src/agent-tools/agent-doc-lint.ts +5 -1
- package/packages/bundled-features/src/agent-tools/agent-manifest.ts +36 -27
- package/packages/bundled-features/src/agent-tools/api-docs/collect-events.ts +8 -1
- package/packages/bundled-features/src/agent-tools/api-docs/collect.ts +3 -2
- package/packages/bundled-features/src/agent-tools/api-docs/generate.ts +6 -0
- package/packages/bundled-features/src/agent-tools/api-docs/index.ts +1 -0
- package/packages/bundled-features/src/agent-tools/api-docs/problems.ts +38 -1
- package/packages/bundled-features/src/agent-tools/api-docs/render-openapi.ts +1 -0
- package/packages/bundled-features/src/agent-tools/api-docs/resolve-config.ts +17 -0
- package/packages/bundled-features/src/agent-tools/api-docs/scope-slug-collisions.ts +17 -0
- package/packages/bundled-features/src/agent-tools/api-docs/translation-gaps.ts +42 -0
- package/packages/bundled-features/src/agent-tools/api-docs/webhook-example-problems.ts +30 -0
- package/packages/bundled-features/src/agent-tools/changes.json +12 -0
- package/packages/bundled-features/src/agent-tools/index.ts +1 -0
- package/packages/bundled-features/src/agent-tools/labels.ts +19 -6
- package/packages/bundled-features/src/agent-tools/tool-catalog.ts +18 -7
- package/packages/bundled-features/src/agent-tools/tool-dispatch.ts +14 -1
- package/packages/bundled-features/src/agent-tools/types.ts +4 -0
- package/packages/bundled-features/src/audit/event-classification.ts +6 -0
- package/packages/bundled-features/src/audit/web/i18n.ts +1 -0
- package/packages/bundled-features/src/auth-email-password/changes.json +18 -0
- package/packages/bundled-features/src/auth-email-password/errors.ts +0 -13
- package/packages/bundled-features/src/auth-email-password/handlers/invite-signup-complete.write.ts +147 -121
- package/packages/bundled-features/src/auth-email-password/handlers/login-options.query.ts +1 -1
- package/packages/bundled-features/src/auth-email-password/handlers/request-account-unlock.write.ts +1 -1
- package/packages/bundled-features/src/auth-email-password/handlers/request-email-verification.write.ts +0 -1
- package/packages/bundled-features/src/auth-email-password/handlers/request-password-reset.write.ts +0 -1
- package/packages/bundled-features/src/auth-email-password/handlers/self-registration-status.query.ts +1 -1
- package/packages/bundled-features/src/auth-email-password/reset-token.ts +0 -2
- package/packages/bundled-features/src/auth-email-password/seeding.ts +39 -7
- package/packages/bundled-features/src/auth-email-password/signup-token-store.ts +2 -3
- package/packages/bundled-features/src/auth-email-password/unlock-token.ts +0 -2
- package/packages/bundled-features/src/auth-email-password/verification-token.ts +0 -2
- package/packages/bundled-features/src/auth-email-password/web/auth-form-primitives.tsx +2 -2
- package/packages/bundled-features/src/auth-email-password/web/auth-gate.tsx +2 -2
- package/packages/bundled-features/src/auth-email-password/web/auth-redirect.ts +5 -0
- package/packages/bundled-features/src/auth-email-password/web/forgot-password-screen.tsx +1 -6
- package/packages/bundled-features/src/auth-email-password/web/invite-accept-screen.tsx +1 -1
- package/packages/bundled-features/src/auth-email-password/web/return-path.ts +2 -1
- package/packages/bundled-features/src/auth-email-password/web/session.tsx +12 -13
- package/packages/bundled-features/src/auth-email-password/web/signup-screen.tsx +1 -6
- package/packages/bundled-features/src/auth-email-password/web/static-account.ts +6 -1
- package/packages/bundled-features/src/auth-email-password/web/tenant-switcher.tsx +1 -1
- package/packages/bundled-features/src/auth-email-password/web/token-confirm-screen.tsx +4 -5
- package/packages/bundled-features/src/auth-email-password/web/user-menu.tsx +1 -1
- package/packages/bundled-features/src/auth-mfa/changes.json +6 -0
- package/packages/bundled-features/src/auth-mfa/web/mfa-code-or-recovery-field.tsx +17 -1
- package/packages/bundled-features/src/auth-mfa/web/mfa-disable-dialog.tsx +1 -1
- package/packages/bundled-features/src/auth-mfa/web/mfa-regenerate-recovery-dialog.tsx +1 -1
- package/packages/bundled-features/src/auth-mfa/web/mfa-setup-preauth-screen.tsx +1 -1
- package/packages/bundled-features/src/auth-mfa/web/mfa-verify-screen.tsx +16 -47
- package/packages/bundled-features/src/auth-mfa-user-data/index.ts +5 -6
- package/packages/bundled-features/src/billing-foundation/aggregate-id.ts +0 -4
- package/packages/bundled-features/src/billing-foundation/changes.json +61 -0
- package/packages/bundled-features/src/billing-foundation/checkout-core.ts +19 -1
- package/packages/bundled-features/src/billing-foundation/checkout-ledger.ts +67 -0
- package/packages/bundled-features/src/billing-foundation/consumer-protection/consent-gate.ts +2 -1
- package/packages/bundled-features/src/billing-foundation/consumer-protection/consent-text.ts +49 -2
- package/packages/bundled-features/src/billing-foundation/consumer-protection/termination-open-cancels.ts +5 -0
- package/packages/bundled-features/src/billing-foundation/consumer-protection/termination-provider-timeout.ts +23 -0
- package/packages/bundled-features/src/billing-foundation/consumer-protection/termination-record.ts +12 -7
- package/packages/bundled-features/src/billing-foundation/consumer-protection/termination-revoke.ts +1 -1
- package/packages/bundled-features/src/billing-foundation/events.ts +51 -10
- package/packages/bundled-features/src/billing-foundation/feature.ts +15 -1
- package/packages/bundled-features/src/billing-foundation/handlers/billing-plans.query.ts +47 -14
- package/packages/bundled-features/src/billing-foundation/handlers/create-checkout-session.write.ts +9 -1
- package/packages/bundled-features/src/billing-foundation/handlers/process-event.write.ts +183 -17
- package/packages/bundled-features/src/billing-foundation/handlers/process-payment-event.write.ts +35 -10
- package/packages/bundled-features/src/billing-foundation/handlers/record-checkout-opened.write.ts +25 -0
- package/packages/bundled-features/src/billing-foundation/handlers/start-plan-checkout.write.ts +9 -1
- package/packages/bundled-features/src/billing-foundation/handlers/switch-plan.write.ts +16 -4
- package/packages/bundled-features/src/billing-foundation/i18n.ts +3 -0
- package/packages/bundled-features/src/billing-foundation/pending-plan-switch.ts +80 -0
- package/packages/bundled-features/src/billing-foundation/scrub-raw-payload-headers.ts +50 -0
- package/packages/bundled-features/src/billing-foundation/types.ts +47 -30
- package/packages/bundled-features/src/billing-foundation/validate-options.ts +18 -0
- package/packages/bundled-features/src/billing-foundation/web/billing-plans-panel.tsx +10 -5
- package/packages/bundled-features/src/billing-foundation/web/cancel-contract-dialog.tsx +1 -1
- package/packages/bundled-features/src/billing-foundation/web/checkout-consent-dialog.tsx +1 -1
- package/packages/bundled-features/src/billing-foundation/web/constants.ts +5 -2
- package/packages/bundled-features/src/billing-foundation/web/plan-switch-confirm-dialog.tsx +1 -1
- package/packages/bundled-features/src/billing-foundation/webhook-handler.ts +65 -17
- package/packages/bundled-features/src/cap-counter/aggregate-id.ts +0 -2
- package/packages/bundled-features/src/cap-counter/changes.json +6 -0
- package/packages/bundled-features/src/cap-counter/stock-cap-guard.ts +19 -4
- package/packages/bundled-features/src/cap-overview/changes.json +6 -0
- package/packages/bundled-features/src/cap-overview/handlers/tenant-caps-list.query.ts +22 -6
- package/packages/bundled-features/src/cap-overview/i18n.ts +1 -0
- package/packages/bundled-features/src/cap-overview/index.ts +1 -0
- package/packages/bundled-features/src/cap-overview/types.ts +11 -1
- package/packages/bundled-features/src/cap-overview/web/cap-cards-panel.tsx +6 -2
- package/packages/bundled-features/src/cap-overview/web/cap-usage-bar.tsx +10 -1
- package/packages/bundled-features/src/cap-overview/web/usage-math.ts +5 -0
- package/packages/bundled-features/src/channel-in-app/changes.json +6 -0
- package/packages/bundled-features/src/channel-in-app/handlers/read-state-by-keys.query.ts +2 -2
- package/packages/bundled-features/src/channel-whatsapp/aggregate-id.ts +29 -0
- package/packages/bundled-features/src/channel-whatsapp/changes.json +32 -0
- package/packages/bundled-features/src/channel-whatsapp/constants.ts +46 -0
- package/packages/bundled-features/src/channel-whatsapp/events.ts +94 -0
- package/packages/bundled-features/src/channel-whatsapp/feature.ts +72 -0
- package/packages/bundled-features/src/channel-whatsapp/graph-client.ts +398 -0
- package/packages/bundled-features/src/channel-whatsapp/in-memory-meta.ts +300 -0
- package/packages/bundled-features/src/channel-whatsapp/inbound-handlers.ts +210 -0
- package/packages/bundled-features/src/channel-whatsapp/index.ts +66 -0
- package/packages/bundled-features/src/channel-whatsapp/meta-signature.ts +26 -0
- package/packages/bundled-features/src/channel-whatsapp/options.ts +149 -0
- package/packages/bundled-features/src/channel-whatsapp/pii.ts +109 -0
- package/packages/bundled-features/src/channel-whatsapp/webhook-normalize.ts +247 -0
- package/packages/bundled-features/src/channel-whatsapp/webhook-routes.ts +185 -0
- package/packages/bundled-features/src/compliance-profiles/changes.json +5 -0
- package/packages/bundled-features/src/compliance-profiles/handlers/set-profile.write.ts +2 -0
- package/packages/bundled-features/src/compliance-profiles/handlers/sub-processors.query.ts +1 -1
- package/packages/bundled-features/src/config/changes.json +12 -0
- package/packages/bundled-features/src/config/handlers/set.write.ts +7 -0
- package/packages/bundled-features/src/config/handlers/values.query.ts +8 -1
- package/packages/bundled-features/src/config/index.ts +1 -0
- package/packages/bundled-features/src/config/read-redaction.ts +6 -3
- package/packages/bundled-features/src/config/table.ts +1 -0
- package/packages/bundled-features/src/config/write-helpers.ts +3 -2
- package/packages/bundled-features/src/crypto-shredding/changes.json +18 -0
- package/packages/bundled-features/src/crypto-shredding/constants.ts +2 -0
- package/packages/bundled-features/src/crypto-shredding/handlers/forget-subject.write.ts +38 -18
- package/packages/bundled-features/src/crypto-shredding/index.ts +4 -0
- package/packages/bundled-features/src/crypto-shredding/subject-forget-after-delete-hook.ts +49 -0
- package/packages/bundled-features/src/custom-fields/aggregate-id.ts +0 -1
- package/packages/bundled-features/src/custom-fields/entity.ts +1 -0
- package/packages/bundled-features/src/custom-fields/wire-for-entity.ts +0 -1
- package/packages/bundled-features/src/data-retention/changes.json +12 -0
- package/packages/bundled-features/src/data-retention/erase-notes-of-deleted-row.ts +23 -0
- package/packages/bundled-features/src/data-retention/feature.ts +2 -5
- package/packages/bundled-features/src/data-retention/run-retention-cleanup.ts +38 -18
- package/packages/bundled-features/src/data-retention/tenant-destruction-hold.ts +9 -0
- package/packages/bundled-features/src/delivery/attempt-log-factory.ts +11 -0
- package/packages/bundled-features/src/delivery/attempt-log.ts +3 -3
- package/packages/bundled-features/src/delivery/changes.json +12 -0
- package/packages/bundled-features/src/delivery/channel-context.ts +6 -3
- package/packages/bundled-features/src/delivery/db/queries/preferences.ts +0 -1
- package/packages/bundled-features/src/delivery/delivery-service.ts +3 -0
- package/packages/bundled-features/src/delivery/feature.ts +4 -13
- package/packages/bundled-features/src/delivery/handlers/opted-in-user-ids.query.ts +54 -0
- package/packages/bundled-features/src/delivery/handlers/preferences.query.ts +2 -20
- package/packages/bundled-features/src/delivery/handlers/resubscribe-user.write.ts +2 -25
- package/packages/bundled-features/src/delivery/handlers/unsubscribe-page-chrome.query.ts +2 -0
- package/packages/bundled-features/src/delivery/handlers/unsubscribe-user.write.ts +2 -27
- package/packages/bundled-features/src/delivery/index.ts +3 -1
- package/packages/bundled-features/src/delivery/options.ts +11 -0
- package/packages/bundled-features/src/delivery/preference-rows.ts +33 -0
- package/packages/bundled-features/src/delivery/set-preference-enabled.ts +40 -0
- package/packages/bundled-features/src/delivery/testing.ts +3 -1
- package/packages/bundled-features/src/delivery/types.ts +1 -0
- package/packages/bundled-features/src/delivery/unsubscribe-page.ts +7 -1
- package/packages/bundled-features/src/delivery/upsert-preference.ts +0 -1
- package/packages/bundled-features/src/delivery/web/public-names.ts +1 -0
- package/packages/bundled-features/src/derivatives-sharp/render.ts +9 -9
- package/packages/bundled-features/src/document-ingest-foundation/aggregate-id.ts +0 -1
- package/packages/bundled-features/src/document-ingest-foundation/append-missing-extract-event.ts +37 -25
- package/packages/bundled-features/src/document-ingest-foundation/changes.json +6 -0
- package/packages/bundled-features/src/document-ingest-foundation/feature.ts +1 -0
- package/packages/bundled-features/src/document-ingest-foundation/report-ingest-progress.ts +34 -14
- package/packages/bundled-features/src/documents/aggregate-id.ts +0 -2
- package/packages/bundled-features/src/documents/changes.json +24 -0
- package/packages/bundled-features/src/documents/constants.ts +10 -2
- package/packages/bundled-features/src/documents/ensure-link.ts +3 -4
- package/packages/bundled-features/src/documents/feature.ts +33 -6
- package/packages/bundled-features/src/documents/handlers/import.write.ts +2 -2
- package/packages/bundled-features/src/documents/queries/expiry-overview.query.ts +2 -1
- package/packages/bundled-features/src/documents/queries/for-record.query.ts +3 -4
- package/packages/bundled-features/src/documents/queries/list-page.ts +11 -3
- package/packages/bundled-features/src/documents/queries/overview.query.ts +2 -2
- package/packages/bundled-features/src/documents/screens.ts +8 -3
- package/packages/bundled-features/src/documents/tab.ts +1 -1
- package/packages/bundled-features/src/feature-toggles/toggle-sync-signal.ts +6 -3
- package/packages/bundled-features/src/file-derivatives/handlers/public-variant-by-file-ref.query.ts +1 -1
- package/packages/bundled-features/src/file-derivatives/handlers/public-variant.query.ts +1 -1
- package/packages/bundled-features/src/file-foundation/probe.ts +9 -3
- package/packages/bundled-features/src/file-foundation/read-file-ref-content.ts +24 -11
- package/packages/bundled-features/src/file-provider-inmemory/feature.ts +1 -1
- package/packages/bundled-features/src/file-provider-s3/changes.json +14 -0
- package/packages/bundled-features/src/file-provider-s3/env-feature.ts +1 -1
- package/packages/bundled-features/src/file-provider-s3/env-named-feature.ts +1 -1
- package/packages/bundled-features/src/file-provider-s3/env-schema.ts +24 -7
- package/packages/bundled-features/src/file-provider-s3/feature.ts +1 -1
- package/packages/bundled-features/src/file-provider-s3/index.ts +7 -1
- package/packages/bundled-features/src/file-provider-s3/lib/env-helper.ts +21 -13
- package/packages/bundled-features/src/file-provider-s3/lib/s3-provider.ts +8 -1
- package/packages/bundled-features/src/files/changes.json +7 -0
- package/packages/bundled-features/src/folders/aggregate-id.ts +0 -1
- package/packages/bundled-features/src/folders/web/folder-manager.tsx +6 -6
- package/packages/bundled-features/src/folders-user-data/index.ts +12 -14
- package/packages/bundled-features/src/form-draft/feature.ts +1 -0
- package/packages/bundled-features/src/helpdesk/changes.json +56 -0
- package/packages/bundled-features/src/helpdesk/entity.ts +4 -1
- package/packages/bundled-features/src/helpdesk/feature.ts +42 -0
- package/packages/bundled-features/src/helpdesk/handlers/access.ts +0 -10
- package/packages/bundled-features/src/helpdesk/handlers/attempts.ts +7 -14
- package/packages/bundled-features/src/helpdesk/handlers/challenge.query.ts +1 -2
- package/packages/bundled-features/src/helpdesk/handlers/reply.write.ts +5 -12
- package/packages/bundled-features/src/helpdesk/handlers/report.write.ts +4 -10
- package/packages/bundled-features/src/helpdesk/handlers/submit.write.ts +5 -12
- package/packages/bundled-features/src/helpdesk/index.ts +1 -0
- package/packages/bundled-features/src/helpdesk/legacy-contact-config.ts +61 -0
- package/packages/bundled-features/src/helpdesk/legacy-contact-erasure.ts +45 -0
- package/packages/bundled-features/src/helpdesk/legacy-contact-retention.ts +65 -0
- package/packages/bundled-features/src/helpdesk/legacy-contact-streams.ts +187 -0
- package/packages/bundled-features/src/helpdesk/legacy-contact-user-data.ts +84 -0
- package/packages/bundled-features/src/helpdesk/lib.ts +55 -37
- package/packages/bundled-features/src/helpdesk/user-data-hooks.ts +89 -48
- package/packages/bundled-features/src/helpdesk/web/constants.ts +0 -1
- package/packages/bundled-features/src/inbound-mail-foundation/account-health.ts +1 -1
- package/packages/bundled-features/src/inbound-mail-foundation/account-poll.ts +9 -2
- package/packages/bundled-features/src/inbound-mail-foundation/aggregate-id.ts +0 -2
- package/packages/bundled-features/src/inbound-mail-foundation/changes.json +54 -0
- package/packages/bundled-features/src/inbound-mail-foundation/constants.ts +6 -0
- package/packages/bundled-features/src/inbound-mail-foundation/content-refetch.ts +23 -2
- package/packages/bundled-features/src/inbound-mail-foundation/entities.ts +73 -15
- package/packages/bundled-features/src/inbound-mail-foundation/events.ts +24 -16
- package/packages/bundled-features/src/inbound-mail-foundation/feature.ts +3 -1
- package/packages/bundled-features/src/inbound-mail-foundation/handlers/account-address.ts +16 -2
- package/packages/bundled-features/src/inbound-mail-foundation/handlers/attach-message-content.write.ts +10 -3
- package/packages/bundled-features/src/inbound-mail-foundation/handlers/connect-account.write.ts +23 -9
- package/packages/bundled-features/src/inbound-mail-foundation/handlers/forget-message.write.ts +79 -0
- package/packages/bundled-features/src/inbound-mail-foundation/handlers/ingest-message-schema.ts +18 -5
- package/packages/bundled-features/src/inbound-mail-foundation/i18n.ts +3 -0
- package/packages/bundled-features/src/inbound-mail-foundation/index.ts +1 -0
- package/packages/bundled-features/src/inbound-mail-foundation/normalize-inbound-message.ts +22 -8
- package/packages/bundled-features/src/inbound-mail-foundation/oauth-access-token.ts +1 -1
- package/packages/bundled-features/src/inbound-mail-foundation/outbound-mail.ts +2 -0
- package/packages/bundled-features/src/inbound-mail-foundation/personal-address.ts +20 -0
- package/packages/bundled-features/src/inbound-mail-foundation/purge-messages.ts +54 -0
- package/packages/bundled-features/src/inbound-mail-foundation/quarantine.ts +15 -5
- package/packages/bundled-features/src/inbound-mail-foundation/retention-job.ts +1 -5
- package/packages/bundled-features/src/inbound-mail-foundation/retention-sweep.ts +21 -34
- package/packages/bundled-features/src/inbound-mail-foundation/sanitize-inbound-html.ts +2 -5
- package/packages/bundled-features/src/inbound-mail-foundation/send-from-account.ts +9 -1
- package/packages/bundled-features/src/inbound-mail-foundation/supervisor-ingest.ts +7 -1
- package/packages/bundled-features/src/inbound-mail-foundation/sync-account-now.ts +1 -1
- package/packages/bundled-features/src/inbound-mail-foundation/tenant-destroy-hook.ts +14 -17
- package/packages/bundled-features/src/inbound-mail-foundation/watch-supervisor.ts +1 -1
- package/packages/bundled-features/src/inbound-provider-imap/byte-budget.ts +80 -0
- package/packages/bundled-features/src/inbound-provider-imap/changes.json +13 -0
- package/packages/bundled-features/src/inbound-provider-imap/connect-mailbox.ts +8 -4
- package/packages/bundled-features/src/inbound-provider-imap/connect-my-mailbox.ts +23 -6
- package/packages/bundled-features/src/inbound-provider-imap/connect-target-rate-limit.ts +46 -0
- package/packages/bundled-features/src/inbound-provider-imap/download-batch.ts +47 -10
- package/packages/bundled-features/src/inbound-provider-imap/feature.ts +7 -4
- package/packages/bundled-features/src/inbound-provider-imap/fetch-content.ts +43 -29
- package/packages/bundled-features/src/inbound-provider-imap/i18n.ts +2 -2
- package/packages/bundled-features/src/inbound-provider-imap/parse-message.ts +14 -0
- package/packages/bundled-features/src/inbound-provider-imap/reconnect-mailbox.ts +5 -4
- package/packages/bundled-features/src/inbound-provider-imap/send-mail.ts +39 -7
- package/packages/bundled-features/src/inbound-provider-imap/smtp-client.ts +19 -4
- package/packages/bundled-features/src/inbound-provider-imap/watch-mailbox.ts +8 -23
- package/packages/bundled-features/src/inbound-provider-inmemory/feature.ts +1 -1
- package/packages/bundled-features/src/jobs/events.ts +10 -0
- package/packages/bundled-features/src/jobs/feature.ts +2 -0
- package/packages/bundled-features/src/jobs/handlers/consumer.write.ts +41 -16
- package/packages/bundled-features/src/jobs/web/constants.ts +4 -0
- package/packages/bundled-features/src/mail-foundation/changes.json +6 -0
- package/packages/bundled-features/src/mail-transport-inmemory/feature.ts +1 -1
- package/packages/bundled-features/src/mail-transport-smtp/feature.ts +3 -2
- package/packages/bundled-features/src/managed-pages/changes.json +12 -0
- package/packages/bundled-features/src/managed-pages/handlers/branding.query.ts +1 -1
- package/packages/bundled-features/src/managed-pages/handlers/by-slug.query.ts +1 -1
- package/packages/bundled-features/src/managed-pages/handlers/by-tenant-published.query.ts +1 -1
- package/packages/bundled-features/src/managed-pages/render-page-body.ts +18 -10
- package/packages/bundled-features/src/managed-pages/screens/page-screens.ts +18 -38
- package/packages/bundled-features/src/managed-pages/table.ts +1 -0
- package/packages/bundled-features/src/managed-pages/web/client-plugin.tsx +8 -6
- package/packages/bundled-features/src/managed-pages/web/constants.ts +8 -1
- package/packages/bundled-features/src/managed-pages/web/i18n.ts +11 -3
- package/packages/bundled-features/src/managed-pages/web/markdown-to-document.ts +1 -1
- package/packages/bundled-features/src/managed-pages/web/page-edit-draft.ts +108 -0
- package/packages/bundled-features/src/managed-pages/web/page-edit-screen.tsx +204 -0
- package/packages/bundled-features/src/managed-pages/web/page-settings-rail.tsx +117 -0
- package/packages/bundled-features/src/notes-history-user-data/index.ts +8 -14
- package/packages/bundled-features/src/personal-access-tokens/boot-rules.ts +5 -0
- package/packages/bundled-features/src/personal-access-tokens/handlers/create.write.ts +0 -1
- package/packages/bundled-features/src/personal-access-tokens/scope-events-check.ts +31 -5
- package/packages/bundled-features/src/presence/changes.json +6 -0
- package/packages/bundled-features/src/presence/handlers/list.query.ts +28 -11
- package/packages/bundled-features/src/presence/room.ts +21 -7
- package/packages/bundled-features/src/presence/store.ts +79 -21
- package/packages/bundled-features/src/readiness/changes.json +25 -0
- package/packages/bundled-features/src/readiness/handlers/latest-summary.query.ts +11 -6
- package/packages/bundled-features/src/readiness/handlers/run-probes.write.ts +35 -5
- package/packages/bundled-features/src/readiness/handlers/run-tone.ts +3 -2
- package/packages/bundled-features/src/readiness/handlers/status.query.ts +15 -1
- package/packages/bundled-features/src/readiness/probe-context.ts +11 -10
- package/packages/bundled-features/src/readiness/screens.ts +4 -4
- package/packages/bundled-features/src/readiness/visible-results.ts +5 -3
- package/packages/bundled-features/src/renderer-foundation/api.ts +6 -13
- package/packages/bundled-features/src/renderer-foundation/types.ts +2 -2
- package/packages/bundled-features/src/secrets/changes.json +7 -0
- package/packages/bundled-features/src/secrets/db/queries/read.ts +18 -4
- package/packages/bundled-features/src/secrets/handlers/list.query.ts +8 -2
- package/packages/bundled-features/src/secrets/secret-scope.ts +2 -3
- package/packages/bundled-features/src/secrets/secrets-context.ts +6 -4
- package/packages/bundled-features/src/secrets/write-gate.ts +4 -2
- package/packages/bundled-features/src/seo/handlers/seo-config.query.ts +1 -1
- package/packages/bundled-features/src/shared/acknowledged-system-db.ts +20 -0
- package/packages/bundled-features/src/shared/assert-billing-live.ts +9 -2
- package/packages/bundled-features/src/shared/changes.json +12 -0
- package/packages/bundled-features/src/shared/hmac-signature.ts +4 -2
- package/packages/bundled-features/src/shared/index.ts +7 -1
- package/packages/bundled-features/src/shared/normalize-email.ts +3 -0
- package/packages/bundled-features/src/shared/parent-visibility.ts +25 -1
- package/packages/bundled-features/src/shared/password-hashing.ts +0 -1
- package/packages/bundled-features/src/shared/price-env-shape.ts +1 -4
- package/packages/bundled-features/src/shared/register-user-data-hooks.ts +29 -0
- package/packages/bundled-features/src/shared/require-bootstrap-extension.ts +26 -0
- package/packages/bundled-features/src/shared/send-best-effort.ts +29 -0
- package/packages/bundled-features/src/shared/stream-tenant-backfill.ts +22 -1
- package/packages/bundled-features/src/shared/stream-tenant-derived-state.ts +31 -1
- package/packages/bundled-features/src/step-dispatcher/changes.json +18 -0
- package/packages/bundled-features/src/step-dispatcher/constants.ts +13 -0
- package/packages/bundled-features/src/step-dispatcher/deliver-dispatch-request.ts +50 -2
- package/packages/bundled-features/src/step-dispatcher/feature.ts +42 -1
- package/packages/bundled-features/src/step-dispatcher/mail-runner.ts +0 -1
- package/packages/bundled-features/src/step-dispatcher/sweep-abandoned.ts +61 -0
- package/packages/bundled-features/src/subscription-mollie/changes.json +7 -0
- package/packages/bundled-features/src/subscription-mollie/plugin-methods.ts +5 -3
- package/packages/bundled-features/src/subscription-mollie/verify-webhook.ts +5 -5
- package/packages/bundled-features/src/subscription-paddle/backfill-checkout-ledger.ts +161 -0
- package/packages/bundled-features/src/subscription-paddle/changes.json +19 -0
- package/packages/bundled-features/src/subscription-paddle/checkout-config.query.ts +1 -1
- package/packages/bundled-features/src/subscription-paddle/checkout-methods.ts +2 -8
- package/packages/bundled-features/src/subscription-paddle/constants.ts +1 -2
- package/packages/bundled-features/src/subscription-paddle/feature.ts +26 -24
- package/packages/bundled-features/src/subscription-paddle/ledger-backfill-marker.ts +70 -0
- package/packages/bundled-features/src/subscription-paddle/plan-switch-methods.ts +2 -8
- package/packages/bundled-features/src/subscription-paddle/redeliver-legacy-checkout.ts +57 -0
- package/packages/bundled-features/src/subscription-paddle/runtime.ts +13 -24
- package/packages/bundled-features/src/subscription-paddle/subscription-state.ts +1 -0
- package/packages/bundled-features/src/subscription-paddle/webhook-events.ts +68 -21
- package/packages/bundled-features/src/subscription-stripe/changes.json +13 -0
- package/packages/bundled-features/src/subscription-stripe/feature.ts +5 -0
- package/packages/bundled-features/src/subscription-stripe/plugin-methods.ts +6 -6
- package/packages/bundled-features/src/subscription-stripe/runtime.ts +8 -7
- package/packages/bundled-features/src/subscription-stripe/verify-webhook.ts +38 -6
- package/packages/bundled-features/src/tags/aggregate-id.ts +0 -1
- package/packages/bundled-features/src/tags/web/tag-chip.tsx +4 -5
- package/packages/bundled-features/src/tags/web/tag-manager.tsx +2 -1
- package/packages/bundled-features/src/template-resolver/api.ts +6 -13
- package/packages/bundled-features/src/template-resolver/changes.json +48 -0
- package/packages/bundled-features/src/template-resolver/document-sanitizer.ts +25 -0
- package/packages/bundled-features/src/template-resolver/feature.ts +2 -0
- package/packages/bundled-features/src/template-resolver/handlers/body-preview.query.ts +41 -0
- package/packages/bundled-features/src/template-resolver/handlers/by-slug.query.ts +1 -1
- package/packages/bundled-features/src/template-resolver/handlers/by-tenant.query.ts +1 -1
- package/packages/bundled-features/src/template-resolver/handlers/collection-shared.ts +5 -11
- package/packages/bundled-features/src/template-resolver/handlers/overview.query.ts +3 -2
- package/packages/bundled-features/src/template-resolver/handlers/send-test.write.ts +37 -8
- package/packages/bundled-features/src/template-resolver/linked-resources.ts +2 -5
- package/packages/bundled-features/src/template-resolver/seeding.ts +107 -0
- package/packages/bundled-features/src/template-resolver/table.ts +1 -0
- package/packages/bundled-features/src/template-resolver/template-draft.ts +2 -1
- package/packages/bundled-features/src/template-resolver/template-preview.ts +14 -3
- package/packages/bundled-features/src/template-resolver/testing.ts +0 -2
- package/packages/bundled-features/src/template-resolver/web/client-plugin.tsx +3 -0
- package/packages/bundled-features/src/template-resolver/web/collection-entry-create-form.tsx +33 -33
- package/packages/bundled-features/src/template-resolver/web/constants.ts +7 -0
- package/packages/bundled-features/src/template-resolver/web/content-tree-provider.ts +0 -1
- package/packages/bundled-features/src/template-resolver/web/content-workbench.tsx +142 -0
- package/packages/bundled-features/src/template-resolver/web/document-insert-model.ts +3 -8
- package/packages/bundled-features/src/template-resolver/web/document-link-policy.ts +58 -0
- package/packages/bundled-features/src/template-resolver/web/document-schema.ts +11 -57
- package/packages/bundled-features/src/template-resolver/web/document-tiptap-bubble.tsx +2 -4
- package/packages/bundled-features/src/template-resolver/web/document-tiptap-context.ts +4 -5
- package/packages/bundled-features/src/template-resolver/web/document-tiptap-editor.tsx +2 -2
- package/packages/bundled-features/src/template-resolver/web/document-tiptap-helpers.ts +6 -3
- package/packages/bundled-features/src/template-resolver/web/document-tiptap-toolbar-groups.tsx +2 -3
- package/packages/bundled-features/src/template-resolver/web/editor-handle.ts +1 -0
- package/packages/bundled-features/src/template-resolver/web/fill-document-variables.ts +24 -0
- package/packages/bundled-features/src/template-resolver/web/i18n.ts +14 -0
- package/packages/bundled-features/src/template-resolver/web/index.ts +3 -0
- package/packages/bundled-features/src/template-resolver/web/preview-targets.ts +25 -0
- package/packages/bundled-features/src/template-resolver/web/qualified-names.ts +1 -0
- package/packages/bundled-features/src/template-resolver/web/snippet-preview-renderer.tsx +24 -0
- package/packages/bundled-features/src/template-resolver/web/string-values.ts +7 -0
- package/packages/bundled-features/src/template-resolver/web/text-block-editor.tsx +38 -50
- package/packages/bundled-features/src/template-resolver/web/use-collection-entry-create.ts +7 -0
- package/packages/bundled-features/src/template-resolver/web/use-content-write.ts +1 -3
- package/packages/bundled-features/src/template-resolver/web/use-document-tiptap-model.ts +1 -2
- package/packages/bundled-features/src/template-resolver/web/use-text-block-editor.ts +28 -7
- package/packages/bundled-features/src/template-resolver/web/web-preview-renderer.tsx +132 -0
- package/packages/bundled-features/src/template-resolver-user-data/index.ts +11 -10
- package/packages/bundled-features/src/tenant/changes.json +6 -0
- package/packages/bundled-features/src/tenant/handlers/create.write.ts +7 -8
- package/packages/bundled-features/src/tenant/handlers/list.query.ts +7 -9
- package/packages/bundled-features/src/tenant/handlers/member-directory.query.ts +10 -4
- package/packages/bundled-features/src/tenant/handlers/toggle-enabled.write.ts +1 -1
- package/packages/bundled-features/src/tenant/invited-membership.ts +10 -1
- package/packages/bundled-features/src/tenant/seeding.ts +4 -2
- package/packages/bundled-features/src/tenant/stream-tenant-backfill.ts +5 -1
- package/packages/bundled-features/src/tenant/testing.ts +1 -1
- package/packages/bundled-features/src/tenant-inactivity/changes.json +6 -0
- package/packages/bundled-features/src/tenant-inactivity/check-inactive-tenants.ts +36 -17
- package/packages/bundled-features/src/tenant-inactivity/constants.ts +1 -2
- package/packages/bundled-features/src/tenant-inactivity/handlers/keep-account.write.ts +7 -2
- package/packages/bundled-features/src/tenant-inactivity/state-store.ts +22 -2
- package/packages/bundled-features/src/tenant-lifecycle/changes.json +24 -0
- package/packages/bundled-features/src/tenant-lifecycle/constants.ts +4 -0
- package/packages/bundled-features/src/tenant-lifecycle/feature.ts +1 -0
- package/packages/bundled-features/src/tenant-lifecycle/run-tenant-destroy.ts +43 -6
- package/packages/bundled-features/src/tenant-lifecycle/stages.ts +15 -2
- package/packages/bundled-features/src/tier-engine/aggregate-id.ts +0 -1
- package/packages/bundled-features/src/tier-engine/changes.json +6 -0
- package/packages/bundled-features/src/tier-engine/feature.ts +8 -2
- package/packages/bundled-features/src/user/changes.json +6 -0
- package/packages/bundled-features/src/user/db/queries/stream-tenant-backfill.ts +2 -1
- package/packages/bundled-features/src/user/handlers/me.query.ts +3 -1
- package/packages/bundled-features/src/user/index.ts +1 -0
- package/packages/bundled-features/src/user/resolve-verified-user-email.ts +17 -0
- package/packages/bundled-features/src/user-data-rights/db/queries/export-jobs.ts +0 -1
- package/packages/bundled-features/src/user-data-rights/feature.ts +1 -0
- package/packages/bundled-features/src/user-data-rights/handlers/confirm-deletion-by-token.write.ts +1 -1
- package/packages/bundled-features/src/user-data-rights/handlers/download-by-token.query.ts +1 -1
- package/packages/bundled-features/src/user-data-rights/handlers/request-deletion-by-email.write.ts +1 -1
- package/packages/bundled-features/src/user-data-rights/run-export-jobs.ts +0 -2
- package/packages/bundled-features/src/user-data-rights/run-forget-cleanup.ts +3 -3
- package/packages/bundled-features/src/user-data-rights/schema/download-attempt.ts +3 -2
- package/packages/bundled-features/src/user-data-rights/web/confirm-deletion-screen.tsx +1 -1
- package/packages/bundled-features/src/user-data-rights/web/privacy-center-screen.tsx +1 -1
- package/packages/bundled-features/src/user-data-rights/web/request-deletion-screen.tsx +1 -1
- package/packages/bundled-features/src/user-data-rights-defaults/hooks/api-token.userdata-hook.ts +5 -5
- package/packages/bundled-features/src/user-data-rights-defaults/hooks/hard-delete-own-rows-hook.ts +17 -0
- package/packages/bundled-features/src/user-data-rights-defaults/hooks/in-app-message.userdata-hook.ts +5 -5
- package/packages/bundled-features/src/user-data-rights-defaults/hooks/job-run.userdata-hook.ts +2 -1
- package/packages/bundled-features/src/user-data-rights-defaults/hooks/user-session.userdata-hook.ts +5 -5
- package/packages/bundled-features/src/user-profile/handlers/change-email.write.ts +0 -1
- package/packages/bundled-features/src/waitlist/changes.json +6 -0
- package/packages/bundled-features/src/waitlist/handlers/reject.write.ts +1 -1
- package/packages/bundled-features/src/waitlist/handlers/submit.write.ts +5 -29
- package/packages/bundled-features/src/waitlist/import.ts +2 -1
- package/packages/bundled-features/src/waitlist/lib.ts +2 -11
- package/packages/bundled-features/src/waitlist/link-on-signup.ts +2 -2
- package/packages/bundled-features/src/waitlist/user-data-hooks.ts +6 -19
- package/packages/bundled-features/src/workflow-runner/aggregate-id.ts +0 -1
- package/packages/bundled-features/src/workflow-runner/changes.json +6 -0
- package/packages/bundled-features/src/workflow-runner/event-trigger.ts +6 -2
- package/packages/bundled-features/src/workflow-runner/feature.ts +1 -5
- package/packages/bundled-features/src/workflow-runner/handlers/resume-run.write.ts +7 -4
- package/packages/bundled-features/src/workflow-runner/runner.ts +2 -0
- package/samples/apps/admin-console/src/app/shell.tsx +1 -0
- package/samples/apps/showcase/src/features/demos/web/pages/dialog.tsx +0 -1
- package/samples/apps/showcase/src/features/demos/web/pages/layout.tsx +1 -1
- package/samples/apps/showcase/src/features/demos/web/pages/sidebar-panel.tsx +0 -1
- package/samples/apps/styleguide/src/features/gallery/web/Gallery.tsx +1 -4
- package/samples/apps/ui-walkthrough/src/features/subscription-plans/feature.ts +6 -2
- package/samples/apps/use-all-bundled/e2e-billing-gallery/gallery-features.ts +12 -14
- package/samples/apps/use-all-bundled/feature-manifest.json +60 -29
- package/samples/apps/use-all-bundled/playwright.billing-docs.config.ts +1 -1
- package/samples/apps/use-all-bundled/playwright.config.ts +1 -0
- package/samples/apps/use-all-bundled/src/app/seed.ts +1 -1
- package/samples/apps/use-all-bundled/src/run-config.ts +2 -1
- package/samples/recipes/auth-mfa/src/web/confirmation-code-step.tsx +32 -10
- package/samples/recipes/chat-channels/README.md +2 -0
- package/samples/recipes/crypto-shredding-hr/README.md +11 -0
- package/samples/recipes/crypto-shredding-hr/src/feature.ts +27 -0
- package/samples/recipes/currencies-global/src/entities/currency.ts +1 -0
- package/samples/recipes/managed-pages/README.md +5 -1
- package/samples/recipes/managed-pages/package.json +3 -2
- package/samples/recipes/managed-pages/src/web/branded-preview.tsx +21 -0
- package/samples/recipes/managed-pages/tsconfig.json +8 -0
- package/samples/recipes/pwa-shell/README.md +52 -0
- package/samples/recipes/pwa-shell/bin/server.ts +12 -0
- package/samples/recipes/pwa-shell/package.json +13 -0
- package/samples/recipes/pwa-shell/src/app.ts +34 -0
- package/samples/recipes/rate-limiting/README.md +3 -3
- package/samples/recipes/record-detail-layout/README.md +33 -0
- package/samples/recipes/record-detail-layout/src/feature.ts +556 -44
- package/samples/recipes/record-detail-layout/src/order-board.ts +529 -0
- package/packages/bundled-features/src/managed-pages/web/page-body-section.tsx +0 -72
- package/packages/bundled-features/src/subscription-paddle/tenant-binding.ts +0 -34
- package/packages/bundled-features/src/template-resolver/web/content-field.tsx +0 -61
package/packages/bundled-features/src/inbound-mail-foundation/handlers/forget-message.write.ts
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { WriteHandlerDef } from "@cosmicdrift/kumiko-framework/engine";
|
|
2
|
+
import {
|
|
3
|
+
AccessDeniedError,
|
|
4
|
+
failNotFound,
|
|
5
|
+
writeFailure,
|
|
6
|
+
} from "@cosmicdrift/kumiko-framework/errors";
|
|
7
|
+
import { deleteFileRefsBoundToRecord } from "@cosmicdrift/kumiko-framework/files";
|
|
8
|
+
import * as z from "zod";
|
|
9
|
+
import { INBOUND_MESSAGE_AGGREGATE_TYPE } from "../events.ts";
|
|
10
|
+
import type { InboundMailRoles } from "../mail-roles.ts";
|
|
11
|
+
import { inboundMessagesProjectionTable } from "../projection.ts";
|
|
12
|
+
import { purgeInboundMessages } from "../purge-messages.ts";
|
|
13
|
+
import { isVisibleToCaller, mayReactivateMailbox } from "./scope-visibility.ts";
|
|
14
|
+
|
|
15
|
+
export const forgetMessageSchema = z.object({ messageId: z.uuid() });
|
|
16
|
+
|
|
17
|
+
const FORGET_REASON = "forgotten_by_user";
|
|
18
|
+
|
|
19
|
+
export function createForgetMessageHandler({
|
|
20
|
+
memberRoles,
|
|
21
|
+
adminRoles,
|
|
22
|
+
}: InboundMailRoles): WriteHandlerDef {
|
|
23
|
+
return {
|
|
24
|
+
name: "forget-message",
|
|
25
|
+
schema: forgetMessageSchema,
|
|
26
|
+
access: { roles: [...memberRoles] },
|
|
27
|
+
agent: { risk: "high" },
|
|
28
|
+
description:
|
|
29
|
+
"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.",
|
|
30
|
+
handler: async (event, ctx) => {
|
|
31
|
+
const { messageId } = forgetMessageSchema.parse(event.payload);
|
|
32
|
+
const [row] = await ctx.db.selectMany<{
|
|
33
|
+
readonly id: string;
|
|
34
|
+
readonly bodyRef: string | null;
|
|
35
|
+
readonly ownerUserId: string | null;
|
|
36
|
+
}>(inboundMessagesProjectionTable, { id: messageId });
|
|
37
|
+
if (!row || !isVisibleToCaller(row, event.user)) {
|
|
38
|
+
return failNotFound("inbound-message", messageId);
|
|
39
|
+
}
|
|
40
|
+
if (!mayReactivateMailbox(row.ownerUserId, event.user, adminRoles)) {
|
|
41
|
+
return writeFailure(new AccessDeniedError({ details: { reason: "not_mailbox_owner" } }));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const { files } = ctx.services;
|
|
45
|
+
// Without file storage the original could not be deleted, and the row held its only reference.
|
|
46
|
+
if (row.bodyRef && !files) {
|
|
47
|
+
throw new Error(
|
|
48
|
+
`forget-message: no file storage to delete the stored original of ${messageId}`,
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
const purged = await purgeInboundMessages({
|
|
52
|
+
db: ctx.db,
|
|
53
|
+
tenantId: event.user.tenantId,
|
|
54
|
+
rows: [row],
|
|
55
|
+
archive: (id) =>
|
|
56
|
+
ctx.events.archive(id, {
|
|
57
|
+
aggregateType: INBOUND_MESSAGE_AGGREGATE_TYPE,
|
|
58
|
+
reason: FORGET_REASON,
|
|
59
|
+
}),
|
|
60
|
+
deleteBodyObject: files
|
|
61
|
+
? (bodyRef) => files.refFromFileRef({ storageKey: bodyRef }).delete()
|
|
62
|
+
: undefined,
|
|
63
|
+
deleteAttachments: async (id) => {
|
|
64
|
+
await deleteFileRefsBoundToRecord({
|
|
65
|
+
db: ctx.db,
|
|
66
|
+
user: event.user,
|
|
67
|
+
entityType: INBOUND_MESSAGE_AGGREGATE_TYPE,
|
|
68
|
+
entityId: id,
|
|
69
|
+
});
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
// Rolls the archive back: a half-deleted mail must stay retryable.
|
|
73
|
+
if (purged.failedIds.length > 0) {
|
|
74
|
+
throw new Error(`forget-message: the stored files of ${messageId} could not be deleted`);
|
|
75
|
+
}
|
|
76
|
+
return { isSuccess: true as const, data: { forgotten: true as const } };
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
}
|
package/packages/bundled-features/src/inbound-mail-foundation/handlers/ingest-message-schema.ts
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import * as z from "zod";
|
|
2
|
+
import {
|
|
3
|
+
INBOUND_ADDRESS_LIST_JSON_MAX_CHARS,
|
|
4
|
+
INBOUND_FROM_MAX_CHARS,
|
|
5
|
+
INBOUND_SNIPPET_MAX_CHARS,
|
|
6
|
+
INBOUND_SUBJECT_MAX_CHARS,
|
|
7
|
+
} from "../normalize-inbound-message.ts";
|
|
2
8
|
import { senderAuthenticationFieldSchema } from "../sender-auth.ts";
|
|
3
9
|
import { inboundContentPayloadShape } from "./message-content.ts";
|
|
4
10
|
|
|
@@ -9,6 +15,13 @@ import { inboundContentPayloadShape } from "./message-content.ts";
|
|
|
9
15
|
// storage here; the event itself stays blob-free (references only).
|
|
10
16
|
// =============================================================================
|
|
11
17
|
|
|
18
|
+
const addressListSchema = z
|
|
19
|
+
.array(z.string().max(2000))
|
|
20
|
+
.max(200)
|
|
21
|
+
.refine((list) => JSON.stringify(list).length <= INBOUND_ADDRESS_LIST_JSON_MAX_CHARS, {
|
|
22
|
+
message: "serialized address list too long",
|
|
23
|
+
});
|
|
24
|
+
|
|
12
25
|
export const ingestMessageSchema = z.object({
|
|
13
26
|
accountId: z.uuid(),
|
|
14
27
|
/** Scope inherited from the account — the supervisor knows the
|
|
@@ -22,11 +35,11 @@ export const ingestMessageSchema = z.object({
|
|
|
22
35
|
providerThreadId: z.string().min(1).max(500).nullable(),
|
|
23
36
|
/** References/In-Reply-To chain, oldest first. */
|
|
24
37
|
references: z.array(z.string().min(1).max(500)).max(200),
|
|
25
|
-
from: z.string().min(1).max(
|
|
26
|
-
to:
|
|
27
|
-
cc:
|
|
28
|
-
subject: z.string().max(
|
|
29
|
-
snippet: z.string().max(
|
|
38
|
+
from: z.string().min(1).max(INBOUND_FROM_MAX_CHARS),
|
|
39
|
+
to: addressListSchema,
|
|
40
|
+
cc: addressListSchema,
|
|
41
|
+
subject: z.string().max(INBOUND_SUBJECT_MAX_CHARS),
|
|
42
|
+
snippet: z.string().max(INBOUND_SNIPPET_MAX_CHARS),
|
|
30
43
|
receivedAtIso: z.string().min(1),
|
|
31
44
|
/** From the app's storeBody hook; empty lets the handler store the original itself. */
|
|
32
45
|
bodyRef: z.string().max(500),
|
|
@@ -60,6 +60,9 @@ export const INBOUND_MAIL_FOUNDATION_I18N: Readonly<Record<string, { readonly en
|
|
|
60
60
|
[InboundMailConnectErrors.addressDisconnected.i18nKey]: {
|
|
61
61
|
en: "This mailbox was disconnected before. Use Reactivate in the mailbox list to keep its history.",
|
|
62
62
|
},
|
|
63
|
+
[InboundMailConnectErrors.personalAddressNotOwn.i18nKey]: {
|
|
64
|
+
en: "A personal mailbox can only be connected with the email address of your own account. An admin connects other addresses as a shared mailbox.",
|
|
65
|
+
},
|
|
63
66
|
"inboundMail.accounts.acknowledgeQuarantine": { en: "Confirm quarantine" },
|
|
64
67
|
[`${MAIL_ACCOUNT_STATUS_OPTION_KEY_PREFIX}${InboundMailAccountStatuses.active}`]: {
|
|
65
68
|
en: "Active",
|
|
@@ -6,6 +6,9 @@ import type { RawInboundAttachment, RawInboundMessage, SkippedInboundAttachment
|
|
|
6
6
|
|
|
7
7
|
export const INBOUND_MISSING_SENDER = "(no sender)";
|
|
8
8
|
export const INBOUND_BODY_TEXT_MAX_CHARS = 32_000;
|
|
9
|
+
// Counted in UTF-8 bytes, not characters: the ciphertext grows with the bytes, and a CJK or emoji
|
|
10
|
+
// mail of 500,000 characters would encrypt past the event's bodyHtml maximum.
|
|
11
|
+
export const INBOUND_BODY_HTML_MAX_BYTES = 500_000;
|
|
9
12
|
export const INBOUND_BODY_HTML_MAX_CHARS = 5_000_000;
|
|
10
13
|
export const INBOUND_ATTACHMENT_MAX_BYTES = 25 * 1024 * 1024;
|
|
11
14
|
export const INBOUND_MAIL_ATTACHMENTS_MAX_BYTES = 50 * 1024 * 1024;
|
|
@@ -14,13 +17,16 @@ export const INBOUND_RAW_MIME_MAX_BYTES = INBOUND_MAIL_ATTACHMENTS_MAX_BYTES;
|
|
|
14
17
|
export const INBOUND_ATTACHMENTS_MAX_COUNT = 50;
|
|
15
18
|
export const INBOUND_SKIPPED_ATTACHMENTS_MAX_COUNT = 200;
|
|
16
19
|
|
|
17
|
-
const
|
|
20
|
+
export const INBOUND_FROM_MAX_CHARS = 2000;
|
|
21
|
+
export const INBOUND_SUBJECT_MAX_CHARS = 4000;
|
|
22
|
+
export const INBOUND_SNIPPET_MAX_CHARS = 4000;
|
|
23
|
+
export const INBOUND_MAIL_ADDRESS_MAX_CHARS = 320;
|
|
24
|
+
// Plaintext of one JSON-stringified to/cc list; its ciphertext must fit the event and entity field.
|
|
25
|
+
export const INBOUND_ADDRESS_LIST_JSON_MAX_CHARS = 8000;
|
|
18
26
|
const ADDRESS_MAX = 2000;
|
|
19
27
|
const ADDRESS_LIST_MAX = 200;
|
|
20
28
|
const REFERENCE_MAX = 500;
|
|
21
29
|
const REFERENCES_MAX = 200;
|
|
22
|
-
const SUBJECT_MAX = 4000;
|
|
23
|
-
const SNIPPET_MAX = 4000;
|
|
24
30
|
const MESSAGE_ID_HEADER_MAX = 500;
|
|
25
31
|
|
|
26
32
|
export type NormalizedInboundMessage = Omit<
|
|
@@ -45,6 +51,14 @@ function clip(value: string, max: number): string {
|
|
|
45
51
|
return value.slice(0, cut);
|
|
46
52
|
}
|
|
47
53
|
|
|
54
|
+
function limitAddressList(list: readonly string[]): readonly string[] {
|
|
55
|
+
const kept = list.slice(0, ADDRESS_LIST_MAX).map((a) => clip(a, ADDRESS_MAX));
|
|
56
|
+
while (kept.length > 0 && JSON.stringify(kept).length > INBOUND_ADDRESS_LIST_JSON_MAX_CHARS) {
|
|
57
|
+
kept.pop();
|
|
58
|
+
}
|
|
59
|
+
return kept;
|
|
60
|
+
}
|
|
61
|
+
|
|
48
62
|
function limitReferences(references: readonly string[]): readonly string[] {
|
|
49
63
|
const usable = references.filter((r) => r.length > 0 && r.length <= REFERENCE_MAX);
|
|
50
64
|
if (usable.length <= REFERENCES_MAX) return usable;
|
|
@@ -102,11 +116,11 @@ export function normalizeRawInboundMessage(msg: RawInboundMessage): NormalizedIn
|
|
|
102
116
|
? msg.messageIdHeader
|
|
103
117
|
: null,
|
|
104
118
|
references: limitReferences(msg.references),
|
|
105
|
-
from: from.length === 0 ? INBOUND_MISSING_SENDER : clip(from,
|
|
106
|
-
to: msg.to
|
|
107
|
-
cc: msg.cc
|
|
108
|
-
subject: clip(msg.subject,
|
|
109
|
-
snippet: clip(msg.snippet,
|
|
119
|
+
from: from.length === 0 ? INBOUND_MISSING_SENDER : clip(from, INBOUND_FROM_MAX_CHARS),
|
|
120
|
+
to: limitAddressList(msg.to),
|
|
121
|
+
cc: limitAddressList(msg.cc),
|
|
122
|
+
subject: clip(msg.subject, INBOUND_SUBJECT_MAX_CHARS),
|
|
123
|
+
snippet: clip(msg.snippet, INBOUND_SNIPPET_MAX_CHARS),
|
|
110
124
|
bodyText: clip(fullText, INBOUND_BODY_TEXT_MAX_CHARS),
|
|
111
125
|
bodyTextTruncated: fullText.length > INBOUND_BODY_TEXT_MAX_CHARS,
|
|
112
126
|
bodyHtml: bodyHtml !== null && bodyHtml.length <= INBOUND_BODY_HTML_MAX_CHARS ? bodyHtml : null,
|
|
@@ -166,7 +166,7 @@ export function createOAuthAccessTokenManager(
|
|
|
166
166
|
const hit = cachedValid(account.id);
|
|
167
167
|
if (hit !== undefined) return hit;
|
|
168
168
|
const running = inFlight.get(account.id);
|
|
169
|
-
if (running) return running;
|
|
169
|
+
if (running !== undefined) return running;
|
|
170
170
|
const started = refresh(account, plugin)
|
|
171
171
|
.catch((err: unknown) => {
|
|
172
172
|
cache.delete(account.id);
|
|
@@ -48,6 +48,8 @@ export type OutboundAttachment = {
|
|
|
48
48
|
export type ProviderSentMail = {
|
|
49
49
|
/** Message-ID header of the sent mail, without angle brackets. */
|
|
50
50
|
readonly messageIdHeader: string;
|
|
51
|
+
/** Recipients the outgoing server refused while accepting the others; absent when all were accepted. */
|
|
52
|
+
readonly rejectedRecipients?: readonly string[];
|
|
51
53
|
};
|
|
52
54
|
|
|
53
55
|
export type OutboundMailSent = ProviderSentMail & {
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
import { decryptStoredUserEmail } from "../shared/index.ts";
|
|
3
|
+
|
|
4
|
+
const userRowSchema = z.object({
|
|
5
|
+
email: z.string().optional(),
|
|
6
|
+
isDeleted: z.boolean().nullish(),
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
// A personal mailbox may only carry the caller's own login address: the login check of a password
|
|
10
|
+
// IMAP server (or the OAuth consent) does not bind the address, so a free choice would let a member
|
|
11
|
+
// claim info@firma.de. `userRow` is the user:find-for-auth row of the session user, never payload data.
|
|
12
|
+
export async function isOwnLoginAddress(userRow: unknown, address: string): Promise<boolean> {
|
|
13
|
+
const row = userRowSchema.safeParse(userRow);
|
|
14
|
+
if (!row.success || !row.data.email || row.data.isDeleted === true) return false;
|
|
15
|
+
const own = await decryptStoredUserEmail(
|
|
16
|
+
row.data.email,
|
|
17
|
+
"inbound-mail-foundation:personal-address",
|
|
18
|
+
);
|
|
19
|
+
return own !== null && own.trim().toLowerCase() === address.trim().toLowerCase();
|
|
20
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { TenantId } from "@cosmicdrift/kumiko-framework/engine";
|
|
2
|
+
import { deleteRowsWithoutReplayableStream } from "@cosmicdrift/kumiko-framework/event-store";
|
|
3
|
+
import { inboundMessagesProjectionTable } from "./projection.ts";
|
|
4
|
+
|
|
5
|
+
export type PurgeableMessageRow = { readonly id: string; readonly bodyRef: string | null };
|
|
6
|
+
|
|
7
|
+
export interface PurgeInboundMessagesArgs {
|
|
8
|
+
readonly db: Parameters<typeof deleteRowsWithoutReplayableStream>[0];
|
|
9
|
+
readonly tenantId: TenantId;
|
|
10
|
+
readonly rows: readonly PurgeableMessageRow[];
|
|
11
|
+
readonly archive: (messageId: string) => Promise<void>;
|
|
12
|
+
readonly deleteBodyObject?: ((bodyRef: string) => Promise<void>) | undefined;
|
|
13
|
+
readonly deleteAttachments?: ((messageId: string) => Promise<void>) | undefined;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface PurgeInboundMessagesResult {
|
|
17
|
+
readonly purgedIds: readonly string[];
|
|
18
|
+
readonly failedIds: readonly string[];
|
|
19
|
+
readonly bodyObjectsDeleted: number;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Archive first, delete the row last and strictly by the archived ids: a crash in between leaves an
|
|
23
|
+
// archived stream the next run finishes, and a row is never deleted while its stream could replay.
|
|
24
|
+
// A row whose body or attachment delete fails stays, otherwise the only reference to the object is lost.
|
|
25
|
+
export async function purgeInboundMessages(
|
|
26
|
+
args: PurgeInboundMessagesArgs,
|
|
27
|
+
): Promise<PurgeInboundMessagesResult> {
|
|
28
|
+
const purgedCandidates: string[] = [];
|
|
29
|
+
const failedIds: string[] = [];
|
|
30
|
+
let bodyObjectsDeleted = 0;
|
|
31
|
+
for (const row of args.rows) {
|
|
32
|
+
await args.archive(row.id);
|
|
33
|
+
try {
|
|
34
|
+
if (row.bodyRef && args.deleteBodyObject) {
|
|
35
|
+
await args.deleteBodyObject(row.bodyRef);
|
|
36
|
+
bodyObjectsDeleted++;
|
|
37
|
+
}
|
|
38
|
+
await args.deleteAttachments?.(row.id);
|
|
39
|
+
} catch {
|
|
40
|
+
failedIds.push(row.id);
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
purgedCandidates.push(row.id);
|
|
44
|
+
}
|
|
45
|
+
const purgedIds =
|
|
46
|
+
purgedCandidates.length === 0
|
|
47
|
+
? []
|
|
48
|
+
: await deleteRowsWithoutReplayableStream(args.db, {
|
|
49
|
+
table: inboundMessagesProjectionTable,
|
|
50
|
+
ids: purgedCandidates,
|
|
51
|
+
tenantId: args.tenantId,
|
|
52
|
+
});
|
|
53
|
+
return { purgedIds, failedIds, bodyObjectsDeleted };
|
|
54
|
+
}
|
|
@@ -22,12 +22,15 @@ export async function quarantineMessage(
|
|
|
22
22
|
target: QuarantineTarget,
|
|
23
23
|
reasonCode: QuarantineReasonCode,
|
|
24
24
|
): Promise<boolean> {
|
|
25
|
-
const key = {
|
|
25
|
+
const key = {
|
|
26
|
+
tenantId: target.tenantId,
|
|
27
|
+
accountId: target.accountId,
|
|
28
|
+
providerMessageId: target.providerMessageId,
|
|
29
|
+
};
|
|
26
30
|
if (await fetchOne<{ id: string }>(db, quarantineTable, key)) return false;
|
|
27
31
|
try {
|
|
28
32
|
await insertOne(db, quarantineTable, {
|
|
29
33
|
id: crypto.randomUUID(),
|
|
30
|
-
tenantId: target.tenantId,
|
|
31
34
|
...key,
|
|
32
35
|
reasonCode,
|
|
33
36
|
quarantinedAt: Temporal.Now.instant().toString(),
|
|
@@ -40,9 +43,12 @@ export async function quarantineMessage(
|
|
|
40
43
|
}
|
|
41
44
|
}
|
|
42
45
|
|
|
46
|
+
// tenantId leads the lookups: the unique index and the tenant index are the only ones on the table.
|
|
47
|
+
type QuarantineAccount = Pick<QuarantineTarget, "tenantId" | "accountId">;
|
|
48
|
+
|
|
43
49
|
export async function quarantinedMessageIds(
|
|
44
50
|
db: DbConnection,
|
|
45
|
-
accountId:
|
|
51
|
+
{ tenantId, accountId }: QuarantineAccount,
|
|
46
52
|
providerMessageIds: readonly string[],
|
|
47
53
|
): Promise<ReadonlySet<string>> {
|
|
48
54
|
const ids = new Set<string>();
|
|
@@ -51,6 +57,7 @@ export async function quarantinedMessageIds(
|
|
|
51
57
|
db,
|
|
52
58
|
quarantineTable,
|
|
53
59
|
{
|
|
60
|
+
tenantId,
|
|
54
61
|
accountId,
|
|
55
62
|
providerMessageId: { in: providerMessageIds.slice(start, start + LOOKUP_CHUNK_SIZE) },
|
|
56
63
|
},
|
|
@@ -61,11 +68,14 @@ export async function quarantinedMessageIds(
|
|
|
61
68
|
return ids;
|
|
62
69
|
}
|
|
63
70
|
|
|
64
|
-
export async function hasOpenQuarantine(
|
|
71
|
+
export async function hasOpenQuarantine(
|
|
72
|
+
db: DbConnection,
|
|
73
|
+
{ tenantId, accountId }: QuarantineAccount,
|
|
74
|
+
): Promise<boolean> {
|
|
65
75
|
const rows = await selectMany<{ id: string }>(
|
|
66
76
|
db,
|
|
67
77
|
quarantineTable,
|
|
68
|
-
{ accountId, acknowledgedAt: null },
|
|
78
|
+
{ tenantId, accountId, acknowledgedAt: null },
|
|
69
79
|
{ fields: ["id"], limit: 1 },
|
|
70
80
|
);
|
|
71
81
|
return rows.length > 0;
|
|
@@ -26,11 +26,7 @@ export function registerInboundMailRetentionJob(r: FeatureRegistrar<"inbound-mai
|
|
|
26
26
|
if (!ctx.registry) {
|
|
27
27
|
throw new Error("inbound-mail-retention: ctx.registry required (JobContext incomplete)");
|
|
28
28
|
}
|
|
29
|
-
const tenantId = ctx.systemUser
|
|
30
|
-
if (tenantId === undefined) {
|
|
31
|
-
// skip: cron fired without a perTenant fan-out tenant — nothing scoped
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
29
|
+
const tenantId = ctx.systemUser.tenantId;
|
|
34
30
|
const T = (await import("@cosmicdrift/kumiko-framework/time")).getTemporal();
|
|
35
31
|
const retentionDb = ctx.db.unsafeRaw() as DbConnection; // @cast-boundary db-operator — jobs never run inside a DbTx
|
|
36
32
|
|
|
@@ -40,15 +40,13 @@
|
|
|
40
40
|
|
|
41
41
|
import { type DbRunner, deleteMany, selectMany } from "@cosmicdrift/kumiko-framework/db";
|
|
42
42
|
import type { TenantId } from "@cosmicdrift/kumiko-framework/engine";
|
|
43
|
-
import {
|
|
44
|
-
archiveStream,
|
|
45
|
-
deleteRowsWithoutReplayableStream,
|
|
46
|
-
} from "@cosmicdrift/kumiko-framework/event-store";
|
|
43
|
+
import { archiveStream } from "@cosmicdrift/kumiko-framework/event-store";
|
|
47
44
|
import type { getTemporal } from "@cosmicdrift/kumiko-framework/time";
|
|
48
45
|
import { seenMessageTable } from "./entities.ts";
|
|
49
46
|
import { INBOUND_MESSAGE_AGGREGATE_TYPE } from "./events.ts";
|
|
50
47
|
import { ingestFailureTable } from "./ingest-failures.ts";
|
|
51
48
|
import { inboundMessagesProjectionTable } from "./projection.ts";
|
|
49
|
+
import { purgeInboundMessages } from "./purge-messages.ts";
|
|
52
50
|
import { QUARANTINE_ACKNOWLEDGED_RETENTION_DAYS } from "./quarantine.ts";
|
|
53
51
|
import { quarantineTable } from "./quarantine-entities.ts";
|
|
54
52
|
|
|
@@ -150,36 +148,25 @@ async function purgeExpiredMessages(
|
|
|
150
148
|
).filter((row) => !failedIds.has(row.id));
|
|
151
149
|
if (rows.length === 0) break;
|
|
152
150
|
|
|
153
|
-
const
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
}
|
|
173
|
-
ids.push(row.id);
|
|
174
|
-
}
|
|
175
|
-
if (ids.length > 0) {
|
|
176
|
-
const deleted = await deleteRowsWithoutReplayableStream(args.db, {
|
|
177
|
-
table: inboundMessagesProjectionTable,
|
|
178
|
-
ids,
|
|
179
|
-
tenantId: args.tenantId,
|
|
180
|
-
});
|
|
181
|
-
messagesPurged += deleted.length;
|
|
182
|
-
}
|
|
151
|
+
const purged = await purgeInboundMessages({
|
|
152
|
+
db: args.db,
|
|
153
|
+
tenantId: args.tenantId,
|
|
154
|
+
rows,
|
|
155
|
+
archive: (messageId) =>
|
|
156
|
+
archiveStream(args.db, {
|
|
157
|
+
tenantId: args.tenantId,
|
|
158
|
+
aggregateId: messageId,
|
|
159
|
+
aggregateType: INBOUND_MESSAGE_AGGREGATE_TYPE,
|
|
160
|
+
archivedBy: ARCHIVED_BY,
|
|
161
|
+
reason: REASON,
|
|
162
|
+
}),
|
|
163
|
+
deleteBodyObject: args.deleteBodyObject,
|
|
164
|
+
deleteAttachments: args.deleteAttachments,
|
|
165
|
+
});
|
|
166
|
+
messagesPurged += purged.purgedIds.length;
|
|
167
|
+
bodyObjectsDeleted += purged.bodyObjectsDeleted;
|
|
168
|
+
bodyObjectErrors += purged.failedIds.length;
|
|
169
|
+
for (const id of purged.failedIds) failedIds.add(id);
|
|
183
170
|
|
|
184
171
|
if (rows.length < BATCH_LIMIT) break;
|
|
185
172
|
}
|
|
@@ -2,10 +2,7 @@
|
|
|
2
2
|
// shown by the reader inside a script-free sandboxed iframe; this is the first of the two layers.
|
|
3
3
|
|
|
4
4
|
import sanitizeHtml from "sanitize-html";
|
|
5
|
-
|
|
6
|
-
// Counted in UTF-8 bytes, not characters: the ciphertext grows with the bytes, and a CJK or emoji
|
|
7
|
-
// mail of 500,000 characters would encrypt past the event's bodyHtml maximum.
|
|
8
|
-
export const BODY_HTML_MAX_BYTES = 500_000;
|
|
5
|
+
import { INBOUND_BODY_HTML_MAX_BYTES } from "./normalize-inbound-message.ts";
|
|
9
6
|
|
|
10
7
|
const ALLOWED_TAGS = [
|
|
11
8
|
"p",
|
|
@@ -144,7 +141,7 @@ export function sanitizeInboundHtml(html: string): string | null {
|
|
|
144
141
|
// An image whose src was stripped (cid:, data:, other scheme) is only a broken placeholder.
|
|
145
142
|
exclusiveFilter: (frame) => frame.tag === "img" && frame.attribs["src"] === undefined,
|
|
146
143
|
}).trim();
|
|
147
|
-
return clean.length === 0 || Buffer.byteLength(clean, "utf8") >
|
|
144
|
+
return clean.length === 0 || Buffer.byteLength(clean, "utf8") > INBOUND_BODY_HTML_MAX_BYTES
|
|
148
145
|
? null
|
|
149
146
|
: clean;
|
|
150
147
|
}
|
|
@@ -93,6 +93,10 @@ function isSendableBy(row: MailAccountRow, user: SendMailFromAccountContext["use
|
|
|
93
93
|
return row.status !== InboundMailAccountStatuses.disconnected && isVisibleToCaller(row, user);
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
+
// Sends immediately and cannot be rolled back. Call it from a handler's `beforeTransaction`
|
|
97
|
+
// (its ctx fits here): in the handler body the request transaction would stay open for the whole
|
|
98
|
+
// SMTP/IMAP round trip, and a later rollback would not recall the mail. Pass the result on as the
|
|
99
|
+
// hook's data; a client retry after a failed handler still sends a second copy.
|
|
96
100
|
export async function sendMailFromAccount(
|
|
97
101
|
ctx: SendMailFromAccountContext,
|
|
98
102
|
input: SendMailFromAccountInput,
|
|
@@ -123,7 +127,11 @@ export async function sendMailFromAccount(
|
|
|
123
127
|
const sent = await plugin.send(providerCtx, account, message.data, resolved.attachments);
|
|
124
128
|
return {
|
|
125
129
|
isSuccess: true,
|
|
126
|
-
data: {
|
|
130
|
+
data: {
|
|
131
|
+
messageIdHeader: sent.messageIdHeader,
|
|
132
|
+
attachmentFileIds: resolved.fileIds,
|
|
133
|
+
...(sent.rejectedRecipients && { rejectedRecipients: sent.rejectedRecipients }),
|
|
134
|
+
},
|
|
127
135
|
};
|
|
128
136
|
} catch (err) {
|
|
129
137
|
const failure = sendFailureOf(err);
|
|
@@ -181,7 +181,11 @@ export function createMessageIngester(deps: IngesterDeps): MessageIngester {
|
|
|
181
181
|
): Promise<Attempt> {
|
|
182
182
|
try {
|
|
183
183
|
const msg = normalizeRawInboundMessage(raw);
|
|
184
|
-
|
|
184
|
+
// Normalization drops an oversized original; the hook must not store what ingest then discards.
|
|
185
|
+
const bodyRef = await storeBodyOf(
|
|
186
|
+
account,
|
|
187
|
+
msg.rawMime === null ? { ...raw, rawMime: null } : raw,
|
|
188
|
+
);
|
|
185
189
|
const result = await deps.dispatchWrite({
|
|
186
190
|
handlerQn: InboundMailFoundationHandlers.ingestMessage,
|
|
187
191
|
tenantId: account.tenantId,
|
|
@@ -273,6 +277,8 @@ export function createMessageIngester(deps: IngesterDeps): MessageIngester {
|
|
|
273
277
|
let storageHealthy = options.proof?.storageHealthy ?? false;
|
|
274
278
|
const failures: Failure[] = [];
|
|
275
279
|
for (const msg of msgs) {
|
|
280
|
+
// An abandoned sync (deadline) must stop storing mail while the next sync of the account runs.
|
|
281
|
+
options.signal?.throwIfAborted();
|
|
276
282
|
const result = await attempt(account, msg, cursorSnapshot);
|
|
277
283
|
if (result.kind === "permanent") {
|
|
278
284
|
const headerOnly = headerOnlyOf(msg);
|
|
@@ -24,7 +24,7 @@ export function runExclusivePerAccount(
|
|
|
24
24
|
run: () => Promise<void>,
|
|
25
25
|
): Promise<void> {
|
|
26
26
|
const running = inFlight.get(accountId);
|
|
27
|
-
if (running) return running;
|
|
27
|
+
if (running !== undefined) return running;
|
|
28
28
|
const started = run().finally(() => {
|
|
29
29
|
inFlight.delete(accountId);
|
|
30
30
|
});
|
|
@@ -15,7 +15,6 @@
|
|
|
15
15
|
// tenant subject key, making event-log payloads AND any ciphertext copies
|
|
16
16
|
// unreadable. These hooks dispose of the rows.
|
|
17
17
|
|
|
18
|
-
import type { EntityTableMeta } from "@cosmicdrift/kumiko-framework/db";
|
|
19
18
|
import type { TenantDataHookCtx } from "@cosmicdrift/kumiko-framework/engine";
|
|
20
19
|
import { archiveAndDeleteTenantRows } from "../tenant-lifecycle/index.ts";
|
|
21
20
|
import { seenMessageTable, syncCursorTable } from "./entities.ts";
|
|
@@ -36,24 +35,12 @@ import { quarantineTable } from "./quarantine-entities.ts";
|
|
|
36
35
|
export const INBOUND_MAIL_TENANT_DESTROY_ARCHIVE_REASON =
|
|
37
36
|
"tenant-destroy archives each inbound-mail entity's event-streams before the projection rows are deleted";
|
|
38
37
|
|
|
39
|
-
function archiveAndDeleteRows(
|
|
40
|
-
ctx: TenantDataHookCtx,
|
|
41
|
-
table: EntityTableMeta,
|
|
42
|
-
aggregateType: string,
|
|
43
|
-
): Promise<readonly string[]> {
|
|
44
|
-
return archiveAndDeleteTenantRows(
|
|
45
|
-
ctx,
|
|
46
|
-
table,
|
|
47
|
-
aggregateType,
|
|
48
|
-
INBOUND_MAIL_TENANT_DESTROY_ARCHIVE_REASON,
|
|
49
|
-
);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
38
|
export async function mailAccountTenantDestroyHook(ctx: TenantDataHookCtx): Promise<void> {
|
|
53
|
-
const accountIds = await
|
|
39
|
+
const accountIds = await archiveAndDeleteTenantRows(
|
|
54
40
|
ctx,
|
|
55
41
|
mailAccountsProjectionTable,
|
|
56
42
|
MAIL_ACCOUNT_AGGREGATE_TYPE,
|
|
43
|
+
INBOUND_MAIL_TENANT_DESTROY_ARCHIVE_REASON,
|
|
57
44
|
);
|
|
58
45
|
for (const accountId of accountIds) {
|
|
59
46
|
await ctx.db.deleteMany(syncCursorTable, { accountId });
|
|
@@ -64,9 +51,19 @@ export async function mailAccountTenantDestroyHook(ctx: TenantDataHookCtx): Prom
|
|
|
64
51
|
}
|
|
65
52
|
|
|
66
53
|
export async function inboundMessageTenantDestroyHook(ctx: TenantDataHookCtx): Promise<void> {
|
|
67
|
-
await
|
|
54
|
+
await archiveAndDeleteTenantRows(
|
|
55
|
+
ctx,
|
|
56
|
+
inboundMessagesProjectionTable,
|
|
57
|
+
INBOUND_MESSAGE_AGGREGATE_TYPE,
|
|
58
|
+
INBOUND_MAIL_TENANT_DESTROY_ARCHIVE_REASON,
|
|
59
|
+
);
|
|
68
60
|
}
|
|
69
61
|
|
|
70
62
|
export async function mailThreadTenantDestroyHook(ctx: TenantDataHookCtx): Promise<void> {
|
|
71
|
-
await
|
|
63
|
+
await archiveAndDeleteTenantRows(
|
|
64
|
+
ctx,
|
|
65
|
+
mailThreadsProjectionTable,
|
|
66
|
+
MAIL_THREAD_AGGREGATE_TYPE,
|
|
67
|
+
INBOUND_MAIL_TENANT_DESTROY_ARCHIVE_REASON,
|
|
68
|
+
);
|
|
72
69
|
}
|
|
@@ -484,7 +484,7 @@ export function createInboundMailSupervisor(
|
|
|
484
484
|
clearTimeout(pollTimer);
|
|
485
485
|
pollTimer = null;
|
|
486
486
|
}
|
|
487
|
-
if (pollInFlight) await pollInFlight;
|
|
487
|
+
if (pollInFlight !== null) await pollInFlight;
|
|
488
488
|
await Promise.allSettled([...inFlightSyncs.values(), watchCatchUp.settled()]);
|
|
489
489
|
for (const accountId of [...watchers.keys()]) {
|
|
490
490
|
await stopWatcher(accountId);
|