@query-farm/vgi 0.46.0 → 0.47.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.
Files changed (93) hide show
  1. package/README.md +11 -5
  2. package/dist/arrow/impl-arrowjs/index.d.ts +1 -1
  3. package/dist/arrow/impl-arrowjs/iterate.d.ts +2 -0
  4. package/dist/arrow/impl-flechette/index.d.ts +1 -1
  5. package/dist/arrow/impl-flechette/iterate.d.ts +2 -0
  6. package/dist/arrow/index.d.ts +1 -1
  7. package/dist/catalog/column-expressions.d.ts +8 -0
  8. package/dist/catalog/column-metadata.d.ts +11 -0
  9. package/dist/catalog/composite.d.ts +2 -1
  10. package/dist/catalog/constraints.d.ts +74 -0
  11. package/dist/catalog/descriptors.d.ts +21 -29
  12. package/dist/catalog/interface.d.ts +15 -20
  13. package/dist/catalog/macro-overloads.d.ts +4 -0
  14. package/dist/catalog/read-only.d.ts +7 -1
  15. package/dist/catalog/unconstrained-columns.d.ts +2 -0
  16. package/dist/client/client.d.ts +18 -13
  17. package/dist/client-entry.js +753 -103
  18. package/dist/client-entry.js.map +16 -14
  19. package/dist/functions/projection.d.ts +18 -0
  20. package/dist/functions/table.d.ts +6 -1
  21. package/dist/functions/types.d.ts +1 -0
  22. package/dist/generated/vgi-client.d.ts +177 -36
  23. package/dist/generated/vgi-protocol-schemas.d.ts +51 -1
  24. package/dist/generated/vgi-protocol-types.d.ts +317 -3
  25. package/dist/generated/vgi-service.d.ts +266 -29
  26. package/dist/index.core.d.ts +3 -1
  27. package/dist/index.js +1630 -240
  28. package/dist/index.js.map +41 -34
  29. package/dist/protocol/dispatch.d.ts +9 -9
  30. package/dist/protocol/handlers/aggregate.d.ts +1 -1
  31. package/dist/protocol/handlers/catalog/index.d.ts +1 -1
  32. package/dist/protocol/handlers/catalog/metadata.d.ts +1 -0
  33. package/dist/protocol/handlers/function.d.ts +1 -1
  34. package/dist/protocol/handlers/table-buffering.d.ts +1 -1
  35. package/dist/protocol/handlers/unimplemented.d.ts +1 -1
  36. package/dist/protocol/serializers/bind.d.ts +5 -1
  37. package/dist/protocol/types.d.ts +5 -0
  38. package/dist/rpc-server.d.ts +6 -6
  39. package/dist/serve-entry.js +1613 -447
  40. package/dist/serve-entry.js.map +32 -26
  41. package/dist/util/arrow/index.d.ts +1 -1
  42. package/dist/worker-cf-entry.d.ts +2 -2
  43. package/dist/worker-cf-entry.js +1943 -572
  44. package/dist/worker-cf-entry.js.map +41 -34
  45. package/dist/worker.d.ts +1 -1
  46. package/package.json +5 -4
  47. package/src/arrow/impl-arrowjs/index.ts +1 -1
  48. package/src/arrow/impl-arrowjs/iterate.ts +9 -1
  49. package/src/arrow/impl-arrowjs/project.ts +1 -1
  50. package/src/arrow/impl-flechette/index.ts +1 -1
  51. package/src/arrow/impl-flechette/ipc.ts +12 -0
  52. package/src/arrow/impl-flechette/iterate.ts +5 -0
  53. package/src/arrow/impl-flechette/project.ts +6 -8
  54. package/src/arrow/index.ts +1 -1
  55. package/src/catalog/column-expressions.ts +224 -0
  56. package/src/catalog/column-metadata.ts +151 -0
  57. package/src/catalog/composite.ts +5 -1
  58. package/src/catalog/constraints.ts +207 -0
  59. package/src/catalog/contents-codec.ts +6 -1
  60. package/src/catalog/descriptors.ts +21 -29
  61. package/src/catalog/interface.ts +70 -55
  62. package/src/catalog/macro-overloads.ts +44 -0
  63. package/src/catalog/read-only.ts +92 -71
  64. package/src/catalog/unconstrained-columns.ts +23 -0
  65. package/src/client/client.ts +100 -58
  66. package/src/codec/asd.ts +3 -1
  67. package/src/functions/projection.ts +207 -0
  68. package/src/functions/table.ts +10 -0
  69. package/src/functions/types.ts +1 -0
  70. package/src/generated/vgi-client.ts +199 -37
  71. package/src/generated/vgi-protocol-schemas.ts +455 -41
  72. package/src/generated/vgi-protocol-types.ts +879 -5
  73. package/src/generated/vgi-service.ts +514 -42
  74. package/src/http/client-bundle.ts +1 -1
  75. package/src/http/fetch.ts +1 -1
  76. package/src/index.core.ts +5 -0
  77. package/src/protocol/dispatch.ts +9 -9
  78. package/src/protocol/handlers/aggregate.ts +1 -1
  79. package/src/protocol/handlers/catalog/admin.ts +27 -6
  80. package/src/protocol/handlers/catalog/index.ts +2 -2
  81. package/src/protocol/handlers/catalog/macro.ts +6 -5
  82. package/src/protocol/handlers/catalog/metadata.ts +16 -0
  83. package/src/protocol/handlers/catalog/table.ts +72 -26
  84. package/src/protocol/handlers/catalog/view.ts +24 -3
  85. package/src/protocol/handlers/function.ts +67 -1
  86. package/src/protocol/handlers/table-buffering.ts +1 -1
  87. package/src/protocol/handlers/unimplemented.ts +6 -6
  88. package/src/protocol/serializers/bind.ts +17 -1
  89. package/src/protocol/types.ts +6 -0
  90. package/src/rpc-server.ts +9 -9
  91. package/src/util/arrow/index.ts +1 -1
  92. package/src/worker-cf-entry.ts +6 -0
  93. package/src/worker.ts +1 -1
@@ -1,9 +1,9 @@
1
1
  // Copyright 2025, 2026 Query Farm LLC - https://query.farm
2
- // vgi.v2 methods this SDK registers but does not implement.
2
+ // vgi.v3 methods this SDK registers but does not implement.
3
3
  //
4
- // "The protocol is the unit of optionality": every SDK hosts EVERY vgi.v2
4
+ // "The protocol is the unit of optionality": every SDK hosts EVERY vgi.v3
5
5
  // method with exactly the reference's schemas, so vgi_rpc.Reflection.v1
6
- // reports one vgi.v2 protocol hash everywhere (see VGI_V2_PROTOCOL_HASH in
6
+ // reports one vgi.v3 protocol hash everywhere (see VGI_V3_PROTOCOL_HASH in
7
7
  // ../dispatch.ts). The registration and the UNIMPLEMENTED default for every
8
8
  // method are generated (src/generated/vgi-service.ts); this module only names
9
9
  // the methods whose generated default this worker leaves in place, so a test
@@ -15,7 +15,7 @@
15
15
  import { FunctionRegistry } from "../../functions/registry.js";
16
16
  import {
17
17
  UNIMPLEMENTED_VGI_SERVICE,
18
- VGI_V2_METHODS,
18
+ VGI_V3_METHODS,
19
19
  type VgiMethodSpec,
20
20
  } from "../../generated/vgi-service.js";
21
21
  import { buildVgiService } from "../dispatch.js";
@@ -24,7 +24,7 @@ export { unimplementedMessage } from "../../generated/vgi-service.js";
24
24
 
25
25
  const service = buildVgiService({ registry: new FunctionRegistry() });
26
26
 
27
- /** The vgi.v2 methods (of the reference's 72) this SDK leaves at the generated default. */
28
- export const UNIMPLEMENTED_METHODS: readonly VgiMethodSpec[] = VGI_V2_METHODS.filter(
27
+ /** The vgi.v3 methods (of the reference's 72) this SDK leaves at the generated default. */
28
+ export const UNIMPLEMENTED_METHODS: readonly VgiMethodSpec[] = VGI_V3_METHODS.filter(
29
29
  (m) => service[m.key] === UNIMPLEMENTED_VGI_SERVICE[m.key],
30
30
  );
@@ -6,7 +6,7 @@
6
6
  import { type VgiSchema, schema, field, type VgiBatch, type VgiDataType, utf8, binary, bool, struct, dictionary, int16, list } from "../../arrow/index.js";
7
7
  import { Arguments } from "../../arguments/arguments.js";
8
8
  import { FunctionType } from "../../types.js";
9
- import type { BindRequest, BindResponse, CopyFromContext, CopyToContext } from "../types.js";
9
+ import type { BindRequest, BindResponse, BindRepeatability, CopyFromContext, CopyToContext } from "../types.js";
10
10
  import {
11
11
  serializeSchema,
12
12
  deserializeSchema,
@@ -184,15 +184,29 @@ export function deserializeBindRequest(
184
184
  };
185
185
  }
186
186
 
187
+ /** Validate required wire enum values, including rejecting NULL and absent values. */
188
+ export function parseBindRepeatability(value: unknown): BindRepeatability {
189
+ if (value !== "UNKNOWN" && value !== "STABLE_WITHIN_QUERY")
190
+ throw new Error("invalid bind repeatability");
191
+ return value;
192
+ }
193
+
194
+ /** Only omitted provider declarations default; explicit NULL remains invalid. */
195
+ export function normalizeBindRepeatability(value: unknown): BindRepeatability {
196
+ return parseBindRepeatability(value === undefined ? "UNKNOWN" : value);
197
+ }
198
+
187
199
  export function serializeBindResponse(
188
200
  resp: BindResponse
189
201
  ): Record<string, any> {
190
202
  return {
191
203
  output_schema: serializeSchema(resp.output_schema),
192
204
  opaque_data: resp.opaque_data ?? null,
205
+ projection_expression_profiles: resp.projection_expression_profiles ?? [],
193
206
  lookup_secret_types: resp.lookup_secret_types ?? [],
194
207
  lookup_scopes: resp.lookup_scopes ?? [],
195
208
  lookup_names: resp.lookup_names ?? [],
209
+ repeatability: normalizeBindRepeatability(resp.repeatability),
196
210
  };
197
211
  }
198
212
 
@@ -206,10 +220,12 @@ export function deserializeBindResponse(
206
220
  };
207
221
  return {
208
222
  output_schema: deserializeSchema(toUint8Array(params.output_schema)),
223
+ projection_expression_profiles: toStrArray(params.projection_expression_profiles),
209
224
  opaque_data: params.opaque_data ? toUint8Array(params.opaque_data) : null,
210
225
  lookup_secret_types: toStrArray(params.lookup_secret_types),
211
226
  lookup_scopes: toStrArray(params.lookup_scopes),
212
227
  lookup_names: toStrArray(params.lookup_names),
228
+ repeatability: parseBindRepeatability(params.repeatability),
213
229
  };
214
230
  }
215
231
 
@@ -104,7 +104,13 @@ export interface BindRequest {
104
104
  argument_names?: (string | null)[] | null;
105
105
  }
106
106
 
107
+ /** Equivalent scans of one bound state within a query; independent binds may differ. */
108
+ export type BindRepeatability = "UNKNOWN" | "STABLE_WITHIN_QUERY";
109
+
107
110
  export interface BindResponse {
111
+ /** Omitted provider values serialize as UNKNOWN. Wire values are required. */
112
+ repeatability?: BindRepeatability;
113
+ projection_expression_profiles?: string[];
108
114
  output_schema: VgiSchema;
109
115
  opaque_data: Uint8Array | null;
110
116
  lookup_secret_types?: string[];
package/src/rpc-server.ts CHANGED
@@ -9,7 +9,7 @@
9
9
  //
10
10
  // What a server hosts, in reflection order:
11
11
  //
12
- // 1. The worker's own protocol, `vgi.v2`.
12
+ // 1. The worker's own protocol, `vgi.v3`.
13
13
  // 2. The worker's `hostedProtocols()`, in the order returned -- on EVERY
14
14
  // transport.
15
15
  // 3. `vgi_rpc.Reflection.v1` -- on every transport.
@@ -19,9 +19,9 @@
19
19
  // configured explicitly (never a generated one) *and* the worker can
20
20
  // issue grants. See `attach-ticket.ts`.
21
21
  //
22
- // Extra protocols cannot change `vgi.v2` behaviour: vgi-rpc routes every
22
+ // Extra protocols cannot change `vgi.v3` behaviour: vgi-rpc routes every
23
23
  // request on its `vgi_rpc.protocol` key with no fallback to the primary, so a
24
- // client that only ever names `vgi.v2` (the DuckDB extension) dispatches
24
+ // client that only ever names `vgi.v3` (the DuckDB extension) dispatches
25
25
  // exactly as it would against a single-protocol server.
26
26
 
27
27
  import {
@@ -55,7 +55,7 @@ const RESERVED_PREFIX = "vgi_rpc.";
55
55
  export const INTROSPECT_PRINCIPALS_ENV = "VGI_INTROSPECT_PRINCIPALS";
56
56
 
57
57
  /**
58
- * What a worker hosts beyond `vgi.v2`, and whether it opts into identity.
58
+ * What a worker hosts beyond `vgi.v3`, and whether it opts into identity.
59
59
  *
60
60
  * Accepted by `new Worker({...})`, `serveVgiWorker`, `createVgiWorkerFetch`
61
61
  * and `createVgiFetch` (Cloudflare Workers) alike, so one worker definition
@@ -63,20 +63,20 @@ export const INTROSPECT_PRINCIPALS_ENV = "VGI_INTROSPECT_PRINCIPALS";
63
63
  */
64
64
  export interface HostingOptions {
65
65
  /**
66
- * Additional vgi-rpc protocols to host beside `vgi.v2`, on the **same**
66
+ * Additional vgi-rpc protocols to host beside `vgi.v3`, on the **same**
67
67
  * listener, whatever the transport.
68
68
  *
69
69
  * A vgi-rpc `Protocol` carries its handlers, so each entry is a whole
70
70
  * `(protocol, implementation)` pair. Called **once**, when the server is
71
71
  * built; it may consult configuration or the environment, but the answer is
72
72
  * fixed for the life of the process, so reflection output and protocol
73
- * hashes stay stable. Hosted after `vgi.v2`, in the order returned.
73
+ * hashes stay stable. Hosted after `vgi.v3`, in the order returned.
74
74
  *
75
75
  * The protocol is the unit of optionality: there is no way to host a subset
76
76
  * of a protocol's methods. A capability that is optional is its own
77
77
  * protocol, returned here or not.
78
78
  *
79
- * Each needs a distinct wire name, which may not be `vgi.v2` and may not
79
+ * Each needs a distinct wire name, which may not be `vgi.v3` and may not
80
80
  * use the reserved `vgi_rpc.` prefix: reflection is hosted automatically and
81
81
  * `vgi_rpc.Identity.v2` is enabled through {@link resolveToken} /
82
82
  * {@link mintGrant}. Violations are a startup error naming this hook.
@@ -164,14 +164,14 @@ export interface BuildRpcServerOptions {
164
164
  }
165
165
 
166
166
  /**
167
- * Build the vgi-rpc server for a worker's `vgi.v2` protocol on `transport`.
167
+ * Build the vgi-rpc server for a worker's `vgi.v3` protocol on `transport`.
168
168
  *
169
169
  * Calls `hosting.hostedProtocols()` exactly once and hosts the result beside
170
170
  * `primary`; see the module comment for the full hosted set.
171
171
  *
172
172
  * @throws TypeError `hostedProtocols()` returned something other than an
173
173
  * iterable of vgi-rpc `Protocol`s.
174
- * @throws Error A hosted protocol's name is invalid, reserved, `vgi.v2`'s, or
174
+ * @throws Error A hosted protocol's name is invalid, reserved, `vgi.v3`'s, or
175
175
  * repeated; the transport is unknown; or the worker supplies `resolveToken`
176
176
  * on HTTP with no introspector allowlist.
177
177
  */
@@ -12,7 +12,7 @@ export {
12
12
  batchToScalarDict,
13
13
  batchToSecretDict,
14
14
  safeNumber,
15
- decodeDictValue,
15
+ decodeDictValue, decodeMapValue,
16
16
  filterBatch,
17
17
  projectSchema,
18
18
  projectBatch,
@@ -65,6 +65,10 @@ export {
65
65
  serializeColumnStatistics,
66
66
  BindResultSchema,
67
67
  ScanFunctionResultSchema,
68
+ constraintRecord,
69
+ readConstraintRecord,
70
+ CONSTRAINT_RECORDS_READ,
71
+ ROW_SCALAR_EXPRESSION,
68
72
  } from "./index.core.js";
69
73
 
70
74
  export type {
@@ -86,6 +90,8 @@ export type {
86
90
  RowTransformConfig,
87
91
  RowTransformProcessParams,
88
92
  TableInOutBindParams,
93
+ ConstraintRecordSpec,
94
+ ConstraintRecordView,
89
95
  } from "./index.core.js";
90
96
 
91
97
  export type { ProtocolConfig } from "./protocol/dispatch.js";
package/src/worker.ts CHANGED
@@ -282,7 +282,7 @@ export class Worker {
282
282
  }
283
283
 
284
284
  /**
285
- * Build the vgi-rpc server for one transport: `vgi.v2`, the worker's
285
+ * Build the vgi-rpc server for one transport: `vgi.v3`, the worker's
286
286
  * `hostedProtocols()` and reflection everywhere; identity on HTTP only. The
287
287
  * one construction path every transport uses (see `rpc-server.ts`).
288
288
  */