@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.
- package/dist/assets/index.cjs +243 -6
- package/dist/assets/index.d.ts +113 -13
- package/dist/assets/index.mjs +243 -6
- package/dist/attachments/index.cjs +42 -6
- package/dist/attachments/index.d.ts +8 -0
- package/dist/attachments/index.mjs +42 -6
- package/dist/buckets/index.cjs +211 -6
- package/dist/buckets/index.d.ts +57 -12
- package/dist/buckets/index.mjs +211 -6
- package/dist/cases/index.cjs +180 -6
- package/dist/cases/index.d.ts +165 -3
- package/dist/cases/index.mjs +181 -7
- package/dist/conversational-agent/index.cjs +235 -85
- package/dist/conversational-agent/index.d.ts +327 -80
- package/dist/conversational-agent/index.mjs +234 -84
- package/dist/core/index.cjs +18 -6
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.mjs +18 -6
- package/dist/entities/index.cjs +74 -10
- package/dist/entities/index.d.ts +102 -11
- package/dist/entities/index.mjs +75 -11
- package/dist/feedback/index.cjs +293 -10
- package/dist/feedback/index.d.ts +425 -12
- package/dist/feedback/index.mjs +293 -10
- package/dist/index.cjs +463 -17
- package/dist/index.d.ts +885 -39
- package/dist/index.mjs +464 -18
- package/dist/index.umd.js +463 -17
- package/dist/jobs/index.cjs +211 -6
- package/dist/jobs/index.d.ts +68 -23
- package/dist/jobs/index.mjs +211 -6
- package/dist/maestro-processes/index.cjs +79 -6
- package/dist/maestro-processes/index.d.ts +8 -0
- package/dist/maestro-processes/index.mjs +79 -6
- package/dist/processes/index.cjs +279 -7
- package/dist/processes/index.d.ts +125 -2
- package/dist/processes/index.mjs +279 -7
- package/dist/queues/index.cjs +211 -6
- package/dist/queues/index.d.ts +57 -12
- package/dist/queues/index.mjs +211 -6
- package/dist/tasks/index.cjs +42 -6
- package/dist/tasks/index.d.ts +8 -0
- package/dist/tasks/index.mjs +42 -6
- package/package.json +1 -1
package/dist/processes/index.mjs
CHANGED
|
@@ -503,6 +503,8 @@ class ErrorFactory {
|
|
|
503
503
|
}
|
|
504
504
|
}
|
|
505
505
|
|
|
506
|
+
const FOLDER_KEY = 'X-UIPATH-FolderKey';
|
|
507
|
+
const FOLDER_PATH_ENCODED = 'X-UIPATH-FolderPath-Encoded';
|
|
506
508
|
const FOLDER_ID = 'X-UIPATH-OrganizationUnitId';
|
|
507
509
|
const TRACEPARENT = 'traceparent';
|
|
508
510
|
const UIPATH_TRACEPARENT_ID = 'x-uipath-traceparent-id';
|
|
@@ -649,6 +651,27 @@ var PaginationType;
|
|
|
649
651
|
/**
|
|
650
652
|
* Collection of utility functions for working with objects
|
|
651
653
|
*/
|
|
654
|
+
/**
|
|
655
|
+
* Resolves a field value from an object, supporting both direct keys (e.g., '@odata.count')
|
|
656
|
+
* and dot-separated nested paths (e.g., 'pagination.totalCount').
|
|
657
|
+
* Direct key match takes priority over nested traversal.
|
|
658
|
+
*/
|
|
659
|
+
function resolveNestedField(data, fieldPath) {
|
|
660
|
+
if (!data) {
|
|
661
|
+
return undefined;
|
|
662
|
+
}
|
|
663
|
+
if (fieldPath in data) {
|
|
664
|
+
return data[fieldPath];
|
|
665
|
+
}
|
|
666
|
+
if (!fieldPath.includes('.')) {
|
|
667
|
+
return undefined;
|
|
668
|
+
}
|
|
669
|
+
let value = data;
|
|
670
|
+
for (const part of fieldPath.split('.')) {
|
|
671
|
+
value = value?.[part];
|
|
672
|
+
}
|
|
673
|
+
return value;
|
|
674
|
+
}
|
|
652
675
|
/**
|
|
653
676
|
* Filters out undefined values from an object
|
|
654
677
|
* @param obj The source object
|
|
@@ -889,6 +912,10 @@ const BUCKET_TOKEN_PARAMS = {
|
|
|
889
912
|
TOKEN_PARAM: 'continuationToken'
|
|
890
913
|
};
|
|
891
914
|
|
|
915
|
+
/**
|
|
916
|
+
* Converts a UTC timestamp string (e.g., "5/8/2026 11:20:17 AM") to ISO 8601 UTC format.
|
|
917
|
+
* Returns the original value if parsing fails.
|
|
918
|
+
*/
|
|
892
919
|
/**
|
|
893
920
|
* Transforms data by mapping fields according to the provided field mapping
|
|
894
921
|
* @param data The source data to transform
|
|
@@ -1306,7 +1333,8 @@ class PaginationHelpers {
|
|
|
1306
1333
|
// Extract and transform items from response
|
|
1307
1334
|
// Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N })
|
|
1308
1335
|
const rawItems = Array.isArray(response.data) ? response.data : response.data?.[itemsField];
|
|
1309
|
-
const
|
|
1336
|
+
const rawTotalCount = Array.isArray(response.data) ? undefined : resolveNestedField(response.data, totalCountField);
|
|
1337
|
+
const totalCount = typeof rawTotalCount === 'number' ? rawTotalCount : undefined;
|
|
1310
1338
|
// Parse items - automatically handle JSON string responses
|
|
1311
1339
|
const parsedItems = typeof rawItems === 'string' ? JSON.parse(rawItems) : (rawItems || []);
|
|
1312
1340
|
const items = transformFn ? parsedItems.map(transformFn) : parsedItems;
|
|
@@ -1482,8 +1510,9 @@ class BaseService {
|
|
|
1482
1510
|
constructor(instance, headers) {
|
|
1483
1511
|
// Private field - not visible via Object.keys() or any reflection
|
|
1484
1512
|
_BaseService_apiClient.set(this, void 0);
|
|
1485
|
-
const { config, context, tokenManager } = SDKInternalsRegistry.get(instance);
|
|
1513
|
+
const { config, context, tokenManager, folderKey } = SDKInternalsRegistry.get(instance);
|
|
1486
1514
|
__classPrivateFieldSet(this, _BaseService_apiClient, new ApiClient(config, context, tokenManager, headers ? { headers } : {}), "f");
|
|
1515
|
+
this.config = { folderKey };
|
|
1487
1516
|
}
|
|
1488
1517
|
/**
|
|
1489
1518
|
* Gets a valid authentication token, refreshing if necessary.
|
|
@@ -1602,9 +1631,17 @@ class BaseService {
|
|
|
1602
1631
|
const pageSizeParam = paginationParams?.pageSizeParam || ODATA_OFFSET_PARAMS.PAGE_SIZE_PARAM;
|
|
1603
1632
|
const offsetParam = paginationParams?.offsetParam || ODATA_OFFSET_PARAMS.OFFSET_PARAM;
|
|
1604
1633
|
const countParam = paginationParams?.countParam || ODATA_OFFSET_PARAMS.COUNT_PARAM;
|
|
1634
|
+
// When true (default), converts pageNumber to a skip/offset value (e.g., page 3 with pageSize 10 → skip 20).
|
|
1635
|
+
// When false, passes pageNumber directly as the offset param — used by APIs that accept a page number instead of a record offset.
|
|
1636
|
+
const convertToSkip = paginationParams?.convertToSkip ?? true;
|
|
1605
1637
|
requestParams[pageSizeParam] = limitedPageSize;
|
|
1606
|
-
if (
|
|
1607
|
-
|
|
1638
|
+
if (convertToSkip) {
|
|
1639
|
+
if (params.pageNumber && params.pageNumber > 1) {
|
|
1640
|
+
requestParams[offsetParam] = (params.pageNumber - 1) * limitedPageSize;
|
|
1641
|
+
}
|
|
1642
|
+
}
|
|
1643
|
+
else {
|
|
1644
|
+
requestParams[offsetParam] = params.pageNumber || 1;
|
|
1608
1645
|
}
|
|
1609
1646
|
{
|
|
1610
1647
|
requestParams[countParam] = true;
|
|
@@ -1635,7 +1672,8 @@ class BaseService {
|
|
|
1635
1672
|
// Extract items and metadata
|
|
1636
1673
|
// Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N })
|
|
1637
1674
|
const items = Array.isArray(response.data) ? response.data : (response.data[itemsField] || []);
|
|
1638
|
-
const
|
|
1675
|
+
const rawTotalCount = Array.isArray(response.data) ? undefined : resolveNestedField(response.data, totalCountField);
|
|
1676
|
+
const totalCount = typeof rawTotalCount === 'number' ? rawTotalCount : undefined;
|
|
1639
1677
|
const continuationToken = response.data[continuationTokenField];
|
|
1640
1678
|
// Determine if there are more pages
|
|
1641
1679
|
const hasMore = this.determineHasMorePages(paginationType, {
|
|
@@ -1680,6 +1718,208 @@ class BaseService {
|
|
|
1680
1718
|
}
|
|
1681
1719
|
_BaseService_apiClient = new WeakMap();
|
|
1682
1720
|
|
|
1721
|
+
/**
|
|
1722
|
+
* Validates the `name` argument passed to a `getByName(name, ...)` method.
|
|
1723
|
+
* Trims whitespace and rejects empty/whitespace-only names.
|
|
1724
|
+
*
|
|
1725
|
+
* @param resourceType - Resource label used in error messages (e.g. 'Asset', 'Process')
|
|
1726
|
+
* @param name - Resource name to validate
|
|
1727
|
+
* @returns The trimmed name
|
|
1728
|
+
* @throws ValidationError when `name` is missing or empty after trimming
|
|
1729
|
+
*/
|
|
1730
|
+
function validateName(resourceType, name) {
|
|
1731
|
+
if (!name) {
|
|
1732
|
+
throw new ValidationError({
|
|
1733
|
+
message: `${resourceType} name is required and cannot be empty.`,
|
|
1734
|
+
});
|
|
1735
|
+
}
|
|
1736
|
+
const trimmed = name.trim();
|
|
1737
|
+
if (!trimmed) {
|
|
1738
|
+
throw new ValidationError({
|
|
1739
|
+
message: `${resourceType} name is required and cannot be empty.`,
|
|
1740
|
+
});
|
|
1741
|
+
}
|
|
1742
|
+
return trimmed;
|
|
1743
|
+
}
|
|
1744
|
+
|
|
1745
|
+
/**
|
|
1746
|
+
* Encodes a folder path for the `X-UIPATH-FolderPath-Encoded` header.
|
|
1747
|
+
*
|
|
1748
|
+
* Orchestrator decodes this header as **base64-encoded UTF-16 LE bytes**
|
|
1749
|
+
* (see `HttpHeadersProviderExtensions.GetDecoded` + `OrganizationUnitProvider`
|
|
1750
|
+
* in the Orchestrator repo, which call `Encoding.Unicode.GetString(...)`).
|
|
1751
|
+
* URL-encoding is NOT what the server expects — it must be base64-of-UTF-16-LE
|
|
1752
|
+
* bytes.
|
|
1753
|
+
*
|
|
1754
|
+
* @param folderPath - The folder path (e.g. 'Shared/Finance')
|
|
1755
|
+
* @returns Base64 string suitable for the `X-UIPATH-FolderPath-Encoded` header
|
|
1756
|
+
*/
|
|
1757
|
+
function encodeFolderPathHeader(folderPath) {
|
|
1758
|
+
// Force little-endian regardless of host byte order. `Uint16Array` viewed
|
|
1759
|
+
// as `Uint8Array` would use the host's native order — correct on LE hosts
|
|
1760
|
+
// (x86/ARM-LE) but wrong on BE hosts. `DataView.setUint16(..., true)`
|
|
1761
|
+
// pins LE.
|
|
1762
|
+
const buf = new ArrayBuffer(folderPath.length * 2);
|
|
1763
|
+
const view = new DataView(buf);
|
|
1764
|
+
for (let i = 0; i < folderPath.length; i++) {
|
|
1765
|
+
view.setUint16(i * 2, folderPath.charCodeAt(i), true);
|
|
1766
|
+
}
|
|
1767
|
+
const bytes = new Uint8Array(buf);
|
|
1768
|
+
let binary = '';
|
|
1769
|
+
for (let i = 0; i < bytes.byteLength; i++) {
|
|
1770
|
+
binary += String.fromCharCode(bytes[i]);
|
|
1771
|
+
}
|
|
1772
|
+
// btoa is browser-native; Node 16+ also has it as a global
|
|
1773
|
+
return btoa(binary);
|
|
1774
|
+
}
|
|
1775
|
+
|
|
1776
|
+
/**
|
|
1777
|
+
* Resolves folder context into the appropriate Orchestrator folder headers.
|
|
1778
|
+
*
|
|
1779
|
+
* Centralized so all folder-scoped methods (e.g. `assets.getByName`,
|
|
1780
|
+
* `processes.getByName`, future Queues/Buckets/Jobs) share one implementation.
|
|
1781
|
+
*
|
|
1782
|
+
* Each input field maps directly to its header — no auto-detection or type
|
|
1783
|
+
* coercion. When multiple fields are supplied, all corresponding headers
|
|
1784
|
+
* are forwarded and the server resolves precedence.
|
|
1785
|
+
*
|
|
1786
|
+
* Routing:
|
|
1787
|
+
* - `folderId` → `X-UIPATH-OrganizationUnitId`
|
|
1788
|
+
* - `folderKey` → `X-UIPATH-FolderKey`
|
|
1789
|
+
* - `folderPath` → `X-UIPATH-FolderPath-Encoded`
|
|
1790
|
+
* - none set + `fallbackFolderKey` → fallback used as `X-UIPATH-FolderKey`
|
|
1791
|
+
* - none set + no fallback → `ValidationError`
|
|
1792
|
+
*
|
|
1793
|
+
* @throws ValidationError when no folder context can be resolved.
|
|
1794
|
+
*/
|
|
1795
|
+
function resolveFolderHeaders(input) {
|
|
1796
|
+
const { folderId, folderKey, folderPath, resourceType, fallbackFolderKey } = input;
|
|
1797
|
+
const trimmedKey = folderKey?.trim();
|
|
1798
|
+
const trimmedPath = folderPath?.trim();
|
|
1799
|
+
const headers = {};
|
|
1800
|
+
if (folderId !== undefined) {
|
|
1801
|
+
headers[FOLDER_ID] = folderId;
|
|
1802
|
+
}
|
|
1803
|
+
if (trimmedKey) {
|
|
1804
|
+
headers[FOLDER_KEY] = trimmedKey;
|
|
1805
|
+
}
|
|
1806
|
+
if (trimmedPath) {
|
|
1807
|
+
headers[FOLDER_PATH_ENCODED] = encodeFolderPathHeader(trimmedPath);
|
|
1808
|
+
}
|
|
1809
|
+
// No explicit folder context → meta-tag fallback or error.
|
|
1810
|
+
if (Object.keys(headers).length === 0) {
|
|
1811
|
+
if (!fallbackFolderKey) {
|
|
1812
|
+
throw new ValidationError({
|
|
1813
|
+
message: `${resourceType} requires folder context: pass \`folderId\`, \`folderKey\`, or \`folderPath\`, or initialize the SDK with a folder context.`,
|
|
1814
|
+
});
|
|
1815
|
+
}
|
|
1816
|
+
headers[FOLDER_KEY] = fallbackFolderKey;
|
|
1817
|
+
}
|
|
1818
|
+
return createHeaders(headers);
|
|
1819
|
+
}
|
|
1820
|
+
|
|
1821
|
+
/**
|
|
1822
|
+
* Matches single-quote characters in OData string literals — escaped to `''`
|
|
1823
|
+
* inside the `$filter=Name eq '…'` clause built by `getByNameLookup`.
|
|
1824
|
+
*/
|
|
1825
|
+
const SINGLE_QUOTE_RE = /'/g;
|
|
1826
|
+
/**
|
|
1827
|
+
* Base service for services that need folder-specific functionality.
|
|
1828
|
+
*
|
|
1829
|
+
* Extends BaseService with additional methods for working with folder-scoped resources
|
|
1830
|
+
* in UiPath Orchestrator. Services that work with folders (Assets, Queues) extend this class.
|
|
1831
|
+
*
|
|
1832
|
+
* @remarks
|
|
1833
|
+
* This class provides helper methods for making folder-scoped API calls, handling folder IDs
|
|
1834
|
+
* in request headers, and managing cross-folder queries.
|
|
1835
|
+
*/
|
|
1836
|
+
class FolderScopedService extends BaseService {
|
|
1837
|
+
/**
|
|
1838
|
+
* Gets resources in a folder with optional query parameters
|
|
1839
|
+
*
|
|
1840
|
+
* @param endpoint - API endpoint to call
|
|
1841
|
+
* @param folderId - required folder ID
|
|
1842
|
+
* @param options - Query options
|
|
1843
|
+
* @param transformFn - Optional function to transform the response data
|
|
1844
|
+
* @returns Promise resolving to an array of resources
|
|
1845
|
+
*/
|
|
1846
|
+
async _getByFolder(endpoint, folderId, options = {}, transformFn) {
|
|
1847
|
+
const headers = createHeaders({ [FOLDER_ID]: folderId });
|
|
1848
|
+
const keysToPrefix = Object.keys(options);
|
|
1849
|
+
const apiOptions = addPrefixToKeys(options, ODATA_PREFIX, keysToPrefix);
|
|
1850
|
+
const response = await this.get(endpoint, {
|
|
1851
|
+
params: apiOptions,
|
|
1852
|
+
headers
|
|
1853
|
+
});
|
|
1854
|
+
if (transformFn) {
|
|
1855
|
+
return response.data?.value.map(transformFn);
|
|
1856
|
+
}
|
|
1857
|
+
return response.data?.value;
|
|
1858
|
+
}
|
|
1859
|
+
/**
|
|
1860
|
+
* Look up a single resource by name on a folder-scoped OData collection.
|
|
1861
|
+
*
|
|
1862
|
+
* Shared by `getByName` implementations across services (Assets, Processes, etc).
|
|
1863
|
+
* Handles:
|
|
1864
|
+
* - Name validation via `validateName`
|
|
1865
|
+
* - Folder header resolution via `resolveFolderHeaders` (folderId → ID/key
|
|
1866
|
+
* header by type, folderPath → encoded path header, falls back to
|
|
1867
|
+
* init-time `config.folderKey` from the `uipath:folder-key` meta tag)
|
|
1868
|
+
* - OData `$filter=Name eq '…'` with single-quote escaping + `$top=1`
|
|
1869
|
+
* - Empty-result → `NotFoundError` with folder context in the message
|
|
1870
|
+
*
|
|
1871
|
+
* The transform step is caller-provided because each resource has its own
|
|
1872
|
+
* PascalCase → camelCase field mapping.
|
|
1873
|
+
*
|
|
1874
|
+
* @param resourceType - Resource label used in validation + error messages (e.g. 'Asset', 'Process')
|
|
1875
|
+
* @param endpoint - Folder-scoped OData collection endpoint
|
|
1876
|
+
* @param name - Resource name to search for
|
|
1877
|
+
* @param options - Folder scoping (`folderId` / `folderKey` / `folderPath`) + OData query options (`expand`, `select`)
|
|
1878
|
+
* @param transform - Maps a raw OData item to the typed response (e.g. PascalCase → camelCase via field map)
|
|
1879
|
+
* @throws ValidationError when inputs are malformed; NotFoundError when no match
|
|
1880
|
+
*/
|
|
1881
|
+
async getByNameLookup(resourceType, endpoint, name, options, transform) {
|
|
1882
|
+
const validatedName = validateName(resourceType, name);
|
|
1883
|
+
const { folderId, folderKey, folderPath, ...queryOptions } = options;
|
|
1884
|
+
const headers = resolveFolderHeaders({
|
|
1885
|
+
folderId,
|
|
1886
|
+
folderKey,
|
|
1887
|
+
folderPath,
|
|
1888
|
+
resourceType: `${resourceType}.getByName`,
|
|
1889
|
+
fallbackFolderKey: this.config.folderKey,
|
|
1890
|
+
});
|
|
1891
|
+
const apiOptions = {
|
|
1892
|
+
...addPrefixToKeys(queryOptions, ODATA_PREFIX, Object.keys(queryOptions)),
|
|
1893
|
+
'$filter': `Name eq '${validatedName.replace(SINGLE_QUOTE_RE, "''")}'`,
|
|
1894
|
+
'$top': '1',
|
|
1895
|
+
};
|
|
1896
|
+
const response = await this.get(endpoint, {
|
|
1897
|
+
headers,
|
|
1898
|
+
params: apiOptions,
|
|
1899
|
+
});
|
|
1900
|
+
const items = response.data?.value;
|
|
1901
|
+
if (!items?.length) {
|
|
1902
|
+
const folderHint = describeFolderForError(folderId, folderKey, folderPath);
|
|
1903
|
+
throw new NotFoundError({
|
|
1904
|
+
message: `${resourceType} '${validatedName}' not found${folderHint}.`,
|
|
1905
|
+
});
|
|
1906
|
+
}
|
|
1907
|
+
return transform(items[0]);
|
|
1908
|
+
}
|
|
1909
|
+
}
|
|
1910
|
+
/** Renders the supplied folder for a NotFoundError message. */
|
|
1911
|
+
function describeFolderForError(folderId, folderKey, folderPath) {
|
|
1912
|
+
const path = folderPath?.trim();
|
|
1913
|
+
if (path)
|
|
1914
|
+
return ` in folder '${path}'`;
|
|
1915
|
+
const key = folderKey?.trim();
|
|
1916
|
+
if (key)
|
|
1917
|
+
return ` in folder (key: ${key})`;
|
|
1918
|
+
if (typeof folderId === 'number')
|
|
1919
|
+
return ` in folder (id: ${folderId})`;
|
|
1920
|
+
return '';
|
|
1921
|
+
}
|
|
1922
|
+
|
|
1683
1923
|
/**
|
|
1684
1924
|
* Maps fields for Process entities to ensure consistent naming
|
|
1685
1925
|
*/
|
|
@@ -1720,7 +1960,7 @@ const PROCESS_ENDPOINTS = {
|
|
|
1720
1960
|
// Connection string placeholder that will be replaced during build
|
|
1721
1961
|
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";
|
|
1722
1962
|
// SDK Version placeholder
|
|
1723
|
-
const SDK_VERSION = "1.3.
|
|
1963
|
+
const SDK_VERSION = "1.3.8";
|
|
1724
1964
|
const VERSION = "Version";
|
|
1725
1965
|
const SERVICE = "Service";
|
|
1726
1966
|
const CLOUD_ORGANIZATION_NAME = "CloudOrganizationName";
|
|
@@ -1991,7 +2231,7 @@ function track(nameOrOptions, options) {
|
|
|
1991
2231
|
/**
|
|
1992
2232
|
* Service for interacting with UiPath Orchestrator Processes API
|
|
1993
2233
|
*/
|
|
1994
|
-
class ProcessService extends
|
|
2234
|
+
class ProcessService extends FolderScopedService {
|
|
1995
2235
|
/**
|
|
1996
2236
|
* Gets all processes across folders with optional filtering and folder scoping
|
|
1997
2237
|
*
|
|
@@ -2128,6 +2368,35 @@ class ProcessService extends BaseService {
|
|
|
2128
2368
|
const transformedProcess = transformData(pascalToCamelCaseKeys(response.data), ProcessMap);
|
|
2129
2369
|
return transformedProcess;
|
|
2130
2370
|
}
|
|
2371
|
+
/**
|
|
2372
|
+
* Retrieves a single process by name.
|
|
2373
|
+
*
|
|
2374
|
+
* @param name - Process name to search for
|
|
2375
|
+
* @param options - Folder scoping (`folderId` / `folderKey` / `folderPath`) and optional query parameters (`expand`, `select`)
|
|
2376
|
+
* @returns Promise resolving to a single process
|
|
2377
|
+
* {@link ProcessGetResponse}
|
|
2378
|
+
* @example
|
|
2379
|
+
* ```typescript
|
|
2380
|
+
* import { Processes } from '@uipath/uipath-typescript/processes';
|
|
2381
|
+
*
|
|
2382
|
+
* const processes = new Processes(sdk);
|
|
2383
|
+
*
|
|
2384
|
+
* // By folder ID
|
|
2385
|
+
* await processes.getByName('MyProcess', { folderId: 123 });
|
|
2386
|
+
*
|
|
2387
|
+
* // By folder key (GUID)
|
|
2388
|
+
* await processes.getByName('MyProcess', { folderKey: '5f6dadf1-3677-49dc-8aca-c2999dd4b3ba' });
|
|
2389
|
+
*
|
|
2390
|
+
* // By folder path
|
|
2391
|
+
* await processes.getByName('MyProcess', { folderPath: 'Shared/Finance' });
|
|
2392
|
+
*
|
|
2393
|
+
* // With expand
|
|
2394
|
+
* await processes.getByName('MyProcess', { folderPath: 'Shared/Finance', expand: 'entryPoints' });
|
|
2395
|
+
* ```
|
|
2396
|
+
*/
|
|
2397
|
+
async getByName(name, options = {}) {
|
|
2398
|
+
return this.getByNameLookup('Process', PROCESS_ENDPOINTS.GET_ALL, name, options, (raw) => transformData(pascalToCamelCaseKeys(raw), ProcessMap));
|
|
2399
|
+
}
|
|
2131
2400
|
}
|
|
2132
2401
|
__decorate([
|
|
2133
2402
|
track('Processes.GetAll')
|
|
@@ -2138,6 +2407,9 @@ __decorate([
|
|
|
2138
2407
|
__decorate([
|
|
2139
2408
|
track('Processes.GetById')
|
|
2140
2409
|
], ProcessService.prototype, "getById", null);
|
|
2410
|
+
__decorate([
|
|
2411
|
+
track('Processes.GetByName')
|
|
2412
|
+
], ProcessService.prototype, "getByName", null);
|
|
2141
2413
|
|
|
2142
2414
|
/**
|
|
2143
2415
|
* Enum for package types
|
package/dist/queues/index.cjs
CHANGED
|
@@ -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
|
|
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 (
|
|
1546
|
-
|
|
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
|
|
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
|
/**
|
|
@@ -1686,7 +1891,7 @@ const QueueMap = {
|
|
|
1686
1891
|
// Connection string placeholder that will be replaced during build
|
|
1687
1892
|
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";
|
|
1688
1893
|
// SDK Version placeholder
|
|
1689
|
-
const SDK_VERSION = "1.3.
|
|
1894
|
+
const SDK_VERSION = "1.3.8";
|
|
1690
1895
|
const VERSION = "Version";
|
|
1691
1896
|
const SERVICE = "Service";
|
|
1692
1897
|
const CLOUD_ORGANIZATION_NAME = "CloudOrganizationName";
|