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