@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.
@@ -271,278 +271,33 @@ class NetworkError extends UiPathError {
271
271
  }
272
272
 
273
273
  /**
274
- * SDK Telemetry constants
275
- */
276
- // Connection string placeholder that will be replaced during build
277
- 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";
278
- // SDK Version placeholder
279
- const SDK_VERSION = "1.3.7";
280
- const VERSION = "Version";
281
- const SERVICE = "Service";
282
- const CLOUD_ORGANIZATION_NAME = "CloudOrganizationName";
283
- const CLOUD_TENANT_NAME = "CloudTenantName";
284
- const CLOUD_URL = "CloudUrl";
285
- const CLOUD_CLIENT_ID = "CloudClientId";
286
- const CLOUD_REDIRECT_URI = "CloudRedirectUri";
287
- const APP_NAME = "ApplicationName";
288
- const CLOUD_ROLE_NAME = "uipath-ts-sdk";
289
- // Service and logger names
290
- const SDK_SERVICE_NAME = "UiPath.TypeScript.Sdk";
291
- const SDK_LOGGER_NAME = "uipath-ts-sdk-telemetry";
292
- // Event names
293
- const SDK_RUN_EVENT = "Sdk.Run";
294
- // Default value for unknown/empty attributes
295
- const UNKNOWN = "";
296
-
297
- /**
298
- * Log exporter that sends ALL logs as Application Insights custom events
299
- */
300
- class ApplicationInsightsEventExporter {
301
- constructor(connectionString) {
302
- this.connectionString = connectionString;
303
- }
304
- export(logs, resultCallback) {
305
- try {
306
- logs.forEach(logRecord => {
307
- this.sendAsCustomEvent(logRecord);
308
- });
309
- resultCallback({ code: 0 });
310
- }
311
- catch (error) {
312
- console.debug('Failed to export logs to Application Insights:', error);
313
- resultCallback({ code: 2, error });
314
- }
315
- }
316
- shutdown() {
317
- return Promise.resolve();
318
- }
319
- sendAsCustomEvent(logRecord) {
320
- // Get event name from body or attributes
321
- const eventName = logRecord.body || SDK_RUN_EVENT;
322
- const payload = {
323
- name: 'Microsoft.ApplicationInsights.Event',
324
- time: new Date().toISOString(),
325
- iKey: this.extractInstrumentationKey(),
326
- data: {
327
- baseType: 'EventData',
328
- baseData: {
329
- ver: 2,
330
- name: eventName,
331
- properties: this.convertAttributesToProperties(logRecord.attributes || {})
332
- }
333
- },
334
- tags: {
335
- 'ai.cloud.role': CLOUD_ROLE_NAME,
336
- 'ai.cloud.roleInstance': SDK_VERSION
337
- }
338
- };
339
- this.sendToApplicationInsights(payload);
340
- }
341
- extractInstrumentationKey() {
342
- const match = this.connectionString.match(/InstrumentationKey=([^;]+)/);
343
- return match ? match[1] : '';
344
- }
345
- convertAttributesToProperties(attributes) {
346
- const properties = {};
347
- Object.entries(attributes || {}).forEach(([key, value]) => {
348
- properties[key] = String(value);
349
- });
350
- return properties;
351
- }
352
- async sendToApplicationInsights(payload) {
353
- try {
354
- const ingestionEndpoint = this.extractIngestionEndpoint();
355
- if (!ingestionEndpoint) {
356
- console.debug('No ingestion endpoint found in connection string');
357
- return;
358
- }
359
- const url = `${ingestionEndpoint}/v2/track`;
360
- const response = await fetch(url, {
361
- method: 'POST',
362
- headers: {
363
- 'Content-Type': 'application/json',
364
- },
365
- body: JSON.stringify(payload)
366
- });
367
- if (!response.ok) {
368
- console.debug(`Failed to send event telemetry: ${response.status} ${response.statusText}`);
369
- }
370
- }
371
- catch (error) {
372
- console.debug('Error sending event telemetry to Application Insights:', error);
373
- }
374
- }
375
- extractIngestionEndpoint() {
376
- const match = this.connectionString.match(/IngestionEndpoint=([^;]+)/);
377
- return match ? match[1] : '';
378
- }
379
- }
380
- /**
381
- * Singleton telemetry client
382
- */
383
- class TelemetryClient {
384
- constructor() {
385
- this.isInitialized = false;
386
- }
387
- static getInstance() {
388
- if (!TelemetryClient.instance) {
389
- TelemetryClient.instance = new TelemetryClient();
390
- }
391
- return TelemetryClient.instance;
392
- }
393
- /**
394
- * Initialize telemetry
395
- */
396
- initialize(config) {
397
- if (this.isInitialized) {
398
- return;
399
- }
400
- this.isInitialized = true;
401
- if (config) {
402
- this.telemetryContext = config;
403
- }
404
- try {
405
- const connectionString = this.getConnectionString();
406
- if (!connectionString) {
407
- return;
408
- }
409
- this.setupTelemetryProvider(connectionString);
410
- }
411
- catch (error) {
412
- // Silent failure - telemetry errors shouldn't break functionality
413
- console.debug('Failed to initialize OpenTelemetry:', error);
414
- }
415
- }
416
- getConnectionString() {
417
- const connectionString = CONNECTION_STRING;
418
- return connectionString;
419
- }
420
- setupTelemetryProvider(connectionString) {
421
- const exporter = new ApplicationInsightsEventExporter(connectionString);
422
- const processor = new BatchLogRecordProcessor(exporter);
423
- this.logProvider = new LoggerProvider({
424
- processors: [processor]
425
- });
426
- this.logger = this.logProvider.getLogger(SDK_LOGGER_NAME);
427
- }
428
- /**
429
- * Track a telemetry event
430
- */
431
- track(eventName, name, extraAttributes = {}) {
432
- try {
433
- // Skip if logger not initialized
434
- if (!this.logger) {
435
- return;
436
- }
437
- const finalDisplayName = name || eventName;
438
- const attributes = this.getEnrichedAttributes(extraAttributes, eventName);
439
- // Emit as log
440
- this.logger.emit({
441
- body: finalDisplayName,
442
- attributes: attributes,
443
- timestamp: Date.now(),
444
- });
445
- }
446
- catch (error) {
447
- // Silent failure
448
- console.debug('Failed to track telemetry event:', error);
449
- }
450
- }
451
- /**
452
- * Get enriched attributes for telemetry events
453
- */
454
- getEnrichedAttributes(extraAttributes, eventName) {
455
- const attributes = {
456
- [APP_NAME]: SDK_SERVICE_NAME,
457
- [VERSION]: SDK_VERSION,
458
- [SERVICE]: eventName,
459
- [CLOUD_URL]: this.createCloudUrl(),
460
- [CLOUD_ORGANIZATION_NAME]: this.telemetryContext?.orgName || UNKNOWN,
461
- [CLOUD_TENANT_NAME]: this.telemetryContext?.tenantName || UNKNOWN,
462
- [CLOUD_REDIRECT_URI]: this.telemetryContext?.redirectUri || UNKNOWN,
463
- [CLOUD_CLIENT_ID]: this.telemetryContext?.clientId || UNKNOWN,
464
- ...extraAttributes,
465
- };
466
- return attributes;
467
- }
468
- /**
469
- * Create cloud URL from base URL, organization ID, and tenant ID
470
- */
471
- createCloudUrl() {
472
- const baseUrl = this.telemetryContext?.baseUrl;
473
- const orgId = this.telemetryContext?.orgName;
474
- const tenantId = this.telemetryContext?.tenantName;
475
- if (!baseUrl || !orgId || !tenantId) {
476
- return UNKNOWN;
477
- }
478
- return `${baseUrl}/${orgId}/${tenantId}`;
479
- }
480
- }
481
- // Export singleton instance
482
- const telemetryClient = TelemetryClient.getInstance();
274
+ * SDK Telemetry constants.
275
+ *
276
+ * Only the SDK's identity (version, service name, role name, …) lives
277
+ * here. The Application Insights connection string is injected into
278
+ * `@uipath/core-telemetry` itself at publish time, and the generic attribute
279
+ * keys (`Version`, `Service`, `CloudOrganizationName`, …) are owned by
280
+ * `@uipath/core-telemetry` and consumed there — they are not part of the
281
+ * SDK's public API.
282
+ */
283
+ /** SDK version placeholder — patched by the SDK publish workflow. */
284
+ const CLOUD_ROLE_NAME = 'uipath-ts-sdk';
483
285
 
484
286
  /**
485
- * SDK Track decorator and function for telemetry
486
- */
487
- /**
488
- * Common tracking logic shared between method and function decorators
489
- */
490
- function createTrackedFunction(originalFunction, nameOrOptions, fallbackName, opts) {
491
- return function (...args) {
492
- // Determine if we should track this call
493
- let shouldTrack = true;
494
- if (opts.condition !== undefined) {
495
- if (typeof opts.condition === 'function') {
496
- shouldTrack = opts.condition.apply(this, args);
497
- }
498
- else {
499
- shouldTrack = opts.condition;
500
- }
501
- }
502
- // Track the event if enabled
503
- if (shouldTrack) {
504
- // Use the full name provided in the decorator (e.g., "Queue.GetAll")
505
- const serviceMethod = typeof nameOrOptions === 'string'
506
- ? nameOrOptions
507
- : fallbackName;
508
- // Use 'Sdk.Run' as the name and serviceMethod as the service
509
- telemetryClient.track(serviceMethod, SDK_RUN_EVENT, opts.attributes);
510
- }
511
- // Execute the original function
512
- return originalFunction.apply(this, args);
513
- };
514
- }
515
- /**
516
- * Track decorator that can be used to automatically track function calls
517
- *
518
- * Usage:
519
- * @track("Service.Method")
520
- * function myFunction() { ... }
287
+ * UiPath TypeScript SDK Telemetry
521
288
  *
522
- * @track("Queue.GetAll")
523
- * async getAll() { ... }
524
- *
525
- * @track("Tasks.Create")
526
- * async create() { ... }
527
- *
528
- * @track("Assets.Update", { condition: false })
529
- * function myFunction() { ... }
530
- *
531
- * @track("Processes.Start", { attributes: { customProp: "value" } })
532
- * function myFunction() { ... }
533
- */
534
- function track(nameOrOptions, options) {
535
- return function decorator(_target, propertyKey, descriptor) {
536
- const opts = typeof nameOrOptions === 'object' ? nameOrOptions : {};
537
- if (descriptor && typeof descriptor.value === 'function') {
538
- // Method decorator
539
- descriptor.value = createTrackedFunction(descriptor.value, nameOrOptions, propertyKey || 'unknown_method', opts);
540
- return descriptor;
541
- }
542
- // Function decorator
543
- return (originalFunction) => createTrackedFunction(originalFunction, nameOrOptions, originalFunction.name || 'unknown_function', opts);
544
- };
545
- }
289
+ * Constructs the SDK's own `TelemetryClient` and binds the SDK-local
290
+ * `track` / `trackEvent` to it. Each consumer of `@uipath/core-telemetry`
291
+ * does this independently, so events carry their own consumer's identity
292
+ * and tenant context.
293
+ */
294
+ // Keyed by `CLOUD_ROLE_NAME` so every SDK subpath bundle resolves to the
295
+ // same `TelemetryClient` instance at runtime. A single `initialize(...)`
296
+ // from the `UiPath` constructor therefore wires up `@track` decorators
297
+ // across every subpath bundle (`assets`, `feedback`, `tasks`, …).
298
+ const sdkClient = getOrCreateClient(CLOUD_ROLE_NAME);
299
+ const track = createTrack(sdkClient);
300
+ createTrackEvent(sdkClient);
546
301
 
547
302
  var TaskUserType;
548
303
  (function (TaskUserType) {
@@ -856,6 +611,27 @@ function createHeaders(headersObj) {
856
611
  /**
857
612
  * Collection of utility functions for working with objects
858
613
  */
614
+ /**
615
+ * Resolves a field value from an object, supporting both direct keys (e.g., '@odata.count')
616
+ * and dot-separated nested paths (e.g., 'pagination.totalCount').
617
+ * Direct key match takes priority over nested traversal.
618
+ */
619
+ function resolveNestedField(data, fieldPath) {
620
+ if (!data) {
621
+ return undefined;
622
+ }
623
+ if (fieldPath in data) {
624
+ return data[fieldPath];
625
+ }
626
+ if (!fieldPath.includes('.')) {
627
+ return undefined;
628
+ }
629
+ let value = data;
630
+ for (const part of fieldPath.split('.')) {
631
+ value = value?.[part];
632
+ }
633
+ return value;
634
+ }
859
635
  /**
860
636
  * Filters out undefined values from an object
861
637
  * @param obj The source object
@@ -912,6 +688,10 @@ var PaginationType;
912
688
  PaginationType["TOKEN"] = "token";
913
689
  })(PaginationType || (PaginationType = {}));
914
690
 
691
+ /**
692
+ * Converts a UTC timestamp string (e.g., "5/8/2026 11:20:17 AM") to ISO 8601 UTC format.
693
+ * Returns the original value if parsing fails.
694
+ */
915
695
  /**
916
696
  * Transforms data by mapping fields according to the provided field mapping
917
697
  * @param data The source data to transform
@@ -1428,7 +1208,8 @@ class PaginationHelpers {
1428
1208
  // Extract and transform items from response
1429
1209
  // Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N })
1430
1210
  const rawItems = Array.isArray(response.data) ? response.data : response.data?.[itemsField];
1431
- const totalCount = Array.isArray(response.data) ? undefined : response.data?.[totalCountField];
1211
+ const rawTotalCount = Array.isArray(response.data) ? undefined : resolveNestedField(response.data, totalCountField);
1212
+ const totalCount = typeof rawTotalCount === 'number' ? rawTotalCount : undefined;
1432
1213
  // Parse items - automatically handle JSON string responses
1433
1214
  const parsedItems = typeof rawItems === 'string' ? JSON.parse(rawItems) : (rawItems || []);
1434
1215
  const items = transformFn ? parsedItems.map(transformFn) : parsedItems;
@@ -2145,9 +1926,17 @@ class BaseService {
2145
1926
  const pageSizeParam = paginationParams?.pageSizeParam || ODATA_OFFSET_PARAMS.PAGE_SIZE_PARAM;
2146
1927
  const offsetParam = paginationParams?.offsetParam || ODATA_OFFSET_PARAMS.OFFSET_PARAM;
2147
1928
  const countParam = paginationParams?.countParam || ODATA_OFFSET_PARAMS.COUNT_PARAM;
1929
+ // When true (default), converts pageNumber to a skip/offset value (e.g., page 3 with pageSize 10 → skip 20).
1930
+ // When false, passes pageNumber directly as the offset param — used by APIs that accept a page number instead of a record offset.
1931
+ const convertToSkip = paginationParams?.convertToSkip ?? true;
2148
1932
  requestParams[pageSizeParam] = limitedPageSize;
2149
- if (params.pageNumber && params.pageNumber > 1) {
2150
- requestParams[offsetParam] = (params.pageNumber - 1) * limitedPageSize;
1933
+ if (convertToSkip) {
1934
+ if (params.pageNumber && params.pageNumber > 1) {
1935
+ requestParams[offsetParam] = (params.pageNumber - 1) * limitedPageSize;
1936
+ }
1937
+ }
1938
+ else {
1939
+ requestParams[offsetParam] = params.pageNumber || 1;
2151
1940
  }
2152
1941
  {
2153
1942
  requestParams[countParam] = true;
@@ -2178,7 +1967,8 @@ class BaseService {
2178
1967
  // Extract items and metadata
2179
1968
  // Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N })
2180
1969
  const items = Array.isArray(response.data) ? response.data : (response.data[itemsField] || []);
2181
- const totalCount = Array.isArray(response.data) ? undefined : response.data[totalCountField];
1970
+ const rawTotalCount = Array.isArray(response.data) ? undefined : resolveNestedField(response.data, totalCountField);
1971
+ const totalCount = typeof rawTotalCount === 'number' ? rawTotalCount : undefined;
2182
1972
  const continuationToken = response.data[continuationTokenField];
2183
1973
  // Determine if there are more pages
2184
1974
  const hasMore = this.determineHasMorePages(paginationType, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uipath/uipath-typescript",
3
- "version": "1.3.7",
3
+ "version": "1.3.9",
4
4
  "description": "UiPath TypeScript SDK",
5
5
  "license": "MIT",
6
6
  "keywords": [
@@ -177,14 +177,15 @@
177
177
  "build": "rollup -c",
178
178
  "build:watch": "rollup -c -w",
179
179
  "clean": "rimraf dist && rimraf node_modules && rimraf package-lock.json",
180
- "docs:api": "typedoc && npm run docs:post-process && npm run docs:coded-action-apps",
181
- "docs:coded-action-apps": "npm run docs --prefix packages/coded-action-apps",
180
+ "docs:api": "typedoc && npm run docs:post-process && npm run docs:coded-action-app",
181
+ "docs:coded-action-app": "npm run docs --prefix packages/coded-action-app",
182
182
  "docs:post-process": "node scripts/docs-post-process.mjs",
183
183
  "lint": "oxlint",
184
184
  "typecheck": "tsc --noEmit",
185
185
  "test": "vitest",
186
- "test:unit": "vitest tests/unit",
186
+ "test:unit": "vitest run",
187
187
  "test:integration": "vitest --config vitest.integration.config.ts",
188
+ "test:integration:coverage": "vitest --config vitest.integration.config.ts --coverage",
188
189
  "test:integration:v0": "vitest --config vitest.integration.config.ts --testNamePattern='\\[v0\\]'",
189
190
  "test:integration:v1": "vitest --config vitest.integration.config.ts --testNamePattern='\\[v1\\]'",
190
191
  "test:integration:smoke": "vitest tests/integration/shared/smoke.integration.test.ts --config vitest.integration.config.ts",
@@ -195,7 +196,7 @@
195
196
  "test:coverage": "vitest --coverage"
196
197
  },
197
198
  "dependencies": {
198
- "@opentelemetry/sdk-logs": "^0.204.0",
199
+ "@uipath/core-telemetry": "^1.0.0-beta.1",
199
200
  "socket.io-client": "^4.8.1"
200
201
  },
201
202
  "peerDependencies": {
@@ -215,7 +216,7 @@
215
216
  "dotenv": "^17.2.0",
216
217
  "oxlint": "^1.43.0",
217
218
  "rimraf": "^6.0.1",
218
- "rollup": "^4.60.2",
219
+ "rollup": "^4.60.4",
219
220
  "rollup-plugin-dts": "^6.1.0",
220
221
  "tslib": "^2.8.1",
221
222
  "typedoc": "^0.28.13",
@@ -226,8 +227,5 @@
226
227
  "repository": {
227
228
  "type": "git",
228
229
  "url": "git+https://github.com/UiPath/uipath-typescript.git"
229
- },
230
- "workspaces": [
231
- "packages/*"
232
- ]
230
+ }
233
231
  }