@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
@@ -42,6 +42,108 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
42
42
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
43
43
  };
44
44
 
45
+ /**
46
+ * Maps API field names (countOf*) to SDK field names (*Count) for InstanceStats,
47
+ * aligning naming with ElementStats and other count-suffixed conventions.
48
+ */
49
+ const InstanceStatsMap = {
50
+ countOfAllInstances: 'totalCount',
51
+ countOfRunning: 'runningCount',
52
+ countOfTransitioning: 'transitioningCount',
53
+ countOfPaused: 'pausedCount',
54
+ countOfFaulted: 'faultedCount',
55
+ countOfCompleted: 'completedCount',
56
+ countOfCancelled: 'cancelledCount',
57
+ countOfDeleted: 'deletedCount'
58
+ };
59
+
60
+ /**
61
+ * Converts a UTC timestamp string (e.g., "5/8/2026 11:20:17 AM") to ISO 8601 UTC format.
62
+ * Returns the original value if parsing fails.
63
+ */
64
+ /**
65
+ * Transforms data by renaming each key in `data` exactly once, using the
66
+ * mapping (`sourceField → targetField`). Keys not present in the mapping
67
+ * pass through unchanged. The original (pre-rename) key is dropped — the
68
+ * result contains only the renamed key.
69
+ *
70
+ * Each rename is independent. If the mapping happens to contain chained
71
+ * entries (`a → b` and `b → c`), they do NOT compose: a field named `a`
72
+ * in `data` becomes `b` (not `c`), because the renames are applied based
73
+ * on the original data's keys, not the running result.
74
+ *
75
+ * @param data The source data to transform
76
+ * @param fieldMapping Object mapping source field names to target field names
77
+ * @returns Transformed data with mapped field names
78
+ *
79
+ * @example
80
+ * ```typescript
81
+ * // Single object transformation
82
+ * const data = { id: '123', userName: 'john' };
83
+ * const mapping = { id: 'userId', userName: 'name' };
84
+ * const result = transformData(data, mapping);
85
+ * // result = { userId: '123', name: 'john' }
86
+ *
87
+ * // Array transformation
88
+ * const dataArray = [
89
+ * { id: '123', userName: 'john' },
90
+ * { id: '456', userName: 'jane' }
91
+ * ];
92
+ * const result = transformData(dataArray, mapping);
93
+ * // result = [
94
+ * // { userId: '123', name: 'john' },
95
+ * // { userId: '456', name: 'jane' }
96
+ * // ]
97
+ *
98
+ * // No chaining — `a → b` does not become `a → c` even if the map has `b → c`.
99
+ * transformData({ a: 1 }, { a: 'b', b: 'c' });
100
+ * // result = { b: 1 }
101
+ * ```
102
+ */
103
+ function transformData(data, fieldMapping) {
104
+ // Pass null/undefined through unchanged — callers (e.g. AttachmentService.getById)
105
+ // may invoke this on optional fields that an OData `select` excluded.
106
+ if (data == null) {
107
+ return data;
108
+ }
109
+ // Handle array of objects
110
+ if (Array.isArray(data)) {
111
+ return data.map(item => transformData(item, fieldMapping));
112
+ }
113
+ // Walk the ORIGINAL data's keys, look up each in the mapping. One rename
114
+ // per data key — no mutation of an in-progress result, so chains can't form.
115
+ const result = {};
116
+ for (const [key, value] of Object.entries(data)) {
117
+ const renamedKey = fieldMapping[key] ?? key;
118
+ result[renamedKey] = value;
119
+ }
120
+ return result;
121
+ }
122
+ /**
123
+ * Adds a prefix to specified keys in an object, returning a new object.
124
+ * Only the provided keys are prefixed; all others are left unchanged.
125
+ *
126
+ * @param obj The source object
127
+ * @param prefix The prefix to add (e.g., '$')
128
+ * @param keys The keys to prefix (e.g., ['expand', 'filter'])
129
+ * @returns A new object with specified keys prefixed
130
+ *
131
+ * @example
132
+ * addPrefixToKeys({ expand: 'a', foo: 1 }, '$', ['expand']) // { $expand: 'a', foo: 1 }
133
+ */
134
+ function addPrefixToKeys(obj, prefix, keys) {
135
+ const result = {};
136
+ for (const [key, value] of Object.entries(obj)) {
137
+ if (keys.includes(key)) {
138
+ result[`${prefix}${key}`] = value;
139
+ }
140
+ else {
141
+ result[key] = value;
142
+ }
143
+ }
144
+ return result;
145
+ }
146
+
45
147
  /**
46
148
  * Base path constants for different services
47
149
  */
@@ -67,6 +169,7 @@ const MAESTRO_ENDPOINTS = {
67
169
  CANCEL: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/cancel`,
68
170
  PAUSE: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/pause`,
69
171
  RESUME: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/resume`,
172
+ RETRY: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/retry`,
70
173
  },
71
174
  INCIDENTS: {
72
175
  GET_ALL: `${PIMS_BASE}/api/v1/incidents/summary`,
@@ -87,8 +190,12 @@ const MAESTRO_ENDPOINTS = {
87
190
  INSTANCE_STATUS_BY_DATE: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/InstanceStatusByDate`,
88
191
  /** Top processes ranked by total duration */
89
192
  TOP_PROCESSES_BY_DURATION: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/TopProcessesByDuration`,
193
+ /** Instance stats (counts by status + duration percentiles) */
194
+ INSTANCE_COUNT_BY_STATUS: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/InstanceCountByStatus`,
90
195
  /** Element count by status for agentic instances (process and case) */
91
196
  ELEMENT_COUNT_BY_STATUS: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/ElementCountByStatus`,
197
+ /** Incident counts aggregated by time bucket for time-series charts */
198
+ INCIDENTS_BY_TIME_WINDOW: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/IncidentsByTimeWindow`,
92
199
  },
93
200
  };
94
201
 
@@ -117,7 +224,36 @@ function createProcessMethods(processData, service) {
117
224
  throw new Error('Process key is undefined');
118
225
  if (!processData.packageId)
119
226
  throw new Error('Package ID is undefined');
120
- return service.getElementStats(processData.processKey, processData.packageId, startTime, endTime, packageVersion);
227
+ return service.getElementStats({
228
+ processKey: processData.processKey,
229
+ packageId: processData.packageId,
230
+ packageVersion,
231
+ startTime,
232
+ endTime,
233
+ });
234
+ },
235
+ getInstanceStats(startTime, endTime, packageVersion) {
236
+ if (!processData.processKey)
237
+ throw new Error('Process key is undefined');
238
+ if (!processData.packageId)
239
+ throw new Error('Package ID is undefined');
240
+ return service.getInstanceStats({
241
+ processKey: processData.processKey,
242
+ packageId: processData.packageId,
243
+ packageVersion,
244
+ startTime,
245
+ endTime,
246
+ });
247
+ },
248
+ getInstanceStatusTimeline(startTime, endTime, options) {
249
+ if (!processData.processKey)
250
+ throw new Error('Process key is undefined');
251
+ return service.getInstanceStatusTimeline(startTime, endTime, { ...options, processKeys: [processData.processKey] });
252
+ },
253
+ getIncidentsTimeline(startTime, endTime, options) {
254
+ if (!processData.processKey)
255
+ throw new Error('Process key is undefined');
256
+ return service.getIncidentsTimeline(startTime, endTime, { ...options, processKeys: [processData.processKey] });
121
257
  }
122
258
  };
123
259
  }
@@ -133,6 +269,242 @@ function createProcessWithMethods(processData, service) {
133
269
  return Object.assign({}, processData, methods);
134
270
  }
135
271
 
272
+ /**
273
+ * Creates methods for a process instance
274
+ *
275
+ * @param instanceData - The process instance data (response from API)
276
+ * @param service - The process instance service instance
277
+ * @returns Object containing process instance methods
278
+ */
279
+ function createProcessInstanceMethods(instanceData, service) {
280
+ return {
281
+ async cancel(options) {
282
+ if (!instanceData.instanceId)
283
+ throw new Error('Process instance ID is undefined');
284
+ if (!instanceData.folderKey)
285
+ throw new Error('Process instance folder key is undefined');
286
+ return service.cancel(instanceData.instanceId, instanceData.folderKey, options);
287
+ },
288
+ async pause(options) {
289
+ if (!instanceData.instanceId)
290
+ throw new Error('Process instance ID is undefined');
291
+ if (!instanceData.folderKey)
292
+ throw new Error('Process instance folder key is undefined');
293
+ return service.pause(instanceData.instanceId, instanceData.folderKey, options);
294
+ },
295
+ async resume(options) {
296
+ if (!instanceData.instanceId)
297
+ throw new Error('Process instance ID is undefined');
298
+ if (!instanceData.folderKey)
299
+ throw new Error('Process instance folder key is undefined');
300
+ return service.resume(instanceData.instanceId, instanceData.folderKey, options);
301
+ },
302
+ async retry(options) {
303
+ if (!instanceData.instanceId)
304
+ throw new Error('Process instance ID is undefined');
305
+ if (!instanceData.folderKey)
306
+ throw new Error('Process instance folder key is undefined');
307
+ return service.retry(instanceData.instanceId, instanceData.folderKey, options);
308
+ },
309
+ async getIncidents() {
310
+ if (!instanceData.instanceId)
311
+ throw new Error('Process instance ID is undefined');
312
+ if (!instanceData.folderKey)
313
+ throw new Error('Process instance folder key is undefined');
314
+ return service.getIncidents(instanceData.instanceId, instanceData.folderKey);
315
+ },
316
+ async getExecutionHistory() {
317
+ if (!instanceData.instanceId)
318
+ throw new Error('Process instance ID is undefined');
319
+ if (!instanceData.folderKey)
320
+ throw new Error('Process instance folder key is undefined');
321
+ return service.getExecutionHistory(instanceData.instanceId, instanceData.folderKey);
322
+ },
323
+ async getBpmn() {
324
+ if (!instanceData.instanceId)
325
+ throw new Error('Process instance ID is undefined');
326
+ if (!instanceData.folderKey)
327
+ throw new Error('Process instance folder key is undefined');
328
+ return service.getBpmn(instanceData.instanceId, instanceData.folderKey);
329
+ },
330
+ async getVariables(options) {
331
+ if (!instanceData.instanceId)
332
+ throw new Error('Process instance ID is undefined');
333
+ if (!instanceData.folderKey)
334
+ throw new Error('Process instance folder key is undefined');
335
+ return service.getVariables(instanceData.instanceId, instanceData.folderKey, options);
336
+ }
337
+ };
338
+ }
339
+ /**
340
+ * Creates an actionable process instance by combining API process instance data with operational methods.
341
+ *
342
+ * @param instanceData - The process instance data from API
343
+ * @param service - The process instance service instance
344
+ * @returns A process instance object with added methods
345
+ */
346
+ function createProcessInstanceWithMethods(instanceData, service) {
347
+ const methods = createProcessInstanceMethods(instanceData, service);
348
+ return Object.assign({}, instanceData, methods);
349
+ }
350
+
351
+ /**
352
+ * Process Incident Status
353
+ */
354
+ var ProcessIncidentStatus;
355
+ (function (ProcessIncidentStatus) {
356
+ ProcessIncidentStatus["Open"] = "Open";
357
+ ProcessIncidentStatus["Closed"] = "Closed";
358
+ })(ProcessIncidentStatus || (ProcessIncidentStatus = {}));
359
+ /**
360
+ * Process Incident Type
361
+ */
362
+ var ProcessIncidentType;
363
+ (function (ProcessIncidentType) {
364
+ ProcessIncidentType["System"] = "System";
365
+ ProcessIncidentType["User"] = "User";
366
+ ProcessIncidentType["Deployment"] = "Deployment";
367
+ })(ProcessIncidentType || (ProcessIncidentType = {}));
368
+ /**
369
+ * Process Incident Severity
370
+ */
371
+ var ProcessIncidentSeverity;
372
+ (function (ProcessIncidentSeverity) {
373
+ ProcessIncidentSeverity["Error"] = "Error";
374
+ ProcessIncidentSeverity["Warning"] = "Warning";
375
+ })(ProcessIncidentSeverity || (ProcessIncidentSeverity = {}));
376
+ /**
377
+ * Process Incident Debug Mode
378
+ */
379
+ var DebugMode;
380
+ (function (DebugMode) {
381
+ DebugMode["None"] = "None";
382
+ DebugMode["Default"] = "Default";
383
+ DebugMode["StepByStep"] = "StepByStep";
384
+ DebugMode["SingleStep"] = "SingleStep";
385
+ })(DebugMode || (DebugMode = {}));
386
+
387
+ /**
388
+ * Case Instance Types
389
+ * Types and interfaces for Maestro case instance management
390
+ */
391
+ /**
392
+ * SLA status for a case instance
393
+ */
394
+ var SlaSummaryStatus;
395
+ (function (SlaSummaryStatus) {
396
+ /** Case is within SLA deadline */
397
+ SlaSummaryStatus["ON_TRACK"] = "On Track";
398
+ /** Case is approaching SLA deadline based on at-risk percentage threshold */
399
+ SlaSummaryStatus["AT_RISK"] = "At Risk";
400
+ /** Case has exceeded SLA deadline */
401
+ SlaSummaryStatus["OVERDUE"] = "Overdue";
402
+ /** Case instance has completed */
403
+ SlaSummaryStatus["COMPLETED"] = "Completed";
404
+ /** SLA status cannot be determined (no SLA deadline defined) */
405
+ SlaSummaryStatus["UNKNOWN"] = "Unknown";
406
+ })(SlaSummaryStatus || (SlaSummaryStatus = {}));
407
+ /**
408
+ * Instance status values for case instances and process instances
409
+ */
410
+ var InstanceStatus;
411
+ (function (InstanceStatus) {
412
+ /** Instance status not yet populated by the backend */
413
+ InstanceStatus["UNKNOWN"] = "";
414
+ InstanceStatus["CANCELLED"] = "Cancelled";
415
+ InstanceStatus["CANCELING"] = "Canceling";
416
+ InstanceStatus["COMPLETED"] = "Completed";
417
+ InstanceStatus["FAULTED"] = "Faulted";
418
+ InstanceStatus["PAUSED"] = "Paused";
419
+ InstanceStatus["PAUSING"] = "Pausing";
420
+ InstanceStatus["PENDING"] = "Pending";
421
+ InstanceStatus["RESUMING"] = "Resuming";
422
+ InstanceStatus["RETRYING"] = "Retrying";
423
+ InstanceStatus["RUNNING"] = "Running";
424
+ InstanceStatus["UPGRADING"] = "Upgrading";
425
+ })(InstanceStatus || (InstanceStatus = {}));
426
+ /**
427
+ * Case stage task type
428
+ */
429
+ var StageTaskType;
430
+ (function (StageTaskType) {
431
+ StageTaskType["EXTERNAL_AGENT"] = "external-agent";
432
+ StageTaskType["RPA"] = "rpa";
433
+ StageTaskType["AGENTIC_PROCESS"] = "process";
434
+ StageTaskType["AGENT"] = "agent";
435
+ StageTaskType["ACTION"] = "action";
436
+ StageTaskType["API_WORKFLOW"] = "api-workflow";
437
+ })(StageTaskType || (StageTaskType = {}));
438
+ /**
439
+ * Escalation recipient scope
440
+ */
441
+ var EscalationRecipientScope;
442
+ (function (EscalationRecipientScope) {
443
+ EscalationRecipientScope["USER"] = "user";
444
+ EscalationRecipientScope["USER_GROUP"] = "usergroup";
445
+ })(EscalationRecipientScope || (EscalationRecipientScope = {}));
446
+ /**
447
+ * Escalation action type
448
+ */
449
+ var EscalationActionType;
450
+ (function (EscalationActionType) {
451
+ EscalationActionType["NOTIFICATION"] = "notification";
452
+ })(EscalationActionType || (EscalationActionType = {}));
453
+ /**
454
+ * Escalation rule trigger type
455
+ */
456
+ var EscalationTriggerType;
457
+ (function (EscalationTriggerType) {
458
+ EscalationTriggerType["SLA_BREACHED"] = "sla-breached";
459
+ EscalationTriggerType["AT_RISK"] = "at-risk";
460
+ /** Default value when no escalation rule is defined */
461
+ EscalationTriggerType["NONE"] = "None";
462
+ })(EscalationTriggerType || (EscalationTriggerType = {}));
463
+ /**
464
+ * SLA duration unit
465
+ */
466
+ var SLADurationUnit;
467
+ (function (SLADurationUnit) {
468
+ SLADurationUnit["HOURS"] = "h";
469
+ SLADurationUnit["DAYS"] = "d";
470
+ SLADurationUnit["WEEKS"] = "w";
471
+ SLADurationUnit["MONTHS"] = "m";
472
+ })(SLADurationUnit || (SLADurationUnit = {}));
473
+
474
+ /**
475
+ * Insights Types
476
+ * Shared types for Maestro insights analytics endpoints
477
+ */
478
+ /**
479
+ * Time bucketing granularity for insights time-series queries.
480
+ *
481
+ * Controls how data points are grouped on the time axis.
482
+ */
483
+ var TimeInterval;
484
+ (function (TimeInterval) {
485
+ /** Group data points by hour */
486
+ TimeInterval["Hour"] = "HOUR";
487
+ /** Group data points by day */
488
+ TimeInterval["Day"] = "DAY";
489
+ /** Group data points by week */
490
+ TimeInterval["Week"] = "WEEK";
491
+ })(TimeInterval || (TimeInterval = {}));
492
+ /**
493
+ * Final instance statuses returned by the instance status timeline endpoint.
494
+ *
495
+ * Only includes statuses where the instance has finished execution — Completed, Faulted, or Cancelled.
496
+ * Active statuses like Running or Paused are not included.
497
+ */
498
+ var InstanceFinalStatus;
499
+ (function (InstanceFinalStatus) {
500
+ /** Instance completed successfully */
501
+ InstanceFinalStatus["Completed"] = "Completed";
502
+ /** Instance encountered an error */
503
+ InstanceFinalStatus["Faulted"] = "Faulted";
504
+ /** Instance was cancelled */
505
+ InstanceFinalStatus["Cancelled"] = "Cancelled";
506
+ })(InstanceFinalStatus || (InstanceFinalStatus = {}));
507
+
136
508
  /**
137
509
  * Builds the request body for Insights RTM "top" endpoints.
138
510
  *
@@ -156,48 +528,46 @@ function buildInsightsTopBody(startTime, endTime, isCaseManagement, options) {
156
528
  };
157
529
  }
158
530
  /**
159
- * Fetches instance status timeline from the Insights API.
160
- * Shared implementation used by both MaestroProcessesService and CasesService.
531
+ * Builds the request body for Insights RTM timeline endpoints
532
+ * (`InstanceStatusByDate`, `IncidentsByTimeWindow`).
161
533
  *
162
- * @param postFn - Bound post method from a BaseService subclass
163
534
  * @param startTime - Start of the time range to query
164
535
  * @param endTime - End of the time range to query
165
536
  * @param isCaseManagement - Whether to filter for case management processes
166
- * @param options - Optional settings for time bucketing granularity
167
- * @returns Promise resolving to an array of instance status timeline entries
537
+ * @param options - Optional time bucketing and filtering settings
538
+ * @returns Request body for the Insights RTM timeline endpoint
168
539
  * @internal
169
540
  */
170
- async function fetchInstanceStatusTimeline(postFn, startTime, endTime, isCaseManagement, options) {
171
- const response = await postFn(MAESTRO_ENDPOINTS.INSIGHTS.INSTANCE_STATUS_BY_DATE, {
541
+ function buildInsightsTimelineBody(startTime, endTime, isCaseManagement, options) {
542
+ return {
172
543
  commonParams: {
173
544
  startTime: startTime.getTime(),
174
545
  endTime: endTime.getTime(),
175
546
  isCaseManagement,
547
+ ...(options?.packageId ? { packageId: options.packageId } : {}),
548
+ ...(options?.version ? { version: options.version } : {}),
549
+ ...(options?.processKeys ? { processKeys: options.processKeys } : {}),
176
550
  },
177
- timeSliceUnit: options?.groupBy,
551
+ timeSliceUnit: options?.groupBy ?? TimeInterval.Day,
178
552
  timezoneOffset: new Date().getTimezoneOffset() * -1,
179
- });
180
- return response.data ?? [];
553
+ };
181
554
  }
182
555
  /**
183
- * Builds the request body for the ElementCountByStatus endpoint.
556
+ * Builds the commonParams request body for Insights RTM endpoints
557
+ * that filter by process key, package, time range, and version.
184
558
  *
185
- * @param processKey - Process key to filter by
186
- * @param packageId - Package identifier
187
- * @param startTime - Start of the time range to query
188
- * @param endTime - End of the time range to query
189
- * @param packageVersion - Package version to filter by
190
- * @returns Request body for the ElementCountByStatus endpoint
559
+ * @param request - Process scope + time range to aggregate over
560
+ * @returns Request body with commonParams
191
561
  * @internal
192
562
  */
193
- function buildElementCountByStatusBody(processKey, packageId, startTime, endTime, packageVersion) {
563
+ function buildInsightsCommonBody(request) {
194
564
  return {
195
565
  commonParams: {
196
- processKey,
197
- packageId,
198
- startTime: startTime.getTime(),
199
- endTime: endTime.getTime(),
200
- version: packageVersion
566
+ processKey: request.processKey,
567
+ packageId: request.packageId,
568
+ startTime: request.startTime.getTime(),
569
+ endTime: request.endTime.getTime(),
570
+ version: request.packageVersion
201
571
  }
202
572
  };
203
573
  }
@@ -256,77 +626,6 @@ const PROCESS_INSTANCE_TOKEN_PARAMS = {
256
626
  TOKEN_PARAM: 'nextPage'
257
627
  };
258
628
 
259
- /**
260
- * Converts a UTC timestamp string (e.g., "5/8/2026 11:20:17 AM") to ISO 8601 UTC format.
261
- * Returns the original value if parsing fails.
262
- */
263
- /**
264
- * Transforms data by mapping fields according to the provided field mapping
265
- * @param data The source data to transform
266
- * @param fieldMapping Object mapping source field names to target field names
267
- * @returns Transformed data with mapped field names
268
- *
269
- * @example
270
- * ```typescript
271
- * // Single object transformation
272
- * const data = { id: '123', userName: 'john' };
273
- * const mapping = { id: 'userId', userName: 'name' };
274
- * const result = transformData(data, mapping);
275
- * // result = { userId: '123', name: 'john' }
276
- *
277
- * // Array transformation
278
- * const dataArray = [
279
- * { id: '123', userName: 'john' },
280
- * { id: '456', userName: 'jane' }
281
- * ];
282
- * const result = transformData(dataArray, mapping);
283
- * // result = [
284
- * // { userId: '123', name: 'john' },
285
- * // { userId: '456', name: 'jane' }
286
- * // ]
287
- * ```
288
- */
289
- function transformData(data, fieldMapping) {
290
- // Handle array of objects
291
- if (Array.isArray(data)) {
292
- return data.map(item => transformData(item, fieldMapping));
293
- }
294
- // Handle single object
295
- const result = { ...data };
296
- for (const [sourceField, targetField] of Object.entries(fieldMapping)) {
297
- if (sourceField in result) {
298
- const value = result[sourceField];
299
- delete result[sourceField];
300
- result[targetField] = value;
301
- }
302
- }
303
- return result;
304
- }
305
- /**
306
- * Adds a prefix to specified keys in an object, returning a new object.
307
- * Only the provided keys are prefixed; all others are left unchanged.
308
- *
309
- * @param obj The source object
310
- * @param prefix The prefix to add (e.g., '$')
311
- * @param keys The keys to prefix (e.g., ['expand', 'filter'])
312
- * @returns A new object with specified keys prefixed
313
- *
314
- * @example
315
- * addPrefixToKeys({ expand: 'a', foo: 1 }, '$', ['expand']) // { $expand: 'a', foo: 1 }
316
- */
317
- function addPrefixToKeys(obj, prefix, keys) {
318
- const result = {};
319
- for (const [key, value] of Object.entries(obj)) {
320
- if (keys.includes(key)) {
321
- result[`${prefix}${key}`] = value;
322
- }
323
- else {
324
- result[key] = value;
325
- }
326
- }
327
- return result;
328
- }
329
-
330
629
  /**
331
630
  * Maps fields for Incident entities
332
631
  */
@@ -1931,249 +2230,20 @@ class BaseService {
1931
2230
  case PaginationType.OFFSET:
1932
2231
  const effectivePageSize = info.pageSize ?? DEFAULT_PAGE_SIZE;
1933
2232
  // If totalCount is available, use it for precise calculation
1934
- if (info.totalCount !== undefined) {
1935
- return (info.currentPage * effectivePageSize) < info.totalCount;
1936
- }
1937
- // Fallback when totalCount is not available
1938
- // NOTE: This code path should rarely be executed as the APIs typically return totalCount
1939
- return info.itemsCount === effectivePageSize;
1940
- case PaginationType.TOKEN:
1941
- return !!info.continuationToken;
1942
- default:
1943
- return false;
1944
- }
1945
- }
1946
- }
1947
- _BaseService_apiClient = new WeakMap();
1948
-
1949
- /**
1950
- * Creates methods for a process instance
1951
- *
1952
- * @param instanceData - The process instance data (response from API)
1953
- * @param service - The process instance service instance
1954
- * @returns Object containing process instance methods
1955
- */
1956
- function createProcessInstanceMethods(instanceData, service) {
1957
- return {
1958
- async cancel(options) {
1959
- if (!instanceData.instanceId)
1960
- throw new Error('Process instance ID is undefined');
1961
- if (!instanceData.folderKey)
1962
- throw new Error('Process instance folder key is undefined');
1963
- return service.cancel(instanceData.instanceId, instanceData.folderKey, options);
1964
- },
1965
- async pause(options) {
1966
- if (!instanceData.instanceId)
1967
- throw new Error('Process instance ID is undefined');
1968
- if (!instanceData.folderKey)
1969
- throw new Error('Process instance folder key is undefined');
1970
- return service.pause(instanceData.instanceId, instanceData.folderKey, options);
1971
- },
1972
- async resume(options) {
1973
- if (!instanceData.instanceId)
1974
- throw new Error('Process instance ID is undefined');
1975
- if (!instanceData.folderKey)
1976
- throw new Error('Process instance folder key is undefined');
1977
- return service.resume(instanceData.instanceId, instanceData.folderKey, options);
1978
- },
1979
- async getIncidents() {
1980
- if (!instanceData.instanceId)
1981
- throw new Error('Process instance ID is undefined');
1982
- if (!instanceData.folderKey)
1983
- throw new Error('Process instance folder key is undefined');
1984
- return service.getIncidents(instanceData.instanceId, instanceData.folderKey);
1985
- },
1986
- async getExecutionHistory() {
1987
- if (!instanceData.instanceId)
1988
- throw new Error('Process instance ID is undefined');
1989
- if (!instanceData.folderKey)
1990
- throw new Error('Process instance folder key is undefined');
1991
- return service.getExecutionHistory(instanceData.instanceId, instanceData.folderKey);
1992
- },
1993
- async getBpmn() {
1994
- if (!instanceData.instanceId)
1995
- throw new Error('Process instance ID is undefined');
1996
- if (!instanceData.folderKey)
1997
- throw new Error('Process instance folder key is undefined');
1998
- return service.getBpmn(instanceData.instanceId, instanceData.folderKey);
1999
- },
2000
- async getVariables(options) {
2001
- if (!instanceData.instanceId)
2002
- throw new Error('Process instance ID is undefined');
2003
- if (!instanceData.folderKey)
2004
- throw new Error('Process instance folder key is undefined');
2005
- return service.getVariables(instanceData.instanceId, instanceData.folderKey, options);
2233
+ if (info.totalCount !== undefined) {
2234
+ return (info.currentPage * effectivePageSize) < info.totalCount;
2235
+ }
2236
+ // Fallback when totalCount is not available
2237
+ // NOTE: This code path should rarely be executed as the APIs typically return totalCount
2238
+ return info.itemsCount === effectivePageSize;
2239
+ case PaginationType.TOKEN:
2240
+ return !!info.continuationToken;
2241
+ default:
2242
+ return false;
2006
2243
  }
2007
- };
2008
- }
2009
- /**
2010
- * Creates an actionable process instance by combining API process instance data with operational methods.
2011
- *
2012
- * @param instanceData - The process instance data from API
2013
- * @param service - The process instance service instance
2014
- * @returns A process instance object with added methods
2015
- */
2016
- function createProcessInstanceWithMethods(instanceData, service) {
2017
- const methods = createProcessInstanceMethods(instanceData, service);
2018
- return Object.assign({}, instanceData, methods);
2244
+ }
2019
2245
  }
2020
-
2021
- /**
2022
- * Process Incident Status
2023
- */
2024
- var ProcessIncidentStatus;
2025
- (function (ProcessIncidentStatus) {
2026
- ProcessIncidentStatus["Open"] = "Open";
2027
- ProcessIncidentStatus["Closed"] = "Closed";
2028
- })(ProcessIncidentStatus || (ProcessIncidentStatus = {}));
2029
- /**
2030
- * Process Incident Type
2031
- */
2032
- var ProcessIncidentType;
2033
- (function (ProcessIncidentType) {
2034
- ProcessIncidentType["System"] = "System";
2035
- ProcessIncidentType["User"] = "User";
2036
- ProcessIncidentType["Deployment"] = "Deployment";
2037
- })(ProcessIncidentType || (ProcessIncidentType = {}));
2038
- /**
2039
- * Process Incident Severity
2040
- */
2041
- var ProcessIncidentSeverity;
2042
- (function (ProcessIncidentSeverity) {
2043
- ProcessIncidentSeverity["Error"] = "Error";
2044
- ProcessIncidentSeverity["Warning"] = "Warning";
2045
- })(ProcessIncidentSeverity || (ProcessIncidentSeverity = {}));
2046
- /**
2047
- * Process Incident Debug Mode
2048
- */
2049
- var DebugMode;
2050
- (function (DebugMode) {
2051
- DebugMode["None"] = "None";
2052
- DebugMode["Default"] = "Default";
2053
- DebugMode["StepByStep"] = "StepByStep";
2054
- DebugMode["SingleStep"] = "SingleStep";
2055
- })(DebugMode || (DebugMode = {}));
2056
-
2057
- /**
2058
- * Case Instance Types
2059
- * Types and interfaces for Maestro case instance management
2060
- */
2061
- /**
2062
- * SLA status for a case instance
2063
- */
2064
- var SlaSummaryStatus;
2065
- (function (SlaSummaryStatus) {
2066
- /** Case is within SLA deadline */
2067
- SlaSummaryStatus["ON_TRACK"] = "On Track";
2068
- /** Case is approaching SLA deadline based on at-risk percentage threshold */
2069
- SlaSummaryStatus["AT_RISK"] = "At Risk";
2070
- /** Case has exceeded SLA deadline */
2071
- SlaSummaryStatus["OVERDUE"] = "Overdue";
2072
- /** Case instance has completed */
2073
- SlaSummaryStatus["COMPLETED"] = "Completed";
2074
- /** SLA status cannot be determined (no SLA deadline defined) */
2075
- SlaSummaryStatus["UNKNOWN"] = "Unknown";
2076
- })(SlaSummaryStatus || (SlaSummaryStatus = {}));
2077
- /**
2078
- * Instance status values for case instances and process instances
2079
- */
2080
- var InstanceStatus;
2081
- (function (InstanceStatus) {
2082
- /** Instance status not yet populated by the backend */
2083
- InstanceStatus["UNKNOWN"] = "";
2084
- InstanceStatus["CANCELLED"] = "Cancelled";
2085
- InstanceStatus["CANCELING"] = "Canceling";
2086
- InstanceStatus["COMPLETED"] = "Completed";
2087
- InstanceStatus["FAULTED"] = "Faulted";
2088
- InstanceStatus["PAUSED"] = "Paused";
2089
- InstanceStatus["PAUSING"] = "Pausing";
2090
- InstanceStatus["PENDING"] = "Pending";
2091
- InstanceStatus["RESUMING"] = "Resuming";
2092
- InstanceStatus["RETRYING"] = "Retrying";
2093
- InstanceStatus["RUNNING"] = "Running";
2094
- InstanceStatus["UPGRADING"] = "Upgrading";
2095
- })(InstanceStatus || (InstanceStatus = {}));
2096
- /**
2097
- * Case stage task type
2098
- */
2099
- var StageTaskType;
2100
- (function (StageTaskType) {
2101
- StageTaskType["EXTERNAL_AGENT"] = "external-agent";
2102
- StageTaskType["RPA"] = "rpa";
2103
- StageTaskType["AGENTIC_PROCESS"] = "process";
2104
- StageTaskType["AGENT"] = "agent";
2105
- StageTaskType["ACTION"] = "action";
2106
- StageTaskType["API_WORKFLOW"] = "api-workflow";
2107
- })(StageTaskType || (StageTaskType = {}));
2108
- /**
2109
- * Escalation recipient scope
2110
- */
2111
- var EscalationRecipientScope;
2112
- (function (EscalationRecipientScope) {
2113
- EscalationRecipientScope["USER"] = "user";
2114
- EscalationRecipientScope["USER_GROUP"] = "usergroup";
2115
- })(EscalationRecipientScope || (EscalationRecipientScope = {}));
2116
- /**
2117
- * Escalation action type
2118
- */
2119
- var EscalationActionType;
2120
- (function (EscalationActionType) {
2121
- EscalationActionType["NOTIFICATION"] = "notification";
2122
- })(EscalationActionType || (EscalationActionType = {}));
2123
- /**
2124
- * Escalation rule trigger type
2125
- */
2126
- var EscalationTriggerType;
2127
- (function (EscalationTriggerType) {
2128
- EscalationTriggerType["SLA_BREACHED"] = "sla-breached";
2129
- EscalationTriggerType["AT_RISK"] = "at-risk";
2130
- /** Default value when no escalation rule is defined */
2131
- EscalationTriggerType["NONE"] = "None";
2132
- })(EscalationTriggerType || (EscalationTriggerType = {}));
2133
- /**
2134
- * SLA duration unit
2135
- */
2136
- var SLADurationUnit;
2137
- (function (SLADurationUnit) {
2138
- SLADurationUnit["HOURS"] = "h";
2139
- SLADurationUnit["DAYS"] = "d";
2140
- SLADurationUnit["WEEKS"] = "w";
2141
- SLADurationUnit["MONTHS"] = "m";
2142
- })(SLADurationUnit || (SLADurationUnit = {}));
2143
-
2144
- /**
2145
- * Insights Types
2146
- * Shared types for Maestro insights analytics endpoints
2147
- */
2148
- /**
2149
- * Time bucketing granularity for insights time-series queries.
2150
- *
2151
- * Controls how data points are grouped on the time axis.
2152
- */
2153
- var TimeInterval;
2154
- (function (TimeInterval) {
2155
- /** Group data points by hour */
2156
- TimeInterval["Hour"] = "HOUR";
2157
- /** Group data points by day */
2158
- TimeInterval["Day"] = "DAY";
2159
- /** Group data points by week */
2160
- TimeInterval["Week"] = "WEEK";
2161
- })(TimeInterval || (TimeInterval = {}));
2162
- /**
2163
- * Final instance statuses returned by the instance status timeline endpoint.
2164
- *
2165
- * Only includes statuses where the instance has finished execution — Completed, Faulted, or Cancelled.
2166
- * Active statuses like Running or Paused are not included.
2167
- */
2168
- var InstanceFinalStatus;
2169
- (function (InstanceFinalStatus) {
2170
- /** Instance completed successfully */
2171
- InstanceFinalStatus["Completed"] = "Completed";
2172
- /** Instance encountered an error */
2173
- InstanceFinalStatus["Faulted"] = "Faulted";
2174
- /** Instance was cancelled */
2175
- InstanceFinalStatus["Cancelled"] = "Cancelled";
2176
- })(InstanceFinalStatus || (InstanceFinalStatus = {}));
2246
+ _BaseService_apiClient = new WeakMap();
2177
2247
 
2178
2248
  /**
2179
2249
  * Maps fields for Process Instance entities to ensure consistent naming
@@ -2250,7 +2320,7 @@ class ProcessInstancesService extends BaseService {
2250
2320
  }, options);
2251
2321
  }
2252
2322
  /**
2253
- * Get a process instance by ID with operation methods (cancel, pause, resume)
2323
+ * Get a process instance by ID with operation methods (cancel, pause, resume, retry)
2254
2324
  * @param id The ID of the instance to retrieve
2255
2325
  * @param folderKey The folder key for authorization
2256
2326
  * @returns Promise<ProcessInstanceGetResponse>
@@ -2389,6 +2459,25 @@ class ProcessInstancesService extends BaseService {
2389
2459
  data: response.data
2390
2460
  };
2391
2461
  }
2462
+ /**
2463
+ * Retry a faulted process instance
2464
+ *
2465
+ * Re-runs the failed elements of the instance (and the elements that follow) within
2466
+ * the same instance, spawning new jobs. Use to recover from transient/flaky failures.
2467
+ * @param instanceId The ID of the instance to retry
2468
+ * @param folderKey The folder key for authorization
2469
+ * @param options Optional retry options with comment
2470
+ * @returns Promise resolving to operation result with updated instance data
2471
+ */
2472
+ async retry(instanceId, folderKey, options) {
2473
+ const response = await this.post(MAESTRO_ENDPOINTS.INSTANCES.RETRY(instanceId), options || {}, {
2474
+ headers: createHeaders({ [FOLDER_KEY]: folderKey })
2475
+ });
2476
+ return {
2477
+ success: true,
2478
+ data: response.data
2479
+ };
2480
+ }
2392
2481
  /**
2393
2482
  * Parses BPMN XML to extract variable metadata from uipath:inputOutput elements
2394
2483
  * @private
@@ -2539,6 +2628,9 @@ __decorate([
2539
2628
  __decorate([
2540
2629
  track('ProcessInstances.Resume')
2541
2630
  ], ProcessInstancesService.prototype, "resume", null);
2631
+ __decorate([
2632
+ track('ProcessInstances.Retry')
2633
+ ], ProcessInstancesService.prototype, "retry", null);
2542
2634
  __decorate([
2543
2635
  track('ProcessInstances.GetVariables')
2544
2636
  ], ProcessInstancesService.prototype, "getVariables", null);
@@ -2695,7 +2787,7 @@ class MaestroProcessesService extends BaseService {
2695
2787
  *
2696
2788
  * @param startTime - Start of the time range to query
2697
2789
  * @param endTime - End of the time range to query
2698
- * @param options - Optional settings for time bucketing granularity
2790
+ * @param options - Optional settings for filtering and time bucket granularity
2699
2791
  * @returns Promise resolving to an array of {@link InstanceStatusTimelineResponse}
2700
2792
  *
2701
2793
  * @example
@@ -2722,12 +2814,67 @@ class MaestroProcessesService extends BaseService {
2722
2814
  *
2723
2815
  * @example
2724
2816
  * ```typescript
2817
+ * // Filter to a specific process
2818
+ * const filtered = await maestroProcesses.getInstanceStatusTimeline(startTime, endTime, {
2819
+ * processKeys: ['<processKey>'],
2820
+ * });
2821
+ * ```
2822
+ *
2823
+ * @example
2824
+ * ```typescript
2725
2825
  * // Get all-time data (from Unix epoch to now)
2726
2826
  * const allTime = await maestroProcesses.getInstanceStatusTimeline(new Date(0), new Date());
2727
2827
  * ```
2728
2828
  */
2729
2829
  async getInstanceStatusTimeline(startTime, endTime, options) {
2730
- return fetchInstanceStatusTimeline(this.post.bind(this), startTime, endTime, false, options);
2830
+ const { data } = await this.post(MAESTRO_ENDPOINTS.INSIGHTS.INSTANCE_STATUS_BY_DATE, buildInsightsTimelineBody(startTime, endTime, false, options));
2831
+ return data ?? [];
2832
+ }
2833
+ /**
2834
+ * Get incident counts aggregated by time bucket for maestro processes.
2835
+ *
2836
+ * Returns time-grouped counts of incidents that occurred within each bucket,
2837
+ * useful for rendering incident time-series charts. Use `groupBy` to control
2838
+ * the time bucket size (hour, day, or week) — defaults to day if not provided.
2839
+ *
2840
+ * @param startTime - Start of the time range to query
2841
+ * @param endTime - End of the time range to query
2842
+ * @param options - Optional settings for filtering and time bucket granularity
2843
+ * @returns Promise resolving to an array of {@link IncidentTimelineResponse}
2844
+ *
2845
+ * @example
2846
+ * ```typescript
2847
+ * // Get daily incident counts for the last 7 days
2848
+ * const now = new Date();
2849
+ * const sevenDaysAgo = new Date(Date.now() - 7 * 24 * 60 * 60 * 1000);
2850
+ * const incidents = await maestroProcesses.getIncidentsTimeline(sevenDaysAgo, now);
2851
+ *
2852
+ * for (const incident of incidents) {
2853
+ * console.log(`${incident.startTime} → ${incident.endTime}: ${incident.count} incidents`);
2854
+ * }
2855
+ * ```
2856
+ *
2857
+ * @example
2858
+ * ```typescript
2859
+ * import { TimeInterval } from '@uipath/uipath-typescript/maestro-processes';
2860
+ *
2861
+ * // Get weekly breakdown
2862
+ * const incidents = await maestroProcesses.getIncidentsTimeline(startTime, endTime, {
2863
+ * groupBy: TimeInterval.Week,
2864
+ * });
2865
+ * ```
2866
+ *
2867
+ * @example
2868
+ * ```typescript
2869
+ * // Filter to a specific process
2870
+ * const filtered = await maestroProcesses.getIncidentsTimeline(startTime, endTime, {
2871
+ * processKeys: ['<processKey>'],
2872
+ * });
2873
+ * ```
2874
+ */
2875
+ async getIncidentsTimeline(startTime, endTime, options) {
2876
+ const { data } = await this.post(MAESTRO_ENDPOINTS.INSIGHTS.INCIDENTS_BY_TIME_WINDOW, buildInsightsTimelineBody(startTime, endTime, false, options));
2877
+ return data?.dataPoints ?? [];
2731
2878
  }
2732
2879
  /**
2733
2880
  * Get the top 10 processes ranked by failure count within a time range.
@@ -2822,22 +2969,22 @@ class MaestroProcessesService extends BaseService {
2822
2969
  * Returns per-element execution counts (success, fail, terminated, paused, in-progress) and
2823
2970
  * duration percentile metrics (min, max, avg, p50, p95, p99) for BPMN elements within a process.
2824
2971
  *
2825
- * @param processKey - Process key to filter by
2826
- * @param packageId - Package identifier
2827
- * @param startTime - Start of the time range to query
2828
- * @param endTime - End of the time range to query
2829
- * @param packageVersion - Package version to filter by
2972
+ * @param request - Process scope + time range to aggregate over
2830
2973
  * @returns Promise resolving to an array of {@link ElementStats}
2831
2974
  * @example
2832
2975
  * ```typescript
2833
- * // Get element metrics for a process
2834
- * const elements = await maestroProcesses.getElementStats(
2835
- * '<processKey>',
2836
- * '<packageId>',
2837
- * new Date('2026-04-01'),
2838
- * new Date(),
2839
- * '1.0.1'
2840
- * );
2976
+ * // First, list processes to find the processKey, packageId, and available versions
2977
+ * const processes = await maestroProcesses.getAll();
2978
+ * const process = processes[0];
2979
+ *
2980
+ * // Get element metrics for that process
2981
+ * const elements = await maestroProcesses.getElementStats({
2982
+ * processKey: process.processKey,
2983
+ * packageId: process.packageId,
2984
+ * packageVersion: process.packageVersions[0],
2985
+ * startTime: new Date('2026-04-01'),
2986
+ * endTime: new Date(),
2987
+ * });
2841
2988
  *
2842
2989
  * // Analyze element performance
2843
2990
  * for (const element of elements) {
@@ -2845,12 +2992,58 @@ class MaestroProcessesService extends BaseService {
2845
2992
  * console.log(` Success: ${element.successCount}, Failed: ${element.failCount}`);
2846
2993
  * console.log(` Avg duration: ${element.avgDurationMs}ms, P95: ${element.p95DurationMs}ms`);
2847
2994
  * }
2995
+ *
2996
+ * // Using bound method on a process — auto-fills processKey and packageId
2997
+ * const boundElements = await process.getElementStats(
2998
+ * new Date('2026-04-01'),
2999
+ * new Date(),
3000
+ * process.packageVersions[0]
3001
+ * );
2848
3002
  * ```
2849
3003
  */
2850
- async getElementStats(processKey, packageId, startTime, endTime, packageVersion) {
2851
- const { data } = await this.post(MAESTRO_ENDPOINTS.INSIGHTS.ELEMENT_COUNT_BY_STATUS, buildElementCountByStatusBody(processKey, packageId, startTime, endTime, packageVersion));
3004
+ async getElementStats(request) {
3005
+ const { data } = await this.post(MAESTRO_ENDPOINTS.INSIGHTS.ELEMENT_COUNT_BY_STATUS, buildInsightsCommonBody(request));
2852
3006
  return data ?? [];
2853
3007
  }
3008
+ /**
3009
+ * Get instance stats for a process.
3010
+ *
3011
+ * Returns total instance counts broken down by status (running, completed, faulted, etc.)
3012
+ * and the average execution duration for all instances of a process within a time range.
3013
+ *
3014
+ * @param request - Process scope + time range to aggregate over
3015
+ * @returns Promise resolving to {@link InstanceStats}
3016
+ * @example
3017
+ * ```typescript
3018
+ * // First, list processes to find the processKey, packageId, and available versions
3019
+ * const processes = await maestroProcesses.getAll();
3020
+ * const process = processes[0];
3021
+ *
3022
+ * // Get instance status breakdown for that process
3023
+ * const counts = await maestroProcesses.getInstanceStats({
3024
+ * processKey: process.processKey,
3025
+ * packageId: process.packageId,
3026
+ * packageVersion: process.packageVersions[0],
3027
+ * startTime: new Date('2026-04-01'),
3028
+ * endTime: new Date(),
3029
+ * });
3030
+ *
3031
+ * console.log(`Total: ${counts.totalCount}`);
3032
+ * console.log(`Running: ${counts.runningCount}, Completed: ${counts.completedCount}`);
3033
+ * console.log(`Faulted: ${counts.faultedCount}, Avg duration: ${counts.avgDurationMs}ms`);
3034
+ *
3035
+ * // Using bound method on a process — auto-fills processKey and packageId
3036
+ * const boundCounts = await process.getInstanceStats(
3037
+ * new Date('2026-04-01'),
3038
+ * new Date(),
3039
+ * process.packageVersions[0]
3040
+ * );
3041
+ * ```
3042
+ */
3043
+ async getInstanceStats(request) {
3044
+ const { data } = await this.post(MAESTRO_ENDPOINTS.INSIGHTS.INSTANCE_COUNT_BY_STATUS, buildInsightsCommonBody(request));
3045
+ return transformData(data, InstanceStatsMap);
3046
+ }
2854
3047
  }
2855
3048
  __decorate([
2856
3049
  track('MaestroProcesses.GetAll')
@@ -2867,6 +3060,9 @@ __decorate([
2867
3060
  __decorate([
2868
3061
  track('MaestroProcesses.GetInstanceStatusTimeline')
2869
3062
  ], MaestroProcessesService.prototype, "getInstanceStatusTimeline", null);
3063
+ __decorate([
3064
+ track('MaestroProcesses.GetIncidentsTimeline')
3065
+ ], MaestroProcessesService.prototype, "getIncidentsTimeline", null);
2870
3066
  __decorate([
2871
3067
  track('MaestroProcesses.GetTopFaultedCount')
2872
3068
  ], MaestroProcessesService.prototype, "getTopFaultedCount", null);
@@ -2876,6 +3072,9 @@ __decorate([
2876
3072
  __decorate([
2877
3073
  track('MaestroProcesses.GetElementStats')
2878
3074
  ], MaestroProcessesService.prototype, "getElementStats", null);
3075
+ __decorate([
3076
+ track('MaestroProcesses.GetInstanceStats')
3077
+ ], MaestroProcessesService.prototype, "getInstanceStats", null);
2879
3078
 
2880
3079
  /**
2881
3080
  * Service class for Maestro Process Incidents