@cosmicdrift/kumiko-samples 0.413.1 → 0.415.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/packages/bundled-features/package.json +16 -1
- package/packages/bundled-features/src/admin-shell/changes.json +6 -0
- package/packages/bundled-features/src/admin-shell/feature.ts +8 -7
- package/packages/bundled-features/src/agent-tools/agent-doc-lint.ts +5 -1
- package/packages/bundled-features/src/agent-tools/agent-manifest.ts +36 -27
- package/packages/bundled-features/src/agent-tools/api-docs/collect-events.ts +8 -1
- package/packages/bundled-features/src/agent-tools/api-docs/collect.ts +3 -2
- package/packages/bundled-features/src/agent-tools/api-docs/generate.ts +6 -0
- package/packages/bundled-features/src/agent-tools/api-docs/index.ts +1 -0
- package/packages/bundled-features/src/agent-tools/api-docs/problems.ts +38 -1
- package/packages/bundled-features/src/agent-tools/api-docs/render-openapi.ts +1 -0
- package/packages/bundled-features/src/agent-tools/api-docs/resolve-config.ts +17 -0
- package/packages/bundled-features/src/agent-tools/api-docs/scope-slug-collisions.ts +17 -0
- package/packages/bundled-features/src/agent-tools/api-docs/translation-gaps.ts +42 -0
- package/packages/bundled-features/src/agent-tools/api-docs/webhook-example-problems.ts +30 -0
- package/packages/bundled-features/src/agent-tools/changes.json +12 -0
- package/packages/bundled-features/src/agent-tools/index.ts +1 -0
- package/packages/bundled-features/src/agent-tools/labels.ts +19 -6
- package/packages/bundled-features/src/agent-tools/tool-catalog.ts +18 -7
- package/packages/bundled-features/src/agent-tools/tool-dispatch.ts +14 -1
- package/packages/bundled-features/src/agent-tools/types.ts +4 -0
- package/packages/bundled-features/src/audit/event-classification.ts +6 -0
- package/packages/bundled-features/src/audit/web/i18n.ts +1 -0
- package/packages/bundled-features/src/auth-email-password/changes.json +18 -0
- package/packages/bundled-features/src/auth-email-password/errors.ts +0 -13
- package/packages/bundled-features/src/auth-email-password/handlers/invite-signup-complete.write.ts +147 -121
- package/packages/bundled-features/src/auth-email-password/handlers/login-options.query.ts +1 -1
- package/packages/bundled-features/src/auth-email-password/handlers/request-account-unlock.write.ts +1 -1
- package/packages/bundled-features/src/auth-email-password/handlers/request-email-verification.write.ts +0 -1
- package/packages/bundled-features/src/auth-email-password/handlers/request-password-reset.write.ts +0 -1
- package/packages/bundled-features/src/auth-email-password/handlers/self-registration-status.query.ts +1 -1
- package/packages/bundled-features/src/auth-email-password/reset-token.ts +0 -2
- package/packages/bundled-features/src/auth-email-password/seeding.ts +39 -7
- package/packages/bundled-features/src/auth-email-password/signup-token-store.ts +2 -3
- package/packages/bundled-features/src/auth-email-password/unlock-token.ts +0 -2
- package/packages/bundled-features/src/auth-email-password/verification-token.ts +0 -2
- package/packages/bundled-features/src/auth-email-password/web/auth-form-primitives.tsx +2 -2
- package/packages/bundled-features/src/auth-email-password/web/auth-gate.tsx +2 -2
- package/packages/bundled-features/src/auth-email-password/web/auth-redirect.ts +5 -0
- package/packages/bundled-features/src/auth-email-password/web/forgot-password-screen.tsx +1 -6
- package/packages/bundled-features/src/auth-email-password/web/invite-accept-screen.tsx +1 -1
- package/packages/bundled-features/src/auth-email-password/web/return-path.ts +2 -1
- package/packages/bundled-features/src/auth-email-password/web/session.tsx +12 -13
- package/packages/bundled-features/src/auth-email-password/web/signup-screen.tsx +1 -6
- package/packages/bundled-features/src/auth-email-password/web/static-account.ts +6 -1
- package/packages/bundled-features/src/auth-email-password/web/tenant-switcher.tsx +1 -1
- package/packages/bundled-features/src/auth-email-password/web/token-confirm-screen.tsx +4 -5
- package/packages/bundled-features/src/auth-email-password/web/user-menu.tsx +1 -1
- package/packages/bundled-features/src/auth-mfa/changes.json +6 -0
- package/packages/bundled-features/src/auth-mfa/web/mfa-code-or-recovery-field.tsx +17 -1
- package/packages/bundled-features/src/auth-mfa/web/mfa-disable-dialog.tsx +1 -1
- package/packages/bundled-features/src/auth-mfa/web/mfa-regenerate-recovery-dialog.tsx +1 -1
- package/packages/bundled-features/src/auth-mfa/web/mfa-setup-preauth-screen.tsx +1 -1
- package/packages/bundled-features/src/auth-mfa/web/mfa-verify-screen.tsx +16 -47
- package/packages/bundled-features/src/auth-mfa-user-data/index.ts +5 -6
- package/packages/bundled-features/src/billing-foundation/aggregate-id.ts +0 -4
- package/packages/bundled-features/src/billing-foundation/changes.json +61 -0
- package/packages/bundled-features/src/billing-foundation/checkout-core.ts +19 -1
- package/packages/bundled-features/src/billing-foundation/checkout-ledger.ts +67 -0
- package/packages/bundled-features/src/billing-foundation/consumer-protection/consent-gate.ts +2 -1
- package/packages/bundled-features/src/billing-foundation/consumer-protection/consent-text.ts +49 -2
- package/packages/bundled-features/src/billing-foundation/consumer-protection/termination-open-cancels.ts +5 -0
- package/packages/bundled-features/src/billing-foundation/consumer-protection/termination-provider-timeout.ts +23 -0
- package/packages/bundled-features/src/billing-foundation/consumer-protection/termination-record.ts +12 -7
- package/packages/bundled-features/src/billing-foundation/consumer-protection/termination-revoke.ts +1 -1
- package/packages/bundled-features/src/billing-foundation/events.ts +51 -10
- package/packages/bundled-features/src/billing-foundation/feature.ts +15 -1
- package/packages/bundled-features/src/billing-foundation/handlers/billing-plans.query.ts +47 -14
- package/packages/bundled-features/src/billing-foundation/handlers/create-checkout-session.write.ts +9 -1
- package/packages/bundled-features/src/billing-foundation/handlers/process-event.write.ts +183 -17
- package/packages/bundled-features/src/billing-foundation/handlers/process-payment-event.write.ts +35 -10
- package/packages/bundled-features/src/billing-foundation/handlers/record-checkout-opened.write.ts +25 -0
- package/packages/bundled-features/src/billing-foundation/handlers/start-plan-checkout.write.ts +9 -1
- package/packages/bundled-features/src/billing-foundation/handlers/switch-plan.write.ts +16 -4
- package/packages/bundled-features/src/billing-foundation/i18n.ts +3 -0
- package/packages/bundled-features/src/billing-foundation/pending-plan-switch.ts +80 -0
- package/packages/bundled-features/src/billing-foundation/scrub-raw-payload-headers.ts +50 -0
- package/packages/bundled-features/src/billing-foundation/types.ts +47 -30
- package/packages/bundled-features/src/billing-foundation/validate-options.ts +18 -0
- package/packages/bundled-features/src/billing-foundation/web/billing-plans-panel.tsx +10 -5
- package/packages/bundled-features/src/billing-foundation/web/cancel-contract-dialog.tsx +1 -1
- package/packages/bundled-features/src/billing-foundation/web/checkout-consent-dialog.tsx +1 -1
- package/packages/bundled-features/src/billing-foundation/web/constants.ts +5 -2
- package/packages/bundled-features/src/billing-foundation/web/plan-switch-confirm-dialog.tsx +1 -1
- package/packages/bundled-features/src/billing-foundation/webhook-handler.ts +65 -17
- package/packages/bundled-features/src/cap-counter/aggregate-id.ts +0 -2
- package/packages/bundled-features/src/cap-counter/changes.json +6 -0
- package/packages/bundled-features/src/cap-counter/stock-cap-guard.ts +19 -4
- package/packages/bundled-features/src/cap-overview/changes.json +6 -0
- package/packages/bundled-features/src/cap-overview/handlers/tenant-caps-list.query.ts +22 -6
- package/packages/bundled-features/src/cap-overview/i18n.ts +1 -0
- package/packages/bundled-features/src/cap-overview/index.ts +1 -0
- package/packages/bundled-features/src/cap-overview/types.ts +11 -1
- package/packages/bundled-features/src/cap-overview/web/cap-cards-panel.tsx +6 -2
- package/packages/bundled-features/src/cap-overview/web/cap-usage-bar.tsx +10 -1
- package/packages/bundled-features/src/cap-overview/web/usage-math.ts +5 -0
- package/packages/bundled-features/src/channel-in-app/changes.json +6 -0
- package/packages/bundled-features/src/channel-in-app/handlers/read-state-by-keys.query.ts +2 -2
- package/packages/bundled-features/src/channel-whatsapp/aggregate-id.ts +29 -0
- package/packages/bundled-features/src/channel-whatsapp/changes.json +32 -0
- package/packages/bundled-features/src/channel-whatsapp/constants.ts +46 -0
- package/packages/bundled-features/src/channel-whatsapp/events.ts +94 -0
- package/packages/bundled-features/src/channel-whatsapp/feature.ts +72 -0
- package/packages/bundled-features/src/channel-whatsapp/graph-client.ts +398 -0
- package/packages/bundled-features/src/channel-whatsapp/in-memory-meta.ts +300 -0
- package/packages/bundled-features/src/channel-whatsapp/inbound-handlers.ts +210 -0
- package/packages/bundled-features/src/channel-whatsapp/index.ts +66 -0
- package/packages/bundled-features/src/channel-whatsapp/meta-signature.ts +26 -0
- package/packages/bundled-features/src/channel-whatsapp/options.ts +149 -0
- package/packages/bundled-features/src/channel-whatsapp/pii.ts +109 -0
- package/packages/bundled-features/src/channel-whatsapp/webhook-normalize.ts +247 -0
- package/packages/bundled-features/src/channel-whatsapp/webhook-routes.ts +185 -0
- package/packages/bundled-features/src/compliance-profiles/changes.json +5 -0
- package/packages/bundled-features/src/compliance-profiles/handlers/set-profile.write.ts +2 -0
- package/packages/bundled-features/src/compliance-profiles/handlers/sub-processors.query.ts +1 -1
- package/packages/bundled-features/src/config/changes.json +12 -0
- package/packages/bundled-features/src/config/handlers/set.write.ts +7 -0
- package/packages/bundled-features/src/config/handlers/values.query.ts +8 -1
- package/packages/bundled-features/src/config/index.ts +1 -0
- package/packages/bundled-features/src/config/read-redaction.ts +6 -3
- package/packages/bundled-features/src/config/table.ts +1 -0
- package/packages/bundled-features/src/config/write-helpers.ts +3 -2
- package/packages/bundled-features/src/crypto-shredding/changes.json +18 -0
- package/packages/bundled-features/src/crypto-shredding/constants.ts +2 -0
- package/packages/bundled-features/src/crypto-shredding/handlers/forget-subject.write.ts +38 -18
- package/packages/bundled-features/src/crypto-shredding/index.ts +4 -0
- package/packages/bundled-features/src/crypto-shredding/subject-forget-after-delete-hook.ts +49 -0
- package/packages/bundled-features/src/custom-fields/aggregate-id.ts +0 -1
- package/packages/bundled-features/src/custom-fields/entity.ts +1 -0
- package/packages/bundled-features/src/custom-fields/wire-for-entity.ts +0 -1
- package/packages/bundled-features/src/data-retention/changes.json +12 -0
- package/packages/bundled-features/src/data-retention/erase-notes-of-deleted-row.ts +23 -0
- package/packages/bundled-features/src/data-retention/feature.ts +2 -5
- package/packages/bundled-features/src/data-retention/run-retention-cleanup.ts +38 -18
- package/packages/bundled-features/src/data-retention/tenant-destruction-hold.ts +9 -0
- package/packages/bundled-features/src/delivery/attempt-log-factory.ts +11 -0
- package/packages/bundled-features/src/delivery/attempt-log.ts +3 -3
- package/packages/bundled-features/src/delivery/changes.json +12 -0
- package/packages/bundled-features/src/delivery/channel-context.ts +6 -3
- package/packages/bundled-features/src/delivery/db/queries/preferences.ts +0 -1
- package/packages/bundled-features/src/delivery/delivery-service.ts +3 -0
- package/packages/bundled-features/src/delivery/feature.ts +4 -13
- package/packages/bundled-features/src/delivery/handlers/opted-in-user-ids.query.ts +54 -0
- package/packages/bundled-features/src/delivery/handlers/preferences.query.ts +2 -20
- package/packages/bundled-features/src/delivery/handlers/resubscribe-user.write.ts +2 -25
- package/packages/bundled-features/src/delivery/handlers/unsubscribe-page-chrome.query.ts +2 -0
- package/packages/bundled-features/src/delivery/handlers/unsubscribe-user.write.ts +2 -27
- package/packages/bundled-features/src/delivery/index.ts +3 -1
- package/packages/bundled-features/src/delivery/options.ts +11 -0
- package/packages/bundled-features/src/delivery/preference-rows.ts +33 -0
- package/packages/bundled-features/src/delivery/set-preference-enabled.ts +40 -0
- package/packages/bundled-features/src/delivery/testing.ts +3 -1
- package/packages/bundled-features/src/delivery/types.ts +1 -0
- package/packages/bundled-features/src/delivery/unsubscribe-page.ts +7 -1
- package/packages/bundled-features/src/delivery/upsert-preference.ts +0 -1
- package/packages/bundled-features/src/delivery/web/public-names.ts +1 -0
- package/packages/bundled-features/src/derivatives-sharp/render.ts +9 -9
- package/packages/bundled-features/src/document-ingest-foundation/aggregate-id.ts +0 -1
- package/packages/bundled-features/src/document-ingest-foundation/append-missing-extract-event.ts +37 -25
- package/packages/bundled-features/src/document-ingest-foundation/changes.json +6 -0
- package/packages/bundled-features/src/document-ingest-foundation/feature.ts +1 -0
- package/packages/bundled-features/src/document-ingest-foundation/report-ingest-progress.ts +34 -14
- package/packages/bundled-features/src/documents/aggregate-id.ts +0 -2
- package/packages/bundled-features/src/documents/changes.json +24 -0
- package/packages/bundled-features/src/documents/constants.ts +10 -2
- package/packages/bundled-features/src/documents/ensure-link.ts +3 -4
- package/packages/bundled-features/src/documents/feature.ts +33 -6
- package/packages/bundled-features/src/documents/handlers/import.write.ts +2 -2
- package/packages/bundled-features/src/documents/queries/expiry-overview.query.ts +2 -1
- package/packages/bundled-features/src/documents/queries/for-record.query.ts +3 -4
- package/packages/bundled-features/src/documents/queries/list-page.ts +11 -3
- package/packages/bundled-features/src/documents/queries/overview.query.ts +2 -2
- package/packages/bundled-features/src/documents/screens.ts +8 -3
- package/packages/bundled-features/src/documents/tab.ts +1 -1
- package/packages/bundled-features/src/feature-toggles/toggle-sync-signal.ts +6 -3
- package/packages/bundled-features/src/file-derivatives/handlers/public-variant-by-file-ref.query.ts +1 -1
- package/packages/bundled-features/src/file-derivatives/handlers/public-variant.query.ts +1 -1
- package/packages/bundled-features/src/file-foundation/probe.ts +9 -3
- package/packages/bundled-features/src/file-foundation/read-file-ref-content.ts +24 -11
- package/packages/bundled-features/src/file-provider-inmemory/feature.ts +1 -1
- package/packages/bundled-features/src/file-provider-s3/changes.json +14 -0
- package/packages/bundled-features/src/file-provider-s3/env-feature.ts +1 -1
- package/packages/bundled-features/src/file-provider-s3/env-named-feature.ts +1 -1
- package/packages/bundled-features/src/file-provider-s3/env-schema.ts +24 -7
- package/packages/bundled-features/src/file-provider-s3/feature.ts +1 -1
- package/packages/bundled-features/src/file-provider-s3/index.ts +7 -1
- package/packages/bundled-features/src/file-provider-s3/lib/env-helper.ts +21 -13
- package/packages/bundled-features/src/file-provider-s3/lib/s3-provider.ts +8 -1
- package/packages/bundled-features/src/files/changes.json +7 -0
- package/packages/bundled-features/src/folders/aggregate-id.ts +0 -1
- package/packages/bundled-features/src/folders/web/folder-manager.tsx +6 -6
- package/packages/bundled-features/src/folders-user-data/index.ts +12 -14
- package/packages/bundled-features/src/form-draft/feature.ts +1 -0
- package/packages/bundled-features/src/helpdesk/changes.json +56 -0
- package/packages/bundled-features/src/helpdesk/entity.ts +4 -1
- package/packages/bundled-features/src/helpdesk/feature.ts +42 -0
- package/packages/bundled-features/src/helpdesk/handlers/access.ts +0 -10
- package/packages/bundled-features/src/helpdesk/handlers/attempts.ts +7 -14
- package/packages/bundled-features/src/helpdesk/handlers/challenge.query.ts +1 -2
- package/packages/bundled-features/src/helpdesk/handlers/reply.write.ts +5 -12
- package/packages/bundled-features/src/helpdesk/handlers/report.write.ts +4 -10
- package/packages/bundled-features/src/helpdesk/handlers/submit.write.ts +5 -12
- package/packages/bundled-features/src/helpdesk/index.ts +1 -0
- package/packages/bundled-features/src/helpdesk/legacy-contact-config.ts +61 -0
- package/packages/bundled-features/src/helpdesk/legacy-contact-erasure.ts +45 -0
- package/packages/bundled-features/src/helpdesk/legacy-contact-retention.ts +65 -0
- package/packages/bundled-features/src/helpdesk/legacy-contact-streams.ts +187 -0
- package/packages/bundled-features/src/helpdesk/legacy-contact-user-data.ts +84 -0
- package/packages/bundled-features/src/helpdesk/lib.ts +55 -37
- package/packages/bundled-features/src/helpdesk/user-data-hooks.ts +89 -48
- package/packages/bundled-features/src/helpdesk/web/constants.ts +0 -1
- package/packages/bundled-features/src/inbound-mail-foundation/account-health.ts +1 -1
- package/packages/bundled-features/src/inbound-mail-foundation/account-poll.ts +9 -2
- package/packages/bundled-features/src/inbound-mail-foundation/aggregate-id.ts +0 -2
- package/packages/bundled-features/src/inbound-mail-foundation/changes.json +54 -0
- package/packages/bundled-features/src/inbound-mail-foundation/constants.ts +6 -0
- package/packages/bundled-features/src/inbound-mail-foundation/content-refetch.ts +23 -2
- package/packages/bundled-features/src/inbound-mail-foundation/entities.ts +73 -15
- package/packages/bundled-features/src/inbound-mail-foundation/events.ts +24 -16
- package/packages/bundled-features/src/inbound-mail-foundation/feature.ts +3 -1
- package/packages/bundled-features/src/inbound-mail-foundation/handlers/account-address.ts +16 -2
- package/packages/bundled-features/src/inbound-mail-foundation/handlers/attach-message-content.write.ts +10 -3
- package/packages/bundled-features/src/inbound-mail-foundation/handlers/connect-account.write.ts +23 -9
- package/packages/bundled-features/src/inbound-mail-foundation/handlers/forget-message.write.ts +79 -0
- package/packages/bundled-features/src/inbound-mail-foundation/handlers/ingest-message-schema.ts +18 -5
- package/packages/bundled-features/src/inbound-mail-foundation/i18n.ts +3 -0
- package/packages/bundled-features/src/inbound-mail-foundation/index.ts +1 -0
- package/packages/bundled-features/src/inbound-mail-foundation/normalize-inbound-message.ts +22 -8
- package/packages/bundled-features/src/inbound-mail-foundation/oauth-access-token.ts +1 -1
- package/packages/bundled-features/src/inbound-mail-foundation/outbound-mail.ts +2 -0
- package/packages/bundled-features/src/inbound-mail-foundation/personal-address.ts +20 -0
- package/packages/bundled-features/src/inbound-mail-foundation/purge-messages.ts +54 -0
- package/packages/bundled-features/src/inbound-mail-foundation/quarantine.ts +15 -5
- package/packages/bundled-features/src/inbound-mail-foundation/retention-job.ts +1 -5
- package/packages/bundled-features/src/inbound-mail-foundation/retention-sweep.ts +21 -34
- package/packages/bundled-features/src/inbound-mail-foundation/sanitize-inbound-html.ts +2 -5
- package/packages/bundled-features/src/inbound-mail-foundation/send-from-account.ts +9 -1
- package/packages/bundled-features/src/inbound-mail-foundation/supervisor-ingest.ts +7 -1
- package/packages/bundled-features/src/inbound-mail-foundation/sync-account-now.ts +1 -1
- package/packages/bundled-features/src/inbound-mail-foundation/tenant-destroy-hook.ts +14 -17
- package/packages/bundled-features/src/inbound-mail-foundation/watch-supervisor.ts +1 -1
- package/packages/bundled-features/src/inbound-provider-imap/byte-budget.ts +80 -0
- package/packages/bundled-features/src/inbound-provider-imap/changes.json +13 -0
- package/packages/bundled-features/src/inbound-provider-imap/connect-mailbox.ts +8 -4
- package/packages/bundled-features/src/inbound-provider-imap/connect-my-mailbox.ts +23 -6
- package/packages/bundled-features/src/inbound-provider-imap/connect-target-rate-limit.ts +46 -0
- package/packages/bundled-features/src/inbound-provider-imap/download-batch.ts +47 -10
- package/packages/bundled-features/src/inbound-provider-imap/feature.ts +7 -4
- package/packages/bundled-features/src/inbound-provider-imap/fetch-content.ts +43 -29
- package/packages/bundled-features/src/inbound-provider-imap/i18n.ts +2 -2
- package/packages/bundled-features/src/inbound-provider-imap/parse-message.ts +14 -0
- package/packages/bundled-features/src/inbound-provider-imap/reconnect-mailbox.ts +5 -4
- package/packages/bundled-features/src/inbound-provider-imap/send-mail.ts +39 -7
- package/packages/bundled-features/src/inbound-provider-imap/smtp-client.ts +19 -4
- package/packages/bundled-features/src/inbound-provider-imap/watch-mailbox.ts +8 -23
- package/packages/bundled-features/src/inbound-provider-inmemory/feature.ts +1 -1
- package/packages/bundled-features/src/jobs/events.ts +10 -0
- package/packages/bundled-features/src/jobs/feature.ts +2 -0
- package/packages/bundled-features/src/jobs/handlers/consumer.write.ts +41 -16
- package/packages/bundled-features/src/jobs/web/constants.ts +4 -0
- package/packages/bundled-features/src/mail-foundation/changes.json +6 -0
- package/packages/bundled-features/src/mail-transport-inmemory/feature.ts +1 -1
- package/packages/bundled-features/src/mail-transport-smtp/feature.ts +3 -2
- package/packages/bundled-features/src/managed-pages/changes.json +12 -0
- package/packages/bundled-features/src/managed-pages/handlers/branding.query.ts +1 -1
- package/packages/bundled-features/src/managed-pages/handlers/by-slug.query.ts +1 -1
- package/packages/bundled-features/src/managed-pages/handlers/by-tenant-published.query.ts +1 -1
- package/packages/bundled-features/src/managed-pages/render-page-body.ts +18 -10
- package/packages/bundled-features/src/managed-pages/screens/page-screens.ts +18 -38
- package/packages/bundled-features/src/managed-pages/table.ts +1 -0
- package/packages/bundled-features/src/managed-pages/web/client-plugin.tsx +8 -6
- package/packages/bundled-features/src/managed-pages/web/constants.ts +8 -1
- package/packages/bundled-features/src/managed-pages/web/i18n.ts +11 -3
- package/packages/bundled-features/src/managed-pages/web/markdown-to-document.ts +1 -1
- package/packages/bundled-features/src/managed-pages/web/page-edit-draft.ts +108 -0
- package/packages/bundled-features/src/managed-pages/web/page-edit-screen.tsx +204 -0
- package/packages/bundled-features/src/managed-pages/web/page-settings-rail.tsx +117 -0
- package/packages/bundled-features/src/notes-history-user-data/index.ts +8 -14
- package/packages/bundled-features/src/personal-access-tokens/boot-rules.ts +5 -0
- package/packages/bundled-features/src/personal-access-tokens/handlers/create.write.ts +0 -1
- package/packages/bundled-features/src/personal-access-tokens/scope-events-check.ts +31 -5
- package/packages/bundled-features/src/presence/changes.json +6 -0
- package/packages/bundled-features/src/presence/handlers/list.query.ts +28 -11
- package/packages/bundled-features/src/presence/room.ts +21 -7
- package/packages/bundled-features/src/presence/store.ts +79 -21
- package/packages/bundled-features/src/readiness/changes.json +25 -0
- package/packages/bundled-features/src/readiness/handlers/latest-summary.query.ts +11 -6
- package/packages/bundled-features/src/readiness/handlers/run-probes.write.ts +35 -5
- package/packages/bundled-features/src/readiness/handlers/run-tone.ts +3 -2
- package/packages/bundled-features/src/readiness/handlers/status.query.ts +15 -1
- package/packages/bundled-features/src/readiness/probe-context.ts +11 -10
- package/packages/bundled-features/src/readiness/screens.ts +4 -4
- package/packages/bundled-features/src/readiness/visible-results.ts +5 -3
- package/packages/bundled-features/src/renderer-foundation/api.ts +6 -13
- package/packages/bundled-features/src/renderer-foundation/types.ts +2 -2
- package/packages/bundled-features/src/secrets/changes.json +7 -0
- package/packages/bundled-features/src/secrets/db/queries/read.ts +18 -4
- package/packages/bundled-features/src/secrets/handlers/list.query.ts +8 -2
- package/packages/bundled-features/src/secrets/secret-scope.ts +2 -3
- package/packages/bundled-features/src/secrets/secrets-context.ts +6 -4
- package/packages/bundled-features/src/secrets/write-gate.ts +4 -2
- package/packages/bundled-features/src/seo/handlers/seo-config.query.ts +1 -1
- package/packages/bundled-features/src/shared/acknowledged-system-db.ts +20 -0
- package/packages/bundled-features/src/shared/assert-billing-live.ts +9 -2
- package/packages/bundled-features/src/shared/changes.json +12 -0
- package/packages/bundled-features/src/shared/hmac-signature.ts +4 -2
- package/packages/bundled-features/src/shared/index.ts +7 -1
- package/packages/bundled-features/src/shared/normalize-email.ts +3 -0
- package/packages/bundled-features/src/shared/parent-visibility.ts +25 -1
- package/packages/bundled-features/src/shared/password-hashing.ts +0 -1
- package/packages/bundled-features/src/shared/price-env-shape.ts +1 -4
- package/packages/bundled-features/src/shared/register-user-data-hooks.ts +29 -0
- package/packages/bundled-features/src/shared/require-bootstrap-extension.ts +26 -0
- package/packages/bundled-features/src/shared/send-best-effort.ts +29 -0
- package/packages/bundled-features/src/shared/stream-tenant-backfill.ts +22 -1
- package/packages/bundled-features/src/shared/stream-tenant-derived-state.ts +31 -1
- package/packages/bundled-features/src/step-dispatcher/changes.json +18 -0
- package/packages/bundled-features/src/step-dispatcher/constants.ts +13 -0
- package/packages/bundled-features/src/step-dispatcher/deliver-dispatch-request.ts +50 -2
- package/packages/bundled-features/src/step-dispatcher/feature.ts +42 -1
- package/packages/bundled-features/src/step-dispatcher/mail-runner.ts +0 -1
- package/packages/bundled-features/src/step-dispatcher/sweep-abandoned.ts +61 -0
- package/packages/bundled-features/src/subscription-mollie/changes.json +7 -0
- package/packages/bundled-features/src/subscription-mollie/plugin-methods.ts +5 -3
- package/packages/bundled-features/src/subscription-mollie/verify-webhook.ts +5 -5
- package/packages/bundled-features/src/subscription-paddle/backfill-checkout-ledger.ts +161 -0
- package/packages/bundled-features/src/subscription-paddle/changes.json +19 -0
- package/packages/bundled-features/src/subscription-paddle/checkout-config.query.ts +1 -1
- package/packages/bundled-features/src/subscription-paddle/checkout-methods.ts +2 -8
- package/packages/bundled-features/src/subscription-paddle/constants.ts +1 -2
- package/packages/bundled-features/src/subscription-paddle/feature.ts +26 -24
- package/packages/bundled-features/src/subscription-paddle/ledger-backfill-marker.ts +70 -0
- package/packages/bundled-features/src/subscription-paddle/plan-switch-methods.ts +2 -8
- package/packages/bundled-features/src/subscription-paddle/redeliver-legacy-checkout.ts +57 -0
- package/packages/bundled-features/src/subscription-paddle/runtime.ts +13 -24
- package/packages/bundled-features/src/subscription-paddle/subscription-state.ts +1 -0
- package/packages/bundled-features/src/subscription-paddle/webhook-events.ts +68 -21
- package/packages/bundled-features/src/subscription-stripe/changes.json +13 -0
- package/packages/bundled-features/src/subscription-stripe/feature.ts +5 -0
- package/packages/bundled-features/src/subscription-stripe/plugin-methods.ts +6 -6
- package/packages/bundled-features/src/subscription-stripe/runtime.ts +8 -7
- package/packages/bundled-features/src/subscription-stripe/verify-webhook.ts +38 -6
- package/packages/bundled-features/src/tags/aggregate-id.ts +0 -1
- package/packages/bundled-features/src/tags/web/tag-chip.tsx +4 -5
- package/packages/bundled-features/src/tags/web/tag-manager.tsx +2 -1
- package/packages/bundled-features/src/template-resolver/api.ts +6 -13
- package/packages/bundled-features/src/template-resolver/changes.json +48 -0
- package/packages/bundled-features/src/template-resolver/document-sanitizer.ts +25 -0
- package/packages/bundled-features/src/template-resolver/feature.ts +2 -0
- package/packages/bundled-features/src/template-resolver/handlers/body-preview.query.ts +41 -0
- package/packages/bundled-features/src/template-resolver/handlers/by-slug.query.ts +1 -1
- package/packages/bundled-features/src/template-resolver/handlers/by-tenant.query.ts +1 -1
- package/packages/bundled-features/src/template-resolver/handlers/collection-shared.ts +5 -11
- package/packages/bundled-features/src/template-resolver/handlers/overview.query.ts +3 -2
- package/packages/bundled-features/src/template-resolver/handlers/send-test.write.ts +37 -8
- package/packages/bundled-features/src/template-resolver/linked-resources.ts +2 -5
- package/packages/bundled-features/src/template-resolver/seeding.ts +107 -0
- package/packages/bundled-features/src/template-resolver/table.ts +1 -0
- package/packages/bundled-features/src/template-resolver/template-draft.ts +2 -1
- package/packages/bundled-features/src/template-resolver/template-preview.ts +14 -3
- package/packages/bundled-features/src/template-resolver/testing.ts +0 -2
- package/packages/bundled-features/src/template-resolver/web/client-plugin.tsx +3 -0
- package/packages/bundled-features/src/template-resolver/web/collection-entry-create-form.tsx +33 -33
- package/packages/bundled-features/src/template-resolver/web/constants.ts +7 -0
- package/packages/bundled-features/src/template-resolver/web/content-tree-provider.ts +0 -1
- package/packages/bundled-features/src/template-resolver/web/content-workbench.tsx +142 -0
- package/packages/bundled-features/src/template-resolver/web/document-insert-model.ts +3 -8
- package/packages/bundled-features/src/template-resolver/web/document-link-policy.ts +58 -0
- package/packages/bundled-features/src/template-resolver/web/document-schema.ts +11 -57
- package/packages/bundled-features/src/template-resolver/web/document-tiptap-bubble.tsx +2 -4
- package/packages/bundled-features/src/template-resolver/web/document-tiptap-context.ts +4 -5
- package/packages/bundled-features/src/template-resolver/web/document-tiptap-editor.tsx +2 -2
- package/packages/bundled-features/src/template-resolver/web/document-tiptap-helpers.ts +6 -3
- package/packages/bundled-features/src/template-resolver/web/document-tiptap-toolbar-groups.tsx +2 -3
- package/packages/bundled-features/src/template-resolver/web/editor-handle.ts +1 -0
- package/packages/bundled-features/src/template-resolver/web/fill-document-variables.ts +24 -0
- package/packages/bundled-features/src/template-resolver/web/i18n.ts +14 -0
- package/packages/bundled-features/src/template-resolver/web/index.ts +3 -0
- package/packages/bundled-features/src/template-resolver/web/preview-targets.ts +25 -0
- package/packages/bundled-features/src/template-resolver/web/qualified-names.ts +1 -0
- package/packages/bundled-features/src/template-resolver/web/snippet-preview-renderer.tsx +24 -0
- package/packages/bundled-features/src/template-resolver/web/string-values.ts +7 -0
- package/packages/bundled-features/src/template-resolver/web/text-block-editor.tsx +38 -50
- package/packages/bundled-features/src/template-resolver/web/use-collection-entry-create.ts +7 -0
- package/packages/bundled-features/src/template-resolver/web/use-content-write.ts +1 -3
- package/packages/bundled-features/src/template-resolver/web/use-document-tiptap-model.ts +1 -2
- package/packages/bundled-features/src/template-resolver/web/use-text-block-editor.ts +28 -7
- package/packages/bundled-features/src/template-resolver/web/web-preview-renderer.tsx +132 -0
- package/packages/bundled-features/src/template-resolver-user-data/index.ts +11 -10
- package/packages/bundled-features/src/tenant/changes.json +6 -0
- package/packages/bundled-features/src/tenant/handlers/create.write.ts +7 -8
- package/packages/bundled-features/src/tenant/handlers/list.query.ts +7 -9
- package/packages/bundled-features/src/tenant/handlers/member-directory.query.ts +10 -4
- package/packages/bundled-features/src/tenant/handlers/toggle-enabled.write.ts +1 -1
- package/packages/bundled-features/src/tenant/invited-membership.ts +10 -1
- package/packages/bundled-features/src/tenant/seeding.ts +4 -2
- package/packages/bundled-features/src/tenant/stream-tenant-backfill.ts +5 -1
- package/packages/bundled-features/src/tenant/testing.ts +1 -1
- package/packages/bundled-features/src/tenant-inactivity/changes.json +6 -0
- package/packages/bundled-features/src/tenant-inactivity/check-inactive-tenants.ts +36 -17
- package/packages/bundled-features/src/tenant-inactivity/constants.ts +1 -2
- package/packages/bundled-features/src/tenant-inactivity/handlers/keep-account.write.ts +7 -2
- package/packages/bundled-features/src/tenant-inactivity/state-store.ts +22 -2
- package/packages/bundled-features/src/tenant-lifecycle/changes.json +24 -0
- package/packages/bundled-features/src/tenant-lifecycle/constants.ts +4 -0
- package/packages/bundled-features/src/tenant-lifecycle/feature.ts +1 -0
- package/packages/bundled-features/src/tenant-lifecycle/run-tenant-destroy.ts +43 -6
- package/packages/bundled-features/src/tenant-lifecycle/stages.ts +15 -2
- package/packages/bundled-features/src/tier-engine/aggregate-id.ts +0 -1
- package/packages/bundled-features/src/tier-engine/changes.json +6 -0
- package/packages/bundled-features/src/tier-engine/feature.ts +8 -2
- package/packages/bundled-features/src/user/changes.json +6 -0
- package/packages/bundled-features/src/user/db/queries/stream-tenant-backfill.ts +2 -1
- package/packages/bundled-features/src/user/handlers/me.query.ts +3 -1
- package/packages/bundled-features/src/user/index.ts +1 -0
- package/packages/bundled-features/src/user/resolve-verified-user-email.ts +17 -0
- package/packages/bundled-features/src/user-data-rights/db/queries/export-jobs.ts +0 -1
- package/packages/bundled-features/src/user-data-rights/feature.ts +1 -0
- package/packages/bundled-features/src/user-data-rights/handlers/confirm-deletion-by-token.write.ts +1 -1
- package/packages/bundled-features/src/user-data-rights/handlers/download-by-token.query.ts +1 -1
- package/packages/bundled-features/src/user-data-rights/handlers/request-deletion-by-email.write.ts +1 -1
- package/packages/bundled-features/src/user-data-rights/run-export-jobs.ts +0 -2
- package/packages/bundled-features/src/user-data-rights/run-forget-cleanup.ts +3 -3
- package/packages/bundled-features/src/user-data-rights/schema/download-attempt.ts +3 -2
- package/packages/bundled-features/src/user-data-rights/web/confirm-deletion-screen.tsx +1 -1
- package/packages/bundled-features/src/user-data-rights/web/privacy-center-screen.tsx +1 -1
- package/packages/bundled-features/src/user-data-rights/web/request-deletion-screen.tsx +1 -1
- package/packages/bundled-features/src/user-data-rights-defaults/hooks/api-token.userdata-hook.ts +5 -5
- package/packages/bundled-features/src/user-data-rights-defaults/hooks/hard-delete-own-rows-hook.ts +17 -0
- package/packages/bundled-features/src/user-data-rights-defaults/hooks/in-app-message.userdata-hook.ts +5 -5
- package/packages/bundled-features/src/user-data-rights-defaults/hooks/job-run.userdata-hook.ts +2 -1
- package/packages/bundled-features/src/user-data-rights-defaults/hooks/user-session.userdata-hook.ts +5 -5
- package/packages/bundled-features/src/user-profile/handlers/change-email.write.ts +0 -1
- package/packages/bundled-features/src/waitlist/changes.json +6 -0
- package/packages/bundled-features/src/waitlist/handlers/reject.write.ts +1 -1
- package/packages/bundled-features/src/waitlist/handlers/submit.write.ts +5 -29
- package/packages/bundled-features/src/waitlist/import.ts +2 -1
- package/packages/bundled-features/src/waitlist/lib.ts +2 -11
- package/packages/bundled-features/src/waitlist/link-on-signup.ts +2 -2
- package/packages/bundled-features/src/waitlist/user-data-hooks.ts +6 -19
- package/packages/bundled-features/src/workflow-runner/aggregate-id.ts +0 -1
- package/packages/bundled-features/src/workflow-runner/changes.json +6 -0
- package/packages/bundled-features/src/workflow-runner/event-trigger.ts +6 -2
- package/packages/bundled-features/src/workflow-runner/feature.ts +1 -5
- package/packages/bundled-features/src/workflow-runner/handlers/resume-run.write.ts +7 -4
- package/packages/bundled-features/src/workflow-runner/runner.ts +2 -0
- package/samples/apps/admin-console/src/app/shell.tsx +1 -0
- package/samples/apps/showcase/src/features/demos/web/pages/dialog.tsx +0 -1
- package/samples/apps/showcase/src/features/demos/web/pages/layout.tsx +1 -1
- package/samples/apps/showcase/src/features/demos/web/pages/sidebar-panel.tsx +0 -1
- package/samples/apps/styleguide/src/features/gallery/web/Gallery.tsx +1 -4
- package/samples/apps/ui-walkthrough/src/features/subscription-plans/feature.ts +6 -2
- package/samples/apps/use-all-bundled/e2e-billing-gallery/gallery-features.ts +12 -14
- package/samples/apps/use-all-bundled/feature-manifest.json +60 -29
- package/samples/apps/use-all-bundled/playwright.billing-docs.config.ts +1 -1
- package/samples/apps/use-all-bundled/playwright.config.ts +1 -0
- package/samples/apps/use-all-bundled/src/app/seed.ts +1 -1
- package/samples/apps/use-all-bundled/src/run-config.ts +2 -1
- package/samples/recipes/auth-mfa/src/web/confirmation-code-step.tsx +32 -10
- package/samples/recipes/chat-channels/README.md +2 -0
- package/samples/recipes/crypto-shredding-hr/README.md +11 -0
- package/samples/recipes/crypto-shredding-hr/src/feature.ts +27 -0
- package/samples/recipes/currencies-global/src/entities/currency.ts +1 -0
- package/samples/recipes/managed-pages/README.md +5 -1
- package/samples/recipes/managed-pages/package.json +3 -2
- package/samples/recipes/managed-pages/src/web/branded-preview.tsx +21 -0
- package/samples/recipes/managed-pages/tsconfig.json +8 -0
- package/samples/recipes/pwa-shell/README.md +52 -0
- package/samples/recipes/pwa-shell/bin/server.ts +12 -0
- package/samples/recipes/pwa-shell/package.json +13 -0
- package/samples/recipes/pwa-shell/src/app.ts +34 -0
- package/samples/recipes/rate-limiting/README.md +3 -3
- package/samples/recipes/record-detail-layout/README.md +33 -0
- package/samples/recipes/record-detail-layout/src/feature.ts +556 -44
- package/samples/recipes/record-detail-layout/src/order-board.ts +529 -0
- package/packages/bundled-features/src/managed-pages/web/page-body-section.tsx +0 -72
- package/packages/bundled-features/src/subscription-paddle/tenant-binding.ts +0 -34
- package/packages/bundled-features/src/template-resolver/web/content-field.tsx +0 -61
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
// Kept separate from the folders feature (which only requires "tenant") so
|
|
5
5
|
// folders stays usable without the user-data-rights stack. Mirrors credit-user-data.
|
|
6
6
|
|
|
7
|
-
import { defineFeature
|
|
7
|
+
import { defineFeature } from "@cosmicdrift/kumiko-framework/engine";
|
|
8
|
+
import { registerUserDataHooks } from "../shared/index.ts";
|
|
8
9
|
import {
|
|
9
10
|
folderAssignmentDeleteHook,
|
|
10
11
|
folderAssignmentExportHook,
|
|
@@ -19,19 +20,16 @@ export function createFoldersUserDataFeature() {
|
|
|
19
20
|
r.describe(
|
|
20
21
|
"GDPR (Art. 20 export / Art. 17 erasure) coverage for the `folders` feature's `folder` + `folder-assignment` entities. Mounts the EXT_USER_DATA export + delete hooks so a tenant's folder tree and its entity-to-folder assignments are included in the user-data export bundle and erased on a tenant-scoped forget (single-user tenants only; multi-user + anonymize are no-ops since folder rows carry no per-user PII). Kept separate from `folders` so folder consumers without the user-data-rights pipeline don't pull a hard dependency — requires `user-data-rights`, optionalRequires `folders`.",
|
|
21
22
|
);
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
r.useExtension(EXT_USER_DATA, "folder-assignment", {
|
|
33
|
-
export: folderAssignmentExportHook,
|
|
34
|
-
delete: folderAssignmentDeleteHook,
|
|
23
|
+
registerUserDataHooks(r, {
|
|
24
|
+
sourceFeature: "folders",
|
|
25
|
+
entities: [
|
|
26
|
+
{ entity: "folder", export: folderExportHook, delete: folderDeleteHook },
|
|
27
|
+
{
|
|
28
|
+
entity: "folder-assignment",
|
|
29
|
+
export: folderAssignmentExportHook,
|
|
30
|
+
delete: folderAssignmentDeleteHook,
|
|
31
|
+
},
|
|
32
|
+
],
|
|
35
33
|
});
|
|
36
34
|
},
|
|
37
35
|
{ dedupeOptions: {} },
|
|
@@ -44,6 +44,7 @@ function registerFormDraft(r: FeatureRegistrar<typeof FORM_DRAFT_FEATURE_NAME>):
|
|
|
44
44
|
r.job({
|
|
45
45
|
name: "cleanup",
|
|
46
46
|
trigger: { maintenance: true },
|
|
47
|
+
irreversibleWithoutEntryHandler: "high-risk-or-cron-pipeline",
|
|
47
48
|
concurrency: "skip",
|
|
48
49
|
escapeHatch: { reason: CLEANUP_ESCAPE_HATCH_REASON },
|
|
49
50
|
handler: (payload, ctx) =>
|
|
@@ -1,4 +1,60 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"version": "0.415.0",
|
|
4
|
+
"type": "fix",
|
|
5
|
+
"title": "Helpdesk forwards requests and replies without ctx.notify",
|
|
6
|
+
"detail": "Forwarding a request, the reply mail dispatch and the in-app note are plain dispatches and now run through runBestEffort instead of the notify-gated sendBestEffort, so they no longer get skipped when the delivery feature is not mounted. The legacy contact subject lookup checks the archive first and decrypts an email only for anonymous requests."
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
"version": "0.414.0",
|
|
10
|
+
"type": "fix",
|
|
11
|
+
"title": "Legacy contact data is exported, erased and expired from the event log",
|
|
12
|
+
"detail": "The user-data hooks for requests stored under the former contact names read the dropped `read_contact_requests` and `read_contact_replies` tables, so the export failed and the forget run reported an error on an app that never had those tables. They now fold the `contact-request` and `contact-reply` event streams instead: the export lists the requests of the user (by user id, or by verified email for anonymous ones) with their replies, the forget run purges attachments, erases the record keys and archives the streams. A new maintenance job `helpdesk:job:legacy-contact-retention` applies the retention period to old legacy requests and replies. Deleting a user also erases the notes written on their helpdesk requests and legacy requests."
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"version": "0.414.0",
|
|
16
|
+
"type": "improvement",
|
|
17
|
+
"title": "HELPDESK_REQUEST_ENTITY is exported from the helpdesk entry",
|
|
18
|
+
"detail": "`HELPDESK_REQUEST_ENTITY` comes from `@cosmicdrift/kumiko-bundled-features/helpdesk` next to the other helpdesk constants."
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"version": "0.414.0",
|
|
22
|
+
"type": "improvement",
|
|
23
|
+
"title": "Indexes for helpdesk requests and replies",
|
|
24
|
+
"detail": "All helpdesk rows live in the system tenant, so the tenant index selected nothing. `read_helpdesk_requests` gets indexes on (tenant_id, status) and (tenant_id, reporter_user_id), `read_helpdesk_replies` on (tenant_id, request_id).",
|
|
25
|
+
"migration": "Run `bun kumiko-schema generate` in the app to pick up the new indexes."
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"version": "0.414.0",
|
|
29
|
+
"type": "breaking",
|
|
30
|
+
"title": "Helpdesk reply error passthrough, paged user-data lookups",
|
|
31
|
+
"detail": "helpdesk reply returns the file takeover failure as is (file_rejected) instead of mapping everything to helpdesk_attachment_not_found, which is removed from HelpdeskErrors; user-data forget and export page through all requests and replies, the reply detail lists all replies; the exported SYSTEM_ADMIN_ROLE constant is removed and SystemAdmin checks use ROLES.SystemAdmin.",
|
|
32
|
+
"migration": "Replace imports of SYSTEM_ADMIN_ROLE by ROLES.SystemAdmin; clients matching the helpdesk reply error helpdesk_attachment_not_found match file_rejected instead."
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"version": "0.414.0",
|
|
36
|
+
"type": "fix",
|
|
37
|
+
"title": "Public handlers declare only the anonymous role",
|
|
38
|
+
"detail": "Handlers declaring access.anySignedIn next to the anonymous role list only anonymous in roles (the dropped signed-in roles never had an effect); the SUBMIT_ROLES constant of helpdesk is removed."
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"version": "0.414.0",
|
|
42
|
+
"type": "fix",
|
|
43
|
+
"title": "Notification preferences and config values of the former contact feature are carried over",
|
|
44
|
+
"detail": "The helpdesk notifications declare `renamedFrom: [\"contact:notify:<name>\"]`, so stored preferences and address opt-outs under the former names keep applying (a helpdesk-name row wins). The boot job `helpdesk:job:legacy-contact-config` (`runOnBoot`, idempotent) writes `contact:config:reply-to` and `contact:config:telegram-chat` to `helpdesk:config:reply-to` and `helpdesk:config:telegram-chat` through `config:write:set` as SystemAdmin, only when the helpdesk key has no value yet; the old rows stay untouched. The job declares an `escapeHatch` (crossTenantReads, systemIdentity). This replaces the \"not carried over\" hint of the 0.413.0 migration note for these settings."
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"version": "0.414.0",
|
|
48
|
+
"type": "fix",
|
|
49
|
+
"title": "pre-rename contact requests are exported and erased with the user",
|
|
50
|
+
"detail": "Since the rename from contact to helpdesk, requests and replies stored under the aggregates `contact-request` and `contact-reply` (tables `read_contact_requests`, `read_contact_replies`, attachments with that entity type) sat inert; the EXT_USER_DATA hooks only covered `helpdesk-*`, so a user's export missed them and an erasure left the personal data behind. The helpdesk feature now registers export and delete hooks for the former aggregate, matching by reporter user id or verified email like the current hooks. Deleting forgets the rows through the event-store executor, removes their attachments and shreds the record subject keys. The former entities are not registered, so no schema is generated for them, and installs without former data skip the hooks. The data-retention job does not see these rows, since it only walks registered entities."
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"version": "0.414.0",
|
|
54
|
+
"type": "improvement",
|
|
55
|
+
"title": "acknowledgedSystemDb for system-scoped features",
|
|
56
|
+
"detail": "`acknowledgedSystemDb(ctx, featureName, crossTenantReason)` returns `ctx.systemDb.acknowledgeCrossTenant(reason)` and throws an InternalError naming the feature when `r.systemScope()` is missing. helpdesk and waitlist use it, together with the shared `sendBestEffort` and `resolveVerifiedUserEmail`; behaviour and log texts are unchanged."
|
|
57
|
+
},
|
|
2
58
|
{
|
|
3
59
|
"version": "0.413.1",
|
|
4
60
|
"type": "improvement",
|
|
@@ -124,6 +124,8 @@ export function createHelpdeskRequestEntity(retentionKeepFor: string = DEFAULT_R
|
|
|
124
124
|
closedAt: createTimestampField(),
|
|
125
125
|
replyCount: createNumberField({ default: 0 }),
|
|
126
126
|
},
|
|
127
|
+
// All rows live in the system tenant, so the tenant_id index alone selects nothing.
|
|
128
|
+
indexes: [{ columns: ["tenantId", "status"] }, { columns: ["tenantId", "reporterUserId"] }],
|
|
127
129
|
});
|
|
128
130
|
}
|
|
129
131
|
|
|
@@ -131,7 +133,7 @@ export function createHelpdeskReplyEntity(retentionKeepFor: string = DEFAULT_RET
|
|
|
131
133
|
return createEntity({
|
|
132
134
|
table: "read_helpdesk_replies",
|
|
133
135
|
description:
|
|
134
|
-
"A SystemAdmin's answer to a
|
|
136
|
+
"A SystemAdmin's answer to a helpdesk request, with the channels it went out on; the message is the reporter's personal data because it quotes and addresses them.",
|
|
135
137
|
systemStream: true,
|
|
136
138
|
tenancy: "global",
|
|
137
139
|
retention: { keepFor: retentionKeepFor, strategy: "hardDelete", reference: "sentAt" },
|
|
@@ -163,6 +165,7 @@ export function createHelpdeskReplyEntity(retentionKeepFor: string = DEFAULT_RET
|
|
|
163
165
|
reason: "is_submission_timestamp",
|
|
164
166
|
}),
|
|
165
167
|
},
|
|
168
|
+
indexes: [{ columns: ["tenantId", "requestId"] }],
|
|
166
169
|
});
|
|
167
170
|
}
|
|
168
171
|
|
|
@@ -27,6 +27,13 @@ import { createSendReplyMailHandler } from "./handlers/send-reply-mail.write.ts"
|
|
|
27
27
|
import { createSendTestHandler } from "./handlers/send-test.write.ts";
|
|
28
28
|
import { createSubmitHandler } from "./handlers/submit.write.ts";
|
|
29
29
|
import { createHelpdeskI18n } from "./i18n.ts";
|
|
30
|
+
import { carryOverLegacyContactConfig } from "./legacy-contact-config.ts";
|
|
31
|
+
import { runLegacyContactRetention } from "./legacy-contact-retention.ts";
|
|
32
|
+
import {
|
|
33
|
+
LEGACY_CONTACT_REQUEST_ENTITY,
|
|
34
|
+
legacyContactDeleteHook,
|
|
35
|
+
legacyContactExportHook,
|
|
36
|
+
} from "./legacy-contact-user-data.ts";
|
|
30
37
|
import { TELEGRAM_FEATURE } from "./lib.ts";
|
|
31
38
|
import {
|
|
32
39
|
HELPDESK_ACKNOWLEDGEMENT_VARIABLES,
|
|
@@ -103,28 +110,35 @@ export function createHelpdeskFeature(opts: HelpdeskOptions): FeatureDefinition
|
|
|
103
110
|
});
|
|
104
111
|
}
|
|
105
112
|
|
|
113
|
+
// renamedFrom: preferences and opt-outs stored under the former contact feature keep applying.
|
|
106
114
|
r.notification("new-request", {
|
|
115
|
+
renamedFrom: ["contact:notify:new-request"],
|
|
107
116
|
variables: HELPDESK_NEW_REQUEST_VARIABLES,
|
|
108
117
|
localizedTemplate: helpdeskNewRequestTemplate,
|
|
109
118
|
...(telegram && { templates: { telegram: telegramTemplate } }),
|
|
110
119
|
});
|
|
111
120
|
r.notification("confirmation", {
|
|
121
|
+
renamedFrom: ["contact:notify:confirmation"],
|
|
112
122
|
variables: HELPDESK_CONFIRMATION_VARIABLES,
|
|
113
123
|
localizedTemplate: helpdeskConfirmationTemplate,
|
|
114
124
|
});
|
|
115
125
|
r.notification("acknowledgement", {
|
|
126
|
+
renamedFrom: ["contact:notify:acknowledgement"],
|
|
116
127
|
variables: HELPDESK_ACKNOWLEDGEMENT_VARIABLES,
|
|
117
128
|
localizedTemplate: helpdeskAcknowledgementTemplate,
|
|
118
129
|
});
|
|
119
130
|
r.notification("reply", {
|
|
131
|
+
renamedFrom: ["contact:notify:reply"],
|
|
120
132
|
variables: HELPDESK_REPLY_VARIABLES,
|
|
121
133
|
localizedTemplate: helpdeskReplyTemplate,
|
|
122
134
|
});
|
|
123
135
|
r.notification("reply-in-app", {
|
|
136
|
+
renamedFrom: ["contact:notify:reply-in-app"],
|
|
124
137
|
templates: { inApp: inAppTemplate },
|
|
125
138
|
});
|
|
126
139
|
if (telegram) {
|
|
127
140
|
r.notification("test", {
|
|
141
|
+
renamedFrom: ["contact:notify:test"],
|
|
128
142
|
variables: HELPDESK_TEST_VARIABLES,
|
|
129
143
|
localizedTemplate: helpdeskTestTemplate,
|
|
130
144
|
templates: { telegram: telegramTemplate },
|
|
@@ -169,6 +183,34 @@ export function createHelpdeskFeature(opts: HelpdeskOptions): FeatureDefinition
|
|
|
169
183
|
export: helpdeskExportHook,
|
|
170
184
|
delete: helpdeskDeleteHook,
|
|
171
185
|
});
|
|
186
|
+
// Requests stored before the rename to helpdesk sit inert under the former aggregate and tables.
|
|
187
|
+
r.useExtension(EXT_USER_DATA, LEGACY_CONTACT_REQUEST_ENTITY, {
|
|
188
|
+
export: legacyContactExportHook,
|
|
189
|
+
delete: legacyContactDeleteHook,
|
|
190
|
+
});
|
|
191
|
+
r.job({
|
|
192
|
+
// A literal, not LEGACY_CONTACT_CONFIG_JOB: the feature-AST extractor only reads string literals.
|
|
193
|
+
name: "legacy-contact-config",
|
|
194
|
+
trigger: { manual: true },
|
|
195
|
+
runOnBoot: true,
|
|
196
|
+
concurrency: "skip",
|
|
197
|
+
escapeHatch: {
|
|
198
|
+
reason:
|
|
199
|
+
"the job has no tenant scope and reads the system-tenant config rows stored under the former contact keys through crossTenantReads, then writes them to the helpdesk keys via config:write:set as SystemAdmin",
|
|
200
|
+
grants: ["crossTenantReads", "systemIdentity"],
|
|
201
|
+
},
|
|
202
|
+
handler: async (_payload, ctx) => {
|
|
203
|
+
const carriedOver = await carryOverLegacyContactConfig(ctx);
|
|
204
|
+
ctx.obs.log.info("helpdesk: carried over former contact config", { carriedOver });
|
|
205
|
+
},
|
|
206
|
+
});
|
|
207
|
+
r.job({
|
|
208
|
+
name: "legacy-contact-retention",
|
|
209
|
+
trigger: { maintenance: true },
|
|
210
|
+
irreversibleWithoutEntryHandler: "high-risk-or-cron-pipeline",
|
|
211
|
+
concurrency: "skip",
|
|
212
|
+
handler: async (_payload, ctx) => runLegacyContactRetention(keepFor, ctx),
|
|
213
|
+
});
|
|
172
214
|
// Replies are exported nested under their request and erased with it (helpdeskDeleteHook).
|
|
173
215
|
r.useExtension(EXT_USER_DATA, "helpdesk-reply", {
|
|
174
216
|
export: async () => null,
|
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
import { access } from "@cosmicdrift/kumiko-framework/engine";
|
|
2
|
-
|
|
3
|
-
// The website client sends without a session (credentials: "omit"), so it arrives as anonymous; other callers that carry a session pass through anySignedIn on the handlers.
|
|
4
|
-
export const SUBMIT_ROLES = access.roles(
|
|
5
|
-
...access.anonymous,
|
|
6
|
-
...access.authenticated,
|
|
7
|
-
"Member",
|
|
8
|
-
"TenantAdmin",
|
|
9
|
-
);
|
|
10
|
-
|
|
11
1
|
export const REPORT_ACCESS = {
|
|
12
2
|
openToAll: {
|
|
13
3
|
reason:
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
+
import { ROLES } from "@cosmicdrift/kumiko-framework/auth";
|
|
1
2
|
import {
|
|
2
3
|
createSystemUser,
|
|
3
4
|
type HandlerContext,
|
|
4
5
|
type SessionUser,
|
|
5
6
|
type TenantId,
|
|
6
7
|
} from "@cosmicdrift/kumiko-framework/engine";
|
|
8
|
+
import { chunk } from "@cosmicdrift/kumiko-framework/utils";
|
|
7
9
|
import { IN_APP_NOTIFICATION_QUERIES } from "@cosmicdrift/kumiko-types/in-app-notification-types";
|
|
8
10
|
import { Temporal } from "@cosmicdrift/kumiko-types/temporal";
|
|
9
11
|
import * as z from "zod";
|
|
10
12
|
import { DeliveryQueries } from "../../delivery/index.ts";
|
|
11
|
-
import { SYSTEM_ADMIN_ROLE } from "../lib.ts";
|
|
12
13
|
|
|
13
14
|
// Both queries accept at most this many keys per call.
|
|
14
15
|
const MAX_KEYS_PER_QUERY = 50;
|
|
@@ -30,23 +31,15 @@ const readStateResultSchema = z.object({
|
|
|
30
31
|
|
|
31
32
|
export type HelpdeskAttempt = z.infer<typeof attemptSchema>;
|
|
32
33
|
|
|
33
|
-
function chunked(keys: readonly string[]): readonly (readonly string[])[] {
|
|
34
|
-
const chunks: string[][] = [];
|
|
35
|
-
for (let start = 0; start < keys.length; start += MAX_KEYS_PER_QUERY) {
|
|
36
|
-
chunks.push(keys.slice(start, start + MAX_KEYS_PER_QUERY));
|
|
37
|
-
}
|
|
38
|
-
return chunks;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
34
|
export async function loadAttemptsByKey(
|
|
42
35
|
ctx: Pick<HandlerContext, "dispatch">,
|
|
43
36
|
user: SessionUser,
|
|
44
37
|
keys: readonly string[],
|
|
45
38
|
): Promise<readonly HelpdeskAttempt[]> {
|
|
46
39
|
const rows: HelpdeskAttempt[] = [];
|
|
47
|
-
for (const
|
|
40
|
+
for (const keyChunk of chunk(keys, MAX_KEYS_PER_QUERY)) {
|
|
48
41
|
const result = await ctx.dispatch.queryAs(user, DeliveryQueries.attemptsByKeys, {
|
|
49
|
-
keys:
|
|
42
|
+
keys: keyChunk,
|
|
50
43
|
});
|
|
51
44
|
rows.push(...attemptsResultSchema.parse(result).rows);
|
|
52
45
|
}
|
|
@@ -64,10 +57,10 @@ export async function loadReadAtByKey(
|
|
|
64
57
|
if (ctx.registry.getQueryHandler(IN_APP_NOTIFICATION_QUERIES.readStateByKeys) === undefined) {
|
|
65
58
|
return readAtByKey;
|
|
66
59
|
}
|
|
67
|
-
const user = createSystemUser(reporterTenantId, [
|
|
68
|
-
for (const
|
|
60
|
+
const user = createSystemUser(reporterTenantId, [ROLES.SystemAdmin]);
|
|
61
|
+
for (const keyChunk of chunk(keys, MAX_KEYS_PER_QUERY)) {
|
|
69
62
|
const result = await ctx.dispatch.queryAs(user, IN_APP_NOTIFICATION_QUERIES.readStateByKeys, {
|
|
70
|
-
keys:
|
|
63
|
+
keys: keyChunk,
|
|
71
64
|
});
|
|
72
65
|
for (const row of readStateResultSchema.parse(result).rows)
|
|
73
66
|
readAtByKey.set(row.key, row.readAt);
|
|
@@ -4,7 +4,6 @@ import { issueChallenge } from "../challenge.ts";
|
|
|
4
4
|
import { CHALLENGE_RATE_LIMIT, type HelpdeskSettings } from "../options.ts";
|
|
5
5
|
import { HelpdeskEmptySchema } from "../payloads.ts";
|
|
6
6
|
import { HELPDESK_WEBSITE_KINDS, type HelpdeskPhoneMode } from "../web/constants.ts";
|
|
7
|
-
import { SUBMIT_ROLES } from "./access.ts";
|
|
8
7
|
|
|
9
8
|
export type HelpdeskChallengeData = {
|
|
10
9
|
readonly challenge: string;
|
|
@@ -17,7 +16,7 @@ export function createChallengeQuery(settings: HelpdeskSettings) {
|
|
|
17
16
|
return defineQueryHandler({
|
|
18
17
|
name: "challenge",
|
|
19
18
|
schema: HelpdeskEmptySchema,
|
|
20
|
-
access: { roles:
|
|
19
|
+
access: { roles: ["anonymous"], personalData: "public-intake", anySignedIn: true },
|
|
21
20
|
rateLimit: CHALLENGE_RATE_LIMIT,
|
|
22
21
|
agent: { expose: false },
|
|
23
22
|
description:
|
|
@@ -3,11 +3,7 @@ import {
|
|
|
3
3
|
defineWriteHandler,
|
|
4
4
|
type HandlerContext,
|
|
5
5
|
} from "@cosmicdrift/kumiko-framework/engine";
|
|
6
|
-
import {
|
|
7
|
-
NotFoundError,
|
|
8
|
-
UnprocessableError,
|
|
9
|
-
writeFailure,
|
|
10
|
-
} from "@cosmicdrift/kumiko-framework/errors";
|
|
6
|
+
import { NotFoundError, writeFailure } from "@cosmicdrift/kumiko-framework/errors";
|
|
11
7
|
import { generateId } from "@cosmicdrift/kumiko-framework/utils";
|
|
12
8
|
import { parseTenantId } from "@cosmicdrift/kumiko-types/identifiers";
|
|
13
9
|
import {
|
|
@@ -18,7 +14,7 @@ import {
|
|
|
18
14
|
platformActor,
|
|
19
15
|
replyExecutor,
|
|
20
16
|
requestExecutor,
|
|
21
|
-
|
|
17
|
+
runBestEffort,
|
|
22
18
|
} from "../lib.ts";
|
|
23
19
|
import { HelpdeskReplySchema } from "../payloads.ts";
|
|
24
20
|
import {
|
|
@@ -26,7 +22,6 @@ import {
|
|
|
26
22
|
HELPDESK_REPLY_ENTITY,
|
|
27
23
|
HELPDESK_REQUEST_ENTITY,
|
|
28
24
|
HELPDESK_STATUS,
|
|
29
|
-
HelpdeskErrors,
|
|
30
25
|
HelpdeskHandlers,
|
|
31
26
|
type HelpdeskReplyChannels,
|
|
32
27
|
HelpdeskScreens,
|
|
@@ -55,7 +50,7 @@ async function noteReporterInApp(ctx: HandlerContext, args: InAppNoteArgs): Prom
|
|
|
55
50
|
const tenantId = parseTenantId(request.reporterTenantId);
|
|
56
51
|
// skip: the in-app note needs a signed-in reporter whose tenant id is still valid
|
|
57
52
|
if (!request.reporterUserId || tenantId === null) return;
|
|
58
|
-
await
|
|
53
|
+
await runBestEffort(ctx, "reply in-app note", async () => {
|
|
59
54
|
const noted = await ctx.dispatch.writeAs(
|
|
60
55
|
createSystemUser(tenantId),
|
|
61
56
|
HelpdeskHandlers.notifyReporterInApp,
|
|
@@ -160,9 +155,7 @@ export function createReplyHandler() {
|
|
|
160
155
|
entityId: replyId,
|
|
161
156
|
fileIds: event.payload.fileIds ?? [],
|
|
162
157
|
});
|
|
163
|
-
if (!uploaded.isSuccess)
|
|
164
|
-
return writeFailure(new UnprocessableError(HelpdeskErrors.attachmentNotFound));
|
|
165
|
-
}
|
|
158
|
+
if (!uploaded.isSuccess) return uploaded;
|
|
166
159
|
const fileIds = uploaded.data;
|
|
167
160
|
const author = await loadUserLabel(db, event.user.id);
|
|
168
161
|
const authorName = author?.name ?? event.user.id;
|
|
@@ -180,7 +173,7 @@ export function createReplyHandler() {
|
|
|
180
173
|
});
|
|
181
174
|
if (failed !== null) return failed;
|
|
182
175
|
|
|
183
|
-
await
|
|
176
|
+
await runBestEffort(ctx, "reply mail", async () => {
|
|
184
177
|
const sent = await ctx.dispatch.writeAs(platformActor(), HelpdeskHandlers.sendReplyMail, {
|
|
185
178
|
replyId,
|
|
186
179
|
});
|
|
@@ -2,15 +2,17 @@ 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 { normalizeEmail } from "../../shared/index.ts";
|
|
5
6
|
import {
|
|
7
|
+
forwardHelpdeskRequest,
|
|
6
8
|
helpdeskDb,
|
|
7
9
|
loadTenantName,
|
|
8
10
|
loadTenantPlan,
|
|
9
11
|
loadUserLabel,
|
|
10
|
-
normalizeEmail,
|
|
11
12
|
phoneProblem,
|
|
12
13
|
platformActor,
|
|
13
14
|
requestExecutor,
|
|
15
|
+
runBestEffort,
|
|
14
16
|
sendBestEffort,
|
|
15
17
|
} from "../lib.ts";
|
|
16
18
|
import { helpdeskConfirmationVariables, resolveHelpdeskMailLocale } from "../mail.ts";
|
|
@@ -24,7 +26,6 @@ import {
|
|
|
24
26
|
HELPDESK_STATUS,
|
|
25
27
|
HELPDESK_UPLOAD_FIELD,
|
|
26
28
|
HelpdeskErrors,
|
|
27
|
-
HelpdeskHandlers,
|
|
28
29
|
HelpdeskScreens,
|
|
29
30
|
helpdeskIdempotencyKeys,
|
|
30
31
|
} from "../web/constants.ts";
|
|
@@ -96,14 +97,7 @@ export function createReportHandler(opts: HelpdeskOptions, settings: HelpdeskSet
|
|
|
96
97
|
);
|
|
97
98
|
if (!created.isSuccess) return created;
|
|
98
99
|
|
|
99
|
-
await
|
|
100
|
-
const forwarded = await ctx.dispatch.writeAs(
|
|
101
|
-
platformActor(),
|
|
102
|
-
HelpdeskHandlers.forwardRequest,
|
|
103
|
-
{ requestId },
|
|
104
|
-
);
|
|
105
|
-
if (!forwarded.isSuccess) throw new Error(forwarded.error.message);
|
|
106
|
-
});
|
|
100
|
+
await runBestEffort(ctx, "forward request", () => forwardHelpdeskRequest(ctx, requestId));
|
|
107
101
|
|
|
108
102
|
await sendBestEffort(ctx, "confirmation mail", (notify) =>
|
|
109
103
|
notify(HELPDESK_NOTIFICATION_TYPES.confirmation, {
|
|
@@ -14,13 +14,15 @@ import {
|
|
|
14
14
|
import { normalizePayloadBucketValue } from "@cosmicdrift/kumiko-framework/pipeline";
|
|
15
15
|
import { generateId } from "@cosmicdrift/kumiko-framework/utils";
|
|
16
16
|
import type { PayloadRateLimitOption } from "@cosmicdrift/kumiko-types/handlers";
|
|
17
|
+
import { normalizeEmail } from "../../shared/index.ts";
|
|
17
18
|
import { consumeChallenge } from "../challenge.ts";
|
|
18
19
|
import {
|
|
20
|
+
forwardHelpdeskRequest,
|
|
19
21
|
helpdeskDb,
|
|
20
|
-
normalizeEmail,
|
|
21
22
|
phoneProblem,
|
|
22
23
|
platformActor,
|
|
23
24
|
requestExecutor,
|
|
25
|
+
runBestEffort,
|
|
24
26
|
sendBestEffort,
|
|
25
27
|
} from "../lib.ts";
|
|
26
28
|
import { helpdeskAcknowledgementVariables, resolveHelpdeskMailLocale } from "../mail.ts";
|
|
@@ -38,10 +40,8 @@ import {
|
|
|
38
40
|
HELPDESK_NOTIFICATION_TYPES,
|
|
39
41
|
HELPDESK_SOURCE,
|
|
40
42
|
HELPDESK_STATUS,
|
|
41
|
-
HelpdeskHandlers,
|
|
42
43
|
helpdeskIdempotencyKeys,
|
|
43
44
|
} from "../web/constants.ts";
|
|
44
|
-
import { SUBMIT_ROLES } from "./access.ts";
|
|
45
45
|
|
|
46
46
|
export type HelpdeskSubmitData = { readonly kind: "submitted" };
|
|
47
47
|
|
|
@@ -120,7 +120,7 @@ export function createSubmitHandler(opts: HelpdeskOptions, settings: HelpdeskSet
|
|
|
120
120
|
return defineWriteHandler<"submit", typeof HelpdeskSubmitSchema, HelpdeskSubmitData>({
|
|
121
121
|
name: "submit",
|
|
122
122
|
schema: HelpdeskSubmitSchema,
|
|
123
|
-
access: { roles:
|
|
123
|
+
access: { roles: ["anonymous"], personalData: "public-intake", anySignedIn: true },
|
|
124
124
|
rateLimit: opts.rateLimit ?? DEFAULT_SUBMIT_RATE_LIMIT,
|
|
125
125
|
agent: { expose: false },
|
|
126
126
|
description:
|
|
@@ -166,14 +166,7 @@ export function createSubmitHandler(opts: HelpdeskOptions, settings: HelpdeskSet
|
|
|
166
166
|
);
|
|
167
167
|
if (!created.isSuccess) return created;
|
|
168
168
|
|
|
169
|
-
await
|
|
170
|
-
const forwarded = await ctx.dispatch.writeAs(
|
|
171
|
-
platformActor(),
|
|
172
|
-
HelpdeskHandlers.forwardRequest,
|
|
173
|
-
{ requestId },
|
|
174
|
-
);
|
|
175
|
-
if (!forwarded.isSuccess) throw new Error(forwarded.error.message);
|
|
176
|
-
});
|
|
169
|
+
await runBestEffort(ctx, "forward request", () => forwardHelpdeskRequest(ctx, requestId));
|
|
177
170
|
|
|
178
171
|
await sendBestEffort(ctx, "confirmation mail", (notify) =>
|
|
179
172
|
notify(HELPDESK_NOTIFICATION_TYPES.acknowledgement, {
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { ROLES } from "@cosmicdrift/kumiko-framework/auth";
|
|
2
|
+
import {
|
|
3
|
+
ConfigScopes,
|
|
4
|
+
createSystemUser,
|
|
5
|
+
type JobContext,
|
|
6
|
+
SYSTEM_TENANT_ID,
|
|
7
|
+
} from "@cosmicdrift/kumiko-framework/engine";
|
|
8
|
+
import { InternalError, reraiseAsKumikoError } from "@cosmicdrift/kumiko-framework/errors";
|
|
9
|
+
import { parseJsonSafe } from "@cosmicdrift/kumiko-framework/utils";
|
|
10
|
+
import * as z from "zod";
|
|
11
|
+
import { ConfigHandlers, configValuesTable } from "../config/index.ts";
|
|
12
|
+
import { HELPDESK_FEATURE } from "./web/constants.ts";
|
|
13
|
+
|
|
14
|
+
export const LEGACY_CONTACT_CONFIG_JOB = "legacy-contact-config";
|
|
15
|
+
|
|
16
|
+
// The two keys of the former contact feature; the config values stay under them after the rename.
|
|
17
|
+
const CARRIED_OVER_KEYS: ReadonlyArray<{ readonly legacy: string; readonly current: string }> = [
|
|
18
|
+
{ legacy: "contact:config:reply-to", current: `${HELPDESK_FEATURE}:config:reply-to` },
|
|
19
|
+
{ legacy: "contact:config:telegram-chat", current: `${HELPDESK_FEATURE}:config:telegram-chat` },
|
|
20
|
+
];
|
|
21
|
+
|
|
22
|
+
const storedValueSchema = z.union([z.string(), z.number(), z.boolean()]);
|
|
23
|
+
|
|
24
|
+
// Both keys are system-scope, so the former feature only ever stored system rows.
|
|
25
|
+
// Writes through config:write:set, so the helpdesk key's own validation applies.
|
|
26
|
+
export async function carryOverLegacyContactConfig(ctx: JobContext): Promise<number> {
|
|
27
|
+
const reads = ctx.crossTenantReads;
|
|
28
|
+
if (!reads) {
|
|
29
|
+
throw new InternalError({
|
|
30
|
+
message: "[helpdesk] legacy-contact-config needs the crossTenantReads grant",
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
const systemAdmin = createSystemUser(SYSTEM_TENANT_ID, [ROLES.SystemAdmin]);
|
|
34
|
+
let carriedOver = 0;
|
|
35
|
+
for (const { legacy, current } of CARRIED_OVER_KEYS) {
|
|
36
|
+
// skip: telegramChat is only registered with option telegram, then there is nothing to carry into
|
|
37
|
+
if (!ctx.registry.getConfigKey(current)) continue;
|
|
38
|
+
const alreadySet = await reads.selectMany(configValuesTable, {
|
|
39
|
+
key: current,
|
|
40
|
+
tenantId: SYSTEM_TENANT_ID,
|
|
41
|
+
});
|
|
42
|
+
if (alreadySet.some((row) => row["userId"] == null)) continue;
|
|
43
|
+
const former = await reads.selectMany(configValuesTable, {
|
|
44
|
+
key: legacy,
|
|
45
|
+
tenantId: SYSTEM_TENANT_ID,
|
|
46
|
+
});
|
|
47
|
+
const row = former.find((candidate) => candidate["userId"] == null);
|
|
48
|
+
const stored = typeof row?.["value"] === "string" ? row["value"] : undefined;
|
|
49
|
+
if (stored === undefined) continue;
|
|
50
|
+
const value = storedValueSchema.safeParse(parseJsonSafe<unknown>(stored, undefined));
|
|
51
|
+
if (!value.success) continue;
|
|
52
|
+
const written = await ctx.dispatch.writeAs(systemAdmin, ConfigHandlers.set, {
|
|
53
|
+
key: current,
|
|
54
|
+
value: value.data,
|
|
55
|
+
scope: ConfigScopes.system,
|
|
56
|
+
});
|
|
57
|
+
if (!written.isSuccess) throw reraiseAsKumikoError(written.error);
|
|
58
|
+
carriedOver++;
|
|
59
|
+
}
|
|
60
|
+
return carriedOver;
|
|
61
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { configuredPiiSubjectKms } from "@cosmicdrift/kumiko-framework/crypto";
|
|
2
|
+
import type { TenantDb } from "@cosmicdrift/kumiko-framework/db";
|
|
3
|
+
import {
|
|
4
|
+
archiveLegacyStream,
|
|
5
|
+
LEGACY_CONTACT_REPLY_ENTITY,
|
|
6
|
+
LEGACY_CONTACT_REQUEST_ENTITY,
|
|
7
|
+
type LegacyAggregate,
|
|
8
|
+
} from "./legacy-contact-streams.ts";
|
|
9
|
+
import { eraseNotesOnRequest } from "./user-data-hooks.ts";
|
|
10
|
+
|
|
11
|
+
const ERASE_REASON = "helpdesk:legacy-contact-forget";
|
|
12
|
+
|
|
13
|
+
export type LegacyEraser = {
|
|
14
|
+
readonly db: TenantDb;
|
|
15
|
+
readonly erasedBy: string;
|
|
16
|
+
readonly purgeAttachments: (entity: string, id: string) => Promise<void>;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
// Attachments first, then the record key, then the archive mark: until the stream is archived a
|
|
20
|
+
// retry still finds it.
|
|
21
|
+
export async function eraseLegacyAggregate(
|
|
22
|
+
eraser: LegacyEraser,
|
|
23
|
+
entity: string,
|
|
24
|
+
id: string,
|
|
25
|
+
): Promise<void> {
|
|
26
|
+
await eraser.purgeAttachments(entity, id);
|
|
27
|
+
await configuredPiiSubjectKms()?.eraseKey(
|
|
28
|
+
{ kind: "record", entity, id },
|
|
29
|
+
{ requestId: ERASE_REASON, userId: eraser.erasedBy, eraseReason: ERASE_REASON },
|
|
30
|
+
);
|
|
31
|
+
await archiveLegacyStream(eraser.db, entity, id);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Replies go with their request; notes hang on the request as host and go first, so a retry still
|
|
35
|
+
// finds the request.
|
|
36
|
+
export async function eraseLegacyRequest(
|
|
37
|
+
eraser: LegacyEraser,
|
|
38
|
+
request: LegacyAggregate,
|
|
39
|
+
replies: readonly LegacyAggregate[],
|
|
40
|
+
): Promise<void> {
|
|
41
|
+
await eraseNotesOnRequest(eraser, LEGACY_CONTACT_REQUEST_ENTITY, request.id, eraser.erasedBy);
|
|
42
|
+
for (const reply of replies)
|
|
43
|
+
await eraseLegacyAggregate(eraser, LEGACY_CONTACT_REPLY_ENTITY, reply.id);
|
|
44
|
+
await eraseLegacyAggregate(eraser, LEGACY_CONTACT_REQUEST_ENTITY, request.id);
|
|
45
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { deleteFileRefBytes } from "@cosmicdrift/kumiko-framework/derivatives";
|
|
2
|
+
import type { JobContext } from "@cosmicdrift/kumiko-framework/engine";
|
|
3
|
+
import { InternalError } from "@cosmicdrift/kumiko-framework/errors";
|
|
4
|
+
import { getTemporal } from "@cosmicdrift/kumiko-framework/time";
|
|
5
|
+
import { computeCutoff } from "../data-retention/index.ts";
|
|
6
|
+
import { eraseLegacyAggregate, eraseLegacyRequest } from "./legacy-contact-erasure.ts";
|
|
7
|
+
import {
|
|
8
|
+
LEGACY_CONTACT_REPLY_ENTITY,
|
|
9
|
+
LEGACY_CONTACT_REQUEST_ENTITY,
|
|
10
|
+
type LegacyAggregate,
|
|
11
|
+
readLegacyAggregates,
|
|
12
|
+
repliesOf,
|
|
13
|
+
} from "./legacy-contact-streams.ts";
|
|
14
|
+
import { purgeAttachmentsWith } from "./user-data-hooks.ts";
|
|
15
|
+
|
|
16
|
+
const RETENTION_CONTEXT = "helpdesk:legacy-contact-retention";
|
|
17
|
+
|
|
18
|
+
function isOlderThan(
|
|
19
|
+
aggregate: LegacyAggregate,
|
|
20
|
+
referenceField: string,
|
|
21
|
+
cutoff: ReturnType<typeof computeCutoff>,
|
|
22
|
+
): boolean {
|
|
23
|
+
const reference = aggregate.fields[referenceField];
|
|
24
|
+
if (typeof reference !== "string") return false;
|
|
25
|
+
return getTemporal().Instant.compare(getTemporal().Instant.from(reference), cutoff) < 0;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// The helpdesk entities' retention cron only sees the live tables; the pre-rename streams have none,
|
|
29
|
+
// so the same keepFor is enforced on the event log.
|
|
30
|
+
export async function runLegacyContactRetention(keepFor: string, ctx: JobContext): Promise<void> {
|
|
31
|
+
const cutoff = computeCutoff(keepFor, ctx.tz.now());
|
|
32
|
+
const eraser = {
|
|
33
|
+
db: ctx.db,
|
|
34
|
+
erasedBy: ctx.systemUser.id,
|
|
35
|
+
purgeAttachments: (entity: string, id: string) =>
|
|
36
|
+
purgeAttachmentsWith(ctx, entity, id, async () => {
|
|
37
|
+
const files = ctx.services.files;
|
|
38
|
+
if (!files) {
|
|
39
|
+
throw new InternalError({
|
|
40
|
+
message: `[${RETENTION_CONTEXT}] no file storage resolvable, attachments of ${entity} ${id} cannot be erased`,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
return (storageKey) => deleteFileRefBytes(files, { storageKey }, RETENTION_CONTEXT);
|
|
44
|
+
}),
|
|
45
|
+
};
|
|
46
|
+
const requests = await readLegacyAggregates(ctx.db, LEGACY_CONTACT_REQUEST_ENTITY, {
|
|
47
|
+
decrypt: false,
|
|
48
|
+
});
|
|
49
|
+
const replies = await readLegacyAggregates(ctx.db, LEGACY_CONTACT_REPLY_ENTITY, {
|
|
50
|
+
decrypt: false,
|
|
51
|
+
});
|
|
52
|
+
const erasedRequestIds = new Set<string>();
|
|
53
|
+
for (const request of requests) {
|
|
54
|
+
if (!isOlderThan(request, "submittedAt", cutoff)) continue;
|
|
55
|
+
await eraseLegacyRequest(eraser, request, repliesOf(replies, request.id));
|
|
56
|
+
erasedRequestIds.add(request.id);
|
|
57
|
+
}
|
|
58
|
+
for (const reply of replies) {
|
|
59
|
+
const requestId = reply.fields["requestId"];
|
|
60
|
+
if (typeof requestId === "string" && erasedRequestIds.has(requestId)) continue;
|
|
61
|
+
if (isOlderThan(reply, "sentAt", cutoff)) {
|
|
62
|
+
await eraseLegacyAggregate(eraser, LEGACY_CONTACT_REPLY_ENTITY, reply.id);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|