@query-farm/vgi 0.41.0 → 0.43.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 (35) hide show
  1. package/dist/generated/vgi-service.d.ts +1315 -0
  2. package/dist/index.js +1845 -780
  3. package/dist/index.js.map +16 -15
  4. package/dist/protocol/dispatch.d.ts +25 -3
  5. package/dist/protocol/handlers/aggregate.d.ts +3 -2
  6. package/dist/protocol/handlers/catalog/admin.d.ts +2 -2
  7. package/dist/protocol/handlers/catalog/index.d.ts +3 -2
  8. package/dist/protocol/handlers/catalog/index_methods.d.ts +2 -2
  9. package/dist/protocol/handlers/catalog/macro.d.ts +2 -2
  10. package/dist/protocol/handlers/catalog/shared.d.ts +7 -14
  11. package/dist/protocol/handlers/catalog/table.d.ts +2 -2
  12. package/dist/protocol/handlers/catalog/view.d.ts +2 -2
  13. package/dist/protocol/handlers/function.d.ts +3 -2
  14. package/dist/protocol/handlers/shared.d.ts +0 -1
  15. package/dist/protocol/handlers/table-buffering.d.ts +3 -2
  16. package/dist/protocol/handlers/unimplemented.d.ts +4 -0
  17. package/dist/serve-entry.js +1844 -780
  18. package/dist/serve-entry.js.map +16 -15
  19. package/dist/worker-cf-entry.js +1845 -780
  20. package/dist/worker-cf-entry.js.map +16 -15
  21. package/package.json +1 -1
  22. package/src/generated/vgi-service.ts +2678 -0
  23. package/src/protocol/dispatch.ts +51 -24
  24. package/src/protocol/handlers/aggregate.ts +205 -232
  25. package/src/protocol/handlers/catalog/admin.ts +228 -299
  26. package/src/protocol/handlers/catalog/index.ts +17 -16
  27. package/src/protocol/handlers/catalog/index_methods.ts +26 -36
  28. package/src/protocol/handlers/catalog/macro.ts +54 -77
  29. package/src/protocol/handlers/catalog/shared.ts +30 -47
  30. package/src/protocol/handlers/catalog/table.ts +205 -270
  31. package/src/protocol/handlers/catalog/view.ts +59 -85
  32. package/src/protocol/handlers/function.ts +127 -156
  33. package/src/protocol/handlers/shared.ts +0 -4
  34. package/src/protocol/handlers/table-buffering.ts +53 -71
  35. package/src/protocol/handlers/unimplemented.ts +30 -0
@@ -4675,8 +4675,1260 @@ var arrowStateSerializer = {
4675
4675
  }
4676
4676
  };
4677
4677
 
4678
- // src/protocol/dispatch.ts
4679
- import { Protocol as Protocol2 } from "@query-farm/vgi-rpc";
4678
+ // src/generated/vgi-service.ts
4679
+ init_arrow();
4680
+ import {
4681
+ MethodNotImplementedError,
4682
+ Protocol
4683
+ } from "@query-farm/vgi-rpc";
4684
+ var VGI_PROTOCOL_NAME = "vgi.v2";
4685
+ var VGI_PROTOCOL_VERSION = "2.1.0";
4686
+ function exchangeStream(callbacks) {
4687
+ return { kind: "exchange", ...callbacks };
4688
+ }
4689
+ function producerStream(callbacks) {
4690
+ return { kind: "producer", ...callbacks };
4691
+ }
4692
+ var VGI_V2_METHODS = [
4693
+ {
4694
+ name: "aggregate_bind",
4695
+ key: "aggregateBind",
4696
+ type: "unary",
4697
+ params: schema2([
4698
+ field2("request", binary2(), false)
4699
+ ]),
4700
+ result: schema2([
4701
+ field2("result", binary2(), false)
4702
+ ]),
4703
+ doc: "Bind an aggregate function, return output schema and execution_id."
4704
+ },
4705
+ {
4706
+ name: "aggregate_combine",
4707
+ key: "aggregateCombine",
4708
+ type: "unary",
4709
+ params: schema2([
4710
+ field2("request", binary2(), false)
4711
+ ]),
4712
+ result: schema2([
4713
+ field2("result", binary2(), false)
4714
+ ]),
4715
+ doc: "Merge source states into target states."
4716
+ },
4717
+ {
4718
+ name: "aggregate_destructor",
4719
+ key: "aggregateDestructor",
4720
+ type: "unary",
4721
+ params: schema2([
4722
+ field2("request", binary2(), false)
4723
+ ]),
4724
+ result: schema2([
4725
+ field2("result", binary2(), false)
4726
+ ]),
4727
+ doc: "Best-effort cleanup of aggregate states. Must not raise."
4728
+ },
4729
+ {
4730
+ name: "aggregate_finalize",
4731
+ key: "aggregateFinalize",
4732
+ type: "unary",
4733
+ params: schema2([
4734
+ field2("request", binary2(), false)
4735
+ ]),
4736
+ result: schema2([
4737
+ field2("result", binary2(), false)
4738
+ ]),
4739
+ doc: "Produce results for a chunk of group_ids."
4740
+ },
4741
+ {
4742
+ name: "aggregate_streaming_chunk",
4743
+ key: "aggregateStreamingChunk",
4744
+ type: "unary",
4745
+ params: schema2([
4746
+ field2("request", binary2(), false)
4747
+ ]),
4748
+ result: schema2([
4749
+ field2("result", binary2(), false)
4750
+ ]),
4751
+ doc: "Process one input chunk; returns one output row per input row."
4752
+ },
4753
+ {
4754
+ name: "aggregate_streaming_close",
4755
+ key: "aggregateStreamingClose",
4756
+ type: "unary",
4757
+ params: schema2([
4758
+ field2("request", binary2(), false)
4759
+ ]),
4760
+ result: schema2([
4761
+ field2("result", binary2(), false)
4762
+ ]),
4763
+ doc: "End the streaming session, free per-session state."
4764
+ },
4765
+ {
4766
+ name: "aggregate_streaming_open",
4767
+ key: "aggregateStreamingOpen",
4768
+ type: "unary",
4769
+ params: schema2([
4770
+ field2("request", binary2(), false)
4771
+ ]),
4772
+ result: schema2([
4773
+ field2("result", binary2(), false)
4774
+ ]),
4775
+ doc: "Start a streaming-partitioned aggregate session."
4776
+ },
4777
+ {
4778
+ name: "aggregate_update",
4779
+ key: "aggregateUpdate",
4780
+ type: "unary",
4781
+ params: schema2([
4782
+ field2("request", binary2(), false)
4783
+ ]),
4784
+ result: schema2([
4785
+ field2("result", binary2(), false)
4786
+ ]),
4787
+ doc: "Accumulate rows from a `DataChunk` into per-group state."
4788
+ },
4789
+ {
4790
+ name: "aggregate_window",
4791
+ key: "aggregateWindow",
4792
+ type: "unary",
4793
+ params: schema2([
4794
+ field2("request", binary2(), false)
4795
+ ]),
4796
+ result: schema2([
4797
+ field2("result", binary2(), false)
4798
+ ]),
4799
+ doc: "Compute an aggregate value for one output row of the window."
4800
+ },
4801
+ {
4802
+ name: "aggregate_window_batch",
4803
+ key: "aggregateWindowBatch",
4804
+ type: "unary",
4805
+ params: schema2([
4806
+ field2("request", binary2(), false)
4807
+ ]),
4808
+ result: schema2([
4809
+ field2("result", binary2(), false)
4810
+ ]),
4811
+ doc: "Compute ``count`` window output rows in one batched RPC."
4812
+ },
4813
+ {
4814
+ name: "aggregate_window_destructor",
4815
+ key: "aggregateWindowDestructor",
4816
+ type: "unary",
4817
+ params: schema2([
4818
+ field2("request", binary2(), false)
4819
+ ]),
4820
+ result: schema2([
4821
+ field2("result", binary2(), false)
4822
+ ]),
4823
+ doc: "Evict a cached partition from storage."
4824
+ },
4825
+ {
4826
+ name: "aggregate_window_init",
4827
+ key: "aggregateWindowInit",
4828
+ type: "unary",
4829
+ params: schema2([
4830
+ field2("request", binary2(), false)
4831
+ ]),
4832
+ result: schema2([
4833
+ field2("result", binary2(), false)
4834
+ ]),
4835
+ doc: "Ship a partition to the worker for windowed aggregation."
4836
+ },
4837
+ {
4838
+ name: "bind",
4839
+ key: "bind",
4840
+ type: "unary",
4841
+ params: schema2([
4842
+ field2("request", binary2(), false)
4843
+ ]),
4844
+ result: schema2([
4845
+ field2("result", binary2(), false)
4846
+ ]),
4847
+ doc: "Resolve output schema and validate arguments."
4848
+ },
4849
+ {
4850
+ name: "catalog_attach",
4851
+ key: "catalogAttach",
4852
+ type: "unary",
4853
+ params: schema2([
4854
+ field2("request", binary2(), false)
4855
+ ]),
4856
+ result: schema2([
4857
+ field2("result", binary2(), false)
4858
+ ]),
4859
+ doc: "Attach to a catalog with options."
4860
+ },
4861
+ {
4862
+ name: "catalog_catalogs",
4863
+ key: "catalogCatalogs",
4864
+ type: "unary",
4865
+ params: schema2([]),
4866
+ result: schema2([
4867
+ field2("result", binary2(), false)
4868
+ ]),
4869
+ doc: "List available catalog names."
4870
+ },
4871
+ {
4872
+ name: "catalog_contents",
4873
+ key: "catalogContents",
4874
+ type: "unary",
4875
+ params: schema2([
4876
+ field2("attach_opaque_data", binary2(), false),
4877
+ field2("if_none_match", utf82(), true)
4878
+ ]),
4879
+ result: schema2([
4880
+ field2("result", binary2(), false)
4881
+ ]),
4882
+ doc: "Return every schema and all of its contents in one result."
4883
+ },
4884
+ {
4885
+ name: "catalog_copy_from_formats",
4886
+ key: "catalogCopyFromFormats",
4887
+ type: "unary",
4888
+ params: schema2([
4889
+ field2("attach_opaque_data", binary2(), false),
4890
+ field2("transaction_opaque_data", binary2(), true)
4891
+ ]),
4892
+ result: schema2([
4893
+ field2("result", binary2(), false)
4894
+ ]),
4895
+ doc: "List custom ``COPY ... FROM`` formats advertised by this catalog."
4896
+ },
4897
+ {
4898
+ name: "catalog_create",
4899
+ key: "catalogCreate",
4900
+ type: "unary",
4901
+ params: schema2([
4902
+ field2("request", binary2(), false)
4903
+ ]),
4904
+ result: schema2([]),
4905
+ doc: "Create a new catalog."
4906
+ },
4907
+ {
4908
+ name: "catalog_detach",
4909
+ key: "catalogDetach",
4910
+ type: "unary",
4911
+ params: schema2([
4912
+ field2("attach_opaque_data", binary2(), false)
4913
+ ]),
4914
+ result: schema2([]),
4915
+ doc: "Detach from a catalog."
4916
+ },
4917
+ {
4918
+ name: "catalog_drop",
4919
+ key: "catalogDrop",
4920
+ type: "unary",
4921
+ params: schema2([
4922
+ field2("name", utf82(), false)
4923
+ ]),
4924
+ result: schema2([]),
4925
+ doc: "Drop a catalog."
4926
+ },
4927
+ {
4928
+ name: "catalog_index_create",
4929
+ key: "catalogIndexCreate",
4930
+ type: "unary",
4931
+ params: schema2([
4932
+ field2("request", binary2(), false)
4933
+ ]),
4934
+ result: schema2([]),
4935
+ doc: "Create a new index."
4936
+ },
4937
+ {
4938
+ name: "catalog_index_drop",
4939
+ key: "catalogIndexDrop",
4940
+ type: "unary",
4941
+ params: schema2([
4942
+ field2("attach_opaque_data", binary2(), false),
4943
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
4944
+ field2("name", utf82(), false),
4945
+ field2("ignore_not_found", bool2(), false),
4946
+ field2("cascade", bool2(), false),
4947
+ field2("transaction_opaque_data", binary2(), true)
4948
+ ]),
4949
+ result: schema2([]),
4950
+ doc: "Drop an index."
4951
+ },
4952
+ {
4953
+ name: "catalog_index_get",
4954
+ key: "catalogIndexGet",
4955
+ type: "unary",
4956
+ params: schema2([
4957
+ field2("attach_opaque_data", binary2(), false),
4958
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
4959
+ field2("name", utf82(), false),
4960
+ field2("transaction_opaque_data", binary2(), true)
4961
+ ]),
4962
+ result: schema2([
4963
+ field2("result", binary2(), false)
4964
+ ]),
4965
+ doc: "Get information about an index. Returns 0 or 1 items."
4966
+ },
4967
+ {
4968
+ name: "catalog_macro_create",
4969
+ key: "catalogMacroCreate",
4970
+ type: "unary",
4971
+ params: schema2([
4972
+ field2("request", binary2(), false)
4973
+ ]),
4974
+ result: schema2([]),
4975
+ doc: "Create a new macro."
4976
+ },
4977
+ {
4978
+ name: "catalog_macro_drop",
4979
+ key: "catalogMacroDrop",
4980
+ type: "unary",
4981
+ params: schema2([
4982
+ field2("attach_opaque_data", binary2(), false),
4983
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
4984
+ field2("name", utf82(), false),
4985
+ field2("ignore_not_found", bool2(), false),
4986
+ field2("transaction_opaque_data", binary2(), true)
4987
+ ]),
4988
+ result: schema2([]),
4989
+ doc: "Drop a macro."
4990
+ },
4991
+ {
4992
+ name: "catalog_macro_get",
4993
+ key: "catalogMacroGet",
4994
+ type: "unary",
4995
+ params: schema2([
4996
+ field2("attach_opaque_data", binary2(), false),
4997
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
4998
+ field2("name", utf82(), false),
4999
+ field2("transaction_opaque_data", binary2(), true)
5000
+ ]),
5001
+ result: schema2([
5002
+ field2("result", binary2(), false)
5003
+ ]),
5004
+ doc: "Get information about a macro. Returns 0 or 1 items."
5005
+ },
5006
+ {
5007
+ name: "catalog_schema_contents_functions",
5008
+ key: "catalogSchemaContentsFunctions",
5009
+ type: "unary",
5010
+ params: schema2([
5011
+ field2("attach_opaque_data", binary2(), false),
5012
+ field2("path", list2(field2("item", utf82(), true)), false),
5013
+ field2("type", dictionary2(utf82(), int162()), false),
5014
+ field2("transaction_opaque_data", binary2(), true)
5015
+ ]),
5016
+ result: schema2([
5017
+ field2("result", binary2(), false)
5018
+ ]),
5019
+ doc: "List functions in a schema (scalar or table)."
5020
+ },
5021
+ {
5022
+ name: "catalog_schema_contents_indexes",
5023
+ key: "catalogSchemaContentsIndexes",
5024
+ type: "unary",
5025
+ params: schema2([
5026
+ field2("attach_opaque_data", binary2(), false),
5027
+ field2("path", list2(field2("item", utf82(), true)), false),
5028
+ field2("transaction_opaque_data", binary2(), true)
5029
+ ]),
5030
+ result: schema2([
5031
+ field2("result", binary2(), false)
5032
+ ]),
5033
+ doc: "List indexes in a schema."
5034
+ },
5035
+ {
5036
+ name: "catalog_schema_contents_macros",
5037
+ key: "catalogSchemaContentsMacros",
5038
+ type: "unary",
5039
+ params: schema2([
5040
+ field2("attach_opaque_data", binary2(), false),
5041
+ field2("path", list2(field2("item", utf82(), true)), false),
5042
+ field2("type", dictionary2(utf82(), int162()), false),
5043
+ field2("transaction_opaque_data", binary2(), true)
5044
+ ]),
5045
+ result: schema2([
5046
+ field2("result", binary2(), false)
5047
+ ]),
5048
+ doc: "List macros in a schema (scalar or table)."
5049
+ },
5050
+ {
5051
+ name: "catalog_schema_contents_tables",
5052
+ key: "catalogSchemaContentsTables",
5053
+ type: "unary",
5054
+ params: schema2([
5055
+ field2("attach_opaque_data", binary2(), false),
5056
+ field2("path", list2(field2("item", utf82(), true)), false),
5057
+ field2("transaction_opaque_data", binary2(), true)
5058
+ ]),
5059
+ result: schema2([
5060
+ field2("result", binary2(), false)
5061
+ ]),
5062
+ doc: "List tables in a schema."
5063
+ },
5064
+ {
5065
+ name: "catalog_schema_contents_views",
5066
+ key: "catalogSchemaContentsViews",
5067
+ type: "unary",
5068
+ params: schema2([
5069
+ field2("attach_opaque_data", binary2(), false),
5070
+ field2("path", list2(field2("item", utf82(), true)), false),
5071
+ field2("transaction_opaque_data", binary2(), true)
5072
+ ]),
5073
+ result: schema2([
5074
+ field2("result", binary2(), false)
5075
+ ]),
5076
+ doc: "List views in a schema."
5077
+ },
5078
+ {
5079
+ name: "catalog_schema_create",
5080
+ key: "catalogSchemaCreate",
5081
+ type: "unary",
5082
+ params: schema2([
5083
+ field2("attach_opaque_data", binary2(), false),
5084
+ field2("path", list2(field2("item", utf82(), true)), false),
5085
+ field2("on_conflict", dictionary2(utf82(), int162()), false),
5086
+ field2("comment", utf82(), true),
5087
+ field2("tags", map2(field2("key", utf82(), false), field2("value", utf82(), true), false), true),
5088
+ field2("transaction_opaque_data", binary2(), true)
5089
+ ]),
5090
+ result: schema2([]),
5091
+ doc: "Create a new schema."
5092
+ },
5093
+ {
5094
+ name: "catalog_schema_drop",
5095
+ key: "catalogSchemaDrop",
5096
+ type: "unary",
5097
+ params: schema2([
5098
+ field2("attach_opaque_data", binary2(), false),
5099
+ field2("path", list2(field2("item", utf82(), true)), false),
5100
+ field2("ignore_not_found", bool2(), false),
5101
+ field2("cascade", bool2(), false),
5102
+ field2("transaction_opaque_data", binary2(), true)
5103
+ ]),
5104
+ result: schema2([]),
5105
+ doc: "Drop a schema."
5106
+ },
5107
+ {
5108
+ name: "catalog_schema_get",
5109
+ key: "catalogSchemaGet",
5110
+ type: "unary",
5111
+ params: schema2([
5112
+ field2("attach_opaque_data", binary2(), false),
5113
+ field2("path", list2(field2("item", utf82(), true)), false),
5114
+ field2("transaction_opaque_data", binary2(), true)
5115
+ ]),
5116
+ result: schema2([
5117
+ field2("result", binary2(), false)
5118
+ ]),
5119
+ doc: "Get information about a schema. Returns 0 or 1 items."
5120
+ },
5121
+ {
5122
+ name: "catalog_schemas",
5123
+ key: "catalogSchemas",
5124
+ type: "unary",
5125
+ params: schema2([
5126
+ field2("attach_opaque_data", binary2(), false),
5127
+ field2("transaction_opaque_data", binary2(), true)
5128
+ ]),
5129
+ result: schema2([
5130
+ field2("result", binary2(), false)
5131
+ ]),
5132
+ doc: "List schemas in the catalog."
5133
+ },
5134
+ {
5135
+ name: "catalog_table_column_add",
5136
+ key: "catalogTableColumnAdd",
5137
+ type: "unary",
5138
+ params: schema2([
5139
+ field2("attach_opaque_data", binary2(), false),
5140
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
5141
+ field2("name", utf82(), false),
5142
+ field2("column_definition", binary2(), false),
5143
+ field2("ignore_not_found", bool2(), false),
5144
+ field2("if_column_not_exists", bool2(), false),
5145
+ field2("transaction_opaque_data", binary2(), true)
5146
+ ]),
5147
+ result: schema2([]),
5148
+ doc: "Add a new column to a table."
5149
+ },
5150
+ {
5151
+ name: "catalog_table_column_comment_set",
5152
+ key: "catalogTableColumnCommentSet",
5153
+ type: "unary",
5154
+ params: schema2([
5155
+ field2("attach_opaque_data", binary2(), false),
5156
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
5157
+ field2("name", utf82(), false),
5158
+ field2("column_name", utf82(), false),
5159
+ field2("comment", utf82(), true),
5160
+ field2("ignore_not_found", bool2(), false),
5161
+ field2("transaction_opaque_data", binary2(), true)
5162
+ ]),
5163
+ result: schema2([]),
5164
+ doc: "Set or clear the comment on a table column."
5165
+ },
5166
+ {
5167
+ name: "catalog_table_column_default_drop",
5168
+ key: "catalogTableColumnDefaultDrop",
5169
+ type: "unary",
5170
+ params: schema2([
5171
+ field2("attach_opaque_data", binary2(), false),
5172
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
5173
+ field2("name", utf82(), false),
5174
+ field2("column_name", utf82(), false),
5175
+ field2("ignore_not_found", bool2(), false),
5176
+ field2("transaction_opaque_data", binary2(), true)
5177
+ ]),
5178
+ result: schema2([]),
5179
+ doc: "Remove the default value from a column."
5180
+ },
5181
+ {
5182
+ name: "catalog_table_column_default_set",
5183
+ key: "catalogTableColumnDefaultSet",
5184
+ type: "unary",
5185
+ params: schema2([
5186
+ field2("attach_opaque_data", binary2(), false),
5187
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
5188
+ field2("name", utf82(), false),
5189
+ field2("column_name", utf82(), false),
5190
+ field2("expression", utf82(), false),
5191
+ field2("ignore_not_found", bool2(), false),
5192
+ field2("transaction_opaque_data", binary2(), true)
5193
+ ]),
5194
+ result: schema2([]),
5195
+ doc: "Set the default value expression for a column."
5196
+ },
5197
+ {
5198
+ name: "catalog_table_column_drop",
5199
+ key: "catalogTableColumnDrop",
5200
+ type: "unary",
5201
+ params: schema2([
5202
+ field2("attach_opaque_data", binary2(), false),
5203
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
5204
+ field2("name", utf82(), false),
5205
+ field2("column_name", utf82(), false),
5206
+ field2("ignore_not_found", bool2(), false),
5207
+ field2("if_column_exists", bool2(), false),
5208
+ field2("cascade", bool2(), false),
5209
+ field2("transaction_opaque_data", binary2(), true)
5210
+ ]),
5211
+ result: schema2([]),
5212
+ doc: "Drop a column from a table."
5213
+ },
5214
+ {
5215
+ name: "catalog_table_column_rename",
5216
+ key: "catalogTableColumnRename",
5217
+ type: "unary",
5218
+ params: schema2([
5219
+ field2("attach_opaque_data", binary2(), false),
5220
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
5221
+ field2("name", utf82(), false),
5222
+ field2("column_name", utf82(), false),
5223
+ field2("new_column_name", utf82(), false),
5224
+ field2("ignore_not_found", bool2(), false),
5225
+ field2("transaction_opaque_data", binary2(), true)
5226
+ ]),
5227
+ result: schema2([]),
5228
+ doc: "Rename a column."
5229
+ },
5230
+ {
5231
+ name: "catalog_table_column_statistics_get",
5232
+ key: "catalogTableColumnStatisticsGet",
5233
+ type: "unary",
5234
+ params: schema2([
5235
+ field2("attach_opaque_data", binary2(), false),
5236
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
5237
+ field2("name", utf82(), false),
5238
+ field2("transaction_opaque_data", binary2(), true)
5239
+ ]),
5240
+ result: schema2([
5241
+ field2("result", binary2(), true)
5242
+ ]),
5243
+ doc: "Get column statistics for a table."
5244
+ },
5245
+ {
5246
+ name: "catalog_table_column_type_change",
5247
+ key: "catalogTableColumnTypeChange",
5248
+ type: "unary",
5249
+ params: schema2([
5250
+ field2("attach_opaque_data", binary2(), false),
5251
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
5252
+ field2("name", utf82(), false),
5253
+ field2("column_definition", binary2(), false),
5254
+ field2("expression", utf82(), true),
5255
+ field2("ignore_not_found", bool2(), false),
5256
+ field2("transaction_opaque_data", binary2(), true)
5257
+ ]),
5258
+ result: schema2([]),
5259
+ doc: "Change the type of a column."
5260
+ },
5261
+ {
5262
+ name: "catalog_table_comment_set",
5263
+ key: "catalogTableCommentSet",
5264
+ type: "unary",
5265
+ params: schema2([
5266
+ field2("attach_opaque_data", binary2(), false),
5267
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
5268
+ field2("name", utf82(), false),
5269
+ field2("comment", utf82(), true),
5270
+ field2("ignore_not_found", bool2(), false),
5271
+ field2("transaction_opaque_data", binary2(), true)
5272
+ ]),
5273
+ result: schema2([]),
5274
+ doc: "Set or clear the comment on a table."
5275
+ },
5276
+ {
5277
+ name: "catalog_table_create",
5278
+ key: "catalogTableCreate",
5279
+ type: "unary",
5280
+ params: schema2([
5281
+ field2("request", binary2(), false)
5282
+ ]),
5283
+ result: schema2([]),
5284
+ doc: "Create a new table."
5285
+ },
5286
+ {
5287
+ name: "catalog_table_delete_function_get",
5288
+ key: "catalogTableDeleteFunctionGet",
5289
+ type: "unary",
5290
+ params: schema2([
5291
+ field2("attach_opaque_data", binary2(), false),
5292
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
5293
+ field2("name", utf82(), false),
5294
+ field2("transaction_opaque_data", binary2(), true)
5295
+ ]),
5296
+ result: schema2([
5297
+ field2("result", binary2(), false)
5298
+ ]),
5299
+ doc: "Get the delete function for a table. Returns `WriteFunctionResult` as IPC bytes."
5300
+ },
5301
+ {
5302
+ name: "catalog_table_drop",
5303
+ key: "catalogTableDrop",
5304
+ type: "unary",
5305
+ params: schema2([
5306
+ field2("attach_opaque_data", binary2(), false),
5307
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
5308
+ field2("name", utf82(), false),
5309
+ field2("ignore_not_found", bool2(), false),
5310
+ field2("cascade", bool2(), false),
5311
+ field2("transaction_opaque_data", binary2(), true)
5312
+ ]),
5313
+ result: schema2([]),
5314
+ doc: "Drop a table."
5315
+ },
5316
+ {
5317
+ name: "catalog_table_get",
5318
+ key: "catalogTableGet",
5319
+ type: "unary",
5320
+ params: schema2([
5321
+ field2("attach_opaque_data", binary2(), false),
5322
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
5323
+ field2("name", utf82(), false),
5324
+ field2("at_unit", utf82(), true),
5325
+ field2("at_value", utf82(), true),
5326
+ field2("transaction_opaque_data", binary2(), true)
5327
+ ]),
5328
+ result: schema2([
5329
+ field2("result", binary2(), false)
5330
+ ]),
5331
+ doc: "Get information about a table. Returns 0 or 1 items."
5332
+ },
5333
+ {
5334
+ name: "catalog_table_insert_function_get",
5335
+ key: "catalogTableInsertFunctionGet",
5336
+ type: "unary",
5337
+ params: schema2([
5338
+ field2("attach_opaque_data", binary2(), false),
5339
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
5340
+ field2("name", utf82(), false),
5341
+ field2("transaction_opaque_data", binary2(), true),
5342
+ field2("writable_branch_function_name", utf82(), true)
5343
+ ]),
5344
+ result: schema2([
5345
+ field2("result", binary2(), false)
5346
+ ]),
5347
+ doc: "Get the insert function for a table. Returns `WriteFunctionResult` as IPC bytes."
5348
+ },
5349
+ {
5350
+ name: "catalog_table_not_null_drop",
5351
+ key: "catalogTableNotNullDrop",
5352
+ type: "unary",
5353
+ params: schema2([
5354
+ field2("attach_opaque_data", binary2(), false),
5355
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
5356
+ field2("name", utf82(), false),
5357
+ field2("column_name", utf82(), false),
5358
+ field2("ignore_not_found", bool2(), false),
5359
+ field2("transaction_opaque_data", binary2(), true)
5360
+ ]),
5361
+ result: schema2([]),
5362
+ doc: "Remove NOT NULL constraint from a column."
5363
+ },
5364
+ {
5365
+ name: "catalog_table_not_null_set",
5366
+ key: "catalogTableNotNullSet",
5367
+ type: "unary",
5368
+ params: schema2([
5369
+ field2("attach_opaque_data", binary2(), false),
5370
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
5371
+ field2("name", utf82(), false),
5372
+ field2("column_name", utf82(), false),
5373
+ field2("ignore_not_found", bool2(), false),
5374
+ field2("transaction_opaque_data", binary2(), true)
5375
+ ]),
5376
+ result: schema2([]),
5377
+ doc: "Add NOT NULL constraint to a column."
5378
+ },
5379
+ {
5380
+ name: "catalog_table_rename",
5381
+ key: "catalogTableRename",
5382
+ type: "unary",
5383
+ params: schema2([
5384
+ field2("attach_opaque_data", binary2(), false),
5385
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
5386
+ field2("name", utf82(), false),
5387
+ field2("new_name", utf82(), false),
5388
+ field2("ignore_not_found", bool2(), false),
5389
+ field2("transaction_opaque_data", binary2(), true)
5390
+ ]),
5391
+ result: schema2([]),
5392
+ doc: "Rename a table."
5393
+ },
5394
+ {
5395
+ name: "catalog_table_scan_branches_get",
5396
+ key: "catalogTableScanBranchesGet",
5397
+ type: "unary",
5398
+ params: schema2([
5399
+ field2("attach_opaque_data", binary2(), false),
5400
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
5401
+ field2("name", utf82(), false),
5402
+ field2("at_unit", utf82(), true),
5403
+ field2("at_value", utf82(), true),
5404
+ field2("transaction_opaque_data", binary2(), true)
5405
+ ]),
5406
+ result: schema2([
5407
+ field2("result", binary2(), false)
5408
+ ]),
5409
+ doc: "Get the list of scan branches for a multi-branch table. Returns `ScanBranchesResult` as IPC bytes."
5410
+ },
5411
+ {
5412
+ name: "catalog_table_scan_function_get",
5413
+ key: "catalogTableScanFunctionGet",
5414
+ type: "unary",
5415
+ params: schema2([
5416
+ field2("attach_opaque_data", binary2(), false),
5417
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
5418
+ field2("name", utf82(), false),
5419
+ field2("at_unit", utf82(), true),
5420
+ field2("at_value", utf82(), true),
5421
+ field2("transaction_opaque_data", binary2(), true)
5422
+ ]),
5423
+ result: schema2([
5424
+ field2("result", binary2(), false)
5425
+ ]),
5426
+ doc: "Get the scan function for a table. Returns `ScanFunctionResult` as IPC bytes."
5427
+ },
5428
+ {
5429
+ name: "catalog_table_update_function_get",
5430
+ key: "catalogTableUpdateFunctionGet",
5431
+ type: "unary",
5432
+ params: schema2([
5433
+ field2("attach_opaque_data", binary2(), false),
5434
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
5435
+ field2("name", utf82(), false),
5436
+ field2("transaction_opaque_data", binary2(), true)
5437
+ ]),
5438
+ result: schema2([
5439
+ field2("result", binary2(), false)
5440
+ ]),
5441
+ doc: "Get the update function for a table. Returns `WriteFunctionResult` as IPC bytes."
5442
+ },
5443
+ {
5444
+ name: "catalog_transaction_begin",
5445
+ key: "catalogTransactionBegin",
5446
+ type: "unary",
5447
+ params: schema2([
5448
+ field2("attach_opaque_data", binary2(), false)
5449
+ ]),
5450
+ result: schema2([
5451
+ field2("result", binary2(), false)
5452
+ ]),
5453
+ doc: "Begin a new transaction."
5454
+ },
5455
+ {
5456
+ name: "catalog_transaction_commit",
5457
+ key: "catalogTransactionCommit",
5458
+ type: "unary",
5459
+ params: schema2([
5460
+ field2("attach_opaque_data", binary2(), false),
5461
+ field2("transaction_opaque_data", binary2(), false)
5462
+ ]),
5463
+ result: schema2([]),
5464
+ doc: "Commit a transaction."
5465
+ },
5466
+ {
5467
+ name: "catalog_transaction_rollback",
5468
+ key: "catalogTransactionRollback",
5469
+ type: "unary",
5470
+ params: schema2([
5471
+ field2("attach_opaque_data", binary2(), false),
5472
+ field2("transaction_opaque_data", binary2(), false)
5473
+ ]),
5474
+ result: schema2([]),
5475
+ doc: "Rollback a transaction."
5476
+ },
5477
+ {
5478
+ name: "catalog_version",
5479
+ key: "catalogVersion",
5480
+ type: "unary",
5481
+ params: schema2([
5482
+ field2("attach_opaque_data", binary2(), false),
5483
+ field2("transaction_opaque_data", binary2(), true)
5484
+ ]),
5485
+ result: schema2([
5486
+ field2("result", binary2(), false)
5487
+ ]),
5488
+ doc: "Get the current catalog version."
5489
+ },
5490
+ {
5491
+ name: "catalog_view_comment_set",
5492
+ key: "catalogViewCommentSet",
5493
+ type: "unary",
5494
+ params: schema2([
5495
+ field2("attach_opaque_data", binary2(), false),
5496
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
5497
+ field2("name", utf82(), false),
5498
+ field2("comment", utf82(), true),
5499
+ field2("ignore_not_found", bool2(), false),
5500
+ field2("transaction_opaque_data", binary2(), true)
5501
+ ]),
5502
+ result: schema2([]),
5503
+ doc: "Set or clear the comment on a view."
5504
+ },
5505
+ {
5506
+ name: "catalog_view_create",
5507
+ key: "catalogViewCreate",
5508
+ type: "unary",
5509
+ params: schema2([
5510
+ field2("attach_opaque_data", binary2(), false),
5511
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
5512
+ field2("name", utf82(), false),
5513
+ field2("definition", utf82(), false),
5514
+ field2("on_conflict", dictionary2(utf82(), int162()), false),
5515
+ field2("transaction_opaque_data", binary2(), true)
5516
+ ]),
5517
+ result: schema2([]),
5518
+ doc: "Create a new view."
5519
+ },
5520
+ {
5521
+ name: "catalog_view_drop",
5522
+ key: "catalogViewDrop",
5523
+ type: "unary",
5524
+ params: schema2([
5525
+ field2("attach_opaque_data", binary2(), false),
5526
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
5527
+ field2("name", utf82(), false),
5528
+ field2("ignore_not_found", bool2(), false),
5529
+ field2("cascade", bool2(), false),
5530
+ field2("transaction_opaque_data", binary2(), true)
5531
+ ]),
5532
+ result: schema2([]),
5533
+ doc: "Drop a view."
5534
+ },
5535
+ {
5536
+ name: "catalog_view_get",
5537
+ key: "catalogViewGet",
5538
+ type: "unary",
5539
+ params: schema2([
5540
+ field2("attach_opaque_data", binary2(), false),
5541
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
5542
+ field2("name", utf82(), false),
5543
+ field2("transaction_opaque_data", binary2(), true)
5544
+ ]),
5545
+ result: schema2([
5546
+ field2("result", binary2(), false)
5547
+ ]),
5548
+ doc: "Get information about a view. Returns 0 or 1 items."
5549
+ },
5550
+ {
5551
+ name: "catalog_view_rename",
5552
+ key: "catalogViewRename",
5553
+ type: "unary",
5554
+ params: schema2([
5555
+ field2("attach_opaque_data", binary2(), false),
5556
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
5557
+ field2("name", utf82(), false),
5558
+ field2("new_name", utf82(), false),
5559
+ field2("ignore_not_found", bool2(), false),
5560
+ field2("transaction_opaque_data", binary2(), true)
5561
+ ]),
5562
+ result: schema2([]),
5563
+ doc: "Rename a view."
5564
+ },
5565
+ {
5566
+ name: "init",
5567
+ key: "init",
5568
+ type: "stream",
5569
+ params: schema2([
5570
+ field2("request", binary2(), false)
5571
+ ]),
5572
+ header: schema2([
5573
+ field2("execution_id", binary2(), false),
5574
+ field2("opaque_data", binary2(), true),
5575
+ field2("max_workers", int642(), false)
5576
+ ]),
5577
+ doc: "Initialize a function execution and return a processing stream."
5578
+ },
5579
+ {
5580
+ name: "table_buffering_combine",
5581
+ key: "tableBufferingCombine",
5582
+ type: "unary",
5583
+ params: schema2([
5584
+ field2("request", binary2(), false)
5585
+ ]),
5586
+ result: schema2([
5587
+ field2("result", binary2(), false)
5588
+ ]),
5589
+ doc: "Once-per-query end-of-input signal. Returns finalize_state_ids."
5590
+ },
5591
+ {
5592
+ name: "table_buffering_destructor",
5593
+ key: "tableBufferingDestructor",
5594
+ type: "unary",
5595
+ params: schema2([
5596
+ field2("request", binary2(), false)
5597
+ ]),
5598
+ result: schema2([
5599
+ field2("result", binary2(), false)
5600
+ ]),
5601
+ doc: "Best-effort end-of-query cleanup. Must not raise."
5602
+ },
5603
+ {
5604
+ name: "table_buffering_process",
5605
+ key: "tableBufferingProcess",
5606
+ type: "unary",
5607
+ params: schema2([
5608
+ field2("request", binary2(), false)
5609
+ ]),
5610
+ result: schema2([
5611
+ field2("result", binary2(), false)
5612
+ ]),
5613
+ doc: "Sink one input batch; return the worker-chosen state_id."
5614
+ },
5615
+ {
5616
+ name: "table_function_cardinality",
5617
+ key: "tableFunctionCardinality",
5618
+ type: "unary",
5619
+ params: schema2([
5620
+ field2("request", binary2(), false)
5621
+ ]),
5622
+ result: schema2([
5623
+ field2("result", binary2(), false)
5624
+ ]),
5625
+ doc: "Estimate the cardinality of a table function's output."
5626
+ },
5627
+ {
5628
+ name: "table_function_dynamic_to_string",
5629
+ key: "tableFunctionDynamicToString",
5630
+ type: "unary",
5631
+ params: schema2([
5632
+ field2("request", binary2(), false)
5633
+ ]),
5634
+ result: schema2([
5635
+ field2("result", binary2(), false)
5636
+ ]),
5637
+ doc: "Return user-defined diagnostics for EXPLAIN ANALYZE Extra Info."
5638
+ },
5639
+ {
5640
+ name: "table_function_plan",
5641
+ key: "tableFunctionPlan",
5642
+ type: "unary",
5643
+ params: schema2([
5644
+ field2("request", binary2(), false)
5645
+ ]),
5646
+ result: schema2([
5647
+ field2("result", binary2(), false)
5648
+ ]),
5649
+ doc: "Plan a table-function scan into named, independently redeemable splits."
5650
+ },
5651
+ {
5652
+ name: "table_function_statistics",
5653
+ key: "tableFunctionStatistics",
5654
+ type: "unary",
5655
+ params: schema2([
5656
+ field2("request", binary2(), false)
5657
+ ]),
5658
+ result: schema2([
5659
+ field2("result", binary2(), true)
5660
+ ]),
5661
+ doc: "Return per-column statistics for a table function's output."
5662
+ }
5663
+ ];
5664
+ var UNIMPLEMENTED_VGI_SERVICE = Object.freeze({
5665
+ aggregateBind: async () => {
5666
+ throw notImplemented("aggregate_bind");
5667
+ },
5668
+ aggregateCombine: async () => {
5669
+ throw notImplemented("aggregate_combine");
5670
+ },
5671
+ aggregateDestructor: async () => {
5672
+ throw notImplemented("aggregate_destructor");
5673
+ },
5674
+ aggregateFinalize: async () => {
5675
+ throw notImplemented("aggregate_finalize");
5676
+ },
5677
+ aggregateStreamingChunk: async () => {
5678
+ throw notImplemented("aggregate_streaming_chunk");
5679
+ },
5680
+ aggregateStreamingClose: async () => {
5681
+ throw notImplemented("aggregate_streaming_close");
5682
+ },
5683
+ aggregateStreamingOpen: async () => {
5684
+ throw notImplemented("aggregate_streaming_open");
5685
+ },
5686
+ aggregateUpdate: async () => {
5687
+ throw notImplemented("aggregate_update");
5688
+ },
5689
+ aggregateWindow: async () => {
5690
+ throw notImplemented("aggregate_window");
5691
+ },
5692
+ aggregateWindowBatch: async () => {
5693
+ throw notImplemented("aggregate_window_batch");
5694
+ },
5695
+ aggregateWindowDestructor: async () => {
5696
+ throw notImplemented("aggregate_window_destructor");
5697
+ },
5698
+ aggregateWindowInit: async () => {
5699
+ throw notImplemented("aggregate_window_init");
5700
+ },
5701
+ bind: async () => {
5702
+ throw notImplemented("bind");
5703
+ },
5704
+ catalogAttach: async () => {
5705
+ throw notImplemented("catalog_attach");
5706
+ },
5707
+ catalogCatalogs: async () => {
5708
+ throw notImplemented("catalog_catalogs");
5709
+ },
5710
+ catalogContents: async () => {
5711
+ throw notImplemented("catalog_contents");
5712
+ },
5713
+ catalogCopyFromFormats: async () => {
5714
+ throw notImplemented("catalog_copy_from_formats");
5715
+ },
5716
+ catalogCreate: async () => {
5717
+ throw notImplemented("catalog_create");
5718
+ },
5719
+ catalogDetach: async () => {
5720
+ throw notImplemented("catalog_detach");
5721
+ },
5722
+ catalogDrop: async () => {
5723
+ throw notImplemented("catalog_drop");
5724
+ },
5725
+ catalogIndexCreate: async () => {
5726
+ throw notImplemented("catalog_index_create");
5727
+ },
5728
+ catalogIndexDrop: async () => {
5729
+ throw notImplemented("catalog_index_drop");
5730
+ },
5731
+ catalogIndexGet: async () => {
5732
+ throw notImplemented("catalog_index_get");
5733
+ },
5734
+ catalogMacroCreate: async () => {
5735
+ throw notImplemented("catalog_macro_create");
5736
+ },
5737
+ catalogMacroDrop: async () => {
5738
+ throw notImplemented("catalog_macro_drop");
5739
+ },
5740
+ catalogMacroGet: async () => {
5741
+ throw notImplemented("catalog_macro_get");
5742
+ },
5743
+ catalogSchemaContentsFunctions: async () => {
5744
+ throw notImplemented("catalog_schema_contents_functions");
5745
+ },
5746
+ catalogSchemaContentsIndexes: async () => {
5747
+ throw notImplemented("catalog_schema_contents_indexes");
5748
+ },
5749
+ catalogSchemaContentsMacros: async () => {
5750
+ throw notImplemented("catalog_schema_contents_macros");
5751
+ },
5752
+ catalogSchemaContentsTables: async () => {
5753
+ throw notImplemented("catalog_schema_contents_tables");
5754
+ },
5755
+ catalogSchemaContentsViews: async () => {
5756
+ throw notImplemented("catalog_schema_contents_views");
5757
+ },
5758
+ catalogSchemaCreate: async () => {
5759
+ throw notImplemented("catalog_schema_create");
5760
+ },
5761
+ catalogSchemaDrop: async () => {
5762
+ throw notImplemented("catalog_schema_drop");
5763
+ },
5764
+ catalogSchemaGet: async () => {
5765
+ throw notImplemented("catalog_schema_get");
5766
+ },
5767
+ catalogSchemas: async () => {
5768
+ throw notImplemented("catalog_schemas");
5769
+ },
5770
+ catalogTableColumnAdd: async () => {
5771
+ throw notImplemented("catalog_table_column_add");
5772
+ },
5773
+ catalogTableColumnCommentSet: async () => {
5774
+ throw notImplemented("catalog_table_column_comment_set");
5775
+ },
5776
+ catalogTableColumnDefaultDrop: async () => {
5777
+ throw notImplemented("catalog_table_column_default_drop");
5778
+ },
5779
+ catalogTableColumnDefaultSet: async () => {
5780
+ throw notImplemented("catalog_table_column_default_set");
5781
+ },
5782
+ catalogTableColumnDrop: async () => {
5783
+ throw notImplemented("catalog_table_column_drop");
5784
+ },
5785
+ catalogTableColumnRename: async () => {
5786
+ throw notImplemented("catalog_table_column_rename");
5787
+ },
5788
+ catalogTableColumnStatisticsGet: async () => {
5789
+ throw notImplemented("catalog_table_column_statistics_get");
5790
+ },
5791
+ catalogTableColumnTypeChange: async () => {
5792
+ throw notImplemented("catalog_table_column_type_change");
5793
+ },
5794
+ catalogTableCommentSet: async () => {
5795
+ throw notImplemented("catalog_table_comment_set");
5796
+ },
5797
+ catalogTableCreate: async () => {
5798
+ throw notImplemented("catalog_table_create");
5799
+ },
5800
+ catalogTableDeleteFunctionGet: async () => {
5801
+ throw notImplemented("catalog_table_delete_function_get");
5802
+ },
5803
+ catalogTableDrop: async () => {
5804
+ throw notImplemented("catalog_table_drop");
5805
+ },
5806
+ catalogTableGet: async () => {
5807
+ throw notImplemented("catalog_table_get");
5808
+ },
5809
+ catalogTableInsertFunctionGet: async () => {
5810
+ throw notImplemented("catalog_table_insert_function_get");
5811
+ },
5812
+ catalogTableNotNullDrop: async () => {
5813
+ throw notImplemented("catalog_table_not_null_drop");
5814
+ },
5815
+ catalogTableNotNullSet: async () => {
5816
+ throw notImplemented("catalog_table_not_null_set");
5817
+ },
5818
+ catalogTableRename: async () => {
5819
+ throw notImplemented("catalog_table_rename");
5820
+ },
5821
+ catalogTableScanBranchesGet: async () => {
5822
+ throw notImplemented("catalog_table_scan_branches_get");
5823
+ },
5824
+ catalogTableScanFunctionGet: async () => {
5825
+ throw notImplemented("catalog_table_scan_function_get");
5826
+ },
5827
+ catalogTableUpdateFunctionGet: async () => {
5828
+ throw notImplemented("catalog_table_update_function_get");
5829
+ },
5830
+ catalogTransactionBegin: async () => {
5831
+ throw notImplemented("catalog_transaction_begin");
5832
+ },
5833
+ catalogTransactionCommit: async () => {
5834
+ throw notImplemented("catalog_transaction_commit");
5835
+ },
5836
+ catalogTransactionRollback: async () => {
5837
+ throw notImplemented("catalog_transaction_rollback");
5838
+ },
5839
+ catalogVersion: async () => {
5840
+ throw notImplemented("catalog_version");
5841
+ },
5842
+ catalogViewCommentSet: async () => {
5843
+ throw notImplemented("catalog_view_comment_set");
5844
+ },
5845
+ catalogViewCreate: async () => {
5846
+ throw notImplemented("catalog_view_create");
5847
+ },
5848
+ catalogViewDrop: async () => {
5849
+ throw notImplemented("catalog_view_drop");
5850
+ },
5851
+ catalogViewGet: async () => {
5852
+ throw notImplemented("catalog_view_get");
5853
+ },
5854
+ catalogViewRename: async () => {
5855
+ throw notImplemented("catalog_view_rename");
5856
+ },
5857
+ init: unimplementedStream("init"),
5858
+ tableBufferingCombine: async () => {
5859
+ throw notImplemented("table_buffering_combine");
5860
+ },
5861
+ tableBufferingDestructor: async () => {
5862
+ throw notImplemented("table_buffering_destructor");
5863
+ },
5864
+ tableBufferingProcess: async () => {
5865
+ throw notImplemented("table_buffering_process");
5866
+ },
5867
+ tableFunctionCardinality: async () => {
5868
+ throw notImplemented("table_function_cardinality");
5869
+ },
5870
+ tableFunctionDynamicToString: async () => {
5871
+ throw notImplemented("table_function_dynamic_to_string");
5872
+ },
5873
+ tableFunctionPlan: async () => {
5874
+ throw notImplemented("table_function_plan");
5875
+ },
5876
+ tableFunctionStatistics: async () => {
5877
+ throw notImplemented("table_function_statistics");
5878
+ }
5879
+ });
5880
+ function unimplementedMessage(method) {
5881
+ return `${method} is not implemented by this worker`;
5882
+ }
5883
+ function notImplemented(method) {
5884
+ return new MethodNotImplementedError(unimplementedMessage(method));
5885
+ }
5886
+ function unimplementedStream(method) {
5887
+ return producerStream({
5888
+ outputSchema: schema2([]),
5889
+ init: () => {
5890
+ throw notImplemented(method);
5891
+ },
5892
+ produce: () => {}
5893
+ });
5894
+ }
5895
+ function registerVgiService(protocol, service) {
5896
+ for (const m of VGI_V2_METHODS) {
5897
+ if (m.type === "unary") {
5898
+ const handler = service[m.key];
5899
+ protocol.unary(m.name, {
5900
+ params: m.params,
5901
+ result: m.result,
5902
+ doc: m.doc,
5903
+ handler: (params, ctx) => handler.call(service, params, ctx)
5904
+ });
5905
+ continue;
5906
+ }
5907
+ const stream = service[m.key];
5908
+ const common = {
5909
+ params: m.params,
5910
+ outputSchema: stream.outputSchema,
5911
+ headerSchema: m.header ?? undefined,
5912
+ headerInit: stream.headerInit,
5913
+ onCancel: stream.onCancel,
5914
+ doc: m.doc
5915
+ };
5916
+ if (stream.kind === "exchange") {
5917
+ protocol.exchange(m.name, {
5918
+ ...common,
5919
+ inputSchema: stream.inputSchema,
5920
+ init: stream.init,
5921
+ exchange: stream.exchange
5922
+ });
5923
+ } else {
5924
+ protocol.producer(m.name, { ...common, init: stream.init, produce: stream.produce });
5925
+ }
5926
+ }
5927
+ return protocol;
5928
+ }
5929
+ function createVgiProtocol(service) {
5930
+ return registerVgiService(new Protocol(VGI_PROTOCOL_NAME, { protocolVersion: VGI_PROTOCOL_VERSION }), service);
5931
+ }
4680
5932
 
4681
5933
  // src/protocol/handlers/function.ts
4682
5934
  init_arrow();
@@ -5686,9 +6938,6 @@ var RESULT_BINARY_SCHEMA = schema2([
5686
6938
  var REQUEST_PARAMS_SCHEMA = schema2([
5687
6939
  field2("request", binary2(), false)
5688
6940
  ]);
5689
- var RESULT_BINARY_NULLABLE_SCHEMA = schema2([
5690
- field2("result", binary2(), true)
5691
- ]);
5692
6941
  function unwrapRequest(requestBytes) {
5693
6942
  const bytes = toUint8Array(requestBytes);
5694
6943
  const innerBatch = deserializeBatch(bytes);
@@ -6600,20 +7849,16 @@ async function unwrapParamsOpaque(params, ctx, signingKey) {
6600
7849
  }
6601
7850
  }
6602
7851
  }
6603
- function catalogUnary(protocol, signingKey, name, config) {
6604
- protocol.unary(name, {
6605
- params: config.params,
6606
- result: config.result,
6607
- doc: config.doc,
6608
- handler: async (params, ctx) => {
6609
- if (params.request != null && params.attach_opaque_data === undefined && params.name === undefined) {
6610
- params = unwrapRequest(params.request);
6611
- }
6612
- normalizeRequestSchemaPaths(params);
6613
- await unwrapParamsOpaque(params, ctx, signingKey);
6614
- return config.handler(params, ctx);
7852
+ function catalogHandler(signingKey, handler) {
7853
+ return async (wire, ctx) => {
7854
+ let params = wire;
7855
+ if (params.request != null && params.attach_opaque_data === undefined && params.name === undefined) {
7856
+ params = unwrapRequest(params.request);
6615
7857
  }
6616
- });
7858
+ normalizeRequestSchemaPaths(params);
7859
+ await unwrapParamsOpaque(params, ctx, signingKey);
7860
+ return handler(params, ctx);
7861
+ };
6617
7862
  }
6618
7863
  function makeGetCatalog(catalog) {
6619
7864
  return () => {
@@ -6634,7 +7879,6 @@ function decodeOptionsBatch(bytes) {
6634
7879
  const row = iterRows(batch).next().value;
6635
7880
  return row ?? {};
6636
7881
  }
6637
- var emptyResultSchema = schema2([]);
6638
7882
 
6639
7883
  // src/request-auth.ts
6640
7884
  var scope;
@@ -6864,7 +8108,7 @@ async function resolveSplitPayloads(request, innerParams, opts) {
6864
8108
  }));
6865
8109
  }
6866
8110
  }
6867
- function registerFunctionMethods(protocol, config) {
8111
+ function functionHandlers(config) {
6868
8112
  const { registry, signingKey, catalogInterface } = config;
6869
8113
  async function stripAttach(attach, ctx) {
6870
8114
  if (attach == null)
@@ -6883,26 +8127,20 @@ function registerFunctionMethods(protocol, config) {
6883
8127
  }
6884
8128
  return overloadContext({ ...bindCall, attach_opaque_data: attach }, catalogInterface);
6885
8129
  }
6886
- const initHeaderSchema = GLOBAL_INIT_RESPONSE_SCHEMA;
6887
8130
  const emptySchema = schema2([]);
6888
8131
  const dummyInputSchema = schema2([
6889
8132
  field2("_tick", binary2(), true)
6890
8133
  ]);
6891
- protocol.unary("bind", {
6892
- params: BindParamsSchema,
6893
- result: RESULT_BINARY_SCHEMA,
6894
- handler: async (params, ctx) => {
6895
- const innerParams = unwrapRequest(params.request);
6896
- const request = deserializeBindRequest(innerParams);
6897
- request.attach_opaque_data = await stripAttach(request.attach_opaque_data, ctx);
6898
- const func = registry.get(request.function_name, overloadContext(request, catalogInterface));
6899
- const response = await func.bind(request);
6900
- const serialized = serializeBindResponse(response);
6901
- return wrapResult(serialized, BindResultSchema);
6902
- }
6903
- });
6904
- protocol.exchange("init", {
6905
- params: InitParamsSchema,
8134
+ const bind = async (params, ctx) => {
8135
+ const innerParams = unwrapRequest(params.request);
8136
+ const request = deserializeBindRequest(innerParams);
8137
+ request.attach_opaque_data = await stripAttach(request.attach_opaque_data, ctx);
8138
+ const func = registry.get(request.function_name, overloadContext(request, catalogInterface));
8139
+ const response = await func.bind(request);
8140
+ const serialized = serializeBindResponse(response);
8141
+ return wrapResult(serialized, BindResultSchema);
8142
+ };
8143
+ const init = exchangeStream({
6906
8144
  inputSchema: dummyInputSchema,
6907
8145
  outputSchema: emptySchema,
6908
8146
  init: async (params, ctx) => {
@@ -6995,7 +8233,6 @@ function registerFunctionMethods(protocol, config) {
6995
8233
  }
6996
8234
  state.filterHistory = handlerState?.filterHistory ?? null;
6997
8235
  },
6998
- headerSchema: initHeaderSchema,
6999
8236
  headerInit: (params, state, ctx) => {
7000
8237
  if (!state._initResponse) {
7001
8238
  throw new Error("headerInit called on deserialized state: _initResponse not available");
@@ -7003,83 +8240,75 @@ function registerFunctionMethods(protocol, config) {
7003
8240
  return serializeGlobalInitResponse(state._initResponse);
7004
8241
  }
7005
8242
  });
7006
- protocol.unary("table_function_cardinality", {
7007
- params: TableFunctionCardinalityParamsSchema,
7008
- result: RESULT_BINARY_SCHEMA,
7009
- handler: async (params) => {
7010
- const innerParams = unwrapRequest(params.request);
7011
- const request = deserializeCardinalityRequest(innerParams);
7012
- const func = registry.get(request.bind_call.function_name, await strippedContext(request.bind_call));
7013
- let cardResult;
7014
- if (func.cardinality) {
7015
- cardResult = serializeTableCardinality(await func.cardinality(request));
7016
- } else {
7017
- cardResult = { estimate: null, max: null };
7018
- }
7019
- return wrapResult(cardResult, TableFunctionCardinalityResultSchema);
7020
- }
7021
- });
7022
- protocol.unary("table_function_plan", {
7023
- params: TableFunctionPlanParamsSchema,
7024
- result: RESULT_BINARY_SCHEMA,
7025
- handler: async (params, ctx) => {
7026
- const innerParams = unwrapRequest(params.request);
7027
- const request = deserializePlanRequest(innerParams);
7028
- const func = registry.get(request.bind_call.function_name, await strippedContext(request.bind_call));
7029
- const plan = func.plan ? await func.plan(request) : { splits: [{ payload: new Uint8Array(0) }] };
7030
- const fp = fingerprintInputs(toUint8Array(innerParams.bind_call));
7031
- const fingerprint = await bindFingerprint(fp.schemaPath, fp.functionName, fp.args, fp.settings, new Uint8Array(0));
7032
- const anchor = plan.catalogVersion != null ? splitAnchor(plan.catalogVersion) : await liveSplitAnchor(catalogInterface, request.bind_call, ctx?.auth, signingKey) ?? splitAnchor(0);
7033
- const blobs = [];
7034
- for (const split of plan.splits) {
7035
- const token = await buildSplitToken({
7036
- payload: split.payload,
7037
- fingerprint,
7038
- anchor,
7039
- signingKey,
7040
- auth: ctx?.auth
7041
- });
7042
- blobs.push(serializeBatch(batchFromColumns(Object.fromEntries(SCAN_SPLIT_SCHEMA.fields.map((f) => [
7043
- f.name,
7044
- [scanSplitRow(split, token)[f.name] ?? null]
7045
- ])), SCAN_SPLIT_SCHEMA)));
7046
- }
7047
- return wrapResult(planResponseRow(plan, blobs), PLAN_RESPONSE_SCHEMA);
7048
- }
7049
- });
7050
- protocol.unary("table_function_statistics", {
7051
- params: TableFunctionStatisticsParamsSchema,
7052
- result: RESULT_BINARY_NULLABLE_SCHEMA,
7053
- handler: async (params) => {
7054
- const innerParams = unwrapRequest(params.request);
7055
- const request = deserializeCardinalityRequest(innerParams);
7056
- const func = registry.get(request.bind_call.function_name, await strippedContext(request.bind_call));
7057
- if (!func.statistics)
7058
- return { result: null };
7059
- const stats = func.statistics(request);
7060
- if (!stats || stats.length === 0)
7061
- return { result: null };
7062
- return { result: serializeColumnStatistics(stats) };
8243
+ const tableFunctionCardinality = async (params) => {
8244
+ const innerParams = unwrapRequest(params.request);
8245
+ const request = deserializeCardinalityRequest(innerParams);
8246
+ const func = registry.get(request.bind_call.function_name, await strippedContext(request.bind_call));
8247
+ let cardResult;
8248
+ if (func.cardinality) {
8249
+ cardResult = serializeTableCardinality(await func.cardinality(request));
8250
+ } else {
8251
+ cardResult = { estimate: null, max: null };
7063
8252
  }
7064
- });
7065
- protocol.unary("table_function_dynamic_to_string", {
7066
- params: TableFunctionDynamicToStringParamsSchema,
7067
- result: RESULT_BINARY_SCHEMA,
7068
- handler: async (params) => {
7069
- const innerParams = unwrapRequest(params.request);
7070
- const bindCallBytes = toUint8Array(innerParams.bind_call);
7071
- const bindCallBatch = deserializeBatch(bindCallBytes);
7072
- const bindParams = batchToScalarDict(bindCallBatch);
7073
- const bindCall = deserializeBindRequest(bindParams);
7074
- const globalExecutionId = toUint8Array(innerParams.global_execution_id);
7075
- const bindOpaqueData = innerParams.bind_opaque_data ? toUint8Array(innerParams.bind_opaque_data) : null;
7076
- const func = registry.get(bindCall.function_name, await strippedContext(bindCall));
7077
- const map = func.dynamicToString ? await func.dynamicToString({ bindCall, bindOpaqueData, globalExecutionId }) : {};
7078
- const keys = Object.keys(map);
7079
- const values = keys.map((k) => map[k] ?? "");
7080
- return wrapResult({ keys, values }, TableFunctionDynamicToStringResultSchema);
8253
+ return wrapResult(cardResult, TableFunctionCardinalityResultSchema);
8254
+ };
8255
+ const tableFunctionPlan = async (params, ctx) => {
8256
+ const innerParams = unwrapRequest(params.request);
8257
+ const request = deserializePlanRequest(innerParams);
8258
+ const func = registry.get(request.bind_call.function_name, await strippedContext(request.bind_call));
8259
+ const plan = func.plan ? await func.plan(request) : { splits: [{ payload: new Uint8Array(0) }] };
8260
+ const fp = fingerprintInputs(toUint8Array(innerParams.bind_call));
8261
+ const fingerprint = await bindFingerprint(fp.schemaPath, fp.functionName, fp.args, fp.settings, new Uint8Array(0));
8262
+ const anchor = plan.catalogVersion != null ? splitAnchor(plan.catalogVersion) : await liveSplitAnchor(catalogInterface, request.bind_call, ctx?.auth, signingKey) ?? splitAnchor(0);
8263
+ const blobs = [];
8264
+ for (const split of plan.splits) {
8265
+ const token = await buildSplitToken({
8266
+ payload: split.payload,
8267
+ fingerprint,
8268
+ anchor,
8269
+ signingKey,
8270
+ auth: ctx?.auth
8271
+ });
8272
+ blobs.push(serializeBatch(batchFromColumns(Object.fromEntries(SCAN_SPLIT_SCHEMA.fields.map((f) => [
8273
+ f.name,
8274
+ [scanSplitRow(split, token)[f.name] ?? null]
8275
+ ])), SCAN_SPLIT_SCHEMA)));
7081
8276
  }
7082
- });
8277
+ return wrapResult(planResponseRow(plan, blobs), PLAN_RESPONSE_SCHEMA);
8278
+ };
8279
+ const tableFunctionStatistics = async (params) => {
8280
+ const innerParams = unwrapRequest(params.request);
8281
+ const request = deserializeCardinalityRequest(innerParams);
8282
+ const func = registry.get(request.bind_call.function_name, await strippedContext(request.bind_call));
8283
+ if (!func.statistics)
8284
+ return { result: null };
8285
+ const stats = func.statistics(request);
8286
+ if (!stats || stats.length === 0)
8287
+ return { result: null };
8288
+ return { result: serializeColumnStatistics(stats) };
8289
+ };
8290
+ const tableFunctionDynamicToString = async (params) => {
8291
+ const innerParams = unwrapRequest(params.request);
8292
+ const bindCallBytes = toUint8Array(innerParams.bind_call);
8293
+ const bindCallBatch = deserializeBatch(bindCallBytes);
8294
+ const bindParams = batchToScalarDict(bindCallBatch);
8295
+ const bindCall = deserializeBindRequest(bindParams);
8296
+ const globalExecutionId = toUint8Array(innerParams.global_execution_id);
8297
+ const bindOpaqueData = innerParams.bind_opaque_data ? toUint8Array(innerParams.bind_opaque_data) : null;
8298
+ const func = registry.get(bindCall.function_name, await strippedContext(bindCall));
8299
+ const map = func.dynamicToString ? await func.dynamicToString({ bindCall, bindOpaqueData, globalExecutionId }) : {};
8300
+ const keys = Object.keys(map);
8301
+ const values = keys.map((k) => map[k] ?? "");
8302
+ return wrapResult({ keys, values }, TableFunctionDynamicToStringResultSchema);
8303
+ };
8304
+ return {
8305
+ bind,
8306
+ init,
8307
+ tableFunctionCardinality,
8308
+ tableFunctionPlan,
8309
+ tableFunctionStatistics,
8310
+ tableFunctionDynamicToString
8311
+ };
7083
8312
  }
7084
8313
 
7085
8314
  // src/protocol/handlers/aggregate.ts
@@ -7457,7 +8686,7 @@ function defineAggregate(config) {
7457
8686
  }
7458
8687
 
7459
8688
  // src/protocol/handlers/aggregate.ts
7460
- function registerAggregateMethods(protocol, registry) {
8689
+ function aggregateHandlers(registry) {
7461
8690
  function resolveAggregate(name, schemaPath) {
7462
8691
  const func = registry.get(name, {
7463
8692
  arguments: new Arguments,
@@ -7470,199 +8699,180 @@ function registerAggregateMethods(protocol, registry) {
7470
8699
  }
7471
8700
  return func.aggregateConfig;
7472
8701
  }
7473
- protocol.unary("aggregate_bind", {
7474
- params: AggregateBindParamsSchema,
7475
- result: RESULT_BINARY_SCHEMA,
7476
- handler: async (params) => {
7477
- const innerParams = unwrapRequest(params.request);
7478
- const functionName = innerParams.function_name;
7479
- const cfg = resolveAggregate(functionName, innerParams.schema_path ?? null);
7480
- const argBytes = toUint8Array(innerParams.arguments);
7481
- const args = deserializeArguments(argBytes);
7482
- const inputSchema = innerParams.input_schema ? deserializeSchema(toUint8Array(innerParams.input_schema)) : null;
7483
- const secretsBytes = innerParams.secrets ? toUint8Array(innerParams.secrets) : null;
7484
- const secretsBatch = secretsBytes && secretsBytes.length > 0 ? deserializeBatch(secretsBytes) : null;
7485
- const secrets = secretsBatch ? batchToSecretDict(secretsBatch) : {};
7486
- const bindParams = {
7487
- args: extractArgMap(cfg, args),
7488
- arguments: args,
7489
- inputSchema,
7490
- settings: {},
7491
- secrets,
7492
- argumentNames: innerParams.argument_names ? (Array.isArray(innerParams.argument_names) ? innerParams.argument_names : [...innerParams.argument_names]).map((value) => value == null ? null : String(value)) : null
7493
- };
7494
- const executionId = new Uint8Array(16);
7495
- crypto.getRandomValues(executionId);
7496
- setExecutionState(executionId, {
7497
- states: new Map,
7498
- bindArgs: args,
7499
- bindParams
7500
- });
7501
- const outType = cfg.onBind ? await cfg.onBind(bindParams) : cfg.outputType;
7502
- const outSchema = schema2([field2("result", outType, true)]);
7503
- return wrapResult({ output_schema: serializeSchema(outSchema), execution_id: executionId }, AggregateBindResultSchema);
7504
- }
7505
- });
7506
- protocol.unary("aggregate_update", {
7507
- params: AggregateUpdateParamsSchema,
7508
- result: RESULT_BINARY_SCHEMA,
7509
- handler: (params) => {
7510
- const innerParams = unwrapRequest(params.request);
7511
- const functionName = innerParams.function_name;
7512
- const executionId = toUint8Array(innerParams.execution_id);
7513
- const cfg = resolveAggregate(functionName, innerParams.schema_path ?? null);
7514
- const batch = readSingleBatch(toUint8Array(innerParams.input_batch));
7515
- if (!batch || batch.numRows === 0)
7516
- return wrapResult({}, schema2([]));
7517
- const gidIdx = batch.schema.fields.findIndex((f) => f.name === GROUP_COLUMN_NAME);
7518
- if (gidIdx < 0) {
7519
- throw new Error(`aggregate_update: input batch missing ${GROUP_COLUMN_NAME} column`);
7520
- }
7521
- const gidCol = batch.getChildAt(gidIdx);
7522
- const groupIds = [];
7523
- const uniqueGids = new Set;
7524
- for (let i = 0;i < batch.numRows; i++) {
7525
- const v = gidCol.get(i);
7526
- const g = typeof v === "bigint" ? v : BigInt(v);
7527
- groupIds.push(g);
7528
- uniqueGids.add(g);
7529
- }
7530
- const exec = getExecutionState(executionId, uniqueGids);
7531
- if (!exec) {
7532
- throw new Error(`aggregate_update: unknown execution_id for '${functionName}' (bind missing or state dropped)`);
7533
- }
7534
- const columns = [];
7535
- for (let i = 0;i < batch.schema.fields.length; i++) {
7536
- if (i === gidIdx)
7537
- continue;
7538
- columns.push(batch.getChildAt(i));
7539
- }
7540
- const ensureState = (gid) => {
7541
- let s = exec.states.get(gid);
7542
- if (s === undefined) {
7543
- s = cfg.initialState(exec.bindParams);
7544
- exec.states.set(gid, s);
7545
- }
7546
- return s;
7547
- };
7548
- cfg.update({
7549
- states: exec.states,
7550
- groupIds,
7551
- columns,
7552
- args: exec.bindParams.args,
7553
- ensureState
7554
- });
7555
- persistGroupStates(executionId, uniqueGids);
8702
+ const aggregateBind = async (params) => {
8703
+ const innerParams = unwrapRequest(params.request);
8704
+ const functionName = innerParams.function_name;
8705
+ const cfg = resolveAggregate(functionName, innerParams.schema_path ?? null);
8706
+ const argBytes = toUint8Array(innerParams.arguments);
8707
+ const args = deserializeArguments(argBytes);
8708
+ const inputSchema = innerParams.input_schema ? deserializeSchema(toUint8Array(innerParams.input_schema)) : null;
8709
+ const secretsBytes = innerParams.secrets ? toUint8Array(innerParams.secrets) : null;
8710
+ const secretsBatch = secretsBytes && secretsBytes.length > 0 ? deserializeBatch(secretsBytes) : null;
8711
+ const secrets = secretsBatch ? batchToSecretDict(secretsBatch) : {};
8712
+ const bindParams = {
8713
+ args: extractArgMap(cfg, args),
8714
+ arguments: args,
8715
+ inputSchema,
8716
+ settings: {},
8717
+ secrets,
8718
+ argumentNames: innerParams.argument_names ? (Array.isArray(innerParams.argument_names) ? innerParams.argument_names : [...innerParams.argument_names]).map((value) => value == null ? null : String(value)) : null
8719
+ };
8720
+ const executionId = new Uint8Array(16);
8721
+ crypto.getRandomValues(executionId);
8722
+ setExecutionState(executionId, {
8723
+ states: new Map,
8724
+ bindArgs: args,
8725
+ bindParams
8726
+ });
8727
+ const outType = cfg.onBind ? await cfg.onBind(bindParams) : cfg.outputType;
8728
+ const outSchema = schema2([field2("result", outType, true)]);
8729
+ return wrapResult({ output_schema: serializeSchema(outSchema), execution_id: executionId }, AggregateBindResultSchema);
8730
+ };
8731
+ const aggregateUpdate = (params) => {
8732
+ const innerParams = unwrapRequest(params.request);
8733
+ const functionName = innerParams.function_name;
8734
+ const executionId = toUint8Array(innerParams.execution_id);
8735
+ const cfg = resolveAggregate(functionName, innerParams.schema_path ?? null);
8736
+ const batch = readSingleBatch(toUint8Array(innerParams.input_batch));
8737
+ if (!batch || batch.numRows === 0)
7556
8738
  return wrapResult({}, schema2([]));
8739
+ const gidIdx = batch.schema.fields.findIndex((f) => f.name === GROUP_COLUMN_NAME);
8740
+ if (gidIdx < 0) {
8741
+ throw new Error(`aggregate_update: input batch missing ${GROUP_COLUMN_NAME} column`);
8742
+ }
8743
+ const gidCol = batch.getChildAt(gidIdx);
8744
+ const groupIds = [];
8745
+ const uniqueGids = new Set;
8746
+ for (let i = 0;i < batch.numRows; i++) {
8747
+ const v = gidCol.get(i);
8748
+ const g = typeof v === "bigint" ? v : BigInt(v);
8749
+ groupIds.push(g);
8750
+ uniqueGids.add(g);
8751
+ }
8752
+ const exec = getExecutionState(executionId, uniqueGids);
8753
+ if (!exec) {
8754
+ throw new Error(`aggregate_update: unknown execution_id for '${functionName}' (bind missing or state dropped)`);
8755
+ }
8756
+ const columns = [];
8757
+ for (let i = 0;i < batch.schema.fields.length; i++) {
8758
+ if (i === gidIdx)
8759
+ continue;
8760
+ columns.push(batch.getChildAt(i));
7557
8761
  }
7558
- });
7559
- protocol.unary("aggregate_combine", {
7560
- params: AggregateCombineParamsSchema,
7561
- result: RESULT_BINARY_SCHEMA,
7562
- handler: (params) => {
7563
- const innerParams = unwrapRequest(params.request);
7564
- const functionName = innerParams.function_name;
7565
- const executionId = toUint8Array(innerParams.execution_id);
7566
- const cfg = resolveAggregate(functionName, innerParams.schema_path ?? null);
7567
- const batch = readSingleBatch(toUint8Array(innerParams.merge_batch));
7568
- if (!batch || batch.numRows === 0)
7569
- return wrapResult({}, schema2([]));
7570
- const srcCol = batch.getChild("source_group_id");
7571
- const tgtCol = batch.getChild("target_group_id");
7572
- const referencedGids = new Set;
7573
- const srcIds = [];
7574
- const tgtIds = [];
7575
- for (let i = 0;i < batch.numRows; i++) {
7576
- const src = BigInt(srcCol.get(i));
7577
- const tgt = BigInt(tgtCol.get(i));
7578
- srcIds.push(src);
7579
- tgtIds.push(tgt);
7580
- referencedGids.add(src);
7581
- referencedGids.add(tgt);
7582
- }
7583
- const exec = getExecutionState(executionId, referencedGids);
7584
- if (!exec) {
7585
- throw new Error(`aggregate_combine: unknown execution_id for '${functionName}' ` + `(context missing on disk — bind may have failed or been cleaned up)`);
7586
- }
7587
- const touchedTargets = new Set;
7588
- for (let i = 0;i < batch.numRows; i++) {
7589
- const src = srcIds[i];
7590
- const tgt = tgtIds[i];
7591
- const srcHas = exec.states.has(src);
7592
- const tgtHas = exec.states.has(tgt);
7593
- if (!srcHas && !tgtHas)
7594
- continue;
7595
- const srcState = srcHas ? exec.states.get(src) : cfg.initialState(exec.bindParams);
7596
- const tgtState = tgtHas ? exec.states.get(tgt) : cfg.initialState(exec.bindParams);
7597
- exec.states.set(tgt, cfg.combine(srcState, tgtState, exec.bindParams));
7598
- touchedTargets.add(tgt);
8762
+ const ensureState = (gid) => {
8763
+ let s = exec.states.get(gid);
8764
+ if (s === undefined) {
8765
+ s = cfg.initialState(exec.bindParams);
8766
+ exec.states.set(gid, s);
7599
8767
  }
7600
- persistGroupStates(executionId, touchedTargets);
8768
+ return s;
8769
+ };
8770
+ cfg.update({
8771
+ states: exec.states,
8772
+ groupIds,
8773
+ columns,
8774
+ args: exec.bindParams.args,
8775
+ ensureState
8776
+ });
8777
+ persistGroupStates(executionId, uniqueGids);
8778
+ return wrapResult({}, schema2([]));
8779
+ };
8780
+ const aggregateCombine = (params) => {
8781
+ const innerParams = unwrapRequest(params.request);
8782
+ const functionName = innerParams.function_name;
8783
+ const executionId = toUint8Array(innerParams.execution_id);
8784
+ const cfg = resolveAggregate(functionName, innerParams.schema_path ?? null);
8785
+ const batch = readSingleBatch(toUint8Array(innerParams.merge_batch));
8786
+ if (!batch || batch.numRows === 0)
7601
8787
  return wrapResult({}, schema2([]));
8788
+ const srcCol = batch.getChild("source_group_id");
8789
+ const tgtCol = batch.getChild("target_group_id");
8790
+ const referencedGids = new Set;
8791
+ const srcIds = [];
8792
+ const tgtIds = [];
8793
+ for (let i = 0;i < batch.numRows; i++) {
8794
+ const src = BigInt(srcCol.get(i));
8795
+ const tgt = BigInt(tgtCol.get(i));
8796
+ srcIds.push(src);
8797
+ tgtIds.push(tgt);
8798
+ referencedGids.add(src);
8799
+ referencedGids.add(tgt);
8800
+ }
8801
+ const exec = getExecutionState(executionId, referencedGids);
8802
+ if (!exec) {
8803
+ throw new Error(`aggregate_combine: unknown execution_id for '${functionName}' ` + `(context missing on disk — bind may have failed or been cleaned up)`);
8804
+ }
8805
+ const touchedTargets = new Set;
8806
+ for (let i = 0;i < batch.numRows; i++) {
8807
+ const src = srcIds[i];
8808
+ const tgt = tgtIds[i];
8809
+ const srcHas = exec.states.has(src);
8810
+ const tgtHas = exec.states.has(tgt);
8811
+ if (!srcHas && !tgtHas)
8812
+ continue;
8813
+ const srcState = srcHas ? exec.states.get(src) : cfg.initialState(exec.bindParams);
8814
+ const tgtState = tgtHas ? exec.states.get(tgt) : cfg.initialState(exec.bindParams);
8815
+ exec.states.set(tgt, cfg.combine(srcState, tgtState, exec.bindParams));
8816
+ touchedTargets.add(tgt);
7602
8817
  }
7603
- });
7604
- protocol.unary("aggregate_finalize", {
7605
- params: AggregateFinalizeParamsSchema,
7606
- result: RESULT_BINARY_SCHEMA,
7607
- handler: (params) => {
7608
- const innerParams = unwrapRequest(params.request);
7609
- const functionName = innerParams.function_name;
7610
- const executionId = toUint8Array(innerParams.execution_id);
7611
- const cfg = resolveAggregate(functionName, innerParams.schema_path ?? null);
7612
- const outputSchema = deserializeSchema(toUint8Array(innerParams.output_schema));
7613
- const gidBatch = readSingleBatch(toUint8Array(innerParams.group_ids_batch));
7614
- const groupIds = [];
7615
- const uniqueGids = new Set;
7616
- if (gidBatch) {
7617
- const col = gidBatch.getChild("group_id");
7618
- for (let i = 0;i < gidBatch.numRows; i++) {
7619
- const v = col.get(i);
7620
- const g = typeof v === "bigint" ? v : BigInt(v);
7621
- groupIds.push(g);
7622
- uniqueGids.add(g);
7623
- }
7624
- }
7625
- const exec = getExecutionState(executionId, uniqueGids);
7626
- if (!exec) {
7627
- throw new Error(`aggregate_finalize: unknown execution_id for '${functionName}'`);
7628
- }
7629
- const states = new Map;
7630
- for (const gid of groupIds) {
7631
- states.set(gid, exec.states.has(gid) ? exec.states.get(gid) : null);
7632
- }
7633
- const resultBatch = cfg.finalize({
7634
- groupIds,
7635
- states,
7636
- outputSchema,
7637
- args: exec.bindParams.args
7638
- });
7639
- return wrapResult({ result_batch: serializeBatchWithSchema(resultBatch) }, AggregateFinalizeResultSchema);
7640
- }
7641
- });
7642
- protocol.unary("aggregate_destructor", {
7643
- params: AggregateDestructorParamsSchema,
7644
- result: RESULT_BINARY_SCHEMA,
7645
- handler: (params) => {
7646
- const innerParams = unwrapRequest(params.request);
7647
- const executionId = toUint8Array(innerParams.execution_id);
7648
- const exec = getExecutionState(executionId);
7649
- if (!exec)
7650
- return wrapResult({}, schema2([]));
7651
- const gidBatch = readSingleBatch(toUint8Array(innerParams.group_ids_batch));
7652
- if (!gidBatch || gidBatch.numRows === 0)
7653
- return wrapResult({}, schema2([]));
8818
+ persistGroupStates(executionId, touchedTargets);
8819
+ return wrapResult({}, schema2([]));
8820
+ };
8821
+ const aggregateFinalize = (params) => {
8822
+ const innerParams = unwrapRequest(params.request);
8823
+ const functionName = innerParams.function_name;
8824
+ const executionId = toUint8Array(innerParams.execution_id);
8825
+ const cfg = resolveAggregate(functionName, innerParams.schema_path ?? null);
8826
+ const outputSchema = deserializeSchema(toUint8Array(innerParams.output_schema));
8827
+ const gidBatch = readSingleBatch(toUint8Array(innerParams.group_ids_batch));
8828
+ const groupIds = [];
8829
+ const uniqueGids = new Set;
8830
+ if (gidBatch) {
7654
8831
  const col = gidBatch.getChild("group_id");
7655
- const toDrop = new Set;
7656
8832
  for (let i = 0;i < gidBatch.numRows; i++) {
7657
8833
  const v = col.get(i);
7658
8834
  const g = typeof v === "bigint" ? v : BigInt(v);
7659
- exec.states.delete(g);
7660
- toDrop.add(g);
8835
+ groupIds.push(g);
8836
+ uniqueGids.add(g);
7661
8837
  }
7662
- persistGroupStates(executionId, toDrop);
7663
- return wrapResult({}, schema2([]));
7664
8838
  }
7665
- });
8839
+ const exec = getExecutionState(executionId, uniqueGids);
8840
+ if (!exec) {
8841
+ throw new Error(`aggregate_finalize: unknown execution_id for '${functionName}'`);
8842
+ }
8843
+ const states = new Map;
8844
+ for (const gid of groupIds) {
8845
+ states.set(gid, exec.states.has(gid) ? exec.states.get(gid) : null);
8846
+ }
8847
+ const resultBatch = cfg.finalize({
8848
+ groupIds,
8849
+ states,
8850
+ outputSchema,
8851
+ args: exec.bindParams.args
8852
+ });
8853
+ return wrapResult({ result_batch: serializeBatchWithSchema(resultBatch) }, AggregateFinalizeResultSchema);
8854
+ };
8855
+ const aggregateDestructor = (params) => {
8856
+ const innerParams = unwrapRequest(params.request);
8857
+ const executionId = toUint8Array(innerParams.execution_id);
8858
+ const exec = getExecutionState(executionId);
8859
+ if (!exec)
8860
+ return wrapResult({}, schema2([]));
8861
+ const gidBatch = readSingleBatch(toUint8Array(innerParams.group_ids_batch));
8862
+ if (!gidBatch || gidBatch.numRows === 0)
8863
+ return wrapResult({}, schema2([]));
8864
+ const col = gidBatch.getChild("group_id");
8865
+ const toDrop = new Set;
8866
+ for (let i = 0;i < gidBatch.numRows; i++) {
8867
+ const v = col.get(i);
8868
+ const g = typeof v === "bigint" ? v : BigInt(v);
8869
+ exec.states.delete(g);
8870
+ toDrop.add(g);
8871
+ }
8872
+ persistGroupStates(executionId, toDrop);
8873
+ return wrapResult({}, schema2([]));
8874
+ };
8875
+ return { aggregateBind, aggregateUpdate, aggregateCombine, aggregateFinalize, aggregateDestructor };
7666
8876
  }
7667
8877
  function extractArgMap(cfg, args) {
7668
8878
  const out = {};
@@ -7792,7 +9002,7 @@ function splitLenPrefixed(buf, count) {
7792
9002
  }
7793
9003
 
7794
9004
  // src/protocol/handlers/table-buffering.ts
7795
- function registerTableBufferingMethods(protocol, registry, signingKey) {
9005
+ function tableBufferingHandlers(registry, signingKey) {
7796
9006
  function resolveBuffering(name, schemaPath) {
7797
9007
  const func = registry.get(name, {
7798
9008
  arguments: new Arguments,
@@ -7837,55 +9047,44 @@ function registerTableBufferingMethods(protocol, registry, signingKey) {
7837
9047
  };
7838
9048
  return { func, params };
7839
9049
  }
7840
- protocol.unary("table_buffering_process", {
7841
- params: TableBufferingProcessParamsSchema,
7842
- result: RESULT_BINARY_SCHEMA,
7843
- handler: async (rpcParams, ctx) => {
7844
- const inner = unwrapRequest(rpcParams.request);
7845
- const clientLog = makeClientLog(ctx);
7846
- const { func, params } = await loadParams(inner, clientLog, ctx);
7847
- if (inner.batch_index != null) {
7848
- params.batchIndex = Number(inner.batch_index);
7849
- }
7850
- const batch = deserializeBatch(toUint8Array(inner.input_batch));
7851
- const stateId = await func.bufferingConfig.process(batch, params);
7852
- if (!(stateId instanceof Uint8Array)) {
7853
- throw new Error(`${func.meta.name}.process() must return Uint8Array (the opaque state_id)`);
7854
- }
7855
- return wrapResult({ state_id: stateId }, TableBufferingProcessResultSchema);
9050
+ const tableBufferingProcess = async (rpcParams, ctx) => {
9051
+ const inner = unwrapRequest(rpcParams.request);
9052
+ const clientLog = makeClientLog(ctx);
9053
+ const { func, params } = await loadParams(inner, clientLog, ctx);
9054
+ if (inner.batch_index != null) {
9055
+ params.batchIndex = Number(inner.batch_index);
7856
9056
  }
7857
- });
7858
- protocol.unary("table_buffering_combine", {
7859
- params: TableBufferingCombineParamsSchema,
7860
- result: RESULT_BINARY_SCHEMA,
7861
- handler: async (rpcParams, ctx) => {
7862
- const inner = unwrapRequest(rpcParams.request);
7863
- const clientLog = makeClientLog(ctx);
7864
- const { func, params } = await loadParams(inner, clientLog, ctx);
7865
- const stateIds = decodeBytesList(inner.state_ids);
7866
- const finalizeStateIds = await func.bufferingConfig.combine(stateIds, params);
7867
- const out = finalizeStateIds.map((fid, i) => {
7868
- if (!(fid instanceof Uint8Array)) {
7869
- throw new Error(`${func.meta.name}.combine() returned non-Uint8Array finalize_state_id at index ${i}`);
7870
- }
7871
- return fid;
7872
- });
7873
- return wrapResult({ finalize_state_ids: out }, TableBufferingCombineResultSchema);
9057
+ const batch = deserializeBatch(toUint8Array(inner.input_batch));
9058
+ const stateId = await func.bufferingConfig.process(batch, params);
9059
+ if (!(stateId instanceof Uint8Array)) {
9060
+ throw new Error(`${func.meta.name}.process() must return Uint8Array (the opaque state_id)`);
7874
9061
  }
7875
- });
7876
- protocol.unary("table_buffering_destructor", {
7877
- params: TableBufferingDestructorParamsSchema,
7878
- result: RESULT_BINARY_SCHEMA,
7879
- handler: async (rpcParams) => {
7880
- try {
7881
- const inner = unwrapRequest(rpcParams.request);
7882
- const executionId = toUint8Array(inner.execution_id);
7883
- const bound = new BoundStorage(storage, executionId);
7884
- await bound.executionClear();
7885
- } catch {}
7886
- return wrapResult({}, TableBufferingDestructorResultSchema);
7887
- }
7888
- });
9062
+ return wrapResult({ state_id: stateId }, TableBufferingProcessResultSchema);
9063
+ };
9064
+ const tableBufferingCombine = async (rpcParams, ctx) => {
9065
+ const inner = unwrapRequest(rpcParams.request);
9066
+ const clientLog = makeClientLog(ctx);
9067
+ const { func, params } = await loadParams(inner, clientLog, ctx);
9068
+ const stateIds = decodeBytesList(inner.state_ids);
9069
+ const finalizeStateIds = await func.bufferingConfig.combine(stateIds, params);
9070
+ const out = finalizeStateIds.map((fid, i) => {
9071
+ if (!(fid instanceof Uint8Array)) {
9072
+ throw new Error(`${func.meta.name}.combine() returned non-Uint8Array finalize_state_id at index ${i}`);
9073
+ }
9074
+ return fid;
9075
+ });
9076
+ return wrapResult({ finalize_state_ids: out }, TableBufferingCombineResultSchema);
9077
+ };
9078
+ const tableBufferingDestructor = async (rpcParams) => {
9079
+ try {
9080
+ const inner = unwrapRequest(rpcParams.request);
9081
+ const executionId = toUint8Array(inner.execution_id);
9082
+ const bound = new BoundStorage(storage, executionId);
9083
+ await bound.executionClear();
9084
+ } catch {}
9085
+ return wrapResult({}, TableBufferingDestructorResultSchema);
9086
+ };
9087
+ return { tableBufferingProcess, tableBufferingCombine, tableBufferingDestructor };
7889
9088
  }
7890
9089
  function makeClientLog(ctx) {
7891
9090
  if (ctx && typeof ctx.clientLog === "function") {
@@ -8427,7 +9626,7 @@ class CatalogInterface {
8427
9626
  // src/attach-ticket.ts
8428
9627
  init_arrow();
8429
9628
  import {
8430
- Protocol,
9629
+ Protocol as Protocol2,
8431
9630
  badRequest,
8432
9631
  errorInfo,
8433
9632
  preconditionFailure
@@ -8929,7 +10128,7 @@ async function sealAttach2(config, request, auth) {
8929
10128
  return { ticket: token, expires_at: expiresAt === 0 ? Number.POSITIVE_INFINITY : expiresAt };
8930
10129
  }
8931
10130
  function buildAttachTicketsProtocol(config) {
8932
- const p = new Protocol(ATTACH_TICKETS_PROTOCOL_NAME, { protocolVersion: ATTACH_TICKETS_PROTOCOL_VERSION });
10131
+ const p = new Protocol2(ATTACH_TICKETS_PROTOCOL_NAME, { protocolVersion: ATTACH_TICKETS_PROTOCOL_VERSION });
8933
10132
  p.unary("seal_attach", {
8934
10133
  params: REQUEST_PARAMS_SCHEMA,
8935
10134
  result: RESULT_BINARY_SCHEMA,
@@ -8945,503 +10144,369 @@ function buildAttachTicketsProtocol(config) {
8945
10144
  }
8946
10145
 
8947
10146
  // src/protocol/handlers/catalog/admin.ts
8948
- function registerCatalogAdminMethods(protocol, getCatalog, signingKey) {
8949
- catalogUnary(protocol, signingKey, "catalog_catalogs", {
8950
- params: CatalogCatalogsParamsSchema,
8951
- result: RESULT_BINARY_SCHEMA,
8952
- handler: async () => {
8953
- const cat = getCatalog();
8954
- const infos = cat.catalogsInfo ? await cat.catalogsInfo() : cat.catalogs().map((name) => ({
8955
- name,
8956
- implementation_version: null,
8957
- data_version_spec: null,
8958
- attach_option_specs: [],
8959
- releases: []
8960
- }));
8961
- const items = infos.map((info) => encodeCatalogInfo(info));
8962
- return wrapResult({ items }, CatalogCatalogsResultSchema);
8963
- }
8964
- });
8965
- protocol.unary("catalog_attach", {
8966
- params: CatalogAttachParamsSchema,
8967
- result: RESULT_BINARY_SCHEMA,
8968
- handler: async (params, ctx) => {
8969
- const innerParams = unwrapRequest(params.request);
8970
- const cat = getCatalog();
8971
- let optionsDict = decodeOptionsBatch(innerParams.options);
8972
- const restored = await redeemAttachTicket(optionsDict, signingKey, ctx?.auth ?? currentRequestAuth());
8973
- if (restored !== null) {
8974
- innerParams.name = restored.name;
8975
- innerParams.options = restored.optionsIpc;
8976
- innerParams.data_version_spec = restored.dataVersionSpec;
8977
- innerParams.implementation_version = restored.implementationVersion;
8978
- optionsDict = restored.options;
8979
- }
8980
- const result = await cat.attach(innerParams.name, optionsDict, innerParams.data_version_spec ?? null, innerParams.implementation_version ?? null);
8981
- const sealedAttach = await sealAttach(toUint8Array(result.attach_opaque_data), ctx?.auth, signingKey);
8982
- return wrapResult(buildCatalogAttachResult({
8983
- ...result,
8984
- attach_opaque_data: sealedAttach,
8985
- supports_column_statistics: result.supports_column_statistics ?? true
8986
- }), CatalogAttachResultSchema);
8987
- }
8988
- });
8989
- catalogUnary(protocol, signingKey, "catalog_detach", {
8990
- params: CatalogDetachParamsSchema,
8991
- result: emptyResultSchema,
8992
- handler: async (params) => {
8993
- const cat = getCatalog();
8994
- await cat.detach(toUint8Array(params.attach_opaque_data));
8995
- return {};
8996
- }
10147
+ function catalogAdminHandlers(getCatalog, signingKey) {
10148
+ const catalogCatalogs = catalogHandler(signingKey, async () => {
10149
+ const cat = getCatalog();
10150
+ const infos = cat.catalogsInfo ? await cat.catalogsInfo() : cat.catalogs().map((name) => ({
10151
+ name,
10152
+ implementation_version: null,
10153
+ data_version_spec: null,
10154
+ attach_option_specs: [],
10155
+ releases: []
10156
+ }));
10157
+ const items = infos.map((info) => encodeCatalogInfo(info));
10158
+ return wrapResult({ items }, CatalogCatalogsResultSchema);
8997
10159
  });
8998
- catalogUnary(protocol, signingKey, "catalog_create", {
8999
- params: CatalogCreateParamsSchema,
9000
- result: emptyResultSchema,
9001
- handler: async (params) => {
9002
- const cat = getCatalog();
9003
- await cat.create(params.name, params.on_conflict, params.options);
9004
- return {};
9005
- }
10160
+ const catalogAttach = async (params, ctx) => {
10161
+ const innerParams = unwrapRequest(params.request);
10162
+ const cat = getCatalog();
10163
+ let optionsDict = decodeOptionsBatch(innerParams.options);
10164
+ const restored = await redeemAttachTicket(optionsDict, signingKey, ctx?.auth ?? currentRequestAuth());
10165
+ if (restored !== null) {
10166
+ innerParams.name = restored.name;
10167
+ innerParams.options = restored.optionsIpc;
10168
+ innerParams.data_version_spec = restored.dataVersionSpec;
10169
+ innerParams.implementation_version = restored.implementationVersion;
10170
+ optionsDict = restored.options;
10171
+ }
10172
+ const result = await cat.attach(innerParams.name, optionsDict, innerParams.data_version_spec ?? null, innerParams.implementation_version ?? null);
10173
+ const sealedAttach = await sealAttach(toUint8Array(result.attach_opaque_data), ctx?.auth, signingKey);
10174
+ return wrapResult(buildCatalogAttachResult({
10175
+ ...result,
10176
+ attach_opaque_data: sealedAttach,
10177
+ supports_column_statistics: result.supports_column_statistics ?? true
10178
+ }), CatalogAttachResultSchema);
10179
+ };
10180
+ const catalogDetach = catalogHandler(signingKey, async (params) => {
10181
+ const cat = getCatalog();
10182
+ await cat.detach(toUint8Array(params.attach_opaque_data));
10183
+ return {};
9006
10184
  });
9007
- catalogUnary(protocol, signingKey, "catalog_drop", {
9008
- params: CatalogDropParamsSchema,
9009
- result: emptyResultSchema,
9010
- handler: async (params) => {
9011
- const cat = getCatalog();
9012
- await cat.drop(params.name);
9013
- return {};
9014
- }
10185
+ const catalogCreate = catalogHandler(signingKey, async (params) => {
10186
+ const cat = getCatalog();
10187
+ await cat.create(params.name, params.on_conflict, params.options);
10188
+ return {};
9015
10189
  });
9016
- catalogUnary(protocol, signingKey, "catalog_version", {
9017
- params: CatalogVersionParamsSchema,
9018
- result: RESULT_BINARY_SCHEMA,
9019
- handler: async (params) => {
9020
- const cat = getCatalog();
9021
- const version = await cat.version(toUint8Array(params.attach_opaque_data), params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
9022
- return wrapResult({ version }, CatalogVersionResultSchema);
9023
- }
10190
+ const catalogDrop = catalogHandler(signingKey, async (params) => {
10191
+ const cat = getCatalog();
10192
+ await cat.drop(params.name);
10193
+ return {};
9024
10194
  });
9025
- protocol.unary("catalog_transaction_begin", {
9026
- params: CatalogTransactionBeginParamsSchema,
9027
- result: RESULT_BINARY_SCHEMA,
9028
- handler: async (params, ctx) => {
9029
- const auth = ctx?.auth;
9030
- const sealedAttach = params.attach_opaque_data != null ? toUint8Array(params.attach_opaque_data) : new Uint8Array(0);
9031
- const attachPlain = await openAttach(sealedAttach, auth, signingKey);
9032
- const cat = getCatalog();
9033
- const txPlain = await cat.transactionBegin(attachPlain);
9034
- const transaction_opaque_data = txPlain != null ? await sealTransaction(toUint8Array(txPlain), sealedAttach, auth, signingKey) : null;
9035
- return wrapResult({ transaction_opaque_data }, CatalogTransactionBeginResultSchema);
9036
- }
10195
+ const catalogVersion = catalogHandler(signingKey, async (params) => {
10196
+ const cat = getCatalog();
10197
+ const version = await cat.version(toUint8Array(params.attach_opaque_data), params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
10198
+ return wrapResult({ version }, CatalogVersionResultSchema);
9037
10199
  });
9038
- catalogUnary(protocol, signingKey, "catalog_transaction_commit", {
9039
- params: CatalogTransactionCommitParamsSchema,
9040
- result: emptyResultSchema,
9041
- handler: async (params) => {
9042
- const cat = getCatalog();
9043
- await cat.transactionCommit(toUint8Array(params.attach_opaque_data), toUint8Array(params.transaction_opaque_data));
9044
- return {};
9045
- }
10200
+ const catalogTransactionBegin = async (params, ctx) => {
10201
+ const auth = ctx?.auth;
10202
+ const sealedAttach = params.attach_opaque_data != null ? toUint8Array(params.attach_opaque_data) : new Uint8Array(0);
10203
+ const attachPlain = await openAttach(sealedAttach, auth, signingKey);
10204
+ const cat = getCatalog();
10205
+ const txPlain = await cat.transactionBegin(attachPlain);
10206
+ const transaction_opaque_data = txPlain != null ? await sealTransaction(toUint8Array(txPlain), sealedAttach, auth, signingKey) : null;
10207
+ return wrapResult({ transaction_opaque_data }, CatalogTransactionBeginResultSchema);
10208
+ };
10209
+ const catalogTransactionCommit = catalogHandler(signingKey, async (params) => {
10210
+ const cat = getCatalog();
10211
+ await cat.transactionCommit(toUint8Array(params.attach_opaque_data), toUint8Array(params.transaction_opaque_data));
10212
+ return {};
9046
10213
  });
9047
- catalogUnary(protocol, signingKey, "catalog_transaction_rollback", {
9048
- params: CatalogTransactionRollbackParamsSchema,
9049
- result: emptyResultSchema,
9050
- handler: async (params) => {
9051
- const cat = getCatalog();
9052
- await cat.transactionRollback(toUint8Array(params.attach_opaque_data), toUint8Array(params.transaction_opaque_data));
9053
- return {};
9054
- }
10214
+ const catalogTransactionRollback = catalogHandler(signingKey, async (params) => {
10215
+ const cat = getCatalog();
10216
+ await cat.transactionRollback(toUint8Array(params.attach_opaque_data), toUint8Array(params.transaction_opaque_data));
10217
+ return {};
9055
10218
  });
9056
- catalogUnary(protocol, signingKey, "catalog_schemas", {
9057
- params: CatalogSchemasParamsSchema,
9058
- result: RESULT_BINARY_SCHEMA,
9059
- handler: async (params) => {
9060
- const cat = getCatalog();
9061
- const schemas = await cat.schemas(toUint8Array(params.attach_opaque_data), params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
9062
- return wrapResult({
9063
- items: schemas.map((s) => encodeSchemaInfo(s))
9064
- }, CatalogSchemasResultSchema);
9065
- }
10219
+ const catalogSchemas = catalogHandler(signingKey, async (params) => {
10220
+ const cat = getCatalog();
10221
+ const schemas = await cat.schemas(toUint8Array(params.attach_opaque_data), params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
10222
+ return wrapResult({
10223
+ items: schemas.map((s) => encodeSchemaInfo(s))
10224
+ }, CatalogSchemasResultSchema);
9066
10225
  });
9067
- catalogUnary(protocol, signingKey, "catalog_contents", {
9068
- params: CatalogContentsParamsSchema,
9069
- result: RESULT_BINARY_SCHEMA,
9070
- handler: async (params) => {
9071
- const ifNoneMatch = params.if_none_match == null ? null : String(params.if_none_match);
9072
- return serveCatalogContents(getCatalog(), toUint8Array(params.attach_opaque_data), ifNoneMatch);
9073
- }
10226
+ const catalogContents = catalogHandler(signingKey, async (params) => {
10227
+ const ifNoneMatch = params.if_none_match == null ? null : String(params.if_none_match);
10228
+ return serveCatalogContents(getCatalog(), toUint8Array(params.attach_opaque_data), ifNoneMatch);
9074
10229
  });
9075
- catalogUnary(protocol, signingKey, "catalog_copy_from_formats", {
9076
- params: CatalogCopyFromFormatsParamsSchema,
9077
- result: RESULT_BINARY_SCHEMA,
9078
- handler: async (params) => {
9079
- const cat = getCatalog();
9080
- const formats = await cat.copyFromFormats(toUint8Array(params.attach_opaque_data), params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
9081
- return wrapResult({
9082
- items: formats.map((f) => encodeCopyFromFormatInfo(f))
9083
- }, CatalogCopyFromFormatsResultSchema);
9084
- }
10230
+ const catalogCopyFromFormats = catalogHandler(signingKey, async (params) => {
10231
+ const cat = getCatalog();
10232
+ const formats = await cat.copyFromFormats(toUint8Array(params.attach_opaque_data), params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
10233
+ return wrapResult({
10234
+ items: formats.map((f) => encodeCopyFromFormatInfo(f))
10235
+ }, CatalogCopyFromFormatsResultSchema);
9085
10236
  });
9086
- catalogUnary(protocol, signingKey, "catalog_schema_get", {
9087
- params: CatalogSchemaGetParamsSchema,
9088
- result: RESULT_BINARY_SCHEMA,
9089
- handler: async (params) => {
9090
- const cat = getCatalog();
9091
- const info = await cat.schemaGet(toUint8Array(params.attach_opaque_data), params.path, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
9092
- return wrapResult({
9093
- items: info ? [encodeSchemaInfo(info)] : []
9094
- }, CatalogSchemaGetResultSchema);
9095
- }
10237
+ const catalogSchemaGet = catalogHandler(signingKey, async (params) => {
10238
+ const cat = getCatalog();
10239
+ const info = await cat.schemaGet(toUint8Array(params.attach_opaque_data), params.path, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
10240
+ return wrapResult({
10241
+ items: info ? [encodeSchemaInfo(info)] : []
10242
+ }, CatalogSchemaGetResultSchema);
9096
10243
  });
9097
- catalogUnary(protocol, signingKey, "catalog_schema_create", {
9098
- params: CatalogSchemaCreateParamsSchema,
9099
- result: emptyResultSchema,
9100
- handler: async (params) => {
9101
- const cat = getCatalog();
9102
- await cat.schemaCreate(toUint8Array(params.attach_opaque_data), params.path, params.comment, null, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
9103
- return {};
9104
- }
10244
+ const catalogSchemaCreate = catalogHandler(signingKey, async (params) => {
10245
+ const cat = getCatalog();
10246
+ await cat.schemaCreate(toUint8Array(params.attach_opaque_data), params.path, params.comment, null, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
10247
+ return {};
9105
10248
  });
9106
- catalogUnary(protocol, signingKey, "catalog_schema_drop", {
9107
- params: CatalogSchemaDropParamsSchema,
9108
- result: emptyResultSchema,
9109
- handler: async (params) => {
9110
- const cat = getCatalog();
9111
- 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);
9112
- return {};
9113
- }
10249
+ const catalogSchemaDrop = catalogHandler(signingKey, async (params) => {
10250
+ const cat = getCatalog();
10251
+ 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);
10252
+ return {};
9114
10253
  });
9115
- catalogUnary(protocol, signingKey, "catalog_schema_contents_tables", {
9116
- params: CatalogSchemaContentsTablesParamsSchema,
9117
- result: RESULT_BINARY_SCHEMA,
9118
- handler: async (params) => {
9119
- const cat = getCatalog();
9120
- const tables = await cat.schemaContentsTables(toUint8Array(params.attach_opaque_data), params.path, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
9121
- return wrapResult({
9122
- items: tables.map((t) => encodeTableInfo(t))
9123
- }, CatalogSchemaContentsTablesResultSchema);
9124
- }
10254
+ const catalogSchemaContentsTables = catalogHandler(signingKey, async (params) => {
10255
+ const cat = getCatalog();
10256
+ const tables = await cat.schemaContentsTables(toUint8Array(params.attach_opaque_data), params.path, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
10257
+ return wrapResult({
10258
+ items: tables.map((t) => encodeTableInfo(t))
10259
+ }, CatalogSchemaContentsTablesResultSchema);
9125
10260
  });
9126
- catalogUnary(protocol, signingKey, "catalog_schema_contents_views", {
9127
- params: CatalogSchemaContentsViewsParamsSchema,
9128
- result: RESULT_BINARY_SCHEMA,
9129
- handler: async (params) => {
9130
- const cat = getCatalog();
9131
- const views = await cat.schemaContentsViews(toUint8Array(params.attach_opaque_data), params.path, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
9132
- return wrapResult({
9133
- items: views.map((v) => encodeViewInfo(v))
9134
- }, CatalogSchemaContentsViewsResultSchema);
9135
- }
10261
+ const catalogSchemaContentsViews = catalogHandler(signingKey, async (params) => {
10262
+ const cat = getCatalog();
10263
+ const views = await cat.schemaContentsViews(toUint8Array(params.attach_opaque_data), params.path, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
10264
+ return wrapResult({
10265
+ items: views.map((v) => encodeViewInfo(v))
10266
+ }, CatalogSchemaContentsViewsResultSchema);
9136
10267
  });
9137
- catalogUnary(protocol, signingKey, "catalog_schema_contents_functions", {
9138
- params: CatalogSchemaContentsFunctionsParamsSchema,
9139
- result: RESULT_BINARY_SCHEMA,
9140
- handler: async (params) => {
9141
- const cat = getCatalog();
9142
- 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);
9143
- return wrapResult({
9144
- items: funcs.map((f) => encodeFunctionInfoOnce(f))
9145
- }, CatalogSchemaContentsFunctionsResultSchema);
9146
- }
10268
+ const catalogSchemaContentsFunctions = catalogHandler(signingKey, async (params) => {
10269
+ const cat = getCatalog();
10270
+ 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);
10271
+ return wrapResult({
10272
+ items: funcs.map((f) => encodeFunctionInfoOnce(f))
10273
+ }, CatalogSchemaContentsFunctionsResultSchema);
9147
10274
  });
10275
+ return {
10276
+ catalogCatalogs,
10277
+ catalogAttach,
10278
+ catalogDetach,
10279
+ catalogCreate,
10280
+ catalogDrop,
10281
+ catalogVersion,
10282
+ catalogTransactionBegin,
10283
+ catalogTransactionCommit,
10284
+ catalogTransactionRollback,
10285
+ catalogSchemas,
10286
+ catalogContents,
10287
+ catalogCopyFromFormats,
10288
+ catalogSchemaGet,
10289
+ catalogSchemaCreate,
10290
+ catalogSchemaDrop,
10291
+ catalogSchemaContentsTables,
10292
+ catalogSchemaContentsViews,
10293
+ catalogSchemaContentsFunctions
10294
+ };
9148
10295
  }
9149
10296
 
9150
10297
  // src/protocol/handlers/catalog/table.ts
9151
- function registerCatalogTableMethods(protocol, getCatalog, signingKey) {
9152
- catalogUnary(protocol, signingKey, "catalog_table_get", {
9153
- params: CatalogTableGetParamsSchema,
9154
- result: RESULT_BINARY_SCHEMA,
9155
- handler: async (params) => {
9156
- const cat = getCatalog();
9157
- 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);
9158
- return wrapResult({
9159
- items: info ? [encodeTableInfo(info)] : []
9160
- }, CatalogTableGetResultSchema);
9161
- }
10298
+ function catalogTableHandlers(getCatalog, signingKey) {
10299
+ const catalogTableGet = catalogHandler(signingKey, async (params) => {
10300
+ const cat = getCatalog();
10301
+ 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);
10302
+ return wrapResult({
10303
+ items: info ? [encodeTableInfo(info)] : []
10304
+ }, CatalogTableGetResultSchema);
9162
10305
  });
9163
- catalogUnary(protocol, signingKey, "catalog_table_create", {
9164
- params: CatalogTableCreateParamsSchema,
9165
- result: emptyResultSchema,
9166
- handler: async (params) => {
9167
- const cat = getCatalog();
9168
- 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);
9169
- return {};
9170
- }
10306
+ const catalogTableCreate = catalogHandler(signingKey, async (params) => {
10307
+ const cat = getCatalog();
10308
+ 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);
10309
+ return {};
9171
10310
  });
9172
- catalogUnary(protocol, signingKey, "catalog_table_drop", {
9173
- params: CatalogTableDropParamsSchema,
9174
- result: emptyResultSchema,
9175
- handler: async (params) => {
9176
- const cat = getCatalog();
9177
- 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);
9178
- return {};
9179
- }
10311
+ const catalogTableDrop = catalogHandler(signingKey, async (params) => {
10312
+ const cat = getCatalog();
10313
+ 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);
10314
+ return {};
9180
10315
  });
9181
- catalogUnary(protocol, signingKey, "catalog_table_column_statistics_get", {
9182
- params: CatalogTableColumnStatisticsGetParamsSchema,
9183
- result: RESULT_BINARY_NULLABLE_SCHEMA,
9184
- handler: async (params) => {
9185
- const cat = getCatalog();
9186
- 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);
9187
- return { result: stats?.bytes ?? null };
9188
- }
10316
+ const catalogTableColumnStatisticsGet = catalogHandler(signingKey, async (params) => {
10317
+ const cat = getCatalog();
10318
+ 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);
10319
+ return { result: stats?.bytes ?? null };
9189
10320
  });
9190
- catalogUnary(protocol, signingKey, "catalog_table_scan_function_get", {
9191
- params: CatalogTableScanFunctionGetParamsSchema,
9192
- result: RESULT_BINARY_SCHEMA,
9193
- handler: async (params) => {
9194
- const cat = getCatalog();
9195
- 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);
9196
- return wrapResult(scanResult, ScanFunctionResultSchema);
9197
- }
10321
+ const catalogTableScanFunctionGet = catalogHandler(signingKey, async (params) => {
10322
+ const cat = getCatalog();
10323
+ 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);
10324
+ return wrapResult(scanResult, ScanFunctionResultSchema);
9198
10325
  });
9199
- catalogUnary(protocol, signingKey, "catalog_table_scan_branches_get", {
9200
- params: CatalogTableScanBranchesGetParamsSchema,
9201
- result: RESULT_BINARY_SCHEMA,
9202
- handler: async (params) => {
9203
- const cat = getCatalog();
9204
- 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);
9205
- return wrapResult(branchesResult, ScanBranchesResultSchema);
9206
- }
10326
+ const catalogTableScanBranchesGet = catalogHandler(signingKey, async (params) => {
10327
+ const cat = getCatalog();
10328
+ 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);
10329
+ return wrapResult(branchesResult, ScanBranchesResultSchema);
9207
10330
  });
9208
- catalogUnary(protocol, signingKey, "catalog_table_comment_set", {
9209
- params: CatalogTableCommentSetParamsSchema,
9210
- result: emptyResultSchema,
9211
- handler: async (params) => {
9212
- const cat = getCatalog();
9213
- 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);
9214
- return {};
9215
- }
10331
+ const catalogTableCommentSet = catalogHandler(signingKey, async (params) => {
10332
+ const cat = getCatalog();
10333
+ 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);
10334
+ return {};
9216
10335
  });
9217
- catalogUnary(protocol, signingKey, "catalog_table_rename", {
9218
- params: CatalogTableRenameParamsSchema,
9219
- result: emptyResultSchema,
9220
- handler: async (params) => {
9221
- const cat = getCatalog();
9222
- 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);
9223
- return {};
9224
- }
10336
+ const catalogTableRename = catalogHandler(signingKey, async (params) => {
10337
+ const cat = getCatalog();
10338
+ 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);
10339
+ return {};
9225
10340
  });
9226
- catalogUnary(protocol, signingKey, "catalog_table_column_add", {
9227
- params: CatalogTableColumnAddParamsSchema,
9228
- result: emptyResultSchema,
9229
- handler: async (params) => {
9230
- const cat = getCatalog();
9231
- 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);
9232
- return {};
9233
- }
10341
+ const catalogTableColumnAdd = catalogHandler(signingKey, async (params) => {
10342
+ const cat = getCatalog();
10343
+ 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);
10344
+ return {};
9234
10345
  });
9235
- catalogUnary(protocol, signingKey, "catalog_table_column_drop", {
9236
- params: CatalogTableColumnDropParamsSchema,
9237
- result: emptyResultSchema,
9238
- handler: async (params) => {
9239
- const cat = getCatalog();
9240
- 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);
9241
- return {};
9242
- }
10346
+ const catalogTableColumnDrop = catalogHandler(signingKey, async (params) => {
10347
+ const cat = getCatalog();
10348
+ 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);
10349
+ return {};
9243
10350
  });
9244
- catalogUnary(protocol, signingKey, "catalog_table_column_rename", {
9245
- params: CatalogTableColumnRenameParamsSchema,
9246
- result: emptyResultSchema,
9247
- handler: async (params) => {
9248
- const cat = getCatalog();
9249
- 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);
9250
- return {};
9251
- }
10351
+ const catalogTableColumnRename = catalogHandler(signingKey, async (params) => {
10352
+ const cat = getCatalog();
10353
+ 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);
10354
+ return {};
9252
10355
  });
9253
- catalogUnary(protocol, signingKey, "catalog_table_column_default_set", {
9254
- params: CatalogTableColumnDefaultSetParamsSchema,
9255
- result: emptyResultSchema,
9256
- handler: async (params) => {
9257
- const cat = getCatalog();
9258
- 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);
9259
- return {};
9260
- }
10356
+ const catalogTableColumnDefaultSet = catalogHandler(signingKey, async (params) => {
10357
+ const cat = getCatalog();
10358
+ 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);
10359
+ return {};
9261
10360
  });
9262
- catalogUnary(protocol, signingKey, "catalog_table_column_default_drop", {
9263
- params: CatalogTableColumnDefaultDropParamsSchema,
9264
- result: emptyResultSchema,
9265
- handler: async (params) => {
9266
- const cat = getCatalog();
9267
- 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);
9268
- return {};
9269
- }
10361
+ const catalogTableColumnDefaultDrop = catalogHandler(signingKey, async (params) => {
10362
+ const cat = getCatalog();
10363
+ 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);
10364
+ return {};
9270
10365
  });
9271
- catalogUnary(protocol, signingKey, "catalog_table_column_type_change", {
9272
- params: CatalogTableColumnTypeChangeParamsSchema,
9273
- result: emptyResultSchema,
9274
- handler: async (params) => {
9275
- const cat = getCatalog();
9276
- 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);
9277
- return {};
9278
- }
10366
+ const catalogTableColumnTypeChange = catalogHandler(signingKey, async (params) => {
10367
+ const cat = getCatalog();
10368
+ 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);
10369
+ return {};
9279
10370
  });
9280
- catalogUnary(protocol, signingKey, "catalog_table_not_null_set", {
9281
- params: CatalogTableNotNullSetParamsSchema,
9282
- result: emptyResultSchema,
9283
- handler: async (params) => {
9284
- const cat = getCatalog();
9285
- 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);
9286
- return {};
9287
- }
10371
+ const catalogTableNotNullSet = catalogHandler(signingKey, async (params) => {
10372
+ const cat = getCatalog();
10373
+ 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);
10374
+ return {};
9288
10375
  });
9289
- catalogUnary(protocol, signingKey, "catalog_table_not_null_drop", {
9290
- params: CatalogTableNotNullDropParamsSchema,
9291
- result: emptyResultSchema,
9292
- handler: async (params) => {
9293
- const cat = getCatalog();
9294
- 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);
9295
- return {};
9296
- }
10376
+ const catalogTableNotNullDrop = catalogHandler(signingKey, async (params) => {
10377
+ const cat = getCatalog();
10378
+ 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);
10379
+ return {};
9297
10380
  });
10381
+ return {
10382
+ catalogTableGet,
10383
+ catalogTableCreate,
10384
+ catalogTableDrop,
10385
+ catalogTableColumnStatisticsGet,
10386
+ catalogTableScanFunctionGet,
10387
+ catalogTableScanBranchesGet,
10388
+ catalogTableCommentSet,
10389
+ catalogTableRename,
10390
+ catalogTableColumnAdd,
10391
+ catalogTableColumnDrop,
10392
+ catalogTableColumnRename,
10393
+ catalogTableColumnDefaultSet,
10394
+ catalogTableColumnDefaultDrop,
10395
+ catalogTableColumnTypeChange,
10396
+ catalogTableNotNullSet,
10397
+ catalogTableNotNullDrop
10398
+ };
9298
10399
  }
9299
10400
 
9300
10401
  // src/protocol/handlers/catalog/view.ts
9301
- function registerCatalogViewMethods(protocol, getCatalog, signingKey) {
9302
- catalogUnary(protocol, signingKey, "catalog_view_get", {
9303
- params: CatalogViewGetParamsSchema,
9304
- result: RESULT_BINARY_SCHEMA,
9305
- handler: async (params) => {
9306
- const cat = getCatalog();
9307
- 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);
9308
- return wrapResult({
9309
- items: info ? [encodeViewInfo(info)] : []
9310
- }, CatalogViewGetResultSchema);
9311
- }
10402
+ function catalogViewHandlers(getCatalog, signingKey) {
10403
+ const catalogViewGet = catalogHandler(signingKey, async (params) => {
10404
+ const cat = getCatalog();
10405
+ 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);
10406
+ return wrapResult({
10407
+ items: info ? [encodeViewInfo(info)] : []
10408
+ }, CatalogViewGetResultSchema);
9312
10409
  });
9313
- catalogUnary(protocol, signingKey, "catalog_view_create", {
9314
- params: CatalogViewCreateParamsSchema,
9315
- result: emptyResultSchema,
9316
- handler: async (params) => {
9317
- const cat = getCatalog();
9318
- 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);
9319
- return {};
9320
- }
10410
+ const catalogViewCreate = catalogHandler(signingKey, async (params) => {
10411
+ const cat = getCatalog();
10412
+ 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);
10413
+ return {};
9321
10414
  });
9322
- catalogUnary(protocol, signingKey, "catalog_view_drop", {
9323
- params: CatalogViewDropParamsSchema,
9324
- result: emptyResultSchema,
9325
- handler: async (params) => {
9326
- const cat = getCatalog();
9327
- 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);
9328
- return {};
9329
- }
10415
+ const catalogViewDrop = catalogHandler(signingKey, async (params) => {
10416
+ const cat = getCatalog();
10417
+ 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);
10418
+ return {};
9330
10419
  });
9331
- catalogUnary(protocol, signingKey, "catalog_view_rename", {
9332
- params: CatalogViewRenameParamsSchema,
9333
- result: emptyResultSchema,
9334
- handler: async (params) => {
9335
- const cat = getCatalog();
9336
- 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);
9337
- return {};
9338
- }
10420
+ const catalogViewRename = catalogHandler(signingKey, async (params) => {
10421
+ const cat = getCatalog();
10422
+ 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);
10423
+ return {};
9339
10424
  });
9340
- catalogUnary(protocol, signingKey, "catalog_view_comment_set", {
9341
- params: CatalogViewCommentSetParamsSchema,
9342
- result: emptyResultSchema,
9343
- handler: async (params) => {
9344
- const cat = getCatalog();
9345
- 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);
9346
- return {};
9347
- }
10425
+ const catalogViewCommentSet = catalogHandler(signingKey, async (params) => {
10426
+ const cat = getCatalog();
10427
+ 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);
10428
+ return {};
9348
10429
  });
10430
+ return { catalogViewGet, catalogViewCreate, catalogViewDrop, catalogViewRename, catalogViewCommentSet };
9349
10431
  }
9350
10432
 
9351
10433
  // src/protocol/handlers/catalog/macro.ts
9352
- function registerCatalogMacroMethods(protocol, getCatalog, signingKey) {
9353
- catalogUnary(protocol, signingKey, "catalog_macro_get", {
9354
- params: CatalogMacroGetParamsSchema,
9355
- result: RESULT_BINARY_SCHEMA,
9356
- handler: async (params) => {
9357
- const cat = getCatalog();
9358
- 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);
9359
- return wrapResult({
9360
- items: info ? [encodeMacroInfo(info)] : []
9361
- }, CatalogMacroGetResultSchema);
9362
- }
10434
+ function catalogMacroHandlers(getCatalog, signingKey) {
10435
+ const catalogMacroGet = catalogHandler(signingKey, async (params) => {
10436
+ const cat = getCatalog();
10437
+ 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);
10438
+ return wrapResult({
10439
+ items: info ? [encodeMacroInfo(info)] : []
10440
+ }, CatalogMacroGetResultSchema);
9363
10441
  });
9364
- catalogUnary(protocol, signingKey, "catalog_macro_create", {
9365
- params: CatalogMacroCreateParamsSchema,
9366
- result: emptyResultSchema,
9367
- handler: async (params) => {
9368
- const cat = getCatalog();
9369
- const innerParams = params;
9370
- 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);
9371
- return {};
9372
- }
10442
+ const catalogMacroCreate = catalogHandler(signingKey, async (params) => {
10443
+ const cat = getCatalog();
10444
+ const innerParams = params;
10445
+ 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);
10446
+ return {};
9373
10447
  });
9374
- catalogUnary(protocol, signingKey, "catalog_macro_drop", {
9375
- params: CatalogMacroDropParamsSchema,
9376
- result: emptyResultSchema,
9377
- handler: async (params) => {
9378
- const cat = getCatalog();
9379
- 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);
9380
- return {};
9381
- }
10448
+ const catalogMacroDrop = catalogHandler(signingKey, async (params) => {
10449
+ const cat = getCatalog();
10450
+ 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);
10451
+ return {};
9382
10452
  });
9383
- catalogUnary(protocol, signingKey, "catalog_schema_contents_macros", {
9384
- params: CatalogSchemaContentsMacrosParamsSchema,
9385
- result: RESULT_BINARY_SCHEMA,
9386
- handler: async (params) => {
9387
- const cat = getCatalog();
9388
- 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);
9389
- return wrapResult({
9390
- items: macros.map((m) => encodeMacroInfo(m))
9391
- }, CatalogSchemaContentsMacrosResultSchema);
9392
- }
10453
+ const catalogSchemaContentsMacros = catalogHandler(signingKey, async (params) => {
10454
+ const cat = getCatalog();
10455
+ 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);
10456
+ return wrapResult({
10457
+ items: macros.map((m) => encodeMacroInfo(m))
10458
+ }, CatalogSchemaContentsMacrosResultSchema);
9393
10459
  });
10460
+ return { catalogMacroGet, catalogMacroCreate, catalogMacroDrop, catalogSchemaContentsMacros };
9394
10461
  }
9395
10462
 
9396
10463
  // src/protocol/handlers/catalog/index_methods.ts
9397
- function registerCatalogIndexMethods(protocol, getCatalog, signingKey) {
9398
- catalogUnary(protocol, signingKey, "catalog_schema_contents_indexes", {
9399
- params: CatalogSchemaContentsIndexesParamsSchema,
9400
- result: RESULT_BINARY_SCHEMA,
9401
- handler: async (params) => {
9402
- const cat = getCatalog();
9403
- const indexes = await cat.schemaContentsIndexes(toUint8Array(params.attach_opaque_data), params.path, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
9404
- return wrapResult({
9405
- items: indexes.map((i) => encodeIndexInfo(i))
9406
- }, CatalogSchemaContentsIndexesResultSchema);
9407
- }
10464
+ function catalogIndexHandlers(getCatalog, signingKey) {
10465
+ const catalogSchemaContentsIndexes = catalogHandler(signingKey, async (params) => {
10466
+ const cat = getCatalog();
10467
+ const indexes = await cat.schemaContentsIndexes(toUint8Array(params.attach_opaque_data), params.path, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
10468
+ return wrapResult({
10469
+ items: indexes.map((i) => encodeIndexInfo(i))
10470
+ }, CatalogSchemaContentsIndexesResultSchema);
9408
10471
  });
9409
- catalogUnary(protocol, signingKey, "catalog_index_get", {
9410
- params: CatalogIndexGetParamsSchema,
9411
- result: RESULT_BINARY_SCHEMA,
9412
- handler: async (params) => {
9413
- const cat = getCatalog();
9414
- 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);
9415
- return wrapResult({
9416
- items: info ? [encodeIndexInfo(info)] : []
9417
- }, CatalogIndexGetResultSchema);
9418
- }
10472
+ const catalogIndexGet = catalogHandler(signingKey, async (params) => {
10473
+ const cat = getCatalog();
10474
+ 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);
10475
+ return wrapResult({
10476
+ items: info ? [encodeIndexInfo(info)] : []
10477
+ }, CatalogIndexGetResultSchema);
9419
10478
  });
10479
+ return { catalogSchemaContentsIndexes, catalogIndexGet };
9420
10480
  }
9421
10481
 
9422
10482
  // src/protocol/handlers/catalog/index.ts
9423
- function registerCatalogMethods(protocol, catalog, _catalogName, signingKey) {
10483
+ function catalogHandlers(catalog, signingKey) {
9424
10484
  const getCatalog = makeGetCatalog(catalog);
9425
- registerCatalogAdminMethods(protocol, getCatalog, signingKey);
9426
- registerCatalogTableMethods(protocol, getCatalog, signingKey);
9427
- registerCatalogViewMethods(protocol, getCatalog, signingKey);
9428
- registerCatalogMacroMethods(protocol, getCatalog, signingKey);
9429
- registerCatalogIndexMethods(protocol, getCatalog, signingKey);
10485
+ return {
10486
+ ...catalogAdminHandlers(getCatalog, signingKey),
10487
+ ...catalogTableHandlers(getCatalog, signingKey),
10488
+ ...catalogViewHandlers(getCatalog, signingKey),
10489
+ ...catalogMacroHandlers(getCatalog, signingKey),
10490
+ ...catalogIndexHandlers(getCatalog, signingKey)
10491
+ };
9430
10492
  }
9431
10493
 
9432
10494
  // src/protocol/dispatch.ts
9433
- var VGI_PROTOCOL_NAME = "vgi.v2";
10495
+ function buildVgiService(config) {
10496
+ return {
10497
+ ...UNIMPLEMENTED_VGI_SERVICE,
10498
+ ...functionHandlers({
10499
+ registry: config.registry,
10500
+ signingKey: config.signingKey,
10501
+ catalogInterface: config.catalogInterface
10502
+ }),
10503
+ ...aggregateHandlers(config.registry),
10504
+ ...tableBufferingHandlers(config.registry, config.signingKey),
10505
+ ...catalogHandlers(config.catalogInterface, config.signingKey)
10506
+ };
10507
+ }
9434
10508
  function buildVgiProtocol(config) {
9435
- const protocol = new Protocol2(VGI_PROTOCOL_NAME, { protocolVersion: "2.1.0" });
9436
- registerFunctionMethods(protocol, {
9437
- registry: config.registry,
9438
- signingKey: config.signingKey,
9439
- catalogInterface: config.catalogInterface
9440
- });
9441
- registerAggregateMethods(protocol, config.registry);
9442
- registerTableBufferingMethods(protocol, config.registry, config.signingKey);
9443
- registerCatalogMethods(protocol, config.catalogInterface, config.catalogName, config.signingKey);
9444
- return protocol;
10509
+ return createVgiProtocol(buildVgiService(config));
9445
10510
  }
9446
10511
 
9447
10512
  // src/http/landing-html.ts
@@ -12212,4 +13277,4 @@ export {
12212
13277
  utf82 as utf8
12213
13278
  };
12214
13279
 
12215
- //# debugId=8A1BBED7A349251A64756E2164756E21
13280
+ //# debugId=D9B447159663895D64756E2164756E21