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
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import type { UseCaseDeclaration } from '@ddd-ts-kit/auth';
|
|
2
|
+
{{#if routes.nest}}
|
|
3
|
+
import type { Type } from '@nestjs/common';
|
|
4
|
+
import { {{context.camel}}Controllers } from '{{alias.context}}/{{context.kebab}}.controllers{{alias.ext}}';
|
|
5
|
+
{{/if}}
|
|
2
6
|
import type { Route } from '@ddd-ts-kit/http';
|
|
3
7
|
import type { Actored, DomainEvent, Message } from '@ddd-ts-kit/kernel';
|
|
4
8
|
import type { Platform } from '{{alias.platform}}/composition/platform{{alias.ext}}';
|
|
5
9
|
// ddd-ts-kit:imports
|
|
6
10
|
import { requires, type RequirementOptions } from '@ddd-ts-kit/auth';
|
|
7
11
|
import { on, subscribeAll } from '@ddd-ts-kit/events';
|
|
12
|
+
{{#unless routes.nest}}
|
|
8
13
|
import { controllerRoutes } from '@ddd-ts-kit/http';
|
|
14
|
+
{{/unless}}
|
|
9
15
|
import { {{context.camel}}Permissions } from '{{alias.context}}/{{context.kebab}}.permissions{{alias.ext}}';
|
|
10
16
|
import { {{preset.adapter.pascal}}AccountRepository } from '{{alias.context}}/infrastructure/persistence/{{preset.adapter.kebab}}-account.repository{{alias.ext}}';
|
|
11
17
|
import { {{preset.adapter.pascal}}OrganisationRepository } from '{{alias.context}}/infrastructure/persistence/{{preset.adapter.kebab}}-organisation.repository{{alias.ext}}';
|
|
@@ -48,6 +54,7 @@ import { MemberRemovedIntegrationHandler } from '{{alias.context}}/application/i
|
|
|
48
54
|
import { memberRemovedV1 } from '{{alias.context}}/published-language/member-removed.v1.integration-event{{alias.ext}}';
|
|
49
55
|
import { OrganisationOpenedIntegrationHandler } from '{{alias.context}}/application/integration/handlers/organisation-opened.integration-handler{{alias.ext}}';
|
|
50
56
|
import { organisationOpenedV1 } from '{{alias.context}}/published-language/organisation-opened.v1.integration-event{{alias.ext}}';
|
|
57
|
+
{{#unless routes.nest}}
|
|
51
58
|
import { DeactivateAccountController } from '{{alias.context}}/presentation/http/accounts/deactivate-account/deactivate-account.controller{{alias.ext}}';
|
|
52
59
|
import { ProvisionAccountController } from '{{alias.context}}/presentation/http/accounts/provision-account/provision-account.controller{{alias.ext}}';
|
|
53
60
|
import { AcceptInvitationController } from '{{alias.context}}/presentation/http/invitations/accept-invitation/accept-invitation.controller{{alias.ext}}';
|
|
@@ -60,6 +67,7 @@ import { RemoveMemberController } from '{{alias.context}}/presentation/http/orga
|
|
|
60
67
|
import { RevokeDelegationController } from '{{alias.context}}/presentation/http/organisations/revoke-delegation/revoke-delegation.controller{{alias.ext}}';
|
|
61
68
|
import { RevokeInvitationController } from '{{alias.context}}/presentation/http/organisations/revoke-invitation/revoke-invitation.controller{{alias.ext}}';
|
|
62
69
|
import { SearchMembersController } from '{{alias.context}}/presentation/http/organisations/search-members/search-members.controller{{alias.ext}}';
|
|
70
|
+
{{/unless}}
|
|
63
71
|
import { AccountDeactivatedPublisher } from '{{alias.context}}/application/integration/publishers/account-deactivated.publisher{{alias.ext}}';
|
|
64
72
|
import { AccountDeactivated } from '{{alias.context}}/domain/events/account-deactivated.event{{alias.ext}}';
|
|
65
73
|
import { OrganisationOpenedPublisher } from '{{alias.context}}/application/integration/publishers/organisation-opened.publisher{{alias.ext}}';
|
|
@@ -80,6 +88,10 @@ export interface {{context.pascal}}Wiring {
|
|
|
80
88
|
readonly name: string;
|
|
81
89
|
readonly useCases: readonly UseCaseDeclaration[];
|
|
82
90
|
readonly routes: readonly Route[];
|
|
91
|
+
{{#if routes.nest}}
|
|
92
|
+
/** Its Nest controllers, listed by the generated `{{context.kebab}}.controllers.ts`: Nest builds them, the kit serves their methods. */
|
|
93
|
+
readonly controllers: readonly Type<unknown>[];
|
|
94
|
+
{{/if}}
|
|
83
95
|
}
|
|
84
96
|
|
|
85
97
|
/** Every use case of the context is asked of the context as a whole: inside an organisation, its policies decide. */
|
|
@@ -120,6 +132,7 @@ export function {{context.camel}}Module(platform: Platform): {{context.pascal}}W
|
|
|
120
132
|
],
|
|
121
133
|
routes: [
|
|
122
134
|
// ddd-ts-kit:routes
|
|
135
|
+
{{#unless routes.nest}}
|
|
123
136
|
...controllerRoutes([new DeactivateAccountController(platform.commands)]),
|
|
124
137
|
...controllerRoutes([new ProvisionAccountController(platform.commands)]),
|
|
125
138
|
...controllerRoutes([new AcceptInvitationController(platform.commands)]),
|
|
@@ -132,8 +145,12 @@ export function {{context.camel}}Module(platform: Platform): {{context.pascal}}W
|
|
|
132
145
|
...controllerRoutes([new RevokeDelegationController(platform.commands)]),
|
|
133
146
|
...controllerRoutes([new RevokeInvitationController(platform.commands)]),
|
|
134
147
|
...controllerRoutes([new SearchMembersController(platform.queries)]),
|
|
148
|
+
{{/unless}}
|
|
135
149
|
// /ddd-ts-kit:routes
|
|
136
150
|
],
|
|
151
|
+
{{#if routes.nest}}
|
|
152
|
+
controllers: {{context.camel}}Controllers,
|
|
153
|
+
{{/if}}
|
|
137
154
|
};
|
|
138
155
|
}
|
|
139
156
|
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Controller, HttpCode, Inject, Post } from '@nestjs/common';
|
|
2
|
+
{{#if schemas.shared}}
|
|
3
|
+
import type { Accepted } from '@ddd-ts-kit/http';
|
|
4
|
+
{{/if}}
|
|
5
|
+
import { CurrentActor, KitRoute, KitRoutes } from '@ddd-ts-kit/http/nest';
|
|
6
|
+
import { CommandBus, type Actor } from '@ddd-ts-kit/kernel';
|
|
7
|
+
import { DeactivateAccountCommand } from '{{alias.context}}/application/commands/deactivate-account/deactivate-account.command{{alias.ext}}';
|
|
8
|
+
{{#if schemas.perRoute}}
|
|
9
|
+
import { DeactivateAccountAccepted } from '{{alias.context}}/presentation/http/accounts/deactivate-account/deactivate-account.accepted{{alias.ext}}';
|
|
10
|
+
{{/if}}
|
|
11
|
+
import { AccountsRoutes } from '{{alias.context}}/presentation/http/accounts.routes{{alias.ext}}';
|
|
12
|
+
|
|
13
|
+
/** Built by Nest with the bus it injects, served by the kit: its parts and its answer are read from its signature. */
|
|
14
|
+
@Controller()
|
|
15
|
+
@KitRoutes({ group: AccountsRoutes })
|
|
16
|
+
export class DeactivateAccountController {
|
|
17
|
+
constructor(@Inject(CommandBus) private readonly commands: CommandBus) {}
|
|
18
|
+
|
|
19
|
+
@Post('me/deactivation')
|
|
20
|
+
@HttpCode(200)
|
|
21
|
+
@KitRoute({
|
|
22
|
+
summary: 'Deactivate my account',
|
|
23
|
+
response: { description: 'The account is deactivated; the body carries its identifier.' },
|
|
24
|
+
errors: ['ACCOUNT_NOT_FOUND', 'ACCOUNT_ALREADY_DEACTIVATED', 'ORGANISATION_NOT_FOUND', 'LAST_OWNER'],
|
|
25
|
+
})
|
|
26
|
+
async deactivateAccount(@CurrentActor() actor: Actor): Promise<{{#if schemas.shared}}Accepted{{/if}}{{#if schemas.perRoute}}DeactivateAccountAccepted{{/if}}> {
|
|
27
|
+
const id = await this.commands.execute(new DeactivateAccountCommand(actor));
|
|
28
|
+
|
|
29
|
+
return { id };
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Body, Controller, Inject, Put } from '@nestjs/common';
|
|
2
|
+
{{#if schemas.shared}}
|
|
3
|
+
import type { Accepted } from '@ddd-ts-kit/http';
|
|
4
|
+
{{/if}}
|
|
5
|
+
import { CurrentActor, KitRoute, KitRoutes } from '@ddd-ts-kit/http/nest';
|
|
6
|
+
import { CommandBus, type Actor } from '@ddd-ts-kit/kernel';
|
|
7
|
+
import { ProvisionAccountCommand } from '{{alias.context}}/application/commands/provision-account/provision-account.command{{alias.ext}}';
|
|
8
|
+
import { ProvisionAccountBody } from '{{alias.context}}/presentation/http/accounts/provision-account/provision-account.body{{alias.ext}}';
|
|
9
|
+
{{#if schemas.perRoute}}
|
|
10
|
+
import { ProvisionAccountAccepted } from '{{alias.context}}/presentation/http/accounts/provision-account/provision-account.accepted{{alias.ext}}';
|
|
11
|
+
{{/if}}
|
|
12
|
+
import { AccountsRoutes } from '{{alias.context}}/presentation/http/accounts.routes{{alias.ext}}';
|
|
13
|
+
|
|
14
|
+
/** Built by Nest with the bus it injects, served by the kit: its parts and its answer are read from its signature. */
|
|
15
|
+
@Controller()
|
|
16
|
+
@KitRoutes({ group: AccountsRoutes })
|
|
17
|
+
export class ProvisionAccountController {
|
|
18
|
+
constructor(@Inject(CommandBus) private readonly commands: CommandBus) {}
|
|
19
|
+
|
|
20
|
+
@Put('me')
|
|
21
|
+
@KitRoute({
|
|
22
|
+
summary: 'Provision my account',
|
|
23
|
+
response: { description: 'The account, provisioned or refreshed; the body carries its identifier.' },
|
|
24
|
+
errors: ['EMAIL_NOT_VERIFIED', 'INVALID_EMAIL_ADDRESS', 'INVALID_DISPLAY_NAME', 'ACCOUNT_DEACTIVATED'],
|
|
25
|
+
})
|
|
26
|
+
async provisionAccount(@Body() body: ProvisionAccountBody, @CurrentActor() actor: Actor): Promise<{{#if schemas.shared}}Accepted{{/if}}{{#if schemas.perRoute}}ProvisionAccountAccepted{{/if}}> {
|
|
27
|
+
const id = await this.commands.execute(new ProvisionAccountCommand(actor, profileOf(actor, body.displayName)));
|
|
28
|
+
|
|
29
|
+
return { id };
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* The token is the authority on who the person is: their address comes from it, never from the
|
|
35
|
+
* body, and with whether the provider verified it (`email_verified`), so that nobody accepts an
|
|
36
|
+
* invitation sent to someone else by registering their address unverified.
|
|
37
|
+
*/
|
|
38
|
+
function profileOf(actor: Actor, displayName: string | undefined): ProvisionAccountCommand['profile'] {
|
|
39
|
+
const { email, emailVerified, username } = actor.attributes;
|
|
40
|
+
const address = typeof email === 'string' ? email : '';
|
|
41
|
+
const named = displayName ?? (typeof username === 'string' ? username : address);
|
|
42
|
+
|
|
43
|
+
return { email: address, emailVerified: emailVerified === true, displayName: named };
|
|
44
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Body, Controller, HttpCode, Inject, Post } from '@nestjs/common';
|
|
2
|
+
{{#if schemas.shared}}
|
|
3
|
+
import type { Accepted } from '@ddd-ts-kit/http';
|
|
4
|
+
{{/if}}
|
|
5
|
+
import { CurrentActor, KitRoute, KitRoutes } from '@ddd-ts-kit/http/nest';
|
|
6
|
+
import { CommandBus, type Actor } from '@ddd-ts-kit/kernel';
|
|
7
|
+
{{#if schemas.shared}}
|
|
8
|
+
import { classSchema } from '@ddd-ts-kit/validation/class-validator';
|
|
9
|
+
{{/if}}
|
|
10
|
+
import { AcceptInvitationCommand } from '{{alias.context}}/application/commands/accept-invitation/accept-invitation.command{{alias.ext}}';
|
|
11
|
+
{{#if schemas.shared}}
|
|
12
|
+
import { InvitationToken } from '{{alias.context}}/presentation/http/shared/invitation-token.schema{{alias.ext}}';
|
|
13
|
+
{{/if}}
|
|
14
|
+
{{#if schemas.perRoute}}
|
|
15
|
+
import { AcceptInvitationBody } from '{{alias.context}}/presentation/http/invitations/accept-invitation/accept-invitation.body{{alias.ext}}';
|
|
16
|
+
{{/if}}
|
|
17
|
+
{{#if schemas.perRoute}}
|
|
18
|
+
import { AcceptInvitationAccepted } from '{{alias.context}}/presentation/http/invitations/accept-invitation/accept-invitation.accepted{{alias.ext}}';
|
|
19
|
+
{{/if}}
|
|
20
|
+
import { InvitationsRoutes } from '{{alias.context}}/presentation/http/invitations.routes{{alias.ext}}';
|
|
21
|
+
|
|
22
|
+
{{#if schemas.shared}}
|
|
23
|
+
/** The token every invitation route reads, documented once under its name. */
|
|
24
|
+
const token = classSchema(InvitationToken, { shared: true });
|
|
25
|
+
|
|
26
|
+
{{/if}}
|
|
27
|
+
/** Built by Nest with the bus it injects, served by the kit: its parts and its answer are read from its signature. */
|
|
28
|
+
@Controller()
|
|
29
|
+
@KitRoutes({ group: InvitationsRoutes })
|
|
30
|
+
export class AcceptInvitationController {
|
|
31
|
+
constructor(@Inject(CommandBus) private readonly commands: CommandBus) {}
|
|
32
|
+
|
|
33
|
+
@Post('acceptance')
|
|
34
|
+
@HttpCode(200)
|
|
35
|
+
@KitRoute({
|
|
36
|
+
summary: 'Accept an invitation',
|
|
37
|
+
{{#if schemas.shared}}
|
|
38
|
+
request: { body: token },
|
|
39
|
+
{{/if}}
|
|
40
|
+
response: { description: 'Accepted; the caller is a member, the body carries the identifier of the invitation.' },
|
|
41
|
+
errors: [
|
|
42
|
+
'INVITATION_NOT_FOUND',
|
|
43
|
+
'ACCOUNT_NOT_FOUND',
|
|
44
|
+
'ACCOUNT_DEACTIVATED',
|
|
45
|
+
'INVITATION_NOT_PENDING',
|
|
46
|
+
'INVITATION_EXPIRED',
|
|
47
|
+
'INVITATION_ADDRESSED_TO_ANOTHER',
|
|
48
|
+
'ALREADY_MEMBER',
|
|
49
|
+
],
|
|
50
|
+
})
|
|
51
|
+
async acceptInvitation(@Body() body: {{#if schemas.shared}}InvitationToken{{/if}}{{#if schemas.perRoute}}AcceptInvitationBody{{/if}}, @CurrentActor() actor: Actor): Promise<{{#if schemas.shared}}Accepted{{/if}}{{#if schemas.perRoute}}AcceptInvitationAccepted{{/if}}> {
|
|
52
|
+
const id = await this.commands.execute(new AcceptInvitationCommand(actor, body.token));
|
|
53
|
+
|
|
54
|
+
return { id };
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Body, Controller, HttpCode, Inject, Post } from '@nestjs/common';
|
|
2
|
+
{{#if schemas.shared}}
|
|
3
|
+
import type { Accepted } from '@ddd-ts-kit/http';
|
|
4
|
+
{{/if}}
|
|
5
|
+
import { CurrentActor, KitRoute, KitRoutes } from '@ddd-ts-kit/http/nest';
|
|
6
|
+
import { CommandBus, type Actor } from '@ddd-ts-kit/kernel';
|
|
7
|
+
{{#if schemas.shared}}
|
|
8
|
+
import { classSchema } from '@ddd-ts-kit/validation/class-validator';
|
|
9
|
+
{{/if}}
|
|
10
|
+
import { DeclineInvitationCommand } from '{{alias.context}}/application/commands/decline-invitation/decline-invitation.command{{alias.ext}}';
|
|
11
|
+
{{#if schemas.shared}}
|
|
12
|
+
import { InvitationToken } from '{{alias.context}}/presentation/http/shared/invitation-token.schema{{alias.ext}}';
|
|
13
|
+
{{/if}}
|
|
14
|
+
{{#if schemas.perRoute}}
|
|
15
|
+
import { DeclineInvitationBody } from '{{alias.context}}/presentation/http/invitations/decline-invitation/decline-invitation.body{{alias.ext}}';
|
|
16
|
+
{{/if}}
|
|
17
|
+
{{#if schemas.perRoute}}
|
|
18
|
+
import { DeclineInvitationAccepted } from '{{alias.context}}/presentation/http/invitations/decline-invitation/decline-invitation.accepted{{alias.ext}}';
|
|
19
|
+
{{/if}}
|
|
20
|
+
import { InvitationsRoutes } from '{{alias.context}}/presentation/http/invitations.routes{{alias.ext}}';
|
|
21
|
+
|
|
22
|
+
{{#if schemas.shared}}
|
|
23
|
+
/** The token every invitation route reads, documented once under its name. */
|
|
24
|
+
const token = classSchema(InvitationToken, { shared: true });
|
|
25
|
+
|
|
26
|
+
{{/if}}
|
|
27
|
+
/** Built by Nest with the bus it injects, served by the kit: its parts and its answer are read from its signature. */
|
|
28
|
+
@Controller()
|
|
29
|
+
@KitRoutes({ group: InvitationsRoutes })
|
|
30
|
+
export class DeclineInvitationController {
|
|
31
|
+
constructor(@Inject(CommandBus) private readonly commands: CommandBus) {}
|
|
32
|
+
|
|
33
|
+
@Post('declination')
|
|
34
|
+
@HttpCode(200)
|
|
35
|
+
@KitRoute({
|
|
36
|
+
summary: 'Decline an invitation',
|
|
37
|
+
{{#if schemas.shared}}
|
|
38
|
+
request: { body: token },
|
|
39
|
+
{{/if}}
|
|
40
|
+
response: { description: 'Declined; the body carries the identifier of the invitation.' },
|
|
41
|
+
errors: [
|
|
42
|
+
'INVITATION_NOT_FOUND',
|
|
43
|
+
'ACCOUNT_NOT_FOUND',
|
|
44
|
+
'INVITATION_NOT_PENDING',
|
|
45
|
+
'INVITATION_EXPIRED',
|
|
46
|
+
'INVITATION_ADDRESSED_TO_ANOTHER',
|
|
47
|
+
],
|
|
48
|
+
})
|
|
49
|
+
async declineInvitation(@Body() body: {{#if schemas.shared}}InvitationToken{{/if}}{{#if schemas.perRoute}}DeclineInvitationBody{{/if}}, @CurrentActor() actor: Actor): Promise<{{#if schemas.shared}}Accepted{{/if}}{{#if schemas.perRoute}}DeclineInvitationAccepted{{/if}}> {
|
|
50
|
+
const id = await this.commands.execute(new DeclineInvitationCommand(actor, body.token));
|
|
51
|
+
|
|
52
|
+
return { id };
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Body, Controller, Inject, Param, Put } from '@nestjs/common';
|
|
2
|
+
{{#if schemas.shared}}
|
|
3
|
+
import type { Accepted } from '@ddd-ts-kit/http';
|
|
4
|
+
{{/if}}
|
|
5
|
+
import { CurrentActor, KitRoute, KitRoutes } from '@ddd-ts-kit/http/nest';
|
|
6
|
+
import { CommandBus, type Actor } from '@ddd-ts-kit/kernel';
|
|
7
|
+
import { ChangeMemberRoleCommand } from '{{alias.context}}/application/commands/change-member-role/change-member-role.command{{alias.ext}}';
|
|
8
|
+
import { ChangeMemberRoleParams } from '{{alias.context}}/presentation/http/organisations/change-member-role/change-member-role.params{{alias.ext}}';
|
|
9
|
+
import { ChangeMemberRoleBody } from '{{alias.context}}/presentation/http/organisations/change-member-role/change-member-role.body{{alias.ext}}';
|
|
10
|
+
{{#if schemas.perRoute}}
|
|
11
|
+
import { ChangeMemberRoleAccepted } from '{{alias.context}}/presentation/http/organisations/change-member-role/change-member-role.accepted{{alias.ext}}';
|
|
12
|
+
{{/if}}
|
|
13
|
+
import { OrganisationsRoutes } from '{{alias.context}}/presentation/http/organisations.routes{{alias.ext}}';
|
|
14
|
+
|
|
15
|
+
/** Built by Nest with the bus it injects, served by the kit: its parts and its answer are read from its signature. */
|
|
16
|
+
@Controller()
|
|
17
|
+
@KitRoutes({ group: OrganisationsRoutes })
|
|
18
|
+
export class ChangeMemberRoleController {
|
|
19
|
+
constructor(@Inject(CommandBus) private readonly commands: CommandBus) {}
|
|
20
|
+
|
|
21
|
+
@Put(':organisationId/members/:accountId/role')
|
|
22
|
+
@KitRoute({
|
|
23
|
+
summary: 'Change the role of a member',
|
|
24
|
+
response: { description: 'Changed; the body carries the identifier of the membership.' },
|
|
25
|
+
errors: ['ORGANISATION_NOT_FOUND', 'MEMBER_NOT_FOUND', 'OWN_ROLE', 'ABOVE_OWN_ROLE', 'OWNERS_ONLY', 'LAST_OWNER'],
|
|
26
|
+
})
|
|
27
|
+
async changeMemberRole(@Param() params: ChangeMemberRoleParams, @Body() body: ChangeMemberRoleBody, @CurrentActor() actor: Actor): Promise<{{#if schemas.shared}}Accepted{{/if}}{{#if schemas.perRoute}}ChangeMemberRoleAccepted{{/if}}> {
|
|
28
|
+
const id = await this.commands.execute(new ChangeMemberRoleCommand(actor, params.organisationId, params.accountId, body.role));
|
|
29
|
+
|
|
30
|
+
return { id };
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Body, Controller, Inject, Param, Post } from '@nestjs/common';
|
|
2
|
+
{{#if schemas.shared}}
|
|
3
|
+
import type { Accepted } from '@ddd-ts-kit/http';
|
|
4
|
+
{{/if}}
|
|
5
|
+
import { CurrentActor, KitRoute, KitRoutes } from '@ddd-ts-kit/http/nest';
|
|
6
|
+
import { CommandBus, type Actor } from '@ddd-ts-kit/kernel';
|
|
7
|
+
import { GrantDelegationCommand } from '{{alias.context}}/application/commands/grant-delegation/grant-delegation.command{{alias.ext}}';
|
|
8
|
+
import { GrantDelegationParams } from '{{alias.context}}/presentation/http/organisations/grant-delegation/grant-delegation.params{{alias.ext}}';
|
|
9
|
+
import { GrantDelegationBody } from '{{alias.context}}/presentation/http/organisations/grant-delegation/grant-delegation.body{{alias.ext}}';
|
|
10
|
+
{{#if schemas.perRoute}}
|
|
11
|
+
import { GrantDelegationAccepted } from '{{alias.context}}/presentation/http/organisations/grant-delegation/grant-delegation.accepted{{alias.ext}}';
|
|
12
|
+
{{/if}}
|
|
13
|
+
import { OrganisationsRoutes } from '{{alias.context}}/presentation/http/organisations.routes{{alias.ext}}';
|
|
14
|
+
|
|
15
|
+
/** Built by Nest with the bus it injects, served by the kit: its parts and its answer are read from its signature. */
|
|
16
|
+
@Controller()
|
|
17
|
+
@KitRoutes({ group: OrganisationsRoutes })
|
|
18
|
+
export class GrantDelegationController {
|
|
19
|
+
constructor(@Inject(CommandBus) private readonly commands: CommandBus) {}
|
|
20
|
+
|
|
21
|
+
@Post(':organisationId/delegations')
|
|
22
|
+
@KitRoute({
|
|
23
|
+
summary: 'Lend rights to a member',
|
|
24
|
+
response: { description: 'Granted; the body carries the identifier of the delegation.' },
|
|
25
|
+
errors: [
|
|
26
|
+
'MEMBER_NOT_FOUND',
|
|
27
|
+
'DELEGATION_TO_ONESELF',
|
|
28
|
+
'DELEGATION_WITHOUT_RIGHTS',
|
|
29
|
+
'DELEGATION_BEYOND_RIGHTS',
|
|
30
|
+
'DELEGATION_PERIOD_INVERTED',
|
|
31
|
+
'DELEGATION_TOO_LONG',
|
|
32
|
+
],
|
|
33
|
+
})
|
|
34
|
+
async grantDelegation(@Param() params: GrantDelegationParams, @Body() body: GrantDelegationBody, @CurrentActor() actor: Actor): Promise<{{#if schemas.shared}}Accepted{{/if}}{{#if schemas.perRoute}}GrantDelegationAccepted{{/if}}> {
|
|
35
|
+
const id = await this.commands.execute(new GrantDelegationCommand(actor, params.organisationId, termsOf(body)));
|
|
36
|
+
|
|
37
|
+
return { id };
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function termsOf({ delegateId, rights, startsAt, endsAt }: GrantDelegationBody): GrantDelegationCommand['terms'] {
|
|
42
|
+
return { delegateId, rights, startsAt: new Date(startsAt), endsAt: new Date(endsAt) };
|
|
43
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Body, Controller, Inject, Param, Post } from '@nestjs/common';
|
|
2
|
+
import { CurrentActor, KitRoute, KitRoutes } from '@ddd-ts-kit/http/nest';
|
|
3
|
+
import { CommandBus, type Actor } from '@ddd-ts-kit/kernel';
|
|
4
|
+
import { InviteMemberCommand } from '{{alias.context}}/application/commands/invite-member/invite-member.command{{alias.ext}}';
|
|
5
|
+
import { InviteMemberParams } from '{{alias.context}}/presentation/http/organisations/invite-member/invite-member.params{{alias.ext}}';
|
|
6
|
+
import { InviteMemberBody } from '{{alias.context}}/presentation/http/organisations/invite-member/invite-member.body{{alias.ext}}';
|
|
7
|
+
import { InviteMemberAccepted } from '{{alias.context}}/presentation/http/organisations/invite-member/invite-member.accepted{{alias.ext}}';
|
|
8
|
+
import { OrganisationsRoutes } from '{{alias.context}}/presentation/http/organisations.routes{{alias.ext}}';
|
|
9
|
+
|
|
10
|
+
/** Built by Nest with the bus it injects, served by the kit: its parts and its answer are read from its signature. */
|
|
11
|
+
@Controller()
|
|
12
|
+
@KitRoutes({ group: OrganisationsRoutes })
|
|
13
|
+
export class InviteMemberController {
|
|
14
|
+
constructor(@Inject(CommandBus) private readonly commands: CommandBus) {}
|
|
15
|
+
|
|
16
|
+
@Post(':organisationId/invitations')
|
|
17
|
+
@KitRoute({
|
|
18
|
+
summary: 'Invite a person to the organisation',
|
|
19
|
+
response: { description: 'Issued; the body carries the token to send to the person, given once and never stored.' },
|
|
20
|
+
errors: ['INVALID_EMAIL_ADDRESS', 'ABOVE_OWN_ROLE', 'OWNERS_ONLY'],
|
|
21
|
+
})
|
|
22
|
+
async inviteMember(@Param() params: InviteMemberParams, @Body() body: InviteMemberBody, @CurrentActor() actor: Actor): Promise<InviteMemberAccepted> {
|
|
23
|
+
return this.commands.execute(new InviteMemberCommand(actor, params.organisationId, body));
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Body, Controller, Inject, Post } from '@nestjs/common';
|
|
2
|
+
{{#if schemas.shared}}
|
|
3
|
+
import type { Accepted } from '@ddd-ts-kit/http';
|
|
4
|
+
{{/if}}
|
|
5
|
+
import { CurrentActor, KitRoute, KitRoutes } from '@ddd-ts-kit/http/nest';
|
|
6
|
+
import { CommandBus, type Actor } from '@ddd-ts-kit/kernel';
|
|
7
|
+
import { OpenOrganisationCommand } from '{{alias.context}}/application/commands/open-organisation/open-organisation.command{{alias.ext}}';
|
|
8
|
+
import { OpenOrganisationBody } from '{{alias.context}}/presentation/http/organisations/open-organisation/open-organisation.body{{alias.ext}}';
|
|
9
|
+
{{#if schemas.perRoute}}
|
|
10
|
+
import { OpenOrganisationAccepted } from '{{alias.context}}/presentation/http/organisations/open-organisation/open-organisation.accepted{{alias.ext}}';
|
|
11
|
+
{{/if}}
|
|
12
|
+
import { OrganisationsRoutes } from '{{alias.context}}/presentation/http/organisations.routes{{alias.ext}}';
|
|
13
|
+
|
|
14
|
+
/** Built by Nest with the bus it injects, served by the kit: its parts and its answer are read from its signature. */
|
|
15
|
+
@Controller()
|
|
16
|
+
@KitRoutes({ group: OrganisationsRoutes })
|
|
17
|
+
export class OpenOrganisationController {
|
|
18
|
+
constructor(@Inject(CommandBus) private readonly commands: CommandBus) {}
|
|
19
|
+
|
|
20
|
+
@Post()
|
|
21
|
+
@KitRoute({
|
|
22
|
+
summary: 'Open an organisation',
|
|
23
|
+
response: { description: 'Opened; the body carries its slug, the caller is its first owner.' },
|
|
24
|
+
errors: [
|
|
25
|
+
'ACCOUNT_NOT_FOUND',
|
|
26
|
+
'ACCOUNT_DEACTIVATED',
|
|
27
|
+
'ORGANISATION_SLUG_TAKEN',
|
|
28
|
+
'INVALID_ORGANISATION_SLUG',
|
|
29
|
+
'INVALID_ORGANISATION_NAME',
|
|
30
|
+
],
|
|
31
|
+
})
|
|
32
|
+
async openOrganisation(@Body() body: OpenOrganisationBody, @CurrentActor() actor: Actor): Promise<{{#if schemas.shared}}Accepted{{/if}}{{#if schemas.perRoute}}OpenOrganisationAccepted{{/if}}> {
|
|
33
|
+
const id = await this.commands.execute(new OpenOrganisationCommand(actor, body));
|
|
34
|
+
|
|
35
|
+
return { id };
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Controller, Delete, Inject, Param } from '@nestjs/common';
|
|
2
|
+
{{#if schemas.shared}}
|
|
3
|
+
import type { Accepted } from '@ddd-ts-kit/http';
|
|
4
|
+
{{/if}}
|
|
5
|
+
import { CurrentActor, KitRoute, KitRoutes } from '@ddd-ts-kit/http/nest';
|
|
6
|
+
import { CommandBus, type Actor } from '@ddd-ts-kit/kernel';
|
|
7
|
+
import { RemoveMemberCommand } from '{{alias.context}}/application/commands/remove-member/remove-member.command{{alias.ext}}';
|
|
8
|
+
import { RemoveMemberParams } from '{{alias.context}}/presentation/http/organisations/remove-member/remove-member.params{{alias.ext}}';
|
|
9
|
+
{{#if schemas.perRoute}}
|
|
10
|
+
import { RemoveMemberAccepted } from '{{alias.context}}/presentation/http/organisations/remove-member/remove-member.accepted{{alias.ext}}';
|
|
11
|
+
{{/if}}
|
|
12
|
+
import { OrganisationsRoutes } from '{{alias.context}}/presentation/http/organisations.routes{{alias.ext}}';
|
|
13
|
+
|
|
14
|
+
/** Built by Nest with the bus it injects, served by the kit: its parts and its answer are read from its signature. */
|
|
15
|
+
@Controller()
|
|
16
|
+
@KitRoutes({ group: OrganisationsRoutes })
|
|
17
|
+
export class RemoveMemberController {
|
|
18
|
+
constructor(@Inject(CommandBus) private readonly commands: CommandBus) {}
|
|
19
|
+
|
|
20
|
+
@Delete(':organisationId/members/:accountId')
|
|
21
|
+
@KitRoute({
|
|
22
|
+
summary: 'Remove a member',
|
|
23
|
+
response: { description: 'Removed; the body carries the identifier of the membership.' },
|
|
24
|
+
errors: ['ORGANISATION_NOT_FOUND', 'MEMBER_NOT_FOUND', 'ABOVE_OWN_ROLE', 'OWNERS_ONLY', 'LAST_OWNER'],
|
|
25
|
+
})
|
|
26
|
+
async removeMember(@Param() params: RemoveMemberParams, @CurrentActor() actor: Actor): Promise<{{#if schemas.shared}}Accepted{{/if}}{{#if schemas.perRoute}}RemoveMemberAccepted{{/if}}> {
|
|
27
|
+
const id = await this.commands.execute(new RemoveMemberCommand(actor, params.organisationId, params.accountId));
|
|
28
|
+
|
|
29
|
+
return { id };
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Controller, Delete, Inject, Param } from '@nestjs/common';
|
|
2
|
+
{{#if schemas.shared}}
|
|
3
|
+
import type { Accepted } from '@ddd-ts-kit/http';
|
|
4
|
+
{{/if}}
|
|
5
|
+
import { CurrentActor, KitRoute, KitRoutes } from '@ddd-ts-kit/http/nest';
|
|
6
|
+
import { CommandBus, type Actor } from '@ddd-ts-kit/kernel';
|
|
7
|
+
import { RevokeDelegationCommand } from '{{alias.context}}/application/commands/revoke-delegation/revoke-delegation.command{{alias.ext}}';
|
|
8
|
+
import { RevokeDelegationParams } from '{{alias.context}}/presentation/http/organisations/revoke-delegation/revoke-delegation.params{{alias.ext}}';
|
|
9
|
+
{{#if schemas.perRoute}}
|
|
10
|
+
import { RevokeDelegationAccepted } from '{{alias.context}}/presentation/http/organisations/revoke-delegation/revoke-delegation.accepted{{alias.ext}}';
|
|
11
|
+
{{/if}}
|
|
12
|
+
import { OrganisationsRoutes } from '{{alias.context}}/presentation/http/organisations.routes{{alias.ext}}';
|
|
13
|
+
|
|
14
|
+
/** Built by Nest with the bus it injects, served by the kit: its parts and its answer are read from its signature. */
|
|
15
|
+
@Controller()
|
|
16
|
+
@KitRoutes({ group: OrganisationsRoutes })
|
|
17
|
+
export class RevokeDelegationController {
|
|
18
|
+
constructor(@Inject(CommandBus) private readonly commands: CommandBus) {}
|
|
19
|
+
|
|
20
|
+
@Delete(':organisationId/delegations/:delegationId')
|
|
21
|
+
@KitRoute({
|
|
22
|
+
summary: 'Revoke a delegation',
|
|
23
|
+
response: { description: 'Revoked; the body carries its identifier.' },
|
|
24
|
+
errors: ['DELEGATION_NOT_FOUND', 'DELEGATION_NOT_ACTIVE'],
|
|
25
|
+
})
|
|
26
|
+
async revokeDelegation(@Param() params: RevokeDelegationParams, @CurrentActor() actor: Actor): Promise<{{#if schemas.shared}}Accepted{{/if}}{{#if schemas.perRoute}}RevokeDelegationAccepted{{/if}}> {
|
|
27
|
+
const id = await this.commands.execute(new RevokeDelegationCommand(actor, params.organisationId, params.delegationId));
|
|
28
|
+
|
|
29
|
+
return { id };
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Controller, Delete, Inject, Param } from '@nestjs/common';
|
|
2
|
+
{{#if schemas.shared}}
|
|
3
|
+
import type { Accepted } from '@ddd-ts-kit/http';
|
|
4
|
+
{{/if}}
|
|
5
|
+
import { CurrentActor, KitRoute, KitRoutes } from '@ddd-ts-kit/http/nest';
|
|
6
|
+
import { CommandBus, type Actor } from '@ddd-ts-kit/kernel';
|
|
7
|
+
import { RevokeInvitationCommand } from '{{alias.context}}/application/commands/revoke-invitation/revoke-invitation.command{{alias.ext}}';
|
|
8
|
+
import { RevokeInvitationParams } from '{{alias.context}}/presentation/http/organisations/revoke-invitation/revoke-invitation.params{{alias.ext}}';
|
|
9
|
+
{{#if schemas.perRoute}}
|
|
10
|
+
import { RevokeInvitationAccepted } from '{{alias.context}}/presentation/http/organisations/revoke-invitation/revoke-invitation.accepted{{alias.ext}}';
|
|
11
|
+
{{/if}}
|
|
12
|
+
import { OrganisationsRoutes } from '{{alias.context}}/presentation/http/organisations.routes{{alias.ext}}';
|
|
13
|
+
|
|
14
|
+
/** Built by Nest with the bus it injects, served by the kit: its parts and its answer are read from its signature. */
|
|
15
|
+
@Controller()
|
|
16
|
+
@KitRoutes({ group: OrganisationsRoutes })
|
|
17
|
+
export class RevokeInvitationController {
|
|
18
|
+
constructor(@Inject(CommandBus) private readonly commands: CommandBus) {}
|
|
19
|
+
|
|
20
|
+
@Delete(':organisationId/invitations/:invitationId')
|
|
21
|
+
@KitRoute({
|
|
22
|
+
summary: 'Take back an invitation',
|
|
23
|
+
response: { description: 'Taken back; the body carries its identifier.' },
|
|
24
|
+
errors: ['INVITATION_NOT_FOUND', 'INVITATION_NOT_PENDING'],
|
|
25
|
+
})
|
|
26
|
+
async revokeInvitation(@Param() params: RevokeInvitationParams, @CurrentActor() actor: Actor): Promise<{{#if schemas.shared}}Accepted{{/if}}{{#if schemas.perRoute}}RevokeInvitationAccepted{{/if}}> {
|
|
27
|
+
const id = await this.commands.execute(new RevokeInvitationCommand(actor, params.organisationId, params.invitationId));
|
|
28
|
+
|
|
29
|
+
return { id };
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Controller, Get, Inject, Param, Query } from '@nestjs/common';
|
|
2
|
+
import { pageQuerySchema, pageResponse, pageSchemaOf, type PageBody } from '@ddd-ts-kit/http';
|
|
3
|
+
import { CurrentActor, KitRoute, KitRoutes } from '@ddd-ts-kit/http/nest';
|
|
4
|
+
import { QueryBus, type Actor } from '@ddd-ts-kit/kernel';
|
|
5
|
+
import type { Infer } from '@ddd-ts-kit/validation';
|
|
6
|
+
import { classSchema } from '@ddd-ts-kit/validation/class-validator';
|
|
7
|
+
import { SearchMembersQuery } from '{{alias.context}}/application/queries/search-members/search-members.query{{alias.ext}}';
|
|
8
|
+
import type { SearchMembersItem } from '{{alias.context}}/application/queries/search-members/search-members.result{{alias.ext}}';
|
|
9
|
+
import { SearchMembersLine } from '{{alias.context}}/presentation/http/organisations/search-members/search-members.line{{alias.ext}}';
|
|
10
|
+
import { SearchMembersParams } from '{{alias.context}}/presentation/http/organisations/search-members/search-members.params{{alias.ext}}';
|
|
11
|
+
import { OrganisationsRoutes } from '{{alias.context}}/presentation/http/organisations.routes{{alias.ext}}';
|
|
12
|
+
|
|
13
|
+
const query = pageQuerySchema({ sortable: ['joinedAt'], maxSize: 100, kind: 'offset' });
|
|
14
|
+
const line = classSchema(SearchMembersLine);
|
|
15
|
+
|
|
16
|
+
/** A page of the current members of an organisation, for its members: a page is no DTO class, so @KitRoute gives its query and its answer. */
|
|
17
|
+
@Controller()
|
|
18
|
+
@KitRoutes({ group: OrganisationsRoutes })
|
|
19
|
+
export class SearchMembersController {
|
|
20
|
+
constructor(@Inject(QueryBus) private readonly queries: QueryBus) {}
|
|
21
|
+
|
|
22
|
+
@Get(':organisationId/members')
|
|
23
|
+
@KitRoute({
|
|
24
|
+
summary: 'Search the members of an organisation',
|
|
25
|
+
request: { query },
|
|
26
|
+
response: { description: 'One page of the members.', body: pageSchemaOf(line) },
|
|
27
|
+
errors: [],
|
|
28
|
+
})
|
|
29
|
+
async searchMembers(
|
|
30
|
+
@Param() params: SearchMembersParams,
|
|
31
|
+
@Query() criteria: Infer<typeof query>,
|
|
32
|
+
@CurrentActor() actor: Actor,
|
|
33
|
+
): Promise<PageBody<SearchMembersLine>> {
|
|
34
|
+
const page = await this.queries.execute(new SearchMembersQuery(actor, params.organisationId, criteria));
|
|
35
|
+
|
|
36
|
+
return pageResponse(page, toLine);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function toLine(member: SearchMembersItem): SearchMembersLine {
|
|
41
|
+
return { ...member, joinedAt: member.joinedAt.toISOString() };
|
|
42
|
+
}
|
|
@@ -14,7 +14,7 @@ const scope = new FixedExecutionScope(executionContext({ correlationId: 'contrac
|
|
|
14
14
|
|
|
15
15
|
const expectations = {
|
|
16
16
|
createAggregate: () => anOrganisation().build(),
|
|
17
|
-
mutate
|
|
17
|
+
// No `mutate`: nothing changes an organisation once opened, so the stale-save case stays pending.
|
|
18
18
|
idOf: (subject: Organisation) => subject.id,
|
|
19
19
|
stateOf: (subject: Organisation) => subject.toState(),
|
|
20
20
|
};
|
package/templates/presets/identity/context/test/unit/__context__.module.spec.explicit.ts.tpl
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { describe, expect, it } from '{{tests.module}}';
|
|
2
|
+
{{#if routes.nest}}
|
|
3
|
+
import { nestControllerRoutes } from '@ddd-ts-kit/http/nest';
|
|
4
|
+
{{/if}}
|
|
2
5
|
import { DuplicateHandlerError, type Command, type MessageType, type Query } from '@ddd-ts-kit/kernel';
|
|
6
|
+
{{#if routes.nest}}
|
|
7
|
+
import { classSchema } from '@ddd-ts-kit/validation/class-validator';
|
|
8
|
+
{{/if}}
|
|
3
9
|
import { {{context.camel}}Module } from '{{alias.context}}/{{context.kebab}}.module{{alias.ext}}';
|
|
4
10
|
import { AcceptInvitationCommand } from '{{alias.context}}/application/commands/accept-invitation/accept-invitation.command{{alias.ext}}';
|
|
5
11
|
import { ChangeMemberRoleCommand } from '{{alias.context}}/application/commands/change-member-role/change-member-role.command{{alias.ext}}';
|
|
@@ -52,7 +58,14 @@ describe('The module of {{context.kebab}}', () => {
|
|
|
52
58
|
});
|
|
53
59
|
|
|
54
60
|
it('mounts one route per use case of the context', () => {
|
|
61
|
+
{{#unless routes.nest}}
|
|
55
62
|
const mounted = wiring.routes.map(({ method, path }) => `${method} ${path}`).toSorted();
|
|
63
|
+
{{/unless}}
|
|
64
|
+
{{#if routes.nest}}
|
|
65
|
+
// The Nest controllers of the context, served by the kit: their routes as the application mounts them.
|
|
66
|
+
const routes = nestControllerRoutes(wiring.controllers, { schemaOfClass: (dto) => classSchema(dto) });
|
|
67
|
+
const mounted = routes.map(({ method, path }) => `${method} ${path}`).toSorted();
|
|
68
|
+
{{/if}}
|
|
56
69
|
|
|
57
70
|
expect(mounted).toEqual([
|
|
58
71
|
'DELETE /organisations/:organisationId/delegations/:delegationId',
|