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