@query-farm/vgi 0.41.0 → 0.43.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/generated/vgi-service.d.ts +1315 -0
- package/dist/index.js +1845 -780
- package/dist/index.js.map +16 -15
- package/dist/protocol/dispatch.d.ts +25 -3
- package/dist/protocol/handlers/aggregate.d.ts +3 -2
- package/dist/protocol/handlers/catalog/admin.d.ts +2 -2
- package/dist/protocol/handlers/catalog/index.d.ts +3 -2
- package/dist/protocol/handlers/catalog/index_methods.d.ts +2 -2
- package/dist/protocol/handlers/catalog/macro.d.ts +2 -2
- package/dist/protocol/handlers/catalog/shared.d.ts +7 -14
- package/dist/protocol/handlers/catalog/table.d.ts +2 -2
- package/dist/protocol/handlers/catalog/view.d.ts +2 -2
- package/dist/protocol/handlers/function.d.ts +3 -2
- package/dist/protocol/handlers/shared.d.ts +0 -1
- package/dist/protocol/handlers/table-buffering.d.ts +3 -2
- package/dist/protocol/handlers/unimplemented.d.ts +4 -0
- package/dist/serve-entry.js +1844 -780
- package/dist/serve-entry.js.map +16 -15
- package/dist/worker-cf-entry.js +1845 -780
- package/dist/worker-cf-entry.js.map +16 -15
- package/package.json +1 -1
- package/src/generated/vgi-service.ts +2678 -0
- package/src/protocol/dispatch.ts +51 -24
- package/src/protocol/handlers/aggregate.ts +205 -232
- package/src/protocol/handlers/catalog/admin.ts +228 -299
- package/src/protocol/handlers/catalog/index.ts +17 -16
- package/src/protocol/handlers/catalog/index_methods.ts +26 -36
- package/src/protocol/handlers/catalog/macro.ts +54 -77
- package/src/protocol/handlers/catalog/shared.ts +30 -47
- package/src/protocol/handlers/catalog/table.ts +205 -270
- package/src/protocol/handlers/catalog/view.ts +59 -85
- package/src/protocol/handlers/function.ts +127 -156
- package/src/protocol/handlers/shared.ts +0 -4
- package/src/protocol/handlers/table-buffering.ts +53 -71
- package/src/protocol/handlers/unimplemented.ts +30 -0
|
@@ -10,24 +10,16 @@
|
|
|
10
10
|
// vgi-python's worker._load_table_buffering_params.
|
|
11
11
|
|
|
12
12
|
import { deserializeBatch } from "../../arrow/index.js";
|
|
13
|
-
import {
|
|
13
|
+
import type { VgiService } from "../../generated/vgi-service.js";
|
|
14
14
|
import type { FunctionRegistry } from "../../functions/registry.js";
|
|
15
15
|
import { toUint8Array } from "../../util/bytes.js";
|
|
16
16
|
import { batchToScalarDict, batchToSecretDict } from "../../util/arrow/index.js";
|
|
17
17
|
import {
|
|
18
|
-
TableBufferingCombineParamsSchema,
|
|
19
18
|
TableBufferingCombineResultSchema,
|
|
20
|
-
TableBufferingDestructorParamsSchema,
|
|
21
19
|
TableBufferingDestructorResultSchema,
|
|
22
|
-
TableBufferingProcessParamsSchema,
|
|
23
20
|
TableBufferingProcessResultSchema,
|
|
24
21
|
} from "../../generated/vgi-protocol-schemas.js";
|
|
25
|
-
import {
|
|
26
|
-
REQUEST_PARAMS_SCHEMA,
|
|
27
|
-
RESULT_BINARY_SCHEMA,
|
|
28
|
-
unwrapRequest,
|
|
29
|
-
wrapResult,
|
|
30
|
-
} from "./shared.js";
|
|
22
|
+
import { unwrapRequest, wrapResult } from "./shared.js";
|
|
31
23
|
import { openAttach } from "./catalog/shared.js";
|
|
32
24
|
import {
|
|
33
25
|
BoundStorage,
|
|
@@ -41,11 +33,11 @@ import {
|
|
|
41
33
|
} from "../../functions/table-buffering.js";
|
|
42
34
|
import { Arguments } from "../../arguments/arguments.js";
|
|
43
35
|
|
|
44
|
-
|
|
45
|
-
|
|
36
|
+
/** The table_buffering lifecycle's `vgi.v2` handlers. */
|
|
37
|
+
export function tableBufferingHandlers(
|
|
46
38
|
registry: FunctionRegistry,
|
|
47
39
|
signingKey?: Uint8Array,
|
|
48
|
-
):
|
|
40
|
+
): Partial<VgiService> {
|
|
49
41
|
// `schemaPath` scopes resolution to the schema the caller named. The
|
|
50
42
|
// buffering process/combine RPCs carry it (protocol 1.2.0), so a name
|
|
51
43
|
// declared in two schemas resolves to the one the request names rather than
|
|
@@ -123,72 +115,62 @@ export function registerTableBufferingMethods(
|
|
|
123
115
|
// ------------------------------------------------------------------------
|
|
124
116
|
// table_buffering_process — sink one batch, return state_id (unary)
|
|
125
117
|
// ------------------------------------------------------------------------
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
}
|
|
143
|
-
return wrapResult({ state_id: stateId }, TableBufferingProcessResultSchema);
|
|
144
|
-
},
|
|
145
|
-
});
|
|
118
|
+
const tableBufferingProcess: VgiService["tableBufferingProcess"] = async (rpcParams, ctx?: any) => {
|
|
119
|
+
const inner = unwrapRequest(rpcParams.request);
|
|
120
|
+
const clientLog = makeClientLog(ctx);
|
|
121
|
+
const { func, params } = await loadParams(inner, clientLog, ctx);
|
|
122
|
+
if (inner.batch_index != null) {
|
|
123
|
+
params.batchIndex = Number(inner.batch_index);
|
|
124
|
+
}
|
|
125
|
+
const batch = deserializeBatch(toUint8Array(inner.input_batch));
|
|
126
|
+
const stateId = await func.bufferingConfig.process(batch, params);
|
|
127
|
+
if (!(stateId instanceof Uint8Array)) {
|
|
128
|
+
throw new Error(
|
|
129
|
+
`${func.meta.name}.process() must return Uint8Array (the opaque state_id)`,
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
return wrapResult({ state_id: stateId }, TableBufferingProcessResultSchema);
|
|
133
|
+
};
|
|
146
134
|
|
|
147
135
|
// ------------------------------------------------------------------------
|
|
148
136
|
// table_buffering_combine — group/merge state_ids (unary)
|
|
149
137
|
// ------------------------------------------------------------------------
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
TableBufferingCombineResultSchema,
|
|
170
|
-
);
|
|
171
|
-
},
|
|
172
|
-
});
|
|
138
|
+
const tableBufferingCombine: VgiService["tableBufferingCombine"] = async (rpcParams, ctx?: any) => {
|
|
139
|
+
const inner = unwrapRequest(rpcParams.request);
|
|
140
|
+
const clientLog = makeClientLog(ctx);
|
|
141
|
+
const { func, params } = await loadParams(inner, clientLog, ctx);
|
|
142
|
+
const stateIds = decodeBytesList(inner.state_ids);
|
|
143
|
+
const finalizeStateIds = await func.bufferingConfig.combine(stateIds, params);
|
|
144
|
+
const out = finalizeStateIds.map((fid, i) => {
|
|
145
|
+
if (!(fid instanceof Uint8Array)) {
|
|
146
|
+
throw new Error(
|
|
147
|
+
`${func.meta.name}.combine() returned non-Uint8Array finalize_state_id at index ${i}`,
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
return fid;
|
|
151
|
+
});
|
|
152
|
+
return wrapResult(
|
|
153
|
+
{ finalize_state_ids: out },
|
|
154
|
+
TableBufferingCombineResultSchema,
|
|
155
|
+
);
|
|
156
|
+
};
|
|
173
157
|
|
|
174
158
|
// ------------------------------------------------------------------------
|
|
175
159
|
// table_buffering_destructor — best-effort end-of-query cleanup (unary)
|
|
176
160
|
// ------------------------------------------------------------------------
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
},
|
|
191
|
-
});
|
|
161
|
+
const tableBufferingDestructor: VgiService["tableBufferingDestructor"] = async (rpcParams) => {
|
|
162
|
+
try {
|
|
163
|
+
const inner = unwrapRequest(rpcParams.request);
|
|
164
|
+
const executionId = toUint8Array(inner.execution_id);
|
|
165
|
+
const bound = new BoundStorage(defaultStorage, executionId);
|
|
166
|
+
await bound.executionClear();
|
|
167
|
+
} catch {
|
|
168
|
+
// Teardown path — swallow; the entry is wiped when the worker exits.
|
|
169
|
+
}
|
|
170
|
+
return wrapResult({}, TableBufferingDestructorResultSchema);
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
return { tableBufferingProcess, tableBufferingCombine, tableBufferingDestructor };
|
|
192
174
|
}
|
|
193
175
|
|
|
194
176
|
function makeClientLog(ctx: any): (level: string, message: string) => void {
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// Copyright 2025, 2026 Query Farm LLC - https://query.farm
|
|
2
|
+
// vgi.v2 methods this SDK registers but does not implement.
|
|
3
|
+
//
|
|
4
|
+
// "The protocol is the unit of optionality": every SDK hosts EVERY vgi.v2
|
|
5
|
+
// method with exactly the reference's schemas, so vgi_rpc.Reflection.v1
|
|
6
|
+
// reports one vgi.v2 protocol hash everywhere (see VGI_V2_PROTOCOL_HASH in
|
|
7
|
+
// ../dispatch.ts). The registration and the UNIMPLEMENTED default for every
|
|
8
|
+
// method are generated (src/generated/vgi-service.ts); this module only names
|
|
9
|
+
// the methods whose generated default this worker leaves in place, so a test
|
|
10
|
+
// can assert each one refuses with UNIMPLEMENTED.
|
|
11
|
+
//
|
|
12
|
+
// To implement one, add its handler to a group in this directory; it drops off
|
|
13
|
+
// this list by itself.
|
|
14
|
+
|
|
15
|
+
import { FunctionRegistry } from "../../functions/registry.js";
|
|
16
|
+
import {
|
|
17
|
+
UNIMPLEMENTED_VGI_SERVICE,
|
|
18
|
+
VGI_V2_METHODS,
|
|
19
|
+
type VgiMethodSpec,
|
|
20
|
+
} from "../../generated/vgi-service.js";
|
|
21
|
+
import { buildVgiService } from "../dispatch.js";
|
|
22
|
+
|
|
23
|
+
export { unimplementedMessage } from "../../generated/vgi-service.js";
|
|
24
|
+
|
|
25
|
+
const service = buildVgiService({ registry: new FunctionRegistry() });
|
|
26
|
+
|
|
27
|
+
/** The vgi.v2 methods (of the reference's 72) this SDK leaves at the generated default. */
|
|
28
|
+
export const UNIMPLEMENTED_METHODS: readonly VgiMethodSpec[] = VGI_V2_METHODS.filter(
|
|
29
|
+
(m) => service[m.key] === UNIMPLEMENTED_VGI_SERVICE[m.key],
|
|
30
|
+
);
|