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