@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
|
@@ -1,25 +1,26 @@
|
|
|
1
1
|
// Copyright 2025, 2026 Query Farm LLC - https://query.farm
|
|
2
|
-
// Catalog handler orchestrator:
|
|
2
|
+
// Catalog handler orchestrator: every catalog_* `vgi.v2` handler.
|
|
3
3
|
|
|
4
|
-
import { Protocol } from "@query-farm/vgi-rpc";
|
|
5
4
|
import type { CatalogInterface } from "../../../catalog/interface.js";
|
|
5
|
+
import type { VgiService } from "../../../generated/vgi-service.js";
|
|
6
6
|
import { makeGetCatalog } from "./shared.js";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
7
|
+
import { catalogAdminHandlers } from "./admin.js";
|
|
8
|
+
import { catalogTableHandlers } from "./table.js";
|
|
9
|
+
import { catalogViewHandlers } from "./view.js";
|
|
10
|
+
import { catalogMacroHandlers } from "./macro.js";
|
|
11
|
+
import { catalogIndexHandlers } from "./index_methods.js";
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
/** The catalog_* `vgi.v2` handlers, over *catalog* (or `NoCatalogError` without one). */
|
|
14
|
+
export function catalogHandlers(
|
|
15
15
|
catalog: CatalogInterface | undefined,
|
|
16
|
-
_catalogName: string | undefined,
|
|
17
16
|
signingKey?: Uint8Array,
|
|
18
|
-
):
|
|
17
|
+
): Partial<VgiService> {
|
|
19
18
|
const getCatalog = makeGetCatalog(catalog);
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
return {
|
|
20
|
+
...catalogAdminHandlers(getCatalog, signingKey),
|
|
21
|
+
...catalogTableHandlers(getCatalog, signingKey),
|
|
22
|
+
...catalogViewHandlers(getCatalog, signingKey),
|
|
23
|
+
...catalogMacroHandlers(getCatalog, signingKey),
|
|
24
|
+
...catalogIndexHandlers(getCatalog, signingKey),
|
|
25
|
+
};
|
|
25
26
|
}
|
|
@@ -1,58 +1,48 @@
|
|
|
1
1
|
// Copyright 2025, 2026 Query Farm LLC - https://query.farm
|
|
2
2
|
// Catalog index handlers: index_get, schema_contents_indexes.
|
|
3
3
|
|
|
4
|
-
import
|
|
5
|
-
import { Protocol } from "@query-farm/vgi-rpc";
|
|
4
|
+
import type { VgiService } from "../../../generated/vgi-service.js";
|
|
6
5
|
import { encodeIndexInfo } from "../../../generated/vgi-client.js";
|
|
7
6
|
import {
|
|
8
|
-
CatalogIndexGetParamsSchema,
|
|
9
7
|
CatalogIndexGetResultSchema,
|
|
10
|
-
CatalogSchemaContentsIndexesParamsSchema,
|
|
11
8
|
CatalogSchemaContentsIndexesResultSchema,
|
|
12
9
|
} from "../../../generated/vgi-protocol-schemas.js";
|
|
13
10
|
import { toUint8Array } from "../../../util/bytes.js";
|
|
14
11
|
import {
|
|
15
|
-
RESULT_BINARY_SCHEMA,
|
|
16
12
|
wrapResult,
|
|
17
13
|
} from "../shared.js";
|
|
18
14
|
import {
|
|
19
15
|
type GetCatalog,
|
|
20
|
-
|
|
16
|
+
catalogHandler,
|
|
21
17
|
} from "./shared.js";
|
|
22
18
|
|
|
23
|
-
export function
|
|
19
|
+
export function catalogIndexHandlers(getCatalog: GetCatalog, signingKey?: Uint8Array): Partial<VgiService> {
|
|
24
20
|
// catalog_schema_contents_indexes
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
return wrapResult({
|
|
36
|
-
items: indexes.map((i) => encodeIndexInfo(i)),
|
|
37
|
-
}, CatalogSchemaContentsIndexesResultSchema);
|
|
38
|
-
},
|
|
21
|
+
const catalogSchemaContentsIndexes = catalogHandler(signingKey, async (params) => {
|
|
22
|
+
const cat = getCatalog();
|
|
23
|
+
const indexes = await cat.schemaContentsIndexes(
|
|
24
|
+
toUint8Array(params.attach_opaque_data),
|
|
25
|
+
params.path,
|
|
26
|
+
params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined,
|
|
27
|
+
);
|
|
28
|
+
return wrapResult({
|
|
29
|
+
items: indexes.map((i) => encodeIndexInfo(i)),
|
|
30
|
+
}, CatalogSchemaContentsIndexesResultSchema);
|
|
39
31
|
});
|
|
40
32
|
|
|
41
33
|
// catalog_index_get
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return wrapResult({
|
|
54
|
-
items: info ? [encodeIndexInfo(info)] : [],
|
|
55
|
-
}, CatalogIndexGetResultSchema);
|
|
56
|
-
},
|
|
34
|
+
const catalogIndexGet = catalogHandler(signingKey, async (params) => {
|
|
35
|
+
const cat = getCatalog();
|
|
36
|
+
const info = await cat.indexGet(
|
|
37
|
+
toUint8Array(params.attach_opaque_data),
|
|
38
|
+
params.schema_path,
|
|
39
|
+
params.name,
|
|
40
|
+
params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined,
|
|
41
|
+
);
|
|
42
|
+
return wrapResult({
|
|
43
|
+
items: info ? [encodeIndexInfo(info)] : [],
|
|
44
|
+
}, CatalogIndexGetResultSchema);
|
|
57
45
|
});
|
|
46
|
+
|
|
47
|
+
return { catalogSchemaContentsIndexes, catalogIndexGet };
|
|
58
48
|
}
|
|
@@ -1,107 +1,84 @@
|
|
|
1
1
|
// Copyright 2025, 2026 Query Farm LLC - https://query.farm
|
|
2
2
|
// Catalog macro handlers: macro_get/create/drop, schema_contents_macros.
|
|
3
3
|
|
|
4
|
-
import
|
|
5
|
-
import { Protocol } from "@query-farm/vgi-rpc";
|
|
4
|
+
import type { VgiService } from "../../../generated/vgi-service.js";
|
|
6
5
|
import { encodeMacroInfo } from "../../../generated/vgi-client.js";
|
|
7
6
|
import {
|
|
8
|
-
CatalogMacroCreateParamsSchema,
|
|
9
|
-
CatalogMacroDropParamsSchema,
|
|
10
|
-
CatalogMacroGetParamsSchema,
|
|
11
7
|
CatalogMacroGetResultSchema,
|
|
12
|
-
CatalogSchemaContentsMacrosParamsSchema,
|
|
13
8
|
CatalogSchemaContentsMacrosResultSchema,
|
|
14
9
|
} from "../../../generated/vgi-protocol-schemas.js";
|
|
15
10
|
import type { MacroType } from "../../../catalog/interface.js";
|
|
16
11
|
import { toUint8Array } from "../../../util/bytes.js";
|
|
17
12
|
import { decodeDictValue } from "../../../util/arrow/index.js";
|
|
18
13
|
import {
|
|
19
|
-
REQUEST_PARAMS_SCHEMA,
|
|
20
|
-
RESULT_BINARY_SCHEMA,
|
|
21
|
-
unwrapRequest,
|
|
22
14
|
wrapResult,
|
|
23
15
|
} from "../shared.js";
|
|
24
16
|
import {
|
|
25
17
|
type GetCatalog,
|
|
26
|
-
|
|
27
|
-
catalogUnary,
|
|
18
|
+
catalogHandler,
|
|
28
19
|
} from "./shared.js";
|
|
29
20
|
|
|
30
|
-
export function
|
|
21
|
+
export function catalogMacroHandlers(getCatalog: GetCatalog, signingKey?: Uint8Array): Partial<VgiService> {
|
|
31
22
|
// catalog_macro_get
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
return wrapResult({
|
|
44
|
-
items: info ? [encodeMacroInfo(info)] : [],
|
|
45
|
-
}, CatalogMacroGetResultSchema);
|
|
46
|
-
},
|
|
23
|
+
const catalogMacroGet = catalogHandler(signingKey, async (params) => {
|
|
24
|
+
const cat = getCatalog();
|
|
25
|
+
const info = await cat.macroGet(
|
|
26
|
+
toUint8Array(params.attach_opaque_data),
|
|
27
|
+
params.schema_path,
|
|
28
|
+
params.name,
|
|
29
|
+
params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined
|
|
30
|
+
);
|
|
31
|
+
return wrapResult({
|
|
32
|
+
items: info ? [encodeMacroInfo(info)] : [],
|
|
33
|
+
}, CatalogMacroGetResultSchema);
|
|
47
34
|
});
|
|
48
35
|
|
|
49
36
|
// catalog_macro_create
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
innerParams.transaction_opaque_data ? toUint8Array(innerParams.transaction_opaque_data) : undefined
|
|
68
|
-
);
|
|
69
|
-
return {};
|
|
70
|
-
},
|
|
37
|
+
const catalogMacroCreate = catalogHandler(signingKey, async (params) => {
|
|
38
|
+
const cat = getCatalog();
|
|
39
|
+
// catalogHandler already flattened the wrapped request.
|
|
40
|
+
const innerParams = params;
|
|
41
|
+
await cat.macroCreate(
|
|
42
|
+
toUint8Array(innerParams.attach_opaque_data),
|
|
43
|
+
innerParams.schema_path,
|
|
44
|
+
innerParams.name,
|
|
45
|
+
innerParams.macro_type as MacroType,
|
|
46
|
+
innerParams.parameters ? (Array.isArray(innerParams.parameters) ? innerParams.parameters : [...innerParams.parameters]) : [],
|
|
47
|
+
innerParams.definition,
|
|
48
|
+
innerParams.on_conflict,
|
|
49
|
+
innerParams.parameter_default_values ? toUint8Array(innerParams.parameter_default_values) : null,
|
|
50
|
+
innerParams.arguments_schema ? toUint8Array(innerParams.arguments_schema) : null,
|
|
51
|
+
innerParams.transaction_opaque_data ? toUint8Array(innerParams.transaction_opaque_data) : undefined
|
|
52
|
+
);
|
|
53
|
+
return {};
|
|
71
54
|
});
|
|
72
55
|
|
|
73
56
|
// catalog_macro_drop
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined
|
|
85
|
-
);
|
|
86
|
-
return {};
|
|
87
|
-
},
|
|
57
|
+
const catalogMacroDrop = catalogHandler(signingKey, async (params) => {
|
|
58
|
+
const cat = getCatalog();
|
|
59
|
+
await cat.macroDrop(
|
|
60
|
+
toUint8Array(params.attach_opaque_data),
|
|
61
|
+
params.schema_path,
|
|
62
|
+
params.name,
|
|
63
|
+
params.ignore_not_found,
|
|
64
|
+
params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined
|
|
65
|
+
);
|
|
66
|
+
return {};
|
|
88
67
|
});
|
|
89
68
|
|
|
90
69
|
// catalog_schema_contents_macros
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
return wrapResult({
|
|
103
|
-
items: macros.map((m) => encodeMacroInfo(m)),
|
|
104
|
-
}, CatalogSchemaContentsMacrosResultSchema);
|
|
105
|
-
},
|
|
70
|
+
const catalogSchemaContentsMacros = catalogHandler(signingKey, async (params) => {
|
|
71
|
+
const cat = getCatalog();
|
|
72
|
+
const macros = await cat.schemaContentsMacros(
|
|
73
|
+
toUint8Array(params.attach_opaque_data),
|
|
74
|
+
params.path,
|
|
75
|
+
decodeDictValue(params.type),
|
|
76
|
+
params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined
|
|
77
|
+
);
|
|
78
|
+
return wrapResult({
|
|
79
|
+
items: macros.map((m) => encodeMacroInfo(m)),
|
|
80
|
+
}, CatalogSchemaContentsMacrosResultSchema);
|
|
106
81
|
});
|
|
82
|
+
|
|
83
|
+
return { catalogMacroGet, catalogMacroCreate, catalogMacroDrop, catalogSchemaContentsMacros };
|
|
107
84
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// Copyright 2025, 2026 Query Farm LLC - https://query.farm
|
|
2
2
|
// Shared param schemas and helpers for catalog protocol handlers.
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { iterRows } from "../../../arrow/index.js";
|
|
5
|
+
import type { AuthContext, CallContext } from "@query-farm/vgi-rpc";
|
|
6
6
|
import type { CatalogInterface } from "../../../catalog/interface.js";
|
|
7
7
|
import { NoCatalogError } from "../../../errors.js";
|
|
8
8
|
import { deserializeBatch } from "../../../util/arrow/index.js";
|
|
@@ -174,43 +174,32 @@ async function unwrapParamsOpaque(
|
|
|
174
174
|
}
|
|
175
175
|
|
|
176
176
|
/**
|
|
177
|
-
*
|
|
178
|
-
*
|
|
179
|
-
*
|
|
180
|
-
*
|
|
177
|
+
* Wrap a catalog unary handler so its request opaque-data fields are unwrapped
|
|
178
|
+
* before the body runs. Used for every catalog_* method except catalog_attach
|
|
179
|
+
* / catalog_transaction_begin, which seal their outputs and are written
|
|
180
|
+
* bespoke. The body sees the flattened params as a plain record.
|
|
181
181
|
*/
|
|
182
|
-
export function
|
|
183
|
-
protocol: Protocol,
|
|
182
|
+
export function catalogHandler<R>(
|
|
184
183
|
signingKey: Uint8Array | undefined,
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
// field off the envelope (all undefined) and macro_create handed the
|
|
205
|
-
// catalog an unopened attach value.
|
|
206
|
-
if (params.request != null && params.attach_opaque_data === undefined && params.name === undefined) {
|
|
207
|
-
params = unwrapRequest(params.request);
|
|
208
|
-
}
|
|
209
|
-
normalizeRequestSchemaPaths(params);
|
|
210
|
-
await unwrapParamsOpaque(params, ctx, signingKey);
|
|
211
|
-
return config.handler(params, ctx);
|
|
212
|
-
},
|
|
213
|
-
});
|
|
184
|
+
handler: (params: Record<string, any>, ctx: CallContext) => R | Promise<R>,
|
|
185
|
+
): (params: object, ctx: CallContext) => Promise<R> {
|
|
186
|
+
return async (wire: object, ctx: CallContext) => {
|
|
187
|
+
let params = wire as Record<string, any>;
|
|
188
|
+
// catalog_create / catalog_table_create / catalog_macro_create (and
|
|
189
|
+
// catalog_index_create) send one `request: binary` column holding the
|
|
190
|
+
// IPC-serialized request record, so their attach/transaction values ride
|
|
191
|
+
// INSIDE it. Flatten it first, so handlers read the request's fields
|
|
192
|
+
// directly and those values are opened (and the framework UUID stripped)
|
|
193
|
+
// like every other catalog call's. Before this, table_create read every
|
|
194
|
+
// field off the envelope (all undefined) and macro_create handed the
|
|
195
|
+
// catalog an unopened attach value.
|
|
196
|
+
if (params.request != null && params.attach_opaque_data === undefined && params.name === undefined) {
|
|
197
|
+
params = unwrapRequest(params.request);
|
|
198
|
+
}
|
|
199
|
+
normalizeRequestSchemaPaths(params);
|
|
200
|
+
await unwrapParamsOpaque(params, ctx, signingKey);
|
|
201
|
+
return handler(params, ctx);
|
|
202
|
+
};
|
|
214
203
|
}
|
|
215
204
|
|
|
216
205
|
export function makeGetCatalog(catalog: CatalogInterface | undefined): GetCatalog {
|
|
@@ -240,18 +229,12 @@ export function decodeOptionsBatch(bytes: any): Record<string, unknown> {
|
|
|
240
229
|
return row ?? {};
|
|
241
230
|
}
|
|
242
231
|
|
|
243
|
-
// ---------------------------------------------------------------------------
|
|
244
|
-
// Common param schemas
|
|
245
|
-
// ---------------------------------------------------------------------------
|
|
246
|
-
|
|
247
|
-
export const emptyResultSchema = schema([]);
|
|
248
|
-
|
|
249
232
|
// Eight hand-written catalog param schemas used to live here, restating shapes
|
|
250
|
-
// codegen already emits. Every
|
|
251
|
-
//
|
|
233
|
+
// codegen already emits. Every method's schemas now come from the generated
|
|
234
|
+
// registration table (src/generated/vgi-service.ts) and these were left behind, referenced by nothing but their
|
|
252
235
|
// own import lines. A stale duplicate is worse than no duplicate: the copies
|
|
253
236
|
// this SDK kept had drifted on `attach_opaque_data` nullability (45 generated
|
|
254
237
|
// schemas say non-null, every copy said nullable) and on `type` being
|
|
255
238
|
// dictionary-encoded utf8 rather than plain utf8, and the result was that a
|
|
256
|
-
// CORRECT client got rejected at the very first catalog call.
|
|
257
|
-
//
|
|
239
|
+
// CORRECT client got rejected at the very first catalog call. Never revive one:
|
|
240
|
+
// the registration table is generated, schemas and all.
|