@reportportal/client-javascript 5.5.12 → 5.6.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.
- package/README.md +22 -0
- package/VERSION +1 -1
- package/build/commons/config.d.ts +5 -0
- package/build/commons/config.js +125 -0
- package/build/commons/config.js.map +1 -0
- package/build/commons/errors.d.ts +9 -0
- package/build/commons/errors.js +28 -0
- package/build/commons/errors.js.map +1 -0
- package/build/constants/events.d.ts +9 -0
- package/build/constants/events.js +14 -0
- package/build/constants/events.js.map +1 -0
- package/build/constants/index.d.ts +7 -0
- package/build/constants/index.js +19 -0
- package/build/constants/index.js.map +1 -0
- package/build/constants/launchModes.d.ts +4 -0
- package/build/constants/launchModes.js +9 -0
- package/build/constants/launchModes.js.map +1 -0
- package/build/constants/logLevels.d.ts +9 -0
- package/build/constants/logLevels.js +13 -0
- package/build/constants/logLevels.js.map +1 -0
- package/build/constants/mergeTypes.d.ts +4 -0
- package/build/constants/mergeTypes.js +9 -0
- package/build/constants/mergeTypes.js.map +1 -0
- package/build/constants/outputs.d.ts +2 -0
- package/build/constants/outputs.js +35 -0
- package/build/constants/outputs.js.map +1 -0
- package/build/constants/statuses.d.ts +14 -0
- package/build/constants/statuses.js +19 -0
- package/build/constants/statuses.js.map +1 -0
- package/build/constants/testItemTypes.d.ts +17 -0
- package/build/constants/testItemTypes.js +22 -0
- package/build/constants/testItemTypes.js.map +1 -0
- package/build/helpers.d.ts +22 -0
- package/build/helpers.js +110 -0
- package/build/helpers.js.map +1 -0
- package/build/logger.d.ts +2 -0
- package/build/logger.js +28 -0
- package/build/logger.js.map +1 -0
- package/build/models/common.d.ts +37 -0
- package/build/models/common.js +3 -0
- package/build/models/common.js.map +1 -0
- package/build/models/config.d.ts +97 -0
- package/build/models/config.js +3 -0
- package/build/models/config.js.map +1 -0
- package/build/models/index.d.ts +5 -0
- package/build/models/index.js +22 -0
- package/build/models/index.js.map +1 -0
- package/build/models/reporting.d.ts +11 -0
- package/build/models/reporting.js +3 -0
- package/build/models/reporting.js.map +1 -0
- package/build/models/requests.d.ts +84 -0
- package/build/models/requests.js +3 -0
- package/build/models/requests.js.map +1 -0
- package/build/models/responses.d.ts +87 -0
- package/build/models/responses.js +3 -0
- package/build/models/responses.js.map +1 -0
- package/build/oauth.d.ts +42 -0
- package/build/oauth.js +182 -0
- package/build/oauth.js.map +1 -0
- package/build/pjson.d.ts +2 -0
- package/build/pjson.js +28 -0
- package/build/pjson.js.map +1 -0
- package/build/proxyHelper.d.ts +28 -0
- package/build/proxyHelper.js +173 -0
- package/build/proxyHelper.js.map +1 -0
- package/build/publicReportingAPI.d.ts +37 -0
- package/build/publicReportingAPI.js +56 -0
- package/build/publicReportingAPI.js.map +1 -0
- package/build/report-portal-client.d.ts +99 -0
- package/build/report-portal-client.js +607 -0
- package/build/report-portal-client.js.map +1 -0
- package/build/rest.d.ts +23 -0
- package/build/rest.js +205 -0
- package/build/rest.js.map +1 -0
- package/build/statistics/client-id.d.ts +1 -0
- package/build/statistics/client-id.js +73 -0
- package/build/statistics/client-id.js.map +1 -0
- package/build/statistics/constants.d.ts +11 -0
- package/build/statistics/constants.js +52 -0
- package/build/statistics/constants.js.map +1 -0
- package/build/statistics/statistics.d.ts +19 -0
- package/build/statistics/statistics.js +57 -0
- package/build/statistics/statistics.js.map +1 -0
- package/constants.d.ts +1 -0
- package/constants.js +1 -0
- package/helpers.d.ts +2 -0
- package/helpers.js +1 -0
- package/models.d.ts +1 -0
- package/package.json +82 -16
- package/publicReportingAPI.d.ts +2 -0
- package/publicReportingAPI.js +1 -0
- package/index.d.ts +0 -443
- package/lib/commons/config.js +0 -133
- package/lib/commons/errors.js +0 -29
- package/lib/constants/events.js +0 -11
- package/lib/constants/outputs.js +0 -13
- package/lib/constants/statuses.js +0 -12
- package/lib/helpers.js +0 -111
- package/lib/logger.js +0 -41
- package/lib/oauth.js +0 -226
- package/lib/proxyHelper.js +0 -232
- package/lib/publicReportingAPI.js +0 -92
- package/lib/report-portal-client.js +0 -905
- package/lib/rest.js +0 -218
- package/statistics/client-id.js +0 -46
- package/statistics/constants.js +0 -49
- package/statistics/statistics.js +0 -63
package/index.d.ts
DELETED
|
@@ -1,443 +0,0 @@
|
|
|
1
|
-
declare module '@reportportal/client-javascript' {
|
|
2
|
-
/**
|
|
3
|
-
* OAuth 2.0 configuration for password grant flow.
|
|
4
|
-
*/
|
|
5
|
-
export interface OAuthConfig {
|
|
6
|
-
/**
|
|
7
|
-
* OAuth 2.0 token endpoint URL for password grant flow.
|
|
8
|
-
*/
|
|
9
|
-
tokenEndpoint: string;
|
|
10
|
-
/**
|
|
11
|
-
* Username for OAuth 2.0 password grant.
|
|
12
|
-
*/
|
|
13
|
-
username: string;
|
|
14
|
-
/**
|
|
15
|
-
* Password for OAuth 2.0 password grant.
|
|
16
|
-
*/
|
|
17
|
-
password: string;
|
|
18
|
-
/**
|
|
19
|
-
* OAuth 2.0 client ID.
|
|
20
|
-
*/
|
|
21
|
-
clientId: string;
|
|
22
|
-
/**
|
|
23
|
-
* OAuth 2.0 client secret (optional, depending on your OAuth server configuration).
|
|
24
|
-
*/
|
|
25
|
-
clientSecret?: string;
|
|
26
|
-
/**
|
|
27
|
-
* OAuth 2.0 scope (optional, space-separated list of scopes).
|
|
28
|
-
*/
|
|
29
|
-
scope?: string;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Proxy configuration object.
|
|
34
|
-
*/
|
|
35
|
-
export interface ProxyConfig {
|
|
36
|
-
/**
|
|
37
|
-
* Protocol for the proxy (http or https).
|
|
38
|
-
*/
|
|
39
|
-
protocol?: string;
|
|
40
|
-
/**
|
|
41
|
-
* Proxy host.
|
|
42
|
-
*/
|
|
43
|
-
host: string;
|
|
44
|
-
/**
|
|
45
|
-
* Proxy port.
|
|
46
|
-
*/
|
|
47
|
-
port: number;
|
|
48
|
-
/**
|
|
49
|
-
* Optional authentication for the proxy.
|
|
50
|
-
*/
|
|
51
|
-
auth?: {
|
|
52
|
-
username: string;
|
|
53
|
-
password: string;
|
|
54
|
-
};
|
|
55
|
-
/**
|
|
56
|
-
* Optional debug logs for the proxy.
|
|
57
|
-
*/
|
|
58
|
-
debug?: boolean;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* REST client configuration options.
|
|
63
|
-
*/
|
|
64
|
-
export interface RestClientConfig {
|
|
65
|
-
/**
|
|
66
|
-
* Request timeout in milliseconds.
|
|
67
|
-
*/
|
|
68
|
-
timeout?: number;
|
|
69
|
-
/**
|
|
70
|
-
* Proxy configuration. Can be:
|
|
71
|
-
* - false: Disable proxy
|
|
72
|
-
* - string: Proxy URL (e.g., 'http://proxy.example.com:8080')
|
|
73
|
-
* - ProxyConfig object: Detailed proxy configuration
|
|
74
|
-
*/
|
|
75
|
-
proxy?: false | string | ProxyConfig;
|
|
76
|
-
/**
|
|
77
|
-
* Comma-separated list of domains to bypass proxy.
|
|
78
|
-
* Example: 'localhost,127.0.0.1,.example.com'
|
|
79
|
-
* This takes precedence over NO_PROXY environment variable.
|
|
80
|
-
*/
|
|
81
|
-
noProxy?: string;
|
|
82
|
-
/**
|
|
83
|
-
* Custom HTTP agent options.
|
|
84
|
-
*/
|
|
85
|
-
agent?: any;
|
|
86
|
-
/**
|
|
87
|
-
* Retry configuration.
|
|
88
|
-
*/
|
|
89
|
-
retry?: number | any;
|
|
90
|
-
/**
|
|
91
|
-
* Enable debug logging.
|
|
92
|
-
*/
|
|
93
|
-
debug?: boolean;
|
|
94
|
-
/**
|
|
95
|
-
* Any other axios configuration options.
|
|
96
|
-
*/
|
|
97
|
-
[key: string]: any;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Configuration options for initializing the Report Portal client.
|
|
102
|
-
*
|
|
103
|
-
* @example API Key Authentication
|
|
104
|
-
* ```typescript
|
|
105
|
-
* const rp = new ReportPortalClient({
|
|
106
|
-
* endpoint: 'https://your.reportportal.server/api/v1',
|
|
107
|
-
* project: 'your_project_name',
|
|
108
|
-
* apiKey: 'your_api_key',
|
|
109
|
-
* });
|
|
110
|
-
* ```
|
|
111
|
-
*
|
|
112
|
-
* @example OAuth 2.0 Authentication
|
|
113
|
-
* ```typescript
|
|
114
|
-
* const rp = new ReportPortalClient({
|
|
115
|
-
* endpoint: 'https://your.reportportal.server/api/v1',
|
|
116
|
-
* project: 'your_project_name',
|
|
117
|
-
* oauth: {
|
|
118
|
-
* tokenEndpoint: 'https://your-oauth-server.com/oauth/token',
|
|
119
|
-
* username: 'your-username',
|
|
120
|
-
* password: 'your-password',
|
|
121
|
-
* clientId: 'your-client-id',
|
|
122
|
-
* clientSecret: 'your-client-secret', // optional
|
|
123
|
-
* scope: 'reportportal', // optional
|
|
124
|
-
* }
|
|
125
|
-
* });
|
|
126
|
-
* ```
|
|
127
|
-
*
|
|
128
|
-
* @example With Proxy Configuration
|
|
129
|
-
* ```typescript
|
|
130
|
-
* const rp = new ReportPortalClient({
|
|
131
|
-
* endpoint: 'https://your.reportportal.server/api/v1',
|
|
132
|
-
* project: 'your_project_name',
|
|
133
|
-
* apiKey: 'your_api_key',
|
|
134
|
-
* restClientConfig: {
|
|
135
|
-
* proxy: {
|
|
136
|
-
* protocol: 'https',
|
|
137
|
-
* host: '127.0.0.1',
|
|
138
|
-
* port: 8080,
|
|
139
|
-
* },
|
|
140
|
-
* noProxy: 'localhost,.local.domain',
|
|
141
|
-
* }
|
|
142
|
-
* });
|
|
143
|
-
* ```
|
|
144
|
-
*/
|
|
145
|
-
export interface ReportPortalConfig {
|
|
146
|
-
apiKey?: string;
|
|
147
|
-
endpoint: string;
|
|
148
|
-
launch: string;
|
|
149
|
-
project: string;
|
|
150
|
-
headers?: Record<string, string>;
|
|
151
|
-
debug?: boolean;
|
|
152
|
-
isLaunchMergeRequired?: boolean;
|
|
153
|
-
launchUuidPrint?: boolean;
|
|
154
|
-
launchUuidPrintOutput?: string;
|
|
155
|
-
restClientConfig?: RestClientConfig;
|
|
156
|
-
token?: string;
|
|
157
|
-
skippedIsNotIssue?: boolean;
|
|
158
|
-
/**
|
|
159
|
-
* OAuth 2.0 configuration object. When provided, OAuth authentication will be used instead of API key.
|
|
160
|
-
*/
|
|
161
|
-
oauth?: OAuthConfig;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* Options to start a new launch.
|
|
166
|
-
*
|
|
167
|
-
* @example
|
|
168
|
-
* ```typescript
|
|
169
|
-
* const launch = rp.startLaunch({
|
|
170
|
-
* name: 'My Test Launch',
|
|
171
|
-
* startTime: rp.helpers.now(),
|
|
172
|
-
* });
|
|
173
|
-
* ```
|
|
174
|
-
*/
|
|
175
|
-
export interface LaunchOptions {
|
|
176
|
-
name?: string;
|
|
177
|
-
startTime?: string | number;
|
|
178
|
-
description?: string;
|
|
179
|
-
attributes?: Array<{ key?: string; value?: string } | string>;
|
|
180
|
-
mode?: string;
|
|
181
|
-
id?: string;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* Options to start a new test item (e.g., test case or suite).
|
|
186
|
-
*
|
|
187
|
-
* @example
|
|
188
|
-
* ```typescript
|
|
189
|
-
* const testItem = rp.startTestItem({
|
|
190
|
-
* name: 'My Test Case',
|
|
191
|
-
* type: 'TEST',
|
|
192
|
-
* startTime: rp.helpers.now(),
|
|
193
|
-
* });
|
|
194
|
-
* ```
|
|
195
|
-
*/
|
|
196
|
-
export interface StartTestItemOptions {
|
|
197
|
-
name: string;
|
|
198
|
-
type: string;
|
|
199
|
-
description?: string;
|
|
200
|
-
startTime?: string | number;
|
|
201
|
-
attributes?: Array<{ key?: string; value?: string } | string>;
|
|
202
|
-
hasStats?: boolean;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
/**
|
|
206
|
-
* Options to send logs to Report Portal.
|
|
207
|
-
*
|
|
208
|
-
* @example
|
|
209
|
-
* ```typescript
|
|
210
|
-
* await rp.sendLog(testItem.tempId, {
|
|
211
|
-
* level: 'INFO',
|
|
212
|
-
* message: 'Step executed successfully',
|
|
213
|
-
* time: rp.helpers.now(),
|
|
214
|
-
* });
|
|
215
|
-
* ```
|
|
216
|
-
*/
|
|
217
|
-
export interface LogOptions {
|
|
218
|
-
level?: string;
|
|
219
|
-
message?: string;
|
|
220
|
-
time?: string | number;
|
|
221
|
-
file?: {
|
|
222
|
-
name: string;
|
|
223
|
-
content: string;
|
|
224
|
-
type: string;
|
|
225
|
-
};
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
/**
|
|
229
|
-
* Options to finish a test item.
|
|
230
|
-
*
|
|
231
|
-
* @example
|
|
232
|
-
* ```typescript
|
|
233
|
-
* await rp.finishTestItem(testItem.tempId, {
|
|
234
|
-
* status: 'PASSED',
|
|
235
|
-
* endTime: rp.helpers.now(),
|
|
236
|
-
* });
|
|
237
|
-
* ```
|
|
238
|
-
*/
|
|
239
|
-
export interface FinishTestItemOptions {
|
|
240
|
-
status?: string;
|
|
241
|
-
endTime?: string | number;
|
|
242
|
-
issue?: {
|
|
243
|
-
issueType: string;
|
|
244
|
-
comment?: string;
|
|
245
|
-
externalSystemIssues?: Array<any>;
|
|
246
|
-
};
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
/**
|
|
250
|
-
* Options to finish a launch.
|
|
251
|
-
*
|
|
252
|
-
* @example
|
|
253
|
-
* ```typescript
|
|
254
|
-
* await rp.finishLaunch(launch.tempId, {
|
|
255
|
-
* endTime: rp.helpers.now(),
|
|
256
|
-
* });
|
|
257
|
-
* ```
|
|
258
|
-
*/
|
|
259
|
-
export interface FinishLaunchOptions {
|
|
260
|
-
endTime?: string | number;
|
|
261
|
-
status?: string;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
/**
|
|
265
|
-
* Main Report Portal client for interacting with the API.
|
|
266
|
-
*/
|
|
267
|
-
export default class ReportPortalClient {
|
|
268
|
-
/**
|
|
269
|
-
* Initializes a new Report Portal client.
|
|
270
|
-
*/
|
|
271
|
-
constructor(config: ReportPortalConfig, agentInfo?: { name?: string; version?: string; framework_version?: string });
|
|
272
|
-
|
|
273
|
-
/**
|
|
274
|
-
* Starts a new launch.
|
|
275
|
-
* @example
|
|
276
|
-
* ```typescript
|
|
277
|
-
* const launchObj = rpClient.startLaunch({
|
|
278
|
-
* name: 'Client test',
|
|
279
|
-
* startTime: rpClient.helpers.now(),
|
|
280
|
-
* description: 'description of the launch',
|
|
281
|
-
* attributes: [
|
|
282
|
-
* {
|
|
283
|
-
* 'key': 'yourKey',
|
|
284
|
-
* 'value': 'yourValue'
|
|
285
|
-
* },
|
|
286
|
-
* {
|
|
287
|
-
* 'value': 'yourValue'
|
|
288
|
-
* }
|
|
289
|
-
* ],
|
|
290
|
-
* //this param used only when you need client to send data into the existing launch
|
|
291
|
-
* id: 'id'
|
|
292
|
-
* });
|
|
293
|
-
* await launchObj.promise;
|
|
294
|
-
* ```
|
|
295
|
-
*/
|
|
296
|
-
startLaunch(options: LaunchOptions): { tempId: string; promise: Promise<any> };
|
|
297
|
-
|
|
298
|
-
/**
|
|
299
|
-
* Finishes an active launch.
|
|
300
|
-
* @example
|
|
301
|
-
* ```typescript
|
|
302
|
-
* const launchFinishObj = rpClient.finishLaunch(launchObj.tempId, {
|
|
303
|
-
* endTime: rpClient.helpers.now()
|
|
304
|
-
* });
|
|
305
|
-
* await launchFinishObj.promise;
|
|
306
|
-
* ```
|
|
307
|
-
*/
|
|
308
|
-
finishLaunch(
|
|
309
|
-
launchId: string,
|
|
310
|
-
options?: FinishLaunchOptions,
|
|
311
|
-
): { tempId: string; promise: Promise<any> };
|
|
312
|
-
|
|
313
|
-
/**
|
|
314
|
-
* Update the launch data
|
|
315
|
-
* @example
|
|
316
|
-
* ```typescript
|
|
317
|
-
* const updateLunch = rpClient.updateLaunch(
|
|
318
|
-
* launchObj.tempId,
|
|
319
|
-
* {
|
|
320
|
-
* description: 'new launch description',
|
|
321
|
-
* attributes: [
|
|
322
|
-
* {
|
|
323
|
-
* key: 'yourKey',
|
|
324
|
-
* value: 'yourValue'
|
|
325
|
-
* },
|
|
326
|
-
* {
|
|
327
|
-
* value: 'yourValue'
|
|
328
|
-
* }
|
|
329
|
-
* ],
|
|
330
|
-
* mode: 'DEBUG'
|
|
331
|
-
* }
|
|
332
|
-
* );
|
|
333
|
-
* await updateLaunch.promise;
|
|
334
|
-
* ```
|
|
335
|
-
*/
|
|
336
|
-
updateLaunch(
|
|
337
|
-
launchId: string,
|
|
338
|
-
options: LaunchOptions,
|
|
339
|
-
): { tempId: string; promise: Promise<any> };
|
|
340
|
-
|
|
341
|
-
/**
|
|
342
|
-
* Starts a new test item under a launch or parent item.
|
|
343
|
-
* @example
|
|
344
|
-
* ```typescript
|
|
345
|
-
* const suiteObj = rpClient.startTestItem({
|
|
346
|
-
* description: makeid(),
|
|
347
|
-
* name: makeid(),
|
|
348
|
-
* startTime: rpClient.helpers.now(),
|
|
349
|
-
* type: 'SUITE'
|
|
350
|
-
* }, launchObj.tempId);
|
|
351
|
-
* const stepObj = rpClient.startTestItem({
|
|
352
|
-
* description: makeid(),
|
|
353
|
-
* name: makeid(),
|
|
354
|
-
* startTime: rpClient.helpers.now(),
|
|
355
|
-
* attributes: [
|
|
356
|
-
* {
|
|
357
|
-
* key: 'yourKey',
|
|
358
|
-
* value: 'yourValue'
|
|
359
|
-
* },
|
|
360
|
-
* {
|
|
361
|
-
* value: 'yourValue'
|
|
362
|
-
* }
|
|
363
|
-
* ],
|
|
364
|
-
* type: 'STEP'
|
|
365
|
-
* }, launchObj.tempId, suiteObj.tempId);
|
|
366
|
-
* ```
|
|
367
|
-
*/
|
|
368
|
-
startTestItem(
|
|
369
|
-
options: StartTestItemOptions,
|
|
370
|
-
launchId: string,
|
|
371
|
-
parentId?: string,
|
|
372
|
-
): {
|
|
373
|
-
tempId: string;
|
|
374
|
-
promise: Promise<any>;
|
|
375
|
-
};
|
|
376
|
-
|
|
377
|
-
/**
|
|
378
|
-
* Finishes a test item.
|
|
379
|
-
* @example
|
|
380
|
-
* ```typescript
|
|
381
|
-
* const finishObj = rpClient.finishTestItem(itemObj.tempId, {
|
|
382
|
-
* status: 'failed'
|
|
383
|
-
* });
|
|
384
|
-
* await finishObj.promise;
|
|
385
|
-
* ```
|
|
386
|
-
*/
|
|
387
|
-
finishTestItem(
|
|
388
|
-
itemId: string,
|
|
389
|
-
options: FinishTestItemOptions,
|
|
390
|
-
): { tempId: string; promise: Promise<any> };
|
|
391
|
-
|
|
392
|
-
/**
|
|
393
|
-
* Sends a log entry to a test item.
|
|
394
|
-
* @example
|
|
395
|
-
* ```typescript
|
|
396
|
-
* const logObj = rpClient.sendLog(stepObj.tempId, {
|
|
397
|
-
* level: 'INFO',
|
|
398
|
-
* message: 'User clicks login button',
|
|
399
|
-
* time: rpClient.helpers.now()
|
|
400
|
-
* });
|
|
401
|
-
* await logObj.promise;
|
|
402
|
-
* ```
|
|
403
|
-
*/
|
|
404
|
-
sendLog(
|
|
405
|
-
itemId: string,
|
|
406
|
-
options: LogOptions,
|
|
407
|
-
file?: { name: string; content: string | Buffer; type: string },
|
|
408
|
-
): { tempId: string; promise: Promise<any> };
|
|
409
|
-
|
|
410
|
-
/**
|
|
411
|
-
* Waits for all test items to be finished.
|
|
412
|
-
* @example
|
|
413
|
-
* ```typescript
|
|
414
|
-
* await agent.getPromiseFinishAllItems(agent.tempLaunchId);
|
|
415
|
-
* ```
|
|
416
|
-
*/
|
|
417
|
-
getPromiseFinishAllItems(launchId: string): Promise<any>;
|
|
418
|
-
|
|
419
|
-
/**
|
|
420
|
-
* Check if connection is established
|
|
421
|
-
* @example
|
|
422
|
-
* ```typescript
|
|
423
|
-
* await agent.checkConnect();
|
|
424
|
-
* ```
|
|
425
|
-
*/
|
|
426
|
-
checkConnect(): Promise<any>;
|
|
427
|
-
|
|
428
|
-
helpers: {
|
|
429
|
-
/**
|
|
430
|
-
* Generate ISO timestamp
|
|
431
|
-
* @example
|
|
432
|
-
* ```typescript
|
|
433
|
-
* await rpClient.sendLog(stepObj.tempId, {
|
|
434
|
-
* level: 'INFO',
|
|
435
|
-
* message: 'User clicks login button',
|
|
436
|
-
* time: rpClient.helpers.now()
|
|
437
|
-
* });
|
|
438
|
-
* ```
|
|
439
|
-
*/
|
|
440
|
-
now(): string;
|
|
441
|
-
};
|
|
442
|
-
}
|
|
443
|
-
}
|
package/lib/commons/config.js
DELETED
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
const { ReportPortalRequiredOptionError, ReportPortalValidationError } = require('./errors');
|
|
2
|
-
const { OUTPUT_TYPES } = require('../constants/outputs');
|
|
3
|
-
|
|
4
|
-
const getOption = (options, optionName, defaultValue) => {
|
|
5
|
-
if (!Object.prototype.hasOwnProperty.call(options, optionName) || !options[optionName]) {
|
|
6
|
-
return defaultValue;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
return options[optionName];
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
const getRequiredOption = (options, optionName) => {
|
|
13
|
-
if (!Object.prototype.hasOwnProperty.call(options, optionName) || !options[optionName]) {
|
|
14
|
-
throw new ReportPortalRequiredOptionError(optionName);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
return options[optionName];
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const getApiKey = ({ apiKey, token }) => {
|
|
21
|
-
let calculatedApiKey = apiKey;
|
|
22
|
-
if (!calculatedApiKey) {
|
|
23
|
-
calculatedApiKey = token;
|
|
24
|
-
if (!calculatedApiKey) {
|
|
25
|
-
throw new ReportPortalRequiredOptionError('apiKey');
|
|
26
|
-
} else {
|
|
27
|
-
console.warn(`Option 'token' is deprecated. Use 'apiKey' instead.`);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
return calculatedApiKey;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
const getOAuthConfig = (options) => {
|
|
35
|
-
const oauthParams = options.oauth || {};
|
|
36
|
-
|
|
37
|
-
const { tokenEndpoint, username, password, clientId, clientSecret, scope } = oauthParams;
|
|
38
|
-
|
|
39
|
-
if (!tokenEndpoint && !username && !password && !clientId) {
|
|
40
|
-
return null;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
if (!tokenEndpoint) {
|
|
44
|
-
throw new ReportPortalRequiredOptionError('oauth.tokenEndpoint');
|
|
45
|
-
}
|
|
46
|
-
if (!username) {
|
|
47
|
-
throw new ReportPortalRequiredOptionError('oauth.username');
|
|
48
|
-
}
|
|
49
|
-
if (!password) {
|
|
50
|
-
throw new ReportPortalRequiredOptionError('oauth.password');
|
|
51
|
-
}
|
|
52
|
-
if (!clientId) {
|
|
53
|
-
throw new ReportPortalRequiredOptionError('oauth.clientId');
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
return {
|
|
57
|
-
tokenEndpoint,
|
|
58
|
-
username,
|
|
59
|
-
password,
|
|
60
|
-
clientId,
|
|
61
|
-
clientSecret,
|
|
62
|
-
scope,
|
|
63
|
-
};
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
const getClientConfig = (options) => {
|
|
67
|
-
let calculatedOptions = options;
|
|
68
|
-
try {
|
|
69
|
-
if (typeof options !== 'object') {
|
|
70
|
-
throw new ReportPortalValidationError('`options` must be an object.');
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// Try to get OAuth config first
|
|
74
|
-
const oauthConfig = getOAuthConfig(options);
|
|
75
|
-
|
|
76
|
-
// If OAuth is not configured, apiKey is required
|
|
77
|
-
let apiKey;
|
|
78
|
-
if (!oauthConfig) {
|
|
79
|
-
apiKey = getApiKey(options);
|
|
80
|
-
} else {
|
|
81
|
-
// If OAuth is configured, apiKey is optional (use it if provided)
|
|
82
|
-
try {
|
|
83
|
-
apiKey = getApiKey(options);
|
|
84
|
-
} catch (error) {
|
|
85
|
-
// Ignore error if OAuth is configured
|
|
86
|
-
apiKey = null;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
const project = getRequiredOption(options, 'project');
|
|
91
|
-
const endpoint = getRequiredOption(options, 'endpoint');
|
|
92
|
-
|
|
93
|
-
const launchUuidPrintOutputType = getOption(options, 'launchUuidPrintOutput', 'STDOUT')
|
|
94
|
-
.toString()
|
|
95
|
-
.toUpperCase();
|
|
96
|
-
const launchUuidPrintOutput = getOption(
|
|
97
|
-
OUTPUT_TYPES,
|
|
98
|
-
launchUuidPrintOutputType,
|
|
99
|
-
OUTPUT_TYPES.STDOUT,
|
|
100
|
-
);
|
|
101
|
-
|
|
102
|
-
calculatedOptions = {
|
|
103
|
-
apiKey,
|
|
104
|
-
oauth: oauthConfig,
|
|
105
|
-
project,
|
|
106
|
-
endpoint,
|
|
107
|
-
launch: options.launch,
|
|
108
|
-
debug: options.debug,
|
|
109
|
-
isLaunchMergeRequired:
|
|
110
|
-
options.isLaunchMergeRequired === undefined ? false : options.isLaunchMergeRequired,
|
|
111
|
-
headers: options.headers,
|
|
112
|
-
restClientConfig: options.restClientConfig,
|
|
113
|
-
attributes: options.attributes,
|
|
114
|
-
mode: options.mode,
|
|
115
|
-
description: options.description,
|
|
116
|
-
launchUuidPrint: options.launchUuidPrint,
|
|
117
|
-
launchUuidPrintOutput,
|
|
118
|
-
skippedIsNotIssue: !!options.skippedIsNotIssue,
|
|
119
|
-
};
|
|
120
|
-
} catch (error) {
|
|
121
|
-
// don't throw the error up to not break the entire process
|
|
122
|
-
console.dir(error);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
return calculatedOptions;
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
module.exports = {
|
|
129
|
-
getClientConfig,
|
|
130
|
-
getRequiredOption,
|
|
131
|
-
getApiKey,
|
|
132
|
-
getOAuthConfig,
|
|
133
|
-
};
|
package/lib/commons/errors.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
class ReportPortalError extends Error {
|
|
2
|
-
constructor(message) {
|
|
3
|
-
const basicMessage = `\nReportPortal client error: ${message}`;
|
|
4
|
-
super(basicMessage);
|
|
5
|
-
this.name = 'ReportPortalError';
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
class ReportPortalValidationError extends ReportPortalError {
|
|
10
|
-
constructor(message) {
|
|
11
|
-
const basicMessage = `\nValidation failed. Please, check the specified parameters: ${message}`;
|
|
12
|
-
super(basicMessage);
|
|
13
|
-
this.name = 'ReportPortalValidationError';
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
class ReportPortalRequiredOptionError extends ReportPortalValidationError {
|
|
18
|
-
constructor(propertyName) {
|
|
19
|
-
const basicMessage = `\nProperty '${propertyName}' must not be empty.`;
|
|
20
|
-
super(basicMessage);
|
|
21
|
-
this.name = 'ReportPortalRequiredOptionError';
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
module.exports = {
|
|
26
|
-
ReportPortalError,
|
|
27
|
-
ReportPortalValidationError,
|
|
28
|
-
ReportPortalRequiredOptionError,
|
|
29
|
-
};
|
package/lib/constants/events.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
const EVENTS = {
|
|
2
|
-
SET_DESCRIPTION: 'rp:setDescription',
|
|
3
|
-
SET_TEST_CASE_ID: 'rp:setTestCaseId',
|
|
4
|
-
SET_STATUS: 'rp:setStatus',
|
|
5
|
-
SET_LAUNCH_STATUS: 'rp:setLaunchStatus',
|
|
6
|
-
ADD_ATTRIBUTES: 'rp:addAttributes',
|
|
7
|
-
ADD_LOG: 'rp:addLog',
|
|
8
|
-
ADD_LAUNCH_LOG: 'rp:addLaunchLog',
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
module.exports = { EVENTS };
|
package/lib/constants/outputs.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
const helpers = require('../helpers');
|
|
2
|
-
|
|
3
|
-
const OUTPUT_TYPES = {
|
|
4
|
-
// eslint-disable-next-line no-console
|
|
5
|
-
STDOUT: (launchUuid) => console.log(`Report Portal Launch UUID: ${launchUuid}`),
|
|
6
|
-
// eslint-disable-next-line no-console
|
|
7
|
-
STDERR: (launchUuid) => console.error(`Report Portal Launch UUID: ${launchUuid}`),
|
|
8
|
-
// eslint-disable-next-line no-return-assign
|
|
9
|
-
ENVIRONMENT: (launchUuid) => (process.env.RP_LAUNCH_UUID = launchUuid),
|
|
10
|
-
FILE: helpers.saveLaunchUuidToFile,
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
module.exports = { OUTPUT_TYPES };
|