|
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: string; |
9 | | - stmt: any[]; |
10 | | - columns?: any[]; |
11 | | -} |
12 | | -export type WhilteListCheckMode = 'table' | 'column'; |
13 | | -export interface Option { |
14 | | - database?: string, |
15 | | - type?: string, |
16 | | -} |
17 | | -export interface TableColumnAst { |
18 | | - tableList: string[]; |
19 | | - columnList: string[]; |
20 | | - ast: AST[] | AST; |
21 | | -} |
22 | | -export interface From { |
23 | | - db: string | null; |
24 | | - table: string; |
25 | | - as: string | null; |
26 | | -} |
27 | | -export interface Dual { |
28 | | - type: 'dual'; |
29 | | -} |
30 | | -export interface Limit { |
31 | | - type: string; |
32 | | - value: number; |
33 | | -} |
34 | | -export interface OrderBy { |
35 | | - type: 'ASC' | 'DESC'; |
36 | | - expr: any; |
37 | | -} |
38 | | -export interface ColumnRef { |
39 | | - type: 'column_ref'; |
40 | | - table: string | null; |
41 | | - column: string; |
42 | | -} |
43 | | -export interface SetList { |
44 | | - column: string; |
45 | | - value: any; |
46 | | - table: string | null; |
47 | | -} |
48 | | -export interface InsertReplaceValue { |
49 | | - type: 'expr_list'; |
50 | | - value: any[]; |
51 | | -} |
52 | | -export interface Star { |
53 | | - type: 'star'; |
54 | | - value: '*'; |
55 | | -} |
56 | | -export interface AggrFunc { |
57 | | - type: 'aggr_func'; |
58 | | - name: string; |
59 | | - args: ColumnRef | AggrFunc | Star | null; |
60 | | -} |
61 | | -export interface Column { |
62 | | - expr: ColumnRef | AggrFunc; |
63 | | - as: string; |
64 | | -} |
65 | | -export interface Select { |
66 | | - with: With | null; |
67 | | - type: 'select'; |
68 | | - options: any[] | null; |
69 | | - distinct: 'DISTINCT' | null; |
70 | | - columns: any[] | Column[] | '*'; |
71 | | - from: Array<From | Dual> | null; |
72 | | - where: any; |
73 | | - groupby: ColumnRef[] | null; |
74 | | - having: any[] | null; |
75 | | - orderby: OrderBy[] | null; |
76 | | - limit: Limit[] | null; |
77 | | -} |
78 | | -export interface Insert_Replace { |
79 | | - type: 'replace' | 'insert'; |
80 | | - db: string | null; |
81 | | - table: any; |
82 | | - columns: string[] | null; |
83 | | - values: InsertReplaceValue[]; |
84 | | -} |
85 | | -export interface Update { |
86 | | - type: 'update'; |
87 | | - db: string | null; |
88 | | - table: Array<From | Dual> | null; |
89 | | - set: SetList[]; |
90 | | - where: any; |
91 | | -} |
92 | | -export interface Delete { |
93 | | - type: 'delete'; |
94 | | - table: any; |
95 | | - from: Array<From | Dual>; |
96 | | - where: any; |
97 | | -} |
98 | | - |
99 | | -export interface Alter { |
100 | | - type: 'alter', |
101 | | - table: From, |
102 | | - expr: any |
103 | | -} |
104 | | - |
105 | | -export interface Use { |
106 | | - type: 'use'; |
107 | | - db: string; |
108 | | -} |
109 | | - |
110 | | -export type AST = Use | Select | Insert_Replace | Update | Delete | Alter; |
111 | | - |
112 | | -export class Parser { |
113 | | - constructor(); |
114 | | - |
115 | | - parse(sql: string, opt?: Option): TableColumnAst; |
116 | | - |
117 | | - astify(sql: string, opt?: Option): AST[] | AST; |
118 | | - |
119 | | - sqlify(ast: AST[] | AST, opt?: Option): string; |
120 | | - |
121 | | - whiteListCheck(sql: string, whiteList: string[], opt?: Option): Error | undefined; |
122 | | - |
123 | | - tableList(sql: string, opt?: Option): string[]; |
124 | | - |
125 | | - columnList(sql: string, opt?: Option): string[]; |
126 | | -} |
| 1 | +export * from './types'; |
0 commit comments