ddd-ts-kit 0.2.0 → 0.4.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/README.md +99 -3
- package/dist/check/canonical/roles.d.ts.map +1 -1
- package/dist/check/canonical/roles.js +18 -1
- package/dist/check/canonical/roles.js.map +1 -1
- package/dist/check/catalogue/architecture-rules.d.ts.map +1 -1
- package/dist/check/catalogue/architecture-rules.js +4 -0
- package/dist/check/catalogue/architecture-rules.js.map +1 -1
- package/dist/check/catalogue/eslint-only-rules.d.ts.map +1 -1
- package/dist/check/catalogue/eslint-only-rules.js +24 -0
- package/dist/check/catalogue/eslint-only-rules.js.map +1 -1
- package/dist/check/declarations/classes-of.d.ts +2 -2
- package/dist/check/declarations/classes-of.js +4 -6
- package/dist/check/declarations/classes-of.js.map +1 -1
- package/dist/check/errors/builds-through-factories.d.ts +4 -0
- package/dist/check/errors/builds-through-factories.d.ts.map +1 -0
- package/dist/check/errors/builds-through-factories.js +5 -0
- package/dist/check/errors/builds-through-factories.js.map +1 -0
- package/dist/check/errors/error-code.d.ts +6 -0
- package/dist/check/errors/error-code.d.ts.map +1 -0
- package/dist/check/errors/error-code.js +2 -0
- package/dist/check/errors/error-code.js.map +1 -0
- package/dist/check/errors/error-codes.d.ts +8 -0
- package/dist/check/errors/error-codes.d.ts.map +1 -0
- package/dist/check/errors/error-codes.js +21 -0
- package/dist/check/errors/error-codes.js.map +1 -0
- package/dist/check/errors/kit-error-codes.d.ts +3 -0
- package/dist/check/errors/kit-error-codes.d.ts.map +1 -0
- package/dist/check/errors/kit-error-codes.js +17 -0
- package/dist/check/errors/kit-error-codes.js.map +1 -0
- package/dist/check/explain/errors-docs.d.ts +3 -0
- package/dist/check/explain/errors-docs.d.ts.map +1 -0
- package/dist/check/explain/errors-docs.js +30 -0
- package/dist/check/explain/errors-docs.js.map +1 -0
- package/dist/check/explain/rule-docs.d.ts.map +1 -1
- package/dist/check/explain/rule-docs.js +2 -0
- package/dist/check/explain/rule-docs.js.map +1 -1
- package/dist/check/explain/tree-docs.d.ts.map +1 -1
- package/dist/check/explain/tree-docs.js +3 -2
- package/dist/check/explain/tree-docs.js.map +1 -1
- package/dist/check/fixtures/authz-declared-fixtures.d.ts.map +1 -1
- package/dist/check/fixtures/authz-declared-fixtures.js +19 -0
- package/dist/check/fixtures/authz-declared-fixtures.js.map +1 -1
- package/dist/check/fixtures/errors-fixtures.d.ts +3 -0
- package/dist/check/fixtures/errors-fixtures.d.ts.map +1 -0
- package/dist/check/fixtures/errors-fixtures.js +136 -0
- package/dist/check/fixtures/errors-fixtures.js.map +1 -0
- package/dist/check/fixtures/fixtures.d.ts.map +1 -1
- package/dist/check/fixtures/fixtures.js +2 -0
- package/dist/check/fixtures/fixtures.js.map +1 -1
- package/dist/check/fixtures/tree-fixtures.d.ts.map +1 -1
- package/dist/check/fixtures/tree-fixtures.js +25 -3
- package/dist/check/fixtures/tree-fixtures.js.map +1 -1
- package/dist/check/rules/authz-declared.d.ts.map +1 -1
- package/dist/check/rules/authz-declared.js +24 -0
- package/dist/check/rules/authz-declared.js.map +1 -1
- package/dist/check/rules/declarations-role-declared.js +1 -1
- package/dist/check/rules/declarations-role-declared.js.map +1 -1
- package/dist/check/rules/errors-code-unique.d.ts +3 -0
- package/dist/check/rules/errors-code-unique.d.ts.map +1 -0
- package/dist/check/rules/errors-code-unique.js +34 -0
- package/dist/check/rules/errors-code-unique.js.map +1 -0
- package/dist/check/rules/errors-known-code.d.ts +3 -0
- package/dist/check/rules/errors-known-code.d.ts.map +1 -0
- package/dist/check/rules/errors-known-code.js +51 -0
- package/dist/check/rules/errors-known-code.js.map +1 -0
- package/dist/check/rules/language-glossary-term.d.ts.map +1 -1
- package/dist/check/rules/language-glossary-term.js +7 -5
- package/dist/check/rules/language-glossary-term.js.map +1 -1
- package/dist/commands/controllers.d.ts +8 -0
- package/dist/commands/controllers.d.ts.map +1 -0
- package/dist/commands/controllers.js +57 -0
- package/dist/commands/controllers.js.map +1 -0
- package/dist/commands/error-factories.d.ts +7 -0
- package/dist/commands/error-factories.d.ts.map +1 -0
- package/dist/commands/error-factories.js +65 -0
- package/dist/commands/error-factories.js.map +1 -0
- package/dist/commands/generate.js +10 -0
- package/dist/commands/generate.js.map +1 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +2 -0
- package/dist/commands/init.js.map +1 -1
- package/dist/config/index.d.ts +1 -1
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +1 -1
- package/dist/config/index.js.map +1 -1
- package/dist/config/parse-stack.d.ts.map +1 -1
- package/dist/config/parse-stack.js +3 -1
- package/dist/config/parse-stack.js.map +1 -1
- package/dist/config/stack.d.ts +18 -0
- package/dist/config/stack.d.ts.map +1 -1
- package/dist/config/stack.js +2 -0
- package/dist/config/stack.js.map +1 -1
- package/dist/controllers/entries-of.d.ts +3 -0
- package/dist/controllers/entries-of.d.ts.map +1 -0
- package/dist/controllers/entries-of.js +19 -0
- package/dist/controllers/entries-of.js.map +1 -0
- package/dist/controllers/finish-migration.d.ts +8 -0
- package/dist/controllers/finish-migration.d.ts.map +1 -0
- package/dist/controllers/finish-migration.js +71 -0
- package/dist/controllers/finish-migration.js.map +1 -0
- package/dist/controllers/function-route.d.ts +23 -0
- package/dist/controllers/function-route.d.ts.map +1 -0
- package/dist/controllers/function-route.js +2 -0
- package/dist/controllers/function-route.js.map +1 -0
- package/dist/controllers/handle-body.d.ts +8 -0
- package/dist/controllers/handle-body.d.ts.map +1 -0
- package/dist/controllers/handle-body.js +29 -0
- package/dist/controllers/handle-body.js.map +1 -0
- package/dist/controllers/handle-types-of.d.ts +15 -0
- package/dist/controllers/handle-types-of.d.ts.map +1 -0
- package/dist/controllers/handle-types-of.js +48 -0
- package/dist/controllers/handle-types-of.js.map +1 -0
- package/dist/controllers/migrate-context.d.ts +4 -0
- package/dist/controllers/migrate-context.d.ts.map +1 -0
- package/dist/controllers/migrate-context.js +74 -0
- package/dist/controllers/migrate-context.js.map +1 -0
- package/dist/controllers/migrated-group.d.ts +11 -0
- package/dist/controllers/migrated-group.d.ts.map +1 -0
- package/dist/controllers/migrated-group.js +2 -0
- package/dist/controllers/migrated-group.js.map +1 -0
- package/dist/controllers/migration.d.ts +16 -0
- package/dist/controllers/migration.d.ts.map +1 -0
- package/dist/controllers/migration.js +2 -0
- package/dist/controllers/migration.js.map +1 -0
- package/dist/controllers/plan-context.d.ts +22 -0
- package/dist/controllers/plan-context.d.ts.map +1 -0
- package/dist/controllers/plan-context.js +70 -0
- package/dist/controllers/plan-context.js.map +1 -0
- package/dist/controllers/read-function-route.d.ts +4 -0
- package/dist/controllers/read-function-route.d.ts.map +1 -0
- package/dist/controllers/read-function-route.js +37 -0
- package/dist/controllers/read-function-route.js.map +1 -0
- package/dist/controllers/render-controller.d.ts +15 -0
- package/dist/controllers/render-controller.d.ts.map +1 -0
- package/dist/controllers/render-controller.js +104 -0
- package/dist/controllers/render-controller.js.map +1 -0
- package/dist/declared/declared-role.d.ts +8 -2
- package/dist/declared/declared-role.d.ts.map +1 -1
- package/dist/declared/declared-role.js +17 -3
- package/dist/declared/declared-role.js.map +1 -1
- package/dist/declared/index.d.ts +1 -1
- package/dist/declared/index.d.ts.map +1 -1
- package/dist/declared/index.js +1 -1
- package/dist/declared/index.js.map +1 -1
- package/dist/depcruise/hygiene-rules.js +2 -1
- package/dist/depcruise/hygiene-rules.js.map +1 -1
- package/dist/describe/context-description.d.ts +17 -0
- package/dist/describe/context-description.d.ts.map +1 -1
- package/dist/describe/decorator-options.d.ts +3 -0
- package/dist/describe/decorator-options.d.ts.map +1 -0
- package/dist/describe/decorator-options.js +20 -0
- package/dist/describe/decorator-options.js.map +1 -0
- package/dist/describe/describe-context.d.ts.map +1 -1
- package/dist/describe/describe-context.js +2 -0
- package/dist/describe/describe-context.js.map +1 -1
- package/dist/describe/format-description.d.ts.map +1 -1
- package/dist/describe/format-description.js +9 -1
- package/dist/describe/format-description.js.map +1 -1
- package/dist/describe/listed-in.d.ts +3 -0
- package/dist/describe/listed-in.d.ts.map +1 -0
- package/dist/describe/listed-in.js +9 -0
- package/dist/describe/listed-in.js.map +1 -0
- package/dist/describe/read-controllers.d.ts +5 -0
- package/dist/describe/read-controllers.d.ts.map +1 -0
- package/dist/describe/read-controllers.js +98 -0
- package/dist/describe/read-controllers.js.map +1 -0
- package/dist/describe/read-errors.d.ts +8 -0
- package/dist/describe/read-errors.d.ts.map +1 -0
- package/dist/describe/read-errors.js +52 -0
- package/dist/describe/read-errors.js.map +1 -0
- package/dist/describe/read-route-groups.d.ts +5 -0
- package/dist/describe/read-route-groups.d.ts.map +1 -0
- package/dist/describe/read-route-groups.js +37 -0
- package/dist/describe/read-route-groups.js.map +1 -0
- package/dist/describe/read-routes.d.ts +4 -1
- package/dist/describe/read-routes.d.ts.map +1 -1
- package/dist/describe/read-routes.js +10 -4
- package/dist/describe/read-routes.js.map +1 -1
- package/dist/describe/reference-lines.js +27 -7
- package/dist/describe/reference-lines.js.map +1 -1
- package/dist/describe/route-group-fact.d.ts +11 -0
- package/dist/describe/route-group-fact.d.ts.map +1 -0
- package/dist/describe/route-group-fact.js +2 -0
- package/dist/describe/route-group-fact.js.map +1 -0
- package/dist/generate/errors/add-factory.d.ts +13 -0
- package/dist/generate/errors/add-factory.d.ts.map +1 -0
- package/dist/generate/errors/add-factory.js +30 -0
- package/dist/generate/errors/add-factory.js.map +1 -0
- package/dist/generate/errors/add-spec-case.d.ts +6 -0
- package/dist/generate/errors/add-spec-case.d.ts.map +1 -0
- package/dist/generate/errors/add-spec-case.js +26 -0
- package/dist/generate/errors/add-spec-case.js.map +1 -0
- package/dist/generate/errors/class-body.d.ts +8 -0
- package/dist/generate/errors/class-body.d.ts.map +1 -0
- package/dist/generate/errors/class-body.js +11 -0
- package/dist/generate/errors/class-body.js.map +1 -0
- package/dist/generate/errors/codes-of-context.d.ts +4 -0
- package/dist/generate/errors/codes-of-context.d.ts.map +1 -0
- package/dist/generate/errors/codes-of-context.js +17 -0
- package/dist/generate/errors/codes-of-context.js.map +1 -0
- package/dist/generate/errors/refusal-code.d.ts +13 -0
- package/dist/generate/errors/refusal-code.d.ts.map +1 -0
- package/dist/generate/errors/refusal-code.js +19 -0
- package/dist/generate/errors/refusal-code.js.map +1 -0
- package/dist/generate/errors/refusal-name.d.ts +4 -0
- package/dist/generate/errors/refusal-name.d.ts.map +1 -0
- package/dist/generate/errors/refusal-name.js +15 -0
- package/dist/generate/errors/refusal-name.js.map +1 -0
- package/dist/generate/errors/static-methods.d.ts +10 -0
- package/dist/generate/errors/static-methods.d.ts.map +1 -0
- package/dist/generate/errors/static-methods.js +13 -0
- package/dist/generate/errors/static-methods.js.map +1 -0
- package/dist/generate/errors/vague-refusal-names.d.ts +3 -0
- package/dist/generate/errors/vague-refusal-names.d.ts.map +1 -0
- package/dist/generate/errors/vague-refusal-names.js +15 -0
- package/dist/generate/errors/vague-refusal-names.js.map +1 -0
- package/dist/generate/kind.d.ts +12 -0
- package/dist/generate/kind.d.ts.map +1 -1
- package/dist/generate/kinds/declare-context-entries.d.ts +1 -1
- package/dist/generate/kinds/declare-context-entries.js +4 -3
- package/dist/generate/kinds/declare-context-entries.js.map +1 -1
- package/dist/generate/kinds/domain-error-kind.d.ts.map +1 -1
- package/dist/generate/kinds/domain-error-kind.js +4 -1
- package/dist/generate/kinds/domain-error-kind.js.map +1 -1
- package/dist/generate/kinds/e2e-kind.d.ts.map +1 -1
- package/dist/generate/kinds/e2e-kind.js +29 -6
- package/dist/generate/kinds/e2e-kind.js.map +1 -1
- package/dist/generate/kinds/error-kind.d.ts +3 -0
- package/dist/generate/kinds/error-kind.d.ts.map +1 -0
- package/dist/generate/kinds/error-kind.js +75 -0
- package/dist/generate/kinds/error-kind.js.map +1 -0
- package/dist/generate/kinds/extraction/service-selection.d.ts.map +1 -1
- package/dist/generate/kinds/extraction/service-selection.js +2 -1
- package/dist/generate/kinds/extraction/service-selection.js.map +1 -1
- package/dist/generate/kinds/guard-kind.d.ts +3 -0
- package/dist/generate/kinds/guard-kind.d.ts.map +1 -0
- package/dist/generate/kinds/guard-kind.js +27 -0
- package/dist/generate/kinds/guard-kind.js.map +1 -0
- package/dist/generate/kinds/route/controller-imports.d.ts +17 -0
- package/dist/generate/kinds/route/controller-imports.d.ts.map +1 -0
- package/dist/generate/kinds/route/controller-imports.js +22 -0
- package/dist/generate/kinds/route/controller-imports.js.map +1 -0
- package/dist/generate/kinds/route/controller-plan.d.ts +12 -0
- package/dist/generate/kinds/route/controller-plan.d.ts.map +1 -0
- package/dist/generate/kinds/route/controller-plan.js +2 -0
- package/dist/generate/kinds/route/controller-plan.js.map +1 -0
- package/dist/generate/kinds/route/controller-types.d.ts +18 -0
- package/dist/generate/kinds/route/controller-types.d.ts.map +1 -0
- package/dist/generate/kinds/route/controller-types.js +27 -0
- package/dist/generate/kinds/route/controller-types.js.map +1 -0
- package/dist/generate/kinds/route/controller-vars.d.ts +6 -0
- package/dist/generate/kinds/route/controller-vars.d.ts.map +1 -0
- package/dist/generate/kinds/route/controller-vars.js +117 -0
- package/dist/generate/kinds/route/controller-vars.js.map +1 -0
- package/dist/generate/kinds/route/group-file.d.ts +3 -0
- package/dist/generate/kinds/route/group-file.d.ts.map +1 -0
- package/dist/generate/kinds/route/group-file.js +5 -0
- package/dist/generate/kinds/route/group-file.js.map +1 -0
- package/dist/generate/kinds/route/group-prefix.d.ts +4 -0
- package/dist/generate/kinds/route/group-prefix.d.ts.map +1 -0
- package/dist/generate/kinds/route/group-prefix.js +17 -0
- package/dist/generate/kinds/route/group-prefix.js.map +1 -0
- package/dist/generate/kinds/route/group-vars.d.ts +17 -0
- package/dist/generate/kinds/route/group-vars.d.ts.map +1 -0
- package/dist/generate/kinds/route/group-vars.js +33 -0
- package/dist/generate/kinds/route/group-vars.js.map +1 -0
- package/dist/generate/kinds/route/plan-controller.d.ts +6 -0
- package/dist/generate/kinds/route/plan-controller.d.ts.map +1 -0
- package/dist/generate/kinds/route/plan-controller.js +16 -0
- package/dist/generate/kinds/route/plan-controller.js.map +1 -0
- package/dist/generate/kinds/route/resolve-group.d.ts +11 -0
- package/dist/generate/kinds/route/resolve-group.d.ts.map +1 -0
- package/dist/generate/kinds/route/resolve-group.js +31 -0
- package/dist/generate/kinds/route/resolve-group.js.map +1 -0
- package/dist/generate/kinds/route/resource-of.d.ts +5 -0
- package/dist/generate/kinds/route/resource-of.d.ts.map +1 -0
- package/dist/generate/kinds/route/resource-of.js +6 -0
- package/dist/generate/kinds/route/resource-of.js.map +1 -0
- package/dist/generate/kinds/route/route-group.d.ts +11 -0
- package/dist/generate/kinds/route/route-group.d.ts.map +1 -0
- package/dist/generate/kinds/route/route-group.js +2 -0
- package/dist/generate/kinds/route/route-group.js.map +1 -0
- package/dist/generate/kinds/route/write-controller.d.ts +5 -0
- package/dist/generate/kinds/route/write-controller.d.ts.map +1 -0
- package/dist/generate/kinds/route/write-controller.js +55 -0
- package/dist/generate/kinds/route/write-controller.js.map +1 -0
- package/dist/generate/kinds/route-group-kind.d.ts +3 -0
- package/dist/generate/kinds/route-group-kind.d.ts.map +1 -0
- package/dist/generate/kinds/route-group-kind.js +55 -0
- package/dist/generate/kinds/route-group-kind.js.map +1 -0
- package/dist/generate/kinds/route-kind.d.ts +2 -0
- package/dist/generate/kinds/route-kind.d.ts.map +1 -1
- package/dist/generate/kinds/route-kind.js +19 -4
- package/dist/generate/kinds/route-kind.js.map +1 -1
- package/dist/generate/kinds/write-context-files.d.ts.map +1 -1
- package/dist/generate/kinds/write-context-files.js +5 -4
- package/dist/generate/kinds/write-context-files.js.map +1 -1
- package/dist/generate/kinds.d.ts.map +1 -1
- package/dist/generate/kinds.js +8 -1
- package/dist/generate/kinds.js.map +1 -1
- package/dist/generate/lists-routes.d.ts +8 -0
- package/dist/generate/lists-routes.d.ts.map +1 -0
- package/dist/generate/lists-routes.js +10 -0
- package/dist/generate/lists-routes.js.map +1 -0
- package/dist/init/files/audit-files.d.ts.map +1 -1
- package/dist/init/files/audit-files.js +2 -7
- package/dist/init/files/audit-files.js.map +1 -1
- package/dist/init/manifest/versions.js +23 -23
- package/dist/init/stack/resolve-stack.d.ts.map +1 -1
- package/dist/init/stack/resolve-stack.js +5 -1
- package/dist/init/stack/resolve-stack.js.map +1 -1
- package/dist/init/stack/stack-options.d.ts +2 -0
- package/dist/init/stack/stack-options.d.ts.map +1 -1
- package/dist/refusals/apply-plan.d.ts +17 -0
- package/dist/refusals/apply-plan.d.ts.map +1 -0
- package/dist/refusals/apply-plan.js +118 -0
- package/dist/refusals/apply-plan.js.map +1 -0
- package/dist/refusals/factory-name-for.d.ts +7 -0
- package/dist/refusals/factory-name-for.d.ts.map +1 -0
- package/dist/refusals/factory-name-for.js +16 -0
- package/dist/refusals/factory-name-for.js.map +1 -0
- package/dist/refusals/legacy-error.d.ts +21 -0
- package/dist/refusals/legacy-error.d.ts.map +1 -0
- package/dist/refusals/legacy-error.js +2 -0
- package/dist/refusals/legacy-error.js.map +1 -0
- package/dist/refusals/legacy-errors.d.ts +6 -0
- package/dist/refusals/legacy-errors.d.ts.map +1 -0
- package/dist/refusals/legacy-errors.js +16 -0
- package/dist/refusals/legacy-errors.js.map +1 -0
- package/dist/refusals/migration-draft.d.ts +15 -0
- package/dist/refusals/migration-draft.d.ts.map +1 -0
- package/dist/refusals/migration-draft.js +41 -0
- package/dist/refusals/migration-draft.js.map +1 -0
- package/dist/refusals/migration-plan.d.ts +6 -0
- package/dist/refusals/migration-plan.d.ts.map +1 -0
- package/dist/refusals/migration-plan.js +2 -0
- package/dist/refusals/migration-plan.js.map +1 -0
- package/dist/refusals/move.d.ts +15 -0
- package/dist/refusals/move.d.ts.map +1 -0
- package/dist/refusals/move.js +2 -0
- package/dist/refusals/move.js.map +1 -0
- package/dist/refusals/nested-cases.d.ts +3 -0
- package/dist/refusals/nested-cases.d.ts.map +1 -0
- package/dist/refusals/nested-cases.js +9 -0
- package/dist/refusals/nested-cases.js.map +1 -0
- package/dist/refusals/plan-file.d.ts +3 -0
- package/dist/refusals/plan-file.d.ts.map +1 -0
- package/dist/refusals/plan-file.js +3 -0
- package/dist/refusals/plan-file.js.map +1 -0
- package/dist/refusals/planned-factory.d.ts +11 -0
- package/dist/refusals/planned-factory.d.ts.map +1 -0
- package/dist/refusals/planned-factory.js +2 -0
- package/dist/refusals/planned-factory.js.map +1 -0
- package/dist/refusals/planned-move.d.ts +8 -0
- package/dist/refusals/planned-move.d.ts.map +1 -0
- package/dist/refusals/planned-move.js +2 -0
- package/dist/refusals/planned-move.js.map +1 -0
- package/dist/refusals/project-sources.d.ts +5 -0
- package/dist/refusals/project-sources.d.ts.map +1 -0
- package/dist/refusals/project-sources.js +13 -0
- package/dist/refusals/project-sources.js.map +1 -0
- package/dist/refusals/propose-plan.d.ts +16 -0
- package/dist/refusals/propose-plan.d.ts.map +1 -0
- package/dist/refusals/propose-plan.js +39 -0
- package/dist/refusals/propose-plan.js.map +1 -0
- package/dist/refusals/read-legacy-error.d.ts +9 -0
- package/dist/refusals/read-legacy-error.d.ts.map +1 -0
- package/dist/refusals/read-legacy-error.js +75 -0
- package/dist/refusals/read-legacy-error.js.map +1 -0
- package/dist/refusals/read-plan.d.ts +4 -0
- package/dist/refusals/read-plan.d.ts.map +1 -0
- package/dist/refusals/read-plan.js +43 -0
- package/dist/refusals/read-plan.js.map +1 -0
- package/dist/refusals/render-factory.d.ts +5 -0
- package/dist/refusals/render-factory.d.ts.map +1 -0
- package/dist/refusals/render-factory.js +14 -0
- package/dist/refusals/render-factory.js.map +1 -0
- package/dist/refusals/replace-in-code.d.ts +16 -0
- package/dist/refusals/replace-in-code.d.ts.map +1 -0
- package/dist/refusals/replace-in-code.js +20 -0
- package/dist/refusals/replace-in-code.js.map +1 -0
- package/dist/refusals/rewrite-usages.d.ts +6 -0
- package/dist/refusals/rewrite-usages.d.ts.map +1 -0
- package/dist/refusals/rewrite-usages.js +80 -0
- package/dist/refusals/rewrite-usages.js.map +1 -0
- package/dist/refusals/spec-parts.d.ts +8 -0
- package/dist/refusals/spec-parts.d.ts.map +1 -0
- package/dist/refusals/spec-parts.js +14 -0
- package/dist/refusals/spec-parts.js.map +1 -0
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js +14 -1
- package/dist/run.js.map +1 -1
- package/dist/stack/audit-vars.d.ts.map +1 -1
- package/dist/stack/audit-vars.js +3 -1
- package/dist/stack/audit-vars.js.map +1 -1
- package/dist/stack/stack-vars.d.ts.map +1 -1
- package/dist/stack/stack-vars.js +18 -1
- package/dist/stack/stack-vars.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
- package/templates/aggregate/aggregate.ts.tpl +5 -0
- package/templates/command/handler.declared.ts.tpl +5 -0
- package/templates/command/handler.ts.tpl +5 -0
- package/templates/context/wiring.declared.tpl +2 -2
- package/templates/controller/controller.class-validator.ts.tpl +85 -0
- package/templates/controller/controller.none.ts.tpl +101 -0
- package/templates/controller/controller.search.ts.tpl +84 -0
- package/templates/controller/controller.spec.ts.tpl +49 -0
- package/templates/controller/controller.standard-schema.ts.tpl +113 -0
- package/templates/controller/controller.zod.ts.tpl +99 -0
- package/templates/controller/group.ts.tpl +4 -0
- package/templates/controller/guard.spec.ts.tpl +27 -0
- package/templates/controller/guard.ts.tpl +14 -0
- package/templates/controller/mapper.ts.tpl +10 -0
- package/templates/controller/routes.tsyringe.tpl +5 -0
- package/templates/controller/serializer.ts.tpl +10 -0
- package/templates/controller/wiring.manual.tpl +5 -0
- package/templates/docs/openapi.json.tpl +5 -0
- package/templates/entity/entity.ts.tpl +5 -0
- package/templates/error/case.spec.ts.tpl +8 -0
- package/templates/error/concept-error.spec.ts.tpl +7 -0
- package/templates/error/concept-error.ts.tpl +5 -0
- package/templates/error/factory.ts.tpl +4 -0
- package/templates/init/jest.config.js.tpl +7 -0
- package/templates/init/platform/audit/audit.module.manual.ts.tpl +18 -0
- package/templates/init/platform/audit/search-audit-entries.controller.ts.tpl +193 -0
- package/templates/init/platform/compose-application.tsyringe.ts.tpl +38 -4
- package/templates/init/rules/domain.md.tpl +11 -0
- package/templates/init/rules/presentation.md.tpl +18 -5
- package/templates/pipeline/package-scripts.json +1 -1
- package/templates/route/route.class-validator.ts.tpl +1 -1
- package/templates/route/route.none.ts.tpl +1 -1
- package/templates/route/route.search.ts.tpl +1 -1
- package/templates/route/route.standard-schema.ts.tpl +1 -1
- package/templates/route/route.zod.ts.tpl +1 -1
- package/templates/value-object/value-object.ts.tpl +5 -0
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
{{#if route.declaresSchema}}
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
{{/if}}
|
|
4
|
+
import { {{route.httpImports}} } from '@ddd-ts-kit/http';
|
|
5
|
+
import type { {{route.busType}} } from '@ddd-ts-kit/kernel';
|
|
6
|
+
{{#if route.usesInfer}}
|
|
7
|
+
import type { Infer } from '@ddd-ts-kit/validation';
|
|
8
|
+
{{/if}}
|
|
9
|
+
{{#if route.declaresSchema}}
|
|
10
|
+
import { zodSchema } from '@ddd-ts-kit/validation/zod';
|
|
11
|
+
{{/if}}
|
|
12
|
+
{{route.imports}}
|
|
13
|
+
|
|
14
|
+
{{#if route.hasParams}}
|
|
15
|
+
const params = zodSchema(z.object({ {{route.zodParams}} }));
|
|
16
|
+
|
|
17
|
+
{{/if}}
|
|
18
|
+
{{#if route.hasBody}}
|
|
19
|
+
const body = zodSchema(
|
|
20
|
+
z.object({
|
|
21
|
+
// TODO(domain): declare the fields the client sends for "{{name.words}}", with shape constraints only (types, formats, lengths); business rules stay in the domain.
|
|
22
|
+
}),
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
{{/if}}
|
|
26
|
+
{{#if route.returnsId}}
|
|
27
|
+
const accepted = zodSchema(z.object({ id: z.string() }), { io: 'output' });
|
|
28
|
+
|
|
29
|
+
{{/if}}
|
|
30
|
+
{{#if route.isQuery}}
|
|
31
|
+
const answer = zodSchema(
|
|
32
|
+
z.object({
|
|
33
|
+
// TODO(domain): declare the fields of {{name.pascal}}Result that are part of the public contract.
|
|
34
|
+
}),
|
|
35
|
+
{ io: 'output' },
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
{{/if}}
|
|
39
|
+
@Controller({
|
|
40
|
+
{{route.access}}
|
|
41
|
+
method: '{{route.method}}',
|
|
42
|
+
path: '{{route.groupPath}}',
|
|
43
|
+
summary: '{{name.title}}',
|
|
44
|
+
{{#if route.hasTypedParams}}
|
|
45
|
+
params,
|
|
46
|
+
{{/if}}
|
|
47
|
+
{{#if route.hasBody}}
|
|
48
|
+
body,
|
|
49
|
+
{{/if}}
|
|
50
|
+
{{#if route.returnsId}}
|
|
51
|
+
response: { status: {{route.status}}, description: 'Done; the body carries the identifier.', body: accepted },
|
|
52
|
+
{{/if}}
|
|
53
|
+
{{#if route.returnsNothing}}
|
|
54
|
+
response: { status: {{route.status}}, description: 'Done.' },
|
|
55
|
+
{{/if}}
|
|
56
|
+
{{#if route.isQuery}}
|
|
57
|
+
response: { status: {{route.status}}, description: 'The answer.', body: answer },
|
|
58
|
+
{{/if}}
|
|
59
|
+
// TODO(domain): list the codes of the refusals "{{name.words}}" can raise, as their factories set them, so that they appear in the contract with their status (`errors/known-code`).
|
|
60
|
+
errors: [],
|
|
61
|
+
})
|
|
62
|
+
export class {{name.pascal}}Controller {
|
|
63
|
+
constructor({{route.constructorParams}}) {}
|
|
64
|
+
|
|
65
|
+
{{#if route.isQuery}}
|
|
66
|
+
async handle({{route.requestParam}}): Promise<{{route.answerType}}> {
|
|
67
|
+
{{#unless route.mapper}}
|
|
68
|
+
// TODO(domain): build the query from `request` (params, query string); the actor is already there.
|
|
69
|
+
{{/unless}}
|
|
70
|
+
{{#if route.serializer}}
|
|
71
|
+
return this.serializer.serialize(await this.{{route.bus}}.execute({{route.message}}));
|
|
72
|
+
{{/if}}
|
|
73
|
+
{{#unless route.serializer}}
|
|
74
|
+
// TODO(domain): map the answer of the query to the public fields.
|
|
75
|
+
await this.{{route.bus}}.execute({{route.message}});
|
|
76
|
+
|
|
77
|
+
return {};
|
|
78
|
+
{{/unless}}
|
|
79
|
+
}
|
|
80
|
+
{{/if}}
|
|
81
|
+
{{#if route.returnsId}}
|
|
82
|
+
async handle({{route.requestParam}}): Promise<{{route.acceptedType}}> {
|
|
83
|
+
{{#unless route.mapper}}
|
|
84
|
+
// TODO(domain): build the command from `request` (body, params); the actor is already there.
|
|
85
|
+
{{/unless}}
|
|
86
|
+
const id = await this.{{route.bus}}.execute({{route.message}});
|
|
87
|
+
|
|
88
|
+
return { id };
|
|
89
|
+
}
|
|
90
|
+
{{/if}}
|
|
91
|
+
{{#if route.returnsNothing}}
|
|
92
|
+
async handle({{route.requestParam}}): Promise<void> {
|
|
93
|
+
{{#unless route.mapper}}
|
|
94
|
+
// TODO(domain): build the command from `request` (body, params); the actor is already there.
|
|
95
|
+
{{/unless}}
|
|
96
|
+
await this.{{route.bus}}.execute({{route.message}});
|
|
97
|
+
}
|
|
98
|
+
{{/if}}
|
|
99
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { describe, expect, it } from '{{tests.module}}';
|
|
2
|
+
import { ForbiddenError, type GuardRequest } from '@ddd-ts-kit/http';
|
|
3
|
+
import { anonymousActor, executionContext } from '@ddd-ts-kit/kernel';
|
|
4
|
+
import { {{name.pascal}}Guard } from '{{alias.context}}/presentation/http/guards/{{name.kebab}}.guard{{alias.ext}}';
|
|
5
|
+
|
|
6
|
+
const actor = { id: 'user-1', type: 'user', roles: [], attributes: {} } as const;
|
|
7
|
+
const execution = executionContext({ correlationId: 'correlation-1', actor, origin: 'http' });
|
|
8
|
+
|
|
9
|
+
const request: GuardRequest = {
|
|
10
|
+
method: 'GET',
|
|
11
|
+
path: '/',
|
|
12
|
+
operationId: 'anOperation',
|
|
13
|
+
params: {},
|
|
14
|
+
headers: {},
|
|
15
|
+
actor,
|
|
16
|
+
context: { requestId: 'request-1', execution, raw: undefined },
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
describe('{{name.pascal}}Guard', () => {
|
|
20
|
+
it('refuses a caller with 403', () => {
|
|
21
|
+
expect(() => new {{name.pascal}}Guard().check(request)).toThrow(ForbiddenError);
|
|
22
|
+
expect(anonymousActor().type).toBe('anonymous');
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
// TODO(domain): replace the test above by one per decision of the guard.
|
|
26
|
+
it.todo('lets through the caller it is written for');
|
|
27
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ForbiddenError, Guard, type GuardRequest } from '@ddd-ts-kit/http';
|
|
2
|
+
|
|
3
|
+
// TODO(domain): say in one sentence what this guard controls at the edge. It reads the caller and the request, never an aggregate: a right that depends on the element is a permission of the use case (`@Requires`).
|
|
4
|
+
@Guard()
|
|
5
|
+
export class {{name.pascal}}Guard implements Guard {
|
|
6
|
+
readonly documents = { errors: ['FORBIDDEN'] };
|
|
7
|
+
|
|
8
|
+
check({ actor }: GuardRequest): void {
|
|
9
|
+
// TODO(domain): replace this refusal of everybody by the control: a role, a membership read from the path, a key of the request.
|
|
10
|
+
if (actor.id !== '') {
|
|
11
|
+
throw new ForbiddenError('The caller may not use these routes');
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { RequestMapper, type HttpRequest } from '@ddd-ts-kit/http';
|
|
2
|
+
{{route.mapperImports}}
|
|
3
|
+
|
|
4
|
+
@RequestMapper()
|
|
5
|
+
export class {{name.pascal}}Mapper implements RequestMapper<{{route.mapperRequest}}, {{route.input}}> {
|
|
6
|
+
map(request: {{route.mapperRequest}}): {{route.input}} {
|
|
7
|
+
// TODO(domain): hand over what the {{route.messageKind}} needs from `request` (params, query, body){{route.actorNote}}.
|
|
8
|
+
return {{route.mapperMessage}};
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Serializer } from '@ddd-ts-kit/http';
|
|
2
|
+
{{route.serializerImports}}
|
|
3
|
+
|
|
4
|
+
@Serializer()
|
|
5
|
+
export class {{name.pascal}}Serializer implements Serializer<{{route.resultType}}, {{route.serializedType}}> {
|
|
6
|
+
serialize(_result: {{route.resultType}}): {{route.serializedType}} {
|
|
7
|
+
// TODO(domain): copy the public fields of the result, dates as ISO text; what the contract does not declare stays inside.
|
|
8
|
+
return {};
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -13,7 +13,12 @@ export class {{name.pascal}} extends Entity<string> {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
static create(id: string, state: {{name.pascal}}State): {{name.pascal}} {
|
|
16
|
+
{{#if refusals.factories}}
|
|
17
|
+
// TODO(domain): check the invariants {{name.pascal}} guards on its own and throw a refusal of the error class of its aggregate when one is violated (`ddd-ts-kit generate error {{context.kebab}} <Concept> <refusal>`); invariants spanning several entities belong to the aggregate root.
|
|
18
|
+
{{/if}}
|
|
19
|
+
{{#if refusals.classes}}
|
|
16
20
|
// TODO(domain): check the invariants {{name.pascal}} guards on its own and throw a DomainError of ../errors when one is violated; invariants spanning several entities belong to the aggregate root.
|
|
21
|
+
{{/if}}
|
|
17
22
|
return new {{name.pascal}}(id, state);
|
|
18
23
|
}
|
|
19
24
|
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
it('refuses "{{refusal.words}}" with the code {{error.code}}', () => {
|
|
2
|
+
const error = {{name.pascal}}Error.{{refusal.camel}}();
|
|
3
|
+
|
|
4
|
+
expect(error).toBeInstanceOf(DomainError);
|
|
5
|
+
expect(error.code).toBe('{{error.code}}');
|
|
6
|
+
expect(error.message).toBe('{{refusal.title}}.');
|
|
7
|
+
expect(error.facts).toEqual({});
|
|
8
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { describe, expect, it } from '{{tests.module}}';
|
|
2
|
+
import { DomainError } from '@ddd-ts-kit/kernel';
|
|
3
|
+
import { {{name.pascal}}Error } from '{{alias.context}}/domain/errors/{{name.kebab}}.error{{alias.ext}}';
|
|
4
|
+
|
|
5
|
+
describe('{{name.pascal}}Error', () => {
|
|
6
|
+
{{error.case}}
|
|
7
|
+
});
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
static {{refusal.camel}}() {
|
|
2
|
+
// TODO(domain): take as parameters the facts that explain this refusal (which {{context.words}} rule, which value), give them as the third argument and write a message a domain expert would recognise; a fact reaches the client only when named: `.exposing('<fact>')`. The code is the stable contract.
|
|
3
|
+
return {{name.pascal}}Error.refusal('{{error.code}}', '{{refusal.title}}.');
|
|
4
|
+
}
|
|
@@ -16,7 +16,14 @@ export default {
|
|
|
16
16
|
{
|
|
17
17
|
jsc: {
|
|
18
18
|
parser: { syntax: 'typescript', decorators: true },
|
|
19
|
+
{{#if decorators.legacy}}
|
|
20
|
+
// A library of the stack only has legacy decorators: the whole program is compiled in that mode, with the metadata it reads.
|
|
19
21
|
transform: { legacyDecorator: true, decoratorMetadata: true },
|
|
22
|
+
{{/if}}
|
|
23
|
+
{{#if decorators.standard}}
|
|
24
|
+
// Standard decorators, as `tsc` emits them for this project: no `experimentalDecorators` in tsconfig.json.
|
|
25
|
+
transform: { decoratorVersion: '2022-03' },
|
|
26
|
+
{{/if}}
|
|
20
27
|
target: 'es2022',
|
|
21
28
|
},
|
|
22
29
|
},
|
|
@@ -1,10 +1,21 @@
|
|
|
1
1
|
import { requires, type UseCaseDeclaration } from '@ddd-ts-kit/auth';
|
|
2
|
+
{{#if audit.controller}}
|
|
3
|
+
import { controllerRoutes, type Route } from '@ddd-ts-kit/http';
|
|
4
|
+
{{/if}}
|
|
5
|
+
{{#if audit.functionRoute}}
|
|
2
6
|
import type { Route } from '@ddd-ts-kit/http';
|
|
7
|
+
{{/if}}
|
|
3
8
|
import type { Platform } from '{{alias.platform}}/platform{{alias.ext}}';
|
|
4
9
|
import { auditPermissions } from '{{alias.platform}}/audit/audit.permissions{{alias.ext}}';
|
|
5
10
|
import { SearchAuditEntriesHandler } from '{{alias.platform}}/audit/search-audit-entries.handler{{alias.ext}}';
|
|
6
11
|
import { SearchAuditEntriesQuery } from '{{alias.platform}}/audit/search-audit-entries.query{{alias.ext}}';
|
|
12
|
+
{{#if audit.functionRoute}}
|
|
7
13
|
import { searchAuditEntriesRoute } from '{{alias.platform}}/audit/search-audit-entries.route{{alias.ext}}';
|
|
14
|
+
{{/if}}
|
|
15
|
+
{{#if audit.controller}}
|
|
16
|
+
import { SearchAuditEntriesController } from '{{alias.platform}}/audit/search-audit-entries.controller{{alias.ext}}';
|
|
17
|
+
import { securitySchemes } from '{{alias.platform}}/auth/security-schemes{{alias.ext}}';
|
|
18
|
+
{{/if}}
|
|
8
19
|
|
|
9
20
|
interface AuditWiring {
|
|
10
21
|
readonly name: string;
|
|
@@ -34,6 +45,13 @@ export function auditModule(platform: Platform): AuditWiring {
|
|
|
34
45
|
{{#unless authz.rebac}}
|
|
35
46
|
useCases: [requires(SearchAuditEntriesQuery, auditPermissions['trail.read'])],
|
|
36
47
|
{{/unless}}
|
|
48
|
+
{{#if audit.functionRoute}}
|
|
37
49
|
routes: [searchAuditEntriesRoute(platform.queries)],
|
|
50
|
+
{{/if}}
|
|
51
|
+
{{#if audit.controller}}
|
|
52
|
+
routes: controllerRoutes([new SearchAuditEntriesController(platform.queries)], {
|
|
53
|
+
security: Object.keys(securitySchemes),
|
|
54
|
+
}),
|
|
55
|
+
{{/if}}
|
|
38
56
|
};
|
|
39
57
|
}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import type { AuditEntry } from '@ddd-ts-kit/audit';
|
|
2
|
+
import {
|
|
3
|
+
Authenticated,
|
|
4
|
+
Controller,
|
|
5
|
+
pageRequestFrom,
|
|
6
|
+
pageRequestParameters,
|
|
7
|
+
pageResponse,
|
|
8
|
+
pageSchemaOf,
|
|
9
|
+
type HttpRequest,
|
|
10
|
+
type PageBody,
|
|
11
|
+
} from '@ddd-ts-kit/http';
|
|
12
|
+
import { err, ok, type QueryBus } from '@ddd-ts-kit/kernel';
|
|
13
|
+
import { customSchema, type JsonSchema } from '@ddd-ts-kit/validation';
|
|
14
|
+
import { SearchAuditEntriesQuery, type AuditEntriesFilter } from '{{alias.platform}}/audit/search-audit-entries.query{{alias.ext}}';
|
|
15
|
+
|
|
16
|
+
/** Newest first unless asked otherwise, by cursor: the trail only grows, an offset would shift under the reader. */
|
|
17
|
+
const pageLimits = { sortable: ['occurredAt', 'sequence'], maxSize: 100, kind: 'cursor' } as const;
|
|
18
|
+
const outcomes = ['allowed', 'denied', 'succeeded', 'failed'] as const;
|
|
19
|
+
|
|
20
|
+
type Parameters = Readonly<Record<string, unknown>>;
|
|
21
|
+
|
|
22
|
+
const query = customSchema<Parameters>(
|
|
23
|
+
(input) =>
|
|
24
|
+
isRecord(input) ? ok(input) : err([{ path: '', code: 'invalid_type', message: 'Expected query parameters.' }]),
|
|
25
|
+
{
|
|
26
|
+
type: 'object',
|
|
27
|
+
properties: {
|
|
28
|
+
...propertiesOf(pageRequestParameters(pageLimits)),
|
|
29
|
+
actorId: { type: 'string', description: 'Entries about what this actor did.' },
|
|
30
|
+
action: { type: 'string', description: 'A permission id, a command name or an event type.' },
|
|
31
|
+
outcome: { type: 'string', enum: [...outcomes] },
|
|
32
|
+
correlationId: { type: 'string', description: 'Everything one request or event caused.' },
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
/** What leaves the process: identifiers and codes, as the trail holds them. `changes` and `extensions` stay inside. */
|
|
38
|
+
interface AuditEntryView {
|
|
39
|
+
readonly id: string;
|
|
40
|
+
readonly chain: string;
|
|
41
|
+
readonly sequence: number;
|
|
42
|
+
readonly occurredAt: string;
|
|
43
|
+
readonly category: string;
|
|
44
|
+
readonly action: string;
|
|
45
|
+
readonly outcome: string;
|
|
46
|
+
readonly reason?: string;
|
|
47
|
+
readonly actorId: string;
|
|
48
|
+
readonly actorType: string;
|
|
49
|
+
readonly tenantId?: string;
|
|
50
|
+
readonly resourceType?: string;
|
|
51
|
+
readonly resourceId?: string;
|
|
52
|
+
readonly context?: string;
|
|
53
|
+
readonly correlationId: string;
|
|
54
|
+
readonly causationId?: string;
|
|
55
|
+
readonly origin: string;
|
|
56
|
+
readonly previousHash: string;
|
|
57
|
+
readonly hash: string;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const text = { type: 'string' } as const;
|
|
61
|
+
|
|
62
|
+
const entry = customSchema<AuditEntryView>(
|
|
63
|
+
(input) =>
|
|
64
|
+
isEntryView(input) ? ok(input) : err([{ path: '', code: 'invalid_type', message: 'Expected an audit entry.' }]),
|
|
65
|
+
{
|
|
66
|
+
type: 'object',
|
|
67
|
+
required: [
|
|
68
|
+
'id',
|
|
69
|
+
'chain',
|
|
70
|
+
'sequence',
|
|
71
|
+
'occurredAt',
|
|
72
|
+
'category',
|
|
73
|
+
'action',
|
|
74
|
+
'outcome',
|
|
75
|
+
'actorId',
|
|
76
|
+
'actorType',
|
|
77
|
+
'correlationId',
|
|
78
|
+
'origin',
|
|
79
|
+
'previousHash',
|
|
80
|
+
'hash',
|
|
81
|
+
],
|
|
82
|
+
properties: {
|
|
83
|
+
id: text,
|
|
84
|
+
chain: text,
|
|
85
|
+
sequence: { type: 'integer', minimum: 1 },
|
|
86
|
+
occurredAt: { type: 'string', format: 'date-time' },
|
|
87
|
+
category: text,
|
|
88
|
+
action: text,
|
|
89
|
+
outcome: { type: 'string', enum: [...outcomes] },
|
|
90
|
+
reason: text,
|
|
91
|
+
actorId: text,
|
|
92
|
+
actorType: text,
|
|
93
|
+
tenantId: text,
|
|
94
|
+
resourceType: text,
|
|
95
|
+
resourceId: text,
|
|
96
|
+
context: text,
|
|
97
|
+
correlationId: text,
|
|
98
|
+
causationId: text,
|
|
99
|
+
origin: text,
|
|
100
|
+
previousHash: text,
|
|
101
|
+
hash: text,
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
/** The audit trail as a protected read: a use case like any other, so reading it is authorized and recorded. */
|
|
107
|
+
@Controller({
|
|
108
|
+
method: 'GET',
|
|
109
|
+
path: '/audit/entries',
|
|
110
|
+
summary: 'Search the entries of the audit trail',
|
|
111
|
+
tags: ['audit'],
|
|
112
|
+
guards: [Authenticated],
|
|
113
|
+
query,
|
|
114
|
+
response: { status: 200, description: 'A page of entries.', body: pageSchemaOf(entry) },
|
|
115
|
+
errors: ['FORBIDDEN'],
|
|
116
|
+
})
|
|
117
|
+
export class SearchAuditEntriesController {
|
|
118
|
+
constructor(private readonly queries: QueryBus) {}
|
|
119
|
+
|
|
120
|
+
async handle({ query: parameters, actor }: HttpRequest<{ query: Parameters }>): Promise<PageBody<AuditEntryView>> {
|
|
121
|
+
const page = await this.queries.execute(
|
|
122
|
+
new SearchAuditEntriesQuery(actor, pageRequestFrom(parameters, pageLimits), filterOf(parameters)),
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
return pageResponse(page, toView);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function filterOf(parameters: Parameters): AuditEntriesFilter {
|
|
130
|
+
const outcome = outcomes.find((candidate) => candidate === parameters['outcome']);
|
|
131
|
+
|
|
132
|
+
return {
|
|
133
|
+
...textOf(parameters, 'actorId'),
|
|
134
|
+
...textOf(parameters, 'action'),
|
|
135
|
+
...textOf(parameters, 'correlationId'),
|
|
136
|
+
...(outcome === undefined ? {} : { outcome }),
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function textOf<Key extends string>(parameters: Parameters, key: Key): Partial<Record<Key, string>> {
|
|
141
|
+
const value = parameters[key];
|
|
142
|
+
const found: Partial<Record<Key, string>> = {};
|
|
143
|
+
|
|
144
|
+
if (typeof value === 'string' && value !== '') {
|
|
145
|
+
found[key] = value;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
return found;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function toView(source: AuditEntry): AuditEntryView {
|
|
152
|
+
const { actor, resource } = source;
|
|
153
|
+
|
|
154
|
+
return {
|
|
155
|
+
id: source.id,
|
|
156
|
+
chain: source.chain,
|
|
157
|
+
sequence: source.sequence,
|
|
158
|
+
occurredAt: source.occurredAt.toISOString(),
|
|
159
|
+
category: source.category,
|
|
160
|
+
action: source.action,
|
|
161
|
+
outcome: source.outcome,
|
|
162
|
+
...(source.reason === undefined ? {} : { reason: source.reason }),
|
|
163
|
+
actorId: actor.id,
|
|
164
|
+
actorType: actor.type,
|
|
165
|
+
...(source.tenantId === undefined ? {} : { tenantId: source.tenantId }),
|
|
166
|
+
...(resource === undefined ? {} : { resourceType: resource.type, resourceId: resource.id }),
|
|
167
|
+
...(source.context === undefined ? {} : { context: source.context }),
|
|
168
|
+
correlationId: source.correlationId,
|
|
169
|
+
...(source.causationId === undefined ? {} : { causationId: source.causationId }),
|
|
170
|
+
origin: source.origin,
|
|
171
|
+
previousHash: source.previousHash,
|
|
172
|
+
hash: source.hash,
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function propertiesOf(schema: JsonSchema): JsonSchema {
|
|
177
|
+
const { properties } = schema;
|
|
178
|
+
|
|
179
|
+
return typeof properties === 'object' && properties !== null ? { ...properties } : {};
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function isRecord(input: unknown): input is Parameters {
|
|
183
|
+
return typeof input === 'object' && input !== null && !Array.isArray(input);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
function isEntryView(input: unknown): input is AuditEntryView {
|
|
187
|
+
return (
|
|
188
|
+
isRecord(input) &&
|
|
189
|
+
typeof input['id'] === 'string' &&
|
|
190
|
+
typeof input['hash'] === 'string' &&
|
|
191
|
+
typeof input['sequence'] === 'number'
|
|
192
|
+
);
|
|
193
|
+
}
|
|
@@ -3,6 +3,9 @@ import { installAspectRuntime } from '@ddd-ts-kit/aspects';
|
|
|
3
3
|
import { Authenticator } from '@ddd-ts-kit/auth';
|
|
4
4
|
{{/if}}
|
|
5
5
|
import {
|
|
6
|
+
{{#if routes.declaredControllers}}
|
|
7
|
+
DeclaredEdges,
|
|
8
|
+
{{/if}}
|
|
6
9
|
createApplication,
|
|
7
10
|
kernelModule,
|
|
8
11
|
type Application as Container,
|
|
@@ -13,7 +16,12 @@ import {
|
|
|
13
16
|
import { OutboxPublisher } from '@ddd-ts-kit/events';
|
|
14
17
|
{{/if}}
|
|
15
18
|
{{#if http.any}}
|
|
19
|
+
{{#if routes.mountsControllers}}
|
|
20
|
+
import { ErrorMapper, controllerRoutes, defineRoutes, type Route } from '@ddd-ts-kit/http';
|
|
21
|
+
{{/if}}
|
|
22
|
+
{{#unless routes.mountsControllers}}
|
|
16
23
|
import { ErrorMapper, defineRoutes, type Route } from '@ddd-ts-kit/http';
|
|
24
|
+
{{/unless}}
|
|
17
25
|
{{/if}}
|
|
18
26
|
import {
|
|
19
27
|
Cache,
|
|
@@ -51,10 +59,16 @@ import { tracedPublisher } from '@ddd-ts-kit/tracing';
|
|
|
51
59
|
{{#if audit.on}}
|
|
52
60
|
import { auditModule } from '{{alias.platform}}/audit/audit.module{{alias.ext}}';
|
|
53
61
|
{{/if}}
|
|
54
|
-
{{#if audit.
|
|
62
|
+
{{#if audit.functionRoute}}
|
|
55
63
|
import { searchAuditEntriesRoute } from '{{alias.platform}}/audit/search-audit-entries.route{{alias.ext}}';
|
|
56
64
|
{{/if}}
|
|
65
|
+
{{#if audit.controller}}
|
|
66
|
+
import { SearchAuditEntriesController } from '{{alias.platform}}/audit/search-audit-entries.controller{{alias.ext}}';
|
|
67
|
+
{{/if}}
|
|
57
68
|
import { authorization } from '{{alias.platform}}/auth/authorization{{alias.ext}}';
|
|
69
|
+
{{#if routes.mountsControllers}}
|
|
70
|
+
import { securitySchemes } from '{{alias.platform}}/auth/security-schemes{{alias.ext}}';
|
|
71
|
+
{{/if}}
|
|
58
72
|
{{#if http.any}}
|
|
59
73
|
import { httpBoundary, type HttpBoundary } from '{{alias.platform}}/auth/http-boundary{{alias.ext}}';
|
|
60
74
|
{{/if}}
|
|
@@ -109,8 +123,8 @@ export interface Application {
|
|
|
109
123
|
export interface ContextSelection {
|
|
110
124
|
readonly modules: readonly ContextModule[];
|
|
111
125
|
{{#if http.any}}
|
|
112
|
-
/** The routes of each context, given the two buses they call. */
|
|
113
|
-
readonly routes
|
|
126
|
+
/** The function routes of each context, given the two buses they call; controllers need no list. */
|
|
127
|
+
readonly routes?: readonly ((commands: CommandBus, queries: QueryBus) => readonly Route[])[];
|
|
114
128
|
{{/if}}
|
|
115
129
|
}
|
|
116
130
|
|
|
@@ -262,6 +276,26 @@ function routesOf(container: Container, contexts: ContextSelection): readonly Ro
|
|
|
262
276
|
const commands = container.resolve(CommandBus);
|
|
263
277
|
const queries = container.resolve(QueryBus);
|
|
264
278
|
|
|
265
|
-
|
|
279
|
+
{{#unless routes.mountsControllers}}
|
|
280
|
+
return defineRoutes(...(contexts.routes ?? []).map((routes) => routes(commands, queries)){{#if audit.route}}, [searchAuditEntriesRoute(queries)]{{/if}});
|
|
281
|
+
{{/unless}}
|
|
282
|
+
{{#if routes.mountsControllers}}
|
|
283
|
+
// Every route that is not public names these schemes in the contract.
|
|
284
|
+
const security = Object.keys(securitySchemes);
|
|
285
|
+
|
|
286
|
+
return defineRoutes(
|
|
287
|
+
...(contexts.routes ?? []).map((routes) => routes(commands, queries)),
|
|
288
|
+
{{#if routes.declaredControllers}}
|
|
289
|
+
// The controllers the hosted contexts declare, each built from its constructor.
|
|
290
|
+
controllerRoutes(container.resolve(DeclaredEdges).of('controller'), { resolve: container.resolve, security }),
|
|
291
|
+
{{/if}}
|
|
292
|
+
{{#if audit.functionRoute}}
|
|
293
|
+
[searchAuditEntriesRoute(queries)],
|
|
294
|
+
{{/if}}
|
|
295
|
+
{{#if audit.controller}}
|
|
296
|
+
controllerRoutes([new SearchAuditEntriesController(queries)], { security }),
|
|
297
|
+
{{/if}}
|
|
298
|
+
);
|
|
299
|
+
{{/if}}
|
|
266
300
|
}
|
|
267
301
|
{{/if}}
|
|
@@ -10,9 +10,20 @@ paths:
|
|
|
10
10
|
- Names come from the glossary of `CONTEXT.md`, written first (`language/glossary-term`); no `Manager`, `Helper`, `Data`, `Info`, `Model` (`language/no-technical-name`).
|
|
11
11
|
- Aggregate: private constructor, `create` for birth, `rehydrate` for loading, state changed by methods named after the business intention, no setter, no public mutable property (`domain/aggregate-encapsulation`). One aggregate per transaction; another one is referenced by its id.
|
|
12
12
|
- Value objects are immutable, validated in `create`, compared with `equals` (`domain/value-object-immutability`). An email, an amount, a period are types, not strings.
|
|
13
|
+
{{#if refusals.factories}}
|
|
14
|
+
- A violated invariant throws a refusal built by a static factory of the error class of its concept, never `new` and never a bare `Error`: `throw InvoiceError.alreadyIssued(this.id)` (`errors/through-factory`, `domain/no-generic-error`). One class per concept of the glossary in `domain/errors/`, extending `ConceptError`, no constructor (`errors/constructor-not-public`); a factory is named after the refusal and its code says the same words (`errors/factory-name`), one code per refusal of the context (`errors/code-unique`).
|
|
15
|
+
- A factory takes the facts of the refusal as typed parameters and gives them to `refusal(code, message, facts)`. Facts are private: one reaches a client only when the factory names it, `.exposing('<fact>')`, and never when it identifies a person. A value object returns its refusals in the `Result` of `create`: `err(PersonError.invalidEmail(raw))`.
|
|
16
|
+
{{/if}}
|
|
17
|
+
{{#if refusals.classes}}
|
|
13
18
|
- A violated invariant throws a `DomainError` of `domain/errors/` with a stable `code`, never a bare `Error` (`domain/no-generic-error`).
|
|
19
|
+
{{/if}}
|
|
14
20
|
- Domain events are named in the past tense, `<context>.<aggregate>.<fact>` (`events/name-format`), and recorded by the aggregate (`this.record(...)`). They leave with the save: nothing here dispatches them.
|
|
15
21
|
- A repository here is a port: an abstract class extending the kernel `Repository<Aggregate>`, abstract members only (`ports/abstract-class`). A domain service is stateless.
|
|
16
22
|
- Time and identifiers come in as parameters (`purity/*`); nothing here knows the acting user or its rights (`authz/in-application`).
|
|
17
23
|
- One concept per file, with the suffix of its role: `.aggregate.ts`, `.entity.ts`, `.vo.ts`, `.event.ts`, `.error.ts`, `.repository.ts`, `.service.ts` (`naming/suffix`, `naming/one-concept-per-file`).
|
|
24
|
+
{{#if refusals.factories}}
|
|
25
|
+
- The language first, with `/ddd-ts-kit:glossary`. Then create with `npx ddd-ts-kit generate aggregate|entity|value-object|domain-event|domain-service|repository ... --json`, a refusal with `npx ddd-ts-kit generate error <context> <Concept> <refusal> --json` (it adds the factory to the class of the concept, and its case to the spec), and fill the `TODO(domain)` places it lists.
|
|
26
|
+
{{/if}}
|
|
27
|
+
{{#if refusals.classes}}
|
|
18
28
|
- The language first, with `/ddd-ts-kit:glossary`. Then create with `npx ddd-ts-kit generate aggregate|entity|value-object|domain-event|domain-error|domain-service|repository ... --json` and fill the `TODO(domain)` places it lists.
|
|
29
|
+
{{/if}}
|
|
@@ -7,13 +7,26 @@ paths:
|
|
|
7
7
|
|
|
8
8
|
# Presentation layer
|
|
9
9
|
|
|
10
|
+
{{#if routes.controllers}}
|
|
11
|
+
- A route is one class with one method: `<use-case>.controller.ts` in `presentation/http/<resource>/<use-case>/`, carrying `@Controller` of `@ddd-ts-kit/http`. The decorator is the single statement of the route (method, path after the prefix of its group, schemas, response, error codes); `handle` receives what the schemas produce and returns the declared body, and the compiler refuses anything else (`presentation/controller-shape`).
|
|
12
|
+
- A controller decides nothing: it is given the bus of its method (`CommandBus` for POST, PUT, PATCH, DELETE; `QueryBus` for GET), a request mapper and a serializer, nothing else (`presentation/controller-delegates`). `<use-case>.mapper.ts` turns the request and its actor into the command or the query; `<use-case>.serializer.ts` turns the result into the body. Both are optional.
|
|
13
|
+
- A route group (`<resource>.routes.ts`, `@RouteGroup`) gives its controllers a prefix, a tag and guards. A controller names its group, or says `guards: [Public]`: nothing is open by omission (`authz/declared`).
|
|
14
|
+
- A guard is a control at the edge (authenticated, a role, the tenant of the path); a permission stays on the use case (`@Requires`), where a job and an event handler meet it too. A guard of the project is a declared class in `presentation/http/guards/*.guard.ts` and never imports `domain/`, `infrastructure/`, a repository or the command bus (`presentation/guard-at-the-edge`).
|
|
15
|
+
{{/if}}
|
|
16
|
+
{{#if routes.functions}}
|
|
10
17
|
- A route validates the shape of the input, builds a command or a query with the actor, executes it through `CommandBus` or `QueryBus` (never a handler class) and maps the answer. Nothing else.
|
|
18
|
+
{{/if}}
|
|
11
19
|
- Imports `application/` (and domain types for mapping), never `infrastructure/` (`layer/presentation-no-infrastructure`).
|
|
12
20
|
- Input shape is validated here with the schema library of the project, behind the `Schema` port. Business rules are not validated here.
|
|
13
|
-
|
|
14
|
-
-
|
|
15
|
-
|
|
21
|
+
{{#if refusals.factories}}
|
|
22
|
+
- Every route says who may call it (its group or its guards for a controller, `security` for a function) and the codes of the refusals it can answer in `errors`, as their factories set them (`errors/known-code`); the mapping from code to status lives in one place, the error mapper. A client reads the `code`, under `facts` only what a factory exposed, and the message of the refusal as `detail` unless it quotes a fact that is not exposed.
|
|
23
|
+
{{/if}}
|
|
24
|
+
{{#if refusals.classes}}
|
|
25
|
+
- Every route says who may call it (its group or its guards for a controller, `security` for a function) and the `DomainError` codes it can answer in `errors`; the mapping from code to status lives in one place, the error mapper.
|
|
26
|
+
{{/if}}
|
|
27
|
+
- No role or ownership test in a controller or a route (`authz/in-application`): a guard of the group asks for a role at the edge, the bus asks for the permission, a policy decides on loaded state.
|
|
28
|
+
- Request and response types are presentation types, one class or schema per file next to the controller (`*.body.ts`, `*.params.ts`, `*.answer.ts`...; `*.dto.ts` for function routes and under `shared/`): never an aggregate, never a row.
|
|
16
29
|
- Never put the message of an unexpected failure in a response or a log.
|
|
17
|
-
- Files:
|
|
30
|
+
- Files: the canonical tree of `presentation/http/` (`naming/suffix`, `tree/closed`): a folder per controller, `*.routes.ts` for the groups, `guards/`, `shared/`; function routes stay flat (`*.route.ts`, `*.dto.ts`).
|
|
18
31
|
- After a change, `npm run docs:generate` regenerates `openapi/openapi.json`, committed with the route; CI fails on a difference. Never edit it by hand.
|
|
19
|
-
- Contract with `/ddd-ts-kit:document`. Create with `npx ddd-ts-kit generate route <context> <UseCase> --method <M> --path <p> --json`, then `generate e2e <context> <UseCase
|
|
32
|
+
- Contract with `/ddd-ts-kit:document`. Create with `npx ddd-ts-kit generate route <context> <UseCase> --method <M> --path <p> [--group <Name>] [--mapper] [--serializer] --json`, then `generate e2e <context> <UseCase>`; `generate route-group` and `generate guard` write a group and a guard.
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"@biomejs/biome": "2.5.15",
|
|
24
24
|
"@commitlint/cli": "^21.2.3",
|
|
25
25
|
"@commitlint/config-conventional": "^21.2.3",
|
|
26
|
-
"@ddd-ts-kit/eslint-plugin": "^0.
|
|
26
|
+
"@ddd-ts-kit/eslint-plugin": "^0.4.0",
|
|
27
27
|
"@eslint/js": "^10.0.1",
|
|
28
28
|
"@typescript/native": "npm:typescript@~7.0.2",
|
|
29
29
|
"@vitest/coverage-v8": "5.0.3",
|
|
@@ -42,7 +42,7 @@ export function {{name.camel}}Route({{route.bus}}: {{route.busType}}): Route {
|
|
|
42
42
|
{{#if route.isQuery}}
|
|
43
43
|
responses: { {{route.status}}: { description: 'The answer.', body: answer } },
|
|
44
44
|
{{/if}}
|
|
45
|
-
// TODO(domain): list the codes of the
|
|
45
|
+
// TODO(domain): list the codes of the refusals "{{name.words}}" can raise, as their factories set them, so that they appear in the contract with their status (`errors/known-code`).
|
|
46
46
|
errors: [{{route.errorCodes}}],
|
|
47
47
|
security: {{route.security}},
|
|
48
48
|
},
|