@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
  }
@@ -1284,9 +1295,9 @@ class PaginationHelpers {
1284
1295
  * @returns Promise resolving to a paginated result
1285
1296
  */
1286
1297
  static async getAllPaginated(params) {
1287
- const { serviceAccess, getEndpoint, folderId, paginationParams, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
1298
+ const { serviceAccess, getEndpoint, folderId, headers: providedHeaders, paginationParams, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
1288
1299
  const endpoint = getEndpoint(folderId);
1289
- const headers = folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {};
1300
+ const headers = providedHeaders ?? (folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {});
1290
1301
  const paginatedResponse = await serviceAccess.requestWithPagination(method, endpoint, paginationParams, {
1291
1302
  headers,
1292
1303
  params: additionalParams,
@@ -1314,13 +1325,13 @@ class PaginationHelpers {
1314
1325
  * @returns Promise resolving to an object with data and totalCount
1315
1326
  */
1316
1327
  static async getAllNonPaginated(params) {
1317
- const { serviceAccess, getAllEndpoint, getByFolderEndpoint, folderId, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
1328
+ const { serviceAccess, getAllEndpoint, getByFolderEndpoint, folderId, headers: providedHeaders, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
1318
1329
  // Set default field names
1319
1330
  const itemsField = options.itemsField || DEFAULT_ITEMS_FIELD;
1320
1331
  const totalCountField = options.totalCountField || DEFAULT_TOTAL_COUNT_FIELD;
1321
1332
  // Determine endpoint and headers based on folderId
1322
1333
  const endpoint = folderId ? getByFolderEndpoint : getAllEndpoint;
1323
- const headers = folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {};
1334
+ const headers = providedHeaders ?? (folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {});
1324
1335
  // Make the API call based on method
1325
1336
  let response;
1326
1337
  if (method === HTTP_METHODS.POST) {
@@ -1379,6 +1390,7 @@ class PaginationHelpers {
1379
1390
  serviceAccess: config.serviceAccess,
1380
1391
  getEndpoint: config.getEndpoint,
1381
1392
  folderId,
1393
+ headers: config.headers,
1382
1394
  paginationParams: cursor ? { cursor, pageSize } : jumpToPage ? { jumpToPage, pageSize } : { pageSize },
1383
1395
  additionalParams: prefixedOptions,
1384
1396
  transformFn: config.transformFn,
@@ -1396,6 +1408,7 @@ class PaginationHelpers {
1396
1408
  getAllEndpoint: config.getEndpoint(),
1397
1409
  getByFolderEndpoint: byFolderEndpoint,
1398
1410
  folderId,
1411
+ headers: config.headers,
1399
1412
  additionalParams: prefixedOptions,
1400
1413
  transformFn: config.transformFn,
1401
1414
  method: config.method,
@@ -2053,33 +2066,32 @@ class ProcessService extends FolderScopedService {
2053
2066
  }
2054
2067
  }, options);
2055
2068
  }
2056
- /**
2057
- * Starts a process execution (job)
2058
- *
2059
- * @param request - Process start request body
2060
- * @param folderId - Required folder ID
2061
- * @param options - Optional query parameters
2062
- * @returns Promise resolving to the created jobs
2063
- *
2064
- * @example
2065
- * ```typescript
2066
- * import { Processes } from '@uipath/uipath-typescript/processes';
2067
- *
2068
- * const processes = new Processes(sdk);
2069
- *
2070
- * // Start a process by process key
2071
- * const jobs = await processes.start({
2072
- * processKey: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
2073
- * }, 123); // folderId is required
2074
- *
2075
- * // Start a process by name with specific robots
2076
- * const jobs = await processes.start({
2077
- * processName: "MyProcess"
2078
- * }, 123); // folderId is required
2079
- * ```
2080
- */
2081
- async start(request, folderId, options = {}) {
2082
- const headers = createHeaders({ [FOLDER_ID]: folderId });
2069
+ async start(request, optionsOrFolderId, legacyOptions) {
2070
+ // Normalize the two overload forms into a single internal shape.
2071
+ let folderId;
2072
+ let folderKey;
2073
+ let folderPath;
2074
+ let queryOptions;
2075
+ if (typeof optionsOrFolderId === 'number') {
2076
+ // Deprecated positional form: start(request, folderId, options?)
2077
+ folderId = optionsOrFolderId;
2078
+ queryOptions = legacyOptions ?? {};
2079
+ }
2080
+ else {
2081
+ // Preferred form: start(request, options?)
2082
+ const { folderId: fid, folderKey: fkey, folderPath: fpath, ...rest } = optionsOrFolderId ?? {};
2083
+ folderId = fid;
2084
+ folderKey = fkey;
2085
+ folderPath = fpath;
2086
+ queryOptions = rest;
2087
+ }
2088
+ const headers = resolveFolderHeaders({
2089
+ folderId,
2090
+ folderKey,
2091
+ folderPath,
2092
+ resourceType: 'processes.start',
2093
+ fallbackFolderKey: this.config.folderKey,
2094
+ });
2083
2095
  // Transform SDK field names to API field names (e.g., processKey → releaseKey)
2084
2096
  const apiRequest = transformRequest(request, ProcessMap);
2085
2097
  // Create the request object according to API spec
@@ -2087,8 +2099,8 @@ class ProcessService extends FolderScopedService {
2087
2099
  startInfo: apiRequest
2088
2100
  };
2089
2101
  // Prefix all query parameter keys with '$' for OData
2090
- const keysToPrefix = Object.keys(options);
2091
- const apiOptions = addPrefixToKeys(options, ODATA_PREFIX, keysToPrefix);
2102
+ const keysToPrefix = Object.keys(queryOptions);
2103
+ const apiOptions = addPrefixToKeys(queryOptions, ODATA_PREFIX, keysToPrefix);
2092
2104
  const response = await this.post(PROCESS_ENDPOINTS.START_PROCESS, requestBody, {
2093
2105
  params: apiOptions,
2094
2106
  headers
@@ -744,6 +744,17 @@ interface ProcessGetByIdOptions extends BaseOptions {
744
744
  */
745
745
  interface ProcessGetByNameOptions extends FolderScopedOptions {
746
746
  }
747
+ /**
748
+ * Options for starting a process. Combines folder scoping
749
+ * (`folderId` / `folderKey` / `folderPath`) with the OData query options
750
+ * (`expand`, `select`, `filter`, `orderby`) accepted by the start endpoint.
751
+ *
752
+ * Folder scoping is optional in the type — the SDK falls back to the
753
+ * init-time folderKey (e.g. `<meta name="uipath:folder-key">` in coded-app
754
+ * deployments). A `ValidationError` is raised when neither is provided.
755
+ */
756
+ interface ProcessStartOptions extends FolderScopedOptions, RequestOptions {
757
+ }
747
758
 
748
759
  /**
749
760
  * Service for managing and executing UiPath Automation Processes.
@@ -840,26 +851,45 @@ interface ProcessServiceModel {
840
851
  */
841
852
  getByName(name: string, options?: ProcessGetByNameOptions): Promise<ProcessGetResponse>;
842
853
  /**
843
- * Starts a process with the specified configuration
854
+ * Starts a process with the specified configuration.
855
+ *
856
+ * Folder context can be supplied as `folderId`, `folderKey`, or `folderPath`
857
+ * inside the options.
844
858
  *
845
859
  * @param request - Process start configuration
846
- * @param folderId - Required folder ID
847
- * @param options - Optional request options
860
+ * @param options - Folder scoping (`folderId` / `folderKey` / `folderPath`) and optional query parameters (`expand`, `select`, `filter`, `orderby`)
848
861
  * @returns Promise resolving to array of started process instances
849
862
  * {@link ProcessStartResponse}
850
863
  * @example
851
864
  * ```typescript
852
- * // Start a process by process key
853
- * const result = await processes.start({
854
- * processKey: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
855
- * }, <folderId>); // folderId is required
856
- *
857
- * // Start a process by name with specific robots
858
- * const result = await processes.start({
859
- * processName: "MyProcess"
860
- * }, <folderId>); // folderId is required
865
+ * // By folder ID
866
+ * await processes.start({ processKey: '<processKey>' }, { folderId: <folderId> });
867
+ *
868
+ * // By folder key (GUID)
869
+ * await processes.start({ processKey: '<processKey>' }, { folderKey: '5f6dadf1-3677-49dc-8aca-c2999dd4b3ba' });
870
+ *
871
+ * // By folder path
872
+ * await processes.start({ processKey: '<processKey>' }, { folderPath: 'Shared/Finance' });
873
+ *
874
+ * // Start by process name (instead of processKey)
875
+ * await processes.start({ processName: 'MyProcess' }, { folderId: <folderId> });
876
+ *
877
+ * // With additional options
878
+ * await processes.start({ processKey: '<processKey>' }, { folderId: <folderId>, expand: 'Robot' });
861
879
  * ```
862
880
  */
881
+ start(request: ProcessStartRequest, options?: ProcessStartOptions): Promise<ProcessStartResponse[]>;
882
+ /**
883
+ * Starts a process — positional `folderId` form.
884
+ *
885
+ * @deprecated Use the options-object form: `start(request, { folderId })`. See {@link ProcessStartOptions} for the supported options.
886
+ *
887
+ * @param request - Process start configuration
888
+ * @param folderId - Required folder ID (numeric)
889
+ * @param options - Optional request options
890
+ * @returns Promise resolving to array of started process instances
891
+ * {@link ProcessStartResponse}
892
+ */
863
893
  start(request: ProcessStartRequest, folderId: number, options?: RequestOptions): Promise<ProcessStartResponse[]>;
864
894
  }
865
895
 
@@ -913,12 +943,15 @@ declare class ProcessService extends FolderScopedService implements ProcessServi
913
943
  */
914
944
  getAll<T extends ProcessGetAllOptions = ProcessGetAllOptions>(options?: T): Promise<T extends HasPaginationOptions<T> ? PaginatedResponse<ProcessGetResponse> : NonPaginatedResponse<ProcessGetResponse>>;
915
945
  /**
916
- * Starts a process execution (job)
946
+ * Starts a process with the specified configuration.
917
947
  *
918
- * @param request - Process start request body
919
- * @param folderId - Required folder ID
920
- * @param options - Optional query parameters
921
- * @returns Promise resolving to the created jobs
948
+ * Folder context can be supplied as `folderId`, `folderKey`, or `folderPath`
949
+ * inside the options.
950
+ *
951
+ * @param request - Process start configuration
952
+ * @param options - Folder scoping (`folderId` / `folderKey` / `folderPath`) and optional query parameters (`expand`, `select`, `filter`, `orderby`)
953
+ * @returns Promise resolving to array of started process instances
954
+ * {@link ProcessStartResponse}
922
955
  *
923
956
  * @example
924
957
  * ```typescript
@@ -926,17 +959,34 @@ declare class ProcessService extends FolderScopedService implements ProcessServi
926
959
  *
927
960
  * const processes = new Processes(sdk);
928
961
  *
929
- * // Start a process by process key
930
- * const jobs = await processes.start({
931
- * processKey: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
932
- * }, 123); // folderId is required
962
+ * // By folder ID
963
+ * await processes.start({ processKey: '<processKey>' }, { folderId: <folderId> });
933
964
  *
934
- * // Start a process by name with specific robots
935
- * const jobs = await processes.start({
936
- * processName: "MyProcess"
937
- * }, 123); // folderId is required
965
+ * // By folder key (GUID)
966
+ * await processes.start({ processKey: '<processKey>' }, { folderKey: '5f6dadf1-3677-49dc-8aca-c2999dd4b3ba' });
967
+ *
968
+ * // By folder path
969
+ * await processes.start({ processKey: '<processKey>' }, { folderPath: 'Shared/Finance' });
970
+ *
971
+ * // Start by process name (instead of processKey)
972
+ * await processes.start({ processName: 'MyProcess' }, { folderId: <folderId> });
973
+ *
974
+ * // With additional options
975
+ * await processes.start({ processKey: '<processKey>' }, { folderId: <folderId>, expand: 'Robot' });
938
976
  * ```
939
977
  */
978
+ start(request: ProcessStartRequest, options?: ProcessStartOptions): Promise<ProcessStartResponse[]>;
979
+ /**
980
+ * Starts a process — positional `folderId` form.
981
+ *
982
+ * @deprecated Use the options-object form: `start(request, { folderId })`. See {@link ProcessStartOptions} for the supported options.
983
+ *
984
+ * @param request - Process start configuration
985
+ * @param folderId - Required folder ID (numeric)
986
+ * @param options - Optional request options
987
+ * @returns Promise resolving to array of started process instances
988
+ * {@link ProcessStartResponse}
989
+ */
940
990
  start(request: ProcessStartRequest, folderId: number, options?: RequestOptions): Promise<ProcessStartResponse[]>;
941
991
  /**
942
992
  * Gets a single process by ID
@@ -987,4 +1037,4 @@ declare class ProcessService extends FolderScopedService implements ProcessServi
987
1037
  }
988
1038
 
989
1039
  export { JobPriority, JobSourceType, JobType, PackageSourceType, PackageType, ProcessService, ProcessService as Processes, RemoteControlAccess, RobotSize, RuntimeType, StartStrategy, StopStrategy, TargetFramework };
990
- export type { ArgumentMetadata, BaseProcessStartRequest, FolderProperties, JobAttachment, JobError, Machine, ProcessGetAllOptions, ProcessGetByIdOptions, ProcessGetByNameOptions, ProcessGetResponse, ProcessProperties, ProcessServiceModel, ProcessStartRequest, ProcessStartRequestWithKey, ProcessStartRequestWithName, ProcessStartResponse, RobotMetadata };
1040
+ export type { ArgumentMetadata, BaseProcessStartRequest, FolderProperties, JobAttachment, JobError, Machine, ProcessGetAllOptions, ProcessGetByIdOptions, ProcessGetByNameOptions, ProcessGetResponse, ProcessProperties, ProcessServiceModel, ProcessStartOptions, ProcessStartRequest, ProcessStartRequestWithKey, ProcessStartRequestWithName, ProcessStartResponse, RobotMetadata };
@@ -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
  }
@@ -1282,9 +1293,9 @@ class PaginationHelpers {
1282
1293
  * @returns Promise resolving to a paginated result
1283
1294
  */
1284
1295
  static async getAllPaginated(params) {
1285
- const { serviceAccess, getEndpoint, folderId, paginationParams, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
1296
+ const { serviceAccess, getEndpoint, folderId, headers: providedHeaders, paginationParams, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
1286
1297
  const endpoint = getEndpoint(folderId);
1287
- const headers = folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {};
1298
+ const headers = providedHeaders ?? (folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {});
1288
1299
  const paginatedResponse = await serviceAccess.requestWithPagination(method, endpoint, paginationParams, {
1289
1300
  headers,
1290
1301
  params: additionalParams,
@@ -1312,13 +1323,13 @@ class PaginationHelpers {
1312
1323
  * @returns Promise resolving to an object with data and totalCount
1313
1324
  */
1314
1325
  static async getAllNonPaginated(params) {
1315
- const { serviceAccess, getAllEndpoint, getByFolderEndpoint, folderId, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
1326
+ const { serviceAccess, getAllEndpoint, getByFolderEndpoint, folderId, headers: providedHeaders, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
1316
1327
  // Set default field names
1317
1328
  const itemsField = options.itemsField || DEFAULT_ITEMS_FIELD;
1318
1329
  const totalCountField = options.totalCountField || DEFAULT_TOTAL_COUNT_FIELD;
1319
1330
  // Determine endpoint and headers based on folderId
1320
1331
  const endpoint = folderId ? getByFolderEndpoint : getAllEndpoint;
1321
- const headers = folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {};
1332
+ const headers = providedHeaders ?? (folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {});
1322
1333
  // Make the API call based on method
1323
1334
  let response;
1324
1335
  if (method === HTTP_METHODS.POST) {
@@ -1377,6 +1388,7 @@ class PaginationHelpers {
1377
1388
  serviceAccess: config.serviceAccess,
1378
1389
  getEndpoint: config.getEndpoint,
1379
1390
  folderId,
1391
+ headers: config.headers,
1380
1392
  paginationParams: cursor ? { cursor, pageSize } : jumpToPage ? { jumpToPage, pageSize } : { pageSize },
1381
1393
  additionalParams: prefixedOptions,
1382
1394
  transformFn: config.transformFn,
@@ -1394,6 +1406,7 @@ class PaginationHelpers {
1394
1406
  getAllEndpoint: config.getEndpoint(),
1395
1407
  getByFolderEndpoint: byFolderEndpoint,
1396
1408
  folderId,
1409
+ headers: config.headers,
1397
1410
  additionalParams: prefixedOptions,
1398
1411
  transformFn: config.transformFn,
1399
1412
  method: config.method,
@@ -2051,33 +2064,32 @@ class ProcessService extends FolderScopedService {
2051
2064
  }
2052
2065
  }, options);
2053
2066
  }
2054
- /**
2055
- * Starts a process execution (job)
2056
- *
2057
- * @param request - Process start request body
2058
- * @param folderId - Required folder ID
2059
- * @param options - Optional query parameters
2060
- * @returns Promise resolving to the created jobs
2061
- *
2062
- * @example
2063
- * ```typescript
2064
- * import { Processes } from '@uipath/uipath-typescript/processes';
2065
- *
2066
- * const processes = new Processes(sdk);
2067
- *
2068
- * // Start a process by process key
2069
- * const jobs = await processes.start({
2070
- * processKey: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
2071
- * }, 123); // folderId is required
2072
- *
2073
- * // Start a process by name with specific robots
2074
- * const jobs = await processes.start({
2075
- * processName: "MyProcess"
2076
- * }, 123); // folderId is required
2077
- * ```
2078
- */
2079
- async start(request, folderId, options = {}) {
2080
- const headers = createHeaders({ [FOLDER_ID]: folderId });
2067
+ async start(request, optionsOrFolderId, legacyOptions) {
2068
+ // Normalize the two overload forms into a single internal shape.
2069
+ let folderId;
2070
+ let folderKey;
2071
+ let folderPath;
2072
+ let queryOptions;
2073
+ if (typeof optionsOrFolderId === 'number') {
2074
+ // Deprecated positional form: start(request, folderId, options?)
2075
+ folderId = optionsOrFolderId;
2076
+ queryOptions = legacyOptions ?? {};
2077
+ }
2078
+ else {
2079
+ // Preferred form: start(request, options?)
2080
+ const { folderId: fid, folderKey: fkey, folderPath: fpath, ...rest } = optionsOrFolderId ?? {};
2081
+ folderId = fid;
2082
+ folderKey = fkey;
2083
+ folderPath = fpath;
2084
+ queryOptions = rest;
2085
+ }
2086
+ const headers = resolveFolderHeaders({
2087
+ folderId,
2088
+ folderKey,
2089
+ folderPath,
2090
+ resourceType: 'processes.start',
2091
+ fallbackFolderKey: this.config.folderKey,
2092
+ });
2081
2093
  // Transform SDK field names to API field names (e.g., processKey → releaseKey)
2082
2094
  const apiRequest = transformRequest(request, ProcessMap);
2083
2095
  // Create the request object according to API spec
@@ -2085,8 +2097,8 @@ class ProcessService extends FolderScopedService {
2085
2097
  startInfo: apiRequest
2086
2098
  };
2087
2099
  // Prefix all query parameter keys with '$' for OData
2088
- const keysToPrefix = Object.keys(options);
2089
- const apiOptions = addPrefixToKeys(options, ODATA_PREFIX, keysToPrefix);
2100
+ const keysToPrefix = Object.keys(queryOptions);
2101
+ const apiOptions = addPrefixToKeys(queryOptions, ODATA_PREFIX, keysToPrefix);
2090
2102
  const response = await this.post(PROCESS_ENDPOINTS.START_PROCESS, requestBody, {
2091
2103
  params: apiOptions,
2092
2104
  headers
@@ -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,
@@ -1159,9 +1159,9 @@ class PaginationHelpers {
1159
1159
  * @returns Promise resolving to a paginated result
1160
1160
  */
1161
1161
  static async getAllPaginated(params) {
1162
- const { serviceAccess, getEndpoint, folderId, paginationParams, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
1162
+ const { serviceAccess, getEndpoint, folderId, headers: providedHeaders, paginationParams, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
1163
1163
  const endpoint = getEndpoint(folderId);
1164
- const headers = folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {};
1164
+ const headers = providedHeaders ?? (folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {});
1165
1165
  const paginatedResponse = await serviceAccess.requestWithPagination(method, endpoint, paginationParams, {
1166
1166
  headers,
1167
1167
  params: additionalParams,
@@ -1189,13 +1189,13 @@ class PaginationHelpers {
1189
1189
  * @returns Promise resolving to an object with data and totalCount
1190
1190
  */
1191
1191
  static async getAllNonPaginated(params) {
1192
- const { serviceAccess, getAllEndpoint, getByFolderEndpoint, folderId, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
1192
+ const { serviceAccess, getAllEndpoint, getByFolderEndpoint, folderId, headers: providedHeaders, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
1193
1193
  // Set default field names
1194
1194
  const itemsField = options.itemsField || DEFAULT_ITEMS_FIELD;
1195
1195
  const totalCountField = options.totalCountField || DEFAULT_TOTAL_COUNT_FIELD;
1196
1196
  // Determine endpoint and headers based on folderId
1197
1197
  const endpoint = folderId ? getByFolderEndpoint : getAllEndpoint;
1198
- const headers = folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {};
1198
+ const headers = providedHeaders ?? (folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {});
1199
1199
  // Make the API call based on method
1200
1200
  let response;
1201
1201
  if (method === HTTP_METHODS.POST) {
@@ -1254,6 +1254,7 @@ class PaginationHelpers {
1254
1254
  serviceAccess: config.serviceAccess,
1255
1255
  getEndpoint: config.getEndpoint,
1256
1256
  folderId,
1257
+ headers: config.headers,
1257
1258
  paginationParams: cursor ? { cursor, pageSize } : jumpToPage ? { jumpToPage, pageSize } : { pageSize },
1258
1259
  additionalParams: prefixedOptions,
1259
1260
  transformFn: config.transformFn,
@@ -1271,6 +1272,7 @@ class PaginationHelpers {
1271
1272
  getAllEndpoint: config.getEndpoint(),
1272
1273
  getByFolderEndpoint: byFolderEndpoint,
1273
1274
  folderId,
1275
+ headers: config.headers,
1274
1276
  additionalParams: prefixedOptions,
1275
1277
  transformFn: config.transformFn,
1276
1278
  method: config.method,
@@ -1600,14 +1602,25 @@ class ApiClient {
1600
1602
  if (!text) {
1601
1603
  return undefined;
1602
1604
  }
1603
- return JSON.parse(text);
1605
+ try {
1606
+ return JSON.parse(text);
1607
+ }
1608
+ catch (error) {
1609
+ if (error instanceof SyntaxError) {
1610
+ throw new ServerError({
1611
+ message: `Server returned non-JSON response (${response.status} ${response.url}): ${error.message}`,
1612
+ statusCode: response.status,
1613
+ });
1614
+ }
1615
+ throw error;
1616
+ }
1604
1617
  }
1605
1618
  catch (error) {
1606
1619
  // If it's already one of our errors, re-throw it
1607
1620
  if (error.type && error.type.includes('Error')) {
1608
1621
  throw error;
1609
1622
  }
1610
- // Otherwise, it's likely a network error
1623
+ // Otherwise, it's a genuine network/fetch failure
1611
1624
  throw ErrorFactory.createNetworkError(error);
1612
1625
  }
1613
1626
  }