@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,8 +1,6 @@
|
|
|
1
1
|
import { access, defineWriteHandler } from "@cosmicdrift/kumiko-framework/engine";
|
|
2
|
-
import { InternalError } from "@cosmicdrift/kumiko-framework/errors";
|
|
3
2
|
import * as z from "zod";
|
|
4
|
-
import {
|
|
5
|
-
import { upsertPreference } from "../upsert-preference.ts";
|
|
3
|
+
import { setPreferenceEnabled } from "../set-preference-enabled.ts";
|
|
6
4
|
|
|
7
5
|
export const resubscribeUserWrite = defineWriteHandler({
|
|
8
6
|
name: "resubscribeUser",
|
|
@@ -18,26 +16,5 @@ export const resubscribeUserWrite = defineWriteHandler({
|
|
|
18
16
|
agent: { expose: false },
|
|
19
17
|
description:
|
|
20
18
|
"Re-enables one notification type and channel combination for the userId carried in a verified unsubscribe token; dispatched by the signed resubscribe route, not meant for UI callers.",
|
|
21
|
-
handler:
|
|
22
|
-
const { userId, channel } = event.payload;
|
|
23
|
-
const notificationType = currentNotificationType(ctx.registry, event.payload.notificationType);
|
|
24
|
-
const { tenantId } = event.user;
|
|
25
|
-
|
|
26
|
-
if (!ctx.systemDb) {
|
|
27
|
-
throw new InternalError({
|
|
28
|
-
message: "resubscribeUser: ctx.systemDb missing on a system-scoped handler",
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
const db = ctx.systemDb.assertTenantMatch(tenantId);
|
|
32
|
-
|
|
33
|
-
const result = await upsertPreference(db, event.user, {
|
|
34
|
-
tenantId,
|
|
35
|
-
userId,
|
|
36
|
-
notificationType,
|
|
37
|
-
channel,
|
|
38
|
-
enabled: true,
|
|
39
|
-
});
|
|
40
|
-
if (!result.isSuccess) return result;
|
|
41
|
-
return { isSuccess: true, data: { notificationType, channel } };
|
|
42
|
-
},
|
|
19
|
+
handler: (event, ctx) => setPreferenceEnabled("resubscribeUser", event, ctx, true),
|
|
43
20
|
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { access, defineQueryHandler, type TenantId } from "@cosmicdrift/kumiko-framework/engine";
|
|
2
2
|
import { InternalError } from "@cosmicdrift/kumiko-framework/errors";
|
|
3
3
|
import * as z from "zod";
|
|
4
|
+
import { fileContextForTenant } from "../../file-foundation/index.ts";
|
|
4
5
|
import {
|
|
5
6
|
collectRendererPlugins,
|
|
6
7
|
createRendererFoundationApi,
|
|
@@ -50,6 +51,7 @@ export const unsubscribePageChromeQuery = defineQueryHandler({
|
|
|
50
51
|
registry: ctx.registry,
|
|
51
52
|
tenantId,
|
|
52
53
|
...(ctx.config !== undefined && { config: ctx.config }),
|
|
54
|
+
filesForTenant: (fileTenantId) => fileContextForTenant(ctx, tenantId, fileTenantId),
|
|
53
55
|
},
|
|
54
56
|
);
|
|
55
57
|
},
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { access, defineWriteHandler } from "@cosmicdrift/kumiko-framework/engine";
|
|
2
|
-
import { InternalError } from "@cosmicdrift/kumiko-framework/errors";
|
|
3
2
|
import * as z from "zod";
|
|
4
|
-
import {
|
|
5
|
-
import { upsertPreference } from "../upsert-preference.ts";
|
|
3
|
+
import { setPreferenceEnabled } from "../set-preference-enabled.ts";
|
|
6
4
|
|
|
7
5
|
export const unsubscribeUserWrite = defineWriteHandler({
|
|
8
6
|
name: "unsubscribeUser",
|
|
@@ -18,28 +16,5 @@ export const unsubscribeUserWrite = defineWriteHandler({
|
|
|
18
16
|
agent: { expose: false },
|
|
19
17
|
description:
|
|
20
18
|
"Disables one notification type and channel combination for the userId carried in a verified unsubscribe token; dispatched by the signed unsubscribe route, not meant for UI callers.",
|
|
21
|
-
handler:
|
|
22
|
-
// userId comes from the payload, not event.user.id — the caller here is
|
|
23
|
-
// the system user dispatchSystemWrite runs as, not the user unsubscribing.
|
|
24
|
-
const { userId, channel } = event.payload;
|
|
25
|
-
const notificationType = currentNotificationType(ctx.registry, event.payload.notificationType);
|
|
26
|
-
const { tenantId } = event.user;
|
|
27
|
-
|
|
28
|
-
if (!ctx.systemDb) {
|
|
29
|
-
throw new InternalError({
|
|
30
|
-
message: "unsubscribeUser: ctx.systemDb missing on a system-scoped handler",
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
const db = ctx.systemDb.assertTenantMatch(tenantId);
|
|
34
|
-
|
|
35
|
-
const result = await upsertPreference(db, event.user, {
|
|
36
|
-
tenantId,
|
|
37
|
-
userId,
|
|
38
|
-
notificationType,
|
|
39
|
-
channel,
|
|
40
|
-
enabled: false,
|
|
41
|
-
});
|
|
42
|
-
if (!result.isSuccess) return result;
|
|
43
|
-
return { isSuccess: true, data: { notificationType, channel } };
|
|
44
|
-
},
|
|
19
|
+
handler: (event, ctx) => setPreferenceEnabled("unsubscribeUser", event, ctx, false),
|
|
45
20
|
});
|
|
@@ -15,6 +15,7 @@ export {
|
|
|
15
15
|
toAttachmentRef,
|
|
16
16
|
withoutDeliveryEnvelopeKeys,
|
|
17
17
|
} from "./attachment-ref.ts";
|
|
18
|
+
export { createDeliveryAttemptLogFactory } from "./attempt-log-factory.ts";
|
|
18
19
|
export {
|
|
19
20
|
type AttemptLogRetentionOptions,
|
|
20
21
|
DEFAULT_ATTEMPT_LOG_RETENTION_DAYS,
|
|
@@ -66,13 +67,14 @@ export {
|
|
|
66
67
|
type KillSwitchResolver,
|
|
67
68
|
type RateLimitConfig,
|
|
68
69
|
} from "./delivery-service.ts";
|
|
69
|
-
export { createDeliveryFeature
|
|
70
|
+
export { createDeliveryFeature } from "./feature.ts";
|
|
70
71
|
export {
|
|
71
72
|
type UnsubscribeAddressPayload,
|
|
72
73
|
unsubscribeAddressPayloadSchema,
|
|
73
74
|
} from "./handlers/unsubscribe-address.write.ts";
|
|
74
75
|
export { currentNotificationType } from "./notification-type-aliases.ts";
|
|
75
76
|
export { createDeliveryNotifyFactory } from "./notify-factory.ts";
|
|
77
|
+
export type { DeliveryFeatureOptions } from "./options.ts";
|
|
76
78
|
export {
|
|
77
79
|
buildSystemChannelContext,
|
|
78
80
|
type SystemChannelContextDeps,
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type DeliveryFeatureOptions = {
|
|
2
|
+
// Access gate for the delivery-log screen and the `log` query it reads —
|
|
3
|
+
// both move together so the nav entry a role sees always matches a
|
|
4
|
+
// callable handler. Default access.admin includes TenantAdmin,
|
|
5
|
+
// who in a line-of-business app is the operator, not the platform — pass
|
|
6
|
+
// access.systemAdmin to keep this platform-only and out of their nav.
|
|
7
|
+
readonly access?: readonly string[];
|
|
8
|
+
// Attempt events and log rows older than this many days are pruned by a daily job. Default 90;
|
|
9
|
+
// `false` keeps the log forever.
|
|
10
|
+
readonly attemptLogRetentionDays?: number | false;
|
|
11
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { Registry } from "@cosmicdrift/kumiko-framework/engine";
|
|
2
|
+
import { currentNotificationType } from "./notification-type-aliases.ts";
|
|
3
|
+
|
|
4
|
+
type PreferenceRow = {
|
|
5
|
+
readonly userId: string;
|
|
6
|
+
readonly notificationType: string;
|
|
7
|
+
readonly channel: string;
|
|
8
|
+
readonly enabled: boolean;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
// Rows stored under a former notification name are reported under the current
|
|
12
|
+
// one, collapsed with the same precedence as delivery: an exact row wins,
|
|
13
|
+
// otherwise any disabled former-name row disables.
|
|
14
|
+
export function collapsePreferenceRows<Row extends PreferenceRow>(
|
|
15
|
+
registry: Registry,
|
|
16
|
+
rows: readonly Row[],
|
|
17
|
+
): Row[] {
|
|
18
|
+
const collapsed = new Map<string, { row: Row; isExact: boolean }>();
|
|
19
|
+
for (const row of rows) {
|
|
20
|
+
const notificationType = currentNotificationType(registry, row.notificationType);
|
|
21
|
+
const key = `${row.userId}\u0000${notificationType}\u0000${row.channel}`;
|
|
22
|
+
const isExact = row.notificationType === notificationType;
|
|
23
|
+
const existing = collapsed.get(key);
|
|
24
|
+
if (existing?.isExact) continue;
|
|
25
|
+
const formerNameRowDisablesAlready =
|
|
26
|
+
existing !== undefined &&
|
|
27
|
+
!isExact &&
|
|
28
|
+
(existing.row.enabled === false || row.enabled !== false);
|
|
29
|
+
if (formerNameRowDisablesAlready) continue;
|
|
30
|
+
collapsed.set(key, { row: { ...row, notificationType }, isExact });
|
|
31
|
+
}
|
|
32
|
+
return [...collapsed.values()].map((entry) => entry.row);
|
|
33
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { HandlerContext, SessionUser } from "@cosmicdrift/kumiko-framework/engine";
|
|
2
|
+
import { InternalError } from "@cosmicdrift/kumiko-framework/errors";
|
|
3
|
+
import { currentNotificationType } from "./notification-type-aliases.ts";
|
|
4
|
+
import { upsertPreference } from "./upsert-preference.ts";
|
|
5
|
+
|
|
6
|
+
type PreferencePayload = {
|
|
7
|
+
readonly userId: string;
|
|
8
|
+
readonly notificationType: string;
|
|
9
|
+
readonly channel: string;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
// userId comes from the payload, not event.user.id — the caller is the system user
|
|
13
|
+
// dispatchSystemWrite runs as, not the user (un)subscribing.
|
|
14
|
+
export async function setPreferenceEnabled(
|
|
15
|
+
handlerName: string,
|
|
16
|
+
event: { readonly payload: PreferencePayload; readonly user: SessionUser },
|
|
17
|
+
ctx: Pick<HandlerContext, "registry" | "systemDb">,
|
|
18
|
+
enabled: boolean,
|
|
19
|
+
) {
|
|
20
|
+
const { userId, channel } = event.payload;
|
|
21
|
+
const notificationType = currentNotificationType(ctx.registry, event.payload.notificationType);
|
|
22
|
+
const { tenantId } = event.user;
|
|
23
|
+
|
|
24
|
+
if (!ctx.systemDb) {
|
|
25
|
+
throw new InternalError({
|
|
26
|
+
message: `${handlerName}: ctx.systemDb missing on a system-scoped handler`,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
const db = ctx.systemDb.assertTenantMatch(tenantId);
|
|
30
|
+
|
|
31
|
+
const result = await upsertPreference(db, event.user, {
|
|
32
|
+
tenantId,
|
|
33
|
+
userId,
|
|
34
|
+
notificationType,
|
|
35
|
+
channel,
|
|
36
|
+
enabled,
|
|
37
|
+
});
|
|
38
|
+
if (!result.isSuccess) return result;
|
|
39
|
+
return { isSuccess: true, data: { notificationType, channel } } as const;
|
|
40
|
+
}
|
|
@@ -11,6 +11,7 @@ import type { JobRunner } from "@cosmicdrift/kumiko-framework/jobs";
|
|
|
11
11
|
import type { Logger } from "@cosmicdrift/kumiko-framework/logging";
|
|
12
12
|
import type { EnvelopeCipher, SecretsContext } from "@cosmicdrift/kumiko-framework/secrets";
|
|
13
13
|
import type { Redis } from "ioredis";
|
|
14
|
+
import { createDeliveryAttemptLogFactory } from "./attempt-log-factory.ts";
|
|
14
15
|
import type { KillSwitchResolver, RateLimitConfig } from "./delivery-service.ts";
|
|
15
16
|
import { collectChannels, createDeliveryService } from "./delivery-service.ts";
|
|
16
17
|
import { createDeliveryNotifyFactory } from "./notify-factory.ts";
|
|
@@ -34,7 +35,7 @@ export type CreateDeliveryTestContextOptions = {
|
|
|
34
35
|
};
|
|
35
36
|
|
|
36
37
|
/**
|
|
37
|
-
* Helper for setupTestStack: creates a DeliveryService + _notifyFactory for the test context.
|
|
38
|
+
* Helper for setupTestStack: creates a DeliveryService + _notifyFactory + _deliveryAttemptLogFactory for the test context.
|
|
38
39
|
* Abstracts the boilerplate that every Delivery-using test needs.
|
|
39
40
|
*
|
|
40
41
|
* Usage:
|
|
@@ -60,6 +61,7 @@ export function createDeliveryTestContext(
|
|
|
60
61
|
return {
|
|
61
62
|
deliveryService, // exposed so tests can inspect/call directly if needed
|
|
62
63
|
_notifyFactory: createDeliveryNotifyFactory(deliveryService),
|
|
64
|
+
_deliveryAttemptLogFactory: createDeliveryAttemptLogFactory(deliveryService),
|
|
63
65
|
...(options.addressCipher && { configEncryption: options.addressCipher }),
|
|
64
66
|
};
|
|
65
67
|
}
|
|
@@ -138,6 +138,7 @@ export type DeliveryService = {
|
|
|
138
138
|
deliveryDb?: DbConnection,
|
|
139
139
|
fileProviderResolver?: FileProviderResolver,
|
|
140
140
|
): Promise<NotifyDispatched>;
|
|
141
|
+
logAttempt(entry: DeliveryLogEntry, deliveryDb?: DbConnection): Promise<void>;
|
|
141
142
|
};
|
|
142
143
|
|
|
143
144
|
// r.useExtension options-shape: `name` is NOT part of the registration
|
|
@@ -42,6 +42,12 @@ function httpsOrigin(url: string | undefined): string | undefined {
|
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
const INLINE_LOGO_RE = /^data:image\/(?:png|jpeg|webp|gif);base64,[A-Za-z0-9+/]+={0,2}$/;
|
|
46
|
+
|
|
47
|
+
function isShowableLogoSrc(src: string | undefined): boolean {
|
|
48
|
+
return src !== undefined && (httpsOrigin(src) !== undefined || INLINE_LOGO_RE.test(src));
|
|
49
|
+
}
|
|
50
|
+
|
|
45
51
|
function webHost(url: string): string | undefined {
|
|
46
52
|
try {
|
|
47
53
|
const parsed = new URL(url);
|
|
@@ -97,7 +103,7 @@ function brandRowHtml(chrome: MailChrome): string {
|
|
|
97
103
|
const name = chrome.tenantName.trim();
|
|
98
104
|
const initial = Array.from(name)[0]?.toLocaleUpperCase() ?? "";
|
|
99
105
|
const mark =
|
|
100
|
-
|
|
106
|
+
isShowableLogoSrc(chrome.logoUrl) && chrome.logoUrl !== undefined
|
|
101
107
|
? `<img src="${escapeHtmlAttr(chrome.logoUrl)}" alt="">`
|
|
102
108
|
: initial === ""
|
|
103
109
|
? ""
|
|
@@ -25,6 +25,7 @@ export const DeliveryQueries = {
|
|
|
25
25
|
log: "delivery:query:log",
|
|
26
26
|
preferences: "delivery:query:preferences",
|
|
27
27
|
attemptsByKeys: "delivery:query:attempts-by-keys",
|
|
28
|
+
optedInUserIds: "delivery:query:opted-in-user-ids",
|
|
28
29
|
unsubscribePageChrome: "delivery:query:unsubscribe-page-chrome",
|
|
29
30
|
} as const;
|
|
30
31
|
|
|
@@ -249,15 +249,15 @@ const SOURCE_FORMAT_ENCODERS: Record<string, (pipeline: Sharp, quality?: number)
|
|
|
249
249
|
function applyEncoder(pipeline: Sharp, spec: VariantSpec, sourceMimeType: string): Sharp {
|
|
250
250
|
const quality = spec.quality;
|
|
251
251
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
252
|
+
switch (spec.format) {
|
|
253
|
+
case "webp":
|
|
254
|
+
return pipeline.webp(quality !== undefined ? { quality } : undefined);
|
|
255
|
+
case "avif":
|
|
256
|
+
return pipeline.avif(quality !== undefined ? { quality } : undefined);
|
|
257
|
+
case "jpeg":
|
|
258
|
+
return pipeline.jpeg(quality !== undefined ? { quality } : undefined);
|
|
259
|
+
case undefined:
|
|
260
|
+
break;
|
|
261
261
|
}
|
|
262
262
|
|
|
263
263
|
const encode = SOURCE_FORMAT_ENCODERS[sourceMimeType];
|
|
@@ -4,7 +4,6 @@ import { v5 as uuidv5 } from "uuid";
|
|
|
4
4
|
// it re-keys every existing ingest stream.
|
|
5
5
|
const DOCUMENT_INGEST_NAMESPACE = "5c1e8b7a-3d94-4f2a-b6e0-9a7d1c4f8e23";
|
|
6
6
|
|
|
7
|
-
// @wrapper-known uuid-domain
|
|
8
7
|
export function documentIngestAggregateId(tenantId: string, fileRefId: string): string {
|
|
9
8
|
return uuidv5(`${tenantId}|${fileRefId}`, DOCUMENT_INGEST_NAMESPACE);
|
|
10
9
|
}
|
package/packages/bundled-features/src/document-ingest-foundation/append-missing-extract-event.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { InternalError } from "@cosmicdrift/kumiko-framework/errors";
|
|
|
4
4
|
import {
|
|
5
5
|
appendEventInTenantDb,
|
|
6
6
|
getStreamVersionInTenantDb,
|
|
7
|
+
VersionConflictError,
|
|
7
8
|
} from "@cosmicdrift/kumiko-framework/event-store";
|
|
8
9
|
import {
|
|
9
10
|
DOCUMENT_EXTRACT_AGGREGATE_TYPE,
|
|
@@ -20,7 +21,6 @@ export type AppendMissingExtractEventDeps = {
|
|
|
20
21
|
readonly tenantDb: TenantDb;
|
|
21
22
|
readonly registry: Registry;
|
|
22
23
|
readonly actor: SessionUser;
|
|
23
|
-
readonly tenantId: string;
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
export type AppendMissingExtractEventOptions = {
|
|
@@ -38,6 +38,11 @@ export type AppendMissingExtractEventResult =
|
|
|
38
38
|
const CREATED_ONLY_STREAM_VERSION = 1;
|
|
39
39
|
const UNKNOWN_EXTRACT_ERROR = "unknown extract error";
|
|
40
40
|
|
|
41
|
+
function describeMetaError(metaError: unknown): string {
|
|
42
|
+
if (typeof metaError === "string") return metaError;
|
|
43
|
+
return JSON.stringify(metaError) ?? String(metaError);
|
|
44
|
+
}
|
|
45
|
+
|
|
41
46
|
// A previous delivery created the extract but died before appending its ready/failed event.
|
|
42
47
|
// Without the event, consumers waiting on it hang forever.
|
|
43
48
|
export async function appendMissingDocumentExtractEvent(
|
|
@@ -46,11 +51,6 @@ export async function appendMissingDocumentExtractEvent(
|
|
|
46
51
|
fileRefId: string,
|
|
47
52
|
options: AppendMissingExtractEventOptions,
|
|
48
53
|
): Promise<AppendMissingExtractEventResult> {
|
|
49
|
-
if (deps.tenantDb.tenantId !== deps.tenantId) {
|
|
50
|
-
throw new InternalError({
|
|
51
|
-
message: `document-ingest-foundation: tenantDb is bound to tenant ${deps.tenantDb.tenantId}, not ${deps.tenantId}`,
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
54
|
const version = await getStreamVersionInTenantDb(deps.tenantDb, existing.id);
|
|
55
55
|
// A missing stream means a wrong id; appending would make the terminal event the first event of a new stream.
|
|
56
56
|
if (version === 0) {
|
|
@@ -61,24 +61,36 @@ export async function appendMissingDocumentExtractEvent(
|
|
|
61
61
|
// skip: the terminal event was already written, nothing to catch up
|
|
62
62
|
if (version > CREATED_ONLY_STREAM_VERSION) return "already-terminal";
|
|
63
63
|
const metaError = existing.meta?.error;
|
|
64
|
-
const failed =
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
?
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
64
|
+
const failed = metaError !== undefined && metaError !== null;
|
|
65
|
+
const errorText = failed ? describeMetaError(metaError) : "";
|
|
66
|
+
try {
|
|
67
|
+
await appendEventInTenantDb(
|
|
68
|
+
deps.tenantDb,
|
|
69
|
+
{
|
|
70
|
+
aggregateId: existing.id,
|
|
71
|
+
aggregateType: DOCUMENT_EXTRACT_AGGREGATE_TYPE,
|
|
72
|
+
expectedVersion: version,
|
|
73
|
+
type: failed ? options.failedEventQn : options.readyEventQn,
|
|
74
|
+
payload: failed
|
|
75
|
+
? documentExtractFailedPayloadSchema.parse({
|
|
76
|
+
documentExtractId: existing.id,
|
|
77
|
+
fileRefId,
|
|
78
|
+
error: options.mapError?.(errorText) || errorText || UNKNOWN_EXTRACT_ERROR,
|
|
79
|
+
})
|
|
80
|
+
: documentExtractReadyPayloadSchema.parse({ documentExtractId: existing.id, fileRefId }),
|
|
81
|
+
metadata: { userId: deps.actor.id },
|
|
82
|
+
},
|
|
83
|
+
{ registry: deps.registry },
|
|
84
|
+
);
|
|
85
|
+
} catch (error) {
|
|
86
|
+
// A concurrent catch-up run (job retry plus redelivery) wrote the terminal event first.
|
|
87
|
+
if (
|
|
88
|
+
error instanceof VersionConflictError &&
|
|
89
|
+
(await getStreamVersionInTenantDb(deps.tenantDb, existing.id)) > CREATED_ONLY_STREAM_VERSION
|
|
90
|
+
) {
|
|
91
|
+
return "already-terminal";
|
|
92
|
+
}
|
|
93
|
+
throw error;
|
|
94
|
+
}
|
|
83
95
|
return failed ? "appended-failed" : "appended-ready";
|
|
84
96
|
}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type DbConnection, transaction } from "@cosmicdrift/kumiko-framework/db";
|
|
2
2
|
import type { Registry } from "@cosmicdrift/kumiko-framework/engine";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
append,
|
|
5
|
+
getStreamVersion,
|
|
6
|
+
VersionConflictError,
|
|
7
|
+
} from "@cosmicdrift/kumiko-framework/event-store";
|
|
4
8
|
import { runProjectionsForEvent } from "@cosmicdrift/kumiko-framework/pipeline";
|
|
5
9
|
import { documentIngestAggregateId } from "./aggregate-id.ts";
|
|
6
10
|
import {
|
|
@@ -22,22 +26,36 @@ export type ReportIngestProgressInput = {
|
|
|
22
26
|
readonly pagesTotal: number;
|
|
23
27
|
};
|
|
24
28
|
|
|
25
|
-
//
|
|
29
|
+
// Parallel reports for one file race on the stream version; progress is idempotent and the newest
|
|
30
|
+
// report wins, so a lost race re-reads the version and appends again.
|
|
31
|
+
const MAX_VERSION_CONFLICT_ATTEMPTS = 3;
|
|
32
|
+
|
|
33
|
+
// Low-level append() does not fire projections, so they run explicitly, in the same transaction as the append.
|
|
26
34
|
export async function reportIngestProgress(
|
|
27
35
|
deps: ReportIngestProgressDeps,
|
|
28
36
|
input: ReportIngestProgressInput,
|
|
29
37
|
): Promise<void> {
|
|
30
38
|
const payload = documentIngestProgressPayloadSchema.parse(input);
|
|
31
39
|
const aggregateId = documentIngestAggregateId(deps.tenantId, payload.fileRefId);
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
for (let attempt = 1; ; attempt++) {
|
|
41
|
+
try {
|
|
42
|
+
await transaction(deps.db, async (tx) => {
|
|
43
|
+
const expectedVersion = await getStreamVersion(tx, aggregateId, deps.tenantId);
|
|
44
|
+
const stored = await append(tx, {
|
|
45
|
+
aggregateId,
|
|
46
|
+
aggregateType: DOCUMENT_INGEST_AGGREGATE_TYPE,
|
|
47
|
+
tenantId: deps.tenantId,
|
|
48
|
+
expectedVersion,
|
|
49
|
+
type: DOCUMENT_INGEST_PROGRESS_EVENT_QN,
|
|
50
|
+
payload,
|
|
51
|
+
metadata: { userId: deps.actorId },
|
|
52
|
+
});
|
|
53
|
+
await runProjectionsForEvent(stored, deps.registry, tx);
|
|
54
|
+
});
|
|
55
|
+
// skip: event appended, nothing left to retry
|
|
56
|
+
return;
|
|
57
|
+
} catch (e) {
|
|
58
|
+
if (!(e instanceof VersionConflictError) || attempt >= MAX_VERSION_CONFLICT_ATTEMPTS) throw e;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
43
61
|
}
|
|
@@ -4,12 +4,10 @@ import { v5 as uuidv5 } from "uuid";
|
|
|
4
4
|
const DOCUMENT_FOR_FILE_NAMESPACE = "6d2f7e41-3c58-4b0a-9e17-5a4c8d1b2f93";
|
|
5
5
|
const DOCUMENT_LINK_NAMESPACE = "b83a1c6e-9f20-4d57-a1e4-7c0d52f68b19";
|
|
6
6
|
|
|
7
|
-
// @wrapper-known uuid-domain
|
|
8
7
|
export function documentIdForFile(tenantId: string, fileRefId: string): string {
|
|
9
8
|
return uuidv5(`${tenantId}|${fileRefId}`, DOCUMENT_FOR_FILE_NAMESPACE);
|
|
10
9
|
}
|
|
11
10
|
|
|
12
|
-
// @wrapper-known uuid-domain
|
|
13
11
|
export function documentLinkAggregateId(
|
|
14
12
|
tenantId: string,
|
|
15
13
|
documentId: string,
|
|
@@ -1,4 +1,22 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"version": "0.414.0",
|
|
4
|
+
"type": "improvement",
|
|
5
|
+
"title": "documents list and tab show a View action for PDFs",
|
|
6
|
+
"detail": "The file renderer takes `viewInDrawer: true`; list cells then show a View button for PDFs (MIME from the batched `useFileMeta`, one `/api/files/meta` request per page) that opens `PdfPreview` in a drawer. `documents:screen:list` and the documents tab set it. New export `FileViewAction` for custom columns, new i18n key `kumiko.field.file-list.view` (en, de, es, fr, it)."
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
"version": "0.414.0",
|
|
10
|
+
"type": "fix",
|
|
11
|
+
"title": "Capped linked document list",
|
|
12
|
+
"detail": "documents linkedDocumentIds throws the reason too_many_linked_documents (DocumentsReasons) above 10000 links."
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"version": "0.414.0",
|
|
16
|
+
"type": "fix",
|
|
17
|
+
"title": "document import is a no-op after the document stream was archived",
|
|
18
|
+
"detail": "A document whose stream the retention archived is recognised as already imported, so repeating the import changes nothing instead of failing with \"belongs to another record\"."
|
|
19
|
+
},
|
|
2
20
|
{
|
|
3
21
|
"version": "0.404.1",
|
|
4
22
|
"type": "fix",
|
|
@@ -11,20 +11,28 @@ export const DEFAULT_EXPIRING_WITHIN_DAYS = 30;
|
|
|
11
11
|
|
|
12
12
|
export const DOCUMENTS_LIST_SCREEN_ID = "list";
|
|
13
13
|
|
|
14
|
+
export const DOCUMENT_LIVE_ENTITIES = [DOCUMENT_ENTITY, DOCUMENT_LINK_ENTITY];
|
|
15
|
+
|
|
14
16
|
export const DocumentsHandlers = {
|
|
17
|
+
deleteDocument: `documents:write:${DOCUMENT_ENTITY}:delete`,
|
|
15
18
|
link: "documents:write:link",
|
|
16
19
|
unlink: "documents:write:unlink",
|
|
17
20
|
import: "documents:write:import",
|
|
18
21
|
} as const;
|
|
19
22
|
|
|
20
23
|
export const DocumentsQueries = {
|
|
21
|
-
list:
|
|
22
|
-
detail:
|
|
24
|
+
list: `documents:query:${DOCUMENT_ENTITY}:list`,
|
|
25
|
+
detail: `documents:query:${DOCUMENT_ENTITY}:detail`,
|
|
26
|
+
linkList: `documents:query:${DOCUMENT_LINK_ENTITY}:list`,
|
|
23
27
|
forRecord: "documents:query:for-record",
|
|
24
28
|
expiryOverview: "documents:query:expiry-overview",
|
|
25
29
|
overview: "documents:query:overview",
|
|
26
30
|
} as const;
|
|
27
31
|
|
|
32
|
+
export const DocumentsReasons = {
|
|
33
|
+
tooManyLinkedDocuments: "too_many_linked_documents",
|
|
34
|
+
} as const;
|
|
35
|
+
|
|
28
36
|
export const EXPIRY_STATES = ["expired", "expiring", "valid", "none"] as const;
|
|
29
37
|
export type ExpiryState = (typeof EXPIRY_STATES)[number];
|
|
30
38
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { TenantDb } from "@cosmicdrift/kumiko-framework/db";
|
|
2
|
-
import type
|
|
2
|
+
import { type SessionUser, withResponseData } from "@cosmicdrift/kumiko-framework/engine";
|
|
3
3
|
import { isPlainObject } from "@cosmicdrift/kumiko-types/type-guards";
|
|
4
4
|
import { documentLinkAggregateId } from "./aggregate-id.ts";
|
|
5
5
|
import type { DocumentExecutors } from "./executor.ts";
|
|
@@ -28,8 +28,7 @@ export async function ensureDocumentLink(
|
|
|
28
28
|
user,
|
|
29
29
|
db,
|
|
30
30
|
);
|
|
31
|
-
if (created.isSuccess
|
|
32
|
-
|
|
33
|
-
}
|
|
31
|
+
if (created.isSuccess) return withResponseData(created, { id });
|
|
32
|
+
if (created.error.code === "version_conflict") return { isSuccess: true as const, data: { id } };
|
|
34
33
|
return created;
|
|
35
34
|
}
|
|
@@ -63,7 +63,9 @@ export type DocumentsFeatureOptions = {
|
|
|
63
63
|
readonly linkReadMode?: DocumentLinkReadMode;
|
|
64
64
|
/**
|
|
65
65
|
* Who may use the document handlers. One rule applies to read, write and delete; the split form
|
|
66
|
-
* sets them apart. Default TenantAdmin and TenantMember; a missing delete follows write.
|
|
66
|
+
* sets them apart. Default TenantAdmin and TenantMember; a missing delete follows write. Without
|
|
67
|
+
* this option, creating a document is limited to the admin roles, since an unlinked document is
|
|
68
|
+
* visible to them only.
|
|
67
69
|
*/
|
|
68
70
|
readonly access?: AccessRule | DocumentsAccess;
|
|
69
71
|
/** Roles that see every document of their tenant whose file owner they can read, without a link. */
|
|
@@ -125,6 +127,10 @@ function registerDocuments(
|
|
|
125
127
|
...(opts.retention !== undefined && { retention: opts.retention }),
|
|
126
128
|
});
|
|
127
129
|
const linkEntity = createDocumentLinkEntity(linkTargets);
|
|
130
|
+
// A fresh document is invisible until linked, except to the admin roles; with the default access
|
|
131
|
+
// a member would file a record they can never see again. An explicit access option stays in charge.
|
|
132
|
+
const createAccess: AccessRule =
|
|
133
|
+
opts.access === undefined ? { roles: opts.adminRoles ?? DEFAULT_ADMIN_ROLES } : access.write;
|
|
128
134
|
const executors = createDocumentExecutors(documentEntity, linkEntity);
|
|
129
135
|
|
|
130
136
|
r.requires({ features: ["files"] });
|
|
@@ -139,7 +145,7 @@ function registerDocuments(
|
|
|
139
145
|
|
|
140
146
|
r.writeHandler(
|
|
141
147
|
defineEntityCreateHandler(DOCUMENT_ENTITY, documentEntity, {
|
|
142
|
-
access:
|
|
148
|
+
access: createAccess,
|
|
143
149
|
description:
|
|
144
150
|
"Files a new document from an uploaded file; it stays invisible to everyone but the admin roles until it is linked to a record.",
|
|
145
151
|
agent: { risk: "mid" },
|
|
@@ -162,10 +168,26 @@ function registerDocuments(
|
|
|
162
168
|
agent: { risk: "high" },
|
|
163
169
|
}),
|
|
164
170
|
);
|
|
165
|
-
r.hook({
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
171
|
+
r.hook({
|
|
172
|
+
type: "preSave",
|
|
173
|
+
target: `${DOCUMENT_ENTITY}:create`,
|
|
174
|
+
handler: rejectForeignPendingFile,
|
|
175
|
+
});
|
|
176
|
+
r.hook({
|
|
177
|
+
type: "preSave",
|
|
178
|
+
target: `${DOCUMENT_ENTITY}:update`,
|
|
179
|
+
handler: rejectForeignPendingFile,
|
|
180
|
+
});
|
|
181
|
+
r.hook({
|
|
182
|
+
type: "preSave",
|
|
183
|
+
target: `${DOCUMENT_ENTITY}:update`,
|
|
184
|
+
handler: writeGuard.beforeUpdate,
|
|
185
|
+
});
|
|
186
|
+
r.hook({
|
|
187
|
+
type: "preDelete",
|
|
188
|
+
target: `${DOCUMENT_ENTITY}:delete`,
|
|
189
|
+
handler: writeGuard.beforeDelete,
|
|
190
|
+
});
|
|
169
191
|
r.writeHandler(createLinkDocumentHandler({ access: access.write, executors, linkTargets }));
|
|
170
192
|
r.writeHandler(createUnlinkDocumentHandler({ access: access.write, executors, linkTargets }));
|
|
171
193
|
r.writeHandler(
|
|
@@ -45,9 +45,9 @@ async function fileRefExists(
|
|
|
45
45
|
type StreamLoader = Pick<HandlerEvents, "load">;
|
|
46
46
|
|
|
47
47
|
// The stream, not the projected row: a row-level readAccess can hide a document from the system
|
|
48
|
-
// user, and a deleted document still has its stream.
|
|
48
|
+
// user, and a deleted or retention-archived document still has its stream.
|
|
49
49
|
async function streamTypeOf(events: StreamLoader, id: string): Promise<string | undefined> {
|
|
50
|
-
const [first] = await events.load(id, { atVersion: 1 });
|
|
50
|
+
const [first] = await events.load(id, { atVersion: 1, includeArchived: true });
|
|
51
51
|
return first?.aggregateType;
|
|
52
52
|
}
|
|
53
53
|
|