@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
|
@@ -46,6 +46,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
46
46
|
* Base path constants for different services
|
|
47
47
|
*/
|
|
48
48
|
const PIMS_BASE = 'pims_';
|
|
49
|
+
const LLMOPS_BASE = 'llmopstenant_';
|
|
49
50
|
const INSIGHTS_RTM_BASE = 'insightsrtm_';
|
|
50
51
|
|
|
51
52
|
/**
|
|
@@ -60,7 +61,7 @@ const MAESTRO_ENDPOINTS = {
|
|
|
60
61
|
INSTANCES: {
|
|
61
62
|
GET_ALL: `${PIMS_BASE}/api/v1/instances`,
|
|
62
63
|
GET_BY_ID: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}`,
|
|
63
|
-
|
|
64
|
+
GET_ELEMENT_EXECUTIONS: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/element-executions`,
|
|
64
65
|
GET_BPMN: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/bpmn`,
|
|
65
66
|
GET_VARIABLES: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/variables`,
|
|
66
67
|
CANCEL: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/cancel`,
|
|
@@ -72,6 +73,9 @@ const MAESTRO_ENDPOINTS = {
|
|
|
72
73
|
GET_BY_PROCESS: (processKey) => `${PIMS_BASE}/api/v1/incidents/process/${processKey}`,
|
|
73
74
|
GET_BY_INSTANCE: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/incidents`,
|
|
74
75
|
},
|
|
76
|
+
TRACES: {
|
|
77
|
+
GET_SPANS: (traceId) => `${LLMOPS_BASE}/api/Traces/spans?traceId=${traceId}`,
|
|
78
|
+
},
|
|
75
79
|
INSIGHTS: {
|
|
76
80
|
/** Top processes ranked by run count */
|
|
77
81
|
TOP_PROCESSES_BY_RUN_COUNT: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/TopProcessesByRunCount`,
|
|
@@ -83,6 +87,8 @@ const MAESTRO_ENDPOINTS = {
|
|
|
83
87
|
INSTANCE_STATUS_BY_DATE: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/InstanceStatusByDate`,
|
|
84
88
|
/** Top processes ranked by total duration */
|
|
85
89
|
TOP_PROCESSES_BY_DURATION: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/TopProcessesByDuration`,
|
|
90
|
+
/** Element count by status for agentic instances (process and case) */
|
|
91
|
+
ELEMENT_COUNT_BY_STATUS: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/ElementCountByStatus`,
|
|
86
92
|
},
|
|
87
93
|
};
|
|
88
94
|
|
|
@@ -105,6 +111,13 @@ function createProcessMethods(processData, service) {
|
|
|
105
111
|
if (!processData.folderKey)
|
|
106
112
|
throw new Error('Folder key is undefined');
|
|
107
113
|
return service.getIncidents(processData.processKey, processData.folderKey);
|
|
114
|
+
},
|
|
115
|
+
getElementStats(startTime, endTime, packageVersion) {
|
|
116
|
+
if (!processData.processKey)
|
|
117
|
+
throw new Error('Process key is undefined');
|
|
118
|
+
if (!processData.packageId)
|
|
119
|
+
throw new Error('Package ID is undefined');
|
|
120
|
+
return service.getElementStats(processData.processKey, processData.packageId, startTime, endTime, packageVersion);
|
|
108
121
|
}
|
|
109
122
|
};
|
|
110
123
|
}
|
|
@@ -166,6 +179,28 @@ async function fetchInstanceStatusTimeline(postFn, startTime, endTime, isCaseMan
|
|
|
166
179
|
});
|
|
167
180
|
return response.data ?? [];
|
|
168
181
|
}
|
|
182
|
+
/**
|
|
183
|
+
* Builds the request body for the ElementCountByStatus endpoint.
|
|
184
|
+
*
|
|
185
|
+
* @param processKey - Process key to filter by
|
|
186
|
+
* @param packageId - Package identifier
|
|
187
|
+
* @param startTime - Start of the time range to query
|
|
188
|
+
* @param endTime - End of the time range to query
|
|
189
|
+
* @param packageVersion - Package version to filter by
|
|
190
|
+
* @returns Request body for the ElementCountByStatus endpoint
|
|
191
|
+
* @internal
|
|
192
|
+
*/
|
|
193
|
+
function buildElementCountByStatusBody(processKey, packageId, startTime, endTime, packageVersion) {
|
|
194
|
+
return {
|
|
195
|
+
commonParams: {
|
|
196
|
+
processKey,
|
|
197
|
+
packageId,
|
|
198
|
+
startTime: startTime.getTime(),
|
|
199
|
+
endTime: endTime.getTime(),
|
|
200
|
+
version: packageVersion
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
}
|
|
169
204
|
|
|
170
205
|
/**
|
|
171
206
|
* Common constants used across the SDK
|
|
@@ -1158,6 +1193,32 @@ function filterUndefined(obj) {
|
|
|
1158
1193
|
*/
|
|
1159
1194
|
const isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
|
|
1160
1195
|
isBrowser && window.self != window.top && window.location.href.includes('source=ActionCenter');
|
|
1196
|
+
const _params = isBrowser ? new URLSearchParams(window.location.search) : null;
|
|
1197
|
+
/**
|
|
1198
|
+
* True when the coded app has been loaded inside a host frame that explicitly
|
|
1199
|
+
* opted into token delegation by adding `?host=embed` to the iframe src URL.
|
|
1200
|
+
*/
|
|
1201
|
+
const isHostEmbedded = isBrowser && window.self !== window.top && _params?.get('host') === 'embed';
|
|
1202
|
+
/**
|
|
1203
|
+
* The validated parent origin, read from the `?basedomain=` query param set
|
|
1204
|
+
* by the embedding host in the iframe src URL.
|
|
1205
|
+
* Mirrors the same mechanism used by ActionCenterTokenManager.
|
|
1206
|
+
* Non-null only when `?host=embed` is present and `?basedomain=` is a valid URL.
|
|
1207
|
+
*/
|
|
1208
|
+
(() => {
|
|
1209
|
+
if (!isHostEmbedded)
|
|
1210
|
+
return null;
|
|
1211
|
+
const basedomain = _params?.get('basedomain');
|
|
1212
|
+
if (!basedomain)
|
|
1213
|
+
return null;
|
|
1214
|
+
try {
|
|
1215
|
+
return new URL(basedomain).origin;
|
|
1216
|
+
}
|
|
1217
|
+
catch {
|
|
1218
|
+
console.warn('embeddingOrigin: basedomain query param is not a valid URL', basedomain);
|
|
1219
|
+
return null;
|
|
1220
|
+
}
|
|
1221
|
+
})();
|
|
1161
1222
|
|
|
1162
1223
|
/**
|
|
1163
1224
|
* Base64 encoding/decoding
|
|
@@ -1435,12 +1496,18 @@ class PaginationHelpers {
|
|
|
1435
1496
|
* @returns Promise resolving to a paginated result
|
|
1436
1497
|
*/
|
|
1437
1498
|
static async getAllPaginated(params) {
|
|
1438
|
-
const { serviceAccess, getEndpoint, folderId, headers: providedHeaders, paginationParams, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
|
|
1499
|
+
const { serviceAccess, getEndpoint, folderId, headers: providedHeaders, paginationParams, additionalParams, queryParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
|
|
1439
1500
|
const endpoint = getEndpoint(folderId);
|
|
1440
1501
|
const headers = providedHeaders ?? (folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {});
|
|
1502
|
+
// On POST, the caller's options go in the body; queryParams stays in the URL.
|
|
1503
|
+
// On GET, everything is URL — queryParams merges with additionalParams.
|
|
1504
|
+
const isPost = method === HTTP_METHODS.POST;
|
|
1505
|
+
const requestSpec = isPost
|
|
1506
|
+
? { body: additionalParams, params: queryParams }
|
|
1507
|
+
: { params: { ...additionalParams, ...queryParams } };
|
|
1441
1508
|
const paginatedResponse = await serviceAccess.requestWithPagination(method, endpoint, paginationParams, {
|
|
1442
1509
|
headers,
|
|
1443
|
-
|
|
1510
|
+
...requestSpec,
|
|
1444
1511
|
pagination: {
|
|
1445
1512
|
paginationType: options.paginationType || PaginationType.OFFSET,
|
|
1446
1513
|
itemsField: options.itemsField || DEFAULT_ITEMS_FIELD,
|
|
@@ -1465,7 +1532,7 @@ class PaginationHelpers {
|
|
|
1465
1532
|
* @returns Promise resolving to an object with data and totalCount
|
|
1466
1533
|
*/
|
|
1467
1534
|
static async getAllNonPaginated(params) {
|
|
1468
|
-
const { serviceAccess, getAllEndpoint, getByFolderEndpoint, folderId, headers: providedHeaders, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
|
|
1535
|
+
const { serviceAccess, getAllEndpoint, getByFolderEndpoint, folderId, headers: providedHeaders, additionalParams, queryParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
|
|
1469
1536
|
// Set default field names
|
|
1470
1537
|
const itemsField = options.itemsField || DEFAULT_ITEMS_FIELD;
|
|
1471
1538
|
const totalCountField = options.totalCountField || DEFAULT_TOTAL_COUNT_FIELD;
|
|
@@ -1475,17 +1542,18 @@ class PaginationHelpers {
|
|
|
1475
1542
|
// Make the API call based on method
|
|
1476
1543
|
let response;
|
|
1477
1544
|
if (method === HTTP_METHODS.POST) {
|
|
1478
|
-
response = await serviceAccess.post(endpoint, additionalParams, { headers });
|
|
1545
|
+
response = await serviceAccess.post(endpoint, additionalParams, { headers, params: queryParams });
|
|
1479
1546
|
}
|
|
1480
1547
|
else {
|
|
1481
1548
|
response = await serviceAccess.get(endpoint, {
|
|
1482
|
-
params: additionalParams,
|
|
1549
|
+
params: { ...additionalParams, ...queryParams },
|
|
1483
1550
|
headers
|
|
1484
1551
|
});
|
|
1485
1552
|
}
|
|
1486
1553
|
// Extract and transform items from response
|
|
1487
|
-
// Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N })
|
|
1488
|
-
|
|
1554
|
+
// Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N }).
|
|
1555
|
+
// itemsField may be a dotted path (e.g. 'data.agents') for nested envelopes.
|
|
1556
|
+
const rawItems = Array.isArray(response.data) ? response.data : resolveNestedField(response.data, itemsField);
|
|
1489
1557
|
const rawTotalCount = Array.isArray(response.data) ? undefined : resolveNestedField(response.data, totalCountField);
|
|
1490
1558
|
const totalCount = typeof rawTotalCount === 'number' ? rawTotalCount : undefined;
|
|
1491
1559
|
// Parse items - automatically handle JSON string responses
|
|
@@ -1531,8 +1599,9 @@ class PaginationHelpers {
|
|
|
1531
1599
|
getEndpoint: config.getEndpoint,
|
|
1532
1600
|
folderId,
|
|
1533
1601
|
headers: config.headers,
|
|
1534
|
-
paginationParams: cursor ? { cursor, pageSize } : jumpToPage ? { jumpToPage, pageSize } : { pageSize },
|
|
1602
|
+
paginationParams: cursor ? { cursor, pageSize } : jumpToPage !== undefined ? { jumpToPage, pageSize } : { pageSize },
|
|
1535
1603
|
additionalParams: prefixedOptions,
|
|
1604
|
+
queryParams: config.queryParams,
|
|
1536
1605
|
transformFn: config.transformFn,
|
|
1537
1606
|
method: config.method,
|
|
1538
1607
|
options: {
|
|
@@ -1550,6 +1619,7 @@ class PaginationHelpers {
|
|
|
1550
1619
|
folderId,
|
|
1551
1620
|
headers: config.headers,
|
|
1552
1621
|
additionalParams: prefixedOptions,
|
|
1622
|
+
queryParams: config.queryParams,
|
|
1553
1623
|
transformFn: config.transformFn,
|
|
1554
1624
|
method: config.method,
|
|
1555
1625
|
options: {
|
|
@@ -1741,18 +1811,17 @@ class BaseService {
|
|
|
1741
1811
|
const params = this.validateAndPreparePaginationParams(paginationType, paginationOptions);
|
|
1742
1812
|
// Prepare request parameters based on pagination type
|
|
1743
1813
|
const requestParams = this.preparePaginationRequestParams(paginationType, params, options.pagination);
|
|
1744
|
-
//
|
|
1814
|
+
// Route pagination state to wherever the API expects it (body for POST, URL for GET).
|
|
1815
|
+
// Caller-supplied options.body / options.params are respected as-is — the api-client
|
|
1816
|
+
// already handles params (URL) and body (request body) independently for every method.
|
|
1745
1817
|
if (method.toUpperCase() === 'POST') {
|
|
1746
1818
|
const existingBody = (options.body && typeof options.body === 'object') ? options.body : {};
|
|
1747
1819
|
options.body = {
|
|
1748
1820
|
...existingBody,
|
|
1749
|
-
...options.params,
|
|
1750
1821
|
...requestParams
|
|
1751
1822
|
};
|
|
1752
|
-
options.params = undefined;
|
|
1753
1823
|
}
|
|
1754
1824
|
else {
|
|
1755
|
-
// Merge pagination parameters with existing parameters
|
|
1756
1825
|
options.params = {
|
|
1757
1826
|
...options.params,
|
|
1758
1827
|
...requestParams
|
|
@@ -1789,6 +1858,8 @@ class BaseService {
|
|
|
1789
1858
|
// When true (default), converts pageNumber to a skip/offset value (e.g., page 3 with pageSize 10 → skip 20).
|
|
1790
1859
|
// When false, passes pageNumber directly as the offset param — used by APIs that accept a page number instead of a record offset.
|
|
1791
1860
|
const convertToSkip = paginationParams?.convertToSkip ?? true;
|
|
1861
|
+
// When true, sends pageNumber - 1 (for 0-based APIs). Default false (1-based).
|
|
1862
|
+
const zeroBased = paginationParams?.zeroBased ?? false;
|
|
1792
1863
|
requestParams[pageSizeParam] = limitedPageSize;
|
|
1793
1864
|
if (convertToSkip) {
|
|
1794
1865
|
if (params.pageNumber && params.pageNumber > 1) {
|
|
@@ -1796,7 +1867,8 @@ class BaseService {
|
|
|
1796
1867
|
}
|
|
1797
1868
|
}
|
|
1798
1869
|
else {
|
|
1799
|
-
|
|
1870
|
+
const sdkPageNumber = params.pageNumber || 1;
|
|
1871
|
+
requestParams[offsetParam] = zeroBased ? sdkPageNumber - 1 : sdkPageNumber;
|
|
1800
1872
|
}
|
|
1801
1873
|
{
|
|
1802
1874
|
requestParams[countParam] = true;
|
|
@@ -1825,8 +1897,9 @@ class BaseService {
|
|
|
1825
1897
|
const totalCountField = fields.totalCountField || 'totalRecordCount';
|
|
1826
1898
|
const continuationTokenField = fields.continuationTokenField || 'continuationToken';
|
|
1827
1899
|
// Extract items and metadata
|
|
1828
|
-
// Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N })
|
|
1829
|
-
|
|
1900
|
+
// Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N }).
|
|
1901
|
+
// itemsField may be a dotted path (e.g. 'data.agents') for nested envelopes.
|
|
1902
|
+
const items = Array.isArray(response.data) ? response.data : (resolveNestedField(response.data, itemsField) || []);
|
|
1830
1903
|
const rawTotalCount = Array.isArray(response.data) ? undefined : resolveNestedField(response.data, totalCountField);
|
|
1831
1904
|
const totalCount = typeof rawTotalCount === 'number' ? rawTotalCount : undefined;
|
|
1832
1905
|
const continuationToken = response.data[continuationTokenField];
|
|
@@ -1913,7 +1986,9 @@ function createProcessInstanceMethods(instanceData, service) {
|
|
|
1913
1986
|
async getExecutionHistory() {
|
|
1914
1987
|
if (!instanceData.instanceId)
|
|
1915
1988
|
throw new Error('Process instance ID is undefined');
|
|
1916
|
-
|
|
1989
|
+
if (!instanceData.folderKey)
|
|
1990
|
+
throw new Error('Process instance folder key is undefined');
|
|
1991
|
+
return service.getExecutionHistory(instanceData.instanceId, instanceData.folderKey);
|
|
1917
1992
|
},
|
|
1918
1993
|
async getBpmn() {
|
|
1919
1994
|
if (!instanceData.instanceId)
|
|
@@ -2110,12 +2185,6 @@ const ProcessInstanceMap = {
|
|
|
2110
2185
|
createdAt: 'createdTime',
|
|
2111
2186
|
updatedAt: 'updatedTime'
|
|
2112
2187
|
};
|
|
2113
|
-
/**
|
|
2114
|
-
* Maps fields for Process Instance Execution History to ensure consistent naming
|
|
2115
|
-
*/
|
|
2116
|
-
const ProcessInstanceExecutionHistoryMap = {
|
|
2117
|
-
startTime: 'startedTime'
|
|
2118
|
-
};
|
|
2119
2188
|
|
|
2120
2189
|
class ProcessInstancesService extends BaseService {
|
|
2121
2190
|
/**
|
|
@@ -2196,11 +2265,66 @@ class ProcessInstancesService extends BaseService {
|
|
|
2196
2265
|
/**
|
|
2197
2266
|
* Get execution history (spans) for a process instance
|
|
2198
2267
|
* @param instanceId The ID of the instance to get history for
|
|
2199
|
-
* @
|
|
2268
|
+
* @param folderKey The folder key for authorization
|
|
2269
|
+
* @returns Promise resolving to execution history
|
|
2270
|
+
* {@link ProcessInstanceExecutionHistoryResponse}
|
|
2271
|
+
* @example
|
|
2272
|
+
* ```typescript
|
|
2273
|
+
* // Get execution history for a process instance
|
|
2274
|
+
* const history = await processInstances.getExecutionHistory(
|
|
2275
|
+
* <instanceId>,
|
|
2276
|
+
* <folderKey>
|
|
2277
|
+
* );
|
|
2278
|
+
*
|
|
2279
|
+
* // Analyze execution timeline
|
|
2280
|
+
* history.forEach(span => {
|
|
2281
|
+
* console.log(`Activity: ${span.name}`);
|
|
2282
|
+
* console.log(`Start: ${span.startedTime}`);
|
|
2283
|
+
* console.log(`End: ${span.endTime}`);
|
|
2284
|
+
* });
|
|
2285
|
+
* ```
|
|
2200
2286
|
*/
|
|
2201
|
-
async getExecutionHistory(instanceId) {
|
|
2202
|
-
const
|
|
2203
|
-
|
|
2287
|
+
async getExecutionHistory(instanceId, folderKey) {
|
|
2288
|
+
const headers = createHeaders({ [FOLDER_KEY]: folderKey });
|
|
2289
|
+
const elementExecResponse = await this.get(MAESTRO_ENDPOINTS.INSTANCES.GET_ELEMENT_EXECUTIONS(instanceId), { headers });
|
|
2290
|
+
const traceId = elementExecResponse.data.traceId;
|
|
2291
|
+
const spansResponse = await this.get(MAESTRO_ENDPOINTS.TRACES.GET_SPANS(traceId), { headers });
|
|
2292
|
+
// Build span lookup keyed by elementRunId extracted from Attributes JSON
|
|
2293
|
+
const spanMap = new Map();
|
|
2294
|
+
for (const span of spansResponse.data) {
|
|
2295
|
+
try {
|
|
2296
|
+
const attrs = span.Attributes ? JSON.parse(span.Attributes) : null;
|
|
2297
|
+
if (attrs?.elementRunId) {
|
|
2298
|
+
spanMap.set(attrs.elementRunId, span);
|
|
2299
|
+
}
|
|
2300
|
+
}
|
|
2301
|
+
catch {
|
|
2302
|
+
// skip spans with unparseable Attributes — they won't match any elementRunId
|
|
2303
|
+
}
|
|
2304
|
+
}
|
|
2305
|
+
const results = [];
|
|
2306
|
+
for (const elementExec of elementExecResponse.data.elementExecutions) {
|
|
2307
|
+
for (const run of elementExec.elementRuns) {
|
|
2308
|
+
const span = spanMap.get(run.elementRunId);
|
|
2309
|
+
if (span) {
|
|
2310
|
+
results.push(this.mapSpanToHistory(span));
|
|
2311
|
+
}
|
|
2312
|
+
}
|
|
2313
|
+
}
|
|
2314
|
+
return results;
|
|
2315
|
+
}
|
|
2316
|
+
mapSpanToHistory(span) {
|
|
2317
|
+
return {
|
|
2318
|
+
id: span.Id,
|
|
2319
|
+
traceId: span.TraceId,
|
|
2320
|
+
parentId: span.ParentId,
|
|
2321
|
+
name: span.Name,
|
|
2322
|
+
startedTime: span.StartTime,
|
|
2323
|
+
endTime: span.EndTime,
|
|
2324
|
+
attributes: span.Attributes,
|
|
2325
|
+
updatedTime: span.UpdatedAt,
|
|
2326
|
+
expiredTime: span.ExpiryTimeUtc,
|
|
2327
|
+
};
|
|
2204
2328
|
}
|
|
2205
2329
|
/**
|
|
2206
2330
|
* Get BPMN XML file for a process instance
|
|
@@ -2692,6 +2816,41 @@ class MaestroProcessesService extends BaseService {
|
|
|
2692
2816
|
const { data } = await this.post(MAESTRO_ENDPOINTS.INSIGHTS.TOP_PROCESSES_BY_DURATION, buildInsightsTopBody(startTime, endTime, false, options));
|
|
2693
2817
|
return (data ?? []).map(process => ({ ...process, name: process.packageId }));
|
|
2694
2818
|
}
|
|
2819
|
+
/**
|
|
2820
|
+
* Get element stats for process instances
|
|
2821
|
+
*
|
|
2822
|
+
* Returns per-element execution counts (success, fail, terminated, paused, in-progress) and
|
|
2823
|
+
* duration percentile metrics (min, max, avg, p50, p95, p99) for BPMN elements within a process.
|
|
2824
|
+
*
|
|
2825
|
+
* @param processKey - Process key to filter by
|
|
2826
|
+
* @param packageId - Package identifier
|
|
2827
|
+
* @param startTime - Start of the time range to query
|
|
2828
|
+
* @param endTime - End of the time range to query
|
|
2829
|
+
* @param packageVersion - Package version to filter by
|
|
2830
|
+
* @returns Promise resolving to an array of {@link ElementStats}
|
|
2831
|
+
* @example
|
|
2832
|
+
* ```typescript
|
|
2833
|
+
* // Get element metrics for a process
|
|
2834
|
+
* const elements = await maestroProcesses.getElementStats(
|
|
2835
|
+
* '<processKey>',
|
|
2836
|
+
* '<packageId>',
|
|
2837
|
+
* new Date('2026-04-01'),
|
|
2838
|
+
* new Date(),
|
|
2839
|
+
* '1.0.1'
|
|
2840
|
+
* );
|
|
2841
|
+
*
|
|
2842
|
+
* // Analyze element performance
|
|
2843
|
+
* for (const element of elements) {
|
|
2844
|
+
* console.log(`Element: ${element.elementId}`);
|
|
2845
|
+
* console.log(` Success: ${element.successCount}, Failed: ${element.failCount}`);
|
|
2846
|
+
* console.log(` Avg duration: ${element.avgDurationMs}ms, P95: ${element.p95DurationMs}ms`);
|
|
2847
|
+
* }
|
|
2848
|
+
* ```
|
|
2849
|
+
*/
|
|
2850
|
+
async getElementStats(processKey, packageId, startTime, endTime, packageVersion) {
|
|
2851
|
+
const { data } = await this.post(MAESTRO_ENDPOINTS.INSIGHTS.ELEMENT_COUNT_BY_STATUS, buildElementCountByStatusBody(processKey, packageId, startTime, endTime, packageVersion));
|
|
2852
|
+
return data ?? [];
|
|
2853
|
+
}
|
|
2695
2854
|
}
|
|
2696
2855
|
__decorate([
|
|
2697
2856
|
track('MaestroProcesses.GetAll')
|
|
@@ -2714,6 +2873,9 @@ __decorate([
|
|
|
2714
2873
|
__decorate([
|
|
2715
2874
|
track('MaestroProcesses.GetTopExecutionDuration')
|
|
2716
2875
|
], MaestroProcessesService.prototype, "getTopExecutionDuration", null);
|
|
2876
|
+
__decorate([
|
|
2877
|
+
track('MaestroProcesses.GetElementStats')
|
|
2878
|
+
], MaestroProcessesService.prototype, "getElementStats", null);
|
|
2717
2879
|
|
|
2718
2880
|
/**
|
|
2719
2881
|
* Service class for Maestro Process Incidents
|