@tamyla/clodo-framework 3.1.21 → 3.1.22
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 +9 -0
- package/README.md +53 -0
- package/dist/bin/clodo-service.js +47 -15
- package/dist/bin/commands/deploy.js +115 -83
- package/dist/bin/commands/helpers/deployment-ui.js +138 -0
- package/dist/bin/commands/helpers/deployment-verification.js +251 -0
- package/dist/bin/commands/helpers/error-recovery.js +80 -0
- package/dist/bin/commands/helpers/resource-detection.js +113 -0
- package/dist/bin/commands/validate.js +1 -1
- package/dist/bin/security/security-cli.js +1 -1
- package/dist/bin/shared/cache/configuration-cache.js +82 -0
- package/dist/bin/shared/cloudflare/domain-manager.js +1 -1
- package/dist/bin/shared/cloudflare/index.js +1 -1
- package/dist/bin/shared/cloudflare/ops.js +6 -4
- package/dist/bin/shared/config/ConfigurationManager.js +23 -1
- package/dist/bin/shared/config/command-config-manager.js +19 -3
- package/dist/bin/shared/config/index.js +1 -1
- package/dist/bin/shared/deployment/credential-collector.js +30 -7
- package/dist/bin/shared/deployment/index.js +2 -2
- package/dist/bin/shared/deployment/rollback-manager.js +4 -520
- package/dist/bin/shared/deployment/utilities/d1-error-recovery.js +177 -0
- package/dist/bin/shared/deployment/validator.js +40 -10
- package/dist/bin/shared/deployment/workflows/deployment-summary.js +214 -0
- package/dist/bin/shared/deployment/workflows/interactive-confirmation.js +188 -0
- package/dist/bin/shared/deployment/workflows/interactive-database-workflow.js +234 -0
- package/dist/bin/shared/deployment/workflows/interactive-domain-info-gatherer.js +240 -0
- package/dist/bin/shared/deployment/workflows/interactive-secret-workflow.js +228 -0
- package/dist/bin/shared/deployment/workflows/interactive-testing-workflow.js +235 -0
- package/dist/bin/shared/deployment/workflows/interactive-validation.js +218 -0
- package/dist/bin/shared/error-handling/error-classifier.js +46 -0
- package/dist/bin/shared/monitoring/health-checker.js +129 -1
- package/dist/bin/shared/monitoring/memory-manager.js +17 -6
- package/dist/bin/shared/routing/domain-router.js +1 -1
- package/dist/bin/shared/utils/deployment-validator.js +97 -0
- package/dist/bin/shared/utils/formatters.js +10 -0
- package/dist/bin/shared/utils/index.js +13 -1
- package/dist/bin/shared/utils/interactive-prompts.js +34 -18
- package/dist/bin/shared/utils/progress-manager.js +2 -2
- package/dist/bin/shared/utils/progress-spinner.js +53 -0
- package/dist/bin/shared/utils/sensitive-redactor.js +91 -0
- package/dist/bin/shared/validation/ValidationRegistry.js +1 -1
- package/dist/security/index.js +1 -1
- package/dist/security/patterns/insecure-patterns.js +1 -1
- package/dist/utils/constants.js +102 -0
- package/dist/utils/deployment/wrangler-config-manager.js +215 -48
- package/dist/utils/framework-config.js +2 -2
- package/dist/utils/interactive-prompts.js +10 -59
- package/package.json +16 -8
- package/dist/bin/clodo-service-old.js +0 -868
- package/dist/bin/clodo-service-test.js +0 -10
- package/dist/bin/commands/assess.js +0 -91
- package/dist/bin/commands/create.js +0 -77
- package/dist/bin/commands/diagnose.js +0 -83
- package/dist/bin/commands/helpers.js +0 -138
- package/dist/bin/commands/update.js +0 -75
- package/dist/bin/database/deployment-db-manager.js +0 -423
- package/dist/bin/database/enterprise-db-manager.js +0 -457
- package/dist/bin/database/wrangler-d1-manager.js +0 -685
- package/dist/bin/deployment/enterprise-deploy.js +0 -877
- package/dist/bin/deployment/master-deploy.js +0 -1376
- package/dist/bin/deployment/modular-enterprise-deploy.js +0 -466
- package/dist/bin/deployment/modules/DeploymentConfiguration.js +0 -395
- package/dist/bin/deployment/modules/DeploymentOrchestrator.js +0 -492
- package/dist/bin/deployment/modules/EnvironmentManager.js +0 -517
- package/dist/bin/deployment/modules/MonitoringIntegration.js +0 -560
- package/dist/bin/deployment/modules/ValidationManager.js +0 -342
- package/dist/bin/deployment/orchestration/BaseDeploymentOrchestrator.js +0 -426
- package/dist/bin/deployment/orchestration/EnterpriseOrchestrator.js +0 -401
- package/dist/bin/deployment/orchestration/PortfolioOrchestrator.js +0 -273
- package/dist/bin/deployment/orchestration/SingleServiceOrchestrator.js +0 -231
- package/dist/bin/deployment/orchestration/UnifiedDeploymentOrchestrator.js +0 -662
- package/dist/bin/deployment/test-interactive-utils.js +0 -66
- package/dist/bin/portfolio/portfolio-manager.js +0 -487
- package/dist/bin/service-management/create-service.js +0 -122
- package/dist/bin/service-management/init-service.js +0 -79
- package/dist/config/customers.js +0 -623
- package/dist/config/domains.js +0 -186
- package/dist/config/index.js +0 -6
- package/dist/database/database-orchestrator.js +0 -795
- package/dist/database/index.js +0 -4
- package/dist/deployment/index.js +0 -11
- package/dist/deployment/orchestration/BaseDeploymentOrchestrator.js +0 -426
- package/dist/deployment/orchestration/EnterpriseOrchestrator.js +0 -401
- package/dist/deployment/orchestration/PortfolioOrchestrator.js +0 -273
- package/dist/deployment/orchestration/SingleServiceOrchestrator.js +0 -231
- package/dist/deployment/orchestration/UnifiedDeploymentOrchestrator.js +0 -662
- package/dist/deployment/orchestration/index.js +0 -17
- package/dist/deployment/rollback-manager.js +0 -36
- package/dist/deployment/wrangler-deployer.js +0 -640
- package/dist/handlers/GenericRouteHandler.js +0 -532
- package/dist/migration/MigrationAdapters.js +0 -562
- package/dist/modules/ModuleManager.js +0 -668
- package/dist/modules/security.js +0 -96
- package/dist/orchestration/cross-domain-coordinator.js +0 -1083
- package/dist/orchestration/index.js +0 -5
- package/dist/orchestration/modules/DeploymentCoordinator.js +0 -368
- package/dist/orchestration/modules/DomainResolver.js +0 -198
- package/dist/orchestration/modules/StateManager.js +0 -332
- package/dist/orchestration/multi-domain-orchestrator.js +0 -724
- package/dist/routing/EnhancedRouter.js +0 -158
- package/dist/schema/SchemaManager.js +0 -778
- package/dist/service-management/ConfirmationEngine.js +0 -412
- package/dist/service-management/ErrorTracker.js +0 -299
- package/dist/service-management/GenerationEngine.js +0 -447
- package/dist/service-management/InputCollector.js +0 -619
- package/dist/service-management/ServiceCreator.js +0 -265
- package/dist/service-management/ServiceInitializer.js +0 -453
- package/dist/service-management/ServiceOrchestrator.js +0 -633
- package/dist/service-management/generators/BaseGenerator.js +0 -233
- package/dist/service-management/generators/GeneratorRegistry.js +0 -254
- package/dist/service-management/generators/cicd/CiWorkflowGenerator.js +0 -87
- package/dist/service-management/generators/cicd/DeployWorkflowGenerator.js +0 -106
- package/dist/service-management/generators/code/ServiceHandlersGenerator.js +0 -235
- package/dist/service-management/generators/code/ServiceMiddlewareGenerator.js +0 -116
- package/dist/service-management/generators/code/ServiceUtilsGenerator.js +0 -246
- package/dist/service-management/generators/code/WorkerIndexGenerator.js +0 -143
- package/dist/service-management/generators/config/DevelopmentEnvGenerator.js +0 -101
- package/dist/service-management/generators/config/DomainsConfigGenerator.js +0 -175
- package/dist/service-management/generators/config/EnvExampleGenerator.js +0 -178
- package/dist/service-management/generators/config/ProductionEnvGenerator.js +0 -97
- package/dist/service-management/generators/config/StagingEnvGenerator.js +0 -97
- package/dist/service-management/generators/config/WranglerTomlGenerator.js +0 -238
- package/dist/service-management/generators/core/PackageJsonGenerator.js +0 -243
- package/dist/service-management/generators/core/SiteConfigGenerator.js +0 -115
- package/dist/service-management/generators/documentation/ApiDocsGenerator.js +0 -331
- package/dist/service-management/generators/documentation/ConfigurationDocsGenerator.js +0 -294
- package/dist/service-management/generators/documentation/DeploymentDocsGenerator.js +0 -244
- package/dist/service-management/generators/documentation/ReadmeGenerator.js +0 -196
- package/dist/service-management/generators/schemas/ServiceSchemaGenerator.js +0 -190
- package/dist/service-management/generators/scripts/DeployScriptGenerator.js +0 -123
- package/dist/service-management/generators/scripts/HealthCheckScriptGenerator.js +0 -101
- package/dist/service-management/generators/scripts/SetupScriptGenerator.js +0 -88
- package/dist/service-management/generators/service-types/StaticSiteGenerator.js +0 -342
- package/dist/service-management/generators/testing/EslintConfigGenerator.js +0 -85
- package/dist/service-management/generators/testing/IntegrationTestsGenerator.js +0 -237
- package/dist/service-management/generators/testing/JestConfigGenerator.js +0 -72
- package/dist/service-management/generators/testing/UnitTestsGenerator.js +0 -277
- package/dist/service-management/generators/tooling/DockerComposeGenerator.js +0 -71
- package/dist/service-management/generators/tooling/GitignoreGenerator.js +0 -143
- package/dist/service-management/generators/utils/FileWriter.js +0 -179
- package/dist/service-management/generators/utils/PathResolver.js +0 -157
- package/dist/service-management/generators/utils/ServiceManifestGenerator.js +0 -111
- package/dist/service-management/generators/utils/TemplateEngine.js +0 -185
- package/dist/service-management/generators/utils/index.js +0 -18
- package/dist/service-management/handlers/ConfirmationHandler.js +0 -71
- package/dist/service-management/handlers/GenerationHandler.js +0 -80
- package/dist/service-management/handlers/InputHandler.js +0 -59
- package/dist/service-management/handlers/ValidationHandler.js +0 -203
- package/dist/service-management/index.js +0 -14
- package/dist/service-management/routing/DomainRouteMapper.js +0 -311
- package/dist/service-management/routing/RouteGenerator.js +0 -266
- package/dist/service-management/routing/WranglerRoutesBuilder.js +0 -273
- package/dist/service-management/routing/index.js +0 -14
- package/dist/service-management/services/DirectoryStructureService.js +0 -56
- package/dist/service-management/services/GenerationCoordinator.js +0 -208
- package/dist/service-management/services/GeneratorRegistry.js +0 -174
- package/dist/services/GenericDataService.js +0 -501
- package/dist/ui-structures/concepts/second-order-acquisition-strategy.md +0 -286
- package/dist/ui-structures/concepts/service-lifecycle-management.md +0 -150
- package/dist/ui-structures/concepts/service-manifest-guide.md +0 -309
- package/dist/ui-structures/concepts/three-tier-categorization-strategy.md +0 -231
- package/dist/ui-structures/creation/automated-generation-ui.json +0 -246
- package/dist/ui-structures/creation/core-inputs-ui.json +0 -217
- package/dist/ui-structures/creation/smart-confirmable-ui.json +0 -451
- package/dist/ui-structures/reference/absolutely-required-inputs.json +0 -315
- package/dist/ui-structures/reference/service-manifest-template.json +0 -342
- package/dist/version/VersionDetector.js +0 -723
- package/dist/worker/index.js +0 -4
- package/dist/worker/integration.js +0 -351
package/dist/database/index.js
DELETED
package/dist/deployment/index.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
// Deployment Module
|
|
2
|
-
// Core deployment components for the Clodo Framework
|
|
3
|
-
|
|
4
|
-
export { WranglerDeployer } from './wrangler-deployer.js';
|
|
5
|
-
|
|
6
|
-
// Orchestration Framework - Public API for downstream consumers
|
|
7
|
-
export { BaseDeploymentOrchestrator } from './orchestration/BaseDeploymentOrchestrator.js';
|
|
8
|
-
export { SingleServiceOrchestrator } from './orchestration/SingleServiceOrchestrator.js';
|
|
9
|
-
export { PortfolioOrchestrator } from './orchestration/PortfolioOrchestrator.js';
|
|
10
|
-
export { EnterpriseOrchestrator } from './orchestration/EnterpriseOrchestrator.js';
|
|
11
|
-
export { UnifiedDeploymentOrchestrator } from './orchestration/UnifiedDeploymentOrchestrator.js';
|
|
@@ -1,426 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Base Deployment Orchestrator
|
|
3
|
-
*
|
|
4
|
-
* Abstract base class for all deployment orchestration patterns.
|
|
5
|
-
* Provides unified phase pipeline, phase state management, and error handling.
|
|
6
|
-
*
|
|
7
|
-
* Phase Pipeline:
|
|
8
|
-
* 1. Initialization → 2. Validation → 3. Preparation → 4. Deployment → 5. Verification → 6. Monitoring
|
|
9
|
-
*
|
|
10
|
-
* All subclasses must implement phase-specific methods:
|
|
11
|
-
* - onInitialize()
|
|
12
|
-
* - onValidation()
|
|
13
|
-
* - onPrepare()
|
|
14
|
-
* - onDeploy()
|
|
15
|
-
* - onVerify()
|
|
16
|
-
* - onMonitor()
|
|
17
|
-
*
|
|
18
|
-
* @class BaseDeploymentOrchestrator
|
|
19
|
-
* @abstract
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
import { ErrorHandler } from '../../shared/utils/ErrorHandler.js';
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Phase state and execution order
|
|
26
|
-
*/
|
|
27
|
-
const DEPLOYMENT_PHASES = {
|
|
28
|
-
INITIALIZATION: 'initialization',
|
|
29
|
-
VALIDATION: 'validation',
|
|
30
|
-
PREPARATION: 'preparation',
|
|
31
|
-
DEPLOYMENT: 'deployment',
|
|
32
|
-
VERIFICATION: 'verification',
|
|
33
|
-
MONITORING: 'monitoring'
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Phase execution order
|
|
38
|
-
*/
|
|
39
|
-
const PHASE_SEQUENCE = [DEPLOYMENT_PHASES.INITIALIZATION, DEPLOYMENT_PHASES.VALIDATION, DEPLOYMENT_PHASES.PREPARATION, DEPLOYMENT_PHASES.DEPLOYMENT, DEPLOYMENT_PHASES.VERIFICATION, DEPLOYMENT_PHASES.MONITORING];
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Base Deployment Orchestrator - Abstract orchestration framework
|
|
43
|
-
*/
|
|
44
|
-
export class BaseDeploymentOrchestrator {
|
|
45
|
-
/**
|
|
46
|
-
* Constructor
|
|
47
|
-
* @param {Object} options - Configuration options
|
|
48
|
-
* @param {string} options.deploymentId - Unique deployment identifier
|
|
49
|
-
* @param {Object} options.config - Deployment configuration
|
|
50
|
-
* @param {Object} options.auditor - Deployment auditor instance (optional)
|
|
51
|
-
*/
|
|
52
|
-
constructor(options = {}) {
|
|
53
|
-
this.deploymentId = options.deploymentId || `deploy-${Date.now()}`;
|
|
54
|
-
this.config = options.config || {};
|
|
55
|
-
this.auditor = options.auditor;
|
|
56
|
-
|
|
57
|
-
// Phase state management
|
|
58
|
-
this.currentPhase = null;
|
|
59
|
-
this.phaseStates = new Map();
|
|
60
|
-
this.phaseResults = new Map();
|
|
61
|
-
this.phaseErrors = new Map();
|
|
62
|
-
this.startTime = Date.now();
|
|
63
|
-
this.phaseTimings = new Map();
|
|
64
|
-
|
|
65
|
-
// Execution context
|
|
66
|
-
this.executionContext = {
|
|
67
|
-
deploymentId: this.deploymentId,
|
|
68
|
-
startTime: this.startTime,
|
|
69
|
-
phases: {},
|
|
70
|
-
errors: []
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Execute complete deployment orchestration
|
|
76
|
-
* Runs through all phases in sequence with error handling and recovery
|
|
77
|
-
*
|
|
78
|
-
* @param {Object} options - Execution options
|
|
79
|
-
* @returns {Promise<Object>} Deployment result
|
|
80
|
-
* @throws {Error} If critical phase fails
|
|
81
|
-
*/
|
|
82
|
-
async execute(options = {}) {
|
|
83
|
-
const {
|
|
84
|
-
continueOnError = false
|
|
85
|
-
} = options;
|
|
86
|
-
try {
|
|
87
|
-
console.log(`🎯 Starting deployment orchestration: ${this.deploymentId}`);
|
|
88
|
-
console.log(`📊 Phases: ${PHASE_SEQUENCE.join(' → ')}`);
|
|
89
|
-
console.log('');
|
|
90
|
-
|
|
91
|
-
// Execute each phase in sequence
|
|
92
|
-
for (const phase of PHASE_SEQUENCE) {
|
|
93
|
-
try {
|
|
94
|
-
const result = await this.executePhase(phase);
|
|
95
|
-
this.phaseResults.set(phase, result);
|
|
96
|
-
|
|
97
|
-
// Log phase success
|
|
98
|
-
if (this.auditor) {
|
|
99
|
-
this.auditor.logPhase(this.deploymentId, phase, 'complete', {
|
|
100
|
-
result
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
console.log(`✅ Phase '${phase}' completed successfully`);
|
|
104
|
-
} catch (error) {
|
|
105
|
-
// Store phase error
|
|
106
|
-
this.phaseErrors.set(phase, error);
|
|
107
|
-
console.error(`❌ Phase '${phase}' failed: ${error.message}`);
|
|
108
|
-
|
|
109
|
-
// Log phase error
|
|
110
|
-
if (this.auditor) {
|
|
111
|
-
this.auditor.logError(this.deploymentId, error, {
|
|
112
|
-
phase,
|
|
113
|
-
context: this.executionContext
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
// Handle critical phases
|
|
118
|
-
if (this.isCriticalPhase(phase)) {
|
|
119
|
-
if (!continueOnError) {
|
|
120
|
-
throw error;
|
|
121
|
-
}
|
|
122
|
-
console.warn(`⚠️ Continuing despite critical phase failure in '${phase}'`);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
// Generate execution summary
|
|
128
|
-
const summary = this.generateExecutionSummary();
|
|
129
|
-
console.log('');
|
|
130
|
-
console.log(`✅ Deployment orchestration completed: ${this.deploymentId}`);
|
|
131
|
-
console.log(`📈 Execution time: ${this.getExecutionTime()}ms`);
|
|
132
|
-
return summary;
|
|
133
|
-
} catch (error) {
|
|
134
|
-
// Log fatal error to auditor if available
|
|
135
|
-
if (this.auditor) {
|
|
136
|
-
this.auditor.logError(this.deploymentId, error, {
|
|
137
|
-
fatal: true,
|
|
138
|
-
phase: this.currentPhase,
|
|
139
|
-
context: this.executionContext
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
// Re-throw the error without additional wrapping
|
|
144
|
-
throw error;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* Execute single phase
|
|
150
|
-
* @private
|
|
151
|
-
* @param {string} phase - Phase name
|
|
152
|
-
* @returns {Promise<Object>} Phase result
|
|
153
|
-
*/
|
|
154
|
-
async executePhase(phase) {
|
|
155
|
-
this.currentPhase = phase;
|
|
156
|
-
const phaseStartTime = Date.now();
|
|
157
|
-
console.log(`\n🔄 Executing phase: '${phase}'`);
|
|
158
|
-
console.log(` ├─ Phase state: pending → executing → complete`);
|
|
159
|
-
|
|
160
|
-
// Update phase state
|
|
161
|
-
this.phaseStates.set(phase, 'executing');
|
|
162
|
-
try {
|
|
163
|
-
// Validate phase method exists
|
|
164
|
-
const phaseMethod = `on${this.capitalize(phase)}`;
|
|
165
|
-
if (typeof this[phaseMethod] !== 'function') {
|
|
166
|
-
throw new Error(`Phase method '${phaseMethod}' not implemented in ${this.constructor.name}`);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
// Execute phase-specific logic
|
|
170
|
-
const result = await this[phaseMethod]();
|
|
171
|
-
|
|
172
|
-
// Record phase timing
|
|
173
|
-
const phaseDuration = Date.now() - phaseStartTime;
|
|
174
|
-
this.phaseTimings.set(phase, phaseDuration);
|
|
175
|
-
|
|
176
|
-
// Update phase state
|
|
177
|
-
this.phaseStates.set(phase, 'complete');
|
|
178
|
-
return {
|
|
179
|
-
phase,
|
|
180
|
-
status: 'success',
|
|
181
|
-
result,
|
|
182
|
-
duration: phaseDuration,
|
|
183
|
-
timestamp: new Date().toISOString()
|
|
184
|
-
};
|
|
185
|
-
} catch (error) {
|
|
186
|
-
// Record error and re-throw
|
|
187
|
-
const phaseDuration = Date.now() - phaseStartTime;
|
|
188
|
-
this.phaseTimings.set(phase, phaseDuration);
|
|
189
|
-
this.phaseStates.set(phase, 'error');
|
|
190
|
-
throw error;
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
/**
|
|
195
|
-
* Determine if phase is critical to deployment success
|
|
196
|
-
* Critical phases: initialization, validation, deployment
|
|
197
|
-
* Non-critical: monitoring, verification (can warn instead)
|
|
198
|
-
*
|
|
199
|
-
* @private
|
|
200
|
-
* @param {string} phase - Phase name
|
|
201
|
-
* @returns {boolean} True if phase is critical
|
|
202
|
-
*/
|
|
203
|
-
isCriticalPhase(phase) {
|
|
204
|
-
const criticalPhases = [DEPLOYMENT_PHASES.INITIALIZATION, DEPLOYMENT_PHASES.DEPLOYMENT];
|
|
205
|
-
return criticalPhases.includes(phase);
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
/**
|
|
209
|
-
* Generate comprehensive execution summary
|
|
210
|
-
* @private
|
|
211
|
-
* @returns {Object} Execution summary
|
|
212
|
-
*/
|
|
213
|
-
generateExecutionSummary() {
|
|
214
|
-
const summary = {
|
|
215
|
-
deploymentId: this.deploymentId,
|
|
216
|
-
orchestrator: this.constructor.name,
|
|
217
|
-
totalDuration: this.getExecutionTime(),
|
|
218
|
-
phases: {},
|
|
219
|
-
stats: {
|
|
220
|
-
total: PHASE_SEQUENCE.length,
|
|
221
|
-
completed: 0,
|
|
222
|
-
failed: 0,
|
|
223
|
-
skipped: 0
|
|
224
|
-
},
|
|
225
|
-
errors: Array.from(this.phaseErrors.entries()).map(([phase, error]) => ({
|
|
226
|
-
phase,
|
|
227
|
-
message: error.message,
|
|
228
|
-
severity: this.isCriticalPhase(phase) ? 'critical' : 'warning'
|
|
229
|
-
}))
|
|
230
|
-
};
|
|
231
|
-
|
|
232
|
-
// Add phase details to summary
|
|
233
|
-
for (const phase of PHASE_SEQUENCE) {
|
|
234
|
-
const state = this.phaseStates.get(phase);
|
|
235
|
-
const duration = this.phaseTimings.get(phase) || 0;
|
|
236
|
-
summary.phases[phase] = {
|
|
237
|
-
state,
|
|
238
|
-
duration,
|
|
239
|
-
result: this.phaseResults.get(phase),
|
|
240
|
-
error: this.phaseErrors.get(phase)?.message
|
|
241
|
-
};
|
|
242
|
-
if (state === 'complete') summary.stats.completed++;
|
|
243
|
-
if (state === 'error') summary.stats.failed++;
|
|
244
|
-
if (!state) summary.stats.skipped++;
|
|
245
|
-
}
|
|
246
|
-
summary.stats.successRate = Math.round(summary.stats.completed / summary.stats.total * 100);
|
|
247
|
-
return summary;
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
/**
|
|
251
|
-
* Get total execution time in milliseconds
|
|
252
|
-
* @returns {number} Execution time in ms
|
|
253
|
-
*/
|
|
254
|
-
getExecutionTime() {
|
|
255
|
-
return Date.now() - this.startTime;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
/**
|
|
259
|
-
* Get phase status
|
|
260
|
-
* @param {string} phase - Phase name
|
|
261
|
-
* @returns {string} Phase state: 'pending', 'executing', 'complete', 'error'
|
|
262
|
-
*/
|
|
263
|
-
getPhaseStatus(phase) {
|
|
264
|
-
return this.phaseStates.get(phase) || 'pending';
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
/**
|
|
268
|
-
* Get all phase results
|
|
269
|
-
* @returns {Map<string, Object>} Map of phase results
|
|
270
|
-
*/
|
|
271
|
-
getPhaseResults() {
|
|
272
|
-
return new Map(this.phaseResults);
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
/**
|
|
276
|
-
* Get specific phase result
|
|
277
|
-
* @param {string} phase - Phase name
|
|
278
|
-
* @returns {Object} Phase result or null
|
|
279
|
-
*/
|
|
280
|
-
getPhaseResult(phase) {
|
|
281
|
-
return this.phaseResults.get(phase) || null;
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
/**
|
|
285
|
-
* Get execution context
|
|
286
|
-
* @returns {Object} Current execution context
|
|
287
|
-
*/
|
|
288
|
-
getExecutionContext() {
|
|
289
|
-
return {
|
|
290
|
-
...this.executionContext,
|
|
291
|
-
currentPhase: this.currentPhase,
|
|
292
|
-
phaseStates: Object.fromEntries(this.phaseStates),
|
|
293
|
-
phaseTimings: Object.fromEntries(this.phaseTimings),
|
|
294
|
-
totalDuration: this.getExecutionTime()
|
|
295
|
-
};
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
/**
|
|
299
|
-
* Capitalize first letter of string and convert hyphens to camelCase
|
|
300
|
-
* Used for method name generation with special handling for phase names
|
|
301
|
-
*
|
|
302
|
-
* @private
|
|
303
|
-
* @param {string} str - String to capitalize
|
|
304
|
-
* @returns {string} Capitalized camelCase string
|
|
305
|
-
*/
|
|
306
|
-
capitalize(str) {
|
|
307
|
-
// Special mappings for phase names to method names
|
|
308
|
-
const phaseToMethodMap = {
|
|
309
|
-
'initialization': 'Initialize',
|
|
310
|
-
'validation': 'Validation',
|
|
311
|
-
'preparation': 'Prepare',
|
|
312
|
-
'deployment': 'Deploy',
|
|
313
|
-
'verification': 'Verify',
|
|
314
|
-
'monitoring': 'Monitor'
|
|
315
|
-
};
|
|
316
|
-
if (phaseToMethodMap[str]) {
|
|
317
|
-
return phaseToMethodMap[str];
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
// Generic camelCase converter for extensibility
|
|
321
|
-
return str.split('-').map((word, idx) => idx === 0 ? word.charAt(0).toUpperCase() + word.slice(1) : word.charAt(0).toUpperCase() + word.slice(1)).join('');
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
/**
|
|
325
|
-
* Phase lifecycle methods (to be implemented by subclasses)
|
|
326
|
-
* Each phase must be implemented in concrete orchestrator
|
|
327
|
-
*/
|
|
328
|
-
|
|
329
|
-
/**
|
|
330
|
-
* Initialization phase
|
|
331
|
-
* Setup and validate deployment environment
|
|
332
|
-
*
|
|
333
|
-
* @abstract
|
|
334
|
-
* @returns {Promise<Object>} Initialization result
|
|
335
|
-
*/
|
|
336
|
-
async onInitialize() {
|
|
337
|
-
throw new Error(`onInitialize() must be implemented in ${this.constructor.name}`);
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
/**
|
|
341
|
-
* Validation phase
|
|
342
|
-
* Validate all prerequisites and configurations
|
|
343
|
-
*
|
|
344
|
-
* @abstract
|
|
345
|
-
* @returns {Promise<Object>} Validation result
|
|
346
|
-
*/
|
|
347
|
-
async onValidation() {
|
|
348
|
-
throw new Error(`onValidation() must be implemented in ${this.constructor.name}`);
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
/**
|
|
352
|
-
* Preparation phase
|
|
353
|
-
* Prepare resources and deployment artifacts
|
|
354
|
-
*
|
|
355
|
-
* @abstract
|
|
356
|
-
* @returns {Promise<Object>} Preparation result
|
|
357
|
-
*/
|
|
358
|
-
async onPrepare() {
|
|
359
|
-
throw new Error(`onPrepare() must be implemented in ${this.constructor.name}`);
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
/**
|
|
363
|
-
* Deployment phase
|
|
364
|
-
* Execute actual deployment operations
|
|
365
|
-
*
|
|
366
|
-
* @abstract
|
|
367
|
-
* @returns {Promise<Object>} Deployment result
|
|
368
|
-
*/
|
|
369
|
-
async onDeploy() {
|
|
370
|
-
throw new Error(`onDeploy() must be implemented in ${this.constructor.name}`);
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
/**
|
|
374
|
-
* Verification phase
|
|
375
|
-
* Verify deployment success and health
|
|
376
|
-
*
|
|
377
|
-
* @abstract
|
|
378
|
-
* @returns {Promise<Object>} Verification result
|
|
379
|
-
*/
|
|
380
|
-
async onVerify() {
|
|
381
|
-
throw new Error(`onVerify() must be implemented in ${this.constructor.name}`);
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
/**
|
|
385
|
-
* Monitoring phase
|
|
386
|
-
* Setup monitoring and alerting for deployed service
|
|
387
|
-
*
|
|
388
|
-
* @abstract
|
|
389
|
-
* @returns {Promise<Object>} Monitoring result
|
|
390
|
-
*/
|
|
391
|
-
async onMonitor() {
|
|
392
|
-
throw new Error(`onMonitor() must be implemented in ${this.constructor.name}`);
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
/**
|
|
396
|
-
* Static helper to get deployment phases
|
|
397
|
-
* @static
|
|
398
|
-
* @returns {Object} Phase constants
|
|
399
|
-
*/
|
|
400
|
-
static getPhases() {
|
|
401
|
-
return {
|
|
402
|
-
...DEPLOYMENT_PHASES
|
|
403
|
-
};
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
/**
|
|
407
|
-
* Static helper to get phase sequence
|
|
408
|
-
* @static
|
|
409
|
-
* @returns {string[]} Ordered phase names
|
|
410
|
-
*/
|
|
411
|
-
static getPhaseSequence() {
|
|
412
|
-
return [...PHASE_SEQUENCE];
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
/**
|
|
416
|
-
* Static helper to validate phase name
|
|
417
|
-
* @static
|
|
418
|
-
* @param {string} phase - Phase to validate
|
|
419
|
-
* @returns {boolean} True if valid phase
|
|
420
|
-
*/
|
|
421
|
-
static isValidPhase(phase) {
|
|
422
|
-
return PHASE_SEQUENCE.includes(phase);
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
export default BaseDeploymentOrchestrator;
|
|
426
|
-
export { DEPLOYMENT_PHASES, PHASE_SEQUENCE };
|