devops-mcp-server-extension 1.0.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 +218 -0
- package/README.md +527 -0
- package/README.zh-cn.md +503 -0
- package/dist/common/errors.js +77 -0
- package/dist/common/modularTemplates.js +483 -0
- package/dist/common/pipelineTemplates.js +19 -0
- package/dist/common/toolsetManager.js +123 -0
- package/dist/common/toolsets.js +23 -0
- package/dist/common/types.js +60 -0
- package/dist/common/utils.js +381 -0
- package/dist/common/version.js +1 -0
- package/dist/index.js +225 -0
- package/dist/operations/appstack/appOrchestrations.js +260 -0
- package/dist/operations/appstack/appTags.js +168 -0
- package/dist/operations/appstack/appTemplates.js +72 -0
- package/dist/operations/appstack/applications.js +171 -0
- package/dist/operations/appstack/changeOrders.js +320 -0
- package/dist/operations/appstack/changeRequests.js +288 -0
- package/dist/operations/appstack/deploymentResources.js +286 -0
- package/dist/operations/appstack/globalVars.js +221 -0
- package/dist/operations/appstack/releaseWorkflows.js +695 -0
- package/dist/operations/appstack/variableGroups.js +245 -0
- package/dist/operations/codeup/branches.js +157 -0
- package/dist/operations/codeup/changeRequestComments.js +140 -0
- package/dist/operations/codeup/changeRequests.js +230 -0
- package/dist/operations/codeup/commits.js +121 -0
- package/dist/operations/codeup/compare.js +30 -0
- package/dist/operations/codeup/files.js +249 -0
- package/dist/operations/codeup/repositories.js +71 -0
- package/dist/operations/codeup/types.js +414 -0
- package/dist/operations/flow/hostGroup.js +52 -0
- package/dist/operations/flow/pipeline.js +609 -0
- package/dist/operations/flow/pipelineJob.js +126 -0
- package/dist/operations/flow/resourceMember.js +137 -0
- package/dist/operations/flow/serviceConnection.js +27 -0
- package/dist/operations/flow/tag.js +191 -0
- package/dist/operations/flow/types.js +523 -0
- package/dist/operations/flow/vmDeployOrder.js +171 -0
- package/dist/operations/organization/members.js +106 -0
- package/dist/operations/organization/organization.js +110 -0
- package/dist/operations/organization/types.js +111 -0
- package/dist/operations/packages/artifacts.js +71 -0
- package/dist/operations/packages/repositories.js +39 -0
- package/dist/operations/packages/types.js +56 -0
- package/dist/operations/projex/effort.js +122 -0
- package/dist/operations/projex/project.js +243 -0
- package/dist/operations/projex/sprint.js +103 -0
- package/dist/operations/projex/types.js +618 -0
- package/dist/operations/projex/workitem.js +826 -0
- package/dist/operations/testhub/testcases.js +240 -0
- package/dist/operations/testhub/testplans.js +128 -0
- package/dist/tool-handlers/appstack-app-release-workflows.js +103 -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 +31 -0
- package/dist/tool-handlers/appstack-global-vars.js +37 -0
- package/dist/tool-handlers/appstack-orchestrations.js +49 -0
- package/dist/tool-handlers/appstack-release-workflows.js +37 -0
- package/dist/tool-handlers/appstack-tags.js +37 -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/base.js +25 -0
- package/dist/tool-handlers/code-management.js +150 -0
- package/dist/tool-handlers/commit.js +31 -0
- package/dist/tool-handlers/effort.js +103 -0
- package/dist/tool-handlers/index.js +119 -0
- package/dist/tool-handlers/organization.js +72 -0
- package/dist/tool-handlers/packages.js +32 -0
- package/dist/tool-handlers/pipeline.js +289 -0
- package/dist/tool-handlers/project-management.js +201 -0
- package/dist/tool-handlers/resourceMember.js +43 -0
- package/dist/tool-handlers/service-connections.js +16 -0
- package/dist/tool-handlers/tag.js +64 -0
- package/dist/tool-handlers/test-management.js +74 -0
- package/dist/tool-handlers/vmDeployOrder.js +50 -0
- package/dist/tool-registry/appstack-app-release-workflows.js +80 -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 +20 -0
- package/dist/tool-registry/appstack-global-vars.js +25 -0
- package/dist/tool-registry/appstack-orchestrations.js +35 -0
- package/dist/tool-registry/appstack-release-workflows.js +25 -0
- package/dist/tool-registry/appstack-tags.js +25 -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/base.js +19 -0
- package/dist/tool-registry/code-management.js +109 -0
- package/dist/tool-registry/commit.js +20 -0
- package/dist/tool-registry/effort.js +39 -0
- package/dist/tool-registry/index.js +7 -0
- package/dist/tool-registry/organization.js +65 -0
- package/dist/tool-registry/packages.js +21 -0
- package/dist/tool-registry/pipeline.js +190 -0
- package/dist/tool-registry/project-management.js +143 -0
- package/dist/tool-registry/resourceMember.js +29 -0
- package/dist/tool-registry/service-connections.js +10 -0
- package/dist/tool-registry/tag.js +44 -0
- package/dist/tool-registry/test-management.js +59 -0
- package/dist/tool-registry/vmDeployOrder.js +34 -0
- package/package.json +52 -0
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 流水线任务相关操作
|
|
3
|
+
* 提供按照分类获取流水线执行的任务接口
|
|
4
|
+
*/
|
|
5
|
+
import * as utils from "../../common/utils.js";
|
|
6
|
+
import { resolveOrganizationId } from "../organization/organization.js";
|
|
7
|
+
import { PipelineJobItemSchema, PipelineJobHistoryItemSchema, PipelineJobRunLogSchema } from "./types.js";
|
|
8
|
+
/**
|
|
9
|
+
* 按任务分类获取流水线执行的任务
|
|
10
|
+
* @param organizationId Organization ID(组织ID)
|
|
11
|
+
* @param pipelineId Pipeline ID(流水线ID)
|
|
12
|
+
* @param category Task category, currently only supports DEPLOY(任务分类,当前仅支持DEPLOY)
|
|
13
|
+
* @returns 任务列表
|
|
14
|
+
*/
|
|
15
|
+
export async function listPipelineJobsByCategoryFunc(organizationId, pipelineId, category) {
|
|
16
|
+
const finalOrgId = await resolveOrganizationId(organizationId);
|
|
17
|
+
const url = utils.isRegionEdition()
|
|
18
|
+
? `/oapi/v1/flow/pipelines/${pipelineId}/listTasksByCategory/${category}`
|
|
19
|
+
: `/oapi/v1/flow/organizations/${finalOrgId}/pipelines/${pipelineId}/listTasksByCategory/${category}`;
|
|
20
|
+
const response = await utils.yunxiaoRequest(url, {
|
|
21
|
+
method: "GET",
|
|
22
|
+
});
|
|
23
|
+
if (!Array.isArray(response)) {
|
|
24
|
+
return [];
|
|
25
|
+
}
|
|
26
|
+
return response.map(job => PipelineJobItemSchema.parse(job));
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* 获取流水线任务的执行历史
|
|
30
|
+
* @param organizationId Organization ID(组织ID)
|
|
31
|
+
* @param pipelineId Pipeline ID(流水线ID)
|
|
32
|
+
* @param category Task category, currently only supports DEPLOY(任务分类,当前仅支持DEPLOY)
|
|
33
|
+
* @param identifier Task identifier(任务标识)
|
|
34
|
+
* @param page Page number, default 1
|
|
35
|
+
* @param perPage Number of items per page, default 10, max 30
|
|
36
|
+
* @returns Job history list and pagination information
|
|
37
|
+
*/
|
|
38
|
+
export async function listPipelineJobHistorysFunc(organizationId, pipelineId, category, identifier, page = 1, perPage = 10) {
|
|
39
|
+
const finalOrgId = await resolveOrganizationId(organizationId);
|
|
40
|
+
const baseUrl = utils.isRegionEdition()
|
|
41
|
+
? `/oapi/v1/flow/pipelines/getComponentsWithoutButtons`
|
|
42
|
+
: `/oapi/v1/flow/organizations/${finalOrgId}/pipelines/getComponentsWithoutButtons`;
|
|
43
|
+
const queryParams = {
|
|
44
|
+
pipelineId,
|
|
45
|
+
category,
|
|
46
|
+
identifier,
|
|
47
|
+
page,
|
|
48
|
+
perPage
|
|
49
|
+
};
|
|
50
|
+
const url = utils.buildUrl(baseUrl, queryParams);
|
|
51
|
+
const response = await utils.yunxiaoRequest(url, {
|
|
52
|
+
method: "GET",
|
|
53
|
+
});
|
|
54
|
+
const pagination = {
|
|
55
|
+
nextPage: null,
|
|
56
|
+
page: page,
|
|
57
|
+
perPage: perPage,
|
|
58
|
+
prevPage: null,
|
|
59
|
+
total: 0,
|
|
60
|
+
totalPages: 0
|
|
61
|
+
};
|
|
62
|
+
if (response && 'headers' in response) {
|
|
63
|
+
const headers = response.headers;
|
|
64
|
+
if (headers['x-next-page']) {
|
|
65
|
+
pagination.nextPage = parseInt(headers['x-next-page']);
|
|
66
|
+
}
|
|
67
|
+
if (headers['x-page']) {
|
|
68
|
+
pagination.page = parseInt(headers['x-page']);
|
|
69
|
+
}
|
|
70
|
+
if (headers['x-per-page']) {
|
|
71
|
+
pagination.perPage = parseInt(headers['x-per-page']);
|
|
72
|
+
}
|
|
73
|
+
if (headers['x-prev-page']) {
|
|
74
|
+
pagination.prevPage = parseInt(headers['x-prev-page']);
|
|
75
|
+
}
|
|
76
|
+
if (headers['x-total']) {
|
|
77
|
+
pagination.total = parseInt(headers['x-total']);
|
|
78
|
+
}
|
|
79
|
+
if (headers['x-total-pages']) {
|
|
80
|
+
pagination.totalPages = parseInt(headers['x-total-pages']);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
const items = Array.isArray(response)
|
|
84
|
+
? response.map(item => PipelineJobHistoryItemSchema.parse(item))
|
|
85
|
+
: [];
|
|
86
|
+
return {
|
|
87
|
+
items,
|
|
88
|
+
pagination
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* 手动运行流水线任务
|
|
93
|
+
* @param organizationId Organization ID(组织ID)
|
|
94
|
+
* @param pipelineId Pipeline ID(流水线ID)
|
|
95
|
+
* @param pipelineRunId Pipeline run instance ID(流水线运行ID)
|
|
96
|
+
* @param jobId Job ID for the pipeline run task(流水线运行任务ID)
|
|
97
|
+
* @returns Whether the operation was successful
|
|
98
|
+
*/
|
|
99
|
+
export async function executePipelineJobRunFunc(organizationId, pipelineId, pipelineRunId, jobId) {
|
|
100
|
+
const finalOrgId = await resolveOrganizationId(organizationId);
|
|
101
|
+
const url = utils.isRegionEdition()
|
|
102
|
+
? `/oapi/v1/flow/pipelines/${pipelineId}/pipelineRuns/${pipelineRunId}/jobs/${jobId}/start`
|
|
103
|
+
: `/oapi/v1/flow/organizations/${finalOrgId}/pipelines/${pipelineId}/pipelineRuns/${pipelineRunId}/jobs/${jobId}/start`;
|
|
104
|
+
const response = await utils.yunxiaoRequest(url, {
|
|
105
|
+
method: "POST",
|
|
106
|
+
});
|
|
107
|
+
return Boolean(response);
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* 查询任务运行日志
|
|
111
|
+
* @param organizationId Organization ID(组织ID)
|
|
112
|
+
* @param pipelineId Pipeline ID(流水线ID)
|
|
113
|
+
* @param pipelineRunId Pipeline run instance ID(流水线运行ID)
|
|
114
|
+
* @param jobId Job ID of the pipeline run task(流水线运行任务ID)
|
|
115
|
+
* @returns Log content and metadata
|
|
116
|
+
*/
|
|
117
|
+
export async function getPipelineJobRunLogFunc(organizationId, pipelineId, pipelineRunId, jobId) {
|
|
118
|
+
const finalOrgId = await resolveOrganizationId(organizationId);
|
|
119
|
+
const url = utils.isRegionEdition()
|
|
120
|
+
? `/oapi/v1/flow/pipelines/${pipelineId}/runs/${pipelineRunId}/job/${jobId}/log`
|
|
121
|
+
: `/oapi/v1/flow/organizations/${finalOrgId}/pipelines/${pipelineId}/runs/${pipelineRunId}/job/${jobId}/log`;
|
|
122
|
+
const response = await utils.yunxiaoRequest(url, {
|
|
123
|
+
method: "GET",
|
|
124
|
+
});
|
|
125
|
+
return PipelineJobRunLogSchema.parse(response);
|
|
126
|
+
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import * as utils from "../../common/utils.js";
|
|
2
|
+
import { resolveOrganizationId } from "../organization/organization.js";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
// 定义资源成员的Zod模式
|
|
5
|
+
export const ResourceMemberSchema = z.object({
|
|
6
|
+
username: z.string().nullable().optional().describe("用户名"),
|
|
7
|
+
userId: z.string().nullable().optional().describe("用户id"),
|
|
8
|
+
role: z.string().nullable().optional().describe("用户角色"),
|
|
9
|
+
});
|
|
10
|
+
// 定义API请求参数的Zod模式
|
|
11
|
+
export const ResourceMemberBaseSchema = z.object({
|
|
12
|
+
organizationId: z.string().describe("企业Id"),
|
|
13
|
+
resourceType: z.string().describe("资源类型 pipeline 流水线 hostGroup 主机组"),
|
|
14
|
+
resourceId: z.string().describe("资源Id"),
|
|
15
|
+
});
|
|
16
|
+
export const DeleteResourceMemberSchema = ResourceMemberBaseSchema.extend({
|
|
17
|
+
userId: z.string().describe("用户Id"),
|
|
18
|
+
});
|
|
19
|
+
export const UpdateResourceMemberSchema = ResourceMemberBaseSchema.extend({
|
|
20
|
+
roleName: z.string().describe("角色部署组 hostGroup: user(成员,使用权限) admin(管理员,使用编辑权限) 流水线 pipeline: admin(管理员,查看、运行、编辑权限) member(运行权限) viewer(查看权限)"),
|
|
21
|
+
userId: z.string().describe("用户id"),
|
|
22
|
+
});
|
|
23
|
+
export const CreateResourceMemberSchema = ResourceMemberBaseSchema.extend({
|
|
24
|
+
roleName: z.string().describe("角色部署组 hostGroup: user(成员,使用权限) admin(管理员,使用编辑权限) owner(拥有者,所有权限) 流水线 pipeline: owner(拥有者,所有权限) admin(管理员,查看、运行、编辑权限) member(运行权限) viewer(查看权限)"),
|
|
25
|
+
userId: z.string().describe("用户id"),
|
|
26
|
+
});
|
|
27
|
+
export const UpdateResourceOwnerSchema = ResourceMemberBaseSchema.extend({
|
|
28
|
+
newOwnerId: z.string().describe("新拥有者用户Id"),
|
|
29
|
+
});
|
|
30
|
+
/**
|
|
31
|
+
* 删除资源成员
|
|
32
|
+
* @param organizationId 企业Id
|
|
33
|
+
* @param resourceType 资源类型 pipeline 流水线 hostGroup 主机组
|
|
34
|
+
* @param resourceId 资源Id
|
|
35
|
+
* @param userId 用户Id
|
|
36
|
+
* @returns 是否成功
|
|
37
|
+
*/
|
|
38
|
+
export async function deleteResourceMemberFunc(organizationId, resourceType, resourceId, userId) {
|
|
39
|
+
const finalOrgId = await resolveOrganizationId(organizationId);
|
|
40
|
+
const url = utils.isRegionEdition()
|
|
41
|
+
? `/oapi/v1/flow/resourceMembers/resourceTypes/${resourceType}/resourceIds/${resourceId}`
|
|
42
|
+
: `/oapi/v1/flow/organizations/${finalOrgId}/resourceMembers/resourceTypes/${resourceType}/resourceIds/${resourceId}`;
|
|
43
|
+
const queryParams = { userId };
|
|
44
|
+
const fullUrl = utils.buildUrl(url, queryParams);
|
|
45
|
+
const response = await utils.yunxiaoRequest(fullUrl, {
|
|
46
|
+
method: "DELETE",
|
|
47
|
+
});
|
|
48
|
+
return Boolean(response);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* 获取资源成员列表
|
|
52
|
+
* @param organizationId 企业Id
|
|
53
|
+
* @param resourceType 资源类型 pipeline 流水线 hostGroup 主机组
|
|
54
|
+
* @param resourceId 资源Id
|
|
55
|
+
* @returns 资源成员列表
|
|
56
|
+
*/
|
|
57
|
+
export async function listResourceMembersFunc(organizationId, resourceType, resourceId) {
|
|
58
|
+
const finalOrgId = await resolveOrganizationId(organizationId);
|
|
59
|
+
const url = utils.isRegionEdition()
|
|
60
|
+
? `/oapi/v1/flow/resourceMembers/resourceTypes/${resourceType}/resourceIds/${resourceId}`
|
|
61
|
+
: `/oapi/v1/flow/organizations/${finalOrgId}/resourceMembers/resourceTypes/${resourceType}/resourceIds/${resourceId}`;
|
|
62
|
+
const response = await utils.yunxiaoRequest(url, {
|
|
63
|
+
method: "GET",
|
|
64
|
+
});
|
|
65
|
+
if (Array.isArray(response)) {
|
|
66
|
+
return response.map(item => ResourceMemberSchema.parse(item));
|
|
67
|
+
}
|
|
68
|
+
// 如果响应不是数组,但包含数据,尝试解析单个对象
|
|
69
|
+
try {
|
|
70
|
+
return [ResourceMemberSchema.parse(response)];
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
return [];
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* 更新资源成员
|
|
78
|
+
* @param organizationId 企业Id
|
|
79
|
+
* @param resourceType 资源类型 pipeline 流水线 hostGroup 主机组
|
|
80
|
+
* @param resourceId 资源Id
|
|
81
|
+
* @param roleName 角色
|
|
82
|
+
* @param userId 用户id
|
|
83
|
+
* @returns 是否成功
|
|
84
|
+
*/
|
|
85
|
+
export async function updateResourceMemberFunc(organizationId, resourceType, resourceId, roleName, userId) {
|
|
86
|
+
const finalOrgId = await resolveOrganizationId(organizationId);
|
|
87
|
+
const url = utils.isRegionEdition()
|
|
88
|
+
? `/oapi/v1/flow/resourceMembers/resourceTypes/${resourceType}/resourceIds/${resourceId}`
|
|
89
|
+
: `/oapi/v1/flow/organizations/${finalOrgId}/resourceMembers/resourceTypes/${resourceType}/resourceIds/${resourceId}`;
|
|
90
|
+
const queryParams = { roleName, userId };
|
|
91
|
+
const fullUrl = utils.buildUrl(url, queryParams);
|
|
92
|
+
const response = await utils.yunxiaoRequest(fullUrl, {
|
|
93
|
+
method: "PUT",
|
|
94
|
+
});
|
|
95
|
+
return Boolean(response);
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* 插入资源成员
|
|
99
|
+
* @param organizationId 企业Id
|
|
100
|
+
* @param resourceType 资源类型 pipeline 流水线 hostGroup 主机组
|
|
101
|
+
* @param resourceId 资源Id
|
|
102
|
+
* @param roleName 角色
|
|
103
|
+
* @param userId 用户id
|
|
104
|
+
* @returns 是否成功
|
|
105
|
+
*/
|
|
106
|
+
export async function createResourceMemberFunc(organizationId, resourceType, resourceId, roleName, userId) {
|
|
107
|
+
const finalOrgId = await resolveOrganizationId(organizationId);
|
|
108
|
+
const url = utils.isRegionEdition()
|
|
109
|
+
? `/oapi/v1/flow/resourceMembers/resourceTypes/${resourceType}/resourceIds/${resourceId}`
|
|
110
|
+
: `/oapi/v1/flow/organizations/${finalOrgId}/resourceMembers/resourceTypes/${resourceType}/resourceIds/${resourceId}`;
|
|
111
|
+
const queryParams = { roleName, userId };
|
|
112
|
+
const fullUrl = utils.buildUrl(url, queryParams);
|
|
113
|
+
const response = await utils.yunxiaoRequest(fullUrl, {
|
|
114
|
+
method: "POST",
|
|
115
|
+
});
|
|
116
|
+
return Boolean(response);
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* 移交资源对象拥有者
|
|
120
|
+
* @param organizationId 企业Id
|
|
121
|
+
* @param resourceType 资源类型 pipeline 流水线 hostGroup 主机组
|
|
122
|
+
* @param resourceId 资源Id
|
|
123
|
+
* @param newOwnerId 新拥有者用户Id
|
|
124
|
+
* @returns 是否成功
|
|
125
|
+
*/
|
|
126
|
+
export async function updateResourceOwnerFunc(organizationId, resourceType, resourceId, newOwnerId) {
|
|
127
|
+
const finalOrgId = await resolveOrganizationId(organizationId);
|
|
128
|
+
const url = utils.isRegionEdition()
|
|
129
|
+
? `/oapi/v1/flow/resourceMembers/resourceTypes/${resourceType}/resourceIds/${resourceId}/transfer/owner`
|
|
130
|
+
: `/oapi/v1/flow/organizations/${finalOrgId}/resourceMembers/resourceTypes/${resourceType}/resourceIds/${resourceId}/transfer/owner`;
|
|
131
|
+
const queryParams = { newOwnerId };
|
|
132
|
+
const fullUrl = utils.buildUrl(url, queryParams);
|
|
133
|
+
const response = await utils.yunxiaoRequest(fullUrl, {
|
|
134
|
+
method: "POST",
|
|
135
|
+
});
|
|
136
|
+
return Boolean(response);
|
|
137
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as utils from "../../common/utils.js";
|
|
2
|
+
import { resolveOrganizationId } from "../organization/organization.js";
|
|
3
|
+
import { ServiceConnectionSchema } from "./types.js";
|
|
4
|
+
/**
|
|
5
|
+
* 获取服务连接列表
|
|
6
|
+
* @param organizationId 组织ID
|
|
7
|
+
* @param serviceConnectionType 服务连接类型
|
|
8
|
+
* @returns 服务连接列表
|
|
9
|
+
*/
|
|
10
|
+
export async function listServiceConnectionsFunc(organizationId, serviceConnectionType) {
|
|
11
|
+
const finalOrgId = await resolveOrganizationId(organizationId);
|
|
12
|
+
const baseUrl = utils.isRegionEdition()
|
|
13
|
+
? `/oapi/v1/flow/serviceConnections`
|
|
14
|
+
: `/oapi/v1/flow/organizations/${finalOrgId}/serviceConnections`;
|
|
15
|
+
// 构建查询参数
|
|
16
|
+
const queryParams = {
|
|
17
|
+
sericeConnectionType: serviceConnectionType // 注意:API文档中拼写为 sericeConnectionType
|
|
18
|
+
};
|
|
19
|
+
const url = utils.buildUrl(baseUrl, queryParams);
|
|
20
|
+
const response = await utils.yunxiaoRequest(url, {
|
|
21
|
+
method: "GET",
|
|
22
|
+
});
|
|
23
|
+
if (!Array.isArray(response)) {
|
|
24
|
+
return [];
|
|
25
|
+
}
|
|
26
|
+
return response.map(item => ServiceConnectionSchema.parse(item));
|
|
27
|
+
}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import * as utils from "../../common/utils.js";
|
|
2
|
+
import { resolveOrganizationId } from "../organization/organization.js";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
// 定义标签和标签分类的Zod模式
|
|
5
|
+
export const TagGroupSchema = z.object({
|
|
6
|
+
id: z.number().int().nullable().optional().describe("标签分类 id"),
|
|
7
|
+
name: z.string().nullable().optional().describe("标签分类名称"),
|
|
8
|
+
creatorAccountId: z.string().nullable().optional().describe("创建人"),
|
|
9
|
+
modifierAccountId: z.string().nullable().optional().describe("更新人"),
|
|
10
|
+
});
|
|
11
|
+
export const TagSchema = z.object({
|
|
12
|
+
id: z.number().int().nullable().optional().describe("标签 id"),
|
|
13
|
+
name: z.string().nullable().optional().describe("标签名称"),
|
|
14
|
+
color: z.string().nullable().optional().describe("标签颜色"),
|
|
15
|
+
creatorAccountId: z.string().nullable().optional().describe("创建人"),
|
|
16
|
+
modifierAccountId: z.string().nullable().optional().describe("更新人"),
|
|
17
|
+
});
|
|
18
|
+
export const TagGroupWithTagsSchema = TagGroupSchema.extend({
|
|
19
|
+
flowTagList: z.array(TagSchema).nullable().optional().describe("标签列表"),
|
|
20
|
+
});
|
|
21
|
+
// 定义API请求参数的Zod模式
|
|
22
|
+
export const BaseTagSchema = z.object({
|
|
23
|
+
organizationId: z.string().describe("企业Id"),
|
|
24
|
+
});
|
|
25
|
+
export const CreateTagSchema = BaseTagSchema.extend({
|
|
26
|
+
name: z.string().describe("标签名称"),
|
|
27
|
+
color: z.string().describe("#1F9AEF 蓝色; #E63A3A 红色; #FA8C15 黄色; #15AD31 绿色; #7978E5 紫色; #8C8C8C 灰色"),
|
|
28
|
+
flowTagGroupId: z.number().int().describe("标签分类 id"),
|
|
29
|
+
});
|
|
30
|
+
export const CreateTagGroupSchema = BaseTagSchema.extend({
|
|
31
|
+
name: z.string().describe("标签分类名称"),
|
|
32
|
+
});
|
|
33
|
+
export const DeleteTagGroupSchema = BaseTagSchema.extend({
|
|
34
|
+
id: z.number().int().describe("标签分类 id"),
|
|
35
|
+
});
|
|
36
|
+
export const UpdateTagGroupSchema = DeleteTagGroupSchema.extend({
|
|
37
|
+
name: z.string().describe("标签分类名称"),
|
|
38
|
+
});
|
|
39
|
+
export const DeleteTagSchema = BaseTagSchema.extend({
|
|
40
|
+
id: z.number().int().describe("标签 id"),
|
|
41
|
+
});
|
|
42
|
+
export const UpdateTagSchema = DeleteTagSchema.extend({
|
|
43
|
+
name: z.string().describe("标签名称"),
|
|
44
|
+
color: z.string().describe("#1F9AEF 蓝色; #E63A3A 红色; #FA8C15 黄色; #15AD31 绿色; #7978E5 紫色; #8C8C8C 灰色"),
|
|
45
|
+
flowTagGroupId: z.number().int().describe("标签分类 id"),
|
|
46
|
+
});
|
|
47
|
+
export const GetTagGroupSchema = DeleteTagGroupSchema;
|
|
48
|
+
/**
|
|
49
|
+
* 创建标签
|
|
50
|
+
* @param organizationId 企业Id
|
|
51
|
+
* @param name 标签名称
|
|
52
|
+
* @param color 标签颜色
|
|
53
|
+
* @param flowTagGroupId 标签分类 id
|
|
54
|
+
* @returns 标签 id
|
|
55
|
+
*/
|
|
56
|
+
export async function createTagFunc(organizationId, name, color, flowTagGroupId) {
|
|
57
|
+
const finalOrgId = await resolveOrganizationId(organizationId);
|
|
58
|
+
const url = utils.isRegionEdition()
|
|
59
|
+
? `/oapi/v1/flow/tags`
|
|
60
|
+
: `/oapi/v1/flow/organizations/${finalOrgId}/tags`;
|
|
61
|
+
const queryParams = { name, color, flowTagGroupId };
|
|
62
|
+
const fullUrl = utils.buildUrl(url, queryParams);
|
|
63
|
+
const response = await utils.yunxiaoRequest(fullUrl, {
|
|
64
|
+
method: "POST",
|
|
65
|
+
});
|
|
66
|
+
return Number(response);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* 创建标签分类
|
|
70
|
+
* @param organizationId 企业Id
|
|
71
|
+
* @param name 标签分类名称
|
|
72
|
+
* @returns 标签分类 id
|
|
73
|
+
*/
|
|
74
|
+
export async function createTagGroupFunc(organizationId, name) {
|
|
75
|
+
const finalOrgId = await resolveOrganizationId(organizationId);
|
|
76
|
+
const url = utils.isRegionEdition()
|
|
77
|
+
? `/oapi/v1/flow/tagGroups`
|
|
78
|
+
: `/oapi/v1/flow/organizations/${finalOrgId}/tagGroups`;
|
|
79
|
+
const queryParams = { name };
|
|
80
|
+
const fullUrl = utils.buildUrl(url, queryParams);
|
|
81
|
+
const response = await utils.yunxiaoRequest(fullUrl, {
|
|
82
|
+
method: "POST",
|
|
83
|
+
});
|
|
84
|
+
return Number(response);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* 获取流水线分类列表
|
|
88
|
+
* @param organizationId 企业Id
|
|
89
|
+
* @returns 流水线分类列表
|
|
90
|
+
*/
|
|
91
|
+
export async function listTagGroupsFunc(organizationId) {
|
|
92
|
+
const finalOrgId = await resolveOrganizationId(organizationId);
|
|
93
|
+
const url = utils.isRegionEdition()
|
|
94
|
+
? `/oapi/v1/flow/tagGroups`
|
|
95
|
+
: `/oapi/v1/flow/organizations/${finalOrgId}/tagGroups`;
|
|
96
|
+
const response = await utils.yunxiaoRequest(url, {
|
|
97
|
+
method: "GET",
|
|
98
|
+
});
|
|
99
|
+
if (Array.isArray(response)) {
|
|
100
|
+
return response.map(item => TagGroupSchema.parse(item));
|
|
101
|
+
}
|
|
102
|
+
return [];
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* 删除标签分类
|
|
106
|
+
* @param organizationId 企业Id
|
|
107
|
+
* @param id 标签分类 id
|
|
108
|
+
* @returns 是否成功
|
|
109
|
+
*/
|
|
110
|
+
export async function deleteTagGroupFunc(organizationId, id) {
|
|
111
|
+
const finalOrgId = await resolveOrganizationId(organizationId);
|
|
112
|
+
const url = utils.isRegionEdition()
|
|
113
|
+
? `/oapi/v1/flow/tagGroups/${id}`
|
|
114
|
+
: `/oapi/v1/flow/organizations/${finalOrgId}/tagGroups/${id}`;
|
|
115
|
+
const response = await utils.yunxiaoRequest(url, {
|
|
116
|
+
method: "DELETE",
|
|
117
|
+
});
|
|
118
|
+
return Boolean(response);
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* 更新标签分类
|
|
122
|
+
* @param organizationId 企业Id
|
|
123
|
+
* @param id 标签分类 id
|
|
124
|
+
* @param name 标签分类名称
|
|
125
|
+
* @returns 是否成功
|
|
126
|
+
*/
|
|
127
|
+
export async function updateTagGroupFunc(organizationId, id, name) {
|
|
128
|
+
const finalOrgId = await resolveOrganizationId(organizationId);
|
|
129
|
+
const url = utils.isRegionEdition()
|
|
130
|
+
? `/oapi/v1/flow/tagGroups/${id}`
|
|
131
|
+
: `/oapi/v1/flow/organizations/${finalOrgId}/tagGroups/${id}`;
|
|
132
|
+
const queryParams = { name };
|
|
133
|
+
const fullUrl = utils.buildUrl(url, queryParams);
|
|
134
|
+
const response = await utils.yunxiaoRequest(fullUrl, {
|
|
135
|
+
method: "PUT",
|
|
136
|
+
});
|
|
137
|
+
return Boolean(response);
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* 获取标签分类
|
|
141
|
+
* @param organizationId 企业Id
|
|
142
|
+
* @param id 标签分类 id
|
|
143
|
+
* @returns 标签分类
|
|
144
|
+
*/
|
|
145
|
+
export async function getTagGroupFunc(organizationId, id) {
|
|
146
|
+
const finalOrgId = await resolveOrganizationId(organizationId);
|
|
147
|
+
const url = utils.isRegionEdition()
|
|
148
|
+
? `/oapi/v1/flow/tagGroups/${id}`
|
|
149
|
+
: `/oapi/v1/flow/organizations/${finalOrgId}/tagGroups/${id}`;
|
|
150
|
+
const response = await utils.yunxiaoRequest(url, {
|
|
151
|
+
method: "GET",
|
|
152
|
+
});
|
|
153
|
+
return TagGroupWithTagsSchema.parse(response);
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* 删除标签
|
|
157
|
+
* @param organizationId 企业Id
|
|
158
|
+
* @param id 标签 id
|
|
159
|
+
* @returns 是否成功
|
|
160
|
+
*/
|
|
161
|
+
export async function deleteTagFunc(organizationId, id) {
|
|
162
|
+
const finalOrgId = await resolveOrganizationId(organizationId);
|
|
163
|
+
const url = utils.isRegionEdition()
|
|
164
|
+
? `/oapi/v1/flow/tags/${id}`
|
|
165
|
+
: `/oapi/v1/flow/organizations/${finalOrgId}/tags/${id}`;
|
|
166
|
+
const response = await utils.yunxiaoRequest(url, {
|
|
167
|
+
method: "DELETE",
|
|
168
|
+
});
|
|
169
|
+
return Boolean(response);
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* 更新标签
|
|
173
|
+
* @param organizationId 企业Id
|
|
174
|
+
* @param id 标签 id
|
|
175
|
+
* @param name 标签名称
|
|
176
|
+
* @param color 标签颜色
|
|
177
|
+
* @param flowTagGroupId 标签分类 id
|
|
178
|
+
* @returns 是否成功
|
|
179
|
+
*/
|
|
180
|
+
export async function updateTagFunc(organizationId, id, name, color, flowTagGroupId) {
|
|
181
|
+
const finalOrgId = await resolveOrganizationId(organizationId);
|
|
182
|
+
const url = utils.isRegionEdition()
|
|
183
|
+
? `/oapi/v1/flow/tags/${id}`
|
|
184
|
+
: `/oapi/v1/flow/organizations/${finalOrgId}/tags/${id}`;
|
|
185
|
+
const queryParams = { name, color, flowTagGroupId };
|
|
186
|
+
const fullUrl = utils.buildUrl(url, queryParams);
|
|
187
|
+
const response = await utils.yunxiaoRequest(fullUrl, {
|
|
188
|
+
method: "PUT",
|
|
189
|
+
});
|
|
190
|
+
return Boolean(response);
|
|
191
|
+
}
|