@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.
Files changed (105) hide show
  1. package/README.md +1 -1
  2. package/dist/arguments/argument-spec.d.ts +17 -11
  3. package/dist/catalog/descriptors.d.ts +2 -2
  4. package/dist/catalog/publication.d.ts +7 -7
  5. package/dist/client/client.d.ts +9 -3
  6. package/dist/client/errors.d.ts +2 -2
  7. package/dist/client/types.d.ts +21 -0
  8. package/dist/client-entry.d.ts +1 -1
  9. package/dist/client-entry.js +56 -7
  10. package/dist/client-entry.js.map +23 -23
  11. package/dist/filter-pushdown/deserialize.d.ts +1 -1
  12. package/dist/filter-pushdown/types.d.ts +10 -10
  13. package/dist/functions/scalar.d.ts +1 -1
  14. package/dist/functions/table-buffering.d.ts +20 -20
  15. package/dist/functions/table-in-out.d.ts +4 -4
  16. package/dist/functions/table.d.ts +7 -7
  17. package/dist/functions/types.d.ts +47 -47
  18. package/dist/generated/vgi-client.d.ts +5 -0
  19. package/dist/generated/vgi-protocol-schemas.d.ts +5 -0
  20. package/dist/generated/vgi-protocol-types.d.ts +57 -0
  21. package/dist/generated/vgi-service.d.ts +1 -1
  22. package/dist/http/fetch.d.ts +10 -10
  23. package/dist/index.core.d.ts +3 -1
  24. package/dist/index.js +289 -103
  25. package/dist/index.js.map +57 -55
  26. package/dist/protocol/dispatch.d.ts +4 -4
  27. package/dist/protocol/handlers/function.d.ts +2 -2
  28. package/dist/protocol/serializers/cardinality.d.ts +4 -1
  29. package/dist/protocol/serializers/splits.d.ts +41 -1
  30. package/dist/protocol/types.d.ts +5 -5
  31. package/dist/rpc-server.d.ts +6 -6
  32. package/dist/serve-entry.d.ts +16 -16
  33. package/dist/serve-entry.js +119 -30
  34. package/dist/serve-entry.js.map +42 -40
  35. package/dist/split-token.d.ts +6 -6
  36. package/dist/types.d.ts +9 -2
  37. package/dist/util/defined.d.ts +21 -0
  38. package/dist/worker-cf-entry.js +199 -94
  39. package/dist/worker-cf-entry.js.map +55 -53
  40. package/dist/worker.d.ts +2 -2
  41. package/package.json +6 -4
  42. package/src/arguments/argument-spec.ts +17 -11
  43. package/src/arrow/codec/registry.ts +2 -2
  44. package/src/arrow/impl-arrowjs/build.ts +1 -1
  45. package/src/arrow/impl-arrowjs/canonical.ts +23 -23
  46. package/src/arrow/impl-arrowjs/empty.ts +2 -2
  47. package/src/arrow/impl-arrowjs/ipc.ts +2 -2
  48. package/src/arrow/impl-arrowjs/iterate.ts +2 -2
  49. package/src/arrow/impl-arrowjs/project.ts +2 -2
  50. package/src/arrow/impl-flechette/build.ts +2 -1
  51. package/src/arrow/impl-flechette/canonical.ts +10 -9
  52. package/src/arrow/impl-flechette/compat.ts +3 -3
  53. package/src/arrow/impl-flechette/message-meta.ts +5 -4
  54. package/src/arrow/impl-flechette/statistics.ts +2 -2
  55. package/src/attach-ticket.ts +2 -2
  56. package/src/catalog/column-metadata.ts +1 -1
  57. package/src/catalog/composite.ts +2 -2
  58. package/src/catalog/constraints.ts +9 -9
  59. package/src/catalog/descriptors.ts +1 -1
  60. package/src/catalog/interface.ts +12 -12
  61. package/src/catalog/publication.ts +9 -8
  62. package/src/catalog/read-only.ts +9 -8
  63. package/src/catalog/sql-grammar.ts +6 -6
  64. package/src/client/client.ts +52 -15
  65. package/src/client/errors.ts +1 -1
  66. package/src/client/types.ts +23 -0
  67. package/src/client-entry.ts +2 -0
  68. package/src/codec/asd.ts +3 -3
  69. package/src/codec/conform.ts +3 -3
  70. package/src/filter-pushdown/collector.ts +1 -1
  71. package/src/filter-pushdown/deserialize.ts +13 -10
  72. package/src/filter-pushdown/evaluate.ts +3 -2
  73. package/src/filter-pushdown/history.ts +3 -2
  74. package/src/filter-pushdown/types.ts +10 -10
  75. package/src/functions/continuation.ts +1 -1
  76. package/src/functions/projection.ts +1 -1
  77. package/src/functions/registry.ts +14 -14
  78. package/src/functions/scalar.ts +3 -3
  79. package/src/functions/storage-cf-do.ts +2 -2
  80. package/src/functions/table-buffering.ts +25 -21
  81. package/src/functions/table-in-out.ts +8 -8
  82. package/src/functions/table.ts +27 -25
  83. package/src/functions/types.ts +47 -47
  84. package/src/generated/vgi-client.ts +6 -1
  85. package/src/generated/vgi-protocol-schemas.ts +36 -1
  86. package/src/generated/vgi-protocol-types.ts +130 -1
  87. package/src/generated/vgi-service.ts +7 -5
  88. package/src/http/fetch.ts +17 -12
  89. package/src/index.core.ts +34 -0
  90. package/src/protocol/carried-init-request.ts +1 -1
  91. package/src/protocol/dispatch.ts +4 -4
  92. package/src/protocol/handlers/aggregate.ts +8 -7
  93. package/src/protocol/handlers/catalog/shared.ts +1 -1
  94. package/src/protocol/handlers/function.ts +2 -2
  95. package/src/protocol/serializers/cardinality.ts +16 -3
  96. package/src/protocol/serializers/splits.ts +82 -9
  97. package/src/protocol/state-serializer.ts +1 -1
  98. package/src/protocol/types.ts +5 -5
  99. package/src/rpc-server.ts +13 -12
  100. package/src/serve-entry.ts +18 -18
  101. package/src/split-token.ts +10 -9
  102. package/src/types.ts +9 -2
  103. package/src/util/defined.ts +30 -0
  104. package/src/util/parent-rows.ts +2 -2
  105. package/src/worker.ts +15 -14
@@ -71,8 +71,8 @@ export declare function buildSplitToken(opts: {
71
71
  payload: Uint8Array;
72
72
  fingerprint: Uint8Array;
73
73
  anchor: Uint8Array;
74
- signingKey?: Uint8Array;
75
- auth?: AuthContext;
74
+ signingKey?: Uint8Array | undefined;
75
+ auth?: AuthContext | undefined;
76
76
  }): Promise<Uint8Array>;
77
77
  /**
78
78
  * Verify a split token and return the worker's payload.
@@ -81,8 +81,8 @@ export declare function buildSplitToken(opts: {
81
81
  * check.
82
82
  */
83
83
  export declare function openSplitToken(token: Uint8Array, opts?: {
84
- signingKey?: Uint8Array;
85
- auth?: AuthContext;
86
- expectedFingerprint?: Uint8Array;
87
- currentAnchor?: Uint8Array;
84
+ signingKey?: Uint8Array | undefined;
85
+ auth?: AuthContext | undefined;
86
+ expectedFingerprint?: Uint8Array | undefined;
87
+ currentAnchor?: Uint8Array | undefined;
88
88
  }): Promise<Uint8Array>;
package/dist/types.d.ts CHANGED
@@ -58,8 +58,15 @@ export declare const VGI_DEFAULT_KEY = "vgi_default";
58
58
  export declare const VGI_CHOICES_KEY = "vgi_choices";
59
59
  export declare const VGI_RANGE_KEY = "vgi_range";
60
60
  export declare const VGI_PATTERN_KEY = "vgi_pattern";
61
+ /**
62
+ * Row-count estimate/upper bound returned by a table function's `cardinality`
63
+ * hook. Both travel as int64 on the wire, so either a `number` (must be an
64
+ * integer) or a `bigint` is accepted — int64 arguments arrive as `bigint`, so
65
+ * `{ estimate: args.count, max: args.count }` works without a `Number(...)`
66
+ * conversion. `null` means unknown.
67
+ */
61
68
  export interface TableCardinality {
62
- estimate: number | null;
63
- max: number | null;
69
+ estimate: number | bigint | null;
70
+ max: number | bigint | null;
64
71
  }
65
72
  export declare const DEFAULT_MAX_WORKERS = 99999;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * The type of `T` with every property whose value may be `undefined` made
3
+ * optional and stripped of `undefined` — the shape `omitUndefined` returns.
4
+ * It is assignable to option bags declared `{ k?: V }` under
5
+ * `exactOptionalPropertyTypes`.
6
+ */
7
+ export type OmitUndefined<T> = {
8
+ [K in keyof T as undefined extends T[K] ? never : K]: T[K];
9
+ } & {
10
+ [K in keyof T as undefined extends T[K] ? K : never]?: Exclude<T[K], undefined>;
11
+ };
12
+ /**
13
+ * Copy `obj` without the keys whose value is `undefined`.
14
+ *
15
+ * Used when forwarding optional settings to an options bag owned by another
16
+ * package (vgi-rpc, Bun) whose optional properties do not admit an explicit
17
+ * `undefined`. Readers of such bags treat an absent key and an `undefined`
18
+ * one identically (`??`, destructuring defaults), so this only changes the
19
+ * static type.
20
+ */
21
+ export declare function omitUndefined<T extends object>(obj: T): OmitUndefined<T>;
@@ -2522,6 +2522,16 @@ var init_storage = __esm(() => {
2522
2522
  });
2523
2523
  });
2524
2524
 
2525
+ // src/util/defined.ts
2526
+ function omitUndefined(obj) {
2527
+ const out = {};
2528
+ for (const [k, v] of Object.entries(obj)) {
2529
+ if (v !== undefined)
2530
+ out[k] = v;
2531
+ }
2532
+ return out;
2533
+ }
2534
+
2525
2535
  // src/http/fetch.ts
2526
2536
  import {
2527
2537
  AuthContext,
@@ -2600,7 +2610,8 @@ function resolveColumn(batch, columnName) {
2600
2610
  throw new FilterV2Error(`filter column ${columnName} is unavailable in emitted batch`);
2601
2611
  }
2602
2612
  const column = batch.getChildAt(index);
2603
- resolved = column ? { type: batch.schema.fields[index].type, column } : null;
2613
+ const field = batch.schema.fields[index];
2614
+ resolved = column && field ? { type: field.type, column } : null;
2604
2615
  byName.set(columnName, resolved);
2605
2616
  }
2606
2617
  return resolved;
@@ -3448,10 +3459,11 @@ class FilterParser {
3448
3459
  if (new Set(names).size !== names.length)
3449
3460
  throw new FilterV2Error("filter payload names must be unique");
3450
3461
  for (let i = 1;i < names.length; i++) {
3451
- if (!PAYLOAD_NAME.test(names[i]))
3452
- throw new FilterV2Error(`noncanonical payload name ${names[i]}`);
3453
- if (names[i].startsWith("type_") && this.valueAt(i) !== null) {
3454
- throw new FilterV2Error(`${names[i]} must contain NULL`);
3462
+ const name = names[i];
3463
+ if (!PAYLOAD_NAME.test(name))
3464
+ throw new FilterV2Error(`noncanonical payload name ${name}`);
3465
+ if (name.startsWith("type_") && this.valueAt(i) !== null) {
3466
+ throw new FilterV2Error(`${name} must contain NULL`);
3455
3467
  }
3456
3468
  }
3457
3469
  this.context = parseContext(batch.schema);
@@ -3464,9 +3476,10 @@ class FilterParser {
3464
3476
  }
3465
3477
  valueAt(index) {
3466
3478
  const column = this.batch.getChildAt(index);
3467
- if (!column)
3479
+ const field = this.batch.schema.fields[index];
3480
+ if (!column || !field)
3468
3481
  throw new FilterV2Error(`missing payload column ${index}`);
3469
- return readCanonicalValue(this.batch.schema.fields[index].type, column, 0);
3482
+ return readCanonicalValue(field.type, column, 0);
3470
3483
  }
3471
3484
  validateContextCapability() {
3472
3485
  if (this.context.profile === NO_EVALUATION_CONTEXT)
@@ -3587,9 +3600,10 @@ class FilterParser {
3587
3600
  const ref = expectUint(rawRef, `${prefix}_ref`);
3588
3601
  const name = `${prefix}_${ref}`;
3589
3602
  const indexes = this.batch.schema.fields.flatMap((field, index) => field.name === name ? [index] : []);
3590
- if (indexes.length !== 1)
3603
+ const index = indexes.length === 1 ? indexes[0] : undefined;
3604
+ if (index === undefined)
3591
3605
  throw new FilterV2Error(`missing or duplicate payload ${name}`);
3592
- return { ref, field: this.batch.schema.fields[indexes[0]], value: this.valueAt(indexes[0]) };
3606
+ return { ref, field: this.batch.schema.fields[index], value: this.valueAt(index) };
3593
3607
  }
3594
3608
  identity(raw, where) {
3595
3609
  const object = expectObject(raw, where);
@@ -3887,9 +3901,10 @@ function decodeFilterDelta(bytes) {
3887
3901
  }
3888
3902
  function deltaRevisionKeys(batch) {
3889
3903
  const column = batch.getChildAt(0);
3890
- if (!column)
3904
+ const field = batch.schema.fields[0];
3905
+ if (!column || !field)
3891
3906
  throw new FilterV2Error("delta document has no filter_spec column");
3892
- const raw = readCanonicalValue(batch.schema.fields[0].type, column, 0);
3907
+ const raw = readCanonicalValue(field.type, column, 0);
3893
3908
  const document = JSON.parse(String(raw));
3894
3909
  return (document.updates ?? []).map((update) => revisionKey(update.id, update.revision));
3895
3910
  }
@@ -4459,6 +4474,20 @@ function deserializeBindResponse(params) {
4459
4474
  }
4460
4475
  // src/protocol/serializers/init.ts
4461
4476
  init_arrow();
4477
+
4478
+ // src/protocol/types.ts
4479
+ var OrderByDirection;
4480
+ ((OrderByDirection) => {
4481
+ OrderByDirection["ASC"] = "ASC";
4482
+ OrderByDirection["DESC"] = "DESC";
4483
+ })(OrderByDirection ||= {});
4484
+ var OrderByNullOrder;
4485
+ ((OrderByNullOrder) => {
4486
+ OrderByNullOrder["NULLS_FIRST"] = "NULLS_FIRST";
4487
+ OrderByNullOrder["NULLS_LAST"] = "NULLS_LAST";
4488
+ })(OrderByNullOrder ||= {});
4489
+
4490
+ // src/protocol/serializers/init.ts
4462
4491
  var INIT_REQUEST_SCHEMA = schema2([
4463
4492
  field2("bind_call", binary2(), false),
4464
4493
  field2("output_schema", binary2(), false),
@@ -4625,10 +4654,19 @@ function deserializeCardinalityRequest(params) {
4625
4654
  bind_opaque_data: params.bind_opaque_data ? toUint8Array2(params.bind_opaque_data) : null
4626
4655
  };
4627
4656
  }
4657
+ function cardinalityValue(name, v) {
4658
+ if (v === null || v === undefined)
4659
+ return null;
4660
+ if (typeof v === "bigint")
4661
+ return v;
4662
+ if (typeof v === "number" && Number.isInteger(v))
4663
+ return BigInt(v);
4664
+ throw new TypeError(`TableCardinality.${name} must be an integer number, a bigint, or null (got ${typeof v}: ${String(v)})`);
4665
+ }
4628
4666
  function serializeTableCardinality(card) {
4629
4667
  return {
4630
- estimate: card.estimate,
4631
- max: card.max
4668
+ estimate: cardinalityValue("estimate", card.estimate),
4669
+ max: cardinalityValue("max", card.max)
4632
4670
  };
4633
4671
  }
4634
4672
  // src/protocol/carried-init-request.ts
@@ -4901,7 +4939,7 @@ import {
4901
4939
  Protocol
4902
4940
  } from "@query-farm/vgi-rpc";
4903
4941
  var VGI_PROTOCOL_NAME = "vgi.v3";
4904
- var VGI_PROTOCOL_VERSION = "3.0.0";
4942
+ var VGI_PROTOCOL_VERSION = "3.1.0";
4905
4943
  function exchangeStream(callbacks) {
4906
4944
  return { kind: "exchange", ...callbacks };
4907
4945
  }
@@ -6350,9 +6388,9 @@ function registerVgiService(protocol, service) {
6350
6388
  const common = {
6351
6389
  params: m.params,
6352
6390
  outputSchema: stream.outputSchema,
6353
- headerSchema: m.header ?? undefined,
6354
- headerInit: stream.headerInit,
6355
- onCancel: stream.onCancel,
6391
+ ...m.header ? { headerSchema: m.header } : {},
6392
+ ...stream.headerInit ? { headerInit: stream.headerInit } : {},
6393
+ ...stream.onCancel ? { onCancel: stream.onCancel } : {},
6356
6394
  doc: m.doc
6357
6395
  };
6358
6396
  if (stream.kind === "exchange") {
@@ -6501,6 +6539,26 @@ var CopyFromFormatInfoSchema = schema2([
6501
6539
  field2("description", utf82(), false),
6502
6540
  field2("ordered", bool2(), false)
6503
6541
  ]);
6542
+ var FieldPathSchema = schema2([
6543
+ field2("components", list2(field2("item", utf82(), true)), false)
6544
+ ]);
6545
+ var TransformSpecSchema = schema2([
6546
+ field2("id", utf82(), false),
6547
+ field2("inputs", list2(field2("item", binary2(), true)), false),
6548
+ field2("parameters", binary2(), true)
6549
+ ]);
6550
+ var KeyGroupingSchema = schema2([
6551
+ field2("keys", list2(field2("item", binary2(), true)), false)
6552
+ ]);
6553
+ var RangeKeySchema = schema2([
6554
+ field2("transform", binary2(), false),
6555
+ field2("direction", dictionary2(utf82(), int162()), false),
6556
+ field2("null_order", dictionary2(utf82(), int162()), false)
6557
+ ]);
6558
+ var RangePartitioningSchema = schema2([
6559
+ field2("keys", list2(field2("item", binary2(), true)), false),
6560
+ field2("split_points", binary2(), false)
6561
+ ]);
6504
6562
  var MacroParameterSchema = schema2([
6505
6563
  field2("name", utf82(), false),
6506
6564
  field2("declared_type", binary2(), true),
@@ -6731,6 +6789,9 @@ var ScanSplitSchema = schema2([
6731
6789
  field2("estimated_rows", int642(), true),
6732
6790
  field2("rows_exact", bool2(), false),
6733
6791
  field2("estimated_bytes", int642(), true),
6792
+ field2("key_value", binary2(), true),
6793
+ field2("range_index", int642(), true),
6794
+ field2("column_bounds", binary2(), true),
6734
6795
  field2("partition_bounds", binary2(), true),
6735
6796
  field2("column_statistics", binary2(), true),
6736
6797
  field2("location_ids", list2(field2("item", int642(), true)), true),
@@ -7206,6 +7267,8 @@ var TableFunctionPlanResultSchema = schema2([
7206
7267
  field2("catalog_version", int642(), true),
7207
7268
  field2("scope", utf82(), false),
7208
7269
  field2("locations", list2(field2("item", utf82(), true)), true),
7270
+ field2("key_grouping", binary2(), true),
7271
+ field2("range_partitioning", binary2(), true),
7209
7272
  field2("partitioning", list2(field2("item", binary2(), true)), true),
7210
7273
  field2("sort_order", list2(field2("item", binary2(), true)), true),
7211
7274
  field2("cache_max_age_seconds", int642(), true),
@@ -10016,14 +10079,40 @@ function deserializePlanRequest(params) {
10016
10079
  projectionIds = [...raw].map(Number);
10017
10080
  }
10018
10081
  const asBigInt = (v) => v == null ? null : typeof v === "bigint" ? v : BigInt(Number(v));
10082
+ const asBytes = (v) => v == null ? null : toUint8Array2(v);
10083
+ const asBytesList = (v) => {
10084
+ if (v == null)
10085
+ return null;
10086
+ const values = Array.isArray(v) ? v : v && typeof v[Symbol.iterator] === "function" ? [...v] : [];
10087
+ return values.filter((entry) => entry != null).map(toUint8Array2);
10088
+ };
10089
+ const enumValue = (v, values) => {
10090
+ if (v == null)
10091
+ return null;
10092
+ const text = String(v);
10093
+ return values.includes(text) ? text : null;
10094
+ };
10019
10095
  return {
10020
10096
  bind_call: bindCall,
10021
- bind_opaque_data: params.bind_opaque_data ? toUint8Array2(params.bind_opaque_data) : null,
10097
+ bind_opaque_data: asBytes(params.bind_opaque_data),
10022
10098
  projection_ids: projectionIds,
10023
- pushdown_filters: params.pushdown_filters ? toUint8Array2(params.pushdown_filters) : null,
10099
+ pushdown_filters: asBytes(params.pushdown_filters),
10100
+ join_keys: asBytesList(params.join_keys),
10101
+ row_limit: asBigInt(params.row_limit),
10024
10102
  target_split_bytes: asBigInt(params.target_split_bytes),
10025
10103
  min_splits: asBigInt(params.min_splits),
10026
- cursor: params.cursor ? toUint8Array2(params.cursor) : null
10104
+ max_splits_per_response: asBigInt(params.max_splits_per_response),
10105
+ cursor: asBytes(params.cursor),
10106
+ refined_filters: asBytes(params.refined_filters),
10107
+ filters_complete: params.filters_complete == null ? true : Boolean(params.filters_complete),
10108
+ start_position: asBytes(params.start_position),
10109
+ end_position: asBytes(params.end_position),
10110
+ order_by_column_name: params.order_by_column_name == null ? null : String(params.order_by_column_name),
10111
+ order_by_direction: enumValue(params.order_by_direction, Object.values(OrderByDirection)),
10112
+ order_by_null_order: enumValue(params.order_by_null_order, Object.values(OrderByNullOrder)),
10113
+ order_by_limit: asBigInt(params.order_by_limit),
10114
+ tablesample_percentage: params.tablesample_percentage == null ? null : Number(params.tablesample_percentage),
10115
+ tablesample_seed: asBigInt(params.tablesample_seed)
10027
10116
  };
10028
10117
  }
10029
10118
  function fingerprintInputs(bindCallBytes) {
@@ -10043,6 +10132,9 @@ function scanSplitRow(split, token) {
10043
10132
  estimated_rows: asBigInt(split.estimatedRows),
10044
10133
  rows_exact: split.rowsExact === true,
10045
10134
  estimated_bytes: asBigInt(split.estimatedBytes),
10135
+ key_value: split.keyValue ?? null,
10136
+ range_index: asBigInt(split.rangeIndex),
10137
+ column_bounds: split.columnBounds ?? null,
10046
10138
  partition_bounds: split.partitionBounds ?? null,
10047
10139
  column_statistics: split.columnStatistics ?? null,
10048
10140
  location_ids: split.locationIds ?? null,
@@ -10063,12 +10155,14 @@ function planResponseRow(result, splitBlobs) {
10063
10155
  estimated_total_bytes: asBigInt(result.estimatedTotalBytes),
10064
10156
  catalog_version: asBigInt(result.catalogVersion),
10065
10157
  scope: result.scope ?? "catalog",
10066
- locations: null,
10067
- partitioning: [],
10068
- sort_order: [],
10158
+ locations: result.locations ?? null,
10159
+ key_grouping: result.keyGrouping ?? null,
10160
+ range_partitioning: result.rangePartitioning ?? null,
10161
+ partitioning: result.partitioning ?? null,
10162
+ sort_order: result.sortOrder ?? null,
10069
10163
  cache_max_age_seconds: asBigInt(result.cacheMaxAgeSeconds),
10070
- start_position: new Uint8Array(0),
10071
- end_position: new Uint8Array(0)
10164
+ start_position: result.startPosition ?? null,
10165
+ end_position: result.endPosition ?? null
10072
10166
  };
10073
10167
  }
10074
10168
 
@@ -11012,6 +11106,7 @@ function extractArgMap(cfg, args) {
11012
11106
  }
11013
11107
  }
11014
11108
  for (let i = 0;i < constNames.length; i++) {
11109
+ const name = constNames[i];
11015
11110
  let v;
11016
11111
  try {
11017
11112
  v = args.get(i);
@@ -11026,16 +11121,16 @@ function extractArgMap(cfg, args) {
11026
11121
  v = Number(v);
11027
11122
  }
11028
11123
  } catch {
11029
- const def = cfg.argDefaults?.[constNames[i]];
11124
+ const def = cfg.argDefaults?.[name];
11030
11125
  if (def !== undefined)
11031
- out[constNames[i]] = def;
11126
+ out[name] = def;
11032
11127
  continue;
11033
11128
  }
11034
- const constraints = cfg.argConstraints?.[constNames[i]];
11129
+ const constraints = cfg.argConstraints?.[name];
11035
11130
  if (constraints !== undefined) {
11036
- validateConstConstraints(constNames[i], constraints, v);
11131
+ validateConstConstraints(name, constraints, v);
11037
11132
  }
11038
- out[constNames[i]] = v;
11133
+ out[name] = v;
11039
11134
  }
11040
11135
  if (cfg.argDefaults) {
11041
11136
  for (const [name, def] of Object.entries(cfg.argDefaults)) {
@@ -12236,15 +12331,16 @@ class CatalogSnapshotManager {
12236
12331
  validateCatalogPublicationEnvelope(bytes);
12237
12332
  }
12238
12333
  });
12239
- if (resolved.numRows !== 1 || resolved.schema.fields.length !== 1 || resolved.schema.fields[0].name !== "result" || typeSignature(resolved.schema.fields[0].type) !== typeSignature(binary2()) || resolved.schema.fields[0].nullable)
12334
+ const resultField = resolved.schema.fields.length === 1 ? resolved.schema.fields[0] : undefined;
12335
+ if (resolved.numRows !== 1 || !resultField || resultField.name !== "result" || typeSignature(resultField.type) !== typeSignature(binary2()) || resultField.nullable)
12240
12336
  throw new Error("invalid published RPC envelope");
12241
12337
  const bytes = resolved.getChild("result")?.get(0);
12242
12338
  if (!(bytes instanceof Uint8Array))
12243
12339
  throw new Error("published catalog has no result bytes");
12244
12340
  const decoded = decodeASDCollection(CatalogContentsResultSchema, bytes);
12245
- if (decoded.length !== 1)
12341
+ const response = decoded.length === 1 ? decoded[0] : undefined;
12342
+ if (!response)
12246
12343
  throw new Error("published catalog must contain exactly one response row");
12247
- const response = decoded[0];
12248
12344
  if (response.not_modified || Number(response.catalog_version) !== identity.catalogVersion || response.etag !== m.etag)
12249
12345
  throw new Error("published catalog version or ETag mismatch");
12250
12346
  decodeCatalogStreams(response);
@@ -13959,12 +14055,12 @@ function buildRpcServer(primary, hosting, options) {
13959
14055
  if (tickets)
13960
14056
  protocols.push(tickets);
13961
14057
  }
13962
- return new VgiRpcServer(primary, {
14058
+ return new VgiRpcServer(primary, omitUndefined({
13963
14059
  serverId: options.serverId,
13964
14060
  protocols,
13965
14061
  identity,
13966
14062
  grantKeys: null
13967
- });
14063
+ }));
13968
14064
  }
13969
14065
  function validatedHostedProtocols(hosting, primary) {
13970
14066
  if (hosting.hostedProtocols === undefined)
@@ -14008,13 +14104,13 @@ function buildIdentity(hosting, grantKeys, env) {
14008
14104
  const { resolveToken, mintGrant } = hosting;
14009
14105
  if (!resolveToken && !mintGrant && !grantKeys)
14010
14106
  return;
14011
- return new IdentityImpl({
14107
+ return new IdentityImpl(omitUndefined({
14012
14108
  resolveToken,
14013
14109
  mintGrant,
14014
14110
  grantKeys: grantKeys ?? undefined,
14015
14111
  introspectPrincipals: resolveToken ? resolveIntrospectPrincipals(hosting.introspectPrincipals, env) : undefined,
14016
14112
  maxAuthAge: hosting.maxAuthAge
14017
- });
14113
+ }));
14018
14114
  }
14019
14115
  function buildAttachTickets(hosting, grantKeys, config, env) {
14020
14116
  if (!config || !config.signingKeyConfigured || !config.signingKey)
@@ -14096,7 +14192,7 @@ function createVgiFetch(opts) {
14096
14192
  });
14097
14193
  const reservedCheck = checkReservedAttachOptions(opts.protocol.catalogInterface);
14098
14194
  reservedCheck.catch((e) => console.error(`VGI worker refused to serve: ${e.message}`));
14099
- const handler = createHttpHandler(server, {
14195
+ const handler = createHttpHandler(server, omitUndefined({
14100
14196
  prefix,
14101
14197
  serverId,
14102
14198
  tokenKey: opts.signingKey,
@@ -14111,7 +14207,7 @@ function createVgiFetch(opts) {
14111
14207
  repositoryUrl: opts.repositoryUrl,
14112
14208
  extraRoutes: createLandingRoutes(opts.landingInfo),
14113
14209
  enableLandingPage: false
14114
- });
14210
+ }));
14115
14211
  return async (req) => {
14116
14212
  await reservedCheck;
14117
14213
  const storage = await ensureRequestAuthStorage();
@@ -14504,7 +14600,7 @@ function defineTableFunction(config) {
14504
14600
  lookup_names: result.lookupNames
14505
14601
  };
14506
14602
  },
14507
- projection: config.projection ? (proposal) => config.projection({ args: extractArgs(proposal.bindCall), bindCall: proposal.bindCall, settings: batchToScalarDict(proposal.bindCall.settings), secrets: batchToSecretDict(proposal.bindCall.secrets), resolvedSecretsProvided: proposal.bindCall.resolved_secrets_provided }, proposal) : undefined,
14603
+ ...config.projection ? { projection: (proposal) => config.projection({ args: extractArgs(proposal.bindCall), bindCall: proposal.bindCall, settings: batchToScalarDict(proposal.bindCall.settings), secrets: batchToSecretDict(proposal.bindCall.secrets), resolvedSecretsProvided: proposal.bindCall.resolved_secrets_provided }, proposal) } : {},
14508
14604
  async globalInit(request) {
14509
14605
  const executionId = new Uint8Array(16);
14510
14606
  crypto.getRandomValues(executionId);
@@ -14617,55 +14713,63 @@ function defineTableFunction(config) {
14617
14713
  }
14618
14714
  };
14619
14715
  },
14620
- cardinality: config.cardinality ? (request) => {
14621
- const args = extractArgs(request.bind_call);
14622
- const settings = batchToScalarDict(request.bind_call.settings);
14623
- const secrets = batchToSecretDict(request.bind_call.secrets);
14624
- return config.cardinality({
14625
- args,
14626
- bindCall: request.bind_call,
14627
- settings,
14628
- secrets,
14629
- resolvedSecretsProvided: request.bind_call.resolved_secrets_provided ?? false
14630
- });
14631
- } : undefined,
14632
- plan: config.plan ? (request) => {
14633
- const args = extractArgs(request.bind_call);
14634
- const settings = batchToScalarDict(request.bind_call.settings);
14635
- const secrets = batchToSecretDict(request.bind_call.secrets);
14636
- return config.plan({
14637
- args,
14638
- bindCall: request.bind_call,
14639
- settings,
14640
- secrets,
14641
- resolvedSecretsProvided: request.bind_call.resolved_secrets_provided ?? false
14642
- }, request);
14643
- } : undefined,
14644
- statistics: config.statistics ? (request) => {
14645
- const args = extractArgs(request.bind_call);
14646
- const settings = batchToScalarDict(request.bind_call.settings);
14647
- const secrets = batchToSecretDict(request.bind_call.secrets);
14648
- return config.statistics({
14649
- args,
14650
- bindCall: request.bind_call,
14651
- settings,
14652
- secrets,
14653
- resolvedSecretsProvided: request.bind_call.resolved_secrets_provided ?? false
14654
- });
14655
- } : undefined,
14656
- dynamicToString: config.dynamicToString ? (request) => {
14657
- const args = extractArgs(request.bindCall);
14658
- const settings = batchToScalarDict(request.bindCall.settings);
14659
- const secrets = batchToSecretDict(request.bindCall.secrets);
14660
- const storage2 = new BoundStorage(storage, request.globalExecutionId);
14661
- return config.dynamicToString({
14662
- args,
14663
- bindCall: request.bindCall,
14664
- settings,
14665
- secrets,
14666
- resolvedSecretsProvided: request.bindCall.resolved_secrets_provided ?? false
14667
- }, request.globalExecutionId, storage2);
14668
- } : undefined
14716
+ ...config.cardinality ? {
14717
+ cardinality: (request) => {
14718
+ const args = extractArgs(request.bind_call);
14719
+ const settings = batchToScalarDict(request.bind_call.settings);
14720
+ const secrets = batchToSecretDict(request.bind_call.secrets);
14721
+ return config.cardinality({
14722
+ args,
14723
+ bindCall: request.bind_call,
14724
+ settings,
14725
+ secrets,
14726
+ resolvedSecretsProvided: request.bind_call.resolved_secrets_provided ?? false
14727
+ });
14728
+ }
14729
+ } : {},
14730
+ ...config.plan ? {
14731
+ plan: (request) => {
14732
+ const args = extractArgs(request.bind_call);
14733
+ const settings = batchToScalarDict(request.bind_call.settings);
14734
+ const secrets = batchToSecretDict(request.bind_call.secrets);
14735
+ return config.plan({
14736
+ args,
14737
+ bindCall: request.bind_call,
14738
+ settings,
14739
+ secrets,
14740
+ resolvedSecretsProvided: request.bind_call.resolved_secrets_provided ?? false
14741
+ }, request);
14742
+ }
14743
+ } : {},
14744
+ ...config.statistics ? {
14745
+ statistics: (request) => {
14746
+ const args = extractArgs(request.bind_call);
14747
+ const settings = batchToScalarDict(request.bind_call.settings);
14748
+ const secrets = batchToSecretDict(request.bind_call.secrets);
14749
+ return config.statistics({
14750
+ args,
14751
+ bindCall: request.bind_call,
14752
+ settings,
14753
+ secrets,
14754
+ resolvedSecretsProvided: request.bind_call.resolved_secrets_provided ?? false
14755
+ });
14756
+ }
14757
+ } : {},
14758
+ ...config.dynamicToString ? {
14759
+ dynamicToString: (request) => {
14760
+ const args = extractArgs(request.bindCall);
14761
+ const settings = batchToScalarDict(request.bindCall.settings);
14762
+ const secrets = batchToSecretDict(request.bindCall.secrets);
14763
+ const storage2 = new BoundStorage(storage, request.globalExecutionId);
14764
+ return config.dynamicToString({
14765
+ args,
14766
+ bindCall: request.bindCall,
14767
+ settings,
14768
+ secrets,
14769
+ resolvedSecretsProvided: request.bindCall.resolved_secrets_provided ?? false
14770
+ }, request.globalExecutionId, storage2);
14771
+ }
14772
+ } : {}
14669
14773
  };
14670
14774
  }
14671
14775
  // src/functions/table-in-out.ts
@@ -15570,12 +15674,13 @@ class ReadOnlyCatalogInterface extends CatalogInterface {
15570
15674
  if (typeof part !== "string" || !part || part.includes("\x00"))
15571
15675
  throw new Error("invalid requiredFilters component");
15572
15676
  const matches = fields.filter((f) => f.name === part);
15573
- if (matches.length !== 1)
15677
+ const match = matches.length === 1 ? matches[0] : undefined;
15678
+ if (!match)
15574
15679
  throw new Error(`unknown or ambiguous requiredFilters component: ${part}`);
15575
15680
  if (i + 1 < path.length) {
15576
- if (!isStruct(matches[0].type))
15681
+ if (!isStruct(match.type))
15577
15682
  throw new Error(`non-struct requiredFilters parent: ${part}`);
15578
- fields = matches[0].type.children;
15683
+ fields = match.type.children;
15579
15684
  }
15580
15685
  }
15581
15686
  }
@@ -16133,7 +16238,7 @@ class CompositeCatalogInterface extends CatalogInterface {
16133
16238
  }
16134
16239
  _route(attachOpaqueData) {
16135
16240
  const idx = attachOpaqueData[ROUTE_BYTE];
16136
- const route = this._backends[idx];
16241
+ const route = idx === undefined ? undefined : this._backends[idx];
16137
16242
  if (!route) {
16138
16243
  throw new OpaqueDataRejectedError("attach_opaque_data");
16139
16244
  }
@@ -16786,4 +16891,4 @@ export {
16786
16891
  validateTableConstraints
16787
16892
  };
16788
16893
 
16789
- //# debugId=F6DD0A9F209BC28864756E2164756E21
16894
+ //# debugId=F3074584951B62A064756E2164756E21