@cosmicdrift/kumiko-bundled-features 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/dist/admin-shell/feature.js +2 -2
- package/dist/agent-tools/agent-doc-lint.js +2 -1
- package/dist/agent-tools/agent-manifest.js +33 -25
- package/dist/agent-tools/api-docs/collect-events.js +4 -1
- package/dist/agent-tools/api-docs/collect.js +3 -3
- package/dist/agent-tools/api-docs/generate.js +4 -1
- package/dist/agent-tools/api-docs/index.d.ts +1 -0
- package/dist/agent-tools/api-docs/index.js +1 -0
- package/dist/agent-tools/api-docs/problems.d.ts +21 -0
- package/dist/agent-tools/api-docs/problems.js +11 -1
- package/dist/agent-tools/api-docs/render-openapi.js +2 -0
- package/dist/agent-tools/api-docs/resolve-config.d.ts +9 -0
- package/dist/agent-tools/api-docs/resolve-config.js +11 -0
- package/dist/agent-tools/api-docs/scope-slug-collisions.d.ts +4 -0
- package/dist/agent-tools/api-docs/scope-slug-collisions.js +10 -0
- package/dist/agent-tools/api-docs/translation-gaps.d.ts +4 -0
- package/dist/agent-tools/api-docs/translation-gaps.js +29 -0
- package/dist/agent-tools/api-docs/webhook-example-problems.d.ts +6 -0
- package/dist/agent-tools/api-docs/webhook-example-problems.js +25 -0
- package/dist/agent-tools/index.d.ts +1 -1
- package/dist/agent-tools/index.js +1 -1
- package/dist/agent-tools/labels.d.ts +3 -2
- package/dist/agent-tools/labels.js +21 -4
- package/dist/agent-tools/tool-catalog.d.ts +5 -5
- package/dist/agent-tools/tool-catalog.js +12 -10
- package/dist/agent-tools/tool-dispatch.js +11 -1
- package/dist/agent-tools/types.d.ts +4 -0
- package/dist/audit/event-classification.js +6 -0
- package/dist/audit/web/i18n.js +1 -0
- package/dist/auth-email-password/errors.js +0 -13
- package/dist/auth-email-password/handlers/invite-signup-complete.write.js +101 -84
- package/dist/auth-email-password/handlers/login-options.query.js +1 -1
- package/dist/auth-email-password/handlers/request-account-unlock.write.js +1 -1
- package/dist/auth-email-password/handlers/request-email-verification.write.js +0 -1
- package/dist/auth-email-password/handlers/request-password-reset.write.js +0 -1
- package/dist/auth-email-password/handlers/self-registration-status.query.js +1 -1
- package/dist/auth-email-password/reset-token.js +0 -2
- package/dist/auth-email-password/seeding.js +34 -8
- package/dist/auth-email-password/unlock-token.js +0 -2
- package/dist/auth-email-password/verification-token.js +0 -2
- package/dist/auth-email-password/web/auth-form-primitives.js +2 -2
- package/dist/auth-email-password/web/auth-gate.js +2 -2
- package/dist/auth-email-password/web/auth-redirect.d.ts +1 -0
- package/dist/auth-email-password/web/auth-redirect.js +4 -0
- package/dist/auth-email-password/web/forgot-password-screen.js +1 -5
- package/dist/auth-email-password/web/invite-accept-screen.js +1 -1
- package/dist/auth-email-password/web/return-path.d.ts +2 -1
- package/dist/auth-email-password/web/return-path.js +2 -1
- package/dist/auth-email-password/web/session.js +11 -12
- package/dist/auth-email-password/web/signup-screen.js +1 -5
- package/dist/auth-email-password/web/static-account.js +6 -2
- package/dist/auth-email-password/web/token-confirm-screen.js +4 -5
- package/dist/auth-mfa/web/mfa-code-or-recovery-field.d.ts +6 -1
- package/dist/auth-mfa/web/mfa-code-or-recovery-field.js +4 -2
- package/dist/auth-mfa/web/mfa-disable-dialog.js +1 -1
- package/dist/auth-mfa/web/mfa-regenerate-recovery-dialog.js +1 -1
- package/dist/auth-mfa/web/mfa-setup-preauth-screen.js +1 -1
- package/dist/auth-mfa/web/mfa-verify-screen.js +7 -11
- package/dist/auth-mfa-user-data/index.js +5 -6
- package/dist/billing-foundation/aggregate-id.js +0 -4
- package/dist/billing-foundation/checkout-core.js +8 -1
- package/dist/billing-foundation/checkout-ledger.d.ts +15 -0
- package/dist/billing-foundation/checkout-ledger.js +32 -0
- package/dist/billing-foundation/consumer-protection/consent-gate.d.ts +1 -1
- package/dist/billing-foundation/consumer-protection/consent-gate.js +2 -2
- package/dist/billing-foundation/consumer-protection/consent-text.d.ts +6 -2
- package/dist/billing-foundation/consumer-protection/consent-text.js +29 -3
- package/dist/billing-foundation/consumer-protection/termination-open-cancels.d.ts +2 -1
- package/dist/billing-foundation/consumer-protection/termination-open-cancels.js +5 -1
- package/dist/billing-foundation/consumer-protection/termination-provider-timeout.d.ts +2 -0
- package/dist/billing-foundation/consumer-protection/termination-provider-timeout.js +17 -0
- package/dist/billing-foundation/consumer-protection/termination-record.js +5 -4
- package/dist/billing-foundation/consumer-protection/termination-revoke.js +1 -1
- package/dist/billing-foundation/events.d.ts +22 -0
- package/dist/billing-foundation/events.js +38 -10
- package/dist/billing-foundation/feature.js +12 -1
- package/dist/billing-foundation/handlers/billing-plans.query.js +25 -15
- package/dist/billing-foundation/handlers/create-checkout-session.write.js +1 -1
- package/dist/billing-foundation/handlers/process-event.write.d.ts +2 -2
- package/dist/billing-foundation/handlers/process-event.write.js +94 -12
- package/dist/billing-foundation/handlers/process-payment-event.write.d.ts +1 -2
- package/dist/billing-foundation/handlers/process-payment-event.write.js +29 -9
- package/dist/billing-foundation/handlers/record-checkout-opened.write.d.ts +2 -0
- package/dist/billing-foundation/handlers/record-checkout-opened.write.js +22 -0
- package/dist/billing-foundation/handlers/start-plan-checkout.write.js +1 -1
- package/dist/billing-foundation/handlers/switch-plan.write.js +10 -4
- package/dist/billing-foundation/i18n.js +3 -0
- package/dist/billing-foundation/pending-plan-switch.d.ts +12 -0
- package/dist/billing-foundation/pending-plan-switch.js +57 -0
- package/dist/billing-foundation/scrub-raw-payload-headers.d.ts +4 -0
- package/dist/billing-foundation/scrub-raw-payload-headers.js +33 -0
- package/dist/billing-foundation/types.d.ts +40 -24
- package/dist/billing-foundation/validate-options.js +14 -0
- package/dist/billing-foundation/web/billing-plans-panel.js +8 -3
- package/dist/billing-foundation/web/cancel-contract-dialog.js +1 -1
- package/dist/billing-foundation/web/checkout-consent-dialog.js +1 -1
- package/dist/billing-foundation/web/constants.d.ts +3 -0
- package/dist/billing-foundation/web/constants.js +5 -2
- package/dist/billing-foundation/web/plan-switch-confirm-dialog.js +1 -1
- package/dist/billing-foundation/webhook-handler.js +53 -11
- package/dist/cap-counter/aggregate-id.js +0 -2
- package/dist/cap-counter/stock-cap-guard.d.ts +1 -0
- package/dist/cap-counter/stock-cap-guard.js +18 -4
- package/dist/cap-overview/handlers/tenant-caps-list.query.js +18 -4
- package/dist/cap-overview/i18n.js +1 -0
- package/dist/cap-overview/index.d.ts +1 -1
- package/dist/cap-overview/types.d.ts +4 -0
- package/dist/cap-overview/web/cap-cards-panel.js +6 -2
- package/dist/cap-overview/web/cap-usage-bar.js +6 -1
- package/dist/cap-overview/web/usage-math.d.ts +1 -0
- package/dist/cap-overview/web/usage-math.js +4 -0
- package/dist/channel-in-app/handlers/read-state-by-keys.query.js +2 -2
- package/dist/channel-whatsapp/aggregate-id.d.ts +8 -0
- package/dist/channel-whatsapp/aggregate-id.js +18 -0
- package/dist/channel-whatsapp/constants.d.ts +25 -0
- package/dist/channel-whatsapp/constants.js +36 -0
- package/dist/channel-whatsapp/events.d.ts +87 -0
- package/dist/channel-whatsapp/events.js +70 -0
- package/dist/channel-whatsapp/feature.d.ts +3 -0
- package/dist/channel-whatsapp/feature.js +56 -0
- package/dist/channel-whatsapp/graph-client.d.ts +85 -0
- package/dist/channel-whatsapp/graph-client.js +272 -0
- package/dist/channel-whatsapp/in-memory-meta.d.ts +83 -0
- package/dist/channel-whatsapp/in-memory-meta.js +181 -0
- package/dist/channel-whatsapp/inbound-handlers.d.ts +39 -0
- package/dist/channel-whatsapp/inbound-handlers.js +127 -0
- package/dist/channel-whatsapp/index.d.ts +10 -0
- package/dist/channel-whatsapp/index.js +10 -0
- package/dist/channel-whatsapp/meta-signature.d.ts +5 -0
- package/dist/channel-whatsapp/meta-signature.js +19 -0
- package/dist/channel-whatsapp/options.d.ts +32 -0
- package/dist/channel-whatsapp/options.js +83 -0
- package/dist/channel-whatsapp/pii.d.ts +32 -0
- package/dist/channel-whatsapp/pii.js +61 -0
- package/dist/channel-whatsapp/webhook-normalize.d.ts +7 -0
- package/dist/channel-whatsapp/webhook-normalize.js +185 -0
- package/dist/channel-whatsapp/webhook-routes.d.ts +10 -0
- package/dist/channel-whatsapp/webhook-routes.js +118 -0
- package/dist/compliance-profiles/handlers/sub-processors.query.js +1 -1
- package/dist/config/handlers/set.write.js +7 -0
- package/dist/config/handlers/values.query.js +8 -1
- package/dist/config/index.d.ts +1 -1
- package/dist/config/index.js +1 -1
- package/dist/config/read-redaction.d.ts +1 -0
- package/dist/config/read-redaction.js +5 -2
- package/dist/config/table.js +1 -0
- package/dist/config/write-helpers.js +3 -2
- package/dist/crypto-shredding/constants.d.ts +1 -0
- package/dist/crypto-shredding/constants.js +1 -0
- package/dist/crypto-shredding/handlers/forget-subject.write.js +34 -13
- package/dist/crypto-shredding/index.d.ts +1 -0
- package/dist/crypto-shredding/index.js +1 -0
- package/dist/crypto-shredding/subject-forget-after-delete-hook.d.ts +12 -0
- package/dist/crypto-shredding/subject-forget-after-delete-hook.js +38 -0
- package/dist/custom-fields/aggregate-id.js +0 -1
- package/dist/custom-fields/entity.js +1 -0
- package/dist/custom-fields/wire-for-entity.js +0 -1
- package/dist/data-retention/erase-notes-of-deleted-row.d.ts +9 -0
- package/dist/data-retention/erase-notes-of-deleted-row.js +15 -0
- package/dist/data-retention/feature.js +1 -5
- package/dist/data-retention/run-retention-cleanup.d.ts +1 -0
- package/dist/data-retention/run-retention-cleanup.js +39 -19
- package/dist/data-retention/tenant-destruction-hold.js +7 -0
- package/dist/delivery/attempt-log-factory.d.ts +3 -0
- package/dist/delivery/attempt-log-factory.js +5 -0
- package/dist/delivery/attempt-log.d.ts +2 -2
- package/dist/delivery/channel-context.d.ts +1 -1
- package/dist/delivery/channel-context.js +5 -2
- package/dist/delivery/db/queries/preferences.js +0 -1
- package/dist/delivery/delivery-service.js +3 -0
- package/dist/delivery/feature.d.ts +1 -4
- package/dist/delivery/feature.js +3 -1
- package/dist/delivery/handlers/attempts-by-keys.query.d.ts +1 -1
- package/dist/delivery/handlers/opted-in-user-ids.query.d.ts +7 -0
- package/dist/delivery/handlers/opted-in-user-ids.query.js +41 -0
- package/dist/delivery/handlers/preferences.query.js +2 -20
- package/dist/delivery/handlers/resubscribe-user.write.d.ts +2 -2
- package/dist/delivery/handlers/resubscribe-user.write.js +2 -24
- package/dist/delivery/handlers/unsubscribe-page-chrome.query.js +2 -0
- package/dist/delivery/handlers/unsubscribe-user.write.d.ts +2 -2
- package/dist/delivery/handlers/unsubscribe-user.write.js +2 -26
- package/dist/delivery/index.d.ts +3 -1
- package/dist/delivery/index.js +1 -0
- package/dist/delivery/options.d.ts +4 -0
- package/dist/delivery/options.js +1 -0
- package/dist/delivery/preference-rows.d.ts +9 -0
- package/dist/delivery/preference-rows.js +22 -0
- package/dist/delivery/set-preference-enabled.d.ts +17 -0
- package/dist/delivery/set-preference-enabled.js +26 -0
- package/dist/delivery/tables.d.ts +2 -2
- package/dist/delivery/testing.d.ts +1 -1
- package/dist/delivery/testing.js +3 -1
- package/dist/delivery/types.d.ts +1 -0
- package/dist/delivery/unsubscribe-page.js +5 -1
- package/dist/delivery/upsert-preference.js +0 -1
- package/dist/delivery/web/public-names.d.ts +1 -0
- package/dist/delivery/web/public-names.js +1 -0
- package/dist/derivatives-sharp/render.js +9 -9
- package/dist/document-ingest-foundation/aggregate-id.js +0 -1
- package/dist/document-ingest-foundation/append-missing-extract-event.d.ts +0 -1
- package/dist/document-ingest-foundation/append-missing-extract-event.js +32 -21
- package/dist/document-ingest-foundation/report-ingest-progress.d.ts +1 -1
- package/dist/document-ingest-foundation/report-ingest-progress.js +29 -13
- package/dist/documents/aggregate-id.js +0 -2
- package/dist/documents/constants.d.ts +6 -0
- package/dist/documents/constants.js +8 -2
- package/dist/documents/ensure-link.d.ts +5 -8
- package/dist/documents/ensure-link.js +4 -2
- package/dist/documents/feature.d.ts +3 -1
- package/dist/documents/feature.js +24 -5
- package/dist/documents/handlers/import.write.js +2 -2
- package/dist/documents/queries/expiry-overview.query.js +2 -1
- package/dist/documents/queries/for-record.query.js +3 -4
- package/dist/documents/queries/list-page.js +11 -3
- package/dist/documents/queries/overview.query.js +2 -2
- package/dist/documents/screens.js +3 -3
- package/dist/documents/tab.js +1 -1
- package/dist/feature-toggles/toggle-sync-signal.d.ts +2 -2
- package/dist/feature-toggles/toggle-sync-signal.js +3 -2
- package/dist/file-derivatives/handlers/public-variant-by-file-ref.query.js +1 -1
- package/dist/file-derivatives/handlers/public-variant.query.js +1 -1
- package/dist/file-foundation/probe.js +9 -3
- package/dist/file-foundation/read-file-ref-content.js +23 -11
- package/dist/file-provider-inmemory/feature.js +1 -1
- package/dist/file-provider-s3/env-feature.js +1 -1
- package/dist/file-provider-s3/env-named-feature.js +1 -1
- package/dist/file-provider-s3/env-schema.d.ts +10 -1
- package/dist/file-provider-s3/env-schema.js +20 -7
- package/dist/file-provider-s3/feature.js +1 -1
- package/dist/file-provider-s3/index.d.ts +1 -1
- package/dist/file-provider-s3/index.js +1 -1
- package/dist/file-provider-s3/lib/env-helper.d.ts +3 -2
- package/dist/file-provider-s3/lib/env-helper.js +13 -12
- package/dist/file-provider-s3/lib/s3-provider.js +10 -2
- package/dist/folders/aggregate-id.js +0 -1
- package/dist/folders/web/folder-manager.js +1 -1
- package/dist/folders-user-data/index.js +12 -14
- package/dist/helpdesk/entity.js +4 -1
- package/dist/helpdesk/feature.js +36 -0
- package/dist/helpdesk/handlers/access.d.ts +0 -1
- package/dist/helpdesk/handlers/access.js +0 -3
- package/dist/helpdesk/handlers/attempts.js +7 -13
- package/dist/helpdesk/handlers/challenge.query.js +1 -2
- package/dist/helpdesk/handlers/reply.write.js +4 -5
- package/dist/helpdesk/handlers/report.write.js +3 -7
- package/dist/helpdesk/handlers/submit.write.js +4 -9
- package/dist/helpdesk/index.d.ts +1 -1
- package/dist/helpdesk/index.js +1 -1
- package/dist/helpdesk/legacy-contact-config.d.ts +3 -0
- package/dist/helpdesk/legacy-contact-config.js +57 -0
- package/dist/helpdesk/legacy-contact-erasure.d.ts +9 -0
- package/dist/helpdesk/legacy-contact-erasure.js +19 -0
- package/dist/helpdesk/legacy-contact-retention.d.ts +2 -0
- package/dist/helpdesk/legacy-contact-retention.js +53 -0
- package/dist/helpdesk/legacy-contact-streams.d.ts +20 -0
- package/dist/helpdesk/legacy-contact-streams.js +121 -0
- package/dist/helpdesk/legacy-contact-user-data.d.ts +5 -0
- package/dist/helpdesk/legacy-contact-user-data.js +62 -0
- package/dist/helpdesk/lib.d.ts +7 -1
- package/dist/helpdesk/lib.js +29 -29
- package/dist/helpdesk/user-data-hooks.d.ts +10 -1
- package/dist/helpdesk/user-data-hooks.js +47 -36
- package/dist/helpdesk/web/constants.d.ts +0 -1
- package/dist/helpdesk/web/constants.js +0 -1
- package/dist/inbound-mail-foundation/account-health.js +1 -1
- package/dist/inbound-mail-foundation/account-poll.js +1 -1
- package/dist/inbound-mail-foundation/aggregate-id.js +0 -2
- package/dist/inbound-mail-foundation/constants.d.ts +6 -0
- package/dist/inbound-mail-foundation/constants.js +6 -0
- package/dist/inbound-mail-foundation/content-refetch.d.ts +1 -0
- package/dist/inbound-mail-foundation/content-refetch.js +15 -1
- package/dist/inbound-mail-foundation/entities.js +57 -15
- package/dist/inbound-mail-foundation/events.js +15 -16
- package/dist/inbound-mail-foundation/feature.js +3 -1
- package/dist/inbound-mail-foundation/handlers/account-address.d.ts +2 -2
- package/dist/inbound-mail-foundation/handlers/account-address.js +10 -2
- package/dist/inbound-mail-foundation/handlers/attach-message-content.write.js +8 -3
- package/dist/inbound-mail-foundation/handlers/connect-account.write.js +12 -7
- package/dist/inbound-mail-foundation/handlers/forget-message.write.d.ts +7 -0
- package/dist/inbound-mail-foundation/handlers/forget-message.write.js +54 -0
- package/dist/inbound-mail-foundation/i18n.js +3 -0
- package/dist/inbound-mail-foundation/index.d.ts +1 -0
- package/dist/inbound-mail-foundation/index.js +1 -0
- package/dist/inbound-mail-foundation/oauth-access-token.js +1 -1
- package/dist/inbound-mail-foundation/outbound-mail.d.ts +2 -0
- package/dist/inbound-mail-foundation/personal-address.d.ts +1 -0
- package/dist/inbound-mail-foundation/personal-address.js +16 -0
- package/dist/inbound-mail-foundation/purge-messages.d.ts +20 -0
- package/dist/inbound-mail-foundation/purge-messages.js +33 -0
- package/dist/inbound-mail-foundation/quarantine.d.ts +3 -2
- package/dist/inbound-mail-foundation/quarantine.js +9 -5
- package/dist/inbound-mail-foundation/retention-job.js +1 -5
- package/dist/inbound-mail-foundation/retention-sweep.js +17 -28
- package/dist/inbound-mail-foundation/send-from-account.js +9 -1
- package/dist/inbound-mail-foundation/supervisor-ingest.js +4 -1
- package/dist/inbound-mail-foundation/sync-account-now.js +1 -1
- package/dist/inbound-mail-foundation/tenant-destroy-hook.js +3 -6
- package/dist/inbound-mail-foundation/watch-supervisor.js +1 -1
- package/dist/inbound-provider-imap/byte-budget.d.ts +14 -0
- package/dist/inbound-provider-imap/byte-budget.js +53 -0
- package/dist/inbound-provider-imap/connect-mailbox.d.ts +2 -4
- package/dist/inbound-provider-imap/connect-mailbox.js +8 -3
- package/dist/inbound-provider-imap/connect-my-mailbox.d.ts +1 -1
- package/dist/inbound-provider-imap/connect-my-mailbox.js +15 -4
- package/dist/inbound-provider-imap/connect-target-rate-limit.d.ts +3 -0
- package/dist/inbound-provider-imap/connect-target-rate-limit.js +37 -0
- package/dist/inbound-provider-imap/download-batch.d.ts +10 -0
- package/dist/inbound-provider-imap/download-batch.js +21 -6
- package/dist/inbound-provider-imap/feature.js +7 -4
- package/dist/inbound-provider-imap/fetch-content.js +35 -30
- package/dist/inbound-provider-imap/i18n.js +2 -2
- package/dist/inbound-provider-imap/parse-message.d.ts +7 -0
- package/dist/inbound-provider-imap/parse-message.js +8 -0
- package/dist/inbound-provider-imap/reconnect-mailbox.js +5 -4
- package/dist/inbound-provider-imap/send-mail.d.ts +2 -0
- package/dist/inbound-provider-imap/send-mail.js +32 -6
- package/dist/inbound-provider-imap/smtp-client.d.ts +9 -2
- package/dist/inbound-provider-imap/smtp-client.js +15 -3
- package/dist/inbound-provider-imap/watch-mailbox.js +3 -24
- package/dist/inbound-provider-inmemory/feature.js +1 -1
- package/dist/jobs/events.d.ts +13 -0
- package/dist/jobs/events.js +8 -0
- package/dist/jobs/feature.js +2 -0
- package/dist/jobs/handlers/consumer.write.js +31 -20
- package/dist/jobs/web/constants.d.ts +3 -0
- package/dist/jobs/web/constants.js +3 -0
- package/dist/mail-transport-inmemory/feature.js +1 -1
- package/dist/mail-transport-smtp/feature.js +3 -2
- package/dist/managed-pages/handlers/branding.query.js +1 -1
- package/dist/managed-pages/handlers/by-slug.query.js +1 -1
- package/dist/managed-pages/handlers/by-tenant-published.query.js +1 -1
- package/dist/managed-pages/render-page-body.d.ts +2 -0
- package/dist/managed-pages/render-page-body.js +12 -8
- package/dist/managed-pages/screens/page-screens.d.ts +3 -2
- package/dist/managed-pages/screens/page-screens.js +14 -33
- package/dist/managed-pages/table.js +1 -0
- package/dist/managed-pages/web/client-plugin.js +8 -6
- package/dist/managed-pages/web/constants.d.ts +5 -1
- package/dist/managed-pages/web/constants.js +6 -1
- package/dist/managed-pages/web/i18n.js +11 -3
- package/dist/managed-pages/web/markdown-to-document.js +1 -1
- package/dist/managed-pages/web/page-edit-draft.d.ts +32 -0
- package/dist/managed-pages/web/page-edit-draft.js +76 -0
- package/dist/managed-pages/web/page-edit-screen.d.ts +2 -0
- package/dist/managed-pages/web/page-edit-screen.js +106 -0
- package/dist/managed-pages/web/page-settings-rail.d.ts +11 -0
- package/dist/managed-pages/web/page-settings-rail.js +14 -0
- package/dist/notes-history-user-data/index.js +8 -14
- package/dist/personal-access-tokens/boot-rules.d.ts +5 -0
- package/dist/personal-access-tokens/boot-rules.js +5 -0
- package/dist/personal-access-tokens/handlers/create.write.js +0 -1
- package/dist/personal-access-tokens/scope-events-check.js +26 -6
- package/dist/presence/handlers/list.query.js +18 -8
- package/dist/presence/room.d.ts +2 -0
- package/dist/presence/room.js +8 -5
- package/dist/presence/store.d.ts +2 -0
- package/dist/presence/store.js +62 -26
- package/dist/readiness/handlers/latest-summary.query.js +10 -6
- package/dist/readiness/handlers/run-probes.write.js +24 -4
- package/dist/readiness/handlers/run-tone.js +3 -2
- package/dist/readiness/handlers/status.query.js +11 -3
- package/dist/readiness/probe-context.js +7 -10
- package/dist/readiness/screens.js +4 -4
- package/dist/readiness/visible-results.d.ts +1 -1
- package/dist/readiness/visible-results.js +5 -2
- package/dist/renderer-foundation/api.js +6 -12
- package/dist/renderer-foundation/types.d.ts +2 -2
- package/dist/secrets/db/queries/read.d.ts +2 -1
- package/dist/secrets/db/queries/read.js +10 -1
- package/dist/secrets/handlers/list.query.js +4 -2
- package/dist/secrets/secret-scope.d.ts +0 -1
- package/dist/secrets/secret-scope.js +2 -2
- package/dist/secrets/secrets-context.js +4 -4
- package/dist/secrets/table.d.ts +1 -1
- package/dist/secrets/write-gate.js +4 -2
- package/dist/seo/handlers/seo-config.query.js +1 -1
- package/dist/shared/acknowledged-system-db.d.ts +5 -0
- package/dist/shared/acknowledged-system-db.js +9 -0
- package/dist/shared/assert-billing-live.d.ts +1 -0
- package/dist/shared/assert-billing-live.js +5 -2
- package/dist/shared/index.d.ts +6 -2
- package/dist/shared/index.js +6 -2
- package/dist/shared/parent-visibility.d.ts +1 -0
- package/dist/shared/parent-visibility.js +16 -1
- package/dist/shared/password-hashing.js +0 -1
- package/dist/shared/price-env-shape.js +1 -1
- package/dist/shared/register-user-data-hooks.d.ts +11 -0
- package/dist/shared/register-user-data-hooks.js +11 -0
- package/dist/shared/require-bootstrap-extension.d.ts +9 -0
- package/dist/shared/require-bootstrap-extension.js +16 -0
- package/dist/shared/send-best-effort.d.ts +2 -0
- package/dist/shared/send-best-effort.js +14 -0
- package/dist/shared/stream-tenant-backfill.d.ts +1 -0
- package/dist/shared/stream-tenant-backfill.js +17 -1
- package/dist/shared/stream-tenant-derived-state.d.ts +5 -1
- package/dist/shared/stream-tenant-derived-state.js +19 -2
- package/dist/step-dispatcher/constants.d.ts +4 -0
- package/dist/step-dispatcher/constants.js +11 -0
- package/dist/step-dispatcher/deliver-dispatch-request.d.ts +1 -0
- package/dist/step-dispatcher/deliver-dispatch-request.js +38 -2
- package/dist/step-dispatcher/feature.js +20 -2
- package/dist/step-dispatcher/mail-runner.js +0 -1
- package/dist/step-dispatcher/sweep-abandoned.d.ts +10 -0
- package/dist/step-dispatcher/sweep-abandoned.js +43 -0
- package/dist/subscription-mollie/plugin-methods.d.ts +1 -0
- package/dist/subscription-mollie/plugin-methods.js +1 -2
- package/dist/subscription-mollie/verify-webhook.js +5 -5
- package/dist/subscription-paddle/backfill-checkout-ledger.d.ts +9 -0
- package/dist/subscription-paddle/backfill-checkout-ledger.js +110 -0
- package/dist/subscription-paddle/checkout-config.query.js +1 -1
- package/dist/subscription-paddle/checkout-methods.js +2 -8
- package/dist/subscription-paddle/constants.d.ts +0 -1
- package/dist/subscription-paddle/constants.js +1 -2
- package/dist/subscription-paddle/feature.d.ts +0 -4
- package/dist/subscription-paddle/feature.js +21 -20
- package/dist/subscription-paddle/ledger-backfill-marker.d.ts +17 -0
- package/dist/subscription-paddle/ledger-backfill-marker.js +53 -0
- package/dist/subscription-paddle/plan-switch-methods.js +2 -8
- package/dist/subscription-paddle/redeliver-legacy-checkout.d.ts +11 -0
- package/dist/subscription-paddle/redeliver-legacy-checkout.js +26 -0
- package/dist/subscription-paddle/runtime.d.ts +3 -5
- package/dist/subscription-paddle/runtime.js +4 -7
- package/dist/subscription-paddle/subscription-state.d.ts +1 -0
- package/dist/subscription-paddle/subscription-state.js +1 -0
- package/dist/subscription-paddle/webhook-events.d.ts +4 -0
- package/dist/subscription-paddle/webhook-events.js +40 -22
- package/dist/subscription-stripe/feature.d.ts +4 -0
- package/dist/subscription-stripe/feature.js +1 -0
- package/dist/subscription-stripe/plugin-methods.d.ts +1 -0
- package/dist/subscription-stripe/plugin-methods.js +2 -5
- package/dist/subscription-stripe/runtime.d.ts +2 -1
- package/dist/subscription-stripe/runtime.js +5 -7
- package/dist/subscription-stripe/verify-webhook.js +21 -6
- package/dist/tags/aggregate-id.js +0 -1
- package/dist/tags/web/tag-chip.js +0 -1
- package/dist/tags/web/tag-manager.js +3 -1
- package/dist/template-resolver/api.js +6 -12
- package/dist/template-resolver/document-sanitizer.d.ts +1 -1
- package/dist/template-resolver/document-sanitizer.js +18 -0
- package/dist/template-resolver/feature.d.ts +1 -0
- package/dist/template-resolver/feature.js +2 -0
- package/dist/template-resolver/handlers/body-preview.query.d.ts +11 -0
- package/dist/template-resolver/handlers/body-preview.query.js +41 -0
- package/dist/template-resolver/handlers/by-slug.query.js +1 -1
- package/dist/template-resolver/handlers/by-tenant.query.js +1 -1
- package/dist/template-resolver/handlers/collection-shared.js +5 -8
- package/dist/template-resolver/handlers/overview.query.d.ts +1 -0
- package/dist/template-resolver/handlers/overview.query.js +2 -1
- package/dist/template-resolver/handlers/send-test.write.js +27 -8
- package/dist/template-resolver/linked-resources.js +2 -6
- package/dist/template-resolver/seeding.js +67 -1
- package/dist/template-resolver/table.js +1 -0
- package/dist/template-resolver/template-draft.js +2 -1
- package/dist/template-resolver/template-preview.js +12 -3
- package/dist/template-resolver/testing.js +0 -2
- package/dist/template-resolver/web/client-plugin.js +3 -0
- package/dist/template-resolver/web/collection-entry-create-form.js +19 -9
- package/dist/template-resolver/web/constants.d.ts +2 -0
- package/dist/template-resolver/web/constants.js +2 -0
- package/dist/template-resolver/web/content-tree-provider.js +0 -1
- package/dist/template-resolver/web/content-workbench.d.ts +22 -0
- package/dist/template-resolver/web/content-workbench.js +32 -0
- package/dist/template-resolver/web/document-insert-model.d.ts +2 -4
- package/dist/template-resolver/web/document-insert-model.js +1 -2
- package/dist/template-resolver/web/document-link-policy.d.ts +3 -0
- package/dist/template-resolver/web/document-link-policy.js +53 -0
- package/dist/template-resolver/web/document-schema.d.ts +2 -4
- package/dist/template-resolver/web/document-schema.js +2 -53
- package/dist/template-resolver/web/document-tiptap-context.d.ts +2 -5
- package/dist/template-resolver/web/document-tiptap-context.js +2 -2
- package/dist/template-resolver/web/document-tiptap-editor.js +2 -2
- package/dist/template-resolver/web/document-tiptap-helpers.d.ts +7 -4
- package/dist/template-resolver/web/document-tiptap-toolbar-groups.js +3 -3
- package/dist/template-resolver/web/editor-handle.js +1 -0
- package/dist/template-resolver/web/fill-document-variables.d.ts +1 -0
- package/dist/template-resolver/web/fill-document-variables.js +22 -0
- package/dist/template-resolver/web/i18n.js +10 -0
- package/dist/template-resolver/web/index.d.ts +3 -0
- package/dist/template-resolver/web/index.js +2 -0
- package/dist/template-resolver/web/preview-targets.d.ts +5 -0
- package/dist/template-resolver/web/preview-targets.js +21 -0
- package/dist/template-resolver/web/qualified-names.d.ts +1 -0
- package/dist/template-resolver/web/qualified-names.js +1 -0
- package/dist/template-resolver/web/snippet-preview-renderer.d.ts +2 -0
- package/dist/template-resolver/web/snippet-preview-renderer.js +15 -0
- package/dist/template-resolver/web/string-values.d.ts +1 -0
- package/dist/template-resolver/web/string-values.js +8 -0
- package/dist/template-resolver/web/text-block-editor.js +18 -11
- package/dist/template-resolver/web/use-collection-entry-create.d.ts +1 -0
- package/dist/template-resolver/web/use-collection-entry-create.js +6 -0
- package/dist/template-resolver/web/use-document-tiptap-model.d.ts +2 -6
- package/dist/template-resolver/web/use-text-block-editor.d.ts +3 -0
- package/dist/template-resolver/web/use-text-block-editor.js +26 -5
- package/dist/template-resolver/web/web-preview-renderer.d.ts +12 -0
- package/dist/template-resolver/web/web-preview-renderer.js +41 -0
- package/dist/template-resolver-user-data/index.js +11 -10
- package/dist/tenant/handlers/create.write.js +3 -7
- package/dist/tenant/handlers/list.query.js +3 -8
- package/dist/tenant/handlers/member-directory.query.js +10 -5
- package/dist/tenant/handlers/toggle-enabled.write.js +1 -1
- package/dist/tenant/invited-membership.js +9 -1
- package/dist/tenant/seeding.d.ts +3 -0
- package/dist/tenant/seeding.js +3 -1
- package/dist/tenant/stream-tenant-backfill.js +5 -1
- package/dist/tenant/testing.js +1 -1
- package/dist/tenant-inactivity/check-inactive-tenants.js +5 -5
- package/dist/tenant-inactivity/constants.js +1 -2
- package/dist/tenant-inactivity/handlers/keep-account.write.js +1 -2
- package/dist/tenant-inactivity/state-store.d.ts +1 -0
- package/dist/tenant-inactivity/state-store.js +9 -1
- package/dist/tenant-lifecycle/constants.d.ts +1 -0
- package/dist/tenant-lifecycle/constants.js +3 -0
- package/dist/tenant-lifecycle/run-tenant-destroy.js +38 -5
- package/dist/tenant-lifecycle/stages.js +14 -2
- package/dist/tier-engine/aggregate-id.js +0 -1
- package/dist/tier-engine/feature.js +9 -2
- package/dist/user/db/queries/stream-tenant-backfill.js +2 -1
- package/dist/user/handlers/me.query.js +4 -1
- package/dist/user/index.d.ts +1 -0
- package/dist/user/index.js +1 -0
- package/dist/user/resolve-verified-user-email.d.ts +2 -0
- package/dist/user/resolve-verified-user-email.js +14 -0
- package/dist/user-data-rights/db/queries/export-jobs.js +0 -1
- package/dist/user-data-rights/handlers/confirm-deletion-by-token.write.js +1 -1
- package/dist/user-data-rights/handlers/download-by-token.query.js +1 -1
- package/dist/user-data-rights/handlers/request-deletion-by-email.write.js +1 -1
- package/dist/user-data-rights/run-export-jobs.js +0 -2
- package/dist/user-data-rights/run-forget-cleanup.js +2 -2
- package/dist/user-data-rights/schema/download-attempt.js +3 -2
- package/dist/user-data-rights/web/confirm-deletion-screen.js +2 -2
- package/dist/user-data-rights/web/privacy-center-screen.js +1 -1
- package/dist/user-data-rights/web/request-deletion-screen.js +2 -2
- package/dist/user-data-rights-defaults/hooks/api-token.userdata-hook.js +5 -6
- package/dist/user-data-rights-defaults/hooks/hard-delete-own-rows-hook.d.ts +7 -0
- package/dist/user-data-rights-defaults/hooks/hard-delete-own-rows-hook.js +11 -0
- package/dist/user-data-rights-defaults/hooks/in-app-message.userdata-hook.js +5 -6
- package/dist/user-data-rights-defaults/hooks/job-run.userdata-hook.js +2 -1
- package/dist/user-data-rights-defaults/hooks/user-session.userdata-hook.js +5 -6
- package/dist/user-profile/handlers/change-email.write.js +0 -1
- package/dist/waitlist/handlers/submit.write.js +5 -18
- package/dist/waitlist/lib.js +2 -7
- package/dist/waitlist/user-data-hooks.js +6 -20
- package/dist/workflow-runner/aggregate-id.js +0 -1
- package/dist/workflow-runner/event-trigger.js +6 -2
- package/dist/workflow-runner/feature.js +1 -5
- package/dist/workflow-runner/handlers/resume-run.write.js +4 -3
- package/dist/workflow-runner/runner.d.ts +1 -0
- package/package.json +35 -11
- package/src/admin-shell/changes.json +6 -0
- package/src/agent-tools/changes.json +12 -0
- package/src/auth-email-password/changes.json +18 -0
- package/src/billing-foundation/changes.json +37 -0
- package/src/cap-counter/changes.json +6 -0
- package/src/cap-overview/changes.json +6 -0
- package/src/channel-in-app/changes.json +6 -0
- package/src/channel-whatsapp/changes.json +8 -0
- package/src/config/changes.json +12 -0
- package/src/crypto-shredding/changes.json +18 -0
- package/src/data-retention/changes.json +12 -0
- package/src/delivery/changes.json +6 -0
- package/src/documents/changes.json +18 -0
- package/src/file-provider-s3/changes.json +14 -0
- package/src/files/changes.json +7 -0
- package/src/helpdesk/changes.json +50 -0
- package/src/inbound-mail-foundation/changes.json +48 -0
- package/src/inbound-provider-imap/changes.json +13 -0
- package/src/mail-foundation/changes.json +6 -0
- package/src/managed-pages/changes.json +12 -0
- package/src/presence/changes.json +6 -0
- package/src/readiness/changes.json +25 -0
- package/src/secrets/changes.json +7 -0
- package/src/shared/changes.json +6 -0
- package/src/step-dispatcher/changes.json +12 -0
- package/src/subscription-mollie/changes.json +7 -0
- package/src/subscription-paddle/changes.json +13 -0
- package/src/subscription-stripe/changes.json +7 -0
- package/src/template-resolver/changes.json +36 -0
- package/src/tenant/changes.json +6 -0
- package/src/tenant-lifecycle/changes.json +18 -0
- package/src/tier-engine/changes.json +6 -0
- package/src/user/changes.json +6 -0
- package/src/waitlist/changes.json +6 -0
- package/dist/managed-pages/web/page-body-section.d.ts +0 -3
- package/dist/managed-pages/web/page-body-section.js +0 -40
- package/dist/subscription-paddle/tenant-binding.d.ts +0 -8
- package/dist/subscription-paddle/tenant-binding.js +0 -26
- package/dist/template-resolver/web/content-field.d.ts +0 -9
- package/dist/template-resolver/web/content-field.js +0 -14
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { createSystemUser, defineWriteHandler, } from "@cosmicdrift/kumiko-framework/engine";
|
|
2
|
-
import { NotFoundError,
|
|
2
|
+
import { NotFoundError, writeFailure } from "@cosmicdrift/kumiko-framework/errors";
|
|
3
3
|
import { generateId } from "@cosmicdrift/kumiko-framework/utils";
|
|
4
4
|
import { parseTenantId } from "@cosmicdrift/kumiko-types/identifiers";
|
|
5
5
|
import { adminAccess, helpdeskDb, loadUserLabel, pickReplyChannels, platformActor, replyExecutor, requestExecutor, sendBestEffort, } from "../lib.js";
|
|
6
6
|
import { HelpdeskReplySchema } from "../payloads.js";
|
|
7
|
-
import { HELPDESK_REPLY_CHANNELS, HELPDESK_REPLY_ENTITY, HELPDESK_REQUEST_ENTITY, HELPDESK_STATUS,
|
|
7
|
+
import { HELPDESK_REPLY_CHANNELS, HELPDESK_REPLY_ENTITY, HELPDESK_REQUEST_ENTITY, HELPDESK_STATUS, HelpdeskHandlers, HelpdeskScreens, } from "../web/constants.js";
|
|
8
8
|
import { takeOverUploads } from "./take-over-uploads.js";
|
|
9
9
|
async function noteReporterInApp(ctx, args) {
|
|
10
10
|
const { request } = args;
|
|
@@ -83,9 +83,8 @@ export function createReplyHandler() {
|
|
|
83
83
|
entityId: replyId,
|
|
84
84
|
fileIds: event.payload.fileIds ?? [],
|
|
85
85
|
});
|
|
86
|
-
if (!uploaded.isSuccess)
|
|
87
|
-
return
|
|
88
|
-
}
|
|
86
|
+
if (!uploaded.isSuccess)
|
|
87
|
+
return uploaded;
|
|
89
88
|
const fileIds = uploaded.data;
|
|
90
89
|
const author = await loadUserLabel(db, event.user.id);
|
|
91
90
|
const authorName = author?.name ?? event.user.id;
|
|
@@ -2,12 +2,12 @@ import { requestContext } from "@cosmicdrift/kumiko-framework/api";
|
|
|
2
2
|
import { defineWriteHandler } from "@cosmicdrift/kumiko-framework/engine";
|
|
3
3
|
import { UnprocessableError, writeFailure } from "@cosmicdrift/kumiko-framework/errors";
|
|
4
4
|
import { generateId } from "@cosmicdrift/kumiko-framework/utils";
|
|
5
|
-
import { helpdeskDb, loadTenantName, loadTenantPlan, loadUserLabel, normalizeEmail, phoneProblem, platformActor, requestExecutor, sendBestEffort, } from "../lib.js";
|
|
5
|
+
import { forwardHelpdeskRequest, helpdeskDb, loadTenantName, loadTenantPlan, loadUserLabel, normalizeEmail, phoneProblem, platformActor, requestExecutor, sendBestEffort, } from "../lib.js";
|
|
6
6
|
import { helpdeskConfirmationVariables, resolveHelpdeskMailLocale } from "../mail.js";
|
|
7
7
|
import { REPORT_RATE_LIMIT } from "../options.js";
|
|
8
8
|
import { HelpdeskReportSchema } from "../payloads.js";
|
|
9
9
|
import { summarizeUserAgent } from "../user-agent.js";
|
|
10
|
-
import { HELPDESK_NOTIFICATION_TYPES, HELPDESK_REQUEST_ENTITY, HELPDESK_SOURCE, HELPDESK_STATUS, HELPDESK_UPLOAD_FIELD, HelpdeskErrors,
|
|
10
|
+
import { HELPDESK_NOTIFICATION_TYPES, HELPDESK_REQUEST_ENTITY, HELPDESK_SOURCE, HELPDESK_STATUS, HELPDESK_UPLOAD_FIELD, HelpdeskErrors, HelpdeskScreens, helpdeskIdempotencyKeys, } from "../web/constants.js";
|
|
11
11
|
import { REPORT_ACCESS } from "./access.js";
|
|
12
12
|
import { takeOverUploads } from "./take-over-uploads.js";
|
|
13
13
|
export function createReportHandler(opts, settings) {
|
|
@@ -67,11 +67,7 @@ export function createReportHandler(opts, settings) {
|
|
|
67
67
|
}, platformActor(), db);
|
|
68
68
|
if (!created.isSuccess)
|
|
69
69
|
return created;
|
|
70
|
-
await sendBestEffort(ctx, "forward request",
|
|
71
|
-
const forwarded = await ctx.dispatch.writeAs(platformActor(), HelpdeskHandlers.forwardRequest, { requestId });
|
|
72
|
-
if (!forwarded.isSuccess)
|
|
73
|
-
throw new Error(forwarded.error.message);
|
|
74
|
-
});
|
|
70
|
+
await sendBestEffort(ctx, "forward request", () => forwardHelpdeskRequest(ctx, requestId));
|
|
75
71
|
await sendBestEffort(ctx, "confirmation mail", (notify) => notify(HELPDESK_NOTIFICATION_TYPES.confirmation, {
|
|
76
72
|
route: { email },
|
|
77
73
|
recipientId: requestId,
|
|
@@ -4,15 +4,14 @@ import { InternalError, isKumikoError, UnprocessableError, writeFailure, } from
|
|
|
4
4
|
import { normalizePayloadBucketValue } from "@cosmicdrift/kumiko-framework/pipeline";
|
|
5
5
|
import { generateId } from "@cosmicdrift/kumiko-framework/utils";
|
|
6
6
|
import { consumeChallenge } from "../challenge.js";
|
|
7
|
-
import { helpdeskDb, normalizeEmail, phoneProblem, platformActor, requestExecutor, sendBestEffort, } from "../lib.js";
|
|
7
|
+
import { forwardHelpdeskRequest, helpdeskDb, normalizeEmail, phoneProblem, platformActor, requestExecutor, sendBestEffort, } from "../lib.js";
|
|
8
8
|
import { helpdeskAcknowledgementVariables, resolveHelpdeskMailLocale } from "../mail.js";
|
|
9
9
|
import { DEFAULT_SUBMIT_EMAIL_RATE_LIMITS, DEFAULT_SUBMIT_RATE_LIMIT, } from "../options.js";
|
|
10
10
|
import { HelpdeskSubmitSchema } from "../payloads.js";
|
|
11
11
|
import { verifyProofOfWork } from "../pow.js";
|
|
12
12
|
import { deriveSubjectFromMessage } from "../subject.js";
|
|
13
13
|
import { summarizeUserAgent } from "../user-agent.js";
|
|
14
|
-
import { HELPDESK_NOTIFICATION_TYPES, HELPDESK_SOURCE, HELPDESK_STATUS,
|
|
15
|
-
import { SUBMIT_ROLES } from "./access.js";
|
|
14
|
+
import { HELPDESK_NOTIFICATION_TYPES, HELPDESK_SOURCE, HELPDESK_STATUS, helpdeskIdempotencyKeys, } from "../web/constants.js";
|
|
16
15
|
// Identical body for stored and silently dropped submits, so a bot learns nothing from it.
|
|
17
16
|
const SUBMITTED = {
|
|
18
17
|
isSuccess: true,
|
|
@@ -75,7 +74,7 @@ export function createSubmitHandler(opts, settings) {
|
|
|
75
74
|
return defineWriteHandler({
|
|
76
75
|
name: "submit",
|
|
77
76
|
schema: HelpdeskSubmitSchema,
|
|
78
|
-
access: { roles:
|
|
77
|
+
access: { roles: ["anonymous"], personalData: "public-intake", anySignedIn: true },
|
|
79
78
|
rateLimit: opts.rateLimit ?? DEFAULT_SUBMIT_RATE_LIMIT,
|
|
80
79
|
agent: { expose: false },
|
|
81
80
|
description: "Public contact form: stores a question, contact request or problem report from a website visitor after a single-use proof-of-work challenge, forwards it to the SystemAdmins (mail, optional Telegram) and mails the sender a copy. Spam (honeypot, unknown or reused challenge, too fast, wrong proof of work) gets the same success body but nothing is stored or sent.",
|
|
@@ -115,11 +114,7 @@ export function createSubmitHandler(opts, settings) {
|
|
|
115
114
|
}, platformActor(), helpdeskDb(ctx));
|
|
116
115
|
if (!created.isSuccess)
|
|
117
116
|
return created;
|
|
118
|
-
await sendBestEffort(ctx, "forward request",
|
|
119
|
-
const forwarded = await ctx.dispatch.writeAs(platformActor(), HelpdeskHandlers.forwardRequest, { requestId });
|
|
120
|
-
if (!forwarded.isSuccess)
|
|
121
|
-
throw new Error(forwarded.error.message);
|
|
122
|
-
});
|
|
117
|
+
await sendBestEffort(ctx, "forward request", () => forwardHelpdeskRequest(ctx, requestId));
|
|
123
118
|
await sendBestEffort(ctx, "confirmation mail", (notify) => notify(HELPDESK_NOTIFICATION_TYPES.acknowledgement, {
|
|
124
119
|
route: { email },
|
|
125
120
|
recipientId: requestId,
|
package/dist/helpdesk/index.d.ts
CHANGED
|
@@ -2,4 +2,4 @@ export { helpdeskReplyEntity, helpdeskReplyTable, helpdeskRequestEntity, helpdes
|
|
|
2
2
|
export { createHelpdeskFeature } from "./feature.ts";
|
|
3
3
|
export type { HelpdeskOptions } from "./options.ts";
|
|
4
4
|
export { helpdeskOpenRequestsPanels } from "./panels.ts";
|
|
5
|
-
export { HELPDESK_ADMIN_KINDS, HELPDESK_CLIENT_PATH, HELPDESK_DELIVERY_CHANNEL, HELPDESK_DELIVERY_STATUS, HELPDESK_FEATURE, HELPDESK_FIELD_LIMITS, HELPDESK_KIND, HELPDESK_NOTIFICATION_TYPES, HELPDESK_ORIGIN, HELPDESK_REPLY_CHANNELS, HELPDESK_SOURCE, HELPDESK_STATUS, HELPDESK_WEBSITE_KINDS, HelpdeskConfigKeys, HelpdeskErrors, HelpdeskHandlers, HelpdeskQueries, HelpdeskScreens, } from "./web/constants.ts";
|
|
5
|
+
export { HELPDESK_ADMIN_KINDS, HELPDESK_CLIENT_PATH, HELPDESK_DELIVERY_CHANNEL, HELPDESK_DELIVERY_STATUS, HELPDESK_FEATURE, HELPDESK_FIELD_LIMITS, HELPDESK_KIND, HELPDESK_NOTIFICATION_TYPES, HELPDESK_ORIGIN, HELPDESK_REPLY_CHANNELS, HELPDESK_REQUEST_ENTITY, HELPDESK_SOURCE, HELPDESK_STATUS, HELPDESK_WEBSITE_KINDS, HelpdeskConfigKeys, HelpdeskErrors, HelpdeskHandlers, HelpdeskQueries, HelpdeskScreens, } from "./web/constants.ts";
|
package/dist/helpdesk/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { helpdeskReplyEntity, helpdeskReplyTable, helpdeskRequestEntity, helpdeskRequestTable, } from "./entity.js";
|
|
2
2
|
export { createHelpdeskFeature } from "./feature.js";
|
|
3
3
|
export { helpdeskOpenRequestsPanels } from "./panels.js";
|
|
4
|
-
export { HELPDESK_ADMIN_KINDS, HELPDESK_CLIENT_PATH, HELPDESK_DELIVERY_CHANNEL, HELPDESK_DELIVERY_STATUS, HELPDESK_FEATURE, HELPDESK_FIELD_LIMITS, HELPDESK_KIND, HELPDESK_NOTIFICATION_TYPES, HELPDESK_ORIGIN, HELPDESK_REPLY_CHANNELS, HELPDESK_SOURCE, HELPDESK_STATUS, HELPDESK_WEBSITE_KINDS, HelpdeskConfigKeys, HelpdeskErrors, HelpdeskHandlers, HelpdeskQueries, HelpdeskScreens, } from "./web/constants.js";
|
|
4
|
+
export { HELPDESK_ADMIN_KINDS, HELPDESK_CLIENT_PATH, HELPDESK_DELIVERY_CHANNEL, HELPDESK_DELIVERY_STATUS, HELPDESK_FEATURE, HELPDESK_FIELD_LIMITS, HELPDESK_KIND, HELPDESK_NOTIFICATION_TYPES, HELPDESK_ORIGIN, HELPDESK_REPLY_CHANNELS, HELPDESK_REQUEST_ENTITY, HELPDESK_SOURCE, HELPDESK_STATUS, HELPDESK_WEBSITE_KINDS, HelpdeskConfigKeys, HelpdeskErrors, HelpdeskHandlers, HelpdeskQueries, HelpdeskScreens, } from "./web/constants.js";
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { ROLES } from "@cosmicdrift/kumiko-framework/auth";
|
|
2
|
+
import { ConfigScopes, createSystemUser, SYSTEM_TENANT_ID, } from "@cosmicdrift/kumiko-framework/engine";
|
|
3
|
+
import { InternalError, reraiseAsKumikoError } from "@cosmicdrift/kumiko-framework/errors";
|
|
4
|
+
import { parseJsonSafe } from "@cosmicdrift/kumiko-framework/utils";
|
|
5
|
+
import * as z from "zod";
|
|
6
|
+
import { ConfigHandlers, configValuesTable } from "../config/index.js";
|
|
7
|
+
import { HELPDESK_FEATURE } from "./web/constants.js";
|
|
8
|
+
export const LEGACY_CONTACT_CONFIG_JOB = "legacy-contact-config";
|
|
9
|
+
// The two keys of the former contact feature; the config values stay under them after the rename.
|
|
10
|
+
const CARRIED_OVER_KEYS = [
|
|
11
|
+
{ legacy: "contact:config:reply-to", current: `${HELPDESK_FEATURE}:config:reply-to` },
|
|
12
|
+
{ legacy: "contact:config:telegram-chat", current: `${HELPDESK_FEATURE}:config:telegram-chat` },
|
|
13
|
+
];
|
|
14
|
+
const storedValueSchema = z.union([z.string(), z.number(), z.boolean()]);
|
|
15
|
+
// Both keys are system-scope, so the former feature only ever stored system rows.
|
|
16
|
+
// Writes through config:write:set, so the helpdesk key's own validation applies.
|
|
17
|
+
export async function carryOverLegacyContactConfig(ctx) {
|
|
18
|
+
const reads = ctx.crossTenantReads;
|
|
19
|
+
if (!reads) {
|
|
20
|
+
throw new InternalError({
|
|
21
|
+
message: "[helpdesk] legacy-contact-config needs the crossTenantReads grant",
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
const systemAdmin = createSystemUser(SYSTEM_TENANT_ID, [ROLES.SystemAdmin]);
|
|
25
|
+
let carriedOver = 0;
|
|
26
|
+
for (const { legacy, current } of CARRIED_OVER_KEYS) {
|
|
27
|
+
// skip: telegramChat is only registered with option telegram, then there is nothing to carry into
|
|
28
|
+
if (!ctx.registry.getConfigKey(current))
|
|
29
|
+
continue;
|
|
30
|
+
const alreadySet = await reads.selectMany(configValuesTable, {
|
|
31
|
+
key: current,
|
|
32
|
+
tenantId: SYSTEM_TENANT_ID,
|
|
33
|
+
});
|
|
34
|
+
if (alreadySet.some((row) => row["userId"] == null))
|
|
35
|
+
continue;
|
|
36
|
+
const former = await reads.selectMany(configValuesTable, {
|
|
37
|
+
key: legacy,
|
|
38
|
+
tenantId: SYSTEM_TENANT_ID,
|
|
39
|
+
});
|
|
40
|
+
const row = former.find((candidate) => candidate["userId"] == null);
|
|
41
|
+
const stored = typeof row?.["value"] === "string" ? row["value"] : undefined;
|
|
42
|
+
if (stored === undefined)
|
|
43
|
+
continue;
|
|
44
|
+
const value = storedValueSchema.safeParse(parseJsonSafe(stored, undefined));
|
|
45
|
+
if (!value.success)
|
|
46
|
+
continue;
|
|
47
|
+
const written = await ctx.dispatch.writeAs(systemAdmin, ConfigHandlers.set, {
|
|
48
|
+
key: current,
|
|
49
|
+
value: value.data,
|
|
50
|
+
scope: ConfigScopes.system,
|
|
51
|
+
});
|
|
52
|
+
if (!written.isSuccess)
|
|
53
|
+
throw reraiseAsKumikoError(written.error);
|
|
54
|
+
carriedOver++;
|
|
55
|
+
}
|
|
56
|
+
return carriedOver;
|
|
57
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { TenantDb } from "@cosmicdrift/kumiko-framework/db";
|
|
2
|
+
import { type LegacyAggregate } from "./legacy-contact-streams.ts";
|
|
3
|
+
export type LegacyEraser = {
|
|
4
|
+
readonly db: TenantDb;
|
|
5
|
+
readonly erasedBy: string;
|
|
6
|
+
readonly purgeAttachments: (entity: string, id: string) => Promise<void>;
|
|
7
|
+
};
|
|
8
|
+
export declare function eraseLegacyAggregate(eraser: LegacyEraser, entity: string, id: string): Promise<void>;
|
|
9
|
+
export declare function eraseLegacyRequest(eraser: LegacyEraser, request: LegacyAggregate, replies: readonly LegacyAggregate[]): Promise<void>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { configuredPiiSubjectKms } from "@cosmicdrift/kumiko-framework/crypto";
|
|
2
|
+
import { archiveLegacyStream, LEGACY_CONTACT_REPLY_ENTITY, LEGACY_CONTACT_REQUEST_ENTITY, } from "./legacy-contact-streams.js";
|
|
3
|
+
import { eraseNotesOnRequest } from "./user-data-hooks.js";
|
|
4
|
+
const ERASE_REASON = "helpdesk:legacy-contact-forget";
|
|
5
|
+
// Attachments first, then the record key, then the archive mark: until the stream is archived a
|
|
6
|
+
// retry still finds it.
|
|
7
|
+
export async function eraseLegacyAggregate(eraser, entity, id) {
|
|
8
|
+
await eraser.purgeAttachments(entity, id);
|
|
9
|
+
await configuredPiiSubjectKms()?.eraseKey({ kind: "record", entity, id }, { requestId: ERASE_REASON, userId: eraser.erasedBy, eraseReason: ERASE_REASON });
|
|
10
|
+
await archiveLegacyStream(eraser.db, entity, id);
|
|
11
|
+
}
|
|
12
|
+
// Replies go with their request; notes hang on the request as host and go first, so a retry still
|
|
13
|
+
// finds the request.
|
|
14
|
+
export async function eraseLegacyRequest(eraser, request, replies) {
|
|
15
|
+
await eraseNotesOnRequest(eraser, LEGACY_CONTACT_REQUEST_ENTITY, request.id, eraser.erasedBy);
|
|
16
|
+
for (const reply of replies)
|
|
17
|
+
await eraseLegacyAggregate(eraser, LEGACY_CONTACT_REPLY_ENTITY, reply.id);
|
|
18
|
+
await eraseLegacyAggregate(eraser, LEGACY_CONTACT_REQUEST_ENTITY, request.id);
|
|
19
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { deleteFileRefBytes } from "@cosmicdrift/kumiko-framework/derivatives";
|
|
2
|
+
import { InternalError } from "@cosmicdrift/kumiko-framework/errors";
|
|
3
|
+
import { getTemporal } from "@cosmicdrift/kumiko-framework/time";
|
|
4
|
+
import { computeCutoff } from "../data-retention/index.js";
|
|
5
|
+
import { eraseLegacyAggregate, eraseLegacyRequest } from "./legacy-contact-erasure.js";
|
|
6
|
+
import { LEGACY_CONTACT_REPLY_ENTITY, LEGACY_CONTACT_REQUEST_ENTITY, readLegacyAggregates, repliesOf, } from "./legacy-contact-streams.js";
|
|
7
|
+
import { purgeAttachmentsWith } from "./user-data-hooks.js";
|
|
8
|
+
const RETENTION_CONTEXT = "helpdesk:legacy-contact-retention";
|
|
9
|
+
function isOlderThan(aggregate, referenceField, cutoff) {
|
|
10
|
+
const reference = aggregate.fields[referenceField];
|
|
11
|
+
if (typeof reference !== "string")
|
|
12
|
+
return false;
|
|
13
|
+
return getTemporal().Instant.compare(getTemporal().Instant.from(reference), cutoff) < 0;
|
|
14
|
+
}
|
|
15
|
+
// The helpdesk entities' retention cron only sees the live tables; the pre-rename streams have none,
|
|
16
|
+
// so the same keepFor is enforced on the event log.
|
|
17
|
+
export async function runLegacyContactRetention(keepFor, ctx) {
|
|
18
|
+
const cutoff = computeCutoff(keepFor, ctx.tz.now());
|
|
19
|
+
const eraser = {
|
|
20
|
+
db: ctx.db,
|
|
21
|
+
erasedBy: ctx.systemUser.id,
|
|
22
|
+
purgeAttachments: (entity, id) => purgeAttachmentsWith(ctx, entity, id, async () => {
|
|
23
|
+
const files = ctx.services.files;
|
|
24
|
+
if (!files) {
|
|
25
|
+
throw new InternalError({
|
|
26
|
+
message: `[${RETENTION_CONTEXT}] no file storage resolvable, attachments of ${entity} ${id} cannot be erased`,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
return (storageKey) => deleteFileRefBytes(files, { storageKey }, RETENTION_CONTEXT);
|
|
30
|
+
}),
|
|
31
|
+
};
|
|
32
|
+
const requests = await readLegacyAggregates(ctx.db, LEGACY_CONTACT_REQUEST_ENTITY, {
|
|
33
|
+
decrypt: false,
|
|
34
|
+
});
|
|
35
|
+
const replies = await readLegacyAggregates(ctx.db, LEGACY_CONTACT_REPLY_ENTITY, {
|
|
36
|
+
decrypt: false,
|
|
37
|
+
});
|
|
38
|
+
const erasedRequestIds = new Set();
|
|
39
|
+
for (const request of requests) {
|
|
40
|
+
if (!isOlderThan(request, "submittedAt", cutoff))
|
|
41
|
+
continue;
|
|
42
|
+
await eraseLegacyRequest(eraser, request, repliesOf(replies, request.id));
|
|
43
|
+
erasedRequestIds.add(request.id);
|
|
44
|
+
}
|
|
45
|
+
for (const reply of replies) {
|
|
46
|
+
const requestId = reply.fields["requestId"];
|
|
47
|
+
if (typeof requestId === "string" && erasedRequestIds.has(requestId))
|
|
48
|
+
continue;
|
|
49
|
+
if (isOlderThan(reply, "sentAt", cutoff)) {
|
|
50
|
+
await eraseLegacyAggregate(eraser, LEGACY_CONTACT_REPLY_ENTITY, reply.id);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { TenantDb } from "@cosmicdrift/kumiko-framework/db";
|
|
2
|
+
export declare const LEGACY_CONTACT_REQUEST_ENTITY = "contact-request";
|
|
3
|
+
export declare const LEGACY_CONTACT_REPLY_ENTITY = "contact-reply";
|
|
4
|
+
export declare const LEGACY_ARCHIVE_REASON = "legacy contact data erased";
|
|
5
|
+
export type LegacyAggregate = {
|
|
6
|
+
readonly id: string;
|
|
7
|
+
readonly fields: Readonly<Record<string, unknown>>;
|
|
8
|
+
readonly erased: boolean;
|
|
9
|
+
};
|
|
10
|
+
export type LegacyReadOptions = {
|
|
11
|
+
readonly decrypt?: boolean;
|
|
12
|
+
readonly isCandidate?: (raw: Readonly<Record<string, unknown>>) => boolean;
|
|
13
|
+
};
|
|
14
|
+
export declare function readLegacyAggregates(db: TenantDb, aggregateType: string, options?: LegacyReadOptions): Promise<readonly LegacyAggregate[]>;
|
|
15
|
+
export declare function findLegacyRequestsOfSubject(db: TenantDb, subject: {
|
|
16
|
+
readonly userId: string;
|
|
17
|
+
readonly email: string | undefined;
|
|
18
|
+
}): Promise<readonly LegacyAggregate[]>;
|
|
19
|
+
export declare function archiveLegacyStream(db: TenantDb, aggregateType: string, aggregateId: string): Promise<void>;
|
|
20
|
+
export declare function repliesOf(replies: readonly LegacyAggregate[], requestId: string): readonly LegacyAggregate[];
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { collectPiiEncryptedFields, configuredPiiSubjectKms, decryptPiiFieldValues, isPiiCiphertext, PII_ERASED_SENTINEL, } from "@cosmicdrift/kumiko-framework/crypto";
|
|
2
|
+
import { SYSTEM_TENANT_ID } from "@cosmicdrift/kumiko-framework/engine";
|
|
3
|
+
import { archiveStream, isStreamArchived, streamAllEventsByType, } from "@cosmicdrift/kumiko-framework/event-store";
|
|
4
|
+
import { systemTenantReadRunner, systemTenantWriteRunner, } from "@cosmicdrift/kumiko-framework/internal/row-level-security";
|
|
5
|
+
import { helpdeskReplyEntity, helpdeskRequestEntity } from "./entity.js";
|
|
6
|
+
// Data stored before the contact -> helpdesk rename stays under the old aggregate names. The old
|
|
7
|
+
// read tables are dropped in the apps, so the streams are folded straight from the event log.
|
|
8
|
+
export const LEGACY_CONTACT_REQUEST_ENTITY = "contact-request";
|
|
9
|
+
export const LEGACY_CONTACT_REPLY_ENTITY = "contact-reply";
|
|
10
|
+
const PII_DECRYPT_REASON = "helpdesk:legacy-contact-streams";
|
|
11
|
+
const ARCHIVED_BY = "helpdesk:legacy-contact";
|
|
12
|
+
const ARCHIVE_WRITE_REASON = "archives the legacy contact streams of an erased subject in the system tenant";
|
|
13
|
+
export const LEGACY_ARCHIVE_REASON = "legacy contact data erased";
|
|
14
|
+
const PII_FIELDS_BY_TYPE = {
|
|
15
|
+
[LEGACY_CONTACT_REQUEST_ENTITY]: collectPiiEncryptedFields(helpdeskRequestEntity),
|
|
16
|
+
[LEGACY_CONTACT_REPLY_ENTITY]: collectPiiEncryptedFields(helpdeskReplyEntity),
|
|
17
|
+
};
|
|
18
|
+
function isRecord(value) {
|
|
19
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
20
|
+
}
|
|
21
|
+
async function readableFields(aggregateType, fields, onlyFields) {
|
|
22
|
+
const piiFields = PII_FIELDS_BY_TYPE[aggregateType] ?? [];
|
|
23
|
+
const kms = configuredPiiSubjectKms();
|
|
24
|
+
if (kms === undefined)
|
|
25
|
+
return fields;
|
|
26
|
+
return decryptPiiFieldValues(fields, onlyFields ? piiFields.filter((name) => onlyFields.includes(name)) : piiFields, kms, { requestId: PII_DECRYPT_REASON });
|
|
27
|
+
}
|
|
28
|
+
function hasUnreadablePersonalField(aggregateType, fields) {
|
|
29
|
+
return (PII_FIELDS_BY_TYPE[aggregateType] ?? []).some((name) => {
|
|
30
|
+
const value = fields[name];
|
|
31
|
+
return value === PII_ERASED_SENTINEL || isPiiCiphertext(value);
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
// Folds created and updated events per aggregate; a deleted or forgotten stream is gone for good.
|
|
35
|
+
async function foldLegacyStreams(runner, aggregateType) {
|
|
36
|
+
const folded = new Map();
|
|
37
|
+
const gone = new Set();
|
|
38
|
+
for await (const event of streamAllEventsByType(runner, aggregateType)) {
|
|
39
|
+
const id = event.aggregateId;
|
|
40
|
+
if (gone.has(id))
|
|
41
|
+
continue;
|
|
42
|
+
switch (event.type) {
|
|
43
|
+
case `${aggregateType}.created`:
|
|
44
|
+
folded.set(id, { ...event.payload });
|
|
45
|
+
break;
|
|
46
|
+
case `${aggregateType}.updated`: {
|
|
47
|
+
const current = folded.get(id);
|
|
48
|
+
const changes = event.payload["changes"];
|
|
49
|
+
if (current && isRecord(changes))
|
|
50
|
+
Object.assign(current, changes);
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
case `${aggregateType}.deleted`:
|
|
54
|
+
case `${aggregateType}.forgotten`:
|
|
55
|
+
folded.delete(id);
|
|
56
|
+
gone.add(id);
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return folded;
|
|
61
|
+
}
|
|
62
|
+
// Archived streams are skipped, so an erased aggregate is never read again. The archive lookup
|
|
63
|
+
// is per aggregate (the framework has no bulk query for it), after the candidate filter.
|
|
64
|
+
export async function readLegacyAggregates(db, aggregateType, options = {}) {
|
|
65
|
+
const runner = systemTenantReadRunner(db);
|
|
66
|
+
const aggregates = [];
|
|
67
|
+
for (const [id, raw] of await foldLegacyStreams(runner, aggregateType)) {
|
|
68
|
+
if (options.isCandidate && !options.isCandidate(raw))
|
|
69
|
+
continue;
|
|
70
|
+
if (await isStreamArchived(runner, SYSTEM_TENANT_ID, id))
|
|
71
|
+
continue;
|
|
72
|
+
if (options.decrypt === false) {
|
|
73
|
+
aggregates.push({ id, fields: raw, erased: false });
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
const fields = await readableFields(aggregateType, raw);
|
|
77
|
+
aggregates.push({ id, fields, erased: hasUnreadablePersonalField(aggregateType, fields) });
|
|
78
|
+
}
|
|
79
|
+
return aggregates;
|
|
80
|
+
}
|
|
81
|
+
// A signed-in request carries the plaintext user id; an anonymous one is matched by the email,
|
|
82
|
+
// which is the only field decrypted for the rest. Only the matches are fully decrypted.
|
|
83
|
+
export async function findLegacyRequestsOfSubject(db, subject) {
|
|
84
|
+
const runner = systemTenantReadRunner(db);
|
|
85
|
+
const matches = [];
|
|
86
|
+
for (const [id, raw] of await foldLegacyStreams(runner, LEGACY_CONTACT_REQUEST_ENTITY)) {
|
|
87
|
+
if (!(await isSubjectRequest(raw, subject)))
|
|
88
|
+
continue;
|
|
89
|
+
if (await isStreamArchived(runner, SYSTEM_TENANT_ID, id))
|
|
90
|
+
continue;
|
|
91
|
+
const fields = await readableFields(LEGACY_CONTACT_REQUEST_ENTITY, raw);
|
|
92
|
+
matches.push({
|
|
93
|
+
id,
|
|
94
|
+
fields,
|
|
95
|
+
erased: hasUnreadablePersonalField(LEGACY_CONTACT_REQUEST_ENTITY, fields),
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
return matches;
|
|
99
|
+
}
|
|
100
|
+
async function isSubjectRequest(raw, subject) {
|
|
101
|
+
if (raw["reporterUserId"] === subject.userId)
|
|
102
|
+
return true;
|
|
103
|
+
if (subject.email === undefined)
|
|
104
|
+
return false;
|
|
105
|
+
const { email } = await readableFields(LEGACY_CONTACT_REQUEST_ENTITY, { email: raw["email"] }, [
|
|
106
|
+
"email",
|
|
107
|
+
]);
|
|
108
|
+
return typeof email === "string" && email.toLowerCase() === subject.email;
|
|
109
|
+
}
|
|
110
|
+
export async function archiveLegacyStream(db, aggregateType, aggregateId) {
|
|
111
|
+
await archiveStream(systemTenantWriteRunner(db, ARCHIVE_WRITE_REASON), {
|
|
112
|
+
tenantId: SYSTEM_TENANT_ID,
|
|
113
|
+
aggregateId,
|
|
114
|
+
aggregateType,
|
|
115
|
+
archivedBy: ARCHIVED_BY,
|
|
116
|
+
reason: LEGACY_ARCHIVE_REASON,
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
export function repliesOf(replies, requestId) {
|
|
120
|
+
return replies.filter((reply) => reply.fields["requestId"] === requestId);
|
|
121
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { UserDataDeleteHook, UserDataExportHook } from "@cosmicdrift/kumiko-framework/engine";
|
|
2
|
+
import { LEGACY_CONTACT_REPLY_ENTITY, LEGACY_CONTACT_REQUEST_ENTITY } from "./legacy-contact-streams.ts";
|
|
3
|
+
export { LEGACY_CONTACT_REPLY_ENTITY, LEGACY_CONTACT_REQUEST_ENTITY };
|
|
4
|
+
export declare const legacyContactExportHook: UserDataExportHook;
|
|
5
|
+
export declare const legacyContactDeleteHook: UserDataDeleteHook;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { resolveVerifiedUserEmail } from "../user/index.js";
|
|
2
|
+
import { eraseLegacyRequest } from "./legacy-contact-erasure.js";
|
|
3
|
+
import { findLegacyRequestsOfSubject, LEGACY_CONTACT_REPLY_ENTITY, LEGACY_CONTACT_REQUEST_ENTITY, readLegacyAggregates, repliesOf, } from "./legacy-contact-streams.js";
|
|
4
|
+
import { findAttachments, purgeAttachments } from "./user-data-hooks.js";
|
|
5
|
+
export { LEGACY_CONTACT_REPLY_ENTITY, LEGACY_CONTACT_REQUEST_ENTITY };
|
|
6
|
+
const PII_DECRYPT_REASON = "helpdesk:legacy-contact-user-data";
|
|
7
|
+
async function findLegacyRequests(ctx) {
|
|
8
|
+
const email = (await resolveVerifiedUserEmail(ctx, PII_DECRYPT_REASON))?.toLowerCase();
|
|
9
|
+
return findLegacyRequestsOfSubject(ctx.db, { userId: ctx.userId, email });
|
|
10
|
+
}
|
|
11
|
+
// Replies are linked by the plaintext request id, so only those of the matched requests are read.
|
|
12
|
+
function repliesOfRequests(ctx, requests) {
|
|
13
|
+
const requestIds = new Set(requests.map((request) => request.id));
|
|
14
|
+
return readLegacyAggregates(ctx.db, LEGACY_CONTACT_REPLY_ENTITY, {
|
|
15
|
+
isCandidate: (raw) => typeof raw["requestId"] === "string" && requestIds.has(raw["requestId"]),
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
export const legacyContactExportHook = async (ctx) => {
|
|
19
|
+
const requests = (await findLegacyRequests(ctx)).filter((request) => !request.erased);
|
|
20
|
+
if (requests.length === 0)
|
|
21
|
+
return null;
|
|
22
|
+
const replies = await repliesOfRequests(ctx, requests);
|
|
23
|
+
const rows = [];
|
|
24
|
+
for (const request of requests) {
|
|
25
|
+
const { fields } = request;
|
|
26
|
+
rows.push({
|
|
27
|
+
kind: fields["kind"],
|
|
28
|
+
status: fields["status"],
|
|
29
|
+
source: fields["source"],
|
|
30
|
+
subject: fields["subject"],
|
|
31
|
+
message: fields["message"],
|
|
32
|
+
name: fields["name"],
|
|
33
|
+
email: fields["email"],
|
|
34
|
+
phone: fields["phone"],
|
|
35
|
+
page: fields["page"],
|
|
36
|
+
submittedAt: String(fields["submittedAt"]),
|
|
37
|
+
attachments: (await findAttachments(ctx, LEGACY_CONTACT_REQUEST_ENTITY, request.id)).map((file) => file.fileName),
|
|
38
|
+
replies: repliesOf(replies, request.id)
|
|
39
|
+
.filter((reply) => !reply.erased)
|
|
40
|
+
.map((reply) => ({
|
|
41
|
+
message: reply.fields["message"],
|
|
42
|
+
authorName: reply.fields["authorName"],
|
|
43
|
+
sentAt: String(reply.fields["sentAt"]),
|
|
44
|
+
})),
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
return { entity: LEGACY_CONTACT_REQUEST_ENTITY, rows };
|
|
48
|
+
};
|
|
49
|
+
export const legacyContactDeleteHook = async (ctx) => {
|
|
50
|
+
const requests = await findLegacyRequests(ctx);
|
|
51
|
+
// skip: user has no pre-rename contact data to erase
|
|
52
|
+
if (requests.length === 0)
|
|
53
|
+
return;
|
|
54
|
+
const replies = await repliesOfRequests(ctx, requests);
|
|
55
|
+
for (const request of requests) {
|
|
56
|
+
await eraseLegacyRequest({
|
|
57
|
+
db: ctx.db,
|
|
58
|
+
erasedBy: ctx.userId,
|
|
59
|
+
purgeAttachments: (entity, id) => purgeAttachments(ctx, entity, id),
|
|
60
|
+
}, request, repliesOf(replies, request.id));
|
|
61
|
+
}
|
|
62
|
+
};
|
package/dist/helpdesk/lib.d.ts
CHANGED
|
@@ -4,7 +4,6 @@ import { HelpdeskErrors, type HelpdeskPhoneMode, type HelpdeskReplyChannels } fr
|
|
|
4
4
|
export declare const IN_APP_FEATURE = "channel-in-app";
|
|
5
5
|
export declare const TELEGRAM_FEATURE = "channel-telegram";
|
|
6
6
|
export declare const HELPDESK_CROSS_TENANT_REASON = "helpdesk is platform-wide (systemScope)";
|
|
7
|
-
export declare const SYSTEM_ADMIN_ROLE = "SystemAdmin";
|
|
8
7
|
export declare const adminAccess: {
|
|
9
8
|
readonly roles: readonly string[];
|
|
10
9
|
};
|
|
@@ -65,6 +64,12 @@ export declare const replyExecutor: import("@cosmicdrift/kumiko-types/event-stor
|
|
|
65
64
|
readonly requestId: string;
|
|
66
65
|
readonly sentAt: Temporal.Instant;
|
|
67
66
|
}>;
|
|
67
|
+
export declare function listAllPages<Row>(fetchPage: (page: {
|
|
68
|
+
limit: number;
|
|
69
|
+
offset: number;
|
|
70
|
+
}) => Promise<{
|
|
71
|
+
rows: readonly Row[];
|
|
72
|
+
}>): Promise<Row[]>;
|
|
68
73
|
export declare function listRepliesOf(db: TenantDb, requestId: string): Promise<{
|
|
69
74
|
readonly id: string;
|
|
70
75
|
readonly tenantId: string;
|
|
@@ -95,6 +100,7 @@ export type UserLabel = {
|
|
|
95
100
|
};
|
|
96
101
|
export declare function loadUserLabel(db: TenantDb, userId: string): Promise<UserLabel | null>;
|
|
97
102
|
export declare function sendBestEffort(ctx: Pick<HandlerContext, "notify" | "obs">, label: string, send: (notify: NonNullable<HandlerContext["notify"]>) => Promise<unknown>): Promise<void>;
|
|
103
|
+
export declare function forwardHelpdeskRequest(ctx: Pick<HandlerContext, "dispatch">, requestId: string): Promise<void>;
|
|
98
104
|
export declare function pickReplyChannels(ctx: Pick<HandlerContext, "hasFeature">, reporterUserId: string | null | undefined): Promise<HelpdeskReplyChannels>;
|
|
99
105
|
export declare function phoneProblem(mode: HelpdeskPhoneMode, phone: string | undefined): (typeof HelpdeskErrors)[keyof typeof HelpdeskErrors] | null;
|
|
100
106
|
export declare function loadTenantName(db: TenantDb, tenantId: string): Promise<string | null>;
|
package/dist/helpdesk/lib.js
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
|
+
import { ROLES } from "@cosmicdrift/kumiko-framework/auth";
|
|
1
2
|
import { createEventStoreExecutor, fetchOne, selectMany, } from "@cosmicdrift/kumiko-framework/db";
|
|
2
3
|
import { access, createSystemUser, SYSTEM_TENANT_ID, } from "@cosmicdrift/kumiko-framework/engine";
|
|
3
|
-
import { InternalError } from "@cosmicdrift/kumiko-framework/errors";
|
|
4
4
|
import { propertyOf } from "@cosmicdrift/kumiko-types/type-guards";
|
|
5
|
-
import { decryptStoredPii } from "../shared/index.js";
|
|
5
|
+
import { acknowledgedSystemDb, decryptStoredPii, sendBestEffort as sendSharedBestEffort, } from "../shared/index.js";
|
|
6
6
|
import { tenantTable } from "../tenant/index.js";
|
|
7
7
|
import { TierEngineQueries } from "../tier-engine/index.js";
|
|
8
8
|
import { USER_STATUS, userTable } from "../user/index.js";
|
|
9
9
|
import { helpdeskReplyEntity, helpdeskReplyTable, helpdeskRequestEntity, helpdeskRequestTable, } from "./entity.js";
|
|
10
|
-
import { HELPDESK_REPLY_CHANNELS, HELPDESK_REPLY_ENTITY, HELPDESK_REQUEST_ENTITY, HelpdeskErrors, } from "./web/constants.js";
|
|
10
|
+
import { HELPDESK_REPLY_CHANNELS, HELPDESK_REPLY_ENTITY, HELPDESK_REQUEST_ENTITY, HelpdeskErrors, HelpdeskHandlers, } from "./web/constants.js";
|
|
11
11
|
export const IN_APP_FEATURE = "channel-in-app";
|
|
12
12
|
export const TELEGRAM_FEATURE = "channel-telegram";
|
|
13
13
|
export const HELPDESK_CROSS_TENANT_REASON = "helpdesk is platform-wide (systemScope)";
|
|
14
|
-
export const SYSTEM_ADMIN_ROLE = "SystemAdmin";
|
|
15
14
|
const PII_DECRYPT_REASON = "helpdesk:user-lookup";
|
|
16
15
|
export const adminAccess = { roles: access.systemAdmin };
|
|
17
16
|
export const internalAccess = { roles: access.system };
|
|
@@ -21,33 +20,37 @@ export const requestExecutor = createEventStoreExecutor(helpdeskRequestTable, he
|
|
|
21
20
|
export const replyExecutor = createEventStoreExecutor(helpdeskReplyTable, helpdeskReplyEntity, {
|
|
22
21
|
entityName: HELPDESK_REPLY_ENTITY,
|
|
23
22
|
});
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
// Equals the executor's MAX_LIST_LIMIT, so every page is filled until the last one.
|
|
24
|
+
const LIST_PAGE_SIZE = 200;
|
|
25
|
+
export async function listAllPages(fetchPage) {
|
|
26
|
+
const all = [];
|
|
27
|
+
for (;;) {
|
|
28
|
+
const { rows } = await fetchPage({ limit: LIST_PAGE_SIZE, offset: all.length });
|
|
29
|
+
all.push(...rows);
|
|
30
|
+
if (rows.length < LIST_PAGE_SIZE)
|
|
31
|
+
return all;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
export function listRepliesOf(db, requestId) {
|
|
35
|
+
return listAllPages((page) => replyExecutor.list({
|
|
27
36
|
filter: { field: "requestId", op: "eq", value: requestId },
|
|
28
37
|
sort: "sentAt",
|
|
29
38
|
sortDirection: "asc",
|
|
30
|
-
|
|
31
|
-
}, platformActor(), db);
|
|
32
|
-
return found.rows;
|
|
39
|
+
...page,
|
|
40
|
+
}, platformActor(), db));
|
|
33
41
|
}
|
|
34
42
|
export function normalizeEmail(email) {
|
|
35
43
|
return email.toLowerCase();
|
|
36
44
|
}
|
|
37
45
|
export function helpdeskDb(ctx) {
|
|
38
|
-
|
|
39
|
-
throw new InternalError({
|
|
40
|
-
message: "helpdesk requires ctx.systemDb — is r.systemScope() set on the feature?",
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
return ctx.systemDb.acknowledgeCrossTenant(HELPDESK_CROSS_TENANT_REASON);
|
|
46
|
+
return acknowledgedSystemDb(ctx, "helpdesk", HELPDESK_CROSS_TENANT_REASON);
|
|
44
47
|
}
|
|
45
48
|
// Requests and replies are systemStream rows, so every write targets the system tenant's stream.
|
|
46
49
|
export function platformActor() {
|
|
47
50
|
return createSystemUser(SYSTEM_TENANT_ID);
|
|
48
51
|
}
|
|
49
52
|
export async function listSystemAdminIds(db) {
|
|
50
|
-
const rows = await selectMany(db, userTable, { isDeleted: false, status: USER_STATUS.Active, roles:
|
|
53
|
+
const rows = await selectMany(db, userTable, { isDeleted: false, status: USER_STATUS.Active, roles: ROLES.SystemAdmin }, { fields: ["id"], orderBy: { col: "id" } });
|
|
51
54
|
return rows.map((r) => r.id);
|
|
52
55
|
}
|
|
53
56
|
export async function loadUserLabel(db, userId) {
|
|
@@ -59,17 +62,14 @@ export async function loadUserLabel(db, userId) {
|
|
|
59
62
|
return { name, email };
|
|
60
63
|
}
|
|
61
64
|
export async function sendBestEffort(ctx, label, send) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
error: err instanceof Error ? err.message : String(err),
|
|
71
|
-
});
|
|
72
|
-
}
|
|
65
|
+
return sendSharedBestEffort(ctx, `[helpdesk] ${label} failed`, send);
|
|
66
|
+
}
|
|
67
|
+
export async function forwardHelpdeskRequest(ctx, requestId) {
|
|
68
|
+
const forwarded = await ctx.dispatch.writeAs(platformActor(), HelpdeskHandlers.forwardRequest, {
|
|
69
|
+
requestId,
|
|
70
|
+
});
|
|
71
|
+
if (!forwarded.isSuccess)
|
|
72
|
+
throw new Error(forwarded.error.message);
|
|
73
73
|
}
|
|
74
74
|
export async function pickReplyChannels(ctx, reporterUserId) {
|
|
75
75
|
const hasInApp = reporterUserId && (await ctx.hasFeature(IN_APP_FEATURE));
|
|
@@ -96,7 +96,7 @@ export async function loadTenantPlan(ctx, tenantId) {
|
|
|
96
96
|
if (ctx.registry.getQueryHandler(TierEngineQueries.getTenantTier) === undefined)
|
|
97
97
|
return null;
|
|
98
98
|
try {
|
|
99
|
-
const assignment = await ctx.dispatch.queryAs(createSystemUser(SYSTEM_TENANT_ID, [
|
|
99
|
+
const assignment = await ctx.dispatch.queryAs(createSystemUser(SYSTEM_TENANT_ID, [ROLES.SystemAdmin]), TierEngineQueries.getTenantTier, { tenantId });
|
|
100
100
|
const tier = propertyOf(assignment, "tier");
|
|
101
101
|
return typeof tier === "string" && tier !== "" ? planDisplayName(tier) : null;
|
|
102
102
|
}
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
-
import type { UserDataDeleteHook, UserDataExportHook } from "@cosmicdrift/kumiko-framework/engine";
|
|
1
|
+
import type { UserDataDeleteHook, UserDataExportHook, UserDataHookCtx } from "@cosmicdrift/kumiko-framework/engine";
|
|
2
|
+
export declare function findAttachments(ctx: Pick<UserDataHookCtx, "db">, entity: string, id: string): Promise<readonly {
|
|
3
|
+
id: string;
|
|
4
|
+
storageKey: string;
|
|
5
|
+
fileName: string;
|
|
6
|
+
}[]>;
|
|
7
|
+
export type AttachmentByteDeleter = (storageKey: string) => Promise<readonly string[]>;
|
|
8
|
+
export declare function purgeAttachmentsWith(ctx: Pick<UserDataHookCtx, "db">, entity: string, id: string, resolveByteDeleter: () => Promise<AttachmentByteDeleter>): Promise<void>;
|
|
9
|
+
export declare function purgeAttachments(ctx: UserDataHookCtx, entity: string, id: string): Promise<void>;
|
|
10
|
+
export declare function eraseNotesOnRequest(ctx: Pick<UserDataHookCtx, "db">, entity: string, id: string, erasedBy: string): Promise<void>;
|
|
2
11
|
export declare const helpdeskExportHook: UserDataExportHook;
|
|
3
12
|
export declare const helpdeskDeleteHook: UserDataDeleteHook;
|