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