@uipath/uipath-typescript 1.3.8 → 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 +25 -270
- package/dist/assets/index.mjs +25 -270
- package/dist/attachments/index.cjs +23 -267
- package/dist/attachments/index.mjs +23 -267
- package/dist/buckets/index.cjs +54 -270
- package/dist/buckets/index.d.ts +50 -1
- package/dist/buckets/index.mjs +54 -270
- package/dist/cases/index.cjs +408 -337
- package/dist/cases/index.d.ts +534 -2
- package/dist/cases/index.mjs +409 -338
- package/dist/conversational-agent/index.cjs +71 -281
- package/dist/conversational-agent/index.d.ts +62 -12
- package/dist/conversational-agent/index.mjs +71 -282
- 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 +25 -270
- package/dist/entities/index.mjs +25 -270
- package/dist/feedback/index.cjs +23 -268
- package/dist/feedback/index.mjs +23 -268
- package/dist/index.cjs +600 -293
- package/dist/index.d.ts +1603 -722
- package/dist/index.mjs +600 -279
- package/dist/index.umd.js +789 -158
- package/dist/jobs/index.cjs +25 -270
- package/dist/jobs/index.mjs +25 -270
- package/dist/maestro-processes/index.cjs +1751 -1720
- package/dist/maestro-processes/index.d.ts +430 -2
- package/dist/maestro-processes/index.mjs +1752 -1721
- package/dist/processes/index.cjs +25 -270
- package/dist/processes/index.mjs +25 -270
- package/dist/queues/index.cjs +25 -270
- package/dist/queues/index.mjs +25 -270
- package/dist/tasks/index.cjs +25 -270
- package/dist/tasks/index.mjs +25 -270
- 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
|
*/
|
|
@@ -1833,345 +1957,33 @@ class BaseService {
|
|
|
1833
1957
|
_BaseService_apiClient = new WeakMap();
|
|
1834
1958
|
|
|
1835
1959
|
/**
|
|
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();
|
|
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';
|
|
2112
1971
|
|
|
2113
1972
|
/**
|
|
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
|
|
1973
|
+
* UiPath TypeScript SDK Telemetry
|
|
2146
1974
|
*
|
|
2147
|
-
*
|
|
2148
|
-
*
|
|
2149
|
-
*
|
|
2150
|
-
*
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
*
|
|
2160
|
-
* @track("Processes.Start", { attributes: { customProp: "value" } })
|
|
2161
|
-
* function myFunction() { ... }
|
|
2162
|
-
*/
|
|
2163
|
-
function track(nameOrOptions, options) {
|
|
2164
|
-
return function decorator(_target, propertyKey, descriptor) {
|
|
2165
|
-
const opts = typeof nameOrOptions === 'object' ? nameOrOptions : {};
|
|
2166
|
-
if (descriptor && typeof descriptor.value === 'function') {
|
|
2167
|
-
// Method decorator
|
|
2168
|
-
descriptor.value = createTrackedFunction(descriptor.value, nameOrOptions, propertyKey || 'unknown_method', opts);
|
|
2169
|
-
return descriptor;
|
|
2170
|
-
}
|
|
2171
|
-
// Function decorator
|
|
2172
|
-
return (originalFunction) => createTrackedFunction(originalFunction, nameOrOptions, originalFunction.name || 'unknown_function', opts);
|
|
2173
|
-
};
|
|
2174
|
-
}
|
|
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);
|
|
2175
1987
|
|
|
2176
1988
|
/**
|
|
2177
1989
|
* Creates query parameters object from key-value pairs, filtering out undefined values
|
|
@@ -2243,6 +2055,177 @@ class CasesService extends BaseService {
|
|
|
2243
2055
|
name: this.extractCaseName(caseItem.packageId)
|
|
2244
2056
|
}));
|
|
2245
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
|
+
}
|
|
2246
2229
|
/**
|
|
2247
2230
|
* Extract a readable case name from the packageId
|
|
2248
2231
|
* @param packageId - The full package identifier
|
|
@@ -2265,6 +2248,18 @@ class CasesService extends BaseService {
|
|
|
2265
2248
|
__decorate([
|
|
2266
2249
|
track('Cases.GetAll')
|
|
2267
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);
|
|
2268
2263
|
|
|
2269
2264
|
/**
|
|
2270
2265
|
* Process Incident Status
|
|
@@ -2449,6 +2444,11 @@ function createCaseInstanceMethods(instanceData, service) {
|
|
|
2449
2444
|
if (!instanceData.instanceId)
|
|
2450
2445
|
throw new Error('Case instance ID is undefined');
|
|
2451
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 });
|
|
2452
2452
|
}
|
|
2453
2453
|
};
|
|
2454
2454
|
}
|
|
@@ -2464,6 +2464,40 @@ function createCaseInstanceWithMethods(instanceData, service) {
|
|
|
2464
2464
|
return Object.assign({}, instanceData, methods);
|
|
2465
2465
|
}
|
|
2466
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
|
+
|
|
2467
2501
|
/**
|
|
2468
2502
|
* Maps fields for Case Instance entities to ensure consistent naming
|
|
2469
2503
|
*/
|
|
@@ -3678,6 +3712,40 @@ class CaseInstancesService extends BaseService {
|
|
|
3678
3712
|
}
|
|
3679
3713
|
}, apiOptions);
|
|
3680
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
|
+
}
|
|
3681
3749
|
}
|
|
3682
3750
|
__decorate([
|
|
3683
3751
|
track('CaseInstances.GetAll')
|
|
@@ -3709,5 +3777,8 @@ __decorate([
|
|
|
3709
3777
|
__decorate([
|
|
3710
3778
|
track('CaseInstances.GetSlaSummary')
|
|
3711
3779
|
], CaseInstancesService.prototype, "getSlaSummary", null);
|
|
3780
|
+
__decorate([
|
|
3781
|
+
track('CaseInstances.GetStagesSlaSummary')
|
|
3782
|
+
], CaseInstancesService.prototype, "getStagesSlaSummary", null);
|
|
3712
3783
|
|
|
3713
|
-
export { CaseInstancesService as CaseInstances, CaseInstancesService, CasesService as Cases, CasesService, EscalationActionType, EscalationRecipientScope, EscalationTriggerType, InstanceStatus, SLADurationUnit, SlaSummaryStatus, StageTaskType, createCaseInstanceWithMethods };
|
|
3784
|
+
export { CaseInstancesService as CaseInstances, CaseInstancesService, CasesService as Cases, CasesService, EscalationActionType, EscalationRecipientScope, EscalationTriggerType, InstanceFinalStatus, InstanceStatus, SLADurationUnit, SlaSummaryStatus, StageTaskType, TimeInterval, createCaseInstanceWithMethods };
|