zentao-api 0.7.2 → 0.8.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/dist/browser/zentao-api.global.js +17 -17
- package/dist/modules/generated.d.ts +13113 -5402
- package/dist/modules/generated.js +6744 -1377
- package/dist/modules/override.js +121 -196
- package/dist/version.js +2 -2
- package/package.json +1 -1
package/dist/modules/override.js
CHANGED
|
@@ -23,6 +23,15 @@ const requestJSON = async ({ request: command, body, bodyType, client, timeout,
|
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
25
|
};
|
|
26
|
+
/** 代码库接口只有 status=success 才成功,表单校验还可能返回 result=fail。 */
|
|
27
|
+
const requestCoderJSON = async (info) => {
|
|
28
|
+
const response = await requestJSON(info);
|
|
29
|
+
if (info.options.raw || (isRecord(response) && response.status === 'success' && response.result !== 'fail'))
|
|
30
|
+
return response;
|
|
31
|
+
return isRecord(response)
|
|
32
|
+
? { ...response, status: 'fail' }
|
|
33
|
+
: { status: 'fail', message: 'Invalid coder API response.', response };
|
|
34
|
+
};
|
|
26
35
|
/**
|
|
27
36
|
* 内置覆盖 / 扩展定义。
|
|
28
37
|
*
|
|
@@ -85,252 +94,168 @@ const requestJSON = async ({ request: command, body, bodyType, client, timeout,
|
|
|
85
94
|
* @internal
|
|
86
95
|
*/
|
|
87
96
|
export function applyBuiltinOverrides() {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
method: 'post',
|
|
99
|
-
path: '/db/query',
|
|
100
|
-
resultType: 'list',
|
|
101
|
-
resultGetter: 'rows',
|
|
102
|
-
pagerGetter: { pageID: 'page', recPerPage: 'limit', recTotal: 'total' },
|
|
103
|
-
request: requestJSON,
|
|
104
|
-
requestBody: {
|
|
105
|
-
required: true,
|
|
106
|
-
schema: {
|
|
107
|
-
type: 'object',
|
|
108
|
-
required: ['sql'],
|
|
109
|
-
properties: {
|
|
110
|
-
sql: { type: 'string', description: 'SQL 查询语句' },
|
|
111
|
-
page: { type: 'integer', description: '页码,默认 1' },
|
|
112
|
-
limit: { type: 'integer', description: '每页记录数,默认 100' },
|
|
113
|
-
},
|
|
114
|
-
},
|
|
115
|
-
example: { sql: 'select * from zt_config', page: 4, limit: 3 },
|
|
116
|
-
},
|
|
117
|
-
},
|
|
118
|
-
{
|
|
119
|
-
name: 'tables',
|
|
120
|
-
minVersion: ['22.7', 'biz13.7', 'max8.7', 'ipd5.7'],
|
|
121
|
-
display: '获取数据库表列表',
|
|
122
|
-
type: 'list',
|
|
123
|
-
method: 'get',
|
|
124
|
-
path: '/db/tables',
|
|
125
|
-
resultType: 'list',
|
|
126
|
-
resultGetter: 'tables',
|
|
127
|
-
request: requestJSON,
|
|
128
|
-
},
|
|
129
|
-
{
|
|
130
|
-
name: 'table',
|
|
131
|
-
minVersion: ['22.7', 'biz13.7', 'max8.7', 'ipd5.7'],
|
|
132
|
-
display: '获取数据库表结构',
|
|
133
|
-
description: 'meta 返回表信息、主键和列定义;sql 返回包含表信息、dialect 和建表 SQL 的对象。',
|
|
134
|
-
type: 'get',
|
|
135
|
-
method: 'get',
|
|
136
|
-
path: '/db/tables/{table}',
|
|
137
|
-
pathParams: { table: '数据库表名,例如 zt_config' },
|
|
138
|
-
params: [{
|
|
139
|
-
name: 'type',
|
|
140
|
-
type: 'string',
|
|
141
|
-
description: '表结构返回格式',
|
|
142
|
-
defaultValue: 'meta',
|
|
143
|
-
options: [{ value: 'meta', label: '元数据' }, { value: 'sql', label: '建表 SQL' }],
|
|
144
|
-
}],
|
|
145
|
-
resultType: 'object',
|
|
146
|
-
resultGetter: data => isRecord(data) ? data.table ?? data : data,
|
|
147
|
-
request: requestJSON,
|
|
148
|
-
},
|
|
149
|
-
],
|
|
97
|
+
// 已纳入 OpenAPI 的接口仅保留 JSON 校验及兼容响应处理。
|
|
98
|
+
for (const [moduleName, actionName] of [
|
|
99
|
+
['db', 'query'], ['db', 'tables'], ['db', 'table'],
|
|
100
|
+
['knowledgelib', 'list'], ['knowledge', 'list'],
|
|
101
|
+
['knowledge', 'embeddingsSearch'], ['knowledge', 'search'], ['knowledge', 'get'],
|
|
102
|
+
]) {
|
|
103
|
+
extendModuleAction(moduleName, actionName, { request: requestJSON });
|
|
104
|
+
}
|
|
105
|
+
extendModuleAction('db', 'table', {
|
|
106
|
+
resultGetter: data => isRecord(data) ? data.table ?? data : data,
|
|
150
107
|
});
|
|
151
|
-
//
|
|
152
|
-
const
|
|
153
|
-
const knowledgeType = {
|
|
154
|
-
type: 'string',
|
|
155
|
-
description: '知识类型,省略或空字符串表示不限;text/file 不可与非空 objectType 同时使用。',
|
|
156
|
-
options: [
|
|
157
|
-
{ value: 'object', label: '对象知识' },
|
|
158
|
-
{ value: 'text', label: '文本知识' },
|
|
159
|
-
{ value: 'file', label: '文件知识' },
|
|
160
|
-
],
|
|
161
|
-
};
|
|
162
|
-
const knowledgeObjectType = {
|
|
163
|
-
type: 'string',
|
|
164
|
-
description: '来源对象类型;单独指定时按 type=object 筛选,每次只接受一个编码。',
|
|
165
|
-
options: [
|
|
166
|
-
{ value: 'story', label: '需求' },
|
|
167
|
-
{ value: 'task', label: '任务' },
|
|
168
|
-
{ value: 'case', label: '测试用例' },
|
|
169
|
-
{ value: 'bug', label: 'Bug' },
|
|
170
|
-
{ value: 'plan', label: '产品计划' },
|
|
171
|
-
{ value: 'release', label: '发布' },
|
|
172
|
-
{ value: 'feedback', label: '反馈' },
|
|
173
|
-
{ value: 'ticket', label: '工单' },
|
|
174
|
-
{ value: 'doc', label: '文档(含接口文档)' },
|
|
175
|
-
{ value: 'issue', label: '问题' },
|
|
176
|
-
{ value: 'risk', label: '风险' },
|
|
177
|
-
{ value: 'opportunity', label: '机会' },
|
|
178
|
-
{ value: 'practice', label: '最佳实践' },
|
|
179
|
-
{ value: 'component', label: '组件' },
|
|
180
|
-
],
|
|
181
|
-
};
|
|
108
|
+
// 代码库接口尚未纳入 OpenAPI,需部署对应 API 2.0 实现。
|
|
109
|
+
const coderMinVersion = ['22.7', 'biz13.7', 'max8.7', 'ipd5.7'];
|
|
182
110
|
defineModules([
|
|
183
111
|
{
|
|
184
|
-
name: '
|
|
185
|
-
display: '
|
|
186
|
-
description: '
|
|
112
|
+
name: 'space',
|
|
113
|
+
display: '代码库空间',
|
|
114
|
+
description: '需部署代码库 API 2.0 实现,仅返回当前用户可访问的未删除空间。',
|
|
187
115
|
actions: [],
|
|
188
116
|
},
|
|
189
117
|
{
|
|
190
|
-
name: '
|
|
191
|
-
display: '
|
|
192
|
-
description: '
|
|
118
|
+
name: 'repo',
|
|
119
|
+
display: '代码库',
|
|
120
|
+
description: '需部署代码库 API 2.0 实现,支持查询空间代码库和创建 GitFox 代码库。',
|
|
193
121
|
actions: [],
|
|
194
122
|
},
|
|
195
123
|
]);
|
|
196
|
-
defineModuleActions('
|
|
124
|
+
defineModuleActions('space', {
|
|
197
125
|
name: 'list',
|
|
198
|
-
minVersion:
|
|
199
|
-
display: '
|
|
126
|
+
minVersion: coderMinVersion,
|
|
127
|
+
display: '获取代码库空间列表',
|
|
128
|
+
description: '需 space.browse 权限,按空间 ID 降序排列;先按当前用户权限过滤,再分页。',
|
|
200
129
|
type: 'list',
|
|
201
130
|
method: 'get',
|
|
202
|
-
path: '/
|
|
131
|
+
path: '/spaces',
|
|
203
132
|
resultType: 'list',
|
|
204
|
-
resultGetter: '
|
|
133
|
+
resultGetter: 'spaces',
|
|
205
134
|
pagerGetter: 'pager',
|
|
206
|
-
request:
|
|
135
|
+
request: requestCoderJSON,
|
|
207
136
|
params: [
|
|
208
|
-
{
|
|
209
|
-
name: 'type',
|
|
210
|
-
type: 'string',
|
|
211
|
-
description: '库类型,省略或空字符串时合并两类可见库',
|
|
212
|
-
options: [{ value: 'my', label: '我的知识库' }, { value: 'team', label: '组织知识库' }],
|
|
213
|
-
},
|
|
214
|
-
{ name: 'keyword', type: 'string', description: '知识库名称或描述关键词,首尾空白会被移除' },
|
|
215
137
|
{ name: 'pageID', type: 'number', defaultValue: 1, description: '页码,从 1 开始的正整数' },
|
|
216
138
|
{ name: 'recPerPage', type: 'number', defaultValue: 20, description: '每页条数,范围 1~100' },
|
|
217
139
|
],
|
|
218
140
|
});
|
|
219
|
-
defineModuleActions('
|
|
141
|
+
defineModuleActions('repo', [
|
|
220
142
|
{
|
|
221
143
|
name: 'list',
|
|
222
|
-
minVersion:
|
|
223
|
-
display: '
|
|
224
|
-
description: '
|
|
144
|
+
minVersion: coderMinVersion,
|
|
145
|
+
display: '获取空间下的代码库列表',
|
|
146
|
+
description: '需 repo.maintain 权限及空间访问权限,独立授权空间另需空间内的 repo.maintain 权限。仅返回未删除、非导入中且当前用户可访问的代码库;url.http、url.ssh 可能缺省,克隆地址保持服务端原值。',
|
|
225
147
|
type: 'list',
|
|
226
148
|
method: 'get',
|
|
227
|
-
path: '/
|
|
228
|
-
pathParams: {
|
|
149
|
+
path: '/spaces/{spaceID}/repos',
|
|
150
|
+
pathParams: { spaceID: '代码库空间 ID,正整数' },
|
|
229
151
|
resultType: 'list',
|
|
230
|
-
resultGetter: '
|
|
152
|
+
resultGetter: 'repos',
|
|
231
153
|
pagerGetter: 'pager',
|
|
232
|
-
request:
|
|
154
|
+
request: requestCoderJSON,
|
|
233
155
|
params: [
|
|
234
|
-
{ name: 'type', ...knowledgeType },
|
|
235
|
-
{ name: 'objectType', ...knowledgeObjectType },
|
|
236
156
|
{ name: 'pageID', type: 'number', defaultValue: 1, description: '页码,从 1 开始的正整数' },
|
|
237
157
|
{ name: 'recPerPage', type: 'number', defaultValue: 20, description: '每页条数,范围 1~100' },
|
|
158
|
+
{
|
|
159
|
+
name: 'orderBy',
|
|
160
|
+
type: 'string',
|
|
161
|
+
defaultValue: 'id_desc',
|
|
162
|
+
description: '排序方式',
|
|
163
|
+
options: [
|
|
164
|
+
{ value: 'id_asc', label: 'ID 升序' },
|
|
165
|
+
{ value: 'id_desc', label: 'ID 降序' },
|
|
166
|
+
{ value: 'name_asc', label: '名称升序' },
|
|
167
|
+
{ value: 'name_desc', label: '名称降序' },
|
|
168
|
+
],
|
|
169
|
+
},
|
|
238
170
|
],
|
|
239
171
|
},
|
|
240
172
|
{
|
|
241
|
-
name: '
|
|
242
|
-
minVersion:
|
|
243
|
-
display: '
|
|
244
|
-
description: '
|
|
245
|
-
type: '
|
|
173
|
+
name: 'create',
|
|
174
|
+
minVersion: coderMinVersion,
|
|
175
|
+
display: '创建代码库',
|
|
176
|
+
description: '需配置 GitFox,具备 repo.createRepo 全局权限、空间及关联产品访问权限;私有空间或独立授权空间另需空间内的 repo.create 权限,独立授权空间还需 repo.createRepo 权限。以当前 Token 用户创建,默认 main 分支并初始化 README;返回 id,不返回克隆地址。超时或后续步骤失败时远端代码库可能已创建,重试前应查询目标空间核对。',
|
|
177
|
+
type: 'create',
|
|
246
178
|
method: 'post',
|
|
247
|
-
path: '/
|
|
248
|
-
resultType: '
|
|
249
|
-
|
|
250
|
-
request: requestJSON,
|
|
179
|
+
path: '/repos',
|
|
180
|
+
resultType: 'object',
|
|
181
|
+
request: requestCoderJSON,
|
|
251
182
|
requestBody: {
|
|
252
183
|
required: true,
|
|
253
184
|
mediaType: 'application/json',
|
|
254
185
|
schema: {
|
|
255
186
|
type: 'object',
|
|
256
|
-
required: ['
|
|
257
|
-
example: {
|
|
187
|
+
required: ['space', 'product', 'name'],
|
|
188
|
+
example: { space: 10, product: [12], name: 'demo' },
|
|
258
189
|
properties: {
|
|
259
|
-
|
|
260
|
-
|
|
190
|
+
space: { type: 'integer', minimum: 1, description: '代码库空间 ID,使用 JSON 数字;字段名为 space' },
|
|
191
|
+
product: {
|
|
261
192
|
type: 'array',
|
|
262
193
|
minItems: 1,
|
|
263
194
|
items: { type: 'integer', minimum: 1 },
|
|
264
|
-
description: '
|
|
195
|
+
description: '关联产品 ID 的非空正整数数组,例如 [12];不接受字符串元素或逗号分隔字符串',
|
|
265
196
|
},
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
},
|
|
272
|
-
},
|
|
273
|
-
},
|
|
274
|
-
{
|
|
275
|
-
name: 'search',
|
|
276
|
-
minVersion: knowledgeMinVersion,
|
|
277
|
-
display: '多知识库关键词搜索',
|
|
278
|
-
description: '需 ai.searchknowledgelib 权限,按字面文本匹配 title 或已保存的 content,不依赖向量索引。标题与正文分别匹配,单个关键词不能跨字段拼接。返回完整正文及 contentType,正文为空或 null 时返回空字符串;每条知识只返回一次,按知识 ID 降序分页。',
|
|
279
|
-
type: 'list',
|
|
280
|
-
method: 'post',
|
|
281
|
-
path: '/ai/knowledges/search',
|
|
282
|
-
resultType: 'list',
|
|
283
|
-
resultGetter: 'data',
|
|
284
|
-
pagerGetter: 'pager',
|
|
285
|
-
request: requestJSON,
|
|
286
|
-
requestBody: {
|
|
287
|
-
required: true,
|
|
288
|
-
mediaType: 'application/json',
|
|
289
|
-
schema: {
|
|
290
|
-
type: 'object',
|
|
291
|
-
required: ['keywords', 'libIDs'],
|
|
292
|
-
example: { keywords: ['登录', '超时'], libIDs: [12, 18], matchMode: 'any', pageID: 1, recPerPage: 20 },
|
|
293
|
-
properties: {
|
|
294
|
-
keywords: {
|
|
295
|
-
type: 'array',
|
|
296
|
-
minItems: 1,
|
|
297
|
-
items: { type: 'string', minLength: 1 },
|
|
298
|
-
description: '非空关键词数组,每项去除首尾空白后为 1~200 个 Unicode 字符,去重后最多 20 项;%、_ 和反斜杠按普通字符匹配',
|
|
299
|
-
},
|
|
300
|
-
libIDs: {
|
|
301
|
-
type: 'array',
|
|
302
|
-
minItems: 1,
|
|
303
|
-
items: { type: 'integer', minimum: 1 },
|
|
304
|
-
description: '本地知识库 ID 的非空正整数数组,例如 [12,18];不接受字符串元素,重复 ID 自动去重',
|
|
197
|
+
name: {
|
|
198
|
+
type: 'string',
|
|
199
|
+
minLength: 1,
|
|
200
|
+
pattern: '^[A-Za-z_][A-Za-z0-9_.-]*$',
|
|
201
|
+
description: '去除首尾空白后,以英文字母或下划线开头,后续仅允许英文字母、数字、下划线、连字符和点',
|
|
305
202
|
},
|
|
306
|
-
|
|
203
|
+
desc: { type: 'string', defaultValue: '', description: '代码库描述;可选字段使用默认值时应省略,不传 null' },
|
|
204
|
+
acl: {
|
|
307
205
|
type: 'string',
|
|
308
|
-
defaultValue: '
|
|
309
|
-
|
|
310
|
-
|
|
206
|
+
defaultValue: 'open',
|
|
207
|
+
options: [{ value: 'open', label: '公开' }, { value: 'private', label: '私有' }],
|
|
208
|
+
description: '访问权限,private 时 members 必须非空',
|
|
209
|
+
},
|
|
210
|
+
members: {
|
|
211
|
+
type: 'array',
|
|
212
|
+
defaultValue: [],
|
|
213
|
+
items: { type: 'string', minLength: 1 },
|
|
214
|
+
description: '成员账号数组,账号须存在、未删除且未关闭;acl=private 时必填且非空,服务端自动加入当前创建者',
|
|
311
215
|
},
|
|
312
|
-
type: knowledgeType,
|
|
313
|
-
objectType: knowledgeObjectType,
|
|
314
|
-
pageID: { type: 'integer', minimum: 1, defaultValue: 1, description: '页码,从 1 开始的正整数' },
|
|
315
|
-
recPerPage: { type: 'integer', minimum: 1, maximum: 100, defaultValue: 20, description: '每页条数,范围 1~100' },
|
|
316
216
|
},
|
|
317
217
|
},
|
|
318
218
|
},
|
|
319
219
|
},
|
|
320
|
-
{
|
|
321
|
-
name: 'get',
|
|
322
|
-
minVersion: knowledgeMinVersion,
|
|
323
|
-
display: '获取知识详细内容',
|
|
324
|
-
description: '返回已保存的完整正文及来源信息,不触发文件提取、知识同步或索引更新。按 contentType 解释正文,尚未保存正文时 content 可为空。',
|
|
325
|
-
type: 'get',
|
|
326
|
-
method: 'get',
|
|
327
|
-
path: '/ai/knowledges/{knowledgeID}',
|
|
328
|
-
pathParams: { knowledgeID: '本地知识条目 ID,正整数;不可使用 chunkID 或来源对象 objectID' },
|
|
329
|
-
resultType: 'object',
|
|
330
|
-
resultGetter: 'data',
|
|
331
|
-
request: requestJSON,
|
|
332
|
-
},
|
|
333
220
|
]);
|
|
221
|
+
defineModuleActions('product', {
|
|
222
|
+
name: 'repos',
|
|
223
|
+
minVersion: coderMinVersion,
|
|
224
|
+
display: '获取产品关联的代码库列表',
|
|
225
|
+
description: '需部署代码库 API 2.0 实现,具备 repo.browse 权限及产品访问权限。仅返回未删除、非导入中且当前用户可访问的代码库,不分页、不保证排序;url.http、url.ssh 可能缺省。产品不存在、已删除或不可访问时为业务失败。',
|
|
226
|
+
type: 'list',
|
|
227
|
+
method: 'get',
|
|
228
|
+
path: '/products/{productID}/repos',
|
|
229
|
+
pathParams: { productID: '产品 ID,正整数' },
|
|
230
|
+
resultType: 'list',
|
|
231
|
+
resultGetter: 'repos',
|
|
232
|
+
request: requestCoderJSON,
|
|
233
|
+
});
|
|
234
|
+
defineModuleActions('my', {
|
|
235
|
+
name: 'createSSH',
|
|
236
|
+
minVersion: coderMinVersion,
|
|
237
|
+
display: '添加我的 SSH 公钥',
|
|
238
|
+
description: '需部署代码库 API 2.0 实现并配置 GitFox,将公钥添加到当前 Token 用户的 GitFox 账号,account 不能改变归属。成功仅返回 message,不返回密钥 ID;公钥错误保留在 rawMessage.publicKey 中。',
|
|
239
|
+
type: 'action',
|
|
240
|
+
method: 'post',
|
|
241
|
+
path: '/my/sshkeys',
|
|
242
|
+
resultType: 'text',
|
|
243
|
+
resultGetter: 'message',
|
|
244
|
+
request: requestCoderJSON,
|
|
245
|
+
requestBody: {
|
|
246
|
+
required: true,
|
|
247
|
+
mediaType: 'application/json',
|
|
248
|
+
schema: {
|
|
249
|
+
type: 'object',
|
|
250
|
+
required: ['name', 'publicKey'],
|
|
251
|
+
example: { name: 'coder', publicKey: 'ssh-ed25519 <替换为完整公钥内容> coder' },
|
|
252
|
+
properties: {
|
|
253
|
+
name: { type: 'string', minLength: 1, pattern: '^[A-Za-z0-9_.$-]+$', description: '密钥名称,去除首尾空白后仅允许英文字母、数字、连字符、下划线、点和 $' },
|
|
254
|
+
publicKey: { type: 'string', minLength: 1, description: '完整单行 SSH 公钥文本,去除首尾空白;支持 ssh-rsa、ecdsa-sha2-nistp256/384/521、ssh-ed25519、sk-ecdsa-sha2-nistp256@openssh.com、sk-ssh-ed25519@openssh.com 前缀,完整性及重复检查由 GitFox 处理' },
|
|
255
|
+
},
|
|
256
|
+
},
|
|
257
|
+
},
|
|
258
|
+
});
|
|
334
259
|
for (const [moduleName, actionName] of [['product', 'create'], ['product', 'update'], ['feedback', 'close']]) {
|
|
335
260
|
extendModuleAction(moduleName, actionName, { request: requestJSON });
|
|
336
261
|
}
|
package/dist/version.js
CHANGED