@query-farm/vgi 0.42.0 → 0.44.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 +5 -2
- package/dist/attach-ticket.d.ts +18 -7
- package/dist/client-entry.js +215 -91
- package/dist/client-entry.js.map +10 -9
- package/dist/codec/asd.d.ts +3 -1
- package/dist/codec/conform.d.ts +51 -0
- package/dist/errors.d.ts +5 -1
- package/dist/generated/vgi-service.d.ts +1315 -0
- package/dist/index.core.d.ts +1 -1
- package/dist/index.js +2143 -932
- package/dist/index.js.map +29 -28
- package/dist/protocol/dispatch.d.ts +14 -5
- 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 +2 -2
- package/dist/protocol/handlers/table-buffering.d.ts +3 -2
- package/dist/protocol/handlers/unimplemented.d.ts +4 -17
- package/dist/protocol/serializers/shared.d.ts +2 -1
- package/dist/rpc-server.d.ts +2 -2
- package/dist/serve-entry.js +2104 -903
- package/dist/serve-entry.js.map +25 -24
- package/dist/worker-cf-entry.js +2045 -842
- package/dist/worker-cf-entry.js.map +29 -28
- package/package.json +3 -3
- package/src/attach-ticket.ts +41 -13
- package/src/catalog/composite.ts +2 -1
- package/src/catalog/interface.ts +5 -4
- package/src/catalog/read-only.ts +8 -6
- package/src/client/client.ts +13 -5
- package/src/codec/asd.ts +5 -2
- package/src/codec/conform.ts +193 -0
- package/src/errors.ts +27 -7
- package/src/functions/registry.ts +3 -2
- package/src/generated/vgi-service.ts +2678 -0
- package/src/http/fetch.ts +1 -1
- package/src/index.core.ts +3 -1
- package/src/protocol/dispatch.ts +40 -29
- 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 +8 -6
- package/src/protocol/handlers/table-buffering.ts +53 -71
- package/src/protocol/handlers/unimplemented.ts +18 -62
- package/src/protocol/serializers/bind.ts +3 -1
- package/src/protocol/serializers/shared.ts +5 -2
- package/src/rpc-server.ts +7 -7
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { Protocol } from "@query-farm/vgi-rpc";
|
|
1
|
+
import type { Protocol } from "@query-farm/vgi-rpc";
|
|
2
2
|
import type { FunctionRegistry } from "../functions/registry.js";
|
|
3
3
|
import type { CatalogInterface } from "../catalog/interface.js";
|
|
4
|
+
import { VGI_PROTOCOL_NAME, type VgiService } from "../generated/vgi-service.js";
|
|
4
5
|
export interface ProtocolConfig {
|
|
5
6
|
registry: FunctionRegistry;
|
|
6
7
|
catalogInterface?: CatalogInterface;
|
|
@@ -24,7 +25,8 @@ export interface ProtocolConfig {
|
|
|
24
25
|
* That matters for this consumer specifically: the DuckDB extension ships to
|
|
25
26
|
* users and cannot be flag-dayed.
|
|
26
27
|
*
|
|
27
|
-
* Declared rather than derived
|
|
28
|
+
* Declared rather than derived, and now generated with the method table
|
|
29
|
+
* (src/generated/vgi-service.ts). Until the transports made the routing key
|
|
28
30
|
* required, each implementation's wire name defaulted to whatever its local
|
|
29
31
|
* type was called, which left the six ports disagreeing four ways — Python
|
|
30
32
|
* `VgiProtocol`, Java and C# `VgiService`, Go the framework default `Service`,
|
|
@@ -38,18 +40,25 @@ export interface ProtocolConfig {
|
|
|
38
40
|
* so the HTTP entry points build that scope from the same constant the
|
|
39
41
|
* protocol is registered under rather than a second copy of the literal.
|
|
40
42
|
*/
|
|
41
|
-
export
|
|
43
|
+
export { VGI_PROTOCOL_NAME };
|
|
42
44
|
/**
|
|
43
45
|
* The `vgi.v2` protocol hash `vgi_rpc.Reflection.v1` must report for this
|
|
44
46
|
* worker: the reference's (vgi-python 0.43.0, 72 methods). Every SDK hosts
|
|
45
47
|
* every `vgi.v2` method with the reference's schemas, so the hash is one value
|
|
46
48
|
* across the ports; a method this SDK does not implement is still registered
|
|
47
|
-
* (
|
|
48
|
-
* params/result/header schemas only
|
|
49
|
+
* with the generated UNIMPLEMENTED default (src/generated/vgi-service.ts). The
|
|
50
|
+
* hash covers method names, types and the params/result/header schemas only
|
|
51
|
+
* (WIRE_PROTOCOL.md §14).
|
|
49
52
|
*
|
|
50
53
|
* It changes only with vgi.v2's protocol version (currently 2.1.0). Asserted
|
|
51
54
|
* by src/protocol/__tests__/vgi-v2-hash.test.ts; if that test fails, the
|
|
52
55
|
* surface drifted from the reference -- fix the schemas, do not bump this.
|
|
53
56
|
*/
|
|
54
57
|
export declare const VGI_V2_PROTOCOL_HASH = "774cb80090d71ea76d09aa311b9cda4ca4c33c3bf72c43242eb6dc87b6f79ce5";
|
|
58
|
+
/**
|
|
59
|
+
* This worker's `vgi.v2` implementation: the generated UNIMPLEMENTED default
|
|
60
|
+
* for every method, overridden by the handler groups for what this SDK serves.
|
|
61
|
+
*/
|
|
62
|
+
export declare function buildVgiService(config: ProtocolConfig): VgiService;
|
|
63
|
+
/** The `vgi.v2` protocol, registered from the generated table with {@link buildVgiService}. */
|
|
55
64
|
export declare function buildVgiProtocol(config: ProtocolConfig): Protocol;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { VgiService } from "../../generated/vgi-service.js";
|
|
2
2
|
import type { FunctionRegistry } from "../../functions/registry.js";
|
|
3
|
-
|
|
3
|
+
/** The aggregate lifecycle's `vgi.v2` handlers. */
|
|
4
|
+
export declare function aggregateHandlers(registry: FunctionRegistry): Partial<VgiService>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { VgiService } from "../../../generated/vgi-service.js";
|
|
2
2
|
import { type GetCatalog } from "./shared.js";
|
|
3
|
-
export declare function
|
|
3
|
+
export declare function catalogAdminHandlers(getCatalog: GetCatalog, signingKey?: Uint8Array): Partial<VgiService>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import { Protocol } from "@query-farm/vgi-rpc";
|
|
2
1
|
import type { CatalogInterface } from "../../../catalog/interface.js";
|
|
3
|
-
|
|
2
|
+
import type { VgiService } from "../../../generated/vgi-service.js";
|
|
3
|
+
/** The catalog_* `vgi.v2` handlers, over *catalog* (or `NoCatalogError` without one). */
|
|
4
|
+
export declare function catalogHandlers(catalog: CatalogInterface | undefined, signingKey?: Uint8Array): Partial<VgiService>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { VgiService } from "../../../generated/vgi-service.js";
|
|
2
2
|
import { type GetCatalog } from "./shared.js";
|
|
3
|
-
export declare function
|
|
3
|
+
export declare function catalogIndexHandlers(getCatalog: GetCatalog, signingKey?: Uint8Array): Partial<VgiService>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { VgiService } from "../../../generated/vgi-service.js";
|
|
2
2
|
import { type GetCatalog } from "./shared.js";
|
|
3
|
-
export declare function
|
|
3
|
+
export declare function catalogMacroHandlers(getCatalog: GetCatalog, signingKey?: Uint8Array): Partial<VgiService>;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Protocol, type AuthContext, type CallContext } from "@query-farm/vgi-rpc";
|
|
1
|
+
import type { AuthContext, CallContext } from "@query-farm/vgi-rpc";
|
|
3
2
|
import type { CatalogInterface } from "../../../catalog/interface.js";
|
|
4
3
|
export type GetCatalog = () => CatalogInterface;
|
|
5
4
|
/**
|
|
@@ -40,17 +39,12 @@ export declare function shardKeyForAttach(sealed: Uint8Array | undefined, auth:
|
|
|
40
39
|
*/
|
|
41
40
|
export declare function sealTransaction(plaintext: Uint8Array, attachEnvelope: Uint8Array, auth: AuthContext | undefined, signingKey: Uint8Array | undefined): Promise<Uint8Array>;
|
|
42
41
|
/**
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*/
|
|
48
|
-
export declare function
|
|
49
|
-
params: unknown;
|
|
50
|
-
result: unknown;
|
|
51
|
-
handler: (params: Record<string, any>, ctx: CallContext) => unknown;
|
|
52
|
-
doc?: string;
|
|
53
|
-
}): void;
|
|
42
|
+
* Wrap a catalog unary handler so its request opaque-data fields are unwrapped
|
|
43
|
+
* before the body runs. Used for every catalog_* method except catalog_attach
|
|
44
|
+
* / catalog_transaction_begin, which seal their outputs and are written
|
|
45
|
+
* bespoke. The body sees the flattened params as a plain record.
|
|
46
|
+
*/
|
|
47
|
+
export declare function catalogHandler<R>(signingKey: Uint8Array | undefined, handler: (params: Record<string, any>, ctx: CallContext) => R | Promise<R>): (params: object, ctx: CallContext) => Promise<R>;
|
|
54
48
|
export declare function makeGetCatalog(catalog: CatalogInterface | undefined): GetCatalog;
|
|
55
49
|
/**
|
|
56
50
|
* Decode the `options` field of a catalog_attach request into a plain
|
|
@@ -59,4 +53,3 @@ export declare function makeGetCatalog(catalog: CatalogInterface | undefined): G
|
|
|
59
53
|
* one row with the value. Returns `{}` for null / empty input.
|
|
60
54
|
*/
|
|
61
55
|
export declare function decodeOptionsBatch(bytes: any): Record<string, unknown>;
|
|
62
|
-
export declare const emptyResultSchema: VgiSchema;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { VgiService } from "../../../generated/vgi-service.js";
|
|
2
2
|
import { type GetCatalog } from "./shared.js";
|
|
3
|
-
export declare function
|
|
3
|
+
export declare function catalogTableHandlers(getCatalog: GetCatalog, signingKey?: Uint8Array): Partial<VgiService>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { VgiService } from "../../../generated/vgi-service.js";
|
|
2
2
|
import { type GetCatalog } from "./shared.js";
|
|
3
|
-
export declare function
|
|
3
|
+
export declare function catalogViewHandlers(getCatalog: GetCatalog, signingKey?: Uint8Array): Partial<VgiService>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type VgiService } from "../../generated/vgi-service.js";
|
|
2
2
|
import type { FunctionRegistry } from "../../functions/registry.js";
|
|
3
3
|
export interface FunctionHandlerConfig {
|
|
4
4
|
registry: FunctionRegistry;
|
|
@@ -23,4 +23,5 @@ export interface FunctionHandlerConfig {
|
|
|
23
23
|
version?(attach: Uint8Array, txn?: Uint8Array): number | Promise<number>;
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
|
-
|
|
26
|
+
/** The per-function lifecycle's `vgi.v2` handlers. */
|
|
27
|
+
export declare function functionHandlers(config: FunctionHandlerConfig): Partial<VgiService>;
|
|
@@ -2,7 +2,6 @@ import { type VgiSchema } from "../../arrow/index.js";
|
|
|
2
2
|
import type { OverloadContext } from "../../functions/registry.js";
|
|
3
3
|
export declare const RESULT_BINARY_SCHEMA: VgiSchema;
|
|
4
4
|
export declare const REQUEST_PARAMS_SCHEMA: VgiSchema;
|
|
5
|
-
export declare const RESULT_BINARY_NULLABLE_SCHEMA: VgiSchema;
|
|
6
5
|
/**
|
|
7
6
|
* Unwrap a "request" Binary column: deserialize the inner Arrow IPC batch
|
|
8
7
|
* and return flat columns as a dict (row 0).
|
|
@@ -12,7 +11,8 @@ export declare function unwrapRequest(requestBytes: any): Record<string, any>;
|
|
|
12
11
|
export declare function normalizeRequestSchemaPaths(params: Record<string, any>): void;
|
|
13
12
|
/**
|
|
14
13
|
* Wrap a dict of values into a single "result" Binary column.
|
|
15
|
-
* Builds a 1-row batch from the values using the given schema
|
|
14
|
+
* Builds a 1-row batch from the values using the given schema (conformed to
|
|
15
|
+
* the protocol's container rules, see `conformRecord`),
|
|
16
16
|
* serializes it to IPC bytes, and returns { result: bytes }.
|
|
17
17
|
*/
|
|
18
18
|
export declare function wrapResult(values: Record<string, any>, innerSchema: VgiSchema | import("../../arrow/index.js").VgiSchema): {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { VgiService } from "../../generated/vgi-service.js";
|
|
2
2
|
import type { FunctionRegistry } from "../../functions/registry.js";
|
|
3
|
-
|
|
3
|
+
/** The table_buffering lifecycle's `vgi.v2` handlers. */
|
|
4
|
+
export declare function tableBufferingHandlers(registry: FunctionRegistry, signingKey?: Uint8Array): Partial<VgiService>;
|
|
@@ -1,17 +1,4 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
|
|
5
|
-
readonly name: string;
|
|
6
|
-
readonly params: VgiSchema;
|
|
7
|
-
readonly result: VgiSchema;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* The vgi.v2 methods (of the reference's 72) this SDK does not implement.
|
|
11
|
-
* Exported so a test can assert each one refuses with UNIMPLEMENTED.
|
|
12
|
-
*/
|
|
13
|
-
export declare const UNIMPLEMENTED_METHODS: readonly UnimplementedMethod[];
|
|
14
|
-
/** The message every unimplemented method answers with. */
|
|
15
|
-
export declare function unimplementedMessage(method: string): string;
|
|
16
|
-
export declare function registerUnimplementedMethods(protocol: Protocol): void;
|
|
17
|
-
export {};
|
|
1
|
+
import { type VgiMethodSpec } from "../../generated/vgi-service.js";
|
|
2
|
+
export { unimplementedMessage } from "../../generated/vgi-service.js";
|
|
3
|
+
/** The vgi.v2 methods (of the reference's 72) this SDK leaves at the generated default. */
|
|
4
|
+
export declare const UNIMPLEMENTED_METHODS: readonly VgiMethodSpec[];
|
|
@@ -7,6 +7,7 @@ import { type VgiSchema, type VgiBatch } from "../../arrow/index.js";
|
|
|
7
7
|
export declare function toUint8Array(val: any): Uint8Array;
|
|
8
8
|
/**
|
|
9
9
|
* Build a single-row RecordBatch from a {fieldName: value} dict matching the
|
|
10
|
-
* given schema. Auto-coerces JS numbers to BigInt for Int64 fields
|
|
10
|
+
* given schema. Auto-coerces JS numbers to BigInt for Int64 fields, and
|
|
11
|
+
* applies the protocol's container rules (`conformRecord`).
|
|
11
12
|
*/
|
|
12
13
|
export declare function buildSingleRowBatch(schema: VgiSchema, values: Record<string, any>): VgiBatch;
|
package/dist/rpc-server.d.ts
CHANGED
|
@@ -31,13 +31,13 @@ export interface HostingOptions {
|
|
|
31
31
|
*
|
|
32
32
|
* Each needs a distinct wire name, which may not be `vgi.v2` and may not
|
|
33
33
|
* use the reserved `vgi_rpc.` prefix: reflection is hosted automatically and
|
|
34
|
-
* `vgi_rpc.Identity.
|
|
34
|
+
* `vgi_rpc.Identity.v2` is enabled through {@link resolveToken} /
|
|
35
35
|
* {@link mintGrant}. Violations are a startup error naming this hook.
|
|
36
36
|
*/
|
|
37
37
|
hostedProtocols?: () => Iterable<Protocol>;
|
|
38
38
|
/**
|
|
39
39
|
* Resolve an opaque bearer credential to the identity it authenticates as.
|
|
40
|
-
* Supplying it hosts `vgi_rpc.Identity.
|
|
40
|
+
* Supplying it hosts `vgi_rpc.Identity.v2`'s `introspect_token` -- on HTTP,
|
|
41
41
|
* the transport that authenticates callers. Absent, the method is absent
|
|
42
42
|
* (not hosted-and-refusing), which keeps a dependency upgrade from growing a
|
|
43
43
|
* credential-to-identity oracle on every existing worker.
|