@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/buckets/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
|
}
|
|
@@ -1262,9 +1273,9 @@ class PaginationHelpers {
|
|
|
1262
1273
|
* @returns Promise resolving to a paginated result
|
|
1263
1274
|
*/
|
|
1264
1275
|
static async getAllPaginated(params) {
|
|
1265
|
-
const { serviceAccess, getEndpoint, folderId, paginationParams, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
|
|
1276
|
+
const { serviceAccess, getEndpoint, folderId, headers: providedHeaders, paginationParams, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
|
|
1266
1277
|
const endpoint = getEndpoint(folderId);
|
|
1267
|
-
const headers = folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {};
|
|
1278
|
+
const headers = providedHeaders ?? (folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {});
|
|
1268
1279
|
const paginatedResponse = await serviceAccess.requestWithPagination(method, endpoint, paginationParams, {
|
|
1269
1280
|
headers,
|
|
1270
1281
|
params: additionalParams,
|
|
@@ -1292,13 +1303,13 @@ class PaginationHelpers {
|
|
|
1292
1303
|
* @returns Promise resolving to an object with data and totalCount
|
|
1293
1304
|
*/
|
|
1294
1305
|
static async getAllNonPaginated(params) {
|
|
1295
|
-
const { serviceAccess, getAllEndpoint, getByFolderEndpoint, folderId, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
|
|
1306
|
+
const { serviceAccess, getAllEndpoint, getByFolderEndpoint, folderId, headers: providedHeaders, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
|
|
1296
1307
|
// Set default field names
|
|
1297
1308
|
const itemsField = options.itemsField || DEFAULT_ITEMS_FIELD;
|
|
1298
1309
|
const totalCountField = options.totalCountField || DEFAULT_TOTAL_COUNT_FIELD;
|
|
1299
1310
|
// Determine endpoint and headers based on folderId
|
|
1300
1311
|
const endpoint = folderId ? getByFolderEndpoint : getAllEndpoint;
|
|
1301
|
-
const headers = folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {};
|
|
1312
|
+
const headers = providedHeaders ?? (folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {});
|
|
1302
1313
|
// Make the API call based on method
|
|
1303
1314
|
let response;
|
|
1304
1315
|
if (method === HTTP_METHODS.POST) {
|
|
@@ -1357,6 +1368,7 @@ class PaginationHelpers {
|
|
|
1357
1368
|
serviceAccess: config.serviceAccess,
|
|
1358
1369
|
getEndpoint: config.getEndpoint,
|
|
1359
1370
|
folderId,
|
|
1371
|
+
headers: config.headers,
|
|
1360
1372
|
paginationParams: cursor ? { cursor, pageSize } : jumpToPage ? { jumpToPage, pageSize } : { pageSize },
|
|
1361
1373
|
additionalParams: prefixedOptions,
|
|
1362
1374
|
transformFn: config.transformFn,
|
|
@@ -1374,6 +1386,7 @@ class PaginationHelpers {
|
|
|
1374
1386
|
getAllEndpoint: config.getEndpoint(),
|
|
1375
1387
|
getByFolderEndpoint: byFolderEndpoint,
|
|
1376
1388
|
folderId,
|
|
1389
|
+
headers: config.headers,
|
|
1377
1390
|
additionalParams: prefixedOptions,
|
|
1378
1391
|
transformFn: config.transformFn,
|
|
1379
1392
|
method: config.method,
|
|
@@ -1918,6 +1931,8 @@ const BUCKET_ENDPOINTS = {
|
|
|
1918
1931
|
GET_FILE_META_DATA: (id) => `${ORCHESTRATOR_BASE}/api/Buckets/${id}/ListFiles`,
|
|
1919
1932
|
GET_READ_URI: (id) => `${ORCHESTRATOR_BASE}/odata/Buckets(${id})/UiPath.Server.Configuration.OData.GetReadUri`,
|
|
1920
1933
|
GET_WRITE_URI: (id) => `${ORCHESTRATOR_BASE}/odata/Buckets(${id})/UiPath.Server.Configuration.OData.GetWriteUri`,
|
|
1934
|
+
DELETE_FILE: (id) => `${ORCHESTRATOR_BASE}/odata/Buckets(${id})/UiPath.Server.Configuration.OData.DeleteFile`,
|
|
1935
|
+
GET_FILES: (id) => `${ORCHESTRATOR_BASE}/odata/Buckets(${id})/UiPath.Server.Configuration.OData.GetFiles`,
|
|
1921
1936
|
};
|
|
1922
1937
|
|
|
1923
1938
|
/**
|
|
@@ -1930,278 +1945,33 @@ const BucketMap = {
|
|
|
1930
1945
|
};
|
|
1931
1946
|
|
|
1932
1947
|
/**
|
|
1933
|
-
* SDK Telemetry constants
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
const
|
|
1944
|
-
const CLOUD_CLIENT_ID = "CloudClientId";
|
|
1945
|
-
const CLOUD_REDIRECT_URI = "CloudRedirectUri";
|
|
1946
|
-
const APP_NAME = "ApplicationName";
|
|
1947
|
-
const CLOUD_ROLE_NAME = "uipath-ts-sdk";
|
|
1948
|
-
// Service and logger names
|
|
1949
|
-
const SDK_SERVICE_NAME = "UiPath.TypeScript.Sdk";
|
|
1950
|
-
const SDK_LOGGER_NAME = "uipath-ts-sdk-telemetry";
|
|
1951
|
-
// Event names
|
|
1952
|
-
const SDK_RUN_EVENT = "Sdk.Run";
|
|
1953
|
-
// Default value for unknown/empty attributes
|
|
1954
|
-
const UNKNOWN = "";
|
|
1955
|
-
|
|
1956
|
-
/**
|
|
1957
|
-
* Log exporter that sends ALL logs as Application Insights custom events
|
|
1958
|
-
*/
|
|
1959
|
-
class ApplicationInsightsEventExporter {
|
|
1960
|
-
constructor(connectionString) {
|
|
1961
|
-
this.connectionString = connectionString;
|
|
1962
|
-
}
|
|
1963
|
-
export(logs, resultCallback) {
|
|
1964
|
-
try {
|
|
1965
|
-
logs.forEach(logRecord => {
|
|
1966
|
-
this.sendAsCustomEvent(logRecord);
|
|
1967
|
-
});
|
|
1968
|
-
resultCallback({ code: 0 });
|
|
1969
|
-
}
|
|
1970
|
-
catch (error) {
|
|
1971
|
-
console.debug('Failed to export logs to Application Insights:', error);
|
|
1972
|
-
resultCallback({ code: 2, error });
|
|
1973
|
-
}
|
|
1974
|
-
}
|
|
1975
|
-
shutdown() {
|
|
1976
|
-
return Promise.resolve();
|
|
1977
|
-
}
|
|
1978
|
-
sendAsCustomEvent(logRecord) {
|
|
1979
|
-
// Get event name from body or attributes
|
|
1980
|
-
const eventName = logRecord.body || SDK_RUN_EVENT;
|
|
1981
|
-
const payload = {
|
|
1982
|
-
name: 'Microsoft.ApplicationInsights.Event',
|
|
1983
|
-
time: new Date().toISOString(),
|
|
1984
|
-
iKey: this.extractInstrumentationKey(),
|
|
1985
|
-
data: {
|
|
1986
|
-
baseType: 'EventData',
|
|
1987
|
-
baseData: {
|
|
1988
|
-
ver: 2,
|
|
1989
|
-
name: eventName,
|
|
1990
|
-
properties: this.convertAttributesToProperties(logRecord.attributes || {})
|
|
1991
|
-
}
|
|
1992
|
-
},
|
|
1993
|
-
tags: {
|
|
1994
|
-
'ai.cloud.role': CLOUD_ROLE_NAME,
|
|
1995
|
-
'ai.cloud.roleInstance': SDK_VERSION
|
|
1996
|
-
}
|
|
1997
|
-
};
|
|
1998
|
-
this.sendToApplicationInsights(payload);
|
|
1999
|
-
}
|
|
2000
|
-
extractInstrumentationKey() {
|
|
2001
|
-
const match = this.connectionString.match(/InstrumentationKey=([^;]+)/);
|
|
2002
|
-
return match ? match[1] : '';
|
|
2003
|
-
}
|
|
2004
|
-
convertAttributesToProperties(attributes) {
|
|
2005
|
-
const properties = {};
|
|
2006
|
-
Object.entries(attributes || {}).forEach(([key, value]) => {
|
|
2007
|
-
properties[key] = String(value);
|
|
2008
|
-
});
|
|
2009
|
-
return properties;
|
|
2010
|
-
}
|
|
2011
|
-
async sendToApplicationInsights(payload) {
|
|
2012
|
-
try {
|
|
2013
|
-
const ingestionEndpoint = this.extractIngestionEndpoint();
|
|
2014
|
-
if (!ingestionEndpoint) {
|
|
2015
|
-
console.debug('No ingestion endpoint found in connection string');
|
|
2016
|
-
return;
|
|
2017
|
-
}
|
|
2018
|
-
const url = `${ingestionEndpoint}/v2/track`;
|
|
2019
|
-
const response = await fetch(url, {
|
|
2020
|
-
method: 'POST',
|
|
2021
|
-
headers: {
|
|
2022
|
-
'Content-Type': 'application/json',
|
|
2023
|
-
},
|
|
2024
|
-
body: JSON.stringify(payload)
|
|
2025
|
-
});
|
|
2026
|
-
if (!response.ok) {
|
|
2027
|
-
console.debug(`Failed to send event telemetry: ${response.status} ${response.statusText}`);
|
|
2028
|
-
}
|
|
2029
|
-
}
|
|
2030
|
-
catch (error) {
|
|
2031
|
-
console.debug('Error sending event telemetry to Application Insights:', error);
|
|
2032
|
-
}
|
|
2033
|
-
}
|
|
2034
|
-
extractIngestionEndpoint() {
|
|
2035
|
-
const match = this.connectionString.match(/IngestionEndpoint=([^;]+)/);
|
|
2036
|
-
return match ? match[1] : '';
|
|
2037
|
-
}
|
|
2038
|
-
}
|
|
2039
|
-
/**
|
|
2040
|
-
* Singleton telemetry client
|
|
2041
|
-
*/
|
|
2042
|
-
class TelemetryClient {
|
|
2043
|
-
constructor() {
|
|
2044
|
-
this.isInitialized = false;
|
|
2045
|
-
}
|
|
2046
|
-
static getInstance() {
|
|
2047
|
-
if (!TelemetryClient.instance) {
|
|
2048
|
-
TelemetryClient.instance = new TelemetryClient();
|
|
2049
|
-
}
|
|
2050
|
-
return TelemetryClient.instance;
|
|
2051
|
-
}
|
|
2052
|
-
/**
|
|
2053
|
-
* Initialize telemetry
|
|
2054
|
-
*/
|
|
2055
|
-
initialize(config) {
|
|
2056
|
-
if (this.isInitialized) {
|
|
2057
|
-
return;
|
|
2058
|
-
}
|
|
2059
|
-
this.isInitialized = true;
|
|
2060
|
-
if (config) {
|
|
2061
|
-
this.telemetryContext = config;
|
|
2062
|
-
}
|
|
2063
|
-
try {
|
|
2064
|
-
const connectionString = this.getConnectionString();
|
|
2065
|
-
if (!connectionString) {
|
|
2066
|
-
return;
|
|
2067
|
-
}
|
|
2068
|
-
this.setupTelemetryProvider(connectionString);
|
|
2069
|
-
}
|
|
2070
|
-
catch (error) {
|
|
2071
|
-
// Silent failure - telemetry errors shouldn't break functionality
|
|
2072
|
-
console.debug('Failed to initialize OpenTelemetry:', error);
|
|
2073
|
-
}
|
|
2074
|
-
}
|
|
2075
|
-
getConnectionString() {
|
|
2076
|
-
const connectionString = CONNECTION_STRING;
|
|
2077
|
-
return connectionString;
|
|
2078
|
-
}
|
|
2079
|
-
setupTelemetryProvider(connectionString) {
|
|
2080
|
-
const exporter = new ApplicationInsightsEventExporter(connectionString);
|
|
2081
|
-
const processor = new BatchLogRecordProcessor(exporter);
|
|
2082
|
-
this.logProvider = new LoggerProvider({
|
|
2083
|
-
processors: [processor]
|
|
2084
|
-
});
|
|
2085
|
-
this.logger = this.logProvider.getLogger(SDK_LOGGER_NAME);
|
|
2086
|
-
}
|
|
2087
|
-
/**
|
|
2088
|
-
* Track a telemetry event
|
|
2089
|
-
*/
|
|
2090
|
-
track(eventName, name, extraAttributes = {}) {
|
|
2091
|
-
try {
|
|
2092
|
-
// Skip if logger not initialized
|
|
2093
|
-
if (!this.logger) {
|
|
2094
|
-
return;
|
|
2095
|
-
}
|
|
2096
|
-
const finalDisplayName = name || eventName;
|
|
2097
|
-
const attributes = this.getEnrichedAttributes(extraAttributes, eventName);
|
|
2098
|
-
// Emit as log
|
|
2099
|
-
this.logger.emit({
|
|
2100
|
-
body: finalDisplayName,
|
|
2101
|
-
attributes: attributes,
|
|
2102
|
-
timestamp: Date.now(),
|
|
2103
|
-
});
|
|
2104
|
-
}
|
|
2105
|
-
catch (error) {
|
|
2106
|
-
// Silent failure
|
|
2107
|
-
console.debug('Failed to track telemetry event:', error);
|
|
2108
|
-
}
|
|
2109
|
-
}
|
|
2110
|
-
/**
|
|
2111
|
-
* Get enriched attributes for telemetry events
|
|
2112
|
-
*/
|
|
2113
|
-
getEnrichedAttributes(extraAttributes, eventName) {
|
|
2114
|
-
const attributes = {
|
|
2115
|
-
[APP_NAME]: SDK_SERVICE_NAME,
|
|
2116
|
-
[VERSION]: SDK_VERSION,
|
|
2117
|
-
[SERVICE]: eventName,
|
|
2118
|
-
[CLOUD_URL]: this.createCloudUrl(),
|
|
2119
|
-
[CLOUD_ORGANIZATION_NAME]: this.telemetryContext?.orgName || UNKNOWN,
|
|
2120
|
-
[CLOUD_TENANT_NAME]: this.telemetryContext?.tenantName || UNKNOWN,
|
|
2121
|
-
[CLOUD_REDIRECT_URI]: this.telemetryContext?.redirectUri || UNKNOWN,
|
|
2122
|
-
[CLOUD_CLIENT_ID]: this.telemetryContext?.clientId || UNKNOWN,
|
|
2123
|
-
...extraAttributes,
|
|
2124
|
-
};
|
|
2125
|
-
return attributes;
|
|
2126
|
-
}
|
|
2127
|
-
/**
|
|
2128
|
-
* Create cloud URL from base URL, organization ID, and tenant ID
|
|
2129
|
-
*/
|
|
2130
|
-
createCloudUrl() {
|
|
2131
|
-
const baseUrl = this.telemetryContext?.baseUrl;
|
|
2132
|
-
const orgId = this.telemetryContext?.orgName;
|
|
2133
|
-
const tenantId = this.telemetryContext?.tenantName;
|
|
2134
|
-
if (!baseUrl || !orgId || !tenantId) {
|
|
2135
|
-
return UNKNOWN;
|
|
2136
|
-
}
|
|
2137
|
-
return `${baseUrl}/${orgId}/${tenantId}`;
|
|
2138
|
-
}
|
|
2139
|
-
}
|
|
2140
|
-
// Export singleton instance
|
|
2141
|
-
const telemetryClient = TelemetryClient.getInstance();
|
|
1948
|
+
* SDK Telemetry constants.
|
|
1949
|
+
*
|
|
1950
|
+
* Only the SDK's identity (version, service name, role name, …) lives
|
|
1951
|
+
* here. The Application Insights connection string is injected into
|
|
1952
|
+
* `@uipath/core-telemetry` itself at publish time, and the generic attribute
|
|
1953
|
+
* keys (`Version`, `Service`, `CloudOrganizationName`, …) are owned by
|
|
1954
|
+
* `@uipath/core-telemetry` and consumed there — they are not part of the
|
|
1955
|
+
* SDK's public API.
|
|
1956
|
+
*/
|
|
1957
|
+
/** SDK version placeholder — patched by the SDK publish workflow. */
|
|
1958
|
+
const CLOUD_ROLE_NAME = 'uipath-ts-sdk';
|
|
2142
1959
|
|
|
2143
1960
|
/**
|
|
2144
|
-
*
|
|
2145
|
-
*/
|
|
2146
|
-
/**
|
|
2147
|
-
* Common tracking logic shared between method and function decorators
|
|
2148
|
-
*/
|
|
2149
|
-
function createTrackedFunction(originalFunction, nameOrOptions, fallbackName, opts) {
|
|
2150
|
-
return function (...args) {
|
|
2151
|
-
// Determine if we should track this call
|
|
2152
|
-
let shouldTrack = true;
|
|
2153
|
-
if (opts.condition !== undefined) {
|
|
2154
|
-
if (typeof opts.condition === 'function') {
|
|
2155
|
-
shouldTrack = opts.condition.apply(this, args);
|
|
2156
|
-
}
|
|
2157
|
-
else {
|
|
2158
|
-
shouldTrack = opts.condition;
|
|
2159
|
-
}
|
|
2160
|
-
}
|
|
2161
|
-
// Track the event if enabled
|
|
2162
|
-
if (shouldTrack) {
|
|
2163
|
-
// Use the full name provided in the decorator (e.g., "Queue.GetAll")
|
|
2164
|
-
const serviceMethod = typeof nameOrOptions === 'string'
|
|
2165
|
-
? nameOrOptions
|
|
2166
|
-
: fallbackName;
|
|
2167
|
-
// Use 'Sdk.Run' as the name and serviceMethod as the service
|
|
2168
|
-
telemetryClient.track(serviceMethod, SDK_RUN_EVENT, opts.attributes);
|
|
2169
|
-
}
|
|
2170
|
-
// Execute the original function
|
|
2171
|
-
return originalFunction.apply(this, args);
|
|
2172
|
-
};
|
|
2173
|
-
}
|
|
2174
|
-
/**
|
|
2175
|
-
* Track decorator that can be used to automatically track function calls
|
|
1961
|
+
* UiPath TypeScript SDK Telemetry
|
|
2176
1962
|
*
|
|
2177
|
-
*
|
|
2178
|
-
*
|
|
2179
|
-
*
|
|
2180
|
-
*
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
*
|
|
2190
|
-
* @track("Processes.Start", { attributes: { customProp: "value" } })
|
|
2191
|
-
* function myFunction() { ... }
|
|
2192
|
-
*/
|
|
2193
|
-
function track(nameOrOptions, options) {
|
|
2194
|
-
return function decorator(_target, propertyKey, descriptor) {
|
|
2195
|
-
const opts = typeof nameOrOptions === 'object' ? nameOrOptions : {};
|
|
2196
|
-
if (descriptor && typeof descriptor.value === 'function') {
|
|
2197
|
-
// Method decorator
|
|
2198
|
-
descriptor.value = createTrackedFunction(descriptor.value, nameOrOptions, propertyKey || 'unknown_method', opts);
|
|
2199
|
-
return descriptor;
|
|
2200
|
-
}
|
|
2201
|
-
// Function decorator
|
|
2202
|
-
return (originalFunction) => createTrackedFunction(originalFunction, nameOrOptions, originalFunction.name || 'unknown_function', opts);
|
|
2203
|
-
};
|
|
2204
|
-
}
|
|
1963
|
+
* Constructs the SDK's own `TelemetryClient` and binds the SDK-local
|
|
1964
|
+
* `track` / `trackEvent` to it. Each consumer of `@uipath/core-telemetry`
|
|
1965
|
+
* does this independently, so events carry their own consumer's identity
|
|
1966
|
+
* and tenant context.
|
|
1967
|
+
*/
|
|
1968
|
+
// Keyed by `CLOUD_ROLE_NAME` so every SDK subpath bundle resolves to the
|
|
1969
|
+
// same `TelemetryClient` instance at runtime. A single `initialize(...)`
|
|
1970
|
+
// from the `UiPath` constructor therefore wires up `@track` decorators
|
|
1971
|
+
// across every subpath bundle (`assets`, `feedback`, `tasks`, …).
|
|
1972
|
+
const sdkClient = getOrCreateClient(CLOUD_ROLE_NAME);
|
|
1973
|
+
const track = createTrack(sdkClient);
|
|
1974
|
+
createTrackEvent(sdkClient);
|
|
2205
1975
|
|
|
2206
1976
|
class BucketService extends FolderScopedService {
|
|
2207
1977
|
/**
|
|
@@ -2239,6 +2009,32 @@ class BucketService extends FolderScopedService {
|
|
|
2239
2009
|
// Transform response from PascalCase to camelCase
|
|
2240
2010
|
return pascalToCamelCaseKeys(response.data);
|
|
2241
2011
|
}
|
|
2012
|
+
/**
|
|
2013
|
+
* Retrieves a single orchestrator storage bucket by name.
|
|
2014
|
+
*
|
|
2015
|
+
* @param name - Bucket name to search for
|
|
2016
|
+
* @param options - Folder scoping (`folderId` / `folderKey` / `folderPath`) and optional query parameters (`expand`, `select`)
|
|
2017
|
+
* @returns Promise resolving to a single bucket
|
|
2018
|
+
* {@link BucketGetResponse}
|
|
2019
|
+
* @example
|
|
2020
|
+
* ```typescript
|
|
2021
|
+
* import { Buckets } from '@uipath/uipath-typescript/buckets';
|
|
2022
|
+
*
|
|
2023
|
+
* const buckets = new Buckets(sdk);
|
|
2024
|
+
*
|
|
2025
|
+
* // By folder ID
|
|
2026
|
+
* await buckets.getByName('MyBucket', { folderId: <folderId> });
|
|
2027
|
+
*
|
|
2028
|
+
* // By folder key (GUID)
|
|
2029
|
+
* await buckets.getByName('MyBucket', { folderKey: '<folderKey>' });
|
|
2030
|
+
*
|
|
2031
|
+
* // By folder path
|
|
2032
|
+
* await buckets.getByName('MyBucket', { folderPath: '<folderPath>' });
|
|
2033
|
+
* ```
|
|
2034
|
+
*/
|
|
2035
|
+
async getByName(name, options = {}) {
|
|
2036
|
+
return this.getByNameLookup('Bucket', BUCKET_ENDPOINTS.GET_BY_FOLDER, name, options, (raw) => pascalToCamelCaseKeys(raw));
|
|
2037
|
+
}
|
|
2242
2038
|
/**
|
|
2243
2039
|
* Gets all buckets across folders with optional filtering and folder scoping
|
|
2244
2040
|
*
|
|
@@ -2510,6 +2306,120 @@ class BucketService extends FolderScopedService {
|
|
|
2510
2306
|
}
|
|
2511
2307
|
return transformedData;
|
|
2512
2308
|
}
|
|
2309
|
+
/**
|
|
2310
|
+
* Lists all files in a bucket.
|
|
2311
|
+
*
|
|
2312
|
+
* Returns a flat, recursive listing of all files in the bucket. Supports regex filtering
|
|
2313
|
+
* and filter / orderby / select / expand. {@link BucketFile} entries include
|
|
2314
|
+
* `isDirectory` so callers can distinguish folders from files.
|
|
2315
|
+
*
|
|
2316
|
+
* The method returns either:
|
|
2317
|
+
* - A NonPaginatedResponse with items array (when no pagination parameters are provided)
|
|
2318
|
+
* - A PaginatedResponse with navigation cursors (when any pagination parameter is provided)
|
|
2319
|
+
*
|
|
2320
|
+
* @param bucketId - The ID of the bucket
|
|
2321
|
+
* @param options - Folder scoping (`folderId` / `folderKey` / `folderPath`) and optional parameters for regex filtering, query options, and pagination
|
|
2322
|
+
* @returns Promise resolving to either an array of files NonPaginatedResponse<BucketFile> or a PaginatedResponse<BucketFile> when pagination options are used.
|
|
2323
|
+
*
|
|
2324
|
+
* @example
|
|
2325
|
+
* ```typescript
|
|
2326
|
+
* import { Buckets } from '@uipath/uipath-typescript/buckets';
|
|
2327
|
+
*
|
|
2328
|
+
* const buckets = new Buckets(sdk);
|
|
2329
|
+
*
|
|
2330
|
+
* // List all files in the bucket
|
|
2331
|
+
* const files = await buckets.getFiles(<bucketId>, { folderId: <folderId> });
|
|
2332
|
+
*
|
|
2333
|
+
* // Filter by regex pattern
|
|
2334
|
+
* const pdfs = await buckets.getFiles(<bucketId>, {
|
|
2335
|
+
* folderId: <folderId>,
|
|
2336
|
+
* fileNameRegex: '.*\\.pdf$'
|
|
2337
|
+
* });
|
|
2338
|
+
*
|
|
2339
|
+
* // First page with pagination
|
|
2340
|
+
* const page1 = await buckets.getFiles(<bucketId>, { folderId: <folderId>, pageSize: 10 });
|
|
2341
|
+
*
|
|
2342
|
+
* // Navigate using cursor
|
|
2343
|
+
* if (page1.hasNextPage) {
|
|
2344
|
+
* const page2 = await buckets.getFiles(<bucketId>, { folderId: <folderId>, cursor: page1.nextCursor });
|
|
2345
|
+
* }
|
|
2346
|
+
*
|
|
2347
|
+
* // Jump to specific page
|
|
2348
|
+
* const page5 = await buckets.getFiles(<bucketId>, {
|
|
2349
|
+
* folderId: <folderId>,
|
|
2350
|
+
* jumpToPage: 5,
|
|
2351
|
+
* pageSize: 10
|
|
2352
|
+
* });
|
|
2353
|
+
* ```
|
|
2354
|
+
*/
|
|
2355
|
+
async getFiles(bucketId, options) {
|
|
2356
|
+
if (!bucketId) {
|
|
2357
|
+
throw new ValidationError({ message: 'bucketId is required for getFiles' });
|
|
2358
|
+
}
|
|
2359
|
+
const { folderId, folderKey, folderPath, ...restOptions } = options ?? {};
|
|
2360
|
+
const headers = resolveFolderHeaders({
|
|
2361
|
+
folderId,
|
|
2362
|
+
folderKey,
|
|
2363
|
+
folderPath,
|
|
2364
|
+
resourceType: 'Buckets.getFiles',
|
|
2365
|
+
fallbackFolderKey: this.config.folderKey,
|
|
2366
|
+
});
|
|
2367
|
+
const transformBucketFile = (file) => transformData(pascalToCamelCaseKeys(file), BucketMap);
|
|
2368
|
+
return PaginationHelpers.getAll({
|
|
2369
|
+
serviceAccess: this.createPaginationServiceAccess(),
|
|
2370
|
+
getEndpoint: () => BUCKET_ENDPOINTS.GET_FILES(bucketId),
|
|
2371
|
+
transformFn: transformBucketFile,
|
|
2372
|
+
pagination: {
|
|
2373
|
+
paginationType: PaginationType.OFFSET,
|
|
2374
|
+
itemsField: ODATA_PAGINATION.ITEMS_FIELD,
|
|
2375
|
+
totalCountField: ODATA_PAGINATION.TOTAL_COUNT_FIELD,
|
|
2376
|
+
paginationParams: {
|
|
2377
|
+
pageSizeParam: ODATA_OFFSET_PARAMS.PAGE_SIZE_PARAM,
|
|
2378
|
+
offsetParam: ODATA_OFFSET_PARAMS.OFFSET_PARAM,
|
|
2379
|
+
countParam: ODATA_OFFSET_PARAMS.COUNT_PARAM,
|
|
2380
|
+
},
|
|
2381
|
+
},
|
|
2382
|
+
excludeFromPrefix: ['directory', 'recursive', 'fileNameRegex'],
|
|
2383
|
+
headers,
|
|
2384
|
+
}, { ...restOptions, directory: '/', recursive: true });
|
|
2385
|
+
}
|
|
2386
|
+
/**
|
|
2387
|
+
* Deletes a file from a bucket
|
|
2388
|
+
*
|
|
2389
|
+
* @param bucketId - The ID of the bucket
|
|
2390
|
+
* @param path - The full path to the file to delete
|
|
2391
|
+
* @param options - Folder scoping (`folderId` / `folderKey` / `folderPath`)
|
|
2392
|
+
* @returns Promise resolving when the file is deleted
|
|
2393
|
+
*
|
|
2394
|
+
* @example
|
|
2395
|
+
* ```typescript
|
|
2396
|
+
* import { Buckets } from '@uipath/uipath-typescript/buckets';
|
|
2397
|
+
*
|
|
2398
|
+
* const buckets = new Buckets(sdk);
|
|
2399
|
+
*
|
|
2400
|
+
* // Delete a file from a bucket
|
|
2401
|
+
* await buckets.deleteFile(<bucketId>, '/folder/file.pdf', { folderId: <folderId> });
|
|
2402
|
+
* ```
|
|
2403
|
+
*/
|
|
2404
|
+
async deleteFile(bucketId, path, options) {
|
|
2405
|
+
if (!bucketId) {
|
|
2406
|
+
throw new ValidationError({ message: 'bucketId is required for deleteFile' });
|
|
2407
|
+
}
|
|
2408
|
+
if (!path) {
|
|
2409
|
+
throw new ValidationError({ message: 'path is required for deleteFile' });
|
|
2410
|
+
}
|
|
2411
|
+
const headers = resolveFolderHeaders({
|
|
2412
|
+
folderId: options?.folderId,
|
|
2413
|
+
folderKey: options?.folderKey,
|
|
2414
|
+
folderPath: options?.folderPath,
|
|
2415
|
+
resourceType: 'Buckets.deleteFile',
|
|
2416
|
+
fallbackFolderKey: this.config.folderKey,
|
|
2417
|
+
});
|
|
2418
|
+
await this.delete(BUCKET_ENDPOINTS.DELETE_FILE(bucketId), {
|
|
2419
|
+
params: { path },
|
|
2420
|
+
headers,
|
|
2421
|
+
});
|
|
2422
|
+
}
|
|
2513
2423
|
/**
|
|
2514
2424
|
* Gets a direct upload URL for a file in the bucket
|
|
2515
2425
|
*
|
|
@@ -2528,6 +2438,9 @@ class BucketService extends FolderScopedService {
|
|
|
2528
2438
|
__decorate([
|
|
2529
2439
|
track('Buckets.GetById')
|
|
2530
2440
|
], BucketService.prototype, "getById", null);
|
|
2441
|
+
__decorate([
|
|
2442
|
+
track('Buckets.GetByName')
|
|
2443
|
+
], BucketService.prototype, "getByName", null);
|
|
2531
2444
|
__decorate([
|
|
2532
2445
|
track('Buckets.GetAll')
|
|
2533
2446
|
], BucketService.prototype, "getAll", null);
|
|
@@ -2540,6 +2453,12 @@ __decorate([
|
|
|
2540
2453
|
__decorate([
|
|
2541
2454
|
track('Buckets.GetReadUri')
|
|
2542
2455
|
], BucketService.prototype, "getReadUri", null);
|
|
2456
|
+
__decorate([
|
|
2457
|
+
track('Buckets.GetFiles')
|
|
2458
|
+
], BucketService.prototype, "getFiles", null);
|
|
2459
|
+
__decorate([
|
|
2460
|
+
track('Buckets.DeleteFile')
|
|
2461
|
+
], BucketService.prototype, "deleteFile", null);
|
|
2543
2462
|
|
|
2544
2463
|
var BucketOptions;
|
|
2545
2464
|
(function (BucketOptions) {
|