declapract-typescript-ehmpathy 0.49.14 → 0.50.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/dist/.test/assets/cicd-common/declarations/declapract.declare.yml +8 -0
- package/dist/.test/assets/cicd-common/declarations/practices/cicd-common/.declapract.integration.test.ts +597 -0
- package/dist/.test/assets/cicd-common/declarations/practices/cicd-common/.test/assets/repo-with-unpinned-workflow/.github/workflows/.test.yml +19 -0
- package/dist/.test/assets/cicd-common/declarations/practices/cicd-common/.test/assets/repo-with-unpinned-workflow/.github/workflows/consumer-owned.yml +21 -0
- package/dist/.test/assets/cicd-common/declarations/practices/cicd-common/.test/assets/repo-with-unpinned-workflow/.github/workflows/review.yml +26 -0
- package/dist/.test/assets/cicd-common/declarations/practices/cicd-common/.test/assets/repo-with-unpinned-workflow/declapract.use.yml +6 -0
- package/dist/.test/assets/cicd-common/declarations/practices/cicd-common/.test/assets/repo-with-unpinned-workflow/package.json +4 -0
- package/dist/.test/assets/cicd-common/declarations/practices/cicd-common/__snapshots__/.declapract.integration.test.ts.snap +604 -0
- package/dist/.test/assets/cicd-common/declarations/practices/cicd-common/__snapshots__/declastruct-insync-grep.declapract.integration.test.ts.snap +3 -0
- package/dist/.test/assets/cicd-common/declarations/practices/cicd-common/__snapshots__/report-slow-tests.play.declapract.integration.test.ts.snap +28 -0
- package/dist/.test/assets/cicd-common/declarations/practices/cicd-common/bad-practices/has-changelog-file/changelog.md.declapract.ts +11 -0
- package/dist/.test/assets/cicd-common/declarations/practices/cicd-common/bad-practices/old-names/.github/workflows/ci-on-commit.yml.declapract.ts +3 -0
- package/dist/.test/assets/cicd-common/declarations/practices/cicd-common/bad-practices/old-names/.github/workflows/ci_on_commit.yml.declapract.ts +3 -0
- package/dist/.test/assets/cicd-common/declarations/practices/cicd-common/bad-practices/old-names/.github/workflows/pr-release-on-main.yml.declapract.ts +3 -0
- package/dist/.test/assets/cicd-common/declarations/practices/cicd-common/bad-practices/old-names/.github/workflows/test-on-commit.yml.declapract.ts +3 -0
- package/dist/.test/assets/cicd-common/declarations/practices/cicd-common/bad-practices/old-names/.github/workflows/test_on_commit.yml.declapract.ts +3 -0
- package/dist/.test/assets/cicd-common/declarations/practices/cicd-common/bad-practices/old-use-apikeys/.agent/repo=.this/role=any/skills/use.apikeys.json.declapract.ts +7 -0
- package/dist/.test/assets/cicd-common/declarations/practices/cicd-common/bad-practices/old-use-apikeys/.agent/repo=.this/role=any/skills/use.apikeys.sh.declapract.ts +7 -0
- package/dist/.test/assets/cicd-common/declarations/practices/cicd-common/best-practice/.declapract.readme.md +8 -0
- package/dist/.test/assets/cicd-common/declarations/practices/cicd-common/best-practice/.github/actions/please-release/action.yml +469 -0
- package/dist/.test/assets/cicd-common/declarations/practices/cicd-common/best-practice/.github/actions/test-shards-setup/action.yml +68 -0
- package/dist/.test/assets/cicd-common/declarations/practices/cicd-common/best-practice/.github/workflows/.declastruct.yml +218 -0
- package/dist/.test/assets/cicd-common/declarations/practices/cicd-common/best-practice/.github/workflows/.install.yml +56 -0
- package/dist/.test/assets/cicd-common/declarations/practices/cicd-common/best-practice/.github/workflows/.test.yml +434 -0
- package/dist/.test/assets/cicd-common/declarations/practices/cicd-common/best-practice/.github/workflows/.test.yml.declapract.ts +26 -0
- package/dist/.test/assets/cicd-common/declarations/practices/cicd-common/best-practice/.github/workflows/release.yml +32 -0
- package/dist/.test/assets/cicd-common/declarations/practices/cicd-common/best-practice/.github/workflows/report-slow-tests.sh +65 -0
- package/dist/.test/assets/cicd-common/declarations/practices/cicd-common/best-practice/.github/workflows/review.yml +26 -0
- package/dist/.test/assets/cicd-common/declarations/practices/cicd-common/best-practice/.github/workflows/test.yml +25 -0
- package/dist/.test/assets/cicd-common/declarations/practices/cicd-common/best-practice/.github/workflows/test.yml.declapract.ts +15 -0
- package/dist/.test/assets/cicd-common/declarations/practices/cicd-common/declastruct-insync-grep.declapract.integration.test.ts +49 -0
- package/dist/.test/assets/cicd-common/declarations/practices/cicd-common/report-slow-tests.play.declapract.integration.test.ts +161 -0
- package/dist/.test/assets/cicd-common/declarations/useCases.yml +11 -0
- package/dist/.test/assets/cicd-service/declarations/practices/persist-with-rds/.test/assets/repo-with-hand-patch/declapract.use.yml +4 -0
- package/dist/.test/assets/cicd-service/declarations/practices/persist-with-rds/.test/assets/repo-with-hand-patch/package.json +17 -0
- package/dist/.test/assets/cicd-service/declarations/practices/persist-with-rds/.test/assets/repo-with-hand-patch/patches/left-pad@1.3.0.patch +6 -0
- package/dist/.test/assets/cicd-service/declarations/practices/persist-with-rds/.test/assets/repo-with-hand-patch/patches/pg-pool@3.14.0.patch +12 -0
- package/dist/.test/assets/cicd-service/declarations/practices/persist-with-rds/__snapshots__/pg-pool-patch.declapract.integration.test.ts.snap +147 -0
- package/dist/.test/assets/cicd-service/declarations/practices/persist-with-rds/best-practice/.declapract.readme.md +29 -0
- package/dist/.test/assets/cicd-service/declarations/practices/persist-with-rds/best-practice/.gitattributes.declapract.ts +64 -0
- package/dist/.test/assets/cicd-service/declarations/practices/persist-with-rds/best-practice/package.json +5 -0
- package/dist/.test/assets/cicd-service/declarations/practices/persist-with-rds/best-practice/patches/pg-pool.patch +21 -0
- package/dist/.test/assets/cicd-service/declarations/practices/persist-with-rds/pg-pool-patch.declapract.integration.test.ts +884 -0
- package/dist/.test/assets/expo-fullusecase/declarations/practices/cicd-common/.declapract.integration.test.ts +15 -21
- package/dist/.test/assets/expo-fullusecase/declarations/practices/git/.declapract.integration.test.ts +2 -2
- package/dist/.test/assets/expo-fullusecase/declarations/practices/git/.gitattributes.declapract.integration.test.ts +34 -19
- package/dist/.test/assets/expo-fullusecase/declarations/practices/git/.test/assets/repo-with-legacy-gitattributes/declapract.use.yml +3 -3
- package/dist/.test/assets/expo-fullusecase/declarations/practices/git/__snapshots__/.gitattributes.declapract.integration.test.ts.snap +4 -4
- package/dist/.test/assets/expo-fullusecase/declarations/practices/git/best-practice/.declapract.readme.md +37 -0
- package/dist/.test/assets/expo-fullusecase/declarations/practices/git/best-practice/.gitattributes.declapract.ts +42 -63
- package/dist/.test/assets/expo-fullusecase/declarations/practices/pnpm/.test/assets/repo-stale-patch-beside-bare/declapract.use.yml +4 -0
- package/dist/.test/assets/expo-fullusecase/declarations/practices/pnpm/.test/assets/repo-stale-patch-beside-bare/package.json +15 -0
- package/dist/.test/assets/expo-fullusecase/declarations/practices/pnpm/.test/assets/repo-stale-patch-beside-bare/patches/rhachet-roles-ehmpathy.patch +6 -0
- package/dist/.test/assets/expo-fullusecase/declarations/practices/pnpm/.test/assets/repo-stale-patch-beside-bare/patches/rhachet-roles-ehmpathy@1.39.1.patch +6 -0
- package/dist/.test/assets/expo-fullusecase/declarations/practices/pnpm/.test/assets/repo-stale-patch-beside-bare/patches/type-fns@1.21.3.patch +6 -0
- package/dist/.test/assets/expo-fullusecase/declarations/practices/pnpm/.test/assets/repo-stale-patch-beside-bare/pnpm-lock.yaml +19 -0
- package/dist/.test/assets/expo-fullusecase/declarations/practices/pnpm/__snapshots__/stale-patched-dependency.declapract.integration.test.ts.snap +39 -0
- package/dist/.test/assets/expo-fullusecase/declarations/practices/pnpm/stale-patched-dependency.declapract.integration.test.ts +53 -0
- package/dist/.test/assets/expo-fullusecase/declarations/practices/rhachet/best-practice/.declapract.readme.md +8 -0
- package/dist/.test/assets/expo-fullusecase/declarations/practices/rhachet/best-practice/.gitattributes.declapract.ts +65 -0
- package/dist/.test/assets/expo-fullusecase/declarations/practices/tests-any/best-practice/.declapract.readme.md +7 -0
- package/dist/.test/assets/expo-fullusecase/declarations/practices/tests-any/best-practice/.gitattributes.declapract.ts +60 -0
- package/dist/.test/assets/expo-migration/declarations/practices/git/.declapract.integration.test.ts +2 -2
- package/dist/.test/assets/expo-migration/declarations/practices/git/.gitattributes.declapract.integration.test.ts +34 -19
- package/dist/.test/assets/expo-migration/declarations/practices/git/.test/assets/repo-with-legacy-gitattributes/declapract.use.yml +3 -3
- package/dist/.test/assets/expo-migration/declarations/practices/git/__snapshots__/.gitattributes.declapract.integration.test.ts.snap +4 -4
- package/dist/.test/assets/expo-migration/declarations/practices/git/best-practice/.declapract.readme.md +37 -0
- package/dist/.test/assets/expo-migration/declarations/practices/git/best-practice/.gitattributes.declapract.ts +42 -63
- package/dist/.test/assets/expo-migration/declarations/practices/pnpm/.test/assets/repo-stale-patch-beside-bare/declapract.use.yml +4 -0
- package/dist/.test/assets/expo-migration/declarations/practices/pnpm/.test/assets/repo-stale-patch-beside-bare/package.json +15 -0
- package/dist/.test/assets/expo-migration/declarations/practices/pnpm/.test/assets/repo-stale-patch-beside-bare/patches/rhachet-roles-ehmpathy.patch +6 -0
- package/dist/.test/assets/expo-migration/declarations/practices/pnpm/.test/assets/repo-stale-patch-beside-bare/patches/rhachet-roles-ehmpathy@1.39.1.patch +6 -0
- package/dist/.test/assets/expo-migration/declarations/practices/pnpm/.test/assets/repo-stale-patch-beside-bare/patches/type-fns@1.21.3.patch +6 -0
- package/dist/.test/assets/expo-migration/declarations/practices/pnpm/.test/assets/repo-stale-patch-beside-bare/pnpm-lock.yaml +19 -0
- package/dist/.test/assets/expo-migration/declarations/practices/pnpm/__snapshots__/stale-patched-dependency.declapract.integration.test.ts.snap +39 -0
- package/dist/.test/assets/expo-migration/declarations/practices/pnpm/stale-patched-dependency.declapract.integration.test.ts +53 -0
- package/dist/.test/assets/expo-migration/declarations/practices/rhachet/best-practice/.declapract.readme.md +8 -0
- package/dist/.test/assets/expo-migration/declarations/practices/rhachet/best-practice/.gitattributes.declapract.ts +65 -0
- package/dist/.test/assets/expo-migration/declarations/practices/tests-any/best-practice/.declapract.readme.md +7 -0
- package/dist/.test/assets/expo-migration/declarations/practices/tests-any/best-practice/.gitattributes.declapract.ts +60 -0
- package/dist/.test/assets/expo-toolchain/declarations/practices/tests-any/best-practice/.declapract.readme.md +7 -0
- package/dist/.test/assets/expo-toolchain/declarations/practices/tests-any/best-practice/.gitattributes.declapract.ts +60 -0
- package/dist/.test/assets/git/declarations/declapract.declare.yml +8 -0
- package/dist/.test/assets/git/declarations/practices/git/.declapract.integration.test.ts +1001 -0
- package/dist/.test/assets/git/declarations/practices/git/.gitattributes.declapract.integration.test.ts +120 -0
- package/dist/.test/assets/git/declarations/practices/git/.test/assets/repo-with-legacy-gitattributes/.gitattributes +6 -0
- package/dist/.test/assets/git/declarations/practices/git/.test/assets/repo-with-legacy-gitattributes/declapract.use.yml +7 -0
- package/dist/.test/assets/git/declarations/practices/git/.test/assets/repo-with-legacy-gitattributes/package.json +4 -0
- package/dist/.test/assets/git/declarations/practices/git/.test/assets/repo-with-rhachet-only/declapract.use.yml +6 -0
- package/dist/.test/assets/git/declarations/practices/git/.test/assets/repo-with-rhachet-only/package.json +4 -0
- package/dist/.test/assets/git/declarations/practices/git/.test/assets/repo-without-cache-ignores/declapract.use.yml +9 -0
- package/dist/.test/assets/git/declarations/practices/git/.test/assets/repo-without-cache-ignores/package.json +4 -0
- package/dist/.test/assets/git/declarations/practices/git/__snapshots__/.declapract.integration.test.ts.snap +55 -0
- package/dist/.test/assets/git/declarations/practices/git/__snapshots__/.gitattributes.declapract.integration.test.ts.snap +24 -0
- package/dist/.test/assets/git/declarations/practices/git/best-practice/.declapract.readme.md +60 -0
- package/dist/.test/assets/git/declarations/practices/git/best-practice/.gitattributes.declapract.ts +77 -0
- package/dist/.test/assets/git/declarations/practices/git/best-practice/.gitignore.declapract.ts +100 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-dynamodb/.declapract.integration.test.ts +181 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-dynamodb/.test/assets/demo-repo-with-dynamodb/declapract.declare.yml +4 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-dynamodb/.test/assets/demo-repo-with-dynamodb/declapract.use.yml +11 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-dynamodb/.test/assets/demo-repo-with-dynamodb/package.json +1 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-dynamodb/.test/assets/demo-repo-with-dynamodb/useCases.yml +8 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-dynamodb/__snapshots__/.declapract.integration.test.ts.snap +234 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-dynamodb/best-practice/.gitattributes.declapract.ts +56 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-dynamodb/best-practice/codegen.dynamodb.dao.ts +16 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-dynamodb/best-practice/package.json +16 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-dynamodb/best-practice/package.json.declapract.ts +3 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-dynamodb/best-practice/provision/docker/integration-test-db/docker-compose.yml +9 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/.declapract.integration.test.ts +237 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/.extensions.sql.declapract.integration.test.ts +159 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/.test/assets/demo-repo-config-schema/declapract.use.yml +20 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/.test/assets/demo-repo-config-schema/declarations/declapract.declare.yml +6 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/.test/assets/demo-repo-config-schema/package.json +4 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/.test/assets/demo-repo-on-a-prior-major/codegen.sql.dao.yml +20 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/.test/assets/demo-repo-on-a-prior-major/declapract.declare.yml +4 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/.test/assets/demo-repo-on-a-prior-major/declapract.use.yml +19 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/.test/assets/demo-repo-on-a-prior-major/package.json +4 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/.test/assets/demo-repo-on-a-prior-major/provision/docker/testdb/build-image.dockerfile +6 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/.test/assets/demo-repo-with-custom-extensions/declapract.declare.yml +4 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/.test/assets/demo-repo-with-custom-extensions/declapract.use.yml +21 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/.test/assets/demo-repo-with-custom-extensions/package.json +4 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/.test/assets/demo-repo-with-custom-extensions/provision/schema/sql/init/.extensions.sql +9 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/.test/assets/demo-repo-with-dev-config/config/dev.json +18 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/.test/assets/demo-repo-with-dev-config/declapract.declare.yml +4 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/.test/assets/demo-repo-with-dev-config/declapract.use.yml +18 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/.test/assets/demo-repo-with-dev-config/package.json +4 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/.test/assets/repo-with-hand-patch/declapract.use.yml +4 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/.test/assets/repo-with-hand-patch/package.json +17 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/.test/assets/repo-with-hand-patch/patches/left-pad@1.3.0.patch +6 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/.test/assets/repo-with-hand-patch/patches/pg-pool@3.14.0.patch +12 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/__snapshots__/.declapract.integration.test.ts.snap +45 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/__snapshots__/.extensions.sql.declapract.integration.test.ts.snap +77 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/__snapshots__/config-validates-schema.declapract.integration.test.ts.snap +500 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/__snapshots__/database-wrappers-typecheck.declapract.integration.test.ts.snap +10 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/__snapshots__/deploy-database-gerunds.declapract.integration.test.ts.snap +102 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/__snapshots__/engine-upgrade.declapract.integration.test.ts.snap +151 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/__snapshots__/pg-pool-patch.declapract.integration.test.ts.snap +147 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/__snapshots__/provision-testdb-access.declapract.integration.test.ts.snap +3 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/__snapshots__/ssm-param-names.declapract.integration.test.ts.snap +9 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/__snapshots__/testdb-preflight-failloud.declapract.integration.test.ts.snap +30 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/__snapshots__/with-connection-in-input.declapract.integration.test.ts.snap +57 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/legacy-change-id/.declapract.integration.test.ts +71 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/legacy-change-id/.declapract.readme.md +6 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/legacy-change-id/.test/assets/demo-repo-with-legacy-change-id/declapract.declare.yml +4 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/legacy-change-id/.test/assets/demo-repo-with-legacy-change-id/declapract.use.yml +19 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/legacy-change-id/.test/assets/demo-repo-with-legacy-change-id/package.json +4 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/legacy-change-id/.test/assets/demo-repo-with-legacy-change-id/provision/schema/sql/init.yml +15 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/legacy-change-id/__snapshots__/.declapract.integration.test.ts.snap +39 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/legacy-change-id/provision/schema/<star><star>/<star>.yml.declapract.ts +68 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/non-prefixed-manual-init-sqls/.declapract.readme.md +5 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/non-prefixed-manual-init-sqls/provision/schema/sql/init/database.sql.declapract.ts +3 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/non-prefixed-manual-init-sqls/provision/schema/sql/init/extensions.sql.declapract.ts +13 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/non-prefixed-manual-init-sqls/provision/schema/sql/init/schema.sql.declapract.ts +3 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/non-prefixed-manual-init-sqls/provision/schema/sql/init/user.cicd.sql.declapract.ts +3 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/non-prefixed-manual-init-sqls/provision/schema/sql/init/user.datalakedb.sql.declapract.ts +3 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/old-config-file-names/codegen.sql.yml.declapract.ts +3 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/old-dev-config-location/config/dev.json.declapract.ts +23 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/old-get-database-connection/.declapract.integration.test.ts +221 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/old-get-database-connection/.declapract.readme.md +11 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/old-get-database-connection/.test/assets/demo-repo-with-old-get-database-connection/declapract.declare.yml +4 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/old-get-database-connection/.test/assets/demo-repo-with-old-get-database-connection/declapract.use.yml +19 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/old-get-database-connection/.test/assets/demo-repo-with-old-get-database-connection/package.json +4 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/old-get-database-connection/.test/assets/demo-repo-with-old-get-database-connection/src/access/daos/daoSurfer.ts +15 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/old-get-database-connection/.test/assets/demo-repo-with-old-get-database-connection/src/domain.operations/getSurfLesson.ts +14 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/old-get-database-connection/.test/assets/demo-repo-with-old-get-database-connection/src/utils/database/getDatabaseConnection.integration.test.ts +10 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/old-get-database-connection/.test/assets/demo-repo-with-old-get-database-connection/src/utils/database/getDatabaseConnection.ts +68 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/old-get-database-connection/.test/assets/old-templates/getDatabaseConnection.3a193e5.ts +65 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/old-get-database-connection/.test/assets/old-templates/getDatabaseConnection.66284e3.ts +30 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/old-get-database-connection/.test/assets/old-templates/getDatabaseConnection.68cf8ba.ts +90 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/old-get-database-connection/.test/assets/old-templates/getDatabaseConnection.9e1bdc4.ts +65 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/old-get-database-connection/.test/assets/old-templates/getDatabaseConnection.c6cef7e.ts +68 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/old-get-database-connection/.test/assets/old-templates/getDatabaseConnection.c8eb35b.ts +90 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/old-get-database-connection/.test/assets/old-templates/getDatabaseConnection.d1e8cd7.ts +31 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/old-get-database-connection/.test/assets/old-templates/getDatabaseConnection.e0c53d8.ts +90 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/old-get-database-connection/.test/assets/old-templates/getDatabaseConnection.eab15c0.ts +89 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/old-get-database-connection/.test/assets/old-templates/getDatabaseConnection.ef25ae0.ts +32 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/old-get-database-connection/.test/assets/old-templates/getDatabaseConnection.integration.test.66284e3.ts +10 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/old-get-database-connection/__snapshots__/.declapract.integration.test.ts.snap +75 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/old-get-database-connection/src/<star><star>/<star>.ts.declapract.ts +33 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/old-get-database-connection/src/utils/database/getDatabaseConnection.integration.test.ts.declapract.ts +43 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/old-get-database-connection/src/utils/database/getDatabaseConnection.ts.declapract.ts +51 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/old-integration-test-db-dir/.declapract.readme.md +1 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/old-integration-test-db-dir/provision/docker/integration_test_db/<star><star>/<star>.declapract.ts +15 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/old-integration-test-db-hyphen-dir/.declapract.readme.md +1 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/old-integration-test-db-hyphen-dir/provision/docker/integration-test-db/<star><star>/<star>.declapract.ts +15 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/old-integration-test-db-paths/.declapract.readme.md +1 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/old-integration-test-db-paths/package.json +8 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/old-integration-test-db-paths/package.json.declapract.ts +10 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/old-packagejson-script-names/package.json +9 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/old-packagejson-script-names/package.json.declapract.ts +22 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/old-param-placeholder/config/<star>.json.declapract.ts +14 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/pg-client-without-ssl/.declapract.integration.test.ts +86 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/pg-client-without-ssl/.declapract.readme.md +9 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/pg-client-without-ssl/.test/assets/demo-repo-with-plaintext-pg-client/declapract.declare.yml +4 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/pg-client-without-ssl/.test/assets/demo-repo-with-plaintext-pg-client/declapract.use.yml +19 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/pg-client-without-ssl/.test/assets/demo-repo-with-plaintext-pg-client/package.json +4 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/pg-client-without-ssl/.test/assets/demo-repo-with-plaintext-pg-client/src/access/sdks/sdkWaveArchive.ts +7 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/pg-client-without-ssl/.test/assets/demo-repo-with-plaintext-pg-client/src/utils/database/getSurfReportConnection.ts +19 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/pg-client-without-ssl/__snapshots__/.declapract.integration.test.ts.snap +72 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/pg-client-without-ssl/src/<star><star>/<star>.ts.declapract.ts +32 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/schema-entities-dir/.declapract.readme.md +1 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/schema-entities-dir/provision/schema/entities/<star>.ts.declapract.ts +12 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/schema-entities-dir/provision/schema/sql/entities.yml.declapract.ts +13 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/terraform-parameters/.declapract.integration.test.ts +95 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/terraform-parameters/.test/assets/demo-repo-with-terraform-ssm/declapract.declare.yml +4 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/terraform-parameters/.test/assets/demo-repo-with-terraform-ssm/declapract.use.yml +18 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/terraform-parameters/.test/assets/demo-repo-with-terraform-ssm/package.json +4 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/terraform-parameters/.test/assets/demo-repo-with-terraform-ssm/provision/aws/product/parameter-store.tf +32 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/terraform-parameters/__snapshots__/.declapract.integration.test.ts.snap +60 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/terraform-parameters/provision/aws/product/parameter-store.tf.declapract.ts +94 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/with-connection-in-input/.declapract.readme.md +10 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/with-connection-in-input/.test/assets/demo-repo-with-connection-in-input/declapract.use.yml +2 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/with-connection-in-input/.test/assets/demo-repo-with-connection-in-input/package.json +4 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/with-connection-in-input/.test/assets/demo-repo-with-connection-in-input/src/domain.operations/findSurferById.ts +9 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/with-connection-in-input/.test/assets/demo-repo-with-connection-in-input/src/utils/database/withDatabaseConnection.ts +10 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/with-connection-in-input/src/<star><star>/<star>.ts.declapract.ts +55 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/.declapract.readme.md +114 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/.gitattributes.declapract.ts +64 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/codegen.sql.dao.yml +18 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/codegen.sql.dao.yml.declapract.ts +35 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/codegen.sql.schema.yml +6 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/codegen.sql.types.yml +16 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/config/prep.json +40 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/config/prep.json.declapract.ts +11 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/config/prod.json +40 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/config/prod.json.declapract.ts +11 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/config/test.json +37 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/config/test.json.declapract.ts +11 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/package.json +36 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/package.json.declapract.ts +3 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/patches/pg-pool.patch +21 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/provision/aws/readme.md +113 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/provision/aws/resources.parameters.ts +60 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/provision/aws/resources.ts +30 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/provision/docker/testdb/build-image.dockerfile +7 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/provision/docker/testdb/build-image.dockerfile.declapract.ts +37 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/provision/docker/testdb/check-engine-skew.integration.test.ts +115 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/provision/docker/testdb/check-engine-skew.sh +165 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/provision/docker/testdb/compose.sh +43 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/provision/docker/testdb/docker-compose.yml +19 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/provision/docker/testdb/init/.gitignore +3 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/provision/docker/testdb/init/readme.md +3 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/provision/docker/testdb/wait-for-postgres.sh +25 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/provision/schema/connection.config.js +36 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/provision/schema/control.yml +7 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/provision/schema/deploy.database.sh +97 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/provision/schema/sql/init/.database.sql +10 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/provision/schema/sql/init/.extensions.sql +16 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/provision/schema/sql/init/.extensions.sql.declapract.ts +46 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/provision/schema/sql/init/.schema.sql +11 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/provision/schema/sql/init/.user.cicd.sql +14 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/provision/schema/sql/init/.user.datalakedb.sql +12 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/provision/schema/sql/init/default_transaction_isolation.sql +6 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/provision/schema/sql/init/user.service.sql +16 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/provision/schema/sql/init.yml +9 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/provision/schema/sql/init.yml.declapract.ts +3 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/src/.test/assets/database/getTestdbIdentity.ts +52 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/src/.test/assets/database/getTestdbPort.ts +17 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/src/utils/config/config.schema.ts +77 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/src/utils/database/asDatabaseClientSsl.test.ts +82 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/src/utils/database/asDatabaseClientSsl.ts +52 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/src/utils/database/databaseClientTimeouts.ts +14 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/src/utils/database/getOneDatabaseConnection.integration.test.ts +10 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/src/utils/database/getOneDatabaseConnection.ts +119 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/src/utils/database/getOneDatabasePort.ts +30 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/src/utils/database/rdsCaBundleUsEast1.test.ts +51 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/src/utils/database/rdsCaBundleUsEast1.ts +86 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/src/utils/database/withDatabaseContext.ts +54 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/src/utils/database/withDatabaseTransaction.ts +35 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/config-validates-schema.declapract.integration.test.ts +332 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/database-client.declapract.integration.test.ts +291 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/database-wrappers-typecheck.declapract.integration.test.ts +225 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/deploy-database-gerunds.declapract.integration.test.ts +57 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/empty-template-declares-zero-clusters.declapract.integration.test.ts +71 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/engine-upgrade.declapract.integration.test.ts +243 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/pg-pool-patch.declapract.integration.test.ts +884 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/provision-testdb-access.declapract.integration.test.ts +50 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/ssm-param-names.declapract.integration.test.ts +154 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/testdb-per-worktree.declapract.integration.test.ts +332 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/testdb-preflight-failloud.declapract.integration.test.ts +83 -0
- package/dist/.test/assets/git/declarations/practices/persist-with-rds/with-connection-in-input.declapract.integration.test.ts +97 -0
- package/dist/.test/assets/git/declarations/practices/rhachet/.declapract.integration.test.ts +98 -0
- package/dist/.test/assets/git/declarations/practices/rhachet/.test/assets/demo-repo-with-consumer-boot/.agent/repo=.this/role=any/boot.yml +9 -0
- package/dist/.test/assets/git/declarations/practices/rhachet/.test/assets/demo-repo-with-consumer-boot/declapract.declare.yml +4 -0
- package/dist/.test/assets/git/declarations/practices/rhachet/.test/assets/demo-repo-with-consumer-boot/declapract.use.yml +2 -0
- package/dist/.test/assets/git/declarations/practices/rhachet/.test/assets/demo-repo-with-consumer-boot/package.json +4 -0
- package/dist/.test/assets/git/declarations/practices/rhachet/.test/assets/repo-keyrack-extant/.agent/keyrack.yml +9 -0
- package/dist/.test/assets/git/declarations/practices/rhachet/.test/assets/repo-keyrack-extant/declapract.use.node.yml +4 -0
- package/dist/.test/assets/git/declarations/practices/rhachet/.test/assets/repo-keyrack-extant/declapract.use.yml +4 -0
- package/dist/.test/assets/git/declarations/practices/rhachet/.test/assets/repo-keyrack-extant/package.json +4 -0
- package/dist/.test/assets/git/declarations/practices/rhachet/.test/assets/repo-self-linked/declapract.use.yml +4 -0
- package/dist/.test/assets/git/declarations/practices/rhachet/.test/assets/repo-self-linked/package.json +22 -0
- package/dist/.test/assets/git/declarations/practices/rhachet/__snapshots__/.declapract.integration.test.ts.snap +46 -0
- package/dist/.test/assets/git/declarations/practices/rhachet/__snapshots__/boot-refs-glossary.declapract.integration.test.ts.snap +6 -0
- package/dist/.test/assets/git/declarations/practices/rhachet/__snapshots__/boot-yml-findsert.declapract.integration.test.ts.snap +33 -0
- package/dist/.test/assets/git/declarations/practices/rhachet/__snapshots__/keyrack-yml-findsert.declapract.integration.test.ts.snap +28 -0
- package/dist/.test/assets/git/declarations/practices/rhachet/__snapshots__/self-link-build-order.declapract.integration.test.ts.snap +81 -0
- package/dist/.test/assets/git/declarations/practices/rhachet/bad-practices/deprecated-use-file/.declapract.readme.md +11 -0
- package/dist/.test/assets/git/declarations/practices/rhachet/bad-practices/deprecated-use-file/rhachet.use.ts.declapract.ts +12 -0
- package/dist/.test/assets/git/declarations/practices/rhachet/bad-practices/prod-deps/.declapract.readme.md +59 -0
- package/dist/.test/assets/git/declarations/practices/rhachet/bad-practices/prod-deps/.test/assets/demo-repo-with-rhachet-prod-deps/declapract.declare.yml +4 -0
- package/dist/.test/assets/git/declarations/practices/rhachet/bad-practices/prod-deps/.test/assets/demo-repo-with-rhachet-prod-deps/declapract.use.yml +2 -0
- package/dist/.test/assets/git/declarations/practices/rhachet/bad-practices/prod-deps/.test/assets/demo-repo-with-rhachet-prod-deps/package.json +12 -0
- package/dist/.test/assets/git/declarations/practices/rhachet/bad-practices/prod-deps/package.json +5 -0
- package/dist/.test/assets/git/declarations/practices/rhachet/bad-practices/prod-deps/package.json.declapract.ts +88 -0
- package/dist/.test/assets/git/declarations/practices/rhachet/bad-practices/review-peer-artifacts/.behavior/<star><star>/.reviews/<star><star>/<star>peer-review<star>.md.declapract.ts +16 -0
- package/dist/.test/assets/git/declarations/practices/rhachet/bad-practices/review-peer-artifacts/.behavior/<star><star>/.reviews/peer/<star><star>/<star>.md.declapract.ts +16 -0
- package/dist/.test/assets/git/declarations/practices/rhachet/bad-practices/review-peer-artifacts/.declapract.readme.md +12 -0
- package/dist/.test/assets/git/declarations/practices/rhachet/best-practice/.agent/keyrack.yml.declapract.ts +143 -0
- package/dist/.test/assets/git/declarations/practices/rhachet/best-practice/.agent/repo=.this/role=any/boot.yml +22 -0
- package/dist/.test/assets/git/declarations/practices/rhachet/best-practice/.agent/repo=.this/role=any/boot.yml.declapract.ts +189 -0
- package/dist/.test/assets/git/declarations/practices/rhachet/best-practice/.declapract.readme.md +40 -0
- package/dist/.test/assets/git/declarations/practices/rhachet/best-practice/.gitattributes.declapract.ts +65 -0
- package/dist/.test/assets/git/declarations/practices/rhachet/best-practice/.gitignore.declapract.ts +94 -0
- package/dist/.test/assets/git/declarations/practices/rhachet/best-practice/package.json +19 -0
- package/dist/.test/assets/git/declarations/practices/rhachet/best-practice/package.json.declapract.ts +51 -0
- package/dist/.test/assets/git/declarations/practices/rhachet/boot-refs-glossary.declapract.integration.test.ts +91 -0
- package/dist/.test/assets/git/declarations/practices/rhachet/boot-yml-findsert.declapract.integration.test.ts +149 -0
- package/dist/.test/assets/git/declarations/practices/rhachet/keyrack-yml-findsert.declapract.integration.test.ts +105 -0
- package/dist/.test/assets/git/declarations/practices/rhachet/self-link-build-order.declapract.integration.test.ts +88 -0
- package/dist/.test/assets/git/declarations/practices/tests-any/.test/assets/repo-old-acceptance-utils/blackbox/lambdas/consumeSESEmailEventFromSNS.acceptance.test.ts +23 -0
- package/dist/.test/assets/git/declarations/practices/tests-any/.test/assets/repo-old-acceptance-utils/declapract.use.yml +9 -0
- package/dist/.test/assets/git/declarations/practices/tests-any/.test/assets/repo-old-acceptance-utils/package.json +4 -0
- package/dist/.test/assets/git/declarations/practices/tests-any/.test/assets/repo-old-acceptance-utils-2/blackbox/lambdas/addDecoratedImage.acceptance.test.ts +19 -0
- package/dist/.test/assets/git/declarations/practices/tests-any/.test/assets/repo-old-acceptance-utils-2/declapract.use.yml +9 -0
- package/dist/.test/assets/git/declarations/practices/tests-any/.test/assets/repo-old-acceptance-utils-2/package.json +4 -0
- package/dist/.test/assets/git/declarations/practices/tests-any/.test/assets/repo-old-acceptance-utils-3/blackbox/lambdas/addDecoratedImage.acceptance.test.ts +19 -0
- package/dist/.test/assets/git/declarations/practices/tests-any/.test/assets/repo-old-acceptance-utils-3/declapract.use.yml +9 -0
- package/dist/.test/assets/git/declarations/practices/tests-any/.test/assets/repo-old-acceptance-utils-3/package.json +4 -0
- package/dist/.test/assets/git/declarations/practices/tests-any/__snapshots__/changedsince-origin-main.declapract.integration.test.ts.snap +8 -0
- package/dist/.test/assets/git/declarations/practices/tests-any/__snapshots__/livedb-wake-branches.declapract.integration.test.ts.snap +6 -0
- package/dist/.test/assets/git/declarations/practices/tests-any/__snapshots__/old-acceptance-test-utils.declapract.integration.test.ts.snap +162 -0
- package/dist/.test/assets/git/declarations/practices/tests-any/__snapshots__/test-kind-seam.declapract.integration.test.ts.snap +9 -0
- package/dist/.test/assets/git/declarations/practices/tests-any/autoprune-hooks.declapract.integration.test.ts +111 -0
- package/dist/.test/assets/git/declarations/practices/tests-any/bad-practices/dev-tool-in-dependencies/.declapract.integration.test.ts +69 -0
- package/dist/.test/assets/git/declarations/practices/tests-any/bad-practices/dev-tool-in-dependencies/.declapract.readme.md +19 -0
- package/dist/.test/assets/git/declarations/practices/tests-any/bad-practices/dev-tool-in-dependencies/.test/assets/demo-repo-with-stale-test-fns-dep/declapract.use.yml +3 -0
- package/dist/.test/assets/git/declarations/practices/tests-any/bad-practices/dev-tool-in-dependencies/.test/assets/demo-repo-with-stale-test-fns-dep/package.json +11 -0
- package/dist/.test/assets/git/declarations/practices/tests-any/bad-practices/dev-tool-in-dependencies/__snapshots__/.declapract.integration.test.ts.snap +43 -0
- package/dist/.test/assets/git/declarations/practices/tests-any/bad-practices/dev-tool-in-dependencies/package.json.declapract.ts +81 -0
- package/dist/.test/assets/git/declarations/practices/tests-any/bad-practices/javascript-config-files/.declapract.readme.md +1 -0
- package/dist/.test/assets/git/declarations/practices/tests-any/bad-practices/javascript-config-files/jest.<star>.js.declapract.ts +17 -0
- package/dist/.test/assets/git/declarations/practices/tests-any/bad-practices/mocks/.declapract.readme.md +8 -0
- package/dist/.test/assets/git/declarations/practices/tests-any/bad-practices/mocks/<star><star>/__mock__/<star>.js +3 -0
- package/dist/.test/assets/git/declarations/practices/tests-any/bad-practices/mocks/<star><star>/__mock__/<star>.ts +3 -0
- package/dist/.test/assets/git/declarations/practices/tests-any/bad-practices/old-acceptance-dir-location/.declapract.integration.test.ts +83 -0
- package/dist/.test/assets/git/declarations/practices/tests-any/bad-practices/old-acceptance-dir-location/.declapract.readme.md +22 -0
- package/dist/.test/assets/git/declarations/practices/tests-any/bad-practices/old-acceptance-dir-location/.test/assets/demo-repo-with-accept-blackbox-dir/accept.blackbox/.test/assets/.agent/config.yml +1 -0
- package/dist/.test/assets/git/declarations/practices/tests-any/bad-practices/old-acceptance-dir-location/.test/assets/demo-repo-with-accept-blackbox-dir/accept.blackbox/.test/assets/.rhachet/manifest.json +1 -0
- package/dist/.test/assets/git/declarations/practices/tests-any/bad-practices/old-acceptance-dir-location/.test/assets/demo-repo-with-accept-blackbox-dir/accept.blackbox/somefile.ts +1 -0
- package/dist/.test/assets/git/declarations/practices/tests-any/bad-practices/old-acceptance-dir-location/.test/assets/demo-repo-with-accept-blackbox-dir/declapract.use.yml +6 -0
- package/dist/.test/assets/git/declarations/practices/tests-any/bad-practices/old-acceptance-dir-location/.test/assets/demo-repo-with-accept-blackbox-dir/package.json +4 -0
- package/dist/.test/assets/git/declarations/practices/tests-any/bad-practices/old-acceptance-dir-location/accept.blackbox/<star><star>/<star>.declapract.ts +19 -0
- package/dist/.test/assets/git/declarations/practices/tests-any/bad-practices/old-acceptance-dir-location/acceptance/<star><star>/<star>.declapract.ts +19 -0
- package/dist/.test/assets/git/declarations/practices/tests-any/bad-practices/old-acceptance-import-paths/.declapract.readme.md +31 -0
- package/dist/.test/assets/git/declarations/practices/tests-any/bad-practices/old-acceptance-import-paths/<star><star>/<star>.ts.declapract.ts +25 -0
- package/dist/.test/assets/git/declarations/practices/tests-any/bad-practices/old-acceptance-test-utils/blackbox/_utils/getDataFromLastOpenBracketAtStartOfLine.ts.declapract.ts +3 -0
- package/dist/.test/assets/git/declarations/practices/tests-any/bad-practices/old-acceptance-test-utils/blackbox/_utils/invokeLambda.ts.declapract.ts +3 -0
- package/dist/.test/assets/git/declarations/practices/tests-any/bad-practices/old-acceptance-test-utils/blackbox/lambdas/<star>.ts.declapract.ts +49 -0
- package/dist/.test/assets/git/declarations/practices/tests-any/bad-practices/old-acceptance-test-utils-2/blackbox/lambdas/<star>.ts.declapract.ts +27 -0
- package/dist/.test/assets/git/declarations/practices/tests-any/bad-practices/old-acceptance-test-utils-3/blackbox/_utils/environment.ts.declapract.ts +3 -0
- package/dist/.test/assets/git/declarations/practices/tests-any/bad-practices/old-acceptance-test-utils-3/blackbox/lambdas/<star>.ts.declapract.ts +23 -0
- package/dist/.test/assets/git/declarations/practices/tests-any/bad-practices/old-extension-pattern/.declapract.readme.md +3 -0
- package/dist/.test/assets/git/declarations/practices/tests-any/bad-practices/old-extension-pattern/<star><star>/<star>.test.acceptance.ts.declapract.ts +11 -0
- package/dist/.test/assets/git/declarations/practices/tests-any/bad-practices/old-extension-pattern/<star><star>/<star>.test.integration.ts.declapract.ts +11 -0
- package/dist/.test/assets/git/declarations/practices/tests-any/bad-practices/old-test-utils-and-assets-location/.declapract.readme.md +8 -0
- package/dist/.test/assets/git/declarations/practices/tests-any/bad-practices/old-test-utils-and-assets-location/<star><star>/<star>.ts.declapract.ts +27 -0
- package/dist/.test/assets/git/declarations/practices/tests-any/bad-practices/old-test-utils-and-assets-location/<star><star>/__test_assets__/<star><star>/<star>.declapract.ts +17 -0
- package/dist/.test/assets/git/declarations/practices/tests-any/bad-practices/old-test-utils-and-assets-location/<star><star>/__test_utils__/<star><star>/<star>.declapract.ts +17 -0
- package/dist/.test/assets/git/declarations/practices/tests-any/best-practice/.declapract.readme.md +52 -0
- package/dist/.test/assets/git/declarations/practices/tests-any/best-practice/.declapract.todo.md +3 -0
- package/dist/.test/assets/git/declarations/practices/tests-any/best-practice/.gitattributes.declapract.ts +60 -0
- package/dist/.test/assets/git/declarations/practices/tests-any/best-practice/package.json +18 -0
- package/dist/.test/assets/git/declarations/practices/tests-any/best-practice/package.json.declapract.ts +3 -0
- package/dist/.test/assets/git/declarations/practices/tests-any/best-practice/src/.test/useWakeOfLivedb.ts +209 -0
- package/dist/.test/assets/git/declarations/practices/tests-any/best-practice/src/<star><star>/<star>.integration.test.ts.declapract.ts +8 -0
- package/dist/.test/assets/git/declarations/practices/tests-any/best-practice/src/<star><star>/<star>.test.ts.declapract.ts +7 -0
- package/dist/.test/assets/git/declarations/practices/tests-any/build-ifstale.declapract.integration.test.ts +124 -0
- package/dist/.test/assets/git/declarations/practices/tests-any/changedsince-origin-main.declapract.integration.test.ts +58 -0
- package/dist/.test/assets/git/declarations/practices/tests-any/livedb-wake-branches.declapract.integration.test.ts +315 -0
- package/dist/.test/assets/git/declarations/practices/tests-any/old-acceptance-test-utils.declapract.integration.test.ts +122 -0
- package/dist/.test/assets/git/declarations/practices/tests-any/package.json.shell-flags.declapract.integration.test.ts +139 -0
- package/dist/.test/assets/git/declarations/practices/tests-any/test-kind-seam.declapract.integration.test.ts +87 -0
- package/dist/.test/assets/git/declarations/useCases.yml +29 -0
- package/dist/.test/assets/{expo-fullusecase/declarations/practices/git/best-practice → git/repo-with-all-gitattributes-declarers}/.gitattributes +3 -0
- package/dist/.test/assets/git/repo-with-all-gitattributes-declarers/declapract.use.yml +26 -0
- package/dist/.test/assets/git/repo-with-all-gitattributes-declarers/package.json +4 -0
- package/dist/.test/assets/pnpm/declarations/practices/pnpm/.test/assets/repo-stale-patch-beside-bare/declapract.use.yml +4 -0
- package/dist/.test/assets/pnpm/declarations/practices/pnpm/.test/assets/repo-stale-patch-beside-bare/package.json +15 -0
- package/dist/.test/assets/pnpm/declarations/practices/pnpm/.test/assets/repo-stale-patch-beside-bare/patches/rhachet-roles-ehmpathy.patch +6 -0
- package/dist/.test/assets/pnpm/declarations/practices/pnpm/.test/assets/repo-stale-patch-beside-bare/patches/rhachet-roles-ehmpathy@1.39.1.patch +6 -0
- package/dist/.test/assets/pnpm/declarations/practices/pnpm/.test/assets/repo-stale-patch-beside-bare/patches/type-fns@1.21.3.patch +6 -0
- package/dist/.test/assets/pnpm/declarations/practices/pnpm/.test/assets/repo-stale-patch-beside-bare/pnpm-lock.yaml +19 -0
- package/dist/.test/assets/pnpm/declarations/practices/pnpm/__snapshots__/stale-patched-dependency.declapract.integration.test.ts.snap +39 -0
- package/dist/.test/assets/pnpm/declarations/practices/pnpm/stale-patched-dependency.declapract.integration.test.ts +53 -0
- package/dist/.test/assets/rhachet/declarations/practices/rhachet/best-practice/.declapract.readme.md +8 -0
- package/dist/.test/assets/rhachet/declarations/practices/rhachet/best-practice/.gitattributes.declapract.ts +65 -0
- package/dist/.test/assets/tests-any-only/declarations/practices/tests-any/best-practice/.declapract.readme.md +7 -0
- package/dist/.test/assets/tests-any-only/declarations/practices/tests-any/best-practice/.gitattributes.declapract.ts +60 -0
- package/dist/__snapshots__/gitattributesDeclarers.declapract.integration.test.ts.snap +79 -0
- package/dist/__snapshots__/repoSkills.declapract.acceptance.test.ts.snap +512 -0
- package/dist/__snapshots__/typecheckBestPracticeTemplates.declapract.integration.test.ts.snap +80 -0
- package/dist/gitattributesDeclarers.declapract.integration.test.ts +438 -0
- package/dist/practiceOwnerPerFile.declapract.integration.test.ts +53 -0
- package/dist/practices/cicd-common/.declapract.integration.test.ts +15 -21
- package/dist/practices/git/.declapract.integration.test.ts +2 -2
- package/dist/practices/git/.gitattributes.declapract.integration.test.ts +34 -19
- package/dist/practices/git/.test/assets/repo-with-legacy-gitattributes/declapract.use.yml +3 -3
- package/dist/practices/git/__snapshots__/.gitattributes.declapract.integration.test.ts.snap +4 -4
- package/dist/practices/git/best-practice/.declapract.readme.md +37 -0
- package/dist/practices/git/best-practice/.gitattributes.declapract.ts +42 -63
- package/dist/practices/persist-with-dynamodb/best-practice/.gitattributes.declapract.ts +56 -0
- package/dist/practices/persist-with-rds/.test/assets/repo-with-hand-patch/declapract.use.yml +4 -0
- package/dist/practices/persist-with-rds/.test/assets/repo-with-hand-patch/package.json +17 -0
- package/dist/practices/persist-with-rds/.test/assets/repo-with-hand-patch/patches/left-pad@1.3.0.patch +6 -0
- package/dist/practices/persist-with-rds/.test/assets/repo-with-hand-patch/patches/pg-pool@3.14.0.patch +12 -0
- package/dist/practices/persist-with-rds/__snapshots__/pg-pool-patch.declapract.integration.test.ts.snap +147 -0
- package/dist/practices/persist-with-rds/best-practice/.declapract.readme.md +29 -0
- package/dist/practices/persist-with-rds/best-practice/.gitattributes.declapract.ts +64 -0
- package/dist/practices/persist-with-rds/best-practice/package.json +5 -0
- package/dist/practices/persist-with-rds/best-practice/patches/pg-pool.patch +21 -0
- package/dist/practices/persist-with-rds/pg-pool-patch.declapract.integration.test.ts +884 -0
- package/dist/practices/pnpm/.test/assets/repo-stale-patch-beside-bare/declapract.use.yml +4 -0
- package/dist/practices/pnpm/.test/assets/repo-stale-patch-beside-bare/package.json +15 -0
- package/dist/practices/pnpm/.test/assets/repo-stale-patch-beside-bare/patches/rhachet-roles-ehmpathy.patch +6 -0
- package/dist/practices/pnpm/.test/assets/repo-stale-patch-beside-bare/patches/rhachet-roles-ehmpathy@1.39.1.patch +6 -0
- package/dist/practices/pnpm/.test/assets/repo-stale-patch-beside-bare/patches/type-fns@1.21.3.patch +6 -0
- package/dist/practices/pnpm/.test/assets/repo-stale-patch-beside-bare/pnpm-lock.yaml +19 -0
- package/dist/practices/pnpm/__snapshots__/stale-patched-dependency.declapract.integration.test.ts.snap +39 -0
- package/dist/practices/pnpm/stale-patched-dependency.declapract.integration.test.ts +53 -0
- package/dist/practices/rhachet/best-practice/.declapract.readme.md +8 -0
- package/dist/practices/rhachet/best-practice/.gitattributes.declapract.ts +65 -0
- package/dist/practices/tests-any/best-practice/.declapract.readme.md +7 -0
- package/dist/practices/tests-any/best-practice/.gitattributes.declapract.ts +60 -0
- package/dist/repoSkills.declapract.acceptance.test.ts +1150 -0
- package/dist/typecheckBestPracticeTemplates.declapract.integration.test.ts +181 -19
- package/dist/utils/defineExpectedGitattributesContents.ts +247 -0
- package/package.json +6 -6
- package/dist/.test/assets/expo-migration/declarations/practices/git/best-practice/.gitattributes +0 -7
- package/dist/practices/git/best-practice/.gitattributes +0 -7
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
|
|
2
|
+
|
|
3
|
+
exports[`legacy-change-id (#530) given: [case1] a repo whose schema definitions use the legacy \`id:\` key when: [t0] the input, before any fix then: init.yml holds \`id:\` on each change, and matches snapshot: init.yml — before 1`] = `
|
|
4
|
+
"- type: change
|
|
5
|
+
id: init_default_txn_isolation
|
|
6
|
+
author: declapract
|
|
7
|
+
path: ./init/default_transaction_isolation.sql
|
|
8
|
+
|
|
9
|
+
- type: change
|
|
10
|
+
id: init_service_user
|
|
11
|
+
author: declapract
|
|
12
|
+
path: ./init/user.service.sql
|
|
13
|
+
|
|
14
|
+
# a change the repo added on its own
|
|
15
|
+
- type: change
|
|
16
|
+
id: init_analyst_user
|
|
17
|
+
author: surfschool
|
|
18
|
+
path: ./init/user.analyst.sql
|
|
19
|
+
"
|
|
20
|
+
`;
|
|
21
|
+
|
|
22
|
+
exports[`legacy-change-id (#530) given: [case1] a repo whose schema definitions use the legacy \`id:\` key when: [t1] apply runs then: each change entry declares \`exid:\`, the repo extra kept, and matches snapshot: init.yml — after 1`] = `
|
|
23
|
+
"- type: change
|
|
24
|
+
exid: init_default_txn_isolation
|
|
25
|
+
author: declapract
|
|
26
|
+
path: ./init/default_transaction_isolation.sql
|
|
27
|
+
|
|
28
|
+
- type: change
|
|
29
|
+
exid: init_service_user
|
|
30
|
+
author: declapract
|
|
31
|
+
path: ./init/user.service.sql
|
|
32
|
+
|
|
33
|
+
# a change the repo added on its own
|
|
34
|
+
- type: change
|
|
35
|
+
exid: init_analyst_user
|
|
36
|
+
author: surfschool
|
|
37
|
+
path: ./init/user.analyst.sql
|
|
38
|
+
"
|
|
39
|
+
`;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { FileCheckFunction, FileFixFunction } from 'declapract';
|
|
2
|
+
import { isMap, isScalar, parseDocument, visit } from 'yaml';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* .what = the `id` key of each sql-schema-control change entry that still uses the legacy key
|
|
6
|
+
* .why = sql-schema-control@1.8.0 renamed a change's natural key from `id:` to `exid:`. the
|
|
7
|
+
* tool still reads `id:`, but nudges on every plan and apply. only the key on a
|
|
8
|
+
* `type: change` entry moves; an `id` key anywhere else in the yml is not the tool's.
|
|
9
|
+
* .note = an entry that already declares `exid` is never a target — whether it also holds an
|
|
10
|
+
* `id` (the tool rejects that pair) or not. a rename there would leave two `exid` keys.
|
|
11
|
+
*/
|
|
12
|
+
const getLegacyChangeIdKeyRanges = (input: {
|
|
13
|
+
contents: string;
|
|
14
|
+
}): { start: number; end: number }[] => {
|
|
15
|
+
const document = parseDocument(input.contents);
|
|
16
|
+
const ranges: { start: number; end: number }[] = [];
|
|
17
|
+
visit(document, {
|
|
18
|
+
Map: (_key, map) => {
|
|
19
|
+
if (!isMap(map)) return;
|
|
20
|
+
const isChange = map.get('type') === 'change';
|
|
21
|
+
if (!isChange) return;
|
|
22
|
+
if (map.has('exid')) return;
|
|
23
|
+
const pair = map.items.find(
|
|
24
|
+
(item) => isScalar(item.key) && item.key.value === 'id',
|
|
25
|
+
);
|
|
26
|
+
if (!pair || !isScalar(pair.key) || !pair.key.range) return;
|
|
27
|
+
ranges.push({ start: pair.key.range[0], end: pair.key.range[1] });
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
return ranges;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* .what = the contents with `exid` spliced over each given key range
|
|
35
|
+
* .why = a splice keeps every other byte — comments, blank lines, quotes — exactly as the repo
|
|
36
|
+
* wrote them
|
|
37
|
+
* .note = applied bottom-up, so the earlier offsets stay valid
|
|
38
|
+
*/
|
|
39
|
+
const withExidOverRanges = (input: {
|
|
40
|
+
contents: string;
|
|
41
|
+
ranges: { start: number; end: number }[];
|
|
42
|
+
}): string =>
|
|
43
|
+
[...input.ranges]
|
|
44
|
+
.sort((a, b) => b.start - a.start)
|
|
45
|
+
.reduce(
|
|
46
|
+
(text, range) =>
|
|
47
|
+
`${text.slice(0, range.start)}exid${text.slice(range.end)}`,
|
|
48
|
+
input.contents,
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
export const check: FileCheckFunction = (contents) => {
|
|
52
|
+
if (contents && getLegacyChangeIdKeyRanges({ contents }).length > 0) return; // bad practice detected
|
|
53
|
+
throw new Error(
|
|
54
|
+
'does not match bad practice: no sql-schema-control change entry uses the legacy `id:` key',
|
|
55
|
+
);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export const fix: FileFixFunction = (contents) => {
|
|
59
|
+
if (!contents) return { contents };
|
|
60
|
+
|
|
61
|
+
// splice `exid` over each legacy key
|
|
62
|
+
return {
|
|
63
|
+
contents: withExidOverRanges({
|
|
64
|
+
contents,
|
|
65
|
+
ranges: getLegacyChangeIdKeyRanges({ contents }),
|
|
66
|
+
}),
|
|
67
|
+
};
|
|
68
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
we have several files that are not automatically managed by `sql-schema-control` and must be applied manually with superuser privileges
|
|
2
|
+
|
|
3
|
+
to make the distinction between these and the files that _are_ managed by `sql-schema-control`, we've adopted the convention that the ones that need to be applied manually with `superuser` privs are prefixed with a `.`
|
|
4
|
+
|
|
5
|
+
this practice checks for the case where we didn't have the prefix - and fixes it by prefixing the files for us
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { FileCheckType, type FileFixFunction } from 'declapract';
|
|
2
|
+
|
|
3
|
+
export const check = FileCheckType.EXISTS;
|
|
4
|
+
|
|
5
|
+
// for this one, we want to move the file, not just delete it, since it may have had customizations
|
|
6
|
+
export const fix: FileFixFunction = (_, context) => {
|
|
7
|
+
return {
|
|
8
|
+
relativeFilePath: context.relativeFilePath.replace(
|
|
9
|
+
'/extensions.sql',
|
|
10
|
+
'/.extensions.sql',
|
|
11
|
+
),
|
|
12
|
+
};
|
|
13
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { FileCheckType, type FileFixFunction } from 'declapract';
|
|
2
|
+
|
|
3
|
+
import { asPrepConfigPath } from '../../../../../utils/asPrepConfigPath';
|
|
4
|
+
import { migrateDevConfigToPrep } from '../../../../../utils/migrateDevConfigToPrep';
|
|
5
|
+
|
|
6
|
+
export const check = FileCheckType.EXISTS;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* .what = move config/dev.json → config/prep.json and migrate the access tokens (dev → prep)
|
|
10
|
+
* .why = both halves are shared utils (one source for both declarers): migrateDevConfigToPrep
|
|
11
|
+
* owns the content migration, asPrepConfigPath owns the relocate. the `__CHANG3_ME__`
|
|
12
|
+
* passwords stay as they are — `deploy.database.sh` creates prep users with that
|
|
13
|
+
* password, so a flip to `$.at(aws::param)` would point the app at params that hold no
|
|
14
|
+
* value (#683).
|
|
15
|
+
*/
|
|
16
|
+
export const fix: FileFixFunction = (contents, context) => ({
|
|
17
|
+
contents: contents
|
|
18
|
+
? migrateDevConfigToPrep({ contents })
|
|
19
|
+
: (contents ?? null),
|
|
20
|
+
relativeFilePath: asPrepConfigPath({
|
|
21
|
+
relativeFilePath: context.relativeFilePath,
|
|
22
|
+
}),
|
|
23
|
+
});
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import fs from 'fs/promises';
|
|
2
|
+
import { readdirSync, readFileSync } from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
|
|
5
|
+
import type { FileCheckContext } from 'declapract';
|
|
6
|
+
import { executeApply } from 'declapract';
|
|
7
|
+
import { genTempDir, given, then, useThen, when } from 'test-fns';
|
|
8
|
+
|
|
9
|
+
import { asTemplateFingerprint } from '../../../../utils/asTemplateFingerprint';
|
|
10
|
+
import {
|
|
11
|
+
check as checkOldTest,
|
|
12
|
+
fix as fixOldTest,
|
|
13
|
+
OLD_TEST_TEMPLATE_FINGERPRINTS,
|
|
14
|
+
} from './src/utils/database/getDatabaseConnection.integration.test.ts.declapract';
|
|
15
|
+
import {
|
|
16
|
+
check as checkOldFactory,
|
|
17
|
+
fix as fixOldFactory,
|
|
18
|
+
OLD_TEMPLATE_FINGERPRINTS,
|
|
19
|
+
} from './src/utils/database/getDatabaseConnection.ts.declapract';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* .what = proof of the old-get-database-connection retirement (#659): every body the practice
|
|
23
|
+
* ever shipped at `src/utils/database/getDatabaseConnection.ts` is deleted, an edited copy
|
|
24
|
+
* is kept and flagged, and every importer is repointed onto `getOneDatabaseConnection` —
|
|
25
|
+
* first per declaration, then through the REAL declapract apply pipeline.
|
|
26
|
+
* .why = b8d4803 renamed the factory and left the old file behind, where it still reads the
|
|
27
|
+
* `database.service` config key the practice removed — tsc goes red on every adopter that
|
|
28
|
+
* carried it, and 50+ importers still name it. a delete of a file an adopter edited would
|
|
29
|
+
* drop that edit silently, so the delete keys on a template match, never on existence.
|
|
30
|
+
* .teeth = drop a fingerprint and its fixture reddens; delete on existence alone and the edited
|
|
31
|
+
* copy case reddens; rename every `getDatabaseConnection` token and the foreign-import
|
|
32
|
+
* case in `daoSurfer.ts` reddens.
|
|
33
|
+
* .note = INTEGRATION by `rule.forbid.unit.remote-boundaries`: it reads fixture files and runs an
|
|
34
|
+
* apply into a temp dir.
|
|
35
|
+
*/
|
|
36
|
+
// each apply evaluates the whole practice, and case4 runs four per pass
|
|
37
|
+
jest.setTimeout(10 * 60 * 1000);
|
|
38
|
+
|
|
39
|
+
const OLD_TEMPLATES_DIR =path.join(__dirname, '.test/assets/old-templates');
|
|
40
|
+
const context = {} as FileCheckContext; // note: these declarations read no context
|
|
41
|
+
|
|
42
|
+
const oldFactoryFixtures = readdirSync(OLD_TEMPLATES_DIR)
|
|
43
|
+
.filter((name) => /^getDatabaseConnection\.[0-9a-f]+\.ts$/.test(name))
|
|
44
|
+
.map((name) => ({
|
|
45
|
+
name,
|
|
46
|
+
source: readFileSync(path.join(OLD_TEMPLATES_DIR, name), 'utf8'),
|
|
47
|
+
}));
|
|
48
|
+
const oldTestFixture = readFileSync(
|
|
49
|
+
path.join(OLD_TEMPLATES_DIR, 'getDatabaseConnection.integration.test.66284e3.ts'),
|
|
50
|
+
'utf8',
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
describe('old-get-database-connection (#659)', () => {
|
|
54
|
+
given('[case1] each body the practice shipped at getDatabaseConnection.ts', () => {
|
|
55
|
+
then('every template revision is held as a fixture', () => {
|
|
56
|
+
expect(oldFactoryFixtures.length).toEqual(10);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
oldFactoryFixtures.forEach((fixture) =>
|
|
60
|
+
when(`[t0] ${fixture.name} is fixed`, () => {
|
|
61
|
+
then('its fingerprint is a known template', () => {
|
|
62
|
+
expect(OLD_TEMPLATE_FINGERPRINTS).toContain(
|
|
63
|
+
asTemplateFingerprint({ source: fixture.source }),
|
|
64
|
+
);
|
|
65
|
+
});
|
|
66
|
+
then('the file is deleted', () => {
|
|
67
|
+
expect(() => checkOldFactory(fixture.source, context)).not.toThrow();
|
|
68
|
+
expect(fixOldFactory(fixture.source, context)).toEqual({ contents: null });
|
|
69
|
+
});
|
|
70
|
+
}),
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
when('[t1] the newest template, reformatted (double quotes, no semicolons)', () => {
|
|
74
|
+
const newest = oldFactoryFixtures.find((fixture) =>
|
|
75
|
+
fixture.name.includes('e0c53d8'),
|
|
76
|
+
)!.source;
|
|
77
|
+
const reformatted = newest
|
|
78
|
+
.replace(/^(import .*)'([^']+)';$/gm, '$1"$2"')
|
|
79
|
+
.replace(/;$/gm, '');
|
|
80
|
+
then('format drift still reads as the template, so the file is deleted', () => {
|
|
81
|
+
expect(reformatted).not.toEqual(newest);
|
|
82
|
+
expect(fixOldFactory(reformatted, context)).toEqual({ contents: null });
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
given('[case2] a getDatabaseConnection.ts the adopter edited', () => {
|
|
88
|
+
const newest = oldFactoryFixtures.find((fixture) =>
|
|
89
|
+
fixture.name.includes('e0c53d8'),
|
|
90
|
+
)!.source;
|
|
91
|
+
const edited = newest.replace(
|
|
92
|
+
'await client.connect();',
|
|
93
|
+
"await client.connect();\n await client.query('SET statement_timeout = 5000;');",
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
when('[t0] fix runs', () => {
|
|
97
|
+
const { contents: fixed } = fixOldFactory(edited, context) as {
|
|
98
|
+
contents: string;
|
|
99
|
+
};
|
|
100
|
+
then('the file is kept, with its edit and a review pointer', () => {
|
|
101
|
+
expect(fixed).toContain("SET statement_timeout = 5000;");
|
|
102
|
+
expect(fixed.split('\n')[0]).toContain(
|
|
103
|
+
'@declapract:review: getDatabaseConnection.ts is retired',
|
|
104
|
+
);
|
|
105
|
+
});
|
|
106
|
+
then('a second fix changes zero bytes', () => {
|
|
107
|
+
expect(fixOldFactory(fixed, context)).toEqual({ contents: fixed });
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
given('[case3] the old integration test', () => {
|
|
113
|
+
when('[t0] the shipped body is fixed', () => {
|
|
114
|
+
then('its fingerprint is known, and the duplicate is deleted', () => {
|
|
115
|
+
expect(OLD_TEST_TEMPLATE_FINGERPRINTS).toContain(
|
|
116
|
+
asTemplateFingerprint({ source: oldTestFixture }),
|
|
117
|
+
);
|
|
118
|
+
expect(fixOldTest(oldTestFixture, context)).toEqual({ contents: null });
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
when('[t1] an edited copy is fixed', () => {
|
|
123
|
+
const edited = oldTestFixture.replace(
|
|
124
|
+
"it('should be able",
|
|
125
|
+
"it('should still be able",
|
|
126
|
+
);
|
|
127
|
+
const { contents: fixed } = fixOldTest(edited, context) as {
|
|
128
|
+
contents: string;
|
|
129
|
+
};
|
|
130
|
+
then('it is kept and repointed, and check no longer detects it', () => {
|
|
131
|
+
expect(fixed).toContain("from './getOneDatabaseConnection'");
|
|
132
|
+
expect(fixed).toContain('await getOneDatabaseConnection()');
|
|
133
|
+
expect(() => checkOldTest(fixed, context)).toThrow(
|
|
134
|
+
'does not match bad practice',
|
|
135
|
+
);
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
given('[case4] a repo with the old factory, its test, and two importers', () => {
|
|
141
|
+
const tempDir = genTempDir({
|
|
142
|
+
slug: 'declapract-persist-with-rds-old-get-database-connection',
|
|
143
|
+
clone:
|
|
144
|
+
'./src/practices/persist-with-rds/bad-practices/old-get-database-connection/.test/assets/demo-repo-with-old-get-database-connection',
|
|
145
|
+
symlink: [{ at: 'declarations', to: 'src' }],
|
|
146
|
+
});
|
|
147
|
+
const read = (relativePath: string) =>
|
|
148
|
+
fs.readFile(path.join(tempDir, relativePath), 'utf-8');
|
|
149
|
+
const exists = (relativePath: string): Promise<boolean> =>
|
|
150
|
+
fs
|
|
151
|
+
.access(path.join(tempDir, relativePath))
|
|
152
|
+
.then(() => true)
|
|
153
|
+
.catch((error: NodeJS.ErrnoException) => {
|
|
154
|
+
if (error.code === 'ENOENT') return false; // absent is the probe's answer
|
|
155
|
+
throw error; // any other read failure is a malfunction, never "absent"
|
|
156
|
+
});
|
|
157
|
+
const apply = (file: string) =>
|
|
158
|
+
executeApply({
|
|
159
|
+
config: path.join(tempDir, 'declapract.use.yml'),
|
|
160
|
+
practice: 'persist-with-rds',
|
|
161
|
+
file,
|
|
162
|
+
});
|
|
163
|
+
const importers = [
|
|
164
|
+
'src/domain.operations/getSurfLesson.ts',
|
|
165
|
+
'src/access/daos/daoSurfer.ts',
|
|
166
|
+
];
|
|
167
|
+
const retired = [
|
|
168
|
+
'src/utils/database/getDatabaseConnection.ts',
|
|
169
|
+
'src/utils/database/getDatabaseConnection.integration.test.ts',
|
|
170
|
+
];
|
|
171
|
+
|
|
172
|
+
when('[t0] the input, before any fix', () => {
|
|
173
|
+
then('each importer matches snapshot', async () => {
|
|
174
|
+
for (const importer of importers)
|
|
175
|
+
expect(await read(importer)).toMatchSnapshot(`${importer} — before`);
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
when('[t1] apply runs over each affected file', () => {
|
|
180
|
+
useThen('apply', async () => {
|
|
181
|
+
for (const file of [...retired, ...importers]) await apply(file);
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
then('the retired factory and its test are gone', async () => {
|
|
185
|
+
for (const file of retired) expect(await exists(file)).toEqual(false);
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
then('the operation reads getOneDatabaseConnection, and matches snapshot', async () => {
|
|
189
|
+
const after = await read('src/domain.operations/getSurfLesson.ts');
|
|
190
|
+
expect(after).toContain("from '../utils/database/getOneDatabaseConnection'");
|
|
191
|
+
expect(after).toContain('await getOneDatabaseConnection()');
|
|
192
|
+
expect(after).not.toMatch(/\bgetDatabaseConnection\b/);
|
|
193
|
+
expect(after).toMatchSnapshot('src/domain.operations/getSurfLesson.ts — after');
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
then('the dao is repointed, its foreign import untouched, and matches snapshot', async () => {
|
|
197
|
+
const after = await read('src/access/daos/daoSurfer.ts');
|
|
198
|
+
expect(after).toContain(
|
|
199
|
+
"from '@src/utils/database/getOneDatabaseConnection'",
|
|
200
|
+
);
|
|
201
|
+
expect(after).toContain(
|
|
202
|
+
"import { getDatabaseConnection as getLegacyWarehouse } from 'surf-warehouse-sdk'",
|
|
203
|
+
);
|
|
204
|
+
expect(after).toMatchSnapshot('src/access/daos/daoSurfer.ts — after');
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
when('[t2] apply runs again (idempotency)', () => {
|
|
209
|
+
const passes = useThen('a second apply', async () => {
|
|
210
|
+
const before = await Promise.all(importers.map((file) => read(file)));
|
|
211
|
+
for (const file of [...retired, ...importers]) await apply(file);
|
|
212
|
+
const after = await Promise.all(importers.map((file) => read(file)));
|
|
213
|
+
return { before, after };
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
then('the second apply changes zero bytes', () => {
|
|
217
|
+
expect(passes.after).toEqual(passes.before);
|
|
218
|
+
});
|
|
219
|
+
});
|
|
220
|
+
});
|
|
221
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
persist-with-rds renamed its connection factory from `getDatabaseConnection` to
|
|
2
|
+
`getOneDatabaseConnection`. the old file reads a config key the practice removed, so it fails tsc.
|
|
3
|
+
|
|
4
|
+
this fix:
|
|
5
|
+
- deletes `src/utils/database/getDatabaseConnection.ts` when it still matches a template the
|
|
6
|
+
practice shipped. the match ignores format, so a reformatted copy still counts
|
|
7
|
+
- keeps a copy the repo edited, and stamps a review pointer at its top
|
|
8
|
+
- deletes the old `getDatabaseConnection.integration.test.ts` on a template match. an edited copy
|
|
9
|
+
is kept and repointed
|
|
10
|
+
- repoints every importer under `src/` onto `getOneDatabaseConnection`, both the module path and
|
|
11
|
+
the factory name. a `getDatabaseConnection` imported from another module is left alone
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
declarations: './'
|
|
2
|
+
useCase: lambda-service-with-rds
|
|
3
|
+
variables:
|
|
4
|
+
organizationName: 'test-org'
|
|
5
|
+
projectName: 'test-project'
|
|
6
|
+
databaseName: 'testdb'
|
|
7
|
+
databaseClusterName: 'testdb'
|
|
8
|
+
databaseUserName:
|
|
9
|
+
cicdUser: 'testdb_cicd'
|
|
10
|
+
serviceUser: 'testdb_service'
|
|
11
|
+
databaseTunnelHost:
|
|
12
|
+
prep: 'localhost'
|
|
13
|
+
prod: 'localhost'
|
|
14
|
+
databaseClusterHost:
|
|
15
|
+
prep: 'localhost'
|
|
16
|
+
prod: 'localhost'
|
|
17
|
+
awsAccountId:
|
|
18
|
+
prep: '123456789012'
|
|
19
|
+
prod: '123456789012'
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { DatabaseConnection } from '@src/utils/database/getDatabaseConnection';
|
|
2
|
+
|
|
3
|
+
// a getDatabaseConnection from another module must never be renamed
|
|
4
|
+
import { getDatabaseConnection as getLegacyWarehouse } from 'surf-warehouse-sdk';
|
|
5
|
+
|
|
6
|
+
export const findSurferByUuid = async (
|
|
7
|
+
input: { uuid: string },
|
|
8
|
+
context: { dbConnection: DatabaseConnection },
|
|
9
|
+
) => {
|
|
10
|
+
await getLegacyWarehouse();
|
|
11
|
+
return context.dbConnection.query({
|
|
12
|
+
sql: 'select * from surfer where uuid = $1',
|
|
13
|
+
values: [input.uuid],
|
|
14
|
+
});
|
|
15
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type DatabaseConnection,
|
|
3
|
+
getDatabaseConnection,
|
|
4
|
+
} from '../utils/database/getDatabaseConnection';
|
|
5
|
+
|
|
6
|
+
export const getSurfLesson = async (input: { uuid: string }) => {
|
|
7
|
+
const dbConnection: DatabaseConnection = await getDatabaseConnection();
|
|
8
|
+
const result = await dbConnection.query({
|
|
9
|
+
sql: 'select * from surf_lesson where uuid = $1',
|
|
10
|
+
values: [input.uuid],
|
|
11
|
+
});
|
|
12
|
+
await dbConnection.end();
|
|
13
|
+
return result.rows[0] ?? null;
|
|
14
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { getDatabaseConnection } from './getDatabaseConnection';
|
|
2
|
+
|
|
3
|
+
describe('getDatabaseConnection', () => {
|
|
4
|
+
it('should be able to connect and execute a query', async () => {
|
|
5
|
+
const dbConnection = await getDatabaseConnection();
|
|
6
|
+
const result = await dbConnection.query({ sql: 'select 1' });
|
|
7
|
+
expect(result.rows.length).toEqual(1);
|
|
8
|
+
await dbConnection.end();
|
|
9
|
+
});
|
|
10
|
+
});
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import pg, { Client, QueryResult, QueryResultRow } from 'pg';
|
|
2
|
+
|
|
3
|
+
import { getConfig } from '../config/getConfig';
|
|
4
|
+
|
|
5
|
+
// https://github.com/brianc/node-postgres/pull/353#issuecomment-283709264
|
|
6
|
+
pg.types.setTypeParser(20, (value) => parseInt(value, 10)); // cast bigints to numbers; by default, pg returns bigints as strings, since max val of bigint is bigger than max safe value in js
|
|
7
|
+
pg.types.setTypeParser(1700, (value) => parseFloat(value)); // cast numerics to numbers; by default, pg returns numerics as strings
|
|
8
|
+
|
|
9
|
+
export interface DatabaseConnection {
|
|
10
|
+
query: <Row extends QueryResultRow>(args: {
|
|
11
|
+
sql: string;
|
|
12
|
+
values?: any[];
|
|
13
|
+
}) => Promise<QueryResult<Row>>;
|
|
14
|
+
end: () => Promise<void>;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export class DatabaseQueryError extends Error {
|
|
18
|
+
constructor({
|
|
19
|
+
sql,
|
|
20
|
+
values,
|
|
21
|
+
caught,
|
|
22
|
+
}: {
|
|
23
|
+
sql: string;
|
|
24
|
+
values?: any[];
|
|
25
|
+
caught: Error;
|
|
26
|
+
}) {
|
|
27
|
+
const message = `
|
|
28
|
+
caught error querying database: ${caught.message}
|
|
29
|
+
|
|
30
|
+
sql:
|
|
31
|
+
${sql.trim()}
|
|
32
|
+
|
|
33
|
+
values:
|
|
34
|
+
${JSON.stringify(values)}
|
|
35
|
+
`.trim();
|
|
36
|
+
super(message);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export const getDatabaseConnection = async (): Promise<DatabaseConnection> => {
|
|
41
|
+
const config = await getConfig();
|
|
42
|
+
const dbConfig = config.database.service;
|
|
43
|
+
const client = new Client({
|
|
44
|
+
host: dbConfig.host,
|
|
45
|
+
user: dbConfig.username,
|
|
46
|
+
password: dbConfig.password,
|
|
47
|
+
database: dbConfig.schema,
|
|
48
|
+
port: dbConfig.port,
|
|
49
|
+
});
|
|
50
|
+
await client.connect();
|
|
51
|
+
await client.query(`SET search_path TO ${dbConfig.schema}, public;`); // https://www.postgresql.org/docs/current/ddl-schemas.html#DDL-SCHEMAS-
|
|
52
|
+
const dbConnection = {
|
|
53
|
+
query: ({ sql, values }: { sql: string; values?: (string | number)[] }) =>
|
|
54
|
+
client.query(sql, values),
|
|
55
|
+
end: () => client.end(),
|
|
56
|
+
};
|
|
57
|
+
return {
|
|
58
|
+
query: (args: { sql: string; values?: any[] }) =>
|
|
59
|
+
dbConnection.query(args).catch((error) => {
|
|
60
|
+
throw new DatabaseQueryError({
|
|
61
|
+
sql: args.sql,
|
|
62
|
+
values: args.values,
|
|
63
|
+
caught: error,
|
|
64
|
+
});
|
|
65
|
+
}),
|
|
66
|
+
end: () => dbConnection.end(),
|
|
67
|
+
};
|
|
68
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import pg, { Client, QueryResult } from 'pg';
|
|
2
|
+
|
|
3
|
+
import { getConfig } from '../config/getConfig';
|
|
4
|
+
|
|
5
|
+
// https://github.com/brianc/node-postgres/pull/353#issuecomment-283709264
|
|
6
|
+
pg.types.setTypeParser(20, (value) => parseInt(value, 10)); // cast bigints to numbers; by default, pg returns bigints as strings, since max val of bigint is bigger than max safe value in js
|
|
7
|
+
pg.types.setTypeParser(1700, (value) => parseFloat(value)); // cast numerics to numbers; by default, pg returns numerics as strings
|
|
8
|
+
|
|
9
|
+
export interface DatabaseConnection {
|
|
10
|
+
query: (args: { sql: string; values?: any[] }) => Promise<QueryResult<any>>;
|
|
11
|
+
end: () => Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export class DatabaseQueryError extends Error {
|
|
15
|
+
constructor({
|
|
16
|
+
sql,
|
|
17
|
+
values,
|
|
18
|
+
caught,
|
|
19
|
+
}: {
|
|
20
|
+
sql: string;
|
|
21
|
+
values?: any[];
|
|
22
|
+
caught: Error;
|
|
23
|
+
}) {
|
|
24
|
+
const message = `
|
|
25
|
+
caught error querying database: ${caught.message}
|
|
26
|
+
|
|
27
|
+
sql:
|
|
28
|
+
${sql.trim()}
|
|
29
|
+
|
|
30
|
+
values:
|
|
31
|
+
${JSON.stringify(values)}
|
|
32
|
+
`.trim();
|
|
33
|
+
super(message);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export const getDatabaseConnection = async (): Promise<DatabaseConnection> => {
|
|
38
|
+
const config = await getConfig();
|
|
39
|
+
const dbConfig = config.database.service;
|
|
40
|
+
const client = new Client({
|
|
41
|
+
host: dbConfig.host,
|
|
42
|
+
user: dbConfig.username,
|
|
43
|
+
password: dbConfig.password,
|
|
44
|
+
database: dbConfig.schema,
|
|
45
|
+
port: dbConfig.port,
|
|
46
|
+
});
|
|
47
|
+
await client.connect();
|
|
48
|
+
await client.query(`SET search_path TO ${dbConfig.schema}, public;`); // https://www.postgresql.org/docs/current/ddl-schemas.html#DDL-SCHEMAS-
|
|
49
|
+
const dbConnection = {
|
|
50
|
+
query: ({ sql, values }: { sql: string; values?: (string | number)[] }) =>
|
|
51
|
+
client.query(sql, values),
|
|
52
|
+
end: () => client.end(),
|
|
53
|
+
};
|
|
54
|
+
return {
|
|
55
|
+
query: (args: { sql: string; values?: any[] }) =>
|
|
56
|
+
dbConnection.query(args).catch((error) => {
|
|
57
|
+
throw new DatabaseQueryError({
|
|
58
|
+
sql: args.sql,
|
|
59
|
+
values: args.values,
|
|
60
|
+
caught: error,
|
|
61
|
+
});
|
|
62
|
+
}),
|
|
63
|
+
end: () => dbConnection.end(),
|
|
64
|
+
};
|
|
65
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import pg, { Client, QueryResult } from 'pg';
|
|
2
|
+
import { getConfig } from '../config/getConfig';
|
|
3
|
+
|
|
4
|
+
// https://github.com/brianc/node-postgres/pull/353#issuecomment-283709264
|
|
5
|
+
pg.types.setTypeParser(20, (value) => parseInt(value, 10)); // cast bigints to numbers; by default, pg returns bigints as strings, since max val of bigint is bigger than max safe value in js
|
|
6
|
+
pg.types.setTypeParser(1700, (value) => parseFloat(value)); // cast numerics to numbers; by default, pg returns numerics as strings
|
|
7
|
+
|
|
8
|
+
export interface DatabaseConnection {
|
|
9
|
+
query: (args: { sql: string; values?: any[] }) => Promise<QueryResult<any>>;
|
|
10
|
+
end: () => Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const getDatabaseConnection = async (): Promise<DatabaseConnection> => {
|
|
14
|
+
const config = await getConfig();
|
|
15
|
+
const dbConfig = config.database.service;
|
|
16
|
+
const client = new Client({
|
|
17
|
+
host: dbConfig.host,
|
|
18
|
+
user: dbConfig.username,
|
|
19
|
+
password: dbConfig.password,
|
|
20
|
+
database: dbConfig.schema,
|
|
21
|
+
port: dbConfig.port,
|
|
22
|
+
});
|
|
23
|
+
await client.connect();
|
|
24
|
+
await client.query(`SET search_path TO ${dbConfig.schema}, public;`); // https://www.postgresql.org/docs/current/ddl-schemas.html#DDL-SCHEMAS-
|
|
25
|
+
const dbConnection = {
|
|
26
|
+
query: ({ sql, values }: { sql: string; values?: (string | number)[] }) => client.query(sql, values),
|
|
27
|
+
end: () => client.end(),
|
|
28
|
+
};
|
|
29
|
+
return dbConnection;
|
|
30
|
+
};
|