@eide/foir-cli 0.2.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -448,26 +448,2240 @@ function registerLogoutCommand(program2, globalOpts) {
448
448
  import inquirer from "inquirer";
449
449
 
450
450
  // src/lib/client.ts
451
- import { createClient } from "@connectrpc/connect";
451
+ import { createClient as createRpcClient } from "@connectrpc/connect";
452
452
  import { createConnectTransport } from "@connectrpc/connect-node";
453
+ import { IdentityService as IdentityService2 } from "@eide/foir-proto-ts/identity/v1/identity_pb";
454
+ import { ModelsService as ModelsService2 } from "@eide/foir-proto-ts/models/v1/models_pb";
455
+ import { RecordsService as RecordsService2 } from "@eide/foir-proto-ts/records/v1/records_pb";
456
+ import { ConfigsService as ConfigsService2 } from "@eide/foir-proto-ts/configs/v1/configs_pb";
457
+ import { SegmentsService as SegmentsService2 } from "@eide/foir-proto-ts/segments/v1/segments_pb";
458
+ import { ExperimentsService as ExperimentsService2 } from "@eide/foir-proto-ts/experiments/v1/experiments_pb";
459
+ import { SettingsService as SettingsService2 } from "@eide/foir-proto-ts/settings/v1/settings_pb";
460
+ import { StorageService as StorageService2 } from "@eide/foir-proto-ts/storage/v1/storage_pb";
461
+
462
+ // src/lib/rpc/identity.ts
463
+ import { create } from "@bufbuild/protobuf";
464
+ import {
465
+ LoginRequestSchema,
466
+ LoginWithOTPRequestSchema,
467
+ RequestOTPRequestSchema,
468
+ LogoutRequestSchema,
469
+ GetMeRequestSchema,
470
+ GetSessionContextRequestSchema,
471
+ SwitchTenantRequestSchema,
472
+ SwitchProjectRequestSchema,
473
+ ClearSessionContextRequestSchema,
474
+ RefreshTokenRequestSchema,
475
+ RegisterRequestSchema,
476
+ VerifyEmailRequestSchema,
477
+ ResendVerificationEmailRequestSchema,
478
+ UpdatePasswordRequestSchema,
479
+ RequestPasswordResetRequestSchema,
480
+ ResetPasswordRequestSchema,
481
+ SendEmailVerificationCodeRequestSchema,
482
+ VerifyEmailCodeRequestSchema,
483
+ CreateAdminUserRequestSchema,
484
+ GetAdminUserRequestSchema,
485
+ UpdateAdminUserRequestSchema,
486
+ ListAdminUsersRequestSchema,
487
+ GrantAccessRequestSchema,
488
+ RevokeAccessRequestSchema,
489
+ CreateCustomerRequestSchema,
490
+ GetCustomerRequestSchema,
491
+ UpdateCustomerRequestSchema,
492
+ DeleteCustomerRequestSchema,
493
+ ListCustomersRequestSchema,
494
+ SuspendCustomerRequestSchema,
495
+ CreateTenantRequestSchema,
496
+ GetTenantRequestSchema,
497
+ UpdateTenantRequestSchema,
498
+ ListTenantsRequestSchema,
499
+ DeleteTenantRequestSchema,
500
+ CreateProjectRequestSchema,
501
+ GetProjectRequestSchema,
502
+ UpdateProjectRequestSchema,
503
+ ListProjectsRequestSchema,
504
+ DeleteProjectRequestSchema,
505
+ GetDefaultProjectRequestSchema,
506
+ SetDefaultProjectRequestSchema,
507
+ CreateInvitationRequestSchema,
508
+ ListInvitationsRequestSchema,
509
+ RevokeInvitationRequestSchema,
510
+ AcceptInvitationRequestSchema,
511
+ ValidateInvitationRequestSchema,
512
+ CreateApiKeyRequestSchema,
513
+ GetApiKeyRequestSchema,
514
+ ListApiKeysRequestSchema,
515
+ UpdateApiKeyRequestSchema,
516
+ RotateApiKeyRequestSchema,
517
+ RevokeApiKeyRequestSchema,
518
+ MintServiceTokenRequestSchema,
519
+ ListAuthProvidersRequestSchema,
520
+ GetAuthProviderRequestSchema,
521
+ CreateAuthProviderRequestSchema,
522
+ UpdateAuthProviderRequestSchema,
523
+ DeleteAuthProviderRequestSchema,
524
+ EnabledOAuthProvidersRequestSchema,
525
+ CheckEmailAvailabilityRequestSchema,
526
+ CompleteAccountSetupRequestSchema,
527
+ CreateSignupSessionRequestSchema,
528
+ UpdateMyProfileRequestSchema,
529
+ ListMyOAuthConnectionsRequestSchema,
530
+ UnlinkOAuthProviderRequestSchema,
531
+ ResendInvitationRequestSchema,
532
+ GetCustomerAuthConfigRequestSchema,
533
+ VerifyCustomerTokenRequestSchema,
534
+ GetCustomerManagementStatusRequestSchema
535
+ } from "@eide/foir-proto-ts/identity/v1/identity_pb";
536
+ import {
537
+ InviteType,
538
+ AccessRole,
539
+ CustomerStatus,
540
+ AdminUserStatus,
541
+ TenantStatus,
542
+ ProjectStatus,
543
+ InvitationStatus
544
+ } from "@eide/foir-proto-ts/identity/v1/identity_pb";
545
+ function createIdentityMethods(client) {
546
+ return {
547
+ // ── Auth ──────────────────────────────────────────────
548
+ async login(email, password, tenantId, projectId) {
549
+ const resp = await client.login(
550
+ create(LoginRequestSchema, { email, password, tenantId, projectId })
551
+ );
552
+ return {
553
+ sessionId: resp.sessionId,
554
+ user: resp.user ?? null
555
+ };
556
+ },
557
+ async loginWithOTP(email, otp, tenantId, projectId) {
558
+ const resp = await client.loginWithOTP(
559
+ create(LoginWithOTPRequestSchema, { email, otp, tenantId, projectId })
560
+ );
561
+ return {
562
+ sessionId: resp.sessionId,
563
+ user: resp.user ?? null
564
+ };
565
+ },
566
+ async requestOTP(email, tenantId, projectId) {
567
+ const resp = await client.requestOTP(
568
+ create(RequestOTPRequestSchema, { email, tenantId, projectId })
569
+ );
570
+ return { success: resp.success };
571
+ },
572
+ async logout() {
573
+ const resp = await client.logout(create(LogoutRequestSchema, {}));
574
+ return { success: resp.success };
575
+ },
576
+ async register(params) {
577
+ const resp = await client.register(
578
+ create(RegisterRequestSchema, {
579
+ email: params.email,
580
+ password: params.password,
581
+ tenantId: params.tenantId,
582
+ projectId: params.projectId,
583
+ role: params.role
584
+ })
585
+ );
586
+ return { user: resp.user ?? null };
587
+ },
588
+ // ── Email Verification ────────────────────────────────
589
+ async verifyEmail(token) {
590
+ const resp = await client.verifyEmail(
591
+ create(VerifyEmailRequestSchema, { token })
592
+ );
593
+ return { success: resp.success };
594
+ },
595
+ async resendVerificationEmail() {
596
+ const resp = await client.resendVerificationEmail(
597
+ create(ResendVerificationEmailRequestSchema, {})
598
+ );
599
+ return { success: resp.success };
600
+ },
601
+ async sendEmailVerificationCode(email) {
602
+ const resp = await client.sendEmailVerificationCode(
603
+ create(SendEmailVerificationCodeRequestSchema, { email })
604
+ );
605
+ return { success: resp.success };
606
+ },
607
+ async verifyEmailCode(email, code) {
608
+ const resp = await client.verifyEmailCode(
609
+ create(VerifyEmailCodeRequestSchema, { email, code })
610
+ );
611
+ return { success: resp.success, verified: resp.verified };
612
+ },
613
+ // ── Password ──────────────────────────────────────────
614
+ async updatePassword(currentPassword, newPassword) {
615
+ const resp = await client.updatePassword(
616
+ create(UpdatePasswordRequestSchema, { currentPassword, newPassword })
617
+ );
618
+ return { success: resp.success };
619
+ },
620
+ async requestPasswordReset(email) {
621
+ const resp = await client.requestPasswordReset(
622
+ create(RequestPasswordResetRequestSchema, { email })
623
+ );
624
+ return { success: resp.success };
625
+ },
626
+ async resetPassword(token, newPassword) {
627
+ const resp = await client.resetPassword(
628
+ create(ResetPasswordRequestSchema, { token, newPassword })
629
+ );
630
+ return { success: resp.success };
631
+ },
632
+ // ── Session Context ───────────────────────────────────
633
+ async getMe() {
634
+ const resp = await client.getMe(create(GetMeRequestSchema, {}));
635
+ return { user: resp.user ?? null };
636
+ },
637
+ async getSessionContext() {
638
+ const resp = await client.getSessionContext(
639
+ create(GetSessionContextRequestSchema, {})
640
+ );
641
+ return resp.context ?? null;
642
+ },
643
+ async switchTenant(tenantId) {
644
+ const resp = await client.switchTenant(
645
+ create(SwitchTenantRequestSchema, { tenantId })
646
+ );
647
+ return resp.context ?? null;
648
+ },
649
+ async switchProject(projectId) {
650
+ const resp = await client.switchProject(
651
+ create(SwitchProjectRequestSchema, { projectId })
652
+ );
653
+ return resp.context ?? null;
654
+ },
655
+ async clearSessionContext() {
656
+ await client.clearSessionContext(
657
+ create(ClearSessionContextRequestSchema, {})
658
+ );
659
+ return { success: true };
660
+ },
661
+ async refreshToken(refreshToken) {
662
+ const resp = await client.refreshToken(
663
+ create(RefreshTokenRequestSchema, { refreshToken })
664
+ );
665
+ return { accessToken: resp.accessToken, refreshToken: resp.refreshToken };
666
+ },
667
+ // ── Admin Users ───────────────────────────────────────
668
+ async createAdminUser(params) {
669
+ const resp = await client.createAdminUser(
670
+ create(CreateAdminUserRequestSchema, params)
671
+ );
672
+ return { user: resp.user ?? null };
673
+ },
674
+ async getAdminUser(id) {
675
+ const resp = await client.getAdminUser(
676
+ create(GetAdminUserRequestSchema, { id })
677
+ );
678
+ return { user: resp.user ?? null };
679
+ },
680
+ async updateAdminUser(params) {
681
+ const resp = await client.updateAdminUser(
682
+ create(UpdateAdminUserRequestSchema, params)
683
+ );
684
+ return { user: resp.user ?? null };
685
+ },
686
+ async listAdminUsers(params = {}) {
687
+ const resp = await client.listAdminUsers(
688
+ create(ListAdminUsersRequestSchema, {
689
+ search: params.search,
690
+ status: params.status,
691
+ role: params.role,
692
+ limit: params.limit ?? 50,
693
+ offset: params.offset ?? 0
694
+ })
695
+ );
696
+ return {
697
+ items: resp.items ?? [],
698
+ total: Number(resp.total)
699
+ };
700
+ },
701
+ async grantAccess(params) {
702
+ const resp = await client.grantAccess(
703
+ create(GrantAccessRequestSchema, params)
704
+ );
705
+ return { access: resp.access ?? null };
706
+ },
707
+ async revokeAccess(accessId) {
708
+ const resp = await client.revokeAccess(
709
+ create(RevokeAccessRequestSchema, { accessId })
710
+ );
711
+ return { success: resp.success };
712
+ },
713
+ // ── Customers ─────────────────────────────────────────
714
+ async createCustomer(params) {
715
+ const resp = await client.createCustomer(
716
+ create(CreateCustomerRequestSchema, {
717
+ email: params.email,
718
+ password: params.password
719
+ })
720
+ );
721
+ return {
722
+ customer: resp.customer ?? null
723
+ };
724
+ },
725
+ async getCustomer(id) {
726
+ const resp = await client.getCustomer(
727
+ create(GetCustomerRequestSchema, { id })
728
+ );
729
+ return {
730
+ customer: resp.customer ?? null
731
+ };
732
+ },
733
+ async updateCustomer(params) {
734
+ const resp = await client.updateCustomer(
735
+ create(UpdateCustomerRequestSchema, {
736
+ id: params.id,
737
+ email: params.email,
738
+ status: params.status
739
+ })
740
+ );
741
+ return {
742
+ customer: resp.customer ?? null
743
+ };
744
+ },
745
+ async deleteCustomer(id) {
746
+ const resp = await client.deleteCustomer(
747
+ create(DeleteCustomerRequestSchema, { id })
748
+ );
749
+ return { success: resp.success };
750
+ },
751
+ async listCustomers(params = {}) {
752
+ const resp = await client.listCustomers(
753
+ create(ListCustomersRequestSchema, {
754
+ search: params.search,
755
+ status: params.status,
756
+ limit: params.limit ?? 50,
757
+ offset: params.offset ?? 0
758
+ })
759
+ );
760
+ return {
761
+ items: resp.items ?? [],
762
+ total: Number(resp.total)
763
+ };
764
+ },
765
+ async suspendCustomer(id) {
766
+ const resp = await client.suspendCustomer(
767
+ create(SuspendCustomerRequestSchema, { id })
768
+ );
769
+ return {
770
+ customer: resp.customer ?? null
771
+ };
772
+ },
773
+ // ── Tenants ───────────────────────────────────────────
774
+ async createTenant(params) {
775
+ const resp = await client.createTenant(
776
+ create(CreateTenantRequestSchema, { name: params.name })
777
+ );
778
+ return { tenant: resp.tenant ?? null };
779
+ },
780
+ async getTenant(id) {
781
+ const resp = await client.getTenant(
782
+ create(GetTenantRequestSchema, { id })
783
+ );
784
+ return { tenant: resp.tenant ?? null };
785
+ },
786
+ async updateTenant(params) {
787
+ const resp = await client.updateTenant(
788
+ create(UpdateTenantRequestSchema, {
789
+ id: params.id,
790
+ name: params.name,
791
+ status: params.status
792
+ })
793
+ );
794
+ return { tenant: resp.tenant ?? null };
795
+ },
796
+ async listTenants(params = {}) {
797
+ const resp = await client.listTenants(
798
+ create(ListTenantsRequestSchema, {
799
+ status: params.status,
800
+ limit: params.limit ?? 50,
801
+ offset: params.offset ?? 0
802
+ })
803
+ );
804
+ return {
805
+ items: resp.items ?? [],
806
+ total: Number(resp.total)
807
+ };
808
+ },
809
+ async deleteTenant(id) {
810
+ const resp = await client.deleteTenant(
811
+ create(DeleteTenantRequestSchema, { id })
812
+ );
813
+ return { success: resp.success };
814
+ },
815
+ // ── Projects ──────────────────────────────────────────
816
+ async createProject(params) {
817
+ const resp = await client.createProject(
818
+ create(CreateProjectRequestSchema, {
819
+ tenantId: params.tenantId,
820
+ name: params.name,
821
+ description: params.description
822
+ })
823
+ );
824
+ return { project: resp.project ?? null };
825
+ },
826
+ async getProject(id) {
827
+ const resp = await client.getProject(
828
+ create(GetProjectRequestSchema, { id })
829
+ );
830
+ return { project: resp.project ?? null };
831
+ },
832
+ async updateProject(params) {
833
+ const resp = await client.updateProject(
834
+ create(UpdateProjectRequestSchema, {
835
+ id: params.id,
836
+ name: params.name,
837
+ description: params.description
838
+ })
839
+ );
840
+ return { project: resp.project ?? null };
841
+ },
842
+ async listProjects(params) {
843
+ const resp = await client.listProjects(
844
+ create(ListProjectsRequestSchema, {
845
+ tenantId: params.tenantId,
846
+ status: params.status,
847
+ limit: params.limit ?? 50,
848
+ offset: params.offset ?? 0
849
+ })
850
+ );
851
+ return {
852
+ items: resp.items ?? [],
853
+ total: Number(resp.total)
854
+ };
855
+ },
856
+ async deleteProject(id) {
857
+ const resp = await client.deleteProject(
858
+ create(DeleteProjectRequestSchema, { id })
859
+ );
860
+ return { success: resp.success };
861
+ },
862
+ async getDefaultProject(tenantId) {
863
+ const resp = await client.getDefaultProject(
864
+ create(GetDefaultProjectRequestSchema, { tenantId })
865
+ );
866
+ return { project: resp.project ?? null };
867
+ },
868
+ async setDefaultProject(params) {
869
+ const resp = await client.setDefaultProject(
870
+ create(SetDefaultProjectRequestSchema, {
871
+ projectId: params.projectId
872
+ })
873
+ );
874
+ return { project: resp.project ?? null };
875
+ },
876
+ // ── Invitations ───────────────────────────────────────
877
+ async createInvitation(params) {
878
+ const resp = await client.createInvitation(
879
+ create(CreateInvitationRequestSchema, {
880
+ email: params.email,
881
+ tenantId: params.tenantId,
882
+ projectIds: params.projectIds ?? [],
883
+ role: params.role,
884
+ inviteType: params.inviteType,
885
+ message: params.message
886
+ })
887
+ );
888
+ return {
889
+ invitation: resp.invitation ?? null
890
+ };
891
+ },
892
+ async listInvitations(params) {
893
+ const resp = await client.listInvitations(
894
+ create(ListInvitationsRequestSchema, {
895
+ tenantId: params.tenantId,
896
+ status: params.status,
897
+ limit: params.limit ?? 50,
898
+ offset: params.offset ?? 0
899
+ })
900
+ );
901
+ return {
902
+ items: resp.items ?? [],
903
+ total: Number(resp.total)
904
+ };
905
+ },
906
+ async revokeInvitation(invitationId) {
907
+ const resp = await client.revokeInvitation(
908
+ create(RevokeInvitationRequestSchema, { invitationId })
909
+ );
910
+ return { success: resp.success };
911
+ },
912
+ async acceptInvitation(params) {
913
+ const resp = await client.acceptInvitation(
914
+ create(AcceptInvitationRequestSchema, {
915
+ token: params.token,
916
+ password: params.password
917
+ })
918
+ );
919
+ return {
920
+ user: resp.user ?? null,
921
+ sessionId: resp.sessionId
922
+ };
923
+ },
924
+ async validateInvitation(params) {
925
+ const resp = await client.validateInvitation(
926
+ create(ValidateInvitationRequestSchema, { token: params.token })
927
+ );
928
+ return {
929
+ invitation: resp.invitation ?? null
930
+ };
931
+ },
932
+ // ── API Keys ──────────────────────────────────────────
933
+ async createApiKey(params) {
934
+ const resp = await client.createApiKey(
935
+ create(CreateApiKeyRequestSchema, {
936
+ name: params.name,
937
+ keyType: params.keyType,
938
+ rateLimitPerHour: params.rateLimitPerHour
939
+ })
940
+ );
941
+ return { apiKey: resp.apiKey ?? null };
942
+ },
943
+ async getApiKey(id) {
944
+ const resp = await client.getApiKey(
945
+ create(GetApiKeyRequestSchema, { id })
946
+ );
947
+ return { apiKey: resp.apiKey ?? null };
948
+ },
949
+ async listApiKeys(params = {}) {
950
+ const resp = await client.listApiKeys(
951
+ create(ListApiKeysRequestSchema, {
952
+ limit: params.limit ?? 50,
953
+ offset: params.offset ?? 0
954
+ })
955
+ );
956
+ return {
957
+ items: resp.items ?? [],
958
+ total: Number(resp.total)
959
+ };
960
+ },
961
+ async updateApiKey(params) {
962
+ const resp = await client.updateApiKey(
963
+ create(UpdateApiKeyRequestSchema, {
964
+ id: params.id,
965
+ name: params.name,
966
+ isActive: params.isActive,
967
+ rateLimitPerHour: params.rateLimitPerHour
968
+ })
969
+ );
970
+ return { apiKey: resp.apiKey ?? null };
971
+ },
972
+ async rotateApiKey(id) {
973
+ const resp = await client.rotateApiKey(
974
+ create(RotateApiKeyRequestSchema, { id })
975
+ );
976
+ return { apiKey: resp.apiKey ?? null };
977
+ },
978
+ async revokeApiKey(id) {
979
+ const resp = await client.revokeApiKey(
980
+ create(RevokeApiKeyRequestSchema, { id })
981
+ );
982
+ return { success: resp.success };
983
+ },
984
+ // ── Service Tokens ──────────────────────────────────────────
985
+ async mintServiceToken(purpose) {
986
+ const resp = await client.mintServiceToken(
987
+ create(MintServiceTokenRequestSchema, { purpose })
988
+ );
989
+ return {
990
+ token: resp.token,
991
+ purpose: resp.purpose,
992
+ expiresAt: resp.expiresAt
993
+ };
994
+ },
995
+ // ── Auth Providers ───────────────────────────────────────
996
+ async listAuthProviders(params = {}) {
997
+ const resp = await client.listAuthProviders(
998
+ create(ListAuthProvidersRequestSchema, {
999
+ enabled: params.enabled,
1000
+ limit: params.limit ?? 50,
1001
+ offset: params.offset ?? 0
1002
+ })
1003
+ );
1004
+ return {
1005
+ items: resp.providers ?? [],
1006
+ total: resp.total
1007
+ };
1008
+ },
1009
+ async getAuthProvider(id) {
1010
+ const resp = await client.getAuthProvider(
1011
+ create(GetAuthProviderRequestSchema, { id })
1012
+ );
1013
+ return resp.provider ?? null;
1014
+ },
1015
+ async createAuthProvider(params) {
1016
+ const resp = await client.createAuthProvider(
1017
+ create(CreateAuthProviderRequestSchema, {
1018
+ key: params.key,
1019
+ name: params.name,
1020
+ type: params.type,
1021
+ config: params.config,
1022
+ enabled: params.enabled,
1023
+ isDefault: params.isDefault,
1024
+ priority: params.priority
1025
+ })
1026
+ );
1027
+ return resp.provider ?? null;
1028
+ },
1029
+ async updateAuthProvider(params) {
1030
+ const resp = await client.updateAuthProvider(
1031
+ create(UpdateAuthProviderRequestSchema, {
1032
+ id: params.id,
1033
+ name: params.name,
1034
+ config: params.config,
1035
+ enabled: params.enabled,
1036
+ isDefault: params.isDefault,
1037
+ priority: params.priority
1038
+ })
1039
+ );
1040
+ return resp.provider ?? null;
1041
+ },
1042
+ async deleteAuthProvider(id) {
1043
+ const resp = await client.deleteAuthProvider(
1044
+ create(DeleteAuthProviderRequestSchema, { id })
1045
+ );
1046
+ return resp.success;
1047
+ },
1048
+ async enabledOAuthProviders() {
1049
+ const resp = await client.enabledOAuthProviders(
1050
+ create(EnabledOAuthProvidersRequestSchema, {})
1051
+ );
1052
+ return resp.providers ?? [];
1053
+ },
1054
+ // ── Signup / Account Setup ───────────────────────────────
1055
+ async checkEmailAvailability(email) {
1056
+ const resp = await client.checkEmailAvailability(
1057
+ create(CheckEmailAvailabilityRequestSchema, { email })
1058
+ );
1059
+ return { available: resp.available };
1060
+ },
1061
+ async completeAccountSetup(params) {
1062
+ const resp = await client.completeAccountSetup(
1063
+ create(CompleteAccountSetupRequestSchema, {
1064
+ firstName: params.firstName,
1065
+ lastName: params.lastName,
1066
+ password: params.password
1067
+ })
1068
+ );
1069
+ return {
1070
+ success: resp.success,
1071
+ redirectUrl: resp.redirectUrl ?? void 0
1072
+ };
1073
+ },
1074
+ async createSignupSession(userId) {
1075
+ const resp = await client.createSignupSession(
1076
+ create(CreateSignupSessionRequestSchema, { userId })
1077
+ );
1078
+ return { success: resp.success };
1079
+ },
1080
+ // ── Profile / OAuth ───────────────────────────────────────
1081
+ async updateMyProfile(params) {
1082
+ const resp = await client.updateMyProfile(
1083
+ create(UpdateMyProfileRequestSchema, {
1084
+ firstName: params.firstName,
1085
+ lastName: params.lastName,
1086
+ avatarUrl: params.avatarUrl
1087
+ })
1088
+ );
1089
+ return resp.user ?? null;
1090
+ },
1091
+ async listMyOAuthConnections() {
1092
+ const resp = await client.listMyOAuthConnections(
1093
+ create(ListMyOAuthConnectionsRequestSchema, {})
1094
+ );
1095
+ return resp.connections ?? [];
1096
+ },
1097
+ async unlinkOAuthProvider(provider) {
1098
+ const resp = await client.unlinkOAuthProvider(
1099
+ create(UnlinkOAuthProviderRequestSchema, { provider })
1100
+ );
1101
+ return resp.success;
1102
+ },
1103
+ // ── Invitations (additional) ─────────────────────────────
1104
+ async resendInvitation(invitationId) {
1105
+ const resp = await client.resendInvitation(
1106
+ create(ResendInvitationRequestSchema, { invitationId })
1107
+ );
1108
+ return resp.success;
1109
+ },
1110
+ // ── Customer Auth ────────────────────────────────────────
1111
+ async getCustomerAuthConfig() {
1112
+ const resp = await client.getCustomerAuthConfig(
1113
+ create(GetCustomerAuthConfigRequestSchema, {})
1114
+ );
1115
+ return resp.config ?? null;
1116
+ },
1117
+ async verifyCustomerToken(token) {
1118
+ const resp = await client.verifyCustomerToken(
1119
+ create(VerifyCustomerTokenRequestSchema, { token })
1120
+ );
1121
+ return resp;
1122
+ },
1123
+ async getCustomerManagementStatus() {
1124
+ const resp = await client.getCustomerManagementStatus(
1125
+ create(GetCustomerManagementStatusRequestSchema, {})
1126
+ );
1127
+ return resp.status ?? null;
1128
+ }
1129
+ };
1130
+ }
1131
+
1132
+ // src/lib/rpc/models.ts
1133
+ import { create as create2 } from "@bufbuild/protobuf";
1134
+ import {
1135
+ FieldSchema as ProtoFieldSchema,
1136
+ SharingConfigSchema as ProtoSharingConfigSchema,
1137
+ ModelConfigSchema as ProtoModelConfigSchema,
1138
+ CreateModelRequestSchema,
1139
+ GetModelRequestSchema,
1140
+ GetModelByKeyRequestSchema,
1141
+ ListModelsRequestSchema,
1142
+ UpdateModelRequestSchema,
1143
+ DeleteModelRequestSchema,
1144
+ DuplicateModelRequestSchema,
1145
+ ListModelVersionsRequestSchema,
1146
+ RestoreModelVersionRequestSchema
1147
+ } from "@eide/foir-proto-ts/models/v1/models_pb";
1148
+ function jsFieldToProto(f) {
1149
+ return create2(ProtoFieldSchema, {
1150
+ id: f.id,
1151
+ key: f.key,
1152
+ label: f.label,
1153
+ type: f.type,
1154
+ required: f.required,
1155
+ helpText: f.helpText,
1156
+ placeholder: f.placeholder,
1157
+ config: f.config && Object.keys(f.config).length > 0 ? f.config : void 0,
1158
+ itemType: f.itemType,
1159
+ storage: f.storage,
1160
+ templateZone: f.templateZone,
1161
+ zoneOrder: f.zoneOrder
1162
+ });
1163
+ }
1164
+ function jsConfigToProto(c) {
1165
+ return create2(ProtoModelConfigSchema, {
1166
+ versioning: c.versioning ?? false,
1167
+ publishing: c.publishing ?? false,
1168
+ variants: c.variants ?? false,
1169
+ inline: c.inline ?? false,
1170
+ customerScoped: c.customerScoped ?? false,
1171
+ sharing: c.sharing ? create2(ProtoSharingConfigSchema, {
1172
+ enabled: c.sharing.enabled,
1173
+ requireAcceptance: c.sharing.requireAcceptance
1174
+ }) : void 0,
1175
+ pluralName: c.pluralName,
1176
+ description: c.description,
1177
+ category: c.category,
1178
+ icon: c.icon,
1179
+ displayField: c.displayField,
1180
+ naturalKeyField: c.naturalKeyField,
1181
+ systemEntity: c.systemEntity ?? false,
1182
+ deletable: c.deletable,
1183
+ editable: c.editable
1184
+ });
1185
+ }
1186
+ function createModelsMethods(client) {
1187
+ return {
1188
+ // ── Queries ──────────────────────────────────────────────
1189
+ async getModel(id) {
1190
+ const resp = await client.getModel(create2(GetModelRequestSchema, { id }));
1191
+ return resp.model ?? null;
1192
+ },
1193
+ async getModelByKey(key) {
1194
+ const resp = await client.getModelByKey(
1195
+ create2(GetModelByKeyRequestSchema, { key })
1196
+ );
1197
+ return resp.model ?? null;
1198
+ },
1199
+ async listModels(params = {}) {
1200
+ const resp = await client.listModels(
1201
+ create2(ListModelsRequestSchema, {
1202
+ search: params.search,
1203
+ category: params.category,
1204
+ configId: params.configId,
1205
+ limit: params.limit ?? 50,
1206
+ offset: params.offset ?? 0
1207
+ })
1208
+ );
1209
+ return {
1210
+ items: resp.models ?? [],
1211
+ total: resp.total
1212
+ };
1213
+ },
1214
+ // ── Mutations ────────────────────────────────────────────
1215
+ async createModel(params) {
1216
+ const resp = await client.createModel(
1217
+ create2(CreateModelRequestSchema, {
1218
+ key: params.key,
1219
+ name: params.name,
1220
+ fields: params.fields.map(jsFieldToProto),
1221
+ config: params.config ? jsConfigToProto(params.config) : void 0,
1222
+ configId: params.configId
1223
+ })
1224
+ );
1225
+ return resp.model ?? null;
1226
+ },
1227
+ async updateModel(params) {
1228
+ const resp = await client.updateModel(
1229
+ create2(UpdateModelRequestSchema, {
1230
+ id: params.id,
1231
+ name: params.name,
1232
+ updateFields: params.fields != null,
1233
+ fields: params.fields?.map(jsFieldToProto) ?? [],
1234
+ config: params.config ? jsConfigToProto(params.config) : void 0,
1235
+ changeDescription: params.changeDescription
1236
+ })
1237
+ );
1238
+ return resp.model ?? null;
1239
+ },
1240
+ async deleteModel(id) {
1241
+ const resp = await client.deleteModel(
1242
+ create2(DeleteModelRequestSchema, { id })
1243
+ );
1244
+ return resp.success;
1245
+ },
1246
+ async duplicateModel(params) {
1247
+ const resp = await client.duplicateModel(
1248
+ create2(DuplicateModelRequestSchema, params)
1249
+ );
1250
+ return resp.model ?? null;
1251
+ },
1252
+ // ── Versioning ───────────────────────────────────────────
1253
+ async listModelVersions(modelId, params = {}) {
1254
+ const resp = await client.listModelVersions(
1255
+ create2(ListModelVersionsRequestSchema, {
1256
+ modelId,
1257
+ limit: params.limit ?? 50,
1258
+ offset: params.offset ?? 0
1259
+ })
1260
+ );
1261
+ return {
1262
+ items: resp.versions ?? [],
1263
+ total: resp.total
1264
+ };
1265
+ },
1266
+ async restoreModelVersion(modelId, versionId) {
1267
+ const resp = await client.restoreModelVersion(
1268
+ create2(RestoreModelVersionRequestSchema, { modelId, versionId })
1269
+ );
1270
+ return resp.model ?? null;
1271
+ }
1272
+ };
1273
+ }
1274
+
1275
+ // src/lib/rpc/records.ts
1276
+ import { create as create3 } from "@bufbuild/protobuf";
1277
+ import {
1278
+ CreateRecordRequestSchema,
1279
+ GetRecordRequestSchema,
1280
+ GetRecordByKeyRequestSchema,
1281
+ GetRecordByKeyOrIdRequestSchema,
1282
+ ListRecordsRequestSchema,
1283
+ UpdateRecordRequestSchema,
1284
+ DeleteRecordRequestSchema,
1285
+ DuplicateRecordRequestSchema,
1286
+ DuplicateRecordsBulkRequestSchema,
1287
+ BatchRecordOperationsRequestSchema,
1288
+ BatchOperationSchema,
1289
+ RecordFilterSchema,
1290
+ BulkUpdateRecordsRequestSchema,
1291
+ CreateVersionRequestSchema,
1292
+ PublishVersionRequestSchema,
1293
+ UnpublishRecordRequestSchema,
1294
+ RevertToVersionRequestSchema,
1295
+ ListRecordVersionsRequestSchema,
1296
+ SaveContentRequestSchema,
1297
+ CreateVariantRequestSchema,
1298
+ UpdateVariantRequestSchema,
1299
+ DeleteVariantRequestSchema,
1300
+ SetDefaultVariantRequestSchema,
1301
+ ListRecordVariantsRequestSchema,
1302
+ ScheduleRecordPublishRequestSchema,
1303
+ CancelScheduledRecordPublishRequestSchema,
1304
+ ListScheduledPublishesRequestSchema,
1305
+ ListDraftVersionsRequestSchema,
1306
+ BatchPublishVersionsRequestSchema,
1307
+ CreatePublishBatchRequestSchema,
1308
+ UpdatePublishBatchRequestSchema,
1309
+ CancelPublishBatchRequestSchema,
1310
+ RollbackPublishBatchRequestSchema,
1311
+ RetryFailedBatchItemsRequestSchema,
1312
+ AddItemsToPublishBatchRequestSchema,
1313
+ RemoveItemsFromPublishBatchRequestSchema,
1314
+ ListPublishBatchesRequestSchema,
1315
+ GetPublishBatchRequestSchema,
1316
+ GlobalSearchRequestSchema,
1317
+ GetEmbeddingStatsRequestSchema,
1318
+ GetRecordEmbeddingsRequestSchema,
1319
+ FindSimilarRecordsRequestSchema
1320
+ } from "@eide/foir-proto-ts/records/v1/records_pb";
1321
+ import { RecordType, BatchStatus } from "@eide/foir-proto-ts/records/v1/records_pb";
1322
+ function sanitizeData(obj) {
1323
+ const result = {};
1324
+ for (const [key, value] of Object.entries(obj)) {
1325
+ if (value === void 0) continue;
1326
+ if (value !== null && typeof value === "object" && !Array.isArray(value)) {
1327
+ result[key] = sanitizeData(value);
1328
+ } else if (Array.isArray(value)) {
1329
+ result[key] = value.map((item) => {
1330
+ if (item === void 0) return null;
1331
+ if (item !== null && typeof item === "object" && !Array.isArray(item)) {
1332
+ return sanitizeData(item);
1333
+ }
1334
+ return item;
1335
+ });
1336
+ } else {
1337
+ result[key] = value;
1338
+ }
1339
+ }
1340
+ return result;
1341
+ }
1342
+ function createRecordsMethods(client) {
1343
+ return {
1344
+ // ── CRUD ──────────────────────────────────────────────────
1345
+ async createRecord(params) {
1346
+ const resp = await client.createRecord(
1347
+ create3(CreateRecordRequestSchema, {
1348
+ modelKey: params.modelKey,
1349
+ naturalKey: params.naturalKey,
1350
+ data: params.data ? sanitizeData(params.data) : void 0,
1351
+ customerId: params.customerId,
1352
+ metadata: params.metadata ? sanitizeData(params.metadata) : void 0,
1353
+ changeDescription: params.changeDescription
1354
+ })
1355
+ );
1356
+ return {
1357
+ record: resp.record ?? null,
1358
+ variant: resp.variant ?? null,
1359
+ version: resp.version ?? null
1360
+ };
1361
+ },
1362
+ async getRecord(id) {
1363
+ const resp = await client.getRecord(
1364
+ create3(GetRecordRequestSchema, { id })
1365
+ );
1366
+ return resp.record ?? null;
1367
+ },
1368
+ async getRecordByKey(modelKey, naturalKey) {
1369
+ const resp = await client.getRecordByKey(
1370
+ create3(GetRecordByKeyRequestSchema, { modelKey, naturalKey })
1371
+ );
1372
+ return resp.record ?? null;
1373
+ },
1374
+ async getRecordByKeyOrId(modelKey, identifier) {
1375
+ const resp = await client.getRecordByKeyOrId(
1376
+ create3(GetRecordByKeyOrIdRequestSchema, { modelKey, identifier })
1377
+ );
1378
+ return resp.record ?? null;
1379
+ },
1380
+ async listRecords(params) {
1381
+ const resp = await client.listRecords(
1382
+ create3(ListRecordsRequestSchema, {
1383
+ modelKey: params.modelKey,
1384
+ limit: params.limit ?? 50,
1385
+ offset: params.offset ?? 0,
1386
+ customerId: params.customerId,
1387
+ search: params.search,
1388
+ filters: params.filters?.map(
1389
+ (f) => create3(RecordFilterSchema, {
1390
+ field: f.field,
1391
+ operator: f.operator
1392
+ })
1393
+ )
1394
+ })
1395
+ );
1396
+ return {
1397
+ items: resp.records ?? [],
1398
+ total: resp.total
1399
+ };
1400
+ },
1401
+ async updateRecord(params) {
1402
+ const resp = await client.updateRecord(
1403
+ create3(UpdateRecordRequestSchema, {
1404
+ id: params.id,
1405
+ data: sanitizeData(params.data),
1406
+ naturalKey: params.naturalKey
1407
+ })
1408
+ );
1409
+ return resp.record ?? null;
1410
+ },
1411
+ async deleteRecord(id) {
1412
+ const resp = await client.deleteRecord(
1413
+ create3(DeleteRecordRequestSchema, { id })
1414
+ );
1415
+ return resp.success;
1416
+ },
1417
+ async duplicateRecord(id, newNaturalKey) {
1418
+ const resp = await client.duplicateRecord(
1419
+ create3(DuplicateRecordRequestSchema, { id, newNaturalKey })
1420
+ );
1421
+ return resp.record ?? null;
1422
+ },
1423
+ async duplicateRecordsBulk(ids, modelKey) {
1424
+ const resp = await client.duplicateRecordsBulk(
1425
+ create3(DuplicateRecordsBulkRequestSchema, { ids, modelKey })
1426
+ );
1427
+ return resp.records ?? [];
1428
+ },
1429
+ async batchRecordOperations(operations) {
1430
+ const typeMap = { create: 1, update: 2, delete: 3 };
1431
+ const resp = await client.batchRecordOperations(
1432
+ create3(BatchRecordOperationsRequestSchema, {
1433
+ operations: operations.map(
1434
+ (op) => create3(BatchOperationSchema, {
1435
+ type: typeMap[op.type],
1436
+ id: op.id,
1437
+ modelKey: op.modelKey,
1438
+ naturalKey: op.naturalKey,
1439
+ data: op.data ? sanitizeData(
1440
+ op.data
1441
+ ) : void 0,
1442
+ customerId: op.customerId
1443
+ })
1444
+ )
1445
+ })
1446
+ );
1447
+ return resp.results ?? [];
1448
+ },
1449
+ async bulkUpdateRecords(params) {
1450
+ const resp = await client.bulkUpdateRecords(
1451
+ create3(BulkUpdateRecordsRequestSchema, {
1452
+ modelKey: params.modelKey,
1453
+ data: sanitizeData(params.data)
1454
+ })
1455
+ );
1456
+ return { count: resp.count };
1457
+ },
1458
+ // ── Versioning ────────────────────────────────────────────
1459
+ async createVersion(parentId, data, changeDescription) {
1460
+ const resp = await client.createVersion(
1461
+ create3(CreateVersionRequestSchema, {
1462
+ parentId,
1463
+ data: data ? sanitizeData(data) : void 0,
1464
+ changeDescription
1465
+ })
1466
+ );
1467
+ return resp.version ?? null;
1468
+ },
1469
+ async publishVersion(versionId) {
1470
+ const resp = await client.publishVersion(
1471
+ create3(PublishVersionRequestSchema, { versionId })
1472
+ );
1473
+ return resp.record ?? null;
1474
+ },
1475
+ async unpublishRecord(recordId) {
1476
+ const resp = await client.unpublishRecord(
1477
+ create3(UnpublishRecordRequestSchema, { recordId })
1478
+ );
1479
+ return resp.success;
1480
+ },
1481
+ async revertToVersion(versionId) {
1482
+ const resp = await client.revertToVersion(
1483
+ create3(RevertToVersionRequestSchema, { versionId })
1484
+ );
1485
+ return resp.record ?? null;
1486
+ },
1487
+ async listRecordVersions(parentId, params) {
1488
+ const resp = await client.listRecordVersions(
1489
+ create3(ListRecordVersionsRequestSchema, {
1490
+ parentId,
1491
+ limit: params?.limit ?? 50,
1492
+ offset: params?.offset ?? 0
1493
+ })
1494
+ );
1495
+ return {
1496
+ items: resp.versions ?? [],
1497
+ total: resp.total
1498
+ };
1499
+ },
1500
+ async saveContent(params) {
1501
+ const resp = await client.saveContent(
1502
+ create3(SaveContentRequestSchema, {
1503
+ recordId: params.recordId,
1504
+ data: sanitizeData(params.data),
1505
+ variantKey: params.variantKey,
1506
+ changeDescription: params.changeDescription
1507
+ })
1508
+ );
1509
+ return {
1510
+ record: resp.record ?? null,
1511
+ version: resp.version ?? null
1512
+ };
1513
+ },
1514
+ // ── Variants ──────────────────────────────────────────────
1515
+ async createVariant(recordId, variantKey, data) {
1516
+ const resp = await client.createVariant(
1517
+ create3(CreateVariantRequestSchema, {
1518
+ recordId,
1519
+ variantKey,
1520
+ data: data ? sanitizeData(data) : void 0
1521
+ })
1522
+ );
1523
+ return resp.variant ?? null;
1524
+ },
1525
+ async updateVariant(variantId, data) {
1526
+ const resp = await client.updateVariant(
1527
+ create3(UpdateVariantRequestSchema, {
1528
+ variantId,
1529
+ data: sanitizeData(data)
1530
+ })
1531
+ );
1532
+ return resp.variant ?? null;
1533
+ },
1534
+ async deleteVariant(variantId) {
1535
+ const resp = await client.deleteVariant(
1536
+ create3(DeleteVariantRequestSchema, { variantId })
1537
+ );
1538
+ return resp.success;
1539
+ },
1540
+ async setDefaultVariant(recordId, variantId) {
1541
+ const resp = await client.setDefaultVariant(
1542
+ create3(SetDefaultVariantRequestSchema, { recordId, variantId })
1543
+ );
1544
+ return resp.record ?? null;
1545
+ },
1546
+ async listRecordVariants(recordId, params) {
1547
+ const resp = await client.listRecordVariants(
1548
+ create3(ListRecordVariantsRequestSchema, {
1549
+ recordId,
1550
+ limit: params?.limit ?? 50,
1551
+ offset: params?.offset ?? 0
1552
+ })
1553
+ );
1554
+ return {
1555
+ items: resp.variants ?? [],
1556
+ total: resp.total
1557
+ };
1558
+ },
1559
+ // ── Scheduling ────────────────────────────────────────────
1560
+ async scheduleRecordPublish(versionId, publishAt, unpublishAt) {
1561
+ const resp = await client.scheduleRecordPublish(
1562
+ create3(ScheduleRecordPublishRequestSchema, {
1563
+ versionId,
1564
+ publishAt: {
1565
+ seconds: BigInt(Math.floor(publishAt.getTime() / 1e3)),
1566
+ nanos: 0
1567
+ },
1568
+ unpublishAt: unpublishAt ? {
1569
+ seconds: BigInt(Math.floor(unpublishAt.getTime() / 1e3)),
1570
+ nanos: 0
1571
+ } : void 0
1572
+ })
1573
+ );
1574
+ return resp.version ?? null;
1575
+ },
1576
+ async cancelScheduledRecordPublish(versionId) {
1577
+ const resp = await client.cancelScheduledRecordPublish(
1578
+ create3(CancelScheduledRecordPublishRequestSchema, { versionId })
1579
+ );
1580
+ return resp.version ?? null;
1581
+ },
1582
+ async listScheduledPublishes(params) {
1583
+ const resp = await client.listScheduledPublishes(
1584
+ create3(ListScheduledPublishesRequestSchema, {
1585
+ from: params?.from ? {
1586
+ seconds: BigInt(Math.floor(params.from.getTime() / 1e3)),
1587
+ nanos: 0
1588
+ } : void 0,
1589
+ to: params?.to ? {
1590
+ seconds: BigInt(Math.floor(params.to.getTime() / 1e3)),
1591
+ nanos: 0
1592
+ } : void 0,
1593
+ modelKey: params?.modelKey,
1594
+ limit: params?.limit ?? 50,
1595
+ offset: params?.offset ?? 0
1596
+ })
1597
+ );
1598
+ return {
1599
+ items: resp.versions ?? [],
1600
+ total: resp.total
1601
+ };
1602
+ },
1603
+ async listDraftVersions(params) {
1604
+ const resp = await client.listDraftVersions(
1605
+ create3(ListDraftVersionsRequestSchema, {
1606
+ modelKey: params?.modelKey,
1607
+ search: params?.search,
1608
+ limit: params?.limit ?? 50,
1609
+ offset: params?.offset ?? 0
1610
+ })
1611
+ );
1612
+ return {
1613
+ items: resp.versions ?? [],
1614
+ total: resp.total
1615
+ };
1616
+ },
1617
+ // ── Batch Publishing ──────────────────────────────────────
1618
+ async batchPublishVersions(versionIds) {
1619
+ const resp = await client.batchPublishVersions(
1620
+ create3(BatchPublishVersionsRequestSchema, { versionIds })
1621
+ );
1622
+ return {
1623
+ records: resp.records ?? [],
1624
+ publishedCount: resp.publishedCount
1625
+ };
1626
+ },
1627
+ // ── Publish Batches ───────────────────────────────────────
1628
+ async createPublishBatch(params) {
1629
+ const resp = await client.createPublishBatch(
1630
+ create3(CreatePublishBatchRequestSchema, {
1631
+ name: params.name,
1632
+ versionIds: params.versionIds,
1633
+ scheduledAt: params.scheduledAt ? {
1634
+ seconds: BigInt(
1635
+ Math.floor(params.scheduledAt.getTime() / 1e3)
1636
+ ),
1637
+ nanos: 0
1638
+ } : void 0
1639
+ })
1640
+ );
1641
+ return resp.batch ?? null;
1642
+ },
1643
+ async updatePublishBatch(params) {
1644
+ const resp = await client.updatePublishBatch(
1645
+ create3(UpdatePublishBatchRequestSchema, {
1646
+ batchId: params.batchId,
1647
+ name: params.name,
1648
+ scheduledAt: params.scheduledAt ? {
1649
+ seconds: BigInt(
1650
+ Math.floor(params.scheduledAt.getTime() / 1e3)
1651
+ ),
1652
+ nanos: 0
1653
+ } : void 0
1654
+ })
1655
+ );
1656
+ return resp.batch ?? null;
1657
+ },
1658
+ async cancelPublishBatch(batchId) {
1659
+ const resp = await client.cancelPublishBatch(
1660
+ create3(CancelPublishBatchRequestSchema, { batchId })
1661
+ );
1662
+ return resp.batch ?? null;
1663
+ },
1664
+ async rollbackPublishBatch(batchId) {
1665
+ const resp = await client.rollbackPublishBatch(
1666
+ create3(RollbackPublishBatchRequestSchema, { batchId })
1667
+ );
1668
+ return resp.batch ?? null;
1669
+ },
1670
+ async retryFailedBatchItems(batchId) {
1671
+ const resp = await client.retryFailedBatchItems(
1672
+ create3(RetryFailedBatchItemsRequestSchema, { batchId })
1673
+ );
1674
+ return {
1675
+ batch: resp.batch ?? null,
1676
+ retriedCount: resp.retriedCount
1677
+ };
1678
+ },
1679
+ async addItemsToPublishBatch(batchId, versionIds) {
1680
+ const resp = await client.addItemsToPublishBatch(
1681
+ create3(AddItemsToPublishBatchRequestSchema, { batchId, versionIds })
1682
+ );
1683
+ return resp.batch ?? null;
1684
+ },
1685
+ async removeItemsFromPublishBatch(batchId, versionIds) {
1686
+ const resp = await client.removeItemsFromPublishBatch(
1687
+ create3(RemoveItemsFromPublishBatchRequestSchema, {
1688
+ batchId,
1689
+ versionIds
1690
+ })
1691
+ );
1692
+ return resp.batch ?? null;
1693
+ },
1694
+ async listPublishBatches(params) {
1695
+ const resp = await client.listPublishBatches(
1696
+ create3(ListPublishBatchesRequestSchema, {
1697
+ status: params?.status,
1698
+ from: params?.from ? {
1699
+ seconds: BigInt(Math.floor(params.from.getTime() / 1e3)),
1700
+ nanos: 0
1701
+ } : void 0,
1702
+ to: params?.to ? {
1703
+ seconds: BigInt(Math.floor(params.to.getTime() / 1e3)),
1704
+ nanos: 0
1705
+ } : void 0,
1706
+ limit: params?.limit ?? 50,
1707
+ offset: params?.offset ?? 0
1708
+ })
1709
+ );
1710
+ return {
1711
+ items: resp.batches ?? [],
1712
+ total: resp.total
1713
+ };
1714
+ },
1715
+ async getPublishBatch(batchId) {
1716
+ const resp = await client.getPublishBatch(
1717
+ create3(GetPublishBatchRequestSchema, { batchId })
1718
+ );
1719
+ return {
1720
+ batch: resp.batch ?? null,
1721
+ versions: resp.versions ?? []
1722
+ };
1723
+ },
1724
+ // ── Search & Embeddings ──────────────────────────────────
1725
+ async globalSearch(params) {
1726
+ const resp = await client.globalSearch(
1727
+ create3(GlobalSearchRequestSchema, {
1728
+ query: params.query,
1729
+ modelKeys: params.modelKeys ?? [],
1730
+ limit: params.limit ?? 20
1731
+ })
1732
+ );
1733
+ return {
1734
+ items: resp.records ?? [],
1735
+ total: resp.total
1736
+ };
1737
+ },
1738
+ async getEmbeddingStats(modelKey) {
1739
+ const resp = await client.getEmbeddingStats(
1740
+ create3(GetEmbeddingStatsRequestSchema, {
1741
+ modelKey
1742
+ })
1743
+ );
1744
+ return resp.stats ?? [];
1745
+ },
1746
+ async getRecordEmbeddings(recordId) {
1747
+ const resp = await client.getRecordEmbeddings(
1748
+ create3(GetRecordEmbeddingsRequestSchema, { recordId })
1749
+ );
1750
+ return resp.embeddings ?? [];
1751
+ },
1752
+ async findSimilarRecords(params) {
1753
+ const resp = await client.findSimilarRecords(
1754
+ create3(FindSimilarRecordsRequestSchema, {
1755
+ recordId: params.recordId,
1756
+ modelKey: params.modelKey,
1757
+ limit: params.limit ?? 10
1758
+ })
1759
+ );
1760
+ return resp.records ?? [];
1761
+ }
1762
+ };
1763
+ }
1764
+
1765
+ // src/lib/rpc/configs.ts
1766
+ import { create as create4 } from "@bufbuild/protobuf";
1767
+ import {
1768
+ CreateConfigRequestSchema,
1769
+ GetConfigRequestSchema,
1770
+ GetConfigByKeyRequestSchema,
1771
+ ListConfigsRequestSchema,
1772
+ UpdateConfigRequestSchema,
1773
+ DeleteConfigRequestSchema,
1774
+ ConfigDirection,
1775
+ ListOperationsRequestSchema,
1776
+ ApplyConfigRequestSchema
1777
+ } from "@eide/foir-proto-ts/configs/v1/configs_pb";
1778
+ import { ConfigDirection as ConfigDirection2 } from "@eide/foir-proto-ts/configs/v1/configs_pb";
1779
+ var DIRECTION_TO_PROTO = {
1780
+ read: ConfigDirection.READ,
1781
+ write: ConfigDirection.WRITE,
1782
+ bidirectional: ConfigDirection.BIDIRECTIONAL
1783
+ };
1784
+ function createConfigsMethods(client) {
1785
+ return {
1786
+ // ── Operations ────────────────────────────────────────────
1787
+ async listOperations(params = {}) {
1788
+ return client.listOperations(
1789
+ create4(ListOperationsRequestSchema, {
1790
+ category: params.category,
1791
+ isActive: params.isActive,
1792
+ search: params.search,
1793
+ limit: params.limit ?? 50,
1794
+ offset: params.offset ?? 0
1795
+ })
1796
+ );
1797
+ },
1798
+ // ── Queries ──────────────────────────────────────────────
1799
+ async getConfig(id) {
1800
+ const resp = await client.getConfig(
1801
+ create4(GetConfigRequestSchema, { id })
1802
+ );
1803
+ return resp.config ?? null;
1804
+ },
1805
+ async getConfigByKey(key) {
1806
+ const resp = await client.getConfigByKey(
1807
+ create4(GetConfigByKeyRequestSchema, { key })
1808
+ );
1809
+ return resp.config ?? null;
1810
+ },
1811
+ async listConfigs(params = {}) {
1812
+ return client.listConfigs(
1813
+ create4(ListConfigsRequestSchema, {
1814
+ configType: params.configType,
1815
+ enabled: params.enabled,
1816
+ limit: params.limit ?? 50,
1817
+ offset: params.offset ?? 0
1818
+ })
1819
+ );
1820
+ },
1821
+ // ── Mutations ────────────────────────────────────────────
1822
+ async createConfig(params) {
1823
+ const resp = await client.createConfig(
1824
+ create4(CreateConfigRequestSchema, {
1825
+ key: params.key,
1826
+ configType: params.configType,
1827
+ direction: DIRECTION_TO_PROTO[params.direction ?? "read"] ?? ConfigDirection.READ,
1828
+ name: params.name,
1829
+ description: params.description,
1830
+ config: params.config,
1831
+ enabled: params.enabled
1832
+ })
1833
+ );
1834
+ return resp.config ?? null;
1835
+ },
1836
+ async updateConfig(params) {
1837
+ const resp = await client.updateConfig(
1838
+ create4(UpdateConfigRequestSchema, {
1839
+ id: params.id,
1840
+ name: params.name,
1841
+ description: params.description,
1842
+ config: params.config,
1843
+ enabled: params.enabled,
1844
+ webhooks: params.webhooks,
1845
+ hooks: params.hooks
1846
+ })
1847
+ );
1848
+ return resp.config ?? null;
1849
+ },
1850
+ async applyConfig(configKey, configData) {
1851
+ const resp = await client.applyConfig(
1852
+ create4(ApplyConfigRequestSchema, {
1853
+ configKey,
1854
+ configData
1855
+ })
1856
+ );
1857
+ return resp.config ?? null;
1858
+ },
1859
+ async deleteConfig(id) {
1860
+ const resp = await client.deleteConfig(
1861
+ create4(DeleteConfigRequestSchema, { id })
1862
+ );
1863
+ return resp.success;
1864
+ }
1865
+ };
1866
+ }
1867
+
1868
+ // src/lib/rpc/segments.ts
1869
+ import { create as create5 } from "@bufbuild/protobuf";
1870
+ import {
1871
+ CreateSegmentRequestSchema,
1872
+ GetSegmentRequestSchema,
1873
+ GetSegmentByKeyRequestSchema,
1874
+ ListSegmentsRequestSchema,
1875
+ UpdateSegmentRequestSchema,
1876
+ DeleteSegmentRequestSchema,
1877
+ GetCustomerMembershipsRequestSchema,
1878
+ PreviewSegmentRulesRequestSchema,
1879
+ TestSegmentEvaluationRequestSchema,
1880
+ SetGlobalOptOutRequestSchema,
1881
+ OptOutOfSegmentRequestSchema,
1882
+ OptBackIntoSegmentRequestSchema
1883
+ } from "@eide/foir-proto-ts/segments/v1/segments_pb";
1884
+ function createSegmentsMethods(client) {
1885
+ return {
1886
+ // ── Queries ──────────────────────────────────────────────
1887
+ async getSegment(id) {
1888
+ const resp = await client.getSegment(
1889
+ create5(GetSegmentRequestSchema, { id })
1890
+ );
1891
+ return resp.segment ?? null;
1892
+ },
1893
+ async getSegmentByKey(key) {
1894
+ const resp = await client.getSegmentByKey(
1895
+ create5(GetSegmentByKeyRequestSchema, { key })
1896
+ );
1897
+ return resp.segment ?? null;
1898
+ },
1899
+ async listSegments(params = {}) {
1900
+ return client.listSegments(
1901
+ create5(ListSegmentsRequestSchema, {
1902
+ isActive: params.isActive,
1903
+ limit: params.limit ?? 50,
1904
+ offset: params.offset ?? 0
1905
+ })
1906
+ );
1907
+ },
1908
+ // ── Mutations ────────────────────────────────────────────
1909
+ async createSegment(params) {
1910
+ const resp = await client.createSegment(
1911
+ create5(CreateSegmentRequestSchema, {
1912
+ key: params.key,
1913
+ name: params.name,
1914
+ description: params.description,
1915
+ rules: params.rules,
1916
+ evaluationMode: params.evaluationMode,
1917
+ isActive: params.isActive
1918
+ })
1919
+ );
1920
+ return resp.segment ?? null;
1921
+ },
1922
+ async updateSegment(params) {
1923
+ const resp = await client.updateSegment(
1924
+ create5(UpdateSegmentRequestSchema, {
1925
+ id: params.id,
1926
+ name: params.name,
1927
+ description: params.description,
1928
+ rules: params.rules,
1929
+ evaluationMode: params.evaluationMode,
1930
+ isActive: params.isActive
1931
+ })
1932
+ );
1933
+ return resp.segment ?? null;
1934
+ },
1935
+ async deleteSegment(id) {
1936
+ const resp = await client.deleteSegment(
1937
+ create5(DeleteSegmentRequestSchema, { id })
1938
+ );
1939
+ return resp.success;
1940
+ },
1941
+ // ── Customer Operations ──────────────────────────────────
1942
+ async getCustomerMemberships(customerId) {
1943
+ return client.getCustomerMemberships(
1944
+ create5(GetCustomerMembershipsRequestSchema, { customerId })
1945
+ );
1946
+ },
1947
+ async previewSegmentRules(rules, sampleSize) {
1948
+ const resp = await client.previewSegmentRules(
1949
+ create5(PreviewSegmentRulesRequestSchema, {
1950
+ rules,
1951
+ sampleSize: sampleSize ?? 10
1952
+ })
1953
+ );
1954
+ return resp.preview ?? null;
1955
+ },
1956
+ async testSegmentEvaluation(segmentId, customerId) {
1957
+ const resp = await client.testSegmentEvaluation(
1958
+ create5(TestSegmentEvaluationRequestSchema, { segmentId, customerId })
1959
+ );
1960
+ return resp.result ?? null;
1961
+ },
1962
+ // ── Opt-out Management ───────────────────────────────────
1963
+ async setGlobalOptOut(customerId, optedOut) {
1964
+ const resp = await client.setGlobalOptOut(
1965
+ create5(SetGlobalOptOutRequestSchema, { customerId, optedOut })
1966
+ );
1967
+ return resp.success;
1968
+ },
1969
+ async optOutOfSegment(customerId, segmentId) {
1970
+ const resp = await client.optOutOfSegment(
1971
+ create5(OptOutOfSegmentRequestSchema, { customerId, segmentId })
1972
+ );
1973
+ return resp.success;
1974
+ },
1975
+ async optBackIntoSegment(customerId, segmentId) {
1976
+ const resp = await client.optBackIntoSegment(
1977
+ create5(OptBackIntoSegmentRequestSchema, { customerId, segmentId })
1978
+ );
1979
+ return resp.success;
1980
+ }
1981
+ };
1982
+ }
1983
+
1984
+ // src/lib/rpc/experiments.ts
1985
+ import { create as create6 } from "@bufbuild/protobuf";
1986
+ import {
1987
+ ExperimentStatus,
1988
+ CreateExperimentRequestSchema,
1989
+ GetExperimentRequestSchema,
1990
+ GetExperimentByKeyRequestSchema,
1991
+ ListExperimentsRequestSchema,
1992
+ UpdateExperimentRequestSchema,
1993
+ DeleteExperimentRequestSchema,
1994
+ StartExperimentRequestSchema,
1995
+ PauseExperimentRequestSchema,
1996
+ ResumeExperimentRequestSchema,
1997
+ EndExperimentRequestSchema,
1998
+ GetExperimentStatsRequestSchema,
1999
+ ForceAssignExperimentRequestSchema,
2000
+ RemoveExperimentAssignmentRequestSchema,
2001
+ ApplyExperimentWinnerRequestSchema,
2002
+ GetCustomerAssignmentsRequestSchema,
2003
+ ExperimentVariantSchema
2004
+ } from "@eide/foir-proto-ts/experiments/v1/experiments_pb";
2005
+ import { ExperimentStatus as ExperimentStatus2 } from "@eide/foir-proto-ts/experiments/v1/experiments_pb";
2006
+ var STATUS_TO_PROTO = {
2007
+ draft: ExperimentStatus.DRAFT,
2008
+ running: ExperimentStatus.RUNNING,
2009
+ paused: ExperimentStatus.PAUSED,
2010
+ ended: ExperimentStatus.COMPLETED,
2011
+ completed: ExperimentStatus.COMPLETED
2012
+ };
2013
+ function createExperimentsMethods(client) {
2014
+ return {
2015
+ // ── Queries ──────────────────────────────────────────────
2016
+ async getExperiment(id) {
2017
+ const resp = await client.getExperiment(
2018
+ create6(GetExperimentRequestSchema, { id })
2019
+ );
2020
+ return resp.experiment ?? null;
2021
+ },
2022
+ async getExperimentByKey(key) {
2023
+ const resp = await client.getExperimentByKey(
2024
+ create6(GetExperimentByKeyRequestSchema, { key })
2025
+ );
2026
+ return resp.experiment ?? null;
2027
+ },
2028
+ async listExperiments(params = {}) {
2029
+ return client.listExperiments(
2030
+ create6(ListExperimentsRequestSchema, {
2031
+ status: params.status ? STATUS_TO_PROTO[params.status] : void 0,
2032
+ isActive: params.isActive,
2033
+ limit: params.limit ?? 50,
2034
+ offset: params.offset ?? 0
2035
+ })
2036
+ );
2037
+ },
2038
+ async getExperimentStats(experimentId) {
2039
+ const resp = await client.getExperimentStats(
2040
+ create6(GetExperimentStatsRequestSchema, { experimentId })
2041
+ );
2042
+ return resp.stats ?? null;
2043
+ },
2044
+ // ── Mutations ────────────────────────────────────────────
2045
+ async createExperiment(params) {
2046
+ const resp = await client.createExperiment(
2047
+ create6(CreateExperimentRequestSchema, {
2048
+ key: params.key,
2049
+ name: params.name,
2050
+ description: params.description,
2051
+ targeting: params.targeting,
2052
+ controlPercent: params.controlPercent,
2053
+ variants: params.variants?.map(
2054
+ (v) => create6(ExperimentVariantSchema, {
2055
+ key: v.key,
2056
+ name: v.name,
2057
+ percent: v.percent
2058
+ })
2059
+ ) ?? []
2060
+ })
2061
+ );
2062
+ return resp.experiment ?? null;
2063
+ },
2064
+ async updateExperiment(params) {
2065
+ const resp = await client.updateExperiment(
2066
+ create6(UpdateExperimentRequestSchema, {
2067
+ id: params.id,
2068
+ name: params.name,
2069
+ description: params.description,
2070
+ targeting: params.targeting,
2071
+ controlPercent: params.controlPercent,
2072
+ variants: params.variants?.map(
2073
+ (v) => create6(ExperimentVariantSchema, {
2074
+ key: v.key,
2075
+ name: v.name,
2076
+ percent: v.percent
2077
+ })
2078
+ )
2079
+ })
2080
+ );
2081
+ return resp.experiment ?? null;
2082
+ },
2083
+ async deleteExperiment(id) {
2084
+ const resp = await client.deleteExperiment(
2085
+ create6(DeleteExperimentRequestSchema, { id })
2086
+ );
2087
+ return resp.success;
2088
+ },
2089
+ // ── Lifecycle ────────────────────────────────────────────
2090
+ async startExperiment(experimentId) {
2091
+ const resp = await client.startExperiment(
2092
+ create6(StartExperimentRequestSchema, { experimentId })
2093
+ );
2094
+ return resp.experiment ?? null;
2095
+ },
2096
+ async pauseExperiment(experimentId) {
2097
+ const resp = await client.pauseExperiment(
2098
+ create6(PauseExperimentRequestSchema, { experimentId })
2099
+ );
2100
+ return resp.experiment ?? null;
2101
+ },
2102
+ async resumeExperiment(experimentId) {
2103
+ const resp = await client.resumeExperiment(
2104
+ create6(ResumeExperimentRequestSchema, { experimentId })
2105
+ );
2106
+ return resp.experiment ?? null;
2107
+ },
2108
+ async endExperiment(experimentId) {
2109
+ const resp = await client.endExperiment(
2110
+ create6(EndExperimentRequestSchema, { experimentId })
2111
+ );
2112
+ return resp.experiment ?? null;
2113
+ },
2114
+ async applyExperimentWinner(experimentId, winnerVariantKey) {
2115
+ const resp = await client.applyExperimentWinner(
2116
+ create6(ApplyExperimentWinnerRequestSchema, {
2117
+ experimentId,
2118
+ winnerVariantKey
2119
+ })
2120
+ );
2121
+ return resp.experiment ?? null;
2122
+ },
2123
+ // ── Assignments ──────────────────────────────────────────
2124
+ async forceAssignExperiment(customerId, experimentId, variantKey) {
2125
+ const resp = await client.forceAssignExperiment(
2126
+ create6(ForceAssignExperimentRequestSchema, {
2127
+ customerId,
2128
+ experimentId,
2129
+ variantKey
2130
+ })
2131
+ );
2132
+ return resp.assignment ?? null;
2133
+ },
2134
+ async removeExperimentAssignment(customerId, experimentId) {
2135
+ const resp = await client.removeExperimentAssignment(
2136
+ create6(RemoveExperimentAssignmentRequestSchema, {
2137
+ customerId,
2138
+ experimentId
2139
+ })
2140
+ );
2141
+ return resp.success;
2142
+ },
2143
+ async getCustomerAssignments(customerId) {
2144
+ const resp = await client.getCustomerAssignments(
2145
+ create6(GetCustomerAssignmentsRequestSchema, { customerId })
2146
+ );
2147
+ return resp.assignments ?? [];
2148
+ }
2149
+ };
2150
+ }
2151
+
2152
+ // src/lib/rpc/settings.ts
2153
+ import { create as create7 } from "@bufbuild/protobuf";
2154
+ import {
2155
+ GetSettingsRequestSchema,
2156
+ UpdateSettingRequestSchema,
2157
+ ListContextDimensionsRequestSchema,
2158
+ GetContextDimensionRequestSchema,
2159
+ CreateContextDimensionRequestSchema,
2160
+ UpdateContextDimensionRequestSchema,
2161
+ DeleteContextDimensionRequestSchema,
2162
+ GetContextDimensionValuesRequestSchema,
2163
+ GetCustomerProfileSchemaRequestSchema,
2164
+ GetCustomerProfileRequestSchema,
2165
+ SetCustomerProfileRequestSchema,
2166
+ UpdateCustomerProfileSchemaRequestSchema,
2167
+ GetCustomerResolutionAttributesRequestSchema,
2168
+ GetEditorConfigsRequestSchema,
2169
+ ListEmailActionsRequestSchema,
2170
+ ListResendTemplatesRequestSchema,
2171
+ UpdateEmailActionRequestSchema,
2172
+ ListVariantCatalogRequestSchema,
2173
+ GetVariantCatalogEntryRequestSchema,
2174
+ CreateVariantCatalogEntryRequestSchema,
2175
+ UpdateVariantCatalogEntryRequestSchema,
2176
+ DeleteVariantCatalogEntryRequestSchema,
2177
+ CreateNoteRequestSchema,
2178
+ GetNoteRequestSchema,
2179
+ ListNotesRequestSchema,
2180
+ UpdateNoteRequestSchema,
2181
+ DeleteNoteRequestSchema,
2182
+ ListMyMentionsRequestSchema,
2183
+ UpdateMentionStatusRequestSchema,
2184
+ ListLocalesRequestSchema,
2185
+ GetLocaleRequestSchema,
2186
+ CreateLocaleRequestSchema,
2187
+ UpdateLocaleRequestSchema,
2188
+ DeleteLocaleRequestSchema,
2189
+ GetNavPreferencesRequestSchema,
2190
+ UpdateNavPreferencesRequestSchema,
2191
+ ListRecentlyOpenedRequestSchema,
2192
+ TrackRecentlyOpenedRequestSchema,
2193
+ RemoveRecentlyOpenedRequestSchema,
2194
+ ClearRecentlyOpenedRequestSchema
2195
+ } from "@eide/foir-proto-ts/settings/v1/settings_pb";
2196
+ function createSettingsMethods(client) {
2197
+ return {
2198
+ // ── Settings ─────────────────────────────────────────────
2199
+ async getSettings(params = {}) {
2200
+ const resp = await client.getSettings(
2201
+ create7(GetSettingsRequestSchema, {
2202
+ category: params.category,
2203
+ key: params.key
2204
+ })
2205
+ );
2206
+ return resp.settings ?? [];
2207
+ },
2208
+ async updateSetting(params) {
2209
+ const resp = await client.updateSetting(
2210
+ create7(UpdateSettingRequestSchema, {
2211
+ key: params.key,
2212
+ value: params.value
2213
+ })
2214
+ );
2215
+ return resp.setting ?? null;
2216
+ },
2217
+ // ── Mentions ─────────────────────────────────────────────
2218
+ async listMyMentions(params = {}) {
2219
+ return client.listMyMentions(
2220
+ create7(ListMyMentionsRequestSchema, {
2221
+ status: params.status ?? [],
2222
+ entityType: params.entityType,
2223
+ limit: params.limit ?? 50,
2224
+ offset: params.offset ?? 0
2225
+ })
2226
+ );
2227
+ },
2228
+ async updateMentionStatus(params) {
2229
+ const resp = await client.updateMentionStatus(
2230
+ create7(UpdateMentionStatusRequestSchema, {
2231
+ mentionId: params.mentionId,
2232
+ status: params.status,
2233
+ completedNote: params.completedNote,
2234
+ dismissReason: params.dismissReason
2235
+ })
2236
+ );
2237
+ return resp.mention ?? null;
2238
+ },
2239
+ // ── Notes ────────────────────────────────────────────────
2240
+ async createNote(params) {
2241
+ const resp = await client.createNote(
2242
+ create7(CreateNoteRequestSchema, {
2243
+ ...params,
2244
+ content: params.content
2245
+ })
2246
+ );
2247
+ return resp.note ?? null;
2248
+ },
2249
+ async getNote(id) {
2250
+ const resp = await client.getNote(create7(GetNoteRequestSchema, { id }));
2251
+ return resp.note ?? null;
2252
+ },
2253
+ async listNotes(params) {
2254
+ return client.listNotes(
2255
+ create7(ListNotesRequestSchema, {
2256
+ entityType: params.entityType,
2257
+ entityId: params.entityId,
2258
+ limit: params.limit ?? 50,
2259
+ offset: params.offset ?? 0
2260
+ })
2261
+ );
2262
+ },
2263
+ async updateNote(params) {
2264
+ const resp = await client.updateNote(
2265
+ create7(UpdateNoteRequestSchema, {
2266
+ id: params.id,
2267
+ content: params.content,
2268
+ isResolved: params.isResolved
2269
+ })
2270
+ );
2271
+ return resp.note ?? null;
2272
+ },
2273
+ async deleteNote(id) {
2274
+ const resp = await client.deleteNote(
2275
+ create7(DeleteNoteRequestSchema, { id })
2276
+ );
2277
+ return resp.success;
2278
+ },
2279
+ // ── Context Dimensions ───────────────────────────────────
2280
+ async listContextDimensions(params = {}) {
2281
+ return client.listContextDimensions(
2282
+ create7(ListContextDimensionsRequestSchema, {
2283
+ search: params.search,
2284
+ limit: params.limit ?? 50,
2285
+ offset: params.offset ?? 0
2286
+ })
2287
+ );
2288
+ },
2289
+ async getContextDimension(id) {
2290
+ const resp = await client.getContextDimension(
2291
+ create7(GetContextDimensionRequestSchema, { id })
2292
+ );
2293
+ return resp.dimension ?? null;
2294
+ },
2295
+ async createContextDimension(params) {
2296
+ const resp = await client.createContextDimension(
2297
+ create7(CreateContextDimensionRequestSchema, params)
2298
+ );
2299
+ return resp.dimension ?? null;
2300
+ },
2301
+ async updateContextDimension(params) {
2302
+ const resp = await client.updateContextDimension(
2303
+ create7(UpdateContextDimensionRequestSchema, params)
2304
+ );
2305
+ return resp.dimension ?? null;
2306
+ },
2307
+ async deleteContextDimension(id) {
2308
+ const resp = await client.deleteContextDimension(
2309
+ create7(DeleteContextDimensionRequestSchema, { id })
2310
+ );
2311
+ return resp.success;
2312
+ },
2313
+ async getContextDimensionValues(dimensionKey, params = {}) {
2314
+ return client.getContextDimensionValues(
2315
+ create7(GetContextDimensionValuesRequestSchema, {
2316
+ dimensionKey,
2317
+ search: params.search,
2318
+ limit: params.limit ?? 50,
2319
+ offset: params.offset ?? 0
2320
+ })
2321
+ );
2322
+ },
2323
+ // ── Customer Profile Schema ──────────────────────────────
2324
+ async getCustomerProfileSchema() {
2325
+ const resp = await client.getCustomerProfileSchema(
2326
+ create7(GetCustomerProfileSchemaRequestSchema, {})
2327
+ );
2328
+ return resp.schema ?? null;
2329
+ },
2330
+ async getCustomerProfile(customerId) {
2331
+ const resp = await client.getCustomerProfile(
2332
+ create7(GetCustomerProfileRequestSchema, { customerId })
2333
+ );
2334
+ return resp.data ?? null;
2335
+ },
2336
+ async setCustomerProfile(params) {
2337
+ const resp = await client.setCustomerProfile(
2338
+ create7(SetCustomerProfileRequestSchema, {
2339
+ customerId: params.customerId,
2340
+ data: params.data
2341
+ })
2342
+ );
2343
+ return resp.success;
2344
+ },
2345
+ async updateCustomerProfileSchema(params) {
2346
+ const resp = await client.updateCustomerProfileSchema(
2347
+ create7(UpdateCustomerProfileSchemaRequestSchema, {
2348
+ fields: params.fields.map((f) => ({
2349
+ id: f.id,
2350
+ key: f.key,
2351
+ type: f.type,
2352
+ label: f.label,
2353
+ required: f.required,
2354
+ helpText: f.helpText,
2355
+ placeholder: f.placeholder,
2356
+ config: f.config
2357
+ })),
2358
+ publicFields: params.publicFields
2359
+ })
2360
+ );
2361
+ return resp.schema ?? null;
2362
+ },
2363
+ async getCustomerResolutionAttributes(customerId) {
2364
+ return client.getCustomerResolutionAttributes(
2365
+ create7(GetCustomerResolutionAttributesRequestSchema, { customerId })
2366
+ );
2367
+ },
2368
+ async getEditorConfigs(modelKey) {
2369
+ const resp = await client.getEditorConfigs(
2370
+ create7(GetEditorConfigsRequestSchema, { modelKey })
2371
+ );
2372
+ return resp.placements ?? [];
2373
+ },
2374
+ // ── Variant Catalog ──────────────────────────────────────
2375
+ async listVariantCatalog(params = {}) {
2376
+ return client.listVariantCatalog(
2377
+ create7(ListVariantCatalogRequestSchema, {
2378
+ isActive: params.isActive,
2379
+ limit: params.limit ?? 50,
2380
+ offset: params.offset ?? 0
2381
+ })
2382
+ );
2383
+ },
2384
+ async getVariantCatalogEntry(id) {
2385
+ const resp = await client.getVariantCatalogEntry(
2386
+ create7(GetVariantCatalogEntryRequestSchema, { id })
2387
+ );
2388
+ return resp.entry ?? null;
2389
+ },
2390
+ async createVariantCatalogEntry(params) {
2391
+ const resp = await client.createVariantCatalogEntry(
2392
+ create7(CreateVariantCatalogEntryRequestSchema, {
2393
+ key: params.key,
2394
+ name: params.name,
2395
+ description: params.description,
2396
+ targetingRules: params.targetingRules,
2397
+ priority: params.priority,
2398
+ isDefault: params.isDefault,
2399
+ isActive: params.isActive
2400
+ })
2401
+ );
2402
+ return resp.entry ?? null;
2403
+ },
2404
+ async updateVariantCatalogEntry(params) {
2405
+ const resp = await client.updateVariantCatalogEntry(
2406
+ create7(UpdateVariantCatalogEntryRequestSchema, {
2407
+ id: params.id,
2408
+ name: params.name,
2409
+ description: params.description,
2410
+ targetingRules: params.targetingRules,
2411
+ priority: params.priority,
2412
+ isDefault: params.isDefault,
2413
+ isActive: params.isActive
2414
+ })
2415
+ );
2416
+ return resp.entry ?? null;
2417
+ },
2418
+ async deleteVariantCatalogEntry(id) {
2419
+ const resp = await client.deleteVariantCatalogEntry(
2420
+ create7(DeleteVariantCatalogEntryRequestSchema, { id })
2421
+ );
2422
+ return resp.success;
2423
+ },
2424
+ // ── Locales ──────────────────────────────────────────────
2425
+ async listLocales(params = {}) {
2426
+ return client.listLocales(
2427
+ create7(ListLocalesRequestSchema, {
2428
+ includeInactive: params.includeInactive,
2429
+ limit: params.limit ?? 50,
2430
+ offset: params.offset ?? 0
2431
+ })
2432
+ );
2433
+ },
2434
+ async getLocale(id) {
2435
+ const resp = await client.getLocale(
2436
+ create7(GetLocaleRequestSchema, { id })
2437
+ );
2438
+ return resp.locale ?? null;
2439
+ },
2440
+ async createLocale(params) {
2441
+ const resp = await client.createLocale(
2442
+ create7(CreateLocaleRequestSchema, {
2443
+ locale: params.locale,
2444
+ displayName: params.displayName,
2445
+ nativeName: params.nativeName,
2446
+ isDefault: params.isDefault,
2447
+ isRtl: params.isRtl,
2448
+ fallbackLocale: params.fallbackLocale
2449
+ })
2450
+ );
2451
+ return resp.locale ?? null;
2452
+ },
2453
+ async updateLocale(params) {
2454
+ const resp = await client.updateLocale(
2455
+ create7(UpdateLocaleRequestSchema, {
2456
+ id: params.id,
2457
+ displayName: params.displayName,
2458
+ nativeName: params.nativeName,
2459
+ isDefault: params.isDefault,
2460
+ isActive: params.isActive,
2461
+ isRtl: params.isRtl,
2462
+ fallbackLocale: params.fallbackLocale
2463
+ })
2464
+ );
2465
+ return resp.locale ?? null;
2466
+ },
2467
+ async deleteLocale(id) {
2468
+ const resp = await client.deleteLocale(
2469
+ create7(DeleteLocaleRequestSchema, { id })
2470
+ );
2471
+ return resp.success;
2472
+ },
2473
+ // ── Nav Preferences ─────────────────────────────────────
2474
+ async getNavPreferences() {
2475
+ const resp = await client.getNavPreferences(
2476
+ create7(GetNavPreferencesRequestSchema, {})
2477
+ );
2478
+ return resp.preferences ?? null;
2479
+ },
2480
+ async updateNavPreferences(params) {
2481
+ const resp = await client.updateNavPreferences(
2482
+ create7(UpdateNavPreferencesRequestSchema, {
2483
+ preferences: params.preferences ? {
2484
+ favoriteProjects: params.preferences.favoriteProjects,
2485
+ favoriteNavItems: params.preferences.favoriteNavItems,
2486
+ collapsedSections: params.preferences.collapsedSections,
2487
+ navItemOrder: params.preferences.navItemOrder
2488
+ } : void 0,
2489
+ toggleProjectId: params.toggleProjectId,
2490
+ toggleNavItem: params.toggleNavItem,
2491
+ toggleSection: params.toggleSection
2492
+ })
2493
+ );
2494
+ return resp.preferences ?? null;
2495
+ },
2496
+ // ── Recently Opened ─────────────────────────────────────
2497
+ async listRecentlyOpened(limit) {
2498
+ const resp = await client.listRecentlyOpened(
2499
+ create7(ListRecentlyOpenedRequestSchema, {
2500
+ limit: limit ?? 20
2501
+ })
2502
+ );
2503
+ return resp.items ?? [];
2504
+ },
2505
+ async trackRecentlyOpened(params) {
2506
+ const resp = await client.trackRecentlyOpened(
2507
+ create7(TrackRecentlyOpenedRequestSchema, {
2508
+ type: params.type,
2509
+ id: params.id,
2510
+ label: params.label,
2511
+ path: params.path
2512
+ })
2513
+ );
2514
+ return resp.success;
2515
+ },
2516
+ async removeRecentlyOpened(params) {
2517
+ const resp = await client.removeRecentlyOpened(
2518
+ create7(RemoveRecentlyOpenedRequestSchema, {
2519
+ type: params.type,
2520
+ id: params.id
2521
+ })
2522
+ );
2523
+ return resp.success;
2524
+ },
2525
+ async clearRecentlyOpened() {
2526
+ const resp = await client.clearRecentlyOpened(
2527
+ create7(ClearRecentlyOpenedRequestSchema, {})
2528
+ );
2529
+ return resp.success;
2530
+ },
2531
+ // ── Email Actions ──────────────────────────────────────────
2532
+ async listEmailActions(params = {}) {
2533
+ return client.listEmailActions(
2534
+ create7(ListEmailActionsRequestSchema, {
2535
+ limit: params.limit ?? 50,
2536
+ offset: params.offset ?? 0
2537
+ })
2538
+ );
2539
+ },
2540
+ async updateEmailAction(params) {
2541
+ const resp = await client.updateEmailAction(
2542
+ create7(UpdateEmailActionRequestSchema, {
2543
+ key: params.key,
2544
+ resendTemplateId: params.resendTemplateId,
2545
+ defaultFrom: params.defaultFrom,
2546
+ defaultSubject: params.defaultSubject,
2547
+ customData: params.customData,
2548
+ isActive: params.isActive
2549
+ })
2550
+ );
2551
+ return resp.action ?? null;
2552
+ },
2553
+ async listResendTemplates() {
2554
+ const resp = await client.listResendTemplates(
2555
+ create7(ListResendTemplatesRequestSchema, {})
2556
+ );
2557
+ return resp.templates ?? [];
2558
+ }
2559
+ };
2560
+ }
2561
+
2562
+ // src/lib/rpc/storage.ts
2563
+ import { create as create8 } from "@bufbuild/protobuf";
453
2564
  import {
454
- IdentityService,
455
- ModelsService,
456
- RecordsService,
457
- ConfigsService,
458
- SegmentsService,
459
- ExperimentsService,
460
- SettingsService,
461
- StorageService
462
- } from "@foir/connect-clients/services";
463
- import { createIdentityMethods } from "@foir/connect-clients/identity";
464
- import { createModelsMethods } from "@foir/connect-clients/models";
465
- import { createRecordsMethods } from "@foir/connect-clients/records";
466
- import { createConfigsMethods } from "@foir/connect-clients/configs";
467
- import { createSegmentsMethods } from "@foir/connect-clients/segments";
468
- import { createExperimentsMethods } from "@foir/connect-clients/experiments";
469
- import { createSettingsMethods } from "@foir/connect-clients/settings";
470
- import { createStorageMethods } from "@foir/connect-clients/storage";
2565
+ CreateFileUploadRequestSchema,
2566
+ ConfirmFileUploadRequestSchema,
2567
+ GetFileRequestSchema,
2568
+ ListFilesRequestSchema,
2569
+ GetStorageUsageRequestSchema,
2570
+ UpdateFileRequestSchema,
2571
+ UpdateFileMetadataRequestSchema,
2572
+ DeleteFileRequestSchema,
2573
+ PermanentlyDeleteFileRequestSchema,
2574
+ RestoreFileRequestSchema,
2575
+ TrackFileUsageRequestSchema,
2576
+ RemoveFileUsageRequestSchema,
2577
+ CleanupOrphanedFilesRequestSchema
2578
+ } from "@eide/foir-proto-ts/storage/v1/storage_pb";
2579
+ function createStorageMethods(client) {
2580
+ return {
2581
+ async createFileUpload(params) {
2582
+ return client.createFileUpload(
2583
+ create8(CreateFileUploadRequestSchema, {
2584
+ filename: params.filename,
2585
+ mimeType: params.mimeType,
2586
+ size: BigInt(params.size),
2587
+ folder: params.folder
2588
+ })
2589
+ );
2590
+ },
2591
+ async confirmFileUpload(uploadId) {
2592
+ const resp = await client.confirmFileUpload(
2593
+ create8(ConfirmFileUploadRequestSchema, { uploadId })
2594
+ );
2595
+ return resp.file ?? null;
2596
+ },
2597
+ async getFile(id) {
2598
+ const resp = await client.getFile(create8(GetFileRequestSchema, { id }));
2599
+ return resp.file ?? null;
2600
+ },
2601
+ async listFiles(params) {
2602
+ return client.listFiles(
2603
+ create8(ListFilesRequestSchema, {
2604
+ folder: params.folder,
2605
+ mimeType: params.mimeType,
2606
+ search: params.search,
2607
+ includeDeleted: params.includeDeleted ?? false,
2608
+ limit: params.limit ?? 50,
2609
+ offset: params.offset ?? 0
2610
+ })
2611
+ );
2612
+ },
2613
+ async getStorageUsage() {
2614
+ const resp = await client.getStorageUsage(
2615
+ create8(GetStorageUsageRequestSchema, {})
2616
+ );
2617
+ return resp.usage ?? null;
2618
+ },
2619
+ async updateFile(params) {
2620
+ const resp = await client.updateFile(
2621
+ create8(UpdateFileRequestSchema, {
2622
+ id: params.id,
2623
+ filename: params.filename,
2624
+ folder: params.folder,
2625
+ tags: params.tags ?? []
2626
+ })
2627
+ );
2628
+ return resp.file ?? null;
2629
+ },
2630
+ async updateFileMetadata(params) {
2631
+ const resp = await client.updateFileMetadata(
2632
+ create8(UpdateFileMetadataRequestSchema, {
2633
+ id: params.id,
2634
+ altText: params.altText,
2635
+ caption: params.caption,
2636
+ description: params.description
2637
+ })
2638
+ );
2639
+ return resp.file ?? null;
2640
+ },
2641
+ async deleteFile(id) {
2642
+ const resp = await client.deleteFile(
2643
+ create8(DeleteFileRequestSchema, { id })
2644
+ );
2645
+ return resp.success;
2646
+ },
2647
+ async permanentlyDeleteFile(id) {
2648
+ const resp = await client.permanentlyDeleteFile(
2649
+ create8(PermanentlyDeleteFileRequestSchema, { id })
2650
+ );
2651
+ return resp.success;
2652
+ },
2653
+ async restoreFile(id) {
2654
+ const resp = await client.restoreFile(
2655
+ create8(RestoreFileRequestSchema, { id })
2656
+ );
2657
+ return resp.file ?? null;
2658
+ },
2659
+ async trackFileUsage(fileId, entityType) {
2660
+ const resp = await client.trackFileUsage(
2661
+ create8(TrackFileUsageRequestSchema, { fileId, entityType })
2662
+ );
2663
+ return resp.file ?? null;
2664
+ },
2665
+ async removeFileUsage(fileId, entityType) {
2666
+ const resp = await client.removeFileUsage(
2667
+ create8(RemoveFileUsageRequestSchema, { fileId, entityType })
2668
+ );
2669
+ return resp.success;
2670
+ },
2671
+ async cleanupOrphanedFiles(params) {
2672
+ return client.cleanupOrphanedFiles(
2673
+ create8(CleanupOrphanedFilesRequestSchema, {
2674
+ orphanThresholdDays: params?.orphanThresholdDays ?? 30,
2675
+ dryRun: params?.dryRun ?? false,
2676
+ limit: params?.limit ?? 100
2677
+ })
2678
+ );
2679
+ }
2680
+ };
2681
+ }
2682
+
2683
+ // src/lib/client.ts
2684
+ import { GraphQLClient } from "graphql-request";
471
2685
  async function createPlatformClient(options) {
472
2686
  const apiUrl = getApiUrl(options);
473
2687
  const headers = {};
@@ -503,16 +2717,16 @@ async function createPlatformClient(options) {
503
2717
  interceptors: [authInterceptor]
504
2718
  });
505
2719
  return {
506
- identity: createIdentityMethods(createClient(IdentityService, transport)),
507
- models: createModelsMethods(createClient(ModelsService, transport)),
508
- records: createRecordsMethods(createClient(RecordsService, transport)),
509
- configs: createConfigsMethods(createClient(ConfigsService, transport)),
510
- segments: createSegmentsMethods(createClient(SegmentsService, transport)),
2720
+ identity: createIdentityMethods(createRpcClient(IdentityService2, transport)),
2721
+ models: createModelsMethods(createRpcClient(ModelsService2, transport)),
2722
+ records: createRecordsMethods(createRpcClient(RecordsService2, transport)),
2723
+ configs: createConfigsMethods(createRpcClient(ConfigsService2, transport)),
2724
+ segments: createSegmentsMethods(createRpcClient(SegmentsService2, transport)),
511
2725
  experiments: createExperimentsMethods(
512
- createClient(ExperimentsService, transport)
2726
+ createRpcClient(ExperimentsService2, transport)
513
2727
  ),
514
- settings: createSettingsMethods(createClient(SettingsService, transport)),
515
- storage: createStorageMethods(createClient(StorageService, transport))
2728
+ settings: createSettingsMethods(createRpcClient(SettingsService2, transport)),
2729
+ storage: createStorageMethods(createRpcClient(StorageService2, transport))
516
2730
  };
517
2731
  }
518
2732
  function createPlatformClientWithHeaders(apiUrl, headers) {
@@ -528,16 +2742,16 @@ function createPlatformClientWithHeaders(apiUrl, headers) {
528
2742
  interceptors: [authInterceptor]
529
2743
  });
530
2744
  return {
531
- identity: createIdentityMethods(createClient(IdentityService, transport)),
532
- models: createModelsMethods(createClient(ModelsService, transport)),
533
- records: createRecordsMethods(createClient(RecordsService, transport)),
534
- configs: createConfigsMethods(createClient(ConfigsService, transport)),
535
- segments: createSegmentsMethods(createClient(SegmentsService, transport)),
2745
+ identity: createIdentityMethods(createRpcClient(IdentityService2, transport)),
2746
+ models: createModelsMethods(createRpcClient(ModelsService2, transport)),
2747
+ records: createRecordsMethods(createRpcClient(RecordsService2, transport)),
2748
+ configs: createConfigsMethods(createRpcClient(ConfigsService2, transport)),
2749
+ segments: createSegmentsMethods(createRpcClient(SegmentsService2, transport)),
536
2750
  experiments: createExperimentsMethods(
537
- createClient(ExperimentsService, transport)
2751
+ createRpcClient(ExperimentsService2, transport)
538
2752
  ),
539
- settings: createSettingsMethods(createClient(SettingsService, transport)),
540
- storage: createStorageMethods(createClient(StorageService, transport))
2753
+ settings: createSettingsMethods(createRpcClient(SettingsService2, transport)),
2754
+ storage: createStorageMethods(createRpcClient(StorageService2, transport))
541
2755
  };
542
2756
  }
543
2757
  async function getStorageAuth(options) {
@@ -872,7 +3086,9 @@ function registerWhoamiCommand(program2, globalOpts) {
872
3086
  import { promises as fs2 } from "fs";
873
3087
  import { basename } from "path";
874
3088
  import chalk3 from "chalk";
875
- import { createStorageClient } from "@foir/connect-clients/storage";
3089
+ import { createClient } from "@connectrpc/connect";
3090
+ import { createConnectTransport as createConnectTransport2 } from "@connectrpc/connect-node";
3091
+ import { StorageService as StorageService3 } from "@eide/foir-proto-ts/storage/v1/storage_pb";
876
3092
 
877
3093
  // src/lib/input.ts
878
3094
  import inquirer2 from "inquirer";
@@ -966,11 +3182,19 @@ function guessMimeType(filename) {
966
3182
  function getStorageUrl() {
967
3183
  return process.env.FOIR_STORAGE_URL ?? "https://storage.foir.dev";
968
3184
  }
969
- function createClient2(getToken) {
970
- return createStorageClient({
3185
+ function createStorageRpcClient(getToken) {
3186
+ const transport = createConnectTransport2({
971
3187
  baseUrl: getStorageUrl(),
972
- getAuthToken: getToken
3188
+ httpVersion: "1.1",
3189
+ interceptors: [
3190
+ (next) => async (req) => {
3191
+ const token = await getToken();
3192
+ if (token) req.header.set("Authorization", `Bearer ${token}`);
3193
+ return next(req);
3194
+ }
3195
+ ]
973
3196
  });
3197
+ return createStorageMethods(createClient(StorageService3, transport));
974
3198
  }
975
3199
  function registerMediaCommands(program2, globalOpts) {
976
3200
  const media = program2.command("media").description("Media file operations");
@@ -980,7 +3204,7 @@ function registerMediaCommands(program2, globalOpts) {
980
3204
  async (filepath, flags) => {
981
3205
  const opts = globalOpts();
982
3206
  const { getToken } = await getStorageAuth(opts);
983
- const storage = createClient2(getToken);
3207
+ const storage = createStorageRpcClient(getToken);
984
3208
  const fileBuffer = await fs2.readFile(filepath);
985
3209
  const filename = basename(filepath);
986
3210
  const mimeType = guessMimeType(filename);
@@ -1021,7 +3245,7 @@ function registerMediaCommands(program2, globalOpts) {
1021
3245
  async (flags) => {
1022
3246
  const opts = globalOpts();
1023
3247
  const { getToken } = await getStorageAuth(opts);
1024
- const storage = createClient2(getToken);
3248
+ const storage = createStorageRpcClient(getToken);
1025
3249
  const result = await storage.listFiles({
1026
3250
  folder: flags.folder,
1027
3251
  mimeType: flags["mime-type"] ?? flags.mimeType,
@@ -1063,7 +3287,7 @@ function registerMediaCommands(program2, globalOpts) {
1063
3287
  withErrorHandler(globalOpts, async (id) => {
1064
3288
  const opts = globalOpts();
1065
3289
  const { getToken } = await getStorageAuth(opts);
1066
- const storage = createClient2(getToken);
3290
+ const storage = createStorageRpcClient(getToken);
1067
3291
  const file = await storage.getFile(id);
1068
3292
  formatOutput(file, opts);
1069
3293
  })
@@ -1072,7 +3296,7 @@ function registerMediaCommands(program2, globalOpts) {
1072
3296
  withErrorHandler(globalOpts, async () => {
1073
3297
  const opts = globalOpts();
1074
3298
  const { getToken } = await getStorageAuth(opts);
1075
- const storage = createClient2(getToken);
3299
+ const storage = createStorageRpcClient(getToken);
1076
3300
  const usage = await storage.getStorageUsage();
1077
3301
  if (opts.json || opts.jsonl) {
1078
3302
  formatOutput(usage, opts);
@@ -1091,7 +3315,7 @@ function registerMediaCommands(program2, globalOpts) {
1091
3315
  async (id, flags) => {
1092
3316
  const opts = globalOpts();
1093
3317
  const { getToken } = await getStorageAuth(opts);
1094
- const storage = createClient2(getToken);
3318
+ const storage = createStorageRpcClient(getToken);
1095
3319
  const file = await storage.updateFile({
1096
3320
  id,
1097
3321
  filename: flags.filename,
@@ -1112,7 +3336,7 @@ function registerMediaCommands(program2, globalOpts) {
1112
3336
  async (id, flags) => {
1113
3337
  const opts = globalOpts();
1114
3338
  const { getToken } = await getStorageAuth(opts);
1115
- const storage = createClient2(getToken);
3339
+ const storage = createStorageRpcClient(getToken);
1116
3340
  const file = await storage.updateFileMetadata({
1117
3341
  id,
1118
3342
  altText: flags.altText ?? flags["alt-text"],
@@ -1140,7 +3364,7 @@ function registerMediaCommands(program2, globalOpts) {
1140
3364
  return;
1141
3365
  }
1142
3366
  const { getToken } = await getStorageAuth(opts);
1143
- const storage = createClient2(getToken);
3367
+ const storage = createStorageRpcClient(getToken);
1144
3368
  if (flags.permanent) {
1145
3369
  await storage.permanentlyDeleteFile(id);
1146
3370
  success("Permanently deleted file");
@@ -1155,7 +3379,7 @@ function registerMediaCommands(program2, globalOpts) {
1155
3379
  withErrorHandler(globalOpts, async (id) => {
1156
3380
  const opts = globalOpts();
1157
3381
  const { getToken } = await getStorageAuth(opts);
1158
- const storage = createClient2(getToken);
3382
+ const storage = createStorageRpcClient(getToken);
1159
3383
  const file = await storage.restoreFile(id);
1160
3384
  if (opts.json || opts.jsonl) {
1161
3385
  formatOutput(file, opts);
@@ -2258,7 +4482,7 @@ import { readdirSync } from "fs";
2258
4482
  import { resolve as resolve5 } from "path";
2259
4483
  import chalk9 from "chalk";
2260
4484
 
2261
- // ../command-registry/src/command-map.ts
4485
+ // src/command-registry/command-map.ts
2262
4486
  var COMMANDS = [
2263
4487
  // =========================================================================
2264
4488
  // MODELS
@@ -2433,6 +4657,15 @@ var COMMANDS = [
2433
4657
  scalarResult: true,
2434
4658
  successMessage: "Unpublished record"
2435
4659
  },
4660
+ {
4661
+ group: "records",
4662
+ name: "cancel-schedule",
4663
+ description: "Cancel a scheduled publish or unpublish",
4664
+ operation: "cancelScheduledRecordPublish",
4665
+ operationType: "mutation",
4666
+ positionalArgs: [{ name: "versionId", graphqlArg: "versionId", description: "Version ID" }],
4667
+ successMessage: "Cancelled scheduled publish for version {versionId}"
4668
+ },
2436
4669
  {
2437
4670
  group: "records",
2438
4671
  name: "duplicate",
@@ -2489,6 +4722,104 @@ var COMMANDS = [
2489
4722
  successMessage: "Created variant"
2490
4723
  },
2491
4724
  // =========================================================================
4725
+ // ROLLOUTS
4726
+ // =========================================================================
4727
+ {
4728
+ group: "rollouts",
4729
+ name: "list",
4730
+ description: "List rollouts",
4731
+ operation: "listPublishBatches",
4732
+ operationType: "query",
4733
+ columns: [
4734
+ { key: "id", header: "ID", width: 28 },
4735
+ { key: "name", header: "Name", width: 24 },
4736
+ { key: "status", header: "Status", width: 16 },
4737
+ { key: "itemCount", header: "Items", width: 6 },
4738
+ { key: "completedCount", header: "Done", width: 6 },
4739
+ { key: "scheduledAt", header: "Scheduled", width: 12, format: "timeAgo" },
4740
+ { key: "createdAt", header: "Created", width: 12, format: "timeAgo" }
4741
+ ]
4742
+ },
4743
+ {
4744
+ group: "rollouts",
4745
+ name: "get",
4746
+ description: "Get a rollout",
4747
+ operation: "getPublishBatch",
4748
+ operationType: "query",
4749
+ positionalArgs: [{ name: "id", graphqlArg: "id", description: "Rollout ID" }]
4750
+ },
4751
+ {
4752
+ group: "rollouts",
4753
+ name: "create",
4754
+ description: "Create a rollout",
4755
+ operation: "createPublishBatch",
4756
+ operationType: "mutation",
4757
+ acceptsInput: true,
4758
+ successMessage: "Created rollout {name}"
4759
+ },
4760
+ {
4761
+ group: "rollouts",
4762
+ name: "update",
4763
+ description: "Update a rollout",
4764
+ operation: "updatePublishBatch",
4765
+ operationType: "mutation",
4766
+ positionalArgs: [{ name: "id", graphqlArg: "id", description: "Rollout ID" }],
4767
+ acceptsInput: true,
4768
+ successMessage: "Updated rollout"
4769
+ },
4770
+ {
4771
+ group: "rollouts",
4772
+ name: "cancel",
4773
+ description: "Cancel a rollout",
4774
+ operation: "cancelPublishBatch",
4775
+ operationType: "mutation",
4776
+ positionalArgs: [{ name: "id", graphqlArg: "id", description: "Rollout ID" }],
4777
+ requiresConfirmation: true,
4778
+ scalarResult: true,
4779
+ successMessage: "Cancelled rollout"
4780
+ },
4781
+ {
4782
+ group: "rollouts",
4783
+ name: "rollback",
4784
+ description: "Rollback a completed rollout",
4785
+ operation: "rollbackPublishBatch",
4786
+ operationType: "mutation",
4787
+ positionalArgs: [{ name: "id", graphqlArg: "id", description: "Rollout ID" }],
4788
+ requiresConfirmation: true,
4789
+ scalarResult: true,
4790
+ successMessage: "Rolled back rollout"
4791
+ },
4792
+ {
4793
+ group: "rollouts",
4794
+ name: "retry",
4795
+ description: "Retry failed items in a rollout",
4796
+ operation: "retryFailedBatchItems",
4797
+ operationType: "mutation",
4798
+ positionalArgs: [{ name: "id", graphqlArg: "id", description: "Rollout ID" }],
4799
+ scalarResult: true,
4800
+ successMessage: "Retrying failed items in rollout"
4801
+ },
4802
+ {
4803
+ group: "rollouts",
4804
+ name: "add-items",
4805
+ description: "Add version IDs to a rollout",
4806
+ operation: "addItemsToPublishBatch",
4807
+ operationType: "mutation",
4808
+ positionalArgs: [{ name: "id", graphqlArg: "id", description: "Rollout ID" }],
4809
+ acceptsInput: true,
4810
+ successMessage: "Added items to rollout"
4811
+ },
4812
+ {
4813
+ group: "rollouts",
4814
+ name: "remove-items",
4815
+ description: "Remove version IDs from a rollout",
4816
+ operation: "removeItemsFromPublishBatch",
4817
+ operationType: "mutation",
4818
+ positionalArgs: [{ name: "id", graphqlArg: "id", description: "Rollout ID" }],
4819
+ acceptsInput: true,
4820
+ successMessage: "Removed items from rollout"
4821
+ },
4822
+ // =========================================================================
2492
4823
  // LOCALES
2493
4824
  // =========================================================================
2494
4825
  {
@@ -3197,6 +5528,7 @@ var COMMANDS = [
3197
5528
  description: "List hook deliveries",
3198
5529
  operation: "hookDeliveries",
3199
5530
  operationType: "query",
5531
+ positionalArgs: [{ name: "hookId", graphqlArg: "hookId", description: "Hook ID" }],
3200
5532
  columns: [
3201
5533
  { key: "id", header: "ID", width: 28 },
3202
5534
  { key: "event", header: "Event", width: 16 },
@@ -3600,8 +5932,19 @@ var COMMANDS = [
3600
5932
  }
3601
5933
  ];
3602
5934
 
5935
+ // src/command-registry/schema-engine.ts
5936
+ import {
5937
+ buildSchema,
5938
+ isObjectType,
5939
+ isInputObjectType,
5940
+ isListType,
5941
+ isNonNullType,
5942
+ isScalarType,
5943
+ isEnumType
5944
+ } from "graphql";
5945
+
3603
5946
  // src/commands/register-commands.ts
3604
- import { RecordType } from "@foir/connect-clients/records";
5947
+ import { RecordType as RecordType2 } from "@eide/foir-proto-ts/records/v1/records_pb";
3605
5948
  function buildDispatchTable() {
3606
5949
  return {
3607
5950
  // ── Models ──────────────────────────────────────────────────
@@ -4247,7 +6590,7 @@ function registerDynamicCommands(program2, globalOpts) {
4247
6590
  } else {
4248
6591
  try {
4249
6592
  const record = await client.records.getRecord(versionIdValue);
4250
- if (record?.recordType === RecordType.RECORD && record?.currentVersionId) {
6593
+ if (record?.recordType === RecordType2.RECORD && record?.currentVersionId) {
4251
6594
  variables.versionId = record.currentVersionId;
4252
6595
  }
4253
6596
  } catch {