@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.
@@ -272,6 +272,10 @@ class NetworkError extends UiPathError {
272
272
  }
273
273
  }
274
274
 
275
+ /**
276
+ * Converts a UTC timestamp string (e.g., "5/8/2026 11:20:17 AM") to ISO 8601 UTC format.
277
+ * Returns the original value if parsing fails.
278
+ */
275
279
  /**
276
280
  * Transforms data by mapping fields according to the provided field mapping
277
281
  * @param data The source data to transform
@@ -471,277 +475,33 @@ const BUCKET_TOKEN_PARAMS = {
471
475
  };
472
476
 
473
477
  /**
474
- * SDK Telemetry constants
478
+ * SDK Telemetry constants.
479
+ *
480
+ * Only the SDK's identity (version, service name, role name, …) lives
481
+ * here. The Application Insights connection string is injected into
482
+ * `@uipath/core-telemetry` itself at publish time, and the generic attribute
483
+ * keys (`Version`, `Service`, `CloudOrganizationName`, …) are owned by
484
+ * `@uipath/core-telemetry` and consumed there — they are not part of the
485
+ * SDK's public API.
475
486
  */
476
- // Connection string placeholder that will be replaced during build
477
- 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";
478
- // SDK Version placeholder
479
- const SDK_VERSION = "1.3.7";
480
- const VERSION = "Version";
481
- const SERVICE = "Service";
482
- const CLOUD_ORGANIZATION_NAME = "CloudOrganizationName";
483
- const CLOUD_TENANT_NAME = "CloudTenantName";
484
- const CLOUD_URL = "CloudUrl";
485
- const CLOUD_CLIENT_ID = "CloudClientId";
486
- const CLOUD_REDIRECT_URI = "CloudRedirectUri";
487
- const APP_NAME = "ApplicationName";
488
- const CLOUD_ROLE_NAME = "uipath-ts-sdk";
489
- // Service and logger names
490
- const SDK_SERVICE_NAME = "UiPath.TypeScript.Sdk";
491
- const SDK_LOGGER_NAME = "uipath-ts-sdk-telemetry";
492
- // Event names
493
- const SDK_RUN_EVENT = "Sdk.Run";
494
- // Default value for unknown/empty attributes
495
- const UNKNOWN = "";
487
+ /** SDK version placeholder patched by the SDK publish workflow. */
488
+ const CLOUD_ROLE_NAME = 'uipath-ts-sdk';
496
489
 
497
490
  /**
498
- * Log exporter that sends ALL logs as Application Insights custom events
499
- */
500
- class ApplicationInsightsEventExporter {
501
- constructor(connectionString) {
502
- this.connectionString = connectionString;
503
- }
504
- export(logs, resultCallback) {
505
- try {
506
- logs.forEach(logRecord => {
507
- this.sendAsCustomEvent(logRecord);
508
- });
509
- resultCallback({ code: 0 });
510
- }
511
- catch (error) {
512
- console.debug('Failed to export logs to Application Insights:', error);
513
- resultCallback({ code: 2, error });
514
- }
515
- }
516
- shutdown() {
517
- return Promise.resolve();
518
- }
519
- sendAsCustomEvent(logRecord) {
520
- // Get event name from body or attributes
521
- const eventName = logRecord.body || SDK_RUN_EVENT;
522
- const payload = {
523
- name: 'Microsoft.ApplicationInsights.Event',
524
- time: new Date().toISOString(),
525
- iKey: this.extractInstrumentationKey(),
526
- data: {
527
- baseType: 'EventData',
528
- baseData: {
529
- ver: 2,
530
- name: eventName,
531
- properties: this.convertAttributesToProperties(logRecord.attributes || {})
532
- }
533
- },
534
- tags: {
535
- 'ai.cloud.role': CLOUD_ROLE_NAME,
536
- 'ai.cloud.roleInstance': SDK_VERSION
537
- }
538
- };
539
- this.sendToApplicationInsights(payload);
540
- }
541
- extractInstrumentationKey() {
542
- const match = this.connectionString.match(/InstrumentationKey=([^;]+)/);
543
- return match ? match[1] : '';
544
- }
545
- convertAttributesToProperties(attributes) {
546
- const properties = {};
547
- Object.entries(attributes || {}).forEach(([key, value]) => {
548
- properties[key] = String(value);
549
- });
550
- return properties;
551
- }
552
- async sendToApplicationInsights(payload) {
553
- try {
554
- const ingestionEndpoint = this.extractIngestionEndpoint();
555
- if (!ingestionEndpoint) {
556
- console.debug('No ingestion endpoint found in connection string');
557
- return;
558
- }
559
- const url = `${ingestionEndpoint}/v2/track`;
560
- const response = await fetch(url, {
561
- method: 'POST',
562
- headers: {
563
- 'Content-Type': 'application/json',
564
- },
565
- body: JSON.stringify(payload)
566
- });
567
- if (!response.ok) {
568
- console.debug(`Failed to send event telemetry: ${response.status} ${response.statusText}`);
569
- }
570
- }
571
- catch (error) {
572
- console.debug('Error sending event telemetry to Application Insights:', error);
573
- }
574
- }
575
- extractIngestionEndpoint() {
576
- const match = this.connectionString.match(/IngestionEndpoint=([^;]+)/);
577
- return match ? match[1] : '';
578
- }
579
- }
580
- /**
581
- * Singleton telemetry client
582
- */
583
- class TelemetryClient {
584
- constructor() {
585
- this.isInitialized = false;
586
- }
587
- static getInstance() {
588
- if (!TelemetryClient.instance) {
589
- TelemetryClient.instance = new TelemetryClient();
590
- }
591
- return TelemetryClient.instance;
592
- }
593
- /**
594
- * Initialize telemetry
595
- */
596
- initialize(config) {
597
- if (this.isInitialized) {
598
- return;
599
- }
600
- this.isInitialized = true;
601
- if (config) {
602
- this.telemetryContext = config;
603
- }
604
- try {
605
- const connectionString = this.getConnectionString();
606
- if (!connectionString) {
607
- return;
608
- }
609
- this.setupTelemetryProvider(connectionString);
610
- }
611
- catch (error) {
612
- // Silent failure - telemetry errors shouldn't break functionality
613
- console.debug('Failed to initialize OpenTelemetry:', error);
614
- }
615
- }
616
- getConnectionString() {
617
- const connectionString = CONNECTION_STRING;
618
- return connectionString;
619
- }
620
- setupTelemetryProvider(connectionString) {
621
- const exporter = new ApplicationInsightsEventExporter(connectionString);
622
- const processor = new sdkLogs.BatchLogRecordProcessor(exporter);
623
- this.logProvider = new sdkLogs.LoggerProvider({
624
- processors: [processor]
625
- });
626
- this.logger = this.logProvider.getLogger(SDK_LOGGER_NAME);
627
- }
628
- /**
629
- * Track a telemetry event
630
- */
631
- track(eventName, name, extraAttributes = {}) {
632
- try {
633
- // Skip if logger not initialized
634
- if (!this.logger) {
635
- return;
636
- }
637
- const finalDisplayName = name || eventName;
638
- const attributes = this.getEnrichedAttributes(extraAttributes, eventName);
639
- // Emit as log
640
- this.logger.emit({
641
- body: finalDisplayName,
642
- attributes: attributes,
643
- timestamp: Date.now(),
644
- });
645
- }
646
- catch (error) {
647
- // Silent failure
648
- console.debug('Failed to track telemetry event:', error);
649
- }
650
- }
651
- /**
652
- * Get enriched attributes for telemetry events
653
- */
654
- getEnrichedAttributes(extraAttributes, eventName) {
655
- const attributes = {
656
- [APP_NAME]: SDK_SERVICE_NAME,
657
- [VERSION]: SDK_VERSION,
658
- [SERVICE]: eventName,
659
- [CLOUD_URL]: this.createCloudUrl(),
660
- [CLOUD_ORGANIZATION_NAME]: this.telemetryContext?.orgName || UNKNOWN,
661
- [CLOUD_TENANT_NAME]: this.telemetryContext?.tenantName || UNKNOWN,
662
- [CLOUD_REDIRECT_URI]: this.telemetryContext?.redirectUri || UNKNOWN,
663
- [CLOUD_CLIENT_ID]: this.telemetryContext?.clientId || UNKNOWN,
664
- ...extraAttributes,
665
- };
666
- return attributes;
667
- }
668
- /**
669
- * Create cloud URL from base URL, organization ID, and tenant ID
670
- */
671
- createCloudUrl() {
672
- const baseUrl = this.telemetryContext?.baseUrl;
673
- const orgId = this.telemetryContext?.orgName;
674
- const tenantId = this.telemetryContext?.tenantName;
675
- if (!baseUrl || !orgId || !tenantId) {
676
- return UNKNOWN;
677
- }
678
- return `${baseUrl}/${orgId}/${tenantId}`;
679
- }
680
- }
681
- // Export singleton instance
682
- const telemetryClient = TelemetryClient.getInstance();
683
-
684
- /**
685
- * SDK Track decorator and function for telemetry
686
- */
687
- /**
688
- * Common tracking logic shared between method and function decorators
689
- */
690
- function createTrackedFunction(originalFunction, nameOrOptions, fallbackName, opts) {
691
- return function (...args) {
692
- // Determine if we should track this call
693
- let shouldTrack = true;
694
- if (opts.condition !== undefined) {
695
- if (typeof opts.condition === 'function') {
696
- shouldTrack = opts.condition.apply(this, args);
697
- }
698
- else {
699
- shouldTrack = opts.condition;
700
- }
701
- }
702
- // Track the event if enabled
703
- if (shouldTrack) {
704
- // Use the full name provided in the decorator (e.g., "Queue.GetAll")
705
- const serviceMethod = nameOrOptions
706
- ;
707
- // Use 'Sdk.Run' as the name and serviceMethod as the service
708
- telemetryClient.track(serviceMethod, SDK_RUN_EVENT, opts.attributes);
709
- }
710
- // Execute the original function
711
- return originalFunction.apply(this, args);
712
- };
713
- }
714
- /**
715
- * Track decorator that can be used to automatically track function calls
716
- *
717
- * Usage:
718
- * @track("Service.Method")
719
- * function myFunction() { ... }
720
- *
721
- * @track("Queue.GetAll")
722
- * async getAll() { ... }
723
- *
724
- * @track("Tasks.Create")
725
- * async create() { ... }
726
- *
727
- * @track("Assets.Update", { condition: false })
728
- * function myFunction() { ... }
491
+ * UiPath TypeScript SDK Telemetry
729
492
  *
730
- * @track("Processes.Start", { attributes: { customProp: "value" } })
731
- * function myFunction() { ... }
493
+ * Constructs the SDK's own `TelemetryClient` and binds the SDK-local
494
+ * `track` / `trackEvent` to it. Each consumer of `@uipath/core-telemetry`
495
+ * does this independently, so events carry their own consumer's identity
496
+ * and tenant context.
732
497
  */
733
- function track(nameOrOptions, options) {
734
- return function decorator(_target, propertyKey, descriptor) {
735
- const opts = {};
736
- if (descriptor && typeof descriptor.value === 'function') {
737
- // Method decorator
738
- descriptor.value = createTrackedFunction(descriptor.value, nameOrOptions, propertyKey || 'unknown_method', opts);
739
- return descriptor;
740
- }
741
- // Function decorator
742
- return (originalFunction) => createTrackedFunction(originalFunction, nameOrOptions, originalFunction.name || 'unknown_function', opts);
743
- };
744
- }
498
+ // Keyed by `CLOUD_ROLE_NAME` so every SDK subpath bundle resolves to the
499
+ // same `TelemetryClient` instance at runtime. A single `initialize(...)`
500
+ // from the `UiPath` constructor therefore wires up `@track` decorators
501
+ // across every subpath bundle (`assets`, `feedback`, `tasks`, …).
502
+ const sdkClient = coreTelemetry.getOrCreateClient(CLOUD_ROLE_NAME);
503
+ const track = coreTelemetry.createTrack(sdkClient);
504
+ coreTelemetry.createTrackEvent(sdkClient);
745
505
 
746
506
  /**
747
507
  * Maps fields for Attachment entities to ensure consistent naming
@@ -1130,6 +890,27 @@ var PaginationType;
1130
890
  /**
1131
891
  * Collection of utility functions for working with objects
1132
892
  */
893
+ /**
894
+ * Resolves a field value from an object, supporting both direct keys (e.g., '@odata.count')
895
+ * and dot-separated nested paths (e.g., 'pagination.totalCount').
896
+ * Direct key match takes priority over nested traversal.
897
+ */
898
+ function resolveNestedField(data, fieldPath) {
899
+ if (!data) {
900
+ return undefined;
901
+ }
902
+ if (fieldPath in data) {
903
+ return data[fieldPath];
904
+ }
905
+ if (!fieldPath.includes('.')) {
906
+ return undefined;
907
+ }
908
+ let value = data;
909
+ for (const part of fieldPath.split('.')) {
910
+ value = value?.[part];
911
+ }
912
+ return value;
913
+ }
1133
914
  /**
1134
915
  * Filters out undefined values from an object
1135
916
  * @param obj The source object
@@ -1532,7 +1313,8 @@ class PaginationHelpers {
1532
1313
  // Extract and transform items from response
1533
1314
  // Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N })
1534
1315
  const rawItems = Array.isArray(response.data) ? response.data : response.data?.[itemsField];
1535
- const totalCount = Array.isArray(response.data) ? undefined : response.data?.[totalCountField];
1316
+ const rawTotalCount = Array.isArray(response.data) ? undefined : resolveNestedField(response.data, totalCountField);
1317
+ const totalCount = typeof rawTotalCount === 'number' ? rawTotalCount : undefined;
1536
1318
  // Parse items - automatically handle JSON string responses
1537
1319
  const parsedItems = typeof rawItems === 'string' ? JSON.parse(rawItems) : (rawItems || []);
1538
1320
  const items = transformFn ? parsedItems.map(transformFn) : parsedItems;
@@ -1829,9 +1611,17 @@ class BaseService {
1829
1611
  const pageSizeParam = paginationParams?.pageSizeParam || ODATA_OFFSET_PARAMS.PAGE_SIZE_PARAM;
1830
1612
  const offsetParam = paginationParams?.offsetParam || ODATA_OFFSET_PARAMS.OFFSET_PARAM;
1831
1613
  const countParam = paginationParams?.countParam || ODATA_OFFSET_PARAMS.COUNT_PARAM;
1614
+ // When true (default), converts pageNumber to a skip/offset value (e.g., page 3 with pageSize 10 → skip 20).
1615
+ // When false, passes pageNumber directly as the offset param — used by APIs that accept a page number instead of a record offset.
1616
+ const convertToSkip = paginationParams?.convertToSkip ?? true;
1832
1617
  requestParams[pageSizeParam] = limitedPageSize;
1833
- if (params.pageNumber && params.pageNumber > 1) {
1834
- requestParams[offsetParam] = (params.pageNumber - 1) * limitedPageSize;
1618
+ if (convertToSkip) {
1619
+ if (params.pageNumber && params.pageNumber > 1) {
1620
+ requestParams[offsetParam] = (params.pageNumber - 1) * limitedPageSize;
1621
+ }
1622
+ }
1623
+ else {
1624
+ requestParams[offsetParam] = params.pageNumber || 1;
1835
1625
  }
1836
1626
  {
1837
1627
  requestParams[countParam] = true;
@@ -1862,7 +1652,8 @@ class BaseService {
1862
1652
  // Extract items and metadata
1863
1653
  // Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N })
1864
1654
  const items = Array.isArray(response.data) ? response.data : (response.data[itemsField] || []);
1865
- const totalCount = Array.isArray(response.data) ? undefined : response.data[totalCountField];
1655
+ const rawTotalCount = Array.isArray(response.data) ? undefined : resolveNestedField(response.data, totalCountField);
1656
+ const totalCount = typeof rawTotalCount === 'number' ? rawTotalCount : undefined;
1866
1657
  const continuationToken = response.data[continuationTokenField];
1867
1658
  // Determine if there are more pages
1868
1659
  const hasMore = this.determineHasMorePages(paginationType, {
@@ -194,6 +194,7 @@ interface RequestWithPaginationOptions extends RequestSpec {
194
194
  offsetParam?: string;
195
195
  tokenParam?: string;
196
196
  countParam?: string;
197
+ convertToSkip?: boolean;
197
198
  };
198
199
  };
199
200
  }