@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,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.
@@ -653,6 +653,27 @@ var PaginationType;
653
653
  /**
654
654
  * Collection of utility functions for working with objects
655
655
  */
656
+ /**
657
+ * Resolves a field value from an object, supporting both direct keys (e.g., '@odata.count')
658
+ * and dot-separated nested paths (e.g., 'pagination.totalCount').
659
+ * Direct key match takes priority over nested traversal.
660
+ */
661
+ function resolveNestedField(data, fieldPath) {
662
+ if (!data) {
663
+ return undefined;
664
+ }
665
+ if (fieldPath in data) {
666
+ return data[fieldPath];
667
+ }
668
+ if (!fieldPath.includes('.')) {
669
+ return undefined;
670
+ }
671
+ let value = data;
672
+ for (const part of fieldPath.split('.')) {
673
+ value = value?.[part];
674
+ }
675
+ return value;
676
+ }
656
677
  /**
657
678
  * Filters out undefined values from an object
658
679
  * @param obj The source object
@@ -893,6 +914,10 @@ const BUCKET_TOKEN_PARAMS = {
893
914
  TOKEN_PARAM: 'continuationToken'
894
915
  };
895
916
 
917
+ /**
918
+ * Converts a UTC timestamp string (e.g., "5/8/2026 11:20:17 AM") to ISO 8601 UTC format.
919
+ * Returns the original value if parsing fails.
920
+ */
896
921
  /**
897
922
  * Transforms data by mapping fields according to the provided field mapping
898
923
  * @param data The source data to transform
@@ -1310,7 +1335,8 @@ class PaginationHelpers {
1310
1335
  // Extract and transform items from response
1311
1336
  // Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N })
1312
1337
  const rawItems = Array.isArray(response.data) ? response.data : response.data?.[itemsField];
1313
- const totalCount = Array.isArray(response.data) ? undefined : response.data?.[totalCountField];
1338
+ const rawTotalCount = Array.isArray(response.data) ? undefined : resolveNestedField(response.data, totalCountField);
1339
+ const totalCount = typeof rawTotalCount === 'number' ? rawTotalCount : undefined;
1314
1340
  // Parse items - automatically handle JSON string responses
1315
1341
  const parsedItems = typeof rawItems === 'string' ? JSON.parse(rawItems) : (rawItems || []);
1316
1342
  const items = transformFn ? parsedItems.map(transformFn) : parsedItems;
@@ -1607,9 +1633,17 @@ class BaseService {
1607
1633
  const pageSizeParam = paginationParams?.pageSizeParam || ODATA_OFFSET_PARAMS.PAGE_SIZE_PARAM;
1608
1634
  const offsetParam = paginationParams?.offsetParam || ODATA_OFFSET_PARAMS.OFFSET_PARAM;
1609
1635
  const countParam = paginationParams?.countParam || ODATA_OFFSET_PARAMS.COUNT_PARAM;
1636
+ // When true (default), converts pageNumber to a skip/offset value (e.g., page 3 with pageSize 10 → skip 20).
1637
+ // When false, passes pageNumber directly as the offset param — used by APIs that accept a page number instead of a record offset.
1638
+ const convertToSkip = paginationParams?.convertToSkip ?? true;
1610
1639
  requestParams[pageSizeParam] = limitedPageSize;
1611
- if (params.pageNumber && params.pageNumber > 1) {
1612
- requestParams[offsetParam] = (params.pageNumber - 1) * limitedPageSize;
1640
+ if (convertToSkip) {
1641
+ if (params.pageNumber && params.pageNumber > 1) {
1642
+ requestParams[offsetParam] = (params.pageNumber - 1) * limitedPageSize;
1643
+ }
1644
+ }
1645
+ else {
1646
+ requestParams[offsetParam] = params.pageNumber || 1;
1613
1647
  }
1614
1648
  {
1615
1649
  requestParams[countParam] = true;
@@ -1640,7 +1674,8 @@ class BaseService {
1640
1674
  // Extract items and metadata
1641
1675
  // Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N })
1642
1676
  const items = Array.isArray(response.data) ? response.data : (response.data[itemsField] || []);
1643
- const totalCount = Array.isArray(response.data) ? undefined : response.data[totalCountField];
1677
+ const rawTotalCount = Array.isArray(response.data) ? undefined : resolveNestedField(response.data, totalCountField);
1678
+ const totalCount = typeof rawTotalCount === 'number' ? rawTotalCount : undefined;
1644
1679
  const continuationToken = response.data[continuationTokenField];
1645
1680
  // Determine if there are more pages
1646
1681
  const hasMore = this.determineHasMorePages(paginationType, {
@@ -1922,278 +1957,33 @@ const PROCESS_ENDPOINTS = {
1922
1957
  };
1923
1958
 
1924
1959
  /**
1925
- * SDK Telemetry constants
1926
- */
1927
- // Connection string placeholder that will be replaced during build
1928
- 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";
1929
- // SDK Version placeholder
1930
- const SDK_VERSION = "1.3.7";
1931
- const VERSION = "Version";
1932
- const SERVICE = "Service";
1933
- const CLOUD_ORGANIZATION_NAME = "CloudOrganizationName";
1934
- const CLOUD_TENANT_NAME = "CloudTenantName";
1935
- const CLOUD_URL = "CloudUrl";
1936
- const CLOUD_CLIENT_ID = "CloudClientId";
1937
- const CLOUD_REDIRECT_URI = "CloudRedirectUri";
1938
- const APP_NAME = "ApplicationName";
1939
- const CLOUD_ROLE_NAME = "uipath-ts-sdk";
1940
- // Service and logger names
1941
- const SDK_SERVICE_NAME = "UiPath.TypeScript.Sdk";
1942
- const SDK_LOGGER_NAME = "uipath-ts-sdk-telemetry";
1943
- // Event names
1944
- const SDK_RUN_EVENT = "Sdk.Run";
1945
- // Default value for unknown/empty attributes
1946
- const UNKNOWN = "";
1947
-
1948
- /**
1949
- * Log exporter that sends ALL logs as Application Insights custom events
1950
- */
1951
- class ApplicationInsightsEventExporter {
1952
- constructor(connectionString) {
1953
- this.connectionString = connectionString;
1954
- }
1955
- export(logs, resultCallback) {
1956
- try {
1957
- logs.forEach(logRecord => {
1958
- this.sendAsCustomEvent(logRecord);
1959
- });
1960
- resultCallback({ code: 0 });
1961
- }
1962
- catch (error) {
1963
- console.debug('Failed to export logs to Application Insights:', error);
1964
- resultCallback({ code: 2, error });
1965
- }
1966
- }
1967
- shutdown() {
1968
- return Promise.resolve();
1969
- }
1970
- sendAsCustomEvent(logRecord) {
1971
- // Get event name from body or attributes
1972
- const eventName = logRecord.body || SDK_RUN_EVENT;
1973
- const payload = {
1974
- name: 'Microsoft.ApplicationInsights.Event',
1975
- time: new Date().toISOString(),
1976
- iKey: this.extractInstrumentationKey(),
1977
- data: {
1978
- baseType: 'EventData',
1979
- baseData: {
1980
- ver: 2,
1981
- name: eventName,
1982
- properties: this.convertAttributesToProperties(logRecord.attributes || {})
1983
- }
1984
- },
1985
- tags: {
1986
- 'ai.cloud.role': CLOUD_ROLE_NAME,
1987
- 'ai.cloud.roleInstance': SDK_VERSION
1988
- }
1989
- };
1990
- this.sendToApplicationInsights(payload);
1991
- }
1992
- extractInstrumentationKey() {
1993
- const match = this.connectionString.match(/InstrumentationKey=([^;]+)/);
1994
- return match ? match[1] : '';
1995
- }
1996
- convertAttributesToProperties(attributes) {
1997
- const properties = {};
1998
- Object.entries(attributes || {}).forEach(([key, value]) => {
1999
- properties[key] = String(value);
2000
- });
2001
- return properties;
2002
- }
2003
- async sendToApplicationInsights(payload) {
2004
- try {
2005
- const ingestionEndpoint = this.extractIngestionEndpoint();
2006
- if (!ingestionEndpoint) {
2007
- console.debug('No ingestion endpoint found in connection string');
2008
- return;
2009
- }
2010
- const url = `${ingestionEndpoint}/v2/track`;
2011
- const response = await fetch(url, {
2012
- method: 'POST',
2013
- headers: {
2014
- 'Content-Type': 'application/json',
2015
- },
2016
- body: JSON.stringify(payload)
2017
- });
2018
- if (!response.ok) {
2019
- console.debug(`Failed to send event telemetry: ${response.status} ${response.statusText}`);
2020
- }
2021
- }
2022
- catch (error) {
2023
- console.debug('Error sending event telemetry to Application Insights:', error);
2024
- }
2025
- }
2026
- extractIngestionEndpoint() {
2027
- const match = this.connectionString.match(/IngestionEndpoint=([^;]+)/);
2028
- return match ? match[1] : '';
2029
- }
2030
- }
2031
- /**
2032
- * Singleton telemetry client
2033
- */
2034
- class TelemetryClient {
2035
- constructor() {
2036
- this.isInitialized = false;
2037
- }
2038
- static getInstance() {
2039
- if (!TelemetryClient.instance) {
2040
- TelemetryClient.instance = new TelemetryClient();
2041
- }
2042
- return TelemetryClient.instance;
2043
- }
2044
- /**
2045
- * Initialize telemetry
2046
- */
2047
- initialize(config) {
2048
- if (this.isInitialized) {
2049
- return;
2050
- }
2051
- this.isInitialized = true;
2052
- if (config) {
2053
- this.telemetryContext = config;
2054
- }
2055
- try {
2056
- const connectionString = this.getConnectionString();
2057
- if (!connectionString) {
2058
- return;
2059
- }
2060
- this.setupTelemetryProvider(connectionString);
2061
- }
2062
- catch (error) {
2063
- // Silent failure - telemetry errors shouldn't break functionality
2064
- console.debug('Failed to initialize OpenTelemetry:', error);
2065
- }
2066
- }
2067
- getConnectionString() {
2068
- const connectionString = CONNECTION_STRING;
2069
- return connectionString;
2070
- }
2071
- setupTelemetryProvider(connectionString) {
2072
- const exporter = new ApplicationInsightsEventExporter(connectionString);
2073
- const processor = new sdkLogs.BatchLogRecordProcessor(exporter);
2074
- this.logProvider = new sdkLogs.LoggerProvider({
2075
- processors: [processor]
2076
- });
2077
- this.logger = this.logProvider.getLogger(SDK_LOGGER_NAME);
2078
- }
2079
- /**
2080
- * Track a telemetry event
2081
- */
2082
- track(eventName, name, extraAttributes = {}) {
2083
- try {
2084
- // Skip if logger not initialized
2085
- if (!this.logger) {
2086
- return;
2087
- }
2088
- const finalDisplayName = name || eventName;
2089
- const attributes = this.getEnrichedAttributes(extraAttributes, eventName);
2090
- // Emit as log
2091
- this.logger.emit({
2092
- body: finalDisplayName,
2093
- attributes: attributes,
2094
- timestamp: Date.now(),
2095
- });
2096
- }
2097
- catch (error) {
2098
- // Silent failure
2099
- console.debug('Failed to track telemetry event:', error);
2100
- }
2101
- }
2102
- /**
2103
- * Get enriched attributes for telemetry events
2104
- */
2105
- getEnrichedAttributes(extraAttributes, eventName) {
2106
- const attributes = {
2107
- [APP_NAME]: SDK_SERVICE_NAME,
2108
- [VERSION]: SDK_VERSION,
2109
- [SERVICE]: eventName,
2110
- [CLOUD_URL]: this.createCloudUrl(),
2111
- [CLOUD_ORGANIZATION_NAME]: this.telemetryContext?.orgName || UNKNOWN,
2112
- [CLOUD_TENANT_NAME]: this.telemetryContext?.tenantName || UNKNOWN,
2113
- [CLOUD_REDIRECT_URI]: this.telemetryContext?.redirectUri || UNKNOWN,
2114
- [CLOUD_CLIENT_ID]: this.telemetryContext?.clientId || UNKNOWN,
2115
- ...extraAttributes,
2116
- };
2117
- return attributes;
2118
- }
2119
- /**
2120
- * Create cloud URL from base URL, organization ID, and tenant ID
2121
- */
2122
- createCloudUrl() {
2123
- const baseUrl = this.telemetryContext?.baseUrl;
2124
- const orgId = this.telemetryContext?.orgName;
2125
- const tenantId = this.telemetryContext?.tenantName;
2126
- if (!baseUrl || !orgId || !tenantId) {
2127
- return UNKNOWN;
2128
- }
2129
- return `${baseUrl}/${orgId}/${tenantId}`;
2130
- }
2131
- }
2132
- // Export singleton instance
2133
- const telemetryClient = TelemetryClient.getInstance();
1960
+ * SDK Telemetry constants.
1961
+ *
1962
+ * Only the SDK's identity (version, service name, role name, …) lives
1963
+ * here. The Application Insights connection string is injected into
1964
+ * `@uipath/core-telemetry` itself at publish time, and the generic attribute
1965
+ * keys (`Version`, `Service`, `CloudOrganizationName`, …) are owned by
1966
+ * `@uipath/core-telemetry` and consumed there — they are not part of the
1967
+ * SDK's public API.
1968
+ */
1969
+ /** SDK version placeholder — patched by the SDK publish workflow. */
1970
+ const CLOUD_ROLE_NAME = 'uipath-ts-sdk';
2134
1971
 
2135
1972
  /**
2136
- * SDK Track decorator and function for telemetry
2137
- */
2138
- /**
2139
- * Common tracking logic shared between method and function decorators
2140
- */
2141
- function createTrackedFunction(originalFunction, nameOrOptions, fallbackName, opts) {
2142
- return function (...args) {
2143
- // Determine if we should track this call
2144
- let shouldTrack = true;
2145
- if (opts.condition !== undefined) {
2146
- if (typeof opts.condition === 'function') {
2147
- shouldTrack = opts.condition.apply(this, args);
2148
- }
2149
- else {
2150
- shouldTrack = opts.condition;
2151
- }
2152
- }
2153
- // Track the event if enabled
2154
- if (shouldTrack) {
2155
- // Use the full name provided in the decorator (e.g., "Queue.GetAll")
2156
- const serviceMethod = typeof nameOrOptions === 'string'
2157
- ? nameOrOptions
2158
- : fallbackName;
2159
- // Use 'Sdk.Run' as the name and serviceMethod as the service
2160
- telemetryClient.track(serviceMethod, SDK_RUN_EVENT, opts.attributes);
2161
- }
2162
- // Execute the original function
2163
- return originalFunction.apply(this, args);
2164
- };
2165
- }
2166
- /**
2167
- * Track decorator that can be used to automatically track function calls
1973
+ * UiPath TypeScript SDK Telemetry
2168
1974
  *
2169
- * Usage:
2170
- * @track("Service.Method")
2171
- * function myFunction() { ... }
2172
- *
2173
- * @track("Queue.GetAll")
2174
- * async getAll() { ... }
2175
- *
2176
- * @track("Tasks.Create")
2177
- * async create() { ... }
2178
- *
2179
- * @track("Assets.Update", { condition: false })
2180
- * function myFunction() { ... }
2181
- *
2182
- * @track("Processes.Start", { attributes: { customProp: "value" } })
2183
- * function myFunction() { ... }
2184
- */
2185
- function track(nameOrOptions, options) {
2186
- return function decorator(_target, propertyKey, descriptor) {
2187
- const opts = typeof nameOrOptions === 'object' ? nameOrOptions : {};
2188
- if (descriptor && typeof descriptor.value === 'function') {
2189
- // Method decorator
2190
- descriptor.value = createTrackedFunction(descriptor.value, nameOrOptions, propertyKey || 'unknown_method', opts);
2191
- return descriptor;
2192
- }
2193
- // Function decorator
2194
- return (originalFunction) => createTrackedFunction(originalFunction, nameOrOptions, originalFunction.name || 'unknown_function', opts);
2195
- };
2196
- }
1975
+ * Constructs the SDK's own `TelemetryClient` and binds the SDK-local
1976
+ * `track` / `trackEvent` to it. Each consumer of `@uipath/core-telemetry`
1977
+ * does this independently, so events carry their own consumer's identity
1978
+ * and tenant context.
1979
+ */
1980
+ // Keyed by `CLOUD_ROLE_NAME` so every SDK subpath bundle resolves to the
1981
+ // same `TelemetryClient` instance at runtime. A single `initialize(...)`
1982
+ // from the `UiPath` constructor therefore wires up `@track` decorators
1983
+ // across every subpath bundle (`assets`, `feedback`, `tasks`, …).
1984
+ const sdkClient = coreTelemetry.getOrCreateClient(CLOUD_ROLE_NAME);
1985
+ const track = coreTelemetry.createTrack(sdkClient);
1986
+ coreTelemetry.createTrackEvent(sdkClient);
2197
1987
 
2198
1988
  /**
2199
1989
  * Service for interacting with UiPath Orchestrator Processes API
@@ -106,6 +106,7 @@ interface RequestWithPaginationOptions extends RequestSpec {
106
106
  offsetParam?: string;
107
107
  tokenParam?: string;
108
108
  countParam?: string;
109
+ convertToSkip?: boolean;
109
110
  };
110
111
  };
111
112
  }