rawsql-ts 0.11.14-beta → 0.11.16-beta

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 (31) hide show
  1. package/dist/esm/index.js +2 -0
  2. package/dist/esm/index.js.map +1 -1
  3. package/dist/esm/index.min.js +19 -17
  4. package/dist/esm/index.min.js.map +4 -4
  5. package/dist/esm/src/index.d.ts +2 -0
  6. package/dist/esm/src/index.js +2 -0
  7. package/dist/esm/src/index.js.map +1 -1
  8. package/dist/esm/src/transformers/CTEComposer.d.ts +136 -0
  9. package/dist/esm/src/transformers/CTEComposer.js +298 -0
  10. package/dist/esm/src/transformers/CTEComposer.js.map +1 -0
  11. package/dist/esm/src/transformers/CTEQueryDecomposer.d.ts +213 -0
  12. package/dist/esm/src/transformers/CTEQueryDecomposer.js +360 -0
  13. package/dist/esm/src/transformers/CTEQueryDecomposer.js.map +1 -0
  14. package/dist/esm/src/transformers/SqlFormatter.d.ts +39 -21
  15. package/dist/esm/src/transformers/SqlFormatter.js.map +1 -1
  16. package/dist/esm/tsconfig.browser.tsbuildinfo +1 -1
  17. package/dist/index.min.js +19 -17
  18. package/dist/index.min.js.map +4 -4
  19. package/dist/src/index.d.ts +2 -0
  20. package/dist/src/index.js +2 -0
  21. package/dist/src/index.js.map +1 -1
  22. package/dist/src/transformers/CTEComposer.d.ts +136 -0
  23. package/dist/src/transformers/CTEComposer.js +302 -0
  24. package/dist/src/transformers/CTEComposer.js.map +1 -0
  25. package/dist/src/transformers/CTEQueryDecomposer.d.ts +213 -0
  26. package/dist/src/transformers/CTEQueryDecomposer.js +369 -0
  27. package/dist/src/transformers/CTEQueryDecomposer.js.map +1 -0
  28. package/dist/src/transformers/SqlFormatter.d.ts +39 -21
  29. package/dist/src/transformers/SqlFormatter.js.map +1 -1
  30. package/dist/tsconfig.tsbuildinfo +1 -1
  31. package/package.json +1 -1
@@ -0,0 +1,213 @@
1
+ import { SimpleSelectQuery } from "../models/SimpleSelectQuery";
2
+ import { SqlFormatterOptions } from "./SqlFormatter";
3
+ /**
4
+ * Interface representing a decomposed CTE with executable query
5
+ * @public
6
+ */
7
+ export interface DecomposedCTE {
8
+ /** Name of the CTE */
9
+ name: string;
10
+ /** Executable SQL query for this CTE (includes dependencies) */
11
+ query: string;
12
+ /** Array of CTE names that this CTE depends on */
13
+ dependencies: string[];
14
+ /** Array of CTE names that depend on this CTE */
15
+ dependents: string[];
16
+ /** Whether this CTE is recursive */
17
+ isRecursive: boolean;
18
+ }
19
+ /**
20
+ * Options for CTEQueryDecomposer extending SqlFormatterOptions
21
+ * @public
22
+ */
23
+ export interface CTEDecomposerOptions extends SqlFormatterOptions {
24
+ /** Whether to add comments to decomposed queries showing metadata and dependencies */
25
+ addComments?: boolean;
26
+ }
27
+ /**
28
+ * Decomposes complex CTEs into executable standalone queries
29
+ *
30
+ * This class analyzes Common Table Expressions and generates executable standalone queries
31
+ * for each CTE, making complex CTE debugging easier. It supports:
32
+ * - Recursive CTE detection and handling
33
+ * - Dependency analysis (dependencies and dependents for each CTE)
34
+ * - Configurable SQL formatter options (MySQL, PostgreSQL, custom styles)
35
+ * - Optional comment generation showing CTE metadata and relationships
36
+ * - Comprehensive error handling for circular dependencies
37
+ *
38
+ * @example
39
+ * ```typescript
40
+ * const decomposer = new CTEQueryDecomposer({
41
+ * preset: 'postgres',
42
+ * addComments: true,
43
+ * keywordCase: 'upper'
44
+ * });
45
+ *
46
+ * const query = `
47
+ * with users_data as (select * from users),
48
+ * active_users as (select * from users_data where active = true)
49
+ * select * from active_users
50
+ * `;
51
+ *
52
+ * const decomposed = decomposer.decompose(SelectQueryParser.parse(query));
53
+ * // Returns array of DecomposedCTE objects with executable queries
54
+ * ```
55
+ *
56
+ * @public
57
+ */
58
+ export declare class CTEQueryDecomposer {
59
+ private static readonly ERROR_MESSAGES;
60
+ private static readonly COMMENT_TEXTS;
61
+ private readonly dependencyAnalyzer;
62
+ private readonly cteCollector;
63
+ private readonly formatter;
64
+ private readonly options;
65
+ /**
66
+ * Creates a new CTEQueryDecomposer instance
67
+ * @param options - Configuration options extending SqlFormatterOptions
68
+ */
69
+ constructor(options?: CTEDecomposerOptions);
70
+ /**
71
+ * Decomposes CTEs in a query into executable standalone queries
72
+ *
73
+ * This method analyzes the query structure to:
74
+ * 1. Collect all CTEs and analyze their dependencies
75
+ * 2. Detect recursive CTEs and handle them separately
76
+ * 3. Generate executable queries for each CTE including required dependencies
77
+ * 4. Add optional comments with metadata (if addComments option is enabled)
78
+ * 5. Format output according to specified formatter options
79
+ *
80
+ * @param query - The SimpleSelectQuery containing CTEs to decompose
81
+ * @returns Array of decomposed CTEs with executable queries, dependencies, and metadata
82
+ * @throws Error if circular dependencies are detected in non-recursive CTEs
83
+ *
84
+ * @example
85
+ * ```typescript
86
+ * const query = SelectQueryParser.parse(`
87
+ * with base as (select * from users),
88
+ * filtered as (select * from base where active = true)
89
+ * select * from filtered
90
+ * `);
91
+ *
92
+ * const result = decomposer.decompose(query);
93
+ * // Returns:
94
+ * // [
95
+ * // { name: 'base', query: 'select * from users', dependencies: [], ... },
96
+ * // { name: 'filtered', query: 'with base as (...) select * from base where active = true', dependencies: ['base'], ... }
97
+ * // ]
98
+ * ```
99
+ */
100
+ decompose(query: SimpleSelectQuery): DecomposedCTE[];
101
+ /**
102
+ * Synchronizes edited CTEs back into a unified query and re-decomposes them
103
+ *
104
+ * This method resolves inconsistencies between edited CTEs by:
105
+ * 1. Composing the edited CTEs into a unified query
106
+ * 2. Parsing the unified query to ensure consistency
107
+ * 3. Re-decomposing the synchronized query
108
+ *
109
+ * This is useful when CTEs have been edited independently and may have
110
+ * inconsistencies that need to be resolved through a unified composition.
111
+ *
112
+ * @param editedCTEs - Array of edited CTEs that may have inconsistencies
113
+ * @param rootQuery - The main query that uses the CTEs
114
+ * @returns Array of re-decomposed CTEs with resolved inconsistencies
115
+ * @throws Error if the composed query cannot be parsed or contains errors
116
+ *
117
+ * @example
118
+ * ```typescript
119
+ * // After editing CTEs independently, synchronize them
120
+ * const editedCTEs = [
121
+ * { name: 'users_data', query: 'select * from users where active = true' },
122
+ * { name: 'active_users', query: 'select * from users_data where id >= 1000' }
123
+ * ];
124
+ *
125
+ * const synchronized = decomposer.synchronize(editedCTEs, 'select count(*) from active_users');
126
+ * // Returns re-decomposed CTEs with resolved dependencies
127
+ * ```
128
+ */
129
+ synchronize(editedCTEs: Array<{
130
+ name: string;
131
+ query: string;
132
+ }>, rootQuery: string): DecomposedCTE[];
133
+ /**
134
+ * Validates circular dependencies for non-recursive CTEs
135
+ * @param hasRecursiveCTEs Whether the query contains recursive CTEs
136
+ * @throws Error if circular dependencies exist in non-recursive CTEs
137
+ */
138
+ private validateCircularDependencies;
139
+ /**
140
+ * Processes CTE nodes and generates decomposed CTEs
141
+ * @param query Original query
142
+ * @param nodes CTE dependency nodes
143
+ * @param recursiveCTEs List of recursive CTE names
144
+ * @returns Array of decomposed CTEs
145
+ */
146
+ private processCTENodes;
147
+ /**
148
+ * Creates a decomposed CTE for recursive CTEs
149
+ */
150
+ private createRecursiveCTE;
151
+ /**
152
+ * Creates a decomposed CTE for standard (non-recursive) CTEs
153
+ */
154
+ private createStandardCTE;
155
+ /**
156
+ * Builds an executable query for a CTE by including its dependencies
157
+ */
158
+ private buildExecutableQuery;
159
+ /**
160
+ * Collects all required CTEs for a target CTE in dependency order
161
+ */
162
+ private collectRequiredCTEs;
163
+ /**
164
+ * Builds WITH clause from required CTEs
165
+ */
166
+ private buildWithClause;
167
+ /**
168
+ * Finds recursive CTEs in the query
169
+ * @param query The query to analyze
170
+ * @param ctes All CTEs in the query
171
+ * @returns Array of recursive CTE names
172
+ */
173
+ private findRecursiveCTEs;
174
+ /**
175
+ * Checks if a WITH clause is recursive
176
+ * @param query The query to check
177
+ * @returns true if the query contains WITH RECURSIVE
178
+ */
179
+ private isRecursiveWithClause;
180
+ /**
181
+ * Adds comments to the query if addComments option is enabled
182
+ * @param query The query string to add comments to
183
+ * @param cteName The name of the CTE
184
+ * @param dependencies Array of dependency names
185
+ * @param dependents Array of dependent names
186
+ * @param isRecursive Whether this is a recursive CTE
187
+ * @returns Query with comments added if enabled, otherwise original query
188
+ */
189
+ private addCommentsToQuery;
190
+ /**
191
+ * Generates comment lines for a CTE
192
+ * @param cteName The name of the CTE
193
+ * @param dependencies Array of dependency names
194
+ * @param dependents Array of dependent names
195
+ * @param isRecursive Whether this is a recursive CTE
196
+ * @returns Array of comment strings
197
+ */
198
+ private generateComments;
199
+ /**
200
+ * Adds text comments as SQL comments when AST parsing fails
201
+ * @param query Original query
202
+ * @param cteName The name of the CTE
203
+ * @param dependencies Array of dependency names
204
+ * @param dependents Array of dependent names
205
+ * @param isRecursive Whether this is a recursive CTE
206
+ * @returns Query with text comments prepended
207
+ */
208
+ private addTextCommentsToQuery;
209
+ /**
210
+ * Extracts the name from a CommonTable
211
+ */
212
+ private getCTEName;
213
+ }
@@ -0,0 +1,360 @@
1
+ import { CTEDependencyAnalyzer } from "./CTEDependencyAnalyzer";
2
+ import { CTECollector } from "./CTECollector";
3
+ import { SqlFormatter } from "./SqlFormatter";
4
+ import { CommentEditor } from "../utils/CommentEditor";
5
+ import { SelectQueryParser } from "../parsers/SelectQueryParser";
6
+ import { CTEComposer } from "./CTEComposer";
7
+ /**
8
+ * Decomposes complex CTEs into executable standalone queries
9
+ *
10
+ * This class analyzes Common Table Expressions and generates executable standalone queries
11
+ * for each CTE, making complex CTE debugging easier. It supports:
12
+ * - Recursive CTE detection and handling
13
+ * - Dependency analysis (dependencies and dependents for each CTE)
14
+ * - Configurable SQL formatter options (MySQL, PostgreSQL, custom styles)
15
+ * - Optional comment generation showing CTE metadata and relationships
16
+ * - Comprehensive error handling for circular dependencies
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * const decomposer = new CTEQueryDecomposer({
21
+ * preset: 'postgres',
22
+ * addComments: true,
23
+ * keywordCase: 'upper'
24
+ * });
25
+ *
26
+ * const query = `
27
+ * with users_data as (select * from users),
28
+ * active_users as (select * from users_data where active = true)
29
+ * select * from active_users
30
+ * `;
31
+ *
32
+ * const decomposed = decomposer.decompose(SelectQueryParser.parse(query));
33
+ * // Returns array of DecomposedCTE objects with executable queries
34
+ * ```
35
+ *
36
+ * @public
37
+ */
38
+ export class CTEQueryDecomposer {
39
+ /**
40
+ * Creates a new CTEQueryDecomposer instance
41
+ * @param options - Configuration options extending SqlFormatterOptions
42
+ */
43
+ constructor(options = {}) {
44
+ this.options = options;
45
+ this.dependencyAnalyzer = new CTEDependencyAnalyzer();
46
+ this.cteCollector = new CTECollector();
47
+ this.formatter = new SqlFormatter(options);
48
+ }
49
+ /**
50
+ * Decomposes CTEs in a query into executable standalone queries
51
+ *
52
+ * This method analyzes the query structure to:
53
+ * 1. Collect all CTEs and analyze their dependencies
54
+ * 2. Detect recursive CTEs and handle them separately
55
+ * 3. Generate executable queries for each CTE including required dependencies
56
+ * 4. Add optional comments with metadata (if addComments option is enabled)
57
+ * 5. Format output according to specified formatter options
58
+ *
59
+ * @param query - The SimpleSelectQuery containing CTEs to decompose
60
+ * @returns Array of decomposed CTEs with executable queries, dependencies, and metadata
61
+ * @throws Error if circular dependencies are detected in non-recursive CTEs
62
+ *
63
+ * @example
64
+ * ```typescript
65
+ * const query = SelectQueryParser.parse(`
66
+ * with base as (select * from users),
67
+ * filtered as (select * from base where active = true)
68
+ * select * from filtered
69
+ * `);
70
+ *
71
+ * const result = decomposer.decompose(query);
72
+ * // Returns:
73
+ * // [
74
+ * // { name: 'base', query: 'select * from users', dependencies: [], ... },
75
+ * // { name: 'filtered', query: 'with base as (...) select * from base where active = true', dependencies: ['base'], ... }
76
+ * // ]
77
+ * ```
78
+ */
79
+ decompose(query) {
80
+ const ctes = this.cteCollector.collect(query);
81
+ if (ctes.length === 0) {
82
+ return [];
83
+ }
84
+ const recursiveCTEs = this.findRecursiveCTEs(query, ctes);
85
+ const dependencyGraph = this.dependencyAnalyzer.analyzeDependencies(query);
86
+ this.validateCircularDependencies(recursiveCTEs.length > 0);
87
+ return this.processCTENodes(query, dependencyGraph.nodes, recursiveCTEs);
88
+ }
89
+ /**
90
+ * Synchronizes edited CTEs back into a unified query and re-decomposes them
91
+ *
92
+ * This method resolves inconsistencies between edited CTEs by:
93
+ * 1. Composing the edited CTEs into a unified query
94
+ * 2. Parsing the unified query to ensure consistency
95
+ * 3. Re-decomposing the synchronized query
96
+ *
97
+ * This is useful when CTEs have been edited independently and may have
98
+ * inconsistencies that need to be resolved through a unified composition.
99
+ *
100
+ * @param editedCTEs - Array of edited CTEs that may have inconsistencies
101
+ * @param rootQuery - The main query that uses the CTEs
102
+ * @returns Array of re-decomposed CTEs with resolved inconsistencies
103
+ * @throws Error if the composed query cannot be parsed or contains errors
104
+ *
105
+ * @example
106
+ * ```typescript
107
+ * // After editing CTEs independently, synchronize them
108
+ * const editedCTEs = [
109
+ * { name: 'users_data', query: 'select * from users where active = true' },
110
+ * { name: 'active_users', query: 'select * from users_data where id >= 1000' }
111
+ * ];
112
+ *
113
+ * const synchronized = decomposer.synchronize(editedCTEs, 'select count(*) from active_users');
114
+ * // Returns re-decomposed CTEs with resolved dependencies
115
+ * ```
116
+ */
117
+ synchronize(editedCTEs, rootQuery) {
118
+ if (editedCTEs.length === 0) {
119
+ return [];
120
+ }
121
+ // Use CTEComposer to create a unified query, sharing formatter options
122
+ const composerOptions = Object.assign(Object.assign({}, this.options), {
123
+ // Remove decomposer-specific options
124
+ addComments: undefined });
125
+ const composer = new CTEComposer(composerOptions);
126
+ const unifiedQuery = composer.compose(editedCTEs, rootQuery);
127
+ // Parse the unified query
128
+ const parsedQuery = SelectQueryParser.parse(unifiedQuery);
129
+ // Re-decompose the synchronized query
130
+ return this.decompose(parsedQuery);
131
+ }
132
+ /**
133
+ * Validates circular dependencies for non-recursive CTEs
134
+ * @param hasRecursiveCTEs Whether the query contains recursive CTEs
135
+ * @throws Error if circular dependencies exist in non-recursive CTEs
136
+ */
137
+ validateCircularDependencies(hasRecursiveCTEs) {
138
+ if (this.dependencyAnalyzer.hasCircularDependency() && !hasRecursiveCTEs) {
139
+ throw new Error(CTEQueryDecomposer.ERROR_MESSAGES.CIRCULAR_REFERENCE);
140
+ }
141
+ }
142
+ /**
143
+ * Processes CTE nodes and generates decomposed CTEs
144
+ * @param query Original query
145
+ * @param nodes CTE dependency nodes
146
+ * @param recursiveCTEs List of recursive CTE names
147
+ * @returns Array of decomposed CTEs
148
+ */
149
+ processCTENodes(query, nodes, recursiveCTEs) {
150
+ const result = [];
151
+ for (const node of nodes) {
152
+ const isRecursive = recursiveCTEs.includes(node.name);
153
+ if (isRecursive) {
154
+ result.push(this.createRecursiveCTE(node, query));
155
+ }
156
+ else {
157
+ result.push(this.createStandardCTE(node, nodes));
158
+ }
159
+ }
160
+ return result;
161
+ }
162
+ /**
163
+ * Creates a decomposed CTE for recursive CTEs
164
+ */
165
+ createRecursiveCTE(node, query) {
166
+ const formattedQuery = this.formatter.format(query).formattedSql;
167
+ const finalQuery = this.addCommentsToQuery(formattedQuery, node.name, [], [], true);
168
+ return {
169
+ name: node.name,
170
+ query: finalQuery,
171
+ dependencies: [],
172
+ dependents: [],
173
+ isRecursive: true
174
+ };
175
+ }
176
+ /**
177
+ * Creates a decomposed CTE for standard (non-recursive) CTEs
178
+ */
179
+ createStandardCTE(node, allNodes) {
180
+ const query = this.buildExecutableQuery(node, allNodes);
181
+ const finalQuery = this.addCommentsToQuery(query, node.name, node.dependencies, node.dependents, false);
182
+ return {
183
+ name: node.name,
184
+ query: finalQuery,
185
+ dependencies: [...node.dependencies],
186
+ dependents: [...node.dependents],
187
+ isRecursive: false
188
+ };
189
+ }
190
+ /**
191
+ * Builds an executable query for a CTE by including its dependencies
192
+ */
193
+ buildExecutableQuery(targetNode, allNodes) {
194
+ const requiredCTEs = this.collectRequiredCTEs(targetNode, allNodes);
195
+ if (requiredCTEs.length === 0) {
196
+ // No dependencies, just return the CTE's query
197
+ return this.formatter.format(targetNode.cte.query).formattedSql;
198
+ }
199
+ // Build WITH clause with required CTEs
200
+ const withClause = this.buildWithClause(requiredCTEs);
201
+ const mainQuery = this.formatter.format(targetNode.cte.query).formattedSql;
202
+ return `${withClause} ${mainQuery}`;
203
+ }
204
+ /**
205
+ * Collects all required CTEs for a target CTE in dependency order
206
+ */
207
+ collectRequiredCTEs(targetNode, allNodes) {
208
+ const visited = new Set();
209
+ const result = [];
210
+ const nodeMap = new Map();
211
+ // Build node lookup map
212
+ for (const node of allNodes) {
213
+ nodeMap.set(node.name, node);
214
+ }
215
+ const collectDependencies = (nodeName) => {
216
+ if (visited.has(nodeName))
217
+ return;
218
+ visited.add(nodeName);
219
+ const node = nodeMap.get(nodeName);
220
+ if (!node)
221
+ return;
222
+ // First collect all dependencies
223
+ for (const depName of node.dependencies) {
224
+ collectDependencies(depName);
225
+ }
226
+ // Then add this node (ensuring dependencies come first)
227
+ if (nodeName !== targetNode.name) {
228
+ result.push(node);
229
+ }
230
+ };
231
+ // Collect dependencies for the target node
232
+ for (const depName of targetNode.dependencies) {
233
+ collectDependencies(depName);
234
+ }
235
+ return result;
236
+ }
237
+ /**
238
+ * Builds WITH clause from required CTEs
239
+ */
240
+ buildWithClause(requiredCTEs) {
241
+ if (requiredCTEs.length === 0)
242
+ return "";
243
+ const cteDefinitions = requiredCTEs.map(node => {
244
+ const cteName = node.name;
245
+ const cteQuery = this.formatter.format(node.cte.query).formattedSql;
246
+ return `${cteName} as (${cteQuery})`;
247
+ });
248
+ return `with ${cteDefinitions.join(", ")}`;
249
+ }
250
+ /**
251
+ * Finds recursive CTEs in the query
252
+ * @param query The query to analyze
253
+ * @param ctes All CTEs in the query
254
+ * @returns Array of recursive CTE names
255
+ */
256
+ findRecursiveCTEs(query, ctes) {
257
+ if (!query.withClause || !this.isRecursiveWithClause(query)) {
258
+ return [];
259
+ }
260
+ // For now, assume all CTEs in a RECURSIVE WITH are recursive
261
+ // This is a simplification - in reality, only some CTEs might be recursive
262
+ return ctes.map(cte => this.getCTEName(cte));
263
+ }
264
+ /**
265
+ * Checks if a WITH clause is recursive
266
+ * @param query The query to check
267
+ * @returns true if the query contains WITH RECURSIVE
268
+ */
269
+ isRecursiveWithClause(query) {
270
+ const queryText = this.formatter.format(query).formattedSql.toLowerCase();
271
+ return queryText.includes('with recursive');
272
+ }
273
+ /**
274
+ * Adds comments to the query if addComments option is enabled
275
+ * @param query The query string to add comments to
276
+ * @param cteName The name of the CTE
277
+ * @param dependencies Array of dependency names
278
+ * @param dependents Array of dependent names
279
+ * @param isRecursive Whether this is a recursive CTE
280
+ * @returns Query with comments added if enabled, otherwise original query
281
+ */
282
+ addCommentsToQuery(query, cteName, dependencies, dependents, isRecursive) {
283
+ if (this.options.addComments !== true) {
284
+ return query;
285
+ }
286
+ try {
287
+ // Parse the query to add comments to its AST
288
+ const parsedQuery = SelectQueryParser.parse(query);
289
+ // Generate comment lines
290
+ const comments = this.generateComments(cteName, dependencies, dependents, isRecursive);
291
+ // Add comments to the root query (this should place them at the beginning)
292
+ comments.forEach(comment => {
293
+ CommentEditor.addComment(parsedQuery, comment);
294
+ });
295
+ // Format with comment export enabled
296
+ const formatterWithComments = new SqlFormatter(Object.assign(Object.assign({}, this.options), { exportComment: true }));
297
+ return formatterWithComments.format(parsedQuery).formattedSql;
298
+ }
299
+ catch (error) {
300
+ // If parsing fails, return original query with simple text comments
301
+ console.warn(`${CTEQueryDecomposer.ERROR_MESSAGES.PARSING_FAILED}: ${error}`);
302
+ return this.addTextCommentsToQuery(query, cteName, dependencies, dependents, isRecursive);
303
+ }
304
+ }
305
+ /**
306
+ * Generates comment lines for a CTE
307
+ * @param cteName The name of the CTE
308
+ * @param dependencies Array of dependency names
309
+ * @param dependents Array of dependent names
310
+ * @param isRecursive Whether this is a recursive CTE
311
+ * @returns Array of comment strings
312
+ */
313
+ generateComments(cteName, dependencies, dependents, isRecursive) {
314
+ const { AUTO_GENERATED, ORIGINAL_CTE, DEPENDENCIES, DEPENDENTS, RECURSIVE_TYPE, NONE } = CTEQueryDecomposer.COMMENT_TEXTS;
315
+ const comments = [];
316
+ comments.push(AUTO_GENERATED);
317
+ comments.push(`${ORIGINAL_CTE} ${cteName}`);
318
+ if (isRecursive) {
319
+ comments.push(RECURSIVE_TYPE);
320
+ }
321
+ const depsText = dependencies.length > 0 ? dependencies.join(", ") : NONE;
322
+ comments.push(`${DEPENDENCIES} ${depsText}`);
323
+ const dependentsText = dependents.length > 0 ? dependents.join(", ") : NONE;
324
+ comments.push(`${DEPENDENTS} ${dependentsText}`);
325
+ return comments;
326
+ }
327
+ /**
328
+ * Adds text comments as SQL comments when AST parsing fails
329
+ * @param query Original query
330
+ * @param cteName The name of the CTE
331
+ * @param dependencies Array of dependency names
332
+ * @param dependents Array of dependent names
333
+ * @param isRecursive Whether this is a recursive CTE
334
+ * @returns Query with text comments prepended
335
+ */
336
+ addTextCommentsToQuery(query, cteName, dependencies, dependents, isRecursive) {
337
+ const comments = this.generateComments(cteName, dependencies, dependents, isRecursive);
338
+ const commentLines = comments.map(comment => `-- ${comment}`).join('\n');
339
+ return `${commentLines}\n${query}`;
340
+ }
341
+ /**
342
+ * Extracts the name from a CommonTable
343
+ */
344
+ getCTEName(cte) {
345
+ return cte.aliasExpression.table.name;
346
+ }
347
+ }
348
+ CTEQueryDecomposer.ERROR_MESSAGES = {
349
+ CIRCULAR_REFERENCE: "Circular reference detected in non-recursive CTEs",
350
+ PARSING_FAILED: "Failed to parse query for comment injection"
351
+ };
352
+ CTEQueryDecomposer.COMMENT_TEXTS = {
353
+ AUTO_GENERATED: "Auto-generated by CTE decomposer",
354
+ ORIGINAL_CTE: "Original CTE:",
355
+ DEPENDENCIES: "Dependencies:",
356
+ DEPENDENTS: "Dependents:",
357
+ RECURSIVE_TYPE: "Type: Recursive CTE",
358
+ NONE: "none"
359
+ };
360
+ //# sourceMappingURL=CTEQueryDecomposer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CTEQueryDecomposer.js","sourceRoot":"","sources":["../../../../src/transformers/CTEQueryDecomposer.ts"],"names":[],"mappings":"AAEA,OAAO,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AAC,KAAK,CAAC,IAAI,CAAC;IAC1C,CAAC;;AA5YuB,iCAAc,GAAG;IACrC,kBAAkB,EAAE,mDAAmD;IACvE,cAAc,EAAE,6CAA6C;CACvD,CAAC;AAEa,gCAAa,GAAG;IACpC,cAAc,EAAE,kCAAkC;IAClD,YAAY,EAAE,eAAe;IAC7B,YAAY,EAAE,eAAe;IAC7B,UAAU,EAAE,aAAa;IACzB,cAAc,EAAE,qBAAqB;IACrC,IAAI,EAAE,MAAM;CACN,CAAC"}
@@ -10,33 +10,51 @@ export type PresetName = (typeof VALID_PRESETS)[number];
10
10
  * - 'full-oneline': Entire WITH clause is formatted as one line
11
11
  */
12
12
  export type WithClauseStyle = 'standard' | 'cte-oneline' | 'full-oneline';
13
+ /**
14
+ * Options for SqlFormatter configuration
15
+ * @public
16
+ */
17
+ export interface SqlFormatterOptions {
18
+ /** Database preset for formatting style ('mysql', 'postgres', 'sqlserver', 'sqlite') */
19
+ preset?: PresetName;
20
+ /** Custom identifier escape characters (e.g., {start: '"', end: '"'} for PostgreSQL) */
21
+ identifierEscape?: {
22
+ start: string;
23
+ end: string;
24
+ };
25
+ /** Parameter symbol configuration for SQL parameters */
26
+ parameterSymbol?: string | {
27
+ start: string;
28
+ end: string;
29
+ };
30
+ /** Style for parameter formatting */
31
+ parameterStyle?: 'anonymous' | 'indexed' | 'named';
32
+ /** Number of spaces for indentation */
33
+ indentSize?: number;
34
+ /** Character to use for indentation ('space' or 'tab') */
35
+ indentChar?: IndentCharOption;
36
+ /** Newline character style */
37
+ newline?: NewlineOption;
38
+ /** Case transformation for SQL keywords */
39
+ keywordCase?: 'none' | 'upper' | 'lower';
40
+ /** Style for comma line breaks */
41
+ commaBreak?: CommaBreakStyle;
42
+ /** Style for AND/OR line breaks */
43
+ andBreak?: AndBreakStyle;
44
+ /** Whether to export comments in formatted output */
45
+ exportComment?: boolean;
46
+ /** Whether to only export comments from clause-level keywords */
47
+ strictCommentPlacement?: boolean;
48
+ /** Formatting style for WITH clauses */
49
+ withClauseStyle?: WithClauseStyle;
50
+ }
13
51
  /**
14
52
  * SqlFormatter class combines parsing and printing of SQL queries into a single interface.
15
53
  */
16
54
  export declare class SqlFormatter {
17
55
  private parser;
18
56
  private printer;
19
- constructor(options?: {
20
- preset?: PresetName;
21
- identifierEscape?: {
22
- start: string;
23
- end: string;
24
- };
25
- parameterSymbol?: string | {
26
- start: string;
27
- end: string;
28
- };
29
- parameterStyle?: 'anonymous' | 'indexed' | 'named';
30
- indentSize?: number;
31
- indentChar?: IndentCharOption;
32
- newline?: NewlineOption;
33
- keywordCase?: 'none' | 'upper' | 'lower';
34
- commaBreak?: CommaBreakStyle;
35
- andBreak?: AndBreakStyle;
36
- exportComment?: boolean;
37
- strictCommentPlacement?: boolean;
38
- withClauseStyle?: WithClauseStyle;
39
- }); /**
57
+ constructor(options?: SqlFormatterOptions); /**
40
58
  * Formats a SQL query string with the given parameters.
41
59
  * @param sqlText The SQL query string to format.
42
60
  * @param parameters A dictionary of parameters to replace in the query.
@@ -1 +1 @@
1
- {"version":3,"file":"SqlFormatter.js","sourceRoot":"","sources":["../../../../src/transformers/SqlFormatter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAmB,OAAO,EAAE,MAAM,gCAAgC,CAAC;AAC/F,OAAO,EAAE,UAAU,EAAkC,MAAM,cAAc,CAAC;AAK1E,4CAA4C;AAC5C,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,CAAU,CAAC;AAWnF;;GAEG;AACH,MAAM,OAAO,YAAY;IAIrB,YAAY,UAcR,EAAE;;QAEF,MAAM,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAE1E,IAAI,OAAO,CAAC,MAAM,IAAI,CAAC,YAAY,EAAE,CAAC;YAClC,MAAM,IAAI,KAAK,C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