ddd-ts-kit 0.111.0 → 0.113.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 +154 -0
- package/README.fr.md +52 -6
- package/README.md +48 -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 +6 -0
- package/dist/check/catalogue/architecture-rules.js.map +1 -1
- package/dist/check/commands/check-command.js +4 -3
- package/dist/check/commands/check-command.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 +38 -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 +4 -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/read-model-list-files.d.ts +7 -0
- package/dist/check/fixtures/read-model-list-files.d.ts.map +1 -0
- package/dist/check/fixtures/read-model-list-files.js +18 -0
- package/dist/check/fixtures/read-model-list-files.js.map +1 -0
- package/dist/check/fixtures/read-model-listed-fixtures.d.ts +3 -0
- package/dist/check/fixtures/read-model-listed-fixtures.d.ts.map +1 -0
- package/dist/check/fixtures/read-model-listed-fixtures.js +292 -0
- package/dist/check/fixtures/read-model-listed-fixtures.js.map +1 -0
- 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-fixtures.d.ts.map +1 -1
- package/dist/check/fixtures/tenancy-fixtures.js +2 -1
- package/dist/check/fixtures/tenancy-fixtures.js.map +1 -1
- package/dist/check/fixtures/tenancy-prisma-fixtures.d.ts.map +1 -1
- package/dist/check/fixtures/tenancy-prisma-fixtures.js +2 -0
- package/dist/check/fixtures/tenancy-prisma-fixtures.js.map +1 -1
- package/dist/check/fixtures/tenancy-typeorm-fixtures.d.ts.map +1 -1
- package/dist/check/fixtures/tenancy-typeorm-fixtures.js +2 -0
- package/dist/check/fixtures/tenancy-typeorm-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/model/finding.d.ts +2 -1
- package/dist/check/model/finding.d.ts.map +1 -1
- package/dist/check/model/violation.d.ts +4 -1
- package/dist/check/model/violation.d.ts.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/read-models/list-findings.d.ts +22 -0
- package/dist/check/read-models/list-findings.d.ts.map +1 -0
- package/dist/check/read-models/list-findings.js +84 -0
- package/dist/check/read-models/list-findings.js.map +1 -0
- 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/declarations-port-adapter-wired.js +9 -2
- package/dist/check/rules/declarations-port-adapter-wired.js.map +1 -1
- 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/persistence-read-model-listed.d.ts +3 -0
- package/dist/check/rules/persistence-read-model-listed.d.ts.map +1 -0
- package/dist/check/rules/persistence-read-model-listed.js +93 -0
- package/dist/check/rules/persistence-read-model-listed.js.map +1 -0
- package/dist/check/scan/lexer.d.ts +4 -0
- package/dist/check/scan/lexer.d.ts.map +1 -1
- package/dist/check/scan/lexer.js +11 -0
- package/dist/check/scan/lexer.js.map +1 -1
- package/dist/check/scan/scan.d.ts +6 -0
- package/dist/check/scan/scan.d.ts.map +1 -1
- package/dist/check/scan/scan.js +1 -0
- package/dist/check/scan/scan.js.map +1 -1
- package/dist/check/structure/read-structure.js +35 -13
- package/dist/check/structure/read-structure.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.d.ts.map +1 -1
- package/dist/commands/generate.js +4 -0
- package/dist/commands/generate.js.map +1 -1
- package/dist/commands/json-report.js +4 -4
- package/dist/commands/json-report.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/print-report.js +3 -0
- package/dist/commands/print-report.js.map +1 -1
- package/dist/commands/prisma-client.d.ts +8 -0
- package/dist/commands/prisma-client.d.ts.map +1 -0
- package/dist/commands/prisma-client.js +23 -0
- package/dist/commands/prisma-client.js.map +1 -0
- 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/declare-storage.d.ts.map +1 -1
- package/dist/generate/kinds/declare-storage.js +6 -1
- package/dist/generate/kinds/declare-storage.js.map +1 -1
- package/dist/generate/kinds/declare-table.d.ts +2 -0
- package/dist/generate/kinds/declare-table.d.ts.map +1 -1
- package/dist/generate/kinds/declare-table.js +65 -1
- package/dist/generate/kinds/declare-table.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/read-model/list-read-model.d.ts +12 -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 +24 -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 +25 -1
- package/dist/generate/kinds/read-model-kind.js.map +1 -1
- package/dist/generate/kinds/same-name/code-from.d.ts +8 -0
- package/dist/generate/kinds/same-name/code-from.d.ts.map +1 -0
- package/dist/generate/kinds/same-name/code-from.js +34 -0
- package/dist/generate/kinds/same-name/code-from.js.map +1 -0
- package/dist/generate/kinds/same-name/context-of-source.d.ts +5 -0
- package/dist/generate/kinds/same-name/context-of-source.d.ts.map +1 -0
- package/dist/generate/kinds/same-name/context-of-source.js +10 -0
- package/dist/generate/kinds/same-name/context-of-source.js.map +1 -0
- package/dist/generate/kinds/same-name/entities-list.d.ts +6 -0
- package/dist/generate/kinds/same-name/entities-list.d.ts.map +1 -0
- package/dist/generate/kinds/same-name/entities-list.js +25 -0
- package/dist/generate/kinds/same-name/entities-list.js.map +1 -0
- package/dist/generate/kinds/same-name/exports-an-alias.d.ts +12 -0
- package/dist/generate/kinds/same-name/exports-an-alias.d.ts.map +1 -0
- package/dist/generate/kinds/same-name/exports-an-alias.js +150 -0
- package/dist/generate/kinds/same-name/exports-an-alias.js.map +1 -0
- package/dist/generate/kinds/same-name/free-name.d.ts +10 -0
- package/dist/generate/kinds/same-name/free-name.d.ts.map +1 -0
- package/dist/generate/kinds/same-name/free-name.js +20 -0
- package/dist/generate/kinds/same-name/free-name.js.map +1 -0
- package/dist/generate/kinds/same-name/hidden-symbols.d.ts +8 -0
- package/dist/generate/kinds/same-name/hidden-symbols.d.ts.map +1 -0
- package/dist/generate/kinds/same-name/hidden-symbols.js +18 -0
- package/dist/generate/kinds/same-name/hidden-symbols.js.map +1 -0
- package/dist/generate/kinds/same-name/imported-twice-notes.d.ts +10 -0
- package/dist/generate/kinds/same-name/imported-twice-notes.d.ts.map +1 -0
- package/dist/generate/kinds/same-name/imported-twice-notes.js +24 -0
- package/dist/generate/kinds/same-name/imported-twice-notes.js.map +1 -0
- package/dist/generate/kinds/same-name/index-exports.d.ts +11 -0
- package/dist/generate/kinds/same-name/index-exports.d.ts.map +1 -0
- package/dist/generate/kinds/same-name/index-exports.js +27 -0
- package/dist/generate/kinds/same-name/index-exports.js.map +1 -0
- package/dist/generate/kinds/same-name/index-picture.d.ts +29 -0
- package/dist/generate/kinds/same-name/index-picture.d.ts.map +1 -0
- package/dist/generate/kinds/same-name/index-picture.js +63 -0
- package/dist/generate/kinds/same-name/index-picture.js.map +1 -0
- package/dist/generate/kinds/same-name/index-reading.d.ts +83 -0
- package/dist/generate/kinds/same-name/index-reading.d.ts.map +1 -0
- package/dist/generate/kinds/same-name/index-reading.js +105 -0
- package/dist/generate/kinds/same-name/index-reading.js.map +1 -0
- package/dist/generate/kinds/same-name/keep-the-picture.d.ts +17 -0
- package/dist/generate/kinds/same-name/keep-the-picture.d.ts.map +1 -0
- package/dist/generate/kinds/same-name/keep-the-picture.js +164 -0
- package/dist/generate/kinds/same-name/keep-the-picture.js.map +1 -0
- package/dist/generate/kinds/same-name/lines-to-settle.d.ts +37 -0
- package/dist/generate/kinds/same-name/lines-to-settle.d.ts.map +1 -0
- package/dist/generate/kinds/same-name/lines-to-settle.js +100 -0
- package/dist/generate/kinds/same-name/lines-to-settle.js.map +1 -0
- package/dist/generate/kinds/same-name/linked.d.ts +14 -0
- package/dist/generate/kinds/same-name/linked.d.ts.map +1 -0
- package/dist/generate/kinds/same-name/linked.js +14 -0
- package/dist/generate/kinds/same-name/linked.js.map +1 -0
- package/dist/generate/kinds/same-name/listed-entity.d.ts +25 -0
- package/dist/generate/kinds/same-name/listed-entity.d.ts.map +1 -0
- package/dist/generate/kinds/same-name/listed-entity.js +25 -0
- package/dist/generate/kinds/same-name/listed-entity.js.map +1 -0
- package/dist/generate/kinds/same-name/may-share.d.ts +22 -0
- package/dist/generate/kinds/same-name/may-share.d.ts.map +1 -0
- package/dist/generate/kinds/same-name/may-share.js +35 -0
- package/dist/generate/kinds/same-name/may-share.js.map +1 -0
- package/dist/generate/kinds/same-name/not-settled.d.ts +16 -0
- package/dist/generate/kinds/same-name/not-settled.d.ts.map +1 -0
- package/dist/generate/kinds/same-name/not-settled.js +12 -0
- package/dist/generate/kinds/same-name/not-settled.js.map +1 -0
- package/dist/generate/kinds/same-name/places-of.d.ts +4 -0
- package/dist/generate/kinds/same-name/places-of.d.ts.map +1 -0
- package/dist/generate/kinds/same-name/places-of.js +13 -0
- package/dist/generate/kinds/same-name/places-of.js.map +1 -0
- package/dist/generate/kinds/same-name/project-reader.d.ts +13 -0
- package/dist/generate/kinds/same-name/project-reader.d.ts.map +1 -0
- package/dist/generate/kinds/same-name/project-reader.js +55 -0
- package/dist/generate/kinds/same-name/project-reader.js.map +1 -0
- package/dist/generate/kinds/same-name/read-module.d.ts +44 -0
- package/dist/generate/kinds/same-name/read-module.d.ts.map +1 -0
- package/dist/generate/kinds/same-name/read-module.js +189 -0
- package/dist/generate/kinds/same-name/read-module.js.map +1 -0
- package/dist/generate/kinds/same-name/read-tables-file.d.ts +34 -0
- package/dist/generate/kinds/same-name/read-tables-file.d.ts.map +1 -0
- package/dist/generate/kinds/same-name/read-tables-file.js +116 -0
- package/dist/generate/kinds/same-name/read-tables-file.js.map +1 -0
- package/dist/generate/kinds/same-name/region-of.d.ts +3 -0
- package/dist/generate/kinds/same-name/region-of.d.ts.map +1 -0
- package/dist/generate/kinds/same-name/region-of.js +5 -0
- package/dist/generate/kinds/same-name/region-of.js.map +1 -0
- package/dist/generate/kinds/same-name/settle-same-names.d.ts +30 -0
- package/dist/generate/kinds/same-name/settle-same-names.d.ts.map +1 -0
- package/dist/generate/kinds/same-name/settle-same-names.js +123 -0
- package/dist/generate/kinds/same-name/settle-same-names.js.map +1 -0
- package/dist/generate/kinds/same-name/signature-of.d.ts +4 -0
- package/dist/generate/kinds/same-name/signature-of.d.ts.map +1 -0
- package/dist/generate/kinds/same-name/signature-of.js +5 -0
- package/dist/generate/kinds/same-name/signature-of.js.map +1 -0
- package/dist/generate/kinds/same-name/sources-of.d.ts +35 -0
- package/dist/generate/kinds/same-name/sources-of.d.ts.map +1 -0
- package/dist/generate/kinds/same-name/sources-of.js +57 -0
- package/dist/generate/kinds/same-name/sources-of.js.map +1 -0
- package/dist/generate/kinds/same-name/symbol-of.d.ts +9 -0
- package/dist/generate/kinds/same-name/symbol-of.d.ts.map +1 -0
- package/dist/generate/kinds/same-name/symbol-of.js +8 -0
- package/dist/generate/kinds/same-name/symbol-of.js.map +1 -0
- package/dist/generate/kinds/same-name/tables-constants.d.ts +5 -0
- package/dist/generate/kinds/same-name/tables-constants.d.ts.map +1 -0
- package/dist/generate/kinds/same-name/tables-constants.js +8 -0
- package/dist/generate/kinds/same-name/tables-constants.js.map +1 -0
- package/dist/generate/kinds/same-name/tables-file-of.d.ts +5 -0
- package/dist/generate/kinds/same-name/tables-file-of.d.ts.map +1 -0
- package/dist/generate/kinds/same-name/tables-file-of.js +6 -0
- package/dist/generate/kinds/same-name/tables-file-of.js.map +1 -0
- package/dist/generate/kinds/same-name/tables-files-held.d.ts +9 -0
- package/dist/generate/kinds/same-name/tables-files-held.d.ts.map +1 -0
- package/dist/generate/kinds/same-name/tables-files-held.js +14 -0
- package/dist/generate/kinds/same-name/tables-files-held.js.map +1 -0
- package/dist/generate/kinds/same-name/unread-note.d.ts +22 -0
- package/dist/generate/kinds/same-name/unread-note.d.ts.map +1 -0
- package/dist/generate/kinds/same-name/unread-note.js +76 -0
- package/dist/generate/kinds/same-name/unread-note.js.map +1 -0
- package/dist/generate/kinds/same-name/unseen-shares.d.ts +14 -0
- package/dist/generate/kinds/same-name/unseen-shares.d.ts.map +1 -0
- package/dist/generate/kinds/same-name/unseen-shares.js +23 -0
- package/dist/generate/kinds/same-name/unseen-shares.js.map +1 -0
- package/dist/generate/kinds/same-name/workspace-index.d.ts +6 -0
- package/dist/generate/kinds/same-name/workspace-index.d.ts.map +1 -0
- package/dist/generate/kinds/same-name/workspace-index.js +13 -0
- package/dist/generate/kinds/same-name/workspace-index.js.map +1 -0
- package/dist/generate/kinds/same-name/workspace-sources.d.ts +9 -0
- package/dist/generate/kinds/same-name/workspace-sources.d.ts.map +1 -0
- package/dist/generate/kinds/same-name/workspace-sources.js +10 -0
- package/dist/generate/kinds/same-name/workspace-sources.js.map +1 -0
- package/dist/generate/kinds/same-name/yield-to-the-trunk.d.ts +14 -0
- package/dist/generate/kinds/same-name/yield-to-the-trunk.d.ts.map +1 -0
- package/dist/generate/kinds/same-name/yield-to-the-trunk.js +59 -0
- package/dist/generate/kinds/same-name/yield-to-the-trunk.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/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/generator-lock/held-lock-refusal.d.ts.map +1 -1
- package/dist/generator-lock/held-lock-refusal.js +1 -7
- package/dist/generator-lock/held-lock-refusal.js.map +1 -1
- package/dist/generator-lock/holder-text.d.ts +4 -0
- package/dist/generator-lock/holder-text.d.ts.map +1 -0
- package/dist/generator-lock/holder-text.js +10 -0
- package/dist/generator-lock/holder-text.js.map +1 -0
- package/dist/generator-lock/index.d.ts +4 -0
- package/dist/generator-lock/index.d.ts.map +1 -1
- package/dist/generator-lock/index.js +2 -0
- package/dist/generator-lock/index.js.map +1 -1
- package/dist/generator-lock/with-folder-lock.d.ts +27 -0
- package/dist/generator-lock/with-folder-lock.d.ts.map +1 -0
- package/dist/generator-lock/with-folder-lock.js +65 -0
- package/dist/generator-lock/with-folder-lock.js.map +1 -0
- package/dist/generator-lock/with-generator-lock.d.ts +1 -5
- package/dist/generator-lock/with-generator-lock.d.ts.map +1 -1
- package/dist/generator-lock/with-generator-lock.js +11 -58
- package/dist/generator-lock/with-generator-lock.js.map +1 -1
- package/dist/help/tool-notes.d.ts.map +1 -1
- package/dist/help/tool-notes.js +17 -1
- package/dist/help/tool-notes.js.map +1 -1
- package/dist/help/usage.d.ts.map +1 -1
- package/dist/help/usage.js +2 -1
- package/dist/help/usage.js.map +1 -1
- package/dist/help/work-notes.d.ts.map +1 -1
- package/dist/help/work-notes.js +15 -5
- package/dist/help/work-notes.js.map +1 -1
- package/dist/init/end-of-the-index.d.ts +9 -0
- package/dist/init/end-of-the-index.d.ts.map +1 -0
- package/dist/init/end-of-the-index.js +13 -0
- package/dist/init/end-of-the-index.js.map +1 -0
- 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/laid-out.d.ts +3 -0
- package/dist/init/laid-out.d.ts.map +1 -0
- package/dist/init/laid-out.js +7 -0
- package/dist/init/laid-out.js.map +1 -0
- package/dist/init/list-read-models.d.ts +20 -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/prisma-client-script.js +1 -1
- package/dist/init/manifest/prisma-client-script.js.map +1 -1
- package/dist/init/manifest/versions.js +33 -33
- 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 +12 -2
- package/dist/init/rewire-contexts.js.map +1 -1
- package/dist/init/rewire-tables.d.ts.map +1 -1
- package/dist/init/rewire-tables.js +18 -10
- package/dist/init/rewire-tables.js.map +1 -1
- package/dist/init/run-init.d.ts.map +1 -1
- package/dist/init/run-init.js +4 -8
- package/dist/init/run-init.js.map +1 -1
- package/dist/init/settle-index-names.d.ts +11 -0
- package/dist/init/settle-index-names.d.ts.map +1 -0
- package/dist/init/settle-index-names.js +89 -0
- package/dist/init/settle-index-names.js.map +1 -0
- 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/accept-in-merge-message.d.ts.map +1 -1
- package/dist/merge/accept-in-merge-message.js +2 -7
- package/dist/merge/accept-in-merge-message.js.map +1 -1
- package/dist/merge/as-settled.d.ts +7 -0
- package/dist/merge/as-settled.d.ts.map +1 -0
- package/dist/merge/as-settled.js +9 -0
- package/dist/merge/as-settled.js.map +1 -0
- package/dist/merge/config-of-the-merge.d.ts +12 -0
- package/dist/merge/config-of-the-merge.d.ts.map +1 -0
- package/dist/merge/config-of-the-merge.js +35 -0
- package/dist/merge/config-of-the-merge.js.map +1 -0
- package/dist/merge/continue-merge.d.ts.map +1 -1
- package/dist/merge/continue-merge.js +32 -1
- package/dist/merge/continue-merge.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/lines-at-moved-places.d.ts +10 -0
- package/dist/merge/lines-at-moved-places.d.ts.map +1 -0
- package/dist/merge/lines-at-moved-places.js +38 -0
- package/dist/merge/lines-at-moved-places.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/in-progress-merge.d.ts.map +1 -1
- package/dist/merge/lost/in-progress-merge.js +6 -2
- package/dist/merge/lost/in-progress-merge.js.map +1 -1
- package/dist/merge/lost/line-findings.d.ts +3 -2
- package/dist/merge/lost/line-findings.d.ts.map +1 -1
- package/dist/merge/lost/line-findings.js +5 -4
- package/dist/merge/lost/line-findings.js.map +1 -1
- package/dist/merge/lost/line-key.d.ts +7 -0
- package/dist/merge/lost/line-key.d.ts.map +1 -0
- package/dist/merge/lost/line-key.js +11 -0
- package/dist/merge/lost/line-key.js.map +1 -0
- package/dist/merge/lost/lost-lines.d.ts +1 -1
- package/dist/merge/lost/lost-lines.d.ts.map +1 -1
- package/dist/merge/lost/lost-lines.js +3 -2
- package/dist/merge/lost/lost-lines.js.map +1 -1
- package/dist/merge/lost/merge-of-record.d.ts.map +1 -1
- package/dist/merge/lost/merge-of-record.js +1 -0
- package/dist/merge/lost/merge-of-record.js.map +1 -1
- package/dist/merge/lost/merge-records.d.ts +2 -0
- package/dist/merge/lost/merge-records.d.ts.map +1 -1
- package/dist/merge/lost/merge-records.js +3 -2
- package/dist/merge/lost/merge-records.js.map +1 -1
- package/dist/merge/lost/merge-to-verify.d.ts +2 -0
- package/dist/merge/lost/merge-to-verify.d.ts.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/rewritten-in-place.d.ts +5 -2
- package/dist/merge/lost/rewritten-in-place.d.ts.map +1 -1
- package/dist/merge/lost/rewritten-in-place.js +6 -5
- package/dist/merge/lost/rewritten-in-place.js.map +1 -1
- package/dist/merge/lost/verify-merge.d.ts.map +1 -1
- package/dist/merge/lost/verify-merge.js +10 -3
- package/dist/merge/lost/verify-merge.js.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-state.d.ts +2 -0
- package/dist/merge/merge-state.d.ts.map +1 -1
- package/dist/merge/merge-state.js +3 -2
- package/dist/merge/merge-state.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 +8 -3
- package/dist/merge/merge-trunk.js.map +1 -1
- package/dist/merge/merged-tree-workspace.d.ts +19 -0
- package/dist/merge/merged-tree-workspace.d.ts.map +1 -0
- package/dist/merge/merged-tree-workspace.js +41 -0
- package/dist/merge/merged-tree-workspace.js.map +1 -0
- package/dist/merge/moved-tables-files.d.ts +9 -0
- package/dist/merge/moved-tables-files.d.ts.map +1 -0
- package/dist/merge/moved-tables-files.js +16 -0
- package/dist/merge/moved-tables-files.js.map +1 -0
- 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/preview-table-names.d.ts +21 -0
- package/dist/merge/preview-table-names.d.ts.map +1 -0
- package/dist/merge/preview-table-names.js +85 -0
- package/dist/merge/preview-table-names.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/merge/settle-table-names.d.ts +21 -0
- package/dist/merge/settle-table-names.d.ts.map +1 -0
- package/dist/merge/settle-table-names.js +60 -0
- package/dist/merge/settle-table-names.js.map +1 -0
- package/dist/merge/side-index.d.ts +13 -0
- package/dist/merge/side-index.d.ts.map +1 -0
- package/dist/merge/side-index.js +43 -0
- package/dist/merge/side-index.js.map +1 -0
- package/dist/merge/side-reader.d.ts +8 -0
- package/dist/merge/side-reader.d.ts.map +1 -0
- package/dist/merge/side-reader.js +13 -0
- package/dist/merge/side-reader.js.map +1 -0
- package/dist/merge/side-tables-file.d.ts +5 -0
- package/dist/merge/side-tables-file.d.ts.map +1 -0
- package/dist/merge/side-tables-file.js +10 -0
- package/dist/merge/side-tables-file.js.map +1 -0
- package/dist/merge/table-names-settled.d.ts +18 -0
- package/dist/merge/table-names-settled.d.ts.map +1 -0
- package/dist/merge/table-names-settled.js +168 -0
- package/dist/merge/table-names-settled.js.map +1 -0
- package/dist/merge/trailer-in-merge-message.d.ts +9 -0
- package/dist/merge/trailer-in-merge-message.d.ts.map +1 -0
- package/dist/merge/trailer-in-merge-message.js +16 -0
- package/dist/merge/trailer-in-merge-message.js.map +1 -0
- package/dist/merge/tree-files.d.ts +21 -0
- package/dist/merge/tree-files.d.ts.map +1 -0
- package/dist/merge/tree-files.js +86 -0
- package/dist/merge/tree-files.js.map +1 -0
- package/dist/merge/trunk-reader.d.ts +5 -0
- package/dist/merge/trunk-reader.d.ts.map +1 -0
- package/dist/merge/trunk-reader.js +9 -0
- package/dist/merge/trunk-reader.js.map +1 -0
- package/dist/merge/two-tables-files.d.ts +19 -0
- package/dist/merge/two-tables-files.d.ts.map +1 -0
- package/dist/merge/two-tables-files.js +67 -0
- package/dist/merge/two-tables-files.js.map +1 -0
- package/dist/migration/file-of-source.d.ts +3 -0
- package/dist/migration/file-of-source.d.ts.map +1 -0
- package/dist/migration/file-of-source.js +5 -0
- package/dist/migration/file-of-source.js.map +1 -0
- package/dist/migration/hidden-in-index.d.ts +15 -0
- package/dist/migration/hidden-in-index.d.ts.map +1 -0
- package/dist/migration/hidden-in-index.js +23 -0
- package/dist/migration/hidden-in-index.js.map +1 -0
- package/dist/migration/index.d.ts +3 -0
- package/dist/migration/index.d.ts.map +1 -1
- package/dist/migration/index.js +3 -0
- package/dist/migration/index.js.map +1 -1
- package/dist/migration/is-source-of-context.d.ts +17 -0
- package/dist/migration/is-source-of-context.d.ts.map +1 -0
- package/dist/migration/is-source-of-context.js +13 -0
- package/dist/migration/is-source-of-context.js.map +1 -0
- package/dist/migration/listed-in-index.d.ts +15 -3
- package/dist/migration/listed-in-index.d.ts.map +1 -1
- package/dist/migration/listed-in-index.js +25 -4
- package/dist/migration/listed-in-index.js.map +1 -1
- package/dist/migration/named-bindings-of.d.ts +14 -0
- package/dist/migration/named-bindings-of.d.ts.map +1 -0
- package/dist/migration/named-bindings-of.js +21 -0
- package/dist/migration/named-bindings-of.js.map +1 -0
- 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/migration/warn-dropped-context-tables.d.ts.map +1 -1
- package/dist/migration/warn-dropped-context-tables.js +21 -6
- package/dist/migration/warn-dropped-context-tables.js.map +1 -1
- 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/prisma-client/client-outputs.d.ts +3 -0
- package/dist/prisma-client/client-outputs.d.ts.map +1 -0
- package/dist/prisma-client/client-outputs.js +9 -0
- package/dist/prisma-client/client-outputs.js.map +1 -0
- package/dist/prisma-client/index.d.ts +4 -0
- package/dist/prisma-client/index.d.ts.map +1 -0
- package/dist/prisma-client/index.js +4 -0
- package/dist/prisma-client/index.js.map +1 -0
- package/dist/prisma-client/prisma-client-fingerprint.d.ts +7 -0
- package/dist/prisma-client/prisma-client-fingerprint.d.ts.map +1 -0
- package/dist/prisma-client/prisma-client-fingerprint.js +32 -0
- package/dist/prisma-client/prisma-client-fingerprint.js.map +1 -0
- package/dist/prisma-client/prisma-client-in-turn.d.ts +14 -0
- package/dist/prisma-client/prisma-client-in-turn.d.ts.map +1 -0
- package/dist/prisma-client/prisma-client-in-turn.js +15 -0
- package/dist/prisma-client/prisma-client-in-turn.js.map +1 -0
- package/dist/prisma-client/prisma-client-lock-refusal.d.ts +5 -0
- package/dist/prisma-client/prisma-client-lock-refusal.d.ts.map +1 -0
- package/dist/prisma-client/prisma-client-lock-refusal.js +11 -0
- package/dist/prisma-client/prisma-client-lock-refusal.js.map +1 -0
- package/dist/prisma-client/prisma-client-paths.d.ts +7 -0
- package/dist/prisma-client/prisma-client-paths.d.ts.map +1 -0
- package/dist/prisma-client/prisma-client-paths.js +8 -0
- package/dist/prisma-client/prisma-client-paths.js.map +1 -0
- package/dist/prisma-client/refresh-prisma-client.d.ts +16 -0
- package/dist/prisma-client/refresh-prisma-client.d.ts.map +1 -0
- package/dist/prisma-client/refresh-prisma-client.js +53 -0
- package/dist/prisma-client/refresh-prisma-client.js.map +1 -0
- package/dist/prisma-client/schema-files.d.ts +3 -0
- package/dist/prisma-client/schema-files.d.ts.map +1 -0
- package/dist/prisma-client/schema-files.js +18 -0
- package/dist/prisma-client/schema-files.js.map +1 -0
- package/dist/prisma-schema/single-prisma-schema-steps.js +1 -1
- package/dist/prisma-schema/single-prisma-schema-steps.js.map +1 -1
- package/dist/read-models/buildable-constructor.d.ts +3 -0
- package/dist/read-models/buildable-constructor.d.ts.map +1 -0
- package/dist/read-models/buildable-constructor.js +3 -0
- package/dist/read-models/buildable-constructor.js.map +1 -0
- package/dist/read-models/declared-class.d.ts +14 -0
- package/dist/read-models/declared-class.d.ts.map +1 -0
- package/dist/read-models/declared-class.js +2 -0
- package/dist/read-models/declared-class.js.map +1 -0
- package/dist/read-models/declared-classes.d.ts +32 -0
- package/dist/read-models/declared-classes.d.ts.map +1 -0
- package/dist/read-models/declared-classes.js +123 -0
- package/dist/read-models/declared-classes.js.map +1 -0
- package/dist/read-models/list-answers.d.ts +35 -0
- package/dist/read-models/list-answers.d.ts.map +1 -0
- package/dist/read-models/list-answers.js +53 -0
- package/dist/read-models/list-answers.js.map +1 -0
- package/dist/read-models/listing-of.d.ts +25 -0
- package/dist/read-models/listing-of.d.ts.map +1 -0
- package/dist/read-models/listing-of.js +22 -0
- package/dist/read-models/listing-of.js.map +1 -0
- package/dist/read-models/read-model-list-of.d.ts +12 -0
- package/dist/read-models/read-model-list-of.d.ts.map +1 -0
- package/dist/read-models/read-model-list-of.js +94 -0
- package/dist/read-models/read-model-list-of.js.map +1 -0
- package/dist/read-models/read-model-list.d.ts +41 -0
- package/dist/read-models/read-model-list.d.ts.map +1 -0
- package/dist/read-models/read-model-list.js +2 -0
- package/dist/read-models/read-model-list.js.map +1 -0
- package/dist/read-models/read-model-store.d.ts +16 -0
- package/dist/read-models/read-model-store.d.ts.map +1 -0
- package/dist/read-models/read-model-store.js +2 -0
- package/dist/read-models/read-model-store.js.map +1 -0
- package/dist/read-models/read-model-stores-of.d.ts +14 -0
- package/dist/read-models/read-model-stores-of.d.ts.map +1 -0
- package/dist/read-models/read-model-stores-of.js +63 -0
- package/dist/read-models/read-model-stores-of.js.map +1 -0
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js +3 -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/slice/storage-of-slice.d.ts +10 -7
- package/dist/slice/storage-of-slice.d.ts.map +1 -1
- package/dist/slice/storage-of-slice.js +145 -22
- package/dist/slice/storage-of-slice.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/stack-vars.d.ts.map +1 -1
- package/dist/stack/stack-vars.js +10 -1
- package/dist/stack/stack-vars.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/workspace/exit-code-of.d.ts +2 -2
- package/dist/workspace/exit-code-of.d.ts.map +1 -1
- package/dist/workspace/exit-code-of.js +2 -2
- package/dist/workspace/exit-code-of.js.map +1 -1
- package/dist/workspace/located-step.d.ts +5 -0
- package/dist/workspace/located-step.d.ts.map +1 -0
- package/dist/workspace/located-step.js +7 -0
- package/dist/workspace/located-step.js.map +1 -0
- package/dist/workspace/remove-file.d.ts +3 -0
- package/dist/workspace/remove-file.d.ts.map +1 -0
- package/dist/workspace/remove-file.js +11 -0
- package/dist/workspace/remove-file.js.map +1 -0
- package/dist/workspace/workspace-report.d.ts +2 -0
- package/dist/workspace/workspace-report.d.ts.map +1 -1
- package/dist/workspace/workspace.d.ts +4 -3
- package/dist/workspace/workspace.d.ts.map +1 -1
- package/dist/workspace/workspace.js +16 -16
- package/dist/workspace/workspace.js.map +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/docker/dockerignore.tpl +2 -0
- 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 +70 -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 +5 -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/biome.json.tpl +1 -1
- package/templates/pipeline/github/workflows/codeql.yml +2 -2
- package/templates/pipeline/package-scripts.json +2 -2
- 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
- package/templates/repository/typeorm/schema-export.tpl +2 -2
- package/templates/read-model/typeorm/schema-export.tpl +0 -4
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import type pg from 'pg';
|
|
2
|
+
import { KEPT_TABLES } from './test-database-kept{{alias.sibling}}';
|
|
3
|
+
import { codeOf, connectedTo, databaseOf } from './test-database-server{{alias.sibling}}';
|
|
4
|
+
|
|
5
|
+
/** What a run did to its copy of the migrated database. */
|
|
6
|
+
export interface Emptied {
|
|
7
|
+
/** The tables it emptied that held rows. */
|
|
8
|
+
readonly held: readonly string[];
|
|
9
|
+
/** The tables it left with their rows because the role of the run may not empty them. */
|
|
10
|
+
readonly ofAnotherRole: readonly string[];
|
|
11
|
+
/** The names of KEPT_TABLES that are no table of the copy. */
|
|
12
|
+
readonly unmatched: readonly string[];
|
|
13
|
+
/** The bytes the tables it emptied took. */
|
|
14
|
+
readonly bytes: number;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
interface Table {
|
|
18
|
+
/** `<schema>.<table>`, as KEPT_TABLES names it and as the server stores it. */
|
|
19
|
+
readonly name: string;
|
|
20
|
+
readonly schema: string;
|
|
21
|
+
/** The same, as a statement names it. */
|
|
22
|
+
readonly quoted: string;
|
|
23
|
+
/** The role of the run may empty it: it owns it, a truncate that restarts the sequences being the right of the owner, and may use its schema. */
|
|
24
|
+
readonly owned: boolean;
|
|
25
|
+
/** Its rows are in its partitions, which are emptied with it. */
|
|
26
|
+
readonly partitioned: boolean;
|
|
27
|
+
readonly bytes: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
interface Link {
|
|
31
|
+
readonly from: string;
|
|
32
|
+
readonly to: string;
|
|
33
|
+
readonly schema: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** What a name of KEPT_TABLES looks like: a schema, then a table or `*`, as the server stores them, without quotes; a dot ends the schema. */
|
|
37
|
+
const NAME = /^[^.*"]+\.(?:[^.*"]+|\*)$/;
|
|
38
|
+
/** What the generated list names that a project may not hold yet: nothing is said when one of these is no table. */
|
|
39
|
+
{{#if orm.drizzle}}
|
|
40
|
+
const MAY_BE_ABSENT = ['drizzle.__drizzle_migrations', 'audit.*'];
|
|
41
|
+
{{/if}}
|
|
42
|
+
{{#if orm.knex}}
|
|
43
|
+
const MAY_BE_ABSENT = ['public.knex_migrations', 'public.knex_migrations_lock', 'audit.*'];
|
|
44
|
+
{{/if}}
|
|
45
|
+
{{#if orm.prisma}}
|
|
46
|
+
const MAY_BE_ABSENT = ['public._prisma_migrations', 'audit.*'];
|
|
47
|
+
{{/if}}
|
|
48
|
+
{{#if orm.typeorm}}
|
|
49
|
+
const MAY_BE_ABSENT = ['public.migrations', 'public.typeorm_metadata', 'audit.*'];
|
|
50
|
+
{{/if}}
|
|
51
|
+
|
|
52
|
+
/** The tables of the project: not those of the server, nor those of an extension, which keeps its own, nor a partition, which goes with its table. */
|
|
53
|
+
const TABLES = `select n.nspname || '.' || c.relname as name, n.nspname as schema, format('%I.%I', n.nspname, c.relname) as quoted,
|
|
54
|
+
pg_has_role(c.relowner, 'USAGE') and has_schema_privilege(n.oid, 'USAGE') as owned,
|
|
55
|
+
c.relkind = 'p' as partitioned, pg_total_relation_size(c.oid)::text as bytes
|
|
56
|
+
from pg_class c join pg_namespace n on n.oid = c.relnamespace
|
|
57
|
+
where c.relkind in ('r', 'p') and not c.relispartition
|
|
58
|
+
and n.nspname not in ('pg_catalog', 'information_schema') and n.nspname not like 'pg\\_%'
|
|
59
|
+
and not exists (select 1 from pg_depend d where d.classid = 'pg_class'::regclass and d.objid = c.oid and d.deptype = 'e')
|
|
60
|
+
order by 1`;
|
|
61
|
+
|
|
62
|
+
const NAMED = (alias: string, name: string): string =>
|
|
63
|
+
`join pg_class ${alias} on ${alias}.oid = ${name} join pg_namespace ${alias}n on ${alias}n.oid = ${alias}.relnamespace`;
|
|
64
|
+
|
|
65
|
+
/** A table, the one it references or is a partition of, and its own schema. */
|
|
66
|
+
const LINK = `rn.nspname || '.' || r.relname as "from", fn.nspname || '.' || f.relname as "to", rn.nspname as schema`;
|
|
67
|
+
|
|
68
|
+
const REFERENCES = `select ${LINK}
|
|
69
|
+
from pg_constraint k ${NAMED('r', 'k.conrelid')} ${NAMED('f', 'k.confrelid')} where k.contype = 'f'`;
|
|
70
|
+
|
|
71
|
+
/** Each partition and the table it is a partition of. */
|
|
72
|
+
const PARTITIONS = `select ${LINK}
|
|
73
|
+
from pg_inherits i ${NAMED('r', 'i.inhrelid')} ${NAMED('f', 'i.inhparent')} where r.relispartition`;
|
|
74
|
+
|
|
75
|
+
/** The materialized views that hold a result and that the role may refresh, the oldest first: one may read another. */
|
|
76
|
+
const VIEWS = `select format('%I.%I', n.nspname, c.relname) as quoted
|
|
77
|
+
from pg_class c join pg_namespace n on n.oid = c.relnamespace
|
|
78
|
+
where c.relkind = 'm' and c.relispopulated and pg_has_role(c.relowner, 'USAGE') order by c.oid`;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Empties the copy `name` of the migrated database `url` names: every table of the project but
|
|
82
|
+
* those KEPT_TABLES lists (test-database-kept.ts) and those the role may not empty, in one
|
|
83
|
+
* statement, without `cascade` and each table `only`, so that a kept table is never emptied
|
|
84
|
+
* through a foreign key nor through the table it inherits from. A spec file then starts from the
|
|
85
|
+
* tables of the migrated database and no row, as on PostgreSQL in process, whatever a migration,
|
|
86
|
+
* an application or a spec stored there. The materialized views are refreshed, so that none shows
|
|
87
|
+
* the rows that are gone. A sequence no column owns keeps its value.
|
|
88
|
+
*/
|
|
89
|
+
export async function emptied(url: string, name: string): Promise<Emptied> {
|
|
90
|
+
const copy = await connectedTo(url, name);
|
|
91
|
+
|
|
92
|
+
try {
|
|
93
|
+
refuseAShapelessName();
|
|
94
|
+
|
|
95
|
+
const tables = (await copy.query<Table>(TABLES)).rows;
|
|
96
|
+
const emptying = tables.filter((table) => table.owned && !kept(table));
|
|
97
|
+
|
|
98
|
+
if (tables.length === 0) {
|
|
99
|
+
throw new Error(`The database "${databaseOf(url)}" holds no table: migrate it first (npm run db:migrate).`);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
await refuseWhatAKeptTableLoses(copy, tables, emptying);
|
|
103
|
+
|
|
104
|
+
const held = await holdingRows(copy, emptying);
|
|
105
|
+
|
|
106
|
+
await empty(copy, emptying);
|
|
107
|
+
|
|
108
|
+
return {
|
|
109
|
+
held,
|
|
110
|
+
ofAnotherRole: tables.filter((table) => !table.owned && !kept(table)).map((table) => table.name),
|
|
111
|
+
unmatched: unmatched(tables),
|
|
112
|
+
bytes: emptying.reduce((sum, table) => sum + Number(table.bytes), 0),
|
|
113
|
+
};
|
|
114
|
+
} catch (error) {
|
|
115
|
+
throw codeOf(error) === '' ? error : notEmptied(databaseOf(url), error);
|
|
116
|
+
} finally {
|
|
117
|
+
await copy.end();
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function kept(table: Pick<Table, 'name' | 'schema'>): boolean {
|
|
122
|
+
return KEPT_TABLES.some((listed) => names(listed, table));
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** A listed name is the table, letter for letter, or its schema followed by `.*`, whatever the name of the table holds. */
|
|
126
|
+
function names(listed: string, { name, schema }: Pick<Table, 'name' | 'schema'>): boolean {
|
|
127
|
+
return listed === name || listed === `${schema}.*`;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function unmatched(tables: readonly Table[]): string[] {
|
|
131
|
+
return KEPT_TABLES.filter((one) => !MAY_BE_ABSENT.includes(one) && !tables.some((table) => names(one, table)));
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function refuseAShapelessName(): void {
|
|
135
|
+
const shapeless = KEPT_TABLES.find((listed) => !NAME.test(listed));
|
|
136
|
+
|
|
137
|
+
if (shapeless !== undefined) {
|
|
138
|
+
throw new Error(
|
|
139
|
+
`KEPT_TABLES of test/support/test-database-kept.ts holds "${shapeless}": a name is <schema>.<table>, or <schema>.* for every table of a schema, written as the server stores it and without quotes (a table created as "Countries" is public.Countries, one created as countries or Countries without quotes is public.countries); a table whose name holds a dot or a quote is kept through <schema>.* only.`,
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Said before the server refuses it without a name, or does it without a word: a table that keeps
|
|
146
|
+
* its rows and references an emptied one, which no `cascade` empties for it, and a kept partition
|
|
147
|
+
* of an emptied table, which goes with its table.
|
|
148
|
+
*/
|
|
149
|
+
async function refuseWhatAKeptTableLoses(
|
|
150
|
+
copy: pg.Client,
|
|
151
|
+
tables: readonly Table[],
|
|
152
|
+
emptying: readonly Table[],
|
|
153
|
+
): Promise<void> {
|
|
154
|
+
const partitions = (await copy.query<Link>(PARTITIONS)).rows;
|
|
155
|
+
const tableOf = (name: string): string => partitions.find((partition) => partition.from === name)?.to ?? name;
|
|
156
|
+
const rootOf = (name: string): string => (tableOf(name) === name ? name : rootOf(tableOf(name)));
|
|
157
|
+
const gone = new Set(emptying.map((table) => table.name));
|
|
158
|
+
|
|
159
|
+
const stays = (name: string): boolean =>
|
|
160
|
+
tables.some((table) => table.name === rootOf(name)) && !gone.has(rootOf(name));
|
|
161
|
+
|
|
162
|
+
const partition = partitions.find(({ from, schema }) => kept({ name: from, schema }) && gone.has(rootOf(from)))?.from;
|
|
163
|
+
const broken = (await copy.query<Link>(REFERENCES)).rows.find(({ from, to }) => stays(from) && gone.has(rootOf(to)));
|
|
164
|
+
const where = 'in KEPT_TABLES of test/support/test-database-kept.ts';
|
|
165
|
+
|
|
166
|
+
if (partition !== undefined) {
|
|
167
|
+
throw new Error(
|
|
168
|
+
`The table ${partition} is a partition of ${rootOf(partition)}, which the run empties, and a partition is emptied with its table: keep ${rootOf(partition)} ${where}.`,
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
if (broken !== undefined) {
|
|
173
|
+
throw new Error(
|
|
174
|
+
`The table ${rootOf(broken.from)} keeps its rows and references ${rootOf(broken.to)}, which the run empties: keep ${rootOf(broken.to)} too, ${where}.`,
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
async function holdingRows(copy: pg.Client, emptying: readonly Table[]): Promise<string[]> {
|
|
180
|
+
const each = emptying.map(
|
|
181
|
+
({ name, quoted }) => `select '${name.replaceAll("'", "''")}' as name where exists (select 1 from ${quoted})`,
|
|
182
|
+
);
|
|
183
|
+
|
|
184
|
+
if (emptying.length === 0) {
|
|
185
|
+
return [];
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
return (await copy.query<{ name: string }>(each.join(' union all '))).rows.map((row) => row.name);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
async function empty(copy: pg.Client, emptying: readonly Table[]): Promise<void> {
|
|
192
|
+
// `only`: a table that inherits from an emptied one and keeps its rows is not reached through it. A partitioned table has no rows of its own.
|
|
193
|
+
const each = emptying.map((table) => (table.partitioned ? table.quoted : `only ${table.quoted}`));
|
|
194
|
+
|
|
195
|
+
if (emptying.length > 0) {
|
|
196
|
+
await copy.query(`truncate table ${each.join(', ')} restart identity`);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
for (const view of (await copy.query<{ quoted: string }>(VIEWS)).rows) {
|
|
200
|
+
await copy.query(`refresh materialized view ${view.quoted}`);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
function notEmptied(database: string, error: unknown): Error {
|
|
205
|
+
return new Error(
|
|
206
|
+
`The copy of the database "${database}" could not be emptied (${String(error)}): list the table it names in KEPT_TABLES of test/support/test-database-kept.ts, or give the tests a database of their own, migrated and empty.`,
|
|
207
|
+
{ cause: error },
|
|
208
|
+
);
|
|
209
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The tables an end-to-end run on a server leaves their rows (test-database-emptying.ts): every
|
|
3
|
+
* other table of its copy of the migrated database is emptied before a spec file starts. A name is
|
|
4
|
+
* `<schema>.<table>`, or `<schema>.*` for every table of a schema, written as the server stores it
|
|
5
|
+
* and without quotes: in lower case unless the table was created between quotes (`"Countries"` is
|
|
6
|
+
* `public.Countries`); a table whose name holds a dot or a quote is kept through `<schema>.*`
|
|
7
|
+
* only. The run says of a name that it is no table of the database. Add a table
|
|
8
|
+
* whose rows a migration inserts and the application reads (a list of countries, a plan). A kept
|
|
9
|
+
* table that references an emptied one, or is a partition of one, needs that one kept too: the run
|
|
10
|
+
* says which.
|
|
11
|
+
*/
|
|
12
|
+
export const KEPT_TABLES: readonly string[] = [
|
|
13
|
+
// What the migration tool writes of what it applied: a table it is told to name otherwise goes here under that name.
|
|
14
|
+
{{#if orm.drizzle}}
|
|
15
|
+
'drizzle.__drizzle_migrations',
|
|
16
|
+
{{/if}}
|
|
17
|
+
{{#if orm.knex}}
|
|
18
|
+
'public.knex_migrations',
|
|
19
|
+
'public.knex_migrations_lock',
|
|
20
|
+
{{/if}}
|
|
21
|
+
{{#if orm.prisma}}
|
|
22
|
+
'public._prisma_migrations',
|
|
23
|
+
{{/if}}
|
|
24
|
+
{{#if orm.typeorm}}
|
|
25
|
+
'public.migrations',
|
|
26
|
+
'public.typeorm_metadata',
|
|
27
|
+
{{/if}}
|
|
28
|
+
{{#if audit.on}}
|
|
29
|
+
// The audit trail, which its guard keeps append-only whoever asks.
|
|
30
|
+
'audit.*',
|
|
31
|
+
{{/if}}
|
|
32
|
+
];
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type pg from 'pg';
|
|
2
|
+
import { dropping, keyOf, LIVE, locked, runOf } from './test-database-server{{alias.sibling}}';
|
|
3
|
+
import { BEAT, DEAD_AFTER_SECONDS } from './test-database-session{{alias.sibling}}';
|
|
4
|
+
|
|
5
|
+
interface Leftover {
|
|
6
|
+
readonly name: string;
|
|
7
|
+
/** The comment of the database: on its template, a run says when it last lived. */
|
|
8
|
+
readonly said: string | null;
|
|
9
|
+
/** The clock of the server, in seconds, as a text. */
|
|
10
|
+
readonly now: string;
|
|
11
|
+
readonly connected: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Drops what the runs that died left on the server, in the session `server` of the run `own`. A
|
|
16
|
+
* database is dropped when it is named after a run on the database `url` names, the lock of that
|
|
17
|
+
* run is free, the run has not said for a minute that it lives, and nobody is connected to the
|
|
18
|
+
* database. The lock alone is not enough: a run whose session the server ended takes it again a
|
|
19
|
+
* moment later, and a file whose pool is idle has no session. A run that lives, in another
|
|
20
|
+
* checkout or on another machine, therefore keeps its databases; a database with any other name is
|
|
21
|
+
* never dropped; and what a run killed a moment ago left goes with a run that starts a minute later.
|
|
22
|
+
*/
|
|
23
|
+
export async function dropLeftovers(server: pg.Client, url: string, own: string): Promise<void> {
|
|
24
|
+
const { rows } = await server.query<Leftover>(
|
|
25
|
+
`select d.datname as name, shobj_description(d.oid, 'pg_database') as said, extract(epoch from now())::bigint::text as now,
|
|
26
|
+
exists (select 1 from pg_stat_activity a where a.datid = d.oid) as connected
|
|
27
|
+
from pg_database d`,
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
const left = rows.filter(({ name }) => ![undefined, own].includes(runOf(name, url)));
|
|
31
|
+
|
|
32
|
+
for (const run of new Set(left.map(({ name }) => runOf(name, url) ?? ''))) {
|
|
33
|
+
const ofTheRun = left.filter(({ name }) => runOf(name, url) === run);
|
|
34
|
+
|
|
35
|
+
if (!lives(ofTheRun) && (await locked(server, `pg_try_advisory_lock(${LIVE}, ${keyOf(run)})`))) {
|
|
36
|
+
// A database somebody is connected to is a file that still runs: asked to drop it, the server would wait 5 seconds, then refuse.
|
|
37
|
+
for (const { name } of ofTheRun.filter((database) => !database.connected)) {
|
|
38
|
+
await server.query(dropping(name, '')).catch(() => undefined);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
await locked(server, `pg_advisory_unlock(${LIVE}, ${keyOf(run)})`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function lives(databases: readonly Leftover[]): boolean {
|
|
47
|
+
return databases.some(({ said, now }) => {
|
|
48
|
+
const last = said?.startsWith(BEAT) === true ? Number(said.slice(BEAT.length)) : 0;
|
|
49
|
+
|
|
50
|
+
return Number(now) - last < DEAD_AFTER_SECONDS;
|
|
51
|
+
});
|
|
52
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import type pg from 'pg';
|
|
2
|
+
import { poolSizeFor } from './test-database-budget{{alias.sibling}}';
|
|
3
|
+
import { copied } from './test-database-copy{{alias.sibling}}';
|
|
4
|
+
import { emptied, type Emptied } from './test-database-emptying{{alias.sibling}}';
|
|
5
|
+
import { dropLeftovers } from './test-database-leftovers{{alias.sibling}}';
|
|
6
|
+
import { databaseOf, dropping, nameOf, onServer, runOf, TEMPLATE } from './test-database-server{{alias.sibling}}';
|
|
7
|
+
import { openSession, type RunSession } from './test-database-session{{alias.sibling}}';
|
|
8
|
+
|
|
9
|
+
/** A run on a server: the template its files copy, the pool of each, and its end. */
|
|
10
|
+
export interface Run {
|
|
11
|
+
readonly template: string;
|
|
12
|
+
readonly poolSize: number;
|
|
13
|
+
|
|
14
|
+
/** Drops the template and what the files of the run did not drop, then lets the lock go. Never throws. */
|
|
15
|
+
end(): Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** A migrated database holds a few megabytes: beyond this it holds rows, and the run says what copying them costs. */
|
|
19
|
+
const LARGE = 64 * 1024 * 1024;
|
|
20
|
+
/** How many of the tables a line names before it counts the others. */
|
|
21
|
+
const NAMED = 20;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Starts a run on the server `url` names, in which `atOnce` spec files run at the same time: takes
|
|
25
|
+
* the lock that says it lives, drops what the runs that died left, refuses a run the connections
|
|
26
|
+
* of the server cannot take, then copies the migrated database (test-database-copy.ts) and empties
|
|
27
|
+
* the copy. The global setup of the end-to-end run calls it once, where no timeout of
|
|
28
|
+
* a hook applies (test-database-setup.ts), and each file copies the template in a fraction of a
|
|
29
|
+
* second (test-database-clone.ts). What the run has to say goes to `tell`, the error output.
|
|
30
|
+
*/
|
|
31
|
+
export async function openRun(url: string, atOnce: number, tell = toErrorOutput): Promise<Run> {
|
|
32
|
+
const session = await openSession(url, tell);
|
|
33
|
+
const template = nameOf(url, session.id, TEMPLATE);
|
|
34
|
+
const end = (): Promise<void> => ended(session, url);
|
|
35
|
+
|
|
36
|
+
try {
|
|
37
|
+
await dropLeftovers(session.server(), url, session.id);
|
|
38
|
+
|
|
39
|
+
const poolSize = await poolSizeFor(session.server(), atOnce);
|
|
40
|
+
const from = Date.now();
|
|
41
|
+
|
|
42
|
+
await copied(url, template);
|
|
43
|
+
await session.beatOn(template);
|
|
44
|
+
|
|
45
|
+
for (const line of said(await emptied(url, template), databaseOf(url), Math.ceil((Date.now() - from) / 1000))) {
|
|
46
|
+
tell(line + '\n');
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return { template, poolSize, end };
|
|
50
|
+
} catch (error) {
|
|
51
|
+
await end();
|
|
52
|
+
|
|
53
|
+
throw error;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function toErrorOutput(line: string): void {
|
|
58
|
+
process.stderr.write(line);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** On the session of the run, or on another one when the server ended that one; what cannot be dropped now goes with a later run. */
|
|
62
|
+
async function ended(session: RunSession, url: string): Promise<void> {
|
|
63
|
+
const dropOwn = async (server: pg.Client): Promise<void> => {
|
|
64
|
+
const { rows } = await server.query<{ datname: string }>('select datname from pg_database');
|
|
65
|
+
|
|
66
|
+
for (const { datname } of rows.filter((row) => runOf(row.datname, url) === session.id)) {
|
|
67
|
+
await server.query(dropping(datname));
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
await dropOwn(session.server())
|
|
72
|
+
.catch(() => onServer(url, dropOwn))
|
|
73
|
+
.catch(() => undefined);
|
|
74
|
+
|
|
75
|
+
await session.end();
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** One line for each thing a reader may have to act on: rows that are gone, tables left as they were, names that keep nothing, a copy that took time. */
|
|
79
|
+
function said({ held, ofAnotherRole, unmatched, bytes }: Emptied, database: string, seconds: number): string[] {
|
|
80
|
+
const gone = `The run emptied ${held.length} table(s) of its copy of "${database}" that held rows (${named(held)}): a spec stores the rows it needs, and a table whose rows the application reads is listed in KEPT_TABLES of test/support/test-database-kept.ts.`;
|
|
81
|
+
const left = `It left ${ofAnotherRole.length} table(s) with their rows, which another role owns or whose schema the role of the run may not use (${named(ofAnotherRole)}).`;
|
|
82
|
+
const large = `Those rows take ${Math.round(bytes / (1024 * 1024))} MB: copying them took ${seconds} s of this run. Give the tests a database of their own, migrated and empty: create it, name it in DATABASE_URL, then npm run db:migrate.`;
|
|
83
|
+
|
|
84
|
+
return [
|
|
85
|
+
...(held.length > 0 ? [gone] : []),
|
|
86
|
+
...(ofAnotherRole.length > 0 ? [left] : []),
|
|
87
|
+
...unmatched.map(
|
|
88
|
+
(name) =>
|
|
89
|
+
`KEPT_TABLES of test/support/test-database-kept.ts lists ${name}, which is no table of "${database}" and keeps nothing: a name is written as the server stores it, in lower case unless the table was created between quotes, and a view holds no rows of its own.`,
|
|
90
|
+
),
|
|
91
|
+
...(bytes >= LARGE ? [large] : []),
|
|
92
|
+
];
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function named(tables: readonly string[]): string {
|
|
96
|
+
const others = tables.length - NAMED;
|
|
97
|
+
|
|
98
|
+
return tables.slice(0, NAMED).join(', ') + (others > 0 ? ` and ${others} more` : '');
|
|
99
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import pg from 'pg';
|
|
2
|
+
|
|
3
|
+
/** Set by the global setup of an end-to-end run, read by its files: the template of the run and the pool of each file. */
|
|
4
|
+
export const RUN_TEMPLATE = 'TEST_DATABASE_RUN';
|
|
5
|
+
export const POOL_SIZE = 'TEST_DATABASE_POOL_SIZE';
|
|
6
|
+
|
|
7
|
+
/** A database of a run is named `<database>_test_<run>_<template or random>`, the migrated one cut so that the name fits in 63 bytes. */
|
|
8
|
+
const MARKER = '_test_';
|
|
9
|
+
const KEPT_OF_THE_NAME = 38;
|
|
10
|
+
|
|
11
|
+
export const TEMPLATE = 'template';
|
|
12
|
+
/** The advisory lock a run holds as long as it lives, on the `postgres` database of the server: this number and the run. */
|
|
13
|
+
export const LIVE = 0x64646b74;
|
|
14
|
+
|
|
15
|
+
/** The advisory lock held while a database is copied, with the run, or 0 while a run copies the migrated one. */
|
|
16
|
+
const COPYING = LIVE + 1;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* What a role, a database or a server may set that ends a statement or a wait after some time
|
|
20
|
+
* (`alter role ... set statement_timeout`), for the requests of an application: the sessions of a
|
|
21
|
+
* run only copy, empty and drop its own databases and wait their turn to do so, which lasts as
|
|
22
|
+
* long as the database is large, so none applies to them. Read from the settings the server has:
|
|
23
|
+
* `transaction_timeout` came with PostgreSQL 17. These sessions open no transaction of their own:
|
|
24
|
+
* `idle_in_transaction_session_timeout` never applies. The pool of an application under test is
|
|
25
|
+
* another session, with the timeouts of its role.
|
|
26
|
+
*/
|
|
27
|
+
const NO_TIMEOUT = `select set_config(name, '0', false) from pg_settings where name in ('statement_timeout', 'lock_timeout', 'transaction_timeout')`;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* A session on a database of the server, `postgres` by default: the runs hold their locks there,
|
|
31
|
+
* and copy and drop from there, since a session on a database makes its copy refused. A run
|
|
32
|
+
* therefore cannot have `postgres` itself as its migrated database. No timeout of the role ends
|
|
33
|
+
* what the session does.
|
|
34
|
+
*/
|
|
35
|
+
export async function connectedTo(url: string, database = 'postgres'): Promise<pg.Client> {
|
|
36
|
+
if (databaseOf(url) === 'postgres') {
|
|
37
|
+
throw new Error(
|
|
38
|
+
'DATABASE_URL names the database "postgres", where the runs hold their locks and which they copy from: give the tests a database of their own (create database <name>, name it in DATABASE_URL, then npm run db:migrate).',
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const client = new pg.Client({ connectionString: urlOf(url, database), keepAlive: true });
|
|
43
|
+
|
|
44
|
+
// A client whose session the server ended emits an error: with nobody listening, it would end the runner. Its queries reject.
|
|
45
|
+
client.on('error', () => undefined);
|
|
46
|
+
await client.connect();
|
|
47
|
+
await client.query(NO_TIMEOUT);
|
|
48
|
+
|
|
49
|
+
return client;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** Runs `work` on a session of its own, ended whatever happens. */
|
|
53
|
+
export async function onServer(url: string, work: (server: pg.Client) => Promise<unknown>): Promise<void> {
|
|
54
|
+
const server = await connectedTo(url);
|
|
55
|
+
|
|
56
|
+
try {
|
|
57
|
+
await work(server);
|
|
58
|
+
} finally {
|
|
59
|
+
await server.end();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** Whether the session took, or let go, the lock `call` names. */
|
|
64
|
+
export async function locked(server: pg.Client, call: string): Promise<boolean> {
|
|
65
|
+
const { rows } = await server.query<{ held: boolean }>(`select ${call} as held`);
|
|
66
|
+
|
|
67
|
+
return rows[0]?.held === true;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** The run as the second key of a lock, a signed 32-bit integer. */
|
|
71
|
+
export function keyOf(run: string): number {
|
|
72
|
+
return Number.parseInt(run, 16) | 0;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** Runs `work` while this session holds the copying lock of `run`: two copies at once slow each other, the next one waits. */
|
|
76
|
+
export async function oneAtATime(server: pg.Client, run: string, work: () => Promise<unknown>): Promise<void> {
|
|
77
|
+
await server.query(`select pg_advisory_lock(${COPYING}, ${keyOf(run)})`);
|
|
78
|
+
|
|
79
|
+
try {
|
|
80
|
+
await work();
|
|
81
|
+
} finally {
|
|
82
|
+
await server.query(`select pg_advisory_unlock(${COPYING}, ${keyOf(run)})`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** The run a database belongs to, by its name; undefined for a database that is not one of a run on the database `url` names. */
|
|
87
|
+
export function runOf(name: string, url: string): string | undefined {
|
|
88
|
+
const rest = name.startsWith(prefixOf(url)) ? name.slice(prefixOf(url).length) : '';
|
|
89
|
+
|
|
90
|
+
return /^([0-9a-f]{8})_(?:template|[0-9a-f]{8})$/.exec(rest)?.[1];
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export function nameOf(url: string, run: string, last: string): string {
|
|
94
|
+
return prefixOf(url) + run + '_' + last;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function prefixOf(url: string): string {
|
|
98
|
+
return databaseOf(url).slice(0, KEPT_OF_THE_NAME) + MARKER;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export function databaseOf(url: string): string {
|
|
102
|
+
return decodeURIComponent(new URL(url).pathname.slice(1));
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** The same server, role and parameters, another database. */
|
|
106
|
+
export function urlOf(url: string, database: string): string {
|
|
107
|
+
const address = new URL(url);
|
|
108
|
+
|
|
109
|
+
address.pathname = '/' + encodeURIComponent(database);
|
|
110
|
+
|
|
111
|
+
return address.toString();
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export function copying(from: string, to: string): string {
|
|
115
|
+
return 'create database ' + quoted(to) + ' template ' + quoted(from);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** With `force`, whoever is still connected to it; without, only a database nobody is connected to. */
|
|
119
|
+
export function dropping(name: string, force = ' with (force)'): string {
|
|
120
|
+
return 'drop database if exists ' + quoted(name) + force;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function quoted(name: string): string {
|
|
124
|
+
return '"' + name.replaceAll('"', '""') + '"';
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** The SQLSTATE of a server that is asked for a database it does not have. */
|
|
128
|
+
export const NO_SUCH_DATABASE = '3D000';
|
|
129
|
+
|
|
130
|
+
/** Said by the run when it finds its template gone, and by a file that cannot copy it. */
|
|
131
|
+
export function lostDatabases(template: string): string {
|
|
132
|
+
return `The run lost its databases: its template "${template}" is no longer on the server. A run whose session ended for more than a minute is held dead, and a later run drops what it left; an administrator may have dropped it too. Run again.`;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/** The SQLSTATE of an error of the server, empty for any other error. */
|
|
136
|
+
export function codeOf(error: unknown): string {
|
|
137
|
+
const code: unknown = error instanceof Error ? Reflect.get(error, 'code') : undefined;
|
|
138
|
+
|
|
139
|
+
return typeof code === 'string' ? code : '';
|
|
140
|
+
}
|
|
@@ -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
|
+
}
|