@yinuo-ngm/mcp-server 0.1.1 → 0.1.2
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 +97 -43
- package/lib/register-tools.js +6 -2
- package/lib/tools/hub-v2/client.d.ts +15 -0
- package/lib/tools/hub-v2/client.js +97 -0
- package/lib/tools/hub-v2/config.d.ts +34 -0
- package/lib/tools/hub-v2/config.js +297 -0
- package/lib/tools/hub-v2/docs.tools.d.ts +2 -0
- package/lib/tools/hub-v2/docs.tools.js +81 -0
- package/lib/tools/hub-v2/errors.d.ts +8 -0
- package/lib/tools/hub-v2/errors.js +27 -0
- package/lib/tools/hub-v2/index.d.ts +2 -0
- package/lib/tools/hub-v2/index.js +17 -0
- package/lib/tools/hub-v2/issues.tools.d.ts +2 -0
- package/lib/tools/hub-v2/issues.tools.js +154 -0
- package/lib/tools/hub-v2/projects.tools.d.ts +2 -0
- package/lib/tools/hub-v2/projects.tools.js +28 -0
- package/lib/tools/hub-v2/rd.tools.d.ts +2 -0
- package/lib/tools/hub-v2/rd.tools.js +202 -0
- package/lib/tools/hub-v2/schemas.d.ts +585 -0
- package/lib/tools/hub-v2/schemas.js +167 -0
- package/lib/tools/hub-v2/upload.tools.d.ts +2 -0
- package/lib/tools/hub-v2/upload.tools.js +150 -0
- package/lib/tools/index.d.ts +2 -0
- package/lib/tools/index.js +2 -0
- package/lib/utils/errors.d.ts +5 -0
- package/lib/utils/errors.js +12 -0
- package/lib/utils/result.d.ts +11 -2
- package/lib/utils/result.js +99 -3
- package/package.json +7 -3
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hubV2DocsTools = hubV2DocsTools;
|
|
4
|
+
const client_1 = require("./client");
|
|
5
|
+
const config_1 = require("./config");
|
|
6
|
+
const schemas_1 = require("./schemas");
|
|
7
|
+
const result_1 = require("../../utils/result");
|
|
8
|
+
function hubV2DocsTools() {
|
|
9
|
+
return [
|
|
10
|
+
{
|
|
11
|
+
name: "hub_v2_docs_list",
|
|
12
|
+
description: "List Hub V2 project documents with Project Token.",
|
|
13
|
+
riskLevel: "read",
|
|
14
|
+
inputSchema: schemas_1.docsListSchema,
|
|
15
|
+
async handler(args) {
|
|
16
|
+
const ctx = (0, config_1.resolveHubV2Context)(args, "project");
|
|
17
|
+
const client = new client_1.HubV2Client(ctx);
|
|
18
|
+
const status = args.status;
|
|
19
|
+
const data = await client.request("GET", client.tokenUrl("/docs", {
|
|
20
|
+
page: args.page ?? 1,
|
|
21
|
+
pageSize: args.pageSize ?? 20,
|
|
22
|
+
status,
|
|
23
|
+
statusGroup: status ? undefined : "active",
|
|
24
|
+
keyword: args.keyword,
|
|
25
|
+
category: args.category,
|
|
26
|
+
categoryId: args.categoryId,
|
|
27
|
+
}));
|
|
28
|
+
return (0, result_1.ok)("hub_v2_docs_list", data);
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
name: "hub_v2_docs_get",
|
|
33
|
+
description: "Read one Hub V2 project document by id with Project Token.",
|
|
34
|
+
riskLevel: "read",
|
|
35
|
+
inputSchema: schemas_1.docsGetSchema,
|
|
36
|
+
async handler(args) {
|
|
37
|
+
const ctx = (0, config_1.resolveHubV2Context)(args, "project");
|
|
38
|
+
const client = new client_1.HubV2Client(ctx);
|
|
39
|
+
const data = await client.request("GET", client.tokenUrl(`/docs/${encodeURIComponent(args.docId)}`));
|
|
40
|
+
return (0, result_1.ok)("hub_v2_docs_get", data);
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: "hub_v2_docs_get_by_slug",
|
|
45
|
+
description: "Read one Hub V2 project document by slug with Project Token.",
|
|
46
|
+
riskLevel: "read",
|
|
47
|
+
inputSchema: schemas_1.docsGetBySlugSchema,
|
|
48
|
+
async handler(args) {
|
|
49
|
+
const ctx = (0, config_1.resolveHubV2Context)(args, "project");
|
|
50
|
+
const client = new client_1.HubV2Client(ctx);
|
|
51
|
+
const payload = await client.request("GET", client.tokenUrl(`/docs/by-slug/${encodeURIComponent(args.slug)}`));
|
|
52
|
+
if (args.contentOnly) {
|
|
53
|
+
const content = extractDocumentContent(payload);
|
|
54
|
+
if (typeof content === "string") {
|
|
55
|
+
return (0, result_1.ok)("hub_v2_docs_get_by_slug", content);
|
|
56
|
+
}
|
|
57
|
+
return (0, result_1.fail)("hub_v2_docs_get_by_slug", "Hub V2 document response did not include data.contentMd or data.item.contentMd", {
|
|
58
|
+
code: "DOCUMENT_CONTENT_NOT_FOUND",
|
|
59
|
+
detail: {
|
|
60
|
+
slug: args.slug,
|
|
61
|
+
responseKeys: Object.keys(payload),
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
return (0, result_1.ok)("hub_v2_docs_get_by_slug", payload);
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
];
|
|
69
|
+
}
|
|
70
|
+
function extractDocumentContent(payload) {
|
|
71
|
+
const data = payload.data && typeof payload.data === "object" && !Array.isArray(payload.data)
|
|
72
|
+
? payload.data
|
|
73
|
+
: undefined;
|
|
74
|
+
if (typeof data?.contentMd === "string") {
|
|
75
|
+
return data.contentMd;
|
|
76
|
+
}
|
|
77
|
+
const item = data?.item && typeof data.item === "object" && !Array.isArray(data.item)
|
|
78
|
+
? data.item
|
|
79
|
+
: undefined;
|
|
80
|
+
return typeof item?.contentMd === "string" ? item.contentMd : undefined;
|
|
81
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare class HubV2HttpError extends Error {
|
|
2
|
+
readonly status: number;
|
|
3
|
+
readonly code?: string | undefined;
|
|
4
|
+
readonly detail?: unknown | undefined;
|
|
5
|
+
constructor(message: string, status: number, code?: string | undefined, detail?: unknown | undefined);
|
|
6
|
+
}
|
|
7
|
+
export declare function formatHubV2HttpError(status: number, statusText: string, body: unknown): string;
|
|
8
|
+
export declare function toHubV2HttpError(status: number, statusText: string, body: unknown): HubV2HttpError;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HubV2HttpError = void 0;
|
|
4
|
+
exports.formatHubV2HttpError = formatHubV2HttpError;
|
|
5
|
+
exports.toHubV2HttpError = toHubV2HttpError;
|
|
6
|
+
class HubV2HttpError extends Error {
|
|
7
|
+
constructor(message, status, code, detail) {
|
|
8
|
+
super(message);
|
|
9
|
+
this.status = status;
|
|
10
|
+
this.code = code;
|
|
11
|
+
this.detail = detail;
|
|
12
|
+
this.name = "HubV2HttpError";
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.HubV2HttpError = HubV2HttpError;
|
|
16
|
+
function formatHubV2HttpError(status, statusText, body) {
|
|
17
|
+
const record = body && typeof body === "object" && !Array.isArray(body) ? body : {};
|
|
18
|
+
const code = typeof record.code === "string" ? record.code : "HTTP_ERROR";
|
|
19
|
+
const message = typeof record.message === "string" ? record.message : statusText;
|
|
20
|
+
return `Hub V2 HTTP ${status} ${code}: ${message}`;
|
|
21
|
+
}
|
|
22
|
+
function toHubV2HttpError(status, statusText, body) {
|
|
23
|
+
const record = body && typeof body === "object" && !Array.isArray(body) ? body : {};
|
|
24
|
+
const code = typeof record.code === "string" ? record.code : "HTTP_ERROR";
|
|
25
|
+
const detail = record.detail ?? record.data ?? body;
|
|
26
|
+
return new HubV2HttpError(formatHubV2HttpError(status, statusText, body), status, code, detail);
|
|
27
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hubV2Tools = hubV2Tools;
|
|
4
|
+
const docs_tools_1 = require("./docs.tools");
|
|
5
|
+
const issues_tools_1 = require("./issues.tools");
|
|
6
|
+
const projects_tools_1 = require("./projects.tools");
|
|
7
|
+
const rd_tools_1 = require("./rd.tools");
|
|
8
|
+
const upload_tools_1 = require("./upload.tools");
|
|
9
|
+
function hubV2Tools() {
|
|
10
|
+
return [
|
|
11
|
+
...(0, projects_tools_1.hubV2ProjectsTools)(),
|
|
12
|
+
...(0, docs_tools_1.hubV2DocsTools)(),
|
|
13
|
+
...(0, issues_tools_1.hubV2IssuesTools)(),
|
|
14
|
+
...(0, rd_tools_1.hubV2RdTools)(),
|
|
15
|
+
...(0, upload_tools_1.hubV2UploadTools)(),
|
|
16
|
+
];
|
|
17
|
+
}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hubV2IssuesTools = hubV2IssuesTools;
|
|
4
|
+
const client_1 = require("./client");
|
|
5
|
+
const config_1 = require("./config");
|
|
6
|
+
const schemas_1 = require("./schemas");
|
|
7
|
+
const result_1 = require("../../utils/result");
|
|
8
|
+
function hubV2IssuesTools() {
|
|
9
|
+
return [
|
|
10
|
+
{
|
|
11
|
+
name: "hub_v2_issues_list",
|
|
12
|
+
description: "List Hub V2 issues with Project Token.",
|
|
13
|
+
riskLevel: "read",
|
|
14
|
+
inputSchema: schemas_1.issuesListSchema,
|
|
15
|
+
async handler(args) {
|
|
16
|
+
const ctx = (0, config_1.resolveHubV2Context)(args, "project");
|
|
17
|
+
const client = new client_1.HubV2Client(ctx);
|
|
18
|
+
const data = await client.request("GET", client.tokenUrl("/issues", {
|
|
19
|
+
page: args.page ?? 1,
|
|
20
|
+
pageSize: args.pageSize ?? 20,
|
|
21
|
+
keyword: args.keyword,
|
|
22
|
+
status: args.status,
|
|
23
|
+
priority: args.priority,
|
|
24
|
+
assigneeId: args.assigneeId,
|
|
25
|
+
verifierId: args.verifierId,
|
|
26
|
+
rdItemId: args.rdItemId,
|
|
27
|
+
}));
|
|
28
|
+
return (0, result_1.ok)("hub_v2_issues_list", data);
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
name: "hub_v2_issues_get",
|
|
33
|
+
description: "Read one Hub V2 issue by id with Project Token.",
|
|
34
|
+
riskLevel: "read",
|
|
35
|
+
inputSchema: schemas_1.issueGetSchema,
|
|
36
|
+
async handler(args) {
|
|
37
|
+
const ctx = (0, config_1.resolveHubV2Context)(args, "project");
|
|
38
|
+
const client = new client_1.HubV2Client(ctx);
|
|
39
|
+
const data = await client.request("GET", client.tokenUrl(`/issues/${encodeURIComponent(args.issueId)}`));
|
|
40
|
+
return (0, result_1.ok)("hub_v2_issues_get", data);
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: "hub_v2_issues_create",
|
|
45
|
+
description: "Preview or create a Hub V2 issue with Personal Token.",
|
|
46
|
+
riskLevel: "write",
|
|
47
|
+
inputSchema: schemas_1.issueCreateSchema,
|
|
48
|
+
allowPreviewWhenBlocked: true,
|
|
49
|
+
isConfirmed: (args) => args.confirm === true,
|
|
50
|
+
async handler(args) {
|
|
51
|
+
const path = "/issues";
|
|
52
|
+
const body = (0, client_1.compact)({
|
|
53
|
+
title: args.title,
|
|
54
|
+
description: args.description,
|
|
55
|
+
type: args.type,
|
|
56
|
+
priority: args.priority,
|
|
57
|
+
assigneeId: args.assigneeId,
|
|
58
|
+
verifierId: args.verifierId,
|
|
59
|
+
rdItemId: args.rdItemId,
|
|
60
|
+
moduleCode: args.moduleCode,
|
|
61
|
+
versionCode: args.versionCode,
|
|
62
|
+
environmentCode: args.environmentCode,
|
|
63
|
+
});
|
|
64
|
+
if (!args.confirm) {
|
|
65
|
+
return (0, result_1.ok)("hub_v2_issues_create", {
|
|
66
|
+
code: "PREVIEW",
|
|
67
|
+
message: "set confirm=true to execute this write operation",
|
|
68
|
+
data: {
|
|
69
|
+
method: "POST",
|
|
70
|
+
path,
|
|
71
|
+
requiredScope: "issue:create:write",
|
|
72
|
+
body,
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
const ctx = (0, config_1.resolveHubV2Context)(args, "personal");
|
|
77
|
+
const client = new client_1.HubV2Client(ctx);
|
|
78
|
+
const data = await client.request("POST", client.personalUrl(path), body);
|
|
79
|
+
return (0, result_1.ok)("hub_v2_issues_create", data);
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
name: "hub_v2_issues_comment",
|
|
84
|
+
description: "Preview or add a Hub V2 issue comment with Personal Token.",
|
|
85
|
+
riskLevel: "write",
|
|
86
|
+
inputSchema: schemas_1.issueCommentSchema,
|
|
87
|
+
allowPreviewWhenBlocked: true,
|
|
88
|
+
isConfirmed: (args) => args.confirm === true,
|
|
89
|
+
async handler(args) {
|
|
90
|
+
const path = `/issues/${encodeURIComponent(args.issueId)}/comments`;
|
|
91
|
+
const body = (0, client_1.compact)({
|
|
92
|
+
content: args.content,
|
|
93
|
+
mentions: args.mentions,
|
|
94
|
+
});
|
|
95
|
+
if (!args.confirm) {
|
|
96
|
+
return (0, result_1.ok)("hub_v2_issues_comment", {
|
|
97
|
+
code: "PREVIEW",
|
|
98
|
+
message: "set confirm=true to execute this write operation",
|
|
99
|
+
data: {
|
|
100
|
+
method: "POST",
|
|
101
|
+
path,
|
|
102
|
+
requiredScope: "issue:comment:write",
|
|
103
|
+
body,
|
|
104
|
+
},
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
const ctx = (0, config_1.resolveHubV2Context)(args, "personal");
|
|
108
|
+
const client = new client_1.HubV2Client(ctx);
|
|
109
|
+
const data = await client.request("POST", client.personalUrl(path), body);
|
|
110
|
+
return (0, result_1.ok)("hub_v2_issues_comment", data);
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
name: "hub_v2_issues_update",
|
|
115
|
+
description: "Preview or update Hub V2 issue basic fields with Personal Token.",
|
|
116
|
+
riskLevel: "write",
|
|
117
|
+
inputSchema: schemas_1.issueUpdateSchema,
|
|
118
|
+
allowPreviewWhenBlocked: true,
|
|
119
|
+
isConfirmed: (args) => args.confirm === true,
|
|
120
|
+
async handler(args) {
|
|
121
|
+
const path = `/issues/${encodeURIComponent(args.issueId)}`;
|
|
122
|
+
const body = (0, client_1.compactUndefined)({
|
|
123
|
+
title: args.title,
|
|
124
|
+
description: args.description,
|
|
125
|
+
type: args.type,
|
|
126
|
+
priority: args.priority,
|
|
127
|
+
rdItemId: args.rdItemId,
|
|
128
|
+
moduleCode: args.moduleCode,
|
|
129
|
+
versionCode: args.versionCode,
|
|
130
|
+
environmentCode: args.environmentCode,
|
|
131
|
+
});
|
|
132
|
+
if (Object.keys(body).length === 0) {
|
|
133
|
+
return (0, result_1.fail)("hub_v2_issues_update", "at least one issue field is required");
|
|
134
|
+
}
|
|
135
|
+
if (!args.confirm) {
|
|
136
|
+
return (0, result_1.ok)("hub_v2_issues_update", {
|
|
137
|
+
code: "PREVIEW",
|
|
138
|
+
message: "set confirm=true to execute this write operation",
|
|
139
|
+
data: {
|
|
140
|
+
method: "PATCH",
|
|
141
|
+
path,
|
|
142
|
+
requiredScope: "issue:update:write",
|
|
143
|
+
body,
|
|
144
|
+
},
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
const ctx = (0, config_1.resolveHubV2Context)(args, "personal");
|
|
148
|
+
const client = new client_1.HubV2Client(ctx);
|
|
149
|
+
const data = await client.request("PATCH", client.personalUrl(path), body, { preserveNull: true });
|
|
150
|
+
return (0, result_1.ok)("hub_v2_issues_update", data);
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
];
|
|
154
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hubV2ProjectsTools = hubV2ProjectsTools;
|
|
4
|
+
const config_1 = require("./config");
|
|
5
|
+
const schemas_1 = require("./schemas");
|
|
6
|
+
const result_1 = require("../../utils/result");
|
|
7
|
+
function hubV2ProjectsTools() {
|
|
8
|
+
return [
|
|
9
|
+
{
|
|
10
|
+
name: "hub_v2_projects_list",
|
|
11
|
+
description: "List locally configured Hub V2 project aliases without exposing tokens.",
|
|
12
|
+
riskLevel: "read",
|
|
13
|
+
inputSchema: schemas_1.projectSelectorSchema,
|
|
14
|
+
handler(args) {
|
|
15
|
+
return (0, result_1.ok)("hub_v2_projects_list", (0, config_1.listConfiguredProjects)(args.project ?? args.projectKey));
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
name: "hub_v2_projects_get",
|
|
20
|
+
description: "Get one locally configured Hub V2 project summary without exposing tokens.",
|
|
21
|
+
riskLevel: "read",
|
|
22
|
+
inputSchema: schemas_1.projectSelectorSchema,
|
|
23
|
+
handler(args) {
|
|
24
|
+
return (0, result_1.ok)("hub_v2_projects_get", (0, config_1.getConfiguredProject)(args));
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
];
|
|
28
|
+
}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hubV2RdTools = hubV2RdTools;
|
|
4
|
+
const client_1 = require("./client");
|
|
5
|
+
const config_1 = require("./config");
|
|
6
|
+
const schemas_1 = require("./schemas");
|
|
7
|
+
const result_1 = require("../../utils/result");
|
|
8
|
+
function hubV2RdTools() {
|
|
9
|
+
return [
|
|
10
|
+
{
|
|
11
|
+
name: "hub_v2_rd_list",
|
|
12
|
+
description: "List Hub V2 RD items with Project Token.",
|
|
13
|
+
riskLevel: "read",
|
|
14
|
+
inputSchema: schemas_1.rdListSchema,
|
|
15
|
+
async handler(args) {
|
|
16
|
+
const ctx = (0, config_1.resolveHubV2Context)(args, "project");
|
|
17
|
+
const client = new client_1.HubV2Client(ctx);
|
|
18
|
+
const data = await client.request("GET", client.tokenUrl("/rd-items", {
|
|
19
|
+
page: args.page ?? 1,
|
|
20
|
+
pageSize: args.pageSize ?? 20,
|
|
21
|
+
keyword: args.keyword,
|
|
22
|
+
stageId: args.stageId,
|
|
23
|
+
status: args.status,
|
|
24
|
+
type: args.type,
|
|
25
|
+
priority: args.priority,
|
|
26
|
+
assigneeId: args.assigneeId,
|
|
27
|
+
}));
|
|
28
|
+
return (0, result_1.ok)("hub_v2_rd_list", data);
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
name: "hub_v2_rd_get",
|
|
33
|
+
description: "Read one Hub V2 RD item by id with Project Token.",
|
|
34
|
+
riskLevel: "read",
|
|
35
|
+
inputSchema: schemas_1.rdGetSchema,
|
|
36
|
+
async handler(args) {
|
|
37
|
+
const ctx = (0, config_1.resolveHubV2Context)(args, "project");
|
|
38
|
+
const client = new client_1.HubV2Client(ctx);
|
|
39
|
+
const data = await client.request("GET", client.tokenUrl(`/rd-items/${encodeURIComponent(args.itemId)}`));
|
|
40
|
+
return (0, result_1.ok)("hub_v2_rd_get", data);
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: "hub_v2_rd_stage_tasks_list",
|
|
45
|
+
description: "List Hub V2 RD current stage tasks with Project Token.",
|
|
46
|
+
riskLevel: "read",
|
|
47
|
+
inputSchema: schemas_1.rdStageTasksListSchema,
|
|
48
|
+
async handler(args) {
|
|
49
|
+
const ctx = (0, config_1.resolveHubV2Context)(args, "project");
|
|
50
|
+
const client = new client_1.HubV2Client(ctx);
|
|
51
|
+
const data = await client.request("GET", client.tokenUrl(`/rd-items/${encodeURIComponent(args.itemId)}/stage-tasks`));
|
|
52
|
+
return (0, result_1.ok)("hub_v2_rd_stage_tasks_list", data);
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
name: "hub_v2_rd_create",
|
|
57
|
+
description: "Preview or create a Hub V2 RD item with Personal Token.",
|
|
58
|
+
riskLevel: "write",
|
|
59
|
+
inputSchema: schemas_1.rdCreateSchema,
|
|
60
|
+
allowPreviewWhenBlocked: true,
|
|
61
|
+
isConfirmed: (args) => args.confirm === true,
|
|
62
|
+
async handler(args) {
|
|
63
|
+
const path = "/rd-items";
|
|
64
|
+
const body = (0, client_1.compact)({
|
|
65
|
+
title: args.title,
|
|
66
|
+
description: args.description,
|
|
67
|
+
stageId: args.stageId,
|
|
68
|
+
type: args.type,
|
|
69
|
+
priority: args.priority,
|
|
70
|
+
memberIds: args.memberIds,
|
|
71
|
+
verifierId: args.verifierId,
|
|
72
|
+
planStartAt: args.planStartAt,
|
|
73
|
+
planEndAt: args.planEndAt,
|
|
74
|
+
stageTasks: args.stageTasks,
|
|
75
|
+
stageTaskTemplates: args.stageTaskTemplates,
|
|
76
|
+
});
|
|
77
|
+
if (!args.confirm) {
|
|
78
|
+
return (0, result_1.ok)("hub_v2_rd_create", {
|
|
79
|
+
code: "PREVIEW",
|
|
80
|
+
message: "set confirm=true to execute this write operation",
|
|
81
|
+
data: {
|
|
82
|
+
method: "POST",
|
|
83
|
+
path,
|
|
84
|
+
requiredScope: "rd:create:write",
|
|
85
|
+
body,
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
const ctx = (0, config_1.resolveHubV2Context)(args, "personal");
|
|
90
|
+
const client = new client_1.HubV2Client(ctx);
|
|
91
|
+
const data = await client.request("POST", client.personalUrl(path), body);
|
|
92
|
+
return (0, result_1.ok)("hub_v2_rd_create", data);
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
name: "hub_v2_rd_advance_stage",
|
|
97
|
+
description: "Preview or execute Hub V2 RD stage advance with Personal Token.",
|
|
98
|
+
riskLevel: "write",
|
|
99
|
+
inputSchema: schemas_1.rdAdvanceStageSchema,
|
|
100
|
+
allowPreviewWhenBlocked: true,
|
|
101
|
+
isConfirmed: (args) => args.confirm === true,
|
|
102
|
+
async handler(args) {
|
|
103
|
+
const path = `/rd-items/${encodeURIComponent(args.itemId)}/advance-stage`;
|
|
104
|
+
const body = (0, client_1.compact)({
|
|
105
|
+
stageId: args.stageId,
|
|
106
|
+
memberIds: args.memberIds,
|
|
107
|
+
description: args.description,
|
|
108
|
+
planStartAt: args.planStartAt,
|
|
109
|
+
planEndAt: args.planEndAt,
|
|
110
|
+
stageTasks: args.stageTasks,
|
|
111
|
+
stageTaskTemplates: args.stageTaskTemplates,
|
|
112
|
+
});
|
|
113
|
+
if (!args.confirm) {
|
|
114
|
+
return (0, result_1.ok)("hub_v2_rd_advance_stage", {
|
|
115
|
+
code: "PREVIEW",
|
|
116
|
+
message: "set confirm=true to execute this write operation",
|
|
117
|
+
data: {
|
|
118
|
+
method: "POST",
|
|
119
|
+
path,
|
|
120
|
+
requiredScope: "rd:transition:write",
|
|
121
|
+
body,
|
|
122
|
+
},
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
const ctx = (0, config_1.resolveHubV2Context)(args, "personal");
|
|
126
|
+
const client = new client_1.HubV2Client(ctx);
|
|
127
|
+
const data = await client.request("POST", client.personalUrl(path), body);
|
|
128
|
+
return (0, result_1.ok)("hub_v2_rd_advance_stage", data);
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
name: "hub_v2_rd_stage_tasks_create",
|
|
133
|
+
description: "Preview or create a Hub V2 RD stage task on the current stage with Personal Token.",
|
|
134
|
+
riskLevel: "write",
|
|
135
|
+
inputSchema: schemas_1.rdStageTaskCreateSchema,
|
|
136
|
+
allowPreviewWhenBlocked: true,
|
|
137
|
+
isConfirmed: (args) => args.confirm === true,
|
|
138
|
+
async handler(args) {
|
|
139
|
+
const path = `/rd-items/${encodeURIComponent(args.itemId)}/stage-tasks`;
|
|
140
|
+
const body = (0, client_1.compact)({
|
|
141
|
+
title: args.title,
|
|
142
|
+
description: args.description,
|
|
143
|
+
ownerIds: args.ownerIds,
|
|
144
|
+
plannedStartAt: args.plannedStartAt,
|
|
145
|
+
plannedEndAt: args.plannedEndAt,
|
|
146
|
+
sortOrder: args.sortOrder,
|
|
147
|
+
remark: args.remark,
|
|
148
|
+
});
|
|
149
|
+
if (!args.confirm) {
|
|
150
|
+
return (0, result_1.ok)("hub_v2_rd_stage_tasks_create", {
|
|
151
|
+
code: "PREVIEW",
|
|
152
|
+
message: "set confirm=true to execute this write operation",
|
|
153
|
+
data: {
|
|
154
|
+
method: "POST",
|
|
155
|
+
path,
|
|
156
|
+
requiredScope: "rd:stage-task:write",
|
|
157
|
+
body,
|
|
158
|
+
},
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
const ctx = (0, config_1.resolveHubV2Context)(args, "personal");
|
|
162
|
+
const client = new client_1.HubV2Client(ctx);
|
|
163
|
+
const data = await client.request("POST", client.personalUrl(path), body);
|
|
164
|
+
return (0, result_1.ok)("hub_v2_rd_stage_tasks_create", data);
|
|
165
|
+
},
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
name: "hub_v2_rd_update_progress",
|
|
169
|
+
description: "Preview or update Hub V2 RD progress with Personal Token.",
|
|
170
|
+
riskLevel: "write",
|
|
171
|
+
inputSchema: schemas_1.rdUpdateProgressSchema,
|
|
172
|
+
allowPreviewWhenBlocked: true,
|
|
173
|
+
isConfirmed: (args) => args.confirm === true,
|
|
174
|
+
async handler(args) {
|
|
175
|
+
const path = `/rd-items/${encodeURIComponent(args.itemId)}/progress`;
|
|
176
|
+
const body = (0, client_1.compact)({
|
|
177
|
+
progress: args.progress,
|
|
178
|
+
note: args.note,
|
|
179
|
+
blockReason: args.blockReason,
|
|
180
|
+
resolveBlockId: args.resolveBlockId,
|
|
181
|
+
stageTaskId: args.stageTaskId,
|
|
182
|
+
});
|
|
183
|
+
if (!args.confirm) {
|
|
184
|
+
return (0, result_1.ok)("hub_v2_rd_update_progress", {
|
|
185
|
+
code: "PREVIEW",
|
|
186
|
+
message: "set confirm=true to execute this write operation",
|
|
187
|
+
data: {
|
|
188
|
+
method: "POST",
|
|
189
|
+
path,
|
|
190
|
+
requiredScope: "rd:progress:write or rd:transition:write",
|
|
191
|
+
body,
|
|
192
|
+
},
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
const ctx = (0, config_1.resolveHubV2Context)(args, "personal");
|
|
196
|
+
const client = new client_1.HubV2Client(ctx);
|
|
197
|
+
const data = await client.request("POST", client.personalUrl(path), body);
|
|
198
|
+
return (0, result_1.ok)("hub_v2_rd_update_progress", data);
|
|
199
|
+
},
|
|
200
|
+
},
|
|
201
|
+
];
|
|
202
|
+
}
|