@uipath/uipath-typescript 1.3.7 → 1.3.9
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/dist/assets/index.cjs +64 -274
- package/dist/assets/index.d.ts +1 -0
- package/dist/assets/index.mjs +64 -274
- package/dist/attachments/index.cjs +62 -271
- package/dist/attachments/index.d.ts +1 -0
- package/dist/attachments/index.mjs +62 -271
- package/dist/buckets/index.cjs +93 -274
- package/dist/buckets/index.d.ts +51 -1
- package/dist/buckets/index.mjs +93 -274
- package/dist/cases/index.cjs +580 -336
- package/dist/cases/index.d.ts +690 -3
- package/dist/cases/index.mjs +581 -337
- package/dist/conversational-agent/index.cjs +110 -285
- package/dist/conversational-agent/index.d.ts +63 -12
- package/dist/conversational-agent/index.mjs +110 -286
- package/dist/core/index.cjs +39 -289
- package/dist/core/index.d.ts +9 -98
- package/dist/core/index.mjs +40 -275
- package/dist/document-understanding/index.cjs +18 -1
- package/dist/document-understanding/index.d.ts +636 -610
- package/dist/document-understanding/index.mjs +18 -1
- package/dist/entities/index.cjs +64 -274
- package/dist/entities/index.d.ts +1 -0
- package/dist/entities/index.mjs +64 -274
- package/dist/feedback/index.cjs +313 -276
- package/dist/feedback/index.d.ts +418 -12
- package/dist/feedback/index.mjs +313 -276
- package/dist/index.cjs +777 -297
- package/dist/index.d.ts +2005 -721
- package/dist/index.mjs +777 -283
- package/dist/index.umd.js +966 -162
- package/dist/jobs/index.cjs +64 -274
- package/dist/jobs/index.d.ts +1 -0
- package/dist/jobs/index.mjs +64 -274
- package/dist/maestro-processes/index.cjs +1789 -1686
- package/dist/maestro-processes/index.d.ts +431 -2
- package/dist/maestro-processes/index.mjs +1790 -1687
- package/dist/processes/index.cjs +64 -274
- package/dist/processes/index.d.ts +1 -0
- package/dist/processes/index.mjs +64 -274
- package/dist/queues/index.cjs +64 -274
- package/dist/queues/index.d.ts +1 -0
- package/dist/queues/index.mjs +64 -274
- package/dist/tasks/index.cjs +64 -274
- package/dist/tasks/index.d.ts +1 -0
- package/dist/tasks/index.mjs +64 -274
- package/package.json +8 -10
package/dist/cases/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getOrCreateClient, createTrack, createTrackEvent } from '@uipath/core-telemetry';
|
|
2
2
|
|
|
3
3
|
/******************************************************************************
|
|
4
4
|
Copyright (c) Microsoft Corporation.
|
|
@@ -54,6 +54,130 @@ var ProcessType;
|
|
|
54
54
|
ProcessType["CaseManagement"] = "CaseManagement";
|
|
55
55
|
})(ProcessType || (ProcessType = {}));
|
|
56
56
|
|
|
57
|
+
/**
|
|
58
|
+
* Base path constants for different services
|
|
59
|
+
*/
|
|
60
|
+
const ORCHESTRATOR_BASE = 'orchestrator_';
|
|
61
|
+
const PIMS_BASE = 'pims_';
|
|
62
|
+
const INSIGHTS_RTM_BASE = 'insightsrtm_';
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Orchestrator Service Endpoints
|
|
66
|
+
*/
|
|
67
|
+
/**
|
|
68
|
+
* Task Service (Action Center) Endpoints
|
|
69
|
+
*/
|
|
70
|
+
const TASK_ENDPOINTS = {
|
|
71
|
+
CREATE_GENERIC_TASK: `${ORCHESTRATOR_BASE}/tasks/GenericTasks/CreateTask`,
|
|
72
|
+
GET_TASK_USERS: (folderId) => `${ORCHESTRATOR_BASE}/odata/Tasks/UiPath.Server.Configuration.OData.GetTaskUsers(organizationUnitId=${folderId})`,
|
|
73
|
+
GET_TASKS_ACROSS_FOLDERS: `${ORCHESTRATOR_BASE}/odata/Tasks/UiPath.Server.Configuration.OData.GetTasksAcrossFolders`,
|
|
74
|
+
GET_TASKS_ACROSS_FOLDERS_ADMIN: `${ORCHESTRATOR_BASE}/odata/Tasks/UiPath.Server.Configuration.OData.GetTasksAcrossFoldersForAdmin`,
|
|
75
|
+
GET_BY_ID: (id) => `${ORCHESTRATOR_BASE}/odata/Tasks(${id})`,
|
|
76
|
+
ASSIGN_TASKS: `${ORCHESTRATOR_BASE}/odata/Tasks/UiPath.Server.Configuration.OData.AssignTasks`,
|
|
77
|
+
REASSIGN_TASKS: `${ORCHESTRATOR_BASE}/odata/Tasks/UiPath.Server.Configuration.OData.ReassignTasks`,
|
|
78
|
+
UNASSIGN_TASKS: `${ORCHESTRATOR_BASE}/odata/Tasks/UiPath.Server.Configuration.OData.UnassignTasks`,
|
|
79
|
+
COMPLETE_FORM_TASK: `${ORCHESTRATOR_BASE}/forms/TaskForms/CompleteTask`,
|
|
80
|
+
COMPLETE_APP_TASK: `${ORCHESTRATOR_BASE}/tasks/AppTasks/CompleteAppTask`,
|
|
81
|
+
COMPLETE_GENERIC_TASK: `${ORCHESTRATOR_BASE}/tasks/GenericTasks/CompleteTask`,
|
|
82
|
+
GET_TASK_FORM_BY_ID: `${ORCHESTRATOR_BASE}/forms/TaskForms/GetTaskFormById`,
|
|
83
|
+
GET_GENERIC_TASK_BY_ID: `${ORCHESTRATOR_BASE}/tasks/GenericTasks/GetTaskDataById`,
|
|
84
|
+
GET_APP_TASK_BY_ID: `${ORCHESTRATOR_BASE}/tasks/AppTasks/GetAppTaskById`,
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Maestro Service Endpoints
|
|
89
|
+
*/
|
|
90
|
+
/**
|
|
91
|
+
* Maestro Process Service Endpoints
|
|
92
|
+
*/
|
|
93
|
+
const MAESTRO_ENDPOINTS = {
|
|
94
|
+
PROCESSES: {
|
|
95
|
+
GET_ALL: `${PIMS_BASE}/api/v1/processes/summary`,
|
|
96
|
+
GET_SETTINGS: (processKey) => `${PIMS_BASE}/api/v1/processes/${processKey}/settings`,
|
|
97
|
+
},
|
|
98
|
+
INSTANCES: {
|
|
99
|
+
GET_ALL: `${PIMS_BASE}/api/v1/instances`,
|
|
100
|
+
GET_BY_ID: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}`,
|
|
101
|
+
GET_EXECUTION_HISTORY: (instanceId) => `${PIMS_BASE}/api/v1/spans/${instanceId}`,
|
|
102
|
+
GET_BPMN: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/bpmn`,
|
|
103
|
+
GET_VARIABLES: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/variables`,
|
|
104
|
+
CANCEL: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/cancel`,
|
|
105
|
+
PAUSE: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/pause`,
|
|
106
|
+
RESUME: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/resume`,
|
|
107
|
+
},
|
|
108
|
+
INCIDENTS: {
|
|
109
|
+
GET_ALL: `${PIMS_BASE}/api/v1/incidents/summary`,
|
|
110
|
+
GET_BY_PROCESS: (processKey) => `${PIMS_BASE}/api/v1/incidents/process/${processKey}`,
|
|
111
|
+
GET_BY_INSTANCE: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/incidents`,
|
|
112
|
+
},
|
|
113
|
+
CASES: {
|
|
114
|
+
GET_CASE_JSON: (instanceId) => `${PIMS_BASE}/api/v1/cases/${instanceId}/case-json`,
|
|
115
|
+
GET_ELEMENT_EXECUTIONS: (instanceId) => `${PIMS_BASE}/api/v1/element-executions/case-instances/${instanceId}`,
|
|
116
|
+
REOPEN: (instanceId) => `${PIMS_BASE}/api/v1/cases/${instanceId}/reopen`,
|
|
117
|
+
},
|
|
118
|
+
INSIGHTS: {
|
|
119
|
+
/** SLA summary for case instances */
|
|
120
|
+
SLA_SUMMARY: `${INSIGHTS_RTM_BASE}/caseManagement/slaSummary`,
|
|
121
|
+
/** Stages summary for case instances */
|
|
122
|
+
STAGES_SUMMARY: `${INSIGHTS_RTM_BASE}/caseManagement/stages`,
|
|
123
|
+
/** Top processes ranked by run count */
|
|
124
|
+
TOP_PROCESSES_BY_RUN_COUNT: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/TopProcessesByRunCount`,
|
|
125
|
+
/** Top processes ranked by failure count */
|
|
126
|
+
TOP_PROCESSES_WITH_FAILURE: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/TopProcesseswithFailure`,
|
|
127
|
+
/** Instance status aggregated by date for time-series charts */
|
|
128
|
+
INSTANCE_STATUS_BY_DATE: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/InstanceStatusByDate`,
|
|
129
|
+
/** Top processes ranked by total duration */
|
|
130
|
+
TOP_PROCESSES_BY_DURATION: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/TopProcessesByDuration`,
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Builds the request body for Insights RTM "top" endpoints.
|
|
136
|
+
*
|
|
137
|
+
* @param startTime - Start of the time range to query
|
|
138
|
+
* @param endTime - End of the time range to query
|
|
139
|
+
* @param isCaseManagement - Whether to filter for case management processes
|
|
140
|
+
* @param options - Optional filters (packageId, processKey, version)
|
|
141
|
+
* @returns Request body for the Insights RTM endpoint
|
|
142
|
+
* @internal
|
|
143
|
+
*/
|
|
144
|
+
function buildInsightsTopBody(startTime, endTime, isCaseManagement, options) {
|
|
145
|
+
return {
|
|
146
|
+
commonParams: {
|
|
147
|
+
startTime: startTime.getTime(),
|
|
148
|
+
endTime: endTime.getTime(),
|
|
149
|
+
isCaseManagement,
|
|
150
|
+
...(options?.packageId ? { packageId: options.packageId } : {}),
|
|
151
|
+
...(options?.processKey ? { processKey: options.processKey } : {}),
|
|
152
|
+
...(options?.version ? { version: options.version } : {}),
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Fetches instance status timeline from the Insights API.
|
|
158
|
+
* Shared implementation used by both MaestroProcessesService and CasesService.
|
|
159
|
+
*
|
|
160
|
+
* @param postFn - Bound post method from a BaseService subclass
|
|
161
|
+
* @param startTime - Start of the time range to query
|
|
162
|
+
* @param endTime - End of the time range to query
|
|
163
|
+
* @param isCaseManagement - Whether to filter for case management processes
|
|
164
|
+
* @param options - Optional settings for time bucketing granularity
|
|
165
|
+
* @returns Promise resolving to an array of instance status timeline entries
|
|
166
|
+
* @internal
|
|
167
|
+
*/
|
|
168
|
+
async function fetchInstanceStatusTimeline(postFn, startTime, endTime, isCaseManagement, options) {
|
|
169
|
+
const response = await postFn(MAESTRO_ENDPOINTS.INSIGHTS.INSTANCE_STATUS_BY_DATE, {
|
|
170
|
+
commonParams: {
|
|
171
|
+
startTime: startTime.getTime(),
|
|
172
|
+
endTime: endTime.getTime(),
|
|
173
|
+
isCaseManagement,
|
|
174
|
+
},
|
|
175
|
+
timeSliceUnit: options?.groupBy,
|
|
176
|
+
timezoneOffset: new Date().getTimezoneOffset() * -1,
|
|
177
|
+
});
|
|
178
|
+
return response.data ?? [];
|
|
179
|
+
}
|
|
180
|
+
|
|
57
181
|
/**
|
|
58
182
|
* Type guards for error response types
|
|
59
183
|
*/
|
|
@@ -662,6 +786,27 @@ var PaginationType;
|
|
|
662
786
|
/**
|
|
663
787
|
* Collection of utility functions for working with objects
|
|
664
788
|
*/
|
|
789
|
+
/**
|
|
790
|
+
* Resolves a field value from an object, supporting both direct keys (e.g., '@odata.count')
|
|
791
|
+
* and dot-separated nested paths (e.g., 'pagination.totalCount').
|
|
792
|
+
* Direct key match takes priority over nested traversal.
|
|
793
|
+
*/
|
|
794
|
+
function resolveNestedField(data, fieldPath) {
|
|
795
|
+
if (!data) {
|
|
796
|
+
return undefined;
|
|
797
|
+
}
|
|
798
|
+
if (fieldPath in data) {
|
|
799
|
+
return data[fieldPath];
|
|
800
|
+
}
|
|
801
|
+
if (!fieldPath.includes('.')) {
|
|
802
|
+
return undefined;
|
|
803
|
+
}
|
|
804
|
+
let value = data;
|
|
805
|
+
for (const part of fieldPath.split('.')) {
|
|
806
|
+
value = value?.[part];
|
|
807
|
+
}
|
|
808
|
+
return value;
|
|
809
|
+
}
|
|
665
810
|
/**
|
|
666
811
|
* Filters out undefined values from an object
|
|
667
812
|
* @param obj The source object
|
|
@@ -900,6 +1045,26 @@ const ODATA_PAGINATION = {
|
|
|
900
1045
|
/** Default field name for total count in a paginated OData response */
|
|
901
1046
|
TOTAL_COUNT_FIELD: '@odata.count'
|
|
902
1047
|
};
|
|
1048
|
+
/**
|
|
1049
|
+
* SLA Summary pagination constants for page-number-based pagination
|
|
1050
|
+
*/
|
|
1051
|
+
const SLA_SUMMARY_PAGINATION = {
|
|
1052
|
+
/** Field name for items in SLA summary response */
|
|
1053
|
+
ITEMS_FIELD: 'data',
|
|
1054
|
+
/** Dot-notation path for total count in nested pagination object */
|
|
1055
|
+
TOTAL_COUNT_FIELD: 'pagination.totalCount'
|
|
1056
|
+
};
|
|
1057
|
+
/**
|
|
1058
|
+
* SLA Summary OFFSET pagination parameter names (page-number style, no skip conversion)
|
|
1059
|
+
*/
|
|
1060
|
+
const SLA_SUMMARY_OFFSET_PARAMS = {
|
|
1061
|
+
/** Page size parameter name */
|
|
1062
|
+
PAGE_SIZE_PARAM: 'PageSize',
|
|
1063
|
+
/** Page number parameter name (sent directly, not converted to skip) */
|
|
1064
|
+
OFFSET_PARAM: 'PageNumber',
|
|
1065
|
+
/** No count param needed */
|
|
1066
|
+
COUNT_PARAM: undefined
|
|
1067
|
+
};
|
|
903
1068
|
/**
|
|
904
1069
|
* Process Instance pagination constants for token-based pagination
|
|
905
1070
|
*/
|
|
@@ -939,6 +1104,14 @@ const PROCESS_INSTANCE_TOKEN_PARAMS = {
|
|
|
939
1104
|
TOKEN_PARAM: 'nextPage'
|
|
940
1105
|
};
|
|
941
1106
|
|
|
1107
|
+
/**
|
|
1108
|
+
* Converts a UTC timestamp string (e.g., "5/8/2026 11:20:17 AM") to ISO 8601 UTC format.
|
|
1109
|
+
* Returns the original value if parsing fails.
|
|
1110
|
+
*/
|
|
1111
|
+
function toISOUtc(value) {
|
|
1112
|
+
const date = new Date(value + ' UTC');
|
|
1113
|
+
return isNaN(date.getTime()) ? value : date.toISOString();
|
|
1114
|
+
}
|
|
942
1115
|
/**
|
|
943
1116
|
* Transforms data by mapping fields according to the provided field mapping
|
|
944
1117
|
* @param data The source data to transform
|
|
@@ -1398,7 +1571,8 @@ class PaginationHelpers {
|
|
|
1398
1571
|
// Extract and transform items from response
|
|
1399
1572
|
// Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N })
|
|
1400
1573
|
const rawItems = Array.isArray(response.data) ? response.data : response.data?.[itemsField];
|
|
1401
|
-
const
|
|
1574
|
+
const rawTotalCount = Array.isArray(response.data) ? undefined : resolveNestedField(response.data, totalCountField);
|
|
1575
|
+
const totalCount = typeof rawTotalCount === 'number' ? rawTotalCount : undefined;
|
|
1402
1576
|
// Parse items - automatically handle JSON string responses
|
|
1403
1577
|
const parsedItems = typeof rawItems === 'string' ? JSON.parse(rawItems) : (rawItems || []);
|
|
1404
1578
|
const items = transformFn ? parsedItems.map(transformFn) : parsedItems;
|
|
@@ -1695,9 +1869,17 @@ class BaseService {
|
|
|
1695
1869
|
const pageSizeParam = paginationParams?.pageSizeParam || ODATA_OFFSET_PARAMS.PAGE_SIZE_PARAM;
|
|
1696
1870
|
const offsetParam = paginationParams?.offsetParam || ODATA_OFFSET_PARAMS.OFFSET_PARAM;
|
|
1697
1871
|
const countParam = paginationParams?.countParam || ODATA_OFFSET_PARAMS.COUNT_PARAM;
|
|
1872
|
+
// When true (default), converts pageNumber to a skip/offset value (e.g., page 3 with pageSize 10 → skip 20).
|
|
1873
|
+
// When false, passes pageNumber directly as the offset param — used by APIs that accept a page number instead of a record offset.
|
|
1874
|
+
const convertToSkip = paginationParams?.convertToSkip ?? true;
|
|
1698
1875
|
requestParams[pageSizeParam] = limitedPageSize;
|
|
1699
|
-
if (
|
|
1700
|
-
|
|
1876
|
+
if (convertToSkip) {
|
|
1877
|
+
if (params.pageNumber && params.pageNumber > 1) {
|
|
1878
|
+
requestParams[offsetParam] = (params.pageNumber - 1) * limitedPageSize;
|
|
1879
|
+
}
|
|
1880
|
+
}
|
|
1881
|
+
else {
|
|
1882
|
+
requestParams[offsetParam] = params.pageNumber || 1;
|
|
1701
1883
|
}
|
|
1702
1884
|
{
|
|
1703
1885
|
requestParams[countParam] = true;
|
|
@@ -1728,7 +1910,8 @@ class BaseService {
|
|
|
1728
1910
|
// Extract items and metadata
|
|
1729
1911
|
// Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N })
|
|
1730
1912
|
const items = Array.isArray(response.data) ? response.data : (response.data[itemsField] || []);
|
|
1731
|
-
const
|
|
1913
|
+
const rawTotalCount = Array.isArray(response.data) ? undefined : resolveNestedField(response.data, totalCountField);
|
|
1914
|
+
const totalCount = typeof rawTotalCount === 'number' ? rawTotalCount : undefined;
|
|
1732
1915
|
const continuationToken = response.data[continuationTokenField];
|
|
1733
1916
|
// Determine if there are more pages
|
|
1734
1917
|
const hasMore = this.determineHasMorePages(paginationType, {
|
|
@@ -1774,340 +1957,33 @@ class BaseService {
|
|
|
1774
1957
|
_BaseService_apiClient = new WeakMap();
|
|
1775
1958
|
|
|
1776
1959
|
/**
|
|
1777
|
-
*
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
*
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
const TASK_ENDPOINTS = {
|
|
1789
|
-
CREATE_GENERIC_TASK: `${ORCHESTRATOR_BASE}/tasks/GenericTasks/CreateTask`,
|
|
1790
|
-
GET_TASK_USERS: (folderId) => `${ORCHESTRATOR_BASE}/odata/Tasks/UiPath.Server.Configuration.OData.GetTaskUsers(organizationUnitId=${folderId})`,
|
|
1791
|
-
GET_TASKS_ACROSS_FOLDERS: `${ORCHESTRATOR_BASE}/odata/Tasks/UiPath.Server.Configuration.OData.GetTasksAcrossFolders`,
|
|
1792
|
-
GET_TASKS_ACROSS_FOLDERS_ADMIN: `${ORCHESTRATOR_BASE}/odata/Tasks/UiPath.Server.Configuration.OData.GetTasksAcrossFoldersForAdmin`,
|
|
1793
|
-
GET_BY_ID: (id) => `${ORCHESTRATOR_BASE}/odata/Tasks(${id})`,
|
|
1794
|
-
ASSIGN_TASKS: `${ORCHESTRATOR_BASE}/odata/Tasks/UiPath.Server.Configuration.OData.AssignTasks`,
|
|
1795
|
-
REASSIGN_TASKS: `${ORCHESTRATOR_BASE}/odata/Tasks/UiPath.Server.Configuration.OData.ReassignTasks`,
|
|
1796
|
-
UNASSIGN_TASKS: `${ORCHESTRATOR_BASE}/odata/Tasks/UiPath.Server.Configuration.OData.UnassignTasks`,
|
|
1797
|
-
COMPLETE_FORM_TASK: `${ORCHESTRATOR_BASE}/forms/TaskForms/CompleteTask`,
|
|
1798
|
-
COMPLETE_APP_TASK: `${ORCHESTRATOR_BASE}/tasks/AppTasks/CompleteAppTask`,
|
|
1799
|
-
COMPLETE_GENERIC_TASK: `${ORCHESTRATOR_BASE}/tasks/GenericTasks/CompleteTask`,
|
|
1800
|
-
GET_TASK_FORM_BY_ID: `${ORCHESTRATOR_BASE}/forms/TaskForms/GetTaskFormById`,
|
|
1801
|
-
GET_GENERIC_TASK_BY_ID: `${ORCHESTRATOR_BASE}/tasks/GenericTasks/GetTaskDataById`,
|
|
1802
|
-
GET_APP_TASK_BY_ID: `${ORCHESTRATOR_BASE}/tasks/AppTasks/GetAppTaskById`,
|
|
1803
|
-
};
|
|
1804
|
-
|
|
1805
|
-
/**
|
|
1806
|
-
* Maestro Service Endpoints
|
|
1807
|
-
*/
|
|
1808
|
-
/**
|
|
1809
|
-
* Maestro Process Service Endpoints
|
|
1810
|
-
*/
|
|
1811
|
-
const MAESTRO_ENDPOINTS = {
|
|
1812
|
-
PROCESSES: {
|
|
1813
|
-
GET_ALL: `${PIMS_BASE}/api/v1/processes/summary`,
|
|
1814
|
-
GET_SETTINGS: (processKey) => `${PIMS_BASE}/api/v1/processes/${processKey}/settings`,
|
|
1815
|
-
},
|
|
1816
|
-
INSTANCES: {
|
|
1817
|
-
GET_ALL: `${PIMS_BASE}/api/v1/instances`,
|
|
1818
|
-
GET_BY_ID: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}`,
|
|
1819
|
-
GET_EXECUTION_HISTORY: (instanceId) => `${PIMS_BASE}/api/v1/spans/${instanceId}`,
|
|
1820
|
-
GET_BPMN: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/bpmn`,
|
|
1821
|
-
GET_VARIABLES: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/variables`,
|
|
1822
|
-
CANCEL: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/cancel`,
|
|
1823
|
-
PAUSE: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/pause`,
|
|
1824
|
-
RESUME: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/resume`,
|
|
1825
|
-
},
|
|
1826
|
-
INCIDENTS: {
|
|
1827
|
-
GET_ALL: `${PIMS_BASE}/api/v1/incidents/summary`,
|
|
1828
|
-
GET_BY_PROCESS: (processKey) => `${PIMS_BASE}/api/v1/incidents/process/${processKey}`,
|
|
1829
|
-
GET_BY_INSTANCE: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/incidents`,
|
|
1830
|
-
},
|
|
1831
|
-
CASES: {
|
|
1832
|
-
GET_CASE_JSON: (instanceId) => `${PIMS_BASE}/api/v1/cases/${instanceId}/case-json`,
|
|
1833
|
-
GET_ELEMENT_EXECUTIONS: (instanceId) => `${PIMS_BASE}/api/v1/element-executions/case-instances/${instanceId}`,
|
|
1834
|
-
REOPEN: (instanceId) => `${PIMS_BASE}/api/v1/cases/${instanceId}/reopen`,
|
|
1835
|
-
},
|
|
1836
|
-
};
|
|
1837
|
-
|
|
1838
|
-
/**
|
|
1839
|
-
* SDK Telemetry constants
|
|
1840
|
-
*/
|
|
1841
|
-
// Connection string placeholder that will be replaced during build
|
|
1842
|
-
const CONNECTION_STRING = "InstrumentationKey=a6efa11d-1feb-4508-9738-e13e12dcae5e;IngestionEndpoint=https://westeurope-5.in.applicationinsights.azure.com/;LiveEndpoint=https://westeurope.livediagnostics.monitor.azure.com/;ApplicationId=7c58eb1c-9581-4ba6-839e-11725848a037";
|
|
1843
|
-
// SDK Version placeholder
|
|
1844
|
-
const SDK_VERSION = "1.3.7";
|
|
1845
|
-
const VERSION = "Version";
|
|
1846
|
-
const SERVICE = "Service";
|
|
1847
|
-
const CLOUD_ORGANIZATION_NAME = "CloudOrganizationName";
|
|
1848
|
-
const CLOUD_TENANT_NAME = "CloudTenantName";
|
|
1849
|
-
const CLOUD_URL = "CloudUrl";
|
|
1850
|
-
const CLOUD_CLIENT_ID = "CloudClientId";
|
|
1851
|
-
const CLOUD_REDIRECT_URI = "CloudRedirectUri";
|
|
1852
|
-
const APP_NAME = "ApplicationName";
|
|
1853
|
-
const CLOUD_ROLE_NAME = "uipath-ts-sdk";
|
|
1854
|
-
// Service and logger names
|
|
1855
|
-
const SDK_SERVICE_NAME = "UiPath.TypeScript.Sdk";
|
|
1856
|
-
const SDK_LOGGER_NAME = "uipath-ts-sdk-telemetry";
|
|
1857
|
-
// Event names
|
|
1858
|
-
const SDK_RUN_EVENT = "Sdk.Run";
|
|
1859
|
-
// Default value for unknown/empty attributes
|
|
1860
|
-
const UNKNOWN = "";
|
|
1861
|
-
|
|
1862
|
-
/**
|
|
1863
|
-
* Log exporter that sends ALL logs as Application Insights custom events
|
|
1864
|
-
*/
|
|
1865
|
-
class ApplicationInsightsEventExporter {
|
|
1866
|
-
constructor(connectionString) {
|
|
1867
|
-
this.connectionString = connectionString;
|
|
1868
|
-
}
|
|
1869
|
-
export(logs, resultCallback) {
|
|
1870
|
-
try {
|
|
1871
|
-
logs.forEach(logRecord => {
|
|
1872
|
-
this.sendAsCustomEvent(logRecord);
|
|
1873
|
-
});
|
|
1874
|
-
resultCallback({ code: 0 });
|
|
1875
|
-
}
|
|
1876
|
-
catch (error) {
|
|
1877
|
-
console.debug('Failed to export logs to Application Insights:', error);
|
|
1878
|
-
resultCallback({ code: 2, error });
|
|
1879
|
-
}
|
|
1880
|
-
}
|
|
1881
|
-
shutdown() {
|
|
1882
|
-
return Promise.resolve();
|
|
1883
|
-
}
|
|
1884
|
-
sendAsCustomEvent(logRecord) {
|
|
1885
|
-
// Get event name from body or attributes
|
|
1886
|
-
const eventName = logRecord.body || SDK_RUN_EVENT;
|
|
1887
|
-
const payload = {
|
|
1888
|
-
name: 'Microsoft.ApplicationInsights.Event',
|
|
1889
|
-
time: new Date().toISOString(),
|
|
1890
|
-
iKey: this.extractInstrumentationKey(),
|
|
1891
|
-
data: {
|
|
1892
|
-
baseType: 'EventData',
|
|
1893
|
-
baseData: {
|
|
1894
|
-
ver: 2,
|
|
1895
|
-
name: eventName,
|
|
1896
|
-
properties: this.convertAttributesToProperties(logRecord.attributes || {})
|
|
1897
|
-
}
|
|
1898
|
-
},
|
|
1899
|
-
tags: {
|
|
1900
|
-
'ai.cloud.role': CLOUD_ROLE_NAME,
|
|
1901
|
-
'ai.cloud.roleInstance': SDK_VERSION
|
|
1902
|
-
}
|
|
1903
|
-
};
|
|
1904
|
-
this.sendToApplicationInsights(payload);
|
|
1905
|
-
}
|
|
1906
|
-
extractInstrumentationKey() {
|
|
1907
|
-
const match = this.connectionString.match(/InstrumentationKey=([^;]+)/);
|
|
1908
|
-
return match ? match[1] : '';
|
|
1909
|
-
}
|
|
1910
|
-
convertAttributesToProperties(attributes) {
|
|
1911
|
-
const properties = {};
|
|
1912
|
-
Object.entries(attributes || {}).forEach(([key, value]) => {
|
|
1913
|
-
properties[key] = String(value);
|
|
1914
|
-
});
|
|
1915
|
-
return properties;
|
|
1916
|
-
}
|
|
1917
|
-
async sendToApplicationInsights(payload) {
|
|
1918
|
-
try {
|
|
1919
|
-
const ingestionEndpoint = this.extractIngestionEndpoint();
|
|
1920
|
-
if (!ingestionEndpoint) {
|
|
1921
|
-
console.debug('No ingestion endpoint found in connection string');
|
|
1922
|
-
return;
|
|
1923
|
-
}
|
|
1924
|
-
const url = `${ingestionEndpoint}/v2/track`;
|
|
1925
|
-
const response = await fetch(url, {
|
|
1926
|
-
method: 'POST',
|
|
1927
|
-
headers: {
|
|
1928
|
-
'Content-Type': 'application/json',
|
|
1929
|
-
},
|
|
1930
|
-
body: JSON.stringify(payload)
|
|
1931
|
-
});
|
|
1932
|
-
if (!response.ok) {
|
|
1933
|
-
console.debug(`Failed to send event telemetry: ${response.status} ${response.statusText}`);
|
|
1934
|
-
}
|
|
1935
|
-
}
|
|
1936
|
-
catch (error) {
|
|
1937
|
-
console.debug('Error sending event telemetry to Application Insights:', error);
|
|
1938
|
-
}
|
|
1939
|
-
}
|
|
1940
|
-
extractIngestionEndpoint() {
|
|
1941
|
-
const match = this.connectionString.match(/IngestionEndpoint=([^;]+)/);
|
|
1942
|
-
return match ? match[1] : '';
|
|
1943
|
-
}
|
|
1944
|
-
}
|
|
1945
|
-
/**
|
|
1946
|
-
* Singleton telemetry client
|
|
1947
|
-
*/
|
|
1948
|
-
class TelemetryClient {
|
|
1949
|
-
constructor() {
|
|
1950
|
-
this.isInitialized = false;
|
|
1951
|
-
}
|
|
1952
|
-
static getInstance() {
|
|
1953
|
-
if (!TelemetryClient.instance) {
|
|
1954
|
-
TelemetryClient.instance = new TelemetryClient();
|
|
1955
|
-
}
|
|
1956
|
-
return TelemetryClient.instance;
|
|
1957
|
-
}
|
|
1958
|
-
/**
|
|
1959
|
-
* Initialize telemetry
|
|
1960
|
-
*/
|
|
1961
|
-
initialize(config) {
|
|
1962
|
-
if (this.isInitialized) {
|
|
1963
|
-
return;
|
|
1964
|
-
}
|
|
1965
|
-
this.isInitialized = true;
|
|
1966
|
-
if (config) {
|
|
1967
|
-
this.telemetryContext = config;
|
|
1968
|
-
}
|
|
1969
|
-
try {
|
|
1970
|
-
const connectionString = this.getConnectionString();
|
|
1971
|
-
if (!connectionString) {
|
|
1972
|
-
return;
|
|
1973
|
-
}
|
|
1974
|
-
this.setupTelemetryProvider(connectionString);
|
|
1975
|
-
}
|
|
1976
|
-
catch (error) {
|
|
1977
|
-
// Silent failure - telemetry errors shouldn't break functionality
|
|
1978
|
-
console.debug('Failed to initialize OpenTelemetry:', error);
|
|
1979
|
-
}
|
|
1980
|
-
}
|
|
1981
|
-
getConnectionString() {
|
|
1982
|
-
const connectionString = CONNECTION_STRING;
|
|
1983
|
-
return connectionString;
|
|
1984
|
-
}
|
|
1985
|
-
setupTelemetryProvider(connectionString) {
|
|
1986
|
-
const exporter = new ApplicationInsightsEventExporter(connectionString);
|
|
1987
|
-
const processor = new BatchLogRecordProcessor(exporter);
|
|
1988
|
-
this.logProvider = new LoggerProvider({
|
|
1989
|
-
processors: [processor]
|
|
1990
|
-
});
|
|
1991
|
-
this.logger = this.logProvider.getLogger(SDK_LOGGER_NAME);
|
|
1992
|
-
}
|
|
1993
|
-
/**
|
|
1994
|
-
* Track a telemetry event
|
|
1995
|
-
*/
|
|
1996
|
-
track(eventName, name, extraAttributes = {}) {
|
|
1997
|
-
try {
|
|
1998
|
-
// Skip if logger not initialized
|
|
1999
|
-
if (!this.logger) {
|
|
2000
|
-
return;
|
|
2001
|
-
}
|
|
2002
|
-
const finalDisplayName = name || eventName;
|
|
2003
|
-
const attributes = this.getEnrichedAttributes(extraAttributes, eventName);
|
|
2004
|
-
// Emit as log
|
|
2005
|
-
this.logger.emit({
|
|
2006
|
-
body: finalDisplayName,
|
|
2007
|
-
attributes: attributes,
|
|
2008
|
-
timestamp: Date.now(),
|
|
2009
|
-
});
|
|
2010
|
-
}
|
|
2011
|
-
catch (error) {
|
|
2012
|
-
// Silent failure
|
|
2013
|
-
console.debug('Failed to track telemetry event:', error);
|
|
2014
|
-
}
|
|
2015
|
-
}
|
|
2016
|
-
/**
|
|
2017
|
-
* Get enriched attributes for telemetry events
|
|
2018
|
-
*/
|
|
2019
|
-
getEnrichedAttributes(extraAttributes, eventName) {
|
|
2020
|
-
const attributes = {
|
|
2021
|
-
[APP_NAME]: SDK_SERVICE_NAME,
|
|
2022
|
-
[VERSION]: SDK_VERSION,
|
|
2023
|
-
[SERVICE]: eventName,
|
|
2024
|
-
[CLOUD_URL]: this.createCloudUrl(),
|
|
2025
|
-
[CLOUD_ORGANIZATION_NAME]: this.telemetryContext?.orgName || UNKNOWN,
|
|
2026
|
-
[CLOUD_TENANT_NAME]: this.telemetryContext?.tenantName || UNKNOWN,
|
|
2027
|
-
[CLOUD_REDIRECT_URI]: this.telemetryContext?.redirectUri || UNKNOWN,
|
|
2028
|
-
[CLOUD_CLIENT_ID]: this.telemetryContext?.clientId || UNKNOWN,
|
|
2029
|
-
...extraAttributes,
|
|
2030
|
-
};
|
|
2031
|
-
return attributes;
|
|
2032
|
-
}
|
|
2033
|
-
/**
|
|
2034
|
-
* Create cloud URL from base URL, organization ID, and tenant ID
|
|
2035
|
-
*/
|
|
2036
|
-
createCloudUrl() {
|
|
2037
|
-
const baseUrl = this.telemetryContext?.baseUrl;
|
|
2038
|
-
const orgId = this.telemetryContext?.orgName;
|
|
2039
|
-
const tenantId = this.telemetryContext?.tenantName;
|
|
2040
|
-
if (!baseUrl || !orgId || !tenantId) {
|
|
2041
|
-
return UNKNOWN;
|
|
2042
|
-
}
|
|
2043
|
-
return `${baseUrl}/${orgId}/${tenantId}`;
|
|
2044
|
-
}
|
|
2045
|
-
}
|
|
2046
|
-
// Export singleton instance
|
|
2047
|
-
const telemetryClient = TelemetryClient.getInstance();
|
|
1960
|
+
* SDK Telemetry constants.
|
|
1961
|
+
*
|
|
1962
|
+
* Only the SDK's identity (version, service name, role name, …) lives
|
|
1963
|
+
* here. The Application Insights connection string is injected into
|
|
1964
|
+
* `@uipath/core-telemetry` itself at publish time, and the generic attribute
|
|
1965
|
+
* keys (`Version`, `Service`, `CloudOrganizationName`, …) are owned by
|
|
1966
|
+
* `@uipath/core-telemetry` and consumed there — they are not part of the
|
|
1967
|
+
* SDK's public API.
|
|
1968
|
+
*/
|
|
1969
|
+
/** SDK version placeholder — patched by the SDK publish workflow. */
|
|
1970
|
+
const CLOUD_ROLE_NAME = 'uipath-ts-sdk';
|
|
2048
1971
|
|
|
2049
1972
|
/**
|
|
2050
|
-
*
|
|
2051
|
-
*/
|
|
2052
|
-
/**
|
|
2053
|
-
* Common tracking logic shared between method and function decorators
|
|
2054
|
-
*/
|
|
2055
|
-
function createTrackedFunction(originalFunction, nameOrOptions, fallbackName, opts) {
|
|
2056
|
-
return function (...args) {
|
|
2057
|
-
// Determine if we should track this call
|
|
2058
|
-
let shouldTrack = true;
|
|
2059
|
-
if (opts.condition !== undefined) {
|
|
2060
|
-
if (typeof opts.condition === 'function') {
|
|
2061
|
-
shouldTrack = opts.condition.apply(this, args);
|
|
2062
|
-
}
|
|
2063
|
-
else {
|
|
2064
|
-
shouldTrack = opts.condition;
|
|
2065
|
-
}
|
|
2066
|
-
}
|
|
2067
|
-
// Track the event if enabled
|
|
2068
|
-
if (shouldTrack) {
|
|
2069
|
-
// Use the full name provided in the decorator (e.g., "Queue.GetAll")
|
|
2070
|
-
const serviceMethod = typeof nameOrOptions === 'string'
|
|
2071
|
-
? nameOrOptions
|
|
2072
|
-
: fallbackName;
|
|
2073
|
-
// Use 'Sdk.Run' as the name and serviceMethod as the service
|
|
2074
|
-
telemetryClient.track(serviceMethod, SDK_RUN_EVENT, opts.attributes);
|
|
2075
|
-
}
|
|
2076
|
-
// Execute the original function
|
|
2077
|
-
return originalFunction.apply(this, args);
|
|
2078
|
-
};
|
|
2079
|
-
}
|
|
2080
|
-
/**
|
|
2081
|
-
* Track decorator that can be used to automatically track function calls
|
|
2082
|
-
*
|
|
2083
|
-
* Usage:
|
|
2084
|
-
* @track("Service.Method")
|
|
2085
|
-
* function myFunction() { ... }
|
|
2086
|
-
*
|
|
2087
|
-
* @track("Queue.GetAll")
|
|
2088
|
-
* async getAll() { ... }
|
|
2089
|
-
*
|
|
2090
|
-
* @track("Tasks.Create")
|
|
2091
|
-
* async create() { ... }
|
|
2092
|
-
*
|
|
2093
|
-
* @track("Assets.Update", { condition: false })
|
|
2094
|
-
* function myFunction() { ... }
|
|
1973
|
+
* UiPath TypeScript SDK Telemetry
|
|
2095
1974
|
*
|
|
2096
|
-
*
|
|
2097
|
-
*
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
return (originalFunction) => createTrackedFunction(originalFunction, nameOrOptions, originalFunction.name || 'unknown_function', opts);
|
|
2109
|
-
};
|
|
2110
|
-
}
|
|
1975
|
+
* Constructs the SDK's own `TelemetryClient` and binds the SDK-local
|
|
1976
|
+
* `track` / `trackEvent` to it. Each consumer of `@uipath/core-telemetry`
|
|
1977
|
+
* does this independently, so events carry their own consumer's identity
|
|
1978
|
+
* and tenant context.
|
|
1979
|
+
*/
|
|
1980
|
+
// Keyed by `CLOUD_ROLE_NAME` so every SDK subpath bundle resolves to the
|
|
1981
|
+
// same `TelemetryClient` instance at runtime. A single `initialize(...)`
|
|
1982
|
+
// from the `UiPath` constructor therefore wires up `@track` decorators
|
|
1983
|
+
// across every subpath bundle (`assets`, `feedback`, `tasks`, …).
|
|
1984
|
+
const sdkClient = getOrCreateClient(CLOUD_ROLE_NAME);
|
|
1985
|
+
const track = createTrack(sdkClient);
|
|
1986
|
+
createTrackEvent(sdkClient);
|
|
2111
1987
|
|
|
2112
1988
|
/**
|
|
2113
1989
|
* Creates query parameters object from key-value pairs, filtering out undefined values
|
|
@@ -2179,6 +2055,177 @@ class CasesService extends BaseService {
|
|
|
2179
2055
|
name: this.extractCaseName(caseItem.packageId)
|
|
2180
2056
|
}));
|
|
2181
2057
|
}
|
|
2058
|
+
/**
|
|
2059
|
+
* Get the top 5 case processes ranked by run count within a time range.
|
|
2060
|
+
*
|
|
2061
|
+
* Returns an array of up to 5 case processes sorted by how many times they were executed,
|
|
2062
|
+
* useful for identifying the most active case processes in a given period.
|
|
2063
|
+
*
|
|
2064
|
+
* @param startTime - Start of the time range to query
|
|
2065
|
+
* @param endTime - End of the time range to query
|
|
2066
|
+
* @param options - Optional filters (packageId, processKey, version)
|
|
2067
|
+
* @returns Promise resolving to an array of {@link CaseGetTopRunCountResponse}
|
|
2068
|
+
* @example
|
|
2069
|
+
* ```typescript
|
|
2070
|
+
* import { Cases } from '@uipath/uipath-typescript/cases';
|
|
2071
|
+
*
|
|
2072
|
+
* const cases = new Cases(sdk);
|
|
2073
|
+
*
|
|
2074
|
+
* // Get top case processes by run count for the last 7 days
|
|
2075
|
+
* const topProcesses = await cases.getTopRunCount(
|
|
2076
|
+
* new Date(Date.now() - 7 * 24 * 60 * 60 * 1000),
|
|
2077
|
+
* new Date()
|
|
2078
|
+
* );
|
|
2079
|
+
*
|
|
2080
|
+
* for (const process of topProcesses) {
|
|
2081
|
+
* console.log(`${process.packageId}: ${process.runCount} runs`);
|
|
2082
|
+
* }
|
|
2083
|
+
* ```
|
|
2084
|
+
*
|
|
2085
|
+
* @example
|
|
2086
|
+
* ```typescript
|
|
2087
|
+
* // Get top case processes by run count for a specific package
|
|
2088
|
+
* const filtered = await cases.getTopRunCount(
|
|
2089
|
+
* new Date(Date.now() - 7 * 24 * 60 * 60 * 1000),
|
|
2090
|
+
* new Date(),
|
|
2091
|
+
* { packageId: '<packageId>' }
|
|
2092
|
+
* );
|
|
2093
|
+
* ```
|
|
2094
|
+
*/
|
|
2095
|
+
async getTopRunCount(startTime, endTime, options) {
|
|
2096
|
+
const { data } = await this.post(MAESTRO_ENDPOINTS.INSIGHTS.TOP_PROCESSES_BY_RUN_COUNT, buildInsightsTopBody(startTime, endTime, true, options));
|
|
2097
|
+
return (data ?? []).map(process => ({ ...process, name: this.extractCaseName(process.packageId) }));
|
|
2098
|
+
}
|
|
2099
|
+
/**
|
|
2100
|
+
* Get all instances status counts aggregated by date for case management processes.
|
|
2101
|
+
*
|
|
2102
|
+
* Returns time-grouped counts of case instances grouped by status (Completed, Faulted, Cancelled),
|
|
2103
|
+
* useful for rendering time-series charts. Use `groupBy` to control the time bucket size
|
|
2104
|
+
* (hour, day, or week) — defaults to day if not provided.
|
|
2105
|
+
*
|
|
2106
|
+
* @param startTime - Start of the time range to query
|
|
2107
|
+
* @param endTime - End of the time range to query
|
|
2108
|
+
* @param options - Optional settings for time bucketing granularity
|
|
2109
|
+
* @returns Promise resolving to an array of {@link InstanceStatusTimelineResponse}
|
|
2110
|
+
*
|
|
2111
|
+
* @example
|
|
2112
|
+
* ```typescript
|
|
2113
|
+
* // Get daily instance status for the last 7 days
|
|
2114
|
+
* const now = new Date();
|
|
2115
|
+
* const sevenDaysAgo = new Date(Date.now() - 7 * 24 * 60 * 60 * 1000);
|
|
2116
|
+
* const statuses = await cases.getInstanceStatusTimeline(sevenDaysAgo, now);
|
|
2117
|
+
*
|
|
2118
|
+
* for (const entry of statuses) {
|
|
2119
|
+
* console.log(`${entry.startTime} — ${entry.status}: ${entry.count}`);
|
|
2120
|
+
* }
|
|
2121
|
+
* ```
|
|
2122
|
+
*
|
|
2123
|
+
* @example
|
|
2124
|
+
* ```typescript
|
|
2125
|
+
* import { TimeInterval } from '@uipath/uipath-typescript/cases';
|
|
2126
|
+
*
|
|
2127
|
+
* // Get weekly breakdown
|
|
2128
|
+
* const statuses = await cases.getInstanceStatusTimeline(startTime, endTime, {
|
|
2129
|
+
* groupBy: TimeInterval.Week,
|
|
2130
|
+
* });
|
|
2131
|
+
* ```
|
|
2132
|
+
*
|
|
2133
|
+
* @example
|
|
2134
|
+
* ```typescript
|
|
2135
|
+
* // Get all-time data (from Unix epoch to now)
|
|
2136
|
+
* const allTime = await cases.getInstanceStatusTimeline(new Date(0), new Date());
|
|
2137
|
+
* ```
|
|
2138
|
+
*/
|
|
2139
|
+
async getInstanceStatusTimeline(startTime, endTime, options) {
|
|
2140
|
+
return fetchInstanceStatusTimeline(this.post.bind(this), startTime, endTime, true, options);
|
|
2141
|
+
}
|
|
2142
|
+
/**
|
|
2143
|
+
* Get the top 10 case processes ranked by failure count within a time range.
|
|
2144
|
+
*
|
|
2145
|
+
* Returns an array of up to 10 case processes sorted by how many instances faulted,
|
|
2146
|
+
* useful for identifying the most error-prone case processes in a given period.
|
|
2147
|
+
*
|
|
2148
|
+
* @param startTime - Start of the time range to query
|
|
2149
|
+
* @param endTime - End of the time range to query
|
|
2150
|
+
* @param options - Optional filters (packageId, processKey, version)
|
|
2151
|
+
* @returns Promise resolving to an array of {@link CaseGetTopFaultedCountResponse}
|
|
2152
|
+
* @example
|
|
2153
|
+
* ```typescript
|
|
2154
|
+
* import { Cases } from '@uipath/uipath-typescript/cases';
|
|
2155
|
+
*
|
|
2156
|
+
* const cases = new Cases(sdk);
|
|
2157
|
+
*
|
|
2158
|
+
* // Get top case processes by faulted count for the last 7 days
|
|
2159
|
+
* const topFailing = await cases.getTopFaultedCount(
|
|
2160
|
+
* new Date(Date.now() - 7 * 24 * 60 * 60 * 1000),
|
|
2161
|
+
* new Date()
|
|
2162
|
+
* );
|
|
2163
|
+
*
|
|
2164
|
+
* for (const process of topFailing) {
|
|
2165
|
+
* console.log(`${process.packageId}: ${process.faultedCount} failures`);
|
|
2166
|
+
* }
|
|
2167
|
+
* ```
|
|
2168
|
+
*
|
|
2169
|
+
* @example
|
|
2170
|
+
* ```typescript
|
|
2171
|
+
* // Get top case processes by faulted count for a specific package
|
|
2172
|
+
* const filtered = await cases.getTopFaultedCount(
|
|
2173
|
+
* new Date(Date.now() - 7 * 24 * 60 * 60 * 1000),
|
|
2174
|
+
* new Date(),
|
|
2175
|
+
* { packageId: '<packageId>' }
|
|
2176
|
+
* );
|
|
2177
|
+
* ```
|
|
2178
|
+
*/
|
|
2179
|
+
async getTopFaultedCount(startTime, endTime, options) {
|
|
2180
|
+
const { data } = await this.post(MAESTRO_ENDPOINTS.INSIGHTS.TOP_PROCESSES_WITH_FAILURE, buildInsightsTopBody(startTime, endTime, true, options));
|
|
2181
|
+
return (data ?? []).map(item => ({
|
|
2182
|
+
packageId: item.packageId,
|
|
2183
|
+
processKey: item.processKey,
|
|
2184
|
+
faultedCount: item.runCount,
|
|
2185
|
+
name: this.extractCaseName(item.packageId),
|
|
2186
|
+
}));
|
|
2187
|
+
}
|
|
2188
|
+
/**
|
|
2189
|
+
* Get the top 5 case processes ranked by total duration within a time range.
|
|
2190
|
+
*
|
|
2191
|
+
* Returns an array of up to 5 case processes sorted by their total execution time,
|
|
2192
|
+
* useful for identifying the longest-running case processes in a given period.
|
|
2193
|
+
*
|
|
2194
|
+
* @param startTime - Start of the time range to query
|
|
2195
|
+
* @param endTime - End of the time range to query
|
|
2196
|
+
* @param options - Optional filters (packageId, processKey, version)
|
|
2197
|
+
* @returns Promise resolving to an array of {@link CaseGetTopDurationResponse}
|
|
2198
|
+
* @example
|
|
2199
|
+
* ```typescript
|
|
2200
|
+
* import { Cases } from '@uipath/uipath-typescript/cases';
|
|
2201
|
+
*
|
|
2202
|
+
* const cases = new Cases(sdk);
|
|
2203
|
+
*
|
|
2204
|
+
* // Get top case processes by duration for the last 7 days
|
|
2205
|
+
* const topProcesses = await cases.getTopExecutionDuration(
|
|
2206
|
+
* new Date(Date.now() - 7 * 24 * 60 * 60 * 1000),
|
|
2207
|
+
* new Date()
|
|
2208
|
+
* );
|
|
2209
|
+
*
|
|
2210
|
+
* for (const process of topProcesses) {
|
|
2211
|
+
* console.log(`${process.packageId}: ${process.duration}ms total`);
|
|
2212
|
+
* }
|
|
2213
|
+
* ```
|
|
2214
|
+
*
|
|
2215
|
+
* @example
|
|
2216
|
+
* ```typescript
|
|
2217
|
+
* // Get top case processes by duration for a specific package
|
|
2218
|
+
* const filtered = await cases.getTopExecutionDuration(
|
|
2219
|
+
* new Date(Date.now() - 7 * 24 * 60 * 60 * 1000),
|
|
2220
|
+
* new Date(),
|
|
2221
|
+
* { packageId: '<packageId>' }
|
|
2222
|
+
* );
|
|
2223
|
+
* ```
|
|
2224
|
+
*/
|
|
2225
|
+
async getTopExecutionDuration(startTime, endTime, options) {
|
|
2226
|
+
const { data } = await this.post(MAESTRO_ENDPOINTS.INSIGHTS.TOP_PROCESSES_BY_DURATION, buildInsightsTopBody(startTime, endTime, true, options));
|
|
2227
|
+
return (data ?? []).map(process => ({ ...process, name: this.extractCaseName(process.packageId) }));
|
|
2228
|
+
}
|
|
2182
2229
|
/**
|
|
2183
2230
|
* Extract a readable case name from the packageId
|
|
2184
2231
|
* @param packageId - The full package identifier
|
|
@@ -2201,6 +2248,18 @@ class CasesService extends BaseService {
|
|
|
2201
2248
|
__decorate([
|
|
2202
2249
|
track('Cases.GetAll')
|
|
2203
2250
|
], CasesService.prototype, "getAll", null);
|
|
2251
|
+
__decorate([
|
|
2252
|
+
track('Cases.GetTopRunCount')
|
|
2253
|
+
], CasesService.prototype, "getTopRunCount", null);
|
|
2254
|
+
__decorate([
|
|
2255
|
+
track('Cases.GetInstanceStatusTimeline')
|
|
2256
|
+
], CasesService.prototype, "getInstanceStatusTimeline", null);
|
|
2257
|
+
__decorate([
|
|
2258
|
+
track('Cases.GetTopFaultedCount')
|
|
2259
|
+
], CasesService.prototype, "getTopFaultedCount", null);
|
|
2260
|
+
__decorate([
|
|
2261
|
+
track('Cases.GetTopExecutionDuration')
|
|
2262
|
+
], CasesService.prototype, "getTopExecutionDuration", null);
|
|
2204
2263
|
|
|
2205
2264
|
/**
|
|
2206
2265
|
* Process Incident Status
|
|
@@ -2242,6 +2301,41 @@ var DebugMode;
|
|
|
2242
2301
|
* Case Instance Types
|
|
2243
2302
|
* Types and interfaces for Maestro case instance management
|
|
2244
2303
|
*/
|
|
2304
|
+
/**
|
|
2305
|
+
* SLA status for a case instance
|
|
2306
|
+
*/
|
|
2307
|
+
var SlaSummaryStatus;
|
|
2308
|
+
(function (SlaSummaryStatus) {
|
|
2309
|
+
/** Case is within SLA deadline */
|
|
2310
|
+
SlaSummaryStatus["ON_TRACK"] = "On Track";
|
|
2311
|
+
/** Case is approaching SLA deadline based on at-risk percentage threshold */
|
|
2312
|
+
SlaSummaryStatus["AT_RISK"] = "At Risk";
|
|
2313
|
+
/** Case has exceeded SLA deadline */
|
|
2314
|
+
SlaSummaryStatus["OVERDUE"] = "Overdue";
|
|
2315
|
+
/** Case instance has completed */
|
|
2316
|
+
SlaSummaryStatus["COMPLETED"] = "Completed";
|
|
2317
|
+
/** SLA status cannot be determined (no SLA deadline defined) */
|
|
2318
|
+
SlaSummaryStatus["UNKNOWN"] = "Unknown";
|
|
2319
|
+
})(SlaSummaryStatus || (SlaSummaryStatus = {}));
|
|
2320
|
+
/**
|
|
2321
|
+
* Instance status values for case instances and process instances
|
|
2322
|
+
*/
|
|
2323
|
+
var InstanceStatus;
|
|
2324
|
+
(function (InstanceStatus) {
|
|
2325
|
+
/** Instance status not yet populated by the backend */
|
|
2326
|
+
InstanceStatus["UNKNOWN"] = "";
|
|
2327
|
+
InstanceStatus["CANCELLED"] = "Cancelled";
|
|
2328
|
+
InstanceStatus["CANCELING"] = "Canceling";
|
|
2329
|
+
InstanceStatus["COMPLETED"] = "Completed";
|
|
2330
|
+
InstanceStatus["FAULTED"] = "Faulted";
|
|
2331
|
+
InstanceStatus["PAUSED"] = "Paused";
|
|
2332
|
+
InstanceStatus["PAUSING"] = "Pausing";
|
|
2333
|
+
InstanceStatus["PENDING"] = "Pending";
|
|
2334
|
+
InstanceStatus["RESUMING"] = "Resuming";
|
|
2335
|
+
InstanceStatus["RETRYING"] = "Retrying";
|
|
2336
|
+
InstanceStatus["RUNNING"] = "Running";
|
|
2337
|
+
InstanceStatus["UPGRADING"] = "Upgrading";
|
|
2338
|
+
})(InstanceStatus || (InstanceStatus = {}));
|
|
2245
2339
|
/**
|
|
2246
2340
|
* Case stage task type
|
|
2247
2341
|
*/
|
|
@@ -2276,6 +2370,8 @@ var EscalationTriggerType;
|
|
|
2276
2370
|
(function (EscalationTriggerType) {
|
|
2277
2371
|
EscalationTriggerType["SLA_BREACHED"] = "sla-breached";
|
|
2278
2372
|
EscalationTriggerType["AT_RISK"] = "at-risk";
|
|
2373
|
+
/** Default value when no escalation rule is defined */
|
|
2374
|
+
EscalationTriggerType["NONE"] = "None";
|
|
2279
2375
|
})(EscalationTriggerType || (EscalationTriggerType = {}));
|
|
2280
2376
|
/**
|
|
2281
2377
|
* SLA duration unit
|
|
@@ -2343,6 +2439,16 @@ function createCaseInstanceMethods(instanceData, service) {
|
|
|
2343
2439
|
if (!instanceData.instanceId)
|
|
2344
2440
|
throw new Error('Case instance ID is undefined');
|
|
2345
2441
|
return service.getActionTasks(instanceData.instanceId, options);
|
|
2442
|
+
},
|
|
2443
|
+
async getSlaSummary(options) {
|
|
2444
|
+
if (!instanceData.instanceId)
|
|
2445
|
+
throw new Error('Case instance ID is undefined');
|
|
2446
|
+
return service.getSlaSummary({ ...options, caseInstanceId: instanceData.instanceId });
|
|
2447
|
+
},
|
|
2448
|
+
async getStagesSlaSummary() {
|
|
2449
|
+
if (!instanceData.instanceId)
|
|
2450
|
+
throw new Error('Case instance ID is undefined');
|
|
2451
|
+
return service.getStagesSlaSummary({ caseInstanceId: instanceData.instanceId });
|
|
2346
2452
|
}
|
|
2347
2453
|
};
|
|
2348
2454
|
}
|
|
@@ -2358,6 +2464,40 @@ function createCaseInstanceWithMethods(instanceData, service) {
|
|
|
2358
2464
|
return Object.assign({}, instanceData, methods);
|
|
2359
2465
|
}
|
|
2360
2466
|
|
|
2467
|
+
/**
|
|
2468
|
+
* Insights Types
|
|
2469
|
+
* Shared types for Maestro insights analytics endpoints
|
|
2470
|
+
*/
|
|
2471
|
+
/**
|
|
2472
|
+
* Time bucketing granularity for insights time-series queries.
|
|
2473
|
+
*
|
|
2474
|
+
* Controls how data points are grouped on the time axis.
|
|
2475
|
+
*/
|
|
2476
|
+
var TimeInterval;
|
|
2477
|
+
(function (TimeInterval) {
|
|
2478
|
+
/** Group data points by hour */
|
|
2479
|
+
TimeInterval["Hour"] = "HOUR";
|
|
2480
|
+
/** Group data points by day */
|
|
2481
|
+
TimeInterval["Day"] = "DAY";
|
|
2482
|
+
/** Group data points by week */
|
|
2483
|
+
TimeInterval["Week"] = "WEEK";
|
|
2484
|
+
})(TimeInterval || (TimeInterval = {}));
|
|
2485
|
+
/**
|
|
2486
|
+
* Final instance statuses returned by the instance status timeline endpoint.
|
|
2487
|
+
*
|
|
2488
|
+
* Only includes statuses where the instance has finished execution — Completed, Faulted, or Cancelled.
|
|
2489
|
+
* Active statuses like Running or Paused are not included.
|
|
2490
|
+
*/
|
|
2491
|
+
var InstanceFinalStatus;
|
|
2492
|
+
(function (InstanceFinalStatus) {
|
|
2493
|
+
/** Instance completed successfully */
|
|
2494
|
+
InstanceFinalStatus["Completed"] = "Completed";
|
|
2495
|
+
/** Instance encountered an error */
|
|
2496
|
+
InstanceFinalStatus["Faulted"] = "Faulted";
|
|
2497
|
+
/** Instance was cancelled */
|
|
2498
|
+
InstanceFinalStatus["Cancelled"] = "Cancelled";
|
|
2499
|
+
})(InstanceFinalStatus || (InstanceFinalStatus = {}));
|
|
2500
|
+
|
|
2361
2501
|
/**
|
|
2362
2502
|
* Maps fields for Case Instance entities to ensure consistent naming
|
|
2363
2503
|
*/
|
|
@@ -3508,6 +3648,104 @@ class CaseInstancesService extends BaseService {
|
|
|
3508
3648
|
};
|
|
3509
3649
|
return await this.taskService.getAll(enhancedOptions);
|
|
3510
3650
|
}
|
|
3651
|
+
/**
|
|
3652
|
+
* Get SLA summary for all case instances across folders.
|
|
3653
|
+
*
|
|
3654
|
+
* Returns SLA status, due times, escalation info, and instance metadata for each case instance.
|
|
3655
|
+
* The default page size is 50, so only the top 50 items are returned when no pagination options are provided.
|
|
3656
|
+
*
|
|
3657
|
+
* @param options - Optional filtering and pagination options
|
|
3658
|
+
* @returns Promise resolving to {@link SlaSummaryResponse}, paginated or non-paginated based on options
|
|
3659
|
+
* @example
|
|
3660
|
+
* ```typescript
|
|
3661
|
+
* // Non-paginated (returns top 50 items by default)
|
|
3662
|
+
* const summary = await caseInstances.getSlaSummary();
|
|
3663
|
+
* console.log(`Found ${summary.totalCount} cases`);
|
|
3664
|
+
*
|
|
3665
|
+
* // Filter by case instance ID
|
|
3666
|
+
* const filtered = await caseInstances.getSlaSummary({
|
|
3667
|
+
* caseInstanceId: '<caseInstanceId>'
|
|
3668
|
+
* });
|
|
3669
|
+
*
|
|
3670
|
+
* // Filter by time range
|
|
3671
|
+
* const timeFiltered = await caseInstances.getSlaSummary({
|
|
3672
|
+
* startTimeUtc: new Date('2026-01-01'),
|
|
3673
|
+
* endTimeUtc: new Date('2026-01-31')
|
|
3674
|
+
* });
|
|
3675
|
+
*
|
|
3676
|
+
* // With pagination
|
|
3677
|
+
* const page1 = await caseInstances.getSlaSummary({ pageSize: 25 });
|
|
3678
|
+
* if (page1.hasNextPage) {
|
|
3679
|
+
* const page2 = await caseInstances.getSlaSummary({ cursor: page1.nextCursor });
|
|
3680
|
+
* }
|
|
3681
|
+
*
|
|
3682
|
+
* // Jump to specific page
|
|
3683
|
+
* const page3 = await caseInstances.getSlaSummary({ jumpToPage: 3, pageSize: 25 });
|
|
3684
|
+
* ```
|
|
3685
|
+
*/
|
|
3686
|
+
async getSlaSummary(options) {
|
|
3687
|
+
const apiOptions = options ? {
|
|
3688
|
+
...options,
|
|
3689
|
+
startTimeUtc: options.startTimeUtc?.toISOString(),
|
|
3690
|
+
endTimeUtc: options.endTimeUtc?.toISOString()
|
|
3691
|
+
} : undefined;
|
|
3692
|
+
return PaginationHelpers.getAll({
|
|
3693
|
+
serviceAccess: this.createPaginationServiceAccess(),
|
|
3694
|
+
getEndpoint: () => MAESTRO_ENDPOINTS.INSIGHTS.SLA_SUMMARY,
|
|
3695
|
+
method: HTTP_METHODS.POST,
|
|
3696
|
+
excludeFromPrefix: ['caseInstanceId', 'startTimeUtc', 'endTimeUtc'],
|
|
3697
|
+
transformFn: (item) => ({
|
|
3698
|
+
...item,
|
|
3699
|
+
slaDueTime: toISOUtc(item.slaDueTime),
|
|
3700
|
+
lastModifiedTime: toISOUtc(item.lastModifiedTime)
|
|
3701
|
+
}),
|
|
3702
|
+
pagination: {
|
|
3703
|
+
paginationType: PaginationType.OFFSET,
|
|
3704
|
+
itemsField: SLA_SUMMARY_PAGINATION.ITEMS_FIELD,
|
|
3705
|
+
totalCountField: SLA_SUMMARY_PAGINATION.TOTAL_COUNT_FIELD,
|
|
3706
|
+
paginationParams: {
|
|
3707
|
+
pageSizeParam: SLA_SUMMARY_OFFSET_PARAMS.PAGE_SIZE_PARAM,
|
|
3708
|
+
offsetParam: SLA_SUMMARY_OFFSET_PARAMS.OFFSET_PARAM,
|
|
3709
|
+
countParam: SLA_SUMMARY_OFFSET_PARAMS.COUNT_PARAM,
|
|
3710
|
+
convertToSkip: false
|
|
3711
|
+
}
|
|
3712
|
+
}
|
|
3713
|
+
}, apiOptions);
|
|
3714
|
+
}
|
|
3715
|
+
/**
|
|
3716
|
+
* Get stages SLA summary for case instances across folders.
|
|
3717
|
+
*
|
|
3718
|
+
* Returns stage-level SLA status and escalation information for each case instance, aggregated from Insights Real-Time Monitoring.
|
|
3719
|
+
*
|
|
3720
|
+
* @param options - Optional filtering options
|
|
3721
|
+
* @returns Promise resolving to an array of {@link CaseInstanceStageSLAResponse}
|
|
3722
|
+
* @example
|
|
3723
|
+
* ```typescript
|
|
3724
|
+
* // Get stages SLA summary for all case instances
|
|
3725
|
+
* const stagesSla = await caseInstances.getStagesSlaSummary();
|
|
3726
|
+
* for (const item of stagesSla) {
|
|
3727
|
+
* console.log(`Instance: ${item.caseInstanceId}`);
|
|
3728
|
+
* for (const stage of item.stages) {
|
|
3729
|
+
* console.log(` Stage: ${stage.name} - SLA Status: ${stage.slaStatus}, Due: ${stage.slaDueTime}`);
|
|
3730
|
+
* }
|
|
3731
|
+
* }
|
|
3732
|
+
*
|
|
3733
|
+
* // Filter by case instance ID
|
|
3734
|
+
* const filtered = await caseInstances.getStagesSlaSummary({
|
|
3735
|
+
* caseInstanceId: '<caseInstanceId>'
|
|
3736
|
+
* });
|
|
3737
|
+
*
|
|
3738
|
+
* // Using bound method on a case instance
|
|
3739
|
+
* const instance = await caseInstances.getById('<instanceId>', '<folderKey>');
|
|
3740
|
+
* const stagesSla = await instance.getStagesSlaSummary();
|
|
3741
|
+
* ```
|
|
3742
|
+
*/
|
|
3743
|
+
async getStagesSlaSummary(options) {
|
|
3744
|
+
const response = await this.post(MAESTRO_ENDPOINTS.INSIGHTS.STAGES_SUMMARY, {
|
|
3745
|
+
caseInstanceId: options?.caseInstanceId,
|
|
3746
|
+
});
|
|
3747
|
+
return response.data ?? [];
|
|
3748
|
+
}
|
|
3511
3749
|
}
|
|
3512
3750
|
__decorate([
|
|
3513
3751
|
track('CaseInstances.GetAll')
|
|
@@ -3536,5 +3774,11 @@ __decorate([
|
|
|
3536
3774
|
__decorate([
|
|
3537
3775
|
track('CaseInstances.GetActionTasks')
|
|
3538
3776
|
], CaseInstancesService.prototype, "getActionTasks", null);
|
|
3777
|
+
__decorate([
|
|
3778
|
+
track('CaseInstances.GetSlaSummary')
|
|
3779
|
+
], CaseInstancesService.prototype, "getSlaSummary", null);
|
|
3780
|
+
__decorate([
|
|
3781
|
+
track('CaseInstances.GetStagesSlaSummary')
|
|
3782
|
+
], CaseInstancesService.prototype, "getStagesSlaSummary", null);
|
|
3539
3783
|
|
|
3540
|
-
export { CaseInstancesService as CaseInstances, CaseInstancesService, CasesService as Cases, CasesService, EscalationActionType, EscalationRecipientScope, EscalationTriggerType, SLADurationUnit, StageTaskType, createCaseInstanceWithMethods };
|
|
3784
|
+
export { CaseInstancesService as CaseInstances, CaseInstancesService, CasesService as Cases, CasesService, EscalationActionType, EscalationRecipientScope, EscalationTriggerType, InstanceFinalStatus, InstanceStatus, SLADurationUnit, SlaSummaryStatus, StageTaskType, TimeInterval, createCaseInstanceWithMethods };
|