@query-farm/vgi 0.49.2 → 0.50.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/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 +265 -170
- package/dist/index.js.map +16 -16
- package/dist/protocol/dispatch.d.ts +5 -3
- package/dist/serve-entry.js +43 -45
- package/dist/serve-entry.js.map +9 -9
- package/dist/worker-cf-entry.js +221 -154
- package/dist/worker-cf-entry.js.map +15 -15
- 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/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();
|
|
@@ -4727,7 +4750,7 @@ import {
|
|
|
4727
4750
|
Protocol
|
|
4728
4751
|
} from "@query-farm/vgi-rpc";
|
|
4729
4752
|
var VGI_PROTOCOL_NAME = "vgi.v3";
|
|
4730
|
-
var VGI_PROTOCOL_VERSION = "3.
|
|
4753
|
+
var VGI_PROTOCOL_VERSION = "3.3.0";
|
|
4731
4754
|
function exchangeStream(callbacks) {
|
|
4732
4755
|
return { kind: "exchange", ...callbacks };
|
|
4733
4756
|
}
|
|
@@ -5461,7 +5484,9 @@ var VGI_V3_METHODS = [
|
|
|
5461
5484
|
params: schema2([
|
|
5462
5485
|
field2("request", binary2(), false)
|
|
5463
5486
|
]),
|
|
5464
|
-
result: schema2([
|
|
5487
|
+
result: schema2([
|
|
5488
|
+
field2("result", binary2(), false)
|
|
5489
|
+
]),
|
|
5465
5490
|
doc: "Create a new table."
|
|
5466
5491
|
},
|
|
5467
5492
|
{
|
|
@@ -5605,23 +5630,6 @@ var VGI_V3_METHODS = [
|
|
|
5605
5630
|
]),
|
|
5606
5631
|
doc: "Get the list of scan branches for a multi-branch table. Returns `ScanBranchesResult` as IPC bytes."
|
|
5607
5632
|
},
|
|
5608
|
-
{
|
|
5609
|
-
name: "catalog_table_scan_function_get",
|
|
5610
|
-
key: "catalogTableScanFunctionGet",
|
|
5611
|
-
type: "unary",
|
|
5612
|
-
params: schema2([
|
|
5613
|
-
field2("attach_opaque_data", binary2(), false),
|
|
5614
|
-
field2("schema_path", list2(field2("item", utf82(), true)), false),
|
|
5615
|
-
field2("name", utf82(), false),
|
|
5616
|
-
field2("at_unit", utf82(), true),
|
|
5617
|
-
field2("at_value", utf82(), true),
|
|
5618
|
-
field2("transaction_opaque_data", binary2(), true)
|
|
5619
|
-
]),
|
|
5620
|
-
result: schema2([
|
|
5621
|
-
field2("result", binary2(), false)
|
|
5622
|
-
]),
|
|
5623
|
-
doc: "Get the scan function for a table. Returns `ScanFunctionResult` as IPC bytes."
|
|
5624
|
-
},
|
|
5625
5633
|
{
|
|
5626
5634
|
name: "catalog_table_update_function_get",
|
|
5627
5635
|
key: "catalogTableUpdateFunctionGet",
|
|
@@ -6084,9 +6092,6 @@ var UNIMPLEMENTED_VGI_SERVICE = Object.freeze({
|
|
|
6084
6092
|
catalogTableScanBranchesGet: async () => {
|
|
6085
6093
|
throw notImplemented("catalog_table_scan_branches_get");
|
|
6086
6094
|
},
|
|
6087
|
-
catalogTableScanFunctionGet: async () => {
|
|
6088
|
-
throw notImplemented("catalog_table_scan_function_get");
|
|
6089
|
-
},
|
|
6090
6095
|
catalogTableUpdateFunctionGet: async () => {
|
|
6091
6096
|
throw notImplemented("catalog_table_update_function_get");
|
|
6092
6097
|
},
|
|
@@ -6200,7 +6205,7 @@ function createVgiProtocol(service) {
|
|
|
6200
6205
|
}
|
|
6201
6206
|
|
|
6202
6207
|
// src/generated/vgi-protocol-schemas.ts
|
|
6203
|
-
var VGI_CATALOG_CONTRACT_HASH = "
|
|
6208
|
+
var VGI_CATALOG_CONTRACT_HASH = "e0965c93219b6ef6574d82c007c600462594a08085db1242b127ed27e193da0f";
|
|
6204
6209
|
var CatalogInfoSchema = schema2([
|
|
6205
6210
|
field2("name", utf82(), false),
|
|
6206
6211
|
field2("implementation_version", utf82(), true),
|
|
@@ -6291,7 +6296,8 @@ var FunctionInfoSchema = schema2([
|
|
|
6291
6296
|
field2("input_from_args", bool2(), false),
|
|
6292
6297
|
field2("input_rows_per_call", int642(), true),
|
|
6293
6298
|
field2("required_settings", list2(field2("item", utf82(), true)), false),
|
|
6294
|
-
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)
|
|
6295
6301
|
]);
|
|
6296
6302
|
var MacroInfoSchema = schema2([
|
|
6297
6303
|
field2("comment", utf82(), true),
|
|
@@ -7004,6 +7010,9 @@ var CatalogTableConstraintsApplyResultSchema = schema2([
|
|
|
7004
7010
|
field2("definition_revision", binary2(), false),
|
|
7005
7011
|
field2("constraints", list2(field2("item", binary2(), true)), false)
|
|
7006
7012
|
]);
|
|
7013
|
+
var CatalogTableCreateResultSchema = schema2([
|
|
7014
|
+
field2("created", bool2(), false)
|
|
7015
|
+
]);
|
|
7007
7016
|
var CatalogTableGetResultSchema = schema2([
|
|
7008
7017
|
field2("items", list2(field2("item", binary2(), true)), false)
|
|
7009
7018
|
]);
|
|
@@ -7409,14 +7418,6 @@ var CatalogTableScanBranchesGetParamsSchema = schema2([
|
|
|
7409
7418
|
field2("transaction_opaque_data", binary2(), true),
|
|
7410
7419
|
field2("pushdown_filters", binary2(), true)
|
|
7411
7420
|
]);
|
|
7412
|
-
var CatalogTableScanFunctionGetParamsSchema = schema2([
|
|
7413
|
-
field2("attach_opaque_data", binary2(), false),
|
|
7414
|
-
field2("schema_path", list2(field2("item", utf82(), true)), false),
|
|
7415
|
-
field2("name", utf82(), false),
|
|
7416
|
-
field2("at_unit", utf82(), true),
|
|
7417
|
-
field2("at_value", utf82(), true),
|
|
7418
|
-
field2("transaction_opaque_data", binary2(), true)
|
|
7419
|
-
]);
|
|
7420
7421
|
var CatalogTableUpdateFunctionGetParamsSchema = schema2([
|
|
7421
7422
|
field2("attach_opaque_data", binary2(), false),
|
|
7422
7423
|
field2("schema_path", list2(field2("item", utf82(), true)), false),
|
|
@@ -13132,8 +13133,11 @@ function catalogTableHandlers(getCatalog, signingKey, attachSecretKey) {
|
|
|
13132
13133
|
validateColumnMetadataIpc(toUint8Array(params.columns));
|
|
13133
13134
|
validateColumnExpressionsIpc(toUint8Array(params.columns), params.schema_path);
|
|
13134
13135
|
requireCreateColumns(toUint8Array(params.columns), definitions);
|
|
13135
|
-
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);
|
|
13136
|
-
|
|
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);
|
|
13137
13141
|
});
|
|
13138
13142
|
const catalogTableConstraintsApply = catalogHandler(keys, async (params) => {
|
|
13139
13143
|
const attach = toUint8Array(params.attach_opaque_data);
|
|
@@ -13178,11 +13182,6 @@ function catalogTableHandlers(getCatalog, signingKey, attachSecretKey) {
|
|
|
13178
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);
|
|
13179
13183
|
return { result: stats?.bytes ?? null };
|
|
13180
13184
|
});
|
|
13181
|
-
const catalogTableScanFunctionGet = catalogHandler(keys, async (params) => {
|
|
13182
|
-
const cat = getCatalog();
|
|
13183
|
-
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);
|
|
13184
|
-
return wrapResult(scanResult, ScanFunctionResultSchema);
|
|
13185
|
-
});
|
|
13186
13185
|
const optionalTx = (params) => params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined;
|
|
13187
13186
|
const catalogTableInsertFunctionGet = catalogHandler(keys, async (params) => {
|
|
13188
13187
|
const result = await getCatalog().tableInsertFunctionGet(toUint8Array(params.attach_opaque_data), params.schema_path, params.name, optionalTx(params), params.writable_branch_function_name ?? null);
|
|
@@ -13283,7 +13282,6 @@ function catalogTableHandlers(getCatalog, signingKey, attachSecretKey) {
|
|
|
13283
13282
|
catalogTableCreate,
|
|
13284
13283
|
catalogTableDrop,
|
|
13285
13284
|
catalogTableColumnStatisticsGet,
|
|
13286
|
-
catalogTableScanFunctionGet,
|
|
13287
13285
|
catalogTableInsertFunctionGet,
|
|
13288
13286
|
catalogTableUpdateFunctionGet,
|
|
13289
13287
|
catalogTableDeleteFunctionGet,
|
|
@@ -13872,4 +13870,4 @@ export {
|
|
|
13872
13870
|
serveVgiWorker
|
|
13873
13871
|
};
|
|
13874
13872
|
|
|
13875
|
-
//# debugId=
|
|
13873
|
+
//# debugId=EB4B71D0E052664C64756E2164756E21
|