ddd-ts-kit 0.90.0 → 0.91.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 +285 -0
- package/README.fr.md +39 -7
- package/README.md +35 -6
- package/dist/alias/index.d.ts +2 -1
- package/dist/alias/index.d.ts.map +1 -1
- package/dist/alias/index.js +1 -0
- package/dist/alias/index.js.map +1 -1
- package/dist/alias/mapper-target-text.d.ts +4 -0
- package/dist/alias/mapper-target-text.d.ts.map +1 -0
- package/dist/alias/mapper-target-text.js +5 -0
- package/dist/alias/mapper-target-text.js.map +1 -0
- package/dist/alias/module-name-mapper.d.ts +5 -2
- package/dist/alias/module-name-mapper.d.ts.map +1 -1
- package/dist/alias/module-name-mapper.js +5 -2
- package/dist/alias/module-name-mapper.js.map +1 -1
- package/dist/check/alias/test-runners.js +8 -3
- package/dist/check/alias/test-runners.js.map +1 -1
- package/dist/check/baseline/apply-baseline.d.ts +14 -0
- package/dist/check/baseline/apply-baseline.d.ts.map +1 -0
- package/dist/check/baseline/apply-baseline.js +30 -0
- package/dist/check/baseline/apply-baseline.js.map +1 -0
- package/dist/check/baseline/baseline-following-moves.d.ts +9 -0
- package/dist/check/baseline/baseline-following-moves.d.ts.map +1 -0
- package/dist/check/baseline/baseline-following-moves.js +10 -0
- package/dist/check/baseline/baseline-following-moves.js.map +1 -0
- package/dist/check/baseline/baseline-move.d.ts +6 -0
- package/dist/check/baseline/baseline-move.d.ts.map +1 -0
- package/dist/check/baseline/baseline-move.js +2 -0
- package/dist/check/baseline/baseline-move.js.map +1 -0
- package/dist/check/baseline/baseline-text.d.ts +4 -0
- package/dist/check/baseline/baseline-text.d.ts.map +1 -0
- package/dist/check/baseline/baseline-text.js +12 -0
- package/dist/check/baseline/baseline-text.js.map +1 -0
- package/dist/check/baseline/baseline.d.ts +6 -0
- package/dist/check/baseline/baseline.d.ts.map +1 -0
- package/dist/check/baseline/baseline.js +2 -0
- package/dist/check/baseline/baseline.js.map +1 -0
- package/dist/check/baseline/moved-baseline-text.d.ts +4 -0
- package/dist/check/baseline/moved-baseline-text.d.ts.map +1 -0
- package/dist/check/baseline/moved-baseline-text.js +13 -0
- package/dist/check/baseline/moved-baseline-text.js.map +1 -0
- package/dist/check/baseline/parse-baseline.d.ts +4 -0
- package/dist/check/baseline/parse-baseline.d.ts.map +1 -0
- package/dist/check/baseline/parse-baseline.js +19 -0
- package/dist/check/baseline/parse-baseline.js.map +1 -0
- package/dist/check/baseline/pruned-baseline.d.ts +5 -0
- package/dist/check/baseline/pruned-baseline.d.ts.map +1 -0
- package/dist/check/baseline/pruned-baseline.js +14 -0
- package/dist/check/baseline/pruned-baseline.js.map +1 -0
- package/dist/check/baseline/read-baseline.d.ts +6 -0
- package/dist/check/baseline/read-baseline.d.ts.map +1 -0
- package/dist/check/baseline/read-baseline.js +11 -0
- package/dist/check/baseline/read-baseline.js.map +1 -0
- package/dist/check/baseline/recorded-baseline.d.ts +5 -0
- package/dist/check/baseline/recorded-baseline.d.ts.map +1 -0
- package/dist/check/baseline/recorded-baseline.js +11 -0
- package/dist/check/baseline/recorded-baseline.js.map +1 -0
- package/dist/check/baseline/renamed-files.d.ts +8 -0
- package/dist/check/baseline/renamed-files.d.ts.map +1 -0
- package/dist/check/baseline/renamed-files.js +23 -0
- package/dist/check/baseline/renamed-files.js.map +1 -0
- package/dist/check/baseline/write-baseline.d.ts +4 -0
- package/dist/check/baseline/write-baseline.d.ts.map +1 -0
- package/dist/check/baseline/write-baseline.js +9 -0
- package/dist/check/baseline/write-baseline.js.map +1 -0
- package/dist/check/canonical/stray-entry.d.ts.map +1 -1
- package/dist/check/canonical/stray-entry.js +5 -1
- package/dist/check/canonical/stray-entry.js.map +1 -1
- package/dist/check/catalogue/architecture-rules.d.ts.map +1 -1
- package/dist/check/catalogue/architecture-rules.js +4 -0
- package/dist/check/catalogue/architecture-rules.js.map +1 -1
- package/dist/check/commands/check-command.d.ts.map +1 -1
- package/dist/check/commands/check-command.js +46 -1
- package/dist/check/commands/check-command.js.map +1 -1
- package/dist/check/commands/check-file-command.d.ts +5 -0
- package/dist/check/commands/check-file-command.d.ts.map +1 -1
- package/dist/check/commands/check-file-command.js +27 -6
- package/dist/check/commands/check-file-command.js.map +1 -1
- package/dist/check/explain/nest-docs.d.ts +3 -0
- package/dist/check/explain/nest-docs.d.ts.map +1 -0
- package/dist/check/explain/nest-docs.js +31 -0
- package/dist/check/explain/nest-docs.js.map +1 -0
- package/dist/check/explain/rule-docs.d.ts.map +1 -1
- package/dist/check/explain/rule-docs.js +2 -0
- package/dist/check/explain/rule-docs.js.map +1 -1
- package/dist/check/fixtures/alias-declared-fixtures.js +1 -1
- package/dist/check/fixtures/alias-declared-fixtures.js.map +1 -1
- package/dist/check/fixtures/authz-declared-fixtures.js +1 -1
- package/dist/check/fixtures/authz-declared-fixtures.js.map +1 -1
- package/dist/check/fixtures/fixtures.d.ts.map +1 -1
- package/dist/check/fixtures/fixtures.js +4 -0
- package/dist/check/fixtures/fixtures.js.map +1 -1
- package/dist/check/fixtures/nest-controllers-fixtures.d.ts +3 -0
- package/dist/check/fixtures/nest-controllers-fixtures.d.ts.map +1 -0
- package/dist/check/fixtures/nest-controllers-fixtures.js +86 -0
- package/dist/check/fixtures/nest-controllers-fixtures.js.map +1 -0
- package/dist/check/fixtures/nest-fixtures.d.ts +3 -0
- package/dist/check/fixtures/nest-fixtures.d.ts.map +1 -0
- package/dist/check/fixtures/nest-fixtures.js +59 -0
- package/dist/check/fixtures/nest-fixtures.js.map +1 -0
- package/dist/check/nest/nest-equivalents-of.d.ts +14 -0
- package/dist/check/nest/nest-equivalents-of.d.ts.map +1 -0
- package/dist/check/nest/nest-equivalents-of.js +119 -0
- package/dist/check/nest/nest-equivalents-of.js.map +1 -0
- package/dist/check/project/load-project.d.ts +2 -0
- package/dist/check/project/load-project.d.ts.map +1 -1
- package/dist/check/project/load-project.js +7 -3
- package/dist/check/project/load-project.js.map +1 -1
- package/dist/check/rules/nest-controllers-current.d.ts +3 -0
- package/dist/check/rules/nest-controllers-current.d.ts.map +1 -0
- package/dist/check/rules/nest-controllers-current.js +43 -0
- package/dist/check/rules/nest-controllers-current.js.map +1 -0
- package/dist/check/rules/nest-no-parallel-pipeline.d.ts +3 -0
- package/dist/check/rules/nest-no-parallel-pipeline.d.ts.map +1 -0
- package/dist/check/rules/nest-no-parallel-pipeline.js +70 -0
- package/dist/check/rules/nest-no-parallel-pipeline.js.map +1 -0
- package/dist/check/support/is-generated-context-file.d.ts.map +1 -1
- package/dist/check/support/is-generated-context-file.js +4 -1
- package/dist/check/support/is-generated-context-file.js.map +1 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +1 -0
- package/dist/commands/init.js.map +1 -1
- package/dist/config/config.d.ts +6 -0
- package/dist/config/config.d.ts.map +1 -1
- package/dist/config/index.d.ts +1 -1
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +1 -1
- package/dist/config/index.js.map +1 -1
- package/dist/config/parse-config.js +1 -0
- package/dist/config/parse-config.js.map +1 -1
- package/dist/config/parse-stack.d.ts.map +1 -1
- package/dist/config/parse-stack.js +2 -1
- package/dist/config/parse-stack.js.map +1 -1
- package/dist/config/serialize-config.js +9 -2
- package/dist/config/serialize-config.js.map +1 -1
- package/dist/config/stack.d.ts +17 -4
- package/dist/config/stack.d.ts.map +1 -1
- package/dist/config/stack.js +4 -1
- package/dist/config/stack.js.map +1 -1
- package/dist/dev/refresh-declarations.d.ts.map +1 -1
- package/dist/dev/refresh-declarations.js +4 -1
- package/dist/dev/refresh-declarations.js.map +1 -1
- package/dist/docs/write-docs.d.ts.map +1 -1
- package/dist/docs/write-docs.js +2 -0
- package/dist/docs/write-docs.js.map +1 -1
- package/dist/file-moves/move-files.d.ts.map +1 -1
- package/dist/file-moves/move-files.js +10 -0
- package/dist/file-moves/move-files.js.map +1 -1
- package/dist/generate/kinds/property-kind.d.ts +3 -0
- package/dist/generate/kinds/property-kind.d.ts.map +1 -0
- package/dist/generate/kinds/property-kind.js +51 -0
- package/dist/generate/kinds/property-kind.js.map +1 -0
- package/dist/generate/kinds/route/nest-controller-vars.d.ts +11 -0
- package/dist/generate/kinds/route/nest-controller-vars.d.ts.map +1 -0
- package/dist/generate/kinds/route/nest-controller-vars.js +97 -0
- package/dist/generate/kinds/route/nest-controller-vars.js.map +1 -0
- package/dist/generate/kinds/route/route-vars.d.ts.map +1 -1
- package/dist/generate/kinds/route/route-vars.js +1 -9
- package/dist/generate/kinds/route/route-vars.js.map +1 -1
- package/dist/generate/kinds/route/success-status.d.ts +5 -0
- package/dist/generate/kinds/route/success-status.d.ts.map +1 -0
- package/dist/generate/kinds/route/success-status.js +11 -0
- package/dist/generate/kinds/route/success-status.js.map +1 -0
- package/dist/generate/kinds/route/write-nest-controller.d.ts +8 -0
- package/dist/generate/kinds/route/write-nest-controller.d.ts.map +1 -0
- package/dist/generate/kinds/route/write-nest-controller.js +52 -0
- package/dist/generate/kinds/route/write-nest-controller.js.map +1 -0
- package/dist/generate/kinds/route-kind.d.ts.map +1 -1
- package/dist/generate/kinds/route-kind.js +6 -1
- package/dist/generate/kinds/route-kind.js.map +1 -1
- package/dist/generate/kinds.d.ts.map +1 -1
- package/dist/generate/kinds.js +2 -0
- package/dist/generate/kinds.js.map +1 -1
- package/dist/generate/refresh-docs.d.ts.map +1 -1
- package/dist/generate/refresh-docs.js +2 -0
- package/dist/generate/refresh-docs.js.map +1 -1
- package/dist/generate/shared-writes.d.ts.map +1 -1
- package/dist/generate/shared-writes.js +5 -0
- package/dist/generate/shared-writes.js.map +1 -1
- package/dist/help/usage.d.ts +1 -1
- package/dist/help/usage.d.ts.map +1 -1
- package/dist/help/usage.js +4 -2
- package/dist/help/usage.js.map +1 -1
- package/dist/init/agent-permissions.js +2 -0
- package/dist/init/agent-permissions.js.map +1 -1
- package/dist/init/files/audit-files.js +1 -1
- 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 -0
- package/dist/init/files/persistence-files.js.map +1 -1
- package/dist/init/knip-vars.d.ts.map +1 -1
- package/dist/init/knip-vars.js +10 -2
- package/dist/init/knip-vars.js.map +1 -1
- package/dist/init/manifest/dependencies-against-stack.d.ts +18 -0
- package/dist/init/manifest/dependencies-against-stack.d.ts.map +1 -0
- package/dist/init/manifest/dependencies-against-stack.js +95 -0
- package/dist/init/manifest/dependencies-against-stack.js.map +1 -0
- package/dist/init/manifest/dependencies-for.d.ts.map +1 -1
- package/dist/init/manifest/dependencies-for.js +12 -2
- package/dist/init/manifest/dependencies-for.js.map +1 -1
- package/dist/init/manifest/scripts-for.js +5 -2
- package/dist/init/manifest/scripts-for.js.map +1 -1
- package/dist/init/manifest/versions.d.ts.map +1 -1
- package/dist/init/manifest/versions.js +30 -24
- package/dist/init/manifest/versions.js.map +1 -1
- package/dist/init/run-init.d.ts.map +1 -1
- package/dist/init/run-init.js +14 -1
- package/dist/init/run-init.js.map +1 -1
- package/dist/init/stack/resolve-queue.d.ts +4 -10
- package/dist/init/stack/resolve-queue.d.ts.map +1 -1
- package/dist/init/stack/resolve-queue.js +7 -11
- package/dist/init/stack/resolve-queue.js.map +1 -1
- package/dist/init/stack/resolve-stack.d.ts.map +1 -1
- package/dist/init/stack/resolve-stack.js +23 -4
- package/dist/init/stack/resolve-stack.js.map +1 -1
- package/dist/init/stack/stack-options.d.ts +2 -0
- package/dist/init/stack/stack-options.d.ts.map +1 -1
- package/dist/nest-controllers/controllers-file.d.ts +3 -0
- package/dist/nest-controllers/controllers-file.d.ts.map +1 -0
- package/dist/nest-controllers/controllers-file.js +5 -0
- package/dist/nest-controllers/controllers-file.js.map +1 -0
- package/dist/nest-controllers/nest-answer.d.ts +16 -0
- package/dist/nest-controllers/nest-answer.d.ts.map +1 -0
- package/dist/nest-controllers/nest-answer.js +2 -0
- package/dist/nest-controllers/nest-answer.js.map +1 -0
- package/dist/nest-controllers/nest-controller-entry.d.ts +16 -0
- package/dist/nest-controllers/nest-controller-entry.d.ts.map +1 -0
- package/dist/nest-controllers/nest-controller-entry.js +2 -0
- package/dist/nest-controllers/nest-controller-entry.js.map +1 -0
- package/dist/nest-controllers/read-nest-controllers.d.ts +15 -0
- package/dist/nest-controllers/read-nest-controllers.d.ts.map +1 -0
- package/dist/nest-controllers/read-nest-controllers.js +89 -0
- package/dist/nest-controllers/read-nest-controllers.js.map +1 -0
- package/dist/nest-controllers/refresh-nest-controllers.d.ts +9 -0
- package/dist/nest-controllers/refresh-nest-controllers.d.ts.map +1 -0
- package/dist/nest-controllers/refresh-nest-controllers.js +32 -0
- package/dist/nest-controllers/refresh-nest-controllers.js.map +1 -0
- package/dist/nest-controllers/render-controllers-file.d.ts +8 -0
- package/dist/nest-controllers/render-controllers-file.d.ts.map +1 -0
- package/dist/nest-controllers/render-controllers-file.js +56 -0
- package/dist/nest-controllers/render-controllers-file.js.map +1 -0
- package/dist/platform-folders/platform-folders.d.ts.map +1 -1
- package/dist/platform-folders/platform-folders.js +10 -0
- package/dist/platform-folders/platform-folders.js.map +1 -1
- package/dist/presets/apply-preset.d.ts.map +1 -1
- package/dist/presets/apply-preset.js +22 -2
- package/dist/presets/apply-preset.js.map +1 -1
- package/dist/presets/identity-preset.d.ts.map +1 -1
- package/dist/presets/identity-preset.js +4 -1
- package/dist/presets/identity-preset.js.map +1 -1
- package/dist/presets/identity-refusal.d.ts.map +1 -1
- package/dist/presets/identity-refusal.js +11 -5
- package/dist/presets/identity-refusal.js.map +1 -1
- package/dist/presets/lay-out-prisma-models.d.ts +8 -0
- package/dist/presets/lay-out-prisma-models.d.ts.map +1 -0
- package/dist/presets/lay-out-prisma-models.js +51 -0
- package/dist/presets/lay-out-prisma-models.js.map +1 -0
- package/dist/presets/preset-files.d.ts.map +1 -1
- package/dist/presets/preset-files.js +3 -0
- package/dist/presets/preset-files.js.map +1 -1
- package/dist/presets/preset.d.ts +11 -0
- package/dist/presets/preset.d.ts.map +1 -1
- package/dist/sdk/client-files.d.ts +5 -3
- package/dist/sdk/client-files.d.ts.map +1 -1
- package/dist/sdk/client-files.js +8 -3
- package/dist/sdk/client-files.js.map +1 -1
- package/dist/sdk/client-manifest.d.ts +3 -0
- package/dist/sdk/client-manifest.d.ts.map +1 -1
- package/dist/sdk/client-manifest.js +15 -2
- package/dist/sdk/client-manifest.js.map +1 -1
- package/dist/sdk/client-operation.d.ts +6 -0
- package/dist/sdk/client-operation.d.ts.map +1 -1
- package/dist/sdk/read-operation.d.ts.map +1 -1
- package/dist/sdk/read-operation.js +6 -0
- package/dist/sdk/read-operation.js.map +1 -1
- package/dist/sdk/render-orpc.d.ts +8 -0
- package/dist/sdk/render-orpc.d.ts.map +1 -0
- package/dist/sdk/render-orpc.js +42 -0
- package/dist/sdk/render-orpc.js.map +1 -0
- package/dist/sdk/render-readme.d.ts +3 -0
- package/dist/sdk/render-readme.d.ts.map +1 -1
- package/dist/sdk/render-readme.js +46 -0
- package/dist/sdk/render-readme.js.map +1 -1
- package/dist/sdk/render-trpc.d.ts +9 -0
- package/dist/sdk/render-trpc.d.ts.map +1 -0
- package/dist/sdk/render-trpc.js +36 -0
- package/dist/sdk/render-trpc.js.map +1 -0
- package/dist/sdk/rpc-packages.d.ts +7 -0
- package/dist/sdk/rpc-packages.d.ts.map +1 -0
- package/dist/sdk/rpc-packages.js +9 -0
- package/dist/sdk/rpc-packages.js.map +1 -0
- package/dist/sdk/rpc.d.ts +4 -0
- package/dist/sdk/rpc.d.ts.map +1 -0
- package/dist/sdk/rpc.js +2 -0
- package/dist/sdk/rpc.js.map +1 -0
- package/dist/sdk/write-clients.d.ts.map +1 -1
- package/dist/sdk/write-clients.js +18 -3
- package/dist/sdk/write-clients.js.map +1 -1
- package/dist/stack/alias-vars.d.ts.map +1 -1
- package/dist/stack/alias-vars.js +2 -2
- package/dist/stack/alias-vars.js.map +1 -1
- package/dist/stack/audit-vars.js +1 -1
- package/dist/stack/audit-vars.js.map +1 -1
- package/dist/stack/cache-vars.d.ts +5 -1
- package/dist/stack/cache-vars.d.ts.map +1 -1
- package/dist/stack/cache-vars.js +9 -3
- package/dist/stack/cache-vars.js.map +1 -1
- package/dist/stack/stack-vars.d.ts +1 -1
- package/dist/stack/stack-vars.d.ts.map +1 -1
- package/dist/stack/stack-vars.js +11 -6
- package/dist/stack/stack-vars.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +4 -4
- package/templates/architecture/extractable.declared.spec.ts.tpl +22 -17
- package/templates/architecture/extractable.manual.spec.ts.tpl +14 -9
- package/templates/architecture/extractable.tsyringe.spec.ts.tpl +19 -14
- package/templates/context/module.manual.ts.tpl +11 -0
- package/templates/init/jest.config.js.tpl +6 -0
- package/templates/init/platform/composition/compose-application.manual.ts.tpl +50 -0
- package/templates/init/platform/composition/platform.module.tsyringe.ts.tpl +9 -3
- package/templates/init/platform/database/persistence-over.drizzle.ts.tpl +1 -1
- package/templates/init/platform/database/persistence-over.knex.ts.tpl +1 -1
- package/templates/init/platform/database/persistence-over.prisma.ts.tpl +7 -1
- package/templates/init/platform/database/persistence-over.typeorm.ts.tpl +23 -1
- package/templates/init/platform/database/persistence.contract.spec.ts.tpl +113 -0
- package/templates/init/platform/database/persistence.orm.ts.tpl +8 -3
- package/templates/init/platform/database/schema.prisma.tpl +3 -1
- package/templates/init/platform/database/schema.typeorm.ts.tpl +17 -3
- package/templates/init/platform/database/table-statements.drizzle.ts.tpl +36 -0
- package/templates/init/platform/files/bind-files.tsyringe.ts.tpl +1 -1
- package/templates/init/platform/files/create-files.ts.tpl +1 -1
- package/templates/init/platform/http/create-app-module.ts.tpl +20 -0
- package/templates/init/platform/http/start-http-server.express.ts.tpl +48 -1
- package/templates/init/platform/http/start-http-server.fastify.ts.tpl +50 -2
- package/templates/init/platform/http/start-http-server.hono.ts.tpl +60 -1
- package/templates/init/platform/http/start-http-server.nest.ts.tpl +61 -3
- package/templates/init/platform/jobs/create-background-work.ts.tpl +2 -2
- package/templates/init/rules/infrastructure.md.tpl +3 -0
- package/templates/init/rules/presentation.md.tpl +7 -0
- package/templates/nest-controller/controller.spec.ts.tpl +57 -0
- package/templates/nest-controller/controller.ts.tpl +65 -0
- package/templates/pipeline/knip.json.tpl +4 -8
- package/templates/pipeline/package-scripts.json +1 -1
- package/templates/presets/identity/context/__context__.module.explicit.ts.tpl +254 -0
- package/templates/presets/identity/context/application/authorization/change-member-roles.policy.ts.tpl +10 -0
- package/templates/presets/identity/context/application/authorization/grant-delegations.policy.ts.tpl +10 -0
- package/templates/presets/identity/context/application/authorization/invite-members.policy.ts.tpl +10 -0
- package/templates/presets/identity/context/application/authorization/read-members.policy.ts.tpl +10 -0
- package/templates/presets/identity/context/application/authorization/remove-members.policy.ts.tpl +10 -0
- package/templates/presets/identity/context/application/authorization/revoke-delegations.policy.ts.tpl +10 -0
- package/templates/presets/identity/context/application/authorization/revoke-invitations.policy.ts.tpl +10 -0
- package/templates/presets/identity/context/application/commands/accept-invitation/accept-invitation.command.ts.tpl +6 -0
- package/templates/presets/identity/context/application/commands/accept-invitation/accept-invitation.handler.ts.tpl +12 -0
- package/templates/presets/identity/context/application/commands/change-member-role/change-member-role.command.ts.tpl +6 -0
- package/templates/presets/identity/context/application/commands/change-member-role/change-member-role.handler.ts.tpl +12 -0
- package/templates/presets/identity/context/application/commands/deactivate-account/deactivate-account.command.ts.tpl +6 -0
- package/templates/presets/identity/context/application/commands/deactivate-account/deactivate-account.handler.ts.tpl +12 -0
- package/templates/presets/identity/context/application/commands/decline-invitation/decline-invitation.command.ts.tpl +6 -0
- package/templates/presets/identity/context/application/commands/decline-invitation/decline-invitation.handler.ts.tpl +12 -0
- package/templates/presets/identity/context/application/commands/grant-delegation/grant-delegation.command.ts.tpl +6 -0
- package/templates/presets/identity/context/application/commands/grant-delegation/grant-delegation.handler.ts.tpl +12 -0
- package/templates/presets/identity/context/application/commands/invite-member/invite-member.command.ts.tpl +6 -0
- package/templates/presets/identity/context/application/commands/invite-member/invite-member.handler.ts.tpl +12 -0
- package/templates/presets/identity/context/application/commands/open-organisation/open-organisation.command.ts.tpl +6 -0
- package/templates/presets/identity/context/application/commands/open-organisation/open-organisation.handler.ts.tpl +12 -0
- package/templates/presets/identity/context/application/commands/provision-account/provision-account.command.ts.tpl +6 -0
- package/templates/presets/identity/context/application/commands/provision-account/provision-account.handler.ts.tpl +12 -0
- package/templates/presets/identity/context/application/commands/remove-member/remove-member.command.ts.tpl +6 -0
- package/templates/presets/identity/context/application/commands/remove-member/remove-member.handler.ts.tpl +12 -0
- package/templates/presets/identity/context/application/commands/revoke-delegation/revoke-delegation.command.ts.tpl +6 -0
- package/templates/presets/identity/context/application/commands/revoke-delegation/revoke-delegation.handler.ts.tpl +12 -0
- package/templates/presets/identity/context/application/commands/revoke-invitation/revoke-invitation.command.ts.tpl +6 -0
- package/templates/presets/identity/context/application/commands/revoke-invitation/revoke-invitation.handler.ts.tpl +12 -0
- package/templates/presets/identity/context/application/integration/handlers/account-deactivated.integration-handler.ts.tpl +4 -0
- package/templates/presets/identity/context/application/integration/handlers/member-joined.integration-handler.ts.tpl +4 -0
- package/templates/presets/identity/context/application/integration/handlers/member-removed.integration-handler.ts.tpl +4 -0
- package/templates/presets/identity/context/application/integration/handlers/organisation-opened.integration-handler.ts.tpl +4 -0
- package/templates/presets/identity/context/application/integration/publishers/account-deactivated.publisher.ts.tpl +10 -1
- package/templates/presets/identity/context/application/integration/publishers/delegation-granted.publisher.ts.tpl +10 -1
- package/templates/presets/identity/context/application/integration/publishers/delegation-revoked.publisher.ts.tpl +10 -1
- package/templates/presets/identity/context/application/integration/publishers/member-joined.publisher.ts.tpl +10 -1
- package/templates/presets/identity/context/application/integration/publishers/member-removed.publisher.ts.tpl +10 -1
- package/templates/presets/identity/context/application/integration/publishers/member-role-changed.publisher.ts.tpl +10 -1
- package/templates/presets/identity/context/application/integration/publishers/organisation-opened.publisher.ts.tpl +10 -1
- package/templates/presets/identity/context/application/queries/search-members/search-members.handler.ts.tpl +12 -0
- package/templates/presets/identity/context/application/queries/search-members/search-members.query.ts.tpl +6 -0
- package/templates/presets/identity/context/infrastructure/external/crypto-invitation-tokens.adapter.ts.tpl +9 -0
- package/templates/presets/identity/context/infrastructure/external/environment-identity-provider-connection.adapter.ts.tpl +9 -0
- package/templates/presets/identity/context/infrastructure/external/keycloak-identity-provider-admin.adapter.ts.tpl +9 -0
- package/templates/presets/identity/context/infrastructure/persistence/account.mapper.prisma.ts.tpl +36 -0
- package/templates/presets/identity/context/infrastructure/persistence/account.personal-fields.privacy.prisma.ts.tpl +19 -0
- package/templates/presets/identity/context/infrastructure/persistence/delegation.mapper.prisma.ts.tpl +48 -0
- package/templates/presets/identity/context/infrastructure/persistence/drizzle-account.repository.drizzle.ts.tpl +9 -0
- package/templates/presets/identity/context/infrastructure/persistence/drizzle-delegation.repository.drizzle.ts.tpl +9 -0
- package/templates/presets/identity/context/infrastructure/persistence/drizzle-invitation.repository.drizzle.ts.tpl +9 -0
- package/templates/presets/identity/context/infrastructure/persistence/drizzle-member.repository.drizzle.ts.tpl +9 -0
- package/templates/presets/identity/context/infrastructure/persistence/drizzle-organisation.repository.drizzle.ts.tpl +9 -0
- package/templates/presets/identity/context/infrastructure/persistence/drizzle-search-members-reader.repository.drizzle.ts.tpl +9 -0
- package/templates/presets/identity/context/infrastructure/persistence/invitation.mapper.prisma.ts.tpl +43 -0
- package/templates/presets/identity/context/infrastructure/persistence/invitation.personal-fields.privacy.prisma.ts.tpl +20 -0
- package/templates/presets/identity/context/infrastructure/persistence/knex-account.repository.knex.ts.tpl +9 -0
- package/templates/presets/identity/context/infrastructure/persistence/knex-delegation.repository.knex.ts.tpl +9 -0
- package/templates/presets/identity/context/infrastructure/persistence/knex-invitation.repository.knex.ts.tpl +9 -0
- package/templates/presets/identity/context/infrastructure/persistence/knex-member.repository.knex.ts.tpl +9 -0
- package/templates/presets/identity/context/infrastructure/persistence/knex-organisation.repository.knex.ts.tpl +9 -0
- package/templates/presets/identity/context/infrastructure/persistence/knex-search-members-reader.repository.knex.ts.tpl +9 -0
- package/templates/presets/identity/context/infrastructure/persistence/member.mapper.prisma.ts.tpl +34 -0
- package/templates/presets/identity/context/infrastructure/persistence/organisation.mapper.prisma.ts.tpl +26 -0
- package/templates/presets/identity/context/infrastructure/persistence/prisma-account.repository.prisma.ts.tpl +63 -0
- package/templates/presets/identity/context/infrastructure/persistence/prisma-delegation.repository.prisma.ts.tpl +81 -0
- package/templates/presets/identity/context/infrastructure/persistence/prisma-invitation.repository.prisma.ts.tpl +69 -0
- package/templates/presets/identity/context/infrastructure/persistence/prisma-member.repository.prisma.ts.tpl +80 -0
- package/templates/presets/identity/context/infrastructure/persistence/prisma-organisation.repository.prisma.ts.tpl +63 -0
- package/templates/presets/identity/context/infrastructure/persistence/prisma-search-members-reader.repository.prisma.ts.tpl +82 -0
- package/templates/presets/identity/context/test/integration/account.repository.contract.spec.ts.tpl +3 -3
- package/templates/presets/identity/context/test/integration/delegation.repository.contract.spec.ts.tpl +5 -5
- package/templates/presets/identity/context/test/integration/invitation.repository.contract.spec.ts.tpl +5 -5
- package/templates/presets/identity/context/test/integration/member.repository.contract.spec.ts.tpl +5 -5
- package/templates/presets/identity/context/test/integration/organisation.repository.contract.spec.ts.tpl +3 -3
- package/templates/presets/identity/context/test/integration/search-members-reader.spec.ts.tpl +8 -8
- package/templates/presets/identity/context/test/unit/__context__.module.spec.explicit.ts.tpl +95 -0
- package/templates/presets/identity/context/test/worlds/__context__.world.explicit.ts.tpl +332 -0
- package/templates/presets/identity/explicit/access-policies.wiring.tpl +16 -0
- package/templates/presets/identity/prisma/models.prisma.tpl +128 -0
- package/templates/property/value-object.properties.spec.ts.tpl +38 -0
- package/templates/sdk/orpc.ts.tpl +46 -0
- package/templates/sdk/trpc.ts.tpl +86 -0
- /package/templates/presets/identity/context/test/worlds/{__context__.world.ts.tpl → __context__.world.declared.ts.tpl} +0 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { AuditStamp } from '@ddd-ts-kit/kernel';
|
|
2
|
+
import { Organisation } from '{{alias.context}}/domain/aggregates/organisation.aggregate{{alias.ext}}';
|
|
3
|
+
import { OrganisationName } from '{{alias.context}}/domain/value-objects/organisation-name.vo{{alias.ext}}';
|
|
4
|
+
import type { {{context.pascal}}Organisation as OrganisationRow } from '{{alias.generated}}/prisma/client{{alias.ext}}';
|
|
5
|
+
|
|
6
|
+
export type OrganisationColumns = Omit<OrganisationRow, 'version' | keyof AuditStamp>;
|
|
7
|
+
|
|
8
|
+
export const OrganisationMapper = {
|
|
9
|
+
toDomain(row: OrganisationRow): Organisation {
|
|
10
|
+
const loaded = Organisation.rehydrate(row.id, {
|
|
11
|
+
name: OrganisationName.create(row.name),
|
|
12
|
+
openedBy: row.openedBy,
|
|
13
|
+
openedAt: row.openedAt,
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
loaded.version = row.version;
|
|
17
|
+
|
|
18
|
+
return loaded;
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
toRow(saved: Organisation): OrganisationColumns {
|
|
22
|
+
const state = saved.toState();
|
|
23
|
+
|
|
24
|
+
return { id: saved.id, name: state.name.value, openedBy: state.openedBy, openedAt: state.openedAt };
|
|
25
|
+
},
|
|
26
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { optimisticUpdate } from '@ddd-ts-kit/prisma';
|
|
2
|
+
import { stampCreation, stampUpdate, type Clock, type ExecutionScope } from '@ddd-ts-kit/kernel';
|
|
3
|
+
{{#if style.declared}}
|
|
4
|
+
import { Repository } from '@ddd-ts-kit/kernel/declarations';
|
|
5
|
+
{{/if}}
|
|
6
|
+
import type { Account } from '{{alias.context}}/domain/aggregates/account.aggregate{{alias.ext}}';
|
|
7
|
+
{{#if style.declared}}
|
|
8
|
+
import { AccountRepository } from '{{alias.context}}/domain/repositories/account.repository{{alias.ext}}';
|
|
9
|
+
{{/if}}
|
|
10
|
+
{{#unless style.declared}}
|
|
11
|
+
import type { AccountRepository } from '{{alias.context}}/domain/repositories/account.repository{{alias.ext}}';
|
|
12
|
+
{{/unless}}
|
|
13
|
+
import type { Database } from '{{alias.platform}}/database/database{{alias.ext}}';
|
|
14
|
+
import { AccountMapper, type AccountColumns } from '{{alias.context}}/infrastructure/persistence/account.mapper{{alias.ext}}';
|
|
15
|
+
|
|
16
|
+
type VersionedAccount = AccountColumns & { readonly version: number };
|
|
17
|
+
|
|
18
|
+
{{#if style.declared}}
|
|
19
|
+
@Repository(AccountRepository)
|
|
20
|
+
{{/if}}
|
|
21
|
+
export class PrismaAccountRepository implements AccountRepository {
|
|
22
|
+
constructor(
|
|
23
|
+
private readonly database: Database,
|
|
24
|
+
private readonly scope: ExecutionScope,
|
|
25
|
+
private readonly clock: Clock,
|
|
26
|
+
) {}
|
|
27
|
+
|
|
28
|
+
async findById(id: string): Promise<Account | undefined> {
|
|
29
|
+
const row = await accountsOf(this.database).findUnique({ where: { id } });
|
|
30
|
+
|
|
31
|
+
return row === null ? undefined : AccountMapper.toDomain(row);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async save(saved: Account): Promise<void> {
|
|
35
|
+
await optimisticUpdate(saved, async ({ expected, next }) => {
|
|
36
|
+
const state = { ...AccountMapper.toRow(saved), version: next };
|
|
37
|
+
const written = expected === 0 ? await this.insert(state) : await this.update(state, expected);
|
|
38
|
+
|
|
39
|
+
return written.count;
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
private insert(state: VersionedAccount): Promise<{ count: number }> {
|
|
44
|
+
const row = { ...state, ...stampCreation(this.scope, this.clock) };
|
|
45
|
+
|
|
46
|
+
return accountsOf(this.database).createMany({ data: [row], skipDuplicates: true });
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
private update(state: VersionedAccount, expected: number): Promise<{ count: number }> {
|
|
50
|
+
return accountsOf(this.database).updateMany({
|
|
51
|
+
where: { id: state.id, version: expected },
|
|
52
|
+
data: { ...state, ...stampUpdate(this.scope, this.clock) },
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** The accounts on the client of the unit of work, which every statement of this file goes through. */
|
|
58
|
+
function accountsOf(database: Database): ReturnType<Database['client']>['{{context.camel}}Account'] {
|
|
59
|
+
{{#if tenancy.any}}
|
|
60
|
+
// ddd-ts-kit-disable-next-line tenancy/scoped-statement -- {{preset.adr}}: the {{context.kebab}} context is the control plane of the tenants, and its rows belong to none of them.
|
|
61
|
+
{{/if}}
|
|
62
|
+
return database.client().{{context.camel}}Account;
|
|
63
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { optimisticUpdate } from '@ddd-ts-kit/prisma';
|
|
2
|
+
import { stampCreation, stampUpdate, type Clock, type ExecutionScope } from '@ddd-ts-kit/kernel';
|
|
3
|
+
{{#if style.declared}}
|
|
4
|
+
import { Repository } from '@ddd-ts-kit/kernel/declarations';
|
|
5
|
+
{{/if}}
|
|
6
|
+
import type { Delegation } from '{{alias.context}}/domain/aggregates/delegation.aggregate{{alias.ext}}';
|
|
7
|
+
{{#if style.declared}}
|
|
8
|
+
import { DelegationRepository } from '{{alias.context}}/domain/repositories/delegation.repository{{alias.ext}}';
|
|
9
|
+
{{/if}}
|
|
10
|
+
{{#unless style.declared}}
|
|
11
|
+
import type { DelegationRepository } from '{{alias.context}}/domain/repositories/delegation.repository{{alias.ext}}';
|
|
12
|
+
{{/unless}}
|
|
13
|
+
import type { Database } from '{{alias.platform}}/database/database{{alias.ext}}';
|
|
14
|
+
import { DelegationMapper, type DelegationColumns } from '{{alias.context}}/infrastructure/persistence/delegation.mapper{{alias.ext}}';
|
|
15
|
+
|
|
16
|
+
type VersionedDelegation = DelegationColumns & { readonly version: number };
|
|
17
|
+
|
|
18
|
+
{{#if style.declared}}
|
|
19
|
+
@Repository(DelegationRepository)
|
|
20
|
+
{{/if}}
|
|
21
|
+
export class PrismaDelegationRepository implements DelegationRepository {
|
|
22
|
+
constructor(
|
|
23
|
+
private readonly database: Database,
|
|
24
|
+
private readonly scope: ExecutionScope,
|
|
25
|
+
private readonly clock: Clock,
|
|
26
|
+
) {}
|
|
27
|
+
|
|
28
|
+
async findById(id: string): Promise<Delegation | undefined> {
|
|
29
|
+
const row = await delegationsOf(this.database).findUnique({ where: { id } });
|
|
30
|
+
|
|
31
|
+
return row === null ? undefined : DelegationMapper.toDomain(row);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async findUnendedTo(organisationId: string, delegateId: string): Promise<readonly Delegation[]> {
|
|
35
|
+
const rows = await delegationsOf(this.database).findMany({
|
|
36
|
+
where: { organisationId, delegateId, endedAt: null },
|
|
37
|
+
orderBy: { id: 'asc' },
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
return rows.map((row) => DelegationMapper.toDomain(row));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
async findUnendedInvolving(organisationId: string, accountId: string): Promise<readonly Delegation[]> {
|
|
44
|
+
const rows = await delegationsOf(this.database).findMany({
|
|
45
|
+
where: { organisationId, endedAt: null, OR: [{ delegatorId: accountId }, { delegateId: accountId }] },
|
|
46
|
+
orderBy: { id: 'asc' },
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
return rows.map((row) => DelegationMapper.toDomain(row));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
async save(saved: Delegation): Promise<void> {
|
|
53
|
+
await optimisticUpdate(saved, async ({ expected, next }) => {
|
|
54
|
+
const state = { ...DelegationMapper.toRow(saved), version: next };
|
|
55
|
+
const written = expected === 0 ? await this.insert(state) : await this.update(state, expected);
|
|
56
|
+
|
|
57
|
+
return written.count;
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
private insert(state: VersionedDelegation): Promise<{ count: number }> {
|
|
62
|
+
const row = { ...state, ...stampCreation(this.scope, this.clock) };
|
|
63
|
+
|
|
64
|
+
return delegationsOf(this.database).createMany({ data: [row], skipDuplicates: true });
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
private update(state: VersionedDelegation, expected: number): Promise<{ count: number }> {
|
|
68
|
+
return delegationsOf(this.database).updateMany({
|
|
69
|
+
where: { id: state.id, version: expected },
|
|
70
|
+
data: { ...state, ...stampUpdate(this.scope, this.clock) },
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** The delegations on the client of the unit of work, which every statement of this file goes through. */
|
|
76
|
+
function delegationsOf(database: Database): ReturnType<Database['client']>['{{context.camel}}Delegation'] {
|
|
77
|
+
{{#if tenancy.any}}
|
|
78
|
+
// ddd-ts-kit-disable-next-line tenancy/scoped-statement -- {{preset.adr}}: the {{context.kebab}} context is the control plane of the tenants, and its rows belong to none of them.
|
|
79
|
+
{{/if}}
|
|
80
|
+
return database.client().{{context.camel}}Delegation;
|
|
81
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { optimisticUpdate } from '@ddd-ts-kit/prisma';
|
|
2
|
+
import { stampCreation, stampUpdate, type Clock, type ExecutionScope } from '@ddd-ts-kit/kernel';
|
|
3
|
+
{{#if style.declared}}
|
|
4
|
+
import { Repository } from '@ddd-ts-kit/kernel/declarations';
|
|
5
|
+
{{/if}}
|
|
6
|
+
import type { Invitation } from '{{alias.context}}/domain/aggregates/invitation.aggregate{{alias.ext}}';
|
|
7
|
+
{{#if style.declared}}
|
|
8
|
+
import { InvitationRepository } from '{{alias.context}}/domain/repositories/invitation.repository{{alias.ext}}';
|
|
9
|
+
{{/if}}
|
|
10
|
+
{{#unless style.declared}}
|
|
11
|
+
import type { InvitationRepository } from '{{alias.context}}/domain/repositories/invitation.repository{{alias.ext}}';
|
|
12
|
+
{{/unless}}
|
|
13
|
+
import type { Database } from '{{alias.platform}}/database/database{{alias.ext}}';
|
|
14
|
+
import { InvitationMapper, type InvitationColumns } from '{{alias.context}}/infrastructure/persistence/invitation.mapper{{alias.ext}}';
|
|
15
|
+
|
|
16
|
+
type VersionedInvitation = InvitationColumns & { readonly version: number };
|
|
17
|
+
|
|
18
|
+
{{#if style.declared}}
|
|
19
|
+
@Repository(InvitationRepository)
|
|
20
|
+
{{/if}}
|
|
21
|
+
export class PrismaInvitationRepository implements InvitationRepository {
|
|
22
|
+
constructor(
|
|
23
|
+
private readonly database: Database,
|
|
24
|
+
private readonly scope: ExecutionScope,
|
|
25
|
+
private readonly clock: Clock,
|
|
26
|
+
) {}
|
|
27
|
+
|
|
28
|
+
async findById(id: string): Promise<Invitation | undefined> {
|
|
29
|
+
const row = await invitationsOf(this.database).findUnique({ where: { id } });
|
|
30
|
+
|
|
31
|
+
return row === null ? undefined : InvitationMapper.toDomain(row);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async findByTokenHash(tokenHash: string): Promise<Invitation | undefined> {
|
|
35
|
+
const row = await invitationsOf(this.database).findUnique({ where: { tokenHash } });
|
|
36
|
+
|
|
37
|
+
return row === null ? undefined : InvitationMapper.toDomain(row);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async save(saved: Invitation): Promise<void> {
|
|
41
|
+
await optimisticUpdate(saved, async ({ expected, next }) => {
|
|
42
|
+
const state = { ...InvitationMapper.toRow(saved), version: next };
|
|
43
|
+
const written = expected === 0 ? await this.insert(state) : await this.update(state, expected);
|
|
44
|
+
|
|
45
|
+
return written.count;
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
private insert(state: VersionedInvitation): Promise<{ count: number }> {
|
|
50
|
+
const row = { ...state, ...stampCreation(this.scope, this.clock) };
|
|
51
|
+
|
|
52
|
+
return invitationsOf(this.database).createMany({ data: [row], skipDuplicates: true });
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
private update(state: VersionedInvitation, expected: number): Promise<{ count: number }> {
|
|
56
|
+
return invitationsOf(this.database).updateMany({
|
|
57
|
+
where: { id: state.id, version: expected },
|
|
58
|
+
data: { ...state, ...stampUpdate(this.scope, this.clock) },
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** The invitations on the client of the unit of work, which every statement of this file goes through. */
|
|
64
|
+
function invitationsOf(database: Database): ReturnType<Database['client']>['{{context.camel}}Invitation'] {
|
|
65
|
+
{{#if tenancy.any}}
|
|
66
|
+
// ddd-ts-kit-disable-next-line tenancy/scoped-statement -- {{preset.adr}}: the {{context.kebab}} context is the control plane of the tenants, and its rows belong to none of them.
|
|
67
|
+
{{/if}}
|
|
68
|
+
return database.client().{{context.camel}}Invitation;
|
|
69
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { optimisticUpdate } from '@ddd-ts-kit/prisma';
|
|
2
|
+
import { stampCreation, stampUpdate, type Clock, type ExecutionScope } from '@ddd-ts-kit/kernel';
|
|
3
|
+
{{#if style.declared}}
|
|
4
|
+
import { Repository } from '@ddd-ts-kit/kernel/declarations';
|
|
5
|
+
{{/if}}
|
|
6
|
+
import type { Member } from '{{alias.context}}/domain/aggregates/member.aggregate{{alias.ext}}';
|
|
7
|
+
{{#if style.declared}}
|
|
8
|
+
import { MemberRepository } from '{{alias.context}}/domain/repositories/member.repository{{alias.ext}}';
|
|
9
|
+
{{/if}}
|
|
10
|
+
{{#unless style.declared}}
|
|
11
|
+
import type { MemberRepository } from '{{alias.context}}/domain/repositories/member.repository{{alias.ext}}';
|
|
12
|
+
{{/unless}}
|
|
13
|
+
import { MemberRole } from '{{alias.context}}/domain/vocabularies/member-role.vocabulary{{alias.ext}}';
|
|
14
|
+
import type { Database } from '{{alias.platform}}/database/database{{alias.ext}}';
|
|
15
|
+
import { MemberMapper, type MemberColumns } from '{{alias.context}}/infrastructure/persistence/member.mapper{{alias.ext}}';
|
|
16
|
+
|
|
17
|
+
type VersionedMember = MemberColumns & { readonly version: number };
|
|
18
|
+
|
|
19
|
+
{{#if style.declared}}
|
|
20
|
+
@Repository(MemberRepository)
|
|
21
|
+
{{/if}}
|
|
22
|
+
export class PrismaMemberRepository implements MemberRepository {
|
|
23
|
+
constructor(
|
|
24
|
+
private readonly database: Database,
|
|
25
|
+
private readonly scope: ExecutionScope,
|
|
26
|
+
private readonly clock: Clock,
|
|
27
|
+
) {}
|
|
28
|
+
|
|
29
|
+
async findById(id: string): Promise<Member | undefined> {
|
|
30
|
+
const row = await membersOf(this.database).findUnique({ where: { id } });
|
|
31
|
+
|
|
32
|
+
return row === null ? undefined : MemberMapper.toDomain(row);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async findOf(organisationId: string, accountId: string): Promise<Member | undefined> {
|
|
36
|
+
const row = await membersOf(this.database).findFirst({ where: { organisationId, accountId, removedAt: null } });
|
|
37
|
+
|
|
38
|
+
return row === null ? undefined : MemberMapper.toDomain(row);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async searchCurrentOf(accountId: string): Promise<readonly Member[]> {
|
|
42
|
+
const rows = await membersOf(this.database).findMany({ where: { accountId, removedAt: null }, orderBy: { id: 'asc' } });
|
|
43
|
+
|
|
44
|
+
return rows.map((row) => MemberMapper.toDomain(row));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
countOwners(organisationId: string): Promise<number> {
|
|
48
|
+
return membersOf(this.database).count({ where: { organisationId, role: MemberRole.Owner, removedAt: null } });
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async save(saved: Member): Promise<void> {
|
|
52
|
+
await optimisticUpdate(saved, async ({ expected, next }) => {
|
|
53
|
+
const state = { ...MemberMapper.toRow(saved), version: next };
|
|
54
|
+
const written = expected === 0 ? await this.insert(state) : await this.update(state, expected);
|
|
55
|
+
|
|
56
|
+
return written.count;
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
private insert(state: VersionedMember): Promise<{ count: number }> {
|
|
61
|
+
const row = { ...state, ...stampCreation(this.scope, this.clock) };
|
|
62
|
+
|
|
63
|
+
return membersOf(this.database).createMany({ data: [row], skipDuplicates: true });
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
private update(state: VersionedMember, expected: number): Promise<{ count: number }> {
|
|
67
|
+
return membersOf(this.database).updateMany({
|
|
68
|
+
where: { id: state.id, version: expected },
|
|
69
|
+
data: { ...state, ...stampUpdate(this.scope, this.clock) },
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** The members on the client of the unit of work, which every statement of this file goes through. */
|
|
75
|
+
function membersOf(database: Database): ReturnType<Database['client']>['{{context.camel}}Member'] {
|
|
76
|
+
{{#if tenancy.any}}
|
|
77
|
+
// ddd-ts-kit-disable-next-line tenancy/scoped-statement -- {{preset.adr}}: the {{context.kebab}} context is the control plane of the tenants, and its rows belong to none of them.
|
|
78
|
+
{{/if}}
|
|
79
|
+
return database.client().{{context.camel}}Member;
|
|
80
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { optimisticUpdate } from '@ddd-ts-kit/prisma';
|
|
2
|
+
import { stampCreation, stampUpdate, type Clock, type ExecutionScope } from '@ddd-ts-kit/kernel';
|
|
3
|
+
{{#if style.declared}}
|
|
4
|
+
import { Repository } from '@ddd-ts-kit/kernel/declarations';
|
|
5
|
+
{{/if}}
|
|
6
|
+
import type { Organisation } from '{{alias.context}}/domain/aggregates/organisation.aggregate{{alias.ext}}';
|
|
7
|
+
{{#if style.declared}}
|
|
8
|
+
import { OrganisationRepository } from '{{alias.context}}/domain/repositories/organisation.repository{{alias.ext}}';
|
|
9
|
+
{{/if}}
|
|
10
|
+
{{#unless style.declared}}
|
|
11
|
+
import type { OrganisationRepository } from '{{alias.context}}/domain/repositories/organisation.repository{{alias.ext}}';
|
|
12
|
+
{{/unless}}
|
|
13
|
+
import type { Database } from '{{alias.platform}}/database/database{{alias.ext}}';
|
|
14
|
+
import { OrganisationMapper, type OrganisationColumns } from '{{alias.context}}/infrastructure/persistence/organisation.mapper{{alias.ext}}';
|
|
15
|
+
|
|
16
|
+
type VersionedOrganisation = OrganisationColumns & { readonly version: number };
|
|
17
|
+
|
|
18
|
+
{{#if style.declared}}
|
|
19
|
+
@Repository(OrganisationRepository)
|
|
20
|
+
{{/if}}
|
|
21
|
+
export class PrismaOrganisationRepository implements OrganisationRepository {
|
|
22
|
+
constructor(
|
|
23
|
+
private readonly database: Database,
|
|
24
|
+
private readonly scope: ExecutionScope,
|
|
25
|
+
private readonly clock: Clock,
|
|
26
|
+
) {}
|
|
27
|
+
|
|
28
|
+
async findById(id: string): Promise<Organisation | undefined> {
|
|
29
|
+
const row = await organisationsOf(this.database).findUnique({ where: { id } });
|
|
30
|
+
|
|
31
|
+
return row === null ? undefined : OrganisationMapper.toDomain(row);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async save(saved: Organisation): Promise<void> {
|
|
35
|
+
await optimisticUpdate(saved, async ({ expected, next }) => {
|
|
36
|
+
const state = { ...OrganisationMapper.toRow(saved), version: next };
|
|
37
|
+
const written = expected === 0 ? await this.insert(state) : await this.update(state, expected);
|
|
38
|
+
|
|
39
|
+
return written.count;
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
private insert(state: VersionedOrganisation): Promise<{ count: number }> {
|
|
44
|
+
const row = { ...state, ...stampCreation(this.scope, this.clock) };
|
|
45
|
+
|
|
46
|
+
return organisationsOf(this.database).createMany({ data: [row], skipDuplicates: true });
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
private update(state: VersionedOrganisation, expected: number): Promise<{ count: number }> {
|
|
50
|
+
return organisationsOf(this.database).updateMany({
|
|
51
|
+
where: { id: state.id, version: expected },
|
|
52
|
+
data: { ...state, ...stampUpdate(this.scope, this.clock) },
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** The organisations on the client of the unit of work, which every statement of this file goes through. */
|
|
58
|
+
function organisationsOf(database: Database): ReturnType<Database['client']>['{{context.camel}}Organisation'] {
|
|
59
|
+
{{#if tenancy.any}}
|
|
60
|
+
// ddd-ts-kit-disable-next-line tenancy/scoped-statement -- {{preset.adr}}: the {{context.kebab}} context is the control plane of the tenants, and its rows belong to none of them.
|
|
61
|
+
{{/if}}
|
|
62
|
+
return database.client().{{context.camel}}Organisation;
|
|
63
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { InvalidPageRequestError, pageOf, type PageRequest } from '@ddd-ts-kit/kernel';
|
|
2
|
+
{{#if style.declared}}
|
|
3
|
+
import { Repository } from '@ddd-ts-kit/kernel/declarations';
|
|
4
|
+
{{/if}}
|
|
5
|
+
{{#if style.declared}}
|
|
6
|
+
import { SearchMembersReader } from '{{alias.context}}/application/ports/search-members-reader.port{{alias.ext}}';
|
|
7
|
+
{{/if}}
|
|
8
|
+
{{#unless style.declared}}
|
|
9
|
+
import type { SearchMembersReader } from '{{alias.context}}/application/ports/search-members-reader.port{{alias.ext}}';
|
|
10
|
+
{{/unless}}
|
|
11
|
+
import type {
|
|
12
|
+
SearchMembersItem,
|
|
13
|
+
SearchMembersResult,
|
|
14
|
+
SearchMembersSort,
|
|
15
|
+
} from '{{alias.context}}/application/queries/search-members/search-members.result{{alias.ext}}';
|
|
16
|
+
import type { Database } from '{{alias.platform}}/database/database{{alias.ext}}';
|
|
17
|
+
import type { {{context.pascal}}Account as AccountRow, {{context.pascal}}Member as MemberRow } from '{{alias.generated}}/prisma/client{{alias.ext}}';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The current members of an organisation with the profile of their account: the page applied by
|
|
21
|
+
* the database, then the accounts of that page read in one statement, since the models of the
|
|
22
|
+
* context hold no relation.
|
|
23
|
+
*/
|
|
24
|
+
{{#if style.declared}}
|
|
25
|
+
@Repository(SearchMembersReader)
|
|
26
|
+
{{/if}}
|
|
27
|
+
export class PrismaSearchMembersReader implements SearchMembersReader {
|
|
28
|
+
constructor(private readonly database: Database) {}
|
|
29
|
+
|
|
30
|
+
async search(organisationId: string, page: PageRequest<SearchMembersSort>): Promise<SearchMembersResult> {
|
|
31
|
+
if (page.kind !== 'offset') {
|
|
32
|
+
throw new InvalidPageRequestError('The members of an organisation are read by offset');
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const direction = page.sort[0]?.direction === 'desc' ? 'desc' : 'asc';
|
|
36
|
+
const client = clientOf(this.database);
|
|
37
|
+
const current = { organisationId, removedAt: null };
|
|
38
|
+
|
|
39
|
+
const members = await client.{{context.camel}}Member.findMany({
|
|
40
|
+
where: current,
|
|
41
|
+
orderBy: [{ joinedAt: direction }, { id: direction }],
|
|
42
|
+
take: page.limit,
|
|
43
|
+
skip: page.offset,
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
const accounts = await client.{{context.camel}}Account.findMany({
|
|
47
|
+
where: { id: { in: members.map((member) => member.accountId) } },
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
const total = await client.{{context.camel}}Member.count({ where: current });
|
|
51
|
+
|
|
52
|
+
return pageOf(withProfiles(members, accounts), { total });
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** Each member of the page with the profile of its account, in the order of the page. */
|
|
57
|
+
function withProfiles(members: readonly MemberRow[], accounts: readonly AccountRow[]): SearchMembersItem[] {
|
|
58
|
+
return members.flatMap((member) => {
|
|
59
|
+
const account = accounts.find((candidate) => candidate.id === member.accountId);
|
|
60
|
+
|
|
61
|
+
return account === undefined
|
|
62
|
+
? []
|
|
63
|
+
: [
|
|
64
|
+
{
|
|
65
|
+
memberId: member.id,
|
|
66
|
+
accountId: member.accountId,
|
|
67
|
+
displayName: account.displayName,
|
|
68
|
+
email: account.email,
|
|
69
|
+
role: member.role,
|
|
70
|
+
joinedAt: member.joinedAt,
|
|
71
|
+
},
|
|
72
|
+
];
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** The client of the unit of work, which every statement of this file goes through. */
|
|
77
|
+
function clientOf(database: Database): ReturnType<Database['client']> {
|
|
78
|
+
{{#if tenancy.any}}
|
|
79
|
+
// ddd-ts-kit-disable-next-line tenancy/scoped-statement -- {{preset.adr}}: the {{context.kebab}} context is the control plane of the tenants, and its rows belong to none of them.
|
|
80
|
+
{{/if}}
|
|
81
|
+
return database.client();
|
|
82
|
+
}
|
package/templates/presets/identity/context/test/integration/account.repository.contract.spec.ts.tpl
CHANGED
|
@@ -2,7 +2,7 @@ import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it } from
|
|
|
2
2
|
import { FixedClock, FixedExecutionScope, executionContext, type Actor } from '@ddd-ts-kit/kernel';
|
|
3
3
|
import { repositoryContract } from '@ddd-ts-kit/testing/contracts';
|
|
4
4
|
import type { Account } from '{{alias.context}}/domain/aggregates/account.aggregate{{alias.ext}}';
|
|
5
|
-
import { {{#if orm.knex}}Knex{{/if}}{{#if orm.drizzle}}Drizzle{{/if}}AccountRepository } from '{{alias.context}}/infrastructure/persistence/{{#if orm.knex}}knex{{/if}}{{#if orm.drizzle}}drizzle{{/if}}-account.repository{{alias.ext}}';
|
|
5
|
+
import { {{#if orm.knex}}Knex{{/if}}{{#if orm.drizzle}}Drizzle{{/if}}{{#if orm.prisma}}Prisma{{/if}}AccountRepository } from '{{alias.context}}/infrastructure/persistence/{{#if orm.knex}}knex{{/if}}{{#if orm.drizzle}}drizzle{{/if}}{{#if orm.prisma}}prisma{{/if}}-account.repository{{alias.ext}}';
|
|
6
6
|
import { openTestDatabase, type TestDatabase } from '{{alias.platform}}/database/open-test-database{{alias.ext}}';
|
|
7
7
|
import { anAccount } from '{{alias.context}}/test/builders/account.builder{{alias.ext}}';
|
|
8
8
|
import { FakeAccountRepository } from '{{alias.context}}/test/fakes/account.repository.fake{{alias.ext}}';
|
|
@@ -39,10 +39,10 @@ repositoryContract<Account>(runner, {
|
|
|
39
39
|
|
|
40
40
|
repositoryContract<Account>(runner, {
|
|
41
41
|
...expectations,
|
|
42
|
-
name: '{{#if orm.knex}}Knex{{/if}}{{#if orm.drizzle}}Drizzle{{/if}}AccountRepository',
|
|
42
|
+
name: '{{#if orm.knex}}Knex{{/if}}{{#if orm.drizzle}}Drizzle{{/if}}{{#if orm.prisma}}Prisma{{/if}}AccountRepository',
|
|
43
43
|
createRepository: async () => {
|
|
44
44
|
await database.reset();
|
|
45
45
|
|
|
46
|
-
return new {{#if orm.knex}}Knex{{/if}}{{#if orm.drizzle}}Drizzle{{/if}}AccountRepository(database.persistence.database, scope, clock);
|
|
46
|
+
return new {{#if orm.knex}}Knex{{/if}}{{#if orm.drizzle}}Drizzle{{/if}}{{#if orm.prisma}}Prisma{{/if}}AccountRepository(database.persistence.database, scope, clock);
|
|
47
47
|
},
|
|
48
48
|
});
|
|
@@ -3,7 +3,7 @@ import { FixedClock, FixedExecutionScope, executionContext, type Actor } from '@
|
|
|
3
3
|
import { repositoryContract } from '@ddd-ts-kit/testing/contracts';
|
|
4
4
|
import type { Delegation } from '{{alias.context}}/domain/aggregates/delegation.aggregate{{alias.ext}}';
|
|
5
5
|
import type { DelegationRepository } from '{{alias.context}}/domain/repositories/delegation.repository{{alias.ext}}';
|
|
6
|
-
import { {{#if orm.knex}}Knex{{/if}}{{#if orm.drizzle}}Drizzle{{/if}}DelegationRepository } from '{{alias.context}}/infrastructure/persistence/{{#if orm.knex}}knex{{/if}}{{#if orm.drizzle}}drizzle{{/if}}-delegation.repository{{alias.ext}}';
|
|
6
|
+
import { {{#if orm.knex}}Knex{{/if}}{{#if orm.drizzle}}Drizzle{{/if}}{{#if orm.prisma}}Prisma{{/if}}DelegationRepository } from '{{alias.context}}/infrastructure/persistence/{{#if orm.knex}}knex{{/if}}{{#if orm.drizzle}}drizzle{{/if}}{{#if orm.prisma}}prisma{{/if}}-delegation.repository{{alias.ext}}';
|
|
7
7
|
import { openTestDatabase, type TestDatabase } from '{{alias.platform}}/database/open-test-database{{alias.ext}}';
|
|
8
8
|
import { aDelegation } from '{{alias.context}}/test/builders/delegation.builder{{alias.ext}}';
|
|
9
9
|
import { FakeDelegationRepository } from '{{alias.context}}/test/fakes/delegation.repository.fake{{alias.ext}}';
|
|
@@ -40,11 +40,11 @@ repositoryContract<Delegation>(runner, {
|
|
|
40
40
|
|
|
41
41
|
repositoryContract<Delegation>(runner, {
|
|
42
42
|
...expectations,
|
|
43
|
-
name: '{{#if orm.knex}}Knex{{/if}}{{#if orm.drizzle}}Drizzle{{/if}}DelegationRepository',
|
|
43
|
+
name: '{{#if orm.knex}}Knex{{/if}}{{#if orm.drizzle}}Drizzle{{/if}}{{#if orm.prisma}}Prisma{{/if}}DelegationRepository',
|
|
44
44
|
createRepository: async () => {
|
|
45
45
|
await database.reset();
|
|
46
46
|
|
|
47
|
-
return new {{#if orm.knex}}Knex{{/if}}{{#if orm.drizzle}}Drizzle{{/if}}DelegationRepository(database.persistence.database, scope, clock);
|
|
47
|
+
return new {{#if orm.knex}}Knex{{/if}}{{#if orm.drizzle}}Drizzle{{/if}}{{#if orm.prisma}}Prisma{{/if}}DelegationRepository(database.persistence.database, scope, clock);
|
|
48
48
|
},
|
|
49
49
|
});
|
|
50
50
|
|
|
@@ -73,11 +73,11 @@ function adapters(): [string, () => Promise<DelegationRepository>][] {
|
|
|
73
73
|
return [
|
|
74
74
|
['FakeDelegationRepository', async () => new FakeDelegationRepository()],
|
|
75
75
|
[
|
|
76
|
-
'{{#if orm.knex}}Knex{{/if}}{{#if orm.drizzle}}Drizzle{{/if}}DelegationRepository',
|
|
76
|
+
'{{#if orm.knex}}Knex{{/if}}{{#if orm.drizzle}}Drizzle{{/if}}{{#if orm.prisma}}Prisma{{/if}}DelegationRepository',
|
|
77
77
|
async () => {
|
|
78
78
|
await database.reset();
|
|
79
79
|
|
|
80
|
-
return new {{#if orm.knex}}Knex{{/if}}{{#if orm.drizzle}}Drizzle{{/if}}DelegationRepository(database.persistence.database, scope, clock);
|
|
80
|
+
return new {{#if orm.knex}}Knex{{/if}}{{#if orm.drizzle}}Drizzle{{/if}}{{#if orm.prisma}}Prisma{{/if}}DelegationRepository(database.persistence.database, scope, clock);
|
|
81
81
|
},
|
|
82
82
|
],
|
|
83
83
|
];
|
|
@@ -3,7 +3,7 @@ import { FixedClock, FixedExecutionScope, executionContext, type Actor } from '@
|
|
|
3
3
|
import { repositoryContract } from '@ddd-ts-kit/testing/contracts';
|
|
4
4
|
import type { Invitation } from '{{alias.context}}/domain/aggregates/invitation.aggregate{{alias.ext}}';
|
|
5
5
|
import type { InvitationRepository } from '{{alias.context}}/domain/repositories/invitation.repository{{alias.ext}}';
|
|
6
|
-
import { {{#if orm.knex}}Knex{{/if}}{{#if orm.drizzle}}Drizzle{{/if}}InvitationRepository } from '{{alias.context}}/infrastructure/persistence/{{#if orm.knex}}knex{{/if}}{{#if orm.drizzle}}drizzle{{/if}}-invitation.repository{{alias.ext}}';
|
|
6
|
+
import { {{#if orm.knex}}Knex{{/if}}{{#if orm.drizzle}}Drizzle{{/if}}{{#if orm.prisma}}Prisma{{/if}}InvitationRepository } from '{{alias.context}}/infrastructure/persistence/{{#if orm.knex}}knex{{/if}}{{#if orm.drizzle}}drizzle{{/if}}{{#if orm.prisma}}prisma{{/if}}-invitation.repository{{alias.ext}}';
|
|
7
7
|
import { openTestDatabase, type TestDatabase } from '{{alias.platform}}/database/open-test-database{{alias.ext}}';
|
|
8
8
|
import { anInvitation } from '{{alias.context}}/test/builders/invitation.builder{{alias.ext}}';
|
|
9
9
|
import { FakeInvitationRepository } from '{{alias.context}}/test/fakes/invitation.repository.fake{{alias.ext}}';
|
|
@@ -40,11 +40,11 @@ repositoryContract<Invitation>(runner, {
|
|
|
40
40
|
|
|
41
41
|
repositoryContract<Invitation>(runner, {
|
|
42
42
|
...expectations,
|
|
43
|
-
name: '{{#if orm.knex}}Knex{{/if}}{{#if orm.drizzle}}Drizzle{{/if}}InvitationRepository',
|
|
43
|
+
name: '{{#if orm.knex}}Knex{{/if}}{{#if orm.drizzle}}Drizzle{{/if}}{{#if orm.prisma}}Prisma{{/if}}InvitationRepository',
|
|
44
44
|
createRepository: async () => {
|
|
45
45
|
await database.reset();
|
|
46
46
|
|
|
47
|
-
return new {{#if orm.knex}}Knex{{/if}}{{#if orm.drizzle}}Drizzle{{/if}}InvitationRepository(database.persistence.database, scope, clock);
|
|
47
|
+
return new {{#if orm.knex}}Knex{{/if}}{{#if orm.drizzle}}Drizzle{{/if}}{{#if orm.prisma}}Prisma{{/if}}InvitationRepository(database.persistence.database, scope, clock);
|
|
48
48
|
},
|
|
49
49
|
});
|
|
50
50
|
|
|
@@ -65,11 +65,11 @@ function adapters(): [string, () => Promise<InvitationRepository>][] {
|
|
|
65
65
|
return [
|
|
66
66
|
['FakeInvitationRepository', async () => new FakeInvitationRepository()],
|
|
67
67
|
[
|
|
68
|
-
'{{#if orm.knex}}Knex{{/if}}{{#if orm.drizzle}}Drizzle{{/if}}InvitationRepository',
|
|
68
|
+
'{{#if orm.knex}}Knex{{/if}}{{#if orm.drizzle}}Drizzle{{/if}}{{#if orm.prisma}}Prisma{{/if}}InvitationRepository',
|
|
69
69
|
async () => {
|
|
70
70
|
await database.reset();
|
|
71
71
|
|
|
72
|
-
return new {{#if orm.knex}}Knex{{/if}}{{#if orm.drizzle}}Drizzle{{/if}}InvitationRepository(database.persistence.database, scope, clock);
|
|
72
|
+
return new {{#if orm.knex}}Knex{{/if}}{{#if orm.drizzle}}Drizzle{{/if}}{{#if orm.prisma}}Prisma{{/if}}InvitationRepository(database.persistence.database, scope, clock);
|
|
73
73
|
},
|
|
74
74
|
],
|
|
75
75
|
];
|
package/templates/presets/identity/context/test/integration/member.repository.contract.spec.ts.tpl
CHANGED
|
@@ -4,7 +4,7 @@ import { repositoryContract } from '@ddd-ts-kit/testing/contracts';
|
|
|
4
4
|
import type { Member } from '{{alias.context}}/domain/aggregates/member.aggregate{{alias.ext}}';
|
|
5
5
|
import type { MemberRepository } from '{{alias.context}}/domain/repositories/member.repository{{alias.ext}}';
|
|
6
6
|
import { MemberRole } from '{{alias.context}}/domain/vocabularies/member-role.vocabulary{{alias.ext}}';
|
|
7
|
-
import { {{#if orm.knex}}Knex{{/if}}{{#if orm.drizzle}}Drizzle{{/if}}MemberRepository } from '{{alias.context}}/infrastructure/persistence/{{#if orm.knex}}knex{{/if}}{{#if orm.drizzle}}drizzle{{/if}}-member.repository{{alias.ext}}';
|
|
7
|
+
import { {{#if orm.knex}}Knex{{/if}}{{#if orm.drizzle}}Drizzle{{/if}}{{#if orm.prisma}}Prisma{{/if}}MemberRepository } from '{{alias.context}}/infrastructure/persistence/{{#if orm.knex}}knex{{/if}}{{#if orm.drizzle}}drizzle{{/if}}{{#if orm.prisma}}prisma{{/if}}-member.repository{{alias.ext}}';
|
|
8
8
|
import { openTestDatabase, type TestDatabase } from '{{alias.platform}}/database/open-test-database{{alias.ext}}';
|
|
9
9
|
import { aMember } from '{{alias.context}}/test/builders/member.builder{{alias.ext}}';
|
|
10
10
|
import { FakeMemberRepository } from '{{alias.context}}/test/fakes/member.repository.fake{{alias.ext}}';
|
|
@@ -41,11 +41,11 @@ repositoryContract<Member>(runner, {
|
|
|
41
41
|
|
|
42
42
|
repositoryContract<Member>(runner, {
|
|
43
43
|
...expectations,
|
|
44
|
-
name: '{{#if orm.knex}}Knex{{/if}}{{#if orm.drizzle}}Drizzle{{/if}}MemberRepository',
|
|
44
|
+
name: '{{#if orm.knex}}Knex{{/if}}{{#if orm.drizzle}}Drizzle{{/if}}{{#if orm.prisma}}Prisma{{/if}}MemberRepository',
|
|
45
45
|
createRepository: async () => {
|
|
46
46
|
await database.reset();
|
|
47
47
|
|
|
48
|
-
return new {{#if orm.knex}}Knex{{/if}}{{#if orm.drizzle}}Drizzle{{/if}}MemberRepository(database.persistence.database, scope, clock);
|
|
48
|
+
return new {{#if orm.knex}}Knex{{/if}}{{#if orm.drizzle}}Drizzle{{/if}}{{#if orm.prisma}}Prisma{{/if}}MemberRepository(database.persistence.database, scope, clock);
|
|
49
49
|
},
|
|
50
50
|
});
|
|
51
51
|
|
|
@@ -81,11 +81,11 @@ function adapters(): [string, () => Promise<MemberRepository>][] {
|
|
|
81
81
|
return [
|
|
82
82
|
['FakeMemberRepository', async () => new FakeMemberRepository()],
|
|
83
83
|
[
|
|
84
|
-
'{{#if orm.knex}}Knex{{/if}}{{#if orm.drizzle}}Drizzle{{/if}}MemberRepository',
|
|
84
|
+
'{{#if orm.knex}}Knex{{/if}}{{#if orm.drizzle}}Drizzle{{/if}}{{#if orm.prisma}}Prisma{{/if}}MemberRepository',
|
|
85
85
|
async () => {
|
|
86
86
|
await database.reset();
|
|
87
87
|
|
|
88
|
-
return new {{#if orm.knex}}Knex{{/if}}{{#if orm.drizzle}}Drizzle{{/if}}MemberRepository(database.persistence.database, scope, clock);
|
|
88
|
+
return new {{#if orm.knex}}Knex{{/if}}{{#if orm.drizzle}}Drizzle{{/if}}{{#if orm.prisma}}Prisma{{/if}}MemberRepository(database.persistence.database, scope, clock);
|
|
89
89
|
},
|
|
90
90
|
],
|
|
91
91
|
];
|
|
@@ -2,7 +2,7 @@ import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it } from
|
|
|
2
2
|
import { FixedClock, FixedExecutionScope, executionContext, type Actor } from '@ddd-ts-kit/kernel';
|
|
3
3
|
import { repositoryContract } from '@ddd-ts-kit/testing/contracts';
|
|
4
4
|
import type { Organisation } from '{{alias.context}}/domain/aggregates/organisation.aggregate{{alias.ext}}';
|
|
5
|
-
import { {{#if orm.knex}}Knex{{/if}}{{#if orm.drizzle}}Drizzle{{/if}}OrganisationRepository } from '{{alias.context}}/infrastructure/persistence/{{#if orm.knex}}knex{{/if}}{{#if orm.drizzle}}drizzle{{/if}}-organisation.repository{{alias.ext}}';
|
|
5
|
+
import { {{#if orm.knex}}Knex{{/if}}{{#if orm.drizzle}}Drizzle{{/if}}{{#if orm.prisma}}Prisma{{/if}}OrganisationRepository } from '{{alias.context}}/infrastructure/persistence/{{#if orm.knex}}knex{{/if}}{{#if orm.drizzle}}drizzle{{/if}}{{#if orm.prisma}}prisma{{/if}}-organisation.repository{{alias.ext}}';
|
|
6
6
|
import { openTestDatabase, type TestDatabase } from '{{alias.platform}}/database/open-test-database{{alias.ext}}';
|
|
7
7
|
import { anOrganisation } from '{{alias.context}}/test/builders/organisation.builder{{alias.ext}}';
|
|
8
8
|
import { FakeOrganisationRepository } from '{{alias.context}}/test/fakes/organisation.repository.fake{{alias.ext}}';
|
|
@@ -37,10 +37,10 @@ repositoryContract<Organisation>(runner, {
|
|
|
37
37
|
|
|
38
38
|
repositoryContract<Organisation>(runner, {
|
|
39
39
|
...expectations,
|
|
40
|
-
name: '{{#if orm.knex}}Knex{{/if}}{{#if orm.drizzle}}Drizzle{{/if}}OrganisationRepository',
|
|
40
|
+
name: '{{#if orm.knex}}Knex{{/if}}{{#if orm.drizzle}}Drizzle{{/if}}{{#if orm.prisma}}Prisma{{/if}}OrganisationRepository',
|
|
41
41
|
createRepository: async () => {
|
|
42
42
|
await database.reset();
|
|
43
43
|
|
|
44
|
-
return new {{#if orm.knex}}Knex{{/if}}{{#if orm.drizzle}}Drizzle{{/if}}OrganisationRepository(database.persistence.database, scope, clock);
|
|
44
|
+
return new {{#if orm.knex}}Knex{{/if}}{{#if orm.drizzle}}Drizzle{{/if}}{{#if orm.prisma}}Prisma{{/if}}OrganisationRepository(database.persistence.database, scope, clock);
|
|
45
45
|
},
|
|
46
46
|
});
|