@uipath/uipath-typescript 1.1.3 → 1.2.1

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.
@@ -546,11 +546,8 @@ class ApiClient {
546
546
  return this.tokenManager.getValidToken();
547
547
  }
548
548
  async getDefaultHeaders() {
549
- // Get headers from execution context first
550
- const contextHeaders = this.executionContext.getHeaders();
551
549
  const token = await this.getValidToken();
552
550
  return {
553
- ...contextHeaders,
554
551
  'Authorization': `Bearer ${token}`,
555
552
  'Content-Type': CONTENT_TYPES.JSON,
556
553
  ...this.defaultHeaders,
@@ -1652,6 +1649,13 @@ function createEntityMethods(entityData, service) {
1652
1649
  throw new Error('Entity ID is undefined');
1653
1650
  return service.insertRecordsById(entityData.id, data, options);
1654
1651
  },
1652
+ async updateRecord(recordId, data, options) {
1653
+ if (!entityData.id)
1654
+ throw new Error('Entity ID is undefined');
1655
+ if (!recordId)
1656
+ throw new Error('Record ID is undefined');
1657
+ return service.updateRecordById(entityData.id, recordId, data, options);
1658
+ },
1655
1659
  async updateRecords(data, options) {
1656
1660
  if (!entityData.id)
1657
1661
  throw new Error('Entity ID is undefined');
@@ -1675,24 +1679,19 @@ function createEntityMethods(entityData, service) {
1675
1679
  return service.getRecordById(entityData.id, recordId, options);
1676
1680
  },
1677
1681
  async downloadAttachment(recordId, fieldName) {
1678
- if (!entityData.name)
1679
- throw new Error('Entity name is undefined');
1680
- return service.downloadAttachment({
1681
- entityName: entityData.name,
1682
- recordId,
1683
- fieldName
1684
- });
1682
+ if (!entityData.id)
1683
+ throw new Error('Entity ID is undefined');
1684
+ return service.downloadAttachment(entityData.id, recordId, fieldName);
1685
1685
  },
1686
- async uploadAttachment(recordId, fieldName, file, expansionLevel) {
1687
- if (!entityData.name)
1688
- throw new Error('Entity name is undefined');
1689
- return service.uploadAttachment({
1690
- entityName: entityData.name,
1691
- recordId,
1692
- fieldName,
1693
- file,
1694
- expansionLevel
1695
- });
1686
+ async uploadAttachment(recordId, fieldName, file, options) {
1687
+ if (!entityData.id)
1688
+ throw new Error('Entity ID is undefined');
1689
+ return service.uploadAttachment(entityData.id, recordId, fieldName, file, options);
1690
+ },
1691
+ async deleteAttachment(recordId, fieldName) {
1692
+ if (!entityData.id)
1693
+ throw new Error('Entity ID is undefined');
1694
+ return service.deleteAttachment(entityData.id, recordId, fieldName);
1696
1695
  },
1697
1696
  async insert(data, options) {
1698
1697
  return this.insertRecord(data, options);
@@ -1742,10 +1741,12 @@ const DATA_FABRIC_ENDPOINTS = {
1742
1741
  GET_RECORD_BY_ID: (entityId, recordId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${entityId}/read/${recordId}`,
1743
1742
  INSERT_BY_ID: (entityId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${entityId}/insert`,
1744
1743
  BATCH_INSERT_BY_ID: (entityId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${entityId}/insert-batch`,
1744
+ UPDATE_RECORD_BY_ID: (entityId, recordId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${entityId}/update/${recordId}`,
1745
1745
  UPDATE_BY_ID: (entityId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${entityId}/update-batch`,
1746
1746
  DELETE_BY_ID: (entityId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${entityId}/delete-batch`,
1747
- DOWNLOAD_ATTACHMENT: (entityName, recordId, fieldName) => `${DATAFABRIC_BASE}/api/Attachment/${entityName}/${recordId}/${fieldName}`,
1748
- UPLOAD_ATTACHMENT: (entityName, recordId, fieldName) => `${DATAFABRIC_BASE}/api/Attachment/${entityName}/${recordId}/${fieldName}`,
1747
+ DOWNLOAD_ATTACHMENT: (entityId, recordId, fieldName) => `${DATAFABRIC_BASE}/api/Attachment/entity/${entityId}/${recordId}/${fieldName}`,
1748
+ UPLOAD_ATTACHMENT: (entityId, recordId, fieldName) => `${DATAFABRIC_BASE}/api/Attachment/entity/${entityId}/${recordId}/${fieldName}`,
1749
+ DELETE_ATTACHMENT: (entityId, recordId, fieldName) => `${DATAFABRIC_BASE}/api/Attachment/entity/${entityId}/${recordId}/${fieldName}`,
1749
1750
  },
1750
1751
  CHOICESETS: {
1751
1752
  GET_ALL: `${DATAFABRIC_BASE}/api/Entity/choiceset`,
@@ -1902,7 +1903,7 @@ const EntityFieldTypeMap = {
1902
1903
  // Connection string placeholder that will be replaced during build
1903
1904
  const CONNECTION_STRING = "InstrumentationKey=a6efa11d-1feb-4508-9738-e13e12dcae5e;IngestionEndpoint=https://westeurope-5.in.applicationinsights.azure.com/;LiveEndpoint=https://westeurope.livediagnostics.monitor.azure.com/;ApplicationId=7c58eb1c-9581-4ba6-839e-11725848a037";
1904
1905
  // SDK Version placeholder
1905
- const SDK_VERSION = "1.1.3";
1906
+ const SDK_VERSION = "1.2.1";
1906
1907
  const VERSION = "Version";
1907
1908
  const SERVICE = "Service";
1908
1909
  const CLOUD_ORGANIZATION_NAME = "CloudOrganizationName";
@@ -2369,6 +2370,42 @@ class EntityService extends BaseService {
2369
2370
  const camelResponse = pascalToCamelCaseKeys(response.data);
2370
2371
  return camelResponse;
2371
2372
  }
2373
+ /**
2374
+ * Updates a single record in an entity by entity ID
2375
+ *
2376
+ * @param entityId - UUID of the entity
2377
+ * @param recordId - UUID of the record to update
2378
+ * @param data - Key-value pairs of fields to update
2379
+ * @param options - Update options
2380
+ * @returns Promise resolving to the updated record
2381
+ *
2382
+ * @example
2383
+ * ```typescript
2384
+ * import { Entities } from '@uipath/uipath-typescript/entities';
2385
+ *
2386
+ * const entities = new Entities(sdk);
2387
+ *
2388
+ * // Basic usage
2389
+ * const result = await entities.updateRecordById("<entityId>", "<recordId>", { name: "John Updated", age: 31 });
2390
+ *
2391
+ * // With options
2392
+ * const result = await entities.updateRecordById("<entityId>", "<recordId>", { name: "John Updated", age: 31 }, {
2393
+ * expansionLevel: 1
2394
+ * });
2395
+ * ```
2396
+ */
2397
+ async updateRecordById(entityId, recordId, data, options = {}) {
2398
+ const params = createParams({
2399
+ expansionLevel: options.expansionLevel
2400
+ });
2401
+ const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.UPDATE_RECORD_BY_ID(entityId, recordId), data, {
2402
+ params,
2403
+ ...options
2404
+ });
2405
+ // Convert PascalCase response to camelCase
2406
+ const camelResponse = pascalToCamelCaseKeys(response.data);
2407
+ return camelResponse;
2408
+ }
2372
2409
  /**
2373
2410
  * Updates data in an entity by entity ID
2374
2411
  *
@@ -2478,7 +2515,9 @@ class EntityService extends BaseService {
2478
2515
  /**
2479
2516
  * Downloads an attachment from an entity record field
2480
2517
  *
2481
- * @param options - Options containing entityName, recordId, and fieldName
2518
+ * @param entityId - UUID of the entity
2519
+ * @param recordId - UUID of the record containing the attachment
2520
+ * @param fieldName - Name of the File-type field containing the attachment
2482
2521
  * @returns Promise resolving to Blob containing the file content
2483
2522
  *
2484
2523
  * @example
@@ -2487,16 +2526,20 @@ class EntityService extends BaseService {
2487
2526
  *
2488
2527
  * const entities = new Entities(sdk);
2489
2528
  *
2529
+ * // Get the entityId from getAll()
2530
+ * const allEntities = await entities.getAll();
2531
+ * const entityId = allEntities[0].id;
2532
+ *
2533
+ * // Get the recordId from getAllRecords()
2534
+ * const records = await entities.getAllRecords(entityId);
2535
+ * const recordId = records[0].id;
2536
+ *
2490
2537
  * // Download attachment for a specific record and field
2491
- * const blob = await entities.downloadAttachment({
2492
- * entityName: 'Invoice',
2493
- * recordId: '<record-uuid>',
2494
- * fieldName: 'Documents'
2495
- * });
2538
+ * const blob = await entities.downloadAttachment(entityId, recordId, 'Documents');
2539
+ * ```
2496
2540
  */
2497
- async downloadAttachment(options) {
2498
- const { entityName, recordId, fieldName } = options;
2499
- const response = await this.get(DATA_FABRIC_ENDPOINTS.ENTITY.DOWNLOAD_ATTACHMENT(entityName, recordId, fieldName), {
2541
+ async downloadAttachment(entityId, recordId, fieldName) {
2542
+ const response = await this.get(DATA_FABRIC_ENDPOINTS.ENTITY.DOWNLOAD_ATTACHMENT(entityId, recordId, fieldName), {
2500
2543
  responseType: RESPONSE_TYPES.BLOB
2501
2544
  });
2502
2545
  return response.data;
@@ -2504,8 +2547,12 @@ class EntityService extends BaseService {
2504
2547
  /**
2505
2548
  * Uploads an attachment to a File-type field of an entity record
2506
2549
  *
2507
- * @param options - Options containing entityName, recordId, fieldName, file, and optional expansionLevel
2508
- * @returns Promise resolving to the upload response
2550
+ * @param entityId - UUID of the entity
2551
+ * @param recordId - UUID of the record to upload the attachment to
2552
+ * @param fieldName - Name of the File-type field
2553
+ * @param file - File to upload (Blob, File, or Uint8Array)
2554
+ * @param options - Optional {@link EntityUploadAttachmentOptions} (e.g. expansionLevel)
2555
+ * @returns Promise resolving to {@link EntityUploadAttachmentResponse}
2509
2556
  *
2510
2557
  * @example
2511
2558
  * ```typescript
@@ -2513,17 +2560,19 @@ class EntityService extends BaseService {
2513
2560
  *
2514
2561
  * const entities = new Entities(sdk);
2515
2562
  *
2563
+ * // Get the entityId from getAll()
2564
+ * const allEntities = await entities.getAll();
2565
+ * const entityId = allEntities[0].id;
2566
+ *
2567
+ * // Get the recordId from getAllRecords()
2568
+ * const records = await entities.getAllRecords(entityId);
2569
+ * const recordId = records[0].id;
2570
+ *
2516
2571
  * // Upload a file attachment
2517
- * const response = await entities.uploadAttachment({
2518
- * entityName: 'Invoice',
2519
- * recordId: '<record-uuid>',
2520
- * fieldName: 'Documents',
2521
- * file: file
2522
- * });
2572
+ * const response = await entities.uploadAttachment(entityId, recordId, 'Documents', file);
2523
2573
  * ```
2524
2574
  */
2525
- async uploadAttachment(options) {
2526
- const { entityName, recordId, fieldName, file, expansionLevel } = options;
2575
+ async uploadAttachment(entityId, recordId, fieldName, file, options) {
2527
2576
  const formData = new FormData();
2528
2577
  if (file instanceof Uint8Array) {
2529
2578
  formData.append('file', new Blob([file.buffer]));
@@ -2531,12 +2580,42 @@ class EntityService extends BaseService {
2531
2580
  else {
2532
2581
  formData.append('file', file);
2533
2582
  }
2534
- const params = createParams({ expansionLevel });
2535
- const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.UPLOAD_ATTACHMENT(entityName, recordId, fieldName), formData, { params });
2583
+ const params = createParams({ expansionLevel: options?.expansionLevel });
2584
+ const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.UPLOAD_ATTACHMENT(entityId, recordId, fieldName), formData, { params });
2536
2585
  // Convert PascalCase response to camelCase
2537
2586
  const camelResponse = pascalToCamelCaseKeys(response.data);
2538
2587
  return camelResponse;
2539
2588
  }
2589
+ /**
2590
+ * Removes an attachment from a File-type field of an entity record
2591
+ *
2592
+ * @param entityId - UUID of the entity
2593
+ * @param recordId - UUID of the record containing the attachment
2594
+ * @param fieldName - Name of the File-type field containing the attachment
2595
+ * @returns Promise resolving to {@link EntityDeleteAttachmentResponse}
2596
+ *
2597
+ * @example
2598
+ * ```typescript
2599
+ * import { Entities } from '@uipath/uipath-typescript/entities';
2600
+ *
2601
+ * const entities = new Entities(sdk);
2602
+ *
2603
+ * // Get the entityId from getAll()
2604
+ * const allEntities = await entities.getAll();
2605
+ * const entityId = allEntities[0].id;
2606
+ *
2607
+ * // Get the recordId from getAllRecords()
2608
+ * const records = await entities.getAllRecords(entityId);
2609
+ * const recordId = records[0].id;
2610
+ *
2611
+ * // Delete attachment for a specific record and field
2612
+ * await entities.deleteAttachment(entityId, recordId, 'Documents');
2613
+ * ```
2614
+ */
2615
+ async deleteAttachment(entityId, recordId, fieldName) {
2616
+ const response = await this.delete(DATA_FABRIC_ENDPOINTS.ENTITY.DELETE_ATTACHMENT(entityId, recordId, fieldName));
2617
+ return response.data;
2618
+ }
2540
2619
  /**
2541
2620
  * @hidden
2542
2621
  * @deprecated Use {@link getAllRecords} instead.
@@ -2658,6 +2737,9 @@ __decorate([
2658
2737
  __decorate([
2659
2738
  track('Entities.InsertRecordsById')
2660
2739
  ], EntityService.prototype, "insertRecordsById", null);
2740
+ __decorate([
2741
+ track('Entities.UpdateRecordById')
2742
+ ], EntityService.prototype, "updateRecordById", null);
2661
2743
  __decorate([
2662
2744
  track('Entities.UpdateRecordsById')
2663
2745
  ], EntityService.prototype, "updateRecordsById", null);
@@ -2673,6 +2755,9 @@ __decorate([
2673
2755
  __decorate([
2674
2756
  track('Entities.UploadAttachment')
2675
2757
  ], EntityService.prototype, "uploadAttachment", null);
2758
+ __decorate([
2759
+ track('Entities.DeleteAttachment')
2760
+ ], EntityService.prototype, "deleteAttachment", null);
2676
2761
 
2677
2762
  class ChoiceSetService extends BaseService {
2678
2763
  /**