@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.cjs
CHANGED
|
@@ -3886,6 +3886,15 @@ class ExecutionContext {
|
|
|
3886
3886
|
*/
|
|
3887
3887
|
const isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
|
|
3888
3888
|
|
|
3889
|
+
/**
|
|
3890
|
+
* Session storage keys used by the auth module
|
|
3891
|
+
*/
|
|
3892
|
+
const AUTH_STORAGE_KEYS = {
|
|
3893
|
+
TOKEN_PREFIX: 'uipath_sdk_user_token-',
|
|
3894
|
+
OAUTH_CONTEXT: 'uipath_sdk_oauth_context',
|
|
3895
|
+
CODE_VERIFIER: 'uipath_sdk_code_verifier',
|
|
3896
|
+
};
|
|
3897
|
+
|
|
3889
3898
|
// Type guard to check if config has OAuth credentials
|
|
3890
3899
|
function hasOAuthConfig(config) {
|
|
3891
3900
|
return Boolean(config.clientId && config.redirectUri && config.scope);
|
|
@@ -3895,6 +3904,303 @@ function hasSecretConfig(config) {
|
|
|
3895
3904
|
return Boolean(config.secret);
|
|
3896
3905
|
}
|
|
3897
3906
|
|
|
3907
|
+
/**
|
|
3908
|
+
* Base error class for all UiPath SDK errors
|
|
3909
|
+
* Extends Error for standard error handling compatibility
|
|
3910
|
+
*/
|
|
3911
|
+
class UiPathError extends Error {
|
|
3912
|
+
constructor(type, params) {
|
|
3913
|
+
super(params.message);
|
|
3914
|
+
this.name = type;
|
|
3915
|
+
this.type = type;
|
|
3916
|
+
this.statusCode = params.statusCode;
|
|
3917
|
+
this.requestId = params.requestId;
|
|
3918
|
+
this.timestamp = new Date();
|
|
3919
|
+
// Maintains proper stack trace for where our error was thrown
|
|
3920
|
+
if (Error.captureStackTrace) {
|
|
3921
|
+
Error.captureStackTrace(this, this.constructor);
|
|
3922
|
+
}
|
|
3923
|
+
}
|
|
3924
|
+
/**
|
|
3925
|
+
* Returns a clean JSON representation of the error
|
|
3926
|
+
*/
|
|
3927
|
+
toJSON() {
|
|
3928
|
+
return {
|
|
3929
|
+
type: this.type,
|
|
3930
|
+
message: this.message,
|
|
3931
|
+
statusCode: this.statusCode,
|
|
3932
|
+
requestId: this.requestId,
|
|
3933
|
+
timestamp: this.timestamp
|
|
3934
|
+
};
|
|
3935
|
+
}
|
|
3936
|
+
/**
|
|
3937
|
+
* Returns detailed debug information including stack trace
|
|
3938
|
+
*/
|
|
3939
|
+
getDebugInfo() {
|
|
3940
|
+
return {
|
|
3941
|
+
...this.toJSON(),
|
|
3942
|
+
stack: this.stack
|
|
3943
|
+
};
|
|
3944
|
+
}
|
|
3945
|
+
}
|
|
3946
|
+
|
|
3947
|
+
/**
|
|
3948
|
+
* HTTP status code constants for error handling
|
|
3949
|
+
*/
|
|
3950
|
+
const HttpStatus = {
|
|
3951
|
+
// Client errors (4xx)
|
|
3952
|
+
BAD_REQUEST: 400,
|
|
3953
|
+
UNAUTHORIZED: 401,
|
|
3954
|
+
FORBIDDEN: 403,
|
|
3955
|
+
NOT_FOUND: 404,
|
|
3956
|
+
TOO_MANY_REQUESTS: 429,
|
|
3957
|
+
// Server errors (5xx)
|
|
3958
|
+
INTERNAL_SERVER_ERROR: 500,
|
|
3959
|
+
NOT_IMPLEMENTED: 501,
|
|
3960
|
+
BAD_GATEWAY: 502,
|
|
3961
|
+
SERVICE_UNAVAILABLE: 503,
|
|
3962
|
+
GATEWAY_TIMEOUT: 504
|
|
3963
|
+
};
|
|
3964
|
+
/**
|
|
3965
|
+
* Error type constants for consistent error identification
|
|
3966
|
+
*/
|
|
3967
|
+
const ErrorType = {
|
|
3968
|
+
AUTHENTICATION: 'AuthenticationError',
|
|
3969
|
+
AUTHORIZATION: 'AuthorizationError',
|
|
3970
|
+
VALIDATION: 'ValidationError',
|
|
3971
|
+
NOT_FOUND: 'NotFoundError',
|
|
3972
|
+
RATE_LIMIT: 'RateLimitError',
|
|
3973
|
+
SERVER: 'ServerError',
|
|
3974
|
+
NETWORK: 'NetworkError'
|
|
3975
|
+
};
|
|
3976
|
+
/**
|
|
3977
|
+
* HTTP header constants for error handling
|
|
3978
|
+
*/
|
|
3979
|
+
const HttpHeaders = {
|
|
3980
|
+
X_REQUEST_ID: 'x-request-id'
|
|
3981
|
+
};
|
|
3982
|
+
/**
|
|
3983
|
+
* Standard error message constants
|
|
3984
|
+
*/
|
|
3985
|
+
const ErrorMessages = {
|
|
3986
|
+
// Authentication errors
|
|
3987
|
+
AUTHENTICATION_FAILED: 'Authentication failed',
|
|
3988
|
+
// Authorization errors
|
|
3989
|
+
ACCESS_DENIED: 'Access denied',
|
|
3990
|
+
// Validation errors
|
|
3991
|
+
VALIDATION_FAILED: 'Validation failed',
|
|
3992
|
+
// Not found errors
|
|
3993
|
+
RESOURCE_NOT_FOUND: 'Resource not found',
|
|
3994
|
+
// Rate limit errors
|
|
3995
|
+
RATE_LIMIT_EXCEEDED: 'Rate limit exceeded',
|
|
3996
|
+
// Server errors
|
|
3997
|
+
INTERNAL_SERVER_ERROR: 'Internal Server error occurred',
|
|
3998
|
+
// Network errors
|
|
3999
|
+
NETWORK_ERROR: 'Network error occurred',
|
|
4000
|
+
REQUEST_TIMEOUT: 'Request timed out',
|
|
4001
|
+
REQUEST_ABORTED: 'Request was aborted',
|
|
4002
|
+
};
|
|
4003
|
+
/**
|
|
4004
|
+
* Error name constants for network error identification
|
|
4005
|
+
*/
|
|
4006
|
+
const ErrorNames = {
|
|
4007
|
+
ABORT_ERROR: 'AbortError'};
|
|
4008
|
+
|
|
4009
|
+
/**
|
|
4010
|
+
* Error thrown when authentication fails (401 errors)
|
|
4011
|
+
* Common scenarios:
|
|
4012
|
+
* - Invalid credentials
|
|
4013
|
+
* - Expired token
|
|
4014
|
+
* - Missing authentication
|
|
4015
|
+
*/
|
|
4016
|
+
class AuthenticationError extends UiPathError {
|
|
4017
|
+
constructor(params = {}) {
|
|
4018
|
+
super(ErrorType.AUTHENTICATION, {
|
|
4019
|
+
message: params.message || ErrorMessages.AUTHENTICATION_FAILED,
|
|
4020
|
+
statusCode: params.statusCode ?? HttpStatus.UNAUTHORIZED,
|
|
4021
|
+
requestId: params.requestId
|
|
4022
|
+
});
|
|
4023
|
+
}
|
|
4024
|
+
}
|
|
4025
|
+
|
|
4026
|
+
/**
|
|
4027
|
+
* Error thrown when authorization fails (403 errors)
|
|
4028
|
+
* Common scenarios:
|
|
4029
|
+
* - Insufficient permissions
|
|
4030
|
+
* - Access denied to resource
|
|
4031
|
+
* - Invalid scope
|
|
4032
|
+
*/
|
|
4033
|
+
class AuthorizationError extends UiPathError {
|
|
4034
|
+
constructor(params = {}) {
|
|
4035
|
+
super(ErrorType.AUTHORIZATION, {
|
|
4036
|
+
message: params.message || ErrorMessages.ACCESS_DENIED,
|
|
4037
|
+
statusCode: params.statusCode ?? HttpStatus.FORBIDDEN,
|
|
4038
|
+
requestId: params.requestId
|
|
4039
|
+
});
|
|
4040
|
+
}
|
|
4041
|
+
}
|
|
4042
|
+
|
|
4043
|
+
/**
|
|
4044
|
+
* Error thrown when validation fails (400 errors or client-side validation)
|
|
4045
|
+
* Common scenarios:
|
|
4046
|
+
* - Invalid input parameters
|
|
4047
|
+
* - Missing required fields
|
|
4048
|
+
* - Invalid data format
|
|
4049
|
+
*/
|
|
4050
|
+
class ValidationError extends UiPathError {
|
|
4051
|
+
constructor(params = {}) {
|
|
4052
|
+
super(ErrorType.VALIDATION, {
|
|
4053
|
+
message: params.message || ErrorMessages.VALIDATION_FAILED,
|
|
4054
|
+
statusCode: params.statusCode ?? HttpStatus.BAD_REQUEST,
|
|
4055
|
+
requestId: params.requestId
|
|
4056
|
+
});
|
|
4057
|
+
}
|
|
4058
|
+
}
|
|
4059
|
+
|
|
4060
|
+
/**
|
|
4061
|
+
* Error thrown when a resource is not found (404 errors)
|
|
4062
|
+
* Common scenarios:
|
|
4063
|
+
* - Resource doesn't exist
|
|
4064
|
+
* - Invalid ID provided
|
|
4065
|
+
* - Resource deleted
|
|
4066
|
+
*/
|
|
4067
|
+
class NotFoundError extends UiPathError {
|
|
4068
|
+
constructor(params = {}) {
|
|
4069
|
+
super(ErrorType.NOT_FOUND, {
|
|
4070
|
+
message: params.message || ErrorMessages.RESOURCE_NOT_FOUND,
|
|
4071
|
+
statusCode: params.statusCode ?? HttpStatus.NOT_FOUND,
|
|
4072
|
+
requestId: params.requestId
|
|
4073
|
+
});
|
|
4074
|
+
}
|
|
4075
|
+
}
|
|
4076
|
+
|
|
4077
|
+
/**
|
|
4078
|
+
* Error thrown when rate limit is exceeded (429 errors)
|
|
4079
|
+
* Common scenarios:
|
|
4080
|
+
* - Too many requests in a time window
|
|
4081
|
+
* - API throttling
|
|
4082
|
+
*/
|
|
4083
|
+
class RateLimitError extends UiPathError {
|
|
4084
|
+
constructor(params = {}) {
|
|
4085
|
+
super(ErrorType.RATE_LIMIT, {
|
|
4086
|
+
message: params.message || ErrorMessages.RATE_LIMIT_EXCEEDED,
|
|
4087
|
+
statusCode: params.statusCode ?? HttpStatus.TOO_MANY_REQUESTS,
|
|
4088
|
+
requestId: params.requestId
|
|
4089
|
+
});
|
|
4090
|
+
}
|
|
4091
|
+
}
|
|
4092
|
+
|
|
4093
|
+
/**
|
|
4094
|
+
* Error thrown when server encounters an error (5xx errors)
|
|
4095
|
+
* Common scenarios:
|
|
4096
|
+
* - Internal server error
|
|
4097
|
+
* - Service unavailable
|
|
4098
|
+
* - Gateway timeout
|
|
4099
|
+
*/
|
|
4100
|
+
class ServerError extends UiPathError {
|
|
4101
|
+
constructor(params = {}) {
|
|
4102
|
+
super(ErrorType.SERVER, {
|
|
4103
|
+
message: params.message || ErrorMessages.INTERNAL_SERVER_ERROR,
|
|
4104
|
+
statusCode: params.statusCode ?? HttpStatus.INTERNAL_SERVER_ERROR,
|
|
4105
|
+
requestId: params.requestId
|
|
4106
|
+
});
|
|
4107
|
+
}
|
|
4108
|
+
/**
|
|
4109
|
+
* Checks if this is a temporary error that might succeed on retry
|
|
4110
|
+
*/
|
|
4111
|
+
get isRetryable() {
|
|
4112
|
+
return this.statusCode === HttpStatus.BAD_GATEWAY ||
|
|
4113
|
+
this.statusCode === HttpStatus.SERVICE_UNAVAILABLE ||
|
|
4114
|
+
this.statusCode === HttpStatus.GATEWAY_TIMEOUT;
|
|
4115
|
+
}
|
|
4116
|
+
}
|
|
4117
|
+
|
|
4118
|
+
/**
|
|
4119
|
+
* Error thrown when network/connection issues occur
|
|
4120
|
+
* Common scenarios:
|
|
4121
|
+
* - Connection timeout
|
|
4122
|
+
* - DNS resolution failure
|
|
4123
|
+
* - Network unreachable
|
|
4124
|
+
* - Request aborted
|
|
4125
|
+
*/
|
|
4126
|
+
class NetworkError extends UiPathError {
|
|
4127
|
+
constructor(params = {}) {
|
|
4128
|
+
super(ErrorType.NETWORK, {
|
|
4129
|
+
message: params.message || ErrorMessages.NETWORK_ERROR,
|
|
4130
|
+
statusCode: params.statusCode, // Network errors typically don't have HTTP status codes
|
|
4131
|
+
requestId: params.requestId
|
|
4132
|
+
});
|
|
4133
|
+
}
|
|
4134
|
+
}
|
|
4135
|
+
|
|
4136
|
+
/**
|
|
4137
|
+
* Type guard to check if an error is a UiPathError
|
|
4138
|
+
*/
|
|
4139
|
+
function isUiPathError(error) {
|
|
4140
|
+
return error instanceof UiPathError;
|
|
4141
|
+
}
|
|
4142
|
+
/**
|
|
4143
|
+
* Type guard to check if an error is an AuthenticationError
|
|
4144
|
+
*/
|
|
4145
|
+
function isAuthenticationError(error) {
|
|
4146
|
+
return error instanceof AuthenticationError;
|
|
4147
|
+
}
|
|
4148
|
+
/**
|
|
4149
|
+
* Type guard to check if an error is an AuthorizationError
|
|
4150
|
+
*/
|
|
4151
|
+
function isAuthorizationError(error) {
|
|
4152
|
+
return error instanceof AuthorizationError;
|
|
4153
|
+
}
|
|
4154
|
+
/**
|
|
4155
|
+
* Type guard to check if an error is a ValidationError
|
|
4156
|
+
*/
|
|
4157
|
+
function isValidationError(error) {
|
|
4158
|
+
return error instanceof ValidationError;
|
|
4159
|
+
}
|
|
4160
|
+
/**
|
|
4161
|
+
* Type guard to check if an error is a NotFoundError
|
|
4162
|
+
*/
|
|
4163
|
+
function isNotFoundError(error) {
|
|
4164
|
+
return error instanceof NotFoundError;
|
|
4165
|
+
}
|
|
4166
|
+
/**
|
|
4167
|
+
* Type guard to check if an error is a RateLimitError
|
|
4168
|
+
*/
|
|
4169
|
+
function isRateLimitError(error) {
|
|
4170
|
+
return error instanceof RateLimitError;
|
|
4171
|
+
}
|
|
4172
|
+
/**
|
|
4173
|
+
* Type guard to check if an error is a ServerError
|
|
4174
|
+
*/
|
|
4175
|
+
function isServerError(error) {
|
|
4176
|
+
return error instanceof ServerError;
|
|
4177
|
+
}
|
|
4178
|
+
/**
|
|
4179
|
+
* Type guard to check if an error is a NetworkError
|
|
4180
|
+
*/
|
|
4181
|
+
function isNetworkError(error) {
|
|
4182
|
+
return error instanceof NetworkError;
|
|
4183
|
+
}
|
|
4184
|
+
/**
|
|
4185
|
+
* Helper to get error details in a safe way
|
|
4186
|
+
*/
|
|
4187
|
+
function getErrorDetails(error) {
|
|
4188
|
+
if (isUiPathError(error)) {
|
|
4189
|
+
return {
|
|
4190
|
+
message: error.message,
|
|
4191
|
+
statusCode: error.statusCode
|
|
4192
|
+
};
|
|
4193
|
+
}
|
|
4194
|
+
if (error instanceof Error) {
|
|
4195
|
+
return {
|
|
4196
|
+
message: error.message
|
|
4197
|
+
};
|
|
4198
|
+
}
|
|
4199
|
+
return {
|
|
4200
|
+
message: String(error)
|
|
4201
|
+
};
|
|
4202
|
+
}
|
|
4203
|
+
|
|
3898
4204
|
/**
|
|
3899
4205
|
* TokenManager is responsible for managing authentication tokens.
|
|
3900
4206
|
* It provides token operations for a specific client ID.
|
|
@@ -3912,7 +4218,6 @@ class TokenManager {
|
|
|
3912
4218
|
this.executionContext = executionContext;
|
|
3913
4219
|
this.config = config;
|
|
3914
4220
|
this.isOAuth = isOAuth;
|
|
3915
|
-
this.STORAGE_KEY_PREFIX = 'uipath_sdk_user_token-';
|
|
3916
4221
|
this.refreshPromise = null;
|
|
3917
4222
|
}
|
|
3918
4223
|
/**
|
|
@@ -3927,11 +4232,46 @@ class TokenManager {
|
|
|
3927
4232
|
}
|
|
3928
4233
|
return new Date() >= tokenInfo.expiresAt;
|
|
3929
4234
|
}
|
|
4235
|
+
/**
|
|
4236
|
+
* Gets a valid authentication token, refreshing if necessary.
|
|
4237
|
+
* This is the single source of truth for token validation and refresh logic.
|
|
4238
|
+
*
|
|
4239
|
+
* @returns The valid token string
|
|
4240
|
+
* @throws AuthenticationError if no token available or refresh fails
|
|
4241
|
+
*/
|
|
4242
|
+
async getValidToken() {
|
|
4243
|
+
const tokenInfo = this.executionContext.get('tokenInfo');
|
|
4244
|
+
if (!tokenInfo) {
|
|
4245
|
+
throw new AuthenticationError({
|
|
4246
|
+
message: 'No authentication token available. Make sure to initialize the SDK first.'
|
|
4247
|
+
});
|
|
4248
|
+
}
|
|
4249
|
+
// For secret-based tokens, they never expire
|
|
4250
|
+
if (tokenInfo.type === 'secret') {
|
|
4251
|
+
return tokenInfo.token;
|
|
4252
|
+
}
|
|
4253
|
+
// If token is not expired, return it
|
|
4254
|
+
if (!this.isTokenExpired(tokenInfo)) {
|
|
4255
|
+
return tokenInfo.token;
|
|
4256
|
+
}
|
|
4257
|
+
// Token is expired, refresh it
|
|
4258
|
+
try {
|
|
4259
|
+
const newToken = await this.refreshAccessToken();
|
|
4260
|
+
return newToken.access_token;
|
|
4261
|
+
}
|
|
4262
|
+
catch (error) {
|
|
4263
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
4264
|
+
throw new AuthenticationError({
|
|
4265
|
+
message: `Token refresh failed: ${message}. Please re-authenticate.`,
|
|
4266
|
+
statusCode: HttpStatus.UNAUTHORIZED
|
|
4267
|
+
});
|
|
4268
|
+
}
|
|
4269
|
+
}
|
|
3930
4270
|
/**
|
|
3931
4271
|
* Gets the storage key for this TokenManager instance
|
|
3932
4272
|
*/
|
|
3933
4273
|
_getStorageKey() {
|
|
3934
|
-
return `${
|
|
4274
|
+
return `${AUTH_STORAGE_KEYS.TOKEN_PREFIX}${this.config.clientId}`;
|
|
3935
4275
|
}
|
|
3936
4276
|
/**
|
|
3937
4277
|
* Loads token from session storage if available
|
|
@@ -4141,10 +4481,6 @@ class TokenManager {
|
|
|
4141
4481
|
}
|
|
4142
4482
|
}
|
|
4143
4483
|
|
|
4144
|
-
/**
|
|
4145
|
-
* API Endpoint Constants
|
|
4146
|
-
* Centralized location for all API endpoints used throughout the SDK
|
|
4147
|
-
*/
|
|
4148
4484
|
/**
|
|
4149
4485
|
* Base path constants for different services
|
|
4150
4486
|
*/
|
|
@@ -4152,6 +4488,66 @@ const ORCHESTRATOR_BASE = 'orchestrator_';
|
|
|
4152
4488
|
const PIMS_BASE = 'pims_';
|
|
4153
4489
|
const DATAFABRIC_BASE = 'datafabric_';
|
|
4154
4490
|
const IDENTITY_BASE = 'identity_';
|
|
4491
|
+
|
|
4492
|
+
/**
|
|
4493
|
+
* Orchestrator Service Endpoints
|
|
4494
|
+
*/
|
|
4495
|
+
/**
|
|
4496
|
+
* Task Service (Action Center) Endpoints
|
|
4497
|
+
*/
|
|
4498
|
+
const TASK_ENDPOINTS = {
|
|
4499
|
+
CREATE_GENERIC_TASK: `${ORCHESTRATOR_BASE}/tasks/GenericTasks/CreateTask`,
|
|
4500
|
+
GET_TASK_USERS: (folderId) => `${ORCHESTRATOR_BASE}/odata/Tasks/UiPath.Server.Configuration.OData.GetTaskUsers(organizationUnitId=${folderId})`,
|
|
4501
|
+
GET_TASKS_ACROSS_FOLDERS: `${ORCHESTRATOR_BASE}/odata/Tasks/UiPath.Server.Configuration.OData.GetTasksAcrossFolders`,
|
|
4502
|
+
GET_TASKS_ACROSS_FOLDERS_ADMIN: `${ORCHESTRATOR_BASE}/odata/Tasks/UiPath.Server.Configuration.OData.GetTasksAcrossFoldersForAdmin`,
|
|
4503
|
+
GET_BY_ID: (id) => `${ORCHESTRATOR_BASE}/odata/Tasks(${id})`,
|
|
4504
|
+
ASSIGN_TASKS: `${ORCHESTRATOR_BASE}/odata/Tasks/UiPath.Server.Configuration.OData.AssignTasks`,
|
|
4505
|
+
REASSIGN_TASKS: `${ORCHESTRATOR_BASE}/odata/Tasks/UiPath.Server.Configuration.OData.ReassignTasks`,
|
|
4506
|
+
UNASSIGN_TASKS: `${ORCHESTRATOR_BASE}/odata/Tasks/UiPath.Server.Configuration.OData.UnassignTasks`,
|
|
4507
|
+
COMPLETE_FORM_TASK: `${ORCHESTRATOR_BASE}/forms/TaskForms/CompleteTask`,
|
|
4508
|
+
COMPLETE_APP_TASK: `${ORCHESTRATOR_BASE}/tasks/AppTasks/CompleteAppTask`,
|
|
4509
|
+
COMPLETE_GENERIC_TASK: `${ORCHESTRATOR_BASE}/tasks/GenericTasks/CompleteTask`,
|
|
4510
|
+
GET_TASK_FORM_BY_ID: `${ORCHESTRATOR_BASE}/forms/TaskForms/GetTaskFormById`,
|
|
4511
|
+
};
|
|
4512
|
+
/**
|
|
4513
|
+
* Orchestrator Bucket Endpoints
|
|
4514
|
+
*/
|
|
4515
|
+
const BUCKET_ENDPOINTS = {
|
|
4516
|
+
GET_BY_FOLDER: `${ORCHESTRATOR_BASE}/odata/Buckets`,
|
|
4517
|
+
GET_ALL: `${ORCHESTRATOR_BASE}/odata/Buckets/UiPath.Server.Configuration.OData.GetBucketsAcrossFolders`,
|
|
4518
|
+
GET_BY_ID: (id) => `${ORCHESTRATOR_BASE}/odata/Buckets(${id})`,
|
|
4519
|
+
GET_FILE_META_DATA: (id) => `${ORCHESTRATOR_BASE}/api/Buckets/${id}/ListFiles`,
|
|
4520
|
+
GET_READ_URI: (id) => `${ORCHESTRATOR_BASE}/odata/Buckets(${id})/UiPath.Server.Configuration.OData.GetReadUri`,
|
|
4521
|
+
GET_WRITE_URI: (id) => `${ORCHESTRATOR_BASE}/odata/Buckets(${id})/UiPath.Server.Configuration.OData.GetWriteUri`,
|
|
4522
|
+
};
|
|
4523
|
+
/**
|
|
4524
|
+
* Orchestrator Process Service Endpoints
|
|
4525
|
+
*/
|
|
4526
|
+
const PROCESS_ENDPOINTS = {
|
|
4527
|
+
GET_ALL: `${ORCHESTRATOR_BASE}/odata/Releases`,
|
|
4528
|
+
START_PROCESS: `${ORCHESTRATOR_BASE}/odata/Jobs/UiPath.Server.Configuration.OData.StartJobs`,
|
|
4529
|
+
GET_BY_ID: (id) => `${ORCHESTRATOR_BASE}/odata/Releases(${id})`,
|
|
4530
|
+
};
|
|
4531
|
+
/**
|
|
4532
|
+
* Orchestrator Queue Service Endpoints
|
|
4533
|
+
*/
|
|
4534
|
+
const QUEUE_ENDPOINTS = {
|
|
4535
|
+
GET_BY_FOLDER: `${ORCHESTRATOR_BASE}/odata/QueueDefinitions`,
|
|
4536
|
+
GET_ALL: `${ORCHESTRATOR_BASE}/odata/QueueDefinitions/UiPath.Server.Configuration.OData.GetQueuesAcrossFolders`,
|
|
4537
|
+
GET_BY_ID: (id) => `${ORCHESTRATOR_BASE}/odata/QueueDefinitions(${id})`,
|
|
4538
|
+
};
|
|
4539
|
+
/**
|
|
4540
|
+
* Orchestrator Asset Service Endpoints
|
|
4541
|
+
*/
|
|
4542
|
+
const ASSET_ENDPOINTS = {
|
|
4543
|
+
GET_BY_FOLDER: `${ORCHESTRATOR_BASE}/odata/Assets/UiPath.Server.Configuration.OData.GetFiltered`,
|
|
4544
|
+
GET_ALL: `${ORCHESTRATOR_BASE}/odata/Assets/UiPath.Server.Configuration.OData.GetAssetsAcrossFolders`,
|
|
4545
|
+
GET_BY_ID: (id) => `${ORCHESTRATOR_BASE}/odata/Assets(${id})`,
|
|
4546
|
+
};
|
|
4547
|
+
|
|
4548
|
+
/**
|
|
4549
|
+
* Maestro Service Endpoints
|
|
4550
|
+
*/
|
|
4155
4551
|
/**
|
|
4156
4552
|
* Maestro Process Service Endpoints
|
|
4157
4553
|
*/
|
|
@@ -4181,25 +4577,12 @@ const MAESTRO_ENDPOINTS = {
|
|
|
4181
4577
|
REOPEN: (instanceId) => `${PIMS_BASE}/api/v1/cases/${instanceId}/reopen`,
|
|
4182
4578
|
},
|
|
4183
4579
|
};
|
|
4580
|
+
|
|
4184
4581
|
/**
|
|
4185
|
-
*
|
|
4582
|
+
* Data Fabric Service Endpoints
|
|
4186
4583
|
*/
|
|
4187
|
-
const TASK_ENDPOINTS = {
|
|
4188
|
-
CREATE_GENERIC_TASK: `${ORCHESTRATOR_BASE}/tasks/GenericTasks/CreateTask`,
|
|
4189
|
-
GET_TASK_USERS: (folderId) => `${ORCHESTRATOR_BASE}/odata/Tasks/UiPath.Server.Configuration.OData.GetTaskUsers(organizationUnitId=${folderId})`,
|
|
4190
|
-
GET_TASKS_ACROSS_FOLDERS: `${ORCHESTRATOR_BASE}/odata/Tasks/UiPath.Server.Configuration.OData.GetTasksAcrossFolders`,
|
|
4191
|
-
GET_TASKS_ACROSS_FOLDERS_ADMIN: `${ORCHESTRATOR_BASE}/odata/Tasks/UiPath.Server.Configuration.OData.GetTasksAcrossFoldersForAdmin`,
|
|
4192
|
-
GET_BY_ID: (id) => `${ORCHESTRATOR_BASE}/odata/Tasks(${id})`,
|
|
4193
|
-
ASSIGN_TASKS: `${ORCHESTRATOR_BASE}/odata/Tasks/UiPath.Server.Configuration.OData.AssignTasks`,
|
|
4194
|
-
REASSIGN_TASKS: `${ORCHESTRATOR_BASE}/odata/Tasks/UiPath.Server.Configuration.OData.ReassignTasks`,
|
|
4195
|
-
UNASSIGN_TASKS: `${ORCHESTRATOR_BASE}/odata/Tasks/UiPath.Server.Configuration.OData.UnassignTasks`,
|
|
4196
|
-
COMPLETE_FORM_TASK: `${ORCHESTRATOR_BASE}/forms/TaskForms/CompleteTask`,
|
|
4197
|
-
COMPLETE_APP_TASK: `${ORCHESTRATOR_BASE}/tasks/AppTasks/CompleteAppTask`,
|
|
4198
|
-
COMPLETE_GENERIC_TASK: `${ORCHESTRATOR_BASE}/tasks/GenericTasks/CompleteTask`,
|
|
4199
|
-
GET_TASK_FORM_BY_ID: `${ORCHESTRATOR_BASE}/forms/TaskForms/GetTaskFormById`,
|
|
4200
|
-
};
|
|
4201
4584
|
/**
|
|
4202
|
-
* Data Fabric Service Endpoints
|
|
4585
|
+
* Data Fabric Entity Service Endpoints
|
|
4203
4586
|
*/
|
|
4204
4587
|
const DATA_FABRIC_ENDPOINTS = {
|
|
4205
4588
|
ENTITY: {
|
|
@@ -4210,55 +4593,24 @@ const DATA_FABRIC_ENDPOINTS = {
|
|
|
4210
4593
|
INSERT_BY_ID: (entityId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${entityId}/insert`,
|
|
4211
4594
|
BATCH_INSERT_BY_ID: (entityId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${entityId}/insert-batch`,
|
|
4212
4595
|
UPDATE_BY_ID: (entityId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${entityId}/update-batch`,
|
|
4213
|
-
DELETE_BY_ID: (entityId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${entityId}/delete-batch`,
|
|
4214
|
-
DOWNLOAD_ATTACHMENT: (entityName, recordId, fieldName) => `${DATAFABRIC_BASE}/api/Attachment/${entityName}/${recordId}/${fieldName}`,
|
|
4215
|
-
},
|
|
4216
|
-
CHOICESETS: {
|
|
4217
|
-
GET_ALL: `${DATAFABRIC_BASE}/api/Entity/choiceset`,
|
|
4218
|
-
GET_BY_ID: (choiceSetId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${choiceSetId}/query_expansion`,
|
|
4219
|
-
},
|
|
4220
|
-
};
|
|
4221
|
-
/**
|
|
4222
|
-
* Orchestrator Bucket Endpoints
|
|
4223
|
-
*/
|
|
4224
|
-
const BUCKET_ENDPOINTS = {
|
|
4225
|
-
GET_BY_FOLDER: `${ORCHESTRATOR_BASE}/odata/Buckets`,
|
|
4226
|
-
GET_ALL: `${ORCHESTRATOR_BASE}/odata/Buckets/UiPath.Server.Configuration.OData.GetBucketsAcrossFolders`,
|
|
4227
|
-
GET_BY_ID: (id) => `${ORCHESTRATOR_BASE}/odata/Buckets(${id})`,
|
|
4228
|
-
GET_FILE_META_DATA: (id) => `${ORCHESTRATOR_BASE}/api/Buckets/${id}/ListFiles`,
|
|
4229
|
-
GET_READ_URI: (id) => `${ORCHESTRATOR_BASE}/odata/Buckets(${id})/UiPath.Server.Configuration.OData.GetReadUri`,
|
|
4230
|
-
GET_WRITE_URI: (id) => `${ORCHESTRATOR_BASE}/odata/Buckets(${id})/UiPath.Server.Configuration.OData.GetWriteUri`,
|
|
4231
|
-
};
|
|
4232
|
-
/**
|
|
4233
|
-
* Identity/Authentication Endpoints
|
|
4234
|
-
*/
|
|
4235
|
-
const IDENTITY_ENDPOINTS = {
|
|
4236
|
-
TOKEN: `${IDENTITY_BASE}/connect/token`,
|
|
4237
|
-
AUTHORIZE: `${IDENTITY_BASE}/connect/authorize`,
|
|
4238
|
-
};
|
|
4239
|
-
/**
|
|
4240
|
-
* Orchestrator Process Service Endpoints
|
|
4241
|
-
*/
|
|
4242
|
-
const PROCESS_ENDPOINTS = {
|
|
4243
|
-
GET_ALL: `${ORCHESTRATOR_BASE}/odata/Releases`,
|
|
4244
|
-
START_PROCESS: `${ORCHESTRATOR_BASE}/odata/Jobs/UiPath.Server.Configuration.OData.StartJobs`,
|
|
4245
|
-
GET_BY_ID: (id) => `${ORCHESTRATOR_BASE}/odata/Releases(${id})`,
|
|
4596
|
+
DELETE_BY_ID: (entityId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${entityId}/delete-batch`,
|
|
4597
|
+
DOWNLOAD_ATTACHMENT: (entityName, recordId, fieldName) => `${DATAFABRIC_BASE}/api/Attachment/${entityName}/${recordId}/${fieldName}`,
|
|
4598
|
+
},
|
|
4599
|
+
CHOICESETS: {
|
|
4600
|
+
GET_ALL: `${DATAFABRIC_BASE}/api/Entity/choiceset`,
|
|
4601
|
+
GET_BY_ID: (choiceSetId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${choiceSetId}/query_expansion`,
|
|
4602
|
+
},
|
|
4246
4603
|
};
|
|
4604
|
+
|
|
4247
4605
|
/**
|
|
4248
|
-
*
|
|
4606
|
+
* Identity/Authentication Endpoints
|
|
4249
4607
|
*/
|
|
4250
|
-
const QUEUE_ENDPOINTS = {
|
|
4251
|
-
GET_BY_FOLDER: `${ORCHESTRATOR_BASE}/odata/QueueDefinitions`,
|
|
4252
|
-
GET_ALL: `${ORCHESTRATOR_BASE}/odata/QueueDefinitions/UiPath.Server.Configuration.OData.GetQueuesAcrossFolders`,
|
|
4253
|
-
GET_BY_ID: (id) => `${ORCHESTRATOR_BASE}/odata/QueueDefinitions(${id})`,
|
|
4254
|
-
};
|
|
4255
4608
|
/**
|
|
4256
|
-
*
|
|
4609
|
+
* Identity Service Endpoints
|
|
4257
4610
|
*/
|
|
4258
|
-
const
|
|
4259
|
-
|
|
4260
|
-
|
|
4261
|
-
GET_BY_ID: (id) => `${ORCHESTRATOR_BASE}/odata/Assets(${id})`,
|
|
4611
|
+
const IDENTITY_ENDPOINTS = {
|
|
4612
|
+
TOKEN: `${IDENTITY_BASE}/connect/token`,
|
|
4613
|
+
AUTHORIZE: `${IDENTITY_BASE}/connect/authorize`,
|
|
4262
4614
|
};
|
|
4263
4615
|
|
|
4264
4616
|
class AuthService {
|
|
@@ -4281,7 +4633,7 @@ class AuthService {
|
|
|
4281
4633
|
return false;
|
|
4282
4634
|
const urlParams = new URLSearchParams(window.location.search);
|
|
4283
4635
|
const code = urlParams.get('code');
|
|
4284
|
-
const hasCodeVerifier = sessionStorage.getItem(
|
|
4636
|
+
const hasCodeVerifier = sessionStorage.getItem(AUTH_STORAGE_KEYS.CODE_VERIFIER);
|
|
4285
4637
|
return !!(code && hasCodeVerifier);
|
|
4286
4638
|
}
|
|
4287
4639
|
/**
|
|
@@ -4292,7 +4644,7 @@ class AuthService {
|
|
|
4292
4644
|
return null;
|
|
4293
4645
|
}
|
|
4294
4646
|
try {
|
|
4295
|
-
const stored = sessionStorage.getItem(
|
|
4647
|
+
const stored = sessionStorage.getItem(AUTH_STORAGE_KEYS.OAUTH_CONTEXT);
|
|
4296
4648
|
if (!stored) {
|
|
4297
4649
|
return null;
|
|
4298
4650
|
}
|
|
@@ -4300,13 +4652,13 @@ class AuthService {
|
|
|
4300
4652
|
// Validate required fields
|
|
4301
4653
|
if (!context.codeVerifier || !context.clientId || !context.redirectUri ||
|
|
4302
4654
|
!context.baseUrl || !context.orgName) {
|
|
4303
|
-
sessionStorage.removeItem(
|
|
4655
|
+
sessionStorage.removeItem(AUTH_STORAGE_KEYS.OAUTH_CONTEXT);
|
|
4304
4656
|
return null;
|
|
4305
4657
|
}
|
|
4306
4658
|
return context;
|
|
4307
4659
|
}
|
|
4308
4660
|
catch (error) {
|
|
4309
|
-
sessionStorage.removeItem(
|
|
4661
|
+
sessionStorage.removeItem(AUTH_STORAGE_KEYS.OAUTH_CONTEXT);
|
|
4310
4662
|
console.warn('Failed to parse stored OAuth context from session storage', error);
|
|
4311
4663
|
return null;
|
|
4312
4664
|
}
|
|
@@ -4381,7 +4733,7 @@ class AuthService {
|
|
|
4381
4733
|
throw new Error('OAuth flow is only supported in browser environments');
|
|
4382
4734
|
}
|
|
4383
4735
|
// Check if we have a stored code verifier indicating we're in an OAuth flow
|
|
4384
|
-
const codeVerifier = sessionStorage.getItem(
|
|
4736
|
+
const codeVerifier = sessionStorage.getItem(AUTH_STORAGE_KEYS.CODE_VERIFIER);
|
|
4385
4737
|
const isInOAuthFlow = codeVerifier !== null;
|
|
4386
4738
|
const urlParams = new URLSearchParams(window.location.search);
|
|
4387
4739
|
const code = urlParams.get('code');
|
|
@@ -4390,7 +4742,7 @@ class AuthService {
|
|
|
4390
4742
|
// We're expecting a callback - validate parameters
|
|
4391
4743
|
if (!code) {
|
|
4392
4744
|
// Clear stored state on error
|
|
4393
|
-
sessionStorage.removeItem(
|
|
4745
|
+
sessionStorage.removeItem(AUTH_STORAGE_KEYS.CODE_VERIFIER);
|
|
4394
4746
|
throw new Error('Authorization code missing in OAuth callback');
|
|
4395
4747
|
}
|
|
4396
4748
|
// Validate the authorization code format before using it
|
|
@@ -4398,7 +4750,7 @@ class AuthService {
|
|
|
4398
4750
|
const codePattern = /^[A-Za-z0-9\-._~+/]+=*$/;
|
|
4399
4751
|
if (!codePattern.test(code)) {
|
|
4400
4752
|
// Clear stored state on error
|
|
4401
|
-
sessionStorage.removeItem(
|
|
4753
|
+
sessionStorage.removeItem(AUTH_STORAGE_KEYS.CODE_VERIFIER);
|
|
4402
4754
|
throw new Error('Invalid authorization code format');
|
|
4403
4755
|
}
|
|
4404
4756
|
// Authorization code is present and validated, so we can exchange it for a token.
|
|
@@ -4439,6 +4791,24 @@ class AuthService {
|
|
|
4439
4791
|
hasValidToken() {
|
|
4440
4792
|
return this.tokenManager.hasValidToken();
|
|
4441
4793
|
}
|
|
4794
|
+
/**
|
|
4795
|
+
* Clears all authentication state including tokens and stored OAuth context.
|
|
4796
|
+
*/
|
|
4797
|
+
logout() {
|
|
4798
|
+
this.tokenManager.clearToken();
|
|
4799
|
+
// Clear OAuth context from session storage. These are normally cleaned up in _handleOAuthCallback after a successful
|
|
4800
|
+
// token exchange, but if a user calls logout() while an OAuth flow is
|
|
4801
|
+
// mid-redirect (before callback completes), they'd be left behind.
|
|
4802
|
+
if (isBrowser) {
|
|
4803
|
+
try {
|
|
4804
|
+
sessionStorage.removeItem(AUTH_STORAGE_KEYS.OAUTH_CONTEXT);
|
|
4805
|
+
sessionStorage.removeItem(AUTH_STORAGE_KEYS.CODE_VERIFIER);
|
|
4806
|
+
}
|
|
4807
|
+
catch (error) {
|
|
4808
|
+
console.warn('Failed to clear OAuth context from session storage', error);
|
|
4809
|
+
}
|
|
4810
|
+
}
|
|
4811
|
+
}
|
|
4442
4812
|
/**
|
|
4443
4813
|
* Get the current token
|
|
4444
4814
|
*/
|
|
@@ -4570,8 +4940,8 @@ class AuthService {
|
|
|
4570
4940
|
tenantName: this.config.tenantName,
|
|
4571
4941
|
scope
|
|
4572
4942
|
};
|
|
4573
|
-
sessionStorage.setItem(
|
|
4574
|
-
sessionStorage.setItem(
|
|
4943
|
+
sessionStorage.setItem(AUTH_STORAGE_KEYS.OAUTH_CONTEXT, JSON.stringify(oauthContext));
|
|
4944
|
+
sessionStorage.setItem(AUTH_STORAGE_KEYS.CODE_VERIFIER, codeVerifier);
|
|
4575
4945
|
const authUrl = this.getAuthorizationUrl({
|
|
4576
4946
|
clientId,
|
|
4577
4947
|
redirectUri,
|
|
@@ -4581,7 +4951,7 @@ class AuthService {
|
|
|
4581
4951
|
window.location.href = authUrl;
|
|
4582
4952
|
}
|
|
4583
4953
|
async _handleOAuthCallback(code, clientId, redirectUri) {
|
|
4584
|
-
const codeVerifier = sessionStorage.getItem(
|
|
4954
|
+
const codeVerifier = sessionStorage.getItem(AUTH_STORAGE_KEYS.CODE_VERIFIER);
|
|
4585
4955
|
if (!codeVerifier) {
|
|
4586
4956
|
throw new Error('Code verifier not found in session storage. Authentication may have been interrupted.');
|
|
4587
4957
|
}
|
|
@@ -4592,8 +4962,8 @@ class AuthService {
|
|
|
4592
4962
|
codeVerifier
|
|
4593
4963
|
});
|
|
4594
4964
|
// Clear OAuth context and code verifier after successful token exchange
|
|
4595
|
-
sessionStorage.removeItem(
|
|
4596
|
-
sessionStorage.removeItem(
|
|
4965
|
+
sessionStorage.removeItem(AUTH_STORAGE_KEYS.OAUTH_CONTEXT);
|
|
4966
|
+
sessionStorage.removeItem(AUTH_STORAGE_KEYS.CODE_VERIFIER);
|
|
4597
4967
|
const url = new URL(window.location.href);
|
|
4598
4968
|
url.searchParams.delete('code');
|
|
4599
4969
|
url.searchParams.delete('state');
|
|
@@ -4619,7 +4989,7 @@ function normalizeBaseUrl(url) {
|
|
|
4619
4989
|
// Connection string placeholder that will be replaced during build
|
|
4620
4990
|
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";
|
|
4621
4991
|
// SDK Version placeholder
|
|
4622
|
-
const SDK_VERSION = "1.
|
|
4992
|
+
const SDK_VERSION = "1.1.1";
|
|
4623
4993
|
const VERSION = "Version";
|
|
4624
4994
|
const SERVICE = "Service";
|
|
4625
4995
|
const CLOUD_ORGANIZATION_NAME = "CloudOrganizationName";
|
|
@@ -4796,7 +5166,6 @@ class TelemetryClient {
|
|
|
4796
5166
|
*/
|
|
4797
5167
|
getEnrichedAttributes(extraAttributes, eventName) {
|
|
4798
5168
|
const attributes = {
|
|
4799
|
-
...extraAttributes,
|
|
4800
5169
|
[APP_NAME]: SDK_SERVICE_NAME,
|
|
4801
5170
|
[VERSION]: SDK_VERSION,
|
|
4802
5171
|
[SERVICE]: eventName,
|
|
@@ -4805,6 +5174,7 @@ class TelemetryClient {
|
|
|
4805
5174
|
[CLOUD_TENANT_NAME]: this.telemetryContext?.tenantName || UNKNOWN$1,
|
|
4806
5175
|
[CLOUD_REDIRECT_URI]: this.telemetryContext?.redirectUri || UNKNOWN$1,
|
|
4807
5176
|
[CLOUD_CLIENT_ID]: this.telemetryContext?.clientId || UNKNOWN$1,
|
|
5177
|
+
...extraAttributes,
|
|
4808
5178
|
};
|
|
4809
5179
|
return attributes;
|
|
4810
5180
|
}
|
|
@@ -5077,329 +5447,47 @@ let UiPath$1 = class UiPath {
|
|
|
5077
5447
|
*/
|
|
5078
5448
|
async completeOAuth() {
|
|
5079
5449
|
if (!AuthService.isInOAuthCallback()) {
|
|
5080
|
-
throw new Error('Not in OAuth callback state. Call initialize() first to start OAuth flow.');
|
|
5081
|
-
}
|
|
5082
|
-
try {
|
|
5083
|
-
const success = await __classPrivateFieldGet(this, _UiPath_authService, "f").authenticate(__classPrivateFieldGet(this, _UiPath_config, "f"));
|
|
5084
|
-
if (success && this.isAuthenticated()) {
|
|
5085
|
-
__classPrivateFieldSet(this, _UiPath_initialized, true, "f");
|
|
5086
|
-
return true;
|
|
5087
|
-
}
|
|
5088
|
-
return false;
|
|
5089
|
-
}
|
|
5090
|
-
catch (error) {
|
|
5091
|
-
const errorMessage = error instanceof Error ? error.message : 'An unknown error occurred';
|
|
5092
|
-
throw new Error(`Failed to complete OAuth: ${errorMessage}`);
|
|
5093
|
-
}
|
|
5094
|
-
}
|
|
5095
|
-
/**
|
|
5096
|
-
* Check if the user is authenticated (has valid token)
|
|
5097
|
-
*/
|
|
5098
|
-
isAuthenticated() {
|
|
5099
|
-
return __classPrivateFieldGet(this, _UiPath_authService, "f").hasValidToken();
|
|
5100
|
-
}
|
|
5101
|
-
/**
|
|
5102
|
-
* Get the current authentication token
|
|
5103
|
-
*/
|
|
5104
|
-
getToken() {
|
|
5105
|
-
return __classPrivateFieldGet(this, _UiPath_authService, "f").getToken();
|
|
5106
|
-
}
|
|
5107
|
-
};
|
|
5108
|
-
_UiPath_config = new WeakMap(), _UiPath_authService = new WeakMap(), _UiPath_initialized = new WeakMap();
|
|
5109
|
-
|
|
5110
|
-
/**
|
|
5111
|
-
* Base error class for all UiPath SDK errors
|
|
5112
|
-
* Pure TypeScript class with clean interface
|
|
5113
|
-
*/
|
|
5114
|
-
class UiPathError {
|
|
5115
|
-
constructor(type, params) {
|
|
5116
|
-
this.type = type;
|
|
5117
|
-
this.message = params.message;
|
|
5118
|
-
this.statusCode = params.statusCode;
|
|
5119
|
-
this.requestId = params.requestId;
|
|
5120
|
-
this.timestamp = new Date();
|
|
5121
|
-
// Capture stack trace for debugging
|
|
5122
|
-
this.stack = (new Error()).stack;
|
|
5123
|
-
}
|
|
5124
|
-
/**
|
|
5125
|
-
* Returns a clean JSON representation of the error
|
|
5126
|
-
*/
|
|
5127
|
-
toJSON() {
|
|
5128
|
-
return {
|
|
5129
|
-
type: this.type,
|
|
5130
|
-
message: this.message,
|
|
5131
|
-
statusCode: this.statusCode,
|
|
5132
|
-
requestId: this.requestId,
|
|
5133
|
-
timestamp: this.timestamp
|
|
5134
|
-
};
|
|
5135
|
-
}
|
|
5136
|
-
/**
|
|
5137
|
-
* Returns detailed debug information including stack trace
|
|
5138
|
-
*/
|
|
5139
|
-
getDebugInfo() {
|
|
5140
|
-
return {
|
|
5141
|
-
...this.toJSON(),
|
|
5142
|
-
stack: this.stack
|
|
5143
|
-
};
|
|
5144
|
-
}
|
|
5145
|
-
}
|
|
5146
|
-
|
|
5147
|
-
/**
|
|
5148
|
-
* HTTP status code constants for error handling
|
|
5149
|
-
*/
|
|
5150
|
-
const HttpStatus = {
|
|
5151
|
-
// Client errors (4xx)
|
|
5152
|
-
BAD_REQUEST: 400,
|
|
5153
|
-
UNAUTHORIZED: 401,
|
|
5154
|
-
FORBIDDEN: 403,
|
|
5155
|
-
NOT_FOUND: 404,
|
|
5156
|
-
TOO_MANY_REQUESTS: 429,
|
|
5157
|
-
// Server errors (5xx)
|
|
5158
|
-
INTERNAL_SERVER_ERROR: 500,
|
|
5159
|
-
NOT_IMPLEMENTED: 501,
|
|
5160
|
-
BAD_GATEWAY: 502,
|
|
5161
|
-
SERVICE_UNAVAILABLE: 503,
|
|
5162
|
-
GATEWAY_TIMEOUT: 504
|
|
5163
|
-
};
|
|
5164
|
-
/**
|
|
5165
|
-
* Error type constants for consistent error identification
|
|
5166
|
-
*/
|
|
5167
|
-
const ErrorType = {
|
|
5168
|
-
AUTHENTICATION: 'AuthenticationError',
|
|
5169
|
-
AUTHORIZATION: 'AuthorizationError',
|
|
5170
|
-
VALIDATION: 'ValidationError',
|
|
5171
|
-
NOT_FOUND: 'NotFoundError',
|
|
5172
|
-
RATE_LIMIT: 'RateLimitError',
|
|
5173
|
-
SERVER: 'ServerError',
|
|
5174
|
-
NETWORK: 'NetworkError'
|
|
5175
|
-
};
|
|
5176
|
-
/**
|
|
5177
|
-
* HTTP header constants for error handling
|
|
5178
|
-
*/
|
|
5179
|
-
const HttpHeaders = {
|
|
5180
|
-
X_REQUEST_ID: 'x-request-id'
|
|
5181
|
-
};
|
|
5182
|
-
/**
|
|
5183
|
-
* Standard error message constants
|
|
5184
|
-
*/
|
|
5185
|
-
const ErrorMessages = {
|
|
5186
|
-
// Authentication errors
|
|
5187
|
-
AUTHENTICATION_FAILED: 'Authentication failed',
|
|
5188
|
-
// Authorization errors
|
|
5189
|
-
ACCESS_DENIED: 'Access denied',
|
|
5190
|
-
// Validation errors
|
|
5191
|
-
VALIDATION_FAILED: 'Validation failed',
|
|
5192
|
-
// Not found errors
|
|
5193
|
-
RESOURCE_NOT_FOUND: 'Resource not found',
|
|
5194
|
-
// Rate limit errors
|
|
5195
|
-
RATE_LIMIT_EXCEEDED: 'Rate limit exceeded',
|
|
5196
|
-
// Server errors
|
|
5197
|
-
INTERNAL_SERVER_ERROR: 'Internal Server error occurred',
|
|
5198
|
-
// Network errors
|
|
5199
|
-
NETWORK_ERROR: 'Network error occurred',
|
|
5200
|
-
REQUEST_TIMEOUT: 'Request timed out',
|
|
5201
|
-
REQUEST_ABORTED: 'Request was aborted',
|
|
5202
|
-
};
|
|
5203
|
-
/**
|
|
5204
|
-
* Error name constants for network error identification
|
|
5205
|
-
*/
|
|
5206
|
-
const ErrorNames = {
|
|
5207
|
-
ABORT_ERROR: 'AbortError'};
|
|
5208
|
-
|
|
5209
|
-
/**
|
|
5210
|
-
* Error thrown when authentication fails (401 errors)
|
|
5211
|
-
* Common scenarios:
|
|
5212
|
-
* - Invalid credentials
|
|
5213
|
-
* - Expired token
|
|
5214
|
-
* - Missing authentication
|
|
5215
|
-
*/
|
|
5216
|
-
class AuthenticationError extends UiPathError {
|
|
5217
|
-
constructor(params = {}) {
|
|
5218
|
-
super(ErrorType.AUTHENTICATION, {
|
|
5219
|
-
message: params.message || ErrorMessages.AUTHENTICATION_FAILED,
|
|
5220
|
-
statusCode: params.statusCode ?? HttpStatus.UNAUTHORIZED,
|
|
5221
|
-
requestId: params.requestId
|
|
5222
|
-
});
|
|
5223
|
-
}
|
|
5224
|
-
}
|
|
5225
|
-
|
|
5226
|
-
/**
|
|
5227
|
-
* Error thrown when authorization fails (403 errors)
|
|
5228
|
-
* Common scenarios:
|
|
5229
|
-
* - Insufficient permissions
|
|
5230
|
-
* - Access denied to resource
|
|
5231
|
-
* - Invalid scope
|
|
5232
|
-
*/
|
|
5233
|
-
class AuthorizationError extends UiPathError {
|
|
5234
|
-
constructor(params = {}) {
|
|
5235
|
-
super(ErrorType.AUTHORIZATION, {
|
|
5236
|
-
message: params.message || ErrorMessages.ACCESS_DENIED,
|
|
5237
|
-
statusCode: params.statusCode ?? HttpStatus.FORBIDDEN,
|
|
5238
|
-
requestId: params.requestId
|
|
5239
|
-
});
|
|
5240
|
-
}
|
|
5241
|
-
}
|
|
5242
|
-
|
|
5243
|
-
/**
|
|
5244
|
-
* Error thrown when validation fails (400 errors or client-side validation)
|
|
5245
|
-
* Common scenarios:
|
|
5246
|
-
* - Invalid input parameters
|
|
5247
|
-
* - Missing required fields
|
|
5248
|
-
* - Invalid data format
|
|
5249
|
-
*/
|
|
5250
|
-
class ValidationError extends UiPathError {
|
|
5251
|
-
constructor(params = {}) {
|
|
5252
|
-
super(ErrorType.VALIDATION, {
|
|
5253
|
-
message: params.message || ErrorMessages.VALIDATION_FAILED,
|
|
5254
|
-
statusCode: params.statusCode ?? HttpStatus.BAD_REQUEST,
|
|
5255
|
-
requestId: params.requestId
|
|
5256
|
-
});
|
|
5257
|
-
}
|
|
5258
|
-
}
|
|
5259
|
-
|
|
5260
|
-
/**
|
|
5261
|
-
* Error thrown when a resource is not found (404 errors)
|
|
5262
|
-
* Common scenarios:
|
|
5263
|
-
* - Resource doesn't exist
|
|
5264
|
-
* - Invalid ID provided
|
|
5265
|
-
* - Resource deleted
|
|
5266
|
-
*/
|
|
5267
|
-
class NotFoundError extends UiPathError {
|
|
5268
|
-
constructor(params = {}) {
|
|
5269
|
-
super(ErrorType.NOT_FOUND, {
|
|
5270
|
-
message: params.message || ErrorMessages.RESOURCE_NOT_FOUND,
|
|
5271
|
-
statusCode: params.statusCode ?? HttpStatus.NOT_FOUND,
|
|
5272
|
-
requestId: params.requestId
|
|
5273
|
-
});
|
|
5274
|
-
}
|
|
5275
|
-
}
|
|
5276
|
-
|
|
5277
|
-
/**
|
|
5278
|
-
* Error thrown when rate limit is exceeded (429 errors)
|
|
5279
|
-
* Common scenarios:
|
|
5280
|
-
* - Too many requests in a time window
|
|
5281
|
-
* - API throttling
|
|
5282
|
-
*/
|
|
5283
|
-
class RateLimitError extends UiPathError {
|
|
5284
|
-
constructor(params = {}) {
|
|
5285
|
-
super(ErrorType.RATE_LIMIT, {
|
|
5286
|
-
message: params.message || ErrorMessages.RATE_LIMIT_EXCEEDED,
|
|
5287
|
-
statusCode: params.statusCode ?? HttpStatus.TOO_MANY_REQUESTS,
|
|
5288
|
-
requestId: params.requestId
|
|
5289
|
-
});
|
|
5290
|
-
}
|
|
5291
|
-
}
|
|
5292
|
-
|
|
5293
|
-
/**
|
|
5294
|
-
* Error thrown when server encounters an error (5xx errors)
|
|
5295
|
-
* Common scenarios:
|
|
5296
|
-
* - Internal server error
|
|
5297
|
-
* - Service unavailable
|
|
5298
|
-
* - Gateway timeout
|
|
5299
|
-
*/
|
|
5300
|
-
class ServerError extends UiPathError {
|
|
5301
|
-
constructor(params = {}) {
|
|
5302
|
-
super(ErrorType.SERVER, {
|
|
5303
|
-
message: params.message || ErrorMessages.INTERNAL_SERVER_ERROR,
|
|
5304
|
-
statusCode: params.statusCode ?? HttpStatus.INTERNAL_SERVER_ERROR,
|
|
5305
|
-
requestId: params.requestId
|
|
5306
|
-
});
|
|
5450
|
+
throw new Error('Not in OAuth callback state. Call initialize() first to start OAuth flow.');
|
|
5451
|
+
}
|
|
5452
|
+
try {
|
|
5453
|
+
const success = await __classPrivateFieldGet(this, _UiPath_authService, "f").authenticate(__classPrivateFieldGet(this, _UiPath_config, "f"));
|
|
5454
|
+
if (success && this.isAuthenticated()) {
|
|
5455
|
+
__classPrivateFieldSet(this, _UiPath_initialized, true, "f");
|
|
5456
|
+
return true;
|
|
5457
|
+
}
|
|
5458
|
+
return false;
|
|
5459
|
+
}
|
|
5460
|
+
catch (error) {
|
|
5461
|
+
const errorMessage = error instanceof Error ? error.message : 'An unknown error occurred';
|
|
5462
|
+
throw new Error(`Failed to complete OAuth: ${errorMessage}`);
|
|
5463
|
+
}
|
|
5307
5464
|
}
|
|
5308
5465
|
/**
|
|
5309
|
-
*
|
|
5466
|
+
* Check if the user is authenticated (has valid token)
|
|
5310
5467
|
*/
|
|
5311
|
-
|
|
5312
|
-
return this
|
|
5313
|
-
this.statusCode === HttpStatus.SERVICE_UNAVAILABLE ||
|
|
5314
|
-
this.statusCode === HttpStatus.GATEWAY_TIMEOUT;
|
|
5315
|
-
}
|
|
5316
|
-
}
|
|
5317
|
-
|
|
5318
|
-
/**
|
|
5319
|
-
* Error thrown when network/connection issues occur
|
|
5320
|
-
* Common scenarios:
|
|
5321
|
-
* - Connection timeout
|
|
5322
|
-
* - DNS resolution failure
|
|
5323
|
-
* - Network unreachable
|
|
5324
|
-
* - Request aborted
|
|
5325
|
-
*/
|
|
5326
|
-
class NetworkError extends UiPathError {
|
|
5327
|
-
constructor(params = {}) {
|
|
5328
|
-
super(ErrorType.NETWORK, {
|
|
5329
|
-
message: params.message || ErrorMessages.NETWORK_ERROR,
|
|
5330
|
-
statusCode: params.statusCode, // Network errors typically don't have HTTP status codes
|
|
5331
|
-
requestId: params.requestId
|
|
5332
|
-
});
|
|
5468
|
+
isAuthenticated() {
|
|
5469
|
+
return __classPrivateFieldGet(this, _UiPath_authService, "f").hasValidToken();
|
|
5333
5470
|
}
|
|
5334
|
-
|
|
5335
|
-
|
|
5336
|
-
|
|
5337
|
-
|
|
5338
|
-
|
|
5339
|
-
function isUiPathError(error) {
|
|
5340
|
-
return error instanceof UiPathError;
|
|
5341
|
-
}
|
|
5342
|
-
/**
|
|
5343
|
-
* Type guard to check if an error is an AuthenticationError
|
|
5344
|
-
*/
|
|
5345
|
-
function isAuthenticationError(error) {
|
|
5346
|
-
return error instanceof AuthenticationError;
|
|
5347
|
-
}
|
|
5348
|
-
/**
|
|
5349
|
-
* Type guard to check if an error is an AuthorizationError
|
|
5350
|
-
*/
|
|
5351
|
-
function isAuthorizationError(error) {
|
|
5352
|
-
return error instanceof AuthorizationError;
|
|
5353
|
-
}
|
|
5354
|
-
/**
|
|
5355
|
-
* Type guard to check if an error is a ValidationError
|
|
5356
|
-
*/
|
|
5357
|
-
function isValidationError(error) {
|
|
5358
|
-
return error instanceof ValidationError;
|
|
5359
|
-
}
|
|
5360
|
-
/**
|
|
5361
|
-
* Type guard to check if an error is a NotFoundError
|
|
5362
|
-
*/
|
|
5363
|
-
function isNotFoundError(error) {
|
|
5364
|
-
return error instanceof NotFoundError;
|
|
5365
|
-
}
|
|
5366
|
-
/**
|
|
5367
|
-
* Type guard to check if an error is a RateLimitError
|
|
5368
|
-
*/
|
|
5369
|
-
function isRateLimitError(error) {
|
|
5370
|
-
return error instanceof RateLimitError;
|
|
5371
|
-
}
|
|
5372
|
-
/**
|
|
5373
|
-
* Type guard to check if an error is a ServerError
|
|
5374
|
-
*/
|
|
5375
|
-
function isServerError(error) {
|
|
5376
|
-
return error instanceof ServerError;
|
|
5377
|
-
}
|
|
5378
|
-
/**
|
|
5379
|
-
* Type guard to check if an error is a NetworkError
|
|
5380
|
-
*/
|
|
5381
|
-
function isNetworkError(error) {
|
|
5382
|
-
return error instanceof NetworkError;
|
|
5383
|
-
}
|
|
5384
|
-
/**
|
|
5385
|
-
* Helper to get error details in a safe way
|
|
5386
|
-
*/
|
|
5387
|
-
function getErrorDetails(error) {
|
|
5388
|
-
if (isUiPathError(error)) {
|
|
5389
|
-
return {
|
|
5390
|
-
message: error.message,
|
|
5391
|
-
statusCode: error.statusCode
|
|
5392
|
-
};
|
|
5471
|
+
/**
|
|
5472
|
+
* Get the current authentication token
|
|
5473
|
+
*/
|
|
5474
|
+
getToken() {
|
|
5475
|
+
return __classPrivateFieldGet(this, _UiPath_authService, "f").getToken();
|
|
5393
5476
|
}
|
|
5394
|
-
|
|
5395
|
-
|
|
5396
|
-
|
|
5397
|
-
|
|
5477
|
+
/**
|
|
5478
|
+
* Logout from the SDK, clearing all authentication state.
|
|
5479
|
+
* After calling this method, the user will need to re-initialize to authenticate again.
|
|
5480
|
+
*/
|
|
5481
|
+
logout() {
|
|
5482
|
+
// Secret-based auth has no session to end — skip silently
|
|
5483
|
+
if (hasSecretConfig(__classPrivateFieldGet(this, _UiPath_config, "f"))) {
|
|
5484
|
+
return;
|
|
5485
|
+
}
|
|
5486
|
+
__classPrivateFieldGet(this, _UiPath_authService, "f").logout();
|
|
5487
|
+
__classPrivateFieldSet(this, _UiPath_initialized, false, "f");
|
|
5398
5488
|
}
|
|
5399
|
-
|
|
5400
|
-
|
|
5401
|
-
};
|
|
5402
|
-
}
|
|
5489
|
+
};
|
|
5490
|
+
_UiPath_config = new WeakMap(), _UiPath_authService = new WeakMap(), _UiPath_initialized = new WeakMap();
|
|
5403
5491
|
|
|
5404
5492
|
/**
|
|
5405
5493
|
* Type guards for error response types
|
|
@@ -5673,29 +5761,7 @@ class ApiClient {
|
|
|
5673
5761
|
* @throws AuthenticationError if no token available or refresh fails
|
|
5674
5762
|
*/
|
|
5675
5763
|
async getValidToken() {
|
|
5676
|
-
|
|
5677
|
-
const tokenInfo = this.executionContext.get('tokenInfo');
|
|
5678
|
-
if (!tokenInfo) {
|
|
5679
|
-
throw new AuthenticationError({ message: 'No authentication token available. Make sure to initialize the SDK first.' });
|
|
5680
|
-
}
|
|
5681
|
-
// For secret-based tokens, they never expire
|
|
5682
|
-
if (tokenInfo.type === 'secret') {
|
|
5683
|
-
return tokenInfo.token;
|
|
5684
|
-
}
|
|
5685
|
-
// If token is not expired, return it
|
|
5686
|
-
if (!this.tokenManager.isTokenExpired(tokenInfo)) {
|
|
5687
|
-
return tokenInfo.token;
|
|
5688
|
-
}
|
|
5689
|
-
try {
|
|
5690
|
-
const newToken = await this.tokenManager.refreshAccessToken();
|
|
5691
|
-
return newToken.access_token;
|
|
5692
|
-
}
|
|
5693
|
-
catch (error) {
|
|
5694
|
-
throw new AuthenticationError({
|
|
5695
|
-
message: `Token refresh failed: ${error.message}. Please re-authenticate.`,
|
|
5696
|
-
statusCode: HttpStatus.UNAUTHORIZED
|
|
5697
|
-
});
|
|
5698
|
-
}
|
|
5764
|
+
return this.tokenManager.getValidToken();
|
|
5699
5765
|
}
|
|
5700
5766
|
async getDefaultHeaders() {
|
|
5701
5767
|
// Get headers from execution context first
|
|
@@ -6380,6 +6446,51 @@ function reverseMap(map) {
|
|
|
6380
6446
|
return acc;
|
|
6381
6447
|
}, {});
|
|
6382
6448
|
}
|
|
6449
|
+
/**
|
|
6450
|
+
* Transforms request data from SDK field names to API field names.
|
|
6451
|
+
*
|
|
6452
|
+
* This is the inverse of `transformData` - while `transformData` converts
|
|
6453
|
+
* API responses to SDK format (API → SDK), this function converts SDK
|
|
6454
|
+
* requests to API format (SDK → API).
|
|
6455
|
+
*
|
|
6456
|
+
* @param data The request data with SDK field names
|
|
6457
|
+
* @param responseMap The response mapping (API → SDK) - will be automatically reversed
|
|
6458
|
+
* @returns A new object with API field names
|
|
6459
|
+
*
|
|
6460
|
+
* @example
|
|
6461
|
+
* ```typescript
|
|
6462
|
+
* // Response map: API field → SDK field
|
|
6463
|
+
* const ProcessMap = { releaseKey: 'processKey', releaseName: 'processName' };
|
|
6464
|
+
*
|
|
6465
|
+
* // SDK request with SDK field names
|
|
6466
|
+
* const sdkRequest = { processKey: 'abc-123', processName: 'MyProcess' };
|
|
6467
|
+
*
|
|
6468
|
+
* // Transform to API format
|
|
6469
|
+
* const apiRequest = transformRequest(sdkRequest, ProcessMap);
|
|
6470
|
+
* // Result: { releaseKey: 'abc-123', releaseName: 'MyProcess' }
|
|
6471
|
+
* ```
|
|
6472
|
+
*
|
|
6473
|
+
* @example
|
|
6474
|
+
* ```typescript
|
|
6475
|
+
* // Conversation example
|
|
6476
|
+
* const ConversationMap = { agentReleaseId: 'agentId' };
|
|
6477
|
+
*
|
|
6478
|
+
* const sdkOptions = { agentId: 123, folderId: 456, label: 'My Chat' };
|
|
6479
|
+
* const apiPayload = transformRequest(sdkOptions, ConversationMap);
|
|
6480
|
+
* // Result: { agentReleaseId: 123, folderId: 456, label: 'My Chat' }
|
|
6481
|
+
* ```
|
|
6482
|
+
*/
|
|
6483
|
+
function transformRequest(data, responseMap) {
|
|
6484
|
+
const result = { ...data };
|
|
6485
|
+
const requestMap = reverseMap(responseMap);
|
|
6486
|
+
for (const [sdkField, apiField] of Object.entries(requestMap)) {
|
|
6487
|
+
if (sdkField in result) {
|
|
6488
|
+
result[apiField] = result[sdkField];
|
|
6489
|
+
delete result[sdkField];
|
|
6490
|
+
}
|
|
6491
|
+
}
|
|
6492
|
+
return result;
|
|
6493
|
+
}
|
|
6383
6494
|
/**
|
|
6384
6495
|
* Transforms an array-based dictionary with separate keys and values arrays
|
|
6385
6496
|
* into a standard JavaScript object/record
|
|
@@ -6637,10 +6748,7 @@ class PaginationHelpers {
|
|
|
6637
6748
|
*/
|
|
6638
6749
|
static async getAll(config, options) {
|
|
6639
6750
|
const optionsWithDefaults = options || {};
|
|
6640
|
-
const { folderId, ...restOptions } = optionsWithDefaults;
|
|
6641
|
-
const cursor = options?.cursor;
|
|
6642
|
-
const pageSize = options?.pageSize;
|
|
6643
|
-
const jumpToPage = options?.jumpToPage;
|
|
6751
|
+
const { folderId, pageSize, cursor, jumpToPage, ...restOptions } = optionsWithDefaults;
|
|
6644
6752
|
// Determine if pagination is requested
|
|
6645
6753
|
const isPaginationRequested = PaginationHelpers.hasPaginationParameters(options || {});
|
|
6646
6754
|
// Process parameters (custom processing if provided, otherwise default)
|
|
@@ -10343,17 +10451,8 @@ class ProcessService extends BaseService {
|
|
|
10343
10451
|
*/
|
|
10344
10452
|
async start(request, folderId, options = {}) {
|
|
10345
10453
|
const headers = createHeaders({ [FOLDER_ID]: folderId });
|
|
10346
|
-
// Transform
|
|
10347
|
-
const apiRequest =
|
|
10348
|
-
// Create a reverse mapping using ProcessMap
|
|
10349
|
-
const reversedPropertiesMap = reverseMap(ProcessMap);
|
|
10350
|
-
// Apply transformations for any client properties found in the request
|
|
10351
|
-
Object.entries(reversedPropertiesMap).forEach(([clientKey, apiKey]) => {
|
|
10352
|
-
if (clientKey in apiRequest) {
|
|
10353
|
-
apiRequest[apiKey] = apiRequest[clientKey];
|
|
10354
|
-
delete apiRequest[clientKey];
|
|
10355
|
-
}
|
|
10356
|
-
});
|
|
10454
|
+
// Transform SDK field names to API field names (e.g., processKey → releaseKey)
|
|
10455
|
+
const apiRequest = transformRequest(request, ProcessMap);
|
|
10357
10456
|
// Create the request object according to API spec
|
|
10358
10457
|
const requestBody = {
|
|
10359
10458
|
startInfo: apiRequest
|
|
@@ -10761,7 +10860,266 @@ exports.JobState = void 0;
|
|
|
10761
10860
|
JobState["Resumed"] = "Resumed";
|
|
10762
10861
|
})(exports.JobState || (exports.JobState = {}));
|
|
10763
10862
|
|
|
10863
|
+
/**
|
|
10864
|
+
* Common Constants for Conversational Agent
|
|
10865
|
+
*/
|
|
10866
|
+
/**
|
|
10867
|
+
* Common field mappings shared across all conversational agent entities.
|
|
10868
|
+
* Maps API response fields to SDK-consistent naming conventions.
|
|
10869
|
+
*/
|
|
10870
|
+
const CommonFieldMap = {
|
|
10871
|
+
createdAt: 'createdTime',
|
|
10872
|
+
updatedAt: 'updatedTime'
|
|
10873
|
+
};
|
|
10874
|
+
|
|
10875
|
+
/**
|
|
10876
|
+
* Constants for Conversational Agent
|
|
10877
|
+
*/
|
|
10878
|
+
/**
|
|
10879
|
+
* Maps API response fields to SDK field names (API → SDK)
|
|
10880
|
+
* Used when transforming API responses for SDK consumers.
|
|
10881
|
+
* For request transformation (SDK → API), use `transformRequest(data, ConversationMap)`.
|
|
10882
|
+
*/
|
|
10883
|
+
const ConversationMap = {
|
|
10884
|
+
...CommonFieldMap,
|
|
10885
|
+
conversationId: 'id',
|
|
10886
|
+
lastActivityAt: 'lastActivityTime',
|
|
10887
|
+
agentReleaseId: 'agentId'
|
|
10888
|
+
};
|
|
10889
|
+
/**
|
|
10890
|
+
* Maps fields for Exchange entity to ensure consistent SDK naming
|
|
10891
|
+
*/
|
|
10892
|
+
const ExchangeMap = {
|
|
10893
|
+
...CommonFieldMap
|
|
10894
|
+
};
|
|
10895
|
+
/**
|
|
10896
|
+
* Maps fields for Message entity to ensure consistent SDK naming
|
|
10897
|
+
*/
|
|
10898
|
+
const MessageMap = {
|
|
10899
|
+
...CommonFieldMap
|
|
10900
|
+
};
|
|
10901
|
+
|
|
10902
|
+
/**
|
|
10903
|
+
* Common types for Conversational Agent
|
|
10904
|
+
* Contains IDs, primitives, and utility types used across conversation types.
|
|
10905
|
+
*/
|
|
10906
|
+
/**
|
|
10907
|
+
* Identifies the origin of a message in the conversation.
|
|
10908
|
+
*/
|
|
10909
|
+
exports.MessageRole = void 0;
|
|
10910
|
+
(function (MessageRole) {
|
|
10911
|
+
MessageRole["System"] = "system";
|
|
10912
|
+
MessageRole["User"] = "user";
|
|
10913
|
+
MessageRole["Assistant"] = "assistant";
|
|
10914
|
+
})(exports.MessageRole || (exports.MessageRole = {}));
|
|
10915
|
+
/**
|
|
10916
|
+
* Identifies the type of an interrupt.
|
|
10917
|
+
*/
|
|
10918
|
+
exports.InterruptType = void 0;
|
|
10919
|
+
(function (InterruptType) {
|
|
10920
|
+
InterruptType["ToolCallConfirmation"] = "uipath_cas_tool_call_confirmation";
|
|
10921
|
+
})(exports.InterruptType || (exports.InterruptType = {}));
|
|
10922
|
+
|
|
10923
|
+
/**
|
|
10924
|
+
* Core data model types for Conversational Agent REST endpoints
|
|
10925
|
+
* Contains: Conversation, Exchange, Message, ContentPart, ToolCall, etc.
|
|
10926
|
+
*/
|
|
10927
|
+
/**
|
|
10928
|
+
* Represents the order in which items should be sorted.
|
|
10929
|
+
*/
|
|
10930
|
+
exports.SortOrder = void 0;
|
|
10931
|
+
(function (SortOrder) {
|
|
10932
|
+
SortOrder["Ascending"] = "ascending";
|
|
10933
|
+
SortOrder["Descending"] = "descending";
|
|
10934
|
+
})(exports.SortOrder || (exports.SortOrder = {}));
|
|
10935
|
+
/**
|
|
10936
|
+
* Feedback rating type.
|
|
10937
|
+
*/
|
|
10938
|
+
exports.FeedbackRating = void 0;
|
|
10939
|
+
(function (FeedbackRating) {
|
|
10940
|
+
FeedbackRating["Positive"] = "positive";
|
|
10941
|
+
FeedbackRating["Negative"] = "negative";
|
|
10942
|
+
})(exports.FeedbackRating || (exports.FeedbackRating = {}));
|
|
10943
|
+
|
|
10944
|
+
/**
|
|
10945
|
+
* Event types for Conversational Agent WebSocket protocol
|
|
10946
|
+
*/
|
|
10947
|
+
/**
|
|
10948
|
+
* Identifies how sensitive the LLM should be when detecting the start or end of speech.
|
|
10949
|
+
*
|
|
10950
|
+
* * UNSPECIFIED - the default is HIGH
|
|
10951
|
+
* * HIGH - Will detect the start/end of speech more often.
|
|
10952
|
+
* * LOW - Will detect the start/end of speech less often.
|
|
10953
|
+
*/
|
|
10954
|
+
exports.InputStreamSpeechSensitivity = void 0;
|
|
10955
|
+
(function (InputStreamSpeechSensitivity) {
|
|
10956
|
+
InputStreamSpeechSensitivity["Unspecified"] = "UNSPECIFIED";
|
|
10957
|
+
InputStreamSpeechSensitivity["High"] = "HIGH";
|
|
10958
|
+
InputStreamSpeechSensitivity["Low"] = "LOW";
|
|
10959
|
+
})(exports.InputStreamSpeechSensitivity || (exports.InputStreamSpeechSensitivity = {}));
|
|
10960
|
+
|
|
10961
|
+
/**
|
|
10962
|
+
* Content Part Stream Types
|
|
10963
|
+
*
|
|
10964
|
+
* Defines the public API for interacting with streaming content parts
|
|
10965
|
+
* within a message. Content parts represent text, audio, images, etc.
|
|
10966
|
+
*/
|
|
10967
|
+
/**
|
|
10968
|
+
* Types of citation processing errors
|
|
10969
|
+
*/
|
|
10970
|
+
exports.CitationErrorType = void 0;
|
|
10971
|
+
(function (CitationErrorType) {
|
|
10972
|
+
CitationErrorType["CitationNotEnded"] = "CitationNotEnded";
|
|
10973
|
+
CitationErrorType["CitationNotStarted"] = "CitationNotStarted";
|
|
10974
|
+
})(exports.CitationErrorType || (exports.CitationErrorType = {}));
|
|
10975
|
+
|
|
10976
|
+
/**
|
|
10977
|
+
* Conversation Service Model
|
|
10978
|
+
*
|
|
10979
|
+
* This interface defines the HTTP CRUD operations for conversations
|
|
10980
|
+
* and real-time WebSocket session management.
|
|
10981
|
+
*/
|
|
10982
|
+
/**
|
|
10983
|
+
* Creates methods for a conversation
|
|
10984
|
+
*
|
|
10985
|
+
* @param conversationData - The conversation data (response from API)
|
|
10986
|
+
* @param service - The conversation service instance
|
|
10987
|
+
* @param sessionMethods - Optional session methods for WebSocket session operations
|
|
10988
|
+
* @param exchangeService - Optional exchange service for scoped exchange methods
|
|
10989
|
+
* @returns Object containing conversation methods
|
|
10990
|
+
*/
|
|
10991
|
+
function createConversationMethods(conversationData, service, sessionMethods, exchangeService) {
|
|
10992
|
+
return {
|
|
10993
|
+
exchanges: {
|
|
10994
|
+
getAll(options) {
|
|
10995
|
+
if (!conversationData.id)
|
|
10996
|
+
throw new Error('Conversation ID is undefined');
|
|
10997
|
+
if (!exchangeService)
|
|
10998
|
+
throw new Error('Exchange methods are not available.');
|
|
10999
|
+
return exchangeService.getAll(conversationData.id, options);
|
|
11000
|
+
},
|
|
11001
|
+
getById(exchangeId, options) {
|
|
11002
|
+
if (!conversationData.id)
|
|
11003
|
+
throw new Error('Conversation ID is undefined');
|
|
11004
|
+
if (!exchangeService)
|
|
11005
|
+
throw new Error('Exchange methods are not available.');
|
|
11006
|
+
return exchangeService.getById(conversationData.id, exchangeId, options);
|
|
11007
|
+
},
|
|
11008
|
+
createFeedback(exchangeId, options) {
|
|
11009
|
+
if (!conversationData.id)
|
|
11010
|
+
throw new Error('Conversation ID is undefined');
|
|
11011
|
+
if (!exchangeService)
|
|
11012
|
+
throw new Error('Exchange methods are not available.');
|
|
11013
|
+
return exchangeService.createFeedback(conversationData.id, exchangeId, options);
|
|
11014
|
+
}
|
|
11015
|
+
},
|
|
11016
|
+
async update(options) {
|
|
11017
|
+
if (!conversationData.id)
|
|
11018
|
+
throw new Error('Conversation ID is undefined');
|
|
11019
|
+
return service.updateById(conversationData.id, options);
|
|
11020
|
+
},
|
|
11021
|
+
async delete() {
|
|
11022
|
+
if (!conversationData.id)
|
|
11023
|
+
throw new Error('Conversation ID is undefined');
|
|
11024
|
+
return service.deleteById(conversationData.id);
|
|
11025
|
+
},
|
|
11026
|
+
startSession(options) {
|
|
11027
|
+
if (!conversationData.id)
|
|
11028
|
+
throw new Error('Conversation ID is undefined');
|
|
11029
|
+
if (!sessionMethods) {
|
|
11030
|
+
throw new Error('Session methods are not available. Use ConversationService to create conversations with session support.');
|
|
11031
|
+
}
|
|
11032
|
+
return sessionMethods.startSession(conversationData.id, options);
|
|
11033
|
+
},
|
|
11034
|
+
getSession() {
|
|
11035
|
+
if (!conversationData.id)
|
|
11036
|
+
throw new Error('Conversation ID is undefined');
|
|
11037
|
+
if (!sessionMethods) {
|
|
11038
|
+
throw new Error('Session methods are not available. Use ConversationService to create conversations with session support.');
|
|
11039
|
+
}
|
|
11040
|
+
return sessionMethods.getSession(conversationData.id);
|
|
11041
|
+
},
|
|
11042
|
+
endSession() {
|
|
11043
|
+
if (!conversationData.id)
|
|
11044
|
+
throw new Error('Conversation ID is undefined');
|
|
11045
|
+
if (!sessionMethods) {
|
|
11046
|
+
throw new Error('Session methods are not available. Use ConversationService to create conversations with session support.');
|
|
11047
|
+
}
|
|
11048
|
+
sessionMethods.endSession(conversationData.id);
|
|
11049
|
+
},
|
|
11050
|
+
async uploadAttachment(file) {
|
|
11051
|
+
if (!conversationData.id)
|
|
11052
|
+
throw new Error('Conversation ID is undefined');
|
|
11053
|
+
return service.uploadAttachment(conversationData.id, file);
|
|
11054
|
+
}
|
|
11055
|
+
};
|
|
11056
|
+
}
|
|
11057
|
+
/**
|
|
11058
|
+
* Creates an actionable conversation by combining API conversation data with operational methods.
|
|
11059
|
+
*
|
|
11060
|
+
* @param conversationData - The conversation data from API
|
|
11061
|
+
* @param service - The conversation service instance
|
|
11062
|
+
* @param sessionMethods - Optional session methods for WebSocket session operations
|
|
11063
|
+
* @param exchangeService - Optional exchange service for scoped exchange methods
|
|
11064
|
+
* @returns A conversation object with added methods
|
|
11065
|
+
*/
|
|
11066
|
+
function createConversationWithMethods(conversationData, service, sessionMethods, exchangeService) {
|
|
11067
|
+
const methods = createConversationMethods(conversationData, service, sessionMethods, exchangeService);
|
|
11068
|
+
return Object.assign({}, conversationData, methods);
|
|
11069
|
+
}
|
|
11070
|
+
|
|
11071
|
+
/**
|
|
11072
|
+
* Agent Service Models
|
|
11073
|
+
*
|
|
11074
|
+
* Provides fluent API for agent objects returned from getAll() and getById().
|
|
11075
|
+
*/
|
|
11076
|
+
/**
|
|
11077
|
+
* Creates methods for an agent
|
|
11078
|
+
*
|
|
11079
|
+
* @param agentData - The agent data from API
|
|
11080
|
+
* @param conversationService - The conversation service instance for delegation
|
|
11081
|
+
* @returns Object containing agent methods
|
|
11082
|
+
*/
|
|
11083
|
+
function createAgentMethods(agentData, conversationService) {
|
|
11084
|
+
const agentConversations = {
|
|
11085
|
+
async create(options = {}) {
|
|
11086
|
+
return conversationService.create(agentData.id, agentData.folderId, options);
|
|
11087
|
+
}
|
|
11088
|
+
};
|
|
11089
|
+
return {
|
|
11090
|
+
conversations: agentConversations,
|
|
11091
|
+
get connectionStatus() { return conversationService.connectionStatus; },
|
|
11092
|
+
get isConnected() { return conversationService.isConnected; },
|
|
11093
|
+
get connectionError() { return conversationService.connectionError; }
|
|
11094
|
+
};
|
|
11095
|
+
}
|
|
11096
|
+
function createAgentWithMethods(agentData, conversationService) {
|
|
11097
|
+
const methods = createAgentMethods(agentData, conversationService);
|
|
11098
|
+
return Object.defineProperties(Object.assign({}, agentData), Object.getOwnPropertyDescriptors(methods));
|
|
11099
|
+
}
|
|
11100
|
+
|
|
11101
|
+
/**
|
|
11102
|
+
* Constants for Agent Service
|
|
11103
|
+
*/
|
|
11104
|
+
/**
|
|
11105
|
+
* Maps fields for Agent entities to ensure consistent SDK naming
|
|
11106
|
+
*/
|
|
11107
|
+
const AgentMap = {
|
|
11108
|
+
...CommonFieldMap
|
|
11109
|
+
};
|
|
11110
|
+
|
|
11111
|
+
/**
|
|
11112
|
+
* Constants for User Service
|
|
11113
|
+
*/
|
|
11114
|
+
/**
|
|
11115
|
+
* Maps fields for User Settings entities to ensure consistent SDK naming
|
|
11116
|
+
*/
|
|
11117
|
+
const UserSettingsMap = {
|
|
11118
|
+
...CommonFieldMap
|
|
11119
|
+
};
|
|
11120
|
+
|
|
10764
11121
|
exports.APP_NAME = APP_NAME;
|
|
11122
|
+
exports.AgentMap = AgentMap;
|
|
10765
11123
|
exports.AuthenticationError = AuthenticationError;
|
|
10766
11124
|
exports.AuthorizationError = AuthorizationError;
|
|
10767
11125
|
exports.CLOUD_CLIENT_ID = CLOUD_CLIENT_ID;
|
|
@@ -10771,12 +11129,15 @@ exports.CLOUD_ROLE_NAME = CLOUD_ROLE_NAME;
|
|
|
10771
11129
|
exports.CLOUD_TENANT_NAME = CLOUD_TENANT_NAME;
|
|
10772
11130
|
exports.CLOUD_URL = CLOUD_URL;
|
|
10773
11131
|
exports.CONNECTION_STRING = CONNECTION_STRING;
|
|
11132
|
+
exports.ConversationMap = ConversationMap;
|
|
10774
11133
|
exports.DEFAULT_ITEMS_FIELD = DEFAULT_ITEMS_FIELD;
|
|
10775
11134
|
exports.DEFAULT_PAGE_SIZE = DEFAULT_PAGE_SIZE;
|
|
10776
11135
|
exports.DEFAULT_TOTAL_COUNT_FIELD = DEFAULT_TOTAL_COUNT_FIELD;
|
|
10777
11136
|
exports.ErrorType = ErrorType;
|
|
11137
|
+
exports.ExchangeMap = ExchangeMap;
|
|
10778
11138
|
exports.HttpStatus = HttpStatus;
|
|
10779
11139
|
exports.MAX_PAGE_SIZE = MAX_PAGE_SIZE;
|
|
11140
|
+
exports.MessageMap = MessageMap;
|
|
10780
11141
|
exports.NetworkError = NetworkError;
|
|
10781
11142
|
exports.NotFoundError = NotFoundError;
|
|
10782
11143
|
exports.RateLimitError = RateLimitError;
|
|
@@ -10789,9 +11150,12 @@ exports.ServerError = ServerError;
|
|
|
10789
11150
|
exports.UNKNOWN = UNKNOWN$1;
|
|
10790
11151
|
exports.UiPath = UiPath;
|
|
10791
11152
|
exports.UiPathError = UiPathError;
|
|
11153
|
+
exports.UserSettingsMap = UserSettingsMap;
|
|
10792
11154
|
exports.VERSION = VERSION;
|
|
10793
11155
|
exports.ValidationError = ValidationError;
|
|
11156
|
+
exports.createAgentWithMethods = createAgentWithMethods;
|
|
10794
11157
|
exports.createCaseInstanceWithMethods = createCaseInstanceWithMethods;
|
|
11158
|
+
exports.createConversationWithMethods = createConversationWithMethods;
|
|
10795
11159
|
exports.createEntityWithMethods = createEntityWithMethods;
|
|
10796
11160
|
exports.createProcessInstanceWithMethods = createProcessInstanceWithMethods;
|
|
10797
11161
|
exports.createProcessWithMethods = createProcessWithMethods;
|