@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
@@ -3173,8 +3173,1259 @@ var arrowStateSerializer = {
3173
3173
  }
3174
3174
  };
3175
3175
 
3176
- // src/protocol/dispatch.ts
3177
- import { Protocol as Protocol2 } from "@query-farm/vgi-rpc";
3176
+ // src/generated/vgi-service.ts
3177
+ import {
3178
+ MethodNotImplementedError,
3179
+ Protocol
3180
+ } from "@query-farm/vgi-rpc";
3181
+ var VGI_PROTOCOL_NAME = "vgi.v2";
3182
+ var VGI_PROTOCOL_VERSION = "2.1.0";
3183
+ function exchangeStream(callbacks) {
3184
+ return { kind: "exchange", ...callbacks };
3185
+ }
3186
+ function producerStream(callbacks) {
3187
+ return { kind: "producer", ...callbacks };
3188
+ }
3189
+ var VGI_V2_METHODS = [
3190
+ {
3191
+ name: "aggregate_bind",
3192
+ key: "aggregateBind",
3193
+ type: "unary",
3194
+ params: schema2([
3195
+ field2("request", binary2(), false)
3196
+ ]),
3197
+ result: schema2([
3198
+ field2("result", binary2(), false)
3199
+ ]),
3200
+ doc: "Bind an aggregate function, return output schema and execution_id."
3201
+ },
3202
+ {
3203
+ name: "aggregate_combine",
3204
+ key: "aggregateCombine",
3205
+ type: "unary",
3206
+ params: schema2([
3207
+ field2("request", binary2(), false)
3208
+ ]),
3209
+ result: schema2([
3210
+ field2("result", binary2(), false)
3211
+ ]),
3212
+ doc: "Merge source states into target states."
3213
+ },
3214
+ {
3215
+ name: "aggregate_destructor",
3216
+ key: "aggregateDestructor",
3217
+ type: "unary",
3218
+ params: schema2([
3219
+ field2("request", binary2(), false)
3220
+ ]),
3221
+ result: schema2([
3222
+ field2("result", binary2(), false)
3223
+ ]),
3224
+ doc: "Best-effort cleanup of aggregate states. Must not raise."
3225
+ },
3226
+ {
3227
+ name: "aggregate_finalize",
3228
+ key: "aggregateFinalize",
3229
+ type: "unary",
3230
+ params: schema2([
3231
+ field2("request", binary2(), false)
3232
+ ]),
3233
+ result: schema2([
3234
+ field2("result", binary2(), false)
3235
+ ]),
3236
+ doc: "Produce results for a chunk of group_ids."
3237
+ },
3238
+ {
3239
+ name: "aggregate_streaming_chunk",
3240
+ key: "aggregateStreamingChunk",
3241
+ type: "unary",
3242
+ params: schema2([
3243
+ field2("request", binary2(), false)
3244
+ ]),
3245
+ result: schema2([
3246
+ field2("result", binary2(), false)
3247
+ ]),
3248
+ doc: "Process one input chunk; returns one output row per input row."
3249
+ },
3250
+ {
3251
+ name: "aggregate_streaming_close",
3252
+ key: "aggregateStreamingClose",
3253
+ type: "unary",
3254
+ params: schema2([
3255
+ field2("request", binary2(), false)
3256
+ ]),
3257
+ result: schema2([
3258
+ field2("result", binary2(), false)
3259
+ ]),
3260
+ doc: "End the streaming session, free per-session state."
3261
+ },
3262
+ {
3263
+ name: "aggregate_streaming_open",
3264
+ key: "aggregateStreamingOpen",
3265
+ type: "unary",
3266
+ params: schema2([
3267
+ field2("request", binary2(), false)
3268
+ ]),
3269
+ result: schema2([
3270
+ field2("result", binary2(), false)
3271
+ ]),
3272
+ doc: "Start a streaming-partitioned aggregate session."
3273
+ },
3274
+ {
3275
+ name: "aggregate_update",
3276
+ key: "aggregateUpdate",
3277
+ type: "unary",
3278
+ params: schema2([
3279
+ field2("request", binary2(), false)
3280
+ ]),
3281
+ result: schema2([
3282
+ field2("result", binary2(), false)
3283
+ ]),
3284
+ doc: "Accumulate rows from a `DataChunk` into per-group state."
3285
+ },
3286
+ {
3287
+ name: "aggregate_window",
3288
+ key: "aggregateWindow",
3289
+ type: "unary",
3290
+ params: schema2([
3291
+ field2("request", binary2(), false)
3292
+ ]),
3293
+ result: schema2([
3294
+ field2("result", binary2(), false)
3295
+ ]),
3296
+ doc: "Compute an aggregate value for one output row of the window."
3297
+ },
3298
+ {
3299
+ name: "aggregate_window_batch",
3300
+ key: "aggregateWindowBatch",
3301
+ type: "unary",
3302
+ params: schema2([
3303
+ field2("request", binary2(), false)
3304
+ ]),
3305
+ result: schema2([
3306
+ field2("result", binary2(), false)
3307
+ ]),
3308
+ doc: "Compute ``count`` window output rows in one batched RPC."
3309
+ },
3310
+ {
3311
+ name: "aggregate_window_destructor",
3312
+ key: "aggregateWindowDestructor",
3313
+ type: "unary",
3314
+ params: schema2([
3315
+ field2("request", binary2(), false)
3316
+ ]),
3317
+ result: schema2([
3318
+ field2("result", binary2(), false)
3319
+ ]),
3320
+ doc: "Evict a cached partition from storage."
3321
+ },
3322
+ {
3323
+ name: "aggregate_window_init",
3324
+ key: "aggregateWindowInit",
3325
+ type: "unary",
3326
+ params: schema2([
3327
+ field2("request", binary2(), false)
3328
+ ]),
3329
+ result: schema2([
3330
+ field2("result", binary2(), false)
3331
+ ]),
3332
+ doc: "Ship a partition to the worker for windowed aggregation."
3333
+ },
3334
+ {
3335
+ name: "bind",
3336
+ key: "bind",
3337
+ type: "unary",
3338
+ params: schema2([
3339
+ field2("request", binary2(), false)
3340
+ ]),
3341
+ result: schema2([
3342
+ field2("result", binary2(), false)
3343
+ ]),
3344
+ doc: "Resolve output schema and validate arguments."
3345
+ },
3346
+ {
3347
+ name: "catalog_attach",
3348
+ key: "catalogAttach",
3349
+ type: "unary",
3350
+ params: schema2([
3351
+ field2("request", binary2(), false)
3352
+ ]),
3353
+ result: schema2([
3354
+ field2("result", binary2(), false)
3355
+ ]),
3356
+ doc: "Attach to a catalog with options."
3357
+ },
3358
+ {
3359
+ name: "catalog_catalogs",
3360
+ key: "catalogCatalogs",
3361
+ type: "unary",
3362
+ params: schema2([]),
3363
+ result: schema2([
3364
+ field2("result", binary2(), false)
3365
+ ]),
3366
+ doc: "List available catalog names."
3367
+ },
3368
+ {
3369
+ name: "catalog_contents",
3370
+ key: "catalogContents",
3371
+ type: "unary",
3372
+ params: schema2([
3373
+ field2("attach_opaque_data", binary2(), false),
3374
+ field2("if_none_match", utf82(), true)
3375
+ ]),
3376
+ result: schema2([
3377
+ field2("result", binary2(), false)
3378
+ ]),
3379
+ doc: "Return every schema and all of its contents in one result."
3380
+ },
3381
+ {
3382
+ name: "catalog_copy_from_formats",
3383
+ key: "catalogCopyFromFormats",
3384
+ type: "unary",
3385
+ params: schema2([
3386
+ field2("attach_opaque_data", binary2(), false),
3387
+ field2("transaction_opaque_data", binary2(), true)
3388
+ ]),
3389
+ result: schema2([
3390
+ field2("result", binary2(), false)
3391
+ ]),
3392
+ doc: "List custom ``COPY ... FROM`` formats advertised by this catalog."
3393
+ },
3394
+ {
3395
+ name: "catalog_create",
3396
+ key: "catalogCreate",
3397
+ type: "unary",
3398
+ params: schema2([
3399
+ field2("request", binary2(), false)
3400
+ ]),
3401
+ result: schema2([]),
3402
+ doc: "Create a new catalog."
3403
+ },
3404
+ {
3405
+ name: "catalog_detach",
3406
+ key: "catalogDetach",
3407
+ type: "unary",
3408
+ params: schema2([
3409
+ field2("attach_opaque_data", binary2(), false)
3410
+ ]),
3411
+ result: schema2([]),
3412
+ doc: "Detach from a catalog."
3413
+ },
3414
+ {
3415
+ name: "catalog_drop",
3416
+ key: "catalogDrop",
3417
+ type: "unary",
3418
+ params: schema2([
3419
+ field2("name", utf82(), false)
3420
+ ]),
3421
+ result: schema2([]),
3422
+ doc: "Drop a catalog."
3423
+ },
3424
+ {
3425
+ name: "catalog_index_create",
3426
+ key: "catalogIndexCreate",
3427
+ type: "unary",
3428
+ params: schema2([
3429
+ field2("request", binary2(), false)
3430
+ ]),
3431
+ result: schema2([]),
3432
+ doc: "Create a new index."
3433
+ },
3434
+ {
3435
+ name: "catalog_index_drop",
3436
+ key: "catalogIndexDrop",
3437
+ type: "unary",
3438
+ params: schema2([
3439
+ field2("attach_opaque_data", binary2(), false),
3440
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
3441
+ field2("name", utf82(), false),
3442
+ field2("ignore_not_found", bool2(), false),
3443
+ field2("cascade", bool2(), false),
3444
+ field2("transaction_opaque_data", binary2(), true)
3445
+ ]),
3446
+ result: schema2([]),
3447
+ doc: "Drop an index."
3448
+ },
3449
+ {
3450
+ name: "catalog_index_get",
3451
+ key: "catalogIndexGet",
3452
+ type: "unary",
3453
+ params: schema2([
3454
+ field2("attach_opaque_data", binary2(), false),
3455
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
3456
+ field2("name", utf82(), false),
3457
+ field2("transaction_opaque_data", binary2(), true)
3458
+ ]),
3459
+ result: schema2([
3460
+ field2("result", binary2(), false)
3461
+ ]),
3462
+ doc: "Get information about an index. Returns 0 or 1 items."
3463
+ },
3464
+ {
3465
+ name: "catalog_macro_create",
3466
+ key: "catalogMacroCreate",
3467
+ type: "unary",
3468
+ params: schema2([
3469
+ field2("request", binary2(), false)
3470
+ ]),
3471
+ result: schema2([]),
3472
+ doc: "Create a new macro."
3473
+ },
3474
+ {
3475
+ name: "catalog_macro_drop",
3476
+ key: "catalogMacroDrop",
3477
+ type: "unary",
3478
+ params: schema2([
3479
+ field2("attach_opaque_data", binary2(), false),
3480
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
3481
+ field2("name", utf82(), false),
3482
+ field2("ignore_not_found", bool2(), false),
3483
+ field2("transaction_opaque_data", binary2(), true)
3484
+ ]),
3485
+ result: schema2([]),
3486
+ doc: "Drop a macro."
3487
+ },
3488
+ {
3489
+ name: "catalog_macro_get",
3490
+ key: "catalogMacroGet",
3491
+ type: "unary",
3492
+ params: schema2([
3493
+ field2("attach_opaque_data", binary2(), false),
3494
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
3495
+ field2("name", utf82(), false),
3496
+ field2("transaction_opaque_data", binary2(), true)
3497
+ ]),
3498
+ result: schema2([
3499
+ field2("result", binary2(), false)
3500
+ ]),
3501
+ doc: "Get information about a macro. Returns 0 or 1 items."
3502
+ },
3503
+ {
3504
+ name: "catalog_schema_contents_functions",
3505
+ key: "catalogSchemaContentsFunctions",
3506
+ type: "unary",
3507
+ params: schema2([
3508
+ field2("attach_opaque_data", binary2(), false),
3509
+ field2("path", list2(field2("item", utf82(), true)), false),
3510
+ field2("type", dictionary2(utf82(), int162()), false),
3511
+ field2("transaction_opaque_data", binary2(), true)
3512
+ ]),
3513
+ result: schema2([
3514
+ field2("result", binary2(), false)
3515
+ ]),
3516
+ doc: "List functions in a schema (scalar or table)."
3517
+ },
3518
+ {
3519
+ name: "catalog_schema_contents_indexes",
3520
+ key: "catalogSchemaContentsIndexes",
3521
+ type: "unary",
3522
+ params: schema2([
3523
+ field2("attach_opaque_data", binary2(), false),
3524
+ field2("path", list2(field2("item", utf82(), true)), false),
3525
+ field2("transaction_opaque_data", binary2(), true)
3526
+ ]),
3527
+ result: schema2([
3528
+ field2("result", binary2(), false)
3529
+ ]),
3530
+ doc: "List indexes in a schema."
3531
+ },
3532
+ {
3533
+ name: "catalog_schema_contents_macros",
3534
+ key: "catalogSchemaContentsMacros",
3535
+ type: "unary",
3536
+ params: schema2([
3537
+ field2("attach_opaque_data", binary2(), false),
3538
+ field2("path", list2(field2("item", utf82(), true)), false),
3539
+ field2("type", dictionary2(utf82(), int162()), false),
3540
+ field2("transaction_opaque_data", binary2(), true)
3541
+ ]),
3542
+ result: schema2([
3543
+ field2("result", binary2(), false)
3544
+ ]),
3545
+ doc: "List macros in a schema (scalar or table)."
3546
+ },
3547
+ {
3548
+ name: "catalog_schema_contents_tables",
3549
+ key: "catalogSchemaContentsTables",
3550
+ type: "unary",
3551
+ params: schema2([
3552
+ field2("attach_opaque_data", binary2(), false),
3553
+ field2("path", list2(field2("item", utf82(), true)), false),
3554
+ field2("transaction_opaque_data", binary2(), true)
3555
+ ]),
3556
+ result: schema2([
3557
+ field2("result", binary2(), false)
3558
+ ]),
3559
+ doc: "List tables in a schema."
3560
+ },
3561
+ {
3562
+ name: "catalog_schema_contents_views",
3563
+ key: "catalogSchemaContentsViews",
3564
+ type: "unary",
3565
+ params: schema2([
3566
+ field2("attach_opaque_data", binary2(), false),
3567
+ field2("path", list2(field2("item", utf82(), true)), false),
3568
+ field2("transaction_opaque_data", binary2(), true)
3569
+ ]),
3570
+ result: schema2([
3571
+ field2("result", binary2(), false)
3572
+ ]),
3573
+ doc: "List views in a schema."
3574
+ },
3575
+ {
3576
+ name: "catalog_schema_create",
3577
+ key: "catalogSchemaCreate",
3578
+ type: "unary",
3579
+ params: schema2([
3580
+ field2("attach_opaque_data", binary2(), false),
3581
+ field2("path", list2(field2("item", utf82(), true)), false),
3582
+ field2("on_conflict", dictionary2(utf82(), int162()), false),
3583
+ field2("comment", utf82(), true),
3584
+ field2("tags", map2(field2("key", utf82(), false), field2("value", utf82(), true), false), true),
3585
+ field2("transaction_opaque_data", binary2(), true)
3586
+ ]),
3587
+ result: schema2([]),
3588
+ doc: "Create a new schema."
3589
+ },
3590
+ {
3591
+ name: "catalog_schema_drop",
3592
+ key: "catalogSchemaDrop",
3593
+ type: "unary",
3594
+ params: schema2([
3595
+ field2("attach_opaque_data", binary2(), false),
3596
+ field2("path", list2(field2("item", utf82(), true)), false),
3597
+ field2("ignore_not_found", bool2(), false),
3598
+ field2("cascade", bool2(), false),
3599
+ field2("transaction_opaque_data", binary2(), true)
3600
+ ]),
3601
+ result: schema2([]),
3602
+ doc: "Drop a schema."
3603
+ },
3604
+ {
3605
+ name: "catalog_schema_get",
3606
+ key: "catalogSchemaGet",
3607
+ type: "unary",
3608
+ params: schema2([
3609
+ field2("attach_opaque_data", binary2(), false),
3610
+ field2("path", list2(field2("item", utf82(), true)), false),
3611
+ field2("transaction_opaque_data", binary2(), true)
3612
+ ]),
3613
+ result: schema2([
3614
+ field2("result", binary2(), false)
3615
+ ]),
3616
+ doc: "Get information about a schema. Returns 0 or 1 items."
3617
+ },
3618
+ {
3619
+ name: "catalog_schemas",
3620
+ key: "catalogSchemas",
3621
+ type: "unary",
3622
+ params: schema2([
3623
+ field2("attach_opaque_data", binary2(), false),
3624
+ field2("transaction_opaque_data", binary2(), true)
3625
+ ]),
3626
+ result: schema2([
3627
+ field2("result", binary2(), false)
3628
+ ]),
3629
+ doc: "List schemas in the catalog."
3630
+ },
3631
+ {
3632
+ name: "catalog_table_column_add",
3633
+ key: "catalogTableColumnAdd",
3634
+ type: "unary",
3635
+ params: schema2([
3636
+ field2("attach_opaque_data", binary2(), false),
3637
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
3638
+ field2("name", utf82(), false),
3639
+ field2("column_definition", binary2(), false),
3640
+ field2("ignore_not_found", bool2(), false),
3641
+ field2("if_column_not_exists", bool2(), false),
3642
+ field2("transaction_opaque_data", binary2(), true)
3643
+ ]),
3644
+ result: schema2([]),
3645
+ doc: "Add a new column to a table."
3646
+ },
3647
+ {
3648
+ name: "catalog_table_column_comment_set",
3649
+ key: "catalogTableColumnCommentSet",
3650
+ type: "unary",
3651
+ params: schema2([
3652
+ field2("attach_opaque_data", binary2(), false),
3653
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
3654
+ field2("name", utf82(), false),
3655
+ field2("column_name", utf82(), false),
3656
+ field2("comment", utf82(), true),
3657
+ field2("ignore_not_found", bool2(), false),
3658
+ field2("transaction_opaque_data", binary2(), true)
3659
+ ]),
3660
+ result: schema2([]),
3661
+ doc: "Set or clear the comment on a table column."
3662
+ },
3663
+ {
3664
+ name: "catalog_table_column_default_drop",
3665
+ key: "catalogTableColumnDefaultDrop",
3666
+ type: "unary",
3667
+ params: schema2([
3668
+ field2("attach_opaque_data", binary2(), false),
3669
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
3670
+ field2("name", utf82(), false),
3671
+ field2("column_name", utf82(), false),
3672
+ field2("ignore_not_found", bool2(), false),
3673
+ field2("transaction_opaque_data", binary2(), true)
3674
+ ]),
3675
+ result: schema2([]),
3676
+ doc: "Remove the default value from a column."
3677
+ },
3678
+ {
3679
+ name: "catalog_table_column_default_set",
3680
+ key: "catalogTableColumnDefaultSet",
3681
+ type: "unary",
3682
+ params: schema2([
3683
+ field2("attach_opaque_data", binary2(), false),
3684
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
3685
+ field2("name", utf82(), false),
3686
+ field2("column_name", utf82(), false),
3687
+ field2("expression", utf82(), false),
3688
+ field2("ignore_not_found", bool2(), false),
3689
+ field2("transaction_opaque_data", binary2(), true)
3690
+ ]),
3691
+ result: schema2([]),
3692
+ doc: "Set the default value expression for a column."
3693
+ },
3694
+ {
3695
+ name: "catalog_table_column_drop",
3696
+ key: "catalogTableColumnDrop",
3697
+ type: "unary",
3698
+ params: schema2([
3699
+ field2("attach_opaque_data", binary2(), false),
3700
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
3701
+ field2("name", utf82(), false),
3702
+ field2("column_name", utf82(), false),
3703
+ field2("ignore_not_found", bool2(), false),
3704
+ field2("if_column_exists", bool2(), false),
3705
+ field2("cascade", bool2(), false),
3706
+ field2("transaction_opaque_data", binary2(), true)
3707
+ ]),
3708
+ result: schema2([]),
3709
+ doc: "Drop a column from a table."
3710
+ },
3711
+ {
3712
+ name: "catalog_table_column_rename",
3713
+ key: "catalogTableColumnRename",
3714
+ type: "unary",
3715
+ params: schema2([
3716
+ field2("attach_opaque_data", binary2(), false),
3717
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
3718
+ field2("name", utf82(), false),
3719
+ field2("column_name", utf82(), false),
3720
+ field2("new_column_name", utf82(), false),
3721
+ field2("ignore_not_found", bool2(), false),
3722
+ field2("transaction_opaque_data", binary2(), true)
3723
+ ]),
3724
+ result: schema2([]),
3725
+ doc: "Rename a column."
3726
+ },
3727
+ {
3728
+ name: "catalog_table_column_statistics_get",
3729
+ key: "catalogTableColumnStatisticsGet",
3730
+ type: "unary",
3731
+ params: schema2([
3732
+ field2("attach_opaque_data", binary2(), false),
3733
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
3734
+ field2("name", utf82(), false),
3735
+ field2("transaction_opaque_data", binary2(), true)
3736
+ ]),
3737
+ result: schema2([
3738
+ field2("result", binary2(), true)
3739
+ ]),
3740
+ doc: "Get column statistics for a table."
3741
+ },
3742
+ {
3743
+ name: "catalog_table_column_type_change",
3744
+ key: "catalogTableColumnTypeChange",
3745
+ type: "unary",
3746
+ params: schema2([
3747
+ field2("attach_opaque_data", binary2(), false),
3748
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
3749
+ field2("name", utf82(), false),
3750
+ field2("column_definition", binary2(), false),
3751
+ field2("expression", utf82(), true),
3752
+ field2("ignore_not_found", bool2(), false),
3753
+ field2("transaction_opaque_data", binary2(), true)
3754
+ ]),
3755
+ result: schema2([]),
3756
+ doc: "Change the type of a column."
3757
+ },
3758
+ {
3759
+ name: "catalog_table_comment_set",
3760
+ key: "catalogTableCommentSet",
3761
+ type: "unary",
3762
+ params: schema2([
3763
+ field2("attach_opaque_data", binary2(), false),
3764
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
3765
+ field2("name", utf82(), false),
3766
+ field2("comment", utf82(), true),
3767
+ field2("ignore_not_found", bool2(), false),
3768
+ field2("transaction_opaque_data", binary2(), true)
3769
+ ]),
3770
+ result: schema2([]),
3771
+ doc: "Set or clear the comment on a table."
3772
+ },
3773
+ {
3774
+ name: "catalog_table_create",
3775
+ key: "catalogTableCreate",
3776
+ type: "unary",
3777
+ params: schema2([
3778
+ field2("request", binary2(), false)
3779
+ ]),
3780
+ result: schema2([]),
3781
+ doc: "Create a new table."
3782
+ },
3783
+ {
3784
+ name: "catalog_table_delete_function_get",
3785
+ key: "catalogTableDeleteFunctionGet",
3786
+ type: "unary",
3787
+ params: schema2([
3788
+ field2("attach_opaque_data", binary2(), false),
3789
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
3790
+ field2("name", utf82(), false),
3791
+ field2("transaction_opaque_data", binary2(), true)
3792
+ ]),
3793
+ result: schema2([
3794
+ field2("result", binary2(), false)
3795
+ ]),
3796
+ doc: "Get the delete function for a table. Returns `WriteFunctionResult` as IPC bytes."
3797
+ },
3798
+ {
3799
+ name: "catalog_table_drop",
3800
+ key: "catalogTableDrop",
3801
+ type: "unary",
3802
+ params: schema2([
3803
+ field2("attach_opaque_data", binary2(), false),
3804
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
3805
+ field2("name", utf82(), false),
3806
+ field2("ignore_not_found", bool2(), false),
3807
+ field2("cascade", bool2(), false),
3808
+ field2("transaction_opaque_data", binary2(), true)
3809
+ ]),
3810
+ result: schema2([]),
3811
+ doc: "Drop a table."
3812
+ },
3813
+ {
3814
+ name: "catalog_table_get",
3815
+ key: "catalogTableGet",
3816
+ type: "unary",
3817
+ params: schema2([
3818
+ field2("attach_opaque_data", binary2(), false),
3819
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
3820
+ field2("name", utf82(), false),
3821
+ field2("at_unit", utf82(), true),
3822
+ field2("at_value", utf82(), true),
3823
+ field2("transaction_opaque_data", binary2(), true)
3824
+ ]),
3825
+ result: schema2([
3826
+ field2("result", binary2(), false)
3827
+ ]),
3828
+ doc: "Get information about a table. Returns 0 or 1 items."
3829
+ },
3830
+ {
3831
+ name: "catalog_table_insert_function_get",
3832
+ key: "catalogTableInsertFunctionGet",
3833
+ type: "unary",
3834
+ params: schema2([
3835
+ field2("attach_opaque_data", binary2(), false),
3836
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
3837
+ field2("name", utf82(), false),
3838
+ field2("transaction_opaque_data", binary2(), true),
3839
+ field2("writable_branch_function_name", utf82(), true)
3840
+ ]),
3841
+ result: schema2([
3842
+ field2("result", binary2(), false)
3843
+ ]),
3844
+ doc: "Get the insert function for a table. Returns `WriteFunctionResult` as IPC bytes."
3845
+ },
3846
+ {
3847
+ name: "catalog_table_not_null_drop",
3848
+ key: "catalogTableNotNullDrop",
3849
+ type: "unary",
3850
+ params: schema2([
3851
+ field2("attach_opaque_data", binary2(), false),
3852
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
3853
+ field2("name", utf82(), false),
3854
+ field2("column_name", utf82(), false),
3855
+ field2("ignore_not_found", bool2(), false),
3856
+ field2("transaction_opaque_data", binary2(), true)
3857
+ ]),
3858
+ result: schema2([]),
3859
+ doc: "Remove NOT NULL constraint from a column."
3860
+ },
3861
+ {
3862
+ name: "catalog_table_not_null_set",
3863
+ key: "catalogTableNotNullSet",
3864
+ type: "unary",
3865
+ params: schema2([
3866
+ field2("attach_opaque_data", binary2(), false),
3867
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
3868
+ field2("name", utf82(), false),
3869
+ field2("column_name", utf82(), false),
3870
+ field2("ignore_not_found", bool2(), false),
3871
+ field2("transaction_opaque_data", binary2(), true)
3872
+ ]),
3873
+ result: schema2([]),
3874
+ doc: "Add NOT NULL constraint to a column."
3875
+ },
3876
+ {
3877
+ name: "catalog_table_rename",
3878
+ key: "catalogTableRename",
3879
+ type: "unary",
3880
+ params: schema2([
3881
+ field2("attach_opaque_data", binary2(), false),
3882
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
3883
+ field2("name", utf82(), false),
3884
+ field2("new_name", utf82(), false),
3885
+ field2("ignore_not_found", bool2(), false),
3886
+ field2("transaction_opaque_data", binary2(), true)
3887
+ ]),
3888
+ result: schema2([]),
3889
+ doc: "Rename a table."
3890
+ },
3891
+ {
3892
+ name: "catalog_table_scan_branches_get",
3893
+ key: "catalogTableScanBranchesGet",
3894
+ type: "unary",
3895
+ params: schema2([
3896
+ field2("attach_opaque_data", binary2(), false),
3897
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
3898
+ field2("name", utf82(), false),
3899
+ field2("at_unit", utf82(), true),
3900
+ field2("at_value", utf82(), true),
3901
+ field2("transaction_opaque_data", binary2(), true)
3902
+ ]),
3903
+ result: schema2([
3904
+ field2("result", binary2(), false)
3905
+ ]),
3906
+ doc: "Get the list of scan branches for a multi-branch table. Returns `ScanBranchesResult` as IPC bytes."
3907
+ },
3908
+ {
3909
+ name: "catalog_table_scan_function_get",
3910
+ key: "catalogTableScanFunctionGet",
3911
+ type: "unary",
3912
+ params: schema2([
3913
+ field2("attach_opaque_data", binary2(), false),
3914
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
3915
+ field2("name", utf82(), false),
3916
+ field2("at_unit", utf82(), true),
3917
+ field2("at_value", utf82(), true),
3918
+ field2("transaction_opaque_data", binary2(), true)
3919
+ ]),
3920
+ result: schema2([
3921
+ field2("result", binary2(), false)
3922
+ ]),
3923
+ doc: "Get the scan function for a table. Returns `ScanFunctionResult` as IPC bytes."
3924
+ },
3925
+ {
3926
+ name: "catalog_table_update_function_get",
3927
+ key: "catalogTableUpdateFunctionGet",
3928
+ type: "unary",
3929
+ params: schema2([
3930
+ field2("attach_opaque_data", binary2(), false),
3931
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
3932
+ field2("name", utf82(), false),
3933
+ field2("transaction_opaque_data", binary2(), true)
3934
+ ]),
3935
+ result: schema2([
3936
+ field2("result", binary2(), false)
3937
+ ]),
3938
+ doc: "Get the update function for a table. Returns `WriteFunctionResult` as IPC bytes."
3939
+ },
3940
+ {
3941
+ name: "catalog_transaction_begin",
3942
+ key: "catalogTransactionBegin",
3943
+ type: "unary",
3944
+ params: schema2([
3945
+ field2("attach_opaque_data", binary2(), false)
3946
+ ]),
3947
+ result: schema2([
3948
+ field2("result", binary2(), false)
3949
+ ]),
3950
+ doc: "Begin a new transaction."
3951
+ },
3952
+ {
3953
+ name: "catalog_transaction_commit",
3954
+ key: "catalogTransactionCommit",
3955
+ type: "unary",
3956
+ params: schema2([
3957
+ field2("attach_opaque_data", binary2(), false),
3958
+ field2("transaction_opaque_data", binary2(), false)
3959
+ ]),
3960
+ result: schema2([]),
3961
+ doc: "Commit a transaction."
3962
+ },
3963
+ {
3964
+ name: "catalog_transaction_rollback",
3965
+ key: "catalogTransactionRollback",
3966
+ type: "unary",
3967
+ params: schema2([
3968
+ field2("attach_opaque_data", binary2(), false),
3969
+ field2("transaction_opaque_data", binary2(), false)
3970
+ ]),
3971
+ result: schema2([]),
3972
+ doc: "Rollback a transaction."
3973
+ },
3974
+ {
3975
+ name: "catalog_version",
3976
+ key: "catalogVersion",
3977
+ type: "unary",
3978
+ params: schema2([
3979
+ field2("attach_opaque_data", binary2(), false),
3980
+ field2("transaction_opaque_data", binary2(), true)
3981
+ ]),
3982
+ result: schema2([
3983
+ field2("result", binary2(), false)
3984
+ ]),
3985
+ doc: "Get the current catalog version."
3986
+ },
3987
+ {
3988
+ name: "catalog_view_comment_set",
3989
+ key: "catalogViewCommentSet",
3990
+ type: "unary",
3991
+ params: schema2([
3992
+ field2("attach_opaque_data", binary2(), false),
3993
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
3994
+ field2("name", utf82(), false),
3995
+ field2("comment", utf82(), true),
3996
+ field2("ignore_not_found", bool2(), false),
3997
+ field2("transaction_opaque_data", binary2(), true)
3998
+ ]),
3999
+ result: schema2([]),
4000
+ doc: "Set or clear the comment on a view."
4001
+ },
4002
+ {
4003
+ name: "catalog_view_create",
4004
+ key: "catalogViewCreate",
4005
+ type: "unary",
4006
+ params: schema2([
4007
+ field2("attach_opaque_data", binary2(), false),
4008
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
4009
+ field2("name", utf82(), false),
4010
+ field2("definition", utf82(), false),
4011
+ field2("on_conflict", dictionary2(utf82(), int162()), false),
4012
+ field2("transaction_opaque_data", binary2(), true)
4013
+ ]),
4014
+ result: schema2([]),
4015
+ doc: "Create a new view."
4016
+ },
4017
+ {
4018
+ name: "catalog_view_drop",
4019
+ key: "catalogViewDrop",
4020
+ type: "unary",
4021
+ params: schema2([
4022
+ field2("attach_opaque_data", binary2(), false),
4023
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
4024
+ field2("name", utf82(), false),
4025
+ field2("ignore_not_found", bool2(), false),
4026
+ field2("cascade", bool2(), false),
4027
+ field2("transaction_opaque_data", binary2(), true)
4028
+ ]),
4029
+ result: schema2([]),
4030
+ doc: "Drop a view."
4031
+ },
4032
+ {
4033
+ name: "catalog_view_get",
4034
+ key: "catalogViewGet",
4035
+ type: "unary",
4036
+ params: schema2([
4037
+ field2("attach_opaque_data", binary2(), false),
4038
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
4039
+ field2("name", utf82(), false),
4040
+ field2("transaction_opaque_data", binary2(), true)
4041
+ ]),
4042
+ result: schema2([
4043
+ field2("result", binary2(), false)
4044
+ ]),
4045
+ doc: "Get information about a view. Returns 0 or 1 items."
4046
+ },
4047
+ {
4048
+ name: "catalog_view_rename",
4049
+ key: "catalogViewRename",
4050
+ type: "unary",
4051
+ params: schema2([
4052
+ field2("attach_opaque_data", binary2(), false),
4053
+ field2("schema_path", list2(field2("item", utf82(), true)), false),
4054
+ field2("name", utf82(), false),
4055
+ field2("new_name", utf82(), false),
4056
+ field2("ignore_not_found", bool2(), false),
4057
+ field2("transaction_opaque_data", binary2(), true)
4058
+ ]),
4059
+ result: schema2([]),
4060
+ doc: "Rename a view."
4061
+ },
4062
+ {
4063
+ name: "init",
4064
+ key: "init",
4065
+ type: "stream",
4066
+ params: schema2([
4067
+ field2("request", binary2(), false)
4068
+ ]),
4069
+ header: schema2([
4070
+ field2("execution_id", binary2(), false),
4071
+ field2("opaque_data", binary2(), true),
4072
+ field2("max_workers", int642(), false)
4073
+ ]),
4074
+ doc: "Initialize a function execution and return a processing stream."
4075
+ },
4076
+ {
4077
+ name: "table_buffering_combine",
4078
+ key: "tableBufferingCombine",
4079
+ type: "unary",
4080
+ params: schema2([
4081
+ field2("request", binary2(), false)
4082
+ ]),
4083
+ result: schema2([
4084
+ field2("result", binary2(), false)
4085
+ ]),
4086
+ doc: "Once-per-query end-of-input signal. Returns finalize_state_ids."
4087
+ },
4088
+ {
4089
+ name: "table_buffering_destructor",
4090
+ key: "tableBufferingDestructor",
4091
+ type: "unary",
4092
+ params: schema2([
4093
+ field2("request", binary2(), false)
4094
+ ]),
4095
+ result: schema2([
4096
+ field2("result", binary2(), false)
4097
+ ]),
4098
+ doc: "Best-effort end-of-query cleanup. Must not raise."
4099
+ },
4100
+ {
4101
+ name: "table_buffering_process",
4102
+ key: "tableBufferingProcess",
4103
+ type: "unary",
4104
+ params: schema2([
4105
+ field2("request", binary2(), false)
4106
+ ]),
4107
+ result: schema2([
4108
+ field2("result", binary2(), false)
4109
+ ]),
4110
+ doc: "Sink one input batch; return the worker-chosen state_id."
4111
+ },
4112
+ {
4113
+ name: "table_function_cardinality",
4114
+ key: "tableFunctionCardinality",
4115
+ type: "unary",
4116
+ params: schema2([
4117
+ field2("request", binary2(), false)
4118
+ ]),
4119
+ result: schema2([
4120
+ field2("result", binary2(), false)
4121
+ ]),
4122
+ doc: "Estimate the cardinality of a table function's output."
4123
+ },
4124
+ {
4125
+ name: "table_function_dynamic_to_string",
4126
+ key: "tableFunctionDynamicToString",
4127
+ type: "unary",
4128
+ params: schema2([
4129
+ field2("request", binary2(), false)
4130
+ ]),
4131
+ result: schema2([
4132
+ field2("result", binary2(), false)
4133
+ ]),
4134
+ doc: "Return user-defined diagnostics for EXPLAIN ANALYZE Extra Info."
4135
+ },
4136
+ {
4137
+ name: "table_function_plan",
4138
+ key: "tableFunctionPlan",
4139
+ type: "unary",
4140
+ params: schema2([
4141
+ field2("request", binary2(), false)
4142
+ ]),
4143
+ result: schema2([
4144
+ field2("result", binary2(), false)
4145
+ ]),
4146
+ doc: "Plan a table-function scan into named, independently redeemable splits."
4147
+ },
4148
+ {
4149
+ name: "table_function_statistics",
4150
+ key: "tableFunctionStatistics",
4151
+ type: "unary",
4152
+ params: schema2([
4153
+ field2("request", binary2(), false)
4154
+ ]),
4155
+ result: schema2([
4156
+ field2("result", binary2(), true)
4157
+ ]),
4158
+ doc: "Return per-column statistics for a table function's output."
4159
+ }
4160
+ ];
4161
+ var UNIMPLEMENTED_VGI_SERVICE = Object.freeze({
4162
+ aggregateBind: async () => {
4163
+ throw notImplemented("aggregate_bind");
4164
+ },
4165
+ aggregateCombine: async () => {
4166
+ throw notImplemented("aggregate_combine");
4167
+ },
4168
+ aggregateDestructor: async () => {
4169
+ throw notImplemented("aggregate_destructor");
4170
+ },
4171
+ aggregateFinalize: async () => {
4172
+ throw notImplemented("aggregate_finalize");
4173
+ },
4174
+ aggregateStreamingChunk: async () => {
4175
+ throw notImplemented("aggregate_streaming_chunk");
4176
+ },
4177
+ aggregateStreamingClose: async () => {
4178
+ throw notImplemented("aggregate_streaming_close");
4179
+ },
4180
+ aggregateStreamingOpen: async () => {
4181
+ throw notImplemented("aggregate_streaming_open");
4182
+ },
4183
+ aggregateUpdate: async () => {
4184
+ throw notImplemented("aggregate_update");
4185
+ },
4186
+ aggregateWindow: async () => {
4187
+ throw notImplemented("aggregate_window");
4188
+ },
4189
+ aggregateWindowBatch: async () => {
4190
+ throw notImplemented("aggregate_window_batch");
4191
+ },
4192
+ aggregateWindowDestructor: async () => {
4193
+ throw notImplemented("aggregate_window_destructor");
4194
+ },
4195
+ aggregateWindowInit: async () => {
4196
+ throw notImplemented("aggregate_window_init");
4197
+ },
4198
+ bind: async () => {
4199
+ throw notImplemented("bind");
4200
+ },
4201
+ catalogAttach: async () => {
4202
+ throw notImplemented("catalog_attach");
4203
+ },
4204
+ catalogCatalogs: async () => {
4205
+ throw notImplemented("catalog_catalogs");
4206
+ },
4207
+ catalogContents: async () => {
4208
+ throw notImplemented("catalog_contents");
4209
+ },
4210
+ catalogCopyFromFormats: async () => {
4211
+ throw notImplemented("catalog_copy_from_formats");
4212
+ },
4213
+ catalogCreate: async () => {
4214
+ throw notImplemented("catalog_create");
4215
+ },
4216
+ catalogDetach: async () => {
4217
+ throw notImplemented("catalog_detach");
4218
+ },
4219
+ catalogDrop: async () => {
4220
+ throw notImplemented("catalog_drop");
4221
+ },
4222
+ catalogIndexCreate: async () => {
4223
+ throw notImplemented("catalog_index_create");
4224
+ },
4225
+ catalogIndexDrop: async () => {
4226
+ throw notImplemented("catalog_index_drop");
4227
+ },
4228
+ catalogIndexGet: async () => {
4229
+ throw notImplemented("catalog_index_get");
4230
+ },
4231
+ catalogMacroCreate: async () => {
4232
+ throw notImplemented("catalog_macro_create");
4233
+ },
4234
+ catalogMacroDrop: async () => {
4235
+ throw notImplemented("catalog_macro_drop");
4236
+ },
4237
+ catalogMacroGet: async () => {
4238
+ throw notImplemented("catalog_macro_get");
4239
+ },
4240
+ catalogSchemaContentsFunctions: async () => {
4241
+ throw notImplemented("catalog_schema_contents_functions");
4242
+ },
4243
+ catalogSchemaContentsIndexes: async () => {
4244
+ throw notImplemented("catalog_schema_contents_indexes");
4245
+ },
4246
+ catalogSchemaContentsMacros: async () => {
4247
+ throw notImplemented("catalog_schema_contents_macros");
4248
+ },
4249
+ catalogSchemaContentsTables: async () => {
4250
+ throw notImplemented("catalog_schema_contents_tables");
4251
+ },
4252
+ catalogSchemaContentsViews: async () => {
4253
+ throw notImplemented("catalog_schema_contents_views");
4254
+ },
4255
+ catalogSchemaCreate: async () => {
4256
+ throw notImplemented("catalog_schema_create");
4257
+ },
4258
+ catalogSchemaDrop: async () => {
4259
+ throw notImplemented("catalog_schema_drop");
4260
+ },
4261
+ catalogSchemaGet: async () => {
4262
+ throw notImplemented("catalog_schema_get");
4263
+ },
4264
+ catalogSchemas: async () => {
4265
+ throw notImplemented("catalog_schemas");
4266
+ },
4267
+ catalogTableColumnAdd: async () => {
4268
+ throw notImplemented("catalog_table_column_add");
4269
+ },
4270
+ catalogTableColumnCommentSet: async () => {
4271
+ throw notImplemented("catalog_table_column_comment_set");
4272
+ },
4273
+ catalogTableColumnDefaultDrop: async () => {
4274
+ throw notImplemented("catalog_table_column_default_drop");
4275
+ },
4276
+ catalogTableColumnDefaultSet: async () => {
4277
+ throw notImplemented("catalog_table_column_default_set");
4278
+ },
4279
+ catalogTableColumnDrop: async () => {
4280
+ throw notImplemented("catalog_table_column_drop");
4281
+ },
4282
+ catalogTableColumnRename: async () => {
4283
+ throw notImplemented("catalog_table_column_rename");
4284
+ },
4285
+ catalogTableColumnStatisticsGet: async () => {
4286
+ throw notImplemented("catalog_table_column_statistics_get");
4287
+ },
4288
+ catalogTableColumnTypeChange: async () => {
4289
+ throw notImplemented("catalog_table_column_type_change");
4290
+ },
4291
+ catalogTableCommentSet: async () => {
4292
+ throw notImplemented("catalog_table_comment_set");
4293
+ },
4294
+ catalogTableCreate: async () => {
4295
+ throw notImplemented("catalog_table_create");
4296
+ },
4297
+ catalogTableDeleteFunctionGet: async () => {
4298
+ throw notImplemented("catalog_table_delete_function_get");
4299
+ },
4300
+ catalogTableDrop: async () => {
4301
+ throw notImplemented("catalog_table_drop");
4302
+ },
4303
+ catalogTableGet: async () => {
4304
+ throw notImplemented("catalog_table_get");
4305
+ },
4306
+ catalogTableInsertFunctionGet: async () => {
4307
+ throw notImplemented("catalog_table_insert_function_get");
4308
+ },
4309
+ catalogTableNotNullDrop: async () => {
4310
+ throw notImplemented("catalog_table_not_null_drop");
4311
+ },
4312
+ catalogTableNotNullSet: async () => {
4313
+ throw notImplemented("catalog_table_not_null_set");
4314
+ },
4315
+ catalogTableRename: async () => {
4316
+ throw notImplemented("catalog_table_rename");
4317
+ },
4318
+ catalogTableScanBranchesGet: async () => {
4319
+ throw notImplemented("catalog_table_scan_branches_get");
4320
+ },
4321
+ catalogTableScanFunctionGet: async () => {
4322
+ throw notImplemented("catalog_table_scan_function_get");
4323
+ },
4324
+ catalogTableUpdateFunctionGet: async () => {
4325
+ throw notImplemented("catalog_table_update_function_get");
4326
+ },
4327
+ catalogTransactionBegin: async () => {
4328
+ throw notImplemented("catalog_transaction_begin");
4329
+ },
4330
+ catalogTransactionCommit: async () => {
4331
+ throw notImplemented("catalog_transaction_commit");
4332
+ },
4333
+ catalogTransactionRollback: async () => {
4334
+ throw notImplemented("catalog_transaction_rollback");
4335
+ },
4336
+ catalogVersion: async () => {
4337
+ throw notImplemented("catalog_version");
4338
+ },
4339
+ catalogViewCommentSet: async () => {
4340
+ throw notImplemented("catalog_view_comment_set");
4341
+ },
4342
+ catalogViewCreate: async () => {
4343
+ throw notImplemented("catalog_view_create");
4344
+ },
4345
+ catalogViewDrop: async () => {
4346
+ throw notImplemented("catalog_view_drop");
4347
+ },
4348
+ catalogViewGet: async () => {
4349
+ throw notImplemented("catalog_view_get");
4350
+ },
4351
+ catalogViewRename: async () => {
4352
+ throw notImplemented("catalog_view_rename");
4353
+ },
4354
+ init: unimplementedStream("init"),
4355
+ tableBufferingCombine: async () => {
4356
+ throw notImplemented("table_buffering_combine");
4357
+ },
4358
+ tableBufferingDestructor: async () => {
4359
+ throw notImplemented("table_buffering_destructor");
4360
+ },
4361
+ tableBufferingProcess: async () => {
4362
+ throw notImplemented("table_buffering_process");
4363
+ },
4364
+ tableFunctionCardinality: async () => {
4365
+ throw notImplemented("table_function_cardinality");
4366
+ },
4367
+ tableFunctionDynamicToString: async () => {
4368
+ throw notImplemented("table_function_dynamic_to_string");
4369
+ },
4370
+ tableFunctionPlan: async () => {
4371
+ throw notImplemented("table_function_plan");
4372
+ },
4373
+ tableFunctionStatistics: async () => {
4374
+ throw notImplemented("table_function_statistics");
4375
+ }
4376
+ });
4377
+ function unimplementedMessage(method) {
4378
+ return `${method} is not implemented by this worker`;
4379
+ }
4380
+ function notImplemented(method) {
4381
+ return new MethodNotImplementedError(unimplementedMessage(method));
4382
+ }
4383
+ function unimplementedStream(method) {
4384
+ return producerStream({
4385
+ outputSchema: schema2([]),
4386
+ init: () => {
4387
+ throw notImplemented(method);
4388
+ },
4389
+ produce: () => {}
4390
+ });
4391
+ }
4392
+ function registerVgiService(protocol, service) {
4393
+ for (const m of VGI_V2_METHODS) {
4394
+ if (m.type === "unary") {
4395
+ const handler = service[m.key];
4396
+ protocol.unary(m.name, {
4397
+ params: m.params,
4398
+ result: m.result,
4399
+ doc: m.doc,
4400
+ handler: (params, ctx) => handler.call(service, params, ctx)
4401
+ });
4402
+ continue;
4403
+ }
4404
+ const stream = service[m.key];
4405
+ const common = {
4406
+ params: m.params,
4407
+ outputSchema: stream.outputSchema,
4408
+ headerSchema: m.header ?? undefined,
4409
+ headerInit: stream.headerInit,
4410
+ onCancel: stream.onCancel,
4411
+ doc: m.doc
4412
+ };
4413
+ if (stream.kind === "exchange") {
4414
+ protocol.exchange(m.name, {
4415
+ ...common,
4416
+ inputSchema: stream.inputSchema,
4417
+ init: stream.init,
4418
+ exchange: stream.exchange
4419
+ });
4420
+ } else {
4421
+ protocol.producer(m.name, { ...common, init: stream.init, produce: stream.produce });
4422
+ }
4423
+ }
4424
+ return protocol;
4425
+ }
4426
+ function createVgiProtocol(service) {
4427
+ return registerVgiService(new Protocol(VGI_PROTOCOL_NAME, { protocolVersion: VGI_PROTOCOL_VERSION }), service);
4428
+ }
3178
4429
 
3179
4430
  // src/util/statistics.ts
3180
4431
  function serializeColumnStatistics(stats, _cacheMaxAgeSeconds) {
@@ -4170,9 +5421,6 @@ var RESULT_BINARY_SCHEMA = schema2([
4170
5421
  var REQUEST_PARAMS_SCHEMA = schema2([
4171
5422
  field2("request", binary2(), false)
4172
5423
  ]);
4173
- var RESULT_BINARY_NULLABLE_SCHEMA = schema2([
4174
- field2("result", binary2(), true)
4175
- ]);
4176
5424
  function unwrapRequest(requestBytes) {
4177
5425
  const bytes = toUint8Array(requestBytes);
4178
5426
  const innerBatch = deserializeBatch(bytes);
@@ -5060,20 +6308,16 @@ async function unwrapParamsOpaque(params, ctx, signingKey) {
5060
6308
  }
5061
6309
  }
5062
6310
  }
5063
- function catalogUnary(protocol, signingKey, name, config) {
5064
- protocol.unary(name, {
5065
- params: config.params,
5066
- result: config.result,
5067
- doc: config.doc,
5068
- handler: async (params, ctx) => {
5069
- if (params.request != null && params.attach_opaque_data === undefined && params.name === undefined) {
5070
- params = unwrapRequest(params.request);
5071
- }
5072
- normalizeRequestSchemaPaths(params);
5073
- await unwrapParamsOpaque(params, ctx, signingKey);
5074
- return config.handler(params, ctx);
6311
+ function catalogHandler(signingKey, handler) {
6312
+ return async (wire, ctx) => {
6313
+ let params = wire;
6314
+ if (params.request != null && params.attach_opaque_data === undefined && params.name === undefined) {
6315
+ params = unwrapRequest(params.request);
5075
6316
  }
5076
- });
6317
+ normalizeRequestSchemaPaths(params);
6318
+ await unwrapParamsOpaque(params, ctx, signingKey);
6319
+ return handler(params, ctx);
6320
+ };
5077
6321
  }
5078
6322
  function makeGetCatalog(catalog) {
5079
6323
  return () => {
@@ -5094,7 +6338,6 @@ function decodeOptionsBatch(bytes) {
5094
6338
  const row = iterRows(batch).next().value;
5095
6339
  return row ?? {};
5096
6340
  }
5097
- var emptyResultSchema = schema2([]);
5098
6341
 
5099
6342
  // src/request-auth.ts
5100
6343
  var scope;
@@ -5324,7 +6567,7 @@ async function resolveSplitPayloads(request, innerParams, opts) {
5324
6567
  }));
5325
6568
  }
5326
6569
  }
5327
- function registerFunctionMethods(protocol, config) {
6570
+ function functionHandlers(config) {
5328
6571
  const { registry, signingKey, catalogInterface } = config;
5329
6572
  async function stripAttach(attach, ctx) {
5330
6573
  if (attach == null)
@@ -5343,26 +6586,20 @@ function registerFunctionMethods(protocol, config) {
5343
6586
  }
5344
6587
  return overloadContext({ ...bindCall, attach_opaque_data: attach }, catalogInterface);
5345
6588
  }
5346
- const initHeaderSchema = GLOBAL_INIT_RESPONSE_SCHEMA;
5347
6589
  const emptySchema = schema2([]);
5348
6590
  const dummyInputSchema = schema2([
5349
6591
  field2("_tick", binary2(), true)
5350
6592
  ]);
5351
- protocol.unary("bind", {
5352
- params: BindParamsSchema,
5353
- result: RESULT_BINARY_SCHEMA,
5354
- handler: async (params, ctx) => {
5355
- const innerParams = unwrapRequest(params.request);
5356
- const request = deserializeBindRequest(innerParams);
5357
- request.attach_opaque_data = await stripAttach(request.attach_opaque_data, ctx);
5358
- const func = registry.get(request.function_name, overloadContext(request, catalogInterface));
5359
- const response = await func.bind(request);
5360
- const serialized = serializeBindResponse(response);
5361
- return wrapResult(serialized, BindResultSchema);
5362
- }
5363
- });
5364
- protocol.exchange("init", {
5365
- params: InitParamsSchema,
6593
+ const bind = async (params, ctx) => {
6594
+ const innerParams = unwrapRequest(params.request);
6595
+ const request = deserializeBindRequest(innerParams);
6596
+ request.attach_opaque_data = await stripAttach(request.attach_opaque_data, ctx);
6597
+ const func = registry.get(request.function_name, overloadContext(request, catalogInterface));
6598
+ const response = await func.bind(request);
6599
+ const serialized = serializeBindResponse(response);
6600
+ return wrapResult(serialized, BindResultSchema);
6601
+ };
6602
+ const init = exchangeStream({
5366
6603
  inputSchema: dummyInputSchema,
5367
6604
  outputSchema: emptySchema,
5368
6605
  init: async (params, ctx) => {
@@ -5455,7 +6692,6 @@ function registerFunctionMethods(protocol, config) {
5455
6692
  }
5456
6693
  state.filterHistory = handlerState?.filterHistory ?? null;
5457
6694
  },
5458
- headerSchema: initHeaderSchema,
5459
6695
  headerInit: (params, state, ctx) => {
5460
6696
  if (!state._initResponse) {
5461
6697
  throw new Error("headerInit called on deserialized state: _initResponse not available");
@@ -5463,83 +6699,75 @@ function registerFunctionMethods(protocol, config) {
5463
6699
  return serializeGlobalInitResponse(state._initResponse);
5464
6700
  }
5465
6701
  });
5466
- protocol.unary("table_function_cardinality", {
5467
- params: TableFunctionCardinalityParamsSchema,
5468
- result: RESULT_BINARY_SCHEMA,
5469
- handler: async (params) => {
5470
- const innerParams = unwrapRequest(params.request);
5471
- const request = deserializeCardinalityRequest(innerParams);
5472
- const func = registry.get(request.bind_call.function_name, await strippedContext(request.bind_call));
5473
- let cardResult;
5474
- if (func.cardinality) {
5475
- cardResult = serializeTableCardinality(await func.cardinality(request));
5476
- } else {
5477
- cardResult = { estimate: null, max: null };
5478
- }
5479
- return wrapResult(cardResult, TableFunctionCardinalityResultSchema);
5480
- }
5481
- });
5482
- protocol.unary("table_function_plan", {
5483
- params: TableFunctionPlanParamsSchema,
5484
- result: RESULT_BINARY_SCHEMA,
5485
- handler: async (params, ctx) => {
5486
- const innerParams = unwrapRequest(params.request);
5487
- const request = deserializePlanRequest(innerParams);
5488
- const func = registry.get(request.bind_call.function_name, await strippedContext(request.bind_call));
5489
- const plan = func.plan ? await func.plan(request) : { splits: [{ payload: new Uint8Array(0) }] };
5490
- const fp = fingerprintInputs(toUint8Array(innerParams.bind_call));
5491
- const fingerprint = await bindFingerprint(fp.schemaPath, fp.functionName, fp.args, fp.settings, new Uint8Array(0));
5492
- const anchor = plan.catalogVersion != null ? splitAnchor(plan.catalogVersion) : await liveSplitAnchor(catalogInterface, request.bind_call, ctx?.auth, signingKey) ?? splitAnchor(0);
5493
- const blobs = [];
5494
- for (const split of plan.splits) {
5495
- const token = await buildSplitToken({
5496
- payload: split.payload,
5497
- fingerprint,
5498
- anchor,
5499
- signingKey,
5500
- auth: ctx?.auth
5501
- });
5502
- blobs.push(serializeBatch(batchFromColumns(Object.fromEntries(SCAN_SPLIT_SCHEMA.fields.map((f) => [
5503
- f.name,
5504
- [scanSplitRow(split, token)[f.name] ?? null]
5505
- ])), SCAN_SPLIT_SCHEMA)));
5506
- }
5507
- return wrapResult(planResponseRow(plan, blobs), PLAN_RESPONSE_SCHEMA);
5508
- }
5509
- });
5510
- protocol.unary("table_function_statistics", {
5511
- params: TableFunctionStatisticsParamsSchema,
5512
- result: RESULT_BINARY_NULLABLE_SCHEMA,
5513
- handler: async (params) => {
5514
- const innerParams = unwrapRequest(params.request);
5515
- const request = deserializeCardinalityRequest(innerParams);
5516
- const func = registry.get(request.bind_call.function_name, await strippedContext(request.bind_call));
5517
- if (!func.statistics)
5518
- return { result: null };
5519
- const stats = func.statistics(request);
5520
- if (!stats || stats.length === 0)
5521
- return { result: null };
5522
- return { result: serializeColumnStatistics(stats) };
6702
+ const tableFunctionCardinality = async (params) => {
6703
+ const innerParams = unwrapRequest(params.request);
6704
+ const request = deserializeCardinalityRequest(innerParams);
6705
+ const func = registry.get(request.bind_call.function_name, await strippedContext(request.bind_call));
6706
+ let cardResult;
6707
+ if (func.cardinality) {
6708
+ cardResult = serializeTableCardinality(await func.cardinality(request));
6709
+ } else {
6710
+ cardResult = { estimate: null, max: null };
5523
6711
  }
5524
- });
5525
- protocol.unary("table_function_dynamic_to_string", {
5526
- params: TableFunctionDynamicToStringParamsSchema,
5527
- result: RESULT_BINARY_SCHEMA,
5528
- handler: async (params) => {
5529
- const innerParams = unwrapRequest(params.request);
5530
- const bindCallBytes = toUint8Array(innerParams.bind_call);
5531
- const bindCallBatch = deserializeBatch(bindCallBytes);
5532
- const bindParams = batchToScalarDict(bindCallBatch);
5533
- const bindCall = deserializeBindRequest(bindParams);
5534
- const globalExecutionId = toUint8Array(innerParams.global_execution_id);
5535
- const bindOpaqueData = innerParams.bind_opaque_data ? toUint8Array(innerParams.bind_opaque_data) : null;
5536
- const func = registry.get(bindCall.function_name, await strippedContext(bindCall));
5537
- const map = func.dynamicToString ? await func.dynamicToString({ bindCall, bindOpaqueData, globalExecutionId }) : {};
5538
- const keys = Object.keys(map);
5539
- const values = keys.map((k) => map[k] ?? "");
5540
- return wrapResult({ keys, values }, TableFunctionDynamicToStringResultSchema);
6712
+ return wrapResult(cardResult, TableFunctionCardinalityResultSchema);
6713
+ };
6714
+ const tableFunctionPlan = async (params, ctx) => {
6715
+ const innerParams = unwrapRequest(params.request);
6716
+ const request = deserializePlanRequest(innerParams);
6717
+ const func = registry.get(request.bind_call.function_name, await strippedContext(request.bind_call));
6718
+ const plan = func.plan ? await func.plan(request) : { splits: [{ payload: new Uint8Array(0) }] };
6719
+ const fp = fingerprintInputs(toUint8Array(innerParams.bind_call));
6720
+ const fingerprint = await bindFingerprint(fp.schemaPath, fp.functionName, fp.args, fp.settings, new Uint8Array(0));
6721
+ const anchor = plan.catalogVersion != null ? splitAnchor(plan.catalogVersion) : await liveSplitAnchor(catalogInterface, request.bind_call, ctx?.auth, signingKey) ?? splitAnchor(0);
6722
+ const blobs = [];
6723
+ for (const split of plan.splits) {
6724
+ const token = await buildSplitToken({
6725
+ payload: split.payload,
6726
+ fingerprint,
6727
+ anchor,
6728
+ signingKey,
6729
+ auth: ctx?.auth
6730
+ });
6731
+ blobs.push(serializeBatch(batchFromColumns(Object.fromEntries(SCAN_SPLIT_SCHEMA.fields.map((f) => [
6732
+ f.name,
6733
+ [scanSplitRow(split, token)[f.name] ?? null]
6734
+ ])), SCAN_SPLIT_SCHEMA)));
5541
6735
  }
5542
- });
6736
+ return wrapResult(planResponseRow(plan, blobs), PLAN_RESPONSE_SCHEMA);
6737
+ };
6738
+ const tableFunctionStatistics = async (params) => {
6739
+ const innerParams = unwrapRequest(params.request);
6740
+ const request = deserializeCardinalityRequest(innerParams);
6741
+ const func = registry.get(request.bind_call.function_name, await strippedContext(request.bind_call));
6742
+ if (!func.statistics)
6743
+ return { result: null };
6744
+ const stats = func.statistics(request);
6745
+ if (!stats || stats.length === 0)
6746
+ return { result: null };
6747
+ return { result: serializeColumnStatistics(stats) };
6748
+ };
6749
+ const tableFunctionDynamicToString = async (params) => {
6750
+ const innerParams = unwrapRequest(params.request);
6751
+ const bindCallBytes = toUint8Array(innerParams.bind_call);
6752
+ const bindCallBatch = deserializeBatch(bindCallBytes);
6753
+ const bindParams = batchToScalarDict(bindCallBatch);
6754
+ const bindCall = deserializeBindRequest(bindParams);
6755
+ const globalExecutionId = toUint8Array(innerParams.global_execution_id);
6756
+ const bindOpaqueData = innerParams.bind_opaque_data ? toUint8Array(innerParams.bind_opaque_data) : null;
6757
+ const func = registry.get(bindCall.function_name, await strippedContext(bindCall));
6758
+ const map = func.dynamicToString ? await func.dynamicToString({ bindCall, bindOpaqueData, globalExecutionId }) : {};
6759
+ const keys = Object.keys(map);
6760
+ const values = keys.map((k) => map[k] ?? "");
6761
+ return wrapResult({ keys, values }, TableFunctionDynamicToStringResultSchema);
6762
+ };
6763
+ return {
6764
+ bind,
6765
+ init,
6766
+ tableFunctionCardinality,
6767
+ tableFunctionPlan,
6768
+ tableFunctionStatistics,
6769
+ tableFunctionDynamicToString
6770
+ };
5543
6771
  }
5544
6772
 
5545
6773
  // src/arguments/argument-spec.ts
@@ -5710,7 +6938,7 @@ function persistGroupStates(executionId, gids) {
5710
6938
  }
5711
6939
 
5712
6940
  // src/protocol/handlers/aggregate.ts
5713
- function registerAggregateMethods(protocol, registry) {
6941
+ function aggregateHandlers(registry) {
5714
6942
  function resolveAggregate(name, schemaPath) {
5715
6943
  const func = registry.get(name, {
5716
6944
  arguments: new Arguments,
@@ -5723,199 +6951,180 @@ function registerAggregateMethods(protocol, registry) {
5723
6951
  }
5724
6952
  return func.aggregateConfig;
5725
6953
  }
5726
- protocol.unary("aggregate_bind", {
5727
- params: AggregateBindParamsSchema,
5728
- result: RESULT_BINARY_SCHEMA,
5729
- handler: async (params) => {
5730
- const innerParams = unwrapRequest(params.request);
5731
- const functionName = innerParams.function_name;
5732
- const cfg = resolveAggregate(functionName, innerParams.schema_path ?? null);
5733
- const argBytes = toUint8Array(innerParams.arguments);
5734
- const args = deserializeArguments(argBytes);
5735
- const inputSchema = innerParams.input_schema ? deserializeSchema(toUint8Array(innerParams.input_schema)) : null;
5736
- const secretsBytes = innerParams.secrets ? toUint8Array(innerParams.secrets) : null;
5737
- const secretsBatch = secretsBytes && secretsBytes.length > 0 ? deserializeBatch(secretsBytes) : null;
5738
- const secrets = secretsBatch ? batchToSecretDict(secretsBatch) : {};
5739
- const bindParams = {
5740
- args: extractArgMap(cfg, args),
5741
- arguments: args,
5742
- inputSchema,
5743
- settings: {},
5744
- secrets,
5745
- argumentNames: innerParams.argument_names ? (Array.isArray(innerParams.argument_names) ? innerParams.argument_names : [...innerParams.argument_names]).map((value) => value == null ? null : String(value)) : null
5746
- };
5747
- const executionId = new Uint8Array(16);
5748
- crypto.getRandomValues(executionId);
5749
- setExecutionState(executionId, {
5750
- states: new Map,
5751
- bindArgs: args,
5752
- bindParams
5753
- });
5754
- const outType = cfg.onBind ? await cfg.onBind(bindParams) : cfg.outputType;
5755
- const outSchema = schema2([field2("result", outType, true)]);
5756
- return wrapResult({ output_schema: serializeSchema(outSchema), execution_id: executionId }, AggregateBindResultSchema);
5757
- }
5758
- });
5759
- protocol.unary("aggregate_update", {
5760
- params: AggregateUpdateParamsSchema,
5761
- result: RESULT_BINARY_SCHEMA,
5762
- handler: (params) => {
5763
- const innerParams = unwrapRequest(params.request);
5764
- const functionName = innerParams.function_name;
5765
- const executionId = toUint8Array(innerParams.execution_id);
5766
- const cfg = resolveAggregate(functionName, innerParams.schema_path ?? null);
5767
- const batch = readSingleBatch(toUint8Array(innerParams.input_batch));
5768
- if (!batch || batch.numRows === 0)
5769
- return wrapResult({}, schema2([]));
5770
- const gidIdx = batch.schema.fields.findIndex((f) => f.name === GROUP_COLUMN_NAME);
5771
- if (gidIdx < 0) {
5772
- throw new Error(`aggregate_update: input batch missing ${GROUP_COLUMN_NAME} column`);
5773
- }
5774
- const gidCol = batch.getChildAt(gidIdx);
5775
- const groupIds = [];
5776
- const uniqueGids = new Set;
5777
- for (let i = 0;i < batch.numRows; i++) {
5778
- const v = gidCol.get(i);
5779
- const g = typeof v === "bigint" ? v : BigInt(v);
5780
- groupIds.push(g);
5781
- uniqueGids.add(g);
5782
- }
5783
- const exec = getExecutionState(executionId, uniqueGids);
5784
- if (!exec) {
5785
- throw new Error(`aggregate_update: unknown execution_id for '${functionName}' (bind missing or state dropped)`);
5786
- }
5787
- const columns = [];
5788
- for (let i = 0;i < batch.schema.fields.length; i++) {
5789
- if (i === gidIdx)
5790
- continue;
5791
- columns.push(batch.getChildAt(i));
5792
- }
5793
- const ensureState = (gid) => {
5794
- let s = exec.states.get(gid);
5795
- if (s === undefined) {
5796
- s = cfg.initialState(exec.bindParams);
5797
- exec.states.set(gid, s);
5798
- }
5799
- return s;
5800
- };
5801
- cfg.update({
5802
- states: exec.states,
5803
- groupIds,
5804
- columns,
5805
- args: exec.bindParams.args,
5806
- ensureState
5807
- });
5808
- persistGroupStates(executionId, uniqueGids);
6954
+ const aggregateBind = async (params) => {
6955
+ const innerParams = unwrapRequest(params.request);
6956
+ const functionName = innerParams.function_name;
6957
+ const cfg = resolveAggregate(functionName, innerParams.schema_path ?? null);
6958
+ const argBytes = toUint8Array(innerParams.arguments);
6959
+ const args = deserializeArguments(argBytes);
6960
+ const inputSchema = innerParams.input_schema ? deserializeSchema(toUint8Array(innerParams.input_schema)) : null;
6961
+ const secretsBytes = innerParams.secrets ? toUint8Array(innerParams.secrets) : null;
6962
+ const secretsBatch = secretsBytes && secretsBytes.length > 0 ? deserializeBatch(secretsBytes) : null;
6963
+ const secrets = secretsBatch ? batchToSecretDict(secretsBatch) : {};
6964
+ const bindParams = {
6965
+ args: extractArgMap(cfg, args),
6966
+ arguments: args,
6967
+ inputSchema,
6968
+ settings: {},
6969
+ secrets,
6970
+ argumentNames: innerParams.argument_names ? (Array.isArray(innerParams.argument_names) ? innerParams.argument_names : [...innerParams.argument_names]).map((value) => value == null ? null : String(value)) : null
6971
+ };
6972
+ const executionId = new Uint8Array(16);
6973
+ crypto.getRandomValues(executionId);
6974
+ setExecutionState(executionId, {
6975
+ states: new Map,
6976
+ bindArgs: args,
6977
+ bindParams
6978
+ });
6979
+ const outType = cfg.onBind ? await cfg.onBind(bindParams) : cfg.outputType;
6980
+ const outSchema = schema2([field2("result", outType, true)]);
6981
+ return wrapResult({ output_schema: serializeSchema(outSchema), execution_id: executionId }, AggregateBindResultSchema);
6982
+ };
6983
+ const aggregateUpdate = (params) => {
6984
+ const innerParams = unwrapRequest(params.request);
6985
+ const functionName = innerParams.function_name;
6986
+ const executionId = toUint8Array(innerParams.execution_id);
6987
+ const cfg = resolveAggregate(functionName, innerParams.schema_path ?? null);
6988
+ const batch = readSingleBatch(toUint8Array(innerParams.input_batch));
6989
+ if (!batch || batch.numRows === 0)
5809
6990
  return wrapResult({}, schema2([]));
6991
+ const gidIdx = batch.schema.fields.findIndex((f) => f.name === GROUP_COLUMN_NAME);
6992
+ if (gidIdx < 0) {
6993
+ throw new Error(`aggregate_update: input batch missing ${GROUP_COLUMN_NAME} column`);
6994
+ }
6995
+ const gidCol = batch.getChildAt(gidIdx);
6996
+ const groupIds = [];
6997
+ const uniqueGids = new Set;
6998
+ for (let i = 0;i < batch.numRows; i++) {
6999
+ const v = gidCol.get(i);
7000
+ const g = typeof v === "bigint" ? v : BigInt(v);
7001
+ groupIds.push(g);
7002
+ uniqueGids.add(g);
7003
+ }
7004
+ const exec = getExecutionState(executionId, uniqueGids);
7005
+ if (!exec) {
7006
+ throw new Error(`aggregate_update: unknown execution_id for '${functionName}' (bind missing or state dropped)`);
7007
+ }
7008
+ const columns = [];
7009
+ for (let i = 0;i < batch.schema.fields.length; i++) {
7010
+ if (i === gidIdx)
7011
+ continue;
7012
+ columns.push(batch.getChildAt(i));
5810
7013
  }
5811
- });
5812
- protocol.unary("aggregate_combine", {
5813
- params: AggregateCombineParamsSchema,
5814
- result: RESULT_BINARY_SCHEMA,
5815
- handler: (params) => {
5816
- const innerParams = unwrapRequest(params.request);
5817
- const functionName = innerParams.function_name;
5818
- const executionId = toUint8Array(innerParams.execution_id);
5819
- const cfg = resolveAggregate(functionName, innerParams.schema_path ?? null);
5820
- const batch = readSingleBatch(toUint8Array(innerParams.merge_batch));
5821
- if (!batch || batch.numRows === 0)
5822
- return wrapResult({}, schema2([]));
5823
- const srcCol = batch.getChild("source_group_id");
5824
- const tgtCol = batch.getChild("target_group_id");
5825
- const referencedGids = new Set;
5826
- const srcIds = [];
5827
- const tgtIds = [];
5828
- for (let i = 0;i < batch.numRows; i++) {
5829
- const src = BigInt(srcCol.get(i));
5830
- const tgt = BigInt(tgtCol.get(i));
5831
- srcIds.push(src);
5832
- tgtIds.push(tgt);
5833
- referencedGids.add(src);
5834
- referencedGids.add(tgt);
5835
- }
5836
- const exec = getExecutionState(executionId, referencedGids);
5837
- if (!exec) {
5838
- throw new Error(`aggregate_combine: unknown execution_id for '${functionName}' ` + `(context missing on disk \u2014 bind may have failed or been cleaned up)`);
5839
- }
5840
- const touchedTargets = new Set;
5841
- for (let i = 0;i < batch.numRows; i++) {
5842
- const src = srcIds[i];
5843
- const tgt = tgtIds[i];
5844
- const srcHas = exec.states.has(src);
5845
- const tgtHas = exec.states.has(tgt);
5846
- if (!srcHas && !tgtHas)
5847
- continue;
5848
- const srcState = srcHas ? exec.states.get(src) : cfg.initialState(exec.bindParams);
5849
- const tgtState = tgtHas ? exec.states.get(tgt) : cfg.initialState(exec.bindParams);
5850
- exec.states.set(tgt, cfg.combine(srcState, tgtState, exec.bindParams));
5851
- touchedTargets.add(tgt);
7014
+ const ensureState = (gid) => {
7015
+ let s = exec.states.get(gid);
7016
+ if (s === undefined) {
7017
+ s = cfg.initialState(exec.bindParams);
7018
+ exec.states.set(gid, s);
5852
7019
  }
5853
- persistGroupStates(executionId, touchedTargets);
7020
+ return s;
7021
+ };
7022
+ cfg.update({
7023
+ states: exec.states,
7024
+ groupIds,
7025
+ columns,
7026
+ args: exec.bindParams.args,
7027
+ ensureState
7028
+ });
7029
+ persistGroupStates(executionId, uniqueGids);
7030
+ return wrapResult({}, schema2([]));
7031
+ };
7032
+ const aggregateCombine = (params) => {
7033
+ const innerParams = unwrapRequest(params.request);
7034
+ const functionName = innerParams.function_name;
7035
+ const executionId = toUint8Array(innerParams.execution_id);
7036
+ const cfg = resolveAggregate(functionName, innerParams.schema_path ?? null);
7037
+ const batch = readSingleBatch(toUint8Array(innerParams.merge_batch));
7038
+ if (!batch || batch.numRows === 0)
5854
7039
  return wrapResult({}, schema2([]));
7040
+ const srcCol = batch.getChild("source_group_id");
7041
+ const tgtCol = batch.getChild("target_group_id");
7042
+ const referencedGids = new Set;
7043
+ const srcIds = [];
7044
+ const tgtIds = [];
7045
+ for (let i = 0;i < batch.numRows; i++) {
7046
+ const src = BigInt(srcCol.get(i));
7047
+ const tgt = BigInt(tgtCol.get(i));
7048
+ srcIds.push(src);
7049
+ tgtIds.push(tgt);
7050
+ referencedGids.add(src);
7051
+ referencedGids.add(tgt);
7052
+ }
7053
+ const exec = getExecutionState(executionId, referencedGids);
7054
+ if (!exec) {
7055
+ throw new Error(`aggregate_combine: unknown execution_id for '${functionName}' ` + `(context missing on disk \u2014 bind may have failed or been cleaned up)`);
7056
+ }
7057
+ const touchedTargets = new Set;
7058
+ for (let i = 0;i < batch.numRows; i++) {
7059
+ const src = srcIds[i];
7060
+ const tgt = tgtIds[i];
7061
+ const srcHas = exec.states.has(src);
7062
+ const tgtHas = exec.states.has(tgt);
7063
+ if (!srcHas && !tgtHas)
7064
+ continue;
7065
+ const srcState = srcHas ? exec.states.get(src) : cfg.initialState(exec.bindParams);
7066
+ const tgtState = tgtHas ? exec.states.get(tgt) : cfg.initialState(exec.bindParams);
7067
+ exec.states.set(tgt, cfg.combine(srcState, tgtState, exec.bindParams));
7068
+ touchedTargets.add(tgt);
5855
7069
  }
5856
- });
5857
- protocol.unary("aggregate_finalize", {
5858
- params: AggregateFinalizeParamsSchema,
5859
- result: RESULT_BINARY_SCHEMA,
5860
- handler: (params) => {
5861
- const innerParams = unwrapRequest(params.request);
5862
- const functionName = innerParams.function_name;
5863
- const executionId = toUint8Array(innerParams.execution_id);
5864
- const cfg = resolveAggregate(functionName, innerParams.schema_path ?? null);
5865
- const outputSchema = deserializeSchema(toUint8Array(innerParams.output_schema));
5866
- const gidBatch = readSingleBatch(toUint8Array(innerParams.group_ids_batch));
5867
- const groupIds = [];
5868
- const uniqueGids = new Set;
5869
- if (gidBatch) {
5870
- const col = gidBatch.getChild("group_id");
5871
- for (let i = 0;i < gidBatch.numRows; i++) {
5872
- const v = col.get(i);
5873
- const g = typeof v === "bigint" ? v : BigInt(v);
5874
- groupIds.push(g);
5875
- uniqueGids.add(g);
5876
- }
5877
- }
5878
- const exec = getExecutionState(executionId, uniqueGids);
5879
- if (!exec) {
5880
- throw new Error(`aggregate_finalize: unknown execution_id for '${functionName}'`);
5881
- }
5882
- const states = new Map;
5883
- for (const gid of groupIds) {
5884
- states.set(gid, exec.states.has(gid) ? exec.states.get(gid) : null);
5885
- }
5886
- const resultBatch = cfg.finalize({
5887
- groupIds,
5888
- states,
5889
- outputSchema,
5890
- args: exec.bindParams.args
5891
- });
5892
- return wrapResult({ result_batch: serializeBatchWithSchema(resultBatch) }, AggregateFinalizeResultSchema);
5893
- }
5894
- });
5895
- protocol.unary("aggregate_destructor", {
5896
- params: AggregateDestructorParamsSchema,
5897
- result: RESULT_BINARY_SCHEMA,
5898
- handler: (params) => {
5899
- const innerParams = unwrapRequest(params.request);
5900
- const executionId = toUint8Array(innerParams.execution_id);
5901
- const exec = getExecutionState(executionId);
5902
- if (!exec)
5903
- return wrapResult({}, schema2([]));
5904
- const gidBatch = readSingleBatch(toUint8Array(innerParams.group_ids_batch));
5905
- if (!gidBatch || gidBatch.numRows === 0)
5906
- return wrapResult({}, schema2([]));
7070
+ persistGroupStates(executionId, touchedTargets);
7071
+ return wrapResult({}, schema2([]));
7072
+ };
7073
+ const aggregateFinalize = (params) => {
7074
+ const innerParams = unwrapRequest(params.request);
7075
+ const functionName = innerParams.function_name;
7076
+ const executionId = toUint8Array(innerParams.execution_id);
7077
+ const cfg = resolveAggregate(functionName, innerParams.schema_path ?? null);
7078
+ const outputSchema = deserializeSchema(toUint8Array(innerParams.output_schema));
7079
+ const gidBatch = readSingleBatch(toUint8Array(innerParams.group_ids_batch));
7080
+ const groupIds = [];
7081
+ const uniqueGids = new Set;
7082
+ if (gidBatch) {
5907
7083
  const col = gidBatch.getChild("group_id");
5908
- const toDrop = new Set;
5909
7084
  for (let i = 0;i < gidBatch.numRows; i++) {
5910
7085
  const v = col.get(i);
5911
7086
  const g = typeof v === "bigint" ? v : BigInt(v);
5912
- exec.states.delete(g);
5913
- toDrop.add(g);
7087
+ groupIds.push(g);
7088
+ uniqueGids.add(g);
5914
7089
  }
5915
- persistGroupStates(executionId, toDrop);
5916
- return wrapResult({}, schema2([]));
5917
7090
  }
5918
- });
7091
+ const exec = getExecutionState(executionId, uniqueGids);
7092
+ if (!exec) {
7093
+ throw new Error(`aggregate_finalize: unknown execution_id for '${functionName}'`);
7094
+ }
7095
+ const states = new Map;
7096
+ for (const gid of groupIds) {
7097
+ states.set(gid, exec.states.has(gid) ? exec.states.get(gid) : null);
7098
+ }
7099
+ const resultBatch = cfg.finalize({
7100
+ groupIds,
7101
+ states,
7102
+ outputSchema,
7103
+ args: exec.bindParams.args
7104
+ });
7105
+ return wrapResult({ result_batch: serializeBatchWithSchema(resultBatch) }, AggregateFinalizeResultSchema);
7106
+ };
7107
+ const aggregateDestructor = (params) => {
7108
+ const innerParams = unwrapRequest(params.request);
7109
+ const executionId = toUint8Array(innerParams.execution_id);
7110
+ const exec = getExecutionState(executionId);
7111
+ if (!exec)
7112
+ return wrapResult({}, schema2([]));
7113
+ const gidBatch = readSingleBatch(toUint8Array(innerParams.group_ids_batch));
7114
+ if (!gidBatch || gidBatch.numRows === 0)
7115
+ return wrapResult({}, schema2([]));
7116
+ const col = gidBatch.getChild("group_id");
7117
+ const toDrop = new Set;
7118
+ for (let i = 0;i < gidBatch.numRows; i++) {
7119
+ const v = col.get(i);
7120
+ const g = typeof v === "bigint" ? v : BigInt(v);
7121
+ exec.states.delete(g);
7122
+ toDrop.add(g);
7123
+ }
7124
+ persistGroupStates(executionId, toDrop);
7125
+ return wrapResult({}, schema2([]));
7126
+ };
7127
+ return { aggregateBind, aggregateUpdate, aggregateCombine, aggregateFinalize, aggregateDestructor };
5919
7128
  }
5920
7129
  function extractArgMap(cfg, args) {
5921
7130
  const out = {};
@@ -6006,7 +7215,7 @@ function splitLenPrefixed(buf, count) {
6006
7215
  }
6007
7216
 
6008
7217
  // src/protocol/handlers/table-buffering.ts
6009
- function registerTableBufferingMethods(protocol, registry, signingKey) {
7218
+ function tableBufferingHandlers(registry, signingKey) {
6010
7219
  function resolveBuffering(name, schemaPath) {
6011
7220
  const func = registry.get(name, {
6012
7221
  arguments: new Arguments,
@@ -6051,55 +7260,44 @@ function registerTableBufferingMethods(protocol, registry, signingKey) {
6051
7260
  };
6052
7261
  return { func, params };
6053
7262
  }
6054
- protocol.unary("table_buffering_process", {
6055
- params: TableBufferingProcessParamsSchema,
6056
- result: RESULT_BINARY_SCHEMA,
6057
- handler: async (rpcParams, ctx) => {
6058
- const inner = unwrapRequest(rpcParams.request);
6059
- const clientLog = makeClientLog(ctx);
6060
- const { func, params } = await loadParams(inner, clientLog, ctx);
6061
- if (inner.batch_index != null) {
6062
- params.batchIndex = Number(inner.batch_index);
6063
- }
6064
- const batch = deserializeBatch(toUint8Array(inner.input_batch));
6065
- const stateId = await func.bufferingConfig.process(batch, params);
6066
- if (!(stateId instanceof Uint8Array)) {
6067
- throw new Error(`${func.meta.name}.process() must return Uint8Array (the opaque state_id)`);
6068
- }
6069
- return wrapResult({ state_id: stateId }, TableBufferingProcessResultSchema);
7263
+ const tableBufferingProcess = async (rpcParams, ctx) => {
7264
+ const inner = unwrapRequest(rpcParams.request);
7265
+ const clientLog = makeClientLog(ctx);
7266
+ const { func, params } = await loadParams(inner, clientLog, ctx);
7267
+ if (inner.batch_index != null) {
7268
+ params.batchIndex = Number(inner.batch_index);
6070
7269
  }
6071
- });
6072
- protocol.unary("table_buffering_combine", {
6073
- params: TableBufferingCombineParamsSchema,
6074
- result: RESULT_BINARY_SCHEMA,
6075
- handler: async (rpcParams, ctx) => {
6076
- const inner = unwrapRequest(rpcParams.request);
6077
- const clientLog = makeClientLog(ctx);
6078
- const { func, params } = await loadParams(inner, clientLog, ctx);
6079
- const stateIds = decodeBytesList(inner.state_ids);
6080
- const finalizeStateIds = await func.bufferingConfig.combine(stateIds, params);
6081
- const out = finalizeStateIds.map((fid, i) => {
6082
- if (!(fid instanceof Uint8Array)) {
6083
- throw new Error(`${func.meta.name}.combine() returned non-Uint8Array finalize_state_id at index ${i}`);
6084
- }
6085
- return fid;
6086
- });
6087
- return wrapResult({ finalize_state_ids: out }, TableBufferingCombineResultSchema);
7270
+ const batch = deserializeBatch(toUint8Array(inner.input_batch));
7271
+ const stateId = await func.bufferingConfig.process(batch, params);
7272
+ if (!(stateId instanceof Uint8Array)) {
7273
+ throw new Error(`${func.meta.name}.process() must return Uint8Array (the opaque state_id)`);
6088
7274
  }
6089
- });
6090
- protocol.unary("table_buffering_destructor", {
6091
- params: TableBufferingDestructorParamsSchema,
6092
- result: RESULT_BINARY_SCHEMA,
6093
- handler: async (rpcParams) => {
6094
- try {
6095
- const inner = unwrapRequest(rpcParams.request);
6096
- const executionId = toUint8Array(inner.execution_id);
6097
- const bound = new BoundStorage(storage, executionId);
6098
- await bound.executionClear();
6099
- } catch {}
6100
- return wrapResult({}, TableBufferingDestructorResultSchema);
6101
- }
6102
- });
7275
+ return wrapResult({ state_id: stateId }, TableBufferingProcessResultSchema);
7276
+ };
7277
+ const tableBufferingCombine = async (rpcParams, ctx) => {
7278
+ const inner = unwrapRequest(rpcParams.request);
7279
+ const clientLog = makeClientLog(ctx);
7280
+ const { func, params } = await loadParams(inner, clientLog, ctx);
7281
+ const stateIds = decodeBytesList(inner.state_ids);
7282
+ const finalizeStateIds = await func.bufferingConfig.combine(stateIds, params);
7283
+ const out = finalizeStateIds.map((fid, i) => {
7284
+ if (!(fid instanceof Uint8Array)) {
7285
+ throw new Error(`${func.meta.name}.combine() returned non-Uint8Array finalize_state_id at index ${i}`);
7286
+ }
7287
+ return fid;
7288
+ });
7289
+ return wrapResult({ finalize_state_ids: out }, TableBufferingCombineResultSchema);
7290
+ };
7291
+ const tableBufferingDestructor = async (rpcParams) => {
7292
+ try {
7293
+ const inner = unwrapRequest(rpcParams.request);
7294
+ const executionId = toUint8Array(inner.execution_id);
7295
+ const bound = new BoundStorage(storage, executionId);
7296
+ await bound.executionClear();
7297
+ } catch {}
7298
+ return wrapResult({}, TableBufferingDestructorResultSchema);
7299
+ };
7300
+ return { tableBufferingProcess, tableBufferingCombine, tableBufferingDestructor };
6103
7301
  }
6104
7302
  function makeClientLog(ctx) {
6105
7303
  if (ctx && typeof ctx.clientLog === "function") {
@@ -6415,7 +7613,7 @@ var encodeCopyFromFormatInfo = (v) => encodeASD(CopyFromFormatInfoSchema, {
6415
7613
 
6416
7614
  // src/attach-ticket.ts
6417
7615
  import {
6418
- Protocol,
7616
+ Protocol as Protocol2,
6419
7617
  badRequest,
6420
7618
  errorInfo,
6421
7619
  preconditionFailure
@@ -6871,7 +8069,7 @@ async function sealAttach2(config, request, auth) {
6871
8069
  return { ticket: token, expires_at: expiresAt === 0 ? Number.POSITIVE_INFINITY : expiresAt };
6872
8070
  }
6873
8071
  function buildAttachTicketsProtocol(config) {
6874
- const p = new Protocol(ATTACH_TICKETS_PROTOCOL_NAME, { protocolVersion: ATTACH_TICKETS_PROTOCOL_VERSION });
8072
+ const p = new Protocol2(ATTACH_TICKETS_PROTOCOL_NAME, { protocolVersion: ATTACH_TICKETS_PROTOCOL_VERSION });
6875
8073
  p.unary("seal_attach", {
6876
8074
  params: REQUEST_PARAMS_SCHEMA,
6877
8075
  result: RESULT_BINARY_SCHEMA,
@@ -6887,503 +8085,369 @@ function buildAttachTicketsProtocol(config) {
6887
8085
  }
6888
8086
 
6889
8087
  // src/protocol/handlers/catalog/admin.ts
6890
- function registerCatalogAdminMethods(protocol, getCatalog, signingKey) {
6891
- catalogUnary(protocol, signingKey, "catalog_catalogs", {
6892
- params: CatalogCatalogsParamsSchema,
6893
- result: RESULT_BINARY_SCHEMA,
6894
- handler: async () => {
6895
- const cat = getCatalog();
6896
- const infos = cat.catalogsInfo ? await cat.catalogsInfo() : cat.catalogs().map((name) => ({
6897
- name,
6898
- implementation_version: null,
6899
- data_version_spec: null,
6900
- attach_option_specs: [],
6901
- releases: []
6902
- }));
6903
- const items = infos.map((info) => encodeCatalogInfo(info));
6904
- return wrapResult({ items }, CatalogCatalogsResultSchema);
6905
- }
6906
- });
6907
- protocol.unary("catalog_attach", {
6908
- params: CatalogAttachParamsSchema,
6909
- result: RESULT_BINARY_SCHEMA,
6910
- handler: async (params, ctx) => {
6911
- const innerParams = unwrapRequest(params.request);
6912
- const cat = getCatalog();
6913
- let optionsDict = decodeOptionsBatch(innerParams.options);
6914
- const restored = await redeemAttachTicket(optionsDict, signingKey, ctx?.auth ?? currentRequestAuth());
6915
- if (restored !== null) {
6916
- innerParams.name = restored.name;
6917
- innerParams.options = restored.optionsIpc;
6918
- innerParams.data_version_spec = restored.dataVersionSpec;
6919
- innerParams.implementation_version = restored.implementationVersion;
6920
- optionsDict = restored.options;
6921
- }
6922
- const result = await cat.attach(innerParams.name, optionsDict, innerParams.data_version_spec ?? null, innerParams.implementation_version ?? null);
6923
- const sealedAttach = await sealAttach(toUint8Array(result.attach_opaque_data), ctx?.auth, signingKey);
6924
- return wrapResult(buildCatalogAttachResult({
6925
- ...result,
6926
- attach_opaque_data: sealedAttach,
6927
- supports_column_statistics: result.supports_column_statistics ?? true
6928
- }), CatalogAttachResultSchema);
6929
- }
6930
- });
6931
- catalogUnary(protocol, signingKey, "catalog_detach", {
6932
- params: CatalogDetachParamsSchema,
6933
- result: emptyResultSchema,
6934
- handler: async (params) => {
6935
- const cat = getCatalog();
6936
- await cat.detach(toUint8Array(params.attach_opaque_data));
6937
- return {};
6938
- }
8088
+ function catalogAdminHandlers(getCatalog, signingKey) {
8089
+ const catalogCatalogs = catalogHandler(signingKey, async () => {
8090
+ const cat = getCatalog();
8091
+ const infos = cat.catalogsInfo ? await cat.catalogsInfo() : cat.catalogs().map((name) => ({
8092
+ name,
8093
+ implementation_version: null,
8094
+ data_version_spec: null,
8095
+ attach_option_specs: [],
8096
+ releases: []
8097
+ }));
8098
+ const items = infos.map((info) => encodeCatalogInfo(info));
8099
+ return wrapResult({ items }, CatalogCatalogsResultSchema);
6939
8100
  });
6940
- catalogUnary(protocol, signingKey, "catalog_create", {
6941
- params: CatalogCreateParamsSchema,
6942
- result: emptyResultSchema,
6943
- handler: async (params) => {
6944
- const cat = getCatalog();
6945
- await cat.create(params.name, params.on_conflict, params.options);
6946
- return {};
6947
- }
8101
+ const catalogAttach = async (params, ctx) => {
8102
+ const innerParams = unwrapRequest(params.request);
8103
+ const cat = getCatalog();
8104
+ let optionsDict = decodeOptionsBatch(innerParams.options);
8105
+ const restored = await redeemAttachTicket(optionsDict, signingKey, ctx?.auth ?? currentRequestAuth());
8106
+ if (restored !== null) {
8107
+ innerParams.name = restored.name;
8108
+ innerParams.options = restored.optionsIpc;
8109
+ innerParams.data_version_spec = restored.dataVersionSpec;
8110
+ innerParams.implementation_version = restored.implementationVersion;
8111
+ optionsDict = restored.options;
8112
+ }
8113
+ const result = await cat.attach(innerParams.name, optionsDict, innerParams.data_version_spec ?? null, innerParams.implementation_version ?? null);
8114
+ const sealedAttach = await sealAttach(toUint8Array(result.attach_opaque_data), ctx?.auth, signingKey);
8115
+ return wrapResult(buildCatalogAttachResult({
8116
+ ...result,
8117
+ attach_opaque_data: sealedAttach,
8118
+ supports_column_statistics: result.supports_column_statistics ?? true
8119
+ }), CatalogAttachResultSchema);
8120
+ };
8121
+ const catalogDetach = catalogHandler(signingKey, async (params) => {
8122
+ const cat = getCatalog();
8123
+ await cat.detach(toUint8Array(params.attach_opaque_data));
8124
+ return {};
6948
8125
  });
6949
- catalogUnary(protocol, signingKey, "catalog_drop", {
6950
- params: CatalogDropParamsSchema,
6951
- result: emptyResultSchema,
6952
- handler: async (params) => {
6953
- const cat = getCatalog();
6954
- await cat.drop(params.name);
6955
- return {};
6956
- }
8126
+ const catalogCreate = catalogHandler(signingKey, async (params) => {
8127
+ const cat = getCatalog();
8128
+ await cat.create(params.name, params.on_conflict, params.options);
8129
+ return {};
6957
8130
  });
6958
- catalogUnary(protocol, signingKey, "catalog_version", {
6959
- params: CatalogVersionParamsSchema,
6960
- result: RESULT_BINARY_SCHEMA,
6961
- handler: async (params) => {
6962
- const cat = getCatalog();
6963
- const version = await cat.version(toUint8Array(params.attach_opaque_data), params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
6964
- return wrapResult({ version }, CatalogVersionResultSchema);
6965
- }
8131
+ const catalogDrop = catalogHandler(signingKey, async (params) => {
8132
+ const cat = getCatalog();
8133
+ await cat.drop(params.name);
8134
+ return {};
6966
8135
  });
6967
- protocol.unary("catalog_transaction_begin", {
6968
- params: CatalogTransactionBeginParamsSchema,
6969
- result: RESULT_BINARY_SCHEMA,
6970
- handler: async (params, ctx) => {
6971
- const auth = ctx?.auth;
6972
- const sealedAttach = params.attach_opaque_data != null ? toUint8Array(params.attach_opaque_data) : new Uint8Array(0);
6973
- const attachPlain = await openAttach(sealedAttach, auth, signingKey);
6974
- const cat = getCatalog();
6975
- const txPlain = await cat.transactionBegin(attachPlain);
6976
- const transaction_opaque_data = txPlain != null ? await sealTransaction(toUint8Array(txPlain), sealedAttach, auth, signingKey) : null;
6977
- return wrapResult({ transaction_opaque_data }, CatalogTransactionBeginResultSchema);
6978
- }
8136
+ const catalogVersion = catalogHandler(signingKey, async (params) => {
8137
+ const cat = getCatalog();
8138
+ const version = await cat.version(toUint8Array(params.attach_opaque_data), params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
8139
+ return wrapResult({ version }, CatalogVersionResultSchema);
6979
8140
  });
6980
- catalogUnary(protocol, signingKey, "catalog_transaction_commit", {
6981
- params: CatalogTransactionCommitParamsSchema,
6982
- result: emptyResultSchema,
6983
- handler: async (params) => {
6984
- const cat = getCatalog();
6985
- await cat.transactionCommit(toUint8Array(params.attach_opaque_data), toUint8Array(params.transaction_opaque_data));
6986
- return {};
6987
- }
8141
+ const catalogTransactionBegin = async (params, ctx) => {
8142
+ const auth = ctx?.auth;
8143
+ const sealedAttach = params.attach_opaque_data != null ? toUint8Array(params.attach_opaque_data) : new Uint8Array(0);
8144
+ const attachPlain = await openAttach(sealedAttach, auth, signingKey);
8145
+ const cat = getCatalog();
8146
+ const txPlain = await cat.transactionBegin(attachPlain);
8147
+ const transaction_opaque_data = txPlain != null ? await sealTransaction(toUint8Array(txPlain), sealedAttach, auth, signingKey) : null;
8148
+ return wrapResult({ transaction_opaque_data }, CatalogTransactionBeginResultSchema);
8149
+ };
8150
+ const catalogTransactionCommit = catalogHandler(signingKey, async (params) => {
8151
+ const cat = getCatalog();
8152
+ await cat.transactionCommit(toUint8Array(params.attach_opaque_data), toUint8Array(params.transaction_opaque_data));
8153
+ return {};
6988
8154
  });
6989
- catalogUnary(protocol, signingKey, "catalog_transaction_rollback", {
6990
- params: CatalogTransactionRollbackParamsSchema,
6991
- result: emptyResultSchema,
6992
- handler: async (params) => {
6993
- const cat = getCatalog();
6994
- await cat.transactionRollback(toUint8Array(params.attach_opaque_data), toUint8Array(params.transaction_opaque_data));
6995
- return {};
6996
- }
8155
+ const catalogTransactionRollback = catalogHandler(signingKey, async (params) => {
8156
+ const cat = getCatalog();
8157
+ await cat.transactionRollback(toUint8Array(params.attach_opaque_data), toUint8Array(params.transaction_opaque_data));
8158
+ return {};
6997
8159
  });
6998
- catalogUnary(protocol, signingKey, "catalog_schemas", {
6999
- params: CatalogSchemasParamsSchema,
7000
- result: RESULT_BINARY_SCHEMA,
7001
- handler: async (params) => {
7002
- const cat = getCatalog();
7003
- const schemas = await cat.schemas(toUint8Array(params.attach_opaque_data), params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
7004
- return wrapResult({
7005
- items: schemas.map((s) => encodeSchemaInfo(s))
7006
- }, CatalogSchemasResultSchema);
7007
- }
8160
+ const catalogSchemas = catalogHandler(signingKey, async (params) => {
8161
+ const cat = getCatalog();
8162
+ const schemas = await cat.schemas(toUint8Array(params.attach_opaque_data), params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
8163
+ return wrapResult({
8164
+ items: schemas.map((s) => encodeSchemaInfo(s))
8165
+ }, CatalogSchemasResultSchema);
7008
8166
  });
7009
- catalogUnary(protocol, signingKey, "catalog_contents", {
7010
- params: CatalogContentsParamsSchema,
7011
- result: RESULT_BINARY_SCHEMA,
7012
- handler: async (params) => {
7013
- const ifNoneMatch = params.if_none_match == null ? null : String(params.if_none_match);
7014
- return serveCatalogContents(getCatalog(), toUint8Array(params.attach_opaque_data), ifNoneMatch);
7015
- }
8167
+ const catalogContents = catalogHandler(signingKey, async (params) => {
8168
+ const ifNoneMatch = params.if_none_match == null ? null : String(params.if_none_match);
8169
+ return serveCatalogContents(getCatalog(), toUint8Array(params.attach_opaque_data), ifNoneMatch);
7016
8170
  });
7017
- catalogUnary(protocol, signingKey, "catalog_copy_from_formats", {
7018
- params: CatalogCopyFromFormatsParamsSchema,
7019
- result: RESULT_BINARY_SCHEMA,
7020
- handler: async (params) => {
7021
- const cat = getCatalog();
7022
- const formats = await cat.copyFromFormats(toUint8Array(params.attach_opaque_data), params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
7023
- return wrapResult({
7024
- items: formats.map((f) => encodeCopyFromFormatInfo(f))
7025
- }, CatalogCopyFromFormatsResultSchema);
7026
- }
8171
+ const catalogCopyFromFormats = catalogHandler(signingKey, async (params) => {
8172
+ const cat = getCatalog();
8173
+ const formats = await cat.copyFromFormats(toUint8Array(params.attach_opaque_data), params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
8174
+ return wrapResult({
8175
+ items: formats.map((f) => encodeCopyFromFormatInfo(f))
8176
+ }, CatalogCopyFromFormatsResultSchema);
7027
8177
  });
7028
- catalogUnary(protocol, signingKey, "catalog_schema_get", {
7029
- params: CatalogSchemaGetParamsSchema,
7030
- result: RESULT_BINARY_SCHEMA,
7031
- handler: async (params) => {
7032
- const cat = getCatalog();
7033
- const info = await cat.schemaGet(toUint8Array(params.attach_opaque_data), params.path, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
7034
- return wrapResult({
7035
- items: info ? [encodeSchemaInfo(info)] : []
7036
- }, CatalogSchemaGetResultSchema);
7037
- }
8178
+ const catalogSchemaGet = catalogHandler(signingKey, async (params) => {
8179
+ const cat = getCatalog();
8180
+ const info = await cat.schemaGet(toUint8Array(params.attach_opaque_data), params.path, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
8181
+ return wrapResult({
8182
+ items: info ? [encodeSchemaInfo(info)] : []
8183
+ }, CatalogSchemaGetResultSchema);
7038
8184
  });
7039
- catalogUnary(protocol, signingKey, "catalog_schema_create", {
7040
- params: CatalogSchemaCreateParamsSchema,
7041
- result: emptyResultSchema,
7042
- handler: async (params) => {
7043
- const cat = getCatalog();
7044
- await cat.schemaCreate(toUint8Array(params.attach_opaque_data), params.path, params.comment, null, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
7045
- return {};
7046
- }
8185
+ const catalogSchemaCreate = catalogHandler(signingKey, async (params) => {
8186
+ const cat = getCatalog();
8187
+ await cat.schemaCreate(toUint8Array(params.attach_opaque_data), params.path, params.comment, null, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
8188
+ return {};
7047
8189
  });
7048
- catalogUnary(protocol, signingKey, "catalog_schema_drop", {
7049
- params: CatalogSchemaDropParamsSchema,
7050
- result: emptyResultSchema,
7051
- handler: async (params) => {
7052
- const cat = getCatalog();
7053
- 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);
7054
- return {};
7055
- }
8190
+ const catalogSchemaDrop = catalogHandler(signingKey, async (params) => {
8191
+ const cat = getCatalog();
8192
+ 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);
8193
+ return {};
7056
8194
  });
7057
- catalogUnary(protocol, signingKey, "catalog_schema_contents_tables", {
7058
- params: CatalogSchemaContentsTablesParamsSchema,
7059
- result: RESULT_BINARY_SCHEMA,
7060
- handler: async (params) => {
7061
- const cat = getCatalog();
7062
- const tables = await cat.schemaContentsTables(toUint8Array(params.attach_opaque_data), params.path, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
7063
- return wrapResult({
7064
- items: tables.map((t) => encodeTableInfo(t))
7065
- }, CatalogSchemaContentsTablesResultSchema);
7066
- }
8195
+ const catalogSchemaContentsTables = catalogHandler(signingKey, async (params) => {
8196
+ const cat = getCatalog();
8197
+ const tables = await cat.schemaContentsTables(toUint8Array(params.attach_opaque_data), params.path, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
8198
+ return wrapResult({
8199
+ items: tables.map((t) => encodeTableInfo(t))
8200
+ }, CatalogSchemaContentsTablesResultSchema);
7067
8201
  });
7068
- catalogUnary(protocol, signingKey, "catalog_schema_contents_views", {
7069
- params: CatalogSchemaContentsViewsParamsSchema,
7070
- result: RESULT_BINARY_SCHEMA,
7071
- handler: async (params) => {
7072
- const cat = getCatalog();
7073
- const views = await cat.schemaContentsViews(toUint8Array(params.attach_opaque_data), params.path, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
7074
- return wrapResult({
7075
- items: views.map((v) => encodeViewInfo(v))
7076
- }, CatalogSchemaContentsViewsResultSchema);
7077
- }
8202
+ const catalogSchemaContentsViews = catalogHandler(signingKey, async (params) => {
8203
+ const cat = getCatalog();
8204
+ const views = await cat.schemaContentsViews(toUint8Array(params.attach_opaque_data), params.path, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
8205
+ return wrapResult({
8206
+ items: views.map((v) => encodeViewInfo(v))
8207
+ }, CatalogSchemaContentsViewsResultSchema);
7078
8208
  });
7079
- catalogUnary(protocol, signingKey, "catalog_schema_contents_functions", {
7080
- params: CatalogSchemaContentsFunctionsParamsSchema,
7081
- result: RESULT_BINARY_SCHEMA,
7082
- handler: async (params) => {
7083
- const cat = getCatalog();
7084
- 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);
7085
- return wrapResult({
7086
- items: funcs.map((f) => encodeFunctionInfoOnce(f))
7087
- }, CatalogSchemaContentsFunctionsResultSchema);
7088
- }
8209
+ const catalogSchemaContentsFunctions = catalogHandler(signingKey, async (params) => {
8210
+ const cat = getCatalog();
8211
+ 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);
8212
+ return wrapResult({
8213
+ items: funcs.map((f) => encodeFunctionInfoOnce(f))
8214
+ }, CatalogSchemaContentsFunctionsResultSchema);
7089
8215
  });
8216
+ return {
8217
+ catalogCatalogs,
8218
+ catalogAttach,
8219
+ catalogDetach,
8220
+ catalogCreate,
8221
+ catalogDrop,
8222
+ catalogVersion,
8223
+ catalogTransactionBegin,
8224
+ catalogTransactionCommit,
8225
+ catalogTransactionRollback,
8226
+ catalogSchemas,
8227
+ catalogContents,
8228
+ catalogCopyFromFormats,
8229
+ catalogSchemaGet,
8230
+ catalogSchemaCreate,
8231
+ catalogSchemaDrop,
8232
+ catalogSchemaContentsTables,
8233
+ catalogSchemaContentsViews,
8234
+ catalogSchemaContentsFunctions
8235
+ };
7090
8236
  }
7091
8237
 
7092
8238
  // src/protocol/handlers/catalog/table.ts
7093
- function registerCatalogTableMethods(protocol, getCatalog, signingKey) {
7094
- catalogUnary(protocol, signingKey, "catalog_table_get", {
7095
- params: CatalogTableGetParamsSchema,
7096
- result: RESULT_BINARY_SCHEMA,
7097
- handler: async (params) => {
7098
- const cat = getCatalog();
7099
- 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);
7100
- return wrapResult({
7101
- items: info ? [encodeTableInfo(info)] : []
7102
- }, CatalogTableGetResultSchema);
7103
- }
8239
+ function catalogTableHandlers(getCatalog, signingKey) {
8240
+ const catalogTableGet = catalogHandler(signingKey, async (params) => {
8241
+ const cat = getCatalog();
8242
+ 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);
8243
+ return wrapResult({
8244
+ items: info ? [encodeTableInfo(info)] : []
8245
+ }, CatalogTableGetResultSchema);
7104
8246
  });
7105
- catalogUnary(protocol, signingKey, "catalog_table_create", {
7106
- params: CatalogTableCreateParamsSchema,
7107
- result: emptyResultSchema,
7108
- handler: async (params) => {
7109
- const cat = getCatalog();
7110
- 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);
7111
- return {};
7112
- }
8247
+ const catalogTableCreate = catalogHandler(signingKey, async (params) => {
8248
+ const cat = getCatalog();
8249
+ 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);
8250
+ return {};
7113
8251
  });
7114
- catalogUnary(protocol, signingKey, "catalog_table_drop", {
7115
- params: CatalogTableDropParamsSchema,
7116
- result: emptyResultSchema,
7117
- handler: async (params) => {
7118
- const cat = getCatalog();
7119
- 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);
7120
- return {};
7121
- }
8252
+ const catalogTableDrop = catalogHandler(signingKey, async (params) => {
8253
+ const cat = getCatalog();
8254
+ 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);
8255
+ return {};
7122
8256
  });
7123
- catalogUnary(protocol, signingKey, "catalog_table_column_statistics_get", {
7124
- params: CatalogTableColumnStatisticsGetParamsSchema,
7125
- result: RESULT_BINARY_NULLABLE_SCHEMA,
7126
- handler: async (params) => {
7127
- const cat = getCatalog();
7128
- 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);
7129
- return { result: stats?.bytes ?? null };
7130
- }
8257
+ const catalogTableColumnStatisticsGet = catalogHandler(signingKey, async (params) => {
8258
+ const cat = getCatalog();
8259
+ 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);
8260
+ return { result: stats?.bytes ?? null };
7131
8261
  });
7132
- catalogUnary(protocol, signingKey, "catalog_table_scan_function_get", {
7133
- params: CatalogTableScanFunctionGetParamsSchema,
7134
- result: RESULT_BINARY_SCHEMA,
7135
- handler: async (params) => {
7136
- const cat = getCatalog();
7137
- 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);
7138
- return wrapResult(scanResult, ScanFunctionResultSchema);
7139
- }
8262
+ const catalogTableScanFunctionGet = catalogHandler(signingKey, async (params) => {
8263
+ const cat = getCatalog();
8264
+ 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);
8265
+ return wrapResult(scanResult, ScanFunctionResultSchema);
7140
8266
  });
7141
- catalogUnary(protocol, signingKey, "catalog_table_scan_branches_get", {
7142
- params: CatalogTableScanBranchesGetParamsSchema,
7143
- result: RESULT_BINARY_SCHEMA,
7144
- handler: async (params) => {
7145
- const cat = getCatalog();
7146
- 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);
7147
- return wrapResult(branchesResult, ScanBranchesResultSchema);
7148
- }
8267
+ const catalogTableScanBranchesGet = catalogHandler(signingKey, async (params) => {
8268
+ const cat = getCatalog();
8269
+ 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);
8270
+ return wrapResult(branchesResult, ScanBranchesResultSchema);
7149
8271
  });
7150
- catalogUnary(protocol, signingKey, "catalog_table_comment_set", {
7151
- params: CatalogTableCommentSetParamsSchema,
7152
- result: emptyResultSchema,
7153
- handler: async (params) => {
7154
- const cat = getCatalog();
7155
- 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);
7156
- return {};
7157
- }
8272
+ const catalogTableCommentSet = catalogHandler(signingKey, async (params) => {
8273
+ const cat = getCatalog();
8274
+ 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);
8275
+ return {};
7158
8276
  });
7159
- catalogUnary(protocol, signingKey, "catalog_table_rename", {
7160
- params: CatalogTableRenameParamsSchema,
7161
- result: emptyResultSchema,
7162
- handler: async (params) => {
7163
- const cat = getCatalog();
7164
- 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);
7165
- return {};
7166
- }
8277
+ const catalogTableRename = catalogHandler(signingKey, async (params) => {
8278
+ const cat = getCatalog();
8279
+ 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);
8280
+ return {};
7167
8281
  });
7168
- catalogUnary(protocol, signingKey, "catalog_table_column_add", {
7169
- params: CatalogTableColumnAddParamsSchema,
7170
- result: emptyResultSchema,
7171
- handler: async (params) => {
7172
- const cat = getCatalog();
7173
- 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);
7174
- return {};
7175
- }
8282
+ const catalogTableColumnAdd = catalogHandler(signingKey, async (params) => {
8283
+ const cat = getCatalog();
8284
+ 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);
8285
+ return {};
7176
8286
  });
7177
- catalogUnary(protocol, signingKey, "catalog_table_column_drop", {
7178
- params: CatalogTableColumnDropParamsSchema,
7179
- result: emptyResultSchema,
7180
- handler: async (params) => {
7181
- const cat = getCatalog();
7182
- 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);
7183
- return {};
7184
- }
8287
+ const catalogTableColumnDrop = catalogHandler(signingKey, async (params) => {
8288
+ const cat = getCatalog();
8289
+ 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);
8290
+ return {};
7185
8291
  });
7186
- catalogUnary(protocol, signingKey, "catalog_table_column_rename", {
7187
- params: CatalogTableColumnRenameParamsSchema,
7188
- result: emptyResultSchema,
7189
- handler: async (params) => {
7190
- const cat = getCatalog();
7191
- 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);
7192
- return {};
7193
- }
8292
+ const catalogTableColumnRename = catalogHandler(signingKey, async (params) => {
8293
+ const cat = getCatalog();
8294
+ 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);
8295
+ return {};
7194
8296
  });
7195
- catalogUnary(protocol, signingKey, "catalog_table_column_default_set", {
7196
- params: CatalogTableColumnDefaultSetParamsSchema,
7197
- result: emptyResultSchema,
7198
- handler: async (params) => {
7199
- const cat = getCatalog();
7200
- 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);
7201
- return {};
7202
- }
8297
+ const catalogTableColumnDefaultSet = catalogHandler(signingKey, async (params) => {
8298
+ const cat = getCatalog();
8299
+ 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);
8300
+ return {};
7203
8301
  });
7204
- catalogUnary(protocol, signingKey, "catalog_table_column_default_drop", {
7205
- params: CatalogTableColumnDefaultDropParamsSchema,
7206
- result: emptyResultSchema,
7207
- handler: async (params) => {
7208
- const cat = getCatalog();
7209
- 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);
7210
- return {};
7211
- }
8302
+ const catalogTableColumnDefaultDrop = catalogHandler(signingKey, async (params) => {
8303
+ const cat = getCatalog();
8304
+ 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);
8305
+ return {};
7212
8306
  });
7213
- catalogUnary(protocol, signingKey, "catalog_table_column_type_change", {
7214
- params: CatalogTableColumnTypeChangeParamsSchema,
7215
- result: emptyResultSchema,
7216
- handler: async (params) => {
7217
- const cat = getCatalog();
7218
- 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);
7219
- return {};
7220
- }
8307
+ const catalogTableColumnTypeChange = catalogHandler(signingKey, async (params) => {
8308
+ const cat = getCatalog();
8309
+ 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);
8310
+ return {};
7221
8311
  });
7222
- catalogUnary(protocol, signingKey, "catalog_table_not_null_set", {
7223
- params: CatalogTableNotNullSetParamsSchema,
7224
- result: emptyResultSchema,
7225
- handler: async (params) => {
7226
- const cat = getCatalog();
7227
- 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);
7228
- return {};
7229
- }
8312
+ const catalogTableNotNullSet = catalogHandler(signingKey, async (params) => {
8313
+ const cat = getCatalog();
8314
+ 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);
8315
+ return {};
7230
8316
  });
7231
- catalogUnary(protocol, signingKey, "catalog_table_not_null_drop", {
7232
- params: CatalogTableNotNullDropParamsSchema,
7233
- result: emptyResultSchema,
7234
- handler: async (params) => {
7235
- const cat = getCatalog();
7236
- 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);
7237
- return {};
7238
- }
8317
+ const catalogTableNotNullDrop = catalogHandler(signingKey, async (params) => {
8318
+ const cat = getCatalog();
8319
+ 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);
8320
+ return {};
7239
8321
  });
8322
+ return {
8323
+ catalogTableGet,
8324
+ catalogTableCreate,
8325
+ catalogTableDrop,
8326
+ catalogTableColumnStatisticsGet,
8327
+ catalogTableScanFunctionGet,
8328
+ catalogTableScanBranchesGet,
8329
+ catalogTableCommentSet,
8330
+ catalogTableRename,
8331
+ catalogTableColumnAdd,
8332
+ catalogTableColumnDrop,
8333
+ catalogTableColumnRename,
8334
+ catalogTableColumnDefaultSet,
8335
+ catalogTableColumnDefaultDrop,
8336
+ catalogTableColumnTypeChange,
8337
+ catalogTableNotNullSet,
8338
+ catalogTableNotNullDrop
8339
+ };
7240
8340
  }
7241
8341
 
7242
8342
  // src/protocol/handlers/catalog/view.ts
7243
- function registerCatalogViewMethods(protocol, getCatalog, signingKey) {
7244
- catalogUnary(protocol, signingKey, "catalog_view_get", {
7245
- params: CatalogViewGetParamsSchema,
7246
- result: RESULT_BINARY_SCHEMA,
7247
- handler: async (params) => {
7248
- const cat = getCatalog();
7249
- 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);
7250
- return wrapResult({
7251
- items: info ? [encodeViewInfo(info)] : []
7252
- }, CatalogViewGetResultSchema);
7253
- }
8343
+ function catalogViewHandlers(getCatalog, signingKey) {
8344
+ const catalogViewGet = catalogHandler(signingKey, async (params) => {
8345
+ const cat = getCatalog();
8346
+ 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);
8347
+ return wrapResult({
8348
+ items: info ? [encodeViewInfo(info)] : []
8349
+ }, CatalogViewGetResultSchema);
7254
8350
  });
7255
- catalogUnary(protocol, signingKey, "catalog_view_create", {
7256
- params: CatalogViewCreateParamsSchema,
7257
- result: emptyResultSchema,
7258
- handler: async (params) => {
7259
- const cat = getCatalog();
7260
- 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);
7261
- return {};
7262
- }
8351
+ const catalogViewCreate = catalogHandler(signingKey, async (params) => {
8352
+ const cat = getCatalog();
8353
+ 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);
8354
+ return {};
7263
8355
  });
7264
- catalogUnary(protocol, signingKey, "catalog_view_drop", {
7265
- params: CatalogViewDropParamsSchema,
7266
- result: emptyResultSchema,
7267
- handler: async (params) => {
7268
- const cat = getCatalog();
7269
- 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);
7270
- return {};
7271
- }
8356
+ const catalogViewDrop = catalogHandler(signingKey, async (params) => {
8357
+ const cat = getCatalog();
8358
+ 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);
8359
+ return {};
7272
8360
  });
7273
- catalogUnary(protocol, signingKey, "catalog_view_rename", {
7274
- params: CatalogViewRenameParamsSchema,
7275
- result: emptyResultSchema,
7276
- handler: async (params) => {
7277
- const cat = getCatalog();
7278
- 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);
7279
- return {};
7280
- }
8361
+ const catalogViewRename = catalogHandler(signingKey, async (params) => {
8362
+ const cat = getCatalog();
8363
+ 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);
8364
+ return {};
7281
8365
  });
7282
- catalogUnary(protocol, signingKey, "catalog_view_comment_set", {
7283
- params: CatalogViewCommentSetParamsSchema,
7284
- result: emptyResultSchema,
7285
- handler: async (params) => {
7286
- const cat = getCatalog();
7287
- 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);
7288
- return {};
7289
- }
8366
+ const catalogViewCommentSet = catalogHandler(signingKey, async (params) => {
8367
+ const cat = getCatalog();
8368
+ 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);
8369
+ return {};
7290
8370
  });
8371
+ return { catalogViewGet, catalogViewCreate, catalogViewDrop, catalogViewRename, catalogViewCommentSet };
7291
8372
  }
7292
8373
 
7293
8374
  // src/protocol/handlers/catalog/macro.ts
7294
- function registerCatalogMacroMethods(protocol, getCatalog, signingKey) {
7295
- catalogUnary(protocol, signingKey, "catalog_macro_get", {
7296
- params: CatalogMacroGetParamsSchema,
7297
- result: RESULT_BINARY_SCHEMA,
7298
- handler: async (params) => {
7299
- const cat = getCatalog();
7300
- 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);
7301
- return wrapResult({
7302
- items: info ? [encodeMacroInfo(info)] : []
7303
- }, CatalogMacroGetResultSchema);
7304
- }
8375
+ function catalogMacroHandlers(getCatalog, signingKey) {
8376
+ const catalogMacroGet = catalogHandler(signingKey, async (params) => {
8377
+ const cat = getCatalog();
8378
+ 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);
8379
+ return wrapResult({
8380
+ items: info ? [encodeMacroInfo(info)] : []
8381
+ }, CatalogMacroGetResultSchema);
7305
8382
  });
7306
- catalogUnary(protocol, signingKey, "catalog_macro_create", {
7307
- params: CatalogMacroCreateParamsSchema,
7308
- result: emptyResultSchema,
7309
- handler: async (params) => {
7310
- const cat = getCatalog();
7311
- const innerParams = params;
7312
- 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);
7313
- return {};
7314
- }
8383
+ const catalogMacroCreate = catalogHandler(signingKey, async (params) => {
8384
+ const cat = getCatalog();
8385
+ const innerParams = params;
8386
+ 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);
8387
+ return {};
7315
8388
  });
7316
- catalogUnary(protocol, signingKey, "catalog_macro_drop", {
7317
- params: CatalogMacroDropParamsSchema,
7318
- result: emptyResultSchema,
7319
- handler: async (params) => {
7320
- const cat = getCatalog();
7321
- 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);
7322
- return {};
7323
- }
8389
+ const catalogMacroDrop = catalogHandler(signingKey, async (params) => {
8390
+ const cat = getCatalog();
8391
+ 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);
8392
+ return {};
7324
8393
  });
7325
- catalogUnary(protocol, signingKey, "catalog_schema_contents_macros", {
7326
- params: CatalogSchemaContentsMacrosParamsSchema,
7327
- result: RESULT_BINARY_SCHEMA,
7328
- handler: async (params) => {
7329
- const cat = getCatalog();
7330
- 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);
7331
- return wrapResult({
7332
- items: macros.map((m) => encodeMacroInfo(m))
7333
- }, CatalogSchemaContentsMacrosResultSchema);
7334
- }
8394
+ const catalogSchemaContentsMacros = catalogHandler(signingKey, async (params) => {
8395
+ const cat = getCatalog();
8396
+ 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);
8397
+ return wrapResult({
8398
+ items: macros.map((m) => encodeMacroInfo(m))
8399
+ }, CatalogSchemaContentsMacrosResultSchema);
7335
8400
  });
8401
+ return { catalogMacroGet, catalogMacroCreate, catalogMacroDrop, catalogSchemaContentsMacros };
7336
8402
  }
7337
8403
 
7338
8404
  // src/protocol/handlers/catalog/index_methods.ts
7339
- function registerCatalogIndexMethods(protocol, getCatalog, signingKey) {
7340
- catalogUnary(protocol, signingKey, "catalog_schema_contents_indexes", {
7341
- params: CatalogSchemaContentsIndexesParamsSchema,
7342
- result: RESULT_BINARY_SCHEMA,
7343
- handler: async (params) => {
7344
- const cat = getCatalog();
7345
- const indexes = await cat.schemaContentsIndexes(toUint8Array(params.attach_opaque_data), params.path, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
7346
- return wrapResult({
7347
- items: indexes.map((i) => encodeIndexInfo(i))
7348
- }, CatalogSchemaContentsIndexesResultSchema);
7349
- }
8405
+ function catalogIndexHandlers(getCatalog, signingKey) {
8406
+ const catalogSchemaContentsIndexes = catalogHandler(signingKey, async (params) => {
8407
+ const cat = getCatalog();
8408
+ const indexes = await cat.schemaContentsIndexes(toUint8Array(params.attach_opaque_data), params.path, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
8409
+ return wrapResult({
8410
+ items: indexes.map((i) => encodeIndexInfo(i))
8411
+ }, CatalogSchemaContentsIndexesResultSchema);
7350
8412
  });
7351
- catalogUnary(protocol, signingKey, "catalog_index_get", {
7352
- params: CatalogIndexGetParamsSchema,
7353
- result: RESULT_BINARY_SCHEMA,
7354
- handler: async (params) => {
7355
- const cat = getCatalog();
7356
- 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);
7357
- return wrapResult({
7358
- items: info ? [encodeIndexInfo(info)] : []
7359
- }, CatalogIndexGetResultSchema);
7360
- }
8413
+ const catalogIndexGet = catalogHandler(signingKey, async (params) => {
8414
+ const cat = getCatalog();
8415
+ 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);
8416
+ return wrapResult({
8417
+ items: info ? [encodeIndexInfo(info)] : []
8418
+ }, CatalogIndexGetResultSchema);
7361
8419
  });
8420
+ return { catalogSchemaContentsIndexes, catalogIndexGet };
7362
8421
  }
7363
8422
 
7364
8423
  // src/protocol/handlers/catalog/index.ts
7365
- function registerCatalogMethods(protocol, catalog, _catalogName, signingKey) {
8424
+ function catalogHandlers(catalog, signingKey) {
7366
8425
  const getCatalog = makeGetCatalog(catalog);
7367
- registerCatalogAdminMethods(protocol, getCatalog, signingKey);
7368
- registerCatalogTableMethods(protocol, getCatalog, signingKey);
7369
- registerCatalogViewMethods(protocol, getCatalog, signingKey);
7370
- registerCatalogMacroMethods(protocol, getCatalog, signingKey);
7371
- registerCatalogIndexMethods(protocol, getCatalog, signingKey);
8426
+ return {
8427
+ ...catalogAdminHandlers(getCatalog, signingKey),
8428
+ ...catalogTableHandlers(getCatalog, signingKey),
8429
+ ...catalogViewHandlers(getCatalog, signingKey),
8430
+ ...catalogMacroHandlers(getCatalog, signingKey),
8431
+ ...catalogIndexHandlers(getCatalog, signingKey)
8432
+ };
7372
8433
  }
7373
8434
 
7374
8435
  // src/protocol/dispatch.ts
7375
- var VGI_PROTOCOL_NAME = "vgi.v2";
8436
+ function buildVgiService(config) {
8437
+ return {
8438
+ ...UNIMPLEMENTED_VGI_SERVICE,
8439
+ ...functionHandlers({
8440
+ registry: config.registry,
8441
+ signingKey: config.signingKey,
8442
+ catalogInterface: config.catalogInterface
8443
+ }),
8444
+ ...aggregateHandlers(config.registry),
8445
+ ...tableBufferingHandlers(config.registry, config.signingKey),
8446
+ ...catalogHandlers(config.catalogInterface, config.signingKey)
8447
+ };
8448
+ }
7376
8449
  function buildVgiProtocol(config) {
7377
- const protocol = new Protocol2(VGI_PROTOCOL_NAME, { protocolVersion: "2.1.0" });
7378
- registerFunctionMethods(protocol, {
7379
- registry: config.registry,
7380
- signingKey: config.signingKey,
7381
- catalogInterface: config.catalogInterface
7382
- });
7383
- registerAggregateMethods(protocol, config.registry);
7384
- registerTableBufferingMethods(protocol, config.registry, config.signingKey);
7385
- registerCatalogMethods(protocol, config.catalogInterface, config.catalogName, config.signingKey);
7386
- return protocol;
8450
+ return createVgiProtocol(buildVgiService(config));
7387
8451
  }
7388
8452
 
7389
8453
  // src/http/landing-html.ts
@@ -7826,4 +8890,4 @@ export {
7826
8890
  serveVgiWorker
7827
8891
  };
7828
8892
 
7829
- //# debugId=9AD0D580690218C964756E2164756E21
8893
+ //# debugId=7D0DFE46FB512EAD64756E2164756E21