zentao-api 0.6.5 → 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 +26 -18
- package/dist/client/index.d.ts +30 -3
- package/dist/client/index.js +303 -27
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/misc/environment.d.ts +0 -2
- package/dist/misc/environment.js +43 -19
- package/dist/misc/errors.d.ts +6 -0
- package/dist/misc/errors.js +9 -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 +2240 -59
- package/dist/modules/generated.js +1230 -50
- package/dist/modules/override.d.ts +2 -0
- package/dist/modules/override.js +39 -66
- package/dist/modules/query.d.ts +13 -10
- package/dist/modules/query.js +30 -26
- package/dist/modules/registry-store.js +3 -0
- package/dist/modules/registry.d.ts +0 -9702
- package/dist/modules/registry.js +0 -4
- package/dist/modules/resolve.js +1 -1
- package/dist/profiles/index.d.ts +3 -1
- package/dist/profiles/index.js +13 -4
- package/dist/request/index.d.ts +15 -4
- package/dist/request/index.js +39 -7
- package/dist/types/client.d.ts +8 -3
- package/dist/types/module.d.ts +13 -2
- package/dist/types/options.d.ts +9 -0
- package/dist/types/profile.d.ts +2 -0
- package/dist/types/response.d.ts +9 -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/README.md
CHANGED
|
@@ -221,11 +221,28 @@ setGlobalOptions({
|
|
|
221
221
|
});
|
|
222
222
|
```
|
|
223
223
|
|
|
224
|
-
常用全局选项包括 `client`、`recPerPage`、`limit`、`timeout`、`insecure`、`persistProfiles`、`throwOnFail` 和 `autoFill`。优先级通常为:单次调用选项 > 全局选项 > 客户端默认值。
|
|
224
|
+
常用全局选项包括 `client`、`version`、`recPerPage`、`limit`、`timeout`、`insecure`、`persistProfiles`、`skipVersionCheckOnConfigError`、`throwOnFail` 和 `autoFill`。优先级通常为:单次调用选项 > 全局选项 > 客户端默认值。
|
|
225
|
+
|
|
226
|
+
### 禅道版本检查
|
|
227
|
+
|
|
228
|
+
高阶 `request()` 会在发送业务请求前检查 Action 的必填 `minVersion`。四个系列分别比较,例如 `22.5`、`biz13.5`、`max8.5`、`ipd5.5`;支持点分数字正式版本,暂不支持 alpha、beta、rc 等后缀。底层 `client.get/post/request` 不检查 Action 版本。
|
|
229
|
+
|
|
230
|
+
```ts
|
|
231
|
+
setGlobalOptions({ version: 'biz13.5' });
|
|
232
|
+
await request('story/getGrades'); // 直接使用全局版本,无需获取配置
|
|
233
|
+
await request('story/getGrades', {}, { forceRefreshConfig: true }); // 用服务器实际版本校验本次请求
|
|
234
|
+
|
|
235
|
+
const config = await client.getZentaoConfig(); // 复用有效缓存,缺失或过期时获取
|
|
236
|
+
const freshConfig = await client.getZentaoConfig({ forceRefresh: true });
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
强制刷新不会改写全局 `version`。未指定全局版本时,使用不超过 24 小时的缓存;缓存缺失、过期或时间异常时访问站点根地址的 `/?mode=getconfig`。登录验证成功后也会强制获取一次,即使已设置全局版本。
|
|
240
|
+
|
|
241
|
+
配置获取失败默认停止调用;可以通过全局或单次 `skipVersionCheckOnConfigError: true` 跳过本次检查。该选项不忽略版本不匹配、版本格式错误、取消或 profile 存储错误。版本不匹配抛出 `E_UNSUPPORTED_ZENTAO_VERSION`。
|
|
225
242
|
|
|
226
243
|
### 持久化 Profile
|
|
227
244
|
|
|
228
|
-
Profile 默认不会写入。先启用 `persistProfiles`,登录成功后才会保存站点、账号、token
|
|
245
|
+
Profile 默认不会写入。先启用 `persistProfiles`,登录成功后才会保存站点、账号、token、客户端配置,以及 `serverConfig` 和获取时间 `serverConfigFetchedAt`:
|
|
229
246
|
|
|
230
247
|
```ts
|
|
231
248
|
import { ZentaoClient, setGlobalOptions } from 'zentao-api';
|
|
@@ -313,6 +330,7 @@ import { ZentaoClient, request } from 'zentao-api/browser';
|
|
|
313
330
|
|
|
314
331
|
```ts
|
|
315
332
|
import {
|
|
333
|
+
getModule,
|
|
316
334
|
getModuleAction,
|
|
317
335
|
getModuleActionParams,
|
|
318
336
|
getModuleNames,
|
|
@@ -323,8 +341,14 @@ const modules = getModuleNames();
|
|
|
323
341
|
const action = getModuleAction('bug', 'create');
|
|
324
342
|
const params = getModuleActionParams('bug', 'create');
|
|
325
343
|
const labels = getObjectProps('bug');
|
|
344
|
+
|
|
345
|
+
const supported = getModule('story', { version: 'biz13.0' });
|
|
346
|
+
const unavailable = getModuleAction('story', 'getGrades', { version: 'biz13.0' }); // undefined
|
|
347
|
+
const supportedParams = getModuleActionParams('story', 'create', { version: 'biz13.0', roles: ['body'] });
|
|
326
348
|
```
|
|
327
349
|
|
|
350
|
+
模块查询只使用显式传入的 `version`,省略时返回当前完整定义,不受全局版本影响。过滤后没有动作的模块不返回。旧 Action 后续新增的参数仍按当前定义返回,不做参数级版本过滤。
|
|
351
|
+
|
|
328
352
|
未注册的 API 可以新增为自定义模块:
|
|
329
353
|
|
|
330
354
|
```ts
|
|
@@ -335,6 +359,7 @@ defineModules({
|
|
|
335
359
|
actions: [
|
|
336
360
|
{
|
|
337
361
|
name: 'list',
|
|
362
|
+
minVersion: ['22.0', 'biz13.0', 'max8.0', 'ipd5.0'],
|
|
338
363
|
type: 'list',
|
|
339
364
|
path: '/custom',
|
|
340
365
|
resultGetter: 'items',
|
|
@@ -356,6 +381,8 @@ extendModuleAction('task', 'list', {
|
|
|
356
381
|
|
|
357
382
|
`defineModuleActions()` 可追加或整体替换单个动作,`defineModules(module, { replace: true })` 可整体替换同名模块。请确保扩展代码在第一次调用 `request()` 前执行。
|
|
358
383
|
|
|
384
|
+
所有完整 Action 定义都必须包含非空的 `minVersion` 数组,同一系列不能重复;未列出的系列视为不支持。SDK 0.5.5 及之前已有的 Action 最低版本为 `22.0 / biz13.0 / max8.0 / ipd5.0`,之后新增的 Action 为 `22.5 / biz13.5 / max8.5 / ipd5.5`。
|
|
385
|
+
|
|
359
386
|
## 文档
|
|
360
387
|
|
|
361
388
|
- [快速开始](https://github.com/easysoft/zentao-api/blob/main/docs/guide/index.md)
|