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
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { randomBytes } from 'node:crypto';
|
|
2
|
+
import { setTimeout as later } from 'node:timers/promises';
|
|
3
|
+
import type pg from 'pg';
|
|
4
|
+
import { connectedTo, keyOf, LIVE, locked, lostDatabases } from './test-database-server{{alias.sibling}}';
|
|
5
|
+
|
|
6
|
+
/** A run says that it lives every 15 seconds, and is held dead a minute after it last did (test-database-leftovers.ts). */
|
|
7
|
+
const BEAT_SECONDS = 15;
|
|
8
|
+
|
|
9
|
+
export const DEAD_AFTER_SECONDS = 60;
|
|
10
|
+
/** What the comment of a run starts with, on the database that carries it, before the seconds of the clock of the server. */
|
|
11
|
+
export const BEAT = 'ddd-ts-kit run ';
|
|
12
|
+
|
|
13
|
+
/** How many times, a second apart, a run tries to take a session again before it says that it could not. */
|
|
14
|
+
const ATTEMPTS = 5;
|
|
15
|
+
|
|
16
|
+
/** What says that a run lives: its lock, held by one session, and the comment it refreshes on its template. */
|
|
17
|
+
export interface RunSession {
|
|
18
|
+
readonly id: string;
|
|
19
|
+
|
|
20
|
+
/** The session that holds the lock now: another one once the server ended the first. */
|
|
21
|
+
server(): pg.Client;
|
|
22
|
+
|
|
23
|
+
/** Says on `database`, now and every 15 seconds from now, that the run lives. */
|
|
24
|
+
beatOn(database: string): Promise<void>;
|
|
25
|
+
|
|
26
|
+
/** Lets the lock go. Never throws: a session the server ended is ended. */
|
|
27
|
+
end(): Promise<void>;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
interface Held {
|
|
31
|
+
readonly url: string;
|
|
32
|
+
readonly tell: (line: string) => void;
|
|
33
|
+
id: string;
|
|
34
|
+
client: pg.Client;
|
|
35
|
+
retaking: boolean;
|
|
36
|
+
ended: boolean;
|
|
37
|
+
/** The database that carries the comment of the run, once it has one. */
|
|
38
|
+
database?: string;
|
|
39
|
+
beating?: NodeJS.Timeout;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Opens the session of a run and takes the lock of a name no living run has, before any database
|
|
44
|
+
* carries it. A session can end while the run lives (the server restarts or fails over, an
|
|
45
|
+
* administrator ends it, sessions idle too long are ended, the machine slept): the run then takes
|
|
46
|
+
* another one and its lock again, at once, and says so when it could not. The lock is one of a
|
|
47
|
+
* session: the address is a direct one, never a pooler that hands a session to others.
|
|
48
|
+
*/
|
|
49
|
+
export async function openSession(url: string, tell: (line: string) => void): Promise<RunSession> {
|
|
50
|
+
const held: Held = { url, tell, id: '', client: await connectedTo(url), retaking: false, ended: false };
|
|
51
|
+
|
|
52
|
+
held.id = await lockedRun(held.client);
|
|
53
|
+
watch(held, held.client);
|
|
54
|
+
|
|
55
|
+
return {
|
|
56
|
+
id: held.id,
|
|
57
|
+
server: () => held.client,
|
|
58
|
+
beatOn: (database) => beatingOn(held, database),
|
|
59
|
+
end: () => ended(held),
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
async function lockedRun(client: pg.Client): Promise<string> {
|
|
64
|
+
const id = randomBytes(4).toString('hex');
|
|
65
|
+
|
|
66
|
+
return (await locked(client, `pg_try_advisory_lock(${LIVE}, ${keyOf(id)})`)) ? id : lockedRun(client);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** A client whose session the server ended emits an error, more than once: with nobody listening, it would end the runner. */
|
|
70
|
+
function watch(held: Held, client: pg.Client): void {
|
|
71
|
+
client.on('error', () => {
|
|
72
|
+
if (held.client === client && !held.retaking && !held.ended) {
|
|
73
|
+
held.retaking = true;
|
|
74
|
+
|
|
75
|
+
void retaken(held, ATTEMPTS).finally(() => {
|
|
76
|
+
held.retaking = false;
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
async function retaken(held: Held, attempts: number): Promise<void> {
|
|
83
|
+
try {
|
|
84
|
+
const client = await connectedTo(held.url);
|
|
85
|
+
|
|
86
|
+
watch(held, client);
|
|
87
|
+
|
|
88
|
+
if (!(await locked(client, `pg_try_advisory_lock(${LIVE}, ${keyOf(held.id)})`))) {
|
|
89
|
+
await client.end();
|
|
90
|
+
|
|
91
|
+
throw new Error('another session holds the lock of the run');
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
held.client = client;
|
|
95
|
+
await sayDatabasesLost(held);
|
|
96
|
+
} catch (error) {
|
|
97
|
+
if (attempts > 1 && !held.ended) {
|
|
98
|
+
await later(1000);
|
|
99
|
+
await retaken(held, attempts - 1);
|
|
100
|
+
} else if (!held.ended) {
|
|
101
|
+
// Nothing is left to say that the run lives: the comment is not asked of a session that is gone.
|
|
102
|
+
clearInterval(held.beating);
|
|
103
|
+
|
|
104
|
+
held.tell(
|
|
105
|
+
`The run lost its session on the server and could not take it again (${String(error)}): a minute from now nothing says that its databases are in use, and another run may drop them. A spec file that finds its database gone failed for that reason: run again.\n`,
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** While the run had no session, nothing held its databases: a later run may have dropped them, and the files to come would fail one by one. */
|
|
112
|
+
async function sayDatabasesLost(held: Held): Promise<void> {
|
|
113
|
+
const { database, client } = held;
|
|
114
|
+
|
|
115
|
+
if (database === undefined) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const found = await client.query('select 1 from pg_database where datname = $1', [database]).catch(() => undefined);
|
|
120
|
+
|
|
121
|
+
if (found?.rowCount === 0) {
|
|
122
|
+
held.tell(lostDatabases(database) + '\n');
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
async function beatingOn(held: Held, database: string): Promise<void> {
|
|
127
|
+
const name = "'" + database.replaceAll("'", "''") + "'";
|
|
128
|
+
const beat = `do $$ begin execute format('comment on database %I is %L', ${name}, '${BEAT}' || extract(epoch from now())::bigint); end $$`;
|
|
129
|
+
|
|
130
|
+
await held.client.query(beat);
|
|
131
|
+
held.database = database;
|
|
132
|
+
// Between two sessions a beat is lost: the next one says it, well before the run is held dead.
|
|
133
|
+
held.beating = setInterval(() => void held.client.query(beat).catch(() => undefined), BEAT_SECONDS * 1000);
|
|
134
|
+
held.beating.unref();
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
async function ended(held: Held): Promise<void> {
|
|
138
|
+
held.ended = true;
|
|
139
|
+
clearInterval(held.beating);
|
|
140
|
+
await held.client.end().catch(() => undefined);
|
|
141
|
+
}
|
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
import { rm } from 'node:fs/promises';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* The global teardown of the test runs (`globalTeardown` of jest.config.js): deletes the cluster
|
|
6
|
+
* test-database-template.ts saved, or ends the run test-database-setup.ts started on a server,
|
|
7
|
+
* which left its end where this file finds it. It imports nothing of the project: the unit run
|
|
8
|
+
* loads it too, with the resolution of Node, which knows no alias.
|
|
9
|
+
*/
|
|
5
10
|
export default async function teardown(): Promise<void> {
|
|
6
11
|
const file = process.env['TEST_DATABASE_TEMPLATE'];
|
|
12
|
+
const end: unknown = Reflect.get(globalThis, Symbol.for('ddd-ts-kit.test-database-run'));
|
|
7
13
|
|
|
8
14
|
if (file !== undefined) {
|
|
9
15
|
await rm(path.dirname(file), { recursive: true, force: true });
|
|
10
16
|
}
|
|
17
|
+
|
|
18
|
+
if (typeof end === 'function') {
|
|
19
|
+
await Reflect.apply(end, undefined, []);
|
|
20
|
+
}
|
|
11
21
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { BackgroundJob, BackgroundJobOptions, BackgroundJobPayloadSchema } from '@ddd-ts-kit/kernel';
|
|
2
|
+
import type { BackgroundJobRun } from '@ddd-ts-kit/scheduling';
|
|
2
3
|
|
|
3
4
|
/** A background job class: named by its static `jobName`, built from what its constructor takes, its stored payload read with its static `payload`. */
|
|
4
5
|
export interface BackgroundJobClass<Deps extends readonly unknown[]> {
|
|
@@ -19,4 +20,7 @@ export interface BackgroundJobs {
|
|
|
19
20
|
start(): Promise<void>;
|
|
20
21
|
|
|
21
22
|
stop(): Promise<void>;
|
|
23
|
+
|
|
24
|
+
/** Runs every job due now until none is left and answers the attempts: for a test, or a command run once. Not while the worker runs. */
|
|
25
|
+
runDue(): Promise<BackgroundJobRun[]>;
|
|
22
26
|
}
|
|
@@ -2,6 +2,13 @@ import { forKinds, retry, timeout, when, type Aspect } from '@ddd-ts-kit/aspects
|
|
|
2
2
|
import { adaptersWithOwnPolicy } from '{{alias.platform}}/resilience/adapters-with-own-policy{{alias.ext}}';
|
|
3
3
|
import type { ResilienceSettings } from '{{alias.platform}}/resilience/resilience-settings{{alias.ext}}';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* What a call cut by the default limit says after its duration: the adapter never chose that limit, and
|
|
7
|
+
* one that only hands the call to a slower adapter is cut before the answer, under its own name.
|
|
8
|
+
*/
|
|
9
|
+
const STATED_BY =
|
|
10
|
+
'the default policy of the external and gateway adapters, OUTBOUND_TIMEOUT_MS: `ownPolicy(timeout(<ms>))` on the declaration or the binding of this adapter states another, at least as long as the adapter it calls';
|
|
11
|
+
|
|
5
12
|
/**
|
|
6
13
|
* What goes around every adapter that leaves the process (`external`, `gateway`) and states no
|
|
7
14
|
* policy of its own: retries with backoff, and a time limit for each attempt. `forKinds` is the
|
|
@@ -11,7 +18,7 @@ export function defaultPolicy(settings: ResilienceSettings): Aspect {
|
|
|
11
18
|
const policy = when(
|
|
12
19
|
forKinds('external', 'gateway'),
|
|
13
20
|
retry({ attempts: settings.retryAttempts, backoff: { baseMs: settings.retryBaseDelayMs } }),
|
|
14
|
-
timeout(settings.timeoutMs),
|
|
21
|
+
timeout(settings.timeoutMs, { statedBy: STATED_BY }),
|
|
15
22
|
);
|
|
16
23
|
|
|
17
24
|
return (instance, info) => (adaptersWithOwnPolicy.has(instance) ? instance : policy(instance, info));
|
|
@@ -24,18 +24,18 @@ paths:
|
|
|
24
24
|
{{/if}}
|
|
25
25
|
{{#if style.declared}}
|
|
26
26
|
- An adapter declares itself on its class, one per file (`declarations/role-declared`): `@Repository(InvoiceRepository)`, `@Gateway(Port)` or `@Adapter(Port, { kind })`. What it is given is what its constructor takes, each parameter typed by one class (`{{persistence.tokenOrNone}}`, `ExecutionScope`, `Clock`, a port, an abstract class the platform binds to a value) and nothing listed in the decorator (`declarations/constructor-injection`); an adapter that extends a class of a package writes its own constructor.
|
|
27
|
-
- Retry, timeout and cache go on the declaration (`aspects: [ownPolicy(retry(...), timeout(...))]`) or, when the policy is part of what the adapter is, as decorators of `@ddd-ts-kit/aspects/decorators` (`aspects/outside-in`). Kinds `external` and `gateway` get the default policy of the platform otherwise. `ownPolicy` is the helper of `{{alias.platform}}/resilience/own-policy{{alias.ext}}`, which `generate adapter` writes when the platform does not have it yet.
|
|
27
|
+
- Retry, timeout and cache go on the declaration (`aspects: [ownPolicy(retry(...), timeout(...))]`) or, when the policy is part of what the adapter is, as decorators of `@ddd-ts-kit/aspects/decorators` (`aspects/outside-in`). Kinds `external` and `gateway` get the default policy of the platform otherwise. One left to that default and given the port of an adapter that states a longer limit is cut first: state its policy, or `ownPolicy()` alone when it only hands the call over (`aspects/timeout-covers-delegate`). `ownPolicy` is the helper of `{{alias.platform}}/resilience/own-policy{{alias.ext}}`, which `generate adapter` writes when the platform does not have it yet.
|
|
28
28
|
{{/if}}
|
|
29
29
|
{{#if style.explicit}}
|
|
30
30
|
- An adapter is bound to its port in `<context>.module.ts` only (`composition/only-in-module`), with its kind (`repository`, `gateway`, `external`).
|
|
31
|
-
- Retry, timeout and cache go on the binding (`ownPolicy(retry(...), timeout(...))`) or, when the policy is part of what the adapter is, as decorators of `@ddd-ts-kit/aspects/decorators` (`aspects/outside-in`). Kinds `external` and `gateway` get the default policy of the platform otherwise. `ownPolicy` is the helper of `{{alias.platform}}/resilience/own-policy{{alias.ext}}`, which `generate adapter` writes when the platform does not have it yet.
|
|
31
|
+
- Retry, timeout and cache go on the binding (`ownPolicy(retry(...), timeout(...))`) or, when the policy is part of what the adapter is, as decorators of `@ddd-ts-kit/aspects/decorators` (`aspects/outside-in`). Kinds `external` and `gateway` get the default policy of the platform otherwise. One left to that default and given the port of an adapter that states a longer limit is cut first, under its own name: when you bind an adapter that is given a port, compare the two limits yourself and state its policy, or `ownPolicy()` alone when it only hands the call over. `ownPolicy` is the helper of `{{alias.platform}}/resilience/own-policy{{alias.ext}}`, which `generate adapter` writes when the platform does not have it yet.
|
|
32
32
|
{{/if}}
|
|
33
33
|
- A repository only persists: no `pullEvents()`, no dispatcher (`domain-events/dispatched-on-save`). A removal that announces an event takes the aggregate, not its id.
|
|
34
34
|
{{#if eventSourcing.on}}
|
|
35
35
|
- The repository adapter of an event-sourced aggregate delegates to `EventSourcedRepository` of the kernel. Its stored events are declared in `persistence/<aggregate>-events.mapper.ts` with `defineStoredEvent` and a named type of their data; a change of that type is a new version with its upcaster, never an edit (`event-sourcing/upcaster-required`, against `stored-events.lock.json`, which `ddd-ts-kit docs --stored-events` writes once the shape of a version is final; `docs --check` fails while a version is unrecorded). Every named type the data reaches is declared in the codec file too.
|
|
36
36
|
{{/if}}
|
|
37
37
|
{{#if search.opensearch}}
|
|
38
|
-
- A read model kept in OpenSearch is written by hand, no generator yet: `class SearchInvoiceList extends OpenSearchReadModelStore<InvoiceRow> implements InvoiceList`, whose constructor takes `SearchIndexes` of the platform and calls `super(search.options('billing_invoices', invoiceCriteria))`; its name starts with the context, and nothing else of `@ddd-ts-kit/opensearch` is named here (`search/store-from-platform`). It is a copy for reading, written by its projection (`upsertIfNewer` with the stamp of the event, `delete` that keeps a tombstone) and rebuilt from the events: never read to decide an invariant or a right. It passes `readModelRowsContract` and `criteriaContract` of `@ddd-ts-kit/testing/contracts`, on a node the run names (`OPENSEARCH_URL`); the specs of the context bind its port to `InMemoryReadModelStore` of the kernel.
|
|
38
|
+
- A read model kept in OpenSearch is written by hand, no generator yet: `class SearchInvoiceList extends OpenSearchReadModelStore<InvoiceRow> implements InvoiceList`, whose constructor takes `SearchIndexes` of the platform and calls `super(search.options('billing_invoices', invoiceCriteria))`; its name starts with the context, and nothing else of `@ddd-ts-kit/opensearch` is named here (`search/store-from-platform`). It is a copy for reading, written by its projection (`upsertIfNewer` with the stamp of the event, `updateIfNewer` for an event that changes a row another event created, `delete` that keeps a tombstone) and rebuilt from the events: never read to decide an invariant or a right. It passes `readModelRowsContract` and `criteriaContract` of `@ddd-ts-kit/testing/contracts`, on a node the run names (`OPENSEARCH_URL`); the specs of the context bind its port to `InMemoryReadModelStore` of the kernel.
|
|
39
39
|
{{/if}}
|
|
40
40
|
- Infrastructure faults are plain errors (a 5xx, reported from outside); business refusals are `DomainError`s raised by the domain.
|
|
41
41
|
- Every adapter passes the contract suite of the fake of its port (`test/integration/*.contract.spec.ts`).
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { openPersistence } from '{{alias.platform}}/database/open-persistence{{alias.ext}}';
|
|
2
|
+
import { readModelTables } from '{{alias.platform}}/database/read-model-tables{{alias.ext}}';
|
|
3
|
+
|
|
4
|
+
// The read model tables the application lists ({{config.platformDir}}/database/read-model-tables.ts),
|
|
5
|
+
// checked from the command line as the application checks them when it starts:
|
|
6
|
+
// DATABASE_URL=<the database of the deployment> npm run db:read-models
|
|
7
|
+
// DATABASE_URL=<the database of a service> npm run db:read-models -- --context <context>
|
|
8
|
+
// Every listed table without `--context`; with it, given once per context, the tables of those
|
|
9
|
+
// contexts alone, as a context run as a service of its own checks them on its database.
|
|
10
|
+
// Before a deployment, on the database it is about to reach, once its migrations ran; after
|
|
11
|
+
// `npm run db:migrate` on an empty database, it says the same of the migrations of the project.
|
|
12
|
+
// It needs DATABASE_URL and no other variable of the application; a `.env` file gives it when the
|
|
13
|
+
// command line does not, so it prints the database it read, never its credentials. Then the
|
|
14
|
+
// tables it read and each one that cannot hold the trace of a deleted row, or that it could not
|
|
15
|
+
// read, with what keeps it from it and the migration to write. Exit code: 0 when every listed
|
|
16
|
+
// table is ready, 1 when one is not, 2 when DATABASE_URL names no database, 3 when no table
|
|
17
|
+
// could be read (the database does not answer, or refuses the reading), 4 when `--context` names
|
|
18
|
+
// a context no listed read model belongs to: a misspelt name would otherwise check nothing.
|
|
19
|
+
const NOT_READY = 1;
|
|
20
|
+
const NO_DATABASE = 2;
|
|
21
|
+
const UNREAD = 3;
|
|
22
|
+
const NO_SUCH_CONTEXT = 4;
|
|
23
|
+
|
|
24
|
+
process.exitCode = await checked(process.env['DATABASE_URL'], contextsOf(process.argv));
|
|
25
|
+
|
|
26
|
+
/** The contexts named after `--context`; none, every context. */
|
|
27
|
+
function contextsOf(args: readonly string[]): readonly string[] | undefined {
|
|
28
|
+
const named = args.filter((_, index) => args[index - 1] === '--context');
|
|
29
|
+
|
|
30
|
+
return named.length === 0 ? undefined : named;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
async function checked(databaseUrl = '', contexts?: readonly string[]): Promise<number> {
|
|
34
|
+
if (!URL.canParse(databaseUrl)) {
|
|
35
|
+
console.error('DATABASE_URL names no database: set it to the address of the database to check.');
|
|
36
|
+
|
|
37
|
+
return NO_DATABASE;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
try {
|
|
41
|
+
return await read(databaseUrl, contexts);
|
|
42
|
+
} catch (error) {
|
|
43
|
+
console.error(`The database could not be read: ${error instanceof Error ? error.message : String(error)}`);
|
|
44
|
+
|
|
45
|
+
return UNREAD;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
async function read(databaseUrl: string, contexts?: readonly string[]): Promise<number> {
|
|
50
|
+
const { host, pathname } = new URL(databaseUrl);
|
|
51
|
+
const scope = contexts === undefined ? 'every context' : contexts.join(', ');
|
|
52
|
+
|
|
53
|
+
console.log(`Database ${pathname.slice(1)} on ${host}, ${scope}.`);
|
|
54
|
+
|
|
55
|
+
{{#if orm.prisma}}
|
|
56
|
+
// The bounds of a transaction are those of Prisma: the check opens none.
|
|
57
|
+
const persistence = await openPersistence({ databaseUrl, databaseTransaction: { waitMs: 2_000, timeoutMs: 5_000 } });
|
|
58
|
+
{{/if}}
|
|
59
|
+
{{#unless orm.prisma}}
|
|
60
|
+
const persistence = {{persistence.await}}openPersistence({ databaseUrl });
|
|
61
|
+
{{/unless}}
|
|
62
|
+
|
|
63
|
+
try {
|
|
64
|
+
const tables = readModelTables(persistence);
|
|
65
|
+
const unknown = (contexts ?? []).filter((context) => !tables.contexts.includes(context));
|
|
66
|
+
|
|
67
|
+
if (unknown.length > 0) {
|
|
68
|
+
const held = tables.contexts.length === 0 ? 'no read model' : `those of ${tables.contexts.join(', ')}`;
|
|
69
|
+
|
|
70
|
+
console.error(`No listed read model belongs to ${unknown.join(', ')}: the list holds ${held}.`);
|
|
71
|
+
|
|
72
|
+
return NO_SUCH_CONTEXT;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const { outcome, text } = await tables.hosting(contexts).report();
|
|
76
|
+
|
|
77
|
+
console.log(text);
|
|
78
|
+
|
|
79
|
+
return { ready: 0, 'not-ready': NOT_READY, unread: UNREAD }[outcome];
|
|
80
|
+
} finally {
|
|
81
|
+
await persistence.close();
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -1,26 +1,91 @@
|
|
|
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 { nestControllerRoute } from '@ddd-ts-kit/http/nest';
|
|
4
7
|
import { routeOf } from '@ddd-ts-kit/http/testing';
|
|
8
|
+
{{#if upload.isText}}
|
|
9
|
+
import { multipartUploads } from '@ddd-ts-kit/http/uploads';
|
|
10
|
+
import { KitCodes } from '@ddd-ts-kit/kernel';
|
|
11
|
+
{{/if}}
|
|
5
12
|
import { RecordingCommandBus } from '@ddd-ts-kit/kernel/testing';
|
|
6
13
|
{{route.messageImport}}
|
|
7
14
|
{{route.specImports}}
|
|
15
|
+
{{#if upload.isText}}
|
|
16
|
+
|
|
17
|
+
const BOUNDARY = 'boundary';
|
|
18
|
+
/** An export as a spreadsheet on Windows writes it: the accented letter is one byte, not UTF-8. */
|
|
19
|
+
const WINDOWS_1252 = Buffer.from('label;amount\r\ncaf\xe9;3,50\r\n', 'latin1');
|
|
20
|
+
{{#unless upload.singleByte}}
|
|
21
|
+
const UTF_8 = Buffer.from('label;amount\r\ncafé;3,50\r\n', 'utf8');
|
|
22
|
+
{{/unless}}
|
|
23
|
+
/** The first bytes of an Excel workbook: a binary file, whatever its name and its declared type say. */
|
|
24
|
+
const WORKBOOK = Buffer.from([0xd0, 0xcf, 0x11, 0xe0, 0xa1, 0xb1, 0x1a, 0xe1]);
|
|
25
|
+
{{/if}}
|
|
8
26
|
|
|
9
27
|
describe('{{route.method}} {{route.path}}', () => {
|
|
10
28
|
it('declares the file it receives, and hands it to the command as it streams', async () => {
|
|
11
29
|
const commands = new RecordingCommandBus().answering({{route.input}}, () => 'file-1');
|
|
12
30
|
const served = nestControllerRoute({{name.pascal}}Controller, { instanceOf: () => new {{name.pascal}}Controller(commands) });
|
|
13
|
-
const file = { fileName: '
|
|
31
|
+
const file = { fileName: '{{upload.fileName}}', mediaType: '{{upload.mediaType}}', stream: Readable.from([Buffer.from({{upload.head}})]) };
|
|
14
32
|
const uploads = async () => ({ fields: {}, file });
|
|
15
33
|
const { route{{#if route.protected}}, caller{{/if}}, send } = routeOf(served, { uploads });
|
|
16
34
|
|
|
17
35
|
const response = await send({{route.sentRequest}});
|
|
18
36
|
|
|
19
37
|
expect(response.status).toBe(201);
|
|
20
|
-
expect(commands.executed).toMatchObject([{ {{#if route.protected}}actor: caller, {{/if}}upload: { area: '{{name.kebab}}', received: { fileName: '
|
|
38
|
+
expect(commands.executed).toMatchObject([{ {{#if route.protected}}actor: caller, {{/if}}upload: { area: '{{name.kebab}}', received: { fileName: '{{upload.fileName}}' } } }]);
|
|
21
39
|
expect(route.upload?.field).toBe('file');
|
|
22
40
|
});
|
|
41
|
+
{{#if upload.isText}}
|
|
42
|
+
|
|
43
|
+
{{#if upload.singleByte}}
|
|
44
|
+
it('receives byte for byte a text file that is not UTF-8, and refuses a workbook under the name of a CSV', async () => {
|
|
45
|
+
{{/if}}
|
|
46
|
+
{{#unless upload.singleByte}}
|
|
47
|
+
it('receives a text file in UTF-8, and refuses one in another encoding or a workbook under the name of a CSV', async () => {
|
|
48
|
+
{{/unless}}
|
|
49
|
+
let received: Buffer = Buffer.alloc(0);
|
|
50
|
+
|
|
51
|
+
const commands = new RecordingCommandBus().answering({{route.input}}, async (command) => {
|
|
52
|
+
received = await buffer(command.upload.received.stream);
|
|
53
|
+
|
|
54
|
+
return 'file-1';
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
const served = nestControllerRoute({{name.pascal}}Controller, { instanceOf: () => new {{name.pascal}}Controller(commands) });
|
|
58
|
+
const { send } = routeOf(served, { uploads: multipartUploads() });
|
|
59
|
+
const sent = {{route.sentRequest}};
|
|
60
|
+
|
|
61
|
+
const taken = await send({ ...sent, ...aForm({{upload.taken}}) });
|
|
62
|
+
{{#unless upload.singleByte}}
|
|
63
|
+
const inAnotherEncoding = await send({ ...sent, ...aForm(WINDOWS_1252) });
|
|
64
|
+
{{/unless}}
|
|
65
|
+
const binary = await send({ ...sent, ...aForm(WORKBOOK) });
|
|
66
|
+
|
|
67
|
+
expect(taken.status).toBe(201);
|
|
68
|
+
expect(received).toEqual({{upload.taken}});
|
|
69
|
+
{{#unless upload.singleByte}}
|
|
70
|
+
expect(inAnotherEncoding).toMatchObject({ status: 415, body: { code: KitCodes.UnsupportedMediaType } });
|
|
71
|
+
{{/unless}}
|
|
72
|
+
expect(binary).toMatchObject({ status: 415, body: { code: KitCodes.UnsupportedMediaType } });
|
|
73
|
+
});
|
|
74
|
+
{{/if}}
|
|
23
75
|
|
|
24
76
|
// 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).
|
|
25
77
|
it.todo('answers the documented status for each error code of the use case');
|
|
26
78
|
});
|
|
79
|
+
{{#if upload.isText}}
|
|
80
|
+
|
|
81
|
+
/** A multipart form as a browser sends it: the file under the field the route declares, its bytes as they are. */
|
|
82
|
+
function aForm(content: Buffer) {
|
|
83
|
+
const head = `--${BOUNDARY}\r\nContent-Disposition: form-data; name="file"; filename="export.csv"\r\nContent-Type: text/csv\r\n\r\n`;
|
|
84
|
+
const body = Buffer.concat([Buffer.from(head), content, Buffer.from(`\r\n--${BOUNDARY}--\r\n`)]);
|
|
85
|
+
|
|
86
|
+
return {
|
|
87
|
+
headers: { 'content-type': `multipart/form-data; boundary=${BOUNDARY}` },
|
|
88
|
+
stream: Readable.from([body]),
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
{{/if}}
|
|
@@ -13,7 +13,19 @@ export class {{name.pascal}}Controller {
|
|
|
13
13
|
@{{route.nestMethod}}({{route.nestPath}})
|
|
14
14
|
@KitRoute({
|
|
15
15
|
// 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.
|
|
16
|
+
{{#unless upload.isText}}
|
|
16
17
|
upload: { field: 'file', maxBytes: 10_485_760, mediaTypes: ['application/pdf', 'image/png', 'image/jpeg'] },
|
|
18
|
+
{{/unless}}
|
|
19
|
+
{{#if upload.isText}}
|
|
20
|
+
upload: {
|
|
21
|
+
field: 'file',
|
|
22
|
+
maxBytes: 10_485_760,
|
|
23
|
+
// A browser on Windows names a CSV `application/vnd.ms-excel`: the kit has no content rule for it, so the route states one.
|
|
24
|
+
mediaTypes: ['text/csv', 'application/csv', 'application/vnd.ms-excel'],
|
|
25
|
+
text: '{{upload.text}}',
|
|
26
|
+
contentRules: { 'application/vnd.ms-excel': 'text' },
|
|
27
|
+
},
|
|
28
|
+
{{/if}}
|
|
17
29
|
response: { status: 201, description: 'Stored; the file is visible once the command has committed.' },
|
|
18
30
|
// 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`).
|
|
19
31
|
errors: [],
|
|
@@ -7,14 +7,19 @@ type {{aggregate.pascal}}Row = typeof {{aggregate.tableCamel}}.$inferSelect;
|
|
|
7
7
|
* What `{{aggregate.table}}` keeps of a person in clear, and whose it is: the columns below belong to the person
|
|
8
8
|
* `{{personal.subject}}` names{{#if personal.pseudonymise}}, and each reads `[erased]` once that person is erased{{/if}}{{#if personal.row}}, and their row is deleted once that person is erased{{/if}}.
|
|
9
9
|
* Read by {{personal.names.adapter}}, which `npm run privacy:erase` runs; a column added later that holds
|
|
10
|
-
* personal data is declared here too, and its mapper writes it.
|
|
10
|
+
* personal data is declared here too{{#unless personal.ofTable}}, and its mapper writes it{{/unless}}.
|
|
11
11
|
*/
|
|
12
12
|
const declaration: PersonalFieldsOptions<{{aggregate.pascal}}Row> = {
|
|
13
13
|
subject: '{{personal.subject}}',
|
|
14
14
|
{{personal.fields}}
|
|
15
15
|
erasure: '{{personal.erasure}}',
|
|
16
16
|
{{#if personal.retains}}
|
|
17
|
+
{{#unless personal.ofTable}}
|
|
17
18
|
// TODO(domain): the mapper writes {{personal.retentionColumn}} empty: write the date the relation with the person ended (the contract closed, the account deleted), or these rows never expire. Never count from the registration.
|
|
19
|
+
{{/unless}}
|
|
20
|
+
{{#if personal.ofTable}}
|
|
21
|
+
// TODO(domain): what writes {{aggregate.table}} writes in {{personal.retentionColumn}} the date the relation with the person ended (the contract closed, the account deleted), or these rows never expire. Never count from the registration.
|
|
22
|
+
{{/if}}
|
|
18
23
|
retention: {{personal.retention}},
|
|
19
24
|
{{/if}}
|
|
20
25
|
};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { personalFields, type PersonalFieldsOptions } from '@ddd-ts-kit/kernel';
|
|
2
2
|
import { {{context.constant}}_SCHEMA } from '{{alias.context}}/infrastructure/persistence/{{context.kebab}}.schema{{alias.ext}}';
|
|
3
|
+
{{#unless personal.ofTable}}
|
|
3
4
|
import type { {{aggregate.pascal}}Row } from '{{alias.context}}/infrastructure/persistence/{{aggregate.kebab}}-row.schema{{alias.ext}}';
|
|
5
|
+
{{/unless}}
|
|
4
6
|
|
|
5
7
|
/** The table as the erasure reaches it: its statements are written on the table{{#if tenant.scoped}}, confined to the tenant of the work{{/if}}. */
|
|
6
8
|
const TABLE = { schema: {{context.constant}}_SCHEMA, table: '{{aggregate.table}}' };
|
|
@@ -9,14 +11,25 @@ const TABLE = { schema: {{context.constant}}_SCHEMA, table: '{{aggregate.table}}
|
|
|
9
11
|
* What `{{aggregate.table}}` keeps of a person in clear, and whose it is: the columns below belong to the person
|
|
10
12
|
* `{{personal.subject}}` names{{#if personal.pseudonymise}}, and each reads `[erased]` once that person is erased{{/if}}{{#if personal.row}}, and their row is deleted once that person is erased{{/if}}.
|
|
11
13
|
* Read by {{personal.names.adapter}}, which `npm run privacy:erase` runs; a column added later that holds
|
|
12
|
-
* personal data is declared here too, and its mapper writes it.
|
|
14
|
+
* personal data is declared here too{{#unless personal.ofTable}}, and its mapper writes it{{/unless}}.
|
|
13
15
|
*/
|
|
16
|
+
{{#if personal.ofTable}}
|
|
17
|
+
// The columns are named as the database spells them: no row type of the project describes this table.
|
|
18
|
+
const declaration: PersonalFieldsOptions<Record<string, unknown>> = {
|
|
19
|
+
{{/if}}
|
|
20
|
+
{{#unless personal.ofTable}}
|
|
14
21
|
const declaration: PersonalFieldsOptions<{{aggregate.pascal}}Row> = {
|
|
22
|
+
{{/unless}}
|
|
15
23
|
subject: '{{personal.subject}}',
|
|
16
24
|
{{personal.fields}}
|
|
17
25
|
erasure: '{{personal.erasure}}',
|
|
18
26
|
{{#if personal.retains}}
|
|
27
|
+
{{#unless personal.ofTable}}
|
|
19
28
|
// TODO(domain): the mapper writes {{personal.retentionColumn}} empty: write the date the relation with the person ended (the contract closed, the account deleted), or these rows never expire. Never count from the registration.
|
|
29
|
+
{{/unless}}
|
|
30
|
+
{{#if personal.ofTable}}
|
|
31
|
+
// TODO(domain): what writes {{aggregate.table}} writes in {{personal.retentionColumn}} the date the relation with the person ended (the contract closed, the account deleted), or these rows never expire. Never count from the registration.
|
|
32
|
+
{{/if}}
|
|
20
33
|
retention: {{personal.retention}},
|
|
21
34
|
{{/if}}
|
|
22
35
|
};
|
|
@@ -8,7 +8,7 @@ const TABLE: PrismaPersonalTable = { schema: '{{context.schema}}', table: '{{agg
|
|
|
8
8
|
* What `{{aggregate.table}}` keeps of a person in clear, and whose it is: the columns below belong to the person
|
|
9
9
|
* `{{personal.subject}}` names{{#if personal.pseudonymise}}, and each reads `[erased]` once that person is erased{{/if}}{{#if personal.row}}, and their row is deleted once that person is erased{{/if}}.
|
|
10
10
|
* Read by {{personal.names.adapter}}, which `npm run privacy:erase` runs; a column added later that holds
|
|
11
|
-
* personal data is declared here too, and its mapper writes it.
|
|
11
|
+
* personal data is declared here too{{#unless personal.ofTable}}, and its mapper writes it{{/unless}}.
|
|
12
12
|
*/
|
|
13
13
|
// The columns are named as the database spells them (`@map`), since the erasure writes SQL on the table.
|
|
14
14
|
const declaration: PersonalFieldsOptions<Record<string, unknown>> = {
|
|
@@ -16,7 +16,12 @@ const declaration: PersonalFieldsOptions<Record<string, unknown>> = {
|
|
|
16
16
|
{{personal.fields}}
|
|
17
17
|
erasure: '{{personal.erasure}}',
|
|
18
18
|
{{#if personal.retains}}
|
|
19
|
+
{{#unless personal.ofTable}}
|
|
19
20
|
// TODO(domain): the mapper writes {{personal.retentionColumn}} empty: write the date the relation with the person ended (the contract closed, the account deleted), or these rows never expire. Never count from the registration.
|
|
21
|
+
{{/unless}}
|
|
22
|
+
{{#if personal.ofTable}}
|
|
23
|
+
// TODO(domain): what writes {{aggregate.table}} writes in {{personal.retentionColumn}} the date the relation with the person ended (the contract closed, the account deleted), or these rows never expire. Never count from the registration.
|
|
24
|
+
{{/if}}
|
|
20
25
|
retention: {{personal.retention}},
|
|
21
26
|
{{/if}}
|
|
22
27
|
};
|
|
@@ -1,19 +1,39 @@
|
|
|
1
|
+
{{#if personal.ofTable}}
|
|
2
|
+
import type { EntitySchema } from 'typeorm';
|
|
3
|
+
{{/if}}
|
|
1
4
|
import { personalFields, type PersonalFieldsOptions } from '@ddd-ts-kit/kernel';
|
|
2
5
|
import { {{aggregate.tableCamel}} } from '{{alias.context}}/infrastructure/persistence/{{context.kebab}}.schema{{alias.ext}}';
|
|
6
|
+
{{#unless personal.ofTable}}
|
|
3
7
|
import type { {{aggregate.pascal}}Row } from '{{alias.context}}/infrastructure/persistence/{{aggregate.kebab}}-row.schema{{alias.ext}}';
|
|
8
|
+
{{/unless}}
|
|
9
|
+
{{#if personal.ofTable}}
|
|
10
|
+
|
|
11
|
+
/** The row an entity schema types. */
|
|
12
|
+
type RowOf<Schema> = Schema extends EntitySchema<infer Row> ? Row : never;
|
|
13
|
+
{{/if}}
|
|
4
14
|
|
|
5
15
|
/**
|
|
6
16
|
* What `{{aggregate.table}}` keeps of a person in clear, and whose it is: the columns below belong to the person
|
|
7
17
|
* `{{personal.subject}}` names{{#if personal.pseudonymise}}, and each reads `[erased]` once that person is erased{{/if}}{{#if personal.row}}, and their row is deleted once that person is erased{{/if}}.
|
|
8
18
|
* Read by {{personal.names.adapter}}, which `npm run privacy:erase` runs; a column added later that holds
|
|
9
|
-
* personal data is declared here too, and its mapper writes it.
|
|
19
|
+
* personal data is declared here too{{#unless personal.ofTable}}, and its mapper writes it{{/unless}}.
|
|
10
20
|
*/
|
|
21
|
+
{{#if personal.ofTable}}
|
|
22
|
+
const declaration: PersonalFieldsOptions<RowOf<typeof {{aggregate.tableCamel}}>> = {
|
|
23
|
+
{{/if}}
|
|
24
|
+
{{#unless personal.ofTable}}
|
|
11
25
|
const declaration: PersonalFieldsOptions<{{aggregate.pascal}}Row> = {
|
|
26
|
+
{{/unless}}
|
|
12
27
|
subject: '{{personal.subject}}',
|
|
13
28
|
{{personal.fields}}
|
|
14
29
|
erasure: '{{personal.erasure}}',
|
|
15
30
|
{{#if personal.retains}}
|
|
31
|
+
{{#unless personal.ofTable}}
|
|
16
32
|
// TODO(domain): the mapper writes {{personal.retentionColumn}} empty: write the date the relation with the person ended (the contract closed, the account deleted), or these rows never expire. Never count from the registration.
|
|
33
|
+
{{/unless}}
|
|
34
|
+
{{#if personal.ofTable}}
|
|
35
|
+
// TODO(domain): what writes {{aggregate.table}} writes in {{personal.retentionColumn}} the date the relation with the person ended (the contract closed, the account deleted), or these rows never expire. Never count from the registration.
|
|
36
|
+
{{/if}}
|
|
17
37
|
retention: {{personal.retention}},
|
|
18
38
|
{{/if}}
|
|
19
39
|
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { describe, expect, it } from '{{tests.module}}';
|
|
2
|
+
import { {{personal.names.fake}} } from '{{alias.context}}/test/fakes/{{personal.names.portKebab}}.fake{{alias.ext}}';
|
|
3
|
+
import { {{personal.names.exportFake}} } from '{{alias.context}}/test/fakes/{{personal.names.exportPortKebab}}.fake{{alias.ext}}';
|
|
4
|
+
|
|
5
|
+
/** The source every record of `{{aggregate.table}}` names: the context, then the table. */
|
|
6
|
+
const SOURCE = '{{context.kebab}}.{{aggregate.table}}';
|
|
7
|
+
|
|
8
|
+
// TODO(domain): no aggregate owns {{aggregate.table}}, so no repository nor builder writes its rows here. Open the test database (openTestDatabase of the platform), insert the rows of two people as the project writes that table, build {{personal.names.adapter}} and {{personal.names.exportAdapter}} on it, and replace each entry below by its test.
|
|
9
|
+
describe('{{personal.names.adapter}}, on {{aggregate.table}}', () => {
|
|
10
|
+
it.todo('erases what the table keeps of the subject, as the declaration says, and leaves the others');
|
|
11
|
+
it.todo('reaches nothing the second time: an erasure run again completes one that failed half way');
|
|
12
|
+
{{#if personal.retains}}
|
|
13
|
+
it.todo('erases the rows whose retention ended, as the declaration says, and leaves the others');
|
|
14
|
+
{{/if}}
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
describe('{{personal.names.exportAdapter}}, on {{aggregate.table}}', () => {
|
|
18
|
+
it.todo('hands over the columns of the subject as plain data, under its source, and nothing of the others');
|
|
19
|
+
it.todo('answers what the row reads once the subject is erased');
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
describe('{{personal.names.fake}} and {{personal.names.exportFake}}', () => {
|
|
23
|
+
it('counts the rows it holds of a person, and forgets them at the first erasure', async () => {
|
|
24
|
+
const fake = new {{personal.names.fake}}().holds('ada', 2);
|
|
25
|
+
|
|
26
|
+
expect(await fake.erase('ada')).toBe(2);
|
|
27
|
+
expect(await fake.erase('ada')).toBe(0);
|
|
28
|
+
expect(fake.erased).toEqual(['ada', 'ada']);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('hands over the records it holds of a person, and remembers who was asked', async () => {
|
|
32
|
+
const record = { source: SOURCE, values: { kept: 'of ada' } };
|
|
33
|
+
const fake = new {{personal.names.exportFake}}().holds('ada', record);
|
|
34
|
+
|
|
35
|
+
expect(await fake.exportOf('ada')).toEqual([record]);
|
|
36
|
+
expect(await fake.exportOf('bob')).toEqual([]);
|
|
37
|
+
expect(fake.asked).toEqual(['ada', 'bob']);
|
|
38
|
+
});
|
|
39
|
+
});
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"@biomejs/biome": "2.6.4",
|
|
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.112.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",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { and, eq } from 'drizzle-orm';
|
|
2
|
-
import {
|
|
2
|
+
import { insertIgnoringConflict, optimisticUpdate } from '@ddd-ts-kit/drizzle/postgres';
|
|
3
3
|
import { stampCreation, stampUpdate, type Clock, type ExecutionScope } from '@ddd-ts-kit/kernel';
|
|
4
4
|
{{#if style.declared}}
|
|
5
5
|
import { Repository } from '@ddd-ts-kit/kernel/declarations';
|
|
@@ -36,20 +36,16 @@ export class DrizzleAccountRepository implements AccountRepository {
|
|
|
36
36
|
async save(saved: Account): Promise<void> {
|
|
37
37
|
await optimisticUpdate(saved, async ({ expected, next }) => {
|
|
38
38
|
const state = { ...AccountMapper.toRow(saved), version: next };
|
|
39
|
-
const written = expected === 0 ? await this.insert(state) : await this.update(state, expected);
|
|
40
39
|
|
|
41
|
-
return
|
|
40
|
+
return expected === 0 ? this.insert(state) : (await this.update(state, expected)).length;
|
|
42
41
|
});
|
|
43
42
|
}
|
|
44
43
|
|
|
45
|
-
private insert(state: VersionedAccount) {
|
|
44
|
+
private async insert(state: VersionedAccount): Promise<number> {
|
|
46
45
|
const row = { ...state, ...stampCreation(this.scope, this.clock) };
|
|
46
|
+
const insertion = () => executorOf(this.database).insert(accounts).values(row);
|
|
47
47
|
|
|
48
|
-
return
|
|
49
|
-
.insert(accounts)
|
|
50
|
-
.values(row)
|
|
51
|
-
.onConflictDoNothing({ target: primaryKeyOf(accounts) })
|
|
52
|
-
.returning({ id: accounts.id });
|
|
48
|
+
return (await insertIgnoringConflict(insertion, accounts)) ? 1 : 0;
|
|
53
49
|
}
|
|
54
50
|
|
|
55
51
|
private update(state: VersionedAccount, expected: number) {
|