@cosmicdrift/kumiko-samples 0.366.0 → 0.368.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 -2
- package/packages/bundled-features/src/audit/handlers/details.query.ts +1 -1
- package/packages/bundled-features/src/audit/handlers/list.query.ts +1 -1
- package/packages/bundled-features/src/audit/run-escape-hatch-retention.ts +5 -5
- package/packages/bundled-features/src/auth-email-password/bootstrap.ts +1 -1
- package/packages/bundled-features/src/auth-email-password/handlers/invite-accept-with-login.write.ts +10 -3
- package/packages/bundled-features/src/auth-email-password/handlers/invite-accept.write.ts +10 -3
- 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 +6 -2
- package/packages/bundled-features/src/auth-email-password/handlers/signup-confirm.write.ts +1 -1
- package/packages/bundled-features/src/auth-email-password/seeding.ts +2 -2
- package/packages/bundled-features/src/auth-foundation/feature.ts +43 -34
- package/packages/bundled-features/src/auth-foundation/index.ts +1 -0
- package/packages/bundled-features/src/auth-mfa/db/queries.ts +5 -2
- package/packages/bundled-features/src/auth-mfa/handlers/enable-confirm-preauth.write.ts +1 -1
- 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 +2 -2
- package/packages/bundled-features/src/auth-mfa/handlers/status.query.ts +1 -1
- package/packages/bundled-features/src/auth-mfa/handlers/verify.write.ts +1 -1
- package/packages/bundled-features/src/auth-mfa/mfa-code-verifier.ts +1 -1
- package/packages/bundled-features/src/auth-mfa/mfa-status-checker.ts +1 -1
- package/packages/bundled-features/src/auth-mfa-user-data/index.ts +19 -10
- package/packages/bundled-features/src/billing-foundation/billing-info-query.ts +1 -1
- package/packages/bundled-features/src/billing-foundation/feature.ts +138 -135
- package/packages/bundled-features/src/billing-foundation/handlers/create-portal-session.write.ts +1 -1
- package/packages/bundled-features/src/billing-foundation/projection.ts +3 -2
- package/packages/bundled-features/src/cap-counter/calendar-cap-usage-reservation.ts +52 -1
- package/packages/bundled-features/src/cap-counter/cap-reservation.ts +203 -15
- package/packages/bundled-features/src/cap-counter/changes.json +13 -0
- package/packages/bundled-features/src/cap-counter/feature.ts +84 -73
- package/packages/bundled-features/src/cap-counter/handlers/increment-rolling.write.ts +3 -4
- package/packages/bundled-features/src/cap-counter/index.ts +9 -1
- package/packages/bundled-features/src/cap-counter/tables.ts +10 -3
- package/packages/bundled-features/src/cap-overview/handlers/caps-usage.query.ts +1 -2
- package/packages/bundled-features/src/cap-overview/handlers/tenant-caps-list.query.ts +6 -2
- package/packages/bundled-features/src/cap-overview/handlers/tenant-options.query.ts +1 -1
- package/packages/bundled-features/src/channel-email/changes.json +6 -0
- package/packages/bundled-features/src/channel-email/email-channel.ts +12 -2
- package/packages/bundled-features/src/channel-email/feature.ts +1 -1
- package/packages/bundled-features/src/channel-in-app/handlers/inbox.query.ts +1 -1
- package/packages/bundled-features/src/channel-in-app/handlers/mark-all-read.write.ts +1 -1
- package/packages/bundled-features/src/channel-in-app/handlers/mark-read.write.ts +1 -1
- package/packages/bundled-features/src/channel-in-app/handlers/unread-count.query.ts +1 -1
- package/packages/bundled-features/src/channel-in-app/tables.ts +1 -1
- package/packages/bundled-features/src/compliance-profiles/handlers/for-tenant.query.ts +1 -1
- package/packages/bundled-features/src/compliance-profiles/handlers/needs-profile.query.ts +1 -1
- package/packages/bundled-features/src/compliance-profiles/handlers/set-profile.write.ts +1 -2
- package/packages/bundled-features/src/compliance-profiles/resolve-for-tenant.ts +1 -1
- package/packages/bundled-features/src/compliance-profiles/seeding.ts +8 -4
- package/packages/bundled-features/src/compliance-profiles-ops/index.ts +26 -17
- package/packages/bundled-features/src/config/db/queries/resolver.ts +1 -1
- package/packages/bundled-features/src/config/handlers/reencrypt.job.ts +2 -2
- package/packages/bundled-features/src/config/resolver.ts +1 -1
- package/packages/bundled-features/src/config/write-helpers.ts +1 -1
- package/packages/bundled-features/src/crypto-shredding/changes.json +6 -0
- package/packages/bundled-features/src/crypto-shredding/handlers/forget-subject.write.ts +9 -7
- package/packages/bundled-features/src/custom-fields/db/queries/field-access.ts +1 -1
- package/packages/bundled-features/src/custom-fields/db/queries/projection.ts +1 -1
- package/packages/bundled-features/src/custom-fields/db/queries/quota.ts +1 -1
- package/packages/bundled-features/src/custom-fields/db/queries/retention.ts +6 -2
- package/packages/bundled-features/src/custom-fields/db/queries/user-data-rights.ts +1 -1
- package/packages/bundled-features/src/custom-fields/feature.ts +11 -14
- package/packages/bundled-features/src/custom-fields/handlers/clear-custom-field.write.ts +2 -2
- package/packages/bundled-features/src/custom-fields/handlers/delete-system-field.write.ts +2 -2
- package/packages/bundled-features/src/custom-fields/handlers/delete-tenant-field.write.ts +2 -2
- package/packages/bundled-features/src/custom-fields/handlers/set-custom-field.write.ts +2 -2
- package/packages/bundled-features/src/custom-fields/wire-for-entity.ts +4 -4
- package/packages/bundled-features/src/data-retention/resolve-for-tenant.ts +1 -1
- package/packages/bundled-features/src/data-retention/run-retention-cleanup.ts +16 -10
- package/packages/bundled-features/src/delivery/address-opt-out.ts +5 -2
- package/packages/bundled-features/src/delivery/attempt-log-retention.ts +1 -1
- package/packages/bundled-features/src/delivery/changes.json +12 -0
- package/packages/bundled-features/src/delivery/channel-context.ts +2 -1
- package/packages/bundled-features/src/delivery/db/queries/address-opt-outs.ts +1 -1
- package/packages/bundled-features/src/delivery/db/queries/preferences.ts +1 -1
- package/packages/bundled-features/src/delivery/delivery-service.ts +70 -8
- package/packages/bundled-features/src/delivery/feature.ts +2 -2
- package/packages/bundled-features/src/delivery/handlers/log.query.ts +3 -2
- package/packages/bundled-features/src/delivery/handlers/preferences.query.ts +1 -1
- package/packages/bundled-features/src/delivery/handlers/unsubscribe-address.write.ts +10 -5
- package/packages/bundled-features/src/delivery/index.ts +6 -0
- package/packages/bundled-features/src/delivery/testing.ts +2 -0
- package/packages/bundled-features/src/delivery/types.ts +4 -0
- package/packages/bundled-features/src/delivery/unsubscribe-link.ts +73 -0
- package/packages/bundled-features/src/delivery/unsubscribe-page-strings.ts +17 -0
- package/packages/bundled-features/src/delivery/unsubscribe.ts +94 -31
- package/packages/bundled-features/src/delivery/upsert-preference.ts +5 -2
- package/packages/bundled-features/src/derivatives-sharp/feature.ts +21 -12
- package/packages/bundled-features/src/derivatives-sharp/index.ts +1 -1
- package/packages/bundled-features/src/document-ingest-foundation/feature.ts +112 -103
- package/packages/bundled-features/src/document-ingest-foundation/forget-extract-with-file-ref.ts +3 -3
- package/packages/bundled-features/src/document-ingest-foundation/index.ts +4 -1
- package/packages/bundled-features/src/feature-toggles/global-feature-state-table.ts +1 -1
- package/packages/bundled-features/src/feature-toggles/handlers/set.write.ts +3 -5
- package/packages/bundled-features/src/feature-toggles/toggle-runtime.ts +1 -1
- package/packages/bundled-features/src/file-derivatives/feature.ts +134 -129
- 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/feature.ts +38 -29
- package/packages/bundled-features/src/file-foundation/index.ts +1 -0
- package/packages/bundled-features/src/file-foundation/read-file-ref-content.ts +1 -1
- package/packages/bundled-features/src/file-provider-inmemory/feature.ts +32 -21
- package/packages/bundled-features/src/file-provider-inmemory/index.ts +6 -1
- package/packages/bundled-features/src/file-provider-s3/changes.json +10 -1
- package/packages/bundled-features/src/file-provider-s3/env-feature.ts +62 -0
- package/packages/bundled-features/src/file-provider-s3/feature.ts +107 -73
- package/packages/bundled-features/src/file-provider-s3/index.ts +6 -1
- package/packages/bundled-features/src/file-provider-s3/lib/index.ts +3 -0
- package/packages/bundled-features/src/{files-provider-s3 → file-provider-s3/lib}/s3-provider.ts +19 -19
- package/packages/bundled-features/src/file-provider-s3-env/index.ts +7 -2
- package/packages/bundled-features/src/files-provider-s3/index.ts +11 -3
- package/packages/bundled-features/src/files-tenant-data/handlers/sweep-orphaned-derivatives.job.ts +1 -1
- package/packages/bundled-features/src/files-tenant-data/hooks.ts +1 -2
- package/packages/bundled-features/src/folders/feature.ts +8 -3
- package/packages/bundled-features/src/folders-user-data/index.ts +27 -18
- package/packages/bundled-features/src/form-draft/db/queries/cleanup.ts +1 -1
- package/packages/bundled-features/src/form-draft/db/queries/draft-count.ts +1 -1
- package/packages/bundled-features/src/form-draft/db/queries/owned-file-refs.ts +3 -2
- package/packages/bundled-features/src/form-draft/feature.ts +6 -1
- package/packages/bundled-features/src/form-draft/handlers/cleanup.job.ts +2 -2
- package/packages/bundled-features/src/form-draft/index.ts +1 -1
- package/packages/bundled-features/src/form-draft/lookup.ts +1 -1
- package/packages/bundled-features/src/form-draft-user-data/index.ts +19 -10
- package/packages/bundled-features/src/inbound-mail-foundation/feature.ts +165 -154
- package/packages/bundled-features/src/inbound-mail-foundation/handlers/ingest-message.write.ts +1 -2
- package/packages/bundled-features/src/inbound-mail-foundation/index.ts +1 -1
- package/packages/bundled-features/src/inbound-mail-foundation/oauth-access-token.ts +5 -2
- package/packages/bundled-features/src/inbound-mail-foundation/projection.ts +3 -2
- package/packages/bundled-features/src/inbound-mail-foundation/watch-supervisor.ts +1 -1
- package/packages/bundled-features/src/inbound-provider-imap/feature.ts +22 -13
- package/packages/bundled-features/src/inbound-provider-imap/index.ts +6 -1
- package/packages/bundled-features/src/inbound-provider-inmemory/feature.ts +20 -12
- package/packages/bundled-features/src/inbound-provider-inmemory/index.ts +1 -0
- package/packages/bundled-features/src/jobs/db/queries/retention.ts +1 -1
- package/packages/bundled-features/src/jobs/db/queries/stale-run-sweep.ts +1 -1
- package/packages/bundled-features/src/jobs/handlers/detail.query.ts +1 -1
- package/packages/bundled-features/src/jobs/handlers/list.query.ts +7 -2
- package/packages/bundled-features/src/jobs/handlers/retry.write.ts +1 -1
- package/packages/bundled-features/src/jobs/handlers/tenant-failures.query.ts +1 -1
- package/packages/bundled-features/src/jobs/handlers/tenant-runs.query.ts +1 -1
- package/packages/bundled-features/src/jobs/job-run-logger.ts +11 -10
- 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/feature.ts +6 -3
- package/packages/bundled-features/src/mail-foundation/feature.ts +107 -55
- package/packages/bundled-features/src/mail-foundation/index.ts +4 -0
- package/packages/bundled-features/src/mail-transport-inmemory/feature.ts +25 -17
- package/packages/bundled-features/src/mail-transport-inmemory/index.ts +6 -1
- package/packages/bundled-features/src/mail-transport-smtp/feature.ts +91 -79
- package/packages/bundled-features/src/mail-transport-smtp/index.ts +1 -0
- 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 -2
- package/packages/bundled-features/src/managed-pages/handlers/set.write.ts +1 -2
- package/packages/bundled-features/src/managed-pages/seeding.ts +8 -4
- package/packages/bundled-features/src/metrics/compute.ts +1 -1
- package/packages/bundled-features/src/metrics/filters.ts +1 -1
- package/packages/bundled-features/src/metrics/validate.ts +1 -1
- package/packages/bundled-features/src/notes-history/feature.ts +6 -3
- package/packages/bundled-features/src/notes-history/handlers/add-note.write.ts +1 -1
- package/packages/bundled-features/src/notes-history-user-data/hooks.ts +1 -1
- package/packages/bundled-features/src/notes-history-user-data/index.ts +27 -18
- package/packages/bundled-features/src/personal-access-tokens/changes.json +6 -0
- package/packages/bundled-features/src/personal-access-tokens/feature.ts +17 -2
- package/packages/bundled-features/src/personal-access-tokens/handlers/create.write.ts +1 -1
- package/packages/bundled-features/src/personal-access-tokens/handlers/list.query.ts +2 -2
- package/packages/bundled-features/src/personal-access-tokens/handlers/revoke.write.ts +1 -1
- package/packages/bundled-features/src/personal-access-tokens/resolver.ts +1 -1
- package/packages/bundled-features/src/personal-access-tokens/revoke-for-user.ts +2 -2
- package/packages/bundled-features/src/personal-access-tokens/roles.ts +8 -6
- package/packages/bundled-features/src/personal-access-tokens/screens.ts +2 -0
- package/packages/bundled-features/src/readiness/feature.ts +25 -16
- package/packages/bundled-features/src/readiness/index.ts +1 -1
- package/packages/bundled-features/src/secrets/db/queries/read.ts +1 -1
- package/packages/bundled-features/src/secrets/feature.ts +8 -3
- package/packages/bundled-features/src/secrets/handlers/rotate.job.ts +2 -2
- package/packages/bundled-features/src/secrets/secrets-context.ts +4 -3
- package/packages/bundled-features/src/sessions/db/queries/cleanup.ts +1 -1
- package/packages/bundled-features/src/sessions/handlers/detail.query.ts +1 -1
- package/packages/bundled-features/src/sessions/handlers/list.query.ts +2 -2
- package/packages/bundled-features/src/sessions/handlers/mine.query.ts +1 -1
- package/packages/bundled-features/src/sessions/handlers/revoke-all-for-user.write.ts +1 -1
- package/packages/bundled-features/src/sessions/handlers/revoke-all-others.write.ts +1 -1
- package/packages/bundled-features/src/sessions/handlers/revoke.write.ts +1 -1
- package/packages/bundled-features/src/sessions/session-callbacks.ts +14 -7
- package/packages/bundled-features/src/sessions/testing.ts +1 -1
- package/packages/bundled-features/src/tags/feature.ts +6 -3
- package/packages/bundled-features/src/template-resolver/api.ts +1 -1
- package/packages/bundled-features/src/template-resolver/changes.json +25 -0
- package/packages/bundled-features/src/template-resolver/compile-document-body.ts +61 -9
- package/packages/bundled-features/src/template-resolver/document-sanitizer.ts +19 -0
- package/packages/bundled-features/src/template-resolver/document-schema.ts +33 -0
- package/packages/bundled-features/src/template-resolver/handlers/bundle-import.ts +10 -2
- 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 -2
- package/packages/bundled-features/src/template-resolver/handlers/collection-item.query.ts +1 -1
- package/packages/bundled-features/src/template-resolver/handlers/collection-list.query.ts +1 -2
- package/packages/bundled-features/src/template-resolver/handlers/collection-set.write.ts +1 -1
- package/packages/bundled-features/src/template-resolver/handlers/copy-locale.write.ts +9 -3
- package/packages/bundled-features/src/template-resolver/handlers/diff-to-system.query.ts +1 -1
- package/packages/bundled-features/src/template-resolver/handlers/export-bundle.query.ts +1 -1
- package/packages/bundled-features/src/template-resolver/handlers/find-by-id.query.ts +9 -2
- package/packages/bundled-features/src/template-resolver/handlers/layout-source.query.ts +1 -1
- package/packages/bundled-features/src/template-resolver/handlers/list.query.ts +7 -2
- package/packages/bundled-features/src/template-resolver/handlers/overview.query.ts +8 -3
- package/packages/bundled-features/src/template-resolver/handlers/reset-to-system.write.ts +1 -1
- package/packages/bundled-features/src/template-resolver/handlers/resource-remove.write.ts +1 -1
- package/packages/bundled-features/src/template-resolver/handlers/set.write.ts +1 -1
- package/packages/bundled-features/src/template-resolver/handlers/template-write.ts +22 -2
- package/packages/bundled-features/src/template-resolver/handlers/tenant-overrides.query.ts +1 -1
- package/packages/bundled-features/src/template-resolver/handlers/toggle-status.write.ts +1 -1
- package/packages/bundled-features/src/template-resolver/handlers/usage.query.ts +1 -1
- package/packages/bundled-features/src/template-resolver/handlers/validate.query.ts +1 -1
- package/packages/bundled-features/src/template-resolver/index.ts +4 -0
- package/packages/bundled-features/src/template-resolver/qualified-names.ts +1 -0
- package/packages/bundled-features/src/template-resolver/seeding.ts +57 -10
- package/packages/bundled-features/src/template-resolver/store-template-resource.ts +1 -1
- package/packages/bundled-features/src/template-resolver/template-preview.ts +3 -1
- package/packages/bundled-features/src/template-resolver/template-resources.ts +1 -1
- package/packages/bundled-features/src/template-resolver/template-system-only.ts +21 -0
- package/packages/bundled-features/src/template-resolver/template-validation.ts +48 -24
- package/packages/bundled-features/src/template-resolver/testing.ts +1 -1
- package/packages/bundled-features/src/template-resolver/web/i18n.ts +2 -0
- package/packages/bundled-features/src/template-resolver-user-data/index.ts +23 -14
- package/packages/bundled-features/src/tenant/handlers/active-tenant-ids.query.ts +1 -1
- package/packages/bundled-features/src/tenant/handlers/add-member.write.ts +1 -2
- package/packages/bundled-features/src/tenant/handlers/cancel-invitation.write.ts +1 -1
- package/packages/bundled-features/src/tenant/handlers/invitations.query.ts +1 -1
- package/packages/bundled-features/src/tenant/handlers/me.query.ts +1 -1
- 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/remove-member.write.ts +2 -1
- package/packages/bundled-features/src/tenant/handlers/resolve-user-ids.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/handlers/update-member-roles.write.ts +1 -2
- package/packages/bundled-features/src/tenant/invited-membership.ts +2 -2
- package/packages/bundled-features/src/tenant/last-tenant-admin.ts +1 -2
- package/packages/bundled-features/src/tenant/seeding.ts +12 -12
- package/packages/bundled-features/src/tenant-lifecycle/handlers/cancel-destruction.write.ts +1 -2
- package/packages/bundled-features/src/tenant-lifecycle/handlers/request-destruction.write.ts +1 -2
- package/packages/bundled-features/src/tenant-lifecycle/lib/revoke-tenant-sessions.ts +1 -1
- package/packages/bundled-features/src/tenant-lifecycle/lifecycle-gate.ts +1 -1
- package/packages/bundled-features/src/tenant-lifecycle/run-tenant-destroy.ts +3 -3
- package/packages/bundled-features/src/tenant-lifecycle/stages.ts +10 -5
- package/packages/bundled-features/src/tenant-lifecycle/testing.ts +3 -3
- package/packages/bundled-features/src/tenant-settings/feature.ts +34 -29
- package/packages/bundled-features/src/tier-engine/feature.ts +426 -428
- package/packages/bundled-features/src/tier-engine/handlers/get-tenant-tier.query.ts +2 -3
- package/packages/bundled-features/src/tier-engine/handlers/set-tenant-tier.write.ts +5 -2
- package/packages/bundled-features/src/user/changes.json +6 -0
- package/packages/bundled-features/src/user/db/queries/stream-tenant-backfill.ts +1 -1
- package/packages/bundled-features/src/user/handlers/create.write.ts +1 -2
- package/packages/bundled-features/src/user/handlers/find-for-auth.query.ts +1 -1
- package/packages/bundled-features/src/user/handlers/list.query.ts +1 -1
- package/packages/bundled-features/src/user/handlers/update-roles.ts +2 -1
- package/packages/bundled-features/src/user/index.ts +5 -1
- package/packages/bundled-features/src/user/invited-global-roles.ts +2 -2
- package/packages/bundled-features/src/user/principal-status.ts +13 -3
- package/packages/bundled-features/src/user/resolve-display-names.ts +1 -1
- package/packages/bundled-features/src/user/seeding.ts +5 -5
- package/packages/bundled-features/src/user-data-rights/audit-download.ts +2 -2
- package/packages/bundled-features/src/user-data-rights/changes.json +6 -0
- package/packages/bundled-features/src/user-data-rights/db/queries/export-jobs.ts +1 -1
- package/packages/bundled-features/src/user-data-rights/db/queries/forget-cleanup.ts +1 -1
- package/packages/bundled-features/src/user-data-rights/handlers/download-by-job.query.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/export-status.query.ts +1 -1
- package/packages/bundled-features/src/user-data-rights/handlers/list-download-attempts.query.ts +1 -1
- package/packages/bundled-features/src/user-data-rights/handlers/my-audit-log.query.ts +1 -1
- package/packages/bundled-features/src/user-data-rights/handlers/request-export.write.ts +1 -2
- package/packages/bundled-features/src/user-data-rights/handlers/run-forget-cleanup.write.ts +3 -3
- package/packages/bundled-features/src/user-data-rights/lib/deny-if-target-outside-admin-tenant.ts +1 -1
- package/packages/bundled-features/src/user-data-rights/lib/update-user-lifecycle.ts +7 -2
- package/packages/bundled-features/src/user-data-rights/run-export-jobs.ts +7 -3
- package/packages/bundled-features/src/user-data-rights/run-forget-cleanup.ts +11 -5
- package/packages/bundled-features/src/user-data-rights/run-user-export.ts +10 -5
- package/packages/bundled-features/src/waitlist/handlers/invite.write.ts +1 -2
- package/packages/bundled-features/src/waitlist/handlers/reject.write.ts +1 -1
- package/packages/bundled-features/src/waitlist/lib.ts +5 -2
- package/packages/bundled-features/src/workflow-runner/event-subscriber.ts +1 -1
- package/packages/bundled-features/src/workflow-runner/feature.ts +58 -47
- package/packages/bundled-features/src/workflow-runner/handlers/resume-run.write.ts +1 -1
- package/packages/bundled-features/src/workflow-runner/index.ts +1 -1
- package/packages/bundled-features/src/workflow-runner/pending-projection.ts +1 -1
- package/samples/apps/admin-console/src/run-config.ts +2 -2
- package/samples/apps/cap-billing-demo/package.json +3 -0
- package/samples/apps/cap-billing-demo/src/feature.ts +2 -2
- package/samples/apps/cap-billing-demo/src/run-config.ts +8 -8
- package/samples/apps/marketing-demo/src/app/seed.ts +1 -1
- package/samples/apps/marketing-demo/src/db/queries/seed-counts.ts +1 -1
- package/samples/apps/showcase/package.json +3 -0
- package/samples/apps/showcase/src/app/seed-items.ts +1 -1
- package/samples/apps/styleguide/src/app/seed.ts +2 -2
- package/samples/apps/styleguide/src/features/ai-settings/seed.ts +2 -2
- package/samples/apps/ui-walkthrough/scripts/emit-e2e-data.ts +1 -1
- package/samples/apps/ui-walkthrough/src/app/auth-constants.ts +1 -1
- package/samples/apps/ui-walkthrough/src/app/seed-rental.ts +2 -2
- package/samples/apps/ui-walkthrough/src/app/seed-templates.ts +2 -0
- package/samples/apps/ui-walkthrough/src/app/seed-vehicles.ts +1 -1
- package/samples/apps/ui-walkthrough/src/app/seed.ts +1 -1
- package/samples/apps/ui-walkthrough/src/app/template-seed-data.ts +12 -0
- package/samples/apps/ui-walkthrough/src/db/queries/row-counts.ts +1 -1
- package/samples/apps/ui-walkthrough/src/db/queries/task-counts.ts +1 -1
- package/samples/apps/ui-walkthrough/src/features/billing/feature.ts +7 -0
- package/samples/apps/ui-walkthrough/src/features/billing/i18n.ts +2 -0
- package/samples/apps/use-all-bundled/feature-manifest.json +4 -4
- package/samples/apps/use-all-bundled/package.json +4 -0
- package/samples/apps/use-all-bundled/scripts/check-coverage.ts +2 -2
- package/samples/apps/use-all-bundled/src/app/auth-constants.ts +1 -1
- package/samples/apps/use-all-bundled/src/app/cap-overview-caps.ts +2 -2
- package/samples/apps/use-all-bundled/src/app/dev-app-options.ts +1 -1
- package/samples/apps/use-all-bundled/src/app/seed-documents.ts +1 -1
- package/samples/apps/use-all-bundled/src/app/seed.ts +11 -5
- package/samples/apps/use-all-bundled/src/run-config.ts +55 -56
- package/samples/apps/user-data-rights-demo/README.md +2 -2
- package/samples/apps/user-data-rights-demo/package.json +3 -0
- package/samples/apps/user-data-rights-demo/src/run-config.ts +7 -7
- package/samples/apps/workspaces/package.json +3 -0
- package/samples/recipes/access-control/package.json +3 -0
- package/samples/recipes/anonymous-access/package.json +3 -0
- package/samples/recipes/anonymous-access-multitenant/package.json +3 -0
- package/samples/recipes/apex-landing/package.json +1 -0
- package/samples/recipes/apex-surface-auth/package.json +3 -0
- package/samples/recipes/apex-surface-auth/src/feature.ts +2 -2
- package/samples/recipes/api-worker-split/package.json +3 -0
- package/samples/recipes/api-worker-split/src/feature.ts +1 -2
- package/samples/recipes/auth-claims/package.json +3 -0
- package/samples/recipes/auth-foundation-providers/src/feature.ts +1 -1
- package/samples/recipes/auth-mfa/package.json +3 -0
- package/samples/recipes/basic-entity/package.json +3 -0
- package/samples/recipes/chat-channels/package.json +3 -0
- package/samples/recipes/compliance-profiles-demo/package.json +3 -0
- package/samples/recipes/cross-feature-events/package.json +3 -1
- package/samples/recipes/cross-feature-events/src/feature.ts +1 -1
- package/samples/recipes/crypto-shredding-hr/package.json +3 -0
- package/samples/recipes/currencies-global/package.json +3 -0
- package/samples/recipes/currencies-per-tenant/package.json +3 -0
- package/samples/recipes/custom-fields-basic/package.json +3 -0
- package/samples/recipes/custom-handlers/package.json +3 -0
- package/samples/recipes/dashboard-stats/package.json +3 -0
- package/samples/recipes/delivery-notifications/package.json +3 -0
- package/samples/recipes/e2e-generator/package.json +3 -0
- package/samples/recipes/embedded/package.json +3 -0
- package/samples/recipes/embedded-entity-form/package.json +1 -0
- package/samples/recipes/encrypted-tenant-config/README.md +1 -1
- package/samples/recipes/encrypted-tenant-config/package.json +3 -0
- package/samples/recipes/error-contract/package.json +3 -0
- package/samples/recipes/event-sourcing/package.json +3 -1
- package/samples/recipes/event-sourcing/src/feature.ts +16 -20
- package/samples/recipes/event-sourcing/tsconfig.json +2 -6
- package/samples/recipes/feature-toggles/package.json +3 -0
- package/samples/recipes/field-access/package.json +3 -0
- package/samples/recipes/files-post-processing/package.json +1 -0
- package/samples/recipes/golden-path/README.md +30 -0
- package/samples/recipes/golden-path/package.json +11 -0
- package/samples/recipes/golden-path/src/feature.ts +70 -0
- package/samples/recipes/idempotency/package.json +3 -0
- package/samples/recipes/inbound-mail-triage/package.json +3 -0
- package/samples/recipes/lane-routing/package.json +3 -0
- package/samples/recipes/ledger-banking/package.json +3 -0
- package/samples/recipes/ledger-invoicing/package.json +3 -0
- package/samples/recipes/legal-pages/package.json +3 -0
- package/samples/recipes/lifecycle-hooks/package.json +3 -0
- package/samples/recipes/managed-config/package.json +3 -0
- package/samples/recipes/managed-pages/package.json +3 -0
- package/samples/recipes/notes-history-basic/package.json +3 -0
- package/samples/recipes/ownership/package.json +3 -0
- package/samples/recipes/pdf-audit-export/package.json +1 -0
- package/samples/recipes/pipeline-basics/package.json +3 -0
- package/samples/recipes/public-share-token/package.json +3 -0
- package/samples/recipes/public-share-token/src/feature.ts +1 -1
- package/samples/recipes/rate-limiting/package.json +3 -0
- package/samples/recipes/realtime-sse/package.json +3 -0
- package/samples/recipes/record-detail-layout/package.json +1 -0
- package/samples/recipes/reference-data/package.json +3 -0
- package/samples/recipes/relations/package.json +3 -0
- package/samples/recipes/screens-nav/package.json +3 -0
- package/samples/recipes/search/package.json +3 -0
- package/samples/recipes/secrets-demo/package.json +3 -0
- package/samples/recipes/security-baseline/src/feature.ts +2 -2
- package/samples/recipes/session-revocation/README.md +1 -1
- package/samples/recipes/session-revocation/package.json +3 -0
- package/samples/recipes/session-revocation/src/feature.ts +1 -1
- package/samples/recipes/state-machine/package.json +3 -1
- package/samples/recipes/state-machine/src/entities/invoice.ts +2 -2
- package/samples/recipes/state-machine/src/events.ts +19 -0
- package/samples/recipes/state-machine/src/feature.ts +25 -30
- package/samples/recipes/state-machine/src/handlers/_helpers.ts +13 -14
- package/samples/recipes/state-machine/src/handlers/create.ts +1 -1
- package/samples/recipes/state-machine/src/handlers/transitions.ts +129 -122
- package/samples/recipes/state-machine/src/reducer.ts +1 -1
- package/samples/recipes/state-machine/tsconfig.json +2 -6
- package/samples/recipes/tags-basic/package.json +3 -0
- package/samples/recipes/tenant-isolation/package.json +3 -0
- package/samples/recipes/tenant-settings/package.json +3 -0
- package/samples/recipes/tier-admin/package.json +3 -0
- package/samples/recipes/timezones/package.json +3 -0
- package/samples/recipes/tsconfig.base.json +1 -1
- package/samples/recipes/user-data-rights/package.json +3 -0
- package/samples/recipes/user-data-rights/src/feature.ts +6 -2
- package/samples/recipes/user-profile/package.json +3 -0
- package/samples/recipes/user-profile/src/feature.ts +2 -2
- package/samples/recipes/webhook-step/package.json +3 -0
- package/samples/recipes/wizard-form/package.json +1 -0
- package/samples/recipes/workflow-engine/package.json +3 -0
- package/samples/recipes/workflow-engine/src/db/queries/suspended-runs.ts +5 -2
- package/samples/recipes/writeform-section/package.json +1 -0
- package/packages/bundled-features/src/file-provider-s3-env/feature.ts +0 -58
- /package/packages/bundled-features/src/{files-provider-s3 → file-provider-s3/lib}/env-helper.ts +0 -0
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
//
|
|
6
6
|
// - r.defineEvent with { version, migrations } — evolving event shapes +
|
|
7
7
|
// upcast older payloads on read (declarative + sync/async transforms)
|
|
8
|
-
// -
|
|
9
|
-
// -
|
|
8
|
+
// - emitEvent — write domain events onto the aggregate stream, payload typed by the EventDef
|
|
9
|
+
// - emitEvent with headers — Marten free key/value metadata
|
|
10
10
|
// - r.projection — single-stream read model (inline in the write TX)
|
|
11
11
|
// - r.multiStreamProjection — cross-aggregate async read model
|
|
12
12
|
// - ctx.loadAggregate with { asOf } — point-in-time aggregate state
|
|
@@ -19,26 +19,25 @@
|
|
|
19
19
|
// - getAllProjectionProgress — projection lag for ops dashboards
|
|
20
20
|
|
|
21
21
|
import {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
defineFeature,
|
|
25
|
-
defineProjectionQueryHandler,
|
|
26
|
-
typedPayload,
|
|
27
|
-
} from "@app/define";
|
|
28
|
-
import {
|
|
22
|
+
buildEntityTable,
|
|
23
|
+
createEventStoreExecutor,
|
|
29
24
|
fetchOne,
|
|
30
25
|
incrementCounter,
|
|
31
26
|
insertOne,
|
|
32
|
-
updateMany,
|
|
33
|
-
} from "@cosmicdrift/kumiko-framework/bun-db";
|
|
34
|
-
import {
|
|
35
|
-
buildEntityTable,
|
|
36
|
-
createEventStoreExecutor,
|
|
37
27
|
integer,
|
|
38
28
|
table,
|
|
39
29
|
text,
|
|
30
|
+
updateMany,
|
|
40
31
|
uuid,
|
|
41
32
|
} from "@cosmicdrift/kumiko-framework/db";
|
|
33
|
+
import {
|
|
34
|
+
createEntity,
|
|
35
|
+
createTextField,
|
|
36
|
+
defineFeature,
|
|
37
|
+
defineProjectionQueryHandler,
|
|
38
|
+
emitEvent,
|
|
39
|
+
typedPayload,
|
|
40
|
+
} from "@cosmicdrift/kumiko-framework/engine";
|
|
42
41
|
import { z } from "zod";
|
|
43
42
|
|
|
44
43
|
// --- Reducer: shared by live + snapshot-aware query handlers ---
|
|
@@ -286,10 +285,9 @@ export const invoiceFeature = defineFeature("showcase", (r) => {
|
|
|
286
285
|
const headers: Record<string, string> = {};
|
|
287
286
|
if (event.payload.geoRegion) headers["geoRegion"] = event.payload.geoRegion;
|
|
288
287
|
if (event.payload.abTestBucket) headers["abTestBucket"] = event.payload.abTestBucket;
|
|
289
|
-
await ctx
|
|
288
|
+
await emitEvent(ctx, approved, {
|
|
290
289
|
aggregateId: event.payload.id,
|
|
291
290
|
aggregateType: "showcase-invoice",
|
|
292
|
-
type: approved.name,
|
|
293
291
|
payload: { amountCents: event.payload.amountCents, approvedBy: event.payload.approvedBy },
|
|
294
292
|
...(Object.keys(headers).length > 0 ? { headers } : {}),
|
|
295
293
|
});
|
|
@@ -306,10 +304,9 @@ export const invoiceFeature = defineFeature("showcase", (r) => {
|
|
|
306
304
|
approverId: event.payload.approverId,
|
|
307
305
|
});
|
|
308
306
|
const approverDisplayName: string = row?.displayName ?? `unknown:${event.payload.approverId}`;
|
|
309
|
-
await ctx
|
|
307
|
+
await emitEvent(ctx, acknowledged, {
|
|
310
308
|
aggregateId: event.payload.id,
|
|
311
309
|
aggregateType: "showcase-invoice",
|
|
312
|
-
type: acknowledged.name,
|
|
313
310
|
payload: { approverId: event.payload.approverId, approverDisplayName },
|
|
314
311
|
});
|
|
315
312
|
return { isSuccess: true as const, data: { id: event.payload.id } };
|
|
@@ -321,10 +318,9 @@ export const invoiceFeature = defineFeature("showcase", (r) => {
|
|
|
321
318
|
name: "invoice:pay",
|
|
322
319
|
schema: z.object({ id: z.uuid(), amountCents: z.number().int() }),
|
|
323
320
|
handler: async (event, ctx) => {
|
|
324
|
-
await ctx
|
|
321
|
+
await emitEvent(ctx, paid, {
|
|
325
322
|
aggregateId: event.payload.id,
|
|
326
323
|
aggregateType: "showcase-invoice",
|
|
327
|
-
type: paid.name,
|
|
328
324
|
payload: { amountCents: event.payload.amountCents },
|
|
329
325
|
});
|
|
330
326
|
return { isSuccess: true as const, data: { id: event.payload.id } };
|
|
@@ -11,16 +11,12 @@
|
|
|
11
11
|
"@cosmicdrift/kumiko-dev-server": [
|
|
12
12
|
"../../../packages/dev-server/src/index.ts"
|
|
13
13
|
],
|
|
14
|
-
"@cosmicdrift/kumiko-dev-server/*": [
|
|
15
|
-
"../../../packages/dev-server/src/*"
|
|
16
|
-
],
|
|
17
|
-
"@app/define": ["./.kumiko/define.ts"],
|
|
18
|
-
"@app/*": ["./.kumiko/*"]
|
|
14
|
+
"@cosmicdrift/kumiko-dev-server/*": ["../../../packages/dev-server/src/*"]
|
|
19
15
|
},
|
|
20
16
|
"noEmit": true,
|
|
21
17
|
"rootDir": "../../..",
|
|
22
18
|
"lib": ["ESNext", "DOM", "DOM.Iterable"],
|
|
23
19
|
"types": ["bun-types"]
|
|
24
20
|
},
|
|
25
|
-
"include": ["./src"
|
|
21
|
+
"include": ["./src"]
|
|
26
22
|
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Golden path
|
|
2
|
+
|
|
3
|
+
The smallest complete Kumiko feature: one entity, one write handler that emits
|
|
4
|
+
an event, one projection, one screen, and an integration test that writes
|
|
5
|
+
through HTTP and reads the result back. Every other recipe is a variation on
|
|
6
|
+
this shape. The walkthrough is in [`docs/golden-path.md`](../../../docs/golden-path.md).
|
|
7
|
+
|
|
8
|
+
## What it shows
|
|
9
|
+
|
|
10
|
+
- **Entity** — `ticketEntity` declares `title` and `isClosed`. `r.crud` registers
|
|
11
|
+
`ticket:create`, `ticket:list` and `ticket:detail` for it; update and delete
|
|
12
|
+
are switched off with `verbs`.
|
|
13
|
+
- **Write handler** — `ticket:close` checks that the ticket exists and emits the
|
|
14
|
+
`ticket-closed` event. It never touches the table.
|
|
15
|
+
- **Event** — `r.defineEvent` declares `ticket-closed` with a Zod payload;
|
|
16
|
+
`emitEvent` appends it to the ticket's stream in the handler's transaction.
|
|
17
|
+
- **Projection** — `ticket-status` folds `ticket-closed` into the ticket row
|
|
18
|
+
(`isClosed: true`), in the same transaction as the write.
|
|
19
|
+
- **Screen** — `ticket-list` is a declarative `entityList`; the renderer builds
|
|
20
|
+
the UI from it.
|
|
21
|
+
- **Test** — `setupTestStack` boots the real server and database;
|
|
22
|
+
`stack.http.writeOk` and `queryOk` go over HTTP. Each test runs in its own
|
|
23
|
+
tenant.
|
|
24
|
+
|
|
25
|
+
## Files
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
src/feature.ts entity, event, handler, projection, screen
|
|
29
|
+
src/__tests__/feature.integration.test.ts write → read back, access, not found
|
|
30
|
+
```
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@cosmicdrift/kumiko-sample-golden-path",
|
|
3
|
+
"description": "The smallest complete feature: entity, write handler, event, projection, screen and an integration test.",
|
|
4
|
+
"private": true,
|
|
5
|
+
"dependencies": {
|
|
6
|
+
"@cosmicdrift/kumiko-framework": "workspace:*"
|
|
7
|
+
},
|
|
8
|
+
"devDependencies": {
|
|
9
|
+
"@cosmicdrift/kumiko-testing": "workspace:*"
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createBooleanField,
|
|
3
|
+
createEntity,
|
|
4
|
+
createEntityExecutor,
|
|
5
|
+
createTextField,
|
|
6
|
+
defineFeature,
|
|
7
|
+
emitEvent,
|
|
8
|
+
setFields,
|
|
9
|
+
} from "@cosmicdrift/kumiko-framework/engine";
|
|
10
|
+
import { failNotFound } from "@cosmicdrift/kumiko-framework/errors";
|
|
11
|
+
import { z } from "zod";
|
|
12
|
+
|
|
13
|
+
export const ticketEntity = createEntity({
|
|
14
|
+
table: "read_golden_path_tickets",
|
|
15
|
+
fields: {
|
|
16
|
+
title: createTextField({ personal: false, reason: "is_business_data", required: true }),
|
|
17
|
+
isClosed: createBooleanField({ default: false }),
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
export const helpdeskFeature = defineFeature("helpdesk", (r) => {
|
|
22
|
+
const { table: ticketTable, executor: ticketExecutor } = createEntityExecutor(
|
|
23
|
+
"ticket",
|
|
24
|
+
ticketEntity,
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
r.crud("ticket", ticketEntity, {
|
|
28
|
+
write: { access: { roles: ["Admin", "User"] } },
|
|
29
|
+
read: { access: { roles: ["Admin", "User"] } },
|
|
30
|
+
verbs: { update: false, delete: false },
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const ticketClosed = r.defineEvent("ticket-closed", z.object({ resolution: z.string().min(1) }), {
|
|
34
|
+
piiFields: "none",
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
r.writeHandler({
|
|
38
|
+
name: "ticket:close",
|
|
39
|
+
schema: z.object({ id: z.uuid(), resolution: z.string().min(1) }),
|
|
40
|
+
access: { roles: ["Admin"] },
|
|
41
|
+
handler: async (event, ctx) => {
|
|
42
|
+
const ticket = await ticketExecutor.detail({ id: event.payload.id }, event.user, ctx.db);
|
|
43
|
+
if (!ticket) {
|
|
44
|
+
return failNotFound("ticket", event.payload.id);
|
|
45
|
+
}
|
|
46
|
+
await emitEvent(ctx, ticketClosed, {
|
|
47
|
+
aggregateId: event.payload.id,
|
|
48
|
+
aggregateType: "ticket",
|
|
49
|
+
payload: { resolution: event.payload.resolution },
|
|
50
|
+
});
|
|
51
|
+
return { isSuccess: true as const, data: { id: event.payload.id } };
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
r.projection({
|
|
56
|
+
name: "ticket-status",
|
|
57
|
+
source: "ticket",
|
|
58
|
+
table: ticketTable,
|
|
59
|
+
apply: {
|
|
60
|
+
[ticketClosed.name]: setFields(ticketTable, { isClosed: true }),
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
r.screen({
|
|
65
|
+
id: "ticket-list",
|
|
66
|
+
type: "entityList",
|
|
67
|
+
entity: "ticket",
|
|
68
|
+
columns: ["title", "isClosed"],
|
|
69
|
+
});
|
|
70
|
+
});
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
// A full consumer adds domain snapshots, layouts and tier gates on top.
|
|
7
7
|
|
|
8
8
|
import { generateToken } from "@cosmicdrift/kumiko-framework/api";
|
|
9
|
-
import { fetchOne } from "@cosmicdrift/kumiko-framework/
|
|
9
|
+
import { fetchOne } from "@cosmicdrift/kumiko-framework/db";
|
|
10
10
|
import {
|
|
11
11
|
createEntity,
|
|
12
12
|
createEntityExecutor,
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// rate-limiting, audit) and how it silences the NODE_ENV=production boot
|
|
4
4
|
// warning that fires when one of those four is missing.
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { createAuthFoundationFeature } from "@cosmicdrift/kumiko-bundled-features/auth-foundation";
|
|
7
7
|
import { createConfigFeature } from "@cosmicdrift/kumiko-bundled-features/config";
|
|
8
8
|
import { securityBaselineFeatures } from "@cosmicdrift/kumiko-bundled-features/presets";
|
|
9
9
|
import { createTenantFeature } from "@cosmicdrift/kumiko-bundled-features/tenant";
|
|
@@ -14,6 +14,6 @@ export const APP_FEATURES: FeatureDefinition[] = [
|
|
|
14
14
|
createConfigFeature(),
|
|
15
15
|
createUserFeature(),
|
|
16
16
|
createTenantFeature(),
|
|
17
|
-
|
|
17
|
+
createAuthFoundationFeature(),
|
|
18
18
|
...securityBaselineFeatures(),
|
|
19
19
|
];
|
|
@@ -15,7 +15,7 @@ The production wiring shape: an app builds `createSessionCallbacks()` against a
|
|
|
15
15
|
## What to copy into your app
|
|
16
16
|
|
|
17
17
|
```ts illustration
|
|
18
|
-
const db = createDbConnection(config.databaseUrl);
|
|
18
|
+
const db = createDbConnection({ url: config.databaseUrl });
|
|
19
19
|
const callbacks = createSessionCallbacks({ db });
|
|
20
20
|
|
|
21
21
|
const server = buildServer({
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
//
|
|
9
9
|
// What to copy into your own app:
|
|
10
10
|
//
|
|
11
|
-
// const db = createDbConnection(config.databaseUrl);
|
|
11
|
+
// const db = createDbConnection({ url: config.databaseUrl });
|
|
12
12
|
// const callbacks = createSessionCallbacks({ db });
|
|
13
13
|
// const server = buildServer({
|
|
14
14
|
// registry: buildRegistry([
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
"description": "Enforced entity state transitions. No more illegal state changes.",
|
|
4
4
|
"private": true,
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@app/define": "file:./.kumiko",
|
|
7
6
|
"@cosmicdrift/kumiko-framework": "workspace:*"
|
|
7
|
+
},
|
|
8
|
+
"devDependencies": {
|
|
9
|
+
"@cosmicdrift/kumiko-testing": "workspace:*"
|
|
8
10
|
}
|
|
9
11
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
+
import { buildEntityTable } from "@cosmicdrift/kumiko-framework/db";
|
|
1
2
|
import {
|
|
2
3
|
createEntity,
|
|
3
4
|
createMoneyField,
|
|
4
5
|
createSelectField,
|
|
5
6
|
createTextField,
|
|
6
7
|
defineTransitions,
|
|
7
|
-
} from "@
|
|
8
|
-
import { buildEntityTable } from "@cosmicdrift/kumiko-framework/db";
|
|
8
|
+
} from "@cosmicdrift/kumiko-framework/engine";
|
|
9
9
|
|
|
10
10
|
export const INVOICE_STATES = ["draft", "sent", "paid", "cancelled"] as const;
|
|
11
11
|
|
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
// strings, so a rename here propagates everywhere instead of silently
|
|
4
4
|
// breaking the reducer.
|
|
5
5
|
|
|
6
|
+
import type { EventDef } from "@cosmicdrift/kumiko-framework/engine";
|
|
7
|
+
import { z } from "zod";
|
|
8
|
+
|
|
6
9
|
export const FEATURE_NAME = "billing";
|
|
7
10
|
export const ENTITY_NAME = "invoice";
|
|
8
11
|
|
|
@@ -30,3 +33,19 @@ export function eventName<const TShort extends string>(
|
|
|
30
33
|
// The auto-generated event the executor emits on create — entity name dot
|
|
31
34
|
// "created", no feature prefix (executor convention).
|
|
32
35
|
export const INVOICE_CREATED_EVENT = `${ENTITY_NAME}.created` as const;
|
|
36
|
+
|
|
37
|
+
export const emptyEventPayload = z.object({});
|
|
38
|
+
export const statusForcedPayload = z.object({
|
|
39
|
+
newStatus: z.enum(["draft", "sent", "paid", "cancelled"]),
|
|
40
|
+
fromStatus: z.enum(["draft", "sent", "paid", "cancelled"]),
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// The EventDefs r.defineEvent returns inside the feature setup. Handlers receive them so that
|
|
44
|
+
// emitEvent checks each payload against the event's own schema.
|
|
45
|
+
export type InvoiceEvents = {
|
|
46
|
+
readonly sent: EventDef<z.infer<typeof emptyEventPayload>>;
|
|
47
|
+
readonly markedPaid: EventDef<z.infer<typeof emptyEventPayload>>;
|
|
48
|
+
readonly cancelled: EventDef<z.infer<typeof emptyEventPayload>>;
|
|
49
|
+
readonly reopened: EventDef<z.infer<typeof emptyEventPayload>>;
|
|
50
|
+
readonly statusForced: EventDef<z.infer<typeof statusForcedPayload>>;
|
|
51
|
+
};
|