@uipath/uipath-typescript 1.4.2 → 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/README.md +7 -1
  2. package/dist/agent-memory/index.d.ts +4 -1
  3. package/dist/agents/index.cjs +341 -6
  4. package/dist/agents/index.d.ts +717 -16
  5. package/dist/agents/index.mjs +342 -7
  6. package/dist/assets/index.cjs +132 -15
  7. package/dist/assets/index.d.ts +12 -1
  8. package/dist/assets/index.mjs +132 -15
  9. package/dist/attachments/index.cjs +120 -12
  10. package/dist/attachments/index.mjs +120 -12
  11. package/dist/buckets/index.cjs +136 -15
  12. package/dist/buckets/index.d.ts +12 -1
  13. package/dist/buckets/index.mjs +136 -15
  14. package/dist/cases/index.cjs +1203 -938
  15. package/dist/cases/index.d.ts +325 -45
  16. package/dist/cases/index.mjs +1203 -938
  17. package/dist/conversational-agent/index.cjs +48 -10
  18. package/dist/conversational-agent/index.d.ts +117 -6
  19. package/dist/conversational-agent/index.mjs +48 -10
  20. package/dist/core/index.cjs +1 -1
  21. package/dist/core/index.mjs +1 -1
  22. package/dist/entities/index.cjs +448 -9
  23. package/dist/entities/index.d.ts +441 -1
  24. package/dist/entities/index.mjs +447 -10
  25. package/dist/feedback/index.cjs +25 -9
  26. package/dist/feedback/index.mjs +25 -9
  27. package/dist/index.cjs +1281 -330
  28. package/dist/index.d.ts +1988 -143
  29. package/dist/index.mjs +1282 -331
  30. package/dist/index.umd.js +1230 -279
  31. package/dist/jobs/index.cjs +141 -19
  32. package/dist/jobs/index.d.ts +22 -6
  33. package/dist/jobs/index.mjs +141 -19
  34. package/dist/maestro-processes/index.cjs +553 -354
  35. package/dist/maestro-processes/index.d.ts +376 -47
  36. package/dist/maestro-processes/index.mjs +553 -354
  37. package/dist/notifications/index.cjs +2012 -0
  38. package/dist/notifications/index.d.ts +615 -0
  39. package/dist/notifications/index.mjs +2010 -0
  40. package/dist/processes/index.cjs +118 -18
  41. package/dist/processes/index.d.ts +18 -2
  42. package/dist/processes/index.mjs +118 -18
  43. package/dist/queues/index.cjs +131 -14
  44. package/dist/queues/index.d.ts +12 -1
  45. package/dist/queues/index.mjs +131 -14
  46. package/dist/tasks/index.cjs +125 -13
  47. package/dist/tasks/index.d.ts +4 -1
  48. package/dist/tasks/index.mjs +125 -13
  49. package/dist/traces/index.cjs +220 -6
  50. package/dist/traces/index.d.ts +360 -25
  51. package/dist/traces/index.mjs +221 -7
  52. package/package.json +14 -4
@@ -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
  */
@@ -69,6 +171,7 @@ const MAESTRO_ENDPOINTS = {
69
171
  CANCEL: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/cancel`,
70
172
  PAUSE: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/pause`,
71
173
  RESUME: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/resume`,
174
+ RETRY: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/retry`,
72
175
  },
73
176
  INCIDENTS: {
74
177
  GET_ALL: `${PIMS_BASE}/api/v1/incidents/summary`,
@@ -89,8 +192,12 @@ const MAESTRO_ENDPOINTS = {
89
192
  INSTANCE_STATUS_BY_DATE: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/InstanceStatusByDate`,
90
193
  /** Top processes ranked by total duration */
91
194
  TOP_PROCESSES_BY_DURATION: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/TopProcessesByDuration`,
195
+ /** Instance stats (counts by status + duration percentiles) */
196
+ INSTANCE_COUNT_BY_STATUS: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/InstanceCountByStatus`,
92
197
  /** Element count by status for agentic instances (process and case) */
93
198
  ELEMENT_COUNT_BY_STATUS: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/ElementCountByStatus`,
199
+ /** Incident counts aggregated by time bucket for time-series charts */
200
+ INCIDENTS_BY_TIME_WINDOW: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/IncidentsByTimeWindow`,
94
201
  },
95
202
  };
96
203
 
@@ -119,7 +226,36 @@ function createProcessMethods(processData, service) {
119
226
  throw new Error('Process key is undefined');
120
227
  if (!processData.packageId)
121
228
  throw new Error('Package ID is undefined');
122
- return service.getElementStats(processData.processKey, processData.packageId, startTime, endTime, packageVersion);
229
+ return service.getElementStats({
230
+ processKey: processData.processKey,
231
+ packageId: processData.packageId,
232
+ packageVersion,
233
+ startTime,
234
+ endTime,
235
+ });
236
+ },
237
+ getInstanceStats(startTime, endTime, packageVersion) {
238
+ if (!processData.processKey)
239
+ throw new Error('Process key is undefined');
240
+ if (!processData.packageId)
241
+ throw new Error('Package ID is undefined');
242
+ return service.getInstanceStats({
243
+ processKey: processData.processKey,
244
+ packageId: processData.packageId,
245
+ packageVersion,
246
+ startTime,
247
+ endTime,
248
+ });
249
+ },
250
+ getInstanceStatusTimeline(startTime, endTime, options) {
251
+ if (!processData.processKey)
252
+ throw new Error('Process key is undefined');
253
+ return service.getInstanceStatusTimeline(startTime, endTime, { ...options, processKeys: [processData.processKey] });
254
+ },
255
+ getIncidentsTimeline(startTime, endTime, options) {
256
+ if (!processData.processKey)
257
+ throw new Error('Process key is undefined');
258
+ return service.getIncidentsTimeline(startTime, endTime, { ...options, processKeys: [processData.processKey] });
123
259
  }
124
260
  };
125
261
  }
@@ -135,6 +271,242 @@ function createProcessWithMethods(processData, service) {
135
271
  return Object.assign({}, processData, methods);
136
272
  }
137
273
 
274
+ /**
275
+ * Creates methods for a process instance
276
+ *
277
+ * @param instanceData - The process instance data (response from API)
278
+ * @param service - The process instance service instance
279
+ * @returns Object containing process instance methods
280
+ */
281
+ function createProcessInstanceMethods(instanceData, service) {
282
+ return {
283
+ async cancel(options) {
284
+ if (!instanceData.instanceId)
285
+ throw new Error('Process instance ID is undefined');
286
+ if (!instanceData.folderKey)
287
+ throw new Error('Process instance folder key is undefined');
288
+ return service.cancel(instanceData.instanceId, instanceData.folderKey, options);
289
+ },
290
+ async pause(options) {
291
+ if (!instanceData.instanceId)
292
+ throw new Error('Process instance ID is undefined');
293
+ if (!instanceData.folderKey)
294
+ throw new Error('Process instance folder key is undefined');
295
+ return service.pause(instanceData.instanceId, instanceData.folderKey, options);
296
+ },
297
+ async resume(options) {
298
+ if (!instanceData.instanceId)
299
+ throw new Error('Process instance ID is undefined');
300
+ if (!instanceData.folderKey)
301
+ throw new Error('Process instance folder key is undefined');
302
+ return service.resume(instanceData.instanceId, instanceData.folderKey, options);
303
+ },
304
+ async retry(options) {
305
+ if (!instanceData.instanceId)
306
+ throw new Error('Process instance ID is undefined');
307
+ if (!instanceData.folderKey)
308
+ throw new Error('Process instance folder key is undefined');
309
+ return service.retry(instanceData.instanceId, instanceData.folderKey, options);
310
+ },
311
+ async getIncidents() {
312
+ if (!instanceData.instanceId)
313
+ throw new Error('Process instance ID is undefined');
314
+ if (!instanceData.folderKey)
315
+ throw new Error('Process instance folder key is undefined');
316
+ return service.getIncidents(instanceData.instanceId, instanceData.folderKey);
317
+ },
318
+ async getExecutionHistory() {
319
+ if (!instanceData.instanceId)
320
+ throw new Error('Process instance ID is undefined');
321
+ if (!instanceData.folderKey)
322
+ throw new Error('Process instance folder key is undefined');
323
+ return service.getExecutionHistory(instanceData.instanceId, instanceData.folderKey);
324
+ },
325
+ async getBpmn() {
326
+ if (!instanceData.instanceId)
327
+ throw new Error('Process instance ID is undefined');
328
+ if (!instanceData.folderKey)
329
+ throw new Error('Process instance folder key is undefined');
330
+ return service.getBpmn(instanceData.instanceId, instanceData.folderKey);
331
+ },
332
+ async getVariables(options) {
333
+ if (!instanceData.instanceId)
334
+ throw new Error('Process instance ID is undefined');
335
+ if (!instanceData.folderKey)
336
+ throw new Error('Process instance folder key is undefined');
337
+ return service.getVariables(instanceData.instanceId, instanceData.folderKey, options);
338
+ }
339
+ };
340
+ }
341
+ /**
342
+ * Creates an actionable process instance by combining API process instance data with operational methods.
343
+ *
344
+ * @param instanceData - The process instance data from API
345
+ * @param service - The process instance service instance
346
+ * @returns A process instance object with added methods
347
+ */
348
+ function createProcessInstanceWithMethods(instanceData, service) {
349
+ const methods = createProcessInstanceMethods(instanceData, service);
350
+ return Object.assign({}, instanceData, methods);
351
+ }
352
+
353
+ /**
354
+ * Process Incident Status
355
+ */
356
+ exports.ProcessIncidentStatus = void 0;
357
+ (function (ProcessIncidentStatus) {
358
+ ProcessIncidentStatus["Open"] = "Open";
359
+ ProcessIncidentStatus["Closed"] = "Closed";
360
+ })(exports.ProcessIncidentStatus || (exports.ProcessIncidentStatus = {}));
361
+ /**
362
+ * Process Incident Type
363
+ */
364
+ exports.ProcessIncidentType = void 0;
365
+ (function (ProcessIncidentType) {
366
+ ProcessIncidentType["System"] = "System";
367
+ ProcessIncidentType["User"] = "User";
368
+ ProcessIncidentType["Deployment"] = "Deployment";
369
+ })(exports.ProcessIncidentType || (exports.ProcessIncidentType = {}));
370
+ /**
371
+ * Process Incident Severity
372
+ */
373
+ exports.ProcessIncidentSeverity = void 0;
374
+ (function (ProcessIncidentSeverity) {
375
+ ProcessIncidentSeverity["Error"] = "Error";
376
+ ProcessIncidentSeverity["Warning"] = "Warning";
377
+ })(exports.ProcessIncidentSeverity || (exports.ProcessIncidentSeverity = {}));
378
+ /**
379
+ * Process Incident Debug Mode
380
+ */
381
+ exports.DebugMode = void 0;
382
+ (function (DebugMode) {
383
+ DebugMode["None"] = "None";
384
+ DebugMode["Default"] = "Default";
385
+ DebugMode["StepByStep"] = "StepByStep";
386
+ DebugMode["SingleStep"] = "SingleStep";
387
+ })(exports.DebugMode || (exports.DebugMode = {}));
388
+
389
+ /**
390
+ * Case Instance Types
391
+ * Types and interfaces for Maestro case instance management
392
+ */
393
+ /**
394
+ * SLA status for a case instance
395
+ */
396
+ var SlaSummaryStatus;
397
+ (function (SlaSummaryStatus) {
398
+ /** Case is within SLA deadline */
399
+ SlaSummaryStatus["ON_TRACK"] = "On Track";
400
+ /** Case is approaching SLA deadline based on at-risk percentage threshold */
401
+ SlaSummaryStatus["AT_RISK"] = "At Risk";
402
+ /** Case has exceeded SLA deadline */
403
+ SlaSummaryStatus["OVERDUE"] = "Overdue";
404
+ /** Case instance has completed */
405
+ SlaSummaryStatus["COMPLETED"] = "Completed";
406
+ /** SLA status cannot be determined (no SLA deadline defined) */
407
+ SlaSummaryStatus["UNKNOWN"] = "Unknown";
408
+ })(SlaSummaryStatus || (SlaSummaryStatus = {}));
409
+ /**
410
+ * Instance status values for case instances and process instances
411
+ */
412
+ var InstanceStatus;
413
+ (function (InstanceStatus) {
414
+ /** Instance status not yet populated by the backend */
415
+ InstanceStatus["UNKNOWN"] = "";
416
+ InstanceStatus["CANCELLED"] = "Cancelled";
417
+ InstanceStatus["CANCELING"] = "Canceling";
418
+ InstanceStatus["COMPLETED"] = "Completed";
419
+ InstanceStatus["FAULTED"] = "Faulted";
420
+ InstanceStatus["PAUSED"] = "Paused";
421
+ InstanceStatus["PAUSING"] = "Pausing";
422
+ InstanceStatus["PENDING"] = "Pending";
423
+ InstanceStatus["RESUMING"] = "Resuming";
424
+ InstanceStatus["RETRYING"] = "Retrying";
425
+ InstanceStatus["RUNNING"] = "Running";
426
+ InstanceStatus["UPGRADING"] = "Upgrading";
427
+ })(InstanceStatus || (InstanceStatus = {}));
428
+ /**
429
+ * Case stage task type
430
+ */
431
+ var StageTaskType;
432
+ (function (StageTaskType) {
433
+ StageTaskType["EXTERNAL_AGENT"] = "external-agent";
434
+ StageTaskType["RPA"] = "rpa";
435
+ StageTaskType["AGENTIC_PROCESS"] = "process";
436
+ StageTaskType["AGENT"] = "agent";
437
+ StageTaskType["ACTION"] = "action";
438
+ StageTaskType["API_WORKFLOW"] = "api-workflow";
439
+ })(StageTaskType || (StageTaskType = {}));
440
+ /**
441
+ * Escalation recipient scope
442
+ */
443
+ var EscalationRecipientScope;
444
+ (function (EscalationRecipientScope) {
445
+ EscalationRecipientScope["USER"] = "user";
446
+ EscalationRecipientScope["USER_GROUP"] = "usergroup";
447
+ })(EscalationRecipientScope || (EscalationRecipientScope = {}));
448
+ /**
449
+ * Escalation action type
450
+ */
451
+ var EscalationActionType;
452
+ (function (EscalationActionType) {
453
+ EscalationActionType["NOTIFICATION"] = "notification";
454
+ })(EscalationActionType || (EscalationActionType = {}));
455
+ /**
456
+ * Escalation rule trigger type
457
+ */
458
+ var EscalationTriggerType;
459
+ (function (EscalationTriggerType) {
460
+ EscalationTriggerType["SLA_BREACHED"] = "sla-breached";
461
+ EscalationTriggerType["AT_RISK"] = "at-risk";
462
+ /** Default value when no escalation rule is defined */
463
+ EscalationTriggerType["NONE"] = "None";
464
+ })(EscalationTriggerType || (EscalationTriggerType = {}));
465
+ /**
466
+ * SLA duration unit
467
+ */
468
+ var SLADurationUnit;
469
+ (function (SLADurationUnit) {
470
+ SLADurationUnit["HOURS"] = "h";
471
+ SLADurationUnit["DAYS"] = "d";
472
+ SLADurationUnit["WEEKS"] = "w";
473
+ SLADurationUnit["MONTHS"] = "m";
474
+ })(SLADurationUnit || (SLADurationUnit = {}));
475
+
476
+ /**
477
+ * Insights Types
478
+ * Shared types for Maestro insights analytics endpoints
479
+ */
480
+ /**
481
+ * Time bucketing granularity for insights time-series queries.
482
+ *
483
+ * Controls how data points are grouped on the time axis.
484
+ */
485
+ exports.TimeInterval = void 0;
486
+ (function (TimeInterval) {
487
+ /** Group data points by hour */
488
+ TimeInterval["Hour"] = "HOUR";
489
+ /** Group data points by day */
490
+ TimeInterval["Day"] = "DAY";
491
+ /** Group data points by week */
492
+ TimeInterval["Week"] = "WEEK";
493
+ })(exports.TimeInterval || (exports.TimeInterval = {}));
494
+ /**
495
+ * Final instance statuses returned by the instance status timeline endpoint.
496
+ *
497
+ * Only includes statuses where the instance has finished execution — Completed, Faulted, or Cancelled.
498
+ * Active statuses like Running or Paused are not included.
499
+ */
500
+ exports.InstanceFinalStatus = void 0;
501
+ (function (InstanceFinalStatus) {
502
+ /** Instance completed successfully */
503
+ InstanceFinalStatus["Completed"] = "Completed";
504
+ /** Instance encountered an error */
505
+ InstanceFinalStatus["Faulted"] = "Faulted";
506
+ /** Instance was cancelled */
507
+ InstanceFinalStatus["Cancelled"] = "Cancelled";
508
+ })(exports.InstanceFinalStatus || (exports.InstanceFinalStatus = {}));
509
+
138
510
  /**
139
511
  * Builds the request body for Insights RTM "top" endpoints.
140
512
  *
@@ -158,48 +530,46 @@ function buildInsightsTopBody(startTime, endTime, isCaseManagement, options) {
158
530
  };
159
531
  }
160
532
  /**
161
- * Fetches instance status timeline from the Insights API.
162
- * Shared implementation used by both MaestroProcessesService and CasesService.
533
+ * Builds the request body for Insights RTM timeline endpoints
534
+ * (`InstanceStatusByDate`, `IncidentsByTimeWindow`).
163
535
  *
164
- * @param postFn - Bound post method from a BaseService subclass
165
536
  * @param startTime - Start of the time range to query
166
537
  * @param endTime - End of the time range to query
167
538
  * @param isCaseManagement - Whether to filter for case management processes
168
- * @param options - Optional settings for time bucketing granularity
169
- * @returns Promise resolving to an array of instance status timeline entries
539
+ * @param options - Optional time bucketing and filtering settings
540
+ * @returns Request body for the Insights RTM timeline endpoint
170
541
  * @internal
171
542
  */
172
- async function fetchInstanceStatusTimeline(postFn, startTime, endTime, isCaseManagement, options) {
173
- const response = await postFn(MAESTRO_ENDPOINTS.INSIGHTS.INSTANCE_STATUS_BY_DATE, {
543
+ function buildInsightsTimelineBody(startTime, endTime, isCaseManagement, options) {
544
+ return {
174
545
  commonParams: {
175
546
  startTime: startTime.getTime(),
176
547
  endTime: endTime.getTime(),
177
548
  isCaseManagement,
549
+ ...(options?.packageId ? { packageId: options.packageId } : {}),
550
+ ...(options?.version ? { version: options.version } : {}),
551
+ ...(options?.processKeys ? { processKeys: options.processKeys } : {}),
178
552
  },
179
- timeSliceUnit: options?.groupBy,
553
+ timeSliceUnit: options?.groupBy ?? exports.TimeInterval.Day,
180
554
  timezoneOffset: new Date().getTimezoneOffset() * -1,
181
- });
182
- return response.data ?? [];
555
+ };
183
556
  }
184
557
  /**
185
- * Builds the request body for the ElementCountByStatus endpoint.
558
+ * Builds the commonParams request body for Insights RTM endpoints
559
+ * that filter by process key, package, time range, and version.
186
560
  *
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
561
+ * @param request - Process scope + time range to aggregate over
562
+ * @returns Request body with commonParams
193
563
  * @internal
194
564
  */
195
- function buildElementCountByStatusBody(processKey, packageId, startTime, endTime, packageVersion) {
565
+ function buildInsightsCommonBody(request) {
196
566
  return {
197
567
  commonParams: {
198
- processKey,
199
- packageId,
200
- startTime: startTime.getTime(),
201
- endTime: endTime.getTime(),
202
- version: packageVersion
568
+ processKey: request.processKey,
569
+ packageId: request.packageId,
570
+ startTime: request.startTime.getTime(),
571
+ endTime: request.endTime.getTime(),
572
+ version: request.packageVersion
203
573
  }
204
574
  };
205
575
  }
@@ -258,77 +628,6 @@ const PROCESS_INSTANCE_TOKEN_PARAMS = {
258
628
  TOKEN_PARAM: 'nextPage'
259
629
  };
260
630
 
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
631
  /**
333
632
  * Maps fields for Incident entities
334
633
  */
@@ -1933,249 +2232,20 @@ class BaseService {
1933
2232
  case PaginationType.OFFSET:
1934
2233
  const effectivePageSize = info.pageSize ?? DEFAULT_PAGE_SIZE;
1935
2234
  // If totalCount is available, use it for precise calculation
1936
- if (info.totalCount !== undefined) {
1937
- return (info.currentPage * effectivePageSize) < info.totalCount;
1938
- }
1939
- // Fallback when totalCount is not available
1940
- // NOTE: This code path should rarely be executed as the APIs typically return totalCount
1941
- return info.itemsCount === effectivePageSize;
1942
- case PaginationType.TOKEN:
1943
- return !!info.continuationToken;
1944
- default:
1945
- return false;
1946
- }
1947
- }
1948
- }
1949
- _BaseService_apiClient = new WeakMap();
1950
-
1951
- /**
1952
- * Creates methods for a process instance
1953
- *
1954
- * @param instanceData - The process instance data (response from API)
1955
- * @param service - The process instance service instance
1956
- * @returns Object containing process instance methods
1957
- */
1958
- function createProcessInstanceMethods(instanceData, service) {
1959
- return {
1960
- async cancel(options) {
1961
- if (!instanceData.instanceId)
1962
- throw new Error('Process instance ID is undefined');
1963
- if (!instanceData.folderKey)
1964
- throw new Error('Process instance folder key is undefined');
1965
- return service.cancel(instanceData.instanceId, instanceData.folderKey, options);
1966
- },
1967
- async pause(options) {
1968
- if (!instanceData.instanceId)
1969
- throw new Error('Process instance ID is undefined');
1970
- if (!instanceData.folderKey)
1971
- throw new Error('Process instance folder key is undefined');
1972
- return service.pause(instanceData.instanceId, instanceData.folderKey, options);
1973
- },
1974
- async resume(options) {
1975
- if (!instanceData.instanceId)
1976
- throw new Error('Process instance ID is undefined');
1977
- if (!instanceData.folderKey)
1978
- throw new Error('Process instance folder key is undefined');
1979
- return service.resume(instanceData.instanceId, instanceData.folderKey, options);
1980
- },
1981
- async getIncidents() {
1982
- if (!instanceData.instanceId)
1983
- throw new Error('Process instance ID is undefined');
1984
- if (!instanceData.folderKey)
1985
- throw new Error('Process instance folder key is undefined');
1986
- return service.getIncidents(instanceData.instanceId, instanceData.folderKey);
1987
- },
1988
- async getExecutionHistory() {
1989
- if (!instanceData.instanceId)
1990
- throw new Error('Process instance ID is undefined');
1991
- if (!instanceData.folderKey)
1992
- throw new Error('Process instance folder key is undefined');
1993
- return service.getExecutionHistory(instanceData.instanceId, instanceData.folderKey);
1994
- },
1995
- async getBpmn() {
1996
- if (!instanceData.instanceId)
1997
- throw new Error('Process instance ID is undefined');
1998
- if (!instanceData.folderKey)
1999
- throw new Error('Process instance folder key is undefined');
2000
- return service.getBpmn(instanceData.instanceId, instanceData.folderKey);
2001
- },
2002
- async getVariables(options) {
2003
- if (!instanceData.instanceId)
2004
- throw new Error('Process instance ID is undefined');
2005
- if (!instanceData.folderKey)
2006
- throw new Error('Process instance folder key is undefined');
2007
- return service.getVariables(instanceData.instanceId, instanceData.folderKey, options);
2235
+ if (info.totalCount !== undefined) {
2236
+ return (info.currentPage * effectivePageSize) < info.totalCount;
2237
+ }
2238
+ // Fallback when totalCount is not available
2239
+ // NOTE: This code path should rarely be executed as the APIs typically return totalCount
2240
+ return info.itemsCount === effectivePageSize;
2241
+ case PaginationType.TOKEN:
2242
+ return !!info.continuationToken;
2243
+ default:
2244
+ return false;
2008
2245
  }
2009
- };
2010
- }
2011
- /**
2012
- * Creates an actionable process instance by combining API process instance data with operational methods.
2013
- *
2014
- * @param instanceData - The process instance data from API
2015
- * @param service - The process instance service instance
2016
- * @returns A process instance object with added methods
2017
- */
2018
- function createProcessInstanceWithMethods(instanceData, service) {
2019
- const methods = createProcessInstanceMethods(instanceData, service);
2020
- return Object.assign({}, instanceData, methods);
2246
+ }
2021
2247
  }
2022
-
2023
- /**
2024
- * Process Incident Status
2025
- */
2026
- exports.ProcessIncidentStatus = void 0;
2027
- (function (ProcessIncidentStatus) {
2028
- ProcessIncidentStatus["Open"] = "Open";
2029
- ProcessIncidentStatus["Closed"] = "Closed";
2030
- })(exports.ProcessIncidentStatus || (exports.ProcessIncidentStatus = {}));
2031
- /**
2032
- * Process Incident Type
2033
- */
2034
- exports.ProcessIncidentType = void 0;
2035
- (function (ProcessIncidentType) {
2036
- ProcessIncidentType["System"] = "System";
2037
- ProcessIncidentType["User"] = "User";
2038
- ProcessIncidentType["Deployment"] = "Deployment";
2039
- })(exports.ProcessIncidentType || (exports.ProcessIncidentType = {}));
2040
- /**
2041
- * Process Incident Severity
2042
- */
2043
- exports.ProcessIncidentSeverity = void 0;
2044
- (function (ProcessIncidentSeverity) {
2045
- ProcessIncidentSeverity["Error"] = "Error";
2046
- ProcessIncidentSeverity["Warning"] = "Warning";
2047
- })(exports.ProcessIncidentSeverity || (exports.ProcessIncidentSeverity = {}));
2048
- /**
2049
- * Process Incident Debug Mode
2050
- */
2051
- exports.DebugMode = void 0;
2052
- (function (DebugMode) {
2053
- DebugMode["None"] = "None";
2054
- DebugMode["Default"] = "Default";
2055
- DebugMode["StepByStep"] = "StepByStep";
2056
- DebugMode["SingleStep"] = "SingleStep";
2057
- })(exports.DebugMode || (exports.DebugMode = {}));
2058
-
2059
- /**
2060
- * Case Instance Types
2061
- * Types and interfaces for Maestro case instance management
2062
- */
2063
- /**
2064
- * SLA status for a case instance
2065
- */
2066
- var SlaSummaryStatus;
2067
- (function (SlaSummaryStatus) {
2068
- /** Case is within SLA deadline */
2069
- SlaSummaryStatus["ON_TRACK"] = "On Track";
2070
- /** Case is approaching SLA deadline based on at-risk percentage threshold */
2071
- SlaSummaryStatus["AT_RISK"] = "At Risk";
2072
- /** Case has exceeded SLA deadline */
2073
- SlaSummaryStatus["OVERDUE"] = "Overdue";
2074
- /** Case instance has completed */
2075
- SlaSummaryStatus["COMPLETED"] = "Completed";
2076
- /** SLA status cannot be determined (no SLA deadline defined) */
2077
- SlaSummaryStatus["UNKNOWN"] = "Unknown";
2078
- })(SlaSummaryStatus || (SlaSummaryStatus = {}));
2079
- /**
2080
- * Instance status values for case instances and process instances
2081
- */
2082
- var InstanceStatus;
2083
- (function (InstanceStatus) {
2084
- /** Instance status not yet populated by the backend */
2085
- InstanceStatus["UNKNOWN"] = "";
2086
- InstanceStatus["CANCELLED"] = "Cancelled";
2087
- InstanceStatus["CANCELING"] = "Canceling";
2088
- InstanceStatus["COMPLETED"] = "Completed";
2089
- InstanceStatus["FAULTED"] = "Faulted";
2090
- InstanceStatus["PAUSED"] = "Paused";
2091
- InstanceStatus["PAUSING"] = "Pausing";
2092
- InstanceStatus["PENDING"] = "Pending";
2093
- InstanceStatus["RESUMING"] = "Resuming";
2094
- InstanceStatus["RETRYING"] = "Retrying";
2095
- InstanceStatus["RUNNING"] = "Running";
2096
- InstanceStatus["UPGRADING"] = "Upgrading";
2097
- })(InstanceStatus || (InstanceStatus = {}));
2098
- /**
2099
- * Case stage task type
2100
- */
2101
- var StageTaskType;
2102
- (function (StageTaskType) {
2103
- StageTaskType["EXTERNAL_AGENT"] = "external-agent";
2104
- StageTaskType["RPA"] = "rpa";
2105
- StageTaskType["AGENTIC_PROCESS"] = "process";
2106
- StageTaskType["AGENT"] = "agent";
2107
- StageTaskType["ACTION"] = "action";
2108
- StageTaskType["API_WORKFLOW"] = "api-workflow";
2109
- })(StageTaskType || (StageTaskType = {}));
2110
- /**
2111
- * Escalation recipient scope
2112
- */
2113
- var EscalationRecipientScope;
2114
- (function (EscalationRecipientScope) {
2115
- EscalationRecipientScope["USER"] = "user";
2116
- EscalationRecipientScope["USER_GROUP"] = "usergroup";
2117
- })(EscalationRecipientScope || (EscalationRecipientScope = {}));
2118
- /**
2119
- * Escalation action type
2120
- */
2121
- var EscalationActionType;
2122
- (function (EscalationActionType) {
2123
- EscalationActionType["NOTIFICATION"] = "notification";
2124
- })(EscalationActionType || (EscalationActionType = {}));
2125
- /**
2126
- * Escalation rule trigger type
2127
- */
2128
- var EscalationTriggerType;
2129
- (function (EscalationTriggerType) {
2130
- EscalationTriggerType["SLA_BREACHED"] = "sla-breached";
2131
- EscalationTriggerType["AT_RISK"] = "at-risk";
2132
- /** Default value when no escalation rule is defined */
2133
- EscalationTriggerType["NONE"] = "None";
2134
- })(EscalationTriggerType || (EscalationTriggerType = {}));
2135
- /**
2136
- * SLA duration unit
2137
- */
2138
- var SLADurationUnit;
2139
- (function (SLADurationUnit) {
2140
- SLADurationUnit["HOURS"] = "h";
2141
- SLADurationUnit["DAYS"] = "d";
2142
- SLADurationUnit["WEEKS"] = "w";
2143
- SLADurationUnit["MONTHS"] = "m";
2144
- })(SLADurationUnit || (SLADurationUnit = {}));
2145
-
2146
- /**
2147
- * Insights Types
2148
- * Shared types for Maestro insights analytics endpoints
2149
- */
2150
- /**
2151
- * Time bucketing granularity for insights time-series queries.
2152
- *
2153
- * Controls how data points are grouped on the time axis.
2154
- */
2155
- exports.TimeInterval = void 0;
2156
- (function (TimeInterval) {
2157
- /** Group data points by hour */
2158
- TimeInterval["Hour"] = "HOUR";
2159
- /** Group data points by day */
2160
- TimeInterval["Day"] = "DAY";
2161
- /** Group data points by week */
2162
- TimeInterval["Week"] = "WEEK";
2163
- })(exports.TimeInterval || (exports.TimeInterval = {}));
2164
- /**
2165
- * Final instance statuses returned by the instance status timeline endpoint.
2166
- *
2167
- * Only includes statuses where the instance has finished execution — Completed, Faulted, or Cancelled.
2168
- * Active statuses like Running or Paused are not included.
2169
- */
2170
- exports.InstanceFinalStatus = void 0;
2171
- (function (InstanceFinalStatus) {
2172
- /** Instance completed successfully */
2173
- InstanceFinalStatus["Completed"] = "Completed";
2174
- /** Instance encountered an error */
2175
- InstanceFinalStatus["Faulted"] = "Faulted";
2176
- /** Instance was cancelled */
2177
- InstanceFinalStatus["Cancelled"] = "Cancelled";
2178
- })(exports.InstanceFinalStatus || (exports.InstanceFinalStatus = {}));
2248
+ _BaseService_apiClient = new WeakMap();
2179
2249
 
2180
2250
  /**
2181
2251
  * Maps fields for Process Instance entities to ensure consistent naming
@@ -2252,7 +2322,7 @@ class ProcessInstancesService extends BaseService {
2252
2322
  }, options);
2253
2323
  }
2254
2324
  /**
2255
- * Get a process instance by ID with operation methods (cancel, pause, resume)
2325
+ * Get a process instance by ID with operation methods (cancel, pause, resume, retry)
2256
2326
  * @param id The ID of the instance to retrieve
2257
2327
  * @param folderKey The folder key for authorization
2258
2328
  * @returns Promise<ProcessInstanceGetResponse>
@@ -2391,6 +2461,25 @@ class ProcessInstancesService extends BaseService {
2391
2461
  data: response.data
2392
2462
  };
2393
2463
  }
2464
+ /**
2465
+ * Retry a faulted process instance
2466
+ *
2467
+ * Re-runs the failed elements of the instance (and the elements that follow) within
2468
+ * the same instance, spawning new jobs. Use to recover from transient/flaky failures.
2469
+ * @param instanceId The ID of the instance to retry
2470
+ * @param folderKey The folder key for authorization
2471
+ * @param options Optional retry options with comment
2472
+ * @returns Promise resolving to operation result with updated instance data
2473
+ */
2474
+ async retry(instanceId, folderKey, options) {
2475
+ const response = await this.post(MAESTRO_ENDPOINTS.INSTANCES.RETRY(instanceId), options || {}, {
2476
+ headers: createHeaders({ [FOLDER_KEY]: folderKey })
2477
+ });
2478
+ return {
2479
+ success: true,
2480
+ data: response.data
2481
+ };
2482
+ }
2394
2483
  /**
2395
2484
  * Parses BPMN XML to extract variable metadata from uipath:inputOutput elements
2396
2485
  * @private
@@ -2541,6 +2630,9 @@ __decorate([
2541
2630
  __decorate([
2542
2631
  track('ProcessInstances.Resume')
2543
2632
  ], ProcessInstancesService.prototype, "resume", null);
2633
+ __decorate([
2634
+ track('ProcessInstances.Retry')
2635
+ ], ProcessInstancesService.prototype, "retry", null);
2544
2636
  __decorate([
2545
2637
  track('ProcessInstances.GetVariables')
2546
2638
  ], ProcessInstancesService.prototype, "getVariables", null);
@@ -2697,7 +2789,7 @@ class MaestroProcessesService extends BaseService {
2697
2789
  *
2698
2790
  * @param startTime - Start of the time range to query
2699
2791
  * @param endTime - End of the time range to query
2700
- * @param options - Optional settings for time bucketing granularity
2792
+ * @param options - Optional settings for filtering and time bucket granularity
2701
2793
  * @returns Promise resolving to an array of {@link InstanceStatusTimelineResponse}
2702
2794
  *
2703
2795
  * @example
@@ -2724,12 +2816,67 @@ class MaestroProcessesService extends BaseService {
2724
2816
  *
2725
2817
  * @example
2726
2818
  * ```typescript
2819
+ * // Filter to a specific process
2820
+ * const filtered = await maestroProcesses.getInstanceStatusTimeline(startTime, endTime, {
2821
+ * processKeys: ['<processKey>'],
2822
+ * });
2823
+ * ```
2824
+ *
2825
+ * @example
2826
+ * ```typescript
2727
2827
  * // Get all-time data (from Unix epoch to now)
2728
2828
  * const allTime = await maestroProcesses.getInstanceStatusTimeline(new Date(0), new Date());
2729
2829
  * ```
2730
2830
  */
2731
2831
  async getInstanceStatusTimeline(startTime, endTime, options) {
2732
- return fetchInstanceStatusTimeline(this.post.bind(this), startTime, endTime, false, options);
2832
+ const { data } = await this.post(MAESTRO_ENDPOINTS.INSIGHTS.INSTANCE_STATUS_BY_DATE, buildInsightsTimelineBody(startTime, endTime, false, options));
2833
+ return data ?? [];
2834
+ }
2835
+ /**
2836
+ * Get incident counts aggregated by time bucket for maestro processes.
2837
+ *
2838
+ * Returns time-grouped counts of incidents that occurred within each bucket,
2839
+ * useful for rendering incident time-series charts. Use `groupBy` to control
2840
+ * the time bucket size (hour, day, or week) — defaults to day if not provided.
2841
+ *
2842
+ * @param startTime - Start of the time range to query
2843
+ * @param endTime - End of the time range to query
2844
+ * @param options - Optional settings for filtering and time bucket granularity
2845
+ * @returns Promise resolving to an array of {@link IncidentTimelineResponse}
2846
+ *
2847
+ * @example
2848
+ * ```typescript
2849
+ * // Get daily incident counts for the last 7 days
2850
+ * const now = new Date();
2851
+ * const sevenDaysAgo = new Date(Date.now() - 7 * 24 * 60 * 60 * 1000);
2852
+ * const incidents = await maestroProcesses.getIncidentsTimeline(sevenDaysAgo, now);
2853
+ *
2854
+ * for (const incident of incidents) {
2855
+ * console.log(`${incident.startTime} → ${incident.endTime}: ${incident.count} incidents`);
2856
+ * }
2857
+ * ```
2858
+ *
2859
+ * @example
2860
+ * ```typescript
2861
+ * import { TimeInterval } from '@uipath/uipath-typescript/maestro-processes';
2862
+ *
2863
+ * // Get weekly breakdown
2864
+ * const incidents = await maestroProcesses.getIncidentsTimeline(startTime, endTime, {
2865
+ * groupBy: TimeInterval.Week,
2866
+ * });
2867
+ * ```
2868
+ *
2869
+ * @example
2870
+ * ```typescript
2871
+ * // Filter to a specific process
2872
+ * const filtered = await maestroProcesses.getIncidentsTimeline(startTime, endTime, {
2873
+ * processKeys: ['<processKey>'],
2874
+ * });
2875
+ * ```
2876
+ */
2877
+ async getIncidentsTimeline(startTime, endTime, options) {
2878
+ const { data } = await this.post(MAESTRO_ENDPOINTS.INSIGHTS.INCIDENTS_BY_TIME_WINDOW, buildInsightsTimelineBody(startTime, endTime, false, options));
2879
+ return data?.dataPoints ?? [];
2733
2880
  }
2734
2881
  /**
2735
2882
  * Get the top 10 processes ranked by failure count within a time range.
@@ -2824,22 +2971,22 @@ class MaestroProcessesService extends BaseService {
2824
2971
  * Returns per-element execution counts (success, fail, terminated, paused, in-progress) and
2825
2972
  * duration percentile metrics (min, max, avg, p50, p95, p99) for BPMN elements within a process.
2826
2973
  *
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
2974
+ * @param request - Process scope + time range to aggregate over
2832
2975
  * @returns Promise resolving to an array of {@link ElementStats}
2833
2976
  * @example
2834
2977
  * ```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
- * );
2978
+ * // First, list processes to find the processKey, packageId, and available versions
2979
+ * const processes = await maestroProcesses.getAll();
2980
+ * const process = processes[0];
2981
+ *
2982
+ * // Get element metrics for that process
2983
+ * const elements = await maestroProcesses.getElementStats({
2984
+ * processKey: process.processKey,
2985
+ * packageId: process.packageId,
2986
+ * packageVersion: process.packageVersions[0],
2987
+ * startTime: new Date('2026-04-01'),
2988
+ * endTime: new Date(),
2989
+ * });
2843
2990
  *
2844
2991
  * // Analyze element performance
2845
2992
  * for (const element of elements) {
@@ -2847,12 +2994,58 @@ class MaestroProcessesService extends BaseService {
2847
2994
  * console.log(` Success: ${element.successCount}, Failed: ${element.failCount}`);
2848
2995
  * console.log(` Avg duration: ${element.avgDurationMs}ms, P95: ${element.p95DurationMs}ms`);
2849
2996
  * }
2997
+ *
2998
+ * // Using bound method on a process — auto-fills processKey and packageId
2999
+ * const boundElements = await process.getElementStats(
3000
+ * new Date('2026-04-01'),
3001
+ * new Date(),
3002
+ * process.packageVersions[0]
3003
+ * );
2850
3004
  * ```
2851
3005
  */
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));
3006
+ async getElementStats(request) {
3007
+ const { data } = await this.post(MAESTRO_ENDPOINTS.INSIGHTS.ELEMENT_COUNT_BY_STATUS, buildInsightsCommonBody(request));
2854
3008
  return data ?? [];
2855
3009
  }
3010
+ /**
3011
+ * Get instance stats for a process.
3012
+ *
3013
+ * Returns total instance counts broken down by status (running, completed, faulted, etc.)
3014
+ * and the average execution duration for all instances of a process within a time range.
3015
+ *
3016
+ * @param request - Process scope + time range to aggregate over
3017
+ * @returns Promise resolving to {@link InstanceStats}
3018
+ * @example
3019
+ * ```typescript
3020
+ * // First, list processes to find the processKey, packageId, and available versions
3021
+ * const processes = await maestroProcesses.getAll();
3022
+ * const process = processes[0];
3023
+ *
3024
+ * // Get instance status breakdown for that process
3025
+ * const counts = await maestroProcesses.getInstanceStats({
3026
+ * processKey: process.processKey,
3027
+ * packageId: process.packageId,
3028
+ * packageVersion: process.packageVersions[0],
3029
+ * startTime: new Date('2026-04-01'),
3030
+ * endTime: new Date(),
3031
+ * });
3032
+ *
3033
+ * console.log(`Total: ${counts.totalCount}`);
3034
+ * console.log(`Running: ${counts.runningCount}, Completed: ${counts.completedCount}`);
3035
+ * console.log(`Faulted: ${counts.faultedCount}, Avg duration: ${counts.avgDurationMs}ms`);
3036
+ *
3037
+ * // Using bound method on a process — auto-fills processKey and packageId
3038
+ * const boundCounts = await process.getInstanceStats(
3039
+ * new Date('2026-04-01'),
3040
+ * new Date(),
3041
+ * process.packageVersions[0]
3042
+ * );
3043
+ * ```
3044
+ */
3045
+ async getInstanceStats(request) {
3046
+ const { data } = await this.post(MAESTRO_ENDPOINTS.INSIGHTS.INSTANCE_COUNT_BY_STATUS, buildInsightsCommonBody(request));
3047
+ return transformData(data, InstanceStatsMap);
3048
+ }
2856
3049
  }
2857
3050
  __decorate([
2858
3051
  track('MaestroProcesses.GetAll')
@@ -2869,6 +3062,9 @@ __decorate([
2869
3062
  __decorate([
2870
3063
  track('MaestroProcesses.GetInstanceStatusTimeline')
2871
3064
  ], MaestroProcessesService.prototype, "getInstanceStatusTimeline", null);
3065
+ __decorate([
3066
+ track('MaestroProcesses.GetIncidentsTimeline')
3067
+ ], MaestroProcessesService.prototype, "getIncidentsTimeline", null);
2872
3068
  __decorate([
2873
3069
  track('MaestroProcesses.GetTopFaultedCount')
2874
3070
  ], MaestroProcessesService.prototype, "getTopFaultedCount", null);
@@ -2878,6 +3074,9 @@ __decorate([
2878
3074
  __decorate([
2879
3075
  track('MaestroProcesses.GetElementStats')
2880
3076
  ], MaestroProcessesService.prototype, "getElementStats", null);
3077
+ __decorate([
3078
+ track('MaestroProcesses.GetInstanceStats')
3079
+ ], MaestroProcessesService.prototype, "getInstanceStats", null);
2881
3080
 
2882
3081
  /**
2883
3082
  * Service class for Maestro Process Incidents