@uipath/uipath-typescript 1.3.6 → 1.3.8

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 (44) hide show
  1. package/dist/assets/index.cjs +243 -6
  2. package/dist/assets/index.d.ts +113 -13
  3. package/dist/assets/index.mjs +243 -6
  4. package/dist/attachments/index.cjs +42 -6
  5. package/dist/attachments/index.d.ts +8 -0
  6. package/dist/attachments/index.mjs +42 -6
  7. package/dist/buckets/index.cjs +211 -6
  8. package/dist/buckets/index.d.ts +57 -12
  9. package/dist/buckets/index.mjs +211 -6
  10. package/dist/cases/index.cjs +180 -6
  11. package/dist/cases/index.d.ts +165 -3
  12. package/dist/cases/index.mjs +181 -7
  13. package/dist/conversational-agent/index.cjs +235 -85
  14. package/dist/conversational-agent/index.d.ts +327 -80
  15. package/dist/conversational-agent/index.mjs +234 -84
  16. package/dist/core/index.cjs +18 -6
  17. package/dist/core/index.d.ts +1 -1
  18. package/dist/core/index.mjs +18 -6
  19. package/dist/entities/index.cjs +74 -10
  20. package/dist/entities/index.d.ts +102 -11
  21. package/dist/entities/index.mjs +75 -11
  22. package/dist/feedback/index.cjs +293 -10
  23. package/dist/feedback/index.d.ts +425 -12
  24. package/dist/feedback/index.mjs +293 -10
  25. package/dist/index.cjs +463 -17
  26. package/dist/index.d.ts +885 -39
  27. package/dist/index.mjs +464 -18
  28. package/dist/index.umd.js +463 -17
  29. package/dist/jobs/index.cjs +211 -6
  30. package/dist/jobs/index.d.ts +68 -23
  31. package/dist/jobs/index.mjs +211 -6
  32. package/dist/maestro-processes/index.cjs +79 -6
  33. package/dist/maestro-processes/index.d.ts +8 -0
  34. package/dist/maestro-processes/index.mjs +79 -6
  35. package/dist/processes/index.cjs +279 -7
  36. package/dist/processes/index.d.ts +125 -2
  37. package/dist/processes/index.mjs +279 -7
  38. package/dist/queues/index.cjs +211 -6
  39. package/dist/queues/index.d.ts +57 -12
  40. package/dist/queues/index.mjs +211 -6
  41. package/dist/tasks/index.cjs +42 -6
  42. package/dist/tasks/index.d.ts +8 -0
  43. package/dist/tasks/index.mjs +42 -6
  44. package/package.json +1 -1
@@ -505,6 +505,8 @@ class ErrorFactory {
505
505
  }
506
506
  }
507
507
 
508
+ const FOLDER_KEY = 'X-UIPATH-FolderKey';
509
+ const FOLDER_PATH_ENCODED = 'X-UIPATH-FolderPath-Encoded';
508
510
  const FOLDER_ID = 'X-UIPATH-OrganizationUnitId';
509
511
  const TRACEPARENT = 'traceparent';
510
512
  const UIPATH_TRACEPARENT_ID = 'x-uipath-traceparent-id';
@@ -651,6 +653,27 @@ var PaginationType;
651
653
  /**
652
654
  * Collection of utility functions for working with objects
653
655
  */
656
+ /**
657
+ * Resolves a field value from an object, supporting both direct keys (e.g., '@odata.count')
658
+ * and dot-separated nested paths (e.g., 'pagination.totalCount').
659
+ * Direct key match takes priority over nested traversal.
660
+ */
661
+ function resolveNestedField(data, fieldPath) {
662
+ if (!data) {
663
+ return undefined;
664
+ }
665
+ if (fieldPath in data) {
666
+ return data[fieldPath];
667
+ }
668
+ if (!fieldPath.includes('.')) {
669
+ return undefined;
670
+ }
671
+ let value = data;
672
+ for (const part of fieldPath.split('.')) {
673
+ value = value?.[part];
674
+ }
675
+ return value;
676
+ }
654
677
  /**
655
678
  * Filters out undefined values from an object
656
679
  * @param obj The source object
@@ -891,6 +914,10 @@ const BUCKET_TOKEN_PARAMS = {
891
914
  TOKEN_PARAM: 'continuationToken'
892
915
  };
893
916
 
917
+ /**
918
+ * Converts a UTC timestamp string (e.g., "5/8/2026 11:20:17 AM") to ISO 8601 UTC format.
919
+ * Returns the original value if parsing fails.
920
+ */
894
921
  /**
895
922
  * Transforms data by mapping fields according to the provided field mapping
896
923
  * @param data The source data to transform
@@ -1245,7 +1272,8 @@ class PaginationHelpers {
1245
1272
  // Extract and transform items from response
1246
1273
  // Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N })
1247
1274
  const rawItems = Array.isArray(response.data) ? response.data : response.data?.[itemsField];
1248
- const totalCount = Array.isArray(response.data) ? undefined : response.data?.[totalCountField];
1275
+ const rawTotalCount = Array.isArray(response.data) ? undefined : resolveNestedField(response.data, totalCountField);
1276
+ const totalCount = typeof rawTotalCount === 'number' ? rawTotalCount : undefined;
1249
1277
  // Parse items - automatically handle JSON string responses
1250
1278
  const parsedItems = typeof rawItems === 'string' ? JSON.parse(rawItems) : (rawItems || []);
1251
1279
  const items = transformFn ? parsedItems.map(transformFn) : parsedItems;
@@ -1421,8 +1449,9 @@ class BaseService {
1421
1449
  constructor(instance, headers) {
1422
1450
  // Private field - not visible via Object.keys() or any reflection
1423
1451
  _BaseService_apiClient.set(this, void 0);
1424
- const { config, context, tokenManager } = SDKInternalsRegistry.get(instance);
1452
+ const { config, context, tokenManager, folderKey } = SDKInternalsRegistry.get(instance);
1425
1453
  __classPrivateFieldSet(this, _BaseService_apiClient, new ApiClient(config, context, tokenManager, headers ? { headers } : {}), "f");
1454
+ this.config = { folderKey };
1426
1455
  }
1427
1456
  /**
1428
1457
  * Gets a valid authentication token, refreshing if necessary.
@@ -1541,9 +1570,17 @@ class BaseService {
1541
1570
  const pageSizeParam = paginationParams?.pageSizeParam || ODATA_OFFSET_PARAMS.PAGE_SIZE_PARAM;
1542
1571
  const offsetParam = paginationParams?.offsetParam || ODATA_OFFSET_PARAMS.OFFSET_PARAM;
1543
1572
  const countParam = paginationParams?.countParam || ODATA_OFFSET_PARAMS.COUNT_PARAM;
1573
+ // When true (default), converts pageNumber to a skip/offset value (e.g., page 3 with pageSize 10 → skip 20).
1574
+ // When false, passes pageNumber directly as the offset param — used by APIs that accept a page number instead of a record offset.
1575
+ const convertToSkip = paginationParams?.convertToSkip ?? true;
1544
1576
  requestParams[pageSizeParam] = limitedPageSize;
1545
- if (params.pageNumber && params.pageNumber > 1) {
1546
- requestParams[offsetParam] = (params.pageNumber - 1) * limitedPageSize;
1577
+ if (convertToSkip) {
1578
+ if (params.pageNumber && params.pageNumber > 1) {
1579
+ requestParams[offsetParam] = (params.pageNumber - 1) * limitedPageSize;
1580
+ }
1581
+ }
1582
+ else {
1583
+ requestParams[offsetParam] = params.pageNumber || 1;
1547
1584
  }
1548
1585
  {
1549
1586
  requestParams[countParam] = true;
@@ -1574,7 +1611,8 @@ class BaseService {
1574
1611
  // Extract items and metadata
1575
1612
  // Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N })
1576
1613
  const items = Array.isArray(response.data) ? response.data : (response.data[itemsField] || []);
1577
- const totalCount = Array.isArray(response.data) ? undefined : response.data[totalCountField];
1614
+ const rawTotalCount = Array.isArray(response.data) ? undefined : resolveNestedField(response.data, totalCountField);
1615
+ const totalCount = typeof rawTotalCount === 'number' ? rawTotalCount : undefined;
1578
1616
  const continuationToken = response.data[continuationTokenField];
1579
1617
  // Determine if there are more pages
1580
1618
  const hasMore = this.determineHasMorePages(paginationType, {
@@ -1619,6 +1657,111 @@ class BaseService {
1619
1657
  }
1620
1658
  _BaseService_apiClient = new WeakMap();
1621
1659
 
1660
+ /**
1661
+ * Validates the `name` argument passed to a `getByName(name, ...)` method.
1662
+ * Trims whitespace and rejects empty/whitespace-only names.
1663
+ *
1664
+ * @param resourceType - Resource label used in error messages (e.g. 'Asset', 'Process')
1665
+ * @param name - Resource name to validate
1666
+ * @returns The trimmed name
1667
+ * @throws ValidationError when `name` is missing or empty after trimming
1668
+ */
1669
+ function validateName(resourceType, name) {
1670
+ if (!name) {
1671
+ throw new ValidationError({
1672
+ message: `${resourceType} name is required and cannot be empty.`,
1673
+ });
1674
+ }
1675
+ const trimmed = name.trim();
1676
+ if (!trimmed) {
1677
+ throw new ValidationError({
1678
+ message: `${resourceType} name is required and cannot be empty.`,
1679
+ });
1680
+ }
1681
+ return trimmed;
1682
+ }
1683
+
1684
+ /**
1685
+ * Encodes a folder path for the `X-UIPATH-FolderPath-Encoded` header.
1686
+ *
1687
+ * Orchestrator decodes this header as **base64-encoded UTF-16 LE bytes**
1688
+ * (see `HttpHeadersProviderExtensions.GetDecoded` + `OrganizationUnitProvider`
1689
+ * in the Orchestrator repo, which call `Encoding.Unicode.GetString(...)`).
1690
+ * URL-encoding is NOT what the server expects — it must be base64-of-UTF-16-LE
1691
+ * bytes.
1692
+ *
1693
+ * @param folderPath - The folder path (e.g. 'Shared/Finance')
1694
+ * @returns Base64 string suitable for the `X-UIPATH-FolderPath-Encoded` header
1695
+ */
1696
+ function encodeFolderPathHeader(folderPath) {
1697
+ // Force little-endian regardless of host byte order. `Uint16Array` viewed
1698
+ // as `Uint8Array` would use the host's native order — correct on LE hosts
1699
+ // (x86/ARM-LE) but wrong on BE hosts. `DataView.setUint16(..., true)`
1700
+ // pins LE.
1701
+ const buf = new ArrayBuffer(folderPath.length * 2);
1702
+ const view = new DataView(buf);
1703
+ for (let i = 0; i < folderPath.length; i++) {
1704
+ view.setUint16(i * 2, folderPath.charCodeAt(i), true);
1705
+ }
1706
+ const bytes = new Uint8Array(buf);
1707
+ let binary = '';
1708
+ for (let i = 0; i < bytes.byteLength; i++) {
1709
+ binary += String.fromCharCode(bytes[i]);
1710
+ }
1711
+ // btoa is browser-native; Node 16+ also has it as a global
1712
+ return btoa(binary);
1713
+ }
1714
+
1715
+ /**
1716
+ * Resolves folder context into the appropriate Orchestrator folder headers.
1717
+ *
1718
+ * Centralized so all folder-scoped methods (e.g. `assets.getByName`,
1719
+ * `processes.getByName`, future Queues/Buckets/Jobs) share one implementation.
1720
+ *
1721
+ * Each input field maps directly to its header — no auto-detection or type
1722
+ * coercion. When multiple fields are supplied, all corresponding headers
1723
+ * are forwarded and the server resolves precedence.
1724
+ *
1725
+ * Routing:
1726
+ * - `folderId` → `X-UIPATH-OrganizationUnitId`
1727
+ * - `folderKey` → `X-UIPATH-FolderKey`
1728
+ * - `folderPath` → `X-UIPATH-FolderPath-Encoded`
1729
+ * - none set + `fallbackFolderKey` → fallback used as `X-UIPATH-FolderKey`
1730
+ * - none set + no fallback → `ValidationError`
1731
+ *
1732
+ * @throws ValidationError when no folder context can be resolved.
1733
+ */
1734
+ function resolveFolderHeaders(input) {
1735
+ const { folderId, folderKey, folderPath, resourceType, fallbackFolderKey } = input;
1736
+ const trimmedKey = folderKey?.trim();
1737
+ const trimmedPath = folderPath?.trim();
1738
+ const headers = {};
1739
+ if (folderId !== undefined) {
1740
+ headers[FOLDER_ID] = folderId;
1741
+ }
1742
+ if (trimmedKey) {
1743
+ headers[FOLDER_KEY] = trimmedKey;
1744
+ }
1745
+ if (trimmedPath) {
1746
+ headers[FOLDER_PATH_ENCODED] = encodeFolderPathHeader(trimmedPath);
1747
+ }
1748
+ // No explicit folder context → meta-tag fallback or error.
1749
+ if (Object.keys(headers).length === 0) {
1750
+ if (!fallbackFolderKey) {
1751
+ throw new ValidationError({
1752
+ message: `${resourceType} requires folder context: pass \`folderId\`, \`folderKey\`, or \`folderPath\`, or initialize the SDK with a folder context.`,
1753
+ });
1754
+ }
1755
+ headers[FOLDER_KEY] = fallbackFolderKey;
1756
+ }
1757
+ return createHeaders(headers);
1758
+ }
1759
+
1760
+ /**
1761
+ * Matches single-quote characters in OData string literals — escaped to `''`
1762
+ * inside the `$filter=Name eq '…'` clause built by `getByNameLookup`.
1763
+ */
1764
+ const SINGLE_QUOTE_RE = /'/g;
1622
1765
  /**
1623
1766
  * Base service for services that need folder-specific functionality.
1624
1767
  *
@@ -1652,6 +1795,68 @@ class FolderScopedService extends BaseService {
1652
1795
  }
1653
1796
  return response.data?.value;
1654
1797
  }
1798
+ /**
1799
+ * Look up a single resource by name on a folder-scoped OData collection.
1800
+ *
1801
+ * Shared by `getByName` implementations across services (Assets, Processes, etc).
1802
+ * Handles:
1803
+ * - Name validation via `validateName`
1804
+ * - Folder header resolution via `resolveFolderHeaders` (folderId → ID/key
1805
+ * header by type, folderPath → encoded path header, falls back to
1806
+ * init-time `config.folderKey` from the `uipath:folder-key` meta tag)
1807
+ * - OData `$filter=Name eq '…'` with single-quote escaping + `$top=1`
1808
+ * - Empty-result → `NotFoundError` with folder context in the message
1809
+ *
1810
+ * The transform step is caller-provided because each resource has its own
1811
+ * PascalCase → camelCase field mapping.
1812
+ *
1813
+ * @param resourceType - Resource label used in validation + error messages (e.g. 'Asset', 'Process')
1814
+ * @param endpoint - Folder-scoped OData collection endpoint
1815
+ * @param name - Resource name to search for
1816
+ * @param options - Folder scoping (`folderId` / `folderKey` / `folderPath`) + OData query options (`expand`, `select`)
1817
+ * @param transform - Maps a raw OData item to the typed response (e.g. PascalCase → camelCase via field map)
1818
+ * @throws ValidationError when inputs are malformed; NotFoundError when no match
1819
+ */
1820
+ async getByNameLookup(resourceType, endpoint, name, options, transform) {
1821
+ const validatedName = validateName(resourceType, name);
1822
+ const { folderId, folderKey, folderPath, ...queryOptions } = options;
1823
+ const headers = resolveFolderHeaders({
1824
+ folderId,
1825
+ folderKey,
1826
+ folderPath,
1827
+ resourceType: `${resourceType}.getByName`,
1828
+ fallbackFolderKey: this.config.folderKey,
1829
+ });
1830
+ const apiOptions = {
1831
+ ...addPrefixToKeys(queryOptions, ODATA_PREFIX, Object.keys(queryOptions)),
1832
+ '$filter': `Name eq '${validatedName.replace(SINGLE_QUOTE_RE, "''")}'`,
1833
+ '$top': '1',
1834
+ };
1835
+ const response = await this.get(endpoint, {
1836
+ headers,
1837
+ params: apiOptions,
1838
+ });
1839
+ const items = response.data?.value;
1840
+ if (!items?.length) {
1841
+ const folderHint = describeFolderForError(folderId, folderKey, folderPath);
1842
+ throw new NotFoundError({
1843
+ message: `${resourceType} '${validatedName}' not found${folderHint}.`,
1844
+ });
1845
+ }
1846
+ return transform(items[0]);
1847
+ }
1848
+ }
1849
+ /** Renders the supplied folder for a NotFoundError message. */
1850
+ function describeFolderForError(folderId, folderKey, folderPath) {
1851
+ const path = folderPath?.trim();
1852
+ if (path)
1853
+ return ` in folder '${path}'`;
1854
+ const key = folderKey?.trim();
1855
+ if (key)
1856
+ return ` in folder (key: ${key})`;
1857
+ if (typeof folderId === 'number')
1858
+ return ` in folder (id: ${folderId})`;
1859
+ return '';
1655
1860
  }
1656
1861
 
1657
1862
  /**
@@ -1753,7 +1958,7 @@ const JobMap = {
1753
1958
  // Connection string placeholder that will be replaced during build
1754
1959
  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";
1755
1960
  // SDK Version placeholder
1756
- const SDK_VERSION = "1.3.6";
1961
+ const SDK_VERSION = "1.3.8";
1757
1962
  const VERSION = "Version";
1758
1963
  const SERVICE = "Service";
1759
1964
  const CLOUD_ORGANIZATION_NAME = "CloudOrganizationName";
@@ -106,6 +106,7 @@ interface RequestWithPaginationOptions extends RequestSpec {
106
106
  offsetParam?: string;
107
107
  tokenParam?: string;
108
108
  countParam?: string;
109
+ convertToSkip?: boolean;
109
110
  };
110
111
  };
111
112
  }
@@ -218,6 +219,13 @@ interface ApiResponse<T> {
218
219
  */
219
220
  declare class BaseService {
220
221
  #private;
222
+ /**
223
+ * SDK configuration (read-only). Available to subclasses so they can
224
+ * fall back to init-time defaults like `folderKey`.
225
+ */
226
+ protected readonly config: {
227
+ folderKey?: string;
228
+ };
221
229
  /**
222
230
  * Creates a base service instance with dependency injection.
223
231
  *
@@ -291,29 +299,6 @@ declare class BaseService {
291
299
  private determineHasMorePages;
292
300
  }
293
301
 
294
- /**
295
- * Base service for services that need folder-specific functionality.
296
- *
297
- * Extends BaseService with additional methods for working with folder-scoped resources
298
- * in UiPath Orchestrator. Services that work with folders (Assets, Queues) extend this class.
299
- *
300
- * @remarks
301
- * This class provides helper methods for making folder-scoped API calls, handling folder IDs
302
- * in request headers, and managing cross-folder queries.
303
- */
304
- declare class FolderScopedService extends BaseService {
305
- /**
306
- * Gets resources in a folder with optional query parameters
307
- *
308
- * @param endpoint - API endpoint to call
309
- * @param folderId - required folder ID
310
- * @param options - Query options
311
- * @param transformFn - Optional function to transform the response data
312
- * @returns Promise resolving to an array of resources
313
- */
314
- protected _getByFolder<T, R = T>(endpoint: string, folderId: number, options?: Record<string, any>, transformFn?: (item: T) => R): Promise<R[]>;
315
- }
316
-
317
302
  /**
318
303
  * Common enum for job state used across services
319
304
  */
@@ -339,6 +324,66 @@ interface RequestOptions extends BaseOptions {
339
324
  filter?: string;
340
325
  orderby?: string;
341
326
  }
327
+ /**
328
+ * Options that scope a name-based lookup (e.g. `getByName`) to a folder.
329
+ * Provide one of `folderId`, `folderKey`, or `folderPath`. When more than
330
+ * one is supplied, all are forwarded; the server applies precedence
331
+ * `folderPath` > `folderKey` > `folderId`.
332
+ */
333
+ interface FolderScopedOptions extends BaseOptions {
334
+ /** Numeric folder ID. */
335
+ folderId?: number;
336
+ /** Folder key (GUID-formatted string). */
337
+ folderKey?: string;
338
+ /** Slash-delimited folder path, e.g. `'Shared/Finance'`. */
339
+ folderPath?: string;
340
+ }
341
+
342
+ /**
343
+ * Base service for services that need folder-specific functionality.
344
+ *
345
+ * Extends BaseService with additional methods for working with folder-scoped resources
346
+ * in UiPath Orchestrator. Services that work with folders (Assets, Queues) extend this class.
347
+ *
348
+ * @remarks
349
+ * This class provides helper methods for making folder-scoped API calls, handling folder IDs
350
+ * in request headers, and managing cross-folder queries.
351
+ */
352
+ declare class FolderScopedService extends BaseService {
353
+ /**
354
+ * Gets resources in a folder with optional query parameters
355
+ *
356
+ * @param endpoint - API endpoint to call
357
+ * @param folderId - required folder ID
358
+ * @param options - Query options
359
+ * @param transformFn - Optional function to transform the response data
360
+ * @returns Promise resolving to an array of resources
361
+ */
362
+ protected _getByFolder<T, R = T>(endpoint: string, folderId: number, options?: Record<string, any>, transformFn?: (item: T) => R): Promise<R[]>;
363
+ /**
364
+ * Look up a single resource by name on a folder-scoped OData collection.
365
+ *
366
+ * Shared by `getByName` implementations across services (Assets, Processes, etc).
367
+ * Handles:
368
+ * - Name validation via `validateName`
369
+ * - Folder header resolution via `resolveFolderHeaders` (folderId → ID/key
370
+ * header by type, folderPath → encoded path header, falls back to
371
+ * init-time `config.folderKey` from the `uipath:folder-key` meta tag)
372
+ * - OData `$filter=Name eq '…'` with single-quote escaping + `$top=1`
373
+ * - Empty-result → `NotFoundError` with folder context in the message
374
+ *
375
+ * The transform step is caller-provided because each resource has its own
376
+ * PascalCase → camelCase field mapping.
377
+ *
378
+ * @param resourceType - Resource label used in validation + error messages (e.g. 'Asset', 'Process')
379
+ * @param endpoint - Folder-scoped OData collection endpoint
380
+ * @param name - Resource name to search for
381
+ * @param options - Folder scoping (`folderId` / `folderKey` / `folderPath`) + OData query options (`expand`, `select`)
382
+ * @param transform - Maps a raw OData item to the typed response (e.g. PascalCase → camelCase via field map)
383
+ * @throws ValidationError when inputs are malformed; NotFoundError when no match
384
+ */
385
+ protected getByNameLookup<TRaw extends object, T>(resourceType: string, endpoint: string, name: string, options: FolderScopedOptions, transform: (raw: TRaw) => T): Promise<T>;
386
+ }
342
387
 
343
388
  /**
344
389
  * Enum for package types