@uipath/uipath-typescript 1.3.8 → 1.3.10
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 +44 -276
- package/dist/assets/index.mjs +44 -276
- package/dist/attachments/index.cjs +42 -273
- package/dist/attachments/index.mjs +42 -273
- package/dist/buckets/index.cjs +195 -276
- package/dist/buckets/index.d.ts +213 -1
- package/dist/buckets/index.mjs +195 -276
- package/dist/cases/index.cjs +427 -343
- package/dist/cases/index.d.ts +534 -2
- package/dist/cases/index.mjs +428 -344
- package/dist/conversational-agent/index.cjs +90 -287
- package/dist/conversational-agent/index.d.ts +62 -12
- package/dist/conversational-agent/index.mjs +90 -288
- 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 +251 -277
- package/dist/entities/index.d.ts +305 -2
- package/dist/entities/index.mjs +251 -277
- package/dist/feedback/index.cjs +42 -274
- package/dist/feedback/index.mjs +42 -274
- package/dist/index.cjs +998 -351
- package/dist/index.d.ts +2159 -762
- package/dist/index.mjs +998 -337
- package/dist/index.umd.js +1208 -237
- package/dist/jobs/index.cjs +44 -276
- package/dist/jobs/index.mjs +44 -276
- package/dist/maestro-processes/index.cjs +1761 -1717
- package/dist/maestro-processes/index.d.ts +430 -2
- package/dist/maestro-processes/index.mjs +1762 -1718
- package/dist/processes/index.cjs +72 -305
- package/dist/processes/index.d.ts +76 -26
- package/dist/processes/index.mjs +72 -305
- package/dist/queues/index.cjs +44 -276
- package/dist/queues/index.mjs +44 -276
- package/dist/tasks/index.cjs +44 -276
- package/dist/tasks/index.mjs +44 -276
- package/package.json +8 -10
package/dist/cases/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var coreTelemetry = require('@uipath/core-telemetry');
|
|
4
4
|
|
|
5
5
|
/******************************************************************************
|
|
6
6
|
Copyright (c) Microsoft Corporation.
|
|
@@ -56,6 +56,130 @@ var ProcessType;
|
|
|
56
56
|
ProcessType["CaseManagement"] = "CaseManagement";
|
|
57
57
|
})(ProcessType || (ProcessType = {}));
|
|
58
58
|
|
|
59
|
+
/**
|
|
60
|
+
* Base path constants for different services
|
|
61
|
+
*/
|
|
62
|
+
const ORCHESTRATOR_BASE = 'orchestrator_';
|
|
63
|
+
const PIMS_BASE = 'pims_';
|
|
64
|
+
const INSIGHTS_RTM_BASE = 'insightsrtm_';
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Orchestrator Service Endpoints
|
|
68
|
+
*/
|
|
69
|
+
/**
|
|
70
|
+
* Task Service (Action Center) Endpoints
|
|
71
|
+
*/
|
|
72
|
+
const TASK_ENDPOINTS = {
|
|
73
|
+
CREATE_GENERIC_TASK: `${ORCHESTRATOR_BASE}/tasks/GenericTasks/CreateTask`,
|
|
74
|
+
GET_TASK_USERS: (folderId) => `${ORCHESTRATOR_BASE}/odata/Tasks/UiPath.Server.Configuration.OData.GetTaskUsers(organizationUnitId=${folderId})`,
|
|
75
|
+
GET_TASKS_ACROSS_FOLDERS: `${ORCHESTRATOR_BASE}/odata/Tasks/UiPath.Server.Configuration.OData.GetTasksAcrossFolders`,
|
|
76
|
+
GET_TASKS_ACROSS_FOLDERS_ADMIN: `${ORCHESTRATOR_BASE}/odata/Tasks/UiPath.Server.Configuration.OData.GetTasksAcrossFoldersForAdmin`,
|
|
77
|
+
GET_BY_ID: (id) => `${ORCHESTRATOR_BASE}/odata/Tasks(${id})`,
|
|
78
|
+
ASSIGN_TASKS: `${ORCHESTRATOR_BASE}/odata/Tasks/UiPath.Server.Configuration.OData.AssignTasks`,
|
|
79
|
+
REASSIGN_TASKS: `${ORCHESTRATOR_BASE}/odata/Tasks/UiPath.Server.Configuration.OData.ReassignTasks`,
|
|
80
|
+
UNASSIGN_TASKS: `${ORCHESTRATOR_BASE}/odata/Tasks/UiPath.Server.Configuration.OData.UnassignTasks`,
|
|
81
|
+
COMPLETE_FORM_TASK: `${ORCHESTRATOR_BASE}/forms/TaskForms/CompleteTask`,
|
|
82
|
+
COMPLETE_APP_TASK: `${ORCHESTRATOR_BASE}/tasks/AppTasks/CompleteAppTask`,
|
|
83
|
+
COMPLETE_GENERIC_TASK: `${ORCHESTRATOR_BASE}/tasks/GenericTasks/CompleteTask`,
|
|
84
|
+
GET_TASK_FORM_BY_ID: `${ORCHESTRATOR_BASE}/forms/TaskForms/GetTaskFormById`,
|
|
85
|
+
GET_GENERIC_TASK_BY_ID: `${ORCHESTRATOR_BASE}/tasks/GenericTasks/GetTaskDataById`,
|
|
86
|
+
GET_APP_TASK_BY_ID: `${ORCHESTRATOR_BASE}/tasks/AppTasks/GetAppTaskById`,
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Maestro Service Endpoints
|
|
91
|
+
*/
|
|
92
|
+
/**
|
|
93
|
+
* Maestro Process Service Endpoints
|
|
94
|
+
*/
|
|
95
|
+
const MAESTRO_ENDPOINTS = {
|
|
96
|
+
PROCESSES: {
|
|
97
|
+
GET_ALL: `${PIMS_BASE}/api/v1/processes/summary`,
|
|
98
|
+
GET_SETTINGS: (processKey) => `${PIMS_BASE}/api/v1/processes/${processKey}/settings`,
|
|
99
|
+
},
|
|
100
|
+
INSTANCES: {
|
|
101
|
+
GET_ALL: `${PIMS_BASE}/api/v1/instances`,
|
|
102
|
+
GET_BY_ID: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}`,
|
|
103
|
+
GET_EXECUTION_HISTORY: (instanceId) => `${PIMS_BASE}/api/v1/spans/${instanceId}`,
|
|
104
|
+
GET_BPMN: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/bpmn`,
|
|
105
|
+
GET_VARIABLES: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/variables`,
|
|
106
|
+
CANCEL: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/cancel`,
|
|
107
|
+
PAUSE: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/pause`,
|
|
108
|
+
RESUME: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/resume`,
|
|
109
|
+
},
|
|
110
|
+
INCIDENTS: {
|
|
111
|
+
GET_ALL: `${PIMS_BASE}/api/v1/incidents/summary`,
|
|
112
|
+
GET_BY_PROCESS: (processKey) => `${PIMS_BASE}/api/v1/incidents/process/${processKey}`,
|
|
113
|
+
GET_BY_INSTANCE: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/incidents`,
|
|
114
|
+
},
|
|
115
|
+
CASES: {
|
|
116
|
+
GET_CASE_JSON: (instanceId) => `${PIMS_BASE}/api/v1/cases/${instanceId}/case-json`,
|
|
117
|
+
GET_ELEMENT_EXECUTIONS: (instanceId) => `${PIMS_BASE}/api/v1/element-executions/case-instances/${instanceId}`,
|
|
118
|
+
REOPEN: (instanceId) => `${PIMS_BASE}/api/v1/cases/${instanceId}/reopen`,
|
|
119
|
+
},
|
|
120
|
+
INSIGHTS: {
|
|
121
|
+
/** SLA summary for case instances */
|
|
122
|
+
SLA_SUMMARY: `${INSIGHTS_RTM_BASE}/caseManagement/slaSummary`,
|
|
123
|
+
/** Stages summary for case instances */
|
|
124
|
+
STAGES_SUMMARY: `${INSIGHTS_RTM_BASE}/caseManagement/stages`,
|
|
125
|
+
/** Top processes ranked by run count */
|
|
126
|
+
TOP_PROCESSES_BY_RUN_COUNT: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/TopProcessesByRunCount`,
|
|
127
|
+
/** Top processes ranked by failure count */
|
|
128
|
+
TOP_PROCESSES_WITH_FAILURE: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/TopProcesseswithFailure`,
|
|
129
|
+
/** Instance status aggregated by date for time-series charts */
|
|
130
|
+
INSTANCE_STATUS_BY_DATE: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/InstanceStatusByDate`,
|
|
131
|
+
/** Top processes ranked by total duration */
|
|
132
|
+
TOP_PROCESSES_BY_DURATION: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/TopProcessesByDuration`,
|
|
133
|
+
},
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Builds the request body for Insights RTM "top" endpoints.
|
|
138
|
+
*
|
|
139
|
+
* @param startTime - Start of the time range to query
|
|
140
|
+
* @param endTime - End of the time range to query
|
|
141
|
+
* @param isCaseManagement - Whether to filter for case management processes
|
|
142
|
+
* @param options - Optional filters (packageId, processKey, version)
|
|
143
|
+
* @returns Request body for the Insights RTM endpoint
|
|
144
|
+
* @internal
|
|
145
|
+
*/
|
|
146
|
+
function buildInsightsTopBody(startTime, endTime, isCaseManagement, options) {
|
|
147
|
+
return {
|
|
148
|
+
commonParams: {
|
|
149
|
+
startTime: startTime.getTime(),
|
|
150
|
+
endTime: endTime.getTime(),
|
|
151
|
+
isCaseManagement,
|
|
152
|
+
...(options?.packageId ? { packageId: options.packageId } : {}),
|
|
153
|
+
...(options?.processKey ? { processKey: options.processKey } : {}),
|
|
154
|
+
...(options?.version ? { version: options.version } : {}),
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Fetches instance status timeline from the Insights API.
|
|
160
|
+
* Shared implementation used by both MaestroProcessesService and CasesService.
|
|
161
|
+
*
|
|
162
|
+
* @param postFn - Bound post method from a BaseService subclass
|
|
163
|
+
* @param startTime - Start of the time range to query
|
|
164
|
+
* @param endTime - End of the time range to query
|
|
165
|
+
* @param isCaseManagement - Whether to filter for case management processes
|
|
166
|
+
* @param options - Optional settings for time bucketing granularity
|
|
167
|
+
* @returns Promise resolving to an array of instance status timeline entries
|
|
168
|
+
* @internal
|
|
169
|
+
*/
|
|
170
|
+
async function fetchInstanceStatusTimeline(postFn, startTime, endTime, isCaseManagement, options) {
|
|
171
|
+
const response = await postFn(MAESTRO_ENDPOINTS.INSIGHTS.INSTANCE_STATUS_BY_DATE, {
|
|
172
|
+
commonParams: {
|
|
173
|
+
startTime: startTime.getTime(),
|
|
174
|
+
endTime: endTime.getTime(),
|
|
175
|
+
isCaseManagement,
|
|
176
|
+
},
|
|
177
|
+
timeSliceUnit: options?.groupBy,
|
|
178
|
+
timezoneOffset: new Date().getTimezoneOffset() * -1,
|
|
179
|
+
});
|
|
180
|
+
return response.data ?? [];
|
|
181
|
+
}
|
|
182
|
+
|
|
59
183
|
/**
|
|
60
184
|
* Type guards for error response types
|
|
61
185
|
*/
|
|
@@ -624,14 +748,25 @@ class ApiClient {
|
|
|
624
748
|
if (!text) {
|
|
625
749
|
return undefined;
|
|
626
750
|
}
|
|
627
|
-
|
|
751
|
+
try {
|
|
752
|
+
return JSON.parse(text);
|
|
753
|
+
}
|
|
754
|
+
catch (error) {
|
|
755
|
+
if (error instanceof SyntaxError) {
|
|
756
|
+
throw new ServerError({
|
|
757
|
+
message: `Server returned non-JSON response (${response.status} ${response.url}): ${error.message}`,
|
|
758
|
+
statusCode: response.status,
|
|
759
|
+
});
|
|
760
|
+
}
|
|
761
|
+
throw error;
|
|
762
|
+
}
|
|
628
763
|
}
|
|
629
764
|
catch (error) {
|
|
630
765
|
// If it's already one of our errors, re-throw it
|
|
631
766
|
if (error.type && error.type.includes('Error')) {
|
|
632
767
|
throw error;
|
|
633
768
|
}
|
|
634
|
-
// Otherwise, it's
|
|
769
|
+
// Otherwise, it's a genuine network/fetch failure
|
|
635
770
|
throw ErrorFactory.createNetworkError(error);
|
|
636
771
|
}
|
|
637
772
|
}
|
|
@@ -1398,9 +1533,9 @@ class PaginationHelpers {
|
|
|
1398
1533
|
* @returns Promise resolving to a paginated result
|
|
1399
1534
|
*/
|
|
1400
1535
|
static async getAllPaginated(params) {
|
|
1401
|
-
const { serviceAccess, getEndpoint, folderId, paginationParams, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
|
|
1536
|
+
const { serviceAccess, getEndpoint, folderId, headers: providedHeaders, paginationParams, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
|
|
1402
1537
|
const endpoint = getEndpoint(folderId);
|
|
1403
|
-
const headers = folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {};
|
|
1538
|
+
const headers = providedHeaders ?? (folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {});
|
|
1404
1539
|
const paginatedResponse = await serviceAccess.requestWithPagination(method, endpoint, paginationParams, {
|
|
1405
1540
|
headers,
|
|
1406
1541
|
params: additionalParams,
|
|
@@ -1428,13 +1563,13 @@ class PaginationHelpers {
|
|
|
1428
1563
|
* @returns Promise resolving to an object with data and totalCount
|
|
1429
1564
|
*/
|
|
1430
1565
|
static async getAllNonPaginated(params) {
|
|
1431
|
-
const { serviceAccess, getAllEndpoint, getByFolderEndpoint, folderId, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
|
|
1566
|
+
const { serviceAccess, getAllEndpoint, getByFolderEndpoint, folderId, headers: providedHeaders, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
|
|
1432
1567
|
// Set default field names
|
|
1433
1568
|
const itemsField = options.itemsField || DEFAULT_ITEMS_FIELD;
|
|
1434
1569
|
const totalCountField = options.totalCountField || DEFAULT_TOTAL_COUNT_FIELD;
|
|
1435
1570
|
// Determine endpoint and headers based on folderId
|
|
1436
1571
|
const endpoint = folderId ? getByFolderEndpoint : getAllEndpoint;
|
|
1437
|
-
const headers = folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {};
|
|
1572
|
+
const headers = providedHeaders ?? (folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {});
|
|
1438
1573
|
// Make the API call based on method
|
|
1439
1574
|
let response;
|
|
1440
1575
|
if (method === HTTP_METHODS.POST) {
|
|
@@ -1493,6 +1628,7 @@ class PaginationHelpers {
|
|
|
1493
1628
|
serviceAccess: config.serviceAccess,
|
|
1494
1629
|
getEndpoint: config.getEndpoint,
|
|
1495
1630
|
folderId,
|
|
1631
|
+
headers: config.headers,
|
|
1496
1632
|
paginationParams: cursor ? { cursor, pageSize } : jumpToPage ? { jumpToPage, pageSize } : { pageSize },
|
|
1497
1633
|
additionalParams: prefixedOptions,
|
|
1498
1634
|
transformFn: config.transformFn,
|
|
@@ -1510,6 +1646,7 @@ class PaginationHelpers {
|
|
|
1510
1646
|
getAllEndpoint: config.getEndpoint(),
|
|
1511
1647
|
getByFolderEndpoint: byFolderEndpoint,
|
|
1512
1648
|
folderId,
|
|
1649
|
+
headers: config.headers,
|
|
1513
1650
|
additionalParams: prefixedOptions,
|
|
1514
1651
|
transformFn: config.transformFn,
|
|
1515
1652
|
method: config.method,
|
|
@@ -1835,345 +1972,33 @@ class BaseService {
|
|
|
1835
1972
|
_BaseService_apiClient = new WeakMap();
|
|
1836
1973
|
|
|
1837
1974
|
/**
|
|
1838
|
-
*
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
*
|
|
1846
|
-
*/
|
|
1847
|
-
/**
|
|
1848
|
-
|
|
1849
|
-
*/
|
|
1850
|
-
const TASK_ENDPOINTS = {
|
|
1851
|
-
CREATE_GENERIC_TASK: `${ORCHESTRATOR_BASE}/tasks/GenericTasks/CreateTask`,
|
|
1852
|
-
GET_TASK_USERS: (folderId) => `${ORCHESTRATOR_BASE}/odata/Tasks/UiPath.Server.Configuration.OData.GetTaskUsers(organizationUnitId=${folderId})`,
|
|
1853
|
-
GET_TASKS_ACROSS_FOLDERS: `${ORCHESTRATOR_BASE}/odata/Tasks/UiPath.Server.Configuration.OData.GetTasksAcrossFolders`,
|
|
1854
|
-
GET_TASKS_ACROSS_FOLDERS_ADMIN: `${ORCHESTRATOR_BASE}/odata/Tasks/UiPath.Server.Configuration.OData.GetTasksAcrossFoldersForAdmin`,
|
|
1855
|
-
GET_BY_ID: (id) => `${ORCHESTRATOR_BASE}/odata/Tasks(${id})`,
|
|
1856
|
-
ASSIGN_TASKS: `${ORCHESTRATOR_BASE}/odata/Tasks/UiPath.Server.Configuration.OData.AssignTasks`,
|
|
1857
|
-
REASSIGN_TASKS: `${ORCHESTRATOR_BASE}/odata/Tasks/UiPath.Server.Configuration.OData.ReassignTasks`,
|
|
1858
|
-
UNASSIGN_TASKS: `${ORCHESTRATOR_BASE}/odata/Tasks/UiPath.Server.Configuration.OData.UnassignTasks`,
|
|
1859
|
-
COMPLETE_FORM_TASK: `${ORCHESTRATOR_BASE}/forms/TaskForms/CompleteTask`,
|
|
1860
|
-
COMPLETE_APP_TASK: `${ORCHESTRATOR_BASE}/tasks/AppTasks/CompleteAppTask`,
|
|
1861
|
-
COMPLETE_GENERIC_TASK: `${ORCHESTRATOR_BASE}/tasks/GenericTasks/CompleteTask`,
|
|
1862
|
-
GET_TASK_FORM_BY_ID: `${ORCHESTRATOR_BASE}/forms/TaskForms/GetTaskFormById`,
|
|
1863
|
-
GET_GENERIC_TASK_BY_ID: `${ORCHESTRATOR_BASE}/tasks/GenericTasks/GetTaskDataById`,
|
|
1864
|
-
GET_APP_TASK_BY_ID: `${ORCHESTRATOR_BASE}/tasks/AppTasks/GetAppTaskById`,
|
|
1865
|
-
};
|
|
1866
|
-
|
|
1867
|
-
/**
|
|
1868
|
-
* Maestro Service Endpoints
|
|
1869
|
-
*/
|
|
1870
|
-
/**
|
|
1871
|
-
* Maestro Process Service Endpoints
|
|
1872
|
-
*/
|
|
1873
|
-
const MAESTRO_ENDPOINTS = {
|
|
1874
|
-
PROCESSES: {
|
|
1875
|
-
GET_ALL: `${PIMS_BASE}/api/v1/processes/summary`,
|
|
1876
|
-
GET_SETTINGS: (processKey) => `${PIMS_BASE}/api/v1/processes/${processKey}/settings`,
|
|
1877
|
-
},
|
|
1878
|
-
INSTANCES: {
|
|
1879
|
-
GET_ALL: `${PIMS_BASE}/api/v1/instances`,
|
|
1880
|
-
GET_BY_ID: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}`,
|
|
1881
|
-
GET_EXECUTION_HISTORY: (instanceId) => `${PIMS_BASE}/api/v1/spans/${instanceId}`,
|
|
1882
|
-
GET_BPMN: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/bpmn`,
|
|
1883
|
-
GET_VARIABLES: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/variables`,
|
|
1884
|
-
CANCEL: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/cancel`,
|
|
1885
|
-
PAUSE: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/pause`,
|
|
1886
|
-
RESUME: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/resume`,
|
|
1887
|
-
},
|
|
1888
|
-
INCIDENTS: {
|
|
1889
|
-
GET_ALL: `${PIMS_BASE}/api/v1/incidents/summary`,
|
|
1890
|
-
GET_BY_PROCESS: (processKey) => `${PIMS_BASE}/api/v1/incidents/process/${processKey}`,
|
|
1891
|
-
GET_BY_INSTANCE: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/incidents`,
|
|
1892
|
-
},
|
|
1893
|
-
CASES: {
|
|
1894
|
-
GET_CASE_JSON: (instanceId) => `${PIMS_BASE}/api/v1/cases/${instanceId}/case-json`,
|
|
1895
|
-
GET_ELEMENT_EXECUTIONS: (instanceId) => `${PIMS_BASE}/api/v1/element-executions/case-instances/${instanceId}`,
|
|
1896
|
-
REOPEN: (instanceId) => `${PIMS_BASE}/api/v1/cases/${instanceId}/reopen`,
|
|
1897
|
-
},
|
|
1898
|
-
INSIGHTS: {
|
|
1899
|
-
/** SLA summary for case instances */
|
|
1900
|
-
SLA_SUMMARY: `${INSIGHTS_RTM_BASE}/caseManagement/slaSummary`,
|
|
1901
|
-
},
|
|
1902
|
-
};
|
|
1903
|
-
|
|
1904
|
-
/**
|
|
1905
|
-
* SDK Telemetry constants
|
|
1906
|
-
*/
|
|
1907
|
-
// Connection string placeholder that will be replaced during build
|
|
1908
|
-
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";
|
|
1909
|
-
// SDK Version placeholder
|
|
1910
|
-
const SDK_VERSION = "1.3.8";
|
|
1911
|
-
const VERSION = "Version";
|
|
1912
|
-
const SERVICE = "Service";
|
|
1913
|
-
const CLOUD_ORGANIZATION_NAME = "CloudOrganizationName";
|
|
1914
|
-
const CLOUD_TENANT_NAME = "CloudTenantName";
|
|
1915
|
-
const CLOUD_URL = "CloudUrl";
|
|
1916
|
-
const CLOUD_CLIENT_ID = "CloudClientId";
|
|
1917
|
-
const CLOUD_REDIRECT_URI = "CloudRedirectUri";
|
|
1918
|
-
const APP_NAME = "ApplicationName";
|
|
1919
|
-
const CLOUD_ROLE_NAME = "uipath-ts-sdk";
|
|
1920
|
-
// Service and logger names
|
|
1921
|
-
const SDK_SERVICE_NAME = "UiPath.TypeScript.Sdk";
|
|
1922
|
-
const SDK_LOGGER_NAME = "uipath-ts-sdk-telemetry";
|
|
1923
|
-
// Event names
|
|
1924
|
-
const SDK_RUN_EVENT = "Sdk.Run";
|
|
1925
|
-
// Default value for unknown/empty attributes
|
|
1926
|
-
const UNKNOWN = "";
|
|
1927
|
-
|
|
1928
|
-
/**
|
|
1929
|
-
* Log exporter that sends ALL logs as Application Insights custom events
|
|
1930
|
-
*/
|
|
1931
|
-
class ApplicationInsightsEventExporter {
|
|
1932
|
-
constructor(connectionString) {
|
|
1933
|
-
this.connectionString = connectionString;
|
|
1934
|
-
}
|
|
1935
|
-
export(logs, resultCallback) {
|
|
1936
|
-
try {
|
|
1937
|
-
logs.forEach(logRecord => {
|
|
1938
|
-
this.sendAsCustomEvent(logRecord);
|
|
1939
|
-
});
|
|
1940
|
-
resultCallback({ code: 0 });
|
|
1941
|
-
}
|
|
1942
|
-
catch (error) {
|
|
1943
|
-
console.debug('Failed to export logs to Application Insights:', error);
|
|
1944
|
-
resultCallback({ code: 2, error });
|
|
1945
|
-
}
|
|
1946
|
-
}
|
|
1947
|
-
shutdown() {
|
|
1948
|
-
return Promise.resolve();
|
|
1949
|
-
}
|
|
1950
|
-
sendAsCustomEvent(logRecord) {
|
|
1951
|
-
// Get event name from body or attributes
|
|
1952
|
-
const eventName = logRecord.body || SDK_RUN_EVENT;
|
|
1953
|
-
const payload = {
|
|
1954
|
-
name: 'Microsoft.ApplicationInsights.Event',
|
|
1955
|
-
time: new Date().toISOString(),
|
|
1956
|
-
iKey: this.extractInstrumentationKey(),
|
|
1957
|
-
data: {
|
|
1958
|
-
baseType: 'EventData',
|
|
1959
|
-
baseData: {
|
|
1960
|
-
ver: 2,
|
|
1961
|
-
name: eventName,
|
|
1962
|
-
properties: this.convertAttributesToProperties(logRecord.attributes || {})
|
|
1963
|
-
}
|
|
1964
|
-
},
|
|
1965
|
-
tags: {
|
|
1966
|
-
'ai.cloud.role': CLOUD_ROLE_NAME,
|
|
1967
|
-
'ai.cloud.roleInstance': SDK_VERSION
|
|
1968
|
-
}
|
|
1969
|
-
};
|
|
1970
|
-
this.sendToApplicationInsights(payload);
|
|
1971
|
-
}
|
|
1972
|
-
extractInstrumentationKey() {
|
|
1973
|
-
const match = this.connectionString.match(/InstrumentationKey=([^;]+)/);
|
|
1974
|
-
return match ? match[1] : '';
|
|
1975
|
-
}
|
|
1976
|
-
convertAttributesToProperties(attributes) {
|
|
1977
|
-
const properties = {};
|
|
1978
|
-
Object.entries(attributes || {}).forEach(([key, value]) => {
|
|
1979
|
-
properties[key] = String(value);
|
|
1980
|
-
});
|
|
1981
|
-
return properties;
|
|
1982
|
-
}
|
|
1983
|
-
async sendToApplicationInsights(payload) {
|
|
1984
|
-
try {
|
|
1985
|
-
const ingestionEndpoint = this.extractIngestionEndpoint();
|
|
1986
|
-
if (!ingestionEndpoint) {
|
|
1987
|
-
console.debug('No ingestion endpoint found in connection string');
|
|
1988
|
-
return;
|
|
1989
|
-
}
|
|
1990
|
-
const url = `${ingestionEndpoint}/v2/track`;
|
|
1991
|
-
const response = await fetch(url, {
|
|
1992
|
-
method: 'POST',
|
|
1993
|
-
headers: {
|
|
1994
|
-
'Content-Type': 'application/json',
|
|
1995
|
-
},
|
|
1996
|
-
body: JSON.stringify(payload)
|
|
1997
|
-
});
|
|
1998
|
-
if (!response.ok) {
|
|
1999
|
-
console.debug(`Failed to send event telemetry: ${response.status} ${response.statusText}`);
|
|
2000
|
-
}
|
|
2001
|
-
}
|
|
2002
|
-
catch (error) {
|
|
2003
|
-
console.debug('Error sending event telemetry to Application Insights:', error);
|
|
2004
|
-
}
|
|
2005
|
-
}
|
|
2006
|
-
extractIngestionEndpoint() {
|
|
2007
|
-
const match = this.connectionString.match(/IngestionEndpoint=([^;]+)/);
|
|
2008
|
-
return match ? match[1] : '';
|
|
2009
|
-
}
|
|
2010
|
-
}
|
|
2011
|
-
/**
|
|
2012
|
-
* Singleton telemetry client
|
|
2013
|
-
*/
|
|
2014
|
-
class TelemetryClient {
|
|
2015
|
-
constructor() {
|
|
2016
|
-
this.isInitialized = false;
|
|
2017
|
-
}
|
|
2018
|
-
static getInstance() {
|
|
2019
|
-
if (!TelemetryClient.instance) {
|
|
2020
|
-
TelemetryClient.instance = new TelemetryClient();
|
|
2021
|
-
}
|
|
2022
|
-
return TelemetryClient.instance;
|
|
2023
|
-
}
|
|
2024
|
-
/**
|
|
2025
|
-
* Initialize telemetry
|
|
2026
|
-
*/
|
|
2027
|
-
initialize(config) {
|
|
2028
|
-
if (this.isInitialized) {
|
|
2029
|
-
return;
|
|
2030
|
-
}
|
|
2031
|
-
this.isInitialized = true;
|
|
2032
|
-
if (config) {
|
|
2033
|
-
this.telemetryContext = config;
|
|
2034
|
-
}
|
|
2035
|
-
try {
|
|
2036
|
-
const connectionString = this.getConnectionString();
|
|
2037
|
-
if (!connectionString) {
|
|
2038
|
-
return;
|
|
2039
|
-
}
|
|
2040
|
-
this.setupTelemetryProvider(connectionString);
|
|
2041
|
-
}
|
|
2042
|
-
catch (error) {
|
|
2043
|
-
// Silent failure - telemetry errors shouldn't break functionality
|
|
2044
|
-
console.debug('Failed to initialize OpenTelemetry:', error);
|
|
2045
|
-
}
|
|
2046
|
-
}
|
|
2047
|
-
getConnectionString() {
|
|
2048
|
-
const connectionString = CONNECTION_STRING;
|
|
2049
|
-
return connectionString;
|
|
2050
|
-
}
|
|
2051
|
-
setupTelemetryProvider(connectionString) {
|
|
2052
|
-
const exporter = new ApplicationInsightsEventExporter(connectionString);
|
|
2053
|
-
const processor = new sdkLogs.BatchLogRecordProcessor(exporter);
|
|
2054
|
-
this.logProvider = new sdkLogs.LoggerProvider({
|
|
2055
|
-
processors: [processor]
|
|
2056
|
-
});
|
|
2057
|
-
this.logger = this.logProvider.getLogger(SDK_LOGGER_NAME);
|
|
2058
|
-
}
|
|
2059
|
-
/**
|
|
2060
|
-
* Track a telemetry event
|
|
2061
|
-
*/
|
|
2062
|
-
track(eventName, name, extraAttributes = {}) {
|
|
2063
|
-
try {
|
|
2064
|
-
// Skip if logger not initialized
|
|
2065
|
-
if (!this.logger) {
|
|
2066
|
-
return;
|
|
2067
|
-
}
|
|
2068
|
-
const finalDisplayName = name || eventName;
|
|
2069
|
-
const attributes = this.getEnrichedAttributes(extraAttributes, eventName);
|
|
2070
|
-
// Emit as log
|
|
2071
|
-
this.logger.emit({
|
|
2072
|
-
body: finalDisplayName,
|
|
2073
|
-
attributes: attributes,
|
|
2074
|
-
timestamp: Date.now(),
|
|
2075
|
-
});
|
|
2076
|
-
}
|
|
2077
|
-
catch (error) {
|
|
2078
|
-
// Silent failure
|
|
2079
|
-
console.debug('Failed to track telemetry event:', error);
|
|
2080
|
-
}
|
|
2081
|
-
}
|
|
2082
|
-
/**
|
|
2083
|
-
* Get enriched attributes for telemetry events
|
|
2084
|
-
*/
|
|
2085
|
-
getEnrichedAttributes(extraAttributes, eventName) {
|
|
2086
|
-
const attributes = {
|
|
2087
|
-
[APP_NAME]: SDK_SERVICE_NAME,
|
|
2088
|
-
[VERSION]: SDK_VERSION,
|
|
2089
|
-
[SERVICE]: eventName,
|
|
2090
|
-
[CLOUD_URL]: this.createCloudUrl(),
|
|
2091
|
-
[CLOUD_ORGANIZATION_NAME]: this.telemetryContext?.orgName || UNKNOWN,
|
|
2092
|
-
[CLOUD_TENANT_NAME]: this.telemetryContext?.tenantName || UNKNOWN,
|
|
2093
|
-
[CLOUD_REDIRECT_URI]: this.telemetryContext?.redirectUri || UNKNOWN,
|
|
2094
|
-
[CLOUD_CLIENT_ID]: this.telemetryContext?.clientId || UNKNOWN,
|
|
2095
|
-
...extraAttributes,
|
|
2096
|
-
};
|
|
2097
|
-
return attributes;
|
|
2098
|
-
}
|
|
2099
|
-
/**
|
|
2100
|
-
* Create cloud URL from base URL, organization ID, and tenant ID
|
|
2101
|
-
*/
|
|
2102
|
-
createCloudUrl() {
|
|
2103
|
-
const baseUrl = this.telemetryContext?.baseUrl;
|
|
2104
|
-
const orgId = this.telemetryContext?.orgName;
|
|
2105
|
-
const tenantId = this.telemetryContext?.tenantName;
|
|
2106
|
-
if (!baseUrl || !orgId || !tenantId) {
|
|
2107
|
-
return UNKNOWN;
|
|
2108
|
-
}
|
|
2109
|
-
return `${baseUrl}/${orgId}/${tenantId}`;
|
|
2110
|
-
}
|
|
2111
|
-
}
|
|
2112
|
-
// Export singleton instance
|
|
2113
|
-
const telemetryClient = TelemetryClient.getInstance();
|
|
1975
|
+
* SDK Telemetry constants.
|
|
1976
|
+
*
|
|
1977
|
+
* Only the SDK's identity (version, service name, role name, …) lives
|
|
1978
|
+
* here. The Application Insights connection string is injected into
|
|
1979
|
+
* `@uipath/core-telemetry` itself at publish time, and the generic attribute
|
|
1980
|
+
* keys (`Version`, `Service`, `CloudOrganizationName`, …) are owned by
|
|
1981
|
+
* `@uipath/core-telemetry` and consumed there — they are not part of the
|
|
1982
|
+
* SDK's public API.
|
|
1983
|
+
*/
|
|
1984
|
+
/** SDK version placeholder — patched by the SDK publish workflow. */
|
|
1985
|
+
const CLOUD_ROLE_NAME = 'uipath-ts-sdk';
|
|
2114
1986
|
|
|
2115
1987
|
/**
|
|
2116
|
-
*
|
|
2117
|
-
*/
|
|
2118
|
-
/**
|
|
2119
|
-
* Common tracking logic shared between method and function decorators
|
|
2120
|
-
*/
|
|
2121
|
-
function createTrackedFunction(originalFunction, nameOrOptions, fallbackName, opts) {
|
|
2122
|
-
return function (...args) {
|
|
2123
|
-
// Determine if we should track this call
|
|
2124
|
-
let shouldTrack = true;
|
|
2125
|
-
if (opts.condition !== undefined) {
|
|
2126
|
-
if (typeof opts.condition === 'function') {
|
|
2127
|
-
shouldTrack = opts.condition.apply(this, args);
|
|
2128
|
-
}
|
|
2129
|
-
else {
|
|
2130
|
-
shouldTrack = opts.condition;
|
|
2131
|
-
}
|
|
2132
|
-
}
|
|
2133
|
-
// Track the event if enabled
|
|
2134
|
-
if (shouldTrack) {
|
|
2135
|
-
// Use the full name provided in the decorator (e.g., "Queue.GetAll")
|
|
2136
|
-
const serviceMethod = typeof nameOrOptions === 'string'
|
|
2137
|
-
? nameOrOptions
|
|
2138
|
-
: fallbackName;
|
|
2139
|
-
// Use 'Sdk.Run' as the name and serviceMethod as the service
|
|
2140
|
-
telemetryClient.track(serviceMethod, SDK_RUN_EVENT, opts.attributes);
|
|
2141
|
-
}
|
|
2142
|
-
// Execute the original function
|
|
2143
|
-
return originalFunction.apply(this, args);
|
|
2144
|
-
};
|
|
2145
|
-
}
|
|
2146
|
-
/**
|
|
2147
|
-
* Track decorator that can be used to automatically track function calls
|
|
2148
|
-
*
|
|
2149
|
-
* Usage:
|
|
2150
|
-
* @track("Service.Method")
|
|
2151
|
-
* function myFunction() { ... }
|
|
2152
|
-
*
|
|
2153
|
-
* @track("Queue.GetAll")
|
|
2154
|
-
* async getAll() { ... }
|
|
2155
|
-
*
|
|
2156
|
-
* @track("Tasks.Create")
|
|
2157
|
-
* async create() { ... }
|
|
2158
|
-
*
|
|
2159
|
-
* @track("Assets.Update", { condition: false })
|
|
2160
|
-
* function myFunction() { ... }
|
|
1988
|
+
* UiPath TypeScript SDK Telemetry
|
|
2161
1989
|
*
|
|
2162
|
-
*
|
|
2163
|
-
*
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
return (originalFunction) => createTrackedFunction(originalFunction, nameOrOptions, originalFunction.name || 'unknown_function', opts);
|
|
2175
|
-
};
|
|
2176
|
-
}
|
|
1990
|
+
* Constructs the SDK's own `TelemetryClient` and binds the SDK-local
|
|
1991
|
+
* `track` / `trackEvent` to it. Each consumer of `@uipath/core-telemetry`
|
|
1992
|
+
* does this independently, so events carry their own consumer's identity
|
|
1993
|
+
* and tenant context.
|
|
1994
|
+
*/
|
|
1995
|
+
// Keyed by `CLOUD_ROLE_NAME` so every SDK subpath bundle resolves to the
|
|
1996
|
+
// same `TelemetryClient` instance at runtime. A single `initialize(...)`
|
|
1997
|
+
// from the `UiPath` constructor therefore wires up `@track` decorators
|
|
1998
|
+
// across every subpath bundle (`assets`, `feedback`, `tasks`, …).
|
|
1999
|
+
const sdkClient = coreTelemetry.getOrCreateClient(CLOUD_ROLE_NAME);
|
|
2000
|
+
const track = coreTelemetry.createTrack(sdkClient);
|
|
2001
|
+
coreTelemetry.createTrackEvent(sdkClient);
|
|
2177
2002
|
|
|
2178
2003
|
/**
|
|
2179
2004
|
* Creates query parameters object from key-value pairs, filtering out undefined values
|
|
@@ -2245,6 +2070,177 @@ class CasesService extends BaseService {
|
|
|
2245
2070
|
name: this.extractCaseName(caseItem.packageId)
|
|
2246
2071
|
}));
|
|
2247
2072
|
}
|
|
2073
|
+
/**
|
|
2074
|
+
* Get the top 5 case processes ranked by run count within a time range.
|
|
2075
|
+
*
|
|
2076
|
+
* Returns an array of up to 5 case processes sorted by how many times they were executed,
|
|
2077
|
+
* useful for identifying the most active case processes in a given period.
|
|
2078
|
+
*
|
|
2079
|
+
* @param startTime - Start of the time range to query
|
|
2080
|
+
* @param endTime - End of the time range to query
|
|
2081
|
+
* @param options - Optional filters (packageId, processKey, version)
|
|
2082
|
+
* @returns Promise resolving to an array of {@link CaseGetTopRunCountResponse}
|
|
2083
|
+
* @example
|
|
2084
|
+
* ```typescript
|
|
2085
|
+
* import { Cases } from '@uipath/uipath-typescript/cases';
|
|
2086
|
+
*
|
|
2087
|
+
* const cases = new Cases(sdk);
|
|
2088
|
+
*
|
|
2089
|
+
* // Get top case processes by run count for the last 7 days
|
|
2090
|
+
* const topProcesses = await cases.getTopRunCount(
|
|
2091
|
+
* new Date(Date.now() - 7 * 24 * 60 * 60 * 1000),
|
|
2092
|
+
* new Date()
|
|
2093
|
+
* );
|
|
2094
|
+
*
|
|
2095
|
+
* for (const process of topProcesses) {
|
|
2096
|
+
* console.log(`${process.packageId}: ${process.runCount} runs`);
|
|
2097
|
+
* }
|
|
2098
|
+
* ```
|
|
2099
|
+
*
|
|
2100
|
+
* @example
|
|
2101
|
+
* ```typescript
|
|
2102
|
+
* // Get top case processes by run count for a specific package
|
|
2103
|
+
* const filtered = await cases.getTopRunCount(
|
|
2104
|
+
* new Date(Date.now() - 7 * 24 * 60 * 60 * 1000),
|
|
2105
|
+
* new Date(),
|
|
2106
|
+
* { packageId: '<packageId>' }
|
|
2107
|
+
* );
|
|
2108
|
+
* ```
|
|
2109
|
+
*/
|
|
2110
|
+
async getTopRunCount(startTime, endTime, options) {
|
|
2111
|
+
const { data } = await this.post(MAESTRO_ENDPOINTS.INSIGHTS.TOP_PROCESSES_BY_RUN_COUNT, buildInsightsTopBody(startTime, endTime, true, options));
|
|
2112
|
+
return (data ?? []).map(process => ({ ...process, name: this.extractCaseName(process.packageId) }));
|
|
2113
|
+
}
|
|
2114
|
+
/**
|
|
2115
|
+
* Get all instances status counts aggregated by date for case management processes.
|
|
2116
|
+
*
|
|
2117
|
+
* Returns time-grouped counts of case instances grouped by status (Completed, Faulted, Cancelled),
|
|
2118
|
+
* useful for rendering time-series charts. Use `groupBy` to control the time bucket size
|
|
2119
|
+
* (hour, day, or week) — defaults to day if not provided.
|
|
2120
|
+
*
|
|
2121
|
+
* @param startTime - Start of the time range to query
|
|
2122
|
+
* @param endTime - End of the time range to query
|
|
2123
|
+
* @param options - Optional settings for time bucketing granularity
|
|
2124
|
+
* @returns Promise resolving to an array of {@link InstanceStatusTimelineResponse}
|
|
2125
|
+
*
|
|
2126
|
+
* @example
|
|
2127
|
+
* ```typescript
|
|
2128
|
+
* // Get daily instance status for the last 7 days
|
|
2129
|
+
* const now = new Date();
|
|
2130
|
+
* const sevenDaysAgo = new Date(Date.now() - 7 * 24 * 60 * 60 * 1000);
|
|
2131
|
+
* const statuses = await cases.getInstanceStatusTimeline(sevenDaysAgo, now);
|
|
2132
|
+
*
|
|
2133
|
+
* for (const entry of statuses) {
|
|
2134
|
+
* console.log(`${entry.startTime} — ${entry.status}: ${entry.count}`);
|
|
2135
|
+
* }
|
|
2136
|
+
* ```
|
|
2137
|
+
*
|
|
2138
|
+
* @example
|
|
2139
|
+
* ```typescript
|
|
2140
|
+
* import { TimeInterval } from '@uipath/uipath-typescript/cases';
|
|
2141
|
+
*
|
|
2142
|
+
* // Get weekly breakdown
|
|
2143
|
+
* const statuses = await cases.getInstanceStatusTimeline(startTime, endTime, {
|
|
2144
|
+
* groupBy: TimeInterval.Week,
|
|
2145
|
+
* });
|
|
2146
|
+
* ```
|
|
2147
|
+
*
|
|
2148
|
+
* @example
|
|
2149
|
+
* ```typescript
|
|
2150
|
+
* // Get all-time data (from Unix epoch to now)
|
|
2151
|
+
* const allTime = await cases.getInstanceStatusTimeline(new Date(0), new Date());
|
|
2152
|
+
* ```
|
|
2153
|
+
*/
|
|
2154
|
+
async getInstanceStatusTimeline(startTime, endTime, options) {
|
|
2155
|
+
return fetchInstanceStatusTimeline(this.post.bind(this), startTime, endTime, true, options);
|
|
2156
|
+
}
|
|
2157
|
+
/**
|
|
2158
|
+
* Get the top 10 case processes ranked by failure count within a time range.
|
|
2159
|
+
*
|
|
2160
|
+
* Returns an array of up to 10 case processes sorted by how many instances faulted,
|
|
2161
|
+
* useful for identifying the most error-prone case processes in a given period.
|
|
2162
|
+
*
|
|
2163
|
+
* @param startTime - Start of the time range to query
|
|
2164
|
+
* @param endTime - End of the time range to query
|
|
2165
|
+
* @param options - Optional filters (packageId, processKey, version)
|
|
2166
|
+
* @returns Promise resolving to an array of {@link CaseGetTopFaultedCountResponse}
|
|
2167
|
+
* @example
|
|
2168
|
+
* ```typescript
|
|
2169
|
+
* import { Cases } from '@uipath/uipath-typescript/cases';
|
|
2170
|
+
*
|
|
2171
|
+
* const cases = new Cases(sdk);
|
|
2172
|
+
*
|
|
2173
|
+
* // Get top case processes by faulted count for the last 7 days
|
|
2174
|
+
* const topFailing = await cases.getTopFaultedCount(
|
|
2175
|
+
* new Date(Date.now() - 7 * 24 * 60 * 60 * 1000),
|
|
2176
|
+
* new Date()
|
|
2177
|
+
* );
|
|
2178
|
+
*
|
|
2179
|
+
* for (const process of topFailing) {
|
|
2180
|
+
* console.log(`${process.packageId}: ${process.faultedCount} failures`);
|
|
2181
|
+
* }
|
|
2182
|
+
* ```
|
|
2183
|
+
*
|
|
2184
|
+
* @example
|
|
2185
|
+
* ```typescript
|
|
2186
|
+
* // Get top case processes by faulted count for a specific package
|
|
2187
|
+
* const filtered = await cases.getTopFaultedCount(
|
|
2188
|
+
* new Date(Date.now() - 7 * 24 * 60 * 60 * 1000),
|
|
2189
|
+
* new Date(),
|
|
2190
|
+
* { packageId: '<packageId>' }
|
|
2191
|
+
* );
|
|
2192
|
+
* ```
|
|
2193
|
+
*/
|
|
2194
|
+
async getTopFaultedCount(startTime, endTime, options) {
|
|
2195
|
+
const { data } = await this.post(MAESTRO_ENDPOINTS.INSIGHTS.TOP_PROCESSES_WITH_FAILURE, buildInsightsTopBody(startTime, endTime, true, options));
|
|
2196
|
+
return (data ?? []).map(item => ({
|
|
2197
|
+
packageId: item.packageId,
|
|
2198
|
+
processKey: item.processKey,
|
|
2199
|
+
faultedCount: item.runCount,
|
|
2200
|
+
name: this.extractCaseName(item.packageId),
|
|
2201
|
+
}));
|
|
2202
|
+
}
|
|
2203
|
+
/**
|
|
2204
|
+
* Get the top 5 case processes ranked by total duration within a time range.
|
|
2205
|
+
*
|
|
2206
|
+
* Returns an array of up to 5 case processes sorted by their total execution time,
|
|
2207
|
+
* useful for identifying the longest-running case processes in a given period.
|
|
2208
|
+
*
|
|
2209
|
+
* @param startTime - Start of the time range to query
|
|
2210
|
+
* @param endTime - End of the time range to query
|
|
2211
|
+
* @param options - Optional filters (packageId, processKey, version)
|
|
2212
|
+
* @returns Promise resolving to an array of {@link CaseGetTopDurationResponse}
|
|
2213
|
+
* @example
|
|
2214
|
+
* ```typescript
|
|
2215
|
+
* import { Cases } from '@uipath/uipath-typescript/cases';
|
|
2216
|
+
*
|
|
2217
|
+
* const cases = new Cases(sdk);
|
|
2218
|
+
*
|
|
2219
|
+
* // Get top case processes by duration for the last 7 days
|
|
2220
|
+
* const topProcesses = await cases.getTopExecutionDuration(
|
|
2221
|
+
* new Date(Date.now() - 7 * 24 * 60 * 60 * 1000),
|
|
2222
|
+
* new Date()
|
|
2223
|
+
* );
|
|
2224
|
+
*
|
|
2225
|
+
* for (const process of topProcesses) {
|
|
2226
|
+
* console.log(`${process.packageId}: ${process.duration}ms total`);
|
|
2227
|
+
* }
|
|
2228
|
+
* ```
|
|
2229
|
+
*
|
|
2230
|
+
* @example
|
|
2231
|
+
* ```typescript
|
|
2232
|
+
* // Get top case processes by duration for a specific package
|
|
2233
|
+
* const filtered = await cases.getTopExecutionDuration(
|
|
2234
|
+
* new Date(Date.now() - 7 * 24 * 60 * 60 * 1000),
|
|
2235
|
+
* new Date(),
|
|
2236
|
+
* { packageId: '<packageId>' }
|
|
2237
|
+
* );
|
|
2238
|
+
* ```
|
|
2239
|
+
*/
|
|
2240
|
+
async getTopExecutionDuration(startTime, endTime, options) {
|
|
2241
|
+
const { data } = await this.post(MAESTRO_ENDPOINTS.INSIGHTS.TOP_PROCESSES_BY_DURATION, buildInsightsTopBody(startTime, endTime, true, options));
|
|
2242
|
+
return (data ?? []).map(process => ({ ...process, name: this.extractCaseName(process.packageId) }));
|
|
2243
|
+
}
|
|
2248
2244
|
/**
|
|
2249
2245
|
* Extract a readable case name from the packageId
|
|
2250
2246
|
* @param packageId - The full package identifier
|
|
@@ -2267,6 +2263,18 @@ class CasesService extends BaseService {
|
|
|
2267
2263
|
__decorate([
|
|
2268
2264
|
track('Cases.GetAll')
|
|
2269
2265
|
], CasesService.prototype, "getAll", null);
|
|
2266
|
+
__decorate([
|
|
2267
|
+
track('Cases.GetTopRunCount')
|
|
2268
|
+
], CasesService.prototype, "getTopRunCount", null);
|
|
2269
|
+
__decorate([
|
|
2270
|
+
track('Cases.GetInstanceStatusTimeline')
|
|
2271
|
+
], CasesService.prototype, "getInstanceStatusTimeline", null);
|
|
2272
|
+
__decorate([
|
|
2273
|
+
track('Cases.GetTopFaultedCount')
|
|
2274
|
+
], CasesService.prototype, "getTopFaultedCount", null);
|
|
2275
|
+
__decorate([
|
|
2276
|
+
track('Cases.GetTopExecutionDuration')
|
|
2277
|
+
], CasesService.prototype, "getTopExecutionDuration", null);
|
|
2270
2278
|
|
|
2271
2279
|
/**
|
|
2272
2280
|
* Process Incident Status
|
|
@@ -2451,6 +2459,11 @@ function createCaseInstanceMethods(instanceData, service) {
|
|
|
2451
2459
|
if (!instanceData.instanceId)
|
|
2452
2460
|
throw new Error('Case instance ID is undefined');
|
|
2453
2461
|
return service.getSlaSummary({ ...options, caseInstanceId: instanceData.instanceId });
|
|
2462
|
+
},
|
|
2463
|
+
async getStagesSlaSummary() {
|
|
2464
|
+
if (!instanceData.instanceId)
|
|
2465
|
+
throw new Error('Case instance ID is undefined');
|
|
2466
|
+
return service.getStagesSlaSummary({ caseInstanceId: instanceData.instanceId });
|
|
2454
2467
|
}
|
|
2455
2468
|
};
|
|
2456
2469
|
}
|
|
@@ -2466,6 +2479,40 @@ function createCaseInstanceWithMethods(instanceData, service) {
|
|
|
2466
2479
|
return Object.assign({}, instanceData, methods);
|
|
2467
2480
|
}
|
|
2468
2481
|
|
|
2482
|
+
/**
|
|
2483
|
+
* Insights Types
|
|
2484
|
+
* Shared types for Maestro insights analytics endpoints
|
|
2485
|
+
*/
|
|
2486
|
+
/**
|
|
2487
|
+
* Time bucketing granularity for insights time-series queries.
|
|
2488
|
+
*
|
|
2489
|
+
* Controls how data points are grouped on the time axis.
|
|
2490
|
+
*/
|
|
2491
|
+
exports.TimeInterval = void 0;
|
|
2492
|
+
(function (TimeInterval) {
|
|
2493
|
+
/** Group data points by hour */
|
|
2494
|
+
TimeInterval["Hour"] = "HOUR";
|
|
2495
|
+
/** Group data points by day */
|
|
2496
|
+
TimeInterval["Day"] = "DAY";
|
|
2497
|
+
/** Group data points by week */
|
|
2498
|
+
TimeInterval["Week"] = "WEEK";
|
|
2499
|
+
})(exports.TimeInterval || (exports.TimeInterval = {}));
|
|
2500
|
+
/**
|
|
2501
|
+
* Final instance statuses returned by the instance status timeline endpoint.
|
|
2502
|
+
*
|
|
2503
|
+
* Only includes statuses where the instance has finished execution — Completed, Faulted, or Cancelled.
|
|
2504
|
+
* Active statuses like Running or Paused are not included.
|
|
2505
|
+
*/
|
|
2506
|
+
exports.InstanceFinalStatus = void 0;
|
|
2507
|
+
(function (InstanceFinalStatus) {
|
|
2508
|
+
/** Instance completed successfully */
|
|
2509
|
+
InstanceFinalStatus["Completed"] = "Completed";
|
|
2510
|
+
/** Instance encountered an error */
|
|
2511
|
+
InstanceFinalStatus["Faulted"] = "Faulted";
|
|
2512
|
+
/** Instance was cancelled */
|
|
2513
|
+
InstanceFinalStatus["Cancelled"] = "Cancelled";
|
|
2514
|
+
})(exports.InstanceFinalStatus || (exports.InstanceFinalStatus = {}));
|
|
2515
|
+
|
|
2469
2516
|
/**
|
|
2470
2517
|
* Maps fields for Case Instance entities to ensure consistent naming
|
|
2471
2518
|
*/
|
|
@@ -3680,6 +3727,40 @@ class CaseInstancesService extends BaseService {
|
|
|
3680
3727
|
}
|
|
3681
3728
|
}, apiOptions);
|
|
3682
3729
|
}
|
|
3730
|
+
/**
|
|
3731
|
+
* Get stages SLA summary for case instances across folders.
|
|
3732
|
+
*
|
|
3733
|
+
* Returns stage-level SLA status and escalation information for each case instance, aggregated from Insights Real-Time Monitoring.
|
|
3734
|
+
*
|
|
3735
|
+
* @param options - Optional filtering options
|
|
3736
|
+
* @returns Promise resolving to an array of {@link CaseInstanceStageSLAResponse}
|
|
3737
|
+
* @example
|
|
3738
|
+
* ```typescript
|
|
3739
|
+
* // Get stages SLA summary for all case instances
|
|
3740
|
+
* const stagesSla = await caseInstances.getStagesSlaSummary();
|
|
3741
|
+
* for (const item of stagesSla) {
|
|
3742
|
+
* console.log(`Instance: ${item.caseInstanceId}`);
|
|
3743
|
+
* for (const stage of item.stages) {
|
|
3744
|
+
* console.log(` Stage: ${stage.name} - SLA Status: ${stage.slaStatus}, Due: ${stage.slaDueTime}`);
|
|
3745
|
+
* }
|
|
3746
|
+
* }
|
|
3747
|
+
*
|
|
3748
|
+
* // Filter by case instance ID
|
|
3749
|
+
* const filtered = await caseInstances.getStagesSlaSummary({
|
|
3750
|
+
* caseInstanceId: '<caseInstanceId>'
|
|
3751
|
+
* });
|
|
3752
|
+
*
|
|
3753
|
+
* // Using bound method on a case instance
|
|
3754
|
+
* const instance = await caseInstances.getById('<instanceId>', '<folderKey>');
|
|
3755
|
+
* const stagesSla = await instance.getStagesSlaSummary();
|
|
3756
|
+
* ```
|
|
3757
|
+
*/
|
|
3758
|
+
async getStagesSlaSummary(options) {
|
|
3759
|
+
const response = await this.post(MAESTRO_ENDPOINTS.INSIGHTS.STAGES_SUMMARY, {
|
|
3760
|
+
caseInstanceId: options?.caseInstanceId,
|
|
3761
|
+
});
|
|
3762
|
+
return response.data ?? [];
|
|
3763
|
+
}
|
|
3683
3764
|
}
|
|
3684
3765
|
__decorate([
|
|
3685
3766
|
track('CaseInstances.GetAll')
|
|
@@ -3711,6 +3792,9 @@ __decorate([
|
|
|
3711
3792
|
__decorate([
|
|
3712
3793
|
track('CaseInstances.GetSlaSummary')
|
|
3713
3794
|
], CaseInstancesService.prototype, "getSlaSummary", null);
|
|
3795
|
+
__decorate([
|
|
3796
|
+
track('CaseInstances.GetStagesSlaSummary')
|
|
3797
|
+
], CaseInstancesService.prototype, "getStagesSlaSummary", null);
|
|
3714
3798
|
|
|
3715
3799
|
exports.CaseInstances = CaseInstancesService;
|
|
3716
3800
|
exports.CaseInstancesService = CaseInstancesService;
|