ddd-ts-kit 0.111.0 → 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 +112 -0
- package/README.fr.md +35 -6
- package/README.md +32 -5
- 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/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/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/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 +1 -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/generate/generate-options.d.ts +3 -0
- package/dist/generate/generate-options.d.ts.map +1 -1
- package/dist/generate/generate-options.js +1 -0
- package/dist/generate/generate-options.js.map +1 -1
- package/dist/generate/kind.d.ts +2 -0
- package/dist/generate/kind.d.ts.map +1 -1
- package/dist/generate/kinds/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/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-kind.d.ts.map +1 -1
- package/dist/generate/kinds/read-model-kind.js +19 -0
- package/dist/generate/kinds/read-model-kind.js.map +1 -1
- 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/shared-writes.d.ts.map +1 -1
- package/dist/generate/shared-writes.js +3 -2
- 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 +5 -1
- 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 -2
- 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/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/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/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/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +6 -6
- 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 +5 -0
- package/templates/init/e2e/test-database-setup.ts.tpl +120 -0
- package/templates/init/e2e/vitest.e2e.config.ts.tpl +2 -1
- 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 +8 -3
- package/templates/init/platform/database/open-test-database.knex.ts.tpl +8 -3
- package/templates/init/platform/database/open-test-database.prisma.ts.tpl +8 -3
- package/templates/init/platform/database/open-test-database.typeorm.ts.tpl +8 -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 +52 -161
- 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/resilience/default-policy.ts.tpl +8 -1
- package/templates/init/rules/infrastructure.md.tpl +2 -2
- 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/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/repository/drizzle/repository.ts.tpl +6 -9
|
@@ -14,6 +14,9 @@ import type { FileStorage, JobSettings } from '@ddd-ts-kit/kernel';
|
|
|
14
14
|
import type { JobSettings } from '@ddd-ts-kit/kernel';
|
|
15
15
|
{{/unless}}
|
|
16
16
|
{{/unless}}
|
|
17
|
+
{{#if persistence.hasDatabase}}
|
|
18
|
+
import type { ReadModelTablesAtStart } from '@ddd-ts-kit/kernel';
|
|
19
|
+
{{/if}}
|
|
17
20
|
import type { QueueWorkerOptions } from '@ddd-ts-kit/scheduling';
|
|
18
21
|
import type { ConsumerTrace } from '@ddd-ts-kit/tracing';
|
|
19
22
|
{{#if search.opensearch}}
|
|
@@ -66,6 +69,14 @@ export interface PlatformOptions {
|
|
|
66
69
|
readonly queues?: Pick<QueueWorkerOptions, 'concurrency' | 'pollIntervalMs' | 'graceMs'>;
|
|
67
70
|
/** Whether a consumed event continues the trace of its publication (the default) or starts one linked to it. */
|
|
68
71
|
readonly traceConsumers?: ConsumerTrace;
|
|
72
|
+
{{#if persistence.hasDatabase}}
|
|
73
|
+
/**
|
|
74
|
+
* What the start does with a listed read model table that cannot hold the trace of a deleted row. Left out, it
|
|
75
|
+
* refuses to start, with every such table and the migration to write; `'reported'` logs them as one error
|
|
76
|
+
* and starts, for a deployment that starts the application before its migrations ran.
|
|
77
|
+
*/
|
|
78
|
+
readonly readModelTables?: ReadModelTablesAtStart;
|
|
79
|
+
{{/if}}
|
|
69
80
|
{{#if cache.redis}}
|
|
70
81
|
/** The Redis protocol server; left out, the cache, the lock and the limiter stay in the memory of the process. */
|
|
71
82
|
readonly redis?: RedisServices;
|
|
@@ -26,6 +26,9 @@ import type {
|
|
|
26
26
|
RateLimiter,
|
|
27
27
|
{{/if}}
|
|
28
28
|
} from '@ddd-ts-kit/kernel';
|
|
29
|
+
{{#if persistence.hasDatabase}}
|
|
30
|
+
import type { ReadModelTables } from '@ddd-ts-kit/kernel';
|
|
31
|
+
{{/if}}
|
|
29
32
|
{{#if queue.stored}}
|
|
30
33
|
import type { JobStore } from '@ddd-ts-kit/scheduling';
|
|
31
34
|
{{/if}}
|
|
@@ -68,6 +71,10 @@ export interface Platform {
|
|
|
68
71
|
/** The provider itself: what the outbox relay delivers to. */
|
|
69
72
|
readonly eventBus: IntegrationEventPublisher;
|
|
70
73
|
readonly persistence: Persistence;
|
|
74
|
+
{{#if persistence.hasDatabase}}
|
|
75
|
+
/** The listed read model tables of these contexts, which an application checks in one pass when it starts, before an event reaches a store. */
|
|
76
|
+
readModelTables(contexts: readonly string[]): ReadModelTables;
|
|
77
|
+
{{/if}}
|
|
71
78
|
/** Asks the policies about one element, then the authorizer: for the rules that need loaded state. */
|
|
72
79
|
readonly access: Access;
|
|
73
80
|
/**
|
|
@@ -65,9 +65,14 @@ import { {{#if broker.external}}EventSubscribers, {{/if}}ProcessedEventStore, Un
|
|
|
65
65
|
import { ExecutionScope, ProcessStore } from '@ddd-ts-kit/kernel';
|
|
66
66
|
{{/if}}
|
|
67
67
|
{{/unless}}
|
|
68
|
+
{{#if persistence.hasDatabase}}
|
|
69
|
+
import { Logger, type ReadModelTablesAtStart } from '@ddd-ts-kit/kernel';
|
|
70
|
+
{{/if}}
|
|
71
|
+
{{#unless persistence.hasDatabase}}
|
|
68
72
|
{{#if queue.redis}}
|
|
69
73
|
import { Logger } from '@ddd-ts-kit/kernel';
|
|
70
74
|
{{/if}}
|
|
75
|
+
{{/unless}}
|
|
71
76
|
{{#if queue.stored}}
|
|
72
77
|
import { JobStore } from '@ddd-ts-kit/scheduling';
|
|
73
78
|
{{/if}}
|
|
@@ -79,6 +84,9 @@ import { Database } from '{{alias.platform}}/database/database{{alias.ext}}';
|
|
|
79
84
|
{{/if}}
|
|
80
85
|
import type { ConsumerTrace } from '@ddd-ts-kit/tracing';
|
|
81
86
|
import type { Persistence } from '{{alias.platform}}/database/persistence{{alias.ext}}';
|
|
87
|
+
{{#if persistence.hasDatabase}}
|
|
88
|
+
import { readModelTables } from '{{alias.platform}}/database/read-model-tables{{alias.ext}}';
|
|
89
|
+
{{/if}}
|
|
82
90
|
{{#if http.any}}
|
|
83
91
|
import { platformErrorMapper } from '{{alias.platform}}/composition/platform-error-mapper{{alias.ext}}';
|
|
84
92
|
{{/if}}
|
|
@@ -116,6 +124,14 @@ export interface PlatformOptions {
|
|
|
116
124
|
readonly resilience?: ResilienceSettings;
|
|
117
125
|
/** Whether a consumed event continues the trace of its publication (the default) or starts one linked to it. */
|
|
118
126
|
readonly traceConsumers?: ConsumerTrace;
|
|
127
|
+
{{#if persistence.hasDatabase}}
|
|
128
|
+
/**
|
|
129
|
+
* What the start does with a listed read model table that cannot hold the trace of a deleted row. Left out, it
|
|
130
|
+
* refuses to start, with every such table and the migration to write; `'reported'` logs them as one error
|
|
131
|
+
* and starts, for a deployment that starts the application before its migrations ran.
|
|
132
|
+
*/
|
|
133
|
+
readonly readModelTables?: ReadModelTablesAtStart;
|
|
134
|
+
{{/if}}
|
|
119
135
|
{{#if errors.sentry}}
|
|
120
136
|
/** Where unexpected failures are reported: the reporter of `errors.ts` in `main.ts`; left out (the tools, the tests), nowhere. */
|
|
121
137
|
readonly errors?: ErrorReporter;
|
|
@@ -138,10 +154,28 @@ export interface PlatformOptions {
|
|
|
138
154
|
/**
|
|
139
155
|
* What this platform puts in place of the in-process defaults of the kernel module: the storage
|
|
140
156
|
* and whatever else `main.ts` opened for it. Replacing a provider happens here and nowhere else.
|
|
157
|
+
{{#if persistence.hasDatabase}}
|
|
158
|
+
* `hosted` holds the contexts this application hosts: it checks their read model tables and no other.
|
|
159
|
+
{{/if}}
|
|
141
160
|
*/
|
|
161
|
+
{{#if persistence.hasDatabase}}
|
|
162
|
+
export function platformModule(
|
|
163
|
+
persistence: Persistence,
|
|
164
|
+
options: PlatformOptions,
|
|
165
|
+
hosted?: readonly ContextModule[],
|
|
166
|
+
): ContextModule {
|
|
167
|
+
const contexts = hosted?.map(({ name }) => name);
|
|
168
|
+
|
|
169
|
+
{{/if}}
|
|
170
|
+
{{#unless persistence.hasDatabase}}
|
|
142
171
|
export function platformModule(persistence: Persistence, options: PlatformOptions): ContextModule {
|
|
172
|
+
{{/unless}}
|
|
143
173
|
return defineContextModule({
|
|
144
174
|
name: 'platform',
|
|
175
|
+
{{#if persistence.hasDatabase}}
|
|
176
|
+
// Before a consumer is subscribed or a request served, whenever a store is built: each listed read model table of the hosted contexts, read by its own store.
|
|
177
|
+
onStart: ({ resolve }) => readModelTables(persistence, contexts).atStart(resolve(Logger), options.readModelTables),
|
|
178
|
+
{{/if}}
|
|
145
179
|
// Closed inside `stop()` of the application, after the jobs and the consumers and before the logger is flushed.
|
|
146
180
|
onStop: () => options.events.close(),
|
|
147
181
|
register(builder) {
|
|
@@ -7,8 +7,13 @@ export interface DatabaseConnection {
|
|
|
7
7
|
close(): Promise<void>;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
export
|
|
11
|
-
|
|
10
|
+
export interface ConnectionOptions {
|
|
11
|
+
/** Default 10. The tests on a server share its connections between the files that run at once. */
|
|
12
|
+
readonly poolSize?: number;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function connectToDatabase(url: string, options: ConnectionOptions = {}): DatabaseConnection {
|
|
16
|
+
const db = drizzle({ connection: { connectionString: url, max: options.poolSize ?? 10 } });
|
|
12
17
|
|
|
13
18
|
return { db, close: () => db.$client.end() };
|
|
14
19
|
}
|
|
@@ -30,6 +30,9 @@ export interface TestDatabase {
|
|
|
30
30
|
* no migration run. With a URL, the tests run on that server instead, each call on a copy of the
|
|
31
31
|
* database the URL names, which must already be migrated (`npm run db:migrate`); the migrations
|
|
32
32
|
* remain what production applies.
|
|
33
|
+
* The copy holds the tables and no row, but for the tables test/support/test-database-kept.ts
|
|
34
|
+
* lists: an end-to-end run makes it from the template of its global setup, any other caller
|
|
35
|
+
* copies the migrated database itself.
|
|
33
36
|
*/
|
|
34
37
|
export function openTestDatabase(url?: string): Promise<TestDatabase> {
|
|
35
38
|
return url === undefined ? openInProcess() : openServer(url);
|
|
@@ -64,12 +67,14 @@ async function inProcessPostgres(): Promise<PGlite> {
|
|
|
64
67
|
}
|
|
65
68
|
|
|
66
69
|
/**
|
|
67
|
-
* A database of its own on the server,
|
|
68
|
-
*
|
|
70
|
+
* A database of its own on the server, dropped at close (test/support/test-database-clone.ts): the
|
|
71
|
+
* tables of the migrated one, emptied but for those test/support/test-database-kept.ts lists. No
|
|
72
|
+
* other file, and no other run, reads or empties its rows. Its pool is the share this file has of
|
|
73
|
+
* the connections of the server.
|
|
69
74
|
*/
|
|
70
75
|
async function openServer(url: string): Promise<TestDatabase> {
|
|
71
76
|
const clone = await cloneDatabase(url);
|
|
72
|
-
const connection = connectToDatabase(clone.url);
|
|
77
|
+
const connection = connectToDatabase(clone.url, { poolSize: clone.poolSize });
|
|
73
78
|
const statements = new TableStatements();
|
|
74
79
|
|
|
75
80
|
return {
|
|
@@ -34,6 +34,9 @@ export interface TestDatabase {
|
|
|
34
34
|
* ./schema.ts: adapter and end-to-end specs need no container. With a URL, the tests run on
|
|
35
35
|
* that server instead, each call on a copy of the database the URL names, which must already be
|
|
36
36
|
* migrated (`npm run db:migrate`).
|
|
37
|
+
* The copy holds the tables and no row, but for the tables test/support/test-database-kept.ts
|
|
38
|
+
* lists: an end-to-end run makes it from the template of its global setup, any other caller
|
|
39
|
+
* copies the migrated database itself.
|
|
37
40
|
*/
|
|
38
41
|
export function openTestDatabase(url?: string): Promise<TestDatabase> {
|
|
39
42
|
return url === undefined ? openInProcess() : openServer(url);
|
|
@@ -73,12 +76,14 @@ async function inProcessPostgres(): Promise<PGlite> {
|
|
|
73
76
|
}
|
|
74
77
|
|
|
75
78
|
/**
|
|
76
|
-
* A database of its own on the server,
|
|
77
|
-
*
|
|
79
|
+
* A database of its own on the server, dropped at close (test/support/test-database-clone.ts): the
|
|
80
|
+
* tables of the migrated one, emptied but for those test/support/test-database-kept.ts lists. No
|
|
81
|
+
* other file, and no other run, reads or empties its rows. Its pool is the share this file has of
|
|
82
|
+
* the connections of the server.
|
|
78
83
|
*/
|
|
79
84
|
async function openServer(url: string): Promise<TestDatabase> {
|
|
80
85
|
const clone = await cloneDatabase(url);
|
|
81
|
-
const connection = connectToDatabase(clone.url);
|
|
86
|
+
const connection = connectToDatabase(clone.url, { poolSize: clone.poolSize });
|
|
82
87
|
|
|
83
88
|
return {
|
|
84
89
|
url: clone.url,
|
|
@@ -34,6 +34,9 @@ export interface TestDatabase {
|
|
|
34
34
|
* and end-to-end specs need no container. With a URL, the tests run on that server instead,
|
|
35
35
|
* each call on a copy of the database the URL names, which must already be migrated
|
|
36
36
|
* (`npm run db:migrate`).
|
|
37
|
+
* The copy holds the tables and no row, but for the tables test/support/test-database-kept.ts
|
|
38
|
+
* lists: an end-to-end run makes it from the template of its global setup, any other caller
|
|
39
|
+
* copies the migrated database itself.
|
|
37
40
|
*/
|
|
38
41
|
export function openTestDatabase(url?: string): Promise<TestDatabase> {
|
|
39
42
|
return url === undefined ? openInProcess() : openServer(url);
|
|
@@ -73,12 +76,14 @@ async function inProcessPostgres(): Promise<PGlite> {
|
|
|
73
76
|
}
|
|
74
77
|
|
|
75
78
|
/**
|
|
76
|
-
* A database of its own on the server,
|
|
77
|
-
*
|
|
79
|
+
* A database of its own on the server, dropped at close (test/support/test-database-clone.ts): the
|
|
80
|
+
* tables of the migrated one, emptied but for those test/support/test-database-kept.ts lists. No
|
|
81
|
+
* other file, and no other run, reads or empties its rows. Its pool is the share this file has of
|
|
82
|
+
* the connections of the server.
|
|
78
83
|
*/
|
|
79
84
|
async function openServer(url: string): Promise<TestDatabase> {
|
|
80
85
|
const clone = await cloneDatabase(url);
|
|
81
|
-
const client = createClient(clone.url);
|
|
86
|
+
const client = createClient(clone.url, { poolSize: clone.poolSize });
|
|
82
87
|
|
|
83
88
|
const close = async (): Promise<void> => {
|
|
84
89
|
await client.$disconnect();
|
|
@@ -34,6 +34,9 @@ export interface TestDatabase {
|
|
|
34
34
|
* created from the entity schemas: adapter and end-to-end specs need no container. With a URL,
|
|
35
35
|
* the tests run on that server instead, each call on a copy of the database the URL names, which
|
|
36
36
|
* must already be migrated (`npm run db:migrate`).
|
|
37
|
+
* The copy holds the tables and no row, but for the tables test/support/test-database-kept.ts
|
|
38
|
+
* lists: an end-to-end run makes it from the template of its global setup, any other caller
|
|
39
|
+
* copies the migrated database itself.
|
|
37
40
|
*/
|
|
38
41
|
export function openTestDatabase(url?: string): Promise<TestDatabase> {
|
|
39
42
|
return url === undefined ? openInProcess() : openServer(url);
|
|
@@ -76,12 +79,14 @@ async function inProcessPostgres(): Promise<PGlite> {
|
|
|
76
79
|
}
|
|
77
80
|
|
|
78
81
|
/**
|
|
79
|
-
* A database of its own on the server,
|
|
80
|
-
*
|
|
82
|
+
* A database of its own on the server, dropped at close (test/support/test-database-clone.ts): the
|
|
83
|
+
* tables of the migrated one, emptied but for those test/support/test-database-kept.ts lists. No
|
|
84
|
+
* other file, and no other run, reads or empties its rows. Its pool is the share this file has of
|
|
85
|
+
* the connections of the server.
|
|
81
86
|
*/
|
|
82
87
|
async function openServer(url: string): Promise<TestDatabase> {
|
|
83
88
|
const clone = await cloneDatabase(url);
|
|
84
|
-
const dataSource = createDataSource(clone.url);
|
|
89
|
+
const dataSource = createDataSource(clone.url, { poolSize: clone.poolSize });
|
|
85
90
|
|
|
86
91
|
await dataSource.initialize();
|
|
87
92
|
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AsyncLocalStorageExecutionScope,
|
|
3
|
+
ReadModelTables,
|
|
4
|
+
type ExecutionScope,
|
|
5
|
+
type ReadModelInATable,
|
|
6
|
+
} from '@ddd-ts-kit/kernel';
|
|
7
|
+
import type { Persistence } from '{{alias.platform}}/database/persistence{{alias.ext}}';
|
|
8
|
+
// ddd-ts-kit:imports
|
|
9
|
+
// /ddd-ts-kit:imports
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The class of a read model store, built as the application binds it: on the storage, with the
|
|
13
|
+
* scope of the work when it keeps tenant data.
|
|
14
|
+
*/
|
|
15
|
+
type Store = new (database: Persistence['database'], scope: ExecutionScope) => ReadModelInATable;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The bounded contexts of the project: `generate context` adds each. An entry of the list names
|
|
19
|
+
* one of them, or does not compile.
|
|
20
|
+
*/
|
|
21
|
+
type Contexts = [
|
|
22
|
+
// ddd-ts-kit:contexts
|
|
23
|
+
// /ddd-ts-kit:contexts
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The read models the application keeps in a table: the context each belongs to and the class of
|
|
28
|
+
* its store. `generate read-model` adds its store here, and `init` those it finds in the tree; a
|
|
29
|
+
* store written by hand is added by hand. A table that is not listed is never read. A store left
|
|
30
|
+
* out on purpose is a comment here that holds `<context>: <Store>` and the reason: `init` then
|
|
31
|
+
* leaves it out, and the check says nothing of it.
|
|
32
|
+
*/
|
|
33
|
+
const LISTED: readonly (readonly [context: Contexts[number], store: Store])[] = [
|
|
34
|
+
// ddd-ts-kit:read-model-tables
|
|
35
|
+
// /ddd-ts-kit:read-model-tables
|
|
36
|
+
];
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* The read model stores of the tree `init` could not list, `<context>: <Store>`, since their
|
|
40
|
+
* constructor takes something else: the check says at each start that nothing checks their
|
|
41
|
+
* tables, until each is listed through a class of its own that builds it.
|
|
42
|
+
*/
|
|
43
|
+
const NOT_LISTED: readonly string[] = [
|
|
44
|
+
// ddd-ts-kit:read-models-not-listed
|
|
45
|
+
// /ddd-ts-kit:read-models-not-listed
|
|
46
|
+
];
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* The listed tables of these contexts, every context when none is named, checked in one pass:
|
|
50
|
+
* each is read by its own store, with the code that store runs before its first trace, so the
|
|
51
|
+
* verdict is the store's and the migration of a table that is not ready names the columns the
|
|
52
|
+
* store maps and no other. An application asks it when it starts, of the contexts it hosts: a
|
|
53
|
+
* context run as a service of its own checks its tables, on its database, and no other.
|
|
54
|
+
* `npm run db:read-models` asks it of the database a deployment is about to reach. The scope a
|
|
55
|
+
* store of tenant data is given is never read by the check.
|
|
56
|
+
*/
|
|
57
|
+
export function readModelTables(persistence: Persistence, contexts?: readonly string[]): ReadModelTables {
|
|
58
|
+
const scope = new AsyncLocalStorageExecutionScope();
|
|
59
|
+
|
|
60
|
+
const listed = LISTED.map(([context, Store]) => ({
|
|
61
|
+
context,
|
|
62
|
+
name: Store.name,
|
|
63
|
+
build: () => new Store(persistence.database, scope),
|
|
64
|
+
}));
|
|
65
|
+
|
|
66
|
+
return new ReadModelTables(listed, NOT_LISTED).hosting(contexts);
|
|
67
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import type pg from 'pg';
|
|
2
|
+
|
|
3
|
+
/** Stated by whoever starts the run: the connections it may take, when that is less than what the server has left. */
|
|
4
|
+
const STATED = 'TEST_DATABASE_CONNECTIONS';
|
|
5
|
+
/** The pool an application opens when nothing bounds it, and the one under which a request that waits for another never ends. */
|
|
6
|
+
const LARGEST_POOL = 10;
|
|
7
|
+
const SMALLEST_POOL = 2;
|
|
8
|
+
/** Beside its pool a file has one connection to spare: the one that copies and drops its database, a client a spec opens itself. */
|
|
9
|
+
const SPARE = 1;
|
|
10
|
+
|
|
11
|
+
/** One thing that bounds the connections of a run. */
|
|
12
|
+
interface Bound {
|
|
13
|
+
readonly left: number;
|
|
14
|
+
/** How a refusal says it. */
|
|
15
|
+
readonly counted: string;
|
|
16
|
+
/** What raises it. */
|
|
17
|
+
readonly remedy: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
type Counts = Record<'max' | 'reserved' | 'open' | 'limit' | 'openOfRole', number> & { readonly role: string };
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The pool of each file of a run in which `atOnce` files run at the same time: what the tightest
|
|
24
|
+
* bound leaves, shared between them, less the connection each has to spare, 10 at most. A run that
|
|
25
|
+
* does not fit is refused here with its numbers and what raises that bound, before any file
|
|
26
|
+
* starts, instead of `too many clients` from the driver in the middle of a spec. The count is
|
|
27
|
+
* taken once, on the session `server` of the run, itself among the connections open: a run that
|
|
28
|
+
* starts later sees what this one has open, not what it will open.
|
|
29
|
+
*/
|
|
30
|
+
export async function poolSizeFor(server: pg.Client, atOnce: number): Promise<number> {
|
|
31
|
+
const { left, counted, remedy } = tightest(await bounds(server));
|
|
32
|
+
const each = SMALLEST_POOL + SPARE;
|
|
33
|
+
const fitting = Math.floor(left / each);
|
|
34
|
+
const fewer = fitting > 0 ? `run at most ${fitting} at once (npm run test:e2e -- --maxWorkers=${fitting}), or ` : '';
|
|
35
|
+
|
|
36
|
+
if (fitting < atOnce) {
|
|
37
|
+
throw new Error(
|
|
38
|
+
`${atOnce} spec files at once need ${atOnce * each} connections (${SMALLEST_POOL} for each application at least and ${SPARE} to spare), and ${counted}: ${fewer}${remedy}.`,
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return Math.min(LARGEST_POOL, Math.floor(left / atOnce) - SPARE);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function tightest(all: readonly Bound[]): Bound {
|
|
46
|
+
return all.reduce((least, bound) => (bound.left < least.left ? bound : least));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** The server, the role when it has a limit of its own, and what TEST_DATABASE_CONNECTIONS states. */
|
|
50
|
+
async function bounds(server: pg.Client): Promise<Bound[]> {
|
|
51
|
+
const { rows } = await server.query<Counts>(
|
|
52
|
+
`select current_setting('max_connections')::int as max,
|
|
53
|
+
current_setting('superuser_reserved_connections')::int + coalesce(current_setting('reserved_connections', true)::int, 0) as reserved,
|
|
54
|
+
(select count(*)::int from pg_stat_activity where usesysid is not null and coalesce(backend_type, 'client backend') = 'client backend') as "open",
|
|
55
|
+
(select case when rolsuper then -1 else rolconnlimit end from pg_roles where rolname = current_user) as "limit",
|
|
56
|
+
(select count(*)::int from pg_stat_activity where usename = current_user) as "openOfRole",
|
|
57
|
+
current_user::text as "role"`,
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
const [counts = { max: 0, reserved: 0, open: 0, limit: -1, openOfRole: 0, role: '' }] = rows;
|
|
61
|
+
const ofTheServer = [boundOfTheServer(counts), ...(counts.limit < 0 ? [] : [boundOfTheRole(counts)])];
|
|
62
|
+
|
|
63
|
+
return [...ofTheServer, ...stated(tightest(ofTheServer))];
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function boundOfTheServer({ max, reserved, open }: Counts): Bound {
|
|
67
|
+
return {
|
|
68
|
+
left: max - reserved - open,
|
|
69
|
+
counted: `the server leaves ${max - reserved - open} (max_connections ${max}, ${reserved} reserved, ${open} open)`,
|
|
70
|
+
remedy: 'raise max_connections',
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function boundOfTheRole({ role, limit, openOfRole }: Counts): Bound {
|
|
75
|
+
return {
|
|
76
|
+
left: limit - openOfRole,
|
|
77
|
+
counted: `the role ${role} has ${limit - openOfRole} left (connection limit ${limit}, ${openOfRole} open)`,
|
|
78
|
+
remedy: `raise the limit of the role (alter role ${role} connection limit <more>)`,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** What the variable states, when it is set: a whole number of connections, no more than the server leaves. */
|
|
83
|
+
function stated(ofTheServer: Bound): Bound[] {
|
|
84
|
+
const text = process.env[STATED] ?? '';
|
|
85
|
+
const connections = Number(text);
|
|
86
|
+
|
|
87
|
+
if (text === '') {
|
|
88
|
+
return [];
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (!Number.isInteger(connections) || connections < 1) {
|
|
92
|
+
throw new Error(`${STATED} is "${text}": state a whole number of connections, 1 or more, or leave it unset.`);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (connections > ofTheServer.left) {
|
|
96
|
+
throw new Error(
|
|
97
|
+
`${STATED} states ${connections} connections, and ${ofTheServer.counted}: state ${ofTheServer.left} at most, or leave it unset.`,
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return [
|
|
102
|
+
{
|
|
103
|
+
left: connections,
|
|
104
|
+
counted: `${STATED} allows ${connections}`,
|
|
105
|
+
remedy: `state more in ${STATED} (${ofTheServer.left} at most)`,
|
|
106
|
+
},
|
|
107
|
+
];
|
|
108
|
+
}
|
|
@@ -1,184 +1,75 @@
|
|
|
1
1
|
import { randomBytes } from 'node:crypto';
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import { openRun } from './test-database-run{{alias.sibling}}';
|
|
3
|
+
import {
|
|
4
|
+
codeOf,
|
|
5
|
+
copying,
|
|
6
|
+
dropping,
|
|
7
|
+
lostDatabases,
|
|
8
|
+
nameOf,
|
|
9
|
+
NO_SUCH_DATABASE,
|
|
10
|
+
oneAtATime,
|
|
11
|
+
onServer,
|
|
12
|
+
POOL_SIZE,
|
|
13
|
+
RUN_TEMPLATE,
|
|
14
|
+
runOf,
|
|
15
|
+
urlOf,
|
|
16
|
+
} from './test-database-server{{alias.sibling}}';
|
|
17
|
+
|
|
18
|
+
/** A database of its own for one caller, on the server it was given. */
|
|
5
19
|
export interface DatabaseClone {
|
|
6
20
|
readonly url: string;
|
|
7
21
|
|
|
22
|
+
/** The connections the application of the caller may open: its share of what the server has left, so that every file of a run fits. */
|
|
23
|
+
readonly poolSize: number;
|
|
24
|
+
|
|
8
25
|
/** Drops the database, whoever is still connected to it. */
|
|
9
26
|
drop(): Promise<void>;
|
|
10
27
|
}
|
|
11
28
|
|
|
12
|
-
/**
|
|
13
|
-
const
|
|
14
|
-
/** PostgreSQL keeps 63 bytes of a name: the migrated one is cut so that what follows it always fits. */
|
|
15
|
-
const KEPT_OF_THE_NAME = 38;
|
|
16
|
-
/** No spec file runs for an hour: a copy that old was left by a run that was killed. */
|
|
17
|
-
const LEFTOVER_AFTER_SECONDS = 3600;
|
|
18
|
-
/** The SQLSTATE of a server that refuses to copy a database other sessions are connected to. */
|
|
19
|
-
const OTHER_SESSIONS = '55006';
|
|
20
|
-
|
|
21
|
-
const REFUSALS: Readonly<Record<string, (database: string) => string>> = {
|
|
22
|
-
[OTHER_SESSIONS]: (database) =>
|
|
23
|
-
`The database "${database}" has other sessions (an application that runs, a console, a migration): PostgreSQL copies a database only while nobody else is connected to it. Close them, or give the tests a database of their own.`,
|
|
24
|
-
'42501': (database) =>
|
|
25
|
-
`The role of DATABASE_URL may not copy the database "${database}", and each spec file runs on a copy of it: the role creates databases (alter role <role> createdb) and owns that one (alter database "${database}" owner to <role>).`,
|
|
26
|
-
'3D000': (database) =>
|
|
27
|
-
`The server of DATABASE_URL has no database "${database}": create it, then migrate it (npm run db:migrate).`,
|
|
28
|
-
};
|
|
29
|
+
/** The pool of a file that is a run of its own: nothing shares the connections of the server between such runs, so each takes few. */
|
|
30
|
+
const POOL_OF_ITS_OWN = 4;
|
|
29
31
|
|
|
30
32
|
/**
|
|
31
|
-
* A
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
33
|
+
* A database of its own on the server `url` names: the tables of the migrated database and none
|
|
34
|
+
* of the rows a run empties (test-database-emptying.ts). In an end-to-end run the global setup
|
|
35
|
+
* copied and emptied the migrated database once (test-database-setup.ts), and this copies that
|
|
36
|
+
* template (`create database ... template`), one copy at a time in the run, in a fraction of a
|
|
37
|
+
* second whatever the migrated database holds. Anywhere else (a spec of the unit run, a project
|
|
38
|
+
* with no end-to-end run) nothing started a run: the call is a run of its own, which copies the
|
|
39
|
+
* migrated database itself, in the time that takes. Either way spec files run at the same time on
|
|
40
|
+
* one server and nothing one stores reaches another. The copy is dropped when its caller closes
|
|
41
|
+
* it, at the end of its run, or by a later run when its own was killed.
|
|
35
42
|
*/
|
|
36
43
|
export async function cloneDatabase(url: string): Promise<DatabaseClone> {
|
|
37
|
-
const
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
await onServer(url, async (server) => {
|
|
41
|
-
await dropLeftovers(server, database);
|
|
42
|
-
await copy(server, database, name);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
const clone = { url: urlOf(url, name), drop: () => onServer(url, (server) => drop(server, name)) };
|
|
46
|
-
|
|
47
|
-
await refuseWithoutTable(clone, database);
|
|
48
|
-
|
|
49
|
-
return clone;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Runs `work` on a connection of its own to the maintenance database of the server, never to the
|
|
54
|
-
* migrated one: PostgreSQL refuses to copy a database another session is connected to, and the
|
|
55
|
-
* files that start together would be those sessions for one another.
|
|
56
|
-
*/
|
|
57
|
-
async function onServer(url: string, work: (server: pg.Client) => Promise<void>): Promise<void> {
|
|
58
|
-
const server = new pg.Client({ connectionString: urlOf(url, maintenanceDatabaseOf(url)) });
|
|
44
|
+
const template = process.env[RUN_TEMPLATE] ?? '';
|
|
45
|
+
const run = runOf(template, url);
|
|
59
46
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
try {
|
|
63
|
-
await work(server);
|
|
64
|
-
} finally {
|
|
65
|
-
await server.end();
|
|
47
|
+
if (run === undefined) {
|
|
48
|
+
return runOfItsOwn(url);
|
|
66
49
|
}
|
|
67
|
-
}
|
|
68
50
|
|
|
69
|
-
|
|
70
|
-
async function dropLeftovers(server: pg.Client, database: string): Promise<void> {
|
|
71
|
-
const { rows } = await server.query<{ datname: string }>('select datname from pg_database');
|
|
72
|
-
const oldest = secondsNow() - LEFTOVER_AFTER_SECONDS;
|
|
51
|
+
const name = nameOf(url, run, randomBytes(4).toString('hex'));
|
|
73
52
|
|
|
74
|
-
|
|
75
|
-
|
|
53
|
+
await onServer(url, (server) => oneAtATime(server, run, () => server.query(copying(template, name)))).catch(
|
|
54
|
+
(error: unknown) => {
|
|
55
|
+
throw codeOf(error) === NO_SUCH_DATABASE ? new Error(lostDatabases(template), { cause: error }) : error;
|
|
56
|
+
},
|
|
57
|
+
);
|
|
76
58
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
59
|
+
return {
|
|
60
|
+
url: urlOf(url, name),
|
|
61
|
+
poolSize: Number(process.env[POOL_SIZE]),
|
|
62
|
+
drop: () => onServer(url, (server) => server.query(dropping(name))),
|
|
63
|
+
};
|
|
82
64
|
}
|
|
83
65
|
|
|
84
66
|
/**
|
|
85
|
-
*
|
|
86
|
-
*
|
|
67
|
+
* The template of a run of one file is the database of that file. Nothing counts the files that
|
|
68
|
+
* do this at the same time, each one a run that sees the connections left when it starts: each
|
|
69
|
+
* takes a small pool, and the session of its lock.
|
|
87
70
|
*/
|
|
88
|
-
async function
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
try {
|
|
92
|
-
await server.query(statement).catch((error: unknown) => {
|
|
93
|
-
if (codeOf(error) !== OTHER_SESSIONS) {
|
|
94
|
-
throw error;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
return server.query(statement);
|
|
98
|
-
});
|
|
99
|
-
} catch (error) {
|
|
100
|
-
throw refusalOf(error, database);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
async function drop(server: pg.Client, name: string): Promise<void> {
|
|
105
|
-
await server.query('drop database if exists ' + quoted(name) + ' with (force)');
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/** A server nobody migrated answers `relation does not exist` at the first statement of a spec: said here, with the command. */
|
|
109
|
-
async function refuseWithoutTable(clone: DatabaseClone, database: string): Promise<void> {
|
|
110
|
-
const connection = new pg.Client({ connectionString: clone.url });
|
|
111
|
-
|
|
112
|
-
await connection.connect();
|
|
113
|
-
|
|
114
|
-
const { rows } = await connection.query(
|
|
115
|
-
"select 1 from information_schema.tables where table_schema not in ('pg_catalog', 'information_schema') limit 1",
|
|
116
|
-
);
|
|
117
|
-
|
|
118
|
-
await connection.end();
|
|
119
|
-
|
|
120
|
-
if (rows.length === 0) {
|
|
121
|
-
await clone.drop();
|
|
122
|
-
|
|
123
|
-
throw new Error(`The database "${database}" holds no table: migrate it first (npm run db:migrate).`);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
function refusalOf(error: unknown, database: string): unknown {
|
|
128
|
-
const refusal = REFUSALS[codeOf(error)];
|
|
129
|
-
|
|
130
|
-
return refusal === undefined ? error : new Error(refusal(database), { cause: error });
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/** The SQLSTATE of an error of the server, empty for any other error. */
|
|
134
|
-
function codeOf(error: unknown): string {
|
|
135
|
-
const code: unknown = error instanceof Error ? Reflect.get(error, 'code') : undefined;
|
|
136
|
-
|
|
137
|
-
return typeof code === 'string' ? code : '';
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
function copyName(database: string, seconds: number): string {
|
|
141
|
-
return prefixOf(database) + String(seconds) + '_' + randomBytes(4).toString('hex');
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
/** When the copy named `name` was made, in seconds; undefined for a database that is not a copy of `database`. */
|
|
145
|
-
function createdAt(name: string, database: string): number | undefined {
|
|
146
|
-
const prefix = prefixOf(database);
|
|
147
|
-
const [seconds, random, ...rest] = name.slice(prefix.length).split('_');
|
|
148
|
-
|
|
149
|
-
if (!name.startsWith(prefix) || seconds === undefined || random === undefined || rest.length > 0) {
|
|
150
|
-
return undefined;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
return /^\d{10}$/.test(seconds) && /^[0-9a-f]{8}$/.test(random) ? Number(seconds) : undefined;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
function prefixOf(database: string): string {
|
|
157
|
-
return database.slice(0, KEPT_OF_THE_NAME) + MARKER;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
function secondsNow(): number {
|
|
161
|
-
return Math.floor(Date.now() / 1000);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
function databaseOf(url: string): string {
|
|
165
|
-
return decodeURIComponent(new URL(url).pathname.slice(1));
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
/** `postgres`, which every server has; `template1` when the migrated database is that one. */
|
|
169
|
-
function maintenanceDatabaseOf(url: string): string {
|
|
170
|
-
return databaseOf(url) === 'postgres' ? 'template1' : 'postgres';
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
/** The same server, role and parameters, another database. */
|
|
174
|
-
function urlOf(url: string, database: string): string {
|
|
175
|
-
const address = new URL(url);
|
|
176
|
-
|
|
177
|
-
address.pathname = '/' + encodeURIComponent(database);
|
|
178
|
-
|
|
179
|
-
return address.toString();
|
|
180
|
-
}
|
|
71
|
+
async function runOfItsOwn(url: string): Promise<DatabaseClone> {
|
|
72
|
+
const run = await openRun(url, 1);
|
|
181
73
|
|
|
182
|
-
|
|
183
|
-
return '"' + name.replaceAll('"', '""') + '"';
|
|
74
|
+
return { url: urlOf(url, run.template), poolSize: Math.min(run.poolSize, POOL_OF_ITS_OWN), drop: run.end };
|
|
184
75
|
}
|