@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,152 @@
1
+ (function (global, factory) {
2
+ if (typeof define === "function" && define.amd) {
3
+ define(["exports", "./expr", "./util", "./over"], factory);
4
+ } else if (typeof exports !== "undefined") {
5
+ factory(exports, require("./expr"), require("./util"), require("./over"));
6
+ } else {
7
+ var mod = {
8
+ exports: {}
9
+ };
10
+ factory(mod.exports, global.expr, global.util, global.over);
11
+ global.func = mod.exports;
12
+ }
13
+ })(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _expr, _util, _over) {
14
+ "use strict";
15
+
16
+ Object.defineProperty(_exports, "__esModule", {
17
+ value: true
18
+ });
19
+ _exports.anyValueFuncToSQL = anyValueFuncToSQL;
20
+ _exports.castToSQL = castToSQL;
21
+ _exports.extractFunToSQL = extractFunToSQL;
22
+ _exports.flattenFunToSQL = flattenFunToSQL;
23
+ _exports.funcToSQL = funcToSQL;
24
+ _exports.tablefuncFunToSQL = tablefuncFunToSQL;
25
+ function anyValueFuncToSQL(stmt) {
26
+ const {
27
+ args,
28
+ type,
29
+ over
30
+ } = stmt;
31
+ const {
32
+ expr,
33
+ having
34
+ } = args;
35
+ let sql = `${(0, _util.toUpper)(type)}(${(0, _expr.exprToSQL)(expr)}`;
36
+ if (having) sql = `${sql} HAVING ${(0, _util.toUpper)(having.prefix)} ${(0, _expr.exprToSQL)(having.expr)}`;
37
+ sql = `${sql})`;
38
+ const overStr = (0, _over.overToSQL)(over);
39
+ return [sql, overStr].filter(_util.hasVal).join(' ');
40
+ }
41
+ function arrayDimensionToSymbol(target) {
42
+ if (!target || !target.array) return '';
43
+ switch (target.array) {
44
+ case 'one':
45
+ return '[]';
46
+ case 'two':
47
+ return '[][]';
48
+ }
49
+ }
50
+ function castToSQL(expr) {
51
+ const {
52
+ arrows = [],
53
+ collate,
54
+ target,
55
+ expr: expression,
56
+ keyword,
57
+ symbol,
58
+ as: alias,
59
+ properties = []
60
+ } = expr;
61
+ const {
62
+ length,
63
+ dataType,
64
+ parentheses,
65
+ quoted,
66
+ scale,
67
+ suffix: dataTypeSuffix
68
+ } = target;
69
+ let str = '';
70
+ if (length != null) str = scale ? `${length}, ${scale}` : length;
71
+ if (parentheses) str = `(${str})`;
72
+ if (dataTypeSuffix && dataTypeSuffix.length) str += ` ${dataTypeSuffix.join(' ')}`;
73
+ let prefix = (0, _expr.exprToSQL)(expression);
74
+ let symbolChar = '::';
75
+ let suffix = '';
76
+ if (symbol === 'as') {
77
+ prefix = `${(0, _util.toUpper)(keyword)}(${prefix}`;
78
+ suffix = ')';
79
+ symbolChar = ` ${symbol.toUpperCase()} `;
80
+ }
81
+ suffix += arrows.map((arrow, index) => (0, _util.commonOptionConnector)(arrow, _util.literalToSQL, properties[index])).join(' ');
82
+ if (alias) suffix += ` AS ${(0, _util.identifierToSql)(alias)}`;
83
+ if (collate) suffix += ` ${(0, _util.commonTypeValue)(collate).join(' ')}`;
84
+ const arrayDimension = arrayDimensionToSymbol(target);
85
+ const result = [prefix, symbolChar, quoted, dataType, quoted, arrayDimension, str, suffix];
86
+ return result.filter(_util.hasVal).join('');
87
+ }
88
+ function extractFunToSQL(stmt) {
89
+ const {
90
+ args,
91
+ type
92
+ } = stmt;
93
+ const {
94
+ field,
95
+ cast_type: castType,
96
+ source
97
+ } = args;
98
+ const result = [`${(0, _util.toUpper)(type)}(${(0, _util.toUpper)(field)}`, 'FROM', (0, _util.toUpper)(castType), (0, _expr.exprToSQL)(source)];
99
+ return `${result.filter(_util.hasVal).join(' ')})`;
100
+ }
101
+ function flattenArgToSQL(arg) {
102
+ if (!arg) return '';
103
+ const {
104
+ type,
105
+ symbol,
106
+ value
107
+ } = arg;
108
+ const result = [(0, _util.toUpper)(type), symbol, (0, _expr.exprToSQL)(value)];
109
+ return result.filter(_util.hasVal).join(' ');
110
+ }
111
+ function flattenFunToSQL(stmt) {
112
+ const {
113
+ args,
114
+ type
115
+ } = stmt;
116
+ const keys = ['input', 'path', 'outer', 'recursive', 'mode'];
117
+ const argsStr = keys.map(key => flattenArgToSQL(args[key])).filter(_util.hasVal).join(', ');
118
+ return `${(0, _util.toUpper)(type)}(${argsStr})`;
119
+ }
120
+ function funcToSQL(expr) {
121
+ const {
122
+ args,
123
+ name,
124
+ args_parentheses,
125
+ parentheses,
126
+ over,
127
+ collate,
128
+ suffix
129
+ } = expr;
130
+ const collateStr = (0, _util.commonTypeValue)(collate).join(' ');
131
+ const overStr = (0, _over.overToSQL)(over);
132
+ const suffixStr = (0, _expr.exprToSQL)(suffix);
133
+ if (!args) return [name, overStr].filter(_util.hasVal).join(' ');
134
+ let separator = expr.separator || ', ';
135
+ if ((0, _util.toUpper)(name) === 'TRIM') separator = ' ';
136
+ let str = [name];
137
+ str.push(args_parentheses === false ? ' ' : '(');
138
+ str.push((0, _expr.exprToSQL)(args).join(separator));
139
+ if (args_parentheses !== false) str.push(')');
140
+ str = [str.join(''), suffixStr].filter(_util.hasVal).join(' ');
141
+ return [parentheses ? `(${str})` : str, collateStr, overStr].filter(_util.hasVal).join(' ');
142
+ }
143
+ function tablefuncFunToSQL(expr) {
144
+ const {
145
+ as,
146
+ name,
147
+ args
148
+ } = expr;
149
+ const result = [`${name}(${(0, _expr.exprToSQL)(args).join(', ')})`, 'AS', funcToSQL(as)];
150
+ return result.join(' ');
151
+ }
152
+ });
@@ -0,0 +1,106 @@
1
+ (function (global, factory) {
2
+ if (typeof define === "function" && define.amd) {
3
+ define(["exports", "./util", "./expr"], factory);
4
+ } else if (typeof exports !== "undefined") {
5
+ factory(exports, require("./util"), require("./expr"));
6
+ } else {
7
+ var mod = {
8
+ exports: {}
9
+ };
10
+ factory(mod.exports, global.util, global.expr);
11
+ global.indexDefinition = mod.exports;
12
+ }
13
+ })(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _util, _expr) {
14
+ "use strict";
15
+
16
+ Object.defineProperty(_exports, "__esModule", {
17
+ value: true
18
+ });
19
+ _exports.indexDefinitionToSQL = indexDefinitionToSQL;
20
+ _exports.indexOptionListToSQL = indexOptionListToSQL;
21
+ _exports.indexOptionToSQL = indexOptionToSQL;
22
+ _exports.indexTypeAndOptionToSQL = indexTypeAndOptionToSQL;
23
+ _exports.indexTypeToSQL = indexTypeToSQL;
24
+ function indexTypeToSQL(indexType) {
25
+ if (!indexType) return [];
26
+ const {
27
+ keyword,
28
+ type
29
+ } = indexType;
30
+ return [keyword.toUpperCase(), (0, _util.toUpper)(type)];
31
+ }
32
+ function indexOptionToSQL(indexOpt) {
33
+ if (!indexOpt) return;
34
+ const {
35
+ type,
36
+ expr,
37
+ symbol
38
+ } = indexOpt;
39
+ const upperType = type.toUpperCase();
40
+ const indexOptArray = [];
41
+ indexOptArray.push(upperType);
42
+ switch (upperType) {
43
+ case 'KEY_BLOCK_SIZE':
44
+ if (symbol) indexOptArray.push(symbol);
45
+ indexOptArray.push((0, _util.literalToSQL)(expr));
46
+ break;
47
+ case 'BTREE':
48
+ case 'HASH':
49
+ indexOptArray.length = 0;
50
+ indexOptArray.push(...indexTypeToSQL(indexOpt));
51
+ break;
52
+ case 'WITH PARSER':
53
+ indexOptArray.push(expr);
54
+ break;
55
+ case 'VISIBLE':
56
+ case 'INVISIBLE':
57
+ break;
58
+ case 'COMMENT':
59
+ indexOptArray.shift();
60
+ indexOptArray.push((0, _util.commentToSQL)(indexOpt));
61
+ break;
62
+ case 'DATA_COMPRESSION':
63
+ indexOptArray.push(symbol, (0, _util.toUpper)(expr.value), (0, _util.onPartitionsToSQL)(expr.on));
64
+ break;
65
+ default:
66
+ indexOptArray.push(symbol, (0, _util.literalToSQL)(expr));
67
+ break;
68
+ }
69
+ return indexOptArray.filter(_util.hasVal).join(' ');
70
+ }
71
+ function indexOptionListToSQL(indexOptList) {
72
+ if (!indexOptList) return [];
73
+ return indexOptList.map(indexOptionToSQL);
74
+ }
75
+ function indexTypeAndOptionToSQL(indexDefinition) {
76
+ const {
77
+ constraint_type: constraintType,
78
+ index_type: indexType,
79
+ index_options: indexOptions = [],
80
+ definition,
81
+ on,
82
+ with: withExpr
83
+ } = indexDefinition;
84
+ const dataType = [];
85
+ dataType.push(...indexTypeToSQL(indexType));
86
+ if (definition && definition.length) {
87
+ const definitionSQL = (0, _util.toUpper)(constraintType) === 'CHECK' ? `(${(0, _expr.exprToSQL)(definition[0])})` : `(${definition.map(col => (0, _expr.exprToSQL)(col)).join(', ')})`;
88
+ dataType.push(definitionSQL);
89
+ }
90
+ dataType.push(indexOptionListToSQL(indexOptions).join(' '));
91
+ if (withExpr) dataType.push(`WITH (${indexOptionListToSQL(withExpr).join(', ')})`);
92
+ if (on) dataType.push(`ON [${on}]`);
93
+ return dataType;
94
+ }
95
+ function indexDefinitionToSQL(indexDefinition) {
96
+ const indexSQL = [];
97
+ const {
98
+ keyword,
99
+ index
100
+ } = indexDefinition;
101
+ indexSQL.push((0, _util.toUpper)(keyword));
102
+ indexSQL.push(index);
103
+ indexSQL.push(...indexTypeAndOptionToSQL(indexDefinition));
104
+ return indexSQL.filter(_util.hasVal).join(' ');
105
+ }
106
+ });
@@ -0,0 +1,111 @@
1
+ (function (global, factory) {
2
+ if (typeof define === "function" && define.amd) {
3
+ define(["exports", "./tables", "./expr", "./column", "./util", "./select", "./update"], factory);
4
+ } else if (typeof exports !== "undefined") {
5
+ factory(exports, require("./tables"), require("./expr"), require("./column"), require("./util"), require("./select"), require("./update"));
6
+ } else {
7
+ var mod = {
8
+ exports: {}
9
+ };
10
+ factory(mod.exports, global.tables, global.expr, global.column, global.util, global.select, global.update);
11
+ global.insert = mod.exports;
12
+ }
13
+ })(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _tables, _expr, _column, _util, _select, _update) {
14
+ "use strict";
15
+
16
+ Object.defineProperty(_exports, "__esModule", {
17
+ value: true
18
+ });
19
+ _exports.conflictToSQL = conflictToSQL;
20
+ _exports.insertToSQL = insertToSQL;
21
+ _exports.valuesToSQL = valuesToSQL;
22
+ /**
23
+ * @param {Array} values
24
+ * @return {string}
25
+ */
26
+ function valuesToSQL(values) {
27
+ if (values.type === 'select') return (0, _select.selectToSQL)(values);
28
+ const clauses = values.map(_expr.exprToSQL);
29
+ return `(${clauses.join('), (')})`;
30
+ }
31
+ function partitionToSQL(partition) {
32
+ if (!partition) return '';
33
+ const partitionArr = ['PARTITION', '('];
34
+ if (Array.isArray(partition)) {
35
+ partitionArr.push(partition.map(_util.identifierToSql).join(', '));
36
+ } else {
37
+ const {
38
+ value
39
+ } = partition;
40
+ partitionArr.push(value.map(_expr.exprToSQL).join(', '));
41
+ }
42
+ partitionArr.push(')');
43
+ return partitionArr.filter(_util.hasVal).join('');
44
+ }
45
+ function conflictTargetToSQL(conflictTarget) {
46
+ if (!conflictTarget) return '';
47
+ const {
48
+ type
49
+ } = conflictTarget;
50
+ switch (type) {
51
+ case 'column':
52
+ return `(${conflictTarget.expr.map(_column.columnRefToSQL).join(', ')})`;
53
+ }
54
+ }
55
+ function conflictActionToSQL(conflictAction) {
56
+ const {
57
+ expr,
58
+ keyword
59
+ } = conflictAction;
60
+ const {
61
+ type
62
+ } = expr;
63
+ const result = [(0, _util.toUpper)(keyword)];
64
+ switch (type) {
65
+ case 'origin':
66
+ result.push((0, _util.literalToSQL)(expr));
67
+ break;
68
+ case 'update':
69
+ result.push('UPDATE', (0, _util.commonOptionConnector)('SET', _update.setToSQL, expr.set), (0, _util.commonOptionConnector)('WHERE', _expr.exprToSQL, expr.where));
70
+ break;
71
+ }
72
+ return result.filter(_util.hasVal).join(' ');
73
+ }
74
+ function conflictToSQL(conflict) {
75
+ if (!conflict) return '';
76
+ const {
77
+ action,
78
+ target
79
+ } = conflict;
80
+ const result = [conflictTargetToSQL(target), conflictActionToSQL(action)];
81
+ return result.filter(_util.hasVal).join(' ');
82
+ }
83
+ function insertToSQL(stmt) {
84
+ const {
85
+ table,
86
+ type,
87
+ prefix = 'into',
88
+ columns,
89
+ conflict,
90
+ values,
91
+ where,
92
+ on_duplicate_update: onDuplicateUpdate,
93
+ partition,
94
+ returning,
95
+ set
96
+ } = stmt;
97
+ const {
98
+ keyword,
99
+ set: duplicateSet
100
+ } = onDuplicateUpdate || {};
101
+ const clauses = [(0, _util.toUpper)(type), (0, _util.toUpper)(prefix), (0, _tables.tablesToSQL)(table), partitionToSQL(partition)];
102
+ if (Array.isArray(columns)) clauses.push(`(${columns.map(_util.identifierToSql).join(', ')})`);
103
+ clauses.push((0, _util.commonOptionConnector)(Array.isArray(values) ? 'VALUES' : '', valuesToSQL, values));
104
+ clauses.push((0, _util.commonOptionConnector)('ON CONFLICT', conflictToSQL, conflict));
105
+ clauses.push((0, _util.commonOptionConnector)('SET', _update.setToSQL, set));
106
+ clauses.push((0, _util.commonOptionConnector)('WHERE', _expr.exprToSQL, where));
107
+ clauses.push((0, _util.returningToSQL)(returning));
108
+ clauses.push((0, _util.commonOptionConnector)(keyword, _update.setToSQL, duplicateSet));
109
+ return clauses.filter(_util.hasVal).join(' ');
110
+ }
111
+ });
@@ -0,0 +1,28 @@
1
+ (function (global, factory) {
2
+ if (typeof define === "function" && define.amd) {
3
+ define(["exports", "./util", "./expr"], factory);
4
+ } else if (typeof exports !== "undefined") {
5
+ factory(exports, require("./util"), require("./expr"));
6
+ } else {
7
+ var mod = {
8
+ exports: {}
9
+ };
10
+ factory(mod.exports, global.util, global.expr);
11
+ global.interval = mod.exports;
12
+ }
13
+ })(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _util, _expr) {
14
+ "use strict";
15
+
16
+ Object.defineProperty(_exports, "__esModule", {
17
+ value: true
18
+ });
19
+ _exports.intervalToSQL = intervalToSQL;
20
+ function intervalToSQL(intervalExpr) {
21
+ const {
22
+ expr,
23
+ unit
24
+ } = intervalExpr;
25
+ const result = ['INTERVAL', (0, _expr.exprToSQL)(expr), (0, _util.toUpper)(unit)];
26
+ return result.filter(_util.hasVal).join(' ');
27
+ }
28
+ });
@@ -0,0 +1,28 @@
1
+ (function (global, factory) {
2
+ if (typeof define === "function" && define.amd) {
3
+ define(["exports", "./expr", "./util"], factory);
4
+ } else if (typeof exports !== "undefined") {
5
+ factory(exports, require("./expr"), require("./util"));
6
+ } else {
7
+ var mod = {
8
+ exports: {}
9
+ };
10
+ factory(mod.exports, global.expr, global.util);
11
+ global.json = mod.exports;
12
+ }
13
+ })(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _expr, _util) {
14
+ "use strict";
15
+
16
+ Object.defineProperty(_exports, "__esModule", {
17
+ value: true
18
+ });
19
+ _exports.jsonExprToSQL = jsonExprToSQL;
20
+ function jsonExprToSQL(expr) {
21
+ const {
22
+ keyword,
23
+ expr_list: exprList
24
+ } = expr;
25
+ const result = [(0, _util.toUpper)(keyword), exprList.map(exprItem => (0, _expr.exprToSQL)(exprItem)).join(', ')].join(' ');
26
+ return result;
27
+ }
28
+ });
@@ -0,0 +1,45 @@
1
+ (function (global, factory) {
2
+ if (typeof define === "function" && define.amd) {
3
+ define(["exports", "./util", "./expr"], factory);
4
+ } else if (typeof exports !== "undefined") {
5
+ factory(exports, require("./util"), require("./expr"));
6
+ } else {
7
+ var mod = {
8
+ exports: {}
9
+ };
10
+ factory(mod.exports, global.util, global.expr);
11
+ global.limit = mod.exports;
12
+ }
13
+ })(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _util, _expr) {
14
+ "use strict";
15
+
16
+ Object.defineProperty(_exports, "__esModule", {
17
+ value: true
18
+ });
19
+ _exports.limitToSQL = limitToSQL;
20
+ function composePrefixValSuffix(stmt) {
21
+ if (!stmt) return [];
22
+ return [(0, _util.toUpper)(stmt.prefix), (0, _expr.exprToSQL)(stmt.value), (0, _util.toUpper)(stmt.suffix)];
23
+ }
24
+ function fetchOffsetToSQL(stmt) {
25
+ const {
26
+ fetch,
27
+ offset
28
+ } = stmt;
29
+ const result = [...composePrefixValSuffix(offset), ...composePrefixValSuffix(fetch)];
30
+ return result.filter(_util.hasVal).join(' ');
31
+ }
32
+ function limitOffsetToSQL(limit) {
33
+ const {
34
+ seperator,
35
+ value
36
+ } = limit;
37
+ if (value.length === 1 && seperator === 'offset') return (0, _util.connector)('OFFSET', (0, _expr.exprToSQL)(value[0]));
38
+ return (0, _util.connector)('LIMIT', value.map(_expr.exprToSQL).join(`${seperator === 'offset' ? ' ' : ''}${(0, _util.toUpper)(seperator)} `));
39
+ }
40
+ function limitToSQL(limit) {
41
+ if (!limit) return '';
42
+ if (limit.fetch) return fetchOffsetToSQL(limit);
43
+ return limitOffsetToSQL(limit);
44
+ }
45
+ });
@@ -0,0 +1,39 @@
1
+ (function (global, factory) {
2
+ if (typeof define === "function" && define.amd) {
3
+ define(["exports", "./util", "./expr", "./window"], factory);
4
+ } else if (typeof exports !== "undefined") {
5
+ factory(exports, require("./util"), require("./expr"), require("./window"));
6
+ } else {
7
+ var mod = {
8
+ exports: {}
9
+ };
10
+ factory(mod.exports, global.util, global.expr, global.window);
11
+ global.over = mod.exports;
12
+ }
13
+ })(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _util, _expr, _window) {
14
+ "use strict";
15
+
16
+ Object.defineProperty(_exports, "__esModule", {
17
+ value: true
18
+ });
19
+ _exports.overToSQL = overToSQL;
20
+ function overToSQL(over) {
21
+ if (!over) return;
22
+ const {
23
+ as_window_specification: asWindowSpec,
24
+ expr,
25
+ keyword,
26
+ type,
27
+ parentheses
28
+ } = over;
29
+ const upperType = (0, _util.toUpper)(type);
30
+ if (upperType === 'WINDOW') return `OVER ${(0, _window.asWindowSpecToSQL)(asWindowSpec)}`;
31
+ if (upperType === 'ON UPDATE') {
32
+ let onUpdate = `${(0, _util.toUpper)(type)} ${(0, _util.toUpper)(keyword)}`;
33
+ const args = (0, _expr.exprToSQL)(expr) || [];
34
+ if (parentheses) onUpdate = `${onUpdate}(${args.join(', ')})`;
35
+ return onUpdate;
36
+ }
37
+ throw new Error('unknown over type');
38
+ }
39
+ });
@@ -0,0 +1,33 @@
1
+ (function (global, factory) {
2
+ if (typeof define === "function" && define.amd) {
3
+ define(["exports", "../pegjs/bigquery.pegjs", "../pegjs/db2.pegjs", "../pegjs/hive.pegjs", "../pegjs/mysql.pegjs", "../pegjs/mariadb.pegjs", "../pegjs/postgresql.pegjs", "../pegjs/sqlite.pegjs", "../pegjs/transactsql.pegjs", "../pegjs/flinksql.pegjs", "../pegjs/snowflake.pegjs", "../pegjs/noql.pegjs"], factory);
4
+ } else if (typeof exports !== "undefined") {
5
+ factory(exports, require("../pegjs/bigquery.pegjs"), require("../pegjs/db2.pegjs"), require("../pegjs/hive.pegjs"), require("../pegjs/mysql.pegjs"), require("../pegjs/mariadb.pegjs"), require("../pegjs/postgresql.pegjs"), require("../pegjs/sqlite.pegjs"), require("../pegjs/transactsql.pegjs"), require("../pegjs/flinksql.pegjs"), require("../pegjs/snowflake.pegjs"), require("../pegjs/noql.pegjs"));
6
+ } else {
7
+ var mod = {
8
+ exports: {}
9
+ };
10
+ factory(mod.exports, global.bigquery, global.db2, global.hive, global.mysql, global.mariadb, global.postgresql, global.sqlite, global.transactsql, global.flinksql, global.snowflake, global.noql);
11
+ global.parserAll = mod.exports;
12
+ }
13
+ })(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _bigquery, _db, _hive, _mysql, _mariadb, _postgresql, _sqlite, _transactsql, _flinksql, _snowflake, _noql) {
14
+ "use strict";
15
+
16
+ Object.defineProperty(_exports, "__esModule", {
17
+ value: true
18
+ });
19
+ _exports.default = void 0;
20
+ var _default = _exports.default = {
21
+ bigquery: _bigquery.parse,
22
+ db2: _db.parse,
23
+ hive: _hive.parse,
24
+ mysql: _mysql.parse,
25
+ mariadb: _mariadb.parse,
26
+ postgresql: _postgresql.parse,
27
+ snowflake: _snowflake.parse,
28
+ sqlite: _sqlite.parse,
29
+ transactsql: _transactsql.parse,
30
+ flinksql: _flinksql.parse,
31
+ noql: _noql.parse
32
+ };
33
+ });
@@ -0,0 +1,82 @@
1
+ (function (global, factory) {
2
+ if (typeof define === "function" && define.amd) {
3
+ define(["exports", "./expr", "./parser.all", "./sql", "./util"], factory);
4
+ } else if (typeof exports !== "undefined") {
5
+ factory(exports, require("./expr"), require("./parser.all"), require("./sql"), require("./util"));
6
+ } else {
7
+ var mod = {
8
+ exports: {}
9
+ };
10
+ factory(mod.exports, global.expr, global.parser, global.sql, global.util);
11
+ global.parser = mod.exports;
12
+ }
13
+ })(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _expr, _parser, _sql, _util) {
14
+ "use strict";
15
+
16
+ Object.defineProperty(_exports, "__esModule", {
17
+ value: true
18
+ });
19
+ _exports.default = void 0;
20
+ _parser = _interopRequireDefault(_parser);
21
+ _sql = _interopRequireDefault(_sql);
22
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
+ class Parser {
24
+ astify(sql, opt = _util.DEFAULT_OPT) {
25
+ const astInfo = this.parse(sql, opt);
26
+ return astInfo && astInfo.ast;
27
+ }
28
+ sqlify(ast, opt = _util.DEFAULT_OPT) {
29
+ (0, _util.setParserOpt)(opt);
30
+ return (0, _sql.default)(ast, opt);
31
+ }
32
+ exprToSQL(expr, opt = _util.DEFAULT_OPT) {
33
+ (0, _util.setParserOpt)(opt);
34
+ return (0, _expr.exprToSQL)(expr);
35
+ }
36
+ parse(sql, opt = _util.DEFAULT_OPT) {
37
+ const {
38
+ database = PARSER_NAME || 'mysql'
39
+ } = opt;
40
+ (0, _util.setParserOpt)(opt);
41
+ const typeCase = database.toLowerCase();
42
+ if (_parser.default[typeCase]) return _parser.default[typeCase](sql.trim(), opt.parseOptions || _util.DEFAULT_OPT.parseOptions);
43
+ throw new Error(`${database} is not supported currently`);
44
+ }
45
+ whiteListCheck(sql, whiteList, opt = _util.DEFAULT_OPT) {
46
+ if (!whiteList || whiteList.length === 0) return;
47
+ const {
48
+ type = 'table'
49
+ } = opt;
50
+ if (!this[`${type}List`] || typeof this[`${type}List`] !== 'function') throw new Error(`${type} is not valid check mode`);
51
+ const checkFun = this[`${type}List`].bind(this);
52
+ const authorityList = checkFun(sql, opt);
53
+ let hasAuthority = true;
54
+ let denyInfo = '';
55
+ for (const authority of authorityList) {
56
+ let hasCorrespondingAuthority = false;
57
+ for (const whiteAuthority of whiteList) {
58
+ const regex = new RegExp(whiteAuthority, 'i');
59
+ if (regex.test(authority)) {
60
+ hasCorrespondingAuthority = true;
61
+ break;
62
+ }
63
+ }
64
+ if (!hasCorrespondingAuthority) {
65
+ denyInfo = authority;
66
+ hasAuthority = false;
67
+ break;
68
+ }
69
+ }
70
+ if (!hasAuthority) throw new Error(`authority = '${denyInfo}' is required in ${type} whiteList to execute SQL = '${sql}'`);
71
+ }
72
+ tableList(sql, opt) {
73
+ const astInfo = this.parse(sql, opt);
74
+ return astInfo && astInfo.tableList;
75
+ }
76
+ columnList(sql, opt) {
77
+ const astInfo = this.parse(sql, opt);
78
+ return astInfo && astInfo.columnList;
79
+ }
80
+ }
81
+ var _default = _exports.default = Parser;
82
+ });
@@ -0,0 +1,23 @@
1
+ (function (global, factory) {
2
+ if (typeof define === "function" && define.amd) {
3
+ define(["exports", "../pegjs/mysql.pegjs"], factory);
4
+ } else if (typeof exports !== "undefined") {
5
+ factory(exports, require("../pegjs/mysql.pegjs"));
6
+ } else {
7
+ var mod = {
8
+ exports: {}
9
+ };
10
+ factory(mod.exports, global.mysql);
11
+ global.parserSingle = mod.exports;
12
+ }
13
+ })(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _mysql) {
14
+ "use strict";
15
+
16
+ Object.defineProperty(_exports, "__esModule", {
17
+ value: true
18
+ });
19
+ _exports.default = void 0;
20
+ var _default = _exports.default = {
21
+ [PARSER_NAME]: _mysql.parse
22
+ };
23
+ });