@uipath/uipath-typescript 1.4.1 → 1.5.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 (46) hide show
  1. package/dist/agent-memory/index.d.ts +4 -1
  2. package/dist/agents/index.cjs +341 -6
  3. package/dist/agents/index.d.ts +717 -16
  4. package/dist/agents/index.mjs +342 -7
  5. package/dist/assets/index.cjs +25 -9
  6. package/dist/assets/index.mjs +25 -9
  7. package/dist/attachments/index.cjs +25 -9
  8. package/dist/attachments/index.mjs +25 -9
  9. package/dist/buckets/index.cjs +25 -9
  10. package/dist/buckets/index.mjs +25 -9
  11. package/dist/cases/index.cjs +621 -524
  12. package/dist/cases/index.d.ts +186 -43
  13. package/dist/cases/index.mjs +621 -524
  14. package/dist/conversational-agent/index.cjs +25 -9
  15. package/dist/conversational-agent/index.mjs +25 -9
  16. package/dist/core/index.cjs +1 -1
  17. package/dist/core/index.mjs +1 -1
  18. package/dist/document-understanding/index.cjs +84 -84
  19. package/dist/document-understanding/index.d.ts +2 -1
  20. package/dist/document-understanding/index.mjs +1 -1
  21. package/dist/entities/index.cjs +25 -9
  22. package/dist/entities/index.mjs +25 -9
  23. package/dist/feedback/index.cjs +25 -9
  24. package/dist/feedback/index.mjs +25 -9
  25. package/dist/index.cjs +332 -62
  26. package/dist/index.d.ts +827 -89
  27. package/dist/index.mjs +333 -63
  28. package/dist/index.umd.js +332 -62
  29. package/dist/jobs/index.cjs +129 -14
  30. package/dist/jobs/index.d.ts +10 -5
  31. package/dist/jobs/index.mjs +129 -14
  32. package/dist/maestro-processes/index.cjs +198 -100
  33. package/dist/maestro-processes/index.d.ts +188 -43
  34. package/dist/maestro-processes/index.mjs +198 -100
  35. package/dist/processes/index.cjs +25 -9
  36. package/dist/processes/index.d.ts +6 -1
  37. package/dist/processes/index.mjs +25 -9
  38. package/dist/queues/index.cjs +25 -9
  39. package/dist/queues/index.mjs +25 -9
  40. package/dist/tasks/index.cjs +25 -9
  41. package/dist/tasks/index.d.ts +4 -1
  42. package/dist/tasks/index.mjs +25 -9
  43. package/dist/traces/index.cjs +2 -2
  44. package/dist/traces/index.d.ts +3 -3
  45. package/dist/traces/index.mjs +2 -2
  46. package/package.json +1 -1
@@ -44,6 +44,108 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
44
44
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
45
45
  };
46
46
 
47
+ /**
48
+ * Maps API field names (countOf*) to SDK field names (*Count) for InstanceStats,
49
+ * aligning naming with ElementStats and other count-suffixed conventions.
50
+ */
51
+ const InstanceStatsMap = {
52
+ countOfAllInstances: 'totalCount',
53
+ countOfRunning: 'runningCount',
54
+ countOfTransitioning: 'transitioningCount',
55
+ countOfPaused: 'pausedCount',
56
+ countOfFaulted: 'faultedCount',
57
+ countOfCompleted: 'completedCount',
58
+ countOfCancelled: 'cancelledCount',
59
+ countOfDeleted: 'deletedCount'
60
+ };
61
+
62
+ /**
63
+ * Converts a UTC timestamp string (e.g., "5/8/2026 11:20:17 AM") to ISO 8601 UTC format.
64
+ * Returns the original value if parsing fails.
65
+ */
66
+ /**
67
+ * Transforms data by renaming each key in `data` exactly once, using the
68
+ * mapping (`sourceField → targetField`). Keys not present in the mapping
69
+ * pass through unchanged. The original (pre-rename) key is dropped — the
70
+ * result contains only the renamed key.
71
+ *
72
+ * Each rename is independent. If the mapping happens to contain chained
73
+ * entries (`a → b` and `b → c`), they do NOT compose: a field named `a`
74
+ * in `data` becomes `b` (not `c`), because the renames are applied based
75
+ * on the original data's keys, not the running result.
76
+ *
77
+ * @param data The source data to transform
78
+ * @param fieldMapping Object mapping source field names to target field names
79
+ * @returns Transformed data with mapped field names
80
+ *
81
+ * @example
82
+ * ```typescript
83
+ * // Single object transformation
84
+ * const data = { id: '123', userName: 'john' };
85
+ * const mapping = { id: 'userId', userName: 'name' };
86
+ * const result = transformData(data, mapping);
87
+ * // result = { userId: '123', name: 'john' }
88
+ *
89
+ * // Array transformation
90
+ * const dataArray = [
91
+ * { id: '123', userName: 'john' },
92
+ * { id: '456', userName: 'jane' }
93
+ * ];
94
+ * const result = transformData(dataArray, mapping);
95
+ * // result = [
96
+ * // { userId: '123', name: 'john' },
97
+ * // { userId: '456', name: 'jane' }
98
+ * // ]
99
+ *
100
+ * // No chaining — `a → b` does not become `a → c` even if the map has `b → c`.
101
+ * transformData({ a: 1 }, { a: 'b', b: 'c' });
102
+ * // result = { b: 1 }
103
+ * ```
104
+ */
105
+ function transformData(data, fieldMapping) {
106
+ // Pass null/undefined through unchanged — callers (e.g. AttachmentService.getById)
107
+ // may invoke this on optional fields that an OData `select` excluded.
108
+ if (data == null) {
109
+ return data;
110
+ }
111
+ // Handle array of objects
112
+ if (Array.isArray(data)) {
113
+ return data.map(item => transformData(item, fieldMapping));
114
+ }
115
+ // Walk the ORIGINAL data's keys, look up each in the mapping. One rename
116
+ // per data key — no mutation of an in-progress result, so chains can't form.
117
+ const result = {};
118
+ for (const [key, value] of Object.entries(data)) {
119
+ const renamedKey = fieldMapping[key] ?? key;
120
+ result[renamedKey] = value;
121
+ }
122
+ return result;
123
+ }
124
+ /**
125
+ * Adds a prefix to specified keys in an object, returning a new object.
126
+ * Only the provided keys are prefixed; all others are left unchanged.
127
+ *
128
+ * @param obj The source object
129
+ * @param prefix The prefix to add (e.g., '$')
130
+ * @param keys The keys to prefix (e.g., ['expand', 'filter'])
131
+ * @returns A new object with specified keys prefixed
132
+ *
133
+ * @example
134
+ * addPrefixToKeys({ expand: 'a', foo: 1 }, '$', ['expand']) // { $expand: 'a', foo: 1 }
135
+ */
136
+ function addPrefixToKeys(obj, prefix, keys) {
137
+ const result = {};
138
+ for (const [key, value] of Object.entries(obj)) {
139
+ if (keys.includes(key)) {
140
+ result[`${prefix}${key}`] = value;
141
+ }
142
+ else {
143
+ result[key] = value;
144
+ }
145
+ }
146
+ return result;
147
+ }
148
+
47
149
  /**
48
150
  * Base path constants for different services
49
151
  */
@@ -89,6 +191,8 @@ const MAESTRO_ENDPOINTS = {
89
191
  INSTANCE_STATUS_BY_DATE: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/InstanceStatusByDate`,
90
192
  /** Top processes ranked by total duration */
91
193
  TOP_PROCESSES_BY_DURATION: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/TopProcessesByDuration`,
194
+ /** Instance stats (counts by status + duration percentiles) */
195
+ INSTANCE_COUNT_BY_STATUS: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/InstanceCountByStatus`,
92
196
  /** Element count by status for agentic instances (process and case) */
93
197
  ELEMENT_COUNT_BY_STATUS: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/ElementCountByStatus`,
94
198
  },
@@ -119,7 +223,26 @@ function createProcessMethods(processData, service) {
119
223
  throw new Error('Process key is undefined');
120
224
  if (!processData.packageId)
121
225
  throw new Error('Package ID is undefined');
122
- return service.getElementStats(processData.processKey, processData.packageId, startTime, endTime, packageVersion);
226
+ return service.getElementStats({
227
+ processKey: processData.processKey,
228
+ packageId: processData.packageId,
229
+ packageVersion,
230
+ startTime,
231
+ endTime,
232
+ });
233
+ },
234
+ getInstanceStats(startTime, endTime, packageVersion) {
235
+ if (!processData.processKey)
236
+ throw new Error('Process key is undefined');
237
+ if (!processData.packageId)
238
+ throw new Error('Package ID is undefined');
239
+ return service.getInstanceStats({
240
+ processKey: processData.processKey,
241
+ packageId: processData.packageId,
242
+ packageVersion,
243
+ startTime,
244
+ endTime,
245
+ });
123
246
  }
124
247
  };
125
248
  }
@@ -182,24 +305,21 @@ async function fetchInstanceStatusTimeline(postFn, startTime, endTime, isCaseMan
182
305
  return response.data ?? [];
183
306
  }
184
307
  /**
185
- * Builds the request body for the ElementCountByStatus endpoint.
308
+ * Builds the commonParams request body for Insights RTM endpoints
309
+ * that filter by process key, package, time range, and version.
186
310
  *
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
311
+ * @param request - Process scope + time range to aggregate over
312
+ * @returns Request body with commonParams
193
313
  * @internal
194
314
  */
195
- function buildElementCountByStatusBody(processKey, packageId, startTime, endTime, packageVersion) {
315
+ function buildInsightsCommonBody(request) {
196
316
  return {
197
317
  commonParams: {
198
- processKey,
199
- packageId,
200
- startTime: startTime.getTime(),
201
- endTime: endTime.getTime(),
202
- version: packageVersion
318
+ processKey: request.processKey,
319
+ packageId: request.packageId,
320
+ startTime: request.startTime.getTime(),
321
+ endTime: request.endTime.getTime(),
322
+ version: request.packageVersion
203
323
  }
204
324
  };
205
325
  }
@@ -258,77 +378,6 @@ const PROCESS_INSTANCE_TOKEN_PARAMS = {
258
378
  TOKEN_PARAM: 'nextPage'
259
379
  };
260
380
 
261
- /**
262
- * Converts a UTC timestamp string (e.g., "5/8/2026 11:20:17 AM") to ISO 8601 UTC format.
263
- * Returns the original value if parsing fails.
264
- */
265
- /**
266
- * Transforms data by mapping fields according to the provided field mapping
267
- * @param data The source data to transform
268
- * @param fieldMapping Object mapping source field names to target field names
269
- * @returns Transformed data with mapped field names
270
- *
271
- * @example
272
- * ```typescript
273
- * // Single object transformation
274
- * const data = { id: '123', userName: 'john' };
275
- * const mapping = { id: 'userId', userName: 'name' };
276
- * const result = transformData(data, mapping);
277
- * // result = { userId: '123', name: 'john' }
278
- *
279
- * // Array transformation
280
- * const dataArray = [
281
- * { id: '123', userName: 'john' },
282
- * { id: '456', userName: 'jane' }
283
- * ];
284
- * const result = transformData(dataArray, mapping);
285
- * // result = [
286
- * // { userId: '123', name: 'john' },
287
- * // { userId: '456', name: 'jane' }
288
- * // ]
289
- * ```
290
- */
291
- function transformData(data, fieldMapping) {
292
- // Handle array of objects
293
- if (Array.isArray(data)) {
294
- return data.map(item => transformData(item, fieldMapping));
295
- }
296
- // Handle single object
297
- const result = { ...data };
298
- for (const [sourceField, targetField] of Object.entries(fieldMapping)) {
299
- if (sourceField in result) {
300
- const value = result[sourceField];
301
- delete result[sourceField];
302
- result[targetField] = value;
303
- }
304
- }
305
- return result;
306
- }
307
- /**
308
- * Adds a prefix to specified keys in an object, returning a new object.
309
- * Only the provided keys are prefixed; all others are left unchanged.
310
- *
311
- * @param obj The source object
312
- * @param prefix The prefix to add (e.g., '$')
313
- * @param keys The keys to prefix (e.g., ['expand', 'filter'])
314
- * @returns A new object with specified keys prefixed
315
- *
316
- * @example
317
- * addPrefixToKeys({ expand: 'a', foo: 1 }, '$', ['expand']) // { $expand: 'a', foo: 1 }
318
- */
319
- function addPrefixToKeys(obj, prefix, keys) {
320
- const result = {};
321
- for (const [key, value] of Object.entries(obj)) {
322
- if (keys.includes(key)) {
323
- result[`${prefix}${key}`] = value;
324
- }
325
- else {
326
- result[key] = value;
327
- }
328
- }
329
- return result;
330
- }
331
-
332
381
  /**
333
382
  * Maps fields for Incident entities
334
383
  */
@@ -2824,22 +2873,22 @@ class MaestroProcessesService extends BaseService {
2824
2873
  * Returns per-element execution counts (success, fail, terminated, paused, in-progress) and
2825
2874
  * duration percentile metrics (min, max, avg, p50, p95, p99) for BPMN elements within a process.
2826
2875
  *
2827
- * @param processKey - Process key to filter by
2828
- * @param packageId - Package identifier
2829
- * @param startTime - Start of the time range to query
2830
- * @param endTime - End of the time range to query
2831
- * @param packageVersion - Package version to filter by
2876
+ * @param request - Process scope + time range to aggregate over
2832
2877
  * @returns Promise resolving to an array of {@link ElementStats}
2833
2878
  * @example
2834
2879
  * ```typescript
2835
- * // Get element metrics for a process
2836
- * const elements = await maestroProcesses.getElementStats(
2837
- * '<processKey>',
2838
- * '<packageId>',
2839
- * new Date('2026-04-01'),
2840
- * new Date(),
2841
- * '1.0.1'
2842
- * );
2880
+ * // First, list processes to find the processKey, packageId, and available versions
2881
+ * const processes = await maestroProcesses.getAll();
2882
+ * const process = processes[0];
2883
+ *
2884
+ * // Get element metrics for that process
2885
+ * const elements = await maestroProcesses.getElementStats({
2886
+ * processKey: process.processKey,
2887
+ * packageId: process.packageId,
2888
+ * packageVersion: process.packageVersions[0],
2889
+ * startTime: new Date('2026-04-01'),
2890
+ * endTime: new Date(),
2891
+ * });
2843
2892
  *
2844
2893
  * // Analyze element performance
2845
2894
  * for (const element of elements) {
@@ -2847,12 +2896,58 @@ class MaestroProcessesService extends BaseService {
2847
2896
  * console.log(` Success: ${element.successCount}, Failed: ${element.failCount}`);
2848
2897
  * console.log(` Avg duration: ${element.avgDurationMs}ms, P95: ${element.p95DurationMs}ms`);
2849
2898
  * }
2899
+ *
2900
+ * // Using bound method on a process — auto-fills processKey and packageId
2901
+ * const boundElements = await process.getElementStats(
2902
+ * new Date('2026-04-01'),
2903
+ * new Date(),
2904
+ * process.packageVersions[0]
2905
+ * );
2850
2906
  * ```
2851
2907
  */
2852
- async getElementStats(processKey, packageId, startTime, endTime, packageVersion) {
2853
- const { data } = await this.post(MAESTRO_ENDPOINTS.INSIGHTS.ELEMENT_COUNT_BY_STATUS, buildElementCountByStatusBody(processKey, packageId, startTime, endTime, packageVersion));
2908
+ async getElementStats(request) {
2909
+ const { data } = await this.post(MAESTRO_ENDPOINTS.INSIGHTS.ELEMENT_COUNT_BY_STATUS, buildInsightsCommonBody(request));
2854
2910
  return data ?? [];
2855
2911
  }
2912
+ /**
2913
+ * Get instance stats for a process.
2914
+ *
2915
+ * Returns total instance counts broken down by status (running, completed, faulted, etc.)
2916
+ * and the average execution duration for all instances of a process within a time range.
2917
+ *
2918
+ * @param request - Process scope + time range to aggregate over
2919
+ * @returns Promise resolving to {@link InstanceStats}
2920
+ * @example
2921
+ * ```typescript
2922
+ * // First, list processes to find the processKey, packageId, and available versions
2923
+ * const processes = await maestroProcesses.getAll();
2924
+ * const process = processes[0];
2925
+ *
2926
+ * // Get instance status breakdown for that process
2927
+ * const counts = await maestroProcesses.getInstanceStats({
2928
+ * processKey: process.processKey,
2929
+ * packageId: process.packageId,
2930
+ * packageVersion: process.packageVersions[0],
2931
+ * startTime: new Date('2026-04-01'),
2932
+ * endTime: new Date(),
2933
+ * });
2934
+ *
2935
+ * console.log(`Total: ${counts.totalCount}`);
2936
+ * console.log(`Running: ${counts.runningCount}, Completed: ${counts.completedCount}`);
2937
+ * console.log(`Faulted: ${counts.faultedCount}, Avg duration: ${counts.avgDurationMs}ms`);
2938
+ *
2939
+ * // Using bound method on a process — auto-fills processKey and packageId
2940
+ * const boundCounts = await process.getInstanceStats(
2941
+ * new Date('2026-04-01'),
2942
+ * new Date(),
2943
+ * process.packageVersions[0]
2944
+ * );
2945
+ * ```
2946
+ */
2947
+ async getInstanceStats(request) {
2948
+ const { data } = await this.post(MAESTRO_ENDPOINTS.INSIGHTS.INSTANCE_COUNT_BY_STATUS, buildInsightsCommonBody(request));
2949
+ return transformData(data, InstanceStatsMap);
2950
+ }
2856
2951
  }
2857
2952
  __decorate([
2858
2953
  track('MaestroProcesses.GetAll')
@@ -2878,6 +2973,9 @@ __decorate([
2878
2973
  __decorate([
2879
2974
  track('MaestroProcesses.GetElementStats')
2880
2975
  ], MaestroProcessesService.prototype, "getElementStats", null);
2976
+ __decorate([
2977
+ track('MaestroProcesses.GetInstanceStats')
2978
+ ], MaestroProcessesService.prototype, "getInstanceStats", null);
2881
2979
 
2882
2980
  /**
2883
2981
  * Service class for Maestro Process Incidents
@@ -110,21 +110,12 @@ interface GetTopDurationResponse extends GetTopBaseResponse {
110
110
  duration: number;
111
111
  }
112
112
  /**
113
- * Element count by status for a BPMN element within a process or case
113
+ * Duration percentile stats shared by Insights aggregate endpoints (per-element and per-process/case).
114
+ *
115
+ * For instance-level stats, durations are computed over terminal instances only
116
+ * (Completed, Cancelled, Deleted) and default to `0` when no terminal instances exist.
114
117
  */
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;
118
+ interface DurationStats {
128
119
  /** Minimum duration in milliseconds */
129
120
  minDurationMs: number;
130
121
  /** Maximum duration in milliseconds */
@@ -138,6 +129,65 @@ interface ElementStats {
138
129
  /** 99th percentile duration in milliseconds */
139
130
  p99DurationMs: number;
140
131
  }
132
+ /**
133
+ * Instance count and duration stats aggregated by status for a process or case within a time range.
134
+ *
135
+ * Duration fields are computed over terminal instances only (Completed, Cancelled, Deleted)
136
+ * and default to `0` when no terminal instances exist in the time range.
137
+ */
138
+ interface InstanceStats extends DurationStats {
139
+ /** Total number of instances across all statuses */
140
+ totalCount: number;
141
+ /** Number of currently running instances */
142
+ runningCount: number;
143
+ /** Number of instances in transitioning state */
144
+ transitioningCount: number;
145
+ /** Number of paused instances */
146
+ pausedCount: number;
147
+ /** Number of faulted instances */
148
+ faultedCount: number;
149
+ /** Number of completed instances */
150
+ completedCount: number;
151
+ /** Number of cancelled instances */
152
+ cancelledCount: number;
153
+ /** Number of deleted instances */
154
+ deletedCount: number;
155
+ }
156
+ /**
157
+ * Required request parameters for process-scoped insights stats endpoints
158
+ * (`getElementStats`, `getInstanceStats`).
159
+ *
160
+ * Identifies a single process+package+version and the time range to aggregate over.
161
+ */
162
+ interface MaestroProcessStatsRequest {
163
+ /** Process key to filter by */
164
+ processKey: string;
165
+ /** Package identifier */
166
+ packageId: string;
167
+ /** Package version to filter by */
168
+ packageVersion: string;
169
+ /** Start of the time range to query */
170
+ startTime: Date;
171
+ /** End of the time range to query */
172
+ endTime: Date;
173
+ }
174
+ /**
175
+ * Per-element execution counts and duration percentiles for a BPMN element within a process or case.
176
+ */
177
+ interface ElementStats extends DurationStats {
178
+ /** BPMN element identifier */
179
+ elementId: string;
180
+ /** Number of successful executions */
181
+ successCount: number;
182
+ /** Number of failed executions */
183
+ failCount: number;
184
+ /** Number of terminated executions */
185
+ terminatedCount: number;
186
+ /** Number of paused executions */
187
+ pausedCount: number;
188
+ /** Number of in-progress executions */
189
+ inProgressCount: number;
190
+ }
141
191
 
142
192
  /**
143
193
  * Maestro Process Types
@@ -530,22 +580,22 @@ interface MaestroProcessesServiceModel {
530
580
  * Returns per-element execution counts (success, fail, terminated, paused, in-progress) and
531
581
  * duration percentile metrics (min, max, avg, p50, p95, p99) for BPMN elements within a process.
532
582
  *
533
- * @param processKey - Process key to filter by
534
- * @param packageId - Package identifier
535
- * @param startTime - Start of the time range to query
536
- * @param endTime - End of the time range to query
537
- * @param packageVersion - Package version to filter by
583
+ * @param request - Process scope + time range to aggregate over
538
584
  * @returns Promise resolving to an array of {@link ElementStats}
539
585
  * @example
540
586
  * ```typescript
541
- * // Get element metrics for a process
542
- * const elements = await maestroProcesses.getElementStats(
543
- * '<processKey>',
544
- * '<packageId>',
545
- * new Date('2026-04-01'),
546
- * new Date(),
547
- * '1.0.1'
548
- * );
587
+ * // First, list processes to find the processKey, packageId, and available versions
588
+ * const processes = await maestroProcesses.getAll();
589
+ * const process = processes[0];
590
+ *
591
+ * // Get element metrics for that process
592
+ * const elements = await maestroProcesses.getElementStats({
593
+ * processKey: process.processKey,
594
+ * packageId: process.packageId,
595
+ * packageVersion: process.packageVersions[0],
596
+ * startTime: new Date('2026-04-01'),
597
+ * endTime: new Date(),
598
+ * });
549
599
  *
550
600
  * // Analyze element performance
551
601
  * for (const element of elements) {
@@ -553,9 +603,52 @@ interface MaestroProcessesServiceModel {
553
603
  * console.log(` Success: ${element.successCount}, Failed: ${element.failCount}`);
554
604
  * console.log(` Avg duration: ${element.avgDurationMs}ms, P95: ${element.p95DurationMs}ms`);
555
605
  * }
606
+ *
607
+ * // Using bound method on a process — auto-fills processKey and packageId
608
+ * const boundElements = await process.getElementStats(
609
+ * new Date('2026-04-01'),
610
+ * new Date(),
611
+ * process.packageVersions[0]
612
+ * );
613
+ * ```
614
+ */
615
+ getElementStats(request: MaestroProcessStatsRequest): Promise<ElementStats[]>;
616
+ /**
617
+ * Get instance stats for a process.
618
+ *
619
+ * Returns total instance counts broken down by status (running, completed, faulted, etc.)
620
+ * and the average execution duration for all instances of a process within a time range.
621
+ *
622
+ * @param request - Process scope + time range to aggregate over
623
+ * @returns Promise resolving to {@link InstanceStats}
624
+ * @example
625
+ * ```typescript
626
+ * // First, list processes to find the processKey, packageId, and available versions
627
+ * const processes = await maestroProcesses.getAll();
628
+ * const process = processes[0];
629
+ *
630
+ * // Get instance status breakdown for that process
631
+ * const counts = await maestroProcesses.getInstanceStats({
632
+ * processKey: process.processKey,
633
+ * packageId: process.packageId,
634
+ * packageVersion: process.packageVersions[0],
635
+ * startTime: new Date('2026-04-01'),
636
+ * endTime: new Date(),
637
+ * });
638
+ *
639
+ * console.log(`Total: ${counts.totalCount}`);
640
+ * console.log(`Running: ${counts.runningCount}, Completed: ${counts.completedCount}`);
641
+ * console.log(`Faulted: ${counts.faultedCount}, Avg duration: ${counts.avgDurationMs}ms`);
642
+ *
643
+ * // Using bound method on a process — auto-fills processKey and packageId
644
+ * const boundCounts = await process.getInstanceStats(
645
+ * new Date('2026-04-01'),
646
+ * new Date(),
647
+ * process.packageVersions[0]
648
+ * );
556
649
  * ```
557
650
  */
558
- getElementStats(processKey: string, packageId: string, startTime: Date, endTime: Date, packageVersion: string): Promise<ElementStats[]>;
651
+ getInstanceStats(request: MaestroProcessStatsRequest): Promise<InstanceStats>;
559
652
  }
560
653
  interface ProcessMethods {
561
654
  /**
@@ -573,6 +666,15 @@ interface ProcessMethods {
573
666
  * @returns Promise resolving to an array of {@link ElementStats}
574
667
  */
575
668
  getElementStats(startTime: Date, endTime: Date, packageVersion: string): Promise<ElementStats[]>;
669
+ /**
670
+ * Get instance stats for this process
671
+ *
672
+ * @param startTime - Start of the time range to query
673
+ * @param endTime - End of the time range to query
674
+ * @param packageVersion - Package version to filter by
675
+ * @returns Promise resolving to {@link InstanceStats}
676
+ */
677
+ getInstanceStats(startTime: Date, endTime: Date, packageVersion: string): Promise<InstanceStats>;
576
678
  }
577
679
  type MaestroProcessGetAllResponse = RawMaestroProcessGetAllResponse & ProcessMethods;
578
680
  /**
@@ -1574,22 +1676,22 @@ declare class MaestroProcessesService extends BaseService implements MaestroProc
1574
1676
  * Returns per-element execution counts (success, fail, terminated, paused, in-progress) and
1575
1677
  * duration percentile metrics (min, max, avg, p50, p95, p99) for BPMN elements within a process.
1576
1678
  *
1577
- * @param processKey - Process key to filter by
1578
- * @param packageId - Package identifier
1579
- * @param startTime - Start of the time range to query
1580
- * @param endTime - End of the time range to query
1581
- * @param packageVersion - Package version to filter by
1679
+ * @param request - Process scope + time range to aggregate over
1582
1680
  * @returns Promise resolving to an array of {@link ElementStats}
1583
1681
  * @example
1584
1682
  * ```typescript
1585
- * // Get element metrics for a process
1586
- * const elements = await maestroProcesses.getElementStats(
1587
- * '<processKey>',
1588
- * '<packageId>',
1589
- * new Date('2026-04-01'),
1590
- * new Date(),
1591
- * '1.0.1'
1592
- * );
1683
+ * // First, list processes to find the processKey, packageId, and available versions
1684
+ * const processes = await maestroProcesses.getAll();
1685
+ * const process = processes[0];
1686
+ *
1687
+ * // Get element metrics for that process
1688
+ * const elements = await maestroProcesses.getElementStats({
1689
+ * processKey: process.processKey,
1690
+ * packageId: process.packageId,
1691
+ * packageVersion: process.packageVersions[0],
1692
+ * startTime: new Date('2026-04-01'),
1693
+ * endTime: new Date(),
1694
+ * });
1593
1695
  *
1594
1696
  * // Analyze element performance
1595
1697
  * for (const element of elements) {
@@ -1597,9 +1699,52 @@ declare class MaestroProcessesService extends BaseService implements MaestroProc
1597
1699
  * console.log(` Success: ${element.successCount}, Failed: ${element.failCount}`);
1598
1700
  * console.log(` Avg duration: ${element.avgDurationMs}ms, P95: ${element.p95DurationMs}ms`);
1599
1701
  * }
1702
+ *
1703
+ * // Using bound method on a process — auto-fills processKey and packageId
1704
+ * const boundElements = await process.getElementStats(
1705
+ * new Date('2026-04-01'),
1706
+ * new Date(),
1707
+ * process.packageVersions[0]
1708
+ * );
1709
+ * ```
1710
+ */
1711
+ getElementStats(request: MaestroProcessStatsRequest): Promise<ElementStats[]>;
1712
+ /**
1713
+ * Get instance stats for a process.
1714
+ *
1715
+ * Returns total instance counts broken down by status (running, completed, faulted, etc.)
1716
+ * and the average execution duration for all instances of a process within a time range.
1717
+ *
1718
+ * @param request - Process scope + time range to aggregate over
1719
+ * @returns Promise resolving to {@link InstanceStats}
1720
+ * @example
1721
+ * ```typescript
1722
+ * // First, list processes to find the processKey, packageId, and available versions
1723
+ * const processes = await maestroProcesses.getAll();
1724
+ * const process = processes[0];
1725
+ *
1726
+ * // Get instance status breakdown for that process
1727
+ * const counts = await maestroProcesses.getInstanceStats({
1728
+ * processKey: process.processKey,
1729
+ * packageId: process.packageId,
1730
+ * packageVersion: process.packageVersions[0],
1731
+ * startTime: new Date('2026-04-01'),
1732
+ * endTime: new Date(),
1733
+ * });
1734
+ *
1735
+ * console.log(`Total: ${counts.totalCount}`);
1736
+ * console.log(`Running: ${counts.runningCount}, Completed: ${counts.completedCount}`);
1737
+ * console.log(`Faulted: ${counts.faultedCount}, Avg duration: ${counts.avgDurationMs}ms`);
1738
+ *
1739
+ * // Using bound method on a process — auto-fills processKey and packageId
1740
+ * const boundCounts = await process.getInstanceStats(
1741
+ * new Date('2026-04-01'),
1742
+ * new Date(),
1743
+ * process.packageVersions[0]
1744
+ * );
1600
1745
  * ```
1601
1746
  */
1602
- getElementStats(processKey: string, packageId: string, startTime: Date, endTime: Date, packageVersion: string): Promise<ElementStats[]>;
1747
+ getInstanceStats(request: MaestroProcessStatsRequest): Promise<InstanceStats>;
1603
1748
  }
1604
1749
 
1605
1750
  declare class ProcessInstancesService extends BaseService implements ProcessInstancesServiceModel {
@@ -1774,4 +1919,4 @@ declare class ProcessIncidentsService extends BaseService implements ProcessInci
1774
1919
  }
1775
1920
 
1776
1921
  export { DebugMode, InstanceFinalStatus, MaestroProcessesService as MaestroProcesses, MaestroProcessesService, ProcessIncidentSeverity, ProcessIncidentStatus, ProcessIncidentType, ProcessIncidentsService as ProcessIncidents, ProcessIncidentsService, ProcessInstancesService as ProcessInstances, ProcessInstancesService, TimeInterval, createProcessInstanceWithMethods, createProcessWithMethods };
1777
- export type { BpmnXmlString, ElementGetTopFailedCountResponse, ElementMetaData, ElementStats, GetTopBaseResponse, GetTopDurationResponse, GetTopFaultedCountResponse, GetTopRunCountResponse, GlobalVariableMetaData, InstanceStatusTimelineResponse, MaestroProcessGetAllResponse, MaestroProcessesServiceModel, ProcessGetTopDurationResponse, ProcessGetTopFaultedCountResponse, ProcessGetTopRunCountResponse, ProcessIncidentGetAllResponse, ProcessIncidentGetResponse, ProcessIncidentsServiceModel, ProcessInstanceExecutionHistoryResponse, ProcessInstanceGetAllOptions, ProcessInstanceGetAllWithPaginationOptions, ProcessInstanceGetResponse, ProcessInstanceGetVariablesOptions, ProcessInstanceGetVariablesResponse, ProcessInstanceMethods, ProcessInstanceOperationOptions, ProcessInstanceOperationResponse, ProcessInstanceRun, ProcessInstancesServiceModel, ProcessMethods, RawMaestroProcessGetAllResponse, RawProcessInstanceGetResponse, TimelineOptions, TopQueryOptions };
1922
+ export type { BpmnXmlString, DurationStats, ElementGetTopFailedCountResponse, ElementMetaData, ElementStats, GetTopBaseResponse, GetTopDurationResponse, GetTopFaultedCountResponse, GetTopRunCountResponse, GlobalVariableMetaData, InstanceStats, InstanceStatusTimelineResponse, MaestroProcessGetAllResponse, MaestroProcessStatsRequest, MaestroProcessesServiceModel, ProcessGetTopDurationResponse, ProcessGetTopFaultedCountResponse, ProcessGetTopRunCountResponse, ProcessIncidentGetAllResponse, ProcessIncidentGetResponse, ProcessIncidentsServiceModel, ProcessInstanceExecutionHistoryResponse, ProcessInstanceGetAllOptions, ProcessInstanceGetAllWithPaginationOptions, ProcessInstanceGetResponse, ProcessInstanceGetVariablesOptions, ProcessInstanceGetVariablesResponse, ProcessInstanceMethods, ProcessInstanceOperationOptions, ProcessInstanceOperationResponse, ProcessInstanceRun, ProcessInstancesServiceModel, ProcessMethods, RawMaestroProcessGetAllResponse, RawProcessInstanceGetResponse, TimelineOptions, TopQueryOptions };