zentao-api 0.6.4 → 0.6.6
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/dist/browser/zentao-api.global.js +26 -18
- package/dist/client/index.d.ts +4 -1
- package/dist/client/index.js +194 -17
- package/dist/index.d.ts +1 -1
- package/dist/misc/environment.d.ts +0 -2
- package/dist/misc/environment.js +43 -19
- package/dist/misc/errors.d.ts +1 -0
- package/dist/misc/errors.js +1 -0
- package/dist/modules/generated.d.ts +2045 -59
- package/dist/modules/generated.js +1027 -55
- package/dist/modules/override.js +36 -66
- package/dist/modules/query.d.ts +0 -2
- package/dist/modules/query.js +5 -15
- package/dist/modules/registry.d.ts +0 -9669
- package/dist/modules/registry.js +0 -4
- package/dist/modules/resolve.js +1 -1
- package/dist/profiles/index.js +1 -4
- package/dist/request/index.d.ts +12 -4
- package/dist/request/index.js +2 -2
- package/dist/types/client.d.ts +3 -3
- package/dist/types/module.d.ts +6 -2
- package/dist/types/options.d.ts +1 -0
- package/dist/utils/doc-helper/index.d.ts +1 -2
- package/dist/utils/doc-helper/index.js +0 -1
- package/dist/utils/doc-helper/inline.d.ts +0 -1
- package/dist/utils/doc-helper/inline.js +3 -81
- package/dist/utils/doc-helper/shared.d.ts +0 -5
- package/dist/utils/doc-helper/shared.js +0 -34
- package/dist/utils/doc-helper/types.d.ts +1 -13
- package/dist/version.js +2 -2
- package/package.json +9 -8
- package/dist/utils/doc-helper/html.d.ts +0 -3
- package/dist/utils/doc-helper/html.js +0 -442
package/dist/modules/override.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { extendModuleAction } from './define.js';
|
|
1
|
+
import { extendModuleAction, defineModuleActions } from './define.js';
|
|
2
2
|
import { extractResult } from './resolve.js';
|
|
3
3
|
import { snapshotToMarkdown } from '../utils/doc-helper/markdown.js';
|
|
4
4
|
import { isRecord } from '../utils/index.js';
|
|
@@ -90,14 +90,6 @@ export function applyBuiltinOverrides() {
|
|
|
90
90
|
}
|
|
91
91
|
return action;
|
|
92
92
|
});
|
|
93
|
-
// 修改 task/list URL 定义
|
|
94
|
-
extendModuleAction('task', 'list', (action) => {
|
|
95
|
-
action.path = '/executions/{executionID}/tasks';
|
|
96
|
-
action.pathParams = {
|
|
97
|
-
executionID: '执行ID',
|
|
98
|
-
};
|
|
99
|
-
return action;
|
|
100
|
-
});
|
|
101
93
|
// 修改 acl 字段默认值为 open
|
|
102
94
|
[
|
|
103
95
|
['product', 'create'],
|
|
@@ -113,31 +105,10 @@ export function applyBuiltinOverrides() {
|
|
|
113
105
|
return action;
|
|
114
106
|
});
|
|
115
107
|
});
|
|
116
|
-
// execution
|
|
108
|
+
// execution/create 补充 OpenAPI 尚未声明的里程碑字段
|
|
117
109
|
extendModuleAction('execution', 'create', (action) => {
|
|
118
110
|
const properties = action.requestBody.schema?.properties;
|
|
119
111
|
if (properties) {
|
|
120
|
-
if (!properties.type) {
|
|
121
|
-
properties.type = {
|
|
122
|
-
type: 'string',
|
|
123
|
-
description: '类型(sprint 迭代,敏捷项目用 | stage 阶段,瀑布/IPD 用 | kanban 看板)',
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
if (!properties.attribute) {
|
|
127
|
-
properties.attribute = {
|
|
128
|
-
type: 'string',
|
|
129
|
-
description: [
|
|
130
|
-
'阶段属性:mix - 综合(父阶段可挂不同类型子阶段)',
|
|
131
|
-
'request - 需求(不关联需求、不测、不构建、不导入 Bug)',
|
|
132
|
-
'design - 设计(不测、不构建、不 DevOps)',
|
|
133
|
-
'dev - 开发(功能完整,可需求、任务、测试、构建)',
|
|
134
|
-
'qa - 测试(同上,偏测试)',
|
|
135
|
-
'release - 发布(同上,偏发布)',
|
|
136
|
-
'review - 总结评审(最严:不关联需求、不测、不构建)',
|
|
137
|
-
'other - 其他(无上述专项限制)'
|
|
138
|
-
].join(' | '),
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
112
|
if (!properties.milestone) {
|
|
142
113
|
properties.milestone = {
|
|
143
114
|
type: 'integer',
|
|
@@ -145,13 +116,6 @@ export function applyBuiltinOverrides() {
|
|
|
145
116
|
format: 'int32'
|
|
146
117
|
};
|
|
147
118
|
}
|
|
148
|
-
if (!properties.parent) {
|
|
149
|
-
properties.parent = {
|
|
150
|
-
type: 'integer',
|
|
151
|
-
description: '父级项目',
|
|
152
|
-
format: 'int32'
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
119
|
}
|
|
156
120
|
return action;
|
|
157
121
|
});
|
|
@@ -179,34 +143,6 @@ export function applyBuiltinOverrides() {
|
|
|
179
143
|
}
|
|
180
144
|
return action;
|
|
181
145
|
});
|
|
182
|
-
// 修改 BUG 列表选项
|
|
183
|
-
extendModuleAction('bug', 'list', (action) => {
|
|
184
|
-
const params = action.params;
|
|
185
|
-
const browseTypeParam = params?.find((param) => param.name === 'browseType');
|
|
186
|
-
if (browseTypeParam && browseTypeParam.options?.length) {
|
|
187
|
-
const options = browseTypeParam.options;
|
|
188
|
-
const assignedtomeOption = options.find(x => x.value === 'assignedtome');
|
|
189
|
-
if (assignedtomeOption) {
|
|
190
|
-
browseTypeParam.options = [
|
|
191
|
-
...options.filter(x => x !== assignedtomeOption),
|
|
192
|
-
{
|
|
193
|
-
...assignedtomeOption,
|
|
194
|
-
value: 'assigntome',
|
|
195
|
-
}
|
|
196
|
-
];
|
|
197
|
-
}
|
|
198
|
-
if (!browseTypeParam.options.some(x => x.value === 'resolvedbyme')) {
|
|
199
|
-
browseTypeParam.options = [
|
|
200
|
-
...browseTypeParam.options,
|
|
201
|
-
{
|
|
202
|
-
value: 'resolvedbyme',
|
|
203
|
-
label: '由我解决',
|
|
204
|
-
}
|
|
205
|
-
];
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
return action;
|
|
209
|
-
});
|
|
210
146
|
// 获取文档详情时支持将文档原始 JSON 内容转换为 Markdown
|
|
211
147
|
extendModuleAction('doc', 'get', (action) => {
|
|
212
148
|
const oldGetter = action.resultGetter;
|
|
@@ -239,4 +175,38 @@ export function applyBuiltinOverrides() {
|
|
|
239
175
|
};
|
|
240
176
|
return action;
|
|
241
177
|
});
|
|
178
|
+
// 定义获取需求层级操作
|
|
179
|
+
defineModuleActions('story', {
|
|
180
|
+
name: 'getGrades',
|
|
181
|
+
display: '获取需求层级选项',
|
|
182
|
+
type: 'list',
|
|
183
|
+
method: 'get',
|
|
184
|
+
path: '/storygrades',
|
|
185
|
+
resultType: 'list',
|
|
186
|
+
resultGetter: 'grades',
|
|
187
|
+
});
|
|
188
|
+
// 需求创建时支持设置需求层级
|
|
189
|
+
extendModuleAction('story', 'create', (action) => {
|
|
190
|
+
const properties = action.requestBody.schema?.properties;
|
|
191
|
+
if (properties && !properties.grade) {
|
|
192
|
+
properties.grade = {
|
|
193
|
+
type: 'integer',
|
|
194
|
+
description: '需求层级,可用的需求层级可以通过 story-getGrades 操作获取',
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
return action;
|
|
198
|
+
});
|
|
199
|
+
// 创建和修改任务时,任务类型字段
|
|
200
|
+
['create', 'update'].forEach((actionName) => {
|
|
201
|
+
extendModuleAction('task', actionName, (action) => {
|
|
202
|
+
const properties = action.requestBody.schema?.properties;
|
|
203
|
+
if (properties && !properties.type) {
|
|
204
|
+
properties.type = {
|
|
205
|
+
type: 'string',
|
|
206
|
+
description: '任务类型(枚举:design 设计 | devel 开发 | request 需求 | test 测试 | study 研究 | discuss 讨论 | ui 界面 | affair 事务 | misc 其他)',
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
return action;
|
|
210
|
+
});
|
|
211
|
+
});
|
|
242
212
|
}
|
package/dist/modules/query.d.ts
CHANGED
|
@@ -15,8 +15,6 @@ export declare function getModule(moduleName: string): ModuleDefinition | undefi
|
|
|
15
15
|
* 解析顺序:
|
|
16
16
|
* 1. `actionName === 'ls'` 时映射为 `list`(仅作为别名,不会修改注册表)。
|
|
17
17
|
* 2. 在该模块的动作中按名称大小写不敏感匹配。
|
|
18
|
-
* 3. 当请求的动作不是基础 CRUD(`list`/`get`/`create`/`update`/`delete`)时,
|
|
19
|
-
* 额外允许命中 `type === 'action'` 的自定义动作(即使名字不在基础 CRUD 中)。
|
|
20
18
|
*
|
|
21
19
|
* 返回值同样是已深冻结的引用,请勿尝试修改。
|
|
22
20
|
*
|
package/dist/modules/query.js
CHANGED
|
@@ -18,8 +18,6 @@ export function getModule(moduleName) {
|
|
|
18
18
|
* 解析顺序:
|
|
19
19
|
* 1. `actionName === 'ls'` 时映射为 `list`(仅作为别名,不会修改注册表)。
|
|
20
20
|
* 2. 在该模块的动作中按名称大小写不敏感匹配。
|
|
21
|
-
* 3. 当请求的动作不是基础 CRUD(`list`/`get`/`create`/`update`/`delete`)时,
|
|
22
|
-
* 额外允许命中 `type === 'action'` 的自定义动作(即使名字不在基础 CRUD 中)。
|
|
23
21
|
*
|
|
24
22
|
* 返回值同样是已深冻结的引用,请勿尝试修改。
|
|
25
23
|
*
|
|
@@ -32,16 +30,7 @@ export function getModuleAction(moduleName, actionName) {
|
|
|
32
30
|
if (!module)
|
|
33
31
|
return undefined;
|
|
34
32
|
const normalized = actionName === 'ls' ? 'list' : actionName;
|
|
35
|
-
|
|
36
|
-
if (direct)
|
|
37
|
-
return direct;
|
|
38
|
-
const crud = new Set(['list', 'get', 'create', 'update', 'delete']);
|
|
39
|
-
if (!crud.has(normalized)) {
|
|
40
|
-
const custom = module.actions.find((action) => action.type === 'action' && String(action.name).toLowerCase() === normalized.toLowerCase());
|
|
41
|
-
if (custom)
|
|
42
|
-
return custom;
|
|
43
|
-
}
|
|
44
|
-
return undefined;
|
|
33
|
+
return module.actions.find((action) => String(action.name).toLowerCase() === normalized.toLowerCase());
|
|
45
34
|
}
|
|
46
35
|
/**
|
|
47
36
|
* 获取指定模块下的某个动作的参数。
|
|
@@ -82,12 +71,13 @@ export function getModuleActionParams(moduleName, actionName, options) {
|
|
|
82
71
|
if (schema.type === 'object') {
|
|
83
72
|
const requiredSet = new Set(schema.required ? schema.required.map(x => x.toLowerCase()) : []);
|
|
84
73
|
Object.entries(schema.properties).forEach(([name, property]) => {
|
|
74
|
+
const propertyType = property.type;
|
|
85
75
|
params.push({
|
|
76
|
+
...property,
|
|
86
77
|
name,
|
|
87
78
|
role: 'body',
|
|
88
79
|
required: property.required ?? requiredSet.has(name.toLowerCase()),
|
|
89
|
-
type:
|
|
90
|
-
...property,
|
|
80
|
+
type: propertyType === 'integer' ? 'number' : propertyType ?? 'string',
|
|
91
81
|
});
|
|
92
82
|
});
|
|
93
83
|
}
|
|
@@ -128,5 +118,5 @@ export function isModuleName(moduleName) {
|
|
|
128
118
|
* @returns 对象属性。
|
|
129
119
|
*/
|
|
130
120
|
export function getObjectProps(objectType) {
|
|
131
|
-
return objectProps[objectType];
|
|
121
|
+
return objectProps[objectType] ?? {};
|
|
132
122
|
}
|