@uipath/uipath-typescript 1.3.11 → 1.4.0

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 (56) hide show
  1. package/dist/agent-memory/index.cjs +1765 -0
  2. package/dist/agent-memory/index.d.ts +588 -0
  3. package/dist/agent-memory/index.mjs +1763 -0
  4. package/dist/agents/index.cjs +1726 -0
  5. package/dist/agents/index.d.ts +502 -0
  6. package/dist/agents/index.mjs +1724 -0
  7. package/dist/assets/index.cjs +155 -30
  8. package/dist/assets/index.d.ts +84 -5
  9. package/dist/assets/index.mjs +155 -30
  10. package/dist/attachments/index.cjs +37 -6
  11. package/dist/attachments/index.d.ts +1 -0
  12. package/dist/attachments/index.mjs +37 -6
  13. package/dist/buckets/index.cjs +37 -6
  14. package/dist/buckets/index.d.ts +1 -0
  15. package/dist/buckets/index.mjs +37 -6
  16. package/dist/cases/index.cjs +141 -10
  17. package/dist/cases/index.d.ts +118 -7
  18. package/dist/cases/index.mjs +141 -11
  19. package/dist/conversational-agent/index.cjs +124 -57
  20. package/dist/conversational-agent/index.d.ts +190 -122
  21. package/dist/conversational-agent/index.mjs +124 -57
  22. package/dist/core/index.cjs +413 -105
  23. package/dist/core/index.d.ts +15 -0
  24. package/dist/core/index.mjs +413 -105
  25. package/dist/entities/index.cjs +122 -43
  26. package/dist/entities/index.d.ts +140 -35
  27. package/dist/entities/index.mjs +122 -43
  28. package/dist/feedback/index.cjs +37 -6
  29. package/dist/feedback/index.d.ts +1 -0
  30. package/dist/feedback/index.mjs +37 -6
  31. package/dist/governance/index.cjs +1782 -0
  32. package/dist/governance/index.d.ts +598 -0
  33. package/dist/governance/index.mjs +1780 -0
  34. package/dist/index.cjs +956 -283
  35. package/dist/index.d.ts +1138 -121
  36. package/dist/index.mjs +956 -284
  37. package/dist/index.umd.js +3113 -2423
  38. package/dist/jobs/index.cjs +37 -6
  39. package/dist/jobs/index.d.ts +1 -0
  40. package/dist/jobs/index.mjs +37 -6
  41. package/dist/maestro-processes/index.cjs +173 -18
  42. package/dist/maestro-processes/index.d.ts +131 -9
  43. package/dist/maestro-processes/index.mjs +173 -18
  44. package/dist/processes/index.cjs +37 -6
  45. package/dist/processes/index.d.ts +1 -0
  46. package/dist/processes/index.mjs +37 -6
  47. package/dist/queues/index.cjs +37 -6
  48. package/dist/queues/index.d.ts +1 -0
  49. package/dist/queues/index.mjs +37 -6
  50. package/dist/tasks/index.cjs +37 -6
  51. package/dist/tasks/index.d.ts +1 -0
  52. package/dist/tasks/index.mjs +37 -6
  53. package/dist/traces/index.cjs +37 -6
  54. package/dist/traces/index.d.ts +1 -0
  55. package/dist/traces/index.mjs +37 -6
  56. package/package.json +32 -2
@@ -505,6 +505,7 @@ class ErrorFactory {
505
505
  }
506
506
  }
507
507
 
508
+ const FOLDER_KEY = 'X-UIPATH-FolderKey';
508
509
  const FOLDER_ID = 'X-UIPATH-OrganizationUnitId';
509
510
  const TRACEPARENT = 'traceparent';
510
511
  const UIPATH_TRACEPARENT_ID = 'x-uipath-traceparent-id';
@@ -719,6 +720,32 @@ function filterUndefined(obj) {
719
720
  */
720
721
  const isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
721
722
  isBrowser && window.self != window.top && window.location.href.includes('source=ActionCenter');
723
+ const _params = isBrowser ? new URLSearchParams(window.location.search) : null;
724
+ /**
725
+ * True when the coded app has been loaded inside a host frame that explicitly
726
+ * opted into token delegation by adding `?host=embed` to the iframe src URL.
727
+ */
728
+ const isHostEmbedded = isBrowser && window.self !== window.top && _params?.get('host') === 'embed';
729
+ /**
730
+ * The validated parent origin, read from the `?basedomain=` query param set
731
+ * by the embedding host in the iframe src URL.
732
+ * Mirrors the same mechanism used by ActionCenterTokenManager.
733
+ * Non-null only when `?host=embed` is present and `?basedomain=` is a valid URL.
734
+ */
735
+ (() => {
736
+ if (!isHostEmbedded)
737
+ return null;
738
+ const basedomain = _params?.get('basedomain');
739
+ if (!basedomain)
740
+ return null;
741
+ try {
742
+ return new URL(basedomain).origin;
743
+ }
744
+ catch {
745
+ console.warn('embeddingOrigin: basedomain query param is not a valid URL', basedomain);
746
+ return null;
747
+ }
748
+ })();
722
749
 
723
750
  /**
724
751
  * Base64 encoding/decoding
@@ -1300,8 +1327,9 @@ class PaginationHelpers {
1300
1327
  });
1301
1328
  }
1302
1329
  // Extract and transform items from response
1303
- // Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N })
1304
- const rawItems = Array.isArray(response.data) ? response.data : response.data?.[itemsField];
1330
+ // Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N }).
1331
+ // itemsField may be a dotted path (e.g. 'data.agents') for nested envelopes.
1332
+ const rawItems = Array.isArray(response.data) ? response.data : resolveNestedField(response.data, itemsField);
1305
1333
  const rawTotalCount = Array.isArray(response.data) ? undefined : resolveNestedField(response.data, totalCountField);
1306
1334
  const totalCount = typeof rawTotalCount === 'number' ? rawTotalCount : undefined;
1307
1335
  // Parse items - automatically handle JSON string responses
@@ -1347,7 +1375,7 @@ class PaginationHelpers {
1347
1375
  getEndpoint: config.getEndpoint,
1348
1376
  folderId,
1349
1377
  headers: config.headers,
1350
- paginationParams: cursor ? { cursor, pageSize } : jumpToPage ? { jumpToPage, pageSize } : { pageSize },
1378
+ paginationParams: cursor ? { cursor, pageSize } : jumpToPage !== undefined ? { jumpToPage, pageSize } : { pageSize },
1351
1379
  additionalParams: prefixedOptions,
1352
1380
  transformFn: config.transformFn,
1353
1381
  method: config.method,
@@ -1605,6 +1633,8 @@ class BaseService {
1605
1633
  // When true (default), converts pageNumber to a skip/offset value (e.g., page 3 with pageSize 10 → skip 20).
1606
1634
  // When false, passes pageNumber directly as the offset param — used by APIs that accept a page number instead of a record offset.
1607
1635
  const convertToSkip = paginationParams?.convertToSkip ?? true;
1636
+ // When true, sends pageNumber - 1 (for 0-based APIs). Default false (1-based).
1637
+ const zeroBased = paginationParams?.zeroBased ?? false;
1608
1638
  requestParams[pageSizeParam] = limitedPageSize;
1609
1639
  if (convertToSkip) {
1610
1640
  if (params.pageNumber && params.pageNumber > 1) {
@@ -1612,7 +1642,8 @@ class BaseService {
1612
1642
  }
1613
1643
  }
1614
1644
  else {
1615
- requestParams[offsetParam] = params.pageNumber || 1;
1645
+ const sdkPageNumber = params.pageNumber || 1;
1646
+ requestParams[offsetParam] = zeroBased ? sdkPageNumber - 1 : sdkPageNumber;
1616
1647
  }
1617
1648
  {
1618
1649
  requestParams[countParam] = true;
@@ -1641,8 +1672,9 @@ class BaseService {
1641
1672
  const totalCountField = fields.totalCountField || 'totalRecordCount';
1642
1673
  const continuationTokenField = fields.continuationTokenField || 'continuationToken';
1643
1674
  // Extract items and metadata
1644
- // Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N })
1645
- const items = Array.isArray(response.data) ? response.data : (response.data[itemsField] || []);
1675
+ // Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N }).
1676
+ // itemsField may be a dotted path (e.g. 'data.agents') for nested envelopes.
1677
+ const items = Array.isArray(response.data) ? response.data : (resolveNestedField(response.data, itemsField) || []);
1646
1678
  const rawTotalCount = Array.isArray(response.data) ? undefined : resolveNestedField(response.data, totalCountField);
1647
1679
  const totalCount = typeof rawTotalCount === 'number' ? rawTotalCount : undefined;
1648
1680
  const continuationToken = response.data[continuationTokenField];
@@ -1725,12 +1757,12 @@ function createEntityMethods(entityData, service) {
1725
1757
  throw new Error('Entity ID is undefined');
1726
1758
  return service.deleteRecordsById(entityData.id, recordIds, options);
1727
1759
  },
1728
- async deleteRecord(recordId) {
1760
+ async deleteRecord(recordId, options) {
1729
1761
  if (!entityData.id)
1730
1762
  throw new Error('Entity ID is undefined');
1731
1763
  if (!recordId)
1732
1764
  throw new Error('Record ID is undefined');
1733
- return service.deleteRecordById(entityData.id, recordId);
1765
+ return service.deleteRecordById(entityData.id, recordId, options);
1734
1766
  },
1735
1767
  async getAllRecords(options) {
1736
1768
  if (!entityData.id)
@@ -1744,30 +1776,30 @@ function createEntityMethods(entityData, service) {
1744
1776
  throw new Error('Record ID is undefined');
1745
1777
  return service.getRecordById(entityData.id, recordId, options);
1746
1778
  },
1747
- async downloadAttachment(recordId, fieldName) {
1779
+ async downloadAttachment(recordId, fieldName, options) {
1748
1780
  if (!entityData.id)
1749
1781
  throw new Error('Entity ID is undefined');
1750
- return service.downloadAttachment(entityData.id, recordId, fieldName);
1782
+ return service.downloadAttachment(entityData.id, recordId, fieldName, options);
1751
1783
  },
1752
1784
  async uploadAttachment(recordId, fieldName, file, options) {
1753
1785
  if (!entityData.id)
1754
1786
  throw new Error('Entity ID is undefined');
1755
1787
  return service.uploadAttachment(entityData.id, recordId, fieldName, file, options);
1756
1788
  },
1757
- async deleteAttachment(recordId, fieldName) {
1789
+ async deleteAttachment(recordId, fieldName, options) {
1758
1790
  if (!entityData.id)
1759
1791
  throw new Error('Entity ID is undefined');
1760
- return service.deleteAttachment(entityData.id, recordId, fieldName);
1792
+ return service.deleteAttachment(entityData.id, recordId, fieldName, options);
1761
1793
  },
1762
1794
  async queryRecords(options) {
1763
1795
  if (!entityData.id)
1764
1796
  throw new Error('Entity ID is undefined');
1765
1797
  return service.queryRecordsById(entityData.id, options);
1766
1798
  },
1767
- async importRecords(file) {
1799
+ async importRecords(file, options) {
1768
1800
  if (!entityData.id)
1769
1801
  throw new Error('Entity ID is undefined');
1770
- return service.importRecordsById(entityData.id, file);
1802
+ return service.importRecordsById(entityData.id, file, options);
1771
1803
  },
1772
1804
  async insert(data, options) {
1773
1805
  return this.insertRecord(data, options);
@@ -1778,10 +1810,10 @@ function createEntityMethods(entityData, service) {
1778
1810
  async getRecords(options) {
1779
1811
  return this.getAllRecords(options);
1780
1812
  },
1781
- async delete() {
1813
+ async delete(options) {
1782
1814
  if (!entityData.id)
1783
1815
  throw new Error('Entity ID is undefined');
1784
- return service.deleteById(entityData.id);
1816
+ return service.deleteById(entityData.id, options);
1785
1817
  },
1786
1818
  async update(options) {
1787
1819
  if (!entityData.id)
@@ -2190,6 +2222,7 @@ class EntityService extends BaseService {
2190
2222
  * Gets entity metadata by entity ID with attached operation methods
2191
2223
  *
2192
2224
  * @param id - UUID of the entity
2225
+ * @param options - Optional {@link EntityGetByIdOptions} (e.g. `folderKey` for folder-scoped entities)
2193
2226
  * @returns Promise resolving to entity metadata with schema information and operation methods
2194
2227
  *
2195
2228
  * @example
@@ -2199,6 +2232,9 @@ class EntityService extends BaseService {
2199
2232
  * const entities = new Entities(sdk);
2200
2233
  * const entity = await entities.getById("<entityId>");
2201
2234
  *
2235
+ * // Folder-scoped: pass the entity's folder key
2236
+ * const folderEntity = await entities.getById("<entityId>", { folderKey: "<folderKey>" });
2237
+ *
2202
2238
  * // Call operations directly on the entity
2203
2239
  * const records = await entity.getAllRecords();
2204
2240
  *
@@ -2212,9 +2248,9 @@ class EntityService extends BaseService {
2212
2248
  * ]);
2213
2249
  * ```
2214
2250
  */
2215
- async getById(id) {
2251
+ async getById(id, options) {
2216
2252
  // Get entity metadata
2217
- const response = await this.get(DATA_FABRIC_ENDPOINTS.ENTITY.GET_BY_ID(id));
2253
+ const response = await this.get(DATA_FABRIC_ENDPOINTS.ENTITY.GET_BY_ID(id), { headers: createHeaders({ [FOLDER_KEY]: options?.folderKey }) });
2218
2254
  // Apply EntityMap transformations
2219
2255
  const metadata = transformData(response.data, EntityMap);
2220
2256
  // Transform metadata with field mappers
@@ -2257,9 +2293,14 @@ class EntityService extends BaseService {
2257
2293
  * ```
2258
2294
  */
2259
2295
  async getAllRecords(entityId, options) {
2296
+ // folderKey is header-only — destructure it out so PaginationHelpers doesn't serialise it
2297
+ // into the query string as $folderKey.
2298
+ const { folderKey, ...rest } = options ?? {};
2299
+ const downstreamOptions = options === undefined ? undefined : rest;
2260
2300
  return PaginationHelpers.getAll({
2261
2301
  serviceAccess: this.createPaginationServiceAccess(),
2262
2302
  getEndpoint: () => DATA_FABRIC_ENDPOINTS.ENTITY.GET_ENTITY_RECORDS(entityId),
2303
+ headers: createHeaders({ [FOLDER_KEY]: folderKey }),
2263
2304
  pagination: {
2264
2305
  paginationType: PaginationType.OFFSET,
2265
2306
  itemsField: ENTITY_PAGINATION.ITEMS_FIELD,
@@ -2271,7 +2312,7 @@ class EntityService extends BaseService {
2271
2312
  }
2272
2313
  },
2273
2314
  excludeFromPrefix: ['expansionLevel'] // Don't add ODATA prefix to expansionLevel
2274
- }, options);
2315
+ }, downstreamOptions);
2275
2316
  }
2276
2317
  /**
2277
2318
  * Gets a single entity record by entity ID and record ID
@@ -2296,7 +2337,7 @@ class EntityService extends BaseService {
2296
2337
  const params = createParams({
2297
2338
  expansionLevel: options.expansionLevel
2298
2339
  });
2299
- const response = await this.get(DATA_FABRIC_ENDPOINTS.ENTITY.GET_RECORD_BY_ID(entityId, recordId), { params });
2340
+ const response = await this.get(DATA_FABRIC_ENDPOINTS.ENTITY.GET_RECORD_BY_ID(entityId, recordId), { params, headers: createHeaders({ [FOLDER_KEY]: options.folderKey }) });
2300
2341
  return response.data;
2301
2342
  }
2302
2343
  /**
@@ -2328,7 +2369,7 @@ class EntityService extends BaseService {
2328
2369
  });
2329
2370
  const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.INSERT_BY_ID(id), data, {
2330
2371
  params,
2331
- ...options
2372
+ headers: createHeaders({ [FOLDER_KEY]: options.folderKey }),
2332
2373
  });
2333
2374
  return response.data;
2334
2375
  }
@@ -2369,7 +2410,7 @@ class EntityService extends BaseService {
2369
2410
  });
2370
2411
  const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.BATCH_INSERT_BY_ID(id), data, {
2371
2412
  params,
2372
- ...options
2413
+ headers: createHeaders({ [FOLDER_KEY]: options.folderKey }),
2373
2414
  });
2374
2415
  return response.data;
2375
2416
  }
@@ -2403,7 +2444,7 @@ class EntityService extends BaseService {
2403
2444
  });
2404
2445
  const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.UPDATE_RECORD_BY_ID(entityId, recordId), data, {
2405
2446
  params,
2406
- ...options
2447
+ headers: createHeaders({ [FOLDER_KEY]: options.folderKey }),
2407
2448
  });
2408
2449
  return response.data;
2409
2450
  }
@@ -2445,7 +2486,7 @@ class EntityService extends BaseService {
2445
2486
  });
2446
2487
  const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.UPDATE_BY_ID(id), data, {
2447
2488
  params,
2448
- ...options
2489
+ headers: createHeaders({ [FOLDER_KEY]: options.folderKey }),
2449
2490
  });
2450
2491
  return response.data;
2451
2492
  }
@@ -2477,7 +2518,7 @@ class EntityService extends BaseService {
2477
2518
  });
2478
2519
  const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.DELETE_BY_ID(id), recordIds, {
2479
2520
  params,
2480
- ...options
2521
+ headers: createHeaders({ [FOLDER_KEY]: options.folderKey }),
2481
2522
  });
2482
2523
  return response.data;
2483
2524
  }
@@ -2489,6 +2530,7 @@ class EntityService extends BaseService {
2489
2530
  *
2490
2531
  * @param entityId - UUID of the entity
2491
2532
  * @param recordId - UUID of the record to delete
2533
+ * @param options - Optional {@link EntityDeleteRecordByIdOptions} (e.g. `folderKey` for folder-scoped entities)
2492
2534
  * @returns Promise resolving to void on success
2493
2535
  * @example
2494
2536
  * ```typescript
@@ -2497,10 +2539,13 @@ class EntityService extends BaseService {
2497
2539
  * const entities = new Entities(sdk);
2498
2540
  *
2499
2541
  * await entities.deleteRecordById("<entityId>", "<recordId>");
2542
+ *
2543
+ * // Folder-scoped: pass the entity's folder key
2544
+ * await entities.deleteRecordById("<entityId>", "<recordId>", { folderKey: "<folderKey>" });
2500
2545
  * ```
2501
2546
  */
2502
- async deleteRecordById(entityId, recordId) {
2503
- await this.delete(DATA_FABRIC_ENDPOINTS.ENTITY.DELETE_RECORD_BY_ID(entityId, recordId));
2547
+ async deleteRecordById(entityId, recordId, options) {
2548
+ await this.delete(DATA_FABRIC_ENDPOINTS.ENTITY.DELETE_RECORD_BY_ID(entityId, recordId), { headers: createHeaders({ [FOLDER_KEY]: options?.folderKey }) });
2504
2549
  }
2505
2550
  /**
2506
2551
  * Gets all entities in the system
@@ -2586,10 +2631,15 @@ class EntityService extends BaseService {
2586
2631
  * ```
2587
2632
  */
2588
2633
  async queryRecordsById(id, options) {
2634
+ // folderKey is header-only — destructure it out so PaginationHelpers doesn't include
2635
+ // it in the POST body alongside the query filters.
2636
+ const { folderKey, ...rest } = options ?? {};
2637
+ const downstreamOptions = options === undefined ? undefined : rest;
2589
2638
  return PaginationHelpers.getAll({
2590
2639
  serviceAccess: this.createPaginationServiceAccess(),
2591
2640
  getEndpoint: () => DATA_FABRIC_ENDPOINTS.ENTITY.QUERY_BY_ID(id),
2592
2641
  method: HTTP_METHODS.POST,
2642
+ headers: createHeaders({ [FOLDER_KEY]: folderKey }),
2593
2643
  pagination: {
2594
2644
  paginationType: PaginationType.OFFSET,
2595
2645
  itemsField: ENTITY_PAGINATION.ITEMS_FIELD,
@@ -2601,13 +2651,14 @@ class EntityService extends BaseService {
2601
2651
  }
2602
2652
  },
2603
2653
  excludeFromPrefix: ['expansionLevel', 'filterGroup', 'selectedFields', 'sortOptions', 'aggregates', 'groupBy']
2604
- }, options);
2654
+ }, downstreamOptions);
2605
2655
  }
2606
2656
  /**
2607
2657
  * Imports records from a CSV file into an entity
2608
2658
  *
2609
2659
  * @param id - UUID of the entity
2610
2660
  * @param file - CSV file to import (Blob, File, or Uint8Array)
2661
+ * @param options - Optional {@link EntityImportRecordsByIdOptions} (e.g. `folderKey` for folder-scoped entities)
2611
2662
  * @returns Promise resolving to import result with record counts
2612
2663
  *
2613
2664
  * @example
@@ -2628,10 +2679,12 @@ class EntityService extends BaseService {
2628
2679
  * if (result.errorFileLink) {
2629
2680
  * console.log(`Error file link: ${result.errorFileLink}`);
2630
2681
  * }
2682
+ *
2683
+ * // Folder-scoped entity: pass the entity's folder key
2684
+ * await entities.importRecordsById("<entityId>", fileInput.files[0], { folderKey: "<folderKey>" });
2631
2685
  * ```
2632
- * @internal
2633
2686
  */
2634
- async importRecordsById(id, file) {
2687
+ async importRecordsById(id, file, options) {
2635
2688
  const formData = new FormData();
2636
2689
  if (file instanceof Uint8Array) {
2637
2690
  formData.append('file', new Blob([file.buffer]));
@@ -2639,7 +2692,7 @@ class EntityService extends BaseService {
2639
2692
  else {
2640
2693
  formData.append('file', file);
2641
2694
  }
2642
- const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.BULK_UPLOAD_BY_ID(id), formData);
2695
+ const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.BULK_UPLOAD_BY_ID(id), formData, { headers: createHeaders({ [FOLDER_KEY]: options?.folderKey }) });
2643
2696
  return response.data;
2644
2697
  }
2645
2698
  /**
@@ -2648,6 +2701,7 @@ class EntityService extends BaseService {
2648
2701
  * @param entityId - UUID of the entity
2649
2702
  * @param recordId - UUID of the record containing the attachment
2650
2703
  * @param fieldName - Name of the File-type field containing the attachment
2704
+ * @param options - Optional {@link EntityDownloadAttachmentOptions} (e.g. `folderKey` for folder-scoped entities)
2651
2705
  * @returns Promise resolving to Blob containing the file content
2652
2706
  *
2653
2707
  * @example
@@ -2666,11 +2720,15 @@ class EntityService extends BaseService {
2666
2720
  *
2667
2721
  * // Download attachment for a specific record and field
2668
2722
  * const blob = await entities.downloadAttachment(entityId, recordId, 'Documents');
2723
+ *
2724
+ * // Folder-scoped: pass the entity's folder key
2725
+ * const blob = await entities.downloadAttachment(entityId, recordId, 'Documents', { folderKey: "<folderKey>" });
2669
2726
  * ```
2670
2727
  */
2671
- async downloadAttachment(entityId, recordId, fieldName) {
2728
+ async downloadAttachment(entityId, recordId, fieldName, options) {
2672
2729
  const response = await this.get(DATA_FABRIC_ENDPOINTS.ENTITY.DOWNLOAD_ATTACHMENT(entityId, recordId, fieldName), {
2673
- responseType: RESPONSE_TYPES.BLOB
2730
+ responseType: RESPONSE_TYPES.BLOB,
2731
+ headers: createHeaders({ [FOLDER_KEY]: options?.folderKey }),
2674
2732
  });
2675
2733
  return response.data;
2676
2734
  }
@@ -2681,7 +2739,7 @@ class EntityService extends BaseService {
2681
2739
  * @param recordId - UUID of the record to upload the attachment to
2682
2740
  * @param fieldName - Name of the File-type field
2683
2741
  * @param file - File to upload (Blob, File, or Uint8Array)
2684
- * @param options - Optional {@link EntityUploadAttachmentOptions} (e.g. expansionLevel)
2742
+ * @param options - Optional {@link EntityUploadAttachmentOptions} (e.g. `expansionLevel`, `folderKey` for folder-scoped entities)
2685
2743
  * @returns Promise resolving to {@link EntityUploadAttachmentResponse}
2686
2744
  *
2687
2745
  * @example
@@ -2700,6 +2758,9 @@ class EntityService extends BaseService {
2700
2758
  *
2701
2759
  * // Upload a file attachment
2702
2760
  * const response = await entities.uploadAttachment(entityId, recordId, 'Documents', file);
2761
+ *
2762
+ * // Folder-scoped entity: pass the entity's folder key
2763
+ * await entities.uploadAttachment(entityId, recordId, 'Documents', file, { folderKey: "<folderKey>" });
2703
2764
  * ```
2704
2765
  */
2705
2766
  async uploadAttachment(entityId, recordId, fieldName, file, options) {
@@ -2711,7 +2772,10 @@ class EntityService extends BaseService {
2711
2772
  formData.append('file', file);
2712
2773
  }
2713
2774
  const params = createParams({ expansionLevel: options?.expansionLevel });
2714
- const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.UPLOAD_ATTACHMENT(entityId, recordId, fieldName), formData, { params });
2775
+ const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.UPLOAD_ATTACHMENT(entityId, recordId, fieldName), formData, {
2776
+ params,
2777
+ headers: createHeaders({ [FOLDER_KEY]: options?.folderKey }),
2778
+ });
2715
2779
  return response.data;
2716
2780
  }
2717
2781
  /**
@@ -2720,6 +2784,7 @@ class EntityService extends BaseService {
2720
2784
  * @param entityId - UUID of the entity
2721
2785
  * @param recordId - UUID of the record containing the attachment
2722
2786
  * @param fieldName - Name of the File-type field containing the attachment
2787
+ * @param options - Optional {@link EntityDeleteAttachmentOptions} (e.g. `folderKey` for folder-scoped entities)
2723
2788
  * @returns Promise resolving to {@link EntityDeleteAttachmentResponse}
2724
2789
  *
2725
2790
  * @example
@@ -2738,10 +2803,13 @@ class EntityService extends BaseService {
2738
2803
  *
2739
2804
  * // Delete attachment for a specific record and field
2740
2805
  * await entities.deleteAttachment(entityId, recordId, 'Documents');
2806
+ *
2807
+ * // Folder-scoped: pass the entity's folder key
2808
+ * await entities.deleteAttachment(entityId, recordId, 'Documents', { folderKey: "<folderKey>" });
2741
2809
  * ```
2742
2810
  */
2743
- async deleteAttachment(entityId, recordId, fieldName) {
2744
- const response = await this.delete(DATA_FABRIC_ENDPOINTS.ENTITY.DELETE_ATTACHMENT(entityId, recordId, fieldName));
2811
+ async deleteAttachment(entityId, recordId, fieldName, options) {
2812
+ const response = await this.delete(DATA_FABRIC_ENDPOINTS.ENTITY.DELETE_ATTACHMENT(entityId, recordId, fieldName), { headers: createHeaders({ [FOLDER_KEY]: options?.folderKey }) });
2745
2813
  return response.data;
2746
2814
  }
2747
2815
  /**
@@ -2804,23 +2872,27 @@ class EntityService extends BaseService {
2804
2872
  externalFields: opts.externalFields ?? [],
2805
2873
  },
2806
2874
  };
2807
- const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.UPSERT, payload);
2875
+ const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.UPSERT, payload, { headers: createHeaders({ [FOLDER_KEY]: opts.folderKey }) });
2808
2876
  return response.data;
2809
2877
  }
2810
2878
  /**
2811
2879
  * Deletes a Data Fabric entity and all its records
2812
2880
  *
2813
2881
  * @param id - UUID of the entity to delete
2882
+ * @param options - Optional {@link EntityDeleteByIdOptions} (e.g. `folderKey` for folder-scoped entities)
2814
2883
  * @returns Promise resolving when the entity is deleted
2815
2884
  *
2816
2885
  * @example
2817
2886
  * ```typescript
2818
2887
  * await entities.deleteById("<entityId>");
2888
+ *
2889
+ * // Folder-scoped: pass the entity's folder key
2890
+ * await entities.deleteById("<entityId>", { folderKey: "<folderKey>" });
2819
2891
  * ```
2820
2892
  * @internal
2821
2893
  */
2822
- async deleteById(id) {
2823
- await this.delete(DATA_FABRIC_ENDPOINTS.ENTITY.DELETE(id));
2894
+ async deleteById(id, options) {
2895
+ await this.delete(DATA_FABRIC_ENDPOINTS.ENTITY.DELETE(id), { headers: createHeaders({ [FOLDER_KEY]: options?.folderKey }) });
2824
2896
  }
2825
2897
  /**
2826
2898
  * Updates an existing Data Fabric entity — schema and/or metadata.
@@ -2867,6 +2939,12 @@ class EntityService extends BaseService {
2867
2939
  * { id: "<fieldId>", lengthLimit: 1000 },
2868
2940
  * ],
2869
2941
  * });
2942
+ *
2943
+ * // Folder-scoped entity: add a field to an entity that lives in a non-tenant folder
2944
+ * await entities.updateById("<entityId>", {
2945
+ * folderKey: "<folderKey>",
2946
+ * addFields: [{ fieldName: "notes", type: EntityFieldDataType.MULTILINE_TEXT }],
2947
+ * });
2870
2948
  * ```
2871
2949
  * @internal
2872
2950
  */
@@ -2882,7 +2960,7 @@ class EntityService extends BaseService {
2882
2960
  ...(opts.displayName !== undefined && { displayName: opts.displayName }),
2883
2961
  ...(opts.description !== undefined && { description: opts.description }),
2884
2962
  ...(opts.isRbacEnabled !== undefined && { isRbacEnabled: opts.isRbacEnabled }),
2885
- });
2963
+ }, { headers: createHeaders({ [FOLDER_KEY]: opts.folderKey }) });
2886
2964
  }
2887
2965
  }
2888
2966
  /**
@@ -2893,7 +2971,8 @@ class EntityService extends BaseService {
2893
2971
  * @private
2894
2972
  */
2895
2973
  async applySchemaUpdate(entityId, options) {
2896
- const entityResponse = await this.get(DATA_FABRIC_ENDPOINTS.ENTITY.GET_BY_ID(entityId));
2974
+ const folderHeaders = createHeaders({ [FOLDER_KEY]: options.folderKey });
2975
+ const entityResponse = await this.get(DATA_FABRIC_ENDPOINTS.ENTITY.GET_BY_ID(entityId), { headers: folderHeaders });
2897
2976
  const raw = entityResponse.data;
2898
2977
  // Carry forward existing non-system fields from GET response (skip system/primary-key fields)
2899
2978
  let fields = (raw.fields ?? [])
@@ -2956,7 +3035,7 @@ class EntityService extends BaseService {
2956
3035
  isInsightsEnabled: raw.isInsightsEnabled ?? false,
2957
3036
  externalFields: raw.externalFields ?? [],
2958
3037
  },
2959
- });
3038
+ }, { headers: folderHeaders });
2960
3039
  }
2961
3040
  /**
2962
3041
  * Orchestrates all field mapping transformations