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
package/templates/presets/identity/context/test/integration/search-members-reader.spec.ts.tpl
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { afterAll, beforeAll, beforeEach, describe, expect, it } from '{{tests.module}}';
|
|
2
2
|
import { FixedClock, FixedExecutionScope, executionContext, offsetPage, type Actor } from '@ddd-ts-kit/kernel';
|
|
3
3
|
import { MemberRole } from '{{alias.context}}/domain/vocabularies/member-role.vocabulary{{alias.ext}}';
|
|
4
|
-
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}}MemberRepository } from '{{alias.context}}/infrastructure/persistence/{{#if orm.knex}}knex{{/if}}{{#if orm.drizzle}}drizzle{{/if}}-member.repository{{alias.ext}}';
|
|
6
|
-
import { {{#if orm.knex}}Knex{{/if}}{{#if orm.drizzle}}Drizzle{{/if}}SearchMembersReader } from '{{alias.context}}/infrastructure/persistence/{{#if orm.knex}}knex{{/if}}{{#if orm.drizzle}}drizzle{{/if}}-search-members-reader.repository{{alias.ext}}';
|
|
4
|
+
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}}';
|
|
5
|
+
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}}';
|
|
6
|
+
import { {{#if orm.knex}}Knex{{/if}}{{#if orm.drizzle}}Drizzle{{/if}}{{#if orm.prisma}}Prisma{{/if}}SearchMembersReader } from '{{alias.context}}/infrastructure/persistence/{{#if orm.knex}}knex{{/if}}{{#if orm.drizzle}}drizzle{{/if}}{{#if orm.prisma}}prisma{{/if}}-search-members-reader.repository{{alias.ext}}';
|
|
7
7
|
import { openTestDatabase, type TestDatabase } from '{{alias.platform}}/database/open-test-database{{alias.ext}}';
|
|
8
8
|
import { anAccount } from '{{alias.context}}/test/builders/account.builder{{alias.ext}}';
|
|
9
9
|
import { aMember } from '{{alias.context}}/test/builders/member.builder{{alias.ext}}';
|
|
@@ -21,8 +21,8 @@ beforeAll(async () => {
|
|
|
21
21
|
beforeEach(async () => {
|
|
22
22
|
await database.reset();
|
|
23
23
|
|
|
24
|
-
const accounts = new {{#if orm.knex}}Knex{{/if}}{{#if orm.drizzle}}Drizzle{{/if}}AccountRepository(database.persistence.database, scope, clock);
|
|
25
|
-
const members = new {{#if orm.knex}}Knex{{/if}}{{#if orm.drizzle}}Drizzle{{/if}}MemberRepository(database.persistence.database, scope, clock);
|
|
24
|
+
const accounts = new {{#if orm.knex}}Knex{{/if}}{{#if orm.drizzle}}Drizzle{{/if}}{{#if orm.prisma}}Prisma{{/if}}AccountRepository(database.persistence.database, scope, clock);
|
|
25
|
+
const members = new {{#if orm.knex}}Knex{{/if}}{{#if orm.drizzle}}Drizzle{{/if}}{{#if orm.prisma}}Prisma{{/if}}MemberRepository(database.persistence.database, scope, clock);
|
|
26
26
|
|
|
27
27
|
for (const [id, name] of [
|
|
28
28
|
['subject-ada', 'Ada'],
|
|
@@ -42,9 +42,9 @@ afterAll(async () => {
|
|
|
42
42
|
await database.close();
|
|
43
43
|
});
|
|
44
44
|
|
|
45
|
-
describe('{{#if orm.knex}}Knex{{/if}}{{#if orm.drizzle}}Drizzle{{/if}}SearchMembersReader', () => {
|
|
45
|
+
describe('{{#if orm.knex}}Knex{{/if}}{{#if orm.drizzle}}Drizzle{{/if}}{{#if orm.prisma}}Prisma{{/if}}SearchMembersReader', () => {
|
|
46
46
|
it('reads the current members of one organisation, with the profile of their account, earliest first', async () => {
|
|
47
|
-
const reader = new {{#if orm.knex}}Knex{{/if}}{{#if orm.drizzle}}Drizzle{{/if}}SearchMembersReader(database.persistence.database);
|
|
47
|
+
const reader = new {{#if orm.knex}}Knex{{/if}}{{#if orm.drizzle}}Drizzle{{/if}}{{#if orm.prisma}}Prisma{{/if}}SearchMembersReader(database.persistence.database);
|
|
48
48
|
|
|
49
49
|
const page = await reader.search('acme', offsetPage({ limit: 10 }));
|
|
50
50
|
|
|
@@ -72,7 +72,7 @@ describe('{{#if orm.knex}}Knex{{/if}}{{#if orm.drizzle}}Drizzle{{/if}}SearchMemb
|
|
|
72
72
|
});
|
|
73
73
|
|
|
74
74
|
it('answers a page of them, latest first when asked, with the total', async () => {
|
|
75
|
-
const reader = new {{#if orm.knex}}Knex{{/if}}{{#if orm.drizzle}}Drizzle{{/if}}SearchMembersReader(database.persistence.database);
|
|
75
|
+
const reader = new {{#if orm.knex}}Knex{{/if}}{{#if orm.drizzle}}Drizzle{{/if}}{{#if orm.prisma}}Prisma{{/if}}SearchMembersReader(database.persistence.database);
|
|
76
76
|
|
|
77
77
|
const page = await reader.search('acme', offsetPage({ limit: 1, offset: 1, sort: [{ field: 'joinedAt', direction: 'desc' }] }));
|
|
78
78
|
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { describe, expect, it } from '{{tests.module}}';
|
|
2
|
+
import { DuplicateHandlerError, type Command, type MessageType, type Query } from '@ddd-ts-kit/kernel';
|
|
3
|
+
import { {{context.camel}}Module } from '{{alias.context}}/{{context.kebab}}.module{{alias.ext}}';
|
|
4
|
+
import { AcceptInvitationCommand } from '{{alias.context}}/application/commands/accept-invitation/accept-invitation.command{{alias.ext}}';
|
|
5
|
+
import { ChangeMemberRoleCommand } from '{{alias.context}}/application/commands/change-member-role/change-member-role.command{{alias.ext}}';
|
|
6
|
+
import { DeactivateAccountCommand } from '{{alias.context}}/application/commands/deactivate-account/deactivate-account.command{{alias.ext}}';
|
|
7
|
+
import { DeclineInvitationCommand } from '{{alias.context}}/application/commands/decline-invitation/decline-invitation.command{{alias.ext}}';
|
|
8
|
+
import { GrantDelegationCommand } from '{{alias.context}}/application/commands/grant-delegation/grant-delegation.command{{alias.ext}}';
|
|
9
|
+
import { InviteMemberCommand } from '{{alias.context}}/application/commands/invite-member/invite-member.command{{alias.ext}}';
|
|
10
|
+
import { OpenOrganisationCommand } from '{{alias.context}}/application/commands/open-organisation/open-organisation.command{{alias.ext}}';
|
|
11
|
+
import { ProvisionAccountCommand } from '{{alias.context}}/application/commands/provision-account/provision-account.command{{alias.ext}}';
|
|
12
|
+
import { RemoveMemberCommand } from '{{alias.context}}/application/commands/remove-member/remove-member.command{{alias.ext}}';
|
|
13
|
+
import { RevokeDelegationCommand } from '{{alias.context}}/application/commands/revoke-delegation/revoke-delegation.command{{alias.ext}}';
|
|
14
|
+
import { RevokeInvitationCommand } from '{{alias.context}}/application/commands/revoke-invitation/revoke-invitation.command{{alias.ext}}';
|
|
15
|
+
import { SearchMembersQuery } from '{{alias.context}}/application/queries/search-members/search-members.query{{alias.ext}}';
|
|
16
|
+
import { createPlatform } from '{{alias.platform}}/composition/create-platform{{alias.ext}}';
|
|
17
|
+
import { inertPersistence } from '{{alias.platform}}/database/inert-persistence{{alias.ext}}';
|
|
18
|
+
import { inProcessEvents } from '{{alias.platform}}/events/in-process-events{{alias.ext}}';
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The module of the context as the application composes it, on the platform: the specs of the use
|
|
22
|
+
* cases run on the world of the context, this one holds the module to them, so that a use case
|
|
23
|
+
* the module forgets, or a route it does not mount, fails here.
|
|
24
|
+
*/
|
|
25
|
+
const platform = createPlatform(inertPersistence(), { events: inProcessEvents() });
|
|
26
|
+
const wiring = {{context.camel}}Module(platform);
|
|
27
|
+
|
|
28
|
+
const USE_CASES = [
|
|
29
|
+
command(AcceptInvitationCommand),
|
|
30
|
+
command(ChangeMemberRoleCommand),
|
|
31
|
+
command(DeactivateAccountCommand),
|
|
32
|
+
command(DeclineInvitationCommand),
|
|
33
|
+
command(GrantDelegationCommand),
|
|
34
|
+
command(InviteMemberCommand),
|
|
35
|
+
command(OpenOrganisationCommand),
|
|
36
|
+
command(ProvisionAccountCommand),
|
|
37
|
+
command(RemoveMemberCommand),
|
|
38
|
+
command(RevokeDelegationCommand),
|
|
39
|
+
command(RevokeInvitationCommand),
|
|
40
|
+
query(SearchMembersQuery),
|
|
41
|
+
];
|
|
42
|
+
|
|
43
|
+
describe('The module of {{context.kebab}}', () => {
|
|
44
|
+
it.each(USE_CASES)('gives %s its handler', (_name, handled) => {
|
|
45
|
+
expect(handled).toBe(true);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it('requires a permission of every use case of the context, and of nothing else', () => {
|
|
49
|
+
const required = wiring.useCases.map(({ type }) => type.name).toSorted();
|
|
50
|
+
|
|
51
|
+
expect(required).toEqual(USE_CASES.map(([name]) => name).toSorted());
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('mounts one route per use case of the context', () => {
|
|
55
|
+
const mounted = wiring.routes.map(({ method, path }) => `${method} ${path}`).toSorted();
|
|
56
|
+
|
|
57
|
+
expect(mounted).toEqual([
|
|
58
|
+
'DELETE /organisations/:organisationId/delegations/:delegationId',
|
|
59
|
+
'DELETE /organisations/:organisationId/invitations/:invitationId',
|
|
60
|
+
'DELETE /organisations/:organisationId/members/:accountId',
|
|
61
|
+
'GET /organisations/:organisationId/members',
|
|
62
|
+
'POST /accounts/me/deactivation',
|
|
63
|
+
'POST /invitations/acceptance',
|
|
64
|
+
'POST /invitations/declination',
|
|
65
|
+
'POST /organisations',
|
|
66
|
+
'POST /organisations/:organisationId/delegations',
|
|
67
|
+
'POST /organisations/:organisationId/invitations',
|
|
68
|
+
'PUT /accounts/me',
|
|
69
|
+
'PUT /organisations/:organisationId/members/:accountId/role',
|
|
70
|
+
]);
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
function command<C extends Command<unknown>>(type: MessageType<C>) {
|
|
75
|
+
return [type.name, alreadyHandled(() => platform.commands.register(type, { execute: never }))] as const;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function query<Q extends Query<unknown>>(type: MessageType<Q>) {
|
|
79
|
+
return [type.name, alreadyHandled(() => platform.queries.register(type, { execute: never }))] as const;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** Whether the bus already held a handler of the message: a second one is then refused as a duplicate. */
|
|
83
|
+
function alreadyHandled(register: () => unknown): boolean {
|
|
84
|
+
try {
|
|
85
|
+
register();
|
|
86
|
+
|
|
87
|
+
return false;
|
|
88
|
+
} catch (error) {
|
|
89
|
+
return error instanceof DuplicateHandlerError;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function never(): Promise<never> {
|
|
94
|
+
return Promise.reject(new Error('A second handler is never run'));
|
|
95
|
+
}
|
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AuthorizationMap,
|
|
3
|
+
PolicyAccess,
|
|
4
|
+
RoleBasedAuthorizer,
|
|
5
|
+
authorizationMiddleware,
|
|
6
|
+
requires,
|
|
7
|
+
type Access,
|
|
8
|
+
} from '@ddd-ts-kit/auth';
|
|
9
|
+
import { anActor } from '@ddd-ts-kit/auth/testing';
|
|
10
|
+
import { on, subscribeAll } from '@ddd-ts-kit/events';
|
|
11
|
+
import { InMemoryProcessedEventStore, type Actor } from '@ddd-ts-kit/kernel';
|
|
12
|
+
import { createTestBuses, type TestBuses } from '@ddd-ts-kit/testing';
|
|
13
|
+
import { {{context.camel}}Permissions } from '{{alias.context}}/{{context.kebab}}.permissions{{alias.ext}}';
|
|
14
|
+
import { AcceptInvitationCommand } from '{{alias.context}}/application/commands/accept-invitation/accept-invitation.command{{alias.ext}}';
|
|
15
|
+
import { AcceptInvitationHandler } from '{{alias.context}}/application/commands/accept-invitation/accept-invitation.handler{{alias.ext}}';
|
|
16
|
+
import { ChangeMemberRoleCommand } from '{{alias.context}}/application/commands/change-member-role/change-member-role.command{{alias.ext}}';
|
|
17
|
+
import { ChangeMemberRoleHandler } from '{{alias.context}}/application/commands/change-member-role/change-member-role.handler{{alias.ext}}';
|
|
18
|
+
import { DeactivateAccountCommand } from '{{alias.context}}/application/commands/deactivate-account/deactivate-account.command{{alias.ext}}';
|
|
19
|
+
import { DeactivateAccountHandler } from '{{alias.context}}/application/commands/deactivate-account/deactivate-account.handler{{alias.ext}}';
|
|
20
|
+
import { DeclineInvitationCommand } from '{{alias.context}}/application/commands/decline-invitation/decline-invitation.command{{alias.ext}}';
|
|
21
|
+
import { DeclineInvitationHandler } from '{{alias.context}}/application/commands/decline-invitation/decline-invitation.handler{{alias.ext}}';
|
|
22
|
+
import { GrantDelegationCommand } from '{{alias.context}}/application/commands/grant-delegation/grant-delegation.command{{alias.ext}}';
|
|
23
|
+
import { GrantDelegationHandler } from '{{alias.context}}/application/commands/grant-delegation/grant-delegation.handler{{alias.ext}}';
|
|
24
|
+
import { InviteMemberCommand } from '{{alias.context}}/application/commands/invite-member/invite-member.command{{alias.ext}}';
|
|
25
|
+
import { InviteMemberHandler } from '{{alias.context}}/application/commands/invite-member/invite-member.handler{{alias.ext}}';
|
|
26
|
+
import { OpenOrganisationCommand } from '{{alias.context}}/application/commands/open-organisation/open-organisation.command{{alias.ext}}';
|
|
27
|
+
import { OpenOrganisationHandler } from '{{alias.context}}/application/commands/open-organisation/open-organisation.handler{{alias.ext}}';
|
|
28
|
+
import { ProvisionAccountCommand } from '{{alias.context}}/application/commands/provision-account/provision-account.command{{alias.ext}}';
|
|
29
|
+
import { ProvisionAccountHandler } from '{{alias.context}}/application/commands/provision-account/provision-account.handler{{alias.ext}}';
|
|
30
|
+
import { RemoveMemberCommand } from '{{alias.context}}/application/commands/remove-member/remove-member.command{{alias.ext}}';
|
|
31
|
+
import { RemoveMemberHandler } from '{{alias.context}}/application/commands/remove-member/remove-member.handler{{alias.ext}}';
|
|
32
|
+
import { RevokeDelegationCommand } from '{{alias.context}}/application/commands/revoke-delegation/revoke-delegation.command{{alias.ext}}';
|
|
33
|
+
import { RevokeDelegationHandler } from '{{alias.context}}/application/commands/revoke-delegation/revoke-delegation.handler{{alias.ext}}';
|
|
34
|
+
import { RevokeInvitationCommand } from '{{alias.context}}/application/commands/revoke-invitation/revoke-invitation.command{{alias.ext}}';
|
|
35
|
+
import { RevokeInvitationHandler } from '{{alias.context}}/application/commands/revoke-invitation/revoke-invitation.handler{{alias.ext}}';
|
|
36
|
+
import { SearchMembersQuery } from '{{alias.context}}/application/queries/search-members/search-members.query{{alias.ext}}';
|
|
37
|
+
import { SearchMembersHandler } from '{{alias.context}}/application/queries/search-members/search-members.handler{{alias.ext}}';
|
|
38
|
+
import { AccountDeactivatedIntegrationHandler } from '{{alias.context}}/application/integration/handlers/account-deactivated.integration-handler{{alias.ext}}';
|
|
39
|
+
import { accountDeactivatedV1 } from '{{alias.context}}/published-language/account-deactivated.v1.integration-event{{alias.ext}}';
|
|
40
|
+
import { MemberJoinedIntegrationHandler } from '{{alias.context}}/application/integration/handlers/member-joined.integration-handler{{alias.ext}}';
|
|
41
|
+
import { memberJoinedV1 } from '{{alias.context}}/published-language/member-joined.v1.integration-event{{alias.ext}}';
|
|
42
|
+
import { MemberRemovedIntegrationHandler } from '{{alias.context}}/application/integration/handlers/member-removed.integration-handler{{alias.ext}}';
|
|
43
|
+
import { memberRemovedV1 } from '{{alias.context}}/published-language/member-removed.v1.integration-event{{alias.ext}}';
|
|
44
|
+
import { OrganisationOpenedIntegrationHandler } from '{{alias.context}}/application/integration/handlers/organisation-opened.integration-handler{{alias.ext}}';
|
|
45
|
+
import { organisationOpenedV1 } from '{{alias.context}}/published-language/organisation-opened.v1.integration-event{{alias.ext}}';
|
|
46
|
+
import { AccountDeactivatedPublisher } from '{{alias.context}}/application/integration/publishers/account-deactivated.publisher{{alias.ext}}';
|
|
47
|
+
import { AccountDeactivated } from '{{alias.context}}/domain/events/account-deactivated.event{{alias.ext}}';
|
|
48
|
+
import { OrganisationOpenedPublisher } from '{{alias.context}}/application/integration/publishers/organisation-opened.publisher{{alias.ext}}';
|
|
49
|
+
import { OrganisationOpened } from '{{alias.context}}/domain/events/organisation-opened.event{{alias.ext}}';
|
|
50
|
+
import { MemberJoinedPublisher } from '{{alias.context}}/application/integration/publishers/member-joined.publisher{{alias.ext}}';
|
|
51
|
+
import { MemberJoined } from '{{alias.context}}/domain/events/member-joined.event{{alias.ext}}';
|
|
52
|
+
import { MemberRoleChangedPublisher } from '{{alias.context}}/application/integration/publishers/member-role-changed.publisher{{alias.ext}}';
|
|
53
|
+
import { MemberRoleChanged } from '{{alias.context}}/domain/events/member-role-changed.event{{alias.ext}}';
|
|
54
|
+
import { MemberRemovedPublisher } from '{{alias.context}}/application/integration/publishers/member-removed.publisher{{alias.ext}}';
|
|
55
|
+
import { MemberRemoved } from '{{alias.context}}/domain/events/member-removed.event{{alias.ext}}';
|
|
56
|
+
import { DelegationGrantedPublisher } from '{{alias.context}}/application/integration/publishers/delegation-granted.publisher{{alias.ext}}';
|
|
57
|
+
import { DelegationGranted } from '{{alias.context}}/domain/events/delegation-granted.event{{alias.ext}}';
|
|
58
|
+
import { DelegationRevokedPublisher } from '{{alias.context}}/application/integration/publishers/delegation-revoked.publisher{{alias.ext}}';
|
|
59
|
+
import { DelegationRevoked } from '{{alias.context}}/domain/events/delegation-revoked.event{{alias.ext}}';
|
|
60
|
+
import { ChangeMemberRolesPolicy } from '{{alias.context}}/application/authorization/change-member-roles.policy{{alias.ext}}';
|
|
61
|
+
import { GrantDelegationsPolicy } from '{{alias.context}}/application/authorization/grant-delegations.policy{{alias.ext}}';
|
|
62
|
+
import { InviteMembersPolicy } from '{{alias.context}}/application/authorization/invite-members.policy{{alias.ext}}';
|
|
63
|
+
import { ReadMembersPolicy } from '{{alias.context}}/application/authorization/read-members.policy{{alias.ext}}';
|
|
64
|
+
import { RemoveMembersPolicy } from '{{alias.context}}/application/authorization/remove-members.policy{{alias.ext}}';
|
|
65
|
+
import { RevokeDelegationsPolicy } from '{{alias.context}}/application/authorization/revoke-delegations.policy{{alias.ext}}';
|
|
66
|
+
import { RevokeInvitationsPolicy } from '{{alias.context}}/application/authorization/revoke-invitations.policy{{alias.ext}}';
|
|
67
|
+
import { FakeAccountRepository } from '{{alias.context}}/test/fakes/account.repository.fake{{alias.ext}}';
|
|
68
|
+
import { FakeDelegationRepository } from '{{alias.context}}/test/fakes/delegation.repository.fake{{alias.ext}}';
|
|
69
|
+
import { FakeIdentityProviderAdmin } from '{{alias.context}}/test/fakes/identity-provider-admin.fake{{alias.ext}}';
|
|
70
|
+
import { FakeInvitationRepository } from '{{alias.context}}/test/fakes/invitation.repository.fake{{alias.ext}}';
|
|
71
|
+
import { FakeInvitationTokens } from '{{alias.context}}/test/fakes/invitation-tokens.fake{{alias.ext}}';
|
|
72
|
+
import { FakeMemberRepository } from '{{alias.context}}/test/fakes/member.repository.fake{{alias.ext}}';
|
|
73
|
+
import { FakeOrganisationRepository } from '{{alias.context}}/test/fakes/organisation.repository.fake{{alias.ext}}';
|
|
74
|
+
import { FakeSearchMembersReader } from '{{alias.context}}/test/fakes/search-members-reader.fake{{alias.ext}}';
|
|
75
|
+
|
|
76
|
+
/** The role every signed-in person holds in these specs: the platform grants it the permissions of the context. */
|
|
77
|
+
const PERSON = 'person';
|
|
78
|
+
|
|
79
|
+
const authorizer = new RoleBasedAuthorizer({ roles: { [PERSON]: Object.values({{context.camel}}Permissions) } });
|
|
80
|
+
|
|
81
|
+
/** What each use case of the context requires, as `{{context.kebab}}.module.ts` lists it. */
|
|
82
|
+
const people = authorizationMiddleware({
|
|
83
|
+
authorizer,
|
|
84
|
+
map: AuthorizationMap.of(
|
|
85
|
+
requires(AcceptInvitationCommand, {{context.camel}}Permissions['invitation.accept'], {
|
|
86
|
+
resource: () => ({ type: 'context', id: '{{context.kebab}}' }),
|
|
87
|
+
}),
|
|
88
|
+
requires(ChangeMemberRoleCommand, {{context.camel}}Permissions['member.change-role'], {
|
|
89
|
+
resource: () => ({ type: 'context', id: '{{context.kebab}}' }),
|
|
90
|
+
}),
|
|
91
|
+
requires(DeactivateAccountCommand, {{context.camel}}Permissions['account.deactivate'], {
|
|
92
|
+
resource: () => ({ type: 'context', id: '{{context.kebab}}' }),
|
|
93
|
+
}),
|
|
94
|
+
requires(DeclineInvitationCommand, {{context.camel}}Permissions['invitation.decline'], {
|
|
95
|
+
resource: () => ({ type: 'context', id: '{{context.kebab}}' }),
|
|
96
|
+
}),
|
|
97
|
+
requires(GrantDelegationCommand, {{context.camel}}Permissions['delegation.grant'], {
|
|
98
|
+
resource: () => ({ type: 'context', id: '{{context.kebab}}' }),
|
|
99
|
+
}),
|
|
100
|
+
requires(InviteMemberCommand, {{context.camel}}Permissions['member.invite'], {
|
|
101
|
+
resource: () => ({ type: 'context', id: '{{context.kebab}}' }),
|
|
102
|
+
}),
|
|
103
|
+
requires(OpenOrganisationCommand, {{context.camel}}Permissions['organisation.open'], {
|
|
104
|
+
resource: () => ({ type: 'context', id: '{{context.kebab}}' }),
|
|
105
|
+
}),
|
|
106
|
+
requires(ProvisionAccountCommand, {{context.camel}}Permissions['account.provision'], {
|
|
107
|
+
resource: () => ({ type: 'context', id: '{{context.kebab}}' }),
|
|
108
|
+
}),
|
|
109
|
+
requires(RemoveMemberCommand, {{context.camel}}Permissions['member.remove'], {
|
|
110
|
+
resource: () => ({ type: 'context', id: '{{context.kebab}}' }),
|
|
111
|
+
}),
|
|
112
|
+
requires(RevokeDelegationCommand, {{context.camel}}Permissions['delegation.revoke'], {
|
|
113
|
+
resource: () => ({ type: 'context', id: '{{context.kebab}}' }),
|
|
114
|
+
}),
|
|
115
|
+
requires(RevokeInvitationCommand, {{context.camel}}Permissions['invitation.revoke'], {
|
|
116
|
+
resource: () => ({ type: 'context', id: '{{context.kebab}}' }),
|
|
117
|
+
}),
|
|
118
|
+
requires(SearchMembersQuery, {{context.camel}}Permissions['member.search'], {
|
|
119
|
+
resource: () => ({ type: 'context', id: '{{context.kebab}}' }),
|
|
120
|
+
}),
|
|
121
|
+
),
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* The context on fakes, wired as `{{context.kebab}}.module.ts` wires it, behind an authorizer that
|
|
126
|
+
* grants its permissions to every signed-in person: inside an organisation, its own policies
|
|
127
|
+
* decide. `as(id)` is that person, `stranger` an actor the platform grants nothing.
|
|
128
|
+
*/
|
|
129
|
+
export function arrangeIdentity() {
|
|
130
|
+
const ports = fakePorts();
|
|
131
|
+
const buses = createTestBuses({ eventBusFailures: 'as-thrown' });
|
|
132
|
+
const wired = { buses, ports, repositories: dispatchedBy(buses, ports), access: accessOn(buses) };
|
|
133
|
+
|
|
134
|
+
buses.commandBus.use(people);
|
|
135
|
+
buses.queryBus.use(people);
|
|
136
|
+
registerAccountsAndOrganisations(wired);
|
|
137
|
+
registerInvitations(wired);
|
|
138
|
+
registerMembersAndDelegations(wired);
|
|
139
|
+
publishTheFacts(buses);
|
|
140
|
+
|
|
141
|
+
const start = (): Promise<void> => listen(wired);
|
|
142
|
+
const as = (id: string): Actor => anActor().named(id).withRole(PERSON).build();
|
|
143
|
+
|
|
144
|
+
return { application: { ...buses, start }, ...ports, as, stranger: anActor().named('stranger').build() };
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* The same, started: its consumers listen, among them those that bring the identity provider in
|
|
149
|
+
* line with the facts the context publishes (`application/integration/handlers/`).
|
|
150
|
+
*/
|
|
151
|
+
export async function startedIdentity(): Promise<ReturnType<typeof arrangeIdentity>> {
|
|
152
|
+
const arranged = arrangeIdentity();
|
|
153
|
+
|
|
154
|
+
await arranged.application.start();
|
|
155
|
+
|
|
156
|
+
return arranged;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function fakePorts() {
|
|
160
|
+
return {
|
|
161
|
+
accounts: new FakeAccountRepository(),
|
|
162
|
+
organisations: new FakeOrganisationRepository(),
|
|
163
|
+
members: new FakeMemberRepository(),
|
|
164
|
+
invitations: new FakeInvitationRepository(),
|
|
165
|
+
delegations: new FakeDelegationRepository(),
|
|
166
|
+
identityProvider: new FakeIdentityProviderAdmin(),
|
|
167
|
+
tokens: new FakeInvitationTokens(),
|
|
168
|
+
reader: new FakeSearchMembersReader(),
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/** The repositories as the application hands them to the handlers: a save announces the events of the aggregate. */
|
|
173
|
+
function dispatchedBy(buses: TestBuses, ports: ReturnType<typeof fakePorts>) {
|
|
174
|
+
return {
|
|
175
|
+
accounts: buses.dispatching(ports.accounts),
|
|
176
|
+
organisations: buses.dispatching(ports.organisations),
|
|
177
|
+
members: buses.dispatching(ports.members),
|
|
178
|
+
invitations: buses.dispatching(ports.invitations),
|
|
179
|
+
delegations: buses.dispatching(ports.delegations),
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/** The policies of the context, as the platform lists them in `access-policies.ts`. */
|
|
184
|
+
function accessOn(buses: TestBuses): Access {
|
|
185
|
+
return new PolicyAccess({
|
|
186
|
+
authorizer,
|
|
187
|
+
clock: buses.clock,
|
|
188
|
+
policies: [
|
|
189
|
+
new ChangeMemberRolesPolicy(),
|
|
190
|
+
new GrantDelegationsPolicy(),
|
|
191
|
+
new InviteMembersPolicy(),
|
|
192
|
+
new ReadMembersPolicy(),
|
|
193
|
+
new RemoveMembersPolicy(),
|
|
194
|
+
new RevokeDelegationsPolicy(),
|
|
195
|
+
new RevokeInvitationsPolicy(),
|
|
196
|
+
],
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
interface Wired {
|
|
201
|
+
readonly buses: TestBuses;
|
|
202
|
+
readonly ports: ReturnType<typeof fakePorts>;
|
|
203
|
+
readonly repositories: ReturnType<typeof dispatchedBy>;
|
|
204
|
+
readonly access: Access;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
function registerAccountsAndOrganisations({ buses, repositories }: Wired): void {
|
|
208
|
+
const { commandBus, ids, clock } = buses;
|
|
209
|
+
const { accounts, organisations, members, delegations } = repositories;
|
|
210
|
+
|
|
211
|
+
commandBus.register(ProvisionAccountCommand, new ProvisionAccountHandler(accounts, clock));
|
|
212
|
+
|
|
213
|
+
commandBus.register(
|
|
214
|
+
DeactivateAccountCommand,
|
|
215
|
+
new DeactivateAccountHandler(accounts, organisations, members, delegations, clock),
|
|
216
|
+
);
|
|
217
|
+
|
|
218
|
+
commandBus.register(
|
|
219
|
+
OpenOrganisationCommand,
|
|
220
|
+
new OpenOrganisationHandler(organisations, members, accounts, ids, clock),
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
function registerInvitations({ buses, repositories, ports, access }: Wired): void {
|
|
225
|
+
const { commandBus, ids, clock } = buses;
|
|
226
|
+
const { accounts, members, invitations, delegations } = repositories;
|
|
227
|
+
|
|
228
|
+
commandBus.register(
|
|
229
|
+
InviteMemberCommand,
|
|
230
|
+
new InviteMemberHandler(invitations, members, delegations, ports.tokens, access, ids, clock),
|
|
231
|
+
);
|
|
232
|
+
|
|
233
|
+
commandBus.register(
|
|
234
|
+
AcceptInvitationCommand,
|
|
235
|
+
new AcceptInvitationHandler(invitations, members, accounts, ports.tokens, ids, clock),
|
|
236
|
+
);
|
|
237
|
+
|
|
238
|
+
commandBus.register(
|
|
239
|
+
DeclineInvitationCommand,
|
|
240
|
+
new DeclineInvitationHandler(invitations, accounts, ports.tokens, clock),
|
|
241
|
+
);
|
|
242
|
+
|
|
243
|
+
commandBus.register(
|
|
244
|
+
RevokeInvitationCommand,
|
|
245
|
+
new RevokeInvitationHandler(invitations, members, delegations, access, clock),
|
|
246
|
+
);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
function registerMembersAndDelegations({ buses, repositories, ports, access }: Wired): void {
|
|
250
|
+
const { commandBus, queryBus, ids, clock } = buses;
|
|
251
|
+
const { organisations, members, delegations } = repositories;
|
|
252
|
+
|
|
253
|
+
commandBus.register(
|
|
254
|
+
ChangeMemberRoleCommand,
|
|
255
|
+
new ChangeMemberRoleHandler(organisations, members, delegations, access, clock),
|
|
256
|
+
);
|
|
257
|
+
|
|
258
|
+
commandBus.register(RemoveMemberCommand, new RemoveMemberHandler(organisations, members, delegations, access, clock));
|
|
259
|
+
commandBus.register(GrantDelegationCommand, new GrantDelegationHandler(delegations, members, access, ids, clock));
|
|
260
|
+
commandBus.register(RevokeDelegationCommand, new RevokeDelegationHandler(delegations, members, access, clock));
|
|
261
|
+
queryBus.register(SearchMembersQuery, new SearchMembersHandler(ports.reader, members, delegations, access, clock));
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/** The facts the context announces, published as the integration events of its published language. */
|
|
265
|
+
function publishTheFacts({ domainEvents, eventBus, ids }: TestBuses): void {
|
|
266
|
+
domainEvents.on(
|
|
267
|
+
AccountDeactivated.eventName,
|
|
268
|
+
announcedBy(AccountDeactivated, new AccountDeactivatedPublisher(eventBus, ids)),
|
|
269
|
+
);
|
|
270
|
+
|
|
271
|
+
domainEvents.on(
|
|
272
|
+
OrganisationOpened.eventName,
|
|
273
|
+
announcedBy(OrganisationOpened, new OrganisationOpenedPublisher(eventBus, ids)),
|
|
274
|
+
);
|
|
275
|
+
|
|
276
|
+
domainEvents.on(MemberJoined.eventName, announcedBy(MemberJoined, new MemberJoinedPublisher(eventBus, ids)));
|
|
277
|
+
|
|
278
|
+
domainEvents.on(
|
|
279
|
+
MemberRoleChanged.eventName,
|
|
280
|
+
announcedBy(MemberRoleChanged, new MemberRoleChangedPublisher(eventBus, ids)),
|
|
281
|
+
);
|
|
282
|
+
|
|
283
|
+
domainEvents.on(MemberRemoved.eventName, announcedBy(MemberRemoved, new MemberRemovedPublisher(eventBus, ids)));
|
|
284
|
+
|
|
285
|
+
domainEvents.on(
|
|
286
|
+
DelegationGranted.eventName,
|
|
287
|
+
announcedBy(DelegationGranted, new DelegationGrantedPublisher(eventBus, ids)),
|
|
288
|
+
);
|
|
289
|
+
|
|
290
|
+
domainEvents.on(
|
|
291
|
+
DelegationRevoked.eventName,
|
|
292
|
+
announcedBy(DelegationRevoked, new DelegationRevokedPublisher(eventBus, ids)),
|
|
293
|
+
);
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/** A handler of the dispatcher that hands the events of one class to their publisher. */
|
|
297
|
+
function announcedBy<Fact>(
|
|
298
|
+
fact: abstract new (...args: never[]) => Fact,
|
|
299
|
+
publisher: { handle(event: Fact): Promise<void> },
|
|
300
|
+
) {
|
|
301
|
+
return async (event: unknown): Promise<void> => {
|
|
302
|
+
if (event instanceof fact) {
|
|
303
|
+
await publisher.handle(event);
|
|
304
|
+
}
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/** The consumers that bring the identity provider in line, each event handled once. */
|
|
309
|
+
function listen({ buses, repositories, ports }: Wired): Promise<void> {
|
|
310
|
+
const processed = new InMemoryProcessedEventStore();
|
|
311
|
+
|
|
312
|
+
const options = (consumer: string) => ({
|
|
313
|
+
consumer: `{{context.kebab}}.${consumer}`,
|
|
314
|
+
processed,
|
|
315
|
+
unitOfWork: buses.unitOfWork,
|
|
316
|
+
scope: buses.executionScope,
|
|
317
|
+
});
|
|
318
|
+
|
|
319
|
+
const disables = new AccountDeactivatedIntegrationHandler(ports.identityProvider);
|
|
320
|
+
const joins = new MemberJoinedIntegrationHandler(repositories.members, ports.identityProvider);
|
|
321
|
+
const removes = new MemberRemovedIntegrationHandler(repositories.members, ports.identityProvider);
|
|
322
|
+
const opens = new OrganisationOpenedIntegrationHandler(ports.identityProvider);
|
|
323
|
+
|
|
324
|
+
subscribeAll(buses.eventBus, [
|
|
325
|
+
on(accountDeactivatedV1, (event) => disables.handle(event), options('provider-disables-account')),
|
|
326
|
+
on(memberJoinedV1, (event) => joins.handle(event), options('provider-follows-joined-member')),
|
|
327
|
+
on(memberRemovedV1, (event) => removes.handle(event), options('provider-follows-removed-member')),
|
|
328
|
+
on(organisationOpenedV1, (event) => opens.handle(event), options('provider-opens-organisation')),
|
|
329
|
+
]);
|
|
330
|
+
|
|
331
|
+
return Promise.resolve();
|
|
332
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
@@imports
|
|
2
|
+
import { ChangeMemberRolesPolicy } from '{{alias.context}}/application/authorization/change-member-roles.policy{{alias.ext}}';
|
|
3
|
+
import { GrantDelegationsPolicy } from '{{alias.context}}/application/authorization/grant-delegations.policy{{alias.ext}}';
|
|
4
|
+
import { InviteMembersPolicy } from '{{alias.context}}/application/authorization/invite-members.policy{{alias.ext}}';
|
|
5
|
+
import { ReadMembersPolicy } from '{{alias.context}}/application/authorization/read-members.policy{{alias.ext}}';
|
|
6
|
+
import { RemoveMembersPolicy } from '{{alias.context}}/application/authorization/remove-members.policy{{alias.ext}}';
|
|
7
|
+
import { RevokeDelegationsPolicy } from '{{alias.context}}/application/authorization/revoke-delegations.policy{{alias.ext}}';
|
|
8
|
+
import { RevokeInvitationsPolicy } from '{{alias.context}}/application/authorization/revoke-invitations.policy{{alias.ext}}';
|
|
9
|
+
@@policies
|
|
10
|
+
new ChangeMemberRolesPolicy(),
|
|
11
|
+
new GrantDelegationsPolicy(),
|
|
12
|
+
new InviteMembersPolicy(),
|
|
13
|
+
new ReadMembersPolicy(),
|
|
14
|
+
new RemoveMembersPolicy(),
|
|
15
|
+
new RevokeDelegationsPolicy(),
|
|
16
|
+
new RevokeInvitationsPolicy(),
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/// Whether an account may still act: a deactivated account keeps its history and signs in no more.
|
|
2
|
+
enum {{context.pascal}}AccountStatus {
|
|
3
|
+
active
|
|
4
|
+
deactivated
|
|
5
|
+
|
|
6
|
+
@@map("account_status")
|
|
7
|
+
@@schema("{{context.schema}}")
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/// The role of a member in an organisation: what the member may do there follows from it.
|
|
11
|
+
enum {{context.pascal}}MemberRole {
|
|
12
|
+
owner
|
|
13
|
+
admin
|
|
14
|
+
member
|
|
15
|
+
|
|
16
|
+
@@map("member_role")
|
|
17
|
+
@@schema("{{context.schema}}")
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/// Where an invitation stands: pending until its person answers, or the organisation takes it back.
|
|
21
|
+
enum {{context.pascal}}InvitationStatus {
|
|
22
|
+
pending
|
|
23
|
+
accepted
|
|
24
|
+
declined
|
|
25
|
+
revoked
|
|
26
|
+
|
|
27
|
+
@@map("invitation_status")
|
|
28
|
+
@@schema("{{context.schema}}")
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/// Keyed by the subject the identity provider gives the person. No password is stored.
|
|
32
|
+
model {{context.pascal}}Account {
|
|
33
|
+
id String @id
|
|
34
|
+
email String
|
|
35
|
+
displayName String @map("display_name")
|
|
36
|
+
status {{context.pascal}}AccountStatus
|
|
37
|
+
provisionedAt DateTime @map("provisioned_at") @db.Timestamptz(3)
|
|
38
|
+
deactivatedAt DateTime? @map("deactivated_at") @db.Timestamptz(3)
|
|
39
|
+
version Int
|
|
40
|
+
createdAt DateTime @map("created_at") @db.Timestamptz(3)
|
|
41
|
+
createdBy String @map("created_by")
|
|
42
|
+
updatedAt DateTime @map("updated_at") @db.Timestamptz(3)
|
|
43
|
+
updatedBy String @map("updated_by")
|
|
44
|
+
|
|
45
|
+
@@map("accounts")
|
|
46
|
+
@@schema("{{context.schema}}")
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/// Keyed by the slug, which is also the tenant id when the project has tenants.
|
|
50
|
+
model {{context.pascal}}Organisation {
|
|
51
|
+
id String @id
|
|
52
|
+
name String
|
|
53
|
+
openedBy String @map("opened_by")
|
|
54
|
+
openedAt DateTime @map("opened_at") @db.Timestamptz(3)
|
|
55
|
+
version Int
|
|
56
|
+
createdAt DateTime @map("created_at") @db.Timestamptz(3)
|
|
57
|
+
createdBy String @map("created_by")
|
|
58
|
+
updatedAt DateTime @map("updated_at") @db.Timestamptz(3)
|
|
59
|
+
updatedBy String @map("updated_by")
|
|
60
|
+
|
|
61
|
+
@@map("organisations")
|
|
62
|
+
@@schema("{{context.schema}}")
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/// One current membership per account and organisation: the partial unique index is the guard.
|
|
66
|
+
model {{context.pascal}}Member {
|
|
67
|
+
id String @id
|
|
68
|
+
organisationId String @map("organisation_id")
|
|
69
|
+
accountId String @map("account_id")
|
|
70
|
+
role {{context.pascal}}MemberRole
|
|
71
|
+
joinedAt DateTime @map("joined_at") @db.Timestamptz(3)
|
|
72
|
+
removedAt DateTime? @map("removed_at") @db.Timestamptz(3)
|
|
73
|
+
version Int
|
|
74
|
+
createdAt DateTime @map("created_at") @db.Timestamptz(3)
|
|
75
|
+
createdBy String @map("created_by")
|
|
76
|
+
updatedAt DateTime @map("updated_at") @db.Timestamptz(3)
|
|
77
|
+
updatedBy String @map("updated_by")
|
|
78
|
+
|
|
79
|
+
// Preview feature `partialIndexes`: after an upgrade of Prisma, check generated/schema.sql keeps the WHERE.
|
|
80
|
+
@@unique([organisationId, accountId], map: "members_current_idx", where: { removedAt: null })
|
|
81
|
+
@@index([accountId], map: "members_account_idx")
|
|
82
|
+
@@map("members")
|
|
83
|
+
@@schema("{{context.schema}}")
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
model {{context.pascal}}Invitation {
|
|
87
|
+
id String @id
|
|
88
|
+
organisationId String @map("organisation_id")
|
|
89
|
+
email String
|
|
90
|
+
role {{context.pascal}}MemberRole
|
|
91
|
+
tokenHash String @unique @map("token_hash")
|
|
92
|
+
invitedBy String @map("invited_by")
|
|
93
|
+
issuedAt DateTime @map("issued_at") @db.Timestamptz(3)
|
|
94
|
+
expiresAt DateTime @map("expires_at") @db.Timestamptz(3)
|
|
95
|
+
status {{context.pascal}}InvitationStatus
|
|
96
|
+
answeredAt DateTime? @map("answered_at") @db.Timestamptz(3)
|
|
97
|
+
version Int
|
|
98
|
+
createdAt DateTime @map("created_at") @db.Timestamptz(3)
|
|
99
|
+
createdBy String @map("created_by")
|
|
100
|
+
updatedAt DateTime @map("updated_at") @db.Timestamptz(3)
|
|
101
|
+
updatedBy String @map("updated_by")
|
|
102
|
+
|
|
103
|
+
@@index([organisationId, status], map: "invitations_organisation_idx")
|
|
104
|
+
@@map("invitations")
|
|
105
|
+
@@schema("{{context.schema}}")
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
model {{context.pascal}}Delegation {
|
|
109
|
+
id String @id
|
|
110
|
+
organisationId String @map("organisation_id")
|
|
111
|
+
delegatorId String @map("delegator_id")
|
|
112
|
+
delegateId String @map("delegate_id")
|
|
113
|
+
/// The rights lent, separated by commas: a right is a word of `MemberRight`, which holds none.
|
|
114
|
+
rights String
|
|
115
|
+
startsAt DateTime @map("starts_at") @db.Timestamptz(3)
|
|
116
|
+
endsAt DateTime @map("ends_at") @db.Timestamptz(3)
|
|
117
|
+
endedAt DateTime? @map("ended_at") @db.Timestamptz(3)
|
|
118
|
+
version Int
|
|
119
|
+
createdAt DateTime @map("created_at") @db.Timestamptz(3)
|
|
120
|
+
createdBy String @map("created_by")
|
|
121
|
+
updatedAt DateTime @map("updated_at") @db.Timestamptz(3)
|
|
122
|
+
updatedBy String @map("updated_by")
|
|
123
|
+
|
|
124
|
+
@@index([organisationId, delegateId], map: "delegations_delegate_idx")
|
|
125
|
+
@@index([organisationId, delegatorId], map: "delegations_delegator_idx")
|
|
126
|
+
@@map("delegations")
|
|
127
|
+
@@schema("{{context.schema}}")
|
|
128
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { describe, expect, it } from '{{tests.module}}';
|
|
2
|
+
import fc from 'fast-check';
|
|
3
|
+
{{#if valueObjects.result}}
|
|
4
|
+
import { unwrap } from '@ddd-ts-kit/kernel';
|
|
5
|
+
{{/if}}
|
|
6
|
+
import { {{name.pascal}} } from '{{alias.context}}/domain/value-objects/{{name.kebab}}.vo{{alias.ext}}';
|
|
7
|
+
|
|
8
|
+
describe('{{name.pascal}}, for any value', () => {
|
|
9
|
+
it('is equal to the {{name.words}} created again from its own value', () => {
|
|
10
|
+
fc.assert(
|
|
11
|
+
fc.property(any{{name.pascal}}(), (value) => {
|
|
12
|
+
expect(create(value.value).equals(value)).toBe(true);
|
|
13
|
+
}),
|
|
14
|
+
);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
// TODO(domain): state each law {{name.pascal}} holds for every value as a property over any{{name.pascal}}(), its title the law, then remove the entry it replaces.
|
|
18
|
+
it.todo('keeps its invariants after each of its operations, for any value');
|
|
19
|
+
it.todo('gives the same answer whichever of two values comes first, for a comparison it offers');
|
|
20
|
+
it.todo('gives the value back after a format then a parse, for any value');
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
// TODO(domain): generate the real components of {{name.pascal}}, within the bounds its factory accepts, so that every generated value is one the model accepts.
|
|
24
|
+
function any{{name.pascal}}(): fc.Arbitrary<{{name.pascal}}> {
|
|
25
|
+
return fc
|
|
26
|
+
.string({ minLength: 1 })
|
|
27
|
+
.filter((value) => value.trim().length > 0)
|
|
28
|
+
.map(create);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function create(value: string): {{name.pascal}} {
|
|
32
|
+
{{#if valueObjects.throwing}}
|
|
33
|
+
return {{name.pascal}}.create(value);
|
|
34
|
+
{{/if}}
|
|
35
|
+
{{#if valueObjects.result}}
|
|
36
|
+
return unwrap({{name.pascal}}.create(value));
|
|
37
|
+
{{/if}}
|
|
38
|
+
}
|