postgrest-parser 0.1.0 → 0.1.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.
- package/package.json +4 -5
- package/pkg/LICENSE +21 -0
- package/pkg/README.md +1082 -0
- package/pkg/client.d.ts +226 -0
- package/pkg/client.js +378 -0
- package/pkg/client.ts +528 -0
- package/pkg/package.json +31 -0
- package/pkg/postgrest_parser.d.ts +294 -0
- package/pkg/postgrest_parser.js +1144 -0
- package/pkg/postgrest_parser_bg.wasm +0 -0
- package/pkg/postgrest_parser_bg.wasm.d.ts +27 -0
- package/pkg/tsconfig.json +33 -0
- package/pkg/types.d.ts +174 -0
- package/pkg/types.js +16 -0
- package/pkg/types.ts +203 -0
|
@@ -0,0 +1,1144 @@
|
|
|
1
|
+
/* @ts-self-types="./postgrest_parser.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Result of parsing a PostgREST query, designed for TypeScript consumption.
|
|
5
|
+
*/
|
|
6
|
+
export class WasmQueryResult {
|
|
7
|
+
static __wrap(ptr) {
|
|
8
|
+
ptr = ptr >>> 0;
|
|
9
|
+
const obj = Object.create(WasmQueryResult.prototype);
|
|
10
|
+
obj.__wbg_ptr = ptr;
|
|
11
|
+
WasmQueryResultFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
12
|
+
return obj;
|
|
13
|
+
}
|
|
14
|
+
__destroy_into_raw() {
|
|
15
|
+
const ptr = this.__wbg_ptr;
|
|
16
|
+
this.__wbg_ptr = 0;
|
|
17
|
+
WasmQueryResultFinalization.unregister(this);
|
|
18
|
+
return ptr;
|
|
19
|
+
}
|
|
20
|
+
free() {
|
|
21
|
+
const ptr = this.__destroy_into_raw();
|
|
22
|
+
wasm.__wbg_wasmqueryresult_free(ptr, 0);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Get the query parameters as a JSON string
|
|
26
|
+
* @returns {any}
|
|
27
|
+
*/
|
|
28
|
+
get params() {
|
|
29
|
+
const ret = wasm.wasmqueryresult_params(this.__wbg_ptr);
|
|
30
|
+
return takeObject(ret);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Get the SQL query string
|
|
34
|
+
* @returns {string}
|
|
35
|
+
*/
|
|
36
|
+
get query() {
|
|
37
|
+
let deferred1_0;
|
|
38
|
+
let deferred1_1;
|
|
39
|
+
try {
|
|
40
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
41
|
+
wasm.wasmqueryresult_query(retptr, this.__wbg_ptr);
|
|
42
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
43
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
44
|
+
deferred1_0 = r0;
|
|
45
|
+
deferred1_1 = r1;
|
|
46
|
+
return getStringFromWasm0(r0, r1);
|
|
47
|
+
} finally {
|
|
48
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
49
|
+
wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Get the list of tables as a JSON array
|
|
54
|
+
* @returns {any}
|
|
55
|
+
*/
|
|
56
|
+
get tables() {
|
|
57
|
+
const ret = wasm.wasmqueryresult_tables(this.__wbg_ptr);
|
|
58
|
+
return takeObject(ret);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Get the entire result as a JSON object
|
|
62
|
+
* @returns {any}
|
|
63
|
+
*/
|
|
64
|
+
toJSON() {
|
|
65
|
+
const ret = wasm.wasmqueryresult_toJSON(this.__wbg_ptr);
|
|
66
|
+
return takeObject(ret);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (Symbol.dispose) WasmQueryResult.prototype[Symbol.dispose] = WasmQueryResult.prototype.free;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Build a WHERE clause from parsed filters.
|
|
73
|
+
*
|
|
74
|
+
* # Arguments
|
|
75
|
+
*
|
|
76
|
+
* * `filters_json` - JSON array of filter conditions
|
|
77
|
+
*
|
|
78
|
+
* # Returns
|
|
79
|
+
*
|
|
80
|
+
* Returns an object with `clause` (SQL string) and `params` (array of values).
|
|
81
|
+
* @param {any} filters_json
|
|
82
|
+
* @returns {any}
|
|
83
|
+
*/
|
|
84
|
+
export function buildFilterClause(filters_json) {
|
|
85
|
+
try {
|
|
86
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
87
|
+
wasm.buildFilterClause(retptr, addHeapObject(filters_json));
|
|
88
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
89
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
90
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
91
|
+
if (r2) {
|
|
92
|
+
throw takeObject(r1);
|
|
93
|
+
}
|
|
94
|
+
return takeObject(r0);
|
|
95
|
+
} finally {
|
|
96
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Initialize schema cache from a database query executor.
|
|
102
|
+
*
|
|
103
|
+
* This function accepts a JavaScript async function that executes SQL queries
|
|
104
|
+
* and returns results. The schema introspection queries will be executed via
|
|
105
|
+
* this callback to populate the relationship cache.
|
|
106
|
+
*
|
|
107
|
+
* # Arguments
|
|
108
|
+
*
|
|
109
|
+
* * `query_executor` - An async JavaScript function with signature:
|
|
110
|
+
* `async (sql: string) => { rows: any[] }`
|
|
111
|
+
*
|
|
112
|
+
* # Example (TypeScript with PGlite)
|
|
113
|
+
*
|
|
114
|
+
* ```typescript
|
|
115
|
+
* import { PGlite } from '@electric-sql/pglite';
|
|
116
|
+
* import { initSchemaFromDb } from './pkg/postgrest_parser.js';
|
|
117
|
+
*
|
|
118
|
+
* const db = new PGlite();
|
|
119
|
+
*
|
|
120
|
+
* // Create query executor for WASM
|
|
121
|
+
* const queryExecutor = async (sql: string) => {
|
|
122
|
+
* const result = await db.query(sql);
|
|
123
|
+
* return { rows: result.rows };
|
|
124
|
+
* };
|
|
125
|
+
*
|
|
126
|
+
* // Initialize schema from database
|
|
127
|
+
* await initSchemaFromDb(queryExecutor);
|
|
128
|
+
* ```
|
|
129
|
+
* @param {Function} query_executor
|
|
130
|
+
* @returns {Promise<void>}
|
|
131
|
+
*/
|
|
132
|
+
export function initSchemaFromDb(query_executor) {
|
|
133
|
+
const ret = wasm.initSchemaFromDb(addHeapObject(query_executor));
|
|
134
|
+
return takeObject(ret);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Initialize WASM module (call this first from JavaScript)
|
|
139
|
+
*/
|
|
140
|
+
export function init_panic_hook() {
|
|
141
|
+
wasm.init_panic_hook();
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Parse and generate SQL for a DELETE operation.
|
|
146
|
+
*
|
|
147
|
+
* # Arguments
|
|
148
|
+
*
|
|
149
|
+
* * `table` - The table name
|
|
150
|
+
* * `query_string` - Query string with filters and optional returning
|
|
151
|
+
* * `headers` - Optional headers as JSON string
|
|
152
|
+
*
|
|
153
|
+
* # Example (TypeScript)
|
|
154
|
+
*
|
|
155
|
+
* ```typescript
|
|
156
|
+
* const result = parseDelete("users", "id=eq.123&returning=id", null);
|
|
157
|
+
* console.log(result.query); // DELETE FROM "users" WHERE ...
|
|
158
|
+
* console.log(result.params); // ["123"]
|
|
159
|
+
* ```
|
|
160
|
+
* @param {string} table
|
|
161
|
+
* @param {string} query_string
|
|
162
|
+
* @param {string | null} [headers]
|
|
163
|
+
* @returns {WasmQueryResult}
|
|
164
|
+
*/
|
|
165
|
+
export function parseDelete(table, query_string, headers) {
|
|
166
|
+
try {
|
|
167
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
168
|
+
const ptr0 = passStringToWasm0(table, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
169
|
+
const len0 = WASM_VECTOR_LEN;
|
|
170
|
+
const ptr1 = passStringToWasm0(query_string, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
171
|
+
const len1 = WASM_VECTOR_LEN;
|
|
172
|
+
var ptr2 = isLikeNone(headers) ? 0 : passStringToWasm0(headers, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
173
|
+
var len2 = WASM_VECTOR_LEN;
|
|
174
|
+
wasm.parseDelete(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
|
|
175
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
176
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
177
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
178
|
+
if (r2) {
|
|
179
|
+
throw takeObject(r1);
|
|
180
|
+
}
|
|
181
|
+
return WasmQueryResult.__wrap(r0);
|
|
182
|
+
} finally {
|
|
183
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Parse and generate SQL for an INSERT operation.
|
|
189
|
+
*
|
|
190
|
+
* # Arguments
|
|
191
|
+
*
|
|
192
|
+
* * `table` - The table name
|
|
193
|
+
* * `body` - JSON body (single object or array of objects)
|
|
194
|
+
* * `query_string` - Optional query string for returning, on_conflict, etc.
|
|
195
|
+
* * `headers` - Optional headers as JSON string (e.g., '{"Prefer":"return=representation"}')
|
|
196
|
+
*
|
|
197
|
+
* # Example (TypeScript)
|
|
198
|
+
*
|
|
199
|
+
* ```typescript
|
|
200
|
+
* const result = parseInsert("users",
|
|
201
|
+
* JSON.stringify({ name: "Alice", email: "alice@example.com" }),
|
|
202
|
+
* "on_conflict=email&returning=id,name",
|
|
203
|
+
* JSON.stringify({ Prefer: "return=representation" })
|
|
204
|
+
* );
|
|
205
|
+
* console.log(result.query); // INSERT INTO "users" ...
|
|
206
|
+
* console.log(result.params); // ["Alice", "alice@example.com"]
|
|
207
|
+
* ```
|
|
208
|
+
* @param {string} table
|
|
209
|
+
* @param {string} body
|
|
210
|
+
* @param {string | null} [query_string]
|
|
211
|
+
* @param {string | null} [headers]
|
|
212
|
+
* @returns {WasmQueryResult}
|
|
213
|
+
*/
|
|
214
|
+
export function parseInsert(table, body, query_string, headers) {
|
|
215
|
+
try {
|
|
216
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
217
|
+
const ptr0 = passStringToWasm0(table, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
218
|
+
const len0 = WASM_VECTOR_LEN;
|
|
219
|
+
const ptr1 = passStringToWasm0(body, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
220
|
+
const len1 = WASM_VECTOR_LEN;
|
|
221
|
+
var ptr2 = isLikeNone(query_string) ? 0 : passStringToWasm0(query_string, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
222
|
+
var len2 = WASM_VECTOR_LEN;
|
|
223
|
+
var ptr3 = isLikeNone(headers) ? 0 : passStringToWasm0(headers, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
224
|
+
var len3 = WASM_VECTOR_LEN;
|
|
225
|
+
wasm.parseInsert(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
226
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
227
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
228
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
229
|
+
if (r2) {
|
|
230
|
+
throw takeObject(r1);
|
|
231
|
+
}
|
|
232
|
+
return WasmQueryResult.__wrap(r0);
|
|
233
|
+
} finally {
|
|
234
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Parse only the query string without generating SQL.
|
|
240
|
+
*
|
|
241
|
+
* Useful if you want to inspect the parsed structure before generating SQL.
|
|
242
|
+
*
|
|
243
|
+
* # Arguments
|
|
244
|
+
*
|
|
245
|
+
* * `query_string` - The PostgREST query string
|
|
246
|
+
*
|
|
247
|
+
* # Returns
|
|
248
|
+
*
|
|
249
|
+
* Returns the parsed parameters as a JSON object.
|
|
250
|
+
* @param {string} query_string
|
|
251
|
+
* @returns {any}
|
|
252
|
+
*/
|
|
253
|
+
export function parseOnly(query_string) {
|
|
254
|
+
try {
|
|
255
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
256
|
+
const ptr0 = passStringToWasm0(query_string, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
257
|
+
const len0 = WASM_VECTOR_LEN;
|
|
258
|
+
wasm.parseOnly(retptr, ptr0, len0);
|
|
259
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
260
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
261
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
262
|
+
if (r2) {
|
|
263
|
+
throw takeObject(r1);
|
|
264
|
+
}
|
|
265
|
+
return takeObject(r0);
|
|
266
|
+
} finally {
|
|
267
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Parse a PostgREST query string and convert it to SQL.
|
|
273
|
+
*
|
|
274
|
+
* # Arguments
|
|
275
|
+
*
|
|
276
|
+
* * `table` - The table name to query
|
|
277
|
+
* * `query_string` - The PostgREST query string (e.g., "select=id,name&age=gte.18")
|
|
278
|
+
*
|
|
279
|
+
* # Returns
|
|
280
|
+
*
|
|
281
|
+
* Returns a `WasmQueryResult` containing the SQL query, parameters, and affected tables.
|
|
282
|
+
*
|
|
283
|
+
* # Example (TypeScript)
|
|
284
|
+
*
|
|
285
|
+
* ```typescript
|
|
286
|
+
* const result = parseQueryString("users", "age=gte.18&status=eq.active");
|
|
287
|
+
* console.log(result.query); // SELECT * FROM "users" WHERE ...
|
|
288
|
+
* console.log(result.params); // ["18", "active"]
|
|
289
|
+
* console.log(result.tables); // ["users"]
|
|
290
|
+
* ```
|
|
291
|
+
* @param {string} table
|
|
292
|
+
* @param {string} query_string
|
|
293
|
+
* @returns {WasmQueryResult}
|
|
294
|
+
*/
|
|
295
|
+
export function parseQueryString(table, query_string) {
|
|
296
|
+
try {
|
|
297
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
298
|
+
const ptr0 = passStringToWasm0(table, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
299
|
+
const len0 = WASM_VECTOR_LEN;
|
|
300
|
+
const ptr1 = passStringToWasm0(query_string, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
301
|
+
const len1 = WASM_VECTOR_LEN;
|
|
302
|
+
wasm.parseQueryString(retptr, ptr0, len0, ptr1, len1);
|
|
303
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
304
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
305
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
306
|
+
if (r2) {
|
|
307
|
+
throw takeObject(r1);
|
|
308
|
+
}
|
|
309
|
+
return WasmQueryResult.__wrap(r0);
|
|
310
|
+
} finally {
|
|
311
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* Parse a complete HTTP request and generate appropriate SQL.
|
|
317
|
+
*
|
|
318
|
+
* This is the most comprehensive function - it handles all HTTP methods
|
|
319
|
+
* and automatically chooses between SELECT, INSERT, UPDATE, DELETE, or RPC.
|
|
320
|
+
*
|
|
321
|
+
* # Arguments
|
|
322
|
+
*
|
|
323
|
+
* * `method` - HTTP method: "GET", "POST", "PUT", "PATCH", "DELETE"
|
|
324
|
+
* * `path` - Resource path (table name or "rpc/function_name")
|
|
325
|
+
* * `query_string` - URL query string
|
|
326
|
+
* * `body` - Request body as JSON string (or null)
|
|
327
|
+
* * `headers` - Optional headers as JSON object (for Prefer header)
|
|
328
|
+
*
|
|
329
|
+
* # Example (TypeScript)
|
|
330
|
+
*
|
|
331
|
+
* ```typescript
|
|
332
|
+
* // SELECT query
|
|
333
|
+
* const getResult = parseRequest("GET", "users", "age=gte.18&limit=10", null, null);
|
|
334
|
+
*
|
|
335
|
+
* // INSERT with upsert
|
|
336
|
+
* const postResult = parseRequest("POST", "users", "on_conflict=email",
|
|
337
|
+
* JSON.stringify({ name: "Alice", email: "alice@example.com" }),
|
|
338
|
+
* JSON.stringify({ Prefer: "return=representation" })
|
|
339
|
+
* );
|
|
340
|
+
*
|
|
341
|
+
* // RPC call
|
|
342
|
+
* const rpcResult = parseRequest("POST", "rpc/my_function",
|
|
343
|
+
* "select=result",
|
|
344
|
+
* JSON.stringify({ arg1: "value" }),
|
|
345
|
+
* null
|
|
346
|
+
* );
|
|
347
|
+
* ```
|
|
348
|
+
* @param {string} method
|
|
349
|
+
* @param {string} path
|
|
350
|
+
* @param {string} query_string
|
|
351
|
+
* @param {string | null} [body]
|
|
352
|
+
* @param {string | null} [headers]
|
|
353
|
+
* @returns {WasmQueryResult}
|
|
354
|
+
*/
|
|
355
|
+
export function parseRequest(method, path, query_string, body, headers) {
|
|
356
|
+
try {
|
|
357
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
358
|
+
const ptr0 = passStringToWasm0(method, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
359
|
+
const len0 = WASM_VECTOR_LEN;
|
|
360
|
+
const ptr1 = passStringToWasm0(path, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
361
|
+
const len1 = WASM_VECTOR_LEN;
|
|
362
|
+
const ptr2 = passStringToWasm0(query_string, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
363
|
+
const len2 = WASM_VECTOR_LEN;
|
|
364
|
+
var ptr3 = isLikeNone(body) ? 0 : passStringToWasm0(body, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
365
|
+
var len3 = WASM_VECTOR_LEN;
|
|
366
|
+
var ptr4 = isLikeNone(headers) ? 0 : passStringToWasm0(headers, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
367
|
+
var len4 = WASM_VECTOR_LEN;
|
|
368
|
+
wasm.parseRequest(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4);
|
|
369
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
370
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
371
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
372
|
+
if (r2) {
|
|
373
|
+
throw takeObject(r1);
|
|
374
|
+
}
|
|
375
|
+
return WasmQueryResult.__wrap(r0);
|
|
376
|
+
} finally {
|
|
377
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
/**
|
|
382
|
+
* Parse and generate SQL for an RPC (stored procedure/function) call.
|
|
383
|
+
*
|
|
384
|
+
* # Arguments
|
|
385
|
+
*
|
|
386
|
+
* * `function_name` - The function name (can include schema: "schema.function")
|
|
387
|
+
* * `body` - JSON object with function arguments (or null for no args)
|
|
388
|
+
* * `query_string` - Optional query string for filtering/ordering results
|
|
389
|
+
* * `headers` - Optional headers as JSON string
|
|
390
|
+
*
|
|
391
|
+
* # Example (TypeScript)
|
|
392
|
+
*
|
|
393
|
+
* ```typescript
|
|
394
|
+
* const result = parseRpc("calculate_total",
|
|
395
|
+
* JSON.stringify({ order_id: 123, tax_rate: 0.08 }),
|
|
396
|
+
* "select=total,tax&limit=1",
|
|
397
|
+
* null
|
|
398
|
+
* );
|
|
399
|
+
* console.log(result.query); // SELECT * FROM calculate_total(...)
|
|
400
|
+
* console.log(result.params); // [123, 0.08]
|
|
401
|
+
* ```
|
|
402
|
+
* @param {string} function_name
|
|
403
|
+
* @param {string | null} [body]
|
|
404
|
+
* @param {string | null} [query_string]
|
|
405
|
+
* @param {string | null} [headers]
|
|
406
|
+
* @returns {WasmQueryResult}
|
|
407
|
+
*/
|
|
408
|
+
export function parseRpc(function_name, body, query_string, headers) {
|
|
409
|
+
try {
|
|
410
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
411
|
+
const ptr0 = passStringToWasm0(function_name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
412
|
+
const len0 = WASM_VECTOR_LEN;
|
|
413
|
+
var ptr1 = isLikeNone(body) ? 0 : passStringToWasm0(body, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
414
|
+
var len1 = WASM_VECTOR_LEN;
|
|
415
|
+
var ptr2 = isLikeNone(query_string) ? 0 : passStringToWasm0(query_string, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
416
|
+
var len2 = WASM_VECTOR_LEN;
|
|
417
|
+
var ptr3 = isLikeNone(headers) ? 0 : passStringToWasm0(headers, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
418
|
+
var len3 = WASM_VECTOR_LEN;
|
|
419
|
+
wasm.parseRpc(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
420
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
421
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
422
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
423
|
+
if (r2) {
|
|
424
|
+
throw takeObject(r1);
|
|
425
|
+
}
|
|
426
|
+
return WasmQueryResult.__wrap(r0);
|
|
427
|
+
} finally {
|
|
428
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
/**
|
|
433
|
+
* Parse and generate SQL for an UPDATE operation.
|
|
434
|
+
*
|
|
435
|
+
* # Arguments
|
|
436
|
+
*
|
|
437
|
+
* * `table` - The table name
|
|
438
|
+
* * `body` - JSON object with fields to update
|
|
439
|
+
* * `query_string` - Query string with filters and optional returning
|
|
440
|
+
* * `headers` - Optional headers as JSON string
|
|
441
|
+
*
|
|
442
|
+
* # Example (TypeScript)
|
|
443
|
+
*
|
|
444
|
+
* ```typescript
|
|
445
|
+
* const result = parseUpdate("users",
|
|
446
|
+
* JSON.stringify({ status: "active" }),
|
|
447
|
+
* "id=eq.123&returning=id,status",
|
|
448
|
+
* null
|
|
449
|
+
* );
|
|
450
|
+
* console.log(result.query); // UPDATE "users" SET ...
|
|
451
|
+
* console.log(result.params); // ["active", "123"]
|
|
452
|
+
* ```
|
|
453
|
+
* @param {string} table
|
|
454
|
+
* @param {string} body
|
|
455
|
+
* @param {string} query_string
|
|
456
|
+
* @param {string | null} [headers]
|
|
457
|
+
* @returns {WasmQueryResult}
|
|
458
|
+
*/
|
|
459
|
+
export function parseUpdate(table, body, query_string, headers) {
|
|
460
|
+
try {
|
|
461
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
462
|
+
const ptr0 = passStringToWasm0(table, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
463
|
+
const len0 = WASM_VECTOR_LEN;
|
|
464
|
+
const ptr1 = passStringToWasm0(body, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
465
|
+
const len1 = WASM_VECTOR_LEN;
|
|
466
|
+
const ptr2 = passStringToWasm0(query_string, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
467
|
+
const len2 = WASM_VECTOR_LEN;
|
|
468
|
+
var ptr3 = isLikeNone(headers) ? 0 : passStringToWasm0(headers, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
469
|
+
var len3 = WASM_VECTOR_LEN;
|
|
470
|
+
wasm.parseUpdate(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
471
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
472
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
473
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
474
|
+
if (r2) {
|
|
475
|
+
throw takeObject(r1);
|
|
476
|
+
}
|
|
477
|
+
return WasmQueryResult.__wrap(r0);
|
|
478
|
+
} finally {
|
|
479
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
function __wbg_get_imports() {
|
|
484
|
+
const import0 = {
|
|
485
|
+
__proto__: null,
|
|
486
|
+
__wbg_Error_8c4e43fe74559d73: function(arg0, arg1) {
|
|
487
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
488
|
+
return addHeapObject(ret);
|
|
489
|
+
},
|
|
490
|
+
__wbg_Number_04624de7d0e8332d: function(arg0) {
|
|
491
|
+
const ret = Number(getObject(arg0));
|
|
492
|
+
return ret;
|
|
493
|
+
},
|
|
494
|
+
__wbg_String_8f0eb39a4a4c2f66: function(arg0, arg1) {
|
|
495
|
+
const ret = String(getObject(arg1));
|
|
496
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
497
|
+
const len1 = WASM_VECTOR_LEN;
|
|
498
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
499
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
500
|
+
},
|
|
501
|
+
__wbg___wbindgen_bigint_get_as_i64_8fcf4ce7f1ca72a2: function(arg0, arg1) {
|
|
502
|
+
const v = getObject(arg1);
|
|
503
|
+
const ret = typeof(v) === 'bigint' ? v : undefined;
|
|
504
|
+
getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
|
|
505
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
506
|
+
},
|
|
507
|
+
__wbg___wbindgen_boolean_get_bbbb1c18aa2f5e25: function(arg0) {
|
|
508
|
+
const v = getObject(arg0);
|
|
509
|
+
const ret = typeof(v) === 'boolean' ? v : undefined;
|
|
510
|
+
return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
|
|
511
|
+
},
|
|
512
|
+
__wbg___wbindgen_debug_string_0bc8482c6e3508ae: function(arg0, arg1) {
|
|
513
|
+
const ret = debugString(getObject(arg1));
|
|
514
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
515
|
+
const len1 = WASM_VECTOR_LEN;
|
|
516
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
517
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
518
|
+
},
|
|
519
|
+
__wbg___wbindgen_in_47fa6863be6f2f25: function(arg0, arg1) {
|
|
520
|
+
const ret = getObject(arg0) in getObject(arg1);
|
|
521
|
+
return ret;
|
|
522
|
+
},
|
|
523
|
+
__wbg___wbindgen_is_bigint_31b12575b56f32fc: function(arg0) {
|
|
524
|
+
const ret = typeof(getObject(arg0)) === 'bigint';
|
|
525
|
+
return ret;
|
|
526
|
+
},
|
|
527
|
+
__wbg___wbindgen_is_function_0095a73b8b156f76: function(arg0) {
|
|
528
|
+
const ret = typeof(getObject(arg0)) === 'function';
|
|
529
|
+
return ret;
|
|
530
|
+
},
|
|
531
|
+
__wbg___wbindgen_is_object_5ae8e5880f2c1fbd: function(arg0) {
|
|
532
|
+
const val = getObject(arg0);
|
|
533
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
534
|
+
return ret;
|
|
535
|
+
},
|
|
536
|
+
__wbg___wbindgen_is_string_cd444516edc5b180: function(arg0) {
|
|
537
|
+
const ret = typeof(getObject(arg0)) === 'string';
|
|
538
|
+
return ret;
|
|
539
|
+
},
|
|
540
|
+
__wbg___wbindgen_is_undefined_9e4d92534c42d778: function(arg0) {
|
|
541
|
+
const ret = getObject(arg0) === undefined;
|
|
542
|
+
return ret;
|
|
543
|
+
},
|
|
544
|
+
__wbg___wbindgen_jsval_eq_11888390b0186270: function(arg0, arg1) {
|
|
545
|
+
const ret = getObject(arg0) === getObject(arg1);
|
|
546
|
+
return ret;
|
|
547
|
+
},
|
|
548
|
+
__wbg___wbindgen_jsval_loose_eq_9dd77d8cd6671811: function(arg0, arg1) {
|
|
549
|
+
const ret = getObject(arg0) == getObject(arg1);
|
|
550
|
+
return ret;
|
|
551
|
+
},
|
|
552
|
+
__wbg___wbindgen_number_get_8ff4255516ccad3e: function(arg0, arg1) {
|
|
553
|
+
const obj = getObject(arg1);
|
|
554
|
+
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
555
|
+
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
556
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
557
|
+
},
|
|
558
|
+
__wbg___wbindgen_string_get_72fb696202c56729: function(arg0, arg1) {
|
|
559
|
+
const obj = getObject(arg1);
|
|
560
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
561
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
562
|
+
var len1 = WASM_VECTOR_LEN;
|
|
563
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
564
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
565
|
+
},
|
|
566
|
+
__wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {
|
|
567
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
568
|
+
},
|
|
569
|
+
__wbg__wbg_cb_unref_d9b87ff7982e3b21: function(arg0) {
|
|
570
|
+
getObject(arg0)._wbg_cb_unref();
|
|
571
|
+
},
|
|
572
|
+
__wbg_call_389efe28435a9388: function() { return handleError(function (arg0, arg1) {
|
|
573
|
+
const ret = getObject(arg0).call(getObject(arg1));
|
|
574
|
+
return addHeapObject(ret);
|
|
575
|
+
}, arguments); },
|
|
576
|
+
__wbg_call_4708e0c13bdc8e95: function() { return handleError(function (arg0, arg1, arg2) {
|
|
577
|
+
const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
|
|
578
|
+
return addHeapObject(ret);
|
|
579
|
+
}, arguments); },
|
|
580
|
+
__wbg_done_57b39ecd9addfe81: function(arg0) {
|
|
581
|
+
const ret = getObject(arg0).done;
|
|
582
|
+
return ret;
|
|
583
|
+
},
|
|
584
|
+
__wbg_entries_58c7934c745daac7: function(arg0) {
|
|
585
|
+
const ret = Object.entries(getObject(arg0));
|
|
586
|
+
return addHeapObject(ret);
|
|
587
|
+
},
|
|
588
|
+
__wbg_error_7534b8e9a36f1ab4: function(arg0, arg1) {
|
|
589
|
+
let deferred0_0;
|
|
590
|
+
let deferred0_1;
|
|
591
|
+
try {
|
|
592
|
+
deferred0_0 = arg0;
|
|
593
|
+
deferred0_1 = arg1;
|
|
594
|
+
console.error(getStringFromWasm0(arg0, arg1));
|
|
595
|
+
} finally {
|
|
596
|
+
wasm.__wbindgen_export4(deferred0_0, deferred0_1, 1);
|
|
597
|
+
}
|
|
598
|
+
},
|
|
599
|
+
__wbg_get_9b94d73e6221f75c: function(arg0, arg1) {
|
|
600
|
+
const ret = getObject(arg0)[arg1 >>> 0];
|
|
601
|
+
return addHeapObject(ret);
|
|
602
|
+
},
|
|
603
|
+
__wbg_get_b3ed3ad4be2bc8ac: function() { return handleError(function (arg0, arg1) {
|
|
604
|
+
const ret = Reflect.get(getObject(arg0), getObject(arg1));
|
|
605
|
+
return addHeapObject(ret);
|
|
606
|
+
}, arguments); },
|
|
607
|
+
__wbg_get_with_ref_key_1dc361bd10053bfe: function(arg0, arg1) {
|
|
608
|
+
const ret = getObject(arg0)[getObject(arg1)];
|
|
609
|
+
return addHeapObject(ret);
|
|
610
|
+
},
|
|
611
|
+
__wbg_instanceof_ArrayBuffer_c367199e2fa2aa04: function(arg0) {
|
|
612
|
+
let result;
|
|
613
|
+
try {
|
|
614
|
+
result = getObject(arg0) instanceof ArrayBuffer;
|
|
615
|
+
} catch (_) {
|
|
616
|
+
result = false;
|
|
617
|
+
}
|
|
618
|
+
const ret = result;
|
|
619
|
+
return ret;
|
|
620
|
+
},
|
|
621
|
+
__wbg_instanceof_Map_53af74335dec57f4: function(arg0) {
|
|
622
|
+
let result;
|
|
623
|
+
try {
|
|
624
|
+
result = getObject(arg0) instanceof Map;
|
|
625
|
+
} catch (_) {
|
|
626
|
+
result = false;
|
|
627
|
+
}
|
|
628
|
+
const ret = result;
|
|
629
|
+
return ret;
|
|
630
|
+
},
|
|
631
|
+
__wbg_instanceof_Uint8Array_9b9075935c74707c: function(arg0) {
|
|
632
|
+
let result;
|
|
633
|
+
try {
|
|
634
|
+
result = getObject(arg0) instanceof Uint8Array;
|
|
635
|
+
} catch (_) {
|
|
636
|
+
result = false;
|
|
637
|
+
}
|
|
638
|
+
const ret = result;
|
|
639
|
+
return ret;
|
|
640
|
+
},
|
|
641
|
+
__wbg_isArray_d314bb98fcf08331: function(arg0) {
|
|
642
|
+
const ret = Array.isArray(getObject(arg0));
|
|
643
|
+
return ret;
|
|
644
|
+
},
|
|
645
|
+
__wbg_isSafeInteger_bfbc7332a9768d2a: function(arg0) {
|
|
646
|
+
const ret = Number.isSafeInteger(getObject(arg0));
|
|
647
|
+
return ret;
|
|
648
|
+
},
|
|
649
|
+
__wbg_iterator_6ff6560ca1568e55: function() {
|
|
650
|
+
const ret = Symbol.iterator;
|
|
651
|
+
return addHeapObject(ret);
|
|
652
|
+
},
|
|
653
|
+
__wbg_length_32ed9a279acd054c: function(arg0) {
|
|
654
|
+
const ret = getObject(arg0).length;
|
|
655
|
+
return ret;
|
|
656
|
+
},
|
|
657
|
+
__wbg_length_35a7bace40f36eac: function(arg0) {
|
|
658
|
+
const ret = getObject(arg0).length;
|
|
659
|
+
return ret;
|
|
660
|
+
},
|
|
661
|
+
__wbg_log_6b5ca2e6124b2808: function(arg0) {
|
|
662
|
+
console.log(getObject(arg0));
|
|
663
|
+
},
|
|
664
|
+
__wbg_new_361308b2356cecd0: function() {
|
|
665
|
+
const ret = new Object();
|
|
666
|
+
return addHeapObject(ret);
|
|
667
|
+
},
|
|
668
|
+
__wbg_new_3eb36ae241fe6f44: function() {
|
|
669
|
+
const ret = new Array();
|
|
670
|
+
return addHeapObject(ret);
|
|
671
|
+
},
|
|
672
|
+
__wbg_new_8a6f238a6ece86ea: function() {
|
|
673
|
+
const ret = new Error();
|
|
674
|
+
return addHeapObject(ret);
|
|
675
|
+
},
|
|
676
|
+
__wbg_new_b5d9e2fb389fef91: function(arg0, arg1) {
|
|
677
|
+
try {
|
|
678
|
+
var state0 = {a: arg0, b: arg1};
|
|
679
|
+
var cb0 = (arg0, arg1) => {
|
|
680
|
+
const a = state0.a;
|
|
681
|
+
state0.a = 0;
|
|
682
|
+
try {
|
|
683
|
+
return __wasm_bindgen_func_elem_443(a, state0.b, arg0, arg1);
|
|
684
|
+
} finally {
|
|
685
|
+
state0.a = a;
|
|
686
|
+
}
|
|
687
|
+
};
|
|
688
|
+
const ret = new Promise(cb0);
|
|
689
|
+
return addHeapObject(ret);
|
|
690
|
+
} finally {
|
|
691
|
+
state0.a = state0.b = 0;
|
|
692
|
+
}
|
|
693
|
+
},
|
|
694
|
+
__wbg_new_dca287b076112a51: function() {
|
|
695
|
+
const ret = new Map();
|
|
696
|
+
return addHeapObject(ret);
|
|
697
|
+
},
|
|
698
|
+
__wbg_new_dd2b680c8bf6ae29: function(arg0) {
|
|
699
|
+
const ret = new Uint8Array(getObject(arg0));
|
|
700
|
+
return addHeapObject(ret);
|
|
701
|
+
},
|
|
702
|
+
__wbg_new_no_args_1c7c842f08d00ebb: function(arg0, arg1) {
|
|
703
|
+
const ret = new Function(getStringFromWasm0(arg0, arg1));
|
|
704
|
+
return addHeapObject(ret);
|
|
705
|
+
},
|
|
706
|
+
__wbg_next_3482f54c49e8af19: function() { return handleError(function (arg0) {
|
|
707
|
+
const ret = getObject(arg0).next();
|
|
708
|
+
return addHeapObject(ret);
|
|
709
|
+
}, arguments); },
|
|
710
|
+
__wbg_next_418f80d8f5303233: function(arg0) {
|
|
711
|
+
const ret = getObject(arg0).next;
|
|
712
|
+
return addHeapObject(ret);
|
|
713
|
+
},
|
|
714
|
+
__wbg_prototypesetcall_bdcdcc5842e4d77d: function(arg0, arg1, arg2) {
|
|
715
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
|
|
716
|
+
},
|
|
717
|
+
__wbg_queueMicrotask_0aa0a927f78f5d98: function(arg0) {
|
|
718
|
+
const ret = getObject(arg0).queueMicrotask;
|
|
719
|
+
return addHeapObject(ret);
|
|
720
|
+
},
|
|
721
|
+
__wbg_queueMicrotask_5bb536982f78a56f: function(arg0) {
|
|
722
|
+
queueMicrotask(getObject(arg0));
|
|
723
|
+
},
|
|
724
|
+
__wbg_resolve_002c4b7d9d8f6b64: function(arg0) {
|
|
725
|
+
const ret = Promise.resolve(getObject(arg0));
|
|
726
|
+
return addHeapObject(ret);
|
|
727
|
+
},
|
|
728
|
+
__wbg_set_1eb0999cf5d27fc8: function(arg0, arg1, arg2) {
|
|
729
|
+
const ret = getObject(arg0).set(getObject(arg1), getObject(arg2));
|
|
730
|
+
return addHeapObject(ret);
|
|
731
|
+
},
|
|
732
|
+
__wbg_set_3f1d0b984ed272ed: function(arg0, arg1, arg2) {
|
|
733
|
+
getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
|
|
734
|
+
},
|
|
735
|
+
__wbg_set_f43e577aea94465b: function(arg0, arg1, arg2) {
|
|
736
|
+
getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
|
|
737
|
+
},
|
|
738
|
+
__wbg_stack_0ed75d68575b0f3c: function(arg0, arg1) {
|
|
739
|
+
const ret = getObject(arg1).stack;
|
|
740
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
741
|
+
const len1 = WASM_VECTOR_LEN;
|
|
742
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
743
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
744
|
+
},
|
|
745
|
+
__wbg_static_accessor_GLOBAL_12837167ad935116: function() {
|
|
746
|
+
const ret = typeof global === 'undefined' ? null : global;
|
|
747
|
+
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
|
748
|
+
},
|
|
749
|
+
__wbg_static_accessor_GLOBAL_THIS_e628e89ab3b1c95f: function() {
|
|
750
|
+
const ret = typeof globalThis === 'undefined' ? null : globalThis;
|
|
751
|
+
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
|
752
|
+
},
|
|
753
|
+
__wbg_static_accessor_SELF_a621d3dfbb60d0ce: function() {
|
|
754
|
+
const ret = typeof self === 'undefined' ? null : self;
|
|
755
|
+
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
|
756
|
+
},
|
|
757
|
+
__wbg_static_accessor_WINDOW_f8727f0cf888e0bd: function() {
|
|
758
|
+
const ret = typeof window === 'undefined' ? null : window;
|
|
759
|
+
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
|
760
|
+
},
|
|
761
|
+
__wbg_then_0d9fe2c7b1857d32: function(arg0, arg1, arg2) {
|
|
762
|
+
const ret = getObject(arg0).then(getObject(arg1), getObject(arg2));
|
|
763
|
+
return addHeapObject(ret);
|
|
764
|
+
},
|
|
765
|
+
__wbg_then_b9e7b3b5f1a9e1b5: function(arg0, arg1) {
|
|
766
|
+
const ret = getObject(arg0).then(getObject(arg1));
|
|
767
|
+
return addHeapObject(ret);
|
|
768
|
+
},
|
|
769
|
+
__wbg_value_0546255b415e96c1: function(arg0) {
|
|
770
|
+
const ret = getObject(arg0).value;
|
|
771
|
+
return addHeapObject(ret);
|
|
772
|
+
},
|
|
773
|
+
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
774
|
+
// Cast intrinsic for `Closure(Closure { dtor_idx: 51, function: Function { arguments: [Externref], shim_idx: 52, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
775
|
+
const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_363, __wasm_bindgen_func_elem_364);
|
|
776
|
+
return addHeapObject(ret);
|
|
777
|
+
},
|
|
778
|
+
__wbindgen_cast_0000000000000002: function(arg0) {
|
|
779
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
780
|
+
const ret = arg0;
|
|
781
|
+
return addHeapObject(ret);
|
|
782
|
+
},
|
|
783
|
+
__wbindgen_cast_0000000000000003: function(arg0) {
|
|
784
|
+
// Cast intrinsic for `I64 -> Externref`.
|
|
785
|
+
const ret = arg0;
|
|
786
|
+
return addHeapObject(ret);
|
|
787
|
+
},
|
|
788
|
+
__wbindgen_cast_0000000000000004: function(arg0, arg1) {
|
|
789
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
790
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
791
|
+
return addHeapObject(ret);
|
|
792
|
+
},
|
|
793
|
+
__wbindgen_cast_0000000000000005: function(arg0) {
|
|
794
|
+
// Cast intrinsic for `U64 -> Externref`.
|
|
795
|
+
const ret = BigInt.asUintN(64, arg0);
|
|
796
|
+
return addHeapObject(ret);
|
|
797
|
+
},
|
|
798
|
+
__wbindgen_object_clone_ref: function(arg0) {
|
|
799
|
+
const ret = getObject(arg0);
|
|
800
|
+
return addHeapObject(ret);
|
|
801
|
+
},
|
|
802
|
+
__wbindgen_object_drop_ref: function(arg0) {
|
|
803
|
+
takeObject(arg0);
|
|
804
|
+
},
|
|
805
|
+
};
|
|
806
|
+
return {
|
|
807
|
+
__proto__: null,
|
|
808
|
+
"./postgrest_parser_bg.js": import0,
|
|
809
|
+
};
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
function __wasm_bindgen_func_elem_364(arg0, arg1, arg2) {
|
|
813
|
+
wasm.__wasm_bindgen_func_elem_364(arg0, arg1, addHeapObject(arg2));
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
function __wasm_bindgen_func_elem_443(arg0, arg1, arg2, arg3) {
|
|
817
|
+
wasm.__wasm_bindgen_func_elem_443(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
const WasmQueryResultFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
821
|
+
? { register: () => {}, unregister: () => {} }
|
|
822
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmqueryresult_free(ptr >>> 0, 1));
|
|
823
|
+
|
|
824
|
+
function addHeapObject(obj) {
|
|
825
|
+
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
826
|
+
const idx = heap_next;
|
|
827
|
+
heap_next = heap[idx];
|
|
828
|
+
|
|
829
|
+
heap[idx] = obj;
|
|
830
|
+
return idx;
|
|
831
|
+
}
|
|
832
|
+
|
|
833
|
+
const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined')
|
|
834
|
+
? { register: () => {}, unregister: () => {} }
|
|
835
|
+
: new FinalizationRegistry(state => state.dtor(state.a, state.b));
|
|
836
|
+
|
|
837
|
+
function debugString(val) {
|
|
838
|
+
// primitive types
|
|
839
|
+
const type = typeof val;
|
|
840
|
+
if (type == 'number' || type == 'boolean' || val == null) {
|
|
841
|
+
return `${val}`;
|
|
842
|
+
}
|
|
843
|
+
if (type == 'string') {
|
|
844
|
+
return `"${val}"`;
|
|
845
|
+
}
|
|
846
|
+
if (type == 'symbol') {
|
|
847
|
+
const description = val.description;
|
|
848
|
+
if (description == null) {
|
|
849
|
+
return 'Symbol';
|
|
850
|
+
} else {
|
|
851
|
+
return `Symbol(${description})`;
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
if (type == 'function') {
|
|
855
|
+
const name = val.name;
|
|
856
|
+
if (typeof name == 'string' && name.length > 0) {
|
|
857
|
+
return `Function(${name})`;
|
|
858
|
+
} else {
|
|
859
|
+
return 'Function';
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
// objects
|
|
863
|
+
if (Array.isArray(val)) {
|
|
864
|
+
const length = val.length;
|
|
865
|
+
let debug = '[';
|
|
866
|
+
if (length > 0) {
|
|
867
|
+
debug += debugString(val[0]);
|
|
868
|
+
}
|
|
869
|
+
for(let i = 1; i < length; i++) {
|
|
870
|
+
debug += ', ' + debugString(val[i]);
|
|
871
|
+
}
|
|
872
|
+
debug += ']';
|
|
873
|
+
return debug;
|
|
874
|
+
}
|
|
875
|
+
// Test for built-in
|
|
876
|
+
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
|
877
|
+
let className;
|
|
878
|
+
if (builtInMatches && builtInMatches.length > 1) {
|
|
879
|
+
className = builtInMatches[1];
|
|
880
|
+
} else {
|
|
881
|
+
// Failed to match the standard '[object ClassName]'
|
|
882
|
+
return toString.call(val);
|
|
883
|
+
}
|
|
884
|
+
if (className == 'Object') {
|
|
885
|
+
// we're a user defined class or Object
|
|
886
|
+
// JSON.stringify avoids problems with cycles, and is generally much
|
|
887
|
+
// easier than looping through ownProperties of `val`.
|
|
888
|
+
try {
|
|
889
|
+
return 'Object(' + JSON.stringify(val) + ')';
|
|
890
|
+
} catch (_) {
|
|
891
|
+
return 'Object';
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
// errors
|
|
895
|
+
if (val instanceof Error) {
|
|
896
|
+
return `${val.name}: ${val.message}\n${val.stack}`;
|
|
897
|
+
}
|
|
898
|
+
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
899
|
+
return className;
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
function dropObject(idx) {
|
|
903
|
+
if (idx < 132) return;
|
|
904
|
+
heap[idx] = heap_next;
|
|
905
|
+
heap_next = idx;
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
909
|
+
ptr = ptr >>> 0;
|
|
910
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
let cachedDataViewMemory0 = null;
|
|
914
|
+
function getDataViewMemory0() {
|
|
915
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
916
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
917
|
+
}
|
|
918
|
+
return cachedDataViewMemory0;
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
function getStringFromWasm0(ptr, len) {
|
|
922
|
+
ptr = ptr >>> 0;
|
|
923
|
+
return decodeText(ptr, len);
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
let cachedUint8ArrayMemory0 = null;
|
|
927
|
+
function getUint8ArrayMemory0() {
|
|
928
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
929
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
930
|
+
}
|
|
931
|
+
return cachedUint8ArrayMemory0;
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
function getObject(idx) { return heap[idx]; }
|
|
935
|
+
|
|
936
|
+
function handleError(f, args) {
|
|
937
|
+
try {
|
|
938
|
+
return f.apply(this, args);
|
|
939
|
+
} catch (e) {
|
|
940
|
+
wasm.__wbindgen_export3(addHeapObject(e));
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
let heap = new Array(128).fill(undefined);
|
|
945
|
+
heap.push(undefined, null, true, false);
|
|
946
|
+
|
|
947
|
+
let heap_next = heap.length;
|
|
948
|
+
|
|
949
|
+
function isLikeNone(x) {
|
|
950
|
+
return x === undefined || x === null;
|
|
951
|
+
}
|
|
952
|
+
|
|
953
|
+
function makeMutClosure(arg0, arg1, dtor, f) {
|
|
954
|
+
const state = { a: arg0, b: arg1, cnt: 1, dtor };
|
|
955
|
+
const real = (...args) => {
|
|
956
|
+
|
|
957
|
+
// First up with a closure we increment the internal reference
|
|
958
|
+
// count. This ensures that the Rust closure environment won't
|
|
959
|
+
// be deallocated while we're invoking it.
|
|
960
|
+
state.cnt++;
|
|
961
|
+
const a = state.a;
|
|
962
|
+
state.a = 0;
|
|
963
|
+
try {
|
|
964
|
+
return f(a, state.b, ...args);
|
|
965
|
+
} finally {
|
|
966
|
+
state.a = a;
|
|
967
|
+
real._wbg_cb_unref();
|
|
968
|
+
}
|
|
969
|
+
};
|
|
970
|
+
real._wbg_cb_unref = () => {
|
|
971
|
+
if (--state.cnt === 0) {
|
|
972
|
+
state.dtor(state.a, state.b);
|
|
973
|
+
state.a = 0;
|
|
974
|
+
CLOSURE_DTORS.unregister(state);
|
|
975
|
+
}
|
|
976
|
+
};
|
|
977
|
+
CLOSURE_DTORS.register(real, state, state);
|
|
978
|
+
return real;
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
982
|
+
if (realloc === undefined) {
|
|
983
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
984
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
985
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
986
|
+
WASM_VECTOR_LEN = buf.length;
|
|
987
|
+
return ptr;
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
let len = arg.length;
|
|
991
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
992
|
+
|
|
993
|
+
const mem = getUint8ArrayMemory0();
|
|
994
|
+
|
|
995
|
+
let offset = 0;
|
|
996
|
+
|
|
997
|
+
for (; offset < len; offset++) {
|
|
998
|
+
const code = arg.charCodeAt(offset);
|
|
999
|
+
if (code > 0x7F) break;
|
|
1000
|
+
mem[ptr + offset] = code;
|
|
1001
|
+
}
|
|
1002
|
+
if (offset !== len) {
|
|
1003
|
+
if (offset !== 0) {
|
|
1004
|
+
arg = arg.slice(offset);
|
|
1005
|
+
}
|
|
1006
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
1007
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
1008
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
1009
|
+
|
|
1010
|
+
offset += ret.written;
|
|
1011
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1014
|
+
WASM_VECTOR_LEN = offset;
|
|
1015
|
+
return ptr;
|
|
1016
|
+
}
|
|
1017
|
+
|
|
1018
|
+
function takeObject(idx) {
|
|
1019
|
+
const ret = getObject(idx);
|
|
1020
|
+
dropObject(idx);
|
|
1021
|
+
return ret;
|
|
1022
|
+
}
|
|
1023
|
+
|
|
1024
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
1025
|
+
cachedTextDecoder.decode();
|
|
1026
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
1027
|
+
let numBytesDecoded = 0;
|
|
1028
|
+
function decodeText(ptr, len) {
|
|
1029
|
+
numBytesDecoded += len;
|
|
1030
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
1031
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
1032
|
+
cachedTextDecoder.decode();
|
|
1033
|
+
numBytesDecoded = len;
|
|
1034
|
+
}
|
|
1035
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
1036
|
+
}
|
|
1037
|
+
|
|
1038
|
+
const cachedTextEncoder = new TextEncoder();
|
|
1039
|
+
|
|
1040
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
1041
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
1042
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
1043
|
+
view.set(buf);
|
|
1044
|
+
return {
|
|
1045
|
+
read: arg.length,
|
|
1046
|
+
written: buf.length
|
|
1047
|
+
};
|
|
1048
|
+
};
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
let WASM_VECTOR_LEN = 0;
|
|
1052
|
+
|
|
1053
|
+
let wasmModule, wasm;
|
|
1054
|
+
function __wbg_finalize_init(instance, module) {
|
|
1055
|
+
wasm = instance.exports;
|
|
1056
|
+
wasmModule = module;
|
|
1057
|
+
cachedDataViewMemory0 = null;
|
|
1058
|
+
cachedUint8ArrayMemory0 = null;
|
|
1059
|
+
wasm.__wbindgen_start();
|
|
1060
|
+
return wasm;
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1063
|
+
async function __wbg_load(module, imports) {
|
|
1064
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
1065
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
1066
|
+
try {
|
|
1067
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
1068
|
+
} catch (e) {
|
|
1069
|
+
const validResponse = module.ok && expectedResponseType(module.type);
|
|
1070
|
+
|
|
1071
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
1072
|
+
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
1073
|
+
|
|
1074
|
+
} else { throw e; }
|
|
1075
|
+
}
|
|
1076
|
+
}
|
|
1077
|
+
|
|
1078
|
+
const bytes = await module.arrayBuffer();
|
|
1079
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
1080
|
+
} else {
|
|
1081
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
1082
|
+
|
|
1083
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
1084
|
+
return { instance, module };
|
|
1085
|
+
} else {
|
|
1086
|
+
return instance;
|
|
1087
|
+
}
|
|
1088
|
+
}
|
|
1089
|
+
|
|
1090
|
+
function expectedResponseType(type) {
|
|
1091
|
+
switch (type) {
|
|
1092
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
1093
|
+
}
|
|
1094
|
+
return false;
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
|
|
1098
|
+
function initSync(module) {
|
|
1099
|
+
if (wasm !== undefined) return wasm;
|
|
1100
|
+
|
|
1101
|
+
|
|
1102
|
+
if (module !== undefined) {
|
|
1103
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
1104
|
+
({module} = module)
|
|
1105
|
+
} else {
|
|
1106
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
1107
|
+
}
|
|
1108
|
+
}
|
|
1109
|
+
|
|
1110
|
+
const imports = __wbg_get_imports();
|
|
1111
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
1112
|
+
module = new WebAssembly.Module(module);
|
|
1113
|
+
}
|
|
1114
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
1115
|
+
return __wbg_finalize_init(instance, module);
|
|
1116
|
+
}
|
|
1117
|
+
|
|
1118
|
+
async function __wbg_init(module_or_path) {
|
|
1119
|
+
if (wasm !== undefined) return wasm;
|
|
1120
|
+
|
|
1121
|
+
|
|
1122
|
+
if (module_or_path !== undefined) {
|
|
1123
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
1124
|
+
({module_or_path} = module_or_path)
|
|
1125
|
+
} else {
|
|
1126
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
1127
|
+
}
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1130
|
+
if (module_or_path === undefined) {
|
|
1131
|
+
module_or_path = new URL('postgrest_parser_bg.wasm', import.meta.url);
|
|
1132
|
+
}
|
|
1133
|
+
const imports = __wbg_get_imports();
|
|
1134
|
+
|
|
1135
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
1136
|
+
module_or_path = fetch(module_or_path);
|
|
1137
|
+
}
|
|
1138
|
+
|
|
1139
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
1140
|
+
|
|
1141
|
+
return __wbg_finalize_init(instance, module);
|
|
1142
|
+
}
|
|
1143
|
+
|
|
1144
|
+
export { initSync, __wbg_init as default };
|