@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,4 +1,4 @@
1
- import { BatchLogRecordProcessor, LoggerProvider } from '@opentelemetry/sdk-logs';
1
+ import { getOrCreateClient, createTrack, createTrackEvent } from '@uipath/core-telemetry';
2
2
 
3
3
  /******************************************************************************
4
4
  Copyright (c) Microsoft Corporation.
@@ -651,6 +651,27 @@ var PaginationType;
651
651
  /**
652
652
  * Collection of utility functions for working with objects
653
653
  */
654
+ /**
655
+ * Resolves a field value from an object, supporting both direct keys (e.g., '@odata.count')
656
+ * and dot-separated nested paths (e.g., 'pagination.totalCount').
657
+ * Direct key match takes priority over nested traversal.
658
+ */
659
+ function resolveNestedField(data, fieldPath) {
660
+ if (!data) {
661
+ return undefined;
662
+ }
663
+ if (fieldPath in data) {
664
+ return data[fieldPath];
665
+ }
666
+ if (!fieldPath.includes('.')) {
667
+ return undefined;
668
+ }
669
+ let value = data;
670
+ for (const part of fieldPath.split('.')) {
671
+ value = value?.[part];
672
+ }
673
+ return value;
674
+ }
654
675
  /**
655
676
  * Filters out undefined values from an object
656
677
  * @param obj The source object
@@ -900,6 +921,10 @@ const BUCKET_TOKEN_PARAMS = {
900
921
  TOKEN_PARAM: 'continuationToken'
901
922
  };
902
923
 
924
+ /**
925
+ * Converts a UTC timestamp string (e.g., "5/8/2026 11:20:17 AM") to ISO 8601 UTC format.
926
+ * Returns the original value if parsing fails.
927
+ */
903
928
  /**
904
929
  * Transforms data by mapping fields according to the provided field mapping
905
930
  * @param data The source data to transform
@@ -1288,7 +1313,8 @@ class PaginationHelpers {
1288
1313
  // Extract and transform items from response
1289
1314
  // Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N })
1290
1315
  const rawItems = Array.isArray(response.data) ? response.data : response.data?.[itemsField];
1291
- const totalCount = Array.isArray(response.data) ? undefined : response.data?.[totalCountField];
1316
+ const rawTotalCount = Array.isArray(response.data) ? undefined : resolveNestedField(response.data, totalCountField);
1317
+ const totalCount = typeof rawTotalCount === 'number' ? rawTotalCount : undefined;
1292
1318
  // Parse items - automatically handle JSON string responses
1293
1319
  const parsedItems = typeof rawItems === 'string' ? JSON.parse(rawItems) : (rawItems || []);
1294
1320
  const items = transformFn ? parsedItems.map(transformFn) : parsedItems;
@@ -1585,9 +1611,17 @@ class BaseService {
1585
1611
  const pageSizeParam = paginationParams?.pageSizeParam || ODATA_OFFSET_PARAMS.PAGE_SIZE_PARAM;
1586
1612
  const offsetParam = paginationParams?.offsetParam || ODATA_OFFSET_PARAMS.OFFSET_PARAM;
1587
1613
  const countParam = paginationParams?.countParam || ODATA_OFFSET_PARAMS.COUNT_PARAM;
1614
+ // When true (default), converts pageNumber to a skip/offset value (e.g., page 3 with pageSize 10 → skip 20).
1615
+ // When false, passes pageNumber directly as the offset param — used by APIs that accept a page number instead of a record offset.
1616
+ const convertToSkip = paginationParams?.convertToSkip ?? true;
1588
1617
  requestParams[pageSizeParam] = limitedPageSize;
1589
- if (params.pageNumber && params.pageNumber > 1) {
1590
- requestParams[offsetParam] = (params.pageNumber - 1) * limitedPageSize;
1618
+ if (convertToSkip) {
1619
+ if (params.pageNumber && params.pageNumber > 1) {
1620
+ requestParams[offsetParam] = (params.pageNumber - 1) * limitedPageSize;
1621
+ }
1622
+ }
1623
+ else {
1624
+ requestParams[offsetParam] = params.pageNumber || 1;
1591
1625
  }
1592
1626
  {
1593
1627
  requestParams[countParam] = true;
@@ -1618,7 +1652,8 @@ class BaseService {
1618
1652
  // Extract items and metadata
1619
1653
  // Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N })
1620
1654
  const items = Array.isArray(response.data) ? response.data : (response.data[itemsField] || []);
1621
- const totalCount = Array.isArray(response.data) ? undefined : response.data[totalCountField];
1655
+ const rawTotalCount = Array.isArray(response.data) ? undefined : resolveNestedField(response.data, totalCountField);
1656
+ const totalCount = typeof rawTotalCount === 'number' ? rawTotalCount : undefined;
1622
1657
  const continuationToken = response.data[continuationTokenField];
1623
1658
  // Determine if there are more pages
1624
1659
  const hasMore = this.determineHasMorePages(paginationType, {
@@ -1895,278 +1930,33 @@ const BucketMap = {
1895
1930
  };
1896
1931
 
1897
1932
  /**
1898
- * SDK Telemetry constants
1899
- */
1900
- // Connection string placeholder that will be replaced during build
1901
- 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";
1902
- // SDK Version placeholder
1903
- const SDK_VERSION = "1.3.7";
1904
- const VERSION = "Version";
1905
- const SERVICE = "Service";
1906
- const CLOUD_ORGANIZATION_NAME = "CloudOrganizationName";
1907
- const CLOUD_TENANT_NAME = "CloudTenantName";
1908
- const CLOUD_URL = "CloudUrl";
1909
- const CLOUD_CLIENT_ID = "CloudClientId";
1910
- const CLOUD_REDIRECT_URI = "CloudRedirectUri";
1911
- const APP_NAME = "ApplicationName";
1912
- const CLOUD_ROLE_NAME = "uipath-ts-sdk";
1913
- // Service and logger names
1914
- const SDK_SERVICE_NAME = "UiPath.TypeScript.Sdk";
1915
- const SDK_LOGGER_NAME = "uipath-ts-sdk-telemetry";
1916
- // Event names
1917
- const SDK_RUN_EVENT = "Sdk.Run";
1918
- // Default value for unknown/empty attributes
1919
- const UNKNOWN = "";
1920
-
1921
- /**
1922
- * Log exporter that sends ALL logs as Application Insights custom events
1923
- */
1924
- class ApplicationInsightsEventExporter {
1925
- constructor(connectionString) {
1926
- this.connectionString = connectionString;
1927
- }
1928
- export(logs, resultCallback) {
1929
- try {
1930
- logs.forEach(logRecord => {
1931
- this.sendAsCustomEvent(logRecord);
1932
- });
1933
- resultCallback({ code: 0 });
1934
- }
1935
- catch (error) {
1936
- console.debug('Failed to export logs to Application Insights:', error);
1937
- resultCallback({ code: 2, error });
1938
- }
1939
- }
1940
- shutdown() {
1941
- return Promise.resolve();
1942
- }
1943
- sendAsCustomEvent(logRecord) {
1944
- // Get event name from body or attributes
1945
- const eventName = logRecord.body || SDK_RUN_EVENT;
1946
- const payload = {
1947
- name: 'Microsoft.ApplicationInsights.Event',
1948
- time: new Date().toISOString(),
1949
- iKey: this.extractInstrumentationKey(),
1950
- data: {
1951
- baseType: 'EventData',
1952
- baseData: {
1953
- ver: 2,
1954
- name: eventName,
1955
- properties: this.convertAttributesToProperties(logRecord.attributes || {})
1956
- }
1957
- },
1958
- tags: {
1959
- 'ai.cloud.role': CLOUD_ROLE_NAME,
1960
- 'ai.cloud.roleInstance': SDK_VERSION
1961
- }
1962
- };
1963
- this.sendToApplicationInsights(payload);
1964
- }
1965
- extractInstrumentationKey() {
1966
- const match = this.connectionString.match(/InstrumentationKey=([^;]+)/);
1967
- return match ? match[1] : '';
1968
- }
1969
- convertAttributesToProperties(attributes) {
1970
- const properties = {};
1971
- Object.entries(attributes || {}).forEach(([key, value]) => {
1972
- properties[key] = String(value);
1973
- });
1974
- return properties;
1975
- }
1976
- async sendToApplicationInsights(payload) {
1977
- try {
1978
- const ingestionEndpoint = this.extractIngestionEndpoint();
1979
- if (!ingestionEndpoint) {
1980
- console.debug('No ingestion endpoint found in connection string');
1981
- return;
1982
- }
1983
- const url = `${ingestionEndpoint}/v2/track`;
1984
- const response = await fetch(url, {
1985
- method: 'POST',
1986
- headers: {
1987
- 'Content-Type': 'application/json',
1988
- },
1989
- body: JSON.stringify(payload)
1990
- });
1991
- if (!response.ok) {
1992
- console.debug(`Failed to send event telemetry: ${response.status} ${response.statusText}`);
1993
- }
1994
- }
1995
- catch (error) {
1996
- console.debug('Error sending event telemetry to Application Insights:', error);
1997
- }
1998
- }
1999
- extractIngestionEndpoint() {
2000
- const match = this.connectionString.match(/IngestionEndpoint=([^;]+)/);
2001
- return match ? match[1] : '';
2002
- }
2003
- }
2004
- /**
2005
- * Singleton telemetry client
2006
- */
2007
- class TelemetryClient {
2008
- constructor() {
2009
- this.isInitialized = false;
2010
- }
2011
- static getInstance() {
2012
- if (!TelemetryClient.instance) {
2013
- TelemetryClient.instance = new TelemetryClient();
2014
- }
2015
- return TelemetryClient.instance;
2016
- }
2017
- /**
2018
- * Initialize telemetry
2019
- */
2020
- initialize(config) {
2021
- if (this.isInitialized) {
2022
- return;
2023
- }
2024
- this.isInitialized = true;
2025
- if (config) {
2026
- this.telemetryContext = config;
2027
- }
2028
- try {
2029
- const connectionString = this.getConnectionString();
2030
- if (!connectionString) {
2031
- return;
2032
- }
2033
- this.setupTelemetryProvider(connectionString);
2034
- }
2035
- catch (error) {
2036
- // Silent failure - telemetry errors shouldn't break functionality
2037
- console.debug('Failed to initialize OpenTelemetry:', error);
2038
- }
2039
- }
2040
- getConnectionString() {
2041
- const connectionString = CONNECTION_STRING;
2042
- return connectionString;
2043
- }
2044
- setupTelemetryProvider(connectionString) {
2045
- const exporter = new ApplicationInsightsEventExporter(connectionString);
2046
- const processor = new BatchLogRecordProcessor(exporter);
2047
- this.logProvider = new LoggerProvider({
2048
- processors: [processor]
2049
- });
2050
- this.logger = this.logProvider.getLogger(SDK_LOGGER_NAME);
2051
- }
2052
- /**
2053
- * Track a telemetry event
2054
- */
2055
- track(eventName, name, extraAttributes = {}) {
2056
- try {
2057
- // Skip if logger not initialized
2058
- if (!this.logger) {
2059
- return;
2060
- }
2061
- const finalDisplayName = name || eventName;
2062
- const attributes = this.getEnrichedAttributes(extraAttributes, eventName);
2063
- // Emit as log
2064
- this.logger.emit({
2065
- body: finalDisplayName,
2066
- attributes: attributes,
2067
- timestamp: Date.now(),
2068
- });
2069
- }
2070
- catch (error) {
2071
- // Silent failure
2072
- console.debug('Failed to track telemetry event:', error);
2073
- }
2074
- }
2075
- /**
2076
- * Get enriched attributes for telemetry events
2077
- */
2078
- getEnrichedAttributes(extraAttributes, eventName) {
2079
- const attributes = {
2080
- [APP_NAME]: SDK_SERVICE_NAME,
2081
- [VERSION]: SDK_VERSION,
2082
- [SERVICE]: eventName,
2083
- [CLOUD_URL]: this.createCloudUrl(),
2084
- [CLOUD_ORGANIZATION_NAME]: this.telemetryContext?.orgName || UNKNOWN,
2085
- [CLOUD_TENANT_NAME]: this.telemetryContext?.tenantName || UNKNOWN,
2086
- [CLOUD_REDIRECT_URI]: this.telemetryContext?.redirectUri || UNKNOWN,
2087
- [CLOUD_CLIENT_ID]: this.telemetryContext?.clientId || UNKNOWN,
2088
- ...extraAttributes,
2089
- };
2090
- return attributes;
2091
- }
2092
- /**
2093
- * Create cloud URL from base URL, organization ID, and tenant ID
2094
- */
2095
- createCloudUrl() {
2096
- const baseUrl = this.telemetryContext?.baseUrl;
2097
- const orgId = this.telemetryContext?.orgName;
2098
- const tenantId = this.telemetryContext?.tenantName;
2099
- if (!baseUrl || !orgId || !tenantId) {
2100
- return UNKNOWN;
2101
- }
2102
- return `${baseUrl}/${orgId}/${tenantId}`;
2103
- }
2104
- }
2105
- // Export singleton instance
2106
- const telemetryClient = TelemetryClient.getInstance();
1933
+ * SDK Telemetry constants.
1934
+ *
1935
+ * Only the SDK's identity (version, service name, role name, …) lives
1936
+ * here. The Application Insights connection string is injected into
1937
+ * `@uipath/core-telemetry` itself at publish time, and the generic attribute
1938
+ * keys (`Version`, `Service`, `CloudOrganizationName`, …) are owned by
1939
+ * `@uipath/core-telemetry` and consumed there — they are not part of the
1940
+ * SDK's public API.
1941
+ */
1942
+ /** SDK version placeholder — patched by the SDK publish workflow. */
1943
+ const CLOUD_ROLE_NAME = 'uipath-ts-sdk';
2107
1944
 
2108
1945
  /**
2109
- * SDK Track decorator and function for telemetry
2110
- */
2111
- /**
2112
- * Common tracking logic shared between method and function decorators
2113
- */
2114
- function createTrackedFunction(originalFunction, nameOrOptions, fallbackName, opts) {
2115
- return function (...args) {
2116
- // Determine if we should track this call
2117
- let shouldTrack = true;
2118
- if (opts.condition !== undefined) {
2119
- if (typeof opts.condition === 'function') {
2120
- shouldTrack = opts.condition.apply(this, args);
2121
- }
2122
- else {
2123
- shouldTrack = opts.condition;
2124
- }
2125
- }
2126
- // Track the event if enabled
2127
- if (shouldTrack) {
2128
- // Use the full name provided in the decorator (e.g., "Queue.GetAll")
2129
- const serviceMethod = typeof nameOrOptions === 'string'
2130
- ? nameOrOptions
2131
- : fallbackName;
2132
- // Use 'Sdk.Run' as the name and serviceMethod as the service
2133
- telemetryClient.track(serviceMethod, SDK_RUN_EVENT, opts.attributes);
2134
- }
2135
- // Execute the original function
2136
- return originalFunction.apply(this, args);
2137
- };
2138
- }
2139
- /**
2140
- * Track decorator that can be used to automatically track function calls
1946
+ * UiPath TypeScript SDK Telemetry
2141
1947
  *
2142
- * Usage:
2143
- * @track("Service.Method")
2144
- * function myFunction() { ... }
2145
- *
2146
- * @track("Queue.GetAll")
2147
- * async getAll() { ... }
2148
- *
2149
- * @track("Tasks.Create")
2150
- * async create() { ... }
2151
- *
2152
- * @track("Assets.Update", { condition: false })
2153
- * function myFunction() { ... }
2154
- *
2155
- * @track("Processes.Start", { attributes: { customProp: "value" } })
2156
- * function myFunction() { ... }
2157
- */
2158
- function track(nameOrOptions, options) {
2159
- return function decorator(_target, propertyKey, descriptor) {
2160
- const opts = typeof nameOrOptions === 'object' ? nameOrOptions : {};
2161
- if (descriptor && typeof descriptor.value === 'function') {
2162
- // Method decorator
2163
- descriptor.value = createTrackedFunction(descriptor.value, nameOrOptions, propertyKey || 'unknown_method', opts);
2164
- return descriptor;
2165
- }
2166
- // Function decorator
2167
- return (originalFunction) => createTrackedFunction(originalFunction, nameOrOptions, originalFunction.name || 'unknown_function', opts);
2168
- };
2169
- }
1948
+ * Constructs the SDK's own `TelemetryClient` and binds the SDK-local
1949
+ * `track` / `trackEvent` to it. Each consumer of `@uipath/core-telemetry`
1950
+ * does this independently, so events carry their own consumer's identity
1951
+ * and tenant context.
1952
+ */
1953
+ // Keyed by `CLOUD_ROLE_NAME` so every SDK subpath bundle resolves to the
1954
+ // same `TelemetryClient` instance at runtime. A single `initialize(...)`
1955
+ // from the `UiPath` constructor therefore wires up `@track` decorators
1956
+ // across every subpath bundle (`assets`, `feedback`, `tasks`, …).
1957
+ const sdkClient = getOrCreateClient(CLOUD_ROLE_NAME);
1958
+ const track = createTrack(sdkClient);
1959
+ createTrackEvent(sdkClient);
2170
1960
 
2171
1961
  class BucketService extends FolderScopedService {
2172
1962
  /**
@@ -2204,6 +1994,32 @@ class BucketService extends FolderScopedService {
2204
1994
  // Transform response from PascalCase to camelCase
2205
1995
  return pascalToCamelCaseKeys(response.data);
2206
1996
  }
1997
+ /**
1998
+ * Retrieves a single orchestrator storage bucket by name.
1999
+ *
2000
+ * @param name - Bucket name to search for
2001
+ * @param options - Folder scoping (`folderId` / `folderKey` / `folderPath`) and optional query parameters (`expand`, `select`)
2002
+ * @returns Promise resolving to a single bucket
2003
+ * {@link BucketGetResponse}
2004
+ * @example
2005
+ * ```typescript
2006
+ * import { Buckets } from '@uipath/uipath-typescript/buckets';
2007
+ *
2008
+ * const buckets = new Buckets(sdk);
2009
+ *
2010
+ * // By folder ID
2011
+ * await buckets.getByName('MyBucket', { folderId: <folderId> });
2012
+ *
2013
+ * // By folder key (GUID)
2014
+ * await buckets.getByName('MyBucket', { folderKey: '<folderKey>' });
2015
+ *
2016
+ * // By folder path
2017
+ * await buckets.getByName('MyBucket', { folderPath: '<folderPath>' });
2018
+ * ```
2019
+ */
2020
+ async getByName(name, options = {}) {
2021
+ return this.getByNameLookup('Bucket', BUCKET_ENDPOINTS.GET_BY_FOLDER, name, options, (raw) => pascalToCamelCaseKeys(raw));
2022
+ }
2207
2023
  /**
2208
2024
  * Gets all buckets across folders with optional filtering and folder scoping
2209
2025
  *
@@ -2493,6 +2309,9 @@ class BucketService extends FolderScopedService {
2493
2309
  __decorate([
2494
2310
  track('Buckets.GetById')
2495
2311
  ], BucketService.prototype, "getById", null);
2312
+ __decorate([
2313
+ track('Buckets.GetByName')
2314
+ ], BucketService.prototype, "getByName", null);
2496
2315
  __decorate([
2497
2316
  track('Buckets.GetAll')
2498
2317
  ], BucketService.prototype, "getAll", null);