@uipath/uipath-typescript 1.3.5 → 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/README.md +1 -1
- 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 +44 -7
- package/dist/core/index.d.ts +11 -1
- package/dist/core/index.mjs +44 -7
- 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 +40 -5
- package/dist/feedback/index.d.ts +59 -1
- package/dist/feedback/index.mjs +40 -5
- package/dist/index.cjs +312 -14
- package/dist/index.d.ts +515 -32
- package/dist/index.mjs +313 -15
- package/dist/index.umd.js +312 -14
- 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
package/README.md
CHANGED
package/dist/assets/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';
|
|
@@ -1421,8 +1423,9 @@ class BaseService {
|
|
|
1421
1423
|
constructor(instance, headers) {
|
|
1422
1424
|
// Private field - not visible via Object.keys() or any reflection
|
|
1423
1425
|
_BaseService_apiClient.set(this, void 0);
|
|
1424
|
-
const { config, context, tokenManager } = SDKInternalsRegistry.get(instance);
|
|
1426
|
+
const { config, context, tokenManager, folderKey } = SDKInternalsRegistry.get(instance);
|
|
1425
1427
|
__classPrivateFieldSet(this, _BaseService_apiClient, new ApiClient(config, context, tokenManager, headers ? { headers } : {}), "f");
|
|
1428
|
+
this.config = { folderKey };
|
|
1426
1429
|
}
|
|
1427
1430
|
/**
|
|
1428
1431
|
* Gets a valid authentication token, refreshing if necessary.
|
|
@@ -1619,6 +1622,111 @@ class BaseService {
|
|
|
1619
1622
|
}
|
|
1620
1623
|
_BaseService_apiClient = new WeakMap();
|
|
1621
1624
|
|
|
1625
|
+
/**
|
|
1626
|
+
* Validates the `name` argument passed to a `getByName(name, ...)` method.
|
|
1627
|
+
* Trims whitespace and rejects empty/whitespace-only names.
|
|
1628
|
+
*
|
|
1629
|
+
* @param resourceType - Resource label used in error messages (e.g. 'Asset', 'Process')
|
|
1630
|
+
* @param name - Resource name to validate
|
|
1631
|
+
* @returns The trimmed name
|
|
1632
|
+
* @throws ValidationError when `name` is missing or empty after trimming
|
|
1633
|
+
*/
|
|
1634
|
+
function validateName(resourceType, name) {
|
|
1635
|
+
if (!name) {
|
|
1636
|
+
throw new ValidationError({
|
|
1637
|
+
message: `${resourceType} name is required and cannot be empty.`,
|
|
1638
|
+
});
|
|
1639
|
+
}
|
|
1640
|
+
const trimmed = name.trim();
|
|
1641
|
+
if (!trimmed) {
|
|
1642
|
+
throw new ValidationError({
|
|
1643
|
+
message: `${resourceType} name is required and cannot be empty.`,
|
|
1644
|
+
});
|
|
1645
|
+
}
|
|
1646
|
+
return trimmed;
|
|
1647
|
+
}
|
|
1648
|
+
|
|
1649
|
+
/**
|
|
1650
|
+
* Encodes a folder path for the `X-UIPATH-FolderPath-Encoded` header.
|
|
1651
|
+
*
|
|
1652
|
+
* Orchestrator decodes this header as **base64-encoded UTF-16 LE bytes**
|
|
1653
|
+
* (see `HttpHeadersProviderExtensions.GetDecoded` + `OrganizationUnitProvider`
|
|
1654
|
+
* in the Orchestrator repo, which call `Encoding.Unicode.GetString(...)`).
|
|
1655
|
+
* URL-encoding is NOT what the server expects — it must be base64-of-UTF-16-LE
|
|
1656
|
+
* bytes.
|
|
1657
|
+
*
|
|
1658
|
+
* @param folderPath - The folder path (e.g. 'Shared/Finance')
|
|
1659
|
+
* @returns Base64 string suitable for the `X-UIPATH-FolderPath-Encoded` header
|
|
1660
|
+
*/
|
|
1661
|
+
function encodeFolderPathHeader(folderPath) {
|
|
1662
|
+
// Force little-endian regardless of host byte order. `Uint16Array` viewed
|
|
1663
|
+
// as `Uint8Array` would use the host's native order — correct on LE hosts
|
|
1664
|
+
// (x86/ARM-LE) but wrong on BE hosts. `DataView.setUint16(..., true)`
|
|
1665
|
+
// pins LE.
|
|
1666
|
+
const buf = new ArrayBuffer(folderPath.length * 2);
|
|
1667
|
+
const view = new DataView(buf);
|
|
1668
|
+
for (let i = 0; i < folderPath.length; i++) {
|
|
1669
|
+
view.setUint16(i * 2, folderPath.charCodeAt(i), true);
|
|
1670
|
+
}
|
|
1671
|
+
const bytes = new Uint8Array(buf);
|
|
1672
|
+
let binary = '';
|
|
1673
|
+
for (let i = 0; i < bytes.byteLength; i++) {
|
|
1674
|
+
binary += String.fromCharCode(bytes[i]);
|
|
1675
|
+
}
|
|
1676
|
+
// btoa is browser-native; Node 16+ also has it as a global
|
|
1677
|
+
return btoa(binary);
|
|
1678
|
+
}
|
|
1679
|
+
|
|
1680
|
+
/**
|
|
1681
|
+
* Resolves folder context into the appropriate Orchestrator folder headers.
|
|
1682
|
+
*
|
|
1683
|
+
* Centralized so all folder-scoped methods (e.g. `assets.getByName`,
|
|
1684
|
+
* `processes.getByName`, future Queues/Buckets/Jobs) share one implementation.
|
|
1685
|
+
*
|
|
1686
|
+
* Each input field maps directly to its header — no auto-detection or type
|
|
1687
|
+
* coercion. When multiple fields are supplied, all corresponding headers
|
|
1688
|
+
* are forwarded and the server resolves precedence.
|
|
1689
|
+
*
|
|
1690
|
+
* Routing:
|
|
1691
|
+
* - `folderId` → `X-UIPATH-OrganizationUnitId`
|
|
1692
|
+
* - `folderKey` → `X-UIPATH-FolderKey`
|
|
1693
|
+
* - `folderPath` → `X-UIPATH-FolderPath-Encoded`
|
|
1694
|
+
* - none set + `fallbackFolderKey` → fallback used as `X-UIPATH-FolderKey`
|
|
1695
|
+
* - none set + no fallback → `ValidationError`
|
|
1696
|
+
*
|
|
1697
|
+
* @throws ValidationError when no folder context can be resolved.
|
|
1698
|
+
*/
|
|
1699
|
+
function resolveFolderHeaders(input) {
|
|
1700
|
+
const { folderId, folderKey, folderPath, resourceType, fallbackFolderKey } = input;
|
|
1701
|
+
const trimmedKey = folderKey?.trim();
|
|
1702
|
+
const trimmedPath = folderPath?.trim();
|
|
1703
|
+
const headers = {};
|
|
1704
|
+
if (folderId !== undefined) {
|
|
1705
|
+
headers[FOLDER_ID] = folderId;
|
|
1706
|
+
}
|
|
1707
|
+
if (trimmedKey) {
|
|
1708
|
+
headers[FOLDER_KEY] = trimmedKey;
|
|
1709
|
+
}
|
|
1710
|
+
if (trimmedPath) {
|
|
1711
|
+
headers[FOLDER_PATH_ENCODED] = encodeFolderPathHeader(trimmedPath);
|
|
1712
|
+
}
|
|
1713
|
+
// No explicit folder context → meta-tag fallback or error.
|
|
1714
|
+
if (Object.keys(headers).length === 0) {
|
|
1715
|
+
if (!fallbackFolderKey) {
|
|
1716
|
+
throw new ValidationError({
|
|
1717
|
+
message: `${resourceType} requires folder context: pass \`folderId\`, \`folderKey\`, or \`folderPath\`, or initialize the SDK with a folder context.`,
|
|
1718
|
+
});
|
|
1719
|
+
}
|
|
1720
|
+
headers[FOLDER_KEY] = fallbackFolderKey;
|
|
1721
|
+
}
|
|
1722
|
+
return createHeaders(headers);
|
|
1723
|
+
}
|
|
1724
|
+
|
|
1725
|
+
/**
|
|
1726
|
+
* Matches single-quote characters in OData string literals — escaped to `''`
|
|
1727
|
+
* inside the `$filter=Name eq '…'` clause built by `getByNameLookup`.
|
|
1728
|
+
*/
|
|
1729
|
+
const SINGLE_QUOTE_RE = /'/g;
|
|
1622
1730
|
/**
|
|
1623
1731
|
* Base service for services that need folder-specific functionality.
|
|
1624
1732
|
*
|
|
@@ -1652,6 +1760,68 @@ class FolderScopedService extends BaseService {
|
|
|
1652
1760
|
}
|
|
1653
1761
|
return response.data?.value;
|
|
1654
1762
|
}
|
|
1763
|
+
/**
|
|
1764
|
+
* Look up a single resource by name on a folder-scoped OData collection.
|
|
1765
|
+
*
|
|
1766
|
+
* Shared by `getByName` implementations across services (Assets, Processes, etc).
|
|
1767
|
+
* Handles:
|
|
1768
|
+
* - Name validation via `validateName`
|
|
1769
|
+
* - Folder header resolution via `resolveFolderHeaders` (folderId → ID/key
|
|
1770
|
+
* header by type, folderPath → encoded path header, falls back to
|
|
1771
|
+
* init-time `config.folderKey` from the `uipath:folder-key` meta tag)
|
|
1772
|
+
* - OData `$filter=Name eq '…'` with single-quote escaping + `$top=1`
|
|
1773
|
+
* - Empty-result → `NotFoundError` with folder context in the message
|
|
1774
|
+
*
|
|
1775
|
+
* The transform step is caller-provided because each resource has its own
|
|
1776
|
+
* PascalCase → camelCase field mapping.
|
|
1777
|
+
*
|
|
1778
|
+
* @param resourceType - Resource label used in validation + error messages (e.g. 'Asset', 'Process')
|
|
1779
|
+
* @param endpoint - Folder-scoped OData collection endpoint
|
|
1780
|
+
* @param name - Resource name to search for
|
|
1781
|
+
* @param options - Folder scoping (`folderId` / `folderKey` / `folderPath`) + OData query options (`expand`, `select`)
|
|
1782
|
+
* @param transform - Maps a raw OData item to the typed response (e.g. PascalCase → camelCase via field map)
|
|
1783
|
+
* @throws ValidationError when inputs are malformed; NotFoundError when no match
|
|
1784
|
+
*/
|
|
1785
|
+
async getByNameLookup(resourceType, endpoint, name, options, transform) {
|
|
1786
|
+
const validatedName = validateName(resourceType, name);
|
|
1787
|
+
const { folderId, folderKey, folderPath, ...queryOptions } = options;
|
|
1788
|
+
const headers = resolveFolderHeaders({
|
|
1789
|
+
folderId,
|
|
1790
|
+
folderKey,
|
|
1791
|
+
folderPath,
|
|
1792
|
+
resourceType: `${resourceType}.getByName`,
|
|
1793
|
+
fallbackFolderKey: this.config.folderKey,
|
|
1794
|
+
});
|
|
1795
|
+
const apiOptions = {
|
|
1796
|
+
...addPrefixToKeys(queryOptions, ODATA_PREFIX, Object.keys(queryOptions)),
|
|
1797
|
+
'$filter': `Name eq '${validatedName.replace(SINGLE_QUOTE_RE, "''")}'`,
|
|
1798
|
+
'$top': '1',
|
|
1799
|
+
};
|
|
1800
|
+
const response = await this.get(endpoint, {
|
|
1801
|
+
headers,
|
|
1802
|
+
params: apiOptions,
|
|
1803
|
+
});
|
|
1804
|
+
const items = response.data?.value;
|
|
1805
|
+
if (!items?.length) {
|
|
1806
|
+
const folderHint = describeFolderForError(folderId, folderKey, folderPath);
|
|
1807
|
+
throw new NotFoundError({
|
|
1808
|
+
message: `${resourceType} '${validatedName}' not found${folderHint}.`,
|
|
1809
|
+
});
|
|
1810
|
+
}
|
|
1811
|
+
return transform(items[0]);
|
|
1812
|
+
}
|
|
1813
|
+
}
|
|
1814
|
+
/** Renders the supplied folder for a NotFoundError message. */
|
|
1815
|
+
function describeFolderForError(folderId, folderKey, folderPath) {
|
|
1816
|
+
const path = folderPath?.trim();
|
|
1817
|
+
if (path)
|
|
1818
|
+
return ` in folder '${path}'`;
|
|
1819
|
+
const key = folderKey?.trim();
|
|
1820
|
+
if (key)
|
|
1821
|
+
return ` in folder (key: ${key})`;
|
|
1822
|
+
if (typeof folderId === 'number')
|
|
1823
|
+
return ` in folder (id: ${folderId})`;
|
|
1824
|
+
return '';
|
|
1655
1825
|
}
|
|
1656
1826
|
|
|
1657
1827
|
/**
|
|
@@ -1685,7 +1855,7 @@ const AssetMap = {
|
|
|
1685
1855
|
// Connection string placeholder that will be replaced during build
|
|
1686
1856
|
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";
|
|
1687
1857
|
// SDK Version placeholder
|
|
1688
|
-
const SDK_VERSION = "1.3.
|
|
1858
|
+
const SDK_VERSION = "1.3.7";
|
|
1689
1859
|
const VERSION = "Version";
|
|
1690
1860
|
const SERVICE = "Service";
|
|
1691
1861
|
const CLOUD_ORGANIZATION_NAME = "CloudOrganizationName";
|
|
@@ -2040,6 +2210,35 @@ class AssetService extends FolderScopedService {
|
|
|
2040
2210
|
const transformedAsset = transformData(pascalToCamelCaseKeys(response.data), AssetMap);
|
|
2041
2211
|
return transformedAsset;
|
|
2042
2212
|
}
|
|
2213
|
+
/**
|
|
2214
|
+
* Retrieves a single asset by name.
|
|
2215
|
+
*
|
|
2216
|
+
* @param name - Asset name to search for
|
|
2217
|
+
* @param options - Folder scoping (`folderId` / `folderKey` / `folderPath`) and optional query parameters (`expand`, `select`)
|
|
2218
|
+
* @returns Promise resolving to a single asset
|
|
2219
|
+
* {@link AssetGetResponse}
|
|
2220
|
+
* @example
|
|
2221
|
+
* ```typescript
|
|
2222
|
+
* import { Assets } from '@uipath/uipath-typescript/assets';
|
|
2223
|
+
*
|
|
2224
|
+
* const assets = new Assets(sdk);
|
|
2225
|
+
*
|
|
2226
|
+
* // By folder ID
|
|
2227
|
+
* await assets.getByName('ApiKey', { folderId: 123 });
|
|
2228
|
+
*
|
|
2229
|
+
* // By folder key (GUID)
|
|
2230
|
+
* await assets.getByName('ApiKey', { folderKey: '5f6dadf1-3677-49dc-8aca-c2999dd4b3ba' });
|
|
2231
|
+
*
|
|
2232
|
+
* // By folder path
|
|
2233
|
+
* await assets.getByName('ApiKey', { folderPath: 'Shared/Finance' });
|
|
2234
|
+
*
|
|
2235
|
+
* // With expand
|
|
2236
|
+
* await assets.getByName('ApiKey', { folderPath: 'Shared/Finance', expand: 'keyValueList' });
|
|
2237
|
+
* ```
|
|
2238
|
+
*/
|
|
2239
|
+
async getByName(name, options = {}) {
|
|
2240
|
+
return this.getByNameLookup('Asset', ASSET_ENDPOINTS.GET_BY_FOLDER, name, options, (raw) => transformData(pascalToCamelCaseKeys(raw), AssetMap));
|
|
2241
|
+
}
|
|
2043
2242
|
}
|
|
2044
2243
|
__decorate([
|
|
2045
2244
|
track('Assets.GetAll')
|
|
@@ -2047,6 +2246,9 @@ __decorate([
|
|
|
2047
2246
|
__decorate([
|
|
2048
2247
|
track('Assets.GetById')
|
|
2049
2248
|
], AssetService.prototype, "getById", null);
|
|
2249
|
+
__decorate([
|
|
2250
|
+
track('Assets.GetByName')
|
|
2251
|
+
], AssetService.prototype, "getByName", null);
|
|
2050
2252
|
|
|
2051
2253
|
/**
|
|
2052
2254
|
* Enum for Asset Value Scope
|
package/dist/assets/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
|
/**
|
|
@@ -389,6 +433,11 @@ type AssetGetAllOptions = RequestOptions & PaginationOptions & {
|
|
|
389
433
|
*/
|
|
390
434
|
interface AssetGetByIdOptions extends BaseOptions {
|
|
391
435
|
}
|
|
436
|
+
/**
|
|
437
|
+
* Options for getting a single asset by name
|
|
438
|
+
*/
|
|
439
|
+
interface AssetGetByNameOptions extends FolderScopedOptions {
|
|
440
|
+
}
|
|
392
441
|
|
|
393
442
|
/**
|
|
394
443
|
* Service for managing UiPath Assets.
|
|
@@ -450,6 +499,29 @@ interface AssetServiceModel {
|
|
|
450
499
|
* ```
|
|
451
500
|
*/
|
|
452
501
|
getById(id: number, folderId: number, options?: AssetGetByIdOptions): Promise<AssetGetResponse>;
|
|
502
|
+
/**
|
|
503
|
+
* Retrieves a single asset by name.
|
|
504
|
+
*
|
|
505
|
+
* @param name - Asset name to search for
|
|
506
|
+
* @param options - Folder scoping (`folderId` / `folderKey` / `folderPath`) and optional query parameters (`expand`, `select`)
|
|
507
|
+
* @returns Promise resolving to a single asset
|
|
508
|
+
* {@link AssetGetResponse}
|
|
509
|
+
* @example
|
|
510
|
+
* ```typescript
|
|
511
|
+
* // By folder ID
|
|
512
|
+
* await assets.getByName('ApiKey', { folderId: 123 });
|
|
513
|
+
*
|
|
514
|
+
* // By folder key (GUID)
|
|
515
|
+
* await assets.getByName('ApiKey', { folderKey: '5f6dadf1-3677-49dc-8aca-c2999dd4b3ba' });
|
|
516
|
+
*
|
|
517
|
+
* // By folder path
|
|
518
|
+
* await assets.getByName('ApiKey', { folderPath: 'Shared/Finance' });
|
|
519
|
+
*
|
|
520
|
+
* // With expand
|
|
521
|
+
* await assets.getByName('ApiKey', { folderPath: 'Shared/Finance', expand: 'keyValueList' });
|
|
522
|
+
* ```
|
|
523
|
+
*/
|
|
524
|
+
getByName(name: string, options?: AssetGetByNameOptions): Promise<AssetGetResponse>;
|
|
453
525
|
}
|
|
454
526
|
|
|
455
527
|
/**
|
|
@@ -510,7 +582,34 @@ declare class AssetService extends FolderScopedService implements AssetServiceMo
|
|
|
510
582
|
* ```
|
|
511
583
|
*/
|
|
512
584
|
getById(id: number, folderId: number, options?: AssetGetByIdOptions): Promise<AssetGetResponse>;
|
|
585
|
+
/**
|
|
586
|
+
* Retrieves a single asset by name.
|
|
587
|
+
*
|
|
588
|
+
* @param name - Asset name to search for
|
|
589
|
+
* @param options - Folder scoping (`folderId` / `folderKey` / `folderPath`) and optional query parameters (`expand`, `select`)
|
|
590
|
+
* @returns Promise resolving to a single asset
|
|
591
|
+
* {@link AssetGetResponse}
|
|
592
|
+
* @example
|
|
593
|
+
* ```typescript
|
|
594
|
+
* import { Assets } from '@uipath/uipath-typescript/assets';
|
|
595
|
+
*
|
|
596
|
+
* const assets = new Assets(sdk);
|
|
597
|
+
*
|
|
598
|
+
* // By folder ID
|
|
599
|
+
* await assets.getByName('ApiKey', { folderId: 123 });
|
|
600
|
+
*
|
|
601
|
+
* // By folder key (GUID)
|
|
602
|
+
* await assets.getByName('ApiKey', { folderKey: '5f6dadf1-3677-49dc-8aca-c2999dd4b3ba' });
|
|
603
|
+
*
|
|
604
|
+
* // By folder path
|
|
605
|
+
* await assets.getByName('ApiKey', { folderPath: 'Shared/Finance' });
|
|
606
|
+
*
|
|
607
|
+
* // With expand
|
|
608
|
+
* await assets.getByName('ApiKey', { folderPath: 'Shared/Finance', expand: 'keyValueList' });
|
|
609
|
+
* ```
|
|
610
|
+
*/
|
|
611
|
+
getByName(name: string, options?: AssetGetByNameOptions): Promise<AssetGetResponse>;
|
|
513
612
|
}
|
|
514
613
|
|
|
515
614
|
export { AssetService, AssetValueScope, AssetValueType, AssetService as Assets };
|
|
516
|
-
export type { AssetGetAllOptions, AssetGetByIdOptions, AssetGetResponse, AssetServiceModel, CustomKeyValuePair };
|
|
615
|
+
export type { AssetGetAllOptions, AssetGetByIdOptions, AssetGetByNameOptions, AssetGetResponse, AssetServiceModel, CustomKeyValuePair };
|
package/dist/assets/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';
|
|
@@ -1419,8 +1421,9 @@ class BaseService {
|
|
|
1419
1421
|
constructor(instance, headers) {
|
|
1420
1422
|
// Private field - not visible via Object.keys() or any reflection
|
|
1421
1423
|
_BaseService_apiClient.set(this, void 0);
|
|
1422
|
-
const { config, context, tokenManager } = SDKInternalsRegistry.get(instance);
|
|
1424
|
+
const { config, context, tokenManager, folderKey } = SDKInternalsRegistry.get(instance);
|
|
1423
1425
|
__classPrivateFieldSet(this, _BaseService_apiClient, new ApiClient(config, context, tokenManager, headers ? { headers } : {}), "f");
|
|
1426
|
+
this.config = { folderKey };
|
|
1424
1427
|
}
|
|
1425
1428
|
/**
|
|
1426
1429
|
* Gets a valid authentication token, refreshing if necessary.
|
|
@@ -1617,6 +1620,111 @@ class BaseService {
|
|
|
1617
1620
|
}
|
|
1618
1621
|
_BaseService_apiClient = new WeakMap();
|
|
1619
1622
|
|
|
1623
|
+
/**
|
|
1624
|
+
* Validates the `name` argument passed to a `getByName(name, ...)` method.
|
|
1625
|
+
* Trims whitespace and rejects empty/whitespace-only names.
|
|
1626
|
+
*
|
|
1627
|
+
* @param resourceType - Resource label used in error messages (e.g. 'Asset', 'Process')
|
|
1628
|
+
* @param name - Resource name to validate
|
|
1629
|
+
* @returns The trimmed name
|
|
1630
|
+
* @throws ValidationError when `name` is missing or empty after trimming
|
|
1631
|
+
*/
|
|
1632
|
+
function validateName(resourceType, name) {
|
|
1633
|
+
if (!name) {
|
|
1634
|
+
throw new ValidationError({
|
|
1635
|
+
message: `${resourceType} name is required and cannot be empty.`,
|
|
1636
|
+
});
|
|
1637
|
+
}
|
|
1638
|
+
const trimmed = name.trim();
|
|
1639
|
+
if (!trimmed) {
|
|
1640
|
+
throw new ValidationError({
|
|
1641
|
+
message: `${resourceType} name is required and cannot be empty.`,
|
|
1642
|
+
});
|
|
1643
|
+
}
|
|
1644
|
+
return trimmed;
|
|
1645
|
+
}
|
|
1646
|
+
|
|
1647
|
+
/**
|
|
1648
|
+
* Encodes a folder path for the `X-UIPATH-FolderPath-Encoded` header.
|
|
1649
|
+
*
|
|
1650
|
+
* Orchestrator decodes this header as **base64-encoded UTF-16 LE bytes**
|
|
1651
|
+
* (see `HttpHeadersProviderExtensions.GetDecoded` + `OrganizationUnitProvider`
|
|
1652
|
+
* in the Orchestrator repo, which call `Encoding.Unicode.GetString(...)`).
|
|
1653
|
+
* URL-encoding is NOT what the server expects — it must be base64-of-UTF-16-LE
|
|
1654
|
+
* bytes.
|
|
1655
|
+
*
|
|
1656
|
+
* @param folderPath - The folder path (e.g. 'Shared/Finance')
|
|
1657
|
+
* @returns Base64 string suitable for the `X-UIPATH-FolderPath-Encoded` header
|
|
1658
|
+
*/
|
|
1659
|
+
function encodeFolderPathHeader(folderPath) {
|
|
1660
|
+
// Force little-endian regardless of host byte order. `Uint16Array` viewed
|
|
1661
|
+
// as `Uint8Array` would use the host's native order — correct on LE hosts
|
|
1662
|
+
// (x86/ARM-LE) but wrong on BE hosts. `DataView.setUint16(..., true)`
|
|
1663
|
+
// pins LE.
|
|
1664
|
+
const buf = new ArrayBuffer(folderPath.length * 2);
|
|
1665
|
+
const view = new DataView(buf);
|
|
1666
|
+
for (let i = 0; i < folderPath.length; i++) {
|
|
1667
|
+
view.setUint16(i * 2, folderPath.charCodeAt(i), true);
|
|
1668
|
+
}
|
|
1669
|
+
const bytes = new Uint8Array(buf);
|
|
1670
|
+
let binary = '';
|
|
1671
|
+
for (let i = 0; i < bytes.byteLength; i++) {
|
|
1672
|
+
binary += String.fromCharCode(bytes[i]);
|
|
1673
|
+
}
|
|
1674
|
+
// btoa is browser-native; Node 16+ also has it as a global
|
|
1675
|
+
return btoa(binary);
|
|
1676
|
+
}
|
|
1677
|
+
|
|
1678
|
+
/**
|
|
1679
|
+
* Resolves folder context into the appropriate Orchestrator folder headers.
|
|
1680
|
+
*
|
|
1681
|
+
* Centralized so all folder-scoped methods (e.g. `assets.getByName`,
|
|
1682
|
+
* `processes.getByName`, future Queues/Buckets/Jobs) share one implementation.
|
|
1683
|
+
*
|
|
1684
|
+
* Each input field maps directly to its header — no auto-detection or type
|
|
1685
|
+
* coercion. When multiple fields are supplied, all corresponding headers
|
|
1686
|
+
* are forwarded and the server resolves precedence.
|
|
1687
|
+
*
|
|
1688
|
+
* Routing:
|
|
1689
|
+
* - `folderId` → `X-UIPATH-OrganizationUnitId`
|
|
1690
|
+
* - `folderKey` → `X-UIPATH-FolderKey`
|
|
1691
|
+
* - `folderPath` → `X-UIPATH-FolderPath-Encoded`
|
|
1692
|
+
* - none set + `fallbackFolderKey` → fallback used as `X-UIPATH-FolderKey`
|
|
1693
|
+
* - none set + no fallback → `ValidationError`
|
|
1694
|
+
*
|
|
1695
|
+
* @throws ValidationError when no folder context can be resolved.
|
|
1696
|
+
*/
|
|
1697
|
+
function resolveFolderHeaders(input) {
|
|
1698
|
+
const { folderId, folderKey, folderPath, resourceType, fallbackFolderKey } = input;
|
|
1699
|
+
const trimmedKey = folderKey?.trim();
|
|
1700
|
+
const trimmedPath = folderPath?.trim();
|
|
1701
|
+
const headers = {};
|
|
1702
|
+
if (folderId !== undefined) {
|
|
1703
|
+
headers[FOLDER_ID] = folderId;
|
|
1704
|
+
}
|
|
1705
|
+
if (trimmedKey) {
|
|
1706
|
+
headers[FOLDER_KEY] = trimmedKey;
|
|
1707
|
+
}
|
|
1708
|
+
if (trimmedPath) {
|
|
1709
|
+
headers[FOLDER_PATH_ENCODED] = encodeFolderPathHeader(trimmedPath);
|
|
1710
|
+
}
|
|
1711
|
+
// No explicit folder context → meta-tag fallback or error.
|
|
1712
|
+
if (Object.keys(headers).length === 0) {
|
|
1713
|
+
if (!fallbackFolderKey) {
|
|
1714
|
+
throw new ValidationError({
|
|
1715
|
+
message: `${resourceType} requires folder context: pass \`folderId\`, \`folderKey\`, or \`folderPath\`, or initialize the SDK with a folder context.`,
|
|
1716
|
+
});
|
|
1717
|
+
}
|
|
1718
|
+
headers[FOLDER_KEY] = fallbackFolderKey;
|
|
1719
|
+
}
|
|
1720
|
+
return createHeaders(headers);
|
|
1721
|
+
}
|
|
1722
|
+
|
|
1723
|
+
/**
|
|
1724
|
+
* Matches single-quote characters in OData string literals — escaped to `''`
|
|
1725
|
+
* inside the `$filter=Name eq '…'` clause built by `getByNameLookup`.
|
|
1726
|
+
*/
|
|
1727
|
+
const SINGLE_QUOTE_RE = /'/g;
|
|
1620
1728
|
/**
|
|
1621
1729
|
* Base service for services that need folder-specific functionality.
|
|
1622
1730
|
*
|
|
@@ -1650,6 +1758,68 @@ class FolderScopedService extends BaseService {
|
|
|
1650
1758
|
}
|
|
1651
1759
|
return response.data?.value;
|
|
1652
1760
|
}
|
|
1761
|
+
/**
|
|
1762
|
+
* Look up a single resource by name on a folder-scoped OData collection.
|
|
1763
|
+
*
|
|
1764
|
+
* Shared by `getByName` implementations across services (Assets, Processes, etc).
|
|
1765
|
+
* Handles:
|
|
1766
|
+
* - Name validation via `validateName`
|
|
1767
|
+
* - Folder header resolution via `resolveFolderHeaders` (folderId → ID/key
|
|
1768
|
+
* header by type, folderPath → encoded path header, falls back to
|
|
1769
|
+
* init-time `config.folderKey` from the `uipath:folder-key` meta tag)
|
|
1770
|
+
* - OData `$filter=Name eq '…'` with single-quote escaping + `$top=1`
|
|
1771
|
+
* - Empty-result → `NotFoundError` with folder context in the message
|
|
1772
|
+
*
|
|
1773
|
+
* The transform step is caller-provided because each resource has its own
|
|
1774
|
+
* PascalCase → camelCase field mapping.
|
|
1775
|
+
*
|
|
1776
|
+
* @param resourceType - Resource label used in validation + error messages (e.g. 'Asset', 'Process')
|
|
1777
|
+
* @param endpoint - Folder-scoped OData collection endpoint
|
|
1778
|
+
* @param name - Resource name to search for
|
|
1779
|
+
* @param options - Folder scoping (`folderId` / `folderKey` / `folderPath`) + OData query options (`expand`, `select`)
|
|
1780
|
+
* @param transform - Maps a raw OData item to the typed response (e.g. PascalCase → camelCase via field map)
|
|
1781
|
+
* @throws ValidationError when inputs are malformed; NotFoundError when no match
|
|
1782
|
+
*/
|
|
1783
|
+
async getByNameLookup(resourceType, endpoint, name, options, transform) {
|
|
1784
|
+
const validatedName = validateName(resourceType, name);
|
|
1785
|
+
const { folderId, folderKey, folderPath, ...queryOptions } = options;
|
|
1786
|
+
const headers = resolveFolderHeaders({
|
|
1787
|
+
folderId,
|
|
1788
|
+
folderKey,
|
|
1789
|
+
folderPath,
|
|
1790
|
+
resourceType: `${resourceType}.getByName`,
|
|
1791
|
+
fallbackFolderKey: this.config.folderKey,
|
|
1792
|
+
});
|
|
1793
|
+
const apiOptions = {
|
|
1794
|
+
...addPrefixToKeys(queryOptions, ODATA_PREFIX, Object.keys(queryOptions)),
|
|
1795
|
+
'$filter': `Name eq '${validatedName.replace(SINGLE_QUOTE_RE, "''")}'`,
|
|
1796
|
+
'$top': '1',
|
|
1797
|
+
};
|
|
1798
|
+
const response = await this.get(endpoint, {
|
|
1799
|
+
headers,
|
|
1800
|
+
params: apiOptions,
|
|
1801
|
+
});
|
|
1802
|
+
const items = response.data?.value;
|
|
1803
|
+
if (!items?.length) {
|
|
1804
|
+
const folderHint = describeFolderForError(folderId, folderKey, folderPath);
|
|
1805
|
+
throw new NotFoundError({
|
|
1806
|
+
message: `${resourceType} '${validatedName}' not found${folderHint}.`,
|
|
1807
|
+
});
|
|
1808
|
+
}
|
|
1809
|
+
return transform(items[0]);
|
|
1810
|
+
}
|
|
1811
|
+
}
|
|
1812
|
+
/** Renders the supplied folder for a NotFoundError message. */
|
|
1813
|
+
function describeFolderForError(folderId, folderKey, folderPath) {
|
|
1814
|
+
const path = folderPath?.trim();
|
|
1815
|
+
if (path)
|
|
1816
|
+
return ` in folder '${path}'`;
|
|
1817
|
+
const key = folderKey?.trim();
|
|
1818
|
+
if (key)
|
|
1819
|
+
return ` in folder (key: ${key})`;
|
|
1820
|
+
if (typeof folderId === 'number')
|
|
1821
|
+
return ` in folder (id: ${folderId})`;
|
|
1822
|
+
return '';
|
|
1653
1823
|
}
|
|
1654
1824
|
|
|
1655
1825
|
/**
|
|
@@ -1683,7 +1853,7 @@ const AssetMap = {
|
|
|
1683
1853
|
// Connection string placeholder that will be replaced during build
|
|
1684
1854
|
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";
|
|
1685
1855
|
// SDK Version placeholder
|
|
1686
|
-
const SDK_VERSION = "1.3.
|
|
1856
|
+
const SDK_VERSION = "1.3.7";
|
|
1687
1857
|
const VERSION = "Version";
|
|
1688
1858
|
const SERVICE = "Service";
|
|
1689
1859
|
const CLOUD_ORGANIZATION_NAME = "CloudOrganizationName";
|
|
@@ -2038,6 +2208,35 @@ class AssetService extends FolderScopedService {
|
|
|
2038
2208
|
const transformedAsset = transformData(pascalToCamelCaseKeys(response.data), AssetMap);
|
|
2039
2209
|
return transformedAsset;
|
|
2040
2210
|
}
|
|
2211
|
+
/**
|
|
2212
|
+
* Retrieves a single asset by name.
|
|
2213
|
+
*
|
|
2214
|
+
* @param name - Asset name to search for
|
|
2215
|
+
* @param options - Folder scoping (`folderId` / `folderKey` / `folderPath`) and optional query parameters (`expand`, `select`)
|
|
2216
|
+
* @returns Promise resolving to a single asset
|
|
2217
|
+
* {@link AssetGetResponse}
|
|
2218
|
+
* @example
|
|
2219
|
+
* ```typescript
|
|
2220
|
+
* import { Assets } from '@uipath/uipath-typescript/assets';
|
|
2221
|
+
*
|
|
2222
|
+
* const assets = new Assets(sdk);
|
|
2223
|
+
*
|
|
2224
|
+
* // By folder ID
|
|
2225
|
+
* await assets.getByName('ApiKey', { folderId: 123 });
|
|
2226
|
+
*
|
|
2227
|
+
* // By folder key (GUID)
|
|
2228
|
+
* await assets.getByName('ApiKey', { folderKey: '5f6dadf1-3677-49dc-8aca-c2999dd4b3ba' });
|
|
2229
|
+
*
|
|
2230
|
+
* // By folder path
|
|
2231
|
+
* await assets.getByName('ApiKey', { folderPath: 'Shared/Finance' });
|
|
2232
|
+
*
|
|
2233
|
+
* // With expand
|
|
2234
|
+
* await assets.getByName('ApiKey', { folderPath: 'Shared/Finance', expand: 'keyValueList' });
|
|
2235
|
+
* ```
|
|
2236
|
+
*/
|
|
2237
|
+
async getByName(name, options = {}) {
|
|
2238
|
+
return this.getByNameLookup('Asset', ASSET_ENDPOINTS.GET_BY_FOLDER, name, options, (raw) => transformData(pascalToCamelCaseKeys(raw), AssetMap));
|
|
2239
|
+
}
|
|
2041
2240
|
}
|
|
2042
2241
|
__decorate([
|
|
2043
2242
|
track('Assets.GetAll')
|
|
@@ -2045,6 +2244,9 @@ __decorate([
|
|
|
2045
2244
|
__decorate([
|
|
2046
2245
|
track('Assets.GetById')
|
|
2047
2246
|
], AssetService.prototype, "getById", null);
|
|
2247
|
+
__decorate([
|
|
2248
|
+
track('Assets.GetByName')
|
|
2249
|
+
], AssetService.prototype, "getByName", null);
|
|
2048
2250
|
|
|
2049
2251
|
/**
|
|
2050
2252
|
* Enum for Asset Value Scope
|