ddd-ts-kit 0.102.0 → 0.103.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/CHANGELOG.md +230 -0
- package/README.fr.md +8 -9
- package/README.md +7 -8
- package/dist/acceptance/check-locked-files.d.ts.map +1 -1
- package/dist/acceptance/check-locked-files.js +6 -3
- package/dist/acceptance/check-locked-files.js.map +1 -1
- package/dist/build/rewrite-aliases.d.ts.map +1 -1
- package/dist/build/rewrite-aliases.js +3 -0
- package/dist/build/rewrite-aliases.js.map +1 -1
- package/dist/check/baseline/write-baseline.d.ts.map +1 -1
- package/dist/check/baseline/write-baseline.js +2 -3
- package/dist/check/baseline/write-baseline.js.map +1 -1
- package/dist/check/errors/kit-error-codes.d.ts.map +1 -1
- package/dist/check/errors/kit-error-codes.js +1 -0
- package/dist/check/errors/kit-error-codes.js.map +1 -1
- package/dist/check/explain/authz-docs.js +1 -1
- package/dist/check/explain/authz-docs.js.map +1 -1
- package/dist/check/explain/errors-docs.js +1 -1
- package/dist/check/explain/errors-docs.js.map +1 -1
- package/dist/check/fixtures/authz-policy-fixtures.d.ts.map +1 -1
- package/dist/check/fixtures/authz-policy-fixtures.js +13 -1
- package/dist/check/fixtures/authz-policy-fixtures.js.map +1 -1
- package/dist/check/rules/authz-policy-asked.d.ts.map +1 -1
- package/dist/check/rules/authz-policy-asked.js +45 -6
- package/dist/check/rules/authz-policy-asked.js.map +1 -1
- package/dist/check/rules/test-spec-required.d.ts.map +1 -1
- package/dist/check/rules/test-spec-required.js +3 -1
- package/dist/check/rules/test-spec-required.js.map +1 -1
- package/dist/check/scan/named-outside-imports.d.ts +3 -0
- package/dist/check/scan/named-outside-imports.d.ts.map +1 -0
- package/dist/check/scan/named-outside-imports.js +8 -0
- package/dist/check/scan/named-outside-imports.js.map +1 -0
- package/dist/check/scan/star-exports-of.d.ts +3 -0
- package/dist/check/scan/star-exports-of.d.ts.map +1 -0
- package/dist/check/scan/star-exports-of.js +8 -0
- package/dist/check/scan/star-exports-of.js.map +1 -0
- package/dist/check/scan/string-at.d.ts +3 -0
- package/dist/check/scan/string-at.d.ts.map +1 -0
- package/dist/check/scan/string-at.js +5 -0
- package/dist/check/scan/string-at.js.map +1 -0
- package/dist/check/text/closing-bracket.d.ts +6 -0
- package/dist/check/text/closing-bracket.d.ts.map +1 -0
- package/dist/check/text/closing-bracket.js +24 -0
- package/dist/check/text/closing-bracket.js.map +1 -0
- package/dist/commands/depcruise-config.d.ts.map +1 -1
- package/dist/commands/depcruise-config.js +4 -0
- package/dist/commands/depcruise-config.js.map +1 -1
- package/dist/commands/drizzle-generate.d.ts +3 -2
- package/dist/commands/drizzle-generate.d.ts.map +1 -1
- package/dist/commands/drizzle-generate.js +14 -6
- package/dist/commands/drizzle-generate.js.map +1 -1
- package/dist/commands/generate.d.ts.map +1 -1
- package/dist/commands/generate.js +3 -2
- package/dist/commands/generate.js.map +1 -1
- package/dist/commands/knex-generate.d.ts +10 -0
- package/dist/commands/knex-generate.d.ts.map +1 -0
- package/dist/commands/knex-generate.js +74 -0
- package/dist/commands/knex-generate.js.map +1 -0
- package/dist/commands/lint.js +15 -0
- package/dist/commands/lint.js.map +1 -1
- package/dist/commands/move-to-module.d.ts.map +1 -1
- package/dist/commands/move-to-module.js +3 -0
- package/dist/commands/move-to-module.js.map +1 -1
- package/dist/commands/mutation.js +1 -1
- package/dist/commands/mutation.js.map +1 -1
- package/dist/commands/parse-migration-arguments.d.ts +11 -0
- package/dist/commands/parse-migration-arguments.d.ts.map +1 -0
- package/dist/commands/parse-migration-arguments.js +17 -0
- package/dist/commands/parse-migration-arguments.js.map +1 -0
- package/dist/commands/prisma-generate.d.ts.map +1 -1
- package/dist/commands/prisma-generate.js +5 -11
- package/dist/commands/prisma-generate.js.map +1 -1
- package/dist/commands/typeorm-generate.d.ts +2 -1
- package/dist/commands/typeorm-generate.d.ts.map +1 -1
- package/dist/commands/typeorm-generate.js +5 -2
- package/dist/commands/typeorm-generate.js.map +1 -1
- package/dist/doctor/permission-findings.d.ts.map +1 -1
- package/dist/doctor/permission-findings.js +68 -4
- package/dist/doctor/permission-findings.js.map +1 -1
- package/dist/generate/concept-role.d.ts +10 -0
- package/dist/generate/concept-role.d.ts.map +1 -1
- package/dist/generate/concept.d.ts.map +1 -1
- package/dist/generate/concept.js +5 -1
- package/dist/generate/concept.js.map +1 -1
- package/dist/generate/emit.d.ts +5 -2
- package/dist/generate/emit.d.ts.map +1 -1
- package/dist/generate/emit.js +5 -4
- package/dist/generate/emit.js.map +1 -1
- package/dist/generate/event-names.d.ts.map +1 -1
- package/dist/generate/event-names.js.map +1 -1
- package/dist/generate/files-without-modules.d.ts +8 -0
- package/dist/generate/files-without-modules.d.ts.map +1 -0
- package/dist/generate/files-without-modules.js +12 -0
- package/dist/generate/files-without-modules.js.map +1 -0
- package/dist/generate/grant-permission.js +2 -2
- package/dist/generate/grant-permission.js.map +1 -1
- package/dist/generate/kinds/aggregate-kind.js +4 -4
- package/dist/generate/kinds/aggregate-kind.js.map +1 -1
- package/dist/generate/kinds/command-kind.d.ts.map +1 -1
- package/dist/generate/kinds/command-kind.js +6 -1
- package/dist/generate/kinds/command-kind.js.map +1 -1
- package/dist/generate/kinds/declare-storage.d.ts.map +1 -1
- package/dist/generate/kinds/declare-storage.js +4 -10
- package/dist/generate/kinds/declare-storage.js.map +1 -1
- package/dist/generate/kinds/domain-event-kind.d.ts.map +1 -1
- package/dist/generate/kinds/domain-event-kind.js +3 -1
- package/dist/generate/kinds/domain-event-kind.js.map +1 -1
- package/dist/generate/kinds/e2e-kind.d.ts.map +1 -1
- package/dist/generate/kinds/e2e-kind.js +8 -1
- package/dist/generate/kinds/e2e-kind.js.map +1 -1
- package/dist/generate/kinds/ensure-domain-event.d.ts.map +1 -1
- package/dist/generate/kinds/ensure-domain-event.js +2 -0
- package/dist/generate/kinds/ensure-domain-event.js.map +1 -1
- package/dist/generate/kinds/extraction/add-compose-service.js +1 -1
- package/dist/generate/kinds/extraction/add-compose-service.js.map +1 -1
- package/dist/generate/kinds/extraction/compose-service-of.d.ts +5 -0
- package/dist/generate/kinds/extraction/compose-service-of.d.ts.map +1 -0
- package/dist/generate/kinds/extraction/compose-service-of.js +8 -0
- package/dist/generate/kinds/extraction/compose-service-of.js.map +1 -0
- package/dist/generate/kinds/gateway-kind.js +9 -0
- package/dist/generate/kinds/gateway-kind.js.map +1 -1
- package/dist/generate/kinds/generate-context.d.ts.map +1 -1
- package/dist/generate/kinds/generate-context.js +36 -0
- package/dist/generate/kinds/generate-context.js.map +1 -1
- package/dist/generate/kinds/generate-repository.d.ts.map +1 -1
- package/dist/generate/kinds/generate-repository.js +13 -0
- package/dist/generate/kinds/generate-repository.js.map +1 -1
- package/dist/generate/kinds/query-kind.d.ts.map +1 -1
- package/dist/generate/kinds/query-kind.js +24 -2
- package/dist/generate/kinds/query-kind.js.map +1 -1
- package/dist/generate/kinds/route/find-use-case.js +1 -1
- package/dist/generate/kinds/route/find-use-case.js.map +1 -1
- package/dist/generate/kinds/service-kind.d.ts.map +1 -1
- package/dist/generate/kinds/service-kind.js +3 -2
- package/dist/generate/kinds/service-kind.js.map +1 -1
- package/dist/generate/kinds/tables-files.d.ts +3 -0
- package/dist/generate/kinds/tables-files.d.ts.map +1 -0
- package/dist/generate/kinds/tables-files.js +7 -0
- package/dist/generate/kinds/tables-files.js.map +1 -0
- package/dist/generate/kinds/worker-kind.d.ts.map +1 -1
- package/dist/generate/kinds/worker-kind.js +12 -0
- package/dist/generate/kinds/worker-kind.js.map +1 -1
- package/dist/generate/kinds/write-birth.d.ts +8 -0
- package/dist/generate/kinds/write-birth.d.ts.map +1 -0
- package/dist/generate/kinds/write-birth.js +13 -0
- package/dist/generate/kinds/write-birth.js.map +1 -0
- package/dist/generate/kinds/write-event-sourced-aggregate.d.ts.map +1 -1
- package/dist/generate/kinds/write-event-sourced-aggregate.js +8 -1
- package/dist/generate/kinds/write-event-sourced-aggregate.js.map +1 -1
- package/dist/generate/mark-policy-questions.js +2 -2
- package/dist/generate/mark-policy-questions.js.map +1 -1
- package/dist/generate/permission-name.d.ts +3 -0
- package/dist/generate/permission-name.d.ts.map +1 -0
- package/dist/generate/permission-name.js +3 -0
- package/dist/generate/permission-name.js.map +1 -0
- package/dist/generate/permission-named.d.ts.map +1 -1
- package/dist/generate/permission-named.js +1 -1
- package/dist/generate/permission-named.js.map +1 -1
- package/dist/generate/permission-words.d.ts +7 -0
- package/dist/generate/permission-words.d.ts.map +1 -0
- package/dist/generate/permission-words.js +11 -0
- package/dist/generate/permission-words.js.map +1 -0
- package/dist/generate/refined-by-policy.js +2 -2
- package/dist/generate/refined-by-policy.js.map +1 -1
- package/dist/generate/refuse-stuttering-event.d.ts +8 -0
- package/dist/generate/refuse-stuttering-event.d.ts.map +1 -0
- package/dist/generate/refuse-stuttering-event.js +14 -0
- package/dist/generate/refuse-stuttering-event.js.map +1 -0
- package/dist/generate/shared-writes.d.ts.map +1 -1
- package/dist/generate/shared-writes.js +1 -0
- package/dist/generate/shared-writes.js.map +1 -1
- package/dist/generate/spoken-in-language.d.ts +11 -2
- package/dist/generate/spoken-in-language.d.ts.map +1 -1
- package/dist/generate/spoken-in-language.js +27 -12
- package/dist/generate/spoken-in-language.js.map +1 -1
- package/dist/help/flag-notes.d.ts.map +1 -1
- package/dist/help/flag-notes.js +5 -1
- package/dist/help/flag-notes.js.map +1 -1
- package/dist/help/tool-notes.d.ts.map +1 -1
- package/dist/help/tool-notes.js +16 -0
- package/dist/help/tool-notes.js.map +1 -1
- package/dist/help/usage.d.ts.map +1 -1
- package/dist/help/usage.js +1 -0
- package/dist/help/usage.js.map +1 -1
- package/dist/init/agent-permissions.d.ts.map +1 -1
- package/dist/init/agent-permissions.js +18 -3
- package/dist/init/agent-permissions.js.map +1 -1
- package/dist/init/files/audit-files.d.ts.map +1 -1
- package/dist/init/files/audit-files.js +1 -0
- package/dist/init/files/audit-files.js.map +1 -1
- package/dist/init/files/persistence-files.d.ts.map +1 -1
- package/dist/init/files/persistence-files.js +2 -1
- package/dist/init/files/persistence-files.js.map +1 -1
- package/dist/init/files/script-files.d.ts +4 -1
- package/dist/init/files/script-files.d.ts.map +1 -1
- package/dist/init/files/script-files.js +6 -1
- package/dist/init/files/script-files.js.map +1 -1
- package/dist/init/is-team-file.d.ts +2 -2
- package/dist/init/is-team-file.d.ts.map +1 -1
- package/dist/init/is-team-file.js +5 -3
- package/dist/init/is-team-file.js.map +1 -1
- package/dist/init/keep-regions.d.ts +21 -0
- package/dist/init/keep-regions.d.ts.map +1 -0
- package/dist/init/keep-regions.js +63 -0
- package/dist/init/keep-regions.js.map +1 -0
- package/dist/init/kept-combination-notes.d.ts.map +1 -1
- package/dist/init/kept-combination-notes.js +6 -2
- package/dist/init/kept-combination-notes.js.map +1 -1
- package/dist/init/kept-compose-services.d.ts +6 -0
- package/dist/init/kept-compose-services.d.ts.map +1 -0
- package/dist/init/kept-compose-services.js +42 -0
- package/dist/init/kept-compose-services.js.map +1 -0
- package/dist/init/kept-role-vocabulary.d.ts +3 -0
- package/dist/init/kept-role-vocabulary.d.ts.map +1 -0
- package/dist/init/kept-role-vocabulary.js +7 -0
- package/dist/init/kept-role-vocabulary.js.map +1 -0
- package/dist/init/kept-roles.d.ts +12 -0
- package/dist/init/kept-roles.d.ts.map +1 -0
- package/dist/init/kept-roles.js +29 -0
- package/dist/init/kept-roles.js.map +1 -0
- package/dist/init/kept-wiring.d.ts +22 -0
- package/dist/init/kept-wiring.d.ts.map +1 -0
- package/dist/init/kept-wiring.js +91 -0
- package/dist/init/kept-wiring.js.map +1 -0
- package/dist/init/knip-vars.d.ts.map +1 -1
- package/dist/init/knip-vars.js +5 -1
- package/dist/init/knip-vars.js.map +1 -1
- package/dist/init/manifest/database-scripts.d.ts.map +1 -1
- package/dist/init/manifest/database-scripts.js +5 -3
- package/dist/init/manifest/database-scripts.js.map +1 -1
- package/dist/init/manifest/scripts-for.d.ts.map +1 -1
- package/dist/init/manifest/scripts-for.js +8 -0
- package/dist/init/manifest/scripts-for.js.map +1 -1
- package/dist/init/manifest/versions.js +24 -24
- package/dist/init/orphaned-wiring-notes.d.ts +13 -0
- package/dist/init/orphaned-wiring-notes.d.ts.map +1 -0
- package/dist/init/orphaned-wiring-notes.js +42 -0
- package/dist/init/orphaned-wiring-notes.js.map +1 -0
- package/dist/init/profile-hooks.js +1 -1
- package/dist/init/profile-hooks.js.map +1 -1
- package/dist/init/repositories-left-behind.d.ts +12 -0
- package/dist/init/repositories-left-behind.d.ts.map +1 -0
- package/dist/init/repositories-left-behind.js +26 -0
- package/dist/init/repositories-left-behind.js.map +1 -0
- package/dist/init/rewire-audited-events.d.ts +10 -0
- package/dist/init/rewire-audited-events.d.ts.map +1 -0
- package/dist/init/rewire-audited-events.js +32 -0
- package/dist/init/rewire-audited-events.js.map +1 -0
- package/dist/init/rewire-contexts.d.ts +15 -0
- package/dist/init/rewire-contexts.d.ts.map +1 -0
- package/dist/init/rewire-contexts.js +41 -0
- package/dist/init/rewire-contexts.js.map +1 -0
- package/dist/init/rewire-preset.d.ts +9 -0
- package/dist/init/rewire-preset.d.ts.map +1 -0
- package/dist/init/rewire-preset.js +29 -0
- package/dist/init/rewire-preset.js.map +1 -0
- package/dist/init/rewire-tables.d.ts +10 -0
- package/dist/init/rewire-tables.d.ts.map +1 -0
- package/dist/init/rewire-tables.js +54 -0
- package/dist/init/rewire-tables.js.map +1 -0
- package/dist/init/run-init.d.ts.map +1 -1
- package/dist/init/run-init.js +28 -28
- package/dist/init/run-init.js.map +1 -1
- package/dist/init/stack/kept-flag-notes.d.ts +7 -0
- package/dist/init/stack/kept-flag-notes.d.ts.map +1 -0
- package/dist/init/stack/kept-flag-notes.js +24 -0
- package/dist/init/stack/kept-flag-notes.js.map +1 -0
- package/dist/init/stack/refuse-unused-no-outbox.d.ts +4 -0
- package/dist/init/stack/refuse-unused-no-outbox.d.ts.map +1 -0
- package/dist/init/stack/refuse-unused-no-outbox.js +9 -0
- package/dist/init/stack/refuse-unused-no-outbox.js.map +1 -0
- package/dist/init/stack/resolve-stack.d.ts.map +1 -1
- package/dist/init/stack/resolve-stack.js +10 -0
- package/dist/init/stack/resolve-stack.js.map +1 -1
- package/dist/init/stack-before.d.ts +4 -0
- package/dist/init/stack-before.d.ts.map +1 -0
- package/dist/init/stack-before.js +11 -0
- package/dist/init/stack-before.js.map +1 -0
- package/dist/init/wiring-notes.d.ts +9 -0
- package/dist/init/wiring-notes.d.ts.map +1 -0
- package/dist/init/wiring-notes.js +22 -0
- package/dist/init/wiring-notes.js.map +1 -0
- package/dist/init/with-named-imports.d.ts +8 -0
- package/dist/init/with-named-imports.d.ts.map +1 -0
- package/dist/init/with-named-imports.js +69 -0
- package/dist/init/with-named-imports.js.map +1 -0
- package/dist/init/with-system-grants.d.ts +7 -0
- package/dist/init/with-system-grants.d.ts.map +1 -0
- package/dist/init/with-system-grants.js +26 -0
- package/dist/init/with-system-grants.js.map +1 -0
- package/dist/init/write-local-environment.d.ts +8 -0
- package/dist/init/write-local-environment.d.ts.map +1 -0
- package/dist/init/write-local-environment.js +18 -0
- package/dist/init/write-local-environment.js.map +1 -0
- package/dist/lint/eslint-in-project.d.ts +1 -1
- package/dist/lint/eslint-in-project.d.ts.map +1 -1
- package/dist/lint/eslint-in-project.js +11 -2
- package/dist/lint/eslint-in-project.js.map +1 -1
- package/dist/markers/index.d.ts +3 -0
- package/dist/markers/index.d.ts.map +1 -1
- package/dist/markers/index.js +3 -0
- package/dist/markers/index.js.map +1 -1
- package/dist/markers/region-marker.d.ts +3 -0
- package/dist/markers/region-marker.d.ts.map +1 -0
- package/dist/markers/region-marker.js +3 -0
- package/dist/markers/region-marker.js.map +1 -0
- package/dist/markers/regions-of.d.ts +9 -0
- package/dist/markers/regions-of.d.ts.map +1 -0
- package/dist/markers/regions-of.js +20 -0
- package/dist/markers/regions-of.js.map +1 -0
- package/dist/markers/unpaired-markers.d.ts +3 -0
- package/dist/markers/unpaired-markers.d.ts.map +1 -0
- package/dist/markers/unpaired-markers.js +13 -0
- package/dist/markers/unpaired-markers.js.map +1 -0
- package/dist/merge/apply-resolutions.d.ts.map +1 -1
- package/dist/merge/apply-resolutions.js +6 -4
- package/dist/merge/apply-resolutions.js.map +1 -1
- package/dist/merge/continue-merge.d.ts.map +1 -1
- package/dist/merge/continue-merge.js +1 -0
- package/dist/merge/continue-merge.js.map +1 -1
- package/dist/merge/ensure-mergeable.js +1 -1
- package/dist/merge/ensure-mergeable.js.map +1 -1
- package/dist/merge/lost/verify-merges.d.ts.map +1 -1
- package/dist/merge/lost/verify-merges.js +4 -0
- package/dist/merge/lost/verify-merges.js.map +1 -1
- package/dist/merge/merge-state.d.ts.map +1 -1
- package/dist/merge/merge-state.js +2 -2
- package/dist/merge/merge-state.js.map +1 -1
- package/dist/merge/merge-trunk.d.ts.map +1 -1
- package/dist/merge/merge-trunk.js +4 -0
- package/dist/merge/merge-trunk.js.map +1 -1
- package/dist/merge/refuse-shallow-history.d.ts +10 -0
- package/dist/merge/refuse-shallow-history.d.ts.map +1 -0
- package/dist/merge/refuse-shallow-history.js +15 -0
- package/dist/merge/refuse-shallow-history.js.map +1 -0
- package/dist/merge/resume-merge.js +2 -2
- package/dist/merge/resume-merge.js.map +1 -1
- package/dist/merge/settle-regions.d.ts.map +1 -1
- package/dist/merge/settle-regions.js +3 -4
- package/dist/merge/settle-regions.js.map +1 -1
- package/dist/migration/audit-guard/append-audit-guard.d.ts +4 -2
- package/dist/migration/audit-guard/append-audit-guard.d.ts.map +1 -1
- package/dist/migration/audit-guard/append-audit-guard.js +18 -3
- package/dist/migration/audit-guard/append-audit-guard.js.map +1 -1
- package/dist/migration/declared-tables.d.ts +8 -0
- package/dist/migration/declared-tables.d.ts.map +1 -0
- package/dist/migration/declared-tables.js +13 -0
- package/dist/migration/declared-tables.js.map +1 -0
- package/dist/migration/find-project-formatter.d.ts.map +1 -1
- package/dist/migration/find-project-formatter.js +2 -1
- package/dist/migration/find-project-formatter.js.map +1 -1
- package/dist/migration/index.d.ts +8 -0
- package/dist/migration/index.d.ts.map +1 -1
- package/dist/migration/index.js +8 -0
- package/dist/migration/index.js.map +1 -1
- package/dist/migration/knex-migration-text.d.ts +4 -0
- package/dist/migration/knex-migration-text.d.ts.map +1 -0
- package/dist/migration/knex-migration-text.js +24 -0
- package/dist/migration/knex-migration-text.js.map +1 -0
- package/dist/migration/knex-schema-difference.d.ts +12 -0
- package/dist/migration/knex-schema-difference.d.ts.map +1 -0
- package/dist/migration/knex-schema-difference.js +165 -0
- package/dist/migration/knex-schema-difference.js.map +1 -0
- package/dist/migration/listed-in-index.d.ts +6 -0
- package/dist/migration/listed-in-index.d.ts.map +1 -0
- package/dist/migration/listed-in-index.js +8 -0
- package/dist/migration/listed-in-index.js.map +1 -0
- package/dist/migration/refuse-other-orm.d.ts +8 -0
- package/dist/migration/refuse-other-orm.d.ts.map +1 -0
- package/dist/migration/refuse-other-orm.js +34 -0
- package/dist/migration/refuse-other-orm.js.map +1 -0
- package/dist/migration/required-migration-name.d.ts +3 -0
- package/dist/migration/required-migration-name.d.ts.map +1 -0
- package/dist/migration/required-migration-name.js +11 -0
- package/dist/migration/required-migration-name.js.map +1 -0
- package/dist/migration/warn-dropped-context-tables.d.ts +12 -0
- package/dist/migration/warn-dropped-context-tables.d.ts.map +1 -0
- package/dist/migration/warn-dropped-context-tables.js +88 -0
- package/dist/migration/warn-dropped-context-tables.js.map +1 -0
- package/dist/package-manager/dialects.js +1 -1
- package/dist/package-manager/dialects.js.map +1 -1
- package/dist/package-manager/in-project-dialect.d.ts +8 -0
- package/dist/package-manager/in-project-dialect.d.ts.map +1 -0
- package/dist/package-manager/in-project-dialect.js +22 -0
- package/dist/package-manager/in-project-dialect.js.map +1 -0
- package/dist/presets/adapter-of.d.ts +5 -0
- package/dist/presets/adapter-of.d.ts.map +1 -0
- package/dist/presets/adapter-of.js +6 -0
- package/dist/presets/adapter-of.js.map +1 -0
- package/dist/presets/apply-preset.d.ts.map +1 -1
- package/dist/presets/apply-preset.js +1 -5
- package/dist/presets/apply-preset.js.map +1 -1
- package/dist/presets/grant-to-signed-in.d.ts.map +1 -1
- package/dist/presets/grant-to-signed-in.js +1 -24
- package/dist/presets/grant-to-signed-in.js.map +1 -1
- package/dist/presets/identity-terms.d.ts.map +1 -1
- package/dist/presets/identity-terms.js +4 -0
- package/dist/presets/identity-terms.js.map +1 -1
- package/dist/presets/lay-out-prisma-models.js +1 -19
- package/dist/presets/lay-out-prisma-models.js.map +1 -1
- package/dist/presets/organisations-as-tenants.d.ts +2 -2
- package/dist/presets/organisations-as-tenants.d.ts.map +1 -1
- package/dist/presets/organisations-as-tenants.js +46 -2
- package/dist/presets/organisations-as-tenants.js.map +1 -1
- package/dist/presets/preset-named.d.ts +2 -0
- package/dist/presets/preset-named.d.ts.map +1 -1
- package/dist/presets/preset-named.js +1 -1
- package/dist/presets/preset-named.js.map +1 -1
- package/dist/presets/wrap-authorizer.d.ts +4 -0
- package/dist/presets/wrap-authorizer.d.ts.map +1 -0
- package/dist/presets/wrap-authorizer.js +25 -0
- package/dist/presets/wrap-authorizer.js.map +1 -0
- package/dist/prisma-schema/datasource-schemas.d.ts +3 -0
- package/dist/prisma-schema/datasource-schemas.d.ts.map +1 -0
- package/dist/prisma-schema/datasource-schemas.js +5 -0
- package/dist/prisma-schema/datasource-schemas.js.map +1 -0
- package/dist/prisma-schema/index.d.ts +4 -0
- package/dist/prisma-schema/index.d.ts.map +1 -1
- package/dist/prisma-schema/index.js +4 -0
- package/dist/prisma-schema/index.js.map +1 -1
- package/dist/prisma-schema/preview-features-of.d.ts +3 -0
- package/dist/prisma-schema/preview-features-of.d.ts.map +1 -0
- package/dist/prisma-schema/preview-features-of.js +7 -0
- package/dist/prisma-schema/preview-features-of.js.map +1 -0
- package/dist/prisma-schema/with-datasource-schema.d.ts +3 -0
- package/dist/prisma-schema/with-datasource-schema.d.ts.map +1 -0
- package/dist/prisma-schema/with-datasource-schema.js +9 -0
- package/dist/prisma-schema/with-datasource-schema.js.map +1 -0
- package/dist/prisma-schema/with-preview-feature.d.ts +3 -0
- package/dist/prisma-schema/with-preview-feature.d.ts.map +1 -0
- package/dist/prisma-schema/with-preview-feature.js +19 -0
- package/dist/prisma-schema/with-preview-feature.js.map +1 -0
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js +10 -1
- package/dist/run.js.map +1 -1
- package/dist/sdk/render-client.js +1 -1
- package/dist/sdk/render-client.js.map +1 -1
- package/dist/slice/record-verification.d.ts.map +1 -1
- package/dist/slice/record-verification.js +2 -5
- package/dist/slice/record-verification.js.map +1 -1
- package/dist/stack/stack-vars.js +6 -2
- package/dist/stack/stack-vars.js.map +1 -1
- package/dist/stories/open-story-scope.d.ts.map +1 -1
- package/dist/stories/open-story-scope.js +2 -4
- package/dist/stories/open-story-scope.js.map +1 -1
- package/dist/story/change-gated.d.ts +3 -3
- package/dist/story/change-gated.d.ts.map +1 -1
- package/dist/story/change-gated.js +13 -7
- package/dist/story/change-gated.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/worker/open-worker-scope.d.ts.map +1 -1
- package/dist/worker/open-worker-scope.js +2 -3
- package/dist/worker/open-worker-scope.js.map +1 -1
- package/dist/workspace/write-inside-project.d.ts +8 -0
- package/dist/workspace/write-inside-project.d.ts.map +1 -0
- package/dist/workspace/write-inside-project.js +17 -0
- package/dist/workspace/write-inside-project.js.map +1 -0
- package/package.json +5 -5
- package/templates/aggregate/event-sourced.events.mapper.ts.tpl +5 -1
- package/templates/command/handler.declared.ts.tpl +4 -12
- package/templates/command/handler.ts.tpl +4 -12
- package/templates/e2e/e2e.spec.ts.tpl +2 -2
- package/templates/init/README.md.tpl +29 -5
- package/templates/init/docker/docker-compose.yml.tpl +5 -2
- package/templates/init/docker/dockerignore.tpl +1 -0
- package/templates/init/docker/env.example.tpl +8 -1
- package/templates/init/gitignore.tpl +1 -0
- package/templates/init/hooks/change-reference.mjs +96 -17
- package/templates/init/hooks/production-gate.mjs +65 -11
- package/templates/init/jest.config.js.tpl +4 -1
- package/templates/init/platform/audit/audit.module.tsyringe.ts.tpl +25 -8
- package/templates/init/platform/audit/create-audit-trail.ts.tpl +59 -0
- package/templates/init/platform/audit/create-audit.ts.tpl +1 -46
- package/templates/init/platform/auth/authentication/development-header-authenticator.ts.tpl +7 -3
- package/templates/init/platform/auth/relationships/relationship-schema.ts.tpl +5 -0
- package/templates/init/platform/composition/compose-application.manual.ts.tpl +22 -7
- package/templates/init/platform/composition/compose-application.tsyringe.ts.tpl +2 -4
- package/templates/init/platform/config/app-config.ts.tpl +9 -0
- package/templates/init/platform/config/load-config.ts.tpl +24 -0
- package/templates/init/platform/database/data-source.typeorm.ts.tpl +6 -0
- package/templates/init/platform/database/gitkeep +0 -0
- package/templates/init/platform/database/knexfile.js.tpl +10 -3
- package/templates/init/platform/database/open-persistence.prisma.ts.tpl +5 -2
- package/templates/init/platform/database/persistence-over.prisma.ts.tpl +11 -3
- package/templates/init/platform/database/prisma.config.ts.tpl +6 -0
- package/templates/init/platform/database/schema.knex.ts.tpl +4 -3
- package/templates/init/platform/http/start-http-server.express.ts.tpl +9 -6
- package/templates/init/platform/http/start-http-server.fastify.ts.tpl +5 -2
- package/templates/init/platform/http/start-http-server.hono.ts.tpl +5 -2
- package/templates/init/platform/jobs/job-settings.ts.tpl +3 -0
- package/templates/init/platform/privacy/run-export.manual.ts.tpl +24 -2
- package/templates/init/platform/privacy/run-export.tsyringe.ts.tpl +30 -1
- package/templates/init/scripts/audit-verify.ts.tpl +35 -0
- package/templates/init/scripts/privacy-export.manual.ts.tpl +1 -7
- package/templates/init/scripts/privacy-export.tsyringe.ts.tpl +1 -7
- package/templates/pipeline/github/dependabot.yml +6 -0
- package/templates/pipeline/github/workflows/ci.yml.tpl +26 -1
- package/templates/pipeline/github/workflows/claude-review.yml +3 -2
- package/templates/pipeline/github/workflows/claude-triage.yml +1 -1
- package/templates/pipeline/github/workflows/codeql.yml +2 -0
- package/templates/pipeline/github/workflows/copilot-setup-steps.yml +2 -0
- package/templates/pipeline/github/workflows/intent-to-spec.yml +12 -4
- package/templates/pipeline/github/workflows/pr-title.yml +2 -0
- package/templates/pipeline/gitlab/claude-review.gitlab-ci.yml.tpl +1 -1
- package/templates/pipeline/knip.json.tpl +1 -4
- package/templates/pipeline/package-scripts.json +2 -2
- package/templates/pipeline/renovate.json +11 -0
- package/templates/pipeline/vitest.config.ts.tpl +3 -2
- package/templates/presets/identity/context/__context__.codes.named.ts.tpl +1 -0
- package/templates/presets/identity/context/__context__.module.explicit.ts.tpl +1 -1
- package/templates/presets/identity/context/application/commands/accept-invitation/accept-invitation.handler.ts.tpl +28 -1
- package/templates/presets/identity/context/domain/aggregates/invitation.aggregate.ts.tpl +13 -1
- package/templates/presets/identity/context/domain/aggregates/member.aggregate.ts.tpl +6 -1
- package/templates/presets/identity/context/domain/errors/invitation-withdrawn.error.named.ts.tpl +13 -0
- package/templates/presets/identity/context/domain/errors/invitation.error.factories.ts.tpl +8 -0
- package/templates/presets/identity/context/domain/services/role-rights.service.ts.tpl +23 -1
- package/templates/presets/identity/context/infrastructure/persistence/__context__.schema.drizzle.ts.tpl +1 -0
- package/templates/presets/identity/context/infrastructure/persistence/create-__context__-tables.schema.knex.ts.tpl +1 -0
- package/templates/presets/identity/context/infrastructure/persistence/drizzle-account.repository.drizzle.ts.tpl +6 -2
- package/templates/presets/identity/context/infrastructure/persistence/drizzle-delegation.repository.drizzle.ts.tpl +6 -2
- package/templates/presets/identity/context/infrastructure/persistence/drizzle-invitation.repository.drizzle.ts.tpl +6 -2
- package/templates/presets/identity/context/infrastructure/persistence/drizzle-member.repository.drizzle.ts.tpl +6 -2
- package/templates/presets/identity/context/infrastructure/persistence/drizzle-organisation.repository.drizzle.ts.tpl +6 -2
- package/templates/presets/identity/context/infrastructure/persistence/invitation-row.schema.knex.ts.tpl +1 -0
- package/templates/presets/identity/context/infrastructure/persistence/invitation.mapper.drizzle.ts.tpl +2 -0
- package/templates/presets/identity/context/infrastructure/persistence/invitation.mapper.knex.ts.tpl +2 -0
- package/templates/presets/identity/context/infrastructure/persistence/invitation.mapper.prisma.ts.tpl +2 -0
- package/templates/presets/identity/context/infrastructure/persistence/prisma-account.repository.prisma.ts.tpl +8 -5
- package/templates/presets/identity/context/infrastructure/persistence/prisma-delegation.repository.prisma.ts.tpl +8 -5
- package/templates/presets/identity/context/infrastructure/persistence/prisma-invitation.repository.prisma.ts.tpl +8 -5
- package/templates/presets/identity/context/infrastructure/persistence/prisma-member.repository.prisma.ts.tpl +8 -5
- package/templates/presets/identity/context/infrastructure/persistence/prisma-organisation.repository.prisma.ts.tpl +8 -5
- package/templates/presets/identity/context/presentation/http/invitations/accept-invitation/accept-invitation.controller.kit-routes.ts.tpl +1 -0
- package/templates/presets/identity/context/presentation/http/invitations/accept-invitation/accept-invitation.controller.nest-routes.ts.tpl +1 -0
- package/templates/presets/identity/context/test/builders/invitation.builder.ts.tpl +15 -2
- package/templates/presets/identity/context/test/integration/invitation.repository.contract.spec.ts.tpl +10 -0
- package/templates/presets/identity/context/test/unit/accept-invitation.handler.spec.ts.tpl +114 -4
- package/templates/presets/identity/context/test/worlds/__context__.world.explicit.ts.tpl +1 -1
- package/templates/presets/identity/design.md.tpl +3 -1
- package/templates/presets/identity/prisma/models.prisma.tpl +1 -0
- package/templates/query/reader.fake.ts.tpl +4 -6
- package/templates/query/reader.in-memory.ts.tpl +1 -1
- package/templates/repository/drizzle/repository.ts.tpl +4 -3
- package/templates/repository/knex/table.tpl +1 -1
- package/templates/repository/prisma/repository.ts.tpl +24 -18
- package/templates/state-machine/state-machine.spec.ts.tpl +5 -0
- package/templates/init/platform/database/migration.knex.js.tpl +0 -8
|
@@ -1,29 +1,45 @@
|
|
|
1
1
|
import { describe, expect, it } from '{{tests.module}}';
|
|
2
2
|
import { InvitationStatus } from '{{alias.context}}/domain/vocabularies/invitation-status.vocabulary{{alias.ext}}';
|
|
3
|
+
import { MemberRight } from '{{alias.context}}/domain/vocabularies/member-right.vocabulary{{alias.ext}}';
|
|
3
4
|
import { MemberRole } from '{{alias.context}}/domain/vocabularies/member-role.vocabulary{{alias.ext}}';
|
|
4
5
|
import { AcceptInvitationCommand } from '{{alias.context}}/application/commands/accept-invitation/accept-invitation.command{{alias.ext}}';
|
|
5
6
|
import { anAccount } from '{{alias.context}}/test/builders/account.builder{{alias.ext}}';
|
|
7
|
+
import { aDelegation } from '{{alias.context}}/test/builders/delegation.builder{{alias.ext}}';
|
|
6
8
|
import { anInvitation } from '{{alias.context}}/test/builders/invitation.builder{{alias.ext}}';
|
|
7
9
|
import { aMember } from '{{alias.context}}/test/builders/member.builder{{alias.ext}}';
|
|
8
|
-
import { arrangeIdentity
|
|
10
|
+
import { arrangeIdentity } from '{{alias.context}}/test/worlds/{{context.kebab}}.world{{alias.ext}}';
|
|
11
|
+
|
|
12
|
+
const DAY = 86_400_000;
|
|
9
13
|
|
|
10
14
|
describe('Accept invitation', () => {
|
|
11
15
|
it('makes the person it was sent to a member, in its role, and tells the provider and the other contexts', async () => {
|
|
12
|
-
const { application, accounts, invitations, members, identityProvider, tokens, as } =
|
|
16
|
+
const { application, accounts, invitations, members, identityProvider, tokens, as } = arrangeIdentity();
|
|
13
17
|
const token = tokens.issue();
|
|
14
18
|
|
|
15
19
|
await accounts.save(anAccount().identifiedBy('subject-grace').reachedAt('grace@example.test').build());
|
|
20
|
+
await members.save(aMember().of('acme', 'subject-ada').as(MemberRole.Owner).build());
|
|
16
21
|
|
|
17
22
|
await invitations.save(
|
|
18
|
-
anInvitation()
|
|
23
|
+
anInvitation()
|
|
24
|
+
.identifiedBy('invitation-1')
|
|
25
|
+
.to('acme')
|
|
26
|
+
.as(MemberRole.Admin)
|
|
27
|
+
.issuedBy('subject-ada')
|
|
28
|
+
.withTokenHash(token.digest)
|
|
29
|
+
.build(),
|
|
19
30
|
);
|
|
20
31
|
|
|
32
|
+
// Started once the organisation is arranged: what the provider is asked from now on follows the answer alone.
|
|
33
|
+
await application.start();
|
|
34
|
+
|
|
35
|
+
const before = application.eventBus.published.length;
|
|
36
|
+
|
|
21
37
|
await application.commandBus.execute(new AcceptInvitationCommand(as('subject-grace'), token.token));
|
|
22
38
|
|
|
23
39
|
expect((await members.findOf('acme', 'subject-grace'))?.role).toBe(MemberRole.Admin);
|
|
24
40
|
expect((await invitations.findById('invitation-1'))?.status).toBe(InvitationStatus.Accepted);
|
|
25
41
|
expect(identityProvider.asked).toEqual(['add subject-grace to acme']);
|
|
26
|
-
expect(application.eventBus.published).toMatchObject([{ type: '{{context.kebab}}.member.joined' }]);
|
|
42
|
+
expect(application.eventBus.published.slice(before)).toMatchObject([{ type: '{{context.kebab}}.member.joined' }]);
|
|
27
43
|
});
|
|
28
44
|
|
|
29
45
|
it('knows no token it did not issue, and no person who never signed in', async () => {
|
|
@@ -67,3 +83,97 @@ describe('Accept invitation', () => {
|
|
|
67
83
|
});
|
|
68
84
|
});
|
|
69
85
|
});
|
|
86
|
+
|
|
87
|
+
describe('Accept invitation, while its issuer may still invite in its role', () => {
|
|
88
|
+
it('withdraws an invitation whose issuer left the organisation, or no longer holds a role that issues it', async () => {
|
|
89
|
+
const { application, accounts, invitations, members, tokens, as } = arrangeIdentity();
|
|
90
|
+
const now = application.clock.now();
|
|
91
|
+
const left = tokens.issue();
|
|
92
|
+
const demoted = tokens.issue();
|
|
93
|
+
|
|
94
|
+
await accounts.save(anAccount().identifiedBy('subject-grace').reachedAt('grace@example.test').build());
|
|
95
|
+
await members.save(aMember().of('acme', 'subject-ada').as(MemberRole.Owner).removedAt(now).build());
|
|
96
|
+
await members.save(aMember().of('acme', 'subject-alan').as(MemberRole.Admin).build());
|
|
97
|
+
|
|
98
|
+
await invitations.save(
|
|
99
|
+
anInvitation().to('acme').as(MemberRole.Owner).issuedBy('subject-ada').withTokenHash(left.digest).build(),
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
await invitations.save(
|
|
103
|
+
anInvitation().to('acme').as(MemberRole.Owner).issuedBy('subject-alan').withTokenHash(demoted.digest).build(),
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
await expect(
|
|
107
|
+
application.commandBus.execute(new AcceptInvitationCommand(as('subject-grace'), left.token)),
|
|
108
|
+
).rejects.toMatchObject({ code: 'INVITATION_WITHDRAWN' });
|
|
109
|
+
|
|
110
|
+
await expect(
|
|
111
|
+
application.commandBus.execute(new AcceptInvitationCommand(as('subject-grace'), demoted.token)),
|
|
112
|
+
).rejects.toMatchObject({ code: 'INVITATION_WITHDRAWN' });
|
|
113
|
+
|
|
114
|
+
expect(await members.findOf('acme', 'subject-grace')).toBeUndefined();
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
it('holds an invitation issued under a delegation while the delegation lends the right to invite', async () => {
|
|
118
|
+
const { application, accounts, invitations, members, delegations, tokens, as } = arrangeIdentity();
|
|
119
|
+
const now = application.clock.now();
|
|
120
|
+
const token = tokens.issue();
|
|
121
|
+
|
|
122
|
+
await accounts.save(anAccount().identifiedBy('subject-grace').reachedAt('grace@example.test').build());
|
|
123
|
+
await members.save(aMember().of('acme', 'subject-alan').build());
|
|
124
|
+
|
|
125
|
+
await delegations.save(
|
|
126
|
+
aDelegation()
|
|
127
|
+
.identifiedBy('delegation-1')
|
|
128
|
+
.to('subject-alan')
|
|
129
|
+
.lending(MemberRight.InviteMembers)
|
|
130
|
+
.between(new Date(now.getTime() - DAY), new Date(now.getTime() + DAY))
|
|
131
|
+
.build(),
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
await invitations.save(
|
|
135
|
+
anInvitation().to('acme').issuedBy('subject-alan').under('delegation-1').withTokenHash(token.digest).build(),
|
|
136
|
+
);
|
|
137
|
+
|
|
138
|
+
await application.commandBus.execute(new AcceptInvitationCommand(as('subject-grace'), token.token));
|
|
139
|
+
|
|
140
|
+
expect((await members.findOf('acme', 'subject-grace'))?.role).toBe(MemberRole.Member);
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
it('withdraws an invitation issued under a delegation once that delegation ended, whatever another one lends', async () => {
|
|
144
|
+
const { application, accounts, invitations, members, delegations, tokens, as } = arrangeIdentity();
|
|
145
|
+
const now = application.clock.now();
|
|
146
|
+
const token = tokens.issue();
|
|
147
|
+
|
|
148
|
+
await accounts.save(anAccount().identifiedBy('subject-grace').reachedAt('grace@example.test').build());
|
|
149
|
+
await members.save(aMember().of('acme', 'subject-alan').build());
|
|
150
|
+
|
|
151
|
+
await delegations.save(
|
|
152
|
+
aDelegation()
|
|
153
|
+
.identifiedBy('delegation-1')
|
|
154
|
+
.to('subject-alan')
|
|
155
|
+
.lending(MemberRight.InviteMembers)
|
|
156
|
+
.between(new Date(now.getTime() - 2 * DAY), new Date(now.getTime() - DAY))
|
|
157
|
+
.build(),
|
|
158
|
+
);
|
|
159
|
+
|
|
160
|
+
await delegations.save(
|
|
161
|
+
aDelegation()
|
|
162
|
+
.identifiedBy('delegation-2')
|
|
163
|
+
.to('subject-alan')
|
|
164
|
+
.lending(MemberRight.InviteMembers)
|
|
165
|
+
.between(new Date(now.getTime() - DAY), new Date(now.getTime() + DAY))
|
|
166
|
+
.build(),
|
|
167
|
+
);
|
|
168
|
+
|
|
169
|
+
await invitations.save(
|
|
170
|
+
anInvitation().to('acme').issuedBy('subject-alan').under('delegation-1').withTokenHash(token.digest).build(),
|
|
171
|
+
);
|
|
172
|
+
|
|
173
|
+
await expect(
|
|
174
|
+
application.commandBus.execute(new AcceptInvitationCommand(as('subject-grace'), token.token)),
|
|
175
|
+
).rejects.toMatchObject({ code: 'INVITATION_WITHDRAWN' });
|
|
176
|
+
|
|
177
|
+
expect(await members.findOf('acme', 'subject-grace')).toBeUndefined();
|
|
178
|
+
});
|
|
179
|
+
});
|
|
@@ -232,7 +232,7 @@ function registerInvitations({ buses, repositories, ports, access }: Wired): voi
|
|
|
232
232
|
|
|
233
233
|
commandBus.register(
|
|
234
234
|
AcceptInvitationCommand,
|
|
235
|
-
new AcceptInvitationHandler(invitations, members, accounts, ports.tokens, ids, clock),
|
|
235
|
+
new AcceptInvitationHandler(invitations, members, accounts, delegations, ports.tokens, ids, clock),
|
|
236
236
|
);
|
|
237
237
|
|
|
238
238
|
commandBus.register(
|
|
@@ -23,7 +23,9 @@ owners and two owners who remove each other at once cannot both commit.
|
|
|
23
23
|
**Invitations.** An invitation is issued to an email address, in a role, for a week. Its token
|
|
24
24
|
is answered to the inviter once (`POST /organisations/:organisationId/invitations`) and only its
|
|
25
25
|
SHA-256 digest is stored: send it to the person (a notification context, a link), who accepts or
|
|
26
|
-
declines it signed in, with the address it was sent to.
|
|
26
|
+
declines it signed in, with the address it was sent to. It holds while its issuer may still
|
|
27
|
+
invite in its role: once the issuer is removed, deactivated, demoted below it or no longer lent
|
|
28
|
+
the right to invite, it is withdrawn and lets nobody in (`INVITATION_WITHDRAWN`).
|
|
27
29
|
|
|
28
30
|
**Delegations.** A member lends some of the rights of their role to another member of the
|
|
29
31
|
organisation, for ninety days at most: the delegate acts in their own name, with those rights, and
|
|
@@ -90,6 +90,7 @@ model {{context.pascal}}Invitation {
|
|
|
90
90
|
role {{context.pascal}}MemberRole
|
|
91
91
|
tokenHash String @unique @map("token_hash")
|
|
92
92
|
invitedBy String @map("invited_by")
|
|
93
|
+
delegationId String? @map("delegation_id")
|
|
93
94
|
issuedAt DateTime @map("issued_at") @db.Timestamptz(3)
|
|
94
95
|
expiresAt DateTime @map("expires_at") @db.Timestamptz(3)
|
|
95
96
|
status {{context.pascal}}InvitationStatus
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import type { {{name.pascal}}Reader } from '{{alias.context}}/application/ports/{{name.kebab}}-reader.port{{alias.ext}}';
|
|
2
1
|
import type { {{name.pascal}}Result } from '{{alias.context}}/application/queries/{{name.kebab}}/{{name.kebab}}.result{{alias.ext}}';
|
|
2
|
+
import { InMemory{{name.pascal}}Reader } from '{{alias.context}}/infrastructure/persistence/{{reader.file}}{{alias.ext}}';
|
|
3
3
|
|
|
4
|
-
export class Fake{{name.pascal}}Reader
|
|
5
|
-
constructor(
|
|
6
|
-
|
|
7
|
-
async read(): Promise<{{name.pascal}}Result> {
|
|
8
|
-
return this.answer;
|
|
4
|
+
export class Fake{{name.pascal}}Reader extends InMemory{{name.pascal}}Reader {
|
|
5
|
+
constructor(protected override readonly answer: {{name.pascal}}Result) {
|
|
6
|
+
super();
|
|
9
7
|
}
|
|
10
8
|
}
|
|
@@ -12,7 +12,7 @@ import type { {{name.pascal}}Result } from '{{alias.context}}/application/querie
|
|
|
12
12
|
@Repository({{name.pascal}}Reader)
|
|
13
13
|
{{/if}}
|
|
14
14
|
export class InMemory{{name.pascal}}Reader implements {{name.pascal}}Reader {
|
|
15
|
-
|
|
15
|
+
protected readonly answer: {{name.pascal}}Result = {};
|
|
16
16
|
|
|
17
17
|
async read(query: {{name.pascal}}Query): Promise<{{name.pascal}}Result> {
|
|
18
18
|
// TODO(domain): replace this canned answer by a real read of the projection, filtered by `query`; a production adapter (SQL view, search index) implements the same port next to this file.
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { and, eq } from 'drizzle-orm';
|
|
2
2
|
{{#if tenant.scoped}}
|
|
3
|
-
import { optimisticUpdate, ownTenantCondition, tenantCondition } from '@ddd-ts-kit/drizzle/postgres';
|
|
3
|
+
import { optimisticUpdate, ownTenantCondition, primaryKeyOf, tenantCondition } from '@ddd-ts-kit/drizzle/postgres';
|
|
4
4
|
{{/if}}
|
|
5
5
|
{{#unless tenant.scoped}}
|
|
6
|
-
import { optimisticUpdate } from '@ddd-ts-kit/drizzle/postgres';
|
|
6
|
+
import { optimisticUpdate, primaryKeyOf } from '@ddd-ts-kit/drizzle/postgres';
|
|
7
7
|
{{/unless}}
|
|
8
8
|
{{#if tenant.scoped}}
|
|
9
9
|
import { stampCreation, stampUpdate, tenantScopeOf, type Clock, type ExecutionScope } from '@ddd-ts-kit/kernel';
|
|
@@ -63,8 +63,9 @@ export class Drizzle{{aggregate.pascal}}Repository implements {{aggregate.pascal
|
|
|
63
63
|
const row = { ...state, {{#if tenant.scoped}}...tenantScopeOf(this.scope), {{/if}}...stampCreation(this.scope, this.clock) };
|
|
64
64
|
|
|
65
65
|
const insertion = this.database.executor().insert({{aggregate.tableCamel}}).values(row);
|
|
66
|
+
const ignoringTheKey = insertion.onConflictDoNothing({ target: primaryKeyOf({{aggregate.tableCamel}}) });
|
|
66
67
|
|
|
67
|
-
return
|
|
68
|
+
return ignoringTheKey.returning({ id: {{aggregate.tableCamel}}.id });
|
|
68
69
|
}
|
|
69
70
|
|
|
70
71
|
private update(state: Versioned{{aggregate.pascal}}, expected: number) {
|
|
@@ -14,7 +14,7 @@ function create{{aggregate.pascal}}Table(knex: Knex): Promise<void> {
|
|
|
14
14
|
{{#if personal.any}}
|
|
15
15
|
{{personal.knexTable}}
|
|
16
16
|
{{/if}}
|
|
17
|
-
// TODO(domain): add one column per field of {{aggregate.pascal}}State (and to {{aggregate.pascal}}Columns of {{aggregate.kebab}}-row.schema.ts), with the type and the constraints the storage must enforce
|
|
17
|
+
// TODO(domain): add one column per field of {{aggregate.pascal}}State (and to {{aggregate.pascal}}Columns of {{aggregate.kebab}}-row.schema.ts), with the type and the constraints the storage must enforce; then run `npm run db:generate <what-it-does>`.
|
|
18
18
|
table.integer('version').notNullable();
|
|
19
19
|
{{#if tenant.scoped}}
|
|
20
20
|
tenantColumn(table);
|
|
@@ -8,10 +8,10 @@ import { stampCreation, stampUpdate, type Clock, type ExecutionScope } from '@dd
|
|
|
8
8
|
import { Repository } from '@ddd-ts-kit/kernel/declarations';
|
|
9
9
|
{{/if}}
|
|
10
10
|
{{#if tenant.scoped}}
|
|
11
|
-
import { optimisticUpdate, ownTenantWhere, tenantWhere } from '@ddd-ts-kit/prisma';
|
|
11
|
+
import { optimisticUpdate, ownTenantWhere, rowsCreated, tenantWhere } from '@ddd-ts-kit/prisma';
|
|
12
12
|
{{/if}}
|
|
13
13
|
{{#unless tenant.scoped}}
|
|
14
|
-
import { optimisticUpdate } from '@ddd-ts-kit/prisma';
|
|
14
|
+
import { optimisticUpdate, rowsCreated } from '@ddd-ts-kit/prisma';
|
|
15
15
|
{{/unless}}
|
|
16
16
|
import type { {{aggregate.pascal}} } from '{{alias.context}}/domain/aggregates/{{aggregate.kebab}}.aggregate{{alias.ext}}';
|
|
17
17
|
{{#if style.declared}}
|
|
@@ -55,17 +55,20 @@ export class Prisma{{aggregate.pascal}}Repository implements {{aggregate.pascal}
|
|
|
55
55
|
async save(saved: {{aggregate.pascal}}): Promise<void> {
|
|
56
56
|
await optimisticUpdate(saved, async ({ expected, next }) => {
|
|
57
57
|
const state = { ...{{aggregate.pascal}}Mapper.toRow(saved), version: next };
|
|
58
|
-
const written = expected === 0 ? await this.insert(state) : await this.update(state, expected);
|
|
59
58
|
|
|
60
|
-
return
|
|
59
|
+
return expected === 0 ? this.insert(state) : (await this.update(state, expected)).count;
|
|
61
60
|
});
|
|
62
61
|
}
|
|
63
62
|
|
|
64
63
|
/** The row is written in the tenant of the work: `tenantScopeOf` names it, `tenantWhere` finds it again. */
|
|
65
|
-
private insert(state: Versioned{{aggregate.pascal}}): Promise<
|
|
64
|
+
private async insert(state: Versioned{{aggregate.pascal}}): Promise<number> {
|
|
66
65
|
const row = { ...state, ...tenantScopeOf(this.scope), ...stampCreation(this.scope, this.clock) };
|
|
66
|
+
const created = await this.database.client().{{context.camel}}{{aggregate.pascal}}.createMany({ data: [row], skipDuplicates: true });
|
|
67
67
|
|
|
68
|
-
return
|
|
68
|
+
return rowsCreated(created, {
|
|
69
|
+
id: state.id,
|
|
70
|
+
holders: () => this.database.client().{{context.camel}}{{aggregate.pascal}}.count({ where: { id: state.id, ...tenantWhere(this.scope) } }),
|
|
71
|
+
});
|
|
69
72
|
}
|
|
70
73
|
|
|
71
74
|
private update(state: Versioned{{aggregate.pascal}}, expected: number): Promise<{ count: number }> {
|
|
@@ -89,18 +92,21 @@ export class Prisma{{aggregate.pascal}}Repository implements {{aggregate.pascal}
|
|
|
89
92
|
await optimisticUpdate(saved, async ({ expected, next }) => {
|
|
90
93
|
const state = { ...{{aggregate.pascal}}Mapper.toRow(saved), version: next };
|
|
91
94
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
95
|
+
if (expected === 0) {
|
|
96
|
+
const created = await table.createMany({
|
|
97
|
+
data: [{ ...state, ...stampCreation(this.scope, this.clock) }],
|
|
98
|
+
skipDuplicates: true,
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
return rowsCreated(created, { id: saved.id, holders: () => table.count({ where: { id: saved.id } }) });
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const updated = await table.updateMany({
|
|
105
|
+
where: { id: saved.id, version: expected },
|
|
106
|
+
data: { ...state, ...stampUpdate(this.scope, this.clock) },
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
return updated.count;
|
|
104
110
|
});
|
|
105
111
|
}
|
|
106
112
|
}
|
|
@@ -11,6 +11,11 @@ describe('The lifecycle of {{aggregate.article}} {{aggregate.words}}', () => {
|
|
|
11
11
|
{{machine.cases}}
|
|
12
12
|
{{/if}}
|
|
13
13
|
|
|
14
|
+
{{#if refusals.named}}
|
|
15
|
+
// TODO(domain): once `refused` names a refusal of its own (`ddd-ts-kit generate error {{context.kebab}} <Refusal> <factory>`), expect its code here; add a case per guard.
|
|
16
|
+
{{/if}}
|
|
17
|
+
{{#unless refusals.named}}
|
|
14
18
|
// TODO(domain): once `refused` names a refusal of {{aggregate.pascal}}Error, expect its code here; add a case per guard.
|
|
19
|
+
{{/unless}}
|
|
15
20
|
it.todo('refuses each forbidden transition with the refusal of the aggregate');
|
|
16
21
|
});
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
// A migration is run by the knex CLI under plain node, which resolves no alias: it names the compiled schema by its path.
|
|
2
|
-
import { createTables } from '../dist/{{config.platformDir}}/database/schema.js';
|
|
3
|
-
|
|
4
|
-
export const up = (knex) => createTables(knex);
|
|
5
|
-
|
|
6
|
-
export const down = () => {
|
|
7
|
-
throw new Error('The initial migration is not reverted: drop the database instead.');
|
|
8
|
-
};
|