@tachybase/module-collection 1.6.25 → 1.6.26

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 (110) hide show
  1. package/dist/externalVersion.js +2 -2
  2. package/{LICENSE → dist/node_modules/node-sql-parser/LICENSE} +3 -3
  3. package/dist/node_modules/node-sql-parser/ast/postgresql.ts +2063 -0
  4. package/dist/node_modules/node-sql-parser/build/athena.d.ts +1 -0
  5. package/dist/node_modules/node-sql-parser/build/athena.js +2 -0
  6. package/dist/node_modules/node-sql-parser/build/bigquery.d.ts +1 -0
  7. package/dist/node_modules/node-sql-parser/build/bigquery.js +2 -0
  8. package/dist/node_modules/node-sql-parser/build/db2.d.ts +1 -0
  9. package/dist/node_modules/node-sql-parser/build/db2.js +2 -0
  10. package/dist/node_modules/node-sql-parser/build/flinksql.d.ts +1 -0
  11. package/dist/node_modules/node-sql-parser/build/flinksql.js +2 -0
  12. package/dist/node_modules/node-sql-parser/build/hive.d.ts +1 -0
  13. package/dist/node_modules/node-sql-parser/build/hive.js +2 -0
  14. package/dist/node_modules/node-sql-parser/build/mariadb.d.ts +1 -0
  15. package/dist/node_modules/node-sql-parser/build/mariadb.js +2 -0
  16. package/dist/node_modules/node-sql-parser/build/mysql.d.ts +1 -0
  17. package/dist/node_modules/node-sql-parser/build/mysql.js +2 -0
  18. package/dist/node_modules/node-sql-parser/build/noql.d.ts +1 -0
  19. package/dist/node_modules/node-sql-parser/build/noql.js +2 -0
  20. package/dist/node_modules/node-sql-parser/build/postgresql.d.ts +1 -0
  21. package/dist/node_modules/node-sql-parser/build/postgresql.js +2 -0
  22. package/dist/node_modules/node-sql-parser/build/redshift.d.ts +1 -0
  23. package/dist/node_modules/node-sql-parser/build/redshift.js +2 -0
  24. package/dist/node_modules/node-sql-parser/build/snowflake.d.ts +1 -0
  25. package/dist/node_modules/node-sql-parser/build/snowflake.js +2 -0
  26. package/dist/node_modules/node-sql-parser/build/sqlite.d.ts +1 -0
  27. package/dist/node_modules/node-sql-parser/build/sqlite.js +2 -0
  28. package/dist/node_modules/node-sql-parser/build/transactsql.d.ts +1 -0
  29. package/dist/node_modules/node-sql-parser/build/transactsql.js +2 -0
  30. package/dist/node_modules/node-sql-parser/build/trino.d.ts +1 -0
  31. package/dist/node_modules/node-sql-parser/build/trino.js +2 -0
  32. package/dist/node_modules/node-sql-parser/index.d.ts +1 -0
  33. package/dist/node_modules/node-sql-parser/index.js +1 -0
  34. package/dist/node_modules/node-sql-parser/lib/aggregation.js +42 -0
  35. package/dist/node_modules/node-sql-parser/lib/alter.js +211 -0
  36. package/dist/node_modules/node-sql-parser/lib/analyze.js +40 -0
  37. package/dist/node_modules/node-sql-parser/lib/array-struct.js +60 -0
  38. package/dist/node_modules/node-sql-parser/lib/assign.js +33 -0
  39. package/dist/node_modules/node-sql-parser/lib/binary.js +48 -0
  40. package/dist/node_modules/node-sql-parser/lib/case.js +39 -0
  41. package/dist/node_modules/node-sql-parser/lib/collate.js +37 -0
  42. package/dist/node_modules/node-sql-parser/lib/column.js +259 -0
  43. package/dist/node_modules/node-sql-parser/lib/command.js +306 -0
  44. package/dist/node_modules/node-sql-parser/lib/comment.js +53 -0
  45. package/dist/node_modules/node-sql-parser/lib/constrain.js +49 -0
  46. package/dist/node_modules/node-sql-parser/lib/create.js +496 -0
  47. package/dist/node_modules/node-sql-parser/lib/delete.js +44 -0
  48. package/dist/node_modules/node-sql-parser/lib/exec.js +37 -0
  49. package/dist/node_modules/node-sql-parser/lib/explain.js +27 -0
  50. package/dist/node_modules/node-sql-parser/lib/expr.js +147 -0
  51. package/dist/node_modules/node-sql-parser/lib/func.js +231 -0
  52. package/dist/node_modules/node-sql-parser/lib/index-definition.js +106 -0
  53. package/dist/node_modules/node-sql-parser/lib/insert.js +112 -0
  54. package/dist/node_modules/node-sql-parser/lib/interval.js +29 -0
  55. package/dist/node_modules/node-sql-parser/lib/json.js +36 -0
  56. package/dist/node_modules/node-sql-parser/lib/limit.js +45 -0
  57. package/dist/node_modules/node-sql-parser/lib/over.js +39 -0
  58. package/dist/node_modules/node-sql-parser/lib/parser.all.js +36 -0
  59. package/dist/node_modules/node-sql-parser/lib/parser.js +88 -0
  60. package/dist/node_modules/node-sql-parser/lib/parser.single.js +23 -0
  61. package/dist/node_modules/node-sql-parser/lib/proc.js +39 -0
  62. package/dist/node_modules/node-sql-parser/lib/select.js +138 -0
  63. package/dist/node_modules/node-sql-parser/lib/show.js +89 -0
  64. package/dist/node_modules/node-sql-parser/lib/sql.js +43 -0
  65. package/dist/node_modules/node-sql-parser/lib/tables.js +277 -0
  66. package/dist/node_modules/node-sql-parser/lib/transaction.js +32 -0
  67. package/dist/node_modules/node-sql-parser/lib/union.js +83 -0
  68. package/dist/node_modules/node-sql-parser/lib/update.js +62 -0
  69. package/dist/node_modules/node-sql-parser/lib/util.js +458 -0
  70. package/dist/node_modules/node-sql-parser/lib/window.js +84 -0
  71. package/dist/node_modules/node-sql-parser/lib/with.js +37 -0
  72. package/dist/node_modules/node-sql-parser/package.json +1 -0
  73. package/dist/node_modules/node-sql-parser/types.d.ts +555 -0
  74. package/dist/node_modules/node-sql-parser/umd/athena.umd.d.ts +1 -0
  75. package/dist/node_modules/node-sql-parser/umd/athena.umd.js +2 -0
  76. package/dist/node_modules/node-sql-parser/umd/bigquery.umd.d.ts +1 -0
  77. package/dist/node_modules/node-sql-parser/umd/bigquery.umd.js +2 -0
  78. package/dist/node_modules/node-sql-parser/umd/db2.umd.d.ts +1 -0
  79. package/dist/node_modules/node-sql-parser/umd/db2.umd.js +2 -0
  80. package/dist/node_modules/node-sql-parser/umd/flinksql.umd.d.ts +1 -0
  81. package/dist/node_modules/node-sql-parser/umd/flinksql.umd.js +2 -0
  82. package/dist/node_modules/node-sql-parser/umd/hive.umd.d.ts +1 -0
  83. package/dist/node_modules/node-sql-parser/umd/hive.umd.js +2 -0
  84. package/dist/node_modules/node-sql-parser/umd/index.umd.d.ts +1 -0
  85. package/dist/node_modules/node-sql-parser/umd/index.umd.js +2 -0
  86. package/dist/node_modules/node-sql-parser/umd/mariadb.umd.d.ts +1 -0
  87. package/dist/node_modules/node-sql-parser/umd/mariadb.umd.js +2 -0
  88. package/dist/node_modules/node-sql-parser/umd/mysql.umd.d.ts +1 -0
  89. package/dist/node_modules/node-sql-parser/umd/mysql.umd.js +2 -0
  90. package/dist/node_modules/node-sql-parser/umd/noql.umd.d.ts +1 -0
  91. package/dist/node_modules/node-sql-parser/umd/noql.umd.js +2 -0
  92. package/dist/node_modules/node-sql-parser/umd/postgresql.umd.d.ts +1 -0
  93. package/dist/node_modules/node-sql-parser/umd/postgresql.umd.js +2 -0
  94. package/dist/node_modules/node-sql-parser/umd/redshift.umd.d.ts +1 -0
  95. package/dist/node_modules/node-sql-parser/umd/redshift.umd.js +2 -0
  96. package/dist/node_modules/node-sql-parser/umd/snowflake.umd.d.ts +1 -0
  97. package/dist/node_modules/node-sql-parser/umd/snowflake.umd.js +2 -0
  98. package/dist/node_modules/node-sql-parser/umd/sqlite.umd.d.ts +1 -0
  99. package/dist/node_modules/node-sql-parser/umd/sqlite.umd.js +2 -0
  100. package/dist/node_modules/node-sql-parser/umd/transactsql.umd.d.ts +1 -0
  101. package/dist/node_modules/node-sql-parser/umd/transactsql.umd.js +2 -0
  102. package/dist/node_modules/node-sql-parser/umd/trino.umd.d.ts +1 -0
  103. package/dist/node_modules/node-sql-parser/umd/trino.umd.js +2 -0
  104. package/dist/server/repositories/collection-repository.d.ts +3 -0
  105. package/dist/server/repositories/collection-repository.js +7 -1
  106. package/dist/server/resourcers/sql.d.ts +28 -1
  107. package/dist/server/resourcers/sql.js +121 -4
  108. package/dist/server/resourcers/views.d.ts +14 -0
  109. package/dist/server/server.d.ts +3 -0
  110. package/package.json +6 -4
@@ -0,0 +1,458 @@
1
+ (function (global, factory) {
2
+ if (typeof define === "function" && define.amd) {
3
+ define(["exports", "./column", "./collate"], factory);
4
+ } else if (typeof exports !== "undefined") {
5
+ factory(exports, require("./column"), require("./collate"));
6
+ } else {
7
+ var mod = {
8
+ exports: {}
9
+ };
10
+ factory(mod.exports, global.column, global.collate);
11
+ global.util = mod.exports;
12
+ }
13
+ })(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _column, _collate) {
14
+ "use strict";
15
+
16
+ Object.defineProperty(_exports, "__esModule", {
17
+ value: true
18
+ });
19
+ _exports.DEFAULT_OPT = void 0;
20
+ _exports.arrayStructTypeToSQL = arrayStructTypeToSQL;
21
+ _exports.autoIncrementToSQL = autoIncrementToSQL;
22
+ _exports.columnIdentifierToSql = columnIdentifierToSql;
23
+ _exports.columnOrderListToSQL = columnOrderListToSQL;
24
+ _exports.commentToSQL = commentToSQL;
25
+ _exports.commonKeywordArgsToSQL = commonKeywordArgsToSQL;
26
+ _exports.commonOptionConnector = commonOptionConnector;
27
+ _exports.commonTypeValue = commonTypeValue;
28
+ _exports.connector = connector;
29
+ _exports.createBinaryExpr = createBinaryExpr;
30
+ _exports.createValueExpr = createValueExpr;
31
+ _exports.dataTypeToSQL = dataTypeToSQL;
32
+ _exports.escape = escape;
33
+ _exports.getParserOpt = getParserOpt;
34
+ _exports.hasVal = hasVal;
35
+ _exports.identifierToSql = identifierToSql;
36
+ _exports.literalToSQL = literalToSQL;
37
+ _exports.onPartitionsToSQL = onPartitionsToSQL;
38
+ _exports.replaceParams = replaceParams;
39
+ _exports.returningToSQL = returningToSQL;
40
+ _exports.setParserOpt = setParserOpt;
41
+ _exports.toUpper = toUpper;
42
+ _exports.topToSQL = topToSQL;
43
+ _exports.triggerEventToSQL = triggerEventToSQL;
44
+ // const escapeMap = {
45
+ // '\0' : '\\0',
46
+ // '\'' : '\\\'',
47
+ // '"' : '\\"',
48
+ // '\b' : '\\b',
49
+ // '\n' : '\\n',
50
+ // '\r' : '\\r',
51
+ // '\t' : '\\t',
52
+ // '\x1a' : '\\Z',
53
+ // // '\\' : '\\\\',
54
+ // }
55
+
56
+ const DEFAULT_OPT = _exports.DEFAULT_OPT = {
57
+ database: PARSER_NAME || 'mysql',
58
+ type: 'table',
59
+ trimQuery: true,
60
+ parseOptions: {
61
+ includeLocations: false
62
+ }
63
+ };
64
+ let parserOpt = DEFAULT_OPT;
65
+ function commonOptionConnector(keyword, action, opt) {
66
+ if (!opt) return;
67
+ if (!keyword) return action(opt);
68
+ return `${keyword.toUpperCase()} ${action(opt)}`;
69
+ }
70
+ function connector(keyword, str) {
71
+ if (!str) return;
72
+ return `${keyword.toUpperCase()} ${str}`;
73
+ }
74
+
75
+ /**
76
+ * @param {(Array|boolean|string|number|null)} value
77
+ * @return {Object}
78
+ */
79
+ function createValueExpr(value) {
80
+ const type = typeof value;
81
+ if (Array.isArray(value)) return {
82
+ type: 'expr_list',
83
+ value: value.map(createValueExpr)
84
+ };
85
+ if (value === null) return {
86
+ type: 'null',
87
+ value: null
88
+ };
89
+ switch (type) {
90
+ case 'boolean':
91
+ return {
92
+ type: 'bool',
93
+ value
94
+ };
95
+ case 'string':
96
+ return {
97
+ type: 'string',
98
+ value
99
+ };
100
+ case 'number':
101
+ return {
102
+ type: 'number',
103
+ value
104
+ };
105
+ default:
106
+ throw new Error(`Cannot convert value "${type}" to SQL`);
107
+ }
108
+ }
109
+
110
+ /**
111
+ * @param operator
112
+ * @param left
113
+ * @param right
114
+ * @return {Object}
115
+ */
116
+ function createBinaryExpr(operator, left, right) {
117
+ const expr = {
118
+ operator,
119
+ type: 'binary_expr'
120
+ };
121
+ expr.left = left.type ? left : createValueExpr(left);
122
+ if (operator === 'BETWEEN' || operator === 'NOT BETWEEN') {
123
+ expr.right = {
124
+ type: 'expr_list',
125
+ value: [createValueExpr(right[0]), createValueExpr(right[1])]
126
+ };
127
+ return expr;
128
+ }
129
+ expr.right = right.type ? right : createValueExpr(right);
130
+ return expr;
131
+ }
132
+
133
+ /**
134
+ * Replace param expressions
135
+ *
136
+ * @param {Object} ast - AST object
137
+ * @param {Object} keys - Keys = parameter names, values = parameter values
138
+ * @return {Object} - Newly created AST object
139
+ */
140
+ function replaceParamsInner(ast, keys) {
141
+ Object.keys(ast).filter(key => {
142
+ const value = ast[key];
143
+ return Array.isArray(value) || typeof value === 'object' && value !== null;
144
+ }).forEach(key => {
145
+ const expr = ast[key];
146
+ if (!(typeof expr === 'object' && expr.type === 'param')) return replaceParamsInner(expr, keys);
147
+ if (typeof keys[expr.value] === 'undefined') throw new Error(`no value for parameter :${expr.value} found`);
148
+ ast[key] = createValueExpr(keys[expr.value]);
149
+ return null;
150
+ });
151
+ return ast;
152
+ }
153
+ function escape(str) {
154
+ return str;
155
+ // const res = []
156
+ // for (let i = 0, len = str.length; i < len; ++i) {
157
+ // let char = str[i]
158
+ // const escaped = escapeMap[char]
159
+ // if (escaped) char = escaped
160
+ // res.push(char)
161
+ // }
162
+ // return res.join('')
163
+ }
164
+ function getParserOpt() {
165
+ return parserOpt;
166
+ }
167
+ function setParserOpt(opt) {
168
+ parserOpt = opt;
169
+ }
170
+ function topToSQL(opt) {
171
+ if (!opt) return;
172
+ const {
173
+ value,
174
+ percent,
175
+ parentheses
176
+ } = opt;
177
+ const val = parentheses ? `(${value})` : value;
178
+ const prefix = `TOP ${val}`;
179
+ if (!percent) return prefix;
180
+ return `${prefix} ${percent.toUpperCase()}`;
181
+ }
182
+ function columnIdentifierToSql(ident) {
183
+ const {
184
+ database
185
+ } = getParserOpt();
186
+ if (!ident) return;
187
+ switch (database && database.toLowerCase()) {
188
+ case 'athena':
189
+ case 'db2':
190
+ case 'postgresql':
191
+ case 'redshift':
192
+ case 'snowflake':
193
+ case 'noql':
194
+ case 'trino':
195
+ case 'sqlite':
196
+ return `"${ident}"`;
197
+ case 'transactsql':
198
+ return `[${ident}]`;
199
+ case 'mysql':
200
+ case 'mariadb':
201
+ case 'bigquery':
202
+ default:
203
+ return `\`${ident}\``;
204
+ }
205
+ }
206
+ function identifierToSql(ident, isDual) {
207
+ const {
208
+ database
209
+ } = getParserOpt();
210
+ if (isDual === true) return `'${ident}'`;
211
+ if (!ident) return;
212
+ if (ident === '*') return ident;
213
+ switch (database && database.toLowerCase()) {
214
+ case 'mysql':
215
+ case 'mariadb':
216
+ return `\`${ident}\``;
217
+ case 'athena':
218
+ case 'postgresql':
219
+ case 'redshift':
220
+ case 'snowflake':
221
+ case 'trino':
222
+ case 'noql':
223
+ case 'sqlite':
224
+ return `"${ident}"`;
225
+ case 'transactsql':
226
+ return `[${ident}]`;
227
+ case 'bigquery':
228
+ case 'db2':
229
+ return ident;
230
+ default:
231
+ return `\`${ident}\``;
232
+ }
233
+ }
234
+ function toUpper(val) {
235
+ if (!val) return;
236
+ return val.toUpperCase();
237
+ }
238
+ function hasVal(val) {
239
+ return val;
240
+ }
241
+ function literalToSQL(literal) {
242
+ if (!literal) return;
243
+ let {
244
+ prefix
245
+ } = literal;
246
+ const {
247
+ type,
248
+ parentheses,
249
+ suffix,
250
+ value
251
+ } = literal;
252
+ let str = typeof literal === 'object' ? value : literal;
253
+ switch (type) {
254
+ case 'backticks_quote_string':
255
+ str = `\`${escape(value)}\``;
256
+ break;
257
+ case 'string':
258
+ str = `'${escape(value)}'`;
259
+ break;
260
+ case 'regex_string':
261
+ str = `r"${escape(value)}"`;
262
+ break;
263
+ case 'hex_string':
264
+ str = `X'${escape(value)}'`;
265
+ break;
266
+ case 'full_hex_string':
267
+ str = `0x${escape(value)}`;
268
+ break;
269
+ case 'natural_string':
270
+ str = `N'${escape(value)}'`;
271
+ break;
272
+ case 'bit_string':
273
+ str = `b'${escape(value)}'`;
274
+ break;
275
+ case 'double_quote_string':
276
+ str = `"${escape(value)}"`;
277
+ break;
278
+ case 'single_quote_string':
279
+ str = `'${value}'`;
280
+ break;
281
+ case 'boolean':
282
+ case 'bool':
283
+ str = value ? 'TRUE' : 'FALSE';
284
+ break;
285
+ case 'null':
286
+ str = 'NULL';
287
+ break;
288
+ case 'star':
289
+ str = '*';
290
+ break;
291
+ case 'param':
292
+ str = `${prefix || ':'}${value}`;
293
+ prefix = null;
294
+ break;
295
+ case 'origin':
296
+ str = value.toUpperCase();
297
+ break;
298
+ case 'date':
299
+ case 'datetime':
300
+ case 'time':
301
+ case 'timestamp':
302
+ str = `${type.toUpperCase()} '${value}'`;
303
+ break;
304
+ case 'var_string':
305
+ str = `N'${escape(value)}'`;
306
+ break;
307
+ case 'unicode_string':
308
+ str = `U&'${escape(value)}'`;
309
+ break;
310
+ default:
311
+ break;
312
+ }
313
+ const result = [];
314
+ if (prefix) result.push(toUpper(prefix));
315
+ result.push(str);
316
+ if (suffix) {
317
+ if (typeof suffix === 'string') result.push(suffix);
318
+ if (typeof suffix === 'object') {
319
+ if (suffix.collate) result.push((0, _collate.collateToSQL)(suffix.collate));else result.push(literalToSQL(suffix));
320
+ }
321
+ }
322
+ str = result.join(' ');
323
+ return parentheses ? `(${str})` : str;
324
+ }
325
+ function commonTypeValue(opt) {
326
+ if (!opt) return [];
327
+ const {
328
+ type,
329
+ symbol,
330
+ value
331
+ } = opt;
332
+ return [type.toUpperCase(), symbol, typeof value === 'string' ? value.toUpperCase() : literalToSQL(value)].filter(hasVal);
333
+ }
334
+ function replaceParams(ast, params) {
335
+ return replaceParamsInner(JSON.parse(JSON.stringify(ast)), params);
336
+ }
337
+ function onPartitionsToSQL(expr) {
338
+ const {
339
+ type,
340
+ partitions
341
+ } = expr;
342
+ const result = [toUpper(type), `(${partitions.map(partition => {
343
+ const {
344
+ type: partitionType
345
+ } = partition;
346
+ if (!(partitionType === 'range')) return literalToSQL(partition);
347
+ const {
348
+ start,
349
+ end,
350
+ symbol
351
+ } = partition;
352
+ return `${literalToSQL(start)} ${toUpper(symbol)} ${literalToSQL(end)}`;
353
+ }).join(', ')})`];
354
+ return result.join(' ');
355
+ }
356
+ function dataTypeToSQL(expr) {
357
+ const {
358
+ dataType,
359
+ length,
360
+ parentheses,
361
+ scale,
362
+ suffix
363
+ } = expr;
364
+ let str = '';
365
+ if (length != null) str = scale ? `${length}, ${scale}` : length;
366
+ if (parentheses) str = `(${str})`;
367
+ if (suffix && suffix.length) str += ` ${suffix.join(' ')}`;
368
+ return `${dataType}${str}`;
369
+ }
370
+ function arrayStructTypeToSQL(expr) {
371
+ if (!expr) return;
372
+ const {
373
+ dataType,
374
+ definition,
375
+ anglebracket
376
+ } = expr;
377
+ const dataTypeUpper = toUpper(dataType);
378
+ const isNotArrayOrStruct = dataTypeUpper !== 'ARRAY' && dataTypeUpper !== 'STRUCT';
379
+ if (isNotArrayOrStruct) return dataTypeUpper;
380
+ const result = definition && definition.map(field => {
381
+ const {
382
+ field_name: fieldName,
383
+ field_type: fieldType
384
+ } = field;
385
+ const fieldResult = [fieldName, arrayStructTypeToSQL(fieldType)];
386
+ return fieldResult.filter(hasVal).join(' ');
387
+ }).join(', ');
388
+ return anglebracket ? `${dataTypeUpper}<${result}>` : `${dataTypeUpper} ${result}`;
389
+ }
390
+ function commentToSQL(comment) {
391
+ if (!comment) return;
392
+ const result = [];
393
+ const {
394
+ keyword,
395
+ symbol,
396
+ value
397
+ } = comment;
398
+ result.push(keyword.toUpperCase());
399
+ if (symbol) result.push(symbol);
400
+ result.push(literalToSQL(value));
401
+ return result.join(' ');
402
+ }
403
+ function triggerEventToSQL(events) {
404
+ return events.map(event => {
405
+ const {
406
+ keyword: eventKw,
407
+ args
408
+ } = event;
409
+ const result = [toUpper(eventKw)];
410
+ if (args) {
411
+ const {
412
+ keyword: kwArgs,
413
+ columns
414
+ } = args;
415
+ result.push(toUpper(kwArgs), columns.map(_column.columnRefToSQL).join(', '));
416
+ }
417
+ return result.join(' ');
418
+ }).join(' OR ');
419
+ }
420
+ function returningToSQL(returning) {
421
+ if (!returning) return '';
422
+ const {
423
+ columns
424
+ } = returning;
425
+ return ['RETURNING', columns.map(_column.columnToSQL).filter(hasVal).join(', ')].join(' ');
426
+ }
427
+ function commonKeywordArgsToSQL(kwArgs) {
428
+ if (!kwArgs) return [];
429
+ return [toUpper(kwArgs.keyword), toUpper(kwArgs.args)];
430
+ }
431
+ function autoIncrementToSQL(autoIncrement) {
432
+ if (!autoIncrement) return;
433
+ if (typeof autoIncrement === 'string') {
434
+ const {
435
+ database
436
+ } = getParserOpt();
437
+ switch (database && database.toLowerCase()) {
438
+ case 'sqlite':
439
+ return 'AUTOINCREMENT';
440
+ default:
441
+ return 'AUTO_INCREMENT';
442
+ }
443
+ }
444
+ const {
445
+ keyword,
446
+ seed,
447
+ increment,
448
+ parentheses
449
+ } = autoIncrement;
450
+ let result = toUpper(keyword);
451
+ if (parentheses) result += `(${literalToSQL(seed)}, ${literalToSQL(increment)})`;
452
+ return result;
453
+ }
454
+ function columnOrderListToSQL(columnOrderList) {
455
+ if (!columnOrderList) return;
456
+ return columnOrderList.map(_column.columnOrderToSQL).filter(hasVal).join(', ');
457
+ }
458
+ });
@@ -0,0 +1,84 @@
1
+ (function (global, factory) {
2
+ if (typeof define === "function" && define.amd) {
3
+ define(["exports", "./util", "./expr", "./over"], factory);
4
+ } else if (typeof exports !== "undefined") {
5
+ factory(exports, require("./util"), require("./expr"), require("./over"));
6
+ } else {
7
+ var mod = {
8
+ exports: {}
9
+ };
10
+ factory(mod.exports, global.util, global.expr, global.over);
11
+ global.window = mod.exports;
12
+ }
13
+ })(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _util, _expr, _over) {
14
+ "use strict";
15
+
16
+ Object.defineProperty(_exports, "__esModule", {
17
+ value: true
18
+ });
19
+ _exports.asWindowSpecToSQL = asWindowSpecToSQL;
20
+ _exports.namedWindowExprListToSQL = namedWindowExprListToSQL;
21
+ _exports.namedWindowExprToSQL = namedWindowExprToSQL;
22
+ _exports.windowFuncToSQL = windowFuncToSQL;
23
+ _exports.windowSpecificationToSQL = windowSpecificationToSQL;
24
+ function windowFrameExprToSQL(windowFrameExpr) {
25
+ if (!windowFrameExpr) return;
26
+ const {
27
+ type
28
+ } = windowFrameExpr;
29
+ if (type === 'rows') {
30
+ return [(0, _util.toUpper)(type), (0, _expr.exprToSQL)(windowFrameExpr.expr)].filter(_util.hasVal).join(' ');
31
+ }
32
+ return (0, _expr.exprToSQL)(windowFrameExpr);
33
+ }
34
+ function windowSpecificationToSQL(windowSpec) {
35
+ const {
36
+ name,
37
+ partitionby,
38
+ orderby,
39
+ window_frame_clause: windowFrame
40
+ } = windowSpec;
41
+ const result = [name, (0, _expr.orderOrPartitionByToSQL)(partitionby, 'partition by'), (0, _expr.orderOrPartitionByToSQL)(orderby, 'order by'), windowFrameExprToSQL(windowFrame)];
42
+ return result.filter(_util.hasVal).join(' ');
43
+ }
44
+ function asWindowSpecToSQL(asWindowSpec) {
45
+ if (typeof asWindowSpec === 'string') return asWindowSpec;
46
+ const {
47
+ window_specification: windowSpec
48
+ } = asWindowSpec;
49
+ return `(${windowSpecificationToSQL(windowSpec)})`;
50
+ }
51
+ function namedWindowExprToSQL(namedWindowExpr) {
52
+ const {
53
+ name,
54
+ as_window_specification: asWindowSpec
55
+ } = namedWindowExpr;
56
+ return `${name} AS ${asWindowSpecToSQL(asWindowSpec)}`;
57
+ }
58
+ function namedWindowExprListToSQL(namedWindowExprInfo) {
59
+ const {
60
+ expr
61
+ } = namedWindowExprInfo;
62
+ return expr.map(namedWindowExprToSQL).join(', ');
63
+ }
64
+ function constructArgsList(expr) {
65
+ const {
66
+ args,
67
+ name,
68
+ consider_nulls = '',
69
+ separator = ', '
70
+ } = expr;
71
+ const argsList = args ? (0, _expr.exprToSQL)(args).join(separator) : '';
72
+ // cover Syntax from FN_NAME(...args [RESPECT NULLS]) [RESPECT NULLS]
73
+ const result = [name, '(', argsList, ')', consider_nulls && ' ', consider_nulls];
74
+ return result.filter(_util.hasVal).join('');
75
+ }
76
+ function windowFuncToSQL(expr) {
77
+ const {
78
+ over
79
+ } = expr;
80
+ const str = constructArgsList(expr);
81
+ const overStr = (0, _over.overToSQL)(over);
82
+ return [str, overStr].filter(_util.hasVal).join(' ');
83
+ }
84
+ });
@@ -0,0 +1,37 @@
1
+ (function (global, factory) {
2
+ if (typeof define === "function" && define.amd) {
3
+ define(["exports", "./column", "./expr", "./util"], factory);
4
+ } else if (typeof exports !== "undefined") {
5
+ factory(exports, require("./column"), require("./expr"), require("./util"));
6
+ } else {
7
+ var mod = {
8
+ exports: {}
9
+ };
10
+ factory(mod.exports, global.column, global.expr, global.util);
11
+ global._with = mod.exports;
12
+ }
13
+ })(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _column, _expr, _util) {
14
+ "use strict";
15
+
16
+ Object.defineProperty(_exports, "__esModule", {
17
+ value: true
18
+ });
19
+ _exports.withToSQL = withToSQL;
20
+ /**
21
+ * @param {Array<Object>} withExpr
22
+ */
23
+ function withToSQL(withExpr) {
24
+ if (!withExpr || withExpr.length === 0) return;
25
+ const isRecursive = withExpr[0].recursive ? 'RECURSIVE ' : '';
26
+ const withExprStr = withExpr.map(cte => {
27
+ const {
28
+ name,
29
+ stmt,
30
+ columns
31
+ } = cte;
32
+ const column = Array.isArray(columns) ? `(${columns.map(_column.columnRefToSQL).join(', ')})` : '';
33
+ return `${name.type === 'default' ? (0, _util.identifierToSql)(name.value) : (0, _util.literalToSQL)(name)}${column} AS (${(0, _expr.exprToSQL)(stmt)})`;
34
+ }).join(', ');
35
+ return `WITH ${isRecursive}${withExprStr}`;
36
+ }
37
+ });
@@ -0,0 +1 @@
1
+ {"name":"node-sql-parser","version":"5.3.10","description":"simple node sql parser","main":"index.js","types":"types.d.ts","scripts":{"start":"webpack --config webpack.config.js","build":"npm run lint && npm run compile && webpack --config webpack.config.js --mode production","test":"npm run lint && mochapack --reporter-option maxDiffSize=1000000 \"test/**/*.spec.js\"","lint":"eslint src","compile":"babel src -d lib","coverLocal":"cross-env NODE_ENV=coverage nyc --reporter=lcov --reporter=text npm run test","cover:run":"cross-env NODE_ENV=coverage nyc --reporter=text-lcov npm run test","cover":"npm run cover:run && nyc report --reporter=text-lcov | coveralls","release":"npm run build && npm publish output/prod"},"repository":{"type":"git","url":"git+https://github.com/taozhi8833998/node-sql-parser.git"},"pre-commit":"coverLocal","keywords":["sql","sql-parser","parser","node","nodejs","node-parser","node-sql-parser","ast","sql-ast"],"author":"taozhi8833998 <taozhi8833998@163.com>","files":["ast/","build","lib","umd/","index.d.ts","index.js","index.js.map","LICENSE","package.json","README.md","types.d.ts"],"license":"Apache-2.0","bugs":{"url":"https://github.com/taozhi8833998/node-sql-parser/issues"},"homepage":"https://github.com/taozhi8833998/node-sql-parser#readme","engines":{"node":">=8"},"devDependencies":{"@babel/cli":"^7.5.5","@babel/core":"^7.10.5","@babel/plugin-proposal-object-rest-spread":"^7.5.5","@babel/preset-env":"^7.10.4","@babel/register":"^7.10.5","@types/chai":"^4.1.7","@types/mocha":"^10.0.1","babel-loader":"^8.1.0","browserify":"^17.0.0","chai":"^4.4.1","copy-webpack-plugin":"^6.0.3","coveralls":"^3.0.13","cross-env":"^7.0.2","eslint":"^8.3.0","eslint-config-airbnb-base":"^15.0.0","eslint-config-strict":"^14.0.1","eslint-plugin-filenames":"^1.3.2","eslint-plugin-import":"^2.16.0","filemanager-webpack-plugin":"^3.1.1","istanbul-instrumenter-loader":"^3.0.1","mocha":"^10.0.0","mochapack":"^2.0.3","nyc":"15.1.0","pegjs":"^0.10.0","pegjs-loader":"^0.5.6","pre-commit":"^1.2.2","rimraf":"^5.0.1","source-map-support":"^0.5.19","tinyify":"^4.0.0","vscode-mocha-hmr":"^1.0.0","webpack":"^4.43.0","webpack-cli":"^4.7.0","webpack-node-externals":"^3.0.0"},"nyc":{"include":["src/**/*.js"],"instrument":false,"sourceMap":false},"dependencies":{"@types/pegjs":"^0.10.0","big-integer":"^1.6.48"},"_lastModified":"2026-08-11T06:20:37.334Z"}