@app-vitals/agent-admin 1.24.0 → 1.25.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.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@app-vitals/agent-admin",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.25.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/app-vitals/agent.git",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@anthropic-ai/sdk": "0.135.0",
|
|
45
|
-
"@app-vitals/agent-lib": "1.
|
|
45
|
+
"@app-vitals/agent-lib": "1.25.0",
|
|
46
46
|
"@hono/zod-openapi": "^1.0.0",
|
|
47
47
|
"@prisma/adapter-pg": "^7.10.0",
|
|
48
48
|
"@prisma/client": "^7.10.0",
|
|
@@ -708,5 +708,884 @@
|
|
|
708
708
|
"members": "read"
|
|
709
709
|
}
|
|
710
710
|
}
|
|
711
|
+
},
|
|
712
|
+
"install_repos_success": {
|
|
713
|
+
"status": 200,
|
|
714
|
+
"body": [
|
|
715
|
+
{
|
|
716
|
+
"id": 1,
|
|
717
|
+
"name": "repo-1",
|
|
718
|
+
"full_name": "acme-eng/repo-1"
|
|
719
|
+
},
|
|
720
|
+
{
|
|
721
|
+
"id": 2,
|
|
722
|
+
"name": "repo-2",
|
|
723
|
+
"full_name": "acme-eng/repo-2"
|
|
724
|
+
}
|
|
725
|
+
]
|
|
726
|
+
},
|
|
727
|
+
"install_repos_page_1": {
|
|
728
|
+
"status": 200,
|
|
729
|
+
"headers": {
|
|
730
|
+
"link": "<https://api.github.com/enterprises/acme/apps/organizations/acme-eng/installations/501/repositories?per_page=100&page=2>; rel=\"next\""
|
|
731
|
+
},
|
|
732
|
+
"body": [
|
|
733
|
+
{
|
|
734
|
+
"id": 1,
|
|
735
|
+
"name": "repo-1",
|
|
736
|
+
"full_name": "acme-eng/repo-1"
|
|
737
|
+
},
|
|
738
|
+
{
|
|
739
|
+
"id": 2,
|
|
740
|
+
"name": "repo-2",
|
|
741
|
+
"full_name": "acme-eng/repo-2"
|
|
742
|
+
}
|
|
743
|
+
]
|
|
744
|
+
},
|
|
745
|
+
"install_repos_page_2": {
|
|
746
|
+
"status": 200,
|
|
747
|
+
"body": [
|
|
748
|
+
{
|
|
749
|
+
"id": 3,
|
|
750
|
+
"name": "repo-3",
|
|
751
|
+
"full_name": "acme-eng/repo-3"
|
|
752
|
+
}
|
|
753
|
+
]
|
|
754
|
+
},
|
|
755
|
+
"install_repos_empty": {
|
|
756
|
+
"status": 200,
|
|
757
|
+
"body": []
|
|
758
|
+
},
|
|
759
|
+
"install_repos_403": {
|
|
760
|
+
"status": 403,
|
|
761
|
+
"body": {
|
|
762
|
+
"message": "Resource not accessible by integration",
|
|
763
|
+
"documentation_url": "https://docs.github.com/enterprise-cloud@latest/rest/enterprise-admin/organization-installations"
|
|
764
|
+
}
|
|
765
|
+
},
|
|
766
|
+
"install_repos_403_secondary_rate_limit": {
|
|
767
|
+
"status": 403,
|
|
768
|
+
"headers": {
|
|
769
|
+
"retry-after": "60"
|
|
770
|
+
},
|
|
771
|
+
"body": {
|
|
772
|
+
"message": "You have exceeded a secondary rate limit. Please wait a few minutes before you try again.",
|
|
773
|
+
"documentation_url": "https://docs.github.com/rest/overview/rate-limits-for-the-rest-api#about-secondary-rate-limits"
|
|
774
|
+
}
|
|
775
|
+
},
|
|
776
|
+
"install_repos_404": {
|
|
777
|
+
"status": 404,
|
|
778
|
+
"body": {
|
|
779
|
+
"message": "Not Found",
|
|
780
|
+
"documentation_url": "https://docs.github.com/enterprise-cloud@latest/rest/enterprise-admin/organization-installations"
|
|
781
|
+
}
|
|
782
|
+
},
|
|
783
|
+
"install_repos_422": {
|
|
784
|
+
"status": 422,
|
|
785
|
+
"body": {
|
|
786
|
+
"message": "Validation Failed",
|
|
787
|
+
"documentation_url": "https://docs.github.com/enterprise-cloud@latest/rest/enterprise-admin/organization-installations"
|
|
788
|
+
}
|
|
789
|
+
},
|
|
790
|
+
"install_repos_429": {
|
|
791
|
+
"status": 429,
|
|
792
|
+
"headers": {
|
|
793
|
+
"retry-after": "30"
|
|
794
|
+
},
|
|
795
|
+
"body": {
|
|
796
|
+
"message": "API rate limit exceeded",
|
|
797
|
+
"documentation_url": "https://docs.github.com/rest/overview/rate-limits-for-the-rest-api"
|
|
798
|
+
}
|
|
799
|
+
},
|
|
800
|
+
"install_repos_500": {
|
|
801
|
+
"status": 500,
|
|
802
|
+
"body": {
|
|
803
|
+
"message": "Server Error"
|
|
804
|
+
}
|
|
805
|
+
},
|
|
806
|
+
"install_repos_503": {
|
|
807
|
+
"status": 503,
|
|
808
|
+
"body": {
|
|
809
|
+
"message": "Service Unavailable"
|
|
810
|
+
}
|
|
811
|
+
},
|
|
812
|
+
"install_repos_add_success": {
|
|
813
|
+
"status": 200,
|
|
814
|
+
"body": [
|
|
815
|
+
{
|
|
816
|
+
"id": 1,
|
|
817
|
+
"name": "repo-1",
|
|
818
|
+
"full_name": "acme-eng/repo-1"
|
|
819
|
+
},
|
|
820
|
+
{
|
|
821
|
+
"id": 2,
|
|
822
|
+
"name": "repo-2",
|
|
823
|
+
"full_name": "acme-eng/repo-2"
|
|
824
|
+
}
|
|
825
|
+
]
|
|
826
|
+
},
|
|
827
|
+
"install_repos_add_batch_1": {
|
|
828
|
+
"status": 200,
|
|
829
|
+
"body": [
|
|
830
|
+
{
|
|
831
|
+
"id": 1,
|
|
832
|
+
"name": "repo-1",
|
|
833
|
+
"full_name": "acme-eng/repo-1"
|
|
834
|
+
},
|
|
835
|
+
{
|
|
836
|
+
"id": 2,
|
|
837
|
+
"name": "repo-2",
|
|
838
|
+
"full_name": "acme-eng/repo-2"
|
|
839
|
+
},
|
|
840
|
+
{
|
|
841
|
+
"id": 3,
|
|
842
|
+
"name": "repo-3",
|
|
843
|
+
"full_name": "acme-eng/repo-3"
|
|
844
|
+
},
|
|
845
|
+
{
|
|
846
|
+
"id": 4,
|
|
847
|
+
"name": "repo-4",
|
|
848
|
+
"full_name": "acme-eng/repo-4"
|
|
849
|
+
},
|
|
850
|
+
{
|
|
851
|
+
"id": 5,
|
|
852
|
+
"name": "repo-5",
|
|
853
|
+
"full_name": "acme-eng/repo-5"
|
|
854
|
+
},
|
|
855
|
+
{
|
|
856
|
+
"id": 6,
|
|
857
|
+
"name": "repo-6",
|
|
858
|
+
"full_name": "acme-eng/repo-6"
|
|
859
|
+
},
|
|
860
|
+
{
|
|
861
|
+
"id": 7,
|
|
862
|
+
"name": "repo-7",
|
|
863
|
+
"full_name": "acme-eng/repo-7"
|
|
864
|
+
},
|
|
865
|
+
{
|
|
866
|
+
"id": 8,
|
|
867
|
+
"name": "repo-8",
|
|
868
|
+
"full_name": "acme-eng/repo-8"
|
|
869
|
+
},
|
|
870
|
+
{
|
|
871
|
+
"id": 9,
|
|
872
|
+
"name": "repo-9",
|
|
873
|
+
"full_name": "acme-eng/repo-9"
|
|
874
|
+
},
|
|
875
|
+
{
|
|
876
|
+
"id": 10,
|
|
877
|
+
"name": "repo-10",
|
|
878
|
+
"full_name": "acme-eng/repo-10"
|
|
879
|
+
},
|
|
880
|
+
{
|
|
881
|
+
"id": 11,
|
|
882
|
+
"name": "repo-11",
|
|
883
|
+
"full_name": "acme-eng/repo-11"
|
|
884
|
+
},
|
|
885
|
+
{
|
|
886
|
+
"id": 12,
|
|
887
|
+
"name": "repo-12",
|
|
888
|
+
"full_name": "acme-eng/repo-12"
|
|
889
|
+
},
|
|
890
|
+
{
|
|
891
|
+
"id": 13,
|
|
892
|
+
"name": "repo-13",
|
|
893
|
+
"full_name": "acme-eng/repo-13"
|
|
894
|
+
},
|
|
895
|
+
{
|
|
896
|
+
"id": 14,
|
|
897
|
+
"name": "repo-14",
|
|
898
|
+
"full_name": "acme-eng/repo-14"
|
|
899
|
+
},
|
|
900
|
+
{
|
|
901
|
+
"id": 15,
|
|
902
|
+
"name": "repo-15",
|
|
903
|
+
"full_name": "acme-eng/repo-15"
|
|
904
|
+
},
|
|
905
|
+
{
|
|
906
|
+
"id": 16,
|
|
907
|
+
"name": "repo-16",
|
|
908
|
+
"full_name": "acme-eng/repo-16"
|
|
909
|
+
},
|
|
910
|
+
{
|
|
911
|
+
"id": 17,
|
|
912
|
+
"name": "repo-17",
|
|
913
|
+
"full_name": "acme-eng/repo-17"
|
|
914
|
+
},
|
|
915
|
+
{
|
|
916
|
+
"id": 18,
|
|
917
|
+
"name": "repo-18",
|
|
918
|
+
"full_name": "acme-eng/repo-18"
|
|
919
|
+
},
|
|
920
|
+
{
|
|
921
|
+
"id": 19,
|
|
922
|
+
"name": "repo-19",
|
|
923
|
+
"full_name": "acme-eng/repo-19"
|
|
924
|
+
},
|
|
925
|
+
{
|
|
926
|
+
"id": 20,
|
|
927
|
+
"name": "repo-20",
|
|
928
|
+
"full_name": "acme-eng/repo-20"
|
|
929
|
+
},
|
|
930
|
+
{
|
|
931
|
+
"id": 21,
|
|
932
|
+
"name": "repo-21",
|
|
933
|
+
"full_name": "acme-eng/repo-21"
|
|
934
|
+
},
|
|
935
|
+
{
|
|
936
|
+
"id": 22,
|
|
937
|
+
"name": "repo-22",
|
|
938
|
+
"full_name": "acme-eng/repo-22"
|
|
939
|
+
},
|
|
940
|
+
{
|
|
941
|
+
"id": 23,
|
|
942
|
+
"name": "repo-23",
|
|
943
|
+
"full_name": "acme-eng/repo-23"
|
|
944
|
+
},
|
|
945
|
+
{
|
|
946
|
+
"id": 24,
|
|
947
|
+
"name": "repo-24",
|
|
948
|
+
"full_name": "acme-eng/repo-24"
|
|
949
|
+
},
|
|
950
|
+
{
|
|
951
|
+
"id": 25,
|
|
952
|
+
"name": "repo-25",
|
|
953
|
+
"full_name": "acme-eng/repo-25"
|
|
954
|
+
},
|
|
955
|
+
{
|
|
956
|
+
"id": 26,
|
|
957
|
+
"name": "repo-26",
|
|
958
|
+
"full_name": "acme-eng/repo-26"
|
|
959
|
+
},
|
|
960
|
+
{
|
|
961
|
+
"id": 27,
|
|
962
|
+
"name": "repo-27",
|
|
963
|
+
"full_name": "acme-eng/repo-27"
|
|
964
|
+
},
|
|
965
|
+
{
|
|
966
|
+
"id": 28,
|
|
967
|
+
"name": "repo-28",
|
|
968
|
+
"full_name": "acme-eng/repo-28"
|
|
969
|
+
},
|
|
970
|
+
{
|
|
971
|
+
"id": 29,
|
|
972
|
+
"name": "repo-29",
|
|
973
|
+
"full_name": "acme-eng/repo-29"
|
|
974
|
+
},
|
|
975
|
+
{
|
|
976
|
+
"id": 30,
|
|
977
|
+
"name": "repo-30",
|
|
978
|
+
"full_name": "acme-eng/repo-30"
|
|
979
|
+
},
|
|
980
|
+
{
|
|
981
|
+
"id": 31,
|
|
982
|
+
"name": "repo-31",
|
|
983
|
+
"full_name": "acme-eng/repo-31"
|
|
984
|
+
},
|
|
985
|
+
{
|
|
986
|
+
"id": 32,
|
|
987
|
+
"name": "repo-32",
|
|
988
|
+
"full_name": "acme-eng/repo-32"
|
|
989
|
+
},
|
|
990
|
+
{
|
|
991
|
+
"id": 33,
|
|
992
|
+
"name": "repo-33",
|
|
993
|
+
"full_name": "acme-eng/repo-33"
|
|
994
|
+
},
|
|
995
|
+
{
|
|
996
|
+
"id": 34,
|
|
997
|
+
"name": "repo-34",
|
|
998
|
+
"full_name": "acme-eng/repo-34"
|
|
999
|
+
},
|
|
1000
|
+
{
|
|
1001
|
+
"id": 35,
|
|
1002
|
+
"name": "repo-35",
|
|
1003
|
+
"full_name": "acme-eng/repo-35"
|
|
1004
|
+
},
|
|
1005
|
+
{
|
|
1006
|
+
"id": 36,
|
|
1007
|
+
"name": "repo-36",
|
|
1008
|
+
"full_name": "acme-eng/repo-36"
|
|
1009
|
+
},
|
|
1010
|
+
{
|
|
1011
|
+
"id": 37,
|
|
1012
|
+
"name": "repo-37",
|
|
1013
|
+
"full_name": "acme-eng/repo-37"
|
|
1014
|
+
},
|
|
1015
|
+
{
|
|
1016
|
+
"id": 38,
|
|
1017
|
+
"name": "repo-38",
|
|
1018
|
+
"full_name": "acme-eng/repo-38"
|
|
1019
|
+
},
|
|
1020
|
+
{
|
|
1021
|
+
"id": 39,
|
|
1022
|
+
"name": "repo-39",
|
|
1023
|
+
"full_name": "acme-eng/repo-39"
|
|
1024
|
+
},
|
|
1025
|
+
{
|
|
1026
|
+
"id": 40,
|
|
1027
|
+
"name": "repo-40",
|
|
1028
|
+
"full_name": "acme-eng/repo-40"
|
|
1029
|
+
},
|
|
1030
|
+
{
|
|
1031
|
+
"id": 41,
|
|
1032
|
+
"name": "repo-41",
|
|
1033
|
+
"full_name": "acme-eng/repo-41"
|
|
1034
|
+
},
|
|
1035
|
+
{
|
|
1036
|
+
"id": 42,
|
|
1037
|
+
"name": "repo-42",
|
|
1038
|
+
"full_name": "acme-eng/repo-42"
|
|
1039
|
+
},
|
|
1040
|
+
{
|
|
1041
|
+
"id": 43,
|
|
1042
|
+
"name": "repo-43",
|
|
1043
|
+
"full_name": "acme-eng/repo-43"
|
|
1044
|
+
},
|
|
1045
|
+
{
|
|
1046
|
+
"id": 44,
|
|
1047
|
+
"name": "repo-44",
|
|
1048
|
+
"full_name": "acme-eng/repo-44"
|
|
1049
|
+
},
|
|
1050
|
+
{
|
|
1051
|
+
"id": 45,
|
|
1052
|
+
"name": "repo-45",
|
|
1053
|
+
"full_name": "acme-eng/repo-45"
|
|
1054
|
+
},
|
|
1055
|
+
{
|
|
1056
|
+
"id": 46,
|
|
1057
|
+
"name": "repo-46",
|
|
1058
|
+
"full_name": "acme-eng/repo-46"
|
|
1059
|
+
},
|
|
1060
|
+
{
|
|
1061
|
+
"id": 47,
|
|
1062
|
+
"name": "repo-47",
|
|
1063
|
+
"full_name": "acme-eng/repo-47"
|
|
1064
|
+
},
|
|
1065
|
+
{
|
|
1066
|
+
"id": 48,
|
|
1067
|
+
"name": "repo-48",
|
|
1068
|
+
"full_name": "acme-eng/repo-48"
|
|
1069
|
+
},
|
|
1070
|
+
{
|
|
1071
|
+
"id": 49,
|
|
1072
|
+
"name": "repo-49",
|
|
1073
|
+
"full_name": "acme-eng/repo-49"
|
|
1074
|
+
},
|
|
1075
|
+
{
|
|
1076
|
+
"id": 50,
|
|
1077
|
+
"name": "repo-50",
|
|
1078
|
+
"full_name": "acme-eng/repo-50"
|
|
1079
|
+
}
|
|
1080
|
+
]
|
|
1081
|
+
},
|
|
1082
|
+
"install_repos_add_batch_2": {
|
|
1083
|
+
"status": 200,
|
|
1084
|
+
"body": [
|
|
1085
|
+
{
|
|
1086
|
+
"id": 51,
|
|
1087
|
+
"name": "repo-51",
|
|
1088
|
+
"full_name": "acme-eng/repo-51"
|
|
1089
|
+
}
|
|
1090
|
+
]
|
|
1091
|
+
},
|
|
1092
|
+
"install_repos_add_403": {
|
|
1093
|
+
"status": 403,
|
|
1094
|
+
"body": {
|
|
1095
|
+
"message": "Resource not accessible by integration",
|
|
1096
|
+
"documentation_url": "https://docs.github.com/enterprise-cloud@latest/rest/enterprise-admin/organization-installations"
|
|
1097
|
+
}
|
|
1098
|
+
},
|
|
1099
|
+
"install_repos_add_403_secondary_rate_limit": {
|
|
1100
|
+
"status": 403,
|
|
1101
|
+
"headers": {
|
|
1102
|
+
"retry-after": "60"
|
|
1103
|
+
},
|
|
1104
|
+
"body": {
|
|
1105
|
+
"message": "You have exceeded a secondary rate limit. Please wait a few minutes before you try again.",
|
|
1106
|
+
"documentation_url": "https://docs.github.com/rest/overview/rate-limits-for-the-rest-api#about-secondary-rate-limits"
|
|
1107
|
+
}
|
|
1108
|
+
},
|
|
1109
|
+
"install_repos_add_404": {
|
|
1110
|
+
"status": 404,
|
|
1111
|
+
"body": {
|
|
1112
|
+
"message": "Not Found",
|
|
1113
|
+
"documentation_url": "https://docs.github.com/enterprise-cloud@latest/rest/enterprise-admin/organization-installations"
|
|
1114
|
+
}
|
|
1115
|
+
},
|
|
1116
|
+
"install_repos_add_422": {
|
|
1117
|
+
"status": 422,
|
|
1118
|
+
"body": {
|
|
1119
|
+
"message": "Validation Failed",
|
|
1120
|
+
"documentation_url": "https://docs.github.com/enterprise-cloud@latest/rest/enterprise-admin/organization-installations"
|
|
1121
|
+
}
|
|
1122
|
+
},
|
|
1123
|
+
"install_repos_add_429": {
|
|
1124
|
+
"status": 429,
|
|
1125
|
+
"headers": {
|
|
1126
|
+
"retry-after": "30"
|
|
1127
|
+
},
|
|
1128
|
+
"body": {
|
|
1129
|
+
"message": "API rate limit exceeded",
|
|
1130
|
+
"documentation_url": "https://docs.github.com/rest/overview/rate-limits-for-the-rest-api"
|
|
1131
|
+
}
|
|
1132
|
+
},
|
|
1133
|
+
"install_repos_add_500": {
|
|
1134
|
+
"status": 500,
|
|
1135
|
+
"body": {
|
|
1136
|
+
"message": "Server Error"
|
|
1137
|
+
}
|
|
1138
|
+
},
|
|
1139
|
+
"install_repos_add_503": {
|
|
1140
|
+
"status": 503,
|
|
1141
|
+
"body": {
|
|
1142
|
+
"message": "Service Unavailable"
|
|
1143
|
+
}
|
|
1144
|
+
},
|
|
1145
|
+
"install_repos_remove_success": {
|
|
1146
|
+
"status": 200,
|
|
1147
|
+
"body": [
|
|
1148
|
+
{
|
|
1149
|
+
"id": 1,
|
|
1150
|
+
"name": "repo-1",
|
|
1151
|
+
"full_name": "acme-eng/repo-1"
|
|
1152
|
+
},
|
|
1153
|
+
{
|
|
1154
|
+
"id": 2,
|
|
1155
|
+
"name": "repo-2",
|
|
1156
|
+
"full_name": "acme-eng/repo-2"
|
|
1157
|
+
}
|
|
1158
|
+
]
|
|
1159
|
+
},
|
|
1160
|
+
"install_repos_remove_batch_1": {
|
|
1161
|
+
"status": 200,
|
|
1162
|
+
"body": [
|
|
1163
|
+
{
|
|
1164
|
+
"id": 1,
|
|
1165
|
+
"name": "repo-1",
|
|
1166
|
+
"full_name": "acme-eng/repo-1"
|
|
1167
|
+
},
|
|
1168
|
+
{
|
|
1169
|
+
"id": 2,
|
|
1170
|
+
"name": "repo-2",
|
|
1171
|
+
"full_name": "acme-eng/repo-2"
|
|
1172
|
+
},
|
|
1173
|
+
{
|
|
1174
|
+
"id": 3,
|
|
1175
|
+
"name": "repo-3",
|
|
1176
|
+
"full_name": "acme-eng/repo-3"
|
|
1177
|
+
},
|
|
1178
|
+
{
|
|
1179
|
+
"id": 4,
|
|
1180
|
+
"name": "repo-4",
|
|
1181
|
+
"full_name": "acme-eng/repo-4"
|
|
1182
|
+
},
|
|
1183
|
+
{
|
|
1184
|
+
"id": 5,
|
|
1185
|
+
"name": "repo-5",
|
|
1186
|
+
"full_name": "acme-eng/repo-5"
|
|
1187
|
+
},
|
|
1188
|
+
{
|
|
1189
|
+
"id": 6,
|
|
1190
|
+
"name": "repo-6",
|
|
1191
|
+
"full_name": "acme-eng/repo-6"
|
|
1192
|
+
},
|
|
1193
|
+
{
|
|
1194
|
+
"id": 7,
|
|
1195
|
+
"name": "repo-7",
|
|
1196
|
+
"full_name": "acme-eng/repo-7"
|
|
1197
|
+
},
|
|
1198
|
+
{
|
|
1199
|
+
"id": 8,
|
|
1200
|
+
"name": "repo-8",
|
|
1201
|
+
"full_name": "acme-eng/repo-8"
|
|
1202
|
+
},
|
|
1203
|
+
{
|
|
1204
|
+
"id": 9,
|
|
1205
|
+
"name": "repo-9",
|
|
1206
|
+
"full_name": "acme-eng/repo-9"
|
|
1207
|
+
},
|
|
1208
|
+
{
|
|
1209
|
+
"id": 10,
|
|
1210
|
+
"name": "repo-10",
|
|
1211
|
+
"full_name": "acme-eng/repo-10"
|
|
1212
|
+
},
|
|
1213
|
+
{
|
|
1214
|
+
"id": 11,
|
|
1215
|
+
"name": "repo-11",
|
|
1216
|
+
"full_name": "acme-eng/repo-11"
|
|
1217
|
+
},
|
|
1218
|
+
{
|
|
1219
|
+
"id": 12,
|
|
1220
|
+
"name": "repo-12",
|
|
1221
|
+
"full_name": "acme-eng/repo-12"
|
|
1222
|
+
},
|
|
1223
|
+
{
|
|
1224
|
+
"id": 13,
|
|
1225
|
+
"name": "repo-13",
|
|
1226
|
+
"full_name": "acme-eng/repo-13"
|
|
1227
|
+
},
|
|
1228
|
+
{
|
|
1229
|
+
"id": 14,
|
|
1230
|
+
"name": "repo-14",
|
|
1231
|
+
"full_name": "acme-eng/repo-14"
|
|
1232
|
+
},
|
|
1233
|
+
{
|
|
1234
|
+
"id": 15,
|
|
1235
|
+
"name": "repo-15",
|
|
1236
|
+
"full_name": "acme-eng/repo-15"
|
|
1237
|
+
},
|
|
1238
|
+
{
|
|
1239
|
+
"id": 16,
|
|
1240
|
+
"name": "repo-16",
|
|
1241
|
+
"full_name": "acme-eng/repo-16"
|
|
1242
|
+
},
|
|
1243
|
+
{
|
|
1244
|
+
"id": 17,
|
|
1245
|
+
"name": "repo-17",
|
|
1246
|
+
"full_name": "acme-eng/repo-17"
|
|
1247
|
+
},
|
|
1248
|
+
{
|
|
1249
|
+
"id": 18,
|
|
1250
|
+
"name": "repo-18",
|
|
1251
|
+
"full_name": "acme-eng/repo-18"
|
|
1252
|
+
},
|
|
1253
|
+
{
|
|
1254
|
+
"id": 19,
|
|
1255
|
+
"name": "repo-19",
|
|
1256
|
+
"full_name": "acme-eng/repo-19"
|
|
1257
|
+
},
|
|
1258
|
+
{
|
|
1259
|
+
"id": 20,
|
|
1260
|
+
"name": "repo-20",
|
|
1261
|
+
"full_name": "acme-eng/repo-20"
|
|
1262
|
+
},
|
|
1263
|
+
{
|
|
1264
|
+
"id": 21,
|
|
1265
|
+
"name": "repo-21",
|
|
1266
|
+
"full_name": "acme-eng/repo-21"
|
|
1267
|
+
},
|
|
1268
|
+
{
|
|
1269
|
+
"id": 22,
|
|
1270
|
+
"name": "repo-22",
|
|
1271
|
+
"full_name": "acme-eng/repo-22"
|
|
1272
|
+
},
|
|
1273
|
+
{
|
|
1274
|
+
"id": 23,
|
|
1275
|
+
"name": "repo-23",
|
|
1276
|
+
"full_name": "acme-eng/repo-23"
|
|
1277
|
+
},
|
|
1278
|
+
{
|
|
1279
|
+
"id": 24,
|
|
1280
|
+
"name": "repo-24",
|
|
1281
|
+
"full_name": "acme-eng/repo-24"
|
|
1282
|
+
},
|
|
1283
|
+
{
|
|
1284
|
+
"id": 25,
|
|
1285
|
+
"name": "repo-25",
|
|
1286
|
+
"full_name": "acme-eng/repo-25"
|
|
1287
|
+
},
|
|
1288
|
+
{
|
|
1289
|
+
"id": 26,
|
|
1290
|
+
"name": "repo-26",
|
|
1291
|
+
"full_name": "acme-eng/repo-26"
|
|
1292
|
+
},
|
|
1293
|
+
{
|
|
1294
|
+
"id": 27,
|
|
1295
|
+
"name": "repo-27",
|
|
1296
|
+
"full_name": "acme-eng/repo-27"
|
|
1297
|
+
},
|
|
1298
|
+
{
|
|
1299
|
+
"id": 28,
|
|
1300
|
+
"name": "repo-28",
|
|
1301
|
+
"full_name": "acme-eng/repo-28"
|
|
1302
|
+
},
|
|
1303
|
+
{
|
|
1304
|
+
"id": 29,
|
|
1305
|
+
"name": "repo-29",
|
|
1306
|
+
"full_name": "acme-eng/repo-29"
|
|
1307
|
+
},
|
|
1308
|
+
{
|
|
1309
|
+
"id": 30,
|
|
1310
|
+
"name": "repo-30",
|
|
1311
|
+
"full_name": "acme-eng/repo-30"
|
|
1312
|
+
},
|
|
1313
|
+
{
|
|
1314
|
+
"id": 31,
|
|
1315
|
+
"name": "repo-31",
|
|
1316
|
+
"full_name": "acme-eng/repo-31"
|
|
1317
|
+
},
|
|
1318
|
+
{
|
|
1319
|
+
"id": 32,
|
|
1320
|
+
"name": "repo-32",
|
|
1321
|
+
"full_name": "acme-eng/repo-32"
|
|
1322
|
+
},
|
|
1323
|
+
{
|
|
1324
|
+
"id": 33,
|
|
1325
|
+
"name": "repo-33",
|
|
1326
|
+
"full_name": "acme-eng/repo-33"
|
|
1327
|
+
},
|
|
1328
|
+
{
|
|
1329
|
+
"id": 34,
|
|
1330
|
+
"name": "repo-34",
|
|
1331
|
+
"full_name": "acme-eng/repo-34"
|
|
1332
|
+
},
|
|
1333
|
+
{
|
|
1334
|
+
"id": 35,
|
|
1335
|
+
"name": "repo-35",
|
|
1336
|
+
"full_name": "acme-eng/repo-35"
|
|
1337
|
+
},
|
|
1338
|
+
{
|
|
1339
|
+
"id": 36,
|
|
1340
|
+
"name": "repo-36",
|
|
1341
|
+
"full_name": "acme-eng/repo-36"
|
|
1342
|
+
},
|
|
1343
|
+
{
|
|
1344
|
+
"id": 37,
|
|
1345
|
+
"name": "repo-37",
|
|
1346
|
+
"full_name": "acme-eng/repo-37"
|
|
1347
|
+
},
|
|
1348
|
+
{
|
|
1349
|
+
"id": 38,
|
|
1350
|
+
"name": "repo-38",
|
|
1351
|
+
"full_name": "acme-eng/repo-38"
|
|
1352
|
+
},
|
|
1353
|
+
{
|
|
1354
|
+
"id": 39,
|
|
1355
|
+
"name": "repo-39",
|
|
1356
|
+
"full_name": "acme-eng/repo-39"
|
|
1357
|
+
},
|
|
1358
|
+
{
|
|
1359
|
+
"id": 40,
|
|
1360
|
+
"name": "repo-40",
|
|
1361
|
+
"full_name": "acme-eng/repo-40"
|
|
1362
|
+
},
|
|
1363
|
+
{
|
|
1364
|
+
"id": 41,
|
|
1365
|
+
"name": "repo-41",
|
|
1366
|
+
"full_name": "acme-eng/repo-41"
|
|
1367
|
+
},
|
|
1368
|
+
{
|
|
1369
|
+
"id": 42,
|
|
1370
|
+
"name": "repo-42",
|
|
1371
|
+
"full_name": "acme-eng/repo-42"
|
|
1372
|
+
},
|
|
1373
|
+
{
|
|
1374
|
+
"id": 43,
|
|
1375
|
+
"name": "repo-43",
|
|
1376
|
+
"full_name": "acme-eng/repo-43"
|
|
1377
|
+
},
|
|
1378
|
+
{
|
|
1379
|
+
"id": 44,
|
|
1380
|
+
"name": "repo-44",
|
|
1381
|
+
"full_name": "acme-eng/repo-44"
|
|
1382
|
+
},
|
|
1383
|
+
{
|
|
1384
|
+
"id": 45,
|
|
1385
|
+
"name": "repo-45",
|
|
1386
|
+
"full_name": "acme-eng/repo-45"
|
|
1387
|
+
},
|
|
1388
|
+
{
|
|
1389
|
+
"id": 46,
|
|
1390
|
+
"name": "repo-46",
|
|
1391
|
+
"full_name": "acme-eng/repo-46"
|
|
1392
|
+
},
|
|
1393
|
+
{
|
|
1394
|
+
"id": 47,
|
|
1395
|
+
"name": "repo-47",
|
|
1396
|
+
"full_name": "acme-eng/repo-47"
|
|
1397
|
+
},
|
|
1398
|
+
{
|
|
1399
|
+
"id": 48,
|
|
1400
|
+
"name": "repo-48",
|
|
1401
|
+
"full_name": "acme-eng/repo-48"
|
|
1402
|
+
},
|
|
1403
|
+
{
|
|
1404
|
+
"id": 49,
|
|
1405
|
+
"name": "repo-49",
|
|
1406
|
+
"full_name": "acme-eng/repo-49"
|
|
1407
|
+
},
|
|
1408
|
+
{
|
|
1409
|
+
"id": 50,
|
|
1410
|
+
"name": "repo-50",
|
|
1411
|
+
"full_name": "acme-eng/repo-50"
|
|
1412
|
+
}
|
|
1413
|
+
]
|
|
1414
|
+
},
|
|
1415
|
+
"install_repos_remove_batch_2": {
|
|
1416
|
+
"status": 200,
|
|
1417
|
+
"body": [
|
|
1418
|
+
{
|
|
1419
|
+
"id": 51,
|
|
1420
|
+
"name": "repo-51",
|
|
1421
|
+
"full_name": "acme-eng/repo-51"
|
|
1422
|
+
}
|
|
1423
|
+
]
|
|
1424
|
+
},
|
|
1425
|
+
"install_repos_remove_403": {
|
|
1426
|
+
"status": 403,
|
|
1427
|
+
"body": {
|
|
1428
|
+
"message": "Resource not accessible by integration",
|
|
1429
|
+
"documentation_url": "https://docs.github.com/enterprise-cloud@latest/rest/enterprise-admin/organization-installations"
|
|
1430
|
+
}
|
|
1431
|
+
},
|
|
1432
|
+
"install_repos_remove_403_secondary_rate_limit": {
|
|
1433
|
+
"status": 403,
|
|
1434
|
+
"headers": {
|
|
1435
|
+
"retry-after": "60"
|
|
1436
|
+
},
|
|
1437
|
+
"body": {
|
|
1438
|
+
"message": "You have exceeded a secondary rate limit. Please wait a few minutes before you try again.",
|
|
1439
|
+
"documentation_url": "https://docs.github.com/rest/overview/rate-limits-for-the-rest-api#about-secondary-rate-limits"
|
|
1440
|
+
}
|
|
1441
|
+
},
|
|
1442
|
+
"install_repos_remove_404": {
|
|
1443
|
+
"status": 404,
|
|
1444
|
+
"body": {
|
|
1445
|
+
"message": "Not Found",
|
|
1446
|
+
"documentation_url": "https://docs.github.com/enterprise-cloud@latest/rest/enterprise-admin/organization-installations"
|
|
1447
|
+
}
|
|
1448
|
+
},
|
|
1449
|
+
"install_repos_remove_422": {
|
|
1450
|
+
"status": 422,
|
|
1451
|
+
"body": {
|
|
1452
|
+
"message": "Cannot remove the last repository from an installation. Remove the installation instead.",
|
|
1453
|
+
"documentation_url": "https://docs.github.com/enterprise-cloud@latest/rest/enterprise-admin/organization-installations"
|
|
1454
|
+
}
|
|
1455
|
+
},
|
|
1456
|
+
"install_repos_remove_429": {
|
|
1457
|
+
"status": 429,
|
|
1458
|
+
"headers": {
|
|
1459
|
+
"retry-after": "30"
|
|
1460
|
+
},
|
|
1461
|
+
"body": {
|
|
1462
|
+
"message": "API rate limit exceeded",
|
|
1463
|
+
"documentation_url": "https://docs.github.com/rest/overview/rate-limits-for-the-rest-api"
|
|
1464
|
+
}
|
|
1465
|
+
},
|
|
1466
|
+
"install_repos_remove_500": {
|
|
1467
|
+
"status": 500,
|
|
1468
|
+
"body": {
|
|
1469
|
+
"message": "Server Error"
|
|
1470
|
+
}
|
|
1471
|
+
},
|
|
1472
|
+
"install_repos_remove_503": {
|
|
1473
|
+
"status": 503,
|
|
1474
|
+
"body": {
|
|
1475
|
+
"message": "Service Unavailable"
|
|
1476
|
+
}
|
|
1477
|
+
},
|
|
1478
|
+
"install_selection_success": {
|
|
1479
|
+
"status": 200,
|
|
1480
|
+
"body": {
|
|
1481
|
+
"id": 501,
|
|
1482
|
+
"client_id": "Iv1.targetapp0001",
|
|
1483
|
+
"account": {
|
|
1484
|
+
"login": "acme-eng",
|
|
1485
|
+
"id": 5010,
|
|
1486
|
+
"type": "Organization"
|
|
1487
|
+
},
|
|
1488
|
+
"repository_selection": "selected",
|
|
1489
|
+
"access_tokens_url": "https://api.github.com/app/installations/501/access_tokens",
|
|
1490
|
+
"repositories_url": "https://api.github.com/installation/repositories",
|
|
1491
|
+
"html_url": "https://github.com/organizations/acme-eng/settings/installations/501",
|
|
1492
|
+
"app_id": 777,
|
|
1493
|
+
"app_slug": "target-app",
|
|
1494
|
+
"target_id": 5010,
|
|
1495
|
+
"target_type": "Organization",
|
|
1496
|
+
"permissions": {
|
|
1497
|
+
"contents": "write",
|
|
1498
|
+
"metadata": "read"
|
|
1499
|
+
},
|
|
1500
|
+
"events": [],
|
|
1501
|
+
"created_at": "2026-10-01T00:00:00Z",
|
|
1502
|
+
"updated_at": "2026-10-01T00:00:00Z",
|
|
1503
|
+
"single_file_name": null,
|
|
1504
|
+
"suspended_at": null,
|
|
1505
|
+
"suspended_by": null
|
|
1506
|
+
}
|
|
1507
|
+
},
|
|
1508
|
+
"install_selection_all": {
|
|
1509
|
+
"status": 200,
|
|
1510
|
+
"body": {
|
|
1511
|
+
"id": 501,
|
|
1512
|
+
"client_id": "Iv1.targetapp0001",
|
|
1513
|
+
"account": {
|
|
1514
|
+
"login": "acme-eng",
|
|
1515
|
+
"id": 5010,
|
|
1516
|
+
"type": "Organization"
|
|
1517
|
+
},
|
|
1518
|
+
"repository_selection": "all",
|
|
1519
|
+
"access_tokens_url": "https://api.github.com/app/installations/501/access_tokens",
|
|
1520
|
+
"repositories_url": "https://api.github.com/installation/repositories",
|
|
1521
|
+
"html_url": "https://github.com/organizations/acme-eng/settings/installations/501",
|
|
1522
|
+
"app_id": 777,
|
|
1523
|
+
"app_slug": "target-app",
|
|
1524
|
+
"target_id": 5010,
|
|
1525
|
+
"target_type": "Organization",
|
|
1526
|
+
"permissions": {
|
|
1527
|
+
"contents": "write",
|
|
1528
|
+
"metadata": "read"
|
|
1529
|
+
},
|
|
1530
|
+
"events": [],
|
|
1531
|
+
"created_at": "2026-10-01T00:00:00Z",
|
|
1532
|
+
"updated_at": "2026-10-01T00:00:00Z",
|
|
1533
|
+
"single_file_name": null,
|
|
1534
|
+
"suspended_at": null,
|
|
1535
|
+
"suspended_by": null
|
|
1536
|
+
}
|
|
1537
|
+
},
|
|
1538
|
+
"install_selection_403": {
|
|
1539
|
+
"status": 403,
|
|
1540
|
+
"body": {
|
|
1541
|
+
"message": "Resource not accessible by integration",
|
|
1542
|
+
"documentation_url": "https://docs.github.com/enterprise-cloud@latest/rest/enterprise-admin/organization-installations"
|
|
1543
|
+
}
|
|
1544
|
+
},
|
|
1545
|
+
"install_selection_403_secondary_rate_limit": {
|
|
1546
|
+
"status": 403,
|
|
1547
|
+
"headers": {
|
|
1548
|
+
"retry-after": "60"
|
|
1549
|
+
},
|
|
1550
|
+
"body": {
|
|
1551
|
+
"message": "You have exceeded a secondary rate limit. Please wait a few minutes before you try again.",
|
|
1552
|
+
"documentation_url": "https://docs.github.com/rest/overview/rate-limits-for-the-rest-api#about-secondary-rate-limits"
|
|
1553
|
+
}
|
|
1554
|
+
},
|
|
1555
|
+
"install_selection_404": {
|
|
1556
|
+
"status": 404,
|
|
1557
|
+
"body": {
|
|
1558
|
+
"message": "Not Found",
|
|
1559
|
+
"documentation_url": "https://docs.github.com/enterprise-cloud@latest/rest/enterprise-admin/organization-installations"
|
|
1560
|
+
}
|
|
1561
|
+
},
|
|
1562
|
+
"install_selection_422": {
|
|
1563
|
+
"status": 422,
|
|
1564
|
+
"body": {
|
|
1565
|
+
"message": "Validation Failed",
|
|
1566
|
+
"documentation_url": "https://docs.github.com/enterprise-cloud@latest/rest/enterprise-admin/organization-installations"
|
|
1567
|
+
}
|
|
1568
|
+
},
|
|
1569
|
+
"install_selection_429": {
|
|
1570
|
+
"status": 429,
|
|
1571
|
+
"headers": {
|
|
1572
|
+
"retry-after": "30"
|
|
1573
|
+
},
|
|
1574
|
+
"body": {
|
|
1575
|
+
"message": "API rate limit exceeded",
|
|
1576
|
+
"documentation_url": "https://docs.github.com/rest/overview/rate-limits-for-the-rest-api"
|
|
1577
|
+
}
|
|
1578
|
+
},
|
|
1579
|
+
"install_selection_500": {
|
|
1580
|
+
"status": 500,
|
|
1581
|
+
"body": {
|
|
1582
|
+
"message": "Server Error"
|
|
1583
|
+
}
|
|
1584
|
+
},
|
|
1585
|
+
"install_selection_503": {
|
|
1586
|
+
"status": 503,
|
|
1587
|
+
"body": {
|
|
1588
|
+
"message": "Service Unavailable"
|
|
1589
|
+
}
|
|
711
1590
|
}
|
|
712
1591
|
}
|
|
@@ -41,6 +41,10 @@ const ENT = "GET /enterprises/acme/installation";
|
|
|
41
41
|
const MINT = "POST /app/installations/4242/access_tokens";
|
|
42
42
|
const ORGS = "GET /enterprises/acme/apps/installable_organizations";
|
|
43
43
|
const INSTS = "GET /enterprises/acme/apps/organizations/acme-eng/installations";
|
|
44
|
+
const REPOS = "GET /enterprises/acme/apps/organizations/acme-eng/installations/501/repositories";
|
|
45
|
+
const SELECTION = "PATCH /enterprises/acme/apps/organizations/acme-eng/installations/501/repositories";
|
|
46
|
+
const ADD = `${SELECTION}/add`;
|
|
47
|
+
const REMOVE = `${SELECTION}/remove`;
|
|
44
48
|
const INSTALL = "POST /enterprises/acme/apps/organizations/acme-eng/installations";
|
|
45
49
|
|
|
46
50
|
interface Recorded {
|
|
@@ -50,8 +54,11 @@ interface Recorded {
|
|
|
50
54
|
body?: string;
|
|
51
55
|
}
|
|
52
56
|
|
|
53
|
-
/**
|
|
54
|
-
|
|
57
|
+
/**
|
|
58
|
+
* routes: "METHOD /path[?page=N]" or "METHOD /path" -> cassette key. An array
|
|
59
|
+
* of keys is replayed in call order (one per request, e.g. batched PATCHes).
|
|
60
|
+
*/
|
|
61
|
+
function replay(routes: Record<string, string | string[]>) {
|
|
55
62
|
const calls: Recorded[] = [];
|
|
56
63
|
const fetchFn = (async (input: RequestInfo | URL, init?: RequestInit) => {
|
|
57
64
|
const u = new URL(input.toString());
|
|
@@ -64,7 +71,8 @@ function replay(routes: Record<string, string>) {
|
|
|
64
71
|
headers: new Headers(init?.headers),
|
|
65
72
|
body: typeof init?.body === "string" ? init.body : undefined,
|
|
66
73
|
});
|
|
67
|
-
const
|
|
74
|
+
const route = (page && routes[`${base}?page=${page}`]) || routes[base];
|
|
75
|
+
const key = Array.isArray(route) ? route.shift() : route;
|
|
68
76
|
if (!key) throw new Error(`no route for ${base} page=${page}`);
|
|
69
77
|
const entry = cassette[key];
|
|
70
78
|
if (!entry) throw new Error(`cassette key not found: ${key}`);
|
|
@@ -78,7 +86,7 @@ function replay(routes: Record<string, string>) {
|
|
|
78
86
|
|
|
79
87
|
const OK = { [ENT]: "enterprise_installation_success", [MINT]: "access_token_success" };
|
|
80
88
|
|
|
81
|
-
function makeClient(routes: Record<string, string>) {
|
|
89
|
+
function makeClient(routes: Record<string, string | string[]>) {
|
|
82
90
|
const { fetchFn, calls } = replay({ ...OK, ...routes });
|
|
83
91
|
const client = new GithubEnterpriseClient({
|
|
84
92
|
appId: "12345",
|
|
@@ -330,3 +338,167 @@ describe("installOnOrg", () => {
|
|
|
330
338
|
});
|
|
331
339
|
}
|
|
332
340
|
});
|
|
341
|
+
|
|
342
|
+
const names = (a: number, b: number) =>
|
|
343
|
+
Array.from({ length: b - a + 1 }, (_, i) => `repo-${a + i}`);
|
|
344
|
+
|
|
345
|
+
describe("listInstallationRepositories", () => {
|
|
346
|
+
it("maps repositories using the installation token", async () => {
|
|
347
|
+
const { client, calls } = makeClient({ [REPOS]: "install_repos_success" });
|
|
348
|
+
expect(await client.listInstallationRepositories("acme-eng", 501)).toEqual([
|
|
349
|
+
{ id: 1, name: "repo-1", fullName: "acme-eng/repo-1" },
|
|
350
|
+
{ id: 2, name: "repo-2", fullName: "acme-eng/repo-2" },
|
|
351
|
+
]);
|
|
352
|
+
const last = calls[calls.length - 1] as Recorded;
|
|
353
|
+
expect(last.path).toBe(
|
|
354
|
+
"/enterprises/acme/apps/organizations/acme-eng/installations/501/repositories?per_page=100&page=1",
|
|
355
|
+
);
|
|
356
|
+
expect(last.headers.get("authorization")).toBe(
|
|
357
|
+
"Bearer ghs_cassetteInstallationToken0000000000",
|
|
358
|
+
);
|
|
359
|
+
});
|
|
360
|
+
|
|
361
|
+
it("follows Link rel=next across pages", async () => {
|
|
362
|
+
const { client } = makeClient({
|
|
363
|
+
[`${REPOS}?page=1`]: "install_repos_page_1",
|
|
364
|
+
[`${REPOS}?page=2`]: "install_repos_page_2",
|
|
365
|
+
});
|
|
366
|
+
const repos = await client.listInstallationRepositories("acme-eng", 501);
|
|
367
|
+
expect(repos.map((r) => r.name)).toEqual(["repo-1", "repo-2", "repo-3"]);
|
|
368
|
+
});
|
|
369
|
+
|
|
370
|
+
it("returns an empty list", async () => {
|
|
371
|
+
const { client } = makeClient({ [REPOS]: "install_repos_empty" });
|
|
372
|
+
expect(await client.listInstallationRepositories("acme-eng", 501)).toEqual([]);
|
|
373
|
+
});
|
|
374
|
+
|
|
375
|
+
for (const [suffix, kind, status] of ERRORS) {
|
|
376
|
+
it(`${suffix} -> ${kind}`, async () => {
|
|
377
|
+
const { client } = makeClient({ [REPOS]: `install_repos_${suffix}` });
|
|
378
|
+
const e = await errOf(client.listInstallationRepositories("acme-eng", 501));
|
|
379
|
+
expect(e.kind).toBe(kind);
|
|
380
|
+
expect(e.status).toBe(status);
|
|
381
|
+
expectNoSecrets(e);
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
});
|
|
385
|
+
|
|
386
|
+
describe("addRepositories", () => {
|
|
387
|
+
it("patches repository names and maps the result", async () => {
|
|
388
|
+
const { client, calls } = makeClient({ [ADD]: "install_repos_add_success" });
|
|
389
|
+
const r = await client.addRepositories("acme-eng", 501, ["repo-1", "repo-2"]);
|
|
390
|
+
expect(r.map((x) => x.fullName)).toEqual(["acme-eng/repo-1", "acme-eng/repo-2"]);
|
|
391
|
+
const last = calls[calls.length - 1] as Recorded;
|
|
392
|
+
expect(last.method).toBe("PATCH");
|
|
393
|
+
expect(JSON.parse(last.body ?? "")).toEqual({ repositories: ["repo-1", "repo-2"] });
|
|
394
|
+
});
|
|
395
|
+
|
|
396
|
+
it("splits 51 repositories into batches of 50 and 1", async () => {
|
|
397
|
+
const { client, calls } = makeClient({
|
|
398
|
+
[ADD]: ["install_repos_add_batch_1", "install_repos_add_batch_2"],
|
|
399
|
+
});
|
|
400
|
+
const r = await client.addRepositories("acme-eng", 501, names(1, 51));
|
|
401
|
+
expect(r).toHaveLength(51);
|
|
402
|
+
const patches = calls.filter((c) => c.method === "PATCH");
|
|
403
|
+
expect(patches.map((c) => JSON.parse(c.body ?? "").repositories.length)).toEqual([50, 1]);
|
|
404
|
+
expect(patches.every((c) => c.path.endsWith("/repositories/add"))).toBe(true);
|
|
405
|
+
});
|
|
406
|
+
|
|
407
|
+
it("makes no request for an empty list", async () => {
|
|
408
|
+
const { client, calls } = makeClient({});
|
|
409
|
+
expect(await client.addRepositories("acme-eng", 501, [])).toEqual([]);
|
|
410
|
+
expect(calls).toHaveLength(0);
|
|
411
|
+
});
|
|
412
|
+
|
|
413
|
+
for (const [suffix, kind, status] of ERRORS) {
|
|
414
|
+
it(`${suffix} -> ${kind}`, async () => {
|
|
415
|
+
const { client } = makeClient({ [ADD]: `install_repos_add_${suffix}` });
|
|
416
|
+
const e = await errOf(client.addRepositories("acme-eng", 501, ["repo-1"]));
|
|
417
|
+
expect(e.kind).toBe(kind);
|
|
418
|
+
expect(e.status).toBe(status);
|
|
419
|
+
expectNoSecrets(e);
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
});
|
|
423
|
+
|
|
424
|
+
describe("removeRepositories", () => {
|
|
425
|
+
it("patches repository names to /remove", async () => {
|
|
426
|
+
const { client, calls } = makeClient({ [REMOVE]: "install_repos_remove_success" });
|
|
427
|
+
const r = await client.removeRepositories("acme-eng", 501, ["repo-1", "repo-2"]);
|
|
428
|
+
expect(r).toHaveLength(2);
|
|
429
|
+
const last = calls[calls.length - 1] as Recorded;
|
|
430
|
+
expect(last.method).toBe("PATCH");
|
|
431
|
+
expect(last.path).toEndWith("/installations/501/repositories/remove");
|
|
432
|
+
expect(JSON.parse(last.body ?? "")).toEqual({ repositories: ["repo-1", "repo-2"] });
|
|
433
|
+
});
|
|
434
|
+
|
|
435
|
+
it("splits 51 repositories into batches of 50 and 1", async () => {
|
|
436
|
+
const { client, calls } = makeClient({
|
|
437
|
+
[REMOVE]: ["install_repos_remove_batch_1", "install_repos_remove_batch_2"],
|
|
438
|
+
});
|
|
439
|
+
const r = await client.removeRepositories("acme-eng", 501, names(1, 51));
|
|
440
|
+
expect(r).toHaveLength(51);
|
|
441
|
+
const patches = calls.filter((c) => c.method === "PATCH");
|
|
442
|
+
expect(patches.map((c) => JSON.parse(c.body ?? "").repositories.length)).toEqual([50, 1]);
|
|
443
|
+
});
|
|
444
|
+
|
|
445
|
+
it("stops at the first failing batch", async () => {
|
|
446
|
+
const { client, calls } = makeClient({
|
|
447
|
+
[REMOVE]: ["install_repos_remove_batch_1", "install_repos_remove_422"],
|
|
448
|
+
});
|
|
449
|
+
const e = await errOf(client.removeRepositories("acme-eng", 501, names(1, 101)));
|
|
450
|
+
expect(e.kind).toBe("validation");
|
|
451
|
+
expect(calls.filter((c) => c.method === "PATCH")).toHaveLength(2);
|
|
452
|
+
});
|
|
453
|
+
|
|
454
|
+
for (const [suffix, kind, status] of ERRORS) {
|
|
455
|
+
it(`${suffix} -> ${kind}`, async () => {
|
|
456
|
+
const { client } = makeClient({ [REMOVE]: `install_repos_remove_${suffix}` });
|
|
457
|
+
const e = await errOf(client.removeRepositories("acme-eng", 501, ["repo-1"]));
|
|
458
|
+
expect(e.kind).toBe(kind);
|
|
459
|
+
expect(e.status).toBe(status);
|
|
460
|
+
expectNoSecrets(e);
|
|
461
|
+
});
|
|
462
|
+
}
|
|
463
|
+
});
|
|
464
|
+
|
|
465
|
+
describe("setRepositorySelection", () => {
|
|
466
|
+
it("toggles to selected with repositories", async () => {
|
|
467
|
+
const { client, calls } = makeClient({ [SELECTION]: "install_selection_success" });
|
|
468
|
+
const inst = await client.setRepositorySelection("acme-eng", 501, {
|
|
469
|
+
repositorySelection: "selected",
|
|
470
|
+
repositories: ["repo-1"],
|
|
471
|
+
});
|
|
472
|
+
expect(inst.repositorySelection).toBe("selected");
|
|
473
|
+
const last = calls[calls.length - 1] as Recorded;
|
|
474
|
+
expect(last.method).toBe("PATCH");
|
|
475
|
+
expect(JSON.parse(last.body ?? "")).toEqual({
|
|
476
|
+
repository_selection: "selected",
|
|
477
|
+
repositories: ["repo-1"],
|
|
478
|
+
});
|
|
479
|
+
});
|
|
480
|
+
|
|
481
|
+
it("toggles to all without sending repositories", async () => {
|
|
482
|
+
const { client, calls } = makeClient({ [SELECTION]: "install_selection_all" });
|
|
483
|
+
const inst = await client.setRepositorySelection("acme-eng", 501, {
|
|
484
|
+
repositorySelection: "all",
|
|
485
|
+
repositories: ["ignored"],
|
|
486
|
+
});
|
|
487
|
+
expect(inst.repositorySelection).toBe("all");
|
|
488
|
+
expect(JSON.parse((calls[calls.length - 1] as Recorded).body ?? "")).toEqual({
|
|
489
|
+
repository_selection: "all",
|
|
490
|
+
});
|
|
491
|
+
});
|
|
492
|
+
|
|
493
|
+
for (const [suffix, kind, status] of ERRORS) {
|
|
494
|
+
it(`${suffix} -> ${kind}`, async () => {
|
|
495
|
+
const { client } = makeClient({ [SELECTION]: `install_selection_${suffix}` });
|
|
496
|
+
const e = await errOf(
|
|
497
|
+
client.setRepositorySelection("acme-eng", 501, { repositorySelection: "all" }),
|
|
498
|
+
);
|
|
499
|
+
expect(e.kind).toBe(kind);
|
|
500
|
+
expect(e.status).toBe(status);
|
|
501
|
+
expectNoSecrets(e);
|
|
502
|
+
});
|
|
503
|
+
}
|
|
504
|
+
});
|
|
@@ -8,7 +8,14 @@
|
|
|
8
8
|
* POST /app/installations/{id}/access_tokens (JWT) -> call the
|
|
9
9
|
* /enterprises/{enterprise}/apps/... endpoints with the installation token.
|
|
10
10
|
*
|
|
11
|
-
*
|
|
11
|
+
* Repository access on an installation (Phase 3): list, add, remove (max 50
|
|
12
|
+
* names per call, batched here) and the all/selected toggle, all under
|
|
13
|
+
* /enterprises/{enterprise}/apps/organizations/{org}/installations/{id}/repositories
|
|
14
|
+
* (GET list; PATCH toggle; PATCH /add; PATCH /remove). They need the
|
|
15
|
+
* installer permission `enterprise_organization_installation_repositories`.
|
|
16
|
+
* The list/add/remove responses are arrays of { id, name, full_name }; the
|
|
17
|
+
* toggle returns the updated installation. /remove returns 422 when removing
|
|
18
|
+
* from an "all" installation or removing the last repository.
|
|
12
19
|
*
|
|
13
20
|
* ── Verified findings (feed GHE-1.5 docs) ─────────────────────────────────
|
|
14
21
|
* Source: github/rest-api-description descriptions/ghec/ghec.json (fetched
|
|
@@ -156,6 +163,18 @@ export interface InstallOnOrgResult {
|
|
|
156
163
|
created: boolean;
|
|
157
164
|
}
|
|
158
165
|
|
|
166
|
+
export interface AccessibleRepository {
|
|
167
|
+
id: number;
|
|
168
|
+
name: string;
|
|
169
|
+
fullName: string;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export interface SetRepositorySelectionInput {
|
|
173
|
+
repositorySelection: "all" | "selected";
|
|
174
|
+
/** Simple repo names (max 50); required when repositorySelection is "selected". */
|
|
175
|
+
repositories?: string[];
|
|
176
|
+
}
|
|
177
|
+
|
|
159
178
|
export interface EnterpriseInstallationToken {
|
|
160
179
|
token: string;
|
|
161
180
|
expiresAt: string;
|
|
@@ -179,6 +198,19 @@ const MAX_REPOSITORIES = 50;
|
|
|
179
198
|
/** Refresh a cached installation token this long before it expires. */
|
|
180
199
|
const TOKEN_REFRESH_SKEW_MS = 60_000;
|
|
181
200
|
|
|
201
|
+
/**
|
|
202
|
+
* Split repository names into batches of at most MAX_REPOSITORIES, keeping
|
|
203
|
+
* order and dropping blanks and duplicates (GitHub caps each call at 50).
|
|
204
|
+
*/
|
|
205
|
+
export function batchRepositoryNames(names: readonly string[]): string[][] {
|
|
206
|
+
const unique = [...new Set(names.filter((n) => n))];
|
|
207
|
+
const batches: string[][] = [];
|
|
208
|
+
for (let i = 0; i < unique.length; i += MAX_REPOSITORIES) {
|
|
209
|
+
batches.push(unique.slice(i, i + MAX_REPOSITORIES));
|
|
210
|
+
}
|
|
211
|
+
return batches;
|
|
212
|
+
}
|
|
213
|
+
|
|
182
214
|
// ─── Client ───────────────────────────────────────────────────────────────────
|
|
183
215
|
|
|
184
216
|
export class GithubEnterpriseClient {
|
|
@@ -316,8 +348,100 @@ export class GithubEnterpriseClient {
|
|
|
316
348
|
return { installation: toInstallation(res.data), created: res.status === 201 };
|
|
317
349
|
}
|
|
318
350
|
|
|
351
|
+
/** List all repositories an installation can access (paginated). */
|
|
352
|
+
async listInstallationRepositories(
|
|
353
|
+
org: string,
|
|
354
|
+
installationId: number,
|
|
355
|
+
): Promise<AccessibleRepository[]> {
|
|
356
|
+
const rows = await this.paginate<RawRepository>(
|
|
357
|
+
this.repositoriesPath(org, installationId),
|
|
358
|
+
"GitHub installation repositories",
|
|
359
|
+
);
|
|
360
|
+
return rows.map(toRepository);
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
/** Grant an installation access to repositories, in batches of at most 50. */
|
|
364
|
+
async addRepositories(
|
|
365
|
+
org: string,
|
|
366
|
+
installationId: number,
|
|
367
|
+
names: readonly string[],
|
|
368
|
+
): Promise<AccessibleRepository[]> {
|
|
369
|
+
return this.patchRepositories(org, installationId, "add", names, "GitHub add installation repositories");
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
/** Remove repository access from an installation, in batches of at most 50. */
|
|
373
|
+
async removeRepositories(
|
|
374
|
+
org: string,
|
|
375
|
+
installationId: number,
|
|
376
|
+
names: readonly string[],
|
|
377
|
+
): Promise<AccessibleRepository[]> {
|
|
378
|
+
return this.patchRepositories(
|
|
379
|
+
org,
|
|
380
|
+
installationId,
|
|
381
|
+
"remove",
|
|
382
|
+
names,
|
|
383
|
+
"GitHub remove installation repositories",
|
|
384
|
+
);
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
/** Toggle an installation between "all" and "selected" repositories. */
|
|
388
|
+
async setRepositorySelection(
|
|
389
|
+
org: string,
|
|
390
|
+
installationId: number,
|
|
391
|
+
input: SetRepositorySelectionInput,
|
|
392
|
+
): Promise<AppInstallation> {
|
|
393
|
+
const context = "GitHub set installation repository selection";
|
|
394
|
+
const path = this.repositoriesPath(org, installationId);
|
|
395
|
+
const repos = input.repositories ?? [];
|
|
396
|
+
if (input.repositorySelection === "selected" && (repos.length === 0 || repos.length > MAX_REPOSITORIES)) {
|
|
397
|
+
throw new GithubEnterpriseError(
|
|
398
|
+
"validation",
|
|
399
|
+
`setRepositorySelection: repositories must list 1-${MAX_REPOSITORIES} names when repositorySelection is "selected"`,
|
|
400
|
+
);
|
|
401
|
+
}
|
|
402
|
+
const body: Record<string, unknown> = { repository_selection: input.repositorySelection };
|
|
403
|
+
if (input.repositorySelection === "selected") body.repositories = repos;
|
|
404
|
+
const { token } = await this.getInstallationToken();
|
|
405
|
+
const res = await this.request<RawInstallation>("PATCH", path, token, context, body);
|
|
406
|
+
if (typeof res.data?.id !== "number") {
|
|
407
|
+
throw new GithubEnterpriseError("unexpected", `${context}: response missing id`);
|
|
408
|
+
}
|
|
409
|
+
return toInstallation(res.data);
|
|
410
|
+
}
|
|
411
|
+
|
|
319
412
|
// ─── internals ──────────────────────────────────────────────────────────────
|
|
320
413
|
|
|
414
|
+
private repositoriesPath(org: string, installationId: number): string {
|
|
415
|
+
if (!Number.isInteger(installationId) || installationId <= 0) {
|
|
416
|
+
throw new GithubEnterpriseError("validation", "installationId must be a positive integer");
|
|
417
|
+
}
|
|
418
|
+
const ent = encodeURIComponent(this.enterprise);
|
|
419
|
+
return `/enterprises/${ent}/apps/organizations/${encodeURIComponent(org)}/installations/${installationId}/repositories`;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
/** Sequential batched PATCH to /add or /remove; stops at the first failing batch. */
|
|
423
|
+
private async patchRepositories(
|
|
424
|
+
org: string,
|
|
425
|
+
installationId: number,
|
|
426
|
+
action: "add" | "remove",
|
|
427
|
+
names: readonly string[],
|
|
428
|
+
context: string,
|
|
429
|
+
): Promise<AccessibleRepository[]> {
|
|
430
|
+
const path = `${this.repositoriesPath(org, installationId)}/${action}`;
|
|
431
|
+
const batches = batchRepositoryNames(names);
|
|
432
|
+
if (batches.length === 0) return [];
|
|
433
|
+
const { token } = await this.getInstallationToken();
|
|
434
|
+
const out: AccessibleRepository[] = [];
|
|
435
|
+
for (const repositories of batches) {
|
|
436
|
+
const res = await this.request<RawRepository[]>("PATCH", path, token, context, { repositories });
|
|
437
|
+
if (!Array.isArray(res.data)) {
|
|
438
|
+
throw new GithubEnterpriseError("unexpected", `${context}: response is not a list`);
|
|
439
|
+
}
|
|
440
|
+
out.push(...res.data.map(toRepository));
|
|
441
|
+
}
|
|
442
|
+
return out;
|
|
443
|
+
}
|
|
444
|
+
|
|
321
445
|
private async paginate<T>(path: string, context: string): Promise<T[]> {
|
|
322
446
|
const { token } = await this.getInstallationToken();
|
|
323
447
|
const all: T[] = [];
|
|
@@ -340,7 +464,7 @@ export class GithubEnterpriseClient {
|
|
|
340
464
|
}
|
|
341
465
|
|
|
342
466
|
private async request<T>(
|
|
343
|
-
method: "GET" | "POST",
|
|
467
|
+
method: "GET" | "POST" | "PATCH",
|
|
344
468
|
path: string,
|
|
345
469
|
bearer: string,
|
|
346
470
|
context: string,
|
|
@@ -387,6 +511,16 @@ interface RawInstallation {
|
|
|
387
511
|
repository_selection: RepositorySelection;
|
|
388
512
|
}
|
|
389
513
|
|
|
514
|
+
interface RawRepository {
|
|
515
|
+
id: number;
|
|
516
|
+
name: string;
|
|
517
|
+
full_name: string;
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
function toRepository(r: RawRepository): AccessibleRepository {
|
|
521
|
+
return { id: r.id, name: r.name, fullName: r.full_name };
|
|
522
|
+
}
|
|
523
|
+
|
|
390
524
|
function toInstallation(r: RawInstallation): AppInstallation {
|
|
391
525
|
return {
|
|
392
526
|
id: r.id,
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
GithubEnterpriseClient,
|
|
9
9
|
GithubEnterpriseError,
|
|
10
10
|
type GithubEnterpriseErrorKind,
|
|
11
|
+
batchRepositoryNames,
|
|
11
12
|
mapGithubEnterpriseError,
|
|
12
13
|
} from "./github-enterprise-client.ts";
|
|
13
14
|
|
|
@@ -95,3 +96,57 @@ describe("GithubEnterpriseClient validation", () => {
|
|
|
95
96
|
expect(err.kind).toBe("validation");
|
|
96
97
|
});
|
|
97
98
|
});
|
|
99
|
+
|
|
100
|
+
describe("batchRepositoryNames", () => {
|
|
101
|
+
const n = (c: number) => Array.from({ length: c }, (_, i) => `r${i}`);
|
|
102
|
+
const sizes = (c: number) => batchRepositoryNames(n(c)).map((b) => b.length);
|
|
103
|
+
|
|
104
|
+
it("returns no batches for an empty list", () => {
|
|
105
|
+
expect(sizes(0)).toEqual([]);
|
|
106
|
+
});
|
|
107
|
+
it("keeps up to 50 names in one batch", () => {
|
|
108
|
+
expect(sizes(1)).toEqual([1]);
|
|
109
|
+
expect(sizes(50)).toEqual([50]);
|
|
110
|
+
});
|
|
111
|
+
it("splits above 50 and preserves order", () => {
|
|
112
|
+
expect(sizes(51)).toEqual([50, 1]);
|
|
113
|
+
expect(sizes(100)).toEqual([50, 50]);
|
|
114
|
+
expect(sizes(120)).toEqual([50, 50, 20]);
|
|
115
|
+
expect(batchRepositoryNames(n(51)).flat()).toEqual(n(51));
|
|
116
|
+
});
|
|
117
|
+
it("drops duplicates and blank names", () => {
|
|
118
|
+
expect(batchRepositoryNames(["a", "b", "a", ""])).toEqual([["a", "b"]]);
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
describe("repository client validation", () => {
|
|
123
|
+
const neverFetch = (async () => {
|
|
124
|
+
throw new Error("fetch must not be called");
|
|
125
|
+
}) as unknown as typeof fetch;
|
|
126
|
+
const client = new GithubEnterpriseClient({
|
|
127
|
+
appId: "1",
|
|
128
|
+
enterprise: "acme",
|
|
129
|
+
privateKey: "unused",
|
|
130
|
+
fetchFn: neverFetch,
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
it("rejects a non-integer installation id before any network call", async () => {
|
|
134
|
+
const err = await client.listInstallationRepositories("o", Number.NaN).catch((e) => e);
|
|
135
|
+
expect(err.kind).toBe("validation");
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
it("rejects selected without repositories before any network call", async () => {
|
|
139
|
+
const err = await client
|
|
140
|
+
.setRepositorySelection("o", 1, { repositorySelection: "selected" })
|
|
141
|
+
.catch((e) => e);
|
|
142
|
+
expect(err.kind).toBe("validation");
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
it("rejects selected with more than 50 repositories", async () => {
|
|
146
|
+
const repositories = Array.from({ length: 51 }, (_, i) => `r${i}`);
|
|
147
|
+
const err = await client
|
|
148
|
+
.setRepositorySelection("o", 1, { repositorySelection: "selected", repositories })
|
|
149
|
+
.catch((e) => e);
|
|
150
|
+
expect(err.kind).toBe("validation");
|
|
151
|
+
});
|
|
152
|
+
});
|