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