@nocobase/plugin-collection-fdw 2.0.3

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 (155) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +99 -0
  3. package/client.d.ts +2 -0
  4. package/client.js +1 -0
  5. package/dist/client/07d37b2045cf49ac.js +10 -0
  6. package/dist/client/19796e1ee00c3777.js +10 -0
  7. package/dist/client/545679e3c044a8fb.js +10 -0
  8. package/dist/client/components/CreateDatabaseServerAction.d.ts +10 -0
  9. package/dist/client/components/DatabaseServerSelect.d.ts +20 -0
  10. package/dist/client/components/EditDatabaseServerAction.d.ts +10 -0
  11. package/dist/client/components/PreviewFields.d.ts +10 -0
  12. package/dist/client/components/PreviewTable.d.ts +10 -0
  13. package/dist/client/components/RemoteTableSelect.d.ts +10 -0
  14. package/dist/client/components/SyncFieldsAction.d.ts +11 -0
  15. package/dist/client/components/UnSupportFields.d.ts +12 -0
  16. package/dist/client/components/schema.d.ts +19 -0
  17. package/dist/client/dccc3127ba4bb534.js +10 -0
  18. package/dist/client/ff008086e5ac8e5e.js +10 -0
  19. package/dist/client/hooks.d.ts +20 -0
  20. package/dist/client/index.d.ts +13 -0
  21. package/dist/client/index.js +10 -0
  22. package/dist/externalVersion.js +24 -0
  23. package/dist/index.d.ts +9 -0
  24. package/dist/index.js +42 -0
  25. package/dist/locale/de-DE.json +17 -0
  26. package/dist/locale/en-US.json +17 -0
  27. package/dist/locale/es-ES.json +17 -0
  28. package/dist/locale/fr-FR.json +17 -0
  29. package/dist/locale/hu-HU.json +17 -0
  30. package/dist/locale/id-ID.json +17 -0
  31. package/dist/locale/index.d.ts +10 -0
  32. package/dist/locale/index.js +42 -0
  33. package/dist/locale/it-IT.json +17 -0
  34. package/dist/locale/ja-JP.json +17 -0
  35. package/dist/locale/ko-KR.json +17 -0
  36. package/dist/locale/nl-NL.json +17 -0
  37. package/dist/locale/pt-BR.json +17 -0
  38. package/dist/locale/ru-RU.json +18 -0
  39. package/dist/locale/tr-TR.json +17 -0
  40. package/dist/locale/uk-UA.json +17 -0
  41. package/dist/locale/vi-VN.json +17 -0
  42. package/dist/locale/zh-CN.json +17 -0
  43. package/dist/locale/zh-TW.json +17 -0
  44. package/dist/node_modules/node-sql-parser/LICENSE +201 -0
  45. package/dist/node_modules/node-sql-parser/ast/postgresql.ts +1834 -0
  46. package/dist/node_modules/node-sql-parser/build/bigquery.d.ts +1 -0
  47. package/dist/node_modules/node-sql-parser/build/bigquery.js +2 -0
  48. package/dist/node_modules/node-sql-parser/build/db2.d.ts +1 -0
  49. package/dist/node_modules/node-sql-parser/build/db2.js +2 -0
  50. package/dist/node_modules/node-sql-parser/build/flinksql.d.ts +1 -0
  51. package/dist/node_modules/node-sql-parser/build/flinksql.js +2 -0
  52. package/dist/node_modules/node-sql-parser/build/hive.d.ts +1 -0
  53. package/dist/node_modules/node-sql-parser/build/hive.js +2 -0
  54. package/dist/node_modules/node-sql-parser/build/mariadb.d.ts +1 -0
  55. package/dist/node_modules/node-sql-parser/build/mariadb.js +2 -0
  56. package/dist/node_modules/node-sql-parser/build/mysql.d.ts +1 -0
  57. package/dist/node_modules/node-sql-parser/build/mysql.js +2 -0
  58. package/dist/node_modules/node-sql-parser/build/noql.d.ts +1 -0
  59. package/dist/node_modules/node-sql-parser/build/noql.js +2 -0
  60. package/dist/node_modules/node-sql-parser/build/postgresql.d.ts +1 -0
  61. package/dist/node_modules/node-sql-parser/build/postgresql.js +2 -0
  62. package/dist/node_modules/node-sql-parser/build/snowflake.d.ts +1 -0
  63. package/dist/node_modules/node-sql-parser/build/snowflake.js +2 -0
  64. package/dist/node_modules/node-sql-parser/build/sqlite.d.ts +1 -0
  65. package/dist/node_modules/node-sql-parser/build/sqlite.js +2 -0
  66. package/dist/node_modules/node-sql-parser/build/transactsql.d.ts +1 -0
  67. package/dist/node_modules/node-sql-parser/build/transactsql.js +2 -0
  68. package/dist/node_modules/node-sql-parser/index.d.ts +1 -0
  69. package/dist/node_modules/node-sql-parser/index.js +1 -0
  70. package/dist/node_modules/node-sql-parser/lib/aggregation.js +39 -0
  71. package/dist/node_modules/node-sql-parser/lib/alter.js +174 -0
  72. package/dist/node_modules/node-sql-parser/lib/analyze.js +40 -0
  73. package/dist/node_modules/node-sql-parser/lib/array-struct.js +60 -0
  74. package/dist/node_modules/node-sql-parser/lib/assign.js +33 -0
  75. package/dist/node_modules/node-sql-parser/lib/binary.js +46 -0
  76. package/dist/node_modules/node-sql-parser/lib/case.js +39 -0
  77. package/dist/node_modules/node-sql-parser/lib/column.js +221 -0
  78. package/dist/node_modules/node-sql-parser/lib/command.js +299 -0
  79. package/dist/node_modules/node-sql-parser/lib/constrain.js +45 -0
  80. package/dist/node_modules/node-sql-parser/lib/create.js +439 -0
  81. package/dist/node_modules/node-sql-parser/lib/delete.js +42 -0
  82. package/dist/node_modules/node-sql-parser/lib/exec.js +37 -0
  83. package/dist/node_modules/node-sql-parser/lib/expr.js +123 -0
  84. package/dist/node_modules/node-sql-parser/lib/func.js +152 -0
  85. package/dist/node_modules/node-sql-parser/lib/index-definition.js +106 -0
  86. package/dist/node_modules/node-sql-parser/lib/insert.js +111 -0
  87. package/dist/node_modules/node-sql-parser/lib/interval.js +28 -0
  88. package/dist/node_modules/node-sql-parser/lib/json.js +28 -0
  89. package/dist/node_modules/node-sql-parser/lib/limit.js +45 -0
  90. package/dist/node_modules/node-sql-parser/lib/over.js +39 -0
  91. package/dist/node_modules/node-sql-parser/lib/parser.all.js +33 -0
  92. package/dist/node_modules/node-sql-parser/lib/parser.js +82 -0
  93. package/dist/node_modules/node-sql-parser/lib/parser.single.js +23 -0
  94. package/dist/node_modules/node-sql-parser/lib/proc.js +39 -0
  95. package/dist/node_modules/node-sql-parser/lib/select.js +132 -0
  96. package/dist/node_modules/node-sql-parser/lib/show.js +88 -0
  97. package/dist/node_modules/node-sql-parser/lib/sql.js +43 -0
  98. package/dist/node_modules/node-sql-parser/lib/tables.js +211 -0
  99. package/dist/node_modules/node-sql-parser/lib/transaction.js +26 -0
  100. package/dist/node_modules/node-sql-parser/lib/union.js +81 -0
  101. package/dist/node_modules/node-sql-parser/lib/update.js +59 -0
  102. package/dist/node_modules/node-sql-parser/lib/util.js +444 -0
  103. package/dist/node_modules/node-sql-parser/lib/window.js +85 -0
  104. package/dist/node_modules/node-sql-parser/lib/with.js +37 -0
  105. package/dist/node_modules/node-sql-parser/package.json +1 -0
  106. package/dist/node_modules/node-sql-parser/types.d.ts +227 -0
  107. package/dist/node_modules/node-sql-parser/umd/bigquery.umd.d.ts +1 -0
  108. package/dist/node_modules/node-sql-parser/umd/bigquery.umd.js +2 -0
  109. package/dist/node_modules/node-sql-parser/umd/db2.umd.d.ts +1 -0
  110. package/dist/node_modules/node-sql-parser/umd/db2.umd.js +2 -0
  111. package/dist/node_modules/node-sql-parser/umd/flinksql.umd.d.ts +1 -0
  112. package/dist/node_modules/node-sql-parser/umd/flinksql.umd.js +2 -0
  113. package/dist/node_modules/node-sql-parser/umd/hive.umd.d.ts +1 -0
  114. package/dist/node_modules/node-sql-parser/umd/hive.umd.js +2 -0
  115. package/dist/node_modules/node-sql-parser/umd/index.umd.d.ts +1 -0
  116. package/dist/node_modules/node-sql-parser/umd/index.umd.js +2 -0
  117. package/dist/node_modules/node-sql-parser/umd/mariadb.umd.d.ts +1 -0
  118. package/dist/node_modules/node-sql-parser/umd/mariadb.umd.js +2 -0
  119. package/dist/node_modules/node-sql-parser/umd/mysql.umd.d.ts +1 -0
  120. package/dist/node_modules/node-sql-parser/umd/mysql.umd.js +2 -0
  121. package/dist/node_modules/node-sql-parser/umd/noql.umd.d.ts +1 -0
  122. package/dist/node_modules/node-sql-parser/umd/noql.umd.js +2 -0
  123. package/dist/node_modules/node-sql-parser/umd/postgresql.umd.d.ts +1 -0
  124. package/dist/node_modules/node-sql-parser/umd/postgresql.umd.js +2 -0
  125. package/dist/node_modules/node-sql-parser/umd/snowflake.umd.d.ts +1 -0
  126. package/dist/node_modules/node-sql-parser/umd/snowflake.umd.js +2 -0
  127. package/dist/node_modules/node-sql-parser/umd/sqlite.umd.d.ts +1 -0
  128. package/dist/node_modules/node-sql-parser/umd/sqlite.umd.js +2 -0
  129. package/dist/node_modules/node-sql-parser/umd/transactsql.umd.d.ts +1 -0
  130. package/dist/node_modules/node-sql-parser/umd/transactsql.umd.js +2 -0
  131. package/dist/server/bridges/mariadb-to-mariadb.d.ts +3 -0
  132. package/dist/server/bridges/mariadb-to-mariadb.js +38 -0
  133. package/dist/server/bridges/mysql-to-mysql.d.ts +13 -0
  134. package/dist/server/bridges/mysql-to-mysql.js +117 -0
  135. package/dist/server/bridges/mysql-to-pg.d.ts +8 -0
  136. package/dist/server/bridges/mysql-to-pg.js +9 -0
  137. package/dist/server/bridges/pg-to-pg.d.ts +21 -0
  138. package/dist/server/bridges/pg-to-pg.js +137 -0
  139. package/dist/server/bridges/remote-local-bridge.d.ts +57 -0
  140. package/dist/server/bridges/remote-local-bridge.js +73 -0
  141. package/dist/server/collections/database-server-collection.d.ts +10 -0
  142. package/dist/server/collections/database-server-collection.js +54 -0
  143. package/dist/server/foreign-data-collection.d.ts +22 -0
  144. package/dist/server/foreign-data-collection.js +118 -0
  145. package/dist/server/index.d.ts +9 -0
  146. package/dist/server/index.js +42 -0
  147. package/dist/server/models/database-server.d.ts +29 -0
  148. package/dist/server/models/database-server.js +226 -0
  149. package/dist/server/plugin.d.ts +14 -0
  150. package/dist/server/plugin.js +111 -0
  151. package/dist/server/resourcers/tables.d.ts +17 -0
  152. package/dist/server/resourcers/tables.js +181 -0
  153. package/package.json +43 -0
  154. package/server.d.ts +2 -0
  155. package/server.js +1 -0
@@ -0,0 +1,444 @@
1
+ (function (global, factory) {
2
+ if (typeof define === "function" && define.amd) {
3
+ define(["exports", "./column"], factory);
4
+ } else if (typeof exports !== "undefined") {
5
+ factory(exports, require("./column"));
6
+ } else {
7
+ var mod = {
8
+ exports: {}
9
+ };
10
+ factory(mod.exports, global.column);
11
+ global.util = mod.exports;
12
+ }
13
+ })(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _column) {
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
+ parseOptions: {}
60
+ };
61
+ let parserOpt = DEFAULT_OPT;
62
+ function commonOptionConnector(keyword, action, opt) {
63
+ if (!opt) return;
64
+ if (!keyword) return action(opt);
65
+ return `${keyword.toUpperCase()} ${action(opt)}`;
66
+ }
67
+ function connector(keyword, str) {
68
+ if (!str) return;
69
+ return `${keyword.toUpperCase()} ${str}`;
70
+ }
71
+
72
+ /**
73
+ * @param {(Array|boolean|string|number|null)} value
74
+ * @return {Object}
75
+ */
76
+ function createValueExpr(value) {
77
+ const type = typeof value;
78
+ if (Array.isArray(value)) return {
79
+ type: 'expr_list',
80
+ value: value.map(createValueExpr)
81
+ };
82
+ if (value === null) return {
83
+ type: 'null',
84
+ value: null
85
+ };
86
+ switch (type) {
87
+ case 'boolean':
88
+ return {
89
+ type: 'bool',
90
+ value
91
+ };
92
+ case 'string':
93
+ return {
94
+ type: 'string',
95
+ value
96
+ };
97
+ case 'number':
98
+ return {
99
+ type: 'number',
100
+ value
101
+ };
102
+ default:
103
+ throw new Error(`Cannot convert value "${type}" to SQL`);
104
+ }
105
+ }
106
+
107
+ /**
108
+ * @param operator
109
+ * @param left
110
+ * @param right
111
+ * @return {Object}
112
+ */
113
+ function createBinaryExpr(operator, left, right) {
114
+ const expr = {
115
+ operator,
116
+ type: 'binary_expr'
117
+ };
118
+ expr.left = left.type ? left : createValueExpr(left);
119
+ if (operator === 'BETWEEN' || operator === 'NOT BETWEEN') {
120
+ expr.right = {
121
+ type: 'expr_list',
122
+ value: [createValueExpr(right[0]), createValueExpr(right[1])]
123
+ };
124
+ return expr;
125
+ }
126
+ expr.right = right.type ? right : createValueExpr(right);
127
+ return expr;
128
+ }
129
+
130
+ /**
131
+ * Replace param expressions
132
+ *
133
+ * @param {Object} ast - AST object
134
+ * @param {Object} keys - Keys = parameter names, values = parameter values
135
+ * @return {Object} - Newly created AST object
136
+ */
137
+ function replaceParamsInner(ast, keys) {
138
+ Object.keys(ast).filter(key => {
139
+ const value = ast[key];
140
+ return Array.isArray(value) || typeof value === 'object' && value !== null;
141
+ }).forEach(key => {
142
+ const expr = ast[key];
143
+ if (!(typeof expr === 'object' && expr.type === 'param')) return replaceParamsInner(expr, keys);
144
+ if (typeof keys[expr.value] === 'undefined') throw new Error(`no value for parameter :${expr.value} found`);
145
+ ast[key] = createValueExpr(keys[expr.value]);
146
+ return null;
147
+ });
148
+ return ast;
149
+ }
150
+ function escape(str) {
151
+ return str;
152
+ // const res = []
153
+ // for (let i = 0, len = str.length; i < len; ++i) {
154
+ // let char = str[i]
155
+ // const escaped = escapeMap[char]
156
+ // if (escaped) char = escaped
157
+ // res.push(char)
158
+ // }
159
+ // return res.join('')
160
+ }
161
+ function getParserOpt() {
162
+ return parserOpt;
163
+ }
164
+ function setParserOpt(opt) {
165
+ parserOpt = opt;
166
+ }
167
+ function topToSQL(opt) {
168
+ if (!opt) return;
169
+ const {
170
+ value,
171
+ percent,
172
+ parentheses
173
+ } = opt;
174
+ const val = parentheses ? `(${value})` : value;
175
+ const prefix = `TOP ${val}`;
176
+ if (!percent) return prefix;
177
+ return `${prefix} ${percent.toUpperCase()}`;
178
+ }
179
+ function columnIdentifierToSql(ident) {
180
+ const {
181
+ database
182
+ } = getParserOpt();
183
+ if (!ident) return;
184
+ switch (database && database.toLowerCase()) {
185
+ case 'postgresql':
186
+ case 'db2':
187
+ case 'snowflake':
188
+ case 'noql':
189
+ return `"${ident}"`;
190
+ case 'transactsql':
191
+ return `[${ident}]`;
192
+ case 'mysql':
193
+ case 'mariadb':
194
+ case 'bigquery':
195
+ default:
196
+ return `\`${ident}\``;
197
+ }
198
+ }
199
+ function identifierToSql(ident, isDual) {
200
+ const {
201
+ database
202
+ } = getParserOpt();
203
+ if (isDual === true) return `'${ident}'`;
204
+ if (!ident) return;
205
+ if (ident === '*') return ident;
206
+ switch (database && database.toLowerCase()) {
207
+ case 'mysql':
208
+ case 'mariadb':
209
+ case 'sqlite':
210
+ return `\`${ident}\``;
211
+ case 'postgresql':
212
+ case 'snowflake':
213
+ case 'noql':
214
+ return `"${ident}"`;
215
+ case 'transactsql':
216
+ return `[${ident}]`;
217
+ case 'bigquery':
218
+ case 'db2':
219
+ return ident;
220
+ default:
221
+ return `\`${ident}\``;
222
+ }
223
+ }
224
+ function commonTypeValue(opt) {
225
+ const result = [];
226
+ if (!opt) return result;
227
+ const {
228
+ type,
229
+ symbol,
230
+ value
231
+ } = opt;
232
+ result.push(type.toUpperCase());
233
+ if (symbol) result.push(symbol);
234
+ result.push(value.toUpperCase());
235
+ return result;
236
+ }
237
+ function toUpper(val) {
238
+ if (!val) return;
239
+ return val.toUpperCase();
240
+ }
241
+ function hasVal(val) {
242
+ return val;
243
+ }
244
+ function literalToSQL(literal) {
245
+ if (!literal) return;
246
+ let {
247
+ prefix
248
+ } = literal;
249
+ const {
250
+ type,
251
+ parentheses,
252
+ suffix,
253
+ value
254
+ } = literal;
255
+ let str = typeof literal === 'string' ? literal : value;
256
+ switch (type) {
257
+ case 'backticks_quote_string':
258
+ str = `\`${escape(value)}\``;
259
+ break;
260
+ case 'string':
261
+ str = `'${escape(value)}'`;
262
+ break;
263
+ case 'regex_string':
264
+ str = `r"${escape(value)}"`;
265
+ break;
266
+ case 'hex_string':
267
+ str = `X'${escape(value)}'`;
268
+ break;
269
+ case 'full_hex_string':
270
+ str = `0x${escape(value)}`;
271
+ break;
272
+ case 'natural_string':
273
+ str = `N'${escape(value)}'`;
274
+ break;
275
+ case 'bit_string':
276
+ str = `b'${escape(value)}'`;
277
+ break;
278
+ case 'double_quote_string':
279
+ str = `"${escape(value)}"`;
280
+ break;
281
+ case 'single_quote_string':
282
+ str = `'${value}'`;
283
+ break;
284
+ case 'boolean':
285
+ case 'bool':
286
+ str = value ? 'TRUE' : 'FALSE';
287
+ break;
288
+ case 'null':
289
+ str = 'NULL';
290
+ break;
291
+ case 'star':
292
+ str = '*';
293
+ break;
294
+ case 'param':
295
+ str = `${prefix || ':'}${value}`;
296
+ prefix = null;
297
+ break;
298
+ case 'origin':
299
+ str = value.toUpperCase();
300
+ break;
301
+ case 'date':
302
+ case 'datetime':
303
+ case 'time':
304
+ case 'timestamp':
305
+ str = `${type.toUpperCase()} '${value}'`;
306
+ break;
307
+ case 'var_string':
308
+ str = `N'${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) result.push(typeof suffix === 'object' && suffix.collate ? commonTypeValue(suffix.collate).join(' ') : toUpper(suffix));
317
+ str = result.join(' ');
318
+ return parentheses ? `(${str})` : str;
319
+ }
320
+ function replaceParams(ast, params) {
321
+ return replaceParamsInner(JSON.parse(JSON.stringify(ast)), params);
322
+ }
323
+ function onPartitionsToSQL(expr) {
324
+ const {
325
+ type,
326
+ partitions
327
+ } = expr;
328
+ const result = [toUpper(type), `(${partitions.map(partition => {
329
+ const {
330
+ type: partitionType
331
+ } = partition;
332
+ if (!(partitionType === 'range')) return literalToSQL(partition);
333
+ const {
334
+ start,
335
+ end,
336
+ symbol
337
+ } = partition;
338
+ return `${literalToSQL(start)} ${toUpper(symbol)} ${literalToSQL(end)}`;
339
+ }).join(', ')})`];
340
+ return result.join(' ');
341
+ }
342
+ function dataTypeToSQL(expr) {
343
+ const {
344
+ dataType,
345
+ length,
346
+ parentheses,
347
+ scale,
348
+ suffix
349
+ } = expr;
350
+ let str = '';
351
+ if (length != null) str = scale ? `${length}, ${scale}` : length;
352
+ if (parentheses) str = `(${str})`;
353
+ if (suffix && suffix.length) str += ` ${suffix.join(' ')}`;
354
+ return `${dataType}${str}`;
355
+ }
356
+ function arrayStructTypeToSQL(expr) {
357
+ if (!expr) return;
358
+ const {
359
+ dataType,
360
+ definition,
361
+ anglebracket
362
+ } = expr;
363
+ const dataTypeUpper = toUpper(dataType);
364
+ const isNotArrayOrStruct = dataTypeUpper !== 'ARRAY' && dataTypeUpper !== 'STRUCT';
365
+ if (isNotArrayOrStruct) return dataTypeUpper;
366
+ const result = definition && definition.map(field => {
367
+ const {
368
+ field_name: fieldName,
369
+ field_type: fieldType
370
+ } = field;
371
+ const fieldResult = [fieldName, arrayStructTypeToSQL(fieldType)];
372
+ return fieldResult.filter(hasVal).join(' ');
373
+ }).join(', ');
374
+ return anglebracket ? `${dataTypeUpper}<${result}>` : `${dataTypeUpper} ${result}`;
375
+ }
376
+ function commentToSQL(comment) {
377
+ if (!comment) return;
378
+ const result = [];
379
+ const {
380
+ keyword,
381
+ symbol,
382
+ value
383
+ } = comment;
384
+ result.push(keyword.toUpperCase());
385
+ if (symbol) result.push(symbol);
386
+ result.push(literalToSQL(value));
387
+ return result.join(' ');
388
+ }
389
+ function triggerEventToSQL(events) {
390
+ return events.map(event => {
391
+ const {
392
+ keyword: eventKw,
393
+ args
394
+ } = event;
395
+ const result = [toUpper(eventKw)];
396
+ if (args) {
397
+ const {
398
+ keyword: kwArgs,
399
+ columns
400
+ } = args;
401
+ result.push(toUpper(kwArgs), columns.map(_column.columnRefToSQL).join(', '));
402
+ }
403
+ return result.join(' ');
404
+ }).join(' OR ');
405
+ }
406
+ function returningToSQL(returning) {
407
+ if (!returning) return '';
408
+ const {
409
+ columns
410
+ } = returning;
411
+ return ['RETURNING', columns.map(_column.columnToSQL).filter(hasVal).join(', ')].join(' ');
412
+ }
413
+ function commonKeywordArgsToSQL(kwArgs) {
414
+ if (!kwArgs) return [];
415
+ return [toUpper(kwArgs.keyword), toUpper(kwArgs.args)];
416
+ }
417
+ function autoIncrementToSQL(autoIncrement) {
418
+ if (!autoIncrement) return;
419
+ if (typeof autoIncrement === 'string') {
420
+ const {
421
+ database
422
+ } = getParserOpt();
423
+ switch (database && database.toLowerCase()) {
424
+ case 'sqlite':
425
+ return 'AUTOINCREMENT';
426
+ default:
427
+ return 'AUTO_INCREMENT';
428
+ }
429
+ }
430
+ const {
431
+ keyword,
432
+ seed,
433
+ increment,
434
+ parentheses
435
+ } = autoIncrement;
436
+ let result = toUpper(keyword);
437
+ if (parentheses) result += `(${literalToSQL(seed)}, ${literalToSQL(increment)})`;
438
+ return result;
439
+ }
440
+ function columnOrderListToSQL(columnOrderList) {
441
+ if (!columnOrderList) return;
442
+ return columnOrderList.map(_column.columnOrderToSQL).filter(hasVal).join(', ');
443
+ }
444
+ });
@@ -0,0 +1,85 @@
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 windowSpecificationToSQL(windowSpec) {
25
+ const {
26
+ name,
27
+ partitionby,
28
+ orderby,
29
+ window_frame_clause: windowFrame
30
+ } = windowSpec;
31
+ const result = [name, (0, _expr.orderOrPartitionByToSQL)(partitionby, 'partition by'), (0, _expr.orderOrPartitionByToSQL)(orderby, 'order by'), (0, _util.toUpper)(windowFrame)];
32
+ return result.filter(_util.hasVal).join(' ');
33
+ }
34
+ function asWindowSpecToSQL(asWindowSpec) {
35
+ if (typeof asWindowSpec === 'string') return asWindowSpec;
36
+ const {
37
+ window_specification: windowSpec
38
+ } = asWindowSpec;
39
+ return `(${windowSpecificationToSQL(windowSpec)})`;
40
+ }
41
+ function namedWindowExprToSQL(namedWindowExpr) {
42
+ const {
43
+ name,
44
+ as_window_specification: asWindowSpec
45
+ } = namedWindowExpr;
46
+ return `${name} AS ${asWindowSpecToSQL(asWindowSpec)}`;
47
+ }
48
+ function namedWindowExprListToSQL(namedWindowExprInfo) {
49
+ const {
50
+ expr
51
+ } = namedWindowExprInfo;
52
+ return expr.map(namedWindowExprToSQL).join(', ');
53
+ }
54
+ function isConsiderNullsInArgs(fnName) {
55
+ // position of IGNORE/RESPECT NULLS varies by function
56
+ switch ((0, _util.toUpper)(fnName)) {
57
+ case 'NTH_VALUE':
58
+ case 'LEAD':
59
+ case 'LAG':
60
+ return false;
61
+ default:
62
+ return true;
63
+ }
64
+ }
65
+ function constructArgsList(expr) {
66
+ const {
67
+ args,
68
+ name,
69
+ consider_nulls = ''
70
+ } = expr;
71
+ const argsList = args ? (0, _expr.exprToSQL)(args).join(', ') : '';
72
+ // cover Syntax from FN_NAME(...args [RESPECT NULLS]) [RESPECT NULLS]
73
+ const isConsidernulls = isConsiderNullsInArgs(name);
74
+ const result = [name, '(', argsList, !isConsidernulls && ')', consider_nulls && ' ', consider_nulls, isConsidernulls && ')'];
75
+ return result.filter(_util.hasVal).join('');
76
+ }
77
+ function windowFuncToSQL(expr) {
78
+ const {
79
+ over
80
+ } = expr;
81
+ const str = constructArgsList(expr);
82
+ const overStr = (0, _over.overToSQL)(over);
83
+ return [str, overStr].filter(_util.hasVal).join(' ');
84
+ }
85
+ });
@@ -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":"4.18.0","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 \"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":{"big-integer":"^1.6.48"},"_lastModified":"2026-02-24T16:56:57.553Z"}