@uipath/uipath-typescript 1.3.11 → 1.4.0
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/agent-memory/index.cjs +1765 -0
- package/dist/agent-memory/index.d.ts +588 -0
- package/dist/agent-memory/index.mjs +1763 -0
- package/dist/agents/index.cjs +1726 -0
- package/dist/agents/index.d.ts +502 -0
- package/dist/agents/index.mjs +1724 -0
- package/dist/assets/index.cjs +155 -30
- package/dist/assets/index.d.ts +84 -5
- package/dist/assets/index.mjs +155 -30
- package/dist/attachments/index.cjs +37 -6
- package/dist/attachments/index.d.ts +1 -0
- package/dist/attachments/index.mjs +37 -6
- package/dist/buckets/index.cjs +37 -6
- package/dist/buckets/index.d.ts +1 -0
- package/dist/buckets/index.mjs +37 -6
- package/dist/cases/index.cjs +141 -10
- package/dist/cases/index.d.ts +118 -7
- package/dist/cases/index.mjs +141 -11
- package/dist/conversational-agent/index.cjs +124 -57
- package/dist/conversational-agent/index.d.ts +190 -122
- package/dist/conversational-agent/index.mjs +124 -57
- package/dist/core/index.cjs +413 -105
- package/dist/core/index.d.ts +15 -0
- package/dist/core/index.mjs +413 -105
- package/dist/entities/index.cjs +122 -43
- package/dist/entities/index.d.ts +140 -35
- package/dist/entities/index.mjs +122 -43
- package/dist/feedback/index.cjs +37 -6
- package/dist/feedback/index.d.ts +1 -0
- package/dist/feedback/index.mjs +37 -6
- package/dist/governance/index.cjs +1782 -0
- package/dist/governance/index.d.ts +598 -0
- package/dist/governance/index.mjs +1780 -0
- package/dist/index.cjs +956 -283
- package/dist/index.d.ts +1138 -121
- package/dist/index.mjs +956 -284
- package/dist/index.umd.js +3113 -2423
- package/dist/jobs/index.cjs +37 -6
- package/dist/jobs/index.d.ts +1 -0
- package/dist/jobs/index.mjs +37 -6
- package/dist/maestro-processes/index.cjs +173 -18
- package/dist/maestro-processes/index.d.ts +131 -9
- package/dist/maestro-processes/index.mjs +173 -18
- package/dist/processes/index.cjs +37 -6
- package/dist/processes/index.d.ts +1 -0
- package/dist/processes/index.mjs +37 -6
- package/dist/queues/index.cjs +37 -6
- package/dist/queues/index.d.ts +1 -0
- package/dist/queues/index.mjs +37 -6
- package/dist/tasks/index.cjs +37 -6
- package/dist/tasks/index.d.ts +1 -0
- package/dist/tasks/index.mjs +37 -6
- package/dist/traces/index.cjs +37 -6
- package/dist/traces/index.d.ts +1 -0
- package/dist/traces/index.mjs +37 -6
- package/package.json +32 -2
package/dist/assets/index.cjs
CHANGED
|
@@ -721,6 +721,32 @@ function filterUndefined(obj) {
|
|
|
721
721
|
*/
|
|
722
722
|
const isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
|
|
723
723
|
isBrowser && window.self != window.top && window.location.href.includes('source=ActionCenter');
|
|
724
|
+
const _params = isBrowser ? new URLSearchParams(window.location.search) : null;
|
|
725
|
+
/**
|
|
726
|
+
* True when the coded app has been loaded inside a host frame that explicitly
|
|
727
|
+
* opted into token delegation by adding `?host=embed` to the iframe src URL.
|
|
728
|
+
*/
|
|
729
|
+
const isHostEmbedded = isBrowser && window.self !== window.top && _params?.get('host') === 'embed';
|
|
730
|
+
/**
|
|
731
|
+
* The validated parent origin, read from the `?basedomain=` query param set
|
|
732
|
+
* by the embedding host in the iframe src URL.
|
|
733
|
+
* Mirrors the same mechanism used by ActionCenterTokenManager.
|
|
734
|
+
* Non-null only when `?host=embed` is present and `?basedomain=` is a valid URL.
|
|
735
|
+
*/
|
|
736
|
+
(() => {
|
|
737
|
+
if (!isHostEmbedded)
|
|
738
|
+
return null;
|
|
739
|
+
const basedomain = _params?.get('basedomain');
|
|
740
|
+
if (!basedomain)
|
|
741
|
+
return null;
|
|
742
|
+
try {
|
|
743
|
+
return new URL(basedomain).origin;
|
|
744
|
+
}
|
|
745
|
+
catch {
|
|
746
|
+
console.warn('embeddingOrigin: basedomain query param is not a valid URL', basedomain);
|
|
747
|
+
return null;
|
|
748
|
+
}
|
|
749
|
+
})();
|
|
724
750
|
|
|
725
751
|
/**
|
|
726
752
|
* Base64 encoding/decoding
|
|
@@ -1281,8 +1307,9 @@ class PaginationHelpers {
|
|
|
1281
1307
|
});
|
|
1282
1308
|
}
|
|
1283
1309
|
// Extract and transform items from response
|
|
1284
|
-
// Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N })
|
|
1285
|
-
|
|
1310
|
+
// Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N }).
|
|
1311
|
+
// itemsField may be a dotted path (e.g. 'data.agents') for nested envelopes.
|
|
1312
|
+
const rawItems = Array.isArray(response.data) ? response.data : resolveNestedField(response.data, itemsField);
|
|
1286
1313
|
const rawTotalCount = Array.isArray(response.data) ? undefined : resolveNestedField(response.data, totalCountField);
|
|
1287
1314
|
const totalCount = typeof rawTotalCount === 'number' ? rawTotalCount : undefined;
|
|
1288
1315
|
// Parse items - automatically handle JSON string responses
|
|
@@ -1328,7 +1355,7 @@ class PaginationHelpers {
|
|
|
1328
1355
|
getEndpoint: config.getEndpoint,
|
|
1329
1356
|
folderId,
|
|
1330
1357
|
headers: config.headers,
|
|
1331
|
-
paginationParams: cursor ? { cursor, pageSize } : jumpToPage ? { jumpToPage, pageSize } : { pageSize },
|
|
1358
|
+
paginationParams: cursor ? { cursor, pageSize } : jumpToPage !== undefined ? { jumpToPage, pageSize } : { pageSize },
|
|
1332
1359
|
additionalParams: prefixedOptions,
|
|
1333
1360
|
transformFn: config.transformFn,
|
|
1334
1361
|
method: config.method,
|
|
@@ -1586,6 +1613,8 @@ class BaseService {
|
|
|
1586
1613
|
// When true (default), converts pageNumber to a skip/offset value (e.g., page 3 with pageSize 10 → skip 20).
|
|
1587
1614
|
// When false, passes pageNumber directly as the offset param — used by APIs that accept a page number instead of a record offset.
|
|
1588
1615
|
const convertToSkip = paginationParams?.convertToSkip ?? true;
|
|
1616
|
+
// When true, sends pageNumber - 1 (for 0-based APIs). Default false (1-based).
|
|
1617
|
+
const zeroBased = paginationParams?.zeroBased ?? false;
|
|
1589
1618
|
requestParams[pageSizeParam] = limitedPageSize;
|
|
1590
1619
|
if (convertToSkip) {
|
|
1591
1620
|
if (params.pageNumber && params.pageNumber > 1) {
|
|
@@ -1593,7 +1622,8 @@ class BaseService {
|
|
|
1593
1622
|
}
|
|
1594
1623
|
}
|
|
1595
1624
|
else {
|
|
1596
|
-
|
|
1625
|
+
const sdkPageNumber = params.pageNumber || 1;
|
|
1626
|
+
requestParams[offsetParam] = zeroBased ? sdkPageNumber - 1 : sdkPageNumber;
|
|
1597
1627
|
}
|
|
1598
1628
|
{
|
|
1599
1629
|
requestParams[countParam] = true;
|
|
@@ -1622,8 +1652,9 @@ class BaseService {
|
|
|
1622
1652
|
const totalCountField = fields.totalCountField || 'totalRecordCount';
|
|
1623
1653
|
const continuationTokenField = fields.continuationTokenField || 'continuationToken';
|
|
1624
1654
|
// Extract items and metadata
|
|
1625
|
-
// Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N })
|
|
1626
|
-
|
|
1655
|
+
// Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N }).
|
|
1656
|
+
// itemsField may be a dotted path (e.g. 'data.agents') for nested envelopes.
|
|
1657
|
+
const items = Array.isArray(response.data) ? response.data : (resolveNestedField(response.data, itemsField) || []);
|
|
1627
1658
|
const rawTotalCount = Array.isArray(response.data) ? undefined : resolveNestedField(response.data, totalCountField);
|
|
1628
1659
|
const totalCount = typeof rawTotalCount === 'number' ? rawTotalCount : undefined;
|
|
1629
1660
|
const continuationToken = response.data[continuationTokenField];
|
|
@@ -1872,6 +1903,26 @@ function describeFolderForError(folderId, folderKey, folderPath) {
|
|
|
1872
1903
|
return '';
|
|
1873
1904
|
}
|
|
1874
1905
|
|
|
1906
|
+
/**
|
|
1907
|
+
* Enum for Asset Value Scope
|
|
1908
|
+
*/
|
|
1909
|
+
exports.AssetValueScope = void 0;
|
|
1910
|
+
(function (AssetValueScope) {
|
|
1911
|
+
AssetValueScope["Global"] = "Global";
|
|
1912
|
+
AssetValueScope["PerRobot"] = "PerRobot";
|
|
1913
|
+
})(exports.AssetValueScope || (exports.AssetValueScope = {}));
|
|
1914
|
+
/**
|
|
1915
|
+
* Enum for Asset Value Type
|
|
1916
|
+
*/
|
|
1917
|
+
exports.AssetValueType = void 0;
|
|
1918
|
+
(function (AssetValueType) {
|
|
1919
|
+
AssetValueType["Text"] = "Text";
|
|
1920
|
+
AssetValueType["Bool"] = "Bool";
|
|
1921
|
+
AssetValueType["Integer"] = "Integer";
|
|
1922
|
+
AssetValueType["Credential"] = "Credential";
|
|
1923
|
+
AssetValueType["Secret"] = "Secret";
|
|
1924
|
+
})(exports.AssetValueType || (exports.AssetValueType = {}));
|
|
1925
|
+
|
|
1875
1926
|
/**
|
|
1876
1927
|
* Base path constants for different services
|
|
1877
1928
|
*/
|
|
@@ -2042,6 +2093,68 @@ class AssetService extends FolderScopedService {
|
|
|
2042
2093
|
async getByName(name, options = {}) {
|
|
2043
2094
|
return this.getByNameLookup('Asset', ASSET_ENDPOINTS.GET_BY_FOLDER, name, options, (raw) => transformData(pascalToCamelCaseKeys(raw), AssetMap));
|
|
2044
2095
|
}
|
|
2096
|
+
/**
|
|
2097
|
+
* Updates the value of an existing asset by ID.
|
|
2098
|
+
*
|
|
2099
|
+
* Fetches the asset internally to determine its type, then updates only the value while
|
|
2100
|
+
* preserving the asset's name, scope, and description.
|
|
2101
|
+
*
|
|
2102
|
+
* **Supported value types:** `Text`, `Integer`, and `Bool` only. Other types
|
|
2103
|
+
* (`Credential`, `Secret`) throw a `ValidationError`.
|
|
2104
|
+
*
|
|
2105
|
+
* The `newValue` runtime type must match the asset's `valueType`:
|
|
2106
|
+
* - `Text` → `string`
|
|
2107
|
+
* - `Integer` → `number` (integer)
|
|
2108
|
+
* - `Bool` → `boolean`
|
|
2109
|
+
*
|
|
2110
|
+
* @param id - Asset ID
|
|
2111
|
+
* @param newValue - New value to apply (string for `Text`, number for `Integer`, boolean for `Bool`)
|
|
2112
|
+
* @param options - Folder scoping (`folderId` / `folderKey` / `folderPath`)
|
|
2113
|
+
* @returns Promise resolving when the asset has been updated
|
|
2114
|
+
*
|
|
2115
|
+
* @example
|
|
2116
|
+
* ```typescript
|
|
2117
|
+
* import { Assets } from '@uipath/uipath-typescript/assets';
|
|
2118
|
+
*
|
|
2119
|
+
* const assets = new Assets(sdk);
|
|
2120
|
+
*
|
|
2121
|
+
* // Update a Text asset by folder ID
|
|
2122
|
+
* await assets.updateValueById(<assetId>, 'new-value', { folderId: <folderId> });
|
|
2123
|
+
*
|
|
2124
|
+
* // Update an Integer asset by folder key (GUID)
|
|
2125
|
+
* await assets.updateValueById(<assetId>, 42, { folderKey: '5f6dadf1-3677-49dc-8aca-c2999dd4b3ba' });
|
|
2126
|
+
*
|
|
2127
|
+
* // Update a Bool asset by folder path
|
|
2128
|
+
* await assets.updateValueById(<assetId>, true, { folderPath: 'Shared/Finance' });
|
|
2129
|
+
* ```
|
|
2130
|
+
*/
|
|
2131
|
+
async updateValueById(id, newValue, options) {
|
|
2132
|
+
if (!id) {
|
|
2133
|
+
throw new ValidationError({ message: 'id is required for updateValueById' });
|
|
2134
|
+
}
|
|
2135
|
+
if (newValue === null || newValue === undefined) {
|
|
2136
|
+
throw new ValidationError({ message: 'newValue is required for updateValueById' });
|
|
2137
|
+
}
|
|
2138
|
+
const headers = resolveFolderHeaders({
|
|
2139
|
+
folderId: options?.folderId,
|
|
2140
|
+
folderKey: options?.folderKey,
|
|
2141
|
+
folderPath: options?.folderPath,
|
|
2142
|
+
resourceType: 'Assets.updateValueById',
|
|
2143
|
+
fallbackFolderKey: this.config.folderKey,
|
|
2144
|
+
});
|
|
2145
|
+
const existingResponse = await this.get(ASSET_ENDPOINTS.GET_BY_ID(id), { headers });
|
|
2146
|
+
const existing = existingResponse.data;
|
|
2147
|
+
const valueField = resolveValueField(id, existing.ValueType, newValue);
|
|
2148
|
+
const body = {
|
|
2149
|
+
Id: id,
|
|
2150
|
+
Name: existing.Name,
|
|
2151
|
+
ValueScope: existing.ValueScope,
|
|
2152
|
+
ValueType: existing.ValueType,
|
|
2153
|
+
Description: existing.Description,
|
|
2154
|
+
[valueField]: newValue,
|
|
2155
|
+
};
|
|
2156
|
+
await this.put(ASSET_ENDPOINTS.GET_BY_ID(id), body, { headers });
|
|
2157
|
+
}
|
|
2045
2158
|
}
|
|
2046
2159
|
__decorate([
|
|
2047
2160
|
track('Assets.GetAll')
|
|
@@ -2052,30 +2165,42 @@ __decorate([
|
|
|
2052
2165
|
__decorate([
|
|
2053
2166
|
track('Assets.GetByName')
|
|
2054
2167
|
], AssetService.prototype, "getByName", null);
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2168
|
+
__decorate([
|
|
2169
|
+
track('Assets.UpdateValueById')
|
|
2170
|
+
], AssetService.prototype, "updateValueById", null);
|
|
2171
|
+
/**
|
|
2172
|
+
* Maps the asset's `valueType` to the PUT body field carrying the new value, validating
|
|
2173
|
+
* that the new value's runtime type matches the asset type.
|
|
2174
|
+
*/
|
|
2175
|
+
function resolveValueField(id, valueType, newValue) {
|
|
2176
|
+
switch (valueType) {
|
|
2177
|
+
case exports.AssetValueType.Text:
|
|
2178
|
+
if (typeof newValue !== 'string') {
|
|
2179
|
+
throw new ValidationError({
|
|
2180
|
+
message: `Asset ${id} has valueType Text; newValue must be a string, got ${typeof newValue}`,
|
|
2181
|
+
});
|
|
2182
|
+
}
|
|
2183
|
+
return 'StringValue';
|
|
2184
|
+
case exports.AssetValueType.Integer:
|
|
2185
|
+
if (typeof newValue !== 'number' || !Number.isInteger(newValue)) {
|
|
2186
|
+
throw new ValidationError({
|
|
2187
|
+
message: `Asset ${id} has valueType Integer; newValue must be an integer number, got ${typeof newValue}`,
|
|
2188
|
+
});
|
|
2189
|
+
}
|
|
2190
|
+
return 'IntValue';
|
|
2191
|
+
case exports.AssetValueType.Bool:
|
|
2192
|
+
if (typeof newValue !== 'boolean') {
|
|
2193
|
+
throw new ValidationError({
|
|
2194
|
+
message: `Asset ${id} has valueType Bool; newValue must be a boolean, got ${typeof newValue}`,
|
|
2195
|
+
});
|
|
2196
|
+
}
|
|
2197
|
+
return 'BoolValue';
|
|
2198
|
+
default:
|
|
2199
|
+
throw new ValidationError({
|
|
2200
|
+
message: `updateValueById only supports Text, Integer, or Bool assets; asset ${id} has valueType ${valueType}`,
|
|
2201
|
+
});
|
|
2202
|
+
}
|
|
2203
|
+
}
|
|
2079
2204
|
|
|
2080
2205
|
exports.AssetService = AssetService;
|
|
2081
2206
|
exports.Assets = AssetService;
|
package/dist/assets/index.d.ts
CHANGED
|
@@ -107,6 +107,7 @@ interface RequestWithPaginationOptions extends RequestSpec {
|
|
|
107
107
|
tokenParam?: string;
|
|
108
108
|
countParam?: string;
|
|
109
109
|
convertToSkip?: boolean;
|
|
110
|
+
zeroBased?: boolean;
|
|
110
111
|
};
|
|
111
112
|
};
|
|
112
113
|
}
|
|
@@ -382,14 +383,10 @@ declare enum AssetValueScope {
|
|
|
382
383
|
* Enum for Asset Value Type
|
|
383
384
|
*/
|
|
384
385
|
declare enum AssetValueType {
|
|
385
|
-
DBConnectionString = "DBConnectionString",
|
|
386
|
-
HttpConnectionString = "HttpConnectionString",
|
|
387
386
|
Text = "Text",
|
|
388
387
|
Bool = "Bool",
|
|
389
388
|
Integer = "Integer",
|
|
390
389
|
Credential = "Credential",
|
|
391
|
-
WindowsCredential = "WindowsCredential",
|
|
392
|
-
KeyValueList = "KeyValueList",
|
|
393
390
|
Secret = "Secret"
|
|
394
391
|
}
|
|
395
392
|
/**
|
|
@@ -439,6 +436,20 @@ interface AssetGetByIdOptions extends BaseOptions {
|
|
|
439
436
|
*/
|
|
440
437
|
interface AssetGetByNameOptions extends FolderScopedOptions {
|
|
441
438
|
}
|
|
439
|
+
/**
|
|
440
|
+
* New value accepted by {@link AssetServiceModel.updateValueById}.
|
|
441
|
+
*
|
|
442
|
+
* The runtime type must match the asset's `valueType`:
|
|
443
|
+
* - `Text` → `string`
|
|
444
|
+
* - `Integer` → `number`
|
|
445
|
+
* - `Bool` → `boolean`
|
|
446
|
+
*/
|
|
447
|
+
type AssetNewValue = string | number | boolean;
|
|
448
|
+
/**
|
|
449
|
+
* Options for updating an asset value by ID
|
|
450
|
+
*/
|
|
451
|
+
interface AssetUpdateValueByIdOptions extends FolderScopedOptions {
|
|
452
|
+
}
|
|
442
453
|
|
|
443
454
|
/**
|
|
444
455
|
* Service for managing UiPath Assets.
|
|
@@ -523,6 +534,38 @@ interface AssetServiceModel {
|
|
|
523
534
|
* ```
|
|
524
535
|
*/
|
|
525
536
|
getByName(name: string, options?: AssetGetByNameOptions): Promise<AssetGetResponse>;
|
|
537
|
+
/**
|
|
538
|
+
* Updates the value of an existing asset by ID.
|
|
539
|
+
*
|
|
540
|
+
* Fetches the asset internally to determine its type, then updates only the value while
|
|
541
|
+
* preserving the asset's name, scope, and description.
|
|
542
|
+
*
|
|
543
|
+
* **Supported value types:** `Text`, `Integer`, and `Bool` only. Other types
|
|
544
|
+
* (`Credential`, `Secret`) throw a `ValidationError`.
|
|
545
|
+
*
|
|
546
|
+
* The `newValue` runtime type must match the asset's `valueType`:
|
|
547
|
+
* - `Text` → `string`
|
|
548
|
+
* - `Integer` → `number` (integer)
|
|
549
|
+
* - `Bool` → `boolean`
|
|
550
|
+
*
|
|
551
|
+
* @param id - Asset ID
|
|
552
|
+
* @param newValue - New value to apply (string for `Text`, number for `Integer`, boolean for `Bool`)
|
|
553
|
+
* @param options - Folder scoping (`folderId` / `folderKey` / `folderPath`)
|
|
554
|
+
* @returns Promise resolving when the asset has been updated
|
|
555
|
+
*
|
|
556
|
+
* @example
|
|
557
|
+
* ```typescript
|
|
558
|
+
* // Update a Text asset by folder ID
|
|
559
|
+
* await assets.updateValueById(<assetId>, 'new-value', { folderId: <folderId> });
|
|
560
|
+
*
|
|
561
|
+
* // Update an Integer asset by folder key (GUID)
|
|
562
|
+
* await assets.updateValueById(<assetId>, 42, { folderKey: '5f6dadf1-3677-49dc-8aca-c2999dd4b3ba' });
|
|
563
|
+
*
|
|
564
|
+
* // Update a Bool asset by folder path
|
|
565
|
+
* await assets.updateValueById(<assetId>, true, { folderPath: 'Shared/Finance' });
|
|
566
|
+
* ```
|
|
567
|
+
*/
|
|
568
|
+
updateValueById(id: number, newValue: AssetNewValue, options?: AssetUpdateValueByIdOptions): Promise<void>;
|
|
526
569
|
}
|
|
527
570
|
|
|
528
571
|
/**
|
|
@@ -610,7 +653,43 @@ declare class AssetService extends FolderScopedService implements AssetServiceMo
|
|
|
610
653
|
* ```
|
|
611
654
|
*/
|
|
612
655
|
getByName(name: string, options?: AssetGetByNameOptions): Promise<AssetGetResponse>;
|
|
656
|
+
/**
|
|
657
|
+
* Updates the value of an existing asset by ID.
|
|
658
|
+
*
|
|
659
|
+
* Fetches the asset internally to determine its type, then updates only the value while
|
|
660
|
+
* preserving the asset's name, scope, and description.
|
|
661
|
+
*
|
|
662
|
+
* **Supported value types:** `Text`, `Integer`, and `Bool` only. Other types
|
|
663
|
+
* (`Credential`, `Secret`) throw a `ValidationError`.
|
|
664
|
+
*
|
|
665
|
+
* The `newValue` runtime type must match the asset's `valueType`:
|
|
666
|
+
* - `Text` → `string`
|
|
667
|
+
* - `Integer` → `number` (integer)
|
|
668
|
+
* - `Bool` → `boolean`
|
|
669
|
+
*
|
|
670
|
+
* @param id - Asset ID
|
|
671
|
+
* @param newValue - New value to apply (string for `Text`, number for `Integer`, boolean for `Bool`)
|
|
672
|
+
* @param options - Folder scoping (`folderId` / `folderKey` / `folderPath`)
|
|
673
|
+
* @returns Promise resolving when the asset has been updated
|
|
674
|
+
*
|
|
675
|
+
* @example
|
|
676
|
+
* ```typescript
|
|
677
|
+
* import { Assets } from '@uipath/uipath-typescript/assets';
|
|
678
|
+
*
|
|
679
|
+
* const assets = new Assets(sdk);
|
|
680
|
+
*
|
|
681
|
+
* // Update a Text asset by folder ID
|
|
682
|
+
* await assets.updateValueById(<assetId>, 'new-value', { folderId: <folderId> });
|
|
683
|
+
*
|
|
684
|
+
* // Update an Integer asset by folder key (GUID)
|
|
685
|
+
* await assets.updateValueById(<assetId>, 42, { folderKey: '5f6dadf1-3677-49dc-8aca-c2999dd4b3ba' });
|
|
686
|
+
*
|
|
687
|
+
* // Update a Bool asset by folder path
|
|
688
|
+
* await assets.updateValueById(<assetId>, true, { folderPath: 'Shared/Finance' });
|
|
689
|
+
* ```
|
|
690
|
+
*/
|
|
691
|
+
updateValueById(id: number, newValue: AssetNewValue, options?: AssetUpdateValueByIdOptions): Promise<void>;
|
|
613
692
|
}
|
|
614
693
|
|
|
615
694
|
export { AssetService, AssetValueScope, AssetValueType, AssetService as Assets };
|
|
616
|
-
export type { AssetGetAllOptions, AssetGetByIdOptions, AssetGetByNameOptions, AssetGetResponse, AssetServiceModel, CustomKeyValuePair };
|
|
695
|
+
export type { AssetGetAllOptions, AssetGetByIdOptions, AssetGetByNameOptions, AssetGetResponse, AssetNewValue, AssetServiceModel, AssetUpdateValueByIdOptions, CustomKeyValuePair };
|
package/dist/assets/index.mjs
CHANGED
|
@@ -719,6 +719,32 @@ function filterUndefined(obj) {
|
|
|
719
719
|
*/
|
|
720
720
|
const isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
|
|
721
721
|
isBrowser && window.self != window.top && window.location.href.includes('source=ActionCenter');
|
|
722
|
+
const _params = isBrowser ? new URLSearchParams(window.location.search) : null;
|
|
723
|
+
/**
|
|
724
|
+
* True when the coded app has been loaded inside a host frame that explicitly
|
|
725
|
+
* opted into token delegation by adding `?host=embed` to the iframe src URL.
|
|
726
|
+
*/
|
|
727
|
+
const isHostEmbedded = isBrowser && window.self !== window.top && _params?.get('host') === 'embed';
|
|
728
|
+
/**
|
|
729
|
+
* The validated parent origin, read from the `?basedomain=` query param set
|
|
730
|
+
* by the embedding host in the iframe src URL.
|
|
731
|
+
* Mirrors the same mechanism used by ActionCenterTokenManager.
|
|
732
|
+
* Non-null only when `?host=embed` is present and `?basedomain=` is a valid URL.
|
|
733
|
+
*/
|
|
734
|
+
(() => {
|
|
735
|
+
if (!isHostEmbedded)
|
|
736
|
+
return null;
|
|
737
|
+
const basedomain = _params?.get('basedomain');
|
|
738
|
+
if (!basedomain)
|
|
739
|
+
return null;
|
|
740
|
+
try {
|
|
741
|
+
return new URL(basedomain).origin;
|
|
742
|
+
}
|
|
743
|
+
catch {
|
|
744
|
+
console.warn('embeddingOrigin: basedomain query param is not a valid URL', basedomain);
|
|
745
|
+
return null;
|
|
746
|
+
}
|
|
747
|
+
})();
|
|
722
748
|
|
|
723
749
|
/**
|
|
724
750
|
* Base64 encoding/decoding
|
|
@@ -1279,8 +1305,9 @@ class PaginationHelpers {
|
|
|
1279
1305
|
});
|
|
1280
1306
|
}
|
|
1281
1307
|
// Extract and transform items from response
|
|
1282
|
-
// Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N })
|
|
1283
|
-
|
|
1308
|
+
// Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N }).
|
|
1309
|
+
// itemsField may be a dotted path (e.g. 'data.agents') for nested envelopes.
|
|
1310
|
+
const rawItems = Array.isArray(response.data) ? response.data : resolveNestedField(response.data, itemsField);
|
|
1284
1311
|
const rawTotalCount = Array.isArray(response.data) ? undefined : resolveNestedField(response.data, totalCountField);
|
|
1285
1312
|
const totalCount = typeof rawTotalCount === 'number' ? rawTotalCount : undefined;
|
|
1286
1313
|
// Parse items - automatically handle JSON string responses
|
|
@@ -1326,7 +1353,7 @@ class PaginationHelpers {
|
|
|
1326
1353
|
getEndpoint: config.getEndpoint,
|
|
1327
1354
|
folderId,
|
|
1328
1355
|
headers: config.headers,
|
|
1329
|
-
paginationParams: cursor ? { cursor, pageSize } : jumpToPage ? { jumpToPage, pageSize } : { pageSize },
|
|
1356
|
+
paginationParams: cursor ? { cursor, pageSize } : jumpToPage !== undefined ? { jumpToPage, pageSize } : { pageSize },
|
|
1330
1357
|
additionalParams: prefixedOptions,
|
|
1331
1358
|
transformFn: config.transformFn,
|
|
1332
1359
|
method: config.method,
|
|
@@ -1584,6 +1611,8 @@ class BaseService {
|
|
|
1584
1611
|
// When true (default), converts pageNumber to a skip/offset value (e.g., page 3 with pageSize 10 → skip 20).
|
|
1585
1612
|
// When false, passes pageNumber directly as the offset param — used by APIs that accept a page number instead of a record offset.
|
|
1586
1613
|
const convertToSkip = paginationParams?.convertToSkip ?? true;
|
|
1614
|
+
// When true, sends pageNumber - 1 (for 0-based APIs). Default false (1-based).
|
|
1615
|
+
const zeroBased = paginationParams?.zeroBased ?? false;
|
|
1587
1616
|
requestParams[pageSizeParam] = limitedPageSize;
|
|
1588
1617
|
if (convertToSkip) {
|
|
1589
1618
|
if (params.pageNumber && params.pageNumber > 1) {
|
|
@@ -1591,7 +1620,8 @@ class BaseService {
|
|
|
1591
1620
|
}
|
|
1592
1621
|
}
|
|
1593
1622
|
else {
|
|
1594
|
-
|
|
1623
|
+
const sdkPageNumber = params.pageNumber || 1;
|
|
1624
|
+
requestParams[offsetParam] = zeroBased ? sdkPageNumber - 1 : sdkPageNumber;
|
|
1595
1625
|
}
|
|
1596
1626
|
{
|
|
1597
1627
|
requestParams[countParam] = true;
|
|
@@ -1620,8 +1650,9 @@ class BaseService {
|
|
|
1620
1650
|
const totalCountField = fields.totalCountField || 'totalRecordCount';
|
|
1621
1651
|
const continuationTokenField = fields.continuationTokenField || 'continuationToken';
|
|
1622
1652
|
// Extract items and metadata
|
|
1623
|
-
// Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N })
|
|
1624
|
-
|
|
1653
|
+
// Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N }).
|
|
1654
|
+
// itemsField may be a dotted path (e.g. 'data.agents') for nested envelopes.
|
|
1655
|
+
const items = Array.isArray(response.data) ? response.data : (resolveNestedField(response.data, itemsField) || []);
|
|
1625
1656
|
const rawTotalCount = Array.isArray(response.data) ? undefined : resolveNestedField(response.data, totalCountField);
|
|
1626
1657
|
const totalCount = typeof rawTotalCount === 'number' ? rawTotalCount : undefined;
|
|
1627
1658
|
const continuationToken = response.data[continuationTokenField];
|
|
@@ -1870,6 +1901,26 @@ function describeFolderForError(folderId, folderKey, folderPath) {
|
|
|
1870
1901
|
return '';
|
|
1871
1902
|
}
|
|
1872
1903
|
|
|
1904
|
+
/**
|
|
1905
|
+
* Enum for Asset Value Scope
|
|
1906
|
+
*/
|
|
1907
|
+
var AssetValueScope;
|
|
1908
|
+
(function (AssetValueScope) {
|
|
1909
|
+
AssetValueScope["Global"] = "Global";
|
|
1910
|
+
AssetValueScope["PerRobot"] = "PerRobot";
|
|
1911
|
+
})(AssetValueScope || (AssetValueScope = {}));
|
|
1912
|
+
/**
|
|
1913
|
+
* Enum for Asset Value Type
|
|
1914
|
+
*/
|
|
1915
|
+
var AssetValueType;
|
|
1916
|
+
(function (AssetValueType) {
|
|
1917
|
+
AssetValueType["Text"] = "Text";
|
|
1918
|
+
AssetValueType["Bool"] = "Bool";
|
|
1919
|
+
AssetValueType["Integer"] = "Integer";
|
|
1920
|
+
AssetValueType["Credential"] = "Credential";
|
|
1921
|
+
AssetValueType["Secret"] = "Secret";
|
|
1922
|
+
})(AssetValueType || (AssetValueType = {}));
|
|
1923
|
+
|
|
1873
1924
|
/**
|
|
1874
1925
|
* Base path constants for different services
|
|
1875
1926
|
*/
|
|
@@ -2040,6 +2091,68 @@ class AssetService extends FolderScopedService {
|
|
|
2040
2091
|
async getByName(name, options = {}) {
|
|
2041
2092
|
return this.getByNameLookup('Asset', ASSET_ENDPOINTS.GET_BY_FOLDER, name, options, (raw) => transformData(pascalToCamelCaseKeys(raw), AssetMap));
|
|
2042
2093
|
}
|
|
2094
|
+
/**
|
|
2095
|
+
* Updates the value of an existing asset by ID.
|
|
2096
|
+
*
|
|
2097
|
+
* Fetches the asset internally to determine its type, then updates only the value while
|
|
2098
|
+
* preserving the asset's name, scope, and description.
|
|
2099
|
+
*
|
|
2100
|
+
* **Supported value types:** `Text`, `Integer`, and `Bool` only. Other types
|
|
2101
|
+
* (`Credential`, `Secret`) throw a `ValidationError`.
|
|
2102
|
+
*
|
|
2103
|
+
* The `newValue` runtime type must match the asset's `valueType`:
|
|
2104
|
+
* - `Text` → `string`
|
|
2105
|
+
* - `Integer` → `number` (integer)
|
|
2106
|
+
* - `Bool` → `boolean`
|
|
2107
|
+
*
|
|
2108
|
+
* @param id - Asset ID
|
|
2109
|
+
* @param newValue - New value to apply (string for `Text`, number for `Integer`, boolean for `Bool`)
|
|
2110
|
+
* @param options - Folder scoping (`folderId` / `folderKey` / `folderPath`)
|
|
2111
|
+
* @returns Promise resolving when the asset has been updated
|
|
2112
|
+
*
|
|
2113
|
+
* @example
|
|
2114
|
+
* ```typescript
|
|
2115
|
+
* import { Assets } from '@uipath/uipath-typescript/assets';
|
|
2116
|
+
*
|
|
2117
|
+
* const assets = new Assets(sdk);
|
|
2118
|
+
*
|
|
2119
|
+
* // Update a Text asset by folder ID
|
|
2120
|
+
* await assets.updateValueById(<assetId>, 'new-value', { folderId: <folderId> });
|
|
2121
|
+
*
|
|
2122
|
+
* // Update an Integer asset by folder key (GUID)
|
|
2123
|
+
* await assets.updateValueById(<assetId>, 42, { folderKey: '5f6dadf1-3677-49dc-8aca-c2999dd4b3ba' });
|
|
2124
|
+
*
|
|
2125
|
+
* // Update a Bool asset by folder path
|
|
2126
|
+
* await assets.updateValueById(<assetId>, true, { folderPath: 'Shared/Finance' });
|
|
2127
|
+
* ```
|
|
2128
|
+
*/
|
|
2129
|
+
async updateValueById(id, newValue, options) {
|
|
2130
|
+
if (!id) {
|
|
2131
|
+
throw new ValidationError({ message: 'id is required for updateValueById' });
|
|
2132
|
+
}
|
|
2133
|
+
if (newValue === null || newValue === undefined) {
|
|
2134
|
+
throw new ValidationError({ message: 'newValue is required for updateValueById' });
|
|
2135
|
+
}
|
|
2136
|
+
const headers = resolveFolderHeaders({
|
|
2137
|
+
folderId: options?.folderId,
|
|
2138
|
+
folderKey: options?.folderKey,
|
|
2139
|
+
folderPath: options?.folderPath,
|
|
2140
|
+
resourceType: 'Assets.updateValueById',
|
|
2141
|
+
fallbackFolderKey: this.config.folderKey,
|
|
2142
|
+
});
|
|
2143
|
+
const existingResponse = await this.get(ASSET_ENDPOINTS.GET_BY_ID(id), { headers });
|
|
2144
|
+
const existing = existingResponse.data;
|
|
2145
|
+
const valueField = resolveValueField(id, existing.ValueType, newValue);
|
|
2146
|
+
const body = {
|
|
2147
|
+
Id: id,
|
|
2148
|
+
Name: existing.Name,
|
|
2149
|
+
ValueScope: existing.ValueScope,
|
|
2150
|
+
ValueType: existing.ValueType,
|
|
2151
|
+
Description: existing.Description,
|
|
2152
|
+
[valueField]: newValue,
|
|
2153
|
+
};
|
|
2154
|
+
await this.put(ASSET_ENDPOINTS.GET_BY_ID(id), body, { headers });
|
|
2155
|
+
}
|
|
2043
2156
|
}
|
|
2044
2157
|
__decorate([
|
|
2045
2158
|
track('Assets.GetAll')
|
|
@@ -2050,29 +2163,41 @@ __decorate([
|
|
|
2050
2163
|
__decorate([
|
|
2051
2164
|
track('Assets.GetByName')
|
|
2052
2165
|
], AssetService.prototype, "getByName", null);
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2166
|
+
__decorate([
|
|
2167
|
+
track('Assets.UpdateValueById')
|
|
2168
|
+
], AssetService.prototype, "updateValueById", null);
|
|
2169
|
+
/**
|
|
2170
|
+
* Maps the asset's `valueType` to the PUT body field carrying the new value, validating
|
|
2171
|
+
* that the new value's runtime type matches the asset type.
|
|
2172
|
+
*/
|
|
2173
|
+
function resolveValueField(id, valueType, newValue) {
|
|
2174
|
+
switch (valueType) {
|
|
2175
|
+
case AssetValueType.Text:
|
|
2176
|
+
if (typeof newValue !== 'string') {
|
|
2177
|
+
throw new ValidationError({
|
|
2178
|
+
message: `Asset ${id} has valueType Text; newValue must be a string, got ${typeof newValue}`,
|
|
2179
|
+
});
|
|
2180
|
+
}
|
|
2181
|
+
return 'StringValue';
|
|
2182
|
+
case AssetValueType.Integer:
|
|
2183
|
+
if (typeof newValue !== 'number' || !Number.isInteger(newValue)) {
|
|
2184
|
+
throw new ValidationError({
|
|
2185
|
+
message: `Asset ${id} has valueType Integer; newValue must be an integer number, got ${typeof newValue}`,
|
|
2186
|
+
});
|
|
2187
|
+
}
|
|
2188
|
+
return 'IntValue';
|
|
2189
|
+
case AssetValueType.Bool:
|
|
2190
|
+
if (typeof newValue !== 'boolean') {
|
|
2191
|
+
throw new ValidationError({
|
|
2192
|
+
message: `Asset ${id} has valueType Bool; newValue must be a boolean, got ${typeof newValue}`,
|
|
2193
|
+
});
|
|
2194
|
+
}
|
|
2195
|
+
return 'BoolValue';
|
|
2196
|
+
default:
|
|
2197
|
+
throw new ValidationError({
|
|
2198
|
+
message: `updateValueById only supports Text, Integer, or Bool assets; asset ${id} has valueType ${valueType}`,
|
|
2199
|
+
});
|
|
2200
|
+
}
|
|
2201
|
+
}
|
|
2077
2202
|
|
|
2078
2203
|
export { AssetService, AssetValueScope, AssetValueType, AssetService as Assets };
|