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