@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
@@ -503,6 +503,45 @@ interface BlobItem {
503
503
  */
504
504
  lastModified: string | null;
505
505
  }
506
+ /**
507
+ * Represents a file or directory entry in a bucket
508
+ */
509
+ interface BucketFile {
510
+ /**
511
+ * Full path to the file or directory
512
+ */
513
+ path: string;
514
+ /**
515
+ * Content type of the file (empty for directories)
516
+ */
517
+ contentType: string;
518
+ /**
519
+ * Size of the file in bytes
520
+ */
521
+ size: number;
522
+ /**
523
+ * Whether the entry is a directory
524
+ */
525
+ isDirectory: boolean;
526
+ /**
527
+ * Identifier of the file, when available
528
+ */
529
+ id: string | null;
530
+ }
531
+ /**
532
+ * Options for listing files in a bucket directory
533
+ */
534
+ type BucketGetFilesOptions = RequestOptions & PaginationOptions & FolderScopedOptions & {
535
+ /**
536
+ * Regex pattern to filter file names (e.g., '.*\\.pdf$')
537
+ */
538
+ fileNameRegex?: string;
539
+ };
540
+ /**
541
+ * Options for deleting a file from a bucket
542
+ */
543
+ interface BucketDeleteFileOptions extends FolderScopedOptions {
544
+ }
506
545
  /**
507
546
  * Options for uploading files to a bucket
508
547
  */
@@ -708,6 +747,64 @@ interface BucketServiceModel {
708
747
  * ```
709
748
  */
710
749
  uploadFile(options: BucketUploadFileOptions): Promise<BucketUploadResponse>;
750
+ /**
751
+ * Deletes a file from a bucket
752
+ *
753
+ * @param bucketId - The ID of the bucket
754
+ * @param path - The full path to the file to delete
755
+ * @param options - Folder scoping (`folderId` / `folderKey` / `folderPath`)
756
+ * @returns Promise resolving when the file is deleted
757
+ * @example
758
+ * ```typescript
759
+ * // Delete a file from a bucket
760
+ * await buckets.deleteFile(<bucketId>, '/folder/file.pdf', { folderId: <folderId> });
761
+ * ```
762
+ */
763
+ deleteFile(bucketId: number, path: string, options?: BucketDeleteFileOptions): Promise<void>;
764
+ /**
765
+ * Lists all files in a bucket.
766
+ *
767
+ * Returns a flat, recursive listing of all files in the bucket. Supports regex filtering
768
+ * and filter / orderby / select / expand. {@link BucketFile} entries include
769
+ * `isDirectory` so callers can distinguish folders from files.
770
+ *
771
+ * The method returns either:
772
+ * - A NonPaginatedResponse with items array (when no pagination parameters are provided)
773
+ * - A PaginatedResponse with navigation cursors (when any pagination parameter is provided)
774
+ *
775
+ * @param bucketId - The ID of the bucket
776
+ * @param options - Folder scoping (`folderId` / `folderKey` / `folderPath`) and optional parameters for regex filtering, query options, and pagination
777
+ * {@link BucketGetFilesOptions}
778
+ * @returns Promise resolving to either an array of files NonPaginatedResponse<BucketFile> or a PaginatedResponse<BucketFile> when pagination options are used.
779
+ * {@link BucketFile}
780
+ * @example
781
+ * ```typescript
782
+ * // List all files in the bucket
783
+ * const files = await buckets.getFiles(<bucketId>, { folderId: <folderId> });
784
+ *
785
+ * // Filter by regex pattern
786
+ * const pdfs = await buckets.getFiles(<bucketId>, {
787
+ * folderId: <folderId>,
788
+ * fileNameRegex: '.*\\.pdf$'
789
+ * });
790
+ *
791
+ * // First page with pagination
792
+ * const page1 = await buckets.getFiles(<bucketId>, { folderId: <folderId>, pageSize: 10 });
793
+ *
794
+ * // Navigate using cursor
795
+ * if (page1.hasNextPage) {
796
+ * const page2 = await buckets.getFiles(<bucketId>, { folderId: <folderId>, cursor: page1.nextCursor });
797
+ * }
798
+ *
799
+ * // Jump to specific page
800
+ * const page5 = await buckets.getFiles(<bucketId>, {
801
+ * folderId: <folderId>,
802
+ * jumpToPage: 5,
803
+ * pageSize: 10
804
+ * });
805
+ * ```
806
+ */
807
+ getFiles<T extends BucketGetFilesOptions = BucketGetFilesOptions>(bucketId: number, options?: T): Promise<T extends HasPaginationOptions<T> ? PaginatedResponse<BucketFile> : NonPaginatedResponse<BucketFile>>;
711
808
  }
712
809
 
713
810
  declare class BucketService extends FolderScopedService implements BucketServiceModel {
@@ -904,6 +1001,72 @@ declare class BucketService extends FolderScopedService implements BucketService
904
1001
  * @returns Promise resolving to blob file access information
905
1002
  */
906
1003
  private _getUri;
1004
+ /**
1005
+ * Lists all files in a bucket.
1006
+ *
1007
+ * Returns a flat, recursive listing of all files in the bucket. Supports regex filtering
1008
+ * and filter / orderby / select / expand. {@link BucketFile} entries include
1009
+ * `isDirectory` so callers can distinguish folders from files.
1010
+ *
1011
+ * The method returns either:
1012
+ * - A NonPaginatedResponse with items array (when no pagination parameters are provided)
1013
+ * - A PaginatedResponse with navigation cursors (when any pagination parameter is provided)
1014
+ *
1015
+ * @param bucketId - The ID of the bucket
1016
+ * @param options - Folder scoping (`folderId` / `folderKey` / `folderPath`) and optional parameters for regex filtering, query options, and pagination
1017
+ * @returns Promise resolving to either an array of files NonPaginatedResponse<BucketFile> or a PaginatedResponse<BucketFile> when pagination options are used.
1018
+ *
1019
+ * @example
1020
+ * ```typescript
1021
+ * import { Buckets } from '@uipath/uipath-typescript/buckets';
1022
+ *
1023
+ * const buckets = new Buckets(sdk);
1024
+ *
1025
+ * // List all files in the bucket
1026
+ * const files = await buckets.getFiles(<bucketId>, { folderId: <folderId> });
1027
+ *
1028
+ * // Filter by regex pattern
1029
+ * const pdfs = await buckets.getFiles(<bucketId>, {
1030
+ * folderId: <folderId>,
1031
+ * fileNameRegex: '.*\\.pdf$'
1032
+ * });
1033
+ *
1034
+ * // First page with pagination
1035
+ * const page1 = await buckets.getFiles(<bucketId>, { folderId: <folderId>, pageSize: 10 });
1036
+ *
1037
+ * // Navigate using cursor
1038
+ * if (page1.hasNextPage) {
1039
+ * const page2 = await buckets.getFiles(<bucketId>, { folderId: <folderId>, cursor: page1.nextCursor });
1040
+ * }
1041
+ *
1042
+ * // Jump to specific page
1043
+ * const page5 = await buckets.getFiles(<bucketId>, {
1044
+ * folderId: <folderId>,
1045
+ * jumpToPage: 5,
1046
+ * pageSize: 10
1047
+ * });
1048
+ * ```
1049
+ */
1050
+ getFiles<T extends BucketGetFilesOptions = BucketGetFilesOptions>(bucketId: number, options?: T): Promise<T extends HasPaginationOptions<T> ? PaginatedResponse<BucketFile> : NonPaginatedResponse<BucketFile>>;
1051
+ /**
1052
+ * Deletes a file from a bucket
1053
+ *
1054
+ * @param bucketId - The ID of the bucket
1055
+ * @param path - The full path to the file to delete
1056
+ * @param options - Folder scoping (`folderId` / `folderKey` / `folderPath`)
1057
+ * @returns Promise resolving when the file is deleted
1058
+ *
1059
+ * @example
1060
+ * ```typescript
1061
+ * import { Buckets } from '@uipath/uipath-typescript/buckets';
1062
+ *
1063
+ * const buckets = new Buckets(sdk);
1064
+ *
1065
+ * // Delete a file from a bucket
1066
+ * await buckets.deleteFile(<bucketId>, '/folder/file.pdf', { folderId: <folderId> });
1067
+ * ```
1068
+ */
1069
+ deleteFile(bucketId: number, path: string, options?: BucketDeleteFileOptions): Promise<void>;
907
1070
  /**
908
1071
  * Gets a direct upload URL for a file in the bucket
909
1072
  *
@@ -914,4 +1077,4 @@ declare class BucketService extends FolderScopedService implements BucketService
914
1077
  }
915
1078
 
916
1079
  export { BucketOptions, BucketService, BucketService as Buckets };
917
- export type { BlobItem, BucketGetAllOptions, BucketGetByIdOptions, BucketGetByNameOptions, BucketGetFileMetaDataOptions, BucketGetFileMetaDataResponse, BucketGetFileMetaDataWithPaginationOptions, BucketGetReadUriOptions, BucketGetResponse, BucketGetUriOptions, BucketGetUriResponse, BucketServiceModel, BucketUploadFileOptions, BucketUploadResponse, ResponseDictionary };
1080
+ export type { BlobItem, BucketDeleteFileOptions, BucketFile, BucketGetAllOptions, BucketGetByIdOptions, BucketGetByNameOptions, BucketGetFileMetaDataOptions, BucketGetFileMetaDataResponse, BucketGetFileMetaDataWithPaginationOptions, BucketGetFilesOptions, BucketGetReadUriOptions, BucketGetResponse, BucketGetUriOptions, BucketGetUriResponse, BucketServiceModel, BucketUploadFileOptions, BucketUploadResponse, ResponseDictionary };
@@ -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
  }
@@ -1262,9 +1273,9 @@ class PaginationHelpers {
1262
1273
  * @returns Promise resolving to a paginated result
1263
1274
  */
1264
1275
  static async getAllPaginated(params) {
1265
- const { serviceAccess, getEndpoint, folderId, paginationParams, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
1276
+ const { serviceAccess, getEndpoint, folderId, headers: providedHeaders, paginationParams, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
1266
1277
  const endpoint = getEndpoint(folderId);
1267
- const headers = folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {};
1278
+ const headers = providedHeaders ?? (folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {});
1268
1279
  const paginatedResponse = await serviceAccess.requestWithPagination(method, endpoint, paginationParams, {
1269
1280
  headers,
1270
1281
  params: additionalParams,
@@ -1292,13 +1303,13 @@ class PaginationHelpers {
1292
1303
  * @returns Promise resolving to an object with data and totalCount
1293
1304
  */
1294
1305
  static async getAllNonPaginated(params) {
1295
- const { serviceAccess, getAllEndpoint, getByFolderEndpoint, folderId, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
1306
+ const { serviceAccess, getAllEndpoint, getByFolderEndpoint, folderId, headers: providedHeaders, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
1296
1307
  // Set default field names
1297
1308
  const itemsField = options.itemsField || DEFAULT_ITEMS_FIELD;
1298
1309
  const totalCountField = options.totalCountField || DEFAULT_TOTAL_COUNT_FIELD;
1299
1310
  // Determine endpoint and headers based on folderId
1300
1311
  const endpoint = folderId ? getByFolderEndpoint : getAllEndpoint;
1301
- const headers = folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {};
1312
+ const headers = providedHeaders ?? (folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {});
1302
1313
  // Make the API call based on method
1303
1314
  let response;
1304
1315
  if (method === HTTP_METHODS.POST) {
@@ -1357,6 +1368,7 @@ class PaginationHelpers {
1357
1368
  serviceAccess: config.serviceAccess,
1358
1369
  getEndpoint: config.getEndpoint,
1359
1370
  folderId,
1371
+ headers: config.headers,
1360
1372
  paginationParams: cursor ? { cursor, pageSize } : jumpToPage ? { jumpToPage, pageSize } : { pageSize },
1361
1373
  additionalParams: prefixedOptions,
1362
1374
  transformFn: config.transformFn,
@@ -1374,6 +1386,7 @@ class PaginationHelpers {
1374
1386
  getAllEndpoint: config.getEndpoint(),
1375
1387
  getByFolderEndpoint: byFolderEndpoint,
1376
1388
  folderId,
1389
+ headers: config.headers,
1377
1390
  additionalParams: prefixedOptions,
1378
1391
  transformFn: config.transformFn,
1379
1392
  method: config.method,
@@ -1918,6 +1931,8 @@ const BUCKET_ENDPOINTS = {
1918
1931
  GET_FILE_META_DATA: (id) => `${ORCHESTRATOR_BASE}/api/Buckets/${id}/ListFiles`,
1919
1932
  GET_READ_URI: (id) => `${ORCHESTRATOR_BASE}/odata/Buckets(${id})/UiPath.Server.Configuration.OData.GetReadUri`,
1920
1933
  GET_WRITE_URI: (id) => `${ORCHESTRATOR_BASE}/odata/Buckets(${id})/UiPath.Server.Configuration.OData.GetWriteUri`,
1934
+ DELETE_FILE: (id) => `${ORCHESTRATOR_BASE}/odata/Buckets(${id})/UiPath.Server.Configuration.OData.DeleteFile`,
1935
+ GET_FILES: (id) => `${ORCHESTRATOR_BASE}/odata/Buckets(${id})/UiPath.Server.Configuration.OData.GetFiles`,
1921
1936
  };
1922
1937
 
1923
1938
  /**
@@ -2291,6 +2306,120 @@ class BucketService extends FolderScopedService {
2291
2306
  }
2292
2307
  return transformedData;
2293
2308
  }
2309
+ /**
2310
+ * Lists all files in a bucket.
2311
+ *
2312
+ * Returns a flat, recursive listing of all files in the bucket. Supports regex filtering
2313
+ * and filter / orderby / select / expand. {@link BucketFile} entries include
2314
+ * `isDirectory` so callers can distinguish folders from files.
2315
+ *
2316
+ * The method returns either:
2317
+ * - A NonPaginatedResponse with items array (when no pagination parameters are provided)
2318
+ * - A PaginatedResponse with navigation cursors (when any pagination parameter is provided)
2319
+ *
2320
+ * @param bucketId - The ID of the bucket
2321
+ * @param options - Folder scoping (`folderId` / `folderKey` / `folderPath`) and optional parameters for regex filtering, query options, and pagination
2322
+ * @returns Promise resolving to either an array of files NonPaginatedResponse<BucketFile> or a PaginatedResponse<BucketFile> when pagination options are used.
2323
+ *
2324
+ * @example
2325
+ * ```typescript
2326
+ * import { Buckets } from '@uipath/uipath-typescript/buckets';
2327
+ *
2328
+ * const buckets = new Buckets(sdk);
2329
+ *
2330
+ * // List all files in the bucket
2331
+ * const files = await buckets.getFiles(<bucketId>, { folderId: <folderId> });
2332
+ *
2333
+ * // Filter by regex pattern
2334
+ * const pdfs = await buckets.getFiles(<bucketId>, {
2335
+ * folderId: <folderId>,
2336
+ * fileNameRegex: '.*\\.pdf$'
2337
+ * });
2338
+ *
2339
+ * // First page with pagination
2340
+ * const page1 = await buckets.getFiles(<bucketId>, { folderId: <folderId>, pageSize: 10 });
2341
+ *
2342
+ * // Navigate using cursor
2343
+ * if (page1.hasNextPage) {
2344
+ * const page2 = await buckets.getFiles(<bucketId>, { folderId: <folderId>, cursor: page1.nextCursor });
2345
+ * }
2346
+ *
2347
+ * // Jump to specific page
2348
+ * const page5 = await buckets.getFiles(<bucketId>, {
2349
+ * folderId: <folderId>,
2350
+ * jumpToPage: 5,
2351
+ * pageSize: 10
2352
+ * });
2353
+ * ```
2354
+ */
2355
+ async getFiles(bucketId, options) {
2356
+ if (!bucketId) {
2357
+ throw new ValidationError({ message: 'bucketId is required for getFiles' });
2358
+ }
2359
+ const { folderId, folderKey, folderPath, ...restOptions } = options ?? {};
2360
+ const headers = resolveFolderHeaders({
2361
+ folderId,
2362
+ folderKey,
2363
+ folderPath,
2364
+ resourceType: 'Buckets.getFiles',
2365
+ fallbackFolderKey: this.config.folderKey,
2366
+ });
2367
+ const transformBucketFile = (file) => transformData(pascalToCamelCaseKeys(file), BucketMap);
2368
+ return PaginationHelpers.getAll({
2369
+ serviceAccess: this.createPaginationServiceAccess(),
2370
+ getEndpoint: () => BUCKET_ENDPOINTS.GET_FILES(bucketId),
2371
+ transformFn: transformBucketFile,
2372
+ pagination: {
2373
+ paginationType: PaginationType.OFFSET,
2374
+ itemsField: ODATA_PAGINATION.ITEMS_FIELD,
2375
+ totalCountField: ODATA_PAGINATION.TOTAL_COUNT_FIELD,
2376
+ paginationParams: {
2377
+ pageSizeParam: ODATA_OFFSET_PARAMS.PAGE_SIZE_PARAM,
2378
+ offsetParam: ODATA_OFFSET_PARAMS.OFFSET_PARAM,
2379
+ countParam: ODATA_OFFSET_PARAMS.COUNT_PARAM,
2380
+ },
2381
+ },
2382
+ excludeFromPrefix: ['directory', 'recursive', 'fileNameRegex'],
2383
+ headers,
2384
+ }, { ...restOptions, directory: '/', recursive: true });
2385
+ }
2386
+ /**
2387
+ * Deletes a file from a bucket
2388
+ *
2389
+ * @param bucketId - The ID of the bucket
2390
+ * @param path - The full path to the file to delete
2391
+ * @param options - Folder scoping (`folderId` / `folderKey` / `folderPath`)
2392
+ * @returns Promise resolving when the file is deleted
2393
+ *
2394
+ * @example
2395
+ * ```typescript
2396
+ * import { Buckets } from '@uipath/uipath-typescript/buckets';
2397
+ *
2398
+ * const buckets = new Buckets(sdk);
2399
+ *
2400
+ * // Delete a file from a bucket
2401
+ * await buckets.deleteFile(<bucketId>, '/folder/file.pdf', { folderId: <folderId> });
2402
+ * ```
2403
+ */
2404
+ async deleteFile(bucketId, path, options) {
2405
+ if (!bucketId) {
2406
+ throw new ValidationError({ message: 'bucketId is required for deleteFile' });
2407
+ }
2408
+ if (!path) {
2409
+ throw new ValidationError({ message: 'path is required for deleteFile' });
2410
+ }
2411
+ const headers = resolveFolderHeaders({
2412
+ folderId: options?.folderId,
2413
+ folderKey: options?.folderKey,
2414
+ folderPath: options?.folderPath,
2415
+ resourceType: 'Buckets.deleteFile',
2416
+ fallbackFolderKey: this.config.folderKey,
2417
+ });
2418
+ await this.delete(BUCKET_ENDPOINTS.DELETE_FILE(bucketId), {
2419
+ params: { path },
2420
+ headers,
2421
+ });
2422
+ }
2294
2423
  /**
2295
2424
  * Gets a direct upload URL for a file in the bucket
2296
2425
  *
@@ -2324,6 +2453,12 @@ __decorate([
2324
2453
  __decorate([
2325
2454
  track('Buckets.GetReadUri')
2326
2455
  ], BucketService.prototype, "getReadUri", null);
2456
+ __decorate([
2457
+ track('Buckets.GetFiles')
2458
+ ], BucketService.prototype, "getFiles", null);
2459
+ __decorate([
2460
+ track('Buckets.DeleteFile')
2461
+ ], BucketService.prototype, "deleteFile", null);
2327
2462
 
2328
2463
  var BucketOptions;
2329
2464
  (function (BucketOptions) {
@@ -126,6 +126,8 @@ const MAESTRO_ENDPOINTS = {
126
126
  TOP_PROCESSES_BY_RUN_COUNT: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/TopProcessesByRunCount`,
127
127
  /** Top processes ranked by failure count */
128
128
  TOP_PROCESSES_WITH_FAILURE: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/TopProcesseswithFailure`,
129
+ /** Top elements ranked by failure count */
130
+ TOP_ELEMENTS_WITH_FAILURE: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/TopElementswithFailure`,
129
131
  /** Instance status aggregated by date for time-series charts */
130
132
  INSTANCE_STATUS_BY_DATE: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/InstanceStatusByDate`,
131
133
  /** Top processes ranked by total duration */
@@ -748,14 +750,25 @@ class ApiClient {
748
750
  if (!text) {
749
751
  return undefined;
750
752
  }
751
- return JSON.parse(text);
753
+ try {
754
+ return JSON.parse(text);
755
+ }
756
+ catch (error) {
757
+ if (error instanceof SyntaxError) {
758
+ throw new ServerError({
759
+ message: `Server returned non-JSON response (${response.status} ${response.url}): ${error.message}`,
760
+ statusCode: response.status,
761
+ });
762
+ }
763
+ throw error;
764
+ }
752
765
  }
753
766
  catch (error) {
754
767
  // If it's already one of our errors, re-throw it
755
768
  if (error.type && error.type.includes('Error')) {
756
769
  throw error;
757
770
  }
758
- // Otherwise, it's likely a network error
771
+ // Otherwise, it's a genuine network/fetch failure
759
772
  throw ErrorFactory.createNetworkError(error);
760
773
  }
761
774
  }
@@ -1522,9 +1535,9 @@ class PaginationHelpers {
1522
1535
  * @returns Promise resolving to a paginated result
1523
1536
  */
1524
1537
  static async getAllPaginated(params) {
1525
- const { serviceAccess, getEndpoint, folderId, paginationParams, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
1538
+ const { serviceAccess, getEndpoint, folderId, headers: providedHeaders, paginationParams, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
1526
1539
  const endpoint = getEndpoint(folderId);
1527
- const headers = folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {};
1540
+ const headers = providedHeaders ?? (folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {});
1528
1541
  const paginatedResponse = await serviceAccess.requestWithPagination(method, endpoint, paginationParams, {
1529
1542
  headers,
1530
1543
  params: additionalParams,
@@ -1552,13 +1565,13 @@ class PaginationHelpers {
1552
1565
  * @returns Promise resolving to an object with data and totalCount
1553
1566
  */
1554
1567
  static async getAllNonPaginated(params) {
1555
- const { serviceAccess, getAllEndpoint, getByFolderEndpoint, folderId, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
1568
+ const { serviceAccess, getAllEndpoint, getByFolderEndpoint, folderId, headers: providedHeaders, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
1556
1569
  // Set default field names
1557
1570
  const itemsField = options.itemsField || DEFAULT_ITEMS_FIELD;
1558
1571
  const totalCountField = options.totalCountField || DEFAULT_TOTAL_COUNT_FIELD;
1559
1572
  // Determine endpoint and headers based on folderId
1560
1573
  const endpoint = folderId ? getByFolderEndpoint : getAllEndpoint;
1561
- const headers = folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {};
1574
+ const headers = providedHeaders ?? (folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {});
1562
1575
  // Make the API call based on method
1563
1576
  let response;
1564
1577
  if (method === HTTP_METHODS.POST) {
@@ -1617,6 +1630,7 @@ class PaginationHelpers {
1617
1630
  serviceAccess: config.serviceAccess,
1618
1631
  getEndpoint: config.getEndpoint,
1619
1632
  folderId,
1633
+ headers: config.headers,
1620
1634
  paginationParams: cursor ? { cursor, pageSize } : jumpToPage ? { jumpToPage, pageSize } : { pageSize },
1621
1635
  additionalParams: prefixedOptions,
1622
1636
  transformFn: config.transformFn,
@@ -1634,6 +1648,7 @@ class PaginationHelpers {
1634
1648
  getAllEndpoint: config.getEndpoint(),
1635
1649
  getByFolderEndpoint: byFolderEndpoint,
1636
1650
  folderId,
1651
+ headers: config.headers,
1637
1652
  additionalParams: prefixedOptions,
1638
1653
  transformFn: config.transformFn,
1639
1654
  method: config.method,
@@ -2098,6 +2113,52 @@ class CasesService extends BaseService {
2098
2113
  const { data } = await this.post(MAESTRO_ENDPOINTS.INSIGHTS.TOP_PROCESSES_BY_RUN_COUNT, buildInsightsTopBody(startTime, endTime, true, options));
2099
2114
  return (data ?? []).map(process => ({ ...process, name: this.extractCaseName(process.packageId) }));
2100
2115
  }
2116
+ /**
2117
+ * Get the top 10 BPMN elements ranked by failure count within a time range.
2118
+ *
2119
+ * Returns an array of up to 10 elements sorted by how many times they failed,
2120
+ * useful for identifying the most error-prone activities in case processes.
2121
+ *
2122
+ * @param startTime - Start of the time range to query
2123
+ * @param endTime - End of the time range to query
2124
+ * @param options - Optional filters (packageId, processKey, version)
2125
+ * @returns Promise resolving to an array of {@link ElementGetTopFailedCountResponse}
2126
+ * @example
2127
+ * ```typescript
2128
+ * import { Cases } from '@uipath/uipath-typescript/cases';
2129
+ *
2130
+ * const cases = new Cases(sdk);
2131
+ *
2132
+ * // Get top failing elements for the last 7 days
2133
+ * const topFailing = await cases.getTopElementFailedCount(
2134
+ * new Date(Date.now() - 7 * 24 * 60 * 60 * 1000),
2135
+ * new Date()
2136
+ * );
2137
+ *
2138
+ * for (const element of topFailing) {
2139
+ * console.log(`${element.elementName} (${element.elementType}): ${element.failedCount} failures`);
2140
+ * }
2141
+ * ```
2142
+ *
2143
+ * @example
2144
+ * ```typescript
2145
+ * // Get top failing elements for a specific process
2146
+ * const filtered = await cases.getTopElementFailedCount(
2147
+ * new Date(Date.now() - 7 * 24 * 60 * 60 * 1000),
2148
+ * new Date(),
2149
+ * { processKey: '<processKey>' }
2150
+ * );
2151
+ * ```
2152
+ */
2153
+ async getTopElementFailedCount(startTime, endTime, options) {
2154
+ const { data } = await this.post(MAESTRO_ENDPOINTS.INSIGHTS.TOP_ELEMENTS_WITH_FAILURE, buildInsightsTopBody(startTime, endTime, true, options));
2155
+ return (data ?? []).map(item => ({
2156
+ elementName: item.elementName,
2157
+ elementType: item.elementType,
2158
+ processKey: item.processKey,
2159
+ failedCount: item.count,
2160
+ }));
2161
+ }
2101
2162
  /**
2102
2163
  * Get all instances status counts aggregated by date for case management processes.
2103
2164
  *
@@ -2253,6 +2314,9 @@ __decorate([
2253
2314
  __decorate([
2254
2315
  track('Cases.GetTopRunCount')
2255
2316
  ], CasesService.prototype, "getTopRunCount", null);
2317
+ __decorate([
2318
+ track('Cases.GetTopElementFailedCount')
2319
+ ], CasesService.prototype, "getTopElementFailedCount", null);
2256
2320
  __decorate([
2257
2321
  track('Cases.GetInstanceStatusTimeline')
2258
2322
  ], CasesService.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
  *
@@ -371,6 +385,44 @@ interface CasesServiceModel {
371
385
  * ```
372
386
  */
373
387
  getTopFaultedCount(startTime: Date, endTime: Date, options?: TopQueryOptions): Promise<CaseGetTopFaultedCountResponse[]>;
388
+ /**
389
+ * Get the top 10 BPMN elements ranked by failure count within a time range.
390
+ *
391
+ * Returns an array of up to 10 elements sorted by how many times they failed,
392
+ * useful for identifying the most error-prone activities in case processes.
393
+ *
394
+ * @param startTime - Start of the time range to query
395
+ * @param endTime - End of the time range to query
396
+ * @param options - Optional filters (packageId, processKey, version)
397
+ * @returns Promise resolving to an array of {@link ElementGetTopFailedCountResponse}
398
+ * @example
399
+ * ```typescript
400
+ * import { Cases } from '@uipath/uipath-typescript/cases';
401
+ *
402
+ * const cases = new Cases(sdk);
403
+ *
404
+ * // Get top failing elements for the last 7 days
405
+ * const topFailing = await cases.getTopElementFailedCount(
406
+ * new Date(Date.now() - 7 * 24 * 60 * 60 * 1000),
407
+ * new Date()
408
+ * );
409
+ *
410
+ * for (const element of topFailing) {
411
+ * console.log(`${element.elementName} (${element.elementType}): ${element.failedCount} failures`);
412
+ * }
413
+ * ```
414
+ *
415
+ * @example
416
+ * ```typescript
417
+ * // Get top failing elements for a specific process
418
+ * const filtered = await cases.getTopElementFailedCount(
419
+ * new Date(Date.now() - 7 * 24 * 60 * 60 * 1000),
420
+ * new Date(),
421
+ * { processKey: '<processKey>' }
422
+ * );
423
+ * ```
424
+ */
425
+ getTopElementFailedCount(startTime: Date, endTime: Date, options?: TopQueryOptions): Promise<ElementGetTopFailedCountResponse[]>;
374
426
  /**
375
427
  * Get all instances status counts aggregated by date for case management processes.
376
428
  *
@@ -1759,6 +1811,44 @@ declare class CasesService extends BaseService implements CasesServiceModel {
1759
1811
  * ```
1760
1812
  */
1761
1813
  getTopRunCount(startTime: Date, endTime: Date, options?: TopQueryOptions): Promise<CaseGetTopRunCountResponse[]>;
1814
+ /**
1815
+ * Get the top 10 BPMN elements ranked by failure count within a time range.
1816
+ *
1817
+ * Returns an array of up to 10 elements sorted by how many times they failed,
1818
+ * useful for identifying the most error-prone activities in case processes.
1819
+ *
1820
+ * @param startTime - Start of the time range to query
1821
+ * @param endTime - End of the time range to query
1822
+ * @param options - Optional filters (packageId, processKey, version)
1823
+ * @returns Promise resolving to an array of {@link ElementGetTopFailedCountResponse}
1824
+ * @example
1825
+ * ```typescript
1826
+ * import { Cases } from '@uipath/uipath-typescript/cases';
1827
+ *
1828
+ * const cases = new Cases(sdk);
1829
+ *
1830
+ * // Get top failing elements for the last 7 days
1831
+ * const topFailing = await cases.getTopElementFailedCount(
1832
+ * new Date(Date.now() - 7 * 24 * 60 * 60 * 1000),
1833
+ * new Date()
1834
+ * );
1835
+ *
1836
+ * for (const element of topFailing) {
1837
+ * console.log(`${element.elementName} (${element.elementType}): ${element.failedCount} failures`);
1838
+ * }
1839
+ * ```
1840
+ *
1841
+ * @example
1842
+ * ```typescript
1843
+ * // Get top failing elements for a specific process
1844
+ * const filtered = await cases.getTopElementFailedCount(
1845
+ * new Date(Date.now() - 7 * 24 * 60 * 60 * 1000),
1846
+ * new Date(),
1847
+ * { processKey: '<processKey>' }
1848
+ * );
1849
+ * ```
1850
+ */
1851
+ getTopElementFailedCount(startTime: Date, endTime: Date, options?: TopQueryOptions): Promise<ElementGetTopFailedCountResponse[]>;
1762
1852
  /**
1763
1853
  * Get all instances status counts aggregated by date for case management processes.
1764
1854
  *
@@ -2134,4 +2224,4 @@ declare class CaseInstancesService extends BaseService implements CaseInstancesS
2134
2224
  }
2135
2225
 
2136
2226
  export { CaseInstancesService as CaseInstances, CaseInstancesService, CasesService as Cases, CasesService, EscalationActionType, EscalationRecipientScope, EscalationTriggerType, InstanceFinalStatus, InstanceStatus, SLADurationUnit, SlaSummaryStatus, StageTaskType, TimeInterval, createCaseInstanceWithMethods };
2137
- export type { CaseAppConfig, CaseAppOverview, CaseGetAllResponse, CaseGetStageResponse, CaseGetTopDurationResponse, CaseGetTopFaultedCountResponse, CaseGetTopRunCountResponse, CaseInstanceExecutionHistoryResponse, CaseInstanceGetAllOptions, CaseInstanceGetAllWithPaginationOptions, CaseInstanceGetResponse, CaseInstanceMethods, CaseInstanceOperationOptions, CaseInstanceOperationResponse, CaseInstanceReopenOptions, CaseInstanceRun, CaseInstanceSlaSummaryOptions, CaseInstanceStageSLAOptions, CaseInstanceStageSLAResponse, CaseInstanceStageSLAStage, CaseInstancesServiceModel, CasesServiceModel, ElementExecutionMetadata, ElementRunMetadata, EscalationAction, EscalationRecipient, EscalationRule, EscalationTriggerMetadata, GetTopBaseResponse, GetTopDurationResponse, GetTopFaultedCountResponse, GetTopRunCountResponse, InstanceStatusTimelineResponse, RawCaseInstanceGetResponse, SlaSummaryResponse, StageSLA, StageTask, TimelineOptions, TopQueryOptions };
2227
+ export type { CaseAppConfig, CaseAppOverview, CaseGetAllResponse, CaseGetStageResponse, CaseGetTopDurationResponse, CaseGetTopFaultedCountResponse, CaseGetTopRunCountResponse, CaseInstanceExecutionHistoryResponse, CaseInstanceGetAllOptions, CaseInstanceGetAllWithPaginationOptions, CaseInstanceGetResponse, CaseInstanceMethods, CaseInstanceOperationOptions, CaseInstanceOperationResponse, CaseInstanceReopenOptions, CaseInstanceRun, CaseInstanceSlaSummaryOptions, CaseInstanceStageSLAOptions, CaseInstanceStageSLAResponse, CaseInstanceStageSLAStage, CaseInstancesServiceModel, CasesServiceModel, ElementExecutionMetadata, ElementGetTopFailedCountResponse, ElementRunMetadata, EscalationAction, EscalationRecipient, EscalationRule, EscalationTriggerMetadata, GetTopBaseResponse, GetTopDurationResponse, GetTopFaultedCountResponse, GetTopRunCountResponse, InstanceStatusTimelineResponse, RawCaseInstanceGetResponse, SlaSummaryResponse, StageSLA, StageTask, TimelineOptions, TopQueryOptions };