@uipath/uipath-typescript 1.3.7 → 1.3.9

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