@uipath/uipath-typescript 1.0.0-beta.18 → 1.1.0

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 (39) hide show
  1. package/LICENSE +2 -2
  2. package/README.md +100 -40
  3. package/dist/assets/index.cjs +2068 -0
  4. package/dist/assets/index.d.ts +513 -0
  5. package/dist/assets/index.mjs +2065 -0
  6. package/dist/buckets/index.cjs +2342 -0
  7. package/dist/buckets/index.d.ts +819 -0
  8. package/dist/buckets/index.mjs +2339 -0
  9. package/dist/cases/index.cjs +3475 -0
  10. package/dist/cases/index.d.ts +1397 -0
  11. package/dist/cases/index.mjs +3469 -0
  12. package/dist/conversational-agent/index.cjs +6622 -0
  13. package/dist/conversational-agent/index.d.ts +6579 -0
  14. package/dist/conversational-agent/index.mjs +6575 -0
  15. package/dist/core/index.cjs +5305 -0
  16. package/dist/core/index.d.ts +398 -0
  17. package/dist/core/index.mjs +5279 -0
  18. package/dist/entities/index.cjs +2727 -0
  19. package/dist/entities/index.d.ts +1513 -0
  20. package/dist/entities/index.mjs +2721 -0
  21. package/dist/index.cjs +3651 -2935
  22. package/dist/index.d.ts +5341 -590
  23. package/dist/index.mjs +3644 -2935
  24. package/dist/index.umd.js +8118 -11244
  25. package/dist/maestro-processes/index.cjs +2587 -0
  26. package/dist/maestro-processes/index.d.ts +1127 -0
  27. package/dist/maestro-processes/index.mjs +2578 -0
  28. package/dist/processes/index.cjs +2247 -0
  29. package/dist/processes/index.d.ts +800 -0
  30. package/dist/processes/index.mjs +2244 -0
  31. package/dist/queues/index.cjs +2053 -0
  32. package/dist/queues/index.d.ts +504 -0
  33. package/dist/queues/index.mjs +2050 -0
  34. package/dist/tasks/index.cjs +2653 -0
  35. package/dist/tasks/index.d.ts +1122 -0
  36. package/dist/tasks/index.mjs +2649 -0
  37. package/package.json +118 -6
  38. package/dist/index.d.cts +0 -5463
  39. package/dist/index.d.mts +0 -5463
@@ -0,0 +1,2342 @@
1
+ 'use strict';
2
+
3
+ var sdkLogs = require('@opentelemetry/sdk-logs');
4
+
5
+ /******************************************************************************
6
+ Copyright (c) Microsoft Corporation.
7
+
8
+ Permission to use, copy, modify, and/or distribute this software for any
9
+ purpose with or without fee is hereby granted.
10
+
11
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
12
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
13
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
14
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
16
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17
+ PERFORMANCE OF THIS SOFTWARE.
18
+ ***************************************************************************** */
19
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
20
+
21
+
22
+ function __decorate(decorators, target, key, desc) {
23
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
24
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
25
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
26
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
27
+ }
28
+
29
+ function __classPrivateFieldGet(receiver, state, kind, f) {
30
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
31
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
32
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
33
+ }
34
+
35
+ function __classPrivateFieldSet(receiver, state, value, kind, f) {
36
+ if (kind === "m") throw new TypeError("Private method is not writable");
37
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
38
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
39
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
40
+ }
41
+
42
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
43
+ var e = new Error(message);
44
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
45
+ };
46
+
47
+ /**
48
+ * Type guards for error response types
49
+ */
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';
73
+ }
74
+
75
+ /**
76
+ * HTTP status code constants for error handling
77
+ */
78
+ const HttpStatus = {
79
+ // Client errors (4xx)
80
+ BAD_REQUEST: 400,
81
+ UNAUTHORIZED: 401,
82
+ FORBIDDEN: 403,
83
+ NOT_FOUND: 404,
84
+ TOO_MANY_REQUESTS: 429,
85
+ // Server errors (5xx)
86
+ INTERNAL_SERVER_ERROR: 500,
87
+ BAD_GATEWAY: 502,
88
+ SERVICE_UNAVAILABLE: 503,
89
+ GATEWAY_TIMEOUT: 504
90
+ };
91
+ /**
92
+ * Error type constants for consistent error identification
93
+ */
94
+ const ErrorType = {
95
+ AUTHENTICATION: 'AuthenticationError',
96
+ AUTHORIZATION: 'AuthorizationError',
97
+ VALIDATION: 'ValidationError',
98
+ NOT_FOUND: 'NotFoundError',
99
+ RATE_LIMIT: 'RateLimitError',
100
+ SERVER: 'ServerError',
101
+ NETWORK: 'NetworkError'
102
+ };
103
+ /**
104
+ * HTTP header constants for error handling
105
+ */
106
+ const HttpHeaders = {
107
+ X_REQUEST_ID: 'x-request-id'
108
+ };
109
+ /**
110
+ * Standard error message constants
111
+ */
112
+ const ErrorMessages = {
113
+ // Authentication errors
114
+ AUTHENTICATION_FAILED: 'Authentication failed',
115
+ // Authorization errors
116
+ ACCESS_DENIED: 'Access denied',
117
+ // Validation errors
118
+ VALIDATION_FAILED: 'Validation failed',
119
+ // Not found errors
120
+ RESOURCE_NOT_FOUND: 'Resource not found',
121
+ // Rate limit errors
122
+ RATE_LIMIT_EXCEEDED: 'Rate limit exceeded',
123
+ // Server errors
124
+ INTERNAL_SERVER_ERROR: 'Internal Server error occurred',
125
+ // Network errors
126
+ NETWORK_ERROR: 'Network error occurred',
127
+ REQUEST_TIMEOUT: 'Request timed out',
128
+ REQUEST_ABORTED: 'Request was aborted',
129
+ };
130
+ /**
131
+ * Error name constants for network error identification
132
+ */
133
+ const ErrorNames = {
134
+ ABORT_ERROR: 'AbortError'};
135
+
136
+ /**
137
+ * Parser for Orchestrator/Task error format
138
+ */
139
+ class OrchestratorErrorParser {
140
+ canParse(errorBody) {
141
+ return isOrchestratorError(errorBody);
142
+ }
143
+ parse(errorBody, response) {
144
+ const error = errorBody;
145
+ return {
146
+ message: error.message,
147
+ code: response?.status?.toString(),
148
+ details: {
149
+ errorCode: error.errorCode,
150
+ traceId: error.traceId,
151
+ originalResponse: error
152
+ },
153
+ requestId: error.traceId
154
+ };
155
+ }
156
+ }
157
+ /**
158
+ * Parser for Entity (Data Fabric) error format
159
+ */
160
+ class EntityErrorParser {
161
+ canParse(errorBody) {
162
+ return isEntityError(errorBody);
163
+ }
164
+ parse(errorBody, response) {
165
+ const error = errorBody;
166
+ return {
167
+ message: error.error,
168
+ code: response?.status?.toString(),
169
+ details: {
170
+ error: error.error,
171
+ traceId: error.traceId,
172
+ originalResponse: error
173
+ },
174
+ requestId: error.traceId
175
+ };
176
+ }
177
+ }
178
+ /**
179
+ * Parser for PIMS error format
180
+ */
181
+ class PimsErrorParser {
182
+ canParse(errorBody) {
183
+ return isPimsError(errorBody);
184
+ }
185
+ parse(errorBody, response) {
186
+ const error = errorBody;
187
+ let message = error.title;
188
+ // If there are validation errors, append them to the message for better visibility
189
+ if (error.errors && Object.keys(error.errors).length > 0) {
190
+ const errorMessages = Object.entries(error.errors)
191
+ .map(([field, messages]) => `${field}: ${messages.join(', ')}`)
192
+ .join('; ');
193
+ message += `. Validation errors: ${errorMessages}`;
194
+ }
195
+ return {
196
+ message,
197
+ code: response?.status?.toString(),
198
+ details: {
199
+ type: error.type,
200
+ title: error.title,
201
+ status: error.status,
202
+ errors: error.errors,
203
+ traceId: error.traceId,
204
+ originalResponse: error
205
+ },
206
+ requestId: error.traceId
207
+ };
208
+ }
209
+ }
210
+ /**
211
+ * Fallback parser for unrecognized formats
212
+ */
213
+ class GenericErrorParser {
214
+ canParse(_errorBody) {
215
+ return true; // Always can parse as last resort
216
+ }
217
+ parse(errorBody, response) {
218
+ // For unknown error formats, just pass through the raw error with fallback message
219
+ const message = response?.statusText || 'An error occurred';
220
+ return {
221
+ message,
222
+ code: response?.status?.toString(),
223
+ details: {
224
+ originalResponse: errorBody
225
+ },
226
+ };
227
+ }
228
+ }
229
+ /**
230
+ * Main error response parser using Chain of Responsibility pattern
231
+ *
232
+ * This parser standardizes error responses from different UiPath services into a
233
+ * consistent format, regardless of the original error structure.
234
+ *
235
+ * Supported formats:
236
+ * 1. Orchestrator/Task: { message, errorCode, traceId }
237
+ * 2. Entity (Data Fabric): { error, traceId }
238
+ * 3. PIMS/Maestro: { type, title, status, errors?, traceId? }
239
+ * 4. Generic: Fallback for any other format
240
+ *
241
+ * @example
242
+ * const parser = new ErrorResponseParser();
243
+ * const errorInfo = await parser.parse(response);
244
+ * // errorInfo will have consistent structure regardless of service
245
+ */
246
+ class ErrorResponseParser {
247
+ constructor() {
248
+ this.strategies = [
249
+ new OrchestratorErrorParser(),
250
+ new EntityErrorParser(),
251
+ new PimsErrorParser(),
252
+ new GenericErrorParser() // Must be last
253
+ ];
254
+ }
255
+ /**
256
+ * Parses error response body into standardized format
257
+ * @param response - The HTTP response object
258
+ * @returns Standardized error information
259
+ */
260
+ async parse(response) {
261
+ try {
262
+ const errorBody = await response.json();
263
+ // Find the first strategy that can parse this error format
264
+ const strategy = this.strategies.find(s => s.canParse(errorBody));
265
+ // GenericErrorParser always returns true, so this will never be null
266
+ return strategy.parse(errorBody, response);
267
+ }
268
+ catch {
269
+ // Handle non-JSON responses
270
+ const responseText = await response.text().catch(() => '');
271
+ return {
272
+ message: response.statusText,
273
+ code: response.status.toString(),
274
+ details: {
275
+ parseError: 'Failed to parse error response as JSON',
276
+ responseText
277
+ },
278
+ requestId: response.headers.get(HttpHeaders.X_REQUEST_ID) || undefined
279
+ };
280
+ }
281
+ }
282
+ }
283
+ // Export singleton instance
284
+ const errorResponseParser = new ErrorResponseParser();
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
+
453
+ /**
454
+ * Factory for creating typed errors based on HTTP status codes
455
+ * Follows the Factory pattern for clean error instantiation
456
+ */
457
+ class ErrorFactory {
458
+ /**
459
+ * Creates appropriate error instance based on HTTP status code
460
+ */
461
+ static createFromHttpStatus(statusCode, errorInfo) {
462
+ const { message, requestId } = errorInfo;
463
+ // Map status codes to error types
464
+ switch (statusCode) {
465
+ case HttpStatus.BAD_REQUEST:
466
+ return new ValidationError({ message, statusCode, requestId });
467
+ case HttpStatus.UNAUTHORIZED:
468
+ return new AuthenticationError({ message, statusCode, requestId });
469
+ case HttpStatus.FORBIDDEN:
470
+ return new AuthorizationError({ message, statusCode, requestId });
471
+ case HttpStatus.NOT_FOUND:
472
+ return new NotFoundError({ message, statusCode, requestId });
473
+ case HttpStatus.TOO_MANY_REQUESTS:
474
+ return new RateLimitError({ message, statusCode, requestId });
475
+ default:
476
+ // For 5xx errors or any other status code
477
+ if (statusCode >= HttpStatus.INTERNAL_SERVER_ERROR) {
478
+ return new ServerError({ message, statusCode, requestId });
479
+ }
480
+ // For unknown client errors, treat as validation error
481
+ return new ValidationError({
482
+ message: `${message} (HTTP ${statusCode})`,
483
+ statusCode,
484
+ requestId
485
+ });
486
+ }
487
+ }
488
+ /**
489
+ * Creates a NetworkError from a fetch/network error
490
+ */
491
+ static createNetworkError(error) {
492
+ let message = ErrorMessages.NETWORK_ERROR;
493
+ if (error instanceof Error) {
494
+ if (error.name === ErrorNames.ABORT_ERROR) {
495
+ message = ErrorMessages.REQUEST_ABORTED;
496
+ }
497
+ else if (error.message.includes('timeout')) {
498
+ message = ErrorMessages.REQUEST_TIMEOUT;
499
+ }
500
+ else {
501
+ message = error.message;
502
+ }
503
+ }
504
+ return new NetworkError({ message });
505
+ }
506
+ }
507
+
508
+ const FOLDER_ID = 'X-UIPATH-OrganizationUnitId';
509
+ /**
510
+ * Content type constants for HTTP requests/responses
511
+ */
512
+ const CONTENT_TYPES = {
513
+ JSON: 'application/json',
514
+ XML: 'application/xml',
515
+ OCTET_STREAM: 'application/octet-stream'
516
+ };
517
+ /**
518
+ * Response type constants for HTTP requests
519
+ */
520
+ const RESPONSE_TYPES = {
521
+ JSON: 'json',
522
+ TEXT: 'text',
523
+ BLOB: 'blob',
524
+ ARRAYBUFFER: 'arraybuffer'
525
+ };
526
+
527
+ class ApiClient {
528
+ constructor(config, executionContext, tokenManager, clientConfig = {}) {
529
+ this.defaultHeaders = {};
530
+ this.config = config;
531
+ this.executionContext = executionContext;
532
+ this.clientConfig = clientConfig;
533
+ this.tokenManager = tokenManager;
534
+ }
535
+ setDefaultHeaders(headers) {
536
+ this.defaultHeaders = { ...this.defaultHeaders, ...headers };
537
+ }
538
+ /**
539
+ * Gets a valid authentication token, refreshing if necessary.
540
+ * Used internally for API requests and exposed for services that need manual auth headers.
541
+ *
542
+ * @returns The valid token
543
+ * @throws AuthenticationError if no token available or refresh fails
544
+ */
545
+ async getValidToken() {
546
+ return this.tokenManager.getValidToken();
547
+ }
548
+ async getDefaultHeaders() {
549
+ // Get headers from execution context first
550
+ const contextHeaders = this.executionContext.getHeaders();
551
+ // If Authorization header is already set in context, use that
552
+ if (contextHeaders['Authorization']) {
553
+ return {
554
+ ...contextHeaders,
555
+ 'Content-Type': CONTENT_TYPES.JSON,
556
+ ...this.defaultHeaders,
557
+ ...this.clientConfig.headers
558
+ };
559
+ }
560
+ const token = await this.getValidToken();
561
+ return {
562
+ ...contextHeaders,
563
+ 'Authorization': `Bearer ${token}`,
564
+ 'Content-Type': CONTENT_TYPES.JSON,
565
+ ...this.defaultHeaders,
566
+ ...this.clientConfig.headers
567
+ };
568
+ }
569
+ async request(method, path, options = {}) {
570
+ // Ensure path starts with a forward slash
571
+ const normalizedPath = path.startsWith('/') ? path.substring(1) : path;
572
+ // Construct URL with org and tenant names
573
+ const url = new URL(`${this.config.orgName}/${this.config.tenantName}/${normalizedPath}`, this.config.baseUrl).toString();
574
+ const headers = {
575
+ ...await this.getDefaultHeaders(),
576
+ ...options.headers
577
+ };
578
+ // Convert params to URLSearchParams
579
+ const searchParams = new URLSearchParams();
580
+ if (options.params) {
581
+ Object.entries(options.params).forEach(([key, value]) => {
582
+ searchParams.append(key, value.toString());
583
+ });
584
+ }
585
+ const fullUrl = searchParams.toString() ? `${url}?${searchParams.toString()}` : url;
586
+ try {
587
+ const response = await fetch(fullUrl, {
588
+ method,
589
+ headers,
590
+ body: options.body ? JSON.stringify(options.body) : undefined,
591
+ signal: options.signal
592
+ });
593
+ if (!response.ok) {
594
+ const errorInfo = await errorResponseParser.parse(response);
595
+ throw ErrorFactory.createFromHttpStatus(response.status, errorInfo);
596
+ }
597
+ if (response.status === 204) {
598
+ return undefined;
599
+ }
600
+ // Handle blob response type for binary data (e.g., file downloads)
601
+ if (options.responseType === RESPONSE_TYPES.BLOB) {
602
+ const blob = await response.blob();
603
+ return blob;
604
+ }
605
+ // Check if we're expecting XML
606
+ const acceptHeader = headers['Accept'] || headers['accept'];
607
+ if (acceptHeader === CONTENT_TYPES.XML) {
608
+ const text = await response.text();
609
+ return text;
610
+ }
611
+ return response.json();
612
+ }
613
+ catch (error) {
614
+ // If it's already one of our errors, re-throw it
615
+ if (error.type && error.type.includes('Error')) {
616
+ throw error;
617
+ }
618
+ // Otherwise, it's likely a network error
619
+ throw ErrorFactory.createNetworkError(error);
620
+ }
621
+ }
622
+ async get(path, options = {}) {
623
+ return this.request('GET', path, options);
624
+ }
625
+ async post(path, data, options = {}) {
626
+ return this.request('POST', path, { ...options, body: data });
627
+ }
628
+ async put(path, data, options = {}) {
629
+ return this.request('PUT', path, { ...options, body: data });
630
+ }
631
+ async patch(path, data, options = {}) {
632
+ return this.request('PATCH', path, { ...options, body: data });
633
+ }
634
+ async delete(path, options = {}) {
635
+ return this.request('DELETE', path, options);
636
+ }
637
+ }
638
+
639
+ /**
640
+ * Pagination types supported by the SDK
641
+ */
642
+ var PaginationType;
643
+ (function (PaginationType) {
644
+ PaginationType["OFFSET"] = "offset";
645
+ PaginationType["TOKEN"] = "token";
646
+ })(PaginationType || (PaginationType = {}));
647
+
648
+ /**
649
+ * Collection of utility functions for working with objects
650
+ */
651
+ /**
652
+ * Filters out undefined values from an object
653
+ * @param obj The source object
654
+ * @returns A new object without undefined values
655
+ *
656
+ * @example
657
+ * ```typescript
658
+ * // Object with undefined values
659
+ * const options = {
660
+ * name: 'test',
661
+ * count: 5,
662
+ * prefix: undefined,
663
+ * suffix: null
664
+ * };
665
+ * const result = filterUndefined(options);
666
+ * // result = { name: 'test', count: 5, suffix: null }
667
+ * ```
668
+ */
669
+ function filterUndefined(obj) {
670
+ const result = {};
671
+ for (const [key, value] of Object.entries(obj)) {
672
+ if (value !== undefined) {
673
+ result[key] = value;
674
+ }
675
+ }
676
+ return result;
677
+ }
678
+
679
+ /**
680
+ * Utility functions for platform detection
681
+ */
682
+ /**
683
+ * Checks if code is running in a browser environment
684
+ */
685
+ const isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
686
+
687
+ /**
688
+ * Base64 encoding/decoding
689
+ */
690
+ /**
691
+ * Encodes a string to base64
692
+ * @param str - The string to encode
693
+ * @returns Base64 encoded string
694
+ */
695
+ function encodeBase64(str) {
696
+ // TextEncoder for UTF-8 encoding (works in both browser and Node.js)
697
+ const encoder = new TextEncoder();
698
+ const data = encoder.encode(str);
699
+ // Convert Uint8Array to base64
700
+ if (isBrowser) {
701
+ // Browser environment
702
+ // Convert Uint8Array to binary string then to base64
703
+ const binaryString = Array.from(data, byte => String.fromCharCode(byte)).join('');
704
+ return btoa(binaryString);
705
+ }
706
+ else {
707
+ // Node.js environment
708
+ return Buffer.from(data).toString('base64');
709
+ }
710
+ }
711
+ /**
712
+ * Decodes a base64 string
713
+ * @param base64 - The base64 string to decode
714
+ * @returns Decoded string
715
+ */
716
+ function decodeBase64(base64) {
717
+ let bytes;
718
+ if (isBrowser) {
719
+ // Browser environment
720
+ const binaryString = atob(base64);
721
+ bytes = new Uint8Array(binaryString.length);
722
+ for (let i = 0; i < binaryString.length; i++) {
723
+ bytes[i] = binaryString.charCodeAt(i);
724
+ }
725
+ }
726
+ else {
727
+ // Node.js environment
728
+ bytes = new Uint8Array(Buffer.from(base64, 'base64'));
729
+ }
730
+ // TextDecoder for UTF-8 decoding (works in both browser and Node.js)
731
+ const decoder = new TextDecoder();
732
+ return decoder.decode(bytes);
733
+ }
734
+
735
+ /**
736
+ * PaginationManager handles the conversion between uniform cursor-based pagination
737
+ * and the specific pagination type for each service
738
+ */
739
+ class PaginationManager {
740
+ /**
741
+ * Create a pagination cursor for subsequent page requests
742
+ */
743
+ static createCursor({ pageInfo, type }) {
744
+ if (!pageInfo.hasMore) {
745
+ return undefined;
746
+ }
747
+ const cursorData = {
748
+ type,
749
+ pageSize: pageInfo.pageSize,
750
+ };
751
+ switch (type) {
752
+ case PaginationType.OFFSET:
753
+ if (pageInfo.currentPage) {
754
+ cursorData.pageNumber = pageInfo.currentPage + 1;
755
+ }
756
+ break;
757
+ case PaginationType.TOKEN:
758
+ if (pageInfo.continuationToken) {
759
+ cursorData.continuationToken = pageInfo.continuationToken;
760
+ }
761
+ else {
762
+ return undefined; // No continuation token, can't continue
763
+ }
764
+ break;
765
+ }
766
+ return {
767
+ value: encodeBase64(JSON.stringify(cursorData))
768
+ };
769
+ }
770
+ /**
771
+ * Create a paginated response with navigation cursors
772
+ */
773
+ static createPaginatedResponse({ pageInfo, type }, items) {
774
+ const nextCursor = PaginationManager.createCursor({ pageInfo, type });
775
+ // Create previous page cursor if applicable
776
+ let previousCursor = undefined;
777
+ if (pageInfo.currentPage && pageInfo.currentPage > 1) {
778
+ const prevCursorData = {
779
+ type,
780
+ pageNumber: pageInfo.currentPage - 1,
781
+ pageSize: pageInfo.pageSize,
782
+ };
783
+ previousCursor = {
784
+ value: encodeBase64(JSON.stringify(prevCursorData))
785
+ };
786
+ }
787
+ // Calculate total pages if we have totalCount and pageSize
788
+ let totalPages = undefined;
789
+ if (pageInfo.totalCount !== undefined && pageInfo.pageSize) {
790
+ totalPages = Math.ceil(pageInfo.totalCount / pageInfo.pageSize);
791
+ }
792
+ // Determine if this pagination type supports page jumping
793
+ const supportsPageJump = type === PaginationType.OFFSET;
794
+ // Create the result object with all fields, then filter out undefined values
795
+ const result = filterUndefined({
796
+ items,
797
+ totalCount: pageInfo.totalCount,
798
+ hasNextPage: pageInfo.hasMore,
799
+ nextCursor: nextCursor,
800
+ previousCursor: previousCursor,
801
+ currentPage: pageInfo.currentPage,
802
+ totalPages,
803
+ supportsPageJump
804
+ });
805
+ return result;
806
+ }
807
+ }
808
+
809
+ /**
810
+ * Creates headers object from key-value pairs
811
+ * @param headersObj - Object containing header key-value pairs
812
+ * @returns Headers object with all values converted to strings
813
+ *
814
+ * @example
815
+ * ```typescript
816
+ * // Single header
817
+ * const headers = createHeaders({ 'X-UIPATH-FolderKey': '1234567890' });
818
+ *
819
+ * // Multiple headers
820
+ * const headers = createHeaders({
821
+ * 'X-UIPATH-FolderKey': '1234567890',
822
+ * 'X-UIPATH-OrganizationUnitId': 123,
823
+ * 'Accept': 'application/json'
824
+ * });
825
+ *
826
+ * // Using constants
827
+ * import { FOLDER_KEY, FOLDER_ID } from '../constants/headers';
828
+ * const headers = createHeaders({
829
+ * [FOLDER_KEY]: 'abc-123',
830
+ * [FOLDER_ID]: 456
831
+ * });
832
+ *
833
+ * // Empty headers
834
+ * const headers = createHeaders();
835
+ * ```
836
+ */
837
+ function createHeaders(headersObj) {
838
+ const headers = {};
839
+ for (const [key, value] of Object.entries(headersObj)) {
840
+ if (value !== undefined && value !== null) {
841
+ headers[key] = value.toString();
842
+ }
843
+ }
844
+ return headers;
845
+ }
846
+
847
+ /**
848
+ * Common constants used across the SDK
849
+ */
850
+ /**
851
+ * Prefix used for OData query parameters
852
+ */
853
+ const ODATA_PREFIX = '$';
854
+ /**
855
+ * HTTP methods
856
+ */
857
+ const HTTP_METHODS = {
858
+ GET: 'GET',
859
+ POST: 'POST'};
860
+ /**
861
+ * OData pagination constants
862
+ */
863
+ const ODATA_PAGINATION = {
864
+ /** Default field name for items in a paginated OData response */
865
+ ITEMS_FIELD: 'value',
866
+ /** Default field name for total count in a paginated OData response */
867
+ TOTAL_COUNT_FIELD: '@odata.count'
868
+ };
869
+ /**
870
+ * Bucket pagination constants for token-based pagination
871
+ */
872
+ const BUCKET_PAGINATION = {
873
+ /** Field name for items in bucket file metadata response */
874
+ ITEMS_FIELD: 'items',
875
+ /** Field name for continuation token in bucket file metadata response */
876
+ CONTINUATION_TOKEN_FIELD: 'continuationToken'
877
+ };
878
+ /**
879
+ * OData OFFSET pagination parameter names (ODATA-style)
880
+ */
881
+ const ODATA_OFFSET_PARAMS = {
882
+ /** OData page size parameter name */
883
+ PAGE_SIZE_PARAM: '$top',
884
+ /** OData offset parameter name */
885
+ OFFSET_PARAM: '$skip',
886
+ /** OData count parameter name */
887
+ COUNT_PARAM: '$count'
888
+ };
889
+ /**
890
+ * Bucket TOKEN pagination parameter names
891
+ */
892
+ const BUCKET_TOKEN_PARAMS = {
893
+ /** Bucket page size parameter name */
894
+ PAGE_SIZE_PARAM: 'takeHint',
895
+ /** Bucket token parameter name */
896
+ TOKEN_PARAM: 'continuationToken'
897
+ };
898
+
899
+ /**
900
+ * Transforms data by mapping fields according to the provided field mapping
901
+ * @param data The source data to transform
902
+ * @param fieldMapping Object mapping source field names to target field names
903
+ * @returns Transformed data with mapped field names
904
+ *
905
+ * @example
906
+ * ```typescript
907
+ * // Single object transformation
908
+ * const data = { id: '123', userName: 'john' };
909
+ * const mapping = { id: 'userId', userName: 'name' };
910
+ * const result = transformData(data, mapping);
911
+ * // result = { userId: '123', name: 'john' }
912
+ *
913
+ * // Array transformation
914
+ * const dataArray = [
915
+ * { id: '123', userName: 'john' },
916
+ * { id: '456', userName: 'jane' }
917
+ * ];
918
+ * const result = transformData(dataArray, mapping);
919
+ * // result = [
920
+ * // { userId: '123', name: 'john' },
921
+ * // { userId: '456', name: 'jane' }
922
+ * // ]
923
+ * ```
924
+ */
925
+ function transformData(data, fieldMapping) {
926
+ // Handle array of objects
927
+ if (Array.isArray(data)) {
928
+ return data.map(item => transformData(item, fieldMapping));
929
+ }
930
+ // Handle single object
931
+ const result = { ...data };
932
+ for (const [sourceField, targetField] of Object.entries(fieldMapping)) {
933
+ if (sourceField in result) {
934
+ const value = result[sourceField];
935
+ delete result[sourceField];
936
+ result[targetField] = value;
937
+ }
938
+ }
939
+ return result;
940
+ }
941
+ /**
942
+ * Converts a string from PascalCase to camelCase
943
+ * @param str The PascalCase string to convert
944
+ * @returns The camelCase version of the string
945
+ *
946
+ * @example
947
+ * ```typescript
948
+ * pascalToCamelCase('HelloWorld'); // 'helloWorld'
949
+ * pascalToCamelCase('TaskAssignmentCriteria'); // 'taskAssignmentCriteria'
950
+ * ```
951
+ */
952
+ function pascalToCamelCase(str) {
953
+ if (!str)
954
+ return str;
955
+ return str.charAt(0).toLowerCase() + str.slice(1);
956
+ }
957
+ /**
958
+ * Generic function to transform object keys using a provided case conversion function
959
+ * @param data The object to transform
960
+ * @param convertCase The function to convert each key
961
+ * @returns A new object with transformed keys
962
+ */
963
+ function transformCaseKeys(data, convertCase) {
964
+ // Handle array of objects
965
+ if (Array.isArray(data)) {
966
+ return data.map(item => {
967
+ // If the array element is a primitive (string, number, etc.), return it as is
968
+ if (item === null || typeof item !== 'object' || typeof item === 'string') {
969
+ return item;
970
+ }
971
+ // Only recursively transform if it's actually an object
972
+ return transformCaseKeys(item, convertCase);
973
+ });
974
+ }
975
+ const result = {};
976
+ for (const [key, value] of Object.entries(data)) {
977
+ const transformedKey = convertCase(key);
978
+ // Recursively transform nested objects and arrays
979
+ if (value !== null && typeof value === 'object') {
980
+ result[transformedKey] = transformCaseKeys(value, convertCase);
981
+ }
982
+ else {
983
+ result[transformedKey] = value;
984
+ }
985
+ }
986
+ return result;
987
+ }
988
+ /**
989
+ * Transforms an object's keys from PascalCase to camelCase
990
+ * @param data The object with PascalCase keys
991
+ * @returns A new object with all keys converted to camelCase
992
+ *
993
+ * @example
994
+ * ```typescript
995
+ * // Simple object
996
+ * pascalToCamelCaseKeys({ Id: "123", TaskName: "Invoice" });
997
+ * // Result: { id: "123", taskName: "Invoice" }
998
+ *
999
+ * // Nested object
1000
+ * pascalToCamelCaseKeys({
1001
+ * TaskId: "456",
1002
+ * TaskDetails: { AssignedUser: "John", Priority: "High" }
1003
+ * });
1004
+ * // Result: {
1005
+ * // taskId: "456",
1006
+ * // taskDetails: { assignedUser: "John", priority: "High" }
1007
+ * // }
1008
+ *
1009
+ * // Array of objects
1010
+ * pascalToCamelCaseKeys([
1011
+ * { Id: "1", IsComplete: false },
1012
+ * { Id: "2", IsComplete: true }
1013
+ * ]);
1014
+ * // Result: [
1015
+ * // { id: "1", isComplete: false },
1016
+ * // { id: "2", isComplete: true }
1017
+ * // ]
1018
+ * ```
1019
+ */
1020
+ function pascalToCamelCaseKeys(data) {
1021
+ return transformCaseKeys(data, pascalToCamelCase);
1022
+ }
1023
+ /**
1024
+ * Adds a prefix to specified keys in an object, returning a new object.
1025
+ * Only the provided keys are prefixed; all others are left unchanged.
1026
+ *
1027
+ * @param obj The source object
1028
+ * @param prefix The prefix to add (e.g., '$')
1029
+ * @param keys The keys to prefix (e.g., ['expand', 'filter'])
1030
+ * @returns A new object with specified keys prefixed
1031
+ *
1032
+ * @example
1033
+ * addPrefixToKeys({ expand: 'a', foo: 1 }, '$', ['expand']) // { $expand: 'a', foo: 1 }
1034
+ */
1035
+ function addPrefixToKeys(obj, prefix, keys) {
1036
+ const result = {};
1037
+ for (const [key, value] of Object.entries(obj)) {
1038
+ if (keys.includes(key)) {
1039
+ result[`${prefix}${key}`] = value;
1040
+ }
1041
+ else {
1042
+ result[key] = value;
1043
+ }
1044
+ }
1045
+ return result;
1046
+ }
1047
+ /**
1048
+ * Transforms an array-based dictionary with separate keys and values arrays
1049
+ * into a standard JavaScript object/record
1050
+ *
1051
+ * @param dictionary Object containing keys and values arrays
1052
+ * @returns A standard record object with direct key-value mapping
1053
+ *
1054
+ * @example
1055
+ * ```typescript
1056
+ * const arrayDict = {
1057
+ * keys: ['Content-Type', 'x-ms-blob-type'],
1058
+ * values: ['application/json', 'BlockBlob']
1059
+ * };
1060
+ * const record = arrayDictionaryToRecord(arrayDict);
1061
+ * // result = {
1062
+ * // 'Content-Type': 'application/json',
1063
+ * // 'x-ms-blob-type': 'BlockBlob'
1064
+ * // }
1065
+ * ```
1066
+ */
1067
+ function arrayDictionaryToRecord(dictionary) {
1068
+ if (!dictionary || !dictionary.keys || !dictionary.values) {
1069
+ return {};
1070
+ }
1071
+ if (dictionary.keys.length !== dictionary.values.length) {
1072
+ console.warn('Keys and values arrays have different lengths');
1073
+ }
1074
+ const record = {};
1075
+ const length = Math.min(dictionary.keys.length, dictionary.values.length);
1076
+ for (let i = 0; i < length; i++) {
1077
+ record[dictionary.keys[i]] = dictionary.values[i];
1078
+ }
1079
+ return record;
1080
+ }
1081
+
1082
+ /**
1083
+ * Constants used throughout the pagination system
1084
+ */
1085
+ /** Maximum number of items that can be requested in a single page */
1086
+ const MAX_PAGE_SIZE = 1000;
1087
+ /** Default page size when jumpToPage is used without specifying pageSize */
1088
+ const DEFAULT_PAGE_SIZE = 50;
1089
+ /** Default field name for items in a paginated response */
1090
+ const DEFAULT_ITEMS_FIELD = 'value';
1091
+ /** Default field name for total count in a paginated response */
1092
+ const DEFAULT_TOTAL_COUNT_FIELD = '@odata.count';
1093
+ /**
1094
+ * Limits the page size to the maximum allowed value
1095
+ * @param pageSize - Requested page size
1096
+ * @returns Limited page size value
1097
+ */
1098
+ function getLimitedPageSize(pageSize) {
1099
+ if (pageSize === undefined || pageSize === null) {
1100
+ return DEFAULT_PAGE_SIZE;
1101
+ }
1102
+ return Math.max(1, Math.min(pageSize, MAX_PAGE_SIZE));
1103
+ }
1104
+
1105
+ /**
1106
+ * Helper functions for pagination that can be used across services
1107
+ */
1108
+ class PaginationHelpers {
1109
+ /**
1110
+ * Checks if any pagination parameters are provided
1111
+ *
1112
+ * @param options - The options object to check
1113
+ * @returns True if any pagination parameter is defined, false otherwise
1114
+ */
1115
+ static hasPaginationParameters(options = {}) {
1116
+ const { cursor, pageSize, jumpToPage } = options;
1117
+ return cursor !== undefined || pageSize !== undefined || jumpToPage !== undefined;
1118
+ }
1119
+ /**
1120
+ * Parse a pagination cursor string into cursor data
1121
+ */
1122
+ static parseCursor(cursorString) {
1123
+ try {
1124
+ const cursorData = JSON.parse(decodeBase64(cursorString));
1125
+ return cursorData;
1126
+ }
1127
+ catch {
1128
+ throw new Error('Invalid pagination cursor');
1129
+ }
1130
+ }
1131
+ /**
1132
+ * Validates cursor format and structure
1133
+ *
1134
+ * @param paginationOptions - The pagination options containing the cursor
1135
+ * @param paginationType - Optional pagination type to validate against
1136
+ */
1137
+ static validateCursor(paginationOptions, paginationType) {
1138
+ if (paginationOptions.cursor !== undefined) {
1139
+ if (!paginationOptions.cursor || typeof paginationOptions.cursor.value !== 'string' || !paginationOptions.cursor.value) {
1140
+ throw new Error('cursor must contain a valid cursor string');
1141
+ }
1142
+ try {
1143
+ // Try to parse the cursor to validate it
1144
+ const cursorData = PaginationHelpers.parseCursor(paginationOptions.cursor.value);
1145
+ // If type is provided, validate cursor contains expected type information
1146
+ if (paginationType) {
1147
+ if (!cursorData.type) {
1148
+ throw new Error('Invalid cursor: missing pagination type');
1149
+ }
1150
+ // Check pagination type compatibility
1151
+ if (cursorData.type !== paginationType) {
1152
+ throw new Error(`Pagination type mismatch: cursor is for ${cursorData.type} but service uses ${paginationType}`);
1153
+ }
1154
+ }
1155
+ }
1156
+ catch (error) {
1157
+ if (error instanceof Error) {
1158
+ // If it's already our error with specific message, pass it through
1159
+ if (error.message.startsWith('Invalid cursor') ||
1160
+ error.message.startsWith('Pagination type mismatch')) {
1161
+ throw error;
1162
+ }
1163
+ }
1164
+ throw new Error('Invalid pagination cursor format');
1165
+ }
1166
+ }
1167
+ }
1168
+ /**
1169
+ * Comprehensive validation for pagination options
1170
+ *
1171
+ * @param options - The pagination options to validate
1172
+ * @param paginationType - The pagination type these options will be used with
1173
+ * @returns Processed pagination parameters ready for use
1174
+ */
1175
+ static validatePaginationOptions(options, paginationType) {
1176
+ // Validate pageSize
1177
+ if (options.pageSize !== undefined && options.pageSize <= 0) {
1178
+ throw new Error('pageSize must be a positive number');
1179
+ }
1180
+ // Validate jumpToPage
1181
+ if (options.jumpToPage !== undefined && options.jumpToPage <= 0) {
1182
+ throw new Error('jumpToPage must be a positive number');
1183
+ }
1184
+ // Validate cursor
1185
+ PaginationHelpers.validateCursor(options, paginationType);
1186
+ // Validate service compatibility
1187
+ if (options.jumpToPage !== undefined && paginationType === PaginationType.TOKEN) {
1188
+ throw new Error('jumpToPage is not supported for token-based pagination. Use cursor-based navigation instead.');
1189
+ }
1190
+ // Get processed parameters
1191
+ return PaginationHelpers.getRequestParameters(options, paginationType);
1192
+ }
1193
+ /**
1194
+ * Convert a unified pagination options to service-specific parameters
1195
+ */
1196
+ static getRequestParameters(options, paginationType) {
1197
+ // Handle jumpToPage
1198
+ if (options.jumpToPage !== undefined) {
1199
+ const jumpToPageOptions = {
1200
+ pageSize: options.pageSize,
1201
+ pageNumber: options.jumpToPage
1202
+ };
1203
+ return filterUndefined(jumpToPageOptions);
1204
+ }
1205
+ // If no cursor is provided, it's a first page request
1206
+ if (!options.cursor) {
1207
+ const firstPageOptions = {
1208
+ pageSize: options.pageSize,
1209
+ // Only set pageNumber for OFFSET pagination
1210
+ pageNumber: paginationType === PaginationType.OFFSET ? 1 : undefined
1211
+ };
1212
+ return filterUndefined(firstPageOptions);
1213
+ }
1214
+ // Parse the cursor
1215
+ try {
1216
+ const cursorData = PaginationHelpers.parseCursor(options.cursor.value);
1217
+ const cursorBasedOptions = {
1218
+ pageSize: cursorData.pageSize || options.pageSize,
1219
+ pageNumber: cursorData.pageNumber,
1220
+ continuationToken: cursorData.continuationToken,
1221
+ type: cursorData.type,
1222
+ };
1223
+ return filterUndefined(cursorBasedOptions);
1224
+ }
1225
+ catch {
1226
+ throw new Error('Invalid pagination cursor');
1227
+ }
1228
+ }
1229
+ /**
1230
+ * Helper method for paginated resource retrieval
1231
+ *
1232
+ * @param params - Parameters for pagination
1233
+ * @returns Promise resolving to a paginated result
1234
+ */
1235
+ static async getAllPaginated(params) {
1236
+ const { serviceAccess, getEndpoint, folderId, paginationParams, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
1237
+ const endpoint = getEndpoint(folderId);
1238
+ const headers = folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {};
1239
+ const paginatedResponse = await serviceAccess.requestWithPagination(method, endpoint, paginationParams, {
1240
+ headers,
1241
+ params: additionalParams,
1242
+ pagination: {
1243
+ paginationType: options.paginationType || PaginationType.OFFSET,
1244
+ itemsField: options.itemsField || DEFAULT_ITEMS_FIELD,
1245
+ totalCountField: options.totalCountField || DEFAULT_TOTAL_COUNT_FIELD,
1246
+ continuationTokenField: options.continuationTokenField,
1247
+ paginationParams: options.paginationParams
1248
+ }
1249
+ });
1250
+ // Parse items - automatically handle JSON string responses
1251
+ const rawItems = paginatedResponse.items;
1252
+ const parsedItems = typeof rawItems === 'string' ? JSON.parse(rawItems) : (rawItems || []);
1253
+ const transformedItems = transformFn ? parsedItems.map(transformFn) : parsedItems;
1254
+ return {
1255
+ ...paginatedResponse,
1256
+ items: transformedItems
1257
+ };
1258
+ }
1259
+ /**
1260
+ * Helper method for non-paginated resource retrieval
1261
+ *
1262
+ * @param params - Parameters for non-paginated resource retrieval
1263
+ * @returns Promise resolving to an object with data and totalCount
1264
+ */
1265
+ static async getAllNonPaginated(params) {
1266
+ const { serviceAccess, getAllEndpoint, getByFolderEndpoint, folderId, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
1267
+ // Set default field names
1268
+ const itemsField = options.itemsField || DEFAULT_ITEMS_FIELD;
1269
+ const totalCountField = options.totalCountField || DEFAULT_TOTAL_COUNT_FIELD;
1270
+ // Determine endpoint and headers based on folderId
1271
+ const endpoint = folderId ? getByFolderEndpoint : getAllEndpoint;
1272
+ const headers = folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {};
1273
+ // Make the API call based on method
1274
+ let response;
1275
+ if (method === HTTP_METHODS.POST) {
1276
+ response = await serviceAccess.post(endpoint, additionalParams, { headers });
1277
+ }
1278
+ else {
1279
+ response = await serviceAccess.get(endpoint, {
1280
+ params: additionalParams,
1281
+ headers
1282
+ });
1283
+ }
1284
+ // Extract and transform items from response
1285
+ const rawItems = response.data?.[itemsField];
1286
+ const totalCount = response.data?.[totalCountField];
1287
+ // Parse items - automatically handle JSON string responses
1288
+ const parsedItems = typeof rawItems === 'string' ? JSON.parse(rawItems) : (rawItems || []);
1289
+ const items = transformFn ? parsedItems.map(transformFn) : parsedItems;
1290
+ return {
1291
+ items,
1292
+ totalCount
1293
+ };
1294
+ }
1295
+ /**
1296
+ * Centralized getAll implementation that handles both paginated and non-paginated requests
1297
+ *
1298
+ * @param config - Configuration for the getAll operation
1299
+ * @param options - Request options including pagination parameters
1300
+ * @returns Promise resolving to either paginated or non-paginated response based on options
1301
+ */
1302
+ static async getAll(config, options) {
1303
+ const optionsWithDefaults = options || {};
1304
+ const { folderId, pageSize, cursor, jumpToPage, ...restOptions } = optionsWithDefaults;
1305
+ // Determine if pagination is requested
1306
+ const isPaginationRequested = PaginationHelpers.hasPaginationParameters(options || {});
1307
+ // Process parameters (custom processing if provided, otherwise default)
1308
+ let processedOptions = restOptions;
1309
+ if (config.processParametersFn) {
1310
+ processedOptions = config.processParametersFn(restOptions, folderId);
1311
+ }
1312
+ // Apply ODATA prefix to keys (excluding specified keys)
1313
+ const excludeKeys = config.excludeFromPrefix || [];
1314
+ const keysToPrefix = Object.keys(processedOptions).filter(k => !excludeKeys.includes(k));
1315
+ const prefixedOptions = addPrefixToKeys(processedOptions, ODATA_PREFIX, keysToPrefix);
1316
+ // Default pagination options
1317
+ const paginationOptions = {
1318
+ paginationType: PaginationType.OFFSET,
1319
+ itemsField: DEFAULT_ITEMS_FIELD,
1320
+ totalCountField: DEFAULT_TOTAL_COUNT_FIELD,
1321
+ ...config.pagination
1322
+ };
1323
+ // Paginated flow
1324
+ if (isPaginationRequested) {
1325
+ return PaginationHelpers.getAllPaginated({
1326
+ serviceAccess: config.serviceAccess,
1327
+ getEndpoint: config.getEndpoint,
1328
+ folderId,
1329
+ paginationParams: cursor ? { cursor, pageSize } : jumpToPage ? { jumpToPage, pageSize } : { pageSize },
1330
+ additionalParams: prefixedOptions,
1331
+ transformFn: config.transformFn,
1332
+ method: config.method,
1333
+ options: {
1334
+ ...paginationOptions,
1335
+ paginationParams: config.pagination?.paginationParams
1336
+ }
1337
+ }); // Type assertion needed due to conditional return
1338
+ }
1339
+ // Non-paginated flow
1340
+ const byFolderEndpoint = config.getByFolderEndpoint || config.getEndpoint(folderId);
1341
+ return PaginationHelpers.getAllNonPaginated({
1342
+ serviceAccess: config.serviceAccess,
1343
+ getAllEndpoint: config.getEndpoint(),
1344
+ getByFolderEndpoint: byFolderEndpoint,
1345
+ folderId,
1346
+ additionalParams: prefixedOptions,
1347
+ transformFn: config.transformFn,
1348
+ method: config.method,
1349
+ options: {
1350
+ itemsField: paginationOptions.itemsField,
1351
+ totalCountField: paginationOptions.totalCountField
1352
+ }
1353
+ });
1354
+ }
1355
+ }
1356
+
1357
+ /**
1358
+ * SDK Internals Registry - Internal registry for SDK instances
1359
+ *
1360
+ * This class is NOT exported in the public API.
1361
+ * It provides a secure way to share SDK internals between
1362
+ * the UiPath class and service classes without exposing them publicly.
1363
+ *
1364
+ * @internal
1365
+ */
1366
+ // Global symbol key to ensure WeakMap is shared across module instances
1367
+ // This prevents issues when core and service modules are bundled separately
1368
+ const REGISTRY_KEY = Symbol.for('@uipath/sdk-internals-registry');
1369
+ // Get or create the global WeakMap store
1370
+ const getGlobalStore = () => {
1371
+ const globalObj = globalThis;
1372
+ if (!globalObj[REGISTRY_KEY]) {
1373
+ globalObj[REGISTRY_KEY] = new WeakMap();
1374
+ }
1375
+ return globalObj[REGISTRY_KEY];
1376
+ };
1377
+ /**
1378
+ * Internal registry for SDK private components.
1379
+ * Uses WeakMap to prevent memory leaks - entries are automatically
1380
+ * garbage collected when the SDK instance is no longer referenced.
1381
+ *
1382
+ * Uses a global singleton pattern to ensure the same WeakMap is shared
1383
+ * across separately bundled modules (core, entities, tasks, etc.).
1384
+ *
1385
+ * @internal - Not exported in public API
1386
+ */
1387
+ class SDKInternalsRegistry {
1388
+ // Use global store to ensure sharing across module bundles
1389
+ static get store() {
1390
+ return getGlobalStore();
1391
+ }
1392
+ /**
1393
+ * Register SDK instance internals
1394
+ * Called by UiPath constructor
1395
+ */
1396
+ static set(instance, internals) {
1397
+ this.store.set(instance, internals);
1398
+ }
1399
+ /**
1400
+ * Retrieve SDK instance internals
1401
+ * Called by BaseService constructor
1402
+ */
1403
+ static get(instance) {
1404
+ const internals = this.store.get(instance);
1405
+ if (!internals) {
1406
+ throw new Error('Invalid SDK instance. Make sure to pass a valid UiPath instance to the service constructor.');
1407
+ }
1408
+ return internals;
1409
+ }
1410
+ }
1411
+
1412
+ var _BaseService_apiClient;
1413
+ /**
1414
+ * Base class for all UiPath SDK services.
1415
+ *
1416
+ * Provides common functionality for authentication, configuration, and API communication.
1417
+ * All service classes extend this base to inherit dependency injection and HTTP client access.
1418
+ *
1419
+ * This class implements the dependency injection pattern where services receive a configured
1420
+ * UiPath instance. The ApiClient is created internally and handles all HTTP operations
1421
+ * including authentication token management.
1422
+ *
1423
+ * @remarks
1424
+ * Service classes should extend this base and call `super(uiPath)` in their constructor.
1425
+ * Protected HTTP methods (get, post, put, patch, delete) are available to all subclasses.
1426
+ *
1427
+ */
1428
+ class BaseService {
1429
+ /**
1430
+ * Creates a base service instance with dependency injection.
1431
+ *
1432
+ * Extracts configuration, execution context, and token manager from the UiPath instance
1433
+ * to initialize an authenticated API client. The ApiClient handles all HTTP operations
1434
+ * and token management internally.
1435
+ *
1436
+ * @param instance - UiPath SDK instance providing authentication and configuration.
1437
+ * Services receive this via dependency injection in the modular pattern.
1438
+ *
1439
+ * @example
1440
+ * ```typescript
1441
+ * // Services automatically call this via super()
1442
+ * export class EntityService extends BaseService {
1443
+ * constructor(instance: IUiPath) {
1444
+ * super(instance); // Initializes the internal ApiClient
1445
+ * }
1446
+ * }
1447
+ *
1448
+ * // Usage in modular pattern
1449
+ * import { UiPath } from '@uipath/uipath-typescript/core';
1450
+ * import { Entities } from '@uipath/uipath-typescript/entities';
1451
+ *
1452
+ * const sdk = new UiPath(config);
1453
+ * await sdk.initialize();
1454
+ * const entities = new Entities(sdk);
1455
+ * ```
1456
+ */
1457
+ constructor(instance) {
1458
+ // Private field - not visible via Object.keys() or any reflection
1459
+ _BaseService_apiClient.set(this, void 0);
1460
+ const { config, context, tokenManager } = SDKInternalsRegistry.get(instance);
1461
+ __classPrivateFieldSet(this, _BaseService_apiClient, new ApiClient(config, context, tokenManager), "f");
1462
+ }
1463
+ /**
1464
+ * Gets a valid authentication token, refreshing if necessary.
1465
+ * Use this when you need to manually add Authorization headers (e.g., direct uploads).
1466
+ *
1467
+ * @returns Promise resolving to a valid access token string
1468
+ * @throws AuthenticationError if no token is available or refresh fails
1469
+ */
1470
+ async getValidAuthToken() {
1471
+ return __classPrivateFieldGet(this, _BaseService_apiClient, "f").getValidToken();
1472
+ }
1473
+ /**
1474
+ * Creates a service accessor for pagination helpers
1475
+ * This allows pagination helpers to access protected methods without making them public
1476
+ */
1477
+ createPaginationServiceAccess() {
1478
+ return {
1479
+ get: (path, options) => this.get(path, options || {}),
1480
+ post: (path, body, options) => this.post(path, body, options || {}),
1481
+ requestWithPagination: (method, path, paginationOptions, options) => this.requestWithPagination(method, path, paginationOptions, options)
1482
+ };
1483
+ }
1484
+ async request(method, path, options = {}) {
1485
+ switch (method.toUpperCase()) {
1486
+ case 'GET':
1487
+ return this.get(path, options);
1488
+ case 'POST':
1489
+ return this.post(path, options.body, options);
1490
+ case 'PUT':
1491
+ return this.put(path, options.body, options);
1492
+ case 'PATCH':
1493
+ return this.patch(path, options.body, options);
1494
+ case 'DELETE':
1495
+ return this.delete(path, options);
1496
+ default:
1497
+ throw new Error(`Unsupported HTTP method: ${method}`);
1498
+ }
1499
+ }
1500
+ async requestWithSpec(spec) {
1501
+ if (!spec.method || !spec.url) {
1502
+ throw new Error('Request spec must include method and url');
1503
+ }
1504
+ return this.request(spec.method, spec.url, spec);
1505
+ }
1506
+ async get(path, options = {}) {
1507
+ const response = await __classPrivateFieldGet(this, _BaseService_apiClient, "f").get(path, options);
1508
+ return { data: response };
1509
+ }
1510
+ async post(path, data, options = {}) {
1511
+ const response = await __classPrivateFieldGet(this, _BaseService_apiClient, "f").post(path, data, options);
1512
+ return { data: response };
1513
+ }
1514
+ async put(path, data, options = {}) {
1515
+ const response = await __classPrivateFieldGet(this, _BaseService_apiClient, "f").put(path, data, options);
1516
+ return { data: response };
1517
+ }
1518
+ async patch(path, data, options = {}) {
1519
+ const response = await __classPrivateFieldGet(this, _BaseService_apiClient, "f").patch(path, data, options);
1520
+ return { data: response };
1521
+ }
1522
+ async delete(path, options = {}) {
1523
+ const response = await __classPrivateFieldGet(this, _BaseService_apiClient, "f").delete(path, options);
1524
+ return { data: response };
1525
+ }
1526
+ /**
1527
+ * Execute a request with cursor-based pagination
1528
+ */
1529
+ async requestWithPagination(method, path, paginationOptions, options) {
1530
+ const paginationType = options.pagination.paginationType;
1531
+ // Validate and prepare pagination parameters
1532
+ const params = this.validateAndPreparePaginationParams(paginationType, paginationOptions);
1533
+ // Prepare request parameters based on pagination type
1534
+ const requestParams = this.preparePaginationRequestParams(paginationType, params, options.pagination);
1535
+ // For POST requests, merge pagination params into body; for GET, use query params
1536
+ if (method.toUpperCase() === 'POST') {
1537
+ const existingBody = (options.body && typeof options.body === 'object') ? options.body : {};
1538
+ options.body = {
1539
+ ...existingBody,
1540
+ ...options.params,
1541
+ ...requestParams
1542
+ };
1543
+ }
1544
+ else {
1545
+ // Merge pagination parameters with existing parameters
1546
+ options.params = {
1547
+ ...options.params,
1548
+ ...requestParams
1549
+ };
1550
+ }
1551
+ // Make the request
1552
+ const response = await this.request(method, path, options);
1553
+ // Extract data from the response and create page result
1554
+ return this.createPaginatedResponseFromResponse(response, params, paginationType, {
1555
+ itemsField: options.pagination.itemsField,
1556
+ totalCountField: options.pagination.totalCountField,
1557
+ continuationTokenField: options.pagination.continuationTokenField
1558
+ });
1559
+ }
1560
+ /**
1561
+ * Validates and prepares pagination parameters from options
1562
+ */
1563
+ validateAndPreparePaginationParams(paginationType, paginationOptions) {
1564
+ return PaginationHelpers.validatePaginationOptions(paginationOptions, paginationType);
1565
+ }
1566
+ /**
1567
+ * Prepares request parameters for pagination based on pagination type
1568
+ */
1569
+ preparePaginationRequestParams(paginationType, params, paginationConfig) {
1570
+ const requestParams = {};
1571
+ let limitedPageSize;
1572
+ const paginationParams = paginationConfig?.paginationParams;
1573
+ switch (paginationType) {
1574
+ case PaginationType.OFFSET:
1575
+ limitedPageSize = getLimitedPageSize(params.pageSize);
1576
+ const pageSizeParam = paginationParams?.pageSizeParam || ODATA_OFFSET_PARAMS.PAGE_SIZE_PARAM;
1577
+ const offsetParam = paginationParams?.offsetParam || ODATA_OFFSET_PARAMS.OFFSET_PARAM;
1578
+ const countParam = paginationParams?.countParam || ODATA_OFFSET_PARAMS.COUNT_PARAM;
1579
+ requestParams[pageSizeParam] = limitedPageSize;
1580
+ if (params.pageNumber && params.pageNumber > 1) {
1581
+ requestParams[offsetParam] = (params.pageNumber - 1) * limitedPageSize;
1582
+ }
1583
+ // Include total count for ODATA APIs
1584
+ {
1585
+ requestParams[countParam] = true;
1586
+ }
1587
+ break;
1588
+ case PaginationType.TOKEN:
1589
+ const tokenPageSizeParam = paginationParams?.pageSizeParam || BUCKET_TOKEN_PARAMS.PAGE_SIZE_PARAM;
1590
+ const tokenParam = paginationParams?.tokenParam || BUCKET_TOKEN_PARAMS.TOKEN_PARAM;
1591
+ if (params.pageSize) {
1592
+ requestParams[tokenPageSizeParam] = getLimitedPageSize(params.pageSize);
1593
+ }
1594
+ if (params.continuationToken) {
1595
+ requestParams[tokenParam] = params.continuationToken;
1596
+ }
1597
+ break;
1598
+ }
1599
+ return requestParams;
1600
+ }
1601
+ /**
1602
+ * Creates a paginated response from API response
1603
+ */
1604
+ createPaginatedResponseFromResponse(response, params, paginationType, fields) {
1605
+ // Extract fields from response
1606
+ const itemsField = fields.itemsField ||
1607
+ (paginationType === PaginationType.TOKEN ? 'items' : 'value');
1608
+ const totalCountField = fields.totalCountField || 'totalRecordCount';
1609
+ const continuationTokenField = fields.continuationTokenField || 'continuationToken';
1610
+ // Extract items and metadata
1611
+ const items = response.data[itemsField] || [];
1612
+ const totalCount = response.data[totalCountField];
1613
+ const continuationToken = response.data[continuationTokenField];
1614
+ // Determine if there are more pages
1615
+ const hasMore = this.determineHasMorePages(paginationType, {
1616
+ totalCount,
1617
+ pageSize: params.pageSize,
1618
+ currentPage: params.pageNumber || 1,
1619
+ itemsCount: items.length,
1620
+ continuationToken
1621
+ });
1622
+ // Create and return the page result
1623
+ return PaginationManager.createPaginatedResponse({
1624
+ pageInfo: {
1625
+ hasMore,
1626
+ totalCount,
1627
+ currentPage: params.pageNumber,
1628
+ pageSize: params.pageSize,
1629
+ continuationToken
1630
+ },
1631
+ type: paginationType,
1632
+ }, items);
1633
+ }
1634
+ /**
1635
+ * Determines if there are more pages based on pagination type and metadata
1636
+ */
1637
+ determineHasMorePages(paginationType, info) {
1638
+ switch (paginationType) {
1639
+ case PaginationType.OFFSET:
1640
+ const effectivePageSize = info.pageSize ?? DEFAULT_PAGE_SIZE;
1641
+ // If totalCount is available, use it for precise calculation
1642
+ if (info.totalCount !== undefined) {
1643
+ return (info.currentPage * effectivePageSize) < info.totalCount;
1644
+ }
1645
+ // Fallback when totalCount is not available
1646
+ // NOTE: This code path should rarely be executed as the APIs typically return totalCount
1647
+ return info.itemsCount === effectivePageSize;
1648
+ case PaginationType.TOKEN:
1649
+ return !!info.continuationToken;
1650
+ default:
1651
+ return false;
1652
+ }
1653
+ }
1654
+ }
1655
+ _BaseService_apiClient = new WeakMap();
1656
+
1657
+ /**
1658
+ * Base service for services that need folder-specific functionality.
1659
+ *
1660
+ * Extends BaseService with additional methods for working with folder-scoped resources
1661
+ * in UiPath Orchestrator. Services that work with folders (Assets, Queues) extend this class.
1662
+ *
1663
+ * @remarks
1664
+ * This class provides helper methods for making folder-scoped API calls, handling folder IDs
1665
+ * in request headers, and managing cross-folder queries.
1666
+ */
1667
+ class FolderScopedService extends BaseService {
1668
+ /**
1669
+ * Gets resources in a folder with optional query parameters
1670
+ *
1671
+ * @param endpoint - API endpoint to call
1672
+ * @param folderId - required folder ID
1673
+ * @param options - Query options
1674
+ * @param transformFn - Optional function to transform the response data
1675
+ * @returns Promise resolving to an array of resources
1676
+ */
1677
+ async _getByFolder(endpoint, folderId, options = {}, transformFn) {
1678
+ const headers = createHeaders({ [FOLDER_ID]: folderId });
1679
+ const keysToPrefix = Object.keys(options);
1680
+ const apiOptions = addPrefixToKeys(options, ODATA_PREFIX, keysToPrefix);
1681
+ const response = await this.get(endpoint, {
1682
+ params: apiOptions,
1683
+ headers
1684
+ });
1685
+ if (transformFn) {
1686
+ return response.data?.value.map(transformFn);
1687
+ }
1688
+ return response.data?.value;
1689
+ }
1690
+ }
1691
+
1692
+ /**
1693
+ * Base path constants for different services
1694
+ */
1695
+ const ORCHESTRATOR_BASE = 'orchestrator_';
1696
+
1697
+ /**
1698
+ * Orchestrator Service Endpoints
1699
+ */
1700
+ /**
1701
+ * Orchestrator Bucket Endpoints
1702
+ */
1703
+ const BUCKET_ENDPOINTS = {
1704
+ GET_BY_FOLDER: `${ORCHESTRATOR_BASE}/odata/Buckets`,
1705
+ GET_ALL: `${ORCHESTRATOR_BASE}/odata/Buckets/UiPath.Server.Configuration.OData.GetBucketsAcrossFolders`,
1706
+ GET_BY_ID: (id) => `${ORCHESTRATOR_BASE}/odata/Buckets(${id})`,
1707
+ GET_FILE_META_DATA: (id) => `${ORCHESTRATOR_BASE}/api/Buckets/${id}/ListFiles`,
1708
+ GET_READ_URI: (id) => `${ORCHESTRATOR_BASE}/odata/Buckets(${id})/UiPath.Server.Configuration.OData.GetReadUri`,
1709
+ GET_WRITE_URI: (id) => `${ORCHESTRATOR_BASE}/odata/Buckets(${id})/UiPath.Server.Configuration.OData.GetWriteUri`,
1710
+ };
1711
+
1712
+ /**
1713
+ * Maps fields for Bucket entities to ensure consistent naming
1714
+ */
1715
+ const BucketMap = {
1716
+ fullPath: 'path',
1717
+ items: 'blobItems',
1718
+ verb: 'httpMethod'
1719
+ };
1720
+
1721
+ /**
1722
+ * SDK Telemetry constants
1723
+ */
1724
+ // Connection string placeholder that will be replaced during build
1725
+ 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";
1726
+ // SDK Version placeholder
1727
+ const SDK_VERSION = "1.1.0";
1728
+ const VERSION = "Version";
1729
+ const SERVICE = "Service";
1730
+ const CLOUD_ORGANIZATION_NAME = "CloudOrganizationName";
1731
+ const CLOUD_TENANT_NAME = "CloudTenantName";
1732
+ const CLOUD_URL = "CloudUrl";
1733
+ const CLOUD_CLIENT_ID = "CloudClientId";
1734
+ const CLOUD_REDIRECT_URI = "CloudRedirectUri";
1735
+ const APP_NAME = "ApplicationName";
1736
+ const CLOUD_ROLE_NAME = "uipath-ts-sdk";
1737
+ // Service and logger names
1738
+ const SDK_SERVICE_NAME = "UiPath.TypeScript.Sdk";
1739
+ const SDK_LOGGER_NAME = "uipath-ts-sdk-telemetry";
1740
+ // Event names
1741
+ const SDK_RUN_EVENT = "Sdk.Run";
1742
+ // Default value for unknown/empty attributes
1743
+ const UNKNOWN = "";
1744
+
1745
+ /**
1746
+ * Log exporter that sends ALL logs as Application Insights custom events
1747
+ */
1748
+ class ApplicationInsightsEventExporter {
1749
+ constructor(connectionString) {
1750
+ this.connectionString = connectionString;
1751
+ }
1752
+ export(logs, resultCallback) {
1753
+ try {
1754
+ logs.forEach(logRecord => {
1755
+ this.sendAsCustomEvent(logRecord);
1756
+ });
1757
+ resultCallback({ code: 0 });
1758
+ }
1759
+ catch (error) {
1760
+ console.debug('Failed to export logs to Application Insights:', error);
1761
+ resultCallback({ code: 2, error });
1762
+ }
1763
+ }
1764
+ shutdown() {
1765
+ return Promise.resolve();
1766
+ }
1767
+ sendAsCustomEvent(logRecord) {
1768
+ // Get event name from body or attributes
1769
+ const eventName = logRecord.body || SDK_RUN_EVENT;
1770
+ const payload = {
1771
+ name: 'Microsoft.ApplicationInsights.Event',
1772
+ time: new Date().toISOString(),
1773
+ iKey: this.extractInstrumentationKey(),
1774
+ data: {
1775
+ baseType: 'EventData',
1776
+ baseData: {
1777
+ ver: 2,
1778
+ name: eventName,
1779
+ properties: this.convertAttributesToProperties(logRecord.attributes || {})
1780
+ }
1781
+ },
1782
+ tags: {
1783
+ 'ai.cloud.role': CLOUD_ROLE_NAME,
1784
+ 'ai.cloud.roleInstance': SDK_VERSION
1785
+ }
1786
+ };
1787
+ this.sendToApplicationInsights(payload);
1788
+ }
1789
+ extractInstrumentationKey() {
1790
+ const match = this.connectionString.match(/InstrumentationKey=([^;]+)/);
1791
+ return match ? match[1] : '';
1792
+ }
1793
+ convertAttributesToProperties(attributes) {
1794
+ const properties = {};
1795
+ Object.entries(attributes || {}).forEach(([key, value]) => {
1796
+ properties[key] = String(value);
1797
+ });
1798
+ return properties;
1799
+ }
1800
+ async sendToApplicationInsights(payload) {
1801
+ try {
1802
+ const ingestionEndpoint = this.extractIngestionEndpoint();
1803
+ if (!ingestionEndpoint) {
1804
+ console.debug('No ingestion endpoint found in connection string');
1805
+ return;
1806
+ }
1807
+ const url = `${ingestionEndpoint}/v2/track`;
1808
+ const response = await fetch(url, {
1809
+ method: 'POST',
1810
+ headers: {
1811
+ 'Content-Type': 'application/json',
1812
+ },
1813
+ body: JSON.stringify(payload)
1814
+ });
1815
+ if (!response.ok) {
1816
+ console.debug(`Failed to send event telemetry: ${response.status} ${response.statusText}`);
1817
+ }
1818
+ }
1819
+ catch (error) {
1820
+ console.debug('Error sending event telemetry to Application Insights:', error);
1821
+ }
1822
+ }
1823
+ extractIngestionEndpoint() {
1824
+ const match = this.connectionString.match(/IngestionEndpoint=([^;]+)/);
1825
+ return match ? match[1] : '';
1826
+ }
1827
+ }
1828
+ /**
1829
+ * Singleton telemetry client
1830
+ */
1831
+ class TelemetryClient {
1832
+ constructor() {
1833
+ this.isInitialized = false;
1834
+ }
1835
+ static getInstance() {
1836
+ if (!TelemetryClient.instance) {
1837
+ TelemetryClient.instance = new TelemetryClient();
1838
+ }
1839
+ return TelemetryClient.instance;
1840
+ }
1841
+ /**
1842
+ * Initialize telemetry
1843
+ */
1844
+ initialize(config) {
1845
+ if (this.isInitialized) {
1846
+ return;
1847
+ }
1848
+ this.isInitialized = true;
1849
+ if (config) {
1850
+ this.telemetryContext = config;
1851
+ }
1852
+ try {
1853
+ const connectionString = this.getConnectionString();
1854
+ if (!connectionString) {
1855
+ return;
1856
+ }
1857
+ this.setupTelemetryProvider(connectionString);
1858
+ }
1859
+ catch (error) {
1860
+ // Silent failure - telemetry errors shouldn't break functionality
1861
+ console.debug('Failed to initialize OpenTelemetry:', error);
1862
+ }
1863
+ }
1864
+ getConnectionString() {
1865
+ const connectionString = CONNECTION_STRING;
1866
+ return connectionString;
1867
+ }
1868
+ setupTelemetryProvider(connectionString) {
1869
+ const exporter = new ApplicationInsightsEventExporter(connectionString);
1870
+ const processor = new sdkLogs.BatchLogRecordProcessor(exporter);
1871
+ this.logProvider = new sdkLogs.LoggerProvider({
1872
+ processors: [processor]
1873
+ });
1874
+ this.logger = this.logProvider.getLogger(SDK_LOGGER_NAME);
1875
+ }
1876
+ /**
1877
+ * Track a telemetry event
1878
+ */
1879
+ track(eventName, name, extraAttributes = {}) {
1880
+ try {
1881
+ // Skip if logger not initialized
1882
+ if (!this.logger) {
1883
+ return;
1884
+ }
1885
+ const finalDisplayName = name || eventName;
1886
+ const attributes = this.getEnrichedAttributes(extraAttributes, eventName);
1887
+ // Emit as log
1888
+ this.logger.emit({
1889
+ body: finalDisplayName,
1890
+ attributes: attributes,
1891
+ timestamp: Date.now(),
1892
+ });
1893
+ }
1894
+ catch (error) {
1895
+ // Silent failure
1896
+ console.debug('Failed to track telemetry event:', error);
1897
+ }
1898
+ }
1899
+ /**
1900
+ * Get enriched attributes for telemetry events
1901
+ */
1902
+ getEnrichedAttributes(extraAttributes, eventName) {
1903
+ const attributes = {
1904
+ [APP_NAME]: SDK_SERVICE_NAME,
1905
+ [VERSION]: SDK_VERSION,
1906
+ [SERVICE]: eventName,
1907
+ [CLOUD_URL]: this.createCloudUrl(),
1908
+ [CLOUD_ORGANIZATION_NAME]: this.telemetryContext?.orgName || UNKNOWN,
1909
+ [CLOUD_TENANT_NAME]: this.telemetryContext?.tenantName || UNKNOWN,
1910
+ [CLOUD_REDIRECT_URI]: this.telemetryContext?.redirectUri || UNKNOWN,
1911
+ [CLOUD_CLIENT_ID]: this.telemetryContext?.clientId || UNKNOWN,
1912
+ ...extraAttributes,
1913
+ };
1914
+ return attributes;
1915
+ }
1916
+ /**
1917
+ * Create cloud URL from base URL, organization ID, and tenant ID
1918
+ */
1919
+ createCloudUrl() {
1920
+ const baseUrl = this.telemetryContext?.baseUrl;
1921
+ const orgId = this.telemetryContext?.orgName;
1922
+ const tenantId = this.telemetryContext?.tenantName;
1923
+ if (!baseUrl || !orgId || !tenantId) {
1924
+ return UNKNOWN;
1925
+ }
1926
+ return `${baseUrl}/${orgId}/${tenantId}`;
1927
+ }
1928
+ }
1929
+ // Export singleton instance
1930
+ const telemetryClient = TelemetryClient.getInstance();
1931
+
1932
+ /**
1933
+ * SDK Track decorator and function for telemetry
1934
+ */
1935
+ /**
1936
+ * Common tracking logic shared between method and function decorators
1937
+ */
1938
+ function createTrackedFunction(originalFunction, nameOrOptions, fallbackName, opts) {
1939
+ return function (...args) {
1940
+ // Determine if we should track this call
1941
+ let shouldTrack = true;
1942
+ if (opts.condition !== undefined) {
1943
+ if (typeof opts.condition === 'function') {
1944
+ shouldTrack = opts.condition.apply(this, args);
1945
+ }
1946
+ else {
1947
+ shouldTrack = opts.condition;
1948
+ }
1949
+ }
1950
+ // Track the event if enabled
1951
+ if (shouldTrack) {
1952
+ // Use the full name provided in the decorator (e.g., "Queue.GetAll")
1953
+ const serviceMethod = typeof nameOrOptions === 'string'
1954
+ ? nameOrOptions
1955
+ : fallbackName;
1956
+ // Use 'Sdk.Run' as the name and serviceMethod as the service
1957
+ telemetryClient.track(serviceMethod, SDK_RUN_EVENT, opts.attributes);
1958
+ }
1959
+ // Execute the original function
1960
+ return originalFunction.apply(this, args);
1961
+ };
1962
+ }
1963
+ /**
1964
+ * Track decorator that can be used to automatically track function calls
1965
+ *
1966
+ * Usage:
1967
+ * @track("Service.Method")
1968
+ * function myFunction() { ... }
1969
+ *
1970
+ * @track("Queue.GetAll")
1971
+ * async getAll() { ... }
1972
+ *
1973
+ * @track("Tasks.Create")
1974
+ * async create() { ... }
1975
+ *
1976
+ * @track("Assets.Update", { condition: false })
1977
+ * function myFunction() { ... }
1978
+ *
1979
+ * @track("Processes.Start", { attributes: { customProp: "value" } })
1980
+ * function myFunction() { ... }
1981
+ */
1982
+ function track(nameOrOptions, options) {
1983
+ return function decorator(_target, propertyKey, descriptor) {
1984
+ const opts = typeof nameOrOptions === 'object' ? nameOrOptions : {};
1985
+ if (descriptor && typeof descriptor.value === 'function') {
1986
+ // Method decorator
1987
+ descriptor.value = createTrackedFunction(descriptor.value, nameOrOptions, propertyKey || 'unknown_method', opts);
1988
+ return descriptor;
1989
+ }
1990
+ // Function decorator
1991
+ return (originalFunction) => createTrackedFunction(originalFunction, nameOrOptions, originalFunction.name || 'unknown_function', opts);
1992
+ };
1993
+ }
1994
+
1995
+ class BucketService extends FolderScopedService {
1996
+ /**
1997
+ * Gets a bucket by ID
1998
+ * @param bucketId - The ID of the bucket to retrieve
1999
+ * @param folderId - Folder ID for organization unit context
2000
+ * @param options - Optional query parameters (expand, select)
2001
+ * @returns Promise resolving to the bucket
2002
+ *
2003
+ * @example
2004
+ * ```typescript
2005
+ * import { Buckets } from '@uipath/uipath-typescript/buckets';
2006
+ *
2007
+ * const buckets = new Buckets(sdk);
2008
+ *
2009
+ * // Get bucket by ID
2010
+ * const bucket = await buckets.getById(123, 456);
2011
+ * ```
2012
+ */
2013
+ async getById(id, folderId, options = {}) {
2014
+ if (!id) {
2015
+ throw new ValidationError({ message: 'bucketId is required for getById' });
2016
+ }
2017
+ if (!folderId) {
2018
+ throw new ValidationError({ message: 'folderId is required for getById' });
2019
+ }
2020
+ const headers = createHeaders({ [FOLDER_ID]: folderId });
2021
+ // Prefix all keys in options with $ for OData
2022
+ const keysToPrefix = Object.keys(options);
2023
+ const apiOptions = addPrefixToKeys(options, ODATA_PREFIX, keysToPrefix);
2024
+ const response = await this.get(BUCKET_ENDPOINTS.GET_BY_ID(id), {
2025
+ params: apiOptions,
2026
+ headers
2027
+ });
2028
+ // Transform response from PascalCase to camelCase
2029
+ return pascalToCamelCaseKeys(response.data);
2030
+ }
2031
+ /**
2032
+ * Gets all buckets across folders with optional filtering and folder scoping
2033
+ *
2034
+ * The method returns either:
2035
+ * - An array of buckets (when no pagination parameters are provided)
2036
+ * - A paginated result with navigation cursors (when any pagination parameter is provided)
2037
+ *
2038
+ * @param options - Query options including optional folderId
2039
+ * @returns Promise resolving to an array of buckets or paginated result
2040
+ *
2041
+ * @example
2042
+ * ```typescript
2043
+ * import { Buckets } from '@uipath/uipath-typescript/buckets';
2044
+ *
2045
+ * const buckets = new Buckets(sdk);
2046
+ *
2047
+ * // Get all buckets across folders
2048
+ * const allBuckets = await buckets.getAll();
2049
+ *
2050
+ * // Get buckets within a specific folder
2051
+ * const folderBuckets = await buckets.getAll({
2052
+ * folderId: 123
2053
+ * });
2054
+ *
2055
+ * // Get buckets with filtering
2056
+ * const filteredBuckets = await buckets.getAll({
2057
+ * filter: "name eq 'MyBucket'"
2058
+ * });
2059
+ *
2060
+ * // First page with pagination
2061
+ * const page1 = await buckets.getAll({ pageSize: 10 });
2062
+ *
2063
+ * // Navigate using cursor
2064
+ * if (page1.hasNextPage) {
2065
+ * const page2 = await buckets.getAll({ cursor: page1.nextCursor });
2066
+ * }
2067
+ *
2068
+ * // Jump to specific page
2069
+ * const page5 = await buckets.getAll({
2070
+ * jumpToPage: 5,
2071
+ * pageSize: 10
2072
+ * });
2073
+ * ```
2074
+ */
2075
+ async getAll(options) {
2076
+ // Transformation function for buckets
2077
+ const transformBucketResponse = (bucket) => pascalToCamelCaseKeys(bucket);
2078
+ return PaginationHelpers.getAll({
2079
+ serviceAccess: this.createPaginationServiceAccess(),
2080
+ getEndpoint: (folderId) => folderId ? BUCKET_ENDPOINTS.GET_BY_FOLDER : BUCKET_ENDPOINTS.GET_ALL,
2081
+ getByFolderEndpoint: BUCKET_ENDPOINTS.GET_BY_FOLDER,
2082
+ transformFn: transformBucketResponse,
2083
+ pagination: {
2084
+ paginationType: PaginationType.OFFSET,
2085
+ itemsField: ODATA_PAGINATION.ITEMS_FIELD,
2086
+ totalCountField: ODATA_PAGINATION.TOTAL_COUNT_FIELD,
2087
+ paginationParams: {
2088
+ pageSizeParam: ODATA_OFFSET_PARAMS.PAGE_SIZE_PARAM,
2089
+ offsetParam: ODATA_OFFSET_PARAMS.OFFSET_PARAM,
2090
+ countParam: ODATA_OFFSET_PARAMS.COUNT_PARAM
2091
+ }
2092
+ }
2093
+ }, options);
2094
+ }
2095
+ /**
2096
+ * Gets metadata for files in a bucket with optional filtering and pagination
2097
+ *
2098
+ * The method returns either:
2099
+ * - A NonPaginatedResponse with items array (when no pagination parameters are provided)
2100
+ * - A PaginatedResponse with navigation cursors (when any pagination parameter is provided)
2101
+ *
2102
+ * @param bucketId - The ID of the bucket to get file metadata from
2103
+ * @param folderId - Required folder ID for organization unit context
2104
+ * @param options - Optional parameters for filtering, pagination and access URL generation
2105
+ * @returns Promise resolving to the list of file metadata in the bucket or paginated result
2106
+ *
2107
+ * @example
2108
+ * ```typescript
2109
+ * import { Buckets } from '@uipath/uipath-typescript/buckets';
2110
+ *
2111
+ * const buckets = new Buckets(sdk);
2112
+ *
2113
+ * // Get metadata for all files in a bucket
2114
+ * const fileMetadata = await buckets.getFileMetaData(123, 456);
2115
+ *
2116
+ * // Get file metadata with a specific prefix
2117
+ * const fileMetadata = await buckets.getFileMetaData(123, 456, {
2118
+ * prefix: '/folder1'
2119
+ * });
2120
+ *
2121
+ * // First page with pagination
2122
+ * const page1 = await buckets.getFileMetaData(123, 456, { pageSize: 10 });
2123
+ *
2124
+ * // Navigate using cursor
2125
+ * if (page1.hasNextPage) {
2126
+ * const page2 = await buckets.getFileMetaData(123, 456, { cursor: page1.nextCursor });
2127
+ * }
2128
+ * ```
2129
+ */
2130
+ async getFileMetaData(bucketId, folderId, options) {
2131
+ if (!bucketId) {
2132
+ throw new ValidationError({ message: 'bucketId is required for getFileMetaData' });
2133
+ }
2134
+ if (!folderId) {
2135
+ throw new ValidationError({ message: 'folderId is required for getFileMetaData' });
2136
+ }
2137
+ // Transformation function for blob items
2138
+ const transformBlobItem = (item) => transformData(item, BucketMap);
2139
+ return PaginationHelpers.getAll({
2140
+ serviceAccess: this.createPaginationServiceAccess(),
2141
+ getEndpoint: () => BUCKET_ENDPOINTS.GET_FILE_META_DATA(bucketId),
2142
+ transformFn: transformBlobItem,
2143
+ pagination: {
2144
+ paginationType: PaginationType.TOKEN,
2145
+ itemsField: BUCKET_PAGINATION.ITEMS_FIELD,
2146
+ continuationTokenField: BUCKET_PAGINATION.CONTINUATION_TOKEN_FIELD,
2147
+ paginationParams: {
2148
+ pageSizeParam: BUCKET_TOKEN_PARAMS.PAGE_SIZE_PARAM,
2149
+ tokenParam: BUCKET_TOKEN_PARAMS.TOKEN_PARAM
2150
+ }
2151
+ },
2152
+ excludeFromPrefix: ['prefix'] // Bucket-specific param, not OData
2153
+ }, { ...options, folderId });
2154
+ }
2155
+ /**
2156
+ * Uploads a file to a bucket
2157
+ *
2158
+ * @param options - Options for file upload including bucket ID, folder ID, path, content, and optional parameters
2159
+ * @returns Promise resolving to a response with success status and HTTP status code
2160
+ *
2161
+ * @example
2162
+ * ```typescript
2163
+ * import { Buckets } from '@uipath/uipath-typescript/buckets';
2164
+ *
2165
+ * const buckets = new Buckets(sdk);
2166
+ *
2167
+ * // Upload a file from browser
2168
+ * const file = new File(['file content'], 'example.txt');
2169
+ * const result = await buckets.uploadFile({
2170
+ * bucketId: 123,
2171
+ * folderId: 456,
2172
+ * path: '/folder/example.txt',
2173
+ * content: file
2174
+ * });
2175
+ *
2176
+ * // In Node env with Buffer
2177
+ * const buffer = Buffer.from('file content');
2178
+ * const result = await buckets.uploadFile({
2179
+ * bucketId: 123,
2180
+ * folderId: 456,
2181
+ * path: '/folder/example.txt',
2182
+ * content: buffer
2183
+ * });
2184
+ * ```
2185
+ */
2186
+ async uploadFile(options) {
2187
+ const { bucketId, folderId, path, content } = options;
2188
+ if (!bucketId) {
2189
+ throw new ValidationError({ message: 'bucketId is required for uploadFile' });
2190
+ }
2191
+ if (!folderId) {
2192
+ throw new ValidationError({ message: 'folderId is required for uploadFile' });
2193
+ }
2194
+ if (!path) {
2195
+ throw new ValidationError({ message: 'path is required for uploadFile' });
2196
+ }
2197
+ if (!content) {
2198
+ throw new ValidationError({ message: 'content is required for uploadFile' });
2199
+ }
2200
+ const uriResponse = await this._getWriteUri({
2201
+ bucketId,
2202
+ folderId,
2203
+ path,
2204
+ });
2205
+ // Upload file to the provided URI
2206
+ const response = await this._uploadToUri(uriResponse, content);
2207
+ return {
2208
+ success: response.status >= 200 && response.status < 300,
2209
+ statusCode: response.status
2210
+ };
2211
+ }
2212
+ /**
2213
+ * Gets a direct download URL for a file in the bucket
2214
+ *
2215
+ * @param options - Contains bucketId, folderId, file path and optional expiry time
2216
+ * @returns Promise resolving to blob file access information
2217
+ *
2218
+ * @example
2219
+ * ```typescript
2220
+ * import { Buckets } from '@uipath/uipath-typescript/buckets';
2221
+ *
2222
+ * const buckets = new Buckets(sdk);
2223
+ *
2224
+ * // Get download URL for a file
2225
+ * const fileAccess = await buckets.getReadUri({
2226
+ * bucketId: 123,
2227
+ * folderId: 456,
2228
+ * path: '/folder/file.pdf'
2229
+ * });
2230
+ * ```
2231
+ */
2232
+ async getReadUri(options) {
2233
+ const { bucketId, folderId, path, expiryInMinutes, ...restOptions } = options;
2234
+ const queryOptions = {
2235
+ expiryInMinutes,
2236
+ ...addPrefixToKeys(restOptions, ODATA_PREFIX, Object.keys(restOptions))
2237
+ };
2238
+ return this._getUri(BUCKET_ENDPOINTS.GET_READ_URI(bucketId), bucketId, folderId, path, queryOptions);
2239
+ }
2240
+ /**
2241
+ * Uploads content to the provided URI
2242
+ * @param uriResponse - Response from getWriteUri containing URL and headers
2243
+ * @param content - The content to upload
2244
+ * @returns The response from the upload request with status info
2245
+ */
2246
+ async _uploadToUri(uriResponse, content) {
2247
+ const { uri, headers = {}, requiresAuth } = uriResponse;
2248
+ if (!uri) {
2249
+ throw new ValidationError({ message: 'Upload URI not available', statusCode: HttpStatus.BAD_REQUEST });
2250
+ }
2251
+ // Create headers for the request
2252
+ let requestHeaders = { ...headers };
2253
+ // Add auth header if required
2254
+ if (requiresAuth) {
2255
+ const token = await this.getValidAuthToken();
2256
+ requestHeaders['Authorization'] = `Bearer ${token}`;
2257
+ }
2258
+ return fetch(uri, {
2259
+ method: 'PUT',
2260
+ body: content,
2261
+ headers: createHeaders(requestHeaders),
2262
+ });
2263
+ }
2264
+ /**
2265
+ * Private method to handle common URI request logic
2266
+ * @param endpoint - The API endpoint to call
2267
+ * @param bucketId - The bucket ID
2268
+ * @param folderId - The folder ID
2269
+ * @param path - The file path
2270
+ * @param queryOptions - Additional query parameters
2271
+ * @returns Promise resolving to blob file access information
2272
+ */
2273
+ async _getUri(endpoint, bucketId, folderId, path, queryOptions = {}) {
2274
+ if (!bucketId) {
2275
+ throw new ValidationError({ message: 'bucketId is required for getUri' });
2276
+ }
2277
+ if (!folderId) {
2278
+ throw new ValidationError({ message: 'folderId is required for getUri' });
2279
+ }
2280
+ if (!path) {
2281
+ throw new ValidationError({ message: 'path is required for getUri' });
2282
+ }
2283
+ // Create headers with required folder ID
2284
+ const headers = createHeaders({ [FOLDER_ID]: folderId });
2285
+ // Filter out undefined values and build query params
2286
+ const queryParams = filterUndefined({
2287
+ path,
2288
+ ...queryOptions
2289
+ });
2290
+ // Make the API call to get URI
2291
+ const response = await this.get(endpoint, {
2292
+ params: queryParams,
2293
+ headers
2294
+ });
2295
+ const transformedData = transformData(pascalToCamelCaseKeys(response.data), BucketMap);
2296
+ // Convert headers from array-based to record if needed
2297
+ if (transformedData.headers && 'keys' in transformedData.headers && 'values' in transformedData.headers) {
2298
+ transformedData.headers = arrayDictionaryToRecord(transformedData.headers);
2299
+ }
2300
+ return transformedData;
2301
+ }
2302
+ /**
2303
+ * Gets a direct upload URL for a file in the bucket
2304
+ *
2305
+ * @param options - Contains bucketId, folderId, file path, optional expiry time
2306
+ * @returns Promise resolving to blob file access information
2307
+ */
2308
+ async _getWriteUri(options) {
2309
+ const { bucketId, folderId, path, expiryInMinutes, ...restOptions } = options;
2310
+ const queryOptions = {
2311
+ expiryInMinutes,
2312
+ ...addPrefixToKeys(restOptions, ODATA_PREFIX, Object.keys(restOptions))
2313
+ };
2314
+ return this._getUri(BUCKET_ENDPOINTS.GET_WRITE_URI(bucketId), bucketId, folderId, path, queryOptions);
2315
+ }
2316
+ }
2317
+ __decorate([
2318
+ track('Buckets.GetById')
2319
+ ], BucketService.prototype, "getById", null);
2320
+ __decorate([
2321
+ track('Buckets.GetAll')
2322
+ ], BucketService.prototype, "getAll", null);
2323
+ __decorate([
2324
+ track('Buckets.GetFileMetaData')
2325
+ ], BucketService.prototype, "getFileMetaData", null);
2326
+ __decorate([
2327
+ track('Buckets.UploadFile')
2328
+ ], BucketService.prototype, "uploadFile", null);
2329
+ __decorate([
2330
+ track('Buckets.GetReadUri')
2331
+ ], BucketService.prototype, "getReadUri", null);
2332
+
2333
+ exports.BucketOptions = void 0;
2334
+ (function (BucketOptions) {
2335
+ BucketOptions["None"] = "None";
2336
+ BucketOptions["ReadOnly"] = "ReadOnly";
2337
+ BucketOptions["AuditReadAccess"] = "AuditReadAccess";
2338
+ BucketOptions["AccessDataThroughOrchestrator"] = "AccessDataThroughOrchestrator";
2339
+ })(exports.BucketOptions || (exports.BucketOptions = {}));
2340
+
2341
+ exports.BucketService = BucketService;
2342
+ exports.Buckets = BucketService;