ddd-ts-kit 0.110.1 → 0.112.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 +164 -0
- package/README.fr.md +39 -8
- package/README.md +36 -7
- package/dist/alias/index.d.ts +2 -0
- package/dist/alias/index.d.ts.map +1 -1
- package/dist/alias/index.js +2 -0
- package/dist/alias/index.js.map +1 -1
- package/dist/alias/neighbour-sources.d.ts +17 -0
- package/dist/alias/neighbour-sources.d.ts.map +1 -0
- package/dist/alias/neighbour-sources.js +11 -0
- package/dist/alias/neighbour-sources.js.map +1 -0
- package/dist/alias/neighbour-suffix.d.ts +8 -0
- package/dist/alias/neighbour-suffix.d.ts.map +1 -0
- package/dist/alias/neighbour-suffix.js +10 -0
- package/dist/alias/neighbour-suffix.js.map +1 -0
- package/dist/build/rewrite-aliases.d.ts.map +1 -1
- package/dist/build/rewrite-aliases.js +11 -0
- package/dist/build/rewrite-aliases.js.map +1 -1
- package/dist/check/alias/build-scripts.d.ts.map +1 -1
- package/dist/check/alias/build-scripts.js +4 -8
- package/dist/check/alias/build-scripts.js.map +1 -1
- package/dist/check/alias/compiler-options-of.d.ts +3 -3
- package/dist/check/alias/compiler-options-of.js +17 -6
- package/dist/check/alias/compiler-options-of.js.map +1 -1
- package/dist/check/alias/neighbour-sources.d.ts +12 -0
- package/dist/check/alias/neighbour-sources.d.ts.map +1 -0
- package/dist/check/alias/neighbour-sources.js +80 -0
- package/dist/check/alias/neighbour-sources.js.map +1 -0
- package/dist/check/alias/script-steps.d.ts +11 -0
- package/dist/check/alias/script-steps.d.ts.map +1 -0
- package/dist/check/alias/script-steps.js +22 -0
- package/dist/check/alias/script-steps.js.map +1 -0
- package/dist/check/aspects/adapter-policies.d.ts +10 -0
- package/dist/check/aspects/adapter-policies.d.ts.map +1 -0
- package/dist/check/aspects/adapter-policies.js +104 -0
- package/dist/check/aspects/adapter-policies.js.map +1 -0
- package/dist/check/aspects/adapter-policy.d.ts +18 -0
- package/dist/check/aspects/adapter-policy.d.ts.map +1 -0
- package/dist/check/aspects/adapter-policy.js +2 -0
- package/dist/check/aspects/adapter-policy.js.map +1 -0
- package/dist/check/aspects/is-under-condition.d.ts +7 -0
- package/dist/check/aspects/is-under-condition.d.ts.map +1 -0
- package/dist/check/aspects/is-under-condition.js +50 -0
- package/dist/check/aspects/is-under-condition.js.map +1 -0
- package/dist/check/aspects/stated-policy.d.ts +18 -0
- package/dist/check/aspects/stated-policy.d.ts.map +1 -0
- package/dist/check/aspects/stated-policy.js +39 -0
- package/dist/check/aspects/stated-policy.js.map +1 -0
- 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/explain/imports-docs.d.ts.map +1 -1
- package/dist/check/explain/imports-docs.js +5 -3
- package/dist/check/explain/imports-docs.js.map +1 -1
- package/dist/check/explain/persistence-docs.d.ts.map +1 -1
- package/dist/check/explain/persistence-docs.js +21 -0
- package/dist/check/explain/persistence-docs.js.map +1 -1
- package/dist/check/explain/standard-docs.d.ts.map +1 -1
- package/dist/check/explain/standard-docs.js +16 -0
- package/dist/check/explain/standard-docs.js.map +1 -1
- package/dist/check/explain/tenancy-docs.d.ts.map +1 -1
- package/dist/check/explain/tenancy-docs.js +3 -1
- package/dist/check/explain/tenancy-docs.js.map +1 -1
- package/dist/check/files/kit-content-types.d.ts +12 -0
- package/dist/check/files/kit-content-types.d.ts.map +1 -0
- package/dist/check/files/kit-content-types.js +38 -0
- package/dist/check/files/kit-content-types.js.map +1 -0
- package/dist/check/files/upload-content-defect.d.ts +7 -0
- package/dist/check/files/upload-content-defect.d.ts.map +1 -0
- package/dist/check/files/upload-content-defect.js +2 -0
- package/dist/check/files/upload-content-defect.js.map +1 -0
- package/dist/check/files/upload-content-defects.d.ts +9 -0
- package/dist/check/files/upload-content-defects.d.ts.map +1 -0
- package/dist/check/files/upload-content-defects.js +54 -0
- package/dist/check/files/upload-content-defects.js.map +1 -0
- package/dist/check/files/upload-declaration.d.ts +7 -0
- package/dist/check/files/upload-declaration.d.ts.map +1 -0
- package/dist/check/files/upload-declaration.js +2 -0
- package/dist/check/files/upload-declaration.js.map +1 -0
- package/dist/check/files/upload-declarations.d.ts +9 -0
- package/dist/check/files/upload-declarations.d.ts.map +1 -0
- package/dist/check/files/upload-declarations.js +41 -0
- package/dist/check/files/upload-declarations.js.map +1 -0
- package/dist/check/fixtures/alias-declared-fixtures.d.ts.map +1 -1
- package/dist/check/fixtures/alias-declared-fixtures.js +95 -1
- package/dist/check/fixtures/alias-declared-fixtures.js.map +1 -1
- 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/imports-fixtures.d.ts.map +1 -1
- package/dist/check/fixtures/imports-fixtures.js +97 -0
- package/dist/check/fixtures/imports-fixtures.js.map +1 -1
- package/dist/check/fixtures/standard-fixtures.d.ts.map +1 -1
- package/dist/check/fixtures/standard-fixtures.js +42 -0
- package/dist/check/fixtures/standard-fixtures.js.map +1 -1
- package/dist/check/fixtures/tenancy-advisory-lock-fixtures.d.ts +9 -0
- package/dist/check/fixtures/tenancy-advisory-lock-fixtures.d.ts.map +1 -0
- package/dist/check/fixtures/tenancy-advisory-lock-fixtures.js +45 -0
- package/dist/check/fixtures/tenancy-advisory-lock-fixtures.js.map +1 -0
- package/dist/check/fixtures/tenancy-fixtures.d.ts.map +1 -1
- package/dist/check/fixtures/tenancy-fixtures.js +2 -0
- package/dist/check/fixtures/tenancy-fixtures.js.map +1 -1
- package/dist/check/fixtures/upload-fixtures.d.ts +3 -0
- package/dist/check/fixtures/upload-fixtures.d.ts.map +1 -0
- package/dist/check/fixtures/upload-fixtures.js +94 -0
- package/dist/check/fixtures/upload-fixtures.js.map +1 -0
- package/dist/check/migrations/is-working-migration.d.ts +6 -0
- package/dist/check/migrations/is-working-migration.d.ts.map +1 -0
- package/dist/check/migrations/is-working-migration.js +8 -0
- package/dist/check/migrations/is-working-migration.js.map +1 -0
- package/dist/check/migrations/journal-entries.d.ts +4 -0
- package/dist/check/migrations/journal-entries.d.ts.map +1 -0
- package/dist/check/migrations/journal-entries.js +21 -0
- package/dist/check/migrations/journal-entries.js.map +1 -0
- package/dist/check/migrations/read-drizzle-migrations.d.ts.map +1 -1
- package/dist/check/migrations/read-drizzle-migrations.js +4 -9
- package/dist/check/migrations/read-drizzle-migrations.js.map +1 -1
- package/dist/check/modules/imported-modules.d.ts +4 -0
- package/dist/check/modules/imported-modules.d.ts.map +1 -0
- package/dist/check/modules/imported-modules.js +5 -0
- package/dist/check/modules/imported-modules.js.map +1 -0
- package/dist/check/modules/module-imports.d.ts +17 -0
- package/dist/check/modules/module-imports.d.ts.map +1 -0
- package/dist/check/modules/module-imports.js +23 -0
- package/dist/check/modules/module-imports.js.map +1 -0
- package/dist/check/project/assemble-project.d.ts.map +1 -1
- package/dist/check/project/assemble-project.js +1 -8
- package/dist/check/project/assemble-project.js.map +1 -1
- package/dist/check/project/file-severity.d.ts +4 -0
- package/dist/check/project/file-severity.d.ts.map +1 -0
- package/dist/check/project/file-severity.js +11 -0
- package/dist/check/project/file-severity.js.map +1 -0
- package/dist/check/project/load-project.js +1 -10
- package/dist/check/project/load-project.js.map +1 -1
- package/dist/check/project/not-in-the-tree.d.ts +10 -0
- package/dist/check/project/not-in-the-tree.d.ts.map +1 -0
- package/dist/check/project/not-in-the-tree.js +17 -0
- package/dist/check/project/not-in-the-tree.js.map +1 -0
- package/dist/check/project/skipped-directories.d.ts +3 -0
- package/dist/check/project/skipped-directories.d.ts.map +1 -0
- package/dist/check/project/skipped-directories.js +3 -0
- package/dist/check/project/skipped-directories.js.map +1 -0
- package/dist/check/project/walk-directory.d.ts.map +1 -1
- package/dist/check/project/walk-directory.js +1 -1
- package/dist/check/project/walk-directory.js.map +1 -1
- package/dist/check/rules/aspects-timeout-covers-delegate.d.ts +3 -0
- package/dist/check/rules/aspects-timeout-covers-delegate.d.ts.map +1 -0
- package/dist/check/rules/aspects-timeout-covers-delegate.js +179 -0
- package/dist/check/rules/aspects-timeout-covers-delegate.js.map +1 -0
- package/dist/check/rules/files-upload-content-rule.d.ts +3 -0
- package/dist/check/rules/files-upload-content-rule.d.ts.map +1 -0
- package/dist/check/rules/files-upload-content-rule.js +25 -0
- package/dist/check/rules/files-upload-content-rule.js.map +1 -0
- package/dist/check/rules/imports-alias-declared.d.ts.map +1 -1
- package/dist/check/rules/imports-alias-declared.js +3 -1
- package/dist/check/rules/imports-alias-declared.js.map +1 -1
- package/dist/check/rules/imports-alias-only.d.ts.map +1 -1
- package/dist/check/rules/imports-alias-only.js +86 -7
- package/dist/check/rules/imports-alias-only.js.map +1 -1
- package/dist/check/rules/module-no-cycle.d.ts.map +1 -1
- package/dist/check/rules/module-no-cycle.js +12 -34
- package/dist/check/rules/module-no-cycle.js.map +1 -1
- package/dist/check/rules/privacy-declared-field.js +1 -1
- package/dist/check/rules/privacy-declared-field.js.map +1 -1
- package/dist/check/rules/tenancy-scoped-statement.d.ts.map +1 -1
- package/dist/check/rules/tenancy-scoped-statement.js +11 -3
- package/dist/check/rules/tenancy-scoped-statement.js.map +1 -1
- package/dist/cli-error.d.ts +7 -2
- package/dist/cli-error.d.ts.map +1 -1
- package/dist/cli-error.js +8 -2
- package/dist/cli-error.js.map +1 -1
- package/dist/commands/generate.js +3 -0
- package/dist/commands/generate.js.map +1 -1
- package/dist/commands/knex-generate.d.ts.map +1 -1
- package/dist/commands/knex-generate.js +2 -1
- package/dist/commands/knex-generate.js.map +1 -1
- package/dist/commands/move-to-module.d.ts +6 -1
- package/dist/commands/move-to-module.d.ts.map +1 -1
- package/dist/commands/move-to-module.js +28 -3
- package/dist/commands/move-to-module.js.map +1 -1
- package/dist/commands/prisma-generate.d.ts.map +1 -1
- package/dist/commands/prisma-generate.js +2 -1
- package/dist/commands/prisma-generate.js.map +1 -1
- package/dist/commands/typeorm-generate.d.ts.map +1 -1
- package/dist/commands/typeorm-generate.js +2 -1
- package/dist/commands/typeorm-generate.js.map +1 -1
- package/dist/commands/verify-merge.d.ts +4 -2
- package/dist/commands/verify-merge.d.ts.map +1 -1
- package/dist/commands/verify-merge.js +8 -5
- package/dist/commands/verify-merge.js.map +1 -1
- package/dist/context-layout/context-layout.d.ts.map +1 -1
- package/dist/context-layout/context-layout.js +6 -0
- package/dist/context-layout/context-layout.js.map +1 -1
- package/dist/context-layout/module-moves.d.ts +8 -0
- package/dist/context-layout/module-moves.d.ts.map +1 -1
- package/dist/context-layout/module-moves.js +14 -3
- package/dist/context-layout/module-moves.js.map +1 -1
- package/dist/context-layout/runner-configs-by-hand.d.ts.map +1 -1
- package/dist/context-layout/runner-configs-by-hand.js +12 -0
- package/dist/context-layout/runner-configs-by-hand.js.map +1 -1
- package/dist/context-layout/settle.d.ts +9 -0
- package/dist/context-layout/settle.d.ts.map +1 -1
- package/dist/context-layout/settle.js +25 -3
- package/dist/context-layout/settle.js.map +1 -1
- package/dist/describe/read-adapters.d.ts.map +1 -1
- package/dist/describe/read-adapters.js +5 -1
- package/dist/describe/read-adapters.js.map +1 -1
- package/dist/describe/read-ports.js +8 -1
- package/dist/describe/read-ports.js.map +1 -1
- package/dist/generate/generate-options.d.ts +10 -0
- package/dist/generate/generate-options.d.ts.map +1 -1
- package/dist/generate/generate-options.js +3 -0
- package/dist/generate/generate-options.js.map +1 -1
- package/dist/generate/kind.d.ts +6 -0
- package/dist/generate/kind.d.ts.map +1 -1
- package/dist/generate/kinds/adapter-kind.d.ts.map +1 -1
- package/dist/generate/kinds/adapter-kind.js +12 -0
- package/dist/generate/kinds/adapter-kind.js.map +1 -1
- package/dist/generate/kinds/declare-storage.d.ts.map +1 -1
- package/dist/generate/kinds/declare-storage.js +3 -57
- package/dist/generate/kinds/declare-storage.js.map +1 -1
- package/dist/generate/kinds/declare-table.d.ts +14 -0
- package/dist/generate/kinds/declare-table.d.ts.map +1 -0
- package/dist/generate/kinds/declare-table.js +72 -0
- package/dist/generate/kinds/declare-table.js.map +1 -0
- package/dist/generate/kinds/e2e/job-slug.d.ts +3 -0
- package/dist/generate/kinds/e2e/job-slug.d.ts.map +1 -0
- package/dist/generate/kinds/e2e/job-slug.js +8 -0
- package/dist/generate/kinds/e2e/job-slug.js.map +1 -0
- package/dist/generate/kinds/e2e/job-spec.d.ts +16 -0
- package/dist/generate/kinds/e2e/job-spec.d.ts.map +1 -0
- package/dist/generate/kinds/e2e/job-spec.js +54 -0
- package/dist/generate/kinds/e2e/job-spec.js.map +1 -0
- package/dist/generate/kinds/e2e/jobs-sending.d.ts +17 -5
- package/dist/generate/kinds/e2e/jobs-sending.d.ts.map +1 -1
- package/dist/generate/kinds/e2e/jobs-sending.js +15 -6
- package/dist/generate/kinds/e2e/jobs-sending.js.map +1 -1
- package/dist/generate/kinds/e2e/reaction-of.d.ts +5 -5
- package/dist/generate/kinds/e2e/reaction-of.d.ts.map +1 -1
- package/dist/generate/kinds/e2e/reaction-of.js +15 -8
- package/dist/generate/kinds/e2e/reaction-of.js.map +1 -1
- package/dist/generate/kinds/e2e/starting-jobs.d.ts +10 -0
- package/dist/generate/kinds/e2e/starting-jobs.d.ts.map +1 -0
- package/dist/generate/kinds/e2e/starting-jobs.js +33 -0
- package/dist/generate/kinds/e2e/starting-jobs.js.map +1 -0
- package/dist/generate/kinds/e2e-kind.d.ts.map +1 -1
- package/dist/generate/kinds/e2e-kind.js +47 -35
- package/dist/generate/kinds/e2e-kind.js.map +1 -1
- package/dist/generate/kinds/file-upload/upload-file-vars.d.ts +9 -0
- package/dist/generate/kinds/file-upload/upload-file-vars.d.ts.map +1 -0
- package/dist/generate/kinds/file-upload/upload-file-vars.js +39 -0
- package/dist/generate/kinds/file-upload/upload-file-vars.js.map +1 -0
- package/dist/generate/kinds/file-upload/write-nest-upload-controller.d.ts.map +1 -1
- package/dist/generate/kinds/file-upload/write-nest-upload-controller.js +2 -1
- package/dist/generate/kinds/file-upload/write-nest-upload-controller.js.map +1 -1
- package/dist/generate/kinds/file-upload/write-upload-controller.d.ts.map +1 -1
- package/dist/generate/kinds/file-upload/write-upload-controller.js +2 -1
- package/dist/generate/kinds/file-upload/write-upload-controller.js.map +1 -1
- package/dist/generate/kinds/file-upload-kind.d.ts.map +1 -1
- package/dist/generate/kinds/file-upload-kind.js +5 -3
- package/dist/generate/kinds/file-upload-kind.js.map +1 -1
- package/dist/generate/kinds/generate-repository.d.ts +8 -0
- package/dist/generate/kinds/generate-repository.d.ts.map +1 -1
- package/dist/generate/kinds/generate-repository.js +2 -13
- package/dist/generate/kinds/generate-repository.js.map +1 -1
- package/dist/generate/kinds/note-the-migration.d.ts +4 -0
- package/dist/generate/kinds/note-the-migration.d.ts.map +1 -0
- package/dist/generate/kinds/note-the-migration.js +13 -0
- package/dist/generate/kinds/note-the-migration.js.map +1 -0
- package/dist/generate/kinds/personal-data/columns-of-table.d.ts +18 -0
- package/dist/generate/kinds/personal-data/columns-of-table.d.ts.map +1 -0
- package/dist/generate/kinds/personal-data/columns-of-table.js +31 -0
- package/dist/generate/kinds/personal-data/columns-of-table.js.map +1 -0
- package/dist/generate/kinds/personal-data/declare-personal-data.d.ts.map +1 -1
- package/dist/generate/kinds/personal-data/declare-personal-data.js +7 -52
- package/dist/generate/kinds/personal-data/declare-personal-data.js.map +1 -1
- package/dist/generate/kinds/personal-data/declare-table-personal-fields.d.ts +11 -0
- package/dist/generate/kinds/personal-data/declare-table-personal-fields.d.ts.map +1 -0
- package/dist/generate/kinds/personal-data/declare-table-personal-fields.js +71 -0
- package/dist/generate/kinds/personal-data/declare-table-personal-fields.js.map +1 -0
- package/dist/generate/kinds/personal-data/personal-request-of-table.d.ts +11 -0
- package/dist/generate/kinds/personal-data/personal-request-of-table.d.ts.map +1 -0
- package/dist/generate/kinds/personal-data/personal-request-of-table.js +20 -0
- package/dist/generate/kinds/personal-data/personal-request-of-table.js.map +1 -0
- package/dist/generate/kinds/personal-data/personal-vars.d.ts +7 -0
- package/dist/generate/kinds/personal-data/personal-vars.d.ts.map +1 -1
- package/dist/generate/kinds/personal-data/personal-vars.js +14 -11
- package/dist/generate/kinds/personal-data/personal-vars.js.map +1 -1
- package/dist/generate/kinds/personal-data/schema-table.d.ts +13 -0
- package/dist/generate/kinds/personal-data/schema-table.d.ts.map +1 -0
- package/dist/generate/kinds/personal-data/schema-table.js +2 -0
- package/dist/generate/kinds/personal-data/schema-table.js.map +1 -0
- package/dist/generate/kinds/personal-data/schema-tables-of.d.ts +9 -0
- package/dist/generate/kinds/personal-data/schema-tables-of.d.ts.map +1 -0
- package/dist/generate/kinds/personal-data/schema-tables-of.js +78 -0
- package/dist/generate/kinds/personal-data/schema-tables-of.js.map +1 -0
- package/dist/generate/kinds/personal-data/table-of-schema.d.ts +15 -0
- package/dist/generate/kinds/personal-data/table-of-schema.d.ts.map +1 -0
- package/dist/generate/kinds/personal-data/table-of-schema.js +39 -0
- package/dist/generate/kinds/personal-data/table-of-schema.js.map +1 -0
- package/dist/generate/kinds/personal-data/write-personal-declaration.d.ts +20 -0
- package/dist/generate/kinds/personal-data/write-personal-declaration.d.ts.map +1 -0
- package/dist/generate/kinds/personal-data/write-personal-declaration.js +63 -0
- package/dist/generate/kinds/personal-data/write-personal-declaration.js.map +1 -0
- package/dist/generate/kinds/personal-fields-kind.d.ts +3 -0
- package/dist/generate/kinds/personal-fields-kind.d.ts.map +1 -0
- package/dist/generate/kinds/personal-fields-kind.js +15 -0
- package/dist/generate/kinds/personal-fields-kind.js.map +1 -0
- package/dist/generate/kinds/projection-kind.d.ts.map +1 -1
- package/dist/generate/kinds/projection-kind.js +2 -1
- package/dist/generate/kinds/projection-kind.js.map +1 -1
- package/dist/generate/kinds/read-model/field-lines.d.ts +11 -0
- package/dist/generate/kinds/read-model/field-lines.d.ts.map +1 -0
- package/dist/generate/kinds/read-model/field-lines.js +85 -0
- package/dist/generate/kinds/read-model/field-lines.js.map +1 -0
- package/dist/generate/kinds/read-model/list-read-model.d.ts +17 -0
- package/dist/generate/kinds/read-model/list-read-model.d.ts.map +1 -0
- package/dist/generate/kinds/read-model/list-read-model.js +22 -0
- package/dist/generate/kinds/read-model/list-read-model.js.map +1 -0
- package/dist/generate/kinds/read-model/live-rows-check.d.ts +22 -0
- package/dist/generate/kinds/read-model/live-rows-check.d.ts.map +1 -0
- package/dist/generate/kinds/read-model/live-rows-check.js +47 -0
- package/dist/generate/kinds/read-model/live-rows-check.js.map +1 -0
- package/dist/generate/kinds/read-model/read-model-fields.d.ts +19 -0
- package/dist/generate/kinds/read-model/read-model-fields.d.ts.map +1 -0
- package/dist/generate/kinds/read-model/read-model-fields.js +31 -0
- package/dist/generate/kinds/read-model/read-model-fields.js.map +1 -0
- package/dist/generate/kinds/read-model/read-model-store.d.ts +24 -0
- package/dist/generate/kinds/read-model/read-model-store.d.ts.map +1 -0
- package/dist/generate/kinds/read-model/read-model-store.js +39 -0
- package/dist/generate/kinds/read-model/read-model-store.js.map +1 -0
- package/dist/generate/kinds/read-model/read-model-table.d.ts +11 -0
- package/dist/generate/kinds/read-model/read-model-table.d.ts.map +1 -0
- package/dist/generate/kinds/read-model/read-model-table.js +2 -0
- package/dist/generate/kinds/read-model/read-model-table.js.map +1 -0
- package/dist/generate/kinds/read-model-kind.d.ts +3 -0
- package/dist/generate/kinds/read-model-kind.d.ts.map +1 -0
- package/dist/generate/kinds/read-model-kind.js +103 -0
- package/dist/generate/kinds/read-model-kind.js.map +1 -0
- package/dist/generate/kinds/service-kind.d.ts.map +1 -1
- package/dist/generate/kinds/service-kind.js +8 -0
- package/dist/generate/kinds/service-kind.js.map +1 -1
- package/dist/generate/kinds/wire-context.d.ts.map +1 -1
- package/dist/generate/kinds/wire-context.js +4 -0
- package/dist/generate/kinds/wire-context.js.map +1 -1
- package/dist/generate/kinds.d.ts.map +1 -1
- package/dist/generate/kinds.js +4 -0
- package/dist/generate/kinds.js.map +1 -1
- package/dist/generate/shared-writes.d.ts.map +1 -1
- package/dist/generate/shared-writes.js +9 -0
- package/dist/generate/shared-writes.js.map +1 -1
- package/dist/help/tool-notes.d.ts.map +1 -1
- package/dist/help/tool-notes.js +7 -2
- package/dist/help/tool-notes.js.map +1 -1
- package/dist/help/usage.js +1 -1
- package/dist/help/work-notes.d.ts.map +1 -1
- package/dist/help/work-notes.js +9 -2
- package/dist/help/work-notes.js.map +1 -1
- package/dist/init/files/end-to-end-files.d.ts.map +1 -1
- package/dist/init/files/end-to-end-files.js +3 -0
- package/dist/init/files/end-to-end-files.js.map +1 -1
- package/dist/init/files/persistence-files.d.ts.map +1 -1
- package/dist/init/files/persistence-files.js +8 -0
- package/dist/init/files/persistence-files.js.map +1 -1
- package/dist/init/files/script-files.d.ts +2 -1
- package/dist/init/files/script-files.d.ts.map +1 -1
- package/dist/init/files/script-files.js +6 -1
- package/dist/init/files/script-files.js.map +1 -1
- package/dist/init/is-team-file.d.ts +2 -2
- package/dist/init/is-team-file.d.ts.map +1 -1
- package/dist/init/is-team-file.js +5 -4
- package/dist/init/is-team-file.js.map +1 -1
- package/dist/init/list-read-models.d.ts +17 -0
- package/dist/init/list-read-models.d.ts.map +1 -0
- package/dist/init/list-read-models.js +74 -0
- package/dist/init/list-read-models.js.map +1 -0
- package/dist/init/manifest/database-scripts.d.ts.map +1 -1
- package/dist/init/manifest/database-scripts.js +8 -0
- package/dist/init/manifest/database-scripts.js.map +1 -1
- package/dist/init/manifest/dependencies-for.d.ts.map +1 -1
- package/dist/init/manifest/dependencies-for.js +10 -7
- package/dist/init/manifest/dependencies-for.js.map +1 -1
- package/dist/init/manifest/versions.js +25 -25
- package/dist/init/rewire-contexts.d.ts +4 -2
- package/dist/init/rewire-contexts.d.ts.map +1 -1
- package/dist/init/rewire-contexts.js +10 -2
- package/dist/init/rewire-contexts.js.map +1 -1
- package/dist/init/run-init.js +1 -1
- package/dist/init/run-init.js.map +1 -1
- package/dist/init/wiring-notes.js +1 -1
- package/dist/init/wiring-notes.js.map +1 -1
- package/dist/init/write-type-script-configs.d.ts +3 -1
- package/dist/init/write-type-script-configs.d.ts.map +1 -1
- package/dist/init/write-type-script-configs.js +14 -2
- package/dist/init/write-type-script-configs.js.map +1 -1
- package/dist/layout/fit-block.js +4 -0
- package/dist/layout/fit-block.js.map +1 -1
- package/dist/merge/format-merge-report.js +5 -2
- package/dist/merge/format-merge-report.js.map +1 -1
- package/dist/merge/land-drizzle.d.ts +4 -0
- package/dist/merge/land-drizzle.d.ts.map +1 -1
- package/dist/merge/land-drizzle.js +6 -1
- package/dist/merge/land-drizzle.js.map +1 -1
- package/dist/merge/land-up-to-date.d.ts +15 -0
- package/dist/merge/land-up-to-date.d.ts.map +1 -0
- package/dist/merge/land-up-to-date.js +76 -0
- package/dist/merge/land-up-to-date.js.map +1 -0
- package/dist/merge/lost/format-merge-verification.d.ts +2 -1
- package/dist/merge/lost/format-merge-verification.d.ts.map +1 -1
- package/dist/merge/lost/format-merge-verification.js +13 -2
- package/dist/merge/lost/format-merge-verification.js.map +1 -1
- package/dist/merge/lost/merge-verification.d.ts +4 -0
- package/dist/merge/lost/merge-verification.d.ts.map +1 -1
- package/dist/merge/lost/verify-merges.d.ts +2 -1
- package/dist/merge/lost/verify-merges.d.ts.map +1 -1
- package/dist/merge/lost/verify-merges.js +10 -4
- package/dist/merge/lost/verify-merges.js.map +1 -1
- package/dist/merge/merge-trunk.d.ts +2 -1
- package/dist/merge/merge-trunk.d.ts.map +1 -1
- package/dist/merge/merge-trunk.js +5 -2
- package/dist/merge/merge-trunk.js.map +1 -1
- package/dist/merge/next-steps.d.ts +3 -0
- package/dist/merge/next-steps.d.ts.map +1 -1
- package/dist/merge/next-steps.js +3 -0
- package/dist/merge/next-steps.js.map +1 -1
- package/dist/merge/order/applied-under-old-name.d.ts +13 -0
- package/dist/merge/order/applied-under-old-name.d.ts.map +1 -0
- package/dist/merge/order/applied-under-old-name.js +14 -0
- package/dist/merge/order/applied-under-old-name.js.map +1 -0
- package/dist/merge/order/comes-after.d.ts +8 -0
- package/dist/merge/order/comes-after.d.ts.map +1 -0
- package/dist/merge/order/comes-after.js +9 -0
- package/dist/merge/order/comes-after.js.map +1 -0
- package/dist/merge/order/drizzle-order.d.ts +11 -0
- package/dist/merge/order/drizzle-order.d.ts.map +1 -0
- package/dist/merge/order/drizzle-order.js +64 -0
- package/dist/merge/order/drizzle-order.js.map +1 -0
- package/dist/merge/order/in-order.d.ts +4 -0
- package/dist/merge/order/in-order.d.ts.map +1 -0
- package/dist/merge/order/in-order.js +6 -0
- package/dist/merge/order/in-order.js.map +1 -0
- package/dist/merge/order/migration-order-finding.d.ts +18 -0
- package/dist/merge/order/migration-order-finding.d.ts.map +1 -0
- package/dist/merge/order/migration-order-finding.js +2 -0
- package/dist/merge/order/migration-order-finding.js.map +1 -0
- package/dist/merge/order/migration-order.d.ts +12 -0
- package/dist/merge/order/migration-order.d.ts.map +1 -0
- package/dist/merge/order/migration-order.js +21 -0
- package/dist/merge/order/migration-order.js.map +1 -0
- package/dist/merge/order/migrations-of-commit.d.ts +7 -0
- package/dist/merge/order/migrations-of-commit.d.ts.map +1 -0
- package/dist/merge/order/migrations-of-commit.js +43 -0
- package/dist/merge/order/migrations-of-commit.js.map +1 -0
- package/dist/merge/order/migrations-of-tree.d.ts +9 -0
- package/dist/merge/order/migrations-of-tree.d.ts.map +1 -0
- package/dist/merge/order/migrations-of-tree.js +25 -0
- package/dist/merge/order/migrations-of-tree.js.map +1 -0
- package/dist/merge/order/named-order.d.ts +11 -0
- package/dist/merge/order/named-order.d.ts.map +1 -0
- package/dist/merge/order/named-order.js +36 -0
- package/dist/merge/order/named-order.js.map +1 -0
- package/dist/merge/order/ordered-migration.d.ts +12 -0
- package/dist/merge/order/ordered-migration.d.ts.map +1 -0
- package/dist/merge/order/ordered-migration.js +2 -0
- package/dist/merge/order/ordered-migration.js.map +1 -0
- package/dist/merge/order/trunk-to-follow.d.ts +9 -0
- package/dist/merge/order/trunk-to-follow.d.ts.map +1 -0
- package/dist/merge/order/trunk-to-follow.js +2 -0
- package/dist/merge/order/trunk-to-follow.js.map +1 -0
- package/dist/merge/renumber-migrations.d.ts +14 -5
- package/dist/merge/renumber-migrations.d.ts.map +1 -1
- package/dist/merge/renumber-migrations.js +141 -60
- package/dist/merge/renumber-migrations.js.map +1 -1
- package/dist/merge/restamp-class.d.ts +9 -0
- package/dist/merge/restamp-class.d.ts.map +1 -0
- package/dist/merge/restamp-class.js +30 -0
- package/dist/merge/restamp-class.js.map +1 -0
- package/dist/migration/index.d.ts +1 -0
- package/dist/migration/index.d.ts.map +1 -1
- package/dist/migration/index.js +1 -0
- package/dist/migration/index.js.map +1 -1
- package/dist/migration/plan-replay.d.ts.map +1 -1
- package/dist/migration/plan-replay.js +2 -1
- package/dist/migration/plan-replay.js.map +1 -1
- package/dist/migration/refuse-taken-migration-name.d.ts +8 -0
- package/dist/migration/refuse-taken-migration-name.d.ts.map +1 -0
- package/dist/migration/refuse-taken-migration-name.js +22 -0
- package/dist/migration/refuse-taken-migration-name.js.map +1 -0
- package/dist/migration/replay-drizzle-migrations.d.ts +5 -0
- package/dist/migration/replay-drizzle-migrations.d.ts.map +1 -1
- package/dist/migration/replay-drizzle-migrations.js +10 -2
- package/dist/migration/replay-drizzle-migrations.js.map +1 -1
- package/dist/migration/replay-plan.d.ts +2 -2
- package/dist/migration/replay-plan.d.ts.map +1 -1
- package/dist/migration/restore-migration-folder.d.ts +6 -2
- package/dist/migration/restore-migration-folder.d.ts.map +1 -1
- package/dist/migration/restore-migration-folder.js +14 -7
- package/dist/migration/restore-migration-folder.js.map +1 -1
- package/dist/migration/snapshot-migration-folder.d.ts +7 -0
- package/dist/migration/snapshot-migration-folder.d.ts.map +1 -0
- package/dist/migration/snapshot-migration-folder.js +12 -0
- package/dist/migration/snapshot-migration-folder.js.map +1 -0
- package/dist/move-to-module/before-the-move.d.ts +5 -0
- package/dist/move-to-module/before-the-move.d.ts.map +1 -0
- package/dist/move-to-module/before-the-move.js +13 -0
- package/dist/move-to-module/before-the-move.js.map +1 -0
- package/dist/move-to-module/closed-cycles.d.ts +21 -0
- package/dist/move-to-module/closed-cycles.d.ts.map +1 -0
- package/dist/move-to-module/closed-cycles.js +66 -0
- package/dist/move-to-module/closed-cycles.js.map +1 -0
- package/dist/move-to-module/cycle-lines.d.ts +7 -0
- package/dist/move-to-module/cycle-lines.d.ts.map +1 -0
- package/dist/move-to-module/cycle-lines.js +22 -0
- package/dist/move-to-module/cycle-lines.js.map +1 -0
- package/dist/move-to-module/cycle-refusal.d.ts +17 -0
- package/dist/move-to-module/cycle-refusal.d.ts.map +1 -0
- package/dist/move-to-module/cycle-refusal.js +25 -0
- package/dist/move-to-module/cycle-refusal.js.map +1 -0
- package/dist/move-to-module/index.d.ts +5 -0
- package/dist/move-to-module/index.d.ts.map +1 -1
- package/dist/move-to-module/index.js +4 -0
- package/dist/move-to-module/index.js.map +1 -1
- package/dist/move-to-module/module-imports-in.d.ts +11 -0
- package/dist/move-to-module/module-imports-in.d.ts.map +1 -0
- package/dist/move-to-module/module-imports-in.js +32 -0
- package/dist/move-to-module/module-imports-in.js.map +1 -0
- package/dist/move-to-module/moves-into-module.d.ts.map +1 -1
- package/dist/move-to-module/moves-into-module.js +6 -18
- package/dist/move-to-module/moves-into-module.js.map +1 -1
- package/dist/move-to-module/place-in-module.d.ts +13 -0
- package/dist/move-to-module/place-in-module.d.ts.map +1 -0
- package/dist/move-to-module/place-in-module.js +24 -0
- package/dist/move-to-module/place-in-module.js.map +1 -0
- package/dist/move-to-module/watch-cycles.d.ts +19 -0
- package/dist/move-to-module/watch-cycles.d.ts.map +1 -0
- package/dist/move-to-module/watch-cycles.js +51 -0
- package/dist/move-to-module/watch-cycles.js.map +1 -0
- package/dist/presets/no-flags.d.ts.map +1 -1
- package/dist/presets/no-flags.js +1 -0
- package/dist/presets/no-flags.js.map +1 -1
- package/dist/run.js +1 -1
- package/dist/run.js.map +1 -1
- package/dist/slice/format-slice-verification.d.ts.map +1 -1
- package/dist/slice/format-slice-verification.js +11 -5
- package/dist/slice/format-slice-verification.js.map +1 -1
- package/dist/stack/alias-vars.d.ts +3 -1
- package/dist/stack/alias-vars.d.ts.map +1 -1
- package/dist/stack/alias-vars.js +5 -2
- package/dist/stack/alias-vars.js.map +1 -1
- package/dist/stack/end-to-end-vars.d.ts +9 -0
- package/dist/stack/end-to-end-vars.d.ts.map +1 -0
- package/dist/stack/end-to-end-vars.js +32 -0
- package/dist/stack/end-to-end-vars.js.map +1 -0
- package/dist/stack/stack-vars.d.ts.map +1 -1
- package/dist/stack/stack-vars.js +2 -0
- package/dist/stack/stack-vars.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/worker/briefing-of.js +2 -2
- package/dist/worker/briefing-of.js.map +1 -1
- package/package.json +6 -6
- package/templates/e2e/e2e-background-job-case.ts.tpl +12 -0
- package/templates/e2e/e2e-job.spec.ts.tpl +3 -3
- package/templates/file-upload/controller.spec.ts.tpl +66 -2
- package/templates/file-upload/controller.ts.tpl +12 -0
- package/templates/file-upload/handler.spec.ts.tpl +3 -3
- package/templates/init/README.md.tpl +20 -1
- package/templates/init/e2e/jest.e2e.config.js.tpl +29 -5
- package/templates/init/e2e/start-application.database.ts.tpl +40 -2
- package/templates/init/e2e/start-application.memory.ts.tpl +36 -0
- package/templates/init/e2e/test-database-setup.ts.tpl +120 -0
- package/templates/init/e2e/vitest.e2e.config.ts.tpl +14 -4
- package/templates/init/platform/composition/compose-application.container.ts.tpl +5 -0
- package/templates/init/platform/composition/compose-application.manual.ts.tpl +20 -3
- package/templates/init/platform/composition/create-platform.manual.ts.tpl +6 -0
- package/templates/init/platform/composition/platform-options.manual.ts.tpl +11 -0
- package/templates/init/platform/composition/platform.manual.ts.tpl +7 -0
- package/templates/init/platform/composition/platform.module.container.ts.tpl +34 -0
- package/templates/init/platform/database/connect-to-database.drizzle.ts.tpl +7 -2
- package/templates/init/platform/database/open-test-database.drizzle.ts.tpl +27 -4
- package/templates/init/platform/database/open-test-database.knex.ts.tpl +26 -3
- package/templates/init/platform/database/open-test-database.prisma.ts.tpl +27 -3
- package/templates/init/platform/database/open-test-database.typeorm.ts.tpl +27 -3
- package/templates/init/platform/database/read-model-tables.ts.tpl +67 -0
- package/templates/init/platform/database/test-database-budget.ts.tpl +108 -0
- package/templates/init/platform/database/test-database-clone.ts.tpl +75 -0
- package/templates/init/platform/database/test-database-copy.ts.tpl +76 -0
- package/templates/init/platform/database/test-database-emptying.ts.tpl +209 -0
- package/templates/init/platform/database/test-database-kept.ts.tpl +32 -0
- package/templates/init/platform/database/test-database-leftovers.ts.tpl +52 -0
- package/templates/init/platform/database/test-database-run.ts.tpl +99 -0
- package/templates/init/platform/database/test-database-server.ts.tpl +140 -0
- package/templates/init/platform/database/test-database-session.ts.tpl +141 -0
- package/templates/init/platform/database/test-database-teardown.ts.tpl +11 -1
- package/templates/init/platform/jobs/background-jobs.ts.tpl +4 -0
- package/templates/init/platform/jobs/create-background-work.ts.tpl +1 -0
- package/templates/init/platform/resilience/default-policy.ts.tpl +8 -1
- package/templates/init/rules/infrastructure.md.tpl +3 -3
- package/templates/init/scripts/read-model-tables.ts.tpl +83 -0
- package/templates/nest-controller/upload.spec.ts.tpl +67 -2
- package/templates/nest-controller/upload.ts.tpl +12 -0
- package/templates/personal-data/declaration.drizzle.ts.tpl +6 -1
- package/templates/personal-data/declaration.knex.ts.tpl +14 -1
- package/templates/personal-data/declaration.prisma.ts.tpl +6 -1
- package/templates/personal-data/declaration.typeorm.ts.tpl +21 -1
- package/templates/personal-data/spec.table.ts.tpl +39 -0
- package/templates/pipeline/package-scripts.json +1 -1
- package/templates/presets/identity/context/infrastructure/persistence/drizzle-account.repository.drizzle.ts.tpl +5 -9
- package/templates/presets/identity/context/infrastructure/persistence/drizzle-delegation.repository.drizzle.ts.tpl +5 -9
- package/templates/presets/identity/context/infrastructure/persistence/drizzle-invitation.repository.drizzle.ts.tpl +5 -9
- package/templates/presets/identity/context/infrastructure/persistence/drizzle-member.repository.drizzle.ts.tpl +5 -9
- package/templates/presets/identity/context/infrastructure/persistence/drizzle-organisation.repository.drizzle.ts.tpl +5 -9
- package/templates/projection/projection.manual.ts.tpl +2 -2
- package/templates/projection/projection.ts.tpl +2 -2
- package/templates/read-model/contract.spec.ts.tpl +95 -0
- package/templates/read-model/drizzle/schema.ts.tpl +8 -0
- package/templates/read-model/drizzle/store.ts.tpl +41 -0
- package/templates/read-model/drizzle/table.tpl +38 -0
- package/templates/read-model/fake.ts.tpl +8 -0
- package/templates/read-model/knex/store.ts.tpl +41 -0
- package/templates/read-model/knex/table.tpl +26 -0
- package/templates/read-model/none/store.ts.tpl +17 -0
- package/templates/read-model/port.ts.tpl +24 -0
- package/templates/read-model/prisma/model.tpl +25 -0
- package/templates/read-model/prisma/store.ts.tpl +43 -0
- package/templates/read-model/typeorm/schema-export.tpl +4 -0
- package/templates/read-model/typeorm/schema.ts.tpl +9 -0
- package/templates/read-model/typeorm/store.ts.tpl +30 -0
- package/templates/read-model/typeorm/table.tpl +54 -0
- package/templates/read-model/wiring.container.tpl +21 -0
- package/templates/repository/drizzle/repository.ts.tpl +6 -9
- package/templates/repository/drizzle/table.tpl +1 -0
- package/templates/repository/typeorm/table.tpl +1 -0
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{{#if tests.vitest}}
|
|
2
|
-
import {
|
|
2
|
+
import { {{e2e.globals}}, onTestFailed } from 'vitest';
|
|
3
3
|
{{/if}}
|
|
4
4
|
{{#if tests.jest}}
|
|
5
|
-
import {
|
|
5
|
+
import { {{e2e.globals}} } from '@jest/globals';
|
|
6
6
|
{{/if}}
|
|
7
7
|
{{#if tests.vitest}}
|
|
8
8
|
import { reportSeedOnFailure } from '@ddd-ts-kit/testing/faker';
|
|
9
9
|
{{/if}}
|
|
10
10
|
import { startApplication, type RunningApplication } from '{{alias.test}}/e2e/support/start-application{{alias.ext}}';
|
|
11
11
|
|
|
12
|
-
//
|
|
12
|
+
// {{e2e.starts}}
|
|
13
13
|
describe('{{name.title}}, end to end', () => {
|
|
14
14
|
let application: RunningApplication;
|
|
15
15
|
|
|
@@ -1,24 +1,88 @@
|
|
|
1
1
|
import { Readable } from 'node:stream';
|
|
2
|
+
{{#if upload.isText}}
|
|
3
|
+
import { buffer } from 'node:stream/consumers';
|
|
4
|
+
{{/if}}
|
|
2
5
|
import { describe, expect, it } from '{{tests.module}}';
|
|
3
6
|
import { routeOf } from '@ddd-ts-kit/http/testing';
|
|
7
|
+
{{#if upload.isText}}
|
|
8
|
+
import { multipartUploads } from '@ddd-ts-kit/http/uploads';
|
|
9
|
+
import { KitCodes } from '@ddd-ts-kit/kernel';
|
|
10
|
+
{{/if}}
|
|
4
11
|
import { RecordingCommandBus } from '@ddd-ts-kit/kernel/testing';
|
|
5
12
|
{{route.messageImport}}
|
|
6
13
|
{{route.specImports}}
|
|
14
|
+
{{#if upload.isText}}
|
|
15
|
+
|
|
16
|
+
const BOUNDARY = 'boundary';
|
|
17
|
+
/** An export as a spreadsheet on Windows writes it: the accented letter is one byte, not UTF-8. */
|
|
18
|
+
const WINDOWS_1252 = Buffer.from('label;amount\r\ncaf\xe9;3,50\r\n', 'latin1');
|
|
19
|
+
{{#unless upload.singleByte}}
|
|
20
|
+
const UTF_8 = Buffer.from('label;amount\r\ncafé;3,50\r\n', 'utf8');
|
|
21
|
+
{{/unless}}
|
|
22
|
+
/** The first bytes of an Excel workbook: a binary file, whatever its name and its declared type say. */
|
|
23
|
+
const WORKBOOK = Buffer.from([0xd0, 0xcf, 0x11, 0xe0, 0xa1, 0xb1, 0x1a, 0xe1]);
|
|
24
|
+
{{/if}}
|
|
7
25
|
|
|
8
26
|
describe('{{route.method}} {{route.path}}', () => {
|
|
9
27
|
it('declares the file it receives, and hands it to the command as it streams', async () => {
|
|
10
28
|
const commands = new RecordingCommandBus().answering({{route.input}}, () => 'file-1');
|
|
11
|
-
const file = { fileName: '
|
|
29
|
+
const file = { fileName: '{{upload.fileName}}', mediaType: '{{upload.mediaType}}', stream: Readable.from([Buffer.from({{upload.head}})]) };
|
|
12
30
|
const uploads = async () => ({ fields: {}, file });
|
|
13
31
|
const { route{{#if route.protected}}, caller{{/if}}, send } = routeOf(new {{name.pascal}}Controller(commands), { uploads });
|
|
14
32
|
|
|
15
33
|
const response = await send({{route.sentRequest}});
|
|
16
34
|
|
|
17
35
|
expect(response.status).toBe(201);
|
|
18
|
-
expect(commands.executed).toMatchObject([{ {{#if route.protected}}actor: caller, {{/if}}upload: { area: '{{name.kebab}}', received: { fileName: '
|
|
36
|
+
expect(commands.executed).toMatchObject([{ {{#if route.protected}}actor: caller, {{/if}}upload: { area: '{{name.kebab}}', received: { fileName: '{{upload.fileName}}' } } }]);
|
|
19
37
|
expect(route.upload?.field).toBe('file');
|
|
20
38
|
});
|
|
39
|
+
{{#if upload.isText}}
|
|
40
|
+
|
|
41
|
+
{{#if upload.singleByte}}
|
|
42
|
+
it('receives byte for byte a text file that is not UTF-8, and refuses a workbook under the name of a CSV', async () => {
|
|
43
|
+
{{/if}}
|
|
44
|
+
{{#unless upload.singleByte}}
|
|
45
|
+
it('receives a text file in UTF-8, and refuses one in another encoding or a workbook under the name of a CSV', async () => {
|
|
46
|
+
{{/unless}}
|
|
47
|
+
let received: Buffer = Buffer.alloc(0);
|
|
48
|
+
|
|
49
|
+
const commands = new RecordingCommandBus().answering({{route.input}}, async (command) => {
|
|
50
|
+
received = await buffer(command.upload.received.stream);
|
|
51
|
+
|
|
52
|
+
return 'file-1';
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
const { send } = routeOf(new {{name.pascal}}Controller(commands), { uploads: multipartUploads() });
|
|
56
|
+
const sent = {{route.sentRequest}};
|
|
57
|
+
|
|
58
|
+
const taken = await send({ ...sent, ...aForm({{upload.taken}}) });
|
|
59
|
+
{{#unless upload.singleByte}}
|
|
60
|
+
const inAnotherEncoding = await send({ ...sent, ...aForm(WINDOWS_1252) });
|
|
61
|
+
{{/unless}}
|
|
62
|
+
const binary = await send({ ...sent, ...aForm(WORKBOOK) });
|
|
63
|
+
|
|
64
|
+
expect(taken.status).toBe(201);
|
|
65
|
+
expect(received).toEqual({{upload.taken}});
|
|
66
|
+
{{#unless upload.singleByte}}
|
|
67
|
+
expect(inAnotherEncoding).toMatchObject({ status: 415, body: { code: KitCodes.UnsupportedMediaType } });
|
|
68
|
+
{{/unless}}
|
|
69
|
+
expect(binary).toMatchObject({ status: 415, body: { code: KitCodes.UnsupportedMediaType } });
|
|
70
|
+
});
|
|
71
|
+
{{/if}}
|
|
21
72
|
|
|
22
73
|
// TODO(domain): replace each entry below by a test of the same shape, through the same `routeOf` (`{ caller }` names another one, `anonymousActor()` of the kernel nobody).
|
|
23
74
|
it.todo('answers the documented status for each error code of the use case');
|
|
24
75
|
});
|
|
76
|
+
{{#if upload.isText}}
|
|
77
|
+
|
|
78
|
+
/** A multipart form as a browser sends it: the file under the field the route declares, its bytes as they are. */
|
|
79
|
+
function aForm(content: Buffer) {
|
|
80
|
+
const head = `--${BOUNDARY}\r\nContent-Disposition: form-data; name="file"; filename="export.csv"\r\nContent-Type: text/csv\r\n\r\n`;
|
|
81
|
+
const body = Buffer.concat([Buffer.from(head), content, Buffer.from(`\r\n--${BOUNDARY}--\r\n`)]);
|
|
82
|
+
|
|
83
|
+
return {
|
|
84
|
+
headers: { 'content-type': `multipart/form-data; boundary=${BOUNDARY}` },
|
|
85
|
+
stream: Readable.from([body]),
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
{{/if}}
|
|
@@ -8,7 +8,19 @@ import type { CommandBus } from '@ddd-ts-kit/kernel';
|
|
|
8
8
|
path: '{{route.groupPath}}',
|
|
9
9
|
summary: '{{name.title}}',
|
|
10
10
|
// TODO(domain): the largest file and the media types "{{name.words}}" accepts: both are part of the contract, and the content is checked against them as it streams.
|
|
11
|
+
{{#unless upload.isText}}
|
|
11
12
|
upload: { field: 'file', maxBytes: 10_485_760, mediaTypes: ['application/pdf', 'image/png', 'image/jpeg'] },
|
|
13
|
+
{{/unless}}
|
|
14
|
+
{{#if upload.isText}}
|
|
15
|
+
upload: {
|
|
16
|
+
field: 'file',
|
|
17
|
+
maxBytes: 10_485_760,
|
|
18
|
+
// A browser on Windows names a CSV `application/vnd.ms-excel`: the kit has no content rule for it, so the route states one.
|
|
19
|
+
mediaTypes: ['text/csv', 'application/csv', 'application/vnd.ms-excel'],
|
|
20
|
+
text: '{{upload.text}}',
|
|
21
|
+
contentRules: { 'application/vnd.ms-excel': 'text' },
|
|
22
|
+
},
|
|
23
|
+
{{/if}}
|
|
12
24
|
response: { status: 201, description: 'Stored; the file is visible once the command has committed.' },
|
|
13
25
|
// 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`).
|
|
14
26
|
errors: [],
|
|
@@ -33,7 +33,7 @@ const holders = authorizationMiddleware({
|
|
|
33
33
|
const holder = anActor().withRole('holder').build();
|
|
34
34
|
{{/if}}
|
|
35
35
|
|
|
36
|
-
const
|
|
36
|
+
const {{upload.sampleName}} = {{upload.sample}};
|
|
37
37
|
|
|
38
38
|
describe('{{name.title}}', () => {
|
|
39
39
|
it('keeps the file under a key of its own, visible once the command has committed', async () => {
|
|
@@ -42,7 +42,7 @@ describe('{{name.title}}', () => {
|
|
|
42
42
|
const key = await commandBus.execute(new {{name.pascal}}Command({{#if access.protected}}holder, {{/if}}aFile()));
|
|
43
43
|
|
|
44
44
|
expect(storage.keys()).toEqual([key]);
|
|
45
|
-
expect(await storage.stat(key)).toMatchObject({ size:
|
|
45
|
+
expect(await storage.stat(key)).toMatchObject({ size: {{upload.sampleName}}.length, mediaType: '{{upload.mediaType}}' });
|
|
46
46
|
});
|
|
47
47
|
{{#if access.protected}}
|
|
48
48
|
|
|
@@ -61,7 +61,7 @@ describe('{{name.title}}', () => {
|
|
|
61
61
|
});
|
|
62
62
|
|
|
63
63
|
function aFile() {
|
|
64
|
-
return { fileName: '
|
|
64
|
+
return { fileName: '{{upload.fileName}}', mediaType: '{{upload.mediaType}}', stream: Readable.from([Buffer.from({{upload.sampleName}})]) };
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
function arrange() {
|
|
@@ -41,6 +41,25 @@ listen on in its `ports` entry (`"0.0.0.0:5432:5432"`), with credentials of its
|
|
|
41
41
|
Every migration is named `<timestamp>_<what-it-does>`: `npm run db:generate` refuses to run
|
|
42
42
|
without a name, so two branches never write the same file, and `npm run check:arch` reports
|
|
43
43
|
migrations that a merge left out of order (`npx ddd-ts-kit explain persistence/migration-history`).
|
|
44
|
+
`npx ddd-ts-kit verify-merge` fails on a migration of the branch that sorts before the last one of
|
|
45
|
+
the trunk, and names the command that puts it after.
|
|
46
|
+
|
|
47
|
+
The application checks its read model tables when it starts, whenever their stores are built:
|
|
48
|
+
those `{{config.platformDir}}/database/read-model-tables.ts` lists for the contexts it hosts (a
|
|
49
|
+
context run as a service checks its own, on its database), where `generate read-model` adds each
|
|
50
|
+
store and `init` those of the tree. A table is read by its own store, so the verdict is the one
|
|
51
|
+
that store gives before its first trace; a database that cannot be reached is one warning and the start goes on; one that is not ready stops the start, named with what
|
|
52
|
+
keeps it from it and the migration to write, in two steps, which touches the columns the store
|
|
53
|
+
maps and no other. On a large table the second step runs in a migration of its own, outside the
|
|
54
|
+
transaction of the first (the documentation of the persistence says how on each migration tool).
|
|
55
|
+
Before a deployment, `DATABASE_URL=<its database> npm run db:read-models` says the same of that
|
|
56
|
+
database (`-- --context <context>` for the tables of one context; exit code 1 when a table is not
|
|
57
|
+
ready, 2 without a database to read, 3 when no table could be read, 4 when the context holds no
|
|
58
|
+
listed read model) and needs no other variable:
|
|
59
|
+
it prints the database it read. A pipeline that starts the application before its migrations
|
|
60
|
+
ran passes `readModelTables: 'reported'` to `composeApplication` in `{{config.sourceRoot}}/main.ts`:
|
|
61
|
+
the tables are logged as one error, the start goes on, and each store still refuses by name before
|
|
62
|
+
its first trace.
|
|
44
63
|
|
|
45
64
|
{{/if}}
|
|
46
65
|
`npm run dev` restarts the application when a source file changes. It runs `tsx watch`, which
|
|
@@ -435,7 +454,7 @@ for each moment of the project: https://github.com/gbourgeat/ddd-ts-kit/blob/mai
|
|
|
435
454
|
|---|---|
|
|
436
455
|
| `npm run dev` | the application with auto reload |
|
|
437
456
|
| `npm test` | domain, application and adapter specs, each spec file held to the time budget of its level |
|
|
438
|
-
| `npm run test:e2e` | the whole application through HTTP, on an in-process database unless `DATABASE_URL` is set |
|
|
457
|
+
| `npm run test:e2e` | the whole application through HTTP, on an in-process database unless `DATABASE_URL` is set: each spec file then runs on a database of its own, the tables of that migrated one, emptied but for those `test/support/test-database-kept.ts` lists (`npm run db:migrate` first; the role creates databases and owns that one; the address is the server itself, not a pooler, and not its `postgres` database; `TEST_DATABASE_CONNECTIONS` states fewer connections than the server leaves) |
|
|
439
458
|
| `npm run check:arch` | `ddd-ts-kit check` |
|
|
440
459
|
| `npm run docs:generate` | context map, OpenAPI, AsyncAPI and event catalog, the pages of what the tests state (`docs/behaviour/`){{#if sdk.on}}, the clients under `clients/`{{/if}} |
|
|
441
460
|
| `npm run regenerate` | every derived file after a change: `.dependency-cruiser.cjs`, then `docs:generate` |
|
|
@@ -1,18 +1,42 @@
|
|
|
1
|
+
{{#if endToEnd.sharedServer}}
|
|
1
2
|
import process from 'node:process';
|
|
3
|
+
{{/if}}
|
|
2
4
|
import base from './jest.config.js';
|
|
3
5
|
|
|
4
|
-
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
{{#if persistence.hasDatabase}}
|
|
7
|
+
// Each spec file starts its own application on a database of its own, PostgreSQL in process or a copy of the one
|
|
8
|
+
// DATABASE_URL names (test/support/test-database-clone.ts): two workers run the files at the same time, on a server too.
|
|
9
|
+
{{/if}}
|
|
10
|
+
{{#unless persistence.hasDatabase}}
|
|
11
|
+
// Each spec file starts its own application, which keeps what it stores in its own memory: two workers run the
|
|
12
|
+
// files at the same time.
|
|
13
|
+
{{/unless}}
|
|
14
|
+
{{#if endToEnd.sharedServer}}
|
|
15
|
+
// {{endToEnd.sharedBy}}:
|
|
16
|
+
// with {{endToEnd.sharedVariables}} set, one worker, so Jest runs the files in band, in one process that keeps the modules
|
|
17
|
+
// of every file it ran (about 15 MB of heap each with ES modules). A long suite there needs a larger heap:
|
|
18
|
+
// NODE_OPTIONS=--max-old-space-size=<MB>.
|
|
19
|
+
const sharedServer = {{endToEnd.sharedInJest}};
|
|
20
|
+
{{/if}}
|
|
9
21
|
|
|
10
22
|
export default {
|
|
11
23
|
...base,
|
|
12
24
|
testMatch: ['<rootDir>/test/e2e/**/*.e2e.spec.ts', '<rootDir>/test/acceptance/**/*.acceptance.spec.ts'],
|
|
13
25
|
testTimeout: 20000,
|
|
26
|
+
{{#if persistence.hasDatabase}}
|
|
27
|
+
// With DATABASE_URL, copies the migrated database once and checks that the files of the run fit in the connections of
|
|
28
|
+
// the server; without it, initialises PostgreSQL in process as jest.config.js does.
|
|
29
|
+
globalSetup: '<rootDir>/test/support/test-database-setup.ts',
|
|
30
|
+
{{/if}}
|
|
31
|
+
{{#if endToEnd.sharedServer}}
|
|
14
32
|
maxWorkers: sharedServer ? 1 : 2,
|
|
15
33
|
// Out of band, a worker whose memory passes this after a file is replaced by a fresh one, so the heap of a long suite
|
|
16
34
|
// stays bounded whatever the number of files. Jest ignores the limit in band, where the heap grows from file to file.
|
|
35
|
+
{{/if}}
|
|
36
|
+
{{#unless endToEnd.sharedServer}}
|
|
37
|
+
maxWorkers: 2,
|
|
38
|
+
// A worker whose memory passes this after a file is replaced by a fresh one, so the heap of a long suite stays
|
|
39
|
+
// bounded whatever the number of files.
|
|
40
|
+
{{/unless}}
|
|
17
41
|
workerIdleMemoryLimit: '800MB',
|
|
18
42
|
};
|
|
@@ -16,6 +16,9 @@ import type { IntegrationEvent, IntegrationEventSubscriber, JobScheduler } from
|
|
|
16
16
|
{{#if di.container}}
|
|
17
17
|
import { defineContextModule } from '@ddd-ts-kit/di';
|
|
18
18
|
{{/if}}
|
|
19
|
+
{{#if di.container}}
|
|
20
|
+
import { QueueWorker } from '@ddd-ts-kit/scheduling';
|
|
21
|
+
{{/if}}
|
|
19
22
|
import { createHttpClient, settled, type HttpClient, type SettledOptions } from '@ddd-ts-kit/testing/e2e';
|
|
20
23
|
{{#if authz.rebac}}
|
|
21
24
|
import { relateSystemActors } from '{{alias.platform}}/auth/relationships/relate-system-actors{{alias.ext}}';
|
|
@@ -40,6 +43,9 @@ import { inProcessEvents } from '{{alias.platform}}/events/in-process-events{{al
|
|
|
40
43
|
import { startOutboxRelay } from '{{alias.platform}}/events/start-outbox-relay{{alias.ext}}';
|
|
41
44
|
{{/if}}
|
|
42
45
|
import { startHttpServer } from '{{alias.platform}}/http/start-http-server{{alias.ext}}';
|
|
46
|
+
{{#unless di.container}}
|
|
47
|
+
import type { BackgroundJobs } from '{{alias.platform}}/jobs/background-jobs{{alias.ext}}';
|
|
48
|
+
{{/unless}}
|
|
43
49
|
{{#if cache.redis}}
|
|
44
50
|
import { openRedis } from '{{alias.platform}}/redis/open-redis{{alias.ext}}';
|
|
45
51
|
{{/if}}
|
|
@@ -119,6 +125,13 @@ export interface RunningApplication {
|
|
|
119
125
|
*/
|
|
120
126
|
runJob(name: string): Promise<void>;
|
|
121
127
|
|
|
128
|
+
/**
|
|
129
|
+
* Runs the background jobs that are due until none is left, in place of the worker of the process,
|
|
130
|
+
* stopped from then on: call it once the request that enqueues answered, then await `settled()`. It
|
|
131
|
+
* answers the name of each job run and rejects when a run did not succeed. A delayed job is not due.
|
|
132
|
+
*/
|
|
133
|
+
runDueJobs(): Promise<string[]>;
|
|
134
|
+
|
|
122
135
|
{{#if authz.rebac}}
|
|
123
136
|
/**
|
|
124
137
|
* Empties the database and writes the relationships of the system actors again, the state right
|
|
@@ -135,13 +148,15 @@ export interface RunningApplication {
|
|
|
135
148
|
|
|
136
149
|
/**
|
|
137
150
|
* Starts the application on a free port. The database is PostgreSQL in process unless
|
|
138
|
-
* DATABASE_URL names a migrated server (`npm run infra:up && npm run db:migrate`)
|
|
151
|
+
* DATABASE_URL names a migrated server (`npm run infra:up && npm run db:migrate`): this file then
|
|
152
|
+
* runs on a copy of that database, its own, dropped when the application closes.
|
|
139
153
|
*/
|
|
140
154
|
export async function startApplication(): Promise<RunningApplication> {
|
|
141
155
|
// An empty variable (a blank line of .env) means the same as none.
|
|
142
156
|
const url = process.env['DATABASE_URL'] === '' ? undefined : process.env['DATABASE_URL'];
|
|
143
157
|
const database = await openTestDatabase(url);
|
|
144
|
-
|
|
158
|
+
// On a server the configuration names the copy, never the migrated database: an adapter that connects from it stays in this file.
|
|
159
|
+
const config = loadConfig(testEnvironment({ DATABASE_URL: database.url ?? 'postgres://in-process/tests' }));
|
|
145
160
|
const credentials = await createCredentials();
|
|
146
161
|
const started = await start(database, config, credentials);
|
|
147
162
|
|
|
@@ -154,6 +169,7 @@ export async function startApplication(): Promise<RunningApplication> {
|
|
|
154
169
|
as: async (actor) => started.client.withHeaders(await credentials.headersOf(actor)),
|
|
155
170
|
publish: (events) => started.publish(events),
|
|
156
171
|
runJob: (name) => started.runJob(name),
|
|
172
|
+
runDueJobs: () => started.runDueJobs(),
|
|
157
173
|
{{#if authz.rebac}}
|
|
158
174
|
relate: (tuple) => relationTuples.write([tuple]),
|
|
159
175
|
{{/if}}
|
|
@@ -182,6 +198,8 @@ interface Started {
|
|
|
182
198
|
|
|
183
199
|
runJob(name: string): Promise<void>;
|
|
184
200
|
|
|
201
|
+
runDueJobs(): Promise<string[]>;
|
|
202
|
+
|
|
185
203
|
settled(options?: SettledOptions): Promise<void>;
|
|
186
204
|
|
|
187
205
|
close(): Promise<void>;
|
|
@@ -227,6 +245,12 @@ async function start(database: TestDatabase, config: AppConfig, credentials: Cre
|
|
|
227
245
|
{{/if}}
|
|
228
246
|
publish: (events) => application.eventBus.publish(events),
|
|
229
247
|
runJob: (name) => runJob(application.jobs, name),
|
|
248
|
+
{{#if di.container}}
|
|
249
|
+
runDueJobs: () => runDueJobs(application.container.resolve(QueueWorker)),
|
|
250
|
+
{{/if}}
|
|
251
|
+
{{#unless di.container}}
|
|
252
|
+
runDueJobs: () => runDueJobs(application.platform.backgroundJobs),
|
|
253
|
+
{{/unless}}
|
|
230
254
|
{{#if events.outbox}}
|
|
231
255
|
settled: (options) => settled({ outbox: () => database.persistence.outbox.stats() }, options),
|
|
232
256
|
{{/if}}
|
|
@@ -306,3 +330,17 @@ async function runJob(jobs: JobScheduler, name: string): Promise<void> {
|
|
|
306
330
|
throw new Error(`The job ${name} is per-tenant and ran for no tenant: open a tenant first (an organisation).`);
|
|
307
331
|
}
|
|
308
332
|
}
|
|
333
|
+
|
|
334
|
+
/** Stops the worker (a queue in memory starts one), runs what is due, and fails the spec on a run that did not succeed, by the code of its error. */
|
|
335
|
+
async function runDueJobs(worker: {{#if di.container}}QueueWorker{{/if}}{{#unless di.container}}BackgroundJobs{{/unless}}): Promise<string[]> {
|
|
336
|
+
await worker.stop();
|
|
337
|
+
|
|
338
|
+
const runs = await worker.runDue();
|
|
339
|
+
const failed = runs.find((run) => run.outcome !== 'succeeded');
|
|
340
|
+
|
|
341
|
+
if (failed !== undefined) {
|
|
342
|
+
throw new Error(`The background job ${failed.job} ended ${failed.outcome} (${failed.errorCode ?? 'no error'}).`);
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
return runs.map((run) => run.job);
|
|
346
|
+
}
|
|
@@ -16,6 +16,9 @@ import type { IntegrationEvent, IntegrationEventSubscriber, JobScheduler } from
|
|
|
16
16
|
{{#if di.container}}
|
|
17
17
|
import { defineContextModule } from '@ddd-ts-kit/di';
|
|
18
18
|
{{/if}}
|
|
19
|
+
{{#if di.container}}
|
|
20
|
+
import { QueueWorker } from '@ddd-ts-kit/scheduling';
|
|
21
|
+
{{/if}}
|
|
19
22
|
import { createHttpClient, settled, type HttpClient, type SettledOptions } from '@ddd-ts-kit/testing/e2e';
|
|
20
23
|
{{#if authz.rebac}}
|
|
21
24
|
import { relationTuples } from '{{alias.platform}}/auth/relationships/relation-tuples{{alias.ext}}';
|
|
@@ -41,6 +44,9 @@ import { inProcessEvents } from '{{alias.platform}}/events/in-process-events{{al
|
|
|
41
44
|
import { startOutboxRelay } from '{{alias.platform}}/events/start-outbox-relay{{alias.ext}}';
|
|
42
45
|
{{/if}}
|
|
43
46
|
import { startHttpServer } from '{{alias.platform}}/http/start-http-server{{alias.ext}}';
|
|
47
|
+
{{#unless di.container}}
|
|
48
|
+
import type { BackgroundJobs } from '{{alias.platform}}/jobs/background-jobs{{alias.ext}}';
|
|
49
|
+
{{/unless}}
|
|
44
50
|
{{#if cache.redis}}
|
|
45
51
|
import { openRedis } from '{{alias.platform}}/redis/open-redis{{alias.ext}}';
|
|
46
52
|
{{/if}}
|
|
@@ -120,6 +126,13 @@ export interface RunningApplication {
|
|
|
120
126
|
*/
|
|
121
127
|
runJob(name: string): Promise<void>;
|
|
122
128
|
|
|
129
|
+
/**
|
|
130
|
+
* Runs the background jobs that are due until none is left, in place of the worker of the process,
|
|
131
|
+
* stopped from then on: call it once the request that enqueues answered, then await `settled()`. It
|
|
132
|
+
* answers the name of each job run and rejects when a run did not succeed. A delayed job is not due.
|
|
133
|
+
*/
|
|
134
|
+
runDueJobs(): Promise<string[]>;
|
|
135
|
+
|
|
123
136
|
/** Starts from nothing again: call it before each test. */
|
|
124
137
|
reset(): Promise<void>;
|
|
125
138
|
|
|
@@ -146,6 +159,7 @@ export async function startApplication(): Promise<RunningApplication> {
|
|
|
146
159
|
as: async (actor) => current.client.withHeaders(await credentials.headersOf(actor)),
|
|
147
160
|
publish: (events) => current.publish(events),
|
|
148
161
|
runJob: (name) => current.runJob(name),
|
|
162
|
+
runDueJobs: () => current.runDueJobs(),
|
|
149
163
|
{{#if authz.rebac}}
|
|
150
164
|
relate: (tuple) => relationTuples.write([tuple]),
|
|
151
165
|
{{/if}}
|
|
@@ -169,6 +183,8 @@ interface Started {
|
|
|
169
183
|
|
|
170
184
|
runJob(name: string): Promise<void>;
|
|
171
185
|
|
|
186
|
+
runDueJobs(): Promise<string[]>;
|
|
187
|
+
|
|
172
188
|
settled(options?: SettledOptions): Promise<void>;
|
|
173
189
|
|
|
174
190
|
close(): Promise<void>;
|
|
@@ -215,6 +231,12 @@ async function start(credentials: Credentials): Promise<Started> {
|
|
|
215
231
|
{{/if}}
|
|
216
232
|
publish: (events) => application.eventBus.publish(events),
|
|
217
233
|
runJob: (name) => runJob(application.jobs, name),
|
|
234
|
+
{{#if di.container}}
|
|
235
|
+
runDueJobs: () => runDueJobs(application.container.resolve(QueueWorker)),
|
|
236
|
+
{{/if}}
|
|
237
|
+
{{#unless di.container}}
|
|
238
|
+
runDueJobs: () => runDueJobs(application.platform.backgroundJobs),
|
|
239
|
+
{{/unless}}
|
|
218
240
|
{{#if events.outbox}}
|
|
219
241
|
settled: (options) => settled({ outbox: () => persistence.outbox.stats() }, options),
|
|
220
242
|
{{/if}}
|
|
@@ -294,3 +316,17 @@ async function runJob(jobs: JobScheduler, name: string): Promise<void> {
|
|
|
294
316
|
throw new Error(`The job ${name} is per-tenant and ran for no tenant: open a tenant first (an organisation).`);
|
|
295
317
|
}
|
|
296
318
|
}
|
|
319
|
+
|
|
320
|
+
/** Stops the worker (a queue in memory starts one), runs what is due, and fails the spec on a run that did not succeed, by the code of its error. */
|
|
321
|
+
async function runDueJobs(worker: {{#if di.container}}QueueWorker{{/if}}{{#unless di.container}}BackgroundJobs{{/unless}}): Promise<string[]> {
|
|
322
|
+
await worker.stop();
|
|
323
|
+
|
|
324
|
+
const runs = await worker.runDue();
|
|
325
|
+
const failed = runs.find((run) => run.outcome !== 'succeeded');
|
|
326
|
+
|
|
327
|
+
if (failed !== undefined) {
|
|
328
|
+
throw new Error(`The background job ${failed.job} ended ${failed.outcome} (${failed.errorCode ?? 'no error'}).`);
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
return runs.map((run) => run.job);
|
|
332
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
{{#if tests.vitest}}
|
|
2
|
+
import type { TestProject } from 'vitest/node';
|
|
3
|
+
import { openRun } from './test-database-run{{alias.sibling}}';
|
|
4
|
+
import { POOL_SIZE, RUN_TEMPLATE } from './test-database-server{{alias.sibling}}';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A global setup of the end-to-end run (vitest.e2e.config.ts), which resolves its teardown. With
|
|
8
|
+
* DATABASE_URL the files run on that server, and what takes time there is done here, once, where no
|
|
9
|
+
* timeout of a hook applies (test-database-run.ts); without it they run on PostgreSQL in process,
|
|
10
|
+
* and nothing is done. The files find the template of the run and their pool in the environment.
|
|
11
|
+
*/
|
|
12
|
+
export async function setup(project: TestProject): Promise<() => Promise<void>> {
|
|
13
|
+
const url = process.env['DATABASE_URL'] ?? '';
|
|
14
|
+
|
|
15
|
+
if (url === '') {
|
|
16
|
+
return () => Promise.resolve();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const run = await openRun(url, filesAtOnce(project));
|
|
20
|
+
|
|
21
|
+
process.env[RUN_TEMPLATE] = run.template;
|
|
22
|
+
process.env[POOL_SIZE] = String(run.poolSize);
|
|
23
|
+
|
|
24
|
+
return run.end;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* As many files at once as the run has workers, and no more than the files of this run, as the
|
|
29
|
+
* runner lists them once the filters of the command line are applied: 3 files never need the
|
|
30
|
+
* connections of 16 workers. A shard runs its share of them, rounded up. While it watches, a run
|
|
31
|
+
* may be handed a file written later, and a list that is empty says nothing: the workers alone count.
|
|
32
|
+
*/
|
|
33
|
+
function filesAtOnce(project: TestProject): number {
|
|
34
|
+
const { maxWorkers, watch, shard } = project.vitest.config;
|
|
35
|
+
const listed = project.vitest.state.getPaths().length;
|
|
36
|
+
const files = watch || listed === 0 ? maxWorkers : Math.ceil(listed / (shard?.count ?? 1));
|
|
37
|
+
|
|
38
|
+
return Math.max(1, Math.min(maxWorkers, files));
|
|
39
|
+
}
|
|
40
|
+
{{/if}}
|
|
41
|
+
{{#if tests.jest}}
|
|
42
|
+
import { readdirSync } from 'node:fs';
|
|
43
|
+
import path from 'node:path';
|
|
44
|
+
import { openRun } from './test-database-run{{alias.sibling}}';
|
|
45
|
+
import { POOL_SIZE, RUN_TEMPLATE } from './test-database-server{{alias.sibling}}';
|
|
46
|
+
import saveCluster from './test-database-template{{alias.sibling}}';
|
|
47
|
+
|
|
48
|
+
/** What Jest hands a global setup, as far as this one reads it: the run, then the project. */
|
|
49
|
+
interface JestRun {
|
|
50
|
+
readonly maxWorkers: number;
|
|
51
|
+
readonly rootDir: string;
|
|
52
|
+
readonly shard?: { readonly shardCount: number };
|
|
53
|
+
readonly testPathPatterns: { readonly patterns: readonly string[] };
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
interface JestProject {
|
|
57
|
+
readonly testPathIgnorePatterns: readonly string[];
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** The spec files jest.e2e.config.js matches. */
|
|
61
|
+
const SPEC = /\.(?:e2e|acceptance)\.spec\.ts$/;
|
|
62
|
+
/** Where the end of the run waits for test-database-teardown.ts, which the unit run loads too and which imports nothing. */
|
|
63
|
+
const END = Symbol.for('ddd-ts-kit.test-database-run');
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* The global setup of the end-to-end run (jest.e2e.config.js). With DATABASE_URL the files run on
|
|
67
|
+
* that server, and what takes time there is done here, once, where no timeout of a hook applies
|
|
68
|
+
* (test-database-run.ts); without it they run on PostgreSQL in process, saved once as in the unit
|
|
69
|
+
* run. Jest loads a global setup, and what it imports, with the resolution of Node, which knows no
|
|
70
|
+
* alias of the project: the files of test/support/ import one another by a relative path.
|
|
71
|
+
*/
|
|
72
|
+
export default async function setup(jest: JestRun, project: JestProject): Promise<void> {
|
|
73
|
+
const url = process.env['DATABASE_URL'] ?? '';
|
|
74
|
+
|
|
75
|
+
if (url === '') {
|
|
76
|
+
await saveCluster();
|
|
77
|
+
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const run = await openRun(url, filesAtOnce(jest, project));
|
|
82
|
+
|
|
83
|
+
process.env[RUN_TEMPLATE] = run.template;
|
|
84
|
+
process.env[POOL_SIZE] = String(run.poolSize);
|
|
85
|
+
Reflect.set(globalThis, END, run.end);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* As many files at once as the run has workers, and no more than the files of this run: 3 files
|
|
90
|
+
* never need the connections of 16 workers. Jest does not hand its list to a global setup: the
|
|
91
|
+
* count is one it cannot exceed, and the workers alone count when it cannot be made, or finds no
|
|
92
|
+
* file: Jest then runs spec files that are not under test/, which this count does not see.
|
|
93
|
+
*/
|
|
94
|
+
function filesAtOnce(jest: JestRun, project: JestProject): number {
|
|
95
|
+
try {
|
|
96
|
+
const listed = specFiles(jest, project).length;
|
|
97
|
+
const files = listed === 0 ? jest.maxWorkers : Math.ceil(listed / (jest.shard?.shardCount ?? 1));
|
|
98
|
+
|
|
99
|
+
return Math.max(1, Math.min(jest.maxWorkers, files));
|
|
100
|
+
} catch {
|
|
101
|
+
return jest.maxWorkers;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* The spec files under test/ that Jest may run: those a pattern of the command line matches, on
|
|
107
|
+
* the path from the root of the project or on the whole path as Jest does, when there is one, less
|
|
108
|
+
* those the configuration ignores.
|
|
109
|
+
*/
|
|
110
|
+
function specFiles({ rootDir, testPathPatterns }: JestRun, { testPathIgnorePatterns }: JestProject): string[] {
|
|
111
|
+
const asked = testPathPatterns.patterns.map((pattern) => new RegExp(pattern.replace(/^\.[/\\]/, '^'), 'i'));
|
|
112
|
+
const ignored = testPathIgnorePatterns.map((pattern) => new RegExp(pattern));
|
|
113
|
+
const whole = (file: string): string => path.join(rootDir, file);
|
|
114
|
+
|
|
115
|
+
return readdirSync(path.join(rootDir, 'test'), { recursive: true, encoding: 'utf8' })
|
|
116
|
+
.map((file) => path.join('test', file))
|
|
117
|
+
.filter((file) => SPEC.test(file) && !ignored.some((pattern) => pattern.test(whole(file))))
|
|
118
|
+
.filter((file) => asked.length === 0 || asked.some((pattern) => pattern.test(file) || pattern.test(whole(file))));
|
|
119
|
+
}
|
|
120
|
+
{{/if}}
|
|
@@ -3,6 +3,13 @@ import { decorators } from '@ddd-ts-kit/testing/vitest';
|
|
|
3
3
|
{{/if}}
|
|
4
4
|
import { defineConfig } from 'vitest/config';
|
|
5
5
|
|
|
6
|
+
{{#if persistence.hasDatabase}}
|
|
7
|
+
// Each spec file starts its own application on a database of its own, PostgreSQL in process or a copy of the one
|
|
8
|
+
// DATABASE_URL names (test/support/test-database-clone.ts): the files run at the same time, on a server too.
|
|
9
|
+
{{/if}}
|
|
10
|
+
{{#unless persistence.hasDatabase}}
|
|
11
|
+
// Each spec file starts its own application, which keeps what it stores in its own memory: the files run at the same time.
|
|
12
|
+
{{/unless}}
|
|
6
13
|
export default defineConfig({
|
|
7
14
|
{{#if decorators.standard}}
|
|
8
15
|
// The application under test holds classes that carry standard decorators.
|
|
@@ -16,12 +23,15 @@ export default defineConfig({
|
|
|
16
23
|
// Discovery imports the role files of a context itself: inlined, the package loads them through the runner, which compiles them.
|
|
17
24
|
server: { deps: { inline: ['@ddd-ts-kit/di'] } },
|
|
18
25
|
{{/if}}
|
|
19
|
-
|
|
20
|
-
//
|
|
21
|
-
|
|
26
|
+
{{#if endToEnd.sharedServer}}
|
|
27
|
+
// {{endToEnd.sharedBy}}:
|
|
28
|
+
// with {{endToEnd.sharedVariables}} set, the files run one after the other.
|
|
29
|
+
fileParallelism: {{endToEnd.apartInVitest}},
|
|
30
|
+
{{/if}}
|
|
22
31
|
{{#if persistence.hasDatabase}}
|
|
23
32
|
// Initialises PostgreSQL in process once: each application starts on a copy of that cluster, and creates its tables there.
|
|
24
|
-
|
|
33
|
+
// With DATABASE_URL, copies the migrated database once instead, and checks that the files of the run fit on the server.
|
|
34
|
+
globalSetup: ['test/support/test-database-template.ts', 'test/support/test-database-setup.ts'],
|
|
25
35
|
{{/if}}
|
|
26
36
|
testTimeout: 20_000,
|
|
27
37
|
hookTimeout: 30_000,
|
|
@@ -216,7 +216,12 @@ export function composeApplication(
|
|
|
216
216
|
const container = createApplication({
|
|
217
217
|
modules: [
|
|
218
218
|
kernel(foundations, persistence, options),
|
|
219
|
+
{{#if persistence.hasDatabase}}
|
|
220
|
+
platformModule(persistence, options, contexts.modules),
|
|
221
|
+
{{/if}}
|
|
222
|
+
{{#unless persistence.hasDatabase}}
|
|
219
223
|
platformModule(persistence, options),
|
|
224
|
+
{{/unless}}
|
|
220
225
|
{{#if eventSourcing.on}}
|
|
221
226
|
eventSourcingModule(foundations.eventSourcing),
|
|
222
227
|
{{/if}}
|
|
@@ -107,9 +107,8 @@ export const everyContext: readonly ContextModule[] = [
|
|
|
107
107
|
];
|
|
108
108
|
|
|
109
109
|
/**
|
|
110
|
-
* The contexts run as services of their own (`ddd-ts-kit generate service`): the application
|
|
111
|
-
*
|
|
112
|
-
* jobs belong to the service, not to both.
|
|
110
|
+
* The contexts run as services of their own (`ddd-ts-kit generate service`): the application `main.ts` and the worker
|
|
111
|
+
* run leaves them out, since their consumers, their processes and their jobs belong to the service, not to both.
|
|
113
112
|
*/
|
|
114
113
|
const extracted: readonly ContextModule[] = [
|
|
115
114
|
// ddd-ts-kit:extracted
|
|
@@ -244,7 +243,12 @@ export function composeApplication(
|
|
|
244
243
|
ready: () => options.redis?.ready() ?? Promise.resolve(true),
|
|
245
244
|
{{/if}}
|
|
246
245
|
platform,
|
|
246
|
+
{{#if persistence.hasDatabase}}
|
|
247
|
+
start: () => start(platform, options, contexts),
|
|
248
|
+
{{/if}}
|
|
249
|
+
{{#unless persistence.hasDatabase}}
|
|
247
250
|
start: () => start(platform, options),
|
|
251
|
+
{{/unless}}
|
|
248
252
|
stop: () => stop(platform, options),
|
|
249
253
|
};
|
|
250
254
|
}
|
|
@@ -272,11 +276,21 @@ function boundaryOf(platform: Platform, options: ApplicationOptions{{#if present
|
|
|
272
276
|
{{/if}}
|
|
273
277
|
|
|
274
278
|
/**
|
|
279
|
+
{{#if persistence.hasDatabase}}
|
|
280
|
+
* The listed read model tables of the hosted contexts first, then the consumers, then the jobs: a job sends commands whose events must find their handlers.
|
|
281
|
+
{{/if}}
|
|
282
|
+
{{#unless persistence.hasDatabase}}
|
|
275
283
|
* The consumers first, then the jobs: a job sends commands whose events must find their handlers.
|
|
284
|
+
{{/unless}}
|
|
276
285
|
* The worker of the background jobs runs in the process that runs the jobs{{#if queue.memory}}, and in every
|
|
277
286
|
* process while the queue is kept in its memory: no other process would see what this one enqueues{{/if}}.
|
|
278
287
|
*/
|
|
288
|
+
{{#if persistence.hasDatabase}}
|
|
289
|
+
async function start(platform: Platform, options: ApplicationOptions, hosted: readonly ContextWiring[]): Promise<void> {
|
|
290
|
+
{{/if}}
|
|
291
|
+
{{#unless persistence.hasDatabase}}
|
|
279
292
|
async function start(platform: Platform, options: ApplicationOptions): Promise<void> {
|
|
293
|
+
{{/unless}}
|
|
280
294
|
{{#if authz.rebac}}
|
|
281
295
|
await relateSystemActors();
|
|
282
296
|
|
|
@@ -290,6 +304,9 @@ async function start(platform: Platform, options: ApplicationOptions): Promise<v
|
|
|
290
304
|
subscribeAll(platform.subscriber, platform.audit.subscriptions);
|
|
291
305
|
{{/unless}}
|
|
292
306
|
{{/if}}
|
|
307
|
+
{{#if persistence.hasDatabase}}
|
|
308
|
+
await platform.readModelTables(hosted.map(({ name }) => name)).atStart(platform.logger, options.readModelTables);
|
|
309
|
+
{{/if}}
|
|
293
310
|
{{#if search.opensearch}}
|
|
294
311
|
// The index of every read model of OpenSearch the contexts built, before an event reaches its projection.
|
|
295
312
|
await platform.search.provision();
|