node-cnb 1.9.0 → 1.10.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/README.md +44 -17
- package/dist/index.js +25 -15
- package/dist/index.js.map +1 -1
- package/dist/paths.json +7777 -8095
- package/package.json +1 -1
- package/pathMethodMap.json +1 -1
- package/src/client.d.ts +216 -0
- package/src/index.ts +27 -21
- package/tsconfig.json +13 -16
package/package.json
CHANGED
package/pathMethodMap.json
CHANGED
package/src/client.d.ts
CHANGED
|
@@ -2841,4 +2841,220 @@ export interface Client {
|
|
|
2841
2841
|
};
|
|
2842
2842
|
};
|
|
2843
2843
|
};
|
|
2844
|
+
|
|
2845
|
+
Organizations: {
|
|
2846
|
+
CreateOrganization: Organizations_CreateOrganization;
|
|
2847
|
+
ListTopGroups: Organizations_ListTopGroups;
|
|
2848
|
+
ListGroups: Organizations_ListGroups;
|
|
2849
|
+
GetGroupsByUserID: Organizations_GetGroupsByUserID;
|
|
2850
|
+
DeleteOrganization: Organizations_DeleteOrganization;
|
|
2851
|
+
GetGroup: Organizations_GetGroup;
|
|
2852
|
+
UpdateOrganization: Organizations_UpdateOrganization;
|
|
2853
|
+
UpdateGroupAvatar: Organizations_UpdateGroupAvatar;
|
|
2854
|
+
GetGroupSetting: Organizations_GetGroupSetting;
|
|
2855
|
+
UpdateGroupSetting: Organizations_UpdateGroupSetting;
|
|
2856
|
+
ListSubgroups: Organizations_ListSubgroups;
|
|
2857
|
+
};
|
|
2858
|
+
|
|
2859
|
+
Users: {
|
|
2860
|
+
GetUserInfo: Users_GetUserInfo;
|
|
2861
|
+
UpdateUserInfo: Users_UpdateUserInfo;
|
|
2862
|
+
AutoCompleteSource: Users_AutoCompleteSource;
|
|
2863
|
+
GetUserInfoByName: Users_GetUserInfoByName;
|
|
2864
|
+
};
|
|
2865
|
+
|
|
2866
|
+
Repositories: {
|
|
2867
|
+
GetRepos: Repositories_GetRepos;
|
|
2868
|
+
GetUserAllStaredRepos: Repositories_GetUserAllStaredRepos;
|
|
2869
|
+
GetPinnedRepoByID: Repositories_GetPinnedRepoByID;
|
|
2870
|
+
GetReposByUserName: Repositories_GetReposByUserName;
|
|
2871
|
+
GetPinnedRepoByGroup: Repositories_GetPinnedRepoByGroup;
|
|
2872
|
+
SetPinnedRepoByGroup: Repositories_SetPinnedRepoByGroup;
|
|
2873
|
+
GetGroupSubRepos: Repositories_GetGroupSubRepos;
|
|
2874
|
+
CreateRepo: Repositories_CreateRepo;
|
|
2875
|
+
DeleteRepo: Repositories_DeleteRepo;
|
|
2876
|
+
GetRepo: Repositories_GetRepo;
|
|
2877
|
+
UpdateRepo: Repositories_UpdateRepo;
|
|
2878
|
+
ListForksRepos: Repositories_ListForksRepos;
|
|
2879
|
+
CreateAFork: Repositories_CreateAFork;
|
|
2880
|
+
};
|
|
2881
|
+
|
|
2882
|
+
Assets: {
|
|
2883
|
+
GetUserAvatar: Assets_GetUserAvatar;
|
|
2884
|
+
PutLogos: Assets_PutLogos;
|
|
2885
|
+
GetLogos: Assets_GetLogos;
|
|
2886
|
+
UploadLogos: Assets_UploadLogos;
|
|
2887
|
+
GetCommitAssets: Assets_GetCommitAssets;
|
|
2888
|
+
GetFiles: Assets_GetFiles;
|
|
2889
|
+
PutFiles: Assets_PutFiles;
|
|
2890
|
+
GetImgs: Assets_GetImgs;
|
|
2891
|
+
PutImgs: Assets_PutImgs;
|
|
2892
|
+
GetReleasesAsset: Assets_GetReleasesAsset;
|
|
2893
|
+
UploadFiles: Assets_UploadFiles;
|
|
2894
|
+
UploadImgs: Assets_UploadImgs;
|
|
2895
|
+
UploadReleases: Assets_UploadReleases;
|
|
2896
|
+
};
|
|
2897
|
+
|
|
2898
|
+
Followers: {
|
|
2899
|
+
GetFollowersByUserID: Followers_GetFollowersByUserID;
|
|
2900
|
+
GetFollowingByUserID: Followers_GetFollowingByUserID;
|
|
2901
|
+
};
|
|
2902
|
+
|
|
2903
|
+
Starring: {
|
|
2904
|
+
GetUserStaredRepos: Starring_GetUserStaredRepos;
|
|
2905
|
+
ListStarUsers: Starring_ListStarUsers;
|
|
2906
|
+
};
|
|
2907
|
+
|
|
2908
|
+
Workspace: {
|
|
2909
|
+
DeleteWorkspace: Workspace_DeleteWorkspace;
|
|
2910
|
+
ListWorkspaces: Workspace_ListWorkspaces;
|
|
2911
|
+
GetWorkspaceDetail: Workspace_GetWorkspaceDetail;
|
|
2912
|
+
};
|
|
2913
|
+
|
|
2914
|
+
Collaborators: {
|
|
2915
|
+
ListInheritMembersOfGroup: Collaborators_ListInheritMembersOfGroup;
|
|
2916
|
+
ListMembersOfGroup: Collaborators_ListMembersOfGroup;
|
|
2917
|
+
DeleteMembersOfGroup: Collaborators_DeleteMembersOfGroup;
|
|
2918
|
+
UpdateMembersOfGroup: Collaborators_UpdateMembersOfGroup;
|
|
2919
|
+
ListInheritMembersOfRepo: Collaborators_ListInheritMembersOfRepo;
|
|
2920
|
+
ListAllMembers: Collaborators_ListAllMembers;
|
|
2921
|
+
ListMembersOfRepo: Collaborators_ListMembersOfRepo;
|
|
2922
|
+
DeleteMembersOfRepo: Collaborators_DeleteMembersOfRepo;
|
|
2923
|
+
UpdateMembersOfRepo: Collaborators_UpdateMembersOfRepo;
|
|
2924
|
+
ListOutsideCollaborators: Collaborators_ListOutsideCollaborators;
|
|
2925
|
+
DeleteOutsideCollaborators: Collaborators_DeleteOutsideCollaborators;
|
|
2926
|
+
UpdateOutsideCollaborators: Collaborators_UpdateOutsideCollaborators;
|
|
2927
|
+
TopContributors: Collaborators_TopContributors;
|
|
2928
|
+
};
|
|
2929
|
+
|
|
2930
|
+
Contributors: {
|
|
2931
|
+
GetMemberAccessLevelOfGroup: Contributors_GetMemberAccessLevelOfGroup;
|
|
2932
|
+
ListMemberAccessLevelOfGroup: Contributors_ListMemberAccessLevelOfGroup;
|
|
2933
|
+
GetMemberAccessLevelOfRepo: Contributors_GetMemberAccessLevelOfRepo;
|
|
2934
|
+
ListMemberAccessLevelOfRepo: Contributors_ListMemberAccessLevelOfRepo;
|
|
2935
|
+
};
|
|
2936
|
+
|
|
2937
|
+
Missions: {
|
|
2938
|
+
DeleteMission: Missions_DeleteMission;
|
|
2939
|
+
};
|
|
2940
|
+
|
|
2941
|
+
Artifactory: {
|
|
2942
|
+
DeleteRegistry: Artifactory_DeleteRegistry;
|
|
2943
|
+
ListPackages: Artifactory_ListPackages;
|
|
2944
|
+
HeadPackages: Artifactory_HeadPackages;
|
|
2945
|
+
GetQuotaByProjectName: Artifactory_GetQuotaByProjectName;
|
|
2946
|
+
GetQuotasByProjectName: Artifactory_GetQuotasByProjectName;
|
|
2947
|
+
DownloadQuotasByProjectName: Artifactory_DownloadQuotasByProjectName;
|
|
2948
|
+
GetPackage: Artifactory_GetPackage;
|
|
2949
|
+
DeletePackageTag: Artifactory_DeletePackageTag;
|
|
2950
|
+
GetPackageTagDetail: Artifactory_GetPackageTagDetail;
|
|
2951
|
+
ListPackageTags: Artifactory_ListPackageTags;
|
|
2952
|
+
};
|
|
2953
|
+
|
|
2954
|
+
Build: {
|
|
2955
|
+
GetBuildLogs: Build_GetBuildLogs;
|
|
2956
|
+
StartBuild: Build_StartBuild;
|
|
2957
|
+
GetBuildStatus: Build_GetBuildStatus;
|
|
2958
|
+
StopBuild: Build_StopBuild;
|
|
2959
|
+
};
|
|
2960
|
+
|
|
2961
|
+
RepoContributor: {
|
|
2962
|
+
GetRepoContributorTrend: RepoContributor_GetRepoContributorTrend;
|
|
2963
|
+
};
|
|
2964
|
+
|
|
2965
|
+
Git: {
|
|
2966
|
+
CreateBlob: Git_CreateBlob;
|
|
2967
|
+
ListBranches: Git_ListBranches;
|
|
2968
|
+
CreateBranch: Git_CreateBranch;
|
|
2969
|
+
DeleteBranch: Git_DeleteBranch;
|
|
2970
|
+
GetBranch: Git_GetBranch;
|
|
2971
|
+
GetCommitAnnotationsInBatch: Git_GetCommitAnnotationsInBatch;
|
|
2972
|
+
GetCommitAnnotations: Git_GetCommitAnnotations;
|
|
2973
|
+
PutCommitAnnotations: Git_PutCommitAnnotations;
|
|
2974
|
+
DeleteCommitAnnotation: Git_DeleteCommitAnnotation;
|
|
2975
|
+
GetCommitAssetsBySha: Git_GetCommitAssetsBySha;
|
|
2976
|
+
PostCommitAssetUploadConfirmation: Git_PostCommitAssetUploadConfirmation;
|
|
2977
|
+
PostCommitAssetUploadURL: Git_PostCommitAssetUploadURL;
|
|
2978
|
+
DeleteCommitAsset: Git_DeleteCommitAsset;
|
|
2979
|
+
GetCommitStatuses: Git_GetCommitStatuses;
|
|
2980
|
+
ListCommits: Git_ListCommits;
|
|
2981
|
+
GetCommit: Git_GetCommit;
|
|
2982
|
+
GetCompareCommits: Git_GetCompareCommits;
|
|
2983
|
+
GetContent: Git_GetContent;
|
|
2984
|
+
GetHead: Git_GetHead;
|
|
2985
|
+
DeleteTagAnnotation: Git_DeleteTagAnnotation;
|
|
2986
|
+
GetTagAnnotations: Git_GetTagAnnotations;
|
|
2987
|
+
PutTagAnnotations: Git_PutTagAnnotations;
|
|
2988
|
+
ListTags: Git_ListTags;
|
|
2989
|
+
CreateTag: Git_CreateTag;
|
|
2990
|
+
DeleteTag: Git_DeleteTag;
|
|
2991
|
+
GetTag: Git_GetTag;
|
|
2992
|
+
};
|
|
2993
|
+
|
|
2994
|
+
Issues: {
|
|
2995
|
+
ListIssues: Issues_ListIssues;
|
|
2996
|
+
CreateIssue: Issues_CreateIssue;
|
|
2997
|
+
GetIssue: Issues_GetIssue;
|
|
2998
|
+
UpdateIssue: Issues_UpdateIssue;
|
|
2999
|
+
ListIssueComments: Issues_ListIssueComments;
|
|
3000
|
+
PostIssueComment: Issues_PostIssueComment;
|
|
3001
|
+
GetIssueComment: Issues_GetIssueComment;
|
|
3002
|
+
PatchIssueComment: Issues_PatchIssueComment;
|
|
3003
|
+
DeleteIssueLabels: Issues_DeleteIssueLabels;
|
|
3004
|
+
ListIssueLabels: Issues_ListIssueLabels;
|
|
3005
|
+
PostIssueLabels: Issues_PostIssueLabels;
|
|
3006
|
+
PutIssueLabels: Issues_PutIssueLabels;
|
|
3007
|
+
DeleteIssueLabel: Issues_DeleteIssueLabel;
|
|
3008
|
+
};
|
|
3009
|
+
|
|
3010
|
+
RepoLabels: {
|
|
3011
|
+
ListLabels: RepoLabels_ListLabels;
|
|
3012
|
+
PostLabel: RepoLabels_PostLabel;
|
|
3013
|
+
DeleteLabel: RepoLabels_DeleteLabel;
|
|
3014
|
+
PatchLabel: RepoLabels_PatchLabel;
|
|
3015
|
+
};
|
|
3016
|
+
|
|
3017
|
+
Pulls: {
|
|
3018
|
+
ListPullsByNumbers: Pulls_ListPullsByNumbers;
|
|
3019
|
+
ListPulls: Pulls_ListPulls;
|
|
3020
|
+
PostPull: Pulls_PostPull;
|
|
3021
|
+
GetPull: Pulls_GetPull;
|
|
3022
|
+
PatchPull: Pulls_PatchPull;
|
|
3023
|
+
ListPullComments: Pulls_ListPullComments;
|
|
3024
|
+
PostPullComment: Pulls_PostPullComment;
|
|
3025
|
+
DeletePullLabels: Pulls_DeletePullLabels;
|
|
3026
|
+
ListPullLabels: Pulls_ListPullLabels;
|
|
3027
|
+
PostPullLabels: Pulls_PostPullLabels;
|
|
3028
|
+
PutPullLabels: Pulls_PutPullLabels;
|
|
3029
|
+
DeletePullLabel: Pulls_DeletePullLabel;
|
|
3030
|
+
MergePull: Pulls_MergePull;
|
|
3031
|
+
PostPullReview: Pulls_PostPullReview;
|
|
3032
|
+
};
|
|
3033
|
+
|
|
3034
|
+
Releases: {
|
|
3035
|
+
ListReleases: Releases_ListReleases;
|
|
3036
|
+
PostRelease: Releases_PostRelease;
|
|
3037
|
+
GetReleaseByTag: Releases_GetReleaseByTag;
|
|
3038
|
+
DeleteRelease: Releases_DeleteRelease;
|
|
3039
|
+
GetReleaseByID: Releases_GetReleaseByID;
|
|
3040
|
+
PatchRelease: Releases_PatchRelease;
|
|
3041
|
+
PostReleaseAssetUploadConfirmation: Releases_PostReleaseAssetUploadConfirmation;
|
|
3042
|
+
PostReleaseAssetUploadURL: Releases_PostReleaseAssetUploadURL;
|
|
3043
|
+
DeleteReleaseAsset: Releases_DeleteReleaseAsset;
|
|
3044
|
+
GetReleaseAsset: Releases_GetReleaseAsset;
|
|
3045
|
+
};
|
|
3046
|
+
|
|
3047
|
+
GitSettings: {
|
|
3048
|
+
ListBranchProtections: GitSettings_ListBranchProtections;
|
|
3049
|
+
PostBranchProtection: GitSettings_PostBranchProtection;
|
|
3050
|
+
DeleteBranchProtection: GitSettings_DeleteBranchProtection;
|
|
3051
|
+
GetBranchProtection: GitSettings_GetBranchProtection;
|
|
3052
|
+
PatchBranchProtection: GitSettings_PatchBranchProtection;
|
|
3053
|
+
GetPipelineSettings: GitSettings_GetPipelineSettings;
|
|
3054
|
+
PutPipelineSettings: GitSettings_PutPipelineSettings;
|
|
3055
|
+
GetPullRequestSettings: GitSettings_GetPullRequestSettings;
|
|
3056
|
+
PutPullRequestSettings: GitSettings_PutPullRequestSettings;
|
|
3057
|
+
GetPushLimitSettings: GitSettings_GetPushLimitSettings;
|
|
3058
|
+
PutPushLimitSettings: GitSettings_PutPushLimitSettings;
|
|
3059
|
+
};
|
|
2844
3060
|
}
|
package/src/index.ts
CHANGED
|
@@ -9,24 +9,7 @@ const callApi = (
|
|
|
9
9
|
params: any,
|
|
10
10
|
): Promise<any> => {
|
|
11
11
|
console.log("call", methodPath);
|
|
12
|
-
const
|
|
13
|
-
const requireParams = methodValue.parameters.filter(
|
|
14
|
-
(item: any) => item.required,
|
|
15
|
-
);
|
|
16
|
-
return requireParams.every(
|
|
17
|
-
(item: any) => (params as any)[item.name] !== undefined,
|
|
18
|
-
);
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
const methodValue =
|
|
22
|
-
methodValues.length === 1
|
|
23
|
-
? methodValues[0]
|
|
24
|
-
: methodValues.filter((item: any) =>
|
|
25
|
-
item.parameters.some((item: any) => item.required),
|
|
26
|
-
)[0] ||
|
|
27
|
-
methodValues.filter((item: any) =>
|
|
28
|
-
item.parameters.every((item: any) => !item.required),
|
|
29
|
-
)[0];
|
|
12
|
+
const methodValue = (paths as any)[methodPath];
|
|
30
13
|
if (!methodValue) {
|
|
31
14
|
throw new Error("未能找出对应api路径");
|
|
32
15
|
}
|
|
@@ -66,7 +49,7 @@ const callApi = (
|
|
|
66
49
|
};
|
|
67
50
|
|
|
68
51
|
export const getClient = (baseUrl: string, token: string): Client => {
|
|
69
|
-
function
|
|
52
|
+
function getProxyForPath(path: string) {
|
|
70
53
|
const methodValue = (paths as any)[path];
|
|
71
54
|
if (methodValue) {
|
|
72
55
|
return (params: any) => callApi(baseUrl, token, path, params);
|
|
@@ -75,19 +58,42 @@ export const getClient = (baseUrl: string, token: string): Client => {
|
|
|
75
58
|
{},
|
|
76
59
|
{
|
|
77
60
|
get(target, prop) {
|
|
78
|
-
return
|
|
61
|
+
return getProxyForPath(path + "." + String(prop));
|
|
79
62
|
},
|
|
80
63
|
},
|
|
81
64
|
);
|
|
82
65
|
}
|
|
83
66
|
}
|
|
67
|
+
function getProxyForTagMethod(tag: string) {
|
|
68
|
+
return new Proxy(
|
|
69
|
+
{},
|
|
70
|
+
{
|
|
71
|
+
get(target, method) {
|
|
72
|
+
const path = Object.keys(paths).find((path) => {
|
|
73
|
+
const item = (paths as any)[path];
|
|
74
|
+
console.log("find method", item, tag, method);
|
|
75
|
+
return item.tags[0] === tag && item.operationId === method;
|
|
76
|
+
});
|
|
77
|
+
const methodValue = (paths as any)[path];
|
|
78
|
+
if (!methodValue) {
|
|
79
|
+
throw new Error(`未能找到对应的api路径: ${tag} ${String(method)}`);
|
|
80
|
+
}
|
|
81
|
+
return (params: any) => callApi(baseUrl, token, path, params);
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
);
|
|
85
|
+
}
|
|
84
86
|
|
|
85
87
|
return new Proxy(
|
|
86
88
|
{},
|
|
87
89
|
{
|
|
88
90
|
get: (target, prop: string) => {
|
|
89
91
|
console.log("get prop", prop);
|
|
90
|
-
|
|
92
|
+
if (/^[A-Z]/.test(prop.charAt(0))) {
|
|
93
|
+
return getProxyForTagMethod(prop);
|
|
94
|
+
} else {
|
|
95
|
+
return getProxyForPath(String(prop));
|
|
96
|
+
}
|
|
91
97
|
},
|
|
92
98
|
},
|
|
93
99
|
) as Client;
|
package/tsconfig.json
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
"src/paths.json"
|
|
16
|
-
],
|
|
17
|
-
}
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"module": "commonjs",
|
|
4
|
+
"noImplicitAny": true,
|
|
5
|
+
"removeComments": true,
|
|
6
|
+
"preserveConstEnums": true,
|
|
7
|
+
"sourceMap": true,
|
|
8
|
+
"resolveJsonModule": true,
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"lib": ["ES2017", "DOM"],
|
|
11
|
+
"outDir": "./dist"
|
|
12
|
+
},
|
|
13
|
+
"include": ["src/index.ts", "src/paths.json"]
|
|
14
|
+
}
|