@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.
Files changed (56) hide show
  1. package/dist/agent-memory/index.cjs +1765 -0
  2. package/dist/agent-memory/index.d.ts +588 -0
  3. package/dist/agent-memory/index.mjs +1763 -0
  4. package/dist/agents/index.cjs +1726 -0
  5. package/dist/agents/index.d.ts +502 -0
  6. package/dist/agents/index.mjs +1724 -0
  7. package/dist/assets/index.cjs +155 -30
  8. package/dist/assets/index.d.ts +84 -5
  9. package/dist/assets/index.mjs +155 -30
  10. package/dist/attachments/index.cjs +37 -6
  11. package/dist/attachments/index.d.ts +1 -0
  12. package/dist/attachments/index.mjs +37 -6
  13. package/dist/buckets/index.cjs +37 -6
  14. package/dist/buckets/index.d.ts +1 -0
  15. package/dist/buckets/index.mjs +37 -6
  16. package/dist/cases/index.cjs +141 -10
  17. package/dist/cases/index.d.ts +118 -7
  18. package/dist/cases/index.mjs +141 -11
  19. package/dist/conversational-agent/index.cjs +124 -57
  20. package/dist/conversational-agent/index.d.ts +190 -122
  21. package/dist/conversational-agent/index.mjs +124 -57
  22. package/dist/core/index.cjs +413 -105
  23. package/dist/core/index.d.ts +15 -0
  24. package/dist/core/index.mjs +413 -105
  25. package/dist/entities/index.cjs +122 -43
  26. package/dist/entities/index.d.ts +140 -35
  27. package/dist/entities/index.mjs +122 -43
  28. package/dist/feedback/index.cjs +37 -6
  29. package/dist/feedback/index.d.ts +1 -0
  30. package/dist/feedback/index.mjs +37 -6
  31. package/dist/governance/index.cjs +1782 -0
  32. package/dist/governance/index.d.ts +598 -0
  33. package/dist/governance/index.mjs +1780 -0
  34. package/dist/index.cjs +956 -283
  35. package/dist/index.d.ts +1138 -121
  36. package/dist/index.mjs +956 -284
  37. package/dist/index.umd.js +3113 -2423
  38. package/dist/jobs/index.cjs +37 -6
  39. package/dist/jobs/index.d.ts +1 -0
  40. package/dist/jobs/index.mjs +37 -6
  41. package/dist/maestro-processes/index.cjs +173 -18
  42. package/dist/maestro-processes/index.d.ts +131 -9
  43. package/dist/maestro-processes/index.mjs +173 -18
  44. package/dist/processes/index.cjs +37 -6
  45. package/dist/processes/index.d.ts +1 -0
  46. package/dist/processes/index.mjs +37 -6
  47. package/dist/queues/index.cjs +37 -6
  48. package/dist/queues/index.d.ts +1 -0
  49. package/dist/queues/index.mjs +37 -6
  50. package/dist/tasks/index.cjs +37 -6
  51. package/dist/tasks/index.d.ts +1 -0
  52. package/dist/tasks/index.mjs +37 -6
  53. package/dist/traces/index.cjs +37 -6
  54. package/dist/traces/index.d.ts +1 -0
  55. package/dist/traces/index.mjs +37 -6
  56. package/package.json +32 -2
@@ -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
- const rawItems = Array.isArray(response.data) ? response.data : response.data?.[itemsField];
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
- requestParams[offsetParam] = params.pageNumber || 1;
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
- const items = Array.isArray(response.data) ? response.data : (response.data[itemsField] || []);
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];
@@ -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
  }
@@ -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
- const rawItems = Array.isArray(response.data) ? response.data : response.data?.[itemsField];
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
- requestParams[offsetParam] = params.pageNumber || 1;
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
- const items = Array.isArray(response.data) ? response.data : (response.data[itemsField] || []);
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];
@@ -48,6 +48,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
48
48
  * Base path constants for different services
49
49
  */
50
50
  const PIMS_BASE = 'pims_';
51
+ const LLMOPS_BASE = 'llmopstenant_';
51
52
  const INSIGHTS_RTM_BASE = 'insightsrtm_';
52
53
 
53
54
  /**
@@ -62,7 +63,7 @@ const MAESTRO_ENDPOINTS = {
62
63
  INSTANCES: {
63
64
  GET_ALL: `${PIMS_BASE}/api/v1/instances`,
64
65
  GET_BY_ID: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}`,
65
- GET_EXECUTION_HISTORY: (instanceId) => `${PIMS_BASE}/api/v1/spans/${instanceId}`,
66
+ GET_ELEMENT_EXECUTIONS: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/element-executions`,
66
67
  GET_BPMN: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/bpmn`,
67
68
  GET_VARIABLES: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/variables`,
68
69
  CANCEL: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/cancel`,
@@ -74,6 +75,9 @@ const MAESTRO_ENDPOINTS = {
74
75
  GET_BY_PROCESS: (processKey) => `${PIMS_BASE}/api/v1/incidents/process/${processKey}`,
75
76
  GET_BY_INSTANCE: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/incidents`,
76
77
  },
78
+ TRACES: {
79
+ GET_SPANS: (traceId) => `${LLMOPS_BASE}/api/Traces/spans?traceId=${traceId}`,
80
+ },
77
81
  INSIGHTS: {
78
82
  /** Top processes ranked by run count */
79
83
  TOP_PROCESSES_BY_RUN_COUNT: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/TopProcessesByRunCount`,
@@ -85,6 +89,8 @@ const MAESTRO_ENDPOINTS = {
85
89
  INSTANCE_STATUS_BY_DATE: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/InstanceStatusByDate`,
86
90
  /** Top processes ranked by total duration */
87
91
  TOP_PROCESSES_BY_DURATION: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/TopProcessesByDuration`,
92
+ /** Element count by status for agentic instances (process and case) */
93
+ ELEMENT_COUNT_BY_STATUS: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/ElementCountByStatus`,
88
94
  },
89
95
  };
90
96
 
@@ -107,6 +113,13 @@ function createProcessMethods(processData, service) {
107
113
  if (!processData.folderKey)
108
114
  throw new Error('Folder key is undefined');
109
115
  return service.getIncidents(processData.processKey, processData.folderKey);
116
+ },
117
+ getElementStats(startTime, endTime, packageVersion) {
118
+ if (!processData.processKey)
119
+ throw new Error('Process key is undefined');
120
+ if (!processData.packageId)
121
+ throw new Error('Package ID is undefined');
122
+ return service.getElementStats(processData.processKey, processData.packageId, startTime, endTime, packageVersion);
110
123
  }
111
124
  };
112
125
  }
@@ -168,6 +181,28 @@ async function fetchInstanceStatusTimeline(postFn, startTime, endTime, isCaseMan
168
181
  });
169
182
  return response.data ?? [];
170
183
  }
184
+ /**
185
+ * Builds the request body for the ElementCountByStatus endpoint.
186
+ *
187
+ * @param processKey - Process key to filter by
188
+ * @param packageId - Package identifier
189
+ * @param startTime - Start of the time range to query
190
+ * @param endTime - End of the time range to query
191
+ * @param packageVersion - Package version to filter by
192
+ * @returns Request body for the ElementCountByStatus endpoint
193
+ * @internal
194
+ */
195
+ function buildElementCountByStatusBody(processKey, packageId, startTime, endTime, packageVersion) {
196
+ return {
197
+ commonParams: {
198
+ processKey,
199
+ packageId,
200
+ startTime: startTime.getTime(),
201
+ endTime: endTime.getTime(),
202
+ version: packageVersion
203
+ }
204
+ };
205
+ }
171
206
 
172
207
  /**
173
208
  * Common constants used across the SDK
@@ -1160,6 +1195,32 @@ function filterUndefined(obj) {
1160
1195
  */
1161
1196
  const isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
1162
1197
  isBrowser && window.self != window.top && window.location.href.includes('source=ActionCenter');
1198
+ const _params = isBrowser ? new URLSearchParams(window.location.search) : null;
1199
+ /**
1200
+ * True when the coded app has been loaded inside a host frame that explicitly
1201
+ * opted into token delegation by adding `?host=embed` to the iframe src URL.
1202
+ */
1203
+ const isHostEmbedded = isBrowser && window.self !== window.top && _params?.get('host') === 'embed';
1204
+ /**
1205
+ * The validated parent origin, read from the `?basedomain=` query param set
1206
+ * by the embedding host in the iframe src URL.
1207
+ * Mirrors the same mechanism used by ActionCenterTokenManager.
1208
+ * Non-null only when `?host=embed` is present and `?basedomain=` is a valid URL.
1209
+ */
1210
+ (() => {
1211
+ if (!isHostEmbedded)
1212
+ return null;
1213
+ const basedomain = _params?.get('basedomain');
1214
+ if (!basedomain)
1215
+ return null;
1216
+ try {
1217
+ return new URL(basedomain).origin;
1218
+ }
1219
+ catch {
1220
+ console.warn('embeddingOrigin: basedomain query param is not a valid URL', basedomain);
1221
+ return null;
1222
+ }
1223
+ })();
1163
1224
 
1164
1225
  /**
1165
1226
  * Base64 encoding/decoding
@@ -1486,8 +1547,9 @@ class PaginationHelpers {
1486
1547
  });
1487
1548
  }
1488
1549
  // Extract and transform items from response
1489
- // Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N })
1490
- const rawItems = Array.isArray(response.data) ? response.data : response.data?.[itemsField];
1550
+ // Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N }).
1551
+ // itemsField may be a dotted path (e.g. 'data.agents') for nested envelopes.
1552
+ const rawItems = Array.isArray(response.data) ? response.data : resolveNestedField(response.data, itemsField);
1491
1553
  const rawTotalCount = Array.isArray(response.data) ? undefined : resolveNestedField(response.data, totalCountField);
1492
1554
  const totalCount = typeof rawTotalCount === 'number' ? rawTotalCount : undefined;
1493
1555
  // Parse items - automatically handle JSON string responses
@@ -1533,7 +1595,7 @@ class PaginationHelpers {
1533
1595
  getEndpoint: config.getEndpoint,
1534
1596
  folderId,
1535
1597
  headers: config.headers,
1536
- paginationParams: cursor ? { cursor, pageSize } : jumpToPage ? { jumpToPage, pageSize } : { pageSize },
1598
+ paginationParams: cursor ? { cursor, pageSize } : jumpToPage !== undefined ? { jumpToPage, pageSize } : { pageSize },
1537
1599
  additionalParams: prefixedOptions,
1538
1600
  transformFn: config.transformFn,
1539
1601
  method: config.method,
@@ -1791,6 +1853,8 @@ class BaseService {
1791
1853
  // When true (default), converts pageNumber to a skip/offset value (e.g., page 3 with pageSize 10 → skip 20).
1792
1854
  // When false, passes pageNumber directly as the offset param — used by APIs that accept a page number instead of a record offset.
1793
1855
  const convertToSkip = paginationParams?.convertToSkip ?? true;
1856
+ // When true, sends pageNumber - 1 (for 0-based APIs). Default false (1-based).
1857
+ const zeroBased = paginationParams?.zeroBased ?? false;
1794
1858
  requestParams[pageSizeParam] = limitedPageSize;
1795
1859
  if (convertToSkip) {
1796
1860
  if (params.pageNumber && params.pageNumber > 1) {
@@ -1798,7 +1862,8 @@ class BaseService {
1798
1862
  }
1799
1863
  }
1800
1864
  else {
1801
- requestParams[offsetParam] = params.pageNumber || 1;
1865
+ const sdkPageNumber = params.pageNumber || 1;
1866
+ requestParams[offsetParam] = zeroBased ? sdkPageNumber - 1 : sdkPageNumber;
1802
1867
  }
1803
1868
  {
1804
1869
  requestParams[countParam] = true;
@@ -1827,8 +1892,9 @@ class BaseService {
1827
1892
  const totalCountField = fields.totalCountField || 'totalRecordCount';
1828
1893
  const continuationTokenField = fields.continuationTokenField || 'continuationToken';
1829
1894
  // Extract items and metadata
1830
- // Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N })
1831
- const items = Array.isArray(response.data) ? response.data : (response.data[itemsField] || []);
1895
+ // Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N }).
1896
+ // itemsField may be a dotted path (e.g. 'data.agents') for nested envelopes.
1897
+ const items = Array.isArray(response.data) ? response.data : (resolveNestedField(response.data, itemsField) || []);
1832
1898
  const rawTotalCount = Array.isArray(response.data) ? undefined : resolveNestedField(response.data, totalCountField);
1833
1899
  const totalCount = typeof rawTotalCount === 'number' ? rawTotalCount : undefined;
1834
1900
  const continuationToken = response.data[continuationTokenField];
@@ -1915,7 +1981,9 @@ function createProcessInstanceMethods(instanceData, service) {
1915
1981
  async getExecutionHistory() {
1916
1982
  if (!instanceData.instanceId)
1917
1983
  throw new Error('Process instance ID is undefined');
1918
- return service.getExecutionHistory(instanceData.instanceId);
1984
+ if (!instanceData.folderKey)
1985
+ throw new Error('Process instance folder key is undefined');
1986
+ return service.getExecutionHistory(instanceData.instanceId, instanceData.folderKey);
1919
1987
  },
1920
1988
  async getBpmn() {
1921
1989
  if (!instanceData.instanceId)
@@ -2112,12 +2180,6 @@ const ProcessInstanceMap = {
2112
2180
  createdAt: 'createdTime',
2113
2181
  updatedAt: 'updatedTime'
2114
2182
  };
2115
- /**
2116
- * Maps fields for Process Instance Execution History to ensure consistent naming
2117
- */
2118
- const ProcessInstanceExecutionHistoryMap = {
2119
- startTime: 'startedTime'
2120
- };
2121
2183
 
2122
2184
  class ProcessInstancesService extends BaseService {
2123
2185
  /**
@@ -2198,11 +2260,66 @@ class ProcessInstancesService extends BaseService {
2198
2260
  /**
2199
2261
  * Get execution history (spans) for a process instance
2200
2262
  * @param instanceId The ID of the instance to get history for
2201
- * @returns Promise<ProcessInstanceExecutionHistoryResponse[]>
2263
+ * @param folderKey The folder key for authorization
2264
+ * @returns Promise resolving to execution history
2265
+ * {@link ProcessInstanceExecutionHistoryResponse}
2266
+ * @example
2267
+ * ```typescript
2268
+ * // Get execution history for a process instance
2269
+ * const history = await processInstances.getExecutionHistory(
2270
+ * <instanceId>,
2271
+ * <folderKey>
2272
+ * );
2273
+ *
2274
+ * // Analyze execution timeline
2275
+ * history.forEach(span => {
2276
+ * console.log(`Activity: ${span.name}`);
2277
+ * console.log(`Start: ${span.startedTime}`);
2278
+ * console.log(`End: ${span.endTime}`);
2279
+ * });
2280
+ * ```
2202
2281
  */
2203
- async getExecutionHistory(instanceId) {
2204
- const response = await this.get(MAESTRO_ENDPOINTS.INSTANCES.GET_EXECUTION_HISTORY(instanceId));
2205
- return response.data.map(historyItem => transformData(historyItem, ProcessInstanceExecutionHistoryMap));
2282
+ async getExecutionHistory(instanceId, folderKey) {
2283
+ const headers = createHeaders({ [FOLDER_KEY]: folderKey });
2284
+ const elementExecResponse = await this.get(MAESTRO_ENDPOINTS.INSTANCES.GET_ELEMENT_EXECUTIONS(instanceId), { headers });
2285
+ const traceId = elementExecResponse.data.traceId;
2286
+ const spansResponse = await this.get(MAESTRO_ENDPOINTS.TRACES.GET_SPANS(traceId), { headers });
2287
+ // Build span lookup keyed by elementRunId extracted from Attributes JSON
2288
+ const spanMap = new Map();
2289
+ for (const span of spansResponse.data) {
2290
+ try {
2291
+ const attrs = span.Attributes ? JSON.parse(span.Attributes) : null;
2292
+ if (attrs?.elementRunId) {
2293
+ spanMap.set(attrs.elementRunId, span);
2294
+ }
2295
+ }
2296
+ catch {
2297
+ // skip spans with unparseable Attributes — they won't match any elementRunId
2298
+ }
2299
+ }
2300
+ const results = [];
2301
+ for (const elementExec of elementExecResponse.data.elementExecutions) {
2302
+ for (const run of elementExec.elementRuns) {
2303
+ const span = spanMap.get(run.elementRunId);
2304
+ if (span) {
2305
+ results.push(this.mapSpanToHistory(span));
2306
+ }
2307
+ }
2308
+ }
2309
+ return results;
2310
+ }
2311
+ mapSpanToHistory(span) {
2312
+ return {
2313
+ id: span.Id,
2314
+ traceId: span.TraceId,
2315
+ parentId: span.ParentId,
2316
+ name: span.Name,
2317
+ startedTime: span.StartTime,
2318
+ endTime: span.EndTime,
2319
+ attributes: span.Attributes,
2320
+ updatedTime: span.UpdatedAt,
2321
+ expiredTime: span.ExpiryTimeUtc,
2322
+ };
2206
2323
  }
2207
2324
  /**
2208
2325
  * Get BPMN XML file for a process instance
@@ -2694,6 +2811,41 @@ class MaestroProcessesService extends BaseService {
2694
2811
  const { data } = await this.post(MAESTRO_ENDPOINTS.INSIGHTS.TOP_PROCESSES_BY_DURATION, buildInsightsTopBody(startTime, endTime, false, options));
2695
2812
  return (data ?? []).map(process => ({ ...process, name: process.packageId }));
2696
2813
  }
2814
+ /**
2815
+ * Get element stats for process instances
2816
+ *
2817
+ * Returns per-element execution counts (success, fail, terminated, paused, in-progress) and
2818
+ * duration percentile metrics (min, max, avg, p50, p95, p99) for BPMN elements within a process.
2819
+ *
2820
+ * @param processKey - Process key to filter by
2821
+ * @param packageId - Package identifier
2822
+ * @param startTime - Start of the time range to query
2823
+ * @param endTime - End of the time range to query
2824
+ * @param packageVersion - Package version to filter by
2825
+ * @returns Promise resolving to an array of {@link ElementStats}
2826
+ * @example
2827
+ * ```typescript
2828
+ * // Get element metrics for a process
2829
+ * const elements = await maestroProcesses.getElementStats(
2830
+ * '<processKey>',
2831
+ * '<packageId>',
2832
+ * new Date('2026-04-01'),
2833
+ * new Date(),
2834
+ * '1.0.1'
2835
+ * );
2836
+ *
2837
+ * // Analyze element performance
2838
+ * for (const element of elements) {
2839
+ * console.log(`Element: ${element.elementId}`);
2840
+ * console.log(` Success: ${element.successCount}, Failed: ${element.failCount}`);
2841
+ * console.log(` Avg duration: ${element.avgDurationMs}ms, P95: ${element.p95DurationMs}ms`);
2842
+ * }
2843
+ * ```
2844
+ */
2845
+ async getElementStats(processKey, packageId, startTime, endTime, packageVersion) {
2846
+ const { data } = await this.post(MAESTRO_ENDPOINTS.INSIGHTS.ELEMENT_COUNT_BY_STATUS, buildElementCountByStatusBody(processKey, packageId, startTime, endTime, packageVersion));
2847
+ return data ?? [];
2848
+ }
2697
2849
  }
2698
2850
  __decorate([
2699
2851
  track('MaestroProcesses.GetAll')
@@ -2716,6 +2868,9 @@ __decorate([
2716
2868
  __decorate([
2717
2869
  track('MaestroProcesses.GetTopExecutionDuration')
2718
2870
  ], MaestroProcessesService.prototype, "getTopExecutionDuration", null);
2871
+ __decorate([
2872
+ track('MaestroProcesses.GetElementStats')
2873
+ ], MaestroProcessesService.prototype, "getElementStats", null);
2719
2874
 
2720
2875
  /**
2721
2876
  * Service class for Maestro Process Incidents