@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.
Files changed (41) hide show
  1. package/dist/assets/index.cjs +44 -276
  2. package/dist/assets/index.mjs +44 -276
  3. package/dist/attachments/index.cjs +42 -273
  4. package/dist/attachments/index.mjs +42 -273
  5. package/dist/buckets/index.cjs +195 -276
  6. package/dist/buckets/index.d.ts +213 -1
  7. package/dist/buckets/index.mjs +195 -276
  8. package/dist/cases/index.cjs +427 -343
  9. package/dist/cases/index.d.ts +534 -2
  10. package/dist/cases/index.mjs +428 -344
  11. package/dist/conversational-agent/index.cjs +90 -287
  12. package/dist/conversational-agent/index.d.ts +62 -12
  13. package/dist/conversational-agent/index.mjs +90 -288
  14. package/dist/core/index.cjs +39 -289
  15. package/dist/core/index.d.ts +9 -98
  16. package/dist/core/index.mjs +40 -275
  17. package/dist/document-understanding/index.cjs +18 -1
  18. package/dist/document-understanding/index.d.ts +636 -610
  19. package/dist/document-understanding/index.mjs +18 -1
  20. package/dist/entities/index.cjs +251 -277
  21. package/dist/entities/index.d.ts +305 -2
  22. package/dist/entities/index.mjs +251 -277
  23. package/dist/feedback/index.cjs +42 -274
  24. package/dist/feedback/index.mjs +42 -274
  25. package/dist/index.cjs +998 -351
  26. package/dist/index.d.ts +2159 -762
  27. package/dist/index.mjs +998 -337
  28. package/dist/index.umd.js +1208 -237
  29. package/dist/jobs/index.cjs +44 -276
  30. package/dist/jobs/index.mjs +44 -276
  31. package/dist/maestro-processes/index.cjs +1761 -1717
  32. package/dist/maestro-processes/index.d.ts +430 -2
  33. package/dist/maestro-processes/index.mjs +1762 -1718
  34. package/dist/processes/index.cjs +72 -305
  35. package/dist/processes/index.d.ts +76 -26
  36. package/dist/processes/index.mjs +72 -305
  37. package/dist/queues/index.cjs +44 -276
  38. package/dist/queues/index.mjs +44 -276
  39. package/dist/tasks/index.cjs +44 -276
  40. package/dist/tasks/index.mjs +44 -276
  41. 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.8";
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() { ... }
521
- *
522
- * @track("Queue.GetAll")
523
- * async getAll() { ... }
287
+ * UiPath TypeScript SDK Telemetry
524
288
  *
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) {
@@ -1402,9 +1157,9 @@ class PaginationHelpers {
1402
1157
  * @returns Promise resolving to a paginated result
1403
1158
  */
1404
1159
  static async getAllPaginated(params) {
1405
- const { serviceAccess, getEndpoint, folderId, paginationParams, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
1160
+ const { serviceAccess, getEndpoint, folderId, headers: providedHeaders, paginationParams, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
1406
1161
  const endpoint = getEndpoint(folderId);
1407
- const headers = folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {};
1162
+ const headers = providedHeaders ?? (folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {});
1408
1163
  const paginatedResponse = await serviceAccess.requestWithPagination(method, endpoint, paginationParams, {
1409
1164
  headers,
1410
1165
  params: additionalParams,
@@ -1432,13 +1187,13 @@ class PaginationHelpers {
1432
1187
  * @returns Promise resolving to an object with data and totalCount
1433
1188
  */
1434
1189
  static async getAllNonPaginated(params) {
1435
- const { serviceAccess, getAllEndpoint, getByFolderEndpoint, folderId, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
1190
+ const { serviceAccess, getAllEndpoint, getByFolderEndpoint, folderId, headers: providedHeaders, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
1436
1191
  // Set default field names
1437
1192
  const itemsField = options.itemsField || DEFAULT_ITEMS_FIELD;
1438
1193
  const totalCountField = options.totalCountField || DEFAULT_TOTAL_COUNT_FIELD;
1439
1194
  // Determine endpoint and headers based on folderId
1440
1195
  const endpoint = folderId ? getByFolderEndpoint : getAllEndpoint;
1441
- const headers = folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {};
1196
+ const headers = providedHeaders ?? (folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {});
1442
1197
  // Make the API call based on method
1443
1198
  let response;
1444
1199
  if (method === HTTP_METHODS.POST) {
@@ -1497,6 +1252,7 @@ class PaginationHelpers {
1497
1252
  serviceAccess: config.serviceAccess,
1498
1253
  getEndpoint: config.getEndpoint,
1499
1254
  folderId,
1255
+ headers: config.headers,
1500
1256
  paginationParams: cursor ? { cursor, pageSize } : jumpToPage ? { jumpToPage, pageSize } : { pageSize },
1501
1257
  additionalParams: prefixedOptions,
1502
1258
  transformFn: config.transformFn,
@@ -1514,6 +1270,7 @@ class PaginationHelpers {
1514
1270
  getAllEndpoint: config.getEndpoint(),
1515
1271
  getByFolderEndpoint: byFolderEndpoint,
1516
1272
  folderId,
1273
+ headers: config.headers,
1517
1274
  additionalParams: prefixedOptions,
1518
1275
  transformFn: config.transformFn,
1519
1276
  method: config.method,
@@ -1843,14 +1600,25 @@ class ApiClient {
1843
1600
  if (!text) {
1844
1601
  return undefined;
1845
1602
  }
1846
- return JSON.parse(text);
1603
+ try {
1604
+ return JSON.parse(text);
1605
+ }
1606
+ catch (error) {
1607
+ if (error instanceof SyntaxError) {
1608
+ throw new ServerError({
1609
+ message: `Server returned non-JSON response (${response.status} ${response.url}): ${error.message}`,
1610
+ statusCode: response.status,
1611
+ });
1612
+ }
1613
+ throw error;
1614
+ }
1847
1615
  }
1848
1616
  catch (error) {
1849
1617
  // If it's already one of our errors, re-throw it
1850
1618
  if (error.type && error.type.includes('Error')) {
1851
1619
  throw error;
1852
1620
  }
1853
- // Otherwise, it's likely a network error
1621
+ // Otherwise, it's a genuine network/fetch failure
1854
1622
  throw ErrorFactory.createNetworkError(error);
1855
1623
  }
1856
1624
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uipath/uipath-typescript",
3
- "version": "1.3.8",
3
+ "version": "1.3.10",
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
  }