@rawsql-ts/ztd-cli 0.17.0 → 0.20.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 (240) hide show
  1. package/README.md +532 -366
  2. package/package.json +26 -15
  3. package/templates/.editorconfig +16 -16
  4. package/templates/.prettierignore +2 -2
  5. package/templates/.prettierrc +24 -24
  6. package/templates/AGENTS.md +30 -52
  7. package/templates/CONTEXT.md +11 -0
  8. package/templates/CONTEXT.webapi.md +11 -0
  9. package/templates/DESIGN.md +17 -0
  10. package/templates/DEV_NOTES.md +14 -0
  11. package/templates/PROMPT_DOGFOOD.webapi.md +49 -0
  12. package/templates/README.md +46 -14
  13. package/templates/README.webapi.md +38 -0
  14. package/templates/scripts/local-source-guard.mjs +189 -0
  15. package/templates/src/AGENTS.md +26 -26
  16. package/templates/src/application/AGENTS.md +15 -0
  17. package/templates/src/application/README.md +6 -0
  18. package/templates/src/catalog/AGENTS.md +28 -37
  19. package/templates/src/catalog/runtime/AGENTS.md +28 -75
  20. package/templates/src/catalog/runtime/_coercions.ts +30 -1
  21. package/templates/src/catalog/runtime/_smoke.runtime.ts +21 -21
  22. package/templates/src/catalog/specs/AGENTS.md +41 -48
  23. package/templates/src/catalog/specs/_smoke.spec.arktype.ts +21 -21
  24. package/templates/src/catalog/specs/_smoke.spec.zod.ts +20 -20
  25. package/templates/src/db/sql-client-adapters.ts +32 -0
  26. package/templates/src/db/sql-client.ts +24 -24
  27. package/templates/src/domain/AGENTS.md +15 -0
  28. package/templates/src/domain/README.md +6 -0
  29. package/templates/src/infrastructure/AGENTS.md +14 -0
  30. package/templates/src/infrastructure/README.md +6 -0
  31. package/templates/src/infrastructure/db/AGENTS.md +14 -0
  32. package/templates/src/infrastructure/db/sql-client-adapters.ts +34 -0
  33. package/templates/{dist/ztd-cli/templates/src → src/infrastructure}/db/sql-client.ts +3 -3
  34. package/templates/src/infrastructure/persistence/AGENTS.md +18 -0
  35. package/templates/src/infrastructure/persistence/README.md +8 -0
  36. package/templates/src/infrastructure/persistence/repositories/AGENTS.md +17 -0
  37. package/templates/src/infrastructure/persistence/repositories/tables/AGENTS.md +20 -0
  38. package/templates/src/infrastructure/persistence/repositories/tables/README.md +5 -0
  39. package/templates/src/infrastructure/persistence/repositories/views/AGENTS.md +16 -0
  40. package/templates/src/infrastructure/persistence/repositories/views/README.md +5 -0
  41. package/templates/src/infrastructure/telemetry/AGENTS.md +14 -0
  42. package/templates/src/infrastructure/telemetry/consoleRepositoryTelemetry.ts +66 -0
  43. package/templates/src/infrastructure/telemetry/repositoryTelemetry.ts +26 -0
  44. package/templates/src/infrastructure/telemetry/types.ts +48 -0
  45. package/templates/src/jobs/AGENTS.md +25 -26
  46. package/templates/src/jobs/README.md +2 -2
  47. package/templates/src/presentation/AGENTS.md +15 -0
  48. package/templates/src/presentation/http/AGENTS.md +15 -0
  49. package/templates/src/presentation/http/README.md +6 -0
  50. package/templates/src/repositories/AGENTS.md +30 -118
  51. package/templates/src/repositories/tables/AGENTS.md +29 -94
  52. package/templates/src/repositories/tables/README.md +5 -3
  53. package/templates/src/repositories/views/AGENTS.md +25 -25
  54. package/templates/src/repositories/views/README.md +5 -3
  55. package/templates/src/sql/AGENTS.md +30 -77
  56. package/templates/src/sql/README.md +5 -5
  57. package/templates/tests/AGENTS.md +29 -62
  58. package/templates/tests/generated/AGENTS.md +23 -16
  59. package/templates/tests/smoke.test.ts +25 -5
  60. package/templates/tests/smoke.validation.test.ts +34 -34
  61. package/templates/tests/support/AGENTS.md +24 -26
  62. package/templates/tests/support/global-setup.ts +15 -15
  63. package/templates/tests/support/testkit-client.ts +14 -14
  64. package/templates/tests/support/testkit-client.webapi.ts +14 -0
  65. package/templates/tests/ztd-layout.generated.ts +6 -6
  66. package/templates/tsconfig.json +15 -15
  67. package/templates/vitest.config.ts +13 -13
  68. package/templates/ztd/AGENTS.md +23 -18
  69. package/templates/ztd/README.md +5 -5
  70. package/templates/ztd/ddl/AGENTS.md +26 -34
  71. package/templates/ztd/ddl/demo.sql +74 -74
  72. package/LICENSE +0 -21
  73. package/dist/commands/ddl.d.ts +0 -7
  74. package/dist/commands/ddl.js +0 -118
  75. package/dist/commands/ddl.js.map +0 -1
  76. package/dist/commands/diff.d.ts +0 -10
  77. package/dist/commands/diff.js +0 -38
  78. package/dist/commands/diff.js.map +0 -1
  79. package/dist/commands/genEntities.d.ts +0 -6
  80. package/dist/commands/genEntities.js +0 -50
  81. package/dist/commands/genEntities.js.map +0 -1
  82. package/dist/commands/init.d.ts +0 -79
  83. package/dist/commands/init.js +0 -1083
  84. package/dist/commands/init.js.map +0 -1
  85. package/dist/commands/lint.d.ts +0 -59
  86. package/dist/commands/lint.js +0 -358
  87. package/dist/commands/lint.js.map +0 -1
  88. package/dist/commands/options.d.ts +0 -9
  89. package/dist/commands/options.js +0 -48
  90. package/dist/commands/options.js.map +0 -1
  91. package/dist/commands/pull.d.ts +0 -10
  92. package/dist/commands/pull.js +0 -105
  93. package/dist/commands/pull.js.map +0 -1
  94. package/dist/commands/ztdConfig.d.ts +0 -23
  95. package/dist/commands/ztdConfig.js +0 -216
  96. package/dist/commands/ztdConfig.js.map +0 -1
  97. package/dist/commands/ztdConfigCommand.d.ts +0 -5
  98. package/dist/commands/ztdConfigCommand.js +0 -157
  99. package/dist/commands/ztdConfigCommand.js.map +0 -1
  100. package/dist/index.d.ts +0 -2
  101. package/dist/index.js +0 -22
  102. package/dist/index.js.map +0 -1
  103. package/dist/utils/agents.d.ts +0 -1
  104. package/dist/utils/agents.js +0 -48
  105. package/dist/utils/agents.js.map +0 -1
  106. package/dist/utils/collectSqlFiles.d.ts +0 -9
  107. package/dist/utils/collectSqlFiles.js +0 -58
  108. package/dist/utils/collectSqlFiles.js.map +0 -1
  109. package/dist/utils/connectionSummary.d.ts +0 -3
  110. package/dist/utils/connectionSummary.js +0 -29
  111. package/dist/utils/connectionSummary.js.map +0 -1
  112. package/dist/utils/dbConnection.d.ts +0 -29
  113. package/dist/utils/dbConnection.js +0 -210
  114. package/dist/utils/dbConnection.js.map +0 -1
  115. package/dist/utils/fs.d.ts +0 -1
  116. package/dist/utils/fs.js +0 -12
  117. package/dist/utils/fs.js.map +0 -1
  118. package/dist/utils/normalizePulledSchema.d.ts +0 -12
  119. package/dist/utils/normalizePulledSchema.js +0 -213
  120. package/dist/utils/normalizePulledSchema.js.map +0 -1
  121. package/dist/utils/optionalDependencies.d.ts +0 -35
  122. package/dist/utils/optionalDependencies.js +0 -96
  123. package/dist/utils/optionalDependencies.js.map +0 -1
  124. package/dist/utils/pgDump.d.ts +0 -11
  125. package/dist/utils/pgDump.js +0 -55
  126. package/dist/utils/pgDump.js.map +0 -1
  127. package/dist/utils/sqlLintHelpers.d.ts +0 -18
  128. package/dist/utils/sqlLintHelpers.js +0 -270
  129. package/dist/utils/sqlLintHelpers.js.map +0 -1
  130. package/dist/utils/typeMapper.d.ts +0 -4
  131. package/dist/utils/typeMapper.js +0 -76
  132. package/dist/utils/typeMapper.js.map +0 -1
  133. package/dist/utils/ztdProjectConfig.d.ts +0 -40
  134. package/dist/utils/ztdProjectConfig.js +0 -167
  135. package/dist/utils/ztdProjectConfig.js.map +0 -1
  136. package/templates/dist/drivers/pg-testkit/src/driver/PgTestkitClient.d.ts +0 -38
  137. package/templates/dist/drivers/pg-testkit/src/driver/PgTestkitClient.js +0 -117
  138. package/templates/dist/drivers/pg-testkit/src/driver/PgTestkitClient.js.map +0 -1
  139. package/templates/dist/drivers/pg-testkit/src/driver/createPgTestkitPool.d.ts +0 -4
  140. package/templates/dist/drivers/pg-testkit/src/driver/createPgTestkitPool.js +0 -71
  141. package/templates/dist/drivers/pg-testkit/src/driver/createPgTestkitPool.js.map +0 -1
  142. package/templates/dist/drivers/pg-testkit/src/index.d.ts +0 -5
  143. package/templates/dist/drivers/pg-testkit/src/index.js +0 -11
  144. package/templates/dist/drivers/pg-testkit/src/index.js.map +0 -1
  145. package/templates/dist/drivers/pg-testkit/src/proxy/wrapPgClient.d.ts +0 -3
  146. package/templates/dist/drivers/pg-testkit/src/proxy/wrapPgClient.js +0 -79
  147. package/templates/dist/drivers/pg-testkit/src/proxy/wrapPgClient.js.map +0 -1
  148. package/templates/dist/drivers/pg-testkit/src/types.d.ts +0 -69
  149. package/templates/dist/drivers/pg-testkit/src/types.js +0 -3
  150. package/templates/dist/drivers/pg-testkit/src/types.js.map +0 -1
  151. package/templates/dist/drivers/pg-testkit/src/utils/fixtureState.d.ts +0 -15
  152. package/templates/dist/drivers/pg-testkit/src/utils/fixtureState.js +0 -34
  153. package/templates/dist/drivers/pg-testkit/src/utils/fixtureState.js.map +0 -1
  154. package/templates/dist/drivers/pg-testkit/src/utils/fixtureValidation.d.ts +0 -12
  155. package/templates/dist/drivers/pg-testkit/src/utils/fixtureValidation.js +0 -53
  156. package/templates/dist/drivers/pg-testkit/src/utils/fixtureValidation.js.map +0 -1
  157. package/templates/dist/mapper-core/src/index.d.ts +0 -160
  158. package/templates/dist/mapper-core/src/index.js +0 -637
  159. package/templates/dist/mapper-core/src/index.js.map +0 -1
  160. package/templates/dist/testkit-core/src/errors/index.d.ts +0 -49
  161. package/templates/dist/testkit-core/src/errors/index.js +0 -111
  162. package/templates/dist/testkit-core/src/errors/index.js.map +0 -1
  163. package/templates/dist/testkit-core/src/fixtures/ColumnAffinity.d.ts +0 -5
  164. package/templates/dist/testkit-core/src/fixtures/ColumnAffinity.js +0 -29
  165. package/templates/dist/testkit-core/src/fixtures/ColumnAffinity.js.map +0 -1
  166. package/templates/dist/testkit-core/src/fixtures/DdlFixtureLoader.d.ts +0 -37
  167. package/templates/dist/testkit-core/src/fixtures/DdlFixtureLoader.js +0 -182
  168. package/templates/dist/testkit-core/src/fixtures/DdlFixtureLoader.js.map +0 -1
  169. package/templates/dist/testkit-core/src/fixtures/FixtureProvider.d.ts +0 -20
  170. package/templates/dist/testkit-core/src/fixtures/FixtureProvider.js +0 -121
  171. package/templates/dist/testkit-core/src/fixtures/FixtureProvider.js.map +0 -1
  172. package/templates/dist/testkit-core/src/fixtures/FixtureStore.d.ts +0 -51
  173. package/templates/dist/testkit-core/src/fixtures/FixtureStore.js +0 -199
  174. package/templates/dist/testkit-core/src/fixtures/FixtureStore.js.map +0 -1
  175. package/templates/dist/testkit-core/src/fixtures/TableDefinitionSchemaRegistry.d.ts +0 -10
  176. package/templates/dist/testkit-core/src/fixtures/TableDefinitionSchemaRegistry.js +0 -28
  177. package/templates/dist/testkit-core/src/fixtures/TableDefinitionSchemaRegistry.js.map +0 -1
  178. package/templates/dist/testkit-core/src/fixtures/TableNameResolver.d.ts +0 -18
  179. package/templates/dist/testkit-core/src/fixtures/TableNameResolver.js +0 -80
  180. package/templates/dist/testkit-core/src/fixtures/TableNameResolver.js.map +0 -1
  181. package/templates/dist/testkit-core/src/fixtures/ddlLint.d.ts +0 -59
  182. package/templates/dist/testkit-core/src/fixtures/ddlLint.js +0 -489
  183. package/templates/dist/testkit-core/src/fixtures/ddlLint.js.map +0 -1
  184. package/templates/dist/testkit-core/src/fixtures/naming.d.ts +0 -1
  185. package/templates/dist/testkit-core/src/fixtures/naming.js +0 -6
  186. package/templates/dist/testkit-core/src/fixtures/naming.js.map +0 -1
  187. package/templates/dist/testkit-core/src/index.d.ts +0 -17
  188. package/templates/dist/testkit-core/src/index.js +0 -47
  189. package/templates/dist/testkit-core/src/index.js.map +0 -1
  190. package/templates/dist/testkit-core/src/logger/NoopLogger.d.ts +0 -8
  191. package/templates/dist/testkit-core/src/logger/NoopLogger.js +0 -16
  192. package/templates/dist/testkit-core/src/logger/NoopLogger.js.map +0 -1
  193. package/templates/dist/testkit-core/src/provider/TestkitProvider.d.ts +0 -57
  194. package/templates/dist/testkit-core/src/provider/TestkitProvider.js +0 -149
  195. package/templates/dist/testkit-core/src/provider/TestkitProvider.js.map +0 -1
  196. package/templates/dist/testkit-core/src/rewriter/ResultSelectRewriter.d.ts +0 -43
  197. package/templates/dist/testkit-core/src/rewriter/ResultSelectRewriter.js +0 -473
  198. package/templates/dist/testkit-core/src/rewriter/ResultSelectRewriter.js.map +0 -1
  199. package/templates/dist/testkit-core/src/rewriter/SelectAnalyzer.d.ts +0 -9
  200. package/templates/dist/testkit-core/src/rewriter/SelectAnalyzer.js +0 -38
  201. package/templates/dist/testkit-core/src/rewriter/SelectAnalyzer.js.map +0 -1
  202. package/templates/dist/testkit-core/src/rewriter/SelectFixtureRewriter.d.ts +0 -42
  203. package/templates/dist/testkit-core/src/rewriter/SelectFixtureRewriter.js +0 -298
  204. package/templates/dist/testkit-core/src/rewriter/SelectFixtureRewriter.js.map +0 -1
  205. package/templates/dist/testkit-core/src/sql/SqliteValuesBuilder.d.ts +0 -12
  206. package/templates/dist/testkit-core/src/sql/SqliteValuesBuilder.js +0 -63
  207. package/templates/dist/testkit-core/src/sql/SqliteValuesBuilder.js.map +0 -1
  208. package/templates/dist/testkit-core/src/types/index.d.ts +0 -69
  209. package/templates/dist/testkit-core/src/types/index.js +0 -3
  210. package/templates/dist/testkit-core/src/types/index.js.map +0 -1
  211. package/templates/dist/testkit-core/src/utils/queryHelpers.d.ts +0 -28
  212. package/templates/dist/testkit-core/src/utils/queryHelpers.js +0 -81
  213. package/templates/dist/testkit-core/src/utils/queryHelpers.js.map +0 -1
  214. package/templates/dist/writer-core/src/index.d.ts +0 -34
  215. package/templates/dist/writer-core/src/index.js +0 -115
  216. package/templates/dist/writer-core/src/index.js.map +0 -1
  217. package/templates/dist/ztd-cli/templates/src/db/sql-client.d.ts +0 -20
  218. package/templates/dist/ztd-cli/templates/src/db/sql-client.js +0 -3
  219. package/templates/dist/ztd-cli/templates/src/db/sql-client.js.map +0 -1
  220. package/templates/dist/ztd-cli/templates/src/repositories/user-accounts.d.ts +0 -36
  221. package/templates/dist/ztd-cli/templates/src/repositories/user-accounts.js +0 -85
  222. package/templates/dist/ztd-cli/templates/src/repositories/user-accounts.js.map +0 -1
  223. package/templates/dist/ztd-cli/templates/tests/generated/ztd-row-map.generated.d.ts +0 -20
  224. package/templates/dist/ztd-cli/templates/tests/generated/ztd-row-map.generated.js +0 -33
  225. package/templates/dist/ztd-cli/templates/tests/generated/ztd-row-map.generated.js.map +0 -1
  226. package/templates/dist/ztd-cli/templates/tests/support/global-setup.d.ts +0 -10
  227. package/templates/dist/ztd-cli/templates/tests/support/global-setup.js +0 -29
  228. package/templates/dist/ztd-cli/templates/tests/support/global-setup.js.map +0 -1
  229. package/templates/dist/ztd-cli/templates/tests/support/testkit-client.d.ts +0 -66
  230. package/templates/dist/ztd-cli/templates/tests/support/testkit-client.js +0 -552
  231. package/templates/dist/ztd-cli/templates/tests/support/testkit-client.js.map +0 -1
  232. package/templates/dist/ztd-cli/templates/tests/user-profiles.test.d.ts +0 -1
  233. package/templates/dist/ztd-cli/templates/tests/user-profiles.test.js +0 -82
  234. package/templates/dist/ztd-cli/templates/tests/user-profiles.test.js.map +0 -1
  235. package/templates/dist/ztd-cli/templates/tests/writer-constraints.test.d.ts +0 -1
  236. package/templates/dist/ztd-cli/templates/tests/writer-constraints.test.js +0 -29
  237. package/templates/dist/ztd-cli/templates/tests/writer-constraints.test.js.map +0 -1
  238. package/templates/dist/ztd-cli/templates/tests/ztd-layout.generated.d.ts +0 -7
  239. package/templates/dist/ztd-cli/templates/tests/ztd-layout.generated.js +0 -10
  240. package/templates/dist/ztd-cli/templates/tests/ztd-layout.generated.js.map +0 -1
@@ -1,115 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.remove = exports.update = exports.insert = void 0;
4
- const identifierPattern = /^[A-Za-z_][A-Za-z0-9_]*$/;
5
- const identifierControlPattern = /[\u0000-\u001F\u007F]/;
6
- const assertIdentifierBasics = (identifier, kind) => {
7
- if (identifier.length === 0) {
8
- throw new Error(`${kind} identifier must not be empty`);
9
- }
10
- if (identifierControlPattern.test(identifier)) {
11
- throw new Error(`identifier "${identifier}" must not contain control characters`);
12
- }
13
- };
14
- const assertColumnIdentifier = (identifier, allowUnsafe) => {
15
- assertIdentifierBasics(identifier, 'column');
16
- if (!allowUnsafe && !identifierPattern.test(identifier)) {
17
- throw new Error(`column identifier "${identifier}" must match ${identifierPattern}`);
18
- }
19
- };
20
- const assertTableIdentifier = (identifier, allowUnsafe) => {
21
- assertIdentifierBasics(identifier, 'table');
22
- if (!allowUnsafe && !identifierPattern.test(identifier)) {
23
- throw new Error(`table identifier "${identifier}" must match ${identifierPattern}`);
24
- }
25
- };
26
- const hasParamValueEntry = (entry) => entry[1] !== undefined;
27
- const ensureEntries = (entries, kind) => {
28
- if (entries.length === 0) {
29
- throw new Error(kind === 'insert' ? 'insert values must not be empty' : 'update values must not be empty');
30
- }
31
- };
32
- const formatPlaceholder = (index) => `$${index}`;
33
- const buildPlaceholders = (count, startIndex = 1) => Array.from({ length: count }, (_, index) => formatPlaceholder(startIndex + index));
34
- const buildWhereClause = (key, startIndex, options) => {
35
- const entries = Object.entries(key);
36
- if (entries.length === 0) {
37
- throw new Error('where must not be empty');
38
- }
39
- const params = [];
40
- const clauses = entries.map(([column, value], index) => {
41
- assertColumnIdentifier(column, options === null || options === void 0 ? void 0 : options.allowUnsafeIdentifiers);
42
- if (value === undefined) {
43
- throw new Error('key values must not be undefined');
44
- }
45
- params.push(value);
46
- return `${column} = ${formatPlaceholder(startIndex + index)}`;
47
- });
48
- // Build a flat AND list of equality checks with placeholders offset by the caller.
49
- return {
50
- clause: `WHERE ${clauses.join(' AND ')}`,
51
- params,
52
- };
53
- };
54
- /**
55
- * Build an INSERT statement that keeps SQL visible and drops undefined fields.
56
- * @param options – Pass `allowUnsafeIdentifiers` when you knowingly use Unicode names.
57
- */
58
- const insert = (table, values, options) => {
59
- const allowUnsafe = (options === null || options === void 0 ? void 0 : options.allowUnsafeIdentifiers) === true;
60
- assertTableIdentifier(table, allowUnsafe);
61
- const entries = Object.entries(values).filter(hasParamValueEntry);
62
- ensureEntries(entries, 'insert');
63
- const columns = [];
64
- const params = [];
65
- for (const [column, value] of entries) {
66
- assertColumnIdentifier(column, allowUnsafe);
67
- columns.push(column);
68
- params.push(value);
69
- }
70
- const columnsList = columns.join(', ');
71
- const placeholders = buildPlaceholders(params.length).join(', ');
72
- return {
73
- sql: `INSERT INTO ${table} (${columnsList}) VALUES (${placeholders})`,
74
- params,
75
- };
76
- };
77
- exports.insert = insert;
78
- /**
79
- * Build an UPDATE statement that reuses parameterized placeholders and guards empty sets.
80
- * @param options – Pass `allowUnsafeIdentifiers` when you knowingly use Unicode names.
81
- */
82
- const update = (table, values, where, options) => {
83
- const allowUnsafe = (options === null || options === void 0 ? void 0 : options.allowUnsafeIdentifiers) === true;
84
- assertTableIdentifier(table, allowUnsafe);
85
- const entries = Object.entries(values).filter(hasParamValueEntry);
86
- ensureEntries(entries, 'update');
87
- const params = [];
88
- const clauses = entries.map(([column, value]) => {
89
- assertColumnIdentifier(column, allowUnsafe);
90
- params.push(value);
91
- return `${column} = ${formatPlaceholder(params.length)}`;
92
- });
93
- // Offset WHERE placeholders so they follow the SET parameters.
94
- const whereClause = buildWhereClause(where, params.length + 1, options);
95
- return {
96
- sql: `UPDATE ${table} SET ${clauses.join(', ')} ${whereClause.clause}`,
97
- params: [...params, ...whereClause.params],
98
- };
99
- };
100
- exports.update = update;
101
- /**
102
- * Build a DELETE statement that only emits equality-only WHERE clauses.
103
- * @param options – Pass `allowUnsafeIdentifiers` when you knowingly use Unicode names.
104
- */
105
- const remove = (table, where, options) => {
106
- const allowUnsafe = (options === null || options === void 0 ? void 0 : options.allowUnsafeIdentifiers) === true;
107
- assertTableIdentifier(table, allowUnsafe);
108
- const whereClause = buildWhereClause(where, 1, options);
109
- return {
110
- sql: `DELETE FROM ${table} ${whereClause.clause}`,
111
- params: [...whereClause.params],
112
- };
113
- };
114
- exports.remove = remove;
115
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../writer-core/src/index.ts"],"names":[],"mappings":";;;AAeA,MAAM,iBAAiB,GAAG,0BAA0B,CAAA;AACpD,MAAM,wBAAwB,GAAG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AC,EAAE,OAAO,CAAC,CAAA;IAEvD,OAAO;QACL,GAAG,EAAE,eAAe,KAAK,IAAI,WAAW,CAAC,MAAM,EAAE;QACjD,MAAM,EAAE,CAAC,GAAG,WAAW,CAAC,MAAM,CAAC;KAChC,CAAA;AACH,CAAC,CAAA;AATY,QAAA,MAAM,UASlB"}
@@ -1,20 +0,0 @@
1
- /**
2
- * Promise that resolves to the array of rows produced by an SQL query.
3
- * @template T Shape of each row yielded by the SQL client.
4
- * @example
5
- * const rows: SqlQueryRows<{ id: number; name: string }> = client.query('SELECT id, name FROM users');
6
- */
7
- export type SqlQueryRows<T> = Promise<T[]>;
8
- /**
9
- * Minimal SQL client interface required by the repository layer.
10
- *
11
- * - Production: adapt `pg` (or other drivers) to normalize results into `T[]`
12
- * - Tests: compatible with `pg-testkit` clients returned by `createTestkitClient()`
13
- *
14
- * Connection strategy note:
15
- * - Prefer a shared client per worker process for performance.
16
- * - Do not share a live client across parallel workers.
17
- */
18
- export type SqlClient = {
19
- query<T extends Record<string, unknown> = Record<string, unknown>>(text: string, values?: readonly unknown[]): SqlQueryRows<T>;
20
- };
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=sql-client.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sql-client.js","sourceRoot":"","sources":["../../../../../src/db/sql-client.ts"],"names":[],"mappings":""}
@@ -1,36 +0,0 @@
1
- import type { SqlClient } from '../db/sql-client';
2
- import { insert, Key, remove, update } from '@rawsql-ts/writer-core';
3
- type UserProfileRow = {
4
- profileId: number;
5
- userAccountId: number;
6
- bio: string | null;
7
- website: string | null;
8
- verified: boolean;
9
- };
10
- export type UserAccountWithProfile = {
11
- userAccountId: number;
12
- username: string;
13
- email: string;
14
- displayName: string;
15
- createdAt: Date;
16
- updatedAt: Date;
17
- profile?: UserProfileRow;
18
- };
19
- export declare function listUserProfiles(client: SqlClient): Promise<UserAccountWithProfile[]>;
20
- export type NewUserAccount = {
21
- username: string;
22
- email: string;
23
- displayName: string;
24
- };
25
- export type DisplayNameUpdatePayload = {
26
- displayName: string;
27
- };
28
- export declare function buildInsertUserAccount(input: NewUserAccount): ReturnType<typeof insert>;
29
- export declare function buildUpdateDisplayName(key: Key, payload: DisplayNameUpdatePayload): ReturnType<typeof update>;
30
- export declare function buildRemoveUserAccount(key: Key): ReturnType<typeof remove>;
31
- export declare const userAccountWriterColumnSets: {
32
- insertColumns: readonly ["username", "email", "display_name"];
33
- updateColumns: readonly ["display_name", "updated_at"];
34
- immutableColumns: readonly ["user_account_id", "created_at"];
35
- };
36
- export {};
@@ -1,85 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.userAccountWriterColumnSets = void 0;
4
- exports.listUserProfiles = listUserProfiles;
5
- exports.buildInsertUserAccount = buildInsertUserAccount;
6
- exports.buildUpdateDisplayName = buildUpdateDisplayName;
7
- exports.buildRemoveUserAccount = buildRemoveUserAccount;
8
- const mapper_core_1 = require("@rawsql-ts/mapper-core");
9
- const writer_core_1 = require("@rawsql-ts/writer-core");
10
- const userAccountTable = 'public.user_account';
11
- // Map the joined profile columns so we can hydrate nested objects later.
12
- const profileMapping = (0, mapper_core_1.entity)({
13
- name: 'userProfile',
14
- key: 'profileId',
15
- columnMap: {
16
- profileId: 'profile_id',
17
- userAccountId: 'profile_user_account_id',
18
- bio: 'bio',
19
- website: 'website',
20
- verified: 'verified',
21
- },
22
- });
23
- const userAccountMapping = (0, mapper_core_1.entity)({
24
- name: 'userAccount',
25
- key: 'userAccountId',
26
- columnMap: {
27
- userAccountId: 'user_account_id',
28
- username: 'username',
29
- email: 'email',
30
- displayName: 'display_name',
31
- createdAt: 'created_at',
32
- updatedAt: 'updated_at',
33
- },
34
- }).belongsTo('profile', profileMapping, 'userAccountId', { optional: true });
35
- const userProfilesSql = `
36
- SELECT
37
- u.user_account_id,
38
- u.username,
39
- u.email,
40
- u.display_name,
41
- u.created_at,
42
- u.updated_at,
43
- p.profile_id,
44
- p.user_account_id AS profile_user_account_id,
45
- p.bio,
46
- p.website,
47
- p.verified
48
- FROM public.user_account u
49
- LEFT JOIN public.user_profile p ON p.user_account_id = u.user_account_id
50
- ORDER BY u.user_account_id, p.profile_id;
51
- `;
52
- // Build a mapper that can translate snake_case columns into camelCase DTOs.
53
- const createMapperForClient = (client) => (0, mapper_core_1.createMapper)((0, mapper_core_1.toRowsExecutor)((sql, params = []) => client.query(sql, params)), {
54
- keyTransform: 'snake_to_camel',
55
- coerceDates: true,
56
- });
57
- async function listUserProfiles(client) {
58
- const mapper = createMapperForClient(client);
59
- return mapper.query(userProfilesSql, [], userAccountMapping);
60
- }
61
- // Writer helpers keep SQL+params visible and enforce the minimal CUD surface.
62
- function buildInsertUserAccount(input) {
63
- return (0, writer_core_1.insert)(userAccountTable, {
64
- username: input.username,
65
- email: input.email,
66
- display_name: input.displayName,
67
- });
68
- }
69
- function buildUpdateDisplayName(key, payload) {
70
- return (0, writer_core_1.update)(userAccountTable, {
71
- // Persist the new display name and bump the timestamp along with it.
72
- display_name: payload.displayName,
73
- updated_at: new Date(),
74
- }, key);
75
- }
76
- function buildRemoveUserAccount(key) {
77
- return (0, writer_core_1.remove)(userAccountTable, key);
78
- }
79
- // Tests consume these lists to verify writer callers stay within the approved columns.
80
- exports.userAccountWriterColumnSets = {
81
- insertColumns: ['username', 'email', 'display_name'],
82
- updateColumns: ['display_name', 'updated_at'],
83
- immutableColumns: ['user_account_id', 'created_at'],
84
- };
85
- //# sourceMappingURL=user-accounts.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"user-accounts.js","sourceRoot":"","sources":["../../../../../src/repositories/user-accounts.ts"],"names":[],"mappings":";;;AAgFA,4CAKC;AAaD,wDAQC;AAED,wDAaC;AAED,wDAEC;AA5HD,wDAA8E;AAC9E,wDAAqE;AAErE,MAAM,gBAAgB,GAAG,qBAAqB,CAAC;AAoB/C,yEAAyE;AACzE,MAAM,cAAc,GAAG,I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B,EAAE;QAC9B,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,YAAY,EAAE,KAAK,CAAC,WAAW;KAChC,CAAC,CAAC;AACL,CAAC;AAED,SAAgB,sBAAsB,CACpC,GAAQ,EACR,OAAiC;IAEjC,OAAO,IAAA,oBAAM,EACX,gBAAgB,EAChB;QACE,qEAAqE;QACrE,YAAY,EAAE,OAAO,CAAC,WAAW;QACjC,UAAU,EAAE,IAAI,IAAI,EAAE;KACvB,EACD,GAAG,CACJ,CAAC;AACJ,CAAC;AAED,SAAgB,sBAAsB,CAAC,GAAQ;IAC7C,OAAO,IAAA,oBAAM,EAAC,gBAAgB,EAAE,GAAG,CAAC,CAAC;AACvC,CAAC;AAED,uFAAuF;AAC1E,QAAA,2BAA2B,GAAG;IACzC,aAAa,EAAE,CAAC,UAAU,EAAE,OAAO,EAAE,cAAc,CAAU;IAC7D,aAAa,EAAE,CAAC,cAAc,EAAE,YAAY,CAAU;IACtD,gBAAgB,EAAE,CAAC,iBAAiB,EAAE,YAAY,CAAU;CAC7D,CAAC"}
@@ -1,20 +0,0 @@
1
- import type { TableFixture, TableSchemaDefinition } from '@rawsql-ts/testkit-core';
2
- export type TestRowMap = {
3
- 'public.user_account': {
4
- user_account_id: number;
5
- username: string;
6
- email: string;
7
- display_name: string;
8
- created_at: string;
9
- updated_at: string;
10
- };
11
- 'public.user_profile': {
12
- profile_id: number;
13
- user_account_id: number;
14
- bio: string | null;
15
- website: string | null;
16
- verified: boolean;
17
- };
18
- };
19
- export declare const tableSchemas: Record<keyof TestRowMap, TableSchemaDefinition>;
20
- export declare function tableFixture<TableName extends keyof TestRowMap>(tableName: TableName, rows: TestRowMap[TableName][], schema: TableSchemaDefinition): TableFixture;
@@ -1,33 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.tableSchemas = void 0;
4
- exports.tableFixture = tableFixture;
5
- exports.tableSchemas = {
6
- 'public.user_account': {
7
- columns: {
8
- user_account_id: 'int',
9
- username: 'text',
10
- email: 'text',
11
- display_name: 'text',
12
- created_at: 'timestamp',
13
- updated_at: 'timestamp',
14
- },
15
- },
16
- 'public.user_profile': {
17
- columns: {
18
- profile_id: 'int',
19
- user_account_id: 'int',
20
- bio: 'text',
21
- website: 'text',
22
- verified: 'boolean',
23
- },
24
- },
25
- };
26
- function tableFixture(tableName, rows, schema) {
27
- return {
28
- tableName,
29
- rows,
30
- schema,
31
- };
32
- }
33
- //# sourceMappingURL=ztd-row-map.generated.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ztd-row-map.generated.js","sourceRoot":"","sources":["../../../../../tests/generated/ztd-row-map.generated.ts"],"names":[],"mappings":";;;AA0CA,oCAUC;AAhCY,QAAA,YAAY,GAAoD;IAC3E,qBAAqB,EAAE;QACrB,OAAO,EAAE;YACP,eAAe,EAAE,KAAK;YACtB,QAAQ,EAAE,MAAM;YAChB,KAAK,EAAE,MAAM;YACb,YAAY,EAAE,MAAM;YACpB,UAAU,EAAE,WAAW;YACvB,UAAU,EAAE,WAAW;SACxB;KACF;IACD,qBAAqB,EAAE;QACrB,OAAO,EAAE;YACP,UAAU,EAAE,KAAK;YACjB,eAAe,EAAE,KAAK;YACtB,GAAG,EAAE,MAAM;YACX,OAAO,EAAE,MAAM;YACf,QAAQ,EAAE,SAAS;SACpB;KACF;CACF,CAAC;AAEF,SAAgB,YAAY,CAC1B,SAAoB,EACpB,IAA6B,EAC7B,MAA6B;IAE7B,OAAO;QACL,SAAS;QACT,IAAI;QACJ,MAAM;KACP,CAAC;AACJ,CAAC"}
@@ -1,10 +0,0 @@
1
- /**
2
- * Vitest global setup.
3
- *
4
- * ZTD tests are safe to run in parallel against a single Postgres instance because pg-testkit
5
- * rewrites CRUD into fixture-backed SELECT queries (no physical tables are created/mutated).
6
- *
7
- * This setup starts exactly one disposable Postgres container when DATABASE_URL is not provided,
8
- * and shares the resulting DATABASE_URL with all Vitest workers.
9
- */
10
- export default function globalSetup(): Promise<(() => undefined) | (() => Promise<void>)>;
@@ -1,29 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = globalSetup;
4
- const postgresql_1 = require("@testcontainers/postgresql");
5
- /**
6
- * Vitest global setup.
7
- *
8
- * ZTD tests are safe to run in parallel against a single Postgres instance because pg-testkit
9
- * rewrites CRUD into fixture-backed SELECT queries (no physical tables are created/mutated).
10
- *
11
- * This setup starts exactly one disposable Postgres container when DATABASE_URL is not provided,
12
- * and shares the resulting DATABASE_URL with all Vitest workers.
13
- */
14
- async function globalSetup() {
15
- const configuredUrl = process.env.DATABASE_URL;
16
- if (configuredUrl && configuredUrl.length > 0) {
17
- return () => undefined;
18
- }
19
- const container = new postgresql_1.PostgreSqlContainer('postgres:18-alpine')
20
- .withDatabase('ztd_playground')
21
- .withUsername('postgres')
22
- .withPassword('postgres');
23
- const started = await container.start();
24
- process.env.DATABASE_URL = started.getConnectionUri();
25
- return async () => {
26
- await started.stop();
27
- };
28
- }
29
- //# sourceMappingURL=global-setup.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"global-setup.js","sourceRoot":"","sources":["../../../../../tests/support/global-setup.ts"],"names":[],"mappings":";;AAWA,8BAiBC;AA5BD,2DAAiE;AAEjE;;;;;;;;GAQG;AACY,KAAK,UAAU,WAAW;IACvC,MAAM,aAAa,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC;IAC/C,IAAI,aAAa,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC9C,OAAO,GAAG,EAAE,CAAC,SAAS,CAAC;IACzB,CAAC;IAED,MAAM,SAAS,GAAG,IAAI,gCAAmB,CAAC,oBAAoB,CAAC;SAC5D,YAAY,CAAC,gBAAgB,CAAC;SAC9B,YAAY,CAAC,UAAU,CAAC;SACxB,YAAY,CAAC,UAAU,CAAC,CAAC;IAE5B,MAAM,OAAO,GAAG,MAAM,SAAS,CAAC,KAAK,EAAE,CAAC;IACxC,OAAO,CAAC,GAAG,CAAC,YAAY,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAEtD,OAAO,KAAK,IAAI,EAAE;QAChB,MAAM,OAAO,CAAC,IAAI,EAAE,CAAC;IACvB,CAAC,CAAC;AACJ,CAAC"}
@@ -1,66 +0,0 @@
1
- import type { QueryResultRow } from 'pg';
2
- import type { TableFixture } from '@rawsql-ts/testkit-core';
3
- type ZtdSqlLogPhase = 'original' | 'rewritten';
4
- type ZtdSqlLogEvent = {
5
- kind: 'ztd-sql';
6
- phase: ZtdSqlLogPhase;
7
- queryId: number;
8
- sql: string;
9
- params?: unknown[];
10
- fixturesApplied?: string[];
11
- timestamp: string;
12
- };
13
- export type ZtdExecutionMode = 'ztd' | 'traditional';
14
- export type TraditionalIsolationMode = 'schema' | 'none';
15
- export type TraditionalCleanupStrategy = 'drop_schema' | 'custom_sql' | 'none';
16
- export interface TraditionalExecutionConfig {
17
- isolation?: TraditionalIsolationMode;
18
- setupSql?: string[];
19
- cleanup?: TraditionalCleanupStrategy;
20
- cleanupSql?: string[];
21
- schemaName?: string;
22
- }
23
- export type ZtdSqlLogOptions = {
24
- enabled?: boolean;
25
- includeParams?: boolean;
26
- logger?: (event: ZtdSqlLogEvent) => void;
27
- profile?: ZtdProfileOptions;
28
- mode?: ZtdExecutionMode;
29
- traditional?: TraditionalExecutionConfig;
30
- };
31
- type ZtdProfilePhase = 'connection' | 'setup' | 'query' | 'teardown';
32
- type ZtdProfileEvent = {
33
- kind: 'ztd-profile';
34
- phase: ZtdProfilePhase;
35
- testName?: string;
36
- workerId?: string;
37
- processId: number;
38
- executionMode?: 'serial' | 'parallel' | 'unknown';
39
- connectionReused?: boolean;
40
- queryId?: number;
41
- queryCount?: number;
42
- durationMs?: number;
43
- totalQueryMs?: number;
44
- sql?: string;
45
- params?: unknown[];
46
- fixturesApplied?: string[];
47
- sampleSql?: string[];
48
- timestamp: string;
49
- };
50
- export type ZtdProfileOptions = {
51
- enabled?: boolean;
52
- perQuery?: boolean;
53
- includeParams?: boolean;
54
- includeSql?: boolean;
55
- sampleLimit?: number;
56
- testName?: string;
57
- executionMode?: 'serial' | 'parallel' | 'unknown';
58
- logger?: (event: ZtdProfileEvent) => void;
59
- };
60
- export type ZtdPlaygroundQueryResult<T extends QueryResultRow = QueryResultRow> = Promise<T[]>;
61
- export type ZtdPlaygroundClient = {
62
- query<T extends QueryResultRow = QueryResultRow>(text: string, values?: unknown[]): ZtdPlaygroundQueryResult<T>;
63
- close(): Promise<void>;
64
- };
65
- export declare function createTestkitClient(fixtures: TableFixture[], options?: ZtdSqlLogOptions): Promise<ZtdPlaygroundClient>;
66
- export {};