@uipath/uipath-typescript 1.3.6 → 1.3.7
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 +204 -2
- package/dist/assets/index.d.ts +112 -13
- package/dist/assets/index.mjs +204 -2
- package/dist/attachments/index.cjs +3 -2
- package/dist/attachments/index.d.ts +7 -0
- package/dist/attachments/index.mjs +3 -2
- package/dist/buckets/index.cjs +172 -2
- package/dist/buckets/index.d.ts +56 -12
- package/dist/buckets/index.mjs +172 -2
- package/dist/cases/index.cjs +3 -2
- package/dist/cases/index.d.ts +7 -0
- package/dist/cases/index.mjs +3 -2
- package/dist/conversational-agent/index.cjs +196 -81
- package/dist/conversational-agent/index.d.ts +326 -80
- package/dist/conversational-agent/index.mjs +195 -80
- 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 +35 -6
- package/dist/entities/index.d.ts +101 -11
- package/dist/entities/index.mjs +36 -7
- package/dist/feedback/index.cjs +3 -2
- package/dist/feedback/index.d.ts +7 -0
- package/dist/feedback/index.mjs +3 -2
- package/dist/index.cjs +286 -13
- package/dist/index.d.ts +475 -32
- package/dist/index.mjs +287 -14
- package/dist/index.umd.js +286 -13
- package/dist/jobs/index.cjs +172 -2
- package/dist/jobs/index.d.ts +67 -23
- package/dist/jobs/index.mjs +172 -2
- package/dist/maestro-processes/index.cjs +3 -2
- package/dist/maestro-processes/index.d.ts +7 -0
- package/dist/maestro-processes/index.mjs +3 -2
- package/dist/processes/index.cjs +240 -3
- package/dist/processes/index.d.ts +124 -2
- package/dist/processes/index.mjs +240 -3
- package/dist/queues/index.cjs +172 -2
- package/dist/queues/index.d.ts +56 -12
- package/dist/queues/index.mjs +172 -2
- package/dist/tasks/index.cjs +3 -2
- package/dist/tasks/index.d.ts +7 -0
- package/dist/tasks/index.mjs +3 -2
- package/package.json +1 -1
|
@@ -476,7 +476,7 @@ const BUCKET_TOKEN_PARAMS = {
|
|
|
476
476
|
// Connection string placeholder that will be replaced during build
|
|
477
477
|
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";
|
|
478
478
|
// SDK Version placeholder
|
|
479
|
-
const SDK_VERSION = "1.3.
|
|
479
|
+
const SDK_VERSION = "1.3.7";
|
|
480
480
|
const VERSION = "Version";
|
|
481
481
|
const SERVICE = "Service";
|
|
482
482
|
const CLOUD_ORGANIZATION_NAME = "CloudOrganizationName";
|
|
@@ -1708,8 +1708,9 @@ class BaseService {
|
|
|
1708
1708
|
constructor(instance, headers) {
|
|
1709
1709
|
// Private field - not visible via Object.keys() or any reflection
|
|
1710
1710
|
_BaseService_apiClient.set(this, void 0);
|
|
1711
|
-
const { config, context, tokenManager } = SDKInternalsRegistry.get(instance);
|
|
1711
|
+
const { config, context, tokenManager, folderKey } = SDKInternalsRegistry.get(instance);
|
|
1712
1712
|
__classPrivateFieldSet(this, _BaseService_apiClient, new ApiClient(config, context, tokenManager, headers ? { headers } : {}), "f");
|
|
1713
|
+
this.config = { folderKey };
|
|
1713
1714
|
}
|
|
1714
1715
|
/**
|
|
1715
1716
|
* Gets a valid authentication token, refreshing if necessary.
|
|
@@ -306,6 +306,13 @@ interface ApiResponse<T> {
|
|
|
306
306
|
*/
|
|
307
307
|
declare class BaseService {
|
|
308
308
|
#private;
|
|
309
|
+
/**
|
|
310
|
+
* SDK configuration (read-only). Available to subclasses so they can
|
|
311
|
+
* fall back to init-time defaults like `folderKey`.
|
|
312
|
+
*/
|
|
313
|
+
protected readonly config: {
|
|
314
|
+
folderKey?: string;
|
|
315
|
+
};
|
|
309
316
|
/**
|
|
310
317
|
* Creates a base service instance with dependency injection.
|
|
311
318
|
*
|
|
@@ -474,7 +474,7 @@ const BUCKET_TOKEN_PARAMS = {
|
|
|
474
474
|
// Connection string placeholder that will be replaced during build
|
|
475
475
|
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";
|
|
476
476
|
// SDK Version placeholder
|
|
477
|
-
const SDK_VERSION = "1.3.
|
|
477
|
+
const SDK_VERSION = "1.3.7";
|
|
478
478
|
const VERSION = "Version";
|
|
479
479
|
const SERVICE = "Service";
|
|
480
480
|
const CLOUD_ORGANIZATION_NAME = "CloudOrganizationName";
|
|
@@ -1706,8 +1706,9 @@ class BaseService {
|
|
|
1706
1706
|
constructor(instance, headers) {
|
|
1707
1707
|
// Private field - not visible via Object.keys() or any reflection
|
|
1708
1708
|
_BaseService_apiClient.set(this, void 0);
|
|
1709
|
-
const { config, context, tokenManager } = SDKInternalsRegistry.get(instance);
|
|
1709
|
+
const { config, context, tokenManager, folderKey } = SDKInternalsRegistry.get(instance);
|
|
1710
1710
|
__classPrivateFieldSet(this, _BaseService_apiClient, new ApiClient(config, context, tokenManager, headers ? { headers } : {}), "f");
|
|
1711
|
+
this.config = { folderKey };
|
|
1711
1712
|
}
|
|
1712
1713
|
/**
|
|
1713
1714
|
* Gets a valid authentication token, refreshing if necessary.
|
package/dist/buckets/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';
|
|
@@ -1464,8 +1466,9 @@ class BaseService {
|
|
|
1464
1466
|
constructor(instance, headers) {
|
|
1465
1467
|
// Private field - not visible via Object.keys() or any reflection
|
|
1466
1468
|
_BaseService_apiClient.set(this, void 0);
|
|
1467
|
-
const { config, context, tokenManager } = SDKInternalsRegistry.get(instance);
|
|
1469
|
+
const { config, context, tokenManager, folderKey } = SDKInternalsRegistry.get(instance);
|
|
1468
1470
|
__classPrivateFieldSet(this, _BaseService_apiClient, new ApiClient(config, context, tokenManager, headers ? { headers } : {}), "f");
|
|
1471
|
+
this.config = { folderKey };
|
|
1469
1472
|
}
|
|
1470
1473
|
/**
|
|
1471
1474
|
* Gets a valid authentication token, refreshing if necessary.
|
|
@@ -1662,6 +1665,111 @@ class BaseService {
|
|
|
1662
1665
|
}
|
|
1663
1666
|
_BaseService_apiClient = new WeakMap();
|
|
1664
1667
|
|
|
1668
|
+
/**
|
|
1669
|
+
* Validates the `name` argument passed to a `getByName(name, ...)` method.
|
|
1670
|
+
* Trims whitespace and rejects empty/whitespace-only names.
|
|
1671
|
+
*
|
|
1672
|
+
* @param resourceType - Resource label used in error messages (e.g. 'Asset', 'Process')
|
|
1673
|
+
* @param name - Resource name to validate
|
|
1674
|
+
* @returns The trimmed name
|
|
1675
|
+
* @throws ValidationError when `name` is missing or empty after trimming
|
|
1676
|
+
*/
|
|
1677
|
+
function validateName(resourceType, name) {
|
|
1678
|
+
if (!name) {
|
|
1679
|
+
throw new ValidationError({
|
|
1680
|
+
message: `${resourceType} name is required and cannot be empty.`,
|
|
1681
|
+
});
|
|
1682
|
+
}
|
|
1683
|
+
const trimmed = name.trim();
|
|
1684
|
+
if (!trimmed) {
|
|
1685
|
+
throw new ValidationError({
|
|
1686
|
+
message: `${resourceType} name is required and cannot be empty.`,
|
|
1687
|
+
});
|
|
1688
|
+
}
|
|
1689
|
+
return trimmed;
|
|
1690
|
+
}
|
|
1691
|
+
|
|
1692
|
+
/**
|
|
1693
|
+
* Encodes a folder path for the `X-UIPATH-FolderPath-Encoded` header.
|
|
1694
|
+
*
|
|
1695
|
+
* Orchestrator decodes this header as **base64-encoded UTF-16 LE bytes**
|
|
1696
|
+
* (see `HttpHeadersProviderExtensions.GetDecoded` + `OrganizationUnitProvider`
|
|
1697
|
+
* in the Orchestrator repo, which call `Encoding.Unicode.GetString(...)`).
|
|
1698
|
+
* URL-encoding is NOT what the server expects — it must be base64-of-UTF-16-LE
|
|
1699
|
+
* bytes.
|
|
1700
|
+
*
|
|
1701
|
+
* @param folderPath - The folder path (e.g. 'Shared/Finance')
|
|
1702
|
+
* @returns Base64 string suitable for the `X-UIPATH-FolderPath-Encoded` header
|
|
1703
|
+
*/
|
|
1704
|
+
function encodeFolderPathHeader(folderPath) {
|
|
1705
|
+
// Force little-endian regardless of host byte order. `Uint16Array` viewed
|
|
1706
|
+
// as `Uint8Array` would use the host's native order — correct on LE hosts
|
|
1707
|
+
// (x86/ARM-LE) but wrong on BE hosts. `DataView.setUint16(..., true)`
|
|
1708
|
+
// pins LE.
|
|
1709
|
+
const buf = new ArrayBuffer(folderPath.length * 2);
|
|
1710
|
+
const view = new DataView(buf);
|
|
1711
|
+
for (let i = 0; i < folderPath.length; i++) {
|
|
1712
|
+
view.setUint16(i * 2, folderPath.charCodeAt(i), true);
|
|
1713
|
+
}
|
|
1714
|
+
const bytes = new Uint8Array(buf);
|
|
1715
|
+
let binary = '';
|
|
1716
|
+
for (let i = 0; i < bytes.byteLength; i++) {
|
|
1717
|
+
binary += String.fromCharCode(bytes[i]);
|
|
1718
|
+
}
|
|
1719
|
+
// btoa is browser-native; Node 16+ also has it as a global
|
|
1720
|
+
return btoa(binary);
|
|
1721
|
+
}
|
|
1722
|
+
|
|
1723
|
+
/**
|
|
1724
|
+
* Resolves folder context into the appropriate Orchestrator folder headers.
|
|
1725
|
+
*
|
|
1726
|
+
* Centralized so all folder-scoped methods (e.g. `assets.getByName`,
|
|
1727
|
+
* `processes.getByName`, future Queues/Buckets/Jobs) share one implementation.
|
|
1728
|
+
*
|
|
1729
|
+
* Each input field maps directly to its header — no auto-detection or type
|
|
1730
|
+
* coercion. When multiple fields are supplied, all corresponding headers
|
|
1731
|
+
* are forwarded and the server resolves precedence.
|
|
1732
|
+
*
|
|
1733
|
+
* Routing:
|
|
1734
|
+
* - `folderId` → `X-UIPATH-OrganizationUnitId`
|
|
1735
|
+
* - `folderKey` → `X-UIPATH-FolderKey`
|
|
1736
|
+
* - `folderPath` → `X-UIPATH-FolderPath-Encoded`
|
|
1737
|
+
* - none set + `fallbackFolderKey` → fallback used as `X-UIPATH-FolderKey`
|
|
1738
|
+
* - none set + no fallback → `ValidationError`
|
|
1739
|
+
*
|
|
1740
|
+
* @throws ValidationError when no folder context can be resolved.
|
|
1741
|
+
*/
|
|
1742
|
+
function resolveFolderHeaders(input) {
|
|
1743
|
+
const { folderId, folderKey, folderPath, resourceType, fallbackFolderKey } = input;
|
|
1744
|
+
const trimmedKey = folderKey?.trim();
|
|
1745
|
+
const trimmedPath = folderPath?.trim();
|
|
1746
|
+
const headers = {};
|
|
1747
|
+
if (folderId !== undefined) {
|
|
1748
|
+
headers[FOLDER_ID] = folderId;
|
|
1749
|
+
}
|
|
1750
|
+
if (trimmedKey) {
|
|
1751
|
+
headers[FOLDER_KEY] = trimmedKey;
|
|
1752
|
+
}
|
|
1753
|
+
if (trimmedPath) {
|
|
1754
|
+
headers[FOLDER_PATH_ENCODED] = encodeFolderPathHeader(trimmedPath);
|
|
1755
|
+
}
|
|
1756
|
+
// No explicit folder context → meta-tag fallback or error.
|
|
1757
|
+
if (Object.keys(headers).length === 0) {
|
|
1758
|
+
if (!fallbackFolderKey) {
|
|
1759
|
+
throw new ValidationError({
|
|
1760
|
+
message: `${resourceType} requires folder context: pass \`folderId\`, \`folderKey\`, or \`folderPath\`, or initialize the SDK with a folder context.`,
|
|
1761
|
+
});
|
|
1762
|
+
}
|
|
1763
|
+
headers[FOLDER_KEY] = fallbackFolderKey;
|
|
1764
|
+
}
|
|
1765
|
+
return createHeaders(headers);
|
|
1766
|
+
}
|
|
1767
|
+
|
|
1768
|
+
/**
|
|
1769
|
+
* Matches single-quote characters in OData string literals — escaped to `''`
|
|
1770
|
+
* inside the `$filter=Name eq '…'` clause built by `getByNameLookup`.
|
|
1771
|
+
*/
|
|
1772
|
+
const SINGLE_QUOTE_RE = /'/g;
|
|
1665
1773
|
/**
|
|
1666
1774
|
* Base service for services that need folder-specific functionality.
|
|
1667
1775
|
*
|
|
@@ -1695,6 +1803,68 @@ class FolderScopedService extends BaseService {
|
|
|
1695
1803
|
}
|
|
1696
1804
|
return response.data?.value;
|
|
1697
1805
|
}
|
|
1806
|
+
/**
|
|
1807
|
+
* Look up a single resource by name on a folder-scoped OData collection.
|
|
1808
|
+
*
|
|
1809
|
+
* Shared by `getByName` implementations across services (Assets, Processes, etc).
|
|
1810
|
+
* Handles:
|
|
1811
|
+
* - Name validation via `validateName`
|
|
1812
|
+
* - Folder header resolution via `resolveFolderHeaders` (folderId → ID/key
|
|
1813
|
+
* header by type, folderPath → encoded path header, falls back to
|
|
1814
|
+
* init-time `config.folderKey` from the `uipath:folder-key` meta tag)
|
|
1815
|
+
* - OData `$filter=Name eq '…'` with single-quote escaping + `$top=1`
|
|
1816
|
+
* - Empty-result → `NotFoundError` with folder context in the message
|
|
1817
|
+
*
|
|
1818
|
+
* The transform step is caller-provided because each resource has its own
|
|
1819
|
+
* PascalCase → camelCase field mapping.
|
|
1820
|
+
*
|
|
1821
|
+
* @param resourceType - Resource label used in validation + error messages (e.g. 'Asset', 'Process')
|
|
1822
|
+
* @param endpoint - Folder-scoped OData collection endpoint
|
|
1823
|
+
* @param name - Resource name to search for
|
|
1824
|
+
* @param options - Folder scoping (`folderId` / `folderKey` / `folderPath`) + OData query options (`expand`, `select`)
|
|
1825
|
+
* @param transform - Maps a raw OData item to the typed response (e.g. PascalCase → camelCase via field map)
|
|
1826
|
+
* @throws ValidationError when inputs are malformed; NotFoundError when no match
|
|
1827
|
+
*/
|
|
1828
|
+
async getByNameLookup(resourceType, endpoint, name, options, transform) {
|
|
1829
|
+
const validatedName = validateName(resourceType, name);
|
|
1830
|
+
const { folderId, folderKey, folderPath, ...queryOptions } = options;
|
|
1831
|
+
const headers = resolveFolderHeaders({
|
|
1832
|
+
folderId,
|
|
1833
|
+
folderKey,
|
|
1834
|
+
folderPath,
|
|
1835
|
+
resourceType: `${resourceType}.getByName`,
|
|
1836
|
+
fallbackFolderKey: this.config.folderKey,
|
|
1837
|
+
});
|
|
1838
|
+
const apiOptions = {
|
|
1839
|
+
...addPrefixToKeys(queryOptions, ODATA_PREFIX, Object.keys(queryOptions)),
|
|
1840
|
+
'$filter': `Name eq '${validatedName.replace(SINGLE_QUOTE_RE, "''")}'`,
|
|
1841
|
+
'$top': '1',
|
|
1842
|
+
};
|
|
1843
|
+
const response = await this.get(endpoint, {
|
|
1844
|
+
headers,
|
|
1845
|
+
params: apiOptions,
|
|
1846
|
+
});
|
|
1847
|
+
const items = response.data?.value;
|
|
1848
|
+
if (!items?.length) {
|
|
1849
|
+
const folderHint = describeFolderForError(folderId, folderKey, folderPath);
|
|
1850
|
+
throw new NotFoundError({
|
|
1851
|
+
message: `${resourceType} '${validatedName}' not found${folderHint}.`,
|
|
1852
|
+
});
|
|
1853
|
+
}
|
|
1854
|
+
return transform(items[0]);
|
|
1855
|
+
}
|
|
1856
|
+
}
|
|
1857
|
+
/** Renders the supplied folder for a NotFoundError message. */
|
|
1858
|
+
function describeFolderForError(folderId, folderKey, folderPath) {
|
|
1859
|
+
const path = folderPath?.trim();
|
|
1860
|
+
if (path)
|
|
1861
|
+
return ` in folder '${path}'`;
|
|
1862
|
+
const key = folderKey?.trim();
|
|
1863
|
+
if (key)
|
|
1864
|
+
return ` in folder (key: ${key})`;
|
|
1865
|
+
if (typeof folderId === 'number')
|
|
1866
|
+
return ` in folder (id: ${folderId})`;
|
|
1867
|
+
return '';
|
|
1698
1868
|
}
|
|
1699
1869
|
|
|
1700
1870
|
/**
|
|
@@ -1732,7 +1902,7 @@ const BucketMap = {
|
|
|
1732
1902
|
// Connection string placeholder that will be replaced during build
|
|
1733
1903
|
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";
|
|
1734
1904
|
// SDK Version placeholder
|
|
1735
|
-
const SDK_VERSION = "1.3.
|
|
1905
|
+
const SDK_VERSION = "1.3.7";
|
|
1736
1906
|
const VERSION = "Version";
|
|
1737
1907
|
const SERVICE = "Service";
|
|
1738
1908
|
const CLOUD_ORGANIZATION_NAME = "CloudOrganizationName";
|
package/dist/buckets/index.d.ts
CHANGED
|
@@ -218,6 +218,13 @@ interface ApiResponse<T> {
|
|
|
218
218
|
*/
|
|
219
219
|
declare class BaseService {
|
|
220
220
|
#private;
|
|
221
|
+
/**
|
|
222
|
+
* SDK configuration (read-only). Available to subclasses so they can
|
|
223
|
+
* fall back to init-time defaults like `folderKey`.
|
|
224
|
+
*/
|
|
225
|
+
protected readonly config: {
|
|
226
|
+
folderKey?: string;
|
|
227
|
+
};
|
|
221
228
|
/**
|
|
222
229
|
* Creates a base service instance with dependency injection.
|
|
223
230
|
*
|
|
@@ -291,6 +298,32 @@ declare class BaseService {
|
|
|
291
298
|
private determineHasMorePages;
|
|
292
299
|
}
|
|
293
300
|
|
|
301
|
+
interface BaseOptions {
|
|
302
|
+
expand?: string;
|
|
303
|
+
select?: string;
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Common request options interface used across services for querying data
|
|
307
|
+
*/
|
|
308
|
+
interface RequestOptions extends BaseOptions {
|
|
309
|
+
filter?: string;
|
|
310
|
+
orderby?: string;
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Options that scope a name-based lookup (e.g. `getByName`) to a folder.
|
|
314
|
+
* Provide one of `folderId`, `folderKey`, or `folderPath`. When more than
|
|
315
|
+
* one is supplied, all are forwarded; the server applies precedence
|
|
316
|
+
* `folderPath` > `folderKey` > `folderId`.
|
|
317
|
+
*/
|
|
318
|
+
interface FolderScopedOptions extends BaseOptions {
|
|
319
|
+
/** Numeric folder ID. */
|
|
320
|
+
folderId?: number;
|
|
321
|
+
/** Folder key (GUID-formatted string). */
|
|
322
|
+
folderKey?: string;
|
|
323
|
+
/** Slash-delimited folder path, e.g. `'Shared/Finance'`. */
|
|
324
|
+
folderPath?: string;
|
|
325
|
+
}
|
|
326
|
+
|
|
294
327
|
/**
|
|
295
328
|
* Base service for services that need folder-specific functionality.
|
|
296
329
|
*
|
|
@@ -312,18 +345,29 @@ declare class FolderScopedService extends BaseService {
|
|
|
312
345
|
* @returns Promise resolving to an array of resources
|
|
313
346
|
*/
|
|
314
347
|
protected _getByFolder<T, R = T>(endpoint: string, folderId: number, options?: Record<string, any>, transformFn?: (item: T) => R): Promise<R[]>;
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
348
|
+
/**
|
|
349
|
+
* Look up a single resource by name on a folder-scoped OData collection.
|
|
350
|
+
*
|
|
351
|
+
* Shared by `getByName` implementations across services (Assets, Processes, etc).
|
|
352
|
+
* Handles:
|
|
353
|
+
* - Name validation via `validateName`
|
|
354
|
+
* - Folder header resolution via `resolveFolderHeaders` (folderId → ID/key
|
|
355
|
+
* header by type, folderPath → encoded path header, falls back to
|
|
356
|
+
* init-time `config.folderKey` from the `uipath:folder-key` meta tag)
|
|
357
|
+
* - OData `$filter=Name eq '…'` with single-quote escaping + `$top=1`
|
|
358
|
+
* - Empty-result → `NotFoundError` with folder context in the message
|
|
359
|
+
*
|
|
360
|
+
* The transform step is caller-provided because each resource has its own
|
|
361
|
+
* PascalCase → camelCase field mapping.
|
|
362
|
+
*
|
|
363
|
+
* @param resourceType - Resource label used in validation + error messages (e.g. 'Asset', 'Process')
|
|
364
|
+
* @param endpoint - Folder-scoped OData collection endpoint
|
|
365
|
+
* @param name - Resource name to search for
|
|
366
|
+
* @param options - Folder scoping (`folderId` / `folderKey` / `folderPath`) + OData query options (`expand`, `select`)
|
|
367
|
+
* @param transform - Maps a raw OData item to the typed response (e.g. PascalCase → camelCase via field map)
|
|
368
|
+
* @throws ValidationError when inputs are malformed; NotFoundError when no match
|
|
369
|
+
*/
|
|
370
|
+
protected getByNameLookup<TRaw extends object, T>(resourceType: string, endpoint: string, name: string, options: FolderScopedOptions, transform: (raw: TRaw) => T): Promise<T>;
|
|
327
371
|
}
|
|
328
372
|
|
|
329
373
|
declare enum BucketOptions {
|
package/dist/buckets/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';
|
|
@@ -1462,8 +1464,9 @@ class BaseService {
|
|
|
1462
1464
|
constructor(instance, headers) {
|
|
1463
1465
|
// Private field - not visible via Object.keys() or any reflection
|
|
1464
1466
|
_BaseService_apiClient.set(this, void 0);
|
|
1465
|
-
const { config, context, tokenManager } = SDKInternalsRegistry.get(instance);
|
|
1467
|
+
const { config, context, tokenManager, folderKey } = SDKInternalsRegistry.get(instance);
|
|
1466
1468
|
__classPrivateFieldSet(this, _BaseService_apiClient, new ApiClient(config, context, tokenManager, headers ? { headers } : {}), "f");
|
|
1469
|
+
this.config = { folderKey };
|
|
1467
1470
|
}
|
|
1468
1471
|
/**
|
|
1469
1472
|
* Gets a valid authentication token, refreshing if necessary.
|
|
@@ -1660,6 +1663,111 @@ class BaseService {
|
|
|
1660
1663
|
}
|
|
1661
1664
|
_BaseService_apiClient = new WeakMap();
|
|
1662
1665
|
|
|
1666
|
+
/**
|
|
1667
|
+
* Validates the `name` argument passed to a `getByName(name, ...)` method.
|
|
1668
|
+
* Trims whitespace and rejects empty/whitespace-only names.
|
|
1669
|
+
*
|
|
1670
|
+
* @param resourceType - Resource label used in error messages (e.g. 'Asset', 'Process')
|
|
1671
|
+
* @param name - Resource name to validate
|
|
1672
|
+
* @returns The trimmed name
|
|
1673
|
+
* @throws ValidationError when `name` is missing or empty after trimming
|
|
1674
|
+
*/
|
|
1675
|
+
function validateName(resourceType, name) {
|
|
1676
|
+
if (!name) {
|
|
1677
|
+
throw new ValidationError({
|
|
1678
|
+
message: `${resourceType} name is required and cannot be empty.`,
|
|
1679
|
+
});
|
|
1680
|
+
}
|
|
1681
|
+
const trimmed = name.trim();
|
|
1682
|
+
if (!trimmed) {
|
|
1683
|
+
throw new ValidationError({
|
|
1684
|
+
message: `${resourceType} name is required and cannot be empty.`,
|
|
1685
|
+
});
|
|
1686
|
+
}
|
|
1687
|
+
return trimmed;
|
|
1688
|
+
}
|
|
1689
|
+
|
|
1690
|
+
/**
|
|
1691
|
+
* Encodes a folder path for the `X-UIPATH-FolderPath-Encoded` header.
|
|
1692
|
+
*
|
|
1693
|
+
* Orchestrator decodes this header as **base64-encoded UTF-16 LE bytes**
|
|
1694
|
+
* (see `HttpHeadersProviderExtensions.GetDecoded` + `OrganizationUnitProvider`
|
|
1695
|
+
* in the Orchestrator repo, which call `Encoding.Unicode.GetString(...)`).
|
|
1696
|
+
* URL-encoding is NOT what the server expects — it must be base64-of-UTF-16-LE
|
|
1697
|
+
* bytes.
|
|
1698
|
+
*
|
|
1699
|
+
* @param folderPath - The folder path (e.g. 'Shared/Finance')
|
|
1700
|
+
* @returns Base64 string suitable for the `X-UIPATH-FolderPath-Encoded` header
|
|
1701
|
+
*/
|
|
1702
|
+
function encodeFolderPathHeader(folderPath) {
|
|
1703
|
+
// Force little-endian regardless of host byte order. `Uint16Array` viewed
|
|
1704
|
+
// as `Uint8Array` would use the host's native order — correct on LE hosts
|
|
1705
|
+
// (x86/ARM-LE) but wrong on BE hosts. `DataView.setUint16(..., true)`
|
|
1706
|
+
// pins LE.
|
|
1707
|
+
const buf = new ArrayBuffer(folderPath.length * 2);
|
|
1708
|
+
const view = new DataView(buf);
|
|
1709
|
+
for (let i = 0; i < folderPath.length; i++) {
|
|
1710
|
+
view.setUint16(i * 2, folderPath.charCodeAt(i), true);
|
|
1711
|
+
}
|
|
1712
|
+
const bytes = new Uint8Array(buf);
|
|
1713
|
+
let binary = '';
|
|
1714
|
+
for (let i = 0; i < bytes.byteLength; i++) {
|
|
1715
|
+
binary += String.fromCharCode(bytes[i]);
|
|
1716
|
+
}
|
|
1717
|
+
// btoa is browser-native; Node 16+ also has it as a global
|
|
1718
|
+
return btoa(binary);
|
|
1719
|
+
}
|
|
1720
|
+
|
|
1721
|
+
/**
|
|
1722
|
+
* Resolves folder context into the appropriate Orchestrator folder headers.
|
|
1723
|
+
*
|
|
1724
|
+
* Centralized so all folder-scoped methods (e.g. `assets.getByName`,
|
|
1725
|
+
* `processes.getByName`, future Queues/Buckets/Jobs) share one implementation.
|
|
1726
|
+
*
|
|
1727
|
+
* Each input field maps directly to its header — no auto-detection or type
|
|
1728
|
+
* coercion. When multiple fields are supplied, all corresponding headers
|
|
1729
|
+
* are forwarded and the server resolves precedence.
|
|
1730
|
+
*
|
|
1731
|
+
* Routing:
|
|
1732
|
+
* - `folderId` → `X-UIPATH-OrganizationUnitId`
|
|
1733
|
+
* - `folderKey` → `X-UIPATH-FolderKey`
|
|
1734
|
+
* - `folderPath` → `X-UIPATH-FolderPath-Encoded`
|
|
1735
|
+
* - none set + `fallbackFolderKey` → fallback used as `X-UIPATH-FolderKey`
|
|
1736
|
+
* - none set + no fallback → `ValidationError`
|
|
1737
|
+
*
|
|
1738
|
+
* @throws ValidationError when no folder context can be resolved.
|
|
1739
|
+
*/
|
|
1740
|
+
function resolveFolderHeaders(input) {
|
|
1741
|
+
const { folderId, folderKey, folderPath, resourceType, fallbackFolderKey } = input;
|
|
1742
|
+
const trimmedKey = folderKey?.trim();
|
|
1743
|
+
const trimmedPath = folderPath?.trim();
|
|
1744
|
+
const headers = {};
|
|
1745
|
+
if (folderId !== undefined) {
|
|
1746
|
+
headers[FOLDER_ID] = folderId;
|
|
1747
|
+
}
|
|
1748
|
+
if (trimmedKey) {
|
|
1749
|
+
headers[FOLDER_KEY] = trimmedKey;
|
|
1750
|
+
}
|
|
1751
|
+
if (trimmedPath) {
|
|
1752
|
+
headers[FOLDER_PATH_ENCODED] = encodeFolderPathHeader(trimmedPath);
|
|
1753
|
+
}
|
|
1754
|
+
// No explicit folder context → meta-tag fallback or error.
|
|
1755
|
+
if (Object.keys(headers).length === 0) {
|
|
1756
|
+
if (!fallbackFolderKey) {
|
|
1757
|
+
throw new ValidationError({
|
|
1758
|
+
message: `${resourceType} requires folder context: pass \`folderId\`, \`folderKey\`, or \`folderPath\`, or initialize the SDK with a folder context.`,
|
|
1759
|
+
});
|
|
1760
|
+
}
|
|
1761
|
+
headers[FOLDER_KEY] = fallbackFolderKey;
|
|
1762
|
+
}
|
|
1763
|
+
return createHeaders(headers);
|
|
1764
|
+
}
|
|
1765
|
+
|
|
1766
|
+
/**
|
|
1767
|
+
* Matches single-quote characters in OData string literals — escaped to `''`
|
|
1768
|
+
* inside the `$filter=Name eq '…'` clause built by `getByNameLookup`.
|
|
1769
|
+
*/
|
|
1770
|
+
const SINGLE_QUOTE_RE = /'/g;
|
|
1663
1771
|
/**
|
|
1664
1772
|
* Base service for services that need folder-specific functionality.
|
|
1665
1773
|
*
|
|
@@ -1693,6 +1801,68 @@ class FolderScopedService extends BaseService {
|
|
|
1693
1801
|
}
|
|
1694
1802
|
return response.data?.value;
|
|
1695
1803
|
}
|
|
1804
|
+
/**
|
|
1805
|
+
* Look up a single resource by name on a folder-scoped OData collection.
|
|
1806
|
+
*
|
|
1807
|
+
* Shared by `getByName` implementations across services (Assets, Processes, etc).
|
|
1808
|
+
* Handles:
|
|
1809
|
+
* - Name validation via `validateName`
|
|
1810
|
+
* - Folder header resolution via `resolveFolderHeaders` (folderId → ID/key
|
|
1811
|
+
* header by type, folderPath → encoded path header, falls back to
|
|
1812
|
+
* init-time `config.folderKey` from the `uipath:folder-key` meta tag)
|
|
1813
|
+
* - OData `$filter=Name eq '…'` with single-quote escaping + `$top=1`
|
|
1814
|
+
* - Empty-result → `NotFoundError` with folder context in the message
|
|
1815
|
+
*
|
|
1816
|
+
* The transform step is caller-provided because each resource has its own
|
|
1817
|
+
* PascalCase → camelCase field mapping.
|
|
1818
|
+
*
|
|
1819
|
+
* @param resourceType - Resource label used in validation + error messages (e.g. 'Asset', 'Process')
|
|
1820
|
+
* @param endpoint - Folder-scoped OData collection endpoint
|
|
1821
|
+
* @param name - Resource name to search for
|
|
1822
|
+
* @param options - Folder scoping (`folderId` / `folderKey` / `folderPath`) + OData query options (`expand`, `select`)
|
|
1823
|
+
* @param transform - Maps a raw OData item to the typed response (e.g. PascalCase → camelCase via field map)
|
|
1824
|
+
* @throws ValidationError when inputs are malformed; NotFoundError when no match
|
|
1825
|
+
*/
|
|
1826
|
+
async getByNameLookup(resourceType, endpoint, name, options, transform) {
|
|
1827
|
+
const validatedName = validateName(resourceType, name);
|
|
1828
|
+
const { folderId, folderKey, folderPath, ...queryOptions } = options;
|
|
1829
|
+
const headers = resolveFolderHeaders({
|
|
1830
|
+
folderId,
|
|
1831
|
+
folderKey,
|
|
1832
|
+
folderPath,
|
|
1833
|
+
resourceType: `${resourceType}.getByName`,
|
|
1834
|
+
fallbackFolderKey: this.config.folderKey,
|
|
1835
|
+
});
|
|
1836
|
+
const apiOptions = {
|
|
1837
|
+
...addPrefixToKeys(queryOptions, ODATA_PREFIX, Object.keys(queryOptions)),
|
|
1838
|
+
'$filter': `Name eq '${validatedName.replace(SINGLE_QUOTE_RE, "''")}'`,
|
|
1839
|
+
'$top': '1',
|
|
1840
|
+
};
|
|
1841
|
+
const response = await this.get(endpoint, {
|
|
1842
|
+
headers,
|
|
1843
|
+
params: apiOptions,
|
|
1844
|
+
});
|
|
1845
|
+
const items = response.data?.value;
|
|
1846
|
+
if (!items?.length) {
|
|
1847
|
+
const folderHint = describeFolderForError(folderId, folderKey, folderPath);
|
|
1848
|
+
throw new NotFoundError({
|
|
1849
|
+
message: `${resourceType} '${validatedName}' not found${folderHint}.`,
|
|
1850
|
+
});
|
|
1851
|
+
}
|
|
1852
|
+
return transform(items[0]);
|
|
1853
|
+
}
|
|
1854
|
+
}
|
|
1855
|
+
/** Renders the supplied folder for a NotFoundError message. */
|
|
1856
|
+
function describeFolderForError(folderId, folderKey, folderPath) {
|
|
1857
|
+
const path = folderPath?.trim();
|
|
1858
|
+
if (path)
|
|
1859
|
+
return ` in folder '${path}'`;
|
|
1860
|
+
const key = folderKey?.trim();
|
|
1861
|
+
if (key)
|
|
1862
|
+
return ` in folder (key: ${key})`;
|
|
1863
|
+
if (typeof folderId === 'number')
|
|
1864
|
+
return ` in folder (id: ${folderId})`;
|
|
1865
|
+
return '';
|
|
1696
1866
|
}
|
|
1697
1867
|
|
|
1698
1868
|
/**
|
|
@@ -1730,7 +1900,7 @@ const BucketMap = {
|
|
|
1730
1900
|
// Connection string placeholder that will be replaced during build
|
|
1731
1901
|
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";
|
|
1732
1902
|
// SDK Version placeholder
|
|
1733
|
-
const SDK_VERSION = "1.3.
|
|
1903
|
+
const SDK_VERSION = "1.3.7";
|
|
1734
1904
|
const VERSION = "Version";
|
|
1735
1905
|
const SERVICE = "Service";
|
|
1736
1906
|
const CLOUD_ORGANIZATION_NAME = "CloudOrganizationName";
|
package/dist/cases/index.cjs
CHANGED
|
@@ -1576,8 +1576,9 @@ class BaseService {
|
|
|
1576
1576
|
constructor(instance, headers) {
|
|
1577
1577
|
// Private field - not visible via Object.keys() or any reflection
|
|
1578
1578
|
_BaseService_apiClient.set(this, void 0);
|
|
1579
|
-
const { config, context, tokenManager } = SDKInternalsRegistry.get(instance);
|
|
1579
|
+
const { config, context, tokenManager, folderKey } = SDKInternalsRegistry.get(instance);
|
|
1580
1580
|
__classPrivateFieldSet(this, _BaseService_apiClient, new ApiClient(config, context, tokenManager, headers ? { headers } : {}), "f");
|
|
1581
|
+
this.config = { folderKey };
|
|
1581
1582
|
}
|
|
1582
1583
|
/**
|
|
1583
1584
|
* Gets a valid authentication token, refreshing if necessary.
|
|
@@ -1842,7 +1843,7 @@ const MAESTRO_ENDPOINTS = {
|
|
|
1842
1843
|
// Connection string placeholder that will be replaced during build
|
|
1843
1844
|
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";
|
|
1844
1845
|
// SDK Version placeholder
|
|
1845
|
-
const SDK_VERSION = "1.3.
|
|
1846
|
+
const SDK_VERSION = "1.3.7";
|
|
1846
1847
|
const VERSION = "Version";
|
|
1847
1848
|
const SERVICE = "Service";
|
|
1848
1849
|
const CLOUD_ORGANIZATION_NAME = "CloudOrganizationName";
|
package/dist/cases/index.d.ts
CHANGED
|
@@ -1150,6 +1150,13 @@ interface ApiResponse<T> {
|
|
|
1150
1150
|
*/
|
|
1151
1151
|
declare class BaseService {
|
|
1152
1152
|
#private;
|
|
1153
|
+
/**
|
|
1154
|
+
* SDK configuration (read-only). Available to subclasses so they can
|
|
1155
|
+
* fall back to init-time defaults like `folderKey`.
|
|
1156
|
+
*/
|
|
1157
|
+
protected readonly config: {
|
|
1158
|
+
folderKey?: string;
|
|
1159
|
+
};
|
|
1153
1160
|
/**
|
|
1154
1161
|
* Creates a base service instance with dependency injection.
|
|
1155
1162
|
*
|
package/dist/cases/index.mjs
CHANGED
|
@@ -1574,8 +1574,9 @@ class BaseService {
|
|
|
1574
1574
|
constructor(instance, headers) {
|
|
1575
1575
|
// Private field - not visible via Object.keys() or any reflection
|
|
1576
1576
|
_BaseService_apiClient.set(this, void 0);
|
|
1577
|
-
const { config, context, tokenManager } = SDKInternalsRegistry.get(instance);
|
|
1577
|
+
const { config, context, tokenManager, folderKey } = SDKInternalsRegistry.get(instance);
|
|
1578
1578
|
__classPrivateFieldSet(this, _BaseService_apiClient, new ApiClient(config, context, tokenManager, headers ? { headers } : {}), "f");
|
|
1579
|
+
this.config = { folderKey };
|
|
1579
1580
|
}
|
|
1580
1581
|
/**
|
|
1581
1582
|
* Gets a valid authentication token, refreshing if necessary.
|
|
@@ -1840,7 +1841,7 @@ const MAESTRO_ENDPOINTS = {
|
|
|
1840
1841
|
// Connection string placeholder that will be replaced during build
|
|
1841
1842
|
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";
|
|
1842
1843
|
// SDK Version placeholder
|
|
1843
|
-
const SDK_VERSION = "1.3.
|
|
1844
|
+
const SDK_VERSION = "1.3.7";
|
|
1844
1845
|
const VERSION = "Version";
|
|
1845
1846
|
const SERVICE = "Service";
|
|
1846
1847
|
const CLOUD_ORGANIZATION_NAME = "CloudOrganizationName";
|