@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, {
@@ -1851,278 +1886,33 @@ const QueueMap = {
1851
1886
  };
1852
1887
 
1853
1888
  /**
1854
- * SDK Telemetry constants
1855
- */
1856
- // Connection string placeholder that will be replaced during build
1857
- 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";
1858
- // SDK Version placeholder
1859
- const SDK_VERSION = "1.3.7";
1860
- const VERSION = "Version";
1861
- const SERVICE = "Service";
1862
- const CLOUD_ORGANIZATION_NAME = "CloudOrganizationName";
1863
- const CLOUD_TENANT_NAME = "CloudTenantName";
1864
- const CLOUD_URL = "CloudUrl";
1865
- const CLOUD_CLIENT_ID = "CloudClientId";
1866
- const CLOUD_REDIRECT_URI = "CloudRedirectUri";
1867
- const APP_NAME = "ApplicationName";
1868
- const CLOUD_ROLE_NAME = "uipath-ts-sdk";
1869
- // Service and logger names
1870
- const SDK_SERVICE_NAME = "UiPath.TypeScript.Sdk";
1871
- const SDK_LOGGER_NAME = "uipath-ts-sdk-telemetry";
1872
- // Event names
1873
- const SDK_RUN_EVENT = "Sdk.Run";
1874
- // Default value for unknown/empty attributes
1875
- const UNKNOWN = "";
1876
-
1877
- /**
1878
- * Log exporter that sends ALL logs as Application Insights custom events
1879
- */
1880
- class ApplicationInsightsEventExporter {
1881
- constructor(connectionString) {
1882
- this.connectionString = connectionString;
1883
- }
1884
- export(logs, resultCallback) {
1885
- try {
1886
- logs.forEach(logRecord => {
1887
- this.sendAsCustomEvent(logRecord);
1888
- });
1889
- resultCallback({ code: 0 });
1890
- }
1891
- catch (error) {
1892
- console.debug('Failed to export logs to Application Insights:', error);
1893
- resultCallback({ code: 2, error });
1894
- }
1895
- }
1896
- shutdown() {
1897
- return Promise.resolve();
1898
- }
1899
- sendAsCustomEvent(logRecord) {
1900
- // Get event name from body or attributes
1901
- const eventName = logRecord.body || SDK_RUN_EVENT;
1902
- const payload = {
1903
- name: 'Microsoft.ApplicationInsights.Event',
1904
- time: new Date().toISOString(),
1905
- iKey: this.extractInstrumentationKey(),
1906
- data: {
1907
- baseType: 'EventData',
1908
- baseData: {
1909
- ver: 2,
1910
- name: eventName,
1911
- properties: this.convertAttributesToProperties(logRecord.attributes || {})
1912
- }
1913
- },
1914
- tags: {
1915
- 'ai.cloud.role': CLOUD_ROLE_NAME,
1916
- 'ai.cloud.roleInstance': SDK_VERSION
1917
- }
1918
- };
1919
- this.sendToApplicationInsights(payload);
1920
- }
1921
- extractInstrumentationKey() {
1922
- const match = this.connectionString.match(/InstrumentationKey=([^;]+)/);
1923
- return match ? match[1] : '';
1924
- }
1925
- convertAttributesToProperties(attributes) {
1926
- const properties = {};
1927
- Object.entries(attributes || {}).forEach(([key, value]) => {
1928
- properties[key] = String(value);
1929
- });
1930
- return properties;
1931
- }
1932
- async sendToApplicationInsights(payload) {
1933
- try {
1934
- const ingestionEndpoint = this.extractIngestionEndpoint();
1935
- if (!ingestionEndpoint) {
1936
- console.debug('No ingestion endpoint found in connection string');
1937
- return;
1938
- }
1939
- const url = `${ingestionEndpoint}/v2/track`;
1940
- const response = await fetch(url, {
1941
- method: 'POST',
1942
- headers: {
1943
- 'Content-Type': 'application/json',
1944
- },
1945
- body: JSON.stringify(payload)
1946
- });
1947
- if (!response.ok) {
1948
- console.debug(`Failed to send event telemetry: ${response.status} ${response.statusText}`);
1949
- }
1950
- }
1951
- catch (error) {
1952
- console.debug('Error sending event telemetry to Application Insights:', error);
1953
- }
1954
- }
1955
- extractIngestionEndpoint() {
1956
- const match = this.connectionString.match(/IngestionEndpoint=([^;]+)/);
1957
- return match ? match[1] : '';
1958
- }
1959
- }
1960
- /**
1961
- * Singleton telemetry client
1962
- */
1963
- class TelemetryClient {
1964
- constructor() {
1965
- this.isInitialized = false;
1966
- }
1967
- static getInstance() {
1968
- if (!TelemetryClient.instance) {
1969
- TelemetryClient.instance = new TelemetryClient();
1970
- }
1971
- return TelemetryClient.instance;
1972
- }
1973
- /**
1974
- * Initialize telemetry
1975
- */
1976
- initialize(config) {
1977
- if (this.isInitialized) {
1978
- return;
1979
- }
1980
- this.isInitialized = true;
1981
- if (config) {
1982
- this.telemetryContext = config;
1983
- }
1984
- try {
1985
- const connectionString = this.getConnectionString();
1986
- if (!connectionString) {
1987
- return;
1988
- }
1989
- this.setupTelemetryProvider(connectionString);
1990
- }
1991
- catch (error) {
1992
- // Silent failure - telemetry errors shouldn't break functionality
1993
- console.debug('Failed to initialize OpenTelemetry:', error);
1994
- }
1995
- }
1996
- getConnectionString() {
1997
- const connectionString = CONNECTION_STRING;
1998
- return connectionString;
1999
- }
2000
- setupTelemetryProvider(connectionString) {
2001
- const exporter = new ApplicationInsightsEventExporter(connectionString);
2002
- const processor = new sdkLogs.BatchLogRecordProcessor(exporter);
2003
- this.logProvider = new sdkLogs.LoggerProvider({
2004
- processors: [processor]
2005
- });
2006
- this.logger = this.logProvider.getLogger(SDK_LOGGER_NAME);
2007
- }
2008
- /**
2009
- * Track a telemetry event
2010
- */
2011
- track(eventName, name, extraAttributes = {}) {
2012
- try {
2013
- // Skip if logger not initialized
2014
- if (!this.logger) {
2015
- return;
2016
- }
2017
- const finalDisplayName = name || eventName;
2018
- const attributes = this.getEnrichedAttributes(extraAttributes, eventName);
2019
- // Emit as log
2020
- this.logger.emit({
2021
- body: finalDisplayName,
2022
- attributes: attributes,
2023
- timestamp: Date.now(),
2024
- });
2025
- }
2026
- catch (error) {
2027
- // Silent failure
2028
- console.debug('Failed to track telemetry event:', error);
2029
- }
2030
- }
2031
- /**
2032
- * Get enriched attributes for telemetry events
2033
- */
2034
- getEnrichedAttributes(extraAttributes, eventName) {
2035
- const attributes = {
2036
- [APP_NAME]: SDK_SERVICE_NAME,
2037
- [VERSION]: SDK_VERSION,
2038
- [SERVICE]: eventName,
2039
- [CLOUD_URL]: this.createCloudUrl(),
2040
- [CLOUD_ORGANIZATION_NAME]: this.telemetryContext?.orgName || UNKNOWN,
2041
- [CLOUD_TENANT_NAME]: this.telemetryContext?.tenantName || UNKNOWN,
2042
- [CLOUD_REDIRECT_URI]: this.telemetryContext?.redirectUri || UNKNOWN,
2043
- [CLOUD_CLIENT_ID]: this.telemetryContext?.clientId || UNKNOWN,
2044
- ...extraAttributes,
2045
- };
2046
- return attributes;
2047
- }
2048
- /**
2049
- * Create cloud URL from base URL, organization ID, and tenant ID
2050
- */
2051
- createCloudUrl() {
2052
- const baseUrl = this.telemetryContext?.baseUrl;
2053
- const orgId = this.telemetryContext?.orgName;
2054
- const tenantId = this.telemetryContext?.tenantName;
2055
- if (!baseUrl || !orgId || !tenantId) {
2056
- return UNKNOWN;
2057
- }
2058
- return `${baseUrl}/${orgId}/${tenantId}`;
2059
- }
2060
- }
2061
- // Export singleton instance
2062
- const telemetryClient = TelemetryClient.getInstance();
1889
+ * SDK Telemetry constants.
1890
+ *
1891
+ * Only the SDK's identity (version, service name, role name, …) lives
1892
+ * here. The Application Insights connection string is injected into
1893
+ * `@uipath/core-telemetry` itself at publish time, and the generic attribute
1894
+ * keys (`Version`, `Service`, `CloudOrganizationName`, …) are owned by
1895
+ * `@uipath/core-telemetry` and consumed there — they are not part of the
1896
+ * SDK's public API.
1897
+ */
1898
+ /** SDK version placeholder — patched by the SDK publish workflow. */
1899
+ const CLOUD_ROLE_NAME = 'uipath-ts-sdk';
2063
1900
 
2064
1901
  /**
2065
- * SDK Track decorator and function for telemetry
2066
- */
2067
- /**
2068
- * Common tracking logic shared between method and function decorators
2069
- */
2070
- function createTrackedFunction(originalFunction, nameOrOptions, fallbackName, opts) {
2071
- return function (...args) {
2072
- // Determine if we should track this call
2073
- let shouldTrack = true;
2074
- if (opts.condition !== undefined) {
2075
- if (typeof opts.condition === 'function') {
2076
- shouldTrack = opts.condition.apply(this, args);
2077
- }
2078
- else {
2079
- shouldTrack = opts.condition;
2080
- }
2081
- }
2082
- // Track the event if enabled
2083
- if (shouldTrack) {
2084
- // Use the full name provided in the decorator (e.g., "Queue.GetAll")
2085
- const serviceMethod = typeof nameOrOptions === 'string'
2086
- ? nameOrOptions
2087
- : fallbackName;
2088
- // Use 'Sdk.Run' as the name and serviceMethod as the service
2089
- telemetryClient.track(serviceMethod, SDK_RUN_EVENT, opts.attributes);
2090
- }
2091
- // Execute the original function
2092
- return originalFunction.apply(this, args);
2093
- };
2094
- }
2095
- /**
2096
- * Track decorator that can be used to automatically track function calls
2097
- *
2098
- * Usage:
2099
- * @track("Service.Method")
2100
- * function myFunction() { ... }
1902
+ * UiPath TypeScript SDK Telemetry
2101
1903
  *
2102
- * @track("Queue.GetAll")
2103
- * async getAll() { ... }
2104
- *
2105
- * @track("Tasks.Create")
2106
- * async create() { ... }
2107
- *
2108
- * @track("Assets.Update", { condition: false })
2109
- * function myFunction() { ... }
2110
- *
2111
- * @track("Processes.Start", { attributes: { customProp: "value" } })
2112
- * function myFunction() { ... }
2113
- */
2114
- function track(nameOrOptions, options) {
2115
- return function decorator(_target, propertyKey, descriptor) {
2116
- const opts = typeof nameOrOptions === 'object' ? nameOrOptions : {};
2117
- if (descriptor && typeof descriptor.value === 'function') {
2118
- // Method decorator
2119
- descriptor.value = createTrackedFunction(descriptor.value, nameOrOptions, propertyKey || 'unknown_method', opts);
2120
- return descriptor;
2121
- }
2122
- // Function decorator
2123
- return (originalFunction) => createTrackedFunction(originalFunction, nameOrOptions, originalFunction.name || 'unknown_function', opts);
2124
- };
2125
- }
1904
+ * Constructs the SDK's own `TelemetryClient` and binds the SDK-local
1905
+ * `track` / `trackEvent` to it. Each consumer of `@uipath/core-telemetry`
1906
+ * does this independently, so events carry their own consumer's identity
1907
+ * and tenant context.
1908
+ */
1909
+ // Keyed by `CLOUD_ROLE_NAME` so every SDK subpath bundle resolves to the
1910
+ // same `TelemetryClient` instance at runtime. A single `initialize(...)`
1911
+ // from the `UiPath` constructor therefore wires up `@track` decorators
1912
+ // across every subpath bundle (`assets`, `feedback`, `tasks`, …).
1913
+ const sdkClient = coreTelemetry.getOrCreateClient(CLOUD_ROLE_NAME);
1914
+ const track = coreTelemetry.createTrack(sdkClient);
1915
+ coreTelemetry.createTrackEvent(sdkClient);
2126
1916
 
2127
1917
  /**
2128
1918
  * Service for interacting with UiPath Orchestrator Queues 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
  }