@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/queues/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var coreTelemetry = require('@uipath/core-telemetry');
|
|
4
4
|
|
|
5
5
|
/******************************************************************************
|
|
6
6
|
Copyright (c) Microsoft Corporation.
|
|
@@ -613,14 +613,25 @@ class ApiClient {
|
|
|
613
613
|
if (!text) {
|
|
614
614
|
return undefined;
|
|
615
615
|
}
|
|
616
|
-
|
|
616
|
+
try {
|
|
617
|
+
return JSON.parse(text);
|
|
618
|
+
}
|
|
619
|
+
catch (error) {
|
|
620
|
+
if (error instanceof SyntaxError) {
|
|
621
|
+
throw new ServerError({
|
|
622
|
+
message: `Server returned non-JSON response (${response.status} ${response.url}): ${error.message}`,
|
|
623
|
+
statusCode: response.status,
|
|
624
|
+
});
|
|
625
|
+
}
|
|
626
|
+
throw error;
|
|
627
|
+
}
|
|
617
628
|
}
|
|
618
629
|
catch (error) {
|
|
619
630
|
// If it's already one of our errors, re-throw it
|
|
620
631
|
if (error.type && error.type.includes('Error')) {
|
|
621
632
|
throw error;
|
|
622
633
|
}
|
|
623
|
-
// Otherwise, it's
|
|
634
|
+
// Otherwise, it's a genuine network/fetch failure
|
|
624
635
|
throw ErrorFactory.createNetworkError(error);
|
|
625
636
|
}
|
|
626
637
|
}
|
|
@@ -1221,9 +1232,9 @@ class PaginationHelpers {
|
|
|
1221
1232
|
* @returns Promise resolving to a paginated result
|
|
1222
1233
|
*/
|
|
1223
1234
|
static async getAllPaginated(params) {
|
|
1224
|
-
const { serviceAccess, getEndpoint, folderId, paginationParams, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
|
|
1235
|
+
const { serviceAccess, getEndpoint, folderId, headers: providedHeaders, paginationParams, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
|
|
1225
1236
|
const endpoint = getEndpoint(folderId);
|
|
1226
|
-
const headers = folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {};
|
|
1237
|
+
const headers = providedHeaders ?? (folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {});
|
|
1227
1238
|
const paginatedResponse = await serviceAccess.requestWithPagination(method, endpoint, paginationParams, {
|
|
1228
1239
|
headers,
|
|
1229
1240
|
params: additionalParams,
|
|
@@ -1251,13 +1262,13 @@ class PaginationHelpers {
|
|
|
1251
1262
|
* @returns Promise resolving to an object with data and totalCount
|
|
1252
1263
|
*/
|
|
1253
1264
|
static async getAllNonPaginated(params) {
|
|
1254
|
-
const { serviceAccess, getAllEndpoint, getByFolderEndpoint, folderId, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
|
|
1265
|
+
const { serviceAccess, getAllEndpoint, getByFolderEndpoint, folderId, headers: providedHeaders, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
|
|
1255
1266
|
// Set default field names
|
|
1256
1267
|
const itemsField = options.itemsField || DEFAULT_ITEMS_FIELD;
|
|
1257
1268
|
const totalCountField = options.totalCountField || DEFAULT_TOTAL_COUNT_FIELD;
|
|
1258
1269
|
// Determine endpoint and headers based on folderId
|
|
1259
1270
|
const endpoint = folderId ? getByFolderEndpoint : getAllEndpoint;
|
|
1260
|
-
const headers = folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {};
|
|
1271
|
+
const headers = providedHeaders ?? (folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {});
|
|
1261
1272
|
// Make the API call based on method
|
|
1262
1273
|
let response;
|
|
1263
1274
|
if (method === HTTP_METHODS.POST) {
|
|
@@ -1316,6 +1327,7 @@ class PaginationHelpers {
|
|
|
1316
1327
|
serviceAccess: config.serviceAccess,
|
|
1317
1328
|
getEndpoint: config.getEndpoint,
|
|
1318
1329
|
folderId,
|
|
1330
|
+
headers: config.headers,
|
|
1319
1331
|
paginationParams: cursor ? { cursor, pageSize } : jumpToPage ? { jumpToPage, pageSize } : { pageSize },
|
|
1320
1332
|
additionalParams: prefixedOptions,
|
|
1321
1333
|
transformFn: config.transformFn,
|
|
@@ -1333,6 +1345,7 @@ class PaginationHelpers {
|
|
|
1333
1345
|
getAllEndpoint: config.getEndpoint(),
|
|
1334
1346
|
getByFolderEndpoint: byFolderEndpoint,
|
|
1335
1347
|
folderId,
|
|
1348
|
+
headers: config.headers,
|
|
1336
1349
|
additionalParams: prefixedOptions,
|
|
1337
1350
|
transformFn: config.transformFn,
|
|
1338
1351
|
method: config.method,
|
|
@@ -1886,278 +1899,33 @@ const QueueMap = {
|
|
|
1886
1899
|
};
|
|
1887
1900
|
|
|
1888
1901
|
/**
|
|
1889
|
-
* SDK Telemetry constants
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
const
|
|
1900
|
-
const CLOUD_CLIENT_ID = "CloudClientId";
|
|
1901
|
-
const CLOUD_REDIRECT_URI = "CloudRedirectUri";
|
|
1902
|
-
const APP_NAME = "ApplicationName";
|
|
1903
|
-
const CLOUD_ROLE_NAME = "uipath-ts-sdk";
|
|
1904
|
-
// Service and logger names
|
|
1905
|
-
const SDK_SERVICE_NAME = "UiPath.TypeScript.Sdk";
|
|
1906
|
-
const SDK_LOGGER_NAME = "uipath-ts-sdk-telemetry";
|
|
1907
|
-
// Event names
|
|
1908
|
-
const SDK_RUN_EVENT = "Sdk.Run";
|
|
1909
|
-
// Default value for unknown/empty attributes
|
|
1910
|
-
const UNKNOWN = "";
|
|
1911
|
-
|
|
1912
|
-
/**
|
|
1913
|
-
* Log exporter that sends ALL logs as Application Insights custom events
|
|
1914
|
-
*/
|
|
1915
|
-
class ApplicationInsightsEventExporter {
|
|
1916
|
-
constructor(connectionString) {
|
|
1917
|
-
this.connectionString = connectionString;
|
|
1918
|
-
}
|
|
1919
|
-
export(logs, resultCallback) {
|
|
1920
|
-
try {
|
|
1921
|
-
logs.forEach(logRecord => {
|
|
1922
|
-
this.sendAsCustomEvent(logRecord);
|
|
1923
|
-
});
|
|
1924
|
-
resultCallback({ code: 0 });
|
|
1925
|
-
}
|
|
1926
|
-
catch (error) {
|
|
1927
|
-
console.debug('Failed to export logs to Application Insights:', error);
|
|
1928
|
-
resultCallback({ code: 2, error });
|
|
1929
|
-
}
|
|
1930
|
-
}
|
|
1931
|
-
shutdown() {
|
|
1932
|
-
return Promise.resolve();
|
|
1933
|
-
}
|
|
1934
|
-
sendAsCustomEvent(logRecord) {
|
|
1935
|
-
// Get event name from body or attributes
|
|
1936
|
-
const eventName = logRecord.body || SDK_RUN_EVENT;
|
|
1937
|
-
const payload = {
|
|
1938
|
-
name: 'Microsoft.ApplicationInsights.Event',
|
|
1939
|
-
time: new Date().toISOString(),
|
|
1940
|
-
iKey: this.extractInstrumentationKey(),
|
|
1941
|
-
data: {
|
|
1942
|
-
baseType: 'EventData',
|
|
1943
|
-
baseData: {
|
|
1944
|
-
ver: 2,
|
|
1945
|
-
name: eventName,
|
|
1946
|
-
properties: this.convertAttributesToProperties(logRecord.attributes || {})
|
|
1947
|
-
}
|
|
1948
|
-
},
|
|
1949
|
-
tags: {
|
|
1950
|
-
'ai.cloud.role': CLOUD_ROLE_NAME,
|
|
1951
|
-
'ai.cloud.roleInstance': SDK_VERSION
|
|
1952
|
-
}
|
|
1953
|
-
};
|
|
1954
|
-
this.sendToApplicationInsights(payload);
|
|
1955
|
-
}
|
|
1956
|
-
extractInstrumentationKey() {
|
|
1957
|
-
const match = this.connectionString.match(/InstrumentationKey=([^;]+)/);
|
|
1958
|
-
return match ? match[1] : '';
|
|
1959
|
-
}
|
|
1960
|
-
convertAttributesToProperties(attributes) {
|
|
1961
|
-
const properties = {};
|
|
1962
|
-
Object.entries(attributes || {}).forEach(([key, value]) => {
|
|
1963
|
-
properties[key] = String(value);
|
|
1964
|
-
});
|
|
1965
|
-
return properties;
|
|
1966
|
-
}
|
|
1967
|
-
async sendToApplicationInsights(payload) {
|
|
1968
|
-
try {
|
|
1969
|
-
const ingestionEndpoint = this.extractIngestionEndpoint();
|
|
1970
|
-
if (!ingestionEndpoint) {
|
|
1971
|
-
console.debug('No ingestion endpoint found in connection string');
|
|
1972
|
-
return;
|
|
1973
|
-
}
|
|
1974
|
-
const url = `${ingestionEndpoint}/v2/track`;
|
|
1975
|
-
const response = await fetch(url, {
|
|
1976
|
-
method: 'POST',
|
|
1977
|
-
headers: {
|
|
1978
|
-
'Content-Type': 'application/json',
|
|
1979
|
-
},
|
|
1980
|
-
body: JSON.stringify(payload)
|
|
1981
|
-
});
|
|
1982
|
-
if (!response.ok) {
|
|
1983
|
-
console.debug(`Failed to send event telemetry: ${response.status} ${response.statusText}`);
|
|
1984
|
-
}
|
|
1985
|
-
}
|
|
1986
|
-
catch (error) {
|
|
1987
|
-
console.debug('Error sending event telemetry to Application Insights:', error);
|
|
1988
|
-
}
|
|
1989
|
-
}
|
|
1990
|
-
extractIngestionEndpoint() {
|
|
1991
|
-
const match = this.connectionString.match(/IngestionEndpoint=([^;]+)/);
|
|
1992
|
-
return match ? match[1] : '';
|
|
1993
|
-
}
|
|
1994
|
-
}
|
|
1995
|
-
/**
|
|
1996
|
-
* Singleton telemetry client
|
|
1997
|
-
*/
|
|
1998
|
-
class TelemetryClient {
|
|
1999
|
-
constructor() {
|
|
2000
|
-
this.isInitialized = false;
|
|
2001
|
-
}
|
|
2002
|
-
static getInstance() {
|
|
2003
|
-
if (!TelemetryClient.instance) {
|
|
2004
|
-
TelemetryClient.instance = new TelemetryClient();
|
|
2005
|
-
}
|
|
2006
|
-
return TelemetryClient.instance;
|
|
2007
|
-
}
|
|
2008
|
-
/**
|
|
2009
|
-
* Initialize telemetry
|
|
2010
|
-
*/
|
|
2011
|
-
initialize(config) {
|
|
2012
|
-
if (this.isInitialized) {
|
|
2013
|
-
return;
|
|
2014
|
-
}
|
|
2015
|
-
this.isInitialized = true;
|
|
2016
|
-
if (config) {
|
|
2017
|
-
this.telemetryContext = config;
|
|
2018
|
-
}
|
|
2019
|
-
try {
|
|
2020
|
-
const connectionString = this.getConnectionString();
|
|
2021
|
-
if (!connectionString) {
|
|
2022
|
-
return;
|
|
2023
|
-
}
|
|
2024
|
-
this.setupTelemetryProvider(connectionString);
|
|
2025
|
-
}
|
|
2026
|
-
catch (error) {
|
|
2027
|
-
// Silent failure - telemetry errors shouldn't break functionality
|
|
2028
|
-
console.debug('Failed to initialize OpenTelemetry:', error);
|
|
2029
|
-
}
|
|
2030
|
-
}
|
|
2031
|
-
getConnectionString() {
|
|
2032
|
-
const connectionString = CONNECTION_STRING;
|
|
2033
|
-
return connectionString;
|
|
2034
|
-
}
|
|
2035
|
-
setupTelemetryProvider(connectionString) {
|
|
2036
|
-
const exporter = new ApplicationInsightsEventExporter(connectionString);
|
|
2037
|
-
const processor = new sdkLogs.BatchLogRecordProcessor(exporter);
|
|
2038
|
-
this.logProvider = new sdkLogs.LoggerProvider({
|
|
2039
|
-
processors: [processor]
|
|
2040
|
-
});
|
|
2041
|
-
this.logger = this.logProvider.getLogger(SDK_LOGGER_NAME);
|
|
2042
|
-
}
|
|
2043
|
-
/**
|
|
2044
|
-
* Track a telemetry event
|
|
2045
|
-
*/
|
|
2046
|
-
track(eventName, name, extraAttributes = {}) {
|
|
2047
|
-
try {
|
|
2048
|
-
// Skip if logger not initialized
|
|
2049
|
-
if (!this.logger) {
|
|
2050
|
-
return;
|
|
2051
|
-
}
|
|
2052
|
-
const finalDisplayName = name || eventName;
|
|
2053
|
-
const attributes = this.getEnrichedAttributes(extraAttributes, eventName);
|
|
2054
|
-
// Emit as log
|
|
2055
|
-
this.logger.emit({
|
|
2056
|
-
body: finalDisplayName,
|
|
2057
|
-
attributes: attributes,
|
|
2058
|
-
timestamp: Date.now(),
|
|
2059
|
-
});
|
|
2060
|
-
}
|
|
2061
|
-
catch (error) {
|
|
2062
|
-
// Silent failure
|
|
2063
|
-
console.debug('Failed to track telemetry event:', error);
|
|
2064
|
-
}
|
|
2065
|
-
}
|
|
2066
|
-
/**
|
|
2067
|
-
* Get enriched attributes for telemetry events
|
|
2068
|
-
*/
|
|
2069
|
-
getEnrichedAttributes(extraAttributes, eventName) {
|
|
2070
|
-
const attributes = {
|
|
2071
|
-
[APP_NAME]: SDK_SERVICE_NAME,
|
|
2072
|
-
[VERSION]: SDK_VERSION,
|
|
2073
|
-
[SERVICE]: eventName,
|
|
2074
|
-
[CLOUD_URL]: this.createCloudUrl(),
|
|
2075
|
-
[CLOUD_ORGANIZATION_NAME]: this.telemetryContext?.orgName || UNKNOWN,
|
|
2076
|
-
[CLOUD_TENANT_NAME]: this.telemetryContext?.tenantName || UNKNOWN,
|
|
2077
|
-
[CLOUD_REDIRECT_URI]: this.telemetryContext?.redirectUri || UNKNOWN,
|
|
2078
|
-
[CLOUD_CLIENT_ID]: this.telemetryContext?.clientId || UNKNOWN,
|
|
2079
|
-
...extraAttributes,
|
|
2080
|
-
};
|
|
2081
|
-
return attributes;
|
|
2082
|
-
}
|
|
2083
|
-
/**
|
|
2084
|
-
* Create cloud URL from base URL, organization ID, and tenant ID
|
|
2085
|
-
*/
|
|
2086
|
-
createCloudUrl() {
|
|
2087
|
-
const baseUrl = this.telemetryContext?.baseUrl;
|
|
2088
|
-
const orgId = this.telemetryContext?.orgName;
|
|
2089
|
-
const tenantId = this.telemetryContext?.tenantName;
|
|
2090
|
-
if (!baseUrl || !orgId || !tenantId) {
|
|
2091
|
-
return UNKNOWN;
|
|
2092
|
-
}
|
|
2093
|
-
return `${baseUrl}/${orgId}/${tenantId}`;
|
|
2094
|
-
}
|
|
2095
|
-
}
|
|
2096
|
-
// Export singleton instance
|
|
2097
|
-
const telemetryClient = TelemetryClient.getInstance();
|
|
1902
|
+
* SDK Telemetry constants.
|
|
1903
|
+
*
|
|
1904
|
+
* Only the SDK's identity (version, service name, role name, …) lives
|
|
1905
|
+
* here. The Application Insights connection string is injected into
|
|
1906
|
+
* `@uipath/core-telemetry` itself at publish time, and the generic attribute
|
|
1907
|
+
* keys (`Version`, `Service`, `CloudOrganizationName`, …) are owned by
|
|
1908
|
+
* `@uipath/core-telemetry` and consumed there — they are not part of the
|
|
1909
|
+
* SDK's public API.
|
|
1910
|
+
*/
|
|
1911
|
+
/** SDK version placeholder — patched by the SDK publish workflow. */
|
|
1912
|
+
const CLOUD_ROLE_NAME = 'uipath-ts-sdk';
|
|
2098
1913
|
|
|
2099
1914
|
/**
|
|
2100
|
-
*
|
|
2101
|
-
*/
|
|
2102
|
-
/**
|
|
2103
|
-
* Common tracking logic shared between method and function decorators
|
|
2104
|
-
*/
|
|
2105
|
-
function createTrackedFunction(originalFunction, nameOrOptions, fallbackName, opts) {
|
|
2106
|
-
return function (...args) {
|
|
2107
|
-
// Determine if we should track this call
|
|
2108
|
-
let shouldTrack = true;
|
|
2109
|
-
if (opts.condition !== undefined) {
|
|
2110
|
-
if (typeof opts.condition === 'function') {
|
|
2111
|
-
shouldTrack = opts.condition.apply(this, args);
|
|
2112
|
-
}
|
|
2113
|
-
else {
|
|
2114
|
-
shouldTrack = opts.condition;
|
|
2115
|
-
}
|
|
2116
|
-
}
|
|
2117
|
-
// Track the event if enabled
|
|
2118
|
-
if (shouldTrack) {
|
|
2119
|
-
// Use the full name provided in the decorator (e.g., "Queue.GetAll")
|
|
2120
|
-
const serviceMethod = typeof nameOrOptions === 'string'
|
|
2121
|
-
? nameOrOptions
|
|
2122
|
-
: fallbackName;
|
|
2123
|
-
// Use 'Sdk.Run' as the name and serviceMethod as the service
|
|
2124
|
-
telemetryClient.track(serviceMethod, SDK_RUN_EVENT, opts.attributes);
|
|
2125
|
-
}
|
|
2126
|
-
// Execute the original function
|
|
2127
|
-
return originalFunction.apply(this, args);
|
|
2128
|
-
};
|
|
2129
|
-
}
|
|
2130
|
-
/**
|
|
2131
|
-
* Track decorator that can be used to automatically track function calls
|
|
2132
|
-
*
|
|
2133
|
-
* Usage:
|
|
2134
|
-
* @track("Service.Method")
|
|
2135
|
-
* function myFunction() { ... }
|
|
2136
|
-
*
|
|
2137
|
-
* @track("Queue.GetAll")
|
|
2138
|
-
* async getAll() { ... }
|
|
1915
|
+
* UiPath TypeScript SDK Telemetry
|
|
2139
1916
|
*
|
|
2140
|
-
*
|
|
2141
|
-
*
|
|
2142
|
-
*
|
|
2143
|
-
*
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
if (descriptor && typeof descriptor.value === 'function') {
|
|
2153
|
-
// Method decorator
|
|
2154
|
-
descriptor.value = createTrackedFunction(descriptor.value, nameOrOptions, propertyKey || 'unknown_method', opts);
|
|
2155
|
-
return descriptor;
|
|
2156
|
-
}
|
|
2157
|
-
// Function decorator
|
|
2158
|
-
return (originalFunction) => createTrackedFunction(originalFunction, nameOrOptions, originalFunction.name || 'unknown_function', opts);
|
|
2159
|
-
};
|
|
2160
|
-
}
|
|
1917
|
+
* Constructs the SDK's own `TelemetryClient` and binds the SDK-local
|
|
1918
|
+
* `track` / `trackEvent` to it. Each consumer of `@uipath/core-telemetry`
|
|
1919
|
+
* does this independently, so events carry their own consumer's identity
|
|
1920
|
+
* and tenant context.
|
|
1921
|
+
*/
|
|
1922
|
+
// Keyed by `CLOUD_ROLE_NAME` so every SDK subpath bundle resolves to the
|
|
1923
|
+
// same `TelemetryClient` instance at runtime. A single `initialize(...)`
|
|
1924
|
+
// from the `UiPath` constructor therefore wires up `@track` decorators
|
|
1925
|
+
// across every subpath bundle (`assets`, `feedback`, `tasks`, …).
|
|
1926
|
+
const sdkClient = coreTelemetry.getOrCreateClient(CLOUD_ROLE_NAME);
|
|
1927
|
+
const track = coreTelemetry.createTrack(sdkClient);
|
|
1928
|
+
coreTelemetry.createTrackEvent(sdkClient);
|
|
2161
1929
|
|
|
2162
1930
|
/**
|
|
2163
1931
|
* Service for interacting with UiPath Orchestrator Queues API
|