@cosmicdrift/kumiko-samples 0.385.0 → 0.387.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/LICENSE +21 -57
- package/README.md +1 -1
- package/package.json +2 -2
- package/packages/bundled-features/package.json +2 -2
- package/packages/bundled-features/src/agent-tools/tool-catalog.ts +1 -1
- package/packages/bundled-features/src/agent-tools/tool-dispatch.ts +0 -2
- package/packages/bundled-features/src/audit/screens.ts +1 -1
- package/packages/bundled-features/src/auth-email-password/auth-user-row.ts +10 -10
- package/packages/bundled-features/src/auth-email-password/feature.ts +6 -6
- package/packages/bundled-features/src/auth-email-password/handlers/change-password.write.ts +3 -3
- package/packages/bundled-features/src/auth-email-password/handlers/confirm-token-flow.ts +5 -5
- package/packages/bundled-features/src/auth-email-password/handlers/invite-accept-with-login.write.ts +1 -1
- package/packages/bundled-features/src/auth-email-password/handlers/invite-accept.write.ts +18 -18
- package/packages/bundled-features/src/auth-email-password/handlers/invite-create.write.ts +12 -12
- package/packages/bundled-features/src/auth-email-password/handlers/invite-info.query.ts +1 -1
- package/packages/bundled-features/src/auth-email-password/handlers/invite-signup-complete.write.ts +24 -26
- package/packages/bundled-features/src/auth-email-password/handlers/login.write.ts +1 -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/handlers/signup-confirm.write.ts +34 -37
- package/packages/bundled-features/src/auth-email-password/handlers/signup-request.write.ts +6 -7
- package/packages/bundled-features/src/auth-email-password/handlers/switch-tenant-mfa-gate.write.ts +1 -5
- package/packages/bundled-features/src/auth-email-password/index.ts +5 -5
- package/packages/bundled-features/src/auth-email-password/lockout-store.ts +1 -1
- package/packages/bundled-features/src/auth-email-password/seeding.ts +63 -66
- package/packages/bundled-features/src/auth-email-password/signup-token-store.ts +8 -8
- package/packages/bundled-features/src/auth-email-password/testing.ts +3 -3
- package/packages/bundled-features/src/auth-email-password/web/auth-client.ts +57 -57
- package/packages/bundled-features/src/auth-email-password/web/auth-form-primitives.tsx +14 -14
- package/packages/bundled-features/src/auth-email-password/web/auth-gate.tsx +15 -16
- package/packages/bundled-features/src/auth-email-password/web/client-plugin.ts +11 -12
- package/packages/bundled-features/src/auth-email-password/web/confirm-account-unlock-screen.tsx +1 -1
- package/packages/bundled-features/src/auth-email-password/web/constants.ts +3 -3
- package/packages/bundled-features/src/auth-email-password/web/default-topbar-actions.tsx +14 -14
- package/packages/bundled-features/src/auth-email-password/web/forgot-password-screen.tsx +11 -11
- package/packages/bundled-features/src/auth-email-password/web/index.ts +5 -5
- package/packages/bundled-features/src/auth-email-password/web/invite-accept-screen.tsx +17 -17
- package/packages/bundled-features/src/auth-email-password/web/login-screen.tsx +3 -4
- package/packages/bundled-features/src/auth-email-password/web/reset-password-screen.tsx +16 -17
- package/packages/bundled-features/src/auth-email-password/web/session.tsx +34 -34
- package/packages/bundled-features/src/auth-email-password/web/signup-complete-screen.tsx +3 -3
- package/packages/bundled-features/src/auth-email-password/web/signup-screen.tsx +14 -14
- package/packages/bundled-features/src/auth-email-password/web/tenant-switcher.tsx +26 -27
- package/packages/bundled-features/src/auth-email-password/web/use-shell-user.ts +12 -13
- package/packages/bundled-features/src/auth-email-password/web/user-menu.tsx +17 -18
- package/packages/bundled-features/src/auth-email-password/web/verify-email-screen.tsx +11 -12
- package/packages/bundled-features/src/auth-foundation/boot-checks.ts +4 -4
- package/packages/bundled-features/src/auth-foundation/resolve-anonymous-access.ts +4 -4
- package/packages/bundled-features/src/auth-foundation/types.ts +2 -2
- package/packages/bundled-features/src/auth-mfa/handlers/disable.write.ts +3 -3
- package/packages/bundled-features/src/auth-mfa/handlers/enable-confirm-preauth.write.ts +4 -4
- package/packages/bundled-features/src/auth-mfa/handlers/enable-confirm.write.ts +2 -2
- package/packages/bundled-features/src/auth-mfa/handlers/enable-start-preauth.write.ts +1 -1
- package/packages/bundled-features/src/auth-mfa/handlers/reencrypt.job.ts +1 -1
- package/packages/bundled-features/src/auth-mfa/handlers/regenerate-recovery.write.ts +5 -5
- package/packages/bundled-features/src/auth-mfa/handlers/verify.write.ts +1 -1
- package/packages/bundled-features/src/auth-mfa/token-secrets.ts +1 -1
- package/packages/bundled-features/src/auth-mfa/web/client-plugin.ts +2 -2
- package/packages/bundled-features/src/auth-mfa/web/i18n.ts +3 -3
- package/packages/bundled-features/src/auth-mfa/web/index.ts +4 -4
- package/packages/bundled-features/src/auth-mfa/web/mfa-client.ts +17 -16
- package/packages/bundled-features/src/auth-mfa/web/mfa-verify-screen.tsx +6 -6
- package/packages/bundled-features/src/billing-foundation/aggregate-id.ts +10 -11
- package/packages/bundled-features/src/billing-foundation/entities.ts +27 -27
- package/packages/bundled-features/src/billing-foundation/events.ts +22 -21
- package/packages/bundled-features/src/billing-foundation/feature.ts +42 -43
- package/packages/bundled-features/src/billing-foundation/get-subscription-for-tenant.ts +3 -5
- package/packages/bundled-features/src/billing-foundation/handlers/create-checkout-session.write.ts +18 -17
- package/packages/bundled-features/src/billing-foundation/handlers/create-portal-session.write.ts +11 -12
- package/packages/bundled-features/src/billing-foundation/handlers/list-subscriptions.query.ts +4 -4
- package/packages/bundled-features/src/billing-foundation/handlers/process-event.write.ts +20 -20
- package/packages/bundled-features/src/billing-foundation/projection.ts +38 -37
- package/packages/bundled-features/src/billing-foundation/subscription-tier-sync.ts +3 -3
- package/packages/bundled-features/src/billing-foundation/tenant-destroy-hook.ts +7 -8
- package/packages/bundled-features/src/billing-foundation/types.ts +64 -65
- package/packages/bundled-features/src/billing-foundation/web/billing-plans-panel.tsx +4 -4
- package/packages/bundled-features/src/billing-foundation/webhook-handler.ts +1 -1
- package/packages/bundled-features/src/cap-counter/aggregate-id.ts +8 -9
- package/packages/bundled-features/src/cap-counter/constants.ts +11 -12
- package/packages/bundled-features/src/cap-counter/enforce-cap.ts +64 -67
- package/packages/bundled-features/src/cap-counter/entity.ts +29 -29
- package/packages/bundled-features/src/cap-counter/feature.ts +34 -35
- package/packages/bundled-features/src/cap-counter/handlers/increment-rolling.write.ts +31 -31
- package/packages/bundled-features/src/cap-counter/handlers/mark-soft-warned.write.ts +4 -5
- package/packages/bundled-features/src/cap-counter/stock-cap-guard.ts +1 -1
- package/packages/bundled-features/src/cap-counter/with-cap-enforcement.ts +3 -5
- package/packages/bundled-features/src/cap-overview/handlers/caps-usage.query.ts +1 -3
- package/packages/bundled-features/src/cap-overview/handlers/tenant-caps-list.query.ts +1 -1
- package/packages/bundled-features/src/channel-email/smtp-transport.ts +34 -31
- package/packages/bundled-features/src/channel-in-app/handlers/unread-count.query.ts +3 -4
- package/packages/bundled-features/src/compliance-profiles/feature.ts +15 -16
- package/packages/bundled-features/src/compliance-profiles/handlers/for-tenant.query.ts +3 -6
- package/packages/bundled-features/src/compliance-profiles/handlers/list-profiles.query.ts +5 -5
- package/packages/bundled-features/src/compliance-profiles/handlers/needs-profile.query.ts +4 -4
- package/packages/bundled-features/src/compliance-profiles/handlers/set-profile.write.ts +13 -14
- package/packages/bundled-features/src/compliance-profiles/handlers/sub-processors.query.ts +9 -11
- package/packages/bundled-features/src/compliance-profiles/resolve-for-tenant.ts +7 -7
- package/packages/bundled-features/src/compliance-profiles/schema/profile-selection.ts +18 -23
- package/packages/bundled-features/src/compliance-profiles/seeding.ts +14 -15
- package/packages/bundled-features/src/compliance-profiles-ops/handlers/tenants-missing-profile.query.ts +3 -3
- package/packages/bundled-features/src/compliance-profiles-ops/index.ts +2 -2
- package/packages/bundled-features/src/config/handlers/readiness.query.ts +7 -7
- package/packages/bundled-features/src/config/handlers/reencrypt.job.ts +4 -5
- package/packages/bundled-features/src/config/handlers/set.write.ts +4 -4
- package/packages/bundled-features/src/config/resolver.ts +4 -4
- package/packages/bundled-features/src/config/table.ts +10 -10
- package/packages/bundled-features/src/config/write-helpers.ts +1 -1
- package/packages/bundled-features/src/crypto-shredding/handlers/forget-subject.write.ts +13 -12
- package/packages/bundled-features/src/custom-fields/aggregate-id.ts +16 -17
- package/packages/bundled-features/src/custom-fields/entity.ts +49 -47
- package/packages/bundled-features/src/custom-fields/events.ts +7 -8
- package/packages/bundled-features/src/custom-fields/feature.ts +70 -72
- package/packages/bundled-features/src/custom-fields/handlers/clear-custom-field.write.ts +9 -8
- package/packages/bundled-features/src/custom-fields/handlers/define-tenant-field.write.ts +28 -26
- package/packages/bundled-features/src/custom-fields/handlers/delete-system-field.write.ts +6 -7
- package/packages/bundled-features/src/custom-fields/handlers/delete-tenant-field.write.ts +12 -13
- package/packages/bundled-features/src/custom-fields/handlers/set-custom-field.write.ts +25 -28
- package/packages/bundled-features/src/custom-fields/handlers/update-tenant-field.write.ts +6 -6
- package/packages/bundled-features/src/custom-fields/lib/field-access.ts +2 -2
- package/packages/bundled-features/src/custom-fields/lib/parse-serialized-field.ts +1 -1
- package/packages/bundled-features/src/custom-fields/lib/quota.ts +1 -1
- package/packages/bundled-features/src/custom-fields/lib/value-schema.ts +10 -12
- package/packages/bundled-features/src/custom-fields/run-retention.ts +3 -3
- package/packages/bundled-features/src/custom-fields/schemas.ts +14 -14
- package/packages/bundled-features/src/custom-fields/web/client-plugin.tsx +2 -5
- package/packages/bundled-features/src/custom-fields/web/constants.ts +2 -2
- package/packages/bundled-features/src/custom-fields/web/custom-fields-form-section.tsx +26 -26
- package/packages/bundled-features/src/custom-fields/wire-for-entity.ts +65 -67
- package/packages/bundled-features/src/custom-fields/wire-user-data-rights.ts +3 -3
- package/packages/bundled-features/src/data-retention/_internal/parse-override.ts +2 -3
- package/packages/bundled-features/src/data-retention/feature.ts +11 -18
- package/packages/bundled-features/src/data-retention/handlers/policy-for.query.ts +6 -6
- package/packages/bundled-features/src/data-retention/keep-for.ts +17 -17
- package/packages/bundled-features/src/data-retention/override-schema.ts +13 -15
- package/packages/bundled-features/src/data-retention/presets.ts +18 -23
- package/packages/bundled-features/src/data-retention/resolve-for-tenant.ts +1 -1
- package/packages/bundled-features/src/data-retention/resolve-tenant-preset.ts +17 -16
- package/packages/bundled-features/src/data-retention/resolver.ts +33 -32
- package/packages/bundled-features/src/data-retention/run-retention-cleanup.ts +71 -58
- package/packages/bundled-features/src/data-retention/schema/tenant-retention-override.ts +13 -11
- package/packages/bundled-features/src/delivery/feature.ts +3 -3
- package/packages/bundled-features/src/delivery/handlers/log.query.ts +1 -1
- package/packages/bundled-features/src/delivery/tables.ts +9 -8
- package/packages/bundled-features/src/delivery/unsubscribe.ts +4 -4
- package/packages/bundled-features/src/delivery/upsert-preference.ts +3 -4
- package/packages/bundled-features/src/document-ingest-foundation/entity.ts +5 -5
- package/packages/bundled-features/src/document-ingest-foundation/events.ts +2 -2
- package/packages/bundled-features/src/document-ingest-foundation/feature.ts +2 -2
- package/packages/bundled-features/src/document-ingest-foundation/pages.ts +1 -1
- package/packages/bundled-features/src/document-ingest-foundation/tenant-destroy-hook.ts +4 -4
- package/packages/bundled-features/src/feature-toggles/compose-tier-resolver.ts +1 -1
- package/packages/bundled-features/src/feature-toggles/feature.ts +1 -1
- package/packages/bundled-features/src/feature-toggles/global-feature-state-table.ts +1 -1
- package/packages/bundled-features/src/feature-toggles/handlers/registered.query.ts +5 -5
- package/packages/bundled-features/src/feature-toggles/toggle-runtime.ts +1 -1
- package/packages/bundled-features/src/feature-toggles/toggle-sync-signal.ts +1 -1
- package/packages/bundled-features/src/feature-toggles/web/constants.ts +1 -1
- package/packages/bundled-features/src/file-derivatives/feature.ts +2 -2
- package/packages/bundled-features/src/file-derivatives/handlers/public-variant.query.ts +1 -1
- package/packages/bundled-features/src/file-derivatives/presets.ts +1 -1
- package/packages/bundled-features/src/file-foundation/feature.ts +6 -6
- package/packages/bundled-features/src/file-provider-inmemory/feature.ts +16 -16
- package/packages/bundled-features/src/file-provider-s3/feature.ts +16 -16
- package/packages/bundled-features/src/file-provider-s3/lib/s3-provider.ts +6 -6
- package/packages/bundled-features/src/files/feature.ts +6 -6
- package/packages/bundled-features/src/files-tenant-data/handlers/sweep-orphaned-derivatives.job.ts +5 -5
- package/packages/bundled-features/src/files-tenant-data/hooks.ts +24 -26
- package/packages/bundled-features/src/files-tenant-data/index.ts +1 -1
- package/packages/bundled-features/src/folders/feature.ts +1 -1
- package/packages/bundled-features/src/folders/web/folder-manager.tsx +2 -2
- package/packages/bundled-features/src/folders/web/tree.ts +5 -5
- package/packages/bundled-features/src/form-draft/db/queries/cleanup.ts +1 -1
- package/packages/bundled-features/src/form-draft/db/queries/owned-file-refs.ts +1 -1
- package/packages/bundled-features/src/form-draft/entity.ts +3 -3
- package/packages/bundled-features/src/form-draft/feature.ts +4 -5
- package/packages/bundled-features/src/form-draft/handlers/discard.write.ts +1 -1
- package/packages/bundled-features/src/form-draft/release-file-refs.ts +6 -6
- package/packages/bundled-features/src/form-draft/schemas.ts +3 -3
- package/packages/bundled-features/src/form-draft/web/constants.ts +0 -2
- package/packages/bundled-features/src/inbound-mail-foundation/aggregate-id.ts +19 -19
- package/packages/bundled-features/src/inbound-mail-foundation/connect-routes.ts +4 -3
- package/packages/bundled-features/src/inbound-mail-foundation/constants.ts +30 -33
- package/packages/bundled-features/src/inbound-mail-foundation/entities.ts +47 -48
- package/packages/bundled-features/src/inbound-mail-foundation/events.ts +54 -50
- package/packages/bundled-features/src/inbound-mail-foundation/feature.ts +39 -39
- package/packages/bundled-features/src/inbound-mail-foundation/handlers/account-state.ts +8 -8
- package/packages/bundled-features/src/inbound-mail-foundation/handlers/connect-account.write.ts +25 -26
- package/packages/bundled-features/src/inbound-mail-foundation/handlers/disconnect-account.write.ts +7 -7
- package/packages/bundled-features/src/inbound-mail-foundation/handlers/ingest-message.write.ts +50 -51
- package/packages/bundled-features/src/inbound-mail-foundation/handlers/list-accounts.query.ts +8 -8
- package/packages/bundled-features/src/inbound-mail-foundation/handlers/list-messages.query.ts +10 -10
- package/packages/bundled-features/src/inbound-mail-foundation/handlers/scope-visibility.ts +3 -4
- package/packages/bundled-features/src/inbound-mail-foundation/handlers/update-account.write.ts +11 -11
- package/packages/bundled-features/src/inbound-mail-foundation/oauth-state.ts +16 -15
- package/packages/bundled-features/src/inbound-mail-foundation/projection.ts +31 -29
- package/packages/bundled-features/src/inbound-mail-foundation/provider-factory.ts +9 -9
- package/packages/bundled-features/src/inbound-mail-foundation/retention-sweep.ts +45 -41
- package/packages/bundled-features/src/inbound-mail-foundation/tenant-destroy-hook.ts +14 -16
- package/packages/bundled-features/src/inbound-mail-foundation/types.ts +66 -67
- package/packages/bundled-features/src/inbound-mail-foundation/watch-supervisor.ts +69 -68
- package/packages/bundled-features/src/inbound-provider-imap/credential-document.ts +13 -13
- package/packages/bundled-features/src/inbound-provider-imap/feature.ts +42 -40
- package/packages/bundled-features/src/inbound-provider-imap/imap-client.ts +20 -19
- package/packages/bundled-features/src/inbound-provider-inmemory/feature.ts +21 -21
- package/packages/bundled-features/src/jobs/db/queries/retention.ts +2 -2
- package/packages/bundled-features/src/jobs/db/queries/stale-run-sweep.ts +3 -3
- package/packages/bundled-features/src/jobs/events.ts +1 -1
- package/packages/bundled-features/src/jobs/feature.ts +6 -7
- package/packages/bundled-features/src/jobs/handlers/detail.query.ts +4 -4
- package/packages/bundled-features/src/jobs/handlers/list.query.ts +1 -1
- package/packages/bundled-features/src/jobs/handlers/projection-rebuild.job.ts +1 -1
- package/packages/bundled-features/src/jobs/handlers/reindex-entity.job.ts +1 -1
- package/packages/bundled-features/src/jobs/handlers/retry.write.ts +1 -1
- package/packages/bundled-features/src/jobs/job-instant.ts +1 -1
- package/packages/bundled-features/src/jobs/job-run-logger.ts +14 -15
- package/packages/bundled-features/src/jobs/job-run-table.ts +3 -3
- package/packages/bundled-features/src/jobs/screens.ts +1 -1
- package/packages/bundled-features/src/jobs/tenant-job-failure-table.ts +1 -1
- package/packages/bundled-features/src/jobs/tenant-job-run-table.ts +1 -1
- package/packages/bundled-features/src/ledger/entity.ts +5 -5
- package/packages/bundled-features/src/ledger/feature.ts +3 -3
- package/packages/bundled-features/src/ledger/handlers/confirm-schedule-period.write.ts +3 -3
- package/packages/bundled-features/src/ledger/recurring.ts +12 -12
- package/packages/bundled-features/src/ledger/schemas.ts +1 -1
- package/packages/bundled-features/src/ledger/web/constants.ts +2 -2
- package/packages/bundled-features/src/ledger/web/index.ts +7 -7
- package/packages/bundled-features/src/legal-pages/feature.ts +40 -41
- package/packages/bundled-features/src/legal-pages/markdown.ts +3 -3
- package/packages/bundled-features/src/legal-pages/web/client-plugin.ts +23 -24
- package/packages/bundled-features/src/legal-pages/web/index.ts +0 -2
- package/packages/bundled-features/src/mail-foundation/feature.ts +26 -27
- package/packages/bundled-features/src/mail-transport-inmemory/feature.ts +27 -28
- package/packages/bundled-features/src/mail-transport-smtp/feature.ts +20 -20
- package/packages/bundled-features/src/managed-pages/branding.ts +6 -6
- package/packages/bundled-features/src/managed-pages/feature.ts +62 -62
- package/packages/bundled-features/src/managed-pages/handlers/by-slug.query.ts +5 -6
- package/packages/bundled-features/src/managed-pages/handlers/by-tenant-published.query.ts +8 -8
- package/packages/bundled-features/src/managed-pages/handlers/set.write.ts +5 -7
- package/packages/bundled-features/src/managed-pages/screens/page-screens.ts +11 -11
- package/packages/bundled-features/src/managed-pages/seeding.ts +8 -8
- package/packages/bundled-features/src/managed-pages/table.ts +16 -15
- package/packages/bundled-features/src/managed-pages/web/client-plugin.tsx +6 -6
- package/packages/bundled-features/src/managed-pages/web/i18n.ts +1 -1
- package/packages/bundled-features/src/notes-history/entity.ts +4 -4
- package/packages/bundled-features/src/notes-history/feature.ts +2 -2
- package/packages/bundled-features/src/notes-history-user-data/hooks.ts +1 -1
- package/packages/bundled-features/src/page-render/layout.ts +9 -9
- package/packages/bundled-features/src/page-render/markdown.ts +11 -11
- package/packages/bundled-features/src/page-render/security-headers.ts +7 -6
- package/packages/bundled-features/src/personal-access-tokens/feature.ts +5 -5
- package/packages/bundled-features/src/personal-access-tokens/roles.ts +2 -2
- package/packages/bundled-features/src/readiness/handlers/status.query.ts +3 -3
- package/packages/bundled-features/src/renderer-foundation/api.ts +12 -13
- package/packages/bundled-features/src/renderer-foundation/constants.ts +2 -2
- package/packages/bundled-features/src/renderer-foundation/feature.ts +7 -7
- package/packages/bundled-features/src/renderer-foundation/types.ts +11 -12
- package/packages/bundled-features/src/secrets/feature.ts +9 -9
- package/packages/bundled-features/src/secrets/web/constants.ts +2 -2
- package/packages/bundled-features/src/seo/feature.ts +3 -3
- package/packages/bundled-features/src/sessions/constants.ts +1 -1
- package/packages/bundled-features/src/sessions/feature.ts +9 -9
- package/packages/bundled-features/src/sessions/handlers/revoke-all-for-user.write.ts +2 -2
- package/packages/bundled-features/src/sessions/handlers/revoke-all-others.write.ts +2 -2
- package/packages/bundled-features/src/sessions/handlers/revoke.write.ts +1 -1
- package/packages/bundled-features/src/sessions/schema/user-session.ts +4 -4
- package/packages/bundled-features/src/sessions/screens.ts +2 -2
- package/packages/bundled-features/src/sessions/session-callbacks.ts +2 -2
- package/packages/bundled-features/src/sessions/session-revoked-event.ts +2 -2
- package/packages/bundled-features/src/shared/assert-no-where-rule-in-ownership-write.ts +1 -1
- package/packages/bundled-features/src/shared/decrypt-stored-pii.ts +1 -1
- package/packages/bundled-features/src/shared/encrypt-for-direct-write.ts +1 -1
- package/packages/bundled-features/src/shared/map-with-concurrency.ts +5 -4
- package/packages/bundled-features/src/shared/parent-visibility.ts +2 -2
- package/packages/bundled-features/src/shared/password-hashing.ts +1 -1
- package/packages/bundled-features/src/shared/signup-handover.ts +1 -2
- package/packages/bundled-features/src/shared/single-use-token-store.ts +1 -1
- package/packages/bundled-features/src/subscription-mollie/constants.ts +15 -17
- package/packages/bundled-features/src/subscription-mollie/feature.ts +41 -42
- package/packages/bundled-features/src/subscription-mollie/index.ts +3 -3
- package/packages/bundled-features/src/subscription-mollie/plugin-methods.ts +17 -16
- package/packages/bundled-features/src/subscription-mollie/verify-webhook.ts +34 -34
- package/packages/bundled-features/src/subscription-stripe/constants.ts +4 -6
- package/packages/bundled-features/src/subscription-stripe/feature.ts +44 -43
- package/packages/bundled-features/src/subscription-stripe/index.ts +6 -6
- package/packages/bundled-features/src/subscription-stripe/plugin-methods.ts +22 -27
- package/packages/bundled-features/src/subscription-stripe/runtime.ts +2 -2
- package/packages/bundled-features/src/subscription-stripe/verify-webhook.ts +62 -64
- package/packages/bundled-features/src/tags/feature.ts +3 -3
- package/packages/bundled-features/src/tags/screens.ts +1 -1
- package/packages/bundled-features/src/template-resolver/api.ts +10 -10
- package/packages/bundled-features/src/template-resolver/handlers/find-by-id.query.ts +5 -5
- package/packages/bundled-features/src/template-resolver/handlers/list.query.ts +1 -1
- package/packages/bundled-features/src/template-resolver/handlers/shared.ts +2 -2
- package/packages/bundled-features/src/template-resolver/handlers/template-write.ts +3 -3
- package/packages/bundled-features/src/template-resolver/handlers/upsert-system.write.ts +3 -4
- package/packages/bundled-features/src/template-resolver/handlers/upsert-tenant.write.ts +4 -5
- package/packages/bundled-features/src/template-resolver/seeding.ts +4 -4
- package/packages/bundled-features/src/template-resolver/table.ts +13 -14
- package/packages/bundled-features/src/template-resolver/web/client-plugin.tsx +2 -2
- package/packages/bundled-features/src/tenant/feature.ts +7 -7
- package/packages/bundled-features/src/tenant/handlers/member-directory.query.ts +1 -1
- package/packages/bundled-features/src/tenant/handlers/members.query.ts +1 -1
- package/packages/bundled-features/src/tenant/handlers/memberships.query.ts +1 -1
- package/packages/bundled-features/src/tenant/handlers/team-list.query.ts +1 -1
- package/packages/bundled-features/src/tenant/handlers/tenant-directory.query.ts +1 -1
- package/packages/bundled-features/src/tenant/invitation-table.ts +37 -40
- package/packages/bundled-features/src/tenant/membership-table.ts +3 -3
- package/packages/bundled-features/src/tenant/schema/tenant.ts +7 -9
- package/packages/bundled-features/src/tenant/screens.ts +1 -1
- package/packages/bundled-features/src/tenant/seeding.ts +19 -18
- package/packages/bundled-features/src/tenant/testing.ts +5 -6
- package/packages/bundled-features/src/tenant/web/constants.ts +2 -2
- package/packages/bundled-features/src/tenant-handover/events.ts +5 -7
- package/packages/bundled-features/src/tenant-handover/feature.ts +1 -1
- package/packages/bundled-features/src/tenant-handover/grant.ts +1 -1
- package/packages/bundled-features/src/tenant-handover/handlers/claim.write.ts +1 -1
- package/packages/bundled-features/src/tenant-handover/move-entity-graph.ts +8 -9
- package/packages/bundled-features/src/tenant-handover/signup-handover-provider.ts +1 -2
- package/packages/bundled-features/src/tenant-handover/transfer-graph.ts +4 -5
- package/packages/bundled-features/src/tenant-lifecycle/boot-checks.ts +1 -1
- package/packages/bundled-features/src/tenant-lifecycle/feature.ts +1 -1
- package/packages/bundled-features/src/tenant-lifecycle/run-tenant-destroy.ts +2 -2
- package/packages/bundled-features/src/tenant-lifecycle/stages.ts +1 -1
- package/packages/bundled-features/src/tenant-settings/constants.ts +1 -1
- package/packages/bundled-features/src/tenant-settings/tenant-defaults.ts +12 -5
- package/packages/bundled-features/src/tier-engine/aggregate-id.ts +15 -16
- package/packages/bundled-features/src/tier-engine/compose-app.ts +14 -14
- package/packages/bundled-features/src/tier-engine/entity.ts +18 -19
- package/packages/bundled-features/src/tier-engine/feature.ts +88 -87
- package/packages/bundled-features/src/tier-engine/handlers/active-tier.query.ts +6 -7
- package/packages/bundled-features/src/tier-engine/handlers/get-tenant-tier.query.ts +4 -4
- package/packages/bundled-features/src/tier-engine/handlers/set-tenant-tier.write.ts +8 -8
- package/packages/bundled-features/src/tier-engine/tier-resolver.ts +2 -2
- package/packages/bundled-features/src/tier-engine/trial.ts +13 -13
- package/packages/bundled-features/src/tier-engine/web/index.ts +4 -4
- package/packages/bundled-features/src/user/db/queries/stream-tenant-backfill.ts +8 -8
- package/packages/bundled-features/src/user/handlers/create.write.ts +4 -4
- package/packages/bundled-features/src/user/schema/user.ts +45 -44
- package/packages/bundled-features/src/user/seeding.ts +40 -40
- package/packages/bundled-features/src/user/testing.ts +3 -3
- package/packages/bundled-features/src/user-data-rights/audit-download.ts +27 -28
- package/packages/bundled-features/src/user-data-rights/boot-checks.ts +1 -1
- package/packages/bundled-features/src/user-data-rights/deletion-token.ts +1 -1
- package/packages/bundled-features/src/user-data-rights/feature.ts +112 -113
- package/packages/bundled-features/src/user-data-rights/handlers/cancel-deletion.write.ts +9 -9
- package/packages/bundled-features/src/user-data-rights/handlers/confirm-deletion-by-token.write.ts +8 -8
- package/packages/bundled-features/src/user-data-rights/handlers/download-by-job.query.ts +29 -30
- package/packages/bundled-features/src/user-data-rights/handlers/download-by-token.query.ts +40 -42
- package/packages/bundled-features/src/user-data-rights/handlers/export-status.query.ts +8 -9
- package/packages/bundled-features/src/user-data-rights/handlers/lift-restriction.write.ts +7 -8
- package/packages/bundled-features/src/user-data-rights/handlers/list-download-attempts.query.ts +2 -2
- package/packages/bundled-features/src/user-data-rights/handlers/my-audit-log.query.ts +4 -4
- package/packages/bundled-features/src/user-data-rights/handlers/request-deletion-by-email.write.ts +30 -29
- package/packages/bundled-features/src/user-data-rights/handlers/request-deletion.write.ts +15 -18
- package/packages/bundled-features/src/user-data-rights/handlers/request-export.write.ts +42 -41
- package/packages/bundled-features/src/user-data-rights/handlers/restrict-account.write.ts +22 -19
- package/packages/bundled-features/src/user-data-rights/handlers/run-forget-cleanup.write.ts +8 -8
- package/packages/bundled-features/src/user-data-rights/index.ts +8 -10
- package/packages/bundled-features/src/user-data-rights/lib/default-mailers.ts +3 -3
- package/packages/bundled-features/src/user-data-rights/lib/update-user-lifecycle.ts +24 -27
- package/packages/bundled-features/src/user-data-rights/run-export-jobs.ts +166 -276
- package/packages/bundled-features/src/user-data-rights/run-forget-cleanup.ts +85 -107
- package/packages/bundled-features/src/user-data-rights/run-user-export.ts +67 -69
- package/packages/bundled-features/src/user-data-rights/schema/download-attempt.ts +11 -11
- package/packages/bundled-features/src/user-data-rights/schema/download-token.ts +37 -41
- package/packages/bundled-features/src/user-data-rights/schema/export-job.ts +65 -67
- package/packages/bundled-features/src/user-data-rights/token-helpers.ts +21 -25
- package/packages/bundled-features/src/user-data-rights/web/client-plugin.tsx +6 -6
- package/packages/bundled-features/src/user-data-rights/web/confirm-deletion-screen.tsx +6 -5
- package/packages/bundled-features/src/user-data-rights/web/constants.ts +1 -1
- package/packages/bundled-features/src/user-data-rights/web/index.ts +5 -5
- package/packages/bundled-features/src/user-data-rights/web/privacy-center-screen.tsx +14 -13
- package/packages/bundled-features/src/user-data-rights/web/public-deletion-gate.tsx +13 -12
- package/packages/bundled-features/src/user-data-rights/web/request-deletion-screen.tsx +6 -6
- package/packages/bundled-features/src/user-data-rights/zip-path.ts +41 -40
- package/packages/bundled-features/src/user-data-rights-defaults/feature.ts +15 -15
- package/packages/bundled-features/src/user-data-rights-defaults/hooks/delivery-attempt.userdata-hook.ts +3 -5
- package/packages/bundled-features/src/user-data-rights-defaults/hooks/file-ref.userdata-hook.ts +45 -51
- package/packages/bundled-features/src/user-data-rights-defaults/hooks/job-run.userdata-hook.ts +2 -2
- package/packages/bundled-features/src/user-data-rights-defaults/hooks/notification-preference.userdata-hook.ts +1 -1
- package/packages/bundled-features/src/user-data-rights-defaults/hooks/user-session.userdata-hook.ts +3 -3
- package/packages/bundled-features/src/user-data-rights-defaults/hooks/user.userdata-hook.ts +32 -31
- package/packages/bundled-features/src/user-profile/handlers/change-email.write.ts +13 -13
- package/packages/bundled-features/src/user-profile/index.ts +3 -3
- package/packages/bundled-features/src/user-profile/web/client-plugin.ts +1 -1
- package/packages/bundled-features/src/user-profile/web/constants.ts +1 -1
- package/packages/bundled-features/src/user-profile/web/profile-screen.tsx +1 -1
- package/packages/bundled-features/src/workflow-runner/aggregate-id.ts +1 -1
- package/packages/bundled-features/src/workflow-runner/event-subscriber.ts +4 -5
- package/packages/bundled-features/src/workflow-runner/event-trigger.ts +4 -15
- package/packages/bundled-features/src/workflow-runner/feature.ts +2 -2
- package/packages/bundled-features/src/workflow-runner/handlers/resume-run.write.ts +4 -4
- package/packages/bundled-features/src/workflow-runner/pending-projection.ts +6 -7
- package/packages/bundled-features/src/workflow-runner/runner.ts +6 -6
- package/packages/bundled-features/src/workflow-runner/tables.ts +6 -6
- package/packages/bundled-features/src/workflow-runner/workflow-registry.ts +1 -1
|
@@ -13,10 +13,9 @@ import {
|
|
|
13
13
|
import { GLOBAL_ROLE_OPTIONS } from "../web/constants.ts";
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
|
-
* User
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* gleiches Pattern wie ROLES.SystemAdmin).
|
|
16
|
+
* User lifecycle status. This is the single source of truth used by the
|
|
17
|
+
* auth middleware, forget job, and restriction handler instead of duplicated
|
|
18
|
+
* magic strings, following the same pattern as ROLES.SystemAdmin.
|
|
20
19
|
*/
|
|
21
20
|
export const USER_STATUS = {
|
|
22
21
|
Active: "active",
|
|
@@ -28,26 +27,27 @@ export const USER_STATUS = {
|
|
|
28
27
|
export type UserStatus = (typeof USER_STATUS)[keyof typeof USER_STATUS];
|
|
29
28
|
|
|
30
29
|
/**
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
30
|
+
* Display strings anonymized by userDeleteHook. Constants keep i18n mapping
|
|
31
|
+
* possible and prevent drift. The default is German; app authors can
|
|
32
|
+
* translate it through the i18n system if desired.
|
|
34
33
|
*/
|
|
35
34
|
export const USER_DELETED_DISPLAY_NAME = "[Geloescht]";
|
|
36
35
|
export const USER_ANONYMIZED_DISPLAY_NAME = "[Anonymisiert]";
|
|
37
36
|
|
|
38
37
|
/**
|
|
39
|
-
* Email
|
|
40
|
-
* —
|
|
41
|
-
*
|
|
42
|
-
* `.invalid
|
|
38
|
+
* Email pseudonyms used after forgetting. `<prefix>-<userId>@anonymized.invalid`
|
|
39
|
+
* — the userId suffix is permitted as a pseudo-audit marker for operator
|
|
40
|
+
* tracing; the user ID itself is a UUID, not PII.
|
|
41
|
+
* The `.invalid` TLD is reserved by RFC2606, so the address can never be
|
|
42
|
+
* delivered.
|
|
43
43
|
*/
|
|
44
44
|
export const USER_DELETED_EMAIL_PREFIX = "deleted";
|
|
45
45
|
export const USER_ANONYMIZED_EMAIL_PREFIX = "anonymized";
|
|
46
46
|
export const USER_ANONYMIZED_EMAIL_DOMAIN = "anonymized.invalid";
|
|
47
47
|
|
|
48
|
-
// Tuple form
|
|
49
|
-
// Object.values(USER_STATUS)
|
|
50
|
-
// type
|
|
48
|
+
// Tuple form for createSelectField (requires a non-empty readonly tuple).
|
|
49
|
+
// Object.values(USER_STATUS) would be string[]; the static tuple preserves
|
|
50
|
+
// type safety.
|
|
51
51
|
const USER_STATUS_OPTIONS = [
|
|
52
52
|
USER_STATUS.Active,
|
|
53
53
|
USER_STATUS.Restricted,
|
|
@@ -63,10 +63,10 @@ export const userEntity = createEntity({
|
|
|
63
63
|
table: "read_users",
|
|
64
64
|
softDelete: true,
|
|
65
65
|
// Tenant-independent identity aggregate — its event stream lives on
|
|
66
|
-
// SYSTEM_TENANT_ID instead of whichever tenant happened to create it
|
|
66
|
+
// SYSTEM_TENANT_ID instead of whichever tenant happened to create it.
|
|
67
67
|
systemStream: true,
|
|
68
68
|
// Every row lives on SYSTEM_TENANT_ID; writes with another tenantId are
|
|
69
|
-
// rejected
|
|
69
|
+
// rejected.
|
|
70
70
|
tenancy: "global",
|
|
71
71
|
fields: {
|
|
72
72
|
// Identity — anyone who can see the user can read the email, but only
|
|
@@ -101,17 +101,17 @@ export const userEntity = createEntity({
|
|
|
101
101
|
}),
|
|
102
102
|
|
|
103
103
|
// Profile — user-editable. Real name in most apps → PII. Searchable via
|
|
104
|
-
// the derived Meili index; events/projection stay ciphertext
|
|
104
|
+
// the derived Meili index; events/projection stay ciphertext.
|
|
105
105
|
displayName: createTextField({
|
|
106
106
|
required: true,
|
|
107
107
|
maxLength: 100,
|
|
108
108
|
personal: "self",
|
|
109
109
|
find: "fuzzy",
|
|
110
110
|
}),
|
|
111
|
-
// No default here — tenant-settings owns the app-wide locale default
|
|
111
|
+
// No default here — tenant-settings owns the app-wide locale default.
|
|
112
112
|
locale: createTextField({ maxLength: 10, personal: false, reason: "technical_reference" }),
|
|
113
113
|
// No default here — mirrors locale: ctx.tz falls back to tenant.timezone
|
|
114
|
-
// (then "UTC") when unset, see buildHandlerContext
|
|
114
|
+
// (then "UTC") when unset, see buildHandlerContext.
|
|
115
115
|
timezone: createTzField(),
|
|
116
116
|
|
|
117
117
|
// Which tenant should this user land in on next login. Set by the login
|
|
@@ -145,21 +145,22 @@ export const userEntity = createEntity({
|
|
|
145
145
|
access: { write: access.privileged },
|
|
146
146
|
}),
|
|
147
147
|
|
|
148
|
-
//
|
|
149
|
-
// - "active":
|
|
150
|
-
// - "restricted": Art. 18
|
|
151
|
-
//
|
|
148
|
+
// User lifecycle status for user-data-rights.
|
|
149
|
+
// - "active": Normal state; all operations are allowed.
|
|
150
|
+
// - "restricted": Art. 18 restriction — login is blocked and every
|
|
151
|
+
// live session is rejected by sessionChecker
|
|
152
152
|
// ("blocked"). Recovery via lift-restriction
|
|
153
|
-
// (openToAll, session
|
|
154
|
-
// - "deletionRequested": delete-account
|
|
155
|
-
//
|
|
156
|
-
// (
|
|
157
|
-
//
|
|
158
|
-
// - "deleted": Forget executed
|
|
159
|
-
// softDelete. Login
|
|
153
|
+
// (openToAll, independent of the session).
|
|
154
|
+
// - "deletionRequested": delete-account was called and gracePeriodEnd set;
|
|
155
|
+
// login is blocked. Existing sessions remain LIVE
|
|
156
|
+
// (reversible), so the user can return to "active"
|
|
157
|
+
// via cancel-deletion.
|
|
158
|
+
// - "deleted": Forget was executed after the grace period; the row
|
|
159
|
+
// was anonymized via softDelete. Login is blocked and
|
|
160
|
+
// the session is "blocked".
|
|
160
161
|
//
|
|
161
|
-
//
|
|
162
|
-
// execute-forget
|
|
162
|
+
// Write access is privileged: only the request-deletion / restrict / lift /
|
|
163
|
+
// execute-forget handlers (all in SYSTEM context) may change the status.
|
|
163
164
|
status: createSelectField({
|
|
164
165
|
required: true,
|
|
165
166
|
default: USER_STATUS.Active,
|
|
@@ -168,22 +169,22 @@ export const userEntity = createEntity({
|
|
|
168
169
|
access: { write: access.privileged },
|
|
169
170
|
}),
|
|
170
171
|
|
|
171
|
-
//
|
|
172
|
-
//
|
|
173
|
-
//
|
|
174
|
-
//
|
|
175
|
-
// (= now() + Compliance-Profile.userRights.gracePeriod),
|
|
176
|
-
// cancel-deletion
|
|
172
|
+
// When a pending forget may actually be executed.
|
|
173
|
+
// The user-data-rights cron job checks daily whether gracePeriodEnd < now()
|
|
174
|
+
// and then triggers the EXT_USER_DATA hooks. NULL means no forget is pending;
|
|
175
|
+
// delete-account sets it to
|
|
176
|
+
// (= now() + Compliance-Profile.userRights.gracePeriod), and
|
|
177
|
+
// cancel-deletion resets it.
|
|
177
178
|
gracePeriodEnd: createTimestampField({
|
|
178
179
|
access: { write: access.privileged },
|
|
179
180
|
}),
|
|
180
181
|
|
|
181
|
-
// Replay
|
|
182
|
-
//
|
|
183
|
-
//
|
|
184
|
-
//
|
|
185
|
-
// (
|
|
186
|
-
//
|
|
182
|
+
// Replay protection for the anonymous email-token deletion flow.
|
|
183
|
+
// request-deletion-by-email sets one UUID per email request, and
|
|
184
|
+
// cancel-deletion clears it. confirm-deletion-by-token incorporates this ID
|
|
185
|
+
// into the token's HMAC purpose, so a token replayed after cancellation
|
|
186
|
+
// (while still within its TTL) no longer verifies against the cleared or
|
|
187
|
+
// renewed ID. NULL means no email request is pending.
|
|
187
188
|
pendingDeletionRequestId: createTextField({
|
|
188
189
|
maxLength: 36,
|
|
189
190
|
access: { write: access.privileged },
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
// Testing
|
|
2
|
-
//
|
|
3
|
-
// `UserHandlers.create`,
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
1
|
+
// Testing helper for the user feature. `seedUser` creates a user directly
|
|
2
|
+
// through the event-store executor—the same path as the real
|
|
3
|
+
// `UserHandlers.create`, but without access checks or ConflictError on
|
|
4
|
+
// duplicates. It is idempotent and add-only via the `email` column: an
|
|
5
|
+
// existing user returns without emitting an event. There is no update path;
|
|
6
|
+
// profile changes go through the regular handler.
|
|
7
7
|
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
//
|
|
8
|
+
// Directly calling `db.insert(userTable)` would bypass the event store, so no
|
|
9
|
+
// `user.created` event would be emitted and no MSP consumers (audit,
|
|
10
|
+
// search-index) would see the seed. The executor path emits the event and
|
|
11
|
+
// writes the projection row in one transaction.
|
|
12
12
|
|
|
13
13
|
import { computeBlindIndex, configuredBlindIndexKey } from "@cosmicdrift/kumiko-framework/crypto";
|
|
14
14
|
import {
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
} from "@cosmicdrift/kumiko-framework/db";
|
|
20
20
|
import type { SessionUser } from "@cosmicdrift/kumiko-framework/engine";
|
|
21
21
|
import { TestUsers } from "@cosmicdrift/kumiko-framework/seeding";
|
|
22
|
-
// kumiko-lint-ignore cross-feature-import shares the postSave-hooks fixture contract with tenant/seeding
|
|
22
|
+
// kumiko-lint-ignore cross-feature-import shares the postSave-hooks fixture contract with tenant/seeding
|
|
23
23
|
import { fireEntityPostSave, type SeedTenantHooks } from "../tenant/seeding.ts";
|
|
24
24
|
import { userEntity, userTable } from "./schema/user.ts";
|
|
25
25
|
|
|
@@ -28,48 +28,48 @@ const userExecutor = createEventStoreExecutor(userTable, userEntity, { entityNam
|
|
|
28
28
|
export type SeedUserOptions = {
|
|
29
29
|
readonly email: string;
|
|
30
30
|
readonly displayName: string;
|
|
31
|
-
/** Optional
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
31
|
+
/** Optional pre-hashed password. For plain-password tests, prefer the
|
|
32
|
+
* convenience wrapper from
|
|
33
|
+
* `@cosmicdrift/kumiko-bundled-features/auth-email-password/seeding`,
|
|
34
|
+
* which performs argon2 hashing. */
|
|
35
35
|
readonly passwordHash?: string;
|
|
36
36
|
readonly locale?: string;
|
|
37
|
-
/** Global roles
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
37
|
+
/** Global roles—stored in users.roles as jsonb string[].
|
|
38
|
+
* The login handler merges them into the session roles alongside tenant-
|
|
39
|
+
* membership roles. Default: empty array. Typical example:
|
|
40
|
+
* `["SystemAdmin"]` for the platform operator. */
|
|
41
41
|
readonly roles?: readonly string[];
|
|
42
|
-
/** Initial
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
42
|
+
/** Initial state for emailVerified. Default: false. The required
|
|
43
|
+
* verification flow must explicitly set "true" when email ownership has
|
|
44
|
+
* already been proven—for example, in a Magic-Link signup where the user
|
|
45
|
+
* clicked the email link before the account was created. */
|
|
46
46
|
readonly emailVerified?: boolean;
|
|
47
47
|
readonly by?: SessionUser;
|
|
48
48
|
};
|
|
49
49
|
|
|
50
50
|
/**
|
|
51
|
-
*
|
|
52
|
-
* Idempotent add-only
|
|
53
|
-
*
|
|
51
|
+
* Seeds a user. Returns the userId (existing or newly created).
|
|
52
|
+
* Idempotent and add-only via the `email` column: if a user with this
|
|
53
|
+
* email exists, its ID is returned without a new insert.
|
|
54
54
|
*/
|
|
55
55
|
export async function seedUser(
|
|
56
56
|
db: DbConnection,
|
|
57
57
|
options: SeedUserOptions,
|
|
58
58
|
// Optional, append-only — same rationale as tenant/seeding's seedTenant
|
|
59
|
-
// hooks param
|
|
59
|
+
// hooks param: fires user's postSave hooks (e.g. a Welcome-
|
|
60
60
|
// notification hook keyed off `allOf: "user"`) for fixtures/self-signup
|
|
61
61
|
// that opt in. Omit to keep today's hook-less behavior.
|
|
62
62
|
hooks?: SeedTenantHooks,
|
|
63
63
|
): Promise<{ id: string }> {
|
|
64
64
|
const by = options.by ?? TestUsers.systemAdmin;
|
|
65
|
-
// executor.create
|
|
66
|
-
//
|
|
67
|
-
//
|
|
65
|
+
// executor.create expects a TenantDb (with an .insert() API). Although
|
|
66
|
+
// User is tenant-agnostic (it has no tenant_id column), the runtime
|
|
67
|
+
// interface requires this wrapper.
|
|
68
68
|
const tdb = createTenantDb({ db, tenantId: by.tenantId, mode: "system" });
|
|
69
69
|
|
|
70
70
|
const existing = await fetchOne(db, userTable, { email: options.email, isDeleted: false });
|
|
71
|
-
// @cast-boundary db-row: users.id
|
|
72
|
-
//
|
|
71
|
+
// @cast-boundary db-row: users.id is a uuid column (string), and fetchOne
|
|
72
|
+
// returns the projection row as Record<string, unknown>.
|
|
73
73
|
if (existing) {
|
|
74
74
|
const id = existing["id"] as string;
|
|
75
75
|
if (options.emailVerified === true) {
|
|
@@ -100,7 +100,7 @@ export async function seedUser(
|
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
// A re-run seed onto a row created before emailVerified flipped to true must
|
|
103
|
-
// still set it
|
|
103
|
+
// still set it — via the executor, so it lands as a real `.updated` event.
|
|
104
104
|
export async function reconcileSeededUserEmailVerified(
|
|
105
105
|
db: DbConnection,
|
|
106
106
|
existingRow: Record<string, unknown>,
|
|
@@ -108,8 +108,8 @@ export async function reconcileSeededUserEmailVerified(
|
|
|
108
108
|
): Promise<void> {
|
|
109
109
|
// skip: already verified, nothing to reconcile
|
|
110
110
|
if (existingRow["emailVerified"] === true) return;
|
|
111
|
-
// @cast-boundary db-row: users.id
|
|
112
|
-
//
|
|
111
|
+
// @cast-boundary db-row: users.id is a uuid column (string), and fetchOne
|
|
112
|
+
// returns the projection row as Record<string, unknown>.
|
|
113
113
|
const id = existingRow["id"] as string;
|
|
114
114
|
const tdb = createTenantDb({ db, tenantId: by.tenantId, mode: "system" });
|
|
115
115
|
const result = await userExecutor.update(
|
|
@@ -173,11 +173,11 @@ export async function rewriteSeededUserEmail(
|
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
175
|
|
|
176
|
-
//
|
|
177
|
-
//
|
|
178
|
-
//
|
|
179
|
-
//
|
|
180
|
-
//
|
|
176
|
+
// Extracts the `id` column from the executor.create result. The executor
|
|
177
|
+
// returns a Record<string, unknown> (the projection row), into which the DB
|
|
178
|
+
// writes the aggregate ID. We validate it at runtime instead of using a
|
|
179
|
+
// blind `as { id: string }` cast, so an API contract violation throws an
|
|
180
|
+
// explicit error rather than surfacing downstream as an undefined-value bug.
|
|
181
181
|
function extractId(data: unknown, who: string): string {
|
|
182
182
|
if (typeof data === "object" && data !== null && "id" in data) {
|
|
183
183
|
const id = (data as { id: unknown }).id; // @cast-boundary engine-bridge
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
// /testing re-
|
|
2
|
-
//
|
|
3
|
-
//
|
|
1
|
+
// /testing re-exports /seeding. See ../tenant/testing.ts for the
|
|
2
|
+
// reason: helpers are shared between tests and Dev-Server bootstrap,
|
|
3
|
+
// and /seeding is the stable home.
|
|
4
4
|
|
|
5
5
|
export * from "./seeding.ts";
|
|
@@ -1,19 +1,18 @@
|
|
|
1
|
-
// Audit
|
|
1
|
+
// Audit helper for the download endpoint.
|
|
2
2
|
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
3
|
+
// During a download (token path or job path), audit fields on the token row
|
|
4
|
+
// are updated:
|
|
5
5
|
// - useCount + 1
|
|
6
6
|
// - lastUsedAt = now
|
|
7
|
-
// - lastUsedFromIp = caller
|
|
8
|
-
// - lastUsedUserAgent = UA
|
|
7
|
+
// - lastUsedFromIp = caller IP (X-Forwarded-For or connection IP)
|
|
8
|
+
// - lastUsedUserAgent = UA header
|
|
9
9
|
//
|
|
10
|
-
// **Best-
|
|
11
|
-
//
|
|
12
|
-
//
|
|
13
|
-
// (kein download-block bei race).
|
|
10
|
+
// **Best-effort update:** version conflicts (two downloads racing to update)
|
|
11
|
+
// are silently swallowed — the audit records the "last use", not "all uses".
|
|
12
|
+
// The second download still succeeds (a race does not block the download).
|
|
14
13
|
//
|
|
15
|
-
// **ES via tokenCrud.update:**
|
|
16
|
-
//
|
|
14
|
+
// **ES via tokenCrud.update:** no direct UPDATE, so the event-store and tenant
|
|
15
|
+
// consistency rules remain in effect.
|
|
17
16
|
|
|
18
17
|
import type { DbRunner } from "@cosmicdrift/kumiko-framework/db";
|
|
19
18
|
import { createEventStoreExecutor, createTenantDb } from "@cosmicdrift/kumiko-framework/db";
|
|
@@ -34,11 +33,11 @@ export interface RecordDownloadUseArgs {
|
|
|
34
33
|
readonly tokenVersion: number;
|
|
35
34
|
readonly tokenUseCount: number;
|
|
36
35
|
/**
|
|
37
|
-
* Tenant
|
|
38
|
-
* tenant-
|
|
39
|
-
*
|
|
40
|
-
* job.requestedFromTenantId —
|
|
41
|
-
*
|
|
36
|
+
* Tenant for the system-mode TenantDb. ExportDownloadToken is
|
|
37
|
+
* tenant-agnostic (1:1 with the tenant-agnostic job), but the event-store
|
|
38
|
+
* stream lookup requires a tenant context. We use
|
|
39
|
+
* job.requestedFromTenantId — the same identity used when creating the
|
|
40
|
+
* token in the worker.
|
|
42
41
|
*/
|
|
43
42
|
readonly tenantId: TenantId;
|
|
44
43
|
readonly now: Instant;
|
|
@@ -47,9 +46,9 @@ export interface RecordDownloadUseArgs {
|
|
|
47
46
|
}
|
|
48
47
|
|
|
49
48
|
/**
|
|
50
|
-
* Audit
|
|
51
|
-
* version
|
|
52
|
-
*
|
|
49
|
+
* Audit update: useCount, lastUsedAt, IP, and UA. Best-effort —
|
|
50
|
+
* version conflicts (parallel downloads) are swallowed, so the download
|
|
51
|
+
* still succeeds.
|
|
53
52
|
*/
|
|
54
53
|
export async function recordDownloadUse(args: RecordDownloadUseArgs): Promise<void> {
|
|
55
54
|
const { db, tokenId, tokenVersion, tokenUseCount, tenantId, now, ip, userAgent } = args;
|
|
@@ -72,15 +71,15 @@ export async function recordDownloadUse(args: RecordDownloadUseArgs): Promise<vo
|
|
|
72
71
|
tdb,
|
|
73
72
|
)
|
|
74
73
|
.catch(() => {
|
|
75
|
-
// version
|
|
76
|
-
//
|
|
77
|
-
//
|
|
74
|
+
// A version conflict means a parallel download already incremented
|
|
75
|
+
// useCount. Keep the first download's audit entry (lastUsedAt, etc.);
|
|
76
|
+
// do not block the download.
|
|
78
77
|
});
|
|
79
78
|
}
|
|
80
79
|
|
|
81
|
-
// extractCallerIp
|
|
82
|
-
//
|
|
83
|
-
//
|
|
80
|
+
// extractCallerIp lives in feature.ts (extractAuditMeta) — query handlers
|
|
81
|
+
// have no direct header access because they are transport-agnostic. The
|
|
82
|
+
// httpRoute wrapper extracts it and places it in payload.auditMeta.
|
|
84
83
|
|
|
85
84
|
export type DownloadAttemptResult = "notFound" | "expired" | "failed" | "signedUrlNotSupported";
|
|
86
85
|
|
|
@@ -97,9 +96,9 @@ export interface RecordInvalidAttemptArgs {
|
|
|
97
96
|
readonly userAgent: string | null;
|
|
98
97
|
}
|
|
99
98
|
|
|
100
|
-
// Best-effort INSERT
|
|
101
|
-
//
|
|
102
|
-
//
|
|
99
|
+
// Best-effort INSERT into read_download_attempts. Errors in the audit path
|
|
100
|
+
// must not kill the download endpoint: the user should receive their 404,
|
|
101
|
+
// not a 500; failures are silently swallowed.
|
|
103
102
|
export async function recordInvalidAttempt(args: RecordInvalidAttemptArgs): Promise<void> {
|
|
104
103
|
const { db, tenantId, now } = args;
|
|
105
104
|
const executor = createSystemUser(tenantId);
|
|
@@ -12,7 +12,7 @@ import { entitiesOf } from "../shared/index.ts";
|
|
|
12
12
|
// only; runtime no-ops (a delete hook that silently skips) are not detectable
|
|
13
13
|
// here — those are covered by the export/forget integration tests.
|
|
14
14
|
//
|
|
15
|
-
// Registered as an `r.bootCheck()` by this feature
|
|
15
|
+
// Registered as an `r.bootCheck()` by this feature — EXT_USER_DATA is
|
|
16
16
|
// owned by user-data-rights (r.extendsRegistrar(EXT_USER_DATA, {})), so any
|
|
17
17
|
// r.useExtension(EXT_USER_DATA, ...) usage across the app already requires
|
|
18
18
|
// user-data-rights to be mounted (boot-validator's extension-provider check
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// subject is the user, the anchor is the pending request id stored on the
|
|
3
3
|
// user row. Minting and verification both run through
|
|
4
4
|
// shared/row-bound-grant, so a token from a cancelled cycle (id nulled) or a
|
|
5
|
-
// superseded one (row holds a newer id) fails verification
|
|
5
|
+
// superseded one (row holds a newer id) fails verification.
|
|
6
6
|
//
|
|
7
7
|
// The purpose string and the anchoring are unchanged from the hand-rolled
|
|
8
8
|
// version this replaced, so tokens stay byte-compatible.
|