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