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