@query-farm/vgi 0.48.3 → 0.48.4
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/dist/catalog/descriptors.d.ts +30 -0
- package/dist/catalog/interface.d.ts +28 -0
- package/dist/catalog/read-only.d.ts +16 -2
- package/dist/client-entry.js.map +2 -2
- package/dist/index.core.d.ts +2 -0
- package/dist/index.js +230 -34
- package/dist/index.js.map +12 -11
- package/dist/protocol/handlers/catalog/shared.d.ts +8 -0
- package/dist/serve-entry.js +43 -9
- package/dist/serve-entry.js.map +6 -6
- package/dist/worker-cf-entry.js +136 -19
- package/dist/worker-cf-entry.js.map +11 -10
- package/dist/write-results.d.ts +57 -0
- package/package.json +1 -1
- package/src/catalog/descriptors.ts +30 -0
- package/src/catalog/interface.ts +51 -0
- package/src/catalog/read-only.ts +123 -18
- package/src/index.core.ts +23 -0
- package/src/protocol/handlers/catalog/shared.ts +17 -0
- package/src/protocol/handlers/catalog/table.ts +37 -0
- package/src/protocol/handlers/function.ts +42 -14
- package/src/write-results.ts +174 -0
package/dist/index.core.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export { CACHE_ETAG_KEY, CACHE_EXPIRES_KEY, CACHE_IF_MODIFIED_SINCE_KEY, CACHE_IF_NONE_MATCH_KEY, CACHE_LAST_MODIFIED_KEY, CACHE_NO_STORE_KEY, CACHE_NOT_MODIFIED_KEY, CACHE_PARTITION_SCOPE_KEY, CACHE_PER_VALUE_KEY, CACHE_REVALIDATABLE_KEY, CACHE_SCOPE_CATALOG, CACHE_SCOPE_KEY, CACHE_SCOPE_TRANSACTION, CACHE_STALE_IF_ERROR_KEY, CACHE_STALE_WHILE_REVALIDATE_KEY, CACHE_TTL_KEY, type CacheControl, cacheControlMetadata, type CacheScope, } from "./cache-control.js";
|
|
2
|
+
export { type WriteOperation, type WriteResultMode, type WriteOptions, WRITE_OPERATIONS, WRITE_RESULT_MODES, ROW_ID_METADATA_KEY, rowIdField, userColumns, validateWriteResultModes, supportsWriteResultMode, coerceWriteResultMode, writeResultSchema, writeCountBatch, writeRowsBatch, writeChangesBatch, writeResultBatch, writeOptions, } from "./write-results.js";
|
|
3
|
+
export type { ScanFunctionResultRecord } from "./catalog/interface.js";
|
|
2
4
|
export { defineScalarFunction, type ScalarFunctionConfig, type ScalarBindParameters, type ScalarComputeInfo, type ScalarParameterDef } from "./functions/scalar.js";
|
|
3
5
|
export { defineTableFunction, type TableFunctionConfig, type TableBindParams, type TableProcessParams } from "./functions/table.js";
|
|
4
6
|
export { defineAggregate, GROUP_COLUMN_NAME, type AggregateFunctionConfig, type AggregateBindParams, type AggregateUpdateParams, type AggregateFinalizeParams, } from "./functions/aggregate.js";
|
package/dist/index.js
CHANGED
|
@@ -2607,6 +2607,103 @@ function cacheControlMetadata(cc, extra) {
|
|
|
2607
2607
|
md.set(CACHE_PER_VALUE_KEY, "1");
|
|
2608
2608
|
return md;
|
|
2609
2609
|
}
|
|
2610
|
+
// src/write-results.ts
|
|
2611
|
+
init_arrow();
|
|
2612
|
+
|
|
2613
|
+
// src/util/bytes.ts
|
|
2614
|
+
function toUint8Array(val) {
|
|
2615
|
+
if (val instanceof Uint8Array)
|
|
2616
|
+
return val;
|
|
2617
|
+
if (val instanceof ArrayBuffer)
|
|
2618
|
+
return new Uint8Array(val);
|
|
2619
|
+
if (typeof Buffer !== "undefined" && Buffer.isBuffer(val))
|
|
2620
|
+
return new Uint8Array(val);
|
|
2621
|
+
if (val && val.buffer instanceof ArrayBuffer) {
|
|
2622
|
+
return new Uint8Array(val.buffer, val.byteOffset, val.byteLength);
|
|
2623
|
+
}
|
|
2624
|
+
return new Uint8Array(0);
|
|
2625
|
+
}
|
|
2626
|
+
|
|
2627
|
+
// src/write-results.ts
|
|
2628
|
+
var WRITE_OPERATIONS = ["insert", "update", "delete"];
|
|
2629
|
+
var WRITE_RESULT_MODES = ["count", "rows", "changes"];
|
|
2630
|
+
var MODE_RANK = { count: 0, rows: 1, changes: 2 };
|
|
2631
|
+
var ROW_ID_METADATA_KEY = "is_row_id";
|
|
2632
|
+
function rowIdField(name = "rowid", type = int642()) {
|
|
2633
|
+
return field2(name, type, false, new Map([[ROW_ID_METADATA_KEY, ""]]));
|
|
2634
|
+
}
|
|
2635
|
+
function validateWriteResultModes(modes) {
|
|
2636
|
+
const out = {};
|
|
2637
|
+
const unknown = Object.keys(modes).filter((op) => !WRITE_OPERATIONS.includes(op)).sort();
|
|
2638
|
+
if (unknown.length)
|
|
2639
|
+
throw new Error(`Unknown write operation(s): ${unknown.join(", ")}`);
|
|
2640
|
+
for (const [operation, mode] of Object.entries(modes)) {
|
|
2641
|
+
if (mode === undefined)
|
|
2642
|
+
continue;
|
|
2643
|
+
if (!(mode in MODE_RANK))
|
|
2644
|
+
throw new Error(`Unknown write result mode '${mode}' for '${operation}'`);
|
|
2645
|
+
out[operation] = mode;
|
|
2646
|
+
}
|
|
2647
|
+
return out;
|
|
2648
|
+
}
|
|
2649
|
+
function supportsWriteResultMode(maximum, requested) {
|
|
2650
|
+
return maximum in MODE_RANK && requested in MODE_RANK && MODE_RANK[maximum] >= MODE_RANK[requested];
|
|
2651
|
+
}
|
|
2652
|
+
function coerceWriteResultMode(value) {
|
|
2653
|
+
if (typeof value !== "string" || !(value in MODE_RANK)) {
|
|
2654
|
+
throw new Error(`Unknown write result mode: ${JSON.stringify(value)}`);
|
|
2655
|
+
}
|
|
2656
|
+
return value;
|
|
2657
|
+
}
|
|
2658
|
+
function userColumns(columns) {
|
|
2659
|
+
return schema2(columns.fields.filter((f) => !f.metadata?.has(ROW_ID_METADATA_KEY)));
|
|
2660
|
+
}
|
|
2661
|
+
function writeResultSchema(mode, tableSchema) {
|
|
2662
|
+
if (mode === "count")
|
|
2663
|
+
return schema2([field2("count", int642(), false)]);
|
|
2664
|
+
if (mode === "rows")
|
|
2665
|
+
return tableSchema;
|
|
2666
|
+
const rowType = struct2(tableSchema.fields);
|
|
2667
|
+
return schema2([field2("old", rowType, true), field2("new", rowType, true)]);
|
|
2668
|
+
}
|
|
2669
|
+
function writeCountBatch(count) {
|
|
2670
|
+
return batchFromColumns({ count: [BigInt(count)] }, writeResultSchema("count", schema2([])));
|
|
2671
|
+
}
|
|
2672
|
+
function writeRowsBatch(tableSchema, rows) {
|
|
2673
|
+
const columns = {};
|
|
2674
|
+
for (const f of tableSchema.fields)
|
|
2675
|
+
columns[f.name] = rows.map((r) => r[f.name] ?? null);
|
|
2676
|
+
return batchFromColumns(columns, tableSchema);
|
|
2677
|
+
}
|
|
2678
|
+
function writeChangesBatch(tableSchema, oldRows, newRows) {
|
|
2679
|
+
if (oldRows.length !== newRows.length)
|
|
2680
|
+
throw new Error("oldRows and newRows must have equal length");
|
|
2681
|
+
const pick = (row) => row == null ? null : Object.fromEntries(tableSchema.fields.map((f) => [f.name, row[f.name] ?? null]));
|
|
2682
|
+
return batchFromColumns({ old: oldRows.map(pick), new: newRows.map(pick) }, writeResultSchema("changes", tableSchema));
|
|
2683
|
+
}
|
|
2684
|
+
function writeResultBatch(mode, tableSchema, oldRows, newRows) {
|
|
2685
|
+
if (mode === "count")
|
|
2686
|
+
return writeCountBatch(newRows.length);
|
|
2687
|
+
if (mode === "changes")
|
|
2688
|
+
return writeChangesBatch(tableSchema, oldRows, newRows);
|
|
2689
|
+
return writeRowsBatch(tableSchema, newRows.map((row, i) => row ?? oldRows[i]));
|
|
2690
|
+
}
|
|
2691
|
+
function writeOptions(bindCall) {
|
|
2692
|
+
const out = { resultMode: "count", onConflict: "throw", onConflictColumns: [] };
|
|
2693
|
+
const raw = bindCall.arguments?.get("write_options", null);
|
|
2694
|
+
if (raw == null)
|
|
2695
|
+
return out;
|
|
2696
|
+
const row = [...iterRows(deserializeBatch(toUint8Array(raw)))][0];
|
|
2697
|
+
if (!row)
|
|
2698
|
+
return out;
|
|
2699
|
+
if (row.result_mode != null)
|
|
2700
|
+
out.resultMode = coerceWriteResultMode(row.result_mode);
|
|
2701
|
+
if (row.on_conflict != null)
|
|
2702
|
+
out.onConflict = String(row.on_conflict);
|
|
2703
|
+
if (row.on_conflict_columns != null)
|
|
2704
|
+
out.onConflictColumns = Array.from(row.on_conflict_columns);
|
|
2705
|
+
return out;
|
|
2706
|
+
}
|
|
2610
2707
|
// src/secrets/requirements.ts
|
|
2611
2708
|
var KNOWN_KEYS = new Set(["secretType", "secret_type", "scope", "secretName", "secret_name"]);
|
|
2612
2709
|
function optionalString(value, what, where) {
|
|
@@ -5329,20 +5426,6 @@ init_storage();
|
|
|
5329
5426
|
init_arrow();
|
|
5330
5427
|
init_registry();
|
|
5331
5428
|
|
|
5332
|
-
// src/util/bytes.ts
|
|
5333
|
-
function toUint8Array(val) {
|
|
5334
|
-
if (val instanceof Uint8Array)
|
|
5335
|
-
return val;
|
|
5336
|
-
if (val instanceof ArrayBuffer)
|
|
5337
|
-
return new Uint8Array(val);
|
|
5338
|
-
if (typeof Buffer !== "undefined" && Buffer.isBuffer(val))
|
|
5339
|
-
return new Uint8Array(val);
|
|
5340
|
-
if (val && val.buffer instanceof ArrayBuffer) {
|
|
5341
|
-
return new Uint8Array(val.buffer, val.byteOffset, val.byteLength);
|
|
5342
|
-
}
|
|
5343
|
-
return new Uint8Array(0);
|
|
5344
|
-
}
|
|
5345
|
-
|
|
5346
5429
|
// src/protocol/carried-init-request.ts
|
|
5347
5430
|
init_arrow();
|
|
5348
5431
|
|
|
@@ -10665,6 +10748,15 @@ class CatalogInterface {
|
|
|
10665
10748
|
tableScanFunctionGet(attachOpaqueData, schemaPath, name, atUnit, atValue, transactionOpaqueData) {
|
|
10666
10749
|
throw new CatalogReadOnlyError("table_scan_function_get");
|
|
10667
10750
|
}
|
|
10751
|
+
tableInsertFunctionGet(attachOpaqueData, schemaPath, name, transactionOpaqueData, writableBranchFunctionName) {
|
|
10752
|
+
throw new CatalogReadOnlyError("table_insert_function_get");
|
|
10753
|
+
}
|
|
10754
|
+
tableUpdateFunctionGet(attachOpaqueData, schemaPath, name, transactionOpaqueData) {
|
|
10755
|
+
throw new CatalogReadOnlyError("table_update_function_get");
|
|
10756
|
+
}
|
|
10757
|
+
tableDeleteFunctionGet(attachOpaqueData, schemaPath, name, transactionOpaqueData) {
|
|
10758
|
+
throw new CatalogReadOnlyError("table_delete_function_get");
|
|
10759
|
+
}
|
|
10668
10760
|
tableScanBranchesGet(attachOpaqueData, schemaPath, name, atUnit, atValue, transactionOpaqueData) {
|
|
10669
10761
|
const legacy = this.tableScanFunctionGet(attachOpaqueData, schemaPath, name, atUnit, atValue, transactionOpaqueData);
|
|
10670
10762
|
return isPromise(legacy) ? legacy.then((r) => singleBranchResult(r)) : singleBranchResult(legacy);
|
|
@@ -11351,6 +11443,9 @@ class ReadOnlyCatalogInterface extends CatalogInterface {
|
|
|
11351
11443
|
this._registry = registry;
|
|
11352
11444
|
if (options.perAttachItemIds)
|
|
11353
11445
|
this.perAttachItemIds = true;
|
|
11446
|
+
for (const sch of descriptor.schemas ?? [])
|
|
11447
|
+
for (const tbl of sch.tables ?? [])
|
|
11448
|
+
validateWritableTable(tbl);
|
|
11354
11449
|
for (const sch of descriptor.schemas ?? []) {
|
|
11355
11450
|
for (const fn of sch.functions ?? [])
|
|
11356
11451
|
registry.registerInSchema(fn, schemaDescriptorPath(sch), descriptor.name);
|
|
@@ -11399,8 +11494,9 @@ class ReadOnlyCatalogInterface extends CatalogInterface {
|
|
|
11399
11494
|
const settings = (this._descriptor.settings ?? []).map((s) => serializeSetting(s));
|
|
11400
11495
|
const secretTypes = (this._descriptor.secretTypes ?? []).map((s) => serializeSecretType(s));
|
|
11401
11496
|
const attachCatalogs = (this._descriptor.attachCatalogs ?? []).map((c) => encodeAttachCatalogInfo(c));
|
|
11402
|
-
const available = this.catalogReadProfiles();
|
|
11403
|
-
const
|
|
11497
|
+
const available = catalogCapabilities({ read: this.catalogReadProfiles(), write: this.catalogWriteProfiles() });
|
|
11498
|
+
const advertised = available.read.length + available.write.length > 0;
|
|
11499
|
+
const selected = selectCatalogCapabilities(available, clientCapabilities);
|
|
11404
11500
|
const hasTimeTravel = this._descriptor.schemas.some((s) => s.tables?.some((t) => t.supportsTimeTravel) ?? false);
|
|
11405
11501
|
return buildCatalogAttachResult({
|
|
11406
11502
|
attach_opaque_data: attachOpaqueData,
|
|
@@ -11421,17 +11517,21 @@ class ReadOnlyCatalogInterface extends CatalogInterface {
|
|
|
11421
11517
|
resolved_data_version: null,
|
|
11422
11518
|
resolved_implementation_version: null,
|
|
11423
11519
|
supports_catalog_contents: this.supportsCatalogContents,
|
|
11424
|
-
catalog_capabilities:
|
|
11425
|
-
selected_capabilities:
|
|
11520
|
+
catalog_capabilities: advertised ? encodeCatalogCapabilities(available) : null,
|
|
11521
|
+
selected_capabilities: advertised ? encodeCatalogCapabilities(selected) : null
|
|
11426
11522
|
});
|
|
11427
11523
|
}
|
|
11428
11524
|
catalogReadProfiles() {
|
|
11429
11525
|
const hasConstraints = this._descriptor.schemas.some((s) => s.tables?.some((t) => (t.constraints?.length ?? 0) > 0) ?? false);
|
|
11430
11526
|
return hasConstraints ? [CONSTRAINT_RECORDS_READ, ROW_SCALAR_EXPRESSION] : [];
|
|
11431
11527
|
}
|
|
11528
|
+
catalogWriteProfiles() {
|
|
11529
|
+
const writableConstrained = this._descriptor.schemas.some((s) => s.tables?.some((t) => (t.constraints?.length ?? 0) > 0 && (t.insertFunction || t.updateFunction || t.deleteFunction)) ?? false);
|
|
11530
|
+
return writableConstrained ? [CONSTRAINT_ENFORCE] : [];
|
|
11531
|
+
}
|
|
11432
11532
|
catalogCapabilities(_attachOpaqueData) {
|
|
11433
|
-
const
|
|
11434
|
-
return read.length
|
|
11533
|
+
const caps = catalogCapabilities({ read: this.catalogReadProfiles(), write: this.catalogWriteProfiles() });
|
|
11534
|
+
return caps.read.length + caps.write.length ? caps : null;
|
|
11435
11535
|
}
|
|
11436
11536
|
detach(attachOpaqueData) {
|
|
11437
11537
|
for (const [name, id] of this._attachments) {
|
|
@@ -11582,12 +11682,12 @@ class ReadOnlyCatalogInterface extends CatalogInterface {
|
|
|
11582
11682
|
columns,
|
|
11583
11683
|
constraints: [...constraints],
|
|
11584
11684
|
definition_revision: t.definitionRevision ?? null,
|
|
11585
|
-
write_result_modes:
|
|
11685
|
+
write_result_modes: writeResultModesFor(t),
|
|
11586
11686
|
supports_column_statistics: t.statistics != null && Object.keys(t.statistics).length > 0,
|
|
11587
11687
|
scan_function: t.function && !t.columns ? inlineScanFunction(t.function, t.arguments, this._schemaForFunction(t.function)) : null,
|
|
11588
|
-
insert_function: null,
|
|
11589
|
-
update_function: null,
|
|
11590
|
-
delete_function: null,
|
|
11688
|
+
insert_function: t.insertFunction ? inlineScanFunction(t.insertFunction, undefined, this._schemaForFunction(t.insertFunction)) : null,
|
|
11689
|
+
update_function: t.updateFunction ? inlineScanFunction(t.updateFunction, undefined, this._schemaForFunction(t.updateFunction)) : null,
|
|
11690
|
+
delete_function: t.deleteFunction ? inlineScanFunction(t.deleteFunction, undefined, this._schemaForFunction(t.deleteFunction)) : null,
|
|
11591
11691
|
cardinality_estimate: t.inlinedCardinality ? Number(t.inlinedCardinality.estimate) : null,
|
|
11592
11692
|
cardinality_max: t.inlinedCardinality ? Number(t.inlinedCardinality.max) : null,
|
|
11593
11693
|
required_filters: requiredFilters
|
|
@@ -11849,6 +11949,32 @@ class ReadOnlyCatalogInterface extends CatalogInterface {
|
|
|
11849
11949
|
}
|
|
11850
11950
|
throw new Error(`Table '${name}' is not function-backed`);
|
|
11851
11951
|
}
|
|
11952
|
+
_writeFunctionGet(schemaPath, name, operation) {
|
|
11953
|
+
const schema = this._descriptor.schemas.find((sch) => schemaPathsEqual(schemaDescriptorPath(sch), schemaPath));
|
|
11954
|
+
const table = schema?.tables?.find((t) => t.name.toLowerCase() === name.toLowerCase());
|
|
11955
|
+
if (!table) {
|
|
11956
|
+
throw new VgiError(`Table '${name}' not found in schema ${schemaPathDisplay(schemaPath)}`, "NOT_FOUND");
|
|
11957
|
+
}
|
|
11958
|
+
const fn = writeFunctionOf(table, operation);
|
|
11959
|
+
if (!fn) {
|
|
11960
|
+
throw new CatalogReadOnlyError(`Table ${schemaPathDisplay(schemaPath)}.${table.name} does not support ${operation.toUpperCase()}`);
|
|
11961
|
+
}
|
|
11962
|
+
return {
|
|
11963
|
+
function_name: fn.meta.name,
|
|
11964
|
+
arguments: serializeArgsBatch(new Arguments, argumentSpecsToSchema(fn.argumentSpecs)),
|
|
11965
|
+
required_extensions: [],
|
|
11966
|
+
schema_path: this._schemaForFunction(fn)
|
|
11967
|
+
};
|
|
11968
|
+
}
|
|
11969
|
+
tableInsertFunctionGet(_attachOpaqueData, schemaPath, name, _transactionOpaqueData, _writableBranchFunctionName) {
|
|
11970
|
+
return this._writeFunctionGet(schemaPath, name, "insert");
|
|
11971
|
+
}
|
|
11972
|
+
tableUpdateFunctionGet(_attachOpaqueData, schemaPath, name, _transactionOpaqueData) {
|
|
11973
|
+
return this._writeFunctionGet(schemaPath, name, "update");
|
|
11974
|
+
}
|
|
11975
|
+
tableDeleteFunctionGet(_attachOpaqueData, schemaPath, name, _transactionOpaqueData) {
|
|
11976
|
+
return this._writeFunctionGet(schemaPath, name, "delete");
|
|
11977
|
+
}
|
|
11852
11978
|
async tableGet(attachOpaqueData, schemaPath, name, atUnit, atValue, transactionOpaqueData) {
|
|
11853
11979
|
validateAtParams(atUnit, atValue);
|
|
11854
11980
|
const schema = this._descriptor.schemas.find((s) => schemaPathsEqual(schemaDescriptorPath(s), schemaPath));
|
|
@@ -12094,6 +12220,28 @@ function sameSpelling(left, right) {
|
|
|
12094
12220
|
const b = normalizeSchemaPath(right);
|
|
12095
12221
|
return a.length === b.length && a.every((part, i) => part === b[i]);
|
|
12096
12222
|
}
|
|
12223
|
+
function writeFunctionOf(table, operation) {
|
|
12224
|
+
return operation === "insert" ? table.insertFunction : operation === "update" ? table.updateFunction : table.deleteFunction;
|
|
12225
|
+
}
|
|
12226
|
+
function validateWritableTable(table) {
|
|
12227
|
+
const modes = validateWriteResultModes(table.writeResultModes ?? {});
|
|
12228
|
+
for (const operation of Object.keys(modes)) {
|
|
12229
|
+
if (!writeFunctionOf(table, operation)) {
|
|
12230
|
+
throw new Error(`Table '${table.name}': writeResultModes declares '${operation}' without a corresponding ${operation}Function`);
|
|
12231
|
+
}
|
|
12232
|
+
}
|
|
12233
|
+
if ((table.updateFunction || table.deleteFunction) && !table.function) {
|
|
12234
|
+
throw new Error(`Table '${table.name}': updateFunction and deleteFunction require a scan function (set 'function') to provide row ids`);
|
|
12235
|
+
}
|
|
12236
|
+
}
|
|
12237
|
+
function writeResultModesFor(table) {
|
|
12238
|
+
const out = {};
|
|
12239
|
+
for (const operation of WRITE_OPERATIONS) {
|
|
12240
|
+
if (writeFunctionOf(table, operation))
|
|
12241
|
+
out[operation] = table.writeResultModes?.[operation] ?? "count";
|
|
12242
|
+
}
|
|
12243
|
+
return out;
|
|
12244
|
+
}
|
|
12097
12245
|
// src/catalog/indexes.ts
|
|
12098
12246
|
var NO_OPTIONS_B64 = "/////zgAAAAQAAAAAAAKABAADgAHAAgACgAAAAAAAAEQAAAAAAAEAAgACAAAAAQACAAAAAQAAAAAAAAAAAAAAP////9QAAAAFAAAAAAAAAAAAAoADgAMAAcACAAKAAAAAAAAAxAAAAAEAAoAGAAMAAgABAAKAAAAFAAAABgAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/////AAAAAA==";
|
|
12099
12247
|
function emptyIndexOptions() {
|
|
@@ -15289,6 +15437,11 @@ async function sealTransaction(plaintext, attachEnvelope, auth, signingKey) {
|
|
|
15289
15437
|
return plaintext;
|
|
15290
15438
|
return sealBytes(plaintext, signingKey, transactionAad(auth, attachEnvelope), TRANSACTION_ENVELOPE_VERSION);
|
|
15291
15439
|
}
|
|
15440
|
+
async function openTransaction(envelope, attachEnvelope, auth, signingKey) {
|
|
15441
|
+
if (!signingKey || envelope.length === 0)
|
|
15442
|
+
return envelope;
|
|
15443
|
+
return openBytes(envelope, signingKey, transactionAad(auth, attachEnvelope), TRANSACTION_ENVELOPE_VERSION, "transaction_opaque_data");
|
|
15444
|
+
}
|
|
15292
15445
|
async function unwrapParamsOpaque(params, ctx, signingKey) {
|
|
15293
15446
|
const auth = ctx?.auth;
|
|
15294
15447
|
let sealedAttach = new Uint8Array(0);
|
|
@@ -15566,7 +15719,12 @@ async function liveSplitAnchor(catalogInterface, bindCall, auth, signingKey) {
|
|
|
15566
15719
|
if (!catalogInterface?.version || bindCall.attach_opaque_data == null)
|
|
15567
15720
|
return;
|
|
15568
15721
|
const raw = toUint8Array(bindCall.attach_opaque_data);
|
|
15569
|
-
|
|
15722
|
+
let txn = bindCall.transaction_opaque_data ? toUint8Array(bindCall.transaction_opaque_data) : undefined;
|
|
15723
|
+
if (txn && txn.length > 0 && signingKey) {
|
|
15724
|
+
try {
|
|
15725
|
+
txn = await openTransaction(txn, raw, auth, signingKey);
|
|
15726
|
+
} catch {}
|
|
15727
|
+
}
|
|
15570
15728
|
const forms = [
|
|
15571
15729
|
async () => raw,
|
|
15572
15730
|
async () => openAttach(raw, auth, signingKey)
|
|
@@ -15604,14 +15762,22 @@ function functionHandlers(config) {
|
|
|
15604
15762
|
return env;
|
|
15605
15763
|
return openAttach(env, ctx?.auth ?? currentRequestAuth(), signingKey);
|
|
15606
15764
|
}
|
|
15765
|
+
async function openOpaque(bindCall, ctx) {
|
|
15766
|
+
const sealedAttach = bindCall.attach_opaque_data != null ? toUint8Array(bindCall.attach_opaque_data) : new Uint8Array(0);
|
|
15767
|
+
if (bindCall.transaction_opaque_data != null) {
|
|
15768
|
+
bindCall.transaction_opaque_data = await openTransaction(toUint8Array(bindCall.transaction_opaque_data), sealedAttach, ctx?.auth ?? currentRequestAuth(), signingKey);
|
|
15769
|
+
}
|
|
15770
|
+
bindCall.attach_opaque_data = await stripAttach(bindCall.attach_opaque_data, ctx);
|
|
15771
|
+
}
|
|
15607
15772
|
async function strippedContext(bindCall, ctx) {
|
|
15608
|
-
|
|
15773
|
+
const copy = { ...bindCall };
|
|
15609
15774
|
try {
|
|
15610
|
-
|
|
15775
|
+
await openOpaque(copy, ctx);
|
|
15611
15776
|
} catch {
|
|
15612
|
-
|
|
15777
|
+
copy.attach_opaque_data = null;
|
|
15778
|
+
copy.transaction_opaque_data = null;
|
|
15613
15779
|
}
|
|
15614
|
-
return overloadContext(
|
|
15780
|
+
return overloadContext(copy, catalogInterface);
|
|
15615
15781
|
}
|
|
15616
15782
|
const emptySchema = schema2([]);
|
|
15617
15783
|
const dummyInputSchema = schema2([
|
|
@@ -15620,7 +15786,7 @@ function functionHandlers(config) {
|
|
|
15620
15786
|
const bind = async (params, ctx) => {
|
|
15621
15787
|
const innerParams = unwrapRequest(params.request);
|
|
15622
15788
|
const request = deserializeBindRequest(innerParams);
|
|
15623
|
-
|
|
15789
|
+
await openOpaque(request, ctx);
|
|
15624
15790
|
const func = registry.get(request.function_name, overloadContext(request, catalogInterface));
|
|
15625
15791
|
const response = await func.bind(request);
|
|
15626
15792
|
validateProjectionOffer(response);
|
|
@@ -15635,7 +15801,7 @@ function functionHandlers(config) {
|
|
|
15635
15801
|
const innerParams = unwrapRequest(params.request);
|
|
15636
15802
|
const request = deserializeInitRequest(innerParams);
|
|
15637
15803
|
const auth = ctx?.auth ?? currentRequestAuth();
|
|
15638
|
-
|
|
15804
|
+
await openOpaque(request.bind_call, ctx);
|
|
15639
15805
|
await resolveSplitPayloads(request, innerParams, {
|
|
15640
15806
|
auth,
|
|
15641
15807
|
signingKey,
|
|
@@ -15680,7 +15846,7 @@ function functionHandlers(config) {
|
|
|
15680
15846
|
} else {
|
|
15681
15847
|
const carried = parseCarriedInitRequest(state.initRequestPacked);
|
|
15682
15848
|
const request = carried.request;
|
|
15683
|
-
|
|
15849
|
+
await openOpaque(request.bind_call, undefined);
|
|
15684
15850
|
await resolveSplitPayloads(request, { bind_call: carried.bindCallIpc }, {
|
|
15685
15851
|
auth: currentRequestAuth(),
|
|
15686
15852
|
signingKey,
|
|
@@ -17539,6 +17705,19 @@ function catalogTableHandlers(getCatalog, signingKey) {
|
|
|
17539
17705
|
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);
|
|
17540
17706
|
return wrapResult(scanResult, ScanFunctionResultSchema);
|
|
17541
17707
|
});
|
|
17708
|
+
const optionalTx = (params) => params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined;
|
|
17709
|
+
const catalogTableInsertFunctionGet = catalogHandler(signingKey, async (params) => {
|
|
17710
|
+
const result = await getCatalog().tableInsertFunctionGet(toUint8Array(params.attach_opaque_data), params.schema_path, params.name, optionalTx(params), params.writable_branch_function_name ?? null);
|
|
17711
|
+
return wrapResult(result, ScanFunctionResultSchema);
|
|
17712
|
+
});
|
|
17713
|
+
const catalogTableUpdateFunctionGet = catalogHandler(signingKey, async (params) => {
|
|
17714
|
+
const result = await getCatalog().tableUpdateFunctionGet(toUint8Array(params.attach_opaque_data), params.schema_path, params.name, optionalTx(params));
|
|
17715
|
+
return wrapResult(result, ScanFunctionResultSchema);
|
|
17716
|
+
});
|
|
17717
|
+
const catalogTableDeleteFunctionGet = catalogHandler(signingKey, async (params) => {
|
|
17718
|
+
const result = await getCatalog().tableDeleteFunctionGet(toUint8Array(params.attach_opaque_data), params.schema_path, params.name, optionalTx(params));
|
|
17719
|
+
return wrapResult(result, ScanFunctionResultSchema);
|
|
17720
|
+
});
|
|
17542
17721
|
const catalogTableScanBranchesGet = catalogHandler(signingKey, async (params) => {
|
|
17543
17722
|
const cat = getCatalog();
|
|
17544
17723
|
const branchesResult = await cat.tableScanBranchesGet(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);
|
|
@@ -17617,6 +17796,9 @@ function catalogTableHandlers(getCatalog, signingKey) {
|
|
|
17617
17796
|
catalogTableDrop,
|
|
17618
17797
|
catalogTableColumnStatisticsGet,
|
|
17619
17798
|
catalogTableScanFunctionGet,
|
|
17799
|
+
catalogTableInsertFunctionGet,
|
|
17800
|
+
catalogTableUpdateFunctionGet,
|
|
17801
|
+
catalogTableDeleteFunctionGet,
|
|
17620
17802
|
catalogTableScanBranchesGet,
|
|
17621
17803
|
catalogTableCommentSet,
|
|
17622
17804
|
catalogTableRename,
|
|
@@ -19539,6 +19721,7 @@ export {
|
|
|
19539
19721
|
PushdownFilters,
|
|
19540
19722
|
READ_ONLY_ITEM_ATTACH_ID,
|
|
19541
19723
|
RESERVED_ATTACH_OPTION,
|
|
19724
|
+
ROW_ID_METADATA_KEY,
|
|
19542
19725
|
ROW_SCALAR_EXPRESSION,
|
|
19543
19726
|
ReadOnlyCatalogInterface,
|
|
19544
19727
|
ReservedAttachOptionError,
|
|
@@ -19560,6 +19743,8 @@ export {
|
|
|
19560
19743
|
VgiClient,
|
|
19561
19744
|
VgiClientError,
|
|
19562
19745
|
VgiError,
|
|
19746
|
+
WRITE_OPERATIONS,
|
|
19747
|
+
WRITE_RESULT_MODES,
|
|
19563
19748
|
Worker,
|
|
19564
19749
|
adoptArrowJsShape,
|
|
19565
19750
|
argumentSpecsToSchema,
|
|
@@ -19609,6 +19794,7 @@ export {
|
|
|
19609
19794
|
canonicalIndex,
|
|
19610
19795
|
catalogCapabilities,
|
|
19611
19796
|
codecFor,
|
|
19797
|
+
coerceWriteResultMode,
|
|
19612
19798
|
columnFromArray,
|
|
19613
19799
|
constraintCapabilities,
|
|
19614
19800
|
constraintRecord,
|
|
@@ -19760,6 +19946,7 @@ export {
|
|
|
19760
19946
|
requireSecretOfType,
|
|
19761
19947
|
resolveMetadata,
|
|
19762
19948
|
resolveStorageFromEnv,
|
|
19949
|
+
rowIdField,
|
|
19763
19950
|
safeNumber,
|
|
19764
19951
|
schema2 as schema,
|
|
19765
19952
|
schemaPathDisplay,
|
|
@@ -19789,6 +19976,7 @@ export {
|
|
|
19789
19976
|
str,
|
|
19790
19977
|
struct2 as struct,
|
|
19791
19978
|
subprocessConnect,
|
|
19979
|
+
supportsWriteResultMode,
|
|
19792
19980
|
tcpConnect,
|
|
19793
19981
|
time2 as time,
|
|
19794
19982
|
timeMicrosecond2 as timeMicrosecond,
|
|
@@ -19808,12 +19996,20 @@ export {
|
|
|
19808
19996
|
uint642 as uint64,
|
|
19809
19997
|
uint82 as uint8,
|
|
19810
19998
|
union2 as union,
|
|
19999
|
+
userColumns,
|
|
19811
20000
|
utf82 as utf8,
|
|
19812
20001
|
validateColumnExpressionSql,
|
|
19813
20002
|
validateConstraintNullability,
|
|
19814
20003
|
validateForeignKeyTargets,
|
|
19815
20004
|
validateNumericCheckSql,
|
|
19816
|
-
validateTableConstraints
|
|
20005
|
+
validateTableConstraints,
|
|
20006
|
+
validateWriteResultModes,
|
|
20007
|
+
writeChangesBatch,
|
|
20008
|
+
writeCountBatch,
|
|
20009
|
+
writeOptions,
|
|
20010
|
+
writeResultBatch,
|
|
20011
|
+
writeResultSchema,
|
|
20012
|
+
writeRowsBatch
|
|
19817
20013
|
};
|
|
19818
20014
|
|
|
19819
|
-
//# debugId=
|
|
20015
|
+
//# debugId=403561B04FC0112564756E2164756E21
|