@query-farm/vgi 0.43.0 → 0.45.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/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 +1 -1
- package/dist/arrow/impl-flechette/index.d.ts +1 -1
- package/dist/arrow/impl-flechette/ipc.d.ts +6 -0
- package/dist/arrow/index.d.ts +1 -1
- package/dist/attach-ticket.d.ts +18 -7
- 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-entry.js +349 -114
- package/dist/client-entry.js.map +16 -14
- package/dist/codec/asd.d.ts +7 -1
- package/dist/codec/conform.d.ts +51 -0
- package/dist/errors.d.ts +5 -1
- package/dist/generated/vgi-client.d.ts +6 -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 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.js +955 -118
- package/dist/index.js.map +33 -28
- package/dist/protocol/dispatch.d.ts +1 -1
- package/dist/protocol/handlers/catalog/contents.d.ts +4 -4
- package/dist/protocol/handlers/shared.d.ts +2 -1
- package/dist/protocol/serializers/shared.d.ts +2 -1
- package/dist/rpc-server.d.ts +2 -2
- package/dist/serve-entry.js +867 -165
- package/dist/serve-entry.js.map +26 -22
- package/dist/worker-cf-entry.js +825 -114
- package/dist/worker-cf-entry.js.map +31 -27
- package/package.json +3 -3
- 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 +7 -2
- 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/attach-ticket.ts +41 -13
- package/src/catalog/composite.ts +2 -1
- package/src/catalog/contents-codec.ts +77 -0
- package/src/catalog/contents-digest.ts +20 -17
- package/src/catalog/interface.ts +8 -4
- package/src/catalog/publication-envelope.ts +62 -0
- package/src/catalog/publication.ts +290 -0
- package/src/catalog/read-only.ts +8 -8
- package/src/catalog/s3-publication.ts +81 -0
- package/src/client/client.ts +15 -24
- package/src/codec/asd.ts +45 -3
- package/src/codec/conform.ts +194 -0
- package/src/errors.ts +27 -7
- package/src/functions/registry.ts +3 -2
- package/src/generated/vgi-client.ts +7 -16
- package/src/generated/vgi-protocol-schemas.ts +13 -6
- package/src/generated/vgi-protocol-types.ts +39 -5
- package/src/generated/vgi-service.ts +4 -3
- package/src/http/fetch.ts +1 -1
- package/src/index.core.ts +3 -1
- 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/shared.ts +8 -2
- package/src/protocol/serializers/bind.ts +3 -1
- package/src/protocol/serializers/shared.ts +5 -2
- package/src/rpc-server.ts +7 -7
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
// Copyright 2025, 2026 Query Farm LLC - https://query.farm
|
|
2
|
+
// SPDX-License-Identifier: LicenseRef-QueryFarm-Source-Available-1.0
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Wire conformance for protocol records.
|
|
6
|
+
*
|
|
7
|
+
* vgi-python is the reference for the wire shape, and two of its rules are not
|
|
8
|
+
* expressed by a record's Arrow schema nullability flags alone:
|
|
9
|
+
*
|
|
10
|
+
* 1. A **non-nullable list or map column is never null.** Python's dataclass
|
|
11
|
+
* defaults a `list[...]` / `dict[...]` field to an empty container, so an
|
|
12
|
+
* "absent" list goes out as `[]`. A JS caller that leaves the field out (or
|
|
13
|
+
* passes `null`) would otherwise put a null in a column the schema calls
|
|
14
|
+
* non-null — `CatalogInfo.releases`, `CatalogInfo.attach_option_specs`,
|
|
15
|
+
* ... — which a strict client rejects as a protocol error.
|
|
16
|
+
*
|
|
17
|
+
* 2. **List items and map values are never null** unless the Python annotation
|
|
18
|
+
* says so (`list[str | None]`). pyarrow marks every list item field nullable,
|
|
19
|
+
* so the generated schemas carry `item: nullable=true` everywhere and cannot
|
|
20
|
+
* tell the two apart. In the whole protocol exactly one field has optional
|
|
21
|
+
* items — `argument_names` on `BindRequest` / `AggregateBindRequest` (a
|
|
22
|
+
* positional argument has no name). Every other null item is a bug on the
|
|
23
|
+
* sending side (e.g. `BindResponse.lookup_names` built from an unset secret
|
|
24
|
+
* name, where Python sends `""`).
|
|
25
|
+
*
|
|
26
|
+
* `conformRecord` applies both rules to a record about to be encoded: a null or
|
|
27
|
+
* absent non-nullable list/map becomes empty, and a null list item / map value
|
|
28
|
+
* becomes its type's zero value (`""`, `0`, `false`, empty bytes, empty list),
|
|
29
|
+
* which is also what the C++ client reads such an item as. It never mutates its
|
|
30
|
+
* input (catalog items may be frozen and shared) and returns the input itself
|
|
31
|
+
* when nothing needed changing. Nullable columns, and scalars, pass through
|
|
32
|
+
* untouched: a null in a non-nullable scalar column has no safe default and is
|
|
33
|
+
* left for the caller to fix (see `wireViolations`).
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
import {
|
|
37
|
+
type VgiSchema,
|
|
38
|
+
type VgiField,
|
|
39
|
+
type VgiDataType,
|
|
40
|
+
isBinary,
|
|
41
|
+
isBool,
|
|
42
|
+
isDictionary,
|
|
43
|
+
isFloat,
|
|
44
|
+
isInt,
|
|
45
|
+
isList,
|
|
46
|
+
isMap,
|
|
47
|
+
isStruct,
|
|
48
|
+
isUtf8,
|
|
49
|
+
} from "../arrow/index.js";
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Top-level / struct-child field names whose list items may legitimately be
|
|
53
|
+
* null (the Python annotation is `list[X | None]`). Derived from vgi-python by
|
|
54
|
+
* walking every protocol dataclass's type hints; keep in sync if the protocol
|
|
55
|
+
* adds another optional-item list.
|
|
56
|
+
*/
|
|
57
|
+
export const OPTIONAL_ITEM_FIELDS: ReadonlySet<string> = new Set(["argument_names"]);
|
|
58
|
+
|
|
59
|
+
function children(type: VgiDataType): VgiField[] {
|
|
60
|
+
return ((type as any).children ?? []) as VgiField[];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function mapValueType(type: VgiDataType): VgiDataType {
|
|
64
|
+
const entries = children(type)[0].type;
|
|
65
|
+
return children(entries)[1].type;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function mapPairs(raw: any): Array<[unknown, unknown]> {
|
|
69
|
+
if (Array.isArray(raw)) return raw.map((e: any) => (Array.isArray(e) ? [e[0], e[1]] : [e?.key, e?.value]));
|
|
70
|
+
if (raw instanceof Map) return Array.from(raw.entries());
|
|
71
|
+
if (typeof raw[Symbol.iterator] === "function") return Array.from(raw as Iterable<[unknown, unknown]>);
|
|
72
|
+
return Object.entries(raw);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** The value a non-null slot of `type` takes when the sender left it null. */
|
|
76
|
+
export function zeroValue(type: VgiDataType): unknown {
|
|
77
|
+
if (isDictionary(type)) return zeroValue((type as any).dictionary as VgiDataType);
|
|
78
|
+
if (isUtf8(type)) return "";
|
|
79
|
+
if (isBinary(type)) return new Uint8Array(0);
|
|
80
|
+
if (isBool(type)) return false;
|
|
81
|
+
if (isInt(type)) return (type as any).bitWidth === 64 ? 0n : 0;
|
|
82
|
+
if (isFloat(type)) return 0;
|
|
83
|
+
if (isList(type) || isMap(type)) return [];
|
|
84
|
+
if (isStruct(type)) {
|
|
85
|
+
const out: Record<string, unknown> = {};
|
|
86
|
+
for (const c of children(type)) out[c.name] = c.nullable ? null : conformValue(c.type, undefined, false, c.name);
|
|
87
|
+
return out;
|
|
88
|
+
}
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** Whether `type` contains a list or map anywhere (memoized per type object). */
|
|
93
|
+
const HAS_CONTAINER = new WeakMap<object, boolean>();
|
|
94
|
+
function hasContainer(type: VgiDataType): boolean {
|
|
95
|
+
const cached = HAS_CONTAINER.get(type as object);
|
|
96
|
+
if (cached !== undefined) return cached;
|
|
97
|
+
let has = isList(type) || isMap(type);
|
|
98
|
+
if (!has && isStruct(type)) has = children(type).some((c) => hasContainer(c.type));
|
|
99
|
+
HAS_CONTAINER.set(type as object, has);
|
|
100
|
+
return has;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Conform one value of `type`. `nullable` is the slot's nullability; `name` is
|
|
105
|
+
* the field name that owns the slot (list items inherit their list's name, for
|
|
106
|
+
* the `OPTIONAL_ITEM_FIELDS` lookup).
|
|
107
|
+
*/
|
|
108
|
+
function conformValue(type: VgiDataType, value: any, nullable: boolean, name: string): any {
|
|
109
|
+
if (value == null) {
|
|
110
|
+
if (nullable) return value ?? null;
|
|
111
|
+
if (isList(type) || isMap(type)) return [];
|
|
112
|
+
return value;
|
|
113
|
+
}
|
|
114
|
+
if (!hasContainer(type)) return value;
|
|
115
|
+
|
|
116
|
+
if (isList(type)) {
|
|
117
|
+
const itemType = children(type)[0].type;
|
|
118
|
+
const itemsNullable = OPTIONAL_ITEM_FIELDS.has(name);
|
|
119
|
+
const items = Array.isArray(value) ? value : Array.from(value as Iterable<unknown>);
|
|
120
|
+
let changed = !Array.isArray(value);
|
|
121
|
+
const out = items.map((item) => {
|
|
122
|
+
const next = item == null && !itemsNullable ? zeroValue(itemType) : conformValue(itemType, item, true, name);
|
|
123
|
+
if (next !== item) changed = true;
|
|
124
|
+
return next;
|
|
125
|
+
});
|
|
126
|
+
return changed ? out : value;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (isMap(type)) {
|
|
130
|
+
const valueType = mapValueType(type);
|
|
131
|
+
const pairs = mapPairs(value);
|
|
132
|
+
let changed = false;
|
|
133
|
+
const out = pairs.map(([k, v]): [unknown, unknown] => {
|
|
134
|
+
const next = v == null ? zeroValue(valueType) : conformValue(valueType, v, true, name);
|
|
135
|
+
if (next !== v) changed = true;
|
|
136
|
+
return [k, next];
|
|
137
|
+
});
|
|
138
|
+
return changed ? out : value;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (isStruct(type)) {
|
|
142
|
+
let out: Record<string, any> | null = null;
|
|
143
|
+
for (const c of children(type)) {
|
|
144
|
+
const v = value[c.name];
|
|
145
|
+
const next = conformValue(c.type, v, c.nullable, c.name);
|
|
146
|
+
if (next !== v) {
|
|
147
|
+
(out ??= { ...value })[c.name] = next;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return out ?? value;
|
|
151
|
+
}
|
|
152
|
+
return value;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* `obj` conformed to `schema`'s wire rules (see the module comment). Returns
|
|
157
|
+
* `obj` itself when nothing changed.
|
|
158
|
+
*/
|
|
159
|
+
export function conformRecord<T extends Record<string, any>>(schema: VgiSchema, obj: T): T {
|
|
160
|
+
let out: Record<string, any> | null = null;
|
|
161
|
+
for (const f of schema.fields) {
|
|
162
|
+
const v = obj[f.name];
|
|
163
|
+
const next = conformValue(f.type, v, f.nullable, f.name);
|
|
164
|
+
if (next !== v) {
|
|
165
|
+
(out ??= { ...obj })[f.name] = next;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return (out ?? obj) as T;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Column-dict form of `conformRecord` for `batchFromColumns` callers: each
|
|
173
|
+
* value is a one-element array holding the row's value.
|
|
174
|
+
*/
|
|
175
|
+
export function conformColumns(
|
|
176
|
+
schema: VgiSchema,
|
|
177
|
+
columns: Record<string, unknown[]>,
|
|
178
|
+
): Record<string, unknown[]> {
|
|
179
|
+
let out: Record<string, unknown[]> | null = null;
|
|
180
|
+
for (const f of schema.fields) {
|
|
181
|
+
const col = columns[f.name];
|
|
182
|
+
const rows = col ?? [undefined];
|
|
183
|
+
let changed = col === undefined;
|
|
184
|
+
const next = rows.map((v) => {
|
|
185
|
+
const c = conformValue(f.type, v, f.nullable, f.name);
|
|
186
|
+
if (c !== v) changed = true;
|
|
187
|
+
return c;
|
|
188
|
+
});
|
|
189
|
+
if (changed) {
|
|
190
|
+
(out ??= { ...columns })[f.name] = next;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
return out ?? columns;
|
|
194
|
+
}
|
package/src/errors.ts
CHANGED
|
@@ -1,13 +1,33 @@
|
|
|
1
1
|
// Copyright 2025, 2026 Query Farm LLC - https://query.farm
|
|
2
2
|
// VGI-specific error classes.
|
|
3
|
+
//
|
|
4
|
+
// Each class declares the canonical gRPC-style code vgi-rpc hoists onto the
|
|
5
|
+
// EXCEPTION batch as `vgi_rpc.error_code` (vgi-rpc WIRE_PROTOCOL.md §8), so a
|
|
6
|
+
// client — and DuckDB's `errors_as_json` — can tell "your input was wrong"
|
|
7
|
+
// from a worker bug. The mapping is shared with every other VGI SDK:
|
|
8
|
+
//
|
|
9
|
+
// INVALID_ARGUMENT argument validation / type rejection
|
|
10
|
+
// NOT_FOUND unknown function, table, schema, catalog
|
|
11
|
+
// ALREADY_EXISTS creating something that is already there
|
|
12
|
+
// FAILED_PRECONDITION writes against a read-only catalog
|
|
13
|
+
// UNIMPLEMENTED an operation the SDK does not support
|
|
14
|
+
//
|
|
15
|
+
// Anything else (RowCountMismatchError, internal invariants) stays UNKNOWN.
|
|
16
|
+
|
|
17
|
+
import type { ErrorCode } from "@query-farm/vgi-rpc";
|
|
3
18
|
|
|
4
19
|
export class VgiError extends Error {
|
|
5
|
-
|
|
20
|
+
/** Canonical code hoisted as `vgi_rpc.error_code`; unset means `UNKNOWN`. */
|
|
21
|
+
readonly errorCode?: ErrorCode;
|
|
22
|
+
|
|
23
|
+
constructor(message: string, code?: ErrorCode) {
|
|
6
24
|
super(message);
|
|
7
25
|
this.name = "VgiError";
|
|
26
|
+
if (code !== undefined) this.errorCode = code;
|
|
8
27
|
}
|
|
9
28
|
}
|
|
10
29
|
|
|
30
|
+
/** A worker bug (the function returned the wrong number of rows): UNKNOWN. */
|
|
11
31
|
export class RowCountMismatchError extends VgiError {
|
|
12
32
|
constructor(expected: number, actual: number) {
|
|
13
33
|
super(
|
|
@@ -20,42 +40,42 @@ export class RowCountMismatchError extends VgiError {
|
|
|
20
40
|
|
|
21
41
|
export class FunctionNotFoundError extends VgiError {
|
|
22
42
|
constructor(name: string, available?: string[]) {
|
|
23
|
-
super(`Unknown function '${name}'
|
|
43
|
+
super(`Unknown function '${name}'`, "NOT_FOUND");
|
|
24
44
|
this.name = "FunctionNotFoundError";
|
|
25
45
|
}
|
|
26
46
|
}
|
|
27
47
|
|
|
28
48
|
export class CatalogReadOnlyError extends VgiError {
|
|
29
49
|
constructor(operation: string) {
|
|
30
|
-
super(`catalog is read-only: ${operation} is not supported
|
|
50
|
+
super(`catalog is read-only: ${operation} is not supported`, "FAILED_PRECONDITION");
|
|
31
51
|
this.name = "CatalogReadOnlyError";
|
|
32
52
|
}
|
|
33
53
|
}
|
|
34
54
|
|
|
35
55
|
export class CatalogNotFoundError extends VgiError {
|
|
36
56
|
constructor(entity: string, name: string) {
|
|
37
|
-
super(`${entity} '${name}' not found
|
|
57
|
+
super(`${entity} '${name}' not found`, "NOT_FOUND");
|
|
38
58
|
this.name = "CatalogNotFoundError";
|
|
39
59
|
}
|
|
40
60
|
}
|
|
41
61
|
|
|
42
62
|
export class CatalogAlreadyExistsError extends VgiError {
|
|
43
63
|
constructor(entity: string, name: string) {
|
|
44
|
-
super(`${entity} '${name}' already exists
|
|
64
|
+
super(`${entity} '${name}' already exists`, "ALREADY_EXISTS");
|
|
45
65
|
this.name = "CatalogAlreadyExistsError";
|
|
46
66
|
}
|
|
47
67
|
}
|
|
48
68
|
|
|
49
69
|
export class ArgumentValidationError extends VgiError {
|
|
50
70
|
constructor(message: string) {
|
|
51
|
-
super(message);
|
|
71
|
+
super(message, "INVALID_ARGUMENT");
|
|
52
72
|
this.name = "ArgumentValidationError";
|
|
53
73
|
}
|
|
54
74
|
}
|
|
55
75
|
|
|
56
76
|
export class NoCatalogError extends VgiError {
|
|
57
77
|
constructor() {
|
|
58
|
-
super("No catalog is configured for this worker");
|
|
78
|
+
super("No catalog is configured for this worker", "UNIMPLEMENTED");
|
|
59
79
|
this.name = "NoCatalogError";
|
|
60
80
|
}
|
|
61
81
|
}
|
|
@@ -10,7 +10,7 @@ import type { VgiSchema } from "../arrow/index.js";
|
|
|
10
10
|
import type { VgiFunction } from "./types.js";
|
|
11
11
|
import type { Arguments } from "../arguments/arguments.js";
|
|
12
12
|
import type { ArgumentSpec } from "../arguments/argument-spec.js";
|
|
13
|
-
import { FunctionNotFoundError } from "../errors.js";
|
|
13
|
+
import { FunctionNotFoundError, VgiError } from "../errors.js";
|
|
14
14
|
import { schemaPathDisplay, schemaPathKey } from "../schema-path.js";
|
|
15
15
|
|
|
16
16
|
export interface OverloadContext {
|
|
@@ -289,9 +289,10 @@ export class FunctionRegistry {
|
|
|
289
289
|
} else if (candidates && candidates.length > 0) {
|
|
290
290
|
const schemas = this.schemasFor(name);
|
|
291
291
|
if (schemas.length > 0) {
|
|
292
|
-
throw new
|
|
292
|
+
throw new VgiError(
|
|
293
293
|
`Function '${name}' is not registered in schema ${schemaPathDisplay(schemaPath)}. ` +
|
|
294
294
|
`It is available in: [${schemas.map(schemaPathDisplay).join(", ")}]`,
|
|
295
|
+
"NOT_FOUND",
|
|
295
296
|
);
|
|
296
297
|
}
|
|
297
298
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// GENERATED by vgi.codegen.ts_client. DO NOT EDIT BY HAND.
|
|
3
3
|
//
|
|
4
4
|
// Generator: vgi-gen-ts-client v1
|
|
5
|
-
// Content hash:
|
|
5
|
+
// Content hash: 8d7e1d802d5f
|
|
6
6
|
//
|
|
7
7
|
// To regenerate:
|
|
8
8
|
// uv run --project ~/Development/vgi-python vgi-gen-ts-client \
|
|
@@ -56,7 +56,6 @@ export interface CatalogInfo {
|
|
|
56
56
|
export interface SchemaInfo {
|
|
57
57
|
comment?: string | null;
|
|
58
58
|
tags: Record<string, string>;
|
|
59
|
-
attach_opaque_data: Uint8Array;
|
|
60
59
|
path: string[];
|
|
61
60
|
estimated_object_count?: Record<string, number> | null;
|
|
62
61
|
}
|
|
@@ -430,24 +429,16 @@ export interface CatalogsResponse {
|
|
|
430
429
|
items: CatalogInfo[];
|
|
431
430
|
}
|
|
432
431
|
|
|
433
|
-
export interface SchemaContents {
|
|
434
|
-
path: string[];
|
|
435
|
-
schema: Uint8Array;
|
|
436
|
-
tables: Uint8Array[];
|
|
437
|
-
views: Uint8Array[];
|
|
438
|
-
scalar_functions: Uint8Array[];
|
|
439
|
-
aggregate_functions: Uint8Array[];
|
|
440
|
-
table_functions: Uint8Array[];
|
|
441
|
-
scalar_macros: Uint8Array[];
|
|
442
|
-
table_macros: Uint8Array[];
|
|
443
|
-
indexes: Uint8Array[];
|
|
444
|
-
}
|
|
445
|
-
|
|
446
432
|
export interface CatalogContentsResponse {
|
|
447
433
|
catalog_version: number;
|
|
448
434
|
etag?: string | null;
|
|
449
435
|
not_modified: boolean;
|
|
450
|
-
schemas
|
|
436
|
+
schemas?: Uint8Array | null;
|
|
437
|
+
tables?: Uint8Array | null;
|
|
438
|
+
views?: Uint8Array | null;
|
|
439
|
+
functions?: Uint8Array | null;
|
|
440
|
+
macros?: Uint8Array | null;
|
|
441
|
+
indexes?: Uint8Array | null;
|
|
451
442
|
}
|
|
452
443
|
|
|
453
444
|
export interface CopyFromFormatsResponse {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// GENERATED by vgi.codegen.ts_schemas. DO NOT EDIT BY HAND.
|
|
3
3
|
//
|
|
4
4
|
// Generator: vgi-gen-ts-schemas v2
|
|
5
|
-
// Content hash:
|
|
5
|
+
// Content hash: 01ae91ad3f0d
|
|
6
6
|
//
|
|
7
7
|
// To regenerate:
|
|
8
8
|
// uv run --project ~/Development/vgi-python vgi-gen-ts-schemas \
|
|
@@ -29,6 +29,9 @@ import {
|
|
|
29
29
|
utf8,
|
|
30
30
|
} from "../arrow/index.js";
|
|
31
31
|
|
|
32
|
+
/** Canonical fingerprint of the nested catalog wire schemas. */
|
|
33
|
+
export const VGI_CATALOG_CONTRACT_HASH = "121e8fe1c074bce00a6d0fcec49d7a90f05e45498cd9ca8a5a3b4a9ae2377a2d";
|
|
34
|
+
|
|
32
35
|
// Origin: CatalogInfo
|
|
33
36
|
export const CatalogInfoSchema = schema([
|
|
34
37
|
field("name", utf8(), false),
|
|
@@ -43,7 +46,6 @@ export const CatalogInfoSchema = schema([
|
|
|
43
46
|
export const SchemaInfoSchema = schema([
|
|
44
47
|
field("comment", utf8(), true),
|
|
45
48
|
field("tags", map(field("key", utf8(), false), field("value", utf8(), true), false), false),
|
|
46
|
-
field("attach_opaque_data", binary(), false),
|
|
47
49
|
field("path", list(field("item", utf8(), true)), false),
|
|
48
50
|
field("estimated_object_count", map(field("key", utf8(), false), field("value", int64(), true), false), true),
|
|
49
51
|
]);
|
|
@@ -90,9 +92,9 @@ export const FunctionInfoSchema = schema([
|
|
|
90
92
|
field("name", utf8(), false),
|
|
91
93
|
field("schema_path", list(field("item", utf8(), true)), false),
|
|
92
94
|
field("function_type", dictionary(utf8(), int16()), false),
|
|
93
|
-
field("arguments", binary(), false),
|
|
94
|
-
field("output_schema", binary(), false),
|
|
95
|
-
field("parameter_default_values", binary(), true),
|
|
95
|
+
field("arguments", dictionary(binary(), int32()), false),
|
|
96
|
+
field("output_schema", dictionary(binary(), int32()), false),
|
|
97
|
+
field("parameter_default_values", dictionary(binary(), int32()), true),
|
|
96
98
|
field("stability", dictionary(utf8(), int16()), true),
|
|
97
99
|
field("null_handling", dictionary(utf8(), int16()), true),
|
|
98
100
|
field("argument_monotonicity", list(field("item", utf8(), true)), true),
|
|
@@ -665,7 +667,12 @@ export const CatalogContentsResultSchema = schema([
|
|
|
665
667
|
field("catalog_version", int64(), false),
|
|
666
668
|
field("etag", utf8(), true),
|
|
667
669
|
field("not_modified", bool(), false),
|
|
668
|
-
field("schemas",
|
|
670
|
+
field("schemas", binary(), true),
|
|
671
|
+
field("tables", binary(), true),
|
|
672
|
+
field("views", binary(), true),
|
|
673
|
+
field("functions", binary(), true),
|
|
674
|
+
field("macros", binary(), true),
|
|
675
|
+
field("indexes", binary(), true),
|
|
669
676
|
]);
|
|
670
677
|
|
|
671
678
|
// Origin: method 'catalog_copy_from_formats' result
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// GENERATED by vgi.codegen.ts_types. DO NOT EDIT BY HAND.
|
|
3
3
|
//
|
|
4
4
|
// Generator: python -m vgi.codegen.ts_types v1
|
|
5
|
-
// Content hash:
|
|
5
|
+
// Content hash: 65401a7ca1e1
|
|
6
6
|
//
|
|
7
7
|
// To regenerate:
|
|
8
8
|
// uv run --project ~/Development/vgi-python python scripts/regen_generated.py
|
|
@@ -14,8 +14,8 @@ import {
|
|
|
14
14
|
CatalogContentsResultSchema,
|
|
15
15
|
SchemaContentsSchema,
|
|
16
16
|
} from "./vgi-protocol-schemas.js";
|
|
17
|
-
import type { CatalogAttachResult, CatalogContentsResponse
|
|
18
|
-
export type { CatalogAttachResult, CatalogContentsResponse
|
|
17
|
+
import type { CatalogAttachResult, CatalogContentsResponse } from "./vgi-client.js";
|
|
18
|
+
export type { CatalogAttachResult, CatalogContentsResponse };
|
|
19
19
|
|
|
20
20
|
// ----------------------------------------------------------------------------
|
|
21
21
|
// CatalogAttachResult (schema: CatalogAttachResultSchema)
|
|
@@ -68,6 +68,30 @@ export const decodeCatalogAttachResult = (b: Uint8Array): CatalogAttachResult =>
|
|
|
68
68
|
// SchemaContents (schema: SchemaContentsSchema)
|
|
69
69
|
// ----------------------------------------------------------------------------
|
|
70
70
|
|
|
71
|
+
/** One schema and everything in it: one struct row of `CatalogContentsResponse.schemas`. Every item is byte-for-byte what the matching per-schema RPC returns in its `items` list, so a client decodes them with the decoders it already has. Each kind is complete: an empty list means the schema has none of that kind. */
|
|
72
|
+
export interface SchemaContents {
|
|
73
|
+
/** The schema path. Equals `SchemaInfo.path` inside `schema`, so a client can name the schema without decoding it. */
|
|
74
|
+
path: string[];
|
|
75
|
+
/** The schema's `SchemaInfo` item (a `catalog_schemas` entry). */
|
|
76
|
+
schema: Uint8Array;
|
|
77
|
+
/** `TableInfo` items (`catalog_schema_contents_tables`). */
|
|
78
|
+
tables: Uint8Array[];
|
|
79
|
+
/** `ViewInfo` items (`catalog_schema_contents_views`). */
|
|
80
|
+
views: Uint8Array[];
|
|
81
|
+
/** `FunctionInfo` items, `SCALAR_FUNCTION`. */
|
|
82
|
+
scalar_functions: Uint8Array[];
|
|
83
|
+
/** `FunctionInfo` items, `AGGREGATE_FUNCTION`. */
|
|
84
|
+
aggregate_functions: Uint8Array[];
|
|
85
|
+
/** `FunctionInfo` items, `TABLE_FUNCTION`. */
|
|
86
|
+
table_functions: Uint8Array[];
|
|
87
|
+
/** `MacroInfo` items, `SCALAR_MACRO`. */
|
|
88
|
+
scalar_macros: Uint8Array[];
|
|
89
|
+
/** `MacroInfo` items, `TABLE_MACRO`. */
|
|
90
|
+
table_macros: Uint8Array[];
|
|
91
|
+
/** `IndexInfo` items (`catalog_schema_contents_indexes`). */
|
|
92
|
+
indexes: Uint8Array[];
|
|
93
|
+
}
|
|
94
|
+
|
|
71
95
|
/** Fields of `SchemaContents` that have a protocol default. */
|
|
72
96
|
export type SchemaContentsDefaultedField =
|
|
73
97
|
| "tables"
|
|
@@ -108,7 +132,12 @@ export const decodeSchemaContents = (b: Uint8Array): SchemaContents => decodeASD
|
|
|
108
132
|
export type CatalogContentsResponseDefaultedField =
|
|
109
133
|
| "etag"
|
|
110
134
|
| "not_modified"
|
|
111
|
-
| "schemas"
|
|
135
|
+
| "schemas"
|
|
136
|
+
| "tables"
|
|
137
|
+
| "views"
|
|
138
|
+
| "functions"
|
|
139
|
+
| "macros"
|
|
140
|
+
| "indexes";
|
|
112
141
|
/** `CatalogContentsResponse` with every field that has a protocol default optional. */
|
|
113
142
|
export type CatalogContentsResponseInit = Omit<CatalogContentsResponse, CatalogContentsResponseDefaultedField> & Partial<Pick<CatalogContentsResponse, CatalogContentsResponseDefaultedField>>;
|
|
114
143
|
|
|
@@ -118,7 +147,12 @@ export function buildCatalogContentsResponse(init: CatalogContentsResponseInit):
|
|
|
118
147
|
catalog_version: init.catalog_version,
|
|
119
148
|
etag: init.etag ?? null,
|
|
120
149
|
not_modified: init.not_modified ?? false,
|
|
121
|
-
schemas: init.schemas ??
|
|
150
|
+
schemas: init.schemas ?? null,
|
|
151
|
+
tables: init.tables ?? null,
|
|
152
|
+
views: init.views ?? null,
|
|
153
|
+
functions: init.functions ?? null,
|
|
154
|
+
macros: init.macros ?? null,
|
|
155
|
+
indexes: init.indexes ?? null,
|
|
122
156
|
};
|
|
123
157
|
}
|
|
124
158
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// GENERATED by vgi.codegen.ts_registry. DO NOT EDIT BY HAND.
|
|
3
3
|
//
|
|
4
4
|
// Generator: python -m vgi.codegen.ts_registry v1
|
|
5
|
-
// Content hash:
|
|
5
|
+
// Content hash: 56897005f0e2
|
|
6
6
|
//
|
|
7
7
|
// To regenerate:
|
|
8
8
|
// uv run --project ~/Development/vgi-python python scripts/regen_generated.py
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
import {
|
|
11
11
|
type CallContext,
|
|
12
12
|
type ExchangeFn,
|
|
13
|
+
type ExternalRef,
|
|
13
14
|
type ExchangeInit,
|
|
14
15
|
type HeaderInit,
|
|
15
16
|
MethodNotImplementedError,
|
|
@@ -37,10 +38,10 @@ import {
|
|
|
37
38
|
export const VGI_PROTOCOL_NAME = "vgi.v2";
|
|
38
39
|
|
|
39
40
|
/** The protocol's semver, stamped on every request by a client of this protocol. */
|
|
40
|
-
export const VGI_PROTOCOL_VERSION = "2.
|
|
41
|
+
export const VGI_PROTOCOL_VERSION = "2.2.0";
|
|
41
42
|
|
|
42
43
|
/** What a unary handler returns: the result row, now or later. */
|
|
43
|
-
export type VgiReply<T> = T | Promise<T>;
|
|
44
|
+
export type VgiReply<T> = T | ExternalRef | Promise<T | ExternalRef>;
|
|
44
45
|
|
|
45
46
|
/** The result of a unary method with no `result` column. */
|
|
46
47
|
export type NoResult = Record<string, never>;
|
package/src/http/fetch.ts
CHANGED
|
@@ -207,7 +207,7 @@ export function createVgiFetch(opts: VgiFetchOptions): (req: Request) => Promise
|
|
|
207
207
|
|
|
208
208
|
// The same builder every other transport uses: `vgi.v2`, the worker's
|
|
209
209
|
// hostedProtocols(), reflection, and -- HTTP being the transport that
|
|
210
|
-
// authenticates callers -- vgi_rpc.Identity.
|
|
210
|
+
// authenticates callers -- vgi_rpc.Identity.v2 when the worker opts in.
|
|
211
211
|
// Built at construction, so a worker that opts into introspection without an
|
|
212
212
|
// allowlist fails here rather than serving traffic.
|
|
213
213
|
const server = buildRpcServer(protocol, opts, {
|
package/src/index.core.ts
CHANGED
|
@@ -186,8 +186,10 @@ export {
|
|
|
186
186
|
AttachTicketInvalidError,
|
|
187
187
|
AttachTicketRequestError,
|
|
188
188
|
SealAttachDeniedError,
|
|
189
|
+
type AttachTicket,
|
|
189
190
|
type AttachTicketClaims,
|
|
190
191
|
type RestoredAttach,
|
|
192
|
+
encodeAttachTicket,
|
|
191
193
|
attachTicketAad,
|
|
192
194
|
mintAttachTicket,
|
|
193
195
|
openAttachTicket,
|
|
@@ -338,7 +340,7 @@ export { str, bytes, int, int32, float, float32, bool, toSchema, OutputCollector
|
|
|
338
340
|
export { subprocessConnect, httpConnect, tcpConnect } from "@query-farm/vgi-rpc";
|
|
339
341
|
export type { RpcClient, StreamSession, LogMessage } from "@query-farm/vgi-rpc";
|
|
340
342
|
|
|
341
|
-
// Hosting additional protocols and opting into vgi_rpc.Identity.
|
|
343
|
+
// Hosting additional protocols and opting into vgi_rpc.Identity.v2. The errors
|
|
342
344
|
// are re-exported so a worker's resolveToken/mintGrant can throw the right one:
|
|
343
345
|
// AuthUnavailableError (or IdentityUnavailableError) for "could not find out",
|
|
344
346
|
// GrantRefusedError to decline a grant.
|
package/src/index.ts
CHANGED
|
@@ -9,3 +9,8 @@ export * from "./index.core.js";
|
|
|
9
9
|
|
|
10
10
|
// Worker (node/bun only — stdio + AF_UNIX launcher transport)
|
|
11
11
|
export { Worker, type WorkerConfig } from "./worker.js";
|
|
12
|
+
|
|
13
|
+
export { CatalogSnapshotManager, MemoryCatalogPublicationRepository, S3CatalogPublicationRepository } from "./catalog/publication.js";
|
|
14
|
+
export type { CatalogSnapshotPolicy, SnapshotIdentity, SnapshotRequest, CatalogPublicationManifest, CatalogPublicationRepository, CatalogManifestObjectStore } from "./catalog/publication.js";
|
|
15
|
+
export { S3CatalogObjectStorage } from "./catalog/s3-publication.js";
|
|
16
|
+
export type { CatalogS3Signer } from "./catalog/s3-publication.js";
|
package/src/protocol/dispatch.ts
CHANGED
|
@@ -69,7 +69,7 @@ export { VGI_PROTOCOL_NAME };
|
|
|
69
69
|
* hash covers method names, types and the params/result/header schemas only
|
|
70
70
|
* (WIRE_PROTOCOL.md §14).
|
|
71
71
|
*
|
|
72
|
-
* It changes only with vgi.v2's protocol version (currently 2.
|
|
72
|
+
* It changes only with vgi.v2's protocol version (currently 2.2.0). Asserted
|
|
73
73
|
* by src/protocol/__tests__/vgi-v2-hash.test.ts; if that test fails, the
|
|
74
74
|
* surface drifted from the reference -- fix the schemas, do not bump this.
|
|
75
75
|
*/
|
|
@@ -207,10 +207,13 @@ export function catalogAdminHandlers(getCatalog: GetCatalog, signingKey?: Uint8A
|
|
|
207
207
|
// the committed catalog at catalog_version. `if_none_match` revalidates a
|
|
208
208
|
// snapshot the client holds (etag / not_modified); see ./contents.ts for the
|
|
209
209
|
// rules, the content-hash etag and the frozen-catalog cache.
|
|
210
|
-
const catalogContents =
|
|
211
|
-
const
|
|
212
|
-
return
|
|
213
|
-
|
|
210
|
+
const catalogContents: VgiService["catalogContents"] = async (params, ctx) => {
|
|
211
|
+
const sealedAttach = toUint8Array(params.attach_opaque_data).slice();
|
|
212
|
+
return catalogHandler(signingKey, async (opened, context) => {
|
|
213
|
+
const ifNoneMatch = opened.if_none_match == null ? null : String(opened.if_none_match);
|
|
214
|
+
return serveCatalogContents(getCatalog(), toUint8Array(opened.attach_opaque_data), ifNoneMatch, context, sealedAttach);
|
|
215
|
+
})(params, ctx);
|
|
216
|
+
};
|
|
214
217
|
|
|
215
218
|
// catalog_copy_from_formats — catalog-level (not schema-scoped). Lists the
|
|
216
219
|
// custom COPY ... FROM formats this catalog advertises; empty list when none.
|