@catchmexz/fedin-vibe-mcp-server 0.1.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/LICENSE +202 -0
- package/dist/common/errors.js +69 -0
- package/dist/common/modularTemplates.js +483 -0
- package/dist/common/pipelineTemplates.js +19 -0
- package/dist/common/types.js +42 -0
- package/dist/common/utils.js +347 -0
- package/dist/common/version.js +1 -0
- package/dist/index.js +217 -0
- package/dist/operations/appstack/appOrchestrations.js +235 -0
- package/dist/operations/appstack/appTags.js +147 -0
- package/dist/operations/appstack/appTemplates.js +67 -0
- package/dist/operations/appstack/applications.js +154 -0
- package/dist/operations/appstack/changeOrders.js +293 -0
- package/dist/operations/appstack/changeRequests.js +263 -0
- package/dist/operations/appstack/deploymentResources.js +265 -0
- package/dist/operations/appstack/globalVars.js +200 -0
- package/dist/operations/appstack/releaseWorkflows.js +178 -0
- package/dist/operations/appstack/variableGroups.js +216 -0
- package/dist/operations/codeup/branches.js +144 -0
- package/dist/operations/codeup/changeRequestComments.js +89 -0
- package/dist/operations/codeup/changeRequests.js +203 -0
- package/dist/operations/codeup/compare.js +26 -0
- package/dist/operations/codeup/files.js +483 -0
- package/dist/operations/codeup/repositories.js +83 -0
- package/dist/operations/codeup/types.js +372 -0
- package/dist/operations/flow/hostGroup.js +48 -0
- package/dist/operations/flow/pipeline.js +530 -0
- package/dist/operations/flow/pipelineJob.js +113 -0
- package/dist/operations/flow/serviceConnection.js +23 -0
- package/dist/operations/flow/types.js +377 -0
- package/dist/operations/git/git-repository.js +334 -0
- package/dist/operations/git/index.js +210 -0
- package/dist/operations/organization/members.js +94 -0
- package/dist/operations/organization/organization.js +73 -0
- package/dist/operations/organization/types.js +111 -0
- package/dist/operations/packages/artifacts.js +64 -0
- package/dist/operations/packages/repositories.js +35 -0
- package/dist/operations/packages/types.js +56 -0
- package/dist/operations/projex/project.js +206 -0
- package/dist/operations/projex/sprint.js +90 -0
- package/dist/operations/projex/types.js +390 -0
- package/dist/operations/projex/workitem.js +452 -0
- package/dist/tool-handlers/appstack-change-orders.js +55 -0
- package/dist/tool-handlers/appstack-change-requests.js +49 -0
- package/dist/tool-handlers/appstack-deployment-resources.js +43 -0
- package/dist/tool-handlers/appstack-global-vars.js +43 -0
- package/dist/tool-handlers/appstack-orchestrations.js +49 -0
- package/dist/tool-handlers/appstack-tags.js +43 -0
- package/dist/tool-handlers/appstack-templates.js +19 -0
- package/dist/tool-handlers/appstack-variable-groups.js +55 -0
- package/dist/tool-handlers/appstack.js +37 -0
- package/dist/tool-handlers/code-management.js +174 -0
- package/dist/tool-handlers/git/branch-operations.js +1 -0
- package/dist/tool-handlers/git/clone-repository.js +36 -0
- package/dist/tool-handlers/git/create-branch.js +26 -0
- package/dist/tool-handlers/git/get-repository-status.js +33 -0
- package/dist/tool-handlers/git/pull-repository.js +27 -0
- package/dist/tool-handlers/git/push-repository.js +37 -0
- package/dist/tool-handlers/git/switch-branch.js +25 -0
- package/dist/tool-handlers/index.js +43 -0
- package/dist/tool-handlers/organization.js +90 -0
- package/dist/tool-handlers/packages.js +32 -0
- package/dist/tool-handlers/pipeline.js +272 -0
- package/dist/tool-handlers/project-management.js +152 -0
- package/dist/tool-handlers/service-connections.js +16 -0
- package/dist/tool-registry/appstack-change-orders.js +40 -0
- package/dist/tool-registry/appstack-change-requests.js +35 -0
- package/dist/tool-registry/appstack-deployment-resources.js +30 -0
- package/dist/tool-registry/appstack-global-vars.js +30 -0
- package/dist/tool-registry/appstack-orchestrations.js +35 -0
- package/dist/tool-registry/appstack-tags.js +30 -0
- package/dist/tool-registry/appstack-templates.js +10 -0
- package/dist/tool-registry/appstack-variable-groups.js +40 -0
- package/dist/tool-registry/appstack.js +25 -0
- package/dist/tool-registry/code-management.js +89 -0
- package/dist/tool-registry/git-repository.js +41 -0
- package/dist/tool-registry/index.js +6 -0
- package/dist/tool-registry/organization.js +65 -0
- package/dist/tool-registry/packages.js +21 -0
- package/dist/tool-registry/pipeline.js +157 -0
- package/dist/tool-registry/project-management.js +108 -0
- package/dist/tool-registry/service-connections.js +10 -0
- package/package.json +39 -0
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { yunxiaoRequest } from '../../common/utils.js';
|
|
3
|
+
// Define the Variable schema based on the definition in appstack.swagger.json
|
|
4
|
+
const VariableSchema = z.object({
|
|
5
|
+
description: z.string().optional().describe("变量描述"),
|
|
6
|
+
key: z.string().optional().describe("变量键"),
|
|
7
|
+
value: z.string().optional().describe("变量值"),
|
|
8
|
+
}).describe("变量模型");
|
|
9
|
+
// Define the RepoMeta schema based on the definition in appstack.swagger.json
|
|
10
|
+
const RepoMetaSchema = z.object({
|
|
11
|
+
name: z.string().describe("仓库名称"),
|
|
12
|
+
type: z.string().describe("仓库类型"),
|
|
13
|
+
}).describe("仓库信息");
|
|
14
|
+
// Define the Revision schema based on the definition in 变量组.swagger.json
|
|
15
|
+
const RevisionSchema = z.object({
|
|
16
|
+
author: z.string().describe("提交人"),
|
|
17
|
+
commitTime: z.number().describe("提交时间"),
|
|
18
|
+
message: z.string().describe("版本提交信息"),
|
|
19
|
+
refs: z.array(z.string()).describe("关联信息"),
|
|
20
|
+
repoMeta: RepoMetaSchema.describe("仓库元信息"),
|
|
21
|
+
sha: z.string().describe("版本sha值"),
|
|
22
|
+
}).describe("版本信息");
|
|
23
|
+
// Define the RevisionVariableGroup schema based on the definition in 变量组.swagger.json
|
|
24
|
+
const RevisionVariableGroupSchema = z.object({
|
|
25
|
+
displayName: z.string().optional().describe("变量组展示名称"),
|
|
26
|
+
name: z.string().optional().describe("变量组名称"),
|
|
27
|
+
revision: RevisionSchema.optional().describe("版本信息"),
|
|
28
|
+
type: z.enum(["GLOBAL", "TEMPLATE", "APP"]).optional().describe("类型"),
|
|
29
|
+
vars: z.array(VariableSchema).optional().describe("变量列表"),
|
|
30
|
+
}).describe("变量组版本记录");
|
|
31
|
+
// Schema for the GetEnvVariableGroups API
|
|
32
|
+
export const GetEnvVariableGroupsRequestSchema = z.object({
|
|
33
|
+
organizationId: z.string().describe("组织ID"),
|
|
34
|
+
appName: z.string().describe("应用名"),
|
|
35
|
+
envName: z.string().describe("环境名"),
|
|
36
|
+
});
|
|
37
|
+
export const GetEnvVariableGroupsResponseSchema = z.array(RevisionVariableGroupSchema);
|
|
38
|
+
// Schema for the CreateVariableGroup API
|
|
39
|
+
export const CreateVariableGroupRequestSchema = z.object({
|
|
40
|
+
organizationId: z.string().describe("组织ID"),
|
|
41
|
+
appName: z.string().describe("应用名"),
|
|
42
|
+
branchName: z.string().optional().describe("版本分支,默认 master"),
|
|
43
|
+
displayName: z.string().optional().describe("变量组展示名"),
|
|
44
|
+
fromRevisionSha: z.string().describe("变量组版本号"),
|
|
45
|
+
message: z.string().optional().describe("变量组描述信息"),
|
|
46
|
+
name: z.string().optional().describe("变量组唯一名"),
|
|
47
|
+
vars: z.array(VariableSchema).optional().describe("变量列表"),
|
|
48
|
+
});
|
|
49
|
+
export const CreateVariableGroupResponseSchema = RevisionVariableGroupSchema;
|
|
50
|
+
// Schema for the DeleteVariableGroup API
|
|
51
|
+
export const DeleteVariableGroupRequestSchema = z.object({
|
|
52
|
+
organizationId: z.string().describe("组织ID"),
|
|
53
|
+
appName: z.string().describe("应用名"),
|
|
54
|
+
variableGroupName: z.string().describe("变量组名"),
|
|
55
|
+
});
|
|
56
|
+
export const DeleteVariableGroupResponseSchema = z.boolean().describe("调用是否成功");
|
|
57
|
+
// Schema for the GetVariableGroup API
|
|
58
|
+
export const GetVariableGroupRequestSchema = z.object({
|
|
59
|
+
organizationId: z.string().describe("组织ID"),
|
|
60
|
+
appName: z.string().describe("应用名"),
|
|
61
|
+
variableGroupName: z.string().describe("变量组名"),
|
|
62
|
+
});
|
|
63
|
+
export const GetVariableGroupResponseSchema = RevisionVariableGroupSchema;
|
|
64
|
+
// Schema for the UpdateVariableGroup API
|
|
65
|
+
export const UpdateVariableGroupRequestSchema = z.object({
|
|
66
|
+
organizationId: z.string().describe("组织ID"),
|
|
67
|
+
appName: z.string().describe("应用名"),
|
|
68
|
+
variableGroupName: z.string().describe("变量组名"),
|
|
69
|
+
branchName: z.string().optional().describe("版本分支,默认 master"),
|
|
70
|
+
displayName: z.string().optional().describe("变量组展示名"),
|
|
71
|
+
fromRevisionSha: z.string().describe("变量组版本号"),
|
|
72
|
+
message: z.string().optional().describe("变量组描述信息"),
|
|
73
|
+
name: z.string().optional().describe("变量组唯一名"),
|
|
74
|
+
vars: z.array(VariableSchema).optional().describe("变量列表"),
|
|
75
|
+
});
|
|
76
|
+
export const UpdateVariableGroupResponseSchema = RevisionVariableGroupSchema;
|
|
77
|
+
// Schema for the GetAppVariableGroups API
|
|
78
|
+
export const GetAppVariableGroupsRequestSchema = z.object({
|
|
79
|
+
organizationId: z.string().describe("组织ID"),
|
|
80
|
+
appName: z.string().describe("应用名"),
|
|
81
|
+
});
|
|
82
|
+
export const GetAppVariableGroupsResponseSchema = z.array(RevisionVariableGroupSchema);
|
|
83
|
+
// Schema for the GetAppVariableGroupsRevision API
|
|
84
|
+
export const GetAppVariableGroupsRevisionRequestSchema = z.object({
|
|
85
|
+
organizationId: z.string().describe("组织ID"),
|
|
86
|
+
appName: z.string().describe("应用名"),
|
|
87
|
+
});
|
|
88
|
+
export const GetAppVariableGroupsRevisionResponseSchema = RevisionSchema;
|
|
89
|
+
/**
|
|
90
|
+
* Get variable groups for an environment
|
|
91
|
+
*
|
|
92
|
+
* @param params - The request parameters
|
|
93
|
+
* @returns The list of variable groups for the environment
|
|
94
|
+
*/
|
|
95
|
+
export async function getEnvVariableGroups(params) {
|
|
96
|
+
const { organizationId, appName, envName } = params;
|
|
97
|
+
try {
|
|
98
|
+
const response = await yunxiaoRequest(`/oapi/v1/appstack/organizations/${organizationId}/apps/${appName}/envs/${envName}/variableGroups`, {
|
|
99
|
+
method: 'GET',
|
|
100
|
+
});
|
|
101
|
+
return GetEnvVariableGroupsResponseSchema.parse(response);
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
throw error;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Create a variable group
|
|
109
|
+
*
|
|
110
|
+
* @param params - The request parameters
|
|
111
|
+
* @returns The created variable group
|
|
112
|
+
*/
|
|
113
|
+
export async function createVariableGroup(params) {
|
|
114
|
+
const { organizationId, appName, ...body } = params;
|
|
115
|
+
try {
|
|
116
|
+
const response = await yunxiaoRequest(`/oapi/v1/appstack/organizations/${organizationId}/apps/${appName}/variableGroup`, {
|
|
117
|
+
method: 'POST',
|
|
118
|
+
body: body,
|
|
119
|
+
});
|
|
120
|
+
return CreateVariableGroupResponseSchema.parse(response);
|
|
121
|
+
}
|
|
122
|
+
catch (error) {
|
|
123
|
+
throw error;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Delete a variable group
|
|
128
|
+
*
|
|
129
|
+
* @param params - The request parameters
|
|
130
|
+
* @returns Whether the deletion was successful
|
|
131
|
+
*/
|
|
132
|
+
export async function deleteVariableGroup(params) {
|
|
133
|
+
const { organizationId, appName, variableGroupName } = params;
|
|
134
|
+
try {
|
|
135
|
+
const response = await yunxiaoRequest(`/oapi/v1/appstack/organizations/${organizationId}/apps/${appName}/variableGroup/${variableGroupName}`, {
|
|
136
|
+
method: 'DELETE',
|
|
137
|
+
});
|
|
138
|
+
return DeleteVariableGroupResponseSchema.parse(response);
|
|
139
|
+
}
|
|
140
|
+
catch (error) {
|
|
141
|
+
throw error;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Get a variable group
|
|
146
|
+
*
|
|
147
|
+
* @param params - The request parameters
|
|
148
|
+
* @returns The variable group
|
|
149
|
+
*/
|
|
150
|
+
export async function getVariableGroup(params) {
|
|
151
|
+
const { organizationId, appName, variableGroupName } = params;
|
|
152
|
+
try {
|
|
153
|
+
const response = await yunxiaoRequest(`/oapi/v1/appstack/organizations/${organizationId}/apps/${appName}/variableGroup/${variableGroupName}`, {
|
|
154
|
+
method: 'GET',
|
|
155
|
+
});
|
|
156
|
+
return GetVariableGroupResponseSchema.parse(response);
|
|
157
|
+
}
|
|
158
|
+
catch (error) {
|
|
159
|
+
throw error;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Update a variable group
|
|
164
|
+
*
|
|
165
|
+
* @param params - The request parameters
|
|
166
|
+
* @returns The updated variable group
|
|
167
|
+
*/
|
|
168
|
+
export async function updateVariableGroup(params) {
|
|
169
|
+
const { organizationId, appName, variableGroupName, ...body } = params;
|
|
170
|
+
try {
|
|
171
|
+
const response = await yunxiaoRequest(`/oapi/v1/appstack/organizations/${organizationId}/apps/${appName}/variableGroup/${variableGroupName}`, {
|
|
172
|
+
method: 'PUT',
|
|
173
|
+
body: body,
|
|
174
|
+
});
|
|
175
|
+
return UpdateVariableGroupResponseSchema.parse(response);
|
|
176
|
+
}
|
|
177
|
+
catch (error) {
|
|
178
|
+
throw error;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Get variable groups for an application
|
|
183
|
+
*
|
|
184
|
+
* @param params - The request parameters
|
|
185
|
+
* @returns The list of variable groups for the application
|
|
186
|
+
*/
|
|
187
|
+
export async function getAppVariableGroups(params) {
|
|
188
|
+
const { organizationId, appName } = params;
|
|
189
|
+
try {
|
|
190
|
+
const response = await yunxiaoRequest(`/oapi/v1/appstack/organizations/${organizationId}/apps/${appName}/variableGroups`, {
|
|
191
|
+
method: 'GET',
|
|
192
|
+
});
|
|
193
|
+
return GetAppVariableGroupsResponseSchema.parse(response);
|
|
194
|
+
}
|
|
195
|
+
catch (error) {
|
|
196
|
+
throw error;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Get the revision of variable groups for an application
|
|
201
|
+
*
|
|
202
|
+
* @param params - The request parameters
|
|
203
|
+
* @returns The revision of variable groups for the application
|
|
204
|
+
*/
|
|
205
|
+
export async function getAppVariableGroupsRevision(params) {
|
|
206
|
+
const { organizationId, appName } = params;
|
|
207
|
+
try {
|
|
208
|
+
const response = await yunxiaoRequest(`/oapi/v1/appstack/organizations/${organizationId}/apps/${appName}/variableGroups:revision`, {
|
|
209
|
+
method: 'GET',
|
|
210
|
+
});
|
|
211
|
+
return GetAppVariableGroupsRevisionResponseSchema.parse(response);
|
|
212
|
+
}
|
|
213
|
+
catch (error) {
|
|
214
|
+
throw error;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { buildUrl, yunxiaoRequest } from "../../common/utils.js";
|
|
2
|
+
import { CodeupBranchSchema } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* 创建分支
|
|
5
|
+
* @param organizationId
|
|
6
|
+
* @param repositoryId
|
|
7
|
+
* @param branch
|
|
8
|
+
* @param ref
|
|
9
|
+
*/
|
|
10
|
+
export async function createBranchFunc(organizationId, repositoryId, branch, ref = "master") {
|
|
11
|
+
// Automatically handle unencoded slashes in repositoryId
|
|
12
|
+
if (repositoryId.includes("/")) {
|
|
13
|
+
// Found unencoded slash, automatically URL encode it
|
|
14
|
+
const parts = repositoryId.split("/", 2);
|
|
15
|
+
if (parts.length === 2) {
|
|
16
|
+
const encodedRepoName = encodeURIComponent(parts[1]);
|
|
17
|
+
// Remove + signs from encoding (spaces are encoded as +, but we need %20)
|
|
18
|
+
const formattedEncodedName = encodedRepoName.replace(/\+/g, "%20");
|
|
19
|
+
repositoryId = `${parts[0]}%2F${formattedEncodedName}`;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
const baseUrl = `/oapi/v1/codeup/organizations/${organizationId}/repositories/${repositoryId}/branches`;
|
|
23
|
+
// Build query parameters
|
|
24
|
+
const queryParams = {
|
|
25
|
+
branch: branch,
|
|
26
|
+
ref: ref
|
|
27
|
+
};
|
|
28
|
+
const url = buildUrl(baseUrl, queryParams);
|
|
29
|
+
console.error("createBranchFunc url:" + url);
|
|
30
|
+
const response = await yunxiaoRequest(url, {
|
|
31
|
+
method: "POST",
|
|
32
|
+
});
|
|
33
|
+
return CodeupBranchSchema.parse(response);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* 获取分支详情
|
|
37
|
+
* @param organizationId
|
|
38
|
+
* @param repositoryId
|
|
39
|
+
* @param branchName
|
|
40
|
+
*/
|
|
41
|
+
export async function getBranchFunc(organizationId, repositoryId, branchName) {
|
|
42
|
+
// Automatically handle unencoded slashes in repositoryId
|
|
43
|
+
if (repositoryId.includes("/")) {
|
|
44
|
+
// Found unencoded slash, automatically URL encode it
|
|
45
|
+
const parts = repositoryId.split("/", 2);
|
|
46
|
+
if (parts.length === 2) {
|
|
47
|
+
const encodedRepoName = encodeURIComponent(parts[1]);
|
|
48
|
+
// Remove + signs from encoding (spaces are encoded as +, but we need %20)
|
|
49
|
+
const formattedEncodedName = encodedRepoName.replace(/\+/g, "%20");
|
|
50
|
+
repositoryId = `${parts[0]}%2F${formattedEncodedName}`;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
// Automatically handle unencoded slashes in branchName
|
|
54
|
+
if (branchName.includes("/")) {
|
|
55
|
+
branchName = encodeURIComponent(branchName);
|
|
56
|
+
}
|
|
57
|
+
const url = `/oapi/v1/codeup/organizations/${organizationId}/repositories/${repositoryId}/branches/${branchName}`;
|
|
58
|
+
const response = await yunxiaoRequest(url, {
|
|
59
|
+
method: "GET",
|
|
60
|
+
});
|
|
61
|
+
return CodeupBranchSchema.parse(response);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* 删除分支
|
|
65
|
+
* @param organizationId
|
|
66
|
+
* @param repositoryId
|
|
67
|
+
* @param branchName
|
|
68
|
+
*/
|
|
69
|
+
export async function deleteBranchFunc(organizationId, repositoryId, branchName) {
|
|
70
|
+
// Automatically handle unencoded slashes in repositoryId
|
|
71
|
+
if (repositoryId.includes("/")) {
|
|
72
|
+
// Found unencoded slash, automatically URL encode it
|
|
73
|
+
const parts = repositoryId.split("/", 2);
|
|
74
|
+
if (parts.length === 2) {
|
|
75
|
+
const encodedRepoName = encodeURIComponent(parts[1]);
|
|
76
|
+
// Remove + signs from encoding (spaces are encoded as +, but we need %20)
|
|
77
|
+
const formattedEncodedName = encodedRepoName.replace(/\+/g, "%20");
|
|
78
|
+
repositoryId = `${parts[0]}%2F${formattedEncodedName}`;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
// Automatically handle unencoded slashes in branchName
|
|
82
|
+
if (branchName.includes("/")) {
|
|
83
|
+
branchName = encodeURIComponent(branchName);
|
|
84
|
+
}
|
|
85
|
+
const url = `/oapi/v1/codeup/organizations/${organizationId}/repositories/${repositoryId}/branches/${branchName}`;
|
|
86
|
+
const response = await yunxiaoRequest(url, {
|
|
87
|
+
method: "DELETE",
|
|
88
|
+
});
|
|
89
|
+
return {
|
|
90
|
+
branchName: branchName
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* 查询分支列表
|
|
95
|
+
* @param organizationId
|
|
96
|
+
* @param repositoryId
|
|
97
|
+
* @param page
|
|
98
|
+
* @param perPage
|
|
99
|
+
* @param sort
|
|
100
|
+
* @param search
|
|
101
|
+
*/
|
|
102
|
+
export async function listBranchesFunc(organizationId, repositoryId, page, perPage, sort, // Possible values: name_asc, name_desc, updated_asc, updated_desc
|
|
103
|
+
search) {
|
|
104
|
+
console.error("listBranchesFunc page:" + page + " perPage:" + perPage + " sort:" + sort + " search:" + search);
|
|
105
|
+
// Automatically handle unencoded slashes in repositoryId
|
|
106
|
+
if (repositoryId.includes("/")) {
|
|
107
|
+
// Found unencoded slash, automatically URL encode it
|
|
108
|
+
const parts = repositoryId.split("/", 2);
|
|
109
|
+
if (parts.length === 2) {
|
|
110
|
+
const encodedRepoName = encodeURIComponent(parts[1]);
|
|
111
|
+
// Remove + signs from encoding (spaces are encoded as +, but we need %20)
|
|
112
|
+
const formattedEncodedName = encodedRepoName.replace(/\+/g, "%20");
|
|
113
|
+
repositoryId = `${parts[0]}%2F${formattedEncodedName}`;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
const baseUrl = `/oapi/v1/codeup/organizations/${organizationId}/repositories/${repositoryId}/branches`;
|
|
117
|
+
// Build query parameters - use lowercase parameter names as expected by the API
|
|
118
|
+
const queryParams = {};
|
|
119
|
+
if (page !== undefined && page !== null) {
|
|
120
|
+
queryParams.page = page;
|
|
121
|
+
}
|
|
122
|
+
if (perPage !== undefined && perPage !== null) {
|
|
123
|
+
queryParams.perPage = perPage;
|
|
124
|
+
}
|
|
125
|
+
if (sort !== undefined && sort !== null) {
|
|
126
|
+
queryParams.sort = sort;
|
|
127
|
+
}
|
|
128
|
+
if (search !== undefined && search !== null) {
|
|
129
|
+
queryParams.search = search;
|
|
130
|
+
}
|
|
131
|
+
const url = buildUrl(baseUrl, queryParams);
|
|
132
|
+
const response = await yunxiaoRequest(url, {
|
|
133
|
+
method: "GET",
|
|
134
|
+
});
|
|
135
|
+
if (!Array.isArray(response)) {
|
|
136
|
+
return [];
|
|
137
|
+
}
|
|
138
|
+
// Map each branch object and handle null values
|
|
139
|
+
return response.map(branchData => {
|
|
140
|
+
// Filter out null values that would cause parsing errors
|
|
141
|
+
// This is a defensive approach until we update all schemas properly
|
|
142
|
+
return CodeupBranchSchema.parse(branchData);
|
|
143
|
+
});
|
|
144
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { yunxiaoRequest, handleRepositoryIdEncoding } from "../../common/utils.js";
|
|
2
|
+
import { ChangeRequestCommentSchema } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* 创建合并请求评论
|
|
5
|
+
* @param organizationId
|
|
6
|
+
* @param repositoryId
|
|
7
|
+
* @param localId
|
|
8
|
+
* @param comment_type
|
|
9
|
+
* @param content
|
|
10
|
+
* @param draft
|
|
11
|
+
* @param resolved
|
|
12
|
+
* @param patchset_biz_id
|
|
13
|
+
* @param file_path
|
|
14
|
+
* @param line_number
|
|
15
|
+
* @param from_patchset_biz_id
|
|
16
|
+
* @param to_patchset_biz_id
|
|
17
|
+
* @param parent_comment_biz_id
|
|
18
|
+
*/
|
|
19
|
+
export async function createChangeRequestCommentFunc(organizationId, repositoryId, localId, comment_type, // Possible values: GLOBAL_COMMENT, INLINE_COMMENT
|
|
20
|
+
content, draft, resolved, patchset_biz_id, file_path, line_number, from_patchset_biz_id, to_patchset_biz_id, parent_comment_biz_id) {
|
|
21
|
+
const encodedRepoId = handleRepositoryIdEncoding(repositoryId);
|
|
22
|
+
const url = `/oapi/v1/codeup/organizations/${organizationId}/repositories/${encodedRepoId}/changeRequests/${localId}/comments`;
|
|
23
|
+
// 准备payload
|
|
24
|
+
const payload = {
|
|
25
|
+
comment_type: comment_type,
|
|
26
|
+
content: content,
|
|
27
|
+
draft: draft,
|
|
28
|
+
resolved: resolved,
|
|
29
|
+
patchset_biz_id: patchset_biz_id,
|
|
30
|
+
};
|
|
31
|
+
// 根据评论类型添加必要参数
|
|
32
|
+
if (comment_type === "INLINE_COMMENT") {
|
|
33
|
+
// 检查INLINE_COMMENT必需的参数
|
|
34
|
+
if (!file_path || line_number === undefined || !from_patchset_biz_id || !to_patchset_biz_id) {
|
|
35
|
+
throw new Error("For INLINE_COMMENT, file_path, line_number, from_patchset_biz_id, and to_patchset_biz_id are required");
|
|
36
|
+
}
|
|
37
|
+
payload.file_path = file_path;
|
|
38
|
+
payload.line_number = line_number;
|
|
39
|
+
payload.from_patchset_biz_id = from_patchset_biz_id;
|
|
40
|
+
payload.to_patchset_biz_id = to_patchset_biz_id;
|
|
41
|
+
}
|
|
42
|
+
// 添加可选参数
|
|
43
|
+
if (parent_comment_biz_id) {
|
|
44
|
+
payload.parent_comment_biz_id = parent_comment_biz_id;
|
|
45
|
+
}
|
|
46
|
+
const response = await yunxiaoRequest(url, {
|
|
47
|
+
method: "POST",
|
|
48
|
+
body: payload,
|
|
49
|
+
});
|
|
50
|
+
return ChangeRequestCommentSchema.parse(response);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* 获取合并请求评论列表
|
|
54
|
+
* @param organizationId
|
|
55
|
+
* @param repositoryId
|
|
56
|
+
* @param localId
|
|
57
|
+
* @param patchSetBizIds
|
|
58
|
+
* @param commentType
|
|
59
|
+
* @param state
|
|
60
|
+
* @param resolved
|
|
61
|
+
* @param filePath
|
|
62
|
+
*/
|
|
63
|
+
export async function listChangeRequestCommentsFunc(organizationId, repositoryId, localId, patchSetBizIds, commentType = "GLOBAL_COMMENT", // Possible values: GLOBAL_COMMENT, INLINE_COMMENT
|
|
64
|
+
state = "OPENED", // Possible values: OPENED, DRAFT
|
|
65
|
+
resolved = false, filePath) {
|
|
66
|
+
const encodedRepoId = handleRepositoryIdEncoding(repositoryId);
|
|
67
|
+
const url = `/oapi/v1/codeup/organizations/${organizationId}/repositories/${encodedRepoId}/changeRequests/${localId}/comments/list`;
|
|
68
|
+
// 准备payload
|
|
69
|
+
const payload = {
|
|
70
|
+
patchSetBizIds: patchSetBizIds || [],
|
|
71
|
+
commentType: commentType,
|
|
72
|
+
state: state,
|
|
73
|
+
resolved: resolved,
|
|
74
|
+
};
|
|
75
|
+
// 添加可选参数
|
|
76
|
+
if (filePath) {
|
|
77
|
+
payload.filePath = filePath;
|
|
78
|
+
}
|
|
79
|
+
const response = await yunxiaoRequest(url, {
|
|
80
|
+
method: "POST",
|
|
81
|
+
body: payload,
|
|
82
|
+
});
|
|
83
|
+
// 确保响应是数组
|
|
84
|
+
if (!Array.isArray(response)) {
|
|
85
|
+
return [];
|
|
86
|
+
}
|
|
87
|
+
// 解析每个评论对象
|
|
88
|
+
return response.map(comment => ChangeRequestCommentSchema.parse(comment));
|
|
89
|
+
}
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { yunxiaoRequest, buildUrl, handleRepositoryIdEncoding, floatToIntString } from "../../common/utils.js";
|
|
2
|
+
import { ChangeRequestSchema, PatchSetSchema } from "./types.js";
|
|
3
|
+
// 通过API获取仓库的数字ID
|
|
4
|
+
async function getRepositoryNumericId(organizationId, repositoryId) {
|
|
5
|
+
const url = `/oapi/v1/codeup/organizations/${organizationId}/repositories/${repositoryId}`;
|
|
6
|
+
const response = await yunxiaoRequest(url, {
|
|
7
|
+
method: "GET",
|
|
8
|
+
});
|
|
9
|
+
if (!response || typeof response !== 'object' || !('id' in response)) {
|
|
10
|
+
throw new Error("Failed to get repository ID");
|
|
11
|
+
}
|
|
12
|
+
const repoId = response.id;
|
|
13
|
+
if (!repoId) {
|
|
14
|
+
throw new Error("Could not get repository ID");
|
|
15
|
+
}
|
|
16
|
+
return repoId.toString();
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* 查询合并请求
|
|
20
|
+
* @param organizationId
|
|
21
|
+
* @param repositoryId
|
|
22
|
+
* @param localId
|
|
23
|
+
*/
|
|
24
|
+
export async function getChangeRequestFunc(organizationId, repositoryId, localId) {
|
|
25
|
+
const encodedRepoId = handleRepositoryIdEncoding(repositoryId);
|
|
26
|
+
const url = `/oapi/v1/codeup/organizations/${organizationId}/repositories/${encodedRepoId}/changeRequests/${localId}`;
|
|
27
|
+
const response = await yunxiaoRequest(url, {
|
|
28
|
+
method: "GET",
|
|
29
|
+
});
|
|
30
|
+
return ChangeRequestSchema.parse(response);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* 查询合并请求列表
|
|
34
|
+
* @param organizationId
|
|
35
|
+
* @param page
|
|
36
|
+
* @param perPage
|
|
37
|
+
* @param projectIds
|
|
38
|
+
* @param authorIds
|
|
39
|
+
* @param reviewerIds
|
|
40
|
+
* @param state
|
|
41
|
+
* @param search
|
|
42
|
+
* @param orderBy
|
|
43
|
+
* @param sort
|
|
44
|
+
* @param createdBefore
|
|
45
|
+
* @param createdAfter
|
|
46
|
+
*/
|
|
47
|
+
export async function listChangeRequestsFunc(organizationId, page, perPage, projectIds, authorIds, reviewerIds, state, // Possible values: opened, merged, closed
|
|
48
|
+
search, orderBy, // Possible values: created_at, updated_at
|
|
49
|
+
sort, // Possible values: asc, desc
|
|
50
|
+
createdBefore, createdAfter) {
|
|
51
|
+
const baseUrl = `/oapi/v1/codeup/organizations/${organizationId}/changeRequests`;
|
|
52
|
+
// 构建查询参数
|
|
53
|
+
const queryParams = {};
|
|
54
|
+
if (page !== undefined) {
|
|
55
|
+
queryParams.page = page;
|
|
56
|
+
}
|
|
57
|
+
if (perPage !== undefined) {
|
|
58
|
+
queryParams.perPage = perPage;
|
|
59
|
+
}
|
|
60
|
+
if (projectIds !== undefined) {
|
|
61
|
+
queryParams.projectIds = projectIds;
|
|
62
|
+
}
|
|
63
|
+
if (authorIds !== undefined) {
|
|
64
|
+
queryParams.authorIds = authorIds;
|
|
65
|
+
}
|
|
66
|
+
if (reviewerIds !== undefined) {
|
|
67
|
+
queryParams.reviewerIds = reviewerIds;
|
|
68
|
+
}
|
|
69
|
+
if (state !== undefined) {
|
|
70
|
+
queryParams.state = state;
|
|
71
|
+
}
|
|
72
|
+
if (search !== undefined) {
|
|
73
|
+
queryParams.search = search;
|
|
74
|
+
}
|
|
75
|
+
if (orderBy !== undefined) {
|
|
76
|
+
queryParams.orderBy = orderBy;
|
|
77
|
+
}
|
|
78
|
+
if (sort !== undefined) {
|
|
79
|
+
queryParams.sort = sort;
|
|
80
|
+
}
|
|
81
|
+
if (createdBefore !== undefined) {
|
|
82
|
+
queryParams.createdBefore = createdBefore;
|
|
83
|
+
}
|
|
84
|
+
if (createdAfter !== undefined) {
|
|
85
|
+
queryParams.createdAfter = createdAfter;
|
|
86
|
+
}
|
|
87
|
+
// 使用buildUrl函数构建包含查询参数的URL
|
|
88
|
+
const url = buildUrl(baseUrl, queryParams);
|
|
89
|
+
const response = await yunxiaoRequest(url, {
|
|
90
|
+
method: "GET",
|
|
91
|
+
});
|
|
92
|
+
// 确保响应是数组
|
|
93
|
+
if (!Array.isArray(response)) {
|
|
94
|
+
return [];
|
|
95
|
+
}
|
|
96
|
+
// 解析每个变更请求对象
|
|
97
|
+
return response.map(changeRequest => ChangeRequestSchema.parse(changeRequest));
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* 查询合并请求的版本列表
|
|
101
|
+
* @param organizationId
|
|
102
|
+
* @param repositoryId
|
|
103
|
+
* @param localId
|
|
104
|
+
*/
|
|
105
|
+
export async function listChangeRequestPatchSetsFunc(organizationId, repositoryId, localId) {
|
|
106
|
+
const encodedRepoId = handleRepositoryIdEncoding(repositoryId);
|
|
107
|
+
const url = `/oapi/v1/codeup/organizations/${organizationId}/repositories/${encodedRepoId}/changeRequests/${localId}/diffs/patches`;
|
|
108
|
+
const response = await yunxiaoRequest(url, {
|
|
109
|
+
method: "GET",
|
|
110
|
+
});
|
|
111
|
+
// 确保响应是数组
|
|
112
|
+
if (!Array.isArray(response)) {
|
|
113
|
+
return [];
|
|
114
|
+
}
|
|
115
|
+
// 解析每个版本对象
|
|
116
|
+
return response.map(patchSet => PatchSetSchema.parse(patchSet));
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* 创建合并请求
|
|
120
|
+
* @param organizationId
|
|
121
|
+
* @param repositoryId
|
|
122
|
+
* @param title
|
|
123
|
+
* @param sourceBranch
|
|
124
|
+
* @param targetBranch
|
|
125
|
+
* @param description
|
|
126
|
+
* @param sourceProjectId
|
|
127
|
+
* @param targetProjectId
|
|
128
|
+
* @param reviewerUserIds
|
|
129
|
+
* @param workItemIds
|
|
130
|
+
* @param createFrom
|
|
131
|
+
*/
|
|
132
|
+
export async function createChangeRequestFunc(organizationId, repositoryId, title, sourceBranch, targetBranch, description, sourceProjectId, targetProjectId, reviewerUserIds, workItemIds, createFrom = "WEB" // Possible values: WEB, COMMAND_LINE
|
|
133
|
+
) {
|
|
134
|
+
const encodedRepoId = handleRepositoryIdEncoding(repositoryId);
|
|
135
|
+
// 检查和获取sourceProjectId和targetProjectId
|
|
136
|
+
let sourceIdString;
|
|
137
|
+
let targetIdString;
|
|
138
|
+
if (sourceProjectId !== undefined) {
|
|
139
|
+
sourceIdString = floatToIntString(sourceProjectId);
|
|
140
|
+
}
|
|
141
|
+
if (targetProjectId !== undefined) {
|
|
142
|
+
targetIdString = floatToIntString(targetProjectId);
|
|
143
|
+
}
|
|
144
|
+
// 如果repositoryId是纯数字,且sourceProjectId或targetProjectId未提供,直接使用repositoryId的值
|
|
145
|
+
if (!isNaN(Number(repositoryId))) {
|
|
146
|
+
// 是数字ID,可以直接使用
|
|
147
|
+
if (sourceIdString === undefined) {
|
|
148
|
+
sourceIdString = repositoryId;
|
|
149
|
+
}
|
|
150
|
+
if (targetIdString === undefined) {
|
|
151
|
+
targetIdString = repositoryId;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
else if (repositoryId.includes("%2F") || repositoryId.includes("/")) {
|
|
155
|
+
// 如果是组织ID与仓库名称的组合,调用API获取数字ID
|
|
156
|
+
if (sourceIdString === undefined || targetIdString === undefined) {
|
|
157
|
+
try {
|
|
158
|
+
const numericId = await getRepositoryNumericId(organizationId, encodedRepoId);
|
|
159
|
+
if (sourceIdString === undefined) {
|
|
160
|
+
sourceIdString = numericId;
|
|
161
|
+
}
|
|
162
|
+
if (targetIdString === undefined) {
|
|
163
|
+
targetIdString = numericId;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
catch (error) {
|
|
167
|
+
throw new Error(`When using 'organizationId%2Frepo-name' format, you must first get the numeric ID of the repository and use it for sourceProjectId and targetProjectId parameters. Please use get_repository tool to get the numeric ID of '${repositoryId}' and then use that ID as the value for sourceProjectId and targetProjectId.`);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
// 确保sourceProjectId和targetProjectId已设置
|
|
172
|
+
if (sourceIdString === undefined) {
|
|
173
|
+
throw new Error("Could not get sourceProjectId, please provide this parameter manually");
|
|
174
|
+
}
|
|
175
|
+
if (targetIdString === undefined) {
|
|
176
|
+
throw new Error("Could not get targetProjectId, please provide this parameter manually");
|
|
177
|
+
}
|
|
178
|
+
const url = `/oapi/v1/codeup/organizations/${organizationId}/repositories/${encodedRepoId}/changeRequests`;
|
|
179
|
+
// 准备payload
|
|
180
|
+
const payload = {
|
|
181
|
+
title: title,
|
|
182
|
+
sourceBranch: sourceBranch,
|
|
183
|
+
targetBranch: targetBranch,
|
|
184
|
+
sourceProjectId: sourceIdString,
|
|
185
|
+
targetProjectId: targetIdString,
|
|
186
|
+
createFrom: createFrom,
|
|
187
|
+
};
|
|
188
|
+
// 添加可选参数
|
|
189
|
+
if (description !== undefined) {
|
|
190
|
+
payload.description = description;
|
|
191
|
+
}
|
|
192
|
+
if (reviewerUserIds !== undefined) {
|
|
193
|
+
payload.reviewerUserIds = reviewerUserIds;
|
|
194
|
+
}
|
|
195
|
+
if (workItemIds !== undefined) {
|
|
196
|
+
payload.workItemIds = workItemIds;
|
|
197
|
+
}
|
|
198
|
+
const response = await yunxiaoRequest(url, {
|
|
199
|
+
method: "POST",
|
|
200
|
+
body: payload,
|
|
201
|
+
});
|
|
202
|
+
return ChangeRequestSchema.parse(response);
|
|
203
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { yunxiaoRequest, buildUrl, handleRepositoryIdEncoding } from "../../common/utils.js";
|
|
2
|
+
import { CompareSchema } from "./types.js";
|
|
3
|
+
export async function getCompareFunc(organizationId, repositoryId, from, to, sourceType, // Possible values: branch, tag
|
|
4
|
+
targetType, // Possible values: branch, tag
|
|
5
|
+
straight) {
|
|
6
|
+
const encodedRepoId = handleRepositoryIdEncoding(repositoryId);
|
|
7
|
+
const baseUrl = `/oapi/v1/codeup/organizations/${organizationId}/repositories/${encodedRepoId}/compares`;
|
|
8
|
+
const queryParams = {
|
|
9
|
+
from,
|
|
10
|
+
to
|
|
11
|
+
};
|
|
12
|
+
if (sourceType !== undefined) {
|
|
13
|
+
queryParams.sourceType = sourceType;
|
|
14
|
+
}
|
|
15
|
+
if (targetType !== undefined) {
|
|
16
|
+
queryParams.targetType = targetType;
|
|
17
|
+
}
|
|
18
|
+
if (straight !== undefined) {
|
|
19
|
+
queryParams.straight = straight;
|
|
20
|
+
}
|
|
21
|
+
const url = buildUrl(baseUrl, queryParams);
|
|
22
|
+
const response = await yunxiaoRequest(url, {
|
|
23
|
+
method: "GET",
|
|
24
|
+
});
|
|
25
|
+
return CompareSchema.parse(response);
|
|
26
|
+
}
|