File tree Expand file tree Collapse file tree 2 files changed +51
-0
lines changed
Expand file tree Collapse file tree 2 files changed +51
-0
lines changed Original file line number Diff line number Diff line change 1+ declare module 'node-sql-parser' {
2+ enum Type {
3+ SELECT = 'select' ,
4+ UPDATE = 'update' ,
5+ INSERT = 'insert' ,
6+ DELETE = 'delete' ,
7+ REPLACE = 'replace'
8+ }
9+ interface With {
10+ name : string ,
11+ stmt : any [ ] ,
12+ columns ?: any [ ]
13+ }
14+ enum WhilteListCheckMode {
15+ TABLE = 'table' ,
16+ COLUMN = 'column'
17+ }
18+ export interface TableColumnAst {
19+ tableList : string [ ] ,
20+ columnsList : string [ ] ,
21+ ast : AST [ ] | AST
22+ }
23+ interface Select {
24+ with ?: With ,
25+ type : Type . SELECT | Type . UPDATE | Type . INSERT | Type . DELETE | Type . REPLACE ,
26+ options ?: any [ ] ,
27+ distinct ?: 'DISTINCT' ,
28+ columns : any [ ] | '*' ,
29+ from ?: [ ] ,
30+ where ?: any ,
31+ groupby ?: any [ ] ,
32+ having ?: any [ ] ,
33+ orderby ?: any [ ] ,
34+ limit ?: { type : string , value : number } [ ]
35+ }
36+
37+ interface Insert {
38+
39+ }
40+ export type AST = Select | Insert
41+ export class Parser {
42+ constructor ( ) ;
43+ parse ( sql : string ) : TableColumnAst ;
44+ astify ( sql : string ) : AST [ ] | AST ;
45+ sqlify ( ast : AST [ ] | AST ) : string ;
46+ whiteListCheck ( sql : string , whiteList : string [ ] , type ?: WhilteListCheckMode . TABLE | WhilteListCheckMode . COLUMN ) : Error | undefined ;
47+ tableList ( sql : string ) : string [ ] ;
48+ columnList ( sql : string ) : string [ ] ;
49+ }
50+ }
Original file line number Diff line number Diff line change 33 "version" : " 1.0.0" ,
44 "description" : " simple node sql parser" ,
55 "main" : " index.js" ,
6+ "type" : " index.d.ts" ,
67 "scripts" : {
78 "build" : " mkdir -p build && pegjs -o build/pegjs-parser.js sql.pegjs" ,
89 "test" : " npm run lint && mocha" ,
You can’t perform that action at this time.
0 commit comments