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