@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/jobs/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.
|
|
@@ -611,14 +611,25 @@ class ApiClient {
|
|
|
611
611
|
if (!text) {
|
|
612
612
|
return undefined;
|
|
613
613
|
}
|
|
614
|
-
|
|
614
|
+
try {
|
|
615
|
+
return JSON.parse(text);
|
|
616
|
+
}
|
|
617
|
+
catch (error) {
|
|
618
|
+
if (error instanceof SyntaxError) {
|
|
619
|
+
throw new ServerError({
|
|
620
|
+
message: `Server returned non-JSON response (${response.status} ${response.url}): ${error.message}`,
|
|
621
|
+
statusCode: response.status,
|
|
622
|
+
});
|
|
623
|
+
}
|
|
624
|
+
throw error;
|
|
625
|
+
}
|
|
615
626
|
}
|
|
616
627
|
catch (error) {
|
|
617
628
|
// If it's already one of our errors, re-throw it
|
|
618
629
|
if (error.type && error.type.includes('Error')) {
|
|
619
630
|
throw error;
|
|
620
631
|
}
|
|
621
|
-
// Otherwise, it's
|
|
632
|
+
// Otherwise, it's a genuine network/fetch failure
|
|
622
633
|
throw ErrorFactory.createNetworkError(error);
|
|
623
634
|
}
|
|
624
635
|
}
|
|
@@ -1219,9 +1230,9 @@ class PaginationHelpers {
|
|
|
1219
1230
|
* @returns Promise resolving to a paginated result
|
|
1220
1231
|
*/
|
|
1221
1232
|
static async getAllPaginated(params) {
|
|
1222
|
-
const { serviceAccess, getEndpoint, folderId, paginationParams, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
|
|
1233
|
+
const { serviceAccess, getEndpoint, folderId, headers: providedHeaders, paginationParams, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
|
|
1223
1234
|
const endpoint = getEndpoint(folderId);
|
|
1224
|
-
const headers = folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {};
|
|
1235
|
+
const headers = providedHeaders ?? (folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {});
|
|
1225
1236
|
const paginatedResponse = await serviceAccess.requestWithPagination(method, endpoint, paginationParams, {
|
|
1226
1237
|
headers,
|
|
1227
1238
|
params: additionalParams,
|
|
@@ -1249,13 +1260,13 @@ class PaginationHelpers {
|
|
|
1249
1260
|
* @returns Promise resolving to an object with data and totalCount
|
|
1250
1261
|
*/
|
|
1251
1262
|
static async getAllNonPaginated(params) {
|
|
1252
|
-
const { serviceAccess, getAllEndpoint, getByFolderEndpoint, folderId, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
|
|
1263
|
+
const { serviceAccess, getAllEndpoint, getByFolderEndpoint, folderId, headers: providedHeaders, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
|
|
1253
1264
|
// Set default field names
|
|
1254
1265
|
const itemsField = options.itemsField || DEFAULT_ITEMS_FIELD;
|
|
1255
1266
|
const totalCountField = options.totalCountField || DEFAULT_TOTAL_COUNT_FIELD;
|
|
1256
1267
|
// Determine endpoint and headers based on folderId
|
|
1257
1268
|
const endpoint = folderId ? getByFolderEndpoint : getAllEndpoint;
|
|
1258
|
-
const headers = folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {};
|
|
1269
|
+
const headers = providedHeaders ?? (folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {});
|
|
1259
1270
|
// Make the API call based on method
|
|
1260
1271
|
let response;
|
|
1261
1272
|
if (method === HTTP_METHODS.POST) {
|
|
@@ -1314,6 +1325,7 @@ class PaginationHelpers {
|
|
|
1314
1325
|
serviceAccess: config.serviceAccess,
|
|
1315
1326
|
getEndpoint: config.getEndpoint,
|
|
1316
1327
|
folderId,
|
|
1328
|
+
headers: config.headers,
|
|
1317
1329
|
paginationParams: cursor ? { cursor, pageSize } : jumpToPage ? { jumpToPage, pageSize } : { pageSize },
|
|
1318
1330
|
additionalParams: prefixedOptions,
|
|
1319
1331
|
transformFn: config.transformFn,
|
|
@@ -1331,6 +1343,7 @@ class PaginationHelpers {
|
|
|
1331
1343
|
getAllEndpoint: config.getEndpoint(),
|
|
1332
1344
|
getByFolderEndpoint: byFolderEndpoint,
|
|
1333
1345
|
folderId,
|
|
1346
|
+
headers: config.headers,
|
|
1334
1347
|
additionalParams: prefixedOptions,
|
|
1335
1348
|
transformFn: config.transformFn,
|
|
1336
1349
|
method: config.method,
|
|
@@ -1951,278 +1964,33 @@ const JobMap = {
|
|
|
1951
1964
|
};
|
|
1952
1965
|
|
|
1953
1966
|
/**
|
|
1954
|
-
* SDK Telemetry constants
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
const
|
|
1965
|
-
const CLOUD_CLIENT_ID = "CloudClientId";
|
|
1966
|
-
const CLOUD_REDIRECT_URI = "CloudRedirectUri";
|
|
1967
|
-
const APP_NAME = "ApplicationName";
|
|
1968
|
-
const CLOUD_ROLE_NAME = "uipath-ts-sdk";
|
|
1969
|
-
// Service and logger names
|
|
1970
|
-
const SDK_SERVICE_NAME = "UiPath.TypeScript.Sdk";
|
|
1971
|
-
const SDK_LOGGER_NAME = "uipath-ts-sdk-telemetry";
|
|
1972
|
-
// Event names
|
|
1973
|
-
const SDK_RUN_EVENT = "Sdk.Run";
|
|
1974
|
-
// Default value for unknown/empty attributes
|
|
1975
|
-
const UNKNOWN = "";
|
|
1976
|
-
|
|
1977
|
-
/**
|
|
1978
|
-
* Log exporter that sends ALL logs as Application Insights custom events
|
|
1979
|
-
*/
|
|
1980
|
-
class ApplicationInsightsEventExporter {
|
|
1981
|
-
constructor(connectionString) {
|
|
1982
|
-
this.connectionString = connectionString;
|
|
1983
|
-
}
|
|
1984
|
-
export(logs, resultCallback) {
|
|
1985
|
-
try {
|
|
1986
|
-
logs.forEach(logRecord => {
|
|
1987
|
-
this.sendAsCustomEvent(logRecord);
|
|
1988
|
-
});
|
|
1989
|
-
resultCallback({ code: 0 });
|
|
1990
|
-
}
|
|
1991
|
-
catch (error) {
|
|
1992
|
-
console.debug('Failed to export logs to Application Insights:', error);
|
|
1993
|
-
resultCallback({ code: 2, error });
|
|
1994
|
-
}
|
|
1995
|
-
}
|
|
1996
|
-
shutdown() {
|
|
1997
|
-
return Promise.resolve();
|
|
1998
|
-
}
|
|
1999
|
-
sendAsCustomEvent(logRecord) {
|
|
2000
|
-
// Get event name from body or attributes
|
|
2001
|
-
const eventName = logRecord.body || SDK_RUN_EVENT;
|
|
2002
|
-
const payload = {
|
|
2003
|
-
name: 'Microsoft.ApplicationInsights.Event',
|
|
2004
|
-
time: new Date().toISOString(),
|
|
2005
|
-
iKey: this.extractInstrumentationKey(),
|
|
2006
|
-
data: {
|
|
2007
|
-
baseType: 'EventData',
|
|
2008
|
-
baseData: {
|
|
2009
|
-
ver: 2,
|
|
2010
|
-
name: eventName,
|
|
2011
|
-
properties: this.convertAttributesToProperties(logRecord.attributes || {})
|
|
2012
|
-
}
|
|
2013
|
-
},
|
|
2014
|
-
tags: {
|
|
2015
|
-
'ai.cloud.role': CLOUD_ROLE_NAME,
|
|
2016
|
-
'ai.cloud.roleInstance': SDK_VERSION
|
|
2017
|
-
}
|
|
2018
|
-
};
|
|
2019
|
-
this.sendToApplicationInsights(payload);
|
|
2020
|
-
}
|
|
2021
|
-
extractInstrumentationKey() {
|
|
2022
|
-
const match = this.connectionString.match(/InstrumentationKey=([^;]+)/);
|
|
2023
|
-
return match ? match[1] : '';
|
|
2024
|
-
}
|
|
2025
|
-
convertAttributesToProperties(attributes) {
|
|
2026
|
-
const properties = {};
|
|
2027
|
-
Object.entries(attributes || {}).forEach(([key, value]) => {
|
|
2028
|
-
properties[key] = String(value);
|
|
2029
|
-
});
|
|
2030
|
-
return properties;
|
|
2031
|
-
}
|
|
2032
|
-
async sendToApplicationInsights(payload) {
|
|
2033
|
-
try {
|
|
2034
|
-
const ingestionEndpoint = this.extractIngestionEndpoint();
|
|
2035
|
-
if (!ingestionEndpoint) {
|
|
2036
|
-
console.debug('No ingestion endpoint found in connection string');
|
|
2037
|
-
return;
|
|
2038
|
-
}
|
|
2039
|
-
const url = `${ingestionEndpoint}/v2/track`;
|
|
2040
|
-
const response = await fetch(url, {
|
|
2041
|
-
method: 'POST',
|
|
2042
|
-
headers: {
|
|
2043
|
-
'Content-Type': 'application/json',
|
|
2044
|
-
},
|
|
2045
|
-
body: JSON.stringify(payload)
|
|
2046
|
-
});
|
|
2047
|
-
if (!response.ok) {
|
|
2048
|
-
console.debug(`Failed to send event telemetry: ${response.status} ${response.statusText}`);
|
|
2049
|
-
}
|
|
2050
|
-
}
|
|
2051
|
-
catch (error) {
|
|
2052
|
-
console.debug('Error sending event telemetry to Application Insights:', error);
|
|
2053
|
-
}
|
|
2054
|
-
}
|
|
2055
|
-
extractIngestionEndpoint() {
|
|
2056
|
-
const match = this.connectionString.match(/IngestionEndpoint=([^;]+)/);
|
|
2057
|
-
return match ? match[1] : '';
|
|
2058
|
-
}
|
|
2059
|
-
}
|
|
2060
|
-
/**
|
|
2061
|
-
* Singleton telemetry client
|
|
2062
|
-
*/
|
|
2063
|
-
class TelemetryClient {
|
|
2064
|
-
constructor() {
|
|
2065
|
-
this.isInitialized = false;
|
|
2066
|
-
}
|
|
2067
|
-
static getInstance() {
|
|
2068
|
-
if (!TelemetryClient.instance) {
|
|
2069
|
-
TelemetryClient.instance = new TelemetryClient();
|
|
2070
|
-
}
|
|
2071
|
-
return TelemetryClient.instance;
|
|
2072
|
-
}
|
|
2073
|
-
/**
|
|
2074
|
-
* Initialize telemetry
|
|
2075
|
-
*/
|
|
2076
|
-
initialize(config) {
|
|
2077
|
-
if (this.isInitialized) {
|
|
2078
|
-
return;
|
|
2079
|
-
}
|
|
2080
|
-
this.isInitialized = true;
|
|
2081
|
-
if (config) {
|
|
2082
|
-
this.telemetryContext = config;
|
|
2083
|
-
}
|
|
2084
|
-
try {
|
|
2085
|
-
const connectionString = this.getConnectionString();
|
|
2086
|
-
if (!connectionString) {
|
|
2087
|
-
return;
|
|
2088
|
-
}
|
|
2089
|
-
this.setupTelemetryProvider(connectionString);
|
|
2090
|
-
}
|
|
2091
|
-
catch (error) {
|
|
2092
|
-
// Silent failure - telemetry errors shouldn't break functionality
|
|
2093
|
-
console.debug('Failed to initialize OpenTelemetry:', error);
|
|
2094
|
-
}
|
|
2095
|
-
}
|
|
2096
|
-
getConnectionString() {
|
|
2097
|
-
const connectionString = CONNECTION_STRING;
|
|
2098
|
-
return connectionString;
|
|
2099
|
-
}
|
|
2100
|
-
setupTelemetryProvider(connectionString) {
|
|
2101
|
-
const exporter = new ApplicationInsightsEventExporter(connectionString);
|
|
2102
|
-
const processor = new BatchLogRecordProcessor(exporter);
|
|
2103
|
-
this.logProvider = new LoggerProvider({
|
|
2104
|
-
processors: [processor]
|
|
2105
|
-
});
|
|
2106
|
-
this.logger = this.logProvider.getLogger(SDK_LOGGER_NAME);
|
|
2107
|
-
}
|
|
2108
|
-
/**
|
|
2109
|
-
* Track a telemetry event
|
|
2110
|
-
*/
|
|
2111
|
-
track(eventName, name, extraAttributes = {}) {
|
|
2112
|
-
try {
|
|
2113
|
-
// Skip if logger not initialized
|
|
2114
|
-
if (!this.logger) {
|
|
2115
|
-
return;
|
|
2116
|
-
}
|
|
2117
|
-
const finalDisplayName = name || eventName;
|
|
2118
|
-
const attributes = this.getEnrichedAttributes(extraAttributes, eventName);
|
|
2119
|
-
// Emit as log
|
|
2120
|
-
this.logger.emit({
|
|
2121
|
-
body: finalDisplayName,
|
|
2122
|
-
attributes: attributes,
|
|
2123
|
-
timestamp: Date.now(),
|
|
2124
|
-
});
|
|
2125
|
-
}
|
|
2126
|
-
catch (error) {
|
|
2127
|
-
// Silent failure
|
|
2128
|
-
console.debug('Failed to track telemetry event:', error);
|
|
2129
|
-
}
|
|
2130
|
-
}
|
|
2131
|
-
/**
|
|
2132
|
-
* Get enriched attributes for telemetry events
|
|
2133
|
-
*/
|
|
2134
|
-
getEnrichedAttributes(extraAttributes, eventName) {
|
|
2135
|
-
const attributes = {
|
|
2136
|
-
[APP_NAME]: SDK_SERVICE_NAME,
|
|
2137
|
-
[VERSION]: SDK_VERSION,
|
|
2138
|
-
[SERVICE]: eventName,
|
|
2139
|
-
[CLOUD_URL]: this.createCloudUrl(),
|
|
2140
|
-
[CLOUD_ORGANIZATION_NAME]: this.telemetryContext?.orgName || UNKNOWN,
|
|
2141
|
-
[CLOUD_TENANT_NAME]: this.telemetryContext?.tenantName || UNKNOWN,
|
|
2142
|
-
[CLOUD_REDIRECT_URI]: this.telemetryContext?.redirectUri || UNKNOWN,
|
|
2143
|
-
[CLOUD_CLIENT_ID]: this.telemetryContext?.clientId || UNKNOWN,
|
|
2144
|
-
...extraAttributes,
|
|
2145
|
-
};
|
|
2146
|
-
return attributes;
|
|
2147
|
-
}
|
|
2148
|
-
/**
|
|
2149
|
-
* Create cloud URL from base URL, organization ID, and tenant ID
|
|
2150
|
-
*/
|
|
2151
|
-
createCloudUrl() {
|
|
2152
|
-
const baseUrl = this.telemetryContext?.baseUrl;
|
|
2153
|
-
const orgId = this.telemetryContext?.orgName;
|
|
2154
|
-
const tenantId = this.telemetryContext?.tenantName;
|
|
2155
|
-
if (!baseUrl || !orgId || !tenantId) {
|
|
2156
|
-
return UNKNOWN;
|
|
2157
|
-
}
|
|
2158
|
-
return `${baseUrl}/${orgId}/${tenantId}`;
|
|
2159
|
-
}
|
|
2160
|
-
}
|
|
2161
|
-
// Export singleton instance
|
|
2162
|
-
const telemetryClient = TelemetryClient.getInstance();
|
|
1967
|
+
* SDK Telemetry constants.
|
|
1968
|
+
*
|
|
1969
|
+
* Only the SDK's identity (version, service name, role name, …) lives
|
|
1970
|
+
* here. The Application Insights connection string is injected into
|
|
1971
|
+
* `@uipath/core-telemetry` itself at publish time, and the generic attribute
|
|
1972
|
+
* keys (`Version`, `Service`, `CloudOrganizationName`, …) are owned by
|
|
1973
|
+
* `@uipath/core-telemetry` and consumed there — they are not part of the
|
|
1974
|
+
* SDK's public API.
|
|
1975
|
+
*/
|
|
1976
|
+
/** SDK version placeholder — patched by the SDK publish workflow. */
|
|
1977
|
+
const CLOUD_ROLE_NAME = 'uipath-ts-sdk';
|
|
2163
1978
|
|
|
2164
1979
|
/**
|
|
2165
|
-
*
|
|
2166
|
-
*/
|
|
2167
|
-
/**
|
|
2168
|
-
* Common tracking logic shared between method and function decorators
|
|
2169
|
-
*/
|
|
2170
|
-
function createTrackedFunction(originalFunction, nameOrOptions, fallbackName, opts) {
|
|
2171
|
-
return function (...args) {
|
|
2172
|
-
// Determine if we should track this call
|
|
2173
|
-
let shouldTrack = true;
|
|
2174
|
-
if (opts.condition !== undefined) {
|
|
2175
|
-
if (typeof opts.condition === 'function') {
|
|
2176
|
-
shouldTrack = opts.condition.apply(this, args);
|
|
2177
|
-
}
|
|
2178
|
-
else {
|
|
2179
|
-
shouldTrack = opts.condition;
|
|
2180
|
-
}
|
|
2181
|
-
}
|
|
2182
|
-
// Track the event if enabled
|
|
2183
|
-
if (shouldTrack) {
|
|
2184
|
-
// Use the full name provided in the decorator (e.g., "Queue.GetAll")
|
|
2185
|
-
const serviceMethod = typeof nameOrOptions === 'string'
|
|
2186
|
-
? nameOrOptions
|
|
2187
|
-
: fallbackName;
|
|
2188
|
-
// Use 'Sdk.Run' as the name and serviceMethod as the service
|
|
2189
|
-
telemetryClient.track(serviceMethod, SDK_RUN_EVENT, opts.attributes);
|
|
2190
|
-
}
|
|
2191
|
-
// Execute the original function
|
|
2192
|
-
return originalFunction.apply(this, args);
|
|
2193
|
-
};
|
|
2194
|
-
}
|
|
2195
|
-
/**
|
|
2196
|
-
* Track decorator that can be used to automatically track function calls
|
|
2197
|
-
*
|
|
2198
|
-
* Usage:
|
|
2199
|
-
* @track("Service.Method")
|
|
2200
|
-
* function myFunction() { ... }
|
|
1980
|
+
* UiPath TypeScript SDK Telemetry
|
|
2201
1981
|
*
|
|
2202
|
-
*
|
|
2203
|
-
*
|
|
2204
|
-
*
|
|
2205
|
-
*
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
function track(nameOrOptions, options) {
|
|
2215
|
-
return function decorator(_target, propertyKey, descriptor) {
|
|
2216
|
-
const opts = typeof nameOrOptions === 'object' ? nameOrOptions : {};
|
|
2217
|
-
if (descriptor && typeof descriptor.value === 'function') {
|
|
2218
|
-
// Method decorator
|
|
2219
|
-
descriptor.value = createTrackedFunction(descriptor.value, nameOrOptions, propertyKey || 'unknown_method', opts);
|
|
2220
|
-
return descriptor;
|
|
2221
|
-
}
|
|
2222
|
-
// Function decorator
|
|
2223
|
-
return (originalFunction) => createTrackedFunction(originalFunction, nameOrOptions, originalFunction.name || 'unknown_function', opts);
|
|
2224
|
-
};
|
|
2225
|
-
}
|
|
1982
|
+
* Constructs the SDK's own `TelemetryClient` and binds the SDK-local
|
|
1983
|
+
* `track` / `trackEvent` to it. Each consumer of `@uipath/core-telemetry`
|
|
1984
|
+
* does this independently, so events carry their own consumer's identity
|
|
1985
|
+
* and tenant context.
|
|
1986
|
+
*/
|
|
1987
|
+
// Keyed by `CLOUD_ROLE_NAME` so every SDK subpath bundle resolves to the
|
|
1988
|
+
// same `TelemetryClient` instance at runtime. A single `initialize(...)`
|
|
1989
|
+
// from the `UiPath` constructor therefore wires up `@track` decorators
|
|
1990
|
+
// across every subpath bundle (`assets`, `feedback`, `tasks`, …).
|
|
1991
|
+
const sdkClient = getOrCreateClient(CLOUD_ROLE_NAME);
|
|
1992
|
+
const track = createTrack(sdkClient);
|
|
1993
|
+
createTrackEvent(sdkClient);
|
|
2226
1994
|
|
|
2227
1995
|
/**
|
|
2228
1996
|
* Maps fields for Attachment entities to ensure consistent naming
|