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.
- package/LICENSE +2 -2
- package/README.md +221 -131
- package/dist/browser/zentao-api.global.js +2 -0
- package/dist/browser.d.ts +1 -0
- package/dist/browser.js +1 -0
- package/dist/client/index.d.ts +39 -0
- package/dist/client/index.js +172 -0
- package/dist/index.d.ts +8 -4
- package/dist/index.js +7 -8
- package/dist/misc/browser-global.d.ts +1 -0
- package/dist/misc/browser-global.js +8 -0
- package/dist/misc/environment.d.ts +8 -0
- package/dist/misc/environment.js +124 -0
- package/dist/misc/errors.d.ts +30 -0
- package/dist/misc/errors.js +40 -0
- package/dist/misc/global-options.d.ts +5 -0
- package/dist/misc/global-options.js +9 -0
- package/dist/modules/generated.d.ts +8 -0
- package/dist/modules/generated.js +4226 -0
- package/dist/modules/registry.d.ts +22 -0
- package/dist/modules/registry.js +142 -0
- package/dist/modules/resolve.d.ts +7 -0
- package/dist/modules/resolve.js +206 -0
- package/dist/profiles/index.d.ts +14 -0
- package/dist/profiles/index.js +205 -0
- package/dist/request/index.d.ts +7 -0
- package/dist/request/index.js +65 -0
- package/dist/types/index.d.ts +296 -0
- package/dist/types/index.js +1 -0
- package/dist/utils/index.d.ts +6 -0
- package/dist/utils/index.js +26 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.js +4 -0
- package/package.json +52 -76
- package/dist/types.d.ts +0 -70
- package/dist/utils.d.ts +0 -93
- package/dist/zentao-api.cjs.development.js +0 -3619
- package/dist/zentao-api.cjs.development.js.map +0 -1
- package/dist/zentao-api.cjs.production.min.js +0 -2
- package/dist/zentao-api.cjs.production.min.js.map +0 -1
- package/dist/zentao-api.esm.js +0 -3611
- package/dist/zentao-api.esm.js.map +0 -1
- package/dist/zentao-config.d.ts +0 -93
- package/dist/zentao-request-builder.d.ts +0 -120
- package/dist/zentao.d.ts +0 -175
- package/dist/zentao12.d.ts +0 -676
- package/src/index.ts +0 -5
- package/src/types.ts +0 -88
- package/src/utils.ts +0 -216
- package/src/zentao-config.ts +0 -150
- package/src/zentao-request-builder.ts +0 -227
- package/src/zentao.ts +0 -596
- package/src/zentao12.ts +0 -1272
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import { Method } from 'axios';
|
|
2
|
-
import { ZentaoApiResult, ZentaoRequestParams } from './types';
|
|
3
|
-
import Zentao from './zentao';
|
|
4
|
-
/**
|
|
5
|
-
* 禅道请求构建类
|
|
6
|
-
* @internal
|
|
7
|
-
*/
|
|
8
|
-
export default class ZentaoRequestBuilder {
|
|
9
|
-
/**
|
|
10
|
-
* 禅道请求实例
|
|
11
|
-
*/
|
|
12
|
-
readonly zentao: Zentao;
|
|
13
|
-
/**
|
|
14
|
-
* 模块名
|
|
15
|
-
*/
|
|
16
|
-
readonly moduleName: string;
|
|
17
|
-
_methodName: string;
|
|
18
|
-
_params?: ZentaoRequestParams;
|
|
19
|
-
_data?: string | Record<string, any>;
|
|
20
|
-
_fields?: string[];
|
|
21
|
-
_resultConvertor?: (remoteData: any, result: ZentaoApiResult) => ZentaoApiResult;
|
|
22
|
-
_url?: string;
|
|
23
|
-
_name?: string;
|
|
24
|
-
/**
|
|
25
|
-
* 创建一个禅道请求构建实例
|
|
26
|
-
* @param zentao 禅道请求实例
|
|
27
|
-
* @param moduleName 方法名
|
|
28
|
-
* @param methodName 模块名
|
|
29
|
-
* @param params 请求参数
|
|
30
|
-
*/
|
|
31
|
-
constructor(zentao: Zentao, moduleName: string, methodName?: string, params?: ZentaoRequestParams);
|
|
32
|
-
/**
|
|
33
|
-
* 获取方法名
|
|
34
|
-
*/
|
|
35
|
-
get methodName(): string;
|
|
36
|
-
/**
|
|
37
|
-
* 获取请求参数
|
|
38
|
-
*/
|
|
39
|
-
get params(): string | import("./types").ZentaoRequestParamPair[] | string[] | Record<string, any> | undefined;
|
|
40
|
-
/**
|
|
41
|
-
* 获取请求数据
|
|
42
|
-
*/
|
|
43
|
-
get data(): string | Record<string, any> | undefined;
|
|
44
|
-
/**
|
|
45
|
-
* 获取结果属性过滤列表
|
|
46
|
-
*/
|
|
47
|
-
get fields(): string[] | undefined;
|
|
48
|
-
/**
|
|
49
|
-
* 获取请求名称
|
|
50
|
-
*/
|
|
51
|
-
get name(): string | undefined;
|
|
52
|
-
/**
|
|
53
|
-
* 获取自定义请求地址
|
|
54
|
-
*/
|
|
55
|
-
get url(): string | undefined;
|
|
56
|
-
/**
|
|
57
|
-
* 获取结果转换函数
|
|
58
|
-
*/
|
|
59
|
-
get resultConvertor(): ((remoteData: any, result: ZentaoApiResult) => ZentaoApiResult) | undefined;
|
|
60
|
-
/**
|
|
61
|
-
* 设置方法名
|
|
62
|
-
* @param name 方法名
|
|
63
|
-
* @returns 禅道请求构建实例自身
|
|
64
|
-
*/
|
|
65
|
-
method(name: string): ZentaoRequestBuilder;
|
|
66
|
-
/**
|
|
67
|
-
* 设置方法名,是方法 `method(name)` 的别名
|
|
68
|
-
* @param name 方法名
|
|
69
|
-
* @returns 禅道请求构建实例自身
|
|
70
|
-
* @alias method
|
|
71
|
-
*/
|
|
72
|
-
f(name: string): ZentaoRequestBuilder;
|
|
73
|
-
/**
|
|
74
|
-
* 设置请求参数
|
|
75
|
-
* @param params 要设置的参数
|
|
76
|
-
* @returns 禅道请求构建实例自身
|
|
77
|
-
*/
|
|
78
|
-
withParams(params: ZentaoRequestParams): ZentaoRequestBuilder;
|
|
79
|
-
/**
|
|
80
|
-
* 追加请求参数
|
|
81
|
-
* @param params 要追加的参数
|
|
82
|
-
* @returns 禅道请求构建实例自身
|
|
83
|
-
*/
|
|
84
|
-
appendParams(params: ZentaoRequestParams): ZentaoRequestBuilder;
|
|
85
|
-
/**
|
|
86
|
-
* 设置请求名称
|
|
87
|
-
* @param name 名称
|
|
88
|
-
* @returns 禅道请求构建实例自身
|
|
89
|
-
*/
|
|
90
|
-
named(name: string): ZentaoRequestBuilder;
|
|
91
|
-
/**
|
|
92
|
-
* 设置结果转换函数
|
|
93
|
-
* @param converter 结果转换函数
|
|
94
|
-
* @returns 禅道请求构建实例自身
|
|
95
|
-
*/
|
|
96
|
-
useConverter(converter: (remoteData: any, result: ZentaoApiResult) => ZentaoApiResult): ZentaoRequestBuilder;
|
|
97
|
-
/**
|
|
98
|
-
* 过滤需要返回的属性列表
|
|
99
|
-
* @param fields 设置仅返回的属性名称列表
|
|
100
|
-
* @returns 禅道请求构建实例自身
|
|
101
|
-
*/
|
|
102
|
-
filterFields(...fields: Array<string | string[] | undefined>): ZentaoRequestBuilder;
|
|
103
|
-
/**
|
|
104
|
-
* 发起 GET 请求
|
|
105
|
-
* @returns 请求结果
|
|
106
|
-
*/
|
|
107
|
-
get(): Promise<ZentaoApiResult>;
|
|
108
|
-
/**
|
|
109
|
-
* 发起 POST 请求
|
|
110
|
-
* @param data 要提交的数据
|
|
111
|
-
* @returns 请求结果
|
|
112
|
-
*/
|
|
113
|
-
post(data?: string | Record<string, any>): Promise<ZentaoApiResult>;
|
|
114
|
-
/**
|
|
115
|
-
* 发起 HTTP 请求,可以指定请求方式
|
|
116
|
-
* @param method 请求方式,默认为 GET
|
|
117
|
-
* @returns 请求结果
|
|
118
|
-
*/
|
|
119
|
-
request(method?: Method): Promise<ZentaoApiResult>;
|
|
120
|
-
}
|
package/dist/zentao.d.ts
DELETED
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
import { AxiosResponse } from 'axios';
|
|
2
|
-
import { ZentaoApiResult, ZentaoOptions, ZentaoRequestMethod, ZentaoRequestParamPair, ZentaoRequestParams, ZentaoRequestType } from './types';
|
|
3
|
-
import ZentaoConfig from './zentao-config';
|
|
4
|
-
import ZentaoRequestBuilder from './zentao-request-builder';
|
|
5
|
-
/**
|
|
6
|
-
* 禅道请求类
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* import { Zentao } from 'zentao-api';
|
|
10
|
-
* const zentao = new Zentao({
|
|
11
|
-
* url: 'https://pro.demo.zentao.net/', account: 'demo', password: '123456'
|
|
12
|
-
* });
|
|
13
|
-
* // TODO: 使用 zentao 调用其他 API
|
|
14
|
-
*/
|
|
15
|
-
export default class Zentao {
|
|
16
|
-
/**
|
|
17
|
-
* 当前服务器和登录账号标识字符串
|
|
18
|
-
*/
|
|
19
|
-
private readonly _identifier;
|
|
20
|
-
/**
|
|
21
|
-
* 是否将 token 存储到本地,如果设置为 `false`,则每次创建新的 `Zentao` 实例都会在首次调用 API 之前重新获取 Token
|
|
22
|
-
*/
|
|
23
|
-
private readonly _preserveToken;
|
|
24
|
-
/**
|
|
25
|
-
* 当前实例名称
|
|
26
|
-
*/
|
|
27
|
-
private readonly _sessionName;
|
|
28
|
-
/**
|
|
29
|
-
* 禅道服务器地址
|
|
30
|
-
*/
|
|
31
|
-
private readonly _url;
|
|
32
|
-
/**
|
|
33
|
-
* 登录账号
|
|
34
|
-
*/
|
|
35
|
-
private readonly _account;
|
|
36
|
-
/**
|
|
37
|
-
* 登录密码
|
|
38
|
-
*/
|
|
39
|
-
private readonly _password;
|
|
40
|
-
/**
|
|
41
|
-
* 如果设置为 `true`,则会在控制台输出详细日志
|
|
42
|
-
*/
|
|
43
|
-
private _debug;
|
|
44
|
-
/**
|
|
45
|
-
* 禅道配置
|
|
46
|
-
*/
|
|
47
|
-
private _config?;
|
|
48
|
-
/**
|
|
49
|
-
* 本地存储管理对象
|
|
50
|
-
*/
|
|
51
|
-
private _store?;
|
|
52
|
-
/**
|
|
53
|
-
* 用户指定的请求方式
|
|
54
|
-
*/
|
|
55
|
-
private _userRequestType?;
|
|
56
|
-
/**
|
|
57
|
-
* 构造一个禅道 API 请求对象
|
|
58
|
-
* @param {ZentaoOptions} [options] 选项,用于指定服务器地址、账号和密码以及 API 调用相关设置
|
|
59
|
-
* @example
|
|
60
|
-
* import { Zentao } from 'zentao-api';
|
|
61
|
-
* const zentao = new Zentao({
|
|
62
|
-
* url: 'https://pro.demo.zentao.net/', // 禅道服务器地址
|
|
63
|
-
* account: 'demo', // 用户账号
|
|
64
|
-
* password: '123456', // 用户密码
|
|
65
|
-
* accessMode: 'GET', // 请求方式
|
|
66
|
-
* preserveToken: true, // 是否将 token 存储到本地,如果设置为 `false`,则每次创建新的 `Zentao` 实例都会在首次调用 API 之前重新获取 Token
|
|
67
|
-
* debug: true, // 如果设置为 `true`,则会在控制台输出详细日志
|
|
68
|
-
* });
|
|
69
|
-
* // TODO: 使用 zentao 调用其他 API
|
|
70
|
-
*/
|
|
71
|
-
constructor(options: ZentaoOptions);
|
|
72
|
-
/**
|
|
73
|
-
* 禅道服务器地址
|
|
74
|
-
*/
|
|
75
|
-
get url(): string;
|
|
76
|
-
/**
|
|
77
|
-
* 当前实例名称
|
|
78
|
-
*/
|
|
79
|
-
get sessionName(): string;
|
|
80
|
-
/**
|
|
81
|
-
* 当前服务器和账号标识
|
|
82
|
-
*/
|
|
83
|
-
get identifier(): string;
|
|
84
|
-
/**
|
|
85
|
-
* 当前用户账号
|
|
86
|
-
*/
|
|
87
|
-
get account(): string;
|
|
88
|
-
/**
|
|
89
|
-
* 登录密码
|
|
90
|
-
*/
|
|
91
|
-
get password(): string;
|
|
92
|
-
/**
|
|
93
|
-
* 请求方式
|
|
94
|
-
*/
|
|
95
|
-
get requestType(): ZentaoRequestType;
|
|
96
|
-
/**
|
|
97
|
-
* 当前用于验证的 Token 字符串
|
|
98
|
-
*/
|
|
99
|
-
get token(): string;
|
|
100
|
-
/**
|
|
101
|
-
* 登录到禅道并更新用于请求 API 的 token,通常不需要手动调用此方法,在调用 API 时会自动判断 token 是否可用,如果不可用会自动调用此方法
|
|
102
|
-
*
|
|
103
|
-
* @returns 返回请求结果,当登录成功时,其中 `result` 字段为所登录的用户信息对象
|
|
104
|
-
* @example
|
|
105
|
-
* import { Zentao } from 'zentao-api';
|
|
106
|
-
* const zentao = new Zentao({
|
|
107
|
-
* url: 'https://pro.demo.zentao.net/', account: 'demo', password: '123456'
|
|
108
|
-
* });
|
|
109
|
-
* const result = await zentao.login();
|
|
110
|
-
* const user = result.result; // 获取当前登录的用户对象
|
|
111
|
-
* console.log('当前登录的用户名称为:', user.realname);
|
|
112
|
-
*/
|
|
113
|
-
login(): Promise<ZentaoApiResult>;
|
|
114
|
-
/**
|
|
115
|
-
* 获取禅道服务器配置
|
|
116
|
-
* @returns 禅道服务器配置
|
|
117
|
-
*/
|
|
118
|
-
fetchConfig(): Promise<ZentaoConfig>;
|
|
119
|
-
/**
|
|
120
|
-
* 根据模块名创建一个禅道请求构建实例
|
|
121
|
-
* @param moduleName 模块名
|
|
122
|
-
* @param methodName 方法名
|
|
123
|
-
* @param params 请求参数
|
|
124
|
-
* @returns 禅道请求构建实例
|
|
125
|
-
*/
|
|
126
|
-
module(moduleName: string, methodName?: string, params?: ZentaoRequestParams): ZentaoRequestBuilder;
|
|
127
|
-
/**
|
|
128
|
-
* 根据模块名创建一个禅道请求构建实例
|
|
129
|
-
* @param moduleName 模块名
|
|
130
|
-
* @param methodName 方法名
|
|
131
|
-
* @param params 请求参数
|
|
132
|
-
* @returns 禅道请求构建实例
|
|
133
|
-
* @alias module
|
|
134
|
-
*/
|
|
135
|
-
m(moduleName: string, methodName?: string, params?: ZentaoRequestParams): ZentaoRequestBuilder;
|
|
136
|
-
/**
|
|
137
|
-
* 向禅道服务器发起请求
|
|
138
|
-
* @param moduleName 模块名
|
|
139
|
-
* @param methodName 方法名
|
|
140
|
-
* @param options 其他请求选项
|
|
141
|
-
* @returns 请求结果
|
|
142
|
-
*/
|
|
143
|
-
request(moduleName: string, methodName?: string, options?: {
|
|
144
|
-
params?: ZentaoRequestParams;
|
|
145
|
-
data?: string | Record<string, any>;
|
|
146
|
-
name?: string;
|
|
147
|
-
method?: ZentaoRequestMethod;
|
|
148
|
-
url?: string;
|
|
149
|
-
resultConvertor?: (remoteData: any, result: ZentaoApiResult) => ZentaoApiResult;
|
|
150
|
-
fields?: string[];
|
|
151
|
-
}): Promise<ZentaoApiResult>;
|
|
152
|
-
/**
|
|
153
|
-
* 生成请求地址
|
|
154
|
-
* @param moduleName 模块名
|
|
155
|
-
* @param methodName 方法名
|
|
156
|
-
* @param params 其他参数
|
|
157
|
-
* @returns 请求地址
|
|
158
|
-
*/
|
|
159
|
-
createUrl(moduleName: string, methodName?: string, params?: ZentaoRequestParamPair[]): string;
|
|
160
|
-
/**
|
|
161
|
-
* 输出 API 请求日志
|
|
162
|
-
* @param name 名称
|
|
163
|
-
* @param atrributes 日志属性对象
|
|
164
|
-
* @param others 其他日志内容
|
|
165
|
-
*/
|
|
166
|
-
protected _log(name: string, atrributes: {
|
|
167
|
-
url?: string;
|
|
168
|
-
params?: ZentaoRequestParamPair[];
|
|
169
|
-
data?: string | Record<string, any>;
|
|
170
|
-
method?: string;
|
|
171
|
-
resp?: AxiosResponse;
|
|
172
|
-
result?: ZentaoApiResult;
|
|
173
|
-
error?: any;
|
|
174
|
-
}, ...others: any[]): void;
|
|
175
|
-
}
|