-
Notifications
You must be signed in to change notification settings - Fork 665
/
Copy pathalasql.d.ts
195 lines (171 loc) · 4.65 KB
/
alasql.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
// Project: https://github.com/alasql/alasql
declare module 'alasql' {
import * as xlsx from 'xlsx';
interface AlaSQLCallback {
(data?: any, err?: Error): void;
}
interface AlaSQLOptions {
errorlog: boolean;
valueof: boolean;
dropifnotexists: boolean; // drop database in any case
datetimeformat: string; // how to handle DATE and DATETIME types
casesensitive: boolean; // table and column names are case sensitive and converted to lower-case
logtarget: string; // target for log. Values: 'console', 'output', 'id' of html tag
logprompt: boolean; // print SQL at log
modifier: any; // values: RECORDSET, VALUE, ROW, COLUMN, MATRIX, TEXTSTRING, INDEX
columnlookup: number; // how many rows to lookup to define columns
autovertex: boolean; // create vertex if not found
usedbo: boolean; // use dbo as current database (for partial T-SQL comaptibility)
autocommit: boolean; // the AUTOCOMMIT ON | OFF
cache: boolean; // use cache
nocount: boolean; // for SET NOCOUNT OFF
nan: boolean; // check for NaN and convert it to undefined
angularjs: boolean;
tsql: boolean;
mysql: boolean;
postgres: boolean;
oracle: boolean;
sqlite: boolean;
orientdb: boolean;
excel: any;
}
// compiled Statement
interface AlaSQLStatement {
(params?: any, cb?: AlaSQLCallback, scope?: any): any;
}
// abstract Syntax Tree
interface AlaSQLAST {
compile(databaseid: string): AlaSQLStatement;
}
// https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/es6-promise/es6-promise.d.ts
interface Thenable<T> {
then<U>(
onFulfilled?: (value: T) => U | Thenable<U>,
onRejected?: (error: any) => U | Thenable<U>
): Thenable<U>;
then<U>(
onFulfilled?: (value: T) => U | Thenable<U>,
onRejected?: (error: any) => void
): Thenable<U>;
catch<U>(onRejected?: (error: any) => U | Thenable<U>): Thenable<U>;
}
// see https://github.com/alasql/alasql/wiki/User%20Defined%20Functions
interface userDefinedFunction {
(...x: any[]): any;
}
interface userDefinedFunctionLookUp {
[x: string]: userDefinedFunction;
}
// see https://github.com/alasql/alasql/wiki/User%20Defined%20Functions
interface userAggregator {
(value: any, accumulator: any, stage: number): any;
}
interface userAggregatorLookUp {
[x: string]: userAggregator;
}
interface userFromFunction {
(dataReference: any, options: any, callback: any, index: any, query: any): any;
}
interface userFromFunctionLookUp {
[x: string]: userFromFunction;
}
/**
* AlaSQL database object. This is a lightweight implimentation
*
* @interface database
*/
interface database {
/**
* The database ID.
*
* @type {string}
* @memberof database
*/
databaseid: string;
/**
* The collection of tables in the database.
*
* @type {tableLookUp}
* @memberof database
*/
tables: tableLookUp;
}
/**
* AlaSQL table object. This is a lightweight implimentation
*
* @interface table
*/
interface table {
/**
* The array of data stored in the table which can be queried
*
* @type {any[]}
* @memberof table
*/
data: any[];
}
/**
* AlaSQL database dictionary
*
* @interface databaseLookUp
*/
interface databaseLookUp {
[databaseName: string]: database;
}
/**
* AlaSQL table dictionary
*
* @interface tableLookUp
*/
interface tableLookUp {
[tableName: string]: table;
}
interface AlaSQL {
options: AlaSQLOptions;
error: Error;
(sql: any, params?: any, cb?: AlaSQLCallback, scope?: any): any;
parse(sql: any): AlaSQLAST;
promise(sql: any, params?: any): Thenable<any>;
fn: userDefinedFunctionLookUp;
from: userFromFunctionLookUp;
aggr: userAggregatorLookUp;
autoval(tablename: string, colname: string, getNext?: boolean): number;
yy: {};
setXLSX(xlsxlib: typeof xlsx): void;
/**
* Array of databases in the AlaSQL object.
*
* @type {databaseLookUp}
* @memberof AlaSQL
*/
databases: databaseLookUp;
/**
* Equivalent to alasql('USE '+databaseid). This will change the current
* database to the one specified. This will update the useid property and
* the tables property.
*
* @param {string} databaseid
* @memberof AlaSQL
*/
use(databaseid: string): void;
/**
* The current database ID. If no database is selected, this is the
* default database ID (called alasql).
*
* @type {string}
* @memberof AlaSQL
*/
useid: string;
/**
* Array of the tables in the default database (called alasql). If
* the database is changes via a USE statement or the use method, this
* becomes the tables in the new database.
*
* @type {tableLookUp}
* @memberof AlaSQL
*/
tables: tableLookUp;
}
const alasql: AlaSQL;
export = alasql;
}