@query-farm/vgi 0.47.2 → 0.48.1
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 +1 -1
- package/dist/arguments/argument-spec.d.ts +17 -11
- package/dist/catalog/descriptors.d.ts +2 -2
- package/dist/catalog/publication.d.ts +7 -7
- package/dist/client/client.d.ts +9 -3
- package/dist/client/errors.d.ts +2 -2
- package/dist/client/types.d.ts +21 -0
- package/dist/client-entry.d.ts +1 -1
- package/dist/client-entry.js +56 -7
- package/dist/client-entry.js.map +23 -23
- package/dist/filter-pushdown/deserialize.d.ts +1 -1
- package/dist/filter-pushdown/types.d.ts +10 -10
- package/dist/functions/scalar.d.ts +1 -1
- package/dist/functions/table-buffering.d.ts +20 -20
- package/dist/functions/table-in-out.d.ts +4 -4
- package/dist/functions/table.d.ts +7 -7
- package/dist/functions/types.d.ts +47 -47
- package/dist/generated/vgi-client.d.ts +5 -0
- package/dist/generated/vgi-protocol-schemas.d.ts +5 -0
- package/dist/generated/vgi-protocol-types.d.ts +57 -0
- package/dist/generated/vgi-service.d.ts +1 -1
- package/dist/http/fetch.d.ts +10 -10
- package/dist/index.core.d.ts +3 -1
- package/dist/index.js +289 -103
- package/dist/index.js.map +57 -55
- package/dist/protocol/dispatch.d.ts +4 -4
- package/dist/protocol/handlers/function.d.ts +2 -2
- package/dist/protocol/serializers/cardinality.d.ts +4 -1
- package/dist/protocol/serializers/splits.d.ts +41 -1
- package/dist/protocol/types.d.ts +5 -5
- package/dist/rpc-server.d.ts +6 -6
- package/dist/serve-entry.d.ts +16 -16
- package/dist/serve-entry.js +119 -30
- package/dist/serve-entry.js.map +42 -40
- package/dist/split-token.d.ts +6 -6
- package/dist/types.d.ts +9 -2
- package/dist/util/defined.d.ts +21 -0
- package/dist/worker-cf-entry.js +199 -94
- package/dist/worker-cf-entry.js.map +55 -53
- package/dist/worker.d.ts +2 -2
- package/package.json +6 -4
- package/src/arguments/argument-spec.ts +17 -11
- package/src/arrow/codec/registry.ts +2 -2
- package/src/arrow/impl-arrowjs/build.ts +1 -1
- package/src/arrow/impl-arrowjs/canonical.ts +23 -23
- package/src/arrow/impl-arrowjs/empty.ts +2 -2
- package/src/arrow/impl-arrowjs/ipc.ts +2 -2
- package/src/arrow/impl-arrowjs/iterate.ts +2 -2
- package/src/arrow/impl-arrowjs/project.ts +2 -2
- package/src/arrow/impl-flechette/build.ts +2 -1
- package/src/arrow/impl-flechette/canonical.ts +10 -9
- package/src/arrow/impl-flechette/compat.ts +3 -3
- package/src/arrow/impl-flechette/message-meta.ts +5 -4
- package/src/arrow/impl-flechette/statistics.ts +2 -2
- package/src/attach-ticket.ts +2 -2
- package/src/catalog/column-metadata.ts +1 -1
- package/src/catalog/composite.ts +2 -2
- package/src/catalog/constraints.ts +9 -9
- package/src/catalog/descriptors.ts +1 -1
- package/src/catalog/interface.ts +12 -12
- package/src/catalog/publication.ts +9 -8
- package/src/catalog/read-only.ts +9 -8
- package/src/catalog/sql-grammar.ts +6 -6
- package/src/client/client.ts +52 -15
- package/src/client/errors.ts +1 -1
- package/src/client/types.ts +23 -0
- package/src/client-entry.ts +2 -0
- package/src/codec/asd.ts +3 -3
- package/src/codec/conform.ts +3 -3
- package/src/filter-pushdown/collector.ts +1 -1
- package/src/filter-pushdown/deserialize.ts +13 -10
- package/src/filter-pushdown/evaluate.ts +3 -2
- package/src/filter-pushdown/history.ts +3 -2
- package/src/filter-pushdown/types.ts +10 -10
- package/src/functions/continuation.ts +1 -1
- package/src/functions/projection.ts +1 -1
- package/src/functions/registry.ts +14 -14
- package/src/functions/scalar.ts +3 -3
- package/src/functions/storage-cf-do.ts +2 -2
- package/src/functions/table-buffering.ts +25 -21
- package/src/functions/table-in-out.ts +8 -8
- package/src/functions/table.ts +27 -25
- package/src/functions/types.ts +47 -47
- package/src/generated/vgi-client.ts +6 -1
- package/src/generated/vgi-protocol-schemas.ts +36 -1
- package/src/generated/vgi-protocol-types.ts +130 -1
- package/src/generated/vgi-service.ts +7 -5
- package/src/http/fetch.ts +17 -12
- package/src/index.core.ts +34 -0
- package/src/protocol/carried-init-request.ts +1 -1
- package/src/protocol/dispatch.ts +4 -4
- package/src/protocol/handlers/aggregate.ts +8 -7
- package/src/protocol/handlers/catalog/shared.ts +1 -1
- package/src/protocol/handlers/function.ts +2 -2
- package/src/protocol/serializers/cardinality.ts +16 -3
- package/src/protocol/serializers/splits.ts +82 -9
- package/src/protocol/state-serializer.ts +1 -1
- package/src/protocol/types.ts +5 -5
- package/src/rpc-server.ts +13 -12
- package/src/serve-entry.ts +18 -18
- package/src/split-token.ts +10 -9
- package/src/types.ts +9 -2
- package/src/util/defined.ts +30 -0
- package/src/util/parent-rows.ts +2 -2
- package/src/worker.ts +15 -14
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// GENERATED by vgi.codegen.ts_client. DO NOT EDIT BY HAND.
|
|
3
3
|
//
|
|
4
4
|
// Generator: vgi-gen-ts-client v1
|
|
5
|
-
// Content hash:
|
|
5
|
+
// Content hash: 0fab849ec28b
|
|
6
6
|
//
|
|
7
7
|
// To regenerate:
|
|
8
8
|
// uv run --project ~/Development/vgi-python vgi-gen-ts-client \
|
|
@@ -784,6 +784,9 @@ export interface ScanSplit {
|
|
|
784
784
|
estimated_rows?: number | null;
|
|
785
785
|
rows_exact: boolean;
|
|
786
786
|
estimated_bytes?: number | null;
|
|
787
|
+
key_value?: /** @record-batch */ Uint8Array | null;
|
|
788
|
+
range_index?: number | null;
|
|
789
|
+
column_bounds?: /** @record-batch */ Uint8Array | null;
|
|
787
790
|
partition_bounds?: /** @record-batch */ Uint8Array | null;
|
|
788
791
|
column_statistics?: Uint8Array | null;
|
|
789
792
|
location_ids?: number[] | null;
|
|
@@ -803,6 +806,8 @@ export interface PlanResponse {
|
|
|
803
806
|
catalog_version?: number | null;
|
|
804
807
|
scope: string;
|
|
805
808
|
locations?: string[] | null;
|
|
809
|
+
key_grouping?: Uint8Array | null;
|
|
810
|
+
range_partitioning?: Uint8Array | null;
|
|
806
811
|
partitioning?: Uint8Array[] | null;
|
|
807
812
|
sort_order?: Uint8Array[] | null;
|
|
808
813
|
cache_max_age_seconds?: number | null;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// GENERATED by vgi.codegen.ts_schemas. DO NOT EDIT BY HAND.
|
|
3
3
|
//
|
|
4
4
|
// Generator: vgi-gen-ts-schemas v2
|
|
5
|
-
// Content hash:
|
|
5
|
+
// Content hash: 4b57381f6bef
|
|
6
6
|
//
|
|
7
7
|
// To regenerate:
|
|
8
8
|
// uv run --project ~/Development/vgi-python vgi-gen-ts-schemas \
|
|
@@ -165,6 +165,36 @@ export const CopyFromFormatInfoSchema = schema([
|
|
|
165
165
|
field("ordered", bool(), false),
|
|
166
166
|
]);
|
|
167
167
|
|
|
168
|
+
// Origin: FieldPath
|
|
169
|
+
export const FieldPathSchema = schema([
|
|
170
|
+
field("components", list(field("item", utf8(), true)), false),
|
|
171
|
+
]);
|
|
172
|
+
|
|
173
|
+
// Origin: TransformSpec
|
|
174
|
+
export const TransformSpecSchema = schema([
|
|
175
|
+
field("id", utf8(), false),
|
|
176
|
+
field("inputs", list(field("item", binary(), true)), false),
|
|
177
|
+
field("parameters", binary(), true),
|
|
178
|
+
]);
|
|
179
|
+
|
|
180
|
+
// Origin: KeyGrouping
|
|
181
|
+
export const KeyGroupingSchema = schema([
|
|
182
|
+
field("keys", list(field("item", binary(), true)), false),
|
|
183
|
+
]);
|
|
184
|
+
|
|
185
|
+
// Origin: RangeKey
|
|
186
|
+
export const RangeKeySchema = schema([
|
|
187
|
+
field("transform", binary(), false),
|
|
188
|
+
field("direction", dictionary(utf8(), int16()), false),
|
|
189
|
+
field("null_order", dictionary(utf8(), int16()), false),
|
|
190
|
+
]);
|
|
191
|
+
|
|
192
|
+
// Origin: RangePartitioning
|
|
193
|
+
export const RangePartitioningSchema = schema([
|
|
194
|
+
field("keys", list(field("item", binary(), true)), false),
|
|
195
|
+
field("split_points", binary(), false),
|
|
196
|
+
]);
|
|
197
|
+
|
|
168
198
|
// Origin: MacroParameter
|
|
169
199
|
export const MacroParameterSchema = schema([
|
|
170
200
|
field("name", utf8(), false),
|
|
@@ -462,6 +492,9 @@ export const ScanSplitSchema = schema([
|
|
|
462
492
|
field("estimated_rows", int64(), true),
|
|
463
493
|
field("rows_exact", bool(), false),
|
|
464
494
|
field("estimated_bytes", int64(), true),
|
|
495
|
+
field("key_value", binary(), true),
|
|
496
|
+
field("range_index", int64(), true),
|
|
497
|
+
field("column_bounds", binary(), true),
|
|
465
498
|
field("partition_bounds", binary(), true),
|
|
466
499
|
field("column_statistics", binary(), true),
|
|
467
500
|
field("location_ids", list(field("item", int64(), true)), true),
|
|
@@ -1087,6 +1120,8 @@ export const TableFunctionPlanResultSchema = schema([
|
|
|
1087
1120
|
field("catalog_version", int64(), true),
|
|
1088
1121
|
field("scope", utf8(), false),
|
|
1089
1122
|
field("locations", list(field("item", utf8(), true)), true),
|
|
1123
|
+
field("key_grouping", binary(), true),
|
|
1124
|
+
field("range_partitioning", binary(), true),
|
|
1090
1125
|
field("partitioning", list(field("item", binary(), true)), true),
|
|
1091
1126
|
field("sort_order", list(field("item", binary(), true)), true),
|
|
1092
1127
|
field("cache_max_age_seconds", int64(), true),
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// GENERATED by vgi.codegen.ts_types. DO NOT EDIT BY HAND.
|
|
3
3
|
//
|
|
4
4
|
// Generator: python -m vgi.codegen.ts_types v1
|
|
5
|
-
// Content hash:
|
|
5
|
+
// Content hash: 50667b91293f
|
|
6
6
|
//
|
|
7
7
|
// To regenerate:
|
|
8
8
|
// uv run --project ~/Development/vgi-python python scripts/regen_generated.py
|
|
@@ -24,9 +24,11 @@ import {
|
|
|
24
24
|
ConstraintSnapshotSchema,
|
|
25
25
|
ConstraintsApplyRequestSchema,
|
|
26
26
|
DependencySnapshotSchema,
|
|
27
|
+
FieldPathSchema,
|
|
27
28
|
ForeignKeyDefinitionSchema,
|
|
28
29
|
IndexDefinitionSchema,
|
|
29
30
|
IndexKeySchema,
|
|
31
|
+
KeyGroupingSchema,
|
|
30
32
|
MacroOverloadSchema,
|
|
31
33
|
MacroParameterSchema,
|
|
32
34
|
ObjectDependencySchema,
|
|
@@ -36,6 +38,8 @@ import {
|
|
|
36
38
|
QueryCapabilitiesSchema,
|
|
37
39
|
QueryEvaluationContextSchema,
|
|
38
40
|
QueryObjectReferenceSchema,
|
|
41
|
+
RangeKeySchema,
|
|
42
|
+
RangePartitioningSchema,
|
|
39
43
|
RequiredFilterPathsSchema,
|
|
40
44
|
SchemaContentsSchema,
|
|
41
45
|
SortKeySchema,
|
|
@@ -43,10 +47,135 @@ import {
|
|
|
43
47
|
SqlStatementSchema,
|
|
44
48
|
TableLayoutChangeSchema,
|
|
45
49
|
TableLayoutSchema,
|
|
50
|
+
TransformSpecSchema,
|
|
46
51
|
} from "./vgi-protocol-schemas.js";
|
|
47
52
|
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";
|
|
48
53
|
export type { CatalogAttachResult, CatalogCapabilities, CatalogContentsResponse, CatalogObjectRef, CatalogQueryPrepareRequest, CatalogQueryPrepareResult, ClientQueryCapabilities, ConstraintSnapshot, ConstraintsApplyRequest, DependencySnapshot, IndexDefinition, MacroOverload, MacroParameter, OptionDefinitions, OptionState, QueryCapabilities, QueryEvaluationContext, QueryObjectReference, SqlExpression, TableLayout };
|
|
49
54
|
|
|
55
|
+
// ----------------------------------------------------------------------------
|
|
56
|
+
// FieldPath (schema: FieldPathSchema)
|
|
57
|
+
// ----------------------------------------------------------------------------
|
|
58
|
+
|
|
59
|
+
/** One raw, component-preserving field reference used by a transform. */
|
|
60
|
+
export interface FieldPath {
|
|
61
|
+
components: string[];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** `FieldPath` has no defaulted fields, so its init is the record itself. */
|
|
65
|
+
export type FieldPathInit = FieldPath;
|
|
66
|
+
|
|
67
|
+
/** Build a complete `FieldPath`, filling the protocol defaults, in wire order. */
|
|
68
|
+
export function buildFieldPath(init: FieldPathInit): FieldPath {
|
|
69
|
+
return {
|
|
70
|
+
components: init.components,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export const encodeFieldPath = (v: FieldPath): Uint8Array => encodeASD(FieldPathSchema, v);
|
|
75
|
+
export const decodeFieldPath = (b: Uint8Array): FieldPath => decodeASD<FieldPath>(FieldPathSchema, b);
|
|
76
|
+
|
|
77
|
+
// ----------------------------------------------------------------------------
|
|
78
|
+
// TransformSpec (schema: TransformSpecSchema)
|
|
79
|
+
// ----------------------------------------------------------------------------
|
|
80
|
+
|
|
81
|
+
/** A versioned, registry-defined partition transform. `id` identifies normative semantics (for example `vgi.identity/1` or `iceberg.bucket/1`). `inputs` contains serialized :class:`FieldPath` records. `parameters` is either absent or a one-row Arrow batch, which permits any number of named, typed parameters without admitting arbitrary recursive expressions. */
|
|
82
|
+
export interface TransformSpec {
|
|
83
|
+
id: string;
|
|
84
|
+
inputs: Uint8Array[];
|
|
85
|
+
parameters?: Uint8Array | null;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** Fields of `TransformSpec` that have a protocol default. */
|
|
89
|
+
export type TransformSpecDefaultedField =
|
|
90
|
+
| "inputs"
|
|
91
|
+
| "parameters";
|
|
92
|
+
/** `TransformSpec` with every field that has a protocol default optional. */
|
|
93
|
+
export type TransformSpecInit = Omit<TransformSpec, TransformSpecDefaultedField> & Partial<Pick<TransformSpec, TransformSpecDefaultedField>>;
|
|
94
|
+
|
|
95
|
+
/** Build a complete `TransformSpec`, filling the protocol defaults, in wire order. */
|
|
96
|
+
export function buildTransformSpec(init: TransformSpecInit): TransformSpec {
|
|
97
|
+
return {
|
|
98
|
+
id: init.id,
|
|
99
|
+
inputs: init.inputs ?? [],
|
|
100
|
+
parameters: init.parameters ?? null,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export const encodeTransformSpec = (v: TransformSpec): Uint8Array => encodeASD(TransformSpecSchema, v);
|
|
105
|
+
export const decodeTransformSpec = (b: Uint8Array): TransformSpec => decodeASD<TransformSpec>(TransformSpecSchema, b);
|
|
106
|
+
|
|
107
|
+
// ----------------------------------------------------------------------------
|
|
108
|
+
// KeyGrouping (schema: KeyGroupingSchema)
|
|
109
|
+
// ----------------------------------------------------------------------------
|
|
110
|
+
|
|
111
|
+
/** Transforms whose exact result tuple is constant within every split. */
|
|
112
|
+
export interface KeyGrouping {
|
|
113
|
+
keys: Uint8Array[];
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/** `KeyGrouping` has no defaulted fields, so its init is the record itself. */
|
|
117
|
+
export type KeyGroupingInit = KeyGrouping;
|
|
118
|
+
|
|
119
|
+
/** Build a complete `KeyGrouping`, filling the protocol defaults, in wire order. */
|
|
120
|
+
export function buildKeyGrouping(init: KeyGroupingInit): KeyGrouping {
|
|
121
|
+
return {
|
|
122
|
+
keys: init.keys,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export const encodeKeyGrouping = (v: KeyGrouping): Uint8Array => encodeASD(KeyGroupingSchema, v);
|
|
127
|
+
export const decodeKeyGrouping = (b: Uint8Array): KeyGrouping => decodeASD<KeyGrouping>(KeyGroupingSchema, b);
|
|
128
|
+
|
|
129
|
+
// ----------------------------------------------------------------------------
|
|
130
|
+
// RangeKey (schema: RangeKeySchema)
|
|
131
|
+
// ----------------------------------------------------------------------------
|
|
132
|
+
|
|
133
|
+
/** One transform and comparator component of a range key. */
|
|
134
|
+
export interface RangeKey {
|
|
135
|
+
transform: Uint8Array;
|
|
136
|
+
direction: string;
|
|
137
|
+
null_order: string;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/** `RangeKey` has no defaulted fields, so its init is the record itself. */
|
|
141
|
+
export type RangeKeyInit = RangeKey;
|
|
142
|
+
|
|
143
|
+
/** Build a complete `RangeKey`, filling the protocol defaults, in wire order. */
|
|
144
|
+
export function buildRangeKey(init: RangeKeyInit): RangeKey {
|
|
145
|
+
return {
|
|
146
|
+
transform: init.transform,
|
|
147
|
+
direction: init.direction,
|
|
148
|
+
null_order: init.null_order,
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export const encodeRangeKey = (v: RangeKey): Uint8Array => encodeASD(RangeKeySchema, v);
|
|
153
|
+
export const decodeRangeKey = (b: Uint8Array): RangeKey => decodeASD<RangeKey>(RangeKeySchema, b);
|
|
154
|
+
|
|
155
|
+
// ----------------------------------------------------------------------------
|
|
156
|
+
// RangePartitioning (schema: RangePartitioningSchema)
|
|
157
|
+
// ----------------------------------------------------------------------------
|
|
158
|
+
|
|
159
|
+
/** Exact half-open range distribution shared by all splits in a plan. `N` split-point rows define `N + 1` ranges. Values equal to point `i` belong to range `i + 1`. Each split names its range with :attr:`ScanSplit.range_index`. */
|
|
160
|
+
export interface RangePartitioning {
|
|
161
|
+
keys: Uint8Array[];
|
|
162
|
+
split_points: Uint8Array;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/** `RangePartitioning` has no defaulted fields, so its init is the record itself. */
|
|
166
|
+
export type RangePartitioningInit = RangePartitioning;
|
|
167
|
+
|
|
168
|
+
/** Build a complete `RangePartitioning`, filling the protocol defaults, in wire order. */
|
|
169
|
+
export function buildRangePartitioning(init: RangePartitioningInit): RangePartitioning {
|
|
170
|
+
return {
|
|
171
|
+
keys: init.keys,
|
|
172
|
+
split_points: init.split_points,
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export const encodeRangePartitioning = (v: RangePartitioning): Uint8Array => encodeASD(RangePartitioningSchema, v);
|
|
177
|
+
export const decodeRangePartitioning = (b: Uint8Array): RangePartitioning => decodeASD<RangePartitioning>(RangePartitioningSchema, b);
|
|
178
|
+
|
|
50
179
|
// ----------------------------------------------------------------------------
|
|
51
180
|
// MacroParameter (schema: MacroParameterSchema)
|
|
52
181
|
// ----------------------------------------------------------------------------
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// GENERATED by vgi.codegen.ts_registry. DO NOT EDIT BY HAND.
|
|
3
3
|
//
|
|
4
4
|
// Generator: python -m vgi.codegen.ts_registry v1
|
|
5
|
-
// Content hash:
|
|
5
|
+
// Content hash: d92d651266e2
|
|
6
6
|
//
|
|
7
7
|
// To regenerate:
|
|
8
8
|
// uv run --project ~/Development/vgi-python python scripts/regen_generated.py
|
|
@@ -38,7 +38,7 @@ import {
|
|
|
38
38
|
export const VGI_PROTOCOL_NAME = "vgi.v3";
|
|
39
39
|
|
|
40
40
|
/** The protocol's semver, stamped on every request by a client of this protocol. */
|
|
41
|
-
export const VGI_PROTOCOL_VERSION = "3.
|
|
41
|
+
export const VGI_PROTOCOL_VERSION = "3.1.0";
|
|
42
42
|
|
|
43
43
|
/** What a unary handler returns: the result row, now or later. */
|
|
44
44
|
export type VgiReply<T> = T | ExternalRef | Promise<T | ExternalRef>;
|
|
@@ -3123,12 +3123,14 @@ export function registerVgiService(protocol: Protocol, service: VgiService): Pro
|
|
|
3123
3123
|
continue;
|
|
3124
3124
|
}
|
|
3125
3125
|
const stream = service[m.key] as VgiStream;
|
|
3126
|
+
// Optional members are spread in only when present, so the options bag
|
|
3127
|
+
// type-checks under exactOptionalPropertyTypes.
|
|
3126
3128
|
const common = {
|
|
3127
3129
|
params: m.params,
|
|
3128
3130
|
outputSchema: stream.outputSchema,
|
|
3129
|
-
headerSchema: m.header
|
|
3130
|
-
headerInit: stream.headerInit,
|
|
3131
|
-
onCancel: stream.onCancel,
|
|
3131
|
+
...(m.header ? { headerSchema: m.header } : {}),
|
|
3132
|
+
...(stream.headerInit ? { headerInit: stream.headerInit } : {}),
|
|
3133
|
+
...(stream.onCancel ? { onCancel: stream.onCancel } : {}),
|
|
3132
3134
|
doc: m.doc,
|
|
3133
3135
|
};
|
|
3134
3136
|
if (stream.kind === "exchange") {
|
package/src/http/fetch.ts
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
// `buildVgiProtocol` as `signingKey`, from one source. Passing different keys to
|
|
11
11
|
// those two seams produces a worker that mints tokens it cannot recover.
|
|
12
12
|
|
|
13
|
+
import { omitUndefined } from "../util/defined.js";
|
|
13
14
|
import {
|
|
14
15
|
AuthContext,
|
|
15
16
|
createHttpHandler,
|
|
@@ -41,14 +42,14 @@ export interface VgiFetchOptions extends HostingOptions {
|
|
|
41
42
|
* configured key hosts `vgi.attach_tickets.v1` (with the ability to issue
|
|
42
43
|
* grants): tickets sealed under a generated key would die on restart.
|
|
43
44
|
* Defaults to `true`, since this factory requires the key to be passed. */
|
|
44
|
-
signingKeyConfigured?: boolean;
|
|
45
|
+
signingKeyConfigured?: boolean | undefined;
|
|
45
46
|
/** State-token TTL in seconds (default 3600). */
|
|
46
|
-
tokenTtl?: number;
|
|
47
|
+
tokenTtl?: number | undefined;
|
|
47
48
|
/** URL path prefix for VGI requests (default "/vgi"). Pass "" to mount at
|
|
48
49
|
* the root, which is what a dedicated single-worker HTTP server wants. */
|
|
49
|
-
prefix?: string;
|
|
50
|
+
prefix?: string | undefined;
|
|
50
51
|
/** Server ID for state-token attribution (default "vgi-cf"). */
|
|
51
|
-
serverId?: string;
|
|
52
|
+
serverId?: string | undefined;
|
|
52
53
|
/** CORS allowed origins, added to all responses so the preflight `OPTIONS`
|
|
53
54
|
* that browser clients send before `__describe__` succeeds.
|
|
54
55
|
*
|
|
@@ -60,9 +61,9 @@ export interface VgiFetchOptions extends HostingOptions {
|
|
|
60
61
|
* always defaulted this way; this matches it so both entries agree.
|
|
61
62
|
*
|
|
62
63
|
* Pass `null` to disable CORS. */
|
|
63
|
-
corsOrigins?: string | null;
|
|
64
|
+
corsOrigins?: string | null | undefined;
|
|
64
65
|
/** Public source-repository URL, surfaced on the landing page. */
|
|
65
|
-
repositoryUrl?: string;
|
|
66
|
+
repositoryUrl?: string | undefined;
|
|
66
67
|
/** Worker identity for the standardized VGI landing surface: `GET /` serves
|
|
67
68
|
* the shared landing.html plus a JSON status document carrying this
|
|
68
69
|
* identity, and `GET /vgi-client.js` serves the browser client build the
|
|
@@ -85,13 +86,13 @@ export interface VgiFetchOptions extends HostingOptions {
|
|
|
85
86
|
* Supplying it is what makes a worker able to serve more than one principal,
|
|
86
87
|
* and the identity it returns is the one the worker seals `attach_opaque_data`
|
|
87
88
|
* and split tokens under. */
|
|
88
|
-
authenticate?: AuthenticateFn;
|
|
89
|
+
authenticate?: AuthenticateFn | undefined;
|
|
89
90
|
/** Off-wire transport identities, including a trusted Iroh HTTP bridge. */
|
|
90
|
-
peerIdentityProviders?: readonly PeerIdentityProvider[];
|
|
91
|
+
peerIdentityProviders?: readonly PeerIdentityProvider[] | undefined;
|
|
91
92
|
/** Policy composing peer evidence with application authentication. */
|
|
92
|
-
peerAuthenticationPolicy?: PeerAuthenticationPolicy;
|
|
93
|
+
peerAuthenticationPolicy?: PeerAuthenticationPolicy | undefined;
|
|
93
94
|
/** Host adapter supplying the physical peer and multiplicity-preserving headers. */
|
|
94
|
-
peerResolutionContext?: (request: Request) => PeerResolutionOptions | Promise<PeerResolutionOptions
|
|
95
|
+
peerResolutionContext?: ((request: Request) => PeerResolutionOptions | Promise<PeerResolutionOptions>) | undefined;
|
|
95
96
|
}
|
|
96
97
|
|
|
97
98
|
// ---------------------------------------------------------------------------
|
|
@@ -226,7 +227,11 @@ export function createVgiFetch(opts: VgiFetchOptions): (req: Request) => Promise
|
|
|
226
227
|
const reservedCheck = checkReservedAttachOptions(opts.protocol.catalogInterface);
|
|
227
228
|
reservedCheck.catch((e) => console.error(`VGI worker refused to serve: ${(e as Error).message}`));
|
|
228
229
|
|
|
229
|
-
|
|
230
|
+
// vgi-rpc's own types disagree under exactOptionalPropertyTypes:
|
|
231
|
+
// `VgiRpcServer.identity` is `IdentityImpl | undefined` while `ProtocolHost`
|
|
232
|
+
// declares `identity?: {...}` without `| undefined`. Both mean "may be
|
|
233
|
+
// absent"; the cast only bridges the declarations.
|
|
234
|
+
const handler = createHttpHandler(server as Parameters<typeof createHttpHandler>[0], omitUndefined({
|
|
230
235
|
prefix,
|
|
231
236
|
serverId,
|
|
232
237
|
tokenKey: opts.signingKey,
|
|
@@ -249,7 +254,7 @@ export function createVgiFetch(opts: VgiFetchOptions): (req: Request) => Promise
|
|
|
249
254
|
// no reason — a VGI worker always has the real thing.
|
|
250
255
|
extraRoutes: createLandingRoutes(opts.landingInfo),
|
|
251
256
|
enableLandingPage: false,
|
|
252
|
-
});
|
|
257
|
+
}));
|
|
253
258
|
return async (req: Request) => {
|
|
254
259
|
await reservedCheck;
|
|
255
260
|
const storage = await ensureRequestAuthStorage();
|
package/src/index.core.ts
CHANGED
|
@@ -115,6 +115,38 @@ export type {
|
|
|
115
115
|
GlobalInitResponse,
|
|
116
116
|
TableCardinality,
|
|
117
117
|
} from "./protocol/types.js";
|
|
118
|
+
export type {
|
|
119
|
+
ScanSplit,
|
|
120
|
+
PlanResult,
|
|
121
|
+
TableFunctionPlanRequest,
|
|
122
|
+
} from "./protocol/serializers/splits.js";
|
|
123
|
+
export {
|
|
124
|
+
type FieldPath,
|
|
125
|
+
type FieldPathInit,
|
|
126
|
+
buildFieldPath,
|
|
127
|
+
encodeFieldPath,
|
|
128
|
+
decodeFieldPath,
|
|
129
|
+
type TransformSpec,
|
|
130
|
+
type TransformSpecInit,
|
|
131
|
+
buildTransformSpec,
|
|
132
|
+
encodeTransformSpec,
|
|
133
|
+
decodeTransformSpec,
|
|
134
|
+
type KeyGrouping,
|
|
135
|
+
type KeyGroupingInit,
|
|
136
|
+
buildKeyGrouping,
|
|
137
|
+
encodeKeyGrouping,
|
|
138
|
+
decodeKeyGrouping,
|
|
139
|
+
type RangeKey,
|
|
140
|
+
type RangeKeyInit,
|
|
141
|
+
buildRangeKey,
|
|
142
|
+
encodeRangeKey,
|
|
143
|
+
decodeRangeKey,
|
|
144
|
+
type RangePartitioning,
|
|
145
|
+
type RangePartitioningInit,
|
|
146
|
+
buildRangePartitioning,
|
|
147
|
+
encodeRangePartitioning,
|
|
148
|
+
decodeRangePartitioning,
|
|
149
|
+
} from "./generated/vgi-protocol-types.js";
|
|
118
150
|
|
|
119
151
|
// Arguments
|
|
120
152
|
export { Arguments } from "./arguments/arguments.js";
|
|
@@ -334,6 +366,8 @@ export { VgiClient, VgiClientError } from "./client/client.js";
|
|
|
334
366
|
export type {
|
|
335
367
|
VgiClientOptions,
|
|
336
368
|
TableFunctionOptions,
|
|
369
|
+
TableFunctionRowsOptions,
|
|
370
|
+
Int64Mode,
|
|
337
371
|
ScalarFunctionOptions,
|
|
338
372
|
TableInOutFunctionOptions,
|
|
339
373
|
OnCreateConflict,
|
|
@@ -93,7 +93,7 @@ const stats = { parses: 0, hits: 0 };
|
|
|
93
93
|
function hashBytes(bytes: Uint8Array): number {
|
|
94
94
|
let h = 0x811c9dc5 ^ bytes.byteLength;
|
|
95
95
|
for (let i = 0; i < bytes.byteLength; i++) {
|
|
96
|
-
h ^= bytes[i]
|
|
96
|
+
h ^= bytes[i]!;
|
|
97
97
|
h = Math.imul(h, 0x01000193);
|
|
98
98
|
}
|
|
99
99
|
return h >>> 0;
|
package/src/protocol/dispatch.ts
CHANGED
|
@@ -21,15 +21,15 @@ import { catalogHandlers } from "./handlers/catalog/index.js";
|
|
|
21
21
|
|
|
22
22
|
export interface ProtocolConfig {
|
|
23
23
|
registry: FunctionRegistry;
|
|
24
|
-
catalogInterface?: CatalogInterface;
|
|
25
|
-
catalogName?: string;
|
|
24
|
+
catalogInterface?: CatalogInterface | undefined;
|
|
25
|
+
catalogName?: string | undefined;
|
|
26
26
|
/**
|
|
27
27
|
* AEAD signing key for sealing catalog opaque-data envelopes. Pass the same
|
|
28
28
|
* 32-byte key used for HTTP state tokens. When omitted (subprocess / unix
|
|
29
29
|
* transports) attach_opaque_data / transaction_opaque_data pass through
|
|
30
30
|
* unsealed — OS process ownership already enforces identity there.
|
|
31
31
|
*/
|
|
32
|
-
signingKey?: Uint8Array;
|
|
32
|
+
signingKey?: Uint8Array | undefined;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
/**
|
|
@@ -69,7 +69,7 @@ export { VGI_PROTOCOL_NAME };
|
|
|
69
69
|
* hash covers method names, types and the params/result/header schemas only
|
|
70
70
|
* (WIRE_PROTOCOL.md §14).
|
|
71
71
|
*
|
|
72
|
-
* It changes only with vgi.v3's protocol version (currently 3.
|
|
72
|
+
* It changes only with vgi.v3's protocol version (currently 3.1.0). Asserted
|
|
73
73
|
* by src/protocol/__tests__/vgi-v3-hash.test.ts; if that test fails, the
|
|
74
74
|
* surface drifted from the reference -- fix the schemas, do not bump this.
|
|
75
75
|
*/
|
|
@@ -203,8 +203,8 @@ export function aggregateHandlers(registry: FunctionRegistry): Partial<VgiServic
|
|
|
203
203
|
}
|
|
204
204
|
const touchedTargets = new Set<bigint>();
|
|
205
205
|
for (let i = 0; i < batch.numRows; i++) {
|
|
206
|
-
const src = srcIds[i]
|
|
207
|
-
const tgt = tgtIds[i]
|
|
206
|
+
const src = srcIds[i]!;
|
|
207
|
+
const tgt = tgtIds[i]!;
|
|
208
208
|
const srcHas = exec.states.has(src);
|
|
209
209
|
const tgtHas = exec.states.has(tgt);
|
|
210
210
|
if (!srcHas && !tgtHas) continue;
|
|
@@ -307,6 +307,7 @@ function extractArgMap(
|
|
|
307
307
|
}
|
|
308
308
|
}
|
|
309
309
|
for (let i = 0; i < constNames.length; i++) {
|
|
310
|
+
const name = constNames[i]!;
|
|
310
311
|
let v: any;
|
|
311
312
|
try {
|
|
312
313
|
v = args.get(i);
|
|
@@ -325,18 +326,18 @@ function extractArgMap(
|
|
|
325
326
|
// args.get throws when the arg isn't set — fall back to the declared
|
|
326
327
|
// default so aggregates called without an explicit const value still
|
|
327
328
|
// see it in update/finalize.
|
|
328
|
-
const def = cfg.argDefaults?.[
|
|
329
|
-
if (def !== undefined) out[
|
|
329
|
+
const def = cfg.argDefaults?.[name];
|
|
330
|
+
if (def !== undefined) out[name] = def;
|
|
330
331
|
continue;
|
|
331
332
|
}
|
|
332
333
|
// Enforce declared constraints on the supplied value. This sits OUTSIDE the
|
|
333
334
|
// try above so a constraint violation propagates as a bind error rather than
|
|
334
335
|
// being swallowed and silently replaced by the default.
|
|
335
|
-
const constraints = cfg.argConstraints?.[
|
|
336
|
+
const constraints = cfg.argConstraints?.[name];
|
|
336
337
|
if (constraints !== undefined) {
|
|
337
|
-
validateConstConstraints(
|
|
338
|
+
validateConstConstraints(name, constraints, v);
|
|
338
339
|
}
|
|
339
|
-
out[
|
|
340
|
+
out[name] = v;
|
|
340
341
|
}
|
|
341
342
|
// Non-const args aren't in the wire Arguments, but users may still want
|
|
342
343
|
// defaults surfaced for `params.args` — apply them here.
|
|
@@ -81,7 +81,7 @@ export async function openAttach(
|
|
|
81
81
|
/** Hex of a byte array (lowercase). */
|
|
82
82
|
function toHex(b: Uint8Array): string {
|
|
83
83
|
let s = "";
|
|
84
|
-
for (let i = 0; i < b.length; i++) s += b[i]
|
|
84
|
+
for (let i = 0; i < b.length; i++) s += b[i]!.toString(16).padStart(2, "0");
|
|
85
85
|
return s;
|
|
86
86
|
}
|
|
87
87
|
|
|
@@ -55,7 +55,7 @@ import {
|
|
|
55
55
|
|
|
56
56
|
export interface FunctionHandlerConfig {
|
|
57
57
|
registry: FunctionRegistry;
|
|
58
|
-
signingKey?: Uint8Array;
|
|
58
|
+
signingKey?: Uint8Array | undefined;
|
|
59
59
|
/**
|
|
60
60
|
* Used to map a bind's `attach_opaque_data` to its catalog, so resolution can
|
|
61
61
|
* be scoped when two catalogs declare the same schema and function name.
|
|
@@ -74,7 +74,7 @@ export interface FunctionHandlerConfig {
|
|
|
74
74
|
* livelock returning no rows, blaming the data for moving when it has not.
|
|
75
75
|
*/
|
|
76
76
|
version?(attach: Uint8Array, txn?: Uint8Array): number | Promise<number>;
|
|
77
|
-
};
|
|
77
|
+
} | undefined;
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
/**
|
|
@@ -28,12 +28,25 @@ export function deserializeCardinalityRequest(
|
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
/** Normalise one cardinality field to the wire's int64 (`bigint`) or null. */
|
|
32
|
+
function cardinalityValue(
|
|
33
|
+
name: "estimate" | "max",
|
|
34
|
+
v: number | bigint | null | undefined,
|
|
35
|
+
): bigint | null {
|
|
36
|
+
if (v === null || v === undefined) return null;
|
|
37
|
+
if (typeof v === "bigint") return v;
|
|
38
|
+
if (typeof v === "number" && Number.isInteger(v)) return BigInt(v);
|
|
39
|
+
throw new TypeError(
|
|
40
|
+
`TableCardinality.${name} must be an integer number, a bigint, or null (got ${typeof v}: ${String(v)})`,
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
31
44
|
export function serializeTableCardinality(
|
|
32
45
|
card: TableCardinality
|
|
33
|
-
):
|
|
46
|
+
): { estimate: bigint | null; max: bigint | null } {
|
|
34
47
|
return {
|
|
35
|
-
estimate: card.estimate,
|
|
36
|
-
max: card.max,
|
|
48
|
+
estimate: cardinalityValue("estimate", card.estimate),
|
|
49
|
+
max: cardinalityValue("max", card.max),
|
|
37
50
|
};
|
|
38
51
|
}
|
|
39
52
|
|