@query-farm/vgi 0.49.1 → 0.50.0
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 +1 -1
- package/dist/catalog/composite.d.ts +1 -1
- package/dist/catalog/descriptors.d.ts +34 -2
- package/dist/catalog/interface.d.ts +47 -8
- package/dist/catalog/read-only.d.ts +48 -1
- package/dist/client/client.d.ts +13 -7
- package/dist/client-entry.d.ts +1 -1
- package/dist/client-entry.js +40 -16
- package/dist/client-entry.js.map +6 -6
- package/dist/functions/storage.d.ts +7 -0
- package/dist/generated/vgi-client.d.ts +4 -0
- package/dist/generated/vgi-protocol-schemas.d.ts +2 -2
- package/dist/generated/vgi-service.d.ts +7 -26
- package/dist/index.core.d.ts +4 -3
- package/dist/index.js +285 -186
- package/dist/index.js.map +17 -17
- package/dist/protocol/dispatch.d.ts +5 -3
- package/dist/serve-entry.js +63 -61
- package/dist/serve-entry.js.map +10 -10
- package/dist/worker-cf-entry.js +241 -170
- package/dist/worker-cf-entry.js.map +16 -16
- package/dist/write-results.d.ts +8 -1
- package/package.json +1 -1
- package/src/catalog/composite.ts +2 -2
- package/src/catalog/descriptors.ts +35 -2
- package/src/catalog/interface.ts +78 -10
- package/src/catalog/read-only.ts +297 -175
- package/src/client/client.ts +22 -13
- package/src/client-entry.ts +4 -0
- package/src/filter-pushdown/evaluate.ts +30 -14
- package/src/functions/storage.ts +44 -3
- package/src/generated/vgi-client.ts +6 -1
- package/src/generated/vgi-protocol-schemas.ts +8 -12
- package/src/generated/vgi-service.ts +9 -48
- package/src/index.core.ts +4 -3
- package/src/protocol/dispatch.ts +5 -3
- package/src/protocol/handlers/catalog/table.ts +14 -21
- package/src/write-results.ts +8 -3
|
@@ -54,18 +54,20 @@ export interface ProtocolConfig {
|
|
|
54
54
|
export { VGI_PROTOCOL_NAME };
|
|
55
55
|
/**
|
|
56
56
|
* The `vgi.v3` protocol hash `vgi_rpc.Reflection.v1` must report for this
|
|
57
|
-
* worker: the combined reference's
|
|
57
|
+
* worker: the combined reference's 84 methods. Every SDK hosts
|
|
58
58
|
* every `vgi.v3` method with the reference's schemas, so the hash is one value
|
|
59
59
|
* across the ports; a method this SDK does not implement is still registered
|
|
60
60
|
* with the generated UNIMPLEMENTED default (src/generated/vgi-service.ts). The
|
|
61
61
|
* hash covers method names, types and the params/result/header schemas only
|
|
62
62
|
* (WIRE_PROTOCOL.md §14).
|
|
63
63
|
*
|
|
64
|
-
* It changes only with vgi.v3's protocol version (currently 3.
|
|
64
|
+
* It changes only with vgi.v3's protocol version (currently 3.3.0: 3.3 removed
|
|
65
|
+
* catalog_table_scan_function_get and gave catalog_table_create a `created`
|
|
66
|
+
* result). Asserted
|
|
65
67
|
* by src/protocol/__tests__/vgi-v3-hash.test.ts; if that test fails, the
|
|
66
68
|
* surface drifted from the reference -- fix the schemas, do not bump this.
|
|
67
69
|
*/
|
|
68
|
-
export declare const VGI_V3_PROTOCOL_HASH = "
|
|
70
|
+
export declare const VGI_V3_PROTOCOL_HASH = "ad10c6b137db8cd0054c8c3d80b0f50946382d52bbd549beaad209e00c180f08";
|
|
69
71
|
/**
|
|
70
72
|
* This worker's `vgi.v3` implementation: the generated UNIMPLEMENTED default
|
|
71
73
|
* for every method, overridden by the handler groups for what this SDK serves.
|
package/dist/serve-entry.js
CHANGED
|
@@ -322,12 +322,34 @@ class FunctionStorageSqlite {
|
|
|
322
322
|
this.dbPath = dbPath ?? getDefaultDbPath();
|
|
323
323
|
const Db = _loadDatabase();
|
|
324
324
|
this._db = new Db(this.dbPath);
|
|
325
|
-
this._db.exec(
|
|
325
|
+
this._db.exec(`PRAGMA busy_timeout=${BUSY_TIMEOUT_MS}`);
|
|
326
|
+
this._setWal();
|
|
326
327
|
this._db.exec("PRAGMA synchronous=NORMAL");
|
|
327
|
-
this._db.exec("PRAGMA busy_timeout=30000");
|
|
328
328
|
this._db.exec("PRAGMA temp_store=MEMORY");
|
|
329
329
|
this._db.exec("PRAGMA cache_size=-65536");
|
|
330
|
-
this.
|
|
330
|
+
this._db.exec("BEGIN IMMEDIATE");
|
|
331
|
+
try {
|
|
332
|
+
this._ensureTables();
|
|
333
|
+
this._db.exec("COMMIT");
|
|
334
|
+
} catch (e) {
|
|
335
|
+
try {
|
|
336
|
+
this._db.exec("ROLLBACK");
|
|
337
|
+
} catch {}
|
|
338
|
+
throw e;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
_setWal() {
|
|
342
|
+
const deadline = Date.now() + BUSY_TIMEOUT_MS;
|
|
343
|
+
for (let delay = 5;; delay = Math.min(delay * 2, 100)) {
|
|
344
|
+
try {
|
|
345
|
+
this._db.exec("PRAGMA journal_mode=WAL");
|
|
346
|
+
return;
|
|
347
|
+
} catch (e) {
|
|
348
|
+
if (!String(e?.code ?? "").startsWith("SQLITE_BUSY") || Date.now() >= deadline)
|
|
349
|
+
throw e;
|
|
350
|
+
Atomics.wait(_SLEEP_CELL, 0, 0, delay);
|
|
351
|
+
}
|
|
352
|
+
}
|
|
331
353
|
}
|
|
332
354
|
close() {
|
|
333
355
|
this._db.close();
|
|
@@ -512,7 +534,7 @@ function getDefaultStorage() {
|
|
|
512
534
|
function bufferArg(data) {
|
|
513
535
|
return Buffer.from(data.buffer, data.byteOffset, data.byteLength);
|
|
514
536
|
}
|
|
515
|
-
var _BUN_SQLITE_MOD = "bun:sqlite", _NODE_OS_MOD2 = "node:os", _NODE_PATH_MOD2 = "node:path", _NODE_FS_MOD2 = "node:fs", _Database = null, UnknownInvocationError, FrameworkNS, NS_WORKER2, _resolved = null, storage;
|
|
537
|
+
var _BUN_SQLITE_MOD = "bun:sqlite", _NODE_OS_MOD2 = "node:os", _NODE_PATH_MOD2 = "node:path", _NODE_FS_MOD2 = "node:fs", _Database = null, UnknownInvocationError, FrameworkNS, NS_WORKER2, BUSY_TIMEOUT_MS = 30000, _SLEEP_CELL, _resolved = null, storage;
|
|
516
538
|
var init_storage = __esm(() => {
|
|
517
539
|
UnknownInvocationError = class UnknownInvocationError extends Error {
|
|
518
540
|
constructor(message) {
|
|
@@ -531,6 +553,7 @@ var init_storage = __esm(() => {
|
|
|
531
553
|
STREAMING_FINALIZE: textBytes("_vgi/streaming_finalize")
|
|
532
554
|
};
|
|
533
555
|
NS_WORKER2 = new TextEncoder().encode("worker");
|
|
556
|
+
_SLEEP_CELL = new Int32Array(new SharedArrayBuffer(4));
|
|
534
557
|
storage = new Proxy({}, {
|
|
535
558
|
get(_t, prop, _r) {
|
|
536
559
|
const inst = getDefaultStorage();
|
|
@@ -2717,16 +2740,18 @@ class WkbBoundsReader {
|
|
|
2717
2740
|
this.offset += 8;
|
|
2718
2741
|
return value;
|
|
2719
2742
|
}
|
|
2720
|
-
point(littleEndian, dimensions) {
|
|
2743
|
+
point(littleEndian, dimensions, isPointGeometry = false) {
|
|
2721
2744
|
const x = this.float64(littleEndian);
|
|
2722
2745
|
const y = this.float64(littleEndian);
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2746
|
+
let allNaN = Number.isNaN(x) && Number.isNaN(y);
|
|
2747
|
+
for (let dimension = 2;dimension < dimensions; dimension++) {
|
|
2748
|
+
allNaN = Number.isNaN(this.float64(littleEndian)) && allNaN;
|
|
2749
|
+
}
|
|
2750
|
+
if (isPointGeometry && allNaN)
|
|
2726
2751
|
return null;
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
return { minX
|
|
2752
|
+
const [minX, maxX] = Number.isNaN(x) ? [-Infinity, Infinity] : [x, x];
|
|
2753
|
+
const [minY, maxY] = Number.isNaN(y) ? [-Infinity, Infinity] : [y, y];
|
|
2754
|
+
return { minX, minY, maxX, maxY };
|
|
2730
2755
|
}
|
|
2731
2756
|
count(littleEndian) {
|
|
2732
2757
|
const count = this.uint32(littleEndian);
|
|
@@ -2778,7 +2803,7 @@ class WkbBoundsReader {
|
|
|
2778
2803
|
if (hasSrid)
|
|
2779
2804
|
this.uint32(littleEndian);
|
|
2780
2805
|
if (type === 1)
|
|
2781
|
-
return this.point(littleEndian, dimensions);
|
|
2806
|
+
return this.point(littleEndian, dimensions, true);
|
|
2782
2807
|
if (type === 2)
|
|
2783
2808
|
return this.points(littleEndian, dimensions);
|
|
2784
2809
|
if (type === 3) {
|
|
@@ -2993,14 +3018,16 @@ class PushdownFilters {
|
|
|
2993
3018
|
for (const predicate of this.predicates) {
|
|
2994
3019
|
if (predicate.expression.node === "runtime_filter" && !predicate.expression.supported)
|
|
2995
3020
|
continue;
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3021
|
+
const advisory = predicate.mode === "advisory";
|
|
3022
|
+
const values = Array.from({ length: batch.numRows }, (_, row) => {
|
|
3023
|
+
try {
|
|
3024
|
+
return evaluateExpression(predicate.expression, batch, row, this.evaluationContext);
|
|
3025
|
+
} catch (error) {
|
|
3026
|
+
if (advisory)
|
|
3027
|
+
return true;
|
|
3028
|
+
throw error;
|
|
3029
|
+
}
|
|
3030
|
+
});
|
|
3004
3031
|
for (let row = 0;row < batch.numRows; row++)
|
|
3005
3032
|
mask[row] &= values[row] === true ? 1 : 0;
|
|
3006
3033
|
}
|
|
@@ -4723,7 +4750,7 @@ import {
|
|
|
4723
4750
|
Protocol
|
|
4724
4751
|
} from "@query-farm/vgi-rpc";
|
|
4725
4752
|
var VGI_PROTOCOL_NAME = "vgi.v3";
|
|
4726
|
-
var VGI_PROTOCOL_VERSION = "3.
|
|
4753
|
+
var VGI_PROTOCOL_VERSION = "3.3.0";
|
|
4727
4754
|
function exchangeStream(callbacks) {
|
|
4728
4755
|
return { kind: "exchange", ...callbacks };
|
|
4729
4756
|
}
|
|
@@ -5457,7 +5484,9 @@ var VGI_V3_METHODS = [
|
|
|
5457
5484
|
params: schema2([
|
|
5458
5485
|
field2("request", binary2(), false)
|
|
5459
5486
|
]),
|
|
5460
|
-
result: schema2([
|
|
5487
|
+
result: schema2([
|
|
5488
|
+
field2("result", binary2(), false)
|
|
5489
|
+
]),
|
|
5461
5490
|
doc: "Create a new table."
|
|
5462
5491
|
},
|
|
5463
5492
|
{
|
|
@@ -5601,23 +5630,6 @@ var VGI_V3_METHODS = [
|
|
|
5601
5630
|
]),
|
|
5602
5631
|
doc: "Get the list of scan branches for a multi-branch table. Returns `ScanBranchesResult` as IPC bytes."
|
|
5603
5632
|
},
|
|
5604
|
-
{
|
|
5605
|
-
name: "catalog_table_scan_function_get",
|
|
5606
|
-
key: "catalogTableScanFunctionGet",
|
|
5607
|
-
type: "unary",
|
|
5608
|
-
params: schema2([
|
|
5609
|
-
field2("attach_opaque_data", binary2(), false),
|
|
5610
|
-
field2("schema_path", list2(field2("item", utf82(), true)), false),
|
|
5611
|
-
field2("name", utf82(), false),
|
|
5612
|
-
field2("at_unit", utf82(), true),
|
|
5613
|
-
field2("at_value", utf82(), true),
|
|
5614
|
-
field2("transaction_opaque_data", binary2(), true)
|
|
5615
|
-
]),
|
|
5616
|
-
result: schema2([
|
|
5617
|
-
field2("result", binary2(), false)
|
|
5618
|
-
]),
|
|
5619
|
-
doc: "Get the scan function for a table. Returns `ScanFunctionResult` as IPC bytes."
|
|
5620
|
-
},
|
|
5621
5633
|
{
|
|
5622
5634
|
name: "catalog_table_update_function_get",
|
|
5623
5635
|
key: "catalogTableUpdateFunctionGet",
|
|
@@ -6080,9 +6092,6 @@ var UNIMPLEMENTED_VGI_SERVICE = Object.freeze({
|
|
|
6080
6092
|
catalogTableScanBranchesGet: async () => {
|
|
6081
6093
|
throw notImplemented("catalog_table_scan_branches_get");
|
|
6082
6094
|
},
|
|
6083
|
-
catalogTableScanFunctionGet: async () => {
|
|
6084
|
-
throw notImplemented("catalog_table_scan_function_get");
|
|
6085
|
-
},
|
|
6086
6095
|
catalogTableUpdateFunctionGet: async () => {
|
|
6087
6096
|
throw notImplemented("catalog_table_update_function_get");
|
|
6088
6097
|
},
|
|
@@ -6196,7 +6205,7 @@ function createVgiProtocol(service) {
|
|
|
6196
6205
|
}
|
|
6197
6206
|
|
|
6198
6207
|
// src/generated/vgi-protocol-schemas.ts
|
|
6199
|
-
var VGI_CATALOG_CONTRACT_HASH = "
|
|
6208
|
+
var VGI_CATALOG_CONTRACT_HASH = "e0965c93219b6ef6574d82c007c600462594a08085db1242b127ed27e193da0f";
|
|
6200
6209
|
var CatalogInfoSchema = schema2([
|
|
6201
6210
|
field2("name", utf82(), false),
|
|
6202
6211
|
field2("implementation_version", utf82(), true),
|
|
@@ -6287,7 +6296,8 @@ var FunctionInfoSchema = schema2([
|
|
|
6287
6296
|
field2("input_from_args", bool2(), false),
|
|
6288
6297
|
field2("input_rows_per_call", int642(), true),
|
|
6289
6298
|
field2("required_settings", list2(field2("item", utf82(), true)), false),
|
|
6290
|
-
field2("required_secrets", list2(field2("item", struct2([field2("secret_type", utf82(), false), field2("scope", utf82(), true), field2("secret_name", utf82(), true)]), true)), false)
|
|
6299
|
+
field2("required_secrets", list2(field2("item", struct2([field2("secret_type", utf82(), false), field2("scope", utf82(), true), field2("secret_name", utf82(), true)]), true)), false),
|
|
6300
|
+
field2("visibility", utf82(), true)
|
|
6291
6301
|
]);
|
|
6292
6302
|
var MacroInfoSchema = schema2([
|
|
6293
6303
|
field2("comment", utf82(), true),
|
|
@@ -7000,6 +7010,9 @@ var CatalogTableConstraintsApplyResultSchema = schema2([
|
|
|
7000
7010
|
field2("definition_revision", binary2(), false),
|
|
7001
7011
|
field2("constraints", list2(field2("item", binary2(), true)), false)
|
|
7002
7012
|
]);
|
|
7013
|
+
var CatalogTableCreateResultSchema = schema2([
|
|
7014
|
+
field2("created", bool2(), false)
|
|
7015
|
+
]);
|
|
7003
7016
|
var CatalogTableGetResultSchema = schema2([
|
|
7004
7017
|
field2("items", list2(field2("item", binary2(), true)), false)
|
|
7005
7018
|
]);
|
|
@@ -7405,14 +7418,6 @@ var CatalogTableScanBranchesGetParamsSchema = schema2([
|
|
|
7405
7418
|
field2("transaction_opaque_data", binary2(), true),
|
|
7406
7419
|
field2("pushdown_filters", binary2(), true)
|
|
7407
7420
|
]);
|
|
7408
|
-
var CatalogTableScanFunctionGetParamsSchema = schema2([
|
|
7409
|
-
field2("attach_opaque_data", binary2(), false),
|
|
7410
|
-
field2("schema_path", list2(field2("item", utf82(), true)), false),
|
|
7411
|
-
field2("name", utf82(), false),
|
|
7412
|
-
field2("at_unit", utf82(), true),
|
|
7413
|
-
field2("at_value", utf82(), true),
|
|
7414
|
-
field2("transaction_opaque_data", binary2(), true)
|
|
7415
|
-
]);
|
|
7416
7421
|
var CatalogTableUpdateFunctionGetParamsSchema = schema2([
|
|
7417
7422
|
field2("attach_opaque_data", binary2(), false),
|
|
7418
7423
|
field2("schema_path", list2(field2("item", utf82(), true)), false),
|
|
@@ -13128,8 +13133,11 @@ function catalogTableHandlers(getCatalog, signingKey, attachSecretKey) {
|
|
|
13128
13133
|
validateColumnMetadataIpc(toUint8Array(params.columns));
|
|
13129
13134
|
validateColumnExpressionsIpc(toUint8Array(params.columns), params.schema_path);
|
|
13130
13135
|
requireCreateColumns(toUint8Array(params.columns), definitions);
|
|
13131
|
-
await cat.tableCreate(attach, params.schema_path, params.name, toUint8Array(params.columns), params.on_conflict, definitions, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
|
|
13132
|
-
|
|
13136
|
+
const created = await cat.tableCreate(attach, params.schema_path, params.name, toUint8Array(params.columns), params.on_conflict, definitions, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
|
|
13137
|
+
if (created != null && typeof created !== "boolean") {
|
|
13138
|
+
throw new TypeError(`tableCreate must return a boolean or nothing, got ${typeof created}`);
|
|
13139
|
+
}
|
|
13140
|
+
return wrapResult({ created: created !== false }, CatalogTableCreateResultSchema);
|
|
13133
13141
|
});
|
|
13134
13142
|
const catalogTableConstraintsApply = catalogHandler(keys, async (params) => {
|
|
13135
13143
|
const attach = toUint8Array(params.attach_opaque_data);
|
|
@@ -13174,11 +13182,6 @@ function catalogTableHandlers(getCatalog, signingKey, attachSecretKey) {
|
|
|
13174
13182
|
const stats = await cat.tableColumnStatisticsGet(toUint8Array(params.attach_opaque_data), params.schema_path, params.name, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
|
|
13175
13183
|
return { result: stats?.bytes ?? null };
|
|
13176
13184
|
});
|
|
13177
|
-
const catalogTableScanFunctionGet = catalogHandler(keys, async (params) => {
|
|
13178
|
-
const cat = getCatalog();
|
|
13179
|
-
const scanResult = await cat.tableScanFunctionGet(toUint8Array(params.attach_opaque_data), params.schema_path, params.name, params.at_unit, params.at_value, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
|
|
13180
|
-
return wrapResult(scanResult, ScanFunctionResultSchema);
|
|
13181
|
-
});
|
|
13182
13185
|
const optionalTx = (params) => params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined;
|
|
13183
13186
|
const catalogTableInsertFunctionGet = catalogHandler(keys, async (params) => {
|
|
13184
13187
|
const result = await getCatalog().tableInsertFunctionGet(toUint8Array(params.attach_opaque_data), params.schema_path, params.name, optionalTx(params), params.writable_branch_function_name ?? null);
|
|
@@ -13279,7 +13282,6 @@ function catalogTableHandlers(getCatalog, signingKey, attachSecretKey) {
|
|
|
13279
13282
|
catalogTableCreate,
|
|
13280
13283
|
catalogTableDrop,
|
|
13281
13284
|
catalogTableColumnStatisticsGet,
|
|
13282
|
-
catalogTableScanFunctionGet,
|
|
13283
13285
|
catalogTableInsertFunctionGet,
|
|
13284
13286
|
catalogTableUpdateFunctionGet,
|
|
13285
13287
|
catalogTableDeleteFunctionGet,
|
|
@@ -13868,4 +13870,4 @@ export {
|
|
|
13868
13870
|
serveVgiWorker
|
|
13869
13871
|
};
|
|
13870
13872
|
|
|
13871
|
-
//# debugId=
|
|
13873
|
+
//# debugId=EB4B71D0E052664C64756E2164756E21
|