@uipath/uipath-typescript 1.0.0 → 1.1.1

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/LICENSE CHANGED
@@ -1,9 +1,9 @@
1
1
  MIT License
2
2
 
3
- Copyright 2025 UiPath
3
+ Copyright 2025-present UiPath
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
6
 
7
7
  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
8
 
9
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -269,6 +269,7 @@ The SDK provides access to the following services through modular imports:
269
269
  - `Buckets` from `@uipath/uipath-typescript/buckets` - Manage storage buckets in Orchestrator
270
270
  - `Queues` from `@uipath/uipath-typescript/queues` - Manage Orchestrator queues
271
271
  - `Assets` from `@uipath/uipath-typescript/assets` - Manage Orchestrator assets
272
+ - `ConversationalAgent` from `@uipath/uipath-typescript/conversational-agent` - Interact with Conversational Agents (real-time streaming, conversations, sessions)
272
273
 
273
274
  <details>
274
275
  <summary><strong>View Example Usage</strong></summary>
@@ -395,6 +396,7 @@ await entities.deleteRecordsById('entity-uuid', ['record-id-1', 'record-id-2']);
395
396
  Check out the [`/samples`](./samples) folder to see sample applications built using the SDK:
396
397
 
397
398
  - **[process-app](./samples/process-app)**: A Maestro process management application demonstrating OAuth authentication and SDK usage
399
+ - **[conversational-agent-app](./samples/conversational-agent-app)**: A Conversational Agent chat application with real-time streaming, conversation management, file attachments, tool call visualization, and feedback
398
400
 
399
401
  <div align="right">
400
402
 
@@ -45,40 +45,31 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
45
45
  };
46
46
 
47
47
  /**
48
- * Base error class for all UiPath SDK errors
49
- * Pure TypeScript class with clean interface
48
+ * Type guards for error response types
50
49
  */
51
- class UiPathError {
52
- constructor(type, params) {
53
- this.type = type;
54
- this.message = params.message;
55
- this.statusCode = params.statusCode;
56
- this.requestId = params.requestId;
57
- this.timestamp = new Date();
58
- // Capture stack trace for debugging
59
- this.stack = (new Error()).stack;
60
- }
61
- /**
62
- * Returns a clean JSON representation of the error
63
- */
64
- toJSON() {
65
- return {
66
- type: this.type,
67
- message: this.message,
68
- statusCode: this.statusCode,
69
- requestId: this.requestId,
70
- timestamp: this.timestamp
71
- };
72
- }
73
- /**
74
- * Returns detailed debug information including stack trace
75
- */
76
- getDebugInfo() {
77
- return {
78
- ...this.toJSON(),
79
- stack: this.stack
80
- };
81
- }
50
+ function isOrchestratorError(error) {
51
+ return typeof error === 'object' &&
52
+ error !== null &&
53
+ 'message' in error &&
54
+ 'errorCode' in error &&
55
+ typeof error.message === 'string' &&
56
+ typeof error.errorCode === 'number';
57
+ }
58
+ function isEntityError(error) {
59
+ return typeof error === 'object' &&
60
+ error !== null &&
61
+ 'error' in error &&
62
+ typeof error.error === 'string';
63
+ }
64
+ function isPimsError(error) {
65
+ return typeof error === 'object' &&
66
+ error !== null &&
67
+ 'type' in error &&
68
+ 'title' in error &&
69
+ 'status' in error &&
70
+ typeof error.type === 'string' &&
71
+ typeof error.title === 'string' &&
72
+ typeof error.status === 'number';
82
73
  }
83
74
 
84
75
  /**
@@ -142,161 +133,6 @@ const ErrorMessages = {
142
133
  const ErrorNames = {
143
134
  ABORT_ERROR: 'AbortError'};
144
135
 
145
- /**
146
- * Error thrown when authentication fails (401 errors)
147
- * Common scenarios:
148
- * - Invalid credentials
149
- * - Expired token
150
- * - Missing authentication
151
- */
152
- class AuthenticationError extends UiPathError {
153
- constructor(params = {}) {
154
- super(ErrorType.AUTHENTICATION, {
155
- message: params.message || ErrorMessages.AUTHENTICATION_FAILED,
156
- statusCode: params.statusCode ?? HttpStatus.UNAUTHORIZED,
157
- requestId: params.requestId
158
- });
159
- }
160
- }
161
-
162
- /**
163
- * Error thrown when authorization fails (403 errors)
164
- * Common scenarios:
165
- * - Insufficient permissions
166
- * - Access denied to resource
167
- * - Invalid scope
168
- */
169
- class AuthorizationError extends UiPathError {
170
- constructor(params = {}) {
171
- super(ErrorType.AUTHORIZATION, {
172
- message: params.message || ErrorMessages.ACCESS_DENIED,
173
- statusCode: params.statusCode ?? HttpStatus.FORBIDDEN,
174
- requestId: params.requestId
175
- });
176
- }
177
- }
178
-
179
- /**
180
- * Error thrown when validation fails (400 errors or client-side validation)
181
- * Common scenarios:
182
- * - Invalid input parameters
183
- * - Missing required fields
184
- * - Invalid data format
185
- */
186
- class ValidationError extends UiPathError {
187
- constructor(params = {}) {
188
- super(ErrorType.VALIDATION, {
189
- message: params.message || ErrorMessages.VALIDATION_FAILED,
190
- statusCode: params.statusCode ?? HttpStatus.BAD_REQUEST,
191
- requestId: params.requestId
192
- });
193
- }
194
- }
195
-
196
- /**
197
- * Error thrown when a resource is not found (404 errors)
198
- * Common scenarios:
199
- * - Resource doesn't exist
200
- * - Invalid ID provided
201
- * - Resource deleted
202
- */
203
- class NotFoundError extends UiPathError {
204
- constructor(params = {}) {
205
- super(ErrorType.NOT_FOUND, {
206
- message: params.message || ErrorMessages.RESOURCE_NOT_FOUND,
207
- statusCode: params.statusCode ?? HttpStatus.NOT_FOUND,
208
- requestId: params.requestId
209
- });
210
- }
211
- }
212
-
213
- /**
214
- * Error thrown when rate limit is exceeded (429 errors)
215
- * Common scenarios:
216
- * - Too many requests in a time window
217
- * - API throttling
218
- */
219
- class RateLimitError extends UiPathError {
220
- constructor(params = {}) {
221
- super(ErrorType.RATE_LIMIT, {
222
- message: params.message || ErrorMessages.RATE_LIMIT_EXCEEDED,
223
- statusCode: params.statusCode ?? HttpStatus.TOO_MANY_REQUESTS,
224
- requestId: params.requestId
225
- });
226
- }
227
- }
228
-
229
- /**
230
- * Error thrown when server encounters an error (5xx errors)
231
- * Common scenarios:
232
- * - Internal server error
233
- * - Service unavailable
234
- * - Gateway timeout
235
- */
236
- class ServerError extends UiPathError {
237
- constructor(params = {}) {
238
- super(ErrorType.SERVER, {
239
- message: params.message || ErrorMessages.INTERNAL_SERVER_ERROR,
240
- statusCode: params.statusCode ?? HttpStatus.INTERNAL_SERVER_ERROR,
241
- requestId: params.requestId
242
- });
243
- }
244
- /**
245
- * Checks if this is a temporary error that might succeed on retry
246
- */
247
- get isRetryable() {
248
- return this.statusCode === HttpStatus.BAD_GATEWAY ||
249
- this.statusCode === HttpStatus.SERVICE_UNAVAILABLE ||
250
- this.statusCode === HttpStatus.GATEWAY_TIMEOUT;
251
- }
252
- }
253
-
254
- /**
255
- * Error thrown when network/connection issues occur
256
- * Common scenarios:
257
- * - Connection timeout
258
- * - DNS resolution failure
259
- * - Network unreachable
260
- * - Request aborted
261
- */
262
- class NetworkError extends UiPathError {
263
- constructor(params = {}) {
264
- super(ErrorType.NETWORK, {
265
- message: params.message || ErrorMessages.NETWORK_ERROR,
266
- statusCode: params.statusCode, // Network errors typically don't have HTTP status codes
267
- requestId: params.requestId
268
- });
269
- }
270
- }
271
-
272
- /**
273
- * Type guards for error response types
274
- */
275
- function isOrchestratorError(error) {
276
- return typeof error === 'object' &&
277
- error !== null &&
278
- 'message' in error &&
279
- 'errorCode' in error &&
280
- typeof error.message === 'string' &&
281
- typeof error.errorCode === 'number';
282
- }
283
- function isEntityError(error) {
284
- return typeof error === 'object' &&
285
- error !== null &&
286
- 'error' in error &&
287
- typeof error.error === 'string';
288
- }
289
- function isPimsError(error) {
290
- return typeof error === 'object' &&
291
- error !== null &&
292
- 'type' in error &&
293
- 'title' in error &&
294
- 'status' in error &&
295
- typeof error.type === 'string' &&
296
- typeof error.title === 'string' &&
297
- typeof error.status === 'number';
298
- }
299
-
300
136
  /**
301
137
  * Parser for Orchestrator/Task error format
302
138
  */
@@ -447,6 +283,173 @@ class ErrorResponseParser {
447
283
  // Export singleton instance
448
284
  const errorResponseParser = new ErrorResponseParser();
449
285
 
286
+ /**
287
+ * Base error class for all UiPath SDK errors
288
+ * Extends Error for standard error handling compatibility
289
+ */
290
+ class UiPathError extends Error {
291
+ constructor(type, params) {
292
+ super(params.message);
293
+ this.name = type;
294
+ this.type = type;
295
+ this.statusCode = params.statusCode;
296
+ this.requestId = params.requestId;
297
+ this.timestamp = new Date();
298
+ // Maintains proper stack trace for where our error was thrown
299
+ if (Error.captureStackTrace) {
300
+ Error.captureStackTrace(this, this.constructor);
301
+ }
302
+ }
303
+ /**
304
+ * Returns a clean JSON representation of the error
305
+ */
306
+ toJSON() {
307
+ return {
308
+ type: this.type,
309
+ message: this.message,
310
+ statusCode: this.statusCode,
311
+ requestId: this.requestId,
312
+ timestamp: this.timestamp
313
+ };
314
+ }
315
+ /**
316
+ * Returns detailed debug information including stack trace
317
+ */
318
+ getDebugInfo() {
319
+ return {
320
+ ...this.toJSON(),
321
+ stack: this.stack
322
+ };
323
+ }
324
+ }
325
+
326
+ /**
327
+ * Error thrown when authentication fails (401 errors)
328
+ * Common scenarios:
329
+ * - Invalid credentials
330
+ * - Expired token
331
+ * - Missing authentication
332
+ */
333
+ class AuthenticationError extends UiPathError {
334
+ constructor(params = {}) {
335
+ super(ErrorType.AUTHENTICATION, {
336
+ message: params.message || ErrorMessages.AUTHENTICATION_FAILED,
337
+ statusCode: params.statusCode ?? HttpStatus.UNAUTHORIZED,
338
+ requestId: params.requestId
339
+ });
340
+ }
341
+ }
342
+
343
+ /**
344
+ * Error thrown when authorization fails (403 errors)
345
+ * Common scenarios:
346
+ * - Insufficient permissions
347
+ * - Access denied to resource
348
+ * - Invalid scope
349
+ */
350
+ class AuthorizationError extends UiPathError {
351
+ constructor(params = {}) {
352
+ super(ErrorType.AUTHORIZATION, {
353
+ message: params.message || ErrorMessages.ACCESS_DENIED,
354
+ statusCode: params.statusCode ?? HttpStatus.FORBIDDEN,
355
+ requestId: params.requestId
356
+ });
357
+ }
358
+ }
359
+
360
+ /**
361
+ * Error thrown when validation fails (400 errors or client-side validation)
362
+ * Common scenarios:
363
+ * - Invalid input parameters
364
+ * - Missing required fields
365
+ * - Invalid data format
366
+ */
367
+ class ValidationError extends UiPathError {
368
+ constructor(params = {}) {
369
+ super(ErrorType.VALIDATION, {
370
+ message: params.message || ErrorMessages.VALIDATION_FAILED,
371
+ statusCode: params.statusCode ?? HttpStatus.BAD_REQUEST,
372
+ requestId: params.requestId
373
+ });
374
+ }
375
+ }
376
+
377
+ /**
378
+ * Error thrown when a resource is not found (404 errors)
379
+ * Common scenarios:
380
+ * - Resource doesn't exist
381
+ * - Invalid ID provided
382
+ * - Resource deleted
383
+ */
384
+ class NotFoundError extends UiPathError {
385
+ constructor(params = {}) {
386
+ super(ErrorType.NOT_FOUND, {
387
+ message: params.message || ErrorMessages.RESOURCE_NOT_FOUND,
388
+ statusCode: params.statusCode ?? HttpStatus.NOT_FOUND,
389
+ requestId: params.requestId
390
+ });
391
+ }
392
+ }
393
+
394
+ /**
395
+ * Error thrown when rate limit is exceeded (429 errors)
396
+ * Common scenarios:
397
+ * - Too many requests in a time window
398
+ * - API throttling
399
+ */
400
+ class RateLimitError extends UiPathError {
401
+ constructor(params = {}) {
402
+ super(ErrorType.RATE_LIMIT, {
403
+ message: params.message || ErrorMessages.RATE_LIMIT_EXCEEDED,
404
+ statusCode: params.statusCode ?? HttpStatus.TOO_MANY_REQUESTS,
405
+ requestId: params.requestId
406
+ });
407
+ }
408
+ }
409
+
410
+ /**
411
+ * Error thrown when server encounters an error (5xx errors)
412
+ * Common scenarios:
413
+ * - Internal server error
414
+ * - Service unavailable
415
+ * - Gateway timeout
416
+ */
417
+ class ServerError extends UiPathError {
418
+ constructor(params = {}) {
419
+ super(ErrorType.SERVER, {
420
+ message: params.message || ErrorMessages.INTERNAL_SERVER_ERROR,
421
+ statusCode: params.statusCode ?? HttpStatus.INTERNAL_SERVER_ERROR,
422
+ requestId: params.requestId
423
+ });
424
+ }
425
+ /**
426
+ * Checks if this is a temporary error that might succeed on retry
427
+ */
428
+ get isRetryable() {
429
+ return this.statusCode === HttpStatus.BAD_GATEWAY ||
430
+ this.statusCode === HttpStatus.SERVICE_UNAVAILABLE ||
431
+ this.statusCode === HttpStatus.GATEWAY_TIMEOUT;
432
+ }
433
+ }
434
+
435
+ /**
436
+ * Error thrown when network/connection issues occur
437
+ * Common scenarios:
438
+ * - Connection timeout
439
+ * - DNS resolution failure
440
+ * - Network unreachable
441
+ * - Request aborted
442
+ */
443
+ class NetworkError extends UiPathError {
444
+ constructor(params = {}) {
445
+ super(ErrorType.NETWORK, {
446
+ message: params.message || ErrorMessages.NETWORK_ERROR,
447
+ statusCode: params.statusCode, // Network errors typically don't have HTTP status codes
448
+ requestId: params.requestId
449
+ });
450
+ }
451
+ }
452
+
450
453
  /**
451
454
  * Factory for creating typed errors based on HTTP status codes
452
455
  * Follows the Factory pattern for clean error instantiation
@@ -540,29 +543,7 @@ class ApiClient {
540
543
  * @throws AuthenticationError if no token available or refresh fails
541
544
  */
542
545
  async getValidToken() {
543
- // Try to get token info from context
544
- const tokenInfo = this.executionContext.get('tokenInfo');
545
- if (!tokenInfo) {
546
- throw new AuthenticationError({ message: 'No authentication token available. Make sure to initialize the SDK first.' });
547
- }
548
- // For secret-based tokens, they never expire
549
- if (tokenInfo.type === 'secret') {
550
- return tokenInfo.token;
551
- }
552
- // If token is not expired, return it
553
- if (!this.tokenManager.isTokenExpired(tokenInfo)) {
554
- return tokenInfo.token;
555
- }
556
- try {
557
- const newToken = await this.tokenManager.refreshAccessToken();
558
- return newToken.access_token;
559
- }
560
- catch (error) {
561
- throw new AuthenticationError({
562
- message: `Token refresh failed: ${error.message}. Please re-authenticate.`,
563
- statusCode: HttpStatus.UNAUTHORIZED
564
- });
565
- }
546
+ return this.tokenManager.getValidToken();
566
547
  }
567
548
  async getDefaultHeaders() {
568
549
  // Get headers from execution context first
@@ -1277,10 +1258,7 @@ class PaginationHelpers {
1277
1258
  */
1278
1259
  static async getAll(config, options) {
1279
1260
  const optionsWithDefaults = options || {};
1280
- const { folderId, ...restOptions } = optionsWithDefaults;
1281
- const cursor = options?.cursor;
1282
- const pageSize = options?.pageSize;
1283
- const jumpToPage = options?.jumpToPage;
1261
+ const { folderId, pageSize, cursor, jumpToPage, ...restOptions } = optionsWithDefaults;
1284
1262
  // Determine if pagination is requested
1285
1263
  const isPaginationRequested = PaginationHelpers.hasPaginationParameters(options || {});
1286
1264
  // Process parameters (custom processing if provided, otherwise default)
@@ -1668,14 +1646,14 @@ class FolderScopedService extends BaseService {
1668
1646
  }
1669
1647
  }
1670
1648
 
1671
- /**
1672
- * API Endpoint Constants
1673
- * Centralized location for all API endpoints used throughout the SDK
1674
- */
1675
1649
  /**
1676
1650
  * Base path constants for different services
1677
1651
  */
1678
1652
  const ORCHESTRATOR_BASE = 'orchestrator_';
1653
+
1654
+ /**
1655
+ * Orchestrator Service Endpoints
1656
+ */
1679
1657
  /**
1680
1658
  * Orchestrator Asset Service Endpoints
1681
1659
  */
@@ -1699,7 +1677,7 @@ const AssetMap = {
1699
1677
  // Connection string placeholder that will be replaced during build
1700
1678
  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";
1701
1679
  // SDK Version placeholder
1702
- const SDK_VERSION = "1.0.0";
1680
+ const SDK_VERSION = "1.1.1";
1703
1681
  const VERSION = "Version";
1704
1682
  const SERVICE = "Service";
1705
1683
  const CLOUD_ORGANIZATION_NAME = "CloudOrganizationName";
@@ -1876,7 +1854,6 @@ class TelemetryClient {
1876
1854
  */
1877
1855
  getEnrichedAttributes(extraAttributes, eventName) {
1878
1856
  const attributes = {
1879
- ...extraAttributes,
1880
1857
  [APP_NAME]: SDK_SERVICE_NAME,
1881
1858
  [VERSION]: SDK_VERSION,
1882
1859
  [SERVICE]: eventName,
@@ -1885,6 +1862,7 @@ class TelemetryClient {
1885
1862
  [CLOUD_TENANT_NAME]: this.telemetryContext?.tenantName || UNKNOWN,
1886
1863
  [CLOUD_REDIRECT_URI]: this.telemetryContext?.redirectUri || UNKNOWN,
1887
1864
  [CLOUD_CLIENT_ID]: this.telemetryContext?.clientId || UNKNOWN,
1865
+ ...extraAttributes,
1888
1866
  };
1889
1867
  return attributes;
1890
1868
  }