@query-farm/vgi 0.28.0 → 0.29.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/README.md +26 -7
  2. package/dist/arguments/argument-spec.d.ts +53 -0
  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/interface.d.ts +43 -0
  13. package/dist/client/client.d.ts +1 -1
  14. package/dist/client-entry.js +360 -178
  15. package/dist/client-entry.js.map +14 -14
  16. package/dist/functions/table.d.ts +63 -0
  17. package/dist/functions/types.d.ts +38 -0
  18. package/dist/generated/vgi-client.d.ts +59 -0
  19. package/dist/generated/vgi-protocol-schemas.d.ts +19 -0
  20. package/dist/http/fetch.d.ts +10 -0
  21. package/dist/index.core.d.ts +2 -2
  22. package/dist/index.js +1203 -834
  23. package/dist/index.js.map +40 -37
  24. package/dist/protocol/handlers/catalog/shared.d.ts +0 -8
  25. package/dist/protocol/handlers/function.d.ts +11 -0
  26. package/dist/protocol/serializers/bind.d.ts +1 -2
  27. package/dist/protocol/serializers/cardinality.d.ts +1 -2
  28. package/dist/protocol/serializers/splits.d.ts +126 -0
  29. package/dist/protocol/types.d.ts +27 -0
  30. package/dist/request-auth.d.ts +28 -0
  31. package/dist/serve-entry.d.ts +4 -0
  32. package/dist/serve-entry.js +745 -359
  33. package/dist/serve-entry.js.map +32 -29
  34. package/dist/split-token.d.ts +88 -0
  35. package/dist/worker-cf-entry.js +1029 -619
  36. package/dist/worker-cf-entry.js.map +37 -34
  37. package/package.json +3 -3
  38. package/src/arguments/argument-spec.ts +81 -0
  39. package/src/arguments/arguments.ts +0 -1
  40. package/src/arrow/impl-arrowjs/index.ts +1 -1
  41. package/src/arrow/impl-arrowjs/iterate.ts +21 -0
  42. package/src/arrow/impl-arrowjs/schema.ts +4 -0
  43. package/src/arrow/impl-flechette/index.ts +1 -1
  44. package/src/arrow/impl-flechette/iterate.ts +24 -1
  45. package/src/arrow/impl-flechette/schema.ts +4 -0
  46. package/src/arrow/index.ts +1 -1
  47. package/src/arrow/schema-types.ts +4 -0
  48. package/src/arrow/types.ts +39 -3
  49. package/src/catalog/interface.ts +124 -29
  50. package/src/catalog/read-only.ts +18 -18
  51. package/src/client/client.ts +6 -2
  52. package/src/functions/aggregate.ts +3 -0
  53. package/src/functions/copy-from.ts +2 -1
  54. package/src/functions/copy-to.ts +2 -1
  55. package/src/functions/scalar.ts +11 -0
  56. package/src/functions/table-buffering.ts +3 -0
  57. package/src/functions/table-in-out.ts +8 -4
  58. package/src/functions/table.ts +129 -2
  59. package/src/functions/types.ts +40 -0
  60. package/src/generated/vgi-client.ts +63 -1
  61. package/src/generated/vgi-protocol-schemas.ts +240 -14
  62. package/src/http/fetch.ts +117 -2
  63. package/src/index.core.ts +2 -2
  64. package/src/protocol/handlers/aggregate.ts +10 -5
  65. package/src/protocol/handlers/catalog/admin.ts +41 -48
  66. package/src/protocol/handlers/catalog/index_methods.ts +4 -11
  67. package/src/protocol/handlers/catalog/macro.ts +8 -16
  68. package/src/protocol/handlers/catalog/shared.ts +10 -57
  69. package/src/protocol/handlers/catalog/table.ts +33 -96
  70. package/src/protocol/handlers/catalog/view.ts +13 -17
  71. package/src/protocol/handlers/function.ts +311 -18
  72. package/src/protocol/handlers/table-buffering.ts +7 -4
  73. package/src/protocol/serializers/bind.ts +56 -63
  74. package/src/protocol/serializers/cardinality.ts +7 -7
  75. package/src/protocol/serializers/init.ts +52 -10
  76. package/src/protocol/serializers/splits.ts +219 -0
  77. package/src/protocol/state-serializer.ts +55 -1
  78. package/src/protocol/types.ts +27 -0
  79. package/src/request-auth.ts +73 -0
  80. package/src/serve-entry.ts +5 -0
  81. package/src/split-token.ts +297 -0
  82. package/src/worker-cf-entry.ts +2 -1
  83. package/src/worker.ts +30 -10
@@ -37,6 +37,7 @@ var __export = (target, all) => {
37
37
  });
38
38
  };
39
39
  var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
40
+ var __require = import.meta.require;
40
41
 
41
42
  // src/functions/storage-cf-do.ts
42
43
  var exports_storage_cf_do = {};
@@ -531,7 +532,11 @@ var init_storage = __esm(() => {
531
532
  });
532
533
 
533
534
  // src/http/fetch.ts
534
- import { createHttpHandler, unpackStateToken } from "@query-farm/vgi-rpc";
535
+ import {
536
+ AuthContext,
537
+ createHttpHandler,
538
+ unpackStateToken
539
+ } from "@query-farm/vgi-rpc";
535
540
 
536
541
  // src/arrow/predicates.ts
537
542
  var TypeId = {
@@ -560,75 +565,113 @@ var TypeId = {
560
565
  function isDecimal(t) {
561
566
  return t.typeId === TypeId.Decimal;
562
567
  }
568
+ function typeSignature(t) {
569
+ if (t == null)
570
+ return "null";
571
+ const a = t;
572
+ const kids = () => Array.isArray(a.children) ? a.children.map((c) => `${c?.name ?? ""}:${typeSignature(c?.type ?? c)}`).join(",") : "";
573
+ switch (t.typeId) {
574
+ case TypeId.Int:
575
+ return `int${a.bitWidth}${a.isSigned ?? a.signed ?? true ? "" : "u"}`;
576
+ case TypeId.Float:
577
+ return `float${a.precision}`;
578
+ case TypeId.Decimal:
579
+ return `decimal${a.bitWidth ?? 128}(${a.precision},${a.scale})`;
580
+ case TypeId.Date:
581
+ case TypeId.Time:
582
+ case TypeId.Duration:
583
+ return `${t.typeId}[${a.unit}]`;
584
+ case TypeId.Timestamp:
585
+ return `ts[${a.unit},${a.timezone ?? ""}]`;
586
+ case TypeId.Interval:
587
+ return `iv[${a.unit}]`;
588
+ case TypeId.FixedSizeBinary:
589
+ return `fsb(${a.byteWidth ?? a.stride})`;
590
+ case TypeId.FixedSizeList:
591
+ return `fsl(${a.listSize ?? a.stride},${kids()})`;
592
+ case TypeId.List:
593
+ case TypeId.Struct:
594
+ case TypeId.Map:
595
+ return `${t.typeId}<${kids()}>`;
596
+ case TypeId.Union:
597
+ return `union(${a.mode},${kids()})`;
598
+ case TypeId.Dictionary:
599
+ return `dict(${typeSignature(a.dictionary)},${typeSignature(a.indices)},${a.ordered ?? a.isOrdered ?? false})`;
600
+ default:
601
+ return Array.isArray(a.children) ? `${t.typeId}<${kids()}>` : String(t.typeId);
602
+ }
603
+ }
563
604
  // src/arrow/impl-arrowjs/index.ts
564
605
  var exports_impl_arrowjs = {};
565
606
  __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,
607
+ DateUnit: () => DateUnit,
630
608
  IntervalUnit: () => IntervalUnit,
631
- DateUnit: () => DateUnit
609
+ TimeUnit: () => TimeUnit,
610
+ UnionMode: () => UnionMode,
611
+ adoptArrowJsShape: () => adoptArrowJsShape,
612
+ backend: () => backend,
613
+ batchFromColumns: () => batchFromColumns,
614
+ batchFromRows: () => batchFromRows,
615
+ batchToScalarDict: () => batchToScalarDict,
616
+ batchToSecretDict: () => batchToSecretDict,
617
+ binary: () => binary,
618
+ bool: () => bool,
619
+ buildStatisticsBatch: () => buildStatisticsBatch,
620
+ columnFromArray: () => columnFromArray,
621
+ date: () => date,
622
+ dateDay: () => dateDay,
623
+ dateMillisecond: () => dateMillisecond,
624
+ decimal: () => decimal,
625
+ decimal128: () => decimal128,
626
+ decimal256: () => decimal256,
627
+ decodeDictValue: () => decodeDictValue,
628
+ denseUnion: () => denseUnion,
629
+ deserializeBatch: () => deserializeBatch,
630
+ deserializeSchema: () => deserializeSchema,
631
+ dictionary: () => dictionary,
632
+ duration: () => duration,
633
+ emptyBatch: () => emptyBatch,
634
+ field: () => field,
635
+ filterBatch: () => filterBatch,
636
+ fixedSizeBinary: () => fixedSizeBinary,
637
+ fixedSizeList: () => fixedSizeList,
638
+ float16: () => float16,
639
+ float32: () => float32,
640
+ float64: () => float64,
641
+ int: () => int,
642
+ int16: () => int16,
643
+ int32: () => int32,
644
+ int64: () => int64,
645
+ int8: () => int8,
646
+ interval: () => interval,
647
+ iterRows: () => iterRows,
648
+ largeBinary: () => largeBinary,
649
+ largeUtf8: () => largeUtf8,
650
+ list: () => list,
651
+ map: () => map,
652
+ nullType: () => nullType,
653
+ projectBatch: () => projectBatch,
654
+ projectSchema: () => projectSchema,
655
+ readCanonicalValue: () => readCanonicalValue,
656
+ safeNumber: () => safeNumber,
657
+ schema: () => schema,
658
+ serializeBatch: () => serializeBatch,
659
+ serializeSchema: () => serializeSchema,
660
+ sparseUnion: () => sparseUnion,
661
+ struct: () => struct,
662
+ time: () => time,
663
+ timeMicrosecond: () => timeMicrosecond,
664
+ timeMillisecond: () => timeMillisecond,
665
+ timeNanosecond: () => timeNanosecond,
666
+ timeSecond: () => timeSecond,
667
+ timestamp: () => timestamp,
668
+ uint16: () => uint16,
669
+ uint32: () => uint32,
670
+ uint64: () => uint64,
671
+ uint8: () => uint8,
672
+ union: () => union,
673
+ utf8: () => utf8,
674
+ withBatchMetadata: () => withBatchMetadata
632
675
  });
633
676
 
634
677
  // src/arrow/impl-arrowjs/schema.ts
@@ -649,7 +692,9 @@ import {
649
692
  Float32 as A_Float32,
650
693
  Float64 as A_Float64,
651
694
  Utf8 as A_Utf8,
695
+ LargeUtf8 as A_LargeUtf8,
652
696
  Binary as A_Binary,
697
+ LargeBinary as A_LargeBinary,
653
698
  Decimal as A_Decimal,
654
699
  Date_ as A_Date,
655
700
  Time as A_Time,
@@ -734,7 +779,9 @@ var float16 = () => new A_Float16;
734
779
  var float32 = () => new A_Float32;
735
780
  var float64 = () => new A_Float64;
736
781
  var utf8 = () => new A_Utf8;
782
+ var largeUtf8 = () => new A_LargeUtf8;
737
783
  var binary = () => new A_Binary;
784
+ var largeBinary = () => new A_LargeBinary;
738
785
  var fixedSizeBinary = (byteWidth) => new A_FixedSizeBinary(byteWidth);
739
786
  function decimal(precision, scale, bitWidth = 128) {
740
787
  return new A_Decimal(scale, precision, bitWidth);
@@ -2013,8 +2060,13 @@ function batchToSecretDict(batch) {
2013
2060
  }
2014
2061
  return result;
2015
2062
  }
2063
+ var MAX_SAFE = BigInt(Number.MAX_SAFE_INTEGER);
2064
+ var MIN_SAFE = -MAX_SAFE;
2016
2065
  function safeNumber(value) {
2017
2066
  if (typeof value === "bigint") {
2067
+ if (value > MAX_SAFE || value < MIN_SAFE) {
2068
+ throw new RangeError(`${value} cannot be represented exactly as a JS number ` + `(|value| > Number.MAX_SAFE_INTEGER). Keep it as a bigint.`);
2069
+ }
2018
2070
  return Number(value);
2019
2071
  }
2020
2072
  return value;
@@ -2277,6 +2329,7 @@ var int642 = () => int64();
2277
2329
  var float642 = () => float64();
2278
2330
  var utf82 = () => utf8();
2279
2331
  var binary2 = () => binary();
2332
+ var largeBinary2 = () => largeBinary();
2280
2333
  var UNIT_TO_TAG = {
2281
2334
  [TimeUnit.SECOND]: "s",
2282
2335
  [TimeUnit.MILLISECOND]: "ms",
@@ -2324,6 +2377,27 @@ var EXCHANGE_STATE_SCHEMA = schema2([
2324
2377
  ]);
2325
2378
  var TEXT_ENCODER = new TextEncoder;
2326
2379
  var TEXT_DECODER = new TextDecoder;
2380
+ var LIST_CHILD_NAME = "item";
2381
+ var emptyListElementType = () => utf82();
2382
+ function inferElementType(values) {
2383
+ let elementType = null;
2384
+ let elementSig = "";
2385
+ for (const v of values) {
2386
+ if (v === null || v === undefined)
2387
+ continue;
2388
+ const t = inferFieldType(v);
2389
+ const sig = typeSignature(t);
2390
+ if (elementType === null) {
2391
+ elementType = t;
2392
+ elementSig = sig;
2393
+ continue;
2394
+ }
2395
+ if (sig !== elementSig) {
2396
+ 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)`);
2397
+ }
2398
+ }
2399
+ return elementType ?? emptyListElementType();
2400
+ }
2327
2401
  function inferFieldType(value) {
2328
2402
  if (value === null || value === undefined)
2329
2403
  return nullType2();
@@ -2342,7 +2416,7 @@ function inferFieldType(value) {
2342
2416
  if (ArrayBuffer.isView(value))
2343
2417
  return binary2();
2344
2418
  if (Array.isArray(value)) {
2345
- throw new Error(`inferFieldType: arrays are not supported in userState (convert to a serializable form first)`);
2419
+ return list2(field2(LIST_CHILD_NAME, inferElementType(value), true));
2346
2420
  }
2347
2421
  if (value instanceof Map) {
2348
2422
  throw new Error(`inferFieldType: Map is not supported in userState (use a plain object instead)`);
@@ -2583,10 +2657,19 @@ function toUint8Array2(val) {
2583
2657
  }
2584
2658
 
2585
2659
  // src/protocol/serializers/bind.ts
2660
+ var COPY_FROM_STRUCT_TYPE = struct2([
2661
+ field2("format", utf82(), false),
2662
+ field2("file_path", utf82(), false),
2663
+ field2("expected_schema", binary2(), false)
2664
+ ]);
2665
+ var COPY_TO_STRUCT_TYPE = struct2([
2666
+ field2("format", utf82(), false),
2667
+ field2("file_path", utf82(), false)
2668
+ ]);
2586
2669
  var BIND_REQUEST_SCHEMA = schema2([
2587
2670
  field2("function_name", utf82(), false),
2588
2671
  field2("arguments", binary2(), false),
2589
- field2("function_type", utf82(), false),
2672
+ field2("function_type", dictionary2(utf82(), int162()), false),
2590
2673
  field2("input_schema", binary2(), true),
2591
2674
  field2("settings", binary2(), true),
2592
2675
  field2("secrets", binary2(), true),
@@ -2595,26 +2678,10 @@ var BIND_REQUEST_SCHEMA = schema2([
2595
2678
  field2("resolved_secrets_provided", bool2(), false),
2596
2679
  field2("at_unit", utf82(), true),
2597
2680
  field2("at_value", utf82(), true),
2681
+ field2("copy_from", COPY_FROM_STRUCT_TYPE, true),
2682
+ field2("copy_to", COPY_TO_STRUCT_TYPE, true),
2598
2683
  field2("schema_name", utf82(), true)
2599
2684
  ]);
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)
2617
- ]);
2618
2685
  function parseCopyFromContext(raw) {
2619
2686
  if (raw == null)
2620
2687
  return null;
@@ -2684,20 +2751,22 @@ var INIT_REQUEST_SCHEMA = schema2([
2684
2751
  field2("bind_call", binary2(), false),
2685
2752
  field2("output_schema", binary2(), false),
2686
2753
  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),
2754
+ field2("projection_ids", list2(field2("item", int642(), true)), true),
2755
+ field2("pushdown_filters", largeBinary2(), true),
2756
+ field2("join_keys", list2(field2("item", largeBinary2(), true)), true),
2757
+ field2("split_tokens", list2(field2("item", largeBinary2(), true)), true),
2758
+ field2("row_limit", int642(), true),
2759
+ field2("phase", dictionary2(utf82(), int162()), true),
2760
+ field2("finalize_state_id", binary2(), true),
2691
2761
  field2("execution_id", binary2(), true),
2692
2762
  field2("init_opaque_data", binary2(), true),
2693
2763
  field2("substream_id", binary2(), true),
2694
2764
  field2("order_by_column_name", utf82(), true),
2695
- field2("order_by_direction", utf82(), true),
2696
- field2("order_by_null_order", utf82(), true),
2765
+ field2("order_by_direction", dictionary2(utf82(), int162()), true),
2766
+ field2("order_by_null_order", dictionary2(utf82(), int162()), true),
2697
2767
  field2("order_by_limit", int642(), true),
2698
2768
  field2("tablesample_percentage", float642(), true),
2699
- field2("tablesample_seed", int642(), true),
2700
- field2("finalize_state_id", binary2(), true)
2769
+ field2("tablesample_seed", int642(), true)
2701
2770
  ]);
2702
2771
  var GLOBAL_INIT_RESPONSE_SCHEMA = schema2([
2703
2772
  field2("execution_id", binary2(), false),
@@ -2749,10 +2818,19 @@ function deserializeInitRequest(params) {
2749
2818
  output_schema: deserializeSchema(toUint8Array2(params.output_schema)),
2750
2819
  bind_opaque_data: params.bind_opaque_data ? toUint8Array2(params.bind_opaque_data) : null,
2751
2820
  projection_ids: projectionIds,
2821
+ row_limit: params.row_limit == null ? null : Number(params.row_limit),
2752
2822
  pushdown_filters: params.pushdown_filters ? deserializeBatch(toUint8Array2(params.pushdown_filters)) : null,
2753
2823
  join_keys: joinKeys,
2754
2824
  phase,
2755
2825
  finalize_state_id: params.finalize_state_id ? toUint8Array2(params.finalize_state_id) : null,
2826
+ split_tokens: (() => {
2827
+ const raw = params.split_tokens;
2828
+ if (raw == null)
2829
+ return null;
2830
+ const iter = Array.isArray(raw) ? raw : typeof raw[Symbol.iterator] === "function" ? raw : [];
2831
+ const tokens = [...iter].filter((e) => e != null).map((e) => toUint8Array2(e));
2832
+ return tokens.length > 0 ? tokens : null;
2833
+ })(),
2756
2834
  execution_id: params.execution_id ? toUint8Array2(params.execution_id) : null,
2757
2835
  init_opaque_data: params.init_opaque_data ? toUint8Array2(params.init_opaque_data) : null,
2758
2836
  substream_id: params.substream_id ? toUint8Array2(params.substream_id) : null,
@@ -2820,10 +2898,6 @@ function serializeGlobalInitResponse(resp) {
2820
2898
  };
2821
2899
  }
2822
2900
  // src/protocol/serializers/cardinality.ts
2823
- var TABLE_CARDINALITY_SCHEMA = schema2([
2824
- field2("estimate", int642(), true),
2825
- field2("max", int642(), true)
2826
- ]);
2827
2901
  var TABLE_FUNCTION_CARDINALITY_REQUEST_SCHEMA = schema2([
2828
2902
  field2("bind_call", binary2(), false),
2829
2903
  field2("bind_opaque_data", binary2(), true)
@@ -2855,7 +2929,7 @@ var CatalogInfoSchema = schema2([
2855
2929
  field2("implementation_version", utf82(), true),
2856
2930
  field2("data_version_spec", utf82(), true),
2857
2931
  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),
2932
+ 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
2933
  field2("source_url", utf82(), true)
2860
2934
  ]);
2861
2935
  var SchemaInfoSchema = schema2([
@@ -2881,14 +2955,14 @@ var TableInfoSchema = schema2([
2881
2955
  field2("supports_delete", bool2(), false),
2882
2956
  field2("supports_returning", bool2(), false),
2883
2957
  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),
2958
+ field2("scan_function", binary2(), true),
2959
+ field2("insert_function", binary2(), true),
2960
+ field2("update_function", binary2(), true),
2961
+ field2("delete_function", binary2(), true),
2962
+ field2("cardinality_estimate", int642(), true),
2963
+ field2("cardinality_max", int642(), true),
2964
+ field2("column_statistics", binary2(), true),
2965
+ field2("bind_result", binary2(), true),
2892
2966
  field2("required_filters", list2(field2("item", list2(field2("item", utf82(), true)), true)), false)
2893
2967
  ]);
2894
2968
  var ViewInfoSchema = schema2([
@@ -2918,8 +2992,12 @@ var FunctionInfoSchema = schema2([
2918
2992
  field2("late_materialization", bool2(), true),
2919
2993
  field2("supported_expression_filters", list2(field2("item", utf82(), true)), false),
2920
2994
  field2("order_preservation", dictionary2(utf82(), int162()), true),
2921
- field2("max_workers", int322(), false),
2995
+ field2("max_workers", int322(), true),
2922
2996
  field2("supports_batch_index", bool2(), false),
2997
+ field2("supports_splits", bool2(), false),
2998
+ field2("filters_exactly_applied", bool2(), false),
2999
+ field2("supports_positions", bool2(), false),
3000
+ field2("split_token_ttl_seconds", int642(), true),
2923
3001
  field2("partition_kind", dictionary2(utf82(), int162()), false),
2924
3002
  field2("order_dependent", dictionary2(utf82(), int162()), false),
2925
3003
  field2("distinct_dependent", dictionary2(utf82(), int162()), false),
@@ -2940,9 +3018,9 @@ var MacroInfoSchema = schema2([
2940
3018
  field2("schema_name", utf82(), false),
2941
3019
  field2("macro_type", dictionary2(utf82(), int162()), false),
2942
3020
  field2("parameters", list2(field2("item", utf82(), true)), false),
2943
- field2("parameter_default_values", binary2(), false),
3021
+ field2("parameter_default_values", binary2(), true),
2944
3022
  field2("definition", utf82(), false),
2945
- field2("arguments_schema", binary2(), false)
3023
+ field2("arguments_schema", binary2(), true)
2946
3024
  ]);
2947
3025
  var IndexInfoSchema = schema2([
2948
3026
  field2("comment", utf82(), true),
@@ -2981,7 +3059,22 @@ var ScanBranchSchema = schema2([
2981
3059
  field2("writable", bool2(), false),
2982
3060
  field2("source_catalog", utf82(), true),
2983
3061
  field2("source_schema", utf82(), true),
2984
- field2("source_table", utf82(), true)
3062
+ field2("source_table", utf82(), true),
3063
+ field2("format_name", utf82(), true),
3064
+ field2("format_locations", list2(field2("item", utf82(), true)), true),
3065
+ field2("format_options", binary2(), true)
3066
+ ]);
3067
+ var ScanSplitSchema = schema2([
3068
+ field2("payload", binary2(), false),
3069
+ field2("token", binary2(), false),
3070
+ field2("estimated_rows", int642(), true),
3071
+ field2("rows_exact", bool2(), false),
3072
+ field2("estimated_bytes", int642(), true),
3073
+ field2("partition_bounds", binary2(), true),
3074
+ field2("column_statistics", binary2(), true),
3075
+ field2("location_ids", list2(field2("item", int642(), true)), true),
3076
+ field2("start_position", binary2(), true),
3077
+ field2("end_position", binary2(), true)
2985
3078
  ]);
2986
3079
  var AttachCatalogInfoSchema = schema2([
2987
3080
  field2("alias", utf82(), false),
@@ -2992,6 +3085,152 @@ var AttachCatalogInfoSchema = schema2([
2992
3085
  field2("required", bool2(), false),
2993
3086
  field2("secret_ref", utf82(), false)
2994
3087
  ]);
3088
+ var AggregateBindRequestSchema = schema2([
3089
+ field2("function_name", utf82(), false),
3090
+ field2("arguments", binary2(), false),
3091
+ field2("input_schema", binary2(), true),
3092
+ field2("settings", binary2(), true),
3093
+ field2("secrets", binary2(), true),
3094
+ field2("attach_opaque_data", binary2(), true),
3095
+ field2("schema_name", utf82(), true)
3096
+ ]);
3097
+ var AggregateCombineRequestSchema = schema2([
3098
+ field2("function_name", utf82(), false),
3099
+ field2("execution_id", binary2(), false),
3100
+ field2("merge_batch", binary2(), false),
3101
+ field2("attach_opaque_data", binary2(), true),
3102
+ field2("schema_name", utf82(), true)
3103
+ ]);
3104
+ var AggregateDestructorRequestSchema = schema2([
3105
+ field2("function_name", utf82(), false),
3106
+ field2("execution_id", binary2(), false),
3107
+ field2("group_ids_batch", binary2(), false),
3108
+ field2("attach_opaque_data", binary2(), true),
3109
+ field2("schema_name", utf82(), true)
3110
+ ]);
3111
+ var AggregateFinalizeRequestSchema = schema2([
3112
+ field2("function_name", utf82(), false),
3113
+ field2("execution_id", binary2(), false),
3114
+ field2("group_ids_batch", binary2(), false),
3115
+ field2("output_schema", binary2(), false),
3116
+ field2("attach_opaque_data", binary2(), true),
3117
+ field2("schema_name", utf82(), true)
3118
+ ]);
3119
+ var AggregateUpdateRequestSchema = schema2([
3120
+ field2("function_name", utf82(), false),
3121
+ field2("execution_id", binary2(), false),
3122
+ field2("input_batch", binary2(), false),
3123
+ field2("attach_opaque_data", binary2(), true),
3124
+ field2("schema_name", utf82(), true)
3125
+ ]);
3126
+ var BindRequestSchema = schema2([
3127
+ field2("function_name", utf82(), false),
3128
+ field2("arguments", binary2(), false),
3129
+ field2("function_type", dictionary2(utf82(), int162()), false),
3130
+ field2("input_schema", binary2(), true),
3131
+ field2("settings", binary2(), true),
3132
+ field2("secrets", binary2(), true),
3133
+ field2("attach_opaque_data", binary2(), true),
3134
+ field2("transaction_opaque_data", binary2(), true),
3135
+ field2("resolved_secrets_provided", bool2(), false),
3136
+ field2("at_unit", utf82(), true),
3137
+ field2("at_value", utf82(), true),
3138
+ field2("copy_from", struct2([field2("format", utf82(), false), field2("file_path", utf82(), false), field2("expected_schema", binary2(), false)]), true),
3139
+ field2("copy_to", struct2([field2("format", utf82(), false), field2("file_path", utf82(), false)]), true),
3140
+ field2("schema_name", utf82(), true)
3141
+ ]);
3142
+ var CatalogAttachRequestSchema = schema2([
3143
+ field2("name", utf82(), false),
3144
+ field2("options", binary2(), true),
3145
+ field2("data_version_spec", utf82(), true),
3146
+ field2("implementation_version", utf82(), true),
3147
+ field2("client_capabilities", binary2(), true)
3148
+ ]);
3149
+ var CopyFromContextSchema = schema2([
3150
+ field2("format", utf82(), false),
3151
+ field2("file_path", utf82(), false),
3152
+ field2("expected_schema", binary2(), false)
3153
+ ]);
3154
+ var CopyToContextSchema = schema2([
3155
+ field2("format", utf82(), false),
3156
+ field2("file_path", utf82(), false)
3157
+ ]);
3158
+ var GlobalInitResponseSchema = schema2([
3159
+ field2("execution_id", binary2(), false),
3160
+ field2("opaque_data", binary2(), true),
3161
+ field2("max_workers", int642(), false)
3162
+ ]);
3163
+ var InitRequestSchema = schema2([
3164
+ field2("bind_call", binary2(), false),
3165
+ field2("output_schema", binary2(), false),
3166
+ field2("bind_opaque_data", binary2(), true),
3167
+ field2("projection_ids", list2(field2("item", int642(), true)), true),
3168
+ field2("pushdown_filters", largeBinary2(), true),
3169
+ field2("join_keys", list2(field2("item", largeBinary2(), true)), true),
3170
+ field2("split_tokens", list2(field2("item", largeBinary2(), true)), true),
3171
+ field2("row_limit", int642(), true),
3172
+ field2("phase", dictionary2(utf82(), int162()), true),
3173
+ field2("finalize_state_id", binary2(), true),
3174
+ field2("execution_id", binary2(), true),
3175
+ field2("init_opaque_data", binary2(), true),
3176
+ field2("substream_id", binary2(), true),
3177
+ field2("order_by_column_name", utf82(), true),
3178
+ field2("order_by_direction", dictionary2(utf82(), int162()), true),
3179
+ field2("order_by_null_order", dictionary2(utf82(), int162()), true),
3180
+ field2("order_by_limit", int642(), true),
3181
+ field2("tablesample_percentage", float642(), true),
3182
+ field2("tablesample_seed", int642(), true)
3183
+ ]);
3184
+ var TableBufferingCombineRequestSchema = schema2([
3185
+ field2("function_name", utf82(), false),
3186
+ field2("execution_id", binary2(), false),
3187
+ field2("state_ids", list2(field2("item", binary2(), true)), false),
3188
+ field2("attach_opaque_data", binary2(), true),
3189
+ field2("transaction_id", binary2(), true),
3190
+ field2("schema_name", utf82(), true)
3191
+ ]);
3192
+ var TableBufferingDestructorRequestSchema = schema2([
3193
+ field2("function_name", utf82(), false),
3194
+ field2("execution_id", binary2(), false),
3195
+ field2("attach_opaque_data", binary2(), true),
3196
+ field2("transaction_id", binary2(), true),
3197
+ field2("schema_name", utf82(), true)
3198
+ ]);
3199
+ var TableBufferingProcessRequestSchema = schema2([
3200
+ field2("function_name", utf82(), false),
3201
+ field2("execution_id", binary2(), false),
3202
+ field2("input_batch", binary2(), false),
3203
+ field2("attach_opaque_data", binary2(), true),
3204
+ field2("transaction_id", binary2(), true),
3205
+ field2("batch_index", int642(), true),
3206
+ field2("schema_name", utf82(), true)
3207
+ ]);
3208
+ var TableFunctionCardinalityRequestSchema = schema2([
3209
+ field2("bind_call", binary2(), false),
3210
+ field2("bind_opaque_data", binary2(), true)
3211
+ ]);
3212
+ var TableFunctionPlanRequestSchema = schema2([
3213
+ field2("bind_call", binary2(), false),
3214
+ field2("bind_opaque_data", binary2(), true),
3215
+ field2("projection_ids", list2(field2("item", int642(), true)), true),
3216
+ field2("pushdown_filters", largeBinary2(), true),
3217
+ field2("join_keys", list2(field2("item", largeBinary2(), true)), true),
3218
+ field2("row_limit", int642(), true),
3219
+ field2("target_split_bytes", int642(), true),
3220
+ field2("min_splits", int642(), true),
3221
+ field2("max_splits_per_response", int642(), true),
3222
+ field2("cursor", binary2(), true),
3223
+ field2("refined_filters", largeBinary2(), true),
3224
+ field2("filters_complete", bool2(), false),
3225
+ field2("start_position", binary2(), true),
3226
+ field2("end_position", binary2(), true),
3227
+ field2("order_by_column_name", utf82(), true),
3228
+ field2("order_by_direction", dictionary2(utf82(), int162()), true),
3229
+ field2("order_by_null_order", dictionary2(utf82(), int162()), true),
3230
+ field2("order_by_limit", int642(), true),
3231
+ field2("tablesample_percentage", float642(), true),
3232
+ field2("tablesample_seed", int642(), true)
3233
+ ]);
2995
3234
  var AggregateBindResultSchema = schema2([
2996
3235
  field2("output_schema", binary2(), false),
2997
3236
  field2("execution_id", binary2(), false)
@@ -3019,7 +3258,7 @@ var AggregateWindowDestructorResultSchema = schema2([]);
3019
3258
  var AggregateWindowInitResultSchema = schema2([]);
3020
3259
  var BindResultSchema = schema2([
3021
3260
  field2("output_schema", binary2(), false),
3022
- field2("opaque_data", binary2(), false),
3261
+ field2("opaque_data", binary2(), true),
3023
3262
  field2("lookup_secret_types", list2(field2("item", utf82(), true)), false),
3024
3263
  field2("lookup_scopes", list2(field2("item", utf82(), true)), false),
3025
3264
  field2("lookup_names", list2(field2("item", utf82(), true)), false)
@@ -3103,6 +3342,24 @@ var TableFunctionDynamicToStringResultSchema = schema2([
3103
3342
  field2("keys", list2(field2("item", utf82(), true)), false),
3104
3343
  field2("values", list2(field2("item", utf82(), true)), false)
3105
3344
  ]);
3345
+ var TableFunctionPlanResultSchema = schema2([
3346
+ field2("splits", list2(field2("item", binary2(), true)), false),
3347
+ field2("next_cursors", list2(field2("item", binary2(), true)), true),
3348
+ field2("execution_id", binary2(), true),
3349
+ field2("init_opaque_data", binary2(), true),
3350
+ field2("max_workers", int642(), true),
3351
+ field2("estimated_total_splits", int642(), true),
3352
+ field2("estimated_total_rows", int642(), true),
3353
+ field2("estimated_total_bytes", int642(), true),
3354
+ field2("catalog_version", int642(), true),
3355
+ field2("scope", utf82(), false),
3356
+ field2("locations", list2(field2("item", utf82(), true)), true),
3357
+ field2("partitioning", list2(field2("item", binary2(), true)), true),
3358
+ field2("sort_order", list2(field2("item", binary2(), true)), true),
3359
+ field2("cache_max_age_seconds", int642(), true),
3360
+ field2("start_position", binary2(), true),
3361
+ field2("end_position", binary2(), true)
3362
+ ]);
3106
3363
  var AggregateBindParamsSchema = schema2([
3107
3364
  field2("request", binary2(), false)
3108
3365
  ]);
@@ -3469,6 +3726,9 @@ var TableFunctionCardinalityParamsSchema = schema2([
3469
3726
  var TableFunctionDynamicToStringParamsSchema = schema2([
3470
3727
  field2("request", binary2(), false)
3471
3728
  ]);
3729
+ var TableFunctionPlanParamsSchema = schema2([
3730
+ field2("request", binary2(), false)
3731
+ ]);
3472
3732
  var TableFunctionStatisticsParamsSchema = schema2([
3473
3733
  field2("request", binary2(), false)
3474
3734
  ]);
@@ -4399,57 +4659,235 @@ function decodeOptionsBatch(bytes) {
4399
4659
  return row ?? {};
4400
4660
  }
4401
4661
  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
- ]);
4662
+
4663
+ // src/request-auth.ts
4664
+ var scope;
4665
+ function setRequestAuthScope(next) {
4666
+ scope = next;
4667
+ }
4668
+ function currentRequestAuth() {
4669
+ return scope?.getStore()?.auth;
4670
+ }
4671
+
4672
+ // src/protocol/serializers/splits.ts
4673
+ var SCAN_SPLIT_SCHEMA = ScanSplitSchema;
4674
+ var PLAN_RESPONSE_SCHEMA = TableFunctionPlanResultSchema;
4675
+ function deserializePlanRequest(params) {
4676
+ const bindCallBytes = toUint8Array2(params.bind_call);
4677
+ const bindCall = deserializeBindRequest(batchToScalarDict(deserializeBatch(bindCallBytes)));
4678
+ let projectionIds = null;
4679
+ if (params.projection_ids != null) {
4680
+ const raw = params.projection_ids;
4681
+ if (Array.isArray(raw))
4682
+ projectionIds = raw.map(Number);
4683
+ else if (raw && typeof raw[Symbol.iterator] === "function")
4684
+ projectionIds = [...raw].map(Number);
4685
+ }
4686
+ const asBigInt = (v) => v == null ? null : typeof v === "bigint" ? v : BigInt(Number(v));
4687
+ return {
4688
+ bind_call: bindCall,
4689
+ bind_opaque_data: params.bind_opaque_data ? toUint8Array2(params.bind_opaque_data) : null,
4690
+ projection_ids: projectionIds,
4691
+ pushdown_filters: params.pushdown_filters ? toUint8Array2(params.pushdown_filters) : null,
4692
+ target_split_bytes: asBigInt(params.target_split_bytes),
4693
+ min_splits: asBigInt(params.min_splits),
4694
+ cursor: params.cursor ? toUint8Array2(params.cursor) : null
4695
+ };
4696
+ }
4697
+ function fingerprintInputs(bindCallBytes) {
4698
+ const dict = batchToScalarDict(deserializeBatch(bindCallBytes));
4699
+ return {
4700
+ schemaName: dict.schema_name == null ? "" : String(dict.schema_name),
4701
+ functionName: String(dict.function_name ?? ""),
4702
+ args: dict.arguments ? toUint8Array2(dict.arguments) : new Uint8Array(0),
4703
+ settings: dict.settings ? toUint8Array2(dict.settings) : new Uint8Array(0)
4704
+ };
4705
+ }
4706
+ function scanSplitRow(split, token) {
4707
+ const asBigInt = (v) => v == null ? null : typeof v === "bigint" ? v : BigInt(v);
4708
+ return {
4709
+ payload: new Uint8Array(0),
4710
+ token,
4711
+ estimated_rows: asBigInt(split.estimatedRows),
4712
+ rows_exact: split.rowsExact === true,
4713
+ estimated_bytes: asBigInt(split.estimatedBytes),
4714
+ partition_bounds: split.partitionBounds ?? null,
4715
+ column_statistics: split.columnStatistics ?? null,
4716
+ location_ids: split.locationIds ?? null,
4717
+ start_position: split.startPosition ?? null,
4718
+ end_position: split.endPosition ?? null
4719
+ };
4720
+ }
4721
+ function planResponseRow(result, splitBlobs) {
4722
+ const asBigInt = (v) => v == null ? null : typeof v === "bigint" ? v : BigInt(v);
4723
+ return {
4724
+ splits: splitBlobs,
4725
+ next_cursors: result.nextCursors ?? [],
4726
+ execution_id: null,
4727
+ init_opaque_data: new Uint8Array(0),
4728
+ max_workers: asBigInt(result.maxWorkers),
4729
+ estimated_total_splits: asBigInt(result.estimatedTotalSplits),
4730
+ estimated_total_rows: asBigInt(result.estimatedTotalRows),
4731
+ estimated_total_bytes: asBigInt(result.estimatedTotalBytes),
4732
+ catalog_version: asBigInt(result.catalogVersion),
4733
+ scope: result.scope ?? "catalog",
4734
+ locations: null,
4735
+ partitioning: [],
4736
+ sort_order: [],
4737
+ cache_max_age_seconds: asBigInt(result.cacheMaxAgeSeconds),
4738
+ start_position: new Uint8Array(0),
4739
+ end_position: new Uint8Array(0)
4740
+ };
4741
+ }
4742
+
4743
+ // src/split-token.ts
4744
+ var SPLIT_TOKEN_FORMAT_VERSION = 1;
4745
+ var FLAG_PAYLOAD_SEALED = 1;
4746
+ var RESERVED_FLAGS_MASK = 254;
4747
+ var FINGERPRINT_LEN = 16;
4748
+ var HEADER_LEN = 4 + FINGERPRINT_LEN;
4749
+ var SEAL_VERSION = 1;
4750
+ var AAD_PREFIX = new TextEncoder().encode("vgi.split_token.v1\x00");
4751
+ var SPLIT_TOKEN_INVALID = "SPLIT_TOKEN_INVALID";
4752
+ var SPLIT_SNAPSHOT_EXPIRED = "SPLIT_SNAPSHOT_EXPIRED";
4753
+ class SplitTokenError extends Error {
4754
+ kind;
4755
+ constructor(kind, message) {
4756
+ super(`[${kind}] ${message}`);
4757
+ this.name = "SplitTokenError";
4758
+ this.kind = kind;
4759
+ }
4760
+ }
4761
+ function concat2(...parts) {
4762
+ const total = parts.reduce((n, p) => n + p.length, 0);
4763
+ const out = new Uint8Array(total);
4764
+ let at = 0;
4765
+ for (const p of parts) {
4766
+ out.set(p, at);
4767
+ at += p.length;
4768
+ }
4769
+ return out;
4770
+ }
4771
+ function equalBytes2(a, b) {
4772
+ if (a.length !== b.length)
4773
+ return false;
4774
+ let diff = 0;
4775
+ for (let i = 0;i < a.length; i++)
4776
+ diff |= a[i] ^ b[i];
4777
+ return diff === 0;
4778
+ }
4779
+ async function bindFingerprint(schemaName, functionName, args, settings, projection) {
4780
+ const enc = new TextEncoder;
4781
+ const zero = Uint8Array.of(0);
4782
+ const field3 = (label, value) => concat2(enc.encode(label), zero, value, zero);
4783
+ const message = concat2(AAD_PREFIX, field3("schema_name", enc.encode(schemaName)), field3("function_name", enc.encode(functionName)), field3("arguments", args), field3("settings", settings), field3("projection_ids", projection));
4784
+ const digest = await crypto.subtle.digest("SHA-256", message);
4785
+ return new Uint8Array(digest).slice(0, FINGERPRINT_LEN);
4786
+ }
4787
+ function splitTokenAad(header, auth) {
4788
+ return concat2(header, identityTail(auth));
4789
+ }
4790
+ function splitAnchor(catalogVersion) {
4791
+ const out = new Uint8Array(8);
4792
+ new DataView(out.buffer).setBigInt64(0, BigInt(catalogVersion), true);
4793
+ return out;
4794
+ }
4795
+ async function buildSplitToken(opts) {
4796
+ const { payload, fingerprint, anchor, signingKey, auth } = opts;
4797
+ if (fingerprint.length !== FINGERPRINT_LEN) {
4798
+ throw new SplitTokenError(SPLIT_TOKEN_INVALID, `bind_fingerprint must be ${FINGERPRINT_LEN} bytes, got ${fingerprint.length}`);
4799
+ }
4800
+ if (anchor.length > 65535) {
4801
+ throw new SplitTokenError(SPLIT_TOKEN_INVALID, `consistency_anchor too long: ${anchor.length} bytes exceeds u16`);
4802
+ }
4803
+ const head = new Uint8Array(4);
4804
+ head[0] = SPLIT_TOKEN_FORMAT_VERSION;
4805
+ head[1] = signingKey ? FLAG_PAYLOAD_SEALED : 0;
4806
+ new DataView(head.buffer).setUint16(2, anchor.length, true);
4807
+ const body = concat2(head, fingerprint, anchor);
4808
+ if (!signingKey)
4809
+ return concat2(body, payload);
4810
+ const sealed = await sealBytes(payload, signingKey, splitTokenAad(body, auth), SEAL_VERSION);
4811
+ return concat2(body, sealed);
4812
+ }
4813
+ async function openSplitToken(token, opts = {}) {
4814
+ const { signingKey, auth, expectedFingerprint, currentAnchor } = opts;
4815
+ if (token.length < HEADER_LEN) {
4816
+ throw new SplitTokenError(SPLIT_TOKEN_INVALID, `split token too short: ${token.length} bytes, need at least ${HEADER_LEN}`);
4817
+ }
4818
+ const version = token[0];
4819
+ const flags = token[1];
4820
+ const view = new DataView(token.buffer, token.byteOffset, token.byteLength);
4821
+ const anchorLen = view.getUint16(2, true);
4822
+ if (version !== SPLIT_TOKEN_FORMAT_VERSION) {
4823
+ throw new SplitTokenError(SPLIT_TOKEN_INVALID, `unsupported split-token format_version ${version}; this worker speaks ` + `${SPLIT_TOKEN_FORMAT_VERSION}`);
4824
+ }
4825
+ if (flags & RESERVED_FLAGS_MASK) {
4826
+ throw new SplitTokenError(SPLIT_TOKEN_INVALID, `split token sets reserved flag bits (flags=0x${flags.toString(16).padStart(2, "0")})`);
4827
+ }
4828
+ const sealed = (flags & FLAG_PAYLOAD_SEALED) !== 0;
4829
+ if (signingKey && !sealed) {
4830
+ 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).");
4831
+ }
4832
+ if (!signingKey && sealed) {
4833
+ throw new SplitTokenError(SPLIT_TOKEN_INVALID, "split token is sealed but this worker holds no signing key; cannot open it");
4834
+ }
4835
+ const endOfAnchor = HEADER_LEN + anchorLen;
4836
+ if (token.length < endOfAnchor) {
4837
+ throw new SplitTokenError(SPLIT_TOKEN_INVALID, `split token truncated: anchor_len=${anchorLen} exceeds token length ${token.length}`);
4838
+ }
4839
+ const fingerprint = token.subarray(4, HEADER_LEN);
4840
+ const anchor = token.subarray(HEADER_LEN, endOfAnchor);
4841
+ const body = token.subarray(0, endOfAnchor);
4842
+ const rest = token.subarray(endOfAnchor);
4843
+ if (expectedFingerprint && !equalBytes2(fingerprint, expectedFingerprint)) {
4844
+ throw new SplitTokenError(SPLIT_TOKEN_INVALID, "split token was minted for a different bind (fingerprint mismatch)");
4845
+ }
4846
+ if (currentAnchor && !equalBytes2(anchor, currentAnchor)) {
4847
+ throw new SplitTokenError(SPLIT_SNAPSHOT_EXPIRED, "split snapshot expired; re-run the query");
4848
+ }
4849
+ if (!sealed)
4850
+ return new Uint8Array(rest);
4851
+ try {
4852
+ return await openBytes(rest, signingKey, splitTokenAad(body, auth), SEAL_VERSION, "split token");
4853
+ } catch (err2) {
4854
+ throw new SplitTokenError(SPLIT_TOKEN_INVALID, `split token failed authentication: ${err2 instanceof Error ? err2.message : String(err2)}`);
4855
+ }
4856
+ }
4451
4857
 
4452
4858
  // src/protocol/handlers/function.ts
4859
+ async function liveSplitAnchor(catalogInterface, bindCall, auth, signingKey) {
4860
+ if (!catalogInterface?.version || bindCall.attach_opaque_data == null)
4861
+ return;
4862
+ const raw = toUint8Array(bindCall.attach_opaque_data);
4863
+ const txn = bindCall.transaction_opaque_data ? toUint8Array(bindCall.transaction_opaque_data) : undefined;
4864
+ const forms = [
4865
+ async () => raw,
4866
+ async () => openAttach(raw, auth, signingKey)
4867
+ ];
4868
+ for (const form of forms) {
4869
+ try {
4870
+ return splitAnchor(await catalogInterface.version(await form(), txn));
4871
+ } catch {}
4872
+ }
4873
+ return;
4874
+ }
4875
+ async function resolveSplitPayloads(request, innerParams, opts) {
4876
+ if (!request.split_tokens)
4877
+ return;
4878
+ const fp = fingerprintInputs(toUint8Array(innerParams.bind_call));
4879
+ const expected = await bindFingerprint(fp.schemaName, fp.functionName, fp.args, fp.settings, new Uint8Array(0));
4880
+ const currentAnchor = opts.checkAnchor ? await liveSplitAnchor(opts.catalogInterface, request.bind_call, opts.auth, opts.signingKey) : undefined;
4881
+ request.split_payloads = [];
4882
+ for (const token of request.split_tokens) {
4883
+ request.split_payloads.push(await openSplitToken(token, {
4884
+ signingKey: opts.signingKey,
4885
+ auth: opts.auth,
4886
+ expectedFingerprint: expected,
4887
+ currentAnchor
4888
+ }));
4889
+ }
4890
+ }
4453
4891
  function registerFunctionMethods(protocol, config) {
4454
4892
  const { registry, signingKey, catalogInterface } = config;
4455
4893
  async function stripAttach(attach, ctx) {
@@ -4458,7 +4896,7 @@ function registerFunctionMethods(protocol, config) {
4458
4896
  const env = toUint8Array(attach);
4459
4897
  if (env.length === 0)
4460
4898
  return env;
4461
- return openAttach(env, ctx?.auth, signingKey);
4899
+ return openAttach(env, ctx?.auth ?? currentRequestAuth(), signingKey);
4462
4900
  }
4463
4901
  async function strippedContext(bindCall, ctx) {
4464
4902
  let attach = null;
@@ -4469,17 +4907,13 @@ function registerFunctionMethods(protocol, config) {
4469
4907
  }
4470
4908
  return overloadContext({ ...bindCall, attach_opaque_data: attach }, catalogInterface);
4471
4909
  }
4472
- const initHeaderSchema = schema2([
4473
- field2("execution_id", binary2(), false),
4474
- field2("opaque_data", binary2(), true),
4475
- field2("max_workers", int642(), false)
4476
- ]);
4910
+ const initHeaderSchema = GLOBAL_INIT_RESPONSE_SCHEMA;
4477
4911
  const emptySchema = schema2([]);
4478
4912
  const dummyInputSchema = schema2([
4479
4913
  field2("_tick", binary2(), true)
4480
4914
  ]);
4481
4915
  protocol.unary("bind", {
4482
- params: REQUEST_PARAMS_SCHEMA,
4916
+ params: BindParamsSchema,
4483
4917
  result: RESULT_BINARY_SCHEMA,
4484
4918
  handler: async (params, ctx) => {
4485
4919
  const innerParams = unwrapRequest(params.request);
@@ -4492,14 +4926,21 @@ function registerFunctionMethods(protocol, config) {
4492
4926
  }
4493
4927
  });
4494
4928
  protocol.exchange("init", {
4495
- params: REQUEST_PARAMS_SCHEMA,
4929
+ params: InitParamsSchema,
4496
4930
  inputSchema: dummyInputSchema,
4497
4931
  outputSchema: emptySchema,
4498
- init: async (params) => {
4932
+ init: async (params, ctx) => {
4499
4933
  const requestIpcBytes = toUint8Array(params.request);
4500
4934
  const innerParams = unwrapRequest(params.request);
4501
4935
  const request = deserializeInitRequest(innerParams);
4502
- request.bind_call.attach_opaque_data = await stripAttach(request.bind_call.attach_opaque_data, undefined);
4936
+ const auth = ctx?.auth ?? currentRequestAuth();
4937
+ request.bind_call.attach_opaque_data = await stripAttach(request.bind_call.attach_opaque_data, ctx);
4938
+ await resolveSplitPayloads(request, innerParams, {
4939
+ auth,
4940
+ signingKey,
4941
+ catalogInterface,
4942
+ checkAnchor: true
4943
+ });
4503
4944
  const func = registry.get(request.bind_call.function_name, overloadContext(request.bind_call, catalogInterface));
4504
4945
  const initResponse = await func.globalInit(request);
4505
4946
  const accumulatedState = recoverFinalizeState(request, config.recoverExchangeState);
@@ -4540,6 +4981,12 @@ function registerFunctionMethods(protocol, config) {
4540
4981
  const initRequestBatch = deserializeBatch(state.initRequestIpc);
4541
4982
  const initRequestDict = batchToScalarDict(initRequestBatch);
4542
4983
  const request = deserializeInitRequest(initRequestDict);
4984
+ await resolveSplitPayloads(request, { bind_call: initRequestDict.bind_call }, {
4985
+ auth: currentRequestAuth(),
4986
+ signingKey,
4987
+ catalogInterface,
4988
+ checkAnchor: false
4989
+ });
4543
4990
  const func = registry.get(state.functionName, await strippedContext(request.bind_call));
4544
4991
  const executionId = state.executionId;
4545
4992
  const opaqueData = state.opaqueData ?? null;
@@ -4583,7 +5030,7 @@ function registerFunctionMethods(protocol, config) {
4583
5030
  }
4584
5031
  });
4585
5032
  protocol.unary("table_function_cardinality", {
4586
- params: REQUEST_PARAMS_SCHEMA,
5033
+ params: TableFunctionCardinalityParamsSchema,
4587
5034
  result: RESULT_BINARY_SCHEMA,
4588
5035
  handler: async (params) => {
4589
5036
  const innerParams = unwrapRequest(params.request);
@@ -4598,8 +5045,36 @@ function registerFunctionMethods(protocol, config) {
4598
5045
  return wrapResult(cardResult, TableFunctionCardinalityResultSchema);
4599
5046
  }
4600
5047
  });
5048
+ protocol.unary("table_function_plan", {
5049
+ params: TableFunctionPlanParamsSchema,
5050
+ result: RESULT_BINARY_SCHEMA,
5051
+ handler: async (params, ctx) => {
5052
+ const innerParams = unwrapRequest(params.request);
5053
+ const request = deserializePlanRequest(innerParams);
5054
+ const func = registry.get(request.bind_call.function_name, await strippedContext(request.bind_call));
5055
+ const plan = func.plan ? await func.plan(request) : { splits: [{ payload: new Uint8Array(0) }] };
5056
+ const fp = fingerprintInputs(toUint8Array(innerParams.bind_call));
5057
+ const fingerprint = await bindFingerprint(fp.schemaName, fp.functionName, fp.args, fp.settings, new Uint8Array(0));
5058
+ const anchor = plan.catalogVersion != null ? splitAnchor(plan.catalogVersion) : await liveSplitAnchor(catalogInterface, request.bind_call, ctx?.auth, signingKey) ?? splitAnchor(0);
5059
+ const blobs = [];
5060
+ for (const split of plan.splits) {
5061
+ const token = await buildSplitToken({
5062
+ payload: split.payload,
5063
+ fingerprint,
5064
+ anchor,
5065
+ signingKey,
5066
+ auth: ctx?.auth
5067
+ });
5068
+ blobs.push(serializeBatch(batchFromColumns(Object.fromEntries(SCAN_SPLIT_SCHEMA.fields.map((f) => [
5069
+ f.name,
5070
+ [scanSplitRow(split, token)[f.name] ?? null]
5071
+ ])), SCAN_SPLIT_SCHEMA)));
5072
+ }
5073
+ return wrapResult(planResponseRow(plan, blobs), PLAN_RESPONSE_SCHEMA);
5074
+ }
5075
+ });
4601
5076
  protocol.unary("table_function_statistics", {
4602
- params: REQUEST_PARAMS_SCHEMA,
5077
+ params: TableFunctionStatisticsParamsSchema,
4603
5078
  result: RESULT_BINARY_NULLABLE_SCHEMA,
4604
5079
  handler: async (params) => {
4605
5080
  const innerParams = unwrapRequest(params.request);
@@ -4614,7 +5089,7 @@ function registerFunctionMethods(protocol, config) {
4614
5089
  }
4615
5090
  });
4616
5091
  protocol.unary("table_function_dynamic_to_string", {
4617
- params: REQUEST_PARAMS_SCHEMA,
5092
+ params: TableFunctionDynamicToStringParamsSchema,
4618
5093
  result: RESULT_BINARY_SCHEMA,
4619
5094
  handler: async (params) => {
4620
5095
  const innerParams = unwrapRequest(params.request);
@@ -4815,7 +5290,7 @@ function registerAggregateMethods(protocol, registry) {
4815
5290
  return func.aggregateConfig;
4816
5291
  }
4817
5292
  protocol.unary("aggregate_bind", {
4818
- params: REQUEST_PARAMS_SCHEMA,
5293
+ params: AggregateBindParamsSchema,
4819
5294
  result: RESULT_BINARY_SCHEMA,
4820
5295
  handler: async (params) => {
4821
5296
  const innerParams = unwrapRequest(params.request);
@@ -4847,7 +5322,7 @@ function registerAggregateMethods(protocol, registry) {
4847
5322
  }
4848
5323
  });
4849
5324
  protocol.unary("aggregate_update", {
4850
- params: REQUEST_PARAMS_SCHEMA,
5325
+ params: AggregateUpdateParamsSchema,
4851
5326
  result: RESULT_BINARY_SCHEMA,
4852
5327
  handler: (params) => {
4853
5328
  const innerParams = unwrapRequest(params.request);
@@ -4900,7 +5375,7 @@ function registerAggregateMethods(protocol, registry) {
4900
5375
  }
4901
5376
  });
4902
5377
  protocol.unary("aggregate_combine", {
4903
- params: REQUEST_PARAMS_SCHEMA,
5378
+ params: AggregateCombineParamsSchema,
4904
5379
  result: RESULT_BINARY_SCHEMA,
4905
5380
  handler: (params) => {
4906
5381
  const innerParams = unwrapRequest(params.request);
@@ -4945,7 +5420,7 @@ function registerAggregateMethods(protocol, registry) {
4945
5420
  }
4946
5421
  });
4947
5422
  protocol.unary("aggregate_finalize", {
4948
- params: REQUEST_PARAMS_SCHEMA,
5423
+ params: AggregateFinalizeParamsSchema,
4949
5424
  result: RESULT_BINARY_SCHEMA,
4950
5425
  handler: (params) => {
4951
5426
  const innerParams = unwrapRequest(params.request);
@@ -4983,7 +5458,7 @@ function registerAggregateMethods(protocol, registry) {
4983
5458
  }
4984
5459
  });
4985
5460
  protocol.unary("aggregate_destructor", {
4986
- params: REQUEST_PARAMS_SCHEMA,
5461
+ params: AggregateDestructorParamsSchema,
4987
5462
  result: RESULT_BINARY_SCHEMA,
4988
5463
  handler: (params) => {
4989
5464
  const innerParams = unwrapRequest(params.request);
@@ -5142,7 +5617,7 @@ function registerTableBufferingMethods(protocol, registry, signingKey) {
5142
5617
  return { func, params };
5143
5618
  }
5144
5619
  protocol.unary("table_buffering_process", {
5145
- params: REQUEST_PARAMS_SCHEMA,
5620
+ params: TableBufferingProcessParamsSchema,
5146
5621
  result: RESULT_BINARY_SCHEMA,
5147
5622
  handler: async (rpcParams, ctx) => {
5148
5623
  const inner = unwrapRequest(rpcParams.request);
@@ -5160,7 +5635,7 @@ function registerTableBufferingMethods(protocol, registry, signingKey) {
5160
5635
  }
5161
5636
  });
5162
5637
  protocol.unary("table_buffering_combine", {
5163
- params: REQUEST_PARAMS_SCHEMA,
5638
+ params: TableBufferingCombineParamsSchema,
5164
5639
  result: RESULT_BINARY_SCHEMA,
5165
5640
  handler: async (rpcParams, ctx) => {
5166
5641
  const inner = unwrapRequest(rpcParams.request);
@@ -5178,7 +5653,7 @@ function registerTableBufferingMethods(protocol, registry, signingKey) {
5178
5653
  }
5179
5654
  });
5180
5655
  protocol.unary("table_buffering_destructor", {
5181
- params: REQUEST_PARAMS_SCHEMA,
5656
+ params: TableBufferingDestructorParamsSchema,
5182
5657
  result: RESULT_BINARY_SCHEMA,
5183
5658
  handler: async (rpcParams) => {
5184
5659
  try {
@@ -5242,7 +5717,7 @@ var encodeCopyFromFormatInfo = (v) => encodeASD(CopyFromFormatInfoSchema, {
5242
5717
  // src/protocol/handlers/catalog/admin.ts
5243
5718
  function registerCatalogAdminMethods(protocol, getCatalog, signingKey) {
5244
5719
  catalogUnary(protocol, signingKey, "catalog_catalogs", {
5245
- params: emptyResultSchema,
5720
+ params: CatalogCatalogsParamsSchema,
5246
5721
  result: RESULT_BINARY_SCHEMA,
5247
5722
  handler: async () => {
5248
5723
  const cat = getCatalog();
@@ -5258,7 +5733,7 @@ function registerCatalogAdminMethods(protocol, getCatalog, signingKey) {
5258
5733
  }
5259
5734
  });
5260
5735
  protocol.unary("catalog_attach", {
5261
- params: REQUEST_PARAMS_SCHEMA,
5736
+ params: CatalogAttachParamsSchema,
5262
5737
  result: RESULT_BINARY_SCHEMA,
5263
5738
  handler: async (params, ctx) => {
5264
5739
  const innerParams = unwrapRequest(params.request);
@@ -5288,7 +5763,7 @@ function registerCatalogAdminMethods(protocol, getCatalog, signingKey) {
5288
5763
  }
5289
5764
  });
5290
5765
  catalogUnary(protocol, signingKey, "catalog_detach", {
5291
- params: attachOpaqueDataParam,
5766
+ params: CatalogDetachParamsSchema,
5292
5767
  result: emptyResultSchema,
5293
5768
  handler: async (params) => {
5294
5769
  const cat = getCatalog();
@@ -5297,11 +5772,7 @@ function registerCatalogAdminMethods(protocol, getCatalog, signingKey) {
5297
5772
  }
5298
5773
  });
5299
5774
  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
- ]),
5775
+ params: CatalogCreateParamsSchema,
5305
5776
  result: emptyResultSchema,
5306
5777
  handler: async (params) => {
5307
5778
  const cat = getCatalog();
@@ -5310,7 +5781,7 @@ function registerCatalogAdminMethods(protocol, getCatalog, signingKey) {
5310
5781
  }
5311
5782
  });
5312
5783
  catalogUnary(protocol, signingKey, "catalog_drop", {
5313
- params: schema2([field2("name", utf82(), false)]),
5784
+ params: CatalogDropParamsSchema,
5314
5785
  result: emptyResultSchema,
5315
5786
  handler: async (params) => {
5316
5787
  const cat = getCatalog();
@@ -5319,7 +5790,7 @@ function registerCatalogAdminMethods(protocol, getCatalog, signingKey) {
5319
5790
  }
5320
5791
  });
5321
5792
  catalogUnary(protocol, signingKey, "catalog_version", {
5322
- params: attachOpaqueDataTxnParams,
5793
+ params: CatalogVersionParamsSchema,
5323
5794
  result: RESULT_BINARY_SCHEMA,
5324
5795
  handler: async (params) => {
5325
5796
  const cat = getCatalog();
@@ -5328,7 +5799,7 @@ function registerCatalogAdminMethods(protocol, getCatalog, signingKey) {
5328
5799
  }
5329
5800
  });
5330
5801
  protocol.unary("catalog_transaction_begin", {
5331
- params: attachOpaqueDataParam,
5802
+ params: CatalogTransactionBeginParamsSchema,
5332
5803
  result: RESULT_BINARY_SCHEMA,
5333
5804
  handler: async (params, ctx) => {
5334
5805
  const auth = ctx?.auth;
@@ -5341,7 +5812,7 @@ function registerCatalogAdminMethods(protocol, getCatalog, signingKey) {
5341
5812
  }
5342
5813
  });
5343
5814
  catalogUnary(protocol, signingKey, "catalog_transaction_commit", {
5344
- params: attachOpaqueDataTxnParams,
5815
+ params: CatalogTransactionCommitParamsSchema,
5345
5816
  result: emptyResultSchema,
5346
5817
  handler: async (params) => {
5347
5818
  const cat = getCatalog();
@@ -5350,7 +5821,7 @@ function registerCatalogAdminMethods(protocol, getCatalog, signingKey) {
5350
5821
  }
5351
5822
  });
5352
5823
  catalogUnary(protocol, signingKey, "catalog_transaction_rollback", {
5353
- params: attachOpaqueDataTxnParams,
5824
+ params: CatalogTransactionRollbackParamsSchema,
5354
5825
  result: emptyResultSchema,
5355
5826
  handler: async (params) => {
5356
5827
  const cat = getCatalog();
@@ -5359,7 +5830,7 @@ function registerCatalogAdminMethods(protocol, getCatalog, signingKey) {
5359
5830
  }
5360
5831
  });
5361
5832
  catalogUnary(protocol, signingKey, "catalog_schemas", {
5362
- params: attachOpaqueDataTxnParams,
5833
+ params: CatalogSchemasParamsSchema,
5363
5834
  result: RESULT_BINARY_SCHEMA,
5364
5835
  handler: async (params) => {
5365
5836
  const cat = getCatalog();
@@ -5370,7 +5841,7 @@ function registerCatalogAdminMethods(protocol, getCatalog, signingKey) {
5370
5841
  }
5371
5842
  });
5372
5843
  catalogUnary(protocol, signingKey, "catalog_copy_from_formats", {
5373
- params: attachOpaqueDataTxnParams,
5844
+ params: CatalogCopyFromFormatsParamsSchema,
5374
5845
  result: RESULT_BINARY_SCHEMA,
5375
5846
  handler: async (params) => {
5376
5847
  const cat = getCatalog();
@@ -5381,7 +5852,7 @@ function registerCatalogAdminMethods(protocol, getCatalog, signingKey) {
5381
5852
  }
5382
5853
  });
5383
5854
  catalogUnary(protocol, signingKey, "catalog_schema_get", {
5384
- params: attachOpaqueDataNameTxnParams,
5855
+ params: CatalogSchemaGetParamsSchema,
5385
5856
  result: RESULT_BINARY_SCHEMA,
5386
5857
  handler: async (params) => {
5387
5858
  const cat = getCatalog();
@@ -5392,13 +5863,7 @@ function registerCatalogAdminMethods(protocol, getCatalog, signingKey) {
5392
5863
  }
5393
5864
  });
5394
5865
  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
- ]),
5866
+ params: CatalogSchemaCreateParamsSchema,
5402
5867
  result: emptyResultSchema,
5403
5868
  handler: async (params) => {
5404
5869
  const cat = getCatalog();
@@ -5407,13 +5872,7 @@ function registerCatalogAdminMethods(protocol, getCatalog, signingKey) {
5407
5872
  }
5408
5873
  });
5409
5874
  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
- ]),
5875
+ params: CatalogSchemaDropParamsSchema,
5417
5876
  result: emptyResultSchema,
5418
5877
  handler: async (params) => {
5419
5878
  const cat = getCatalog();
@@ -5422,7 +5881,7 @@ function registerCatalogAdminMethods(protocol, getCatalog, signingKey) {
5422
5881
  }
5423
5882
  });
5424
5883
  catalogUnary(protocol, signingKey, "catalog_schema_contents_tables", {
5425
- params: attachOpaqueDataNameTxnParams,
5884
+ params: CatalogSchemaContentsTablesParamsSchema,
5426
5885
  result: RESULT_BINARY_SCHEMA,
5427
5886
  handler: async (params) => {
5428
5887
  const cat = getCatalog();
@@ -5433,7 +5892,7 @@ function registerCatalogAdminMethods(protocol, getCatalog, signingKey) {
5433
5892
  }
5434
5893
  });
5435
5894
  catalogUnary(protocol, signingKey, "catalog_schema_contents_views", {
5436
- params: attachOpaqueDataNameTxnParams,
5895
+ params: CatalogSchemaContentsViewsParamsSchema,
5437
5896
  result: RESULT_BINARY_SCHEMA,
5438
5897
  handler: async (params) => {
5439
5898
  const cat = getCatalog();
@@ -5444,12 +5903,7 @@ function registerCatalogAdminMethods(protocol, getCatalog, signingKey) {
5444
5903
  }
5445
5904
  });
5446
5905
  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
- ]),
5906
+ params: CatalogSchemaContentsFunctionsParamsSchema,
5453
5907
  result: RESULT_BINARY_SCHEMA,
5454
5908
  handler: async (params) => {
5455
5909
  const cat = getCatalog();
@@ -5464,14 +5918,7 @@ function registerCatalogAdminMethods(protocol, getCatalog, signingKey) {
5464
5918
  // src/protocol/handlers/catalog/table.ts
5465
5919
  function registerCatalogTableMethods(protocol, getCatalog, signingKey) {
5466
5920
  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
- ]),
5921
+ params: CatalogTableGetParamsSchema,
5475
5922
  result: RESULT_BINARY_SCHEMA,
5476
5923
  handler: async (params) => {
5477
5924
  const cat = getCatalog();
@@ -5482,17 +5929,7 @@ function registerCatalogTableMethods(protocol, getCatalog, signingKey) {
5482
5929
  }
5483
5930
  });
5484
5931
  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
- ]),
5932
+ params: CatalogTableCreateParamsSchema,
5496
5933
  result: emptyResultSchema,
5497
5934
  handler: async (params) => {
5498
5935
  const cat = getCatalog();
@@ -5501,13 +5938,7 @@ function registerCatalogTableMethods(protocol, getCatalog, signingKey) {
5501
5938
  }
5502
5939
  });
5503
5940
  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
- ]),
5941
+ params: CatalogTableDropParamsSchema,
5511
5942
  result: emptyResultSchema,
5512
5943
  handler: async (params) => {
5513
5944
  const cat = getCatalog();
@@ -5516,12 +5947,7 @@ function registerCatalogTableMethods(protocol, getCatalog, signingKey) {
5516
5947
  }
5517
5948
  });
5518
5949
  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
- ]),
5950
+ params: CatalogTableColumnStatisticsGetParamsSchema,
5525
5951
  result: RESULT_BINARY_NULLABLE_SCHEMA,
5526
5952
  handler: async (params) => {
5527
5953
  const cat = getCatalog();
@@ -5530,14 +5956,7 @@ function registerCatalogTableMethods(protocol, getCatalog, signingKey) {
5530
5956
  }
5531
5957
  });
5532
5958
  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
- ]),
5959
+ params: CatalogTableScanFunctionGetParamsSchema,
5541
5960
  result: RESULT_BINARY_SCHEMA,
5542
5961
  handler: async (params) => {
5543
5962
  const cat = getCatalog();
@@ -5546,14 +5965,7 @@ function registerCatalogTableMethods(protocol, getCatalog, signingKey) {
5546
5965
  }
5547
5966
  });
5548
5967
  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
- ]),
5968
+ params: CatalogTableScanBranchesGetParamsSchema,
5557
5969
  result: RESULT_BINARY_SCHEMA,
5558
5970
  handler: async (params) => {
5559
5971
  const cat = getCatalog();
@@ -5562,7 +5974,7 @@ function registerCatalogTableMethods(protocol, getCatalog, signingKey) {
5562
5974
  }
5563
5975
  });
5564
5976
  catalogUnary(protocol, signingKey, "catalog_table_comment_set", {
5565
- params: schemaNameCommentParams,
5977
+ params: CatalogTableCommentSetParamsSchema,
5566
5978
  result: emptyResultSchema,
5567
5979
  handler: async (params) => {
5568
5980
  const cat = getCatalog();
@@ -5571,7 +5983,7 @@ function registerCatalogTableMethods(protocol, getCatalog, signingKey) {
5571
5983
  }
5572
5984
  });
5573
5985
  catalogUnary(protocol, signingKey, "catalog_table_rename", {
5574
- params: schemaNameRenameParams,
5986
+ params: CatalogTableRenameParamsSchema,
5575
5987
  result: emptyResultSchema,
5576
5988
  handler: async (params) => {
5577
5989
  const cat = getCatalog();
@@ -5580,16 +5992,7 @@ function registerCatalogTableMethods(protocol, getCatalog, signingKey) {
5580
5992
  }
5581
5993
  });
5582
5994
  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
- ]),
5995
+ params: CatalogTableColumnAddParamsSchema,
5593
5996
  result: emptyResultSchema,
5594
5997
  handler: async (params) => {
5595
5998
  const cat = getCatalog();
@@ -5598,7 +6001,7 @@ function registerCatalogTableMethods(protocol, getCatalog, signingKey) {
5598
6001
  }
5599
6002
  });
5600
6003
  catalogUnary(protocol, signingKey, "catalog_table_column_drop", {
5601
- params: columnOpParams,
6004
+ params: CatalogTableColumnDropParamsSchema,
5602
6005
  result: emptyResultSchema,
5603
6006
  handler: async (params) => {
5604
6007
  const cat = getCatalog();
@@ -5607,15 +6010,7 @@ function registerCatalogTableMethods(protocol, getCatalog, signingKey) {
5607
6010
  }
5608
6011
  });
5609
6012
  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
- ]),
6013
+ params: CatalogTableColumnRenameParamsSchema,
5619
6014
  result: emptyResultSchema,
5620
6015
  handler: async (params) => {
5621
6016
  const cat = getCatalog();
@@ -5624,15 +6019,7 @@ function registerCatalogTableMethods(protocol, getCatalog, signingKey) {
5624
6019
  }
5625
6020
  });
5626
6021
  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
- ]),
6022
+ params: CatalogTableColumnDefaultSetParamsSchema,
5636
6023
  result: emptyResultSchema,
5637
6024
  handler: async (params) => {
5638
6025
  const cat = getCatalog();
@@ -5641,7 +6028,7 @@ function registerCatalogTableMethods(protocol, getCatalog, signingKey) {
5641
6028
  }
5642
6029
  });
5643
6030
  catalogUnary(protocol, signingKey, "catalog_table_column_default_drop", {
5644
- params: columnOpParams,
6031
+ params: CatalogTableColumnDefaultDropParamsSchema,
5645
6032
  result: emptyResultSchema,
5646
6033
  handler: async (params) => {
5647
6034
  const cat = getCatalog();
@@ -5650,15 +6037,7 @@ function registerCatalogTableMethods(protocol, getCatalog, signingKey) {
5650
6037
  }
5651
6038
  });
5652
6039
  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
- ]),
6040
+ params: CatalogTableColumnTypeChangeParamsSchema,
5662
6041
  result: emptyResultSchema,
5663
6042
  handler: async (params) => {
5664
6043
  const cat = getCatalog();
@@ -5667,7 +6046,7 @@ function registerCatalogTableMethods(protocol, getCatalog, signingKey) {
5667
6046
  }
5668
6047
  });
5669
6048
  catalogUnary(protocol, signingKey, "catalog_table_not_null_set", {
5670
- params: columnOpParams,
6049
+ params: CatalogTableNotNullSetParamsSchema,
5671
6050
  result: emptyResultSchema,
5672
6051
  handler: async (params) => {
5673
6052
  const cat = getCatalog();
@@ -5676,7 +6055,7 @@ function registerCatalogTableMethods(protocol, getCatalog, signingKey) {
5676
6055
  }
5677
6056
  });
5678
6057
  catalogUnary(protocol, signingKey, "catalog_table_not_null_drop", {
5679
- params: columnOpParams,
6058
+ params: CatalogTableNotNullDropParamsSchema,
5680
6059
  result: emptyResultSchema,
5681
6060
  handler: async (params) => {
5682
6061
  const cat = getCatalog();
@@ -5689,7 +6068,7 @@ function registerCatalogTableMethods(protocol, getCatalog, signingKey) {
5689
6068
  // src/protocol/handlers/catalog/view.ts
5690
6069
  function registerCatalogViewMethods(protocol, getCatalog, signingKey) {
5691
6070
  catalogUnary(protocol, signingKey, "catalog_view_get", {
5692
- params: attachOpaqueDataSchemaNameTxnParams,
6071
+ params: CatalogViewGetParamsSchema,
5693
6072
  result: RESULT_BINARY_SCHEMA,
5694
6073
  handler: async (params) => {
5695
6074
  const cat = getCatalog();
@@ -5700,14 +6079,7 @@ function registerCatalogViewMethods(protocol, getCatalog, signingKey) {
5700
6079
  }
5701
6080
  });
5702
6081
  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
- ]),
6082
+ params: CatalogViewCreateParamsSchema,
5711
6083
  result: emptyResultSchema,
5712
6084
  handler: async (params) => {
5713
6085
  const cat = getCatalog();
@@ -5716,7 +6088,7 @@ function registerCatalogViewMethods(protocol, getCatalog, signingKey) {
5716
6088
  }
5717
6089
  });
5718
6090
  catalogUnary(protocol, signingKey, "catalog_view_drop", {
5719
- params: schemaNameIgnoreNotFoundTxnParams,
6091
+ params: CatalogViewDropParamsSchema,
5720
6092
  result: emptyResultSchema,
5721
6093
  handler: async (params) => {
5722
6094
  const cat = getCatalog();
@@ -5725,7 +6097,7 @@ function registerCatalogViewMethods(protocol, getCatalog, signingKey) {
5725
6097
  }
5726
6098
  });
5727
6099
  catalogUnary(protocol, signingKey, "catalog_view_rename", {
5728
- params: schemaNameRenameParams,
6100
+ params: CatalogViewRenameParamsSchema,
5729
6101
  result: emptyResultSchema,
5730
6102
  handler: async (params) => {
5731
6103
  const cat = getCatalog();
@@ -5734,7 +6106,7 @@ function registerCatalogViewMethods(protocol, getCatalog, signingKey) {
5734
6106
  }
5735
6107
  });
5736
6108
  catalogUnary(protocol, signingKey, "catalog_view_comment_set", {
5737
- params: schemaNameCommentParams,
6109
+ params: CatalogViewCommentSetParamsSchema,
5738
6110
  result: emptyResultSchema,
5739
6111
  handler: async (params) => {
5740
6112
  const cat = getCatalog();
@@ -5747,7 +6119,7 @@ function registerCatalogViewMethods(protocol, getCatalog, signingKey) {
5747
6119
  // src/protocol/handlers/catalog/macro.ts
5748
6120
  function registerCatalogMacroMethods(protocol, getCatalog, signingKey) {
5749
6121
  catalogUnary(protocol, signingKey, "catalog_macro_get", {
5750
- params: attachOpaqueDataSchemaNameTxnParams,
6122
+ params: CatalogMacroGetParamsSchema,
5751
6123
  result: RESULT_BINARY_SCHEMA,
5752
6124
  handler: async (params) => {
5753
6125
  const cat = getCatalog();
@@ -5758,7 +6130,7 @@ function registerCatalogMacroMethods(protocol, getCatalog, signingKey) {
5758
6130
  }
5759
6131
  });
5760
6132
  catalogUnary(protocol, signingKey, "catalog_macro_create", {
5761
- params: REQUEST_PARAMS_SCHEMA,
6133
+ params: CatalogMacroCreateParamsSchema,
5762
6134
  result: emptyResultSchema,
5763
6135
  handler: async (params) => {
5764
6136
  const cat = getCatalog();
@@ -5768,13 +6140,7 @@ function registerCatalogMacroMethods(protocol, getCatalog, signingKey) {
5768
6140
  }
5769
6141
  });
5770
6142
  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
- ]),
6143
+ params: CatalogMacroDropParamsSchema,
5778
6144
  result: emptyResultSchema,
5779
6145
  handler: async (params) => {
5780
6146
  const cat = getCatalog();
@@ -5783,12 +6149,7 @@ function registerCatalogMacroMethods(protocol, getCatalog, signingKey) {
5783
6149
  }
5784
6150
  });
5785
6151
  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
- ]),
6152
+ params: CatalogSchemaContentsMacrosParamsSchema,
5792
6153
  result: RESULT_BINARY_SCHEMA,
5793
6154
  handler: async (params) => {
5794
6155
  const cat = getCatalog();
@@ -5803,11 +6164,7 @@ function registerCatalogMacroMethods(protocol, getCatalog, signingKey) {
5803
6164
  // src/protocol/handlers/catalog/index_methods.ts
5804
6165
  function registerCatalogIndexMethods(protocol, getCatalog, signingKey) {
5805
6166
  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
- ]),
6167
+ params: CatalogSchemaContentsIndexesParamsSchema,
5811
6168
  result: RESULT_BINARY_SCHEMA,
5812
6169
  handler: async (params) => {
5813
6170
  const cat = getCatalog();
@@ -5818,12 +6175,7 @@ function registerCatalogIndexMethods(protocol, getCatalog, signingKey) {
5818
6175
  }
5819
6176
  });
5820
6177
  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
- ]),
6178
+ params: CatalogIndexGetParamsSchema,
5827
6179
  result: RESULT_BINARY_SCHEMA,
5828
6180
  handler: async (params) => {
5829
6181
  const cat = getCatalog();
@@ -5964,9 +6316,35 @@ function createLandingRoutes(info) {
5964
6316
  }
5965
6317
 
5966
6318
  // src/http/fetch.ts
6319
+ var requestAuthStorage;
6320
+ var requestAuthStoragePending;
6321
+ function ensureRequestAuthStorage() {
6322
+ if (requestAuthStorage !== undefined)
6323
+ return Promise.resolve(requestAuthStorage);
6324
+ requestAuthStoragePending ??= import("async_hooks").then((mod) => {
6325
+ const storage2 = new mod.AsyncLocalStorage;
6326
+ requestAuthStorage = storage2;
6327
+ setRequestAuthScope(storage2);
6328
+ return storage2;
6329
+ }).catch(() => {
6330
+ requestAuthStorage = null;
6331
+ return null;
6332
+ });
6333
+ return requestAuthStoragePending;
6334
+ }
6335
+ var REQUEST_AUTH_DISPATCH_HOOK = {
6336
+ onDispatchStart(info) {
6337
+ const holder = requestAuthStorage?.getStore();
6338
+ if (holder) {
6339
+ holder.auth = info.authenticated ? new AuthContext(info.authDomain ?? "", true, info.principal ?? "", info.claims ?? {}) : AuthContext.anonymous();
6340
+ }
6341
+ return;
6342
+ },
6343
+ onDispatchEnd() {}
6344
+ };
5967
6345
  function createVgiFetch(opts) {
5968
6346
  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.");
6347
+ 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
6348
  }
5971
6349
  const tokenTtl = opts.tokenTtl ?? 3600;
5972
6350
  const prefix = opts.prefix ?? "/vgi";
@@ -5986,12 +6364,19 @@ function createVgiFetch(opts) {
5986
6364
  tokenKey: opts.signingKey,
5987
6365
  tokenTtl,
5988
6366
  stateSerializer: arrowStateSerializer,
6367
+ dispatchHook: REQUEST_AUTH_DISPATCH_HOOK,
6368
+ authenticate: opts.authenticate,
5989
6369
  corsOrigins: opts.corsOrigins === null ? undefined : opts.corsOrigins ?? "*",
5990
6370
  repositoryUrl: opts.repositoryUrl,
5991
6371
  extraRoutes: createLandingRoutes(opts.landingInfo),
5992
6372
  enableLandingPage: false
5993
6373
  });
5994
- return async (req) => handler(req);
6374
+ return async (req) => {
6375
+ const storage2 = await ensureRequestAuthStorage();
6376
+ if (!storage2)
6377
+ return handler(req);
6378
+ return storage2.run({}, () => handler(req));
6379
+ };
5995
6380
  }
5996
6381
 
5997
6382
  // src/serve-entry.ts
@@ -6063,7 +6448,8 @@ function createVgiWorkerFetch(opts) {
6063
6448
  serverId: opts.serverId ?? opts.name,
6064
6449
  corsOrigins,
6065
6450
  repositoryUrl: opts.repositoryUrl,
6066
- landingInfo: { name: opts.name, doc: opts.doc, version: opts.version }
6451
+ landingInfo: { name: opts.name, doc: opts.doc, version: opts.version },
6452
+ authenticate: opts.authenticate
6067
6453
  });
6068
6454
  }
6069
6455
  function serveVgiWorker(opts) {
@@ -6086,13 +6472,13 @@ function serveVgiWorker(opts) {
6086
6472
  return server;
6087
6473
  }
6088
6474
  export {
6089
- serveVgiWorker,
6090
- resolveSigningKey,
6091
- parseSigningKeyHex,
6092
- createVgiWorkerFetch,
6093
- SIGNING_KEY_BYTES,
6475
+ DEFAULT_PORT,
6094
6476
  DEFAULT_TOKEN_TTL,
6095
- DEFAULT_PORT
6477
+ SIGNING_KEY_BYTES,
6478
+ createVgiWorkerFetch,
6479
+ parseSigningKeyHex,
6480
+ resolveSigningKey,
6481
+ serveVgiWorker
6096
6482
  };
6097
6483
 
6098
- //# debugId=AF152B2CA425E9C164756E2164756E21
6484
+ //# debugId=09DDD8782DD92B2764756E2164756E21