@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
|
@@ -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
|
*
|
|
@@ -316,6 +323,66 @@ interface RequestOptions extends BaseOptions {
|
|
|
316
323
|
filter?: string;
|
|
317
324
|
orderby?: string;
|
|
318
325
|
}
|
|
326
|
+
/**
|
|
327
|
+
* Options that scope a name-based lookup (e.g. `getByName`) to a folder.
|
|
328
|
+
* Provide one of `folderId`, `folderKey`, or `folderPath`. When more than
|
|
329
|
+
* one is supplied, all are forwarded; the server applies precedence
|
|
330
|
+
* `folderPath` > `folderKey` > `folderId`.
|
|
331
|
+
*/
|
|
332
|
+
interface FolderScopedOptions extends BaseOptions {
|
|
333
|
+
/** Numeric folder ID. */
|
|
334
|
+
folderId?: number;
|
|
335
|
+
/** Folder key (GUID-formatted string). */
|
|
336
|
+
folderKey?: string;
|
|
337
|
+
/** Slash-delimited folder path, e.g. `'Shared/Finance'`. */
|
|
338
|
+
folderPath?: string;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* Base service for services that need folder-specific functionality.
|
|
343
|
+
*
|
|
344
|
+
* Extends BaseService with additional methods for working with folder-scoped resources
|
|
345
|
+
* in UiPath Orchestrator. Services that work with folders (Assets, Queues) extend this class.
|
|
346
|
+
*
|
|
347
|
+
* @remarks
|
|
348
|
+
* This class provides helper methods for making folder-scoped API calls, handling folder IDs
|
|
349
|
+
* in request headers, and managing cross-folder queries.
|
|
350
|
+
*/
|
|
351
|
+
declare class FolderScopedService extends BaseService {
|
|
352
|
+
/**
|
|
353
|
+
* Gets resources in a folder with optional query parameters
|
|
354
|
+
*
|
|
355
|
+
* @param endpoint - API endpoint to call
|
|
356
|
+
* @param folderId - required folder ID
|
|
357
|
+
* @param options - Query options
|
|
358
|
+
* @param transformFn - Optional function to transform the response data
|
|
359
|
+
* @returns Promise resolving to an array of resources
|
|
360
|
+
*/
|
|
361
|
+
protected _getByFolder<T, R = T>(endpoint: string, folderId: number, options?: Record<string, any>, transformFn?: (item: T) => R): Promise<R[]>;
|
|
362
|
+
/**
|
|
363
|
+
* Look up a single resource by name on a folder-scoped OData collection.
|
|
364
|
+
*
|
|
365
|
+
* Shared by `getByName` implementations across services (Assets, Processes, etc).
|
|
366
|
+
* Handles:
|
|
367
|
+
* - Name validation via `validateName`
|
|
368
|
+
* - Folder header resolution via `resolveFolderHeaders` (folderId → ID/key
|
|
369
|
+
* header by type, folderPath → encoded path header, falls back to
|
|
370
|
+
* init-time `config.folderKey` from the `uipath:folder-key` meta tag)
|
|
371
|
+
* - OData `$filter=Name eq '…'` with single-quote escaping + `$top=1`
|
|
372
|
+
* - Empty-result → `NotFoundError` with folder context in the message
|
|
373
|
+
*
|
|
374
|
+
* The transform step is caller-provided because each resource has its own
|
|
375
|
+
* PascalCase → camelCase field mapping.
|
|
376
|
+
*
|
|
377
|
+
* @param resourceType - Resource label used in validation + error messages (e.g. 'Asset', 'Process')
|
|
378
|
+
* @param endpoint - Folder-scoped OData collection endpoint
|
|
379
|
+
* @param name - Resource name to search for
|
|
380
|
+
* @param options - Folder scoping (`folderId` / `folderKey` / `folderPath`) + OData query options (`expand`, `select`)
|
|
381
|
+
* @param transform - Maps a raw OData item to the typed response (e.g. PascalCase → camelCase via field map)
|
|
382
|
+
* @throws ValidationError when inputs are malformed; NotFoundError when no match
|
|
383
|
+
*/
|
|
384
|
+
protected getByNameLookup<TRaw extends object, T>(resourceType: string, endpoint: string, name: string, options: FolderScopedOptions, transform: (raw: TRaw) => T): Promise<T>;
|
|
385
|
+
}
|
|
319
386
|
|
|
320
387
|
/**
|
|
321
388
|
* Enum for package types
|
|
@@ -671,6 +738,11 @@ type ProcessGetAllOptions = RequestOptions & PaginationOptions & {
|
|
|
671
738
|
*/
|
|
672
739
|
interface ProcessGetByIdOptions extends BaseOptions {
|
|
673
740
|
}
|
|
741
|
+
/**
|
|
742
|
+
* Options for getting a single process by name
|
|
743
|
+
*/
|
|
744
|
+
interface ProcessGetByNameOptions extends FolderScopedOptions {
|
|
745
|
+
}
|
|
674
746
|
|
|
675
747
|
/**
|
|
676
748
|
* Service for managing and executing UiPath Automation Processes.
|
|
@@ -743,6 +815,29 @@ interface ProcessServiceModel {
|
|
|
743
815
|
* ```
|
|
744
816
|
*/
|
|
745
817
|
getById(id: number, folderId: number, options?: ProcessGetByIdOptions): Promise<ProcessGetResponse>;
|
|
818
|
+
/**
|
|
819
|
+
* Retrieves a single process by name.
|
|
820
|
+
*
|
|
821
|
+
* @param name - Process name to search for
|
|
822
|
+
* @param options - Folder scoping (`folderId` / `folderKey` / `folderPath`) and optional query parameters (`expand`, `select`)
|
|
823
|
+
* @returns Promise resolving to a single process
|
|
824
|
+
* {@link ProcessGetResponse}
|
|
825
|
+
* @example
|
|
826
|
+
* ```typescript
|
|
827
|
+
* // By folder ID
|
|
828
|
+
* await processes.getByName('MyProcess', { folderId: 123 });
|
|
829
|
+
*
|
|
830
|
+
* // By folder key (GUID)
|
|
831
|
+
* await processes.getByName('MyProcess', { folderKey: '5f6dadf1-3677-49dc-8aca-c2999dd4b3ba' });
|
|
832
|
+
*
|
|
833
|
+
* // By folder path
|
|
834
|
+
* await processes.getByName('MyProcess', { folderPath: 'Shared/Finance' });
|
|
835
|
+
*
|
|
836
|
+
* // With expand
|
|
837
|
+
* await processes.getByName('MyProcess', { folderPath: 'Shared/Finance', expand: 'entryPoints' });
|
|
838
|
+
* ```
|
|
839
|
+
*/
|
|
840
|
+
getByName(name: string, options?: ProcessGetByNameOptions): Promise<ProcessGetResponse>;
|
|
746
841
|
/**
|
|
747
842
|
* Starts a process with the specified configuration
|
|
748
843
|
*
|
|
@@ -770,7 +865,7 @@ interface ProcessServiceModel {
|
|
|
770
865
|
/**
|
|
771
866
|
* Service for interacting with UiPath Orchestrator Processes API
|
|
772
867
|
*/
|
|
773
|
-
declare class ProcessService extends
|
|
868
|
+
declare class ProcessService extends FolderScopedService implements ProcessServiceModel {
|
|
774
869
|
/**
|
|
775
870
|
* Gets all processes across folders with optional filtering and folder scoping
|
|
776
871
|
*
|
|
@@ -861,7 +956,34 @@ declare class ProcessService extends BaseService implements ProcessServiceModel
|
|
|
861
956
|
* ```
|
|
862
957
|
*/
|
|
863
958
|
getById(id: number, folderId: number, options?: ProcessGetByIdOptions): Promise<ProcessGetResponse>;
|
|
959
|
+
/**
|
|
960
|
+
* Retrieves a single process by name.
|
|
961
|
+
*
|
|
962
|
+
* @param name - Process name to search for
|
|
963
|
+
* @param options - Folder scoping (`folderId` / `folderKey` / `folderPath`) and optional query parameters (`expand`, `select`)
|
|
964
|
+
* @returns Promise resolving to a single process
|
|
965
|
+
* {@link ProcessGetResponse}
|
|
966
|
+
* @example
|
|
967
|
+
* ```typescript
|
|
968
|
+
* import { Processes } from '@uipath/uipath-typescript/processes';
|
|
969
|
+
*
|
|
970
|
+
* const processes = new Processes(sdk);
|
|
971
|
+
*
|
|
972
|
+
* // By folder ID
|
|
973
|
+
* await processes.getByName('MyProcess', { folderId: 123 });
|
|
974
|
+
*
|
|
975
|
+
* // By folder key (GUID)
|
|
976
|
+
* await processes.getByName('MyProcess', { folderKey: '5f6dadf1-3677-49dc-8aca-c2999dd4b3ba' });
|
|
977
|
+
*
|
|
978
|
+
* // By folder path
|
|
979
|
+
* await processes.getByName('MyProcess', { folderPath: 'Shared/Finance' });
|
|
980
|
+
*
|
|
981
|
+
* // With expand
|
|
982
|
+
* await processes.getByName('MyProcess', { folderPath: 'Shared/Finance', expand: 'entryPoints' });
|
|
983
|
+
* ```
|
|
984
|
+
*/
|
|
985
|
+
getByName(name: string, options?: ProcessGetByNameOptions): Promise<ProcessGetResponse>;
|
|
864
986
|
}
|
|
865
987
|
|
|
866
988
|
export { JobPriority, JobSourceType, JobType, PackageSourceType, PackageType, ProcessService, ProcessService as Processes, RemoteControlAccess, RobotSize, RuntimeType, StartStrategy, StopStrategy, TargetFramework };
|
|
867
|
-
export type { ArgumentMetadata, BaseProcessStartRequest, FolderProperties, JobAttachment, JobError, Machine, ProcessGetAllOptions, ProcessGetByIdOptions, ProcessGetResponse, ProcessProperties, ProcessServiceModel, ProcessStartRequest, ProcessStartRequestWithKey, ProcessStartRequestWithName, ProcessStartResponse, RobotMetadata };
|
|
989
|
+
export type { ArgumentMetadata, BaseProcessStartRequest, FolderProperties, JobAttachment, JobError, Machine, ProcessGetAllOptions, ProcessGetByIdOptions, ProcessGetByNameOptions, ProcessGetResponse, ProcessProperties, ProcessServiceModel, ProcessStartRequest, ProcessStartRequestWithKey, ProcessStartRequestWithName, ProcessStartResponse, RobotMetadata };
|
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';
|
|
@@ -1482,8 +1484,9 @@ class BaseService {
|
|
|
1482
1484
|
constructor(instance, headers) {
|
|
1483
1485
|
// Private field - not visible via Object.keys() or any reflection
|
|
1484
1486
|
_BaseService_apiClient.set(this, void 0);
|
|
1485
|
-
const { config, context, tokenManager } = SDKInternalsRegistry.get(instance);
|
|
1487
|
+
const { config, context, tokenManager, folderKey } = SDKInternalsRegistry.get(instance);
|
|
1486
1488
|
__classPrivateFieldSet(this, _BaseService_apiClient, new ApiClient(config, context, tokenManager, headers ? { headers } : {}), "f");
|
|
1489
|
+
this.config = { folderKey };
|
|
1487
1490
|
}
|
|
1488
1491
|
/**
|
|
1489
1492
|
* Gets a valid authentication token, refreshing if necessary.
|
|
@@ -1680,6 +1683,208 @@ class BaseService {
|
|
|
1680
1683
|
}
|
|
1681
1684
|
_BaseService_apiClient = new WeakMap();
|
|
1682
1685
|
|
|
1686
|
+
/**
|
|
1687
|
+
* Validates the `name` argument passed to a `getByName(name, ...)` method.
|
|
1688
|
+
* Trims whitespace and rejects empty/whitespace-only names.
|
|
1689
|
+
*
|
|
1690
|
+
* @param resourceType - Resource label used in error messages (e.g. 'Asset', 'Process')
|
|
1691
|
+
* @param name - Resource name to validate
|
|
1692
|
+
* @returns The trimmed name
|
|
1693
|
+
* @throws ValidationError when `name` is missing or empty after trimming
|
|
1694
|
+
*/
|
|
1695
|
+
function validateName(resourceType, name) {
|
|
1696
|
+
if (!name) {
|
|
1697
|
+
throw new ValidationError({
|
|
1698
|
+
message: `${resourceType} name is required and cannot be empty.`,
|
|
1699
|
+
});
|
|
1700
|
+
}
|
|
1701
|
+
const trimmed = name.trim();
|
|
1702
|
+
if (!trimmed) {
|
|
1703
|
+
throw new ValidationError({
|
|
1704
|
+
message: `${resourceType} name is required and cannot be empty.`,
|
|
1705
|
+
});
|
|
1706
|
+
}
|
|
1707
|
+
return trimmed;
|
|
1708
|
+
}
|
|
1709
|
+
|
|
1710
|
+
/**
|
|
1711
|
+
* Encodes a folder path for the `X-UIPATH-FolderPath-Encoded` header.
|
|
1712
|
+
*
|
|
1713
|
+
* Orchestrator decodes this header as **base64-encoded UTF-16 LE bytes**
|
|
1714
|
+
* (see `HttpHeadersProviderExtensions.GetDecoded` + `OrganizationUnitProvider`
|
|
1715
|
+
* in the Orchestrator repo, which call `Encoding.Unicode.GetString(...)`).
|
|
1716
|
+
* URL-encoding is NOT what the server expects — it must be base64-of-UTF-16-LE
|
|
1717
|
+
* bytes.
|
|
1718
|
+
*
|
|
1719
|
+
* @param folderPath - The folder path (e.g. 'Shared/Finance')
|
|
1720
|
+
* @returns Base64 string suitable for the `X-UIPATH-FolderPath-Encoded` header
|
|
1721
|
+
*/
|
|
1722
|
+
function encodeFolderPathHeader(folderPath) {
|
|
1723
|
+
// Force little-endian regardless of host byte order. `Uint16Array` viewed
|
|
1724
|
+
// as `Uint8Array` would use the host's native order — correct on LE hosts
|
|
1725
|
+
// (x86/ARM-LE) but wrong on BE hosts. `DataView.setUint16(..., true)`
|
|
1726
|
+
// pins LE.
|
|
1727
|
+
const buf = new ArrayBuffer(folderPath.length * 2);
|
|
1728
|
+
const view = new DataView(buf);
|
|
1729
|
+
for (let i = 0; i < folderPath.length; i++) {
|
|
1730
|
+
view.setUint16(i * 2, folderPath.charCodeAt(i), true);
|
|
1731
|
+
}
|
|
1732
|
+
const bytes = new Uint8Array(buf);
|
|
1733
|
+
let binary = '';
|
|
1734
|
+
for (let i = 0; i < bytes.byteLength; i++) {
|
|
1735
|
+
binary += String.fromCharCode(bytes[i]);
|
|
1736
|
+
}
|
|
1737
|
+
// btoa is browser-native; Node 16+ also has it as a global
|
|
1738
|
+
return btoa(binary);
|
|
1739
|
+
}
|
|
1740
|
+
|
|
1741
|
+
/**
|
|
1742
|
+
* Resolves folder context into the appropriate Orchestrator folder headers.
|
|
1743
|
+
*
|
|
1744
|
+
* Centralized so all folder-scoped methods (e.g. `assets.getByName`,
|
|
1745
|
+
* `processes.getByName`, future Queues/Buckets/Jobs) share one implementation.
|
|
1746
|
+
*
|
|
1747
|
+
* Each input field maps directly to its header — no auto-detection or type
|
|
1748
|
+
* coercion. When multiple fields are supplied, all corresponding headers
|
|
1749
|
+
* are forwarded and the server resolves precedence.
|
|
1750
|
+
*
|
|
1751
|
+
* Routing:
|
|
1752
|
+
* - `folderId` → `X-UIPATH-OrganizationUnitId`
|
|
1753
|
+
* - `folderKey` → `X-UIPATH-FolderKey`
|
|
1754
|
+
* - `folderPath` → `X-UIPATH-FolderPath-Encoded`
|
|
1755
|
+
* - none set + `fallbackFolderKey` → fallback used as `X-UIPATH-FolderKey`
|
|
1756
|
+
* - none set + no fallback → `ValidationError`
|
|
1757
|
+
*
|
|
1758
|
+
* @throws ValidationError when no folder context can be resolved.
|
|
1759
|
+
*/
|
|
1760
|
+
function resolveFolderHeaders(input) {
|
|
1761
|
+
const { folderId, folderKey, folderPath, resourceType, fallbackFolderKey } = input;
|
|
1762
|
+
const trimmedKey = folderKey?.trim();
|
|
1763
|
+
const trimmedPath = folderPath?.trim();
|
|
1764
|
+
const headers = {};
|
|
1765
|
+
if (folderId !== undefined) {
|
|
1766
|
+
headers[FOLDER_ID] = folderId;
|
|
1767
|
+
}
|
|
1768
|
+
if (trimmedKey) {
|
|
1769
|
+
headers[FOLDER_KEY] = trimmedKey;
|
|
1770
|
+
}
|
|
1771
|
+
if (trimmedPath) {
|
|
1772
|
+
headers[FOLDER_PATH_ENCODED] = encodeFolderPathHeader(trimmedPath);
|
|
1773
|
+
}
|
|
1774
|
+
// No explicit folder context → meta-tag fallback or error.
|
|
1775
|
+
if (Object.keys(headers).length === 0) {
|
|
1776
|
+
if (!fallbackFolderKey) {
|
|
1777
|
+
throw new ValidationError({
|
|
1778
|
+
message: `${resourceType} requires folder context: pass \`folderId\`, \`folderKey\`, or \`folderPath\`, or initialize the SDK with a folder context.`,
|
|
1779
|
+
});
|
|
1780
|
+
}
|
|
1781
|
+
headers[FOLDER_KEY] = fallbackFolderKey;
|
|
1782
|
+
}
|
|
1783
|
+
return createHeaders(headers);
|
|
1784
|
+
}
|
|
1785
|
+
|
|
1786
|
+
/**
|
|
1787
|
+
* Matches single-quote characters in OData string literals — escaped to `''`
|
|
1788
|
+
* inside the `$filter=Name eq '…'` clause built by `getByNameLookup`.
|
|
1789
|
+
*/
|
|
1790
|
+
const SINGLE_QUOTE_RE = /'/g;
|
|
1791
|
+
/**
|
|
1792
|
+
* Base service for services that need folder-specific functionality.
|
|
1793
|
+
*
|
|
1794
|
+
* Extends BaseService with additional methods for working with folder-scoped resources
|
|
1795
|
+
* in UiPath Orchestrator. Services that work with folders (Assets, Queues) extend this class.
|
|
1796
|
+
*
|
|
1797
|
+
* @remarks
|
|
1798
|
+
* This class provides helper methods for making folder-scoped API calls, handling folder IDs
|
|
1799
|
+
* in request headers, and managing cross-folder queries.
|
|
1800
|
+
*/
|
|
1801
|
+
class FolderScopedService extends BaseService {
|
|
1802
|
+
/**
|
|
1803
|
+
* Gets resources in a folder with optional query parameters
|
|
1804
|
+
*
|
|
1805
|
+
* @param endpoint - API endpoint to call
|
|
1806
|
+
* @param folderId - required folder ID
|
|
1807
|
+
* @param options - Query options
|
|
1808
|
+
* @param transformFn - Optional function to transform the response data
|
|
1809
|
+
* @returns Promise resolving to an array of resources
|
|
1810
|
+
*/
|
|
1811
|
+
async _getByFolder(endpoint, folderId, options = {}, transformFn) {
|
|
1812
|
+
const headers = createHeaders({ [FOLDER_ID]: folderId });
|
|
1813
|
+
const keysToPrefix = Object.keys(options);
|
|
1814
|
+
const apiOptions = addPrefixToKeys(options, ODATA_PREFIX, keysToPrefix);
|
|
1815
|
+
const response = await this.get(endpoint, {
|
|
1816
|
+
params: apiOptions,
|
|
1817
|
+
headers
|
|
1818
|
+
});
|
|
1819
|
+
if (transformFn) {
|
|
1820
|
+
return response.data?.value.map(transformFn);
|
|
1821
|
+
}
|
|
1822
|
+
return response.data?.value;
|
|
1823
|
+
}
|
|
1824
|
+
/**
|
|
1825
|
+
* Look up a single resource by name on a folder-scoped OData collection.
|
|
1826
|
+
*
|
|
1827
|
+
* Shared by `getByName` implementations across services (Assets, Processes, etc).
|
|
1828
|
+
* Handles:
|
|
1829
|
+
* - Name validation via `validateName`
|
|
1830
|
+
* - Folder header resolution via `resolveFolderHeaders` (folderId → ID/key
|
|
1831
|
+
* header by type, folderPath → encoded path header, falls back to
|
|
1832
|
+
* init-time `config.folderKey` from the `uipath:folder-key` meta tag)
|
|
1833
|
+
* - OData `$filter=Name eq '…'` with single-quote escaping + `$top=1`
|
|
1834
|
+
* - Empty-result → `NotFoundError` with folder context in the message
|
|
1835
|
+
*
|
|
1836
|
+
* The transform step is caller-provided because each resource has its own
|
|
1837
|
+
* PascalCase → camelCase field mapping.
|
|
1838
|
+
*
|
|
1839
|
+
* @param resourceType - Resource label used in validation + error messages (e.g. 'Asset', 'Process')
|
|
1840
|
+
* @param endpoint - Folder-scoped OData collection endpoint
|
|
1841
|
+
* @param name - Resource name to search for
|
|
1842
|
+
* @param options - Folder scoping (`folderId` / `folderKey` / `folderPath`) + OData query options (`expand`, `select`)
|
|
1843
|
+
* @param transform - Maps a raw OData item to the typed response (e.g. PascalCase → camelCase via field map)
|
|
1844
|
+
* @throws ValidationError when inputs are malformed; NotFoundError when no match
|
|
1845
|
+
*/
|
|
1846
|
+
async getByNameLookup(resourceType, endpoint, name, options, transform) {
|
|
1847
|
+
const validatedName = validateName(resourceType, name);
|
|
1848
|
+
const { folderId, folderKey, folderPath, ...queryOptions } = options;
|
|
1849
|
+
const headers = resolveFolderHeaders({
|
|
1850
|
+
folderId,
|
|
1851
|
+
folderKey,
|
|
1852
|
+
folderPath,
|
|
1853
|
+
resourceType: `${resourceType}.getByName`,
|
|
1854
|
+
fallbackFolderKey: this.config.folderKey,
|
|
1855
|
+
});
|
|
1856
|
+
const apiOptions = {
|
|
1857
|
+
...addPrefixToKeys(queryOptions, ODATA_PREFIX, Object.keys(queryOptions)),
|
|
1858
|
+
'$filter': `Name eq '${validatedName.replace(SINGLE_QUOTE_RE, "''")}'`,
|
|
1859
|
+
'$top': '1',
|
|
1860
|
+
};
|
|
1861
|
+
const response = await this.get(endpoint, {
|
|
1862
|
+
headers,
|
|
1863
|
+
params: apiOptions,
|
|
1864
|
+
});
|
|
1865
|
+
const items = response.data?.value;
|
|
1866
|
+
if (!items?.length) {
|
|
1867
|
+
const folderHint = describeFolderForError(folderId, folderKey, folderPath);
|
|
1868
|
+
throw new NotFoundError({
|
|
1869
|
+
message: `${resourceType} '${validatedName}' not found${folderHint}.`,
|
|
1870
|
+
});
|
|
1871
|
+
}
|
|
1872
|
+
return transform(items[0]);
|
|
1873
|
+
}
|
|
1874
|
+
}
|
|
1875
|
+
/** Renders the supplied folder for a NotFoundError message. */
|
|
1876
|
+
function describeFolderForError(folderId, folderKey, folderPath) {
|
|
1877
|
+
const path = folderPath?.trim();
|
|
1878
|
+
if (path)
|
|
1879
|
+
return ` in folder '${path}'`;
|
|
1880
|
+
const key = folderKey?.trim();
|
|
1881
|
+
if (key)
|
|
1882
|
+
return ` in folder (key: ${key})`;
|
|
1883
|
+
if (typeof folderId === 'number')
|
|
1884
|
+
return ` in folder (id: ${folderId})`;
|
|
1885
|
+
return '';
|
|
1886
|
+
}
|
|
1887
|
+
|
|
1683
1888
|
/**
|
|
1684
1889
|
* Maps fields for Process entities to ensure consistent naming
|
|
1685
1890
|
*/
|
|
@@ -1720,7 +1925,7 @@ const PROCESS_ENDPOINTS = {
|
|
|
1720
1925
|
// Connection string placeholder that will be replaced during build
|
|
1721
1926
|
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
1927
|
// SDK Version placeholder
|
|
1723
|
-
const SDK_VERSION = "1.3.
|
|
1928
|
+
const SDK_VERSION = "1.3.7";
|
|
1724
1929
|
const VERSION = "Version";
|
|
1725
1930
|
const SERVICE = "Service";
|
|
1726
1931
|
const CLOUD_ORGANIZATION_NAME = "CloudOrganizationName";
|
|
@@ -1991,7 +2196,7 @@ function track(nameOrOptions, options) {
|
|
|
1991
2196
|
/**
|
|
1992
2197
|
* Service for interacting with UiPath Orchestrator Processes API
|
|
1993
2198
|
*/
|
|
1994
|
-
class ProcessService extends
|
|
2199
|
+
class ProcessService extends FolderScopedService {
|
|
1995
2200
|
/**
|
|
1996
2201
|
* Gets all processes across folders with optional filtering and folder scoping
|
|
1997
2202
|
*
|
|
@@ -2128,6 +2333,35 @@ class ProcessService extends BaseService {
|
|
|
2128
2333
|
const transformedProcess = transformData(pascalToCamelCaseKeys(response.data), ProcessMap);
|
|
2129
2334
|
return transformedProcess;
|
|
2130
2335
|
}
|
|
2336
|
+
/**
|
|
2337
|
+
* Retrieves a single process by name.
|
|
2338
|
+
*
|
|
2339
|
+
* @param name - Process name to search for
|
|
2340
|
+
* @param options - Folder scoping (`folderId` / `folderKey` / `folderPath`) and optional query parameters (`expand`, `select`)
|
|
2341
|
+
* @returns Promise resolving to a single process
|
|
2342
|
+
* {@link ProcessGetResponse}
|
|
2343
|
+
* @example
|
|
2344
|
+
* ```typescript
|
|
2345
|
+
* import { Processes } from '@uipath/uipath-typescript/processes';
|
|
2346
|
+
*
|
|
2347
|
+
* const processes = new Processes(sdk);
|
|
2348
|
+
*
|
|
2349
|
+
* // By folder ID
|
|
2350
|
+
* await processes.getByName('MyProcess', { folderId: 123 });
|
|
2351
|
+
*
|
|
2352
|
+
* // By folder key (GUID)
|
|
2353
|
+
* await processes.getByName('MyProcess', { folderKey: '5f6dadf1-3677-49dc-8aca-c2999dd4b3ba' });
|
|
2354
|
+
*
|
|
2355
|
+
* // By folder path
|
|
2356
|
+
* await processes.getByName('MyProcess', { folderPath: 'Shared/Finance' });
|
|
2357
|
+
*
|
|
2358
|
+
* // With expand
|
|
2359
|
+
* await processes.getByName('MyProcess', { folderPath: 'Shared/Finance', expand: 'entryPoints' });
|
|
2360
|
+
* ```
|
|
2361
|
+
*/
|
|
2362
|
+
async getByName(name, options = {}) {
|
|
2363
|
+
return this.getByNameLookup('Process', PROCESS_ENDPOINTS.GET_ALL, name, options, (raw) => transformData(pascalToCamelCaseKeys(raw), ProcessMap));
|
|
2364
|
+
}
|
|
2131
2365
|
}
|
|
2132
2366
|
__decorate([
|
|
2133
2367
|
track('Processes.GetAll')
|
|
@@ -2138,6 +2372,9 @@ __decorate([
|
|
|
2138
2372
|
__decorate([
|
|
2139
2373
|
track('Processes.GetById')
|
|
2140
2374
|
], ProcessService.prototype, "getById", null);
|
|
2375
|
+
__decorate([
|
|
2376
|
+
track('Processes.GetByName')
|
|
2377
|
+
], ProcessService.prototype, "getByName", null);
|
|
2141
2378
|
|
|
2142
2379
|
/**
|
|
2143
2380
|
* 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';
|
|
@@ -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
|
/**
|
|
@@ -1686,7 +1856,7 @@ const QueueMap = {
|
|
|
1686
1856
|
// Connection string placeholder that will be replaced during build
|
|
1687
1857
|
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
1858
|
// SDK Version placeholder
|
|
1689
|
-
const SDK_VERSION = "1.3.
|
|
1859
|
+
const SDK_VERSION = "1.3.7";
|
|
1690
1860
|
const VERSION = "Version";
|
|
1691
1861
|
const SERVICE = "Service";
|
|
1692
1862
|
const CLOUD_ORGANIZATION_NAME = "CloudOrganizationName";
|