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