@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,39 @@
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.aggregation = 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.aggrToSQL = aggrToSQL;
20
+ function aggrToSQL(expr) {
21
+ /** @type {Object} */
22
+ const {
23
+ args,
24
+ filter,
25
+ over,
26
+ within_group_orderby
27
+ } = expr;
28
+ let str = (0, _expr.exprToSQL)(args.expr);
29
+ const fnName = expr.name;
30
+ const overStr = (0, _over.overToSQL)(over);
31
+ const separator = ' ';
32
+ if (args.distinct) str = ['DISTINCT', str].join(separator);
33
+ if (args.orderby) str = `${str} ${(0, _expr.orderOrPartitionByToSQL)(args.orderby, 'order by')}`;
34
+ if (args.separator) str = [str, (0, _util.toUpper)(args.separator.keyword), (0, _util.literalToSQL)(args.separator.value)].filter(_util.hasVal).join(' ');
35
+ const withinGroup = within_group_orderby ? `WITHIN GROUP (${(0, _expr.orderOrPartitionByToSQL)(within_group_orderby, 'order by')})` : '';
36
+ const filterStr = filter ? `FILTER (WHERE ${(0, _expr.exprToSQL)(filter.where)})` : '';
37
+ return [`${fnName}(${str})`, withinGroup, overStr, filterStr].filter(_util.hasVal).join(' ');
38
+ }
39
+ });
@@ -0,0 +1,174 @@
1
+ (function (global, factory) {
2
+ if (typeof define === "function" && define.amd) {
3
+ define(["exports", "./column", "./create", "./index-definition", "./tables", "./expr", "./select", "./util"], factory);
4
+ } else if (typeof exports !== "undefined") {
5
+ factory(exports, require("./column"), require("./create"), require("./index-definition"), require("./tables"), require("./expr"), require("./select"), require("./util"));
6
+ } else {
7
+ var mod = {
8
+ exports: {}
9
+ };
10
+ factory(mod.exports, global.column, global.create, global.indexDefinition, global.tables, global.expr, global.select, global.util);
11
+ global.alter = mod.exports;
12
+ }
13
+ })(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _column, _create, _indexDefinition, _tables, _expr, _select, _util) {
14
+ "use strict";
15
+
16
+ Object.defineProperty(_exports, "__esModule", {
17
+ value: true
18
+ });
19
+ _exports.alterArgsToSQL = alterArgsToSQL;
20
+ _exports.alterExprToSQL = alterExprToSQL;
21
+ _exports.alterToSQL = alterToSQL;
22
+ function alterExprToSQL(expr) {
23
+ if (!expr) return '';
24
+ const {
25
+ action,
26
+ create_definitions: createDefinition,
27
+ first_after: firstAfter,
28
+ if_not_exists: ifNotExists,
29
+ keyword,
30
+ old_column: oldColumn,
31
+ prefix,
32
+ resource,
33
+ symbol
34
+ } = expr;
35
+ let name = '';
36
+ let dataType = [];
37
+ switch (resource) {
38
+ case 'column':
39
+ dataType = [(0, _column.columnDefinitionToSQL)(expr)];
40
+ break;
41
+ case 'index':
42
+ dataType = (0, _indexDefinition.indexTypeAndOptionToSQL)(expr);
43
+ name = expr[resource];
44
+ break;
45
+ case 'table':
46
+ case 'schema':
47
+ name = (0, _util.identifierToSql)(expr[resource]);
48
+ break;
49
+ case 'aggregate':
50
+ case 'function':
51
+ case 'domain':
52
+ case 'type':
53
+ name = (0, _util.identifierToSql)(expr[resource]);
54
+ break;
55
+ case 'algorithm':
56
+ case 'lock':
57
+ case 'table-option':
58
+ name = [symbol, (0, _util.toUpper)(expr[resource])].filter(_util.hasVal).join(' ');
59
+ break;
60
+ case 'constraint':
61
+ name = (0, _util.identifierToSql)(expr[resource]);
62
+ dataType = [(0, _create.createDefinitionToSQL)(createDefinition)];
63
+ break;
64
+ case 'key':
65
+ name = (0, _util.identifierToSql)(expr[resource]);
66
+ break;
67
+ default:
68
+ name = [symbol, expr[resource]].filter(val => val !== null).join(' ');
69
+ break;
70
+ }
71
+ const alterArray = [(0, _util.toUpper)(action), (0, _util.toUpper)(keyword), (0, _util.toUpper)(ifNotExists), oldColumn && (0, _column.columnRefToSQL)(oldColumn), (0, _util.toUpper)(prefix), name && name.trim(), dataType.filter(_util.hasVal).join(' '), firstAfter && `${(0, _util.toUpper)(firstAfter.keyword)} ${(0, _column.columnRefToSQL)(firstAfter.column)}`];
72
+ return alterArray.filter(_util.hasVal).join(' ');
73
+ }
74
+ function alterTableToSQL(stmt) {
75
+ const {
76
+ type,
77
+ table,
78
+ expr = []
79
+ } = stmt;
80
+ const action = (0, _util.toUpper)(type);
81
+ const tableName = (0, _tables.tablesToSQL)(table);
82
+ const exprList = expr.map(_expr.exprToSQL);
83
+ const result = [action, 'TABLE', tableName, exprList.join(', ')];
84
+ return result.filter(_util.hasVal).join(' ');
85
+ }
86
+ function alterViewToSQL(stmt) {
87
+ const {
88
+ type,
89
+ columns,
90
+ attributes,
91
+ select,
92
+ view,
93
+ with: withExpr
94
+ } = stmt;
95
+ const action = (0, _util.toUpper)(type);
96
+ const viewName = (0, _tables.tableToSQL)(view);
97
+ const result = [action, 'VIEW', viewName];
98
+ if (columns) result.push(`(${columns.map(_column.columnRefToSQL).join(', ')})`);
99
+ if (attributes) result.push(`WITH ${attributes.map(_util.toUpper).join(', ')}`);
100
+ result.push('AS', (0, _select.selectToSQL)(select));
101
+ if (withExpr) result.push((0, _util.toUpper)(withExpr));
102
+ return result.filter(_util.hasVal).join(' ');
103
+ }
104
+ function alterArgsToSQL(arg) {
105
+ const defaultSQL = arg.default && [(0, _util.toUpper)(arg.default.keyword), (0, _expr.exprToSQL)(arg.default.value)].join(' ');
106
+ return [(0, _util.toUpper)(arg.mode), arg.name, (0, _util.dataTypeToSQL)(arg.type), defaultSQL].filter(_util.hasVal).join(' ');
107
+ }
108
+ function alterSchemaToSQL(stmt) {
109
+ const {
110
+ expr,
111
+ keyword,
112
+ schema,
113
+ type
114
+ } = stmt;
115
+ const result = [(0, _util.toUpper)(type), (0, _util.toUpper)(keyword), (0, _util.identifierToSql)(schema), alterExprToSQL(expr)];
116
+ return result.filter(_util.hasVal).join(' ');
117
+ }
118
+ function alterDomainTypeToSQL(stmt) {
119
+ const {
120
+ expr,
121
+ keyword,
122
+ name,
123
+ type
124
+ } = stmt;
125
+ const result = [(0, _util.toUpper)(type), (0, _util.toUpper)(keyword), [(0, _util.identifierToSql)(name.schema), (0, _util.identifierToSql)(name.name)].filter(_util.hasVal).join('.'), alterExprToSQL(expr)];
126
+ return result.filter(_util.hasVal).join(' ');
127
+ }
128
+ function alterFunctionToSQL(stmt) {
129
+ const {
130
+ args,
131
+ expr,
132
+ keyword,
133
+ name,
134
+ type
135
+ } = stmt;
136
+ const result = [(0, _util.toUpper)(type), (0, _util.toUpper)(keyword), [[(0, _util.identifierToSql)(name.schema), (0, _util.identifierToSql)(name.name)].filter(_util.hasVal).join('.'), args && `(${args.expr ? args.expr.map(alterArgsToSQL).join(', ') : ''})`].filter(_util.hasVal).join(''), alterExprToSQL(expr)];
137
+ return result.filter(_util.hasVal).join(' ');
138
+ }
139
+ function alterAggregateToSQL(stmt) {
140
+ const {
141
+ args,
142
+ expr,
143
+ keyword,
144
+ name,
145
+ type
146
+ } = stmt;
147
+ const {
148
+ expr: argsExpr,
149
+ orderby
150
+ } = args;
151
+ const result = [(0, _util.toUpper)(type), (0, _util.toUpper)(keyword), [[(0, _util.identifierToSql)(name.schema), (0, _util.identifierToSql)(name.name)].filter(_util.hasVal).join('.'), `(${argsExpr.map(alterArgsToSQL).join(', ')}${orderby ? [' ORDER', 'BY', orderby.map(alterArgsToSQL).join(', ')].join(' ') : ''})`].filter(_util.hasVal).join(''), alterExprToSQL(expr)];
152
+ return result.filter(_util.hasVal).join(' ');
153
+ }
154
+ function alterToSQL(stmt) {
155
+ const {
156
+ keyword = 'table'
157
+ } = stmt;
158
+ switch (keyword) {
159
+ case 'aggregate':
160
+ return alterAggregateToSQL(stmt);
161
+ case 'table':
162
+ return alterTableToSQL(stmt);
163
+ case 'schema':
164
+ return alterSchemaToSQL(stmt);
165
+ case 'domain':
166
+ case 'type':
167
+ return alterDomainTypeToSQL(stmt);
168
+ case 'function':
169
+ return alterFunctionToSQL(stmt);
170
+ case 'view':
171
+ return alterViewToSQL(stmt);
172
+ }
173
+ }
174
+ });
@@ -0,0 +1,40 @@
1
+ (function (global, factory) {
2
+ if (typeof define === "function" && define.amd) {
3
+ define(["exports", "./expr", "./tables", "./util"], factory);
4
+ } else if (typeof exports !== "undefined") {
5
+ factory(exports, require("./expr"), require("./tables"), require("./util"));
6
+ } else {
7
+ var mod = {
8
+ exports: {}
9
+ };
10
+ factory(mod.exports, global.expr, global.tables, global.util);
11
+ global.analyze = mod.exports;
12
+ }
13
+ })(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _expr, _tables, _util) {
14
+ "use strict";
15
+
16
+ Object.defineProperty(_exports, "__esModule", {
17
+ value: true
18
+ });
19
+ _exports.analyzeToSQL = analyzeToSQL;
20
+ _exports.attachToSQL = attachToSQL;
21
+ function analyzeToSQL(stmt) {
22
+ const {
23
+ type,
24
+ table
25
+ } = stmt;
26
+ const action = (0, _util.toUpper)(type);
27
+ const tableName = (0, _tables.tableToSQL)(table);
28
+ return [action, tableName].join(' ');
29
+ }
30
+ function attachToSQL(stmt) {
31
+ const {
32
+ type,
33
+ database,
34
+ expr,
35
+ as,
36
+ schema
37
+ } = stmt;
38
+ return [(0, _util.toUpper)(type), (0, _util.toUpper)(database), (0, _expr.exprToSQL)(expr), (0, _util.toUpper)(as), (0, _util.identifierToSql)(schema)].filter(_util.hasVal).join(' ');
39
+ }
40
+ });
@@ -0,0 +1,60 @@
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.arrayStruct = 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.arrayStructExprToSQL = arrayStructExprToSQL;
20
+ _exports.arrayStructValueToSQL = arrayStructValueToSQL;
21
+ function arrayExprListToSQL(expr) {
22
+ const {
23
+ array_path: arrayPath,
24
+ brackets,
25
+ expr_list: exprList,
26
+ parentheses
27
+ } = expr;
28
+ if (!exprList) return `[${(0, _column.columnsToSQL)(arrayPath)}]`;
29
+ const result = Array.isArray(exprList) ? exprList.map(col => `(${(0, _column.columnsToSQL)(col)})`).filter(_util.hasVal).join(', ') : (0, _expr.exprToSQL)(exprList);
30
+ if (brackets) return `[${result}]`;
31
+ return parentheses ? `(${result})` : result;
32
+ }
33
+ function arrayStructValueToSQL(expr) {
34
+ const {
35
+ expr_list: exprList,
36
+ type
37
+ } = expr;
38
+ switch ((0, _util.toUpper)(type)) {
39
+ case 'STRUCT':
40
+ return `(${(0, _column.columnsToSQL)(exprList)})`;
41
+ case 'ARRAY':
42
+ return arrayExprListToSQL(expr);
43
+ default:
44
+ return '';
45
+ }
46
+ }
47
+ function arrayStructExprToSQL(expr) {
48
+ const {
49
+ definition,
50
+ keyword
51
+ } = expr;
52
+ const result = [(0, _util.toUpper)(keyword)];
53
+ if (definition && typeof definition === 'object') {
54
+ result.length = 0;
55
+ result.push((0, _util.arrayStructTypeToSQL)(definition));
56
+ }
57
+ result.push(arrayStructValueToSQL(expr));
58
+ return result.filter(_util.hasVal).join('');
59
+ }
60
+ });
@@ -0,0 +1,33 @@
1
+ (function (global, factory) {
2
+ if (typeof define === "function" && define.amd) {
3
+ define(["exports", "./expr"], factory);
4
+ } else if (typeof exports !== "undefined") {
5
+ factory(exports, require("./expr"));
6
+ } else {
7
+ var mod = {
8
+ exports: {}
9
+ };
10
+ factory(mod.exports, global.expr);
11
+ global.assign = mod.exports;
12
+ }
13
+ })(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _expr) {
14
+ "use strict";
15
+
16
+ Object.defineProperty(_exports, "__esModule", {
17
+ value: true
18
+ });
19
+ _exports.assignToSQL = assignToSQL;
20
+ function assignToSQL(expr) {
21
+ /** @type {Object} */
22
+ const {
23
+ left,
24
+ right,
25
+ symbol,
26
+ keyword
27
+ } = expr;
28
+ left.keyword = keyword;
29
+ const leftVar = (0, _expr.exprToSQL)(left);
30
+ const rightVal = (0, _expr.exprToSQL)(right);
31
+ return `${leftVar} ${symbol} ${rightVal}`;
32
+ }
33
+ });
@@ -0,0 +1,46 @@
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.binary = 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.binaryToSQL = binaryToSQL;
20
+ function binaryToSQL(expr) {
21
+ let operator = expr.operator || expr.op;
22
+ let rstr = (0, _expr.exprToSQL)(expr.right);
23
+ let isBetween = false;
24
+ if (Array.isArray(rstr)) {
25
+ switch (operator) {
26
+ case '=':
27
+ operator = 'IN';
28
+ break;
29
+ case '!=':
30
+ operator = 'NOT IN';
31
+ break;
32
+ case 'BETWEEN':
33
+ case 'NOT BETWEEN':
34
+ isBetween = true;
35
+ rstr = `${rstr[0]} AND ${rstr[1]}`;
36
+ break;
37
+ default:
38
+ break;
39
+ }
40
+ if (!isBetween) rstr = `(${rstr.join(', ')})`;
41
+ }
42
+ const escape = expr.right.escape || {};
43
+ const str = [(0, _expr.exprToSQL)(expr.left), operator, rstr, (0, _util.toUpper)(escape.type), (0, _expr.exprToSQL)(escape.value)].filter(_util.hasVal).join(' ');
44
+ return expr.parentheses ? `(${str})` : str;
45
+ }
46
+ });
@@ -0,0 +1,39 @@
1
+ (function (global, factory) {
2
+ if (typeof define === "function" && define.amd) {
3
+ define(["exports", "./expr"], factory);
4
+ } else if (typeof exports !== "undefined") {
5
+ factory(exports, require("./expr"));
6
+ } else {
7
+ var mod = {
8
+ exports: {}
9
+ };
10
+ factory(mod.exports, global.expr);
11
+ global._case = mod.exports;
12
+ }
13
+ })(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _expr) {
14
+ "use strict";
15
+
16
+ Object.defineProperty(_exports, "__esModule", {
17
+ value: true
18
+ });
19
+ _exports.caseToSQL = caseToSQL;
20
+ function caseToSQL(expr) {
21
+ const res = ['CASE'];
22
+ const {
23
+ args: conditions,
24
+ expr: exprItem,
25
+ parentheses
26
+ } = expr;
27
+ if (exprItem) res.push((0, _expr.exprToSQL)(exprItem));
28
+ for (let i = 0, len = conditions.length; i < len; ++i) {
29
+ res.push(conditions[i].type.toUpperCase());
30
+ if (conditions[i].cond) {
31
+ res.push((0, _expr.exprToSQL)(conditions[i].cond));
32
+ res.push('THEN');
33
+ }
34
+ res.push((0, _expr.exprToSQL)(conditions[i].result));
35
+ }
36
+ res.push('END');
37
+ return parentheses ? `(${res.join(' ')})` : res.join(' ');
38
+ }
39
+ });
@@ -0,0 +1,221 @@
1
+ (function (global, factory) {
2
+ if (typeof define === "function" && define.amd) {
3
+ define(["exports", "./constrain", "./expr", "./func", "./tables", "./util"], factory);
4
+ } else if (typeof exports !== "undefined") {
5
+ factory(exports, require("./constrain"), require("./expr"), require("./func"), require("./tables"), require("./util"));
6
+ } else {
7
+ var mod = {
8
+ exports: {}
9
+ };
10
+ factory(mod.exports, global.constrain, global.expr, global.func, global.tables, global.util);
11
+ global.column = mod.exports;
12
+ }
13
+ })(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _constrain, _expr, _func, _tables, _util) {
14
+ "use strict";
15
+
16
+ Object.defineProperty(_exports, "__esModule", {
17
+ value: true
18
+ });
19
+ _exports.columnDataType = columnDataType;
20
+ _exports.columnDefinitionToSQL = columnDefinitionToSQL;
21
+ _exports.columnOrderToSQL = columnOrderToSQL;
22
+ _exports.columnRefToSQL = columnRefToSQL;
23
+ _exports.columnReferenceDefinitionToSQL = columnReferenceDefinitionToSQL;
24
+ _exports.columnToSQL = columnToSQL;
25
+ _exports.columnsToSQL = columnsToSQL;
26
+ _exports.fullTextSearchToSQL = fullTextSearchToSQL;
27
+ function columnOffsetToSQL(column, isDual) {
28
+ if (typeof column === 'string') return (0, _util.identifierToSql)(column, isDual);
29
+ const {
30
+ expr,
31
+ offset,
32
+ suffix
33
+ } = column;
34
+ const offsetExpr = offset && offset.map(offsetItem => ['[', offsetItem.name, `${offsetItem.name ? '(' : ''}`, (0, _util.literalToSQL)(offsetItem.value), `${offsetItem.name ? ')' : ''}`, ']'].filter(_util.hasVal).join('')).join('');
35
+ return [(0, _expr.exprToSQL)(expr), offsetExpr, suffix].filter(_util.hasVal).join('');
36
+ }
37
+ function columnRefToSQL(expr) {
38
+ const {
39
+ array_index,
40
+ arrows = [],
41
+ as,
42
+ collate,
43
+ column,
44
+ db,
45
+ isDual,
46
+ schema,
47
+ table,
48
+ parentheses,
49
+ properties,
50
+ suffix,
51
+ order_by,
52
+ subFields = []
53
+ } = expr;
54
+ let str = column === '*' ? '*' : columnOffsetToSQL(column, isDual);
55
+ const prefix = [schema, db, table].filter(_util.hasVal).map(val => `${(0, _util.identifierToSql)(val)}`).join('.');
56
+ if (prefix) str = `${prefix}.${str}`;
57
+ if (array_index) {
58
+ str = `${str}[${(0, _util.literalToSQL)(array_index.index)}]`;
59
+ if (array_index.property) str = `${str}.${(0, _util.literalToSQL)(array_index.property)}`;
60
+ }
61
+ str = [str, ...subFields].join('.');
62
+ const result = [str, (0, _util.commonOptionConnector)('AS', _expr.exprToSQL, as), arrows.map((arrow, index) => (0, _util.commonOptionConnector)(arrow, _util.literalToSQL, properties[index])).join(' ')];
63
+ if (collate) result.push((0, _util.commonTypeValue)(collate).join(' '));
64
+ result.push((0, _util.toUpper)(suffix));
65
+ result.push((0, _util.toUpper)(order_by));
66
+ const sql = result.filter(_util.hasVal).join(' ');
67
+ return parentheses ? `(${sql})` : sql;
68
+ }
69
+ function columnDataType(definition) {
70
+ const {
71
+ dataType,
72
+ length,
73
+ suffix,
74
+ scale,
75
+ expr
76
+ } = definition || {};
77
+ let result = dataType;
78
+ if (length != null) result += `(${[length, scale].filter(val => val != null).join(', ')})`;
79
+ if (suffix && suffix.length) result += ` ${suffix.join(' ')}`;
80
+ if (expr) result += (0, _expr.exprToSQL)(expr);
81
+ return result;
82
+ }
83
+ function columnReferenceDefinitionToSQL(referenceDefinition) {
84
+ const reference = [];
85
+ if (!referenceDefinition) return reference;
86
+ const {
87
+ definition,
88
+ keyword,
89
+ match,
90
+ table,
91
+ on_action: onAction
92
+ } = referenceDefinition;
93
+ reference.push((0, _util.toUpper)(keyword));
94
+ reference.push((0, _tables.tablesToSQL)(table));
95
+ reference.push(definition && `(${definition.map(col => (0, _expr.exprToSQL)(col)).join(', ')})`);
96
+ reference.push((0, _util.toUpper)(match));
97
+ onAction.map(onRef => reference.push((0, _util.toUpper)(onRef.type), (0, _expr.exprToSQL)(onRef.value)));
98
+ return reference.filter(_util.hasVal);
99
+ }
100
+ function columnOption(definition) {
101
+ const columnOpt = [];
102
+ const {
103
+ nullable,
104
+ character_set: characterSet,
105
+ check,
106
+ comment,
107
+ collate,
108
+ storage,
109
+ default_val: defaultOpt,
110
+ auto_increment: autoIncrement,
111
+ unique: uniqueKey,
112
+ primary_key: primaryKey,
113
+ column_format: columnFormat,
114
+ reference_definition: referenceDefinition
115
+ } = definition;
116
+ columnOpt.push((0, _util.toUpper)(nullable && nullable.value));
117
+ if (defaultOpt) {
118
+ const {
119
+ type,
120
+ value
121
+ } = defaultOpt;
122
+ columnOpt.push(type.toUpperCase(), (0, _expr.exprToSQL)(value));
123
+ }
124
+ const {
125
+ database
126
+ } = (0, _util.getParserOpt)();
127
+ columnOpt.push((0, _constrain.constraintDefinitionToSQL)(check));
128
+ columnOpt.push((0, _util.autoIncrementToSQL)(autoIncrement), (0, _util.toUpper)(primaryKey), (0, _util.toUpper)(uniqueKey), (0, _util.commentToSQL)(comment));
129
+ columnOpt.push(...(0, _util.commonTypeValue)(characterSet));
130
+ if (database !== 'sqlite') columnOpt.push(...(0, _util.commonTypeValue)(collate));
131
+ columnOpt.push(...(0, _util.commonTypeValue)(columnFormat));
132
+ columnOpt.push(...(0, _util.commonTypeValue)(storage));
133
+ columnOpt.push(...columnReferenceDefinitionToSQL(referenceDefinition));
134
+ return columnOpt.filter(_util.hasVal).join(' ');
135
+ }
136
+ function columnOrderToSQL(columnOrder) {
137
+ const {
138
+ column,
139
+ collate,
140
+ nulls,
141
+ opclass,
142
+ order_by
143
+ } = columnOrder;
144
+ const result = [(0, _expr.exprToSQL)(typeof column === 'string' ? {
145
+ type: 'column_ref',
146
+ table: columnOrder.table,
147
+ column
148
+ } : columnOrder), (0, _util.commonOptionConnector)(collate && collate.type, _util.identifierToSql, collate && collate.value), opclass, (0, _util.toUpper)(order_by), (0, _util.toUpper)(nulls)];
149
+ return result.filter(_util.hasVal).join(' ');
150
+ }
151
+ function generatedExpressionToSQL(generated) {
152
+ if (!generated) return;
153
+ const result = [(0, _util.toUpper)(generated.value), `(${(0, _expr.exprToSQL)(generated.expr)})`, (0, _util.toUpper)(generated.storage_type)];
154
+ return result.filter(_util.hasVal).join(' ');
155
+ }
156
+ function columnDefinitionToSQL(columnDefinition) {
157
+ const column = [];
158
+ const name = columnRefToSQL(columnDefinition.column);
159
+ const dataType = columnDataType(columnDefinition.definition);
160
+ column.push(name);
161
+ column.push(dataType);
162
+ const columnOpt = columnOption(columnDefinition);
163
+ column.push(columnOpt);
164
+ const generated = generatedExpressionToSQL(columnDefinition.generated);
165
+ column.push(generated);
166
+ return column.filter(_util.hasVal).join(' ');
167
+ }
168
+ function asToSQL(asStr) {
169
+ if (!asStr) return '';
170
+ return ['AS', /^(`?)[a-z_][0-9a-z_]*(`?)$/i.test(asStr) ? (0, _util.identifierToSql)(asStr) : (0, _util.columnIdentifierToSql)(asStr)].join(' ');
171
+ }
172
+ function fullTextSearchToSQL(expr) {
173
+ const {
174
+ against,
175
+ as,
176
+ columns,
177
+ match,
178
+ mode
179
+ } = expr;
180
+ const matchExpr = [(0, _util.toUpper)(match), `(${columns.map(col => columnRefToSQL(col)).join(', ')})`].join(' ');
181
+ const againstExpr = [(0, _util.toUpper)(against), ['(', (0, _expr.exprToSQL)(expr.expr), mode && ` ${(0, _util.literalToSQL)(mode)}`, ')'].filter(_util.hasVal).join('')].join(' ');
182
+ return [matchExpr, againstExpr, asToSQL(as)].filter(_util.hasVal).join(' ');
183
+ }
184
+ function columnToSQL(column, isDual) {
185
+ const {
186
+ expr,
187
+ type
188
+ } = column;
189
+ if (type === 'cast') return (0, _func.castToSQL)(column);
190
+ if (isDual) expr.isDual = isDual;
191
+ let str = (0, _expr.exprToSQL)(expr);
192
+ const {
193
+ expr_list: exprList
194
+ } = column;
195
+ if (exprList) {
196
+ const result = [str];
197
+ const columnsStr = exprList.map(col => columnToSQL(col, isDual)).join(', ');
198
+ result.push([(0, _util.toUpper)(type), type && '(', columnsStr, type && ')'].filter(_util.hasVal).join(''));
199
+ return result.filter(_util.hasVal).join(' ');
200
+ }
201
+ if (expr.parentheses && Reflect.has(expr, 'array_index')) str = `(${str})`;
202
+ if (expr.array_index && expr.type !== 'column_ref') str = `${str}[${(0, _util.literalToSQL)(expr.array_index.index)}]`;
203
+ return [str, asToSQL(column.as)].filter(_util.hasVal).join(' ');
204
+ }
205
+ function getDual(tables) {
206
+ const baseTable = Array.isArray(tables) && tables[0];
207
+ if (baseTable && baseTable.type === 'dual') return true;
208
+ return false;
209
+ }
210
+ /**
211
+ * Stringify column expressions
212
+ *
213
+ * @param {Array} columns
214
+ * @return {string}
215
+ */
216
+ function columnsToSQL(columns, tables) {
217
+ if (!columns || columns === '*') return columns;
218
+ const isDual = getDual(tables);
219
+ return columns.map(col => columnToSQL(col, isDual)).join(', ');
220
+ }
221
+ });