@uipath/uipath-typescript 1.3.11 → 1.4.1
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 +1772 -0
- package/dist/agent-memory/index.d.ts +588 -0
- package/dist/agent-memory/index.mjs +1770 -0
- package/dist/agents/index.cjs +1995 -0
- package/dist/agents/index.d.ts +961 -0
- package/dist/agents/index.mjs +1993 -0
- package/dist/assets/index.cjs +171 -39
- package/dist/assets/index.d.ts +84 -5
- package/dist/assets/index.mjs +171 -39
- package/dist/attachments/index.cjs +53 -15
- package/dist/attachments/index.d.ts +1 -0
- package/dist/attachments/index.mjs +53 -15
- package/dist/buckets/index.cjs +151 -130
- package/dist/buckets/index.d.ts +198 -84
- package/dist/buckets/index.mjs +151 -130
- package/dist/cases/index.cjs +220 -23
- package/dist/cases/index.d.ts +148 -10
- package/dist/cases/index.mjs +220 -24
- package/dist/conversational-agent/index.cjs +140 -66
- package/dist/conversational-agent/index.d.ts +190 -122
- package/dist/conversational-agent/index.mjs +140 -66
- package/dist/core/index.cjs +445 -108
- package/dist/core/index.d.ts +15 -0
- package/dist/core/index.mjs +445 -108
- package/dist/entities/index.cjs +365 -102
- package/dist/entities/index.d.ts +446 -114
- package/dist/entities/index.mjs +365 -102
- package/dist/feedback/index.cjs +53 -15
- package/dist/feedback/index.d.ts +1 -0
- package/dist/feedback/index.mjs +53 -15
- package/dist/governance/index.cjs +1789 -0
- package/dist/governance/index.d.ts +598 -0
- package/dist/governance/index.mjs +1787 -0
- package/dist/index.cjs +1453 -444
- package/dist/index.d.ts +4150 -1742
- package/dist/index.mjs +1452 -445
- package/dist/index.umd.js +5035 -4009
- package/dist/jobs/index.cjs +53 -15
- package/dist/jobs/index.d.ts +1 -0
- package/dist/jobs/index.mjs +53 -15
- package/dist/maestro-processes/index.cjs +189 -27
- package/dist/maestro-processes/index.d.ts +131 -9
- package/dist/maestro-processes/index.mjs +189 -27
- package/dist/orchestrator-du-module/index.cjs +1788 -0
- package/dist/orchestrator-du-module/index.d.ts +757 -0
- package/dist/orchestrator-du-module/index.mjs +1785 -0
- package/dist/processes/index.cjs +53 -15
- package/dist/processes/index.d.ts +1 -0
- package/dist/processes/index.mjs +53 -15
- package/dist/queues/index.cjs +53 -15
- package/dist/queues/index.d.ts +1 -0
- package/dist/queues/index.mjs +53 -15
- package/dist/tasks/index.cjs +116 -19
- package/dist/tasks/index.d.ts +110 -4
- package/dist/tasks/index.mjs +117 -20
- package/dist/traces/index.cjs +340 -15
- package/dist/traces/index.d.ts +483 -2
- package/dist/traces/index.mjs +339 -16
- package/package.json +42 -2
package/dist/traces/index.cjs
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
|
|
@@ -893,6 +919,35 @@ const ODATA_PREFIX = '$';
|
|
|
893
919
|
const HTTP_METHODS = {
|
|
894
920
|
GET: 'GET',
|
|
895
921
|
POST: 'POST'};
|
|
922
|
+
/**
|
|
923
|
+
* Agents pagination constants — items and total count are nested under the response envelope
|
|
924
|
+
*/
|
|
925
|
+
const AGENTS_PAGINATION = {
|
|
926
|
+
/** Dotted path to the total count in the agents response envelope */
|
|
927
|
+
TOTAL_COUNT_FIELD: 'pagination.totalCount'
|
|
928
|
+
};
|
|
929
|
+
/**
|
|
930
|
+
* Agents OFFSET pagination parameter names (page-number style, 0-based, no skip conversion)
|
|
931
|
+
*/
|
|
932
|
+
const AGENTS_OFFSET_PARAMS = {
|
|
933
|
+
/** Page size parameter name */
|
|
934
|
+
PAGE_SIZE_PARAM: 'pageSize',
|
|
935
|
+
/** Page number parameter name (sent directly, 0-based) */
|
|
936
|
+
OFFSET_PARAM: 'pageNumber',
|
|
937
|
+
/** No count param needed */
|
|
938
|
+
COUNT_PARAM: undefined
|
|
939
|
+
};
|
|
940
|
+
/**
|
|
941
|
+
* Traceview spans pagination constants — items sit directly under `data`,
|
|
942
|
+
* total count under the same envelope location as the agents list. Request
|
|
943
|
+
* params reuse {@link AGENTS_OFFSET_PARAMS} (pageSize + 0-based pageNumber).
|
|
944
|
+
*/
|
|
945
|
+
const TRACEVIEW_SPANS_PAGINATION = {
|
|
946
|
+
/** Field name for the spans array in the response envelope */
|
|
947
|
+
ITEMS_FIELD: 'data',
|
|
948
|
+
/** Total count path — same envelope location as the agents list. */
|
|
949
|
+
TOTAL_COUNT_FIELD: AGENTS_PAGINATION.TOTAL_COUNT_FIELD
|
|
950
|
+
};
|
|
896
951
|
/**
|
|
897
952
|
* OData OFFSET pagination parameter names (ODATA-style)
|
|
898
953
|
*/
|
|
@@ -1179,12 +1234,18 @@ class PaginationHelpers {
|
|
|
1179
1234
|
* @returns Promise resolving to a paginated result
|
|
1180
1235
|
*/
|
|
1181
1236
|
static async getAllPaginated(params) {
|
|
1182
|
-
const { serviceAccess, getEndpoint, folderId, headers: providedHeaders, paginationParams, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
|
|
1237
|
+
const { serviceAccess, getEndpoint, folderId, headers: providedHeaders, paginationParams, additionalParams, queryParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
|
|
1183
1238
|
const endpoint = getEndpoint(folderId);
|
|
1184
1239
|
const headers = providedHeaders ?? (folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {});
|
|
1240
|
+
// On POST, the caller's options go in the body; queryParams stays in the URL.
|
|
1241
|
+
// On GET, everything is URL — queryParams merges with additionalParams.
|
|
1242
|
+
const isPost = method === HTTP_METHODS.POST;
|
|
1243
|
+
const requestSpec = isPost
|
|
1244
|
+
? { body: additionalParams, params: queryParams }
|
|
1245
|
+
: { params: { ...additionalParams, ...queryParams } };
|
|
1185
1246
|
const paginatedResponse = await serviceAccess.requestWithPagination(method, endpoint, paginationParams, {
|
|
1186
1247
|
headers,
|
|
1187
|
-
|
|
1248
|
+
...requestSpec,
|
|
1188
1249
|
pagination: {
|
|
1189
1250
|
paginationType: options.paginationType || PaginationType.OFFSET,
|
|
1190
1251
|
itemsField: options.itemsField || DEFAULT_ITEMS_FIELD,
|
|
@@ -1209,7 +1270,7 @@ class PaginationHelpers {
|
|
|
1209
1270
|
* @returns Promise resolving to an object with data and totalCount
|
|
1210
1271
|
*/
|
|
1211
1272
|
static async getAllNonPaginated(params) {
|
|
1212
|
-
const { serviceAccess, getAllEndpoint, getByFolderEndpoint, folderId, headers: providedHeaders, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
|
|
1273
|
+
const { serviceAccess, getAllEndpoint, getByFolderEndpoint, folderId, headers: providedHeaders, additionalParams, queryParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
|
|
1213
1274
|
// Set default field names
|
|
1214
1275
|
const itemsField = options.itemsField || DEFAULT_ITEMS_FIELD;
|
|
1215
1276
|
const totalCountField = options.totalCountField || DEFAULT_TOTAL_COUNT_FIELD;
|
|
@@ -1219,17 +1280,18 @@ class PaginationHelpers {
|
|
|
1219
1280
|
// Make the API call based on method
|
|
1220
1281
|
let response;
|
|
1221
1282
|
if (method === HTTP_METHODS.POST) {
|
|
1222
|
-
response = await serviceAccess.post(endpoint, additionalParams, { headers });
|
|
1283
|
+
response = await serviceAccess.post(endpoint, additionalParams, { headers, params: queryParams });
|
|
1223
1284
|
}
|
|
1224
1285
|
else {
|
|
1225
1286
|
response = await serviceAccess.get(endpoint, {
|
|
1226
|
-
params: additionalParams,
|
|
1287
|
+
params: { ...additionalParams, ...queryParams },
|
|
1227
1288
|
headers
|
|
1228
1289
|
});
|
|
1229
1290
|
}
|
|
1230
1291
|
// Extract and transform items from response
|
|
1231
|
-
// Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N })
|
|
1232
|
-
|
|
1292
|
+
// Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N }).
|
|
1293
|
+
// itemsField may be a dotted path (e.g. 'data.agents') for nested envelopes.
|
|
1294
|
+
const rawItems = Array.isArray(response.data) ? response.data : resolveNestedField(response.data, itemsField);
|
|
1233
1295
|
const rawTotalCount = Array.isArray(response.data) ? undefined : resolveNestedField(response.data, totalCountField);
|
|
1234
1296
|
const totalCount = typeof rawTotalCount === 'number' ? rawTotalCount : undefined;
|
|
1235
1297
|
// Parse items - automatically handle JSON string responses
|
|
@@ -1275,8 +1337,9 @@ class PaginationHelpers {
|
|
|
1275
1337
|
getEndpoint: config.getEndpoint,
|
|
1276
1338
|
folderId,
|
|
1277
1339
|
headers: config.headers,
|
|
1278
|
-
paginationParams: cursor ? { cursor, pageSize } : jumpToPage ? { jumpToPage, pageSize } : { pageSize },
|
|
1340
|
+
paginationParams: cursor ? { cursor, pageSize } : jumpToPage !== undefined ? { jumpToPage, pageSize } : { pageSize },
|
|
1279
1341
|
additionalParams: prefixedOptions,
|
|
1342
|
+
queryParams: config.queryParams,
|
|
1280
1343
|
transformFn: config.transformFn,
|
|
1281
1344
|
method: config.method,
|
|
1282
1345
|
options: {
|
|
@@ -1294,6 +1357,7 @@ class PaginationHelpers {
|
|
|
1294
1357
|
folderId,
|
|
1295
1358
|
headers: config.headers,
|
|
1296
1359
|
additionalParams: prefixedOptions,
|
|
1360
|
+
queryParams: config.queryParams,
|
|
1297
1361
|
transformFn: config.transformFn,
|
|
1298
1362
|
method: config.method,
|
|
1299
1363
|
options: {
|
|
@@ -1485,18 +1549,17 @@ class BaseService {
|
|
|
1485
1549
|
const params = this.validateAndPreparePaginationParams(paginationType, paginationOptions);
|
|
1486
1550
|
// Prepare request parameters based on pagination type
|
|
1487
1551
|
const requestParams = this.preparePaginationRequestParams(paginationType, params, options.pagination);
|
|
1488
|
-
//
|
|
1552
|
+
// Route pagination state to wherever the API expects it (body for POST, URL for GET).
|
|
1553
|
+
// Caller-supplied options.body / options.params are respected as-is — the api-client
|
|
1554
|
+
// already handles params (URL) and body (request body) independently for every method.
|
|
1489
1555
|
if (method.toUpperCase() === 'POST') {
|
|
1490
1556
|
const existingBody = (options.body && typeof options.body === 'object') ? options.body : {};
|
|
1491
1557
|
options.body = {
|
|
1492
1558
|
...existingBody,
|
|
1493
|
-
...options.params,
|
|
1494
1559
|
...requestParams
|
|
1495
1560
|
};
|
|
1496
|
-
options.params = undefined;
|
|
1497
1561
|
}
|
|
1498
1562
|
else {
|
|
1499
|
-
// Merge pagination parameters with existing parameters
|
|
1500
1563
|
options.params = {
|
|
1501
1564
|
...options.params,
|
|
1502
1565
|
...requestParams
|
|
@@ -1533,6 +1596,8 @@ class BaseService {
|
|
|
1533
1596
|
// When true (default), converts pageNumber to a skip/offset value (e.g., page 3 with pageSize 10 → skip 20).
|
|
1534
1597
|
// When false, passes pageNumber directly as the offset param — used by APIs that accept a page number instead of a record offset.
|
|
1535
1598
|
const convertToSkip = paginationParams?.convertToSkip ?? true;
|
|
1599
|
+
// When true, sends pageNumber - 1 (for 0-based APIs). Default false (1-based).
|
|
1600
|
+
const zeroBased = paginationParams?.zeroBased ?? false;
|
|
1536
1601
|
requestParams[pageSizeParam] = limitedPageSize;
|
|
1537
1602
|
if (convertToSkip) {
|
|
1538
1603
|
if (params.pageNumber && params.pageNumber > 1) {
|
|
@@ -1540,7 +1605,8 @@ class BaseService {
|
|
|
1540
1605
|
}
|
|
1541
1606
|
}
|
|
1542
1607
|
else {
|
|
1543
|
-
|
|
1608
|
+
const sdkPageNumber = params.pageNumber || 1;
|
|
1609
|
+
requestParams[offsetParam] = zeroBased ? sdkPageNumber - 1 : sdkPageNumber;
|
|
1544
1610
|
}
|
|
1545
1611
|
{
|
|
1546
1612
|
requestParams[countParam] = true;
|
|
@@ -1569,8 +1635,9 @@ class BaseService {
|
|
|
1569
1635
|
const totalCountField = fields.totalCountField || 'totalRecordCount';
|
|
1570
1636
|
const continuationTokenField = fields.continuationTokenField || 'continuationToken';
|
|
1571
1637
|
// Extract items and metadata
|
|
1572
|
-
// Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N })
|
|
1573
|
-
|
|
1638
|
+
// Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N }).
|
|
1639
|
+
// itemsField may be a dotted path (e.g. 'data.agents') for nested envelopes.
|
|
1640
|
+
const items = Array.isArray(response.data) ? response.data : (resolveNestedField(response.data, itemsField) || []);
|
|
1574
1641
|
const rawTotalCount = Array.isArray(response.data) ? undefined : resolveNestedField(response.data, totalCountField);
|
|
1575
1642
|
const totalCount = typeof rawTotalCount === 'number' ? rawTotalCount : undefined;
|
|
1576
1643
|
const continuationToken = response.data[continuationTokenField];
|
|
@@ -1762,6 +1829,23 @@ const SpanAttachmentDirectionMap = {
|
|
|
1762
1829
|
* Base path constants for different services
|
|
1763
1830
|
*/
|
|
1764
1831
|
const LLMOPS_BASE = 'llmopstenant_';
|
|
1832
|
+
const INSIGHTS_RTM_BASE = 'insightsrtm_';
|
|
1833
|
+
|
|
1834
|
+
/**
|
|
1835
|
+
* Agent Traces Service Endpoints
|
|
1836
|
+
*/
|
|
1837
|
+
const AGENT_TRACES_ENDPOINTS = {
|
|
1838
|
+
/** Trace-level time-series of error counts grouped by error name. */
|
|
1839
|
+
GET_ERRORS_TIMELINE: `${INSIGHTS_RTM_BASE}/Traceview/errorsTimeline`,
|
|
1840
|
+
/** Trace-level time-series of latency (decimal seconds per series). */
|
|
1841
|
+
GET_LATENCY_TIMELINE: `${INSIGHTS_RTM_BASE}/Traceview/latencyTimeline`,
|
|
1842
|
+
/** Trace-level per-agent AGU/PLTU consumption totals. */
|
|
1843
|
+
GET_UNIT_CONSUMPTION: `${INSIGHTS_RTM_BASE}/Traceview/unitConsumption`,
|
|
1844
|
+
/** All spans for a single trace (flat array, not paginated). */
|
|
1845
|
+
GET_SPANS_BY_TRACE_ID: (traceId) => `${INSIGHTS_RTM_BASE}/Traceview/spans/${traceId}`,
|
|
1846
|
+
/** Paginated spans whose reference hierarchy contains the given reference id. */
|
|
1847
|
+
GET_SPANS_BY_REFERENCE: (referenceId) => `${INSIGHTS_RTM_BASE}/Traceview/spans/reference/${referenceId}`,
|
|
1848
|
+
};
|
|
1765
1849
|
|
|
1766
1850
|
/**
|
|
1767
1851
|
* Traces Service Endpoints
|
|
@@ -1899,4 +1983,245 @@ __decorate([
|
|
|
1899
1983
|
track('Traces.GetSpansByIds')
|
|
1900
1984
|
], TracesService.prototype, "getSpansByIds", null);
|
|
1901
1985
|
|
|
1986
|
+
/**
|
|
1987
|
+
* Maps a raw span record to a {@link AgentSpanGetResponse}
|
|
1988
|
+
*/
|
|
1989
|
+
const transformSpan = (span) => {
|
|
1990
|
+
const { expiryTimeUtc, ...rest } = span;
|
|
1991
|
+
return { ...rest, expiredTime: expiryTimeUtc };
|
|
1992
|
+
};
|
|
1993
|
+
/**
|
|
1994
|
+
* Service for retrieving UiPath Agent trace metrics.
|
|
1995
|
+
*/
|
|
1996
|
+
class AgentTracesService extends BaseService {
|
|
1997
|
+
/**
|
|
1998
|
+
* Retrieves a trace-level time-series of error counts grouped by error name.
|
|
1999
|
+
*
|
|
2000
|
+
* @param options - Optional window and filters
|
|
2001
|
+
* @returns Promise resolving to an array of {@link AgentTraceGetErrorsTimelineResponse}
|
|
2002
|
+
* @example
|
|
2003
|
+
* ```typescript
|
|
2004
|
+
* import { AgentTraces } from '@uipath/uipath-typescript/traces';
|
|
2005
|
+
*
|
|
2006
|
+
* const trace = new AgentTraces(sdk);
|
|
2007
|
+
*
|
|
2008
|
+
* // Get the errors timeline
|
|
2009
|
+
* const result = await trace.getErrorsTimeline();
|
|
2010
|
+
* result.forEach((point) => {
|
|
2011
|
+
* console.log(`${point.date} ${point.name}: ${point.value} errors`);
|
|
2012
|
+
* });
|
|
2013
|
+
* ```
|
|
2014
|
+
* @example
|
|
2015
|
+
* ```typescript
|
|
2016
|
+
* import { AgentTraceExecutionType } from '@uipath/uipath-typescript/traces';
|
|
2017
|
+
*
|
|
2018
|
+
* // Get the errors timeline for an agent version within a time window
|
|
2019
|
+
* const filtered = await trace.getErrorsTimeline({
|
|
2020
|
+
* startTime: new Date('2025-05-01T00:00:00Z'),
|
|
2021
|
+
* endTime: new Date('2025-06-01T00:00:00Z'),
|
|
2022
|
+
* agentId: '<agentId>',
|
|
2023
|
+
* agentVersion: '1.0.0',
|
|
2024
|
+
* executionType: AgentTraceExecutionType.Runtime,
|
|
2025
|
+
* });
|
|
2026
|
+
* ```
|
|
2027
|
+
*/
|
|
2028
|
+
async getErrorsTimeline(options) {
|
|
2029
|
+
const response = await this.post(AGENT_TRACES_ENDPOINTS.GET_ERRORS_TIMELINE, this.buildTraceFilterBody(options));
|
|
2030
|
+
return response.data.data;
|
|
2031
|
+
}
|
|
2032
|
+
/**
|
|
2033
|
+
* Retrieves a trace-level time-series of latency.
|
|
2034
|
+
*
|
|
2035
|
+
* @param options - Optional window and filters
|
|
2036
|
+
* @returns Promise resolving to an array of {@link AgentTraceGetLatencyTimelineResponse}
|
|
2037
|
+
* @example
|
|
2038
|
+
* ```typescript
|
|
2039
|
+
* import { AgentTraces } from '@uipath/uipath-typescript/traces';
|
|
2040
|
+
*
|
|
2041
|
+
* const trace = new AgentTraces(sdk);
|
|
2042
|
+
*
|
|
2043
|
+
* // Get the latency timeline
|
|
2044
|
+
* const result = await trace.getLatencyTimeline();
|
|
2045
|
+
* result.forEach((point) => {
|
|
2046
|
+
* console.log(`${point.date} ${point.name}: ${point.value}s`);
|
|
2047
|
+
* });
|
|
2048
|
+
* ```
|
|
2049
|
+
* @example
|
|
2050
|
+
* ```typescript
|
|
2051
|
+
* import { AgentTraceExecutionType } from '@uipath/uipath-typescript/traces';
|
|
2052
|
+
*
|
|
2053
|
+
* // Get the latency timeline for an agent version within a time window
|
|
2054
|
+
* const filtered = await trace.getLatencyTimeline({
|
|
2055
|
+
* startTime: new Date('2025-05-01T00:00:00Z'),
|
|
2056
|
+
* endTime: new Date('2025-06-01T00:00:00Z'),
|
|
2057
|
+
* agentId: '<agentId>',
|
|
2058
|
+
* agentVersion: '1.0.0',
|
|
2059
|
+
* executionType: AgentTraceExecutionType.Runtime,
|
|
2060
|
+
* });
|
|
2061
|
+
* ```
|
|
2062
|
+
*/
|
|
2063
|
+
async getLatencyTimeline(options) {
|
|
2064
|
+
const response = await this.post(AGENT_TRACES_ENDPOINTS.GET_LATENCY_TIMELINE, this.buildTraceFilterBody(options));
|
|
2065
|
+
return response.data.data;
|
|
2066
|
+
}
|
|
2067
|
+
/**
|
|
2068
|
+
* Retrieves trace-level per-agent unit consumption totals.
|
|
2069
|
+
*
|
|
2070
|
+
* @param options - Optional window and filters
|
|
2071
|
+
* @returns Promise resolving to an array of {@link AgentTraceGetUnitConsumptionResponse}
|
|
2072
|
+
* @example
|
|
2073
|
+
* ```typescript
|
|
2074
|
+
* import { AgentTraces } from '@uipath/uipath-typescript/traces';
|
|
2075
|
+
*
|
|
2076
|
+
* const trace = new AgentTraces(sdk);
|
|
2077
|
+
*
|
|
2078
|
+
* // Get per-agent unit consumption
|
|
2079
|
+
* const result = await trace.getUnitConsumption();
|
|
2080
|
+
* result.forEach((row) => {
|
|
2081
|
+
* console.log(`${row.agentId}: ${row.agentUnitsConsumed} AGU, ${row.platformUnitsConsumed} PLTU`);
|
|
2082
|
+
* });
|
|
2083
|
+
* ```
|
|
2084
|
+
* @example
|
|
2085
|
+
* ```typescript
|
|
2086
|
+
* import { AgentTraceExecutionType } from '@uipath/uipath-typescript/traces';
|
|
2087
|
+
*
|
|
2088
|
+
* // Get per-agent unit consumption for an agent version within a time window
|
|
2089
|
+
* const filtered = await trace.getUnitConsumption({
|
|
2090
|
+
* startTime: new Date('2025-05-01T00:00:00Z'),
|
|
2091
|
+
* endTime: new Date('2025-06-01T00:00:00Z'),
|
|
2092
|
+
* agentId: '<agentId>',
|
|
2093
|
+
* agentVersion: '1.0.0',
|
|
2094
|
+
* executionType: AgentTraceExecutionType.Runtime,
|
|
2095
|
+
* });
|
|
2096
|
+
* ```
|
|
2097
|
+
*/
|
|
2098
|
+
async getUnitConsumption(options) {
|
|
2099
|
+
const response = await this.post(AGENT_TRACES_ENDPOINTS.GET_UNIT_CONSUMPTION, this.buildTraceFilterBody(options));
|
|
2100
|
+
return response.data.data;
|
|
2101
|
+
}
|
|
2102
|
+
/**
|
|
2103
|
+
* Retrieves every span belonging to a single trace.
|
|
2104
|
+
*
|
|
2105
|
+
* @param traceId - Identifier of the trace whose spans should be returned
|
|
2106
|
+
* @returns Promise resolving to an array of {@link AgentSpanGetResponse}
|
|
2107
|
+
* @example
|
|
2108
|
+
* ```typescript
|
|
2109
|
+
* import { AgentTraces } from '@uipath/uipath-typescript/traces';
|
|
2110
|
+
*
|
|
2111
|
+
* const trace = new AgentTraces(sdk);
|
|
2112
|
+
*
|
|
2113
|
+
* const spans = await trace.getSpansByTraceId('<traceId>');
|
|
2114
|
+
* spans.forEach((span) => {
|
|
2115
|
+
* console.log(`${span.name} (${span.startTime} → ${span.endTime ?? 'in progress'})`);
|
|
2116
|
+
* });
|
|
2117
|
+
* ```
|
|
2118
|
+
*/
|
|
2119
|
+
async getSpansByTraceId(traceId) {
|
|
2120
|
+
if (!traceId)
|
|
2121
|
+
throw new ValidationError({ message: 'traceId is required for getSpansByTraceId' });
|
|
2122
|
+
const response = await this.get(AGENT_TRACES_ENDPOINTS.GET_SPANS_BY_TRACE_ID(traceId));
|
|
2123
|
+
return (response.data ?? []).map(transformSpan);
|
|
2124
|
+
}
|
|
2125
|
+
/**
|
|
2126
|
+
* Retrieves spans whose reference hierarchy contains the given reference id.
|
|
2127
|
+
*
|
|
2128
|
+
* Returns a {@link PaginatedResponse} when pagination options (`pageSize`,
|
|
2129
|
+
* `cursor`, or `jumpToPage`) are provided, otherwise a
|
|
2130
|
+
* {@link NonPaginatedResponse}.
|
|
2131
|
+
*
|
|
2132
|
+
* @param referenceId - Reference id matched against each span's reference hierarchy
|
|
2133
|
+
* @param options - Optional pagination and hierarchy/time filters
|
|
2134
|
+
* @returns Promise resolving to a paginated or non-paginated list of {@link AgentSpanGetResponse}
|
|
2135
|
+
* @example
|
|
2136
|
+
* ```typescript
|
|
2137
|
+
* import { AgentTraces } from '@uipath/uipath-typescript/traces';
|
|
2138
|
+
*
|
|
2139
|
+
* const trace = new AgentTraces(sdk);
|
|
2140
|
+
*
|
|
2141
|
+
* // Get spans by referenceId
|
|
2142
|
+
* const result = await trace.getSpansByReference('<referenceId>');
|
|
2143
|
+
* result.items.forEach((span) => console.log(span.name));
|
|
2144
|
+
* ```
|
|
2145
|
+
* @example
|
|
2146
|
+
* ```typescript
|
|
2147
|
+
* import { AgentTraceExecutionType } from '@uipath/uipath-typescript/traces';
|
|
2148
|
+
*
|
|
2149
|
+
* // Get spans by referenceId within a trace and time window
|
|
2150
|
+
* const page = await trace.getSpansByReference('<referenceId>', {
|
|
2151
|
+
* traceId: '<traceId>',
|
|
2152
|
+
* executionType: AgentTraceExecutionType.Runtime,
|
|
2153
|
+
* startTime: new Date('2025-05-01T00:00:00Z'),
|
|
2154
|
+
* endTime: new Date('2025-06-01T00:00:00Z'),
|
|
2155
|
+
* pageSize: 25,
|
|
2156
|
+
* });
|
|
2157
|
+
*
|
|
2158
|
+
* if (page.hasNextPage && page.nextCursor) {
|
|
2159
|
+
* const next = await trace.getSpansByReference('<referenceId>', { cursor: page.nextCursor });
|
|
2160
|
+
* }
|
|
2161
|
+
* ```
|
|
2162
|
+
*/
|
|
2163
|
+
async getSpansByReference(referenceId, options) {
|
|
2164
|
+
if (!referenceId)
|
|
2165
|
+
throw new ValidationError({ message: 'referenceId is required for getSpansByReference' });
|
|
2166
|
+
const { startTime, endTime, ...rest } = options ?? {};
|
|
2167
|
+
const apiOptions = {
|
|
2168
|
+
...rest,
|
|
2169
|
+
...(startTime !== undefined ? { startTime: startTime.toISOString() } : {}),
|
|
2170
|
+
...(endTime !== undefined ? { endTime: endTime.toISOString() } : {}),
|
|
2171
|
+
};
|
|
2172
|
+
return PaginationHelpers.getAll({
|
|
2173
|
+
serviceAccess: this.createPaginationServiceAccess(),
|
|
2174
|
+
getEndpoint: () => AGENT_TRACES_ENDPOINTS.GET_SPANS_BY_REFERENCE(referenceId),
|
|
2175
|
+
method: HTTP_METHODS.GET,
|
|
2176
|
+
transformFn: transformSpan,
|
|
2177
|
+
excludeFromPrefix: Object.keys(apiOptions),
|
|
2178
|
+
pagination: {
|
|
2179
|
+
paginationType: PaginationType.OFFSET,
|
|
2180
|
+
itemsField: TRACEVIEW_SPANS_PAGINATION.ITEMS_FIELD,
|
|
2181
|
+
totalCountField: TRACEVIEW_SPANS_PAGINATION.TOTAL_COUNT_FIELD,
|
|
2182
|
+
paginationParams: {
|
|
2183
|
+
pageSizeParam: AGENTS_OFFSET_PARAMS.PAGE_SIZE_PARAM,
|
|
2184
|
+
offsetParam: AGENTS_OFFSET_PARAMS.OFFSET_PARAM,
|
|
2185
|
+
countParam: AGENTS_OFFSET_PARAMS.COUNT_PARAM,
|
|
2186
|
+
convertToSkip: false,
|
|
2187
|
+
zeroBased: true,
|
|
2188
|
+
},
|
|
2189
|
+
},
|
|
2190
|
+
}, apiOptions);
|
|
2191
|
+
}
|
|
2192
|
+
buildTraceFilterBody(options) {
|
|
2193
|
+
const body = {};
|
|
2194
|
+
if (options?.startTime !== undefined)
|
|
2195
|
+
body.startTime = options.startTime.toISOString();
|
|
2196
|
+
if (options?.endTime !== undefined)
|
|
2197
|
+
body.endTime = options.endTime.toISOString();
|
|
2198
|
+
if (options?.folderKeys !== undefined)
|
|
2199
|
+
body.folderKeys = options.folderKeys;
|
|
2200
|
+
if (options?.agentId !== undefined)
|
|
2201
|
+
body.agentId = options.agentId;
|
|
2202
|
+
if (options?.agentVersion !== undefined)
|
|
2203
|
+
body.agentVersion = options.agentVersion;
|
|
2204
|
+
if (options?.executionType !== undefined)
|
|
2205
|
+
body.executionType = options.executionType;
|
|
2206
|
+
return body;
|
|
2207
|
+
}
|
|
2208
|
+
}
|
|
2209
|
+
__decorate([
|
|
2210
|
+
track('AgentTraces.GetErrorsTimeline')
|
|
2211
|
+
], AgentTracesService.prototype, "getErrorsTimeline", null);
|
|
2212
|
+
__decorate([
|
|
2213
|
+
track('AgentTraces.GetLatencyTimeline')
|
|
2214
|
+
], AgentTracesService.prototype, "getLatencyTimeline", null);
|
|
2215
|
+
__decorate([
|
|
2216
|
+
track('AgentTraces.GetUnitConsumption')
|
|
2217
|
+
], AgentTracesService.prototype, "getUnitConsumption", null);
|
|
2218
|
+
__decorate([
|
|
2219
|
+
track('AgentTraces.GetSpansByTraceId')
|
|
2220
|
+
], AgentTracesService.prototype, "getSpansByTraceId", null);
|
|
2221
|
+
__decorate([
|
|
2222
|
+
track('AgentTraces.GetSpansByReference')
|
|
2223
|
+
], AgentTracesService.prototype, "getSpansByReference", null);
|
|
2224
|
+
|
|
2225
|
+
exports.AgentTraceExecutionType = exports.SpanExecutionType;
|
|
2226
|
+
exports.AgentTraces = AgentTracesService;
|
|
1902
2227
|
exports.Traces = TracesService;
|