zentao-api 0.6.6 → 0.6.7
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 +29 -2
- package/dist/browser/zentao-api.global.js +21 -21
- package/dist/client/index.d.ts +26 -2
- package/dist/client/index.js +109 -10
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/misc/errors.d.ts +5 -0
- package/dist/misc/errors.js +8 -0
- package/dist/misc/zentao-version.d.ts +11 -0
- package/dist/misc/zentao-version.js +35 -0
- package/dist/modules/define.d.ts +4 -3
- package/dist/modules/define.js +4 -3
- package/dist/modules/generated.d.ts +228 -0
- package/dist/modules/generated.js +228 -0
- package/dist/modules/override.d.ts +2 -0
- package/dist/modules/override.js +3 -0
- package/dist/modules/query.d.ts +13 -8
- package/dist/modules/query.js +25 -11
- package/dist/modules/registry-store.js +3 -0
- package/dist/profiles/index.d.ts +3 -1
- package/dist/profiles/index.js +12 -0
- package/dist/request/index.d.ts +3 -0
- package/dist/request/index.js +37 -5
- package/dist/types/client.d.ts +5 -0
- package/dist/types/module.d.ts +7 -0
- package/dist/types/options.d.ts +8 -0
- package/dist/types/profile.d.ts +2 -0
- package/dist/types/response.d.ts +9 -0
- package/dist/version.js +2 -2
- package/package.json +1 -1
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
* ```ts
|
|
21
21
|
* defineModuleActions('bug', {
|
|
22
22
|
* name: 'assignTo',
|
|
23
|
+
* minVersion: ['22.0', 'biz13.0', 'max8.0', 'ipd5.0'],
|
|
23
24
|
* display: '指派 Bug',
|
|
24
25
|
* type: 'action',
|
|
25
26
|
* method: 'put',
|
|
@@ -44,6 +45,7 @@
|
|
|
44
45
|
* actions: [
|
|
45
46
|
* {
|
|
46
47
|
* name: 'list',
|
|
48
|
+
* minVersion: ['22.0', 'biz13.0', 'max8.0', 'ipd5.0'],
|
|
47
49
|
* type: 'list',
|
|
48
50
|
* method: 'get',
|
|
49
51
|
* path: '/customs',
|
package/dist/modules/override.js
CHANGED
|
@@ -24,6 +24,7 @@ import { isRecord } from '../utils/index.js';
|
|
|
24
24
|
* ```ts
|
|
25
25
|
* defineModuleActions('bug', {
|
|
26
26
|
* name: 'assignTo',
|
|
27
|
+
* minVersion: ['22.0', 'biz13.0', 'max8.0', 'ipd5.0'],
|
|
27
28
|
* display: '指派 Bug',
|
|
28
29
|
* type: 'action',
|
|
29
30
|
* method: 'put',
|
|
@@ -48,6 +49,7 @@ import { isRecord } from '../utils/index.js';
|
|
|
48
49
|
* actions: [
|
|
49
50
|
* {
|
|
50
51
|
* name: 'list',
|
|
52
|
+
* minVersion: ['22.0', 'biz13.0', 'max8.0', 'ipd5.0'],
|
|
51
53
|
* type: 'list',
|
|
52
54
|
* method: 'get',
|
|
53
55
|
* path: '/customs',
|
|
@@ -178,6 +180,7 @@ export function applyBuiltinOverrides() {
|
|
|
178
180
|
// 定义获取需求层级操作
|
|
179
181
|
defineModuleActions('story', {
|
|
180
182
|
name: 'getGrades',
|
|
183
|
+
minVersion: ['22.5', 'biz13.5', 'max8.5', 'ipd5.5'],
|
|
181
184
|
display: '获取需求层级选项',
|
|
182
185
|
type: 'list',
|
|
183
186
|
method: 'get',
|
package/dist/modules/query.d.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import type { ModuleAction, ModuleActionParam, ModuleActionParamRole, ModuleDefinition } from '../types/index.js';
|
|
1
|
+
import type { ModuleAction, ModuleActionParam, ModuleActionParamRole, ModuleDefinition, ModuleQueryOptions } from '../types/index.js';
|
|
2
2
|
/**
|
|
3
3
|
* 获取模块定义。
|
|
4
4
|
*
|
|
5
|
-
*
|
|
5
|
+
* 模块名匹配大小写不敏感。未传版本时返回注册表内部的已深冻结引用(O(1) 查询、零拷贝),
|
|
6
6
|
* 任何写入尝试在严格模式下会抛 `TypeError`;如需修改请使用 {@link defineModules}。
|
|
7
7
|
*
|
|
8
8
|
* @param moduleName - 模块名。
|
|
9
|
-
* @
|
|
9
|
+
* @param options - 可选版本过滤;不传时保留完整注册表引用,传入时返回冻结的过滤视图。
|
|
10
|
+
* @returns 已注册的模块定义;模块未注册或过滤后没有动作时返回 `undefined`。
|
|
10
11
|
*/
|
|
11
|
-
export declare function getModule(moduleName: string): ModuleDefinition | undefined;
|
|
12
|
+
export declare function getModule(moduleName: string, options?: ModuleQueryOptions): ModuleDefinition | undefined;
|
|
12
13
|
/**
|
|
13
14
|
* 获取指定模块下的某个动作。
|
|
14
15
|
*
|
|
@@ -20,9 +21,10 @@ export declare function getModule(moduleName: string): ModuleDefinition | undefi
|
|
|
20
21
|
*
|
|
21
22
|
* @param moduleName - 模块名(大小写不敏感)。
|
|
22
23
|
* @param actionName - 动作名(大小写不敏感);支持 `ls` 作为 `list` 的别名。
|
|
24
|
+
* @param options - 可选版本过滤。
|
|
23
25
|
* @returns 匹配到的动作定义;模块未注册或动作不存在时返回 `undefined`。
|
|
24
26
|
*/
|
|
25
|
-
export declare function getModuleAction(moduleName: string, actionName: string): ModuleAction | undefined;
|
|
27
|
+
export declare function getModuleAction(moduleName: string, actionName: string, options?: ModuleQueryOptions): ModuleAction | undefined;
|
|
26
28
|
/**
|
|
27
29
|
* 获取指定模块下的某个动作的参数。
|
|
28
30
|
*
|
|
@@ -30,9 +32,10 @@ export declare function getModuleAction(moduleName: string, actionName: string):
|
|
|
30
32
|
* @param actionName - 动作名(大小写不敏感);支持 `ls` 作为 `list` 的别名。
|
|
31
33
|
* @param options - 选项。
|
|
32
34
|
* @param options.roles - 角色,可选 `path`、`query`、`body`。
|
|
35
|
+
* @param options.version - 可选禅道版本;不支持该动作时返回空数组,不做参数级版本过滤。
|
|
33
36
|
* @returns 动作参数。
|
|
34
37
|
*/
|
|
35
|
-
export declare function getModuleActionParams(moduleName: string, actionName: string, options?: {
|
|
38
|
+
export declare function getModuleActionParams(moduleName: string, actionName: string, options?: ModuleQueryOptions & {
|
|
36
39
|
roles?: ModuleActionParamRole[];
|
|
37
40
|
}): ModuleActionParam[];
|
|
38
41
|
/**
|
|
@@ -41,15 +44,17 @@ export declare function getModuleActionParams(moduleName: string, actionName: st
|
|
|
41
44
|
* 顺序与模块写入注册表的顺序一致;包括内置模块和通过 {@link defineModules} 追加的用户模块。
|
|
42
45
|
*
|
|
43
46
|
* @returns 模块名数组(保留原始大小写)。
|
|
47
|
+
* @param options - 可选版本过滤,仅保留含有支持动作的模块。
|
|
44
48
|
*/
|
|
45
|
-
export declare function getModuleNames(): string[];
|
|
49
|
+
export declare function getModuleNames(options?: ModuleQueryOptions): string[];
|
|
46
50
|
/**
|
|
47
51
|
* 判断模块名是否已注册。
|
|
48
52
|
*
|
|
49
53
|
* @param moduleName - 模块名;匹配大小写不敏感。
|
|
54
|
+
* @param options - 可选版本过滤。
|
|
50
55
|
* @returns 已注册返回 `true`,否则 `false`。
|
|
51
56
|
*/
|
|
52
|
-
export declare function isModuleName(moduleName: string): boolean;
|
|
57
|
+
export declare function isModuleName(moduleName: string, options?: ModuleQueryOptions): boolean;
|
|
53
58
|
/**
|
|
54
59
|
* 获取对象属性。
|
|
55
60
|
*
|
package/dist/modules/query.js
CHANGED
|
@@ -1,16 +1,23 @@
|
|
|
1
|
+
import { parseZentaoVersion, supportsZentaoVersion } from '../misc/zentao-version.js';
|
|
1
2
|
import { objectProps } from './object-props.js';
|
|
2
3
|
import { getModuleMapState, getModulesState } from './registry-store.js';
|
|
3
4
|
/**
|
|
4
5
|
* 获取模块定义。
|
|
5
6
|
*
|
|
6
|
-
*
|
|
7
|
+
* 模块名匹配大小写不敏感。未传版本时返回注册表内部的已深冻结引用(O(1) 查询、零拷贝),
|
|
7
8
|
* 任何写入尝试在严格模式下会抛 `TypeError`;如需修改请使用 {@link defineModules}。
|
|
8
9
|
*
|
|
9
10
|
* @param moduleName - 模块名。
|
|
10
|
-
* @
|
|
11
|
+
* @param options - 可选版本过滤;不传时保留完整注册表引用,传入时返回冻结的过滤视图。
|
|
12
|
+
* @returns 已注册的模块定义;模块未注册或过滤后没有动作时返回 `undefined`。
|
|
11
13
|
*/
|
|
12
|
-
export function getModule(moduleName) {
|
|
13
|
-
|
|
14
|
+
export function getModule(moduleName, options = {}) {
|
|
15
|
+
const version = options.version === undefined ? undefined : parseZentaoVersion(options.version);
|
|
16
|
+
const module = getModuleMapState().get(moduleName.toLowerCase());
|
|
17
|
+
if (!version || !module)
|
|
18
|
+
return module;
|
|
19
|
+
const actions = module.actions.filter(action => supportsZentaoVersion(version, action.minVersion));
|
|
20
|
+
return actions.length ? Object.freeze({ ...module, actions: Object.freeze(actions) }) : undefined;
|
|
14
21
|
}
|
|
15
22
|
/**
|
|
16
23
|
* 获取指定模块下的某个动作。
|
|
@@ -23,10 +30,11 @@ export function getModule(moduleName) {
|
|
|
23
30
|
*
|
|
24
31
|
* @param moduleName - 模块名(大小写不敏感)。
|
|
25
32
|
* @param actionName - 动作名(大小写不敏感);支持 `ls` 作为 `list` 的别名。
|
|
33
|
+
* @param options - 可选版本过滤。
|
|
26
34
|
* @returns 匹配到的动作定义;模块未注册或动作不存在时返回 `undefined`。
|
|
27
35
|
*/
|
|
28
|
-
export function getModuleAction(moduleName, actionName) {
|
|
29
|
-
const module = getModule(moduleName);
|
|
36
|
+
export function getModuleAction(moduleName, actionName, options) {
|
|
37
|
+
const module = getModule(moduleName, options);
|
|
30
38
|
if (!module)
|
|
31
39
|
return undefined;
|
|
32
40
|
const normalized = actionName === 'ls' ? 'list' : actionName;
|
|
@@ -39,12 +47,13 @@ export function getModuleAction(moduleName, actionName) {
|
|
|
39
47
|
* @param actionName - 动作名(大小写不敏感);支持 `ls` 作为 `list` 的别名。
|
|
40
48
|
* @param options - 选项。
|
|
41
49
|
* @param options.roles - 角色,可选 `path`、`query`、`body`。
|
|
50
|
+
* @param options.version - 可选禅道版本;不支持该动作时返回空数组,不做参数级版本过滤。
|
|
42
51
|
* @returns 动作参数。
|
|
43
52
|
*/
|
|
44
53
|
export function getModuleActionParams(moduleName, actionName, options) {
|
|
45
54
|
const { roles } = options ?? {};
|
|
46
55
|
const params = [];
|
|
47
|
-
const action = getModuleAction(moduleName, actionName);
|
|
56
|
+
const action = getModuleAction(moduleName, actionName, options);
|
|
48
57
|
if (!action) {
|
|
49
58
|
return [];
|
|
50
59
|
}
|
|
@@ -98,18 +107,23 @@ export function getModuleActionParams(moduleName, actionName, options) {
|
|
|
98
107
|
* 顺序与模块写入注册表的顺序一致;包括内置模块和通过 {@link defineModules} 追加的用户模块。
|
|
99
108
|
*
|
|
100
109
|
* @returns 模块名数组(保留原始大小写)。
|
|
110
|
+
* @param options - 可选版本过滤,仅保留含有支持动作的模块。
|
|
101
111
|
*/
|
|
102
|
-
export function getModuleNames() {
|
|
103
|
-
|
|
112
|
+
export function getModuleNames(options = {}) {
|
|
113
|
+
const version = options.version === undefined ? undefined : parseZentaoVersion(options.version);
|
|
114
|
+
return getModulesState()
|
|
115
|
+
.filter(module => !version || module.actions.some(action => supportsZentaoVersion(version, action.minVersion)))
|
|
116
|
+
.map(module => module.name);
|
|
104
117
|
}
|
|
105
118
|
/**
|
|
106
119
|
* 判断模块名是否已注册。
|
|
107
120
|
*
|
|
108
121
|
* @param moduleName - 模块名;匹配大小写不敏感。
|
|
122
|
+
* @param options - 可选版本过滤。
|
|
109
123
|
* @returns 已注册返回 `true`,否则 `false`。
|
|
110
124
|
*/
|
|
111
|
-
export function isModuleName(moduleName) {
|
|
112
|
-
return
|
|
125
|
+
export function isModuleName(moduleName, options) {
|
|
126
|
+
return getModule(moduleName, options) !== undefined;
|
|
113
127
|
}
|
|
114
128
|
/**
|
|
115
129
|
* 获取对象属性。
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ZentaoError } from '../misc/errors.js';
|
|
2
|
+
import { validateMinVersion } from '../misc/zentao-version.js';
|
|
2
3
|
import { isRecord } from '../utils/object.js';
|
|
3
4
|
import { BUILTIN_MODULES } from './generated.js';
|
|
4
5
|
// 动作类型到 HTTP 方法 / 结果形态的默认推导表:当动作未显式声明 method / resultType 时按 type 补齐。
|
|
@@ -99,6 +100,7 @@ export function normalizeAction(action) {
|
|
|
99
100
|
return action;
|
|
100
101
|
}
|
|
101
102
|
export function freezeAction(action) {
|
|
103
|
+
validateAction(action);
|
|
102
104
|
return deepFreeze(normalizeAction(action));
|
|
103
105
|
}
|
|
104
106
|
export function freezeModule(module) {
|
|
@@ -146,6 +148,7 @@ export function validateAction(action) {
|
|
|
146
148
|
if (!action || typeof action.name !== 'string' || typeof action.path !== 'string') {
|
|
147
149
|
throw new ZentaoError('E_INVALID_ACTION_DEFINITION');
|
|
148
150
|
}
|
|
151
|
+
validateMinVersion(action.minVersion);
|
|
149
152
|
// method / resultType 可省略(由 normalizeAction 按 type 推导),但显式给出时必须是字符串。
|
|
150
153
|
if (action.method !== undefined && typeof action.method !== 'string') {
|
|
151
154
|
throw new ZentaoError('E_INVALID_ACTION_DEFINITION');
|
package/dist/profiles/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ZentaoProfile, ZentaoProfileRecord } from '../types/index.js';
|
|
1
|
+
import type { ServerConfig, ZentaoProfile, ZentaoProfileRecord } from '../types/index.js';
|
|
2
2
|
/**
|
|
3
3
|
* 浏览器环境下用于在 `localStorage` 中保存 profile 数据的 key。
|
|
4
4
|
*
|
|
@@ -50,6 +50,8 @@ export declare function getProfile(profileKey?: string): Promise<ZentaoProfileRe
|
|
|
50
50
|
* `E_INVALID_BASE_URL`、`E_PROFILE_STORAGE_INVALID`、`E_PROFILE_STORAGE_UNAVAILABLE`。
|
|
51
51
|
*/
|
|
52
52
|
export declare function addProfile(profile: ZentaoProfile): Promise<ZentaoProfileRecord>;
|
|
53
|
+
/** 只刷新已有 profile 的服务器配置,不切换当前账号或重建已删除的记录。 @internal */
|
|
54
|
+
export declare function updateProfileServerConfig(profileKey: string, serverConfig: ServerConfig, fetchedAt: string): Promise<void>;
|
|
53
55
|
/**
|
|
54
56
|
* 删除指定 profile。
|
|
55
57
|
*
|
package/dist/profiles/index.js
CHANGED
|
@@ -238,6 +238,18 @@ export function addProfile(profile) {
|
|
|
238
238
|
return toRecord(normalized);
|
|
239
239
|
});
|
|
240
240
|
}
|
|
241
|
+
/** 只刷新已有 profile 的服务器配置,不切换当前账号或重建已删除的记录。 @internal */
|
|
242
|
+
export function updateProfileServerConfig(profileKey, serverConfig, fetchedAt) {
|
|
243
|
+
return withStoreMutex(async () => {
|
|
244
|
+
const store = await readStore();
|
|
245
|
+
const profile = findProfile(store, profileKey);
|
|
246
|
+
if (!profile)
|
|
247
|
+
return;
|
|
248
|
+
profile.serverConfig = cloneJson(serverConfig);
|
|
249
|
+
profile.serverConfigFetchedAt = fetchedAt;
|
|
250
|
+
await writeStore(store);
|
|
251
|
+
});
|
|
252
|
+
}
|
|
241
253
|
/**
|
|
242
254
|
* 删除指定 profile。
|
|
243
255
|
*
|
package/dist/request/index.d.ts
CHANGED
|
@@ -27,6 +27,9 @@ export type RequestResultFor<Name extends BuiltinRequestName> = ActionMetaOf<Nam
|
|
|
27
27
|
* 选项优先级为:本次调用 options > 全局 options > 客户端默认值。
|
|
28
28
|
* 当响应 `status` 为 `"fail"` 时,默认按原样返回;若 `options.throwOnFail`
|
|
29
29
|
* 或全局 `throwOnFail` 为真,则改为抛出 `E_API_FAILED`。
|
|
30
|
+
* 请求前按 Action 的 `minVersion` 检查服务器版本;全局 `version` 可避免配置探测,
|
|
31
|
+
* `forceRefreshConfig` 则强制使用实际版本。无法获取配置时默认抛错,
|
|
32
|
+
* `skipVersionCheckOnConfigError` 可允许本次跳过检查,但不能忽略明确的版本不匹配。
|
|
30
33
|
*
|
|
31
34
|
* 对 `update` 动作,当 `options.autoFill` 或全局 `autoFill` 为真时,会先 GET 当前对象,
|
|
32
35
|
* 用现值补齐用户未显式传入的 body 字段后再 PUT,避免禅道覆盖未提交字段。详见 {@link RequestOptions.autoFill}。
|
package/dist/request/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { ZentaoError } from '../misc/errors.js';
|
|
1
|
+
import { isZentaoConfigFetchError, ZentaoError } from '../misc/errors.js';
|
|
2
|
+
import { parseZentaoVersion, supportsZentaoVersion } from '../misc/zentao-version.js';
|
|
2
3
|
import { getGlobalOptions } from '../misc/global-options.js';
|
|
3
4
|
import { getModule, getModuleAction } from '../modules/registry.js';
|
|
4
5
|
import { extractPager, extractResult, resolveActionRequest } from '../modules/resolve.js';
|
|
@@ -57,17 +58,17 @@ function getExplicitDataKeys(data) {
|
|
|
57
58
|
* 字段归属判断同时覆盖平铺 `params` 字段与 `params.data` 中的字段;只有 schema 中声明、
|
|
58
59
|
* 用户未传且当前对象存在的字段才会被补齐,避免覆盖用户本次想修改的字段。
|
|
59
60
|
*/
|
|
60
|
-
async function autoFillUpdateParams(module, action, params, options) {
|
|
61
|
+
async function autoFillUpdateParams(module, action, params, options, version) {
|
|
61
62
|
const properties = action.requestBody?.schema?.properties;
|
|
62
63
|
const getAction = module.actions.find((candidate) => candidate.type === 'get' && candidate.path === action.path);
|
|
63
64
|
if (!properties || !getAction)
|
|
64
65
|
return params;
|
|
65
|
-
const current = (await
|
|
66
|
+
const current = (await requestInternal(`${module.name}/${getAction.name}`, params, {
|
|
66
67
|
client: options.client,
|
|
67
68
|
timeout: options.timeout,
|
|
68
69
|
insecure: options.insecure,
|
|
69
70
|
throwOnFail: true,
|
|
70
|
-
})).data;
|
|
71
|
+
}, version)).data;
|
|
71
72
|
if (!isRecord(current))
|
|
72
73
|
return params;
|
|
73
74
|
const explicitDataKeys = getExplicitDataKeys(params.data);
|
|
@@ -172,6 +173,10 @@ function normalizeResponse(command, raw, options) {
|
|
|
172
173
|
return response;
|
|
173
174
|
}
|
|
174
175
|
export async function request(name, params = {}, options = {}) {
|
|
176
|
+
return requestInternal(name, params, options);
|
|
177
|
+
}
|
|
178
|
+
/** version 为 undefined 时解析一次,null 表示本次调用已选择跳过版本检查。 */
|
|
179
|
+
async function requestInternal(name, params, options, version) {
|
|
175
180
|
const globals = getGlobalOptions();
|
|
176
181
|
const client = options.client ?? globals.client;
|
|
177
182
|
if (!client) {
|
|
@@ -195,8 +200,35 @@ export async function request(name, params = {}, options = {}) {
|
|
|
195
200
|
if (!action) {
|
|
196
201
|
throw new ZentaoError('E_INVALID_ACTION', { module: moduleName, action: actionName });
|
|
197
202
|
}
|
|
203
|
+
if (version === undefined) {
|
|
204
|
+
if (!options.forceRefreshConfig && globals.version !== undefined) {
|
|
205
|
+
version = globals.version;
|
|
206
|
+
}
|
|
207
|
+
else {
|
|
208
|
+
try {
|
|
209
|
+
version = (await client.getZentaoConfig({
|
|
210
|
+
forceRefresh: options.forceRefreshConfig,
|
|
211
|
+
timeout: options.timeout ?? globals.timeout,
|
|
212
|
+
insecure: options.insecure ?? globals.insecure,
|
|
213
|
+
})).version;
|
|
214
|
+
}
|
|
215
|
+
catch (error) {
|
|
216
|
+
if (!(options.skipVersionCheckOnConfigError ?? globals.skipVersionCheckOnConfigError)
|
|
217
|
+
|| !isZentaoConfigFetchError(error))
|
|
218
|
+
throw error;
|
|
219
|
+
version = null;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
if (version !== null && !supportsZentaoVersion(parseZentaoVersion(version), action.minVersion)) {
|
|
224
|
+
throw new ZentaoError('E_UNSUPPORTED_ZENTAO_VERSION', {
|
|
225
|
+
action: `${module.name}/${action.name}`,
|
|
226
|
+
version,
|
|
227
|
+
minVersion: action.minVersion.join(', '),
|
|
228
|
+
}, { action: `${module.name}/${action.name}`, version, minVersion: action.minVersion });
|
|
229
|
+
}
|
|
198
230
|
const finalParams = action.type === 'update' && (options.autoFill ?? globals.autoFill)
|
|
199
|
-
? await autoFillUpdateParams(module, action, mergedParams, options)
|
|
231
|
+
? await autoFillUpdateParams(module, action, mergedParams, { ...options, client }, version)
|
|
200
232
|
: mergedParams;
|
|
201
233
|
const command = resolveActionRequest(module, actionName, finalParams);
|
|
202
234
|
const preparedBody = await prepareActionBody(command, {
|
package/dist/types/client.d.ts
CHANGED
|
@@ -36,3 +36,8 @@ export interface ClientRequestOptions {
|
|
|
36
36
|
/** 单次请求 TLS 跳过证书验证选项;仅 Node.js 运行时支持。 */
|
|
37
37
|
insecure?: boolean;
|
|
38
38
|
}
|
|
39
|
+
/** {@link ZentaoClient.getZentaoConfig} 的选项。 */
|
|
40
|
+
export interface GetZentaoConfigOptions extends Pick<ClientRequestOptions, 'timeout' | 'insecure' | 'signal'> {
|
|
41
|
+
/** 忽略已有缓存并重新获取配置,默认 false;同一客户端的并发获取会合并。 */
|
|
42
|
+
forceRefresh?: boolean;
|
|
43
|
+
}
|
package/dist/types/module.d.ts
CHANGED
|
@@ -90,6 +90,8 @@ export type ModuleActionGetterFn<T, O = RequestProcessOptions> = (data: unknown,
|
|
|
90
90
|
export interface ModuleAction {
|
|
91
91
|
/** 动作名称,例如 `list`、`get`、`close`。 */
|
|
92
92
|
name: ModuleActionName;
|
|
93
|
+
/** 各系列支持的最低禅道正式版本,例如 `['22.0', 'biz13.0', 'max8.0', 'ipd5.0']`;不能为空或重复系列,未列出的系列不支持。 */
|
|
94
|
+
minVersion: readonly string[];
|
|
93
95
|
/** 动作类型,决定高阶 request 的路径/参数解析策略,并在 `method`、`resultType` 省略时作为推导依据。 */
|
|
94
96
|
type: ModuleActionType;
|
|
95
97
|
/** 面向用户展示的动作名称。 */
|
|
@@ -140,6 +142,11 @@ export interface ModuleDefinition {
|
|
|
140
142
|
/** 模块支持的动作集合。 */
|
|
141
143
|
actions: readonly ModuleAction[];
|
|
142
144
|
}
|
|
145
|
+
/** 注册库查询选项;不传版本时返回完整的当前定义,不使用全局版本。 */
|
|
146
|
+
export interface ModuleQueryOptions {
|
|
147
|
+
/** 仅返回该禅道版本支持的动作,以及至少含有一个支持动作的模块。 */
|
|
148
|
+
version?: string;
|
|
149
|
+
}
|
|
143
150
|
/** 将模块动作和参数解析后的可执行请求描述。 */
|
|
144
151
|
export interface ModuleActionRequest {
|
|
145
152
|
/** 模块名称。 */
|
package/dist/types/options.d.ts
CHANGED
|
@@ -2,6 +2,10 @@ import type { ZentaoClient } from '../client/index.js';
|
|
|
2
2
|
import type { ProcessListOptions, ProcessSingleOptions } from './data.js';
|
|
3
3
|
/** SDK 进程级全局默认选项,供高阶 {@link request} 调用复用。 */
|
|
4
4
|
export interface GlobalOptions {
|
|
5
|
+
/** 当前禅道正式版本,例如 `biz13.5`;普通高阶请求直接使用,单次强制刷新时使用实际版本。不会自动写入 profile。 */
|
|
6
|
+
version?: string;
|
|
7
|
+
/** 配置网络或响应获取失败时,允许登录继续或高阶请求跳过版本检查,默认 false;不忽略版本不匹配、格式错误或存储错误。 */
|
|
8
|
+
skipVersionCheckOnConfigError?: boolean;
|
|
5
9
|
/** 默认客户端;通常由 `ZentaoClient.init()` 设置。 */
|
|
6
10
|
client?: ZentaoClient;
|
|
7
11
|
/** 默认每页记录数,会映射到模块动作的 `recPerPage` 参数。 */
|
|
@@ -25,6 +29,10 @@ export interface GlobalOptions {
|
|
|
25
29
|
}
|
|
26
30
|
/** 高阶 `request("moduleName")` / `request("moduleName/methodName")` / `request("moduleName/<objectID>")` 的单次调用选项。 */
|
|
27
31
|
export interface RequestOptions extends ProcessListOptions {
|
|
32
|
+
/** 强制刷新服务器配置并用实际版本校验本次请求,优先于全局 version;不会改写全局版本。 */
|
|
33
|
+
forceRefreshConfig?: boolean;
|
|
34
|
+
/** 配置网络或响应获取失败时跳过本次版本检查;优先于全局设置,默认 false,不忽略版本不匹配或格式错误。 */
|
|
35
|
+
skipVersionCheckOnConfigError?: boolean;
|
|
28
36
|
/** 本次调用使用的客户端;优先级高于全局客户端。 */
|
|
29
37
|
client?: ZentaoClient;
|
|
30
38
|
/** 本次调用使用的每页记录数,优先级高于全局 `recPerPage`。 */
|
package/dist/types/profile.d.ts
CHANGED
|
@@ -36,6 +36,8 @@ export interface ZentaoProfile {
|
|
|
36
36
|
lastUsedTime?: string;
|
|
37
37
|
/** 禅道服务端配置。 */
|
|
38
38
|
serverConfig?: ServerConfig;
|
|
39
|
+
/** 成功从 `?mode=getconfig` 获取配置的本地 ISO 时间;缺失时缓存需要刷新。 */
|
|
40
|
+
serverConfigFetchedAt?: string;
|
|
39
41
|
/** 客户端自定义配置。 */
|
|
40
42
|
config?: ZentaoProfileConfig;
|
|
41
43
|
/** 允许上层应用保存额外字段。 */
|
package/dist/types/response.d.ts
CHANGED
|
@@ -58,6 +58,13 @@ export interface LoginResponse extends ApiResponse {
|
|
|
58
58
|
}
|
|
59
59
|
/** 禅道 `?mode=getconfig` 返回的服务端配置。 */
|
|
60
60
|
export interface ServerConfig {
|
|
61
|
+
/**
|
|
62
|
+
* 禅道版本,不同系列以不同的前缀表示,下面为例子:
|
|
63
|
+
* - `22.5`:开源版 22.5
|
|
64
|
+
* - `biz13.5`:企业版 13.5
|
|
65
|
+
* - `max8.5`:旗舰版 8.5
|
|
66
|
+
* - `ipd5.5`:IPD 5.5
|
|
67
|
+
*/
|
|
61
68
|
version: string;
|
|
62
69
|
systemMode: string;
|
|
63
70
|
sprintConcept: string;
|
|
@@ -67,4 +74,6 @@ export interface ServerConfig {
|
|
|
67
74
|
methodVar: string;
|
|
68
75
|
viewVar: string;
|
|
69
76
|
sessionVar: string;
|
|
77
|
+
/** 保留服务端返回的其他配置字段。 */
|
|
78
|
+
[key: string]: unknown;
|
|
70
79
|
}
|
package/dist/version.js
CHANGED