@query-farm/vgi 0.44.0 → 0.46.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 +8 -1
- package/dist/arrow/impl-arrowjs/index.d.ts +1 -1
- package/dist/arrow/impl-arrowjs/ipc.d.ts +6 -0
- package/dist/arrow/impl-flechette/build.d.ts +2 -2
- package/dist/arrow/impl-flechette/canonical.d.ts +2 -2
- package/dist/arrow/impl-flechette/index.d.ts +1 -1
- package/dist/arrow/impl-flechette/ipc.d.ts +6 -0
- package/dist/arrow/impl-flechette/schema.d.ts +19 -5
- package/dist/arrow/index.d.ts +1 -1
- package/dist/catalog/contents-codec.d.ts +7 -0
- package/dist/catalog/contents-digest.d.ts +2 -1
- package/dist/catalog/interface.d.ts +3 -0
- package/dist/catalog/publication-envelope.d.ts +1 -0
- package/dist/catalog/publication.d.ts +142 -0
- package/dist/catalog/s3-publication.d.ts +38 -0
- package/dist/client/client.d.ts +20 -1
- package/dist/client-entry.js +189 -37
- package/dist/client-entry.js.map +15 -12
- package/dist/codec/asd.d.ts +4 -0
- package/dist/functions/continuation.d.ts +69 -0
- package/dist/functions/table-in-out.d.ts +51 -7
- package/dist/functions/types.d.ts +20 -0
- package/dist/generated/vgi-client.d.ts +7 -14
- package/dist/generated/vgi-protocol-schemas.d.ts +2 -0
- package/dist/generated/vgi-protocol-types.d.ts +26 -3
- package/dist/generated/vgi-service.d.ts +3 -3
- package/dist/index.core.d.ts +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +981 -138
- package/dist/index.js.map +31 -25
- package/dist/protocol/dispatch.d.ts +1 -1
- package/dist/protocol/handlers/catalog/contents.d.ts +4 -4
- package/dist/serve-entry.js +643 -81
- package/dist/serve-entry.js.map +22 -18
- package/dist/util/parent-rows.d.ts +8 -0
- package/dist/worker-cf-entry.d.ts +1 -1
- package/dist/worker-cf-entry.js +821 -131
- package/dist/worker-cf-entry.js.map +29 -24
- package/package.json +4 -4
- package/src/arrow/impl-arrowjs/index.ts +1 -0
- package/src/arrow/impl-arrowjs/ipc.ts +23 -0
- package/src/arrow/impl-flechette/build.ts +4 -2
- package/src/arrow/impl-flechette/canonical.ts +14 -7
- package/src/arrow/impl-flechette/index.ts +1 -0
- package/src/arrow/impl-flechette/ipc.ts +19 -0
- package/src/arrow/index.ts +1 -1
- package/src/catalog/contents-codec.ts +77 -0
- package/src/catalog/contents-digest.ts +20 -17
- package/src/catalog/interface.ts +3 -0
- package/src/catalog/publication-envelope.ts +62 -0
- package/src/catalog/publication.ts +290 -0
- package/src/catalog/read-only.ts +6 -2
- package/src/catalog/s3-publication.ts +81 -0
- package/src/client/client.ts +82 -30
- package/src/codec/asd.ts +40 -1
- package/src/codec/conform.ts +2 -1
- package/src/filter-pushdown/collector.ts +17 -1
- package/src/functions/continuation.ts +202 -0
- package/src/functions/table-in-out.ts +131 -56
- package/src/functions/types.ts +20 -0
- package/src/generated/vgi-client.ts +8 -16
- package/src/generated/vgi-protocol-schemas.ts +14 -6
- package/src/generated/vgi-protocol-types.ts +39 -5
- package/src/generated/vgi-service.ts +4 -3
- package/src/index.core.ts +6 -0
- package/src/index.ts +5 -0
- package/src/protocol/dispatch.ts +1 -1
- package/src/protocol/handlers/catalog/admin.ts +7 -4
- package/src/protocol/handlers/catalog/contents.ts +50 -35
- package/src/protocol/handlers/function.ts +12 -0
- package/src/protocol/state-serializer.ts +7 -1
- package/src/util/parent-rows.ts +41 -0
- package/src/worker-cf-entry.ts +3 -0
package/dist/index.js
CHANGED
|
@@ -1729,7 +1729,26 @@ function deserializeBatch(bytes) {
|
|
|
1729
1729
|
}
|
|
1730
1730
|
return batches[0];
|
|
1731
1731
|
}
|
|
1732
|
+
function deserializeBatches(bytes) {
|
|
1733
|
+
return [...RecordBatchReader.from(bytes)];
|
|
1734
|
+
}
|
|
1735
|
+
function serializeBatches(batches, schema) {
|
|
1736
|
+
const writer = new RecordBatchStreamWriter;
|
|
1737
|
+
writer.reset(undefined, schema);
|
|
1738
|
+
for (const batch of batches)
|
|
1739
|
+
writer._writeRecordBatch(batch);
|
|
1740
|
+
writer.close();
|
|
1741
|
+
return writer.toUint8Array(true);
|
|
1742
|
+
}
|
|
1743
|
+
function serializeCollectionRows(schema, rows, maxBatchRows) {
|
|
1744
|
+
const batch = batchFromRows(rows, schema);
|
|
1745
|
+
const batches = [];
|
|
1746
|
+
for (let offset = 0;offset < batch.numRows; offset += maxBatchRows)
|
|
1747
|
+
batches.push(batch.slice(offset, offset + maxBatchRows));
|
|
1748
|
+
return serializeBatches(batches, schema);
|
|
1749
|
+
}
|
|
1732
1750
|
var init_ipc = __esm(() => {
|
|
1751
|
+
init_build();
|
|
1733
1752
|
init_empty();
|
|
1734
1753
|
});
|
|
1735
1754
|
|
|
@@ -1883,6 +1902,7 @@ __export(exports_impl_arrowjs, {
|
|
|
1883
1902
|
decodeDictValue: () => decodeDictValue,
|
|
1884
1903
|
denseUnion: () => denseUnion,
|
|
1885
1904
|
deserializeBatch: () => deserializeBatch,
|
|
1905
|
+
deserializeBatches: () => deserializeBatches,
|
|
1886
1906
|
deserializeSchema: () => deserializeSchema,
|
|
1887
1907
|
dictionary: () => dictionary,
|
|
1888
1908
|
duration: () => duration,
|
|
@@ -1912,6 +1932,8 @@ __export(exports_impl_arrowjs, {
|
|
|
1912
1932
|
safeNumber: () => safeNumber,
|
|
1913
1933
|
schema: () => schema,
|
|
1914
1934
|
serializeBatch: () => serializeBatch,
|
|
1935
|
+
serializeBatches: () => serializeBatches,
|
|
1936
|
+
serializeCollectionRows: () => serializeCollectionRows,
|
|
1915
1937
|
serializeSchema: () => serializeSchema,
|
|
1916
1938
|
sparseUnion: () => sparseUnion,
|
|
1917
1939
|
struct: () => struct,
|
|
@@ -4603,6 +4625,41 @@ function replayFilterHistory(filters, history) {
|
|
|
4603
4625
|
|
|
4604
4626
|
// src/filter-pushdown/collector.ts
|
|
4605
4627
|
init_arrow();
|
|
4628
|
+
|
|
4629
|
+
// src/util/parent-rows.ts
|
|
4630
|
+
var PARENT_ROW_METADATA_KEY = "vgi_rpc.parent_row#b64";
|
|
4631
|
+
function encodeParentRows(parentRows) {
|
|
4632
|
+
const raw = new Uint8Array(parentRows.length * 4);
|
|
4633
|
+
const dv = new DataView(raw.buffer);
|
|
4634
|
+
for (let i = 0;i < parentRows.length; i++) {
|
|
4635
|
+
dv.setInt32(i * 4, parentRows[i], true);
|
|
4636
|
+
}
|
|
4637
|
+
if (typeof globalThis.Buffer !== "undefined") {
|
|
4638
|
+
return globalThis.Buffer.from(raw).toString("base64");
|
|
4639
|
+
}
|
|
4640
|
+
let bin = "";
|
|
4641
|
+
for (let i = 0;i < raw.length; i++)
|
|
4642
|
+
bin += String.fromCharCode(raw[i]);
|
|
4643
|
+
return globalThis.btoa(bin);
|
|
4644
|
+
}
|
|
4645
|
+
function decodeParentRows(encoded) {
|
|
4646
|
+
let raw;
|
|
4647
|
+
if (typeof globalThis.Buffer !== "undefined") {
|
|
4648
|
+
raw = new Uint8Array(globalThis.Buffer.from(encoded, "base64"));
|
|
4649
|
+
} else {
|
|
4650
|
+
const bin = globalThis.atob(encoded);
|
|
4651
|
+
raw = new Uint8Array(bin.length);
|
|
4652
|
+
for (let i = 0;i < bin.length; i++)
|
|
4653
|
+
raw[i] = bin.charCodeAt(i);
|
|
4654
|
+
}
|
|
4655
|
+
const dv = new DataView(raw.buffer, raw.byteOffset, raw.byteLength);
|
|
4656
|
+
const out = new Int32Array(raw.byteLength >> 2);
|
|
4657
|
+
for (let i = 0;i < out.length; i++)
|
|
4658
|
+
out[i] = dv.getInt32(i * 4, true);
|
|
4659
|
+
return out;
|
|
4660
|
+
}
|
|
4661
|
+
|
|
4662
|
+
// src/filter-pushdown/collector.ts
|
|
4606
4663
|
function formatPushedFilters(filters) {
|
|
4607
4664
|
if (!filters || filters.filters.length === 0)
|
|
4608
4665
|
return "(none)";
|
|
@@ -4689,6 +4746,22 @@ class FilteringOutputCollector {
|
|
|
4689
4746
|
} else {
|
|
4690
4747
|
batch = batchFromColumns(batchOrColumns, this.inner.outputSchema);
|
|
4691
4748
|
}
|
|
4749
|
+
const encoded = metadata?.get(PARENT_ROW_METADATA_KEY);
|
|
4750
|
+
if (encoded !== undefined && batch.numRows > 0 && this.filters.filters.length > 0) {
|
|
4751
|
+
const mask = this.filters.evaluate(batch);
|
|
4752
|
+
const parents = decodeParentRows(encoded);
|
|
4753
|
+
const kept = [];
|
|
4754
|
+
for (let i = 0;i < parents.length; i++)
|
|
4755
|
+
if (mask[i])
|
|
4756
|
+
kept.push(parents[i]);
|
|
4757
|
+
const md = new Map(metadata);
|
|
4758
|
+
if (kept.length > 0)
|
|
4759
|
+
md.set(PARENT_ROW_METADATA_KEY, encodeParentRows(kept));
|
|
4760
|
+
else
|
|
4761
|
+
md.delete(PARENT_ROW_METADATA_KEY);
|
|
4762
|
+
this.inner.emit(filterBatch(batch, mask), md);
|
|
4763
|
+
return;
|
|
4764
|
+
}
|
|
4692
4765
|
const filtered = this.filters.apply(batch);
|
|
4693
4766
|
this.inner.emit(filtered, metadata);
|
|
4694
4767
|
}
|
|
@@ -5433,7 +5506,9 @@ function mapPairs(raw) {
|
|
|
5433
5506
|
return Object.entries(raw);
|
|
5434
5507
|
}
|
|
5435
5508
|
function zeroValue(type) {
|
|
5436
|
-
if (
|
|
5509
|
+
if (isDictionary(type))
|
|
5510
|
+
return zeroValue(type.dictionary);
|
|
5511
|
+
if (isUtf8(type))
|
|
5437
5512
|
return "";
|
|
5438
5513
|
if (isBinary(type))
|
|
5439
5514
|
return new Uint8Array(0);
|
|
@@ -5982,7 +6057,8 @@ var EXCHANGE_STATE_SCHEMA = schema2([
|
|
|
5982
6057
|
field2("opaque_data", binary2(), true),
|
|
5983
6058
|
field2("is_producer", bool2(), false),
|
|
5984
6059
|
field2("user_state", binary2(), true),
|
|
5985
|
-
field2("filter_history", binary2(), true)
|
|
6060
|
+
field2("filter_history", binary2(), true),
|
|
6061
|
+
field2("more_pending", bool2(), false)
|
|
5986
6062
|
]);
|
|
5987
6063
|
var TEXT_ENCODER = new TextEncoder;
|
|
5988
6064
|
var TEXT_DECODER = new TextDecoder;
|
|
@@ -5991,6 +6067,7 @@ var FLAG_PRODUCER = 1;
|
|
|
5991
6067
|
var FLAG_OPAQUE_DATA = 2;
|
|
5992
6068
|
var FLAG_USER_STATE = 4;
|
|
5993
6069
|
var FLAG_FILTER_HISTORY = 8;
|
|
6070
|
+
var FLAG_MORE_PENDING = 16;
|
|
5994
6071
|
var LIST_CHILD_NAME = "item";
|
|
5995
6072
|
var emptyListElementType = () => utf82();
|
|
5996
6073
|
function inferElementType(values) {
|
|
@@ -6096,7 +6173,7 @@ var arrowStateSerializer = {
|
|
|
6096
6173
|
const opaqueData = state.opaqueData != null ? toUint8Array(state.opaqueData) : null;
|
|
6097
6174
|
const userState = serializeUserState(state.userState);
|
|
6098
6175
|
const filterHistory = encodeFilterHistory(state.filterHistory);
|
|
6099
|
-
const flags = (state.isProducer ? FLAG_PRODUCER : 0) | (opaqueData ? FLAG_OPAQUE_DATA : 0) | (userState ? FLAG_USER_STATE : 0) | (filterHistory ? FLAG_FILTER_HISTORY : 0);
|
|
6176
|
+
const flags = (state.isProducer ? FLAG_PRODUCER : 0) | (opaqueData ? FLAG_OPAQUE_DATA : 0) | (userState ? FLAG_USER_STATE : 0) | (filterHistory ? FLAG_FILTER_HISTORY : 0) | (state.morePending ? FLAG_MORE_PENDING : 0);
|
|
6100
6177
|
const chunks = [functionName, initRequest, executionId];
|
|
6101
6178
|
if (opaqueData)
|
|
6102
6179
|
chunks.push(opaqueData);
|
|
@@ -6157,15 +6234,99 @@ var arrowStateSerializer = {
|
|
|
6157
6234
|
isProducer,
|
|
6158
6235
|
__isProducer: isProducer,
|
|
6159
6236
|
userState: deserializeUserState(userStateBytes),
|
|
6160
|
-
filterHistory: decodeFilterHistory(filterHistoryBytes)
|
|
6237
|
+
filterHistory: decodeFilterHistory(filterHistoryBytes),
|
|
6238
|
+
morePending: (flags & FLAG_MORE_PENDING) !== 0
|
|
6161
6239
|
};
|
|
6162
6240
|
}
|
|
6163
6241
|
};
|
|
6164
6242
|
|
|
6243
|
+
// src/functions/continuation.ts
|
|
6244
|
+
var STATUS_KEY = "vgi.status";
|
|
6245
|
+
var HAVE_MORE_OUTPUT = "HAVE_MORE_OUTPUT";
|
|
6246
|
+
var CONTINUE = "CONTINUE";
|
|
6247
|
+
var CACHE_KEY_PREFIX = "vgi.cache.";
|
|
6248
|
+
function moreOutputMetadata(more, extra) {
|
|
6249
|
+
const md = new Map(extra ?? []);
|
|
6250
|
+
if (more)
|
|
6251
|
+
md.set(STATUS_KEY, HAVE_MORE_OUTPUT);
|
|
6252
|
+
return md;
|
|
6253
|
+
}
|
|
6254
|
+
function replyMetadata(out) {
|
|
6255
|
+
const idx = out.dataBatchIdx;
|
|
6256
|
+
if (idx == null)
|
|
6257
|
+
return null;
|
|
6258
|
+
const emitted = out.batches[idx];
|
|
6259
|
+
const md = new Map(emitted.batch.metadata ?? []);
|
|
6260
|
+
for (const [k, v] of emitted.metadata ?? [])
|
|
6261
|
+
md.set(k, v);
|
|
6262
|
+
return md;
|
|
6263
|
+
}
|
|
6264
|
+
function refuseMoreOutput(name, out) {
|
|
6265
|
+
if (replyMetadata(out)?.get(STATUS_KEY) === HAVE_MORE_OUTPUT) {
|
|
6266
|
+
throw new Error(`${name}: HAVE_MORE_OUTPUT (moreOutputMetadata) is only valid in a table-in-out ` + `function's process() or resume()`);
|
|
6267
|
+
}
|
|
6268
|
+
}
|
|
6269
|
+
async function continuationTurn(name, eState, input, out, resumable, run) {
|
|
6270
|
+
const inputStatus = input?.metadata?.get(STATUS_KEY) ?? out.inputMetadata?.get(STATUS_KEY);
|
|
6271
|
+
const tick = inputStatus === CONTINUE;
|
|
6272
|
+
if (tick && !eState.morePending) {
|
|
6273
|
+
throw new Error(`${name}: continuation tick received, but no output is pending`);
|
|
6274
|
+
}
|
|
6275
|
+
if (tick && input.numRows !== 0) {
|
|
6276
|
+
throw new Error(`${name}: a continuation tick must have no rows, got ${input.numRows}`);
|
|
6277
|
+
}
|
|
6278
|
+
if (!tick && eState.morePending) {
|
|
6279
|
+
throw new Error(`${name}: input received while output is pending; expected a continuation tick`);
|
|
6280
|
+
}
|
|
6281
|
+
await run(tick);
|
|
6282
|
+
const md = replyMetadata(out);
|
|
6283
|
+
if (md == null) {
|
|
6284
|
+
throw new Error(tick ? `${name}: resume() must emit a batch for every continuation tick` : `${name}: process() must emit a batch for every input batch (No data batch was emitted)`);
|
|
6285
|
+
}
|
|
6286
|
+
const more = md.get(STATUS_KEY) === HAVE_MORE_OUTPUT;
|
|
6287
|
+
if (more && !resumable) {
|
|
6288
|
+
throw new Error(`${name}: emitted HAVE_MORE_OUTPUT but does not implement resume()`);
|
|
6289
|
+
}
|
|
6290
|
+
if (tick) {
|
|
6291
|
+
for (const key of md.keys()) {
|
|
6292
|
+
if (key.startsWith(CACHE_KEY_PREFIX)) {
|
|
6293
|
+
throw new Error(`${name}: cache control is only valid on an input's first reply, ` + `not on one answering a continuation tick (${key})`);
|
|
6294
|
+
}
|
|
6295
|
+
}
|
|
6296
|
+
}
|
|
6297
|
+
eState.morePending = more;
|
|
6298
|
+
}
|
|
6299
|
+
function checkResumeContract(name, config) {
|
|
6300
|
+
if (config.resume == null)
|
|
6301
|
+
return;
|
|
6302
|
+
if (typeof config.resume !== "function") {
|
|
6303
|
+
throw new Error(`${name}: resume must be a function`);
|
|
6304
|
+
}
|
|
6305
|
+
if (config.maxWorkers === 1) {
|
|
6306
|
+
throw new Error(`${name}: resume() (continued output) is not supported with maxWorkers: 1; ` + `the client runs such a function on one shared connection.`);
|
|
6307
|
+
}
|
|
6308
|
+
if (config.initialState == null) {
|
|
6309
|
+
throw new Error(`${name}: resume() continues from its state alone, so the function must ` + `declare an initialState holding where to resume.`);
|
|
6310
|
+
}
|
|
6311
|
+
}
|
|
6312
|
+
function checkInputRowsPerCall(name, value, blended) {
|
|
6313
|
+
if (value == null)
|
|
6314
|
+
return;
|
|
6315
|
+
if (!blended) {
|
|
6316
|
+
throw new Error(`${name}: inputRowsPerCall applies only to a blended row-transform function, ` + `whose per-row input the client can split into calls`);
|
|
6317
|
+
}
|
|
6318
|
+
if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 1) {
|
|
6319
|
+
throw new Error(`${name}: inputRowsPerCall must be a positive integer, got ${String(value)}`);
|
|
6320
|
+
}
|
|
6321
|
+
return value;
|
|
6322
|
+
}
|
|
6323
|
+
|
|
6165
6324
|
// src/functions/table-in-out.ts
|
|
6166
6325
|
var STREAMING_FINALIZE_KEY = new Uint8Array(0);
|
|
6167
6326
|
function defineTableInOutFunction(config) {
|
|
6168
6327
|
assertArrowTypes(config.args, `defineTableInOutFunction("${config.name}"): args`);
|
|
6328
|
+
checkResumeContract(config.name, config);
|
|
6329
|
+
checkInputRowsPerCall(config.name, config.inputRowsPerCall, false);
|
|
6169
6330
|
const specs = [];
|
|
6170
6331
|
let posIdx = 0;
|
|
6171
6332
|
if (config.args) {
|
|
@@ -6347,20 +6508,27 @@ function defineTableInOutFunction(config) {
|
|
|
6347
6508
|
return {
|
|
6348
6509
|
outputSchema,
|
|
6349
6510
|
inputSchema: request.bind_call.input_schema,
|
|
6350
|
-
|
|
6511
|
+
continuesOutput: true,
|
|
6512
|
+
exchangeInit: () => ({ state, processParams, filterHistory: carriedFilterHistory, morePending: false }),
|
|
6351
6513
|
exchangeFn: async (eState, input, out) => {
|
|
6352
|
-
|
|
6353
|
-
|
|
6354
|
-
|
|
6355
|
-
|
|
6356
|
-
|
|
6357
|
-
|
|
6358
|
-
|
|
6359
|
-
|
|
6360
|
-
|
|
6361
|
-
|
|
6362
|
-
|
|
6363
|
-
|
|
6514
|
+
await continuationTurn(config.name, eState, input, out, config.resume != null, async (tick) => {
|
|
6515
|
+
applyRevalidationValidators(eState.processParams, input);
|
|
6516
|
+
applyDynamicFilterUpdate(eState, input);
|
|
6517
|
+
let wrappedOut = makeMetadataBakingCollector(out);
|
|
6518
|
+
if (projIds) {
|
|
6519
|
+
wrappedOut = makeSchemaReconcilingCollector(wrappedOut, outputSchema);
|
|
6520
|
+
}
|
|
6521
|
+
const currentFilters = eState.processParams.pushdownFilters;
|
|
6522
|
+
if (config.autoApplyFilters && currentFilters) {
|
|
6523
|
+
wrappedOut = new FilteringOutputCollector(wrappedOut, currentFilters);
|
|
6524
|
+
}
|
|
6525
|
+
if (tick) {
|
|
6526
|
+
await config.resume(eState.processParams, eState.state, wrappedOut);
|
|
6527
|
+
} else {
|
|
6528
|
+
await processFn(eState.processParams, eState.state, input, wrappedOut);
|
|
6529
|
+
}
|
|
6530
|
+
});
|
|
6531
|
+
if (config.finalize && eState.state != null) {
|
|
6364
6532
|
const serialized = serializeUserState(eState.state);
|
|
6365
6533
|
if (serialized != null) {
|
|
6366
6534
|
await boundStorage.put(serialized);
|
|
@@ -6438,7 +6606,6 @@ function makeSchemaReconcilingCollector(inner, targetSchema) {
|
|
|
6438
6606
|
}
|
|
6439
6607
|
});
|
|
6440
6608
|
}
|
|
6441
|
-
var PARENT_ROW_METADATA_KEY = "vgi_rpc.parent_row#b64";
|
|
6442
6609
|
function parentRowsMetadata(parentRows, outputRows, extra) {
|
|
6443
6610
|
if (parentRows.length !== outputRows) {
|
|
6444
6611
|
throw new Error(`parentRowsMetadata: length ${parentRows.length} != output rows ${outputRows}; ` + `parentRows must carry exactly one input-row index per emitted output row`);
|
|
@@ -6447,28 +6614,16 @@ function parentRowsMetadata(parentRows, outputRows, extra) {
|
|
|
6447
6614
|
if (outputRows === 0) {
|
|
6448
6615
|
return md;
|
|
6449
6616
|
}
|
|
6450
|
-
|
|
6451
|
-
const dv = new DataView(raw.buffer);
|
|
6452
|
-
for (let i = 0;i < parentRows.length; i++) {
|
|
6453
|
-
dv.setInt32(i * 4, parentRows[i], true);
|
|
6454
|
-
}
|
|
6455
|
-
md.set(PARENT_ROW_METADATA_KEY, base64Encode(raw));
|
|
6617
|
+
md.set(PARENT_ROW_METADATA_KEY, encodeParentRows(parentRows));
|
|
6456
6618
|
return md;
|
|
6457
6619
|
}
|
|
6458
|
-
function base64Encode(bytes) {
|
|
6459
|
-
if (typeof globalThis.Buffer !== "undefined") {
|
|
6460
|
-
return globalThis.Buffer.from(bytes).toString("base64");
|
|
6461
|
-
}
|
|
6462
|
-
let bin = "";
|
|
6463
|
-
for (let i = 0;i < bytes.length; i++)
|
|
6464
|
-
bin += String.fromCharCode(bytes[i]);
|
|
6465
|
-
return globalThis.btoa(bin);
|
|
6466
|
-
}
|
|
6467
6620
|
function defineRowTransformFunction(config) {
|
|
6468
6621
|
const numPositional = Object.keys(config.args ?? {}).length + (config.varargs ? 1 : 0);
|
|
6469
6622
|
if (numPositional === 0) {
|
|
6470
6623
|
throw new Error(`${config.name}: a blended row-transform function needs at least one ` + `positional arg (its per-row input column); found none.`);
|
|
6471
6624
|
}
|
|
6625
|
+
checkResumeContract(config.name, config);
|
|
6626
|
+
const inputRowsPerCall = checkInputRowsPerCall(config.name, config.inputRowsPerCall, true);
|
|
6472
6627
|
const specs = [];
|
|
6473
6628
|
let posIdx = 0;
|
|
6474
6629
|
if (config.args) {
|
|
@@ -6522,7 +6677,8 @@ function defineRowTransformFunction(config) {
|
|
|
6522
6677
|
requiredSettings: config.requiredSettings,
|
|
6523
6678
|
requiredSecrets: config.requiredSecrets,
|
|
6524
6679
|
hasFinalize: false,
|
|
6525
|
-
inputFromArgs: true
|
|
6680
|
+
inputFromArgs: true,
|
|
6681
|
+
inputRowsPerCall
|
|
6526
6682
|
};
|
|
6527
6683
|
function extractArgs(request) {
|
|
6528
6684
|
const args = {};
|
|
@@ -6607,22 +6763,30 @@ function defineRowTransformFunction(config) {
|
|
|
6607
6763
|
if (request.bind_call.input_schema == null) {
|
|
6608
6764
|
throw new Error(`${config.name}: is a table-in-out function (its positional args are ` + `per-row input columns) but no input schema was supplied -- call it ` + `via table_in_out_function(input=...), not table_function().`);
|
|
6609
6765
|
}
|
|
6766
|
+
const state = config.initialState ? config.initialState(processParams) : null;
|
|
6610
6767
|
return {
|
|
6611
6768
|
outputSchema,
|
|
6612
6769
|
inputSchema: request.bind_call.input_schema,
|
|
6613
|
-
|
|
6770
|
+
continuesOutput: true,
|
|
6771
|
+
exchangeInit: () => ({ state, processParams, filterHistory: carriedFilterHistory, morePending: false }),
|
|
6614
6772
|
exchangeFn: async (eState, input, out) => {
|
|
6615
|
-
|
|
6616
|
-
|
|
6617
|
-
|
|
6618
|
-
|
|
6619
|
-
|
|
6620
|
-
|
|
6621
|
-
|
|
6622
|
-
|
|
6623
|
-
|
|
6624
|
-
|
|
6625
|
-
|
|
6773
|
+
await continuationTurn(config.name, eState, input, out, config.resume != null, async (tick) => {
|
|
6774
|
+
applyRevalidationValidators(eState.processParams, input);
|
|
6775
|
+
applyDynamicFilterUpdate(eState, input);
|
|
6776
|
+
let wrappedOut = makeMetadataBakingCollector(out);
|
|
6777
|
+
if (projIds) {
|
|
6778
|
+
wrappedOut = makeSchemaReconcilingCollector(wrappedOut, outputSchema);
|
|
6779
|
+
}
|
|
6780
|
+
const currentFilters = eState.processParams.pushdownFilters;
|
|
6781
|
+
if (config.autoApplyFilters && currentFilters) {
|
|
6782
|
+
wrappedOut = new FilteringOutputCollector(wrappedOut, currentFilters);
|
|
6783
|
+
}
|
|
6784
|
+
if (tick) {
|
|
6785
|
+
await config.resume(eState.processParams, eState.state, wrappedOut);
|
|
6786
|
+
} else {
|
|
6787
|
+
await config.process(eState.processParams, input, wrappedOut, eState.state);
|
|
6788
|
+
}
|
|
6789
|
+
});
|
|
6626
6790
|
}
|
|
6627
6791
|
};
|
|
6628
6792
|
}
|
|
@@ -7331,7 +7495,7 @@ function normalizeValue(raw, type) {
|
|
|
7331
7495
|
return out;
|
|
7332
7496
|
}
|
|
7333
7497
|
if (isDictionary(type)) {
|
|
7334
|
-
return raw
|
|
7498
|
+
return normalizeValue(raw, type.dictionary);
|
|
7335
7499
|
}
|
|
7336
7500
|
if (isBinary(type)) {
|
|
7337
7501
|
return toUint8Array3(raw);
|
|
@@ -7360,9 +7524,44 @@ function toUint8Array3(val) {
|
|
|
7360
7524
|
}
|
|
7361
7525
|
return new Uint8Array(0);
|
|
7362
7526
|
}
|
|
7527
|
+
function encodeASDCollection(schema, records) {
|
|
7528
|
+
if (records.length === 0)
|
|
7529
|
+
return null;
|
|
7530
|
+
return serializeCollectionRows(schema, records.map((record) => sortMapsForSchema(schema, conformRecord(schema, record))), 1024);
|
|
7531
|
+
}
|
|
7532
|
+
function decodeASDCollection(schema, bytes) {
|
|
7533
|
+
if (bytes == null)
|
|
7534
|
+
return [];
|
|
7535
|
+
const output = [];
|
|
7536
|
+
const batches = deserializeBatches(bytes);
|
|
7537
|
+
const validateSchema = (actualSchema) => {
|
|
7538
|
+
if (actualSchema.fields.length !== schema.fields.length || schema.fields.some((field, i) => {
|
|
7539
|
+
const actual = actualSchema.fields[i];
|
|
7540
|
+
return actual.name !== field.name || actual.nullable !== field.nullable || typeSignature(actual.type) !== typeSignature(field.type);
|
|
7541
|
+
}))
|
|
7542
|
+
throw new Error("catalog collection has an incompatible metadata schema");
|
|
7543
|
+
};
|
|
7544
|
+
if (batches.length === 0)
|
|
7545
|
+
validateSchema(deserializeSchema(bytes));
|
|
7546
|
+
for (const batch of batches) {
|
|
7547
|
+
validateSchema(batch.schema);
|
|
7548
|
+
for (let row = 0;row < batch.numRows; row++) {
|
|
7549
|
+
const item = {};
|
|
7550
|
+
for (const field of schema.fields) {
|
|
7551
|
+
const value = batch.getChild(field.name)?.get(row);
|
|
7552
|
+
if (value == null && !field.nullable)
|
|
7553
|
+
throw new Error(`catalog collection has null ${field.name}`);
|
|
7554
|
+
item[field.name] = normalizeValue(value, field.type);
|
|
7555
|
+
}
|
|
7556
|
+
output.push(item);
|
|
7557
|
+
}
|
|
7558
|
+
}
|
|
7559
|
+
return output;
|
|
7560
|
+
}
|
|
7363
7561
|
|
|
7364
7562
|
// src/generated/vgi-protocol-schemas.ts
|
|
7365
7563
|
init_arrow();
|
|
7564
|
+
var VGI_CATALOG_CONTRACT_HASH = "0aa39285365f5f4326ce85c4d41d2705ea992dee41cf98d07640a2767b6ac3fb";
|
|
7366
7565
|
var CatalogInfoSchema = schema2([
|
|
7367
7566
|
field2("name", utf82(), false),
|
|
7368
7567
|
field2("implementation_version", utf82(), true),
|
|
@@ -7374,7 +7573,6 @@ var CatalogInfoSchema = schema2([
|
|
|
7374
7573
|
var SchemaInfoSchema = schema2([
|
|
7375
7574
|
field2("comment", utf82(), true),
|
|
7376
7575
|
field2("tags", map2(field2("key", utf82(), false), field2("value", utf82(), true), false), false),
|
|
7377
|
-
field2("attach_opaque_data", binary2(), false),
|
|
7378
7576
|
field2("path", list2(field2("item", utf82(), true)), false),
|
|
7379
7577
|
field2("estimated_object_count", map2(field2("key", utf82(), false), field2("value", int642(), true), false), true)
|
|
7380
7578
|
]);
|
|
@@ -7415,9 +7613,9 @@ var FunctionInfoSchema = schema2([
|
|
|
7415
7613
|
field2("name", utf82(), false),
|
|
7416
7614
|
field2("schema_path", list2(field2("item", utf82(), true)), false),
|
|
7417
7615
|
field2("function_type", dictionary2(utf82(), int162()), false),
|
|
7418
|
-
field2("arguments", binary2(), false),
|
|
7419
|
-
field2("output_schema", binary2(), false),
|
|
7420
|
-
field2("parameter_default_values", binary2(), true),
|
|
7616
|
+
field2("arguments", dictionary2(binary2(), int322()), false),
|
|
7617
|
+
field2("output_schema", dictionary2(binary2(), int322()), false),
|
|
7618
|
+
field2("parameter_default_values", dictionary2(binary2(), int322()), true),
|
|
7421
7619
|
field2("stability", dictionary2(utf82(), int162()), true),
|
|
7422
7620
|
field2("null_handling", dictionary2(utf82(), int162()), true),
|
|
7423
7621
|
field2("argument_monotonicity", list2(field2("item", utf82(), true)), true),
|
|
@@ -7449,6 +7647,7 @@ var FunctionInfoSchema = schema2([
|
|
|
7449
7647
|
field2("sink_order_dependent", bool2(), false),
|
|
7450
7648
|
field2("requires_input_batch_index", bool2(), false),
|
|
7451
7649
|
field2("input_from_args", bool2(), false),
|
|
7650
|
+
field2("input_rows_per_call", int642(), true),
|
|
7452
7651
|
field2("required_settings", list2(field2("item", utf82(), true)), false),
|
|
7453
7652
|
field2("required_secrets", list2(field2("item", struct2([field2("secret_type", utf82(), false), field2("scope", utf82(), true), field2("secret_name", utf82(), true)]), true)), false)
|
|
7454
7653
|
]);
|
|
@@ -7878,7 +8077,12 @@ var CatalogContentsResultSchema = schema2([
|
|
|
7878
8077
|
field2("catalog_version", int642(), false),
|
|
7879
8078
|
field2("etag", utf82(), true),
|
|
7880
8079
|
field2("not_modified", bool2(), false),
|
|
7881
|
-
field2("schemas",
|
|
8080
|
+
field2("schemas", binary2(), true),
|
|
8081
|
+
field2("tables", binary2(), true),
|
|
8082
|
+
field2("views", binary2(), true),
|
|
8083
|
+
field2("functions", binary2(), true),
|
|
8084
|
+
field2("macros", binary2(), true),
|
|
8085
|
+
field2("indexes", binary2(), true)
|
|
7882
8086
|
]);
|
|
7883
8087
|
var CatalogCopyFromFormatsResultSchema = schema2([
|
|
7884
8088
|
field2("items", list2(field2("item", binary2(), true)), false)
|
|
@@ -8355,26 +8559,17 @@ function buildCatalogAttachResult(init) {
|
|
|
8355
8559
|
supports_catalog_contents: init.supports_catalog_contents ?? false
|
|
8356
8560
|
};
|
|
8357
8561
|
}
|
|
8358
|
-
function buildSchemaContents(init) {
|
|
8359
|
-
return {
|
|
8360
|
-
path: init.path,
|
|
8361
|
-
schema: init.schema,
|
|
8362
|
-
tables: init.tables ?? [],
|
|
8363
|
-
views: init.views ?? [],
|
|
8364
|
-
scalar_functions: init.scalar_functions ?? [],
|
|
8365
|
-
aggregate_functions: init.aggregate_functions ?? [],
|
|
8366
|
-
table_functions: init.table_functions ?? [],
|
|
8367
|
-
scalar_macros: init.scalar_macros ?? [],
|
|
8368
|
-
table_macros: init.table_macros ?? [],
|
|
8369
|
-
indexes: init.indexes ?? []
|
|
8370
|
-
};
|
|
8371
|
-
}
|
|
8372
8562
|
function buildCatalogContentsResponse(init) {
|
|
8373
8563
|
return {
|
|
8374
8564
|
catalog_version: init.catalog_version,
|
|
8375
8565
|
etag: init.etag ?? null,
|
|
8376
8566
|
not_modified: init.not_modified ?? false,
|
|
8377
|
-
schemas: init.schemas ??
|
|
8567
|
+
schemas: init.schemas ?? null,
|
|
8568
|
+
tables: init.tables ?? null,
|
|
8569
|
+
views: init.views ?? null,
|
|
8570
|
+
functions: init.functions ?? null,
|
|
8571
|
+
macros: init.macros ?? null,
|
|
8572
|
+
indexes: init.indexes ?? null
|
|
8378
8573
|
};
|
|
8379
8574
|
}
|
|
8380
8575
|
var decodeCatalogContentsResponse = (b) => decodeASD(CatalogContentsResultSchema, b);
|
|
@@ -8527,6 +8722,7 @@ function isPromise(v) {
|
|
|
8527
8722
|
}
|
|
8528
8723
|
|
|
8529
8724
|
class CatalogInterface {
|
|
8725
|
+
catalogSnapshotPolicy = null;
|
|
8530
8726
|
catalogContentsEtag = null;
|
|
8531
8727
|
catalogContentsAttachIndependent = false;
|
|
8532
8728
|
catalogVersionFrozen = false;
|
|
@@ -9097,7 +9293,6 @@ class ReadOnlyCatalogInterface extends CatalogInterface {
|
|
|
9097
9293
|
}
|
|
9098
9294
|
schemas(attachOpaqueData, transactionOpaqueData) {
|
|
9099
9295
|
return this._descriptor.schemas.map((s) => ({
|
|
9100
|
-
attach_opaque_data: this.itemAttachId(attachOpaqueData),
|
|
9101
9296
|
path: schemaDescriptorPath(s),
|
|
9102
9297
|
comment: s.comment ?? null,
|
|
9103
9298
|
tags: s.tags ?? {},
|
|
@@ -9129,7 +9324,6 @@ class ReadOnlyCatalogInterface extends CatalogInterface {
|
|
|
9129
9324
|
if (!desc)
|
|
9130
9325
|
return null;
|
|
9131
9326
|
return {
|
|
9132
|
-
attach_opaque_data: this.itemAttachId(attachOpaqueData),
|
|
9133
9327
|
path: schemaDescriptorPath(desc),
|
|
9134
9328
|
comment: desc.comment ?? null,
|
|
9135
9329
|
tags: desc.tags ?? {},
|
|
@@ -9367,6 +9561,7 @@ class ReadOnlyCatalogInterface extends CatalogInterface {
|
|
|
9367
9561
|
sink_order_dependent: f.kind === "table_buffering" && f.meta.sinkOrderDependent === true,
|
|
9368
9562
|
requires_input_batch_index: f.kind === "table_buffering" && f.meta.requiresInputBatchIndex === true,
|
|
9369
9563
|
input_from_args: f.kind === "table_in_out" && f.meta.inputFromArgs === true,
|
|
9564
|
+
input_rows_per_call: f.kind === "table_in_out" && f.meta.inputFromArgs === true ? f.meta.inputRowsPerCall ?? null : null,
|
|
9370
9565
|
required_settings: meta.requiredSettings,
|
|
9371
9566
|
required_secrets: requiredSecrets.map((s) => ({
|
|
9372
9567
|
secret_type: s.secret_type,
|
|
@@ -11204,7 +11399,7 @@ import {
|
|
|
11204
11399
|
Protocol
|
|
11205
11400
|
} from "@query-farm/vgi-rpc";
|
|
11206
11401
|
var VGI_PROTOCOL_NAME = "vgi.v2";
|
|
11207
|
-
var VGI_PROTOCOL_VERSION = "2.
|
|
11402
|
+
var VGI_PROTOCOL_VERSION = "2.2.0";
|
|
11208
11403
|
function exchangeStream(callbacks) {
|
|
11209
11404
|
return { kind: "exchange", ...callbacks };
|
|
11210
11405
|
}
|
|
@@ -12908,6 +13103,9 @@ function functionHandlers(config) {
|
|
|
12908
13103
|
if (state.userState != null && handlerState?.state !== undefined) {
|
|
12909
13104
|
handlerState.state = state.userState;
|
|
12910
13105
|
}
|
|
13106
|
+
if (handlers.continuesOutput) {
|
|
13107
|
+
handlerState.morePending = state.morePending === true;
|
|
13108
|
+
}
|
|
12911
13109
|
}
|
|
12912
13110
|
if (state.isProducer && handlers.producerFn) {
|
|
12913
13111
|
out.finish = () => {
|
|
@@ -12920,10 +13118,14 @@ function functionHandlers(config) {
|
|
|
12920
13118
|
} else if (handlers.exchangeFn) {
|
|
12921
13119
|
await handlers.exchangeFn(handlerState, input, out);
|
|
12922
13120
|
}
|
|
13121
|
+
if (!handlers.continuesOutput) {
|
|
13122
|
+
refuseMoreOutput(state.functionName, out);
|
|
13123
|
+
}
|
|
12923
13124
|
if (handlerState?.state !== undefined) {
|
|
12924
13125
|
state.userState = handlerState.state;
|
|
12925
13126
|
}
|
|
12926
13127
|
state.filterHistory = handlerState?.filterHistory ?? null;
|
|
13128
|
+
state.morePending = handlerState?.morePending === true;
|
|
12927
13129
|
},
|
|
12928
13130
|
headerInit: (params, state, ctx) => {
|
|
12929
13131
|
if (!state._initResponse) {
|
|
@@ -13356,18 +13558,97 @@ function hex(buf) {
|
|
|
13356
13558
|
return Array.from(buf, (b) => b.toString(16).padStart(2, "0")).join("");
|
|
13357
13559
|
}
|
|
13358
13560
|
|
|
13561
|
+
// src/protocol/handlers/catalog/contents.ts
|
|
13562
|
+
import { ExternalRef as ExternalRef2 } from "@query-farm/vgi-rpc";
|
|
13563
|
+
|
|
13564
|
+
// src/catalog/publication.ts
|
|
13565
|
+
init_arrow();
|
|
13566
|
+
import { ExternalRef, publishExternalResult, resolveExternalLocation } from "@query-farm/vgi-rpc";
|
|
13567
|
+
|
|
13568
|
+
// src/catalog/contents-codec.ts
|
|
13569
|
+
var schemaPathKey2 = (path) => JSON.stringify(path.map((part) => part.toLowerCase()));
|
|
13570
|
+
var CATALOG_STREAM_KINDS = ["schemas", "tables", "views", "functions", "macros", "indexes"];
|
|
13571
|
+
function encodeCatalogStreams(inventory) {
|
|
13572
|
+
const streams = {
|
|
13573
|
+
schemas: encodeASDCollection(SchemaInfoSchema, inventory.map((s) => s.schema)),
|
|
13574
|
+
tables: encodeASDCollection(TableInfoSchema, inventory.flatMap((s) => s.tables)),
|
|
13575
|
+
views: encodeASDCollection(ViewInfoSchema, inventory.flatMap((s) => s.views)),
|
|
13576
|
+
functions: encodeASDCollection(FunctionInfoSchema, inventory.flatMap((s) => [...s.scalar_functions, ...s.aggregate_functions, ...s.table_functions])),
|
|
13577
|
+
macros: encodeASDCollection(MacroInfoSchema, inventory.flatMap((s) => [...s.scalar_macros, ...s.table_macros])),
|
|
13578
|
+
indexes: encodeASDCollection(IndexInfoSchema, inventory.flatMap((s) => s.indexes))
|
|
13579
|
+
};
|
|
13580
|
+
return streams;
|
|
13581
|
+
}
|
|
13582
|
+
function decodeCatalogStreams(response, ifNoneMatch) {
|
|
13583
|
+
if (response.not_modified) {
|
|
13584
|
+
if (response.etag == null || ifNoneMatch !== undefined && response.etag !== ifNoneMatch || CATALOG_STREAM_KINDS.some((kind) => response[kind] != null)) {
|
|
13585
|
+
throw new Error("invalid catalog_contents not_modified response");
|
|
13586
|
+
}
|
|
13587
|
+
return [];
|
|
13588
|
+
}
|
|
13589
|
+
const infos = decodeASDCollection(SchemaInfoSchema, response.schemas);
|
|
13590
|
+
const schemas = [];
|
|
13591
|
+
const index = new Map;
|
|
13592
|
+
for (const schema of infos) {
|
|
13593
|
+
if (!Array.isArray(schema.path) || schema.path.length === 0)
|
|
13594
|
+
throw new Error("catalog schema has an empty path");
|
|
13595
|
+
const key = schemaPathKey2(schema.path);
|
|
13596
|
+
if (index.has(key))
|
|
13597
|
+
throw new Error("catalog contains duplicate schema paths");
|
|
13598
|
+
if (schema.path.length > 1 && !index.has(schemaPathKey2(schema.path.slice(0, -1)))) {
|
|
13599
|
+
throw new Error("catalog schema is missing its preceding parent");
|
|
13600
|
+
}
|
|
13601
|
+
const entry = { schema, tables: [], views: [], scalar_functions: [], aggregate_functions: [], table_functions: [], scalar_macros: [], table_macros: [], indexes: [] };
|
|
13602
|
+
index.set(key, entry);
|
|
13603
|
+
schemas.push(entry);
|
|
13604
|
+
}
|
|
13605
|
+
const owner = (item) => {
|
|
13606
|
+
const entry = index.get(schemaPathKey2(item.schema_path));
|
|
13607
|
+
if (!entry)
|
|
13608
|
+
throw new Error("catalog object references an absent schema");
|
|
13609
|
+
return entry;
|
|
13610
|
+
};
|
|
13611
|
+
for (const item of decodeASDCollection(TableInfoSchema, response.tables))
|
|
13612
|
+
owner(item).tables.push(item);
|
|
13613
|
+
for (const item of decodeASDCollection(ViewInfoSchema, response.views))
|
|
13614
|
+
owner(item).views.push(item);
|
|
13615
|
+
for (const item of decodeASDCollection(FunctionInfoSchema, response.functions)) {
|
|
13616
|
+
const entry = owner(item);
|
|
13617
|
+
switch (String(item.function_type).toUpperCase()) {
|
|
13618
|
+
case "SCALAR":
|
|
13619
|
+
entry.scalar_functions.push(item);
|
|
13620
|
+
break;
|
|
13621
|
+
case "AGGREGATE":
|
|
13622
|
+
entry.aggregate_functions.push(item);
|
|
13623
|
+
break;
|
|
13624
|
+
case "TABLE":
|
|
13625
|
+
case "TABLE_BUFFERING":
|
|
13626
|
+
entry.table_functions.push(item);
|
|
13627
|
+
break;
|
|
13628
|
+
default:
|
|
13629
|
+
throw new Error(`unknown catalog function type ${item.function_type}`);
|
|
13630
|
+
}
|
|
13631
|
+
}
|
|
13632
|
+
for (const item of decodeASDCollection(MacroInfoSchema, response.macros)) {
|
|
13633
|
+
const entry = owner(item);
|
|
13634
|
+
switch (String(item.macro_type).toUpperCase()) {
|
|
13635
|
+
case "SCALAR":
|
|
13636
|
+
entry.scalar_macros.push(item);
|
|
13637
|
+
break;
|
|
13638
|
+
case "TABLE":
|
|
13639
|
+
entry.table_macros.push(item);
|
|
13640
|
+
break;
|
|
13641
|
+
default:
|
|
13642
|
+
throw new Error(`unknown catalog macro type ${item.macro_type}`);
|
|
13643
|
+
}
|
|
13644
|
+
}
|
|
13645
|
+
for (const item of decodeASDCollection(IndexInfoSchema, response.indexes))
|
|
13646
|
+
owner(item).indexes.push(item);
|
|
13647
|
+
return schemas;
|
|
13648
|
+
}
|
|
13649
|
+
|
|
13359
13650
|
// src/catalog/contents-digest.ts
|
|
13360
|
-
|
|
13361
|
-
"tables",
|
|
13362
|
-
"views",
|
|
13363
|
-
"scalar_functions",
|
|
13364
|
-
"aggregate_functions",
|
|
13365
|
-
"table_functions",
|
|
13366
|
-
"scalar_macros",
|
|
13367
|
-
"table_macros",
|
|
13368
|
-
"indexes"
|
|
13369
|
-
];
|
|
13370
|
-
async function catalogContentsDigest(schemas) {
|
|
13651
|
+
async function catalogContentsDigest(streams, version = 0) {
|
|
13371
13652
|
const utf8 = new TextEncoder;
|
|
13372
13653
|
const parts = [];
|
|
13373
13654
|
let total = 0;
|
|
@@ -13387,12 +13668,23 @@ async function catalogContentsDigest(schemas) {
|
|
|
13387
13668
|
for (const v of values)
|
|
13388
13669
|
chunk(v);
|
|
13389
13670
|
};
|
|
13390
|
-
|
|
13391
|
-
|
|
13392
|
-
|
|
13393
|
-
|
|
13394
|
-
|
|
13395
|
-
|
|
13671
|
+
if (Array.isArray(streams)) {
|
|
13672
|
+
count(streams.length);
|
|
13673
|
+
for (const entry of streams) {
|
|
13674
|
+
chunks(entry.path.map((p) => utf8.encode(p)));
|
|
13675
|
+
chunk(entry.schema);
|
|
13676
|
+
for (const kind of ["tables", "views", "scalar_functions", "aggregate_functions", "table_functions", "scalar_macros", "table_macros", "indexes"])
|
|
13677
|
+
chunks(entry[kind]);
|
|
13678
|
+
}
|
|
13679
|
+
} else {
|
|
13680
|
+
chunk(utf8.encode("vgi.catalog-contents.2.2"));
|
|
13681
|
+
count(version);
|
|
13682
|
+
for (const kind of CATALOG_STREAM_KINDS) {
|
|
13683
|
+
const value = streams[kind];
|
|
13684
|
+
count(value == null ? 0 : 1);
|
|
13685
|
+
if (value != null)
|
|
13686
|
+
chunk(value);
|
|
13687
|
+
}
|
|
13396
13688
|
}
|
|
13397
13689
|
const buf = new Uint8Array(total);
|
|
13398
13690
|
let off = 0;
|
|
@@ -13407,7 +13699,391 @@ async function catalogContentsDigest(schemas) {
|
|
|
13407
13699
|
return hex;
|
|
13408
13700
|
}
|
|
13409
13701
|
|
|
13702
|
+
// src/catalog/publication-envelope.ts
|
|
13703
|
+
function validateCatalogPublicationEnvelope(bytes) {
|
|
13704
|
+
try {
|
|
13705
|
+
const stream = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
13706
|
+
let position = 0, messages = 0;
|
|
13707
|
+
while (position < bytes.length) {
|
|
13708
|
+
let length = stream.getInt32(position, true);
|
|
13709
|
+
position += 4;
|
|
13710
|
+
if (length === -1) {
|
|
13711
|
+
length = stream.getInt32(position, true);
|
|
13712
|
+
position += 4;
|
|
13713
|
+
}
|
|
13714
|
+
if (length === 0) {
|
|
13715
|
+
if (position !== bytes.length)
|
|
13716
|
+
throw new Error("trailing data");
|
|
13717
|
+
break;
|
|
13718
|
+
}
|
|
13719
|
+
if (length < 4 || length > bytes.length - position)
|
|
13720
|
+
throw new Error("invalid message length");
|
|
13721
|
+
const head = new DataView(bytes.buffer, bytes.byteOffset + position, length);
|
|
13722
|
+
const tableField = (table, field) => {
|
|
13723
|
+
const vtable = table - head.getInt32(table, true);
|
|
13724
|
+
const vlength = head.getUint16(vtable, true);
|
|
13725
|
+
if (vlength < 4 || vlength % 2 || vtable + vlength > length)
|
|
13726
|
+
throw new Error("invalid vtable");
|
|
13727
|
+
if (4 + 2 * field >= vlength)
|
|
13728
|
+
return null;
|
|
13729
|
+
const offset = head.getUint16(vtable + 4 + 2 * field, true);
|
|
13730
|
+
return offset === 0 ? null : table + offset;
|
|
13731
|
+
};
|
|
13732
|
+
const follow = (pointer) => pointer + head.getUint32(pointer, true);
|
|
13733
|
+
const root = head.getUint32(0, true);
|
|
13734
|
+
const typePosition = tableField(root, 1);
|
|
13735
|
+
const type = typePosition == null ? 0 : head.getUint8(typePosition);
|
|
13736
|
+
if (type !== (messages === 0 ? 1 : messages === 1 ? 3 : -1))
|
|
13737
|
+
throw new Error("expected one schema and one record batch");
|
|
13738
|
+
if (type === 3) {
|
|
13739
|
+
const header = tableField(root, 2);
|
|
13740
|
+
if (header == null)
|
|
13741
|
+
throw new Error("missing record header");
|
|
13742
|
+
const rows = tableField(follow(header), 0);
|
|
13743
|
+
if (rows == null || head.getBigInt64(rows, true) !== 1n)
|
|
13744
|
+
throw new Error("expected one response row");
|
|
13745
|
+
}
|
|
13746
|
+
const metadata = tableField(root, 4);
|
|
13747
|
+
if (metadata != null) {
|
|
13748
|
+
const vector = follow(metadata), count = head.getUint32(vector, true);
|
|
13749
|
+
if (count > length / 4)
|
|
13750
|
+
throw new Error("invalid metadata vector");
|
|
13751
|
+
for (let i = 0;i < count; i++) {
|
|
13752
|
+
const keyPointer = tableField(follow(vector + 4 + 4 * i), 0);
|
|
13753
|
+
if (keyPointer == null)
|
|
13754
|
+
continue;
|
|
13755
|
+
const keyStart = follow(keyPointer), keyLength = head.getUint32(keyStart, true);
|
|
13756
|
+
if (keyStart + 4 + keyLength > length)
|
|
13757
|
+
throw new Error("invalid metadata key");
|
|
13758
|
+
const key = new TextDecoder().decode(new Uint8Array(head.buffer, head.byteOffset + keyStart + 4, keyLength));
|
|
13759
|
+
if (key === "vgi_rpc.location" || key === "vgi_rpc.log_level")
|
|
13760
|
+
throw new Error("pointer/log metadata is not a catalog result");
|
|
13761
|
+
}
|
|
13762
|
+
}
|
|
13763
|
+
const bodyPosition = tableField(root, 3);
|
|
13764
|
+
const bodyLength = bodyPosition == null ? 0 : Number(head.getBigInt64(bodyPosition, true));
|
|
13765
|
+
position += length;
|
|
13766
|
+
if (!Number.isSafeInteger(bodyLength) || bodyLength < 0 || bodyLength > bytes.length - position)
|
|
13767
|
+
throw new Error("invalid body length");
|
|
13768
|
+
position += bodyLength;
|
|
13769
|
+
messages++;
|
|
13770
|
+
}
|
|
13771
|
+
if (messages !== 2)
|
|
13772
|
+
throw new Error("missing response batch");
|
|
13773
|
+
} catch (error) {
|
|
13774
|
+
throw new Error(`invalid published RPC envelope: ${error instanceof Error ? error.message : String(error)}`);
|
|
13775
|
+
}
|
|
13776
|
+
}
|
|
13777
|
+
|
|
13778
|
+
// src/catalog/publication.ts
|
|
13779
|
+
var OUTER_SCHEMA = schema2([field2("result", binary2(), false)]);
|
|
13780
|
+
var DEFAULT_MAX = 64 * 1024 * 1024;
|
|
13781
|
+
var utf83 = new TextEncoder;
|
|
13782
|
+
var equalBytes3 = (a, b) => a.length === b.length && a.every((v, i) => v === b[i]);
|
|
13783
|
+
async function digest(value) {
|
|
13784
|
+
const bytes = new Uint8Array(await crypto.subtle.digest("SHA-256", utf83.encode(value)));
|
|
13785
|
+
return Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("");
|
|
13786
|
+
}
|
|
13787
|
+
function assertRenewedPublication(before, after) {
|
|
13788
|
+
const unchanged = (m) => JSON.stringify([m.key, m.formatVersion, m.protocolName, m.protocolVersion, m.contractHash, m.codecRevision, m.catalogVersion, m.etag, m.sha256, m.rawSize, m.storedSize, m.objectId, m.retainUntil, m.stable, m.validated]);
|
|
13789
|
+
if (unchanged(before) !== unchanged(after))
|
|
13790
|
+
throw new Error("renewal changed immutable catalog identity");
|
|
13791
|
+
}
|
|
13792
|
+
var manifestSame = (a, b) => a.manifestId === b.manifestId;
|
|
13793
|
+
|
|
13794
|
+
class MemoryCatalogPublicationRepository {
|
|
13795
|
+
profile;
|
|
13796
|
+
storage;
|
|
13797
|
+
resolver;
|
|
13798
|
+
describe;
|
|
13799
|
+
manifests = new Map;
|
|
13800
|
+
constructor(profile, storage, resolver, describe) {
|
|
13801
|
+
this.profile = profile;
|
|
13802
|
+
this.storage = storage;
|
|
13803
|
+
this.resolver = resolver;
|
|
13804
|
+
this.describe = describe;
|
|
13805
|
+
}
|
|
13806
|
+
async lookup(key) {
|
|
13807
|
+
return this.manifests.get(key) ?? null;
|
|
13808
|
+
}
|
|
13809
|
+
async commitIfAbsent(manifest) {
|
|
13810
|
+
const existing = this.manifests.get(manifest.key);
|
|
13811
|
+
if (existing)
|
|
13812
|
+
return existing;
|
|
13813
|
+
const committed = Object.freeze({ ...manifest });
|
|
13814
|
+
this.manifests.set(manifest.key, committed);
|
|
13815
|
+
return committed;
|
|
13816
|
+
}
|
|
13817
|
+
async invalidate(key, expected) {
|
|
13818
|
+
const current = this.manifests.get(key);
|
|
13819
|
+
if (current && manifestSame(current, expected))
|
|
13820
|
+
this.manifests.delete(key);
|
|
13821
|
+
}
|
|
13822
|
+
}
|
|
13823
|
+
|
|
13824
|
+
class S3CatalogPublicationRepository {
|
|
13825
|
+
profile;
|
|
13826
|
+
storage;
|
|
13827
|
+
resolver;
|
|
13828
|
+
objects;
|
|
13829
|
+
describe;
|
|
13830
|
+
prefix;
|
|
13831
|
+
renewReference;
|
|
13832
|
+
constructor(profile, storage, resolver, objects, describe, prefix = "vgi/catalog-manifests/") {
|
|
13833
|
+
this.profile = profile;
|
|
13834
|
+
this.storage = storage;
|
|
13835
|
+
this.resolver = resolver;
|
|
13836
|
+
this.objects = objects;
|
|
13837
|
+
this.describe = describe;
|
|
13838
|
+
this.prefix = prefix;
|
|
13839
|
+
}
|
|
13840
|
+
objectKey(key) {
|
|
13841
|
+
if (!/^[0-9a-f]{64}$/.test(key))
|
|
13842
|
+
throw new Error("invalid publication key");
|
|
13843
|
+
return `${this.prefix}${key}.json`;
|
|
13844
|
+
}
|
|
13845
|
+
async lookup(key) {
|
|
13846
|
+
const value = await this.objects.get(this.objectKey(key));
|
|
13847
|
+
if (!value)
|
|
13848
|
+
return null;
|
|
13849
|
+
if (value.body.byteLength > 64 * 1024)
|
|
13850
|
+
throw new Error("catalog manifest exceeds 64 KiB");
|
|
13851
|
+
return JSON.parse(new TextDecoder().decode(value.body));
|
|
13852
|
+
}
|
|
13853
|
+
async commitIfAbsent(manifest) {
|
|
13854
|
+
const stored = await this.objects.put(this.objectKey(manifest.key), utf83.encode(JSON.stringify(manifest)), { ifNoneMatch: "*" });
|
|
13855
|
+
if (stored)
|
|
13856
|
+
return manifest;
|
|
13857
|
+
const current = await this.lookup(manifest.key);
|
|
13858
|
+
if (!current)
|
|
13859
|
+
throw new Error("catalog manifest changed during commit");
|
|
13860
|
+
return current;
|
|
13861
|
+
}
|
|
13862
|
+
async renew(manifest) {
|
|
13863
|
+
if (!this.renewReference)
|
|
13864
|
+
return null;
|
|
13865
|
+
const current = await this.objects.get(this.objectKey(manifest.key));
|
|
13866
|
+
if (!current)
|
|
13867
|
+
return null;
|
|
13868
|
+
const existing = JSON.parse(new TextDecoder().decode(current.body));
|
|
13869
|
+
if (!manifestSame(existing, manifest))
|
|
13870
|
+
return existing;
|
|
13871
|
+
const renewed = await this.renewReference(manifest);
|
|
13872
|
+
if (!renewed)
|
|
13873
|
+
return null;
|
|
13874
|
+
assertRenewedPublication(manifest, renewed);
|
|
13875
|
+
if (await this.objects.put(this.objectKey(manifest.key), utf83.encode(JSON.stringify(renewed)), { ifMatch: current.etag }))
|
|
13876
|
+
return renewed;
|
|
13877
|
+
return this.lookup(manifest.key);
|
|
13878
|
+
}
|
|
13879
|
+
async invalidate(key, expected) {
|
|
13880
|
+
const current = await this.objects.get(this.objectKey(key));
|
|
13881
|
+
if (current && manifestSame(JSON.parse(new TextDecoder().decode(current.body)), expected)) {
|
|
13882
|
+
await this.objects.delete(this.objectKey(key), { ifMatch: current.etag });
|
|
13883
|
+
}
|
|
13884
|
+
}
|
|
13885
|
+
}
|
|
13886
|
+
|
|
13887
|
+
class CatalogSnapshotManager {
|
|
13888
|
+
policy;
|
|
13889
|
+
cached = new Map;
|
|
13890
|
+
pending = new Map;
|
|
13891
|
+
constructor(policy) {
|
|
13892
|
+
this.policy = policy;
|
|
13893
|
+
for (const value of [policy.maxRawBytes, policy.maxStoredBytes, policy.maxCachedManifests]) {
|
|
13894
|
+
if (value != null && (!Number.isSafeInteger(value) || value <= 0))
|
|
13895
|
+
throw new Error("catalog publication limits must be positive safe integers");
|
|
13896
|
+
}
|
|
13897
|
+
if (policy.referenceGraceMs != null && (!Number.isSafeInteger(policy.referenceGraceMs) || policy.referenceGraceMs < 0))
|
|
13898
|
+
throw new Error("catalog publication reference grace must be a nonnegative safe integer");
|
|
13899
|
+
}
|
|
13900
|
+
usable(m) {
|
|
13901
|
+
const deadline = Date.now() + (this.policy.referenceGraceMs ?? 60000);
|
|
13902
|
+
return (m.stable || m.expiresAt != null) && (m.expiresAt == null || m.expiresAt > deadline) && (m.retainUntil == null || m.retainUntil > deadline);
|
|
13903
|
+
}
|
|
13904
|
+
async key(identity) {
|
|
13905
|
+
for (const value of [identity.catalogNamespace, identity.sourceRevision, identity.visibilityScope])
|
|
13906
|
+
if (!value)
|
|
13907
|
+
throw new Error("published catalogs require explicit namespace, revision and visibility scope");
|
|
13908
|
+
if (!Number.isSafeInteger(identity.catalogVersion))
|
|
13909
|
+
throw new Error("catalog version is not a safe integer");
|
|
13910
|
+
return digest(JSON.stringify([
|
|
13911
|
+
VGI_PROTOCOL_NAME,
|
|
13912
|
+
VGI_PROTOCOL_VERSION,
|
|
13913
|
+
VGI_CATALOG_CONTRACT_HASH,
|
|
13914
|
+
1,
|
|
13915
|
+
identity.catalogNamespace,
|
|
13916
|
+
identity.sourceRevision,
|
|
13917
|
+
identity.visibilityScope,
|
|
13918
|
+
identity.catalogVersion,
|
|
13919
|
+
this.policy.repository.profile,
|
|
13920
|
+
this.policy.compression ?? "identity"
|
|
13921
|
+
]));
|
|
13922
|
+
}
|
|
13923
|
+
remember(m) {
|
|
13924
|
+
this.cached.delete(m.key);
|
|
13925
|
+
this.cached.set(m.key, Object.freeze({ ...m }));
|
|
13926
|
+
while (this.cached.size > (this.policy.maxCachedManifests ?? 128))
|
|
13927
|
+
this.cached.delete(this.cached.keys().next().value);
|
|
13928
|
+
}
|
|
13929
|
+
async invalidate(key) {
|
|
13930
|
+
await this.pending.get(key)?.catch(() => {
|
|
13931
|
+
return;
|
|
13932
|
+
});
|
|
13933
|
+
const m = this.cached.get(key) ?? await this.policy.repository.lookup(key);
|
|
13934
|
+
this.cached.delete(key);
|
|
13935
|
+
if (m)
|
|
13936
|
+
await this.policy.repository.invalidate(key, m);
|
|
13937
|
+
}
|
|
13938
|
+
async validate(m, key, identity, expected) {
|
|
13939
|
+
if (m.formatVersion !== 1 || typeof m.manifestId !== "string" || !m.manifestId || m.key !== key || m.protocolName !== VGI_PROTOCOL_NAME || m.protocolVersion !== VGI_PROTOCOL_VERSION || m.contractHash !== VGI_CATALOG_CONTRACT_HASH || m.codecRevision !== 1 || m.catalogVersion !== identity.catalogVersion || m.validated !== true || typeof m.stable !== "boolean" || typeof m.etag !== "string" || !/^[0-9a-f]{64}$/.test(m.sha256) || !Number.isSafeInteger(m.rawSize) || !Number.isSafeInteger(m.storedSize) || m.rawSize <= 0 || m.storedSize <= 0 || m.rawSize > (this.policy.maxRawBytes ?? DEFAULT_MAX) || m.storedSize > (this.policy.maxStoredBytes ?? DEFAULT_MAX) || !this.usable(m))
|
|
13940
|
+
throw new Error("invalid or expired catalog publication manifest");
|
|
13941
|
+
const ref = new ExternalRef(m.url, m.sha256);
|
|
13942
|
+
const configuredFetch = this.policy.repository.resolver.fetch ?? fetch;
|
|
13943
|
+
const resolved = await resolveExternalLocation(ref.pointerBatch(OUTER_SCHEMA), {
|
|
13944
|
+
...this.policy.repository.resolver,
|
|
13945
|
+
fetch: (input, init) => configuredFetch(input, { ...init, signal: AbortSignal.any([...init?.signal ? [init.signal] : [], AbortSignal.timeout(30000)]) }),
|
|
13946
|
+
maxFetchBytes: Math.min(this.policy.maxStoredBytes ?? DEFAULT_MAX, this.policy.repository.resolver.maxFetchBytes ?? Infinity),
|
|
13947
|
+
maxDecompressedBytes: Math.min(this.policy.maxRawBytes ?? DEFAULT_MAX, this.policy.repository.resolver.maxDecompressedBytes ?? Infinity),
|
|
13948
|
+
validateFetchedIpc: (bytes) => {
|
|
13949
|
+
this.policy.repository.resolver.validateFetchedIpc?.(bytes);
|
|
13950
|
+
if (bytes.length !== m.rawSize)
|
|
13951
|
+
throw new Error("catalog publication raw size mismatch");
|
|
13952
|
+
validateCatalogPublicationEnvelope(bytes);
|
|
13953
|
+
}
|
|
13954
|
+
});
|
|
13955
|
+
if (resolved.numRows !== 1 || resolved.schema.fields.length !== 1 || resolved.schema.fields[0].name !== "result" || typeSignature(resolved.schema.fields[0].type) !== typeSignature(binary2()) || resolved.schema.fields[0].nullable)
|
|
13956
|
+
throw new Error("invalid published RPC envelope");
|
|
13957
|
+
const bytes = resolved.getChild("result")?.get(0);
|
|
13958
|
+
if (!(bytes instanceof Uint8Array))
|
|
13959
|
+
throw new Error("published catalog has no result bytes");
|
|
13960
|
+
const decoded = decodeASDCollection(CatalogContentsResultSchema, bytes);
|
|
13961
|
+
if (decoded.length !== 1)
|
|
13962
|
+
throw new Error("published catalog must contain exactly one response row");
|
|
13963
|
+
const response = decoded[0];
|
|
13964
|
+
if (response.not_modified || Number(response.catalog_version) !== identity.catalogVersion || response.etag !== m.etag)
|
|
13965
|
+
throw new Error("published catalog version or ETag mismatch");
|
|
13966
|
+
decodeCatalogStreams(response);
|
|
13967
|
+
if (expected)
|
|
13968
|
+
for (const kind of CATALOG_STREAM_KINDS) {
|
|
13969
|
+
const a = response[kind], b = expected[kind];
|
|
13970
|
+
if (a == null !== (b == null) || a != null && b != null && !equalBytes3(a, b))
|
|
13971
|
+
throw new Error("publication readback changed catalog metadata");
|
|
13972
|
+
}
|
|
13973
|
+
}
|
|
13974
|
+
async import(manifest, identity) {
|
|
13975
|
+
const key = await this.key(identity);
|
|
13976
|
+
await this.validate(manifest, key, identity);
|
|
13977
|
+
const winner = await this.policy.repository.commitIfAbsent(manifest);
|
|
13978
|
+
if (!manifestSame(manifest, winner))
|
|
13979
|
+
await this.validate(winner, key, identity);
|
|
13980
|
+
this.remember(winner);
|
|
13981
|
+
return winner;
|
|
13982
|
+
}
|
|
13983
|
+
async warm(identity, build) {
|
|
13984
|
+
const key = await this.key(identity);
|
|
13985
|
+
const cached = this.cached.get(key);
|
|
13986
|
+
if (cached && this.usable(cached))
|
|
13987
|
+
return cached;
|
|
13988
|
+
const active = this.pending.get(key);
|
|
13989
|
+
if (active)
|
|
13990
|
+
return active;
|
|
13991
|
+
const pending = this.recoverOrPublish(key, identity, build);
|
|
13992
|
+
this.pending.set(key, pending);
|
|
13993
|
+
try {
|
|
13994
|
+
const m = await pending;
|
|
13995
|
+
this.remember(m);
|
|
13996
|
+
return m;
|
|
13997
|
+
} finally {
|
|
13998
|
+
if (this.pending.get(key) === pending)
|
|
13999
|
+
this.pending.delete(key);
|
|
14000
|
+
}
|
|
14001
|
+
}
|
|
14002
|
+
async recoverOrPublish(key, identity, build) {
|
|
14003
|
+
const repository = this.policy.repository;
|
|
14004
|
+
let existing = await repository.lookup(key);
|
|
14005
|
+
if (existing) {
|
|
14006
|
+
try {
|
|
14007
|
+
if (!this.usable(existing) && repository.renew) {
|
|
14008
|
+
const renewed = await repository.renew(existing);
|
|
14009
|
+
if (renewed) {
|
|
14010
|
+
assertRenewedPublication(existing, renewed);
|
|
14011
|
+
existing = renewed;
|
|
14012
|
+
}
|
|
14013
|
+
}
|
|
14014
|
+
await this.validate(existing, key, identity);
|
|
14015
|
+
return existing;
|
|
14016
|
+
} catch {
|
|
14017
|
+
await repository.invalidate(key, existing);
|
|
14018
|
+
}
|
|
14019
|
+
}
|
|
14020
|
+
const response = await build();
|
|
14021
|
+
if (response.not_modified || Number(response.catalog_version) !== identity.catalogVersion)
|
|
14022
|
+
throw new Error("publication requires a full snapshot of the requested version");
|
|
14023
|
+
decodeCatalogStreams(response);
|
|
14024
|
+
response.etag ??= await catalogContentsDigest(response, identity.catalogVersion);
|
|
14025
|
+
const payload = encodeASD(CatalogContentsResultSchema, response);
|
|
14026
|
+
let rawSize = 0, storedSize = 0;
|
|
14027
|
+
const bounded = { upload: async (data, encoding) => {
|
|
14028
|
+
if (encoding)
|
|
14029
|
+
throw new Error("catalog publication uploader requires identity encoding");
|
|
14030
|
+
rawSize = data.byteLength;
|
|
14031
|
+
if (rawSize > (this.policy.maxRawBytes ?? DEFAULT_MAX))
|
|
14032
|
+
throw new Error("catalog publication exceeds byte limit");
|
|
14033
|
+
let body = data;
|
|
14034
|
+
const compression = this.policy.compression ?? "identity";
|
|
14035
|
+
if (compression !== "identity" && compression !== "gzip" && compression !== "zstd")
|
|
14036
|
+
throw new Error("catalog publication compression must be identity, gzip or zstd");
|
|
14037
|
+
if (compression === "gzip") {
|
|
14038
|
+
body = new Uint8Array(await new Response(new Blob([data]).stream().pipeThrough(new CompressionStream("gzip"))).arrayBuffer());
|
|
14039
|
+
} else if (compression === "zstd") {
|
|
14040
|
+
const runtime = globalThis.Bun;
|
|
14041
|
+
if (typeof runtime?.zstdCompress === "function") {
|
|
14042
|
+
body = new Uint8Array(await runtime.zstdCompress(data));
|
|
14043
|
+
} else if (typeof process !== "undefined" && process.versions?.node) {
|
|
14044
|
+
const nodeZlib = "node:zlib";
|
|
14045
|
+
const zlib = await import(nodeZlib);
|
|
14046
|
+
if (typeof zlib.zstdCompressSync !== "function")
|
|
14047
|
+
throw new Error("zstd catalog publication requires Node >=22.15, Bun, or an encoder-capable runtime");
|
|
14048
|
+
body = new Uint8Array(zlib.zstdCompressSync(data));
|
|
14049
|
+
} else {
|
|
14050
|
+
throw new Error("zstd catalog publication requires an encoder-capable runtime; use gzip or identity here");
|
|
14051
|
+
}
|
|
14052
|
+
}
|
|
14053
|
+
storedSize = body.byteLength;
|
|
14054
|
+
if (storedSize > (this.policy.maxStoredBytes ?? DEFAULT_MAX))
|
|
14055
|
+
throw new Error("catalog publication exceeds byte limit");
|
|
14056
|
+
return repository.storage.upload(body, compression === "identity" ? "" : compression);
|
|
14057
|
+
} };
|
|
14058
|
+
const ref = await publishExternalResult(OUTER_SCHEMA, { result: payload }, bounded, { includeSha256: true });
|
|
14059
|
+
const m = {
|
|
14060
|
+
formatVersion: 1,
|
|
14061
|
+
manifestId: crypto.randomUUID(),
|
|
14062
|
+
key,
|
|
14063
|
+
protocolName: VGI_PROTOCOL_NAME,
|
|
14064
|
+
protocolVersion: VGI_PROTOCOL_VERSION,
|
|
14065
|
+
contractHash: VGI_CATALOG_CONTRACT_HASH,
|
|
14066
|
+
codecRevision: 1,
|
|
14067
|
+
catalogVersion: identity.catalogVersion,
|
|
14068
|
+
etag: response.etag,
|
|
14069
|
+
sha256: ref.sha256,
|
|
14070
|
+
rawSize,
|
|
14071
|
+
storedSize,
|
|
14072
|
+
url: ref.url,
|
|
14073
|
+
validated: true,
|
|
14074
|
+
...await repository.describe(ref.url)
|
|
14075
|
+
};
|
|
14076
|
+
await this.validate(m, key, identity, response);
|
|
14077
|
+
const winner = await repository.commitIfAbsent(m);
|
|
14078
|
+
if (!manifestSame(m, winner))
|
|
14079
|
+
await this.validate(winner, key, identity);
|
|
14080
|
+
return winner;
|
|
14081
|
+
}
|
|
14082
|
+
}
|
|
14083
|
+
|
|
13410
14084
|
// src/protocol/handlers/catalog/contents.ts
|
|
14085
|
+
var schemaPathKey3 = (path) => JSON.stringify(path.map((part) => part.toLowerCase()));
|
|
14086
|
+
var PUBLICATIONS = new WeakMap;
|
|
13411
14087
|
var CACHE = new WeakMap;
|
|
13412
14088
|
async function buildCatalogContents(cat, owner, attach, version, ifNoneMatch) {
|
|
13413
14089
|
const result = await cat.catalogContents(attach, ifNoneMatch);
|
|
@@ -13422,39 +14098,74 @@ async function buildCatalogContents(cat, owner, attach, version, ifNoneMatch) {
|
|
|
13422
14098
|
return buildCatalogContentsResponse({ catalog_version: version, etag: etag0, not_modified: true });
|
|
13423
14099
|
}
|
|
13424
14100
|
const infos = [...result.schemas ?? []];
|
|
13425
|
-
const keys = infos.map((c) =>
|
|
14101
|
+
const keys = infos.map((c) => schemaPathKey3(c.schema.path));
|
|
13426
14102
|
const keySet = new Set(keys);
|
|
13427
14103
|
if (keySet.size !== keys.length)
|
|
13428
14104
|
throw new Error("catalog_contents returned duplicate schema paths");
|
|
13429
14105
|
for (const c of infos) {
|
|
13430
|
-
if (c.schema.path.length > 1 && !keySet.has(
|
|
14106
|
+
if (c.schema.path.length > 1 && !keySet.has(schemaPathKey3(c.schema.path.slice(0, -1)))) {
|
|
13431
14107
|
throw new Error(`catalog_contents returned schema path ${JSON.stringify(c.schema.path)} without its parent`);
|
|
13432
14108
|
}
|
|
13433
14109
|
}
|
|
13434
|
-
const
|
|
13435
|
-
path: [...c.schema.path],
|
|
13436
|
-
schema: encodeSchemaInfo(c.schema),
|
|
13437
|
-
tables: c.tables.map((t) => encodeTableInfo(t)),
|
|
13438
|
-
views: c.views.map((v) => encodeViewInfo(v)),
|
|
13439
|
-
scalar_functions: c.scalar_functions.map((f) => encodeFunctionInfoOnce(f)),
|
|
13440
|
-
aggregate_functions: c.aggregate_functions.map((f) => encodeFunctionInfoOnce(f)),
|
|
13441
|
-
table_functions: c.table_functions.map((f) => encodeFunctionInfoOnce(f)),
|
|
13442
|
-
scalar_macros: c.scalar_macros.map((m) => encodeMacroInfo(m)),
|
|
13443
|
-
table_macros: c.table_macros.map((m) => encodeMacroInfo(m)),
|
|
13444
|
-
indexes: c.indexes.map((i) => encodeIndexInfo(i))
|
|
13445
|
-
}));
|
|
14110
|
+
const streams = encodeCatalogStreams(infos.sort((a, b) => a.schema.path.length - b.schema.path.length));
|
|
13446
14111
|
let etag = etag0;
|
|
13447
14112
|
if (etag === null && owner.catalogContentsEtag === "content-hash") {
|
|
13448
|
-
etag = await catalogContentsDigest(
|
|
14113
|
+
etag = await catalogContentsDigest(streams, version);
|
|
13449
14114
|
}
|
|
13450
14115
|
if (etag !== null && ifNoneMatch !== null && etag === ifNoneMatch) {
|
|
13451
14116
|
return buildCatalogContentsResponse({ catalog_version: version, etag, not_modified: true });
|
|
13452
14117
|
}
|
|
13453
|
-
|
|
14118
|
+
const response = buildCatalogContentsResponse({ catalog_version: version, etag, ...streams });
|
|
14119
|
+
decodeCatalogStreams(response);
|
|
14120
|
+
return response;
|
|
13454
14121
|
}
|
|
13455
|
-
async function serveCatalogContents(cat, attach, ifNoneMatch) {
|
|
14122
|
+
async function serveCatalogContents(cat, attach, ifNoneMatch, callContext, sealedAttach = attach) {
|
|
13456
14123
|
const owner = cat.catalogContentsOwner(attach);
|
|
13457
14124
|
const version = Number(await cat.version(attach));
|
|
14125
|
+
const policy = owner.catalogSnapshotPolicy;
|
|
14126
|
+
if (policy?.delivery === "published") {
|
|
14127
|
+
const request = { catalog: cat, attachOpaqueData: attach, callContext, catalogVersion: version };
|
|
14128
|
+
const inline = (etag) => wrapResult(buildCatalogContentsResponse({ catalog_version: version, etag, not_modified: true }), CatalogContentsResultSchema);
|
|
14129
|
+
const cheapEtag = await policy.etag?.(request);
|
|
14130
|
+
if (cheapEtag != null && cheapEtag === ifNoneMatch)
|
|
14131
|
+
return inline(cheapEtag);
|
|
14132
|
+
let manager = PUBLICATIONS.get(policy);
|
|
14133
|
+
if (!manager) {
|
|
14134
|
+
manager = new CatalogSnapshotManager(policy);
|
|
14135
|
+
PUBLICATIONS.set(policy, manager);
|
|
14136
|
+
}
|
|
14137
|
+
const scopeBytes = new Uint8Array(await crypto.subtle.digest("SHA-256", sealedAttach));
|
|
14138
|
+
const attachmentScope = "attachment:" + Array.from(scopeBytes, (b) => b.toString(16).padStart(2, "0")).join("");
|
|
14139
|
+
const identify = async (input) => {
|
|
14140
|
+
const id = await policy.identity(input);
|
|
14141
|
+
return { ...id, visibilityScope: id.visibilityScope ?? attachmentScope };
|
|
14142
|
+
};
|
|
14143
|
+
const identity = await identify(request);
|
|
14144
|
+
if (identity.catalogVersion !== version)
|
|
14145
|
+
throw new Error("snapshot identity version differs from the attached catalog");
|
|
14146
|
+
const assertCurrentIdentity = async () => {
|
|
14147
|
+
const currentVersion = Number(await cat.version(attach));
|
|
14148
|
+
const current = await identify({ ...request, catalogVersion: currentVersion });
|
|
14149
|
+
if (currentVersion !== version || await manager.key(identity) !== await manager.key(current))
|
|
14150
|
+
throw new Error("catalog changed while resolving its publication");
|
|
14151
|
+
};
|
|
14152
|
+
const buildSnapshot = async (validator) => {
|
|
14153
|
+
const response = await buildCatalogContents(cat, owner, attach, version, validator);
|
|
14154
|
+
await assertCurrentIdentity();
|
|
14155
|
+
return response;
|
|
14156
|
+
};
|
|
14157
|
+
try {
|
|
14158
|
+
const manifest = await manager.warm(identity, () => buildSnapshot(null));
|
|
14159
|
+
await assertCurrentIdentity();
|
|
14160
|
+
if (manifest.etag === ifNoneMatch)
|
|
14161
|
+
return inline(manifest.etag);
|
|
14162
|
+
return new ExternalRef2(manifest.url, manifest.sha256);
|
|
14163
|
+
} catch (error) {
|
|
14164
|
+
if (policy.onPublicationFailure !== "ordinary")
|
|
14165
|
+
throw error;
|
|
14166
|
+
return wrapResult(await buildSnapshot(ifNoneMatch), CatalogContentsResultSchema);
|
|
14167
|
+
}
|
|
14168
|
+
}
|
|
13458
14169
|
if (owner.catalogContentsCacheable()) {
|
|
13459
14170
|
let pending = CACHE.get(owner);
|
|
13460
14171
|
let snapshot = pending ? await pending.catch(() => null) : null;
|
|
@@ -13966,10 +14677,13 @@ function catalogAdminHandlers(getCatalog, signingKey) {
|
|
|
13966
14677
|
items: schemas.map((s) => encodeSchemaInfo(s))
|
|
13967
14678
|
}, CatalogSchemasResultSchema);
|
|
13968
14679
|
});
|
|
13969
|
-
const catalogContents =
|
|
13970
|
-
const
|
|
13971
|
-
return
|
|
13972
|
-
|
|
14680
|
+
const catalogContents = async (params, ctx) => {
|
|
14681
|
+
const sealedAttach = toUint8Array(params.attach_opaque_data).slice();
|
|
14682
|
+
return catalogHandler(signingKey, async (opened, context) => {
|
|
14683
|
+
const ifNoneMatch = opened.if_none_match == null ? null : String(opened.if_none_match);
|
|
14684
|
+
return serveCatalogContents(getCatalog(), toUint8Array(opened.attach_opaque_data), ifNoneMatch, context, sealedAttach);
|
|
14685
|
+
})(params, ctx);
|
|
14686
|
+
};
|
|
13973
14687
|
const catalogCopyFromFormats = catalogHandler(signingKey, async (params) => {
|
|
13974
14688
|
const cat = getCatalog();
|
|
13975
14689
|
const formats = await cat.copyFromFormats(toUint8Array(params.attach_opaque_data), params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
|
|
@@ -14563,6 +15277,42 @@ function toAsyncIterator(input) {
|
|
|
14563
15277
|
function onConflictName(onConflict) {
|
|
14564
15278
|
return String(onConflict).toUpperCase();
|
|
14565
15279
|
}
|
|
15280
|
+
function isNotModified(md) {
|
|
15281
|
+
const v = md.get(CACHE_NOT_MODIFIED_KEY);
|
|
15282
|
+
return v != null && v !== "0" && v.toLowerCase() !== "false";
|
|
15283
|
+
}
|
|
15284
|
+
async function* exchangeContinued(session, functionName, input) {
|
|
15285
|
+
const raw = session;
|
|
15286
|
+
if (typeof raw.exchangeRaw !== "function") {
|
|
15287
|
+
throw new VgiClientError(`tableInOutFunction(${functionName}): the transport's stream session has no exchangeRaw(), ` + `which continued output needs to read each reply's vgi.status`);
|
|
15288
|
+
}
|
|
15289
|
+
const exchangeRaw = raw.exchangeRaw.bind(session);
|
|
15290
|
+
let tick = false;
|
|
15291
|
+
let reply = await exchangeRaw({ batch: input, metadata: new Map });
|
|
15292
|
+
for (;; ) {
|
|
15293
|
+
if (reply === null) {
|
|
15294
|
+
if (tick) {
|
|
15295
|
+
throw new VgiClientError(`tableInOutFunction(${functionName}): the worker ended the stream while output was pending`);
|
|
15296
|
+
}
|
|
15297
|
+
return;
|
|
15298
|
+
}
|
|
15299
|
+
const md = new Map([...reply.batch.metadata ?? [], ...reply.metadata]);
|
|
15300
|
+
const more = md.get(STATUS_KEY) === HAVE_MORE_OUTPUT;
|
|
15301
|
+
if (isNotModified(md) && (more || tick)) {
|
|
15302
|
+
throw new VgiClientError(`tableInOutFunction(${functionName}): the worker answered not_modified on a continued reply ` + `(${tick ? "answering a continuation tick" : "one saying HAVE_MORE_OUTPUT"}); ` + `not_modified must be an input's only reply`);
|
|
15303
|
+
}
|
|
15304
|
+
const rows = [...iterRows(reply.batch)];
|
|
15305
|
+
if (rows.length > 0)
|
|
15306
|
+
yield rows;
|
|
15307
|
+
if (!more)
|
|
15308
|
+
return;
|
|
15309
|
+
tick = true;
|
|
15310
|
+
reply = await exchangeRaw({
|
|
15311
|
+
batch: emptyBatch(input.schema),
|
|
15312
|
+
metadata: new Map([[STATUS_KEY, CONTINUE]])
|
|
15313
|
+
});
|
|
15314
|
+
}
|
|
15315
|
+
}
|
|
14566
15316
|
|
|
14567
15317
|
class VgiClient {
|
|
14568
15318
|
rpc;
|
|
@@ -14727,13 +15477,9 @@ class VgiClient {
|
|
|
14727
15477
|
joinKeys: opts.joinKeys
|
|
14728
15478
|
});
|
|
14729
15479
|
try {
|
|
14730
|
-
|
|
14731
|
-
if (outRows.length > 0)
|
|
14732
|
-
yield outRows;
|
|
15480
|
+
yield* exchangeContinued(inputSession, opts.functionName, firstBatch);
|
|
14733
15481
|
for await (const batch of { [Symbol.asyncIterator]: () => inputIter }) {
|
|
14734
|
-
|
|
14735
|
-
if (result.length > 0)
|
|
14736
|
-
yield result;
|
|
15482
|
+
yield* exchangeContinued(inputSession, opts.functionName, batch);
|
|
14737
15483
|
}
|
|
14738
15484
|
} finally {
|
|
14739
15485
|
inputSession.close();
|
|
@@ -14778,13 +15524,13 @@ class VgiClient {
|
|
|
14778
15524
|
});
|
|
14779
15525
|
const outputSchema = bindResp.output_schema;
|
|
14780
15526
|
try {
|
|
14781
|
-
const
|
|
14782
|
-
|
|
14783
|
-
|
|
15527
|
+
for await (const rows of exchangeContinued(inputSession, opts.functionName, firstBatch)) {
|
|
15528
|
+
yield batchFromRows(rows, outputSchema);
|
|
15529
|
+
}
|
|
14784
15530
|
for await (const batch of { [Symbol.asyncIterator]: () => inputIter }) {
|
|
14785
|
-
const
|
|
14786
|
-
|
|
14787
|
-
|
|
15531
|
+
for await (const rows of exchangeContinued(inputSession, opts.functionName, batch)) {
|
|
15532
|
+
yield batchFromRows(rows, outputSchema);
|
|
15533
|
+
}
|
|
14788
15534
|
}
|
|
14789
15535
|
} finally {
|
|
14790
15536
|
inputSession.close();
|
|
@@ -14896,23 +15642,7 @@ class VgiClient {
|
|
|
14896
15642
|
if (!result)
|
|
14897
15643
|
throw new VgiClientError("catalog_contents returned null");
|
|
14898
15644
|
const response = decodeCatalogContentsResponse(toUint8Array(result.result));
|
|
14899
|
-
const schemas = response
|
|
14900
|
-
const schema = decodeSchemaInfo(c.schema);
|
|
14901
|
-
if (JSON.stringify(c.path) !== JSON.stringify(schema.path)) {
|
|
14902
|
-
throw new VgiClientError(`catalog_contents: SchemaContents.path ${JSON.stringify(c.path)} != SchemaInfo.path ${JSON.stringify(schema.path)}`);
|
|
14903
|
-
}
|
|
14904
|
-
return {
|
|
14905
|
-
schema,
|
|
14906
|
-
tables: c.tables.map(decodeTableInfo),
|
|
14907
|
-
views: c.views.map(decodeViewInfo),
|
|
14908
|
-
scalar_functions: c.scalar_functions.map(decodeFunctionInfo),
|
|
14909
|
-
aggregate_functions: c.aggregate_functions.map(decodeFunctionInfo),
|
|
14910
|
-
table_functions: c.table_functions.map(decodeFunctionInfo),
|
|
14911
|
-
scalar_macros: c.scalar_macros.map(decodeMacroInfo),
|
|
14912
|
-
table_macros: c.table_macros.map(decodeMacroInfo),
|
|
14913
|
-
indexes: c.indexes.map(decodeIndexInfo)
|
|
14914
|
-
};
|
|
14915
|
-
});
|
|
15645
|
+
const schemas = decodeCatalogStreams(response, ifNoneMatch);
|
|
14916
15646
|
return {
|
|
14917
15647
|
catalog_version: Number(response.catalog_version ?? 0),
|
|
14918
15648
|
etag: response.etag ?? null,
|
|
@@ -15741,6 +16471,111 @@ ${err.stack}
|
|
|
15741
16471
|
await serveStreamRpc(this.buildServer(this.buildProtocol(), "stream"), { readable, writable });
|
|
15742
16472
|
}
|
|
15743
16473
|
}
|
|
16474
|
+
// src/catalog/s3-publication.ts
|
|
16475
|
+
class S3CatalogObjectStorage {
|
|
16476
|
+
sign;
|
|
16477
|
+
request;
|
|
16478
|
+
objectPrefix;
|
|
16479
|
+
retentionMs;
|
|
16480
|
+
locations = new Map;
|
|
16481
|
+
constructor(sign, request = fetch, objectPrefix = "vgi/catalog-results/", retentionMs) {
|
|
16482
|
+
this.sign = sign;
|
|
16483
|
+
this.request = request;
|
|
16484
|
+
this.objectPrefix = objectPrefix;
|
|
16485
|
+
this.retentionMs = retentionMs;
|
|
16486
|
+
}
|
|
16487
|
+
async upload(data, contentEncoding) {
|
|
16488
|
+
const key = `${this.objectPrefix}${crypto.randomUUID()}.arrow`;
|
|
16489
|
+
const headers = { "Content-Type": "application/vnd.apache.arrow.stream", "If-None-Match": "*" };
|
|
16490
|
+
if (contentEncoding)
|
|
16491
|
+
headers["Content-Encoding"] = contentEncoding;
|
|
16492
|
+
const put = await this.sign({ key, method: "PUT", headers });
|
|
16493
|
+
const response = await this.request(put.url, { method: "PUT", headers, body: data, redirect: "error", signal: AbortSignal.timeout(30000) });
|
|
16494
|
+
if (!response.ok)
|
|
16495
|
+
throw new Error(`catalog object upload failed (${response.status})`);
|
|
16496
|
+
const get = await this.sign({ key, method: "GET", headers: {} });
|
|
16497
|
+
if (!get.stable && get.expiresAt == null)
|
|
16498
|
+
throw new Error("S3 catalog signer must declare GET URL expiration or stability");
|
|
16499
|
+
this.locations.set(get.url, {
|
|
16500
|
+
objectId: key,
|
|
16501
|
+
expiresAt: get.expiresAt,
|
|
16502
|
+
stable: get.stable ?? false,
|
|
16503
|
+
retainUntil: this.retentionMs == null ? undefined : Date.now() + this.retentionMs
|
|
16504
|
+
});
|
|
16505
|
+
return get.url;
|
|
16506
|
+
}
|
|
16507
|
+
async describe(url) {
|
|
16508
|
+
const value = this.locations.get(url);
|
|
16509
|
+
if (!value)
|
|
16510
|
+
throw new Error("unknown catalog object location");
|
|
16511
|
+
this.locations.delete(url);
|
|
16512
|
+
return value;
|
|
16513
|
+
}
|
|
16514
|
+
async get(key) {
|
|
16515
|
+
const signed = await this.sign({ key, method: "GET", headers: {} });
|
|
16516
|
+
const response = await this.request(signed.url, { redirect: "error", signal: AbortSignal.timeout(30000) });
|
|
16517
|
+
if (response.status === 404)
|
|
16518
|
+
return null;
|
|
16519
|
+
if (!response.ok)
|
|
16520
|
+
throw new Error(`catalog manifest GET failed (${response.status})`);
|
|
16521
|
+
const etag = response.headers.get("etag");
|
|
16522
|
+
if (!etag)
|
|
16523
|
+
throw new Error("S3 catalog manifest lacks conditional-operation ETag");
|
|
16524
|
+
const reader = response.body?.getReader();
|
|
16525
|
+
if (!reader)
|
|
16526
|
+
throw new Error("empty catalog manifest body");
|
|
16527
|
+
let size = 0;
|
|
16528
|
+
const parts = [];
|
|
16529
|
+
while (true) {
|
|
16530
|
+
const { done, value } = await reader.read();
|
|
16531
|
+
if (done)
|
|
16532
|
+
break;
|
|
16533
|
+
size += value.byteLength;
|
|
16534
|
+
if (size > 64 * 1024) {
|
|
16535
|
+
await reader.cancel();
|
|
16536
|
+
throw new Error("catalog manifest exceeds 64 KiB");
|
|
16537
|
+
}
|
|
16538
|
+
parts.push(value);
|
|
16539
|
+
}
|
|
16540
|
+
const body = new Uint8Array(size);
|
|
16541
|
+
let offset = 0;
|
|
16542
|
+
for (const part of parts) {
|
|
16543
|
+
body.set(part, offset);
|
|
16544
|
+
offset += part.byteLength;
|
|
16545
|
+
}
|
|
16546
|
+
return { body, etag };
|
|
16547
|
+
}
|
|
16548
|
+
async put(key, body, condition) {
|
|
16549
|
+
const headers = { "Content-Type": "application/json", ..."ifNoneMatch" in condition ? { "If-None-Match": condition.ifNoneMatch } : { "If-Match": condition.ifMatch } };
|
|
16550
|
+
const signed = await this.sign({ key, method: "PUT", headers });
|
|
16551
|
+
const response = await this.request(signed.url, { method: "PUT", headers, body, redirect: "error", signal: AbortSignal.timeout(30000) });
|
|
16552
|
+
if (response.status === 412 || response.status === 409)
|
|
16553
|
+
return false;
|
|
16554
|
+
if (!response.ok)
|
|
16555
|
+
throw new Error(`catalog manifest PUT failed (${response.status})`);
|
|
16556
|
+
return true;
|
|
16557
|
+
}
|
|
16558
|
+
async delete(key, condition) {
|
|
16559
|
+
const headers = { "If-Match": condition.ifMatch };
|
|
16560
|
+
const signed = await this.sign({ key, method: "DELETE", headers });
|
|
16561
|
+
const response = await this.request(signed.url, { method: "DELETE", headers, redirect: "error", signal: AbortSignal.timeout(30000) });
|
|
16562
|
+
if (response.status === 412 || response.status === 404)
|
|
16563
|
+
return false;
|
|
16564
|
+
if (!response.ok)
|
|
16565
|
+
throw new Error(`catalog manifest DELETE failed (${response.status})`);
|
|
16566
|
+
return true;
|
|
16567
|
+
}
|
|
16568
|
+
repository(profile, resolver = {}, manifestPrefix = "vgi/catalog-manifests/") {
|
|
16569
|
+
const repository = new S3CatalogPublicationRepository(profile, this, { ...resolver, storage: this }, this, (url) => this.describe(url), manifestPrefix);
|
|
16570
|
+
repository.renewReference = async (manifest) => {
|
|
16571
|
+
if (!manifest.objectId)
|
|
16572
|
+
return null;
|
|
16573
|
+
const signed = await this.sign({ key: manifest.objectId, method: "GET", headers: {} });
|
|
16574
|
+
return { ...manifest, manifestId: crypto.randomUUID(), url: signed.url, expiresAt: signed.expiresAt, stable: signed.stable ?? false };
|
|
16575
|
+
};
|
|
16576
|
+
return repository;
|
|
16577
|
+
}
|
|
16578
|
+
}
|
|
15744
16579
|
export {
|
|
15745
16580
|
ATTACH_TICKETS_PROTOCOL_NAME,
|
|
15746
16581
|
ATTACH_TICKETS_PROTOCOL_VERSION,
|
|
@@ -15773,11 +16608,13 @@ export {
|
|
|
15773
16608
|
CACHE_STALE_IF_ERROR_KEY,
|
|
15774
16609
|
CACHE_STALE_WHILE_REVALIDATE_KEY,
|
|
15775
16610
|
CACHE_TTL_KEY,
|
|
16611
|
+
CONTINUE,
|
|
15776
16612
|
CatalogAlreadyExistsError,
|
|
15777
16613
|
CatalogFunctionType,
|
|
15778
16614
|
CatalogInterface,
|
|
15779
16615
|
CatalogNotFoundError,
|
|
15780
16616
|
CatalogReadOnlyError,
|
|
16617
|
+
CatalogSnapshotManager,
|
|
15781
16618
|
ComparisonOp,
|
|
15782
16619
|
CompositeCatalogInterface,
|
|
15783
16620
|
DEFAULT_MAX_WORKERS,
|
|
@@ -15794,9 +16631,11 @@ export {
|
|
|
15794
16631
|
GROUP_COLUMN_NAME,
|
|
15795
16632
|
GrantKeys2 as GrantKeys,
|
|
15796
16633
|
GrantRefusedError,
|
|
16634
|
+
HAVE_MORE_OUTPUT,
|
|
15797
16635
|
INTROSPECT_PRINCIPALS_ENV,
|
|
15798
16636
|
IdentityUnavailableError,
|
|
15799
16637
|
IntervalUnit2 as IntervalUnit,
|
|
16638
|
+
MemoryCatalogPublicationRepository,
|
|
15800
16639
|
NoCatalogError,
|
|
15801
16640
|
NullHandling,
|
|
15802
16641
|
OrderDependence,
|
|
@@ -15809,7 +16648,10 @@ export {
|
|
|
15809
16648
|
ReadOnlyCatalogInterface,
|
|
15810
16649
|
ReservedAttachOptionError,
|
|
15811
16650
|
RowCountMismatchError,
|
|
16651
|
+
S3CatalogObjectStorage,
|
|
16652
|
+
S3CatalogPublicationRepository,
|
|
15812
16653
|
SEAL_ATTACH_REQUEST_SCHEMA,
|
|
16654
|
+
STATUS_KEY,
|
|
15813
16655
|
ScanFunctionResultSchema,
|
|
15814
16656
|
SealAttachDeniedError,
|
|
15815
16657
|
StatusError,
|
|
@@ -15957,6 +16799,7 @@ export {
|
|
|
15957
16799
|
map2 as map,
|
|
15958
16800
|
metadatasToArrow,
|
|
15959
16801
|
mintAttachTicket,
|
|
16802
|
+
moreOutputMetadata,
|
|
15960
16803
|
normalizeSchemaPath,
|
|
15961
16804
|
nullType2 as nullType,
|
|
15962
16805
|
openAttachTicket,
|
|
@@ -16011,4 +16854,4 @@ export {
|
|
|
16011
16854
|
utf82 as utf8
|
|
16012
16855
|
};
|
|
16013
16856
|
|
|
16014
|
-
//# debugId=
|
|
16857
|
+
//# debugId=C8BFA3B7418F103264756E2164756E21
|