@tamyla/clodo-framework 3.0.15 → 3.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/CHANGELOG.md +219 -153
  2. package/README.md +133 -1
  3. package/bin/clodo-service.js +1 -1
  4. package/bin/security/security-cli.js +0 -0
  5. package/bin/service-management/create-service.js +0 -0
  6. package/bin/service-management/init-service.js +2 -1
  7. package/dist/service-management/GenerationEngine.js +298 -3025
  8. package/dist/service-management/InputCollector.js +14 -0
  9. package/dist/service-management/ServiceCreator.js +19 -3
  10. package/dist/service-management/generators/BaseGenerator.js +233 -0
  11. package/dist/service-management/generators/GeneratorRegistry.js +254 -0
  12. package/dist/service-management/generators/cicd/CiWorkflowGenerator.js +87 -0
  13. package/dist/service-management/generators/cicd/DeployWorkflowGenerator.js +106 -0
  14. package/dist/service-management/generators/code/ServiceHandlersGenerator.js +235 -0
  15. package/dist/service-management/generators/code/ServiceMiddlewareGenerator.js +116 -0
  16. package/dist/service-management/generators/code/ServiceUtilsGenerator.js +246 -0
  17. package/dist/service-management/generators/code/WorkerIndexGenerator.js +143 -0
  18. package/dist/service-management/generators/config/DevelopmentEnvGenerator.js +101 -0
  19. package/dist/service-management/generators/config/DomainsConfigGenerator.js +175 -0
  20. package/dist/service-management/generators/config/EnvExampleGenerator.js +178 -0
  21. package/dist/service-management/generators/config/ProductionEnvGenerator.js +97 -0
  22. package/dist/service-management/generators/config/StagingEnvGenerator.js +97 -0
  23. package/dist/service-management/generators/config/WranglerTomlGenerator.js +238 -0
  24. package/dist/service-management/generators/core/PackageJsonGenerator.js +243 -0
  25. package/dist/service-management/generators/core/SiteConfigGenerator.js +115 -0
  26. package/dist/service-management/generators/documentation/ApiDocsGenerator.js +331 -0
  27. package/dist/service-management/generators/documentation/ConfigurationDocsGenerator.js +294 -0
  28. package/dist/service-management/generators/documentation/DeploymentDocsGenerator.js +244 -0
  29. package/dist/service-management/generators/documentation/ReadmeGenerator.js +196 -0
  30. package/dist/service-management/generators/schemas/ServiceSchemaGenerator.js +190 -0
  31. package/dist/service-management/generators/scripts/DeployScriptGenerator.js +123 -0
  32. package/dist/service-management/generators/scripts/HealthCheckScriptGenerator.js +101 -0
  33. package/dist/service-management/generators/scripts/SetupScriptGenerator.js +88 -0
  34. package/dist/service-management/generators/service-types/StaticSiteGenerator.js +342 -0
  35. package/dist/service-management/generators/testing/EslintConfigGenerator.js +85 -0
  36. package/dist/service-management/generators/testing/IntegrationTestsGenerator.js +237 -0
  37. package/dist/service-management/generators/testing/JestConfigGenerator.js +72 -0
  38. package/dist/service-management/generators/testing/UnitTestsGenerator.js +277 -0
  39. package/dist/service-management/generators/tooling/DockerComposeGenerator.js +71 -0
  40. package/dist/service-management/generators/tooling/GitignoreGenerator.js +143 -0
  41. package/dist/service-management/generators/utils/FileWriter.js +179 -0
  42. package/dist/service-management/generators/utils/PathResolver.js +157 -0
  43. package/dist/service-management/generators/utils/ServiceManifestGenerator.js +111 -0
  44. package/dist/service-management/generators/utils/TemplateEngine.js +185 -0
  45. package/dist/service-management/generators/utils/index.js +18 -0
  46. package/dist/service-management/routing/DomainRouteMapper.js +311 -0
  47. package/dist/service-management/routing/RouteGenerator.js +266 -0
  48. package/dist/service-management/routing/WranglerRoutesBuilder.js +273 -0
  49. package/dist/service-management/routing/index.js +14 -0
  50. package/dist/service-management/services/DirectoryStructureService.js +56 -0
  51. package/dist/service-management/services/GenerationCoordinator.js +208 -0
  52. package/dist/service-management/services/GeneratorRegistry.js +174 -0
  53. package/dist/services/GenericDataService.js +14 -1
  54. package/dist/utils/config/unified-config-manager.js +128 -12
  55. package/dist/utils/framework-config.js +74 -2
  56. package/dist/worker/integration.js +4 -1
  57. package/package.json +6 -1
  58. package/templates/generic/clodo-service-manifest.json +25 -0
  59. package/templates/static-site/.env.example +61 -0
  60. package/templates/static-site/README.md +176 -0
  61. package/templates/static-site/clodo-service-manifest.json +66 -0
  62. package/templates/static-site/package.json +28 -0
  63. package/templates/static-site/public/404.html +87 -0
  64. package/templates/static-site/public/app.js +100 -0
  65. package/templates/static-site/public/index.html +48 -0
  66. package/templates/static-site/public/styles.css +123 -0
  67. package/templates/static-site/scripts/deploy.ps1 +121 -0
  68. package/templates/static-site/scripts/setup.ps1 +179 -0
  69. package/templates/static-site/src/config/domains.js +35 -0
  70. package/templates/static-site/src/worker/index.js +153 -0
  71. package/templates/static-site/wrangler.toml +43 -0
@@ -0,0 +1,244 @@
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
+ }
@@ -0,0 +1,196 @@
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
+ }
@@ -0,0 +1,190 @@
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
+ }