@guanmingchiu/sqlparser-ts 0.60.0-rc3
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/README.md +89 -0
- package/dist/index.cjs +403 -0
- package/dist/index.d.cts +1309 -0
- package/dist/index.d.mts +1309 -0
- package/dist/index.mjs +379 -0
- package/package.json +62 -0
- package/wasm/LICENSE +201 -0
- package/wasm/README.md +89 -0
- package/wasm/package.json +17 -0
- package/wasm/sqlparser_rs_wasm.d.ts +39 -0
- package/wasm/sqlparser_rs_wasm.js +541 -0
- package/wasm/sqlparser_rs_wasm_bg.wasm +0 -0
- package/wasm/sqlparser_rs_wasm_bg.wasm.d.ts +19 -0
- package/wasm/sqlparser_rs_wasm_web.js +628 -0
- package/wasm/sqlparser_rs_wasm_web_bg.wasm +0 -0
package/wasm/README.md
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# sqlparser-ts
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@guanmingchiu/sqlparser-ts)
|
|
4
|
+
[](https://www.npmjs.com/package/@guanmingchiu/sqlparser-ts)
|
|
5
|
+
[](LICENSE)
|
|
6
|
+
[](https://webassembly.org/)
|
|
7
|
+
[](https://github.com/apache/datafusion-sqlparser-rs)
|
|
8
|
+
|
|
9
|
+
SQL parser for JavaScript and TypeScript, powered by [datafusion-sqlparser-rs](https://github.com/apache/datafusion-sqlparser-rs) via WebAssembly.
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
- Parse SQL into a detailed AST with full TypeScript types
|
|
14
|
+
- Support 14 SQL dialects (PostgreSQL, MySQL, SQLite, BigQuery, and more)
|
|
15
|
+
- Run in Node.js and browsers
|
|
16
|
+
- Stay small (~600KB gzipped) and fast (Rust + WebAssembly)
|
|
17
|
+
- Ship zero native dependencies
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm install @guanmingchiu/sqlparser-ts
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
import { parse, format, validate } from '@guanmingchiu/sqlparser-ts';
|
|
29
|
+
|
|
30
|
+
// Parse SQL into AST
|
|
31
|
+
const ast = parse('SELECT * FROM users');
|
|
32
|
+
|
|
33
|
+
// With specific dialect
|
|
34
|
+
const ast = parse('SELECT * FROM users WHERE id = $1', 'postgresql');
|
|
35
|
+
|
|
36
|
+
// Format SQL
|
|
37
|
+
const sql = format('select * from users');
|
|
38
|
+
// "SELECT * FROM users"
|
|
39
|
+
|
|
40
|
+
// Validate SQL (throws on invalid)
|
|
41
|
+
validate('SELECT * FROM users'); // ok
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Working with AST
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
// Parse and inspect
|
|
48
|
+
const ast = parse('SELECT id, name FROM users WHERE active = true');
|
|
49
|
+
console.log(JSON.stringify(ast, null, 2));
|
|
50
|
+
|
|
51
|
+
// Multiple statements
|
|
52
|
+
const statements = parse(`
|
|
53
|
+
SELECT * FROM users;
|
|
54
|
+
SELECT * FROM orders;
|
|
55
|
+
`);
|
|
56
|
+
console.log(statements.length); // 2
|
|
57
|
+
|
|
58
|
+
// Modify AST and convert back to SQL
|
|
59
|
+
const ast = parse('SELECT * FROM users')[0];
|
|
60
|
+
// ... modify ast ...
|
|
61
|
+
const sql = format(JSON.stringify([ast]));
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Error Handling
|
|
65
|
+
|
|
66
|
+
```typescript
|
|
67
|
+
try {
|
|
68
|
+
parse('SELEC * FORM users');
|
|
69
|
+
} catch (e) {
|
|
70
|
+
console.error(e.message); // Parse error details
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Supported Dialects
|
|
75
|
+
|
|
76
|
+
`generic`, `ansi`, `mysql`, `postgresql`, `sqlite`, `snowflake`, `redshift`, `mssql`, `clickhouse`, `bigquery`, `duckdb`, `databricks`, `hive`, `oracle`
|
|
77
|
+
|
|
78
|
+
## Versioning
|
|
79
|
+
|
|
80
|
+
Follows [Semantic Versioning](https://semver.org/) with upstream tracking:
|
|
81
|
+
|
|
82
|
+
- MAJOR.MINOR: Tracks upstream [datafusion-sqlparser-rs](https://github.com/apache/datafusion-sqlparser-rs)
|
|
83
|
+
- PATCH: sqlparser-ts specific releases
|
|
84
|
+
|
|
85
|
+
Example: `0.60.4` = upstream 0.60 + 4 sqlparser-ts releases
|
|
86
|
+
|
|
87
|
+
## License
|
|
88
|
+
|
|
89
|
+
Apache-2.0
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "sqlparser-rs-wasm",
|
|
3
|
+
"description": "WebAssembly bindings for sqlparser SQL parser",
|
|
4
|
+
"version": "0.60.0-rc3",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/guanmingchiu/sqlparser-ts"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"sqlparser_rs_wasm_bg.wasm",
|
|
12
|
+
"sqlparser_rs_wasm.js",
|
|
13
|
+
"sqlparser_rs_wasm.d.ts"
|
|
14
|
+
],
|
|
15
|
+
"main": "sqlparser_rs_wasm.js",
|
|
16
|
+
"types": "sqlparser_rs_wasm.d.ts"
|
|
17
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Format SQL by parsing and regenerating it (round-trip)
|
|
6
|
+
*/
|
|
7
|
+
export function format_sql(dialect: string, sql: string): string;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Get a list of all supported dialect names
|
|
11
|
+
*/
|
|
12
|
+
export function get_supported_dialects(): any;
|
|
13
|
+
|
|
14
|
+
export function init(): void;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Parse SQL and return the AST as a JSON value
|
|
18
|
+
*/
|
|
19
|
+
export function parse_sql(dialect: string, sql: string): any;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Parse SQL and return the AST as a JSON string
|
|
23
|
+
*/
|
|
24
|
+
export function parse_sql_to_json_string(dialect: string, sql: string): string;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Parse SQL and return a string representation of the AST
|
|
28
|
+
*/
|
|
29
|
+
export function parse_sql_to_string(dialect: string, sql: string): string;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Parse SQL with options and return the AST as a JSON value
|
|
33
|
+
*/
|
|
34
|
+
export function parse_sql_with_options(dialect: string, sql: string, options: any): any;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Validate SQL syntax without returning the full AST
|
|
38
|
+
*/
|
|
39
|
+
export function validate_sql(dialect: string, sql: string): boolean;
|
|
@@ -0,0 +1,541 @@
|
|
|
1
|
+
/* @ts-self-types="./sqlparser_rs_wasm.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Format SQL by parsing and regenerating it (round-trip)
|
|
5
|
+
* @param {string} dialect
|
|
6
|
+
* @param {string} sql
|
|
7
|
+
* @returns {string}
|
|
8
|
+
*/
|
|
9
|
+
function format_sql(dialect, sql) {
|
|
10
|
+
let deferred4_0;
|
|
11
|
+
let deferred4_1;
|
|
12
|
+
try {
|
|
13
|
+
const ptr0 = passStringToWasm0(dialect, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
14
|
+
const len0 = WASM_VECTOR_LEN;
|
|
15
|
+
const ptr1 = passStringToWasm0(sql, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
16
|
+
const len1 = WASM_VECTOR_LEN;
|
|
17
|
+
const ret = wasm.format_sql(ptr0, len0, ptr1, len1);
|
|
18
|
+
var ptr3 = ret[0];
|
|
19
|
+
var len3 = ret[1];
|
|
20
|
+
if (ret[3]) {
|
|
21
|
+
ptr3 = 0; len3 = 0;
|
|
22
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
23
|
+
}
|
|
24
|
+
deferred4_0 = ptr3;
|
|
25
|
+
deferred4_1 = len3;
|
|
26
|
+
return getStringFromWasm0(ptr3, len3);
|
|
27
|
+
} finally {
|
|
28
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.format_sql = format_sql;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Get a list of all supported dialect names
|
|
35
|
+
* @returns {any}
|
|
36
|
+
*/
|
|
37
|
+
function get_supported_dialects() {
|
|
38
|
+
const ret = wasm.get_supported_dialects();
|
|
39
|
+
return ret;
|
|
40
|
+
}
|
|
41
|
+
exports.get_supported_dialects = get_supported_dialects;
|
|
42
|
+
|
|
43
|
+
function init() {
|
|
44
|
+
wasm.init();
|
|
45
|
+
}
|
|
46
|
+
exports.init = init;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Parse SQL and return the AST as a JSON value
|
|
50
|
+
* @param {string} dialect
|
|
51
|
+
* @param {string} sql
|
|
52
|
+
* @returns {any}
|
|
53
|
+
*/
|
|
54
|
+
function parse_sql(dialect, sql) {
|
|
55
|
+
const ptr0 = passStringToWasm0(dialect, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
56
|
+
const len0 = WASM_VECTOR_LEN;
|
|
57
|
+
const ptr1 = passStringToWasm0(sql, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
58
|
+
const len1 = WASM_VECTOR_LEN;
|
|
59
|
+
const ret = wasm.parse_sql(ptr0, len0, ptr1, len1);
|
|
60
|
+
if (ret[2]) {
|
|
61
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
62
|
+
}
|
|
63
|
+
return takeFromExternrefTable0(ret[0]);
|
|
64
|
+
}
|
|
65
|
+
exports.parse_sql = parse_sql;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Parse SQL and return the AST as a JSON string
|
|
69
|
+
* @param {string} dialect
|
|
70
|
+
* @param {string} sql
|
|
71
|
+
* @returns {string}
|
|
72
|
+
*/
|
|
73
|
+
function parse_sql_to_json_string(dialect, sql) {
|
|
74
|
+
let deferred4_0;
|
|
75
|
+
let deferred4_1;
|
|
76
|
+
try {
|
|
77
|
+
const ptr0 = passStringToWasm0(dialect, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
78
|
+
const len0 = WASM_VECTOR_LEN;
|
|
79
|
+
const ptr1 = passStringToWasm0(sql, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
80
|
+
const len1 = WASM_VECTOR_LEN;
|
|
81
|
+
const ret = wasm.parse_sql_to_json_string(ptr0, len0, ptr1, len1);
|
|
82
|
+
var ptr3 = ret[0];
|
|
83
|
+
var len3 = ret[1];
|
|
84
|
+
if (ret[3]) {
|
|
85
|
+
ptr3 = 0; len3 = 0;
|
|
86
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
87
|
+
}
|
|
88
|
+
deferred4_0 = ptr3;
|
|
89
|
+
deferred4_1 = len3;
|
|
90
|
+
return getStringFromWasm0(ptr3, len3);
|
|
91
|
+
} finally {
|
|
92
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
exports.parse_sql_to_json_string = parse_sql_to_json_string;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Parse SQL and return a string representation of the AST
|
|
99
|
+
* @param {string} dialect
|
|
100
|
+
* @param {string} sql
|
|
101
|
+
* @returns {string}
|
|
102
|
+
*/
|
|
103
|
+
function parse_sql_to_string(dialect, sql) {
|
|
104
|
+
let deferred4_0;
|
|
105
|
+
let deferred4_1;
|
|
106
|
+
try {
|
|
107
|
+
const ptr0 = passStringToWasm0(dialect, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
108
|
+
const len0 = WASM_VECTOR_LEN;
|
|
109
|
+
const ptr1 = passStringToWasm0(sql, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
110
|
+
const len1 = WASM_VECTOR_LEN;
|
|
111
|
+
const ret = wasm.parse_sql_to_string(ptr0, len0, ptr1, len1);
|
|
112
|
+
var ptr3 = ret[0];
|
|
113
|
+
var len3 = ret[1];
|
|
114
|
+
if (ret[3]) {
|
|
115
|
+
ptr3 = 0; len3 = 0;
|
|
116
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
117
|
+
}
|
|
118
|
+
deferred4_0 = ptr3;
|
|
119
|
+
deferred4_1 = len3;
|
|
120
|
+
return getStringFromWasm0(ptr3, len3);
|
|
121
|
+
} finally {
|
|
122
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
exports.parse_sql_to_string = parse_sql_to_string;
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Parse SQL with options and return the AST as a JSON value
|
|
129
|
+
* @param {string} dialect
|
|
130
|
+
* @param {string} sql
|
|
131
|
+
* @param {any} options
|
|
132
|
+
* @returns {any}
|
|
133
|
+
*/
|
|
134
|
+
function parse_sql_with_options(dialect, sql, options) {
|
|
135
|
+
const ptr0 = passStringToWasm0(dialect, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
136
|
+
const len0 = WASM_VECTOR_LEN;
|
|
137
|
+
const ptr1 = passStringToWasm0(sql, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
138
|
+
const len1 = WASM_VECTOR_LEN;
|
|
139
|
+
const ret = wasm.parse_sql_with_options(ptr0, len0, ptr1, len1, options);
|
|
140
|
+
if (ret[2]) {
|
|
141
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
142
|
+
}
|
|
143
|
+
return takeFromExternrefTable0(ret[0]);
|
|
144
|
+
}
|
|
145
|
+
exports.parse_sql_with_options = parse_sql_with_options;
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Validate SQL syntax without returning the full AST
|
|
149
|
+
* @param {string} dialect
|
|
150
|
+
* @param {string} sql
|
|
151
|
+
* @returns {boolean}
|
|
152
|
+
*/
|
|
153
|
+
function validate_sql(dialect, sql) {
|
|
154
|
+
const ptr0 = passStringToWasm0(dialect, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
155
|
+
const len0 = WASM_VECTOR_LEN;
|
|
156
|
+
const ptr1 = passStringToWasm0(sql, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
157
|
+
const len1 = WASM_VECTOR_LEN;
|
|
158
|
+
const ret = wasm.validate_sql(ptr0, len0, ptr1, len1);
|
|
159
|
+
if (ret[2]) {
|
|
160
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
161
|
+
}
|
|
162
|
+
return ret[0] !== 0;
|
|
163
|
+
}
|
|
164
|
+
exports.validate_sql = validate_sql;
|
|
165
|
+
|
|
166
|
+
function __wbg_get_imports() {
|
|
167
|
+
const import0 = {
|
|
168
|
+
__proto__: null,
|
|
169
|
+
__wbg_Error_8c4e43fe74559d73: function(arg0, arg1) {
|
|
170
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
171
|
+
return ret;
|
|
172
|
+
},
|
|
173
|
+
__wbg_Number_04624de7d0e8332d: function(arg0) {
|
|
174
|
+
const ret = Number(arg0);
|
|
175
|
+
return ret;
|
|
176
|
+
},
|
|
177
|
+
__wbg_String_8f0eb39a4a4c2f66: function(arg0, arg1) {
|
|
178
|
+
const ret = String(arg1);
|
|
179
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
180
|
+
const len1 = WASM_VECTOR_LEN;
|
|
181
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
182
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
183
|
+
},
|
|
184
|
+
__wbg___wbindgen_bigint_get_as_i64_8fcf4ce7f1ca72a2: function(arg0, arg1) {
|
|
185
|
+
const v = arg1;
|
|
186
|
+
const ret = typeof(v) === 'bigint' ? v : undefined;
|
|
187
|
+
getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
|
|
188
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
189
|
+
},
|
|
190
|
+
__wbg___wbindgen_boolean_get_bbbb1c18aa2f5e25: function(arg0) {
|
|
191
|
+
const v = arg0;
|
|
192
|
+
const ret = typeof(v) === 'boolean' ? v : undefined;
|
|
193
|
+
return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
|
|
194
|
+
},
|
|
195
|
+
__wbg___wbindgen_debug_string_0bc8482c6e3508ae: function(arg0, arg1) {
|
|
196
|
+
const ret = debugString(arg1);
|
|
197
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
198
|
+
const len1 = WASM_VECTOR_LEN;
|
|
199
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
200
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
201
|
+
},
|
|
202
|
+
__wbg___wbindgen_in_47fa6863be6f2f25: function(arg0, arg1) {
|
|
203
|
+
const ret = arg0 in arg1;
|
|
204
|
+
return ret;
|
|
205
|
+
},
|
|
206
|
+
__wbg___wbindgen_is_bigint_31b12575b56f32fc: function(arg0) {
|
|
207
|
+
const ret = typeof(arg0) === 'bigint';
|
|
208
|
+
return ret;
|
|
209
|
+
},
|
|
210
|
+
__wbg___wbindgen_is_null_ac34f5003991759a: function(arg0) {
|
|
211
|
+
const ret = arg0 === null;
|
|
212
|
+
return ret;
|
|
213
|
+
},
|
|
214
|
+
__wbg___wbindgen_is_object_5ae8e5880f2c1fbd: function(arg0) {
|
|
215
|
+
const val = arg0;
|
|
216
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
217
|
+
return ret;
|
|
218
|
+
},
|
|
219
|
+
__wbg___wbindgen_is_undefined_9e4d92534c42d778: function(arg0) {
|
|
220
|
+
const ret = arg0 === undefined;
|
|
221
|
+
return ret;
|
|
222
|
+
},
|
|
223
|
+
__wbg___wbindgen_jsval_eq_11888390b0186270: function(arg0, arg1) {
|
|
224
|
+
const ret = arg0 === arg1;
|
|
225
|
+
return ret;
|
|
226
|
+
},
|
|
227
|
+
__wbg___wbindgen_jsval_loose_eq_9dd77d8cd6671811: function(arg0, arg1) {
|
|
228
|
+
const ret = arg0 == arg1;
|
|
229
|
+
return ret;
|
|
230
|
+
},
|
|
231
|
+
__wbg___wbindgen_number_get_8ff4255516ccad3e: function(arg0, arg1) {
|
|
232
|
+
const obj = arg1;
|
|
233
|
+
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
234
|
+
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
235
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
236
|
+
},
|
|
237
|
+
__wbg___wbindgen_string_get_72fb696202c56729: function(arg0, arg1) {
|
|
238
|
+
const obj = arg1;
|
|
239
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
240
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
241
|
+
var len1 = WASM_VECTOR_LEN;
|
|
242
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
243
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
244
|
+
},
|
|
245
|
+
__wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {
|
|
246
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
247
|
+
},
|
|
248
|
+
__wbg_error_7534b8e9a36f1ab4: function(arg0, arg1) {
|
|
249
|
+
let deferred0_0;
|
|
250
|
+
let deferred0_1;
|
|
251
|
+
try {
|
|
252
|
+
deferred0_0 = arg0;
|
|
253
|
+
deferred0_1 = arg1;
|
|
254
|
+
console.error(getStringFromWasm0(arg0, arg1));
|
|
255
|
+
} finally {
|
|
256
|
+
wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
|
|
257
|
+
}
|
|
258
|
+
},
|
|
259
|
+
__wbg_fromCodePoint_22365db7b7d6ac39: function() { return handleError(function (arg0) {
|
|
260
|
+
const ret = String.fromCodePoint(arg0 >>> 0);
|
|
261
|
+
return ret;
|
|
262
|
+
}, arguments); },
|
|
263
|
+
__wbg_get_with_ref_key_1dc361bd10053bfe: function(arg0, arg1) {
|
|
264
|
+
const ret = arg0[arg1];
|
|
265
|
+
return ret;
|
|
266
|
+
},
|
|
267
|
+
__wbg_instanceof_ArrayBuffer_c367199e2fa2aa04: function(arg0) {
|
|
268
|
+
let result;
|
|
269
|
+
try {
|
|
270
|
+
result = arg0 instanceof ArrayBuffer;
|
|
271
|
+
} catch (_) {
|
|
272
|
+
result = false;
|
|
273
|
+
}
|
|
274
|
+
const ret = result;
|
|
275
|
+
return ret;
|
|
276
|
+
},
|
|
277
|
+
__wbg_instanceof_Uint8Array_9b9075935c74707c: function(arg0) {
|
|
278
|
+
let result;
|
|
279
|
+
try {
|
|
280
|
+
result = arg0 instanceof Uint8Array;
|
|
281
|
+
} catch (_) {
|
|
282
|
+
result = false;
|
|
283
|
+
}
|
|
284
|
+
const ret = result;
|
|
285
|
+
return ret;
|
|
286
|
+
},
|
|
287
|
+
__wbg_isSafeInteger_bfbc7332a9768d2a: function(arg0) {
|
|
288
|
+
const ret = Number.isSafeInteger(arg0);
|
|
289
|
+
return ret;
|
|
290
|
+
},
|
|
291
|
+
__wbg_length_32ed9a279acd054c: function(arg0) {
|
|
292
|
+
const ret = arg0.length;
|
|
293
|
+
return ret;
|
|
294
|
+
},
|
|
295
|
+
__wbg_new_361308b2356cecd0: function() {
|
|
296
|
+
const ret = new Object();
|
|
297
|
+
return ret;
|
|
298
|
+
},
|
|
299
|
+
__wbg_new_3eb36ae241fe6f44: function() {
|
|
300
|
+
const ret = new Array();
|
|
301
|
+
return ret;
|
|
302
|
+
},
|
|
303
|
+
__wbg_new_8a6f238a6ece86ea: function() {
|
|
304
|
+
const ret = new Error();
|
|
305
|
+
return ret;
|
|
306
|
+
},
|
|
307
|
+
__wbg_new_dd2b680c8bf6ae29: function(arg0) {
|
|
308
|
+
const ret = new Uint8Array(arg0);
|
|
309
|
+
return ret;
|
|
310
|
+
},
|
|
311
|
+
__wbg_prototypesetcall_bdcdcc5842e4d77d: function(arg0, arg1, arg2) {
|
|
312
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
313
|
+
},
|
|
314
|
+
__wbg_set_3f1d0b984ed272ed: function(arg0, arg1, arg2) {
|
|
315
|
+
arg0[arg1] = arg2;
|
|
316
|
+
},
|
|
317
|
+
__wbg_set_f43e577aea94465b: function(arg0, arg1, arg2) {
|
|
318
|
+
arg0[arg1 >>> 0] = arg2;
|
|
319
|
+
},
|
|
320
|
+
__wbg_stack_0ed75d68575b0f3c: function(arg0, arg1) {
|
|
321
|
+
const ret = arg1.stack;
|
|
322
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
323
|
+
const len1 = WASM_VECTOR_LEN;
|
|
324
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
325
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
326
|
+
},
|
|
327
|
+
__wbindgen_cast_0000000000000001: function(arg0) {
|
|
328
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
329
|
+
const ret = arg0;
|
|
330
|
+
return ret;
|
|
331
|
+
},
|
|
332
|
+
__wbindgen_cast_0000000000000002: function(arg0) {
|
|
333
|
+
// Cast intrinsic for `I64 -> Externref`.
|
|
334
|
+
const ret = arg0;
|
|
335
|
+
return ret;
|
|
336
|
+
},
|
|
337
|
+
__wbindgen_cast_0000000000000003: function(arg0, arg1) {
|
|
338
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
339
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
340
|
+
return ret;
|
|
341
|
+
},
|
|
342
|
+
__wbindgen_cast_0000000000000004: function(arg0) {
|
|
343
|
+
// Cast intrinsic for `U64 -> Externref`.
|
|
344
|
+
const ret = BigInt.asUintN(64, arg0);
|
|
345
|
+
return ret;
|
|
346
|
+
},
|
|
347
|
+
__wbindgen_init_externref_table: function() {
|
|
348
|
+
const table = wasm.__wbindgen_externrefs;
|
|
349
|
+
const offset = table.grow(4);
|
|
350
|
+
table.set(0, undefined);
|
|
351
|
+
table.set(offset + 0, undefined);
|
|
352
|
+
table.set(offset + 1, null);
|
|
353
|
+
table.set(offset + 2, true);
|
|
354
|
+
table.set(offset + 3, false);
|
|
355
|
+
},
|
|
356
|
+
};
|
|
357
|
+
return {
|
|
358
|
+
__proto__: null,
|
|
359
|
+
"./sqlparser_rs_wasm_bg.js": import0,
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
function addToExternrefTable0(obj) {
|
|
364
|
+
const idx = wasm.__externref_table_alloc();
|
|
365
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
366
|
+
return idx;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
function debugString(val) {
|
|
370
|
+
// primitive types
|
|
371
|
+
const type = typeof val;
|
|
372
|
+
if (type == 'number' || type == 'boolean' || val == null) {
|
|
373
|
+
return `${val}`;
|
|
374
|
+
}
|
|
375
|
+
if (type == 'string') {
|
|
376
|
+
return `"${val}"`;
|
|
377
|
+
}
|
|
378
|
+
if (type == 'symbol') {
|
|
379
|
+
const description = val.description;
|
|
380
|
+
if (description == null) {
|
|
381
|
+
return 'Symbol';
|
|
382
|
+
} else {
|
|
383
|
+
return `Symbol(${description})`;
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
if (type == 'function') {
|
|
387
|
+
const name = val.name;
|
|
388
|
+
if (typeof name == 'string' && name.length > 0) {
|
|
389
|
+
return `Function(${name})`;
|
|
390
|
+
} else {
|
|
391
|
+
return 'Function';
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
// objects
|
|
395
|
+
if (Array.isArray(val)) {
|
|
396
|
+
const length = val.length;
|
|
397
|
+
let debug = '[';
|
|
398
|
+
if (length > 0) {
|
|
399
|
+
debug += debugString(val[0]);
|
|
400
|
+
}
|
|
401
|
+
for(let i = 1; i < length; i++) {
|
|
402
|
+
debug += ', ' + debugString(val[i]);
|
|
403
|
+
}
|
|
404
|
+
debug += ']';
|
|
405
|
+
return debug;
|
|
406
|
+
}
|
|
407
|
+
// Test for built-in
|
|
408
|
+
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
|
409
|
+
let className;
|
|
410
|
+
if (builtInMatches && builtInMatches.length > 1) {
|
|
411
|
+
className = builtInMatches[1];
|
|
412
|
+
} else {
|
|
413
|
+
// Failed to match the standard '[object ClassName]'
|
|
414
|
+
return toString.call(val);
|
|
415
|
+
}
|
|
416
|
+
if (className == 'Object') {
|
|
417
|
+
// we're a user defined class or Object
|
|
418
|
+
// JSON.stringify avoids problems with cycles, and is generally much
|
|
419
|
+
// easier than looping through ownProperties of `val`.
|
|
420
|
+
try {
|
|
421
|
+
return 'Object(' + JSON.stringify(val) + ')';
|
|
422
|
+
} catch (_) {
|
|
423
|
+
return 'Object';
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
// errors
|
|
427
|
+
if (val instanceof Error) {
|
|
428
|
+
return `${val.name}: ${val.message}\n${val.stack}`;
|
|
429
|
+
}
|
|
430
|
+
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
431
|
+
return className;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
435
|
+
ptr = ptr >>> 0;
|
|
436
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
let cachedDataViewMemory0 = null;
|
|
440
|
+
function getDataViewMemory0() {
|
|
441
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
442
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
443
|
+
}
|
|
444
|
+
return cachedDataViewMemory0;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
function getStringFromWasm0(ptr, len) {
|
|
448
|
+
ptr = ptr >>> 0;
|
|
449
|
+
return decodeText(ptr, len);
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
let cachedUint8ArrayMemory0 = null;
|
|
453
|
+
function getUint8ArrayMemory0() {
|
|
454
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
455
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
456
|
+
}
|
|
457
|
+
return cachedUint8ArrayMemory0;
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
function handleError(f, args) {
|
|
461
|
+
try {
|
|
462
|
+
return f.apply(this, args);
|
|
463
|
+
} catch (e) {
|
|
464
|
+
const idx = addToExternrefTable0(e);
|
|
465
|
+
wasm.__wbindgen_exn_store(idx);
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
function isLikeNone(x) {
|
|
470
|
+
return x === undefined || x === null;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
474
|
+
if (realloc === undefined) {
|
|
475
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
476
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
477
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
478
|
+
WASM_VECTOR_LEN = buf.length;
|
|
479
|
+
return ptr;
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
let len = arg.length;
|
|
483
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
484
|
+
|
|
485
|
+
const mem = getUint8ArrayMemory0();
|
|
486
|
+
|
|
487
|
+
let offset = 0;
|
|
488
|
+
|
|
489
|
+
for (; offset < len; offset++) {
|
|
490
|
+
const code = arg.charCodeAt(offset);
|
|
491
|
+
if (code > 0x7F) break;
|
|
492
|
+
mem[ptr + offset] = code;
|
|
493
|
+
}
|
|
494
|
+
if (offset !== len) {
|
|
495
|
+
if (offset !== 0) {
|
|
496
|
+
arg = arg.slice(offset);
|
|
497
|
+
}
|
|
498
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
499
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
500
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
501
|
+
|
|
502
|
+
offset += ret.written;
|
|
503
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
WASM_VECTOR_LEN = offset;
|
|
507
|
+
return ptr;
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
function takeFromExternrefTable0(idx) {
|
|
511
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
512
|
+
wasm.__externref_table_dealloc(idx);
|
|
513
|
+
return value;
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
517
|
+
cachedTextDecoder.decode();
|
|
518
|
+
function decodeText(ptr, len) {
|
|
519
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
const cachedTextEncoder = new TextEncoder();
|
|
523
|
+
|
|
524
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
525
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
526
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
527
|
+
view.set(buf);
|
|
528
|
+
return {
|
|
529
|
+
read: arg.length,
|
|
530
|
+
written: buf.length
|
|
531
|
+
};
|
|
532
|
+
};
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
let WASM_VECTOR_LEN = 0;
|
|
536
|
+
|
|
537
|
+
const wasmPath = `${__dirname}/sqlparser_rs_wasm_bg.wasm`;
|
|
538
|
+
const wasmBytes = require('fs').readFileSync(wasmPath);
|
|
539
|
+
const wasmModule = new WebAssembly.Module(wasmBytes);
|
|
540
|
+
const wasm = new WebAssembly.Instance(wasmModule, __wbg_get_imports()).exports;
|
|
541
|
+
wasm.__wbindgen_start();
|
|
Binary file
|