@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.
Files changed (169) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/README.md +53 -0
  3. package/dist/bin/clodo-service.js +47 -15
  4. package/dist/bin/commands/deploy.js +115 -83
  5. package/dist/bin/commands/helpers/deployment-ui.js +138 -0
  6. package/dist/bin/commands/helpers/deployment-verification.js +251 -0
  7. package/dist/bin/commands/helpers/error-recovery.js +80 -0
  8. package/dist/bin/commands/helpers/resource-detection.js +113 -0
  9. package/dist/bin/commands/validate.js +1 -1
  10. package/dist/bin/security/security-cli.js +1 -1
  11. package/dist/bin/shared/cache/configuration-cache.js +82 -0
  12. package/dist/bin/shared/cloudflare/domain-manager.js +1 -1
  13. package/dist/bin/shared/cloudflare/index.js +1 -1
  14. package/dist/bin/shared/cloudflare/ops.js +6 -4
  15. package/dist/bin/shared/config/ConfigurationManager.js +23 -1
  16. package/dist/bin/shared/config/command-config-manager.js +19 -3
  17. package/dist/bin/shared/config/index.js +1 -1
  18. package/dist/bin/shared/deployment/credential-collector.js +30 -7
  19. package/dist/bin/shared/deployment/index.js +2 -2
  20. package/dist/bin/shared/deployment/rollback-manager.js +4 -520
  21. package/dist/bin/shared/deployment/utilities/d1-error-recovery.js +177 -0
  22. package/dist/bin/shared/deployment/validator.js +40 -10
  23. package/dist/bin/shared/deployment/workflows/deployment-summary.js +214 -0
  24. package/dist/bin/shared/deployment/workflows/interactive-confirmation.js +188 -0
  25. package/dist/bin/shared/deployment/workflows/interactive-database-workflow.js +234 -0
  26. package/dist/bin/shared/deployment/workflows/interactive-domain-info-gatherer.js +240 -0
  27. package/dist/bin/shared/deployment/workflows/interactive-secret-workflow.js +228 -0
  28. package/dist/bin/shared/deployment/workflows/interactive-testing-workflow.js +235 -0
  29. package/dist/bin/shared/deployment/workflows/interactive-validation.js +218 -0
  30. package/dist/bin/shared/error-handling/error-classifier.js +46 -0
  31. package/dist/bin/shared/monitoring/health-checker.js +129 -1
  32. package/dist/bin/shared/monitoring/memory-manager.js +17 -6
  33. package/dist/bin/shared/routing/domain-router.js +1 -1
  34. package/dist/bin/shared/utils/deployment-validator.js +97 -0
  35. package/dist/bin/shared/utils/formatters.js +10 -0
  36. package/dist/bin/shared/utils/index.js +13 -1
  37. package/dist/bin/shared/utils/interactive-prompts.js +34 -18
  38. package/dist/bin/shared/utils/progress-manager.js +2 -2
  39. package/dist/bin/shared/utils/progress-spinner.js +53 -0
  40. package/dist/bin/shared/utils/sensitive-redactor.js +91 -0
  41. package/dist/bin/shared/validation/ValidationRegistry.js +1 -1
  42. package/dist/security/index.js +1 -1
  43. package/dist/security/patterns/insecure-patterns.js +1 -1
  44. package/dist/utils/constants.js +102 -0
  45. package/dist/utils/deployment/wrangler-config-manager.js +215 -48
  46. package/dist/utils/framework-config.js +2 -2
  47. package/dist/utils/interactive-prompts.js +10 -59
  48. package/package.json +16 -8
  49. package/dist/bin/clodo-service-old.js +0 -868
  50. package/dist/bin/clodo-service-test.js +0 -10
  51. package/dist/bin/commands/assess.js +0 -91
  52. package/dist/bin/commands/create.js +0 -77
  53. package/dist/bin/commands/diagnose.js +0 -83
  54. package/dist/bin/commands/helpers.js +0 -138
  55. package/dist/bin/commands/update.js +0 -75
  56. package/dist/bin/database/deployment-db-manager.js +0 -423
  57. package/dist/bin/database/enterprise-db-manager.js +0 -457
  58. package/dist/bin/database/wrangler-d1-manager.js +0 -685
  59. package/dist/bin/deployment/enterprise-deploy.js +0 -877
  60. package/dist/bin/deployment/master-deploy.js +0 -1376
  61. package/dist/bin/deployment/modular-enterprise-deploy.js +0 -466
  62. package/dist/bin/deployment/modules/DeploymentConfiguration.js +0 -395
  63. package/dist/bin/deployment/modules/DeploymentOrchestrator.js +0 -492
  64. package/dist/bin/deployment/modules/EnvironmentManager.js +0 -517
  65. package/dist/bin/deployment/modules/MonitoringIntegration.js +0 -560
  66. package/dist/bin/deployment/modules/ValidationManager.js +0 -342
  67. package/dist/bin/deployment/orchestration/BaseDeploymentOrchestrator.js +0 -426
  68. package/dist/bin/deployment/orchestration/EnterpriseOrchestrator.js +0 -401
  69. package/dist/bin/deployment/orchestration/PortfolioOrchestrator.js +0 -273
  70. package/dist/bin/deployment/orchestration/SingleServiceOrchestrator.js +0 -231
  71. package/dist/bin/deployment/orchestration/UnifiedDeploymentOrchestrator.js +0 -662
  72. package/dist/bin/deployment/test-interactive-utils.js +0 -66
  73. package/dist/bin/portfolio/portfolio-manager.js +0 -487
  74. package/dist/bin/service-management/create-service.js +0 -122
  75. package/dist/bin/service-management/init-service.js +0 -79
  76. package/dist/config/customers.js +0 -623
  77. package/dist/config/domains.js +0 -186
  78. package/dist/config/index.js +0 -6
  79. package/dist/database/database-orchestrator.js +0 -795
  80. package/dist/database/index.js +0 -4
  81. package/dist/deployment/index.js +0 -11
  82. package/dist/deployment/orchestration/BaseDeploymentOrchestrator.js +0 -426
  83. package/dist/deployment/orchestration/EnterpriseOrchestrator.js +0 -401
  84. package/dist/deployment/orchestration/PortfolioOrchestrator.js +0 -273
  85. package/dist/deployment/orchestration/SingleServiceOrchestrator.js +0 -231
  86. package/dist/deployment/orchestration/UnifiedDeploymentOrchestrator.js +0 -662
  87. package/dist/deployment/orchestration/index.js +0 -17
  88. package/dist/deployment/rollback-manager.js +0 -36
  89. package/dist/deployment/wrangler-deployer.js +0 -640
  90. package/dist/handlers/GenericRouteHandler.js +0 -532
  91. package/dist/migration/MigrationAdapters.js +0 -562
  92. package/dist/modules/ModuleManager.js +0 -668
  93. package/dist/modules/security.js +0 -96
  94. package/dist/orchestration/cross-domain-coordinator.js +0 -1083
  95. package/dist/orchestration/index.js +0 -5
  96. package/dist/orchestration/modules/DeploymentCoordinator.js +0 -368
  97. package/dist/orchestration/modules/DomainResolver.js +0 -198
  98. package/dist/orchestration/modules/StateManager.js +0 -332
  99. package/dist/orchestration/multi-domain-orchestrator.js +0 -724
  100. package/dist/routing/EnhancedRouter.js +0 -158
  101. package/dist/schema/SchemaManager.js +0 -778
  102. package/dist/service-management/ConfirmationEngine.js +0 -412
  103. package/dist/service-management/ErrorTracker.js +0 -299
  104. package/dist/service-management/GenerationEngine.js +0 -447
  105. package/dist/service-management/InputCollector.js +0 -619
  106. package/dist/service-management/ServiceCreator.js +0 -265
  107. package/dist/service-management/ServiceInitializer.js +0 -453
  108. package/dist/service-management/ServiceOrchestrator.js +0 -633
  109. package/dist/service-management/generators/BaseGenerator.js +0 -233
  110. package/dist/service-management/generators/GeneratorRegistry.js +0 -254
  111. package/dist/service-management/generators/cicd/CiWorkflowGenerator.js +0 -87
  112. package/dist/service-management/generators/cicd/DeployWorkflowGenerator.js +0 -106
  113. package/dist/service-management/generators/code/ServiceHandlersGenerator.js +0 -235
  114. package/dist/service-management/generators/code/ServiceMiddlewareGenerator.js +0 -116
  115. package/dist/service-management/generators/code/ServiceUtilsGenerator.js +0 -246
  116. package/dist/service-management/generators/code/WorkerIndexGenerator.js +0 -143
  117. package/dist/service-management/generators/config/DevelopmentEnvGenerator.js +0 -101
  118. package/dist/service-management/generators/config/DomainsConfigGenerator.js +0 -175
  119. package/dist/service-management/generators/config/EnvExampleGenerator.js +0 -178
  120. package/dist/service-management/generators/config/ProductionEnvGenerator.js +0 -97
  121. package/dist/service-management/generators/config/StagingEnvGenerator.js +0 -97
  122. package/dist/service-management/generators/config/WranglerTomlGenerator.js +0 -238
  123. package/dist/service-management/generators/core/PackageJsonGenerator.js +0 -243
  124. package/dist/service-management/generators/core/SiteConfigGenerator.js +0 -115
  125. package/dist/service-management/generators/documentation/ApiDocsGenerator.js +0 -331
  126. package/dist/service-management/generators/documentation/ConfigurationDocsGenerator.js +0 -294
  127. package/dist/service-management/generators/documentation/DeploymentDocsGenerator.js +0 -244
  128. package/dist/service-management/generators/documentation/ReadmeGenerator.js +0 -196
  129. package/dist/service-management/generators/schemas/ServiceSchemaGenerator.js +0 -190
  130. package/dist/service-management/generators/scripts/DeployScriptGenerator.js +0 -123
  131. package/dist/service-management/generators/scripts/HealthCheckScriptGenerator.js +0 -101
  132. package/dist/service-management/generators/scripts/SetupScriptGenerator.js +0 -88
  133. package/dist/service-management/generators/service-types/StaticSiteGenerator.js +0 -342
  134. package/dist/service-management/generators/testing/EslintConfigGenerator.js +0 -85
  135. package/dist/service-management/generators/testing/IntegrationTestsGenerator.js +0 -237
  136. package/dist/service-management/generators/testing/JestConfigGenerator.js +0 -72
  137. package/dist/service-management/generators/testing/UnitTestsGenerator.js +0 -277
  138. package/dist/service-management/generators/tooling/DockerComposeGenerator.js +0 -71
  139. package/dist/service-management/generators/tooling/GitignoreGenerator.js +0 -143
  140. package/dist/service-management/generators/utils/FileWriter.js +0 -179
  141. package/dist/service-management/generators/utils/PathResolver.js +0 -157
  142. package/dist/service-management/generators/utils/ServiceManifestGenerator.js +0 -111
  143. package/dist/service-management/generators/utils/TemplateEngine.js +0 -185
  144. package/dist/service-management/generators/utils/index.js +0 -18
  145. package/dist/service-management/handlers/ConfirmationHandler.js +0 -71
  146. package/dist/service-management/handlers/GenerationHandler.js +0 -80
  147. package/dist/service-management/handlers/InputHandler.js +0 -59
  148. package/dist/service-management/handlers/ValidationHandler.js +0 -203
  149. package/dist/service-management/index.js +0 -14
  150. package/dist/service-management/routing/DomainRouteMapper.js +0 -311
  151. package/dist/service-management/routing/RouteGenerator.js +0 -266
  152. package/dist/service-management/routing/WranglerRoutesBuilder.js +0 -273
  153. package/dist/service-management/routing/index.js +0 -14
  154. package/dist/service-management/services/DirectoryStructureService.js +0 -56
  155. package/dist/service-management/services/GenerationCoordinator.js +0 -208
  156. package/dist/service-management/services/GeneratorRegistry.js +0 -174
  157. package/dist/services/GenericDataService.js +0 -501
  158. package/dist/ui-structures/concepts/second-order-acquisition-strategy.md +0 -286
  159. package/dist/ui-structures/concepts/service-lifecycle-management.md +0 -150
  160. package/dist/ui-structures/concepts/service-manifest-guide.md +0 -309
  161. package/dist/ui-structures/concepts/three-tier-categorization-strategy.md +0 -231
  162. package/dist/ui-structures/creation/automated-generation-ui.json +0 -246
  163. package/dist/ui-structures/creation/core-inputs-ui.json +0 -217
  164. package/dist/ui-structures/creation/smart-confirmable-ui.json +0 -451
  165. package/dist/ui-structures/reference/absolutely-required-inputs.json +0 -315
  166. package/dist/ui-structures/reference/service-manifest-template.json +0 -342
  167. package/dist/version/VersionDetector.js +0 -723
  168. package/dist/worker/index.js +0 -4
  169. package/dist/worker/integration.js +0 -351
@@ -1,244 +0,0 @@
1
- import { BaseGenerator } from '../BaseGenerator.js';
2
- import { join } from 'path';
3
- import { writeFileSync, mkdirSync } from 'fs';
4
-
5
- /**
6
- * Deployment Documentation Generator
7
- * Generates comprehensive deployment guide for all environments
8
- */
9
- export class DeploymentDocsGenerator extends BaseGenerator {
10
- /**
11
- * Generate deployment documentation
12
- * @param {Object} context - Generation context
13
- * @returns {Promise<string>} Path to generated deployment docs file
14
- */
15
- async generate(context) {
16
- const {
17
- coreInputs,
18
- confirmedValues,
19
- servicePath
20
- } = this.extractContext(context);
21
- if (!this.shouldGenerate(context)) {
22
- return null;
23
- }
24
-
25
- // Ensure docs directory exists
26
- const docsDir = join(servicePath, 'docs');
27
- mkdirSync(docsDir, {
28
- recursive: true
29
- });
30
- const deploymentDocsContent = this._generateDeploymentDocsContent(coreInputs, confirmedValues);
31
- const filePath = join(servicePath, 'docs', 'DEPLOYMENT.md');
32
- writeFileSync(filePath, deploymentDocsContent, 'utf8');
33
- return filePath;
34
- }
35
-
36
- /**
37
- * Generate deployment documentation content
38
- * @private
39
- */
40
- _generateDeploymentDocsContent(coreInputs, confirmedValues) {
41
- return `# ${confirmedValues.displayName} - Deployment Guide
42
-
43
- ## Overview
44
-
45
- This guide covers deploying ${confirmedValues.displayName} to different environments using the Clodo Framework.
46
-
47
- ## Environments
48
-
49
- ### Development
50
- - **URL**: ${confirmedValues.developmentUrl}
51
- - **Environment**: development
52
- - **Configuration**: \`config/development.env\`
53
-
54
- ### Staging
55
- - **URL**: ${confirmedValues.stagingUrl}
56
- - **Environment**: staging
57
- - **Configuration**: \`config/staging.env\`
58
-
59
- ### Production
60
- - **URL**: ${confirmedValues.productionUrl}
61
- - **Environment**: production
62
- - **Configuration**: \`config/production.env\`
63
-
64
- ## Prerequisites
65
-
66
- - Node.js 18+
67
- - Cloudflare account with Workers enabled
68
- - Wrangler CLI installed
69
- - PowerShell (for deployment scripts)
70
-
71
- ## Initial Setup
72
-
73
- 1. **Clone and setup**:
74
- \`\`\`bash
75
- git clone ${confirmedValues.gitRepositoryUrl}
76
- cd ${coreInputs.serviceName}
77
- .\\scripts\\setup.ps1
78
- \`\`\`
79
-
80
- 2. **Configure environment**:
81
- Edit \`.env\` with your Cloudflare credentials:
82
- \`\`\`bash
83
- CLOUDFLARE_ACCOUNT_ID=your_account_id
84
- CLOUDFLARE_ZONE_ID=your_zone_id
85
- CLOUDFLARE_API_TOKEN=your_api_token
86
- \`\`\`
87
-
88
- 3. **Setup database** (if enabled):
89
- ${confirmedValues.features.database ? `
90
- Create a Cloudflare D1 database and update \`wrangler.toml\`:
91
- \`\`\`toml
92
- [[d1_databases]]
93
- binding = "DB"
94
- database_name = "${confirmedValues.databaseName}"
95
- database_id = "your_database_id"
96
- \`\`\`
97
- ` : 'Database not required for this service type.'}
98
-
99
- ## Development Deployment
100
-
101
- \`\`\`bash
102
- # Start local development server
103
- npm run dev
104
-
105
- # Server will be available at http://localhost:8787
106
- \`\`\`
107
-
108
- ## Staging Deployment
109
-
110
- \`\`\`bash
111
- # Deploy to staging
112
- .\\scripts\\deploy.ps1 -Environment staging
113
-
114
- # Run health checks
115
- .\\scripts\\health-check.ps1 -Environment staging
116
- \`\`\`
117
-
118
- ## Production Deployment
119
-
120
- \`\`\`bash
121
- # Deploy to production
122
- .\\scripts\\deploy.ps1 -Environment production
123
-
124
- # Verify deployment
125
- .\\scripts\\health-check.ps1 -Environment production
126
- \`\`\`
127
-
128
- ## Automated Deployment
129
-
130
- ### GitHub Actions
131
-
132
- The service includes GitHub Actions workflows for automated deployment:
133
-
134
- - **CI**: Runs on every push to main branch
135
- - **Deploy**: Deploys to staging on successful CI
136
- - **Release**: Deploys to production on tag creation
137
-
138
- ### Manual CI/CD
139
-
140
- \`\`\`bash
141
- # Run full CI pipeline locally
142
- npm run lint
143
- npm test
144
- npm run build
145
-
146
- # Deploy if all checks pass
147
- .\\scripts\\deploy.ps1 -Environment production
148
- \`\`\`
149
-
150
- ## Monitoring and Health Checks
151
-
152
- ### Health Check Endpoint
153
-
154
- \`\`\`bash
155
- curl ${confirmedValues.productionUrl}${confirmedValues.healthCheckPath}
156
- \`\`\`
157
-
158
- ### Automated Health Monitoring
159
-
160
- The deployment scripts include automated health checks. For production monitoring, consider:
161
-
162
- - Cloudflare Analytics
163
- - External monitoring services
164
- - Log aggregation tools
165
-
166
- ## Rollback Strategy
167
-
168
- ### Quick Rollback
169
-
170
- \`\`\`bash
171
- # Deploy previous version
172
- wrangler deploy --env production
173
-
174
- # Or redeploy from git
175
- git checkout previous-version
176
- npm run deploy
177
- \`\`\`
178
-
179
- ### Database Rollback
180
-
181
- ${confirmedValues.features.database ? `
182
- If database schema changes need rollback:
183
-
184
- 1. Restore from backup
185
- 2. Run migration rollback scripts
186
- 3. Update wrangler.toml if needed
187
- ` : 'No database rollback required for this service type.'}
188
-
189
- ## Troubleshooting
190
-
191
- ### Common Issues
192
-
193
- 1. **Deployment fails with authentication error**
194
- - Check Cloudflare API token permissions
195
- - Verify account ID and zone ID
196
-
197
- 2. **Health check fails**
198
- - Check database connectivity
199
- - Verify environment variables
200
- - Review worker logs
201
-
202
- 3. **API returns 500 errors**
203
- - Check worker logs in Cloudflare dashboard
204
- - Verify service configuration
205
- - Test locally first
206
-
207
- ### Logs and Debugging
208
-
209
- \`\`\`bash
210
- # View worker logs
211
- wrangler tail
212
-
213
- # Check deployment status
214
- wrangler deployments list
215
-
216
- # View environment info
217
- wrangler whoami
218
- \`\`\`
219
-
220
- ## Security Considerations
221
-
222
- - Store secrets in Cloudflare Workers secrets, not environment variables
223
- - Use HTTPS for all production endpoints
224
- - Implement proper authentication and authorization
225
- - Regularly rotate API tokens
226
- - Monitor for unusual activity
227
-
228
- ## Performance Optimization
229
-
230
- - Enable caching where appropriate
231
- - Use appropriate database indexes
232
- - Monitor response times
233
- - Optimize bundle size
234
- - Consider edge deployment locations
235
- `;
236
- }
237
-
238
- /**
239
- * Determine if generator should run
240
- */
241
- shouldGenerate(context) {
242
- return true; // Always generate deployment documentation
243
- }
244
- }
@@ -1,196 +0,0 @@
1
- import { BaseGenerator } from '../BaseGenerator.js';
2
- import { join } from 'path';
3
- import { writeFileSync } from 'fs';
4
-
5
- /**
6
- * README Generator
7
- * Generates comprehensive README.md documentation for services
8
- */
9
- export class ReadmeGenerator extends BaseGenerator {
10
- /**
11
- * Generate README.md
12
- * @param {Object} context - Generation context
13
- * @returns {Promise<string>} Path to generated README file
14
- */
15
- async generate(context) {
16
- const {
17
- coreInputs,
18
- confirmedValues,
19
- servicePath
20
- } = this.extractContext(context);
21
- if (!this.shouldGenerate(context)) {
22
- return null;
23
- }
24
- const readmeContent = this._generateReadmeContent(coreInputs, confirmedValues);
25
- const filePath = join(servicePath, 'README.md');
26
- writeFileSync(filePath, readmeContent, 'utf8');
27
- return filePath;
28
- }
29
-
30
- /**
31
- * Generate README content
32
- * @private
33
- */
34
- _generateReadmeContent(coreInputs, confirmedValues) {
35
- return `# ${confirmedValues.displayName}
36
-
37
- ${confirmedValues.description}
38
-
39
- ## 🚀 Quick Start
40
-
41
- \\\`\\\`\\\`bash
42
- # Setup development environment
43
- .\\\\scripts\\\\setup.ps1
44
-
45
- # Start development server
46
- npm run dev
47
-
48
- # Run tests
49
- npm test
50
-
51
- # Deploy to production
52
- .\\\\scripts\\\\deploy.ps1 -Environment production
53
- \\\`\\\`\\\`
54
-
55
- ## 📋 Features
56
-
57
- ${Object.entries(confirmedValues.features).filter(([, enabled]) => enabled).map(([feature]) => `- ✅ ${feature.replace(/([A-Z])/g, ' $1').toLowerCase()}`).join('\n')}
58
-
59
- ## 🏗️ Architecture
60
-
61
- This service is built with the **Clodo Framework** and follows a three-tier architecture:
62
-
63
- 1. **Input Collection**: Collects and validates service requirements
64
- 2. **Smart Confirmations**: Generates and confirms derived configuration values
65
- 3. **Automated Generation**: Creates all necessary configuration files and components
66
-
67
- ## 📁 Project Structure
68
-
69
- \`\`\`
70
- ${coreInputs.serviceName}/
71
- ├── src/
72
- │ ├── config/
73
- │ │ └── domains.js # Domain configuration
74
- │ ├── worker/
75
- │ │ └── index.js # Cloudflare Worker entry point
76
- │ ├── handlers/
77
- │ │ └── service-handlers.js # Request handlers
78
- │ ├── middleware/
79
- │ │ └── service-middleware.js # Request/response middleware
80
- │ ├── schemas/
81
- │ │ └── service-schema.js # Data validation schemas
82
- │ └── utils/
83
- │ └── service-utils.js # Utility functions
84
- ├── scripts/
85
- │ ├── deploy.ps1 # Deployment script
86
- │ ├── setup.ps1 # Environment setup
87
- │ └── health-check.ps1 # Health monitoring
88
- ├── test/
89
- │ ├── unit/ # Unit tests
90
- │ └── integration/ # Integration tests
91
- ├── config/ # Environment configurations
92
- ├── docs/ # Documentation
93
- └── wrangler.toml # Cloudflare Workers config
94
- \`\`\`
95
-
96
- ## 🔧 Configuration
97
-
98
- ### Environment Variables
99
-
100
- Copy \`.env.example\` to \`.env\` and configure:
101
-
102
- \`\`\`bash
103
- # Cloudflare Configuration
104
- CLOUDFLARE_ACCOUNT_ID=your_account_id
105
- CLOUDFLARE_ZONE_ID=your_zone_id
106
- CLOUDFLARE_API_TOKEN=your_api_token
107
-
108
- # Service Configuration
109
- SERVICE_NAME=${coreInputs.serviceName}
110
- SERVICE_TYPE=${coreInputs.serviceType}
111
- DOMAIN_NAME=${coreInputs.domainName}
112
- ENVIRONMENT=${coreInputs.environment}
113
- \`\`\`
114
-
115
- ### Service URLs
116
-
117
- - **Production**: ${confirmedValues.productionUrl}
118
- - **Staging**: ${confirmedValues.stagingUrl}
119
- - **Development**: ${confirmedValues.developmentUrl}
120
- - **Documentation**: ${confirmedValues.documentationUrl}
121
-
122
- ## 🧪 Testing
123
-
124
- \`\`\`bash
125
- # Run all tests
126
- npm test
127
-
128
- # Run with coverage
129
- npm run test:coverage
130
-
131
- # Run integration tests only
132
- npm test -- --testPathPattern=integration
133
- \`\`\`
134
-
135
- ## 🚀 Deployment
136
-
137
- ### Development
138
-
139
- \`\`\`bash
140
- npm run dev
141
- \`\`\`
142
-
143
- ### Staging
144
-
145
- \`\`\`bash
146
- .\\scripts\\deploy.ps1 -Environment staging
147
- \`\`\`
148
-
149
- ### Production
150
-
151
- \`\`\`bash
152
- .\\scripts\\deploy.ps1 -Environment production
153
- \`\`\`
154
-
155
- ## 🏥 Health Checks
156
-
157
- \`\`\`bash
158
- # Check service health
159
- .\\scripts\\health-check.ps1 -Environment production
160
- \`\`\`
161
-
162
- Health check endpoint: \`${confirmedValues.healthCheckPath}\`
163
-
164
- ## 📚 API Documentation
165
-
166
- API Base Path: \`${confirmedValues.apiBasePath}\`
167
-
168
- See [API Documentation](./docs/API.md) for detailed endpoint information.
169
-
170
- ## 🤝 Contributing
171
-
172
- 1. Fork the repository
173
- 2. Create a feature branch
174
- 3. Make your changes
175
- 4. Add tests
176
- 5. Submit a pull request
177
-
178
- ## 📄 License
179
-
180
- ${confirmedValues.author} - Generated by Clodo Framework v3.0.0
181
-
182
- ## 🔗 Links
183
-
184
- - **Repository**: ${confirmedValues.gitRepositoryUrl}
185
- - **Documentation**: ${confirmedValues.documentationUrl}
186
- - **Health Check**: ${confirmedValues.productionUrl}${confirmedValues.healthCheckPath}
187
- `;
188
- }
189
-
190
- /**
191
- * Determine if generator should run
192
- */
193
- shouldGenerate(context) {
194
- return true; // Always generate README
195
- }
196
- }
@@ -1,190 +0,0 @@
1
- import { BaseGenerator } from '../BaseGenerator.js';
2
- import { join } from 'path';
3
-
4
- /**
5
- * ServiceSchemaGenerator
6
- *
7
- * Generates src/schemas/service-schema.js with Zod schemas.
8
- */
9
- export class ServiceSchemaGenerator extends BaseGenerator {
10
- constructor(options = {}) {
11
- super({
12
- name: 'ServiceSchemaGenerator',
13
- description: 'Generates service Zod schemas',
14
- outputPath: 'src/schemas/service-schema.js',
15
- ...options
16
- });
17
- }
18
- shouldGenerate(context) {
19
- return true;
20
- }
21
- async generate(context) {
22
- const coreInputs = context.coreInputs || context;
23
- const confirmedValues = context.confirmedValues || context;
24
- const servicePath = context.servicePath || context.outputDir;
25
- this.setContext({
26
- coreInputs,
27
- confirmedValues,
28
- servicePath
29
- });
30
- const typeSchemas = this._generateTypeSpecificSchemas(coreInputs.serviceType);
31
- const content = `/**
32
- * ${confirmedValues.displayName} - Service Schema
33
- *
34
- * Generated by Clodo Framework GenerationEngine
35
- * Service Type: ${coreInputs.serviceType}
36
- */
37
-
38
- import { z } from 'zod';
39
-
40
- // Base service schema
41
- export const baseServiceSchema = z.object({
42
- id: z.string().uuid(),
43
- createdAt: z.date(),
44
- updatedAt: z.date(),
45
- version: z.string().default('${confirmedValues.version}')
46
- });
47
-
48
- // Service-specific schemas based on type
49
- ${typeSchemas}
50
-
51
- // Request/Response schemas
52
- export const healthCheckResponseSchema = z.object({
53
- status: z.enum(['healthy', 'unhealthy']),
54
- timestamp: z.string().datetime(),
55
- service: z.string(),
56
- version: z.string(),
57
- environment: z.string()
58
- });
59
-
60
- export const errorResponseSchema = z.object({
61
- error: z.string(),
62
- message: z.string(),
63
- timestamp: z.string().datetime(),
64
- service: z.string(),
65
- version: z.string()
66
- });
67
-
68
- // Validation helpers
69
- export function validateServiceRequest(data, schema) {
70
- try {
71
- return { success: true, data: schema.parse(data) };
72
- } catch (error) {
73
- return {
74
- success: false,
75
- error: error.errors.map(err => ({
76
- field: err.path.join('.'),
77
- message: err.message
78
- }))
79
- };
80
- }
81
- }
82
-
83
- export function createServiceResponse(data, schema) {
84
- try {
85
- return { success: true, data: schema.parse(data) };
86
- } catch (error) {
87
- throw new Error(\`Response validation failed: \${error.message}\`);
88
- }
89
- }
90
- `;
91
- await this.writeFile(join('src', 'schemas', 'service-schema.js'), content);
92
- return join(servicePath, 'src', 'schemas', 'service-schema.js');
93
- }
94
- _generateTypeSpecificSchemas(serviceType) {
95
- const schemas = {
96
- 'data-service': `export const dataItemSchema = z.object({
97
- id: z.string().uuid(),
98
- name: z.string().min(1).max(100),
99
- description: z.string().max(500).optional(),
100
- data: z.record(z.any()),
101
- tags: z.array(z.string()).optional(),
102
- status: z.enum(['active', 'inactive', 'archived']).default('active')
103
- });
104
-
105
- export const dataQuerySchema = z.object({
106
- limit: z.number().min(1).max(100).default(20),
107
- offset: z.number().min(0).default(0),
108
- search: z.string().optional(),
109
- filters: z.record(z.any()).optional(),
110
- sortBy: z.string().optional(),
111
- sortOrder: z.enum(['asc', 'desc']).default('asc')
112
- });`,
113
- 'auth-service': `export const userSchema = z.object({
114
- id: z.string().uuid(),
115
- email: z.string().email(),
116
- username: z.string().min(3).max(50),
117
- displayName: z.string().min(1).max(100),
118
- roles: z.array(z.string()),
119
- isActive: z.boolean().default(true),
120
- lastLogin: z.date().optional(),
121
- emailVerified: z.boolean().default(false)
122
- });
123
-
124
- export const authTokenSchema = z.object({
125
- token: z.string(),
126
- type: z.enum(['access', 'refresh']),
127
- expiresAt: z.date(),
128
- userId: z.string().uuid(),
129
- scopes: z.array(z.string())
130
- });`,
131
- 'content-service': `export const contentItemSchema = z.object({
132
- id: z.string().uuid(),
133
- title: z.string().min(1).max(200),
134
- content: z.string(),
135
- contentType: z.enum(['article', 'page', 'media', 'document']),
136
- slug: z.string().min(1).max(100),
137
- author: z.string(),
138
- published: z.boolean().default(false),
139
- publishedAt: z.date().optional(),
140
- tags: z.array(z.string()),
141
- metadata: z.record(z.any())
142
- });
143
-
144
- export const mediaAssetSchema = z.object({
145
- id: z.string().uuid(),
146
- filename: z.string(),
147
- originalName: z.string(),
148
- mimeType: z.string(),
149
- size: z.number(),
150
- url: z.string(),
151
- thumbnailUrl: z.string().optional(),
152
- altText: z.string().optional()
153
- });`,
154
- 'api-gateway': `export const apiRouteSchema = z.object({
155
- path: z.string().regex(/^\\/.*/),
156
- method: z.enum(['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'OPTIONS']),
157
- targetService: z.string(),
158
- targetPath: z.string(),
159
- rateLimit: z.number().optional(),
160
- authentication: z.boolean().default(false),
161
- authorization: z.array(z.string()).optional()
162
- });
163
-
164
- export const apiMetricsSchema = z.object({
165
- route: z.string(),
166
- method: z.string(),
167
- responseTime: z.number(),
168
- statusCode: z.number(),
169
- timestamp: z.date(),
170
- userAgent: z.string().optional(),
171
- ipAddress: z.string().optional()
172
- });`,
173
- 'generic': `export const genericItemSchema = z.object({
174
- id: z.string().uuid(),
175
- type: z.string(),
176
- data: z.record(z.any()),
177
- metadata: z.record(z.any()).optional()
178
- });`
179
- };
180
- return schemas[serviceType] || schemas.generic;
181
- }
182
- validateContext(context) {
183
- const coreInputs = context.coreInputs || context;
184
- const confirmedValues = context.confirmedValues || context;
185
- if (!coreInputs.serviceType || !confirmedValues.version || !confirmedValues.displayName) {
186
- throw new Error('ServiceSchemaGenerator: Missing required fields');
187
- }
188
- return true;
189
- }
190
- }