@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.
@@ -43,40 +43,31 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
43
43
  };
44
44
 
45
45
  /**
46
- * Base error class for all UiPath SDK errors
47
- * Pure TypeScript class with clean interface
46
+ * Type guards for error response types
48
47
  */
49
- class UiPathError {
50
- constructor(type, params) {
51
- this.type = type;
52
- this.message = params.message;
53
- this.statusCode = params.statusCode;
54
- this.requestId = params.requestId;
55
- this.timestamp = new Date();
56
- // Capture stack trace for debugging
57
- this.stack = (new Error()).stack;
58
- }
59
- /**
60
- * Returns a clean JSON representation of the error
61
- */
62
- toJSON() {
63
- return {
64
- type: this.type,
65
- message: this.message,
66
- statusCode: this.statusCode,
67
- requestId: this.requestId,
68
- timestamp: this.timestamp
69
- };
70
- }
71
- /**
72
- * Returns detailed debug information including stack trace
73
- */
74
- getDebugInfo() {
75
- return {
76
- ...this.toJSON(),
77
- stack: this.stack
78
- };
79
- }
48
+ function isOrchestratorError(error) {
49
+ return typeof error === 'object' &&
50
+ error !== null &&
51
+ 'message' in error &&
52
+ 'errorCode' in error &&
53
+ typeof error.message === 'string' &&
54
+ typeof error.errorCode === 'number';
55
+ }
56
+ function isEntityError(error) {
57
+ return typeof error === 'object' &&
58
+ error !== null &&
59
+ 'error' in error &&
60
+ typeof error.error === 'string';
61
+ }
62
+ function isPimsError(error) {
63
+ return typeof error === 'object' &&
64
+ error !== null &&
65
+ 'type' in error &&
66
+ 'title' in error &&
67
+ 'status' in error &&
68
+ typeof error.type === 'string' &&
69
+ typeof error.title === 'string' &&
70
+ typeof error.status === 'number';
80
71
  }
81
72
 
82
73
  /**
@@ -140,161 +131,6 @@ const ErrorMessages = {
140
131
  const ErrorNames = {
141
132
  ABORT_ERROR: 'AbortError'};
142
133
 
143
- /**
144
- * Error thrown when authentication fails (401 errors)
145
- * Common scenarios:
146
- * - Invalid credentials
147
- * - Expired token
148
- * - Missing authentication
149
- */
150
- class AuthenticationError extends UiPathError {
151
- constructor(params = {}) {
152
- super(ErrorType.AUTHENTICATION, {
153
- message: params.message || ErrorMessages.AUTHENTICATION_FAILED,
154
- statusCode: params.statusCode ?? HttpStatus.UNAUTHORIZED,
155
- requestId: params.requestId
156
- });
157
- }
158
- }
159
-
160
- /**
161
- * Error thrown when authorization fails (403 errors)
162
- * Common scenarios:
163
- * - Insufficient permissions
164
- * - Access denied to resource
165
- * - Invalid scope
166
- */
167
- class AuthorizationError extends UiPathError {
168
- constructor(params = {}) {
169
- super(ErrorType.AUTHORIZATION, {
170
- message: params.message || ErrorMessages.ACCESS_DENIED,
171
- statusCode: params.statusCode ?? HttpStatus.FORBIDDEN,
172
- requestId: params.requestId
173
- });
174
- }
175
- }
176
-
177
- /**
178
- * Error thrown when validation fails (400 errors or client-side validation)
179
- * Common scenarios:
180
- * - Invalid input parameters
181
- * - Missing required fields
182
- * - Invalid data format
183
- */
184
- class ValidationError extends UiPathError {
185
- constructor(params = {}) {
186
- super(ErrorType.VALIDATION, {
187
- message: params.message || ErrorMessages.VALIDATION_FAILED,
188
- statusCode: params.statusCode ?? HttpStatus.BAD_REQUEST,
189
- requestId: params.requestId
190
- });
191
- }
192
- }
193
-
194
- /**
195
- * Error thrown when a resource is not found (404 errors)
196
- * Common scenarios:
197
- * - Resource doesn't exist
198
- * - Invalid ID provided
199
- * - Resource deleted
200
- */
201
- class NotFoundError extends UiPathError {
202
- constructor(params = {}) {
203
- super(ErrorType.NOT_FOUND, {
204
- message: params.message || ErrorMessages.RESOURCE_NOT_FOUND,
205
- statusCode: params.statusCode ?? HttpStatus.NOT_FOUND,
206
- requestId: params.requestId
207
- });
208
- }
209
- }
210
-
211
- /**
212
- * Error thrown when rate limit is exceeded (429 errors)
213
- * Common scenarios:
214
- * - Too many requests in a time window
215
- * - API throttling
216
- */
217
- class RateLimitError extends UiPathError {
218
- constructor(params = {}) {
219
- super(ErrorType.RATE_LIMIT, {
220
- message: params.message || ErrorMessages.RATE_LIMIT_EXCEEDED,
221
- statusCode: params.statusCode ?? HttpStatus.TOO_MANY_REQUESTS,
222
- requestId: params.requestId
223
- });
224
- }
225
- }
226
-
227
- /**
228
- * Error thrown when server encounters an error (5xx errors)
229
- * Common scenarios:
230
- * - Internal server error
231
- * - Service unavailable
232
- * - Gateway timeout
233
- */
234
- class ServerError extends UiPathError {
235
- constructor(params = {}) {
236
- super(ErrorType.SERVER, {
237
- message: params.message || ErrorMessages.INTERNAL_SERVER_ERROR,
238
- statusCode: params.statusCode ?? HttpStatus.INTERNAL_SERVER_ERROR,
239
- requestId: params.requestId
240
- });
241
- }
242
- /**
243
- * Checks if this is a temporary error that might succeed on retry
244
- */
245
- get isRetryable() {
246
- return this.statusCode === HttpStatus.BAD_GATEWAY ||
247
- this.statusCode === HttpStatus.SERVICE_UNAVAILABLE ||
248
- this.statusCode === HttpStatus.GATEWAY_TIMEOUT;
249
- }
250
- }
251
-
252
- /**
253
- * Error thrown when network/connection issues occur
254
- * Common scenarios:
255
- * - Connection timeout
256
- * - DNS resolution failure
257
- * - Network unreachable
258
- * - Request aborted
259
- */
260
- class NetworkError extends UiPathError {
261
- constructor(params = {}) {
262
- super(ErrorType.NETWORK, {
263
- message: params.message || ErrorMessages.NETWORK_ERROR,
264
- statusCode: params.statusCode, // Network errors typically don't have HTTP status codes
265
- requestId: params.requestId
266
- });
267
- }
268
- }
269
-
270
- /**
271
- * Type guards for error response types
272
- */
273
- function isOrchestratorError(error) {
274
- return typeof error === 'object' &&
275
- error !== null &&
276
- 'message' in error &&
277
- 'errorCode' in error &&
278
- typeof error.message === 'string' &&
279
- typeof error.errorCode === 'number';
280
- }
281
- function isEntityError(error) {
282
- return typeof error === 'object' &&
283
- error !== null &&
284
- 'error' in error &&
285
- typeof error.error === 'string';
286
- }
287
- function isPimsError(error) {
288
- return typeof error === 'object' &&
289
- error !== null &&
290
- 'type' in error &&
291
- 'title' in error &&
292
- 'status' in error &&
293
- typeof error.type === 'string' &&
294
- typeof error.title === 'string' &&
295
- typeof error.status === 'number';
296
- }
297
-
298
134
  /**
299
135
  * Parser for Orchestrator/Task error format
300
136
  */
@@ -445,6 +281,173 @@ class ErrorResponseParser {
445
281
  // Export singleton instance
446
282
  const errorResponseParser = new ErrorResponseParser();
447
283
 
284
+ /**
285
+ * Base error class for all UiPath SDK errors
286
+ * Extends Error for standard error handling compatibility
287
+ */
288
+ class UiPathError extends Error {
289
+ constructor(type, params) {
290
+ super(params.message);
291
+ this.name = type;
292
+ this.type = type;
293
+ this.statusCode = params.statusCode;
294
+ this.requestId = params.requestId;
295
+ this.timestamp = new Date();
296
+ // Maintains proper stack trace for where our error was thrown
297
+ if (Error.captureStackTrace) {
298
+ Error.captureStackTrace(this, this.constructor);
299
+ }
300
+ }
301
+ /**
302
+ * Returns a clean JSON representation of the error
303
+ */
304
+ toJSON() {
305
+ return {
306
+ type: this.type,
307
+ message: this.message,
308
+ statusCode: this.statusCode,
309
+ requestId: this.requestId,
310
+ timestamp: this.timestamp
311
+ };
312
+ }
313
+ /**
314
+ * Returns detailed debug information including stack trace
315
+ */
316
+ getDebugInfo() {
317
+ return {
318
+ ...this.toJSON(),
319
+ stack: this.stack
320
+ };
321
+ }
322
+ }
323
+
324
+ /**
325
+ * Error thrown when authentication fails (401 errors)
326
+ * Common scenarios:
327
+ * - Invalid credentials
328
+ * - Expired token
329
+ * - Missing authentication
330
+ */
331
+ class AuthenticationError extends UiPathError {
332
+ constructor(params = {}) {
333
+ super(ErrorType.AUTHENTICATION, {
334
+ message: params.message || ErrorMessages.AUTHENTICATION_FAILED,
335
+ statusCode: params.statusCode ?? HttpStatus.UNAUTHORIZED,
336
+ requestId: params.requestId
337
+ });
338
+ }
339
+ }
340
+
341
+ /**
342
+ * Error thrown when authorization fails (403 errors)
343
+ * Common scenarios:
344
+ * - Insufficient permissions
345
+ * - Access denied to resource
346
+ * - Invalid scope
347
+ */
348
+ class AuthorizationError extends UiPathError {
349
+ constructor(params = {}) {
350
+ super(ErrorType.AUTHORIZATION, {
351
+ message: params.message || ErrorMessages.ACCESS_DENIED,
352
+ statusCode: params.statusCode ?? HttpStatus.FORBIDDEN,
353
+ requestId: params.requestId
354
+ });
355
+ }
356
+ }
357
+
358
+ /**
359
+ * Error thrown when validation fails (400 errors or client-side validation)
360
+ * Common scenarios:
361
+ * - Invalid input parameters
362
+ * - Missing required fields
363
+ * - Invalid data format
364
+ */
365
+ class ValidationError extends UiPathError {
366
+ constructor(params = {}) {
367
+ super(ErrorType.VALIDATION, {
368
+ message: params.message || ErrorMessages.VALIDATION_FAILED,
369
+ statusCode: params.statusCode ?? HttpStatus.BAD_REQUEST,
370
+ requestId: params.requestId
371
+ });
372
+ }
373
+ }
374
+
375
+ /**
376
+ * Error thrown when a resource is not found (404 errors)
377
+ * Common scenarios:
378
+ * - Resource doesn't exist
379
+ * - Invalid ID provided
380
+ * - Resource deleted
381
+ */
382
+ class NotFoundError extends UiPathError {
383
+ constructor(params = {}) {
384
+ super(ErrorType.NOT_FOUND, {
385
+ message: params.message || ErrorMessages.RESOURCE_NOT_FOUND,
386
+ statusCode: params.statusCode ?? HttpStatus.NOT_FOUND,
387
+ requestId: params.requestId
388
+ });
389
+ }
390
+ }
391
+
392
+ /**
393
+ * Error thrown when rate limit is exceeded (429 errors)
394
+ * Common scenarios:
395
+ * - Too many requests in a time window
396
+ * - API throttling
397
+ */
398
+ class RateLimitError extends UiPathError {
399
+ constructor(params = {}) {
400
+ super(ErrorType.RATE_LIMIT, {
401
+ message: params.message || ErrorMessages.RATE_LIMIT_EXCEEDED,
402
+ statusCode: params.statusCode ?? HttpStatus.TOO_MANY_REQUESTS,
403
+ requestId: params.requestId
404
+ });
405
+ }
406
+ }
407
+
408
+ /**
409
+ * Error thrown when server encounters an error (5xx errors)
410
+ * Common scenarios:
411
+ * - Internal server error
412
+ * - Service unavailable
413
+ * - Gateway timeout
414
+ */
415
+ class ServerError extends UiPathError {
416
+ constructor(params = {}) {
417
+ super(ErrorType.SERVER, {
418
+ message: params.message || ErrorMessages.INTERNAL_SERVER_ERROR,
419
+ statusCode: params.statusCode ?? HttpStatus.INTERNAL_SERVER_ERROR,
420
+ requestId: params.requestId
421
+ });
422
+ }
423
+ /**
424
+ * Checks if this is a temporary error that might succeed on retry
425
+ */
426
+ get isRetryable() {
427
+ return this.statusCode === HttpStatus.BAD_GATEWAY ||
428
+ this.statusCode === HttpStatus.SERVICE_UNAVAILABLE ||
429
+ this.statusCode === HttpStatus.GATEWAY_TIMEOUT;
430
+ }
431
+ }
432
+
433
+ /**
434
+ * Error thrown when network/connection issues occur
435
+ * Common scenarios:
436
+ * - Connection timeout
437
+ * - DNS resolution failure
438
+ * - Network unreachable
439
+ * - Request aborted
440
+ */
441
+ class NetworkError extends UiPathError {
442
+ constructor(params = {}) {
443
+ super(ErrorType.NETWORK, {
444
+ message: params.message || ErrorMessages.NETWORK_ERROR,
445
+ statusCode: params.statusCode, // Network errors typically don't have HTTP status codes
446
+ requestId: params.requestId
447
+ });
448
+ }
449
+ }
450
+
448
451
  /**
449
452
  * Factory for creating typed errors based on HTTP status codes
450
453
  * Follows the Factory pattern for clean error instantiation
@@ -538,29 +541,7 @@ class ApiClient {
538
541
  * @throws AuthenticationError if no token available or refresh fails
539
542
  */
540
543
  async getValidToken() {
541
- // Try to get token info from context
542
- const tokenInfo = this.executionContext.get('tokenInfo');
543
- if (!tokenInfo) {
544
- throw new AuthenticationError({ message: 'No authentication token available. Make sure to initialize the SDK first.' });
545
- }
546
- // For secret-based tokens, they never expire
547
- if (tokenInfo.type === 'secret') {
548
- return tokenInfo.token;
549
- }
550
- // If token is not expired, return it
551
- if (!this.tokenManager.isTokenExpired(tokenInfo)) {
552
- return tokenInfo.token;
553
- }
554
- try {
555
- const newToken = await this.tokenManager.refreshAccessToken();
556
- return newToken.access_token;
557
- }
558
- catch (error) {
559
- throw new AuthenticationError({
560
- message: `Token refresh failed: ${error.message}. Please re-authenticate.`,
561
- statusCode: HttpStatus.UNAUTHORIZED
562
- });
563
- }
544
+ return this.tokenManager.getValidToken();
564
545
  }
565
546
  async getDefaultHeaders() {
566
547
  // Get headers from execution context first
@@ -1399,10 +1380,7 @@ class PaginationHelpers {
1399
1380
  */
1400
1381
  static async getAll(config, options) {
1401
1382
  const optionsWithDefaults = options || {};
1402
- const { folderId, ...restOptions } = optionsWithDefaults;
1403
- const cursor = options?.cursor;
1404
- const pageSize = options?.pageSize;
1405
- const jumpToPage = options?.jumpToPage;
1383
+ const { folderId, pageSize, cursor, jumpToPage, ...restOptions } = optionsWithDefaults;
1406
1384
  // Determine if pagination is requested
1407
1385
  const isPaginationRequested = PaginationHelpers.hasPaginationParameters(options || {});
1408
1386
  // Process parameters (custom processing if provided, otherwise default)
@@ -1892,14 +1870,14 @@ const TaskMap = {
1892
1870
  */
1893
1871
  const DEFAULT_TASK_EXPAND = 'AssignedToUser,CreatorUser,LastModifierUser';
1894
1872
 
1895
- /**
1896
- * API Endpoint Constants
1897
- * Centralized location for all API endpoints used throughout the SDK
1898
- */
1899
1873
  /**
1900
1874
  * Base path constants for different services
1901
1875
  */
1902
1876
  const ORCHESTRATOR_BASE = 'orchestrator_';
1877
+
1878
+ /**
1879
+ * Orchestrator Service Endpoints
1880
+ */
1903
1881
  /**
1904
1882
  * Task Service (Action Center) Endpoints
1905
1883
  */
@@ -1924,7 +1902,7 @@ const TASK_ENDPOINTS = {
1924
1902
  // Connection string placeholder that will be replaced during build
1925
1903
  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";
1926
1904
  // SDK Version placeholder
1927
- const SDK_VERSION = "1.0.0";
1905
+ const SDK_VERSION = "1.1.1";
1928
1906
  const VERSION = "Version";
1929
1907
  const SERVICE = "Service";
1930
1908
  const CLOUD_ORGANIZATION_NAME = "CloudOrganizationName";
@@ -2101,7 +2079,6 @@ class TelemetryClient {
2101
2079
  */
2102
2080
  getEnrichedAttributes(extraAttributes, eventName) {
2103
2081
  const attributes = {
2104
- ...extraAttributes,
2105
2082
  [APP_NAME]: SDK_SERVICE_NAME,
2106
2083
  [VERSION]: SDK_VERSION,
2107
2084
  [SERVICE]: eventName,
@@ -2110,6 +2087,7 @@ class TelemetryClient {
2110
2087
  [CLOUD_TENANT_NAME]: this.telemetryContext?.tenantName || UNKNOWN,
2111
2088
  [CLOUD_REDIRECT_URI]: this.telemetryContext?.redirectUri || UNKNOWN,
2112
2089
  [CLOUD_CLIENT_ID]: this.telemetryContext?.clientId || UNKNOWN,
2090
+ ...extraAttributes,
2113
2091
  };
2114
2092
  return attributes;
2115
2093
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uipath/uipath-typescript",
3
- "version": "1.0.0",
3
+ "version": "1.1.1",
4
4
  "description": "UiPath TypeScript SDK",
5
5
  "license": "MIT",
6
6
  "keywords": [
@@ -115,6 +115,16 @@
115
115
  "types": "./dist/maestro-processes/index.d.ts",
116
116
  "default": "./dist/maestro-processes/index.cjs"
117
117
  }
118
+ },
119
+ "./conversational-agent": {
120
+ "import": {
121
+ "types": "./dist/conversational-agent/index.d.ts",
122
+ "default": "./dist/conversational-agent/index.mjs"
123
+ },
124
+ "require": {
125
+ "types": "./dist/conversational-agent/index.d.ts",
126
+ "default": "./dist/conversational-agent/index.cjs"
127
+ }
118
128
  }
119
129
  },
120
130
  "files": [
@@ -127,22 +137,30 @@
127
137
  "build:watch": "rollup -c -w",
128
138
  "clean": "rimraf dist && rimraf node_modules && rimraf package-lock.json",
129
139
  "docs:api": "typedoc && npm run docs:post-process",
130
- "docs:post-process": "mkdir -p docs/api/interfaces/entity && echo '---\ntitle: Entities\n---\n' | cat - docs/api/interfaces/EntityServiceModel.md > docs/api/interfaces/entity/index.md && rm docs/api/interfaces/EntityServiceModel.md",
140
+ "docs:post-process": "node scripts/docs-post-process.mjs",
131
141
  "lint": "oxlint",
132
142
  "typecheck": "tsc --noEmit",
133
143
  "test": "vitest",
134
144
  "test:unit": "vitest tests/unit",
145
+ "test:integration": "vitest --config vitest.integration.config.ts",
146
+ "test:integration:v0": "vitest --config vitest.integration.config.ts --testNamePattern='\\[v0\\]'",
147
+ "test:integration:v1": "vitest --config vitest.integration.config.ts --testNamePattern='\\[v1\\]'",
148
+ "test:integration:smoke": "vitest tests/integration/shared/smoke.integration.test.ts --config vitest.integration.config.ts",
149
+ "test:integration:watch": "vitest --config vitest.integration.config.ts --watch",
150
+ "test:all": "npm run test:unit && npm run test:integration",
135
151
  "test:watch": "vitest --watch",
136
152
  "test:ui": "vitest --ui",
137
153
  "test:coverage": "vitest --coverage"
138
154
  },
139
155
  "dependencies": {
140
- "@opentelemetry/sdk-logs": "^0.204.0"
156
+ "@opentelemetry/sdk-logs": "^0.204.0",
157
+ "socket.io-client": "^4.8.1"
141
158
  },
142
159
  "peerDependencies": {
143
160
  "zod": "^4.2.1"
144
161
  },
145
162
  "devDependencies": {
163
+ "@rollup/plugin-alias": "^6.0.0",
146
164
  "@rollup/plugin-commonjs": "^25.0.0",
147
165
  "@rollup/plugin-json": "^6.0.0",
148
166
  "@rollup/plugin-node-resolve": "^15.2.0",
@@ -169,4 +187,4 @@
169
187
  "workspaces": [
170
188
  "packages/*"
171
189
  ]
172
- }
190
+ }