@query-farm/vgi 0.28.0 → 0.29.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 (121) hide show
  1. package/README.md +52 -8
  2. package/dist/arguments/argument-spec.d.ts +57 -2
  3. package/dist/arrow/impl-arrowjs/index.d.ts +1 -1
  4. package/dist/arrow/impl-arrowjs/iterate.d.ts +10 -1
  5. package/dist/arrow/impl-arrowjs/schema.d.ts +2 -0
  6. package/dist/arrow/impl-flechette/index.d.ts +1 -1
  7. package/dist/arrow/impl-flechette/iterate.d.ts +10 -1
  8. package/dist/arrow/impl-flechette/schema.d.ts +2 -0
  9. package/dist/arrow/index.d.ts +1 -1
  10. package/dist/arrow/schema-types.d.ts +3 -1
  11. package/dist/arrow/types.d.ts +39 -3
  12. package/dist/catalog/composite.d.ts +13 -13
  13. package/dist/catalog/descriptors.d.ts +7 -3
  14. package/dist/catalog/interface.d.ts +108 -38
  15. package/dist/catalog/read-only.d.ts +32 -15
  16. package/dist/client/client.d.ts +37 -30
  17. package/dist/client/types.d.ts +2 -0
  18. package/dist/client-entry.d.ts +1 -1
  19. package/dist/client-entry.js +791 -447
  20. package/dist/client-entry.js.map +18 -17
  21. package/dist/filter-pushdown/capabilities.d.ts +3 -0
  22. package/dist/filter-pushdown/deserialize.d.ts +14 -15
  23. package/dist/filter-pushdown/evaluate.d.ts +14 -44
  24. package/dist/filter-pushdown/index.d.ts +2 -2
  25. package/dist/filter-pushdown/types.d.ts +120 -68
  26. package/dist/functions/aggregate.d.ts +4 -0
  27. package/dist/functions/registry.d.ts +5 -5
  28. package/dist/functions/scalar.d.ts +6 -1
  29. package/dist/functions/table-buffering.d.ts +9 -0
  30. package/dist/functions/table-in-out.d.ts +13 -0
  31. package/dist/functions/table.d.ts +72 -2
  32. package/dist/functions/types.d.ts +60 -2
  33. package/dist/generated/vgi-client.d.ts +114 -26
  34. package/dist/generated/vgi-protocol-schemas.d.ts +34 -0
  35. package/dist/http/fetch.d.ts +16 -0
  36. package/dist/index.core.d.ts +4 -3
  37. package/dist/index.js +3396 -2064
  38. package/dist/index.js.map +55 -49
  39. package/dist/metadata/types.d.ts +15 -2
  40. package/dist/protocol/handlers/catalog/shared.d.ts +0 -8
  41. package/dist/protocol/handlers/function.d.ts +11 -0
  42. package/dist/protocol/handlers/shared.d.ts +3 -1
  43. package/dist/protocol/serializers/bind.d.ts +1 -2
  44. package/dist/protocol/serializers/cardinality.d.ts +1 -2
  45. package/dist/protocol/serializers/splits.d.ts +126 -0
  46. package/dist/protocol/types.d.ts +36 -3
  47. package/dist/request-auth.d.ts +28 -0
  48. package/dist/schema-path.d.ts +7 -0
  49. package/dist/serve-entry.d.ts +25 -0
  50. package/dist/serve-entry.js +1129 -569
  51. package/dist/serve-entry.js.map +36 -32
  52. package/dist/split-token.d.ts +88 -0
  53. package/dist/types.d.ts +8 -0
  54. package/dist/worker-cf-entry.js +2928 -1689
  55. package/dist/worker-cf-entry.js.map +51 -44
  56. package/dist/worker.d.ts +1 -1
  57. package/package.json +3 -3
  58. package/src/arguments/argument-spec.ts +93 -4
  59. package/src/arguments/arguments.ts +0 -1
  60. package/src/arrow/impl-arrowjs/index.ts +1 -1
  61. package/src/arrow/impl-arrowjs/iterate.ts +21 -0
  62. package/src/arrow/impl-arrowjs/schema.ts +4 -0
  63. package/src/arrow/impl-flechette/index.ts +1 -1
  64. package/src/arrow/impl-flechette/iterate.ts +24 -1
  65. package/src/arrow/impl-flechette/schema.ts +4 -0
  66. package/src/arrow/index.ts +1 -1
  67. package/src/arrow/schema-types.ts +4 -0
  68. package/src/arrow/types.ts +39 -3
  69. package/src/catalog/composite.ts +26 -26
  70. package/src/catalog/descriptors.ts +12 -3
  71. package/src/catalog/interface.ts +217 -72
  72. package/src/catalog/read-only.ts +141 -84
  73. package/src/client/client.ts +97 -73
  74. package/src/client/types.ts +2 -0
  75. package/src/client-entry.ts +2 -1
  76. package/src/filter-pushdown/capabilities.ts +13 -0
  77. package/src/filter-pushdown/collector.ts +22 -35
  78. package/src/filter-pushdown/deserialize.ts +657 -221
  79. package/src/filter-pushdown/evaluate.ts +410 -499
  80. package/src/filter-pushdown/index.ts +16 -2
  81. package/src/filter-pushdown/types.ts +88 -71
  82. package/src/functions/aggregate.ts +12 -1
  83. package/src/functions/copy-from.ts +2 -1
  84. package/src/functions/copy-to.ts +2 -1
  85. package/src/functions/registry.ts +24 -22
  86. package/src/functions/scalar.ts +37 -0
  87. package/src/functions/table-buffering.ts +48 -6
  88. package/src/functions/table-in-out.ts +194 -33
  89. package/src/functions/table.ts +187 -22
  90. package/src/functions/types.ts +64 -1
  91. package/src/generated/vgi-client.ts +122 -28
  92. package/src/generated/vgi-protocol-schemas.ts +455 -58
  93. package/src/http/fetch.ts +129 -2
  94. package/src/index.core.ts +4 -2
  95. package/src/metadata/resolve.ts +43 -1
  96. package/src/metadata/serialize.ts +43 -5
  97. package/src/metadata/types.ts +17 -1
  98. package/src/protocol/dispatch.ts +1 -1
  99. package/src/protocol/handlers/aggregate.ts +23 -12
  100. package/src/protocol/handlers/catalog/admin.ts +47 -54
  101. package/src/protocol/handlers/catalog/index_methods.ts +6 -13
  102. package/src/protocol/handlers/catalog/macro.ts +12 -20
  103. package/src/protocol/handlers/catalog/shared.ts +12 -57
  104. package/src/protocol/handlers/catalog/table.ts +49 -112
  105. package/src/protocol/handlers/catalog/view.ts +18 -22
  106. package/src/protocol/handlers/function.ts +311 -18
  107. package/src/protocol/handlers/shared.ts +12 -3
  108. package/src/protocol/handlers/table-buffering.ts +11 -8
  109. package/src/protocol/serializers/bind.ts +69 -67
  110. package/src/protocol/serializers/cardinality.ts +7 -7
  111. package/src/protocol/serializers/init.ts +52 -10
  112. package/src/protocol/serializers/splits.ts +221 -0
  113. package/src/protocol/state-serializer.ts +55 -1
  114. package/src/protocol/types.ts +36 -3
  115. package/src/request-auth.ts +73 -0
  116. package/src/schema-path.ts +25 -0
  117. package/src/serve-entry.ts +69 -2
  118. package/src/split-token.ts +297 -0
  119. package/src/types.ts +9 -0
  120. package/src/worker-cf-entry.ts +2 -1
  121. package/src/worker.ts +79 -14
@@ -1,28 +1,5 @@
1
1
  // @bun
2
2
  var __defProp = Object.defineProperty;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- function __accessProp(key) {
7
- return this[key];
8
- }
9
- var __toCommonJS = (from) => {
10
- var entry = (__moduleCache ??= new WeakMap).get(from), desc;
11
- if (entry)
12
- return entry;
13
- entry = __defProp({}, "__esModule", { value: true });
14
- if (from && typeof from === "object" || typeof from === "function") {
15
- for (var key of __getOwnPropNames(from))
16
- if (!__hasOwnProp.call(entry, key))
17
- __defProp(entry, key, {
18
- get: __accessProp.bind(from, key),
19
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
20
- });
21
- }
22
- __moduleCache.set(from, entry);
23
- return entry;
24
- };
25
- var __moduleCache;
26
3
  var __returnValue = (v) => v;
27
4
  function __exportSetter(name, newValue) {
28
5
  this[name] = __returnValue.bind(null, newValue);
@@ -36,14 +13,19 @@ var __export = (target, all) => {
36
13
  set: __exportSetter.bind(all, name)
37
14
  });
38
15
  };
39
- var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
16
+ var __esm = (fn, res, err) => () => {
17
+ if (fn)
18
+ try {
19
+ res = fn(fn = 0);
20
+ } catch (e) {
21
+ err = [e];
22
+ }
23
+ if (err)
24
+ throw err[0];
25
+ return res;
26
+ };
40
27
 
41
28
  // src/functions/storage-cf-do.ts
42
- var exports_storage_cf_do = {};
43
- __export(exports_storage_cf_do, {
44
- FunctionStorageCfDo: () => FunctionStorageCfDo
45
- });
46
-
47
29
  class FunctionStorageCfDo {
48
30
  _baseUrl;
49
31
  _token;
@@ -184,8 +166,8 @@ class FunctionStorageCfDo {
184
166
  let resp;
185
167
  try {
186
168
  resp = await this._fetch(url, { method: "POST", headers, body: payload });
187
- } catch (err2) {
188
- lastErr = err2;
169
+ } catch (err) {
170
+ lastErr = err;
189
171
  continue;
190
172
  }
191
173
  let data;
@@ -230,16 +212,16 @@ function int64FromKey(b) {
230
212
  return Number(new DataView(b.buffer, b.byteOffset, 8).getBigInt64(0, false));
231
213
  }
232
214
  function bytesToB64(buf) {
233
- let binary3 = "";
215
+ let binary = "";
234
216
  for (let i = 0;i < buf.length; i++)
235
- binary3 += String.fromCharCode(buf[i]);
236
- return btoa(binary3);
217
+ binary += String.fromCharCode(buf[i]);
218
+ return btoa(binary);
237
219
  }
238
220
  function b64ToBytes(b64) {
239
- const binary3 = atob(b64);
240
- const out = new Uint8Array(binary3.length);
241
- for (let i = 0;i < binary3.length; i++)
242
- out[i] = binary3.charCodeAt(i);
221
+ const binary = atob(b64);
222
+ const out = new Uint8Array(binary.length);
223
+ for (let i = 0;i < binary.length; i++)
224
+ out[i] = binary.charCodeAt(i);
243
225
  return out;
244
226
  }
245
227
  var NS_WORKER;
@@ -481,18 +463,18 @@ class BoundStorage {
481
463
  }
482
464
  }
483
465
  function resolveStorageFromEnv() {
484
- const backend2 = (process.env.VGI_WORKER_SHARED_STORAGE ?? "sqlite").toLowerCase();
485
- if (backend2 === "memory") {
466
+ const backend = (process.env.VGI_WORKER_SHARED_STORAGE ?? "sqlite").toLowerCase();
467
+ if (backend === "memory") {
486
468
  return new FunctionStorageSqlite(":memory:");
487
469
  }
488
- if (backend2 === "sqlite") {
470
+ if (backend === "sqlite") {
489
471
  return new FunctionStorageSqlite;
490
472
  }
491
- if (backend2 === "cloudflare-do") {
492
- const { FunctionStorageCfDo: FunctionStorageCfDo2 } = (init_storage_cf_do(), __toCommonJS(exports_storage_cf_do));
493
- return FunctionStorageCfDo2.fromEnv();
473
+ if (backend === "cloudflare-do") {
474
+ init_storage_cf_do();
475
+ return FunctionStorageCfDo.fromEnv();
494
476
  }
495
- throw new Error(`Unknown VGI_WORKER_SHARED_STORAGE backend: '${backend2}'. Supported: 'memory', 'sqlite', 'cloudflare-do'.`);
477
+ throw new Error(`Unknown VGI_WORKER_SHARED_STORAGE backend: '${backend}'. Supported: 'memory', 'sqlite', 'cloudflare-do'.`);
496
478
  }
497
479
  function getDefaultStorage() {
498
480
  if (_resolved == null)
@@ -530,8 +512,20 @@ var init_storage = __esm(() => {
530
512
  });
531
513
  });
532
514
 
515
+ // src/serve-entry.ts
516
+ import {
517
+ irohForwardedHeaderIdentityProvider,
518
+ IROH_FORWARDED_ENDPOINT_HEADER,
519
+ observePeerIdentity,
520
+ peerIdentityPrimary
521
+ } from "@query-farm/vgi-rpc";
522
+
533
523
  // src/http/fetch.ts
534
- import { createHttpHandler, unpackStateToken } from "@query-farm/vgi-rpc";
524
+ import {
525
+ AuthContext,
526
+ createHttpHandler,
527
+ unpackStateToken
528
+ } from "@query-farm/vgi-rpc";
535
529
 
536
530
  // src/arrow/predicates.ts
537
531
  var TypeId = {
@@ -560,75 +554,113 @@ var TypeId = {
560
554
  function isDecimal(t) {
561
555
  return t.typeId === TypeId.Decimal;
562
556
  }
557
+ function typeSignature(t) {
558
+ if (t == null)
559
+ return "null";
560
+ const a = t;
561
+ const kids = () => Array.isArray(a.children) ? a.children.map((c) => `${c?.name ?? ""}:${typeSignature(c?.type ?? c)}`).join(",") : "";
562
+ switch (t.typeId) {
563
+ case TypeId.Int:
564
+ return `int${a.bitWidth}${a.isSigned ?? a.signed ?? true ? "" : "u"}`;
565
+ case TypeId.Float:
566
+ return `float${a.precision}`;
567
+ case TypeId.Decimal:
568
+ return `decimal${a.bitWidth ?? 128}(${a.precision},${a.scale})`;
569
+ case TypeId.Date:
570
+ case TypeId.Time:
571
+ case TypeId.Duration:
572
+ return `${t.typeId}[${a.unit}]`;
573
+ case TypeId.Timestamp:
574
+ return `ts[${a.unit},${a.timezone ?? ""}]`;
575
+ case TypeId.Interval:
576
+ return `iv[${a.unit}]`;
577
+ case TypeId.FixedSizeBinary:
578
+ return `fsb(${a.byteWidth ?? a.stride})`;
579
+ case TypeId.FixedSizeList:
580
+ return `fsl(${a.listSize ?? a.stride},${kids()})`;
581
+ case TypeId.List:
582
+ case TypeId.Struct:
583
+ case TypeId.Map:
584
+ return `${t.typeId}<${kids()}>`;
585
+ case TypeId.Union:
586
+ return `union(${a.mode},${kids()})`;
587
+ case TypeId.Dictionary:
588
+ return `dict(${typeSignature(a.dictionary)},${typeSignature(a.indices)},${a.ordered ?? a.isOrdered ?? false})`;
589
+ default:
590
+ return Array.isArray(a.children) ? `${t.typeId}<${kids()}>` : String(t.typeId);
591
+ }
592
+ }
563
593
  // src/arrow/impl-arrowjs/index.ts
564
594
  var exports_impl_arrowjs = {};
565
595
  __export(exports_impl_arrowjs, {
566
- withBatchMetadata: () => withBatchMetadata,
567
- utf8: () => utf8,
568
- union: () => union,
569
- uint8: () => uint8,
570
- uint64: () => uint64,
571
- uint32: () => uint32,
572
- uint16: () => uint16,
573
- timestamp: () => timestamp,
574
- timeSecond: () => timeSecond,
575
- timeNanosecond: () => timeNanosecond,
576
- timeMillisecond: () => timeMillisecond,
577
- timeMicrosecond: () => timeMicrosecond,
578
- time: () => time,
579
- struct: () => struct,
580
- sparseUnion: () => sparseUnion,
581
- serializeSchema: () => serializeSchema,
582
- serializeBatch: () => serializeBatch,
583
- schema: () => schema,
584
- safeNumber: () => safeNumber,
585
- readCanonicalValue: () => readCanonicalValue,
586
- projectSchema: () => projectSchema,
587
- projectBatch: () => projectBatch,
588
- nullType: () => nullType,
589
- map: () => map,
590
- list: () => list,
591
- iterRows: () => iterRows,
592
- interval: () => interval,
593
- int8: () => int8,
594
- int64: () => int64,
595
- int32: () => int32,
596
- int16: () => int16,
597
- int: () => int,
598
- float64: () => float64,
599
- float32: () => float32,
600
- float16: () => float16,
601
- fixedSizeList: () => fixedSizeList,
602
- fixedSizeBinary: () => fixedSizeBinary,
603
- filterBatch: () => filterBatch,
604
- field: () => field,
605
- emptyBatch: () => emptyBatch,
606
- duration: () => duration,
607
- dictionary: () => dictionary,
608
- deserializeSchema: () => deserializeSchema,
609
- deserializeBatch: () => deserializeBatch,
610
- denseUnion: () => denseUnion,
611
- decodeDictValue: () => decodeDictValue,
612
- decimal256: () => decimal256,
613
- decimal128: () => decimal128,
614
- decimal: () => decimal,
615
- dateMillisecond: () => dateMillisecond,
616
- dateDay: () => dateDay,
617
- date: () => date,
618
- columnFromArray: () => columnFromArray,
619
- buildStatisticsBatch: () => buildStatisticsBatch,
620
- bool: () => bool,
621
- binary: () => binary,
622
- batchToSecretDict: () => batchToSecretDict,
623
- batchToScalarDict: () => batchToScalarDict,
624
- batchFromRows: () => batchFromRows,
625
- batchFromColumns: () => batchFromColumns,
626
- backend: () => backend,
627
- adoptArrowJsShape: () => adoptArrowJsShape,
628
- UnionMode: () => UnionMode,
629
- TimeUnit: () => TimeUnit,
596
+ DateUnit: () => DateUnit,
630
597
  IntervalUnit: () => IntervalUnit,
631
- DateUnit: () => DateUnit
598
+ TimeUnit: () => TimeUnit,
599
+ UnionMode: () => UnionMode,
600
+ adoptArrowJsShape: () => adoptArrowJsShape,
601
+ backend: () => backend,
602
+ batchFromColumns: () => batchFromColumns,
603
+ batchFromRows: () => batchFromRows,
604
+ batchToScalarDict: () => batchToScalarDict,
605
+ batchToSecretDict: () => batchToSecretDict,
606
+ binary: () => binary,
607
+ bool: () => bool,
608
+ buildStatisticsBatch: () => buildStatisticsBatch,
609
+ columnFromArray: () => columnFromArray,
610
+ date: () => date,
611
+ dateDay: () => dateDay,
612
+ dateMillisecond: () => dateMillisecond,
613
+ decimal: () => decimal,
614
+ decimal128: () => decimal128,
615
+ decimal256: () => decimal256,
616
+ decodeDictValue: () => decodeDictValue,
617
+ denseUnion: () => denseUnion,
618
+ deserializeBatch: () => deserializeBatch,
619
+ deserializeSchema: () => deserializeSchema,
620
+ dictionary: () => dictionary,
621
+ duration: () => duration,
622
+ emptyBatch: () => emptyBatch,
623
+ field: () => field,
624
+ filterBatch: () => filterBatch,
625
+ fixedSizeBinary: () => fixedSizeBinary,
626
+ fixedSizeList: () => fixedSizeList,
627
+ float16: () => float16,
628
+ float32: () => float32,
629
+ float64: () => float64,
630
+ int: () => int,
631
+ int16: () => int16,
632
+ int32: () => int32,
633
+ int64: () => int64,
634
+ int8: () => int8,
635
+ interval: () => interval,
636
+ iterRows: () => iterRows,
637
+ largeBinary: () => largeBinary,
638
+ largeUtf8: () => largeUtf8,
639
+ list: () => list,
640
+ map: () => map,
641
+ nullType: () => nullType,
642
+ projectBatch: () => projectBatch,
643
+ projectSchema: () => projectSchema,
644
+ readCanonicalValue: () => readCanonicalValue,
645
+ safeNumber: () => safeNumber,
646
+ schema: () => schema,
647
+ serializeBatch: () => serializeBatch,
648
+ serializeSchema: () => serializeSchema,
649
+ sparseUnion: () => sparseUnion,
650
+ struct: () => struct,
651
+ time: () => time,
652
+ timeMicrosecond: () => timeMicrosecond,
653
+ timeMillisecond: () => timeMillisecond,
654
+ timeNanosecond: () => timeNanosecond,
655
+ timeSecond: () => timeSecond,
656
+ timestamp: () => timestamp,
657
+ uint16: () => uint16,
658
+ uint32: () => uint32,
659
+ uint64: () => uint64,
660
+ uint8: () => uint8,
661
+ union: () => union,
662
+ utf8: () => utf8,
663
+ withBatchMetadata: () => withBatchMetadata
632
664
  });
633
665
 
634
666
  // src/arrow/impl-arrowjs/schema.ts
@@ -649,7 +681,9 @@ import {
649
681
  Float32 as A_Float32,
650
682
  Float64 as A_Float64,
651
683
  Utf8 as A_Utf8,
684
+ LargeUtf8 as A_LargeUtf8,
652
685
  Binary as A_Binary,
686
+ LargeBinary as A_LargeBinary,
653
687
  Decimal as A_Decimal,
654
688
  Date_ as A_Date,
655
689
  Time as A_Time,
@@ -734,7 +768,9 @@ var float16 = () => new A_Float16;
734
768
  var float32 = () => new A_Float32;
735
769
  var float64 = () => new A_Float64;
736
770
  var utf8 = () => new A_Utf8;
771
+ var largeUtf8 = () => new A_LargeUtf8;
737
772
  var binary = () => new A_Binary;
773
+ var largeBinary = () => new A_LargeBinary;
738
774
  var fixedSizeBinary = (byteWidth) => new A_FixedSizeBinary(byteWidth);
739
775
  function decimal(precision, scale, bitWidth = 128) {
740
776
  return new A_Decimal(scale, precision, bitWidth);
@@ -793,8 +829,8 @@ import {
793
829
  DataType,
794
830
  makeData
795
831
  } from "@query-farm/apache-arrow";
796
- function emptyData(field2) {
797
- const type = field2.type;
832
+ function emptyData(field) {
833
+ const type = field.type;
798
834
  if (DataType.isList(type)) {
799
835
  const childField = type.children[0];
800
836
  return makeData({
@@ -821,8 +857,8 @@ function emptyData(field2) {
821
857
  }
822
858
  return makeData({ type, length: 0, nullCount: 0 });
823
859
  }
824
- function emptyBatch(schema2) {
825
- const a = schema2;
860
+ function emptyBatch(schema) {
861
+ const a = schema;
826
862
  const children = a.fields.map((f) => emptyData(f));
827
863
  const structType = new Struct(a.fields);
828
864
  const data = makeData({
@@ -1829,8 +1865,8 @@ function readUnion(type, col, data, index) {
1829
1865
  const children = type.children;
1830
1866
  const typeIds = data?.typeIds;
1831
1867
  const tcode = typeIds ? typeIds[index] : children.length > 0 ? 0 : -1;
1832
- const map2 = type.typeIdToChildIndex;
1833
- const childIdx = map2 && map2[tcode] !== undefined ? map2[tcode] : tcode;
1868
+ const map = type.typeIdToChildIndex;
1869
+ const childIdx = map && map[tcode] !== undefined ? map[tcode] : tcode;
1834
1870
  const childField = children[childIdx];
1835
1871
  if (!childField)
1836
1872
  return { tag: null, value: null };
@@ -1892,19 +1928,19 @@ function readDictionary(type, col, data, index) {
1892
1928
  function columnFromArray(values, type) {
1893
1929
  return vectorFromArray2(values, type).data[0];
1894
1930
  }
1895
- function batchFromRows(rows, schema2) {
1896
- const a = schema2;
1931
+ function batchFromRows(rows, schema) {
1932
+ const a = schema;
1897
1933
  if (rows.length === 0) {
1898
1934
  return emptyBatch(a);
1899
1935
  }
1900
1936
  const columns = {};
1901
- for (const field2 of a.fields) {
1902
- columns[field2.name] = rows.map((r) => r[field2.name] ?? null);
1937
+ for (const field of a.fields) {
1938
+ columns[field.name] = rows.map((r) => r[field.name] ?? null);
1903
1939
  }
1904
1940
  return batchFromColumns(columns, a);
1905
1941
  }
1906
- function batchFromColumns(columns, schema2, repr = "rich") {
1907
- const a = schema2;
1942
+ function batchFromColumns(columns, schema, repr = "rich") {
1943
+ const a = schema;
1908
1944
  const numRows = a.fields.length > 0 ? columns[a.fields[0].name]?.length ?? 0 : 0;
1909
1945
  const children = a.fields.map((f) => {
1910
1946
  const values = columns[f.name];
@@ -1932,15 +1968,15 @@ function* iterRows(batch, repr = "rich") {
1932
1968
  for (let i = 0;i < a.numRows; i++) {
1933
1969
  const row = {};
1934
1970
  for (let fi = 0;fi < a.schema.fields.length; fi++) {
1935
- const field2 = a.schema.fields[fi];
1936
- const col = a.getChild(field2.name);
1971
+ const field = a.schema.fields[fi];
1972
+ const col = a.getChild(field.name);
1937
1973
  if (!col) {
1938
- row[field2.name] = null;
1974
+ row[field.name] = null;
1939
1975
  continue;
1940
1976
  }
1941
- const canonical = readCanonicalValue(field2.type, col, i);
1977
+ const canonical = readCanonicalValue(field.type, col, i);
1942
1978
  const codec = codecs[fi];
1943
- row[field2.name] = repr === "raw" ? codec.canonicalToRaw(canonical) : codec.canonicalToRich(canonical);
1979
+ row[field.name] = repr === "raw" ? codec.canonicalToRaw(canonical) : codec.canonicalToRich(canonical);
1944
1980
  }
1945
1981
  yield row;
1946
1982
  }
@@ -1952,12 +1988,12 @@ function batchToScalarDict(batch) {
1952
1988
  if (a.numRows === 0)
1953
1989
  return {};
1954
1990
  const result = {};
1955
- for (const field2 of a.schema.fields) {
1956
- const col = a.getChild(field2.name);
1991
+ for (const field of a.schema.fields) {
1992
+ const col = a.getChild(field.name);
1957
1993
  if (col) {
1958
- const type = field2.type;
1994
+ const type = field.type;
1959
1995
  const canonical = readCanonicalValue(type, col, 0);
1960
- result[field2.name] = codecFor(type).canonicalToRich(canonical);
1996
+ result[field.name] = codecFor(type).canonicalToRich(canonical);
1961
1997
  }
1962
1998
  }
1963
1999
  return result;
@@ -1983,18 +2019,18 @@ function batchToSecretDict(batch) {
1983
2019
  if (a.numRows === 0)
1984
2020
  return {};
1985
2021
  const result = {};
1986
- for (const field2 of a.schema.fields) {
1987
- const col = a.getChild(field2.name);
2022
+ for (const field of a.schema.fields) {
2023
+ const col = a.getChild(field.name);
1988
2024
  if (col) {
1989
- const type = field2.type;
2025
+ const type = field.type;
1990
2026
  const val = codecFor(type).canonicalToRich(readCanonicalValue(type, col, 0));
1991
- let key = field2.name;
2027
+ let key = field.name;
1992
2028
  let scope;
1993
- if (field2.name.startsWith("secret_")) {
1994
- const secretType = field2.metadata?.get?.("secret_type");
2029
+ if (field.name.startsWith("secret_")) {
2030
+ const secretType = field.metadata?.get?.("secret_type");
1995
2031
  if (secretType) {
1996
2032
  key = secretType;
1997
- scope = field2.metadata?.get?.("scope") ?? undefined;
2033
+ scope = field.metadata?.get?.("scope") ?? undefined;
1998
2034
  }
1999
2035
  }
2000
2036
  if (val && typeof val === "object" && !ArrayBuffer.isView(val)) {
@@ -2013,8 +2049,13 @@ function batchToSecretDict(batch) {
2013
2049
  }
2014
2050
  return result;
2015
2051
  }
2052
+ var MAX_SAFE = BigInt(Number.MAX_SAFE_INTEGER);
2053
+ var MIN_SAFE = -MAX_SAFE;
2016
2054
  function safeNumber(value) {
2017
2055
  if (typeof value === "bigint") {
2056
+ if (value > MAX_SAFE || value < MIN_SAFE) {
2057
+ throw new RangeError(`${value} cannot be represented exactly as a JS number ` + `(|value| > Number.MAX_SAFE_INTEGER). Keep it as a bigint.`);
2058
+ }
2018
2059
  return Number(value);
2019
2060
  }
2020
2061
  return value;
@@ -2038,11 +2079,11 @@ function filterBatch(batch, mask) {
2038
2079
  indices.push(i);
2039
2080
  }
2040
2081
  const columns = {};
2041
- for (const field2 of a.schema.fields) {
2042
- const col = a.getChild(field2.name);
2043
- const type = field2.type;
2082
+ for (const field of a.schema.fields) {
2083
+ const col = a.getChild(field.name);
2084
+ const type = field.type;
2044
2085
  const codec = codecFor(type);
2045
- columns[field2.name] = indices.map((i) => codec.canonicalToRich(readCanonicalValue(type, col, i)));
2086
+ columns[field.name] = indices.map((i) => codec.canonicalToRich(readCanonicalValue(type, col, i)));
2046
2087
  }
2047
2088
  return batchFromColumns(columns, a.schema);
2048
2089
  }
@@ -2064,8 +2105,8 @@ function validateProjectionIds(caller, projectionIds, fieldCount) {
2064
2105
  }
2065
2106
  return projectionIds.filter((i) => i >= 0 && i < fieldCount);
2066
2107
  }
2067
- function projectSchema(projectionIds, schema2) {
2068
- const a = schema2;
2108
+ function projectSchema(projectionIds, schema) {
2109
+ const a = schema;
2069
2110
  if (!projectionIds)
2070
2111
  return a;
2071
2112
  const validIds = validateProjectionIds("projectSchema", projectionIds, a.fields.length);
@@ -2106,9 +2147,9 @@ import {
2106
2147
  RecordBatchStreamWriter,
2107
2148
  RecordBatchReader
2108
2149
  } from "@query-farm/apache-arrow";
2109
- function serializeSchema(schema2) {
2150
+ function serializeSchema(schema) {
2110
2151
  const writer = new RecordBatchStreamWriter;
2111
- writer.reset(undefined, schema2);
2152
+ writer.reset(undefined, schema);
2112
2153
  writer.close();
2113
2154
  return writer.toUint8Array(true);
2114
2155
  }
@@ -2176,20 +2217,20 @@ function buildTypedColumnData(values, type) {
2176
2217
  function buildStatisticsBatch(stats) {
2177
2218
  if (stats.length === 0) {
2178
2219
  const nullField = new Field3("0", new Null, true);
2179
- const unionType2 = new SparseUnion([0], [nullField]);
2180
- const minData2 = makeData5({
2181
- type: unionType2,
2220
+ const unionType = new SparseUnion([0], [nullField]);
2221
+ const minData = makeData5({
2222
+ type: unionType,
2182
2223
  length: 0,
2183
2224
  typeIds: new Int8Array(0),
2184
2225
  children: [makeData5({ type: new Null, length: 0, nullCount: 0 })]
2185
2226
  });
2186
- const maxData2 = makeData5({
2187
- type: unionType2,
2227
+ const maxData = makeData5({
2228
+ type: unionType,
2188
2229
  length: 0,
2189
2230
  typeIds: new Int8Array(0),
2190
2231
  children: [makeData5({ type: new Null, length: 0, nullCount: 0 })]
2191
2232
  });
2192
- return assemble([], minData2, maxData2, [], [], [], [], [], unionType2);
2233
+ return assemble([], minData, maxData, [], [], [], [], [], unionType);
2193
2234
  }
2194
2235
  const typeOrder = [];
2195
2236
  const typeIdMap = new Map;
@@ -2233,7 +2274,7 @@ function buildStatisticsBatch(stats) {
2233
2274
  return assemble(stats.map((s) => s.columnName), minData, maxData, stats.map((s) => s.hasNull), stats.map((s) => s.hasNotNull), stats.map((s) => s.distinctCount == null ? null : BigInt(s.distinctCount)), stats.map((s) => s.containsUnicode), stats.map((s) => s.maxStringLength == null ? null : BigInt(s.maxStringLength)), unionType);
2234
2275
  }
2235
2276
  function assemble(columnNames, minData, maxData, hasNull, hasNotNull, distinctCount, containsUnicode, maxStringLength, unionType) {
2236
- const schema2 = new Schema5([
2277
+ const schema = new Schema5([
2237
2278
  new Field3("column_name", new Utf8, false),
2238
2279
  new Field3("min", unionType, true),
2239
2280
  new Field3("max", unionType, true),
@@ -2254,9 +2295,9 @@ function assemble(columnNames, minData, maxData, hasNull, hasNotNull, distinctCo
2254
2295
  buildTypedColumnData(containsUnicode, new Bool),
2255
2296
  buildTypedColumnData(maxStringLength, new Uint64)
2256
2297
  ];
2257
- const structType = new Struct5(schema2.fields);
2298
+ const structType = new Struct5(schema.fields);
2258
2299
  const data = makeData5({ type: structType, length: n, children, nullCount: 0 });
2259
- return new RecordBatch6(schema2, data);
2300
+ return new RecordBatch6(schema, data);
2260
2301
  }
2261
2302
 
2262
2303
  // src/arrow/impl-arrowjs/index.ts
@@ -2274,9 +2315,11 @@ var bool2 = () => bool();
2274
2315
  var int162 = () => int16();
2275
2316
  var int322 = () => int32();
2276
2317
  var int642 = () => int64();
2318
+ var uint642 = () => uint64();
2277
2319
  var float642 = () => float64();
2278
2320
  var utf82 = () => utf8();
2279
2321
  var binary2 = () => binary();
2322
+ var largeBinary2 = () => largeBinary();
2280
2323
  var UNIT_TO_TAG = {
2281
2324
  [TimeUnit.SECOND]: "s",
2282
2325
  [TimeUnit.MILLISECOND]: "ms",
@@ -2324,6 +2367,27 @@ var EXCHANGE_STATE_SCHEMA = schema2([
2324
2367
  ]);
2325
2368
  var TEXT_ENCODER = new TextEncoder;
2326
2369
  var TEXT_DECODER = new TextDecoder;
2370
+ var LIST_CHILD_NAME = "item";
2371
+ var emptyListElementType = () => utf82();
2372
+ function inferElementType(values) {
2373
+ let elementType = null;
2374
+ let elementSig = "";
2375
+ for (const v of values) {
2376
+ if (v === null || v === undefined)
2377
+ continue;
2378
+ const t = inferFieldType(v);
2379
+ const sig = typeSignature(t);
2380
+ if (elementType === null) {
2381
+ elementType = t;
2382
+ elementSig = sig;
2383
+ continue;
2384
+ }
2385
+ if (sig !== elementSig) {
2386
+ throw new Error(`inferFieldType: arrays in userState must be homogeneous; ` + `found both '${elementSig}' and '${sig}' in the same array ` + `(split the values into separate fields, or normalize them to one type)`);
2387
+ }
2388
+ }
2389
+ return elementType ?? emptyListElementType();
2390
+ }
2327
2391
  function inferFieldType(value) {
2328
2392
  if (value === null || value === undefined)
2329
2393
  return nullType2();
@@ -2342,7 +2406,7 @@ function inferFieldType(value) {
2342
2406
  if (ArrayBuffer.isView(value))
2343
2407
  return binary2();
2344
2408
  if (Array.isArray(value)) {
2345
- throw new Error(`inferFieldType: arrays are not supported in userState (convert to a serializable form first)`);
2409
+ return list2(field2(LIST_CHILD_NAME, inferElementType(value), true));
2346
2410
  }
2347
2411
  if (value instanceof Map) {
2348
2412
  throw new Error(`inferFieldType: Map is not supported in userState (use a plain object instead)`);
@@ -2583,10 +2647,19 @@ function toUint8Array2(val) {
2583
2647
  }
2584
2648
 
2585
2649
  // src/protocol/serializers/bind.ts
2650
+ var COPY_FROM_STRUCT_TYPE = struct2([
2651
+ field2("format", utf82(), false),
2652
+ field2("file_path", utf82(), false),
2653
+ field2("expected_schema", binary2(), false)
2654
+ ]);
2655
+ var COPY_TO_STRUCT_TYPE = struct2([
2656
+ field2("format", utf82(), false),
2657
+ field2("file_path", utf82(), false)
2658
+ ]);
2586
2659
  var BIND_REQUEST_SCHEMA = schema2([
2587
2660
  field2("function_name", utf82(), false),
2588
2661
  field2("arguments", binary2(), false),
2589
- field2("function_type", utf82(), false),
2662
+ field2("function_type", dictionary2(utf82(), int162()), false),
2590
2663
  field2("input_schema", binary2(), true),
2591
2664
  field2("settings", binary2(), true),
2592
2665
  field2("secrets", binary2(), true),
@@ -2595,25 +2668,10 @@ var BIND_REQUEST_SCHEMA = schema2([
2595
2668
  field2("resolved_secrets_provided", bool2(), false),
2596
2669
  field2("at_unit", utf82(), true),
2597
2670
  field2("at_value", utf82(), true),
2598
- field2("schema_name", utf82(), true)
2599
- ]);
2600
- var COPY_FROM_STRUCT_TYPE = struct2([
2601
- field2("format", utf82(), false),
2602
- field2("file_path", utf82(), false),
2603
- field2("expected_schema", binary2(), false)
2604
- ]);
2605
- var COPY_FROM_FIELD = field2("copy_from", COPY_FROM_STRUCT_TYPE, true);
2606
- var COPY_TO_STRUCT_TYPE = struct2([
2607
- field2("format", utf82(), false),
2608
- field2("file_path", utf82(), false)
2609
- ]);
2610
- var COPY_TO_FIELD = field2("copy_to", COPY_TO_STRUCT_TYPE, true);
2611
- var BIND_RESPONSE_SCHEMA = schema2([
2612
- field2("output_schema", binary2(), false),
2613
- field2("opaque_data", binary2(), true),
2614
- field2("lookup_secret_types", list2(field2("item", utf82(), true)), false),
2615
- field2("lookup_scopes", list2(field2("item", utf82(), true)), false),
2616
- field2("lookup_names", list2(field2("item", utf82(), true)), false)
2671
+ field2("copy_from", COPY_FROM_STRUCT_TYPE, true),
2672
+ field2("copy_to", COPY_TO_STRUCT_TYPE, true),
2673
+ field2("schema_path", list2(field2("item", utf82(), true)), true),
2674
+ field2("argument_names", list2(field2("item", utf82(), true)), true)
2617
2675
  ]);
2618
2676
  function parseCopyFromContext(raw) {
2619
2677
  if (raw == null)
@@ -2665,7 +2723,8 @@ function deserializeBindRequest(params) {
2665
2723
  resolved_secrets_provided: params.resolved_secrets_provided ?? false,
2666
2724
  at_unit: params.at_unit ? String(params.at_unit) : null,
2667
2725
  at_value: params.at_value ? String(params.at_value) : null,
2668
- schema_name: params.schema_name ? String(params.schema_name) : null,
2726
+ schema_path: params.schema_path ? (Array.isArray(params.schema_path) ? params.schema_path : [...params.schema_path]).map(String) : null,
2727
+ argument_names: params.argument_names ? (Array.isArray(params.argument_names) ? params.argument_names : [...params.argument_names]).map((value) => value == null ? null : String(value)) : null,
2669
2728
  copy_from: parseCopyFromContext(params.copy_from),
2670
2729
  copy_to: parseCopyToContext(params.copy_to)
2671
2730
  };
@@ -2684,20 +2743,22 @@ var INIT_REQUEST_SCHEMA = schema2([
2684
2743
  field2("bind_call", binary2(), false),
2685
2744
  field2("output_schema", binary2(), false),
2686
2745
  field2("bind_opaque_data", binary2(), true),
2687
- field2("projection_ids", list2(field2("item", int642(), false)), true),
2688
- field2("pushdown_filters", binary2(), true),
2689
- field2("join_keys", list2(field2("item", binary2(), true)), false),
2690
- field2("phase", utf82(), true),
2746
+ field2("projection_ids", list2(field2("item", int642(), true)), true),
2747
+ field2("pushdown_filters", largeBinary2(), true),
2748
+ field2("join_keys", list2(field2("item", largeBinary2(), true)), true),
2749
+ field2("split_tokens", list2(field2("item", largeBinary2(), true)), true),
2750
+ field2("row_limit", int642(), true),
2751
+ field2("phase", dictionary2(utf82(), int162()), true),
2752
+ field2("finalize_state_id", binary2(), true),
2691
2753
  field2("execution_id", binary2(), true),
2692
2754
  field2("init_opaque_data", binary2(), true),
2693
2755
  field2("substream_id", binary2(), true),
2694
2756
  field2("order_by_column_name", utf82(), true),
2695
- field2("order_by_direction", utf82(), true),
2696
- field2("order_by_null_order", utf82(), true),
2757
+ field2("order_by_direction", dictionary2(utf82(), int162()), true),
2758
+ field2("order_by_null_order", dictionary2(utf82(), int162()), true),
2697
2759
  field2("order_by_limit", int642(), true),
2698
2760
  field2("tablesample_percentage", float642(), true),
2699
- field2("tablesample_seed", int642(), true),
2700
- field2("finalize_state_id", binary2(), true)
2761
+ field2("tablesample_seed", int642(), true)
2701
2762
  ]);
2702
2763
  var GLOBAL_INIT_RESPONSE_SCHEMA = schema2([
2703
2764
  field2("execution_id", binary2(), false),
@@ -2749,10 +2810,19 @@ function deserializeInitRequest(params) {
2749
2810
  output_schema: deserializeSchema(toUint8Array2(params.output_schema)),
2750
2811
  bind_opaque_data: params.bind_opaque_data ? toUint8Array2(params.bind_opaque_data) : null,
2751
2812
  projection_ids: projectionIds,
2813
+ row_limit: params.row_limit == null ? null : Number(params.row_limit),
2752
2814
  pushdown_filters: params.pushdown_filters ? deserializeBatch(toUint8Array2(params.pushdown_filters)) : null,
2753
2815
  join_keys: joinKeys,
2754
2816
  phase,
2755
2817
  finalize_state_id: params.finalize_state_id ? toUint8Array2(params.finalize_state_id) : null,
2818
+ split_tokens: (() => {
2819
+ const raw = params.split_tokens;
2820
+ if (raw == null)
2821
+ return null;
2822
+ const iter = Array.isArray(raw) ? raw : typeof raw[Symbol.iterator] === "function" ? raw : [];
2823
+ const tokens = [...iter].filter((e) => e != null).map((e) => toUint8Array2(e));
2824
+ return tokens.length > 0 ? tokens : null;
2825
+ })(),
2756
2826
  execution_id: params.execution_id ? toUint8Array2(params.execution_id) : null,
2757
2827
  init_opaque_data: params.init_opaque_data ? toUint8Array2(params.init_opaque_data) : null,
2758
2828
  substream_id: params.substream_id ? toUint8Array2(params.substream_id) : null,
@@ -2820,10 +2890,6 @@ function serializeGlobalInitResponse(resp) {
2820
2890
  };
2821
2891
  }
2822
2892
  // src/protocol/serializers/cardinality.ts
2823
- var TABLE_CARDINALITY_SCHEMA = schema2([
2824
- field2("estimate", int642(), true),
2825
- field2("max", int642(), true)
2826
- ]);
2827
2893
  var TABLE_FUNCTION_CARDINALITY_REQUEST_SCHEMA = schema2([
2828
2894
  field2("bind_call", binary2(), false),
2829
2895
  field2("bind_opaque_data", binary2(), true)
@@ -2855,21 +2921,21 @@ var CatalogInfoSchema = schema2([
2855
2921
  field2("implementation_version", utf82(), true),
2856
2922
  field2("data_version_spec", utf82(), true),
2857
2923
  field2("attach_option_specs", list2(field2("item", binary2(), true)), false),
2858
- field2("releases", list2(field2("item", struct2([field2("version", utf82(), false), field2("released_at", timestamp2(TimeUnit2.MICROSECOND, "UTC"), false), field2("summary", utf82(), false), field2("notes_url", utf82(), true)]), true)), false),
2924
+ field2("releases", list2(field2("item", struct2([field2("version", utf82(), false), field2("released_at", timestamp2(TimeUnit2.MICROSECOND, "UTC"), true), field2("summary", utf82(), false), field2("notes_url", utf82(), true)]), true)), false),
2859
2925
  field2("source_url", utf82(), true)
2860
2926
  ]);
2861
2927
  var SchemaInfoSchema = schema2([
2862
2928
  field2("comment", utf82(), true),
2863
2929
  field2("tags", map2(field2("key", utf82(), false), field2("value", utf82(), true), false), false),
2864
2930
  field2("attach_opaque_data", binary2(), false),
2865
- field2("name", utf82(), false),
2931
+ field2("path", list2(field2("item", utf82(), true)), false),
2866
2932
  field2("estimated_object_count", map2(field2("key", utf82(), false), field2("value", int642(), true), false), true)
2867
2933
  ]);
2868
2934
  var TableInfoSchema = schema2([
2869
2935
  field2("comment", utf82(), true),
2870
2936
  field2("tags", map2(field2("key", utf82(), false), field2("value", utf82(), true), false), false),
2871
2937
  field2("name", utf82(), false),
2872
- field2("schema_name", utf82(), false),
2938
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
2873
2939
  field2("columns", binary2(), false),
2874
2940
  field2("not_null_constraints", list2(field2("item", int322(), true)), false),
2875
2941
  field2("unique_constraints", list2(field2("item", list2(field2("item", int322(), true)), true)), false),
@@ -2881,21 +2947,21 @@ var TableInfoSchema = schema2([
2881
2947
  field2("supports_delete", bool2(), false),
2882
2948
  field2("supports_returning", bool2(), false),
2883
2949
  field2("supports_column_statistics", bool2(), false),
2884
- field2("scan_function", binary2(), false),
2885
- field2("insert_function", binary2(), false),
2886
- field2("update_function", binary2(), false),
2887
- field2("delete_function", binary2(), false),
2888
- field2("cardinality_estimate", int642(), false),
2889
- field2("cardinality_max", int642(), false),
2890
- field2("column_statistics", binary2(), false),
2891
- field2("bind_result", binary2(), false),
2950
+ field2("scan_function", binary2(), true),
2951
+ field2("insert_function", binary2(), true),
2952
+ field2("update_function", binary2(), true),
2953
+ field2("delete_function", binary2(), true),
2954
+ field2("cardinality_estimate", int642(), true),
2955
+ field2("cardinality_max", int642(), true),
2956
+ field2("column_statistics", binary2(), true),
2957
+ field2("bind_result", binary2(), true),
2892
2958
  field2("required_filters", list2(field2("item", list2(field2("item", utf82(), true)), true)), false)
2893
2959
  ]);
2894
2960
  var ViewInfoSchema = schema2([
2895
2961
  field2("comment", utf82(), true),
2896
2962
  field2("tags", map2(field2("key", utf82(), false), field2("value", utf82(), true), false), false),
2897
2963
  field2("name", utf82(), false),
2898
- field2("schema_name", utf82(), false),
2964
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
2899
2965
  field2("definition", utf82(), false),
2900
2966
  field2("column_comments", map2(field2("key", utf82(), false), field2("value", utf82(), true), false), false)
2901
2967
  ]);
@@ -2903,12 +2969,14 @@ var FunctionInfoSchema = schema2([
2903
2969
  field2("comment", utf82(), true),
2904
2970
  field2("tags", map2(field2("key", utf82(), false), field2("value", utf82(), true), false), false),
2905
2971
  field2("name", utf82(), false),
2906
- field2("schema_name", utf82(), false),
2972
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
2907
2973
  field2("function_type", dictionary2(utf82(), int162()), false),
2908
2974
  field2("arguments", binary2(), false),
2909
2975
  field2("output_schema", binary2(), false),
2976
+ field2("parameter_default_values", binary2(), true),
2910
2977
  field2("stability", dictionary2(utf82(), int162()), true),
2911
2978
  field2("null_handling", dictionary2(utf82(), int162()), true),
2979
+ field2("argument_monotonicity", list2(field2("item", utf82(), true)), true),
2912
2980
  field2("description", utf82(), false),
2913
2981
  field2("examples", list2(field2("item", struct2([field2("sql", utf82(), false), field2("description", utf82(), false), field2("expected_output", utf82(), true)]), true)), false),
2914
2982
  field2("categories", list2(field2("item", utf82(), true)), false),
@@ -2916,10 +2984,17 @@ var FunctionInfoSchema = schema2([
2916
2984
  field2("filter_pushdown", bool2(), true),
2917
2985
  field2("sampling_pushdown", bool2(), true),
2918
2986
  field2("late_materialization", bool2(), true),
2919
- field2("supported_expression_filters", list2(field2("item", utf82(), true)), false),
2987
+ field2("filter_semantic_profiles", list2(field2("item", utf82(), true)), false),
2988
+ field2("additional_filter_functions", list2(field2("item", struct2([field2("namespace", utf82(), false), field2("name", utf82(), false), field2("version", uint642(), false)]), true)), false),
2989
+ field2("runtime_filter_algorithms", list2(field2("item", struct2([field2("namespace", utf82(), false), field2("name", utf82(), false), field2("version", uint642(), false)]), true)), false),
2990
+ field2("filter_evaluation_contexts", list2(field2("item", struct2([field2("profile", utf82(), false), field2("provider_fingerprint", utf82(), true)]), true)), false),
2920
2991
  field2("order_preservation", dictionary2(utf82(), int162()), true),
2921
- field2("max_workers", int322(), false),
2992
+ field2("max_workers", int322(), true),
2922
2993
  field2("supports_batch_index", bool2(), false),
2994
+ field2("supports_splits", bool2(), false),
2995
+ field2("filters_exactly_applied", bool2(), false),
2996
+ field2("supports_positions", bool2(), false),
2997
+ field2("split_token_ttl_seconds", int642(), true),
2923
2998
  field2("partition_kind", dictionary2(utf82(), int162()), false),
2924
2999
  field2("order_dependent", dictionary2(utf82(), int162()), false),
2925
3000
  field2("distinct_dependent", dictionary2(utf82(), int162()), false),
@@ -2937,18 +3012,18 @@ var MacroInfoSchema = schema2([
2937
3012
  field2("comment", utf82(), true),
2938
3013
  field2("tags", map2(field2("key", utf82(), false), field2("value", utf82(), true), false), false),
2939
3014
  field2("name", utf82(), false),
2940
- field2("schema_name", utf82(), false),
3015
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
2941
3016
  field2("macro_type", dictionary2(utf82(), int162()), false),
2942
3017
  field2("parameters", list2(field2("item", utf82(), true)), false),
2943
- field2("parameter_default_values", binary2(), false),
3018
+ field2("parameter_default_values", binary2(), true),
2944
3019
  field2("definition", utf82(), false),
2945
- field2("arguments_schema", binary2(), false)
3020
+ field2("arguments_schema", binary2(), true)
2946
3021
  ]);
2947
3022
  var IndexInfoSchema = schema2([
2948
3023
  field2("comment", utf82(), true),
2949
3024
  field2("tags", map2(field2("key", utf82(), false), field2("value", utf82(), true), false), false),
2950
3025
  field2("name", utf82(), false),
2951
- field2("schema_name", utf82(), false),
3026
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
2952
3027
  field2("table_name", utf82(), false),
2953
3028
  field2("index_type", utf82(), false),
2954
3029
  field2("constraint_type", dictionary2(utf82(), int162()), false),
@@ -2968,7 +3043,8 @@ var CopyFromFormatInfoSchema = schema2([
2968
3043
  var ScanFunctionResultSchema = schema2([
2969
3044
  field2("function_name", utf82(), false),
2970
3045
  field2("arguments", binary2(), false),
2971
- field2("required_extensions", list2(field2("item", utf82(), true)), false)
3046
+ field2("required_extensions", list2(field2("item", utf82(), true)), false),
3047
+ field2("schema_path", list2(field2("item", utf82(), true)), true)
2972
3048
  ]);
2973
3049
  var ScanBranchesResultSchema = schema2([
2974
3050
  field2("branches", list2(field2("item", binary2(), true)), false),
@@ -2980,8 +3056,24 @@ var ScanBranchSchema = schema2([
2980
3056
  field2("branch_filter", utf82(), true),
2981
3057
  field2("writable", bool2(), false),
2982
3058
  field2("source_catalog", utf82(), true),
2983
- field2("source_schema", utf82(), true),
2984
- field2("source_table", utf82(), true)
3059
+ field2("source_schema_path", list2(field2("item", utf82(), true)), true),
3060
+ field2("source_table", utf82(), true),
3061
+ field2("format_name", utf82(), true),
3062
+ field2("format_locations", list2(field2("item", utf82(), true)), true),
3063
+ field2("format_options", binary2(), true),
3064
+ field2("schema_path", list2(field2("item", utf82(), true)), true)
3065
+ ]);
3066
+ var ScanSplitSchema = schema2([
3067
+ field2("payload", binary2(), false),
3068
+ field2("token", binary2(), false),
3069
+ field2("estimated_rows", int642(), true),
3070
+ field2("rows_exact", bool2(), false),
3071
+ field2("estimated_bytes", int642(), true),
3072
+ field2("partition_bounds", binary2(), true),
3073
+ field2("column_statistics", binary2(), true),
3074
+ field2("location_ids", list2(field2("item", int642(), true)), true),
3075
+ field2("start_position", binary2(), true),
3076
+ field2("end_position", binary2(), true)
2985
3077
  ]);
2986
3078
  var AttachCatalogInfoSchema = schema2([
2987
3079
  field2("alias", utf82(), false),
@@ -2992,6 +3084,285 @@ var AttachCatalogInfoSchema = schema2([
2992
3084
  field2("required", bool2(), false),
2993
3085
  field2("secret_ref", utf82(), false)
2994
3086
  ]);
3087
+ var ForeignKeyInfoSchema = schema2([
3088
+ field2("fk_columns", list2(field2("item", utf82(), true)), false),
3089
+ field2("pk_columns", list2(field2("item", utf82(), true)), false),
3090
+ field2("referenced_table", utf82(), false),
3091
+ field2("referenced_schema_path", list2(field2("item", utf82(), true)), false)
3092
+ ]);
3093
+ var AggregateBindRequestSchema = schema2([
3094
+ field2("function_name", utf82(), false),
3095
+ field2("arguments", binary2(), false),
3096
+ field2("input_schema", binary2(), true),
3097
+ field2("settings", binary2(), true),
3098
+ field2("secrets", binary2(), true),
3099
+ field2("attach_opaque_data", binary2(), true),
3100
+ field2("schema_path", list2(field2("item", utf82(), true)), true),
3101
+ field2("argument_names", list2(field2("item", utf82(), true)), true)
3102
+ ]);
3103
+ var AggregateCombineRequestSchema = schema2([
3104
+ field2("function_name", utf82(), false),
3105
+ field2("execution_id", binary2(), false),
3106
+ field2("merge_batch", binary2(), false),
3107
+ field2("attach_opaque_data", binary2(), true),
3108
+ field2("schema_path", list2(field2("item", utf82(), true)), true)
3109
+ ]);
3110
+ var AggregateDestructorRequestSchema = schema2([
3111
+ field2("function_name", utf82(), false),
3112
+ field2("execution_id", binary2(), false),
3113
+ field2("group_ids_batch", binary2(), false),
3114
+ field2("attach_opaque_data", binary2(), true),
3115
+ field2("schema_path", list2(field2("item", utf82(), true)), true)
3116
+ ]);
3117
+ var AggregateFinalizeRequestSchema = schema2([
3118
+ field2("function_name", utf82(), false),
3119
+ field2("execution_id", binary2(), false),
3120
+ field2("group_ids_batch", binary2(), false),
3121
+ field2("output_schema", binary2(), false),
3122
+ field2("attach_opaque_data", binary2(), true),
3123
+ field2("schema_path", list2(field2("item", utf82(), true)), true)
3124
+ ]);
3125
+ var AggregateStreamingChunkRequestSchema = schema2([
3126
+ field2("function_name", utf82(), false),
3127
+ field2("execution_id", binary2(), false),
3128
+ field2("input_batch", binary2(), false),
3129
+ field2("attach_opaque_data", binary2(), true),
3130
+ field2("schema_path", list2(field2("item", utf82(), true)), true)
3131
+ ]);
3132
+ var AggregateStreamingCloseRequestSchema = schema2([
3133
+ field2("function_name", utf82(), false),
3134
+ field2("execution_id", binary2(), false),
3135
+ field2("attach_opaque_data", binary2(), true),
3136
+ field2("schema_path", list2(field2("item", utf82(), true)), true)
3137
+ ]);
3138
+ var AggregateStreamingOpenRequestSchema = schema2([
3139
+ field2("function_name", utf82(), false),
3140
+ field2("arguments", binary2(), false),
3141
+ field2("input_schema", binary2(), false),
3142
+ field2("partition_key_count", int642(), false),
3143
+ field2("order_key_count", int642(), false),
3144
+ field2("output_schema", binary2(), false),
3145
+ field2("settings", binary2(), true),
3146
+ field2("secrets", binary2(), true),
3147
+ field2("attach_opaque_data", binary2(), true),
3148
+ field2("schema_path", list2(field2("item", utf82(), true)), true)
3149
+ ]);
3150
+ var AggregateUpdateRequestSchema = schema2([
3151
+ field2("function_name", utf82(), false),
3152
+ field2("execution_id", binary2(), false),
3153
+ field2("input_batch", binary2(), false),
3154
+ field2("attach_opaque_data", binary2(), true),
3155
+ field2("schema_path", list2(field2("item", utf82(), true)), true)
3156
+ ]);
3157
+ var AggregateWindowBatchRequestSchema = schema2([
3158
+ field2("function_name", utf82(), false),
3159
+ field2("execution_id", binary2(), false),
3160
+ field2("partition_id", int642(), false),
3161
+ field2("row_idx", int642(), false),
3162
+ field2("count", int642(), false),
3163
+ field2("frames_per_row", list2(field2("item", int642(), true)), false),
3164
+ field2("frame_starts", list2(field2("item", int642(), true)), false),
3165
+ field2("frame_ends", list2(field2("item", int642(), true)), false),
3166
+ field2("attach_opaque_data", binary2(), true),
3167
+ field2("schema_path", list2(field2("item", utf82(), true)), true)
3168
+ ]);
3169
+ var AggregateWindowDestructorRequestSchema = schema2([
3170
+ field2("function_name", utf82(), false),
3171
+ field2("execution_id", binary2(), false),
3172
+ field2("partition_id", int642(), false),
3173
+ field2("attach_opaque_data", binary2(), true),
3174
+ field2("schema_path", list2(field2("item", utf82(), true)), true)
3175
+ ]);
3176
+ var AggregateWindowInitRequestSchema = schema2([
3177
+ field2("function_name", utf82(), false),
3178
+ field2("execution_id", binary2(), false),
3179
+ field2("partition_id", int642(), false),
3180
+ field2("row_count", int642(), false),
3181
+ field2("partition_batch", binary2(), false),
3182
+ field2("output_schema", binary2(), false),
3183
+ field2("filter_mask", binary2(), false),
3184
+ field2("frame_stats", binary2(), false),
3185
+ field2("all_valid", binary2(), false),
3186
+ field2("attach_opaque_data", binary2(), true),
3187
+ field2("schema_path", list2(field2("item", utf82(), true)), true)
3188
+ ]);
3189
+ var AggregateWindowRequestSchema = schema2([
3190
+ field2("function_name", utf82(), false),
3191
+ field2("execution_id", binary2(), false),
3192
+ field2("partition_id", int642(), false),
3193
+ field2("rid", int642(), false),
3194
+ field2("frame_starts", list2(field2("item", int642(), true)), false),
3195
+ field2("frame_ends", list2(field2("item", int642(), true)), false),
3196
+ field2("attach_opaque_data", binary2(), true),
3197
+ field2("schema_path", list2(field2("item", utf82(), true)), true)
3198
+ ]);
3199
+ var BindRequestSchema = schema2([
3200
+ field2("function_name", utf82(), false),
3201
+ field2("arguments", binary2(), false),
3202
+ field2("function_type", dictionary2(utf82(), int162()), false),
3203
+ field2("input_schema", binary2(), true),
3204
+ field2("settings", binary2(), true),
3205
+ field2("secrets", binary2(), true),
3206
+ field2("attach_opaque_data", binary2(), true),
3207
+ field2("transaction_opaque_data", binary2(), true),
3208
+ field2("resolved_secrets_provided", bool2(), false),
3209
+ field2("at_unit", utf82(), true),
3210
+ field2("at_value", utf82(), true),
3211
+ field2("copy_from", struct2([field2("format", utf82(), false), field2("file_path", utf82(), false), field2("expected_schema", binary2(), false)]), true),
3212
+ field2("copy_to", struct2([field2("format", utf82(), false), field2("file_path", utf82(), false)]), true),
3213
+ field2("schema_path", list2(field2("item", utf82(), true)), true),
3214
+ field2("argument_names", list2(field2("item", utf82(), true)), true)
3215
+ ]);
3216
+ var CatalogAttachRequestSchema = schema2([
3217
+ field2("name", utf82(), false),
3218
+ field2("options", binary2(), true),
3219
+ field2("data_version_spec", utf82(), true),
3220
+ field2("implementation_version", utf82(), true),
3221
+ field2("client_capabilities", binary2(), true)
3222
+ ]);
3223
+ var CatalogCreateRequestSchema = schema2([
3224
+ field2("name", utf82(), false),
3225
+ field2("on_conflict", dictionary2(utf82(), int162()), false),
3226
+ field2("options", binary2(), true)
3227
+ ]);
3228
+ var ClientCapabilitiesSchema = schema2([
3229
+ field2("engine", utf82(), false),
3230
+ field2("native_formats", list2(field2("item", utf82(), true)), false),
3231
+ field2("catalogs", list2(field2("item", utf82(), true)), false),
3232
+ field2("can_stream", bool2(), false),
3233
+ field2("filter_encodings", list2(field2("item", utf82(), true)), false)
3234
+ ]);
3235
+ var CopyFromContextSchema = schema2([
3236
+ field2("format", utf82(), false),
3237
+ field2("file_path", utf82(), false),
3238
+ field2("expected_schema", binary2(), false)
3239
+ ]);
3240
+ var CopyToContextSchema = schema2([
3241
+ field2("format", utf82(), false),
3242
+ field2("file_path", utf82(), false)
3243
+ ]);
3244
+ var GlobalInitResponseSchema = schema2([
3245
+ field2("execution_id", binary2(), false),
3246
+ field2("opaque_data", binary2(), true),
3247
+ field2("max_workers", int642(), false)
3248
+ ]);
3249
+ var IndexCreateRequestSchema = schema2([
3250
+ field2("attach_opaque_data", binary2(), false),
3251
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
3252
+ field2("name", utf82(), false),
3253
+ field2("table_name", utf82(), false),
3254
+ field2("index_type", utf82(), false),
3255
+ field2("constraint_type", dictionary2(utf82(), int162()), false),
3256
+ field2("expressions", list2(field2("item", utf82(), true)), false),
3257
+ field2("on_conflict", dictionary2(utf82(), int162()), false),
3258
+ field2("options", map2(field2("key", utf82(), false), field2("value", utf82(), true), false), false),
3259
+ field2("transaction_opaque_data", binary2(), true)
3260
+ ]);
3261
+ var InitRequestSchema = schema2([
3262
+ field2("bind_call", binary2(), false),
3263
+ field2("output_schema", binary2(), false),
3264
+ field2("bind_opaque_data", binary2(), true),
3265
+ field2("projection_ids", list2(field2("item", int642(), true)), true),
3266
+ field2("pushdown_filters", largeBinary2(), true),
3267
+ field2("join_keys", list2(field2("item", largeBinary2(), true)), true),
3268
+ field2("split_tokens", list2(field2("item", largeBinary2(), true)), true),
3269
+ field2("row_limit", int642(), true),
3270
+ field2("phase", dictionary2(utf82(), int162()), true),
3271
+ field2("finalize_state_id", binary2(), true),
3272
+ field2("execution_id", binary2(), true),
3273
+ field2("init_opaque_data", binary2(), true),
3274
+ field2("substream_id", binary2(), true),
3275
+ field2("order_by_column_name", utf82(), true),
3276
+ field2("order_by_direction", dictionary2(utf82(), int162()), true),
3277
+ field2("order_by_null_order", dictionary2(utf82(), int162()), true),
3278
+ field2("order_by_limit", int642(), true),
3279
+ field2("tablesample_percentage", float642(), true),
3280
+ field2("tablesample_seed", int642(), true)
3281
+ ]);
3282
+ var MacroCreateRequestSchema = schema2([
3283
+ field2("attach_opaque_data", binary2(), false),
3284
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
3285
+ field2("name", utf82(), false),
3286
+ field2("macro_type", dictionary2(utf82(), int162()), false),
3287
+ field2("parameters", list2(field2("item", utf82(), true)), false),
3288
+ field2("definition", utf82(), false),
3289
+ field2("on_conflict", dictionary2(utf82(), int162()), false),
3290
+ field2("parameter_default_values", binary2(), true),
3291
+ field2("arguments_schema", binary2(), true),
3292
+ field2("transaction_opaque_data", binary2(), true)
3293
+ ]);
3294
+ var TableCreateRequestSchema = schema2([
3295
+ field2("attach_opaque_data", binary2(), false),
3296
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
3297
+ field2("name", utf82(), false),
3298
+ field2("columns", binary2(), false),
3299
+ field2("on_conflict", dictionary2(utf82(), int162()), false),
3300
+ field2("not_null_constraints", list2(field2("item", int322(), true)), false),
3301
+ field2("unique_constraints", list2(field2("item", list2(field2("item", int322(), true)), true)), false),
3302
+ field2("check_constraints", list2(field2("item", utf82(), true)), false),
3303
+ field2("primary_key_constraints", list2(field2("item", list2(field2("item", int322(), true)), true)), false),
3304
+ field2("foreign_key_constraints", list2(field2("item", binary2(), true)), false),
3305
+ field2("transaction_opaque_data", binary2(), true)
3306
+ ]);
3307
+ var TableBufferingCombineRequestSchema = schema2([
3308
+ field2("function_name", utf82(), false),
3309
+ field2("execution_id", binary2(), false),
3310
+ field2("state_ids", list2(field2("item", binary2(), true)), false),
3311
+ field2("attach_opaque_data", binary2(), true),
3312
+ field2("transaction_id", binary2(), true),
3313
+ field2("schema_path", list2(field2("item", utf82(), true)), true)
3314
+ ]);
3315
+ var TableBufferingDestructorRequestSchema = schema2([
3316
+ field2("function_name", utf82(), false),
3317
+ field2("execution_id", binary2(), false),
3318
+ field2("attach_opaque_data", binary2(), true),
3319
+ field2("transaction_id", binary2(), true),
3320
+ field2("schema_path", list2(field2("item", utf82(), true)), true)
3321
+ ]);
3322
+ var TableBufferingProcessRequestSchema = schema2([
3323
+ field2("function_name", utf82(), false),
3324
+ field2("execution_id", binary2(), false),
3325
+ field2("input_batch", binary2(), false),
3326
+ field2("attach_opaque_data", binary2(), true),
3327
+ field2("transaction_id", binary2(), true),
3328
+ field2("batch_index", int642(), true),
3329
+ field2("schema_path", list2(field2("item", utf82(), true)), true)
3330
+ ]);
3331
+ var TableFunctionCardinalityRequestSchema = schema2([
3332
+ field2("bind_call", binary2(), false),
3333
+ field2("bind_opaque_data", binary2(), true)
3334
+ ]);
3335
+ var TableFunctionDynamicToStringRequestSchema = schema2([
3336
+ field2("bind_call", binary2(), false),
3337
+ field2("bind_opaque_data", binary2(), true),
3338
+ field2("global_execution_id", binary2(), false)
3339
+ ]);
3340
+ var TableFunctionPlanRequestSchema = schema2([
3341
+ field2("bind_call", binary2(), false),
3342
+ field2("bind_opaque_data", binary2(), true),
3343
+ field2("projection_ids", list2(field2("item", int642(), true)), true),
3344
+ field2("pushdown_filters", largeBinary2(), true),
3345
+ field2("join_keys", list2(field2("item", largeBinary2(), true)), true),
3346
+ field2("row_limit", int642(), true),
3347
+ field2("target_split_bytes", int642(), true),
3348
+ field2("min_splits", int642(), true),
3349
+ field2("max_splits_per_response", int642(), true),
3350
+ field2("cursor", binary2(), true),
3351
+ field2("refined_filters", largeBinary2(), true),
3352
+ field2("filters_complete", bool2(), false),
3353
+ field2("start_position", binary2(), true),
3354
+ field2("end_position", binary2(), true),
3355
+ field2("order_by_column_name", utf82(), true),
3356
+ field2("order_by_direction", dictionary2(utf82(), int162()), true),
3357
+ field2("order_by_null_order", dictionary2(utf82(), int162()), true),
3358
+ field2("order_by_limit", int642(), true),
3359
+ field2("tablesample_percentage", float642(), true),
3360
+ field2("tablesample_seed", int642(), true)
3361
+ ]);
3362
+ var TableFunctionStatisticsRequestSchema = schema2([
3363
+ field2("bind_call", binary2(), false),
3364
+ field2("bind_opaque_data", binary2(), true)
3365
+ ]);
2995
3366
  var AggregateBindResultSchema = schema2([
2996
3367
  field2("output_schema", binary2(), false),
2997
3368
  field2("execution_id", binary2(), false)
@@ -3019,7 +3390,7 @@ var AggregateWindowDestructorResultSchema = schema2([]);
3019
3390
  var AggregateWindowInitResultSchema = schema2([]);
3020
3391
  var BindResultSchema = schema2([
3021
3392
  field2("output_schema", binary2(), false),
3022
- field2("opaque_data", binary2(), false),
3393
+ field2("opaque_data", binary2(), true),
3023
3394
  field2("lookup_secret_types", list2(field2("item", utf82(), true)), false),
3024
3395
  field2("lookup_scopes", list2(field2("item", utf82(), true)), false),
3025
3396
  field2("lookup_names", list2(field2("item", utf82(), true)), false)
@@ -3103,6 +3474,24 @@ var TableFunctionDynamicToStringResultSchema = schema2([
3103
3474
  field2("keys", list2(field2("item", utf82(), true)), false),
3104
3475
  field2("values", list2(field2("item", utf82(), true)), false)
3105
3476
  ]);
3477
+ var TableFunctionPlanResultSchema = schema2([
3478
+ field2("splits", list2(field2("item", binary2(), true)), false),
3479
+ field2("next_cursors", list2(field2("item", binary2(), true)), true),
3480
+ field2("execution_id", binary2(), true),
3481
+ field2("init_opaque_data", binary2(), true),
3482
+ field2("max_workers", int642(), true),
3483
+ field2("estimated_total_splits", int642(), true),
3484
+ field2("estimated_total_rows", int642(), true),
3485
+ field2("estimated_total_bytes", int642(), true),
3486
+ field2("catalog_version", int642(), true),
3487
+ field2("scope", utf82(), false),
3488
+ field2("locations", list2(field2("item", utf82(), true)), true),
3489
+ field2("partitioning", list2(field2("item", binary2(), true)), true),
3490
+ field2("sort_order", list2(field2("item", binary2(), true)), true),
3491
+ field2("cache_max_age_seconds", int642(), true),
3492
+ field2("start_position", binary2(), true),
3493
+ field2("end_position", binary2(), true)
3494
+ ]);
3106
3495
  var AggregateBindParamsSchema = schema2([
3107
3496
  field2("request", binary2(), false)
3108
3497
  ]);
@@ -3164,7 +3553,7 @@ var CatalogIndexCreateParamsSchema = schema2([
3164
3553
  ]);
3165
3554
  var CatalogIndexDropParamsSchema = schema2([
3166
3555
  field2("attach_opaque_data", binary2(), false),
3167
- field2("schema_name", utf82(), false),
3556
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
3168
3557
  field2("name", utf82(), false),
3169
3558
  field2("ignore_not_found", bool2(), false),
3170
3559
  field2("cascade", bool2(), false),
@@ -3172,7 +3561,7 @@ var CatalogIndexDropParamsSchema = schema2([
3172
3561
  ]);
3173
3562
  var CatalogIndexGetParamsSchema = schema2([
3174
3563
  field2("attach_opaque_data", binary2(), false),
3175
- field2("schema_name", utf82(), false),
3564
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
3176
3565
  field2("name", utf82(), false),
3177
3566
  field2("transaction_opaque_data", binary2(), true)
3178
3567
  ]);
@@ -3181,47 +3570,47 @@ var CatalogMacroCreateParamsSchema = schema2([
3181
3570
  ]);
3182
3571
  var CatalogMacroDropParamsSchema = schema2([
3183
3572
  field2("attach_opaque_data", binary2(), false),
3184
- field2("schema_name", utf82(), false),
3573
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
3185
3574
  field2("name", utf82(), false),
3186
3575
  field2("ignore_not_found", bool2(), false),
3187
3576
  field2("transaction_opaque_data", binary2(), true)
3188
3577
  ]);
3189
3578
  var CatalogMacroGetParamsSchema = schema2([
3190
3579
  field2("attach_opaque_data", binary2(), false),
3191
- field2("schema_name", utf82(), false),
3580
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
3192
3581
  field2("name", utf82(), false),
3193
3582
  field2("transaction_opaque_data", binary2(), true)
3194
3583
  ]);
3195
3584
  var CatalogSchemaContentsFunctionsParamsSchema = schema2([
3196
3585
  field2("attach_opaque_data", binary2(), false),
3197
- field2("name", utf82(), false),
3586
+ field2("path", list2(field2("item", utf82(), true)), false),
3198
3587
  field2("type", dictionary2(utf82(), int162()), false),
3199
3588
  field2("transaction_opaque_data", binary2(), true)
3200
3589
  ]);
3201
3590
  var CatalogSchemaContentsIndexesParamsSchema = schema2([
3202
3591
  field2("attach_opaque_data", binary2(), false),
3203
- field2("name", utf82(), false),
3592
+ field2("path", list2(field2("item", utf82(), true)), false),
3204
3593
  field2("transaction_opaque_data", binary2(), true)
3205
3594
  ]);
3206
3595
  var CatalogSchemaContentsMacrosParamsSchema = schema2([
3207
3596
  field2("attach_opaque_data", binary2(), false),
3208
- field2("name", utf82(), false),
3597
+ field2("path", list2(field2("item", utf82(), true)), false),
3209
3598
  field2("type", dictionary2(utf82(), int162()), false),
3210
3599
  field2("transaction_opaque_data", binary2(), true)
3211
3600
  ]);
3212
3601
  var CatalogSchemaContentsTablesParamsSchema = schema2([
3213
3602
  field2("attach_opaque_data", binary2(), false),
3214
- field2("name", utf82(), false),
3603
+ field2("path", list2(field2("item", utf82(), true)), false),
3215
3604
  field2("transaction_opaque_data", binary2(), true)
3216
3605
  ]);
3217
3606
  var CatalogSchemaContentsViewsParamsSchema = schema2([
3218
3607
  field2("attach_opaque_data", binary2(), false),
3219
- field2("name", utf82(), false),
3608
+ field2("path", list2(field2("item", utf82(), true)), false),
3220
3609
  field2("transaction_opaque_data", binary2(), true)
3221
3610
  ]);
3222
3611
  var CatalogSchemaCreateParamsSchema = schema2([
3223
3612
  field2("attach_opaque_data", binary2(), false),
3224
- field2("name", utf82(), false),
3613
+ field2("path", list2(field2("item", utf82(), true)), false),
3225
3614
  field2("on_conflict", dictionary2(utf82(), int162()), false),
3226
3615
  field2("comment", utf82(), true),
3227
3616
  field2("tags", map2(field2("key", utf82(), false), field2("value", utf82(), true), false), true),
@@ -3229,14 +3618,14 @@ var CatalogSchemaCreateParamsSchema = schema2([
3229
3618
  ]);
3230
3619
  var CatalogSchemaDropParamsSchema = schema2([
3231
3620
  field2("attach_opaque_data", binary2(), false),
3232
- field2("name", utf82(), false),
3621
+ field2("path", list2(field2("item", utf82(), true)), false),
3233
3622
  field2("ignore_not_found", bool2(), false),
3234
3623
  field2("cascade", bool2(), false),
3235
3624
  field2("transaction_opaque_data", binary2(), true)
3236
3625
  ]);
3237
3626
  var CatalogSchemaGetParamsSchema = schema2([
3238
3627
  field2("attach_opaque_data", binary2(), false),
3239
- field2("name", utf82(), false),
3628
+ field2("path", list2(field2("item", utf82(), true)), false),
3240
3629
  field2("transaction_opaque_data", binary2(), true)
3241
3630
  ]);
3242
3631
  var CatalogSchemasParamsSchema = schema2([
@@ -3245,7 +3634,7 @@ var CatalogSchemasParamsSchema = schema2([
3245
3634
  ]);
3246
3635
  var CatalogTableColumnAddParamsSchema = schema2([
3247
3636
  field2("attach_opaque_data", binary2(), false),
3248
- field2("schema_name", utf82(), false),
3637
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
3249
3638
  field2("name", utf82(), false),
3250
3639
  field2("column_definition", binary2(), false),
3251
3640
  field2("ignore_not_found", bool2(), false),
@@ -3254,7 +3643,7 @@ var CatalogTableColumnAddParamsSchema = schema2([
3254
3643
  ]);
3255
3644
  var CatalogTableColumnCommentSetParamsSchema = schema2([
3256
3645
  field2("attach_opaque_data", binary2(), false),
3257
- field2("schema_name", utf82(), false),
3646
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
3258
3647
  field2("name", utf82(), false),
3259
3648
  field2("column_name", utf82(), false),
3260
3649
  field2("comment", utf82(), true),
@@ -3263,7 +3652,7 @@ var CatalogTableColumnCommentSetParamsSchema = schema2([
3263
3652
  ]);
3264
3653
  var CatalogTableColumnDefaultDropParamsSchema = schema2([
3265
3654
  field2("attach_opaque_data", binary2(), false),
3266
- field2("schema_name", utf82(), false),
3655
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
3267
3656
  field2("name", utf82(), false),
3268
3657
  field2("column_name", utf82(), false),
3269
3658
  field2("ignore_not_found", bool2(), false),
@@ -3271,7 +3660,7 @@ var CatalogTableColumnDefaultDropParamsSchema = schema2([
3271
3660
  ]);
3272
3661
  var CatalogTableColumnDefaultSetParamsSchema = schema2([
3273
3662
  field2("attach_opaque_data", binary2(), false),
3274
- field2("schema_name", utf82(), false),
3663
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
3275
3664
  field2("name", utf82(), false),
3276
3665
  field2("column_name", utf82(), false),
3277
3666
  field2("expression", utf82(), false),
@@ -3280,7 +3669,7 @@ var CatalogTableColumnDefaultSetParamsSchema = schema2([
3280
3669
  ]);
3281
3670
  var CatalogTableColumnDropParamsSchema = schema2([
3282
3671
  field2("attach_opaque_data", binary2(), false),
3283
- field2("schema_name", utf82(), false),
3672
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
3284
3673
  field2("name", utf82(), false),
3285
3674
  field2("column_name", utf82(), false),
3286
3675
  field2("ignore_not_found", bool2(), false),
@@ -3290,7 +3679,7 @@ var CatalogTableColumnDropParamsSchema = schema2([
3290
3679
  ]);
3291
3680
  var CatalogTableColumnRenameParamsSchema = schema2([
3292
3681
  field2("attach_opaque_data", binary2(), false),
3293
- field2("schema_name", utf82(), false),
3682
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
3294
3683
  field2("name", utf82(), false),
3295
3684
  field2("column_name", utf82(), false),
3296
3685
  field2("new_column_name", utf82(), false),
@@ -3299,13 +3688,13 @@ var CatalogTableColumnRenameParamsSchema = schema2([
3299
3688
  ]);
3300
3689
  var CatalogTableColumnStatisticsGetParamsSchema = schema2([
3301
3690
  field2("attach_opaque_data", binary2(), false),
3302
- field2("schema_name", utf82(), false),
3691
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
3303
3692
  field2("name", utf82(), false),
3304
3693
  field2("transaction_opaque_data", binary2(), true)
3305
3694
  ]);
3306
3695
  var CatalogTableColumnTypeChangeParamsSchema = schema2([
3307
3696
  field2("attach_opaque_data", binary2(), false),
3308
- field2("schema_name", utf82(), false),
3697
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
3309
3698
  field2("name", utf82(), false),
3310
3699
  field2("column_definition", binary2(), false),
3311
3700
  field2("expression", utf82(), true),
@@ -3314,7 +3703,7 @@ var CatalogTableColumnTypeChangeParamsSchema = schema2([
3314
3703
  ]);
3315
3704
  var CatalogTableCommentSetParamsSchema = schema2([
3316
3705
  field2("attach_opaque_data", binary2(), false),
3317
- field2("schema_name", utf82(), false),
3706
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
3318
3707
  field2("name", utf82(), false),
3319
3708
  field2("comment", utf82(), true),
3320
3709
  field2("ignore_not_found", bool2(), false),
@@ -3325,13 +3714,13 @@ var CatalogTableCreateParamsSchema = schema2([
3325
3714
  ]);
3326
3715
  var CatalogTableDeleteFunctionGetParamsSchema = schema2([
3327
3716
  field2("attach_opaque_data", binary2(), false),
3328
- field2("schema_name", utf82(), false),
3717
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
3329
3718
  field2("name", utf82(), false),
3330
3719
  field2("transaction_opaque_data", binary2(), true)
3331
3720
  ]);
3332
3721
  var CatalogTableDropParamsSchema = schema2([
3333
3722
  field2("attach_opaque_data", binary2(), false),
3334
- field2("schema_name", utf82(), false),
3723
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
3335
3724
  field2("name", utf82(), false),
3336
3725
  field2("ignore_not_found", bool2(), false),
3337
3726
  field2("cascade", bool2(), false),
@@ -3339,7 +3728,7 @@ var CatalogTableDropParamsSchema = schema2([
3339
3728
  ]);
3340
3729
  var CatalogTableGetParamsSchema = schema2([
3341
3730
  field2("attach_opaque_data", binary2(), false),
3342
- field2("schema_name", utf82(), false),
3731
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
3343
3732
  field2("name", utf82(), false),
3344
3733
  field2("at_unit", utf82(), true),
3345
3734
  field2("at_value", utf82(), true),
@@ -3347,14 +3736,14 @@ var CatalogTableGetParamsSchema = schema2([
3347
3736
  ]);
3348
3737
  var CatalogTableInsertFunctionGetParamsSchema = schema2([
3349
3738
  field2("attach_opaque_data", binary2(), false),
3350
- field2("schema_name", utf82(), false),
3739
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
3351
3740
  field2("name", utf82(), false),
3352
3741
  field2("transaction_opaque_data", binary2(), true),
3353
3742
  field2("writable_branch_function_name", utf82(), true)
3354
3743
  ]);
3355
3744
  var CatalogTableNotNullDropParamsSchema = schema2([
3356
3745
  field2("attach_opaque_data", binary2(), false),
3357
- field2("schema_name", utf82(), false),
3746
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
3358
3747
  field2("name", utf82(), false),
3359
3748
  field2("column_name", utf82(), false),
3360
3749
  field2("ignore_not_found", bool2(), false),
@@ -3362,7 +3751,7 @@ var CatalogTableNotNullDropParamsSchema = schema2([
3362
3751
  ]);
3363
3752
  var CatalogTableNotNullSetParamsSchema = schema2([
3364
3753
  field2("attach_opaque_data", binary2(), false),
3365
- field2("schema_name", utf82(), false),
3754
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
3366
3755
  field2("name", utf82(), false),
3367
3756
  field2("column_name", utf82(), false),
3368
3757
  field2("ignore_not_found", bool2(), false),
@@ -3370,7 +3759,7 @@ var CatalogTableNotNullSetParamsSchema = schema2([
3370
3759
  ]);
3371
3760
  var CatalogTableRenameParamsSchema = schema2([
3372
3761
  field2("attach_opaque_data", binary2(), false),
3373
- field2("schema_name", utf82(), false),
3762
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
3374
3763
  field2("name", utf82(), false),
3375
3764
  field2("new_name", utf82(), false),
3376
3765
  field2("ignore_not_found", bool2(), false),
@@ -3378,7 +3767,7 @@ var CatalogTableRenameParamsSchema = schema2([
3378
3767
  ]);
3379
3768
  var CatalogTableScanBranchesGetParamsSchema = schema2([
3380
3769
  field2("attach_opaque_data", binary2(), false),
3381
- field2("schema_name", utf82(), false),
3770
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
3382
3771
  field2("name", utf82(), false),
3383
3772
  field2("at_unit", utf82(), true),
3384
3773
  field2("at_value", utf82(), true),
@@ -3386,7 +3775,7 @@ var CatalogTableScanBranchesGetParamsSchema = schema2([
3386
3775
  ]);
3387
3776
  var CatalogTableScanFunctionGetParamsSchema = schema2([
3388
3777
  field2("attach_opaque_data", binary2(), false),
3389
- field2("schema_name", utf82(), false),
3778
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
3390
3779
  field2("name", utf82(), false),
3391
3780
  field2("at_unit", utf82(), true),
3392
3781
  field2("at_value", utf82(), true),
@@ -3394,7 +3783,7 @@ var CatalogTableScanFunctionGetParamsSchema = schema2([
3394
3783
  ]);
3395
3784
  var CatalogTableUpdateFunctionGetParamsSchema = schema2([
3396
3785
  field2("attach_opaque_data", binary2(), false),
3397
- field2("schema_name", utf82(), false),
3786
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
3398
3787
  field2("name", utf82(), false),
3399
3788
  field2("transaction_opaque_data", binary2(), true)
3400
3789
  ]);
@@ -3415,7 +3804,7 @@ var CatalogVersionParamsSchema = schema2([
3415
3804
  ]);
3416
3805
  var CatalogViewCommentSetParamsSchema = schema2([
3417
3806
  field2("attach_opaque_data", binary2(), false),
3418
- field2("schema_name", utf82(), false),
3807
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
3419
3808
  field2("name", utf82(), false),
3420
3809
  field2("comment", utf82(), true),
3421
3810
  field2("ignore_not_found", bool2(), false),
@@ -3423,7 +3812,7 @@ var CatalogViewCommentSetParamsSchema = schema2([
3423
3812
  ]);
3424
3813
  var CatalogViewCreateParamsSchema = schema2([
3425
3814
  field2("attach_opaque_data", binary2(), false),
3426
- field2("schema_name", utf82(), false),
3815
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
3427
3816
  field2("name", utf82(), false),
3428
3817
  field2("definition", utf82(), false),
3429
3818
  field2("on_conflict", dictionary2(utf82(), int162()), false),
@@ -3431,7 +3820,7 @@ var CatalogViewCreateParamsSchema = schema2([
3431
3820
  ]);
3432
3821
  var CatalogViewDropParamsSchema = schema2([
3433
3822
  field2("attach_opaque_data", binary2(), false),
3434
- field2("schema_name", utf82(), false),
3823
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
3435
3824
  field2("name", utf82(), false),
3436
3825
  field2("ignore_not_found", bool2(), false),
3437
3826
  field2("cascade", bool2(), false),
@@ -3439,13 +3828,13 @@ var CatalogViewDropParamsSchema = schema2([
3439
3828
  ]);
3440
3829
  var CatalogViewGetParamsSchema = schema2([
3441
3830
  field2("attach_opaque_data", binary2(), false),
3442
- field2("schema_name", utf82(), false),
3831
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
3443
3832
  field2("name", utf82(), false),
3444
3833
  field2("transaction_opaque_data", binary2(), true)
3445
3834
  ]);
3446
3835
  var CatalogViewRenameParamsSchema = schema2([
3447
3836
  field2("attach_opaque_data", binary2(), false),
3448
- field2("schema_name", utf82(), false),
3837
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
3449
3838
  field2("name", utf82(), false),
3450
3839
  field2("new_name", utf82(), false),
3451
3840
  field2("ignore_not_found", bool2(), false),
@@ -3469,10 +3858,18 @@ var TableFunctionCardinalityParamsSchema = schema2([
3469
3858
  var TableFunctionDynamicToStringParamsSchema = schema2([
3470
3859
  field2("request", binary2(), false)
3471
3860
  ]);
3861
+ var TableFunctionPlanParamsSchema = schema2([
3862
+ field2("request", binary2(), false)
3863
+ ]);
3472
3864
  var TableFunctionStatisticsParamsSchema = schema2([
3473
3865
  field2("request", binary2(), false)
3474
3866
  ]);
3475
3867
 
3868
+ // src/schema-path.ts
3869
+ function normalizeSchemaPath(path) {
3870
+ return typeof path === "string" ? [path] : Array.from(path, String);
3871
+ }
3872
+
3476
3873
  // src/protocol/handlers/shared.ts
3477
3874
  var RESULT_BINARY_SCHEMA = schema2([
3478
3875
  field2("result", binary2(), false)
@@ -3486,7 +3883,15 @@ var RESULT_BINARY_NULLABLE_SCHEMA = schema2([
3486
3883
  function unwrapRequest(requestBytes) {
3487
3884
  const bytes = toUint8Array(requestBytes);
3488
3885
  const innerBatch = deserializeBatch(bytes);
3489
- return batchToScalarDict(innerBatch);
3886
+ const params = batchToScalarDict(innerBatch);
3887
+ normalizeRequestSchemaPaths(params);
3888
+ return params;
3889
+ }
3890
+ function normalizeRequestSchemaPaths(params) {
3891
+ if (params.path != null)
3892
+ params.path = normalizeSchemaPath(params.path);
3893
+ if (params.schema_path != null)
3894
+ params.schema_path = normalizeSchemaPath(params.schema_path);
3490
3895
  }
3491
3896
  function wrapResult(values, innerSchema) {
3492
3897
  const a = innerSchema;
@@ -3506,7 +3911,7 @@ function overloadContext(req, catalogInterface) {
3506
3911
  arguments: req.arguments,
3507
3912
  inputSchema: req.input_schema,
3508
3913
  isScalar: String(req.function_type).toLowerCase() === "scalar",
3509
- schemaName: req.schema_name ?? null,
3914
+ schemaPath: req.schema_path ?? null,
3510
3915
  catalogName
3511
3916
  };
3512
3917
  }
@@ -3694,14 +4099,14 @@ function getOutput(expectedLength, out, onlyAligned = true) {
3694
4099
  throw new Error("invalid output, must be aligned");
3695
4100
  return out;
3696
4101
  }
3697
- function u64Lengths(dataLength, aadLength, isLE2) {
4102
+ function u64Lengths(dataLength, aadLength, isLE) {
3698
4103
  anumber(dataLength);
3699
4104
  anumber(aadLength);
3700
- abool(isLE2);
4105
+ abool(isLE);
3701
4106
  const num = new Uint8Array(16);
3702
4107
  const view = createView(num);
3703
- view.setBigUint64(0, BigInt(aadLength), isLE2);
3704
- view.setBigUint64(8, BigInt(dataLength), isLE2);
4108
+ view.setBigUint64(0, BigInt(aadLength), isLE);
4109
+ view.setBigUint64(8, BigInt(dataLength), isLE);
3705
4110
  return num;
3706
4111
  }
3707
4112
  function isAligned32(bytes) {
@@ -4268,8 +4673,8 @@ var ATTACH_AAD_PREFIX = _UTF8.encode("vgi.attach_opaque_data.v1\x00");
4268
4673
  var TRANSACTION_AAD_PREFIX = _UTF8.encode("vgi.transaction_opaque_data.v1\x00");
4269
4674
 
4270
4675
  class OpaqueDataRejectedError extends Error {
4271
- constructor(field3 = "opaque data") {
4272
- super(`${field3} not recognized`);
4676
+ constructor(field = "opaque data") {
4677
+ super(`${field} not recognized`);
4273
4678
  this.name = "OpaqueDataRejectedError";
4274
4679
  }
4275
4680
  }
@@ -4312,16 +4717,16 @@ async function sealBytes(payload, key, aad, version) {
4312
4717
  out.set(ciphertext, 1 + NONCE_LEN);
4313
4718
  return out;
4314
4719
  }
4315
- async function openBytes(token, key, aad, version, field3 = "opaque data") {
4720
+ async function openBytes(token, key, aad, version, field = "opaque data") {
4316
4721
  if (token.length < MIN_ENVELOPE_LEN || token[0] !== (version & 255)) {
4317
- throw new OpaqueDataRejectedError(field3);
4722
+ throw new OpaqueDataRejectedError(field);
4318
4723
  }
4319
4724
  const nonce = token.subarray(1, 1 + NONCE_LEN);
4320
4725
  const ciphertext = token.subarray(1 + NONCE_LEN);
4321
4726
  try {
4322
4727
  return xchacha20poly1305(await normalizeKey(key), nonce, aad).decrypt(ciphertext);
4323
4728
  } catch {
4324
- throw new OpaqueDataRejectedError(field3);
4729
+ throw new OpaqueDataRejectedError(field);
4325
4730
  }
4326
4731
  }
4327
4732
 
@@ -4374,6 +4779,7 @@ function catalogUnary(protocol, signingKey, name, config) {
4374
4779
  result: config.result,
4375
4780
  doc: config.doc,
4376
4781
  handler: async (params, ctx) => {
4782
+ normalizeRequestSchemaPaths(params);
4377
4783
  await unwrapParamsOpaque(params, ctx, signingKey);
4378
4784
  return config.handler(params, ctx);
4379
4785
  }
@@ -4399,57 +4805,235 @@ function decodeOptionsBatch(bytes) {
4399
4805
  return row ?? {};
4400
4806
  }
4401
4807
  var emptyResultSchema = schema2([]);
4402
- var attachOpaqueDataParam = schema2([
4403
- field2("attach_opaque_data", binary2(), true)
4404
- ]);
4405
- var attachOpaqueDataTxnParams = schema2([
4406
- field2("attach_opaque_data", binary2(), true),
4407
- field2("transaction_opaque_data", binary2(), true)
4408
- ]);
4409
- var attachOpaqueDataNameTxnParams = schema2([
4410
- field2("attach_opaque_data", binary2(), true),
4411
- field2("name", utf82(), false),
4412
- field2("transaction_opaque_data", binary2(), true)
4413
- ]);
4414
- var attachOpaqueDataSchemaNameTxnParams = schema2([
4415
- field2("attach_opaque_data", binary2(), true),
4416
- field2("schema_name", utf82(), false),
4417
- field2("name", utf82(), false),
4418
- field2("transaction_opaque_data", binary2(), true)
4419
- ]);
4420
- var schemaNameIgnoreNotFoundTxnParams = schema2([
4421
- field2("attach_opaque_data", binary2(), true),
4422
- field2("schema_name", utf82(), false),
4423
- field2("name", utf82(), false),
4424
- field2("ignore_not_found", bool2(), true),
4425
- field2("transaction_opaque_data", binary2(), true)
4426
- ]);
4427
- var schemaNameCommentParams = schema2([
4428
- field2("attach_opaque_data", binary2(), true),
4429
- field2("schema_name", utf82(), false),
4430
- field2("name", utf82(), false),
4431
- field2("comment", utf82(), true),
4432
- field2("ignore_not_found", bool2(), true),
4433
- field2("transaction_opaque_data", binary2(), true)
4434
- ]);
4435
- var schemaNameRenameParams = schema2([
4436
- field2("attach_opaque_data", binary2(), true),
4437
- field2("schema_name", utf82(), false),
4438
- field2("name", utf82(), false),
4439
- field2("new_name", utf82(), false),
4440
- field2("ignore_not_found", bool2(), true),
4441
- field2("transaction_opaque_data", binary2(), true)
4442
- ]);
4443
- var columnOpParams = schema2([
4444
- field2("attach_opaque_data", binary2(), true),
4445
- field2("schema_name", utf82(), false),
4446
- field2("name", utf82(), false),
4447
- field2("column_name", utf82(), false),
4448
- field2("ignore_not_found", bool2(), true),
4449
- field2("transaction_opaque_data", binary2(), true)
4450
- ]);
4808
+
4809
+ // src/request-auth.ts
4810
+ var scope;
4811
+ function setRequestAuthScope(next) {
4812
+ scope = next;
4813
+ }
4814
+ function currentRequestAuth() {
4815
+ return scope?.getStore()?.auth;
4816
+ }
4817
+
4818
+ // src/protocol/serializers/splits.ts
4819
+ var SCAN_SPLIT_SCHEMA = ScanSplitSchema;
4820
+ var PLAN_RESPONSE_SCHEMA = TableFunctionPlanResultSchema;
4821
+ function deserializePlanRequest(params) {
4822
+ const bindCallBytes = toUint8Array2(params.bind_call);
4823
+ const bindCall = deserializeBindRequest(batchToScalarDict(deserializeBatch(bindCallBytes)));
4824
+ let projectionIds = null;
4825
+ if (params.projection_ids != null) {
4826
+ const raw = params.projection_ids;
4827
+ if (Array.isArray(raw))
4828
+ projectionIds = raw.map(Number);
4829
+ else if (raw && typeof raw[Symbol.iterator] === "function")
4830
+ projectionIds = [...raw].map(Number);
4831
+ }
4832
+ const asBigInt = (v) => v == null ? null : typeof v === "bigint" ? v : BigInt(Number(v));
4833
+ return {
4834
+ bind_call: bindCall,
4835
+ bind_opaque_data: params.bind_opaque_data ? toUint8Array2(params.bind_opaque_data) : null,
4836
+ projection_ids: projectionIds,
4837
+ pushdown_filters: params.pushdown_filters ? toUint8Array2(params.pushdown_filters) : null,
4838
+ target_split_bytes: asBigInt(params.target_split_bytes),
4839
+ min_splits: asBigInt(params.min_splits),
4840
+ cursor: params.cursor ? toUint8Array2(params.cursor) : null
4841
+ };
4842
+ }
4843
+ function fingerprintInputs(bindCallBytes) {
4844
+ const dict = batchToScalarDict(deserializeBatch(bindCallBytes));
4845
+ return {
4846
+ schemaPath: dict.schema_path == null ? [] : (Array.isArray(dict.schema_path) ? dict.schema_path : [...dict.schema_path]).map(String),
4847
+ functionName: String(dict.function_name ?? ""),
4848
+ args: dict.arguments ? toUint8Array2(dict.arguments) : new Uint8Array(0),
4849
+ settings: dict.settings ? toUint8Array2(dict.settings) : new Uint8Array(0)
4850
+ };
4851
+ }
4852
+ function scanSplitRow(split, token) {
4853
+ const asBigInt = (v) => v == null ? null : typeof v === "bigint" ? v : BigInt(v);
4854
+ return {
4855
+ payload: new Uint8Array(0),
4856
+ token,
4857
+ estimated_rows: asBigInt(split.estimatedRows),
4858
+ rows_exact: split.rowsExact === true,
4859
+ estimated_bytes: asBigInt(split.estimatedBytes),
4860
+ partition_bounds: split.partitionBounds ?? null,
4861
+ column_statistics: split.columnStatistics ?? null,
4862
+ location_ids: split.locationIds ?? null,
4863
+ start_position: split.startPosition ?? null,
4864
+ end_position: split.endPosition ?? null
4865
+ };
4866
+ }
4867
+ function planResponseRow(result, splitBlobs) {
4868
+ const asBigInt = (v) => v == null ? null : typeof v === "bigint" ? v : BigInt(v);
4869
+ return {
4870
+ splits: splitBlobs,
4871
+ next_cursors: result.nextCursors ?? [],
4872
+ execution_id: null,
4873
+ init_opaque_data: new Uint8Array(0),
4874
+ max_workers: asBigInt(result.maxWorkers),
4875
+ estimated_total_splits: asBigInt(result.estimatedTotalSplits),
4876
+ estimated_total_rows: asBigInt(result.estimatedTotalRows),
4877
+ estimated_total_bytes: asBigInt(result.estimatedTotalBytes),
4878
+ catalog_version: asBigInt(result.catalogVersion),
4879
+ scope: result.scope ?? "catalog",
4880
+ locations: null,
4881
+ partitioning: [],
4882
+ sort_order: [],
4883
+ cache_max_age_seconds: asBigInt(result.cacheMaxAgeSeconds),
4884
+ start_position: new Uint8Array(0),
4885
+ end_position: new Uint8Array(0)
4886
+ };
4887
+ }
4888
+
4889
+ // src/split-token.ts
4890
+ var SPLIT_TOKEN_FORMAT_VERSION = 1;
4891
+ var FLAG_PAYLOAD_SEALED = 1;
4892
+ var RESERVED_FLAGS_MASK = 254;
4893
+ var FINGERPRINT_LEN = 16;
4894
+ var HEADER_LEN = 4 + FINGERPRINT_LEN;
4895
+ var SEAL_VERSION = 1;
4896
+ var AAD_PREFIX = new TextEncoder().encode("vgi.split_token.v1\x00");
4897
+ var SPLIT_TOKEN_INVALID = "SPLIT_TOKEN_INVALID";
4898
+ var SPLIT_SNAPSHOT_EXPIRED = "SPLIT_SNAPSHOT_EXPIRED";
4899
+ class SplitTokenError extends Error {
4900
+ kind;
4901
+ constructor(kind, message) {
4902
+ super(`[${kind}] ${message}`);
4903
+ this.name = "SplitTokenError";
4904
+ this.kind = kind;
4905
+ }
4906
+ }
4907
+ function concat2(...parts) {
4908
+ const total = parts.reduce((n, p) => n + p.length, 0);
4909
+ const out = new Uint8Array(total);
4910
+ let at = 0;
4911
+ for (const p of parts) {
4912
+ out.set(p, at);
4913
+ at += p.length;
4914
+ }
4915
+ return out;
4916
+ }
4917
+ function equalBytes2(a, b) {
4918
+ if (a.length !== b.length)
4919
+ return false;
4920
+ let diff = 0;
4921
+ for (let i = 0;i < a.length; i++)
4922
+ diff |= a[i] ^ b[i];
4923
+ return diff === 0;
4924
+ }
4925
+ async function bindFingerprint(schemaPath, functionName, args, settings, projection) {
4926
+ const enc = new TextEncoder;
4927
+ const zero = Uint8Array.of(0);
4928
+ const field = (label, value) => concat2(enc.encode(label), zero, value, zero);
4929
+ const message = concat2(AAD_PREFIX, field("schema_path", enc.encode(JSON.stringify(schemaPath))), field("function_name", enc.encode(functionName)), field("arguments", args), field("settings", settings), field("projection_ids", projection));
4930
+ const digest = await crypto.subtle.digest("SHA-256", message);
4931
+ return new Uint8Array(digest).slice(0, FINGERPRINT_LEN);
4932
+ }
4933
+ function splitTokenAad(header, auth) {
4934
+ return concat2(header, identityTail(auth));
4935
+ }
4936
+ function splitAnchor(catalogVersion) {
4937
+ const out = new Uint8Array(8);
4938
+ new DataView(out.buffer).setBigInt64(0, BigInt(catalogVersion), true);
4939
+ return out;
4940
+ }
4941
+ async function buildSplitToken(opts) {
4942
+ const { payload, fingerprint, anchor, signingKey, auth } = opts;
4943
+ if (fingerprint.length !== FINGERPRINT_LEN) {
4944
+ throw new SplitTokenError(SPLIT_TOKEN_INVALID, `bind_fingerprint must be ${FINGERPRINT_LEN} bytes, got ${fingerprint.length}`);
4945
+ }
4946
+ if (anchor.length > 65535) {
4947
+ throw new SplitTokenError(SPLIT_TOKEN_INVALID, `consistency_anchor too long: ${anchor.length} bytes exceeds u16`);
4948
+ }
4949
+ const head = new Uint8Array(4);
4950
+ head[0] = SPLIT_TOKEN_FORMAT_VERSION;
4951
+ head[1] = signingKey ? FLAG_PAYLOAD_SEALED : 0;
4952
+ new DataView(head.buffer).setUint16(2, anchor.length, true);
4953
+ const body = concat2(head, fingerprint, anchor);
4954
+ if (!signingKey)
4955
+ return concat2(body, payload);
4956
+ const sealed = await sealBytes(payload, signingKey, splitTokenAad(body, auth), SEAL_VERSION);
4957
+ return concat2(body, sealed);
4958
+ }
4959
+ async function openSplitToken(token, opts = {}) {
4960
+ const { signingKey, auth, expectedFingerprint, currentAnchor } = opts;
4961
+ if (token.length < HEADER_LEN) {
4962
+ throw new SplitTokenError(SPLIT_TOKEN_INVALID, `split token too short: ${token.length} bytes, need at least ${HEADER_LEN}`);
4963
+ }
4964
+ const version = token[0];
4965
+ const flags = token[1];
4966
+ const view = new DataView(token.buffer, token.byteOffset, token.byteLength);
4967
+ const anchorLen = view.getUint16(2, true);
4968
+ if (version !== SPLIT_TOKEN_FORMAT_VERSION) {
4969
+ throw new SplitTokenError(SPLIT_TOKEN_INVALID, `unsupported split-token format_version ${version}; this worker speaks ` + `${SPLIT_TOKEN_FORMAT_VERSION}`);
4970
+ }
4971
+ if (flags & RESERVED_FLAGS_MASK) {
4972
+ throw new SplitTokenError(SPLIT_TOKEN_INVALID, `split token sets reserved flag bits (flags=0x${flags.toString(16).padStart(2, "0")})`);
4973
+ }
4974
+ const sealed = (flags & FLAG_PAYLOAD_SEALED) !== 0;
4975
+ if (signingKey && !sealed) {
4976
+ throw new SplitTokenError(SPLIT_TOKEN_INVALID, "split token is unsealed but this worker holds a signing key; refusing. An unsealed " + "token cannot be authenticated, so accepting one here would let any caller forge a " + "split (alg:none).");
4977
+ }
4978
+ if (!signingKey && sealed) {
4979
+ throw new SplitTokenError(SPLIT_TOKEN_INVALID, "split token is sealed but this worker holds no signing key; cannot open it");
4980
+ }
4981
+ const endOfAnchor = HEADER_LEN + anchorLen;
4982
+ if (token.length < endOfAnchor) {
4983
+ throw new SplitTokenError(SPLIT_TOKEN_INVALID, `split token truncated: anchor_len=${anchorLen} exceeds token length ${token.length}`);
4984
+ }
4985
+ const fingerprint = token.subarray(4, HEADER_LEN);
4986
+ const anchor = token.subarray(HEADER_LEN, endOfAnchor);
4987
+ const body = token.subarray(0, endOfAnchor);
4988
+ const rest = token.subarray(endOfAnchor);
4989
+ if (expectedFingerprint && !equalBytes2(fingerprint, expectedFingerprint)) {
4990
+ throw new SplitTokenError(SPLIT_TOKEN_INVALID, "split token was minted for a different bind (fingerprint mismatch)");
4991
+ }
4992
+ if (currentAnchor && !equalBytes2(anchor, currentAnchor)) {
4993
+ throw new SplitTokenError(SPLIT_SNAPSHOT_EXPIRED, "split snapshot expired; re-run the query");
4994
+ }
4995
+ if (!sealed)
4996
+ return new Uint8Array(rest);
4997
+ try {
4998
+ return await openBytes(rest, signingKey, splitTokenAad(body, auth), SEAL_VERSION, "split token");
4999
+ } catch (err) {
5000
+ throw new SplitTokenError(SPLIT_TOKEN_INVALID, `split token failed authentication: ${err instanceof Error ? err.message : String(err)}`);
5001
+ }
5002
+ }
4451
5003
 
4452
5004
  // src/protocol/handlers/function.ts
5005
+ async function liveSplitAnchor(catalogInterface, bindCall, auth, signingKey) {
5006
+ if (!catalogInterface?.version || bindCall.attach_opaque_data == null)
5007
+ return;
5008
+ const raw = toUint8Array(bindCall.attach_opaque_data);
5009
+ const txn = bindCall.transaction_opaque_data ? toUint8Array(bindCall.transaction_opaque_data) : undefined;
5010
+ const forms = [
5011
+ async () => raw,
5012
+ async () => openAttach(raw, auth, signingKey)
5013
+ ];
5014
+ for (const form of forms) {
5015
+ try {
5016
+ return splitAnchor(await catalogInterface.version(await form(), txn));
5017
+ } catch {}
5018
+ }
5019
+ return;
5020
+ }
5021
+ async function resolveSplitPayloads(request, innerParams, opts) {
5022
+ if (!request.split_tokens)
5023
+ return;
5024
+ const fp = fingerprintInputs(toUint8Array(innerParams.bind_call));
5025
+ const expected = await bindFingerprint(fp.schemaPath, fp.functionName, fp.args, fp.settings, new Uint8Array(0));
5026
+ const currentAnchor = opts.checkAnchor ? await liveSplitAnchor(opts.catalogInterface, request.bind_call, opts.auth, opts.signingKey) : undefined;
5027
+ request.split_payloads = [];
5028
+ for (const token of request.split_tokens) {
5029
+ request.split_payloads.push(await openSplitToken(token, {
5030
+ signingKey: opts.signingKey,
5031
+ auth: opts.auth,
5032
+ expectedFingerprint: expected,
5033
+ currentAnchor
5034
+ }));
5035
+ }
5036
+ }
4453
5037
  function registerFunctionMethods(protocol, config) {
4454
5038
  const { registry, signingKey, catalogInterface } = config;
4455
5039
  async function stripAttach(attach, ctx) {
@@ -4458,7 +5042,7 @@ function registerFunctionMethods(protocol, config) {
4458
5042
  const env = toUint8Array(attach);
4459
5043
  if (env.length === 0)
4460
5044
  return env;
4461
- return openAttach(env, ctx?.auth, signingKey);
5045
+ return openAttach(env, ctx?.auth ?? currentRequestAuth(), signingKey);
4462
5046
  }
4463
5047
  async function strippedContext(bindCall, ctx) {
4464
5048
  let attach = null;
@@ -4469,17 +5053,13 @@ function registerFunctionMethods(protocol, config) {
4469
5053
  }
4470
5054
  return overloadContext({ ...bindCall, attach_opaque_data: attach }, catalogInterface);
4471
5055
  }
4472
- const initHeaderSchema = schema2([
4473
- field2("execution_id", binary2(), false),
4474
- field2("opaque_data", binary2(), true),
4475
- field2("max_workers", int642(), false)
4476
- ]);
5056
+ const initHeaderSchema = GLOBAL_INIT_RESPONSE_SCHEMA;
4477
5057
  const emptySchema = schema2([]);
4478
5058
  const dummyInputSchema = schema2([
4479
5059
  field2("_tick", binary2(), true)
4480
5060
  ]);
4481
5061
  protocol.unary("bind", {
4482
- params: REQUEST_PARAMS_SCHEMA,
5062
+ params: BindParamsSchema,
4483
5063
  result: RESULT_BINARY_SCHEMA,
4484
5064
  handler: async (params, ctx) => {
4485
5065
  const innerParams = unwrapRequest(params.request);
@@ -4492,14 +5072,21 @@ function registerFunctionMethods(protocol, config) {
4492
5072
  }
4493
5073
  });
4494
5074
  protocol.exchange("init", {
4495
- params: REQUEST_PARAMS_SCHEMA,
5075
+ params: InitParamsSchema,
4496
5076
  inputSchema: dummyInputSchema,
4497
5077
  outputSchema: emptySchema,
4498
- init: async (params) => {
5078
+ init: async (params, ctx) => {
4499
5079
  const requestIpcBytes = toUint8Array(params.request);
4500
5080
  const innerParams = unwrapRequest(params.request);
4501
5081
  const request = deserializeInitRequest(innerParams);
4502
- request.bind_call.attach_opaque_data = await stripAttach(request.bind_call.attach_opaque_data, undefined);
5082
+ const auth = ctx?.auth ?? currentRequestAuth();
5083
+ request.bind_call.attach_opaque_data = await stripAttach(request.bind_call.attach_opaque_data, ctx);
5084
+ await resolveSplitPayloads(request, innerParams, {
5085
+ auth,
5086
+ signingKey,
5087
+ catalogInterface,
5088
+ checkAnchor: true
5089
+ });
4503
5090
  const func = registry.get(request.bind_call.function_name, overloadContext(request.bind_call, catalogInterface));
4504
5091
  const initResponse = await func.globalInit(request);
4505
5092
  const accumulatedState = recoverFinalizeState(request, config.recoverExchangeState);
@@ -4540,6 +5127,12 @@ function registerFunctionMethods(protocol, config) {
4540
5127
  const initRequestBatch = deserializeBatch(state.initRequestIpc);
4541
5128
  const initRequestDict = batchToScalarDict(initRequestBatch);
4542
5129
  const request = deserializeInitRequest(initRequestDict);
5130
+ await resolveSplitPayloads(request, { bind_call: initRequestDict.bind_call }, {
5131
+ auth: currentRequestAuth(),
5132
+ signingKey,
5133
+ catalogInterface,
5134
+ checkAnchor: false
5135
+ });
4543
5136
  const func = registry.get(state.functionName, await strippedContext(request.bind_call));
4544
5137
  const executionId = state.executionId;
4545
5138
  const opaqueData = state.opaqueData ?? null;
@@ -4583,7 +5176,7 @@ function registerFunctionMethods(protocol, config) {
4583
5176
  }
4584
5177
  });
4585
5178
  protocol.unary("table_function_cardinality", {
4586
- params: REQUEST_PARAMS_SCHEMA,
5179
+ params: TableFunctionCardinalityParamsSchema,
4587
5180
  result: RESULT_BINARY_SCHEMA,
4588
5181
  handler: async (params) => {
4589
5182
  const innerParams = unwrapRequest(params.request);
@@ -4598,8 +5191,36 @@ function registerFunctionMethods(protocol, config) {
4598
5191
  return wrapResult(cardResult, TableFunctionCardinalityResultSchema);
4599
5192
  }
4600
5193
  });
5194
+ protocol.unary("table_function_plan", {
5195
+ params: TableFunctionPlanParamsSchema,
5196
+ result: RESULT_BINARY_SCHEMA,
5197
+ handler: async (params, ctx) => {
5198
+ const innerParams = unwrapRequest(params.request);
5199
+ const request = deserializePlanRequest(innerParams);
5200
+ const func = registry.get(request.bind_call.function_name, await strippedContext(request.bind_call));
5201
+ const plan = func.plan ? await func.plan(request) : { splits: [{ payload: new Uint8Array(0) }] };
5202
+ const fp = fingerprintInputs(toUint8Array(innerParams.bind_call));
5203
+ const fingerprint = await bindFingerprint(fp.schemaPath, fp.functionName, fp.args, fp.settings, new Uint8Array(0));
5204
+ const anchor = plan.catalogVersion != null ? splitAnchor(plan.catalogVersion) : await liveSplitAnchor(catalogInterface, request.bind_call, ctx?.auth, signingKey) ?? splitAnchor(0);
5205
+ const blobs = [];
5206
+ for (const split of plan.splits) {
5207
+ const token = await buildSplitToken({
5208
+ payload: split.payload,
5209
+ fingerprint,
5210
+ anchor,
5211
+ signingKey,
5212
+ auth: ctx?.auth
5213
+ });
5214
+ blobs.push(serializeBatch(batchFromColumns(Object.fromEntries(SCAN_SPLIT_SCHEMA.fields.map((f) => [
5215
+ f.name,
5216
+ [scanSplitRow(split, token)[f.name] ?? null]
5217
+ ])), SCAN_SPLIT_SCHEMA)));
5218
+ }
5219
+ return wrapResult(planResponseRow(plan, blobs), PLAN_RESPONSE_SCHEMA);
5220
+ }
5221
+ });
4601
5222
  protocol.unary("table_function_statistics", {
4602
- params: REQUEST_PARAMS_SCHEMA,
5223
+ params: TableFunctionStatisticsParamsSchema,
4603
5224
  result: RESULT_BINARY_NULLABLE_SCHEMA,
4604
5225
  handler: async (params) => {
4605
5226
  const innerParams = unwrapRequest(params.request);
@@ -4614,7 +5235,7 @@ function registerFunctionMethods(protocol, config) {
4614
5235
  }
4615
5236
  });
4616
5237
  protocol.unary("table_function_dynamic_to_string", {
4617
- params: REQUEST_PARAMS_SCHEMA,
5238
+ params: TableFunctionDynamicToStringParamsSchema,
4618
5239
  result: RESULT_BINARY_SCHEMA,
4619
5240
  handler: async (params) => {
4620
5241
  const innerParams = unwrapRequest(params.request);
@@ -4625,9 +5246,9 @@ function registerFunctionMethods(protocol, config) {
4625
5246
  const globalExecutionId = toUint8Array(innerParams.global_execution_id);
4626
5247
  const bindOpaqueData = innerParams.bind_opaque_data ? toUint8Array(innerParams.bind_opaque_data) : null;
4627
5248
  const func = registry.get(bindCall.function_name, await strippedContext(bindCall));
4628
- const map3 = func.dynamicToString ? await func.dynamicToString({ bindCall, bindOpaqueData, globalExecutionId }) : {};
4629
- const keys = Object.keys(map3);
4630
- const values = keys.map((k) => map3[k] ?? "");
5249
+ const map = func.dynamicToString ? await func.dynamicToString({ bindCall, bindOpaqueData, globalExecutionId }) : {};
5250
+ const keys = Object.keys(map);
5251
+ const values = keys.map((k) => map[k] ?? "");
4631
5252
  return wrapResult({ keys, values }, TableFunctionDynamicToStringResultSchema);
4632
5253
  }
4633
5254
  });
@@ -4802,12 +5423,12 @@ function persistGroupStates(executionId, gids) {
4802
5423
 
4803
5424
  // src/protocol/handlers/aggregate.ts
4804
5425
  function registerAggregateMethods(protocol, registry) {
4805
- function resolveAggregate(name, schemaName) {
5426
+ function resolveAggregate(name, schemaPath) {
4806
5427
  const func = registry.get(name, {
4807
5428
  arguments: new Arguments,
4808
5429
  inputSchema: null,
4809
5430
  isScalar: false,
4810
- schemaName: schemaName ?? null
5431
+ schemaPath: schemaPath ?? null
4811
5432
  });
4812
5433
  if (!func || func.kind !== "aggregate") {
4813
5434
  throw new Error(`Function '${name}' is not an aggregate function`);
@@ -4815,12 +5436,12 @@ function registerAggregateMethods(protocol, registry) {
4815
5436
  return func.aggregateConfig;
4816
5437
  }
4817
5438
  protocol.unary("aggregate_bind", {
4818
- params: REQUEST_PARAMS_SCHEMA,
5439
+ params: AggregateBindParamsSchema,
4819
5440
  result: RESULT_BINARY_SCHEMA,
4820
5441
  handler: async (params) => {
4821
5442
  const innerParams = unwrapRequest(params.request);
4822
5443
  const functionName = innerParams.function_name;
4823
- const cfg = resolveAggregate(functionName, innerParams.schema_name ?? null);
5444
+ const cfg = resolveAggregate(functionName, innerParams.schema_path ?? null);
4824
5445
  const argBytes = toUint8Array(innerParams.arguments);
4825
5446
  const args = deserializeArguments(argBytes);
4826
5447
  const inputSchema = innerParams.input_schema ? deserializeSchema(toUint8Array(innerParams.input_schema)) : null;
@@ -4832,7 +5453,8 @@ function registerAggregateMethods(protocol, registry) {
4832
5453
  arguments: args,
4833
5454
  inputSchema,
4834
5455
  settings: {},
4835
- secrets
5456
+ secrets,
5457
+ argumentNames: innerParams.argument_names ? (Array.isArray(innerParams.argument_names) ? innerParams.argument_names : [...innerParams.argument_names]).map((value) => value == null ? null : String(value)) : null
4836
5458
  };
4837
5459
  const executionId = new Uint8Array(16);
4838
5460
  crypto.getRandomValues(executionId);
@@ -4847,13 +5469,13 @@ function registerAggregateMethods(protocol, registry) {
4847
5469
  }
4848
5470
  });
4849
5471
  protocol.unary("aggregate_update", {
4850
- params: REQUEST_PARAMS_SCHEMA,
5472
+ params: AggregateUpdateParamsSchema,
4851
5473
  result: RESULT_BINARY_SCHEMA,
4852
5474
  handler: (params) => {
4853
5475
  const innerParams = unwrapRequest(params.request);
4854
5476
  const functionName = innerParams.function_name;
4855
5477
  const executionId = toUint8Array(innerParams.execution_id);
4856
- const cfg = resolveAggregate(functionName, innerParams.schema_name ?? null);
5478
+ const cfg = resolveAggregate(functionName, innerParams.schema_path ?? null);
4857
5479
  const batch = readSingleBatch(toUint8Array(innerParams.input_batch));
4858
5480
  if (!batch || batch.numRows === 0)
4859
5481
  return wrapResult({}, schema2([]));
@@ -4900,13 +5522,13 @@ function registerAggregateMethods(protocol, registry) {
4900
5522
  }
4901
5523
  });
4902
5524
  protocol.unary("aggregate_combine", {
4903
- params: REQUEST_PARAMS_SCHEMA,
5525
+ params: AggregateCombineParamsSchema,
4904
5526
  result: RESULT_BINARY_SCHEMA,
4905
5527
  handler: (params) => {
4906
5528
  const innerParams = unwrapRequest(params.request);
4907
5529
  const functionName = innerParams.function_name;
4908
5530
  const executionId = toUint8Array(innerParams.execution_id);
4909
- const cfg = resolveAggregate(functionName, innerParams.schema_name ?? null);
5531
+ const cfg = resolveAggregate(functionName, innerParams.schema_path ?? null);
4910
5532
  const batch = readSingleBatch(toUint8Array(innerParams.merge_batch));
4911
5533
  if (!batch || batch.numRows === 0)
4912
5534
  return wrapResult({}, schema2([]));
@@ -4945,13 +5567,13 @@ function registerAggregateMethods(protocol, registry) {
4945
5567
  }
4946
5568
  });
4947
5569
  protocol.unary("aggregate_finalize", {
4948
- params: REQUEST_PARAMS_SCHEMA,
5570
+ params: AggregateFinalizeParamsSchema,
4949
5571
  result: RESULT_BINARY_SCHEMA,
4950
5572
  handler: (params) => {
4951
5573
  const innerParams = unwrapRequest(params.request);
4952
5574
  const functionName = innerParams.function_name;
4953
5575
  const executionId = toUint8Array(innerParams.execution_id);
4954
- const cfg = resolveAggregate(functionName, innerParams.schema_name ?? null);
5576
+ const cfg = resolveAggregate(functionName, innerParams.schema_path ?? null);
4955
5577
  const outputSchema = deserializeSchema(toUint8Array(innerParams.output_schema));
4956
5578
  const gidBatch = readSingleBatch(toUint8Array(innerParams.group_ids_batch));
4957
5579
  const groupIds = [];
@@ -4983,7 +5605,7 @@ function registerAggregateMethods(protocol, registry) {
4983
5605
  }
4984
5606
  });
4985
5607
  protocol.unary("aggregate_destructor", {
4986
- params: REQUEST_PARAMS_SCHEMA,
5608
+ params: AggregateDestructorParamsSchema,
4987
5609
  result: RESULT_BINARY_SCHEMA,
4988
5610
  handler: (params) => {
4989
5611
  const innerParams = unwrapRequest(params.request);
@@ -5021,9 +5643,9 @@ function extractArgMap(cfg, args) {
5021
5643
  let v;
5022
5644
  try {
5023
5645
  v = args.get(i);
5024
- const field3 = args.argumentsSchema?.fields.find((f) => f.name === `positional_${i}`);
5025
- if (field3 && isDecimal(field3.type)) {
5026
- const scale = field3.type.scale;
5646
+ const field = args.argumentsSchema?.fields.find((f) => f.name === `positional_${i}`);
5647
+ if (field && isDecimal(field.type)) {
5648
+ const scale = field.type.scale;
5027
5649
  if (typeof v === "bigint")
5028
5650
  v = Number(v) / Math.pow(10, scale);
5029
5651
  else if (typeof v === "number")
@@ -5097,12 +5719,12 @@ function splitLenPrefixed(buf, count) {
5097
5719
 
5098
5720
  // src/protocol/handlers/table-buffering.ts
5099
5721
  function registerTableBufferingMethods(protocol, registry, signingKey) {
5100
- function resolveBuffering(name, schemaName) {
5722
+ function resolveBuffering(name, schemaPath) {
5101
5723
  const func = registry.get(name, {
5102
5724
  arguments: new Arguments,
5103
5725
  inputSchema: null,
5104
5726
  isScalar: false,
5105
- schemaName: schemaName ?? null
5727
+ schemaPath: schemaPath ?? null
5106
5728
  });
5107
5729
  if (!func || func.kind !== "table_buffering") {
5108
5730
  throw new Error(`Function '${name}' is not a table_buffering function`);
@@ -5115,7 +5737,7 @@ function registerTableBufferingMethods(protocol, registry, signingKey) {
5115
5737
  const rawAttach = inner.attach_opaque_data ? toUint8Array(inner.attach_opaque_data) : null;
5116
5738
  const attach = rawAttach && rawAttach.length > 0 ? await openAttach(rawAttach, ctx?.auth, signingKey) : rawAttach;
5117
5739
  const transactionId = inner.transaction_id ? toUint8Array(inner.transaction_id) : null;
5118
- const func = resolveBuffering(functionName, inner.schema_name ?? null);
5740
+ const func = resolveBuffering(functionName, inner.schema_path ?? null);
5119
5741
  const bound = new BoundStorage(storage, executionId);
5120
5742
  const payload = await bound.stateGet(FrameworkNS.BUFFERING_INIT, BoundStorage.packIntKey(-1));
5121
5743
  if (payload == null) {
@@ -5142,7 +5764,7 @@ function registerTableBufferingMethods(protocol, registry, signingKey) {
5142
5764
  return { func, params };
5143
5765
  }
5144
5766
  protocol.unary("table_buffering_process", {
5145
- params: REQUEST_PARAMS_SCHEMA,
5767
+ params: TableBufferingProcessParamsSchema,
5146
5768
  result: RESULT_BINARY_SCHEMA,
5147
5769
  handler: async (rpcParams, ctx) => {
5148
5770
  const inner = unwrapRequest(rpcParams.request);
@@ -5160,7 +5782,7 @@ function registerTableBufferingMethods(protocol, registry, signingKey) {
5160
5782
  }
5161
5783
  });
5162
5784
  protocol.unary("table_buffering_combine", {
5163
- params: REQUEST_PARAMS_SCHEMA,
5785
+ params: TableBufferingCombineParamsSchema,
5164
5786
  result: RESULT_BINARY_SCHEMA,
5165
5787
  handler: async (rpcParams, ctx) => {
5166
5788
  const inner = unwrapRequest(rpcParams.request);
@@ -5178,7 +5800,7 @@ function registerTableBufferingMethods(protocol, registry, signingKey) {
5178
5800
  }
5179
5801
  });
5180
5802
  protocol.unary("table_buffering_destructor", {
5181
- params: REQUEST_PARAMS_SCHEMA,
5803
+ params: TableBufferingDestructorParamsSchema,
5182
5804
  result: RESULT_BINARY_SCHEMA,
5183
5805
  handler: async (rpcParams) => {
5184
5806
  try {
@@ -5214,8 +5836,8 @@ function hex(buf) {
5214
5836
  }
5215
5837
 
5216
5838
  // src/codec/asd.ts
5217
- function encodeASD(schema3, obj) {
5218
- return serializeBatch(batchFromRows([obj], schema3));
5839
+ function encodeASD(schema, obj) {
5840
+ return serializeBatch(batchFromRows([obj], schema));
5219
5841
  }
5220
5842
 
5221
5843
  // src/generated/vgi-client.ts
@@ -5242,7 +5864,7 @@ var encodeCopyFromFormatInfo = (v) => encodeASD(CopyFromFormatInfoSchema, {
5242
5864
  // src/protocol/handlers/catalog/admin.ts
5243
5865
  function registerCatalogAdminMethods(protocol, getCatalog, signingKey) {
5244
5866
  catalogUnary(protocol, signingKey, "catalog_catalogs", {
5245
- params: emptyResultSchema,
5867
+ params: CatalogCatalogsParamsSchema,
5246
5868
  result: RESULT_BINARY_SCHEMA,
5247
5869
  handler: async () => {
5248
5870
  const cat = getCatalog();
@@ -5258,7 +5880,7 @@ function registerCatalogAdminMethods(protocol, getCatalog, signingKey) {
5258
5880
  }
5259
5881
  });
5260
5882
  protocol.unary("catalog_attach", {
5261
- params: REQUEST_PARAMS_SCHEMA,
5883
+ params: CatalogAttachParamsSchema,
5262
5884
  result: RESULT_BINARY_SCHEMA,
5263
5885
  handler: async (params, ctx) => {
5264
5886
  const innerParams = unwrapRequest(params.request);
@@ -5288,7 +5910,7 @@ function registerCatalogAdminMethods(protocol, getCatalog, signingKey) {
5288
5910
  }
5289
5911
  });
5290
5912
  catalogUnary(protocol, signingKey, "catalog_detach", {
5291
- params: attachOpaqueDataParam,
5913
+ params: CatalogDetachParamsSchema,
5292
5914
  result: emptyResultSchema,
5293
5915
  handler: async (params) => {
5294
5916
  const cat = getCatalog();
@@ -5297,11 +5919,7 @@ function registerCatalogAdminMethods(protocol, getCatalog, signingKey) {
5297
5919
  }
5298
5920
  });
5299
5921
  catalogUnary(protocol, signingKey, "catalog_create", {
5300
- params: schema2([
5301
- field2("name", utf82(), false),
5302
- field2("on_conflict", utf82(), false),
5303
- field2("options", binary2(), true)
5304
- ]),
5922
+ params: CatalogCreateParamsSchema,
5305
5923
  result: emptyResultSchema,
5306
5924
  handler: async (params) => {
5307
5925
  const cat = getCatalog();
@@ -5310,7 +5928,7 @@ function registerCatalogAdminMethods(protocol, getCatalog, signingKey) {
5310
5928
  }
5311
5929
  });
5312
5930
  catalogUnary(protocol, signingKey, "catalog_drop", {
5313
- params: schema2([field2("name", utf82(), false)]),
5931
+ params: CatalogDropParamsSchema,
5314
5932
  result: emptyResultSchema,
5315
5933
  handler: async (params) => {
5316
5934
  const cat = getCatalog();
@@ -5319,7 +5937,7 @@ function registerCatalogAdminMethods(protocol, getCatalog, signingKey) {
5319
5937
  }
5320
5938
  });
5321
5939
  catalogUnary(protocol, signingKey, "catalog_version", {
5322
- params: attachOpaqueDataTxnParams,
5940
+ params: CatalogVersionParamsSchema,
5323
5941
  result: RESULT_BINARY_SCHEMA,
5324
5942
  handler: async (params) => {
5325
5943
  const cat = getCatalog();
@@ -5328,7 +5946,7 @@ function registerCatalogAdminMethods(protocol, getCatalog, signingKey) {
5328
5946
  }
5329
5947
  });
5330
5948
  protocol.unary("catalog_transaction_begin", {
5331
- params: attachOpaqueDataParam,
5949
+ params: CatalogTransactionBeginParamsSchema,
5332
5950
  result: RESULT_BINARY_SCHEMA,
5333
5951
  handler: async (params, ctx) => {
5334
5952
  const auth = ctx?.auth;
@@ -5341,7 +5959,7 @@ function registerCatalogAdminMethods(protocol, getCatalog, signingKey) {
5341
5959
  }
5342
5960
  });
5343
5961
  catalogUnary(protocol, signingKey, "catalog_transaction_commit", {
5344
- params: attachOpaqueDataTxnParams,
5962
+ params: CatalogTransactionCommitParamsSchema,
5345
5963
  result: emptyResultSchema,
5346
5964
  handler: async (params) => {
5347
5965
  const cat = getCatalog();
@@ -5350,7 +5968,7 @@ function registerCatalogAdminMethods(protocol, getCatalog, signingKey) {
5350
5968
  }
5351
5969
  });
5352
5970
  catalogUnary(protocol, signingKey, "catalog_transaction_rollback", {
5353
- params: attachOpaqueDataTxnParams,
5971
+ params: CatalogTransactionRollbackParamsSchema,
5354
5972
  result: emptyResultSchema,
5355
5973
  handler: async (params) => {
5356
5974
  const cat = getCatalog();
@@ -5359,7 +5977,7 @@ function registerCatalogAdminMethods(protocol, getCatalog, signingKey) {
5359
5977
  }
5360
5978
  });
5361
5979
  catalogUnary(protocol, signingKey, "catalog_schemas", {
5362
- params: attachOpaqueDataTxnParams,
5980
+ params: CatalogSchemasParamsSchema,
5363
5981
  result: RESULT_BINARY_SCHEMA,
5364
5982
  handler: async (params) => {
5365
5983
  const cat = getCatalog();
@@ -5370,7 +5988,7 @@ function registerCatalogAdminMethods(protocol, getCatalog, signingKey) {
5370
5988
  }
5371
5989
  });
5372
5990
  catalogUnary(protocol, signingKey, "catalog_copy_from_formats", {
5373
- params: attachOpaqueDataTxnParams,
5991
+ params: CatalogCopyFromFormatsParamsSchema,
5374
5992
  result: RESULT_BINARY_SCHEMA,
5375
5993
  handler: async (params) => {
5376
5994
  const cat = getCatalog();
@@ -5381,79 +5999,62 @@ function registerCatalogAdminMethods(protocol, getCatalog, signingKey) {
5381
5999
  }
5382
6000
  });
5383
6001
  catalogUnary(protocol, signingKey, "catalog_schema_get", {
5384
- params: attachOpaqueDataNameTxnParams,
6002
+ params: CatalogSchemaGetParamsSchema,
5385
6003
  result: RESULT_BINARY_SCHEMA,
5386
6004
  handler: async (params) => {
5387
6005
  const cat = getCatalog();
5388
- const info = await cat.schemaGet(toUint8Array(params.attach_opaque_data), params.name, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
6006
+ const info = await cat.schemaGet(toUint8Array(params.attach_opaque_data), params.path, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
5389
6007
  return wrapResult({
5390
6008
  items: info ? [encodeSchemaInfo(info)] : []
5391
6009
  }, CatalogSchemaGetResultSchema);
5392
6010
  }
5393
6011
  });
5394
6012
  catalogUnary(protocol, signingKey, "catalog_schema_create", {
5395
- params: schema2([
5396
- field2("attach_opaque_data", binary2(), true),
5397
- field2("name", utf82(), false),
5398
- field2("comment", utf82(), true),
5399
- field2("tags", binary2(), true),
5400
- field2("transaction_opaque_data", binary2(), true)
5401
- ]),
6013
+ params: CatalogSchemaCreateParamsSchema,
5402
6014
  result: emptyResultSchema,
5403
6015
  handler: async (params) => {
5404
6016
  const cat = getCatalog();
5405
- await cat.schemaCreate(toUint8Array(params.attach_opaque_data), params.name, params.comment, null, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
6017
+ await cat.schemaCreate(toUint8Array(params.attach_opaque_data), params.path, params.comment, null, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
5406
6018
  return {};
5407
6019
  }
5408
6020
  });
5409
6021
  catalogUnary(protocol, signingKey, "catalog_schema_drop", {
5410
- params: schema2([
5411
- field2("attach_opaque_data", binary2(), true),
5412
- field2("name", utf82(), false),
5413
- field2("ignore_not_found", bool2(), true),
5414
- field2("cascade", bool2(), true),
5415
- field2("transaction_opaque_data", binary2(), true)
5416
- ]),
6022
+ params: CatalogSchemaDropParamsSchema,
5417
6023
  result: emptyResultSchema,
5418
6024
  handler: async (params) => {
5419
6025
  const cat = getCatalog();
5420
- await cat.schemaDrop(toUint8Array(params.attach_opaque_data), params.name, params.ignore_not_found, params.cascade, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
6026
+ await cat.schemaDrop(toUint8Array(params.attach_opaque_data), params.path, params.ignore_not_found, params.cascade, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
5421
6027
  return {};
5422
6028
  }
5423
6029
  });
5424
6030
  catalogUnary(protocol, signingKey, "catalog_schema_contents_tables", {
5425
- params: attachOpaqueDataNameTxnParams,
6031
+ params: CatalogSchemaContentsTablesParamsSchema,
5426
6032
  result: RESULT_BINARY_SCHEMA,
5427
6033
  handler: async (params) => {
5428
6034
  const cat = getCatalog();
5429
- const tables = await cat.schemaContentsTables(toUint8Array(params.attach_opaque_data), params.name, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
6035
+ const tables = await cat.schemaContentsTables(toUint8Array(params.attach_opaque_data), params.path, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
5430
6036
  return wrapResult({
5431
6037
  items: tables.map((t) => encodeTableInfo(t))
5432
6038
  }, CatalogSchemaContentsTablesResultSchema);
5433
6039
  }
5434
6040
  });
5435
6041
  catalogUnary(protocol, signingKey, "catalog_schema_contents_views", {
5436
- params: attachOpaqueDataNameTxnParams,
6042
+ params: CatalogSchemaContentsViewsParamsSchema,
5437
6043
  result: RESULT_BINARY_SCHEMA,
5438
6044
  handler: async (params) => {
5439
6045
  const cat = getCatalog();
5440
- const views = await cat.schemaContentsViews(toUint8Array(params.attach_opaque_data), params.name, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
6046
+ const views = await cat.schemaContentsViews(toUint8Array(params.attach_opaque_data), params.path, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
5441
6047
  return wrapResult({
5442
6048
  items: views.map((v) => encodeViewInfo(v))
5443
6049
  }, CatalogSchemaContentsViewsResultSchema);
5444
6050
  }
5445
6051
  });
5446
6052
  catalogUnary(protocol, signingKey, "catalog_schema_contents_functions", {
5447
- params: schema2([
5448
- field2("attach_opaque_data", binary2(), true),
5449
- field2("name", utf82(), false),
5450
- field2("type", utf82(), false),
5451
- field2("transaction_opaque_data", binary2(), true)
5452
- ]),
6053
+ params: CatalogSchemaContentsFunctionsParamsSchema,
5453
6054
  result: RESULT_BINARY_SCHEMA,
5454
6055
  handler: async (params) => {
5455
6056
  const cat = getCatalog();
5456
- const funcs = await cat.schemaContentsFunctions(toUint8Array(params.attach_opaque_data), params.name, decodeDictValue(params.type), params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
6057
+ const funcs = await cat.schemaContentsFunctions(toUint8Array(params.attach_opaque_data), params.path, decodeDictValue(params.type), params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
5457
6058
  return wrapResult({
5458
6059
  items: funcs.map((f) => encodeFunctionInfo(f))
5459
6060
  }, CatalogSchemaContentsFunctionsResultSchema);
@@ -5464,223 +6065,148 @@ function registerCatalogAdminMethods(protocol, getCatalog, signingKey) {
5464
6065
  // src/protocol/handlers/catalog/table.ts
5465
6066
  function registerCatalogTableMethods(protocol, getCatalog, signingKey) {
5466
6067
  catalogUnary(protocol, signingKey, "catalog_table_get", {
5467
- params: schema2([
5468
- field2("attach_opaque_data", binary2(), true),
5469
- field2("schema_name", utf82(), false),
5470
- field2("name", utf82(), false),
5471
- field2("at_unit", utf82(), true),
5472
- field2("at_value", utf82(), true),
5473
- field2("transaction_opaque_data", binary2(), true)
5474
- ]),
6068
+ params: CatalogTableGetParamsSchema,
5475
6069
  result: RESULT_BINARY_SCHEMA,
5476
6070
  handler: async (params) => {
5477
6071
  const cat = getCatalog();
5478
- const info = await cat.tableGet(toUint8Array(params.attach_opaque_data), params.schema_name, params.name, params.at_unit, params.at_value, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
6072
+ const info = await cat.tableGet(toUint8Array(params.attach_opaque_data), params.schema_path, params.name, params.at_unit, params.at_value, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
5479
6073
  return wrapResult({
5480
6074
  items: info ? [encodeTableInfo(info)] : []
5481
6075
  }, CatalogTableGetResultSchema);
5482
6076
  }
5483
6077
  });
5484
6078
  catalogUnary(protocol, signingKey, "catalog_table_create", {
5485
- params: schema2([
5486
- field2("attach_opaque_data", binary2(), true),
5487
- field2("schema_name", utf82(), false),
5488
- field2("name", utf82(), false),
5489
- field2("columns", binary2(), false),
5490
- field2("on_conflict", utf82(), false),
5491
- field2("not_null_constraints", list2(field2("item", int322(), false)), true),
5492
- field2("unique_constraints", list2(field2("item", list2(field2("item", int322(), false)), false)), true),
5493
- field2("check_constraints", list2(field2("item", utf82(), false)), true),
5494
- field2("transaction_opaque_data", binary2(), true)
5495
- ]),
6079
+ params: CatalogTableCreateParamsSchema,
5496
6080
  result: emptyResultSchema,
5497
6081
  handler: async (params) => {
5498
6082
  const cat = getCatalog();
5499
- await cat.tableCreate(toUint8Array(params.attach_opaque_data), params.schema_name, params.name, toUint8Array(params.columns), params.on_conflict, params.not_null_constraints ?? [], params.unique_constraints ?? [], params.check_constraints ?? [], params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
6083
+ await cat.tableCreate(toUint8Array(params.attach_opaque_data), params.schema_path, params.name, toUint8Array(params.columns), params.on_conflict, params.not_null_constraints ?? [], params.unique_constraints ?? [], params.check_constraints ?? [], params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
5500
6084
  return {};
5501
6085
  }
5502
6086
  });
5503
6087
  catalogUnary(protocol, signingKey, "catalog_table_drop", {
5504
- params: schema2([
5505
- field2("attach_opaque_data", binary2(), true),
5506
- field2("schema_name", utf82(), false),
5507
- field2("name", utf82(), false),
5508
- field2("ignore_not_found", bool2(), true),
5509
- field2("transaction_opaque_data", binary2(), true)
5510
- ]),
6088
+ params: CatalogTableDropParamsSchema,
5511
6089
  result: emptyResultSchema,
5512
6090
  handler: async (params) => {
5513
6091
  const cat = getCatalog();
5514
- await cat.tableDrop(toUint8Array(params.attach_opaque_data), params.schema_name, params.name, params.ignore_not_found, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
6092
+ await cat.tableDrop(toUint8Array(params.attach_opaque_data), params.schema_path, params.name, params.ignore_not_found, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
5515
6093
  return {};
5516
6094
  }
5517
6095
  });
5518
6096
  catalogUnary(protocol, signingKey, "catalog_table_column_statistics_get", {
5519
- params: schema2([
5520
- field2("attach_opaque_data", binary2(), true),
5521
- field2("schema_name", utf82(), false),
5522
- field2("name", utf82(), false),
5523
- field2("transaction_opaque_data", binary2(), true)
5524
- ]),
6097
+ params: CatalogTableColumnStatisticsGetParamsSchema,
5525
6098
  result: RESULT_BINARY_NULLABLE_SCHEMA,
5526
6099
  handler: async (params) => {
5527
6100
  const cat = getCatalog();
5528
- const stats = await cat.tableColumnStatisticsGet(toUint8Array(params.attach_opaque_data), params.schema_name, params.name, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
6101
+ const stats = await cat.tableColumnStatisticsGet(toUint8Array(params.attach_opaque_data), params.schema_path, params.name, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
5529
6102
  return { result: stats?.bytes ?? null };
5530
6103
  }
5531
6104
  });
5532
6105
  catalogUnary(protocol, signingKey, "catalog_table_scan_function_get", {
5533
- params: schema2([
5534
- field2("attach_opaque_data", binary2(), true),
5535
- field2("schema_name", utf82(), false),
5536
- field2("name", utf82(), false),
5537
- field2("at_unit", utf82(), true),
5538
- field2("at_value", utf82(), true),
5539
- field2("transaction_opaque_data", binary2(), true)
5540
- ]),
6106
+ params: CatalogTableScanFunctionGetParamsSchema,
5541
6107
  result: RESULT_BINARY_SCHEMA,
5542
6108
  handler: async (params) => {
5543
6109
  const cat = getCatalog();
5544
- const scanResult = await cat.tableScanFunctionGet(toUint8Array(params.attach_opaque_data), params.schema_name, params.name, params.at_unit, params.at_value, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
6110
+ const scanResult = await cat.tableScanFunctionGet(toUint8Array(params.attach_opaque_data), params.schema_path, params.name, params.at_unit, params.at_value, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
5545
6111
  return wrapResult(scanResult, ScanFunctionResultSchema);
5546
6112
  }
5547
6113
  });
5548
6114
  catalogUnary(protocol, signingKey, "catalog_table_scan_branches_get", {
5549
- params: schema2([
5550
- field2("attach_opaque_data", binary2(), true),
5551
- field2("schema_name", utf82(), false),
5552
- field2("name", utf82(), false),
5553
- field2("at_unit", utf82(), true),
5554
- field2("at_value", utf82(), true),
5555
- field2("transaction_opaque_data", binary2(), true)
5556
- ]),
6115
+ params: CatalogTableScanBranchesGetParamsSchema,
5557
6116
  result: RESULT_BINARY_SCHEMA,
5558
6117
  handler: async (params) => {
5559
6118
  const cat = getCatalog();
5560
- const branchesResult = await cat.tableScanBranchesGet(toUint8Array(params.attach_opaque_data), params.schema_name, params.name, params.at_unit, params.at_value, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
6119
+ const branchesResult = await cat.tableScanBranchesGet(toUint8Array(params.attach_opaque_data), params.schema_path, params.name, params.at_unit, params.at_value, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
5561
6120
  return wrapResult(branchesResult, ScanBranchesResultSchema);
5562
6121
  }
5563
6122
  });
5564
6123
  catalogUnary(protocol, signingKey, "catalog_table_comment_set", {
5565
- params: schemaNameCommentParams,
6124
+ params: CatalogTableCommentSetParamsSchema,
5566
6125
  result: emptyResultSchema,
5567
6126
  handler: async (params) => {
5568
6127
  const cat = getCatalog();
5569
- await cat.tableCommentSet(toUint8Array(params.attach_opaque_data), params.schema_name, params.name, params.comment, params.ignore_not_found, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
6128
+ await cat.tableCommentSet(toUint8Array(params.attach_opaque_data), params.schema_path, params.name, params.comment, params.ignore_not_found, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
5570
6129
  return {};
5571
6130
  }
5572
6131
  });
5573
6132
  catalogUnary(protocol, signingKey, "catalog_table_rename", {
5574
- params: schemaNameRenameParams,
6133
+ params: CatalogTableRenameParamsSchema,
5575
6134
  result: emptyResultSchema,
5576
6135
  handler: async (params) => {
5577
6136
  const cat = getCatalog();
5578
- await cat.tableRename(toUint8Array(params.attach_opaque_data), params.schema_name, params.name, params.new_name, params.ignore_not_found, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
6137
+ await cat.tableRename(toUint8Array(params.attach_opaque_data), params.schema_path, params.name, params.new_name, params.ignore_not_found, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
5579
6138
  return {};
5580
6139
  }
5581
6140
  });
5582
6141
  catalogUnary(protocol, signingKey, "catalog_table_column_add", {
5583
- params: schema2([
5584
- field2("attach_opaque_data", binary2(), true),
5585
- field2("schema_name", utf82(), false),
5586
- field2("name", utf82(), false),
5587
- field2("column_name", utf82(), false),
5588
- field2("column_type", utf82(), false),
5589
- field2("default_value", utf82(), true),
5590
- field2("ignore_not_found", bool2(), true),
5591
- field2("transaction_opaque_data", binary2(), true)
5592
- ]),
6142
+ params: CatalogTableColumnAddParamsSchema,
5593
6143
  result: emptyResultSchema,
5594
6144
  handler: async (params) => {
5595
6145
  const cat = getCatalog();
5596
- await cat.tableColumnAdd(toUint8Array(params.attach_opaque_data), params.schema_name, params.name, params.column_name, params.column_type, params.default_value, params.ignore_not_found, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
6146
+ await cat.tableColumnAdd(toUint8Array(params.attach_opaque_data), params.schema_path, params.name, params.column_name, params.column_type, params.default_value, params.ignore_not_found, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
5597
6147
  return {};
5598
6148
  }
5599
6149
  });
5600
6150
  catalogUnary(protocol, signingKey, "catalog_table_column_drop", {
5601
- params: columnOpParams,
6151
+ params: CatalogTableColumnDropParamsSchema,
5602
6152
  result: emptyResultSchema,
5603
6153
  handler: async (params) => {
5604
6154
  const cat = getCatalog();
5605
- await cat.tableColumnDrop(toUint8Array(params.attach_opaque_data), params.schema_name, params.name, params.column_name, params.ignore_not_found, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
6155
+ await cat.tableColumnDrop(toUint8Array(params.attach_opaque_data), params.schema_path, params.name, params.column_name, params.ignore_not_found, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
5606
6156
  return {};
5607
6157
  }
5608
6158
  });
5609
6159
  catalogUnary(protocol, signingKey, "catalog_table_column_rename", {
5610
- params: schema2([
5611
- field2("attach_opaque_data", binary2(), true),
5612
- field2("schema_name", utf82(), false),
5613
- field2("name", utf82(), false),
5614
- field2("column_name", utf82(), false),
5615
- field2("new_name", utf82(), false),
5616
- field2("ignore_not_found", bool2(), true),
5617
- field2("transaction_opaque_data", binary2(), true)
5618
- ]),
6160
+ params: CatalogTableColumnRenameParamsSchema,
5619
6161
  result: emptyResultSchema,
5620
6162
  handler: async (params) => {
5621
6163
  const cat = getCatalog();
5622
- await cat.tableColumnRename(toUint8Array(params.attach_opaque_data), params.schema_name, params.name, params.column_name, params.new_name, params.ignore_not_found, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
6164
+ await cat.tableColumnRename(toUint8Array(params.attach_opaque_data), params.schema_path, params.name, params.column_name, params.new_name, params.ignore_not_found, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
5623
6165
  return {};
5624
6166
  }
5625
6167
  });
5626
6168
  catalogUnary(protocol, signingKey, "catalog_table_column_default_set", {
5627
- params: schema2([
5628
- field2("attach_opaque_data", binary2(), true),
5629
- field2("schema_name", utf82(), false),
5630
- field2("name", utf82(), false),
5631
- field2("column_name", utf82(), false),
5632
- field2("default_value", utf82(), false),
5633
- field2("ignore_not_found", bool2(), true),
5634
- field2("transaction_opaque_data", binary2(), true)
5635
- ]),
6169
+ params: CatalogTableColumnDefaultSetParamsSchema,
5636
6170
  result: emptyResultSchema,
5637
6171
  handler: async (params) => {
5638
6172
  const cat = getCatalog();
5639
- await cat.tableColumnDefaultSet(toUint8Array(params.attach_opaque_data), params.schema_name, params.name, params.column_name, params.default_value, params.ignore_not_found, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
6173
+ await cat.tableColumnDefaultSet(toUint8Array(params.attach_opaque_data), params.schema_path, params.name, params.column_name, params.default_value, params.ignore_not_found, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
5640
6174
  return {};
5641
6175
  }
5642
6176
  });
5643
6177
  catalogUnary(protocol, signingKey, "catalog_table_column_default_drop", {
5644
- params: columnOpParams,
6178
+ params: CatalogTableColumnDefaultDropParamsSchema,
5645
6179
  result: emptyResultSchema,
5646
6180
  handler: async (params) => {
5647
6181
  const cat = getCatalog();
5648
- await cat.tableColumnDefaultDrop(toUint8Array(params.attach_opaque_data), params.schema_name, params.name, params.column_name, params.ignore_not_found, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
6182
+ await cat.tableColumnDefaultDrop(toUint8Array(params.attach_opaque_data), params.schema_path, params.name, params.column_name, params.ignore_not_found, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
5649
6183
  return {};
5650
6184
  }
5651
6185
  });
5652
6186
  catalogUnary(protocol, signingKey, "catalog_table_column_type_change", {
5653
- params: schema2([
5654
- field2("attach_opaque_data", binary2(), true),
5655
- field2("schema_name", utf82(), false),
5656
- field2("name", utf82(), false),
5657
- field2("column_name", utf82(), false),
5658
- field2("new_type", utf82(), false),
5659
- field2("ignore_not_found", bool2(), true),
5660
- field2("transaction_opaque_data", binary2(), true)
5661
- ]),
6187
+ params: CatalogTableColumnTypeChangeParamsSchema,
5662
6188
  result: emptyResultSchema,
5663
6189
  handler: async (params) => {
5664
6190
  const cat = getCatalog();
5665
- await cat.tableColumnTypeChange(toUint8Array(params.attach_opaque_data), params.schema_name, params.name, params.column_name, params.new_type, params.ignore_not_found, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
6191
+ await cat.tableColumnTypeChange(toUint8Array(params.attach_opaque_data), params.schema_path, params.name, params.column_name, params.new_type, params.ignore_not_found, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
5666
6192
  return {};
5667
6193
  }
5668
6194
  });
5669
6195
  catalogUnary(protocol, signingKey, "catalog_table_not_null_set", {
5670
- params: columnOpParams,
6196
+ params: CatalogTableNotNullSetParamsSchema,
5671
6197
  result: emptyResultSchema,
5672
6198
  handler: async (params) => {
5673
6199
  const cat = getCatalog();
5674
- await cat.tableNotNullSet(toUint8Array(params.attach_opaque_data), params.schema_name, params.name, params.column_name, params.ignore_not_found, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
6200
+ await cat.tableNotNullSet(toUint8Array(params.attach_opaque_data), params.schema_path, params.name, params.column_name, params.ignore_not_found, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
5675
6201
  return {};
5676
6202
  }
5677
6203
  });
5678
6204
  catalogUnary(protocol, signingKey, "catalog_table_not_null_drop", {
5679
- params: columnOpParams,
6205
+ params: CatalogTableNotNullDropParamsSchema,
5680
6206
  result: emptyResultSchema,
5681
6207
  handler: async (params) => {
5682
6208
  const cat = getCatalog();
5683
- await cat.tableNotNullDrop(toUint8Array(params.attach_opaque_data), params.schema_name, params.name, params.column_name, params.ignore_not_found, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
6209
+ await cat.tableNotNullDrop(toUint8Array(params.attach_opaque_data), params.schema_path, params.name, params.column_name, params.ignore_not_found, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
5684
6210
  return {};
5685
6211
  }
5686
6212
  });
@@ -5689,56 +6215,49 @@ function registerCatalogTableMethods(protocol, getCatalog, signingKey) {
5689
6215
  // src/protocol/handlers/catalog/view.ts
5690
6216
  function registerCatalogViewMethods(protocol, getCatalog, signingKey) {
5691
6217
  catalogUnary(protocol, signingKey, "catalog_view_get", {
5692
- params: attachOpaqueDataSchemaNameTxnParams,
6218
+ params: CatalogViewGetParamsSchema,
5693
6219
  result: RESULT_BINARY_SCHEMA,
5694
6220
  handler: async (params) => {
5695
6221
  const cat = getCatalog();
5696
- const info = await cat.viewGet(toUint8Array(params.attach_opaque_data), params.schema_name, params.name, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
6222
+ const info = await cat.viewGet(toUint8Array(params.attach_opaque_data), params.schema_path, params.name, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
5697
6223
  return wrapResult({
5698
6224
  items: info ? [encodeViewInfo(info)] : []
5699
6225
  }, CatalogViewGetResultSchema);
5700
6226
  }
5701
6227
  });
5702
6228
  catalogUnary(protocol, signingKey, "catalog_view_create", {
5703
- params: schema2([
5704
- field2("attach_opaque_data", binary2(), true),
5705
- field2("schema_name", utf82(), false),
5706
- field2("name", utf82(), false),
5707
- field2("definition", utf82(), false),
5708
- field2("on_conflict", utf82(), false),
5709
- field2("transaction_opaque_data", binary2(), true)
5710
- ]),
6229
+ params: CatalogViewCreateParamsSchema,
5711
6230
  result: emptyResultSchema,
5712
6231
  handler: async (params) => {
5713
6232
  const cat = getCatalog();
5714
- await cat.viewCreate(toUint8Array(params.attach_opaque_data), params.schema_name, params.name, params.definition, params.on_conflict, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
6233
+ await cat.viewCreate(toUint8Array(params.attach_opaque_data), params.schema_path, params.name, params.definition, params.on_conflict, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
5715
6234
  return {};
5716
6235
  }
5717
6236
  });
5718
6237
  catalogUnary(protocol, signingKey, "catalog_view_drop", {
5719
- params: schemaNameIgnoreNotFoundTxnParams,
6238
+ params: CatalogViewDropParamsSchema,
5720
6239
  result: emptyResultSchema,
5721
6240
  handler: async (params) => {
5722
6241
  const cat = getCatalog();
5723
- await cat.viewDrop(toUint8Array(params.attach_opaque_data), params.schema_name, params.name, params.ignore_not_found, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
6242
+ await cat.viewDrop(toUint8Array(params.attach_opaque_data), params.schema_path, params.name, params.ignore_not_found, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
5724
6243
  return {};
5725
6244
  }
5726
6245
  });
5727
6246
  catalogUnary(protocol, signingKey, "catalog_view_rename", {
5728
- params: schemaNameRenameParams,
6247
+ params: CatalogViewRenameParamsSchema,
5729
6248
  result: emptyResultSchema,
5730
6249
  handler: async (params) => {
5731
6250
  const cat = getCatalog();
5732
- await cat.viewRename(toUint8Array(params.attach_opaque_data), params.schema_name, params.name, params.new_name, params.ignore_not_found, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
6251
+ await cat.viewRename(toUint8Array(params.attach_opaque_data), params.schema_path, params.name, params.new_name, params.ignore_not_found, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
5733
6252
  return {};
5734
6253
  }
5735
6254
  });
5736
6255
  catalogUnary(protocol, signingKey, "catalog_view_comment_set", {
5737
- params: schemaNameCommentParams,
6256
+ params: CatalogViewCommentSetParamsSchema,
5738
6257
  result: emptyResultSchema,
5739
6258
  handler: async (params) => {
5740
6259
  const cat = getCatalog();
5741
- await cat.viewCommentSet(toUint8Array(params.attach_opaque_data), params.schema_name, params.name, params.comment, params.ignore_not_found, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
6260
+ await cat.viewCommentSet(toUint8Array(params.attach_opaque_data), params.schema_path, params.name, params.comment, params.ignore_not_found, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
5742
6261
  return {};
5743
6262
  }
5744
6263
  });
@@ -5747,52 +6266,41 @@ function registerCatalogViewMethods(protocol, getCatalog, signingKey) {
5747
6266
  // src/protocol/handlers/catalog/macro.ts
5748
6267
  function registerCatalogMacroMethods(protocol, getCatalog, signingKey) {
5749
6268
  catalogUnary(protocol, signingKey, "catalog_macro_get", {
5750
- params: attachOpaqueDataSchemaNameTxnParams,
6269
+ params: CatalogMacroGetParamsSchema,
5751
6270
  result: RESULT_BINARY_SCHEMA,
5752
6271
  handler: async (params) => {
5753
6272
  const cat = getCatalog();
5754
- const info = await cat.macroGet(toUint8Array(params.attach_opaque_data), params.schema_name, params.name, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
6273
+ const info = await cat.macroGet(toUint8Array(params.attach_opaque_data), params.schema_path, params.name, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
5755
6274
  return wrapResult({
5756
6275
  items: info ? [encodeMacroInfo(info)] : []
5757
6276
  }, CatalogMacroGetResultSchema);
5758
6277
  }
5759
6278
  });
5760
6279
  catalogUnary(protocol, signingKey, "catalog_macro_create", {
5761
- params: REQUEST_PARAMS_SCHEMA,
6280
+ params: CatalogMacroCreateParamsSchema,
5762
6281
  result: emptyResultSchema,
5763
6282
  handler: async (params) => {
5764
6283
  const cat = getCatalog();
5765
6284
  const innerParams = unwrapRequest(params.request);
5766
- await cat.macroCreate(toUint8Array(innerParams.attach_opaque_data), innerParams.schema_name, innerParams.name, innerParams.macro_type, innerParams.parameters ? Array.isArray(innerParams.parameters) ? innerParams.parameters : [...innerParams.parameters] : [], innerParams.definition, innerParams.on_conflict, innerParams.parameter_default_values ? toUint8Array(innerParams.parameter_default_values) : null, innerParams.arguments_schema ? toUint8Array(innerParams.arguments_schema) : null, innerParams.transaction_opaque_data ? toUint8Array(innerParams.transaction_opaque_data) : undefined);
6285
+ await cat.macroCreate(toUint8Array(innerParams.attach_opaque_data), innerParams.schema_path, innerParams.name, innerParams.macro_type, innerParams.parameters ? Array.isArray(innerParams.parameters) ? innerParams.parameters : [...innerParams.parameters] : [], innerParams.definition, innerParams.on_conflict, innerParams.parameter_default_values ? toUint8Array(innerParams.parameter_default_values) : null, innerParams.arguments_schema ? toUint8Array(innerParams.arguments_schema) : null, innerParams.transaction_opaque_data ? toUint8Array(innerParams.transaction_opaque_data) : undefined);
5767
6286
  return {};
5768
6287
  }
5769
6288
  });
5770
6289
  catalogUnary(protocol, signingKey, "catalog_macro_drop", {
5771
- params: schema2([
5772
- field2("attach_opaque_data", binary2(), true),
5773
- field2("schema_name", utf82(), false),
5774
- field2("name", utf82(), false),
5775
- field2("ignore_not_found", bool2(), true),
5776
- field2("transaction_opaque_data", binary2(), true)
5777
- ]),
6290
+ params: CatalogMacroDropParamsSchema,
5778
6291
  result: emptyResultSchema,
5779
6292
  handler: async (params) => {
5780
6293
  const cat = getCatalog();
5781
- await cat.macroDrop(toUint8Array(params.attach_opaque_data), params.schema_name, params.name, params.ignore_not_found, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
6294
+ await cat.macroDrop(toUint8Array(params.attach_opaque_data), params.schema_path, params.name, params.ignore_not_found, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
5782
6295
  return {};
5783
6296
  }
5784
6297
  });
5785
6298
  catalogUnary(protocol, signingKey, "catalog_schema_contents_macros", {
5786
- params: schema2([
5787
- field2("attach_opaque_data", binary2(), true),
5788
- field2("name", utf82(), false),
5789
- field2("type", utf82(), false),
5790
- field2("transaction_opaque_data", binary2(), true)
5791
- ]),
6299
+ params: CatalogSchemaContentsMacrosParamsSchema,
5792
6300
  result: RESULT_BINARY_SCHEMA,
5793
6301
  handler: async (params) => {
5794
6302
  const cat = getCatalog();
5795
- const macros = await cat.schemaContentsMacros(toUint8Array(params.attach_opaque_data), params.name, decodeDictValue(params.type), params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
6303
+ const macros = await cat.schemaContentsMacros(toUint8Array(params.attach_opaque_data), params.path, decodeDictValue(params.type), params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
5796
6304
  return wrapResult({
5797
6305
  items: macros.map((m) => encodeMacroInfo(m))
5798
6306
  }, CatalogSchemaContentsMacrosResultSchema);
@@ -5803,31 +6311,22 @@ function registerCatalogMacroMethods(protocol, getCatalog, signingKey) {
5803
6311
  // src/protocol/handlers/catalog/index_methods.ts
5804
6312
  function registerCatalogIndexMethods(protocol, getCatalog, signingKey) {
5805
6313
  catalogUnary(protocol, signingKey, "catalog_schema_contents_indexes", {
5806
- params: schema2([
5807
- field2("attach_opaque_data", binary2(), true),
5808
- field2("name", utf82(), false),
5809
- field2("transaction_opaque_data", binary2(), true)
5810
- ]),
6314
+ params: CatalogSchemaContentsIndexesParamsSchema,
5811
6315
  result: RESULT_BINARY_SCHEMA,
5812
6316
  handler: async (params) => {
5813
6317
  const cat = getCatalog();
5814
- const indexes = await cat.schemaContentsIndexes(toUint8Array(params.attach_opaque_data), params.name, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
6318
+ const indexes = await cat.schemaContentsIndexes(toUint8Array(params.attach_opaque_data), params.path, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
5815
6319
  return wrapResult({
5816
6320
  items: indexes.map((i) => encodeIndexInfo(i))
5817
6321
  }, CatalogSchemaContentsIndexesResultSchema);
5818
6322
  }
5819
6323
  });
5820
6324
  catalogUnary(protocol, signingKey, "catalog_index_get", {
5821
- params: schema2([
5822
- field2("attach_opaque_data", binary2(), true),
5823
- field2("schema_name", utf82(), false),
5824
- field2("name", utf82(), false),
5825
- field2("transaction_opaque_data", binary2(), true)
5826
- ]),
6325
+ params: CatalogIndexGetParamsSchema,
5827
6326
  result: RESULT_BINARY_SCHEMA,
5828
6327
  handler: async (params) => {
5829
6328
  const cat = getCatalog();
5830
- const info = await cat.indexGet(toUint8Array(params.attach_opaque_data), params.schema_name, params.name, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
6329
+ const info = await cat.indexGet(toUint8Array(params.attach_opaque_data), params.schema_path, params.name, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
5831
6330
  return wrapResult({
5832
6331
  items: info ? [encodeIndexInfo(info)] : []
5833
6332
  }, CatalogIndexGetResultSchema);
@@ -5847,7 +6346,7 @@ function registerCatalogMethods(protocol, catalog, _catalogName, signingKey) {
5847
6346
 
5848
6347
  // src/protocol/dispatch.ts
5849
6348
  function buildVgiProtocol(config) {
5850
- const protocol = new Protocol("vgi");
6349
+ const protocol = new Protocol("vgi", { protocolVersion: "2.0.0" });
5851
6350
  registerFunctionMethods(protocol, {
5852
6351
  registry: config.registry,
5853
6352
  recoverExchangeState: config.recoverExchangeState,
@@ -5909,9 +6408,9 @@ function notModified(request, etag, extra) {
5909
6408
  }
5910
6409
  function createLandingRoutes(info) {
5911
6410
  return (request, ctx) => {
5912
- const path2 = ctx.url.pathname;
6411
+ const path = ctx.url.pathname;
5913
6412
  const { prefix } = ctx;
5914
- if (path2 === prefix || path2 === `${prefix}/`) {
6413
+ if (path === prefix || path === `${prefix}/`) {
5915
6414
  const accept = request.headers.get("Accept") ?? "";
5916
6415
  const wantJson = ctx.url.searchParams.get("format") === "json" || accept.includes("application/json") && !accept.includes("text/html");
5917
6416
  if (wantJson) {
@@ -5926,9 +6425,9 @@ function createLandingRoutes(info) {
5926
6425
  oauth: ctx.oauthActive,
5927
6426
  cupola_base: info.cupolaBase ?? DEFAULT_CUPOLA_BASE
5928
6427
  });
5929
- const headers2 = new Headers({ "Content-Type": "application/json" });
5930
- ctx.addCorsHeaders(headers2);
5931
- return new Response(body, { status: 200, headers: headers2 });
6428
+ const headers = new Headers({ "Content-Type": "application/json" });
6429
+ ctx.addCorsHeaders(headers);
6430
+ return new Response(body, { status: 200, headers });
5932
6431
  }
5933
6432
  landingEtag ??= etagFor(LANDING_HTML_BYTES);
5934
6433
  const conditional = notModified(request, landingEtag);
@@ -5944,7 +6443,7 @@ function createLandingRoutes(info) {
5944
6443
  ctx.addCorsHeaders(headers);
5945
6444
  return new Response(LANDING_HTML_BYTES, { status: 200, headers });
5946
6445
  }
5947
- if (path2 === `${prefix}/vgi-client.js`) {
6446
+ if (path === `${prefix}/vgi-client.js`) {
5948
6447
  bundleEtag ??= etagFor(CLIENT_BUNDLE_BYTES);
5949
6448
  const conditional = notModified(request, bundleEtag);
5950
6449
  if (conditional) {
@@ -5964,9 +6463,35 @@ function createLandingRoutes(info) {
5964
6463
  }
5965
6464
 
5966
6465
  // src/http/fetch.ts
6466
+ var requestAuthStorage;
6467
+ var requestAuthStoragePending;
6468
+ function ensureRequestAuthStorage() {
6469
+ if (requestAuthStorage !== undefined)
6470
+ return Promise.resolve(requestAuthStorage);
6471
+ requestAuthStoragePending ??= import("async_hooks").then((mod) => {
6472
+ const storage = new mod.AsyncLocalStorage;
6473
+ requestAuthStorage = storage;
6474
+ setRequestAuthScope(storage);
6475
+ return storage;
6476
+ }).catch(() => {
6477
+ requestAuthStorage = null;
6478
+ return null;
6479
+ });
6480
+ return requestAuthStoragePending;
6481
+ }
6482
+ var REQUEST_AUTH_DISPATCH_HOOK = {
6483
+ onDispatchStart(info) {
6484
+ const holder = requestAuthStorage?.getStore();
6485
+ if (holder) {
6486
+ holder.auth = info.authenticated ? new AuthContext(info.authDomain ?? "", true, info.principal ?? "", info.claims ?? {}) : AuthContext.anonymous();
6487
+ }
6488
+ return;
6489
+ },
6490
+ onDispatchEnd() {}
6491
+ };
5967
6492
  function createVgiFetch(opts) {
5968
6493
  if (!opts.landingInfo) {
5969
- throw new Error("createVgiFetch requires `landingInfo` ({ name, doc, version }). Without it " + "GET / serves vgi-rpc's generic placeholder instead of the VGI landing page " + "and GET /vgi-client.js 404s.");
6494
+ throw new Error("createVgiFetch requires `landingInfo` ({ name, doc, version }). Without it GET / serves vgi-rpc's generic placeholder instead of the VGI landing page and GET /vgi-client.js 404s.");
5970
6495
  }
5971
6496
  const tokenTtl = opts.tokenTtl ?? 3600;
5972
6497
  const prefix = opts.prefix ?? "/vgi";
@@ -5986,20 +6511,30 @@ function createVgiFetch(opts) {
5986
6511
  tokenKey: opts.signingKey,
5987
6512
  tokenTtl,
5988
6513
  stateSerializer: arrowStateSerializer,
6514
+ dispatchHook: REQUEST_AUTH_DISPATCH_HOOK,
6515
+ authenticate: opts.authenticate,
6516
+ peerIdentityProviders: opts.peerIdentityProviders,
6517
+ peerAuthenticationPolicy: opts.peerAuthenticationPolicy,
6518
+ peerResolutionContext: opts.peerResolutionContext,
5989
6519
  corsOrigins: opts.corsOrigins === null ? undefined : opts.corsOrigins ?? "*",
5990
6520
  repositoryUrl: opts.repositoryUrl,
5991
6521
  extraRoutes: createLandingRoutes(opts.landingInfo),
5992
6522
  enableLandingPage: false
5993
6523
  });
5994
- return async (req) => handler(req);
6524
+ return async (req) => {
6525
+ const storage = await ensureRequestAuthStorage();
6526
+ if (!storage)
6527
+ return handler(req);
6528
+ return storage.run({}, () => handler(req));
6529
+ };
5995
6530
  }
5996
6531
 
5997
6532
  // src/serve-entry.ts
5998
6533
  var DEFAULT_PORT = 8787;
5999
6534
  var DEFAULT_TOKEN_TTL = 3600;
6000
6535
  var SIGNING_KEY_BYTES = 32;
6001
- function parseSigningKeyHex(hex2) {
6002
- const cleaned = hex2.trim();
6536
+ function parseSigningKeyHex(hex) {
6537
+ const cleaned = hex.trim();
6003
6538
  const expected = SIGNING_KEY_BYTES * 2;
6004
6539
  if (cleaned.length !== expected || !/^[0-9a-fA-F]+$/.test(cleaned)) {
6005
6540
  throw new Error(`VGI_SIGNING_KEY must be exactly ${expected} hex characters ` + `(${SIGNING_KEY_BYTES} bytes); got ${cleaned.length}. ` + `Generate one with: openssl rand -hex ${SIGNING_KEY_BYTES}`);
@@ -6055,6 +6590,11 @@ function createVgiWorkerFetch(opts) {
6055
6590
  const signingKey = resolveSigningKey(opts.signingKey, env);
6056
6591
  const tokenTtl = resolveTokenTtl(opts.tokenTtl, env);
6057
6592
  const corsOrigins = opts.corsOrigins === null ? null : opts.corsOrigins ?? env.CORS_ORIGINS;
6593
+ const bridge = opts.irohBridge;
6594
+ if (bridge && !bridge.peerResolutionContext) {
6595
+ throw new Error("irohBridge requires a peerResolutionContext when createVgiWorkerFetch is used without serveVgiWorker");
6596
+ }
6597
+ const trustedProxyAddresses = bridge?.trustedProxyAddresses ?? ["127.0.0.1"];
6058
6598
  return createVgiFetch({
6059
6599
  protocol: { registry: opts.registry, catalogInterface: opts.catalogInterface },
6060
6600
  signingKey,
@@ -6063,7 +6603,11 @@ function createVgiWorkerFetch(opts) {
6063
6603
  serverId: opts.serverId ?? opts.name,
6064
6604
  corsOrigins,
6065
6605
  repositoryUrl: opts.repositoryUrl,
6066
- landingInfo: { name: opts.name, doc: opts.doc, version: opts.version }
6606
+ landingInfo: { name: opts.name, doc: opts.doc, version: opts.version },
6607
+ authenticate: opts.authenticate,
6608
+ peerIdentityProviders: bridge ? [irohForwardedHeaderIdentityProvider({ issuer: bridge.issuer, trustedProxyAddresses })] : undefined,
6609
+ peerAuthenticationPolicy: bridge ? bridge.authenticate === false ? observePeerIdentity : peerIdentityPrimary("iroh") : undefined,
6610
+ peerResolutionContext: bridge?.peerResolutionContext
6067
6611
  });
6068
6612
  }
6069
6613
  function serveVgiWorker(opts) {
@@ -6073,8 +6617,24 @@ function serveVgiWorker(opts) {
6073
6617
  }
6074
6618
  const env = opts.env ?? process.env;
6075
6619
  const port = resolvePort(opts.port, env);
6076
- const fetch2 = createVgiWorkerFetch(opts);
6077
- const server = runtime.serve({ port, fetch: fetch2 });
6620
+ const hostname = opts.hostname ?? (opts.irohBridge ? "127.0.0.1" : undefined);
6621
+ if (opts.irohBridge && !["127.0.0.1", "::1", "localhost"].includes(hostname ?? "")) {
6622
+ throw new Error("an Iroh HTTP bridge upstream must bind loopback");
6623
+ }
6624
+ let server;
6625
+ const bridge = opts.irohBridge && !opts.irohBridge.peerResolutionContext ? {
6626
+ ...opts.irohBridge,
6627
+ peerResolutionContext(request) {
6628
+ const immediatePeer = server.requestIP?.(request)?.address;
6629
+ const forwarded = request.headers.get(IROH_FORWARDED_ENDPOINT_HEADER);
6630
+ return {
6631
+ immediatePeer,
6632
+ headers: forwarded === null ? {} : { [IROH_FORWARDED_ENDPOINT_HEADER]: [forwarded] }
6633
+ };
6634
+ }
6635
+ } : opts.irohBridge;
6636
+ const fetch2 = createVgiWorkerFetch({ ...opts, irohBridge: bridge });
6637
+ server = runtime.serve({ port, hostname, fetch: fetch2 });
6078
6638
  if (!opts.quiet) {
6079
6639
  const base = `http://localhost:${server.port}`;
6080
6640
  console.log(`${opts.name} VGI HTTP worker listening on ${base}`);
@@ -6086,13 +6646,13 @@ function serveVgiWorker(opts) {
6086
6646
  return server;
6087
6647
  }
6088
6648
  export {
6089
- serveVgiWorker,
6090
- resolveSigningKey,
6091
- parseSigningKeyHex,
6092
- createVgiWorkerFetch,
6093
- SIGNING_KEY_BYTES,
6649
+ DEFAULT_PORT,
6094
6650
  DEFAULT_TOKEN_TTL,
6095
- DEFAULT_PORT
6651
+ SIGNING_KEY_BYTES,
6652
+ createVgiWorkerFetch,
6653
+ parseSigningKeyHex,
6654
+ resolveSigningKey,
6655
+ serveVgiWorker
6096
6656
  };
6097
6657
 
6098
- //# debugId=AF152B2CA425E9C164756E2164756E21
6658
+ //# debugId=3C4394ABF730E98C64756E2164756E21