@query-farm/vgi 0.50.1 → 0.52.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 +45 -3
- package/dist/client-entry.js +833 -775
- package/dist/client-entry.js.map +10 -10
- package/dist/functions/aggregate.d.ts +25 -21
- package/dist/functions/execution-cache.d.ts +11 -0
- package/dist/functions/storage-blobs.d.ts +173 -0
- package/dist/functions/storage-cf-do.d.ts +50 -0
- package/dist/functions/storage-seal.d.ts +27 -0
- package/dist/functions/storage.d.ts +71 -1
- package/dist/functions/table-buffering.d.ts +30 -0
- package/dist/functions/table.d.ts +6 -1
- package/dist/generated/vgi-client.d.ts +7 -1
- package/dist/generated/vgi-protocol-schemas.d.ts +10 -9
- package/dist/generated/vgi-protocol-types.d.ts +244 -2
- package/dist/generated/vgi-service.d.ts +1 -1
- package/dist/hosted.d.ts +117 -0
- package/dist/http/blob-vendor.d.ts +33 -0
- package/dist/http/fetch.d.ts +60 -2
- package/dist/http/hosted-auth.d.ts +45 -0
- package/dist/index.core.d.ts +11 -3
- package/dist/index.js +8661 -6677
- package/dist/index.js.map +52 -34
- package/dist/protocol/arguments-ref.d.ts +107 -0
- package/dist/protocol/dispatch.d.ts +12 -2
- package/dist/protocol/handlers/aggregate.d.ts +1 -1
- package/dist/protocol/handlers/catalog/shared.d.ts +10 -0
- package/dist/protocol/handlers/function.d.ts +23 -0
- package/dist/protocol/handlers/table-buffering.d.ts +1 -1
- package/dist/protocol/serialize.d.ts +1 -1
- package/dist/protocol/serializers/bind.d.ts +27 -1
- package/dist/protocol/serializers/cardinality.d.ts +1 -1
- package/dist/protocol/serializers/splits.d.ts +7 -0
- package/dist/protocol/state-serializer.d.ts +8 -7
- package/dist/protocol/stream-init.d.ts +17 -0
- package/dist/protocol/types.d.ts +32 -0
- package/dist/secrets/lookups.d.ts +31 -0
- package/dist/serve-entry.d.ts +41 -6
- package/dist/serve-entry.js +8531 -6302
- package/dist/serve-entry.js.map +52 -35
- package/dist/worker-cf-entry.d.ts +5 -0
- package/dist/worker-cf-entry.js +7191 -4990
- package/dist/worker-cf-entry.js.map +59 -41
- package/package.json +5 -4
- package/src/functions/aggregate.ts +101 -152
- package/src/functions/copy-from.ts +2 -2
- package/src/functions/execution-cache.ts +59 -0
- package/src/functions/storage-blobs.ts +654 -0
- package/src/functions/storage-cf-do.ts +176 -22
- package/src/functions/storage-seal.ts +208 -0
- package/src/functions/storage.ts +174 -8
- package/src/functions/table-buffering.ts +104 -18
- package/src/functions/table-in-out.ts +3 -1
- package/src/functions/table.ts +12 -8
- package/src/generated/vgi-client.ts +9 -2
- package/src/generated/vgi-protocol-schemas.ts +115 -107
- package/src/generated/vgi-protocol-types.ts +640 -3
- package/src/generated/vgi-service.ts +2 -2
- package/src/hosted.ts +254 -0
- package/src/http/blob-vendor.ts +80 -0
- package/src/http/fetch.ts +179 -8
- package/src/http/hosted-auth.ts +326 -0
- package/src/index.core.ts +66 -1
- package/src/protocol/arguments-ref.ts +260 -0
- package/src/protocol/dispatch.ts +15 -4
- package/src/protocol/handlers/aggregate.ts +123 -82
- package/src/protocol/handlers/catalog/shared.ts +20 -0
- package/src/protocol/handlers/function.ts +135 -59
- package/src/protocol/handlers/table-buffering.ts +49 -32
- package/src/protocol/serialize.ts +3 -0
- package/src/protocol/serializers/bind.ts +96 -69
- package/src/protocol/serializers/cardinality.ts +4 -7
- package/src/protocol/serializers/init.ts +5 -11
- package/src/protocol/serializers/splits.ts +31 -4
- package/src/protocol/state-serializer.ts +27 -39
- package/src/protocol/stream-init.ts +87 -0
- package/src/protocol/types.ts +33 -0
- package/src/secrets/lookups.ts +53 -0
- package/src/serve-entry.ts +138 -11
- package/src/worker-cf-entry.ts +33 -0
- package/src/worker.ts +25 -0
- package/dist/protocol/carried-init-request.d.ts +0 -28
- package/dist/util/zstd-sync.d.ts +0 -7
- package/src/protocol/carried-init-request.ts +0 -139
- package/src/util/zstd-sync.ts +0 -50
|
@@ -1,5 +1,44 @@
|
|
|
1
|
-
import type { CatalogAttachResult, CatalogCapabilities, CatalogContentsResponse, CatalogObjectRef, CatalogQueryPrepareRequest, CatalogQueryPrepareResult, ClientQueryCapabilities, ConstraintSnapshot, ConstraintsApplyRequest, DependencySnapshot, IndexDefinition, MacroOverload, MacroParameter, OptionDefinitions, OptionState, QueryCapabilities, QueryEvaluationContext, QueryObjectReference, SqlExpression, TableLayout } from "./vgi-client.js";
|
|
2
|
-
export type { CatalogAttachResult, CatalogCapabilities, CatalogContentsResponse, CatalogObjectRef, CatalogQueryPrepareRequest, CatalogQueryPrepareResult, ClientQueryCapabilities, ConstraintSnapshot, ConstraintsApplyRequest, DependencySnapshot, IndexDefinition, MacroOverload, MacroParameter, OptionDefinitions, OptionState, QueryCapabilities, QueryEvaluationContext, QueryObjectReference, SqlExpression, TableLayout };
|
|
1
|
+
import type { ArgumentsLocation, BindRequest, CatalogAttachResult, CatalogCapabilities, CatalogContentsResponse, CatalogObjectRef, CatalogQueryPrepareRequest, CatalogQueryPrepareResult, ClientQueryCapabilities, ConstraintSnapshot, ConstraintsApplyRequest, CopyFromContext, CopyToContext, DependencySnapshot, IndexDefinition, MacroOverload, MacroParameter, OptionDefinitions, OptionState, QueryCapabilities, QueryEvaluationContext, QueryObjectReference, SqlExpression, TableLayout } from "./vgi-client.js";
|
|
2
|
+
export type { ArgumentsLocation, BindRequest, CatalogAttachResult, CatalogCapabilities, CatalogContentsResponse, CatalogObjectRef, CatalogQueryPrepareRequest, CatalogQueryPrepareResult, ClientQueryCapabilities, ConstraintSnapshot, ConstraintsApplyRequest, CopyFromContext, CopyToContext, DependencySnapshot, IndexDefinition, MacroOverload, MacroParameter, OptionDefinitions, OptionState, QueryCapabilities, QueryEvaluationContext, QueryObjectReference, SqlExpression, TableLayout };
|
|
3
|
+
/**
|
|
4
|
+
* The raw-preserving lazy wrapper for a nested record carried as binary
|
|
5
|
+
* (vgi docs/large-values-3.4.md §3.3). It holds the bytes exactly as received
|
|
6
|
+
* (a private copy), decodes them only when `get()` / `value` is first read,
|
|
7
|
+
* and the embedding record's encoder writes the held bytes verbatim, so a
|
|
8
|
+
* decoded-then-re-encoded request is byte-identical to what the peer sent.
|
|
9
|
+
*
|
|
10
|
+
* The decoded value is frozen, and is decoded from a private copy of the bytes,
|
|
11
|
+
* so nothing done to it can change the held bytes. To change a field, build a
|
|
12
|
+
* new record and wrap it with `Nested.of` (or the generated `nested<Record>`).
|
|
13
|
+
* Printing (`toJSON`, `toString`, Node's inspect) never decodes or re-encodes.
|
|
14
|
+
*/
|
|
15
|
+
export declare class Nested<T> {
|
|
16
|
+
#private;
|
|
17
|
+
private constructor();
|
|
18
|
+
/** Wrap bytes received elsewhere (rule 7). The bytes are copied, not decoded. */
|
|
19
|
+
static fromBytes<T>(bytes: Uint8Array, decode: (bytes: Uint8Array) => T, path?: string): Nested<T>;
|
|
20
|
+
/** Serialize a typed record once and hold those bytes (rule 6). */
|
|
21
|
+
static of<T>(record: T, encode: (value: T) => Uint8Array, decode: (bytes: Uint8Array) => T, path?: string): Nested<T>;
|
|
22
|
+
/** The held bytes, exactly as received. Read-only by contract: do not mutate. */
|
|
23
|
+
get bytes(): Uint8Array;
|
|
24
|
+
get byteLength(): number;
|
|
25
|
+
/** The field path decode errors name, e.g. `InitRequest.bind_call`. */
|
|
26
|
+
get path(): string;
|
|
27
|
+
/**
|
|
28
|
+
* The decoded record, decoded on first access and cached (rule 2). A
|
|
29
|
+
* malformed or empty value throws here, naming the field path (rules 3, 9).
|
|
30
|
+
*/
|
|
31
|
+
get(): Readonly<T>;
|
|
32
|
+
/** Same as `get()`. */
|
|
33
|
+
get value(): Readonly<T>;
|
|
34
|
+
/** Equality is over the held bytes (rule 8). */
|
|
35
|
+
equals(other: Nested<T> | null | undefined): boolean;
|
|
36
|
+
toJSON(): {
|
|
37
|
+
nested: string;
|
|
38
|
+
byteLength: number;
|
|
39
|
+
};
|
|
40
|
+
toString(): string;
|
|
41
|
+
}
|
|
3
42
|
/** One raw, component-preserving field reference used by a transform. */
|
|
4
43
|
export interface FieldPath {
|
|
5
44
|
components: string[];
|
|
@@ -371,6 +410,209 @@ export type RequiredFilterPathsInit = Omit<RequiredFilterPaths, RequiredFilterPa
|
|
|
371
410
|
export declare function buildRequiredFilterPaths(init: RequiredFilterPathsInit): RequiredFilterPaths;
|
|
372
411
|
export declare const encodeRequiredFilterPaths: (v: RequiredFilterPaths) => Uint8Array;
|
|
373
412
|
export declare const decodeRequiredFilterPaths: (b: Uint8Array) => RequiredFilterPaths;
|
|
413
|
+
/** `CopyFromContext` has no defaulted fields, so its init is the record itself. */
|
|
414
|
+
export type CopyFromContextInit = CopyFromContext;
|
|
415
|
+
/** Build a complete `CopyFromContext`, filling the protocol defaults, in wire order. */
|
|
416
|
+
export declare function buildCopyFromContext(init: CopyFromContextInit): CopyFromContext;
|
|
417
|
+
export declare const encodeCopyFromContext: (v: CopyFromContext) => Uint8Array;
|
|
418
|
+
export declare const decodeCopyFromContext: (b: Uint8Array) => CopyFromContext;
|
|
419
|
+
/** `CopyToContext` has no defaulted fields, so its init is the record itself. */
|
|
420
|
+
export type CopyToContextInit = CopyToContext;
|
|
421
|
+
/** Build a complete `CopyToContext`, filling the protocol defaults, in wire order. */
|
|
422
|
+
export declare function buildCopyToContext(init: CopyToContextInit): CopyToContext;
|
|
423
|
+
export declare const encodeCopyToContext: (v: CopyToContext) => Uint8Array;
|
|
424
|
+
export declare const decodeCopyToContext: (b: Uint8Array) => CopyToContext;
|
|
425
|
+
/** `ArgumentsLocation` has no defaulted fields, so its init is the record itself. */
|
|
426
|
+
export type ArgumentsLocationInit = ArgumentsLocation;
|
|
427
|
+
/** Build a complete `ArgumentsLocation`, filling the protocol defaults, in wire order. */
|
|
428
|
+
export declare function buildArgumentsLocation(init: ArgumentsLocationInit): ArgumentsLocation;
|
|
429
|
+
export declare const encodeArgumentsLocation: (v: ArgumentsLocation) => Uint8Array;
|
|
430
|
+
export declare const decodeArgumentsLocation: (b: Uint8Array) => ArgumentsLocation;
|
|
431
|
+
/** Fields of `BindRequest` that have a protocol default. */
|
|
432
|
+
export type BindRequestDefaultedField = "input_schema" | "settings" | "secrets" | "attach_opaque_data" | "transaction_opaque_data" | "resolved_secrets_provided" | "at_unit" | "at_value" | "copy_from" | "copy_to" | "schema_path" | "argument_names" | "arguments_location";
|
|
433
|
+
/** `BindRequest` with every field that has a protocol default optional. */
|
|
434
|
+
export type BindRequestInit = Omit<BindRequest, BindRequestDefaultedField> & Partial<Pick<BindRequest, BindRequestDefaultedField>>;
|
|
435
|
+
/** Build a complete `BindRequest`, filling the protocol defaults, in wire order. */
|
|
436
|
+
export declare function buildBindRequest(init: BindRequestInit): BindRequest;
|
|
437
|
+
export declare const encodeBindRequest: (v: BindRequest) => Uint8Array;
|
|
438
|
+
export declare const decodeBindRequest: (b: Uint8Array) => BindRequest;
|
|
439
|
+
/**
|
|
440
|
+
* Wrap a `BindRequest` for a field that carries it as a nested record: a typed
|
|
441
|
+
* record is serialized once (spec §3.3 rule 6); bytes are held as given (rule 7).
|
|
442
|
+
*/
|
|
443
|
+
export declare function nestedBindRequest(source: BindRequest | Uint8Array, path?: string): Nested<BindRequest>;
|
|
444
|
+
/** Consolidated init request for all function types. For secondary init requests, `execution_id` and `init_opaque_data` are set; use :attr:`is_secondary` to distinguish. */
|
|
445
|
+
export interface InitRequest {
|
|
446
|
+
/** The originating `BindRequest` (function name, arguments, schemas). */
|
|
447
|
+
bind_call: Nested<BindRequest>;
|
|
448
|
+
/** Serialized Arrow schema of the rows the function produces. */
|
|
449
|
+
output_schema: Uint8Array;
|
|
450
|
+
/** Opaque per-bind state the worker returned from bind(), threaded back into later calls. Wire-facing bytes the framework produced from the typed `BindResult.opaque_data`; consumers reconstruct via `MyConcreteDataclass.deserialize_from_bytes(raw)`. See `BindResponse.opaque_data` in vgi/invocation.py for the full contract rationale. */
|
|
451
|
+
bind_opaque_data?: Uint8Array | null;
|
|
452
|
+
/** Column indices DuckDB wants projected from the function's output; `None` for scalar functions or when no projection pushdown. */
|
|
453
|
+
projection_ids?: number[] | null;
|
|
454
|
+
/** Serialized filter predicates DuckDB pushed down to the scan; `None` when no filters apply. */
|
|
455
|
+
pushdown_filters?: Uint8Array | null;
|
|
456
|
+
/** Serialized join-key batches pushed down for join filtering; `None` when not applicable. */
|
|
457
|
+
join_keys?: Uint8Array[] | null;
|
|
458
|
+
/** Split tokens to redeem in this init, or None for an ordinary whole-scan init. Usually one; a client that bin-packs sends a whole group and expects them concatenated in the order given. */
|
|
459
|
+
split_tokens?: Uint8Array[] | null;
|
|
460
|
+
/** Plain fetch limit, or None. NOT `order_by_limit`, which is a field of the Top-N hint. DuckDB cannot supply this; DataFusion can. */
|
|
461
|
+
row_limit?: number | null;
|
|
462
|
+
/** For table-in-out functions, which init phase (INPUT / FINALIZE / buffering) this request opens; `None` for other function types. */
|
|
463
|
+
phase?: string | null;
|
|
464
|
+
/** For a buffered-table finalize stream, which state_id this stream serves. Required when `phase=TABLE_BUFFERING_FINALIZE`, `None` otherwise. Opaque bytes — the worker chose the encoding when its combine() returned the finalize_state_ids list. */
|
|
465
|
+
finalize_state_id?: Uint8Array | null;
|
|
466
|
+
/** Identifier for one query execution, stable across the coordinator and any secondary workers; keys worker-owned state. `None` for global init, set for secondary init. */
|
|
467
|
+
execution_id?: Uint8Array | null;
|
|
468
|
+
/** Opaque per-init state threaded back into the stream; same producer/wire/consumer contract as `bind_opaque_data`. */
|
|
469
|
+
init_opaque_data?: Uint8Array | null;
|
|
470
|
+
/** Stable, client-owned identity of the streaming table-in-out substream this request opens (per DuckDB PipelineExecutor). Rides every InitRequest a substream's worker builds — INPUT and FINALIZE — so a worker can locate that substream's accumulated state even when an HTTP load balancer routes its init / process / finalize to different backends. `None` for non-substream function types. */
|
|
471
|
+
substream_id?: Uint8Array | null;
|
|
472
|
+
/** Column name of the order-pushdown hint from DuckDB's RowGroupPruner optimizer; `None` when no hint. */
|
|
473
|
+
order_by_column_name?: string | null;
|
|
474
|
+
/** Sort direction of the order-pushdown hint; `None` when no hint. */
|
|
475
|
+
order_by_direction?: string | null;
|
|
476
|
+
/** Null-ordering of the order-pushdown hint; `None` when no hint. */
|
|
477
|
+
order_by_null_order?: string | null;
|
|
478
|
+
/** Row limit of the order-pushdown hint; `None` when no hint. */
|
|
479
|
+
order_by_limit?: number | null;
|
|
480
|
+
/** Sample percentage of the TABLESAMPLE pushdown hint from DuckDB's SamplingPushdown optimizer; `None` when no hint. */
|
|
481
|
+
tablesample_percentage?: number | null;
|
|
482
|
+
/** Sample seed of the TABLESAMPLE pushdown hint; `None` when no hint. */
|
|
483
|
+
tablesample_seed?: number | null;
|
|
484
|
+
}
|
|
485
|
+
/** Fields of `InitRequest` that have a protocol default. */
|
|
486
|
+
export type InitRequestDefaultedField = "bind_opaque_data" | "projection_ids" | "pushdown_filters" | "join_keys" | "split_tokens" | "row_limit" | "phase" | "finalize_state_id" | "execution_id" | "init_opaque_data" | "substream_id" | "order_by_column_name" | "order_by_direction" | "order_by_null_order" | "order_by_limit" | "tablesample_percentage" | "tablesample_seed";
|
|
487
|
+
/** `InitRequest` with every field that has a protocol default optional. */
|
|
488
|
+
export type InitRequestInit = Omit<InitRequest, InitRequestDefaultedField> & Partial<Pick<InitRequest, InitRequestDefaultedField>>;
|
|
489
|
+
/** Build a complete `InitRequest`, filling the protocol defaults, in wire order. */
|
|
490
|
+
export declare function buildInitRequest(init: InitRequestInit): InitRequest;
|
|
491
|
+
/** Encode a `InitRequest`; each nested record is written as its wrapper's held bytes, never re-serialized. */
|
|
492
|
+
export declare function encodeInitRequest(v: InitRequest): Uint8Array;
|
|
493
|
+
/** Decode a `InitRequest`; each nested record is held as received and decoded only when accessed. */
|
|
494
|
+
export declare function decodeInitRequest(b: Uint8Array): InitRequest;
|
|
495
|
+
/** Consolidated request for table function cardinality. */
|
|
496
|
+
export interface TableFunctionCardinalityRequest {
|
|
497
|
+
/** The originating `BindRequest` (function name, arguments, schemas). */
|
|
498
|
+
bind_call: Nested<BindRequest>;
|
|
499
|
+
/** Opaque per-bind state the worker returned from bind(), threaded back into later calls (same contract as `InitRequest.bind_opaque_data`). */
|
|
500
|
+
bind_opaque_data?: Uint8Array | null;
|
|
501
|
+
}
|
|
502
|
+
/** Fields of `TableFunctionCardinalityRequest` that have a protocol default. */
|
|
503
|
+
export type TableFunctionCardinalityRequestDefaultedField = "bind_opaque_data";
|
|
504
|
+
/** `TableFunctionCardinalityRequest` with every field that has a protocol default optional. */
|
|
505
|
+
export type TableFunctionCardinalityRequestInit = Omit<TableFunctionCardinalityRequest, TableFunctionCardinalityRequestDefaultedField> & Partial<Pick<TableFunctionCardinalityRequest, TableFunctionCardinalityRequestDefaultedField>>;
|
|
506
|
+
/** Build a complete `TableFunctionCardinalityRequest`, filling the protocol defaults, in wire order. */
|
|
507
|
+
export declare function buildTableFunctionCardinalityRequest(init: TableFunctionCardinalityRequestInit): TableFunctionCardinalityRequest;
|
|
508
|
+
/** Encode a `TableFunctionCardinalityRequest`; each nested record is written as its wrapper's held bytes, never re-serialized. */
|
|
509
|
+
export declare function encodeTableFunctionCardinalityRequest(v: TableFunctionCardinalityRequest): Uint8Array;
|
|
510
|
+
/** Decode a `TableFunctionCardinalityRequest`; each nested record is held as received and decoded only when accessed. */
|
|
511
|
+
export declare function decodeTableFunctionCardinalityRequest(b: Uint8Array): TableFunctionCardinalityRequest;
|
|
512
|
+
/** Consolidated request for table function per-column statistics. Mirrors `TableFunctionCardinalityRequest`: the worker receives a full copy of the original `BindRequest` (including parsed `Arguments`), so it can derive per-column stats from the user-supplied args. */
|
|
513
|
+
export interface TableFunctionStatisticsRequest {
|
|
514
|
+
/** The originating `BindRequest` (function name, arguments, schemas). */
|
|
515
|
+
bind_call: Nested<BindRequest>;
|
|
516
|
+
/** Opaque per-bind state the worker returned from bind(), threaded back into later calls (same contract as `InitRequest.bind_opaque_data`). */
|
|
517
|
+
bind_opaque_data?: Uint8Array | null;
|
|
518
|
+
}
|
|
519
|
+
/** Fields of `TableFunctionStatisticsRequest` that have a protocol default. */
|
|
520
|
+
export type TableFunctionStatisticsRequestDefaultedField = "bind_opaque_data";
|
|
521
|
+
/** `TableFunctionStatisticsRequest` with every field that has a protocol default optional. */
|
|
522
|
+
export type TableFunctionStatisticsRequestInit = Omit<TableFunctionStatisticsRequest, TableFunctionStatisticsRequestDefaultedField> & Partial<Pick<TableFunctionStatisticsRequest, TableFunctionStatisticsRequestDefaultedField>>;
|
|
523
|
+
/** Build a complete `TableFunctionStatisticsRequest`, filling the protocol defaults, in wire order. */
|
|
524
|
+
export declare function buildTableFunctionStatisticsRequest(init: TableFunctionStatisticsRequestInit): TableFunctionStatisticsRequest;
|
|
525
|
+
/** Encode a `TableFunctionStatisticsRequest`; each nested record is written as its wrapper's held bytes, never re-serialized. */
|
|
526
|
+
export declare function encodeTableFunctionStatisticsRequest(v: TableFunctionStatisticsRequest): Uint8Array;
|
|
527
|
+
/** Decode a `TableFunctionStatisticsRequest`; each nested record is held as received and decoded only when accessed. */
|
|
528
|
+
export declare function decodeTableFunctionStatisticsRequest(b: Uint8Array): TableFunctionStatisticsRequest;
|
|
529
|
+
/** Post-execution profile-info request, fired once per scan thread. Carries `global_execution_id` so the function class can retrieve whatever diagnostics it persisted during `process()` (shared storage, external service, in-memory class state for single-worker setups, etc.). VGI does not serialize per-thread `_user_state` across the boundary — the user owns persistence. */
|
|
530
|
+
export interface TableFunctionDynamicToStringRequest {
|
|
531
|
+
/** The originating `BindRequest` (function name, arguments, schemas). */
|
|
532
|
+
bind_call: Nested<BindRequest>;
|
|
533
|
+
/** Opaque per-bind state the worker returned from bind(), threaded back into later calls (same contract as `InitRequest.bind_opaque_data`). */
|
|
534
|
+
bind_opaque_data?: Uint8Array | null;
|
|
535
|
+
/** Query-wide execution id under which the function persisted the diagnostics this RPC retrieves. */
|
|
536
|
+
global_execution_id: Uint8Array;
|
|
537
|
+
}
|
|
538
|
+
/** Fields of `TableFunctionDynamicToStringRequest` that have a protocol default. */
|
|
539
|
+
export type TableFunctionDynamicToStringRequestDefaultedField = "bind_opaque_data";
|
|
540
|
+
/** `TableFunctionDynamicToStringRequest` with every field that has a protocol default optional. */
|
|
541
|
+
export type TableFunctionDynamicToStringRequestInit = Omit<TableFunctionDynamicToStringRequest, TableFunctionDynamicToStringRequestDefaultedField> & Partial<Pick<TableFunctionDynamicToStringRequest, TableFunctionDynamicToStringRequestDefaultedField>>;
|
|
542
|
+
/** Build a complete `TableFunctionDynamicToStringRequest`, filling the protocol defaults, in wire order. */
|
|
543
|
+
export declare function buildTableFunctionDynamicToStringRequest(init: TableFunctionDynamicToStringRequestInit): TableFunctionDynamicToStringRequest;
|
|
544
|
+
/** Encode a `TableFunctionDynamicToStringRequest`; each nested record is written as its wrapper's held bytes, never re-serialized. */
|
|
545
|
+
export declare function encodeTableFunctionDynamicToStringRequest(v: TableFunctionDynamicToStringRequest): Uint8Array;
|
|
546
|
+
/** Decode a `TableFunctionDynamicToStringRequest`; each nested record is held as received and decoded only when accessed. */
|
|
547
|
+
export declare function decodeTableFunctionDynamicToStringRequest(b: Uint8Array): TableFunctionDynamicToStringRequest;
|
|
548
|
+
/** Request for the scan-planning phase that precedes per-split `init()`. `plan()` runs once with the pushdown filters and returns named splits; each split is then redeemed by `init()` from any process or host. This is what makes the scan sound in a distributed engine, where a retried task must be able to re-request exactly the work it was given. */
|
|
549
|
+
export interface TableFunctionPlanRequest {
|
|
550
|
+
/** The originating `BindRequest`. */
|
|
551
|
+
bind_call: Nested<BindRequest>;
|
|
552
|
+
/** Opaque per-bind state the worker returned from bind(). */
|
|
553
|
+
bind_opaque_data?: Uint8Array | null;
|
|
554
|
+
/** Column indices the client wants projected. */
|
|
555
|
+
projection_ids?: number[] | null;
|
|
556
|
+
/** Serialized filter predicates. */
|
|
557
|
+
pushdown_filters?: Uint8Array | null;
|
|
558
|
+
/** Serialized join-key batches pushed down for join filtering. */
|
|
559
|
+
join_keys?: Uint8Array[] | null;
|
|
560
|
+
/** Plain fetch limit. NOT `order_by_limit` (which is a field of the Top-N hint). DuckDB cannot supply this — `TableFunctionInitInput` has no limit field — so it is always `None` from DuckDB; DataFusion supplies it from `TableProvider::scan(limit)`. */
|
|
561
|
+
row_limit?: number | null;
|
|
562
|
+
/** Requested split size. The primary sizing lever: a worker should emit splits of comparable cost, because the client cannot see per-split cost and will claim them as interchangeable units. */
|
|
563
|
+
target_split_bytes?: number | null;
|
|
564
|
+
/** Parallelism floor — a small but expensive table still needs enough splits to occupy the client's readers. */
|
|
565
|
+
min_splits?: number | null;
|
|
566
|
+
/** Pagination cap (Trino `getNextBatch(maxSize)`), NOT a sizing hint. */
|
|
567
|
+
max_splits_per_response?: number | null;
|
|
568
|
+
/** Resume point in the *enumeration of splits*. Distinct from `start_position`, which names a place in the *data*. */
|
|
569
|
+
cursor?: Uint8Array | null;
|
|
570
|
+
/** Conjunctive narrowing on a continuation. Narrows future splits only; splits already emitted under a looser filter stay valid. */
|
|
571
|
+
refined_filters?: Uint8Array | null;
|
|
572
|
+
/** False means more refinement may arrive, so the worker may hold back splits; True says stop waiting. */
|
|
573
|
+
filters_complete: boolean;
|
|
574
|
+
/** Exclusive lower bound in the data; `None` = from the start. */
|
|
575
|
+
start_position?: Uint8Array | null;
|
|
576
|
+
/** Inclusive upper bound; `None` = "as of now", and the worker reports the frontier it resolved in `PlanResponse.end_position`. */
|
|
577
|
+
end_position?: Uint8Array | null;
|
|
578
|
+
/** Column of the order-pushdown hint. */
|
|
579
|
+
order_by_column_name?: string | null;
|
|
580
|
+
/** Direction of the order-pushdown hint. */
|
|
581
|
+
order_by_direction?: string | null;
|
|
582
|
+
/** Null ordering of the order-pushdown hint. */
|
|
583
|
+
order_by_null_order?: string | null;
|
|
584
|
+
/** Row limit of the Top-N order-pushdown hint. */
|
|
585
|
+
order_by_limit?: number | null;
|
|
586
|
+
/** TABLESAMPLE percentage hint. */
|
|
587
|
+
tablesample_percentage?: number | null;
|
|
588
|
+
/** TABLESAMPLE seed hint. */
|
|
589
|
+
tablesample_seed?: number | null;
|
|
590
|
+
}
|
|
591
|
+
/** Fields of `TableFunctionPlanRequest` that have a protocol default. */
|
|
592
|
+
export type TableFunctionPlanRequestDefaultedField = "bind_opaque_data" | "projection_ids" | "pushdown_filters" | "join_keys" | "row_limit" | "target_split_bytes" | "min_splits" | "max_splits_per_response" | "cursor" | "refined_filters" | "filters_complete" | "start_position" | "end_position" | "order_by_column_name" | "order_by_direction" | "order_by_null_order" | "order_by_limit" | "tablesample_percentage" | "tablesample_seed";
|
|
593
|
+
/** `TableFunctionPlanRequest` with every field that has a protocol default optional. */
|
|
594
|
+
export type TableFunctionPlanRequestInit = Omit<TableFunctionPlanRequest, TableFunctionPlanRequestDefaultedField> & Partial<Pick<TableFunctionPlanRequest, TableFunctionPlanRequestDefaultedField>>;
|
|
595
|
+
/** Build a complete `TableFunctionPlanRequest`, filling the protocol defaults, in wire order. */
|
|
596
|
+
export declare function buildTableFunctionPlanRequest(init: TableFunctionPlanRequestInit): TableFunctionPlanRequest;
|
|
597
|
+
/** Encode a `TableFunctionPlanRequest`; each nested record is written as its wrapper's held bytes, never re-serialized. */
|
|
598
|
+
export declare function encodeTableFunctionPlanRequest(v: TableFunctionPlanRequest): Uint8Array;
|
|
599
|
+
/** Decode a `TableFunctionPlanRequest`; each nested record is held as received and decoded only when accessed. */
|
|
600
|
+
export declare function decodeTableFunctionPlanRequest(b: Uint8Array): TableFunctionPlanRequest;
|
|
601
|
+
/** Propose pure scalar outputs after bind, before modifying an execution plan. Expressions address the complete original worker output schema. Their result fields are parallel by index; accepted fields append to that schema. Planning allocates no execution resources and cannot consume rows or produce effects. */
|
|
602
|
+
export interface TableFunctionProjectionRequest {
|
|
603
|
+
bind_call: Nested<BindRequest>;
|
|
604
|
+
bind_result: Uint8Array;
|
|
605
|
+
expressions: Uint8Array[];
|
|
606
|
+
result_schema: Uint8Array;
|
|
607
|
+
}
|
|
608
|
+
/** `TableFunctionProjectionRequest` has no defaulted fields, so its init is the record itself. */
|
|
609
|
+
export type TableFunctionProjectionRequestInit = TableFunctionProjectionRequest;
|
|
610
|
+
/** Build a complete `TableFunctionProjectionRequest`, filling the protocol defaults, in wire order. */
|
|
611
|
+
export declare function buildTableFunctionProjectionRequest(init: TableFunctionProjectionRequestInit): TableFunctionProjectionRequest;
|
|
612
|
+
/** Encode a `TableFunctionProjectionRequest`; each nested record is written as its wrapper's held bytes, never re-serialized. */
|
|
613
|
+
export declare function encodeTableFunctionProjectionRequest(v: TableFunctionProjectionRequest): Uint8Array;
|
|
614
|
+
/** Decode a `TableFunctionProjectionRequest`; each nested record is held as received and decoded only when accessed. */
|
|
615
|
+
export declare function decodeTableFunctionProjectionRequest(b: Uint8Array): TableFunctionProjectionRequest;
|
|
374
616
|
/** Fields of `CatalogAttachResult` that have a protocol default. */
|
|
375
617
|
export type CatalogAttachResultDefaultedField = "attach_opaque_data_required" | "default_schema" | "settings" | "secret_types" | "attach_catalogs" | "comment" | "tags" | "supports_column_statistics" | "global_functions" | "global_function_prefix" | "supports_catalog_contents" | "catalog_capabilities" | "selected_capabilities" | "query_pushdown";
|
|
376
618
|
/** `CatalogAttachResult` with every field that has a protocol default optional. */
|
|
@@ -3,7 +3,7 @@ import { type VgiSchema } from "../arrow/index.js";
|
|
|
3
3
|
/** The protocol's wire name: the `vgi_rpc.protocol` routing key and the HTTP path segment. */
|
|
4
4
|
export declare const VGI_PROTOCOL_NAME = "vgi.v3";
|
|
5
5
|
/** The protocol's semver, stamped on every request by a client of this protocol. */
|
|
6
|
-
export declare const VGI_PROTOCOL_VERSION = "3.
|
|
6
|
+
export declare const VGI_PROTOCOL_VERSION = "3.4.0";
|
|
7
7
|
/** What a unary handler returns: the result row, now or later. */
|
|
8
8
|
export type VgiReply<T> = T | ExternalRef | Promise<T | ExternalRef>;
|
|
9
9
|
/** The result of a unary method with no `result` column. */
|
package/dist/hosted.d.ts
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/** Environment variable that turns hosted mode on. Baked into the hosted base image. */
|
|
2
|
+
export declare const HOSTED_ENV = "VGI_ORCHARD_HOSTED";
|
|
3
|
+
/** The challenge on every hosted-mode 401. No `resource_metadata`: a Field
|
|
4
|
+
* Worker never sends a client off to discover an authorization server. */
|
|
5
|
+
export declare const HOSTED_CHALLENGE = "Bearer error=\"invalid_token\"";
|
|
6
|
+
/** `AuthContext.domain` of a caller authenticated by a Pass. */
|
|
7
|
+
export declare const HOSTED_AUTH_DOMAIN = "orchard";
|
|
8
|
+
/** Default (and only-by-override) signing algorithm for Passes. */
|
|
9
|
+
export declare const DEFAULT_HOSTED_ALGORITHMS: readonly string[];
|
|
10
|
+
/** Required JOSE `typ` (RFC 9068). */
|
|
11
|
+
export declare const REQUIRED_TYP = "at+jwt";
|
|
12
|
+
/** Clock skew allowed on `exp` / `nbf`, seconds. */
|
|
13
|
+
export declare const LEEWAY_SECONDS = 60;
|
|
14
|
+
/** Hard upper bound on how long JWKS keys are trusted, seconds. */
|
|
15
|
+
export declare const JWKS_MAX_AGE_SECONDS = 600;
|
|
16
|
+
/** Minimum time between JWKS re-fetches triggered by an unknown `kid`, seconds. */
|
|
17
|
+
export declare const JWKS_REFRESH_MIN_INTERVAL_SECONDS = 60;
|
|
18
|
+
/** Timeout for each JWKS request, seconds. */
|
|
19
|
+
export declare const JWKS_FETCH_TIMEOUT_SECONDS = 10;
|
|
20
|
+
/** The shortest signing key a hosted worker accepts, bytes. */
|
|
21
|
+
export declare const MIN_SIGNING_KEY_BYTES = 32;
|
|
22
|
+
/**
|
|
23
|
+
* The request cap a hosted worker serves with when neither
|
|
24
|
+
* `VGI_RPC_MAX_REQUEST_BYTES` nor `maxRequestBytes` sets one: 32 MiB
|
|
25
|
+
* (vgi-python `HOSTED_DEFAULT_MAX_REQUEST_BYTES`). Advertised as
|
|
26
|
+
* `VGI-Max-Request-Bytes`, so with the blob vendor a larger request goes up
|
|
27
|
+
* through an upload URL instead.
|
|
28
|
+
*/
|
|
29
|
+
export declare const HOSTED_DEFAULT_MAX_REQUEST_BYTES: number;
|
|
30
|
+
/** An environment: `process.env`, a Cloudflare Worker's `env`, or a test map. */
|
|
31
|
+
export type HostedEnv = Readonly<Record<string, string | undefined>>;
|
|
32
|
+
/**
|
|
33
|
+
* A hosted-mode configuration error. The worker must not start.
|
|
34
|
+
*
|
|
35
|
+
* `serveVgiWorker` and `Worker.run` print the message and exit non-zero;
|
|
36
|
+
* `createVgiFetch` / `createVgiWorkerFetch` throw it at construction.
|
|
37
|
+
*/
|
|
38
|
+
export declare class OrchardHostedConfigError extends Error {
|
|
39
|
+
constructor(reason: string, options?: {
|
|
40
|
+
raw?: boolean;
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
/** Verified hosted-mode settings, read from the environment. */
|
|
44
|
+
export interface HostedConfig {
|
|
45
|
+
/** The Front Desk issuer (`iss`), matched exactly. */
|
|
46
|
+
readonly issuer: string;
|
|
47
|
+
/** The one canonical Desk Address (`aud`), matched exactly. */
|
|
48
|
+
readonly audience: string;
|
|
49
|
+
/** Where the Front Desk publishes its signing keys. */
|
|
50
|
+
readonly jwksUri: string;
|
|
51
|
+
/** Accepted JWS algorithms (`ES256` unless overridden). */
|
|
52
|
+
readonly algorithms: readonly string[];
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Whether `VGI_ORCHARD_HOSTED` turns hosted mode on.
|
|
56
|
+
*
|
|
57
|
+
* True for `1`/`true`/`yes`/`on` (any case), false when unset or
|
|
58
|
+
* `0`/`false`/`no`/`off`/empty. Any other value throws
|
|
59
|
+
* {@link OrchardHostedConfigError}: a typo must not quietly start a worker
|
|
60
|
+
* without authentication.
|
|
61
|
+
*/
|
|
62
|
+
export declare function hostedModeEnabled(env?: HostedEnv): boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Parse a `VGI_JWT_ALGORITHMS` value: comma-separated JWS algorithm names.
|
|
65
|
+
* `none` and `HS*` are always refused: an HMAC algorithm checked against a
|
|
66
|
+
* JWKS lets anyone holding the *public* key mint tokens.
|
|
67
|
+
*
|
|
68
|
+
* Returns the default (`ES256`) when unset or blank.
|
|
69
|
+
*/
|
|
70
|
+
export declare function parseJwtAlgorithms(raw: string | undefined): readonly string[];
|
|
71
|
+
/**
|
|
72
|
+
* Read and validate the hosted-mode environment.
|
|
73
|
+
*
|
|
74
|
+
* @throws OrchardHostedConfigError when a required variable is missing, empty
|
|
75
|
+
* or multi-valued, or `VGI_JWT_ALGORITHMS` is unusable.
|
|
76
|
+
*/
|
|
77
|
+
export declare function resolveHostedConfig(env?: HostedEnv): HostedConfig;
|
|
78
|
+
/**
|
|
79
|
+
* Refuse when the environment configures another credential.
|
|
80
|
+
*
|
|
81
|
+
* The TypeScript SDK reads none of these itself, but a hosted image built from
|
|
82
|
+
* another SDK's conventions may carry them, and each one means the operator
|
|
83
|
+
* expects a second way in. Refusing is the only answer that cannot be wrong.
|
|
84
|
+
*
|
|
85
|
+
* @throws OrchardHostedConfigError on `VGI_BEARER_TOKENS`, `VGI_RPC_GRANT_KEYS`,
|
|
86
|
+
* `VGI_OAUTH_RESOURCE` or an active `VGI_PROXY_PROOF_MODE`.
|
|
87
|
+
*/
|
|
88
|
+
export declare function checkHostedEnvironment(env?: HostedEnv): void;
|
|
89
|
+
/**
|
|
90
|
+
* Refuse a hosted worker whose signing key is not stable across restarts.
|
|
91
|
+
*
|
|
92
|
+
* The key seals catalog opaque data and HTTP state tokens. A Field Worker's
|
|
93
|
+
* machines stop and start, and a deployment can run on several of them: a key
|
|
94
|
+
* generated per process makes every restart (and every other machine) reject
|
|
95
|
+
* the sessions DuckDB already holds.
|
|
96
|
+
*
|
|
97
|
+
* @param env the environment (`VGI_SIGNING_KEY`, `VGI_SIGNING_KEY_MINTED`).
|
|
98
|
+
* @param explicit a key passed in code, if any. It counts as configured.
|
|
99
|
+
* @throws OrchardHostedConfigError when there is no configured key, the
|
|
100
|
+
* environment marks it as minted by a parent process, or it is shorter than
|
|
101
|
+
* {@link MIN_SIGNING_KEY_BYTES}.
|
|
102
|
+
*/
|
|
103
|
+
export declare function checkHostedSigningKey(env: HostedEnv, explicit?: Uint8Array | string): void;
|
|
104
|
+
/**
|
|
105
|
+
* Hosted mode from an environment, for `createVgiFetch({ orchardHosted })`.
|
|
106
|
+
*
|
|
107
|
+
* Returns `undefined` when `VGI_ORCHARD_HOSTED` is off. When it is on, returns
|
|
108
|
+
* the validated configuration after checking the environment for any other
|
|
109
|
+
* credential. Cloudflare Workers pass the Worker's `env`; `serveVgiWorker`
|
|
110
|
+
* reads `process.env` itself.
|
|
111
|
+
*
|
|
112
|
+
* @throws OrchardHostedConfigError on any misconfiguration.
|
|
113
|
+
*/
|
|
114
|
+
export declare function orchardHostedFromEnv(env?: HostedEnv): HostedConfig | undefined;
|
|
115
|
+
/** Refuse a non-HTTP transport (stdio, AF_UNIX, TCP, the Iroh raw upstream,
|
|
116
|
+
* a caller-provided byte stream) when hosted mode is on: none carries a Pass. */
|
|
117
|
+
export declare function refuseNonHttpTransportInHostedMode(transport: string, env?: HostedEnv): void;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type ExternalLocationConfig, type UploadUrlProvider } from "@query-farm/vgi-rpc";
|
|
2
|
+
/** The variables {@link blobVendorHttpConfigFromEnv} reads. */
|
|
3
|
+
export interface BlobVendorEnv {
|
|
4
|
+
VGI_BLOB_VENDOR_URL?: string | undefined;
|
|
5
|
+
VGI_BLOB_VENDOR_TOKEN?: string | undefined;
|
|
6
|
+
VGI_CF_DO_TOKEN?: string | undefined;
|
|
7
|
+
VGI_RPC_EXTERNALIZE_THRESHOLD_BYTES?: string | undefined;
|
|
8
|
+
VGI_RPC_EXTERNAL_COMPRESSION?: string | undefined;
|
|
9
|
+
VGI_RPC_MAX_REQUEST_BYTES?: string | undefined;
|
|
10
|
+
VGI_RPC_MAX_UPLOAD_BYTES?: string | undefined;
|
|
11
|
+
}
|
|
12
|
+
/** HTTP handler options from the blob-vendor environment. Every field is
|
|
13
|
+
* absent when nothing is configured. */
|
|
14
|
+
export interface BlobVendorHttpConfig {
|
|
15
|
+
/** Large results are uploaded to the vendor and replaced by a pointer
|
|
16
|
+
* carrying `vgi_rpc.location.sha256`; inbound pointers are fetched only from
|
|
17
|
+
* the vendor's storage hosts. */
|
|
18
|
+
externalLocation?: ExternalLocationConfig | undefined;
|
|
19
|
+
/** The vendor, vending pre-signed upload URLs (`__upload_url__/init`) so
|
|
20
|
+
* clients can send requests over {@link maxRequestBytes}. */
|
|
21
|
+
uploadUrlProvider?: UploadUrlProvider | undefined;
|
|
22
|
+
/** `VGI_RPC_MAX_UPLOAD_BYTES`, advertised as `VGI-Max-Upload-Bytes`. */
|
|
23
|
+
maxUploadBytes?: number | undefined;
|
|
24
|
+
/** `VGI_RPC_MAX_REQUEST_BYTES`, advertised as `VGI-Max-Request-Bytes` and enforced. */
|
|
25
|
+
maxRequestBytes?: number | undefined;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Read the blob-vendor HTTP settings from `env`.
|
|
29
|
+
*
|
|
30
|
+
* @throws Error if a variable is set but malformed, or the vendor URL is set
|
|
31
|
+
* without a token.
|
|
32
|
+
*/
|
|
33
|
+
export declare function blobVendorHttpConfigFromEnv(env: BlobVendorEnv): BlobVendorHttpConfig;
|
package/dist/http/fetch.d.ts
CHANGED
|
@@ -2,7 +2,16 @@ import { type AuthenticateFn, type PeerAuthenticationPolicy, type PeerIdentityPr
|
|
|
2
2
|
import { type ProtocolConfig } from "../protocol/dispatch.js";
|
|
3
3
|
import { type LandingInfo } from "./landing.js";
|
|
4
4
|
import { type HostingOptions } from "../rpc-server.js";
|
|
5
|
-
|
|
5
|
+
import type { BlobVendorHttpConfig } from "./blob-vendor.js";
|
|
6
|
+
import { type HostedConfig } from "../hosted.js";
|
|
7
|
+
import { type HostedVerifierDeps } from "./hosted-auth.js";
|
|
8
|
+
/**
|
|
9
|
+
* The external-location fields ({@link BlobVendorHttpConfig}) are forwarded to
|
|
10
|
+
* vgi-rpc's handler: spread `blobVendorHttpConfigFromEnv(env)` in to serve
|
|
11
|
+
* through the blob vendor (results over the threshold become pointers, large
|
|
12
|
+
* requests arrive through vended upload URLs).
|
|
13
|
+
*/
|
|
14
|
+
export interface VgiFetchOptions extends HostingOptions, BlobVendorHttpConfig {
|
|
6
15
|
/** Wire-protocol config (registry + catalogInterface). */
|
|
7
16
|
protocol: ProtocolConfig;
|
|
8
17
|
/** HMAC key for state-token signing. Pass a stable, secret 32-byte key
|
|
@@ -15,8 +24,34 @@ export interface VgiFetchOptions extends HostingOptions {
|
|
|
15
24
|
* grants): tickets sealed under a generated key would die on restart.
|
|
16
25
|
* Defaults to `true`, since this factory requires the key to be passed. */
|
|
17
26
|
signingKeyConfigured?: boolean | undefined;
|
|
18
|
-
/**
|
|
27
|
+
/**
|
|
28
|
+
* Input key material for sealed framework storage payloads. Pass the
|
|
29
|
+
* configured `VGI_SIGNING_KEY` *string* (its UTF-8 bytes are the cross-SDK
|
|
30
|
+
* ikm, so Python, Java and TypeScript workers of one deployment agree), or
|
|
31
|
+
* bytes to use unchanged. Defaults to {@link signingKey}'s bytes.
|
|
32
|
+
*/
|
|
33
|
+
storageSealKey?: Uint8Array | string | undefined;
|
|
34
|
+
/** State-token TTL in seconds (default 21600, 6 h: vgi-rpc STATE_REF_V1.md). */
|
|
19
35
|
tokenTtl?: number | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* vgi-rpc's cursor rule for a stream state token over its turn budget
|
|
38
|
+
* (STATE_REF_V1.md §9). Defaults to `"error"` (`cursor_too_large`): this SDK
|
|
39
|
+
* carries its init request as an `init` StateRef, so a cursor over budget
|
|
40
|
+
* is a bug to surface, not a size to tolerate.
|
|
41
|
+
*/
|
|
42
|
+
cursorRule?: "warn" | "error" | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* The `VGI-Arguments-Ref-Bytes` value advertised when the server vends
|
|
45
|
+
* upload URLs and its storage is a vgi-rpc ObjectStore (protocol 3.4
|
|
46
|
+
* argument references). Defaults to `$VGI_ARGUMENTS_REF_BYTES`, else 4 MiB.
|
|
47
|
+
*/
|
|
48
|
+
argumentsRefBytes?: number | undefined;
|
|
49
|
+
/**
|
|
50
|
+
* Environment read for `VGI_ARGUMENTS_REF_BYTES` and the test switch
|
|
51
|
+
* `VGI_TEST_DISABLE_ARGUMENTS_REF` (a Cloudflare Worker passes its `env`).
|
|
52
|
+
* Defaults to `process.env` where there is one.
|
|
53
|
+
*/
|
|
54
|
+
env?: Readonly<Record<string, string | undefined>> | undefined;
|
|
20
55
|
/** URL path prefix for VGI requests (default "/vgi"). Pass "" to mount at
|
|
21
56
|
* the root, which is what a dedicated single-worker HTTP server wants. */
|
|
22
57
|
prefix?: string | undefined;
|
|
@@ -65,7 +100,30 @@ export interface VgiFetchOptions extends HostingOptions {
|
|
|
65
100
|
peerAuthenticationPolicy?: PeerAuthenticationPolicy | undefined;
|
|
66
101
|
/** Host adapter supplying the physical peer and multiplicity-preserving headers. */
|
|
67
102
|
peerResolutionContext?: ((request: Request) => PeerResolutionOptions | Promise<PeerResolutionOptions>) | undefined;
|
|
103
|
+
/**
|
|
104
|
+
* Orchard hosted mode: accept only Orchard Passes (RFC 9068 JWT access
|
|
105
|
+
* tokens) on every request except `HEAD /health` and CORS preflights. Pass
|
|
106
|
+
* `orchardHostedFromEnv(env)`, which is `undefined` unless
|
|
107
|
+
* `VGI_ORCHARD_HOSTED` is on. `serveVgiWorker` / `createVgiWorkerFetch` set
|
|
108
|
+
* it from `process.env` themselves.
|
|
109
|
+
*
|
|
110
|
+
* Construction throws `OrchardHostedConfigError` when any other way in is
|
|
111
|
+
* configured (`authenticate`, `grantKeys`, `resolveToken`, `mintGrant`, peer
|
|
112
|
+
* identity) or the signing key is not a configured one. CORS is forced open
|
|
113
|
+
* (`*`): the only credential is the bearer Pass.
|
|
114
|
+
*/
|
|
115
|
+
orchardHosted?: HostedConfig | undefined;
|
|
116
|
+
/** Test seam for hosted mode's JWKS fetch and clock. */
|
|
117
|
+
orchardHostedDeps?: HostedVerifierDeps | undefined;
|
|
68
118
|
}
|
|
119
|
+
/**
|
|
120
|
+
* Refuse a `createVgiFetch` configuration that admits a caller without a Pass.
|
|
121
|
+
* Called by `createVgiFetch` whenever `orchardHosted` is set; throws
|
|
122
|
+
* {@link OrchardHostedConfigError}.
|
|
123
|
+
*/
|
|
124
|
+
export declare function checkHostedFetchOptions(opts: VgiFetchOptions): void;
|
|
125
|
+
/** Default state-token TTL: 6 h (vgi-rpc STATE_REF_V1.md, protocol 3.4). */
|
|
126
|
+
export declare const DEFAULT_TOKEN_TTL = 21600;
|
|
69
127
|
/**
|
|
70
128
|
* Build a fetch handler suitable for `export default { fetch }` in a CF
|
|
71
129
|
* Worker module, or for `Bun.serve({ fetch })`. The returned handler is
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { type AuthenticateFn } from "@query-farm/vgi-rpc";
|
|
2
|
+
import { type HostedConfig } from "../hosted.js";
|
|
3
|
+
/** The slice of `fetch` the JWKS client uses. */
|
|
4
|
+
export type JwksFetch = (url: string, init: RequestInit) => Promise<Response>;
|
|
5
|
+
/** Injection points for tests. Production uses the global `fetch` and clock. */
|
|
6
|
+
export interface HostedVerifierDeps {
|
|
7
|
+
/** Fetch used for the JWKS (default `globalThis.fetch`). */
|
|
8
|
+
fetch?: JwksFetch | undefined;
|
|
9
|
+
/** Clock, milliseconds since the epoch (default `Date.now`). */
|
|
10
|
+
now?: (() => number) | undefined;
|
|
11
|
+
/** Operator warnings (JWKS failures). Never receives a credential. Default `console.error`. */
|
|
12
|
+
warn?: ((message: string) => void) | undefined;
|
|
13
|
+
/** Debug lines (per-request rejections). Never receives a credential. Default: off. */
|
|
14
|
+
debug?: ((message: string) => void) | undefined;
|
|
15
|
+
}
|
|
16
|
+
/** The `max-age` directive of a `Cache-Control` header, seconds, or `null`. */
|
|
17
|
+
export declare function cacheControlMaxAge(value: string | null | undefined): number | null;
|
|
18
|
+
/**
|
|
19
|
+
* Build the Pass verifier for `config`: an `AuthenticateFn` returning an
|
|
20
|
+
* `AuthContext` with domain `"orchard"`, principal `sub` and the Pass's claims
|
|
21
|
+
* exactly as decoded (booleans stay booleans, numbers stay numbers).
|
|
22
|
+
*
|
|
23
|
+
* It throws `AuthFailure` (401) with reason `missing_credential`,
|
|
24
|
+
* `invalid_credential` or `expired_credential`, and `AuthUnavailableError`
|
|
25
|
+
* (503 with `Retry-After`) when no JWKS within its maximum age can be fetched.
|
|
26
|
+
*/
|
|
27
|
+
export declare function hostedAuthenticate(config: HostedConfig, deps?: HostedVerifierDeps): AuthenticateFn;
|
|
28
|
+
/** Whether `fn` was built by {@link hostedAuthenticate}. */
|
|
29
|
+
export declare function isHostedAuthenticate(fn: unknown): boolean;
|
|
30
|
+
/** A hosted gate: the verifier, the `authenticate` to hand vgi-rpc, and the wrapper. */
|
|
31
|
+
export interface HostedGate {
|
|
32
|
+
/** The Pass verifier. */
|
|
33
|
+
readonly verify: AuthenticateFn;
|
|
34
|
+
/**
|
|
35
|
+
* The `authenticate` to give `createHttpHandler`. It returns the identity
|
|
36
|
+
* the gate already verified for this request (re-verifying only if the
|
|
37
|
+
* handler was given a different `Request` object), so a Pass is checked
|
|
38
|
+
* once per request.
|
|
39
|
+
*/
|
|
40
|
+
readonly authenticate: AuthenticateFn;
|
|
41
|
+
/** Put the gate in front of a vgi-rpc HTTP handler mounted at `prefix`. */
|
|
42
|
+
wrap(handler: (req: Request) => Promise<Response> | Response, prefix: string): (req: Request) => Promise<Response>;
|
|
43
|
+
}
|
|
44
|
+
/** Build the hosted-mode request gate for `config`. */
|
|
45
|
+
export declare function createHostedGate(config: HostedConfig, deps?: HostedVerifierDeps): HostedGate;
|
package/dist/index.core.d.ts
CHANGED
|
@@ -18,7 +18,9 @@ export * from "./catalog/public-codecs.js";
|
|
|
18
18
|
export { CompositeCatalogInterface } from "./catalog/composite.js";
|
|
19
19
|
export { FunctionRegistry } from "./functions/registry.js";
|
|
20
20
|
export { FunctionType, FunctionStability, NullHandling, ArgumentMonotonicity, OrderPreservation, OrderDependence, DistinctDependence, TableInOutPhase, DEFAULT_MAX_WORKERS, } from "./types.js";
|
|
21
|
-
export type { BindRequest, BindResponse, BindRepeatability, CopyFromContext, CopyToContext, InitRequest, GlobalInitResponse, TableCardinality, } from "./protocol/types.js";
|
|
21
|
+
export type { ArgumentsLocation, BindRequest, BindResponse, BindRepeatability, CopyFromContext, CopyToContext, InitRequest, GlobalInitResponse, TableCardinality, } from "./protocol/types.js";
|
|
22
|
+
export { decodeBindCall, bindCallBytes, receivedBindCall } from "./protocol/serializers/bind.js";
|
|
23
|
+
export { resolveBindCall, argumentsResolved, argumentsRefBytesFromEnv, argumentsRefHeaderValue, ARGUMENTS_REF_BYTES_HEADER, ARGUMENTS_REF_BYTES_ENV, DEFAULT_ARGUMENTS_REF_BYTES, DISABLE_ARGUMENTS_REF_ENV, ARGUMENTS_REF_MISSING_KIND, ARGUMENTS_REF_MISSING_MESSAGE, INVALID_BIND_REQUEST_KIND, INVALID_BIND_REQUEST_MESSAGE, INVALID_ARGUMENTS_REF_KIND, } from "./protocol/arguments-ref.js";
|
|
22
24
|
export type { ScanSplit, PlanResult, TableFunctionPlanRequest, } from "./protocol/serializers/splits.js";
|
|
23
25
|
export { type FieldPath, type FieldPathInit, buildFieldPath, encodeFieldPath, decodeFieldPath, type TransformSpec, type TransformSpecInit, buildTransformSpec, encodeTransformSpec, decodeTransformSpec, type KeyGrouping, type KeyGroupingInit, buildKeyGrouping, encodeKeyGrouping, decodeKeyGrouping, type RangeKey, type RangeKeyInit, buildRangeKey, encodeRangeKey, decodeRangeKey, type RangePartitioning, type RangePartitioningInit, buildRangePartitioning, encodeRangePartitioning, decodeRangePartitioning, } from "./generated/vgi-protocol-types.js";
|
|
24
26
|
export { Arguments } from "./arguments/arguments.js";
|
|
@@ -44,12 +46,16 @@ export { toUint8Array } from "./util/bytes.js";
|
|
|
44
46
|
export { iterRows, batchFromRows, batchFromColumns, emptyBatch, filterBatch, projectSchema, projectBatch, batchToScalarDict, batchToSecretDict, safeNumber, } from "./util/arrow/index.js";
|
|
45
47
|
export { type SecretFields, type SecretsDict, secretType, secretsOfType, secretOfType, requireSecretOfType, secretByName, secretForScope, secretForScopeOfType, } from "./secrets/helpers.js";
|
|
46
48
|
export { type RequiredSecret, type SecretRequirement, type SecretRequirementSpec, normalizeRequiredSecrets, } from "./secrets/requirements.js";
|
|
49
|
+
export type { SecretLookupFields } from "./secrets/lookups.js";
|
|
47
50
|
export { serializeSchema, deserializeSchema, serializeBatch, deserializeBatch, } from "./util/arrow/index.js";
|
|
48
51
|
export { schema, field, nullType, int8, int16, int64, uint8, uint16, uint32, uint64, float16, float64, utf8, largeUtf8, binary, largeBinary, fixedSizeBinary, decimal, decimal128, decimal256, date, dateDay, dateMillisecond, time, timeSecond, timeMillisecond, timeMicrosecond, timeNanosecond, timestamp, duration, interval, timestampSeconds, timestampMillis, timestampMicros, timestampNanos, durationSeconds, durationMillis, durationMicros, durationNanos, list, fixedSizeList, struct, map, dictionary, union, sparseUnion, denseUnion, TimeUnit, DateUnit, IntervalUnit, UnionMode, codecFor, asDate32, asDate64Ms, asTime32S, asTime32Ms, asTime64Us, asTime64Ns, asTimestampSeconds, asTimestampMillis, asTimestampMicros, asTimestampNanos, asDurationSeconds, asDurationMillis, asDurationMicros, asDurationNanos, asUnscaledDecimal, asInt64, asUint64, fromBranded, fromBrandedNumber, fromBrandedBigInt, TypeId, isNull, isInt, isFloat, isBinary, isUtf8, isBool, isDecimal, isDate, isTime, isTimestamp, isInterval, isList, isStruct, isUnion, isFixedSizeBinary, isFixedSizeList, isMap, isDuration, isDictionary, isBatch, typeSignature, readCanonicalValue, columnFromArray, decodeDictValue, backend, adoptArrowJsShape, } from "./arrow/index.js";
|
|
49
52
|
export type { VgiTypeId, VgiDataType, VgiField, VgiSchema, VgiColumn, VgiColumnData, VgiBatch, VgiBackendInfo, TaggedUnion, NullDescriptor, BoolType, IntType, Int8Type, Int16Type, Int32Type, Int64Type, Uint8Type, Uint16Type, Uint32Type, Uint64Type, FloatType, Utf8Type, LargeUtf8Type, BinaryType, LargeBinaryType, FixedSizeBinaryType, DecimalType, Date32Type, Date64Type, Time32Type, Time64Type, TimestampType, DurationType, IntervalType, ListType, FixedSizeListType, StructType, MapType, DictionaryType, UnionType, TypedField, TUnit, RichValue, RawValue, ValueFor, Repr, Codec, Branded, Date32, Date64Ms, Time32S, Time32Ms, Time64Us, Time64Ns, TimestampSeconds, TimestampMillis, TimestampMicros, TimestampNanos, DurationSeconds, DurationMillis, DurationMicros, DurationNanos, UnscaledDecimal, Int64Raw, Uint64Raw, } from "./arrow/index.js";
|
|
50
53
|
export type { ScalarComputeRow, ScalarOutputValue, ScalarComputeResult } from "./functions/scalar.js";
|
|
51
|
-
export { type FunctionStorage, type WorkerStateKey, FunctionStorageSqlite, BoundStorage, UnknownInvocationError, resolveStorageFromEnv, setStorage, storage as functionStorage, } from "./functions/storage.js";
|
|
52
|
-
export { FunctionStorageCfDo, type FetchLike } from "./functions/storage-cf-do.js";
|
|
54
|
+
export { type FunctionStorage, type WorkerStateKey, FunctionStorageSqlite, BoundStorage, UnknownInvocationError, resolveStorageFromEnv, setStorage, shardKeyOf, storage as functionStorage, } from "./functions/storage.js";
|
|
55
|
+
export { FunctionStorageCfDo, MAX_VALUE_BYTES as CF_DO_MAX_VALUE_BYTES, type FetchLike, type CfDoRetryOptions, } from "./functions/storage-cf-do.js";
|
|
56
|
+
export { ExternalizingStorage, type ExternalizingStorageOptions, StorageBlobError, StorageBlobIntegrityError, StorageBlobMissingError, StorageEnvelopeError, StorageValueTooLargeError, DEFAULT_EXTERNALIZE_BYTES, blobClientFromEnv, externalizeBytesFromEnv, wrapStorageFromEnv, type WrapStorageOptions, } from "./functions/storage-blobs.js";
|
|
57
|
+
export { blobVendorHttpConfigFromEnv, type BlobVendorEnv, type BlobVendorHttpConfig, } from "./http/blob-vendor.js";
|
|
58
|
+
export { StoragePayloadError } from "./functions/storage-seal.js";
|
|
53
59
|
export { VgiClient, VgiClientError } from "./client/client.js";
|
|
54
60
|
export type { VgiClientOptions, TableFunctionOptions, TableFunctionRowsOptions, Int64Mode, ScalarFunctionOptions, TableInOutFunctionOptions, OnCreateConflict, CatalogFunctionType as ClientCatalogFunctionType, CatalogAttachOptions, AttachOptionValue, CatalogSnapshot, LoadCatalogOptions, } from "./client/types.js";
|
|
55
61
|
export { str, bytes, int, int32, float, float32, bool, toSchema, OutputCollector, AuthContext } from "@query-farm/vgi-rpc";
|
|
@@ -58,5 +64,7 @@ export type { RpcClient, StreamSession, LogMessage } from "@query-farm/vgi-rpc";
|
|
|
58
64
|
export { buildRpcServer, grantKeysFromArgv, INTROSPECT_PRINCIPALS_ENV, type BuildRpcServerOptions, type HostingOptions, type ServerTransport, } from "./rpc-server.js";
|
|
59
65
|
export { AuthUnavailableError, GrantKeys, GrantRefusedError, IdentityUnavailableError, StatusError, } from "@query-farm/vgi-rpc";
|
|
60
66
|
export type { GrantMinter, IssuedGrant, TokenIdentity, TokenResolver } from "@query-farm/vgi-rpc";
|
|
67
|
+
export { HOSTED_ENV, HOSTED_CHALLENGE, HOSTED_AUTH_DOMAIN, OrchardHostedConfigError, hostedModeEnabled, resolveHostedConfig, orchardHostedFromEnv, checkHostedEnvironment, checkHostedSigningKey, type HostedConfig, type HostedEnv, } from "./hosted.js";
|
|
68
|
+
export { hostedAuthenticate, isHostedAuthenticate, type HostedVerifierDeps } from "./http/hosted-auth.js";
|
|
61
69
|
export { normalizeSchemaPath, schemaPathDisplay, schemaPathKey, schemaPathsEqual, type SchemaPath } from "./schema-path.js";
|
|
62
70
|
export { SCALAR_PROJECTION_PROFILE, type ProjectionProposal, type ProjectionAcceptance } from "./functions/projection.js";
|