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