ddd-ts-kit 0.91.0 → 0.92.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 +189 -0
- package/README.fr.md +16 -12
- package/README.md +15 -10
- 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/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/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 +2 -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/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/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/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 +2 -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/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/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/platform-files.js +1 -0
- 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/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 +3 -0
- package/dist/platform-layout/platform-layout.d.ts.map +1 -1
- package/dist/platform-layout/platform-layout.js +3 -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/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/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/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 +1 -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/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 +5 -2
- package/templates/init/platform/composition/lay-foundations.manual.ts.tpl +1 -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-test.module.tsyringe.ts.tpl +11 -0
- package/templates/init/platform/composition/platform.module.tsyringe.ts.tpl +5 -2
- package/templates/init/platform/config/app-config.ts.tpl +2 -2
- package/templates/init/platform/config/load-config.ts.tpl +2 -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/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/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/wiring.manual.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 +2 -2
- package/templates/pipeline/eslint.config.mjs.tpl +6 -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/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
package/dist/migration/index.js
CHANGED
|
@@ -3,4 +3,12 @@ export { generateDrizzleMigration } from './generate-drizzle-migration.js';
|
|
|
3
3
|
export { primaryKeyOrderFindings } from './primary-key-order-findings.js';
|
|
4
4
|
export { replayDrizzleMigrations } from './replay-drizzle-migrations.js';
|
|
5
5
|
export { tidyWrittenMigration } from './tidy-written-migration.js';
|
|
6
|
+
export { appendAuditGuard } from './audit-guard/append-audit-guard.js';
|
|
7
|
+
export { auditGuardStatementsOf } from './audit-guard/audit-guard-statements-of.js';
|
|
8
|
+
export { generateGuarded } from './audit-guard/generate-guarded.js';
|
|
9
|
+
export { runOrmTool } from './audit-guard/run-orm-tool.js';
|
|
10
|
+
export { formatAsTheProject } from './format-as-the-project.js';
|
|
11
|
+
export { typeOnlyImports } from './audit-guard/type-only-imports.js';
|
|
12
|
+
export { schemasFirst } from './audit-guard/schemas-first.js';
|
|
13
|
+
export { schemasIfMissing } from './audit-guard/schemas-if-missing.js';
|
|
6
14
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/migration/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/migration/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAC;AACjF,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC"}
|
|
@@ -1,16 +1,8 @@
|
|
|
1
|
+
import type { NestReadType } from './nest-read-type.js';
|
|
1
2
|
/** What a method of a Nest controller answers, as its signature says it. */
|
|
2
3
|
export type NestAnswer = {
|
|
3
4
|
readonly kind: 'none';
|
|
4
5
|
} | {
|
|
5
6
|
readonly kind: 'accepted';
|
|
6
|
-
} |
|
|
7
|
-
readonly kind: 'class';
|
|
8
|
-
readonly name: string;
|
|
9
|
-
readonly specifier: string;
|
|
10
|
-
}
|
|
11
|
-
/** A type the kit cannot turn into a schema (an array, a type written inline, an interface), or no type at all. */
|
|
12
|
-
| {
|
|
13
|
-
readonly kind: 'unread';
|
|
14
|
-
readonly text: string;
|
|
15
|
-
};
|
|
7
|
+
} | NestReadType;
|
|
16
8
|
//# sourceMappingURL=nest-answer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nest-answer.d.ts","sourceRoot":"","sources":["../../src/nest-controllers/nest-answer.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"nest-answer.d.ts","sourceRoot":"","sources":["../../src/nest-controllers/nest-answer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAErD,4EAA4E;AAC5E,MAAM,MAAM,UAAU,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAA;CAAE,GAAG,YAAY,CAAC"}
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import type { NestAnswer } from './nest-answer.js';
|
|
2
|
-
|
|
2
|
+
import type { NestRequestPart } from './nest-request-part.js';
|
|
3
|
+
/** A Nest controller of a context the kit serves, and what the signature of each of its route methods says. */
|
|
3
4
|
export interface NestControllerEntry {
|
|
4
5
|
readonly file: string;
|
|
5
6
|
readonly className: string;
|
|
6
7
|
readonly specifier: string;
|
|
7
8
|
readonly methods: readonly NestRouteMethod[];
|
|
8
9
|
}
|
|
9
|
-
/** A route method of a Nest controller: what its signature says it answers, and whether `@KitRoute` says
|
|
10
|
+
/** A route method of a Nest controller: what its signature says it takes and answers, and whether `@KitRoute` says its answer instead. */
|
|
10
11
|
export interface NestRouteMethod {
|
|
11
12
|
readonly name: string;
|
|
12
13
|
readonly line: number;
|
|
14
|
+
readonly request: readonly NestRequestPart[];
|
|
13
15
|
readonly answer: NestAnswer;
|
|
14
16
|
readonly declaresResponse: boolean;
|
|
15
17
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nest-controller-entry.d.ts","sourceRoot":"","sources":["../../src/nest-controllers/nest-controller-entry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"nest-controller-entry.d.ts","sourceRoot":"","sources":["../../src/nest-controllers/nest-controller-entry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAE3D,+GAA+G;AAC/G,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,SAAS,eAAe,EAAE,CAAC;CAC9C;AAED,0IAA0I;AAC1I,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,SAAS,eAAe,EAAE,CAAC;IAC7C,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAC5B,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAC;CACpC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Config } from '../config/index.js';
|
|
2
|
+
import type { NestControllerEntry } from './nest-controller-entry.js';
|
|
3
|
+
import type { ProjectFiles } from './project-files.js';
|
|
4
|
+
/** The Nest controllers the kit serves in one file, with what the signature of each route method says. */
|
|
5
|
+
export declare function nestControllersIn(files: ProjectFiles, config: Config, file: string): NestControllerEntry[];
|
|
6
|
+
//# sourceMappingURL=nest-controllers-in.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nest-controllers-in.d.ts","sourceRoot":"","sources":["../../src/nest-controllers/nest-controllers-in.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAExC,OAAO,KAAK,EAAE,mBAAmB,EAAmB,MAAM,yBAAyB,CAAC;AAIpF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAuBpD,0GAA0G;AAC1G,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,mBAAmB,EAAE,CAqB1G"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { specifierOf } from '../alias/index.js';
|
|
2
|
+
import { aliasRoots } from '../alias/alias-roots.js';
|
|
3
|
+
import { scan } from '../check/scan/scan.js';
|
|
4
|
+
import { readStructure } from '../check/structure/read-structure.js';
|
|
5
|
+
import { parametersOf } from './parameters-of.js';
|
|
6
|
+
const NEST = '@nestjs/common';
|
|
7
|
+
const BRIDGE = '@ddd-ts-kit/http/nest';
|
|
8
|
+
const ROUTE_DECORATOR = /@(?:Get|Post|Put|Patch|Delete|Head|Options)\s*\(/;
|
|
9
|
+
const RETURN_TYPE = /\)\s*:\s*([\s\S]+?)\s*$/;
|
|
10
|
+
const PROMISED = /^Promise\s*<([\s\S]+)>$/;
|
|
11
|
+
const TYPE_NAME = /^[A-Z][\w$]*$/;
|
|
12
|
+
const CONTROLLER = /@Controller\s*\(/;
|
|
13
|
+
const DECLARED_RESPONSE = /@KitRoute\s*\(\s*\{[\s\S]*\bresponse\s*:/;
|
|
14
|
+
const DECLARED_REQUEST = /@KitRoute\s*\(\s*\{[\s\S]*\brequest\s*:\s*\{([^}]*)\}/;
|
|
15
|
+
/** A parameter that takes a part of the request whole: `@Body() body: IssueInvoiceBody`. */
|
|
16
|
+
const WHOLE_PART = /^@(Body|Query|Param|Headers)\s*\(\s*\)\s*(?:(?:public|private|protected|readonly)\s+)*[\w$]+\??\s*:\s*([\s\S]+)$/;
|
|
17
|
+
const SOURCES = {
|
|
18
|
+
Body: 'body',
|
|
19
|
+
Query: 'query',
|
|
20
|
+
Param: 'params',
|
|
21
|
+
Headers: 'headers',
|
|
22
|
+
};
|
|
23
|
+
/** The Nest controllers the kit serves in one file, with what the signature of each route method says. */
|
|
24
|
+
export function nestControllersIn(files, config, file) {
|
|
25
|
+
const text = files.read(file) ?? '';
|
|
26
|
+
const scanned = scan(text);
|
|
27
|
+
const { imports } = scanned;
|
|
28
|
+
if (!imports.some(({ specifier }) => specifier === NEST) || !imports.some(({ specifier }) => specifier === BRIDGE)) {
|
|
29
|
+
return [];
|
|
30
|
+
}
|
|
31
|
+
const reading = { files, config, imports, text, code: scanned.code };
|
|
32
|
+
return readStructure(scanned)
|
|
33
|
+
.classes.filter(({ isExported, start }) => isExported && CONTROLLER.test(scanned.code.slice(Math.max(0, start - 400), start)))
|
|
34
|
+
.map((shape) => ({
|
|
35
|
+
file,
|
|
36
|
+
className: shape.name,
|
|
37
|
+
specifier: specifierOf(config, file),
|
|
38
|
+
methods: routeMethodsOf(shape, reading),
|
|
39
|
+
}));
|
|
40
|
+
}
|
|
41
|
+
/** The methods of the class that carry a route decorator of Nest, each with what its signature takes and answers. */
|
|
42
|
+
function routeMethodsOf(shape, reading) {
|
|
43
|
+
let previous = shape.bodyStart;
|
|
44
|
+
return shape.methods.flatMap((method) => {
|
|
45
|
+
const decorators = reading.code.slice(previous, method.start);
|
|
46
|
+
previous = method.end;
|
|
47
|
+
if (method.isConstructor || !ROUTE_DECORATOR.test(decorators)) {
|
|
48
|
+
return [];
|
|
49
|
+
}
|
|
50
|
+
const signature = reading.text.slice(method.start, method.bodyStart);
|
|
51
|
+
const written = RETURN_TYPE.exec(signature)?.[1];
|
|
52
|
+
return [
|
|
53
|
+
{
|
|
54
|
+
name: method.name,
|
|
55
|
+
line: method.line,
|
|
56
|
+
request: requestOf(method, decorators, reading),
|
|
57
|
+
answer: written === undefined ? { kind: 'unread', text: 'no return type' } : answerOf(written, reading),
|
|
58
|
+
declaresResponse: DECLARED_RESPONSE.test(decorators),
|
|
59
|
+
},
|
|
60
|
+
];
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
/** The parts of the request the parameters take whole, each with its type and whether `@KitRoute` gives it. */
|
|
64
|
+
function requestOf({ start, bodyStart }, decorators, reading) {
|
|
65
|
+
const declared = DECLARED_REQUEST.exec(decorators)?.[1] ?? '';
|
|
66
|
+
return parametersOf(reading.text.slice(start, bodyStart), reading.code.slice(start, bodyStart)).flatMap((parameter) => {
|
|
67
|
+
const [, decorator = '', type = ''] = WHOLE_PART.exec(parameter) ?? [];
|
|
68
|
+
const source = SOURCES[decorator];
|
|
69
|
+
return source === undefined
|
|
70
|
+
? []
|
|
71
|
+
: [{ source, type: typeOf(type.trim(), reading), declared: givesPart(declared, source) }];
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
/** Whether the members of `request` of `@KitRoute` name that part, written in full (`query: schema`) or short (`query`). */
|
|
75
|
+
function givesPart(members, source) {
|
|
76
|
+
return new RegExp(`(?:^|,)\\s*${source}\\s*(?::|,|$)`).test(members.trim());
|
|
77
|
+
}
|
|
78
|
+
function answerOf(written, reading) {
|
|
79
|
+
const type = (PROMISED.exec(written)?.[1] ?? written).trim();
|
|
80
|
+
if (type === 'void' || type === 'undefined') {
|
|
81
|
+
return { kind: 'none' };
|
|
82
|
+
}
|
|
83
|
+
if (type === 'Accepted' && importOf(type, reading)?.specifier === '@ddd-ts-kit/http') {
|
|
84
|
+
return { kind: 'accepted' };
|
|
85
|
+
}
|
|
86
|
+
const read = typeOf(type, reading);
|
|
87
|
+
return read.kind === 'class' ? read : { kind: 'unread', text: written };
|
|
88
|
+
}
|
|
89
|
+
/** A DTO class imported by its name from a file of the project, else a type the kit cannot read. */
|
|
90
|
+
function typeOf(type, reading) {
|
|
91
|
+
const imported = importOf(type, reading);
|
|
92
|
+
return imported !== undefined && isClassAt(reading, imported.specifier, type)
|
|
93
|
+
? { kind: 'class', name: type, specifier: imported.specifier }
|
|
94
|
+
: { kind: 'unread', text: type };
|
|
95
|
+
}
|
|
96
|
+
function importOf(type, { imports }) {
|
|
97
|
+
return TYPE_NAME.test(type) ? imports.find(({ names }) => names.includes(type)) : undefined;
|
|
98
|
+
}
|
|
99
|
+
/** Whether the file an alias names exports a class of that name: an interface or a type has no schema to read. */
|
|
100
|
+
function isClassAt({ files, config }, specifier, name) {
|
|
101
|
+
const root = aliasRoots(config).find(({ prefix }) => specifier.startsWith(prefix));
|
|
102
|
+
if (root === undefined) {
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
const file = `${root.directory}/${specifier.slice(root.prefix.length).replace(/\.js$/, '')}.ts`;
|
|
106
|
+
return new RegExp(`export\\s+(?:abstract\\s+)?class\\s+${name}\\b`).test(files.read(file) ?? '');
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=nest-controllers-in.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nest-controllers-in.js","sourceRoot":"","sources":["../../src/nest-controllers/nest-controllers-in.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAI1C,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAMlE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAG/C,MAAM,IAAI,GAAG,gBAAgB,CAAC;AAC9B,MAAM,MAAM,GAAG,uBAAuB,CAAC;AACvC,MAAM,eAAe,GAAG,kDAAkD,CAAC;AAC3E,MAAM,WAAW,GAAG,yBAAyB,CAAC;AAC9C,MAAM,QAAQ,GAAG,yBAAyB,CAAC;AAC3C,MAAM,SAAS,GAAG,eAAe,CAAC;AAClC,MAAM,UAAU,GAAG,kBAAkB,CAAC;AACtC,MAAM,iBAAiB,GAAG,0CAA0C,CAAC;AACrE,MAAM,gBAAgB,GAAG,uDAAuD,CAAC;AAEjF,4FAA4F;AAC5F,MAAM,UAAU,GACd,kHAAkH,CAAC;AAErH,MAAM,OAAO,GAAwD;IACnE,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,OAAO;IACd,KAAK,EAAE,QAAQ;IACf,OAAO,EAAE,SAAS;CACnB,CAAC;AAEF,0GAA0G;AAC1G,MAAM,UAAU,iBAAiB,CAAC,KAAmB,EAAE,MAAc,EAAE,IAAY;IACjF,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;IACpC,MAAM,OAAO,GAAG,IAAI,CAAC,IA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AI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,KAAK,CAAC;IAEhG,OAAO,IAAI,MAAM,CAAC,uCAAuC,IAAI,KAAK,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;AACnG,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** A type of a signature the kit turns into a schema, a DTO class, or one it cannot read, as written. */
|
|
2
|
+
export type NestReadType = {
|
|
3
|
+
readonly kind: 'class';
|
|
4
|
+
readonly name: string;
|
|
5
|
+
readonly specifier: string;
|
|
6
|
+
}
|
|
7
|
+
/** A type the kit cannot turn into a schema (an array, a type written inline, an interface), or no type at all. */
|
|
8
|
+
| {
|
|
9
|
+
readonly kind: 'unread';
|
|
10
|
+
readonly text: string;
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=nest-read-type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nest-read-type.d.ts","sourceRoot":"","sources":["../../src/nest-controllers/nest-read-type.ts"],"names":[],"mappings":"AAAA,yGAAyG;AACzG,MAAM,MAAM,YAAY,GACpB;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;CAAE;AAC/E,mHAAmH;GACjH;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nest-read-type.js","sourceRoot":"","sources":["../../src/nest-controllers/nest-read-type.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { NestReadType } from './nest-read-type.js';
|
|
2
|
+
/** A part of the request a parameter of a route method takes whole (`@Body() body: IssueInvoiceBody`), and its type. */
|
|
3
|
+
export interface NestRequestPart {
|
|
4
|
+
readonly source: 'params' | 'query' | 'headers' | 'body';
|
|
5
|
+
readonly type: NestReadType;
|
|
6
|
+
/** Whether `request` of `@KitRoute` gives the schema of this part instead. */
|
|
7
|
+
readonly declared: boolean;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=nest-request-part.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nest-request-part.d.ts","sourceRoot":"","sources":["../../src/nest-controllers/nest-request-part.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAErD,wHAAwH;AACxH,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,MAAM,EAAE,QAAQ,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC;IACzD,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAC5B,8EAA8E;IAC9E,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;CAC5B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nest-request-part.js","sourceRoot":"","sources":["../../src/nest-controllers/nest-request-part.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The parameters of a method as written, from the text of its signature (`issue(@Body() body: X,
|
|
3
|
+
* actor: Actor): Promise<Y>`): what stands between its parentheses, cut at the commas that no
|
|
4
|
+
* bracket holds. `code` is the same text with its comments and strings blanked, where the
|
|
5
|
+
* brackets are counted.
|
|
6
|
+
*/
|
|
7
|
+
export declare function parametersOf(text: string, code: string): string[];
|
|
8
|
+
//# sourceMappingURL=parameters-of.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parameters-of.d.ts","sourceRoot":"","sources":["../../src/nest-controllers/parameters-of.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAwBjE"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
const OPENING = '([{<';
|
|
2
|
+
const CLOSING = ')]}>';
|
|
3
|
+
/**
|
|
4
|
+
* The parameters of a method as written, from the text of its signature (`issue(@Body() body: X,
|
|
5
|
+
* actor: Actor): Promise<Y>`): what stands between its parentheses, cut at the commas that no
|
|
6
|
+
* bracket holds. `code` is the same text with its comments and strings blanked, where the
|
|
7
|
+
* brackets are counted.
|
|
8
|
+
*/
|
|
9
|
+
export function parametersOf(text, code) {
|
|
10
|
+
const open = code.indexOf('(');
|
|
11
|
+
const parameters = [];
|
|
12
|
+
let depth = 0;
|
|
13
|
+
let from = open + 1;
|
|
14
|
+
for (let at = from; open >= 0 && at < code.length; at += 1) {
|
|
15
|
+
const char = code.charAt(at);
|
|
16
|
+
if (depth === 0 && (char === ',' || char === ')')) {
|
|
17
|
+
parameters.push(text.slice(from, at).trim());
|
|
18
|
+
from = at + 1;
|
|
19
|
+
if (char === ')') {
|
|
20
|
+
break;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
else if (OPENING.includes(char)) {
|
|
24
|
+
depth += 1;
|
|
25
|
+
}
|
|
26
|
+
else if (CLOSING.includes(char) && code.charAt(at - 1) !== '=') {
|
|
27
|
+
depth -= 1;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return parameters.filter((parameter) => parameter !== '');
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=parameters-of.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parameters-of.js","sourceRoot":"","sources":["../../src/nest-controllers/parameters-of.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG,MAAM,CAAC;AACvB,MAAM,OAAO,GAAG,MAAM,CAAC;AAEvB;;;;;GAKG;AACH,MAAM,UAAU,YAA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iles {
|
|
3
|
+
read(file: string): string | undefined;
|
|
4
|
+
under(directory: string): readonly string[];
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=project-files.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-files.d.ts","sourceRoot":"","sources":["../../src/nest-controllers/project-files.ts"],"names":[],"mappings":"AAAA,iGAAiG;AACjG,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IACvC,KAAK,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAAC;CAC7C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-files.js","sourceRoot":"","sources":["../../src/nest-controllers/project-files.ts"],"names":[],"mappings":""}
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import type { Config } from '../config/index.js';
|
|
2
2
|
import type { NestControllerEntry } from './nest-controller-entry.js';
|
|
3
|
-
|
|
4
|
-
export interface ProjectFiles {
|
|
5
|
-
read(file: string): string | undefined;
|
|
6
|
-
under(directory: string): readonly string[];
|
|
7
|
-
}
|
|
3
|
+
import type { ProjectFiles } from './project-files.js';
|
|
8
4
|
/**
|
|
9
|
-
* The Nest controllers of a context that the kit serves (a class of `presentation/`
|
|
10
|
-
* Nest's `@Controller`, in a file that imports the
|
|
11
|
-
*
|
|
12
|
-
* `
|
|
5
|
+
* The Nest controllers of a context that the kit serves (a class of a `presentation/` folder of the
|
|
6
|
+
* context or of one of its modules, carrying Nest's `@Controller`, in a file that imports the
|
|
7
|
+
* bridge), in the order of their files, with what the signature of each route method says: the DTO class of each part of the request a parameter
|
|
8
|
+
* takes whole (`@Body() body: IssueInvoiceBody`), and its answer, `Promise<IssuedInvoice>` a DTO
|
|
9
|
+
* class, `Promise<Accepted>` an identifier, `Promise<void>` nothing.
|
|
13
10
|
*/
|
|
14
11
|
export declare function readNestControllers(files: ProjectFiles, config: Config, context: string): NestControllerEntry[];
|
|
15
12
|
//# sourceMappingURL=read-nest-controllers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read-nest-controllers.d.ts","sourceRoot":"","sources":["../../src/nest-controllers/read-nest-controllers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"read-nest-controllers.d.ts","sourceRoot":"","sources":["../../src/nest-controllers/read-nest-controllers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAEnE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,mBAAmB,EAAE,CAO/G"}
|
|
@@ -1,89 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { aliasRoots } from '../alias/alias-roots.js';
|
|
3
|
-
import { scan } from '../check/scan/scan.js';
|
|
4
|
-
import { readStructure } from '../check/structure/read-structure.js';
|
|
5
|
-
const NEST = '@nestjs/common';
|
|
6
|
-
const BRIDGE = '@ddd-ts-kit/http/nest';
|
|
7
|
-
const ROUTE_DECORATOR = /@(?:Get|Post|Put|Patch|Delete|Head|Options)\s*\(/;
|
|
8
|
-
const RETURN_TYPE = /\)\s*:\s*([\s\S]+?)\s*$/;
|
|
9
|
-
const PROMISED = /^Promise\s*<([\s\S]+)>$/;
|
|
10
|
-
const TYPE_NAME = /^[A-Z][\w$]*$/;
|
|
11
|
-
const CONTROLLER = /@Controller\s*\(/;
|
|
12
|
-
const DECLARED_RESPONSE = /@KitRoute\s*\(\s*\{[\s\S]*\bresponse\s*:/;
|
|
1
|
+
import { nestControllersIn } from './nest-controllers-in.js';
|
|
13
2
|
/**
|
|
14
|
-
* The Nest controllers of a context that the kit serves (a class of `presentation/`
|
|
15
|
-
* Nest's `@Controller`, in a file that imports the
|
|
16
|
-
*
|
|
17
|
-
* `
|
|
3
|
+
* The Nest controllers of a context that the kit serves (a class of a `presentation/` folder of the
|
|
4
|
+
* context or of one of its modules, carrying Nest's `@Controller`, in a file that imports the
|
|
5
|
+
* bridge), in the order of their files, with what the signature of each route method says: the DTO class of each part of the request a parameter
|
|
6
|
+
* takes whole (`@Body() body: IssueInvoiceBody`), and its answer, `Promise<IssuedInvoice>` a DTO
|
|
7
|
+
* class, `Promise<Accepted>` an identifier, `Promise<void>` nothing.
|
|
18
8
|
*/
|
|
19
9
|
export function readNestControllers(files, config, context) {
|
|
20
|
-
|
|
10
|
+
// The presentation of the context, and that of each of its modules.
|
|
21
11
|
return files
|
|
22
|
-
.under(
|
|
23
|
-
.filter((file) => file.endsWith('.ts') && !file.endsWith('.spec.ts'))
|
|
12
|
+
.under(`${config.contextsDir}/${context}`)
|
|
13
|
+
.filter((file) => file.includes('/presentation/') && file.endsWith('.ts') && !file.endsWith('.spec.ts'))
|
|
24
14
|
.sort()
|
|
25
|
-
.flatMap((file) =>
|
|
26
|
-
}
|
|
27
|
-
function controllersIn(files, config, file) {
|
|
28
|
-
const text = files.read(file) ?? '';
|
|
29
|
-
const scanned = scan(text);
|
|
30
|
-
const { imports } = scanned;
|
|
31
|
-
if (!imports.some(({ specifier }) => specifier === NEST) || !imports.some(({ specifier }) => specifier === BRIDGE)) {
|
|
32
|
-
return [];
|
|
33
|
-
}
|
|
34
|
-
const reading = { files, config, imports, text, code: scanned.code };
|
|
35
|
-
return readStructure(scanned)
|
|
36
|
-
.classes.filter(({ isExported, start }) => isExported && CONTROLLER.test(scanned.code.slice(Math.max(0, start - 400), start)))
|
|
37
|
-
.map((shape) => ({
|
|
38
|
-
file,
|
|
39
|
-
className: shape.name,
|
|
40
|
-
specifier: specifierOf(config, file),
|
|
41
|
-
methods: routeMethodsOf(shape, reading),
|
|
42
|
-
}));
|
|
43
|
-
}
|
|
44
|
-
/** The methods of the class that carry a route decorator of Nest, each with what its signature answers. */
|
|
45
|
-
function routeMethodsOf(shape, reading) {
|
|
46
|
-
let previous = shape.bodyStart;
|
|
47
|
-
return shape.methods.flatMap((method) => {
|
|
48
|
-
const decorators = reading.code.slice(previous, method.start);
|
|
49
|
-
previous = method.end;
|
|
50
|
-
if (method.isConstructor || !ROUTE_DECORATOR.test(decorators)) {
|
|
51
|
-
return [];
|
|
52
|
-
}
|
|
53
|
-
const written = RETURN_TYPE.exec(reading.text.slice(method.start, method.bodyStart))?.[1];
|
|
54
|
-
return [
|
|
55
|
-
{
|
|
56
|
-
name: method.name,
|
|
57
|
-
line: method.line,
|
|
58
|
-
answer: written === undefined ? { kind: 'unread', text: 'no return type' } : answerOf(written, reading),
|
|
59
|
-
declaresResponse: DECLARED_RESPONSE.test(decorators),
|
|
60
|
-
},
|
|
61
|
-
];
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
function answerOf(written, reading) {
|
|
65
|
-
const type = (PROMISED.exec(written)?.[1] ?? written).trim();
|
|
66
|
-
if (type === 'void' || type === 'undefined') {
|
|
67
|
-
return { kind: 'none' };
|
|
68
|
-
}
|
|
69
|
-
const imported = TYPE_NAME.test(type) ? reading.imports.find(({ names }) => names.includes(type)) : undefined;
|
|
70
|
-
if (imported === undefined) {
|
|
71
|
-
return { kind: 'unread', text: written };
|
|
72
|
-
}
|
|
73
|
-
if (type === 'Accepted' && imported.specifier === '@ddd-ts-kit/http') {
|
|
74
|
-
return { kind: 'accepted' };
|
|
75
|
-
}
|
|
76
|
-
return isClassAt(reading, imported.specifier, type)
|
|
77
|
-
? { kind: 'class', name: type, specifier: imported.specifier }
|
|
78
|
-
: { kind: 'unread', text: written };
|
|
79
|
-
}
|
|
80
|
-
/** Whether the file an alias names exports a class of that name: an interface or a type has no schema to read. */
|
|
81
|
-
function isClassAt({ files, config }, specifier, name) {
|
|
82
|
-
const root = aliasRoots(config).find(({ prefix }) => specifier.startsWith(prefix));
|
|
83
|
-
if (root === undefined) {
|
|
84
|
-
return false;
|
|
85
|
-
}
|
|
86
|
-
const file = `${root.directory}/${specifier.slice(root.prefix.length).replace(/\.js$/, '')}.ts`;
|
|
87
|
-
return new RegExp(`export\\s+(?:abstract\\s+)?class\\s+${name}\\b`).test(files.read(file) ?? '');
|
|
15
|
+
.flatMap((file) => nestControllersIn(files, config, file));
|
|
88
16
|
}
|
|
89
17
|
//# sourceMappingURL=read-nest-controllers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read-nest-controllers.js","sourceRoot":"","sources":["../../src/nest-controllers/read-nest-controllers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"read-nest-controllers.js","sourceRoot":"","sources":["../../src/nest-controllers/read-nest-controllers.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAG1D;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAAmB,EAAE,MAAc,EAAE,OAAe;IACtF,oEAAoE;IACpE,OAAO,KAAK;SACT,KAAK,CAAC,GAAG,MAAM,CAAC,WAAW,IAAI,OAAO,EAAE,CAAC;SACzC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,gBAAgB,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;SACvG,IAAI,EAAE;SACN,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;AAC/D,CAAC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { NestControllerEntry } from './nest-controller-entry.js';
|
|
2
2
|
/**
|
|
3
|
-
* `<context>.controllers.ts`: the Nest controllers of a context, each with what
|
|
4
|
-
*
|
|
5
|
-
* cannot be read is left out: `@KitRoute`
|
|
3
|
+
* `<context>.controllers.ts`: the Nest controllers of a context, each with what the signatures of
|
|
4
|
+
* its methods say, for the module to list and the bridge to read: the DTO classes of the parts of
|
|
5
|
+
* the request they take whole, and what they answer. What cannot be read is left out: `@KitRoute`
|
|
6
|
+
* says it, or `nest/controllers-current` reports it.
|
|
6
7
|
*/
|
|
7
8
|
export declare function renderControllersFile(context: string, constant: string, entries: readonly NestControllerEntry[]): string;
|
|
8
9
|
//# sourceMappingURL=render-controllers-file.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render-controllers-file.d.ts","sourceRoot":"","sources":["../../src/nest-controllers/render-controllers-file.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"render-controllers-file.d.ts","sourceRoot":"","sources":["../../src/nest-controllers/render-controllers-file.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAmB,MAAM,yBAAyB,CAAC;AAIpF;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,SAAS,mBAAmB,EAAE,GACtC,MAAM,CAYR"}
|
|
@@ -1,56 +1,72 @@
|
|
|
1
1
|
const WIDTH = 120;
|
|
2
2
|
/**
|
|
3
|
-
* `<context>.controllers.ts`: the Nest controllers of a context, each with what
|
|
4
|
-
*
|
|
5
|
-
* cannot be read is left out: `@KitRoute`
|
|
3
|
+
* `<context>.controllers.ts`: the Nest controllers of a context, each with what the signatures of
|
|
4
|
+
* its methods say, for the module to list and the bridge to read: the DTO classes of the parts of
|
|
5
|
+
* the request they take whole, and what they answer. What cannot be read is left out: `@KitRoute`
|
|
6
|
+
* says it, or `nest/controllers-current` reports it.
|
|
6
7
|
*/
|
|
7
8
|
export function renderControllersFile(context, constant, entries) {
|
|
8
9
|
const list = entries.length === 0
|
|
9
10
|
? ' = [];'
|
|
10
|
-
: ` = [\n${entries.map((entry) => `${entryOf(entry.className,
|
|
11
|
+
: ` = [\n${entries.map((entry) => `${entryOf(entry.className, entry.methods.flatMap(methodOf))}\n`).join('')}];`;
|
|
11
12
|
return `// Generated by ddd-ts-kit from the Nest controllers of ${context} and the signatures of their methods: never edit it.
|
|
12
13
|
${importsOf(entries).join('\n')}
|
|
13
14
|
|
|
14
|
-
/** The Nest controllers of ${context}, each with what its methods
|
|
15
|
+
/** The Nest controllers of ${context}, each with what the signatures of its methods say: the module of the context lists them, Nest builds them. */
|
|
15
16
|
export const ${constant}: readonly Type<unknown>[]${list}
|
|
16
17
|
`;
|
|
17
18
|
}
|
|
18
|
-
/** The import lines: the bridge and the schema of an identifier when they are used, the controllers, then the DTO classes they
|
|
19
|
+
/** The import lines: the bridge and the schema of an identifier when they are used, the controllers, then the DTO classes they name. */
|
|
19
20
|
function importsOf(entries) {
|
|
20
|
-
const
|
|
21
|
-
const types = new Map(
|
|
21
|
+
const methods = entries.flatMap(({ methods: of }) => of);
|
|
22
|
+
const types = new Map(methods
|
|
23
|
+
.flatMap(({ request, answer }) => [...request.map(({ type }) => type), answer])
|
|
24
|
+
.flatMap((type) => (type.kind === 'class' ? [[type.name, type.specifier]] : [])));
|
|
22
25
|
return [
|
|
23
26
|
...new Set([
|
|
24
|
-
...(
|
|
27
|
+
...(methods.some(({ answer }) => answer.kind === 'accepted')
|
|
25
28
|
? ["import { acceptedSchema } from '@ddd-ts-kit/http';"]
|
|
26
29
|
: []),
|
|
27
|
-
...(entries.length === 0 ? [] : ["import {
|
|
30
|
+
...(entries.length === 0 ? [] : ["import { withSignatures } from '@ddd-ts-kit/http/nest';"]),
|
|
28
31
|
"import type { Type } from '@nestjs/common';",
|
|
29
32
|
...entries.map(({ className, specifier }) => `import { ${className} } from '${specifier}';`),
|
|
30
33
|
...[...types].map(([name, specifier]) => `import { ${name} } from '${specifier}';`),
|
|
31
34
|
]),
|
|
32
35
|
];
|
|
33
36
|
}
|
|
34
|
-
/** What
|
|
35
|
-
function
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
return [`${name}: acceptedSchema`];
|
|
42
|
-
}
|
|
43
|
-
return answer.kind === 'class' ? [`${name}: ${answer.name}`] : [];
|
|
44
|
-
});
|
|
37
|
+
/** What the signature of a method says, as `withSignatures` takes it; left out when nothing of it was read. */
|
|
38
|
+
function methodOf({ name, request, answer }) {
|
|
39
|
+
const members = [
|
|
40
|
+
...request.flatMap(({ source, type }) => (type.kind === 'class' ? [`${source}: ${type.name}`] : [])),
|
|
41
|
+
...answerOf(answer),
|
|
42
|
+
];
|
|
43
|
+
return members.length === 0 ? [] : [{ name, members }];
|
|
45
44
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
return ` withAnswers(${className}, {}),`;
|
|
45
|
+
function answerOf(answer) {
|
|
46
|
+
if (answer.kind === 'none') {
|
|
47
|
+
return ['answer: null'];
|
|
50
48
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
49
|
+
if (answer.kind === 'accepted') {
|
|
50
|
+
return ['answer: acceptedSchema'];
|
|
51
|
+
}
|
|
52
|
+
return answer.kind === 'class' ? [`answer: ${answer.name}`] : [];
|
|
53
|
+
}
|
|
54
|
+
/** One entry of the list, each object on one line when the formatter would keep it there. */
|
|
55
|
+
function entryOf(className, methods) {
|
|
56
|
+
if (methods.length === 0) {
|
|
57
|
+
return ` withSignatures(${className}, {}),`;
|
|
58
|
+
}
|
|
59
|
+
const inline = methods.map(({ name, members }) => `${name}: { ${members.join(', ')} }`);
|
|
60
|
+
const line = ` withSignatures(${className}, { ${inline.join(', ')} }),`;
|
|
61
|
+
if (line.length <= WIDTH) {
|
|
62
|
+
return line;
|
|
63
|
+
}
|
|
64
|
+
const lines = methods.map(({ name, members }, at) => {
|
|
65
|
+
const one = ` ${inline[at] ?? ''},`;
|
|
66
|
+
return one.length <= WIDTH
|
|
67
|
+
? one
|
|
68
|
+
: ` ${name}: {\n${members.map((member) => ` ${member},\n`).join('')} },`;
|
|
69
|
+
});
|
|
70
|
+
return ` withSignatures(${className}, {\n${lines.join('\n')}\n }),`;
|
|
55
71
|
}
|
|
56
72
|
//# sourceMappingURL=render-controllers-file.js.map
|