declapract-typescript-ehmpathy 0.49.15 → 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.
Files changed (390) hide show
  1. package/dist/.test/assets/cicd-common/declarations/declapract.declare.yml +8 -0
  2. package/dist/.test/assets/cicd-common/declarations/practices/cicd-common/.declapract.integration.test.ts +597 -0
  3. package/dist/.test/assets/cicd-common/declarations/practices/cicd-common/.test/assets/repo-with-unpinned-workflow/.github/workflows/.test.yml +19 -0
  4. package/dist/.test/assets/cicd-common/declarations/practices/cicd-common/.test/assets/repo-with-unpinned-workflow/.github/workflows/consumer-owned.yml +21 -0
  5. package/dist/.test/assets/cicd-common/declarations/practices/cicd-common/.test/assets/repo-with-unpinned-workflow/.github/workflows/review.yml +26 -0
  6. package/dist/.test/assets/cicd-common/declarations/practices/cicd-common/.test/assets/repo-with-unpinned-workflow/declapract.use.yml +6 -0
  7. package/dist/.test/assets/cicd-common/declarations/practices/cicd-common/.test/assets/repo-with-unpinned-workflow/package.json +4 -0
  8. package/dist/.test/assets/cicd-common/declarations/practices/cicd-common/__snapshots__/.declapract.integration.test.ts.snap +604 -0
  9. package/dist/.test/assets/cicd-common/declarations/practices/cicd-common/__snapshots__/declastruct-insync-grep.declapract.integration.test.ts.snap +3 -0
  10. package/dist/.test/assets/cicd-common/declarations/practices/cicd-common/__snapshots__/report-slow-tests.play.declapract.integration.test.ts.snap +28 -0
  11. package/dist/.test/assets/cicd-common/declarations/practices/cicd-common/bad-practices/has-changelog-file/changelog.md.declapract.ts +11 -0
  12. package/dist/.test/assets/cicd-common/declarations/practices/cicd-common/bad-practices/old-names/.github/workflows/ci-on-commit.yml.declapract.ts +3 -0
  13. package/dist/.test/assets/cicd-common/declarations/practices/cicd-common/bad-practices/old-names/.github/workflows/ci_on_commit.yml.declapract.ts +3 -0
  14. 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
  15. package/dist/.test/assets/cicd-common/declarations/practices/cicd-common/bad-practices/old-names/.github/workflows/test-on-commit.yml.declapract.ts +3 -0
  16. package/dist/.test/assets/cicd-common/declarations/practices/cicd-common/bad-practices/old-names/.github/workflows/test_on_commit.yml.declapract.ts +3 -0
  17. 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
  18. 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
  19. package/dist/.test/assets/cicd-common/declarations/practices/cicd-common/best-practice/.declapract.readme.md +8 -0
  20. package/dist/.test/assets/cicd-common/declarations/practices/cicd-common/best-practice/.github/actions/please-release/action.yml +469 -0
  21. package/dist/.test/assets/cicd-common/declarations/practices/cicd-common/best-practice/.github/actions/test-shards-setup/action.yml +68 -0
  22. package/dist/.test/assets/cicd-common/declarations/practices/cicd-common/best-practice/.github/workflows/.declastruct.yml +218 -0
  23. package/dist/.test/assets/cicd-common/declarations/practices/cicd-common/best-practice/.github/workflows/.install.yml +56 -0
  24. package/dist/.test/assets/cicd-common/declarations/practices/cicd-common/best-practice/.github/workflows/.test.yml +434 -0
  25. package/dist/.test/assets/cicd-common/declarations/practices/cicd-common/best-practice/.github/workflows/.test.yml.declapract.ts +26 -0
  26. package/dist/.test/assets/cicd-common/declarations/practices/cicd-common/best-practice/.github/workflows/release.yml +32 -0
  27. package/dist/.test/assets/cicd-common/declarations/practices/cicd-common/best-practice/.github/workflows/report-slow-tests.sh +65 -0
  28. package/dist/.test/assets/cicd-common/declarations/practices/cicd-common/best-practice/.github/workflows/review.yml +26 -0
  29. package/dist/.test/assets/cicd-common/declarations/practices/cicd-common/best-practice/.github/workflows/test.yml +25 -0
  30. package/dist/.test/assets/cicd-common/declarations/practices/cicd-common/best-practice/.github/workflows/test.yml.declapract.ts +15 -0
  31. package/dist/.test/assets/cicd-common/declarations/practices/cicd-common/declastruct-insync-grep.declapract.integration.test.ts +49 -0
  32. package/dist/.test/assets/cicd-common/declarations/practices/cicd-common/report-slow-tests.play.declapract.integration.test.ts +161 -0
  33. package/dist/.test/assets/cicd-common/declarations/useCases.yml +11 -0
  34. package/dist/.test/assets/cicd-service/declarations/practices/persist-with-rds/best-practice/.declapract.readme.md +7 -0
  35. package/dist/.test/assets/cicd-service/declarations/practices/persist-with-rds/best-practice/.gitattributes.declapract.ts +64 -0
  36. package/dist/.test/assets/expo-fullusecase/declarations/practices/cicd-common/.declapract.integration.test.ts +15 -21
  37. package/dist/.test/assets/expo-fullusecase/declarations/practices/git/.declapract.integration.test.ts +2 -2
  38. package/dist/.test/assets/expo-fullusecase/declarations/practices/git/.gitattributes.declapract.integration.test.ts +34 -19
  39. package/dist/.test/assets/expo-fullusecase/declarations/practices/git/.test/assets/repo-with-legacy-gitattributes/declapract.use.yml +3 -3
  40. package/dist/.test/assets/expo-fullusecase/declarations/practices/git/__snapshots__/.gitattributes.declapract.integration.test.ts.snap +4 -4
  41. package/dist/.test/assets/expo-fullusecase/declarations/practices/git/best-practice/.declapract.readme.md +37 -0
  42. package/dist/.test/assets/expo-fullusecase/declarations/practices/git/best-practice/.gitattributes.declapract.ts +42 -63
  43. package/dist/.test/assets/expo-fullusecase/declarations/practices/rhachet/best-practice/.declapract.readme.md +8 -0
  44. package/dist/.test/assets/expo-fullusecase/declarations/practices/rhachet/best-practice/.gitattributes.declapract.ts +65 -0
  45. package/dist/.test/assets/expo-fullusecase/declarations/practices/tests-any/best-practice/.declapract.readme.md +7 -0
  46. package/dist/.test/assets/expo-fullusecase/declarations/practices/tests-any/best-practice/.gitattributes.declapract.ts +60 -0
  47. package/dist/.test/assets/expo-migration/declarations/practices/git/.declapract.integration.test.ts +2 -2
  48. package/dist/.test/assets/expo-migration/declarations/practices/git/.gitattributes.declapract.integration.test.ts +34 -19
  49. package/dist/.test/assets/expo-migration/declarations/practices/git/.test/assets/repo-with-legacy-gitattributes/declapract.use.yml +3 -3
  50. package/dist/.test/assets/expo-migration/declarations/practices/git/__snapshots__/.gitattributes.declapract.integration.test.ts.snap +4 -4
  51. package/dist/.test/assets/expo-migration/declarations/practices/git/best-practice/.declapract.readme.md +37 -0
  52. package/dist/.test/assets/expo-migration/declarations/practices/git/best-practice/.gitattributes.declapract.ts +42 -63
  53. package/dist/.test/assets/expo-migration/declarations/practices/rhachet/best-practice/.declapract.readme.md +8 -0
  54. package/dist/.test/assets/expo-migration/declarations/practices/rhachet/best-practice/.gitattributes.declapract.ts +65 -0
  55. package/dist/.test/assets/expo-migration/declarations/practices/tests-any/best-practice/.declapract.readme.md +7 -0
  56. package/dist/.test/assets/expo-migration/declarations/practices/tests-any/best-practice/.gitattributes.declapract.ts +60 -0
  57. package/dist/.test/assets/expo-toolchain/declarations/practices/tests-any/best-practice/.declapract.readme.md +7 -0
  58. package/dist/.test/assets/expo-toolchain/declarations/practices/tests-any/best-practice/.gitattributes.declapract.ts +60 -0
  59. package/dist/.test/assets/git/declarations/declapract.declare.yml +8 -0
  60. package/dist/.test/assets/git/declarations/practices/git/.declapract.integration.test.ts +1001 -0
  61. package/dist/.test/assets/git/declarations/practices/git/.gitattributes.declapract.integration.test.ts +120 -0
  62. package/dist/.test/assets/git/declarations/practices/git/.test/assets/repo-with-legacy-gitattributes/.gitattributes +6 -0
  63. package/dist/.test/assets/git/declarations/practices/git/.test/assets/repo-with-legacy-gitattributes/declapract.use.yml +7 -0
  64. package/dist/.test/assets/git/declarations/practices/git/.test/assets/repo-with-legacy-gitattributes/package.json +4 -0
  65. package/dist/.test/assets/git/declarations/practices/git/.test/assets/repo-with-rhachet-only/declapract.use.yml +6 -0
  66. package/dist/.test/assets/git/declarations/practices/git/.test/assets/repo-with-rhachet-only/package.json +4 -0
  67. package/dist/.test/assets/git/declarations/practices/git/.test/assets/repo-without-cache-ignores/declapract.use.yml +9 -0
  68. package/dist/.test/assets/git/declarations/practices/git/.test/assets/repo-without-cache-ignores/package.json +4 -0
  69. package/dist/.test/assets/git/declarations/practices/git/__snapshots__/.declapract.integration.test.ts.snap +55 -0
  70. package/dist/.test/assets/git/declarations/practices/git/__snapshots__/.gitattributes.declapract.integration.test.ts.snap +24 -0
  71. package/dist/.test/assets/git/declarations/practices/git/best-practice/.declapract.readme.md +60 -0
  72. package/dist/.test/assets/git/declarations/practices/git/best-practice/.gitattributes.declapract.ts +77 -0
  73. package/dist/.test/assets/git/declarations/practices/git/best-practice/.gitignore.declapract.ts +100 -0
  74. package/dist/.test/assets/git/declarations/practices/persist-with-dynamodb/.declapract.integration.test.ts +181 -0
  75. package/dist/.test/assets/git/declarations/practices/persist-with-dynamodb/.test/assets/demo-repo-with-dynamodb/declapract.declare.yml +4 -0
  76. package/dist/.test/assets/git/declarations/practices/persist-with-dynamodb/.test/assets/demo-repo-with-dynamodb/declapract.use.yml +11 -0
  77. package/dist/.test/assets/git/declarations/practices/persist-with-dynamodb/.test/assets/demo-repo-with-dynamodb/package.json +1 -0
  78. package/dist/.test/assets/git/declarations/practices/persist-with-dynamodb/.test/assets/demo-repo-with-dynamodb/useCases.yml +8 -0
  79. package/dist/.test/assets/git/declarations/practices/persist-with-dynamodb/__snapshots__/.declapract.integration.test.ts.snap +234 -0
  80. package/dist/.test/assets/git/declarations/practices/persist-with-dynamodb/best-practice/.gitattributes.declapract.ts +56 -0
  81. package/dist/.test/assets/git/declarations/practices/persist-with-dynamodb/best-practice/codegen.dynamodb.dao.ts +16 -0
  82. package/dist/.test/assets/git/declarations/practices/persist-with-dynamodb/best-practice/package.json +16 -0
  83. package/dist/.test/assets/git/declarations/practices/persist-with-dynamodb/best-practice/package.json.declapract.ts +3 -0
  84. package/dist/.test/assets/git/declarations/practices/persist-with-dynamodb/best-practice/provision/docker/integration-test-db/docker-compose.yml +9 -0
  85. package/dist/.test/assets/git/declarations/practices/persist-with-rds/.declapract.integration.test.ts +237 -0
  86. package/dist/.test/assets/git/declarations/practices/persist-with-rds/.extensions.sql.declapract.integration.test.ts +159 -0
  87. package/dist/.test/assets/git/declarations/practices/persist-with-rds/.test/assets/demo-repo-config-schema/declapract.use.yml +20 -0
  88. package/dist/.test/assets/git/declarations/practices/persist-with-rds/.test/assets/demo-repo-config-schema/declarations/declapract.declare.yml +6 -0
  89. package/dist/.test/assets/git/declarations/practices/persist-with-rds/.test/assets/demo-repo-config-schema/package.json +4 -0
  90. package/dist/.test/assets/git/declarations/practices/persist-with-rds/.test/assets/demo-repo-on-a-prior-major/codegen.sql.dao.yml +20 -0
  91. package/dist/.test/assets/git/declarations/practices/persist-with-rds/.test/assets/demo-repo-on-a-prior-major/declapract.declare.yml +4 -0
  92. package/dist/.test/assets/git/declarations/practices/persist-with-rds/.test/assets/demo-repo-on-a-prior-major/declapract.use.yml +19 -0
  93. package/dist/.test/assets/git/declarations/practices/persist-with-rds/.test/assets/demo-repo-on-a-prior-major/package.json +4 -0
  94. 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
  95. package/dist/.test/assets/git/declarations/practices/persist-with-rds/.test/assets/demo-repo-with-custom-extensions/declapract.declare.yml +4 -0
  96. package/dist/.test/assets/git/declarations/practices/persist-with-rds/.test/assets/demo-repo-with-custom-extensions/declapract.use.yml +21 -0
  97. package/dist/.test/assets/git/declarations/practices/persist-with-rds/.test/assets/demo-repo-with-custom-extensions/package.json +4 -0
  98. 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
  99. package/dist/.test/assets/git/declarations/practices/persist-with-rds/.test/assets/demo-repo-with-dev-config/config/dev.json +18 -0
  100. package/dist/.test/assets/git/declarations/practices/persist-with-rds/.test/assets/demo-repo-with-dev-config/declapract.declare.yml +4 -0
  101. package/dist/.test/assets/git/declarations/practices/persist-with-rds/.test/assets/demo-repo-with-dev-config/declapract.use.yml +18 -0
  102. package/dist/.test/assets/git/declarations/practices/persist-with-rds/.test/assets/demo-repo-with-dev-config/package.json +4 -0
  103. package/dist/.test/assets/git/declarations/practices/persist-with-rds/.test/assets/repo-with-hand-patch/declapract.use.yml +4 -0
  104. package/dist/.test/assets/git/declarations/practices/persist-with-rds/.test/assets/repo-with-hand-patch/package.json +17 -0
  105. 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
  106. 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
  107. package/dist/.test/assets/git/declarations/practices/persist-with-rds/__snapshots__/.declapract.integration.test.ts.snap +45 -0
  108. package/dist/.test/assets/git/declarations/practices/persist-with-rds/__snapshots__/.extensions.sql.declapract.integration.test.ts.snap +77 -0
  109. package/dist/.test/assets/git/declarations/practices/persist-with-rds/__snapshots__/config-validates-schema.declapract.integration.test.ts.snap +500 -0
  110. package/dist/.test/assets/git/declarations/practices/persist-with-rds/__snapshots__/database-wrappers-typecheck.declapract.integration.test.ts.snap +10 -0
  111. package/dist/.test/assets/git/declarations/practices/persist-with-rds/__snapshots__/deploy-database-gerunds.declapract.integration.test.ts.snap +102 -0
  112. package/dist/.test/assets/git/declarations/practices/persist-with-rds/__snapshots__/engine-upgrade.declapract.integration.test.ts.snap +151 -0
  113. package/dist/.test/assets/git/declarations/practices/persist-with-rds/__snapshots__/pg-pool-patch.declapract.integration.test.ts.snap +147 -0
  114. package/dist/.test/assets/git/declarations/practices/persist-with-rds/__snapshots__/provision-testdb-access.declapract.integration.test.ts.snap +3 -0
  115. package/dist/.test/assets/git/declarations/practices/persist-with-rds/__snapshots__/ssm-param-names.declapract.integration.test.ts.snap +9 -0
  116. package/dist/.test/assets/git/declarations/practices/persist-with-rds/__snapshots__/testdb-preflight-failloud.declapract.integration.test.ts.snap +30 -0
  117. package/dist/.test/assets/git/declarations/practices/persist-with-rds/__snapshots__/with-connection-in-input.declapract.integration.test.ts.snap +57 -0
  118. package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/legacy-change-id/.declapract.integration.test.ts +71 -0
  119. package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/legacy-change-id/.declapract.readme.md +6 -0
  120. 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
  121. 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
  122. 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
  123. 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
  124. package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/legacy-change-id/__snapshots__/.declapract.integration.test.ts.snap +39 -0
  125. 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
  126. package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/non-prefixed-manual-init-sqls/.declapract.readme.md +5 -0
  127. 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
  128. 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
  129. 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
  130. 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
  131. 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
  132. package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/old-config-file-names/codegen.sql.yml.declapract.ts +3 -0
  133. package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/old-dev-config-location/config/dev.json.declapract.ts +23 -0
  134. package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/old-get-database-connection/.declapract.integration.test.ts +221 -0
  135. package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/old-get-database-connection/.declapract.readme.md +11 -0
  136. 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
  137. 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
  138. 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
  139. 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
  140. 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
  141. 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
  142. 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
  143. 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
  144. 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
  145. 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
  146. 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
  147. 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
  148. 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
  149. 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
  150. 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
  151. 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
  152. 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
  153. 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
  154. package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/old-get-database-connection/__snapshots__/.declapract.integration.test.ts.snap +75 -0
  155. 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
  156. 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
  157. 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
  158. package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/old-integration-test-db-dir/.declapract.readme.md +1 -0
  159. 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
  160. package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/old-integration-test-db-hyphen-dir/.declapract.readme.md +1 -0
  161. 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
  162. package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/old-integration-test-db-paths/.declapract.readme.md +1 -0
  163. package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/old-integration-test-db-paths/package.json +8 -0
  164. package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/old-integration-test-db-paths/package.json.declapract.ts +10 -0
  165. package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/old-packagejson-script-names/package.json +9 -0
  166. package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/old-packagejson-script-names/package.json.declapract.ts +22 -0
  167. package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/old-param-placeholder/config/<star>.json.declapract.ts +14 -0
  168. package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/pg-client-without-ssl/.declapract.integration.test.ts +86 -0
  169. package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/pg-client-without-ssl/.declapract.readme.md +9 -0
  170. 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
  171. 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
  172. 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
  173. 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
  174. 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
  175. package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/pg-client-without-ssl/__snapshots__/.declapract.integration.test.ts.snap +72 -0
  176. 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
  177. package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/schema-entities-dir/.declapract.readme.md +1 -0
  178. package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/schema-entities-dir/provision/schema/entities/<star>.ts.declapract.ts +12 -0
  179. package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/schema-entities-dir/provision/schema/sql/entities.yml.declapract.ts +13 -0
  180. package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/terraform-parameters/.declapract.integration.test.ts +95 -0
  181. 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
  182. 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
  183. 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
  184. 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
  185. package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/terraform-parameters/__snapshots__/.declapract.integration.test.ts.snap +60 -0
  186. package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/terraform-parameters/provision/aws/product/parameter-store.tf.declapract.ts +94 -0
  187. package/dist/.test/assets/git/declarations/practices/persist-with-rds/bad-practices/with-connection-in-input/.declapract.readme.md +10 -0
  188. 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
  189. 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
  190. 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
  191. 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
  192. 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
  193. package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/.declapract.readme.md +114 -0
  194. package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/.gitattributes.declapract.ts +64 -0
  195. package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/codegen.sql.dao.yml +18 -0
  196. package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/codegen.sql.dao.yml.declapract.ts +35 -0
  197. package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/codegen.sql.schema.yml +6 -0
  198. package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/codegen.sql.types.yml +16 -0
  199. package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/config/prep.json +40 -0
  200. package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/config/prep.json.declapract.ts +11 -0
  201. package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/config/prod.json +40 -0
  202. package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/config/prod.json.declapract.ts +11 -0
  203. package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/config/test.json +37 -0
  204. package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/config/test.json.declapract.ts +11 -0
  205. package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/package.json +36 -0
  206. package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/package.json.declapract.ts +3 -0
  207. package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/patches/pg-pool.patch +21 -0
  208. package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/provision/aws/readme.md +113 -0
  209. package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/provision/aws/resources.parameters.ts +60 -0
  210. package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/provision/aws/resources.ts +30 -0
  211. package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/provision/docker/testdb/build-image.dockerfile +7 -0
  212. package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/provision/docker/testdb/build-image.dockerfile.declapract.ts +37 -0
  213. package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/provision/docker/testdb/check-engine-skew.integration.test.ts +115 -0
  214. package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/provision/docker/testdb/check-engine-skew.sh +165 -0
  215. package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/provision/docker/testdb/compose.sh +43 -0
  216. package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/provision/docker/testdb/docker-compose.yml +19 -0
  217. package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/provision/docker/testdb/init/.gitignore +3 -0
  218. package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/provision/docker/testdb/init/readme.md +3 -0
  219. package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/provision/docker/testdb/wait-for-postgres.sh +25 -0
  220. package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/provision/schema/connection.config.js +36 -0
  221. package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/provision/schema/control.yml +7 -0
  222. package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/provision/schema/deploy.database.sh +97 -0
  223. package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/provision/schema/sql/init/.database.sql +10 -0
  224. package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/provision/schema/sql/init/.extensions.sql +16 -0
  225. package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/provision/schema/sql/init/.extensions.sql.declapract.ts +46 -0
  226. package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/provision/schema/sql/init/.schema.sql +11 -0
  227. package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/provision/schema/sql/init/.user.cicd.sql +14 -0
  228. package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/provision/schema/sql/init/.user.datalakedb.sql +12 -0
  229. package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/provision/schema/sql/init/default_transaction_isolation.sql +6 -0
  230. package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/provision/schema/sql/init/user.service.sql +16 -0
  231. package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/provision/schema/sql/init.yml +9 -0
  232. package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/provision/schema/sql/init.yml.declapract.ts +3 -0
  233. package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/src/.test/assets/database/getTestdbIdentity.ts +52 -0
  234. package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/src/.test/assets/database/getTestdbPort.ts +17 -0
  235. package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/src/utils/config/config.schema.ts +77 -0
  236. package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/src/utils/database/asDatabaseClientSsl.test.ts +82 -0
  237. package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/src/utils/database/asDatabaseClientSsl.ts +52 -0
  238. package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/src/utils/database/databaseClientTimeouts.ts +14 -0
  239. package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/src/utils/database/getOneDatabaseConnection.integration.test.ts +10 -0
  240. package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/src/utils/database/getOneDatabaseConnection.ts +119 -0
  241. package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/src/utils/database/getOneDatabasePort.ts +30 -0
  242. package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/src/utils/database/rdsCaBundleUsEast1.test.ts +51 -0
  243. package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/src/utils/database/rdsCaBundleUsEast1.ts +86 -0
  244. package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/src/utils/database/withDatabaseContext.ts +54 -0
  245. package/dist/.test/assets/git/declarations/practices/persist-with-rds/best-practice/src/utils/database/withDatabaseTransaction.ts +35 -0
  246. package/dist/.test/assets/git/declarations/practices/persist-with-rds/config-validates-schema.declapract.integration.test.ts +332 -0
  247. package/dist/.test/assets/git/declarations/practices/persist-with-rds/database-client.declapract.integration.test.ts +291 -0
  248. package/dist/.test/assets/git/declarations/practices/persist-with-rds/database-wrappers-typecheck.declapract.integration.test.ts +225 -0
  249. package/dist/.test/assets/git/declarations/practices/persist-with-rds/deploy-database-gerunds.declapract.integration.test.ts +57 -0
  250. package/dist/.test/assets/git/declarations/practices/persist-with-rds/empty-template-declares-zero-clusters.declapract.integration.test.ts +71 -0
  251. package/dist/.test/assets/git/declarations/practices/persist-with-rds/engine-upgrade.declapract.integration.test.ts +243 -0
  252. package/dist/.test/assets/git/declarations/practices/persist-with-rds/pg-pool-patch.declapract.integration.test.ts +884 -0
  253. package/dist/.test/assets/git/declarations/practices/persist-with-rds/provision-testdb-access.declapract.integration.test.ts +50 -0
  254. package/dist/.test/assets/git/declarations/practices/persist-with-rds/ssm-param-names.declapract.integration.test.ts +154 -0
  255. package/dist/.test/assets/git/declarations/practices/persist-with-rds/testdb-per-worktree.declapract.integration.test.ts +332 -0
  256. package/dist/.test/assets/git/declarations/practices/persist-with-rds/testdb-preflight-failloud.declapract.integration.test.ts +83 -0
  257. package/dist/.test/assets/git/declarations/practices/persist-with-rds/with-connection-in-input.declapract.integration.test.ts +97 -0
  258. package/dist/.test/assets/git/declarations/practices/rhachet/.declapract.integration.test.ts +98 -0
  259. package/dist/.test/assets/git/declarations/practices/rhachet/.test/assets/demo-repo-with-consumer-boot/.agent/repo=.this/role=any/boot.yml +9 -0
  260. package/dist/.test/assets/git/declarations/practices/rhachet/.test/assets/demo-repo-with-consumer-boot/declapract.declare.yml +4 -0
  261. package/dist/.test/assets/git/declarations/practices/rhachet/.test/assets/demo-repo-with-consumer-boot/declapract.use.yml +2 -0
  262. package/dist/.test/assets/git/declarations/practices/rhachet/.test/assets/demo-repo-with-consumer-boot/package.json +4 -0
  263. package/dist/.test/assets/git/declarations/practices/rhachet/.test/assets/repo-keyrack-extant/.agent/keyrack.yml +9 -0
  264. package/dist/.test/assets/git/declarations/practices/rhachet/.test/assets/repo-keyrack-extant/declapract.use.node.yml +4 -0
  265. package/dist/.test/assets/git/declarations/practices/rhachet/.test/assets/repo-keyrack-extant/declapract.use.yml +4 -0
  266. package/dist/.test/assets/git/declarations/practices/rhachet/.test/assets/repo-keyrack-extant/package.json +4 -0
  267. package/dist/.test/assets/git/declarations/practices/rhachet/.test/assets/repo-self-linked/declapract.use.yml +4 -0
  268. package/dist/.test/assets/git/declarations/practices/rhachet/.test/assets/repo-self-linked/package.json +22 -0
  269. package/dist/.test/assets/git/declarations/practices/rhachet/__snapshots__/.declapract.integration.test.ts.snap +46 -0
  270. package/dist/.test/assets/git/declarations/practices/rhachet/__snapshots__/boot-refs-glossary.declapract.integration.test.ts.snap +6 -0
  271. package/dist/.test/assets/git/declarations/practices/rhachet/__snapshots__/boot-yml-findsert.declapract.integration.test.ts.snap +33 -0
  272. package/dist/.test/assets/git/declarations/practices/rhachet/__snapshots__/keyrack-yml-findsert.declapract.integration.test.ts.snap +28 -0
  273. package/dist/.test/assets/git/declarations/practices/rhachet/__snapshots__/self-link-build-order.declapract.integration.test.ts.snap +81 -0
  274. package/dist/.test/assets/git/declarations/practices/rhachet/bad-practices/deprecated-use-file/.declapract.readme.md +11 -0
  275. package/dist/.test/assets/git/declarations/practices/rhachet/bad-practices/deprecated-use-file/rhachet.use.ts.declapract.ts +12 -0
  276. package/dist/.test/assets/git/declarations/practices/rhachet/bad-practices/prod-deps/.declapract.readme.md +59 -0
  277. 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
  278. 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
  279. package/dist/.test/assets/git/declarations/practices/rhachet/bad-practices/prod-deps/.test/assets/demo-repo-with-rhachet-prod-deps/package.json +12 -0
  280. package/dist/.test/assets/git/declarations/practices/rhachet/bad-practices/prod-deps/package.json +5 -0
  281. package/dist/.test/assets/git/declarations/practices/rhachet/bad-practices/prod-deps/package.json.declapract.ts +88 -0
  282. 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
  283. 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
  284. package/dist/.test/assets/git/declarations/practices/rhachet/bad-practices/review-peer-artifacts/.declapract.readme.md +12 -0
  285. package/dist/.test/assets/git/declarations/practices/rhachet/best-practice/.agent/keyrack.yml.declapract.ts +143 -0
  286. package/dist/.test/assets/git/declarations/practices/rhachet/best-practice/.agent/repo=.this/role=any/boot.yml +22 -0
  287. package/dist/.test/assets/git/declarations/practices/rhachet/best-practice/.agent/repo=.this/role=any/boot.yml.declapract.ts +189 -0
  288. package/dist/.test/assets/git/declarations/practices/rhachet/best-practice/.declapract.readme.md +40 -0
  289. package/dist/.test/assets/git/declarations/practices/rhachet/best-practice/.gitattributes.declapract.ts +65 -0
  290. package/dist/.test/assets/git/declarations/practices/rhachet/best-practice/.gitignore.declapract.ts +94 -0
  291. package/dist/.test/assets/git/declarations/practices/rhachet/best-practice/package.json +19 -0
  292. package/dist/.test/assets/git/declarations/practices/rhachet/best-practice/package.json.declapract.ts +51 -0
  293. package/dist/.test/assets/git/declarations/practices/rhachet/boot-refs-glossary.declapract.integration.test.ts +91 -0
  294. package/dist/.test/assets/git/declarations/practices/rhachet/boot-yml-findsert.declapract.integration.test.ts +149 -0
  295. package/dist/.test/assets/git/declarations/practices/rhachet/keyrack-yml-findsert.declapract.integration.test.ts +105 -0
  296. package/dist/.test/assets/git/declarations/practices/rhachet/self-link-build-order.declapract.integration.test.ts +88 -0
  297. package/dist/.test/assets/git/declarations/practices/tests-any/.test/assets/repo-old-acceptance-utils/blackbox/lambdas/consumeSESEmailEventFromSNS.acceptance.test.ts +23 -0
  298. package/dist/.test/assets/git/declarations/practices/tests-any/.test/assets/repo-old-acceptance-utils/declapract.use.yml +9 -0
  299. package/dist/.test/assets/git/declarations/practices/tests-any/.test/assets/repo-old-acceptance-utils/package.json +4 -0
  300. package/dist/.test/assets/git/declarations/practices/tests-any/.test/assets/repo-old-acceptance-utils-2/blackbox/lambdas/addDecoratedImage.acceptance.test.ts +19 -0
  301. package/dist/.test/assets/git/declarations/practices/tests-any/.test/assets/repo-old-acceptance-utils-2/declapract.use.yml +9 -0
  302. package/dist/.test/assets/git/declarations/practices/tests-any/.test/assets/repo-old-acceptance-utils-2/package.json +4 -0
  303. package/dist/.test/assets/git/declarations/practices/tests-any/.test/assets/repo-old-acceptance-utils-3/blackbox/lambdas/addDecoratedImage.acceptance.test.ts +19 -0
  304. package/dist/.test/assets/git/declarations/practices/tests-any/.test/assets/repo-old-acceptance-utils-3/declapract.use.yml +9 -0
  305. package/dist/.test/assets/git/declarations/practices/tests-any/.test/assets/repo-old-acceptance-utils-3/package.json +4 -0
  306. package/dist/.test/assets/git/declarations/practices/tests-any/__snapshots__/changedsince-origin-main.declapract.integration.test.ts.snap +8 -0
  307. package/dist/.test/assets/git/declarations/practices/tests-any/__snapshots__/livedb-wake-branches.declapract.integration.test.ts.snap +6 -0
  308. package/dist/.test/assets/git/declarations/practices/tests-any/__snapshots__/old-acceptance-test-utils.declapract.integration.test.ts.snap +162 -0
  309. package/dist/.test/assets/git/declarations/practices/tests-any/__snapshots__/test-kind-seam.declapract.integration.test.ts.snap +9 -0
  310. package/dist/.test/assets/git/declarations/practices/tests-any/autoprune-hooks.declapract.integration.test.ts +111 -0
  311. package/dist/.test/assets/git/declarations/practices/tests-any/bad-practices/dev-tool-in-dependencies/.declapract.integration.test.ts +69 -0
  312. package/dist/.test/assets/git/declarations/practices/tests-any/bad-practices/dev-tool-in-dependencies/.declapract.readme.md +19 -0
  313. 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
  314. 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
  315. package/dist/.test/assets/git/declarations/practices/tests-any/bad-practices/dev-tool-in-dependencies/__snapshots__/.declapract.integration.test.ts.snap +43 -0
  316. package/dist/.test/assets/git/declarations/practices/tests-any/bad-practices/dev-tool-in-dependencies/package.json.declapract.ts +81 -0
  317. package/dist/.test/assets/git/declarations/practices/tests-any/bad-practices/javascript-config-files/.declapract.readme.md +1 -0
  318. package/dist/.test/assets/git/declarations/practices/tests-any/bad-practices/javascript-config-files/jest.<star>.js.declapract.ts +17 -0
  319. package/dist/.test/assets/git/declarations/practices/tests-any/bad-practices/mocks/.declapract.readme.md +8 -0
  320. package/dist/.test/assets/git/declarations/practices/tests-any/bad-practices/mocks/<star><star>/__mock__/<star>.js +3 -0
  321. package/dist/.test/assets/git/declarations/practices/tests-any/bad-practices/mocks/<star><star>/__mock__/<star>.ts +3 -0
  322. package/dist/.test/assets/git/declarations/practices/tests-any/bad-practices/old-acceptance-dir-location/.declapract.integration.test.ts +83 -0
  323. package/dist/.test/assets/git/declarations/practices/tests-any/bad-practices/old-acceptance-dir-location/.declapract.readme.md +22 -0
  324. 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
  325. 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
  326. 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
  327. 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
  328. 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
  329. package/dist/.test/assets/git/declarations/practices/tests-any/bad-practices/old-acceptance-dir-location/accept.blackbox/<star><star>/<star>.declapract.ts +19 -0
  330. package/dist/.test/assets/git/declarations/practices/tests-any/bad-practices/old-acceptance-dir-location/acceptance/<star><star>/<star>.declapract.ts +19 -0
  331. package/dist/.test/assets/git/declarations/practices/tests-any/bad-practices/old-acceptance-import-paths/.declapract.readme.md +31 -0
  332. package/dist/.test/assets/git/declarations/practices/tests-any/bad-practices/old-acceptance-import-paths/<star><star>/<star>.ts.declapract.ts +25 -0
  333. package/dist/.test/assets/git/declarations/practices/tests-any/bad-practices/old-acceptance-test-utils/blackbox/_utils/getDataFromLastOpenBracketAtStartOfLine.ts.declapract.ts +3 -0
  334. package/dist/.test/assets/git/declarations/practices/tests-any/bad-practices/old-acceptance-test-utils/blackbox/_utils/invokeLambda.ts.declapract.ts +3 -0
  335. package/dist/.test/assets/git/declarations/practices/tests-any/bad-practices/old-acceptance-test-utils/blackbox/lambdas/<star>.ts.declapract.ts +49 -0
  336. package/dist/.test/assets/git/declarations/practices/tests-any/bad-practices/old-acceptance-test-utils-2/blackbox/lambdas/<star>.ts.declapract.ts +27 -0
  337. package/dist/.test/assets/git/declarations/practices/tests-any/bad-practices/old-acceptance-test-utils-3/blackbox/_utils/environment.ts.declapract.ts +3 -0
  338. package/dist/.test/assets/git/declarations/practices/tests-any/bad-practices/old-acceptance-test-utils-3/blackbox/lambdas/<star>.ts.declapract.ts +23 -0
  339. package/dist/.test/assets/git/declarations/practices/tests-any/bad-practices/old-extension-pattern/.declapract.readme.md +3 -0
  340. package/dist/.test/assets/git/declarations/practices/tests-any/bad-practices/old-extension-pattern/<star><star>/<star>.test.acceptance.ts.declapract.ts +11 -0
  341. package/dist/.test/assets/git/declarations/practices/tests-any/bad-practices/old-extension-pattern/<star><star>/<star>.test.integration.ts.declapract.ts +11 -0
  342. package/dist/.test/assets/git/declarations/practices/tests-any/bad-practices/old-test-utils-and-assets-location/.declapract.readme.md +8 -0
  343. 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
  344. 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
  345. 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
  346. package/dist/.test/assets/git/declarations/practices/tests-any/best-practice/.declapract.readme.md +52 -0
  347. package/dist/.test/assets/git/declarations/practices/tests-any/best-practice/.declapract.todo.md +3 -0
  348. package/dist/.test/assets/git/declarations/practices/tests-any/best-practice/.gitattributes.declapract.ts +60 -0
  349. package/dist/.test/assets/git/declarations/practices/tests-any/best-practice/package.json +18 -0
  350. package/dist/.test/assets/git/declarations/practices/tests-any/best-practice/package.json.declapract.ts +3 -0
  351. package/dist/.test/assets/git/declarations/practices/tests-any/best-practice/src/.test/useWakeOfLivedb.ts +209 -0
  352. package/dist/.test/assets/git/declarations/practices/tests-any/best-practice/src/<star><star>/<star>.integration.test.ts.declapract.ts +8 -0
  353. package/dist/.test/assets/git/declarations/practices/tests-any/best-practice/src/<star><star>/<star>.test.ts.declapract.ts +7 -0
  354. package/dist/.test/assets/git/declarations/practices/tests-any/build-ifstale.declapract.integration.test.ts +124 -0
  355. package/dist/.test/assets/git/declarations/practices/tests-any/changedsince-origin-main.declapract.integration.test.ts +58 -0
  356. package/dist/.test/assets/git/declarations/practices/tests-any/livedb-wake-branches.declapract.integration.test.ts +315 -0
  357. package/dist/.test/assets/git/declarations/practices/tests-any/old-acceptance-test-utils.declapract.integration.test.ts +122 -0
  358. package/dist/.test/assets/git/declarations/practices/tests-any/package.json.shell-flags.declapract.integration.test.ts +139 -0
  359. package/dist/.test/assets/git/declarations/practices/tests-any/test-kind-seam.declapract.integration.test.ts +87 -0
  360. package/dist/.test/assets/git/declarations/useCases.yml +29 -0
  361. package/dist/.test/assets/{expo-fullusecase/declarations/practices/git/best-practice → git/repo-with-all-gitattributes-declarers}/.gitattributes +3 -0
  362. package/dist/.test/assets/git/repo-with-all-gitattributes-declarers/declapract.use.yml +26 -0
  363. package/dist/.test/assets/git/repo-with-all-gitattributes-declarers/package.json +4 -0
  364. package/dist/.test/assets/rhachet/declarations/practices/rhachet/best-practice/.declapract.readme.md +8 -0
  365. package/dist/.test/assets/rhachet/declarations/practices/rhachet/best-practice/.gitattributes.declapract.ts +65 -0
  366. package/dist/.test/assets/tests-any-only/declarations/practices/tests-any/best-practice/.declapract.readme.md +7 -0
  367. package/dist/.test/assets/tests-any-only/declarations/practices/tests-any/best-practice/.gitattributes.declapract.ts +60 -0
  368. package/dist/__snapshots__/gitattributesDeclarers.declapract.integration.test.ts.snap +79 -0
  369. package/dist/__snapshots__/repoSkills.declapract.acceptance.test.ts.snap +512 -0
  370. package/dist/gitattributesDeclarers.declapract.integration.test.ts +438 -0
  371. package/dist/practiceOwnerPerFile.declapract.integration.test.ts +53 -0
  372. package/dist/practices/cicd-common/.declapract.integration.test.ts +15 -21
  373. package/dist/practices/git/.declapract.integration.test.ts +2 -2
  374. package/dist/practices/git/.gitattributes.declapract.integration.test.ts +34 -19
  375. package/dist/practices/git/.test/assets/repo-with-legacy-gitattributes/declapract.use.yml +3 -3
  376. package/dist/practices/git/__snapshots__/.gitattributes.declapract.integration.test.ts.snap +4 -4
  377. package/dist/practices/git/best-practice/.declapract.readme.md +37 -0
  378. package/dist/practices/git/best-practice/.gitattributes.declapract.ts +42 -63
  379. package/dist/practices/persist-with-dynamodb/best-practice/.gitattributes.declapract.ts +56 -0
  380. package/dist/practices/persist-with-rds/best-practice/.declapract.readme.md +7 -0
  381. package/dist/practices/persist-with-rds/best-practice/.gitattributes.declapract.ts +64 -0
  382. package/dist/practices/rhachet/best-practice/.declapract.readme.md +8 -0
  383. package/dist/practices/rhachet/best-practice/.gitattributes.declapract.ts +65 -0
  384. package/dist/practices/tests-any/best-practice/.declapract.readme.md +7 -0
  385. package/dist/practices/tests-any/best-practice/.gitattributes.declapract.ts +60 -0
  386. package/dist/repoSkills.declapract.acceptance.test.ts +1150 -0
  387. package/dist/utils/defineExpectedGitattributesContents.ts +247 -0
  388. package/package.json +4 -4
  389. package/dist/.test/assets/expo-migration/declarations/practices/git/best-practice/.gitattributes +0 -7
  390. package/dist/practices/git/best-practice/.gitattributes +0 -7
@@ -0,0 +1,332 @@
1
+ import { realpathSync } from 'node:fs';
2
+ import fs from 'node:fs/promises';
3
+ import { createRequire } from 'node:module';
4
+ import path from 'node:path';
5
+
6
+ import { executeApply } from 'declapract';
7
+ import { genTempDir, given, then, useBeforeAll, when } from 'test-fns';
8
+ import { getModuleExportsFromTsSource } from '../../utils/getModuleExportsFromTsSource';
9
+
10
+ /**
11
+ * .what = clamps that the config/{test,prep,prod}.json a lambda-service-with-rds apply writes
12
+ * parse under the config.schema.ts that same apply writes — for a fresh repo, and for a
13
+ * repo that holds its own hand-set values.
14
+ * .why = the templates once wrote `tunnel.bastion` / `tunnel.cluster` as strings while the schema
15
+ * demands `{ exid }` / `{ name }`, wrote the logical db name where the rds cluster name
16
+ * belongs, and the fix swapped the whole `database` subtree so a repo's own keys vanished
17
+ * (#638, #523, #562, #539). prep's passwords accept the `__CHANG3_ME__` placeholder its
18
+ * provision creates users with (#683). prep and prod tunnel on distinct local ports (#519).
19
+ * .teeth = restore the string-form bastion/cluster in config/prep.json, or the shallow-spread fix
20
+ * in config/prep.json.declapract.ts, and the safeParse and extras-survive cases redden.
21
+ * .note = the schema is transpiled and run against the zod declapract itself installs (zod is not
22
+ * a root dep of this repo); the parse reads what the emitted source returns.
23
+ */
24
+
25
+ const ENVS = ['test', 'prep', 'prod'] as const;
26
+ const SCHEMA_PATH = 'src/utils/config/config.schema.ts';
27
+
28
+ // mount the real practices under `declarations/`, so the apply writes into the temp repo's own src
29
+ const DECLARATIONS_SYMLINKS = [
30
+ { at: 'declarations/practices', to: 'src/practices' },
31
+ { at: 'declarations/useCases.yml', to: 'src/useCases.yml' },
32
+ ];
33
+
34
+ // zod, as declapract installs it
35
+ const requireFromDeclapract = createRequire(
36
+ realpathSync(path.join(process.cwd(), 'node_modules/declapract/package.json')),
37
+ );
38
+
39
+ type SchemaFound = {
40
+ apply: { safeParse: (value: unknown) => { success: boolean; error?: unknown } };
41
+ };
42
+
43
+ /**
44
+ * .what = transpile an emitted config.schema.ts and return its `schema` export
45
+ */
46
+ const asSchemaFromSource = (input: { src: string }): SchemaFound => {
47
+ const requireStub = (id: string): unknown => {
48
+ if (id === 'zod') return requireFromDeclapract('zod');
49
+ throw new Error(`unexpected require in config.schema.ts: ${id}`);
50
+ };
51
+ const { schema } = getModuleExportsFromTsSource<{ schema: SchemaFound }>({
52
+ source: input.src,
53
+ requireStub,
54
+ });
55
+ return schema!;
56
+ };
57
+
58
+ /**
59
+ * .what = apply one file with each of its two declarers, in declapract's own order (config, then
60
+ * persist-with-rds)
61
+ * .why = a whole-usecase evaluation per file costs minutes; neither declarer branches on
62
+ * `projectPractices`, so a per-practice scope applies the same declarations
63
+ */
64
+ const applyFile = async (input: { tempDir: string; file: string }) => {
65
+ for (const practice of ['config', 'persist-with-rds'])
66
+ await executeApply({
67
+ config: path.join(input.tempDir, 'declapract.use.yml'),
68
+ practice,
69
+ file: input.file,
70
+ });
71
+ };
72
+
73
+ /**
74
+ * .what = apply the three config files and the schema, in that order
75
+ */
76
+ const applyConfigAndSchema = async (input: { tempDir: string }) => {
77
+ for (const env of ENVS)
78
+ await applyFile({ tempDir: input.tempDir, file: `config/${env}.json` });
79
+ await applyFile({ tempDir: input.tempDir, file: SCHEMA_PATH });
80
+ };
81
+
82
+ /**
83
+ * .what = read every config file + the schema off disk
84
+ */
85
+ const readAll = async (input: {
86
+ tempDir: string;
87
+ }): Promise<{ configs: Record<string, string>; schemaSrc: string }> => {
88
+ const configs: Record<string, string> = {};
89
+ for (const env of ENVS)
90
+ configs[env] = await fs.readFile(
91
+ path.join(input.tempDir, `config/${env}.json`),
92
+ 'utf-8',
93
+ );
94
+ const schemaSrc = await fs.readFile(
95
+ path.join(input.tempDir, SCHEMA_PATH),
96
+ 'utf-8',
97
+ );
98
+ return { configs, schemaSrc };
99
+ };
100
+
101
+ /**
102
+ * .what = the parse outcome of each config under schema.apply
103
+ */
104
+ const getAllParseOutcomes = (input: {
105
+ configs: Record<string, string>;
106
+ schemaSrc: string;
107
+ }) => {
108
+ const schema = asSchemaFromSource({ src: input.schemaSrc });
109
+ return ENVS.map((env) => {
110
+ const result = schema.apply.safeParse(JSON.parse(input.configs[env]!));
111
+ return { env, success: result.success, error: result.error };
112
+ });
113
+ };
114
+
115
+ // whole-usecase evaluation per file runs tens of seconds
116
+ jest.setTimeout(600_000);
117
+
118
+ describe('persist-with-rds config validates against config.schema.ts (#638, #683, #519)', () => {
119
+ given('[case1] a fresh repo', () => {
120
+ const tempDir = genTempDir({
121
+ slug: 'declapract-persist-with-rds-config-schema-fresh',
122
+ clone: './src/practices/persist-with-rds/.test/assets/demo-repo-config-schema',
123
+ symlink: DECLARATIONS_SYMLINKS,
124
+ });
125
+
126
+ when('[t0] the configs and the schema are applied, then applied again', () => {
127
+ const scene = useBeforeAll(async () => {
128
+ await applyConfigAndSchema({ tempDir });
129
+ const once = await readAll({ tempDir });
130
+ await applyConfigAndSchema({ tempDir });
131
+ const twice = await readAll({ tempDir });
132
+ return { once, twice };
133
+ });
134
+
135
+ then('each config parses under schema.apply', () => {
136
+ expect(getAllParseOutcomes(scene.once)).toEqual(
137
+ ENVS.map((env) => ({ env, success: true, error: undefined })),
138
+ );
139
+ });
140
+
141
+ then('the tunnel cluster name is the rds cluster, not the db name', () => {
142
+ for (const env of ['prep', 'prod'] as const) {
143
+ const config = JSON.parse(scene.once.configs[env]!);
144
+ expect(config.database.tunnel.cluster).toEqual({ name: 'awesomesdb' });
145
+ expect(config.database.tunnel.bastion).toEqual({
146
+ exid: 'vpc-main-bastion',
147
+ });
148
+ }
149
+ });
150
+
151
+ then('prep and prod tunnel on distinct local ports, test on localhost (#519)', () => {
152
+ const portOf = (env: string) =>
153
+ JSON.parse(scene.once.configs[env]!).database.tunnel.local.port;
154
+ expect(portOf('prep')).not.toEqual(portOf('prod'));
155
+ expect(
156
+ JSON.parse(scene.once.configs.test!).database.tunnel.local.host,
157
+ ).toEqual('localhost');
158
+ });
159
+
160
+ then('a second apply changes no byte', () => {
161
+ expect(scene.twice).toEqual(scene.once);
162
+ });
163
+
164
+ then('the configs match snapshot', () => {
165
+ for (const env of ENVS)
166
+ expect(scene.once.configs[env]).toMatchSnapshot(
167
+ `config/${env}.json — after`,
168
+ );
169
+ });
170
+ });
171
+ });
172
+
173
+ given('[case2] a repo with hand-set values and legacy string tunnel fields', () => {
174
+ const tempDir = genTempDir({
175
+ slug: 'declapract-persist-with-rds-config-schema-handset',
176
+ clone: './src/practices/persist-with-rds/.test/assets/demo-repo-config-schema',
177
+ symlink: DECLARATIONS_SYMLINKS,
178
+ });
179
+
180
+ const BEFORE: Record<string, unknown> = {
181
+ test: {
182
+ organization: 'test-org',
183
+ project: 'test-project',
184
+ environment: { access: 'test' },
185
+ aws: { account: '111111111111', namespace: 'testns' },
186
+ featureFlags: { surfReport: true },
187
+ database: {
188
+ target: { database: 'testdb', schema: 'testdb' },
189
+ pool: { max: 3 },
190
+ role: {
191
+ cicd: {
192
+ 'for-plan': { username: 'cicd_user', password: '__CHANG3_ME__' },
193
+ 'for-apply': { username: 'cicd_user', password: '__CHANG3_ME__' },
194
+ },
195
+ crud: { username: 'service_user', password: '__CHANG3_ME__' },
196
+ },
197
+ tunnel: {
198
+ bastion: 'vpc-main-bastion',
199
+ cluster: 'testdb',
200
+ local: { host: 'localhost', port: 7821 },
201
+ lambda: null,
202
+ },
203
+ },
204
+ },
205
+ prep: {
206
+ organization: 'test-org',
207
+ project: 'test-project',
208
+ environment: { access: 'prep' },
209
+ aws: { account: '111111111111', namespace: 'testns' },
210
+ featureFlags: { surfReport: true },
211
+ database: {
212
+ target: { database: 'testdb', schema: 'testdb' },
213
+ pool: { max: 3 },
214
+ role: {
215
+ cicd: {
216
+ 'for-plan': {
217
+ username: 'cicd_user',
218
+ password: '$.at(aws::param/test-org/test-project/prep/legacy.plan)',
219
+ },
220
+ 'for-apply': {
221
+ username: 'cicd_user',
222
+ password: '$.at(aws::param)',
223
+ },
224
+ },
225
+ crud: { username: 'service_user', password: '__CHANG3_ME__' },
226
+ },
227
+ tunnel: {
228
+ bastion: { exid: 'vpc-main-bastion' },
229
+ cluster: { name: 'hand-set-cluster' },
230
+ local: { host: 'localhost', port: 15432 },
231
+ lambda: { host: 'cluster.prep.example.com', port: 5432 },
232
+ },
233
+ },
234
+ },
235
+ prod: {
236
+ organization: 'test-org',
237
+ project: 'test-project',
238
+ environment: { access: 'prod' },
239
+ aws: { account: '222222222222', namespace: 'testns' },
240
+ featureFlags: { surfReport: true },
241
+ database: {
242
+ target: { database: 'testdb', schema: 'testdb' },
243
+ pool: { max: 3 },
244
+ role: {
245
+ cicd: {
246
+ 'for-plan': { username: 'cicd_user', password: '$.at(aws::param)' },
247
+ 'for-apply': { username: 'cicd_user', password: '$.at(aws::param)' },
248
+ },
249
+ crud: { username: 'service_user', password: '$.at(aws::param)' },
250
+ },
251
+ tunnel: {
252
+ bastion: 'vpc-main-bastion',
253
+ cluster: 'testdb',
254
+ local: { host: 'localhost', port: 15433 },
255
+ lambda: { host: 'cluster.prod.example.com', port: 5432 },
256
+ },
257
+ },
258
+ },
259
+ };
260
+
261
+ when('[t0] the configs and the schema are applied, then applied again', () => {
262
+ const scene = useBeforeAll(async () => {
263
+ await fs.mkdir(path.join(tempDir, 'config'), { recursive: true });
264
+ for (const env of ENVS)
265
+ await fs.writeFile(
266
+ path.join(tempDir, `config/${env}.json`),
267
+ `${JSON.stringify(BEFORE[env], null, 2)}\n`,
268
+ );
269
+ const beforeConfigs: Record<string, string> = {};
270
+ for (const env of ENVS)
271
+ beforeConfigs[env] = await fs.readFile(
272
+ path.join(tempDir, `config/${env}.json`),
273
+ 'utf-8',
274
+ );
275
+ await applyConfigAndSchema({ tempDir });
276
+ const once = await readAll({ tempDir });
277
+ await applyConfigAndSchema({ tempDir });
278
+ const twice = await readAll({ tempDir });
279
+ return { before: beforeConfigs, once, twice };
280
+ });
281
+
282
+ then('each config parses under schema.apply', () => {
283
+ expect(getAllParseOutcomes(scene.once)).toEqual(
284
+ ENVS.map((env) => ({ env, success: true, error: undefined })),
285
+ );
286
+ });
287
+
288
+ then('the repo own keys and hand-set values survive', () => {
289
+ const test = JSON.parse(scene.once.configs.test!);
290
+ const prep = JSON.parse(scene.once.configs.prep!);
291
+ expect(test.featureFlags).toEqual({ surfReport: true });
292
+ expect(prep.database.pool).toEqual({ max: 3 });
293
+ expect(prep.database.tunnel.cluster).toEqual({ name: 'hand-set-cluster' });
294
+ expect(prep.database.role.cicd['for-plan'].password).toEqual(
295
+ '$.at(aws::param/test-org/test-project/prep/legacy.plan)',
296
+ );
297
+ expect(prep.database.role.crud.password).toEqual('__CHANG3_ME__');
298
+ });
299
+
300
+ then('the legacy string tunnel fields are replaced', () => {
301
+ const test = JSON.parse(scene.once.configs.test!);
302
+ const prod = JSON.parse(scene.once.configs.prod!);
303
+ for (const config of [test, prod]) {
304
+ expect(config.database.tunnel.bastion).toEqual({
305
+ exid: 'vpc-main-bastion',
306
+ });
307
+ expect(config.database.tunnel.cluster).toEqual({ name: 'awesomesdb' });
308
+ }
309
+ });
310
+
311
+ then('each config carries the unmigrated-param-paths marker, paths kept (#544)', () => {
312
+ for (const env of ENVS)
313
+ expect(
314
+ JSON.parse(scene.once.configs[env]!)['@declapract:review'],
315
+ ).toContain('#544');
316
+ });
317
+
318
+ then('a second apply changes no byte', () => {
319
+ expect(scene.twice).toEqual(scene.once);
320
+ });
321
+
322
+ then('before and after match snapshot', () => {
323
+ for (const env of ENVS) {
324
+ expect(scene.before[env]).toMatchSnapshot(`config/${env}.json — before`);
325
+ expect(scene.once.configs[env]).toMatchSnapshot(
326
+ `config/${env}.json — after`,
327
+ );
328
+ }
329
+ });
330
+ });
331
+ });
332
+ });
@@ -0,0 +1,291 @@
1
+ import { readdirSync, readFileSync } from 'node:fs';
2
+ import { join, relative } from 'node:path';
3
+
4
+ import { given, then, useBeforeAll, when } from 'test-fns';
5
+ import ts from 'typescript';
6
+
7
+ import { isPgClientWithoutSsl } from '../../utils/withPgClientSslDeclared';
8
+ import { asDatabaseClientSsl } from './best-practice/src/utils/database/asDatabaseClientSsl';
9
+
10
+ /**
11
+ * .what = proves the pg client the persist-with-rds templates build: every client verifies tls
12
+ * (#652), carries the connect and query bounds (#664), and the factory takes a `mode`
13
+ * whose readonly path reads the plan grant and the for-plan role (#673)
14
+ * .why = a postgres 17 cluster forces ssl, so a plaintext client stops to connect the moment the
15
+ * cluster upgrades; a client with no bounds hangs a lambda on a cluster that accepts the
16
+ * socket and never answers; a plan job that connects as the crud role reads a secret its
17
+ * oidc grant is denied. all three live in bytes no adopter may edit, so they are caught here
18
+ * .teeth = drop `ssl:` or `...databaseClientTimeouts` from getOneDatabaseConnection.ts and case1
19
+ * reddens; drop the `mode` input and case2 reddens with TS2554; read `role.crud` under the
20
+ * plan grant and case2 reddens with TS2322 (a password that may be absent)
21
+ * .note = `pg`, `helpful-errors`, `iso-time`, config, and environment are stubbed in memory, so the
22
+ * check needs none of them installed. INTEGRATION by `rule.forbid.unit.remote-boundaries`:
23
+ * it reads the shipped templates off the filesystem
24
+ */
25
+
26
+ const BEST_PRACTICE_DIR = join(__dirname, 'best-practice');
27
+ const TEMPLATE_DIR = join(BEST_PRACTICE_DIR, 'src/utils/database');
28
+ const FIXTURE_ROOT = '/fixture';
29
+
30
+ /**
31
+ * .what = every `.ts` template under a dir, as a path relative to the best-practice root
32
+ */
33
+ const getAllTemplates = (input: { dir: string }): string[] =>
34
+ readdirSync(input.dir, { withFileTypes: true }).flatMap((entry) => {
35
+ const path = join(input.dir, entry.name);
36
+ if (entry.isDirectory()) return getAllTemplates({ dir: path });
37
+ if (!entry.name.endsWith('.ts') || entry.name.includes('.declapract.'))
38
+ return [];
39
+ return [relative(BEST_PRACTICE_DIR, path)];
40
+ });
41
+
42
+ // the strictest options the typescript-node practice emits, over an in-memory fixture root
43
+ const COMPILER_OPTIONS: ts.CompilerOptions = {
44
+ strict: true,
45
+ noUncheckedIndexedAccess: true,
46
+ noImplicitReturns: true,
47
+ noFallthroughCasesInSwitch: true,
48
+ allowUnreachableCode: false,
49
+ exactOptionalPropertyTypes: false,
50
+ esModuleInterop: true,
51
+ target: ts.ScriptTarget.ES2020,
52
+ lib: ['lib.es2020.d.ts'],
53
+ module: ts.ModuleKind.CommonJS,
54
+ moduleResolution: ts.ModuleResolutionKind.Node10,
55
+ baseUrl: FIXTURE_ROOT,
56
+ paths: { '@src/*': ['src/*'] },
57
+ types: ['node'],
58
+ typeRoots: [join(__dirname, '../../../node_modules/@types')],
59
+ noEmit: true,
60
+ };
61
+
62
+ /**
63
+ * .what = the in-memory stand-ins for the packages and app modules the factory imports
64
+ * .why = each declares only the shape the factory reads, so a wrong read reddens the check
65
+ */
66
+ const STUBS: Record<string, string> = {
67
+ 'node_modules/pg/index.d.ts': `
68
+ import type { ConnectionOptions } from 'node:tls';
69
+ export interface QueryResultRow { [column: string]: any }
70
+ export interface QueryResult<R extends QueryResultRow = any> { rows: R[] }
71
+ export interface ClientConfig {
72
+ host?: string; port?: number; user?: string; password?: string; database?: string;
73
+ ssl?: boolean | ConnectionOptions; connectionTimeoutMillis?: number; query_timeout?: number;
74
+ }
75
+ export declare class Client {
76
+ constructor(config: ClientConfig);
77
+ connect(): Promise<void>;
78
+ query<R extends QueryResultRow = any>(sql: string, values?: unknown[]): Promise<QueryResult<R>>;
79
+ end(): Promise<void>;
80
+ }
81
+ declare const pg: { types: { setTypeParser: (oid: number, parse: (value: string) => unknown) => void } };
82
+ export default pg;
83
+ `,
84
+ 'node_modules/helpful-errors/index.d.ts': `
85
+ export declare class HelpfulError extends Error { constructor(message: string, metadata?: Record<string, unknown>); }
86
+ export declare class UnexpectedCodePathError extends HelpfulError {}
87
+ export declare class ConstraintError extends HelpfulError {}
88
+ `,
89
+ 'node_modules/iso-time/index.d.ts': `
90
+ export declare const toMilliseconds: (input: { seconds?: number; minutes?: number }) => number;
91
+ `,
92
+ 'src/utils/environment.ts': `
93
+ export declare const getEnvironment: () => Promise<{
94
+ access: 'test' | 'prep' | 'prod';
95
+ server: 'cloud@aws.lambda' | 'local@node';
96
+ }>;
97
+ `,
98
+ 'src/utils/config/getConfig.ts': `
99
+ type Grant = 'plan' | 'apply';
100
+ type Secret<TGrant extends Grant> = TGrant extends 'plan' ? string | undefined : string;
101
+ export type Config<TGrant extends Grant = 'apply'> = {
102
+ database: {
103
+ target: { database: string; schema: string };
104
+ role: {
105
+ cicd: {
106
+ 'for-plan': { username: string; password: string };
107
+ 'for-apply': { username: string; password: Secret<TGrant> };
108
+ };
109
+ crud: { username: string; password: Secret<TGrant> };
110
+ };
111
+ tunnel: {
112
+ local: { host: string; port: number };
113
+ lambda: { host: string; port: number } | null;
114
+ };
115
+ };
116
+ };
117
+ export declare const getConfig: <TGrant extends Grant = 'apply'>(
118
+ input?: { grant: TGrant | null },
119
+ ) => Promise<Config<TGrant>>;
120
+ `,
121
+ };
122
+
123
+ /**
124
+ * .what = the calls an adopter makes on the factory
125
+ * .why = the bare call must keep its sense, and a mode outside the two must not compile
126
+ */
127
+ const CALLERS = `
128
+ import { getOneDatabaseConnection } from './getOneDatabaseConnection';
129
+
130
+ export const connections = async () => [
131
+ await getOneDatabaseConnection(),
132
+ await getOneDatabaseConnection({ mode: 'readwrite' }),
133
+ await getOneDatabaseConnection({ mode: 'readonly' }),
134
+ ];
135
+
136
+ // @ts-expect-error: only readwrite and readonly are modes
137
+ export const forbidden = () => getOneDatabaseConnection({ mode: 'admin' });
138
+ `;
139
+
140
+ /**
141
+ * .what = type-check an in-memory fixture and return each diagnostic as one line
142
+ */
143
+ const getDiagnostics = (input: { files: Record<string, string> }): string[] => {
144
+ const files = Object.fromEntries(
145
+ Object.entries(input.files).map(([path, source]) => [
146
+ `${FIXTURE_ROOT}/${path}`,
147
+ source,
148
+ ]),
149
+ );
150
+ const host = ts.createCompilerHost(COMPILER_OPTIONS);
151
+ const readFileBase = host.readFile.bind(host);
152
+ const getSourceFileBase = host.getSourceFile.bind(host);
153
+ const fileExistsBase = host.fileExists.bind(host);
154
+ host.fileExists = (fileName) => fileName in files || fileExistsBase(fileName);
155
+ host.directoryExists = (directoryName) =>
156
+ Object.keys(files).some((path) => path.startsWith(`${directoryName}/`)) ||
157
+ ts.sys.directoryExists(directoryName);
158
+ host.readFile = (fileName) => files[fileName] ?? readFileBase(fileName);
159
+ host.getSourceFile = (fileName, languageVersion, ...rest) => {
160
+ const fixture = files[fileName];
161
+ if (fixture !== undefined)
162
+ return ts.createSourceFile(fileName, fixture, languageVersion, true);
163
+ return getSourceFileBase(fileName, languageVersion, ...rest);
164
+ };
165
+ const program = ts.createProgram({
166
+ rootNames: Object.keys(files),
167
+ options: COMPILER_OPTIONS,
168
+ host,
169
+ });
170
+ return ts.getPreEmitDiagnostics(program).map((diagnostic) => {
171
+ const where = diagnostic.file
172
+ ? `${diagnostic.file.fileName.replace(`${FIXTURE_ROOT}/`, '')}:${
173
+ diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start ?? 0)
174
+ .line + 1
175
+ }`
176
+ : '(global)';
177
+ return `${where} TS${diagnostic.code}: ${ts.flattenDiagnosticMessageText(diagnostic.messageText, ' ')}`;
178
+ });
179
+ };
180
+
181
+ describe('persist-with-rds pg client (#652, #664, #673)', () => {
182
+ const readTemplate = (name: string) =>
183
+ readFileSync(join(TEMPLATE_DIR, name), 'utf8');
184
+
185
+ given('[case1] every template that builds a pg Client', () => {
186
+ const clients = getAllTemplates({ dir: BEST_PRACTICE_DIR })
187
+ .map((path) => ({
188
+ path,
189
+ source: readFileSync(join(BEST_PRACTICE_DIR, path), 'utf8'),
190
+ }))
191
+ .filter(({ source }) => /new (pg\.)?Client\(/.test(source));
192
+
193
+ then('at least one is found, so the clamp is not vacuous', () => {
194
+ expect(clients.map(({ path }) => path)).toContain(
195
+ 'src/utils/database/getOneDatabaseConnection.ts',
196
+ );
197
+ });
198
+
199
+ then('each declares verified tls', () => {
200
+ expect(
201
+ clients
202
+ .filter(({ source }) => isPgClientWithoutSsl({ source }))
203
+ .map(({ path }) => path),
204
+ ).toEqual([]);
205
+ });
206
+
207
+ then('each carries the connect and query bounds', () => {
208
+ expect(
209
+ clients
210
+ .filter(({ source }) => !source.includes('...databaseClientTimeouts'))
211
+ .map(({ path }) => path),
212
+ ).toEqual([]);
213
+ });
214
+ });
215
+
216
+ given('[case2] the factory, its tls, and its bounds, where they land', () => {
217
+ when('[t0] tsc runs over them and the calls an adopter makes', () => {
218
+ const diagnostics = useBeforeAll(async () => ({
219
+ lines: getDiagnostics({
220
+ files: {
221
+ ...STUBS,
222
+ 'src/utils/database/getOneDatabaseConnection.ts': readTemplate(
223
+ 'getOneDatabaseConnection.ts',
224
+ ),
225
+ 'src/utils/database/asDatabaseClientSsl.ts': readTemplate(
226
+ 'asDatabaseClientSsl.ts',
227
+ ),
228
+ 'src/utils/database/rdsCaBundleUsEast1.ts': readTemplate(
229
+ 'rdsCaBundleUsEast1.ts',
230
+ ),
231
+ 'src/utils/database/databaseClientTimeouts.ts': readTemplate(
232
+ 'databaseClientTimeouts.ts',
233
+ ),
234
+ 'src/utils/database/getOneDatabasePort.ts': readTemplate(
235
+ 'getOneDatabasePort.ts',
236
+ ),
237
+ 'src/utils/database/callers.ts': CALLERS,
238
+ },
239
+ }),
240
+ }));
241
+
242
+ then('no diagnostic points into the factory or its callers', () => {
243
+ expect(diagnostics.lines).toEqual([]);
244
+ });
245
+ });
246
+ });
247
+
248
+ given('[case3] the readonly mode of the factory', () => {
249
+ const factory = readTemplate('getOneDatabaseConnection.ts');
250
+
251
+ then('the bare call stays readwrite', () => {
252
+ expect(factory).toContain(
253
+ "input: { mode: 'readwrite' | 'readonly' } = { mode: 'readwrite' }",
254
+ );
255
+ });
256
+
257
+ then('readonly reads the plan grant and connects as the for-plan role', () => {
258
+ expect(factory).toContain("await getConfig({ grant: 'plan' })");
259
+ expect(factory).toContain("config.database.role.cicd['for-plan']");
260
+ });
261
+
262
+ then('readonly marks the session read only, and says it is a guard, not a boundary', () => {
263
+ expect(factory).toContain(
264
+ "await client.query('SET SESSION CHARACTERISTICS AS TRANSACTION READ ONLY;')",
265
+ );
266
+ expect(factory).toContain('not a security boundary');
267
+ });
268
+ });
269
+
270
+ given('[case4] the ssl options for each kind of endpoint', () => {
271
+ then('a null endpoint (the local testdb) connects plain', () => {
272
+ expect(asDatabaseClientSsl({ clusterEndpoint: null })).toEqual(false);
273
+ });
274
+
275
+ then('a us-east-1 endpoint verifies against the rds roots', () => {
276
+ const ssl = asDatabaseClientSsl({
277
+ clusterEndpoint: 'surfdb.cluster-abc123.us-east-1.rds.amazonaws.com',
278
+ });
279
+ expect(ssl && ssl.rejectUnauthorized).toEqual(true);
280
+ expect(ssl && String(ssl.ca)).toContain('-----BEGIN CERTIFICATE-----');
281
+ });
282
+
283
+ then('an endpoint in another region fails loud, with a hint', () => {
284
+ expect(() =>
285
+ asDatabaseClientSsl({
286
+ clusterEndpoint: 'surfdb.cluster-abc123.eu-west-2.rds.amazonaws.com',
287
+ }),
288
+ ).toThrow('not in us-east-1');
289
+ });
290
+ });
291
+ });