@query-farm/vgi 0.21.0 → 0.22.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/dist/cache-control.d.ts +26 -0
- package/dist/catalog/composite.d.ts +2 -0
- package/dist/catalog/interface.d.ts +11 -0
- package/dist/client-entry.js +5 -3
- package/dist/client-entry.js.map +5 -5
- package/dist/functions/registry.d.ts +31 -0
- package/dist/functions/scalar.d.ts +7 -3
- package/dist/generated/vgi-client.d.ts +16 -0
- package/dist/index.core.d.ts +1 -1
- package/dist/index.js +120 -16
- package/dist/index.js.map +15 -15
- package/dist/protocol/handlers/function.d.ts +8 -0
- package/dist/protocol/handlers/shared.d.ts +4 -0
- package/dist/protocol/types.d.ts +8 -0
- package/dist/serve-entry.js +35 -13
- package/dist/serve-entry.js.map +8 -8
- package/dist/worker-cf-entry.js +115 -14
- package/dist/worker-cf-entry.js.map +13 -13
- package/dist/worker.d.ts +9 -0
- package/package.json +3 -3
- package/src/cache-control.ts +27 -0
- package/src/catalog/composite.ts +9 -0
- package/src/catalog/interface.ts +15 -0
- package/src/catalog/read-only.ts +13 -0
- package/src/functions/registry.ts +106 -1
- package/src/functions/scalar.ts +10 -5
- package/src/generated/vgi-client.ts +17 -1
- package/src/index.core.ts +1 -0
- package/src/protocol/dispatch.ts +1 -0
- package/src/protocol/handlers/function.ts +29 -8
- package/src/protocol/handlers/shared.ts +25 -1
- package/src/protocol/serializers/bind.ts +7 -0
- package/src/protocol/types.ts +8 -0
- package/src/worker.ts +15 -1
|
@@ -4,5 +4,13 @@ export interface FunctionHandlerConfig {
|
|
|
4
4
|
registry: FunctionRegistry;
|
|
5
5
|
recoverExchangeState?: (opaqueData: Uint8Array) => any;
|
|
6
6
|
signingKey?: Uint8Array;
|
|
7
|
+
/**
|
|
8
|
+
* Used to map a bind's `attach_opaque_data` to its catalog, so resolution can
|
|
9
|
+
* be scoped when two catalogs declare the same schema and function name.
|
|
10
|
+
* Optional — without it, resolution falls back to (schema, name).
|
|
11
|
+
*/
|
|
12
|
+
catalogInterface?: {
|
|
13
|
+
catalogNameForAttach(a: Uint8Array): string | null;
|
|
14
|
+
};
|
|
7
15
|
}
|
|
8
16
|
export declare function registerFunctionMethods(protocol: Protocol, config: FunctionHandlerConfig): void;
|
|
@@ -22,6 +22,10 @@ export declare function overloadContext(req: {
|
|
|
22
22
|
arguments: any;
|
|
23
23
|
input_schema: any;
|
|
24
24
|
function_type: any;
|
|
25
|
+
schema_name?: string | null;
|
|
26
|
+
attach_opaque_data?: Uint8Array | null;
|
|
27
|
+
}, catalogInterface?: {
|
|
28
|
+
catalogNameForAttach(a: Uint8Array): string | null;
|
|
25
29
|
}): OverloadContext;
|
|
26
30
|
/**
|
|
27
31
|
* Recover accumulated exchange state from a FINALIZE init request.
|
package/dist/protocol/types.d.ts
CHANGED
|
@@ -73,6 +73,14 @@ export interface BindRequest {
|
|
|
73
73
|
*/
|
|
74
74
|
at_unit?: string | null;
|
|
75
75
|
at_value?: string | null;
|
|
76
|
+
/**
|
|
77
|
+
* Catalog schema that declares the function being bound. A worker may
|
|
78
|
+
* register the same name in more than one schema, so the bare name does not
|
|
79
|
+
* identify an implementation — resolution is by `(schema_name,
|
|
80
|
+
* function_name)`. Null for callers with no catalog context (COPY handler
|
|
81
|
+
* binds). Mirrors vgi-python's `BindRequest.schema_name`.
|
|
82
|
+
*/
|
|
83
|
+
schema_name?: string | null;
|
|
76
84
|
}
|
|
77
85
|
export interface BindResponse {
|
|
78
86
|
output_schema: VgiSchema;
|
package/dist/serve-entry.js
CHANGED
|
@@ -3029,7 +3029,8 @@ var BIND_REQUEST_SCHEMA = schema2([
|
|
|
3029
3029
|
field2("transaction_opaque_data", binary2(), true),
|
|
3030
3030
|
field2("resolved_secrets_provided", bool2(), false),
|
|
3031
3031
|
field2("at_unit", utf82(), true),
|
|
3032
|
-
field2("at_value", utf82(), true)
|
|
3032
|
+
field2("at_value", utf82(), true),
|
|
3033
|
+
field2("schema_name", utf82(), true)
|
|
3033
3034
|
]);
|
|
3034
3035
|
var COPY_FROM_STRUCT_TYPE = struct2([
|
|
3035
3036
|
field2("format", utf82(), false),
|
|
@@ -3097,6 +3098,7 @@ function deserializeBindRequest(params) {
|
|
|
3097
3098
|
resolved_secrets_provided: params.resolved_secrets_provided ?? false,
|
|
3098
3099
|
at_unit: params.at_unit ? String(params.at_unit) : null,
|
|
3099
3100
|
at_value: params.at_value ? String(params.at_value) : null,
|
|
3101
|
+
schema_name: params.schema_name ? String(params.schema_name) : null,
|
|
3100
3102
|
copy_from: parseCopyFromContext(params.copy_from),
|
|
3101
3103
|
copy_to: parseCopyToContext(params.copy_to)
|
|
3102
3104
|
};
|
|
@@ -3922,11 +3924,21 @@ function wrapResult(values, innerSchema) {
|
|
|
3922
3924
|
const batch = batchFromColumns(Object.fromEntries(a.fields.map((f) => [f.name, [values[f.name] ?? null]])), a);
|
|
3923
3925
|
return { result: serializeBatch(batch) };
|
|
3924
3926
|
}
|
|
3925
|
-
function overloadContext(req) {
|
|
3927
|
+
function overloadContext(req, catalogInterface) {
|
|
3928
|
+
let catalogName = null;
|
|
3929
|
+
if (catalogInterface && req.attach_opaque_data) {
|
|
3930
|
+
try {
|
|
3931
|
+
catalogName = catalogInterface.catalogNameForAttach(req.attach_opaque_data);
|
|
3932
|
+
} catch {
|
|
3933
|
+
catalogName = null;
|
|
3934
|
+
}
|
|
3935
|
+
}
|
|
3926
3936
|
return {
|
|
3927
3937
|
arguments: req.arguments,
|
|
3928
3938
|
inputSchema: req.input_schema,
|
|
3929
|
-
isScalar: String(req.function_type).toLowerCase() === "scalar"
|
|
3939
|
+
isScalar: String(req.function_type).toLowerCase() === "scalar",
|
|
3940
|
+
schemaName: req.schema_name ?? null,
|
|
3941
|
+
catalogName
|
|
3930
3942
|
};
|
|
3931
3943
|
}
|
|
3932
3944
|
function recoverFinalizeState(request, recoverExchangeState) {
|
|
@@ -4917,7 +4929,7 @@ var columnOpParams = schema2([
|
|
|
4917
4929
|
|
|
4918
4930
|
// src/protocol/handlers/function.ts
|
|
4919
4931
|
function registerFunctionMethods(protocol, config) {
|
|
4920
|
-
const { registry, signingKey } = config;
|
|
4932
|
+
const { registry, signingKey, catalogInterface } = config;
|
|
4921
4933
|
async function stripAttach(attach, ctx) {
|
|
4922
4934
|
if (attach == null)
|
|
4923
4935
|
return null;
|
|
@@ -4926,6 +4938,15 @@ function registerFunctionMethods(protocol, config) {
|
|
|
4926
4938
|
return env;
|
|
4927
4939
|
return openAttach(env, ctx?.auth, signingKey);
|
|
4928
4940
|
}
|
|
4941
|
+
async function strippedContext(bindCall, ctx) {
|
|
4942
|
+
let attach = null;
|
|
4943
|
+
try {
|
|
4944
|
+
attach = await stripAttach(bindCall.attach_opaque_data, ctx);
|
|
4945
|
+
} catch {
|
|
4946
|
+
attach = null;
|
|
4947
|
+
}
|
|
4948
|
+
return overloadContext({ ...bindCall, attach_opaque_data: attach }, catalogInterface);
|
|
4949
|
+
}
|
|
4929
4950
|
const initHeaderSchema = schema2([
|
|
4930
4951
|
field2("execution_id", binary2(), false),
|
|
4931
4952
|
field2("opaque_data", binary2(), true),
|
|
@@ -4942,7 +4963,7 @@ function registerFunctionMethods(protocol, config) {
|
|
|
4942
4963
|
const innerParams = unwrapRequest(params.request);
|
|
4943
4964
|
const request = deserializeBindRequest(innerParams);
|
|
4944
4965
|
request.attach_opaque_data = await stripAttach(request.attach_opaque_data, ctx);
|
|
4945
|
-
const func = registry.get(request.function_name, overloadContext(request));
|
|
4966
|
+
const func = registry.get(request.function_name, overloadContext(request, catalogInterface));
|
|
4946
4967
|
const response = await func.bind(request);
|
|
4947
4968
|
const serialized = serializeBindResponse(response);
|
|
4948
4969
|
return wrapResult(serialized, BindResultSchema);
|
|
@@ -4957,7 +4978,7 @@ function registerFunctionMethods(protocol, config) {
|
|
|
4957
4978
|
const innerParams = unwrapRequest(params.request);
|
|
4958
4979
|
const request = deserializeInitRequest(innerParams);
|
|
4959
4980
|
request.bind_call.attach_opaque_data = await stripAttach(request.bind_call.attach_opaque_data, undefined);
|
|
4960
|
-
const func = registry.get(request.bind_call.function_name, overloadContext(request.bind_call));
|
|
4981
|
+
const func = registry.get(request.bind_call.function_name, overloadContext(request.bind_call, catalogInterface));
|
|
4961
4982
|
const initResponse = await func.globalInit(request);
|
|
4962
4983
|
const accumulatedState = recoverFinalizeState(request, config.recoverExchangeState);
|
|
4963
4984
|
const handlers = func.createStreamHandlers(request, initResponse, accumulatedState);
|
|
@@ -4997,7 +5018,7 @@ function registerFunctionMethods(protocol, config) {
|
|
|
4997
5018
|
const initRequestBatch = deserializeBatch(state.initRequestIpc);
|
|
4998
5019
|
const initRequestDict = batchToScalarDict(initRequestBatch);
|
|
4999
5020
|
const request = deserializeInitRequest(initRequestDict);
|
|
5000
|
-
const func = registry.get(state.functionName,
|
|
5021
|
+
const func = registry.get(state.functionName, await strippedContext(request.bind_call));
|
|
5001
5022
|
const executionId = state.executionId;
|
|
5002
5023
|
const opaqueData = state.opaqueData ?? null;
|
|
5003
5024
|
const initResponse = {
|
|
@@ -5045,7 +5066,7 @@ function registerFunctionMethods(protocol, config) {
|
|
|
5045
5066
|
handler: async (params) => {
|
|
5046
5067
|
const innerParams = unwrapRequest(params.request);
|
|
5047
5068
|
const request = deserializeCardinalityRequest(innerParams);
|
|
5048
|
-
const func = registry.get(request.bind_call.function_name,
|
|
5069
|
+
const func = registry.get(request.bind_call.function_name, await strippedContext(request.bind_call));
|
|
5049
5070
|
let cardResult;
|
|
5050
5071
|
if (func.cardinality) {
|
|
5051
5072
|
cardResult = serializeTableCardinality(await func.cardinality(request));
|
|
@@ -5058,10 +5079,10 @@ function registerFunctionMethods(protocol, config) {
|
|
|
5058
5079
|
protocol.unary("table_function_statistics", {
|
|
5059
5080
|
params: REQUEST_PARAMS_SCHEMA,
|
|
5060
5081
|
result: RESULT_BINARY_NULLABLE_SCHEMA,
|
|
5061
|
-
handler: (params) => {
|
|
5082
|
+
handler: async (params) => {
|
|
5062
5083
|
const innerParams = unwrapRequest(params.request);
|
|
5063
5084
|
const request = deserializeCardinalityRequest(innerParams);
|
|
5064
|
-
const func = registry.get(request.bind_call.function_name,
|
|
5085
|
+
const func = registry.get(request.bind_call.function_name, await strippedContext(request.bind_call));
|
|
5065
5086
|
if (!func.statistics)
|
|
5066
5087
|
return { result: null };
|
|
5067
5088
|
const stats = func.statistics(request);
|
|
@@ -5081,7 +5102,7 @@ function registerFunctionMethods(protocol, config) {
|
|
|
5081
5102
|
const bindCall = deserializeBindRequest(bindParams);
|
|
5082
5103
|
const globalExecutionId = toUint8Array(innerParams.global_execution_id);
|
|
5083
5104
|
const bindOpaqueData = innerParams.bind_opaque_data ? toUint8Array(innerParams.bind_opaque_data) : null;
|
|
5084
|
-
const func = registry.get(bindCall.function_name,
|
|
5105
|
+
const func = registry.get(bindCall.function_name, await strippedContext(bindCall));
|
|
5085
5106
|
const map3 = func.dynamicToString ? await func.dynamicToString({ bindCall, bindOpaqueData, globalExecutionId }) : {};
|
|
5086
5107
|
const keys = Object.keys(map3);
|
|
5087
5108
|
const values = keys.map((k) => map3[k] ?? "");
|
|
@@ -6300,7 +6321,8 @@ function buildVgiProtocol(config) {
|
|
|
6300
6321
|
registerFunctionMethods(protocol, {
|
|
6301
6322
|
registry: config.registry,
|
|
6302
6323
|
recoverExchangeState: config.recoverExchangeState,
|
|
6303
|
-
signingKey: config.signingKey
|
|
6324
|
+
signingKey: config.signingKey,
|
|
6325
|
+
catalogInterface: config.catalogInterface
|
|
6304
6326
|
});
|
|
6305
6327
|
registerAggregateMethods(protocol, config.registry);
|
|
6306
6328
|
registerTableBufferingMethods(protocol, config.registry, config.signingKey);
|
|
@@ -6440,4 +6462,4 @@ export {
|
|
|
6440
6462
|
DEFAULT_PORT
|
|
6441
6463
|
};
|
|
6442
6464
|
|
|
6443
|
-
//# debugId=
|
|
6465
|
+
//# debugId=BAA2DFC0A0256E9E64756E2164756E21
|