@uipath/uipath-typescript 1.3.10 → 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 +192 -10
  17. package/dist/cases/index.d.ts +208 -7
  18. package/dist/cases/index.mjs +192 -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 +135 -70
  26. package/dist/entities/index.d.ts +146 -45
  27. package/dist/entities/index.mjs +135 -70
  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 +1050 -291
  35. package/dist/index.d.ts +1313 -134
  36. package/dist/index.mjs +1050 -292
  37. package/dist/index.umd.js +4546 -3770
  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 +224 -18
  42. package/dist/maestro-processes/index.d.ts +221 -9
  43. package/dist/maestro-processes/index.mjs +224 -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 +1933 -0
  54. package/dist/traces/index.d.ts +566 -0
  55. package/dist/traces/index.mjs +1931 -0
  56. package/package.json +42 -2
@@ -61,6 +61,7 @@ var ProcessType;
61
61
  */
62
62
  const ORCHESTRATOR_BASE = 'orchestrator_';
63
63
  const PIMS_BASE = 'pims_';
64
+ const LLMOPS_BASE = 'llmopstenant_';
64
65
  const INSIGHTS_RTM_BASE = 'insightsrtm_';
65
66
 
66
67
  /**
@@ -100,7 +101,7 @@ const MAESTRO_ENDPOINTS = {
100
101
  INSTANCES: {
101
102
  GET_ALL: `${PIMS_BASE}/api/v1/instances`,
102
103
  GET_BY_ID: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}`,
103
- GET_EXECUTION_HISTORY: (instanceId) => `${PIMS_BASE}/api/v1/spans/${instanceId}`,
104
+ GET_ELEMENT_EXECUTIONS: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/element-executions`,
104
105
  GET_BPMN: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/bpmn`,
105
106
  GET_VARIABLES: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/variables`,
106
107
  CANCEL: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/cancel`,
@@ -112,6 +113,9 @@ const MAESTRO_ENDPOINTS = {
112
113
  GET_BY_PROCESS: (processKey) => `${PIMS_BASE}/api/v1/incidents/process/${processKey}`,
113
114
  GET_BY_INSTANCE: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/incidents`,
114
115
  },
116
+ TRACES: {
117
+ GET_SPANS: (traceId) => `${LLMOPS_BASE}/api/Traces/spans?traceId=${traceId}`,
118
+ },
115
119
  CASES: {
116
120
  GET_CASE_JSON: (instanceId) => `${PIMS_BASE}/api/v1/cases/${instanceId}/case-json`,
117
121
  GET_ELEMENT_EXECUTIONS: (instanceId) => `${PIMS_BASE}/api/v1/element-executions/case-instances/${instanceId}`,
@@ -126,13 +130,51 @@ const MAESTRO_ENDPOINTS = {
126
130
  TOP_PROCESSES_BY_RUN_COUNT: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/TopProcessesByRunCount`,
127
131
  /** Top processes ranked by failure count */
128
132
  TOP_PROCESSES_WITH_FAILURE: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/TopProcesseswithFailure`,
133
+ /** Top elements ranked by failure count */
134
+ TOP_ELEMENTS_WITH_FAILURE: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/TopElementswithFailure`,
129
135
  /** Instance status aggregated by date for time-series charts */
130
136
  INSTANCE_STATUS_BY_DATE: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/InstanceStatusByDate`,
131
137
  /** Top processes ranked by total duration */
132
138
  TOP_PROCESSES_BY_DURATION: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/TopProcessesByDuration`,
139
+ /** Element count by status for agentic instances (process and case) */
140
+ ELEMENT_COUNT_BY_STATUS: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/ElementCountByStatus`,
133
141
  },
134
142
  };
135
143
 
144
+ /**
145
+ * Maestro Cases Models
146
+ * Model classes for Maestro cases
147
+ */
148
+ /**
149
+ * Creates methods for a case object
150
+ *
151
+ * @param caseData - The case data (response from API)
152
+ * @param service - The cases service instance
153
+ * @returns Object containing case methods
154
+ */
155
+ function createCaseMethods(caseData, service) {
156
+ return {
157
+ getElementStats(startTime, endTime, packageVersion) {
158
+ if (!caseData.processKey)
159
+ throw new Error('Process key is undefined');
160
+ if (!caseData.packageId)
161
+ throw new Error('Package ID is undefined');
162
+ return service.getElementStats(caseData.processKey, caseData.packageId, startTime, endTime, packageVersion);
163
+ }
164
+ };
165
+ }
166
+ /**
167
+ * Creates an actionable case by combining API case data with operational methods.
168
+ *
169
+ * @param caseData - The case data from API
170
+ * @param service - The cases service instance
171
+ * @returns A case object with added methods
172
+ */
173
+ function createCaseWithMethods(caseData, service) {
174
+ const methods = createCaseMethods(caseData, service);
175
+ return Object.assign({}, caseData, methods);
176
+ }
177
+
136
178
  /**
137
179
  * Builds the request body for Insights RTM "top" endpoints.
138
180
  *
@@ -179,6 +221,28 @@ async function fetchInstanceStatusTimeline(postFn, startTime, endTime, isCaseMan
179
221
  });
180
222
  return response.data ?? [];
181
223
  }
224
+ /**
225
+ * Builds the request body for the ElementCountByStatus endpoint.
226
+ *
227
+ * @param processKey - Process key to filter by
228
+ * @param packageId - Package identifier
229
+ * @param startTime - Start of the time range to query
230
+ * @param endTime - End of the time range to query
231
+ * @param packageVersion - Package version to filter by
232
+ * @returns Request body for the ElementCountByStatus endpoint
233
+ * @internal
234
+ */
235
+ function buildElementCountByStatusBody(processKey, packageId, startTime, endTime, packageVersion) {
236
+ return {
237
+ commonParams: {
238
+ processKey,
239
+ packageId,
240
+ startTime: startTime.getTime(),
241
+ endTime: endTime.getTime(),
242
+ version: packageVersion
243
+ }
244
+ };
245
+ }
182
246
 
183
247
  /**
184
248
  * Type guards for error response types
@@ -875,6 +939,32 @@ function processODataArrayResponse(oDataResponse, successData) {
875
939
  */
876
940
  const isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
877
941
  isBrowser && window.self != window.top && window.location.href.includes('source=ActionCenter');
942
+ const _params = isBrowser ? new URLSearchParams(window.location.search) : null;
943
+ /**
944
+ * True when the coded app has been loaded inside a host frame that explicitly
945
+ * opted into token delegation by adding `?host=embed` to the iframe src URL.
946
+ */
947
+ const isHostEmbedded = isBrowser && window.self !== window.top && _params?.get('host') === 'embed';
948
+ /**
949
+ * The validated parent origin, read from the `?basedomain=` query param set
950
+ * by the embedding host in the iframe src URL.
951
+ * Mirrors the same mechanism used by ActionCenterTokenManager.
952
+ * Non-null only when `?host=embed` is present and `?basedomain=` is a valid URL.
953
+ */
954
+ (() => {
955
+ if (!isHostEmbedded)
956
+ return null;
957
+ const basedomain = _params?.get('basedomain');
958
+ if (!basedomain)
959
+ return null;
960
+ try {
961
+ return new URL(basedomain).origin;
962
+ }
963
+ catch {
964
+ console.warn('embeddingOrigin: basedomain query param is not a valid URL', basedomain);
965
+ return null;
966
+ }
967
+ })();
878
968
 
879
969
  /**
880
970
  * Base64 encoding/decoding
@@ -1582,8 +1672,9 @@ class PaginationHelpers {
1582
1672
  });
1583
1673
  }
1584
1674
  // 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];
1675
+ // Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N }).
1676
+ // itemsField may be a dotted path (e.g. 'data.agents') for nested envelopes.
1677
+ const rawItems = Array.isArray(response.data) ? response.data : resolveNestedField(response.data, itemsField);
1587
1678
  const rawTotalCount = Array.isArray(response.data) ? undefined : resolveNestedField(response.data, totalCountField);
1588
1679
  const totalCount = typeof rawTotalCount === 'number' ? rawTotalCount : undefined;
1589
1680
  // Parse items - automatically handle JSON string responses
@@ -1629,7 +1720,7 @@ class PaginationHelpers {
1629
1720
  getEndpoint: config.getEndpoint,
1630
1721
  folderId,
1631
1722
  headers: config.headers,
1632
- paginationParams: cursor ? { cursor, pageSize } : jumpToPage ? { jumpToPage, pageSize } : { pageSize },
1723
+ paginationParams: cursor ? { cursor, pageSize } : jumpToPage !== undefined ? { jumpToPage, pageSize } : { pageSize },
1633
1724
  additionalParams: prefixedOptions,
1634
1725
  transformFn: config.transformFn,
1635
1726
  method: config.method,
@@ -1887,6 +1978,8 @@ class BaseService {
1887
1978
  // When true (default), converts pageNumber to a skip/offset value (e.g., page 3 with pageSize 10 → skip 20).
1888
1979
  // When false, passes pageNumber directly as the offset param — used by APIs that accept a page number instead of a record offset.
1889
1980
  const convertToSkip = paginationParams?.convertToSkip ?? true;
1981
+ // When true, sends pageNumber - 1 (for 0-based APIs). Default false (1-based).
1982
+ const zeroBased = paginationParams?.zeroBased ?? false;
1890
1983
  requestParams[pageSizeParam] = limitedPageSize;
1891
1984
  if (convertToSkip) {
1892
1985
  if (params.pageNumber && params.pageNumber > 1) {
@@ -1894,7 +1987,8 @@ class BaseService {
1894
1987
  }
1895
1988
  }
1896
1989
  else {
1897
- requestParams[offsetParam] = params.pageNumber || 1;
1990
+ const sdkPageNumber = params.pageNumber || 1;
1991
+ requestParams[offsetParam] = zeroBased ? sdkPageNumber - 1 : sdkPageNumber;
1898
1992
  }
1899
1993
  {
1900
1994
  requestParams[countParam] = true;
@@ -1923,8 +2017,9 @@ class BaseService {
1923
2017
  const totalCountField = fields.totalCountField || 'totalRecordCount';
1924
2018
  const continuationTokenField = fields.continuationTokenField || 'continuationToken';
1925
2019
  // 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] || []);
2020
+ // Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N }).
2021
+ // itemsField may be a dotted path (e.g. 'data.agents') for nested envelopes.
2022
+ const items = Array.isArray(response.data) ? response.data : (resolveNestedField(response.data, itemsField) || []);
1928
2023
  const rawTotalCount = Array.isArray(response.data) ? undefined : resolveNestedField(response.data, totalCountField);
1929
2024
  const totalCount = typeof rawTotalCount === 'number' ? rawTotalCount : undefined;
1930
2025
  const continuationToken = response.data[continuationTokenField];
@@ -2041,7 +2136,7 @@ function createParams(paramsObj = {}) {
2041
2136
  class CasesService extends BaseService {
2042
2137
  /**
2043
2138
  * Get all case management processes with their instance statistics
2044
- * @returns Promise resolving to array of Case objects
2139
+ * @returns Promise resolving to an array of {@link CaseGetAllWithMethodsResponse}
2045
2140
  *
2046
2141
  * @example
2047
2142
  * ```typescript
@@ -2065,10 +2160,10 @@ class CasesService extends BaseService {
2065
2160
  const response = await this.get(MAESTRO_ENDPOINTS.PROCESSES.GET_ALL, { params });
2066
2161
  // Extract processes array from response data and add name field
2067
2162
  const cases = response.data?.processes || [];
2068
- return cases.map(caseItem => ({
2163
+ return cases.map(caseItem => createCaseWithMethods({
2069
2164
  ...caseItem,
2070
2165
  name: this.extractCaseName(caseItem.packageId)
2071
- }));
2166
+ }, this));
2072
2167
  }
2073
2168
  /**
2074
2169
  * Get the top 5 case processes ranked by run count within a time range.
@@ -2111,6 +2206,52 @@ class CasesService extends BaseService {
2111
2206
  const { data } = await this.post(MAESTRO_ENDPOINTS.INSIGHTS.TOP_PROCESSES_BY_RUN_COUNT, buildInsightsTopBody(startTime, endTime, true, options));
2112
2207
  return (data ?? []).map(process => ({ ...process, name: this.extractCaseName(process.packageId) }));
2113
2208
  }
2209
+ /**
2210
+ * Get the top 10 BPMN elements ranked by failure count within a time range.
2211
+ *
2212
+ * Returns an array of up to 10 elements sorted by how many times they failed,
2213
+ * useful for identifying the most error-prone activities in case processes.
2214
+ *
2215
+ * @param startTime - Start of the time range to query
2216
+ * @param endTime - End of the time range to query
2217
+ * @param options - Optional filters (packageId, processKey, version)
2218
+ * @returns Promise resolving to an array of {@link ElementGetTopFailedCountResponse}
2219
+ * @example
2220
+ * ```typescript
2221
+ * import { Cases } from '@uipath/uipath-typescript/cases';
2222
+ *
2223
+ * const cases = new Cases(sdk);
2224
+ *
2225
+ * // Get top failing elements for the last 7 days
2226
+ * const topFailing = await cases.getTopElementFailedCount(
2227
+ * new Date(Date.now() - 7 * 24 * 60 * 60 * 1000),
2228
+ * new Date()
2229
+ * );
2230
+ *
2231
+ * for (const element of topFailing) {
2232
+ * console.log(`${element.elementName} (${element.elementType}): ${element.failedCount} failures`);
2233
+ * }
2234
+ * ```
2235
+ *
2236
+ * @example
2237
+ * ```typescript
2238
+ * // Get top failing elements for a specific process
2239
+ * const filtered = await cases.getTopElementFailedCount(
2240
+ * new Date(Date.now() - 7 * 24 * 60 * 60 * 1000),
2241
+ * new Date(),
2242
+ * { processKey: '<processKey>' }
2243
+ * );
2244
+ * ```
2245
+ */
2246
+ async getTopElementFailedCount(startTime, endTime, options) {
2247
+ const { data } = await this.post(MAESTRO_ENDPOINTS.INSIGHTS.TOP_ELEMENTS_WITH_FAILURE, buildInsightsTopBody(startTime, endTime, true, options));
2248
+ return (data ?? []).map(item => ({
2249
+ elementName: item.elementName,
2250
+ elementType: item.elementType,
2251
+ processKey: item.processKey,
2252
+ failedCount: item.count,
2253
+ }));
2254
+ }
2114
2255
  /**
2115
2256
  * Get all instances status counts aggregated by date for case management processes.
2116
2257
  *
@@ -2241,6 +2382,40 @@ class CasesService extends BaseService {
2241
2382
  const { data } = await this.post(MAESTRO_ENDPOINTS.INSIGHTS.TOP_PROCESSES_BY_DURATION, buildInsightsTopBody(startTime, endTime, true, options));
2242
2383
  return (data ?? []).map(process => ({ ...process, name: this.extractCaseName(process.packageId) }));
2243
2384
  }
2385
+ /**
2386
+ * Get element stats for case instances
2387
+ *
2388
+ * Returns per-element execution counts (success, fail, terminated, paused, in-progress) and
2389
+ * duration percentile metrics (min, max, avg, p50, p95, p99) for BPMN elements within a case.
2390
+ *
2391
+ * @param processKey - Process key to filter by
2392
+ * @param packageId - Package identifier
2393
+ * @param startTime - Start of the time range to query
2394
+ * @param endTime - End of the time range to query
2395
+ * @param packageVersion - Package version to filter by
2396
+ * @returns Promise resolving to an array of {@link ElementStats}
2397
+ * @example
2398
+ * ```typescript
2399
+ * // Get element metrics for a case
2400
+ * const elements = await cases.getElementStats(
2401
+ * '<processKey>',
2402
+ * '<packageId>',
2403
+ * new Date('2026-04-01'),
2404
+ * new Date(),
2405
+ * '1.0.1'
2406
+ * );
2407
+ *
2408
+ * // Find elements with failures
2409
+ * const failedElements = elements.filter(e => e.failCount > 0);
2410
+ * for (const element of failedElements) {
2411
+ * console.log(`Failed element: ${element.elementId}, failures: ${element.failCount}`);
2412
+ * }
2413
+ * ```
2414
+ */
2415
+ async getElementStats(processKey, packageId, startTime, endTime, packageVersion) {
2416
+ const { data } = await this.post(MAESTRO_ENDPOINTS.INSIGHTS.ELEMENT_COUNT_BY_STATUS, buildElementCountByStatusBody(processKey, packageId, startTime, endTime, packageVersion));
2417
+ return data ?? [];
2418
+ }
2244
2419
  /**
2245
2420
  * Extract a readable case name from the packageId
2246
2421
  * @param packageId - The full package identifier
@@ -2266,6 +2441,9 @@ __decorate([
2266
2441
  __decorate([
2267
2442
  track('Cases.GetTopRunCount')
2268
2443
  ], CasesService.prototype, "getTopRunCount", null);
2444
+ __decorate([
2445
+ track('Cases.GetTopElementFailedCount')
2446
+ ], CasesService.prototype, "getTopElementFailedCount", null);
2269
2447
  __decorate([
2270
2448
  track('Cases.GetInstanceStatusTimeline')
2271
2449
  ], CasesService.prototype, "getInstanceStatusTimeline", null);
@@ -2275,6 +2453,9 @@ __decorate([
2275
2453
  __decorate([
2276
2454
  track('Cases.GetTopExecutionDuration')
2277
2455
  ], CasesService.prototype, "getTopExecutionDuration", null);
2456
+ __decorate([
2457
+ track('Cases.GetElementStats')
2458
+ ], CasesService.prototype, "getElementStats", null);
2278
2459
 
2279
2460
  /**
2280
2461
  * Process Incident Status
@@ -3801,3 +3982,4 @@ exports.CaseInstancesService = CaseInstancesService;
3801
3982
  exports.Cases = CasesService;
3802
3983
  exports.CasesService = CasesService;
3803
3984
  exports.createCaseInstanceWithMethods = createCaseInstanceWithMethods;
3985
+ exports.createCaseWithMethods = createCaseWithMethods;
@@ -39,6 +39,20 @@ interface GetTopFaultedCountResponse extends GetTopBaseResponse {
39
39
  /** Number of faulted instances in the given time range */
40
40
  faultedCount: number;
41
41
  }
42
+ /**
43
+ * SDK response for top elements with failure.
44
+ * Shared by both MaestroProcesses and Cases — no service-specific enrichment.
45
+ */
46
+ interface ElementGetTopFailedCountResponse {
47
+ /** BPMN element name (falls back to element ID if name is empty) */
48
+ elementName: string;
49
+ /** BPMN element type (e.g. ServiceTask, ReceiveTask, IntermediateCatchEvent) */
50
+ elementType: string;
51
+ /** The unique process key this element belongs to */
52
+ processKey: string;
53
+ /** Number of failed executions of this element in the given time range */
54
+ failedCount: number;
55
+ }
42
56
  /**
43
57
  * Time bucketing granularity for insights time-series queries.
44
58
  *
@@ -95,6 +109,35 @@ interface GetTopDurationResponse extends GetTopBaseResponse {
95
109
  /** Total execution duration in milliseconds */
96
110
  duration: number;
97
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
+ }
98
141
 
99
142
  /**
100
143
  * Simplified universal pagination cursor
@@ -279,8 +322,7 @@ interface CaseGetTopDurationResponse extends GetTopDurationResponse {
279
322
  */
280
323
  interface CasesServiceModel {
281
324
  /**
282
- * @returns Promise resolving to array of Case objects
283
- * {@link CaseGetAllResponse}
325
+ * @returns Promise resolving to an array of {@link CaseGetAllWithMethodsResponse}
284
326
  * @example
285
327
  * ```typescript
286
328
  * // Get all case management processes
@@ -294,7 +336,7 @@ interface CasesServiceModel {
294
336
  * }
295
337
  * ```
296
338
  */
297
- getAll(): Promise<CaseGetAllResponse[]>;
339
+ getAll(): Promise<CaseGetAllWithMethodsResponse[]>;
298
340
  /**
299
341
  * Get the top 5 case processes ranked by run count within a time range.
300
342
  *
@@ -371,6 +413,44 @@ interface CasesServiceModel {
371
413
  * ```
372
414
  */
373
415
  getTopFaultedCount(startTime: Date, endTime: Date, options?: TopQueryOptions): Promise<CaseGetTopFaultedCountResponse[]>;
416
+ /**
417
+ * Get the top 10 BPMN elements ranked by failure count within a time range.
418
+ *
419
+ * Returns an array of up to 10 elements sorted by how many times they failed,
420
+ * useful for identifying the most error-prone activities in case processes.
421
+ *
422
+ * @param startTime - Start of the time range to query
423
+ * @param endTime - End of the time range to query
424
+ * @param options - Optional filters (packageId, processKey, version)
425
+ * @returns Promise resolving to an array of {@link ElementGetTopFailedCountResponse}
426
+ * @example
427
+ * ```typescript
428
+ * import { Cases } from '@uipath/uipath-typescript/cases';
429
+ *
430
+ * const cases = new Cases(sdk);
431
+ *
432
+ * // Get top failing elements for the last 7 days
433
+ * const topFailing = await cases.getTopElementFailedCount(
434
+ * new Date(Date.now() - 7 * 24 * 60 * 60 * 1000),
435
+ * new Date()
436
+ * );
437
+ *
438
+ * for (const element of topFailing) {
439
+ * console.log(`${element.elementName} (${element.elementType}): ${element.failedCount} failures`);
440
+ * }
441
+ * ```
442
+ *
443
+ * @example
444
+ * ```typescript
445
+ * // Get top failing elements for a specific process
446
+ * const filtered = await cases.getTopElementFailedCount(
447
+ * new Date(Date.now() - 7 * 24 * 60 * 60 * 1000),
448
+ * new Date(),
449
+ * { processKey: '<processKey>' }
450
+ * );
451
+ * ```
452
+ */
453
+ getTopElementFailedCount(startTime: Date, endTime: Date, options?: TopQueryOptions): Promise<ElementGetTopFailedCountResponse[]>;
374
454
  /**
375
455
  * Get all instances status counts aggregated by date for case management processes.
376
456
  *
@@ -450,7 +530,58 @@ interface CasesServiceModel {
450
530
  * ```
451
531
  */
452
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[]>;
453
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[]>;
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;
454
585
 
455
586
  /**
456
587
  * Case Instance Types
@@ -1505,6 +1636,7 @@ interface RequestWithPaginationOptions extends RequestSpec {
1505
1636
  tokenParam?: string;
1506
1637
  countParam?: string;
1507
1638
  convertToSkip?: boolean;
1639
+ zeroBased?: boolean;
1508
1640
  };
1509
1641
  };
1510
1642
  }
@@ -1703,7 +1835,7 @@ declare class BaseService {
1703
1835
  declare class CasesService extends BaseService implements CasesServiceModel {
1704
1836
  /**
1705
1837
  * Get all case management processes with their instance statistics
1706
- * @returns Promise resolving to array of Case objects
1838
+ * @returns Promise resolving to an array of {@link CaseGetAllWithMethodsResponse}
1707
1839
  *
1708
1840
  * @example
1709
1841
  * ```typescript
@@ -1720,7 +1852,7 @@ declare class CasesService extends BaseService implements CasesServiceModel {
1720
1852
  * }
1721
1853
  * ```
1722
1854
  */
1723
- getAll(): Promise<CaseGetAllResponse[]>;
1855
+ getAll(): Promise<CaseGetAllWithMethodsResponse[]>;
1724
1856
  /**
1725
1857
  * Get the top 5 case processes ranked by run count within a time range.
1726
1858
  *
@@ -1759,6 +1891,44 @@ declare class CasesService extends BaseService implements CasesServiceModel {
1759
1891
  * ```
1760
1892
  */
1761
1893
  getTopRunCount(startTime: Date, endTime: Date, options?: TopQueryOptions): Promise<CaseGetTopRunCountResponse[]>;
1894
+ /**
1895
+ * Get the top 10 BPMN elements ranked by failure count within a time range.
1896
+ *
1897
+ * Returns an array of up to 10 elements sorted by how many times they failed,
1898
+ * useful for identifying the most error-prone activities in case processes.
1899
+ *
1900
+ * @param startTime - Start of the time range to query
1901
+ * @param endTime - End of the time range to query
1902
+ * @param options - Optional filters (packageId, processKey, version)
1903
+ * @returns Promise resolving to an array of {@link ElementGetTopFailedCountResponse}
1904
+ * @example
1905
+ * ```typescript
1906
+ * import { Cases } from '@uipath/uipath-typescript/cases';
1907
+ *
1908
+ * const cases = new Cases(sdk);
1909
+ *
1910
+ * // Get top failing elements for the last 7 days
1911
+ * const topFailing = await cases.getTopElementFailedCount(
1912
+ * new Date(Date.now() - 7 * 24 * 60 * 60 * 1000),
1913
+ * new Date()
1914
+ * );
1915
+ *
1916
+ * for (const element of topFailing) {
1917
+ * console.log(`${element.elementName} (${element.elementType}): ${element.failedCount} failures`);
1918
+ * }
1919
+ * ```
1920
+ *
1921
+ * @example
1922
+ * ```typescript
1923
+ * // Get top failing elements for a specific process
1924
+ * const filtered = await cases.getTopElementFailedCount(
1925
+ * new Date(Date.now() - 7 * 24 * 60 * 60 * 1000),
1926
+ * new Date(),
1927
+ * { processKey: '<processKey>' }
1928
+ * );
1929
+ * ```
1930
+ */
1931
+ getTopElementFailedCount(startTime: Date, endTime: Date, options?: TopQueryOptions): Promise<ElementGetTopFailedCountResponse[]>;
1762
1932
  /**
1763
1933
  * Get all instances status counts aggregated by date for case management processes.
1764
1934
  *
@@ -1876,6 +2046,37 @@ declare class CasesService extends BaseService implements CasesServiceModel {
1876
2046
  * ```
1877
2047
  */
1878
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[]>;
1879
2080
  /**
1880
2081
  * Extract a readable case name from the packageId
1881
2082
  * @param packageId - The full package identifier
@@ -2133,5 +2334,5 @@ declare class CaseInstancesService extends BaseService implements CaseInstancesS
2133
2334
  getStagesSlaSummary(options?: CaseInstanceStageSLAOptions): Promise<CaseInstanceStageSLAResponse[]>;
2134
2335
  }
2135
2336
 
2136
- export { CaseInstancesService as CaseInstances, CaseInstancesService, CasesService as Cases, CasesService, EscalationActionType, EscalationRecipientScope, EscalationTriggerType, InstanceFinalStatus, InstanceStatus, SLADurationUnit, SlaSummaryStatus, StageTaskType, TimeInterval, createCaseInstanceWithMethods };
2137
- 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, 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 };