@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.
@@ -669,14 +669,25 @@ class ApiClient {
669
669
  if (!text) {
670
670
  return undefined;
671
671
  }
672
- return JSON.parse(text);
672
+ try {
673
+ return JSON.parse(text);
674
+ }
675
+ catch (error) {
676
+ if (error instanceof SyntaxError) {
677
+ throw new ServerError({
678
+ message: `Server returned non-JSON response (${response.status} ${response.url}): ${error.message}`,
679
+ statusCode: response.status,
680
+ });
681
+ }
682
+ throw error;
683
+ }
673
684
  }
674
685
  catch (error) {
675
686
  // If it's already one of our errors, re-throw it
676
687
  if (error.type && error.type.includes('Error')) {
677
688
  throw error;
678
689
  }
679
- // Otherwise, it's likely a network error
690
+ // Otherwise, it's a genuine network/fetch failure
680
691
  throw ErrorFactory.createNetworkError(error);
681
692
  }
682
693
  }
@@ -1301,9 +1312,9 @@ class PaginationHelpers {
1301
1312
  * @returns Promise resolving to a paginated result
1302
1313
  */
1303
1314
  static async getAllPaginated(params) {
1304
- const { serviceAccess, getEndpoint, folderId, paginationParams, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
1315
+ const { serviceAccess, getEndpoint, folderId, headers: providedHeaders, paginationParams, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
1305
1316
  const endpoint = getEndpoint(folderId);
1306
- const headers = folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {};
1317
+ const headers = providedHeaders ?? (folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {});
1307
1318
  const paginatedResponse = await serviceAccess.requestWithPagination(method, endpoint, paginationParams, {
1308
1319
  headers,
1309
1320
  params: additionalParams,
@@ -1331,13 +1342,13 @@ class PaginationHelpers {
1331
1342
  * @returns Promise resolving to an object with data and totalCount
1332
1343
  */
1333
1344
  static async getAllNonPaginated(params) {
1334
- const { serviceAccess, getAllEndpoint, getByFolderEndpoint, folderId, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
1345
+ const { serviceAccess, getAllEndpoint, getByFolderEndpoint, folderId, headers: providedHeaders, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
1335
1346
  // Set default field names
1336
1347
  const itemsField = options.itemsField || DEFAULT_ITEMS_FIELD;
1337
1348
  const totalCountField = options.totalCountField || DEFAULT_TOTAL_COUNT_FIELD;
1338
1349
  // Determine endpoint and headers based on folderId
1339
1350
  const endpoint = folderId ? getByFolderEndpoint : getAllEndpoint;
1340
- const headers = folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {};
1351
+ const headers = providedHeaders ?? (folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {});
1341
1352
  // Make the API call based on method
1342
1353
  let response;
1343
1354
  if (method === HTTP_METHODS.POST) {
@@ -1396,6 +1407,7 @@ class PaginationHelpers {
1396
1407
  serviceAccess: config.serviceAccess,
1397
1408
  getEndpoint: config.getEndpoint,
1398
1409
  folderId,
1410
+ headers: config.headers,
1399
1411
  paginationParams: cursor ? { cursor, pageSize } : jumpToPage ? { jumpToPage, pageSize } : { pageSize },
1400
1412
  additionalParams: prefixedOptions,
1401
1413
  transformFn: config.transformFn,
@@ -1413,6 +1425,7 @@ class PaginationHelpers {
1413
1425
  getAllEndpoint: config.getEndpoint(),
1414
1426
  getByFolderEndpoint: byFolderEndpoint,
1415
1427
  folderId,
1428
+ headers: config.headers,
1416
1429
  additionalParams: prefixedOptions,
1417
1430
  transformFn: config.transformFn,
1418
1431
  method: config.method,
@@ -5312,7 +5312,7 @@ function normalizeBaseUrl(url) {
5312
5312
  * SDK's public API.
5313
5313
  */
5314
5314
  /** SDK version placeholder — patched by the SDK publish workflow. */
5315
- const SDK_VERSION = '1.3.9';
5315
+ const SDK_VERSION = '1.3.10';
5316
5316
  const CLOUD_ROLE_NAME = 'uipath-ts-sdk';
5317
5317
  const SDK_SERVICE_NAME = 'UiPath.TypeScript.Sdk';
5318
5318
  const SDK_LOGGER_NAME = 'uipath-ts-sdk-telemetry';
@@ -5310,7 +5310,7 @@ function normalizeBaseUrl(url) {
5310
5310
  * SDK's public API.
5311
5311
  */
5312
5312
  /** SDK version placeholder — patched by the SDK publish workflow. */
5313
- const SDK_VERSION = '1.3.9';
5313
+ const SDK_VERSION = '1.3.10';
5314
5314
  const CLOUD_ROLE_NAME = 'uipath-ts-sdk';
5315
5315
  const SDK_SERVICE_NAME = 'UiPath.TypeScript.Sdk';
5316
5316
  const SDK_LOGGER_NAME = 'uipath-ts-sdk-telemetry';
@@ -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
  }
@@ -1240,9 +1251,9 @@ class PaginationHelpers {
1240
1251
  * @returns Promise resolving to a paginated result
1241
1252
  */
1242
1253
  static async getAllPaginated(params) {
1243
- const { serviceAccess, getEndpoint, folderId, paginationParams, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
1254
+ const { serviceAccess, getEndpoint, folderId, headers: providedHeaders, paginationParams, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
1244
1255
  const endpoint = getEndpoint(folderId);
1245
- const headers = folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {};
1256
+ const headers = providedHeaders ?? (folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {});
1246
1257
  const paginatedResponse = await serviceAccess.requestWithPagination(method, endpoint, paginationParams, {
1247
1258
  headers,
1248
1259
  params: additionalParams,
@@ -1270,13 +1281,13 @@ class PaginationHelpers {
1270
1281
  * @returns Promise resolving to an object with data and totalCount
1271
1282
  */
1272
1283
  static async getAllNonPaginated(params) {
1273
- const { serviceAccess, getAllEndpoint, getByFolderEndpoint, folderId, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
1284
+ const { serviceAccess, getAllEndpoint, getByFolderEndpoint, folderId, headers: providedHeaders, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
1274
1285
  // Set default field names
1275
1286
  const itemsField = options.itemsField || DEFAULT_ITEMS_FIELD;
1276
1287
  const totalCountField = options.totalCountField || DEFAULT_TOTAL_COUNT_FIELD;
1277
1288
  // Determine endpoint and headers based on folderId
1278
1289
  const endpoint = folderId ? getByFolderEndpoint : getAllEndpoint;
1279
- const headers = folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {};
1290
+ const headers = providedHeaders ?? (folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {});
1280
1291
  // Make the API call based on method
1281
1292
  let response;
1282
1293
  if (method === HTTP_METHODS.POST) {
@@ -1335,6 +1346,7 @@ class PaginationHelpers {
1335
1346
  serviceAccess: config.serviceAccess,
1336
1347
  getEndpoint: config.getEndpoint,
1337
1348
  folderId,
1349
+ headers: config.headers,
1338
1350
  paginationParams: cursor ? { cursor, pageSize } : jumpToPage ? { jumpToPage, pageSize } : { pageSize },
1339
1351
  additionalParams: prefixedOptions,
1340
1352
  transformFn: config.transformFn,
@@ -1352,6 +1364,7 @@ class PaginationHelpers {
1352
1364
  getAllEndpoint: config.getEndpoint(),
1353
1365
  getByFolderEndpoint: byFolderEndpoint,
1354
1366
  folderId,
1367
+ headers: config.headers,
1355
1368
  additionalParams: prefixedOptions,
1356
1369
  transformFn: config.transformFn,
1357
1370
  method: config.method,
@@ -1938,6 +1951,12 @@ const DATA_FABRIC_ENDPOINTS = {
1938
1951
  CHOICESETS: {
1939
1952
  GET_ALL: `${DATAFABRIC_BASE}/api/Entity/choiceset`,
1940
1953
  GET_BY_ID: (choiceSetId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${choiceSetId}/query_expansion`,
1954
+ CREATE: `${DATAFABRIC_BASE}/api/Entity/choiceset`,
1955
+ UPDATE: (choiceSetId) => `${DATAFABRIC_BASE}/api/Entity/${choiceSetId}/metadata`,
1956
+ DELETE: (choiceSetId) => `${DATAFABRIC_BASE}/api/Entity/${choiceSetId}/delete`,
1957
+ INSERT_BY_NAME: (choiceSetName) => `${DATAFABRIC_BASE}/api/EntityService/${choiceSetName}/choiceset/insert`,
1958
+ UPDATE_BY_NAME: (choiceSetName, valueId) => `${DATAFABRIC_BASE}/api/EntityService/${choiceSetName}/choiceset/${valueId}/update`,
1959
+ DELETE_BY_ID: (choiceSetId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${choiceSetId}/choiceset/delete`,
1941
1960
  },
1942
1961
  };
1943
1962
 
@@ -3267,7 +3286,7 @@ class ChoiceSetService extends BaseService {
3267
3286
  *
3268
3287
  * @example
3269
3288
  * ```typescript
3270
- * import { ChoiceSets } from '@uipath/uipath-typescript/choicesets';
3289
+ * import { ChoiceSets } from '@uipath/uipath-typescript/entities';
3271
3290
  *
3272
3291
  * const choiceSets = new ChoiceSets(sdk);
3273
3292
  *
@@ -3316,6 +3335,188 @@ class ChoiceSetService extends BaseService {
3316
3335
  }
3317
3336
  }, options);
3318
3337
  }
3338
+ /**
3339
+ * Creates a new Data Fabric choice set
3340
+ *
3341
+ * @param name - Choice set name. Must start with a
3342
+ * letter, may contain only letters, numbers, and underscores, length
3343
+ * 3–100 characters (e.g., `"expenseTypes"`).
3344
+ * @param options - Optional choice-set-level settings ({@link ChoiceSetCreateOptions})
3345
+ * @returns Promise resolving to the UUID of the created choice set
3346
+ *
3347
+ * @example
3348
+ * ```typescript
3349
+ * import { ChoiceSets } from '@uipath/uipath-typescript/entities';
3350
+ *
3351
+ * const choicesets = new ChoiceSets(sdk);
3352
+ *
3353
+ * // Minimal create
3354
+ * const expenseTypesId = await choicesets.create("expense_types");
3355
+ *
3356
+ * // With display name and description
3357
+ * const priorityLevelsId = await choicesets.create("priority_levels", {
3358
+ * displayName: "Priority Levels",
3359
+ * description: "Ticket priority categories",
3360
+ * });
3361
+ * ```
3362
+ * @internal
3363
+ */
3364
+ async create(name, options) {
3365
+ const opts = options ?? {};
3366
+ const payload = {
3367
+ ...(opts.description !== undefined && { description: opts.description }),
3368
+ ...(opts.displayName !== undefined && { displayName: opts.displayName }),
3369
+ entityDefinition: {
3370
+ name,
3371
+ fields: [],
3372
+ folderId: opts.folderKey ?? DATA_FABRIC_TENANT_FOLDER_ID,
3373
+ },
3374
+ };
3375
+ const response = await this.post(DATA_FABRIC_ENDPOINTS.CHOICESETS.CREATE, payload);
3376
+ return response.data;
3377
+ }
3378
+ /**
3379
+ * Updates an existing choice set's metadata (display name and/or description).
3380
+ *
3381
+ * **At least one of `displayName` or `description` must be provided** —
3382
+ * the call throws `ValidationError` if both are omitted.
3383
+ *
3384
+ * @param choiceSetId - UUID of the choice set to update
3385
+ * @param options - Metadata fields to change ({@link ChoiceSetUpdateOptions})
3386
+ * @returns Promise resolving when the update is complete
3387
+ *
3388
+ * @example
3389
+ * ```typescript
3390
+ * // First, get the choice set ID using getAll()
3391
+ * const allChoiceSets = await choicesets.getAll();
3392
+ * const expenseTypes = allChoiceSets.find(cs => cs.name === 'expense_types');
3393
+ *
3394
+ * await choicesets.updateById(expenseTypes.id, {
3395
+ * displayName: "Expense Categories",
3396
+ * description: "Updated description",
3397
+ * });
3398
+ * ```
3399
+ * @internal
3400
+ */
3401
+ async updateById(choiceSetId, options) {
3402
+ if (options.displayName === undefined && options.description === undefined) {
3403
+ throw new ValidationError({
3404
+ message: 'updateById requires at least one of displayName or description.',
3405
+ });
3406
+ }
3407
+ await this.patch(DATA_FABRIC_ENDPOINTS.CHOICESETS.UPDATE(choiceSetId), {
3408
+ ...(options.displayName !== undefined && { displayName: options.displayName }),
3409
+ ...(options.description !== undefined && { description: options.description }),
3410
+ });
3411
+ }
3412
+ /**
3413
+ * Deletes a Data Fabric choice set and all its values.
3414
+ *
3415
+ * @param choiceSetId - UUID of the choice set to delete
3416
+ * @returns Promise resolving when the choice set is deleted
3417
+ *
3418
+ * @example
3419
+ * ```typescript
3420
+ * // First, get the choice set ID using getAll()
3421
+ * const allChoiceSets = await choicesets.getAll();
3422
+ * const expenseTypes = allChoiceSets.find(cs => cs.name === 'expense_types');
3423
+ *
3424
+ * await choicesets.deleteById(expenseTypes.id);
3425
+ * ```
3426
+ * @internal
3427
+ */
3428
+ async deleteById(choiceSetId) {
3429
+ await this.post(DATA_FABRIC_ENDPOINTS.CHOICESETS.DELETE(choiceSetId), {});
3430
+ }
3431
+ /**
3432
+ * Inserts a single value into a choice set.
3433
+ *
3434
+ * @param choiceSetId - UUID of the parent choice set
3435
+ * @param name - Identifier name of the new value (e.g., `"TRAVEL"`)
3436
+ * @param options - Optional fields ({@link ChoiceSetValueInsertOptions})
3437
+ * @returns Promise resolving to the inserted value ({@link ChoiceSetValueInsertResponse})
3438
+ *
3439
+ * @example
3440
+ * ```typescript
3441
+ * // First, get the choice set ID using getAll()
3442
+ * const allChoiceSets = await choicesets.getAll();
3443
+ * const expenseTypes = allChoiceSets.find(cs => cs.name === 'expense_types');
3444
+ *
3445
+ * const inserted = await choicesets.insertValueById(expenseTypes.id, 'TRAVEL', {
3446
+ * displayName: 'Travel',
3447
+ * });
3448
+ * console.log(inserted.id);
3449
+ * ```
3450
+ * @internal
3451
+ */
3452
+ async insertValueById(choiceSetId, name, options) {
3453
+ const choiceSetName = await this.resolveChoiceSetName(choiceSetId);
3454
+ const payload = {
3455
+ Name: name,
3456
+ ...(options?.displayName !== undefined && { DisplayName: options.displayName }),
3457
+ };
3458
+ const response = await this.post(DATA_FABRIC_ENDPOINTS.CHOICESETS.INSERT_BY_NAME(choiceSetName), payload);
3459
+ const camelCased = pascalToCamelCaseKeys(response.data);
3460
+ return transformData(camelCased, EntityMap);
3461
+ }
3462
+ /**
3463
+ * Updates an existing choice-set value's display name.
3464
+ *
3465
+ * Only `displayName` is mutable; the value's `name` (identifier) is fixed at
3466
+ * insert time and cannot be changed.
3467
+ *
3468
+ * @param choiceSetId - UUID of the parent choice set
3469
+ * @param valueId - UUID of the value to update
3470
+ * @param displayName - New human-readable display name for the value
3471
+ * @returns Promise resolving to the updated value ({@link ChoiceSetValueUpdateResponse})
3472
+ *
3473
+ * @example
3474
+ * ```typescript
3475
+ * // Get the choice set ID from getAll() and the value ID from getById()
3476
+ * const allChoiceSets = await choicesets.getAll();
3477
+ * const expenseTypes = allChoiceSets.find(cs => cs.name === 'expense_types');
3478
+ * const values = await choicesets.getById(expenseTypes.id);
3479
+ * const travel = values.items.find(v => v.name === 'TRAVEL');
3480
+ *
3481
+ * await choicesets.updateValueById(expenseTypes.id, travel.id, 'Business Travel');
3482
+ * ```
3483
+ * @internal
3484
+ */
3485
+ async updateValueById(choiceSetId, valueId, displayName) {
3486
+ const choiceSetName = await this.resolveChoiceSetName(choiceSetId);
3487
+ const payload = { DisplayName: displayName };
3488
+ const response = await this.post(DATA_FABRIC_ENDPOINTS.CHOICESETS.UPDATE_BY_NAME(choiceSetName, valueId), payload);
3489
+ const camelCased = pascalToCamelCaseKeys(response.data);
3490
+ return transformData(camelCased, EntityMap);
3491
+ }
3492
+ /**
3493
+ * Deletes one or more values from a choice set.
3494
+ *
3495
+ * @param choiceSetId - UUID of the parent choice set
3496
+ * @param valueIds - Array of value UUIDs to delete
3497
+ * @returns Promise resolving when the values are deleted
3498
+ *
3499
+ * @example
3500
+ * ```typescript
3501
+ * // Get the value IDs from getById()
3502
+ * const values = await choicesets.getById('<choiceSetId>');
3503
+ * const idsToDelete = values.items.slice(0, 2).map(v => v.id);
3504
+ *
3505
+ * await choicesets.deleteValuesById('<choiceSetId>', idsToDelete);
3506
+ * ```
3507
+ * @internal
3508
+ */
3509
+ async deleteValuesById(choiceSetId, valueIds) {
3510
+ await this.post(DATA_FABRIC_ENDPOINTS.CHOICESETS.DELETE_BY_ID(choiceSetId), valueIds);
3511
+ }
3512
+ async resolveChoiceSetName(choiceSetId) {
3513
+ const all = await this.getAll();
3514
+ const match = all.find(cs => cs.id === choiceSetId);
3515
+ if (!match) {
3516
+ throw new NotFoundError({ message: `Choice set with id '${choiceSetId}' not found.` });
3517
+ }
3518
+ return match.name;
3519
+ }
3319
3520
  }
3320
3521
  __decorate([
3321
3522
  track('Choicesets.GetAll')
@@ -3323,6 +3524,24 @@ __decorate([
3323
3524
  __decorate([
3324
3525
  track('Choicesets.GetById')
3325
3526
  ], ChoiceSetService.prototype, "getById", null);
3527
+ __decorate([
3528
+ track('Choicesets.Create')
3529
+ ], ChoiceSetService.prototype, "create", null);
3530
+ __decorate([
3531
+ track('Choicesets.UpdateById')
3532
+ ], ChoiceSetService.prototype, "updateById", null);
3533
+ __decorate([
3534
+ track('Choicesets.DeleteById')
3535
+ ], ChoiceSetService.prototype, "deleteById", null);
3536
+ __decorate([
3537
+ track('Choicesets.InsertValueById')
3538
+ ], ChoiceSetService.prototype, "insertValueById", null);
3539
+ __decorate([
3540
+ track('Choicesets.UpdateValueById')
3541
+ ], ChoiceSetService.prototype, "updateValueById", null);
3542
+ __decorate([
3543
+ track('Choicesets.DeleteValuesById')
3544
+ ], ChoiceSetService.prototype, "deleteValuesById", null);
3326
3545
 
3327
3546
  exports.ChoiceSetService = ChoiceSetService;
3328
3547
  exports.ChoiceSets = ChoiceSetService;