zentao-api 0.1.0 → 0.2.0-beta.2

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.
Files changed (53) hide show
  1. package/LICENSE +2 -2
  2. package/README.md +221 -131
  3. package/dist/browser/zentao-api.global.js +2 -0
  4. package/dist/browser.d.ts +1 -0
  5. package/dist/browser.js +1 -0
  6. package/dist/client/index.d.ts +39 -0
  7. package/dist/client/index.js +172 -0
  8. package/dist/index.d.ts +8 -4
  9. package/dist/index.js +7 -8
  10. package/dist/misc/browser-global.d.ts +1 -0
  11. package/dist/misc/browser-global.js +8 -0
  12. package/dist/misc/environment.d.ts +8 -0
  13. package/dist/misc/environment.js +124 -0
  14. package/dist/misc/errors.d.ts +30 -0
  15. package/dist/misc/errors.js +40 -0
  16. package/dist/misc/global-options.d.ts +5 -0
  17. package/dist/misc/global-options.js +9 -0
  18. package/dist/modules/generated.d.ts +8 -0
  19. package/dist/modules/generated.js +4226 -0
  20. package/dist/modules/registry.d.ts +22 -0
  21. package/dist/modules/registry.js +142 -0
  22. package/dist/modules/resolve.d.ts +7 -0
  23. package/dist/modules/resolve.js +206 -0
  24. package/dist/profiles/index.d.ts +14 -0
  25. package/dist/profiles/index.js +205 -0
  26. package/dist/request/index.d.ts +7 -0
  27. package/dist/request/index.js +65 -0
  28. package/dist/types/index.d.ts +296 -0
  29. package/dist/types/index.js +1 -0
  30. package/dist/utils/index.d.ts +6 -0
  31. package/dist/utils/index.js +26 -0
  32. package/dist/version.d.ts +2 -0
  33. package/dist/version.js +4 -0
  34. package/package.json +52 -76
  35. package/dist/types.d.ts +0 -70
  36. package/dist/utils.d.ts +0 -93
  37. package/dist/zentao-api.cjs.development.js +0 -3619
  38. package/dist/zentao-api.cjs.development.js.map +0 -1
  39. package/dist/zentao-api.cjs.production.min.js +0 -2
  40. package/dist/zentao-api.cjs.production.min.js.map +0 -1
  41. package/dist/zentao-api.esm.js +0 -3611
  42. package/dist/zentao-api.esm.js.map +0 -1
  43. package/dist/zentao-config.d.ts +0 -93
  44. package/dist/zentao-request-builder.d.ts +0 -120
  45. package/dist/zentao.d.ts +0 -175
  46. package/dist/zentao12.d.ts +0 -676
  47. package/src/index.ts +0 -5
  48. package/src/types.ts +0 -88
  49. package/src/utils.ts +0 -216
  50. package/src/zentao-config.ts +0 -150
  51. package/src/zentao-request-builder.ts +0 -227
  52. package/src/zentao.ts +0 -596
  53. package/src/zentao12.ts +0 -1272
@@ -0,0 +1,296 @@
1
+ import type { ZentaoClient } from '../client/index.js';
2
+ /** 创建 {@link ZentaoClient} 时使用的配置。 */
3
+ export interface ZentaoClientOptions {
4
+ /** 禅道站点根地址,例如 `https://zentao.example.com`;SDK 会自动拼接 `/api.php/v2`。 */
5
+ baseUrl: string;
6
+ /** 禅道 API Token;未提供时可稍后通过 {@link ZentaoClient.login} 获取并写入实例。 */
7
+ token?: string;
8
+ /** 默认请求超时时间,单位毫秒。 */
9
+ timeout?: number;
10
+ /** 是否跳过 TLS 证书验证;仅 Node.js 运行时支持,浏览器中会抛错。 */
11
+ insecure?: boolean;
12
+ }
13
+ /** SDK 进程级全局默认选项,供高阶 {@link request} 调用复用。 */
14
+ export interface GlobalOptions {
15
+ /** 默认客户端;通常由 `ZentaoClient.init()` 设置。 */
16
+ client?: ZentaoClient;
17
+ /** 默认每页记录数,会映射到模块动作的 `recPerPage` 参数。 */
18
+ recPerPage?: string;
19
+ /** 默认限制返回列表数量,只影响 SDK 归一化后的 `data`。 */
20
+ limit?: string;
21
+ /** 默认请求超时时间,优先级低于单次请求选项。 */
22
+ timeout?: number;
23
+ /** 默认 TLS 跳过证书验证选项;仅 Node.js 运行时支持。 */
24
+ insecure?: boolean;
25
+ /** 是否在登录成功后把账号、Token 和配置持久化为本地 profile。 */
26
+ persistProfiles?: boolean;
27
+ }
28
+ /** SDK 支持的 HTTP 方法。 */
29
+ export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE';
30
+ /** `ZentaoClient.request()` 的单次请求选项。 */
31
+ export interface ClientRequestOptions {
32
+ /** HTTP 方法,默认 `GET`。 */
33
+ method?: HttpMethod;
34
+ /** JSON 请求体;`GET` 请求会忽略该字段。 */
35
+ body?: Record<string, unknown>;
36
+ /** URL 查询参数;`undefined` 值会被跳过。 */
37
+ query?: Record<string, string | number | boolean | undefined>;
38
+ /** 单次请求超时时间,优先级高于全局和客户端默认值。 */
39
+ timeout?: number;
40
+ /** 单次请求 TLS 跳过证书验证选项;仅 Node.js 运行时支持。 */
41
+ insecure?: boolean;
42
+ }
43
+ /** 高阶 `request("moduleName/methodName")` 的单次调用选项。 */
44
+ export interface RequestOptions {
45
+ /** 本次调用使用的客户端;优先级高于全局客户端。 */
46
+ client?: ZentaoClient;
47
+ /** 本次调用使用的每页记录数,优先级高于全局 `recPerPage`。 */
48
+ recPerPage?: string;
49
+ /** 本次调用限制返回列表数量,优先级高于全局 `limit`。 */
50
+ limit?: string;
51
+ /** 本次调用超时时间。 */
52
+ timeout?: number;
53
+ /** 本次调用 TLS 跳过证书验证选项;仅 Node.js 运行时支持。 */
54
+ insecure?: boolean;
55
+ }
56
+ /** 高阶 `request()` 归一化后的返回数据。 */
57
+ export interface ResponseData {
58
+ /** 禅道服务端状态;非标准响应会按成功响应包装到 `data`。 */
59
+ status: 'success' | 'fail';
60
+ /** 禅道服务端返回的消息。 */
61
+ message?: string;
62
+ /** 根据模块动作 `resultGetter` 提取后的业务数据。 */
63
+ data?: any;
64
+ /** 统一分页信息。 */
65
+ pager?: {
66
+ /** 总记录数。 */
67
+ total: number;
68
+ /** 当前页码。 */
69
+ page: number;
70
+ /** 每页记录数。 */
71
+ recPerPage: number;
72
+ };
73
+ }
74
+ /** 禅道 API 原始分页结构。 */
75
+ export interface Pager {
76
+ /** 总记录数。 */
77
+ recTotal: number;
78
+ /** 每页记录数。 */
79
+ recPerPage: number;
80
+ /** 总页数,部分接口不返回。 */
81
+ pageTotal?: number;
82
+ /** 当前页码。 */
83
+ pageID: number;
84
+ }
85
+ /** 禅道 API 通用响应结构,允许携带任意业务字段。 */
86
+ export interface ApiResponse {
87
+ /** 服务端返回状态。 */
88
+ status: 'success' | 'fail';
89
+ /** 服务端消息,可能是字符串、对象或数组。 */
90
+ message?: unknown;
91
+ /** 其他业务字段。 */
92
+ [key: string]: unknown;
93
+ }
94
+ /** 禅道 API 列表响应结构。 */
95
+ export interface ApiListResponse extends ApiResponse {
96
+ /** 原始分页信息。 */
97
+ pager?: Pager;
98
+ }
99
+ /** 登录接口响应结构。 */
100
+ export interface LoginResponse extends ApiResponse {
101
+ /** 登录成功后返回的 API Token。 */
102
+ token?: string;
103
+ /** 部分禅道环境会随登录响应返回用户信息。 */
104
+ user?: Record<string, unknown>;
105
+ /** 部分禅道环境会随登录响应返回服务端配置。 */
106
+ serverConfig?: ServerConfig;
107
+ }
108
+ /** 禅道 `?mode=getconfig` 返回的服务端配置。 */
109
+ export interface ServerConfig {
110
+ version: string;
111
+ systemMode: string;
112
+ sprintConcept: string;
113
+ requestType: string;
114
+ requestFix: string;
115
+ moduleVar: string;
116
+ methodVar: string;
117
+ viewVar: string;
118
+ sessionVar: string;
119
+ }
120
+ /** 保存到本地 profile 中的客户端偏好配置。 */
121
+ export interface ZentaoProfileConfig {
122
+ /** 默认输出格式,供 CLI 等上层应用复用。 */
123
+ defaultOutputFormat?: 'markdown' | 'json' | 'raw';
124
+ /** 界面语言。 */
125
+ lang?: string;
126
+ /** 默认分页大小。 */
127
+ defaultRecPerPage?: number;
128
+ /** 是否跳过 TLS 证书验证;仅 Node.js 运行时支持。 */
129
+ insecure?: boolean;
130
+ /** 是否将对象属性中的 HTML 转换为 Markdown。 */
131
+ htmlToMarkdown?: boolean;
132
+ /** 请求超时时间,单位毫秒。 */
133
+ timeout?: number;
134
+ /** 是否在批量操作出错时停止执行后续操作。 */
135
+ batchFailFast?: boolean;
136
+ /** JSON 格式化时是否添加缩进。 */
137
+ jsonPretty?: boolean;
138
+ /** 模块级分页偏好。 */
139
+ pagers?: Record<string, number>;
140
+ /** 允许上层应用保存自定义配置。 */
141
+ [key: string]: unknown;
142
+ }
143
+ /** 本地持久化的禅道账号 profile。 */
144
+ export interface ZentaoProfile {
145
+ /** 禅道站点根地址,不包含 `/api.php/v2`。 */
146
+ server: string;
147
+ /** 用户账号。 */
148
+ account: string;
149
+ /** 禅道 API Token。 */
150
+ token: string;
151
+ /** 登录验证通过后得到的用户信息。 */
152
+ user?: Record<string, unknown>;
153
+ /** 登录时间。 */
154
+ loginTime?: string;
155
+ /** 最后使用时间。 */
156
+ lastUsedTime?: string;
157
+ /** 禅道服务端配置。 */
158
+ serverConfig?: ServerConfig;
159
+ /** 客户端自定义配置。 */
160
+ config?: ZentaoProfileConfig;
161
+ /** 允许上层应用保存额外字段。 */
162
+ [key: string]: unknown;
163
+ }
164
+ /** 运行时返回的 profile,会额外带上 `account@server` 形式的 key。 */
165
+ export interface ZentaoProfileRecord extends ZentaoProfile {
166
+ key: string;
167
+ }
168
+ /** 本地 profile 存储文件或浏览器 localStorage 中的 JSON 结构。 */
169
+ export interface ZentaoProfilesStore {
170
+ /** 当前使用的 profile key。 */
171
+ currentProfile?: string;
172
+ /** 保存的 profile 列表。 */
173
+ profiles: ZentaoProfile[];
174
+ }
175
+ /** 模块动作类型:基础 CRUD 或自定义动作。 */
176
+ export type ModuleActionType = 'list' | 'get' | 'create' | 'update' | 'delete' | 'action';
177
+ /** 模块动作使用的 HTTP 方法;兼容生成定义中的小写方法。 */
178
+ export type ModuleActionMethod = HttpMethod | Lowercase<HttpMethod>;
179
+ /** 模块动作名称,允许除基础动作外的自定义名称。 */
180
+ export type ModuleActionName = ModuleActionType | (string & {});
181
+ /** 模块动作参数可选项。 */
182
+ export type ModuleActionParamOption = {
183
+ value: unknown;
184
+ label: string;
185
+ };
186
+ /** 模块动作的查询参数定义。 */
187
+ export interface ModuleActionParam {
188
+ /** 参数名称。 */
189
+ name: string;
190
+ /** 参数说明。 */
191
+ description?: string;
192
+ /** 是否必填。 */
193
+ required?: boolean;
194
+ /** 未显式传入时使用的默认值。 */
195
+ defaultValue?: unknown;
196
+ /** 参数值类型,用于基础类型转换。 */
197
+ type?: 'string' | 'number' | 'boolean';
198
+ /** 参数可选值。 */
199
+ options?: ModuleActionParamOption[];
200
+ }
201
+ /** 模块动作结果形态。 */
202
+ export type ModuleActionResultType = 'text' | 'object' | 'list';
203
+ /** 列表分页信息别名。 */
204
+ export type ListPagerInfo = Pager;
205
+ /** 模块动作请求体定义。 */
206
+ export interface ModuleActionRequestBody {
207
+ /** 请求体类型。 */
208
+ type?: 'object' | 'string';
209
+ /** 请求体是否必填。 */
210
+ required?: boolean;
211
+ /** OpenAPI 风格 schema,用于从 params 组装 body。 */
212
+ schema: Record<string, unknown>;
213
+ /** 请求体示例。 */
214
+ example?: unknown;
215
+ }
216
+ /** 模块动作响应定义。 */
217
+ export interface ModuleActionResponse {
218
+ /** 响应说明。 */
219
+ description?: string;
220
+ /** 响应 schema。 */
221
+ schema: Record<string, unknown>;
222
+ /** 响应示例。 */
223
+ example?: unknown;
224
+ }
225
+ /** 模块动作渲染目标类型;保留给 CLI 等上层应用使用。 */
226
+ export type ModuleActionResultRenderType = 'markdown' | 'json' | 'raw';
227
+ /** 模块动作自定义渲染函数类型;SDK 本身不直接渲染终端输出。 */
228
+ export type ModuleActionResultRender = (result: unknown, type: ModuleActionResultRenderType, action: ModuleAction) => string;
229
+ /** 从原始响应中提取分页字段时使用的字段映射。 */
230
+ export interface ModuleActionPagerGetterMap {
231
+ /** 当前页码字段名。 */
232
+ pageID: string;
233
+ /** 每页记录数字段名。 */
234
+ recPerPage: string;
235
+ /** 总记录数字段名。 */
236
+ recTotal: string;
237
+ }
238
+ /** 禅道模块中的单个 API 动作定义。 */
239
+ export interface ModuleAction {
240
+ /** 动作名称,例如 `list`、`get`、`close`。 */
241
+ name: ModuleActionName;
242
+ /** 动作类型,决定高阶 request 的路径/参数解析策略。 */
243
+ type: ModuleActionType;
244
+ /** 面向用户展示的动作名称。 */
245
+ display?: string;
246
+ /** 动作说明。 */
247
+ description?: string;
248
+ /** HTTP 方法。 */
249
+ method: ModuleActionMethod;
250
+ /** API 路径模板,可包含 `{productID}` 等路径参数。 */
251
+ path: string;
252
+ /** 路径参数定义;字符串为说明,对象可携带默认值和可选项。 */
253
+ pathParams?: Record<string, string | Omit<ModuleActionParam, 'name'>>;
254
+ /** 查询参数定义。 */
255
+ params?: ModuleActionParam[];
256
+ /** 请求体定义。 */
257
+ requestBody?: ModuleActionRequestBody;
258
+ /** 结果形态。 */
259
+ resultType: ModuleActionResultType;
260
+ /** 从原始响应中提取分页信息的位置或函数。 */
261
+ pagerGetter?: string | ModuleActionPagerGetterMap | ((data: unknown, params: Record<string, unknown>) => ListPagerInfo);
262
+ /** 从原始响应中提取业务数据的位置或函数。 */
263
+ resultGetter?: string | Record<string, string> | ((data: unknown, params: Record<string, unknown>) => unknown);
264
+ /** 供上层应用使用的渲染配置。 */
265
+ render?: string | ModuleActionResultRender | Record<ModuleActionResultRenderType, ModuleActionResultRender>;
266
+ }
267
+ /** 内置模块名称,同时允许用户扩展自定义模块名。 */
268
+ export type ModuleName = 'user' | 'program' | 'product' | 'project' | 'execution' | 'productplan' | 'story' | 'epic' | 'requirement' | 'bug' | 'testcase' | 'task' | 'feedback' | 'ticket' | 'system' | 'build' | 'testtask' | 'release' | 'file' | (string & {});
269
+ /** 禅道模块定义,由多个动作组成。 */
270
+ export interface ModuleDefinition {
271
+ /** 模块名称,例如 `product`、`bug`。 */
272
+ name: ModuleName;
273
+ /** 面向用户展示的模块名称。 */
274
+ display?: string;
275
+ /** 模块说明。 */
276
+ description?: string;
277
+ /** 模块支持的动作集合。 */
278
+ actions: ModuleAction[];
279
+ }
280
+ /** 将模块动作和参数解析后的可执行请求描述。 */
281
+ export interface ResolvedModuleCommand {
282
+ /** 模块名称。 */
283
+ module: string;
284
+ /** 匹配到的动作定义。 */
285
+ action: ModuleAction;
286
+ /** 原始调用参数。 */
287
+ params: Record<string, unknown>;
288
+ /** 已替换路径参数后的 API 路径。 */
289
+ path: string;
290
+ /** 已组装的查询参数。 */
291
+ query?: Record<string, string | number>;
292
+ /** 已组装的请求体。 */
293
+ data?: Record<string, unknown>;
294
+ /** 从 `id` 或 `{module}ID` 推断出的对象 ID。 */
295
+ id?: number;
296
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ /** 判断值是否为普通对象(非数组、非 null)。 */
2
+ export declare function isRecord(value: unknown): value is Record<string, unknown>;
3
+ /** 将用户传入的站点根地址规范化,兼容误传入 `/api.php/v2` 的场景。 */
4
+ export declare function normalizeSiteUrl(baseUrl: string): string;
5
+ export declare function getNestedValue(obj: unknown, path: string): unknown;
6
+ export declare function asArray<T>(value: T | T[]): T[];
@@ -0,0 +1,26 @@
1
+ import { ZentaoError } from '../misc/errors.js';
2
+ /** 判断值是否为普通对象(非数组、非 null)。 */
3
+ export function isRecord(value) {
4
+ return Boolean(value) && typeof value === 'object' && !Array.isArray(value);
5
+ }
6
+ /** 将用户传入的站点根地址规范化,兼容误传入 `/api.php/v2` 的场景。 */
7
+ export function normalizeSiteUrl(baseUrl) {
8
+ const trimmed = baseUrl.trim().replace(/\/+$/, '');
9
+ if (!trimmed)
10
+ throw new ZentaoError('E_INVALID_BASE_URL');
11
+ return trimmed.replace(/\/api\.php\/v2$/i, '');
12
+ }
13
+ export function getNestedValue(obj, path) {
14
+ const keys = path.split('.');
15
+ let current = obj;
16
+ for (const key of keys) {
17
+ if (current === null || current === undefined || typeof current !== 'object') {
18
+ return undefined;
19
+ }
20
+ current = current[key];
21
+ }
22
+ return current;
23
+ }
24
+ export function asArray(value) {
25
+ return Array.isArray(value) ? value : [value];
26
+ }
@@ -0,0 +1,2 @@
1
+ export declare const BUILD: string;
2
+ export declare const VERSION: string;
@@ -0,0 +1,4 @@
1
+ const fallbackBuild = "2026-05-11T13:46:14.715Z";
2
+ const fallbackVersion = "0.2.0-beta.2";
3
+ export const BUILD = typeof __ZENTAO_API_BUILD__ === 'string' ? __ZENTAO_API_BUILD__ : fallbackBuild;
4
+ export const VERSION = typeof __ZENTAO_API_VERSION__ === 'string' ? __ZENTAO_API_VERSION__ : fallbackVersion;
package/package.json CHANGED
@@ -1,93 +1,69 @@
1
1
  {
2
2
  "name": "zentao-api",
3
- "description": "JavaScript client libary for ZenTao SDK http://www.zentao.net/book/api/setting-369.html",
4
- "version": "0.1.0",
5
- "author": "Catouse <catouse@gmail.com> https://github.com/catouse",
6
- "homepage": "https://github.com/catouse/zentao-api#readme",
3
+ "version": "0.2.0-beta.2",
4
+ "type": "module",
5
+ "description": "Browser and Node.js SDK for ZenTao API",
7
6
  "license": "MIT",
8
- "main": "dist/index.js",
9
- "typings": "dist/index.d.ts",
7
+ "author": "Sun Hao <sunhao@chandao.com>",
10
8
  "repository": {
11
9
  "type": "git",
12
- "url": "git+https://github.com/catouse/zentao-api.git"
10
+ "url": "https://github.com/catouse/zentao-api"
13
11
  },
14
- "bugs": {
15
- "url": "https://github.com/catouse/zentao-api/issues"
12
+ "keywords": [
13
+ "zentao",
14
+ "禅道",
15
+ "api",
16
+ "sdk",
17
+ "browser"
18
+ ],
19
+ "main": "./dist/index.js",
20
+ "types": "./dist/index.d.ts",
21
+ "exports": {
22
+ ".": {
23
+ "types": "./dist/index.d.ts",
24
+ "import": "./dist/index.js"
25
+ },
26
+ "./browser": "./dist/browser/zentao-api.global.js",
27
+ "./package.json": "./package.json"
16
28
  },
17
29
  "files": [
18
30
  "dist",
19
- "src"
31
+ "README.md",
32
+ "LICENSE"
20
33
  ],
21
- "keywords": [
22
- "ZenTao",
23
- "API",
24
- "Client",
25
- "SDK"
26
- ],
27
- "engines": {
28
- "node": ">=10"
29
- },
30
34
  "scripts": {
31
- "start": "tsdx watch",
32
- "build": "tsdx build",
33
- "test": "tsdx test",
34
- "lint": "tsdx lint",
35
- "prepare": "tsdx build",
36
- "size": "size-limit",
37
- "analyze": "size-limit --why",
38
- "doc": "typedoc --out docs/ --theme default --excludePrivate --excludeProtected --excludeExternals src/"
35
+ "test": "bun test",
36
+ "test:real": "bun ./tests/real-env-runner.ts",
37
+ "test:coverage": "bun test --coverage",
38
+ "typecheck": "tsc --noEmit",
39
+ "typecheck:tests": "tsc -p tsconfig.test.json --noEmit",
40
+ "registry:check": "bun run scripts/update-registry.ts --check",
41
+ "build": "rm -rf dist && tsc -p tsconfig.json && bun run scripts/build-browser.ts",
42
+ "smoke:node": "node scripts/smoke-node.mjs",
43
+ "smoke:package": "bun run scripts/smoke-package.ts",
44
+ "docs:reference": "typedoc",
45
+ "docs:zentao-api": "bun run scripts/generate-zentao-api-docs.ts",
46
+ "docs:generate": "bun run docs:reference && bun run docs:zentao-api",
47
+ "docs:dev": "bun run docs:generate && vitepress dev docs",
48
+ "docs:build": "bun run docs:generate && vitepress build docs",
49
+ "docs:preview": "bun run docs:build && vitepress preview docs",
50
+ "check": "bun run test:coverage && bun run typecheck && bun run typecheck:tests && bun run registry:check && bun run build && bun run smoke:node && bun run smoke:package",
51
+ "prepublishOnly": "bun run check"
39
52
  },
40
- "peerDependencies": {},
41
- "husky": {
42
- "hooks": {
43
- "pre-commit": "tsdx lint"
44
- }
45
- },
46
- "prettier": {
47
- "printWidth": 80,
48
- "semi": true,
49
- "tabWidth": 4,
50
- "singleQuote": true,
51
- "trailingComma": "es5",
52
- "bracketSpacing": false,
53
- "useTabs": false
53
+ "dependencies": {
54
+ "turndown": "^7.2.0"
54
55
  },
55
- "module": "dist/zentao-api.esm.js",
56
- "size-limit": [
57
- {
58
- "path": "dist/zentao-api.cjs.production.min.js",
59
- "limit": "10 KB"
60
- },
61
- {
62
- "path": "dist/zentao-api.esm.js",
63
- "limit": "10 KB"
64
- }
65
- ],
66
56
  "devDependencies": {
67
- "@size-limit/preset-small-lib": "^4.9.2",
68
- "@types/configstore": "^4.0.0",
69
- "@types/md5": "^2.3.0",
70
- "@typescript-eslint/eslint-plugin": "^4.17.0",
71
- "@typescript-eslint/parser": "^4.17.0",
72
- "husky": "^5.1.1",
73
- "size-limit": "^4.9.2",
74
- "tsdx": "^0.14.1",
75
- "tslib": "^2.1.0",
76
- "typedoc": "^0.20.30",
77
- "typescript": "^4.2.3"
57
+ "@types/bun": "^1.3.13",
58
+ "@types/node": "^24.10.0",
59
+ "@types/turndown": "^5.0.5",
60
+ "typedoc": "^0.28.19",
61
+ "typedoc-plugin-markdown": "^4.11.0",
62
+ "typedoc-vitepress-theme": "^1.1.2",
63
+ "typescript": "^5.7.0",
64
+ "vitepress": "^1.6.4"
78
65
  },
79
- "dependencies": {
80
- "axios": "^0.21.1",
81
- "configstore": "^5.0.1",
82
- "form-data": "^4.0.0",
83
- "kleur": "^4.1.4",
84
- "md5": "^2.3.0"
85
- },
86
- "resolutions": {
87
- "**/typescript": "^4.2.3",
88
- "**/@typescript-eslint/eslint-plugin": "^4.17.0",
89
- "**/@typescript-eslint/parser": "^4.17.0",
90
- "**/jest": "^26.6.3",
91
- "**/ts-jest": "^26.5.3"
66
+ "engines": {
67
+ "node": ">=18"
92
68
  }
93
69
  }
package/dist/types.d.ts DELETED
@@ -1,70 +0,0 @@
1
- import { Method } from 'axios';
2
- /**
3
- * 支持的禅道请求方式,影响 API 请求 URL 构建方式
4
- */
5
- export declare type ZentaoRequestType = 'PATH_INFO' | 'GET';
6
- /**
7
- * 禅道请求参数键值对
8
- */
9
- export declare type ZentaoRequestParamPair = any[];
10
- /**
11
- * 禅道请求参数
12
- */
13
- export declare type ZentaoRequestParams = Array<ZentaoRequestParamPair> | string[] | string | Record<string, any>;
14
- /**
15
- * 禅道 API 请求方式
16
- */
17
- export declare type ZentaoRequestMethod = Method;
18
- /**
19
- * 禅道 API 返回结果
20
- */
21
- export interface ZentaoApiResult {
22
- /**
23
- * 状态
24
- *
25
- * @remarks
26
- * 如果为 `0` 则表示操作请求失败,如果为 `1`,表示操作请求成功
27
- */
28
- status: 0 | 1;
29
- /**
30
- * 服务器返回的描述结果的文本
31
- */
32
- msg?: any;
33
- /**
34
- * 请求结果数据
35
- */
36
- result?: any;
37
- }
38
- /**
39
- * 禅道 API 初始化选项
40
- */
41
- export interface ZentaoOptions {
42
- /**
43
- * 禅道服务器地址
44
- */
45
- readonly url: string;
46
- /**
47
- * 登录账号
48
- */
49
- readonly account: string;
50
- /**
51
- * 登录密码
52
- */
53
- readonly password: string;
54
- /**
55
- * 请求形式
56
- */
57
- readonly accessMode?: ZentaoRequestType;
58
- /**
59
- * 是否将 token 存储到本地,如果设置为 `false`,则每次创建新的 `Zentao` 实例都会在首次调用 API 之前重新获取 Token
60
- */
61
- readonly preserveToken?: boolean;
62
- /**
63
- * 当前 `Zentao` 实例名称
64
- */
65
- readonly sessionName?: string;
66
- /**
67
- * 如果设置为 `true`,则会在控制台输出详细日志
68
- */
69
- readonly debug?: boolean;
70
- }
package/dist/utils.d.ts DELETED
@@ -1,93 +0,0 @@
1
- import { ZentaoRequestParamPair, ZentaoRequestParams } from './types';
2
- /**
3
- * 创建一个 Date 对象
4
- * @param {Date|number|String} [date=null] 用于创建 Date 对象的日期时间表达值,如果留空则创建当前系统时间对象
5
- * @return {Date} 日期时间对象
6
- * @function
7
- */
8
- export declare const createDate: (date: Date | number | string) => Date;
9
- /**
10
- * 格式化日期时间值为字符串
11
- * @remarks
12
- * 所有可用的格式化参数有:
13
- * - `yyyy`,例如:'2018',表示四位数字表示的年份
14
- * - `yy`,例如:'18',表示两位数字表示的年份
15
- * - `MM`,例如:'07',表示两位数字表示的月份,不足两位在起始用 0 填充
16
- * - `M`,例如:'10',表示一位或两位数字表示的月份
17
- * - `dd`,例如:'05',表示两位数字表示的日期,不足两位在起始用 0 填充
18
- * - `d`,例如:'5',表示一位或两位数字表示的日期
19
- * - `hh`,例如:'08',表示两位数字表示的小时,不足两位在起始用 0 填充
20
- * - `h`,例如:'8',表示一位或两位数字表示的小时
21
- * - `mm`,例如:'3',表示两位数字表示的分钟,不足两位在起始用 0 填充
22
- * - `m`,例如:'03',表示一位或两位数字表示的分钟
23
- * - `ss`,例如:'5',表示两位数字表示的秒数,不足两位在起始用 0 填充
24
- * - `s`,例如:'05',表示一位或两位数字表示的秒数
25
- * - `S`,例如:'236',表示毫秒数
26
- * - `SSS`,例如:'036',表示毫秒数,不足3位在起始用 0 填充
27
- * @summary 格式化日期时间值为字符串
28
- * @param {Date|number|string} date 要格式化的日期时间表达值
29
- * @param {string} [format='yyyy-MM-dd hh:ss'] 格式化字符串
30
- * @return {string} 日期时间格式化文本
31
- * @function
32
- */
33
- export declare const formatDate: (date: Date | number | string, format?: string) => string;
34
- /**
35
- * 格式化禅道地址
36
- * @param url 禅道地址
37
- * @returns 格式化后的禅道地址
38
- * @example
39
- * // 以下例子都返回 `http://demo.zentao.net/`
40
- * formatZentaoUrl('http://demo.zentao.net');
41
- * formatZentaoUrl('http://demo.zentao.net');
42
- * formatZentaoUrl('http://demo.zentao.net/index.php');
43
- * formatZentaoUrl('demo.zentao.net');
44
- */
45
- export declare function formatZentaoUrl(url: string): string;
46
- /**
47
- * 创建一个新的对象,仅保留给定的原始对象上给定的属性
48
- * @param object 给定的原始对象
49
- * @param fields 要保留属性名称列表
50
- * @returns 新的对象
51
- * @example
52
- * const obj = {a: 1, b: 2, c: 3, d: 4};
53
- * slimmingObject(obj, ['b', 'c']); // 返回 `{b: 2, c: 3}`
54
- */
55
- export declare function slimmingObject(object: any, fields: string[]): any;
56
- /**
57
- * 格式化请求参数定义
58
- * @param params 要格式化的参数定义
59
- * @returns 格式化后的参数列表
60
- * @example
61
- * // 下面返回:`[['foo', 'bar'], ['hello', 'world']]`
62
- * normalizeRequestParams([['foo', 'bar'], ['hello', 'world']]);
63
- *
64
- * // 下面返回:`[['foo', 'bar'], ['hello', 'world']]`
65
- * normalizeRequestParams('foo=bar&hello=world');
66
- *
67
- * // 下面返回:`[['foo', 'bar'], ['hello', 'world']]`
68
- * normalizeRequestParams({foo: 'bar', hello: 'world'});
69
- *
70
- * // 下面返回:`[['', 'bar'], ['', 'world']]`
71
- * normalizeRequestParams(['foo', 'bar']);
72
- *
73
- * // 下面返回:`[['foo', 'bar'], ['', 'world']]`
74
- * normalizeRequestParams([['foo', 'bar'], 'bar']);
75
- */
76
- export declare function normalizeRequestParams(params?: ZentaoRequestParams): ZentaoRequestParamPair[];
77
- /**
78
- * 合并两个请求参数定义,并返回合并且格式化后的定义
79
- * @param params 参数定义
80
- * @param otherParams 要合并的其他参数定义
81
- * @returns 合并后的参数列表
82
- * @example
83
- * const params1 = {foo: 'bar', hello: 'world'};
84
- * const params2 = 'answer='42'';
85
- * const params3 = [['foo', 'ter'], ['say', 'hi']];
86
- *
87
- * // 以下返回 `[['foo', 'bar'], ['answer', '42']]`
88
- * mergeRequestParams(params1, params2);
89
- *
90
- * // 以下返回 `[['foo', ['bar', 'ter']], ['answer', '42'], ['hello', 'world'], ['say', 'hi']]`
91
- * mergeRequestParams(params1, params2, params3);
92
- */
93
- export declare function mergeRequestParams(params: ZentaoRequestParams, ...otherParams: ZentaoRequestParams[]): ZentaoRequestParamPair[];