@tamyla/clodo-framework 3.1.4 → 3.1.8
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/CHANGELOG.md +29 -0
- package/bin/clodo-service.js +29 -989
- package/bin/database/enterprise-db-manager.js +7 -5
- package/bin/security/security-cli.js +0 -0
- package/bin/service-management/create-service.js +0 -0
- package/bin/service-management/init-service.js +0 -0
- package/bin/shared/cloudflare/domain-discovery.js +11 -10
- package/bin/shared/cloudflare/ops.js +1 -1
- package/bin/shared/config/ConfigurationManager.js +539 -0
- package/bin/shared/config/index.js +13 -1
- package/bin/shared/database/connection-manager.js +2 -2
- package/bin/shared/database/orchestrator.js +5 -4
- package/bin/shared/deployment/auditor.js +9 -8
- package/bin/shared/logging/Logger.js +214 -0
- package/bin/shared/monitoring/production-monitor.js +21 -9
- package/bin/shared/utils/ErrorHandler.js +675 -0
- package/bin/shared/utils/error-recovery.js +33 -13
- package/bin/shared/utils/file-manager.js +162 -0
- package/bin/shared/utils/formatters.js +247 -0
- package/bin/shared/utils/index.js +14 -4
- package/bin/shared/validation/ValidationRegistry.js +143 -0
- package/dist/deployment/auditor.js +23 -8
- package/dist/deployment/orchestration/BaseDeploymentOrchestrator.js +426 -0
- package/dist/deployment/orchestration/EnterpriseOrchestrator.js +401 -0
- package/dist/deployment/orchestration/PortfolioOrchestrator.js +273 -0
- package/dist/deployment/orchestration/SingleServiceOrchestrator.js +231 -0
- package/dist/deployment/orchestration/UnifiedDeploymentOrchestrator.js +662 -0
- package/dist/deployment/orchestration/index.js +17 -0
- package/dist/index.js +12 -0
- package/dist/orchestration/modules/DomainResolver.js +8 -6
- package/dist/orchestration/multi-domain-orchestrator.js +13 -1
- package/dist/security/index.js +2 -2
- package/dist/service-management/ConfirmationEngine.js +8 -7
- package/dist/service-management/ErrorTracker.js +7 -2
- package/dist/service-management/InputCollector.js +31 -16
- package/dist/service-management/ServiceCreator.js +22 -7
- package/dist/service-management/ServiceInitializer.js +12 -18
- package/dist/shared/cloudflare/domain-discovery.js +11 -10
- package/dist/shared/cloudflare/ops.js +1 -1
- package/dist/shared/config/ConfigurationManager.js +519 -0
- package/dist/shared/config/index.js +5 -1
- package/dist/shared/database/connection-manager.js +2 -2
- package/dist/shared/database/orchestrator.js +13 -4
- package/dist/shared/deployment/auditor.js +23 -8
- package/dist/shared/logging/Logger.js +209 -0
- package/dist/shared/monitoring/production-monitor.js +24 -8
- package/dist/{utils → shared/utils}/ErrorHandler.js +306 -28
- package/dist/shared/utils/error-recovery.js +33 -13
- package/dist/shared/utils/file-manager.js +155 -0
- package/dist/shared/utils/formatters.js +215 -0
- package/dist/shared/utils/index.js +14 -4
- package/dist/shared/validation/ValidationRegistry.js +126 -0
- package/dist/utils/config/unified-config-manager.js +14 -12
- package/dist/utils/deployment/config-cache.js +3 -1
- package/dist/utils/deployment/secret-generator.js +32 -29
- package/dist/utils/framework-config.js +6 -3
- package/dist/utils/ui-structures-loader.js +3 -0
- package/dist/worker/integration.js +11 -1
- package/package.json +31 -3
- package/dist/config/FeatureManager.js +0 -426
- package/dist/config/features.js +0 -230
- package/dist/utils/error-recovery.js +0 -240
|
@@ -1,240 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Error Recovery Module
|
|
3
|
-
* Implements circuit breakers, retries, and graceful degradation
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
export class ErrorRecoveryManager {
|
|
7
|
-
constructor(options = {}) {
|
|
8
|
-
this.options = options;
|
|
9
|
-
this.config = null;
|
|
10
|
-
this.circuitStates = new Map(); // service -> { failures, lastFailure, state }
|
|
11
|
-
this.retryStates = new Map(); // operation -> retry count
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Initialize with framework configuration
|
|
16
|
-
*/
|
|
17
|
-
async initialize() {
|
|
18
|
-
// Import framework config for consistent timing and retry settings
|
|
19
|
-
const {
|
|
20
|
-
frameworkConfig
|
|
21
|
-
} = await import('./framework-config.js');
|
|
22
|
-
const timing = frameworkConfig.getTiming();
|
|
23
|
-
this.config = {
|
|
24
|
-
maxRetries: this.options.maxRetries || timing.retryAttempts,
|
|
25
|
-
retryDelay: this.options.retryDelay || timing.retryDelay,
|
|
26
|
-
circuitBreakerThreshold: this.options.circuitBreakerThreshold || timing.circuitBreakerThreshold,
|
|
27
|
-
circuitBreakerTimeout: this.options.circuitBreakerTimeout || timing.circuitBreakerTimeout,
|
|
28
|
-
gracefulDegradation: this.options.gracefulDegradation !== false,
|
|
29
|
-
...this.options
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Execute operation with error recovery
|
|
35
|
-
*/
|
|
36
|
-
async executeWithRecovery(operation, options = {}) {
|
|
37
|
-
const config = {
|
|
38
|
-
...this.config,
|
|
39
|
-
...options
|
|
40
|
-
};
|
|
41
|
-
const operationId = this.getOperationId(operation);
|
|
42
|
-
|
|
43
|
-
// Check circuit breaker
|
|
44
|
-
if (this.isCircuitOpen(operationId)) {
|
|
45
|
-
if (config.gracefulDegradation) {
|
|
46
|
-
return this.executeGracefulFallback(operation, config);
|
|
47
|
-
}
|
|
48
|
-
throw new Error(`Circuit breaker open for operation: ${operationId}`);
|
|
49
|
-
}
|
|
50
|
-
let lastError;
|
|
51
|
-
for (let attempt = 0; attempt <= config.maxRetries; attempt++) {
|
|
52
|
-
try {
|
|
53
|
-
const result = await operation();
|
|
54
|
-
this.recordSuccess(operationId);
|
|
55
|
-
return result;
|
|
56
|
-
} catch (error) {
|
|
57
|
-
lastError = error;
|
|
58
|
-
this.recordFailure(operationId, error);
|
|
59
|
-
if (attempt < config.maxRetries) {
|
|
60
|
-
const delay = this.calculateRetryDelay(attempt, config.retryDelay);
|
|
61
|
-
await this.delay(delay);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// All retries exhausted
|
|
67
|
-
if (config.gracefulDegradation) {
|
|
68
|
-
return this.executeGracefulFallback(operation, config);
|
|
69
|
-
}
|
|
70
|
-
throw lastError;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Check if circuit breaker is open
|
|
75
|
-
*/
|
|
76
|
-
isCircuitOpen(operationId) {
|
|
77
|
-
const state = this.circuitStates.get(operationId);
|
|
78
|
-
if (!state) return false;
|
|
79
|
-
if (state.state === 'open') {
|
|
80
|
-
// Check if timeout has passed
|
|
81
|
-
if (Date.now() - state.lastFailure > this.config.circuitBreakerTimeout) {
|
|
82
|
-
state.state = 'half-open';
|
|
83
|
-
state.failures = 0;
|
|
84
|
-
return false;
|
|
85
|
-
}
|
|
86
|
-
return true;
|
|
87
|
-
}
|
|
88
|
-
return false;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Record operation success
|
|
93
|
-
*/
|
|
94
|
-
recordSuccess(operationId) {
|
|
95
|
-
const state = this.circuitStates.get(operationId);
|
|
96
|
-
if (state) {
|
|
97
|
-
if (state.state === 'half-open') {
|
|
98
|
-
state.state = 'closed';
|
|
99
|
-
state.failures = 0;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Record operation failure
|
|
106
|
-
*/
|
|
107
|
-
recordFailure(operationId, error) {
|
|
108
|
-
let state = this.circuitStates.get(operationId);
|
|
109
|
-
if (!state) {
|
|
110
|
-
state = {
|
|
111
|
-
failures: 0,
|
|
112
|
-
lastFailure: 0,
|
|
113
|
-
state: 'closed'
|
|
114
|
-
};
|
|
115
|
-
this.circuitStates.set(operationId, state);
|
|
116
|
-
}
|
|
117
|
-
state.failures++;
|
|
118
|
-
state.lastFailure = Date.now();
|
|
119
|
-
if (state.failures >= this.config.circuitBreakerThreshold) {
|
|
120
|
-
state.state = 'open';
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* Calculate retry delay with exponential backoff
|
|
126
|
-
*/
|
|
127
|
-
calculateRetryDelay(attempt, baseDelay) {
|
|
128
|
-
const exponentialDelay = baseDelay * Math.pow(2, attempt);
|
|
129
|
-
const jitter = Math.random() * 0.1 * exponentialDelay;
|
|
130
|
-
return Math.min(exponentialDelay + jitter, 30000); // Max 30 seconds
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Execute graceful fallback
|
|
135
|
-
*/
|
|
136
|
-
async executeGracefulFallback(operation, config) {
|
|
137
|
-
console.warn(`Executing graceful fallback for operation`);
|
|
138
|
-
|
|
139
|
-
// Try to execute with reduced functionality
|
|
140
|
-
try {
|
|
141
|
-
// For deployment operations, try a simplified version
|
|
142
|
-
if (operation.name && operation.name.includes('deploy')) {
|
|
143
|
-
return {
|
|
144
|
-
success: false,
|
|
145
|
-
degraded: true,
|
|
146
|
-
message: 'Operation executed in degraded mode'
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
// For data operations, return cached or default data
|
|
151
|
-
if (operation.name && operation.name.includes('fetch')) {
|
|
152
|
-
return {
|
|
153
|
-
data: [],
|
|
154
|
-
cached: true,
|
|
155
|
-
degraded: true
|
|
156
|
-
};
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
// Default fallback
|
|
160
|
-
return {
|
|
161
|
-
success: false,
|
|
162
|
-
degraded: true,
|
|
163
|
-
fallback: true
|
|
164
|
-
};
|
|
165
|
-
} catch (fallbackError) {
|
|
166
|
-
console.error('Graceful fallback also failed:', fallbackError);
|
|
167
|
-
throw fallbackError;
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* Get unique operation ID
|
|
173
|
-
*/
|
|
174
|
-
getOperationId(operation) {
|
|
175
|
-
if (typeof operation === 'function' && operation.name) {
|
|
176
|
-
return operation.name;
|
|
177
|
-
}
|
|
178
|
-
return `operation_${Date.now()}_${Math.random()}`;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
/**
|
|
182
|
-
* Utility delay function
|
|
183
|
-
*/
|
|
184
|
-
delay(ms) {
|
|
185
|
-
return new Promise(resolve => setTimeout(resolve, ms));
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
/**
|
|
189
|
-
* Get circuit breaker status
|
|
190
|
-
*/
|
|
191
|
-
getCircuitStatus(operationId) {
|
|
192
|
-
const state = this.circuitStates.get(operationId);
|
|
193
|
-
if (!state) {
|
|
194
|
-
return {
|
|
195
|
-
state: 'closed',
|
|
196
|
-
failures: 0
|
|
197
|
-
};
|
|
198
|
-
}
|
|
199
|
-
return {
|
|
200
|
-
state: state.state,
|
|
201
|
-
failures: state.failures,
|
|
202
|
-
lastFailure: state.lastFailure,
|
|
203
|
-
timeSinceLastFailure: Date.now() - state.lastFailure
|
|
204
|
-
};
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
/**
|
|
208
|
-
* Reset circuit breaker
|
|
209
|
-
*/
|
|
210
|
-
resetCircuit(operationId) {
|
|
211
|
-
this.circuitStates.delete(operationId);
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
/**
|
|
215
|
-
* Get all circuit statuses
|
|
216
|
-
*/
|
|
217
|
-
getAllCircuitStatuses() {
|
|
218
|
-
const statuses = {};
|
|
219
|
-
for (const [operationId, state] of this.circuitStates) {
|
|
220
|
-
statuses[operationId] = this.getCircuitStatus(operationId);
|
|
221
|
-
}
|
|
222
|
-
return statuses;
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
/**
|
|
227
|
-
* Retry wrapper for functions
|
|
228
|
-
*/
|
|
229
|
-
export function withRetry(fn, options = {}) {
|
|
230
|
-
const recovery = new ErrorRecoveryManager(options);
|
|
231
|
-
return (...args) => recovery.executeWithRecovery(() => fn(...args), options);
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
/**
|
|
235
|
-
* Circuit breaker wrapper for functions
|
|
236
|
-
*/
|
|
237
|
-
export function withCircuitBreaker(fn, options = {}) {
|
|
238
|
-
const recovery = new ErrorRecoveryManager(options);
|
|
239
|
-
return (...args) => recovery.executeWithRecovery(() => fn(...args), options);
|
|
240
|
-
}
|