zentao-api 0.8.3 → 0.8.5
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 +22 -1
- package/dist/browser/zentao-api.global.js +17 -17
- package/dist/client/index.d.ts +4 -3
- package/dist/client/index.js +31 -1
- package/dist/modules/generated.d.ts +34 -0
- package/dist/modules/generated.js +26 -2
- package/dist/modules/override.js +13 -5
- package/dist/request/index.js +2 -0
- package/dist/types/client.d.ts +15 -1
- package/dist/types/module.d.ts +3 -1
- package/dist/types/options.d.ts +5 -0
- package/dist/version.js +2 -2
- package/package.json +1 -1
package/dist/client/index.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ export declare class ZentaoClient {
|
|
|
20
20
|
private token?;
|
|
21
21
|
private readonly timeout?;
|
|
22
22
|
private readonly insecure?;
|
|
23
|
+
private readonly actionAssistant?;
|
|
23
24
|
private profileKey?;
|
|
24
25
|
private serverConfig?;
|
|
25
26
|
private serverConfigFetchedAt?;
|
|
@@ -56,8 +57,8 @@ export declare class ZentaoClient {
|
|
|
56
57
|
* @returns 解析后的响应体;当响应为空字符串时返回 `undefined`。
|
|
57
58
|
* @throws {ZentaoError} 可能抛出 `E_HTTP_ERROR`(非 2xx 状态)、`E_NETWORK_ERROR`(底层 fetch 失败)、
|
|
58
59
|
* `E_TIMEOUT`(超过 `timeout`)、`E_ABORTED`(外部信号取消)或
|
|
59
|
-
* `E_INSECURE_BROWSER`(浏览器中开启了 `insecure`);传入 `ReadableStream`
|
|
60
|
-
* `E_INVALID_PARAM`。
|
|
60
|
+
* `E_INSECURE_BROWSER`(浏览器中开启了 `insecure`);传入 `ReadableStream` 请求体或无效的
|
|
61
|
+
* `actionAssistant` 对象时会抛 `E_INVALID_PARAM`。
|
|
61
62
|
*/
|
|
62
63
|
request(path: string, options: ClientRequestOptions & {
|
|
63
64
|
responseType: 'response';
|
|
@@ -83,7 +84,7 @@ export declare class ZentaoClient {
|
|
|
83
84
|
/**
|
|
84
85
|
* 匿名获取禅道站点 `/?mode=getconfig` 配置,只需站点地址,无需登录或 profile。
|
|
85
86
|
*
|
|
86
|
-
* 不发送 API Token
|
|
87
|
+
* 不发送 API Token 或操作辅助工具标记,浏览器请求显式省略 Cookie 等凭据,不受 API Token 过期影响。
|
|
87
88
|
*
|
|
88
89
|
* 默认复用不超过 24 小时的缓存;缺失、过期或时间异常时重新获取。
|
|
89
90
|
* `forceRefresh: true` 忽略缓存。同一客户端的并发刷新共用首次调用的传输选项;
|
package/dist/client/index.js
CHANGED
|
@@ -6,6 +6,22 @@ import { getProfileOrThrow, saveLoginProfile, switchProfile, updateProfileServer
|
|
|
6
6
|
import { isRecord, normalizeSiteUrl } from '../utils/index.js';
|
|
7
7
|
const DEFAULT_TIMEOUT = 10000;
|
|
8
8
|
const CONFIG_MAX_AGE = 24 * 60 * 60 * 1000;
|
|
9
|
+
const ACTION_ASSISTANT_HEADER = 'ZenTao-Action-Assistant';
|
|
10
|
+
function serializeActionAssistant(value) {
|
|
11
|
+
if (typeof value === 'string')
|
|
12
|
+
return value;
|
|
13
|
+
const invalidField = /[<>\u0000-\u001f\u007f-\u009f]/;
|
|
14
|
+
if (!isRecord(value) || typeof value.name !== 'string' || !value.name.trim() || invalidField.test(value.name)
|
|
15
|
+
|| (value.info !== undefined && (typeof value.info !== 'string' || invalidField.test(value.info)))) {
|
|
16
|
+
throw new ZentaoError('E_INVALID_PARAM', {
|
|
17
|
+
param: 'actionAssistant',
|
|
18
|
+
value: 'Expected a non-empty name and optional info without angle brackets or control characters.',
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
const name = value.name.trim();
|
|
22
|
+
const info = value.info?.trim();
|
|
23
|
+
return info ? `${name} <${info}>` : name;
|
|
24
|
+
}
|
|
9
25
|
function isServerConfig(value) {
|
|
10
26
|
return isRecord(value) && typeof value.version === 'string' && value.version.trim().length > 0;
|
|
11
27
|
}
|
|
@@ -303,6 +319,7 @@ export class ZentaoClient {
|
|
|
303
319
|
token;
|
|
304
320
|
timeout;
|
|
305
321
|
insecure;
|
|
322
|
+
actionAssistant;
|
|
306
323
|
profileKey;
|
|
307
324
|
serverConfig;
|
|
308
325
|
serverConfigFetchedAt;
|
|
@@ -314,6 +331,7 @@ export class ZentaoClient {
|
|
|
314
331
|
this.token = options.token;
|
|
315
332
|
this.timeout = options.timeout;
|
|
316
333
|
this.insecure = options.insecure;
|
|
334
|
+
this.actionAssistant = options.actionAssistant;
|
|
317
335
|
}
|
|
318
336
|
async request(path, options = {}) {
|
|
319
337
|
return this.fetch(buildUrl(this.baseUrl, path, options.query), options, this.token);
|
|
@@ -335,6 +353,17 @@ export class ZentaoClient {
|
|
|
335
353
|
const insecure = options.insecure ?? globals.insecure ?? this.insecure;
|
|
336
354
|
assertInsecureSupported(insecure);
|
|
337
355
|
const headers = new Headers(options.headers);
|
|
356
|
+
const actionAssistant = options.actionAssistant !== undefined
|
|
357
|
+
? options.actionAssistant
|
|
358
|
+
: headers.get(ACTION_ASSISTANT_HEADER)
|
|
359
|
+
?? (globals.actionAssistant !== undefined ? globals.actionAssistant : this.actionAssistant);
|
|
360
|
+
if (actionAssistant !== undefined) {
|
|
361
|
+
const value = serializeActionAssistant(actionAssistant);
|
|
362
|
+
if (value === '')
|
|
363
|
+
headers.delete(ACTION_ASSISTANT_HEADER);
|
|
364
|
+
else
|
|
365
|
+
headers.set(ACTION_ASSISTANT_HEADER, value);
|
|
366
|
+
}
|
|
338
367
|
if (token) {
|
|
339
368
|
headers.set('Token', token);
|
|
340
369
|
}
|
|
@@ -390,7 +419,7 @@ export class ZentaoClient {
|
|
|
390
419
|
/**
|
|
391
420
|
* 匿名获取禅道站点 `/?mode=getconfig` 配置,只需站点地址,无需登录或 profile。
|
|
392
421
|
*
|
|
393
|
-
* 不发送 API Token
|
|
422
|
+
* 不发送 API Token 或操作辅助工具标记,浏览器请求显式省略 Cookie 等凭据,不受 API Token 过期影响。
|
|
394
423
|
*
|
|
395
424
|
* 默认复用不超过 24 小时的缓存;缺失、过期或时间异常时重新获取。
|
|
396
425
|
* `forceRefresh: true` 忽略缓存。同一客户端的并发刷新共用首次调用的传输选项;
|
|
@@ -420,6 +449,7 @@ export class ZentaoClient {
|
|
|
420
449
|
}
|
|
421
450
|
const pending = this.fetch(buildUrl(this.siteUrl, '/', { mode: 'getconfig' }), {
|
|
422
451
|
method: 'GET', timeout: options.timeout, insecure: options.insecure, signal: options.signal,
|
|
452
|
+
actionAssistant: '',
|
|
423
453
|
}, undefined, { cache: 'no-store', credentials: 'omit' }).then(async (config) => {
|
|
424
454
|
if (!isServerConfig(config))
|
|
425
455
|
throw new ZentaoError('E_INVALID_ZENTAO_CONFIG');
|
|
@@ -3430,6 +3430,10 @@ export declare const BUILTIN_MODULES: ({
|
|
|
3430
3430
|
type: string;
|
|
3431
3431
|
description: string;
|
|
3432
3432
|
};
|
|
3433
|
+
status: {
|
|
3434
|
+
type: string;
|
|
3435
|
+
description: string;
|
|
3436
|
+
};
|
|
3433
3437
|
reviewer: {
|
|
3434
3438
|
type: string;
|
|
3435
3439
|
items: {
|
|
@@ -3556,6 +3560,7 @@ export declare const BUILTIN_MODULES: ({
|
|
|
3556
3560
|
productID?: undefined;
|
|
3557
3561
|
spec?: undefined;
|
|
3558
3562
|
verify?: undefined;
|
|
3563
|
+
status?: undefined;
|
|
3559
3564
|
reviewer?: undefined;
|
|
3560
3565
|
project?: undefined;
|
|
3561
3566
|
execution?: undefined;
|
|
@@ -3627,6 +3632,7 @@ export declare const BUILTIN_MODULES: ({
|
|
|
3627
3632
|
source?: undefined;
|
|
3628
3633
|
verify?: undefined;
|
|
3629
3634
|
assignedTo?: undefined;
|
|
3635
|
+
status?: undefined;
|
|
3630
3636
|
reviewer?: undefined;
|
|
3631
3637
|
project?: undefined;
|
|
3632
3638
|
execution?: undefined;
|
|
@@ -3734,6 +3740,7 @@ export declare const BUILTIN_MODULES: ({
|
|
|
3734
3740
|
category?: undefined;
|
|
3735
3741
|
source?: undefined;
|
|
3736
3742
|
verify?: undefined;
|
|
3743
|
+
status?: undefined;
|
|
3737
3744
|
reviewer?: undefined;
|
|
3738
3745
|
project?: undefined;
|
|
3739
3746
|
execution?: undefined;
|
|
@@ -3789,6 +3796,10 @@ export declare const BUILTIN_MODULES: ({
|
|
|
3789
3796
|
type: string;
|
|
3790
3797
|
description: string;
|
|
3791
3798
|
};
|
|
3799
|
+
status: {
|
|
3800
|
+
type: string;
|
|
3801
|
+
description: string;
|
|
3802
|
+
};
|
|
3792
3803
|
reviewer: {
|
|
3793
3804
|
type: string;
|
|
3794
3805
|
items: {
|
|
@@ -3882,6 +3893,7 @@ export declare const BUILTIN_MODULES: ({
|
|
|
3882
3893
|
source?: undefined;
|
|
3883
3894
|
verify?: undefined;
|
|
3884
3895
|
assignedTo?: undefined;
|
|
3896
|
+
status?: undefined;
|
|
3885
3897
|
reviewer?: undefined;
|
|
3886
3898
|
project?: undefined;
|
|
3887
3899
|
execution?: undefined;
|
|
@@ -4038,6 +4050,10 @@ export declare const BUILTIN_MODULES: ({
|
|
|
4038
4050
|
type: string;
|
|
4039
4051
|
description: string;
|
|
4040
4052
|
};
|
|
4053
|
+
status: {
|
|
4054
|
+
type: string;
|
|
4055
|
+
description: string;
|
|
4056
|
+
};
|
|
4041
4057
|
reviewer: {
|
|
4042
4058
|
type: string;
|
|
4043
4059
|
items: {
|
|
@@ -4144,6 +4160,7 @@ export declare const BUILTIN_MODULES: ({
|
|
|
4144
4160
|
productID?: undefined;
|
|
4145
4161
|
spec?: undefined;
|
|
4146
4162
|
verify?: undefined;
|
|
4163
|
+
status?: undefined;
|
|
4147
4164
|
reviewer?: undefined;
|
|
4148
4165
|
comment?: undefined;
|
|
4149
4166
|
closedReason?: undefined;
|
|
@@ -4221,6 +4238,7 @@ export declare const BUILTIN_MODULES: ({
|
|
|
4221
4238
|
category?: undefined;
|
|
4222
4239
|
source?: undefined;
|
|
4223
4240
|
verify?: undefined;
|
|
4241
|
+
status?: undefined;
|
|
4224
4242
|
reviewer?: undefined;
|
|
4225
4243
|
closedReason?: undefined;
|
|
4226
4244
|
};
|
|
@@ -4267,6 +4285,10 @@ export declare const BUILTIN_MODULES: ({
|
|
|
4267
4285
|
type: string;
|
|
4268
4286
|
description: string;
|
|
4269
4287
|
};
|
|
4288
|
+
status: {
|
|
4289
|
+
type: string;
|
|
4290
|
+
description: string;
|
|
4291
|
+
};
|
|
4270
4292
|
reviewer: {
|
|
4271
4293
|
type: string;
|
|
4272
4294
|
items: {
|
|
@@ -4351,6 +4373,7 @@ export declare const BUILTIN_MODULES: ({
|
|
|
4351
4373
|
source?: undefined;
|
|
4352
4374
|
verify?: undefined;
|
|
4353
4375
|
assignedTo?: undefined;
|
|
4376
|
+
status?: undefined;
|
|
4354
4377
|
reviewer?: undefined;
|
|
4355
4378
|
};
|
|
4356
4379
|
required: string[];
|
|
@@ -4501,6 +4524,10 @@ export declare const BUILTIN_MODULES: ({
|
|
|
4501
4524
|
type: string;
|
|
4502
4525
|
description: string;
|
|
4503
4526
|
};
|
|
4527
|
+
status: {
|
|
4528
|
+
type: string;
|
|
4529
|
+
description: string;
|
|
4530
|
+
};
|
|
4504
4531
|
reviewer: {
|
|
4505
4532
|
type: string;
|
|
4506
4533
|
items: {
|
|
@@ -4607,6 +4634,7 @@ export declare const BUILTIN_MODULES: ({
|
|
|
4607
4634
|
productID?: undefined;
|
|
4608
4635
|
spec?: undefined;
|
|
4609
4636
|
verify?: undefined;
|
|
4637
|
+
status?: undefined;
|
|
4610
4638
|
reviewer?: undefined;
|
|
4611
4639
|
comment?: undefined;
|
|
4612
4640
|
closedReason?: undefined;
|
|
@@ -4684,6 +4712,7 @@ export declare const BUILTIN_MODULES: ({
|
|
|
4684
4712
|
category?: undefined;
|
|
4685
4713
|
source?: undefined;
|
|
4686
4714
|
verify?: undefined;
|
|
4715
|
+
status?: undefined;
|
|
4687
4716
|
reviewer?: undefined;
|
|
4688
4717
|
closedReason?: undefined;
|
|
4689
4718
|
};
|
|
@@ -4738,6 +4767,10 @@ export declare const BUILTIN_MODULES: ({
|
|
|
4738
4767
|
type: string;
|
|
4739
4768
|
description: string;
|
|
4740
4769
|
};
|
|
4770
|
+
status: {
|
|
4771
|
+
type: string;
|
|
4772
|
+
description: string;
|
|
4773
|
+
};
|
|
4741
4774
|
reviewer: {
|
|
4742
4775
|
type: string;
|
|
4743
4776
|
items: {
|
|
@@ -4814,6 +4847,7 @@ export declare const BUILTIN_MODULES: ({
|
|
|
4814
4847
|
source?: undefined;
|
|
4815
4848
|
verify?: undefined;
|
|
4816
4849
|
assignedTo?: undefined;
|
|
4850
|
+
status?: undefined;
|
|
4817
4851
|
reviewer?: undefined;
|
|
4818
4852
|
};
|
|
4819
4853
|
required: string[];
|
|
@@ -2626,6 +2626,10 @@ export const BUILTIN_MODULES = [
|
|
|
2626
2626
|
"type": "string",
|
|
2627
2627
|
"description": "指派给"
|
|
2628
2628
|
},
|
|
2629
|
+
"status": {
|
|
2630
|
+
"type": "string",
|
|
2631
|
+
"description": "无有效评审人时默认 active,可显式指定状态;有有效评审人时固定为 reviewing。"
|
|
2632
|
+
},
|
|
2629
2633
|
"reviewer": {
|
|
2630
2634
|
"type": "array",
|
|
2631
2635
|
"items": {
|
|
@@ -2854,6 +2858,10 @@ export const BUILTIN_MODULES = [
|
|
|
2854
2858
|
"type": "string",
|
|
2855
2859
|
"description": "需求名称"
|
|
2856
2860
|
},
|
|
2861
|
+
"status": {
|
|
2862
|
+
"type": "string",
|
|
2863
|
+
"description": "无有效评审人时默认 active,可显式指定状态;有有效评审人时固定为 reviewing。"
|
|
2864
|
+
},
|
|
2857
2865
|
"reviewer": {
|
|
2858
2866
|
"type": "array",
|
|
2859
2867
|
"items": {
|
|
@@ -3062,6 +3070,10 @@ export const BUILTIN_MODULES = [
|
|
|
3062
3070
|
"type": "string",
|
|
3063
3071
|
"description": "指派给"
|
|
3064
3072
|
},
|
|
3073
|
+
"status": {
|
|
3074
|
+
"type": "string",
|
|
3075
|
+
"description": "无有效评审人时默认 active,可显式指定状态;有有效评审人时固定为 reviewing。"
|
|
3076
|
+
},
|
|
3065
3077
|
"reviewer": {
|
|
3066
3078
|
"type": "array",
|
|
3067
3079
|
"items": {
|
|
@@ -3235,6 +3247,10 @@ export const BUILTIN_MODULES = [
|
|
|
3235
3247
|
"type": "string",
|
|
3236
3248
|
"description": "需求名称"
|
|
3237
3249
|
},
|
|
3250
|
+
"status": {
|
|
3251
|
+
"type": "string",
|
|
3252
|
+
"description": "无有效评审人时默认 active,可显式指定状态;有有效评审人时固定为 reviewing。"
|
|
3253
|
+
},
|
|
3238
3254
|
"reviewer": {
|
|
3239
3255
|
"type": "array",
|
|
3240
3256
|
"items": {
|
|
@@ -3443,6 +3459,10 @@ export const BUILTIN_MODULES = [
|
|
|
3443
3459
|
"type": "string",
|
|
3444
3460
|
"description": "指派给"
|
|
3445
3461
|
},
|
|
3462
|
+
"status": {
|
|
3463
|
+
"type": "string",
|
|
3464
|
+
"description": "无有效评审人时默认 active,可显式指定状态;有有效评审人时固定为 reviewing。"
|
|
3465
|
+
},
|
|
3446
3466
|
"reviewer": {
|
|
3447
3467
|
"type": "array",
|
|
3448
3468
|
"items": {
|
|
@@ -3623,6 +3643,10 @@ export const BUILTIN_MODULES = [
|
|
|
3623
3643
|
"type": "string",
|
|
3624
3644
|
"description": "验收标准"
|
|
3625
3645
|
},
|
|
3646
|
+
"status": {
|
|
3647
|
+
"type": "string",
|
|
3648
|
+
"description": "无有效评审人时默认 active,可显式指定状态;有有效评审人时固定为 reviewing。"
|
|
3649
|
+
},
|
|
3626
3650
|
"reviewer": {
|
|
3627
3651
|
"type": "array",
|
|
3628
3652
|
"items": {
|
|
@@ -13116,8 +13140,8 @@ export const BUILTIN_MODULES = [
|
|
|
13116
13140
|
name: 'browseType',
|
|
13117
13141
|
required: false,
|
|
13118
13142
|
type: 'string',
|
|
13119
|
-
description: '待处理筛选类型,默认
|
|
13120
|
-
defaultValue: '
|
|
13143
|
+
description: '待处理筛选类型,默认 mychecking,取值不区分大小写',
|
|
13144
|
+
defaultValue: 'mychecking',
|
|
13121
13145
|
options: [
|
|
13122
13146
|
{ value: 'mychecking', label: '待我检查' },
|
|
13123
13147
|
{ value: 'checked', label: '已检查' },
|
package/dist/modules/override.js
CHANGED
|
@@ -5,10 +5,10 @@ import { isRecord } from '../utils/index.js';
|
|
|
5
5
|
import { request } from '../request/index.js';
|
|
6
6
|
import { ZentaoError } from '../misc/errors.js';
|
|
7
7
|
/** 这些内置接口要求 JSON,不能把 HTTP 200 的 PHP/SQL 错误文本视为成功。 */
|
|
8
|
-
const requestJSON = async ({ request: command, body, bodyType, client, timeout, insecure }) => {
|
|
8
|
+
const requestJSON = async ({ request: command, body, bodyType, client, timeout, insecure, actionAssistant }) => {
|
|
9
9
|
const response = await client.request(command.path, {
|
|
10
10
|
method: command.action.method.toUpperCase(),
|
|
11
|
-
query: command.query, body, bodyType, timeout, insecure, responseType: 'response',
|
|
11
|
+
query: command.query, body, bodyType, timeout, insecure, actionAssistant, responseType: 'response',
|
|
12
12
|
});
|
|
13
13
|
const responseText = await response.text();
|
|
14
14
|
try {
|
|
@@ -340,15 +340,23 @@ export function applyBuiltinOverrides() {
|
|
|
340
340
|
return { data, query };
|
|
341
341
|
},
|
|
342
342
|
});
|
|
343
|
+
// 部分服务端从 query 读取 productID;复制已解析的 body 值以保留 data 优先级与类型转换。
|
|
344
|
+
extendModuleAction('bug', 'create', {
|
|
345
|
+
beforeRequest: async ({ data, query }) => {
|
|
346
|
+
if (data?.productID === undefined)
|
|
347
|
+
return {};
|
|
348
|
+
return { query: { ...query, productID: data.productID } };
|
|
349
|
+
},
|
|
350
|
+
});
|
|
343
351
|
// 确认表单会重置缺省字段;仅补齐可写字段,不回传详情中的其他属性。
|
|
344
352
|
extendModuleAction('bug', 'confirm', {
|
|
345
|
-
request: async ({ request: command, body, bodyType, client, timeout, insecure, options }) => {
|
|
353
|
+
request: async ({ request: command, body, bodyType, client, timeout, insecure, actionAssistant, options }) => {
|
|
346
354
|
const data = { ...body };
|
|
347
355
|
const fields = ['status', 'assignedTo', 'type', 'pri', 'deadline', 'mailto'];
|
|
348
356
|
const missing = fields.filter(field => data[field] === undefined);
|
|
349
357
|
if (missing.length) {
|
|
350
358
|
const response = await request('bug/get', { id: command.id }, {
|
|
351
|
-
client, timeout, insecure, throwOnFail: true,
|
|
359
|
+
client, timeout, insecure, actionAssistant, throwOnFail: true,
|
|
352
360
|
forceRefreshConfig: options.forceRefreshConfig,
|
|
353
361
|
skipVersionCheckOnConfigError: options.skipVersionCheckOnConfigError,
|
|
354
362
|
});
|
|
@@ -369,7 +377,7 @@ export function applyBuiltinOverrides() {
|
|
|
369
377
|
if (data.assignedTo === 'closed') {
|
|
370
378
|
throw new ZentaoError('E_INVALID_PARAM', { param: 'assignedTo', value: 'closed' });
|
|
371
379
|
}
|
|
372
|
-
return requestJSON({ request: command, body: data, bodyType, client, timeout, insecure, options });
|
|
380
|
+
return requestJSON({ request: command, body: data, bodyType, client, timeout, insecure, actionAssistant, options });
|
|
373
381
|
},
|
|
374
382
|
});
|
|
375
383
|
// 修改 acl 字段默认值为 open
|
package/dist/request/index.js
CHANGED
|
@@ -67,6 +67,7 @@ async function autoFillUpdateParams(module, action, params, options, version) {
|
|
|
67
67
|
client: options.client,
|
|
68
68
|
timeout: options.timeout,
|
|
69
69
|
insecure: options.insecure,
|
|
70
|
+
actionAssistant: options.actionAssistant,
|
|
70
71
|
throwOnFail: true,
|
|
71
72
|
}, version)).data;
|
|
72
73
|
if (!isRecord(current))
|
|
@@ -241,6 +242,7 @@ async function requestInternal(name, params, options, version) {
|
|
|
241
242
|
...preparedBody,
|
|
242
243
|
timeout: options.timeout ?? globals.timeout,
|
|
243
244
|
insecure: options.insecure ?? globals.insecure,
|
|
245
|
+
actionAssistant: options.actionAssistant !== undefined ? options.actionAssistant : globals.actionAssistant,
|
|
244
246
|
};
|
|
245
247
|
const raw = command.action.request
|
|
246
248
|
? await command.action.request({ request: command, ...requestOptions, client, options })
|
package/dist/types/client.d.ts
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 操作辅助工具标记,对应 `ZenTao-Action-Assistant` 请求头。
|
|
3
|
+
* 字符串直接作为头值;对象去除字段首尾空白后序列化为 `name <info>`,没有详情时只发送名称。
|
|
4
|
+
* 对象名称不能为空,名称和详情不能包含尖括号或控制字符;最终头值仍须符合原生 Headers 的限制。
|
|
5
|
+
* 空字符串表示关闭标记;配置仅运行时有效,不保存到 profile。
|
|
6
|
+
*/
|
|
7
|
+
export type ActionAssistant = string | {
|
|
8
|
+
name: string;
|
|
9
|
+
info?: string;
|
|
10
|
+
};
|
|
1
11
|
/** 从本地 profile 恢复客户端时的选项。 */
|
|
2
12
|
export interface FromProfileOptions {
|
|
3
13
|
/** 是否切换为当前 profile 并更新使用时间,默认 true;false 时恢复过程只读存储。 */
|
|
@@ -9,6 +19,8 @@ export interface ZentaoClientOptions {
|
|
|
9
19
|
baseUrl: string;
|
|
10
20
|
/** 禅道 API Token;未提供时可稍后通过 {@link ZentaoClient.login} 获取并写入实例。 */
|
|
11
21
|
token?: string;
|
|
22
|
+
/** 默认操作辅助工具标记;优先级低于全局和单次请求配置,默认不发送。 */
|
|
23
|
+
actionAssistant?: ActionAssistant;
|
|
12
24
|
/** 默认请求超时时间,单位毫秒。 */
|
|
13
25
|
timeout?: number;
|
|
14
26
|
/** 是否跳过 TLS 证书验证;仅 Node.js 运行时支持,浏览器中会抛错。 */
|
|
@@ -30,8 +42,10 @@ export interface ClientRequestOptions {
|
|
|
30
42
|
bodyType?: ClientRequestBodyType;
|
|
31
43
|
/** 响应体解析方式。默认 `auto`,会优先尝试 JSON,失败后回落为文本;`response` 会让 signal 和 timeout 继续控制响应体。 */
|
|
32
44
|
responseType?: ClientResponseType;
|
|
33
|
-
/** 额外请求头;会与 SDK 自动注入的 `Token` / `Content-Type`
|
|
45
|
+
/** 额外请求头;会与 SDK 自动注入的 `Token` / `Content-Type` 合并,同名助手头优先于全局和客户端默认值。 */
|
|
34
46
|
headers?: HeadersInit;
|
|
47
|
+
/** 本次操作辅助工具标记;优先于 headers 中的同名头、全局和客户端默认值。undefined 表示继承,空字符串表示关闭。 */
|
|
48
|
+
actionAssistant?: ActionAssistant;
|
|
35
49
|
/** URL 查询参数;对象和数组使用 deepObject 风格序列化,`undefined` 值会被跳过。 */
|
|
36
50
|
query?: Record<string, unknown>;
|
|
37
51
|
/** 外部取消信号;会与 SDK 自身的超时控制合并。 */
|
package/dist/types/module.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ZentaoClient } from '../client/index.js';
|
|
2
|
-
import type { ClientRequestBodyType, HttpMethod } from './client.js';
|
|
2
|
+
import type { ActionAssistant, ClientRequestBodyType, HttpMethod } from './client.js';
|
|
3
3
|
import type { RequestOptions, RequestProcessOptions } from './options.js';
|
|
4
4
|
import type { Pager } from './response.js';
|
|
5
5
|
/** 模块动作类型:基础 CRUD 或自定义动作。 */
|
|
@@ -110,6 +110,8 @@ export type ModuleActionRequestCallback = (info: {
|
|
|
110
110
|
timeout?: number;
|
|
111
111
|
/** 本次请求的 TLS 选项,未指定时回落到全局选项。 */
|
|
112
112
|
insecure?: boolean;
|
|
113
|
+
/** 操作辅助工具标记,未指定时回落到全局选项;需传给客户端及回调内部的后续请求。 */
|
|
114
|
+
actionAssistant?: ActionAssistant;
|
|
113
115
|
/** 本次调用选定的客户端。 */
|
|
114
116
|
client: ZentaoClient;
|
|
115
117
|
/** 调用方传入的原始请求选项。 */
|
package/dist/types/options.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ZentaoClient } from '../client/index.js';
|
|
2
|
+
import type { ActionAssistant } from './client.js';
|
|
2
3
|
import type { ProcessListOptions, ProcessSingleOptions } from './data.js';
|
|
3
4
|
/** SDK 进程级全局默认选项,供高阶 {@link request} 调用复用。 */
|
|
4
5
|
export interface GlobalOptions {
|
|
@@ -8,6 +9,8 @@ export interface GlobalOptions {
|
|
|
8
9
|
skipVersionCheckOnConfigError?: boolean;
|
|
9
10
|
/** 默认客户端;通常由 `ZentaoClient.init()` 设置。 */
|
|
10
11
|
client?: ZentaoClient;
|
|
12
|
+
/** 默认操作辅助工具标记;覆盖客户端默认值,可被单次请求覆盖,空字符串表示关闭,不保存到 profile。 */
|
|
13
|
+
actionAssistant?: ActionAssistant;
|
|
11
14
|
/** 默认每页记录数,会映射到模块动作的 `recPerPage` 参数。 */
|
|
12
15
|
recPerPage?: string;
|
|
13
16
|
/** 默认限制返回列表数量,只影响 SDK 归一化后的 `data`。 */
|
|
@@ -35,6 +38,8 @@ export interface RequestOptions extends ProcessListOptions {
|
|
|
35
38
|
skipVersionCheckOnConfigError?: boolean;
|
|
36
39
|
/** 本次调用使用的客户端;优先级高于全局客户端。 */
|
|
37
40
|
client?: ZentaoClient;
|
|
41
|
+
/** 本次操作辅助工具标记;覆盖全局和客户端默认值,对象整体替换,undefined 表示继承,空字符串表示关闭。 */
|
|
42
|
+
actionAssistant?: ActionAssistant;
|
|
38
43
|
/** 本次调用使用的每页记录数,优先级高于全局 `recPerPage`。 */
|
|
39
44
|
recPerPage?: string;
|
|
40
45
|
/** 本次调用超时时间。 */
|
package/dist/version.js
CHANGED