@uipath/uipath-typescript 1.3.2 → 1.3.3

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.
@@ -0,0 +1,475 @@
1
+ import { IUiPath } from '../core/index';
2
+
3
+ /**
4
+ * Simplified universal pagination cursor
5
+ * Used to fetch next/previous pages
6
+ */
7
+ interface PaginationCursor {
8
+ /** Opaque string containing all information needed to fetch next page */
9
+ value: string;
10
+ }
11
+ /**
12
+ * Discriminated union for pagination methods - ensures cursor and jumpToPage are mutually exclusive
13
+ */
14
+ type PaginationMethodUnion = {
15
+ cursor?: PaginationCursor;
16
+ jumpToPage?: never;
17
+ } | {
18
+ cursor?: never;
19
+ jumpToPage?: number;
20
+ } | {
21
+ cursor?: never;
22
+ jumpToPage?: never;
23
+ };
24
+ /**
25
+ * Pagination options. Users cannot specify both cursor and jumpToPage.
26
+ */
27
+ type PaginationOptions = {
28
+ /** Size of the page to fetch (items per page) */
29
+ pageSize?: number;
30
+ } & PaginationMethodUnion;
31
+ /**
32
+ * Paginated response containing items and navigation information
33
+ */
34
+ interface PaginatedResponse<T> {
35
+ /** The items in the current page */
36
+ items: T[];
37
+ /** Total count of items across all pages (if available) */
38
+ totalCount?: number;
39
+ /** Whether more pages are available */
40
+ hasNextPage: boolean;
41
+ /** Cursor to fetch the next page (if available) */
42
+ nextCursor?: PaginationCursor;
43
+ /** Cursor to fetch the previous page (if available) */
44
+ previousCursor?: PaginationCursor;
45
+ /** Current page number (1-based, if available) */
46
+ currentPage?: number;
47
+ /** Total number of pages (if available) */
48
+ totalPages?: number;
49
+ /** Whether this pagination type supports jumping to arbitrary pages */
50
+ supportsPageJump: boolean;
51
+ }
52
+ /**
53
+ * Response for non-paginated calls that includes both data and total count
54
+ */
55
+ interface NonPaginatedResponse<T> {
56
+ items: T[];
57
+ totalCount?: number;
58
+ }
59
+ /**
60
+ * Helper type for defining paginated method overloads
61
+ * Creates a union type of all ways pagination can be triggered
62
+ */
63
+ type HasPaginationOptions<T> = (T & {
64
+ pageSize: number;
65
+ }) | (T & {
66
+ cursor: PaginationCursor;
67
+ }) | (T & {
68
+ jumpToPage: number;
69
+ });
70
+
71
+ /**
72
+ * Pagination types supported by the SDK
73
+ */
74
+ declare enum PaginationType {
75
+ OFFSET = "offset",
76
+ TOKEN = "token"
77
+ }
78
+ /**
79
+ * Interface for service access methods needed by pagination helpers
80
+ */
81
+ interface PaginationServiceAccess {
82
+ get<T>(path: string, options?: any): Promise<{
83
+ data: T;
84
+ }>;
85
+ post<T>(path: string, body?: any, options?: any): Promise<{
86
+ data: T;
87
+ }>;
88
+ requestWithPagination<T>(method: string, path: string, paginationOptions: PaginationOptions, options: RequestWithPaginationOptions): Promise<PaginatedResponse<T>>;
89
+ }
90
+ /**
91
+ * Field names for extracting data from paginated responses.
92
+ */
93
+ interface PaginationFieldNames {
94
+ itemsField?: string;
95
+ totalCountField?: string;
96
+ continuationTokenField?: string;
97
+ }
98
+ /**
99
+ * Options for the requestWithPagination method in BaseService.
100
+ */
101
+ interface RequestWithPaginationOptions extends RequestSpec {
102
+ pagination: PaginationFieldNames & {
103
+ paginationType: PaginationType;
104
+ paginationParams?: {
105
+ pageSizeParam?: string;
106
+ offsetParam?: string;
107
+ tokenParam?: string;
108
+ countParam?: string;
109
+ };
110
+ };
111
+ }
112
+
113
+ /**
114
+ * HTTP methods supported by the API client
115
+ */
116
+ type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD' | 'OPTIONS';
117
+ /**
118
+ * Supported response types for API requests
119
+ */
120
+ type ResponseType = 'json' | 'text' | 'blob' | 'arraybuffer' | 'stream';
121
+ /**
122
+ * Query parameters type with support for arrays and nested objects
123
+ */
124
+ type QueryParams = Record<string, string | number | boolean | Array<string | number | boolean> | null | undefined>;
125
+ /**
126
+ * Standard HTTP headers type
127
+ */
128
+ type Headers = Record<string, string>;
129
+ /**
130
+ * Options for request retries
131
+ */
132
+ interface RetryOptions {
133
+ /** Maximum number of retry attempts */
134
+ maxRetries?: number;
135
+ /** Base delay between retries in milliseconds */
136
+ retryDelay?: number;
137
+ /** Whether to use exponential backoff */
138
+ useExponentialBackoff?: boolean;
139
+ /** Status codes that should trigger a retry */
140
+ retryableStatusCodes?: number[];
141
+ }
142
+ /**
143
+ * Options for request timeouts
144
+ */
145
+ interface TimeoutOptions {
146
+ /** Request timeout in milliseconds */
147
+ timeout?: number;
148
+ /** Whether to abort the request on timeout */
149
+ abortOnTimeout?: boolean;
150
+ }
151
+ /**
152
+ * Options for request body transformation
153
+ */
154
+ interface BodyOptions {
155
+ /** Whether to stringify the body */
156
+ stringify?: boolean;
157
+ /** Content type override */
158
+ contentType?: string;
159
+ }
160
+ /**
161
+ * Pagination metadata for API requests
162
+ */
163
+ interface PaginationMetadata {
164
+ /** Type of pagination used by the API endpoint */
165
+ paginationType: PaginationType;
166
+ /** Response field containing items array (defaults to 'value') */
167
+ itemsField?: string;
168
+ /** Response field containing total count (defaults to '@odata.count') */
169
+ totalCountField?: string;
170
+ /** Response field containing continuation token (defaults to 'continuationToken') */
171
+ continuationTokenField?: string;
172
+ }
173
+ /**
174
+ * Base interface for all API requests
175
+ */
176
+ interface RequestSpec {
177
+ /** HTTP method for the request */
178
+ method?: HttpMethod;
179
+ /** URL endpoint for the request */
180
+ url?: string;
181
+ /** Query parameters to be appended to the URL */
182
+ params?: QueryParams;
183
+ /** HTTP headers to include with the request */
184
+ headers?: Headers;
185
+ /** Raw body content (takes precedence over data) */
186
+ body?: unknown;
187
+ /** Expected response type */
188
+ responseType?: ResponseType;
189
+ /** Request timeout options */
190
+ timeoutOptions?: TimeoutOptions;
191
+ /** Retry behavior options */
192
+ retryOptions?: RetryOptions;
193
+ /** Body transformation options */
194
+ bodyOptions?: BodyOptions;
195
+ /** AbortSignal for cancelling the request */
196
+ signal?: AbortSignal;
197
+ /** Pagination metadata for the request */
198
+ pagination?: PaginationMetadata;
199
+ }
200
+
201
+ interface ApiResponse<T> {
202
+ data: T;
203
+ }
204
+ /**
205
+ * Base class for all UiPath SDK services.
206
+ *
207
+ * Provides common functionality for authentication, configuration, and API communication.
208
+ * All service classes extend this base to inherit dependency injection and HTTP client access.
209
+ *
210
+ * This class implements the dependency injection pattern where services receive a configured
211
+ * UiPath instance. The ApiClient is created internally and handles all HTTP operations
212
+ * including authentication token management.
213
+ *
214
+ * @remarks
215
+ * Service classes should extend this base and call `super(uiPath)` in their constructor.
216
+ * Protected HTTP methods (get, post, put, patch, delete) are available to all subclasses.
217
+ *
218
+ */
219
+ declare class BaseService {
220
+ #private;
221
+ /**
222
+ * Creates a base service instance with dependency injection.
223
+ *
224
+ * Extracts configuration, execution context, and token manager from the UiPath instance
225
+ * to initialize an authenticated API client. The ApiClient handles all HTTP operations
226
+ * and token management internally.
227
+ *
228
+ * @param instance - UiPath SDK instance providing authentication and configuration.
229
+ * Services receive this via dependency injection in the modular pattern.
230
+ * @param headers - Optional default headers to include in every request (e.g. `x-uipath-external-user-id` for
231
+ * CAS external-app auth)
232
+ *
233
+ * @example
234
+ * ```typescript
235
+ * // Services automatically call this via super()
236
+ * export class EntityService extends BaseService {
237
+ * constructor(instance: IUiPath) {
238
+ * super(instance); // Initializes the internal ApiClient
239
+ * }
240
+ * }
241
+ *
242
+ * // Usage in modular pattern
243
+ * import { UiPath } from '@uipath/uipath-typescript/core';
244
+ * import { Entities } from '@uipath/uipath-typescript/entities';
245
+ *
246
+ * const sdk = new UiPath(config);
247
+ * await sdk.initialize();
248
+ * const entities = new Entities(sdk);
249
+ * ```
250
+ */
251
+ constructor(instance: IUiPath, headers?: Record<string, string>);
252
+ /**
253
+ * Gets a valid authentication token, refreshing if necessary.
254
+ * Use this when you need to manually add Authorization headers (e.g., direct uploads).
255
+ *
256
+ * @returns Promise resolving to a valid access token string
257
+ * @throws AuthenticationError if no token is available or refresh fails
258
+ */
259
+ protected getValidAuthToken(): Promise<string>;
260
+ /**
261
+ * Creates a service accessor for pagination helpers
262
+ * This allows pagination helpers to access protected methods without making them public
263
+ */
264
+ protected createPaginationServiceAccess(): PaginationServiceAccess;
265
+ protected request<T>(method: string, path: string, options?: RequestSpec): Promise<ApiResponse<T>>;
266
+ protected requestWithSpec<T>(spec: RequestSpec): Promise<ApiResponse<T>>;
267
+ protected get<T>(path: string, options?: RequestSpec): Promise<ApiResponse<T>>;
268
+ protected post<T>(path: string, data?: unknown, options?: RequestSpec): Promise<ApiResponse<T>>;
269
+ protected put<T>(path: string, data?: unknown, options?: RequestSpec): Promise<ApiResponse<T>>;
270
+ protected patch<T>(path: string, data?: unknown, options?: RequestSpec): Promise<ApiResponse<T>>;
271
+ protected delete<T>(path: string, options?: RequestSpec): Promise<ApiResponse<T>>;
272
+ /**
273
+ * Execute a request with cursor-based pagination
274
+ */
275
+ protected requestWithPagination<T>(method: string, path: string, paginationOptions: PaginationOptions, options: RequestWithPaginationOptions): Promise<PaginatedResponse<T>>;
276
+ /**
277
+ * Validates and prepares pagination parameters from options
278
+ */
279
+ private validateAndPreparePaginationParams;
280
+ /**
281
+ * Prepares request parameters for pagination based on pagination type
282
+ */
283
+ private preparePaginationRequestParams;
284
+ /**
285
+ * Creates a paginated response from API response
286
+ */
287
+ private createPaginatedResponseFromResponse;
288
+ /**
289
+ * Determines if there are more pages based on pagination type and metadata
290
+ */
291
+ private determineHasMorePages;
292
+ }
293
+
294
+ /**
295
+ * Represents a category that can be associated with feedback.
296
+ * Default categories (Output, Agent Error, Agent Plan Execution) are auto-created per tenant.
297
+ */
298
+ interface FeedbackCategory {
299
+ /** Unique identifier of the feedback category */
300
+ id: string;
301
+ /** Category name (max 256 characters, unique per tenant) */
302
+ category: string;
303
+ /** Timestamp when the category was created */
304
+ createdAt: string;
305
+ /** Whether this is a system default category (e.g., Output, Agent Error, Agent Plan Execution) */
306
+ isDefault: boolean;
307
+ /** Whether this category applies to positive feedback */
308
+ isPositive: boolean;
309
+ /** Whether this category applies to negative feedback */
310
+ isNegative: boolean;
311
+ }
312
+ /**
313
+ * Status of a feedback entry in the review workflow
314
+ */
315
+ declare enum FeedbackStatus {
316
+ /** Feedback is awaiting review */
317
+ Pending = 0,
318
+ /** Feedback has been approved and confirmed */
319
+ Approved = 1,
320
+ /** Feedback has been dismissed */
321
+ Dismissed = 2
322
+ }
323
+ /**
324
+ * Complete feedback object returned from the API
325
+ */
326
+ interface FeedbackGetResponse {
327
+ /** Unique identifier of the feedback entry */
328
+ id: string;
329
+ /** Trace identifier linking feedback to a specific agent execution */
330
+ traceId: string;
331
+ /** Span identifier representing a specific operation within the trace */
332
+ spanId: string;
333
+ /** Identifier of the agent that generated the response being reviewed */
334
+ agentId: string | null;
335
+ /** Version of the agent at the time the feedback was given (max 100 characters) */
336
+ agentVersion?: string;
337
+ /** Optional text comment provided by the user (max 4000 characters) */
338
+ comment?: string;
339
+ /** Optional metadata string associated with the feedback (max 4000 characters) */
340
+ metadata?: string;
341
+ /** Whether the feedback is positive (thumbs up) or negative (thumbs down) */
342
+ isPositive: boolean;
343
+ /** Categories associated with this feedback entry */
344
+ feedbackCategories: FeedbackCategory[];
345
+ /** Email address of the user who submitted the feedback */
346
+ userEmail?: string;
347
+ /** Current status of the feedback in the review workflow */
348
+ status: FeedbackStatus;
349
+ /** Timestamp when the feedback was created */
350
+ createdTime: string;
351
+ /** Timestamp when the feedback was last updated */
352
+ updatedTime: string;
353
+ }
354
+ /**
355
+ * Options for retrieving multiple feedback entries
356
+ */
357
+ type FeedbackGetAllOptions = PaginationOptions & {
358
+ /** Filter by agent identifier */
359
+ agentId?: string;
360
+ /** Filter by agent version */
361
+ agentVersion?: string;
362
+ /** Filter by feedback status */
363
+ status?: FeedbackStatus;
364
+ /** Filter by OpenTelemetry trace identifier */
365
+ traceId?: string;
366
+ /** Filter by OpenTelemetry span identifier */
367
+ spanId?: string;
368
+ };
369
+
370
+ /**
371
+ * Service for managing UiPath Agent Feedback.
372
+ *
373
+ * Feedback allows you to collect and manage user feedback on AI agent responses,
374
+ * including positive/negative ratings, comments, and categorized feedback.
375
+ * This is useful for monitoring agent quality, identifying areas for improvement,
376
+ * and building datasets for fine-tuning. [Feedback on agent runs](https://docs.uipath.com/agents/automation-cloud/latest/user-guide/agent-traces#feedback-on-agent-runs)
377
+ *
378
+ * ### Usage
379
+ *
380
+ * Prerequisites: Initialize the SDK first - see [Getting Started](/uipath-typescript/getting-started/#import-initialize)
381
+ *
382
+ * ```typescript
383
+ * import { Feedback } from '@uipath/uipath-typescript/feedback';
384
+ *
385
+ * const feedback = new Feedback(sdk);
386
+ * const allFeedback = await feedback.getAll();
387
+ * ```
388
+ */
389
+ interface FeedbackServiceModel {
390
+ /**
391
+ * Gets all feedback across all agents in the tenant, with optional filters.
392
+ *
393
+ * Retrieves a list of feedback entries, optionally filtered by agent, trace, span, status, or agent version.
394
+ * When no pagination options are provided, the API returns up to 100 items. When pagination options are provided without a pageSize, the SDK defaults to 50 items per page.
395
+ *
396
+ * @param options - Optional query parameters for filtering and pagination
397
+ * @returns Promise resolving to {@link NonPaginatedResponse} of {@link FeedbackGetResponse} without pagination options, or {@link PaginatedResponse} of {@link FeedbackGetResponse} when pagination options are used.
398
+ * @example
399
+ * ```typescript
400
+ * import { Feedback, FeedbackStatus } from '@uipath/uipath-typescript/feedback';
401
+ *
402
+ * // Get all feedback (returns API default page size)
403
+ * const allFeedback = await feedback.getAll();
404
+ *
405
+ * // Get the agentId from a feedback entry
406
+ * const agentId = allFeedback.items[0].agentId;
407
+ *
408
+ * // Get feedback for a specific agent
409
+ * const agentFeedback = await feedback.getAll({
410
+ * agentId,
411
+ * });
412
+ *
413
+ * // First page with pagination
414
+ * const page1 = await feedback.getAll({ pageSize: 10 });
415
+ *
416
+ * // Navigate using cursor
417
+ * if (page1.hasNextPage) {
418
+ * const page2 = await feedback.getAll({ cursor: page1.nextCursor });
419
+ * }
420
+ *
421
+ * // Filter by status
422
+ * const activeFeedback = await feedback.getAll({
423
+ * status: FeedbackStatus.Pending,
424
+ * });
425
+ * ```
426
+ */
427
+ getAll<T extends FeedbackGetAllOptions = FeedbackGetAllOptions>(options?: T): Promise<T extends HasPaginationOptions<T> ? PaginatedResponse<FeedbackGetResponse> : NonPaginatedResponse<FeedbackGetResponse>>;
428
+ }
429
+
430
+ /**
431
+ * Service for interacting with UiPath Agent Feedback API
432
+ */
433
+ declare class FeedbackService extends BaseService implements FeedbackServiceModel {
434
+ /**
435
+ * Gets all feedback across all agents in the tenant, with optional filters.
436
+ *
437
+ * Retrieves a list of feedback entries, optionally filtered by agent, trace, span, status, or agent version.
438
+ * When no pagination options are provided, the API returns up to 100 items. When pagination options are provided without a pageSize, the SDK defaults to 50 items per page.
439
+ *
440
+ * @param options - Optional query parameters for filtering and pagination
441
+ * @returns Promise resolving to {@link NonPaginatedResponse} of {@link FeedbackGetResponse} without pagination options, or {@link PaginatedResponse} of {@link FeedbackGetResponse} when pagination options are used.
442
+ * @example
443
+ * ```typescript
444
+ * import { Feedback, FeedbackStatus } from '@uipath/uipath-typescript/feedback';
445
+ *
446
+ * // Get all feedback (default pagination: returns first 50 items)
447
+ * const allFeedback = await feedback.getAll();
448
+ *
449
+ * // Get the agentId from a feedback entry
450
+ * const agentId = allFeedback.items[0].agentId;
451
+ *
452
+ * // Get feedback for a specific agent
453
+ * const agentFeedback = await feedback.getAll({
454
+ * agentId,
455
+ * });
456
+ *
457
+ * // First page with pagination
458
+ * const page1 = await feedback.getAll({ pageSize: 10 });
459
+ *
460
+ * // Navigate using cursor
461
+ * if (page1.hasNextPage) {
462
+ * const page2 = await feedback.getAll({ cursor: page1.nextCursor });
463
+ * }
464
+ *
465
+ * // Filter by status
466
+ * const activeFeedback = await feedback.getAll({
467
+ * status: FeedbackStatus.Pending,
468
+ * });
469
+ * ```
470
+ */
471
+ getAll<T extends FeedbackGetAllOptions = FeedbackGetAllOptions>(options?: T): Promise<T extends HasPaginationOptions<T> ? PaginatedResponse<FeedbackGetResponse> : NonPaginatedResponse<FeedbackGetResponse>>;
472
+ }
473
+
474
+ export { FeedbackService as Feedback, FeedbackStatus };
475
+ export type { FeedbackCategory, FeedbackGetAllOptions, FeedbackGetResponse, FeedbackServiceModel };