@edgible-team/cli 1.0.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 +136 -0
- package/README.md +450 -0
- package/dist/client/api-client.js +1057 -0
- package/dist/client/index.js +21 -0
- package/dist/commands/agent.js +1280 -0
- package/dist/commands/ai.js +608 -0
- package/dist/commands/application.js +885 -0
- package/dist/commands/auth.js +570 -0
- package/dist/commands/base/BaseCommand.js +93 -0
- package/dist/commands/base/CommandHandler.js +7 -0
- package/dist/commands/base/command-wrapper.js +58 -0
- package/dist/commands/base/middleware.js +77 -0
- package/dist/commands/config.js +116 -0
- package/dist/commands/connectivity.js +59 -0
- package/dist/commands/debug.js +98 -0
- package/dist/commands/discover.js +144 -0
- package/dist/commands/examples/migrated-command-example.js +180 -0
- package/dist/commands/gateway.js +494 -0
- package/dist/commands/managedGateway.js +787 -0
- package/dist/commands/utils/config-validator.js +76 -0
- package/dist/commands/utils/gateway-prompt.js +79 -0
- package/dist/commands/utils/input-parser.js +120 -0
- package/dist/commands/utils/output-formatter.js +109 -0
- package/dist/config/app-config.js +99 -0
- package/dist/detection/SystemCapabilityDetector.js +1244 -0
- package/dist/detection/ToolDetector.js +305 -0
- package/dist/detection/WorkloadDetector.js +314 -0
- package/dist/di/bindings.js +99 -0
- package/dist/di/container.js +88 -0
- package/dist/di/types.js +32 -0
- package/dist/index.js +52 -0
- package/dist/interfaces/IDaemonManager.js +3 -0
- package/dist/repositories/config-repository.js +62 -0
- package/dist/repositories/gateway-repository.js +35 -0
- package/dist/scripts/postinstall.js +101 -0
- package/dist/services/AgentStatusManager.js +299 -0
- package/dist/services/ConnectivityTester.js +271 -0
- package/dist/services/DependencyInstaller.js +475 -0
- package/dist/services/LocalAgentManager.js +2216 -0
- package/dist/services/application/ApplicationService.js +299 -0
- package/dist/services/auth/AuthService.js +214 -0
- package/dist/services/aws.js +644 -0
- package/dist/services/daemon/DaemonManagerFactory.js +65 -0
- package/dist/services/daemon/DockerDaemonManager.js +395 -0
- package/dist/services/daemon/LaunchdDaemonManager.js +257 -0
- package/dist/services/daemon/PodmanDaemonManager.js +369 -0
- package/dist/services/daemon/SystemdDaemonManager.js +221 -0
- package/dist/services/daemon/WindowsServiceDaemonManager.js +210 -0
- package/dist/services/daemon/index.js +16 -0
- package/dist/services/edgible.js +3060 -0
- package/dist/services/gateway/GatewayService.js +334 -0
- package/dist/state/config.js +146 -0
- package/dist/types/AgentConfig.js +5 -0
- package/dist/types/AgentStatus.js +5 -0
- package/dist/types/ApiClient.js +5 -0
- package/dist/types/ApiRequests.js +5 -0
- package/dist/types/ApiResponses.js +5 -0
- package/dist/types/Application.js +5 -0
- package/dist/types/CaddyJson.js +5 -0
- package/dist/types/UnifiedAgentStatus.js +56 -0
- package/dist/types/WireGuard.js +5 -0
- package/dist/types/Workload.js +5 -0
- package/dist/types/agent.js +5 -0
- package/dist/types/command-options.js +5 -0
- package/dist/types/connectivity.js +5 -0
- package/dist/types/errors.js +250 -0
- package/dist/types/gateway-types.js +5 -0
- package/dist/types/index.js +48 -0
- package/dist/types/models/ApplicationData.js +5 -0
- package/dist/types/models/CertificateData.js +5 -0
- package/dist/types/models/DeviceData.js +5 -0
- package/dist/types/models/DevicePoolData.js +5 -0
- package/dist/types/models/OrganizationData.js +5 -0
- package/dist/types/models/OrganizationInviteData.js +5 -0
- package/dist/types/models/ProviderConfiguration.js +5 -0
- package/dist/types/models/ResourceData.js +5 -0
- package/dist/types/models/ServiceResourceData.js +5 -0
- package/dist/types/models/UserData.js +5 -0
- package/dist/types/route.js +5 -0
- package/dist/types/validation/schemas.js +218 -0
- package/dist/types/validation.js +5 -0
- package/dist/utils/FileIntegrityManager.js +256 -0
- package/dist/utils/PathMigration.js +219 -0
- package/dist/utils/PathResolver.js +235 -0
- package/dist/utils/PlatformDetector.js +277 -0
- package/dist/utils/console-logger.js +130 -0
- package/dist/utils/docker-compose-parser.js +179 -0
- package/dist/utils/errors.js +130 -0
- package/dist/utils/health-checker.js +155 -0
- package/dist/utils/json-logger.js +72 -0
- package/dist/utils/log-formatter.js +293 -0
- package/dist/utils/logger.js +59 -0
- package/dist/utils/network-utils.js +217 -0
- package/dist/utils/output.js +182 -0
- package/dist/utils/passwordValidation.js +91 -0
- package/dist/utils/progress.js +167 -0
- package/dist/utils/sudo-checker.js +22 -0
- package/dist/utils/urls.js +32 -0
- package/dist/utils/validation.js +31 -0
- package/dist/validation/schemas.js +175 -0
- package/dist/validation/validator.js +67 -0
- package/package.json +83 -0
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// AUTO-GENERATED FILE - DO NOT EDIT
|
|
3
|
+
// This file is copied from backend during build. Changes will be overwritten.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.PasswordResetRequiredError = exports.UserNotConfirmedError = exports.PasswordPolicyError = exports.InvalidInputError = exports.ConflictError = exports.RateLimitError = exports.ChallengeRequiredError = exports.TokenError = exports.ServiceError = exports.ValidationError = exports.UserAlreadyExistsError = exports.UserNotFoundError = exports.AuthenticationError = void 0;
|
|
6
|
+
exports.isAuthenticationError = isAuthenticationError;
|
|
7
|
+
exports.isUserNotFoundError = isUserNotFoundError;
|
|
8
|
+
exports.isUserAlreadyExistsError = isUserAlreadyExistsError;
|
|
9
|
+
exports.isValidationError = isValidationError;
|
|
10
|
+
exports.isServiceError = isServiceError;
|
|
11
|
+
exports.isTokenError = isTokenError;
|
|
12
|
+
exports.isChallengeRequiredError = isChallengeRequiredError;
|
|
13
|
+
exports.isRateLimitError = isRateLimitError;
|
|
14
|
+
exports.isConflictError = isConflictError;
|
|
15
|
+
exports.isInvalidInputError = isInvalidInputError;
|
|
16
|
+
exports.isPasswordPolicyError = isPasswordPolicyError;
|
|
17
|
+
exports.isUserNotConfirmedError = isUserNotConfirmedError;
|
|
18
|
+
exports.isPasswordResetRequiredError = isPasswordResetRequiredError;
|
|
19
|
+
exports.mapCognitoError = mapCognitoError;
|
|
20
|
+
/**
|
|
21
|
+
* Generic error types for common operations
|
|
22
|
+
* These provide a consistent interface for error handling across the application
|
|
23
|
+
*/
|
|
24
|
+
class AuthenticationError extends Error {
|
|
25
|
+
constructor(message, code = 'AUTH_ERROR', statusCode = 401) {
|
|
26
|
+
super(message);
|
|
27
|
+
this.name = 'AuthenticationError';
|
|
28
|
+
this.code = code;
|
|
29
|
+
this.statusCode = statusCode;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.AuthenticationError = AuthenticationError;
|
|
33
|
+
class UserNotFoundError extends Error {
|
|
34
|
+
constructor(message = 'User not found', code = 'USER_NOT_FOUND', statusCode = 404) {
|
|
35
|
+
super(message);
|
|
36
|
+
this.name = 'UserNotFoundError';
|
|
37
|
+
this.code = code;
|
|
38
|
+
this.statusCode = statusCode;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.UserNotFoundError = UserNotFoundError;
|
|
42
|
+
class UserAlreadyExistsError extends Error {
|
|
43
|
+
constructor(message = 'User already exists', code = 'USER_EXISTS', statusCode = 409) {
|
|
44
|
+
super(message);
|
|
45
|
+
this.name = 'UserAlreadyExistsError';
|
|
46
|
+
this.code = code;
|
|
47
|
+
this.statusCode = statusCode;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.UserAlreadyExistsError = UserAlreadyExistsError;
|
|
51
|
+
class ValidationError extends Error {
|
|
52
|
+
constructor(message, code = 'VALIDATION_ERROR', statusCode = 400, fieldErrors) {
|
|
53
|
+
super(message);
|
|
54
|
+
this.name = 'ValidationError';
|
|
55
|
+
this.code = code;
|
|
56
|
+
this.statusCode = statusCode;
|
|
57
|
+
if (fieldErrors !== undefined) {
|
|
58
|
+
this.fieldErrors = fieldErrors;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.ValidationError = ValidationError;
|
|
63
|
+
class ServiceError extends Error {
|
|
64
|
+
constructor(message, code = 'SERVICE_ERROR', statusCode = 500) {
|
|
65
|
+
super(message);
|
|
66
|
+
this.name = 'ServiceError';
|
|
67
|
+
this.code = code;
|
|
68
|
+
this.statusCode = statusCode;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
exports.ServiceError = ServiceError;
|
|
72
|
+
class TokenError extends Error {
|
|
73
|
+
constructor(message, code = 'TOKEN_ERROR', statusCode = 401) {
|
|
74
|
+
super(message);
|
|
75
|
+
this.name = 'TokenError';
|
|
76
|
+
this.code = code;
|
|
77
|
+
this.statusCode = statusCode;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
exports.TokenError = TokenError;
|
|
81
|
+
class ChallengeRequiredError extends Error {
|
|
82
|
+
constructor(message, code = 'CHALLENGE_REQUIRED', statusCode = 400) {
|
|
83
|
+
super(message);
|
|
84
|
+
this.name = 'ChallengeRequiredError';
|
|
85
|
+
this.code = code;
|
|
86
|
+
this.statusCode = statusCode;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
exports.ChallengeRequiredError = ChallengeRequiredError;
|
|
90
|
+
class RateLimitError extends Error {
|
|
91
|
+
constructor(message = 'Too many requests', code = 'RATE_LIMIT_EXCEEDED', statusCode = 429) {
|
|
92
|
+
super(message);
|
|
93
|
+
this.name = 'RateLimitError';
|
|
94
|
+
this.code = code;
|
|
95
|
+
this.statusCode = statusCode;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
exports.RateLimitError = RateLimitError;
|
|
99
|
+
class ConflictError extends Error {
|
|
100
|
+
constructor(message, code = 'CONFLICT', statusCode = 409) {
|
|
101
|
+
super(message);
|
|
102
|
+
this.name = 'ConflictError';
|
|
103
|
+
this.code = code;
|
|
104
|
+
this.statusCode = statusCode;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
exports.ConflictError = ConflictError;
|
|
108
|
+
class InvalidInputError extends Error {
|
|
109
|
+
constructor(message, code = 'INVALID_INPUT', statusCode = 400) {
|
|
110
|
+
super(message);
|
|
111
|
+
this.name = 'InvalidInputError';
|
|
112
|
+
this.code = code;
|
|
113
|
+
this.statusCode = statusCode;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
exports.InvalidInputError = InvalidInputError;
|
|
117
|
+
class PasswordPolicyError extends Error {
|
|
118
|
+
constructor(message = 'Password does not meet policy requirements', code = 'PASSWORD_POLICY_VIOLATION', statusCode = 400) {
|
|
119
|
+
super(message);
|
|
120
|
+
this.name = 'PasswordPolicyError';
|
|
121
|
+
this.code = code;
|
|
122
|
+
this.statusCode = statusCode;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
exports.PasswordPolicyError = PasswordPolicyError;
|
|
126
|
+
class UserNotConfirmedError extends Error {
|
|
127
|
+
constructor(message = 'User account not confirmed', code = 'USER_NOT_CONFIRMED', statusCode = 401) {
|
|
128
|
+
super(message);
|
|
129
|
+
this.name = 'UserNotConfirmedError';
|
|
130
|
+
this.code = code;
|
|
131
|
+
this.statusCode = statusCode;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
exports.UserNotConfirmedError = UserNotConfirmedError;
|
|
135
|
+
class PasswordResetRequiredError extends Error {
|
|
136
|
+
constructor(message = 'Password reset required', code = 'PASSWORD_RESET_REQUIRED', statusCode = 401) {
|
|
137
|
+
super(message);
|
|
138
|
+
this.name = 'PasswordResetRequiredError';
|
|
139
|
+
this.code = code;
|
|
140
|
+
this.statusCode = statusCode;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
exports.PasswordResetRequiredError = PasswordResetRequiredError;
|
|
144
|
+
/**
|
|
145
|
+
* Type guard functions to check error types
|
|
146
|
+
*/
|
|
147
|
+
function isAuthenticationError(error) {
|
|
148
|
+
return error instanceof AuthenticationError;
|
|
149
|
+
}
|
|
150
|
+
function isUserNotFoundError(error) {
|
|
151
|
+
return error instanceof UserNotFoundError;
|
|
152
|
+
}
|
|
153
|
+
function isUserAlreadyExistsError(error) {
|
|
154
|
+
return error instanceof UserAlreadyExistsError;
|
|
155
|
+
}
|
|
156
|
+
function isValidationError(error) {
|
|
157
|
+
return error instanceof ValidationError;
|
|
158
|
+
}
|
|
159
|
+
function isServiceError(error) {
|
|
160
|
+
return error instanceof ServiceError;
|
|
161
|
+
}
|
|
162
|
+
function isTokenError(error) {
|
|
163
|
+
return error instanceof TokenError;
|
|
164
|
+
}
|
|
165
|
+
function isChallengeRequiredError(error) {
|
|
166
|
+
return error instanceof ChallengeRequiredError;
|
|
167
|
+
}
|
|
168
|
+
function isRateLimitError(error) {
|
|
169
|
+
return error instanceof RateLimitError;
|
|
170
|
+
}
|
|
171
|
+
function isConflictError(error) {
|
|
172
|
+
return error instanceof ConflictError;
|
|
173
|
+
}
|
|
174
|
+
function isInvalidInputError(error) {
|
|
175
|
+
return error instanceof InvalidInputError;
|
|
176
|
+
}
|
|
177
|
+
function isPasswordPolicyError(error) {
|
|
178
|
+
return error instanceof PasswordPolicyError;
|
|
179
|
+
}
|
|
180
|
+
function isUserNotConfirmedError(error) {
|
|
181
|
+
return error instanceof UserNotConfirmedError;
|
|
182
|
+
}
|
|
183
|
+
function isPasswordResetRequiredError(error) {
|
|
184
|
+
return error instanceof PasswordResetRequiredError;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Maps AWS Cognito errors to generic error types
|
|
188
|
+
* This provides a consistent error handling interface across the application
|
|
189
|
+
*/
|
|
190
|
+
function mapCognitoError(error) {
|
|
191
|
+
// Check if it's an AWS SDK error with a name property
|
|
192
|
+
console.log('error', error);
|
|
193
|
+
if (error && typeof error === 'object' && error.name) {
|
|
194
|
+
switch (error.name) {
|
|
195
|
+
case 'AliasExistsException':
|
|
196
|
+
return new ConflictError('Email or phone number already associated with another account', 'ALIAS_EXISTS');
|
|
197
|
+
case 'CodeMismatchException':
|
|
198
|
+
return new InvalidInputError('Invalid verification code provided', 'CODE_MISMATCH');
|
|
199
|
+
case 'ExpiredCodeException':
|
|
200
|
+
return new InvalidInputError('Verification code has expired', 'CODE_EXPIRED');
|
|
201
|
+
case 'InternalErrorException':
|
|
202
|
+
return new ServiceError('Internal service error occurred', 'INTERNAL_ERROR');
|
|
203
|
+
case 'InvalidParameterException':
|
|
204
|
+
return new ValidationError('Invalid parameter provided', 'INVALID_PARAMETER');
|
|
205
|
+
case 'InvalidPasswordException':
|
|
206
|
+
return new PasswordPolicyError(error.message || 'Password does not meet policy requirements');
|
|
207
|
+
case 'NotAuthorizedException':
|
|
208
|
+
return new AuthenticationError('Not authorized to perform this action', 'NOT_AUTHORIZED');
|
|
209
|
+
case 'PasswordResetRequiredException':
|
|
210
|
+
return new PasswordResetRequiredError();
|
|
211
|
+
case 'ResourceNotFoundException':
|
|
212
|
+
return new UserNotFoundError('User not found');
|
|
213
|
+
case 'TooManyRequestsException':
|
|
214
|
+
return new RateLimitError('Too many requests, please try again later');
|
|
215
|
+
case 'LimitExceededException':
|
|
216
|
+
return new RateLimitError('Request limit exceeded, please try again later');
|
|
217
|
+
case 'UserNotConfirmedException':
|
|
218
|
+
return new UserNotConfirmedError();
|
|
219
|
+
case 'UserNotFoundException':
|
|
220
|
+
return new UserNotFoundError();
|
|
221
|
+
case 'UsernameExistsException':
|
|
222
|
+
return new UserAlreadyExistsError('Username already exists');
|
|
223
|
+
case 'InvalidUserPoolConfigurationException':
|
|
224
|
+
return new ServiceError('Invalid user pool configuration', 'INVALID_CONFIG');
|
|
225
|
+
case 'LimitExceededException':
|
|
226
|
+
return new RateLimitError('Request limit exceeded, please try again later');
|
|
227
|
+
case 'ConcurrentModificationException':
|
|
228
|
+
return new ConflictError('Concurrent modification detected, please retry', 'CONCURRENT_MODIFICATION');
|
|
229
|
+
case 'InvalidLambdaResponseException':
|
|
230
|
+
return new ServiceError('Invalid Lambda response', 'INVALID_LAMBDA_RESPONSE');
|
|
231
|
+
case 'MFAMethodNotFoundException':
|
|
232
|
+
return new ValidationError('MFA method not found', 'MFA_METHOD_NOT_FOUND');
|
|
233
|
+
case 'SoftwareTokenMFANotFoundException':
|
|
234
|
+
return new ValidationError('Software token MFA not found', 'SOFTWARE_TOKEN_MFA_NOT_FOUND');
|
|
235
|
+
case 'InvalidMFAOptionsException':
|
|
236
|
+
return new ValidationError('Invalid MFA options', 'INVALID_MFA_OPTIONS');
|
|
237
|
+
case 'PasswordResetRequiredException':
|
|
238
|
+
return new PasswordResetRequiredError();
|
|
239
|
+
default:
|
|
240
|
+
// For unknown Cognito errors, wrap them as ServiceError
|
|
241
|
+
return new ServiceError(error.message || 'Unknown Cognito error occurred', error.name || 'UNKNOWN_COGNITO_ERROR');
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
// If it's not a Cognito error, return as-is or wrap as ServiceError
|
|
245
|
+
if (error instanceof Error) {
|
|
246
|
+
return error;
|
|
247
|
+
}
|
|
248
|
+
return new ServiceError(typeof error === 'string' ? error : 'Unknown error occurred', 'UNKNOWN_ERROR');
|
|
249
|
+
}
|
|
250
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// AUTO-GENERATED FILE - DO NOT EDIT
|
|
3
|
+
// This file is copied from backend during build. Changes will be overwritten.
|
|
4
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
5
|
+
if (k2 === undefined) k2 = k;
|
|
6
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
7
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
8
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
9
|
+
}
|
|
10
|
+
Object.defineProperty(o, k2, desc);
|
|
11
|
+
}) : (function(o, m, k, k2) {
|
|
12
|
+
if (k2 === undefined) k2 = k;
|
|
13
|
+
o[k2] = m[k];
|
|
14
|
+
}));
|
|
15
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
16
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
17
|
+
};
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
// Re-export all types from the types folder for easy importing
|
|
20
|
+
// API Client types
|
|
21
|
+
__exportStar(require("./ApiClient"), exports);
|
|
22
|
+
// API Request types
|
|
23
|
+
__exportStar(require("./ApiRequests"), exports);
|
|
24
|
+
// API Response types
|
|
25
|
+
__exportStar(require("./ApiResponses"), exports);
|
|
26
|
+
// Error types and utilities
|
|
27
|
+
__exportStar(require("./errors"), exports);
|
|
28
|
+
// Route handler types
|
|
29
|
+
__exportStar(require("./route"), exports);
|
|
30
|
+
// Agent Configuration types
|
|
31
|
+
__exportStar(require("./AgentConfig"), exports);
|
|
32
|
+
// Caddy Configuration types
|
|
33
|
+
__exportStar(require("./CaddyJson"), exports);
|
|
34
|
+
// Model types
|
|
35
|
+
__exportStar(require("./models/ApplicationData"), exports);
|
|
36
|
+
__exportStar(require("./models/CertificateData"), exports);
|
|
37
|
+
__exportStar(require("./models/DeviceData"), exports);
|
|
38
|
+
__exportStar(require("./models/DevicePoolData"), exports);
|
|
39
|
+
__exportStar(require("./models/OrganizationData"), exports);
|
|
40
|
+
__exportStar(require("./models/OrganizationInviteData"), exports);
|
|
41
|
+
__exportStar(require("./models/ResourceData"), exports);
|
|
42
|
+
__exportStar(require("./models/ServiceResourceData"), exports);
|
|
43
|
+
__exportStar(require("./models/UserData"), exports);
|
|
44
|
+
// New connectivity and validation types
|
|
45
|
+
__exportStar(require("./connectivity"), exports);
|
|
46
|
+
__exportStar(require("./agent"), exports);
|
|
47
|
+
__exportStar(require("./validation"), exports);
|
|
48
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// AUTO-GENERATED FILE - DO NOT EDIT
|
|
3
|
+
// This file is copied from backend during build. Changes will be overwritten.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.GetResourceSchema = exports.UpdateResourceSchema = exports.CreateResourceSchema = exports.CreateDeviceWithOrphanedOrganizationSchema = exports.GetChallengeSessionSchema = exports.ForceChangePasswordSchema = exports.RefreshTokenSchema = exports.AuthenticateSchema = exports.LinkOrganizationSchema = exports.UpdateResourceLimitsSchema = exports.CreateBillingOrganizationSchema = exports.AdoptOrganizationSchema = exports.CancelInviteSchema = exports.DeclineInviteSchema = exports.AcceptInviteSchema = exports.CreateOrganizationInviteSchema = exports.GetDeviceSchema = exports.UpdateDeviceSchema = exports.CreateDeviceSchema = exports.RefreshCertificatePathSchema = exports.GetCertificatePathSchema = exports.GetCertificatesPathSchema = exports.GetApplicationSchema = exports.UpdateApplicationSchema = exports.CreateApplicationSchema = exports.GetUserSchema = exports.UpdateUserSchema = exports.CreateUserSchema = exports.GetOrganizationSchema = exports.UpdateOrganizationSchema = exports.CreateOrganizationSchema = void 0;
|
|
6
|
+
const zod_1 = require("zod");
|
|
7
|
+
// Organization validation schemas
|
|
8
|
+
exports.CreateOrganizationSchema = zod_1.z.object({
|
|
9
|
+
name: zod_1.z.string().min(1, 'Name is required').max(100, 'Name must be 100 characters or less'),
|
|
10
|
+
rootUserEmail: zod_1.z.string().email('Invalid email format'),
|
|
11
|
+
description: zod_1.z.string().max(500, 'Description must be 500 characters or less').optional(),
|
|
12
|
+
billingOrganizationId: zod_1.z.string().min(1, 'Billing organization ID must be provided if specified').optional(),
|
|
13
|
+
});
|
|
14
|
+
exports.UpdateOrganizationSchema = zod_1.z.object({
|
|
15
|
+
name: zod_1.z.string().min(1).max(100).optional(),
|
|
16
|
+
description: zod_1.z.string().max(500).optional(),
|
|
17
|
+
});
|
|
18
|
+
exports.GetOrganizationSchema = zod_1.z.object({
|
|
19
|
+
organizationId: zod_1.z.string().min(1, 'Organization ID is required'),
|
|
20
|
+
});
|
|
21
|
+
// User validation schemas
|
|
22
|
+
exports.CreateUserSchema = zod_1.z.object({
|
|
23
|
+
email: zod_1.z.string().email('Invalid email format'),
|
|
24
|
+
firstName: zod_1.z.string().max(100).optional(),
|
|
25
|
+
lastName: zod_1.z.string().max(100).optional(),
|
|
26
|
+
mobile: zod_1.z.string().max(20).optional(),
|
|
27
|
+
});
|
|
28
|
+
exports.UpdateUserSchema = zod_1.z.object({
|
|
29
|
+
email: zod_1.z.string().email().optional(),
|
|
30
|
+
firstName: zod_1.z.string().max(100).optional(),
|
|
31
|
+
lastName: zod_1.z.string().max(100).optional(),
|
|
32
|
+
organizations: zod_1.z.array(zod_1.z.string()).optional(),
|
|
33
|
+
});
|
|
34
|
+
exports.GetUserSchema = zod_1.z.object({
|
|
35
|
+
email: zod_1.z.string().email('Invalid email format'),
|
|
36
|
+
});
|
|
37
|
+
// Application validation schemas
|
|
38
|
+
exports.CreateApplicationSchema = zod_1.z.object({
|
|
39
|
+
name: zod_1.z.string().min(1, 'Name is required').max(100, 'Name must be 100 characters or less'),
|
|
40
|
+
description: zod_1.z.string().max(500).optional(),
|
|
41
|
+
organizationId: zod_1.z.string().min(1, 'Organization ID is required'),
|
|
42
|
+
environment: zod_1.z.enum(['development', 'staging', 'production']).default('development'),
|
|
43
|
+
configuration: zod_1.z.object({
|
|
44
|
+
port: zod_1.z.number().int().min(1).max(65535, 'Port must be between 1 and 65535'),
|
|
45
|
+
protocol: zod_1.z.enum(['http', 'https', 'tcp', 'udp']),
|
|
46
|
+
}),
|
|
47
|
+
hostnames: zod_1.z
|
|
48
|
+
.array(zod_1.z
|
|
49
|
+
.string()
|
|
50
|
+
.regex(/^(?=.{1,253}$)(?!-)[A-Za-z0-9-]{1,63}(?<!-)(\.(?!-)[A-Za-z0-9-]{1,63}(?<!-))*\.?$/, 'Invalid hostname'))
|
|
51
|
+
.optional(),
|
|
52
|
+
deviceIds: zod_1.z.array(zod_1.z.string().min(1)).min(1, 'At least one device ID is required'),
|
|
53
|
+
gatewayIds: zod_1.z.array(zod_1.z.string().min(1)).optional(),
|
|
54
|
+
useManagedGateway: zod_1.z.boolean().optional(),
|
|
55
|
+
subtype: zod_1.z.enum(['local-preexisting', 'managed-docker', 'systemd', 'docker-compose']),
|
|
56
|
+
});
|
|
57
|
+
exports.UpdateApplicationSchema = zod_1.z.object({
|
|
58
|
+
name: zod_1.z.string().min(1).max(100).optional(),
|
|
59
|
+
description: zod_1.z.string().max(500).optional(),
|
|
60
|
+
environment: zod_1.z.enum(['development', 'staging', 'production']).optional(),
|
|
61
|
+
});
|
|
62
|
+
exports.GetApplicationSchema = zod_1.z.object({
|
|
63
|
+
applicationId: zod_1.z.string().min(1, 'Application ID is required'),
|
|
64
|
+
});
|
|
65
|
+
// Certificate validation schemas
|
|
66
|
+
exports.GetCertificatesPathSchema = zod_1.z.object({
|
|
67
|
+
applicationId: zod_1.z.string().min(1, 'Application ID is required'),
|
|
68
|
+
});
|
|
69
|
+
exports.GetCertificatePathSchema = zod_1.z.object({
|
|
70
|
+
applicationId: zod_1.z.string().min(1, 'Application ID is required'),
|
|
71
|
+
hostname: zod_1.z.string().min(1, 'Hostname is required'),
|
|
72
|
+
});
|
|
73
|
+
exports.RefreshCertificatePathSchema = zod_1.z.object({
|
|
74
|
+
applicationId: zod_1.z.string().min(1, 'Application ID is required'),
|
|
75
|
+
certificateId: zod_1.z.string().min(1, 'Certificate ID is required'),
|
|
76
|
+
});
|
|
77
|
+
// Device validation schemas
|
|
78
|
+
exports.CreateDeviceSchema = zod_1.z.object({
|
|
79
|
+
name: zod_1.z.string().min(1, 'Name is required').max(100, 'Name must be 100 characters or less'),
|
|
80
|
+
type: zod_1.z.enum(['laptop', 'desktop', 'mobile', 'tablet', 'server', 'gateway']).optional(),
|
|
81
|
+
deviceId: zod_1.z.string().optional(),
|
|
82
|
+
os: zod_1.z.string().max(100).optional(),
|
|
83
|
+
browser: zod_1.z.string().max(100).optional(),
|
|
84
|
+
description: zod_1.z.string().max(500).optional(),
|
|
85
|
+
organizationId: zod_1.z.string().min(1, 'Organization ID is required'),
|
|
86
|
+
userEmail: zod_1.z.string().email('Invalid email format'),
|
|
87
|
+
ipAddress: zod_1.z.string().regex(/^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$/).optional(),
|
|
88
|
+
location: zod_1.z.string().max(200).optional(),
|
|
89
|
+
isTrusted: zod_1.z.boolean().optional(),
|
|
90
|
+
privateKey: zod_1.z.string().optional(),
|
|
91
|
+
publicKey: zod_1.z.string().optional(),
|
|
92
|
+
});
|
|
93
|
+
exports.UpdateDeviceSchema = zod_1.z.object({
|
|
94
|
+
name: zod_1.z.string().min(1).max(100).optional(),
|
|
95
|
+
description: zod_1.z.string().max(500).optional(),
|
|
96
|
+
type: zod_1.z.enum(['laptop', 'desktop', 'mobile', 'tablet', 'server', 'gateway']).optional(),
|
|
97
|
+
os: zod_1.z.string().max(100).optional(),
|
|
98
|
+
browser: zod_1.z.string().max(100).optional(),
|
|
99
|
+
location: zod_1.z.string().max(200).optional(),
|
|
100
|
+
status: zod_1.z.enum(['active', 'inactive', 'pending', 'suspended']).optional(),
|
|
101
|
+
isTrusted: zod_1.z.boolean().optional(),
|
|
102
|
+
ipAddress: zod_1.z.string().regex(/^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$/).optional(),
|
|
103
|
+
});
|
|
104
|
+
exports.GetDeviceSchema = zod_1.z.object({
|
|
105
|
+
deviceId: zod_1.z.string().min(1, 'Device ID is required'),
|
|
106
|
+
});
|
|
107
|
+
// Organization Invite validation schemas
|
|
108
|
+
exports.CreateOrganizationInviteSchema = zod_1.z.object({
|
|
109
|
+
organizationId: zod_1.z.string().min(1, 'Organization ID is required'),
|
|
110
|
+
inviteeEmail: zod_1.z.string().email('Invalid email format'),
|
|
111
|
+
permission: zod_1.z.enum(['OWNER', 'EDITOR', 'READ_ONLY']),
|
|
112
|
+
message: zod_1.z.string().max(1000).optional(),
|
|
113
|
+
});
|
|
114
|
+
exports.AcceptInviteSchema = zod_1.z.object({
|
|
115
|
+
inviteId: zod_1.z.string().min(1, 'Invite ID is required'),
|
|
116
|
+
});
|
|
117
|
+
exports.DeclineInviteSchema = zod_1.z.object({
|
|
118
|
+
inviteId: zod_1.z.string().min(1, 'Invite ID is required'),
|
|
119
|
+
});
|
|
120
|
+
exports.CancelInviteSchema = zod_1.z.object({
|
|
121
|
+
inviteId: zod_1.z.string().min(1, 'Invite ID is required'),
|
|
122
|
+
});
|
|
123
|
+
exports.AdoptOrganizationSchema = zod_1.z.object({
|
|
124
|
+
organizationId: zod_1.z.string().min(1, 'Organization ID is required'),
|
|
125
|
+
newOwnerEmail: zod_1.z.string().email('Invalid email format'),
|
|
126
|
+
});
|
|
127
|
+
// Billing Organization validation schemas
|
|
128
|
+
exports.CreateBillingOrganizationSchema = zod_1.z.object({
|
|
129
|
+
name: zod_1.z.string().min(1, 'Name is required').max(100, 'Name must be 100 characters or less').optional(),
|
|
130
|
+
rootUserEmail: zod_1.z.string().email('Invalid email format').optional(),
|
|
131
|
+
description: zod_1.z.string().max(500, 'Description must be 500 characters or less').optional(),
|
|
132
|
+
});
|
|
133
|
+
exports.UpdateResourceLimitsSchema = zod_1.z.object({
|
|
134
|
+
maxOrganizations: zod_1.z.number().int().min(0).optional(),
|
|
135
|
+
maxDataUsageGB: zod_1.z.number().int().min(0).optional(),
|
|
136
|
+
maxDeviceCredits: zod_1.z.number().int().min(0).optional(),
|
|
137
|
+
maxUsers: zod_1.z.number().int().min(0).optional(),
|
|
138
|
+
});
|
|
139
|
+
exports.LinkOrganizationSchema = zod_1.z.object({
|
|
140
|
+
childOrganizationId: zod_1.z.string().min(1, 'Child organization ID is required'),
|
|
141
|
+
});
|
|
142
|
+
// Authentication validation schemas
|
|
143
|
+
exports.AuthenticateSchema = zod_1.z.object({
|
|
144
|
+
email: zod_1.z.string().refine((val) => {
|
|
145
|
+
// Allow valid emails
|
|
146
|
+
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
147
|
+
if (emailRegex.test(val)) {
|
|
148
|
+
return true;
|
|
149
|
+
}
|
|
150
|
+
// Allow device IDs that start with "device_"
|
|
151
|
+
if (val.startsWith('device_')) {
|
|
152
|
+
return true;
|
|
153
|
+
}
|
|
154
|
+
return false;
|
|
155
|
+
}, {
|
|
156
|
+
message: 'Invalid email format or device ID. Email must be a valid format or device ID must start with "device_"',
|
|
157
|
+
}),
|
|
158
|
+
password: zod_1.z.string().min(1, 'Password is required'),
|
|
159
|
+
});
|
|
160
|
+
exports.RefreshTokenSchema = zod_1.z.object({
|
|
161
|
+
refreshToken: zod_1.z.string().min(1, 'Refresh token is required'),
|
|
162
|
+
});
|
|
163
|
+
exports.ForceChangePasswordSchema = zod_1.z.object({
|
|
164
|
+
email: zod_1.z.string().email('Invalid email format'),
|
|
165
|
+
newPassword: zod_1.z.string()
|
|
166
|
+
.min(8, 'Password must be at least 8 characters')
|
|
167
|
+
.regex(/[A-Z]/, 'Password must contain at least one uppercase letter')
|
|
168
|
+
.regex(/[a-z]/, 'Password must contain at least one lowercase letter')
|
|
169
|
+
.regex(/[0-9]/, 'Password must contain at least one number'),
|
|
170
|
+
session: zod_1.z.string().min(1, 'Session is required'),
|
|
171
|
+
});
|
|
172
|
+
exports.GetChallengeSessionSchema = zod_1.z.object({
|
|
173
|
+
email: zod_1.z.string().email('Invalid email format'),
|
|
174
|
+
password: zod_1.z.string().min(1, 'Password is required'),
|
|
175
|
+
});
|
|
176
|
+
// Create Device with Orphaned Organization schema
|
|
177
|
+
exports.CreateDeviceWithOrphanedOrganizationSchema = zod_1.z.object({
|
|
178
|
+
name: zod_1.z.string().min(1, 'Device name is required').max(100),
|
|
179
|
+
description: zod_1.z.string().max(500).optional(),
|
|
180
|
+
type: zod_1.z.enum(['laptop', 'desktop', 'mobile', 'tablet', 'server', 'gateway']).optional(),
|
|
181
|
+
organizationName: zod_1.z.string().min(1, 'Organization name is required').max(100),
|
|
182
|
+
organizationDescription: zod_1.z.string().max(500).optional(),
|
|
183
|
+
userEmail: zod_1.z.string().email('Invalid email format').optional(),
|
|
184
|
+
ipAddress: zod_1.z.string().regex(/^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$/).optional(),
|
|
185
|
+
location: zod_1.z.string().max(200).optional(),
|
|
186
|
+
os: zod_1.z.string().max(100).optional(),
|
|
187
|
+
browser: zod_1.z.string().max(100).optional(),
|
|
188
|
+
isTrusted: zod_1.z.boolean().optional(),
|
|
189
|
+
privateKey: zod_1.z.string().optional(),
|
|
190
|
+
publicKey: zod_1.z.string().optional(),
|
|
191
|
+
password: zod_1.z.string().min(1, 'Password is required'),
|
|
192
|
+
});
|
|
193
|
+
// Resource validation schemas
|
|
194
|
+
exports.CreateResourceSchema = zod_1.z.object({
|
|
195
|
+
name: zod_1.z.string().min(1, 'Name is required').max(100),
|
|
196
|
+
resourceType: zod_1.z.string().min(1, 'Resource type is required'),
|
|
197
|
+
type: zod_1.z.string().optional(),
|
|
198
|
+
region: zod_1.z.string().optional(),
|
|
199
|
+
description: zod_1.z.string().max(500).optional(),
|
|
200
|
+
status: zod_1.z.enum(['running', 'stopped', 'pending', 'error']).optional(),
|
|
201
|
+
cost: zod_1.z.number().nonnegative().optional(),
|
|
202
|
+
tags: zod_1.z.array(zod_1.z.string()).optional(),
|
|
203
|
+
parentResourceId: zod_1.z.string().optional(),
|
|
204
|
+
organizationId: zod_1.z.string().optional(),
|
|
205
|
+
configuration: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).optional(),
|
|
206
|
+
});
|
|
207
|
+
exports.UpdateResourceSchema = zod_1.z.object({
|
|
208
|
+
name: zod_1.z.string().min(1).max(100).optional(),
|
|
209
|
+
description: zod_1.z.string().max(500).optional(),
|
|
210
|
+
status: zod_1.z.enum(['running', 'stopped', 'pending', 'error']).optional(),
|
|
211
|
+
cost: zod_1.z.number().nonnegative().optional(),
|
|
212
|
+
tags: zod_1.z.array(zod_1.z.string()).optional(),
|
|
213
|
+
region: zod_1.z.string().optional(),
|
|
214
|
+
});
|
|
215
|
+
exports.GetResourceSchema = zod_1.z.object({
|
|
216
|
+
resourceId: zod_1.z.string().min(1, 'Resource ID is required'),
|
|
217
|
+
});
|
|
218
|
+
//# sourceMappingURL=schemas.js.map
|