@tachybase/module-collection 1.6.24 → 1.6.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/externalVersion.js +2 -2
- package/{LICENSE → dist/node_modules/node-sql-parser/LICENSE} +3 -3
- package/dist/node_modules/node-sql-parser/ast/postgresql.ts +2063 -0
- package/dist/node_modules/node-sql-parser/build/athena.d.ts +1 -0
- package/dist/node_modules/node-sql-parser/build/athena.js +2 -0
- package/dist/node_modules/node-sql-parser/build/bigquery.d.ts +1 -0
- package/dist/node_modules/node-sql-parser/build/bigquery.js +2 -0
- package/dist/node_modules/node-sql-parser/build/db2.d.ts +1 -0
- package/dist/node_modules/node-sql-parser/build/db2.js +2 -0
- package/dist/node_modules/node-sql-parser/build/flinksql.d.ts +1 -0
- package/dist/node_modules/node-sql-parser/build/flinksql.js +2 -0
- package/dist/node_modules/node-sql-parser/build/hive.d.ts +1 -0
- package/dist/node_modules/node-sql-parser/build/hive.js +2 -0
- package/dist/node_modules/node-sql-parser/build/mariadb.d.ts +1 -0
- package/dist/node_modules/node-sql-parser/build/mariadb.js +2 -0
- package/dist/node_modules/node-sql-parser/build/mysql.d.ts +1 -0
- package/dist/node_modules/node-sql-parser/build/mysql.js +2 -0
- package/dist/node_modules/node-sql-parser/build/noql.d.ts +1 -0
- package/dist/node_modules/node-sql-parser/build/noql.js +2 -0
- package/dist/node_modules/node-sql-parser/build/postgresql.d.ts +1 -0
- package/dist/node_modules/node-sql-parser/build/postgresql.js +2 -0
- package/dist/node_modules/node-sql-parser/build/redshift.d.ts +1 -0
- package/dist/node_modules/node-sql-parser/build/redshift.js +2 -0
- package/dist/node_modules/node-sql-parser/build/snowflake.d.ts +1 -0
- package/dist/node_modules/node-sql-parser/build/snowflake.js +2 -0
- package/dist/node_modules/node-sql-parser/build/sqlite.d.ts +1 -0
- package/dist/node_modules/node-sql-parser/build/sqlite.js +2 -0
- package/dist/node_modules/node-sql-parser/build/transactsql.d.ts +1 -0
- package/dist/node_modules/node-sql-parser/build/transactsql.js +2 -0
- package/dist/node_modules/node-sql-parser/build/trino.d.ts +1 -0
- package/dist/node_modules/node-sql-parser/build/trino.js +2 -0
- package/dist/node_modules/node-sql-parser/index.d.ts +1 -0
- package/dist/node_modules/node-sql-parser/index.js +1 -0
- package/dist/node_modules/node-sql-parser/lib/aggregation.js +42 -0
- package/dist/node_modules/node-sql-parser/lib/alter.js +211 -0
- package/dist/node_modules/node-sql-parser/lib/analyze.js +40 -0
- package/dist/node_modules/node-sql-parser/lib/array-struct.js +60 -0
- package/dist/node_modules/node-sql-parser/lib/assign.js +33 -0
- package/dist/node_modules/node-sql-parser/lib/binary.js +48 -0
- package/dist/node_modules/node-sql-parser/lib/case.js +39 -0
- package/dist/node_modules/node-sql-parser/lib/collate.js +37 -0
- package/dist/node_modules/node-sql-parser/lib/column.js +259 -0
- package/dist/node_modules/node-sql-parser/lib/command.js +306 -0
- package/dist/node_modules/node-sql-parser/lib/comment.js +53 -0
- package/dist/node_modules/node-sql-parser/lib/constrain.js +49 -0
- package/dist/node_modules/node-sql-parser/lib/create.js +496 -0
- package/dist/node_modules/node-sql-parser/lib/delete.js +44 -0
- package/dist/node_modules/node-sql-parser/lib/exec.js +37 -0
- package/dist/node_modules/node-sql-parser/lib/explain.js +27 -0
- package/dist/node_modules/node-sql-parser/lib/expr.js +147 -0
- package/dist/node_modules/node-sql-parser/lib/func.js +231 -0
- package/dist/node_modules/node-sql-parser/lib/index-definition.js +106 -0
- package/dist/node_modules/node-sql-parser/lib/insert.js +112 -0
- package/dist/node_modules/node-sql-parser/lib/interval.js +29 -0
- package/dist/node_modules/node-sql-parser/lib/json.js +36 -0
- package/dist/node_modules/node-sql-parser/lib/limit.js +45 -0
- package/dist/node_modules/node-sql-parser/lib/over.js +39 -0
- package/dist/node_modules/node-sql-parser/lib/parser.all.js +36 -0
- package/dist/node_modules/node-sql-parser/lib/parser.js +88 -0
- package/dist/node_modules/node-sql-parser/lib/parser.single.js +23 -0
- package/dist/node_modules/node-sql-parser/lib/proc.js +39 -0
- package/dist/node_modules/node-sql-parser/lib/select.js +138 -0
- package/dist/node_modules/node-sql-parser/lib/show.js +89 -0
- package/dist/node_modules/node-sql-parser/lib/sql.js +43 -0
- package/dist/node_modules/node-sql-parser/lib/tables.js +277 -0
- package/dist/node_modules/node-sql-parser/lib/transaction.js +32 -0
- package/dist/node_modules/node-sql-parser/lib/union.js +83 -0
- package/dist/node_modules/node-sql-parser/lib/update.js +62 -0
- package/dist/node_modules/node-sql-parser/lib/util.js +458 -0
- package/dist/node_modules/node-sql-parser/lib/window.js +84 -0
- package/dist/node_modules/node-sql-parser/lib/with.js +37 -0
- package/dist/node_modules/node-sql-parser/package.json +1 -0
- package/dist/node_modules/node-sql-parser/types.d.ts +555 -0
- package/dist/node_modules/node-sql-parser/umd/athena.umd.d.ts +1 -0
- package/dist/node_modules/node-sql-parser/umd/athena.umd.js +2 -0
- package/dist/node_modules/node-sql-parser/umd/bigquery.umd.d.ts +1 -0
- package/dist/node_modules/node-sql-parser/umd/bigquery.umd.js +2 -0
- package/dist/node_modules/node-sql-parser/umd/db2.umd.d.ts +1 -0
- package/dist/node_modules/node-sql-parser/umd/db2.umd.js +2 -0
- package/dist/node_modules/node-sql-parser/umd/flinksql.umd.d.ts +1 -0
- package/dist/node_modules/node-sql-parser/umd/flinksql.umd.js +2 -0
- package/dist/node_modules/node-sql-parser/umd/hive.umd.d.ts +1 -0
- package/dist/node_modules/node-sql-parser/umd/hive.umd.js +2 -0
- package/dist/node_modules/node-sql-parser/umd/index.umd.d.ts +1 -0
- package/dist/node_modules/node-sql-parser/umd/index.umd.js +2 -0
- package/dist/node_modules/node-sql-parser/umd/mariadb.umd.d.ts +1 -0
- package/dist/node_modules/node-sql-parser/umd/mariadb.umd.js +2 -0
- package/dist/node_modules/node-sql-parser/umd/mysql.umd.d.ts +1 -0
- package/dist/node_modules/node-sql-parser/umd/mysql.umd.js +2 -0
- package/dist/node_modules/node-sql-parser/umd/noql.umd.d.ts +1 -0
- package/dist/node_modules/node-sql-parser/umd/noql.umd.js +2 -0
- package/dist/node_modules/node-sql-parser/umd/postgresql.umd.d.ts +1 -0
- package/dist/node_modules/node-sql-parser/umd/postgresql.umd.js +2 -0
- package/dist/node_modules/node-sql-parser/umd/redshift.umd.d.ts +1 -0
- package/dist/node_modules/node-sql-parser/umd/redshift.umd.js +2 -0
- package/dist/node_modules/node-sql-parser/umd/snowflake.umd.d.ts +1 -0
- package/dist/node_modules/node-sql-parser/umd/snowflake.umd.js +2 -0
- package/dist/node_modules/node-sql-parser/umd/sqlite.umd.d.ts +1 -0
- package/dist/node_modules/node-sql-parser/umd/sqlite.umd.js +2 -0
- package/dist/node_modules/node-sql-parser/umd/transactsql.umd.d.ts +1 -0
- package/dist/node_modules/node-sql-parser/umd/transactsql.umd.js +2 -0
- package/dist/node_modules/node-sql-parser/umd/trino.umd.d.ts +1 -0
- package/dist/node_modules/node-sql-parser/umd/trino.umd.js +2 -0
- package/dist/server/repositories/collection-repository.d.ts +3 -0
- package/dist/server/repositories/collection-repository.js +7 -1
- package/dist/server/resourcers/sql.d.ts +28 -1
- package/dist/server/resourcers/sql.js +121 -4
- package/dist/server/resourcers/views.d.ts +14 -0
- package/dist/server/server.d.ts +3 -0
- package/package.json +6 -4
|
@@ -0,0 +1,555 @@
|
|
|
1
|
+
// Type definitions for node-sql-parser 1.0
|
|
2
|
+
// Project: https://github.com/taozhi8833998/node-sql-parser#readme
|
|
3
|
+
// Definitions by: taozhi8833998 <https://github.com/taozhi8833998>
|
|
4
|
+
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
5
|
+
// TypeScript Version: 2.4
|
|
6
|
+
|
|
7
|
+
export interface With {
|
|
8
|
+
name: { value: string };
|
|
9
|
+
stmt: {
|
|
10
|
+
_parentheses?: boolean;
|
|
11
|
+
tableList: string[];
|
|
12
|
+
columnList: string[];
|
|
13
|
+
ast: Select;
|
|
14
|
+
};
|
|
15
|
+
columns?: any[];
|
|
16
|
+
}
|
|
17
|
+
import { LocationRange } from "pegjs";
|
|
18
|
+
|
|
19
|
+
export { LocationRange, Location } from "pegjs";
|
|
20
|
+
|
|
21
|
+
export type WhilteListCheckMode = "table" | "column";
|
|
22
|
+
export interface ParseOptions {
|
|
23
|
+
includeLocations?: boolean;
|
|
24
|
+
}
|
|
25
|
+
export interface Option {
|
|
26
|
+
database?: string;
|
|
27
|
+
type?: string;
|
|
28
|
+
trimQuery?: boolean;
|
|
29
|
+
parseOptions?: ParseOptions;
|
|
30
|
+
}
|
|
31
|
+
export interface TableColumnAst {
|
|
32
|
+
tableList: string[];
|
|
33
|
+
columnList: string[];
|
|
34
|
+
ast: AST[] | AST;
|
|
35
|
+
loc?: LocationRange;
|
|
36
|
+
}
|
|
37
|
+
export interface BaseFrom {
|
|
38
|
+
db: string | null;
|
|
39
|
+
table: string;
|
|
40
|
+
as: string | null;
|
|
41
|
+
schema?: string;
|
|
42
|
+
loc?: LocationRange;
|
|
43
|
+
}
|
|
44
|
+
export interface Join extends BaseFrom {
|
|
45
|
+
join: "INNER JOIN" | "LEFT JOIN" | "RIGHT JOIN";
|
|
46
|
+
using?: string[];
|
|
47
|
+
on?: Binary;
|
|
48
|
+
}
|
|
49
|
+
export interface TableExpr {
|
|
50
|
+
expr: {
|
|
51
|
+
ast: Select;
|
|
52
|
+
};
|
|
53
|
+
as?: string | null;
|
|
54
|
+
parentheses: boolean | { length: number }
|
|
55
|
+
}
|
|
56
|
+
export interface Dual {
|
|
57
|
+
type: "dual";
|
|
58
|
+
loc?: LocationRange;
|
|
59
|
+
}
|
|
60
|
+
export type From = BaseFrom | Join | TableExpr | Dual;
|
|
61
|
+
export interface LimitValue {
|
|
62
|
+
type: string;
|
|
63
|
+
value: number;
|
|
64
|
+
loc?: LocationRange;
|
|
65
|
+
}
|
|
66
|
+
export interface Limit {
|
|
67
|
+
seperator: string;
|
|
68
|
+
value: LimitValue[];
|
|
69
|
+
loc?: LocationRange;
|
|
70
|
+
}
|
|
71
|
+
export interface OrderBy {
|
|
72
|
+
type: "ASC" | "DESC";
|
|
73
|
+
expr: any;
|
|
74
|
+
loc?: LocationRange;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export interface ValueExpr<T = string | number | boolean> {
|
|
78
|
+
type:
|
|
79
|
+
| "backticks_quote_string"
|
|
80
|
+
| "string"
|
|
81
|
+
| "regex_string"
|
|
82
|
+
| "hex_string"
|
|
83
|
+
| "full_hex_string"
|
|
84
|
+
| "natural_string"
|
|
85
|
+
| "bit_string"
|
|
86
|
+
| "double_quote_string"
|
|
87
|
+
| "single_quote_string"
|
|
88
|
+
| "boolean"
|
|
89
|
+
| "bool"
|
|
90
|
+
| "null"
|
|
91
|
+
| "star"
|
|
92
|
+
| "param"
|
|
93
|
+
| "origin"
|
|
94
|
+
| "date"
|
|
95
|
+
| "datetime"
|
|
96
|
+
| "default"
|
|
97
|
+
| "time"
|
|
98
|
+
| "timestamp"
|
|
99
|
+
| "var_string";
|
|
100
|
+
value: T;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export interface ColumnRefItem {
|
|
104
|
+
type: "column_ref";
|
|
105
|
+
table: string | null;
|
|
106
|
+
column: string | { expr: ValueExpr };
|
|
107
|
+
options?: ExprList;
|
|
108
|
+
loc?: LocationRange;
|
|
109
|
+
collate?: { collate: CollateExpr };
|
|
110
|
+
}
|
|
111
|
+
export interface ColumnRefExpr {
|
|
112
|
+
type: "expr";
|
|
113
|
+
expr: ColumnRefItem;
|
|
114
|
+
as: string | null;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export type ColumnRef = ColumnRefItem | ColumnRefExpr;
|
|
118
|
+
export interface SetList {
|
|
119
|
+
column: string;
|
|
120
|
+
value: any;
|
|
121
|
+
table: string | null;
|
|
122
|
+
loc?: LocationRange;
|
|
123
|
+
}
|
|
124
|
+
export interface InsertReplaceValue {
|
|
125
|
+
type: "expr_list";
|
|
126
|
+
value: any[];
|
|
127
|
+
loc?: LocationRange;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export interface Star {
|
|
131
|
+
type: "star";
|
|
132
|
+
value: "*" | "";
|
|
133
|
+
loc?: LocationRange;
|
|
134
|
+
}
|
|
135
|
+
export interface Case {
|
|
136
|
+
type: "case";
|
|
137
|
+
expr: null;
|
|
138
|
+
args: Array<
|
|
139
|
+
| {
|
|
140
|
+
cond: Binary;
|
|
141
|
+
result: ExpressionValue;
|
|
142
|
+
type: "when";
|
|
143
|
+
}
|
|
144
|
+
| {
|
|
145
|
+
result: ExpressionValue;
|
|
146
|
+
type: "else";
|
|
147
|
+
}
|
|
148
|
+
>;
|
|
149
|
+
}
|
|
150
|
+
export interface Cast {
|
|
151
|
+
type: "cast";
|
|
152
|
+
keyword: "cast";
|
|
153
|
+
expr: ExpressionValue;
|
|
154
|
+
symbol: "as";
|
|
155
|
+
target: {
|
|
156
|
+
dataType: string;
|
|
157
|
+
quoted?: string;
|
|
158
|
+
}[];
|
|
159
|
+
}
|
|
160
|
+
export interface AggrFunc {
|
|
161
|
+
type: "aggr_func";
|
|
162
|
+
name: string;
|
|
163
|
+
args: {
|
|
164
|
+
expr: ExpressionValue;
|
|
165
|
+
distinct: "DISTINCT" | null;
|
|
166
|
+
orderby: OrderBy[] | null;
|
|
167
|
+
parentheses?: boolean;
|
|
168
|
+
};
|
|
169
|
+
loc?: LocationRange;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export type FunctionName = {
|
|
173
|
+
schema?: { value: string; type: string };
|
|
174
|
+
name: ValueExpr<string>[];
|
|
175
|
+
};
|
|
176
|
+
export interface Function {
|
|
177
|
+
type: "function";
|
|
178
|
+
name: FunctionName;
|
|
179
|
+
args?: ExprList;
|
|
180
|
+
suffix?: any;
|
|
181
|
+
loc?: LocationRange;
|
|
182
|
+
}
|
|
183
|
+
export interface Column {
|
|
184
|
+
expr: ExpressionValue;
|
|
185
|
+
as: ValueExpr<string> | string | null;
|
|
186
|
+
type?: string;
|
|
187
|
+
loc?: LocationRange;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export interface Interval {
|
|
191
|
+
type: "interval";
|
|
192
|
+
unit: string;
|
|
193
|
+
expr: ValueExpr & { loc?: LocationRange };
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export type Param = { type: "param"; value: string; loc?: LocationRange };
|
|
197
|
+
|
|
198
|
+
export type Value = { type: string; value: any; loc?: LocationRange };
|
|
199
|
+
|
|
200
|
+
export type Binary = {
|
|
201
|
+
type: "binary_expr";
|
|
202
|
+
operator: string;
|
|
203
|
+
left: ExpressionValue | ExprList;
|
|
204
|
+
right: ExpressionValue | ExprList;
|
|
205
|
+
loc?: LocationRange;
|
|
206
|
+
parentheses?: boolean;
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
export type Expr = Binary;
|
|
210
|
+
|
|
211
|
+
export type ExpressionValue =
|
|
212
|
+
| ColumnRef
|
|
213
|
+
| Param
|
|
214
|
+
| Function
|
|
215
|
+
| Case
|
|
216
|
+
| AggrFunc
|
|
217
|
+
| Value
|
|
218
|
+
| Binary
|
|
219
|
+
| Cast
|
|
220
|
+
| Interval;
|
|
221
|
+
|
|
222
|
+
export type ExprList = {
|
|
223
|
+
type: "expr_list";
|
|
224
|
+
value: ExpressionValue[];
|
|
225
|
+
loc?: LocationRange;
|
|
226
|
+
parentheses?: boolean;
|
|
227
|
+
separator?: string;
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
export type PartitionBy = {
|
|
231
|
+
type: 'expr';
|
|
232
|
+
expr: ColumnRef[];
|
|
233
|
+
}[];
|
|
234
|
+
|
|
235
|
+
export type WindowSpec = {
|
|
236
|
+
name: null;
|
|
237
|
+
partitionby: PartitionBy;
|
|
238
|
+
orderby: OrderBy[] | null;
|
|
239
|
+
window_frame_clause: string | null; };
|
|
240
|
+
|
|
241
|
+
export type AsWindowSpec = string | { window_specification: WindowSpec; parentheses: boolean };
|
|
242
|
+
|
|
243
|
+
export type NamedWindowExpr = {
|
|
244
|
+
name: string;
|
|
245
|
+
as_window_specification: AsWindowSpec;
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
export type WindowExpr = {
|
|
249
|
+
keyword: 'window';
|
|
250
|
+
type: 'window',
|
|
251
|
+
expr: NamedWindowExpr[];
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
export interface Select {
|
|
255
|
+
with: With[] | null;
|
|
256
|
+
type: "select";
|
|
257
|
+
options: any[] | null;
|
|
258
|
+
distinct: "DISTINCT" | null;
|
|
259
|
+
columns: any[] | Column[];
|
|
260
|
+
from: From[] | TableExpr | null ;
|
|
261
|
+
where: Binary | Function | null;
|
|
262
|
+
groupby: { columns: ColumnRef[] | null, modifiers: ValueExpr<string>[] };
|
|
263
|
+
having: any[] | null;
|
|
264
|
+
orderby: OrderBy[] | null;
|
|
265
|
+
limit: Limit | null;
|
|
266
|
+
window?: WindowExpr;
|
|
267
|
+
qualify?: any[] | null;
|
|
268
|
+
_orderby?: OrderBy[] | null;
|
|
269
|
+
_limit?: Limit | null;
|
|
270
|
+
parentheses_symbol?: boolean;
|
|
271
|
+
_parentheses?: boolean;
|
|
272
|
+
loc?: LocationRange;
|
|
273
|
+
_next?: Select;
|
|
274
|
+
set_op?: string;
|
|
275
|
+
}
|
|
276
|
+
export interface Insert_Replace {
|
|
277
|
+
type: "replace" | "insert";
|
|
278
|
+
table: any;
|
|
279
|
+
columns: string[] | null;
|
|
280
|
+
values: InsertReplaceValue[] | Select;
|
|
281
|
+
partition: any[];
|
|
282
|
+
prefix: string;
|
|
283
|
+
on_duplicate_update: {
|
|
284
|
+
keyword: "on duplicate key update",
|
|
285
|
+
set: SetList[];
|
|
286
|
+
};
|
|
287
|
+
loc?: LocationRange;
|
|
288
|
+
returning?: Returning
|
|
289
|
+
}
|
|
290
|
+
export interface Returning {
|
|
291
|
+
type: 'returning';
|
|
292
|
+
columns: ColumnRef | Select;
|
|
293
|
+
}
|
|
294
|
+
export interface Update {
|
|
295
|
+
type: "update";
|
|
296
|
+
db: string | null;
|
|
297
|
+
table: Array<From | Dual> | null;
|
|
298
|
+
set: SetList[];
|
|
299
|
+
where: Binary | Function | null;
|
|
300
|
+
loc?: LocationRange;
|
|
301
|
+
returning?: Returning
|
|
302
|
+
}
|
|
303
|
+
export interface Delete {
|
|
304
|
+
type: "delete";
|
|
305
|
+
table: any;
|
|
306
|
+
from: Array<From | Dual>;
|
|
307
|
+
where: Binary | Function | null;
|
|
308
|
+
loc?: LocationRange;
|
|
309
|
+
returning?: Returning
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
export interface Alter {
|
|
313
|
+
type: "alter";
|
|
314
|
+
table: From[];
|
|
315
|
+
expr: any;
|
|
316
|
+
loc?: LocationRange;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
export interface Use {
|
|
320
|
+
type: "use";
|
|
321
|
+
db: string;
|
|
322
|
+
loc?: LocationRange;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
type KW_UNSIGNED = "UNSIGNED";
|
|
326
|
+
type KW_ZEROFILL = "ZEROFILL";
|
|
327
|
+
|
|
328
|
+
type Timezone = ["WITHOUT" | "WITH", "TIME", "ZONE"];
|
|
329
|
+
|
|
330
|
+
type KeywordComment = {
|
|
331
|
+
type: "comment";
|
|
332
|
+
keyword: "comment";
|
|
333
|
+
symbol?: "=";
|
|
334
|
+
value: string;
|
|
335
|
+
};
|
|
336
|
+
|
|
337
|
+
type CollateExpr = {
|
|
338
|
+
type: "collate";
|
|
339
|
+
symbol?: "=";
|
|
340
|
+
value: string;
|
|
341
|
+
};
|
|
342
|
+
|
|
343
|
+
type DataType = {
|
|
344
|
+
dataType: string;
|
|
345
|
+
length?: number;
|
|
346
|
+
parentheses?: true;
|
|
347
|
+
scale?: number;
|
|
348
|
+
suffix?: Timezone | (KW_UNSIGNED | KW_ZEROFILL)[];
|
|
349
|
+
array?: "one" | "two";
|
|
350
|
+
};
|
|
351
|
+
|
|
352
|
+
type LiteralNotNull = {
|
|
353
|
+
type: "not null";
|
|
354
|
+
value: "not null";
|
|
355
|
+
};
|
|
356
|
+
|
|
357
|
+
type LiteralNull = { type: "null"; value: null };
|
|
358
|
+
|
|
359
|
+
type LiteralNumeric = number | { type: "bigint"; value: string };
|
|
360
|
+
|
|
361
|
+
type ColumnConstraint = {
|
|
362
|
+
default_val: {
|
|
363
|
+
type: "default";
|
|
364
|
+
value: any;
|
|
365
|
+
};
|
|
366
|
+
nullable: LiteralNotNull | LiteralNull;
|
|
367
|
+
};
|
|
368
|
+
|
|
369
|
+
type ColumnDefinitionOptList = {
|
|
370
|
+
nullable?: ColumnConstraint["nullable"];
|
|
371
|
+
default_val?: ColumnConstraint["default_val"];
|
|
372
|
+
auto_increment?: "auto_increment";
|
|
373
|
+
unique?: "unique" | "unique key";
|
|
374
|
+
primary?: "key" | "primary key";
|
|
375
|
+
comment?: KeywordComment;
|
|
376
|
+
collate?: { collate: CollateExpr };
|
|
377
|
+
column_format?: { column_format: any };
|
|
378
|
+
storage?: { storage: any };
|
|
379
|
+
reference_definition?: { reference_definition: any };
|
|
380
|
+
character_set?: { type: "CHARACTER SET"; value: string; symbol?: "=" };
|
|
381
|
+
};
|
|
382
|
+
|
|
383
|
+
type CreateColumnDefinition = {
|
|
384
|
+
column: ColumnRef;
|
|
385
|
+
definition: DataType;
|
|
386
|
+
resource: "column";
|
|
387
|
+
} & ColumnDefinitionOptList;
|
|
388
|
+
|
|
389
|
+
type IndexType = {
|
|
390
|
+
keyword: "using";
|
|
391
|
+
type: "btree" | "hash" | "gist" | "gin";
|
|
392
|
+
};
|
|
393
|
+
|
|
394
|
+
type IndexOption = {
|
|
395
|
+
type: "key_block_size";
|
|
396
|
+
symbol?: "=";
|
|
397
|
+
expr: LiteralNumeric;
|
|
398
|
+
};
|
|
399
|
+
|
|
400
|
+
type CreateIndexDefinition = {
|
|
401
|
+
index?: string;
|
|
402
|
+
definition: ColumnRef[];
|
|
403
|
+
keyword: "index" | "key";
|
|
404
|
+
index_type?: IndexType;
|
|
405
|
+
resource: "index";
|
|
406
|
+
index_options?: IndexOption[];
|
|
407
|
+
};
|
|
408
|
+
|
|
409
|
+
type CreateFulltextSpatialIndexDefinition = {
|
|
410
|
+
index?: string;
|
|
411
|
+
definition: ColumnRef[];
|
|
412
|
+
keyword?:
|
|
413
|
+
| "fulltext"
|
|
414
|
+
| "spatial"
|
|
415
|
+
| "fulltext key"
|
|
416
|
+
| "spatial key"
|
|
417
|
+
| "fulltext index"
|
|
418
|
+
| "spatial index";
|
|
419
|
+
index_options?: IndexOption[];
|
|
420
|
+
resource: "index";
|
|
421
|
+
};
|
|
422
|
+
|
|
423
|
+
type ConstraintName = { keyword: "constraint"; constraint: string };
|
|
424
|
+
|
|
425
|
+
type CreateConstraintPrimary = {
|
|
426
|
+
constraint?: ConstraintName["constraint"];
|
|
427
|
+
definition: ColumnRef[];
|
|
428
|
+
constraint_type: "primary key";
|
|
429
|
+
keyword?: ConstraintName["keyword"];
|
|
430
|
+
index_type?: IndexType;
|
|
431
|
+
resource: "constraint";
|
|
432
|
+
index_options?: IndexOption[];
|
|
433
|
+
};
|
|
434
|
+
|
|
435
|
+
type CreateConstraintUnique = {
|
|
436
|
+
constraint?: ConstraintName["constraint"];
|
|
437
|
+
definition: ColumnRef[];
|
|
438
|
+
constraint_type: "unique key" | "unique" | "unique index";
|
|
439
|
+
keyword?: ConstraintName["keyword"];
|
|
440
|
+
index_type?: IndexType;
|
|
441
|
+
index?: string;
|
|
442
|
+
resource: "constraint";
|
|
443
|
+
index_options?: IndexOption[];
|
|
444
|
+
};
|
|
445
|
+
|
|
446
|
+
type CreateConstraintForeign = {
|
|
447
|
+
constraint?: ConstraintName["constraint"];
|
|
448
|
+
definition: ColumnRef[];
|
|
449
|
+
constraint_type: "FOREIGN KEY";
|
|
450
|
+
keyword?: ConstraintName["keyword"];
|
|
451
|
+
index?: string;
|
|
452
|
+
resource: "constraint";
|
|
453
|
+
reference_definition?: any;
|
|
454
|
+
};
|
|
455
|
+
|
|
456
|
+
type CreateConstraintCheck = {
|
|
457
|
+
constraint?: ConstraintName["constraint"];
|
|
458
|
+
definition: any[];
|
|
459
|
+
constraint_type: "check";
|
|
460
|
+
keyword?: ConstraintName["keyword"];
|
|
461
|
+
resource: "constraint";
|
|
462
|
+
};
|
|
463
|
+
|
|
464
|
+
type CreateConstraintDefinition =
|
|
465
|
+
| CreateConstraintPrimary
|
|
466
|
+
| CreateConstraintUnique
|
|
467
|
+
| CreateConstraintForeign
|
|
468
|
+
| CreateConstraintCheck;
|
|
469
|
+
|
|
470
|
+
type CreateDefinition =
|
|
471
|
+
| CreateColumnDefinition
|
|
472
|
+
| CreateIndexDefinition
|
|
473
|
+
| CreateFulltextSpatialIndexDefinition
|
|
474
|
+
| CreateConstraintDefinition;
|
|
475
|
+
|
|
476
|
+
export interface Create {
|
|
477
|
+
type: "create";
|
|
478
|
+
keyword: "aggregate" | "table" | "trigger" | "extension" | "function" | "index" | "database" | "schema" | "view" | "domain" | "type" | "user";
|
|
479
|
+
temporary?: "temporary" | null;
|
|
480
|
+
table?: { db: string; table: string }[];
|
|
481
|
+
if_not_exists?: "if not exists" | null;
|
|
482
|
+
like?: {
|
|
483
|
+
type: "like";
|
|
484
|
+
table: string;
|
|
485
|
+
parentheses?: boolean;
|
|
486
|
+
} | null;
|
|
487
|
+
ignore_replace?: "ignore" | "replace" | null;
|
|
488
|
+
as?: string | null;
|
|
489
|
+
query_expr?: any | null;
|
|
490
|
+
create_definitions?: CreateDefinition[] | null;
|
|
491
|
+
table_options?: any[] | null;
|
|
492
|
+
index_using?: {
|
|
493
|
+
keyword: "using";
|
|
494
|
+
type: "btree" | "hash";
|
|
495
|
+
} | null;
|
|
496
|
+
index?: string | null;
|
|
497
|
+
on_kw?: "on" | null;
|
|
498
|
+
index_columns?: any[] | null;
|
|
499
|
+
index_type?: "unique" | "fulltext" | "spatial" | null;
|
|
500
|
+
index_options?: any[] | null;
|
|
501
|
+
algorithm_option?: {
|
|
502
|
+
type: "alter";
|
|
503
|
+
keyword: "algorithm";
|
|
504
|
+
resource: "algorithm";
|
|
505
|
+
symbol: "=" | null;
|
|
506
|
+
algorithm: "default" | "instant" | "inplace" | "copy";
|
|
507
|
+
} | null;
|
|
508
|
+
lock_option?: {
|
|
509
|
+
type: "alter";
|
|
510
|
+
keyword: "lock";
|
|
511
|
+
resource: "lock";
|
|
512
|
+
symbol: "=" | null;
|
|
513
|
+
lock: "default" | "none" | "shared" | "exclusive";
|
|
514
|
+
} | null;
|
|
515
|
+
database?: string;
|
|
516
|
+
loc?: LocationRange;
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
export interface Drop {
|
|
520
|
+
type: "drop";
|
|
521
|
+
keyword: string;
|
|
522
|
+
name: any[];
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
export type AST =
|
|
526
|
+
| Use
|
|
527
|
+
| Select
|
|
528
|
+
| Insert_Replace
|
|
529
|
+
| Update
|
|
530
|
+
| Delete
|
|
531
|
+
| Alter
|
|
532
|
+
| Create
|
|
533
|
+
| Drop;
|
|
534
|
+
|
|
535
|
+
export class Parser {
|
|
536
|
+
constructor();
|
|
537
|
+
|
|
538
|
+
parse(sql: string, opt?: Option): TableColumnAst;
|
|
539
|
+
|
|
540
|
+
astify(sql: string, opt?: Option): AST[] | AST;
|
|
541
|
+
|
|
542
|
+
sqlify(ast: AST[] | AST, opt?: Option): string;
|
|
543
|
+
|
|
544
|
+
exprToSQL(ast: any, opt?: Option): string;
|
|
545
|
+
|
|
546
|
+
whiteListCheck(
|
|
547
|
+
sql: string,
|
|
548
|
+
whiteList: string[],
|
|
549
|
+
opt?: Option
|
|
550
|
+
): Error | undefined;
|
|
551
|
+
|
|
552
|
+
tableList(sql: string, opt?: Option): string[];
|
|
553
|
+
|
|
554
|
+
columnList(sql: string, opt?: Option): string[];
|
|
555
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../types';
|