@reportportal/client-javascript 5.5.9 → 5.5.11

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/VERSION CHANGED
@@ -1 +1 @@
1
- 5.5.10-SNAPSHOT
1
+ 5.5.12-SNAPSHOT
package/index.d.ts CHANGED
@@ -52,6 +52,10 @@ declare module '@reportportal/client-javascript' {
52
52
  username: string;
53
53
  password: string;
54
54
  };
55
+ /**
56
+ * Optional debug logs for the proxy.
57
+ */
58
+ debug?: boolean;
55
59
  }
56
60
 
57
61
  /**
@@ -78,16 +82,11 @@ declare module '@reportportal/client-javascript' {
78
82
  /**
79
83
  * Custom HTTP agent options.
80
84
  */
81
- agent?: Record<string, unknown>;
85
+ agent?: any;
82
86
  /**
83
87
  * Retry configuration.
84
88
  */
85
- retry?: number | {
86
- retries?: number;
87
- retryDelay?: (retryCount: number) => number;
88
- retryCondition?: (error: any) => boolean;
89
- shouldResetTimeout?: boolean;
90
- };
89
+ retry?: number | any;
91
90
  /**
92
91
  * Enable debug logging.
93
92
  */
@@ -95,7 +94,7 @@ declare module '@reportportal/client-javascript' {
95
94
  /**
96
95
  * Any other axios configuration options.
97
96
  */
98
- [key: string]: unknown;
97
+ [key: string]: any;
99
98
  }
100
99
 
101
100
  /**
@@ -175,9 +174,9 @@ declare module '@reportportal/client-javascript' {
175
174
  */
176
175
  export interface LaunchOptions {
177
176
  name?: string;
178
- startTime?: string;
177
+ startTime?: string | number;
179
178
  description?: string;
180
- attributes?: Array<{ key: string; value?: string } | string>;
179
+ attributes?: Array<{ key?: string; value?: string } | string>;
181
180
  mode?: string;
182
181
  id?: string;
183
182
  }
@@ -198,8 +197,8 @@ declare module '@reportportal/client-javascript' {
198
197
  name: string;
199
198
  type: string;
200
199
  description?: string;
201
- startTime?: string;
202
- attributes?: Array<{ key: string; value?: string } | string>;
200
+ startTime?: string | number;
201
+ attributes?: Array<{ key?: string; value?: string } | string>;
203
202
  hasStats?: boolean;
204
203
  }
205
204
 
@@ -218,7 +217,7 @@ declare module '@reportportal/client-javascript' {
218
217
  export interface LogOptions {
219
218
  level?: string;
220
219
  message?: string;
221
- time?: string;
220
+ time?: string | number;
222
221
  file?: {
223
222
  name: string;
224
223
  content: string;
@@ -239,11 +238,11 @@ declare module '@reportportal/client-javascript' {
239
238
  */
240
239
  export interface FinishTestItemOptions {
241
240
  status?: string;
242
- endTime?: string;
241
+ endTime?: string | number;
243
242
  issue?: {
244
243
  issueType: string;
245
244
  comment?: string;
246
- externalSystemIssues?: Array<any>
245
+ externalSystemIssues?: Array<any>;
247
246
  };
248
247
  }
249
248
 
@@ -258,7 +257,7 @@ declare module '@reportportal/client-javascript' {
258
257
  * ```
259
258
  */
260
259
  export interface FinishLaunchOptions {
261
- endTime?: string;
260
+ endTime?: string | number;
262
261
  status?: string;
263
262
  }
264
263
 
@@ -269,7 +268,7 @@ declare module '@reportportal/client-javascript' {
269
268
  /**
270
269
  * Initializes a new Report Portal client.
271
270
  */
272
- constructor(config: ReportPortalConfig);
271
+ constructor(config: ReportPortalConfig, agentInfo?: { name?: string; version?: string; framework_version?: string });
273
272
 
274
273
  /**
275
274
  * Starts a new launch.
@@ -306,7 +305,10 @@ declare module '@reportportal/client-javascript' {
306
305
  * await launchFinishObj.promise;
307
306
  * ```
308
307
  */
309
- finishLaunch(launchId: string, options?: FinishLaunchOptions): Promise<any>;
308
+ finishLaunch(
309
+ launchId: string,
310
+ options?: FinishLaunchOptions,
311
+ ): { tempId: string; promise: Promise<any> };
310
312
 
311
313
  /**
312
314
  * Update the launch data
@@ -331,7 +333,10 @@ declare module '@reportportal/client-javascript' {
331
333
  * await updateLaunch.promise;
332
334
  * ```
333
335
  */
334
- updateLaunch(options: LaunchOptions): { tempId: string; promise: Promise<any> };
336
+ updateLaunch(
337
+ launchId: string,
338
+ options: LaunchOptions,
339
+ ): { tempId: string; promise: Promise<any> };
335
340
 
336
341
  /**
337
342
  * Starts a new test item under a launch or parent item.
@@ -360,34 +365,47 @@ declare module '@reportportal/client-javascript' {
360
365
  * }, launchObj.tempId, suiteObj.tempId);
361
366
  * ```
362
367
  */
363
- startTestItem(options: StartTestItemOptions, launchId: string, parentId?: string): {
368
+ startTestItem(
369
+ options: StartTestItemOptions,
370
+ launchId: string,
371
+ parentId?: string,
372
+ ): {
364
373
  tempId: string;
365
- promise: Promise<any>
374
+ promise: Promise<any>;
366
375
  };
367
376
 
368
377
  /**
369
378
  * Finishes a test item.
370
379
  * @example
371
380
  * ```typescript
372
- * rpClient.finishTestItem(itemObj.tempId, {
381
+ * const finishObj = rpClient.finishTestItem(itemObj.tempId, {
373
382
  * status: 'failed'
374
383
  * });
384
+ * await finishObj.promise;
375
385
  * ```
376
386
  */
377
- finishTestItem(itemId: string, options: FinishTestItemOptions): Promise<any>;
387
+ finishTestItem(
388
+ itemId: string,
389
+ options: FinishTestItemOptions,
390
+ ): { tempId: string; promise: Promise<any> };
378
391
 
379
392
  /**
380
393
  * Sends a log entry to a test item.
381
394
  * @example
382
395
  * ```typescript
383
- * await rpClient.sendLog(stepObj.tempId, {
396
+ * const logObj = rpClient.sendLog(stepObj.tempId, {
384
397
  * level: 'INFO',
385
398
  * message: 'User clicks login button',
386
399
  * time: rpClient.helpers.now()
387
400
  * });
401
+ * await logObj.promise;
388
402
  * ```
389
403
  */
390
- sendLog(itemId: string, options: LogOptions): Promise<any>;
404
+ sendLog(
405
+ itemId: string,
406
+ options: LogOptions,
407
+ file?: { name: string; content: string | Buffer; type: string },
408
+ ): { tempId: string; promise: Promise<any> };
391
409
 
392
410
  /**
393
411
  * Waits for all test items to be finished.
@@ -419,7 +437,7 @@ declare module '@reportportal/client-javascript' {
419
437
  * });
420
438
  * ```
421
439
  */
422
- now(): string
423
- }
440
+ now(): string;
441
+ };
424
442
  }
425
443
  }
@@ -146,10 +146,28 @@ class RPClient {
146
146
  return this.restClient.request('GET', url, {});
147
147
  }
148
148
 
149
+ getServerInfoUrl() {
150
+ return this.config.endpoint.replace('/v1', '/info').replace('/v2', '/info');
151
+ }
152
+
153
+ async fetchServerInfo() {
154
+ const url = this.getServerInfoUrl();
155
+ return this.restClient.request('GET', url, {});
156
+ }
157
+
149
158
  async triggerStatisticsEvent() {
150
159
  if (process.env.REPORTPORTAL_CLIENT_JS_NO_ANALYTICS) {
151
160
  return;
152
161
  }
162
+ try {
163
+ const serverInfo = await this.fetchServerInfo();
164
+ const instanceID = serverInfo?.extensions?.result?.['server.details.instance'];
165
+ if (instanceID) {
166
+ this.statistics.setInstanceID(instanceID);
167
+ }
168
+ } catch (e) {
169
+ this.statistics.setInstanceID('not_set');
170
+ }
153
171
  await this.statistics.trackEvent();
154
172
  }
155
173
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reportportal/client-javascript",
3
- "version": "5.5.9",
3
+ "version": "5.5.11",
4
4
  "description": "ReportPortal client for Node.js",
5
5
  "author": "ReportPortal.io",
6
6
  "scripts": {
@@ -26,9 +26,9 @@
26
26
  "node": ">=14.x"
27
27
  },
28
28
  "dependencies": {
29
- "axios": "^1.12.2",
29
+ "axios": "^1.15.2",
30
30
  "axios-retry": "^4.5.0",
31
- "glob": "^13.0.1",
31
+ "glob": "^13.0.6",
32
32
  "http-proxy-agent": "^7.0.2",
33
33
  "https-proxy-agent": "^7.0.6",
34
34
  "ini": "^2.0.0",
@@ -24,9 +24,20 @@ class Statistics {
24
24
  if (agentParams && hasOption(agentParams, 'version') && agentParams.version) {
25
25
  params.agent_version = agentParams.version;
26
26
  }
27
+ if (
28
+ agentParams &&
29
+ hasOption(agentParams, 'framework_version') &&
30
+ agentParams.framework_version
31
+ ) {
32
+ params.framework_version = agentParams.framework_version;
33
+ }
27
34
  return params;
28
35
  }
29
36
 
37
+ setInstanceID(instanceID) {
38
+ this.eventParams.instanceID = instanceID;
39
+ }
40
+
30
41
  async trackEvent() {
31
42
  try {
32
43
  const requestBody = {