@uipath/uipath-typescript 1.3.8 → 1.3.10
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 +44 -276
- package/dist/assets/index.mjs +44 -276
- package/dist/attachments/index.cjs +42 -273
- package/dist/attachments/index.mjs +42 -273
- package/dist/buckets/index.cjs +195 -276
- package/dist/buckets/index.d.ts +213 -1
- package/dist/buckets/index.mjs +195 -276
- package/dist/cases/index.cjs +427 -343
- package/dist/cases/index.d.ts +534 -2
- package/dist/cases/index.mjs +428 -344
- package/dist/conversational-agent/index.cjs +90 -287
- package/dist/conversational-agent/index.d.ts +62 -12
- package/dist/conversational-agent/index.mjs +90 -288
- 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 +251 -277
- package/dist/entities/index.d.ts +305 -2
- package/dist/entities/index.mjs +251 -277
- package/dist/feedback/index.cjs +42 -274
- package/dist/feedback/index.mjs +42 -274
- package/dist/index.cjs +998 -351
- package/dist/index.d.ts +2159 -762
- package/dist/index.mjs +998 -337
- package/dist/index.umd.js +1208 -237
- package/dist/jobs/index.cjs +44 -276
- package/dist/jobs/index.mjs +44 -276
- package/dist/maestro-processes/index.cjs +1761 -1717
- package/dist/maestro-processes/index.d.ts +430 -2
- package/dist/maestro-processes/index.mjs +1762 -1718
- package/dist/processes/index.cjs +72 -305
- package/dist/processes/index.d.ts +76 -26
- package/dist/processes/index.mjs +72 -305
- package/dist/queues/index.cjs +44 -276
- package/dist/queues/index.mjs +44 -276
- package/dist/tasks/index.cjs +44 -276
- package/dist/tasks/index.mjs +44 -276
- 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.
|
|
@@ -473,277 +473,33 @@ const BUCKET_TOKEN_PARAMS = {
|
|
|
473
473
|
};
|
|
474
474
|
|
|
475
475
|
/**
|
|
476
|
-
* 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.
|
|
477
484
|
*/
|
|
478
|
-
|
|
479
|
-
const
|
|
480
|
-
// SDK Version placeholder
|
|
481
|
-
const SDK_VERSION = "1.3.8";
|
|
482
|
-
const VERSION = "Version";
|
|
483
|
-
const SERVICE = "Service";
|
|
484
|
-
const CLOUD_ORGANIZATION_NAME = "CloudOrganizationName";
|
|
485
|
-
const CLOUD_TENANT_NAME = "CloudTenantName";
|
|
486
|
-
const CLOUD_URL = "CloudUrl";
|
|
487
|
-
const CLOUD_CLIENT_ID = "CloudClientId";
|
|
488
|
-
const CLOUD_REDIRECT_URI = "CloudRedirectUri";
|
|
489
|
-
const APP_NAME = "ApplicationName";
|
|
490
|
-
const CLOUD_ROLE_NAME = "uipath-ts-sdk";
|
|
491
|
-
// Service and logger names
|
|
492
|
-
const SDK_SERVICE_NAME = "UiPath.TypeScript.Sdk";
|
|
493
|
-
const SDK_LOGGER_NAME = "uipath-ts-sdk-telemetry";
|
|
494
|
-
// Event names
|
|
495
|
-
const SDK_RUN_EVENT = "Sdk.Run";
|
|
496
|
-
// Default value for unknown/empty attributes
|
|
497
|
-
const UNKNOWN = "";
|
|
485
|
+
/** SDK version placeholder — patched by the SDK publish workflow. */
|
|
486
|
+
const CLOUD_ROLE_NAME = 'uipath-ts-sdk';
|
|
498
487
|
|
|
499
488
|
/**
|
|
500
|
-
*
|
|
501
|
-
*/
|
|
502
|
-
class ApplicationInsightsEventExporter {
|
|
503
|
-
constructor(connectionString) {
|
|
504
|
-
this.connectionString = connectionString;
|
|
505
|
-
}
|
|
506
|
-
export(logs, resultCallback) {
|
|
507
|
-
try {
|
|
508
|
-
logs.forEach(logRecord => {
|
|
509
|
-
this.sendAsCustomEvent(logRecord);
|
|
510
|
-
});
|
|
511
|
-
resultCallback({ code: 0 });
|
|
512
|
-
}
|
|
513
|
-
catch (error) {
|
|
514
|
-
console.debug('Failed to export logs to Application Insights:', error);
|
|
515
|
-
resultCallback({ code: 2, error });
|
|
516
|
-
}
|
|
517
|
-
}
|
|
518
|
-
shutdown() {
|
|
519
|
-
return Promise.resolve();
|
|
520
|
-
}
|
|
521
|
-
sendAsCustomEvent(logRecord) {
|
|
522
|
-
// Get event name from body or attributes
|
|
523
|
-
const eventName = logRecord.body || SDK_RUN_EVENT;
|
|
524
|
-
const payload = {
|
|
525
|
-
name: 'Microsoft.ApplicationInsights.Event',
|
|
526
|
-
time: new Date().toISOString(),
|
|
527
|
-
iKey: this.extractInstrumentationKey(),
|
|
528
|
-
data: {
|
|
529
|
-
baseType: 'EventData',
|
|
530
|
-
baseData: {
|
|
531
|
-
ver: 2,
|
|
532
|
-
name: eventName,
|
|
533
|
-
properties: this.convertAttributesToProperties(logRecord.attributes || {})
|
|
534
|
-
}
|
|
535
|
-
},
|
|
536
|
-
tags: {
|
|
537
|
-
'ai.cloud.role': CLOUD_ROLE_NAME,
|
|
538
|
-
'ai.cloud.roleInstance': SDK_VERSION
|
|
539
|
-
}
|
|
540
|
-
};
|
|
541
|
-
this.sendToApplicationInsights(payload);
|
|
542
|
-
}
|
|
543
|
-
extractInstrumentationKey() {
|
|
544
|
-
const match = this.connectionString.match(/InstrumentationKey=([^;]+)/);
|
|
545
|
-
return match ? match[1] : '';
|
|
546
|
-
}
|
|
547
|
-
convertAttributesToProperties(attributes) {
|
|
548
|
-
const properties = {};
|
|
549
|
-
Object.entries(attributes || {}).forEach(([key, value]) => {
|
|
550
|
-
properties[key] = String(value);
|
|
551
|
-
});
|
|
552
|
-
return properties;
|
|
553
|
-
}
|
|
554
|
-
async sendToApplicationInsights(payload) {
|
|
555
|
-
try {
|
|
556
|
-
const ingestionEndpoint = this.extractIngestionEndpoint();
|
|
557
|
-
if (!ingestionEndpoint) {
|
|
558
|
-
console.debug('No ingestion endpoint found in connection string');
|
|
559
|
-
return;
|
|
560
|
-
}
|
|
561
|
-
const url = `${ingestionEndpoint}/v2/track`;
|
|
562
|
-
const response = await fetch(url, {
|
|
563
|
-
method: 'POST',
|
|
564
|
-
headers: {
|
|
565
|
-
'Content-Type': 'application/json',
|
|
566
|
-
},
|
|
567
|
-
body: JSON.stringify(payload)
|
|
568
|
-
});
|
|
569
|
-
if (!response.ok) {
|
|
570
|
-
console.debug(`Failed to send event telemetry: ${response.status} ${response.statusText}`);
|
|
571
|
-
}
|
|
572
|
-
}
|
|
573
|
-
catch (error) {
|
|
574
|
-
console.debug('Error sending event telemetry to Application Insights:', error);
|
|
575
|
-
}
|
|
576
|
-
}
|
|
577
|
-
extractIngestionEndpoint() {
|
|
578
|
-
const match = this.connectionString.match(/IngestionEndpoint=([^;]+)/);
|
|
579
|
-
return match ? match[1] : '';
|
|
580
|
-
}
|
|
581
|
-
}
|
|
582
|
-
/**
|
|
583
|
-
* Singleton telemetry client
|
|
584
|
-
*/
|
|
585
|
-
class TelemetryClient {
|
|
586
|
-
constructor() {
|
|
587
|
-
this.isInitialized = false;
|
|
588
|
-
}
|
|
589
|
-
static getInstance() {
|
|
590
|
-
if (!TelemetryClient.instance) {
|
|
591
|
-
TelemetryClient.instance = new TelemetryClient();
|
|
592
|
-
}
|
|
593
|
-
return TelemetryClient.instance;
|
|
594
|
-
}
|
|
595
|
-
/**
|
|
596
|
-
* Initialize telemetry
|
|
597
|
-
*/
|
|
598
|
-
initialize(config) {
|
|
599
|
-
if (this.isInitialized) {
|
|
600
|
-
return;
|
|
601
|
-
}
|
|
602
|
-
this.isInitialized = true;
|
|
603
|
-
if (config) {
|
|
604
|
-
this.telemetryContext = config;
|
|
605
|
-
}
|
|
606
|
-
try {
|
|
607
|
-
const connectionString = this.getConnectionString();
|
|
608
|
-
if (!connectionString) {
|
|
609
|
-
return;
|
|
610
|
-
}
|
|
611
|
-
this.setupTelemetryProvider(connectionString);
|
|
612
|
-
}
|
|
613
|
-
catch (error) {
|
|
614
|
-
// Silent failure - telemetry errors shouldn't break functionality
|
|
615
|
-
console.debug('Failed to initialize OpenTelemetry:', error);
|
|
616
|
-
}
|
|
617
|
-
}
|
|
618
|
-
getConnectionString() {
|
|
619
|
-
const connectionString = CONNECTION_STRING;
|
|
620
|
-
return connectionString;
|
|
621
|
-
}
|
|
622
|
-
setupTelemetryProvider(connectionString) {
|
|
623
|
-
const exporter = new ApplicationInsightsEventExporter(connectionString);
|
|
624
|
-
const processor = new BatchLogRecordProcessor(exporter);
|
|
625
|
-
this.logProvider = new LoggerProvider({
|
|
626
|
-
processors: [processor]
|
|
627
|
-
});
|
|
628
|
-
this.logger = this.logProvider.getLogger(SDK_LOGGER_NAME);
|
|
629
|
-
}
|
|
630
|
-
/**
|
|
631
|
-
* Track a telemetry event
|
|
632
|
-
*/
|
|
633
|
-
track(eventName, name, extraAttributes = {}) {
|
|
634
|
-
try {
|
|
635
|
-
// Skip if logger not initialized
|
|
636
|
-
if (!this.logger) {
|
|
637
|
-
return;
|
|
638
|
-
}
|
|
639
|
-
const finalDisplayName = name || eventName;
|
|
640
|
-
const attributes = this.getEnrichedAttributes(extraAttributes, eventName);
|
|
641
|
-
// Emit as log
|
|
642
|
-
this.logger.emit({
|
|
643
|
-
body: finalDisplayName,
|
|
644
|
-
attributes: attributes,
|
|
645
|
-
timestamp: Date.now(),
|
|
646
|
-
});
|
|
647
|
-
}
|
|
648
|
-
catch (error) {
|
|
649
|
-
// Silent failure
|
|
650
|
-
console.debug('Failed to track telemetry event:', error);
|
|
651
|
-
}
|
|
652
|
-
}
|
|
653
|
-
/**
|
|
654
|
-
* Get enriched attributes for telemetry events
|
|
655
|
-
*/
|
|
656
|
-
getEnrichedAttributes(extraAttributes, eventName) {
|
|
657
|
-
const attributes = {
|
|
658
|
-
[APP_NAME]: SDK_SERVICE_NAME,
|
|
659
|
-
[VERSION]: SDK_VERSION,
|
|
660
|
-
[SERVICE]: eventName,
|
|
661
|
-
[CLOUD_URL]: this.createCloudUrl(),
|
|
662
|
-
[CLOUD_ORGANIZATION_NAME]: this.telemetryContext?.orgName || UNKNOWN,
|
|
663
|
-
[CLOUD_TENANT_NAME]: this.telemetryContext?.tenantName || UNKNOWN,
|
|
664
|
-
[CLOUD_REDIRECT_URI]: this.telemetryContext?.redirectUri || UNKNOWN,
|
|
665
|
-
[CLOUD_CLIENT_ID]: this.telemetryContext?.clientId || UNKNOWN,
|
|
666
|
-
...extraAttributes,
|
|
667
|
-
};
|
|
668
|
-
return attributes;
|
|
669
|
-
}
|
|
670
|
-
/**
|
|
671
|
-
* Create cloud URL from base URL, organization ID, and tenant ID
|
|
672
|
-
*/
|
|
673
|
-
createCloudUrl() {
|
|
674
|
-
const baseUrl = this.telemetryContext?.baseUrl;
|
|
675
|
-
const orgId = this.telemetryContext?.orgName;
|
|
676
|
-
const tenantId = this.telemetryContext?.tenantName;
|
|
677
|
-
if (!baseUrl || !orgId || !tenantId) {
|
|
678
|
-
return UNKNOWN;
|
|
679
|
-
}
|
|
680
|
-
return `${baseUrl}/${orgId}/${tenantId}`;
|
|
681
|
-
}
|
|
682
|
-
}
|
|
683
|
-
// Export singleton instance
|
|
684
|
-
const telemetryClient = TelemetryClient.getInstance();
|
|
685
|
-
|
|
686
|
-
/**
|
|
687
|
-
* SDK Track decorator and function for telemetry
|
|
688
|
-
*/
|
|
689
|
-
/**
|
|
690
|
-
* Common tracking logic shared between method and function decorators
|
|
691
|
-
*/
|
|
692
|
-
function createTrackedFunction(originalFunction, nameOrOptions, fallbackName, opts) {
|
|
693
|
-
return function (...args) {
|
|
694
|
-
// Determine if we should track this call
|
|
695
|
-
let shouldTrack = true;
|
|
696
|
-
if (opts.condition !== undefined) {
|
|
697
|
-
if (typeof opts.condition === 'function') {
|
|
698
|
-
shouldTrack = opts.condition.apply(this, args);
|
|
699
|
-
}
|
|
700
|
-
else {
|
|
701
|
-
shouldTrack = opts.condition;
|
|
702
|
-
}
|
|
703
|
-
}
|
|
704
|
-
// Track the event if enabled
|
|
705
|
-
if (shouldTrack) {
|
|
706
|
-
// Use the full name provided in the decorator (e.g., "Queue.GetAll")
|
|
707
|
-
const serviceMethod = nameOrOptions
|
|
708
|
-
;
|
|
709
|
-
// Use 'Sdk.Run' as the name and serviceMethod as the service
|
|
710
|
-
telemetryClient.track(serviceMethod, SDK_RUN_EVENT, opts.attributes);
|
|
711
|
-
}
|
|
712
|
-
// Execute the original function
|
|
713
|
-
return originalFunction.apply(this, args);
|
|
714
|
-
};
|
|
715
|
-
}
|
|
716
|
-
/**
|
|
717
|
-
* Track decorator that can be used to automatically track function calls
|
|
718
|
-
*
|
|
719
|
-
* Usage:
|
|
720
|
-
* @track("Service.Method")
|
|
721
|
-
* function myFunction() { ... }
|
|
489
|
+
* UiPath TypeScript SDK Telemetry
|
|
722
490
|
*
|
|
723
|
-
*
|
|
724
|
-
*
|
|
725
|
-
*
|
|
726
|
-
*
|
|
727
|
-
* async create() { ... }
|
|
728
|
-
*
|
|
729
|
-
* @track("Assets.Update", { condition: false })
|
|
730
|
-
* function myFunction() { ... }
|
|
731
|
-
*
|
|
732
|
-
* @track("Processes.Start", { attributes: { customProp: "value" } })
|
|
733
|
-
* function myFunction() { ... }
|
|
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.
|
|
734
495
|
*/
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
}
|
|
743
|
-
// Function decorator
|
|
744
|
-
return (originalFunction) => createTrackedFunction(originalFunction, nameOrOptions, originalFunction.name || 'unknown_function', opts);
|
|
745
|
-
};
|
|
746
|
-
}
|
|
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);
|
|
747
503
|
|
|
748
504
|
/**
|
|
749
505
|
* Maps fields for Attachment entities to ensure consistent naming
|
|
@@ -1092,14 +848,25 @@ class ApiClient {
|
|
|
1092
848
|
if (!text) {
|
|
1093
849
|
return undefined;
|
|
1094
850
|
}
|
|
1095
|
-
|
|
851
|
+
try {
|
|
852
|
+
return JSON.parse(text);
|
|
853
|
+
}
|
|
854
|
+
catch (error) {
|
|
855
|
+
if (error instanceof SyntaxError) {
|
|
856
|
+
throw new ServerError({
|
|
857
|
+
message: `Server returned non-JSON response (${response.status} ${response.url}): ${error.message}`,
|
|
858
|
+
statusCode: response.status,
|
|
859
|
+
});
|
|
860
|
+
}
|
|
861
|
+
throw error;
|
|
862
|
+
}
|
|
1096
863
|
}
|
|
1097
864
|
catch (error) {
|
|
1098
865
|
// If it's already one of our errors, re-throw it
|
|
1099
866
|
if (error.type && error.type.includes('Error')) {
|
|
1100
867
|
throw error;
|
|
1101
868
|
}
|
|
1102
|
-
// Otherwise, it's
|
|
869
|
+
// Otherwise, it's a genuine network/fetch failure
|
|
1103
870
|
throw ErrorFactory.createNetworkError(error);
|
|
1104
871
|
}
|
|
1105
872
|
}
|
|
@@ -1504,9 +1271,9 @@ class PaginationHelpers {
|
|
|
1504
1271
|
* @returns Promise resolving to a paginated result
|
|
1505
1272
|
*/
|
|
1506
1273
|
static async getAllPaginated(params) {
|
|
1507
|
-
const { serviceAccess, getEndpoint, folderId, paginationParams, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
|
|
1274
|
+
const { serviceAccess, getEndpoint, folderId, headers: providedHeaders, paginationParams, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
|
|
1508
1275
|
const endpoint = getEndpoint(folderId);
|
|
1509
|
-
const headers = folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {};
|
|
1276
|
+
const headers = providedHeaders ?? (folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {});
|
|
1510
1277
|
const paginatedResponse = await serviceAccess.requestWithPagination(method, endpoint, paginationParams, {
|
|
1511
1278
|
headers,
|
|
1512
1279
|
params: additionalParams,
|
|
@@ -1534,13 +1301,13 @@ class PaginationHelpers {
|
|
|
1534
1301
|
* @returns Promise resolving to an object with data and totalCount
|
|
1535
1302
|
*/
|
|
1536
1303
|
static async getAllNonPaginated(params) {
|
|
1537
|
-
const { serviceAccess, getAllEndpoint, getByFolderEndpoint, folderId, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
|
|
1304
|
+
const { serviceAccess, getAllEndpoint, getByFolderEndpoint, folderId, headers: providedHeaders, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
|
|
1538
1305
|
// Set default field names
|
|
1539
1306
|
const itemsField = options.itemsField || DEFAULT_ITEMS_FIELD;
|
|
1540
1307
|
const totalCountField = options.totalCountField || DEFAULT_TOTAL_COUNT_FIELD;
|
|
1541
1308
|
// Determine endpoint and headers based on folderId
|
|
1542
1309
|
const endpoint = folderId ? getByFolderEndpoint : getAllEndpoint;
|
|
1543
|
-
const headers = folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {};
|
|
1310
|
+
const headers = providedHeaders ?? (folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {});
|
|
1544
1311
|
// Make the API call based on method
|
|
1545
1312
|
let response;
|
|
1546
1313
|
if (method === HTTP_METHODS.POST) {
|
|
@@ -1599,6 +1366,7 @@ class PaginationHelpers {
|
|
|
1599
1366
|
serviceAccess: config.serviceAccess,
|
|
1600
1367
|
getEndpoint: config.getEndpoint,
|
|
1601
1368
|
folderId,
|
|
1369
|
+
headers: config.headers,
|
|
1602
1370
|
paginationParams: cursor ? { cursor, pageSize } : jumpToPage ? { jumpToPage, pageSize } : { pageSize },
|
|
1603
1371
|
additionalParams: prefixedOptions,
|
|
1604
1372
|
transformFn: config.transformFn,
|
|
@@ -1616,6 +1384,7 @@ class PaginationHelpers {
|
|
|
1616
1384
|
getAllEndpoint: config.getEndpoint(),
|
|
1617
1385
|
getByFolderEndpoint: byFolderEndpoint,
|
|
1618
1386
|
folderId,
|
|
1387
|
+
headers: config.headers,
|
|
1619
1388
|
additionalParams: prefixedOptions,
|
|
1620
1389
|
transformFn: config.transformFn,
|
|
1621
1390
|
method: config.method,
|