@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.
@@ -649,6 +649,27 @@ var PaginationType;
649
649
  /**
650
650
  * Collection of utility functions for working with objects
651
651
  */
652
+ /**
653
+ * Resolves a field value from an object, supporting both direct keys (e.g., '@odata.count')
654
+ * and dot-separated nested paths (e.g., 'pagination.totalCount').
655
+ * Direct key match takes priority over nested traversal.
656
+ */
657
+ function resolveNestedField(data, fieldPath) {
658
+ if (!data) {
659
+ return undefined;
660
+ }
661
+ if (fieldPath in data) {
662
+ return data[fieldPath];
663
+ }
664
+ if (!fieldPath.includes('.')) {
665
+ return undefined;
666
+ }
667
+ let value = data;
668
+ for (const part of fieldPath.split('.')) {
669
+ value = value?.[part];
670
+ }
671
+ return value;
672
+ }
652
673
  /**
653
674
  * Filters out undefined values from an object
654
675
  * @param obj The source object
@@ -910,6 +931,10 @@ const BUCKET_TOKEN_PARAMS = {
910
931
  TOKEN_PARAM: 'continuationToken'
911
932
  };
912
933
 
934
+ /**
935
+ * Converts a UTC timestamp string (e.g., "5/8/2026 11:20:17 AM") to ISO 8601 UTC format.
936
+ * Returns the original value if parsing fails.
937
+ */
913
938
  /**
914
939
  * Transforms data by mapping fields according to the provided field mapping
915
940
  * @param data The source data to transform
@@ -1264,7 +1289,8 @@ class PaginationHelpers {
1264
1289
  // Extract and transform items from response
1265
1290
  // Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N })
1266
1291
  const rawItems = Array.isArray(response.data) ? response.data : response.data?.[itemsField];
1267
- const totalCount = Array.isArray(response.data) ? undefined : response.data?.[totalCountField];
1292
+ const rawTotalCount = Array.isArray(response.data) ? undefined : resolveNestedField(response.data, totalCountField);
1293
+ const totalCount = typeof rawTotalCount === 'number' ? rawTotalCount : undefined;
1268
1294
  // Parse items - automatically handle JSON string responses
1269
1295
  const parsedItems = typeof rawItems === 'string' ? JSON.parse(rawItems) : (rawItems || []);
1270
1296
  const items = transformFn ? parsedItems.map(transformFn) : parsedItems;
@@ -1561,9 +1587,17 @@ class BaseService {
1561
1587
  const pageSizeParam = paginationParams?.pageSizeParam || ODATA_OFFSET_PARAMS.PAGE_SIZE_PARAM;
1562
1588
  const offsetParam = paginationParams?.offsetParam || ODATA_OFFSET_PARAMS.OFFSET_PARAM;
1563
1589
  const countParam = paginationParams?.countParam || ODATA_OFFSET_PARAMS.COUNT_PARAM;
1590
+ // When true (default), converts pageNumber to a skip/offset value (e.g., page 3 with pageSize 10 → skip 20).
1591
+ // When false, passes pageNumber directly as the offset param — used by APIs that accept a page number instead of a record offset.
1592
+ const convertToSkip = paginationParams?.convertToSkip ?? true;
1564
1593
  requestParams[pageSizeParam] = limitedPageSize;
1565
- if (params.pageNumber && params.pageNumber > 1) {
1566
- requestParams[offsetParam] = (params.pageNumber - 1) * limitedPageSize;
1594
+ if (convertToSkip) {
1595
+ if (params.pageNumber && params.pageNumber > 1) {
1596
+ requestParams[offsetParam] = (params.pageNumber - 1) * limitedPageSize;
1597
+ }
1598
+ }
1599
+ else {
1600
+ requestParams[offsetParam] = params.pageNumber || 1;
1567
1601
  }
1568
1602
  {
1569
1603
  requestParams[countParam] = true;
@@ -1594,7 +1628,8 @@ class BaseService {
1594
1628
  // Extract items and metadata
1595
1629
  // Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N })
1596
1630
  const items = Array.isArray(response.data) ? response.data : (response.data[itemsField] || []);
1597
- const totalCount = Array.isArray(response.data) ? undefined : response.data[totalCountField];
1631
+ const rawTotalCount = Array.isArray(response.data) ? undefined : resolveNestedField(response.data, totalCountField);
1632
+ const totalCount = typeof rawTotalCount === 'number' ? rawTotalCount : undefined;
1598
1633
  const continuationToken = response.data[continuationTokenField];
1599
1634
  // Determine if there are more pages
1600
1635
  const hasMore = this.determineHasMorePages(paginationType, {
@@ -2098,278 +2133,33 @@ const EntityFieldTypeMap = {
2098
2133
  };
2099
2134
 
2100
2135
  /**
2101
- * SDK Telemetry constants
2102
- */
2103
- // Connection string placeholder that will be replaced during build
2104
- 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";
2105
- // SDK Version placeholder
2106
- const SDK_VERSION = "1.3.7";
2107
- const VERSION = "Version";
2108
- const SERVICE = "Service";
2109
- const CLOUD_ORGANIZATION_NAME = "CloudOrganizationName";
2110
- const CLOUD_TENANT_NAME = "CloudTenantName";
2111
- const CLOUD_URL = "CloudUrl";
2112
- const CLOUD_CLIENT_ID = "CloudClientId";
2113
- const CLOUD_REDIRECT_URI = "CloudRedirectUri";
2114
- const APP_NAME = "ApplicationName";
2115
- const CLOUD_ROLE_NAME = "uipath-ts-sdk";
2116
- // Service and logger names
2117
- const SDK_SERVICE_NAME = "UiPath.TypeScript.Sdk";
2118
- const SDK_LOGGER_NAME = "uipath-ts-sdk-telemetry";
2119
- // Event names
2120
- const SDK_RUN_EVENT = "Sdk.Run";
2121
- // Default value for unknown/empty attributes
2122
- const UNKNOWN = "";
2123
-
2124
- /**
2125
- * Log exporter that sends ALL logs as Application Insights custom events
2126
- */
2127
- class ApplicationInsightsEventExporter {
2128
- constructor(connectionString) {
2129
- this.connectionString = connectionString;
2130
- }
2131
- export(logs, resultCallback) {
2132
- try {
2133
- logs.forEach(logRecord => {
2134
- this.sendAsCustomEvent(logRecord);
2135
- });
2136
- resultCallback({ code: 0 });
2137
- }
2138
- catch (error) {
2139
- console.debug('Failed to export logs to Application Insights:', error);
2140
- resultCallback({ code: 2, error });
2141
- }
2142
- }
2143
- shutdown() {
2144
- return Promise.resolve();
2145
- }
2146
- sendAsCustomEvent(logRecord) {
2147
- // Get event name from body or attributes
2148
- const eventName = logRecord.body || SDK_RUN_EVENT;
2149
- const payload = {
2150
- name: 'Microsoft.ApplicationInsights.Event',
2151
- time: new Date().toISOString(),
2152
- iKey: this.extractInstrumentationKey(),
2153
- data: {
2154
- baseType: 'EventData',
2155
- baseData: {
2156
- ver: 2,
2157
- name: eventName,
2158
- properties: this.convertAttributesToProperties(logRecord.attributes || {})
2159
- }
2160
- },
2161
- tags: {
2162
- 'ai.cloud.role': CLOUD_ROLE_NAME,
2163
- 'ai.cloud.roleInstance': SDK_VERSION
2164
- }
2165
- };
2166
- this.sendToApplicationInsights(payload);
2167
- }
2168
- extractInstrumentationKey() {
2169
- const match = this.connectionString.match(/InstrumentationKey=([^;]+)/);
2170
- return match ? match[1] : '';
2171
- }
2172
- convertAttributesToProperties(attributes) {
2173
- const properties = {};
2174
- Object.entries(attributes || {}).forEach(([key, value]) => {
2175
- properties[key] = String(value);
2176
- });
2177
- return properties;
2178
- }
2179
- async sendToApplicationInsights(payload) {
2180
- try {
2181
- const ingestionEndpoint = this.extractIngestionEndpoint();
2182
- if (!ingestionEndpoint) {
2183
- console.debug('No ingestion endpoint found in connection string');
2184
- return;
2185
- }
2186
- const url = `${ingestionEndpoint}/v2/track`;
2187
- const response = await fetch(url, {
2188
- method: 'POST',
2189
- headers: {
2190
- 'Content-Type': 'application/json',
2191
- },
2192
- body: JSON.stringify(payload)
2193
- });
2194
- if (!response.ok) {
2195
- console.debug(`Failed to send event telemetry: ${response.status} ${response.statusText}`);
2196
- }
2197
- }
2198
- catch (error) {
2199
- console.debug('Error sending event telemetry to Application Insights:', error);
2200
- }
2201
- }
2202
- extractIngestionEndpoint() {
2203
- const match = this.connectionString.match(/IngestionEndpoint=([^;]+)/);
2204
- return match ? match[1] : '';
2205
- }
2206
- }
2207
- /**
2208
- * Singleton telemetry client
2209
- */
2210
- class TelemetryClient {
2211
- constructor() {
2212
- this.isInitialized = false;
2213
- }
2214
- static getInstance() {
2215
- if (!TelemetryClient.instance) {
2216
- TelemetryClient.instance = new TelemetryClient();
2217
- }
2218
- return TelemetryClient.instance;
2219
- }
2220
- /**
2221
- * Initialize telemetry
2222
- */
2223
- initialize(config) {
2224
- if (this.isInitialized) {
2225
- return;
2226
- }
2227
- this.isInitialized = true;
2228
- if (config) {
2229
- this.telemetryContext = config;
2230
- }
2231
- try {
2232
- const connectionString = this.getConnectionString();
2233
- if (!connectionString) {
2234
- return;
2235
- }
2236
- this.setupTelemetryProvider(connectionString);
2237
- }
2238
- catch (error) {
2239
- // Silent failure - telemetry errors shouldn't break functionality
2240
- console.debug('Failed to initialize OpenTelemetry:', error);
2241
- }
2242
- }
2243
- getConnectionString() {
2244
- const connectionString = CONNECTION_STRING;
2245
- return connectionString;
2246
- }
2247
- setupTelemetryProvider(connectionString) {
2248
- const exporter = new ApplicationInsightsEventExporter(connectionString);
2249
- const processor = new BatchLogRecordProcessor(exporter);
2250
- this.logProvider = new LoggerProvider({
2251
- processors: [processor]
2252
- });
2253
- this.logger = this.logProvider.getLogger(SDK_LOGGER_NAME);
2254
- }
2255
- /**
2256
- * Track a telemetry event
2257
- */
2258
- track(eventName, name, extraAttributes = {}) {
2259
- try {
2260
- // Skip if logger not initialized
2261
- if (!this.logger) {
2262
- return;
2263
- }
2264
- const finalDisplayName = name || eventName;
2265
- const attributes = this.getEnrichedAttributes(extraAttributes, eventName);
2266
- // Emit as log
2267
- this.logger.emit({
2268
- body: finalDisplayName,
2269
- attributes: attributes,
2270
- timestamp: Date.now(),
2271
- });
2272
- }
2273
- catch (error) {
2274
- // Silent failure
2275
- console.debug('Failed to track telemetry event:', error);
2276
- }
2277
- }
2278
- /**
2279
- * Get enriched attributes for telemetry events
2280
- */
2281
- getEnrichedAttributes(extraAttributes, eventName) {
2282
- const attributes = {
2283
- [APP_NAME]: SDK_SERVICE_NAME,
2284
- [VERSION]: SDK_VERSION,
2285
- [SERVICE]: eventName,
2286
- [CLOUD_URL]: this.createCloudUrl(),
2287
- [CLOUD_ORGANIZATION_NAME]: this.telemetryContext?.orgName || UNKNOWN,
2288
- [CLOUD_TENANT_NAME]: this.telemetryContext?.tenantName || UNKNOWN,
2289
- [CLOUD_REDIRECT_URI]: this.telemetryContext?.redirectUri || UNKNOWN,
2290
- [CLOUD_CLIENT_ID]: this.telemetryContext?.clientId || UNKNOWN,
2291
- ...extraAttributes,
2292
- };
2293
- return attributes;
2294
- }
2295
- /**
2296
- * Create cloud URL from base URL, organization ID, and tenant ID
2297
- */
2298
- createCloudUrl() {
2299
- const baseUrl = this.telemetryContext?.baseUrl;
2300
- const orgId = this.telemetryContext?.orgName;
2301
- const tenantId = this.telemetryContext?.tenantName;
2302
- if (!baseUrl || !orgId || !tenantId) {
2303
- return UNKNOWN;
2304
- }
2305
- return `${baseUrl}/${orgId}/${tenantId}`;
2306
- }
2307
- }
2308
- // Export singleton instance
2309
- const telemetryClient = TelemetryClient.getInstance();
2136
+ * SDK Telemetry constants.
2137
+ *
2138
+ * Only the SDK's identity (version, service name, role name, …) lives
2139
+ * here. The Application Insights connection string is injected into
2140
+ * `@uipath/core-telemetry` itself at publish time, and the generic attribute
2141
+ * keys (`Version`, `Service`, `CloudOrganizationName`, …) are owned by
2142
+ * `@uipath/core-telemetry` and consumed there — they are not part of the
2143
+ * SDK's public API.
2144
+ */
2145
+ /** SDK version placeholder — patched by the SDK publish workflow. */
2146
+ const CLOUD_ROLE_NAME = 'uipath-ts-sdk';
2310
2147
 
2311
2148
  /**
2312
- * SDK Track decorator and function for telemetry
2313
- */
2314
- /**
2315
- * Common tracking logic shared between method and function decorators
2316
- */
2317
- function createTrackedFunction(originalFunction, nameOrOptions, fallbackName, opts) {
2318
- return function (...args) {
2319
- // Determine if we should track this call
2320
- let shouldTrack = true;
2321
- if (opts.condition !== undefined) {
2322
- if (typeof opts.condition === 'function') {
2323
- shouldTrack = opts.condition.apply(this, args);
2324
- }
2325
- else {
2326
- shouldTrack = opts.condition;
2327
- }
2328
- }
2329
- // Track the event if enabled
2330
- if (shouldTrack) {
2331
- // Use the full name provided in the decorator (e.g., "Queue.GetAll")
2332
- const serviceMethod = typeof nameOrOptions === 'string'
2333
- ? nameOrOptions
2334
- : fallbackName;
2335
- // Use 'Sdk.Run' as the name and serviceMethod as the service
2336
- telemetryClient.track(serviceMethod, SDK_RUN_EVENT, opts.attributes);
2337
- }
2338
- // Execute the original function
2339
- return originalFunction.apply(this, args);
2340
- };
2341
- }
2342
- /**
2343
- * Track decorator that can be used to automatically track function calls
2149
+ * UiPath TypeScript SDK Telemetry
2344
2150
  *
2345
- * Usage:
2346
- * @track("Service.Method")
2347
- * function myFunction() { ... }
2348
- *
2349
- * @track("Queue.GetAll")
2350
- * async getAll() { ... }
2351
- *
2352
- * @track("Tasks.Create")
2353
- * async create() { ... }
2354
- *
2355
- * @track("Assets.Update", { condition: false })
2356
- * function myFunction() { ... }
2357
- *
2358
- * @track("Processes.Start", { attributes: { customProp: "value" } })
2359
- * function myFunction() { ... }
2360
- */
2361
- function track(nameOrOptions, options) {
2362
- return function decorator(_target, propertyKey, descriptor) {
2363
- const opts = typeof nameOrOptions === 'object' ? nameOrOptions : {};
2364
- if (descriptor && typeof descriptor.value === 'function') {
2365
- // Method decorator
2366
- descriptor.value = createTrackedFunction(descriptor.value, nameOrOptions, propertyKey || 'unknown_method', opts);
2367
- return descriptor;
2368
- }
2369
- // Function decorator
2370
- return (originalFunction) => createTrackedFunction(originalFunction, nameOrOptions, originalFunction.name || 'unknown_function', opts);
2371
- };
2372
- }
2151
+ * Constructs the SDK's own `TelemetryClient` and binds the SDK-local
2152
+ * `track` / `trackEvent` to it. Each consumer of `@uipath/core-telemetry`
2153
+ * does this independently, so events carry their own consumer's identity
2154
+ * and tenant context.
2155
+ */
2156
+ // Keyed by `CLOUD_ROLE_NAME` so every SDK subpath bundle resolves to the
2157
+ // same `TelemetryClient` instance at runtime. A single `initialize(...)`
2158
+ // from the `UiPath` constructor therefore wires up `@track` decorators
2159
+ // across every subpath bundle (`assets`, `feedback`, `tasks`, …).
2160
+ const sdkClient = getOrCreateClient(CLOUD_ROLE_NAME);
2161
+ const track = createTrack(sdkClient);
2162
+ createTrackEvent(sdkClient);
2373
2163
 
2374
2164
  /**
2375
2165
  * Service for interacting with the Data Fabric Entity API