@tamyla/clodo-framework 3.1.22 → 3.1.24
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 +16 -0
- package/README.md +230 -1
- package/dist/cli/commands/assess.js +192 -0
- package/dist/cli/commands/create.js +77 -0
- package/dist/{bin → cli}/commands/deploy.js +36 -14
- package/dist/cli/commands/diagnose.js +83 -0
- package/dist/{bin → cli}/commands/helpers/deployment-verification.js +2 -3
- package/dist/{bin → cli}/commands/helpers/error-recovery.js +1 -1
- package/dist/{bin → cli}/commands/helpers/resource-detection.js +1 -1
- package/dist/cli/commands/helpers.js +110 -0
- package/dist/cli/commands/init-config.js +57 -0
- package/dist/cli/commands/update.js +102 -0
- package/dist/cli/commands/validate.js +65 -0
- package/dist/cli/security-cli.js +118 -0
- package/dist/config/FeatureManager.js +6 -0
- package/dist/config/clodo-create.example.json +26 -0
- package/dist/config/clodo-deploy.example.json +41 -0
- package/dist/config/clodo-update.example.json +46 -0
- package/dist/config/clodo-validate.example.json +41 -0
- package/dist/config/customers/template/development.env.template +37 -0
- package/dist/config/customers/template/production.env.template +39 -0
- package/dist/config/customers/template/staging.env.template +37 -0
- package/dist/config/customers.js +625 -0
- package/dist/config/domain-examples/README.md +464 -0
- package/dist/config/domain-examples/environment-mapped.json +168 -0
- package/dist/config/domain-examples/multi-domain.json +144 -0
- package/dist/config/domain-examples/single-domain.json +50 -0
- package/dist/config/domains.js +186 -0
- package/dist/config/examples +12 -0
- package/dist/config/features.js +61 -0
- package/dist/config/index.js +6 -0
- package/dist/config/staging-deployment.json +60 -0
- package/dist/config/validation-config.json +347 -0
- package/dist/database/database-orchestrator.js +795 -0
- package/dist/database/index.js +4 -0
- package/dist/deployment/index.js +11 -0
- package/dist/deployment/orchestration/BaseDeploymentOrchestrator.js +426 -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/deployment/rollback-manager.js +36 -0
- package/dist/deployment/wrangler-deployer.js +640 -0
- package/dist/handlers/GenericRouteHandler.js +532 -0
- package/dist/lib/database/deployment-db-manager.js +423 -0
- package/dist/lib/database/wrangler-d1-manager.js +685 -0
- package/dist/lib/deployment/modules/DeploymentConfiguration.js +395 -0
- package/dist/lib/deployment/modules/DeploymentOrchestrator.js +492 -0
- package/dist/lib/deployment/modules/EnvironmentManager.js +517 -0
- package/dist/lib/deployment/modules/MonitoringIntegration.js +560 -0
- package/dist/lib/deployment/modules/ValidationManager.js +342 -0
- package/dist/lib/deployment/orchestration/BaseDeploymentOrchestrator.js +426 -0
- package/dist/lib/deployment/orchestration/EnterpriseOrchestrator.js +21 -0
- package/dist/lib/deployment/orchestration/PortfolioOrchestrator.js +273 -0
- package/dist/lib/deployment/orchestration/SingleServiceOrchestrator.js +231 -0
- package/dist/lib/deployment/orchestration/UnifiedDeploymentOrchestrator.js +662 -0
- package/dist/{bin → lib}/shared/cloudflare/domain-discovery.js +1 -1
- package/dist/{bin → lib}/shared/cloudflare/domain-manager.js +1 -1
- package/dist/{bin → lib}/shared/cloudflare/ops.js +4 -4
- package/dist/{bin → lib}/shared/config/command-config-manager.js +1 -1
- package/dist/{bin → lib}/shared/config/index.js +1 -1
- package/dist/{bin → lib}/shared/config/manifest-loader.js +3 -3
- package/dist/{bin → lib}/shared/deployment/credential-collector.js +1 -1
- package/dist/lib/shared/deployment/index.js +10 -0
- package/dist/{bin → lib}/shared/deployment/rollback-manager.js +1 -1
- package/dist/{bin → lib}/shared/deployment/utilities/d1-error-recovery.js +1 -1
- package/dist/{bin → lib}/shared/deployment/validator.js +1 -1
- package/dist/{bin → lib}/shared/deployment/workflows/interactive-database-workflow.js +1 -1
- package/dist/{bin → lib}/shared/monitoring/health-checker.js +2 -2
- package/dist/{bin → lib}/shared/routing/domain-router.js +1 -1
- package/dist/{bin → lib}/shared/utils/config-loader.js +47 -11
- package/dist/lib/shared/utils/service-config-manager.js +227 -0
- package/dist/{bin → lib}/shared/validation/ValidationRegistry.js +1 -1
- package/dist/migration/MigrationAdapters.js +608 -0
- package/dist/modules/ModuleManager.js +668 -0
- package/dist/modules/security.js +96 -0
- package/dist/orchestration/cross-domain-coordinator.js +1083 -0
- package/dist/orchestration/index.js +5 -0
- package/dist/orchestration/modules/DeploymentCoordinator.js +368 -0
- package/dist/orchestration/modules/DomainResolver.js +198 -0
- package/dist/orchestration/modules/StateManager.js +332 -0
- package/dist/orchestration/multi-domain-orchestrator.js +765 -0
- package/dist/routing/EnhancedRouter.js +158 -0
- package/dist/schema/SchemaManager.js +778 -0
- package/dist/security/index.js +2 -2
- package/dist/service-management/ConfirmationEngine.js +412 -0
- package/dist/service-management/ErrorTracker.js +299 -0
- package/dist/service-management/GenerationEngine.js +447 -0
- package/dist/service-management/InputCollector.js +619 -0
- package/dist/service-management/ServiceCreator.js +21 -0
- package/dist/service-management/ServiceOrchestrator.js +672 -0
- package/dist/service-management/generators/BaseGenerator.js +233 -0
- package/dist/service-management/generators/GeneratorRegistry.js +254 -0
- package/dist/service-management/generators/cicd/CiWorkflowGenerator.js +87 -0
- package/dist/service-management/generators/cicd/DeployWorkflowGenerator.js +106 -0
- package/dist/service-management/generators/code/ServiceHandlersGenerator.js +235 -0
- package/dist/service-management/generators/code/ServiceMiddlewareGenerator.js +116 -0
- package/dist/service-management/generators/code/ServiceUtilsGenerator.js +246 -0
- package/dist/service-management/generators/code/WorkerIndexGenerator.js +143 -0
- package/dist/service-management/generators/config/DevelopmentEnvGenerator.js +101 -0
- package/dist/service-management/generators/config/DomainsConfigGenerator.js +175 -0
- package/dist/service-management/generators/config/EnvExampleGenerator.js +178 -0
- package/dist/service-management/generators/config/ProductionEnvGenerator.js +97 -0
- package/dist/service-management/generators/config/StagingEnvGenerator.js +97 -0
- package/dist/service-management/generators/config/WranglerTomlGenerator.js +238 -0
- package/dist/service-management/generators/core/PackageJsonGenerator.js +243 -0
- package/dist/service-management/generators/core/SiteConfigGenerator.js +115 -0
- package/dist/service-management/generators/documentation/ApiDocsGenerator.js +331 -0
- package/dist/service-management/generators/documentation/ConfigurationDocsGenerator.js +294 -0
- package/dist/service-management/generators/documentation/DeploymentDocsGenerator.js +244 -0
- package/dist/service-management/generators/documentation/ReadmeGenerator.js +196 -0
- package/dist/service-management/generators/schemas/ServiceSchemaGenerator.js +190 -0
- package/dist/service-management/generators/scripts/DeployScriptGenerator.js +123 -0
- package/dist/service-management/generators/scripts/HealthCheckScriptGenerator.js +101 -0
- package/dist/service-management/generators/scripts/SetupScriptGenerator.js +88 -0
- package/dist/service-management/generators/service-types/StaticSiteGenerator.js +342 -0
- package/dist/service-management/generators/testing/EslintConfigGenerator.js +85 -0
- package/dist/service-management/generators/testing/IntegrationTestsGenerator.js +237 -0
- package/dist/service-management/generators/testing/JestConfigGenerator.js +72 -0
- package/dist/service-management/generators/testing/UnitTestsGenerator.js +277 -0
- package/dist/service-management/generators/tooling/DockerComposeGenerator.js +71 -0
- package/dist/service-management/generators/tooling/GitignoreGenerator.js +143 -0
- package/dist/service-management/generators/utils/FileWriter.js +179 -0
- package/dist/service-management/generators/utils/PathResolver.js +157 -0
- package/dist/service-management/generators/utils/ServiceManifestGenerator.js +111 -0
- package/dist/service-management/generators/utils/TemplateEngine.js +185 -0
- package/dist/service-management/generators/utils/index.js +18 -0
- package/dist/service-management/handlers/ConfirmationHandler.js +71 -0
- package/dist/service-management/handlers/GenerationHandler.js +80 -0
- package/dist/service-management/handlers/InputHandler.js +59 -0
- package/dist/service-management/handlers/ValidationHandler.js +216 -0
- package/dist/service-management/index.js +14 -0
- package/dist/service-management/routing/DomainRouteMapper.js +311 -0
- package/dist/service-management/routing/RouteGenerator.js +266 -0
- package/dist/service-management/routing/WranglerRoutesBuilder.js +273 -0
- package/dist/service-management/routing/index.js +14 -0
- package/dist/service-management/services/DirectoryStructureService.js +56 -0
- package/dist/service-management/services/GenerationCoordinator.js +208 -0
- package/dist/service-management/services/GeneratorRegistry.js +174 -0
- package/dist/services/GenericDataService.js +501 -0
- package/dist/ui-structures/concepts/second-order-acquisition-strategy.md +286 -0
- package/dist/ui-structures/concepts/service-lifecycle-management.md +150 -0
- package/dist/ui-structures/concepts/service-manifest-guide.md +309 -0
- package/dist/ui-structures/concepts/three-tier-categorization-strategy.md +231 -0
- package/dist/ui-structures/creation/automated-generation-ui.json +246 -0
- package/dist/ui-structures/creation/core-inputs-ui.json +217 -0
- package/dist/ui-structures/creation/smart-confirmable-ui.json +451 -0
- package/dist/ui-structures/reference/absolutely-required-inputs.json +315 -0
- package/dist/ui-structures/reference/service-manifest-template.json +342 -0
- package/dist/utils/cloudflare/ops.js +1 -1
- package/dist/utils/file-manager.js +1 -1
- package/dist/utils/formatters.js +1 -1
- package/dist/utils/logger.js +1 -1
- package/dist/version/VersionDetector.js +813 -0
- package/dist/worker/index.js +4 -0
- package/dist/worker/integration.js +351 -0
- package/package.json +7 -15
- package/dist/bin/commands/validate.js +0 -51
- package/dist/bin/security/security-cli.js +0 -108
- package/dist/bin/shared/deployment/index.js +0 -10
- /package/dist/{bin → cli}/clodo-service.js +0 -0
- /package/dist/{bin → cli}/commands/helpers/deployment-ui.js +0 -0
- /package/dist/{bin → lib}/shared/cache/configuration-cache.js +0 -0
- /package/dist/{bin → lib}/shared/cloudflare/index.js +0 -0
- /package/dist/{bin → lib}/shared/config/ConfigurationManager.js +0 -0
- /package/dist/{bin → lib}/shared/config/cache.js +0 -0
- /package/dist/{bin → lib}/shared/config/cloudflare-service-validator.js +0 -0
- /package/dist/{bin → lib}/shared/config/manager.js +0 -0
- /package/dist/{bin → lib}/shared/database/connection-manager.js +0 -0
- /package/dist/{bin → lib}/shared/database/index.js +0 -0
- /package/dist/{bin → lib}/shared/database/orchestrator.js +0 -0
- /package/dist/{bin → lib}/shared/deployment/auditor.js +0 -0
- /package/dist/{bin → lib}/shared/deployment/workflows/deployment-summary.js +0 -0
- /package/dist/{bin → lib}/shared/deployment/workflows/interactive-confirmation.js +0 -0
- /package/dist/{bin → lib}/shared/deployment/workflows/interactive-domain-info-gatherer.js +0 -0
- /package/dist/{bin → lib}/shared/deployment/workflows/interactive-secret-workflow.js +0 -0
- /package/dist/{bin → lib}/shared/deployment/workflows/interactive-testing-workflow.js +0 -0
- /package/dist/{bin → lib}/shared/deployment/workflows/interactive-validation.js +0 -0
- /package/dist/{bin → lib}/shared/error-handling/error-classifier.js +0 -0
- /package/dist/{bin → lib}/shared/index.js +0 -0
- /package/dist/{bin → lib}/shared/logging/Logger.js +0 -0
- /package/dist/{bin → lib}/shared/monitoring/index.js +0 -0
- /package/dist/{bin → lib}/shared/monitoring/memory-manager.js +0 -0
- /package/dist/{bin → lib}/shared/monitoring/production-monitor.js +0 -0
- /package/dist/{bin → lib}/shared/production-tester/api-tester.js +0 -0
- /package/dist/{bin → lib}/shared/production-tester/auth-tester.js +0 -0
- /package/dist/{bin → lib}/shared/production-tester/core.js +0 -0
- /package/dist/{bin → lib}/shared/production-tester/database-tester.js +0 -0
- /package/dist/{bin → lib}/shared/production-tester/index.js +0 -0
- /package/dist/{bin → lib}/shared/production-tester/load-tester.js +0 -0
- /package/dist/{bin → lib}/shared/production-tester/performance-tester.js +0 -0
- /package/dist/{bin → lib}/shared/security/api-token-manager.js +0 -0
- /package/dist/{bin → lib}/shared/security/index.js +0 -0
- /package/dist/{bin → lib}/shared/security/secret-generator.js +0 -0
- /package/dist/{bin → lib}/shared/security/secure-token-manager.js +0 -0
- /package/dist/{bin → lib}/shared/utils/ErrorHandler.js +0 -0
- /package/dist/{bin → lib}/shared/utils/cli-options.js +0 -0
- /package/dist/{bin → lib}/shared/utils/deployment-validator.js +0 -0
- /package/dist/{bin → lib}/shared/utils/error-recovery.js +0 -0
- /package/dist/{bin → lib}/shared/utils/file-manager.js +0 -0
- /package/dist/{bin → lib}/shared/utils/formatters.js +0 -0
- /package/dist/{bin → lib}/shared/utils/graceful-shutdown-manager.js +0 -0
- /package/dist/{bin → lib}/shared/utils/index.js +0 -0
- /package/dist/{bin → lib}/shared/utils/interactive-prompts.js +0 -0
- /package/dist/{bin → lib}/shared/utils/interactive-utils.js +0 -0
- /package/dist/{bin → lib}/shared/utils/output-formatter.js +0 -0
- /package/dist/{bin → lib}/shared/utils/progress-manager.js +0 -0
- /package/dist/{bin → lib}/shared/utils/progress-spinner.js +0 -0
- /package/dist/{bin → lib}/shared/utils/rate-limiter.js +0 -0
- /package/dist/{bin → lib}/shared/utils/sensitive-redactor.js +0 -0
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
{
|
|
2
|
+
"domains": {
|
|
3
|
+
"api.example.com": {
|
|
4
|
+
"environment": "production",
|
|
5
|
+
"serviceName": "api-service",
|
|
6
|
+
"serviceType": "data-service",
|
|
7
|
+
"cloudflareToken": "CLOUDFLARE_API_TOKEN_PLACEHOLDER",
|
|
8
|
+
"cloudflareAccountId": "1234567890abcdef1234567890abcdef",
|
|
9
|
+
"cloudflareZoneId": "0987654321fedcba0987654321fedcba",
|
|
10
|
+
"displayName": "Production API Service",
|
|
11
|
+
"description": "Production API service with high availability",
|
|
12
|
+
"deploymentStrategy": "blue-green",
|
|
13
|
+
"healthCheck": {
|
|
14
|
+
"enabled": true,
|
|
15
|
+
"path": "/health",
|
|
16
|
+
"interval": 30,
|
|
17
|
+
"timeout": 10
|
|
18
|
+
},
|
|
19
|
+
"routing": {
|
|
20
|
+
"rules": [
|
|
21
|
+
{
|
|
22
|
+
"pattern": "/api/v1/*",
|
|
23
|
+
"target": "api-v1-worker",
|
|
24
|
+
"methods": ["GET", "POST", "PUT", "DELETE"]
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"pattern": "/api/v2/*",
|
|
28
|
+
"target": "api-v2-worker",
|
|
29
|
+
"methods": ["GET", "POST", "PUT", "DELETE"]
|
|
30
|
+
}
|
|
31
|
+
]
|
|
32
|
+
},
|
|
33
|
+
"security": {
|
|
34
|
+
"cors": {
|
|
35
|
+
"enabled": true,
|
|
36
|
+
"origins": ["https://app.example.com", "https://admin.example.com"],
|
|
37
|
+
"methods": ["GET", "POST", "PUT", "DELETE"],
|
|
38
|
+
"headers": ["Content-Type", "Authorization", "X-API-Key"]
|
|
39
|
+
},
|
|
40
|
+
"rateLimit": {
|
|
41
|
+
"enabled": true,
|
|
42
|
+
"requests": 5000,
|
|
43
|
+
"window": 60
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
"admin.example.com": {
|
|
48
|
+
"environment": "production",
|
|
49
|
+
"serviceName": "admin-service",
|
|
50
|
+
"serviceType": "web-service",
|
|
51
|
+
"cloudflareToken": "CLOUDFLARE_API_TOKEN_PLACEHOLDER",
|
|
52
|
+
"cloudflareAccountId": "1234567890abcdef1234567890abcdef",
|
|
53
|
+
"cloudflareZoneId": "0987654321fedcba0987654321fedcba",
|
|
54
|
+
"displayName": "Admin Dashboard Service",
|
|
55
|
+
"description": "Administrative dashboard with restricted access",
|
|
56
|
+
"deploymentStrategy": "rolling",
|
|
57
|
+
"healthCheck": {
|
|
58
|
+
"enabled": true,
|
|
59
|
+
"path": "/admin/health",
|
|
60
|
+
"interval": 60,
|
|
61
|
+
"timeout": 15
|
|
62
|
+
},
|
|
63
|
+
"routing": {
|
|
64
|
+
"rules": [
|
|
65
|
+
{
|
|
66
|
+
"pattern": "/admin/*",
|
|
67
|
+
"target": "admin-worker",
|
|
68
|
+
"methods": ["GET", "POST", "PUT", "DELETE"],
|
|
69
|
+
"auth": {
|
|
70
|
+
"required": true,
|
|
71
|
+
"type": "jwt"
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
]
|
|
75
|
+
},
|
|
76
|
+
"security": {
|
|
77
|
+
"cors": {
|
|
78
|
+
"enabled": false
|
|
79
|
+
},
|
|
80
|
+
"rateLimit": {
|
|
81
|
+
"enabled": true,
|
|
82
|
+
"requests": 100,
|
|
83
|
+
"window": 60
|
|
84
|
+
},
|
|
85
|
+
"waf": {
|
|
86
|
+
"enabled": true,
|
|
87
|
+
"rules": ["sql-injection", "xss", "csrf"]
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
"cdn.example.com": {
|
|
92
|
+
"environment": "production",
|
|
93
|
+
"serviceName": "cdn-service",
|
|
94
|
+
"serviceType": "static-site",
|
|
95
|
+
"cloudflareToken": "CLOUDFLARE_API_TOKEN_PLACEHOLDER",
|
|
96
|
+
"cloudflareAccountId": "1234567890abcdef1234567890abcdef",
|
|
97
|
+
"cloudflareZoneId": "0987654321fedcba0987654321fedcba",
|
|
98
|
+
"displayName": "CDN Static Assets",
|
|
99
|
+
"description": "Content delivery network for static assets",
|
|
100
|
+
"deploymentStrategy": "instant",
|
|
101
|
+
"healthCheck": {
|
|
102
|
+
"enabled": false
|
|
103
|
+
},
|
|
104
|
+
"routing": {
|
|
105
|
+
"rules": [
|
|
106
|
+
{
|
|
107
|
+
"pattern": "/*",
|
|
108
|
+
"target": "cdn-worker",
|
|
109
|
+
"methods": ["GET", "HEAD"],
|
|
110
|
+
"cache": {
|
|
111
|
+
"enabled": true,
|
|
112
|
+
"ttl": 3600,
|
|
113
|
+
"purgeOnDeploy": true
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
]
|
|
117
|
+
},
|
|
118
|
+
"security": {
|
|
119
|
+
"cors": {
|
|
120
|
+
"enabled": true,
|
|
121
|
+
"origins": ["*"],
|
|
122
|
+
"methods": ["GET", "HEAD"],
|
|
123
|
+
"headers": ["Cache-Control", "ETag"]
|
|
124
|
+
},
|
|
125
|
+
"rateLimit": {
|
|
126
|
+
"enabled": false
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
"global": {
|
|
132
|
+
"customer": "example-company",
|
|
133
|
+
"organization": "Example Corp",
|
|
134
|
+
"contact": "devops@example.com",
|
|
135
|
+
"version": "1.0.0",
|
|
136
|
+
"lastUpdated": "2025-10-28",
|
|
137
|
+
"multiDomain": {
|
|
138
|
+
"enabled": true,
|
|
139
|
+
"parallelDeployments": 2,
|
|
140
|
+
"rollbackOnFailure": true,
|
|
141
|
+
"healthCheckTimeout": 300
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"domains": {
|
|
3
|
+
"api.example.com": {
|
|
4
|
+
"environment": "production",
|
|
5
|
+
"serviceName": "api-service",
|
|
6
|
+
"serviceType": "data-service",
|
|
7
|
+
"cloudflareToken": "CLOUDFLARE_API_TOKEN_PLACEHOLDER",
|
|
8
|
+
"cloudflareAccountId": "1234567890abcdef1234567890abcdef",
|
|
9
|
+
"cloudflareZoneId": "0987654321fedcba0987654321fedcba",
|
|
10
|
+
"displayName": "Example API Service",
|
|
11
|
+
"description": "Single domain configuration for production API service",
|
|
12
|
+
"deploymentStrategy": "rolling",
|
|
13
|
+
"healthCheck": {
|
|
14
|
+
"enabled": true,
|
|
15
|
+
"path": "/health",
|
|
16
|
+
"interval": 30,
|
|
17
|
+
"timeout": 10
|
|
18
|
+
},
|
|
19
|
+
"routing": {
|
|
20
|
+
"rules": [
|
|
21
|
+
{
|
|
22
|
+
"pattern": "/api/*",
|
|
23
|
+
"target": "api-worker",
|
|
24
|
+
"methods": ["GET", "POST", "PUT", "DELETE"]
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
},
|
|
28
|
+
"security": {
|
|
29
|
+
"cors": {
|
|
30
|
+
"enabled": true,
|
|
31
|
+
"origins": ["https://app.example.com"],
|
|
32
|
+
"methods": ["GET", "POST", "PUT", "DELETE"],
|
|
33
|
+
"headers": ["Content-Type", "Authorization"]
|
|
34
|
+
},
|
|
35
|
+
"rateLimit": {
|
|
36
|
+
"enabled": true,
|
|
37
|
+
"requests": 1000,
|
|
38
|
+
"window": 60
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"global": {
|
|
44
|
+
"customer": "example-company",
|
|
45
|
+
"organization": "Example Corp",
|
|
46
|
+
"contact": "devops@example.com",
|
|
47
|
+
"version": "1.0.0",
|
|
48
|
+
"lastUpdated": "2025-10-28"
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
// Simple inline logger to avoid circular dependency with index.js
|
|
2
|
+
import { validateRequired, deepMerge } from '../utils/index.js';
|
|
3
|
+
const logger = {
|
|
4
|
+
info: (message, ...args) => console.log(`[DomainConfig] ${message}`, ...args),
|
|
5
|
+
error: (message, ...args) => console.error(`[DomainConfig] ${message}`, ...args),
|
|
6
|
+
warn: (message, ...args) => console.warn(`[DomainConfig] ${message}`, ...args),
|
|
7
|
+
debug: (message, ...args) => console.debug(`[DomainConfig] ${message}`, ...args)
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Creates a base domain configuration schema
|
|
12
|
+
* @returns {Object} Base domain configuration template
|
|
13
|
+
*/
|
|
14
|
+
export const createDomainConfigSchema = () => ({
|
|
15
|
+
name: '',
|
|
16
|
+
displayName: '',
|
|
17
|
+
accountId: '',
|
|
18
|
+
zoneId: '',
|
|
19
|
+
domains: {
|
|
20
|
+
production: '',
|
|
21
|
+
staging: '',
|
|
22
|
+
development: ''
|
|
23
|
+
},
|
|
24
|
+
services: {},
|
|
25
|
+
databases: {},
|
|
26
|
+
features: {},
|
|
27
|
+
settings: {
|
|
28
|
+
environment: 'development',
|
|
29
|
+
logLevel: 'info',
|
|
30
|
+
corsOrigins: ['*']
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Validates a domain configuration object
|
|
36
|
+
* @param {Object} config - Domain configuration to validate
|
|
37
|
+
* @throws {Error} If validation fails
|
|
38
|
+
*/
|
|
39
|
+
export const validateDomainConfig = config => {
|
|
40
|
+
try {
|
|
41
|
+
// Required top-level fields
|
|
42
|
+
validateRequired(config, ['name', 'accountId', 'zoneId']);
|
|
43
|
+
|
|
44
|
+
// Validate Cloudflare IDs format (basic check)
|
|
45
|
+
if (!/^[a-f0-9]{32}$/.test(config.accountId)) {
|
|
46
|
+
throw new Error('accountId must be a valid Cloudflare account ID (32 hex characters)');
|
|
47
|
+
}
|
|
48
|
+
if (!/^[a-f0-9]{32}$/.test(config.zoneId)) {
|
|
49
|
+
throw new Error('zoneId must be a valid Cloudflare zone ID (32 hex characters)');
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Validate domains structure
|
|
53
|
+
if (!config.domains || typeof config.domains !== 'object') {
|
|
54
|
+
throw new Error('domains must be an object with production/staging/development keys');
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// At least one domain should be configured
|
|
58
|
+
const hasDomain = Object.values(config.domains).some(domain => domain && domain.trim());
|
|
59
|
+
if (!hasDomain) {
|
|
60
|
+
throw new Error('At least one domain (production, staging, or development) must be configured');
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Validate domain formats (basic URL validation)
|
|
64
|
+
Object.entries(config.domains).forEach(([env, domain]) => {
|
|
65
|
+
if (domain && domain.trim()) {
|
|
66
|
+
try {
|
|
67
|
+
new URL(`https://${domain}`);
|
|
68
|
+
} catch {
|
|
69
|
+
throw new Error(`Invalid domain format for ${env}: ${domain}`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
logger.info(`Domain configuration validated: ${config.name}`);
|
|
74
|
+
} catch (error) {
|
|
75
|
+
logger.error(`Domain configuration validation failed: ${error.message}`);
|
|
76
|
+
throw error;
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Merges base domain config with service-specific extensions
|
|
82
|
+
* @param {Object} baseConfig - Base domain configuration
|
|
83
|
+
* @param {Object} serviceConfig - Service-specific configuration extensions
|
|
84
|
+
* @returns {Object} Merged configuration
|
|
85
|
+
*/
|
|
86
|
+
export const mergeDomainConfigs = (baseConfig, serviceConfig) => {
|
|
87
|
+
if (!baseConfig || !serviceConfig) {
|
|
88
|
+
throw new Error('Both baseConfig and serviceConfig are required for merging');
|
|
89
|
+
}
|
|
90
|
+
const merged = deepMerge(baseConfig, serviceConfig);
|
|
91
|
+
|
|
92
|
+
// Validate the merged configuration
|
|
93
|
+
validateDomainConfig(merged);
|
|
94
|
+
logger.info(`Domain configurations merged: ${baseConfig.name}`);
|
|
95
|
+
return merged;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Creates a domain configuration registry
|
|
100
|
+
* @param {Object} domainConfigs - Object containing domain configurations
|
|
101
|
+
* @returns {Object} Domain registry with lookup methods
|
|
102
|
+
*/
|
|
103
|
+
export const createDomainRegistry = domainConfigs => {
|
|
104
|
+
const registry = {
|
|
105
|
+
...domainConfigs
|
|
106
|
+
};
|
|
107
|
+
return {
|
|
108
|
+
get: domainName => {
|
|
109
|
+
const config = registry[domainName];
|
|
110
|
+
if (!config) {
|
|
111
|
+
throw new Error(`Domain not found: ${domainName}`);
|
|
112
|
+
}
|
|
113
|
+
return config;
|
|
114
|
+
},
|
|
115
|
+
list: () => Object.keys(registry),
|
|
116
|
+
validateAll: () => {
|
|
117
|
+
Object.values(registry).forEach(validateDomainConfig);
|
|
118
|
+
logger.info(`All ${Object.keys(registry).length} domain configurations validated`);
|
|
119
|
+
},
|
|
120
|
+
add: (domainName, config) => {
|
|
121
|
+
validateDomainConfig(config);
|
|
122
|
+
registry[domainName] = config;
|
|
123
|
+
logger.info(`Domain added to registry: ${domainName}`);
|
|
124
|
+
},
|
|
125
|
+
remove: domainName => {
|
|
126
|
+
if (!registry[domainName]) {
|
|
127
|
+
throw new Error(`Domain not found: ${domainName}`);
|
|
128
|
+
}
|
|
129
|
+
delete registry[domainName];
|
|
130
|
+
logger.info(`Domain removed from registry: ${domainName}`);
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Gets domain configuration from environment variables
|
|
137
|
+
* @param {Object} env - Environment variables
|
|
138
|
+
* @param {Object} domainConfigs - Available domain configurations
|
|
139
|
+
* @returns {Object} Domain configuration for current environment
|
|
140
|
+
*/
|
|
141
|
+
export const getDomainFromEnv = (env, domainConfigs) => {
|
|
142
|
+
const domainName = env.DOMAIN_NAME || env.CF_DOMAIN_NAME || 'default';
|
|
143
|
+
if (!domainConfigs[domainName]) {
|
|
144
|
+
logger.warn(`Domain not found: ${domainName}, using default`);
|
|
145
|
+
return domainConfigs.default || Object.values(domainConfigs)[0];
|
|
146
|
+
}
|
|
147
|
+
return domainConfigs[domainName];
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Creates environment-specific configuration overrides
|
|
152
|
+
* @param {Object} baseConfig - Base domain configuration
|
|
153
|
+
* @param {string} environment - Target environment (production, staging, development)
|
|
154
|
+
* @returns {Object} Environment-specific configuration
|
|
155
|
+
*/
|
|
156
|
+
export const createEnvironmentConfig = (baseConfig, environment = 'development') => {
|
|
157
|
+
const envConfig = {
|
|
158
|
+
...baseConfig
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
// Set environment-specific settings
|
|
162
|
+
envConfig.settings = {
|
|
163
|
+
...envConfig.settings,
|
|
164
|
+
environment,
|
|
165
|
+
isProduction: environment === 'production',
|
|
166
|
+
isStaging: environment === 'staging',
|
|
167
|
+
isDevelopment: environment === 'development'
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
// Environment-specific domain selection
|
|
171
|
+
if (envConfig.domains[environment]) {
|
|
172
|
+
envConfig.currentDomain = envConfig.domains[environment];
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// Environment-specific feature overrides
|
|
176
|
+
if (environment === 'production') {
|
|
177
|
+
// Ensure critical features are enabled in production
|
|
178
|
+
envConfig.features = {
|
|
179
|
+
...envConfig.features,
|
|
180
|
+
errorReporting: true,
|
|
181
|
+
monitoring: true
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
logger.info(`Environment config created for ${baseConfig.name} (${environment})`);
|
|
185
|
+
return envConfig;
|
|
186
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"customer": "mycompany",
|
|
3
|
+
"environment": "production",
|
|
4
|
+
"serviceName": "my-api-service",
|
|
5
|
+
"serviceType": "data-service",
|
|
6
|
+
"domainName": "api.mycompany.com",
|
|
7
|
+
"cloudflareToken": "CLOUDFLARE_API_TOKEN_PLACEHOLDER",
|
|
8
|
+
"cloudflareAccountId": "1234567890abcdef1234567890abcdef",
|
|
9
|
+
"cloudflareZoneId": "0987654321fedcba0987654321fedcba",
|
|
10
|
+
"displayName": "My Company API Service",
|
|
11
|
+
"description": "Production API service for customer data management"
|
|
12
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Feature Flag Manager
|
|
3
|
+
* Simple stub for missing features.js
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export class FeatureFlagManager {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.features = new Map();
|
|
9
|
+
}
|
|
10
|
+
isEnabled(feature) {
|
|
11
|
+
return this.features.get(feature) || false;
|
|
12
|
+
}
|
|
13
|
+
enable(feature) {
|
|
14
|
+
this.features.set(feature, true);
|
|
15
|
+
}
|
|
16
|
+
disable(feature) {
|
|
17
|
+
this.features.set(feature, false);
|
|
18
|
+
}
|
|
19
|
+
withFeature(feature, enhancedFn, legacyFn = null) {
|
|
20
|
+
if (this.isEnabled(feature)) {
|
|
21
|
+
return enhancedFn();
|
|
22
|
+
} else if (legacyFn) {
|
|
23
|
+
return legacyFn();
|
|
24
|
+
} else {
|
|
25
|
+
// If no legacy function provided, just call enhanced anyway
|
|
26
|
+
return enhancedFn();
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
getAllFeatures() {
|
|
30
|
+
const result = {};
|
|
31
|
+
for (const [key, value] of this.features) {
|
|
32
|
+
result[key] = {
|
|
33
|
+
enabled: value
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
return result;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Default instance
|
|
41
|
+
export const featureManager = new FeatureFlagManager();
|
|
42
|
+
|
|
43
|
+
// Feature constants
|
|
44
|
+
export const FEATURES = {
|
|
45
|
+
ENHANCED_SCHEMA: 'enhanced_schema',
|
|
46
|
+
ENHANCED_VALIDATION: 'enhanced_validation',
|
|
47
|
+
ENABLE_COMPREHENSIVE_VALIDATION: 'enhanced_validation',
|
|
48
|
+
ENABLE_SQL_CACHING: 'sql_caching',
|
|
49
|
+
ENABLE_SCHEMA_CACHING: 'schema_caching',
|
|
50
|
+
ENABLE_ADVANCED_QUERIES: 'advanced_queries',
|
|
51
|
+
ENABLE_SECURITY_CONTROLS: 'security_controls',
|
|
52
|
+
ENABLE_QUERY_CACHING: 'query_caching',
|
|
53
|
+
ENABLE_ADVANCED_PAGINATION: 'advanced_pagination',
|
|
54
|
+
ENABLE_CACHE_METRICS: 'cache_metrics',
|
|
55
|
+
ENABLE_DEBUG_LOGGING: 'debug_logging',
|
|
56
|
+
ENABLE_ENHANCED_SCHEMA: 'enhanced_schema',
|
|
57
|
+
ENABLE_HOOK_METRICS: 'hook_metrics',
|
|
58
|
+
ENABLE_HOOK_TIMEOUT: 'hook_timeout',
|
|
59
|
+
ENABLE_ENHANCED_HOOKS: 'enhanced_hooks',
|
|
60
|
+
ENABLE_PARALLEL_EXECUTION: 'parallel_execution'
|
|
61
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"// Comment": "Staging deployment configuration for clodo-framework",
|
|
3
|
+
"// Instructions": "This config deploys to staging environment using environment-mapped domain configuration",
|
|
4
|
+
"// Domain": "Uses staging.example.com domain from environment-mapped.json",
|
|
5
|
+
"// Environment": "Staging environment with moderate security and monitoring",
|
|
6
|
+
|
|
7
|
+
"domain": "staging.example.com",
|
|
8
|
+
"environment": "staging",
|
|
9
|
+
"cloudflareToken": "${CLOUDFLARE_API_TOKEN}",
|
|
10
|
+
"cloudflareAccountId": "${CLOUDFLARE_ACCOUNT_ID}",
|
|
11
|
+
"cloudflareZoneId": "${CLOUDFLARE_ZONE_ID}",
|
|
12
|
+
|
|
13
|
+
"deployment": {
|
|
14
|
+
"strategy": "rolling",
|
|
15
|
+
"replicas": 2,
|
|
16
|
+
"maxConcurrency": 50,
|
|
17
|
+
"timeout": 60000,
|
|
18
|
+
"healthCheckInterval": 10000,
|
|
19
|
+
"rollbackOnFailure": true
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
"routing": {
|
|
23
|
+
"enableLoadBalancing": true,
|
|
24
|
+
"loadBalancingPolicy": "round-robin",
|
|
25
|
+
"corsEnabled": true,
|
|
26
|
+
"corsOrigins": ["https://staging.example.com", "https://app-staging.example.com"]
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
"monitoring": {
|
|
30
|
+
"enableMetrics": true,
|
|
31
|
+
"metricsEndpoint": "https://metrics-staging.example.com",
|
|
32
|
+
"alertOnFailure": true,
|
|
33
|
+
"alertEmail": "staging-alerts@example.com"
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
"security": {
|
|
37
|
+
"enableSSL": true,
|
|
38
|
+
"minTLSVersion": "1.2",
|
|
39
|
+
"enableWAF": true,
|
|
40
|
+
"rateLimit": 500,
|
|
41
|
+
"rateLimitWindow": 60,
|
|
42
|
+
"wafRules": ["sql-injection", "xss"]
|
|
43
|
+
},
|
|
44
|
+
|
|
45
|
+
"healthCheck": {
|
|
46
|
+
"enabled": true,
|
|
47
|
+
"endpoint": "/health",
|
|
48
|
+
"interval": 30000,
|
|
49
|
+
"timeout": 10000,
|
|
50
|
+
"healthyThreshold": 2,
|
|
51
|
+
"unhealthyThreshold": 3
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
"logging": {
|
|
55
|
+
"level": "info",
|
|
56
|
+
"includeRequestId": true,
|
|
57
|
+
"includeTimestamp": true,
|
|
58
|
+
"maskSensitiveData": true
|
|
59
|
+
}
|
|
60
|
+
}
|