zentao-api 0.1.0 → 0.2.0-beta.1

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 (51) hide show
  1. package/LICENSE +2 -2
  2. package/README.md +103 -147
  3. package/dist/browser/zentao-api.global.js +1 -0
  4. package/dist/browser.d.ts +1 -0
  5. package/dist/browser.js +1 -0
  6. package/dist/client/index.d.ts +37 -0
  7. package/dist/client/index.js +149 -0
  8. package/dist/index.d.ts +7 -4
  9. package/dist/index.js +6 -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 +6 -0
  13. package/dist/misc/environment.js +30 -0
  14. package/dist/misc/errors.d.ts +25 -0
  15. package/dist/misc/errors.js +35 -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 +129 -0
  22. package/dist/modules/resolve.d.ts +7 -0
  23. package/dist/modules/resolve.js +196 -0
  24. package/dist/request/index.d.ts +7 -0
  25. package/dist/request/index.js +65 -0
  26. package/dist/types/index.d.ts +235 -0
  27. package/dist/types/index.js +1 -0
  28. package/dist/utils/index.d.ts +2 -0
  29. package/dist/utils/index.js +14 -0
  30. package/dist/version.d.ts +2 -0
  31. package/dist/version.js +4 -0
  32. package/package.json +43 -77
  33. package/dist/types.d.ts +0 -70
  34. package/dist/utils.d.ts +0 -93
  35. package/dist/zentao-api.cjs.development.js +0 -3619
  36. package/dist/zentao-api.cjs.development.js.map +0 -1
  37. package/dist/zentao-api.cjs.production.min.js +0 -2
  38. package/dist/zentao-api.cjs.production.min.js.map +0 -1
  39. package/dist/zentao-api.esm.js +0 -3611
  40. package/dist/zentao-api.esm.js.map +0 -1
  41. package/dist/zentao-config.d.ts +0 -93
  42. package/dist/zentao-request-builder.d.ts +0 -120
  43. package/dist/zentao.d.ts +0 -175
  44. package/dist/zentao12.d.ts +0 -676
  45. package/src/index.ts +0 -5
  46. package/src/types.ts +0 -88
  47. package/src/utils.ts +0 -216
  48. package/src/zentao-config.ts +0 -150
  49. package/src/zentao-request-builder.ts +0 -227
  50. package/src/zentao.ts +0 -596
  51. package/src/zentao12.ts +0 -1272
@@ -0,0 +1,14 @@
1
+ export function getNestedValue(obj, path) {
2
+ const keys = path.split('.');
3
+ let current = obj;
4
+ for (const key of keys) {
5
+ if (current === null || current === undefined || typeof current !== 'object') {
6
+ return undefined;
7
+ }
8
+ current = current[key];
9
+ }
10
+ return current;
11
+ }
12
+ export function asArray(value) {
13
+ return Array.isArray(value) ? value : [value];
14
+ }
@@ -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-10T12:45:54.888Z";
2
+ const fallbackVersion = "0.2.0-beta.1";
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,59 @@
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.1",
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.git"
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
+ "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",
45
+ "prepublishOnly": "bun run check"
39
46
  },
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
47
+ "dependencies": {
48
+ "turndown": "^7.2.0"
54
49
  },
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
50
  "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"
51
+ "@types/bun": "^1.3.13",
52
+ "@types/node": "^24.10.0",
53
+ "@types/turndown": "^5.0.5",
54
+ "typescript": "^5.7.0"
78
55
  },
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"
56
+ "engines": {
57
+ "node": ">=18"
92
58
  }
93
- }
59
+ }
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[];