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