@uipath/uipath-typescript 1.3.9 → 1.3.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.
Files changed (39) hide show
  1. package/dist/assets/index.cjs +19 -6
  2. package/dist/assets/index.mjs +19 -6
  3. package/dist/attachments/index.cjs +19 -6
  4. package/dist/attachments/index.mjs +19 -6
  5. package/dist/buckets/index.cjs +141 -6
  6. package/dist/buckets/index.d.ts +164 -1
  7. package/dist/buckets/index.mjs +141 -6
  8. package/dist/cases/index.cjs +70 -6
  9. package/dist/cases/index.d.ts +91 -1
  10. package/dist/cases/index.mjs +70 -6
  11. package/dist/conversational-agent/index.cjs +19 -6
  12. package/dist/conversational-agent/index.mjs +19 -6
  13. package/dist/core/index.cjs +1 -1
  14. package/dist/core/index.mjs +1 -1
  15. package/dist/entities/index.cjs +239 -34
  16. package/dist/entities/index.d.ts +311 -12
  17. package/dist/entities/index.mjs +239 -34
  18. package/dist/feedback/index.cjs +19 -6
  19. package/dist/feedback/index.mjs +19 -6
  20. package/dist/index.cjs +490 -64
  21. package/dist/index.d.ts +714 -36
  22. package/dist/index.mjs +490 -64
  23. package/dist/index.umd.js +491 -65
  24. package/dist/jobs/index.cjs +19 -6
  25. package/dist/jobs/index.mjs +19 -6
  26. package/dist/maestro-processes/index.cjs +70 -6
  27. package/dist/maestro-processes/index.d.ts +91 -1
  28. package/dist/maestro-processes/index.mjs +70 -6
  29. package/dist/processes/index.cjs +47 -35
  30. package/dist/processes/index.d.ts +76 -26
  31. package/dist/processes/index.mjs +47 -35
  32. package/dist/queues/index.cjs +19 -6
  33. package/dist/queues/index.mjs +19 -6
  34. package/dist/tasks/index.cjs +19 -6
  35. package/dist/tasks/index.mjs +19 -6
  36. package/dist/traces/index.cjs +1902 -0
  37. package/dist/traces/index.d.ts +565 -0
  38. package/dist/traces/index.mjs +1900 -0
  39. package/package.json +12 -2
@@ -613,14 +613,25 @@ class ApiClient {
613
613
  if (!text) {
614
614
  return undefined;
615
615
  }
616
- return JSON.parse(text);
616
+ try {
617
+ return JSON.parse(text);
618
+ }
619
+ catch (error) {
620
+ if (error instanceof SyntaxError) {
621
+ throw new ServerError({
622
+ message: `Server returned non-JSON response (${response.status} ${response.url}): ${error.message}`,
623
+ statusCode: response.status,
624
+ });
625
+ }
626
+ throw error;
627
+ }
617
628
  }
618
629
  catch (error) {
619
630
  // If it's already one of our errors, re-throw it
620
631
  if (error.type && error.type.includes('Error')) {
621
632
  throw error;
622
633
  }
623
- // Otherwise, it's likely a network error
634
+ // Otherwise, it's a genuine network/fetch failure
624
635
  throw ErrorFactory.createNetworkError(error);
625
636
  }
626
637
  }
@@ -1221,9 +1232,9 @@ class PaginationHelpers {
1221
1232
  * @returns Promise resolving to a paginated result
1222
1233
  */
1223
1234
  static async getAllPaginated(params) {
1224
- const { serviceAccess, getEndpoint, folderId, paginationParams, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
1235
+ const { serviceAccess, getEndpoint, folderId, headers: providedHeaders, paginationParams, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
1225
1236
  const endpoint = getEndpoint(folderId);
1226
- const headers = folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {};
1237
+ const headers = providedHeaders ?? (folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {});
1227
1238
  const paginatedResponse = await serviceAccess.requestWithPagination(method, endpoint, paginationParams, {
1228
1239
  headers,
1229
1240
  params: additionalParams,
@@ -1251,13 +1262,13 @@ class PaginationHelpers {
1251
1262
  * @returns Promise resolving to an object with data and totalCount
1252
1263
  */
1253
1264
  static async getAllNonPaginated(params) {
1254
- const { serviceAccess, getAllEndpoint, getByFolderEndpoint, folderId, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
1265
+ const { serviceAccess, getAllEndpoint, getByFolderEndpoint, folderId, headers: providedHeaders, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
1255
1266
  // Set default field names
1256
1267
  const itemsField = options.itemsField || DEFAULT_ITEMS_FIELD;
1257
1268
  const totalCountField = options.totalCountField || DEFAULT_TOTAL_COUNT_FIELD;
1258
1269
  // Determine endpoint and headers based on folderId
1259
1270
  const endpoint = folderId ? getByFolderEndpoint : getAllEndpoint;
1260
- const headers = folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {};
1271
+ const headers = providedHeaders ?? (folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {});
1261
1272
  // Make the API call based on method
1262
1273
  let response;
1263
1274
  if (method === HTTP_METHODS.POST) {
@@ -1316,6 +1327,7 @@ class PaginationHelpers {
1316
1327
  serviceAccess: config.serviceAccess,
1317
1328
  getEndpoint: config.getEndpoint,
1318
1329
  folderId,
1330
+ headers: config.headers,
1319
1331
  paginationParams: cursor ? { cursor, pageSize } : jumpToPage ? { jumpToPage, pageSize } : { pageSize },
1320
1332
  additionalParams: prefixedOptions,
1321
1333
  transformFn: config.transformFn,
@@ -1333,6 +1345,7 @@ class PaginationHelpers {
1333
1345
  getAllEndpoint: config.getEndpoint(),
1334
1346
  getByFolderEndpoint: byFolderEndpoint,
1335
1347
  folderId,
1348
+ headers: config.headers,
1336
1349
  additionalParams: prefixedOptions,
1337
1350
  transformFn: config.transformFn,
1338
1351
  method: config.method,
@@ -611,14 +611,25 @@ class ApiClient {
611
611
  if (!text) {
612
612
  return undefined;
613
613
  }
614
- return JSON.parse(text);
614
+ try {
615
+ return JSON.parse(text);
616
+ }
617
+ catch (error) {
618
+ if (error instanceof SyntaxError) {
619
+ throw new ServerError({
620
+ message: `Server returned non-JSON response (${response.status} ${response.url}): ${error.message}`,
621
+ statusCode: response.status,
622
+ });
623
+ }
624
+ throw error;
625
+ }
615
626
  }
616
627
  catch (error) {
617
628
  // If it's already one of our errors, re-throw it
618
629
  if (error.type && error.type.includes('Error')) {
619
630
  throw error;
620
631
  }
621
- // Otherwise, it's likely a network error
632
+ // Otherwise, it's a genuine network/fetch failure
622
633
  throw ErrorFactory.createNetworkError(error);
623
634
  }
624
635
  }
@@ -1219,9 +1230,9 @@ class PaginationHelpers {
1219
1230
  * @returns Promise resolving to a paginated result
1220
1231
  */
1221
1232
  static async getAllPaginated(params) {
1222
- const { serviceAccess, getEndpoint, folderId, paginationParams, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
1233
+ const { serviceAccess, getEndpoint, folderId, headers: providedHeaders, paginationParams, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
1223
1234
  const endpoint = getEndpoint(folderId);
1224
- const headers = folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {};
1235
+ const headers = providedHeaders ?? (folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {});
1225
1236
  const paginatedResponse = await serviceAccess.requestWithPagination(method, endpoint, paginationParams, {
1226
1237
  headers,
1227
1238
  params: additionalParams,
@@ -1249,13 +1260,13 @@ class PaginationHelpers {
1249
1260
  * @returns Promise resolving to an object with data and totalCount
1250
1261
  */
1251
1262
  static async getAllNonPaginated(params) {
1252
- const { serviceAccess, getAllEndpoint, getByFolderEndpoint, folderId, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
1263
+ const { serviceAccess, getAllEndpoint, getByFolderEndpoint, folderId, headers: providedHeaders, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
1253
1264
  // Set default field names
1254
1265
  const itemsField = options.itemsField || DEFAULT_ITEMS_FIELD;
1255
1266
  const totalCountField = options.totalCountField || DEFAULT_TOTAL_COUNT_FIELD;
1256
1267
  // Determine endpoint and headers based on folderId
1257
1268
  const endpoint = folderId ? getByFolderEndpoint : getAllEndpoint;
1258
- const headers = folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {};
1269
+ const headers = providedHeaders ?? (folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {});
1259
1270
  // Make the API call based on method
1260
1271
  let response;
1261
1272
  if (method === HTTP_METHODS.POST) {
@@ -1314,6 +1325,7 @@ class PaginationHelpers {
1314
1325
  serviceAccess: config.serviceAccess,
1315
1326
  getEndpoint: config.getEndpoint,
1316
1327
  folderId,
1328
+ headers: config.headers,
1317
1329
  paginationParams: cursor ? { cursor, pageSize } : jumpToPage ? { jumpToPage, pageSize } : { pageSize },
1318
1330
  additionalParams: prefixedOptions,
1319
1331
  transformFn: config.transformFn,
@@ -1331,6 +1343,7 @@ class PaginationHelpers {
1331
1343
  getAllEndpoint: config.getEndpoint(),
1332
1344
  getByFolderEndpoint: byFolderEndpoint,
1333
1345
  folderId,
1346
+ headers: config.headers,
1334
1347
  additionalParams: prefixedOptions,
1335
1348
  transformFn: config.transformFn,
1336
1349
  method: config.method,
@@ -79,6 +79,8 @@ const MAESTRO_ENDPOINTS = {
79
79
  TOP_PROCESSES_BY_RUN_COUNT: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/TopProcessesByRunCount`,
80
80
  /** Top processes ranked by failure count */
81
81
  TOP_PROCESSES_WITH_FAILURE: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/TopProcesseswithFailure`,
82
+ /** Top elements ranked by failure count */
83
+ TOP_ELEMENTS_WITH_FAILURE: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/TopElementswithFailure`,
82
84
  /** Instance status aggregated by date for time-series charts */
83
85
  INSTANCE_STATUS_BY_DATE: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/InstanceStatusByDate`,
84
86
  /** Top processes ranked by total duration */
@@ -1050,14 +1052,25 @@ class ApiClient {
1050
1052
  if (!text) {
1051
1053
  return undefined;
1052
1054
  }
1053
- return JSON.parse(text);
1055
+ try {
1056
+ return JSON.parse(text);
1057
+ }
1058
+ catch (error) {
1059
+ if (error instanceof SyntaxError) {
1060
+ throw new ServerError({
1061
+ message: `Server returned non-JSON response (${response.status} ${response.url}): ${error.message}`,
1062
+ statusCode: response.status,
1063
+ });
1064
+ }
1065
+ throw error;
1066
+ }
1054
1067
  }
1055
1068
  catch (error) {
1056
1069
  // If it's already one of our errors, re-throw it
1057
1070
  if (error.type && error.type.includes('Error')) {
1058
1071
  throw error;
1059
1072
  }
1060
- // Otherwise, it's likely a network error
1073
+ // Otherwise, it's a genuine network/fetch failure
1061
1074
  throw ErrorFactory.createNetworkError(error);
1062
1075
  }
1063
1076
  }
@@ -1424,9 +1437,9 @@ class PaginationHelpers {
1424
1437
  * @returns Promise resolving to a paginated result
1425
1438
  */
1426
1439
  static async getAllPaginated(params) {
1427
- const { serviceAccess, getEndpoint, folderId, paginationParams, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
1440
+ const { serviceAccess, getEndpoint, folderId, headers: providedHeaders, paginationParams, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
1428
1441
  const endpoint = getEndpoint(folderId);
1429
- const headers = folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {};
1442
+ const headers = providedHeaders ?? (folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {});
1430
1443
  const paginatedResponse = await serviceAccess.requestWithPagination(method, endpoint, paginationParams, {
1431
1444
  headers,
1432
1445
  params: additionalParams,
@@ -1454,13 +1467,13 @@ class PaginationHelpers {
1454
1467
  * @returns Promise resolving to an object with data and totalCount
1455
1468
  */
1456
1469
  static async getAllNonPaginated(params) {
1457
- const { serviceAccess, getAllEndpoint, getByFolderEndpoint, folderId, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
1470
+ const { serviceAccess, getAllEndpoint, getByFolderEndpoint, folderId, headers: providedHeaders, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
1458
1471
  // Set default field names
1459
1472
  const itemsField = options.itemsField || DEFAULT_ITEMS_FIELD;
1460
1473
  const totalCountField = options.totalCountField || DEFAULT_TOTAL_COUNT_FIELD;
1461
1474
  // Determine endpoint and headers based on folderId
1462
1475
  const endpoint = folderId ? getByFolderEndpoint : getAllEndpoint;
1463
- const headers = folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {};
1476
+ const headers = providedHeaders ?? (folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {});
1464
1477
  // Make the API call based on method
1465
1478
  let response;
1466
1479
  if (method === HTTP_METHODS.POST) {
@@ -1519,6 +1532,7 @@ class PaginationHelpers {
1519
1532
  serviceAccess: config.serviceAccess,
1520
1533
  getEndpoint: config.getEndpoint,
1521
1534
  folderId,
1535
+ headers: config.headers,
1522
1536
  paginationParams: cursor ? { cursor, pageSize } : jumpToPage ? { jumpToPage, pageSize } : { pageSize },
1523
1537
  additionalParams: prefixedOptions,
1524
1538
  transformFn: config.transformFn,
@@ -1536,6 +1550,7 @@ class PaginationHelpers {
1536
1550
  getAllEndpoint: config.getEndpoint(),
1537
1551
  getByFolderEndpoint: byFolderEndpoint,
1538
1552
  folderId,
1553
+ headers: config.headers,
1539
1554
  additionalParams: prefixedOptions,
1540
1555
  transformFn: config.transformFn,
1541
1556
  method: config.method,
@@ -2503,6 +2518,52 @@ class MaestroProcessesService extends BaseService {
2503
2518
  const { data } = await this.post(MAESTRO_ENDPOINTS.INSIGHTS.TOP_PROCESSES_BY_RUN_COUNT, buildInsightsTopBody(startTime, endTime, false, options));
2504
2519
  return (data ?? []).map(process => ({ ...process, name: process.packageId }));
2505
2520
  }
2521
+ /**
2522
+ * Get the top 10 BPMN elements ranked by failure count within a time range.
2523
+ *
2524
+ * Returns an array of up to 10 elements sorted by how many times they failed,
2525
+ * useful for identifying the most error-prone activities in processes.
2526
+ *
2527
+ * @param startTime - Start of the time range to query
2528
+ * @param endTime - End of the time range to query
2529
+ * @param options - Optional filters (packageId, processKey, version)
2530
+ * @returns Promise resolving to an array of {@link ElementGetTopFailedCountResponse}
2531
+ * @example
2532
+ * ```typescript
2533
+ * import { MaestroProcesses } from '@uipath/uipath-typescript/maestro-processes';
2534
+ *
2535
+ * const maestroProcesses = new MaestroProcesses(sdk);
2536
+ *
2537
+ * // Get top failing elements for the last 7 days
2538
+ * const topFailing = await maestroProcesses.getTopElementFailedCount(
2539
+ * new Date(Date.now() - 7 * 24 * 60 * 60 * 1000),
2540
+ * new Date()
2541
+ * );
2542
+ *
2543
+ * for (const element of topFailing) {
2544
+ * console.log(`${element.elementName} (${element.elementType}): ${element.failedCount} failures`);
2545
+ * }
2546
+ * ```
2547
+ *
2548
+ * @example
2549
+ * ```typescript
2550
+ * // Get top failing elements for a specific process
2551
+ * const filtered = await maestroProcesses.getTopElementFailedCount(
2552
+ * new Date(Date.now() - 7 * 24 * 60 * 60 * 1000),
2553
+ * new Date(),
2554
+ * { processKey: '<processKey>' }
2555
+ * );
2556
+ * ```
2557
+ */
2558
+ async getTopElementFailedCount(startTime, endTime, options) {
2559
+ const { data } = await this.post(MAESTRO_ENDPOINTS.INSIGHTS.TOP_ELEMENTS_WITH_FAILURE, buildInsightsTopBody(startTime, endTime, false, options));
2560
+ return (data ?? []).map(item => ({
2561
+ elementName: item.elementName,
2562
+ elementType: item.elementType,
2563
+ processKey: item.processKey,
2564
+ failedCount: item.count,
2565
+ }));
2566
+ }
2506
2567
  /**
2507
2568
  * Get all instances status counts aggregated by date for maestro processes.
2508
2569
  *
@@ -2643,6 +2704,9 @@ __decorate([
2643
2704
  __decorate([
2644
2705
  track('MaestroProcesses.GetTopRunCount')
2645
2706
  ], MaestroProcessesService.prototype, "getTopRunCount", null);
2707
+ __decorate([
2708
+ track('MaestroProcesses.GetTopElementFailedCount')
2709
+ ], MaestroProcessesService.prototype, "getTopElementFailedCount", null);
2646
2710
  __decorate([
2647
2711
  track('MaestroProcesses.GetInstanceStatusTimeline')
2648
2712
  ], MaestroProcessesService.prototype, "getInstanceStatusTimeline", null);
@@ -39,6 +39,20 @@ interface GetTopFaultedCountResponse extends GetTopBaseResponse {
39
39
  /** Number of faulted instances in the given time range */
40
40
  faultedCount: number;
41
41
  }
42
+ /**
43
+ * SDK response for top elements with failure.
44
+ * Shared by both MaestroProcesses and Cases — no service-specific enrichment.
45
+ */
46
+ interface ElementGetTopFailedCountResponse {
47
+ /** BPMN element name (falls back to element ID if name is empty) */
48
+ elementName: string;
49
+ /** BPMN element type (e.g. ServiceTask, ReceiveTask, IntermediateCatchEvent) */
50
+ elementType: string;
51
+ /** The unique process key this element belongs to */
52
+ processKey: string;
53
+ /** Number of failed executions of this element in the given time range */
54
+ failedCount: number;
55
+ }
42
56
  /**
43
57
  * Time bucketing granularity for insights time-series queries.
44
58
  *
@@ -364,6 +378,44 @@ interface MaestroProcessesServiceModel {
364
378
  * ```
365
379
  */
366
380
  getTopFaultedCount(startTime: Date, endTime: Date, options?: TopQueryOptions): Promise<ProcessGetTopFaultedCountResponse[]>;
381
+ /**
382
+ * Get the top 10 BPMN elements ranked by failure count within a time range.
383
+ *
384
+ * Returns an array of up to 10 elements sorted by how many times they failed,
385
+ * useful for identifying the most error-prone activities in processes.
386
+ *
387
+ * @param startTime - Start of the time range to query
388
+ * @param endTime - End of the time range to query
389
+ * @param options - Optional filters (packageId, processKey, version)
390
+ * @returns Promise resolving to an array of {@link ElementGetTopFailedCountResponse}
391
+ * @example
392
+ * ```typescript
393
+ * import { MaestroProcesses } from '@uipath/uipath-typescript/maestro-processes';
394
+ *
395
+ * const maestroProcesses = new MaestroProcesses(sdk);
396
+ *
397
+ * // Get top failing elements for the last 7 days
398
+ * const topFailing = await maestroProcesses.getTopElementFailedCount(
399
+ * new Date(Date.now() - 7 * 24 * 60 * 60 * 1000),
400
+ * new Date()
401
+ * );
402
+ *
403
+ * for (const element of topFailing) {
404
+ * console.log(`${element.elementName} (${element.elementType}): ${element.failedCount} failures`);
405
+ * }
406
+ * ```
407
+ *
408
+ * @example
409
+ * ```typescript
410
+ * // Get top failing elements for a specific process
411
+ * const filtered = await maestroProcesses.getTopElementFailedCount(
412
+ * new Date(Date.now() - 7 * 24 * 60 * 60 * 1000),
413
+ * new Date(),
414
+ * { processKey: '<processKey>' }
415
+ * );
416
+ * ```
417
+ */
418
+ getTopElementFailedCount(startTime: Date, endTime: Date, options?: TopQueryOptions): Promise<ElementGetTopFailedCountResponse[]>;
367
419
  /**
368
420
  * Get all instances status counts aggregated by date for maestro processes.
369
421
  *
@@ -1289,6 +1341,44 @@ declare class MaestroProcessesService extends BaseService implements MaestroProc
1289
1341
  * ```
1290
1342
  */
1291
1343
  getTopRunCount(startTime: Date, endTime: Date, options?: TopQueryOptions): Promise<ProcessGetTopRunCountResponse[]>;
1344
+ /**
1345
+ * Get the top 10 BPMN elements ranked by failure count within a time range.
1346
+ *
1347
+ * Returns an array of up to 10 elements sorted by how many times they failed,
1348
+ * useful for identifying the most error-prone activities in processes.
1349
+ *
1350
+ * @param startTime - Start of the time range to query
1351
+ * @param endTime - End of the time range to query
1352
+ * @param options - Optional filters (packageId, processKey, version)
1353
+ * @returns Promise resolving to an array of {@link ElementGetTopFailedCountResponse}
1354
+ * @example
1355
+ * ```typescript
1356
+ * import { MaestroProcesses } from '@uipath/uipath-typescript/maestro-processes';
1357
+ *
1358
+ * const maestroProcesses = new MaestroProcesses(sdk);
1359
+ *
1360
+ * // Get top failing elements for the last 7 days
1361
+ * const topFailing = await maestroProcesses.getTopElementFailedCount(
1362
+ * new Date(Date.now() - 7 * 24 * 60 * 60 * 1000),
1363
+ * new Date()
1364
+ * );
1365
+ *
1366
+ * for (const element of topFailing) {
1367
+ * console.log(`${element.elementName} (${element.elementType}): ${element.failedCount} failures`);
1368
+ * }
1369
+ * ```
1370
+ *
1371
+ * @example
1372
+ * ```typescript
1373
+ * // Get top failing elements for a specific process
1374
+ * const filtered = await maestroProcesses.getTopElementFailedCount(
1375
+ * new Date(Date.now() - 7 * 24 * 60 * 60 * 1000),
1376
+ * new Date(),
1377
+ * { processKey: '<processKey>' }
1378
+ * );
1379
+ * ```
1380
+ */
1381
+ getTopElementFailedCount(startTime: Date, endTime: Date, options?: TopQueryOptions): Promise<ElementGetTopFailedCountResponse[]>;
1292
1382
  /**
1293
1383
  * Get all instances status counts aggregated by date for maestro processes.
1294
1384
  *
@@ -1562,4 +1652,4 @@ declare class ProcessIncidentsService extends BaseService implements ProcessInci
1562
1652
  }
1563
1653
 
1564
1654
  export { DebugMode, InstanceFinalStatus, MaestroProcessesService as MaestroProcesses, MaestroProcessesService, ProcessIncidentSeverity, ProcessIncidentStatus, ProcessIncidentType, ProcessIncidentsService as ProcessIncidents, ProcessIncidentsService, ProcessInstancesService as ProcessInstances, ProcessInstancesService, TimeInterval, createProcessInstanceWithMethods, createProcessWithMethods };
1565
- export type { BpmnXmlString, ElementMetaData, GetTopBaseResponse, GetTopDurationResponse, GetTopFaultedCountResponse, GetTopRunCountResponse, GlobalVariableMetaData, InstanceStatusTimelineResponse, MaestroProcessGetAllResponse, MaestroProcessesServiceModel, ProcessGetTopDurationResponse, ProcessGetTopFaultedCountResponse, ProcessGetTopRunCountResponse, ProcessIncidentGetAllResponse, ProcessIncidentGetResponse, ProcessIncidentsServiceModel, ProcessInstanceExecutionHistoryResponse, ProcessInstanceGetAllOptions, ProcessInstanceGetAllWithPaginationOptions, ProcessInstanceGetResponse, ProcessInstanceGetVariablesOptions, ProcessInstanceGetVariablesResponse, ProcessInstanceMethods, ProcessInstanceOperationOptions, ProcessInstanceOperationResponse, ProcessInstanceRun, ProcessInstancesServiceModel, ProcessMethods, RawMaestroProcessGetAllResponse, RawProcessInstanceGetResponse, TimelineOptions, TopQueryOptions };
1655
+ export type { BpmnXmlString, ElementGetTopFailedCountResponse, ElementMetaData, GetTopBaseResponse, GetTopDurationResponse, GetTopFaultedCountResponse, GetTopRunCountResponse, GlobalVariableMetaData, InstanceStatusTimelineResponse, MaestroProcessGetAllResponse, MaestroProcessesServiceModel, ProcessGetTopDurationResponse, ProcessGetTopFaultedCountResponse, ProcessGetTopRunCountResponse, ProcessIncidentGetAllResponse, ProcessIncidentGetResponse, ProcessIncidentsServiceModel, ProcessInstanceExecutionHistoryResponse, ProcessInstanceGetAllOptions, ProcessInstanceGetAllWithPaginationOptions, ProcessInstanceGetResponse, ProcessInstanceGetVariablesOptions, ProcessInstanceGetVariablesResponse, ProcessInstanceMethods, ProcessInstanceOperationOptions, ProcessInstanceOperationResponse, ProcessInstanceRun, ProcessInstancesServiceModel, ProcessMethods, RawMaestroProcessGetAllResponse, RawProcessInstanceGetResponse, TimelineOptions, TopQueryOptions };
@@ -77,6 +77,8 @@ const MAESTRO_ENDPOINTS = {
77
77
  TOP_PROCESSES_BY_RUN_COUNT: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/TopProcessesByRunCount`,
78
78
  /** Top processes ranked by failure count */
79
79
  TOP_PROCESSES_WITH_FAILURE: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/TopProcesseswithFailure`,
80
+ /** Top elements ranked by failure count */
81
+ TOP_ELEMENTS_WITH_FAILURE: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/TopElementswithFailure`,
80
82
  /** Instance status aggregated by date for time-series charts */
81
83
  INSTANCE_STATUS_BY_DATE: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/InstanceStatusByDate`,
82
84
  /** Top processes ranked by total duration */
@@ -1048,14 +1050,25 @@ class ApiClient {
1048
1050
  if (!text) {
1049
1051
  return undefined;
1050
1052
  }
1051
- return JSON.parse(text);
1053
+ try {
1054
+ return JSON.parse(text);
1055
+ }
1056
+ catch (error) {
1057
+ if (error instanceof SyntaxError) {
1058
+ throw new ServerError({
1059
+ message: `Server returned non-JSON response (${response.status} ${response.url}): ${error.message}`,
1060
+ statusCode: response.status,
1061
+ });
1062
+ }
1063
+ throw error;
1064
+ }
1052
1065
  }
1053
1066
  catch (error) {
1054
1067
  // If it's already one of our errors, re-throw it
1055
1068
  if (error.type && error.type.includes('Error')) {
1056
1069
  throw error;
1057
1070
  }
1058
- // Otherwise, it's likely a network error
1071
+ // Otherwise, it's a genuine network/fetch failure
1059
1072
  throw ErrorFactory.createNetworkError(error);
1060
1073
  }
1061
1074
  }
@@ -1422,9 +1435,9 @@ class PaginationHelpers {
1422
1435
  * @returns Promise resolving to a paginated result
1423
1436
  */
1424
1437
  static async getAllPaginated(params) {
1425
- const { serviceAccess, getEndpoint, folderId, paginationParams, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
1438
+ const { serviceAccess, getEndpoint, folderId, headers: providedHeaders, paginationParams, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
1426
1439
  const endpoint = getEndpoint(folderId);
1427
- const headers = folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {};
1440
+ const headers = providedHeaders ?? (folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {});
1428
1441
  const paginatedResponse = await serviceAccess.requestWithPagination(method, endpoint, paginationParams, {
1429
1442
  headers,
1430
1443
  params: additionalParams,
@@ -1452,13 +1465,13 @@ class PaginationHelpers {
1452
1465
  * @returns Promise resolving to an object with data and totalCount
1453
1466
  */
1454
1467
  static async getAllNonPaginated(params) {
1455
- const { serviceAccess, getAllEndpoint, getByFolderEndpoint, folderId, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
1468
+ const { serviceAccess, getAllEndpoint, getByFolderEndpoint, folderId, headers: providedHeaders, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
1456
1469
  // Set default field names
1457
1470
  const itemsField = options.itemsField || DEFAULT_ITEMS_FIELD;
1458
1471
  const totalCountField = options.totalCountField || DEFAULT_TOTAL_COUNT_FIELD;
1459
1472
  // Determine endpoint and headers based on folderId
1460
1473
  const endpoint = folderId ? getByFolderEndpoint : getAllEndpoint;
1461
- const headers = folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {};
1474
+ const headers = providedHeaders ?? (folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {});
1462
1475
  // Make the API call based on method
1463
1476
  let response;
1464
1477
  if (method === HTTP_METHODS.POST) {
@@ -1517,6 +1530,7 @@ class PaginationHelpers {
1517
1530
  serviceAccess: config.serviceAccess,
1518
1531
  getEndpoint: config.getEndpoint,
1519
1532
  folderId,
1533
+ headers: config.headers,
1520
1534
  paginationParams: cursor ? { cursor, pageSize } : jumpToPage ? { jumpToPage, pageSize } : { pageSize },
1521
1535
  additionalParams: prefixedOptions,
1522
1536
  transformFn: config.transformFn,
@@ -1534,6 +1548,7 @@ class PaginationHelpers {
1534
1548
  getAllEndpoint: config.getEndpoint(),
1535
1549
  getByFolderEndpoint: byFolderEndpoint,
1536
1550
  folderId,
1551
+ headers: config.headers,
1537
1552
  additionalParams: prefixedOptions,
1538
1553
  transformFn: config.transformFn,
1539
1554
  method: config.method,
@@ -2501,6 +2516,52 @@ class MaestroProcessesService extends BaseService {
2501
2516
  const { data } = await this.post(MAESTRO_ENDPOINTS.INSIGHTS.TOP_PROCESSES_BY_RUN_COUNT, buildInsightsTopBody(startTime, endTime, false, options));
2502
2517
  return (data ?? []).map(process => ({ ...process, name: process.packageId }));
2503
2518
  }
2519
+ /**
2520
+ * Get the top 10 BPMN elements ranked by failure count within a time range.
2521
+ *
2522
+ * Returns an array of up to 10 elements sorted by how many times they failed,
2523
+ * useful for identifying the most error-prone activities in processes.
2524
+ *
2525
+ * @param startTime - Start of the time range to query
2526
+ * @param endTime - End of the time range to query
2527
+ * @param options - Optional filters (packageId, processKey, version)
2528
+ * @returns Promise resolving to an array of {@link ElementGetTopFailedCountResponse}
2529
+ * @example
2530
+ * ```typescript
2531
+ * import { MaestroProcesses } from '@uipath/uipath-typescript/maestro-processes';
2532
+ *
2533
+ * const maestroProcesses = new MaestroProcesses(sdk);
2534
+ *
2535
+ * // Get top failing elements for the last 7 days
2536
+ * const topFailing = await maestroProcesses.getTopElementFailedCount(
2537
+ * new Date(Date.now() - 7 * 24 * 60 * 60 * 1000),
2538
+ * new Date()
2539
+ * );
2540
+ *
2541
+ * for (const element of topFailing) {
2542
+ * console.log(`${element.elementName} (${element.elementType}): ${element.failedCount} failures`);
2543
+ * }
2544
+ * ```
2545
+ *
2546
+ * @example
2547
+ * ```typescript
2548
+ * // Get top failing elements for a specific process
2549
+ * const filtered = await maestroProcesses.getTopElementFailedCount(
2550
+ * new Date(Date.now() - 7 * 24 * 60 * 60 * 1000),
2551
+ * new Date(),
2552
+ * { processKey: '<processKey>' }
2553
+ * );
2554
+ * ```
2555
+ */
2556
+ async getTopElementFailedCount(startTime, endTime, options) {
2557
+ const { data } = await this.post(MAESTRO_ENDPOINTS.INSIGHTS.TOP_ELEMENTS_WITH_FAILURE, buildInsightsTopBody(startTime, endTime, false, options));
2558
+ return (data ?? []).map(item => ({
2559
+ elementName: item.elementName,
2560
+ elementType: item.elementType,
2561
+ processKey: item.processKey,
2562
+ failedCount: item.count,
2563
+ }));
2564
+ }
2504
2565
  /**
2505
2566
  * Get all instances status counts aggregated by date for maestro processes.
2506
2567
  *
@@ -2641,6 +2702,9 @@ __decorate([
2641
2702
  __decorate([
2642
2703
  track('MaestroProcesses.GetTopRunCount')
2643
2704
  ], MaestroProcessesService.prototype, "getTopRunCount", null);
2705
+ __decorate([
2706
+ track('MaestroProcesses.GetTopElementFailedCount')
2707
+ ], MaestroProcessesService.prototype, "getTopElementFailedCount", null);
2644
2708
  __decorate([
2645
2709
  track('MaestroProcesses.GetInstanceStatusTimeline')
2646
2710
  ], MaestroProcessesService.prototype, "getInstanceStatusTimeline", null);