@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
@@ -45,214 +45,867 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
45
45
  };
46
46
 
47
47
  /**
48
- * Internal types for Maestro Cases
49
- * These types are used internally by the cases service
50
- */
51
- /**
52
- * Process type enum for filtering
53
- */
54
- var ProcessType;
55
- (function (ProcessType) {
56
- ProcessType["CaseManagement"] = "CaseManagement";
57
- })(ProcessType || (ProcessType = {}));
58
-
59
- /**
60
- * Base path constants for different services
61
- */
62
- const ORCHESTRATOR_BASE = 'orchestrator_';
63
- const PIMS_BASE = 'pims_';
64
- const LLMOPS_BASE = 'llmopstenant_';
65
- const INSIGHTS_RTM_BASE = 'insightsrtm_';
66
-
67
- /**
68
- * Orchestrator Service Endpoints
69
- */
70
- /**
71
- * Task Service (Action Center) Endpoints
72
- */
73
- const TASK_ENDPOINTS = {
74
- CREATE_GENERIC_TASK: `${ORCHESTRATOR_BASE}/tasks/GenericTasks/CreateTask`,
75
- GET_TASK_USERS: (folderId) => `${ORCHESTRATOR_BASE}/odata/Tasks/UiPath.Server.Configuration.OData.GetTaskUsers(organizationUnitId=${folderId})`,
76
- GET_TASKS_ACROSS_FOLDERS: `${ORCHESTRATOR_BASE}/odata/Tasks/UiPath.Server.Configuration.OData.GetTasksAcrossFolders`,
77
- GET_TASKS_ACROSS_FOLDERS_ADMIN: `${ORCHESTRATOR_BASE}/odata/Tasks/UiPath.Server.Configuration.OData.GetTasksAcrossFoldersForAdmin`,
78
- GET_BY_ID: (id) => `${ORCHESTRATOR_BASE}/odata/Tasks(${id})`,
79
- ASSIGN_TASKS: `${ORCHESTRATOR_BASE}/odata/Tasks/UiPath.Server.Configuration.OData.AssignTasks`,
80
- REASSIGN_TASKS: `${ORCHESTRATOR_BASE}/odata/Tasks/UiPath.Server.Configuration.OData.ReassignTasks`,
81
- UNASSIGN_TASKS: `${ORCHESTRATOR_BASE}/odata/Tasks/UiPath.Server.Configuration.OData.UnassignTasks`,
82
- COMPLETE_FORM_TASK: `${ORCHESTRATOR_BASE}/forms/TaskForms/CompleteTask`,
83
- COMPLETE_APP_TASK: `${ORCHESTRATOR_BASE}/tasks/AppTasks/CompleteAppTask`,
84
- COMPLETE_GENERIC_TASK: `${ORCHESTRATOR_BASE}/tasks/GenericTasks/CompleteTask`,
85
- GET_TASK_FORM_BY_ID: `${ORCHESTRATOR_BASE}/forms/TaskForms/GetTaskFormById`,
86
- GET_GENERIC_TASK_BY_ID: `${ORCHESTRATOR_BASE}/tasks/GenericTasks/GetTaskDataById`,
87
- GET_APP_TASK_BY_ID: `${ORCHESTRATOR_BASE}/tasks/AppTasks/GetAppTaskById`,
88
- };
89
-
90
- /**
91
- * Maestro Service Endpoints
48
+ * Maps API field names (countOf*) to SDK field names (*Count) for InstanceStats,
49
+ * aligning naming with ElementStats and other count-suffixed conventions.
92
50
  */
93
- /**
94
- * Maestro Process Service Endpoints
95
- */
96
- const MAESTRO_ENDPOINTS = {
97
- PROCESSES: {
98
- GET_ALL: `${PIMS_BASE}/api/v1/processes/summary`,
99
- GET_SETTINGS: (processKey) => `${PIMS_BASE}/api/v1/processes/${processKey}/settings`,
100
- },
101
- INSTANCES: {
102
- GET_ALL: `${PIMS_BASE}/api/v1/instances`,
103
- GET_BY_ID: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}`,
104
- GET_ELEMENT_EXECUTIONS: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/element-executions`,
105
- GET_BPMN: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/bpmn`,
106
- GET_VARIABLES: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/variables`,
107
- CANCEL: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/cancel`,
108
- PAUSE: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/pause`,
109
- RESUME: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/resume`,
110
- },
111
- INCIDENTS: {
112
- GET_ALL: `${PIMS_BASE}/api/v1/incidents/summary`,
113
- GET_BY_PROCESS: (processKey) => `${PIMS_BASE}/api/v1/incidents/process/${processKey}`,
114
- GET_BY_INSTANCE: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/incidents`,
115
- },
116
- TRACES: {
117
- GET_SPANS: (traceId) => `${LLMOPS_BASE}/api/Traces/spans?traceId=${traceId}`,
118
- },
119
- CASES: {
120
- GET_CASE_JSON: (instanceId) => `${PIMS_BASE}/api/v1/cases/${instanceId}/case-json`,
121
- GET_ELEMENT_EXECUTIONS: (instanceId) => `${PIMS_BASE}/api/v1/element-executions/case-instances/${instanceId}`,
122
- REOPEN: (instanceId) => `${PIMS_BASE}/api/v1/cases/${instanceId}/reopen`,
123
- },
124
- INSIGHTS: {
125
- /** SLA summary for case instances */
126
- SLA_SUMMARY: `${INSIGHTS_RTM_BASE}/caseManagement/slaSummary`,
127
- /** Stages summary for case instances */
128
- STAGES_SUMMARY: `${INSIGHTS_RTM_BASE}/caseManagement/stages`,
129
- /** Top processes ranked by run count */
130
- TOP_PROCESSES_BY_RUN_COUNT: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/TopProcessesByRunCount`,
131
- /** Top processes ranked by failure count */
132
- TOP_PROCESSES_WITH_FAILURE: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/TopProcesseswithFailure`,
133
- /** Top elements ranked by failure count */
134
- TOP_ELEMENTS_WITH_FAILURE: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/TopElementswithFailure`,
135
- /** Instance status aggregated by date for time-series charts */
136
- INSTANCE_STATUS_BY_DATE: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/InstanceStatusByDate`,
137
- /** Top processes ranked by total duration */
138
- TOP_PROCESSES_BY_DURATION: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/TopProcessesByDuration`,
139
- /** Element count by status for agentic instances (process and case) */
140
- ELEMENT_COUNT_BY_STATUS: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/ElementCountByStatus`,
141
- },
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'
142
60
  };
143
61
 
144
62
  /**
145
- * Maestro Cases Models
146
- * Model classes for Maestro cases
147
- */
148
- /**
149
- * Creates methods for a case object
150
- *
151
- * @param caseData - The case data (response from API)
152
- * @param service - The cases service instance
153
- * @returns Object containing case methods
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.
154
65
  */
155
- function createCaseMethods(caseData, service) {
156
- return {
157
- getElementStats(startTime, endTime, packageVersion) {
158
- if (!caseData.processKey)
159
- throw new Error('Process key is undefined');
160
- if (!caseData.packageId)
161
- throw new Error('Package ID is undefined');
162
- return service.getElementStats(caseData.processKey, caseData.packageId, startTime, endTime, packageVersion);
163
- }
164
- };
66
+ function toISOUtc(value) {
67
+ const date = new Date(value + ' UTC');
68
+ return isNaN(date.getTime()) ? value : date.toISOString();
165
69
  }
166
70
  /**
167
- * Creates an actionable case by combining API case data with operational methods.
71
+ * Transforms data by renaming each key in `data` exactly once, using the
72
+ * mapping (`sourceField → targetField`). Keys not present in the mapping
73
+ * pass through unchanged. The original (pre-rename) key is dropped — the
74
+ * result contains only the renamed key.
168
75
  *
169
- * @param caseData - The case data from API
170
- * @param service - The cases service instance
171
- * @returns A case object with added methods
76
+ * Each rename is independent. If the mapping happens to contain chained
77
+ * entries (`a b` and `b → c`), they do NOT compose: a field named `a`
78
+ * in `data` becomes `b` (not `c`), because the renames are applied based
79
+ * on the original data's keys, not the running result.
80
+ *
81
+ * @param data The source data to transform
82
+ * @param fieldMapping Object mapping source field names to target field names
83
+ * @returns Transformed data with mapped field names
84
+ *
85
+ * @example
86
+ * ```typescript
87
+ * // Single object transformation
88
+ * const data = { id: '123', userName: 'john' };
89
+ * const mapping = { id: 'userId', userName: 'name' };
90
+ * const result = transformData(data, mapping);
91
+ * // result = { userId: '123', name: 'john' }
92
+ *
93
+ * // Array transformation
94
+ * const dataArray = [
95
+ * { id: '123', userName: 'john' },
96
+ * { id: '456', userName: 'jane' }
97
+ * ];
98
+ * const result = transformData(dataArray, mapping);
99
+ * // result = [
100
+ * // { userId: '123', name: 'john' },
101
+ * // { userId: '456', name: 'jane' }
102
+ * // ]
103
+ *
104
+ * // No chaining — `a → b` does not become `a → c` even if the map has `b → c`.
105
+ * transformData({ a: 1 }, { a: 'b', b: 'c' });
106
+ * // result = { b: 1 }
107
+ * ```
172
108
  */
173
- function createCaseWithMethods(caseData, service) {
174
- const methods = createCaseMethods(caseData, service);
175
- return Object.assign({}, caseData, methods);
109
+ function transformData(data, fieldMapping) {
110
+ // Pass null/undefined through unchanged — callers (e.g. AttachmentService.getById)
111
+ // may invoke this on optional fields that an OData `select` excluded.
112
+ if (data == null) {
113
+ return data;
114
+ }
115
+ // Handle array of objects
116
+ if (Array.isArray(data)) {
117
+ return data.map(item => transformData(item, fieldMapping));
118
+ }
119
+ // Walk the ORIGINAL data's keys, look up each in the mapping. One rename
120
+ // per data key — no mutation of an in-progress result, so chains can't form.
121
+ const result = {};
122
+ for (const [key, value] of Object.entries(data)) {
123
+ const renamedKey = fieldMapping[key] ?? key;
124
+ result[renamedKey] = value;
125
+ }
126
+ return result;
176
127
  }
177
-
178
128
  /**
179
- * Builds the request body for Insights RTM "top" endpoints.
129
+ * Converts a string from PascalCase to camelCase
130
+ * @param str The PascalCase string to convert
131
+ * @returns The camelCase version of the string
180
132
  *
181
- * @param startTime - Start of the time range to query
182
- * @param endTime - End of the time range to query
183
- * @param isCaseManagement - Whether to filter for case management processes
184
- * @param options - Optional filters (packageId, processKey, version)
185
- * @returns Request body for the Insights RTM endpoint
186
- * @internal
133
+ * @example
134
+ * ```typescript
135
+ * pascalToCamelCase('HelloWorld'); // 'helloWorld'
136
+ * pascalToCamelCase('TaskAssignmentCriteria'); // 'taskAssignmentCriteria'
137
+ * ```
187
138
  */
188
- function buildInsightsTopBody(startTime, endTime, isCaseManagement, options) {
189
- return {
190
- commonParams: {
191
- startTime: startTime.getTime(),
192
- endTime: endTime.getTime(),
193
- isCaseManagement,
194
- ...(options?.packageId ? { packageId: options.packageId } : {}),
195
- ...(options?.processKey ? { processKey: options.processKey } : {}),
196
- ...(options?.version ? { version: options.version } : {}),
197
- }
198
- };
139
+ function pascalToCamelCase(str) {
140
+ if (!str)
141
+ return str;
142
+ return str.charAt(0).toLowerCase() + str.slice(1);
199
143
  }
200
144
  /**
201
- * Fetches instance status timeline from the Insights API.
202
- * Shared implementation used by both MaestroProcessesService and CasesService.
145
+ * Converts a string from camelCase to PascalCase
146
+ * @param str The camelCase string to convert
147
+ * @returns The PascalCase version of the string
203
148
  *
204
- * @param postFn - Bound post method from a BaseService subclass
205
- * @param startTime - Start of the time range to query
206
- * @param endTime - End of the time range to query
207
- * @param isCaseManagement - Whether to filter for case management processes
208
- * @param options - Optional settings for time bucketing granularity
209
- * @returns Promise resolving to an array of instance status timeline entries
210
- * @internal
149
+ * @example
150
+ * ```typescript
151
+ * camelToPascalCase('helloWorld'); // 'HelloWorld'
152
+ * camelToPascalCase('taskAssignmentCriteria'); // 'TaskAssignmentCriteria'
153
+ * ```
211
154
  */
212
- async function fetchInstanceStatusTimeline(postFn, startTime, endTime, isCaseManagement, options) {
213
- const response = await postFn(MAESTRO_ENDPOINTS.INSIGHTS.INSTANCE_STATUS_BY_DATE, {
214
- commonParams: {
215
- startTime: startTime.getTime(),
216
- endTime: endTime.getTime(),
217
- isCaseManagement,
218
- },
219
- timeSliceUnit: options?.groupBy,
220
- timezoneOffset: new Date().getTimezoneOffset() * -1,
221
- });
222
- return response.data ?? [];
155
+ function camelToPascalCase(str) {
156
+ if (!str)
157
+ return str;
158
+ return str.charAt(0).toUpperCase() + str.slice(1);
223
159
  }
224
160
  /**
225
- * Builds the request body for the ElementCountByStatus endpoint.
226
- *
227
- * @param processKey - Process key to filter by
228
- * @param packageId - Package identifier
229
- * @param startTime - Start of the time range to query
230
- * @param endTime - End of the time range to query
231
- * @param packageVersion - Package version to filter by
232
- * @returns Request body for the ElementCountByStatus endpoint
233
- * @internal
161
+ * Generic function to transform object keys using a provided case conversion function
162
+ * @param data The object to transform
163
+ * @param convertCase The function to convert each key
164
+ * @returns A new object with transformed keys
234
165
  */
235
- function buildElementCountByStatusBody(processKey, packageId, startTime, endTime, packageVersion) {
236
- return {
237
- commonParams: {
238
- processKey,
239
- packageId,
240
- startTime: startTime.getTime(),
241
- endTime: endTime.getTime(),
242
- version: packageVersion
166
+ function transformCaseKeys(data, convertCase) {
167
+ // Handle array of objects
168
+ if (Array.isArray(data)) {
169
+ return data.map(item => {
170
+ // If the array element is a primitive (string, number, etc.), return it as is
171
+ if (item === null || typeof item !== 'object' || typeof item === 'string') {
172
+ return item;
173
+ }
174
+ // Only recursively transform if it's actually an object
175
+ return transformCaseKeys(item, convertCase);
176
+ });
177
+ }
178
+ const result = {};
179
+ for (const [key, value] of Object.entries(data)) {
180
+ const transformedKey = convertCase(key);
181
+ // Recursively transform nested objects and arrays
182
+ if (value !== null && typeof value === 'object') {
183
+ result[transformedKey] = transformCaseKeys(value, convertCase);
243
184
  }
244
- };
185
+ else {
186
+ result[transformedKey] = value;
187
+ }
188
+ }
189
+ return result;
245
190
  }
246
-
247
191
  /**
248
- * Type guards for error response types
249
- */
250
- function isOrchestratorError(error) {
251
- return typeof error === 'object' &&
252
- error !== null &&
253
- 'message' in error &&
254
- 'errorCode' in error &&
255
- typeof error.message === 'string' &&
192
+ * Transforms an object's keys from PascalCase to camelCase
193
+ * @param data The object with PascalCase keys
194
+ * @returns A new object with all keys converted to camelCase
195
+ *
196
+ * @example
197
+ * ```typescript
198
+ * // Simple object
199
+ * pascalToCamelCaseKeys({ Id: "123", TaskName: "Invoice" });
200
+ * // Result: { id: "123", taskName: "Invoice" }
201
+ *
202
+ * // Nested object
203
+ * pascalToCamelCaseKeys({
204
+ * TaskId: "456",
205
+ * TaskDetails: { AssignedUser: "John", Priority: "High" }
206
+ * });
207
+ * // Result: {
208
+ * // taskId: "456",
209
+ * // taskDetails: { assignedUser: "John", priority: "High" }
210
+ * // }
211
+ *
212
+ * // Array of objects
213
+ * pascalToCamelCaseKeys([
214
+ * { Id: "1", IsComplete: false },
215
+ * { Id: "2", IsComplete: true }
216
+ * ]);
217
+ * // Result: [
218
+ * // { id: "1", isComplete: false },
219
+ * // { id: "2", isComplete: true }
220
+ * // ]
221
+ * ```
222
+ */
223
+ function pascalToCamelCaseKeys(data) {
224
+ return transformCaseKeys(data, pascalToCamelCase);
225
+ }
226
+ /**
227
+ * Transforms an object's keys from camelCase to PascalCase
228
+ * @param data The object with camelCase keys
229
+ * @returns A new object with all keys converted to PascalCase
230
+ *
231
+ * @example
232
+ * ```typescript
233
+ * // Simple object
234
+ * camelToPascalCaseKeys({ userId: "789", isActive: true });
235
+ * // Result: { UserId: "789", IsActive: true }
236
+ *
237
+ * // Nested object
238
+ * camelToPascalCaseKeys({
239
+ * taskId: "ABC123",
240
+ * submissionData: { customerName: "XYZ Corp" }
241
+ * });
242
+ * // Result: {
243
+ * // TaskId: "ABC123",
244
+ * // SubmissionData: { CustomerName: "XYZ Corp" }
245
+ * // }
246
+ *
247
+ * // Array of objects
248
+ * camelToPascalCaseKeys([
249
+ * { userId: "u1", roleType: "admin" },
250
+ * { userId: "u2", roleType: "user" }
251
+ * ]);
252
+ * // Result: [
253
+ * // { UserId: "u1", RoleType: "admin" },
254
+ * // { UserId: "u2", RoleType: "user" }
255
+ * // ]
256
+ * ```
257
+ */
258
+ function camelToPascalCaseKeys(data) {
259
+ return transformCaseKeys(data, camelToPascalCase);
260
+ }
261
+ /**
262
+ * Maps a field value in an object using a provided mapping object.
263
+ * Returns a new object with the mapped field value.
264
+ *
265
+ * @param obj The object to map
266
+ * @param field The field name to map
267
+ * @param valueMap The mapping object (from input value to output value)
268
+ * @returns A new object with the mapped field value
269
+ *
270
+ * @example
271
+ * const statusMap = { 0: 'Unassigned', 1: 'Pending', 2: 'Completed' };
272
+ * const task = { status: 1, id: 123 };
273
+ * const mapped = mapFieldValue(task, 'status', statusMap);
274
+ * // mapped = { status: 'Pending', id: 123 }
275
+ */
276
+ function _mapFieldValue(obj, field, valueMap) {
277
+ const lookupKey = String(obj[field]);
278
+ return {
279
+ ...obj,
280
+ [field]: lookupKey in valueMap
281
+ ? valueMap[lookupKey]
282
+ : obj[field],
283
+ };
284
+ }
285
+ /**
286
+ * General API response transformer with optional field value mapping.
287
+ *
288
+ * @param data - The API response data to transform
289
+ * @param options - Optional mapping options:
290
+ * - field: The field name to map (optional)
291
+ * - valueMap: The mapping object for the field (optional)
292
+ * - transform: A function to further transform the data (optional)
293
+ * @returns The transformed data, with field value mapped if specified
294
+ *
295
+ * @example
296
+ * // Just transform
297
+ * const result = applyDataTransforms(data);
298
+ *
299
+ * // Map a field value, then transform
300
+ * const result = applyDataTransforms(data, { field: 'status', valueMap: StatusMap });
301
+ *
302
+ * // Map a field value, then apply a custom transform
303
+ * const result = applyDataTransforms(data, { field: 'status', valueMap: StatusMap, transform: customTransform });
304
+ */
305
+ function applyDataTransforms(data, options) {
306
+ let result = data;
307
+ if (options?.field && options?.valueMap) {
308
+ result = _mapFieldValue(result, options.field, options.valueMap);
309
+ }
310
+ if (options?.transform) {
311
+ result = options.transform(result);
312
+ }
313
+ return result;
314
+ }
315
+ /**
316
+ * Adds a prefix to specified keys in an object, returning a new object.
317
+ * Only the provided keys are prefixed; all others are left unchanged.
318
+ *
319
+ * @param obj The source object
320
+ * @param prefix The prefix to add (e.g., '$')
321
+ * @param keys The keys to prefix (e.g., ['expand', 'filter'])
322
+ * @returns A new object with specified keys prefixed
323
+ *
324
+ * @example
325
+ * addPrefixToKeys({ expand: 'a', foo: 1 }, '$', ['expand']) // { $expand: 'a', foo: 1 }
326
+ */
327
+ function addPrefixToKeys(obj, prefix, keys) {
328
+ const result = {};
329
+ for (const [key, value] of Object.entries(obj)) {
330
+ if (keys.includes(key)) {
331
+ result[`${prefix}${key}`] = value;
332
+ }
333
+ else {
334
+ result[key] = value;
335
+ }
336
+ }
337
+ return result;
338
+ }
339
+ /**
340
+ * Creates a new map with the keys and values reversed
341
+ * @param map The original map to reverse
342
+ * @returns A new map with keys and values swapped
343
+ *
344
+ * @example
345
+ * ```typescript
346
+ * const original = { key1: 'value1', key2: 'value2' };
347
+ * const reversed = reverseMap(original);
348
+ * // reversed = { value1: 'key1', value2: 'key2' }
349
+ * ```
350
+ */
351
+ function reverseMap(map) {
352
+ return Object.entries(map).reduce((acc, [key, value]) => {
353
+ acc[value] = key;
354
+ return acc;
355
+ }, {});
356
+ }
357
+ /**
358
+ * OData query-string keys whose values may contain field identifiers that
359
+ * need rewriting from SDK names → API names.
360
+ */
361
+ const ODATA_FIELD_PARAM_KEYS = ['filter', 'orderby', 'select', 'expand'];
362
+ /**
363
+ * Matches one token at a time in an OData expression:
364
+ * 1. A single-quoted string literal, allowing the `''` escape sequence —
365
+ * consumed atomically so identifiers inside the literal can't match.
366
+ * 2. An OData identifier (`[A-Za-z_][A-Za-z0-9_]*`).
367
+ * Anything else (whitespace, operators, parens, commas) is left alone by
368
+ * `String.prototype.replace`, which only substitutes matched substrings.
369
+ */
370
+ const ODATA_TOKEN_RE = /'(?:[^']|'')*'|[A-Za-z_][A-Za-z0-9_]*/g;
371
+ /**
372
+ * Rewrites SDK field identifiers to API field identifiers inside an OData
373
+ * expression string (`$filter`, `$orderby`, `$select`, `$expand`).
374
+ *
375
+ * Field maps (e.g. `JobMap`) rename API fields → SDK fields on responses, so
376
+ * SDK consumers see the renamed names. Without this rewrite, the same name
377
+ * in a `filter` string would be forwarded verbatim and the API (which still
378
+ * uses the original name) would reject it.
379
+ *
380
+ * Quoted string literals (with the OData `''` escape) are preserved exactly:
381
+ * the token regex consumes them whole, so identifiers inside literals never
382
+ * match. Identifier tokens are looked up in the reversed field map.
383
+ *
384
+ * @example
385
+ * ```typescript
386
+ * const requestMap = { processName: 'releaseName' };
387
+ * rewriteODataIdentifiers("processName eq 'processName'", requestMap);
388
+ * // "releaseName eq 'processName'" — identifier rewritten, literal preserved
389
+ * ```
390
+ */
391
+ function rewriteODataIdentifiers(expression, requestMap) {
392
+ if (!expression)
393
+ return expression;
394
+ return expression.replace(ODATA_TOKEN_RE, (match) => match.startsWith("'") ? match : (requestMap[match] ?? match));
395
+ }
396
+ /**
397
+ * Symmetric counterpart of {@link transformRequest} for OData query options:
398
+ * rewrites SDK field identifiers inside the recognized OData string params
399
+ * (`filter`, `orderby`, `select`, `expand`) to their API names using the
400
+ * reversed form of a response field map. Returns a shallow copy with the
401
+ * relevant values rewritten; other keys pass through unchanged.
402
+ *
403
+ * Use at the OData edge so SDK consumers can refer to renamed fields by
404
+ * their SDK name throughout — for reading the response and for filtering /
405
+ * sorting / projecting / expanding.
406
+ *
407
+ * @param options The OData query options as authored with SDK field names
408
+ * @param responseMap The response field map (API → SDK); reversed internally
409
+ *
410
+ * @example
411
+ * ```typescript
412
+ * // JobMap renames releaseName → processName on responses.
413
+ * transformOptions({ filter: "processName eq 'X'" }, JobMap);
414
+ * // { filter: "releaseName eq 'X'" }
415
+ * ```
416
+ */
417
+ function transformOptions(options, responseMap) {
418
+ const requestMap = reverseMap(responseMap);
419
+ if (Object.keys(requestMap).length === 0)
420
+ return options;
421
+ const result = { ...options };
422
+ for (const key of ODATA_FIELD_PARAM_KEYS) {
423
+ const value = result[key];
424
+ if (typeof value === 'string') {
425
+ result[key] = rewriteODataIdentifiers(value, requestMap);
426
+ }
427
+ }
428
+ return result;
429
+ }
430
+
431
+ /**
432
+ * Internal types for Maestro Cases
433
+ * These types are used internally by the cases service
434
+ */
435
+ /**
436
+ * Process type enum for filtering
437
+ */
438
+ var ProcessType;
439
+ (function (ProcessType) {
440
+ ProcessType["CaseManagement"] = "CaseManagement";
441
+ })(ProcessType || (ProcessType = {}));
442
+
443
+ /**
444
+ * Base path constants for different services
445
+ */
446
+ const ORCHESTRATOR_BASE = 'orchestrator_';
447
+ const PIMS_BASE = 'pims_';
448
+ const LLMOPS_BASE = 'llmopstenant_';
449
+ const INSIGHTS_RTM_BASE = 'insightsrtm_';
450
+
451
+ /**
452
+ * Orchestrator Service Endpoints
453
+ */
454
+ /**
455
+ * Task Service (Action Center) Endpoints
456
+ */
457
+ const TASK_ENDPOINTS = {
458
+ CREATE_GENERIC_TASK: `${ORCHESTRATOR_BASE}/tasks/GenericTasks/CreateTask`,
459
+ GET_TASK_USERS: (folderId) => `${ORCHESTRATOR_BASE}/odata/Tasks/UiPath.Server.Configuration.OData.GetTaskUsers(organizationUnitId=${folderId})`,
460
+ GET_TASKS_ACROSS_FOLDERS: `${ORCHESTRATOR_BASE}/odata/Tasks/UiPath.Server.Configuration.OData.GetTasksAcrossFolders`,
461
+ GET_TASKS_ACROSS_FOLDERS_ADMIN: `${ORCHESTRATOR_BASE}/odata/Tasks/UiPath.Server.Configuration.OData.GetTasksAcrossFoldersForAdmin`,
462
+ GET_BY_ID: (id) => `${ORCHESTRATOR_BASE}/odata/Tasks(${id})`,
463
+ ASSIGN_TASKS: `${ORCHESTRATOR_BASE}/odata/Tasks/UiPath.Server.Configuration.OData.AssignTasks`,
464
+ REASSIGN_TASKS: `${ORCHESTRATOR_BASE}/odata/Tasks/UiPath.Server.Configuration.OData.ReassignTasks`,
465
+ UNASSIGN_TASKS: `${ORCHESTRATOR_BASE}/odata/Tasks/UiPath.Server.Configuration.OData.UnassignTasks`,
466
+ COMPLETE_FORM_TASK: `${ORCHESTRATOR_BASE}/forms/TaskForms/CompleteTask`,
467
+ COMPLETE_APP_TASK: `${ORCHESTRATOR_BASE}/tasks/AppTasks/CompleteAppTask`,
468
+ COMPLETE_GENERIC_TASK: `${ORCHESTRATOR_BASE}/tasks/GenericTasks/CompleteTask`,
469
+ GET_TASK_FORM_BY_ID: `${ORCHESTRATOR_BASE}/forms/TaskForms/GetTaskFormById`,
470
+ GET_GENERIC_TASK_BY_ID: `${ORCHESTRATOR_BASE}/tasks/GenericTasks/GetTaskDataById`,
471
+ GET_APP_TASK_BY_ID: `${ORCHESTRATOR_BASE}/tasks/AppTasks/GetAppTaskById`,
472
+ };
473
+
474
+ /**
475
+ * Maestro Service Endpoints
476
+ */
477
+ /**
478
+ * Maestro Process Service Endpoints
479
+ */
480
+ const MAESTRO_ENDPOINTS = {
481
+ PROCESSES: {
482
+ GET_ALL: `${PIMS_BASE}/api/v1/processes/summary`,
483
+ GET_SETTINGS: (processKey) => `${PIMS_BASE}/api/v1/processes/${processKey}/settings`,
484
+ },
485
+ INSTANCES: {
486
+ GET_ALL: `${PIMS_BASE}/api/v1/instances`,
487
+ GET_BY_ID: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}`,
488
+ GET_ELEMENT_EXECUTIONS: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/element-executions`,
489
+ GET_BPMN: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/bpmn`,
490
+ GET_VARIABLES: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/variables`,
491
+ CANCEL: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/cancel`,
492
+ PAUSE: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/pause`,
493
+ RESUME: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/resume`,
494
+ RETRY: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/retry`,
495
+ },
496
+ INCIDENTS: {
497
+ GET_ALL: `${PIMS_BASE}/api/v1/incidents/summary`,
498
+ GET_BY_PROCESS: (processKey) => `${PIMS_BASE}/api/v1/incidents/process/${processKey}`,
499
+ GET_BY_INSTANCE: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/incidents`,
500
+ },
501
+ TRACES: {
502
+ GET_SPANS: (traceId) => `${LLMOPS_BASE}/api/Traces/spans?traceId=${traceId}`,
503
+ },
504
+ CASES: {
505
+ GET_CASE_JSON: (instanceId) => `${PIMS_BASE}/api/v1/cases/${instanceId}/case-json`,
506
+ GET_ELEMENT_EXECUTIONS: (instanceId) => `${PIMS_BASE}/api/v1/element-executions/case-instances/${instanceId}`,
507
+ REOPEN: (instanceId) => `${PIMS_BASE}/api/v1/cases/${instanceId}/reopen`,
508
+ },
509
+ INSIGHTS: {
510
+ /** SLA summary for case instances */
511
+ SLA_SUMMARY: `${INSIGHTS_RTM_BASE}/caseManagement/slaSummary`,
512
+ /** Stages summary for case instances */
513
+ STAGES_SUMMARY: `${INSIGHTS_RTM_BASE}/caseManagement/stages`,
514
+ /** Top processes ranked by run count */
515
+ TOP_PROCESSES_BY_RUN_COUNT: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/TopProcessesByRunCount`,
516
+ /** Top processes ranked by failure count */
517
+ TOP_PROCESSES_WITH_FAILURE: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/TopProcesseswithFailure`,
518
+ /** Top elements ranked by failure count */
519
+ TOP_ELEMENTS_WITH_FAILURE: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/TopElementswithFailure`,
520
+ /** Instance status aggregated by date for time-series charts */
521
+ INSTANCE_STATUS_BY_DATE: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/InstanceStatusByDate`,
522
+ /** Top processes ranked by total duration */
523
+ TOP_PROCESSES_BY_DURATION: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/TopProcessesByDuration`,
524
+ /** Instance stats (counts by status + duration percentiles) */
525
+ INSTANCE_COUNT_BY_STATUS: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/InstanceCountByStatus`,
526
+ /** Element count by status for agentic instances (process and case) */
527
+ ELEMENT_COUNT_BY_STATUS: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/ElementCountByStatus`,
528
+ /** Incident counts aggregated by time bucket for time-series charts */
529
+ INCIDENTS_BY_TIME_WINDOW: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/IncidentsByTimeWindow`,
530
+ },
531
+ };
532
+
533
+ /**
534
+ * Maestro Cases Models
535
+ * Model classes for Maestro cases
536
+ */
537
+ /**
538
+ * Creates methods for a case object
539
+ *
540
+ * @param caseData - The case data (response from API)
541
+ * @param service - The cases service instance
542
+ * @returns Object containing case methods
543
+ */
544
+ function createCaseMethods(caseData, service) {
545
+ return {
546
+ getElementStats(startTime, endTime, packageVersion) {
547
+ if (!caseData.processKey)
548
+ throw new Error('Process key is undefined');
549
+ if (!caseData.packageId)
550
+ throw new Error('Package ID is undefined');
551
+ return service.getElementStats({
552
+ processKey: caseData.processKey,
553
+ packageId: caseData.packageId,
554
+ packageVersion,
555
+ startTime,
556
+ endTime,
557
+ });
558
+ },
559
+ getInstanceStats(startTime, endTime, packageVersion) {
560
+ if (!caseData.processKey)
561
+ throw new Error('Process key is undefined');
562
+ if (!caseData.packageId)
563
+ throw new Error('Package ID is undefined');
564
+ return service.getInstanceStats({
565
+ processKey: caseData.processKey,
566
+ packageId: caseData.packageId,
567
+ packageVersion,
568
+ startTime,
569
+ endTime,
570
+ });
571
+ },
572
+ getInstanceStatusTimeline(startTime, endTime, options) {
573
+ if (!caseData.processKey)
574
+ throw new Error('Process key is undefined');
575
+ return service.getInstanceStatusTimeline(startTime, endTime, { ...options, processKeys: [caseData.processKey] });
576
+ },
577
+ getIncidentsTimeline(startTime, endTime, options) {
578
+ if (!caseData.processKey)
579
+ throw new Error('Process key is undefined');
580
+ return service.getIncidentsTimeline(startTime, endTime, { ...options, processKeys: [caseData.processKey] });
581
+ }
582
+ };
583
+ }
584
+ /**
585
+ * Creates an actionable case by combining API case data with operational methods.
586
+ *
587
+ * @param caseData - The case data from API
588
+ * @param service - The cases service instance
589
+ * @returns A case object with added methods
590
+ */
591
+ function createCaseWithMethods(caseData, service) {
592
+ const methods = createCaseMethods(caseData, service);
593
+ return Object.assign({}, caseData, methods);
594
+ }
595
+
596
+ /**
597
+ * Process Incident Status
598
+ */
599
+ var ProcessIncidentStatus;
600
+ (function (ProcessIncidentStatus) {
601
+ ProcessIncidentStatus["Open"] = "Open";
602
+ ProcessIncidentStatus["Closed"] = "Closed";
603
+ })(ProcessIncidentStatus || (ProcessIncidentStatus = {}));
604
+ /**
605
+ * Process Incident Type
606
+ */
607
+ var ProcessIncidentType;
608
+ (function (ProcessIncidentType) {
609
+ ProcessIncidentType["System"] = "System";
610
+ ProcessIncidentType["User"] = "User";
611
+ ProcessIncidentType["Deployment"] = "Deployment";
612
+ })(ProcessIncidentType || (ProcessIncidentType = {}));
613
+ /**
614
+ * Process Incident Severity
615
+ */
616
+ var ProcessIncidentSeverity;
617
+ (function (ProcessIncidentSeverity) {
618
+ ProcessIncidentSeverity["Error"] = "Error";
619
+ ProcessIncidentSeverity["Warning"] = "Warning";
620
+ })(ProcessIncidentSeverity || (ProcessIncidentSeverity = {}));
621
+ /**
622
+ * Process Incident Debug Mode
623
+ */
624
+ var DebugMode;
625
+ (function (DebugMode) {
626
+ DebugMode["None"] = "None";
627
+ DebugMode["Default"] = "Default";
628
+ DebugMode["StepByStep"] = "StepByStep";
629
+ DebugMode["SingleStep"] = "SingleStep";
630
+ })(DebugMode || (DebugMode = {}));
631
+
632
+ /**
633
+ * Case Instance Types
634
+ * Types and interfaces for Maestro case instance management
635
+ */
636
+ /**
637
+ * SLA status for a case instance
638
+ */
639
+ exports.SlaSummaryStatus = void 0;
640
+ (function (SlaSummaryStatus) {
641
+ /** Case is within SLA deadline */
642
+ SlaSummaryStatus["ON_TRACK"] = "On Track";
643
+ /** Case is approaching SLA deadline based on at-risk percentage threshold */
644
+ SlaSummaryStatus["AT_RISK"] = "At Risk";
645
+ /** Case has exceeded SLA deadline */
646
+ SlaSummaryStatus["OVERDUE"] = "Overdue";
647
+ /** Case instance has completed */
648
+ SlaSummaryStatus["COMPLETED"] = "Completed";
649
+ /** SLA status cannot be determined (no SLA deadline defined) */
650
+ SlaSummaryStatus["UNKNOWN"] = "Unknown";
651
+ })(exports.SlaSummaryStatus || (exports.SlaSummaryStatus = {}));
652
+ /**
653
+ * Instance status values for case instances and process instances
654
+ */
655
+ exports.InstanceStatus = void 0;
656
+ (function (InstanceStatus) {
657
+ /** Instance status not yet populated by the backend */
658
+ InstanceStatus["UNKNOWN"] = "";
659
+ InstanceStatus["CANCELLED"] = "Cancelled";
660
+ InstanceStatus["CANCELING"] = "Canceling";
661
+ InstanceStatus["COMPLETED"] = "Completed";
662
+ InstanceStatus["FAULTED"] = "Faulted";
663
+ InstanceStatus["PAUSED"] = "Paused";
664
+ InstanceStatus["PAUSING"] = "Pausing";
665
+ InstanceStatus["PENDING"] = "Pending";
666
+ InstanceStatus["RESUMING"] = "Resuming";
667
+ InstanceStatus["RETRYING"] = "Retrying";
668
+ InstanceStatus["RUNNING"] = "Running";
669
+ InstanceStatus["UPGRADING"] = "Upgrading";
670
+ })(exports.InstanceStatus || (exports.InstanceStatus = {}));
671
+ /**
672
+ * Case stage task type
673
+ */
674
+ exports.StageTaskType = void 0;
675
+ (function (StageTaskType) {
676
+ StageTaskType["EXTERNAL_AGENT"] = "external-agent";
677
+ StageTaskType["RPA"] = "rpa";
678
+ StageTaskType["AGENTIC_PROCESS"] = "process";
679
+ StageTaskType["AGENT"] = "agent";
680
+ StageTaskType["ACTION"] = "action";
681
+ StageTaskType["API_WORKFLOW"] = "api-workflow";
682
+ })(exports.StageTaskType || (exports.StageTaskType = {}));
683
+ /**
684
+ * Escalation recipient scope
685
+ */
686
+ exports.EscalationRecipientScope = void 0;
687
+ (function (EscalationRecipientScope) {
688
+ EscalationRecipientScope["USER"] = "user";
689
+ EscalationRecipientScope["USER_GROUP"] = "usergroup";
690
+ })(exports.EscalationRecipientScope || (exports.EscalationRecipientScope = {}));
691
+ /**
692
+ * Escalation action type
693
+ */
694
+ exports.EscalationActionType = void 0;
695
+ (function (EscalationActionType) {
696
+ EscalationActionType["NOTIFICATION"] = "notification";
697
+ })(exports.EscalationActionType || (exports.EscalationActionType = {}));
698
+ /**
699
+ * Escalation rule trigger type
700
+ */
701
+ exports.EscalationTriggerType = void 0;
702
+ (function (EscalationTriggerType) {
703
+ EscalationTriggerType["SLA_BREACHED"] = "sla-breached";
704
+ EscalationTriggerType["AT_RISK"] = "at-risk";
705
+ /** Default value when no escalation rule is defined */
706
+ EscalationTriggerType["NONE"] = "None";
707
+ })(exports.EscalationTriggerType || (exports.EscalationTriggerType = {}));
708
+ /**
709
+ * SLA duration unit
710
+ */
711
+ exports.SLADurationUnit = void 0;
712
+ (function (SLADurationUnit) {
713
+ SLADurationUnit["HOURS"] = "h";
714
+ SLADurationUnit["DAYS"] = "d";
715
+ SLADurationUnit["WEEKS"] = "w";
716
+ SLADurationUnit["MONTHS"] = "m";
717
+ })(exports.SLADurationUnit || (exports.SLADurationUnit = {}));
718
+
719
+ /**
720
+ * Creates methods for a case instance
721
+ *
722
+ * @param instanceData - The case instance data (response from API)
723
+ * @param service - The case instance service instance
724
+ * @returns Object containing case instance methods
725
+ */
726
+ function createCaseInstanceMethods(instanceData, service) {
727
+ return {
728
+ async close(options) {
729
+ if (!instanceData.instanceId)
730
+ throw new Error('Case instance ID is undefined');
731
+ if (!instanceData.folderKey)
732
+ throw new Error('Case instance folder key is undefined');
733
+ return service.close(instanceData.instanceId, instanceData.folderKey, options);
734
+ },
735
+ async pause(options) {
736
+ if (!instanceData.instanceId)
737
+ throw new Error('Case instance ID is undefined');
738
+ if (!instanceData.folderKey)
739
+ throw new Error('Case instance folder key is undefined');
740
+ return service.pause(instanceData.instanceId, instanceData.folderKey, options);
741
+ },
742
+ async reopen(options) {
743
+ if (!instanceData.instanceId)
744
+ throw new Error('Case instance ID is undefined');
745
+ if (!instanceData.folderKey)
746
+ throw new Error('Case instance folder key is undefined');
747
+ return service.reopen(instanceData.instanceId, instanceData.folderKey, options);
748
+ },
749
+ async resume(options) {
750
+ if (!instanceData.instanceId)
751
+ throw new Error('Case instance ID is undefined');
752
+ if (!instanceData.folderKey)
753
+ throw new Error('Case instance folder key is undefined');
754
+ return service.resume(instanceData.instanceId, instanceData.folderKey, options);
755
+ },
756
+ async getExecutionHistory() {
757
+ if (!instanceData.instanceId)
758
+ throw new Error('Case instance ID is undefined');
759
+ if (!instanceData.folderKey)
760
+ throw new Error('Case instance folder key is undefined');
761
+ return service.getExecutionHistory(instanceData.instanceId, instanceData.folderKey);
762
+ },
763
+ async getStages() {
764
+ if (!instanceData.instanceId)
765
+ throw new Error('Case instance ID is undefined');
766
+ if (!instanceData.folderKey)
767
+ throw new Error('Case instance folder key is undefined');
768
+ return service.getStages(instanceData.instanceId, instanceData.folderKey);
769
+ },
770
+ async getActionTasks(options) {
771
+ if (!instanceData.instanceId)
772
+ throw new Error('Case instance ID is undefined');
773
+ return service.getActionTasks(instanceData.instanceId, options);
774
+ },
775
+ async getSlaSummary(options) {
776
+ if (!instanceData.instanceId)
777
+ throw new Error('Case instance ID is undefined');
778
+ return service.getSlaSummary({ ...options, caseInstanceId: instanceData.instanceId });
779
+ },
780
+ async getStagesSlaSummary() {
781
+ if (!instanceData.instanceId)
782
+ throw new Error('Case instance ID is undefined');
783
+ return service.getStagesSlaSummary({ caseInstanceId: instanceData.instanceId });
784
+ }
785
+ };
786
+ }
787
+ /**
788
+ * Creates an actionable case instance by combining API case instance data with operational methods.
789
+ *
790
+ * @param instanceData - The case instance data from API
791
+ * @param service - The case instance service instance
792
+ * @returns A case instance object with added methods
793
+ */
794
+ function createCaseInstanceWithMethods(instanceData, service) {
795
+ const methods = createCaseInstanceMethods(instanceData, service);
796
+ return Object.assign({}, instanceData, methods);
797
+ }
798
+
799
+ /**
800
+ * Insights Types
801
+ * Shared types for Maestro insights analytics endpoints
802
+ */
803
+ /**
804
+ * Time bucketing granularity for insights time-series queries.
805
+ *
806
+ * Controls how data points are grouped on the time axis.
807
+ */
808
+ exports.TimeInterval = void 0;
809
+ (function (TimeInterval) {
810
+ /** Group data points by hour */
811
+ TimeInterval["Hour"] = "HOUR";
812
+ /** Group data points by day */
813
+ TimeInterval["Day"] = "DAY";
814
+ /** Group data points by week */
815
+ TimeInterval["Week"] = "WEEK";
816
+ })(exports.TimeInterval || (exports.TimeInterval = {}));
817
+ /**
818
+ * Final instance statuses returned by the instance status timeline endpoint.
819
+ *
820
+ * Only includes statuses where the instance has finished execution — Completed, Faulted, or Cancelled.
821
+ * Active statuses like Running or Paused are not included.
822
+ */
823
+ exports.InstanceFinalStatus = void 0;
824
+ (function (InstanceFinalStatus) {
825
+ /** Instance completed successfully */
826
+ InstanceFinalStatus["Completed"] = "Completed";
827
+ /** Instance encountered an error */
828
+ InstanceFinalStatus["Faulted"] = "Faulted";
829
+ /** Instance was cancelled */
830
+ InstanceFinalStatus["Cancelled"] = "Cancelled";
831
+ })(exports.InstanceFinalStatus || (exports.InstanceFinalStatus = {}));
832
+
833
+ /**
834
+ * Builds the request body for Insights RTM "top" endpoints.
835
+ *
836
+ * @param startTime - Start of the time range to query
837
+ * @param endTime - End of the time range to query
838
+ * @param isCaseManagement - Whether to filter for case management processes
839
+ * @param options - Optional filters (packageId, processKey, version)
840
+ * @returns Request body for the Insights RTM endpoint
841
+ * @internal
842
+ */
843
+ function buildInsightsTopBody(startTime, endTime, isCaseManagement, options) {
844
+ return {
845
+ commonParams: {
846
+ startTime: startTime.getTime(),
847
+ endTime: endTime.getTime(),
848
+ isCaseManagement,
849
+ ...(options?.packageId ? { packageId: options.packageId } : {}),
850
+ ...(options?.processKey ? { processKey: options.processKey } : {}),
851
+ ...(options?.version ? { version: options.version } : {}),
852
+ }
853
+ };
854
+ }
855
+ /**
856
+ * Builds the request body for Insights RTM timeline endpoints
857
+ * (`InstanceStatusByDate`, `IncidentsByTimeWindow`).
858
+ *
859
+ * @param startTime - Start of the time range to query
860
+ * @param endTime - End of the time range to query
861
+ * @param isCaseManagement - Whether to filter for case management processes
862
+ * @param options - Optional time bucketing and filtering settings
863
+ * @returns Request body for the Insights RTM timeline endpoint
864
+ * @internal
865
+ */
866
+ function buildInsightsTimelineBody(startTime, endTime, isCaseManagement, options) {
867
+ return {
868
+ commonParams: {
869
+ startTime: startTime.getTime(),
870
+ endTime: endTime.getTime(),
871
+ isCaseManagement,
872
+ ...(options?.packageId ? { packageId: options.packageId } : {}),
873
+ ...(options?.version ? { version: options.version } : {}),
874
+ ...(options?.processKeys ? { processKeys: options.processKeys } : {}),
875
+ },
876
+ timeSliceUnit: options?.groupBy ?? exports.TimeInterval.Day,
877
+ timezoneOffset: new Date().getTimezoneOffset() * -1,
878
+ };
879
+ }
880
+ /**
881
+ * Builds the commonParams request body for Insights RTM endpoints
882
+ * that filter by process key, package, time range, and version.
883
+ *
884
+ * @param request - Process scope + time range to aggregate over
885
+ * @returns Request body with commonParams
886
+ * @internal
887
+ */
888
+ function buildInsightsCommonBody(request) {
889
+ return {
890
+ commonParams: {
891
+ processKey: request.processKey,
892
+ packageId: request.packageId,
893
+ startTime: request.startTime.getTime(),
894
+ endTime: request.endTime.getTime(),
895
+ version: request.packageVersion
896
+ }
897
+ };
898
+ }
899
+
900
+ /**
901
+ * Type guards for error response types
902
+ */
903
+ function isOrchestratorError(error) {
904
+ return typeof error === 'object' &&
905
+ error !== null &&
906
+ 'message' in error &&
907
+ 'errorCode' in error &&
908
+ typeof error.message === 'string' &&
256
909
  typeof error.errorCode === 'number';
257
910
  }
258
911
  function isEntityError(error) {
@@ -942,532 +1595,270 @@ isBrowser && window.self != window.top && window.location.href.includes('source=
942
1595
  const _params = isBrowser ? new URLSearchParams(window.location.search) : null;
943
1596
  /**
944
1597
  * True when the coded app has been loaded inside a host frame that explicitly
945
- * opted into token delegation by adding `?host=embed` to the iframe src URL.
946
- */
947
- const isHostEmbedded = isBrowser && window.self !== window.top && _params?.get('host') === 'embed';
948
- /**
949
- * The validated parent origin, read from the `?basedomain=` query param set
950
- * by the embedding host in the iframe src URL.
951
- * Mirrors the same mechanism used by ActionCenterTokenManager.
952
- * Non-null only when `?host=embed` is present and `?basedomain=` is a valid URL.
953
- */
954
- (() => {
955
- if (!isHostEmbedded)
956
- return null;
957
- const basedomain = _params?.get('basedomain');
958
- if (!basedomain)
959
- return null;
960
- try {
961
- return new URL(basedomain).origin;
962
- }
963
- catch {
964
- console.warn('embeddingOrigin: basedomain query param is not a valid URL', basedomain);
965
- return null;
966
- }
967
- })();
968
-
969
- /**
970
- * Base64 encoding/decoding
971
- */
972
- /**
973
- * Encodes a string to base64
974
- * @param str - The string to encode
975
- * @returns Base64 encoded string
976
- */
977
- function encodeBase64(str) {
978
- // TextEncoder for UTF-8 encoding (works in both browser and Node.js)
979
- const encoder = new TextEncoder();
980
- const data = encoder.encode(str);
981
- // Convert Uint8Array to base64
982
- if (isBrowser) {
983
- // Browser environment
984
- // Convert Uint8Array to binary string then to base64
985
- const binaryString = Array.from(data, byte => String.fromCharCode(byte)).join('');
986
- return btoa(binaryString);
987
- }
988
- else {
989
- // Node.js environment
990
- return Buffer.from(data).toString('base64');
991
- }
992
- }
993
- /**
994
- * Decodes a base64 string
995
- * @param base64 - The base64 string to decode
996
- * @returns Decoded string
997
- */
998
- function decodeBase64(base64) {
999
- let bytes;
1000
- if (isBrowser) {
1001
- // Browser environment
1002
- const binaryString = atob(base64);
1003
- bytes = new Uint8Array(binaryString.length);
1004
- for (let i = 0; i < binaryString.length; i++) {
1005
- bytes[i] = binaryString.charCodeAt(i);
1006
- }
1007
- }
1008
- else {
1009
- // Node.js environment
1010
- bytes = new Uint8Array(Buffer.from(base64, 'base64'));
1011
- }
1012
- // TextDecoder for UTF-8 decoding (works in both browser and Node.js)
1013
- const decoder = new TextDecoder();
1014
- return decoder.decode(bytes);
1015
- }
1016
-
1017
- /**
1018
- * PaginationManager handles the conversion between uniform cursor-based pagination
1019
- * and the specific pagination type for each service
1020
- */
1021
- class PaginationManager {
1022
- /**
1023
- * Create a pagination cursor for subsequent page requests
1024
- */
1025
- static createCursor({ pageInfo, type }) {
1026
- if (!pageInfo.hasMore) {
1027
- return undefined;
1028
- }
1029
- const cursorData = {
1030
- type,
1031
- pageSize: pageInfo.pageSize,
1032
- };
1033
- switch (type) {
1034
- case PaginationType.OFFSET:
1035
- if (pageInfo.currentPage) {
1036
- cursorData.pageNumber = pageInfo.currentPage + 1;
1037
- }
1038
- break;
1039
- case PaginationType.TOKEN:
1040
- if (pageInfo.continuationToken) {
1041
- cursorData.continuationToken = pageInfo.continuationToken;
1042
- }
1043
- else {
1044
- return undefined; // No continuation token, can't continue
1045
- }
1046
- break;
1047
- }
1048
- return {
1049
- value: encodeBase64(JSON.stringify(cursorData))
1050
- };
1051
- }
1052
- /**
1053
- * Create a paginated response with navigation cursors
1054
- */
1055
- static createPaginatedResponse({ pageInfo, type }, items) {
1056
- const nextCursor = PaginationManager.createCursor({ pageInfo, type });
1057
- // Create previous page cursor if applicable
1058
- let previousCursor = undefined;
1059
- if (pageInfo.currentPage && pageInfo.currentPage > 1) {
1060
- const prevCursorData = {
1061
- type,
1062
- pageNumber: pageInfo.currentPage - 1,
1063
- pageSize: pageInfo.pageSize,
1064
- };
1065
- previousCursor = {
1066
- value: encodeBase64(JSON.stringify(prevCursorData))
1067
- };
1068
- }
1069
- // Calculate total pages if we have totalCount and pageSize
1070
- let totalPages = undefined;
1071
- if (pageInfo.totalCount !== undefined && pageInfo.pageSize) {
1072
- totalPages = Math.ceil(pageInfo.totalCount / pageInfo.pageSize);
1073
- }
1074
- // Determine if this pagination type supports page jumping
1075
- const supportsPageJump = type === PaginationType.OFFSET;
1076
- // Create the result object with all fields, then filter out undefined values
1077
- const result = filterUndefined({
1078
- items,
1079
- totalCount: pageInfo.totalCount,
1080
- hasNextPage: pageInfo.hasMore,
1081
- nextCursor: nextCursor,
1082
- previousCursor: previousCursor,
1083
- currentPage: pageInfo.currentPage,
1084
- totalPages,
1085
- supportsPageJump
1086
- });
1087
- return result;
1088
- }
1089
- }
1090
-
1091
- /**
1092
- * Creates headers object from key-value pairs
1093
- * @param headersObj - Object containing header key-value pairs
1094
- * @returns Headers object with all values converted to strings
1095
- *
1096
- * @example
1097
- * ```typescript
1098
- * // Single header
1099
- * const headers = createHeaders({ 'X-UIPATH-FolderKey': '1234567890' });
1100
- *
1101
- * // Multiple headers
1102
- * const headers = createHeaders({
1103
- * 'X-UIPATH-FolderKey': '1234567890',
1104
- * 'X-UIPATH-OrganizationUnitId': 123,
1105
- * 'Accept': 'application/json'
1106
- * });
1107
- *
1108
- * // Using constants
1109
- * import { FOLDER_KEY, FOLDER_ID } from '../constants/headers';
1110
- * const headers = createHeaders({
1111
- * [FOLDER_KEY]: 'abc-123',
1112
- * [FOLDER_ID]: 456
1113
- * });
1114
- *
1115
- * // Empty headers
1116
- * const headers = createHeaders();
1117
- * ```
1118
- */
1119
- function createHeaders(headersObj) {
1120
- const headers = {};
1121
- for (const [key, value] of Object.entries(headersObj)) {
1122
- if (value !== undefined && value !== null) {
1123
- headers[key] = value.toString();
1124
- }
1125
- }
1126
- return headers;
1127
- }
1128
-
1129
- /**
1130
- * Common constants used across the SDK
1131
- */
1132
- /**
1133
- * Prefix used for OData query parameters
1134
- */
1135
- const ODATA_PREFIX = '$';
1136
- /**
1137
- * HTTP methods
1138
- */
1139
- const HTTP_METHODS = {
1140
- GET: 'GET',
1141
- POST: 'POST'};
1142
- /**
1143
- * OData pagination constants
1144
- */
1145
- const ODATA_PAGINATION = {
1146
- /** Default field name for items in a paginated OData response */
1147
- ITEMS_FIELD: 'value',
1148
- /** Default field name for total count in a paginated OData response */
1149
- TOTAL_COUNT_FIELD: '@odata.count'
1150
- };
1151
- /**
1152
- * SLA Summary pagination constants for page-number-based pagination
1153
- */
1154
- const SLA_SUMMARY_PAGINATION = {
1155
- /** Field name for items in SLA summary response */
1156
- ITEMS_FIELD: 'data',
1157
- /** Dot-notation path for total count in nested pagination object */
1158
- TOTAL_COUNT_FIELD: 'pagination.totalCount'
1159
- };
1160
- /**
1161
- * SLA Summary OFFSET pagination parameter names (page-number style, no skip conversion)
1162
- */
1163
- const SLA_SUMMARY_OFFSET_PARAMS = {
1164
- /** Page size parameter name */
1165
- PAGE_SIZE_PARAM: 'PageSize',
1166
- /** Page number parameter name (sent directly, not converted to skip) */
1167
- OFFSET_PARAM: 'PageNumber',
1168
- /** No count param needed */
1169
- COUNT_PARAM: undefined
1170
- };
1171
- /**
1172
- * Process Instance pagination constants for token-based pagination
1173
- */
1174
- const PROCESS_INSTANCE_PAGINATION = {
1175
- /** Field name for items in process instance response */
1176
- ITEMS_FIELD: 'instances',
1177
- /** Field name for continuation token in process instance response */
1178
- CONTINUATION_TOKEN_FIELD: 'nextPage'
1179
- };
1180
- /**
1181
- * OData OFFSET pagination parameter names (ODATA-style)
1182
- */
1183
- const ODATA_OFFSET_PARAMS = {
1184
- /** OData page size parameter name */
1185
- PAGE_SIZE_PARAM: '$top',
1186
- /** OData offset parameter name */
1187
- OFFSET_PARAM: '$skip',
1188
- /** OData count parameter name */
1189
- COUNT_PARAM: '$count'
1190
- };
1191
- /**
1192
- * Bucket TOKEN pagination parameter names
1193
- */
1194
- const BUCKET_TOKEN_PARAMS = {
1195
- /** Bucket page size parameter name */
1196
- PAGE_SIZE_PARAM: 'takeHint',
1197
- /** Bucket token parameter name */
1198
- TOKEN_PARAM: 'continuationToken'
1199
- };
1598
+ * opted into token delegation by adding `?host=embed` to the iframe src URL.
1599
+ */
1600
+ const isHostEmbedded = isBrowser && window.self !== window.top && _params?.get('host') === 'embed';
1200
1601
  /**
1201
- * Process Instance TOKEN pagination parameter names
1602
+ * The validated parent origin, read from the `?basedomain=` query param set
1603
+ * by the embedding host in the iframe src URL.
1604
+ * Mirrors the same mechanism used by ActionCenterTokenManager.
1605
+ * Non-null only when `?host=embed` is present and `?basedomain=` is a valid URL.
1202
1606
  */
1203
- const PROCESS_INSTANCE_TOKEN_PARAMS = {
1204
- /** Process instance page size parameter name */
1205
- PAGE_SIZE_PARAM: 'pageSize',
1206
- /** Process instance token parameter name */
1207
- TOKEN_PARAM: 'nextPage'
1208
- };
1607
+ (() => {
1608
+ if (!isHostEmbedded)
1609
+ return null;
1610
+ const basedomain = _params?.get('basedomain');
1611
+ if (!basedomain)
1612
+ return null;
1613
+ try {
1614
+ return new URL(basedomain).origin;
1615
+ }
1616
+ catch {
1617
+ console.warn('embeddingOrigin: basedomain query param is not a valid URL', basedomain);
1618
+ return null;
1619
+ }
1620
+ })();
1209
1621
 
1210
1622
  /**
1211
- * Converts a UTC timestamp string (e.g., "5/8/2026 11:20:17 AM") to ISO 8601 UTC format.
1212
- * Returns the original value if parsing fails.
1623
+ * Base64 encoding/decoding
1213
1624
  */
1214
- function toISOUtc(value) {
1215
- const date = new Date(value + ' UTC');
1216
- return isNaN(date.getTime()) ? value : date.toISOString();
1217
- }
1218
1625
  /**
1219
- * Transforms data by mapping fields according to the provided field mapping
1220
- * @param data The source data to transform
1221
- * @param fieldMapping Object mapping source field names to target field names
1222
- * @returns Transformed data with mapped field names
1223
- *
1224
- * @example
1225
- * ```typescript
1226
- * // Single object transformation
1227
- * const data = { id: '123', userName: 'john' };
1228
- * const mapping = { id: 'userId', userName: 'name' };
1229
- * const result = transformData(data, mapping);
1230
- * // result = { userId: '123', name: 'john' }
1231
- *
1232
- * // Array transformation
1233
- * const dataArray = [
1234
- * { id: '123', userName: 'john' },
1235
- * { id: '456', userName: 'jane' }
1236
- * ];
1237
- * const result = transformData(dataArray, mapping);
1238
- * // result = [
1239
- * // { userId: '123', name: 'john' },
1240
- * // { userId: '456', name: 'jane' }
1241
- * // ]
1242
- * ```
1626
+ * Encodes a string to base64
1627
+ * @param str - The string to encode
1628
+ * @returns Base64 encoded string
1243
1629
  */
1244
- function transformData(data, fieldMapping) {
1245
- // Handle array of objects
1246
- if (Array.isArray(data)) {
1247
- return data.map(item => transformData(item, fieldMapping));
1630
+ function encodeBase64(str) {
1631
+ // TextEncoder for UTF-8 encoding (works in both browser and Node.js)
1632
+ const encoder = new TextEncoder();
1633
+ const data = encoder.encode(str);
1634
+ // Convert Uint8Array to base64
1635
+ if (isBrowser) {
1636
+ // Browser environment
1637
+ // Convert Uint8Array to binary string then to base64
1638
+ const binaryString = Array.from(data, byte => String.fromCharCode(byte)).join('');
1639
+ return btoa(binaryString);
1248
1640
  }
1249
- // Handle single object
1250
- const result = { ...data };
1251
- for (const [sourceField, targetField] of Object.entries(fieldMapping)) {
1252
- if (sourceField in result) {
1253
- const value = result[sourceField];
1254
- delete result[sourceField];
1255
- result[targetField] = value;
1256
- }
1641
+ else {
1642
+ // Node.js environment
1643
+ return Buffer.from(data).toString('base64');
1257
1644
  }
1258
- return result;
1259
- }
1260
- /**
1261
- * Converts a string from PascalCase to camelCase
1262
- * @param str The PascalCase string to convert
1263
- * @returns The camelCase version of the string
1264
- *
1265
- * @example
1266
- * ```typescript
1267
- * pascalToCamelCase('HelloWorld'); // 'helloWorld'
1268
- * pascalToCamelCase('TaskAssignmentCriteria'); // 'taskAssignmentCriteria'
1269
- * ```
1270
- */
1271
- function pascalToCamelCase(str) {
1272
- if (!str)
1273
- return str;
1274
- return str.charAt(0).toLowerCase() + str.slice(1);
1275
1645
  }
1276
1646
  /**
1277
- * Converts a string from camelCase to PascalCase
1278
- * @param str The camelCase string to convert
1279
- * @returns The PascalCase version of the string
1280
- *
1281
- * @example
1282
- * ```typescript
1283
- * camelToPascalCase('helloWorld'); // 'HelloWorld'
1284
- * camelToPascalCase('taskAssignmentCriteria'); // 'TaskAssignmentCriteria'
1285
- * ```
1647
+ * Decodes a base64 string
1648
+ * @param base64 - The base64 string to decode
1649
+ * @returns Decoded string
1286
1650
  */
1287
- function camelToPascalCase(str) {
1288
- if (!str)
1289
- return str;
1290
- return str.charAt(0).toUpperCase() + str.slice(1);
1651
+ function decodeBase64(base64) {
1652
+ let bytes;
1653
+ if (isBrowser) {
1654
+ // Browser environment
1655
+ const binaryString = atob(base64);
1656
+ bytes = new Uint8Array(binaryString.length);
1657
+ for (let i = 0; i < binaryString.length; i++) {
1658
+ bytes[i] = binaryString.charCodeAt(i);
1659
+ }
1660
+ }
1661
+ else {
1662
+ // Node.js environment
1663
+ bytes = new Uint8Array(Buffer.from(base64, 'base64'));
1664
+ }
1665
+ // TextDecoder for UTF-8 decoding (works in both browser and Node.js)
1666
+ const decoder = new TextDecoder();
1667
+ return decoder.decode(bytes);
1291
1668
  }
1669
+
1292
1670
  /**
1293
- * Generic function to transform object keys using a provided case conversion function
1294
- * @param data The object to transform
1295
- * @param convertCase The function to convert each key
1296
- * @returns A new object with transformed keys
1671
+ * PaginationManager handles the conversion between uniform cursor-based pagination
1672
+ * and the specific pagination type for each service
1297
1673
  */
1298
- function transformCaseKeys(data, convertCase) {
1299
- // Handle array of objects
1300
- if (Array.isArray(data)) {
1301
- return data.map(item => {
1302
- // If the array element is a primitive (string, number, etc.), return it as is
1303
- if (item === null || typeof item !== 'object' || typeof item === 'string') {
1304
- return item;
1305
- }
1306
- // Only recursively transform if it's actually an object
1307
- return transformCaseKeys(item, convertCase);
1308
- });
1674
+ class PaginationManager {
1675
+ /**
1676
+ * Create a pagination cursor for subsequent page requests
1677
+ */
1678
+ static createCursor({ pageInfo, type }) {
1679
+ if (!pageInfo.hasMore) {
1680
+ return undefined;
1681
+ }
1682
+ const cursorData = {
1683
+ type,
1684
+ pageSize: pageInfo.pageSize,
1685
+ };
1686
+ switch (type) {
1687
+ case PaginationType.OFFSET:
1688
+ if (pageInfo.currentPage) {
1689
+ cursorData.pageNumber = pageInfo.currentPage + 1;
1690
+ }
1691
+ break;
1692
+ case PaginationType.TOKEN:
1693
+ if (pageInfo.continuationToken) {
1694
+ cursorData.continuationToken = pageInfo.continuationToken;
1695
+ }
1696
+ else {
1697
+ return undefined; // No continuation token, can't continue
1698
+ }
1699
+ break;
1700
+ }
1701
+ return {
1702
+ value: encodeBase64(JSON.stringify(cursorData))
1703
+ };
1309
1704
  }
1310
- const result = {};
1311
- for (const [key, value] of Object.entries(data)) {
1312
- const transformedKey = convertCase(key);
1313
- // Recursively transform nested objects and arrays
1314
- if (value !== null && typeof value === 'object') {
1315
- result[transformedKey] = transformCaseKeys(value, convertCase);
1705
+ /**
1706
+ * Create a paginated response with navigation cursors
1707
+ */
1708
+ static createPaginatedResponse({ pageInfo, type }, items) {
1709
+ const nextCursor = PaginationManager.createCursor({ pageInfo, type });
1710
+ // Create previous page cursor if applicable
1711
+ let previousCursor = undefined;
1712
+ if (pageInfo.currentPage && pageInfo.currentPage > 1) {
1713
+ const prevCursorData = {
1714
+ type,
1715
+ pageNumber: pageInfo.currentPage - 1,
1716
+ pageSize: pageInfo.pageSize,
1717
+ };
1718
+ previousCursor = {
1719
+ value: encodeBase64(JSON.stringify(prevCursorData))
1720
+ };
1316
1721
  }
1317
- else {
1318
- result[transformedKey] = value;
1722
+ // Calculate total pages if we have totalCount and pageSize
1723
+ let totalPages = undefined;
1724
+ if (pageInfo.totalCount !== undefined && pageInfo.pageSize) {
1725
+ totalPages = Math.ceil(pageInfo.totalCount / pageInfo.pageSize);
1319
1726
  }
1727
+ // Determine if this pagination type supports page jumping
1728
+ const supportsPageJump = type === PaginationType.OFFSET;
1729
+ // Create the result object with all fields, then filter out undefined values
1730
+ const result = filterUndefined({
1731
+ items,
1732
+ totalCount: pageInfo.totalCount,
1733
+ hasNextPage: pageInfo.hasMore,
1734
+ nextCursor: nextCursor,
1735
+ previousCursor: previousCursor,
1736
+ currentPage: pageInfo.currentPage,
1737
+ totalPages,
1738
+ supportsPageJump
1739
+ });
1740
+ return result;
1320
1741
  }
1321
- return result;
1322
- }
1323
- /**
1324
- * Transforms an object's keys from PascalCase to camelCase
1325
- * @param data The object with PascalCase keys
1326
- * @returns A new object with all keys converted to camelCase
1327
- *
1328
- * @example
1329
- * ```typescript
1330
- * // Simple object
1331
- * pascalToCamelCaseKeys({ Id: "123", TaskName: "Invoice" });
1332
- * // Result: { id: "123", taskName: "Invoice" }
1333
- *
1334
- * // Nested object
1335
- * pascalToCamelCaseKeys({
1336
- * TaskId: "456",
1337
- * TaskDetails: { AssignedUser: "John", Priority: "High" }
1338
- * });
1339
- * // Result: {
1340
- * // taskId: "456",
1341
- * // taskDetails: { assignedUser: "John", priority: "High" }
1342
- * // }
1343
- *
1344
- * // Array of objects
1345
- * pascalToCamelCaseKeys([
1346
- * { Id: "1", IsComplete: false },
1347
- * { Id: "2", IsComplete: true }
1348
- * ]);
1349
- * // Result: [
1350
- * // { id: "1", isComplete: false },
1351
- * // { id: "2", isComplete: true }
1352
- * // ]
1353
- * ```
1354
- */
1355
- function pascalToCamelCaseKeys(data) {
1356
- return transformCaseKeys(data, pascalToCamelCase);
1357
1742
  }
1743
+
1358
1744
  /**
1359
- * Transforms an object's keys from camelCase to PascalCase
1360
- * @param data The object with camelCase keys
1361
- * @returns A new object with all keys converted to PascalCase
1745
+ * Creates headers object from key-value pairs
1746
+ * @param headersObj - Object containing header key-value pairs
1747
+ * @returns Headers object with all values converted to strings
1362
1748
  *
1363
1749
  * @example
1364
1750
  * ```typescript
1365
- * // Simple object
1366
- * camelToPascalCaseKeys({ userId: "789", isActive: true });
1367
- * // Result: { UserId: "789", IsActive: true }
1751
+ * // Single header
1752
+ * const headers = createHeaders({ 'X-UIPATH-FolderKey': '1234567890' });
1368
1753
  *
1369
- * // Nested object
1370
- * camelToPascalCaseKeys({
1371
- * taskId: "ABC123",
1372
- * submissionData: { customerName: "XYZ Corp" }
1754
+ * // Multiple headers
1755
+ * const headers = createHeaders({
1756
+ * 'X-UIPATH-FolderKey': '1234567890',
1757
+ * 'X-UIPATH-OrganizationUnitId': 123,
1758
+ * 'Accept': 'application/json'
1373
1759
  * });
1374
- * // Result: {
1375
- * // TaskId: "ABC123",
1376
- * // SubmissionData: { CustomerName: "XYZ Corp" }
1377
- * // }
1378
1760
  *
1379
- * // Array of objects
1380
- * camelToPascalCaseKeys([
1381
- * { userId: "u1", roleType: "admin" },
1382
- * { userId: "u2", roleType: "user" }
1383
- * ]);
1384
- * // Result: [
1385
- * // { UserId: "u1", RoleType: "admin" },
1386
- * // { UserId: "u2", RoleType: "user" }
1387
- * // ]
1761
+ * // Using constants
1762
+ * import { FOLDER_KEY, FOLDER_ID } from '../constants/headers';
1763
+ * const headers = createHeaders({
1764
+ * [FOLDER_KEY]: 'abc-123',
1765
+ * [FOLDER_ID]: 456
1766
+ * });
1767
+ *
1768
+ * // Empty headers
1769
+ * const headers = createHeaders();
1388
1770
  * ```
1389
1771
  */
1390
- function camelToPascalCaseKeys(data) {
1391
- return transformCaseKeys(data, camelToPascalCase);
1772
+ function createHeaders(headersObj) {
1773
+ const headers = {};
1774
+ for (const [key, value] of Object.entries(headersObj)) {
1775
+ if (value !== undefined && value !== null) {
1776
+ headers[key] = value.toString();
1777
+ }
1778
+ }
1779
+ return headers;
1392
1780
  }
1781
+
1393
1782
  /**
1394
- * Maps a field value in an object using a provided mapping object.
1395
- * Returns a new object with the mapped field value.
1396
- *
1397
- * @param obj The object to map
1398
- * @param field The field name to map
1399
- * @param valueMap The mapping object (from input value to output value)
1400
- * @returns A new object with the mapped field value
1401
- *
1402
- * @example
1403
- * const statusMap = { 0: 'Unassigned', 1: 'Pending', 2: 'Completed' };
1404
- * const task = { status: 1, id: 123 };
1405
- * const mapped = mapFieldValue(task, 'status', statusMap);
1406
- * // mapped = { status: 'Pending', id: 123 }
1783
+ * Common constants used across the SDK
1407
1784
  */
1408
- function _mapFieldValue(obj, field, valueMap) {
1409
- const lookupKey = String(obj[field]);
1410
- return {
1411
- ...obj,
1412
- [field]: lookupKey in valueMap
1413
- ? valueMap[lookupKey]
1414
- : obj[field],
1415
- };
1416
- }
1417
1785
  /**
1418
- * General API response transformer with optional field value mapping.
1419
- *
1420
- * @param data - The API response data to transform
1421
- * @param options - Optional mapping options:
1422
- * - field: The field name to map (optional)
1423
- * - valueMap: The mapping object for the field (optional)
1424
- * - transform: A function to further transform the data (optional)
1425
- * @returns The transformed data, with field value mapped if specified
1426
- *
1427
- * @example
1428
- * // Just transform
1429
- * const result = applyDataTransforms(data);
1430
- *
1431
- * // Map a field value, then transform
1432
- * const result = applyDataTransforms(data, { field: 'status', valueMap: StatusMap });
1433
- *
1434
- * // Map a field value, then apply a custom transform
1435
- * const result = applyDataTransforms(data, { field: 'status', valueMap: StatusMap, transform: customTransform });
1786
+ * Prefix used for OData query parameters
1436
1787
  */
1437
- function applyDataTransforms(data, options) {
1438
- let result = data;
1439
- if (options?.field && options?.valueMap) {
1440
- result = _mapFieldValue(result, options.field, options.valueMap);
1441
- }
1442
- if (options?.transform) {
1443
- result = options.transform(result);
1444
- }
1445
- return result;
1446
- }
1788
+ const ODATA_PREFIX = '$';
1447
1789
  /**
1448
- * Adds a prefix to specified keys in an object, returning a new object.
1449
- * Only the provided keys are prefixed; all others are left unchanged.
1450
- *
1451
- * @param obj The source object
1452
- * @param prefix The prefix to add (e.g., '$')
1453
- * @param keys The keys to prefix (e.g., ['expand', 'filter'])
1454
- * @returns A new object with specified keys prefixed
1455
- *
1456
- * @example
1457
- * addPrefixToKeys({ expand: 'a', foo: 1 }, '$', ['expand']) // { $expand: 'a', foo: 1 }
1790
+ * HTTP methods
1458
1791
  */
1459
- function addPrefixToKeys(obj, prefix, keys) {
1460
- const result = {};
1461
- for (const [key, value] of Object.entries(obj)) {
1462
- if (keys.includes(key)) {
1463
- result[`${prefix}${key}`] = value;
1464
- }
1465
- else {
1466
- result[key] = value;
1467
- }
1468
- }
1469
- return result;
1470
- }
1792
+ const HTTP_METHODS = {
1793
+ GET: 'GET',
1794
+ POST: 'POST'};
1795
+ /**
1796
+ * OData pagination constants
1797
+ */
1798
+ const ODATA_PAGINATION = {
1799
+ /** Default field name for items in a paginated OData response */
1800
+ ITEMS_FIELD: 'value',
1801
+ /** Default field name for total count in a paginated OData response */
1802
+ TOTAL_COUNT_FIELD: '@odata.count'
1803
+ };
1804
+ /**
1805
+ * SLA Summary pagination constants for page-number-based pagination
1806
+ */
1807
+ const SLA_SUMMARY_PAGINATION = {
1808
+ /** Field name for items in SLA summary response */
1809
+ ITEMS_FIELD: 'data',
1810
+ /** Dot-notation path for total count in nested pagination object */
1811
+ TOTAL_COUNT_FIELD: 'pagination.totalCount'
1812
+ };
1813
+ /**
1814
+ * SLA Summary OFFSET pagination parameter names (page-number style, no skip conversion)
1815
+ */
1816
+ const SLA_SUMMARY_OFFSET_PARAMS = {
1817
+ /** Page size parameter name */
1818
+ PAGE_SIZE_PARAM: 'PageSize',
1819
+ /** Page number parameter name (sent directly, not converted to skip) */
1820
+ OFFSET_PARAM: 'PageNumber',
1821
+ /** No count param needed */
1822
+ COUNT_PARAM: undefined
1823
+ };
1824
+ /**
1825
+ * Process Instance pagination constants for token-based pagination
1826
+ */
1827
+ const PROCESS_INSTANCE_PAGINATION = {
1828
+ /** Field name for items in process instance response */
1829
+ ITEMS_FIELD: 'instances',
1830
+ /** Field name for continuation token in process instance response */
1831
+ CONTINUATION_TOKEN_FIELD: 'nextPage'
1832
+ };
1833
+ /**
1834
+ * OData OFFSET pagination parameter names (ODATA-style)
1835
+ */
1836
+ const ODATA_OFFSET_PARAMS = {
1837
+ /** OData page size parameter name */
1838
+ PAGE_SIZE_PARAM: '$top',
1839
+ /** OData offset parameter name */
1840
+ OFFSET_PARAM: '$skip',
1841
+ /** OData count parameter name */
1842
+ COUNT_PARAM: '$count'
1843
+ };
1844
+ /**
1845
+ * Bucket TOKEN pagination parameter names
1846
+ */
1847
+ const BUCKET_TOKEN_PARAMS = {
1848
+ /** Bucket page size parameter name */
1849
+ PAGE_SIZE_PARAM: 'takeHint',
1850
+ /** Bucket token parameter name */
1851
+ TOKEN_PARAM: 'continuationToken'
1852
+ };
1853
+ /**
1854
+ * Process Instance TOKEN pagination parameter names
1855
+ */
1856
+ const PROCESS_INSTANCE_TOKEN_PARAMS = {
1857
+ /** Process instance page size parameter name */
1858
+ PAGE_SIZE_PARAM: 'pageSize',
1859
+ /** Process instance token parameter name */
1860
+ TOKEN_PARAM: 'nextPage'
1861
+ };
1471
1862
 
1472
1863
  /**
1473
1864
  * Constants used throughout the pagination system
@@ -2268,7 +2659,7 @@ class CasesService extends BaseService {
2268
2659
  *
2269
2660
  * @param startTime - Start of the time range to query
2270
2661
  * @param endTime - End of the time range to query
2271
- * @param options - Optional settings for time bucketing granularity
2662
+ * @param options - Optional settings for filtering and time bucket granularity
2272
2663
  * @returns Promise resolving to an array of {@link InstanceStatusTimelineResponse}
2273
2664
  *
2274
2665
  * @example
@@ -2295,12 +2686,67 @@ class CasesService extends BaseService {
2295
2686
  *
2296
2687
  * @example
2297
2688
  * ```typescript
2689
+ * // Filter to a specific case process
2690
+ * const filtered = await cases.getInstanceStatusTimeline(startTime, endTime, {
2691
+ * processKeys: ['<processKey>'],
2692
+ * });
2693
+ * ```
2694
+ *
2695
+ * @example
2696
+ * ```typescript
2298
2697
  * // Get all-time data (from Unix epoch to now)
2299
2698
  * const allTime = await cases.getInstanceStatusTimeline(new Date(0), new Date());
2300
2699
  * ```
2301
2700
  */
2302
2701
  async getInstanceStatusTimeline(startTime, endTime, options) {
2303
- return fetchInstanceStatusTimeline(this.post.bind(this), startTime, endTime, true, options);
2702
+ const { data } = await this.post(MAESTRO_ENDPOINTS.INSIGHTS.INSTANCE_STATUS_BY_DATE, buildInsightsTimelineBody(startTime, endTime, true, options));
2703
+ return data ?? [];
2704
+ }
2705
+ /**
2706
+ * Get incident counts aggregated by time bucket for case management processes.
2707
+ *
2708
+ * Returns time-grouped counts of incidents that occurred within each bucket,
2709
+ * useful for rendering incident time-series charts. Use `groupBy` to control
2710
+ * the time bucket size (hour, day, or week) — defaults to day if not provided.
2711
+ *
2712
+ * @param startTime - Start of the time range to query
2713
+ * @param endTime - End of the time range to query
2714
+ * @param options - Optional settings for filtering and time bucket granularity
2715
+ * @returns Promise resolving to an array of {@link IncidentTimelineResponse}
2716
+ *
2717
+ * @example
2718
+ * ```typescript
2719
+ * // Get daily incident counts for the last 7 days
2720
+ * const now = new Date();
2721
+ * const sevenDaysAgo = new Date(Date.now() - 7 * 24 * 60 * 60 * 1000);
2722
+ * const incidents = await cases.getIncidentsTimeline(sevenDaysAgo, now);
2723
+ *
2724
+ * for (const incident of incidents) {
2725
+ * console.log(`${incident.startTime} → ${incident.endTime}: ${incident.count} incidents`);
2726
+ * }
2727
+ * ```
2728
+ *
2729
+ * @example
2730
+ * ```typescript
2731
+ * import { TimeInterval } from '@uipath/uipath-typescript/cases';
2732
+ *
2733
+ * // Get weekly breakdown
2734
+ * const incidents = await cases.getIncidentsTimeline(startTime, endTime, {
2735
+ * groupBy: TimeInterval.Week,
2736
+ * });
2737
+ * ```
2738
+ *
2739
+ * @example
2740
+ * ```typescript
2741
+ * // Filter to a specific case process
2742
+ * const filtered = await cases.getIncidentsTimeline(startTime, endTime, {
2743
+ * processKeys: ['<processKey>'],
2744
+ * });
2745
+ * ```
2746
+ */
2747
+ async getIncidentsTimeline(startTime, endTime, options) {
2748
+ const { data } = await this.post(MAESTRO_ENDPOINTS.INSIGHTS.INCIDENTS_BY_TIME_WINDOW, buildInsightsTimelineBody(startTime, endTime, true, options));
2749
+ return data?.dataPoints ?? [];
2304
2750
  }
2305
2751
  /**
2306
2752
  * Get the top 10 case processes ranked by failure count within a time range.
@@ -2395,33 +2841,78 @@ class CasesService extends BaseService {
2395
2841
  * Returns per-element execution counts (success, fail, terminated, paused, in-progress) and
2396
2842
  * duration percentile metrics (min, max, avg, p50, p95, p99) for BPMN elements within a case.
2397
2843
  *
2398
- * @param processKey - Process key to filter by
2399
- * @param packageId - Package identifier
2400
- * @param startTime - Start of the time range to query
2401
- * @param endTime - End of the time range to query
2402
- * @param packageVersion - Package version to filter by
2403
- * @returns Promise resolving to an array of {@link ElementStats}
2844
+ * @param request - Process scope + time range to aggregate over
2845
+ * @returns Promise resolving to an array of {@link ElementStats}
2846
+ * @example
2847
+ * ```typescript
2848
+ * // First, list cases to find the processKey, packageId, and available versions
2849
+ * const allCases = await cases.getAll();
2850
+ * const caseItem = allCases[0];
2851
+ *
2852
+ * // Get element metrics for that case
2853
+ * const elements = await cases.getElementStats({
2854
+ * processKey: caseItem.processKey,
2855
+ * packageId: caseItem.packageId,
2856
+ * packageVersion: caseItem.packageVersions[0],
2857
+ * startTime: new Date('2026-04-01'),
2858
+ * endTime: new Date(),
2859
+ * });
2860
+ *
2861
+ * // Find elements with failures
2862
+ * const failedElements = elements.filter(e => e.failCount > 0);
2863
+ * for (const element of failedElements) {
2864
+ * console.log(`Failed element: ${element.elementId}, failures: ${element.failCount}`);
2865
+ * }
2866
+ *
2867
+ * // Using bound method on a case — auto-fills processKey and packageId
2868
+ * const boundElements = await caseItem.getElementStats(
2869
+ * new Date('2026-04-01'),
2870
+ * new Date(),
2871
+ * caseItem.packageVersions[0]
2872
+ * );
2873
+ * ```
2874
+ */
2875
+ async getElementStats(request) {
2876
+ const { data } = await this.post(MAESTRO_ENDPOINTS.INSIGHTS.ELEMENT_COUNT_BY_STATUS, buildInsightsCommonBody(request));
2877
+ return data ?? [];
2878
+ }
2879
+ /**
2880
+ * Get instance stats for a case.
2881
+ *
2882
+ * Returns total instance counts broken down by status (running, completed, faulted, etc.)
2883
+ * and the average execution duration for all instances of a case within a time range.
2884
+ *
2885
+ * @param request - Process scope + time range to aggregate over
2886
+ * @returns Promise resolving to {@link InstanceStats}
2404
2887
  * @example
2405
2888
  * ```typescript
2406
- * // Get element metrics for a case
2407
- * const elements = await cases.getElementStats(
2408
- * '<processKey>',
2409
- * '<packageId>',
2889
+ * // First, list cases to find the processKey, packageId, and available versions
2890
+ * const allCases = await cases.getAll();
2891
+ * const caseItem = allCases[0];
2892
+ *
2893
+ * // Get instance status breakdown for that case
2894
+ * const counts = await cases.getInstanceStats({
2895
+ * processKey: caseItem.processKey,
2896
+ * packageId: caseItem.packageId,
2897
+ * packageVersion: caseItem.packageVersions[0],
2898
+ * startTime: new Date('2026-04-01'),
2899
+ * endTime: new Date(),
2900
+ * });
2901
+ *
2902
+ * console.log(`Total: ${counts.totalCount}`);
2903
+ * console.log(`Completed: ${counts.completedCount}, Faulted: ${counts.faultedCount}`);
2904
+ *
2905
+ * // Using bound method on a case — auto-fills processKey and packageId
2906
+ * const boundCounts = await caseItem.getInstanceStats(
2410
2907
  * new Date('2026-04-01'),
2411
2908
  * new Date(),
2412
- * '1.0.1'
2909
+ * caseItem.packageVersions[0]
2413
2910
  * );
2414
- *
2415
- * // Find elements with failures
2416
- * const failedElements = elements.filter(e => e.failCount > 0);
2417
- * for (const element of failedElements) {
2418
- * console.log(`Failed element: ${element.elementId}, failures: ${element.failCount}`);
2419
- * }
2420
2911
  * ```
2421
2912
  */
2422
- async getElementStats(processKey, packageId, startTime, endTime, packageVersion) {
2423
- const { data } = await this.post(MAESTRO_ENDPOINTS.INSIGHTS.ELEMENT_COUNT_BY_STATUS, buildElementCountByStatusBody(processKey, packageId, startTime, endTime, packageVersion));
2424
- return data ?? [];
2913
+ async getInstanceStats(request) {
2914
+ const { data } = await this.post(MAESTRO_ENDPOINTS.INSIGHTS.INSTANCE_COUNT_BY_STATUS, buildInsightsCommonBody(request));
2915
+ return transformData(data, InstanceStatsMap);
2425
2916
  }
2426
2917
  /**
2427
2918
  * Extract a readable case name from the packageId
@@ -2454,6 +2945,9 @@ __decorate([
2454
2945
  __decorate([
2455
2946
  track('Cases.GetInstanceStatusTimeline')
2456
2947
  ], CasesService.prototype, "getInstanceStatusTimeline", null);
2948
+ __decorate([
2949
+ track('Cases.GetIncidentsTimeline')
2950
+ ], CasesService.prototype, "getIncidentsTimeline", null);
2457
2951
  __decorate([
2458
2952
  track('Cases.GetTopFaultedCount')
2459
2953
  ], CasesService.prototype, "getTopFaultedCount", null);
@@ -2463,243 +2957,9 @@ __decorate([
2463
2957
  __decorate([
2464
2958
  track('Cases.GetElementStats')
2465
2959
  ], CasesService.prototype, "getElementStats", null);
2466
-
2467
- /**
2468
- * Process Incident Status
2469
- */
2470
- var ProcessIncidentStatus;
2471
- (function (ProcessIncidentStatus) {
2472
- ProcessIncidentStatus["Open"] = "Open";
2473
- ProcessIncidentStatus["Closed"] = "Closed";
2474
- })(ProcessIncidentStatus || (ProcessIncidentStatus = {}));
2475
- /**
2476
- * Process Incident Type
2477
- */
2478
- var ProcessIncidentType;
2479
- (function (ProcessIncidentType) {
2480
- ProcessIncidentType["System"] = "System";
2481
- ProcessIncidentType["User"] = "User";
2482
- ProcessIncidentType["Deployment"] = "Deployment";
2483
- })(ProcessIncidentType || (ProcessIncidentType = {}));
2484
- /**
2485
- * Process Incident Severity
2486
- */
2487
- var ProcessIncidentSeverity;
2488
- (function (ProcessIncidentSeverity) {
2489
- ProcessIncidentSeverity["Error"] = "Error";
2490
- ProcessIncidentSeverity["Warning"] = "Warning";
2491
- })(ProcessIncidentSeverity || (ProcessIncidentSeverity = {}));
2492
- /**
2493
- * Process Incident Debug Mode
2494
- */
2495
- var DebugMode;
2496
- (function (DebugMode) {
2497
- DebugMode["None"] = "None";
2498
- DebugMode["Default"] = "Default";
2499
- DebugMode["StepByStep"] = "StepByStep";
2500
- DebugMode["SingleStep"] = "SingleStep";
2501
- })(DebugMode || (DebugMode = {}));
2502
-
2503
- /**
2504
- * Case Instance Types
2505
- * Types and interfaces for Maestro case instance management
2506
- */
2507
- /**
2508
- * SLA status for a case instance
2509
- */
2510
- exports.SlaSummaryStatus = void 0;
2511
- (function (SlaSummaryStatus) {
2512
- /** Case is within SLA deadline */
2513
- SlaSummaryStatus["ON_TRACK"] = "On Track";
2514
- /** Case is approaching SLA deadline based on at-risk percentage threshold */
2515
- SlaSummaryStatus["AT_RISK"] = "At Risk";
2516
- /** Case has exceeded SLA deadline */
2517
- SlaSummaryStatus["OVERDUE"] = "Overdue";
2518
- /** Case instance has completed */
2519
- SlaSummaryStatus["COMPLETED"] = "Completed";
2520
- /** SLA status cannot be determined (no SLA deadline defined) */
2521
- SlaSummaryStatus["UNKNOWN"] = "Unknown";
2522
- })(exports.SlaSummaryStatus || (exports.SlaSummaryStatus = {}));
2523
- /**
2524
- * Instance status values for case instances and process instances
2525
- */
2526
- exports.InstanceStatus = void 0;
2527
- (function (InstanceStatus) {
2528
- /** Instance status not yet populated by the backend */
2529
- InstanceStatus["UNKNOWN"] = "";
2530
- InstanceStatus["CANCELLED"] = "Cancelled";
2531
- InstanceStatus["CANCELING"] = "Canceling";
2532
- InstanceStatus["COMPLETED"] = "Completed";
2533
- InstanceStatus["FAULTED"] = "Faulted";
2534
- InstanceStatus["PAUSED"] = "Paused";
2535
- InstanceStatus["PAUSING"] = "Pausing";
2536
- InstanceStatus["PENDING"] = "Pending";
2537
- InstanceStatus["RESUMING"] = "Resuming";
2538
- InstanceStatus["RETRYING"] = "Retrying";
2539
- InstanceStatus["RUNNING"] = "Running";
2540
- InstanceStatus["UPGRADING"] = "Upgrading";
2541
- })(exports.InstanceStatus || (exports.InstanceStatus = {}));
2542
- /**
2543
- * Case stage task type
2544
- */
2545
- exports.StageTaskType = void 0;
2546
- (function (StageTaskType) {
2547
- StageTaskType["EXTERNAL_AGENT"] = "external-agent";
2548
- StageTaskType["RPA"] = "rpa";
2549
- StageTaskType["AGENTIC_PROCESS"] = "process";
2550
- StageTaskType["AGENT"] = "agent";
2551
- StageTaskType["ACTION"] = "action";
2552
- StageTaskType["API_WORKFLOW"] = "api-workflow";
2553
- })(exports.StageTaskType || (exports.StageTaskType = {}));
2554
- /**
2555
- * Escalation recipient scope
2556
- */
2557
- exports.EscalationRecipientScope = void 0;
2558
- (function (EscalationRecipientScope) {
2559
- EscalationRecipientScope["USER"] = "user";
2560
- EscalationRecipientScope["USER_GROUP"] = "usergroup";
2561
- })(exports.EscalationRecipientScope || (exports.EscalationRecipientScope = {}));
2562
- /**
2563
- * Escalation action type
2564
- */
2565
- exports.EscalationActionType = void 0;
2566
- (function (EscalationActionType) {
2567
- EscalationActionType["NOTIFICATION"] = "notification";
2568
- })(exports.EscalationActionType || (exports.EscalationActionType = {}));
2569
- /**
2570
- * Escalation rule trigger type
2571
- */
2572
- exports.EscalationTriggerType = void 0;
2573
- (function (EscalationTriggerType) {
2574
- EscalationTriggerType["SLA_BREACHED"] = "sla-breached";
2575
- EscalationTriggerType["AT_RISK"] = "at-risk";
2576
- /** Default value when no escalation rule is defined */
2577
- EscalationTriggerType["NONE"] = "None";
2578
- })(exports.EscalationTriggerType || (exports.EscalationTriggerType = {}));
2579
- /**
2580
- * SLA duration unit
2581
- */
2582
- exports.SLADurationUnit = void 0;
2583
- (function (SLADurationUnit) {
2584
- SLADurationUnit["HOURS"] = "h";
2585
- SLADurationUnit["DAYS"] = "d";
2586
- SLADurationUnit["WEEKS"] = "w";
2587
- SLADurationUnit["MONTHS"] = "m";
2588
- })(exports.SLADurationUnit || (exports.SLADurationUnit = {}));
2589
-
2590
- /**
2591
- * Creates methods for a case instance
2592
- *
2593
- * @param instanceData - The case instance data (response from API)
2594
- * @param service - The case instance service instance
2595
- * @returns Object containing case instance methods
2596
- */
2597
- function createCaseInstanceMethods(instanceData, service) {
2598
- return {
2599
- async close(options) {
2600
- if (!instanceData.instanceId)
2601
- throw new Error('Case instance ID is undefined');
2602
- if (!instanceData.folderKey)
2603
- throw new Error('Case instance folder key is undefined');
2604
- return service.close(instanceData.instanceId, instanceData.folderKey, options);
2605
- },
2606
- async pause(options) {
2607
- if (!instanceData.instanceId)
2608
- throw new Error('Case instance ID is undefined');
2609
- if (!instanceData.folderKey)
2610
- throw new Error('Case instance folder key is undefined');
2611
- return service.pause(instanceData.instanceId, instanceData.folderKey, options);
2612
- },
2613
- async reopen(options) {
2614
- if (!instanceData.instanceId)
2615
- throw new Error('Case instance ID is undefined');
2616
- if (!instanceData.folderKey)
2617
- throw new Error('Case instance folder key is undefined');
2618
- return service.reopen(instanceData.instanceId, instanceData.folderKey, options);
2619
- },
2620
- async resume(options) {
2621
- if (!instanceData.instanceId)
2622
- throw new Error('Case instance ID is undefined');
2623
- if (!instanceData.folderKey)
2624
- throw new Error('Case instance folder key is undefined');
2625
- return service.resume(instanceData.instanceId, instanceData.folderKey, options);
2626
- },
2627
- async getExecutionHistory() {
2628
- if (!instanceData.instanceId)
2629
- throw new Error('Case instance ID is undefined');
2630
- if (!instanceData.folderKey)
2631
- throw new Error('Case instance folder key is undefined');
2632
- return service.getExecutionHistory(instanceData.instanceId, instanceData.folderKey);
2633
- },
2634
- async getStages() {
2635
- if (!instanceData.instanceId)
2636
- throw new Error('Case instance ID is undefined');
2637
- if (!instanceData.folderKey)
2638
- throw new Error('Case instance folder key is undefined');
2639
- return service.getStages(instanceData.instanceId, instanceData.folderKey);
2640
- },
2641
- async getActionTasks(options) {
2642
- if (!instanceData.instanceId)
2643
- throw new Error('Case instance ID is undefined');
2644
- return service.getActionTasks(instanceData.instanceId, options);
2645
- },
2646
- async getSlaSummary(options) {
2647
- if (!instanceData.instanceId)
2648
- throw new Error('Case instance ID is undefined');
2649
- return service.getSlaSummary({ ...options, caseInstanceId: instanceData.instanceId });
2650
- },
2651
- async getStagesSlaSummary() {
2652
- if (!instanceData.instanceId)
2653
- throw new Error('Case instance ID is undefined');
2654
- return service.getStagesSlaSummary({ caseInstanceId: instanceData.instanceId });
2655
- }
2656
- };
2657
- }
2658
- /**
2659
- * Creates an actionable case instance by combining API case instance data with operational methods.
2660
- *
2661
- * @param instanceData - The case instance data from API
2662
- * @param service - The case instance service instance
2663
- * @returns A case instance object with added methods
2664
- */
2665
- function createCaseInstanceWithMethods(instanceData, service) {
2666
- const methods = createCaseInstanceMethods(instanceData, service);
2667
- return Object.assign({}, instanceData, methods);
2668
- }
2669
-
2670
- /**
2671
- * Insights Types
2672
- * Shared types for Maestro insights analytics endpoints
2673
- */
2674
- /**
2675
- * Time bucketing granularity for insights time-series queries.
2676
- *
2677
- * Controls how data points are grouped on the time axis.
2678
- */
2679
- exports.TimeInterval = void 0;
2680
- (function (TimeInterval) {
2681
- /** Group data points by hour */
2682
- TimeInterval["Hour"] = "HOUR";
2683
- /** Group data points by day */
2684
- TimeInterval["Day"] = "DAY";
2685
- /** Group data points by week */
2686
- TimeInterval["Week"] = "WEEK";
2687
- })(exports.TimeInterval || (exports.TimeInterval = {}));
2688
- /**
2689
- * Final instance statuses returned by the instance status timeline endpoint.
2690
- *
2691
- * Only includes statuses where the instance has finished execution — Completed, Faulted, or Cancelled.
2692
- * Active statuses like Running or Paused are not included.
2693
- */
2694
- exports.InstanceFinalStatus = void 0;
2695
- (function (InstanceFinalStatus) {
2696
- /** Instance completed successfully */
2697
- InstanceFinalStatus["Completed"] = "Completed";
2698
- /** Instance encountered an error */
2699
- InstanceFinalStatus["Faulted"] = "Faulted";
2700
- /** Instance was cancelled */
2701
- InstanceFinalStatus["Cancelled"] = "Cancelled";
2702
- })(exports.InstanceFinalStatus || (exports.InstanceFinalStatus = {}));
2960
+ __decorate([
2961
+ track('Cases.GetInstanceStats')
2962
+ ], CasesService.prototype, "getInstanceStats", null);
2703
2963
 
2704
2964
  /**
2705
2965
  * Maps fields for Case Instance entities to ensure consistent naming
@@ -3123,6 +3383,10 @@ class TaskService extends BaseService {
3123
3383
  const transformedTask = transformData(pascalToCamelCaseKeys(task), TaskMap);
3124
3384
  return createTaskWithMethods(applyDataTransforms(transformedTask, { field: 'status', valueMap: TaskStatusMap }), this);
3125
3385
  };
3386
+ // Rewrite renamed SDK field names → API names inside OData strings
3387
+ // before delegating, mirroring the transformRequest pattern used for
3388
+ // request bodies.
3389
+ const apiOptions = options ? transformOptions(options, TaskMap) : options;
3126
3390
  return PaginationHelpers.getAll({
3127
3391
  serviceAccess: this.createPaginationServiceAccess(),
3128
3392
  getEndpoint: () => endpoint,
@@ -3139,7 +3403,7 @@ class TaskService extends BaseService {
3139
3403
  countParam: ODATA_OFFSET_PARAMS.COUNT_PARAM // OData OFFSET parameter
3140
3404
  }
3141
3405
  }
3142
- }, options);
3406
+ }, apiOptions);
3143
3407
  }
3144
3408
  /**
3145
3409
  * Gets a task by ID
@@ -3175,9 +3439,10 @@ class TaskService extends BaseService {
3175
3439
  const headers = createHeaders({ [FOLDER_ID]: folderId });
3176
3440
  // Add default expand parameters
3177
3441
  const modifiedOptions = this.addDefaultExpand(restOptions);
3178
- // prefix all keys in options
3179
- const keysToPrefix = Object.keys(modifiedOptions);
3180
- const apiOptions = addPrefixToKeys(modifiedOptions, ODATA_PREFIX, keysToPrefix);
3442
+ // Rewrite renamed SDK field names → API names inside OData strings,
3443
+ // then prefix all keys for OData.
3444
+ const apiFieldOptions = transformOptions(modifiedOptions, TaskMap);
3445
+ const apiOptions = addPrefixToKeys(apiFieldOptions, ODATA_PREFIX, Object.keys(apiFieldOptions));
3181
3446
  const response = await this.get(TASK_ENDPOINTS.GET_BY_ID(id), {
3182
3447
  params: apiOptions,
3183
3448
  headers