ddd-ts-kit 0.91.0 → 0.93.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 +225 -0
- package/README.fr.md +27 -18
- package/README.md +24 -15
- package/dist/acceptance/check-locked-files.d.ts +25 -0
- package/dist/acceptance/check-locked-files.d.ts.map +1 -0
- package/dist/acceptance/check-locked-files.js +84 -0
- package/dist/acceptance/check-locked-files.js.map +1 -0
- package/dist/acceptance/lock-acceptance.d.ts.map +1 -1
- package/dist/acceptance/lock-acceptance.js +2 -1
- package/dist/acceptance/lock-acceptance.js.map +1 -1
- package/dist/acceptance/scenarios-in.d.ts +4 -0
- package/dist/acceptance/scenarios-in.d.ts.map +1 -1
- package/dist/acceptance/scenarios-in.js +2 -2
- package/dist/acceptance/scenarios-in.js.map +1 -1
- package/dist/check/event-sourcing/read-stored-shape.d.ts +2 -0
- package/dist/check/event-sourcing/read-stored-shape.d.ts.map +1 -1
- package/dist/check/event-sourcing/read-stored-shape.js +3 -1
- package/dist/check/event-sourcing/read-stored-shape.js.map +1 -1
- package/dist/check/event-sourcing/stored-event-declaration.d.ts +2 -0
- package/dist/check/event-sourcing/stored-event-declaration.d.ts.map +1 -1
- package/dist/check/event-sourcing/stored-event-declarations.js +1 -0
- package/dist/check/event-sourcing/stored-event-declarations.js.map +1 -1
- package/dist/check/event-sourcing/stored-shape.d.ts +2 -0
- package/dist/check/event-sourcing/stored-shape.d.ts.map +1 -1
- package/dist/check/fixtures/nest-controllers-fixtures.d.ts.map +1 -1
- package/dist/check/fixtures/nest-controllers-fixtures.js +21 -3
- package/dist/check/fixtures/nest-controllers-fixtures.js.map +1 -1
- package/dist/check/nest/nest-equivalents-of.d.ts.map +1 -1
- package/dist/check/nest/nest-equivalents-of.js +7 -2
- package/dist/check/nest/nest-equivalents-of.js.map +1 -1
- package/dist/check/rules/nest-controllers-current.d.ts.map +1 -1
- package/dist/check/rules/nest-controllers-current.js +13 -2
- package/dist/check/rules/nest-controllers-current.js.map +1 -1
- package/dist/commands/acceptance.d.ts.map +1 -1
- package/dist/commands/acceptance.js +14 -0
- package/dist/commands/acceptance.js.map +1 -1
- package/dist/commands/docs.d.ts.map +1 -1
- package/dist/commands/docs.js +13 -5
- package/dist/commands/docs.js.map +1 -1
- package/dist/commands/drizzle-generate.d.ts.map +1 -1
- package/dist/commands/drizzle-generate.js +21 -1
- package/dist/commands/drizzle-generate.js.map +1 -1
- package/dist/commands/generate.js +4 -0
- package/dist/commands/generate.js.map +1 -1
- package/dist/commands/prisma-generate.d.ts +7 -0
- package/dist/commands/prisma-generate.d.ts.map +1 -0
- package/dist/commands/prisma-generate.js +23 -0
- package/dist/commands/prisma-generate.js.map +1 -0
- package/dist/commands/typeorm-generate.d.ts +10 -0
- package/dist/commands/typeorm-generate.d.ts.map +1 -0
- package/dist/commands/typeorm-generate.js +37 -0
- package/dist/commands/typeorm-generate.js.map +1 -0
- package/dist/commit/run-git.d.ts +5 -1
- package/dist/commit/run-git.d.ts.map +1 -1
- package/dist/commit/run-git.js +19 -2
- package/dist/commit/run-git.js.map +1 -1
- package/dist/config/stack.d.ts +1 -1
- package/dist/config/stack.d.ts.map +1 -1
- package/dist/config/stack.js +1 -1
- package/dist/config/stack.js.map +1 -1
- package/dist/controllers/finish-migration.js +4 -2
- package/dist/controllers/finish-migration.js.map +1 -1
- package/dist/describe/guard-errors.d.ts +3 -0
- package/dist/describe/guard-errors.d.ts.map +1 -0
- package/dist/describe/guard-errors.js +10 -0
- package/dist/describe/guard-errors.js.map +1 -0
- package/dist/describe/no-group.d.ts +4 -0
- package/dist/describe/no-group.d.ts.map +1 -0
- package/dist/describe/no-group.js +3 -0
- package/dist/describe/no-group.js.map +1 -0
- package/dist/describe/read-controllers.d.ts +1 -1
- package/dist/describe/read-controllers.d.ts.map +1 -1
- package/dist/describe/read-controllers.js +12 -19
- package/dist/describe/read-controllers.js.map +1 -1
- package/dist/describe/read-nest-controller-routes.d.ts +16 -0
- package/dist/describe/read-nest-controller-routes.d.ts.map +1 -0
- package/dist/describe/read-nest-controller-routes.js +117 -0
- package/dist/describe/read-nest-controller-routes.js.map +1 -0
- package/dist/describe/schema-class-of.d.ts +3 -0
- package/dist/describe/schema-class-of.d.ts.map +1 -0
- package/dist/describe/schema-class-of.js +10 -0
- package/dist/describe/schema-class-of.js.map +1 -0
- package/dist/docs/behaviour-page.d.ts.map +1 -1
- package/dist/docs/behaviour-page.js +9 -1
- package/dist/docs/behaviour-page.js.map +1 -1
- package/dist/docs/declared-stored-events.d.ts +6 -2
- package/dist/docs/declared-stored-events.d.ts.map +1 -1
- package/dist/docs/declared-stored-events.js +4 -3
- package/dist/docs/declared-stored-events.js.map +1 -1
- package/dist/docs/emptily-recorded-stored-events.d.ts +6 -0
- package/dist/docs/emptily-recorded-stored-events.d.ts.map +1 -0
- package/dist/docs/emptily-recorded-stored-events.js +12 -0
- package/dist/docs/emptily-recorded-stored-events.js.map +1 -0
- package/dist/docs/refuse-unreadable-stored-events.d.ts +7 -0
- package/dist/docs/refuse-unreadable-stored-events.d.ts.map +1 -0
- package/dist/docs/refuse-unreadable-stored-events.js +27 -0
- package/dist/docs/refuse-unreadable-stored-events.js.map +1 -0
- package/dist/docs/write-stored-events-lock.d.ts +3 -2
- package/dist/docs/write-stored-events-lock.d.ts.map +1 -1
- package/dist/docs/write-stored-events-lock.js +5 -2
- package/dist/docs/write-stored-events-lock.js.map +1 -1
- package/dist/generate/kind.d.ts +4 -0
- package/dist/generate/kind.d.ts.map +1 -1
- package/dist/generate/kinds/aggregate-kind.d.ts.map +1 -1
- package/dist/generate/kinds/aggregate-kind.js +6 -2
- package/dist/generate/kinds/aggregate-kind.js.map +1 -1
- package/dist/generate/kinds/assert-event-store.d.ts +4 -0
- package/dist/generate/kinds/assert-event-store.d.ts.map +1 -0
- package/dist/generate/kinds/assert-event-store.js +10 -0
- package/dist/generate/kinds/assert-event-store.js.map +1 -0
- package/dist/generate/kinds/file-upload/write-nest-upload-controller.d.ts +9 -0
- package/dist/generate/kinds/file-upload/write-nest-upload-controller.d.ts.map +1 -0
- package/dist/generate/kinds/file-upload/write-nest-upload-controller.js +49 -0
- package/dist/generate/kinds/file-upload/write-nest-upload-controller.js.map +1 -0
- package/dist/generate/kinds/file-upload-kind.d.ts.map +1 -1
- package/dist/generate/kinds/file-upload-kind.js +9 -2
- package/dist/generate/kinds/file-upload-kind.js.map +1 -1
- package/dist/generate/kinds/form-kind.d.ts.map +1 -1
- package/dist/generate/kinds/form-kind.js +15 -11
- package/dist/generate/kinds/form-kind.js.map +1 -1
- package/dist/generate/kinds/generate-event-sourced-repository.d.ts +11 -0
- package/dist/generate/kinds/generate-event-sourced-repository.d.ts.map +1 -0
- package/dist/generate/kinds/generate-event-sourced-repository.js +48 -0
- package/dist/generate/kinds/generate-event-sourced-repository.js.map +1 -0
- package/dist/generate/kinds/generate-repository.d.ts.map +1 -1
- package/dist/generate/kinds/generate-repository.js +5 -0
- package/dist/generate/kinds/generate-repository.js.map +1 -1
- package/dist/generate/kinds/is-event-sourced.d.ts +9 -0
- package/dist/generate/kinds/is-event-sourced.d.ts.map +1 -0
- package/dist/generate/kinds/is-event-sourced.js +11 -0
- package/dist/generate/kinds/is-event-sourced.js.map +1 -0
- package/dist/generate/kinds/job/job-vars.d.ts +4 -1
- package/dist/generate/kinds/job/job-vars.d.ts.map +1 -1
- package/dist/generate/kinds/job/job-vars.js +11 -1
- package/dist/generate/kinds/job/job-vars.js.map +1 -1
- package/dist/generate/kinds/job-kind.js +20 -3
- package/dist/generate/kinds/job-kind.js.map +1 -1
- package/dist/generate/kinds/presentation/controller-source.d.ts +11 -3
- package/dist/generate/kinds/presentation/controller-source.d.ts.map +1 -1
- package/dist/generate/kinds/presentation/controller-source.js +25 -4
- package/dist/generate/kinds/presentation/controller-source.js.map +1 -1
- package/dist/generate/kinds/repository-kind.js +1 -1
- package/dist/generate/kinds/repository-kind.js.map +1 -1
- package/dist/generate/kinds/representation-kind.d.ts.map +1 -1
- package/dist/generate/kinds/representation-kind.js +4 -3
- package/dist/generate/kinds/representation-kind.js.map +1 -1
- package/dist/generate/kinds/route/nest-controller-vars.d.ts +2 -2
- package/dist/generate/kinds/route/nest-controller-vars.js +3 -9
- package/dist/generate/kinds/route/nest-controller-vars.js.map +1 -1
- package/dist/generate/kinds/route/nest-search-vars.d.ts +6 -0
- package/dist/generate/kinds/route/nest-search-vars.d.ts.map +1 -0
- package/dist/generate/kinds/route/nest-search-vars.js +18 -0
- package/dist/generate/kinds/route/nest-search-vars.js.map +1 -0
- package/dist/generate/kinds/route/write-nest-controller.d.ts.map +1 -1
- package/dist/generate/kinds/route/write-nest-controller.js +6 -8
- package/dist/generate/kinds/route/write-nest-controller.js.map +1 -1
- package/dist/generate/kinds/route-kind.js +1 -1
- package/dist/generate/kinds/route-kind.js.map +1 -1
- package/dist/generate/kinds/service-kind.d.ts.map +1 -1
- package/dist/generate/kinds/service-kind.js +30 -3
- package/dist/generate/kinds/service-kind.js.map +1 -1
- package/dist/generate/kinds/wire-repository-on-first-use.d.ts.map +1 -1
- package/dist/generate/kinds/wire-repository-on-first-use.js +2 -1
- package/dist/generate/kinds/wire-repository-on-first-use.js.map +1 -1
- package/dist/generate/kinds/write-event-sourced-aggregate.d.ts.map +1 -1
- package/dist/generate/kinds/write-event-sourced-aggregate.js +5 -13
- package/dist/generate/kinds/write-event-sourced-aggregate.js.map +1 -1
- package/dist/help/notes.d.ts +1 -1
- package/dist/help/notes.d.ts.map +1 -1
- package/dist/help/notes.js +3 -1
- package/dist/help/notes.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 +3 -1
- package/dist/help/usage.js.map +1 -1
- package/dist/init/agent-permissions.js +10 -6
- package/dist/init/agent-permissions.js.map +1 -1
- package/dist/init/files/auth-files.js +4 -0
- package/dist/init/files/auth-files.js.map +1 -1
- package/dist/init/files/inert-persistence-file.d.ts +5 -0
- package/dist/init/files/inert-persistence-file.d.ts.map +1 -0
- package/dist/init/files/inert-persistence-file.js +16 -0
- package/dist/init/files/inert-persistence-file.js.map +1 -0
- package/dist/init/files/platform-files.js +7 -1
- package/dist/init/files/platform-files.js.map +1 -1
- package/dist/init/knip-vars.js +4 -3
- package/dist/init/knip-vars.js.map +1 -1
- package/dist/init/manifest/database-scripts.d.ts.map +1 -1
- package/dist/init/manifest/database-scripts.js +10 -4
- package/dist/init/manifest/database-scripts.js.map +1 -1
- package/dist/init/manifest/dependencies-against-stack.d.ts.map +1 -1
- package/dist/init/manifest/dependencies-against-stack.js +5 -1
- package/dist/init/manifest/dependencies-against-stack.js.map +1 -1
- package/dist/init/manifest/dependencies-for.d.ts.map +1 -1
- package/dist/init/manifest/dependencies-for.js +7 -1
- package/dist/init/manifest/dependencies-for.js.map +1 -1
- package/dist/init/manifest/versions.d.ts.map +1 -1
- package/dist/init/manifest/versions.js +34 -30
- package/dist/init/manifest/versions.js.map +1 -1
- package/dist/init/stack/resolve-stack.js +9 -7
- package/dist/init/stack/resolve-stack.js.map +1 -1
- package/dist/init/template-vars.js +1 -1
- package/dist/init/template-vars.js.map +1 -1
- package/dist/init/write-type-script-configs.d.ts.map +1 -1
- package/dist/init/write-type-script-configs.js +4 -1
- package/dist/init/write-type-script-configs.js.map +1 -1
- package/dist/markers/insert-in-region.js +1 -1
- package/dist/markers/insert-in-region.js.map +1 -1
- package/dist/measures/branch-commits.d.ts +4 -2
- package/dist/measures/branch-commits.d.ts.map +1 -1
- package/dist/measures/branch-commits.js +32 -8
- package/dist/measures/branch-commits.js.map +1 -1
- package/dist/measures/timeline-of.d.ts +3 -2
- package/dist/measures/timeline-of.d.ts.map +1 -1
- package/dist/measures/timeline-of.js +37 -8
- package/dist/measures/timeline-of.js.map +1 -1
- package/dist/merge/lost/untouched-by-branch.d.ts +12 -0
- package/dist/merge/lost/untouched-by-branch.d.ts.map +1 -0
- package/dist/merge/lost/untouched-by-branch.js +22 -0
- package/dist/merge/lost/untouched-by-branch.js.map +1 -0
- package/dist/merge/lost/verify-merge.d.ts.map +1 -1
- package/dist/merge/lost/verify-merge.js +6 -1
- package/dist/merge/lost/verify-merge.js.map +1 -1
- package/dist/migration/audit-guard/append-audit-guard.d.ts +18 -0
- package/dist/migration/audit-guard/append-audit-guard.d.ts.map +1 -0
- package/dist/migration/audit-guard/append-audit-guard.js +27 -0
- package/dist/migration/audit-guard/append-audit-guard.js.map +1 -0
- package/dist/migration/audit-guard/audit-guard-statements-of.d.ts +7 -0
- package/dist/migration/audit-guard/audit-guard-statements-of.d.ts.map +1 -0
- package/dist/migration/audit-guard/audit-guard-statements-of.js +18 -0
- package/dist/migration/audit-guard/audit-guard-statements-of.js.map +1 -0
- package/dist/migration/audit-guard/audit-schema-created.d.ts +3 -0
- package/dist/migration/audit-guard/audit-schema-created.d.ts.map +1 -0
- package/dist/migration/audit-guard/audit-schema-created.js +9 -0
- package/dist/migration/audit-guard/audit-schema-created.js.map +1 -0
- package/dist/migration/audit-guard/generate-guarded.d.ts +16 -0
- package/dist/migration/audit-guard/generate-guarded.d.ts.map +1 -0
- package/dist/migration/audit-guard/generate-guarded.js +22 -0
- package/dist/migration/audit-guard/generate-guarded.js.map +1 -0
- package/dist/migration/audit-guard/guard-marker.d.ts +3 -0
- package/dist/migration/audit-guard/guard-marker.d.ts.map +1 -0
- package/dist/migration/audit-guard/guard-marker.js +3 -0
- package/dist/migration/audit-guard/guard-marker.js.map +1 -0
- package/dist/migration/audit-guard/guarded-text.d.ts +5 -0
- package/dist/migration/audit-guard/guarded-text.d.ts.map +1 -0
- package/dist/migration/audit-guard/guarded-text.js +26 -0
- package/dist/migration/audit-guard/guarded-text.js.map +1 -0
- package/dist/migration/audit-guard/migrations-under.d.ts +3 -0
- package/dist/migration/audit-guard/migrations-under.d.ts.map +1 -0
- package/dist/migration/audit-guard/migrations-under.js +15 -0
- package/dist/migration/audit-guard/migrations-under.js.map +1 -0
- package/dist/migration/audit-guard/run-orm-tool.d.ts +3 -0
- package/dist/migration/audit-guard/run-orm-tool.d.ts.map +1 -0
- package/dist/migration/audit-guard/run-orm-tool.js +13 -0
- package/dist/migration/audit-guard/run-orm-tool.js.map +1 -0
- package/dist/migration/audit-guard/schemas-first.d.ts +6 -0
- package/dist/migration/audit-guard/schemas-first.d.ts.map +1 -0
- package/dist/migration/audit-guard/schemas-first.js +17 -0
- package/dist/migration/audit-guard/schemas-first.js.map +1 -0
- package/dist/migration/audit-guard/schemas-if-missing.d.ts +7 -0
- package/dist/migration/audit-guard/schemas-if-missing.d.ts.map +1 -0
- package/dist/migration/audit-guard/schemas-if-missing.js +9 -0
- package/dist/migration/audit-guard/schemas-if-missing.js.map +1 -0
- package/dist/migration/audit-guard/type-only-imports.d.ts +6 -0
- package/dist/migration/audit-guard/type-only-imports.d.ts.map +1 -0
- package/dist/migration/audit-guard/type-only-imports.js +8 -0
- package/dist/migration/audit-guard/type-only-imports.js.map +1 -0
- package/dist/migration/format-as-the-project.d.ts +4 -0
- package/dist/migration/format-as-the-project.d.ts.map +1 -0
- package/dist/migration/format-as-the-project.js +27 -0
- package/dist/migration/format-as-the-project.js.map +1 -0
- package/dist/migration/format-written-files.d.ts.map +1 -1
- package/dist/migration/format-written-files.js +2 -24
- package/dist/migration/format-written-files.js.map +1 -1
- package/dist/migration/index.d.ts +8 -0
- package/dist/migration/index.d.ts.map +1 -1
- package/dist/migration/index.js +8 -0
- package/dist/migration/index.js.map +1 -1
- package/dist/nest-controllers/nest-answer.d.ts +2 -10
- package/dist/nest-controllers/nest-answer.d.ts.map +1 -1
- package/dist/nest-controllers/nest-controller-entry.d.ts +4 -2
- package/dist/nest-controllers/nest-controller-entry.d.ts.map +1 -1
- package/dist/nest-controllers/nest-controllers-in.d.ts +6 -0
- package/dist/nest-controllers/nest-controllers-in.d.ts.map +1 -0
- package/dist/nest-controllers/nest-controllers-in.js +108 -0
- package/dist/nest-controllers/nest-controllers-in.js.map +1 -0
- package/dist/nest-controllers/nest-read-type.d.ts +12 -0
- package/dist/nest-controllers/nest-read-type.d.ts.map +1 -0
- package/dist/nest-controllers/nest-read-type.js +2 -0
- package/dist/nest-controllers/nest-read-type.js.map +1 -0
- package/dist/nest-controllers/nest-request-part.d.ts +9 -0
- package/dist/nest-controllers/nest-request-part.d.ts.map +1 -0
- package/dist/nest-controllers/nest-request-part.js +2 -0
- package/dist/nest-controllers/nest-request-part.js.map +1 -0
- package/dist/nest-controllers/parameters-of.d.ts +8 -0
- package/dist/nest-controllers/parameters-of.d.ts.map +1 -0
- package/dist/nest-controllers/parameters-of.js +32 -0
- package/dist/nest-controllers/parameters-of.js.map +1 -0
- package/dist/nest-controllers/project-files.d.ts +6 -0
- package/dist/nest-controllers/project-files.d.ts.map +1 -0
- package/dist/nest-controllers/project-files.js +2 -0
- package/dist/nest-controllers/project-files.js.map +1 -0
- package/dist/nest-controllers/read-nest-controllers.d.ts +6 -9
- package/dist/nest-controllers/read-nest-controllers.d.ts.map +1 -1
- package/dist/nest-controllers/read-nest-controllers.js +10 -82
- package/dist/nest-controllers/read-nest-controllers.js.map +1 -1
- package/dist/nest-controllers/render-controllers-file.d.ts +4 -3
- package/dist/nest-controllers/render-controllers-file.d.ts.map +1 -1
- package/dist/nest-controllers/render-controllers-file.js +45 -29
- package/dist/nest-controllers/render-controllers-file.js.map +1 -1
- package/dist/platform-layout/platform-layout.d.ts +5 -0
- package/dist/platform-layout/platform-layout.d.ts.map +1 -1
- package/dist/platform-layout/platform-layout.js +5 -0
- package/dist/platform-layout/platform-layout.js.map +1 -1
- package/dist/presets/identity-refusal.js +3 -3
- package/dist/presets/identity-refusal.js.map +1 -1
- package/dist/presets/no-flags.d.ts.map +1 -1
- package/dist/presets/no-flags.js +1 -0
- package/dist/presets/no-flags.js.map +1 -1
- package/dist/presets/preset-files.d.ts.map +1 -1
- package/dist/presets/preset-files.js +3 -1
- package/dist/presets/preset-files.js.map +1 -1
- package/dist/progress/build-next-of.d.ts +9 -0
- package/dist/progress/build-next-of.d.ts.map +1 -0
- package/dist/progress/build-next-of.js +22 -0
- package/dist/progress/build-next-of.js.map +1 -0
- package/dist/progress/format-progress.d.ts.map +1 -1
- package/dist/progress/format-progress.js +3 -0
- package/dist/progress/format-progress.js.map +1 -1
- package/dist/progress/progress.d.ts +3 -1
- package/dist/progress/progress.d.ts.map +1 -1
- package/dist/progress/read-progress.d.ts.map +1 -1
- package/dist/progress/read-progress.js +7 -2
- package/dist/progress/read-progress.js.map +1 -1
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js +4 -0
- package/dist/run.js.map +1 -1
- package/dist/stack/authentication-vars.d.ts.map +1 -1
- package/dist/stack/authentication-vars.js +8 -2
- package/dist/stack/authentication-vars.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/worker/briefing-of.d.ts.map +1 -1
- package/dist/worker/briefing-of.js +2 -4
- package/dist/worker/briefing-of.js.map +1 -1
- package/dist/worker/resume-message.d.ts.map +1 -1
- package/dist/worker/resume-message.js +1 -2
- package/dist/worker/resume-message.js.map +1 -1
- package/package.json +6 -4
- package/templates/architecture/extractable.declared.spec.ts.tpl +2 -2
- package/templates/architecture/extractable.manual.spec.ts.tpl +2 -2
- package/templates/architecture/extractable.tsyringe.spec.ts.tpl +2 -2
- package/templates/architecture/hosting.declared.spec.ts.tpl +69 -0
- package/templates/architecture/hosting.manual.spec.ts.tpl +57 -0
- package/templates/architecture/hosting.tsyringe.spec.ts.tpl +69 -0
- package/templates/background-job/wiring.manual.tpl +1 -1
- package/templates/command/wiring.manual.tpl +1 -1
- package/templates/context/module.manual.ts.tpl +41 -10
- package/templates/erasure-handler/wiring.manual.tpl +1 -1
- package/templates/event-handler/wiring.manual.tpl +1 -1
- package/templates/file-upload/wiring.manual.tpl +1 -1
- package/templates/init/docker/env.example.tpl +9 -1
- package/templates/init/e2e/auth-environment.passport.ts.tpl +6 -0
- package/templates/init/e2e/create-credentials.passport.ts.tpl +47 -0
- package/templates/init/gitignore.tpl +3 -0
- package/templates/init/main.ts.tpl +27 -20
- package/templates/init/platform/audit/audit.module.tsyringe.ts.tpl +11 -3
- package/templates/init/platform/auth/authentication/actor-of-token.ts.tpl +15 -0
- package/templates/init/platform/auth/authentication/bearer-strategy.ts.tpl +29 -0
- package/templates/init/platform/auth/authentication/create-authenticator.passport.ts.tpl +13 -0
- package/templates/init/platform/composition/compose-application.manual.ts.tpl +30 -6
- package/templates/init/platform/composition/compose-application.tsyringe.ts.tpl +47 -65
- package/templates/init/platform/composition/context-selection.tsyringe.ts.tpl +17 -0
- package/templates/init/platform/composition/lay-foundations.manual.ts.tpl +16 -1
- package/templates/init/platform/composition/lay-foundations.tsyringe.ts.tpl +1 -1
- package/templates/init/platform/composition/platform-error-mapper.ts.tpl +9 -0
- package/templates/init/platform/composition/platform-options.manual.ts.tpl +9 -0
- package/templates/init/platform/composition/platform-test.module.tsyringe.ts.tpl +11 -0
- package/templates/init/platform/composition/platform.module.tsyringe.ts.tpl +5 -2
- package/templates/init/platform/composition/routes-of.tsyringe.ts.tpl +51 -0
- package/templates/init/platform/config/app-config.ts.tpl +9 -2
- package/templates/init/platform/config/load-config.ts.tpl +27 -2
- package/templates/init/platform/database/open-persistence.memory.ts.tpl +10 -0
- package/templates/init/platform/database/persistence-over.drizzle.ts.tpl +5 -0
- package/templates/init/platform/database/persistence-over.knex.ts.tpl +5 -0
- package/templates/init/platform/database/persistence-over.prisma.ts.tpl +5 -0
- package/templates/init/platform/database/persistence-over.typeorm.ts.tpl +5 -0
- package/templates/init/platform/database/persistence.contract.spec.ts.tpl +18 -0
- package/templates/init/platform/database/persistence.memory.ts.tpl +7 -1
- package/templates/init/platform/database/persistence.orm.ts.tpl +9 -1
- package/templates/init/platform/database/schema.drizzle.ts.tpl +11 -1
- package/templates/init/platform/database/schema.prisma.tpl +2 -1
- package/templates/init/platform/database/schema.typeorm.ts.tpl +1 -1
- package/templates/init/platform/event-sourcing/create-event-sourcing.ts.tpl +18 -6
- package/templates/init/platform/files/files.module.tsyringe.ts.tpl +6 -2
- package/templates/init/platform/http/start-http-server.express.ts.tpl +10 -1
- package/templates/init/platform/http/start-http-server.nest.ts.tpl +6 -1
- package/templates/init/platform/jobs/job-settings.ts.tpl +13 -3
- package/templates/init/platform/privacy/privacy.module.tsyringe.ts.tpl +9 -6
- package/templates/init/platform/redis/open-redis.ts.tpl +13 -8
- package/templates/init/rules/presentation.md.tpl +1 -1
- package/templates/integration-event/wiring.manual.tpl +1 -1
- package/templates/integration-handler/wiring.manual.tpl +1 -1
- package/templates/job/job.declared.ts.tpl +1 -1
- package/templates/job/job.spec.buses.ts.tpl +3 -0
- package/templates/job/job.spec.tsyringe.ts.tpl +29 -1
- package/templates/job/wiring.manual.tpl +4 -1
- package/templates/job/wiring.tsyringe.tpl +1 -1
- package/templates/nest-controller/controller.search.ts.tpl +38 -0
- package/templates/nest-controller/controller.ts.tpl +1 -17
- package/templates/nest-controller/upload.spec.ts.tpl +47 -0
- package/templates/nest-controller/upload.ts.tpl +25 -0
- package/templates/pipeline/biome.json.tpl +9 -2
- package/templates/pipeline/eslint.config.mjs.tpl +6 -0
- package/templates/pipeline/knip.json.tpl +1 -0
- package/templates/pipeline/package-scripts.json +2 -2
- package/templates/presets/identity/context/__context__.module.explicit.ts.tpl +17 -0
- package/templates/presets/identity/context/presentation/http/accounts/deactivate-account/deactivate-account.controller.nest-routes.ts.tpl +31 -0
- package/templates/presets/identity/context/presentation/http/accounts/provision-account/provision-account.controller.nest-routes.ts.tpl +44 -0
- package/templates/presets/identity/context/presentation/http/invitations/accept-invitation/accept-invitation.controller.nest-routes.ts.tpl +56 -0
- package/templates/presets/identity/context/presentation/http/invitations/decline-invitation/decline-invitation.controller.nest-routes.ts.tpl +54 -0
- package/templates/presets/identity/context/presentation/http/organisations/change-member-role/change-member-role.controller.nest-routes.ts.tpl +32 -0
- package/templates/presets/identity/context/presentation/http/organisations/grant-delegation/grant-delegation.controller.nest-routes.ts.tpl +43 -0
- package/templates/presets/identity/context/presentation/http/organisations/invite-member/invite-member.controller.nest-routes.ts.tpl +25 -0
- package/templates/presets/identity/context/presentation/http/organisations/open-organisation/open-organisation.controller.nest-routes.ts.tpl +37 -0
- package/templates/presets/identity/context/presentation/http/organisations/remove-member/remove-member.controller.nest-routes.ts.tpl +31 -0
- package/templates/presets/identity/context/presentation/http/organisations/revoke-delegation/revoke-delegation.controller.nest-routes.ts.tpl +31 -0
- package/templates/presets/identity/context/presentation/http/organisations/revoke-invitation/revoke-invitation.controller.nest-routes.ts.tpl +31 -0
- package/templates/presets/identity/context/presentation/http/organisations/search-members/search-members.controller.nest-routes.ts.tpl +42 -0
- package/templates/presets/identity/context/test/integration/organisation.repository.contract.spec.ts.tpl +1 -1
- package/templates/presets/identity/context/test/unit/__context__.module.spec.explicit.ts.tpl +13 -0
- package/templates/presets/identity/context/test/unit/accept-invitation.controller.spec.nest-routes.ts.tpl +70 -0
- package/templates/presets/identity/context/test/unit/change-member-role.controller.spec.nest-routes.ts.tpl +70 -0
- package/templates/presets/identity/context/test/unit/deactivate-account.controller.spec.nest-routes.ts.tpl +57 -0
- package/templates/presets/identity/context/test/unit/decline-invitation.controller.spec.nest-routes.ts.tpl +70 -0
- package/templates/presets/identity/context/test/unit/grant-delegation.controller.spec.nest-routes.ts.tpl +70 -0
- package/templates/presets/identity/context/test/unit/invite-member.controller.spec.nest-routes.ts.tpl +70 -0
- package/templates/presets/identity/context/test/unit/open-organisation.controller.spec.nest-routes.ts.tpl +70 -0
- package/templates/presets/identity/context/test/unit/provision-account.controller.spec.nest-routes.ts.tpl +99 -0
- package/templates/presets/identity/context/test/unit/remove-member.controller.spec.nest-routes.ts.tpl +57 -0
- package/templates/presets/identity/context/test/unit/revoke-delegation.controller.spec.nest-routes.ts.tpl +57 -0
- package/templates/presets/identity/context/test/unit/revoke-invitation.controller.spec.nest-routes.ts.tpl +57 -0
- package/templates/presets/identity/context/test/unit/search-members.controller.spec.nest-routes.ts.tpl +54 -0
- package/templates/process/timeout-job.wiring.manual.tpl +1 -1
- package/templates/query/search.wiring.manual.tpl +1 -1
- package/templates/query/wiring.manual.tpl +1 -1
- package/templates/repository/contract.spec.ts.tpl +1 -3
- package/templates/repository/event-sourced/contract.spec.ts.tpl +36 -0
- package/templates/repository/event-sourced/fake.ts.tpl +24 -0
- package/templates/repository/event-sourced/repository.ts.tpl +38 -0
- package/templates/repository/event-sourced-first-use.wiring.manual.tpl +4 -0
- package/templates/repository/event-sourced.wiring.tsyringe.tpl +6 -0
- package/templates/repository/first-use.wiring.manual.tpl +1 -1
- package/templates/service/compose.tpl +1 -1
- package/templates/service/extracted-name.tpl +2 -0
- package/templates/service/extracted.declared.tpl +6 -0
- package/templates/service/extracted.manual.tpl +2 -0
- package/templates/service/extracted.tsyringe.tpl +6 -0
- package/templates/service/main.ts.tpl +5 -1
- package/templates/worker/main.ts.tpl +20 -13
- /package/templates/presets/identity/context/presentation/http/accounts/deactivate-account/{deactivate-account.controller.ts.tpl → deactivate-account.controller.kit-routes.ts.tpl} +0 -0
- /package/templates/presets/identity/context/presentation/http/accounts/provision-account/{provision-account.controller.ts.tpl → provision-account.controller.kit-routes.ts.tpl} +0 -0
- /package/templates/presets/identity/context/presentation/http/invitations/accept-invitation/{accept-invitation.controller.ts.tpl → accept-invitation.controller.kit-routes.ts.tpl} +0 -0
- /package/templates/presets/identity/context/presentation/http/invitations/decline-invitation/{decline-invitation.controller.ts.tpl → decline-invitation.controller.kit-routes.ts.tpl} +0 -0
- /package/templates/presets/identity/context/presentation/http/organisations/change-member-role/{change-member-role.controller.ts.tpl → change-member-role.controller.kit-routes.ts.tpl} +0 -0
- /package/templates/presets/identity/context/presentation/http/organisations/grant-delegation/{grant-delegation.controller.ts.tpl → grant-delegation.controller.kit-routes.ts.tpl} +0 -0
- /package/templates/presets/identity/context/presentation/http/organisations/invite-member/{invite-member.controller.ts.tpl → invite-member.controller.kit-routes.ts.tpl} +0 -0
- /package/templates/presets/identity/context/presentation/http/organisations/open-organisation/{open-organisation.controller.ts.tpl → open-organisation.controller.kit-routes.ts.tpl} +0 -0
- /package/templates/presets/identity/context/presentation/http/organisations/remove-member/{remove-member.controller.ts.tpl → remove-member.controller.kit-routes.ts.tpl} +0 -0
- /package/templates/presets/identity/context/presentation/http/organisations/revoke-delegation/{revoke-delegation.controller.ts.tpl → revoke-delegation.controller.kit-routes.ts.tpl} +0 -0
- /package/templates/presets/identity/context/presentation/http/organisations/revoke-invitation/{revoke-invitation.controller.ts.tpl → revoke-invitation.controller.kit-routes.ts.tpl} +0 -0
- /package/templates/presets/identity/context/presentation/http/organisations/search-members/{search-members.controller.ts.tpl → search-members.controller.kit-routes.ts.tpl} +0 -0
- /package/templates/presets/identity/context/test/unit/{accept-invitation.controller.spec.ts.tpl → accept-invitation.controller.spec.kit-routes.ts.tpl} +0 -0
- /package/templates/presets/identity/context/test/unit/{change-member-role.controller.spec.ts.tpl → change-member-role.controller.spec.kit-routes.ts.tpl} +0 -0
- /package/templates/presets/identity/context/test/unit/{deactivate-account.controller.spec.ts.tpl → deactivate-account.controller.spec.kit-routes.ts.tpl} +0 -0
- /package/templates/presets/identity/context/test/unit/{decline-invitation.controller.spec.ts.tpl → decline-invitation.controller.spec.kit-routes.ts.tpl} +0 -0
- /package/templates/presets/identity/context/test/unit/{grant-delegation.controller.spec.ts.tpl → grant-delegation.controller.spec.kit-routes.ts.tpl} +0 -0
- /package/templates/presets/identity/context/test/unit/{invite-member.controller.spec.ts.tpl → invite-member.controller.spec.kit-routes.ts.tpl} +0 -0
- /package/templates/presets/identity/context/test/unit/{open-organisation.controller.spec.ts.tpl → open-organisation.controller.spec.kit-routes.ts.tpl} +0 -0
- /package/templates/presets/identity/context/test/unit/{provision-account.controller.spec.ts.tpl → provision-account.controller.spec.kit-routes.ts.tpl} +0 -0
- /package/templates/presets/identity/context/test/unit/{remove-member.controller.spec.ts.tpl → remove-member.controller.spec.kit-routes.ts.tpl} +0 -0
- /package/templates/presets/identity/context/test/unit/{revoke-delegation.controller.spec.ts.tpl → revoke-delegation.controller.spec.kit-routes.ts.tpl} +0 -0
- /package/templates/presets/identity/context/test/unit/{revoke-invitation.controller.spec.ts.tpl → revoke-invitation.controller.spec.kit-routes.ts.tpl} +0 -0
- /package/templates/presets/identity/context/test/unit/{search-members.controller.spec.ts.tpl → search-members.controller.spec.kit-routes.ts.tpl} +0 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { describe, expect, it } from '{{tests.module}}';
|
|
2
|
+
import { executeRoute } from '@ddd-ts-kit/http';
|
|
3
|
+
import { nestControllerRoute } from '@ddd-ts-kit/http/nest';
|
|
4
|
+
import { InMemoryCommandBus, type Actor } from '@ddd-ts-kit/kernel';
|
|
5
|
+
import { classSchema } from '@ddd-ts-kit/validation/class-validator';
|
|
6
|
+
import { AcceptInvitationCommand } from '{{alias.context}}/application/commands/accept-invitation/accept-invitation.command{{alias.ext}}';
|
|
7
|
+
import { AcceptInvitationController } from '{{alias.context}}/presentation/http/invitations/accept-invitation/accept-invitation.controller{{alias.ext}}';
|
|
8
|
+
import { {{context.camel}}Controllers } from '{{alias.context}}/{{context.kebab}}.controllers{{alias.ext}}';
|
|
9
|
+
|
|
10
|
+
/** Who calls, as the authenticator of the platform makes them from the token. */
|
|
11
|
+
const caller: Actor = {
|
|
12
|
+
id: 'subject-ada',
|
|
13
|
+
type: 'user',
|
|
14
|
+
roles: [],
|
|
15
|
+
attributes: { email: 'ada@example.test', username: 'ada' },
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
describe('POST /invitations/acceptance', () => {
|
|
19
|
+
it('answers 200 with what the use case answered, and sends it what the request says', async () => {
|
|
20
|
+
const { route, sent } = arrange();
|
|
21
|
+
|
|
22
|
+
const response = await executeRoute(
|
|
23
|
+
route,
|
|
24
|
+
{ params: {}, query: {}, headers: {}, body: { token: 'token-1' }, raw: undefined },
|
|
25
|
+
{ validateResponses: true, resolvePrincipal: () => caller },
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
expect(route.path).toBe('/invitations/acceptance');
|
|
29
|
+
expect([response.status, response.body]).toEqual([200, { id: 'invitation-1' }]);
|
|
30
|
+
expect(sent).toMatchObject([{ token: 'token-1' }]);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('refuses with 422 a request its contract does not describe, and sends nothing', async () => {
|
|
34
|
+
const { route, sent } = arrange();
|
|
35
|
+
|
|
36
|
+
const response = await executeRoute(
|
|
37
|
+
route,
|
|
38
|
+
{ params: {}, query: {}, headers: {}, body: {}, raw: undefined },
|
|
39
|
+
{ resolvePrincipal: () => caller },
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
expect(response.status).toBe(422);
|
|
43
|
+
expect(sent).toEqual([]);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('is listed in the Nest controllers of the context, which say what its signature takes and answers', () => {
|
|
47
|
+
expect({{context.camel}}Controllers).toContain(AcceptInvitationController);
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
/** The route, on a bus that keeps what it was sent and answers as the use case would. */
|
|
52
|
+
function arrange() {
|
|
53
|
+
const sent: AcceptInvitationCommand[] = [];
|
|
54
|
+
|
|
55
|
+
const commands = new InMemoryCommandBus().register(AcceptInvitationCommand, {
|
|
56
|
+
execute: async (command) => {
|
|
57
|
+
sent.push(command);
|
|
58
|
+
|
|
59
|
+
return 'invitation-1';
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
const route = nestControllerRoute(AcceptInvitationController, {
|
|
64
|
+
instanceOf: () => new AcceptInvitationController(commands),
|
|
65
|
+
// A DTO without a decorated field accepts the empty object alone: whitelist and forbidNonWhitelisted refuse any field.
|
|
66
|
+
schemaOfClass: (dto) => classSchema(dto, { validator: { forbidUnknownValues: false } }),
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
return { route, sent };
|
|
70
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { describe, expect, it } from '{{tests.module}}';
|
|
2
|
+
import { executeRoute } from '@ddd-ts-kit/http';
|
|
3
|
+
import { nestControllerRoute } from '@ddd-ts-kit/http/nest';
|
|
4
|
+
import { InMemoryCommandBus, type Actor } from '@ddd-ts-kit/kernel';
|
|
5
|
+
import { classSchema } from '@ddd-ts-kit/validation/class-validator';
|
|
6
|
+
import { ChangeMemberRoleCommand } from '{{alias.context}}/application/commands/change-member-role/change-member-role.command{{alias.ext}}';
|
|
7
|
+
import { ChangeMemberRoleController } from '{{alias.context}}/presentation/http/organisations/change-member-role/change-member-role.controller{{alias.ext}}';
|
|
8
|
+
import { {{context.camel}}Controllers } from '{{alias.context}}/{{context.kebab}}.controllers{{alias.ext}}';
|
|
9
|
+
|
|
10
|
+
/** Who calls, as the authenticator of the platform makes them from the token. */
|
|
11
|
+
const caller: Actor = {
|
|
12
|
+
id: 'subject-ada',
|
|
13
|
+
type: 'user',
|
|
14
|
+
roles: [],
|
|
15
|
+
attributes: { email: 'ada@example.test', username: 'ada' },
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
describe('PUT /organisations/:organisationId/members/:accountId/role', () => {
|
|
19
|
+
it('answers 200 with what the use case answered, and sends it what the request says', async () => {
|
|
20
|
+
const { route, sent } = arrange();
|
|
21
|
+
|
|
22
|
+
const response = await executeRoute(
|
|
23
|
+
route,
|
|
24
|
+
{ params: { organisationId: 'acme', accountId: 'subject-grace' }, query: {}, headers: {}, body: { role: 'member' }, raw: undefined },
|
|
25
|
+
{ validateResponses: true, resolvePrincipal: () => caller },
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
expect(route.path).toBe('/organisations/:organisationId/members/:accountId/role');
|
|
29
|
+
expect([response.status, response.body]).toEqual([200, { id: 'member-1' }]);
|
|
30
|
+
expect(sent).toMatchObject([{ organisationId: 'acme', accountId: 'subject-grace', role: 'member' }]);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('refuses with 422 a request its contract does not describe, and sends nothing', async () => {
|
|
34
|
+
const { route, sent } = arrange();
|
|
35
|
+
|
|
36
|
+
const response = await executeRoute(
|
|
37
|
+
route,
|
|
38
|
+
{ params: { organisationId: 'acme', accountId: 'subject-grace' }, query: {}, headers: {}, body: { role: 'emperor' }, raw: undefined },
|
|
39
|
+
{ resolvePrincipal: () => caller },
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
expect(response.status).toBe(422);
|
|
43
|
+
expect(sent).toEqual([]);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('is listed in the Nest controllers of the context, which say what its signature takes and answers', () => {
|
|
47
|
+
expect({{context.camel}}Controllers).toContain(ChangeMemberRoleController);
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
/** The route, on a bus that keeps what it was sent and answers as the use case would. */
|
|
52
|
+
function arrange() {
|
|
53
|
+
const sent: ChangeMemberRoleCommand[] = [];
|
|
54
|
+
|
|
55
|
+
const commands = new InMemoryCommandBus().register(ChangeMemberRoleCommand, {
|
|
56
|
+
execute: async (command) => {
|
|
57
|
+
sent.push(command);
|
|
58
|
+
|
|
59
|
+
return 'member-1';
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
const route = nestControllerRoute(ChangeMemberRoleController, {
|
|
64
|
+
instanceOf: () => new ChangeMemberRoleController(commands),
|
|
65
|
+
// A DTO without a decorated field accepts the empty object alone: whitelist and forbidNonWhitelisted refuse any field.
|
|
66
|
+
schemaOfClass: (dto) => classSchema(dto, { validator: { forbidUnknownValues: false } }),
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
return { route, sent };
|
|
70
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { describe, expect, it } from '{{tests.module}}';
|
|
2
|
+
import { executeRoute } from '@ddd-ts-kit/http';
|
|
3
|
+
import { nestControllerRoute } from '@ddd-ts-kit/http/nest';
|
|
4
|
+
import { InMemoryCommandBus, type Actor } from '@ddd-ts-kit/kernel';
|
|
5
|
+
import { classSchema } from '@ddd-ts-kit/validation/class-validator';
|
|
6
|
+
import { DeactivateAccountCommand } from '{{alias.context}}/application/commands/deactivate-account/deactivate-account.command{{alias.ext}}';
|
|
7
|
+
import { DeactivateAccountController } from '{{alias.context}}/presentation/http/accounts/deactivate-account/deactivate-account.controller{{alias.ext}}';
|
|
8
|
+
import { {{context.camel}}Controllers } from '{{alias.context}}/{{context.kebab}}.controllers{{alias.ext}}';
|
|
9
|
+
|
|
10
|
+
/** Who calls, as the authenticator of the platform makes them from the token. */
|
|
11
|
+
const caller: Actor = {
|
|
12
|
+
id: 'subject-ada',
|
|
13
|
+
type: 'user',
|
|
14
|
+
roles: [],
|
|
15
|
+
attributes: { email: 'ada@example.test', username: 'ada' },
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
describe('POST /accounts/me/deactivation', () => {
|
|
19
|
+
it('answers 200 with what the use case answered, and sends it what the request says', async () => {
|
|
20
|
+
const { route, sent } = arrange();
|
|
21
|
+
|
|
22
|
+
const response = await executeRoute(
|
|
23
|
+
route,
|
|
24
|
+
{ params: {}, query: {}, headers: {}, body: {}, raw: undefined },
|
|
25
|
+
{ validateResponses: true, resolvePrincipal: () => caller },
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
expect(route.path).toBe('/accounts/me/deactivation');
|
|
29
|
+
expect([response.status, response.body]).toEqual([200, { id: 'subject-ada' }]);
|
|
30
|
+
expect(sent).toMatchObject([{ actor: { id: 'subject-ada' } }]);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('is listed in the Nest controllers of the context, which say what its signature takes and answers', () => {
|
|
34
|
+
expect({{context.camel}}Controllers).toContain(DeactivateAccountController);
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
/** The route, on a bus that keeps what it was sent and answers as the use case would. */
|
|
39
|
+
function arrange() {
|
|
40
|
+
const sent: DeactivateAccountCommand[] = [];
|
|
41
|
+
|
|
42
|
+
const commands = new InMemoryCommandBus().register(DeactivateAccountCommand, {
|
|
43
|
+
execute: async (command) => {
|
|
44
|
+
sent.push(command);
|
|
45
|
+
|
|
46
|
+
return 'subject-ada';
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
const route = nestControllerRoute(DeactivateAccountController, {
|
|
51
|
+
instanceOf: () => new DeactivateAccountController(commands),
|
|
52
|
+
// A DTO without a decorated field accepts the empty object alone: whitelist and forbidNonWhitelisted refuse any field.
|
|
53
|
+
schemaOfClass: (dto) => classSchema(dto, { validator: { forbidUnknownValues: false } }),
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
return { route, sent };
|
|
57
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { describe, expect, it } from '{{tests.module}}';
|
|
2
|
+
import { executeRoute } from '@ddd-ts-kit/http';
|
|
3
|
+
import { nestControllerRoute } from '@ddd-ts-kit/http/nest';
|
|
4
|
+
import { InMemoryCommandBus, type Actor } from '@ddd-ts-kit/kernel';
|
|
5
|
+
import { classSchema } from '@ddd-ts-kit/validation/class-validator';
|
|
6
|
+
import { DeclineInvitationCommand } from '{{alias.context}}/application/commands/decline-invitation/decline-invitation.command{{alias.ext}}';
|
|
7
|
+
import { DeclineInvitationController } from '{{alias.context}}/presentation/http/invitations/decline-invitation/decline-invitation.controller{{alias.ext}}';
|
|
8
|
+
import { {{context.camel}}Controllers } from '{{alias.context}}/{{context.kebab}}.controllers{{alias.ext}}';
|
|
9
|
+
|
|
10
|
+
/** Who calls, as the authenticator of the platform makes them from the token. */
|
|
11
|
+
const caller: Actor = {
|
|
12
|
+
id: 'subject-ada',
|
|
13
|
+
type: 'user',
|
|
14
|
+
roles: [],
|
|
15
|
+
attributes: { email: 'ada@example.test', username: 'ada' },
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
describe('POST /invitations/declination', () => {
|
|
19
|
+
it('answers 200 with what the use case answered, and sends it what the request says', async () => {
|
|
20
|
+
const { route, sent } = arrange();
|
|
21
|
+
|
|
22
|
+
const response = await executeRoute(
|
|
23
|
+
route,
|
|
24
|
+
{ params: {}, query: {}, headers: {}, body: { token: 'token-1' }, raw: undefined },
|
|
25
|
+
{ validateResponses: true, resolvePrincipal: () => caller },
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
expect(route.path).toBe('/invitations/declination');
|
|
29
|
+
expect([response.status, response.body]).toEqual([200, { id: 'invitation-1' }]);
|
|
30
|
+
expect(sent).toMatchObject([{ token: 'token-1' }]);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('refuses with 422 a request its contract does not describe, and sends nothing', async () => {
|
|
34
|
+
const { route, sent } = arrange();
|
|
35
|
+
|
|
36
|
+
const response = await executeRoute(
|
|
37
|
+
route,
|
|
38
|
+
{ params: {}, query: {}, headers: {}, body: {}, raw: undefined },
|
|
39
|
+
{ resolvePrincipal: () => caller },
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
expect(response.status).toBe(422);
|
|
43
|
+
expect(sent).toEqual([]);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('is listed in the Nest controllers of the context, which say what its signature takes and answers', () => {
|
|
47
|
+
expect({{context.camel}}Controllers).toContain(DeclineInvitationController);
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
/** The route, on a bus that keeps what it was sent and answers as the use case would. */
|
|
52
|
+
function arrange() {
|
|
53
|
+
const sent: DeclineInvitationCommand[] = [];
|
|
54
|
+
|
|
55
|
+
const commands = new InMemoryCommandBus().register(DeclineInvitationCommand, {
|
|
56
|
+
execute: async (command) => {
|
|
57
|
+
sent.push(command);
|
|
58
|
+
|
|
59
|
+
return 'invitation-1';
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
const route = nestControllerRoute(DeclineInvitationController, {
|
|
64
|
+
instanceOf: () => new DeclineInvitationController(commands),
|
|
65
|
+
// A DTO without a decorated field accepts the empty object alone: whitelist and forbidNonWhitelisted refuse any field.
|
|
66
|
+
schemaOfClass: (dto) => classSchema(dto, { validator: { forbidUnknownValues: false } }),
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
return { route, sent };
|
|
70
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { describe, expect, it } from '{{tests.module}}';
|
|
2
|
+
import { executeRoute } from '@ddd-ts-kit/http';
|
|
3
|
+
import { nestControllerRoute } from '@ddd-ts-kit/http/nest';
|
|
4
|
+
import { InMemoryCommandBus, type Actor } from '@ddd-ts-kit/kernel';
|
|
5
|
+
import { classSchema } from '@ddd-ts-kit/validation/class-validator';
|
|
6
|
+
import { GrantDelegationCommand } from '{{alias.context}}/application/commands/grant-delegation/grant-delegation.command{{alias.ext}}';
|
|
7
|
+
import { GrantDelegationController } from '{{alias.context}}/presentation/http/organisations/grant-delegation/grant-delegation.controller{{alias.ext}}';
|
|
8
|
+
import { {{context.camel}}Controllers } from '{{alias.context}}/{{context.kebab}}.controllers{{alias.ext}}';
|
|
9
|
+
|
|
10
|
+
/** Who calls, as the authenticator of the platform makes them from the token. */
|
|
11
|
+
const caller: Actor = {
|
|
12
|
+
id: 'subject-ada',
|
|
13
|
+
type: 'user',
|
|
14
|
+
roles: [],
|
|
15
|
+
attributes: { email: 'ada@example.test', username: 'ada' },
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
describe('POST /organisations/:organisationId/delegations', () => {
|
|
19
|
+
it('answers 201 with what the use case answered, and sends it what the request says', async () => {
|
|
20
|
+
const { route, sent } = arrange();
|
|
21
|
+
|
|
22
|
+
const response = await executeRoute(
|
|
23
|
+
route,
|
|
24
|
+
{ params: { organisationId: 'acme' }, query: {}, headers: {}, body: { delegateId: 'subject-grace', rights: ['invite-members'], startsAt: '2026-01-01T00:00:00.000Z', endsAt: '2026-01-15T00:00:00.000Z' }, raw: undefined },
|
|
25
|
+
{ validateResponses: true, resolvePrincipal: () => caller },
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
expect(route.path).toBe('/organisations/:organisationId/delegations');
|
|
29
|
+
expect([response.status, response.body]).toEqual([201, { id: 'delegation-1' }]);
|
|
30
|
+
expect(sent).toMatchObject([{ organisationId: 'acme', terms: { delegateId: 'subject-grace', rights: ['invite-members'], startsAt: new Date('2026-01-01T00:00:00.000Z'), endsAt: new Date('2026-01-15T00:00:00.000Z') } }]);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('refuses with 422 a request its contract does not describe, and sends nothing', async () => {
|
|
34
|
+
const { route, sent } = arrange();
|
|
35
|
+
|
|
36
|
+
const response = await executeRoute(
|
|
37
|
+
route,
|
|
38
|
+
{ params: { organisationId: 'acme' }, query: {}, headers: {}, body: { delegateId: 'subject-grace', rights: ['rule-the-world'], startsAt: '2026-01-01T00:00:00.000Z', endsAt: '2026-01-15T00:00:00.000Z' }, raw: undefined },
|
|
39
|
+
{ resolvePrincipal: () => caller },
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
expect(response.status).toBe(422);
|
|
43
|
+
expect(sent).toEqual([]);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('is listed in the Nest controllers of the context, which say what its signature takes and answers', () => {
|
|
47
|
+
expect({{context.camel}}Controllers).toContain(GrantDelegationController);
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
/** The route, on a bus that keeps what it was sent and answers as the use case would. */
|
|
52
|
+
function arrange() {
|
|
53
|
+
const sent: GrantDelegationCommand[] = [];
|
|
54
|
+
|
|
55
|
+
const commands = new InMemoryCommandBus().register(GrantDelegationCommand, {
|
|
56
|
+
execute: async (command) => {
|
|
57
|
+
sent.push(command);
|
|
58
|
+
|
|
59
|
+
return 'delegation-1';
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
const route = nestControllerRoute(GrantDelegationController, {
|
|
64
|
+
instanceOf: () => new GrantDelegationController(commands),
|
|
65
|
+
// A DTO without a decorated field accepts the empty object alone: whitelist and forbidNonWhitelisted refuse any field.
|
|
66
|
+
schemaOfClass: (dto) => classSchema(dto, { validator: { forbidUnknownValues: false } }),
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
return { route, sent };
|
|
70
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { describe, expect, it } from '{{tests.module}}';
|
|
2
|
+
import { executeRoute } from '@ddd-ts-kit/http';
|
|
3
|
+
import { nestControllerRoute } from '@ddd-ts-kit/http/nest';
|
|
4
|
+
import { InMemoryCommandBus, type Actor } from '@ddd-ts-kit/kernel';
|
|
5
|
+
import { classSchema } from '@ddd-ts-kit/validation/class-validator';
|
|
6
|
+
import { InviteMemberCommand } from '{{alias.context}}/application/commands/invite-member/invite-member.command{{alias.ext}}';
|
|
7
|
+
import { InviteMemberController } from '{{alias.context}}/presentation/http/organisations/invite-member/invite-member.controller{{alias.ext}}';
|
|
8
|
+
import { {{context.camel}}Controllers } from '{{alias.context}}/{{context.kebab}}.controllers{{alias.ext}}';
|
|
9
|
+
|
|
10
|
+
/** Who calls, as the authenticator of the platform makes them from the token. */
|
|
11
|
+
const caller: Actor = {
|
|
12
|
+
id: 'subject-ada',
|
|
13
|
+
type: 'user',
|
|
14
|
+
roles: [],
|
|
15
|
+
attributes: { email: 'ada@example.test', username: 'ada' },
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
describe('POST /organisations/:organisationId/invitations', () => {
|
|
19
|
+
it('answers 201 with what the use case answered, and sends it what the request says', async () => {
|
|
20
|
+
const { route, sent } = arrange();
|
|
21
|
+
|
|
22
|
+
const response = await executeRoute(
|
|
23
|
+
route,
|
|
24
|
+
{ params: { organisationId: 'acme' }, query: {}, headers: {}, body: { email: 'grace@example.test', role: 'admin' }, raw: undefined },
|
|
25
|
+
{ validateResponses: true, resolvePrincipal: () => caller },
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
expect(route.path).toBe('/organisations/:organisationId/invitations');
|
|
29
|
+
expect([response.status, response.body]).toEqual([201, { id: 'invitation-1', token: 'token-1' }]);
|
|
30
|
+
expect(sent).toMatchObject([{ organisationId: 'acme', invitee: { email: 'grace@example.test', role: 'admin' } }]);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('refuses with 422 a request its contract does not describe, and sends nothing', async () => {
|
|
34
|
+
const { route, sent } = arrange();
|
|
35
|
+
|
|
36
|
+
const response = await executeRoute(
|
|
37
|
+
route,
|
|
38
|
+
{ params: { organisationId: 'acme' }, query: {}, headers: {}, body: { email: 'grace@example.test', role: 'king' }, raw: undefined },
|
|
39
|
+
{ resolvePrincipal: () => caller },
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
expect(response.status).toBe(422);
|
|
43
|
+
expect(sent).toEqual([]);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('is listed in the Nest controllers of the context, which say what its signature takes and answers', () => {
|
|
47
|
+
expect({{context.camel}}Controllers).toContain(InviteMemberController);
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
/** The route, on a bus that keeps what it was sent and answers as the use case would. */
|
|
52
|
+
function arrange() {
|
|
53
|
+
const sent: InviteMemberCommand[] = [];
|
|
54
|
+
|
|
55
|
+
const commands = new InMemoryCommandBus().register(InviteMemberCommand, {
|
|
56
|
+
execute: async (command) => {
|
|
57
|
+
sent.push(command);
|
|
58
|
+
|
|
59
|
+
return { id: 'invitation-1', token: 'token-1' };
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
const route = nestControllerRoute(InviteMemberController, {
|
|
64
|
+
instanceOf: () => new InviteMemberController(commands),
|
|
65
|
+
// A DTO without a decorated field accepts the empty object alone: whitelist and forbidNonWhitelisted refuse any field.
|
|
66
|
+
schemaOfClass: (dto) => classSchema(dto, { validator: { forbidUnknownValues: false } }),
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
return { route, sent };
|
|
70
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { describe, expect, it } from '{{tests.module}}';
|
|
2
|
+
import { executeRoute } from '@ddd-ts-kit/http';
|
|
3
|
+
import { nestControllerRoute } from '@ddd-ts-kit/http/nest';
|
|
4
|
+
import { InMemoryCommandBus, type Actor } from '@ddd-ts-kit/kernel';
|
|
5
|
+
import { classSchema } from '@ddd-ts-kit/validation/class-validator';
|
|
6
|
+
import { OpenOrganisationCommand } from '{{alias.context}}/application/commands/open-organisation/open-organisation.command{{alias.ext}}';
|
|
7
|
+
import { OpenOrganisationController } from '{{alias.context}}/presentation/http/organisations/open-organisation/open-organisation.controller{{alias.ext}}';
|
|
8
|
+
import { {{context.camel}}Controllers } from '{{alias.context}}/{{context.kebab}}.controllers{{alias.ext}}';
|
|
9
|
+
|
|
10
|
+
/** Who calls, as the authenticator of the platform makes them from the token. */
|
|
11
|
+
const caller: Actor = {
|
|
12
|
+
id: 'subject-ada',
|
|
13
|
+
type: 'user',
|
|
14
|
+
roles: [],
|
|
15
|
+
attributes: { email: 'ada@example.test', username: 'ada' },
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
describe('POST /organisations', () => {
|
|
19
|
+
it('answers 201 with what the use case answered, and sends it what the request says', async () => {
|
|
20
|
+
const { route, sent } = arrange();
|
|
21
|
+
|
|
22
|
+
const response = await executeRoute(
|
|
23
|
+
route,
|
|
24
|
+
{ params: {}, query: {}, headers: {}, body: { slug: 'acme', name: 'Acme' }, raw: undefined },
|
|
25
|
+
{ validateResponses: true, resolvePrincipal: () => caller },
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
expect(route.path).toBe('/organisations');
|
|
29
|
+
expect([response.status, response.body]).toEqual([201, { id: 'acme' }]);
|
|
30
|
+
expect(sent).toMatchObject([{ organisation: { slug: 'acme', name: 'Acme' } }]);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('refuses with 422 a request its contract does not describe, and sends nothing', async () => {
|
|
34
|
+
const { route, sent } = arrange();
|
|
35
|
+
|
|
36
|
+
const response = await executeRoute(
|
|
37
|
+
route,
|
|
38
|
+
{ params: {}, query: {}, headers: {}, body: { slug: 'acme' }, raw: undefined },
|
|
39
|
+
{ resolvePrincipal: () => caller },
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
expect(response.status).toBe(422);
|
|
43
|
+
expect(sent).toEqual([]);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('is listed in the Nest controllers of the context, which say what its signature takes and answers', () => {
|
|
47
|
+
expect({{context.camel}}Controllers).toContain(OpenOrganisationController);
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
/** The route, on a bus that keeps what it was sent and answers as the use case would. */
|
|
52
|
+
function arrange() {
|
|
53
|
+
const sent: OpenOrganisationCommand[] = [];
|
|
54
|
+
|
|
55
|
+
const commands = new InMemoryCommandBus().register(OpenOrganisationCommand, {
|
|
56
|
+
execute: async (command) => {
|
|
57
|
+
sent.push(command);
|
|
58
|
+
|
|
59
|
+
return 'acme';
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
const route = nestControllerRoute(OpenOrganisationController, {
|
|
64
|
+
instanceOf: () => new OpenOrganisationController(commands),
|
|
65
|
+
// A DTO without a decorated field accepts the empty object alone: whitelist and forbidNonWhitelisted refuse any field.
|
|
66
|
+
schemaOfClass: (dto) => classSchema(dto, { validator: { forbidUnknownValues: false } }),
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
return { route, sent };
|
|
70
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { describe, expect, it } from '{{tests.module}}';
|
|
2
|
+
import { executeRoute } from '@ddd-ts-kit/http';
|
|
3
|
+
import { nestControllerRoute } from '@ddd-ts-kit/http/nest';
|
|
4
|
+
import { InMemoryCommandBus, type Actor } from '@ddd-ts-kit/kernel';
|
|
5
|
+
import { classSchema } from '@ddd-ts-kit/validation/class-validator';
|
|
6
|
+
import { ProvisionAccountCommand } from '{{alias.context}}/application/commands/provision-account/provision-account.command{{alias.ext}}';
|
|
7
|
+
import { ProvisionAccountController } from '{{alias.context}}/presentation/http/accounts/provision-account/provision-account.controller{{alias.ext}}';
|
|
8
|
+
import { {{context.camel}}Controllers } from '{{alias.context}}/{{context.kebab}}.controllers{{alias.ext}}';
|
|
9
|
+
|
|
10
|
+
/** Who calls, as the authenticator of the platform makes them from the token. */
|
|
11
|
+
const caller: Actor = {
|
|
12
|
+
id: 'subject-ada',
|
|
13
|
+
type: 'user',
|
|
14
|
+
roles: [],
|
|
15
|
+
attributes: { email: 'ada@example.test', emailVerified: true, username: 'ada' },
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
describe('PUT /accounts/me', () => {
|
|
19
|
+
it('answers 200 with what the use case answered, and sends it what the request says', async () => {
|
|
20
|
+
const { route, sent } = arrange();
|
|
21
|
+
|
|
22
|
+
const response = await executeRoute(
|
|
23
|
+
route,
|
|
24
|
+
{ params: {}, query: {}, headers: {}, body: { displayName: 'Ada L.' }, raw: undefined },
|
|
25
|
+
{ validateResponses: true, resolvePrincipal: () => caller },
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
expect(route.path).toBe('/accounts/me');
|
|
29
|
+
expect([response.status, response.body]).toEqual([200, { id: 'subject-ada' }]);
|
|
30
|
+
|
|
31
|
+
expect(sent).toMatchObject([
|
|
32
|
+
{ actor: { id: 'subject-ada' }, profile: { email: 'ada@example.test', emailVerified: true, displayName: 'Ada L.' } },
|
|
33
|
+
]);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('says the address is not verified unless the token says it is', async () => {
|
|
37
|
+
const { route, sent } = arrange();
|
|
38
|
+
const unverified: Actor = { ...caller, attributes: { email: 'ada@example.test' } };
|
|
39
|
+
|
|
40
|
+
await executeRoute(
|
|
41
|
+
route,
|
|
42
|
+
{ params: {}, query: {}, headers: {}, body: {}, raw: undefined },
|
|
43
|
+
{ resolvePrincipal: () => unverified },
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
expect(sent).toMatchObject([{ profile: { email: 'ada@example.test', emailVerified: false, displayName: 'ada@example.test' } }]);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('names the person after their username when the body names nothing, and sends no address the token lacks', async () => {
|
|
50
|
+
const { route, sent } = arrange();
|
|
51
|
+
const withoutAddress: Actor = { ...caller, attributes: { username: 'ada' } };
|
|
52
|
+
|
|
53
|
+
await executeRoute(
|
|
54
|
+
route,
|
|
55
|
+
{ params: {}, query: {}, headers: {}, body: {}, raw: undefined },
|
|
56
|
+
{ resolvePrincipal: () => withoutAddress },
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
expect(sent).toMatchObject([{ profile: { email: '', emailVerified: false, displayName: 'ada' } }]);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('refuses with 422 a request its contract does not describe, and sends nothing', async () => {
|
|
63
|
+
const { route, sent } = arrange();
|
|
64
|
+
|
|
65
|
+
const response = await executeRoute(
|
|
66
|
+
route,
|
|
67
|
+
{ params: {}, query: {}, headers: {}, body: { displayName: '' }, raw: undefined },
|
|
68
|
+
{ resolvePrincipal: () => caller },
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
expect(response.status).toBe(422);
|
|
72
|
+
expect(sent).toEqual([]);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it('is listed in the Nest controllers of the context, which say what its signature takes and answers', () => {
|
|
76
|
+
expect({{context.camel}}Controllers).toContain(ProvisionAccountController);
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
/** The route, on a bus that keeps what it was sent and answers as the use case would. */
|
|
81
|
+
function arrange() {
|
|
82
|
+
const sent: ProvisionAccountCommand[] = [];
|
|
83
|
+
|
|
84
|
+
const commands = new InMemoryCommandBus().register(ProvisionAccountCommand, {
|
|
85
|
+
execute: async (command) => {
|
|
86
|
+
sent.push(command);
|
|
87
|
+
|
|
88
|
+
return 'subject-ada';
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
const route = nestControllerRoute(ProvisionAccountController, {
|
|
93
|
+
instanceOf: () => new ProvisionAccountController(commands),
|
|
94
|
+
// A DTO without a decorated field accepts the empty object alone: whitelist and forbidNonWhitelisted refuse any field.
|
|
95
|
+
schemaOfClass: (dto) => classSchema(dto, { validator: { forbidUnknownValues: false } }),
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
return { route, sent };
|
|
99
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { describe, expect, it } from '{{tests.module}}';
|
|
2
|
+
import { executeRoute } from '@ddd-ts-kit/http';
|
|
3
|
+
import { nestControllerRoute } from '@ddd-ts-kit/http/nest';
|
|
4
|
+
import { InMemoryCommandBus, type Actor } from '@ddd-ts-kit/kernel';
|
|
5
|
+
import { classSchema } from '@ddd-ts-kit/validation/class-validator';
|
|
6
|
+
import { RemoveMemberCommand } from '{{alias.context}}/application/commands/remove-member/remove-member.command{{alias.ext}}';
|
|
7
|
+
import { RemoveMemberController } from '{{alias.context}}/presentation/http/organisations/remove-member/remove-member.controller{{alias.ext}}';
|
|
8
|
+
import { {{context.camel}}Controllers } from '{{alias.context}}/{{context.kebab}}.controllers{{alias.ext}}';
|
|
9
|
+
|
|
10
|
+
/** Who calls, as the authenticator of the platform makes them from the token. */
|
|
11
|
+
const caller: Actor = {
|
|
12
|
+
id: 'subject-ada',
|
|
13
|
+
type: 'user',
|
|
14
|
+
roles: [],
|
|
15
|
+
attributes: { email: 'ada@example.test', username: 'ada' },
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
describe('DELETE /organisations/:organisationId/members/:accountId', () => {
|
|
19
|
+
it('answers 200 with what the use case answered, and sends it what the request says', async () => {
|
|
20
|
+
const { route, sent } = arrange();
|
|
21
|
+
|
|
22
|
+
const response = await executeRoute(
|
|
23
|
+
route,
|
|
24
|
+
{ params: { organisationId: 'acme', accountId: 'subject-grace' }, query: {}, headers: {}, body: {}, raw: undefined },
|
|
25
|
+
{ validateResponses: true, resolvePrincipal: () => caller },
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
expect(route.path).toBe('/organisations/:organisationId/members/:accountId');
|
|
29
|
+
expect([response.status, response.body]).toEqual([200, { id: 'member-1' }]);
|
|
30
|
+
expect(sent).toMatchObject([{ organisationId: 'acme', accountId: 'subject-grace' }]);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('is listed in the Nest controllers of the context, which say what its signature takes and answers', () => {
|
|
34
|
+
expect({{context.camel}}Controllers).toContain(RemoveMemberController);
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
/** The route, on a bus that keeps what it was sent and answers as the use case would. */
|
|
39
|
+
function arrange() {
|
|
40
|
+
const sent: RemoveMemberCommand[] = [];
|
|
41
|
+
|
|
42
|
+
const commands = new InMemoryCommandBus().register(RemoveMemberCommand, {
|
|
43
|
+
execute: async (command) => {
|
|
44
|
+
sent.push(command);
|
|
45
|
+
|
|
46
|
+
return 'member-1';
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
const route = nestControllerRoute(RemoveMemberController, {
|
|
51
|
+
instanceOf: () => new RemoveMemberController(commands),
|
|
52
|
+
// A DTO without a decorated field accepts the empty object alone: whitelist and forbidNonWhitelisted refuse any field.
|
|
53
|
+
schemaOfClass: (dto) => classSchema(dto, { validator: { forbidUnknownValues: false } }),
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
return { route, sent };
|
|
57
|
+
}
|