alasql 4.5.2 → 4.6.1

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.
@@ -1,7 +1,7 @@
1
- //! AlaSQL v4.5.1 build: develop-a7daf2ff | © 2014-2024 Andrey Gershun & Mathias Wulff | License: MIT
1
+ //! AlaSQL v4.6.0 build: develop-e45f0308 | © 2014-2024 Andrey Gershun & Mathias Wulff | License: MIT
2
2
  /*
3
3
  @module alasql
4
- @version 4.5.1
4
+ @version 4.6.0
5
5
 
6
6
  AlaSQL - JavaScript SQL database
7
7
  © 2014-2024 Andrey Gershun & Mathias Wulff
package/dist/alasql.d.ts CHANGED
@@ -3,8 +3,9 @@
3
3
  declare module 'alasql' {
4
4
  import * as xlsx from 'xlsx';
5
5
 
6
- interface AlaSQLCallback {
7
- (data?: any, err?: Error): void;
6
+ // Callback with error-first convention and optional data
7
+ interface AlaSQLCallback<T = unknown> {
8
+ (err: Error | null, data?: T): void;
8
9
  }
9
10
 
10
11
  interface AlaSQLOptions {
@@ -15,7 +16,7 @@ declare module 'alasql' {
15
16
  casesensitive: boolean; // table and column names are case sensitive and converted to lower-case
16
17
  logtarget: string; // target for log. Values: 'console', 'output', 'id' of html tag
17
18
  logprompt: boolean; // print SQL at log
18
- modifier: any; // values: RECORDSET, VALUE, ROW, COLUMN, MATRIX, TEXTSTRING, INDEX
19
+ modifier?: 'RECORDSET' | 'VALUE' | 'ROW' | 'COLUMN' | 'MATRIX' | 'TEXTSTRING' | 'INDEX';
19
20
  columnlookup: number; // how many rows to lookup to define columns
20
21
  autovertex: boolean; // create vertex if not found
21
22
  usedbo: boolean; // use dbo as current database (for partial T-SQL comaptibility)
@@ -30,12 +31,12 @@ declare module 'alasql' {
30
31
  oracle: boolean;
31
32
  sqlite: boolean;
32
33
  orientdb: boolean;
33
- excel: any;
34
+ excel?: xlsx.WorkBook; // now typed
34
35
  }
35
36
 
36
37
  // compiled Statement
37
38
  interface AlaSQLStatement {
38
- (params?: any, cb?: AlaSQLCallback, scope?: any): any;
39
+ <T = unknown>(params?: Record<string, unknown>, cb?: AlaSQLCallback<T>, scope?: unknown): T;
39
40
  }
40
41
 
41
42
  // abstract Syntax Tree
@@ -43,22 +44,9 @@ declare module 'alasql' {
43
44
  compile(databaseid: string): AlaSQLStatement;
44
45
  }
45
46
 
46
- // https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/es6-promise/es6-promise.d.ts
47
- interface Thenable<T> {
48
- then<U>(
49
- onFulfilled?: (value: T) => U | Thenable<U>,
50
- onRejected?: (error: any) => U | Thenable<U>
51
- ): Thenable<U>;
52
- then<U>(
53
- onFulfilled?: (value: T) => U | Thenable<U>,
54
- onRejected?: (error: any) => void
55
- ): Thenable<U>;
56
- catch<U>(onRejected?: (error: any) => U | Thenable<U>): Thenable<U>;
57
- }
58
-
59
47
  // see https://github.com/alasql/alasql/wiki/User%20Defined%20Functions
60
48
  interface userDefinedFunction {
61
- (...x: any[]): any;
49
+ (...x: unknown[]): unknown;
62
50
  }
63
51
 
64
52
  interface userDefinedFunctionLookUp {
@@ -67,7 +55,7 @@ declare module 'alasql' {
67
55
 
68
56
  // see https://github.com/alasql/alasql/wiki/User%20Defined%20Functions
69
57
  interface userAggregator {
70
- (value: any, accumulator: any, stage: number): any;
58
+ (value: unknown, accumulator: unknown, stage: number): unknown;
71
59
  }
72
60
 
73
61
  interface userAggregatorLookUp {
@@ -75,7 +63,13 @@ declare module 'alasql' {
75
63
  }
76
64
 
77
65
  interface userFromFunction {
78
- (dataReference: any, options: any, callback: any, index: any, query: any): any;
66
+ (
67
+ dataReference: unknown,
68
+ options: unknown,
69
+ callback: (res: unknown) => void,
70
+ index: unknown,
71
+ query: unknown
72
+ ): void;
79
73
  }
80
74
 
81
75
  interface userFromFunctionLookUp {
@@ -117,7 +111,7 @@ declare module 'alasql' {
117
111
  * @type {any[]}
118
112
  * @memberof table
119
113
  */
120
- data: any[];
114
+ data: unknown[];
121
115
  }
122
116
 
123
117
  /**
@@ -142,25 +136,31 @@ declare module 'alasql' {
142
136
  new (databaseid?: string): Database;
143
137
  databaseid: string;
144
138
  dbversion: number;
145
- tables: {[key: string]: any};
146
- views: {[key: string]: any};
147
- triggers: {[key: string]: any};
148
- indices: {[key: string]: any};
149
- objects: {[key: string]: any};
139
+ tables: {[key: string]: unknown};
140
+ views: {[key: string]: unknown};
141
+ triggers: {[key: string]: unknown};
142
+ indices: {[key: string]: unknown};
143
+ objects: {[key: string]: unknown};
150
144
  counter: number;
151
- sqlCache: {[key: string]: any};
145
+ sqlCache: {[key: string]: unknown};
152
146
  sqlCacheSize: number;
153
- astCache: {[key: string]: any};
154
- resetSqlCache: () => void;
155
- exec: (sql: string, params?: object, cb?: Function) => any;
156
- autoval: (tablename: string, colname: string, getNext: boolean) => any;
147
+ astCache: {[key: string]: unknown};
148
+ resetSqlCache(): void;
149
+ exec<T = unknown>(sql: string, params?: Record<string, unknown>, cb?: AlaSQLCallback<T>): T;
150
+ autoval(tablename: string, colname: string, getNext: boolean): unknown;
157
151
  }
152
+
158
153
  interface AlaSQL {
159
154
  options: AlaSQLOptions;
160
155
  error: Error;
161
- (sql: any, params?: any, cb?: AlaSQLCallback, scope?: any): any;
162
- parse(sql: any): AlaSQLAST;
163
- promise(sql: any, params?: any): Thenable<any>;
156
+ <T = unknown>(
157
+ sql: string,
158
+ params?: Record<string, unknown>,
159
+ cb?: AlaSQLCallback<T>,
160
+ scope?: unknown
161
+ ): T;
162
+ parse(sql: string): AlaSQLAST;
163
+ promise<T = unknown>(sql: string, params?: Record<string, unknown>): Promise<T>;
164
164
  fn: userDefinedFunctionLookUp;
165
165
  from: userFromFunctionLookUp;
166
166
  aggr: userAggregatorLookUp;
@@ -200,7 +200,7 @@ declare module 'alasql' {
200
200
 
201
201
  /**
202
202
  * Array of the tables in the default database (called alasql). If
203
- * the database is changes via a USE statement or the use method, this
203
+ * the database is changed via a USE statement or the use method, this
204
204
  * becomes the tables in the new database.
205
205
  *
206
206
  * @type {tableLookUp}