@uipath/uipath-typescript 1.0.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +2 -2
- package/README.md +2 -0
- package/dist/assets/index.cjs +199 -221
- package/dist/assets/index.mjs +199 -221
- package/dist/buckets/index.cjs +199 -221
- package/dist/buckets/index.mjs +199 -221
- package/dist/cases/index.cjs +220 -238
- package/dist/cases/index.mjs +220 -238
- package/dist/conversational-agent/index.cjs +6622 -0
- package/dist/conversational-agent/index.d.ts +6579 -0
- package/dist/conversational-agent/index.mjs +6575 -0
- package/dist/core/index.cjs +1264 -1111
- package/dist/core/index.d.ts +111 -11
- package/dist/core/index.mjs +1247 -1112
- package/dist/entities/index.cjs +199 -221
- package/dist/entities/index.mjs +199 -221
- package/dist/index.cjs +799 -435
- package/dist/index.d.ts +4403 -64
- package/dist/index.mjs +793 -436
- package/dist/index.umd.js +799 -435
- package/dist/maestro-processes/index.cjs +199 -221
- package/dist/maestro-processes/index.mjs +199 -221
- package/dist/processes/index.cjs +246 -232
- package/dist/processes/index.d.ts +1 -1
- package/dist/processes/index.mjs +246 -232
- package/dist/queues/index.cjs +199 -221
- package/dist/queues/index.mjs +199 -221
- package/dist/tasks/index.cjs +199 -221
- package/dist/tasks/index.mjs +199 -221
- package/package.json +22 -4
package/dist/index.umd.js
CHANGED
|
@@ -3888,6 +3888,15 @@
|
|
|
3888
3888
|
*/
|
|
3889
3889
|
const isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
|
|
3890
3890
|
|
|
3891
|
+
/**
|
|
3892
|
+
* Session storage keys used by the auth module
|
|
3893
|
+
*/
|
|
3894
|
+
const AUTH_STORAGE_KEYS = {
|
|
3895
|
+
TOKEN_PREFIX: 'uipath_sdk_user_token-',
|
|
3896
|
+
OAUTH_CONTEXT: 'uipath_sdk_oauth_context',
|
|
3897
|
+
CODE_VERIFIER: 'uipath_sdk_code_verifier',
|
|
3898
|
+
};
|
|
3899
|
+
|
|
3891
3900
|
// Type guard to check if config has OAuth credentials
|
|
3892
3901
|
function hasOAuthConfig(config) {
|
|
3893
3902
|
return Boolean(config.clientId && config.redirectUri && config.scope);
|
|
@@ -3897,6 +3906,303 @@
|
|
|
3897
3906
|
return Boolean(config.secret);
|
|
3898
3907
|
}
|
|
3899
3908
|
|
|
3909
|
+
/**
|
|
3910
|
+
* Base error class for all UiPath SDK errors
|
|
3911
|
+
* Extends Error for standard error handling compatibility
|
|
3912
|
+
*/
|
|
3913
|
+
class UiPathError extends Error {
|
|
3914
|
+
constructor(type, params) {
|
|
3915
|
+
super(params.message);
|
|
3916
|
+
this.name = type;
|
|
3917
|
+
this.type = type;
|
|
3918
|
+
this.statusCode = params.statusCode;
|
|
3919
|
+
this.requestId = params.requestId;
|
|
3920
|
+
this.timestamp = new Date();
|
|
3921
|
+
// Maintains proper stack trace for where our error was thrown
|
|
3922
|
+
if (Error.captureStackTrace) {
|
|
3923
|
+
Error.captureStackTrace(this, this.constructor);
|
|
3924
|
+
}
|
|
3925
|
+
}
|
|
3926
|
+
/**
|
|
3927
|
+
* Returns a clean JSON representation of the error
|
|
3928
|
+
*/
|
|
3929
|
+
toJSON() {
|
|
3930
|
+
return {
|
|
3931
|
+
type: this.type,
|
|
3932
|
+
message: this.message,
|
|
3933
|
+
statusCode: this.statusCode,
|
|
3934
|
+
requestId: this.requestId,
|
|
3935
|
+
timestamp: this.timestamp
|
|
3936
|
+
};
|
|
3937
|
+
}
|
|
3938
|
+
/**
|
|
3939
|
+
* Returns detailed debug information including stack trace
|
|
3940
|
+
*/
|
|
3941
|
+
getDebugInfo() {
|
|
3942
|
+
return {
|
|
3943
|
+
...this.toJSON(),
|
|
3944
|
+
stack: this.stack
|
|
3945
|
+
};
|
|
3946
|
+
}
|
|
3947
|
+
}
|
|
3948
|
+
|
|
3949
|
+
/**
|
|
3950
|
+
* HTTP status code constants for error handling
|
|
3951
|
+
*/
|
|
3952
|
+
const HttpStatus = {
|
|
3953
|
+
// Client errors (4xx)
|
|
3954
|
+
BAD_REQUEST: 400,
|
|
3955
|
+
UNAUTHORIZED: 401,
|
|
3956
|
+
FORBIDDEN: 403,
|
|
3957
|
+
NOT_FOUND: 404,
|
|
3958
|
+
TOO_MANY_REQUESTS: 429,
|
|
3959
|
+
// Server errors (5xx)
|
|
3960
|
+
INTERNAL_SERVER_ERROR: 500,
|
|
3961
|
+
NOT_IMPLEMENTED: 501,
|
|
3962
|
+
BAD_GATEWAY: 502,
|
|
3963
|
+
SERVICE_UNAVAILABLE: 503,
|
|
3964
|
+
GATEWAY_TIMEOUT: 504
|
|
3965
|
+
};
|
|
3966
|
+
/**
|
|
3967
|
+
* Error type constants for consistent error identification
|
|
3968
|
+
*/
|
|
3969
|
+
const ErrorType = {
|
|
3970
|
+
AUTHENTICATION: 'AuthenticationError',
|
|
3971
|
+
AUTHORIZATION: 'AuthorizationError',
|
|
3972
|
+
VALIDATION: 'ValidationError',
|
|
3973
|
+
NOT_FOUND: 'NotFoundError',
|
|
3974
|
+
RATE_LIMIT: 'RateLimitError',
|
|
3975
|
+
SERVER: 'ServerError',
|
|
3976
|
+
NETWORK: 'NetworkError'
|
|
3977
|
+
};
|
|
3978
|
+
/**
|
|
3979
|
+
* HTTP header constants for error handling
|
|
3980
|
+
*/
|
|
3981
|
+
const HttpHeaders = {
|
|
3982
|
+
X_REQUEST_ID: 'x-request-id'
|
|
3983
|
+
};
|
|
3984
|
+
/**
|
|
3985
|
+
* Standard error message constants
|
|
3986
|
+
*/
|
|
3987
|
+
const ErrorMessages = {
|
|
3988
|
+
// Authentication errors
|
|
3989
|
+
AUTHENTICATION_FAILED: 'Authentication failed',
|
|
3990
|
+
// Authorization errors
|
|
3991
|
+
ACCESS_DENIED: 'Access denied',
|
|
3992
|
+
// Validation errors
|
|
3993
|
+
VALIDATION_FAILED: 'Validation failed',
|
|
3994
|
+
// Not found errors
|
|
3995
|
+
RESOURCE_NOT_FOUND: 'Resource not found',
|
|
3996
|
+
// Rate limit errors
|
|
3997
|
+
RATE_LIMIT_EXCEEDED: 'Rate limit exceeded',
|
|
3998
|
+
// Server errors
|
|
3999
|
+
INTERNAL_SERVER_ERROR: 'Internal Server error occurred',
|
|
4000
|
+
// Network errors
|
|
4001
|
+
NETWORK_ERROR: 'Network error occurred',
|
|
4002
|
+
REQUEST_TIMEOUT: 'Request timed out',
|
|
4003
|
+
REQUEST_ABORTED: 'Request was aborted',
|
|
4004
|
+
};
|
|
4005
|
+
/**
|
|
4006
|
+
* Error name constants for network error identification
|
|
4007
|
+
*/
|
|
4008
|
+
const ErrorNames = {
|
|
4009
|
+
ABORT_ERROR: 'AbortError'};
|
|
4010
|
+
|
|
4011
|
+
/**
|
|
4012
|
+
* Error thrown when authentication fails (401 errors)
|
|
4013
|
+
* Common scenarios:
|
|
4014
|
+
* - Invalid credentials
|
|
4015
|
+
* - Expired token
|
|
4016
|
+
* - Missing authentication
|
|
4017
|
+
*/
|
|
4018
|
+
class AuthenticationError extends UiPathError {
|
|
4019
|
+
constructor(params = {}) {
|
|
4020
|
+
super(ErrorType.AUTHENTICATION, {
|
|
4021
|
+
message: params.message || ErrorMessages.AUTHENTICATION_FAILED,
|
|
4022
|
+
statusCode: params.statusCode ?? HttpStatus.UNAUTHORIZED,
|
|
4023
|
+
requestId: params.requestId
|
|
4024
|
+
});
|
|
4025
|
+
}
|
|
4026
|
+
}
|
|
4027
|
+
|
|
4028
|
+
/**
|
|
4029
|
+
* Error thrown when authorization fails (403 errors)
|
|
4030
|
+
* Common scenarios:
|
|
4031
|
+
* - Insufficient permissions
|
|
4032
|
+
* - Access denied to resource
|
|
4033
|
+
* - Invalid scope
|
|
4034
|
+
*/
|
|
4035
|
+
class AuthorizationError extends UiPathError {
|
|
4036
|
+
constructor(params = {}) {
|
|
4037
|
+
super(ErrorType.AUTHORIZATION, {
|
|
4038
|
+
message: params.message || ErrorMessages.ACCESS_DENIED,
|
|
4039
|
+
statusCode: params.statusCode ?? HttpStatus.FORBIDDEN,
|
|
4040
|
+
requestId: params.requestId
|
|
4041
|
+
});
|
|
4042
|
+
}
|
|
4043
|
+
}
|
|
4044
|
+
|
|
4045
|
+
/**
|
|
4046
|
+
* Error thrown when validation fails (400 errors or client-side validation)
|
|
4047
|
+
* Common scenarios:
|
|
4048
|
+
* - Invalid input parameters
|
|
4049
|
+
* - Missing required fields
|
|
4050
|
+
* - Invalid data format
|
|
4051
|
+
*/
|
|
4052
|
+
class ValidationError extends UiPathError {
|
|
4053
|
+
constructor(params = {}) {
|
|
4054
|
+
super(ErrorType.VALIDATION, {
|
|
4055
|
+
message: params.message || ErrorMessages.VALIDATION_FAILED,
|
|
4056
|
+
statusCode: params.statusCode ?? HttpStatus.BAD_REQUEST,
|
|
4057
|
+
requestId: params.requestId
|
|
4058
|
+
});
|
|
4059
|
+
}
|
|
4060
|
+
}
|
|
4061
|
+
|
|
4062
|
+
/**
|
|
4063
|
+
* Error thrown when a resource is not found (404 errors)
|
|
4064
|
+
* Common scenarios:
|
|
4065
|
+
* - Resource doesn't exist
|
|
4066
|
+
* - Invalid ID provided
|
|
4067
|
+
* - Resource deleted
|
|
4068
|
+
*/
|
|
4069
|
+
class NotFoundError extends UiPathError {
|
|
4070
|
+
constructor(params = {}) {
|
|
4071
|
+
super(ErrorType.NOT_FOUND, {
|
|
4072
|
+
message: params.message || ErrorMessages.RESOURCE_NOT_FOUND,
|
|
4073
|
+
statusCode: params.statusCode ?? HttpStatus.NOT_FOUND,
|
|
4074
|
+
requestId: params.requestId
|
|
4075
|
+
});
|
|
4076
|
+
}
|
|
4077
|
+
}
|
|
4078
|
+
|
|
4079
|
+
/**
|
|
4080
|
+
* Error thrown when rate limit is exceeded (429 errors)
|
|
4081
|
+
* Common scenarios:
|
|
4082
|
+
* - Too many requests in a time window
|
|
4083
|
+
* - API throttling
|
|
4084
|
+
*/
|
|
4085
|
+
class RateLimitError extends UiPathError {
|
|
4086
|
+
constructor(params = {}) {
|
|
4087
|
+
super(ErrorType.RATE_LIMIT, {
|
|
4088
|
+
message: params.message || ErrorMessages.RATE_LIMIT_EXCEEDED,
|
|
4089
|
+
statusCode: params.statusCode ?? HttpStatus.TOO_MANY_REQUESTS,
|
|
4090
|
+
requestId: params.requestId
|
|
4091
|
+
});
|
|
4092
|
+
}
|
|
4093
|
+
}
|
|
4094
|
+
|
|
4095
|
+
/**
|
|
4096
|
+
* Error thrown when server encounters an error (5xx errors)
|
|
4097
|
+
* Common scenarios:
|
|
4098
|
+
* - Internal server error
|
|
4099
|
+
* - Service unavailable
|
|
4100
|
+
* - Gateway timeout
|
|
4101
|
+
*/
|
|
4102
|
+
class ServerError extends UiPathError {
|
|
4103
|
+
constructor(params = {}) {
|
|
4104
|
+
super(ErrorType.SERVER, {
|
|
4105
|
+
message: params.message || ErrorMessages.INTERNAL_SERVER_ERROR,
|
|
4106
|
+
statusCode: params.statusCode ?? HttpStatus.INTERNAL_SERVER_ERROR,
|
|
4107
|
+
requestId: params.requestId
|
|
4108
|
+
});
|
|
4109
|
+
}
|
|
4110
|
+
/**
|
|
4111
|
+
* Checks if this is a temporary error that might succeed on retry
|
|
4112
|
+
*/
|
|
4113
|
+
get isRetryable() {
|
|
4114
|
+
return this.statusCode === HttpStatus.BAD_GATEWAY ||
|
|
4115
|
+
this.statusCode === HttpStatus.SERVICE_UNAVAILABLE ||
|
|
4116
|
+
this.statusCode === HttpStatus.GATEWAY_TIMEOUT;
|
|
4117
|
+
}
|
|
4118
|
+
}
|
|
4119
|
+
|
|
4120
|
+
/**
|
|
4121
|
+
* Error thrown when network/connection issues occur
|
|
4122
|
+
* Common scenarios:
|
|
4123
|
+
* - Connection timeout
|
|
4124
|
+
* - DNS resolution failure
|
|
4125
|
+
* - Network unreachable
|
|
4126
|
+
* - Request aborted
|
|
4127
|
+
*/
|
|
4128
|
+
class NetworkError extends UiPathError {
|
|
4129
|
+
constructor(params = {}) {
|
|
4130
|
+
super(ErrorType.NETWORK, {
|
|
4131
|
+
message: params.message || ErrorMessages.NETWORK_ERROR,
|
|
4132
|
+
statusCode: params.statusCode, // Network errors typically don't have HTTP status codes
|
|
4133
|
+
requestId: params.requestId
|
|
4134
|
+
});
|
|
4135
|
+
}
|
|
4136
|
+
}
|
|
4137
|
+
|
|
4138
|
+
/**
|
|
4139
|
+
* Type guard to check if an error is a UiPathError
|
|
4140
|
+
*/
|
|
4141
|
+
function isUiPathError(error) {
|
|
4142
|
+
return error instanceof UiPathError;
|
|
4143
|
+
}
|
|
4144
|
+
/**
|
|
4145
|
+
* Type guard to check if an error is an AuthenticationError
|
|
4146
|
+
*/
|
|
4147
|
+
function isAuthenticationError(error) {
|
|
4148
|
+
return error instanceof AuthenticationError;
|
|
4149
|
+
}
|
|
4150
|
+
/**
|
|
4151
|
+
* Type guard to check if an error is an AuthorizationError
|
|
4152
|
+
*/
|
|
4153
|
+
function isAuthorizationError(error) {
|
|
4154
|
+
return error instanceof AuthorizationError;
|
|
4155
|
+
}
|
|
4156
|
+
/**
|
|
4157
|
+
* Type guard to check if an error is a ValidationError
|
|
4158
|
+
*/
|
|
4159
|
+
function isValidationError(error) {
|
|
4160
|
+
return error instanceof ValidationError;
|
|
4161
|
+
}
|
|
4162
|
+
/**
|
|
4163
|
+
* Type guard to check if an error is a NotFoundError
|
|
4164
|
+
*/
|
|
4165
|
+
function isNotFoundError(error) {
|
|
4166
|
+
return error instanceof NotFoundError;
|
|
4167
|
+
}
|
|
4168
|
+
/**
|
|
4169
|
+
* Type guard to check if an error is a RateLimitError
|
|
4170
|
+
*/
|
|
4171
|
+
function isRateLimitError(error) {
|
|
4172
|
+
return error instanceof RateLimitError;
|
|
4173
|
+
}
|
|
4174
|
+
/**
|
|
4175
|
+
* Type guard to check if an error is a ServerError
|
|
4176
|
+
*/
|
|
4177
|
+
function isServerError(error) {
|
|
4178
|
+
return error instanceof ServerError;
|
|
4179
|
+
}
|
|
4180
|
+
/**
|
|
4181
|
+
* Type guard to check if an error is a NetworkError
|
|
4182
|
+
*/
|
|
4183
|
+
function isNetworkError(error) {
|
|
4184
|
+
return error instanceof NetworkError;
|
|
4185
|
+
}
|
|
4186
|
+
/**
|
|
4187
|
+
* Helper to get error details in a safe way
|
|
4188
|
+
*/
|
|
4189
|
+
function getErrorDetails(error) {
|
|
4190
|
+
if (isUiPathError(error)) {
|
|
4191
|
+
return {
|
|
4192
|
+
message: error.message,
|
|
4193
|
+
statusCode: error.statusCode
|
|
4194
|
+
};
|
|
4195
|
+
}
|
|
4196
|
+
if (error instanceof Error) {
|
|
4197
|
+
return {
|
|
4198
|
+
message: error.message
|
|
4199
|
+
};
|
|
4200
|
+
}
|
|
4201
|
+
return {
|
|
4202
|
+
message: String(error)
|
|
4203
|
+
};
|
|
4204
|
+
}
|
|
4205
|
+
|
|
3900
4206
|
/**
|
|
3901
4207
|
* TokenManager is responsible for managing authentication tokens.
|
|
3902
4208
|
* It provides token operations for a specific client ID.
|
|
@@ -3914,7 +4220,6 @@
|
|
|
3914
4220
|
this.executionContext = executionContext;
|
|
3915
4221
|
this.config = config;
|
|
3916
4222
|
this.isOAuth = isOAuth;
|
|
3917
|
-
this.STORAGE_KEY_PREFIX = 'uipath_sdk_user_token-';
|
|
3918
4223
|
this.refreshPromise = null;
|
|
3919
4224
|
}
|
|
3920
4225
|
/**
|
|
@@ -3929,11 +4234,46 @@
|
|
|
3929
4234
|
}
|
|
3930
4235
|
return new Date() >= tokenInfo.expiresAt;
|
|
3931
4236
|
}
|
|
4237
|
+
/**
|
|
4238
|
+
* Gets a valid authentication token, refreshing if necessary.
|
|
4239
|
+
* This is the single source of truth for token validation and refresh logic.
|
|
4240
|
+
*
|
|
4241
|
+
* @returns The valid token string
|
|
4242
|
+
* @throws AuthenticationError if no token available or refresh fails
|
|
4243
|
+
*/
|
|
4244
|
+
async getValidToken() {
|
|
4245
|
+
const tokenInfo = this.executionContext.get('tokenInfo');
|
|
4246
|
+
if (!tokenInfo) {
|
|
4247
|
+
throw new AuthenticationError({
|
|
4248
|
+
message: 'No authentication token available. Make sure to initialize the SDK first.'
|
|
4249
|
+
});
|
|
4250
|
+
}
|
|
4251
|
+
// For secret-based tokens, they never expire
|
|
4252
|
+
if (tokenInfo.type === 'secret') {
|
|
4253
|
+
return tokenInfo.token;
|
|
4254
|
+
}
|
|
4255
|
+
// If token is not expired, return it
|
|
4256
|
+
if (!this.isTokenExpired(tokenInfo)) {
|
|
4257
|
+
return tokenInfo.token;
|
|
4258
|
+
}
|
|
4259
|
+
// Token is expired, refresh it
|
|
4260
|
+
try {
|
|
4261
|
+
const newToken = await this.refreshAccessToken();
|
|
4262
|
+
return newToken.access_token;
|
|
4263
|
+
}
|
|
4264
|
+
catch (error) {
|
|
4265
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
4266
|
+
throw new AuthenticationError({
|
|
4267
|
+
message: `Token refresh failed: ${message}. Please re-authenticate.`,
|
|
4268
|
+
statusCode: HttpStatus.UNAUTHORIZED
|
|
4269
|
+
});
|
|
4270
|
+
}
|
|
4271
|
+
}
|
|
3932
4272
|
/**
|
|
3933
4273
|
* Gets the storage key for this TokenManager instance
|
|
3934
4274
|
*/
|
|
3935
4275
|
_getStorageKey() {
|
|
3936
|
-
return `${
|
|
4276
|
+
return `${AUTH_STORAGE_KEYS.TOKEN_PREFIX}${this.config.clientId}`;
|
|
3937
4277
|
}
|
|
3938
4278
|
/**
|
|
3939
4279
|
* Loads token from session storage if available
|
|
@@ -4143,10 +4483,6 @@
|
|
|
4143
4483
|
}
|
|
4144
4484
|
}
|
|
4145
4485
|
|
|
4146
|
-
/**
|
|
4147
|
-
* API Endpoint Constants
|
|
4148
|
-
* Centralized location for all API endpoints used throughout the SDK
|
|
4149
|
-
*/
|
|
4150
4486
|
/**
|
|
4151
4487
|
* Base path constants for different services
|
|
4152
4488
|
*/
|
|
@@ -4154,6 +4490,66 @@
|
|
|
4154
4490
|
const PIMS_BASE = 'pims_';
|
|
4155
4491
|
const DATAFABRIC_BASE = 'datafabric_';
|
|
4156
4492
|
const IDENTITY_BASE = 'identity_';
|
|
4493
|
+
|
|
4494
|
+
/**
|
|
4495
|
+
* Orchestrator Service Endpoints
|
|
4496
|
+
*/
|
|
4497
|
+
/**
|
|
4498
|
+
* Task Service (Action Center) Endpoints
|
|
4499
|
+
*/
|
|
4500
|
+
const TASK_ENDPOINTS = {
|
|
4501
|
+
CREATE_GENERIC_TASK: `${ORCHESTRATOR_BASE}/tasks/GenericTasks/CreateTask`,
|
|
4502
|
+
GET_TASK_USERS: (folderId) => `${ORCHESTRATOR_BASE}/odata/Tasks/UiPath.Server.Configuration.OData.GetTaskUsers(organizationUnitId=${folderId})`,
|
|
4503
|
+
GET_TASKS_ACROSS_FOLDERS: `${ORCHESTRATOR_BASE}/odata/Tasks/UiPath.Server.Configuration.OData.GetTasksAcrossFolders`,
|
|
4504
|
+
GET_TASKS_ACROSS_FOLDERS_ADMIN: `${ORCHESTRATOR_BASE}/odata/Tasks/UiPath.Server.Configuration.OData.GetTasksAcrossFoldersForAdmin`,
|
|
4505
|
+
GET_BY_ID: (id) => `${ORCHESTRATOR_BASE}/odata/Tasks(${id})`,
|
|
4506
|
+
ASSIGN_TASKS: `${ORCHESTRATOR_BASE}/odata/Tasks/UiPath.Server.Configuration.OData.AssignTasks`,
|
|
4507
|
+
REASSIGN_TASKS: `${ORCHESTRATOR_BASE}/odata/Tasks/UiPath.Server.Configuration.OData.ReassignTasks`,
|
|
4508
|
+
UNASSIGN_TASKS: `${ORCHESTRATOR_BASE}/odata/Tasks/UiPath.Server.Configuration.OData.UnassignTasks`,
|
|
4509
|
+
COMPLETE_FORM_TASK: `${ORCHESTRATOR_BASE}/forms/TaskForms/CompleteTask`,
|
|
4510
|
+
COMPLETE_APP_TASK: `${ORCHESTRATOR_BASE}/tasks/AppTasks/CompleteAppTask`,
|
|
4511
|
+
COMPLETE_GENERIC_TASK: `${ORCHESTRATOR_BASE}/tasks/GenericTasks/CompleteTask`,
|
|
4512
|
+
GET_TASK_FORM_BY_ID: `${ORCHESTRATOR_BASE}/forms/TaskForms/GetTaskFormById`,
|
|
4513
|
+
};
|
|
4514
|
+
/**
|
|
4515
|
+
* Orchestrator Bucket Endpoints
|
|
4516
|
+
*/
|
|
4517
|
+
const BUCKET_ENDPOINTS = {
|
|
4518
|
+
GET_BY_FOLDER: `${ORCHESTRATOR_BASE}/odata/Buckets`,
|
|
4519
|
+
GET_ALL: `${ORCHESTRATOR_BASE}/odata/Buckets/UiPath.Server.Configuration.OData.GetBucketsAcrossFolders`,
|
|
4520
|
+
GET_BY_ID: (id) => `${ORCHESTRATOR_BASE}/odata/Buckets(${id})`,
|
|
4521
|
+
GET_FILE_META_DATA: (id) => `${ORCHESTRATOR_BASE}/api/Buckets/${id}/ListFiles`,
|
|
4522
|
+
GET_READ_URI: (id) => `${ORCHESTRATOR_BASE}/odata/Buckets(${id})/UiPath.Server.Configuration.OData.GetReadUri`,
|
|
4523
|
+
GET_WRITE_URI: (id) => `${ORCHESTRATOR_BASE}/odata/Buckets(${id})/UiPath.Server.Configuration.OData.GetWriteUri`,
|
|
4524
|
+
};
|
|
4525
|
+
/**
|
|
4526
|
+
* Orchestrator Process Service Endpoints
|
|
4527
|
+
*/
|
|
4528
|
+
const PROCESS_ENDPOINTS = {
|
|
4529
|
+
GET_ALL: `${ORCHESTRATOR_BASE}/odata/Releases`,
|
|
4530
|
+
START_PROCESS: `${ORCHESTRATOR_BASE}/odata/Jobs/UiPath.Server.Configuration.OData.StartJobs`,
|
|
4531
|
+
GET_BY_ID: (id) => `${ORCHESTRATOR_BASE}/odata/Releases(${id})`,
|
|
4532
|
+
};
|
|
4533
|
+
/**
|
|
4534
|
+
* Orchestrator Queue Service Endpoints
|
|
4535
|
+
*/
|
|
4536
|
+
const QUEUE_ENDPOINTS = {
|
|
4537
|
+
GET_BY_FOLDER: `${ORCHESTRATOR_BASE}/odata/QueueDefinitions`,
|
|
4538
|
+
GET_ALL: `${ORCHESTRATOR_BASE}/odata/QueueDefinitions/UiPath.Server.Configuration.OData.GetQueuesAcrossFolders`,
|
|
4539
|
+
GET_BY_ID: (id) => `${ORCHESTRATOR_BASE}/odata/QueueDefinitions(${id})`,
|
|
4540
|
+
};
|
|
4541
|
+
/**
|
|
4542
|
+
* Orchestrator Asset Service Endpoints
|
|
4543
|
+
*/
|
|
4544
|
+
const ASSET_ENDPOINTS = {
|
|
4545
|
+
GET_BY_FOLDER: `${ORCHESTRATOR_BASE}/odata/Assets/UiPath.Server.Configuration.OData.GetFiltered`,
|
|
4546
|
+
GET_ALL: `${ORCHESTRATOR_BASE}/odata/Assets/UiPath.Server.Configuration.OData.GetAssetsAcrossFolders`,
|
|
4547
|
+
GET_BY_ID: (id) => `${ORCHESTRATOR_BASE}/odata/Assets(${id})`,
|
|
4548
|
+
};
|
|
4549
|
+
|
|
4550
|
+
/**
|
|
4551
|
+
* Maestro Service Endpoints
|
|
4552
|
+
*/
|
|
4157
4553
|
/**
|
|
4158
4554
|
* Maestro Process Service Endpoints
|
|
4159
4555
|
*/
|
|
@@ -4183,25 +4579,12 @@
|
|
|
4183
4579
|
REOPEN: (instanceId) => `${PIMS_BASE}/api/v1/cases/${instanceId}/reopen`,
|
|
4184
4580
|
},
|
|
4185
4581
|
};
|
|
4582
|
+
|
|
4186
4583
|
/**
|
|
4187
|
-
*
|
|
4584
|
+
* Data Fabric Service Endpoints
|
|
4188
4585
|
*/
|
|
4189
|
-
const TASK_ENDPOINTS = {
|
|
4190
|
-
CREATE_GENERIC_TASK: `${ORCHESTRATOR_BASE}/tasks/GenericTasks/CreateTask`,
|
|
4191
|
-
GET_TASK_USERS: (folderId) => `${ORCHESTRATOR_BASE}/odata/Tasks/UiPath.Server.Configuration.OData.GetTaskUsers(organizationUnitId=${folderId})`,
|
|
4192
|
-
GET_TASKS_ACROSS_FOLDERS: `${ORCHESTRATOR_BASE}/odata/Tasks/UiPath.Server.Configuration.OData.GetTasksAcrossFolders`,
|
|
4193
|
-
GET_TASKS_ACROSS_FOLDERS_ADMIN: `${ORCHESTRATOR_BASE}/odata/Tasks/UiPath.Server.Configuration.OData.GetTasksAcrossFoldersForAdmin`,
|
|
4194
|
-
GET_BY_ID: (id) => `${ORCHESTRATOR_BASE}/odata/Tasks(${id})`,
|
|
4195
|
-
ASSIGN_TASKS: `${ORCHESTRATOR_BASE}/odata/Tasks/UiPath.Server.Configuration.OData.AssignTasks`,
|
|
4196
|
-
REASSIGN_TASKS: `${ORCHESTRATOR_BASE}/odata/Tasks/UiPath.Server.Configuration.OData.ReassignTasks`,
|
|
4197
|
-
UNASSIGN_TASKS: `${ORCHESTRATOR_BASE}/odata/Tasks/UiPath.Server.Configuration.OData.UnassignTasks`,
|
|
4198
|
-
COMPLETE_FORM_TASK: `${ORCHESTRATOR_BASE}/forms/TaskForms/CompleteTask`,
|
|
4199
|
-
COMPLETE_APP_TASK: `${ORCHESTRATOR_BASE}/tasks/AppTasks/CompleteAppTask`,
|
|
4200
|
-
COMPLETE_GENERIC_TASK: `${ORCHESTRATOR_BASE}/tasks/GenericTasks/CompleteTask`,
|
|
4201
|
-
GET_TASK_FORM_BY_ID: `${ORCHESTRATOR_BASE}/forms/TaskForms/GetTaskFormById`,
|
|
4202
|
-
};
|
|
4203
4586
|
/**
|
|
4204
|
-
* Data Fabric Service Endpoints
|
|
4587
|
+
* Data Fabric Entity Service Endpoints
|
|
4205
4588
|
*/
|
|
4206
4589
|
const DATA_FABRIC_ENDPOINTS = {
|
|
4207
4590
|
ENTITY: {
|
|
@@ -4211,56 +4594,25 @@
|
|
|
4211
4594
|
GET_RECORD_BY_ID: (entityId, recordId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${entityId}/read/${recordId}`,
|
|
4212
4595
|
INSERT_BY_ID: (entityId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${entityId}/insert`,
|
|
4213
4596
|
BATCH_INSERT_BY_ID: (entityId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${entityId}/insert-batch`,
|
|
4214
|
-
UPDATE_BY_ID: (entityId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${entityId}/update-batch`,
|
|
4215
|
-
DELETE_BY_ID: (entityId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${entityId}/delete-batch`,
|
|
4216
|
-
DOWNLOAD_ATTACHMENT: (entityName, recordId, fieldName) => `${DATAFABRIC_BASE}/api/Attachment/${entityName}/${recordId}/${fieldName}`,
|
|
4217
|
-
},
|
|
4218
|
-
CHOICESETS: {
|
|
4219
|
-
GET_ALL: `${DATAFABRIC_BASE}/api/Entity/choiceset`,
|
|
4220
|
-
GET_BY_ID: (choiceSetId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${choiceSetId}/query_expansion`,
|
|
4221
|
-
},
|
|
4222
|
-
};
|
|
4223
|
-
/**
|
|
4224
|
-
* Orchestrator Bucket Endpoints
|
|
4225
|
-
*/
|
|
4226
|
-
const BUCKET_ENDPOINTS = {
|
|
4227
|
-
GET_BY_FOLDER: `${ORCHESTRATOR_BASE}/odata/Buckets`,
|
|
4228
|
-
GET_ALL: `${ORCHESTRATOR_BASE}/odata/Buckets/UiPath.Server.Configuration.OData.GetBucketsAcrossFolders`,
|
|
4229
|
-
GET_BY_ID: (id) => `${ORCHESTRATOR_BASE}/odata/Buckets(${id})`,
|
|
4230
|
-
GET_FILE_META_DATA: (id) => `${ORCHESTRATOR_BASE}/api/Buckets/${id}/ListFiles`,
|
|
4231
|
-
GET_READ_URI: (id) => `${ORCHESTRATOR_BASE}/odata/Buckets(${id})/UiPath.Server.Configuration.OData.GetReadUri`,
|
|
4232
|
-
GET_WRITE_URI: (id) => `${ORCHESTRATOR_BASE}/odata/Buckets(${id})/UiPath.Server.Configuration.OData.GetWriteUri`,
|
|
4233
|
-
};
|
|
4234
|
-
/**
|
|
4235
|
-
* Identity/Authentication Endpoints
|
|
4236
|
-
*/
|
|
4237
|
-
const IDENTITY_ENDPOINTS = {
|
|
4238
|
-
TOKEN: `${IDENTITY_BASE}/connect/token`,
|
|
4239
|
-
AUTHORIZE: `${IDENTITY_BASE}/connect/authorize`,
|
|
4240
|
-
};
|
|
4241
|
-
/**
|
|
4242
|
-
* Orchestrator Process Service Endpoints
|
|
4243
|
-
*/
|
|
4244
|
-
const PROCESS_ENDPOINTS = {
|
|
4245
|
-
GET_ALL: `${ORCHESTRATOR_BASE}/odata/Releases`,
|
|
4246
|
-
START_PROCESS: `${ORCHESTRATOR_BASE}/odata/Jobs/UiPath.Server.Configuration.OData.StartJobs`,
|
|
4247
|
-
GET_BY_ID: (id) => `${ORCHESTRATOR_BASE}/odata/Releases(${id})`,
|
|
4597
|
+
UPDATE_BY_ID: (entityId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${entityId}/update-batch`,
|
|
4598
|
+
DELETE_BY_ID: (entityId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${entityId}/delete-batch`,
|
|
4599
|
+
DOWNLOAD_ATTACHMENT: (entityName, recordId, fieldName) => `${DATAFABRIC_BASE}/api/Attachment/${entityName}/${recordId}/${fieldName}`,
|
|
4600
|
+
},
|
|
4601
|
+
CHOICESETS: {
|
|
4602
|
+
GET_ALL: `${DATAFABRIC_BASE}/api/Entity/choiceset`,
|
|
4603
|
+
GET_BY_ID: (choiceSetId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${choiceSetId}/query_expansion`,
|
|
4604
|
+
},
|
|
4248
4605
|
};
|
|
4606
|
+
|
|
4249
4607
|
/**
|
|
4250
|
-
*
|
|
4608
|
+
* Identity/Authentication Endpoints
|
|
4251
4609
|
*/
|
|
4252
|
-
const QUEUE_ENDPOINTS = {
|
|
4253
|
-
GET_BY_FOLDER: `${ORCHESTRATOR_BASE}/odata/QueueDefinitions`,
|
|
4254
|
-
GET_ALL: `${ORCHESTRATOR_BASE}/odata/QueueDefinitions/UiPath.Server.Configuration.OData.GetQueuesAcrossFolders`,
|
|
4255
|
-
GET_BY_ID: (id) => `${ORCHESTRATOR_BASE}/odata/QueueDefinitions(${id})`,
|
|
4256
|
-
};
|
|
4257
4610
|
/**
|
|
4258
|
-
*
|
|
4611
|
+
* Identity Service Endpoints
|
|
4259
4612
|
*/
|
|
4260
|
-
const
|
|
4261
|
-
|
|
4262
|
-
|
|
4263
|
-
GET_BY_ID: (id) => `${ORCHESTRATOR_BASE}/odata/Assets(${id})`,
|
|
4613
|
+
const IDENTITY_ENDPOINTS = {
|
|
4614
|
+
TOKEN: `${IDENTITY_BASE}/connect/token`,
|
|
4615
|
+
AUTHORIZE: `${IDENTITY_BASE}/connect/authorize`,
|
|
4264
4616
|
};
|
|
4265
4617
|
|
|
4266
4618
|
class AuthService {
|
|
@@ -4283,7 +4635,7 @@
|
|
|
4283
4635
|
return false;
|
|
4284
4636
|
const urlParams = new URLSearchParams(window.location.search);
|
|
4285
4637
|
const code = urlParams.get('code');
|
|
4286
|
-
const hasCodeVerifier = sessionStorage.getItem(
|
|
4638
|
+
const hasCodeVerifier = sessionStorage.getItem(AUTH_STORAGE_KEYS.CODE_VERIFIER);
|
|
4287
4639
|
return !!(code && hasCodeVerifier);
|
|
4288
4640
|
}
|
|
4289
4641
|
/**
|
|
@@ -4294,7 +4646,7 @@
|
|
|
4294
4646
|
return null;
|
|
4295
4647
|
}
|
|
4296
4648
|
try {
|
|
4297
|
-
const stored = sessionStorage.getItem(
|
|
4649
|
+
const stored = sessionStorage.getItem(AUTH_STORAGE_KEYS.OAUTH_CONTEXT);
|
|
4298
4650
|
if (!stored) {
|
|
4299
4651
|
return null;
|
|
4300
4652
|
}
|
|
@@ -4302,13 +4654,13 @@
|
|
|
4302
4654
|
// Validate required fields
|
|
4303
4655
|
if (!context.codeVerifier || !context.clientId || !context.redirectUri ||
|
|
4304
4656
|
!context.baseUrl || !context.orgName) {
|
|
4305
|
-
sessionStorage.removeItem(
|
|
4657
|
+
sessionStorage.removeItem(AUTH_STORAGE_KEYS.OAUTH_CONTEXT);
|
|
4306
4658
|
return null;
|
|
4307
4659
|
}
|
|
4308
4660
|
return context;
|
|
4309
4661
|
}
|
|
4310
4662
|
catch (error) {
|
|
4311
|
-
sessionStorage.removeItem(
|
|
4663
|
+
sessionStorage.removeItem(AUTH_STORAGE_KEYS.OAUTH_CONTEXT);
|
|
4312
4664
|
console.warn('Failed to parse stored OAuth context from session storage', error);
|
|
4313
4665
|
return null;
|
|
4314
4666
|
}
|
|
@@ -4383,7 +4735,7 @@
|
|
|
4383
4735
|
throw new Error('OAuth flow is only supported in browser environments');
|
|
4384
4736
|
}
|
|
4385
4737
|
// Check if we have a stored code verifier indicating we're in an OAuth flow
|
|
4386
|
-
const codeVerifier = sessionStorage.getItem(
|
|
4738
|
+
const codeVerifier = sessionStorage.getItem(AUTH_STORAGE_KEYS.CODE_VERIFIER);
|
|
4387
4739
|
const isInOAuthFlow = codeVerifier !== null;
|
|
4388
4740
|
const urlParams = new URLSearchParams(window.location.search);
|
|
4389
4741
|
const code = urlParams.get('code');
|
|
@@ -4392,7 +4744,7 @@
|
|
|
4392
4744
|
// We're expecting a callback - validate parameters
|
|
4393
4745
|
if (!code) {
|
|
4394
4746
|
// Clear stored state on error
|
|
4395
|
-
sessionStorage.removeItem(
|
|
4747
|
+
sessionStorage.removeItem(AUTH_STORAGE_KEYS.CODE_VERIFIER);
|
|
4396
4748
|
throw new Error('Authorization code missing in OAuth callback');
|
|
4397
4749
|
}
|
|
4398
4750
|
// Validate the authorization code format before using it
|
|
@@ -4400,7 +4752,7 @@
|
|
|
4400
4752
|
const codePattern = /^[A-Za-z0-9\-._~+/]+=*$/;
|
|
4401
4753
|
if (!codePattern.test(code)) {
|
|
4402
4754
|
// Clear stored state on error
|
|
4403
|
-
sessionStorage.removeItem(
|
|
4755
|
+
sessionStorage.removeItem(AUTH_STORAGE_KEYS.CODE_VERIFIER);
|
|
4404
4756
|
throw new Error('Invalid authorization code format');
|
|
4405
4757
|
}
|
|
4406
4758
|
// Authorization code is present and validated, so we can exchange it for a token.
|
|
@@ -4441,6 +4793,24 @@
|
|
|
4441
4793
|
hasValidToken() {
|
|
4442
4794
|
return this.tokenManager.hasValidToken();
|
|
4443
4795
|
}
|
|
4796
|
+
/**
|
|
4797
|
+
* Clears all authentication state including tokens and stored OAuth context.
|
|
4798
|
+
*/
|
|
4799
|
+
logout() {
|
|
4800
|
+
this.tokenManager.clearToken();
|
|
4801
|
+
// Clear OAuth context from session storage. These are normally cleaned up in _handleOAuthCallback after a successful
|
|
4802
|
+
// token exchange, but if a user calls logout() while an OAuth flow is
|
|
4803
|
+
// mid-redirect (before callback completes), they'd be left behind.
|
|
4804
|
+
if (isBrowser) {
|
|
4805
|
+
try {
|
|
4806
|
+
sessionStorage.removeItem(AUTH_STORAGE_KEYS.OAUTH_CONTEXT);
|
|
4807
|
+
sessionStorage.removeItem(AUTH_STORAGE_KEYS.CODE_VERIFIER);
|
|
4808
|
+
}
|
|
4809
|
+
catch (error) {
|
|
4810
|
+
console.warn('Failed to clear OAuth context from session storage', error);
|
|
4811
|
+
}
|
|
4812
|
+
}
|
|
4813
|
+
}
|
|
4444
4814
|
/**
|
|
4445
4815
|
* Get the current token
|
|
4446
4816
|
*/
|
|
@@ -4572,8 +4942,8 @@
|
|
|
4572
4942
|
tenantName: this.config.tenantName,
|
|
4573
4943
|
scope
|
|
4574
4944
|
};
|
|
4575
|
-
sessionStorage.setItem(
|
|
4576
|
-
sessionStorage.setItem(
|
|
4945
|
+
sessionStorage.setItem(AUTH_STORAGE_KEYS.OAUTH_CONTEXT, JSON.stringify(oauthContext));
|
|
4946
|
+
sessionStorage.setItem(AUTH_STORAGE_KEYS.CODE_VERIFIER, codeVerifier);
|
|
4577
4947
|
const authUrl = this.getAuthorizationUrl({
|
|
4578
4948
|
clientId,
|
|
4579
4949
|
redirectUri,
|
|
@@ -4583,7 +4953,7 @@
|
|
|
4583
4953
|
window.location.href = authUrl;
|
|
4584
4954
|
}
|
|
4585
4955
|
async _handleOAuthCallback(code, clientId, redirectUri) {
|
|
4586
|
-
const codeVerifier = sessionStorage.getItem(
|
|
4956
|
+
const codeVerifier = sessionStorage.getItem(AUTH_STORAGE_KEYS.CODE_VERIFIER);
|
|
4587
4957
|
if (!codeVerifier) {
|
|
4588
4958
|
throw new Error('Code verifier not found in session storage. Authentication may have been interrupted.');
|
|
4589
4959
|
}
|
|
@@ -4594,8 +4964,8 @@
|
|
|
4594
4964
|
codeVerifier
|
|
4595
4965
|
});
|
|
4596
4966
|
// Clear OAuth context and code verifier after successful token exchange
|
|
4597
|
-
sessionStorage.removeItem(
|
|
4598
|
-
sessionStorage.removeItem(
|
|
4967
|
+
sessionStorage.removeItem(AUTH_STORAGE_KEYS.OAUTH_CONTEXT);
|
|
4968
|
+
sessionStorage.removeItem(AUTH_STORAGE_KEYS.CODE_VERIFIER);
|
|
4599
4969
|
const url = new URL(window.location.href);
|
|
4600
4970
|
url.searchParams.delete('code');
|
|
4601
4971
|
url.searchParams.delete('state');
|
|
@@ -8376,7 +8746,7 @@
|
|
|
8376
8746
|
// Connection string placeholder that will be replaced during build
|
|
8377
8747
|
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";
|
|
8378
8748
|
// SDK Version placeholder
|
|
8379
|
-
const SDK_VERSION = "1.
|
|
8749
|
+
const SDK_VERSION = "1.1.1";
|
|
8380
8750
|
const VERSION = "Version";
|
|
8381
8751
|
const SERVICE = "Service";
|
|
8382
8752
|
const CLOUD_ORGANIZATION_NAME = "CloudOrganizationName";
|
|
@@ -8553,7 +8923,6 @@
|
|
|
8553
8923
|
*/
|
|
8554
8924
|
getEnrichedAttributes(extraAttributes, eventName) {
|
|
8555
8925
|
const attributes = {
|
|
8556
|
-
...extraAttributes,
|
|
8557
8926
|
[APP_NAME]: SDK_SERVICE_NAME,
|
|
8558
8927
|
[VERSION]: SDK_VERSION,
|
|
8559
8928
|
[SERVICE]: eventName,
|
|
@@ -8562,6 +8931,7 @@
|
|
|
8562
8931
|
[CLOUD_TENANT_NAME]: this.telemetryContext?.tenantName || UNKNOWN$1,
|
|
8563
8932
|
[CLOUD_REDIRECT_URI]: this.telemetryContext?.redirectUri || UNKNOWN$1,
|
|
8564
8933
|
[CLOUD_CLIENT_ID]: this.telemetryContext?.clientId || UNKNOWN$1,
|
|
8934
|
+
...extraAttributes,
|
|
8565
8935
|
};
|
|
8566
8936
|
return attributes;
|
|
8567
8937
|
}
|
|
@@ -8835,328 +9205,46 @@
|
|
|
8835
9205
|
async completeOAuth() {
|
|
8836
9206
|
if (!AuthService.isInOAuthCallback()) {
|
|
8837
9207
|
throw new Error('Not in OAuth callback state. Call initialize() first to start OAuth flow.');
|
|
8838
|
-
}
|
|
8839
|
-
try {
|
|
8840
|
-
const success = await __classPrivateFieldGet(this, _UiPath_authService, "f").authenticate(__classPrivateFieldGet(this, _UiPath_config, "f"));
|
|
8841
|
-
if (success && this.isAuthenticated()) {
|
|
8842
|
-
__classPrivateFieldSet(this, _UiPath_initialized, true, "f");
|
|
8843
|
-
return true;
|
|
8844
|
-
}
|
|
8845
|
-
return false;
|
|
8846
|
-
}
|
|
8847
|
-
catch (error) {
|
|
8848
|
-
const errorMessage = error instanceof Error ? error.message : 'An unknown error occurred';
|
|
8849
|
-
throw new Error(`Failed to complete OAuth: ${errorMessage}`);
|
|
8850
|
-
}
|
|
8851
|
-
}
|
|
8852
|
-
/**
|
|
8853
|
-
* Check if the user is authenticated (has valid token)
|
|
8854
|
-
*/
|
|
8855
|
-
isAuthenticated() {
|
|
8856
|
-
return __classPrivateFieldGet(this, _UiPath_authService, "f").hasValidToken();
|
|
8857
|
-
}
|
|
8858
|
-
/**
|
|
8859
|
-
* Get the current authentication token
|
|
8860
|
-
*/
|
|
8861
|
-
getToken() {
|
|
8862
|
-
return __classPrivateFieldGet(this, _UiPath_authService, "f").getToken();
|
|
8863
|
-
}
|
|
8864
|
-
};
|
|
8865
|
-
_UiPath_config = new WeakMap(), _UiPath_authService = new WeakMap(), _UiPath_initialized = new WeakMap();
|
|
8866
|
-
|
|
8867
|
-
/**
|
|
8868
|
-
* Base error class for all UiPath SDK errors
|
|
8869
|
-
* Pure TypeScript class with clean interface
|
|
8870
|
-
*/
|
|
8871
|
-
class UiPathError {
|
|
8872
|
-
constructor(type, params) {
|
|
8873
|
-
this.type = type;
|
|
8874
|
-
this.message = params.message;
|
|
8875
|
-
this.statusCode = params.statusCode;
|
|
8876
|
-
this.requestId = params.requestId;
|
|
8877
|
-
this.timestamp = new Date();
|
|
8878
|
-
// Capture stack trace for debugging
|
|
8879
|
-
this.stack = (new Error()).stack;
|
|
8880
|
-
}
|
|
8881
|
-
/**
|
|
8882
|
-
* Returns a clean JSON representation of the error
|
|
8883
|
-
*/
|
|
8884
|
-
toJSON() {
|
|
8885
|
-
return {
|
|
8886
|
-
type: this.type,
|
|
8887
|
-
message: this.message,
|
|
8888
|
-
statusCode: this.statusCode,
|
|
8889
|
-
requestId: this.requestId,
|
|
8890
|
-
timestamp: this.timestamp
|
|
8891
|
-
};
|
|
8892
|
-
}
|
|
8893
|
-
/**
|
|
8894
|
-
* Returns detailed debug information including stack trace
|
|
8895
|
-
*/
|
|
8896
|
-
getDebugInfo() {
|
|
8897
|
-
return {
|
|
8898
|
-
...this.toJSON(),
|
|
8899
|
-
stack: this.stack
|
|
8900
|
-
};
|
|
8901
|
-
}
|
|
8902
|
-
}
|
|
8903
|
-
|
|
8904
|
-
/**
|
|
8905
|
-
* HTTP status code constants for error handling
|
|
8906
|
-
*/
|
|
8907
|
-
const HttpStatus = {
|
|
8908
|
-
// Client errors (4xx)
|
|
8909
|
-
BAD_REQUEST: 400,
|
|
8910
|
-
UNAUTHORIZED: 401,
|
|
8911
|
-
FORBIDDEN: 403,
|
|
8912
|
-
NOT_FOUND: 404,
|
|
8913
|
-
TOO_MANY_REQUESTS: 429,
|
|
8914
|
-
// Server errors (5xx)
|
|
8915
|
-
INTERNAL_SERVER_ERROR: 500,
|
|
8916
|
-
NOT_IMPLEMENTED: 501,
|
|
8917
|
-
BAD_GATEWAY: 502,
|
|
8918
|
-
SERVICE_UNAVAILABLE: 503,
|
|
8919
|
-
GATEWAY_TIMEOUT: 504
|
|
8920
|
-
};
|
|
8921
|
-
/**
|
|
8922
|
-
* Error type constants for consistent error identification
|
|
8923
|
-
*/
|
|
8924
|
-
const ErrorType = {
|
|
8925
|
-
AUTHENTICATION: 'AuthenticationError',
|
|
8926
|
-
AUTHORIZATION: 'AuthorizationError',
|
|
8927
|
-
VALIDATION: 'ValidationError',
|
|
8928
|
-
NOT_FOUND: 'NotFoundError',
|
|
8929
|
-
RATE_LIMIT: 'RateLimitError',
|
|
8930
|
-
SERVER: 'ServerError',
|
|
8931
|
-
NETWORK: 'NetworkError'
|
|
8932
|
-
};
|
|
8933
|
-
/**
|
|
8934
|
-
* HTTP header constants for error handling
|
|
8935
|
-
*/
|
|
8936
|
-
const HttpHeaders = {
|
|
8937
|
-
X_REQUEST_ID: 'x-request-id'
|
|
8938
|
-
};
|
|
8939
|
-
/**
|
|
8940
|
-
* Standard error message constants
|
|
8941
|
-
*/
|
|
8942
|
-
const ErrorMessages = {
|
|
8943
|
-
// Authentication errors
|
|
8944
|
-
AUTHENTICATION_FAILED: 'Authentication failed',
|
|
8945
|
-
// Authorization errors
|
|
8946
|
-
ACCESS_DENIED: 'Access denied',
|
|
8947
|
-
// Validation errors
|
|
8948
|
-
VALIDATION_FAILED: 'Validation failed',
|
|
8949
|
-
// Not found errors
|
|
8950
|
-
RESOURCE_NOT_FOUND: 'Resource not found',
|
|
8951
|
-
// Rate limit errors
|
|
8952
|
-
RATE_LIMIT_EXCEEDED: 'Rate limit exceeded',
|
|
8953
|
-
// Server errors
|
|
8954
|
-
INTERNAL_SERVER_ERROR: 'Internal Server error occurred',
|
|
8955
|
-
// Network errors
|
|
8956
|
-
NETWORK_ERROR: 'Network error occurred',
|
|
8957
|
-
REQUEST_TIMEOUT: 'Request timed out',
|
|
8958
|
-
REQUEST_ABORTED: 'Request was aborted',
|
|
8959
|
-
};
|
|
8960
|
-
/**
|
|
8961
|
-
* Error name constants for network error identification
|
|
8962
|
-
*/
|
|
8963
|
-
const ErrorNames = {
|
|
8964
|
-
ABORT_ERROR: 'AbortError'};
|
|
8965
|
-
|
|
8966
|
-
/**
|
|
8967
|
-
* Error thrown when authentication fails (401 errors)
|
|
8968
|
-
* Common scenarios:
|
|
8969
|
-
* - Invalid credentials
|
|
8970
|
-
* - Expired token
|
|
8971
|
-
* - Missing authentication
|
|
8972
|
-
*/
|
|
8973
|
-
class AuthenticationError extends UiPathError {
|
|
8974
|
-
constructor(params = {}) {
|
|
8975
|
-
super(ErrorType.AUTHENTICATION, {
|
|
8976
|
-
message: params.message || ErrorMessages.AUTHENTICATION_FAILED,
|
|
8977
|
-
statusCode: params.statusCode ?? HttpStatus.UNAUTHORIZED,
|
|
8978
|
-
requestId: params.requestId
|
|
8979
|
-
});
|
|
8980
|
-
}
|
|
8981
|
-
}
|
|
8982
|
-
|
|
8983
|
-
/**
|
|
8984
|
-
* Error thrown when authorization fails (403 errors)
|
|
8985
|
-
* Common scenarios:
|
|
8986
|
-
* - Insufficient permissions
|
|
8987
|
-
* - Access denied to resource
|
|
8988
|
-
* - Invalid scope
|
|
8989
|
-
*/
|
|
8990
|
-
class AuthorizationError extends UiPathError {
|
|
8991
|
-
constructor(params = {}) {
|
|
8992
|
-
super(ErrorType.AUTHORIZATION, {
|
|
8993
|
-
message: params.message || ErrorMessages.ACCESS_DENIED,
|
|
8994
|
-
statusCode: params.statusCode ?? HttpStatus.FORBIDDEN,
|
|
8995
|
-
requestId: params.requestId
|
|
8996
|
-
});
|
|
8997
|
-
}
|
|
8998
|
-
}
|
|
8999
|
-
|
|
9000
|
-
/**
|
|
9001
|
-
* Error thrown when validation fails (400 errors or client-side validation)
|
|
9002
|
-
* Common scenarios:
|
|
9003
|
-
* - Invalid input parameters
|
|
9004
|
-
* - Missing required fields
|
|
9005
|
-
* - Invalid data format
|
|
9006
|
-
*/
|
|
9007
|
-
class ValidationError extends UiPathError {
|
|
9008
|
-
constructor(params = {}) {
|
|
9009
|
-
super(ErrorType.VALIDATION, {
|
|
9010
|
-
message: params.message || ErrorMessages.VALIDATION_FAILED,
|
|
9011
|
-
statusCode: params.statusCode ?? HttpStatus.BAD_REQUEST,
|
|
9012
|
-
requestId: params.requestId
|
|
9013
|
-
});
|
|
9014
|
-
}
|
|
9015
|
-
}
|
|
9016
|
-
|
|
9017
|
-
/**
|
|
9018
|
-
* Error thrown when a resource is not found (404 errors)
|
|
9019
|
-
* Common scenarios:
|
|
9020
|
-
* - Resource doesn't exist
|
|
9021
|
-
* - Invalid ID provided
|
|
9022
|
-
* - Resource deleted
|
|
9023
|
-
*/
|
|
9024
|
-
class NotFoundError extends UiPathError {
|
|
9025
|
-
constructor(params = {}) {
|
|
9026
|
-
super(ErrorType.NOT_FOUND, {
|
|
9027
|
-
message: params.message || ErrorMessages.RESOURCE_NOT_FOUND,
|
|
9028
|
-
statusCode: params.statusCode ?? HttpStatus.NOT_FOUND,
|
|
9029
|
-
requestId: params.requestId
|
|
9030
|
-
});
|
|
9031
|
-
}
|
|
9032
|
-
}
|
|
9033
|
-
|
|
9034
|
-
/**
|
|
9035
|
-
* Error thrown when rate limit is exceeded (429 errors)
|
|
9036
|
-
* Common scenarios:
|
|
9037
|
-
* - Too many requests in a time window
|
|
9038
|
-
* - API throttling
|
|
9039
|
-
*/
|
|
9040
|
-
class RateLimitError extends UiPathError {
|
|
9041
|
-
constructor(params = {}) {
|
|
9042
|
-
super(ErrorType.RATE_LIMIT, {
|
|
9043
|
-
message: params.message || ErrorMessages.RATE_LIMIT_EXCEEDED,
|
|
9044
|
-
statusCode: params.statusCode ?? HttpStatus.TOO_MANY_REQUESTS,
|
|
9045
|
-
requestId: params.requestId
|
|
9046
|
-
});
|
|
9047
|
-
}
|
|
9048
|
-
}
|
|
9049
|
-
|
|
9050
|
-
/**
|
|
9051
|
-
* Error thrown when server encounters an error (5xx errors)
|
|
9052
|
-
* Common scenarios:
|
|
9053
|
-
* - Internal server error
|
|
9054
|
-
* - Service unavailable
|
|
9055
|
-
* - Gateway timeout
|
|
9056
|
-
*/
|
|
9057
|
-
class ServerError extends UiPathError {
|
|
9058
|
-
constructor(params = {}) {
|
|
9059
|
-
super(ErrorType.SERVER, {
|
|
9060
|
-
message: params.message || ErrorMessages.INTERNAL_SERVER_ERROR,
|
|
9061
|
-
statusCode: params.statusCode ?? HttpStatus.INTERNAL_SERVER_ERROR,
|
|
9062
|
-
requestId: params.requestId
|
|
9063
|
-
});
|
|
9208
|
+
}
|
|
9209
|
+
try {
|
|
9210
|
+
const success = await __classPrivateFieldGet(this, _UiPath_authService, "f").authenticate(__classPrivateFieldGet(this, _UiPath_config, "f"));
|
|
9211
|
+
if (success && this.isAuthenticated()) {
|
|
9212
|
+
__classPrivateFieldSet(this, _UiPath_initialized, true, "f");
|
|
9213
|
+
return true;
|
|
9214
|
+
}
|
|
9215
|
+
return false;
|
|
9216
|
+
}
|
|
9217
|
+
catch (error) {
|
|
9218
|
+
const errorMessage = error instanceof Error ? error.message : 'An unknown error occurred';
|
|
9219
|
+
throw new Error(`Failed to complete OAuth: ${errorMessage}`);
|
|
9220
|
+
}
|
|
9064
9221
|
}
|
|
9065
9222
|
/**
|
|
9066
|
-
*
|
|
9223
|
+
* Check if the user is authenticated (has valid token)
|
|
9067
9224
|
*/
|
|
9068
|
-
|
|
9069
|
-
return this
|
|
9070
|
-
this.statusCode === HttpStatus.SERVICE_UNAVAILABLE ||
|
|
9071
|
-
this.statusCode === HttpStatus.GATEWAY_TIMEOUT;
|
|
9072
|
-
}
|
|
9073
|
-
}
|
|
9074
|
-
|
|
9075
|
-
/**
|
|
9076
|
-
* Error thrown when network/connection issues occur
|
|
9077
|
-
* Common scenarios:
|
|
9078
|
-
* - Connection timeout
|
|
9079
|
-
* - DNS resolution failure
|
|
9080
|
-
* - Network unreachable
|
|
9081
|
-
* - Request aborted
|
|
9082
|
-
*/
|
|
9083
|
-
class NetworkError extends UiPathError {
|
|
9084
|
-
constructor(params = {}) {
|
|
9085
|
-
super(ErrorType.NETWORK, {
|
|
9086
|
-
message: params.message || ErrorMessages.NETWORK_ERROR,
|
|
9087
|
-
statusCode: params.statusCode, // Network errors typically don't have HTTP status codes
|
|
9088
|
-
requestId: params.requestId
|
|
9089
|
-
});
|
|
9225
|
+
isAuthenticated() {
|
|
9226
|
+
return __classPrivateFieldGet(this, _UiPath_authService, "f").hasValidToken();
|
|
9090
9227
|
}
|
|
9091
|
-
|
|
9092
|
-
|
|
9093
|
-
|
|
9094
|
-
|
|
9095
|
-
|
|
9096
|
-
function isUiPathError(error) {
|
|
9097
|
-
return error instanceof UiPathError;
|
|
9098
|
-
}
|
|
9099
|
-
/**
|
|
9100
|
-
* Type guard to check if an error is an AuthenticationError
|
|
9101
|
-
*/
|
|
9102
|
-
function isAuthenticationError(error) {
|
|
9103
|
-
return error instanceof AuthenticationError;
|
|
9104
|
-
}
|
|
9105
|
-
/**
|
|
9106
|
-
* Type guard to check if an error is an AuthorizationError
|
|
9107
|
-
*/
|
|
9108
|
-
function isAuthorizationError(error) {
|
|
9109
|
-
return error instanceof AuthorizationError;
|
|
9110
|
-
}
|
|
9111
|
-
/**
|
|
9112
|
-
* Type guard to check if an error is a ValidationError
|
|
9113
|
-
*/
|
|
9114
|
-
function isValidationError(error) {
|
|
9115
|
-
return error instanceof ValidationError;
|
|
9116
|
-
}
|
|
9117
|
-
/**
|
|
9118
|
-
* Type guard to check if an error is a NotFoundError
|
|
9119
|
-
*/
|
|
9120
|
-
function isNotFoundError(error) {
|
|
9121
|
-
return error instanceof NotFoundError;
|
|
9122
|
-
}
|
|
9123
|
-
/**
|
|
9124
|
-
* Type guard to check if an error is a RateLimitError
|
|
9125
|
-
*/
|
|
9126
|
-
function isRateLimitError(error) {
|
|
9127
|
-
return error instanceof RateLimitError;
|
|
9128
|
-
}
|
|
9129
|
-
/**
|
|
9130
|
-
* Type guard to check if an error is a ServerError
|
|
9131
|
-
*/
|
|
9132
|
-
function isServerError(error) {
|
|
9133
|
-
return error instanceof ServerError;
|
|
9134
|
-
}
|
|
9135
|
-
/**
|
|
9136
|
-
* Type guard to check if an error is a NetworkError
|
|
9137
|
-
*/
|
|
9138
|
-
function isNetworkError(error) {
|
|
9139
|
-
return error instanceof NetworkError;
|
|
9140
|
-
}
|
|
9141
|
-
/**
|
|
9142
|
-
* Helper to get error details in a safe way
|
|
9143
|
-
*/
|
|
9144
|
-
function getErrorDetails(error) {
|
|
9145
|
-
if (isUiPathError(error)) {
|
|
9146
|
-
return {
|
|
9147
|
-
message: error.message,
|
|
9148
|
-
statusCode: error.statusCode
|
|
9149
|
-
};
|
|
9228
|
+
/**
|
|
9229
|
+
* Get the current authentication token
|
|
9230
|
+
*/
|
|
9231
|
+
getToken() {
|
|
9232
|
+
return __classPrivateFieldGet(this, _UiPath_authService, "f").getToken();
|
|
9150
9233
|
}
|
|
9151
|
-
|
|
9152
|
-
|
|
9153
|
-
|
|
9154
|
-
|
|
9234
|
+
/**
|
|
9235
|
+
* Logout from the SDK, clearing all authentication state.
|
|
9236
|
+
* After calling this method, the user will need to re-initialize to authenticate again.
|
|
9237
|
+
*/
|
|
9238
|
+
logout() {
|
|
9239
|
+
// Secret-based auth has no session to end — skip silently
|
|
9240
|
+
if (hasSecretConfig(__classPrivateFieldGet(this, _UiPath_config, "f"))) {
|
|
9241
|
+
return;
|
|
9242
|
+
}
|
|
9243
|
+
__classPrivateFieldGet(this, _UiPath_authService, "f").logout();
|
|
9244
|
+
__classPrivateFieldSet(this, _UiPath_initialized, false, "f");
|
|
9155
9245
|
}
|
|
9156
|
-
|
|
9157
|
-
|
|
9158
|
-
};
|
|
9159
|
-
}
|
|
9246
|
+
};
|
|
9247
|
+
_UiPath_config = new WeakMap(), _UiPath_authService = new WeakMap(), _UiPath_initialized = new WeakMap();
|
|
9160
9248
|
|
|
9161
9249
|
/**
|
|
9162
9250
|
* Type guards for error response types
|
|
@@ -9430,29 +9518,7 @@
|
|
|
9430
9518
|
* @throws AuthenticationError if no token available or refresh fails
|
|
9431
9519
|
*/
|
|
9432
9520
|
async getValidToken() {
|
|
9433
|
-
|
|
9434
|
-
const tokenInfo = this.executionContext.get('tokenInfo');
|
|
9435
|
-
if (!tokenInfo) {
|
|
9436
|
-
throw new AuthenticationError({ message: 'No authentication token available. Make sure to initialize the SDK first.' });
|
|
9437
|
-
}
|
|
9438
|
-
// For secret-based tokens, they never expire
|
|
9439
|
-
if (tokenInfo.type === 'secret') {
|
|
9440
|
-
return tokenInfo.token;
|
|
9441
|
-
}
|
|
9442
|
-
// If token is not expired, return it
|
|
9443
|
-
if (!this.tokenManager.isTokenExpired(tokenInfo)) {
|
|
9444
|
-
return tokenInfo.token;
|
|
9445
|
-
}
|
|
9446
|
-
try {
|
|
9447
|
-
const newToken = await this.tokenManager.refreshAccessToken();
|
|
9448
|
-
return newToken.access_token;
|
|
9449
|
-
}
|
|
9450
|
-
catch (error) {
|
|
9451
|
-
throw new AuthenticationError({
|
|
9452
|
-
message: `Token refresh failed: ${error.message}. Please re-authenticate.`,
|
|
9453
|
-
statusCode: HttpStatus.UNAUTHORIZED
|
|
9454
|
-
});
|
|
9455
|
-
}
|
|
9521
|
+
return this.tokenManager.getValidToken();
|
|
9456
9522
|
}
|
|
9457
9523
|
async getDefaultHeaders() {
|
|
9458
9524
|
// Get headers from execution context first
|
|
@@ -10137,6 +10203,51 @@
|
|
|
10137
10203
|
return acc;
|
|
10138
10204
|
}, {});
|
|
10139
10205
|
}
|
|
10206
|
+
/**
|
|
10207
|
+
* Transforms request data from SDK field names to API field names.
|
|
10208
|
+
*
|
|
10209
|
+
* This is the inverse of `transformData` - while `transformData` converts
|
|
10210
|
+
* API responses to SDK format (API → SDK), this function converts SDK
|
|
10211
|
+
* requests to API format (SDK → API).
|
|
10212
|
+
*
|
|
10213
|
+
* @param data The request data with SDK field names
|
|
10214
|
+
* @param responseMap The response mapping (API → SDK) - will be automatically reversed
|
|
10215
|
+
* @returns A new object with API field names
|
|
10216
|
+
*
|
|
10217
|
+
* @example
|
|
10218
|
+
* ```typescript
|
|
10219
|
+
* // Response map: API field → SDK field
|
|
10220
|
+
* const ProcessMap = { releaseKey: 'processKey', releaseName: 'processName' };
|
|
10221
|
+
*
|
|
10222
|
+
* // SDK request with SDK field names
|
|
10223
|
+
* const sdkRequest = { processKey: 'abc-123', processName: 'MyProcess' };
|
|
10224
|
+
*
|
|
10225
|
+
* // Transform to API format
|
|
10226
|
+
* const apiRequest = transformRequest(sdkRequest, ProcessMap);
|
|
10227
|
+
* // Result: { releaseKey: 'abc-123', releaseName: 'MyProcess' }
|
|
10228
|
+
* ```
|
|
10229
|
+
*
|
|
10230
|
+
* @example
|
|
10231
|
+
* ```typescript
|
|
10232
|
+
* // Conversation example
|
|
10233
|
+
* const ConversationMap = { agentReleaseId: 'agentId' };
|
|
10234
|
+
*
|
|
10235
|
+
* const sdkOptions = { agentId: 123, folderId: 456, label: 'My Chat' };
|
|
10236
|
+
* const apiPayload = transformRequest(sdkOptions, ConversationMap);
|
|
10237
|
+
* // Result: { agentReleaseId: 123, folderId: 456, label: 'My Chat' }
|
|
10238
|
+
* ```
|
|
10239
|
+
*/
|
|
10240
|
+
function transformRequest(data, responseMap) {
|
|
10241
|
+
const result = { ...data };
|
|
10242
|
+
const requestMap = reverseMap(responseMap);
|
|
10243
|
+
for (const [sdkField, apiField] of Object.entries(requestMap)) {
|
|
10244
|
+
if (sdkField in result) {
|
|
10245
|
+
result[apiField] = result[sdkField];
|
|
10246
|
+
delete result[sdkField];
|
|
10247
|
+
}
|
|
10248
|
+
}
|
|
10249
|
+
return result;
|
|
10250
|
+
}
|
|
10140
10251
|
/**
|
|
10141
10252
|
* Transforms an array-based dictionary with separate keys and values arrays
|
|
10142
10253
|
* into a standard JavaScript object/record
|
|
@@ -10394,10 +10505,7 @@
|
|
|
10394
10505
|
*/
|
|
10395
10506
|
static async getAll(config, options) {
|
|
10396
10507
|
const optionsWithDefaults = options || {};
|
|
10397
|
-
const { folderId, ...restOptions } = optionsWithDefaults;
|
|
10398
|
-
const cursor = options?.cursor;
|
|
10399
|
-
const pageSize = options?.pageSize;
|
|
10400
|
-
const jumpToPage = options?.jumpToPage;
|
|
10508
|
+
const { folderId, pageSize, cursor, jumpToPage, ...restOptions } = optionsWithDefaults;
|
|
10401
10509
|
// Determine if pagination is requested
|
|
10402
10510
|
const isPaginationRequested = PaginationHelpers.hasPaginationParameters(options || {});
|
|
10403
10511
|
// Process parameters (custom processing if provided, otherwise default)
|
|
@@ -14100,17 +14208,8 @@
|
|
|
14100
14208
|
*/
|
|
14101
14209
|
async start(request, folderId, options = {}) {
|
|
14102
14210
|
const headers = createHeaders({ [FOLDER_ID]: folderId });
|
|
14103
|
-
// Transform
|
|
14104
|
-
const apiRequest =
|
|
14105
|
-
// Create a reverse mapping using ProcessMap
|
|
14106
|
-
const reversedPropertiesMap = reverseMap(ProcessMap);
|
|
14107
|
-
// Apply transformations for any client properties found in the request
|
|
14108
|
-
Object.entries(reversedPropertiesMap).forEach(([clientKey, apiKey]) => {
|
|
14109
|
-
if (clientKey in apiRequest) {
|
|
14110
|
-
apiRequest[apiKey] = apiRequest[clientKey];
|
|
14111
|
-
delete apiRequest[clientKey];
|
|
14112
|
-
}
|
|
14113
|
-
});
|
|
14211
|
+
// Transform SDK field names to API field names (e.g., processKey → releaseKey)
|
|
14212
|
+
const apiRequest = transformRequest(request, ProcessMap);
|
|
14114
14213
|
// Create the request object according to API spec
|
|
14115
14214
|
const requestBody = {
|
|
14116
14215
|
startInfo: apiRequest
|
|
@@ -14518,7 +14617,266 @@
|
|
|
14518
14617
|
JobState["Resumed"] = "Resumed";
|
|
14519
14618
|
})(exports.JobState || (exports.JobState = {}));
|
|
14520
14619
|
|
|
14620
|
+
/**
|
|
14621
|
+
* Common Constants for Conversational Agent
|
|
14622
|
+
*/
|
|
14623
|
+
/**
|
|
14624
|
+
* Common field mappings shared across all conversational agent entities.
|
|
14625
|
+
* Maps API response fields to SDK-consistent naming conventions.
|
|
14626
|
+
*/
|
|
14627
|
+
const CommonFieldMap = {
|
|
14628
|
+
createdAt: 'createdTime',
|
|
14629
|
+
updatedAt: 'updatedTime'
|
|
14630
|
+
};
|
|
14631
|
+
|
|
14632
|
+
/**
|
|
14633
|
+
* Constants for Conversational Agent
|
|
14634
|
+
*/
|
|
14635
|
+
/**
|
|
14636
|
+
* Maps API response fields to SDK field names (API → SDK)
|
|
14637
|
+
* Used when transforming API responses for SDK consumers.
|
|
14638
|
+
* For request transformation (SDK → API), use `transformRequest(data, ConversationMap)`.
|
|
14639
|
+
*/
|
|
14640
|
+
const ConversationMap = {
|
|
14641
|
+
...CommonFieldMap,
|
|
14642
|
+
conversationId: 'id',
|
|
14643
|
+
lastActivityAt: 'lastActivityTime',
|
|
14644
|
+
agentReleaseId: 'agentId'
|
|
14645
|
+
};
|
|
14646
|
+
/**
|
|
14647
|
+
* Maps fields for Exchange entity to ensure consistent SDK naming
|
|
14648
|
+
*/
|
|
14649
|
+
const ExchangeMap = {
|
|
14650
|
+
...CommonFieldMap
|
|
14651
|
+
};
|
|
14652
|
+
/**
|
|
14653
|
+
* Maps fields for Message entity to ensure consistent SDK naming
|
|
14654
|
+
*/
|
|
14655
|
+
const MessageMap = {
|
|
14656
|
+
...CommonFieldMap
|
|
14657
|
+
};
|
|
14658
|
+
|
|
14659
|
+
/**
|
|
14660
|
+
* Common types for Conversational Agent
|
|
14661
|
+
* Contains IDs, primitives, and utility types used across conversation types.
|
|
14662
|
+
*/
|
|
14663
|
+
/**
|
|
14664
|
+
* Identifies the origin of a message in the conversation.
|
|
14665
|
+
*/
|
|
14666
|
+
exports.MessageRole = void 0;
|
|
14667
|
+
(function (MessageRole) {
|
|
14668
|
+
MessageRole["System"] = "system";
|
|
14669
|
+
MessageRole["User"] = "user";
|
|
14670
|
+
MessageRole["Assistant"] = "assistant";
|
|
14671
|
+
})(exports.MessageRole || (exports.MessageRole = {}));
|
|
14672
|
+
/**
|
|
14673
|
+
* Identifies the type of an interrupt.
|
|
14674
|
+
*/
|
|
14675
|
+
exports.InterruptType = void 0;
|
|
14676
|
+
(function (InterruptType) {
|
|
14677
|
+
InterruptType["ToolCallConfirmation"] = "uipath_cas_tool_call_confirmation";
|
|
14678
|
+
})(exports.InterruptType || (exports.InterruptType = {}));
|
|
14679
|
+
|
|
14680
|
+
/**
|
|
14681
|
+
* Core data model types for Conversational Agent REST endpoints
|
|
14682
|
+
* Contains: Conversation, Exchange, Message, ContentPart, ToolCall, etc.
|
|
14683
|
+
*/
|
|
14684
|
+
/**
|
|
14685
|
+
* Represents the order in which items should be sorted.
|
|
14686
|
+
*/
|
|
14687
|
+
exports.SortOrder = void 0;
|
|
14688
|
+
(function (SortOrder) {
|
|
14689
|
+
SortOrder["Ascending"] = "ascending";
|
|
14690
|
+
SortOrder["Descending"] = "descending";
|
|
14691
|
+
})(exports.SortOrder || (exports.SortOrder = {}));
|
|
14692
|
+
/**
|
|
14693
|
+
* Feedback rating type.
|
|
14694
|
+
*/
|
|
14695
|
+
exports.FeedbackRating = void 0;
|
|
14696
|
+
(function (FeedbackRating) {
|
|
14697
|
+
FeedbackRating["Positive"] = "positive";
|
|
14698
|
+
FeedbackRating["Negative"] = "negative";
|
|
14699
|
+
})(exports.FeedbackRating || (exports.FeedbackRating = {}));
|
|
14700
|
+
|
|
14701
|
+
/**
|
|
14702
|
+
* Event types for Conversational Agent WebSocket protocol
|
|
14703
|
+
*/
|
|
14704
|
+
/**
|
|
14705
|
+
* Identifies how sensitive the LLM should be when detecting the start or end of speech.
|
|
14706
|
+
*
|
|
14707
|
+
* * UNSPECIFIED - the default is HIGH
|
|
14708
|
+
* * HIGH - Will detect the start/end of speech more often.
|
|
14709
|
+
* * LOW - Will detect the start/end of speech less often.
|
|
14710
|
+
*/
|
|
14711
|
+
exports.InputStreamSpeechSensitivity = void 0;
|
|
14712
|
+
(function (InputStreamSpeechSensitivity) {
|
|
14713
|
+
InputStreamSpeechSensitivity["Unspecified"] = "UNSPECIFIED";
|
|
14714
|
+
InputStreamSpeechSensitivity["High"] = "HIGH";
|
|
14715
|
+
InputStreamSpeechSensitivity["Low"] = "LOW";
|
|
14716
|
+
})(exports.InputStreamSpeechSensitivity || (exports.InputStreamSpeechSensitivity = {}));
|
|
14717
|
+
|
|
14718
|
+
/**
|
|
14719
|
+
* Content Part Stream Types
|
|
14720
|
+
*
|
|
14721
|
+
* Defines the public API for interacting with streaming content parts
|
|
14722
|
+
* within a message. Content parts represent text, audio, images, etc.
|
|
14723
|
+
*/
|
|
14724
|
+
/**
|
|
14725
|
+
* Types of citation processing errors
|
|
14726
|
+
*/
|
|
14727
|
+
exports.CitationErrorType = void 0;
|
|
14728
|
+
(function (CitationErrorType) {
|
|
14729
|
+
CitationErrorType["CitationNotEnded"] = "CitationNotEnded";
|
|
14730
|
+
CitationErrorType["CitationNotStarted"] = "CitationNotStarted";
|
|
14731
|
+
})(exports.CitationErrorType || (exports.CitationErrorType = {}));
|
|
14732
|
+
|
|
14733
|
+
/**
|
|
14734
|
+
* Conversation Service Model
|
|
14735
|
+
*
|
|
14736
|
+
* This interface defines the HTTP CRUD operations for conversations
|
|
14737
|
+
* and real-time WebSocket session management.
|
|
14738
|
+
*/
|
|
14739
|
+
/**
|
|
14740
|
+
* Creates methods for a conversation
|
|
14741
|
+
*
|
|
14742
|
+
* @param conversationData - The conversation data (response from API)
|
|
14743
|
+
* @param service - The conversation service instance
|
|
14744
|
+
* @param sessionMethods - Optional session methods for WebSocket session operations
|
|
14745
|
+
* @param exchangeService - Optional exchange service for scoped exchange methods
|
|
14746
|
+
* @returns Object containing conversation methods
|
|
14747
|
+
*/
|
|
14748
|
+
function createConversationMethods(conversationData, service, sessionMethods, exchangeService) {
|
|
14749
|
+
return {
|
|
14750
|
+
exchanges: {
|
|
14751
|
+
getAll(options) {
|
|
14752
|
+
if (!conversationData.id)
|
|
14753
|
+
throw new Error('Conversation ID is undefined');
|
|
14754
|
+
if (!exchangeService)
|
|
14755
|
+
throw new Error('Exchange methods are not available.');
|
|
14756
|
+
return exchangeService.getAll(conversationData.id, options);
|
|
14757
|
+
},
|
|
14758
|
+
getById(exchangeId, options) {
|
|
14759
|
+
if (!conversationData.id)
|
|
14760
|
+
throw new Error('Conversation ID is undefined');
|
|
14761
|
+
if (!exchangeService)
|
|
14762
|
+
throw new Error('Exchange methods are not available.');
|
|
14763
|
+
return exchangeService.getById(conversationData.id, exchangeId, options);
|
|
14764
|
+
},
|
|
14765
|
+
createFeedback(exchangeId, options) {
|
|
14766
|
+
if (!conversationData.id)
|
|
14767
|
+
throw new Error('Conversation ID is undefined');
|
|
14768
|
+
if (!exchangeService)
|
|
14769
|
+
throw new Error('Exchange methods are not available.');
|
|
14770
|
+
return exchangeService.createFeedback(conversationData.id, exchangeId, options);
|
|
14771
|
+
}
|
|
14772
|
+
},
|
|
14773
|
+
async update(options) {
|
|
14774
|
+
if (!conversationData.id)
|
|
14775
|
+
throw new Error('Conversation ID is undefined');
|
|
14776
|
+
return service.updateById(conversationData.id, options);
|
|
14777
|
+
},
|
|
14778
|
+
async delete() {
|
|
14779
|
+
if (!conversationData.id)
|
|
14780
|
+
throw new Error('Conversation ID is undefined');
|
|
14781
|
+
return service.deleteById(conversationData.id);
|
|
14782
|
+
},
|
|
14783
|
+
startSession(options) {
|
|
14784
|
+
if (!conversationData.id)
|
|
14785
|
+
throw new Error('Conversation ID is undefined');
|
|
14786
|
+
if (!sessionMethods) {
|
|
14787
|
+
throw new Error('Session methods are not available. Use ConversationService to create conversations with session support.');
|
|
14788
|
+
}
|
|
14789
|
+
return sessionMethods.startSession(conversationData.id, options);
|
|
14790
|
+
},
|
|
14791
|
+
getSession() {
|
|
14792
|
+
if (!conversationData.id)
|
|
14793
|
+
throw new Error('Conversation ID is undefined');
|
|
14794
|
+
if (!sessionMethods) {
|
|
14795
|
+
throw new Error('Session methods are not available. Use ConversationService to create conversations with session support.');
|
|
14796
|
+
}
|
|
14797
|
+
return sessionMethods.getSession(conversationData.id);
|
|
14798
|
+
},
|
|
14799
|
+
endSession() {
|
|
14800
|
+
if (!conversationData.id)
|
|
14801
|
+
throw new Error('Conversation ID is undefined');
|
|
14802
|
+
if (!sessionMethods) {
|
|
14803
|
+
throw new Error('Session methods are not available. Use ConversationService to create conversations with session support.');
|
|
14804
|
+
}
|
|
14805
|
+
sessionMethods.endSession(conversationData.id);
|
|
14806
|
+
},
|
|
14807
|
+
async uploadAttachment(file) {
|
|
14808
|
+
if (!conversationData.id)
|
|
14809
|
+
throw new Error('Conversation ID is undefined');
|
|
14810
|
+
return service.uploadAttachment(conversationData.id, file);
|
|
14811
|
+
}
|
|
14812
|
+
};
|
|
14813
|
+
}
|
|
14814
|
+
/**
|
|
14815
|
+
* Creates an actionable conversation by combining API conversation data with operational methods.
|
|
14816
|
+
*
|
|
14817
|
+
* @param conversationData - The conversation data from API
|
|
14818
|
+
* @param service - The conversation service instance
|
|
14819
|
+
* @param sessionMethods - Optional session methods for WebSocket session operations
|
|
14820
|
+
* @param exchangeService - Optional exchange service for scoped exchange methods
|
|
14821
|
+
* @returns A conversation object with added methods
|
|
14822
|
+
*/
|
|
14823
|
+
function createConversationWithMethods(conversationData, service, sessionMethods, exchangeService) {
|
|
14824
|
+
const methods = createConversationMethods(conversationData, service, sessionMethods, exchangeService);
|
|
14825
|
+
return Object.assign({}, conversationData, methods);
|
|
14826
|
+
}
|
|
14827
|
+
|
|
14828
|
+
/**
|
|
14829
|
+
* Agent Service Models
|
|
14830
|
+
*
|
|
14831
|
+
* Provides fluent API for agent objects returned from getAll() and getById().
|
|
14832
|
+
*/
|
|
14833
|
+
/**
|
|
14834
|
+
* Creates methods for an agent
|
|
14835
|
+
*
|
|
14836
|
+
* @param agentData - The agent data from API
|
|
14837
|
+
* @param conversationService - The conversation service instance for delegation
|
|
14838
|
+
* @returns Object containing agent methods
|
|
14839
|
+
*/
|
|
14840
|
+
function createAgentMethods(agentData, conversationService) {
|
|
14841
|
+
const agentConversations = {
|
|
14842
|
+
async create(options = {}) {
|
|
14843
|
+
return conversationService.create(agentData.id, agentData.folderId, options);
|
|
14844
|
+
}
|
|
14845
|
+
};
|
|
14846
|
+
return {
|
|
14847
|
+
conversations: agentConversations,
|
|
14848
|
+
get connectionStatus() { return conversationService.connectionStatus; },
|
|
14849
|
+
get isConnected() { return conversationService.isConnected; },
|
|
14850
|
+
get connectionError() { return conversationService.connectionError; }
|
|
14851
|
+
};
|
|
14852
|
+
}
|
|
14853
|
+
function createAgentWithMethods(agentData, conversationService) {
|
|
14854
|
+
const methods = createAgentMethods(agentData, conversationService);
|
|
14855
|
+
return Object.defineProperties(Object.assign({}, agentData), Object.getOwnPropertyDescriptors(methods));
|
|
14856
|
+
}
|
|
14857
|
+
|
|
14858
|
+
/**
|
|
14859
|
+
* Constants for Agent Service
|
|
14860
|
+
*/
|
|
14861
|
+
/**
|
|
14862
|
+
* Maps fields for Agent entities to ensure consistent SDK naming
|
|
14863
|
+
*/
|
|
14864
|
+
const AgentMap = {
|
|
14865
|
+
...CommonFieldMap
|
|
14866
|
+
};
|
|
14867
|
+
|
|
14868
|
+
/**
|
|
14869
|
+
* Constants for User Service
|
|
14870
|
+
*/
|
|
14871
|
+
/**
|
|
14872
|
+
* Maps fields for User Settings entities to ensure consistent SDK naming
|
|
14873
|
+
*/
|
|
14874
|
+
const UserSettingsMap = {
|
|
14875
|
+
...CommonFieldMap
|
|
14876
|
+
};
|
|
14877
|
+
|
|
14521
14878
|
exports.APP_NAME = APP_NAME;
|
|
14879
|
+
exports.AgentMap = AgentMap;
|
|
14522
14880
|
exports.AuthenticationError = AuthenticationError;
|
|
14523
14881
|
exports.AuthorizationError = AuthorizationError;
|
|
14524
14882
|
exports.CLOUD_CLIENT_ID = CLOUD_CLIENT_ID;
|
|
@@ -14528,12 +14886,15 @@
|
|
|
14528
14886
|
exports.CLOUD_TENANT_NAME = CLOUD_TENANT_NAME;
|
|
14529
14887
|
exports.CLOUD_URL = CLOUD_URL;
|
|
14530
14888
|
exports.CONNECTION_STRING = CONNECTION_STRING;
|
|
14889
|
+
exports.ConversationMap = ConversationMap;
|
|
14531
14890
|
exports.DEFAULT_ITEMS_FIELD = DEFAULT_ITEMS_FIELD;
|
|
14532
14891
|
exports.DEFAULT_PAGE_SIZE = DEFAULT_PAGE_SIZE;
|
|
14533
14892
|
exports.DEFAULT_TOTAL_COUNT_FIELD = DEFAULT_TOTAL_COUNT_FIELD;
|
|
14534
14893
|
exports.ErrorType = ErrorType;
|
|
14894
|
+
exports.ExchangeMap = ExchangeMap;
|
|
14535
14895
|
exports.HttpStatus = HttpStatus;
|
|
14536
14896
|
exports.MAX_PAGE_SIZE = MAX_PAGE_SIZE;
|
|
14897
|
+
exports.MessageMap = MessageMap;
|
|
14537
14898
|
exports.NetworkError = NetworkError;
|
|
14538
14899
|
exports.NotFoundError = NotFoundError;
|
|
14539
14900
|
exports.RateLimitError = RateLimitError;
|
|
@@ -14546,9 +14907,12 @@
|
|
|
14546
14907
|
exports.UNKNOWN = UNKNOWN$1;
|
|
14547
14908
|
exports.UiPath = UiPath;
|
|
14548
14909
|
exports.UiPathError = UiPathError;
|
|
14910
|
+
exports.UserSettingsMap = UserSettingsMap;
|
|
14549
14911
|
exports.VERSION = VERSION;
|
|
14550
14912
|
exports.ValidationError = ValidationError;
|
|
14913
|
+
exports.createAgentWithMethods = createAgentWithMethods;
|
|
14551
14914
|
exports.createCaseInstanceWithMethods = createCaseInstanceWithMethods;
|
|
14915
|
+
exports.createConversationWithMethods = createConversationWithMethods;
|
|
14552
14916
|
exports.createEntityWithMethods = createEntityWithMethods;
|
|
14553
14917
|
exports.createProcessInstanceWithMethods = createProcessInstanceWithMethods;
|
|
14554
14918
|
exports.createProcessWithMethods = createProcessWithMethods;
|