meeglesdk 0.1.8 → 0.2.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/CHANGELOG.md +21 -0
- package/README.md +164 -7
- package/RELEASE.md +48 -0
- package/dist/client.d.ts +9 -0
- package/dist/client.js +10 -0
- package/dist/core/base-service.d.ts +2 -0
- package/dist/core/base-service.js +12 -0
- package/dist/core/request/handler.js +3 -2
- package/dist/core/request/types.d.ts +2 -0
- package/dist/helpers/event.d.ts +1 -1
- package/dist/helpers/event.js +14 -0
- package/dist/index.d.ts +14 -10
- package/dist/index.js +3 -0
- package/dist/service/aifield/index.d.ts +26 -0
- package/dist/service/aifield/index.js +27 -0
- package/dist/service/config/resource.d.ts +3 -3
- package/dist/service/config/resource.js +5 -1
- package/dist/service/config/role.d.ts +2 -1
- package/dist/service/config/role.js +2 -1
- package/dist/service/measure/index.d.ts +8 -0
- package/dist/service/measure/index.js +10 -0
- package/dist/service/measure/query.d.ts +31 -1
- package/dist/service/measure/query.js +31 -16
- package/dist/service/view/query.d.ts +10 -1
- package/dist/service/view/query.js +15 -0
- package/dist/service/workitem/attachment.d.ts +12 -12
- package/dist/service/workitem/attachment.js +8 -8
- package/dist/service/workitem/comment.d.ts +11 -11
- package/dist/service/workitem/comment.js +7 -7
- package/dist/service/workitem/search.d.ts +3 -7
- package/dist/service/workitem/search.js +8 -8
- package/dist/service/workitem/wbsDraft/index.d.ts +191 -0
- package/dist/service/workitem/wbsDraft/index.js +264 -0
- package/dist/service/workitem/wbsDraft.d.ts +191 -0
- package/dist/service/workitem/wbsDraft.js +394 -0
- package/dist/service/workitem/wbsProjectKeyResolver.d.ts +34 -0
- package/dist/service/workitem/wbsProjectKeyResolver.js +133 -0
- package/dist/service/workitem/wbsView/index.d.ts +46 -0
- package/dist/service/workitem/wbsView/index.js +51 -0
- package/dist/service/workitem/wbsView.d.ts +48 -0
- package/dist/service/workitem/wbsView.js +86 -0
- package/dist/service/workitem/workItem.d.ts +30 -7
- package/dist/service/workitem/workItem.js +43 -10
- package/dist/service/workitem/workflow.d.ts +2 -2
- package/dist/service/workitem/workflow.js +1 -0
- package/dist/service/workitem/workhour.d.ts +3 -3
- package/dist/types/aifield.d.ts +12 -0
- package/dist/types/aifield.js +4 -0
- package/dist/types/ainode.d.ts +70 -40
- package/dist/types/ainode.js +0 -3
- package/dist/types/common.d.ts +7 -1
- package/dist/types/config.d.ts +85 -22
- package/dist/types/event.d.ts +176 -9
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.js +2 -0
- package/dist/types/measure.d.ts +7 -0
- package/dist/types/tenant.d.ts +17 -4
- package/dist/types/user.d.ts +5 -1
- package/dist/types/view.d.ts +6 -0
- package/dist/types/workitem.d.ts +1413 -159
- package/package.json +8 -4
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WBS 草稿服务
|
|
3
|
+
*
|
|
4
|
+
* 之所以单独拆出这个服务,是因为计划表草稿接口已经形成独立能力域,
|
|
5
|
+
* 继续混在 workflow 服务里会让文档对齐、接口扩展和测试边界越来越混乱。
|
|
6
|
+
*/
|
|
7
|
+
import { BaseService } from '../../core/base-service.js';
|
|
8
|
+
import { WbsProjectKeyResolver } from './wbsProjectKeyResolver.js';
|
|
9
|
+
/** API 路径 */
|
|
10
|
+
export const API_PATHS = {
|
|
11
|
+
/** 创建 WBS 草稿 */
|
|
12
|
+
CREATE: '/open_api/work_item/wbs_draft/create',
|
|
13
|
+
/** 查询 WBS 草稿 */
|
|
14
|
+
QUERY: '/open_api/work_item/wbs_view_draft/query',
|
|
15
|
+
/** 查询创建草稿进度 */
|
|
16
|
+
CREATE_PROGRESS: '/open_api/work_item/wbs_draft_create/progress/query',
|
|
17
|
+
/** 更新 WBS 草稿 */
|
|
18
|
+
PATCH: '/open_api/work_item/wbs_draft/patch/update',
|
|
19
|
+
/** 查询更新草稿进度 */
|
|
20
|
+
PATCH_PROGRESS: '/open_api/work_item/wbs_draft_patch/progress/query',
|
|
21
|
+
/** 发布 WBS 草稿 */
|
|
22
|
+
PUBLISH: '/open_api/work_item/wbs_draft/publish',
|
|
23
|
+
/** 完成创建草稿审核 */
|
|
24
|
+
COMPLETE_CREATE_AUDIT: '/open_api/wbs_view_draft/complete-create-audit',
|
|
25
|
+
/** 重置 WBS 草稿 */
|
|
26
|
+
RESET: '/open_api/work_item/wbs_draft/reset',
|
|
27
|
+
/** 查询发布草稿进度 */
|
|
28
|
+
PUBLISH_PROGRESS: '/open_api/work_item/wbs_draft_publish/progress/query',
|
|
29
|
+
/** 查询重置草稿进度 */
|
|
30
|
+
RESET_PROGRESS: '/open_api/work_item/wbs_draft_reset/progress/query',
|
|
31
|
+
/** 查询 WBS 草稿子工作项配置 */
|
|
32
|
+
SUB_WORK_ITEM_CONF: '/open_api/work_item/wbs_view_draft/sub_work_item_conf',
|
|
33
|
+
/** 查询 WBS 草稿骨架 */
|
|
34
|
+
STRUCTURE: '/open_api/work_item/wbs_draft/structure/query',
|
|
35
|
+
/** 查询 WBS 草稿行详情 */
|
|
36
|
+
ROW_DETAIL: '/open_api/work_item/wbs_draft/detail/query',
|
|
37
|
+
/** 查询 WBS 草稿行配置 */
|
|
38
|
+
ROW_CONFIG: '/open_api/work_item/wbs_draft/task_conf/query',
|
|
39
|
+
/** 更新草稿冻结行 */
|
|
40
|
+
UPDATE_FROZEN_ROWS: '/open_api/:project_key/wbs_view_draft/update/frozen_rows',
|
|
41
|
+
/** 基于提交版本发布草稿 */
|
|
42
|
+
COLLABORATION_PUBLISH: '/open_api/:project_key/wbs_view_draft/publish',
|
|
43
|
+
/** 审批拒绝切回草稿 */
|
|
44
|
+
SWITCH_BACK: '/open_api/:project_key/wbs_view_draft/switch',
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* WBS 草稿服务
|
|
48
|
+
*/
|
|
49
|
+
export class WbsDraftService extends BaseService {
|
|
50
|
+
projectKeyResolver;
|
|
51
|
+
constructor(requestHandler) {
|
|
52
|
+
super(requestHandler);
|
|
53
|
+
this.projectKeyResolver = new WbsProjectKeyResolver(requestHandler);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* 创建 WBS 草稿
|
|
57
|
+
*
|
|
58
|
+
* @param request 创建请求
|
|
59
|
+
* @param options 请求选项
|
|
60
|
+
* @returns 创建草稿结果
|
|
61
|
+
*/
|
|
62
|
+
async createDraft(request, options) {
|
|
63
|
+
const projectKey = await this.projectKeyResolver.resolveProjectKey({
|
|
64
|
+
projectKey: request.project_key,
|
|
65
|
+
workItemId: request.work_item_id,
|
|
66
|
+
workItemTypeKey: request.work_item_type_key,
|
|
67
|
+
options,
|
|
68
|
+
});
|
|
69
|
+
return this.post(API_PATHS.CREATE, {
|
|
70
|
+
...request,
|
|
71
|
+
project_key: projectKey,
|
|
72
|
+
}, options);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* 查询 WBS 草稿
|
|
76
|
+
*
|
|
77
|
+
* @param request 查询请求
|
|
78
|
+
* @param options 请求选项
|
|
79
|
+
* @returns WBS 草稿
|
|
80
|
+
*/
|
|
81
|
+
async getDraft(request, options) {
|
|
82
|
+
const projectKey = await this.projectKeyResolver.resolveProjectKey({
|
|
83
|
+
projectKey: request.project_key,
|
|
84
|
+
workItemId: request.work_item_id,
|
|
85
|
+
workItemTypeKey: request.work_item_type_key,
|
|
86
|
+
options,
|
|
87
|
+
});
|
|
88
|
+
const result = await this.post(API_PATHS.QUERY, {
|
|
89
|
+
...request,
|
|
90
|
+
project_key: projectKey,
|
|
91
|
+
}, options);
|
|
92
|
+
return result.wbs_draft ?? {};
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* 更新 WBS 草稿
|
|
96
|
+
*
|
|
97
|
+
* @param request 更新请求
|
|
98
|
+
* @param options 请求选项
|
|
99
|
+
* @returns 平台返回的关系字段回填结果
|
|
100
|
+
*/
|
|
101
|
+
async patchDraft(request, options) {
|
|
102
|
+
const projectKey = await this.projectKeyResolver.resolveProjectKey({
|
|
103
|
+
projectKey: request.project_key,
|
|
104
|
+
workItemId: request.work_item_id,
|
|
105
|
+
options,
|
|
106
|
+
});
|
|
107
|
+
return this.post(API_PATHS.PATCH, {
|
|
108
|
+
...request,
|
|
109
|
+
project_key: projectKey,
|
|
110
|
+
}, options);
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* 发布 WBS 草稿
|
|
114
|
+
*
|
|
115
|
+
* @param request 发布请求
|
|
116
|
+
* @param options 请求选项
|
|
117
|
+
*/
|
|
118
|
+
async publishDraft(request, options) {
|
|
119
|
+
const projectKey = await this.projectKeyResolver.resolveProjectKey({
|
|
120
|
+
projectKey: request.project_key,
|
|
121
|
+
workItemId: request.work_item_id,
|
|
122
|
+
options,
|
|
123
|
+
});
|
|
124
|
+
return this.post(API_PATHS.PUBLISH, {
|
|
125
|
+
...request,
|
|
126
|
+
project_key: projectKey,
|
|
127
|
+
}, options);
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* 查询创建草稿进度
|
|
131
|
+
*
|
|
132
|
+
* @param request 进度查询请求
|
|
133
|
+
* @param options 请求选项
|
|
134
|
+
* @returns 任务进度
|
|
135
|
+
*/
|
|
136
|
+
async getCreateDraftProgress(request, options) {
|
|
137
|
+
const projectKey = await this.projectKeyResolver.resolveProjectKey({
|
|
138
|
+
projectKey: request.project_key,
|
|
139
|
+
workItemId: request.work_item_id,
|
|
140
|
+
options,
|
|
141
|
+
});
|
|
142
|
+
return this.post(API_PATHS.CREATE_PROGRESS, {
|
|
143
|
+
...request,
|
|
144
|
+
project_key: projectKey,
|
|
145
|
+
}, options);
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* 完成创建草稿审核
|
|
149
|
+
*
|
|
150
|
+
* 这条接口和普通草稿发布链路分离,
|
|
151
|
+
* 单独暴露可以避免调用方误把审核态提交当成普通发布。
|
|
152
|
+
*
|
|
153
|
+
* @param request 审核完成请求
|
|
154
|
+
* @param options 请求选项
|
|
155
|
+
* @returns 是否成功
|
|
156
|
+
*/
|
|
157
|
+
async completeCreateAuditDraft(request, options) {
|
|
158
|
+
const projectKey = await this.projectKeyResolver.resolveProjectKey({
|
|
159
|
+
projectKey: request.project_key,
|
|
160
|
+
workItemId: request.work_item_id,
|
|
161
|
+
options,
|
|
162
|
+
});
|
|
163
|
+
const result = await this.post(API_PATHS.COMPLETE_CREATE_AUDIT, {
|
|
164
|
+
...request,
|
|
165
|
+
project_key: projectKey,
|
|
166
|
+
}, options);
|
|
167
|
+
return { success: result.success };
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* 重置 WBS 草稿
|
|
171
|
+
*
|
|
172
|
+
* @param request 重置请求
|
|
173
|
+
* @param options 请求选项
|
|
174
|
+
* @returns 重置后的 WBS 草稿
|
|
175
|
+
*/
|
|
176
|
+
async resetDraft(request, options) {
|
|
177
|
+
const projectKey = await this.projectKeyResolver.resolveProjectKey({
|
|
178
|
+
projectKey: request.project_key,
|
|
179
|
+
workItemId: request.work_item_id,
|
|
180
|
+
options,
|
|
181
|
+
});
|
|
182
|
+
return this.post(API_PATHS.RESET, {
|
|
183
|
+
...request,
|
|
184
|
+
project_key: projectKey,
|
|
185
|
+
}, options);
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* 查询更新草稿进度
|
|
189
|
+
*
|
|
190
|
+
* @param request 进度查询请求
|
|
191
|
+
* @param options 请求选项
|
|
192
|
+
* @returns 任务进度
|
|
193
|
+
*/
|
|
194
|
+
async getPatchDraftProgress(request, options) {
|
|
195
|
+
const projectKey = await this.projectKeyResolver.resolveProjectKey({
|
|
196
|
+
projectKey: request.project_key,
|
|
197
|
+
options,
|
|
198
|
+
});
|
|
199
|
+
return this.post(API_PATHS.PATCH_PROGRESS, {
|
|
200
|
+
...request,
|
|
201
|
+
project_key: projectKey,
|
|
202
|
+
}, options);
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* 查询 WBS 草稿子工作项配置
|
|
206
|
+
*
|
|
207
|
+
* @param request 查询请求
|
|
208
|
+
* @param options 请求选项
|
|
209
|
+
* @returns 子工作项配置列表
|
|
210
|
+
*/
|
|
211
|
+
async getSubWorkItemConf(request, options) {
|
|
212
|
+
const projectKey = await this.projectKeyResolver.resolveProjectKey({
|
|
213
|
+
projectKey: request.project_key,
|
|
214
|
+
workItemId: request.work_item_id,
|
|
215
|
+
options,
|
|
216
|
+
});
|
|
217
|
+
const result = await this.get(API_PATHS.SUB_WORK_ITEM_CONF, {
|
|
218
|
+
...options,
|
|
219
|
+
query: {
|
|
220
|
+
draft_id: request.draft_id,
|
|
221
|
+
work_item_id: request.work_item_id,
|
|
222
|
+
node_uuid: request.node_uuid,
|
|
223
|
+
project_key: projectKey,
|
|
224
|
+
...options?.query,
|
|
225
|
+
},
|
|
226
|
+
});
|
|
227
|
+
return result.draft_view_sub_work_item_confs ?? [];
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* 查询全量计划表草稿骨架
|
|
231
|
+
*
|
|
232
|
+
* 草稿骨架是后续行详情查询的前置输入,保持独立方法可以让调用链路更清晰。
|
|
233
|
+
*
|
|
234
|
+
* @param request 草稿骨架查询请求
|
|
235
|
+
* @param options 请求选项
|
|
236
|
+
* @returns 草稿骨架响应
|
|
237
|
+
*/
|
|
238
|
+
async queryStructure(request, options) {
|
|
239
|
+
const projectKey = await this.projectKeyResolver.resolveProjectKey({
|
|
240
|
+
projectKey: request.project_key,
|
|
241
|
+
workItemId: request.work_item_id,
|
|
242
|
+
options,
|
|
243
|
+
});
|
|
244
|
+
return this.post(API_PATHS.STRUCTURE, {
|
|
245
|
+
...request,
|
|
246
|
+
project_key: projectKey,
|
|
247
|
+
}, options);
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* 查询计划表草稿数据行详细信息
|
|
251
|
+
*
|
|
252
|
+
* @param request 草稿行详情查询请求
|
|
253
|
+
* @param options 请求选项
|
|
254
|
+
* @returns 草稿行详情原始响应
|
|
255
|
+
*/
|
|
256
|
+
async queryRowDetails(request, options) {
|
|
257
|
+
const projectKey = await this.projectKeyResolver.resolveProjectKey({
|
|
258
|
+
projectKey: request.project_key,
|
|
259
|
+
workItemId: request.work_item_id,
|
|
260
|
+
options,
|
|
261
|
+
});
|
|
262
|
+
return this.post(API_PATHS.ROW_DETAIL, {
|
|
263
|
+
...request,
|
|
264
|
+
project_key: projectKey,
|
|
265
|
+
}, options);
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* 查询计划表草稿行配置信息
|
|
269
|
+
*
|
|
270
|
+
* @param request 草稿行配置查询请求
|
|
271
|
+
* @param options 请求选项
|
|
272
|
+
* @returns 草稿行配置原始响应
|
|
273
|
+
*/
|
|
274
|
+
async queryRowConfig(request, options) {
|
|
275
|
+
const projectKey = await this.projectKeyResolver.resolveProjectKey({
|
|
276
|
+
projectKey: request.project_key,
|
|
277
|
+
workItemId: request.work_item_id,
|
|
278
|
+
options,
|
|
279
|
+
});
|
|
280
|
+
return this.post(API_PATHS.ROW_CONFIG, {
|
|
281
|
+
...request,
|
|
282
|
+
project_key: projectKey,
|
|
283
|
+
}, options);
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* 更新草稿冻结行
|
|
287
|
+
*
|
|
288
|
+
* @param request 冻结行更新请求
|
|
289
|
+
* @param options 请求选项
|
|
290
|
+
*/
|
|
291
|
+
async updateFrozenRows(request, options) {
|
|
292
|
+
const projectKey = await this.projectKeyResolver.resolveProjectKey({
|
|
293
|
+
projectKey: request.project_key,
|
|
294
|
+
workItemId: request.work_item_id,
|
|
295
|
+
options,
|
|
296
|
+
});
|
|
297
|
+
await this.post(API_PATHS.UPDATE_FROZEN_ROWS, request, {
|
|
298
|
+
...options,
|
|
299
|
+
pathParams: {
|
|
300
|
+
...(options?.pathParams ?? {}),
|
|
301
|
+
project_key: projectKey,
|
|
302
|
+
},
|
|
303
|
+
responseValidator: options?.responseValidator,
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* 基于提交版本发布草稿
|
|
308
|
+
*
|
|
309
|
+
* @param request 发布请求
|
|
310
|
+
* @param options 请求选项
|
|
311
|
+
* @returns 是否成功
|
|
312
|
+
*/
|
|
313
|
+
async publishDraftByCommit(request, options) {
|
|
314
|
+
const projectKey = await this.projectKeyResolver.resolveProjectKey({
|
|
315
|
+
projectKey: request.project_key,
|
|
316
|
+
workItemId: request.work_item_id,
|
|
317
|
+
options,
|
|
318
|
+
});
|
|
319
|
+
const result = await this.post(API_PATHS.COLLABORATION_PUBLISH, {
|
|
320
|
+
work_item_id: request.work_item_id,
|
|
321
|
+
draft_id: request.draft_id,
|
|
322
|
+
commit_id: request.commit_id,
|
|
323
|
+
}, {
|
|
324
|
+
...options,
|
|
325
|
+
pathParams: {
|
|
326
|
+
...(options?.pathParams ?? {}),
|
|
327
|
+
project_key: projectKey,
|
|
328
|
+
},
|
|
329
|
+
});
|
|
330
|
+
return { success: result.success };
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* 查询发布草稿进度
|
|
334
|
+
*
|
|
335
|
+
* @param request 进度查询请求
|
|
336
|
+
* @param options 请求选项
|
|
337
|
+
* @returns 任务进度
|
|
338
|
+
*/
|
|
339
|
+
async getPublishDraftProgress(request, options) {
|
|
340
|
+
const projectKey = await this.projectKeyResolver.resolveProjectKey({
|
|
341
|
+
projectKey: request.project_key,
|
|
342
|
+
workItemId: request.work_item_id,
|
|
343
|
+
options,
|
|
344
|
+
});
|
|
345
|
+
return this.post(API_PATHS.PUBLISH_PROGRESS, {
|
|
346
|
+
...request,
|
|
347
|
+
project_key: projectKey,
|
|
348
|
+
}, options);
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* 审批拒绝后切回草稿
|
|
352
|
+
*
|
|
353
|
+
* @param request 切回草稿请求
|
|
354
|
+
* @param options 请求选项
|
|
355
|
+
* @returns 是否成功
|
|
356
|
+
*/
|
|
357
|
+
async switchBackDraft(request, options) {
|
|
358
|
+
const projectKey = await this.projectKeyResolver.resolveProjectKey({
|
|
359
|
+
projectKey: request.project_key,
|
|
360
|
+
workItemId: request.work_item_id,
|
|
361
|
+
options,
|
|
362
|
+
});
|
|
363
|
+
const result = await this.post(API_PATHS.SWITCH_BACK, {
|
|
364
|
+
work_item_id: request.work_item_id,
|
|
365
|
+
draft_id: request.draft_id,
|
|
366
|
+
commit_id: request.commit_id,
|
|
367
|
+
}, {
|
|
368
|
+
...options,
|
|
369
|
+
pathParams: {
|
|
370
|
+
...(options?.pathParams ?? {}),
|
|
371
|
+
project_key: projectKey,
|
|
372
|
+
},
|
|
373
|
+
});
|
|
374
|
+
return { success: result.success };
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* 查询重置草稿进度
|
|
378
|
+
*
|
|
379
|
+
* @param request 进度查询请求
|
|
380
|
+
* @param options 请求选项
|
|
381
|
+
* @returns 任务进度
|
|
382
|
+
*/
|
|
383
|
+
async getResetDraftProgress(request, options) {
|
|
384
|
+
const projectKey = await this.projectKeyResolver.resolveProjectKey({
|
|
385
|
+
projectKey: request.project_key,
|
|
386
|
+
workItemId: request.work_item_id,
|
|
387
|
+
options,
|
|
388
|
+
});
|
|
389
|
+
return this.post(API_PATHS.RESET_PROGRESS, {
|
|
390
|
+
...request,
|
|
391
|
+
project_key: projectKey,
|
|
392
|
+
}, options);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WBS 空间标识解析器
|
|
3
|
+
*
|
|
4
|
+
* WBS 相关接口对 project_key 的要求和普通工作项接口不同:
|
|
5
|
+
* 普通接口通常接受 simple_name,而 WBS 接口实际要求内部 project_key。
|
|
6
|
+
* 这里统一做一次解析,避免调用方为同一空间维护两套标识。
|
|
7
|
+
*/
|
|
8
|
+
import { BaseService, type ServiceRequestOptions } from '../../core/base-service.js';
|
|
9
|
+
interface ResolveProjectKeyRequest {
|
|
10
|
+
projectKey: string;
|
|
11
|
+
workItemId?: number;
|
|
12
|
+
workItemTypeKey?: string;
|
|
13
|
+
options?: ServiceRequestOptions<unknown>;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* WBS project_key 解析器
|
|
17
|
+
*/
|
|
18
|
+
export declare class WbsProjectKeyResolver extends BaseService {
|
|
19
|
+
private readonly cache;
|
|
20
|
+
private readonly pending;
|
|
21
|
+
/**
|
|
22
|
+
* 解析 WBS 可用的 project_key
|
|
23
|
+
*
|
|
24
|
+
* @param request 解析参数
|
|
25
|
+
* @returns WBS 接口可接受的空间 key
|
|
26
|
+
*/
|
|
27
|
+
resolveProjectKey(request: ResolveProjectKeyRequest): Promise<string>;
|
|
28
|
+
private resolveProjectKeyInternal;
|
|
29
|
+
private resolveByWorkItemQuery;
|
|
30
|
+
private resolveByWorkItemFilter;
|
|
31
|
+
private extractCanonicalProjectKey;
|
|
32
|
+
private pickResolverOptions;
|
|
33
|
+
}
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WBS 空间标识解析器
|
|
3
|
+
*
|
|
4
|
+
* WBS 相关接口对 project_key 的要求和普通工作项接口不同:
|
|
5
|
+
* 普通接口通常接受 simple_name,而 WBS 接口实际要求内部 project_key。
|
|
6
|
+
* 这里统一做一次解析,避免调用方为同一空间维护两套标识。
|
|
7
|
+
*/
|
|
8
|
+
import { BaseService } from '../../core/base-service.js';
|
|
9
|
+
const API_PATHS = {
|
|
10
|
+
WORK_ITEM_QUERY: '/open_api/:project_key/work_item/:work_item_type_key/query',
|
|
11
|
+
WORK_ITEM_FILTER: '/open_api/:project_key/work_item/filter',
|
|
12
|
+
WORK_ITEM_TYPES: '/open_api/:project_key/work_item/all-types',
|
|
13
|
+
};
|
|
14
|
+
const CANONICAL_PROJECT_KEY_PATTERN = /^[0-9a-f]{24}$/i;
|
|
15
|
+
/**
|
|
16
|
+
* WBS project_key 解析器
|
|
17
|
+
*/
|
|
18
|
+
export class WbsProjectKeyResolver extends BaseService {
|
|
19
|
+
cache = new Map();
|
|
20
|
+
pending = new Map();
|
|
21
|
+
/**
|
|
22
|
+
* 解析 WBS 可用的 project_key
|
|
23
|
+
*
|
|
24
|
+
* @param request 解析参数
|
|
25
|
+
* @returns WBS 接口可接受的空间 key
|
|
26
|
+
*/
|
|
27
|
+
async resolveProjectKey(request) {
|
|
28
|
+
const projectKey = request.projectKey.trim();
|
|
29
|
+
if (!projectKey || CANONICAL_PROJECT_KEY_PATTERN.test(projectKey)) {
|
|
30
|
+
return projectKey;
|
|
31
|
+
}
|
|
32
|
+
const cached = this.cache.get(projectKey);
|
|
33
|
+
if (cached) {
|
|
34
|
+
return cached;
|
|
35
|
+
}
|
|
36
|
+
const pending = this.pending.get(projectKey);
|
|
37
|
+
if (pending) {
|
|
38
|
+
return pending;
|
|
39
|
+
}
|
|
40
|
+
const task = this.resolveProjectKeyInternal({
|
|
41
|
+
...request,
|
|
42
|
+
projectKey,
|
|
43
|
+
}).finally(() => {
|
|
44
|
+
this.pending.delete(projectKey);
|
|
45
|
+
});
|
|
46
|
+
this.pending.set(projectKey, task);
|
|
47
|
+
return task;
|
|
48
|
+
}
|
|
49
|
+
async resolveProjectKeyInternal(request) {
|
|
50
|
+
const { projectKey, workItemId, workItemTypeKey, options } = request;
|
|
51
|
+
if (workItemId !== undefined && workItemTypeKey) {
|
|
52
|
+
const byQuery = await this.resolveByWorkItemQuery(projectKey, workItemId, workItemTypeKey, options);
|
|
53
|
+
if (byQuery) {
|
|
54
|
+
this.cache.set(projectKey, byQuery);
|
|
55
|
+
return byQuery;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (workItemId !== undefined) {
|
|
59
|
+
const byFilter = await this.resolveByWorkItemFilter(projectKey, workItemId, options);
|
|
60
|
+
if (byFilter) {
|
|
61
|
+
this.cache.set(projectKey, byFilter);
|
|
62
|
+
return byFilter;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return projectKey;
|
|
66
|
+
}
|
|
67
|
+
async resolveByWorkItemQuery(projectKey, workItemId, workItemTypeKey, options) {
|
|
68
|
+
try {
|
|
69
|
+
const result = await this.post(API_PATHS.WORK_ITEM_QUERY, {
|
|
70
|
+
work_item_ids: [workItemId],
|
|
71
|
+
}, {
|
|
72
|
+
...this.pickResolverOptions(options),
|
|
73
|
+
pathParams: {
|
|
74
|
+
...(options?.pathParams ?? {}),
|
|
75
|
+
project_key: projectKey,
|
|
76
|
+
work_item_type_key: workItemTypeKey,
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
return this.extractCanonicalProjectKey(result[0]?.project_key);
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
return undefined;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
async resolveByWorkItemFilter(projectKey, workItemId, options) {
|
|
86
|
+
try {
|
|
87
|
+
const workItemTypes = await this.get(API_PATHS.WORK_ITEM_TYPES, {
|
|
88
|
+
...this.pickResolverOptions(options),
|
|
89
|
+
pathParams: {
|
|
90
|
+
...(options?.pathParams ?? {}),
|
|
91
|
+
project_key: projectKey,
|
|
92
|
+
},
|
|
93
|
+
});
|
|
94
|
+
const workItemTypeKeys = workItemTypes
|
|
95
|
+
.map((item) => item.type_key || item.api_name)
|
|
96
|
+
.filter((item) => Boolean(item));
|
|
97
|
+
if (workItemTypeKeys.length === 0) {
|
|
98
|
+
return undefined;
|
|
99
|
+
}
|
|
100
|
+
const result = await this.postPaginated(API_PATHS.WORK_ITEM_FILTER, {
|
|
101
|
+
work_item_type_keys: workItemTypeKeys,
|
|
102
|
+
work_item_ids: [workItemId],
|
|
103
|
+
page_size: 1,
|
|
104
|
+
}, {
|
|
105
|
+
...this.pickResolverOptions(options),
|
|
106
|
+
pathParams: {
|
|
107
|
+
...(options?.pathParams ?? {}),
|
|
108
|
+
project_key: projectKey,
|
|
109
|
+
},
|
|
110
|
+
});
|
|
111
|
+
return this.extractCanonicalProjectKey(result.data[0]?.project_key);
|
|
112
|
+
}
|
|
113
|
+
catch {
|
|
114
|
+
return undefined;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
extractCanonicalProjectKey(projectKey) {
|
|
118
|
+
if (!projectKey) {
|
|
119
|
+
return undefined;
|
|
120
|
+
}
|
|
121
|
+
return CANONICAL_PROJECT_KEY_PATTERN.test(projectKey) ? projectKey : undefined;
|
|
122
|
+
}
|
|
123
|
+
pickResolverOptions(options) {
|
|
124
|
+
return {
|
|
125
|
+
query: options?.query,
|
|
126
|
+
auth: options?.auth,
|
|
127
|
+
idempotencyKey: options?.idempotencyKey,
|
|
128
|
+
timeout: options?.timeout,
|
|
129
|
+
skipRetry: options?.skipRetry,
|
|
130
|
+
retry: options?.retry,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WBS 发布态服务
|
|
3
|
+
*
|
|
4
|
+
* 计划表发布态接口和草稿态是两套能力边界,
|
|
5
|
+
* 单独拆出服务可以避免 draft/view 两类接口再次混用。
|
|
6
|
+
*/
|
|
7
|
+
import { BaseService, type ServiceRequestOptions } from '../../../core/base-service.js';
|
|
8
|
+
import type { QueryWbsViewStructureRequest, QueryWbsViewStructureResponse, QueryWbsViewRowDetailRequest, QueryWbsViewRowDetailResponse, QueryWbsInstanceExpandInfoRequest, QueryWbsInstanceExpandInfoResponse } from '../../../types/workitem.js';
|
|
9
|
+
/** API 路径 */
|
|
10
|
+
export declare const API_PATHS: {
|
|
11
|
+
/** 查询全量计划表骨架 */
|
|
12
|
+
STRUCTURE: string;
|
|
13
|
+
/** 查询计划表行详情 */
|
|
14
|
+
DETAIL: string;
|
|
15
|
+
/** 查询计划表扩展信息 */
|
|
16
|
+
EXPAND: string;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* WBS 发布态服务
|
|
20
|
+
*/
|
|
21
|
+
export declare class WbsViewService extends BaseService {
|
|
22
|
+
/**
|
|
23
|
+
* 查询全量计划表骨架
|
|
24
|
+
*
|
|
25
|
+
* @param request 查询请求
|
|
26
|
+
* @param options 请求选项
|
|
27
|
+
* @returns 发布态计划表骨架
|
|
28
|
+
*/
|
|
29
|
+
queryStructure(request: QueryWbsViewStructureRequest, options?: ServiceRequestOptions<QueryWbsViewStructureResponse>): Promise<QueryWbsViewStructureResponse>;
|
|
30
|
+
/**
|
|
31
|
+
* 查询计划表行详细信息
|
|
32
|
+
*
|
|
33
|
+
* @param request 查询请求
|
|
34
|
+
* @param options 请求选项
|
|
35
|
+
* @returns 发布态计划表行详情
|
|
36
|
+
*/
|
|
37
|
+
queryRowDetails(request: QueryWbsViewRowDetailRequest, options?: ServiceRequestOptions<QueryWbsViewRowDetailResponse>): Promise<QueryWbsViewRowDetailResponse>;
|
|
38
|
+
/**
|
|
39
|
+
* 查询计划表扩展信息
|
|
40
|
+
*
|
|
41
|
+
* @param request 查询请求
|
|
42
|
+
* @param options 请求选项
|
|
43
|
+
* @returns 发布态计划表扩展信息
|
|
44
|
+
*/
|
|
45
|
+
queryExpandInfo(request: QueryWbsInstanceExpandInfoRequest, options?: ServiceRequestOptions<QueryWbsInstanceExpandInfoResponse>): Promise<QueryWbsInstanceExpandInfoResponse>;
|
|
46
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WBS 发布态服务
|
|
3
|
+
*
|
|
4
|
+
* 计划表发布态接口和草稿态是两套能力边界,
|
|
5
|
+
* 单独拆出服务可以避免 draft/view 两类接口再次混用。
|
|
6
|
+
*/
|
|
7
|
+
import { BaseService } from '../../../core/base-service.js';
|
|
8
|
+
/** API 路径 */
|
|
9
|
+
export const API_PATHS = {
|
|
10
|
+
/** 查询全量计划表骨架 */
|
|
11
|
+
STRUCTURE: '/open_api/work_item/wbs_view/structure/query',
|
|
12
|
+
/** 查询计划表行详情 */
|
|
13
|
+
DETAIL: '/open_api/work_item/wbs_view/detail/query',
|
|
14
|
+
/** 查询计划表扩展信息 */
|
|
15
|
+
EXPAND: '/open_api/work_item/wbs_instance/expand/query',
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* WBS 发布态服务
|
|
19
|
+
*/
|
|
20
|
+
export class WbsViewService extends BaseService {
|
|
21
|
+
/**
|
|
22
|
+
* 查询全量计划表骨架
|
|
23
|
+
*
|
|
24
|
+
* @param request 查询请求
|
|
25
|
+
* @param options 请求选项
|
|
26
|
+
* @returns 发布态计划表骨架
|
|
27
|
+
*/
|
|
28
|
+
async queryStructure(request, options) {
|
|
29
|
+
return this.post(API_PATHS.STRUCTURE, request, options);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* 查询计划表行详细信息
|
|
33
|
+
*
|
|
34
|
+
* @param request 查询请求
|
|
35
|
+
* @param options 请求选项
|
|
36
|
+
* @returns 发布态计划表行详情
|
|
37
|
+
*/
|
|
38
|
+
async queryRowDetails(request, options) {
|
|
39
|
+
return this.post(API_PATHS.DETAIL, request, options);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* 查询计划表扩展信息
|
|
43
|
+
*
|
|
44
|
+
* @param request 查询请求
|
|
45
|
+
* @param options 请求选项
|
|
46
|
+
* @returns 发布态计划表扩展信息
|
|
47
|
+
*/
|
|
48
|
+
async queryExpandInfo(request, options) {
|
|
49
|
+
return this.post(API_PATHS.EXPAND, request, options);
|
|
50
|
+
}
|
|
51
|
+
}
|