@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
@@ -109,6 +109,35 @@ interface GetTopDurationResponse extends GetTopBaseResponse {
109
109
  /** Total execution duration in milliseconds */
110
110
  duration: number;
111
111
  }
112
+ /**
113
+ * Element count by status for a BPMN element within a process or case
114
+ */
115
+ interface ElementStats {
116
+ /** BPMN element identifier */
117
+ elementId: string;
118
+ /** Number of successful executions */
119
+ successCount: number;
120
+ /** Number of failed executions */
121
+ failCount: number;
122
+ /** Number of terminated executions */
123
+ terminatedCount: number;
124
+ /** Number of paused executions */
125
+ pausedCount: number;
126
+ /** Number of in-progress executions */
127
+ inProgressCount: number;
128
+ /** Minimum duration in milliseconds */
129
+ minDurationMs: number;
130
+ /** Maximum duration in milliseconds */
131
+ maxDurationMs: number;
132
+ /** Average duration in milliseconds */
133
+ avgDurationMs: number;
134
+ /** 50th percentile (median) duration in milliseconds */
135
+ p50DurationMs: number;
136
+ /** 95th percentile duration in milliseconds */
137
+ p95DurationMs: number;
138
+ /** 99th percentile duration in milliseconds */
139
+ p99DurationMs: number;
140
+ }
112
141
 
113
142
  /**
114
143
  * Simplified universal pagination cursor
@@ -293,8 +322,7 @@ interface CaseGetTopDurationResponse extends GetTopDurationResponse {
293
322
  */
294
323
  interface CasesServiceModel {
295
324
  /**
296
- * @returns Promise resolving to array of Case objects
297
- * {@link CaseGetAllResponse}
325
+ * @returns Promise resolving to an array of {@link CaseGetAllWithMethodsResponse}
298
326
  * @example
299
327
  * ```typescript
300
328
  * // Get all case management processes
@@ -308,7 +336,7 @@ interface CasesServiceModel {
308
336
  * }
309
337
  * ```
310
338
  */
311
- getAll(): Promise<CaseGetAllResponse[]>;
339
+ getAll(): Promise<CaseGetAllWithMethodsResponse[]>;
312
340
  /**
313
341
  * Get the top 5 case processes ranked by run count within a time range.
314
342
  *
@@ -502,7 +530,58 @@ interface CasesServiceModel {
502
530
  * ```
503
531
  */
504
532
  getTopExecutionDuration(startTime: Date, endTime: Date, options?: TopQueryOptions): Promise<CaseGetTopDurationResponse[]>;
533
+ /**
534
+ * Get element stats for case instances
535
+ *
536
+ * Returns per-element execution counts (success, fail, terminated, paused, in-progress) and
537
+ * duration percentile metrics (min, max, avg, p50, p95, p99) for BPMN elements within a case.
538
+ *
539
+ * @param processKey - Process key to filter by
540
+ * @param packageId - Package identifier
541
+ * @param startTime - Start of the time range to query
542
+ * @param endTime - End of the time range to query
543
+ * @param packageVersion - Package version to filter by
544
+ * @returns Promise resolving to an array of {@link ElementStats}
545
+ * @example
546
+ * ```typescript
547
+ * // Get element metrics for a case
548
+ * const elements = await cases.getElementStats(
549
+ * '<processKey>',
550
+ * '<packageId>',
551
+ * new Date('2026-04-01'),
552
+ * new Date(),
553
+ * '1.0.1'
554
+ * );
555
+ *
556
+ * // Find elements with failures
557
+ * const failedElements = elements.filter(e => e.failCount > 0);
558
+ * for (const element of failedElements) {
559
+ * console.log(`Failed element: ${element.elementId}, failures: ${element.failCount}`);
560
+ * }
561
+ * ```
562
+ */
563
+ getElementStats(processKey: string, packageId: string, startTime: Date, endTime: Date, packageVersion: string): Promise<ElementStats[]>;
564
+ }
565
+ interface CaseMethods {
566
+ /**
567
+ * Get element stats for this case
568
+ *
569
+ * @param startTime - Start of the time range to query
570
+ * @param endTime - End of the time range to query
571
+ * @param packageVersion - Package version to filter by
572
+ * @returns Promise resolving to an array of {@link ElementStats}
573
+ */
574
+ getElementStats(startTime: Date, endTime: Date, packageVersion: string): Promise<ElementStats[]>;
505
575
  }
576
+ type CaseGetAllWithMethodsResponse = CaseGetAllResponse & CaseMethods;
577
+ /**
578
+ * Creates an actionable case by combining API case data with operational methods.
579
+ *
580
+ * @param caseData - The case data from API
581
+ * @param service - The cases service instance
582
+ * @returns A case object with added methods
583
+ */
584
+ declare function createCaseWithMethods(caseData: CaseGetAllResponse, service: CasesServiceModel): CaseGetAllWithMethodsResponse;
506
585
 
507
586
  /**
508
587
  * Case Instance Types
@@ -1557,6 +1636,7 @@ interface RequestWithPaginationOptions extends RequestSpec {
1557
1636
  tokenParam?: string;
1558
1637
  countParam?: string;
1559
1638
  convertToSkip?: boolean;
1639
+ zeroBased?: boolean;
1560
1640
  };
1561
1641
  };
1562
1642
  }
@@ -1755,7 +1835,7 @@ declare class BaseService {
1755
1835
  declare class CasesService extends BaseService implements CasesServiceModel {
1756
1836
  /**
1757
1837
  * Get all case management processes with their instance statistics
1758
- * @returns Promise resolving to array of Case objects
1838
+ * @returns Promise resolving to an array of {@link CaseGetAllWithMethodsResponse}
1759
1839
  *
1760
1840
  * @example
1761
1841
  * ```typescript
@@ -1772,7 +1852,7 @@ declare class CasesService extends BaseService implements CasesServiceModel {
1772
1852
  * }
1773
1853
  * ```
1774
1854
  */
1775
- getAll(): Promise<CaseGetAllResponse[]>;
1855
+ getAll(): Promise<CaseGetAllWithMethodsResponse[]>;
1776
1856
  /**
1777
1857
  * Get the top 5 case processes ranked by run count within a time range.
1778
1858
  *
@@ -1966,6 +2046,37 @@ declare class CasesService extends BaseService implements CasesServiceModel {
1966
2046
  * ```
1967
2047
  */
1968
2048
  getTopExecutionDuration(startTime: Date, endTime: Date, options?: TopQueryOptions): Promise<CaseGetTopDurationResponse[]>;
2049
+ /**
2050
+ * Get element stats for case instances
2051
+ *
2052
+ * Returns per-element execution counts (success, fail, terminated, paused, in-progress) and
2053
+ * duration percentile metrics (min, max, avg, p50, p95, p99) for BPMN elements within a case.
2054
+ *
2055
+ * @param processKey - Process key to filter by
2056
+ * @param packageId - Package identifier
2057
+ * @param startTime - Start of the time range to query
2058
+ * @param endTime - End of the time range to query
2059
+ * @param packageVersion - Package version to filter by
2060
+ * @returns Promise resolving to an array of {@link ElementStats}
2061
+ * @example
2062
+ * ```typescript
2063
+ * // Get element metrics for a case
2064
+ * const elements = await cases.getElementStats(
2065
+ * '<processKey>',
2066
+ * '<packageId>',
2067
+ * new Date('2026-04-01'),
2068
+ * new Date(),
2069
+ * '1.0.1'
2070
+ * );
2071
+ *
2072
+ * // Find elements with failures
2073
+ * const failedElements = elements.filter(e => e.failCount > 0);
2074
+ * for (const element of failedElements) {
2075
+ * console.log(`Failed element: ${element.elementId}, failures: ${element.failCount}`);
2076
+ * }
2077
+ * ```
2078
+ */
2079
+ getElementStats(processKey: string, packageId: string, startTime: Date, endTime: Date, packageVersion: string): Promise<ElementStats[]>;
1969
2080
  /**
1970
2081
  * Extract a readable case name from the packageId
1971
2082
  * @param packageId - The full package identifier
@@ -2223,5 +2334,5 @@ declare class CaseInstancesService extends BaseService implements CaseInstancesS
2223
2334
  getStagesSlaSummary(options?: CaseInstanceStageSLAOptions): Promise<CaseInstanceStageSLAResponse[]>;
2224
2335
  }
2225
2336
 
2226
- export { CaseInstancesService as CaseInstances, CaseInstancesService, CasesService as Cases, CasesService, EscalationActionType, EscalationRecipientScope, EscalationTriggerType, InstanceFinalStatus, InstanceStatus, SLADurationUnit, SlaSummaryStatus, StageTaskType, TimeInterval, createCaseInstanceWithMethods };
2227
- export type { CaseAppConfig, CaseAppOverview, CaseGetAllResponse, CaseGetStageResponse, CaseGetTopDurationResponse, CaseGetTopFaultedCountResponse, CaseGetTopRunCountResponse, CaseInstanceExecutionHistoryResponse, CaseInstanceGetAllOptions, CaseInstanceGetAllWithPaginationOptions, CaseInstanceGetResponse, CaseInstanceMethods, CaseInstanceOperationOptions, CaseInstanceOperationResponse, CaseInstanceReopenOptions, CaseInstanceRun, CaseInstanceSlaSummaryOptions, CaseInstanceStageSLAOptions, CaseInstanceStageSLAResponse, CaseInstanceStageSLAStage, CaseInstancesServiceModel, CasesServiceModel, ElementExecutionMetadata, ElementGetTopFailedCountResponse, ElementRunMetadata, EscalationAction, EscalationRecipient, EscalationRule, EscalationTriggerMetadata, GetTopBaseResponse, GetTopDurationResponse, GetTopFaultedCountResponse, GetTopRunCountResponse, InstanceStatusTimelineResponse, RawCaseInstanceGetResponse, SlaSummaryResponse, StageSLA, StageTask, TimelineOptions, TopQueryOptions };
2337
+ export { CaseInstancesService as CaseInstances, CaseInstancesService, CasesService as Cases, CasesService, EscalationActionType, EscalationRecipientScope, EscalationTriggerType, InstanceFinalStatus, InstanceStatus, SLADurationUnit, SlaSummaryStatus, StageTaskType, TimeInterval, createCaseInstanceWithMethods, createCaseWithMethods };
2338
+ export type { CaseAppConfig, CaseAppOverview, CaseGetAllResponse, CaseGetAllWithMethodsResponse, CaseGetStageResponse, CaseGetTopDurationResponse, CaseGetTopFaultedCountResponse, CaseGetTopRunCountResponse, CaseInstanceExecutionHistoryResponse, CaseInstanceGetAllOptions, CaseInstanceGetAllWithPaginationOptions, CaseInstanceGetResponse, CaseInstanceMethods, CaseInstanceOperationOptions, CaseInstanceOperationResponse, CaseInstanceReopenOptions, CaseInstanceRun, CaseInstanceSlaSummaryOptions, CaseInstanceStageSLAOptions, CaseInstanceStageSLAResponse, CaseInstanceStageSLAStage, CaseInstancesServiceModel, CaseMethods, CasesServiceModel, ElementExecutionMetadata, ElementGetTopFailedCountResponse, ElementRunMetadata, ElementStats, EscalationAction, EscalationRecipient, EscalationRule, EscalationTriggerMetadata, GetTopBaseResponse, GetTopDurationResponse, GetTopFaultedCountResponse, GetTopRunCountResponse, InstanceStatusTimelineResponse, RawCaseInstanceGetResponse, SlaSummaryResponse, StageSLA, StageTask, TimelineOptions, TopQueryOptions };
@@ -59,6 +59,7 @@ var ProcessType;
59
59
  */
60
60
  const ORCHESTRATOR_BASE = 'orchestrator_';
61
61
  const PIMS_BASE = 'pims_';
62
+ const LLMOPS_BASE = 'llmopstenant_';
62
63
  const INSIGHTS_RTM_BASE = 'insightsrtm_';
63
64
 
64
65
  /**
@@ -98,7 +99,7 @@ const MAESTRO_ENDPOINTS = {
98
99
  INSTANCES: {
99
100
  GET_ALL: `${PIMS_BASE}/api/v1/instances`,
100
101
  GET_BY_ID: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}`,
101
- GET_EXECUTION_HISTORY: (instanceId) => `${PIMS_BASE}/api/v1/spans/${instanceId}`,
102
+ GET_ELEMENT_EXECUTIONS: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/element-executions`,
102
103
  GET_BPMN: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/bpmn`,
103
104
  GET_VARIABLES: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/variables`,
104
105
  CANCEL: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/cancel`,
@@ -110,6 +111,9 @@ const MAESTRO_ENDPOINTS = {
110
111
  GET_BY_PROCESS: (processKey) => `${PIMS_BASE}/api/v1/incidents/process/${processKey}`,
111
112
  GET_BY_INSTANCE: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/incidents`,
112
113
  },
114
+ TRACES: {
115
+ GET_SPANS: (traceId) => `${LLMOPS_BASE}/api/Traces/spans?traceId=${traceId}`,
116
+ },
113
117
  CASES: {
114
118
  GET_CASE_JSON: (instanceId) => `${PIMS_BASE}/api/v1/cases/${instanceId}/case-json`,
115
119
  GET_ELEMENT_EXECUTIONS: (instanceId) => `${PIMS_BASE}/api/v1/element-executions/case-instances/${instanceId}`,
@@ -130,9 +134,45 @@ const MAESTRO_ENDPOINTS = {
130
134
  INSTANCE_STATUS_BY_DATE: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/InstanceStatusByDate`,
131
135
  /** Top processes ranked by total duration */
132
136
  TOP_PROCESSES_BY_DURATION: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/TopProcessesByDuration`,
137
+ /** Element count by status for agentic instances (process and case) */
138
+ ELEMENT_COUNT_BY_STATUS: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/ElementCountByStatus`,
133
139
  },
134
140
  };
135
141
 
142
+ /**
143
+ * Maestro Cases Models
144
+ * Model classes for Maestro cases
145
+ */
146
+ /**
147
+ * Creates methods for a case object
148
+ *
149
+ * @param caseData - The case data (response from API)
150
+ * @param service - The cases service instance
151
+ * @returns Object containing case methods
152
+ */
153
+ function createCaseMethods(caseData, service) {
154
+ return {
155
+ getElementStats(startTime, endTime, packageVersion) {
156
+ if (!caseData.processKey)
157
+ throw new Error('Process key is undefined');
158
+ if (!caseData.packageId)
159
+ throw new Error('Package ID is undefined');
160
+ return service.getElementStats(caseData.processKey, caseData.packageId, startTime, endTime, packageVersion);
161
+ }
162
+ };
163
+ }
164
+ /**
165
+ * Creates an actionable case by combining API case data with operational methods.
166
+ *
167
+ * @param caseData - The case data from API
168
+ * @param service - The cases service instance
169
+ * @returns A case object with added methods
170
+ */
171
+ function createCaseWithMethods(caseData, service) {
172
+ const methods = createCaseMethods(caseData, service);
173
+ return Object.assign({}, caseData, methods);
174
+ }
175
+
136
176
  /**
137
177
  * Builds the request body for Insights RTM "top" endpoints.
138
178
  *
@@ -179,6 +219,28 @@ async function fetchInstanceStatusTimeline(postFn, startTime, endTime, isCaseMan
179
219
  });
180
220
  return response.data ?? [];
181
221
  }
222
+ /**
223
+ * Builds the request body for the ElementCountByStatus endpoint.
224
+ *
225
+ * @param processKey - Process key to filter by
226
+ * @param packageId - Package identifier
227
+ * @param startTime - Start of the time range to query
228
+ * @param endTime - End of the time range to query
229
+ * @param packageVersion - Package version to filter by
230
+ * @returns Request body for the ElementCountByStatus endpoint
231
+ * @internal
232
+ */
233
+ function buildElementCountByStatusBody(processKey, packageId, startTime, endTime, packageVersion) {
234
+ return {
235
+ commonParams: {
236
+ processKey,
237
+ packageId,
238
+ startTime: startTime.getTime(),
239
+ endTime: endTime.getTime(),
240
+ version: packageVersion
241
+ }
242
+ };
243
+ }
182
244
 
183
245
  /**
184
246
  * Type guards for error response types
@@ -875,6 +937,32 @@ function processODataArrayResponse(oDataResponse, successData) {
875
937
  */
876
938
  const isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
877
939
  isBrowser && window.self != window.top && window.location.href.includes('source=ActionCenter');
940
+ const _params = isBrowser ? new URLSearchParams(window.location.search) : null;
941
+ /**
942
+ * True when the coded app has been loaded inside a host frame that explicitly
943
+ * opted into token delegation by adding `?host=embed` to the iframe src URL.
944
+ */
945
+ const isHostEmbedded = isBrowser && window.self !== window.top && _params?.get('host') === 'embed';
946
+ /**
947
+ * The validated parent origin, read from the `?basedomain=` query param set
948
+ * by the embedding host in the iframe src URL.
949
+ * Mirrors the same mechanism used by ActionCenterTokenManager.
950
+ * Non-null only when `?host=embed` is present and `?basedomain=` is a valid URL.
951
+ */
952
+ (() => {
953
+ if (!isHostEmbedded)
954
+ return null;
955
+ const basedomain = _params?.get('basedomain');
956
+ if (!basedomain)
957
+ return null;
958
+ try {
959
+ return new URL(basedomain).origin;
960
+ }
961
+ catch {
962
+ console.warn('embeddingOrigin: basedomain query param is not a valid URL', basedomain);
963
+ return null;
964
+ }
965
+ })();
878
966
 
879
967
  /**
880
968
  * Base64 encoding/decoding
@@ -1582,8 +1670,9 @@ class PaginationHelpers {
1582
1670
  });
1583
1671
  }
1584
1672
  // Extract and transform items from response
1585
- // Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N })
1586
- const rawItems = Array.isArray(response.data) ? response.data : response.data?.[itemsField];
1673
+ // Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N }).
1674
+ // itemsField may be a dotted path (e.g. 'data.agents') for nested envelopes.
1675
+ const rawItems = Array.isArray(response.data) ? response.data : resolveNestedField(response.data, itemsField);
1587
1676
  const rawTotalCount = Array.isArray(response.data) ? undefined : resolveNestedField(response.data, totalCountField);
1588
1677
  const totalCount = typeof rawTotalCount === 'number' ? rawTotalCount : undefined;
1589
1678
  // Parse items - automatically handle JSON string responses
@@ -1629,7 +1718,7 @@ class PaginationHelpers {
1629
1718
  getEndpoint: config.getEndpoint,
1630
1719
  folderId,
1631
1720
  headers: config.headers,
1632
- paginationParams: cursor ? { cursor, pageSize } : jumpToPage ? { jumpToPage, pageSize } : { pageSize },
1721
+ paginationParams: cursor ? { cursor, pageSize } : jumpToPage !== undefined ? { jumpToPage, pageSize } : { pageSize },
1633
1722
  additionalParams: prefixedOptions,
1634
1723
  transformFn: config.transformFn,
1635
1724
  method: config.method,
@@ -1887,6 +1976,8 @@ class BaseService {
1887
1976
  // When true (default), converts pageNumber to a skip/offset value (e.g., page 3 with pageSize 10 → skip 20).
1888
1977
  // When false, passes pageNumber directly as the offset param — used by APIs that accept a page number instead of a record offset.
1889
1978
  const convertToSkip = paginationParams?.convertToSkip ?? true;
1979
+ // When true, sends pageNumber - 1 (for 0-based APIs). Default false (1-based).
1980
+ const zeroBased = paginationParams?.zeroBased ?? false;
1890
1981
  requestParams[pageSizeParam] = limitedPageSize;
1891
1982
  if (convertToSkip) {
1892
1983
  if (params.pageNumber && params.pageNumber > 1) {
@@ -1894,7 +1985,8 @@ class BaseService {
1894
1985
  }
1895
1986
  }
1896
1987
  else {
1897
- requestParams[offsetParam] = params.pageNumber || 1;
1988
+ const sdkPageNumber = params.pageNumber || 1;
1989
+ requestParams[offsetParam] = zeroBased ? sdkPageNumber - 1 : sdkPageNumber;
1898
1990
  }
1899
1991
  {
1900
1992
  requestParams[countParam] = true;
@@ -1923,8 +2015,9 @@ class BaseService {
1923
2015
  const totalCountField = fields.totalCountField || 'totalRecordCount';
1924
2016
  const continuationTokenField = fields.continuationTokenField || 'continuationToken';
1925
2017
  // Extract items and metadata
1926
- // Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N })
1927
- const items = Array.isArray(response.data) ? response.data : (response.data[itemsField] || []);
2018
+ // Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N }).
2019
+ // itemsField may be a dotted path (e.g. 'data.agents') for nested envelopes.
2020
+ const items = Array.isArray(response.data) ? response.data : (resolveNestedField(response.data, itemsField) || []);
1928
2021
  const rawTotalCount = Array.isArray(response.data) ? undefined : resolveNestedField(response.data, totalCountField);
1929
2022
  const totalCount = typeof rawTotalCount === 'number' ? rawTotalCount : undefined;
1930
2023
  const continuationToken = response.data[continuationTokenField];
@@ -2041,7 +2134,7 @@ function createParams(paramsObj = {}) {
2041
2134
  class CasesService extends BaseService {
2042
2135
  /**
2043
2136
  * Get all case management processes with their instance statistics
2044
- * @returns Promise resolving to array of Case objects
2137
+ * @returns Promise resolving to an array of {@link CaseGetAllWithMethodsResponse}
2045
2138
  *
2046
2139
  * @example
2047
2140
  * ```typescript
@@ -2065,10 +2158,10 @@ class CasesService extends BaseService {
2065
2158
  const response = await this.get(MAESTRO_ENDPOINTS.PROCESSES.GET_ALL, { params });
2066
2159
  // Extract processes array from response data and add name field
2067
2160
  const cases = response.data?.processes || [];
2068
- return cases.map(caseItem => ({
2161
+ return cases.map(caseItem => createCaseWithMethods({
2069
2162
  ...caseItem,
2070
2163
  name: this.extractCaseName(caseItem.packageId)
2071
- }));
2164
+ }, this));
2072
2165
  }
2073
2166
  /**
2074
2167
  * Get the top 5 case processes ranked by run count within a time range.
@@ -2287,6 +2380,40 @@ class CasesService extends BaseService {
2287
2380
  const { data } = await this.post(MAESTRO_ENDPOINTS.INSIGHTS.TOP_PROCESSES_BY_DURATION, buildInsightsTopBody(startTime, endTime, true, options));
2288
2381
  return (data ?? []).map(process => ({ ...process, name: this.extractCaseName(process.packageId) }));
2289
2382
  }
2383
+ /**
2384
+ * Get element stats for case instances
2385
+ *
2386
+ * Returns per-element execution counts (success, fail, terminated, paused, in-progress) and
2387
+ * duration percentile metrics (min, max, avg, p50, p95, p99) for BPMN elements within a case.
2388
+ *
2389
+ * @param processKey - Process key to filter by
2390
+ * @param packageId - Package identifier
2391
+ * @param startTime - Start of the time range to query
2392
+ * @param endTime - End of the time range to query
2393
+ * @param packageVersion - Package version to filter by
2394
+ * @returns Promise resolving to an array of {@link ElementStats}
2395
+ * @example
2396
+ * ```typescript
2397
+ * // Get element metrics for a case
2398
+ * const elements = await cases.getElementStats(
2399
+ * '<processKey>',
2400
+ * '<packageId>',
2401
+ * new Date('2026-04-01'),
2402
+ * new Date(),
2403
+ * '1.0.1'
2404
+ * );
2405
+ *
2406
+ * // Find elements with failures
2407
+ * const failedElements = elements.filter(e => e.failCount > 0);
2408
+ * for (const element of failedElements) {
2409
+ * console.log(`Failed element: ${element.elementId}, failures: ${element.failCount}`);
2410
+ * }
2411
+ * ```
2412
+ */
2413
+ async getElementStats(processKey, packageId, startTime, endTime, packageVersion) {
2414
+ const { data } = await this.post(MAESTRO_ENDPOINTS.INSIGHTS.ELEMENT_COUNT_BY_STATUS, buildElementCountByStatusBody(processKey, packageId, startTime, endTime, packageVersion));
2415
+ return data ?? [];
2416
+ }
2290
2417
  /**
2291
2418
  * Extract a readable case name from the packageId
2292
2419
  * @param packageId - The full package identifier
@@ -2324,6 +2451,9 @@ __decorate([
2324
2451
  __decorate([
2325
2452
  track('Cases.GetTopExecutionDuration')
2326
2453
  ], CasesService.prototype, "getTopExecutionDuration", null);
2454
+ __decorate([
2455
+ track('Cases.GetElementStats')
2456
+ ], CasesService.prototype, "getElementStats", null);
2327
2457
 
2328
2458
  /**
2329
2459
  * Process Incident Status
@@ -3845,4 +3975,4 @@ __decorate([
3845
3975
  track('CaseInstances.GetStagesSlaSummary')
3846
3976
  ], CaseInstancesService.prototype, "getStagesSlaSummary", null);
3847
3977
 
3848
- export { CaseInstancesService as CaseInstances, CaseInstancesService, CasesService as Cases, CasesService, EscalationActionType, EscalationRecipientScope, EscalationTriggerType, InstanceFinalStatus, InstanceStatus, SLADurationUnit, SlaSummaryStatus, StageTaskType, TimeInterval, createCaseInstanceWithMethods };
3978
+ export { CaseInstancesService as CaseInstances, CaseInstancesService, CasesService as Cases, CasesService, EscalationActionType, EscalationRecipientScope, EscalationTriggerType, InstanceFinalStatus, InstanceStatus, SLADurationUnit, SlaSummaryStatus, StageTaskType, TimeInterval, createCaseInstanceWithMethods, createCaseWithMethods };