@query-farm/vgi 0.48.4 → 0.49.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 +52 -1
- package/dist/attach-secret-keyfile.d.ts +11 -0
- package/dist/attach-secret-options.d.ts +96 -0
- package/dist/catalog/attach-option.d.ts +6 -0
- package/dist/catalog/composite.d.ts +2 -0
- package/dist/catalog/descriptors.d.ts +11 -0
- package/dist/catalog/interface.d.ts +54 -2
- package/dist/catalog/scan-planning.d.ts +76 -0
- package/dist/client-entry.js +32 -4
- package/dist/client-entry.js.map +9 -8
- package/dist/generated/vgi-client.d.ts +1 -0
- package/dist/generated/vgi-protocol-schemas.d.ts +1 -1
- package/dist/generated/vgi-service.d.ts +5 -1
- package/dist/index.core.d.ts +3 -0
- package/dist/index.js +3245 -2538
- package/dist/index.js.map +32 -29
- package/dist/protocol/dispatch.d.ts +13 -2
- package/dist/protocol/handlers/catalog/admin.d.ts +1 -1
- package/dist/protocol/handlers/catalog/index.d.ts +1 -1
- package/dist/protocol/handlers/catalog/index_methods.d.ts +1 -1
- package/dist/protocol/handlers/catalog/macro.d.ts +1 -1
- package/dist/protocol/handlers/catalog/shared.d.ts +28 -3
- package/dist/protocol/handlers/catalog/table.d.ts +1 -1
- package/dist/protocol/handlers/catalog/view.d.ts +1 -1
- package/dist/protocol/handlers/function.d.ts +2 -0
- package/dist/protocol/handlers/table-buffering.d.ts +1 -1
- package/dist/serve-entry.d.ts +5 -0
- package/dist/serve-entry.js +2026 -101
- package/dist/serve-entry.js.map +27 -20
- package/dist/worker-cf-entry.d.ts +2 -2
- package/dist/worker-cf-entry.js +823 -103
- package/dist/worker-cf-entry.js.map +27 -24
- package/dist/worker.d.ts +10 -0
- package/package.json +1 -1
- package/src/attach-secret-keyfile.ts +185 -0
- package/src/attach-secret-options.ts +418 -0
- package/src/catalog/attach-option.ts +6 -0
- package/src/catalog/column-metadata.ts +7 -0
- package/src/catalog/composite.ts +5 -0
- package/src/catalog/descriptors.ts +11 -0
- package/src/catalog/interface.ts +97 -2
- package/src/catalog/read-only.ts +14 -1
- package/src/catalog/scan-planning.ts +314 -0
- package/src/generated/vgi-client.ts +2 -1
- package/src/generated/vgi-protocol-schemas.ts +6 -2
- package/src/generated/vgi-service.ts +7 -2
- package/src/index.core.ts +21 -0
- package/src/protocol/dispatch.ts +16 -4
- package/src/protocol/handlers/catalog/admin.ts +33 -18
- package/src/protocol/handlers/catalog/index.ts +6 -5
- package/src/protocol/handlers/catalog/index_methods.ts +5 -3
- package/src/protocol/handlers/catalog/macro.ts +7 -5
- package/src/protocol/handlers/catalog/shared.ts +52 -6
- package/src/protocol/handlers/catalog/table.ts +43 -30
- package/src/protocol/handlers/catalog/view.ts +9 -7
- package/src/protocol/handlers/function.ts +11 -5
- package/src/protocol/handlers/table-buffering.ts +2 -1
- package/src/serve-entry.ts +6 -1
- package/src/worker-cf-entry.ts +9 -0
- package/src/worker.ts +12 -0
|
@@ -13,6 +13,8 @@ import {
|
|
|
13
13
|
ScanFunctionResultSchema,
|
|
14
14
|
} from "../../../generated/vgi-protocol-schemas.js";
|
|
15
15
|
import { toUint8Array } from "../../../util/bytes.js";
|
|
16
|
+
import { deserializeSchema } from "../../../arrow/index.js";
|
|
17
|
+
import { ScanPlanningFilters } from "../../../catalog/scan-planning.js";
|
|
16
18
|
import { requireCreateColumns } from "../../../catalog/unconstrained-columns.js";
|
|
17
19
|
import { CONSTRAINT_CREATE, CONSTRAINT_ENFORCE, CONSTRAINT_MUTATE, readConstraintRecord } from "../../../catalog/constraints.js";
|
|
18
20
|
import { decodeCatalogObjectRef } from "../../../generated/vgi-protocol-types.js";
|
|
@@ -22,6 +24,7 @@ import {
|
|
|
22
24
|
import {
|
|
23
25
|
type GetCatalog,
|
|
24
26
|
catalogHandler,
|
|
27
|
+
type OpaqueKeys,
|
|
25
28
|
} from "./shared.js";
|
|
26
29
|
|
|
27
30
|
function requireFlatColumnPath(value: unknown, operation: string): string[] {
|
|
@@ -35,9 +38,10 @@ function requireFlatColumnPath(value: unknown, operation: string): string[] {
|
|
|
35
38
|
return path as string[];
|
|
36
39
|
}
|
|
37
40
|
|
|
38
|
-
export function catalogTableHandlers(getCatalog: GetCatalog, signingKey?: Uint8Array): Partial<VgiService> {
|
|
41
|
+
export function catalogTableHandlers(getCatalog: GetCatalog, signingKey?: Uint8Array, attachSecretKey?: Uint8Array): Partial<VgiService> {
|
|
42
|
+
const keys: OpaqueKeys = { signingKey, attachSecretKey };
|
|
39
43
|
// catalog_table_get
|
|
40
|
-
const catalogTableGet = catalogHandler(
|
|
44
|
+
const catalogTableGet = catalogHandler(keys, async (params) => {
|
|
41
45
|
const cat = getCatalog();
|
|
42
46
|
const info = await cat.tableGet(
|
|
43
47
|
toUint8Array(params.attach_opaque_data),
|
|
@@ -53,7 +57,7 @@ export function catalogTableHandlers(getCatalog: GetCatalog, signingKey?: Uint8A
|
|
|
53
57
|
});
|
|
54
58
|
|
|
55
59
|
// catalog_table_create
|
|
56
|
-
const catalogTableCreate = catalogHandler(
|
|
60
|
+
const catalogTableCreate = catalogHandler(keys, async (params) => {
|
|
57
61
|
if (params.constraint_definitions == null) throw new Error("constraint_definitions is required");
|
|
58
62
|
const definitions = Array.from(params.constraint_definitions as Iterable<unknown>, (d) => toUint8Array(d as Uint8Array));
|
|
59
63
|
if (params.comment != null || params.tags != null || params.options != null || params.layout != null) {
|
|
@@ -89,7 +93,7 @@ export function catalogTableHandlers(getCatalog: GetCatalog, signingKey?: Uint8A
|
|
|
89
93
|
|
|
90
94
|
// catalog_table_constraints_apply (ALTER TABLE ... SET/DROP NOT NULL and
|
|
91
95
|
// every other canonical constraint change).
|
|
92
|
-
const catalogTableConstraintsApply = catalogHandler(
|
|
96
|
+
const catalogTableConstraintsApply = catalogHandler(keys, async (params) => {
|
|
93
97
|
const attach = toUint8Array(params.attach_opaque_data);
|
|
94
98
|
const cat = getCatalog();
|
|
95
99
|
const caps = await cat.catalogCapabilities(attach);
|
|
@@ -124,7 +128,7 @@ export function catalogTableHandlers(getCatalog: GetCatalog, signingKey?: Uint8A
|
|
|
124
128
|
});
|
|
125
129
|
|
|
126
130
|
// catalog_table_drop
|
|
127
|
-
const catalogTableDrop = catalogHandler(
|
|
131
|
+
const catalogTableDrop = catalogHandler(keys, async (params) => {
|
|
128
132
|
const cat = getCatalog();
|
|
129
133
|
await cat.tableDrop(
|
|
130
134
|
toUint8Array(params.attach_opaque_data),
|
|
@@ -137,7 +141,7 @@ export function catalogTableHandlers(getCatalog: GetCatalog, signingKey?: Uint8A
|
|
|
137
141
|
});
|
|
138
142
|
|
|
139
143
|
// catalog_table_column_statistics_get
|
|
140
|
-
const catalogTableColumnStatisticsGet = catalogHandler(
|
|
144
|
+
const catalogTableColumnStatisticsGet = catalogHandler(keys, async (params) => {
|
|
141
145
|
const cat = getCatalog();
|
|
142
146
|
const stats = await cat.tableColumnStatisticsGet(
|
|
143
147
|
toUint8Array(params.attach_opaque_data),
|
|
@@ -149,7 +153,7 @@ export function catalogTableHandlers(getCatalog: GetCatalog, signingKey?: Uint8A
|
|
|
149
153
|
});
|
|
150
154
|
|
|
151
155
|
// catalog_table_scan_function_get
|
|
152
|
-
const catalogTableScanFunctionGet = catalogHandler(
|
|
156
|
+
const catalogTableScanFunctionGet = catalogHandler(keys, async (params) => {
|
|
153
157
|
const cat = getCatalog();
|
|
154
158
|
const scanResult = await cat.tableScanFunctionGet(
|
|
155
159
|
toUint8Array(params.attach_opaque_data),
|
|
@@ -167,7 +171,7 @@ export function catalogTableHandlers(getCatalog: GetCatalog, signingKey?: Uint8A
|
|
|
167
171
|
// into TableInfo is only asked when the client skipped the inline value.
|
|
168
172
|
const optionalTx = (params: Record<string, any>): Uint8Array | undefined =>
|
|
169
173
|
params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined;
|
|
170
|
-
const catalogTableInsertFunctionGet = catalogHandler(
|
|
174
|
+
const catalogTableInsertFunctionGet = catalogHandler(keys, async (params) => {
|
|
171
175
|
const result = await getCatalog().tableInsertFunctionGet(
|
|
172
176
|
toUint8Array(params.attach_opaque_data),
|
|
173
177
|
params.schema_path,
|
|
@@ -177,7 +181,7 @@ export function catalogTableHandlers(getCatalog: GetCatalog, signingKey?: Uint8A
|
|
|
177
181
|
);
|
|
178
182
|
return wrapResult(result, ScanFunctionResultSchema);
|
|
179
183
|
});
|
|
180
|
-
const catalogTableUpdateFunctionGet = catalogHandler(
|
|
184
|
+
const catalogTableUpdateFunctionGet = catalogHandler(keys, async (params) => {
|
|
181
185
|
const result = await getCatalog().tableUpdateFunctionGet(
|
|
182
186
|
toUint8Array(params.attach_opaque_data),
|
|
183
187
|
params.schema_path,
|
|
@@ -186,7 +190,7 @@ export function catalogTableHandlers(getCatalog: GetCatalog, signingKey?: Uint8A
|
|
|
186
190
|
);
|
|
187
191
|
return wrapResult(result, ScanFunctionResultSchema);
|
|
188
192
|
});
|
|
189
|
-
const catalogTableDeleteFunctionGet = catalogHandler(
|
|
193
|
+
const catalogTableDeleteFunctionGet = catalogHandler(keys, async (params) => {
|
|
190
194
|
const result = await getCatalog().tableDeleteFunctionGet(
|
|
191
195
|
toUint8Array(params.attach_opaque_data),
|
|
192
196
|
params.schema_path,
|
|
@@ -199,21 +203,30 @@ export function catalogTableHandlers(getCatalog: GetCatalog, signingKey?: Uint8A
|
|
|
199
203
|
// catalog_table_scan_branches_get — branches-aware variant of
|
|
200
204
|
// scan_function_get. The branches-aware C++ extension calls this for every
|
|
201
205
|
// table scan; single-source catalogs synthesise a one-branch result.
|
|
202
|
-
|
|
206
|
+
//
|
|
207
|
+
// Protocol 3.2: always dispatches to tableScanBranchesPlan with the
|
|
208
|
+
// `pushdown_filters` wrapped as a ScanPlanningFilters (decoded lazily against
|
|
209
|
+
// the table's declared columns); its default returns tableScanBranchesGet.
|
|
210
|
+
const catalogTableScanBranchesGet = catalogHandler(keys, async (params) => {
|
|
203
211
|
const cat = getCatalog();
|
|
204
|
-
const
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
+
const attach = toUint8Array(params.attach_opaque_data);
|
|
213
|
+
const tx = params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined;
|
|
214
|
+
const schemaPath = params.schema_path;
|
|
215
|
+
const name = params.name;
|
|
216
|
+
const atUnit = params.at_unit;
|
|
217
|
+
const atValue = params.at_value;
|
|
218
|
+
const filters = params.pushdown_filters != null
|
|
219
|
+
? new ScanPlanningFilters(toUint8Array(params.pushdown_filters), async () => {
|
|
220
|
+
const info = await cat.tableGet(attach, schemaPath, name, atUnit, atValue, tx);
|
|
221
|
+
return info && info.columns.length ? deserializeSchema(toUint8Array(info.columns)) : null;
|
|
222
|
+
})
|
|
223
|
+
: null;
|
|
224
|
+
const branchesResult = await cat.tableScanBranchesPlan(attach, schemaPath, name, atUnit, atValue, tx, filters);
|
|
212
225
|
return wrapResult(branchesResult, ScanBranchesResultSchema);
|
|
213
226
|
});
|
|
214
227
|
|
|
215
228
|
// catalog_table_comment_set
|
|
216
|
-
const catalogTableCommentSet = catalogHandler(
|
|
229
|
+
const catalogTableCommentSet = catalogHandler(keys, async (params) => {
|
|
217
230
|
const cat = getCatalog();
|
|
218
231
|
await cat.tableCommentSet(
|
|
219
232
|
toUint8Array(params.attach_opaque_data),
|
|
@@ -227,7 +240,7 @@ export function catalogTableHandlers(getCatalog: GetCatalog, signingKey?: Uint8A
|
|
|
227
240
|
});
|
|
228
241
|
|
|
229
242
|
// catalog_table_rename
|
|
230
|
-
const catalogTableRename = catalogHandler(
|
|
243
|
+
const catalogTableRename = catalogHandler(keys, async (params) => {
|
|
231
244
|
const cat = getCatalog();
|
|
232
245
|
await cat.tableRename(
|
|
233
246
|
toUint8Array(params.attach_opaque_data),
|
|
@@ -241,7 +254,7 @@ export function catalogTableHandlers(getCatalog: GetCatalog, signingKey?: Uint8A
|
|
|
241
254
|
});
|
|
242
255
|
|
|
243
256
|
// catalog_table_column_add
|
|
244
|
-
const catalogTableColumnAdd = catalogHandler(
|
|
257
|
+
const catalogTableColumnAdd = catalogHandler(keys, async (params) => {
|
|
245
258
|
params.column_path = requireFlatColumnPath(params.column_path, "catalog_table_column_add");
|
|
246
259
|
validateColumnMetadataIpc(toUint8Array(params.column_definition));
|
|
247
260
|
validateColumnExpressionsIpc(toUint8Array(params.column_definition), params.schema_path);
|
|
@@ -259,7 +272,7 @@ export function catalogTableHandlers(getCatalog: GetCatalog, signingKey?: Uint8A
|
|
|
259
272
|
return {};
|
|
260
273
|
});
|
|
261
274
|
// catalog_table_column_drop
|
|
262
|
-
const catalogTableColumnDrop = catalogHandler(
|
|
275
|
+
const catalogTableColumnDrop = catalogHandler(keys, async (params) => {
|
|
263
276
|
params.column_path = requireFlatColumnPath(params.column_path, "catalog_table_column_drop");
|
|
264
277
|
const cat = getCatalog();
|
|
265
278
|
await cat.tableColumnDrop(
|
|
@@ -275,7 +288,7 @@ export function catalogTableHandlers(getCatalog: GetCatalog, signingKey?: Uint8A
|
|
|
275
288
|
return {};
|
|
276
289
|
});
|
|
277
290
|
// catalog_table_column_rename
|
|
278
|
-
const catalogTableColumnRename = catalogHandler(
|
|
291
|
+
const catalogTableColumnRename = catalogHandler(keys, async (params) => {
|
|
279
292
|
params.column_path = requireFlatColumnPath(params.column_path, "catalog_table_column_rename");
|
|
280
293
|
const cat = getCatalog();
|
|
281
294
|
await cat.tableColumnRename(
|
|
@@ -290,7 +303,7 @@ export function catalogTableHandlers(getCatalog: GetCatalog, signingKey?: Uint8A
|
|
|
290
303
|
return {};
|
|
291
304
|
});
|
|
292
305
|
// catalog_table_column_comment_set
|
|
293
|
-
const catalogTableColumnCommentSet = catalogHandler(
|
|
306
|
+
const catalogTableColumnCommentSet = catalogHandler(keys, async (params) => {
|
|
294
307
|
params.column_path = requireFlatColumnPath(params.column_path, "catalog_table_column_comment_set");
|
|
295
308
|
const cat = getCatalog();
|
|
296
309
|
await cat.tableColumnCommentSet(
|
|
@@ -305,7 +318,7 @@ export function catalogTableHandlers(getCatalog: GetCatalog, signingKey?: Uint8A
|
|
|
305
318
|
return {};
|
|
306
319
|
});
|
|
307
320
|
// catalog_table_column_default_set
|
|
308
|
-
const catalogTableColumnDefaultSet = catalogHandler(
|
|
321
|
+
const catalogTableColumnDefaultSet = catalogHandler(keys, async (params) => {
|
|
309
322
|
params.column_path = requireFlatColumnPath(params.column_path, "catalog_table_column_default_set");
|
|
310
323
|
const cat = getCatalog();
|
|
311
324
|
await cat.tableColumnDefaultSet(
|
|
@@ -320,7 +333,7 @@ export function catalogTableHandlers(getCatalog: GetCatalog, signingKey?: Uint8A
|
|
|
320
333
|
return {};
|
|
321
334
|
});
|
|
322
335
|
// catalog_table_column_default_drop
|
|
323
|
-
const catalogTableColumnDefaultDrop = catalogHandler(
|
|
336
|
+
const catalogTableColumnDefaultDrop = catalogHandler(keys, async (params) => {
|
|
324
337
|
params.column_path = requireFlatColumnPath(params.column_path, "catalog_table_column_default_drop");
|
|
325
338
|
const cat = getCatalog();
|
|
326
339
|
await cat.tableColumnDefaultDrop(
|
|
@@ -334,7 +347,7 @@ export function catalogTableHandlers(getCatalog: GetCatalog, signingKey?: Uint8A
|
|
|
334
347
|
return {};
|
|
335
348
|
});
|
|
336
349
|
// catalog_table_column_type_change
|
|
337
|
-
const catalogTableColumnTypeChange = catalogHandler(
|
|
350
|
+
const catalogTableColumnTypeChange = catalogHandler(keys, async (params) => {
|
|
338
351
|
params.column_path = requireFlatColumnPath(params.column_path, "catalog_table_column_type_change");
|
|
339
352
|
const cat = getCatalog();
|
|
340
353
|
await cat.tableColumnTypeChange(
|
|
@@ -350,7 +363,7 @@ export function catalogTableHandlers(getCatalog: GetCatalog, signingKey?: Uint8A
|
|
|
350
363
|
return {};
|
|
351
364
|
});
|
|
352
365
|
// catalog_table_not_null_set
|
|
353
|
-
const catalogTableNotNullSet = catalogHandler(
|
|
366
|
+
const catalogTableNotNullSet = catalogHandler(keys, async (params) => {
|
|
354
367
|
params.column_path = requireFlatColumnPath(params.column_path, "catalog_table_not_null_set");
|
|
355
368
|
const cat = getCatalog();
|
|
356
369
|
await cat.tableNotNullSet(
|
|
@@ -364,7 +377,7 @@ export function catalogTableHandlers(getCatalog: GetCatalog, signingKey?: Uint8A
|
|
|
364
377
|
return {};
|
|
365
378
|
});
|
|
366
379
|
// catalog_table_not_null_drop
|
|
367
|
-
const catalogTableNotNullDrop = catalogHandler(
|
|
380
|
+
const catalogTableNotNullDrop = catalogHandler(keys, async (params) => {
|
|
368
381
|
params.column_path = requireFlatColumnPath(params.column_path, "catalog_table_not_null_drop");
|
|
369
382
|
const cat = getCatalog();
|
|
370
383
|
await cat.tableNotNullDrop(
|
|
@@ -15,11 +15,13 @@ import {
|
|
|
15
15
|
import {
|
|
16
16
|
type GetCatalog,
|
|
17
17
|
catalogHandler,
|
|
18
|
+
type OpaqueKeys,
|
|
18
19
|
} from "./shared.js";
|
|
19
20
|
|
|
20
|
-
export function catalogViewHandlers(getCatalog: GetCatalog, signingKey?: Uint8Array): Partial<VgiService> {
|
|
21
|
+
export function catalogViewHandlers(getCatalog: GetCatalog, signingKey?: Uint8Array, attachSecretKey?: Uint8Array): Partial<VgiService> {
|
|
22
|
+
const keys: OpaqueKeys = { signingKey, attachSecretKey };
|
|
21
23
|
// catalog_view_get
|
|
22
|
-
const catalogViewGet = catalogHandler(
|
|
24
|
+
const catalogViewGet = catalogHandler(keys, async (params) => {
|
|
23
25
|
const cat = getCatalog();
|
|
24
26
|
const info = await cat.viewGet(
|
|
25
27
|
toUint8Array(params.attach_opaque_data),
|
|
@@ -33,7 +35,7 @@ export function catalogViewHandlers(getCatalog: GetCatalog, signingKey?: Uint8Ar
|
|
|
33
35
|
});
|
|
34
36
|
|
|
35
37
|
// catalog_view_create
|
|
36
|
-
const catalogViewCreate = catalogHandler(
|
|
38
|
+
const catalogViewCreate = catalogHandler(keys, async (params) => {
|
|
37
39
|
if (params.security !== "regular") throw new Error(`view security mode ${params.security} is unsupported`);
|
|
38
40
|
const tags = catalogStringMap(params.tags);
|
|
39
41
|
const columnComments = catalogStringMap(params.column_comments);
|
|
@@ -55,7 +57,7 @@ export function catalogViewHandlers(getCatalog: GetCatalog, signingKey?: Uint8Ar
|
|
|
55
57
|
});
|
|
56
58
|
|
|
57
59
|
// catalog_view_drop
|
|
58
|
-
const catalogViewDrop = catalogHandler(
|
|
60
|
+
const catalogViewDrop = catalogHandler(keys, async (params) => {
|
|
59
61
|
const cat = getCatalog();
|
|
60
62
|
await cat.viewDrop(
|
|
61
63
|
toUint8Array(params.attach_opaque_data),
|
|
@@ -68,7 +70,7 @@ export function catalogViewHandlers(getCatalog: GetCatalog, signingKey?: Uint8Ar
|
|
|
68
70
|
});
|
|
69
71
|
|
|
70
72
|
// catalog_view_rename
|
|
71
|
-
const catalogViewRename = catalogHandler(
|
|
73
|
+
const catalogViewRename = catalogHandler(keys, async (params) => {
|
|
72
74
|
const cat = getCatalog();
|
|
73
75
|
await cat.viewRename(
|
|
74
76
|
toUint8Array(params.attach_opaque_data),
|
|
@@ -82,7 +84,7 @@ export function catalogViewHandlers(getCatalog: GetCatalog, signingKey?: Uint8Ar
|
|
|
82
84
|
});
|
|
83
85
|
|
|
84
86
|
// catalog_view_comment_set
|
|
85
|
-
const catalogViewCommentSet = catalogHandler(
|
|
87
|
+
const catalogViewCommentSet = catalogHandler(keys, async (params) => {
|
|
86
88
|
const cat = getCatalog();
|
|
87
89
|
await cat.viewCommentSet(
|
|
88
90
|
toUint8Array(params.attach_opaque_data),
|
|
@@ -95,7 +97,7 @@ export function catalogViewHandlers(getCatalog: GetCatalog, signingKey?: Uint8Ar
|
|
|
95
97
|
return {};
|
|
96
98
|
});
|
|
97
99
|
|
|
98
|
-
const catalogViewColumnCommentSet = catalogHandler(
|
|
100
|
+
const catalogViewColumnCommentSet = catalogHandler(keys, async (params) => {
|
|
99
101
|
const path: string[] = Array.from(params.column_path);
|
|
100
102
|
if (path.length !== 1 || !path[0] || path[0].includes("\0")) throw new Error("view column comments require one raw output identifier");
|
|
101
103
|
await getCatalog().viewColumnCommentSet(
|
|
@@ -56,6 +56,8 @@ import {
|
|
|
56
56
|
export interface FunctionHandlerConfig {
|
|
57
57
|
registry: FunctionRegistry;
|
|
58
58
|
signingKey?: Uint8Array | undefined;
|
|
59
|
+
/** Explicit root key for secret ATTACH options (see attach-secret-options.ts). */
|
|
60
|
+
attachSecretKey?: Uint8Array | undefined;
|
|
59
61
|
/**
|
|
60
62
|
* Used to map a bind's `attach_opaque_data` to its catalog, so resolution can
|
|
61
63
|
* be scoped when two catalogs declare the same schema and function name.
|
|
@@ -90,6 +92,7 @@ async function liveSplitAnchor(
|
|
|
90
92
|
bindCall: { attach_opaque_data?: Uint8Array | null; transaction_opaque_data?: Uint8Array | null },
|
|
91
93
|
auth: AuthContext | undefined,
|
|
92
94
|
signingKey: Uint8Array | undefined,
|
|
95
|
+
attachSecretKey?: Uint8Array,
|
|
93
96
|
): Promise<Uint8Array | undefined> {
|
|
94
97
|
if (!catalogInterface?.version || bindCall.attach_opaque_data == null) return undefined;
|
|
95
98
|
const raw = toUint8Array(bindCall.attach_opaque_data);
|
|
@@ -123,7 +126,7 @@ async function liveSplitAnchor(
|
|
|
123
126
|
// every non-HTTP transport).
|
|
124
127
|
const forms: Array<() => Promise<Uint8Array>> = [
|
|
125
128
|
async () => raw,
|
|
126
|
-
async () => openAttach(raw, auth, signingKey),
|
|
129
|
+
async () => openAttach(raw, auth, signingKey, attachSecretKey),
|
|
127
130
|
];
|
|
128
131
|
for (const form of forms) {
|
|
129
132
|
try {
|
|
@@ -168,6 +171,7 @@ async function resolveSplitPayloads(
|
|
|
168
171
|
opts: {
|
|
169
172
|
auth: any;
|
|
170
173
|
signingKey: Uint8Array | undefined;
|
|
174
|
+
attachSecretKey?: Uint8Array | undefined;
|
|
171
175
|
catalogInterface: any;
|
|
172
176
|
checkAnchor: boolean;
|
|
173
177
|
},
|
|
@@ -182,7 +186,7 @@ async function resolveSplitPayloads(
|
|
|
182
186
|
new Uint8Array(0),
|
|
183
187
|
);
|
|
184
188
|
const currentAnchor = opts.checkAnchor
|
|
185
|
-
? await liveSplitAnchor(opts.catalogInterface, request.bind_call as any, opts.auth, opts.signingKey)
|
|
189
|
+
? await liveSplitAnchor(opts.catalogInterface, request.bind_call as any, opts.auth, opts.signingKey, opts.attachSecretKey)
|
|
186
190
|
: undefined;
|
|
187
191
|
request.split_payloads = [];
|
|
188
192
|
for (const token of request.split_tokens) {
|
|
@@ -202,7 +206,7 @@ async function resolveSplitPayloads(
|
|
|
202
206
|
|
|
203
207
|
/** The per-function lifecycle's `vgi.v3` handlers. */
|
|
204
208
|
export function functionHandlers(config: FunctionHandlerConfig): Partial<VgiService> {
|
|
205
|
-
const { registry, signingKey, catalogInterface } = config;
|
|
209
|
+
const { registry, signingKey, catalogInterface, attachSecretKey } = config;
|
|
206
210
|
|
|
207
211
|
// The framework mints every attach as uuid(16) || catalog_bytes (sealed on
|
|
208
212
|
// HTTP, plaintext on subprocess). Function bodies — like catalog bodies —
|
|
@@ -218,7 +222,7 @@ export function functionHandlers(config: FunctionHandlerConfig): Partial<VgiServ
|
|
|
218
222
|
if (attach == null) return null;
|
|
219
223
|
const env = toUint8Array(attach);
|
|
220
224
|
if (env.length === 0) return env;
|
|
221
|
-
return openAttach(env, ctx?.auth ?? currentRequestAuth(), signingKey);
|
|
225
|
+
return openAttach(env, ctx?.auth ?? currentRequestAuth(), signingKey, attachSecretKey);
|
|
222
226
|
}
|
|
223
227
|
|
|
224
228
|
// Unseal a bind call's opaque values in place, as the catalog handlers do:
|
|
@@ -318,6 +322,7 @@ export function functionHandlers(config: FunctionHandlerConfig): Partial<VgiServ
|
|
|
318
322
|
await resolveSplitPayloads(request, innerParams, {
|
|
319
323
|
auth,
|
|
320
324
|
signingKey,
|
|
325
|
+
attachSecretKey,
|
|
321
326
|
catalogInterface,
|
|
322
327
|
checkAnchor: true,
|
|
323
328
|
});
|
|
@@ -429,6 +434,7 @@ export function functionHandlers(config: FunctionHandlerConfig): Partial<VgiServ
|
|
|
429
434
|
// authentication for every authenticated caller's own tokens.
|
|
430
435
|
auth: currentRequestAuth(),
|
|
431
436
|
signingKey,
|
|
437
|
+
attachSecretKey,
|
|
432
438
|
catalogInterface,
|
|
433
439
|
checkAnchor: false,
|
|
434
440
|
});
|
|
@@ -568,7 +574,7 @@ export function functionHandlers(config: FunctionHandlerConfig): Partial<VgiServ
|
|
|
568
574
|
const anchor =
|
|
569
575
|
plan.catalogVersion != null
|
|
570
576
|
? splitAnchor(plan.catalogVersion)
|
|
571
|
-
: ((await liveSplitAnchor(catalogInterface, request.bind_call as any, ctx?.auth, signingKey)) ??
|
|
577
|
+
: ((await liveSplitAnchor(catalogInterface, request.bind_call as any, ctx?.auth, signingKey, attachSecretKey)) ??
|
|
572
578
|
splitAnchor(0));
|
|
573
579
|
|
|
574
580
|
const blobs: Uint8Array[] = [];
|
|
@@ -37,6 +37,7 @@ import { Arguments } from "../../arguments/arguments.js";
|
|
|
37
37
|
export function tableBufferingHandlers(
|
|
38
38
|
registry: FunctionRegistry,
|
|
39
39
|
signingKey?: Uint8Array,
|
|
40
|
+
attachSecretKey?: Uint8Array,
|
|
40
41
|
): Partial<VgiService> {
|
|
41
42
|
// `schemaPath` scopes resolution to the schema the caller named. The
|
|
42
43
|
// buffering process/combine RPCs carry it (protocol 1.2.0), so a name
|
|
@@ -74,7 +75,7 @@ export function tableBufferingHandlers(
|
|
|
74
75
|
const rawAttach = inner.attach_opaque_data ? toUint8Array(inner.attach_opaque_data) : null;
|
|
75
76
|
const attach =
|
|
76
77
|
rawAttach && rawAttach.length > 0
|
|
77
|
-
? await openAttach(rawAttach, ctx?.auth, signingKey)
|
|
78
|
+
? await openAttach(rawAttach, ctx?.auth, signingKey, attachSecretKey)
|
|
78
79
|
: rawAttach;
|
|
79
80
|
const transactionId = inner.transaction_id ? toUint8Array(inner.transaction_id) : null;
|
|
80
81
|
|
package/src/serve-entry.ts
CHANGED
|
@@ -91,6 +91,11 @@ export interface ServeVgiWorkerOptions extends HostingOptions {
|
|
|
91
91
|
hostname?: string | undefined;
|
|
92
92
|
/** Overrides `$VGI_SIGNING_KEY`. 32 bytes. */
|
|
93
93
|
signingKey?: Uint8Array | undefined;
|
|
94
|
+
/**
|
|
95
|
+
* Optional root key for secret ATTACH options (encrypted inside
|
|
96
|
+
* `attach_opaque_data` for `attachOptions()`). Defaults to the signing key.
|
|
97
|
+
*/
|
|
98
|
+
attachSecretKey?: Uint8Array | undefined;
|
|
94
99
|
/** Overrides `$VGI_TOKEN_TTL` (default 3600 seconds). */
|
|
95
100
|
tokenTtl?: number | undefined;
|
|
96
101
|
/** Overrides `$CORS_ORIGINS` (default "*"). Pass `null` to disable CORS. */
|
|
@@ -242,7 +247,7 @@ export function createVgiWorkerFetch(
|
|
|
242
247
|
const trustedProxyAddresses = bridge?.trustedProxyAddresses ?? ["127.0.0.1"];
|
|
243
248
|
|
|
244
249
|
return createVgiFetch({
|
|
245
|
-
protocol: { registry: opts.registry, catalogInterface: opts.catalogInterface },
|
|
250
|
+
protocol: { registry: opts.registry, catalogInterface: opts.catalogInterface, attachSecretKey: opts.attachSecretKey },
|
|
246
251
|
signingKey,
|
|
247
252
|
signingKeyConfigured,
|
|
248
253
|
tokenTtl,
|
package/src/worker-cf-entry.ts
CHANGED
|
@@ -63,6 +63,12 @@ export {
|
|
|
63
63
|
serializeAttachOptionSpec,
|
|
64
64
|
serializeAttachOptionSpecs,
|
|
65
65
|
serializeColumnStatistics,
|
|
66
|
+
// Multi-branch scans and protocol 3.2 filtered scan planning.
|
|
67
|
+
buildScanBranchesResult,
|
|
68
|
+
ScanPlanningFilters,
|
|
69
|
+
filtersMayMatch,
|
|
70
|
+
SCAN_PLANNING_BIND,
|
|
71
|
+
SCAN_PLANNING_FILTERED,
|
|
66
72
|
BindResultSchema,
|
|
67
73
|
ScanFunctionResultSchema,
|
|
68
74
|
// Resolved-secret selection (the batch is keyed by secret NAME, not type).
|
|
@@ -83,6 +89,9 @@ export type {
|
|
|
83
89
|
CacheScope,
|
|
84
90
|
AttachOptionSpec,
|
|
85
91
|
ColumnStatistics,
|
|
92
|
+
ScanBranchInput,
|
|
93
|
+
ScanPlanningMode,
|
|
94
|
+
ScanCandidateStatistics,
|
|
86
95
|
CatalogAttachResult,
|
|
87
96
|
CatalogDescriptor,
|
|
88
97
|
CatalogInfo,
|
package/src/worker.ts
CHANGED
|
@@ -123,6 +123,15 @@ export interface WorkerConfig extends HostingOptions {
|
|
|
123
123
|
* dispatches on. Omit to have the worker create its own.
|
|
124
124
|
*/
|
|
125
125
|
registry?: FunctionRegistry;
|
|
126
|
+
/**
|
|
127
|
+
* Optional root key for secret ATTACH options (`AttachOptionSpec.secret`),
|
|
128
|
+
* which the framework encrypts inside `attach_opaque_data` for
|
|
129
|
+
* `attachOptions()`. Defaults to the host-local key file
|
|
130
|
+
* (`$VGI_ATTACH_SECRET_KEY_FILE`, else `vgi/attach-secret-options.key` under
|
|
131
|
+
* `$XDG_RUNTIME_DIR` or the per-user temp dir). Every worker process that may
|
|
132
|
+
* receive a given attach must use the same key.
|
|
133
|
+
*/
|
|
134
|
+
attachSecretKey?: Uint8Array;
|
|
126
135
|
}
|
|
127
136
|
|
|
128
137
|
export class Worker {
|
|
@@ -130,8 +139,10 @@ export class Worker {
|
|
|
130
139
|
private _hosting: HostingOptions;
|
|
131
140
|
private _catalogInterface: CatalogInterface | undefined;
|
|
132
141
|
private _catalogName: string | undefined;
|
|
142
|
+
private _attachSecretKey: Uint8Array | undefined;
|
|
133
143
|
|
|
134
144
|
constructor(config: WorkerConfig) {
|
|
145
|
+
this._attachSecretKey = config.attachSecretKey;
|
|
135
146
|
// Reuse the caller's registry when given: a catalogInterface built
|
|
136
147
|
// elsewhere recorded its per-schema function ownership there, and that
|
|
137
148
|
// index is what makes a schema-qualified bind resolve correctly.
|
|
@@ -297,6 +308,7 @@ export class Worker {
|
|
|
297
308
|
registry: this._registry,
|
|
298
309
|
catalogInterface: this._catalogInterface,
|
|
299
310
|
catalogName: this._catalogName,
|
|
311
|
+
attachSecretKey: this._attachSecretKey,
|
|
300
312
|
});
|
|
301
313
|
}
|
|
302
314
|
|