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
|
@@ -8,9 +8,6 @@ import { Authenticator } from '@ddd-ts-kit/auth';
|
|
|
8
8
|
{{/unless}}
|
|
9
9
|
{{/if}}
|
|
10
10
|
import {
|
|
11
|
-
{{#if routes.declaredControllers}}
|
|
12
|
-
DeclaredEdges,
|
|
13
|
-
{{/if}}
|
|
14
11
|
createApplication,
|
|
15
12
|
kernelModule,
|
|
16
13
|
type Application as Container,
|
|
@@ -21,19 +18,11 @@ import {
|
|
|
21
18
|
import { OutboxPublisher } from '@ddd-ts-kit/events';
|
|
22
19
|
{{/if}}
|
|
23
20
|
{{#if http.any}}
|
|
24
|
-
{
|
|
25
|
-
import { ErrorMapper, controllerRoutes, defineRoutes, type Route } from '@ddd-ts-kit/http';
|
|
26
|
-
{{/if}}
|
|
27
|
-
{{#unless routes.mountsControllers}}
|
|
28
|
-
import { ErrorMapper, defineRoutes, type Route } from '@ddd-ts-kit/http';
|
|
29
|
-
{{/unless}}
|
|
21
|
+
import { ErrorMapper, type Route } from '@ddd-ts-kit/http';
|
|
30
22
|
{{/if}}
|
|
31
23
|
import {
|
|
32
24
|
Cache,
|
|
33
25
|
Clock,
|
|
34
|
-
{{#if http.any}}
|
|
35
|
-
CommandBus,
|
|
36
|
-
{{/if}}
|
|
37
26
|
{{#if errors.sentry}}
|
|
38
27
|
{{#if http.any}}
|
|
39
28
|
ErrorReporter,
|
|
@@ -49,6 +38,9 @@ import {
|
|
|
49
38
|
{{#if files.any}}
|
|
50
39
|
InMemoryFileStorage,
|
|
51
40
|
{{/if}}
|
|
41
|
+
{{#if tenancy.any}}
|
|
42
|
+
InMemoryTenantDirectory,
|
|
43
|
+
{{/if}}
|
|
52
44
|
{{#unless broker.external}}
|
|
53
45
|
IntegrationEventSubscriber,
|
|
54
46
|
{{/unless}}
|
|
@@ -57,9 +49,6 @@ import {
|
|
|
57
49
|
{{#if httpCache.perTenant}}
|
|
58
50
|
PublishedCacheInvalidation,
|
|
59
51
|
{{/if}}
|
|
60
|
-
{{#if http.any}}
|
|
61
|
-
QueryBus,
|
|
62
|
-
{{/if}}
|
|
63
52
|
{{#if cache.rateLimit}}
|
|
64
53
|
RateLimiter,
|
|
65
54
|
{{/if}}
|
|
@@ -78,16 +67,7 @@ import { tracedPublisher } from '@ddd-ts-kit/tracing';
|
|
|
78
67
|
{{#if audit.on}}
|
|
79
68
|
import { auditModule } from '{{alias.platform}}/audit/audit.module{{alias.ext}}';
|
|
80
69
|
{{/if}}
|
|
81
|
-
{{#if audit.functionRoute}}
|
|
82
|
-
import { searchAuditEntriesRoute } from '{{alias.platform}}/audit/search-audit-entries/search-audit-entries.route{{alias.ext}}';
|
|
83
|
-
{{/if}}
|
|
84
|
-
{{#if audit.controller}}
|
|
85
|
-
import { SearchAuditEntriesController } from '{{alias.platform}}/audit/search-audit-entries/search-audit-entries.controller{{alias.ext}}';
|
|
86
|
-
{{/if}}
|
|
87
70
|
import { authorization } from '{{alias.platform}}/auth/authorization/authorization{{alias.ext}}';
|
|
88
|
-
{{#if routes.mountsControllers}}
|
|
89
|
-
import { securitySchemes } from '{{alias.platform}}/auth/authentication/security-schemes{{alias.ext}}';
|
|
90
|
-
{{/if}}
|
|
91
71
|
{{#if http.any}}
|
|
92
72
|
import { httpBoundary, type HttpBoundary } from '{{alias.platform}}/auth/authentication/http-boundary{{alias.ext}}';
|
|
93
73
|
{{/if}}
|
|
@@ -115,6 +95,10 @@ import { filesModule } from '{{alias.platform}}/files/files.module{{alias.ext}}'
|
|
|
115
95
|
{{#if privacy.on}}
|
|
116
96
|
import { privacyModule } from '{{alias.platform}}/privacy/privacy.module{{alias.ext}}';
|
|
117
97
|
{{/if}}
|
|
98
|
+
import type { ContextSelection } from '{{alias.platform}}/composition/context-selection{{alias.ext}}';
|
|
99
|
+
{{#if http.any}}
|
|
100
|
+
import { routesOf } from '{{alias.platform}}/composition/routes-of{{alias.ext}}';
|
|
101
|
+
{{/if}}
|
|
118
102
|
import { layFoundations, type Foundations } from '{{alias.platform}}/composition/lay-foundations{{alias.ext}}';
|
|
119
103
|
import { platformModule, type PlatformOptions } from '{{alias.platform}}/composition/platform.module{{alias.ext}}';
|
|
120
104
|
// ddd-ts-kit:imports
|
|
@@ -123,6 +107,12 @@ import { platformModule, type PlatformOptions } from '{{alias.platform}}/composi
|
|
|
123
107
|
export interface ApplicationOptions extends PlatformOptions {
|
|
124
108
|
/** Whether this process runs the scheduled jobs, and their settings; left out (the tools, the tests), no job runs by time. */
|
|
125
109
|
readonly jobs?: JobsOptions;
|
|
110
|
+
/** Whether the jobs of the platform itself are registered: a service passes `false`, they run in the whole application. Default `true`. */
|
|
111
|
+
readonly platformJobs?: boolean;
|
|
112
|
+
{{#if tenancy.any}}
|
|
113
|
+
/** The ids of the tenants that exist (`TENANTS`): a job declared `per-tenant` runs once for each. Left out (the tools, the tests), none, and such a job runs for nobody. */
|
|
114
|
+
readonly tenants?: readonly string[];
|
|
115
|
+
{{/if}}
|
|
126
116
|
{{#if files.any}}
|
|
127
117
|
/** Where the content of files lives: the storage of `main.ts`; left out (the tools, the tests), the memory of the process. */
|
|
128
118
|
readonly files?: FileStorage;
|
|
@@ -164,16 +154,7 @@ export interface Application {
|
|
|
164
154
|
stop(): Promise<void>;
|
|
165
155
|
}
|
|
166
156
|
|
|
167
|
-
|
|
168
|
-
export interface ContextSelection {
|
|
169
|
-
readonly modules: readonly ContextModule[];
|
|
170
|
-
{{#if http.any}}
|
|
171
|
-
/** The function routes of each context, given the two buses they call; controllers need no list. */
|
|
172
|
-
readonly routes?: readonly ((commands: CommandBus, queries: QueryBus) => readonly Route[])[];
|
|
173
|
-
{{/if}}
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
const everyContext: ContextSelection = {
|
|
157
|
+
export const everyContext: ContextSelection = {
|
|
177
158
|
modules: [
|
|
178
159
|
// ddd-ts-kit:contexts
|
|
179
160
|
// /ddd-ts-kit:contexts
|
|
@@ -186,6 +167,27 @@ const everyContext: ContextSelection = {
|
|
|
186
167
|
{{/if}}
|
|
187
168
|
};
|
|
188
169
|
|
|
170
|
+
/** The contexts run as services of their own (`generate service`): `main.ts` and the worker leave them out, routes included. */
|
|
171
|
+
const extractedModules: readonly string[] = [
|
|
172
|
+
// ddd-ts-kit:extracted
|
|
173
|
+
// /ddd-ts-kit:extracted
|
|
174
|
+
];
|
|
175
|
+
{{#if http.any}}
|
|
176
|
+
|
|
177
|
+
const extractedRoutes: NonNullable<ContextSelection['routes']> = [
|
|
178
|
+
// ddd-ts-kit:extracted-routes
|
|
179
|
+
// /ddd-ts-kit:extracted-routes
|
|
180
|
+
];
|
|
181
|
+
{{/if}}
|
|
182
|
+
|
|
183
|
+
/** What `main.ts` and the worker host; `everyContext` stays the full list for the tools, the contracts and the end-to-end tests. */
|
|
184
|
+
export const hostedContexts: ContextSelection = {
|
|
185
|
+
modules: everyContext.modules.filter((module) => !extractedModules.includes(module.name)),
|
|
186
|
+
{{#if http.any}}
|
|
187
|
+
routes: (everyContext.routes ?? []).filter((routes) => !extractedRoutes.includes(routes)),
|
|
188
|
+
{{/if}}
|
|
189
|
+
};
|
|
190
|
+
|
|
189
191
|
/** Wires the bounded contexts on the kernel and the platform. Also used to generate the contracts and by the end-to-end tests. */
|
|
190
192
|
export function composeApplication(
|
|
191
193
|
persistence: Persistence,
|
|
@@ -209,13 +211,18 @@ export function composeApplication(
|
|
|
209
211
|
{{/if}}
|
|
210
212
|
guard,
|
|
211
213
|
{{#if audit.on}}
|
|
214
|
+
{{#if audit.archive}}
|
|
215
|
+
auditModule(foundations.audit, { jobs: options.platformJobs !== false }),
|
|
216
|
+
{{/if}}
|
|
217
|
+
{{#unless audit.archive}}
|
|
212
218
|
auditModule(foundations.audit),
|
|
219
|
+
{{/unless}}
|
|
213
220
|
{{/if}}
|
|
214
221
|
{{#if files.any}}
|
|
215
|
-
filesModule(options.files ?? new InMemoryFileStorage()),
|
|
222
|
+
filesModule(options.files ?? new InMemoryFileStorage(), { jobs: options.platformJobs !== false }),
|
|
216
223
|
{{/if}}
|
|
217
224
|
{{#if privacy.on}}
|
|
218
|
-
privacyModule(),
|
|
225
|
+
privacyModule({ jobs: options.platformJobs !== false }),
|
|
219
226
|
{{/if}}
|
|
220
227
|
...contexts.modules,
|
|
221
228
|
],
|
|
@@ -257,6 +264,10 @@ function kernel(foundations: Foundations, persistence: Persistence, options: App
|
|
|
257
264
|
logger,
|
|
258
265
|
metrics,
|
|
259
266
|
eventBus: bus,
|
|
267
|
+
{{#if tenancy.any}}
|
|
268
|
+
// The tenants a job declared `per-tenant` runs for.
|
|
269
|
+
tenants: new InMemoryTenantDirectory(options.tenants ?? []),
|
|
270
|
+
{{/if}}
|
|
260
271
|
{{#if events.outbox}}
|
|
261
272
|
// Use cases publish to the outbox, in the transaction of their command; the relay of `main.ts` delivers to the provider.
|
|
262
273
|
eventPublisher: scopedPublisher(new OutboxPublisher(persistence.outbox), scope),
|
|
@@ -373,32 +384,3 @@ function running({ container, options, contexts }: Composed): Application {
|
|
|
373
384
|
stop: () => container.stop(),
|
|
374
385
|
};
|
|
375
386
|
}
|
|
376
|
-
{{#if http.any}}
|
|
377
|
-
|
|
378
|
-
function routesOf(container: Container, contexts: ContextSelection): readonly Route[] {
|
|
379
|
-
const commands = container.resolve(CommandBus);
|
|
380
|
-
const queries = container.resolve(QueryBus);
|
|
381
|
-
|
|
382
|
-
{{#unless routes.mountsControllers}}
|
|
383
|
-
return defineRoutes(...(contexts.routes ?? []).map((routes) => routes(commands, queries)){{#if audit.route}}, [searchAuditEntriesRoute(queries)]{{/if}});
|
|
384
|
-
{{/unless}}
|
|
385
|
-
{{#if routes.mountsControllers}}
|
|
386
|
-
// Every route that is not public names these schemes in the contract.
|
|
387
|
-
const security = Object.keys(securitySchemes);
|
|
388
|
-
|
|
389
|
-
return defineRoutes(
|
|
390
|
-
...(contexts.routes ?? []).map((routes) => routes(commands, queries)),
|
|
391
|
-
{{#if routes.declaredControllers}}
|
|
392
|
-
// The controllers the hosted contexts declare, each built from its constructor.
|
|
393
|
-
controllerRoutes(container.resolve(DeclaredEdges).of('controller'), { resolve: container.resolve, security }),
|
|
394
|
-
{{/if}}
|
|
395
|
-
{{#if audit.functionRoute}}
|
|
396
|
-
[searchAuditEntriesRoute(queries)],
|
|
397
|
-
{{/if}}
|
|
398
|
-
{{#if audit.controller}}
|
|
399
|
-
controllerRoutes([new SearchAuditEntriesController(queries)], { security }),
|
|
400
|
-
{{/if}}
|
|
401
|
-
);
|
|
402
|
-
{{/if}}
|
|
403
|
-
}
|
|
404
|
-
{{/if}}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{{#if http.any}}
|
|
2
|
+
import type { ContextModule } from '@ddd-ts-kit/di';
|
|
3
|
+
import type { Route } from '@ddd-ts-kit/http';
|
|
4
|
+
import type { CommandBus, QueryBus } from '@ddd-ts-kit/kernel';
|
|
5
|
+
{{/if}}
|
|
6
|
+
{{#unless http.any}}
|
|
7
|
+
import type { ContextModule } from '@ddd-ts-kit/di';
|
|
8
|
+
{{/unless}}
|
|
9
|
+
|
|
10
|
+
/** The contexts an application hosts: all of them here, one alone in `apps/<context>/main.ts`. */
|
|
11
|
+
export interface ContextSelection {
|
|
12
|
+
readonly modules: readonly ContextModule[];
|
|
13
|
+
{{#if http.any}}
|
|
14
|
+
/** The function routes of each context, given the two buses they call; controllers need no list. */
|
|
15
|
+
readonly routes?: readonly ((commands: CommandBus, queries: QueryBus) => readonly Route[])[];
|
|
16
|
+
{{/if}}
|
|
17
|
+
}
|
|
@@ -8,6 +8,9 @@ import {
|
|
|
8
8
|
{{#if cache.rateLimit}}
|
|
9
9
|
InMemoryRateLimiter,
|
|
10
10
|
{{/if}}
|
|
11
|
+
{{#if tenancy.any}}
|
|
12
|
+
InMemoryTenantDirectory,
|
|
13
|
+
{{/if}}
|
|
11
14
|
{{#if errors.sentry}}
|
|
12
15
|
NoopErrorReporter,
|
|
13
16
|
{{/if}}
|
|
@@ -114,7 +117,7 @@ export function layFoundations(persistence: Persistence, options: PlatformOption
|
|
|
114
117
|
{{#unless audit.on}}
|
|
115
118
|
decisions: logDecisions(logger),
|
|
116
119
|
{{#if eventSourcing.on}}
|
|
117
|
-
eventSourcing: createEventSourcing(persistence),
|
|
120
|
+
eventSourcing: createEventSourcing(persistence{{#if tenancy.any}}, scope{{/if}}),
|
|
118
121
|
{{/if}}
|
|
119
122
|
{{/unless}}
|
|
120
123
|
};
|
|
@@ -126,5 +129,17 @@ function schedulerOf(
|
|
|
126
129
|
traced: TracedApplication,
|
|
127
130
|
parts: InProcessJobSchedulerOptions,
|
|
128
131
|
): JobScheduler {
|
|
132
|
+
{{#if tenancy.any}}
|
|
133
|
+
// The tenants a job declared `per-tenant` runs for; left out (the tools, the tests), none.
|
|
134
|
+
const tenants = new InMemoryTenantDirectory(options.tenants ?? []);
|
|
135
|
+
|
|
136
|
+
return new ConfiguredJobScheduler(
|
|
137
|
+
new InProcessJobScheduler({ ...parts, tenants }),
|
|
138
|
+
options.jobs?.settings ?? {},
|
|
139
|
+
traced.job,
|
|
140
|
+
);
|
|
141
|
+
{{/if}}
|
|
142
|
+
{{#unless tenancy.any}}
|
|
129
143
|
return new ConfiguredJobScheduler(new InProcessJobScheduler(parts), options.jobs?.settings ?? {}, traced.job);
|
|
144
|
+
{{/unless}}
|
|
130
145
|
}
|
|
@@ -83,7 +83,7 @@ export function layFoundations(persistence: Persistence, options: Observed): Fou
|
|
|
83
83
|
{{#unless audit.on}}
|
|
84
84
|
decisions: logDecisions(logger),
|
|
85
85
|
{{#if eventSourcing.on}}
|
|
86
|
-
eventSourcing: createEventSourcing(persistence),
|
|
86
|
+
eventSourcing: createEventSourcing(persistence{{#if tenancy.any}}, scope{{/if}}),
|
|
87
87
|
{{/if}}
|
|
88
88
|
{{/unless}}
|
|
89
89
|
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { createErrorMapper, type ErrorMapper } from '@ddd-ts-kit/http';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* What a refusal becomes on the wire. The application and the test platform bind this one mapper,
|
|
5
|
+
* so a route spec answers what the running application answers: map your own errors here, once.
|
|
6
|
+
*/
|
|
7
|
+
export function platformErrorMapper(): ErrorMapper {
|
|
8
|
+
return createErrorMapper();
|
|
9
|
+
}
|
|
@@ -43,6 +43,15 @@ export interface PlatformOptions {
|
|
|
43
43
|
readonly resilience?: ResilienceSettings;
|
|
44
44
|
/** Whether this process runs the scheduled jobs and consumes the background jobs, and the settings of the scheduled ones; left out (the tools, the tests), no job runs by time. */
|
|
45
45
|
readonly jobs?: JobsOptions;
|
|
46
|
+
/**
|
|
47
|
+
* Whether this composition registers the jobs of the platform itself. They belong to one process of a deployment, the
|
|
48
|
+
* whole application: a service passes `false`, or each of its containers would run them on the same database. Default: `true`.
|
|
49
|
+
*/
|
|
50
|
+
readonly platformJobs?: boolean;
|
|
51
|
+
{{#if tenancy.any}}
|
|
52
|
+
/** The ids of the tenants that exist (`TENANTS`): a job declared `per-tenant` runs once for each. Left out (the tools, the tests), none, and such a job runs for nobody. */
|
|
53
|
+
readonly tenants?: readonly string[];
|
|
54
|
+
{{/if}}
|
|
46
55
|
/** Concurrency per queue, polling interval and grace period of the worker of the background jobs; left out, one attempt at a time per queue. */
|
|
47
56
|
readonly queues?: Pick<QueueWorkerOptions, 'concurrency' | 'pollIntervalMs' | 'graceMs'>;
|
|
48
57
|
/** Whether a consumed event continues the trace of its publication (the default) or starts one linked to it. */
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
{{#if http.any}}
|
|
2
|
+
import { ErrorMapper } from '@ddd-ts-kit/http';
|
|
3
|
+
{{/if}}
|
|
1
4
|
{{#if eventSourcing.on}}
|
|
2
5
|
import { defineContextModule, type ModuleBuilder } from '@ddd-ts-kit/di';
|
|
3
6
|
import {
|
|
@@ -21,6 +24,9 @@ import { defineContextModule } from '@ddd-ts-kit/di';
|
|
|
21
24
|
import { InMemoryFileStorage } from '@ddd-ts-kit/kernel';
|
|
22
25
|
{{/if}}
|
|
23
26
|
{{/unless}}
|
|
27
|
+
{{#if http.any}}
|
|
28
|
+
import { platformErrorMapper } from '{{alias.platform}}/composition/platform-error-mapper{{alias.ext}}';
|
|
29
|
+
{{/if}}
|
|
24
30
|
{{#if persistence.packagedToken}}
|
|
25
31
|
import { {{persistence.token}} } from '{{persistence.tokenPackage}}';
|
|
26
32
|
{{/if}}
|
|
@@ -42,6 +48,11 @@ export const platformTestModule = defineContextModule({
|
|
|
42
48
|
throw new Error('A handler spec has no database: give a fake for the repository it uses.');
|
|
43
49
|
});
|
|
44
50
|
|
|
51
|
+
{{/if}}
|
|
52
|
+
{{#if http.any}}
|
|
53
|
+
// The mapper of the application: a route spec answers what the running application answers.
|
|
54
|
+
builder.bind(ErrorMapper).toValue(platformErrorMapper());
|
|
55
|
+
|
|
45
56
|
{{/if}}
|
|
46
57
|
{{#if files.any}}
|
|
47
58
|
// The files a handler spec stores stay in the memory of the test.
|
|
@@ -11,7 +11,7 @@ import { defineContextModule, type ContextModule } from '@ddd-ts-kit/di';
|
|
|
11
11
|
import { OutboxStore } from '@ddd-ts-kit/events';
|
|
12
12
|
{{/if}}
|
|
13
13
|
{{#if http.any}}
|
|
14
|
-
import { ErrorMapper
|
|
14
|
+
import { ErrorMapper } from '@ddd-ts-kit/http';
|
|
15
15
|
{{/if}}
|
|
16
16
|
{{#if cache.redis}}
|
|
17
17
|
{{#if broker.external}}
|
|
@@ -79,6 +79,9 @@ import { Database } from '{{alias.platform}}/database/database{{alias.ext}}';
|
|
|
79
79
|
{{/if}}
|
|
80
80
|
import type { ConsumerTrace } from '@ddd-ts-kit/tracing';
|
|
81
81
|
import type { Persistence } from '{{alias.platform}}/database/persistence{{alias.ext}}';
|
|
82
|
+
{{#if http.any}}
|
|
83
|
+
import { platformErrorMapper } from '{{alias.platform}}/composition/platform-error-mapper{{alias.ext}}';
|
|
84
|
+
{{/if}}
|
|
82
85
|
import type { EventProvider } from '{{alias.platform}}/events/event-provider{{alias.ext}}';
|
|
83
86
|
import type { LogSettings } from '{{alias.platform}}/observability/create-logger{{alias.ext}}';
|
|
84
87
|
{{#if cache.redis}}
|
|
@@ -153,7 +156,7 @@ export function platformModule(persistence: Persistence, options: PlatformOption
|
|
|
153
156
|
builder.rebind(EventSubscribers).toValue({ forContext: (name) => options.events.forConsumer(name) });
|
|
154
157
|
{{/if}}
|
|
155
158
|
{{#if http.any}}
|
|
156
|
-
builder.bind(ErrorMapper).toValue(
|
|
159
|
+
builder.bind(ErrorMapper).toValue(platformErrorMapper());
|
|
157
160
|
{{/if}}
|
|
158
161
|
// Cross-cutting behaviour stays out of the contexts. Inside the span and the dispatch the kernel module puts around a binding, outside the aspects a binding states for itself (`ownPolicy`).
|
|
159
162
|
builder.around(['external', 'gateway'], () => defaultPolicy(options.resilience ?? defaultResilienceSettings));
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{{#if routes.declaredControllers}}
|
|
2
|
+
import { DeclaredEdges, type Application as Container } from '@ddd-ts-kit/di';
|
|
3
|
+
{{/if}}
|
|
4
|
+
{{#unless routes.declaredControllers}}
|
|
5
|
+
import type { Application as Container } from '@ddd-ts-kit/di';
|
|
6
|
+
{{/unless}}
|
|
7
|
+
{{#if routes.mountsControllers}}
|
|
8
|
+
import { controllerRoutes, defineRoutes, type Route } from '@ddd-ts-kit/http';
|
|
9
|
+
{{/if}}
|
|
10
|
+
{{#unless routes.mountsControllers}}
|
|
11
|
+
import { defineRoutes, type Route } from '@ddd-ts-kit/http';
|
|
12
|
+
{{/unless}}
|
|
13
|
+
import { CommandBus, QueryBus } from '@ddd-ts-kit/kernel';
|
|
14
|
+
{{#if audit.functionRoute}}
|
|
15
|
+
import { searchAuditEntriesRoute } from '{{alias.platform}}/audit/search-audit-entries/search-audit-entries.route{{alias.ext}}';
|
|
16
|
+
{{/if}}
|
|
17
|
+
{{#if audit.controller}}
|
|
18
|
+
import { SearchAuditEntriesController } from '{{alias.platform}}/audit/search-audit-entries/search-audit-entries.controller{{alias.ext}}';
|
|
19
|
+
{{/if}}
|
|
20
|
+
{{#if routes.mountsControllers}}
|
|
21
|
+
import { securitySchemes } from '{{alias.platform}}/auth/authentication/security-schemes{{alias.ext}}';
|
|
22
|
+
{{/if}}
|
|
23
|
+
import type { ContextSelection } from '{{alias.platform}}/composition/context-selection{{alias.ext}}';
|
|
24
|
+
|
|
25
|
+
/** Every route of the hosted contexts, and the ones of the platform. */
|
|
26
|
+
export function routesOf(container: Container, contexts: ContextSelection): readonly Route[] {
|
|
27
|
+
const commands = container.resolve(CommandBus);
|
|
28
|
+
const queries = container.resolve(QueryBus);
|
|
29
|
+
|
|
30
|
+
{{#unless routes.mountsControllers}}
|
|
31
|
+
return defineRoutes(...(contexts.routes ?? []).map((routes) => routes(commands, queries)){{#if audit.route}}, [searchAuditEntriesRoute(queries)]{{/if}});
|
|
32
|
+
{{/unless}}
|
|
33
|
+
{{#if routes.mountsControllers}}
|
|
34
|
+
// Every route that is not public names these schemes in the contract.
|
|
35
|
+
const security = Object.keys(securitySchemes);
|
|
36
|
+
|
|
37
|
+
return defineRoutes(
|
|
38
|
+
...(contexts.routes ?? []).map((routes) => routes(commands, queries)),
|
|
39
|
+
{{#if routes.declaredControllers}}
|
|
40
|
+
// The controllers the hosted contexts declare, each built from its constructor.
|
|
41
|
+
controllerRoutes(container.resolve(DeclaredEdges).of('controller'), { resolve: container.resolve, security }),
|
|
42
|
+
{{/if}}
|
|
43
|
+
{{#if audit.functionRoute}}
|
|
44
|
+
[searchAuditEntriesRoute(queries)],
|
|
45
|
+
{{/if}}
|
|
46
|
+
{{#if audit.controller}}
|
|
47
|
+
controllerRoutes([new SearchAuditEntriesController(queries)], { security }),
|
|
48
|
+
{{/if}}
|
|
49
|
+
);
|
|
50
|
+
{{/if}}
|
|
51
|
+
}
|
|
@@ -12,7 +12,10 @@ import type { TracingConfig } from '{{alias.platform}}/config/read-tracing{{alia
|
|
|
12
12
|
|
|
13
13
|
/** The validated configuration of the process: `loadConfig` is the only reader of the environment. */
|
|
14
14
|
export interface AppConfig {
|
|
15
|
+
/** What this process is called in traces and logs (`OTEL_SERVICE_NAME`): one per container, so it tells the processes of a deployment apart. */
|
|
15
16
|
readonly serviceName: string;
|
|
17
|
+
/** What the processes of one deployment share (`DEPLOYMENT_NAME`, the name of the project when left out): the namespace of the keys they exchange through the server, never `serviceName`. */
|
|
18
|
+
readonly deploymentName: string;
|
|
16
19
|
readonly serviceVersion: string;
|
|
17
20
|
readonly environment: 'development' | 'test' | 'production';
|
|
18
21
|
readonly port: number;
|
|
@@ -23,6 +26,10 @@ export interface AppConfig {
|
|
|
23
26
|
readonly resilience: ResilienceSettings;
|
|
24
27
|
/** Whether this process runs the scheduled jobs (`RUN_JOBS`): off for the API of a project that has a worker. */
|
|
25
28
|
readonly runJobs: boolean;
|
|
29
|
+
{{#if tenancy.any}}
|
|
30
|
+
/** The tenants that exist (`TENANTS`, comma separated): a job declared `per-tenant` runs once for each. Bind a directory of your own in `main.ts` once the tenants live in a table. */
|
|
31
|
+
readonly tenants: readonly string[];
|
|
32
|
+
{{/if}}
|
|
26
33
|
{{#if persistence.needsUrl}}
|
|
27
34
|
readonly databaseUrl: string;
|
|
28
35
|
{{/if}}
|
|
@@ -32,7 +39,7 @@ export interface AppConfig {
|
|
|
32
39
|
{{#if docs.any}}
|
|
33
40
|
readonly docsEnabled: boolean;
|
|
34
41
|
{{/if}}
|
|
35
|
-
{{#if authn.
|
|
42
|
+
{{#if authn.jwks}}
|
|
36
43
|
readonly auth: AuthConfig;
|
|
37
44
|
{{/if}}
|
|
38
45
|
{{#if authn.keycloak}}
|
|
@@ -99,7 +106,7 @@ interface KeycloakConfig {
|
|
|
99
106
|
readonly clientId?: string;
|
|
100
107
|
}
|
|
101
108
|
{{/if}}
|
|
102
|
-
{{#if authn.
|
|
109
|
+
{{#if authn.jwks}}
|
|
103
110
|
|
|
104
111
|
/** Where tokens come from and whom they are for: the issuer, the audience this service answers to, the keys of the issuer. */
|
|
105
112
|
interface AuthConfig {
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
+
{{#if tenancy.any}}
|
|
2
|
+
import { LOG_LEVELS, isTenantId } from '@ddd-ts-kit/kernel';
|
|
3
|
+
{{/if}}
|
|
4
|
+
{{#unless tenancy.any}}
|
|
1
5
|
import { LOG_LEVELS } from '@ddd-ts-kit/kernel';
|
|
6
|
+
{{/unless}}
|
|
2
7
|
import type { AppConfig } from '{{alias.platform}}/config/app-config{{alias.ext}}';
|
|
3
8
|
import { Environment, type Variables } from '{{alias.platform}}/config/environment{{alias.ext}}';
|
|
4
9
|
{{#if files.any}}
|
|
@@ -28,6 +33,7 @@ export function loadConfig(variables: Variables): AppConfig {
|
|
|
28
33
|
|
|
29
34
|
const config: AppConfig = {
|
|
30
35
|
serviceName: env.optional('OTEL_SERVICE_NAME') ?? '{{project.name}}',
|
|
36
|
+
deploymentName: env.optional('DEPLOYMENT_NAME') ?? '{{project.name}}',
|
|
31
37
|
serviceVersion: env.optional('SERVICE_VERSION') ?? '0.0.0',
|
|
32
38
|
environment,
|
|
33
39
|
port: env.integer('PORT', { fallback: 3000, min: 0, max: 65535 }),
|
|
@@ -35,6 +41,9 @@ export function loadConfig(variables: Variables): AppConfig {
|
|
|
35
41
|
tracing: readTracing(env),
|
|
36
42
|
resilience: readResilience(env),
|
|
37
43
|
runJobs: env.flag('RUN_JOBS', runJobsByDefault),
|
|
44
|
+
{{#if tenancy.any}}
|
|
45
|
+
tenants: readTenants(env),
|
|
46
|
+
{{/if}}
|
|
38
47
|
{{#if persistence.needsUrl}}
|
|
39
48
|
databaseUrl: env.url('DATABASE_URL'),
|
|
40
49
|
{{/if}}
|
|
@@ -47,7 +56,7 @@ export function loadConfig(variables: Variables): AppConfig {
|
|
|
47
56
|
{{#if broker.addressed}}
|
|
48
57
|
{{broker.key}}: env.{{broker.reader}}('{{broker.variable}}'),
|
|
49
58
|
{{/if}}
|
|
50
|
-
{{#if authn.
|
|
59
|
+
{{#if authn.jwks}}
|
|
51
60
|
auth: readAuth(env),
|
|
52
61
|
{{/if}}
|
|
53
62
|
{{#if authn.keycloak}}
|
|
@@ -79,6 +88,22 @@ export function loadConfig(variables: Variables): AppConfig {
|
|
|
79
88
|
return config;
|
|
80
89
|
}
|
|
81
90
|
|
|
91
|
+
{{#if tenancy.any}}
|
|
92
|
+
/** `TENANTS=acme,globex`: each id in the grammar of a tenant id. */
|
|
93
|
+
function readTenants(env: Environment): readonly string[] {
|
|
94
|
+
const tenants = (env.optional('TENANTS') ?? '')
|
|
95
|
+
.split(',')
|
|
96
|
+
.map((tenant) => tenant.trim())
|
|
97
|
+
.filter((tenant) => tenant !== '');
|
|
98
|
+
|
|
99
|
+
if (!tenants.every(isTenantId)) {
|
|
100
|
+
env.problem('TENANTS must list tenant ids: letters, digits, _ and -, at most 63 characters each');
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return tenants;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
{{/if}}
|
|
82
107
|
function readLog(env: Environment): AppConfig['log'] {
|
|
83
108
|
return {
|
|
84
109
|
level: env.oneOf('LOG_LEVEL', LOG_LEVELS, 'info'),
|
|
@@ -134,7 +159,7 @@ function readErrorReporting(env: Environment, environment: string): AppConfig['e
|
|
|
134
159
|
};
|
|
135
160
|
}
|
|
136
161
|
{{/if}}
|
|
137
|
-
{{#if authn.
|
|
162
|
+
{{#if authn.jwks}}
|
|
138
163
|
|
|
139
164
|
function readAuth(env: Environment): AppConfig['auth'] {
|
|
140
165
|
return {
|
|
@@ -43,12 +43,22 @@ export function openPersistence(): Persistence {
|
|
|
43
43
|
{{/unless}}
|
|
44
44
|
processedEvents: new InMemoryProcessedEventStore(),
|
|
45
45
|
{{#if eventSourcing.on}}
|
|
46
|
+
{{#if tenancy.any}}
|
|
47
|
+
eventSourcing: (scope) => ({
|
|
48
|
+
events: new InMemoryEventStore(scope),
|
|
49
|
+
snapshots: new InMemorySnapshotStore(),
|
|
50
|
+
checkpoints: new InMemoryCheckpointStore(),
|
|
51
|
+
subjectKeys: new InMemorySubjectKeyStore(),
|
|
52
|
+
}),
|
|
53
|
+
{{/if}}
|
|
54
|
+
{{#unless tenancy.any}}
|
|
46
55
|
eventSourcing: {
|
|
47
56
|
events: new InMemoryEventStore(),
|
|
48
57
|
snapshots: new InMemorySnapshotStore(),
|
|
49
58
|
checkpoints: new InMemoryCheckpointStore(),
|
|
50
59
|
subjectKeys: new InMemorySubjectKeyStore(),
|
|
51
60
|
},
|
|
61
|
+
{{/unless}}
|
|
52
62
|
{{/if}}
|
|
53
63
|
close: () => Promise.resolve(),
|
|
54
64
|
};
|
|
@@ -45,7 +45,12 @@ export function persistenceOver(connection: DatabaseConnection): Persistence {
|
|
|
45
45
|
processes: ({{#if tenancy.any}}tenant{{/if}}) => new DrizzleProcessStore(unitOfWork, { table: processes{{#if tenancy.any}}, tenant{{/if}} }),
|
|
46
46
|
{{/if}}
|
|
47
47
|
{{#if eventSourcing.on}}
|
|
48
|
+
{{#if tenancy.any}}
|
|
49
|
+
eventSourcing: (scope) => createDrizzleEventSourcing(unitOfWork, { schema: EVENT_STORE_SCHEMA, scope }),
|
|
50
|
+
{{/if}}
|
|
51
|
+
{{#unless tenancy.any}}
|
|
48
52
|
eventSourcing: createDrizzleEventSourcing(unitOfWork, { schema: EVENT_STORE_SCHEMA }),
|
|
53
|
+
{{/unless}}
|
|
49
54
|
{{/if}}
|
|
50
55
|
close: () => connection.close(),
|
|
51
56
|
};
|
|
@@ -51,7 +51,12 @@ export function persistenceOver(connection: DatabaseConnection): Persistence {
|
|
|
51
51
|
processes: ({{#if tenancy.any}}tenant{{/if}}) => new KnexProcessStore(unitOfWork, { schema: MESSAGING_SCHEMA{{#if tenancy.any}}, tenant{{/if}} }),
|
|
52
52
|
{{/if}}
|
|
53
53
|
{{#if eventSourcing.on}}
|
|
54
|
+
{{#if tenancy.any}}
|
|
55
|
+
eventSourcing: (scope) => createKnexEventSourcing(unitOfWork, { schema: EVENT_STORE_SCHEMA, scope }),
|
|
56
|
+
{{/if}}
|
|
57
|
+
{{#unless tenancy.any}}
|
|
54
58
|
eventSourcing: createKnexEventSourcing(unitOfWork, { schema: EVENT_STORE_SCHEMA }),
|
|
59
|
+
{{/unless}}
|
|
55
60
|
{{/if}}
|
|
56
61
|
close: () => connection.close(),
|
|
57
62
|
};
|
|
@@ -66,7 +66,12 @@ export function persistenceOver(client: PrismaClient): Persistence {
|
|
|
66
66
|
{{/unless}}
|
|
67
67
|
{{/if}}
|
|
68
68
|
{{#if eventSourcing.on}}
|
|
69
|
+
{{#if tenancy.any}}
|
|
70
|
+
eventSourcing: (scope) => createPrismaEventSourcing(unitOfWork, { schema: EVENT_STORE_SCHEMA, scope }),
|
|
71
|
+
{{/if}}
|
|
72
|
+
{{#unless tenancy.any}}
|
|
69
73
|
eventSourcing: createPrismaEventSourcing(unitOfWork, { schema: EVENT_STORE_SCHEMA }),
|
|
74
|
+
{{/unless}}
|
|
70
75
|
{{/if}}
|
|
71
76
|
close: () => client.$disconnect(),
|
|
72
77
|
};
|
|
@@ -45,7 +45,12 @@ export function persistenceOver(dataSource: DataSource): Persistence {
|
|
|
45
45
|
processes: ({{#if tenancy.any}}tenant{{/if}}) => new TypeOrmProcessStore(unitOfWork, { entity: processes{{#if tenancy.any}}, tenant{{/if}} }),
|
|
46
46
|
{{/if}}
|
|
47
47
|
{{#if eventSourcing.on}}
|
|
48
|
+
{{#if tenancy.any}}
|
|
49
|
+
eventSourcing: (scope) => createTypeOrmEventSourcing(unitOfWork, { schema: EVENT_STORE_SCHEMA, scope }),
|
|
50
|
+
{{/if}}
|
|
51
|
+
{{#unless tenancy.any}}
|
|
48
52
|
eventSourcing: createTypeOrmEventSourcing(unitOfWork, { schema: EVENT_STORE_SCHEMA }),
|
|
53
|
+
{{/unless}}
|
|
49
54
|
{{/if}}
|
|
50
55
|
close: async () => {
|
|
51
56
|
if (dataSource.isInitialized) {
|
|
@@ -2,6 +2,13 @@ import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it } from
|
|
|
2
2
|
{{#if queue.processTable}}
|
|
3
3
|
import { FixedExecutionScope, executionContext, systemActor } from '@ddd-ts-kit/kernel';
|
|
4
4
|
{{/if}}
|
|
5
|
+
{{#unless queue.processTable}}
|
|
6
|
+
{{#if tenancy.any}}
|
|
7
|
+
{{#if eventSourcing.on}}
|
|
8
|
+
import { FixedExecutionScope } from '@ddd-ts-kit/kernel';
|
|
9
|
+
{{/if}}
|
|
10
|
+
{{/if}}
|
|
11
|
+
{{/unless}}
|
|
5
12
|
{{#if queue.database}}
|
|
6
13
|
import {
|
|
7
14
|
{{#if eventSourcing.on}}
|
|
@@ -66,8 +73,19 @@ processedEventStoreContract(runner, {
|
|
|
66
73
|
|
|
67
74
|
eventStoreContract(runner, {
|
|
68
75
|
name: 'The event store of the platform',
|
|
76
|
+
{{#if tenancy.any}}
|
|
77
|
+
createStore: async () => (await emptied()).eventSourcing(new FixedExecutionScope()).events,
|
|
78
|
+
createCompanions: async () => (await emptied()).eventSourcing(new FixedExecutionScope()),
|
|
79
|
+
createTenantStore: async () => {
|
|
80
|
+
const scope = new FixedExecutionScope();
|
|
81
|
+
|
|
82
|
+
return { scope, store: (await emptied()).eventSourcing(scope).events };
|
|
83
|
+
},
|
|
84
|
+
{{/if}}
|
|
85
|
+
{{#unless tenancy.any}}
|
|
69
86
|
createStore: async () => (await emptied()).eventSourcing.events,
|
|
70
87
|
createCompanions: async () => (await emptied()).eventSourcing,
|
|
88
|
+
{{/unless}}
|
|
71
89
|
});
|
|
72
90
|
{{/if}}
|
|
73
91
|
{{#if queue.database}}
|
|
@@ -5,7 +5,7 @@ import type { OutboxStore, RelaySignal } from '@ddd-ts-kit/events';
|
|
|
5
5
|
import type { OutboxStore } from '@ddd-ts-kit/events';
|
|
6
6
|
{{/unless}}
|
|
7
7
|
{{#if eventSourcing.on}}
|
|
8
|
-
import type { EventSourcingStores, ProcessedEventStore, UnitOfWork } from '@ddd-ts-kit/kernel';
|
|
8
|
+
import type { EventSourcingStores, {{#if tenancy.any}}ExecutionScope, {{/if}}ProcessedEventStore, UnitOfWork } from '@ddd-ts-kit/kernel';
|
|
9
9
|
{{/if}}
|
|
10
10
|
{{#unless eventSourcing.on}}
|
|
11
11
|
import type { ProcessedEventStore, UnitOfWork } from '@ddd-ts-kit/kernel';
|
|
@@ -22,7 +22,13 @@ export interface Persistence {
|
|
|
22
22
|
readonly processedEvents: ProcessedEventStore;
|
|
23
23
|
{{#if eventSourcing.on}}
|
|
24
24
|
/** The event store, the snapshots, the checkpoints and the keys of the data subjects: what an event-sourced aggregate is saved through, and what seals its personal values. */
|
|
25
|
+
{{#if tenancy.any}}
|
|
26
|
+
/** Given the execution scope, each stream keeps the tenant of the work that first appended to it. */
|
|
27
|
+
readonly eventSourcing: (scope: ExecutionScope) => EventSourcingStores;
|
|
28
|
+
{{/if}}
|
|
29
|
+
{{#unless tenancy.any}}
|
|
25
30
|
readonly eventSourcing: EventSourcingStores;
|
|
31
|
+
{{/unless}}
|
|
26
32
|
{{/if}}
|
|
27
33
|
|
|
28
34
|
close(): Promise<void>;
|