@cosmicdrift/kumiko-samples 0.413.1 → 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/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/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 +10 -12
- 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/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 +37 -0
- package/packages/bundled-features/src/billing-foundation/checkout-core.ts +8 -1
- package/packages/bundled-features/src/billing-foundation/checkout-ledger.ts +59 -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 +49 -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 +7 -1
- package/packages/bundled-features/src/billing-foundation/handlers/process-event.write.ts +124 -10
- package/packages/bundled-features/src/billing-foundation/handlers/process-payment-event.write.ts +33 -9
- 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 +7 -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 +8 -0
- package/packages/bundled-features/src/channel-whatsapp/constants.ts +46 -0
- package/packages/bundled-features/src/channel-whatsapp/events.ts +93 -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 +189 -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 +226 -0
- package/packages/bundled-features/src/channel-whatsapp/webhook-routes.ts +185 -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 +1 -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 +6 -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 +45 -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/report-ingest-progress.ts +32 -14
- package/packages/bundled-features/src/documents/aggregate-id.ts +0 -2
- package/packages/bundled-features/src/documents/changes.json +18 -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 +28 -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/helpdesk/changes.json +50 -0
- package/packages/bundled-features/src/helpdesk/entity.ts +4 -1
- package/packages/bundled-features/src/helpdesk/feature.ts +41 -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 +2 -9
- package/packages/bundled-features/src/helpdesk/handlers/report.write.ts +2 -9
- package/packages/bundled-features/src/helpdesk/handlers/submit.write.ts +3 -11
- 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 +185 -0
- package/packages/bundled-features/src/helpdesk/legacy-contact-user-data.ts +84 -0
- package/packages/bundled-features/src/helpdesk/lib.ts +47 -34
- 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 +5 -1
- package/packages/bundled-features/src/inbound-mail-foundation/aggregate-id.ts +0 -2
- package/packages/bundled-features/src/inbound-mail-foundation/changes.json +48 -0
- package/packages/bundled-features/src/inbound-mail-foundation/constants.ts +6 -0
- package/packages/bundled-features/src/inbound-mail-foundation/content-refetch.ts +15 -1
- package/packages/bundled-features/src/inbound-mail-foundation/entities.ts +64 -15
- package/packages/bundled-features/src/inbound-mail-foundation/events.ts +15 -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 +21 -8
- package/packages/bundled-features/src/inbound-mail-foundation/handlers/forget-message.write.ts +73 -0
- 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/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/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 +198 -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 +6 -0
- package/packages/bundled-features/src/shared/index.ts +6 -1
- 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 +19 -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 +12 -0
- package/packages/bundled-features/src/step-dispatcher/constants.ts +13 -0
- package/packages/bundled-features/src/step-dispatcher/deliver-dispatch-request.ts +47 -2
- package/packages/bundled-features/src/step-dispatcher/feature.ts +28 -1
- package/packages/bundled-features/src/step-dispatcher/mail-runner.ts +0 -1
- package/packages/bundled-features/src/step-dispatcher/sweep-abandoned.ts +57 -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 +159 -0
- package/packages/bundled-features/src/subscription-paddle/changes.json +13 -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 +36 -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 +7 -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 +24 -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 +36 -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 +77 -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 +126 -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/check-inactive-tenants.ts +4 -3
- package/packages/bundled-features/src/tenant-inactivity/constants.ts +1 -2
- package/packages/bundled-features/src/tenant-inactivity/handlers/keep-account.write.ts +1 -2
- package/packages/bundled-features/src/tenant-inactivity/state-store.ts +10 -1
- package/packages/bundled-features/src/tenant-lifecycle/changes.json +18 -0
- package/packages/bundled-features/src/tenant-lifecycle/constants.ts +4 -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/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/submit.write.ts +4 -28
- package/packages/bundled-features/src/waitlist/lib.ts +2 -7
- 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/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 +5 -4
- package/packages/bundled-features/src/workflow-runner/runner.ts +2 -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/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 +525 -44
- package/samples/recipes/record-detail-layout/src/order-board.ts +521 -0
- package/packages/bundled-features/src/managed-pages/web/page-body-section.tsx +0 -72
- package/packages/bundled-features/src/subscription-paddle/tenant-binding.ts +0 -34
- package/packages/bundled-features/src/template-resolver/web/content-field.tsx +0 -61
|
@@ -1,4 +1,52 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"version": "0.414.0",
|
|
4
|
+
"type": "fix",
|
|
5
|
+
"title": "hanging-account test recovers without the artificial 150ms deadline",
|
|
6
|
+
"detail": "The recovery poll of `watch-supervisor-hanging-account.integration.test.ts` ran with the 150ms deadline meant for the hung fetches, so a slow CI run abandoned the real sync (status degraded, nothing imported). Recovery now uses a supervisor with the default deadline, and the test also asserts a fresh fetch per tick, so a skipped tick fails it."
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
"version": "0.414.0",
|
|
10
|
+
"type": "fix",
|
|
11
|
+
"title": "PII ciphertext limits on inbound-mail entities and the mail-account event",
|
|
12
|
+
"detail": "The `inbound-message`, `mail-thread` and `mail-account` read-model fields for from, to, cc, subject, snippet, address, bodyText and bodyHtml, and the `address`, `bodyText` and `bodyHtml` of the event payloads, capped at plaintext or rough limits although they hold PII ciphertext (envelope plus Base64). A sender, subject, snippet or 320-character address at its plaintext limit failed validation once a PII KMS was configured. Their limits now come from `piiCiphertextMaxLengthFor` in `@cosmicdrift/kumiko-framework/crypto`."
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"version": "0.414.0",
|
|
16
|
+
"type": "fix",
|
|
17
|
+
"title": "ingest-message no longer rejects mails whose encrypted fields reach the plaintext limit",
|
|
18
|
+
"detail": "The `inbound-message-received` and `mail-thread-updated` payload schemas capped from, to, cc, subject and snippet at the plaintext limits, but the payload holds PII ciphertext (envelope plus Base64), so a 4000-character subject or snippet failed with \"Validation failed\" once a PII KMS was configured. The limits now come from the new `piiCiphertextMaxLengthFor` in `@cosmicdrift/kumiko-framework/crypto`."
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"version": "0.414.0",
|
|
22
|
+
"type": "fix",
|
|
23
|
+
"title": "review round 2 inbound mail fixes (connect race, quarantine lookups, storeBody, system search index)",
|
|
24
|
+
"detail": "`connect-account` takes an advisory lock per tenant and normalized address before the duplicate check, so a double submit or the OAuth callback racing the IMAP form cannot create two accounts for one address. `quarantinedMessageIds`, `hasOpenQuarantine` and `quarantineMessage` filter on `tenantId` and use the unique index. The supervisor no longer hands the storeBody hook an original that is above the raw MIME limit. `reindexTenantsSearch` also configures the system tenant index when a searchable entity lives on the system stream, so those documents get the searchable and ranking fields instead of the wildcard fallback; with the system tenant added, `failedConfigures` can count one more tenant."
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"version": "0.414.0",
|
|
28
|
+
"type": "fix",
|
|
29
|
+
"title": "inbound mail content reload, IMAP download budget, abandoned syncs, mail retry, consumer audit",
|
|
30
|
+
"detail": "The snippet-only content reload remembers per account where its scan stopped, so mails behind the newest 1000 anchors are reloaded over later ticks. The IMAP provider reads message sizes first, reports mails above the 50 MB limit as rejected without downloading them, and cuts each download at 100 MB (the rest follows in the next round via hasMore). A sync abandoned at its deadline stops ingesting before the next message. A mail adapter that throws ECONNREFUSED, ENOTFOUND, EAI_AGAIN, EHOSTUNREACH or ENETUNREACH is retried, since nothing was accepted. The jobs consumer-restart, -skip, -disable and -enable writes append a `jobs:event:consumer-state-changed` event (action, consumer, skipped event id, actor) that the audit log shows; locale packages gain the label `audit.log.event.consumer-state-changed`. `sendMailFromAccount` documents that it cannot be rolled back."
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"version": "0.414.0",
|
|
34
|
+
"type": "fix",
|
|
35
|
+
"title": "Shared mailbox on an address of a disconnected personal mailbox",
|
|
36
|
+
"detail": "An admin can connect a shared mailbox on an address held by a member's disconnected personal mailbox. The IMAP sent-folder copy is appended detached, and the docs say to call `sendMailFromAccount` from `beforeTransaction`. With several disconnected mailboxes on one address, the one of the wanted owner kind (shared or personal) is chosen, then the smallest id."
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"version": "0.414.0",
|
|
40
|
+
"type": "improvement",
|
|
41
|
+
"title": "forget-message permanently removes one imported mail",
|
|
42
|
+
"detail": "The new write `forget-message` archives the stream of one mail, deletes its read row, the stored original and the attachment files, and keeps the seen anchor so the intake does not import the mail again. The owner of a personal mailbox or, for a shared one, an admin may call it (agent risk high); a mail of another tenant or of someone else's personal mailbox is reported as not found. The retention sweep shares the purge logic."
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"version": "0.414.0",
|
|
46
|
+
"type": "fix",
|
|
47
|
+
"title": "partial recipient refusal and sender-check id on reconnect",
|
|
48
|
+
"detail": "`sendMailFromAccount` returns `rejectedRecipients` when the outgoing server accepts the mail for some recipients and refuses others; before, nodemailer's partial refusal was dropped and the send counted as fully delivered. `reconnect-mailbox` only writes the sender-check id when the payload carries the field, so an admin reconnecting a mailbox through the \"My mail accounts\" form keeps the stored id; the admin form clears it by sending an empty string."
|
|
49
|
+
},
|
|
2
50
|
{
|
|
3
51
|
"version": "0.412.0",
|
|
4
52
|
"type": "fix",
|
|
@@ -33,6 +33,8 @@ export const InboundMailFoundationHandlers = {
|
|
|
33
33
|
retryQuarantinedMessage: "inbound-mail-foundation:write:retry-quarantined-message",
|
|
34
34
|
/** Marks all open quarantine entries of a mailbox as acknowledged. */
|
|
35
35
|
acknowledgeQuarantine: "inbound-mail-foundation:write:acknowledge-quarantine",
|
|
36
|
+
/** Permanently removes one imported mail with its original and attachments. */
|
|
37
|
+
forgetMessage: "inbound-mail-foundation:write:forget-message",
|
|
36
38
|
/** Supervisor-only: stores the content of an already imported snippet mail. */
|
|
37
39
|
attachMessageContent: "inbound-mail-foundation:write:attach-message-content",
|
|
38
40
|
/** OAuth callback only: the refresh token is stored now, so an active account can sync. */
|
|
@@ -88,6 +90,10 @@ export const InboundMailConnectErrors = {
|
|
|
88
90
|
reason: "address_disconnected",
|
|
89
91
|
i18nKey: "inboundMail.accounts.errors.addressDisconnected",
|
|
90
92
|
},
|
|
93
|
+
personalAddressNotOwn: {
|
|
94
|
+
reason: "personal_address_not_own",
|
|
95
|
+
i18nKey: "inboundMail.accounts.errors.personalAddressNotOwn",
|
|
96
|
+
},
|
|
91
97
|
credentialRequired: {
|
|
92
98
|
reason: "credential_required",
|
|
93
99
|
i18nKey: "inboundMail.accounts.errors.credentialRequired",
|
|
@@ -17,6 +17,12 @@ import type { InboundMailContext, InboundMailProviderPlugin, MailAccountRecord }
|
|
|
17
17
|
export const CONTENT_REFETCH_BUDGET_PER_TICK = 50;
|
|
18
18
|
const SEEN_PAGE_SIZE = 250;
|
|
19
19
|
const SEEN_MAX_PAGES = 4;
|
|
20
|
+
export const CONTENT_REFETCH_SCAN_ROWS_PER_TICK = SEEN_PAGE_SIZE * SEEN_MAX_PAGES;
|
|
21
|
+
|
|
22
|
+
// Where the previous tick stopped scanning, per account. Without it every tick re-reads the newest
|
|
23
|
+
// rows and snippet-only mails further back would never be reached. Lost on restart, which only
|
|
24
|
+
// means the scan starts at the newest mail again.
|
|
25
|
+
const scanResumePoint = new Map<string, Temporal.Instant>();
|
|
20
26
|
|
|
21
27
|
type SeenRow = { readonly providerMessageId: string; readonly seenAt: Temporal.Instant };
|
|
22
28
|
type MessageRow = {
|
|
@@ -37,7 +43,8 @@ async function findSnippetOnlyMessageIds(
|
|
|
37
43
|
): Promise<string[]> {
|
|
38
44
|
const cutoff = Temporal.Now.instant().subtract({ hours: windowDays * 24 });
|
|
39
45
|
const found: string[] = [];
|
|
40
|
-
let before
|
|
46
|
+
let before = scanResumePoint.get(account.id);
|
|
47
|
+
scanResumePoint.delete(account.id);
|
|
41
48
|
for (
|
|
42
49
|
let page = 0;
|
|
43
50
|
page < SEEN_MAX_PAGES && found.length < CONTENT_REFETCH_BUDGET_PER_TICK;
|
|
@@ -58,6 +65,7 @@ async function findSnippetOnlyMessageIds(
|
|
|
58
65
|
},
|
|
59
66
|
);
|
|
60
67
|
if (seen.length === 0) break;
|
|
68
|
+
const pageStart = before;
|
|
61
69
|
const aggregateToProvider = new Map(
|
|
62
70
|
seen.map((row) => [
|
|
63
71
|
inboundMessageAggregateId(account.id, row.providerMessageId),
|
|
@@ -76,7 +84,13 @@ async function findSnippetOnlyMessageIds(
|
|
|
76
84
|
}
|
|
77
85
|
const oldest = seen[seen.length - 1];
|
|
78
86
|
if (seen.length < SEEN_PAGE_SIZE || !oldest) break;
|
|
87
|
+
if (found.length >= CONTENT_REFETCH_BUDGET_PER_TICK) {
|
|
88
|
+
// Reloaded mails stop being candidates, so the page can be read again without looping.
|
|
89
|
+
if (pageStart) scanResumePoint.set(account.id, pageStart);
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
79
92
|
before = oldest.seenAt;
|
|
93
|
+
scanResumePoint.set(account.id, before);
|
|
80
94
|
}
|
|
81
95
|
return found.slice(0, CONTENT_REFETCH_BUDGET_PER_TICK);
|
|
82
96
|
}
|
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
collectPiiSubjectFields,
|
|
3
|
+
piiCiphertextMaxLengthFor,
|
|
4
|
+
} from "@cosmicdrift/kumiko-framework/crypto";
|
|
5
|
+
import {
|
|
6
|
+
deriveEntityTableMeta,
|
|
7
|
+
isSchemaTable,
|
|
8
|
+
physicalColumnName,
|
|
9
|
+
} from "@cosmicdrift/kumiko-framework/db";
|
|
3
10
|
import {
|
|
4
11
|
access,
|
|
5
12
|
createBooleanField,
|
|
@@ -25,8 +32,8 @@ import { DEFAULT_INBOUND_MAIL_ADMIN_ROLES, DEFAULT_INBOUND_MAIL_USER_ROLES } fro
|
|
|
25
32
|
// **PII convention:** `personal: "tenant"` (not `encrypted`): fields must
|
|
26
33
|
// be crypto-shredded when eraseSubjectKeys deletes the tenant subject key on
|
|
27
34
|
// tenant destruction (pattern from billing-foundation).
|
|
28
|
-
//
|
|
29
|
-
// <
|
|
35
|
+
// The projection holds ciphertext, so these fields' maxLength comes from
|
|
36
|
+
// piiCiphertextMaxLengthFor(<plaintext limit>).
|
|
30
37
|
//
|
|
31
38
|
// **Design decision:** The PII subject of an inbound mail is currently the
|
|
32
39
|
// TENANT (mailbox owner), not the external sender. A sender-forget flow would
|
|
@@ -62,7 +69,12 @@ export const mailAccountEntity = createEntity({
|
|
|
62
69
|
reason: "tenant_config_not_personal",
|
|
63
70
|
}),
|
|
64
71
|
// Mailbox address — tenant PII.
|
|
65
|
-
address: createTextField({
|
|
72
|
+
address: createTextField({
|
|
73
|
+
required: true,
|
|
74
|
+
maxLength: piiCiphertextMaxLengthFor(320),
|
|
75
|
+
personal: "tenant",
|
|
76
|
+
find: "none",
|
|
77
|
+
}),
|
|
66
78
|
status: createTextField({
|
|
67
79
|
required: true,
|
|
68
80
|
maxLength: 30,
|
|
@@ -89,6 +101,9 @@ function ownMailboxOrSharedRead(memberRoles: readonly string[]): OwnershipMap {
|
|
|
89
101
|
const rule: OwnershipRule = {
|
|
90
102
|
kind: "where",
|
|
91
103
|
where: (user, ctx) => {
|
|
104
|
+
if (!isSchemaTable(ctx.table)) {
|
|
105
|
+
throw new Error(`${ctx.tableName}: ownership rule received a table not built by table()`);
|
|
106
|
+
}
|
|
92
107
|
const owner = `"${ctx.tableName}"."${physicalColumnName(ctx.table, "ownerUserId")}"`;
|
|
93
108
|
return {
|
|
94
109
|
sqlText: `(${owner} IS NULL OR ${owner} = '' OR ${owner} = $${ctx.paramStart})`,
|
|
@@ -128,21 +143,51 @@ export function createInboundMessageEntity(memberRoles: readonly string[]) {
|
|
|
128
143
|
personal: false,
|
|
129
144
|
reason: "technical_reference",
|
|
130
145
|
}),
|
|
131
|
-
from: createTextField({
|
|
146
|
+
from: createTextField({
|
|
147
|
+
required: true,
|
|
148
|
+
maxLength: piiCiphertextMaxLengthFor(2000),
|
|
149
|
+
personal: "tenant",
|
|
150
|
+
find: "none",
|
|
151
|
+
}),
|
|
132
152
|
// JSON-stringified string[] — als Ganzes encrypted.
|
|
133
|
-
to: createTextField({
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
153
|
+
to: createTextField({
|
|
154
|
+
maxLength: piiCiphertextMaxLengthFor(8000),
|
|
155
|
+
personal: "tenant",
|
|
156
|
+
find: "none",
|
|
157
|
+
}),
|
|
158
|
+
cc: createTextField({
|
|
159
|
+
maxLength: piiCiphertextMaxLengthFor(8000),
|
|
160
|
+
personal: "tenant",
|
|
161
|
+
find: "none",
|
|
162
|
+
}),
|
|
163
|
+
subject: createTextField({
|
|
164
|
+
maxLength: piiCiphertextMaxLengthFor(4000),
|
|
165
|
+
personal: "tenant",
|
|
166
|
+
find: "none",
|
|
167
|
+
}),
|
|
168
|
+
snippet: createTextField({
|
|
169
|
+
maxLength: piiCiphertextMaxLengthFor(4000),
|
|
170
|
+
personal: "tenant",
|
|
171
|
+
find: "none",
|
|
172
|
+
}),
|
|
137
173
|
receivedAt: createTimestampField({ required: true }),
|
|
138
174
|
bodyRef: createTextField({ maxLength: 500, personal: false, reason: "technical_reference" }),
|
|
139
175
|
scope: createTextField({ maxLength: 200, personal: false, reason: "technical_reference" }),
|
|
140
|
-
// Full plaintext, capped at 32_000 characters before encryption (ciphertext is ~2.3x plus envelope).
|
|
141
176
|
// Null on rows from before the column; list-messages never selects it.
|
|
142
|
-
|
|
177
|
+
// Plaintext is clipped to INBOUND_BODY_TEXT_MAX_CHARS (32_000) before encryption.
|
|
178
|
+
bodyText: createLongTextField({
|
|
179
|
+
maxLength: piiCiphertextMaxLengthFor(32_000),
|
|
180
|
+
personal: "tenant",
|
|
181
|
+
find: "none",
|
|
182
|
+
}),
|
|
143
183
|
bodyTextTruncated: createBooleanField(),
|
|
144
|
-
// Sanitized HTML of the mail
|
|
145
|
-
|
|
184
|
+
// Sanitized HTML of the mail, null when the mail has none or it was too large: sanitizeInboundHtml
|
|
185
|
+
// drops anything over 500_000 bytes after sanitizing, before encryption.
|
|
186
|
+
bodyHtml: createLongTextField({
|
|
187
|
+
maxLength: piiCiphertextMaxLengthFor(500_000),
|
|
188
|
+
personal: "tenant",
|
|
189
|
+
find: "none",
|
|
190
|
+
}),
|
|
146
191
|
// Bound to the message (entityType = the aggregate type), so the file guard answers with the
|
|
147
192
|
// mail's visibility. The fileRefs are bound at ingest, the projection copies the ids.
|
|
148
193
|
attachmentFileIds: createFilesField({ personal: false, reason: "technical_reference" }),
|
|
@@ -193,7 +238,11 @@ export const mailThreadEntity = createEntity({
|
|
|
193
238
|
personal: false,
|
|
194
239
|
reason: "technical_reference",
|
|
195
240
|
}),
|
|
196
|
-
subject: createTextField({
|
|
241
|
+
subject: createTextField({
|
|
242
|
+
maxLength: piiCiphertextMaxLengthFor(4000),
|
|
243
|
+
personal: "tenant",
|
|
244
|
+
find: "none",
|
|
245
|
+
}),
|
|
197
246
|
lastMessageAt: createTimestampField({ required: true }),
|
|
198
247
|
messageCount: createNumberField({ required: true, integer: true }),
|
|
199
248
|
},
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
// eraseSubjectKeys makes both the event log and projection unreadable
|
|
21
21
|
// (crypto-shredding, the billing-foundation pattern).
|
|
22
22
|
|
|
23
|
+
import { piiCiphertextMaxLengthFor } from "@cosmicdrift/kumiko-framework/crypto";
|
|
23
24
|
import * as z from "zod";
|
|
24
25
|
import { INBOUND_MAIL_FOUNDATION_FEATURE, InboundMailAccountStatuses } from "./constants.ts";
|
|
25
26
|
import { senderAuthenticationFieldSchema } from "./sender-auth.ts";
|
|
@@ -64,9 +65,7 @@ const accountStatusEnum = z.enum([
|
|
|
64
65
|
// ============================================================================
|
|
65
66
|
//
|
|
66
67
|
// One stream per mailbox (aggregateId = accountId, random UUID on connect).
|
|
67
|
-
// address is PII
|
|
68
|
-
// (a 200-character plaintext becomes ~460+ characters in a JSON envelope;
|
|
69
|
-
// see billing-foundation events.ts).
|
|
68
|
+
// address is PII ciphertext; its plaintext is capped at 320 characters by connect-account.write.ts.
|
|
70
69
|
export const mailAccountEventPayloadSchema = z.object({
|
|
71
70
|
provider: z.string().min(1).max(50),
|
|
72
71
|
/** "password" | "xoauth2" | "oauth" (InboundMailAuthMethods) — deliberately
|
|
@@ -76,7 +75,7 @@ export const mailAccountEventPayloadSchema = z.object({
|
|
|
76
75
|
/** null = shared by the tenant; otherwise, this user's personal mailbox. */
|
|
77
76
|
ownerUserId: z.string().max(36).nullable(),
|
|
78
77
|
displayName: z.string().max(200),
|
|
79
|
-
address: z.string().min(1).max(
|
|
78
|
+
address: z.string().min(1).max(piiCiphertextMaxLengthFor(320)),
|
|
80
79
|
status: accountStatusEnum,
|
|
81
80
|
/** Provider-agnostic watch state ("idle", "watching", "backoff:3", ...)
|
|
82
81
|
* — an operational signal only, not PII. */
|
|
@@ -114,12 +113,12 @@ export const skippedAttachmentSchema = z.object({
|
|
|
114
113
|
});
|
|
115
114
|
|
|
116
115
|
// Shared by inbound-message-received (v2+) and inbound-message-content-fetched.
|
|
117
|
-
// bodyText is ciphertext
|
|
116
|
+
// bodyText is ciphertext of at most INBOUND_BODY_TEXT_MAX_CHARS (32_000) characters.
|
|
118
117
|
const inboundMessageContentShape = {
|
|
119
|
-
bodyText: z.string().max(
|
|
118
|
+
bodyText: z.string().max(piiCiphertextMaxLengthFor(32_000)),
|
|
120
119
|
bodyTextTruncated: z.boolean(),
|
|
121
|
-
/** Sanitized HTML body
|
|
122
|
-
bodyHtml: z.string().max(
|
|
120
|
+
/** Sanitized HTML body as PII ciphertext. sanitizeInboundHtml drops anything over 500_000 bytes after sanitizing. Null: none or too large. */
|
|
121
|
+
bodyHtml: z.string().max(piiCiphertextMaxLengthFor(500_000)).nullable(),
|
|
123
122
|
/** file-foundation FileRef ids (plaintext uuids). Attachments outlive the mail: apps turn them
|
|
124
123
|
* into documents, so the retention sweep never deletes them. */
|
|
125
124
|
attachmentFileIds: z.array(z.uuid()).max(50),
|
|
@@ -135,8 +134,8 @@ const inboundMessageContentShape = {
|
|
|
135
134
|
// aggregateId = inboundMessageAggregateId(accountId, providerMessageId)
|
|
136
135
|
// → deterministic, so provider replays collide on the same stream.
|
|
137
136
|
//
|
|
138
|
-
// PII fields (from/to/cc/subject/snippet):
|
|
139
|
-
//
|
|
137
|
+
// PII fields (from/to/cc/subject/snippet): the maxima are the ciphertext
|
|
138
|
+
// size of the plaintext limits in ingest-message-schema.ts. to/cc are JSON-stringified string[] BEFORE encryption;
|
|
140
139
|
// the payload contains the ciphertext string, not the array (primitives only,
|
|
141
140
|
// upcaster-safe).
|
|
142
141
|
export const inboundMessageEventPayloadSchema = z.object({
|
|
@@ -149,13 +148,13 @@ export const inboundMessageEventPayloadSchema = z.object({
|
|
|
149
148
|
/** Normalized thread key (References-chain root or provider thread ID,
|
|
150
149
|
* prefixed by the provider). */
|
|
151
150
|
threadKey: z.string().min(1).max(500),
|
|
152
|
-
from: z.string().min(1).max(2000),
|
|
151
|
+
from: z.string().min(1).max(piiCiphertextMaxLengthFor(2000)),
|
|
153
152
|
/** JSON-stringified string[], dann PII-encrypted. */
|
|
154
|
-
to: z.string().max(8000),
|
|
153
|
+
to: z.string().max(piiCiphertextMaxLengthFor(8000)),
|
|
155
154
|
/** JSON-stringified string[], dann PII-encrypted. */
|
|
156
|
-
cc: z.string().max(8000),
|
|
157
|
-
subject: z.string().max(4000),
|
|
158
|
-
snippet: z.string().max(4000),
|
|
155
|
+
cc: z.string().max(piiCiphertextMaxLengthFor(8000)),
|
|
156
|
+
subject: z.string().max(piiCiphertextMaxLengthFor(4000)),
|
|
157
|
+
snippet: z.string().max(piiCiphertextMaxLengthFor(4000)),
|
|
159
158
|
/** ISO instant — receipt time reported by the provider (INTERNALDATE or
|
|
160
159
|
* receivedDateTime), not ingest time. */
|
|
161
160
|
receivedAtIso: z.string().min(1),
|
|
@@ -193,7 +192,7 @@ export type InboundMessageContentFetchedEventPayload = z.infer<
|
|
|
193
192
|
// ============================================================================
|
|
194
193
|
export const mailThreadEventPayloadSchema = z.object({
|
|
195
194
|
threadKey: z.string().min(1).max(500),
|
|
196
|
-
subject: z.string().max(4000),
|
|
195
|
+
subject: z.string().max(piiCiphertextMaxLengthFor(4000)),
|
|
197
196
|
lastMessageAtIso: z.string().min(1),
|
|
198
197
|
messageCount: z.number().int().min(1),
|
|
199
198
|
});
|
|
@@ -55,6 +55,7 @@ import { createAcknowledgeQuarantineHandler } from "./handlers/acknowledge-quara
|
|
|
55
55
|
import { attachMessageContentHandler } from "./handlers/attach-message-content.write.ts";
|
|
56
56
|
import { createConnectAccountHandler } from "./handlers/connect-account.write.ts";
|
|
57
57
|
import { createDisconnectAccountHandler } from "./handlers/disconnect-account.write.ts";
|
|
58
|
+
import { createForgetMessageHandler } from "./handlers/forget-message.write.ts";
|
|
58
59
|
import { ingestMessageHandler } from "./handlers/ingest-message.write.ts";
|
|
59
60
|
import { createListAccountsQuery } from "./handlers/list-accounts.query.ts";
|
|
60
61
|
import { createListMessagesQuery } from "./handlers/list-messages.query.ts";
|
|
@@ -104,7 +105,7 @@ export function createInboundMailFoundationFeature(options: InboundMailRoleOptio
|
|
|
104
105
|
(r) => {
|
|
105
106
|
r.adoptsBundledLists();
|
|
106
107
|
r.describe(
|
|
107
|
-
"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.",
|
|
108
|
+
"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.",
|
|
108
109
|
);
|
|
109
110
|
r.uiHints({
|
|
110
111
|
displayLabel: "Inbound Mail · Foundation",
|
|
@@ -256,6 +257,7 @@ export function createInboundMailFoundationFeature(options: InboundMailRoleOptio
|
|
|
256
257
|
r.writeHandler(createReactivateAccountHandler(roles));
|
|
257
258
|
r.writeHandler(createSetTrustedAuthservIdHandler(roles));
|
|
258
259
|
r.writeHandler(createAcknowledgeQuarantineHandler(roles));
|
|
260
|
+
r.writeHandler(createForgetMessageHandler(roles));
|
|
259
261
|
r.writeHandler(createRetryQuarantinedMessageHandler(roles));
|
|
260
262
|
r.writeHandler(attachMessageContentHandler);
|
|
261
263
|
r.writeHandler(markCredentialStoredHandler);
|
|
@@ -27,10 +27,13 @@ function textOf(value: unknown): string {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
// A live mailbox wins over a disconnected one: connecting next to a live mailbox is always a duplicate.
|
|
30
|
+
// Among equals the mailbox of the wanted owner kind (shared or personal) wins, then the smallest id,
|
|
31
|
+
// so the outcome does not depend on projection row order.
|
|
30
32
|
export async function findMailboxByAddress(
|
|
31
33
|
ctx: Pick<HandlerContext, "db">,
|
|
32
34
|
tenantId: string,
|
|
33
35
|
address: string,
|
|
36
|
+
wantedOwnerUserId: string | null,
|
|
34
37
|
): Promise<AddressMatch | undefined> {
|
|
35
38
|
const wanted = normalizeMailAddress(address);
|
|
36
39
|
const rows = await ctx.db.selectMany(mailAccountsProjectionTable, { tenantId });
|
|
@@ -51,10 +54,17 @@ export async function findMailboxByAddress(
|
|
|
51
54
|
status: textOf(row["status"]),
|
|
52
55
|
});
|
|
53
56
|
}
|
|
54
|
-
|
|
57
|
+
const rank = (m: AddressMatch): number =>
|
|
58
|
+
(m.status === InboundMailAccountStatuses.disconnected ? 2 : 0) +
|
|
59
|
+
((m.ownerUserId === null) === (wantedOwnerUserId === null) ? 0 : 1);
|
|
60
|
+
return [...matches].sort((a, b) => rank(a) - rank(b) || a.id.localeCompare(b.id))[0];
|
|
55
61
|
}
|
|
56
62
|
|
|
57
|
-
export type ConnectConflict =
|
|
63
|
+
export type ConnectConflict =
|
|
64
|
+
| "already_connected"
|
|
65
|
+
| "address_disconnected"
|
|
66
|
+
| "reopen_in_place"
|
|
67
|
+
| "replace_disconnected_personal";
|
|
58
68
|
|
|
59
69
|
// A disconnected or sign-in-failed OAuth mailbox of the same provider and owner is reopened (the
|
|
60
70
|
// callback writes the new token into the same slot); everything else must not silently create a second stream for one address.
|
|
@@ -70,6 +80,10 @@ export function connectConflictOf(
|
|
|
70
80
|
// A sign-in error of an OAuth mailbox is healed by signing in again, so it reopens like a disconnect.
|
|
71
81
|
const signInFailed = existing.status === InboundMailAccountStatuses.authError;
|
|
72
82
|
if (!disconnected && !signInFailed) return "already_connected";
|
|
83
|
+
// A member's disconnected personal mailbox must not lock the address for the team's shared one.
|
|
84
|
+
if (disconnected && wanted.ownerUserId === null && existing.ownerUserId !== null) {
|
|
85
|
+
return "replace_disconnected_personal";
|
|
86
|
+
}
|
|
73
87
|
const bothOauth =
|
|
74
88
|
wanted.authMethod === InboundMailAuthMethods.oauth &&
|
|
75
89
|
existing.authMethod === InboundMailAuthMethods.oauth &&
|
|
@@ -57,10 +57,14 @@ function hasContentAlready(events: readonly { type: string; payload: unknown }[]
|
|
|
57
57
|
|
|
58
58
|
const receivedOwnerSchema = z.object({ ownerUserId: z.string().nullable() });
|
|
59
59
|
|
|
60
|
-
|
|
60
|
+
// `null` inside the result means a shared mailbox; an unreadable stream has no result at all, so a
|
|
61
|
+
// personal mail can never fall through to the shared routing.
|
|
62
|
+
function ownerOfStream(
|
|
63
|
+
events: readonly { type: string; payload: unknown }[],
|
|
64
|
+
): { readonly ownerUserId: string | null } | undefined {
|
|
61
65
|
const received = events.find((e) => e.type === INBOUND_MESSAGE_RECEIVED_EVENT_QN);
|
|
62
66
|
const parsed = receivedOwnerSchema.safeParse(received?.payload);
|
|
63
|
-
return parsed.success ? parsed.data.ownerUserId :
|
|
67
|
+
return parsed.success ? { ownerUserId: parsed.data.ownerUserId } : undefined;
|
|
64
68
|
}
|
|
65
69
|
|
|
66
70
|
// Read before the transaction, so it can only skip work: a row that already shows attached content
|
|
@@ -160,6 +164,9 @@ export const attachMessageContentHandler = defineWriteHandler({
|
|
|
160
164
|
return { isSuccess: true as const, data: { duplicate: true as const } };
|
|
161
165
|
}
|
|
162
166
|
|
|
167
|
+
const owner = ownerOfStream(events);
|
|
168
|
+
if (owner === undefined) return failNotFound("inbound-message-received-event", messageAggId);
|
|
169
|
+
|
|
163
170
|
const content =
|
|
164
171
|
payload.outcome !== "fetched"
|
|
165
172
|
? undefined
|
|
@@ -171,7 +178,7 @@ export const attachMessageContentHandler = defineWriteHandler({
|
|
|
171
178
|
content,
|
|
172
179
|
tenantId,
|
|
173
180
|
messageAggId,
|
|
174
|
-
|
|
181
|
+
owner.ownerUserId,
|
|
175
182
|
);
|
|
176
183
|
const appended = await ctx.events.tryAppend({
|
|
177
184
|
aggregateId: messageAggId,
|
package/packages/bundled-features/src/inbound-mail-foundation/handlers/connect-account.write.ts
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
// stays fast and offline-capable (the test result arrives asynchronously
|
|
13
13
|
// as a status transition).
|
|
14
14
|
// - No second account for one address: a live or disconnected address is
|
|
15
|
-
// refused (409 reasons in InboundMailConnectErrors); only a disconnected or
|
|
15
|
+
// refused (a disconnected personal mailbox gives way to a shared one) (409 reasons in InboundMailConnectErrors); only a disconnected or
|
|
16
16
|
// sign-in-failed OAuth mailbox is reopened in place, keeping its account id and cursor.
|
|
17
17
|
// The reopen returns the existing id and changes nothing yet; the callback re-arms it.
|
|
18
18
|
|
|
@@ -41,7 +41,14 @@ import {
|
|
|
41
41
|
type MailAccountEventPayload,
|
|
42
42
|
} from "../events.ts";
|
|
43
43
|
import { accessRolesOf, type InboundMailRoles } from "../mail-roles.ts";
|
|
44
|
-
import {
|
|
44
|
+
import {
|
|
45
|
+
connectConflictOf,
|
|
46
|
+
findMailboxByAddress,
|
|
47
|
+
normalizeMailAddress,
|
|
48
|
+
} from "./account-address.ts";
|
|
49
|
+
|
|
50
|
+
// 'inma': serializes the duplicate-address check and the append per tenant and address (the lock key is tenant-scoped).
|
|
51
|
+
const CONNECT_ADDRESS_LOCK_NAMESPACE = 0x696e6d61;
|
|
45
52
|
|
|
46
53
|
export const connectAccountSchema = z
|
|
47
54
|
.object({
|
|
@@ -96,7 +103,11 @@ export function createConnectAccountHandler({ adminRoles }: InboundMailRoles): W
|
|
|
96
103
|
? event.user.id
|
|
97
104
|
: null;
|
|
98
105
|
|
|
99
|
-
|
|
106
|
+
await ctx.db.advisoryXactLock(
|
|
107
|
+
CONNECT_ADDRESS_LOCK_NAMESPACE,
|
|
108
|
+
normalizeMailAddress(payload.address),
|
|
109
|
+
);
|
|
110
|
+
const existing = await findMailboxByAddress(ctx, tenantId, payload.address, ownerUserId);
|
|
100
111
|
if (existing) {
|
|
101
112
|
const matched = connectConflictOf(existing, {
|
|
102
113
|
authMethod: payload.authMethod,
|
|
@@ -117,11 +128,13 @@ export function createConnectAccountHandler({ adminRoles }: InboundMailRoles): W
|
|
|
117
128
|
data: { accountId: existing.id, reconnected: true as const },
|
|
118
129
|
};
|
|
119
130
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
131
|
+
if (conflict !== "replace_disconnected_personal") {
|
|
132
|
+
const { reason, i18nKey } =
|
|
133
|
+
conflict === "address_disconnected"
|
|
134
|
+
? InboundMailConnectErrors.addressDisconnected
|
|
135
|
+
: InboundMailConnectErrors.addressAlreadyConnected;
|
|
136
|
+
return writeFailure(new UnprocessableError(reason, { i18nKey }));
|
|
137
|
+
}
|
|
125
138
|
}
|
|
126
139
|
|
|
127
140
|
// PII-encrypt the address before the append. This is the only write path to
|
package/packages/bundled-features/src/inbound-mail-foundation/handlers/forget-message.write.ts
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
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
|
+
const purged = await purgeInboundMessages({
|
|
46
|
+
db: ctx.db,
|
|
47
|
+
tenantId: event.user.tenantId,
|
|
48
|
+
rows: [row],
|
|
49
|
+
archive: (id) =>
|
|
50
|
+
ctx.events.archive(id, {
|
|
51
|
+
aggregateType: INBOUND_MESSAGE_AGGREGATE_TYPE,
|
|
52
|
+
reason: FORGET_REASON,
|
|
53
|
+
}),
|
|
54
|
+
deleteBodyObject: files
|
|
55
|
+
? (bodyRef) => files.refFromFileRef({ storageKey: bodyRef }).delete()
|
|
56
|
+
: undefined,
|
|
57
|
+
deleteAttachments: async (id) => {
|
|
58
|
+
await deleteFileRefsBoundToRecord({
|
|
59
|
+
db: ctx.db,
|
|
60
|
+
user: event.user,
|
|
61
|
+
entityType: INBOUND_MESSAGE_AGGREGATE_TYPE,
|
|
62
|
+
entityId: id,
|
|
63
|
+
});
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
// Rolls the archive back: a half-deleted mail must stay retryable.
|
|
67
|
+
if (purged.failedIds.length > 0) {
|
|
68
|
+
throw new Error(`forget-message: the stored files of ${messageId} could not be deleted`);
|
|
69
|
+
}
|
|
70
|
+
return { isSuccess: true as const, data: { forgotten: true as const } };
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
}
|
|
@@ -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",
|
|
@@ -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
|
+
}
|