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