@uipath/uipath-typescript 1.3.9 → 1.3.10

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.
@@ -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
  }
@@ -1157,9 +1157,9 @@ class PaginationHelpers {
1157
1157
  * @returns Promise resolving to a paginated result
1158
1158
  */
1159
1159
  static async getAllPaginated(params) {
1160
- const { serviceAccess, getEndpoint, folderId, paginationParams, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
1160
+ const { serviceAccess, getEndpoint, folderId, headers: providedHeaders, paginationParams, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
1161
1161
  const endpoint = getEndpoint(folderId);
1162
- const headers = folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {};
1162
+ const headers = providedHeaders ?? (folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {});
1163
1163
  const paginatedResponse = await serviceAccess.requestWithPagination(method, endpoint, paginationParams, {
1164
1164
  headers,
1165
1165
  params: additionalParams,
@@ -1187,13 +1187,13 @@ class PaginationHelpers {
1187
1187
  * @returns Promise resolving to an object with data and totalCount
1188
1188
  */
1189
1189
  static async getAllNonPaginated(params) {
1190
- const { serviceAccess, getAllEndpoint, getByFolderEndpoint, folderId, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
1190
+ const { serviceAccess, getAllEndpoint, getByFolderEndpoint, folderId, headers: providedHeaders, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
1191
1191
  // Set default field names
1192
1192
  const itemsField = options.itemsField || DEFAULT_ITEMS_FIELD;
1193
1193
  const totalCountField = options.totalCountField || DEFAULT_TOTAL_COUNT_FIELD;
1194
1194
  // Determine endpoint and headers based on folderId
1195
1195
  const endpoint = folderId ? getByFolderEndpoint : getAllEndpoint;
1196
- const headers = folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {};
1196
+ const headers = providedHeaders ?? (folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {});
1197
1197
  // Make the API call based on method
1198
1198
  let response;
1199
1199
  if (method === HTTP_METHODS.POST) {
@@ -1252,6 +1252,7 @@ class PaginationHelpers {
1252
1252
  serviceAccess: config.serviceAccess,
1253
1253
  getEndpoint: config.getEndpoint,
1254
1254
  folderId,
1255
+ headers: config.headers,
1255
1256
  paginationParams: cursor ? { cursor, pageSize } : jumpToPage ? { jumpToPage, pageSize } : { pageSize },
1256
1257
  additionalParams: prefixedOptions,
1257
1258
  transformFn: config.transformFn,
@@ -1269,6 +1270,7 @@ class PaginationHelpers {
1269
1270
  getAllEndpoint: config.getEndpoint(),
1270
1271
  getByFolderEndpoint: byFolderEndpoint,
1271
1272
  folderId,
1273
+ headers: config.headers,
1272
1274
  additionalParams: prefixedOptions,
1273
1275
  transformFn: config.transformFn,
1274
1276
  method: config.method,
@@ -1598,14 +1600,25 @@ class ApiClient {
1598
1600
  if (!text) {
1599
1601
  return undefined;
1600
1602
  }
1601
- return JSON.parse(text);
1603
+ try {
1604
+ return JSON.parse(text);
1605
+ }
1606
+ catch (error) {
1607
+ if (error instanceof SyntaxError) {
1608
+ throw new ServerError({
1609
+ message: `Server returned non-JSON response (${response.status} ${response.url}): ${error.message}`,
1610
+ statusCode: response.status,
1611
+ });
1612
+ }
1613
+ throw error;
1614
+ }
1602
1615
  }
1603
1616
  catch (error) {
1604
1617
  // If it's already one of our errors, re-throw it
1605
1618
  if (error.type && error.type.includes('Error')) {
1606
1619
  throw error;
1607
1620
  }
1608
- // Otherwise, it's likely a network error
1621
+ // Otherwise, it's a genuine network/fetch failure
1609
1622
  throw ErrorFactory.createNetworkError(error);
1610
1623
  }
1611
1624
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uipath/uipath-typescript",
3
- "version": "1.3.9",
3
+ "version": "1.3.10",
4
4
  "description": "UiPath TypeScript SDK",
5
5
  "license": "MIT",
6
6
  "keywords": [