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