@tamyla/clodo-framework 1.0.0

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 (130) hide show
  1. package/CHANGELOG.md +564 -0
  2. package/LICENSE +21 -0
  3. package/README.md +1393 -0
  4. package/bin/README.md +71 -0
  5. package/bin/clodo-service.js +416 -0
  6. package/bin/security/security-cli.js +96 -0
  7. package/bin/service-management/README.md +74 -0
  8. package/bin/service-management/create-service.js +129 -0
  9. package/bin/service-management/init-service.js +102 -0
  10. package/bin/service-management/init-service.js.backup +889 -0
  11. package/bin/shared/config/customer-cli.js +293 -0
  12. package/dist/config/ConfigurationManager.js +159 -0
  13. package/dist/config/CustomerConfigCLI.js +220 -0
  14. package/dist/config/FeatureManager.js +426 -0
  15. package/dist/config/customers.js +441 -0
  16. package/dist/config/domains.js +180 -0
  17. package/dist/config/features.js +225 -0
  18. package/dist/config/index.js +6 -0
  19. package/dist/database/database-orchestrator.js +730 -0
  20. package/dist/database/index.js +4 -0
  21. package/dist/deployment/auditor.js +971 -0
  22. package/dist/deployment/index.js +10 -0
  23. package/dist/deployment/rollback-manager.js +523 -0
  24. package/dist/deployment/testers/api-tester.js +80 -0
  25. package/dist/deployment/testers/auth-tester.js +129 -0
  26. package/dist/deployment/testers/core.js +217 -0
  27. package/dist/deployment/testers/database-tester.js +105 -0
  28. package/dist/deployment/testers/index.js +74 -0
  29. package/dist/deployment/testers/load-tester.js +120 -0
  30. package/dist/deployment/testers/performance-tester.js +105 -0
  31. package/dist/deployment/validator.js +558 -0
  32. package/dist/deployment/wrangler-deployer.js +574 -0
  33. package/dist/handlers/GenericRouteHandler.js +532 -0
  34. package/dist/index.js +39 -0
  35. package/dist/migration/MigrationAdapters.js +562 -0
  36. package/dist/modules/ModuleManager.js +668 -0
  37. package/dist/modules/security.js +98 -0
  38. package/dist/orchestration/cross-domain-coordinator.js +1083 -0
  39. package/dist/orchestration/index.js +5 -0
  40. package/dist/orchestration/modules/DeploymentCoordinator.js +258 -0
  41. package/dist/orchestration/modules/DomainResolver.js +196 -0
  42. package/dist/orchestration/modules/StateManager.js +332 -0
  43. package/dist/orchestration/multi-domain-orchestrator.js +255 -0
  44. package/dist/routing/EnhancedRouter.js +158 -0
  45. package/dist/schema/SchemaManager.js +778 -0
  46. package/dist/security/ConfigurationValidator.js +490 -0
  47. package/dist/security/DeploymentManager.js +208 -0
  48. package/dist/security/SecretGenerator.js +142 -0
  49. package/dist/security/SecurityCLI.js +228 -0
  50. package/dist/security/index.js +51 -0
  51. package/dist/security/patterns/environment-rules.js +66 -0
  52. package/dist/security/patterns/insecure-patterns.js +21 -0
  53. package/dist/service-management/ConfirmationEngine.js +411 -0
  54. package/dist/service-management/ErrorTracker.js +294 -0
  55. package/dist/service-management/GenerationEngine.js +3109 -0
  56. package/dist/service-management/InputCollector.js +237 -0
  57. package/dist/service-management/ServiceCreator.js +229 -0
  58. package/dist/service-management/ServiceInitializer.js +448 -0
  59. package/dist/service-management/ServiceOrchestrator.js +638 -0
  60. package/dist/service-management/handlers/ConfigMutator.js +130 -0
  61. package/dist/service-management/handlers/ConfirmationHandler.js +71 -0
  62. package/dist/service-management/handlers/GenerationHandler.js +80 -0
  63. package/dist/service-management/handlers/InputHandler.js +59 -0
  64. package/dist/service-management/handlers/ValidationHandler.js +203 -0
  65. package/dist/service-management/index.js +7 -0
  66. package/dist/services/GenericDataService.js +488 -0
  67. package/dist/shared/cloudflare/domain-discovery.js +562 -0
  68. package/dist/shared/cloudflare/domain-manager.js +912 -0
  69. package/dist/shared/cloudflare/index.js +8 -0
  70. package/dist/shared/cloudflare/ops.js +387 -0
  71. package/dist/shared/config/cache.js +1167 -0
  72. package/dist/shared/config/command-config-manager.js +174 -0
  73. package/dist/shared/config/customer-cli.js +258 -0
  74. package/dist/shared/config/index.js +9 -0
  75. package/dist/shared/config/manager.js +289 -0
  76. package/dist/shared/database/connection-manager.js +338 -0
  77. package/dist/shared/database/index.js +7 -0
  78. package/dist/shared/database/orchestrator.js +632 -0
  79. package/dist/shared/deployment/auditor.js +971 -0
  80. package/dist/shared/deployment/index.js +10 -0
  81. package/dist/shared/deployment/rollback-manager.js +523 -0
  82. package/dist/shared/deployment/validator.js +558 -0
  83. package/dist/shared/index.js +32 -0
  84. package/dist/shared/monitoring/health-checker.js +250 -0
  85. package/dist/shared/monitoring/index.js +8 -0
  86. package/dist/shared/monitoring/memory-manager.js +382 -0
  87. package/dist/shared/monitoring/production-monitor.js +390 -0
  88. package/dist/shared/production-tester/api-tester.js +80 -0
  89. package/dist/shared/production-tester/auth-tester.js +129 -0
  90. package/dist/shared/production-tester/core.js +217 -0
  91. package/dist/shared/production-tester/database-tester.js +105 -0
  92. package/dist/shared/production-tester/index.js +74 -0
  93. package/dist/shared/production-tester/load-tester.js +120 -0
  94. package/dist/shared/production-tester/performance-tester.js +105 -0
  95. package/dist/shared/security/api-token-manager.js +296 -0
  96. package/dist/shared/security/index.js +8 -0
  97. package/dist/shared/security/secret-generator.js +918 -0
  98. package/dist/shared/security/secure-token-manager.js +379 -0
  99. package/dist/shared/utils/error-recovery.js +240 -0
  100. package/dist/shared/utils/graceful-shutdown-manager.js +380 -0
  101. package/dist/shared/utils/index.js +9 -0
  102. package/dist/shared/utils/interactive-prompts.js +134 -0
  103. package/dist/shared/utils/rate-limiter.js +249 -0
  104. package/dist/utils/ErrorHandler.js +173 -0
  105. package/dist/utils/deployment/config-cache.js +1160 -0
  106. package/dist/utils/deployment/index.js +6 -0
  107. package/dist/utils/deployment/interactive-prompts.js +97 -0
  108. package/dist/utils/deployment/secret-generator.js +896 -0
  109. package/dist/utils/dirname-helper.js +35 -0
  110. package/dist/utils/domain-config.js +159 -0
  111. package/dist/utils/error-recovery.js +240 -0
  112. package/dist/utils/esm-helper.js +52 -0
  113. package/dist/utils/framework-config.js +481 -0
  114. package/dist/utils/graceful-shutdown-manager.js +379 -0
  115. package/dist/utils/health-checker.js +114 -0
  116. package/dist/utils/index.js +36 -0
  117. package/dist/utils/prompt-handler.js +98 -0
  118. package/dist/utils/usage-tracker.js +252 -0
  119. package/dist/utils/validation.js +112 -0
  120. package/dist/version/VersionDetector.js +723 -0
  121. package/dist/worker/index.js +4 -0
  122. package/dist/worker/integration.js +332 -0
  123. package/docs/FRAMEWORK-ARCHITECTURE-OVERVIEW.md +206 -0
  124. package/docs/INTEGRATION_GUIDE.md +2045 -0
  125. package/docs/README.md +82 -0
  126. package/docs/SECURITY.md +242 -0
  127. package/docs/deployment/deployment-guide.md +540 -0
  128. package/docs/overview.md +280 -0
  129. package/package.json +176 -0
  130. package/types/index.d.ts +575 -0
package/docs/README.md ADDED
@@ -0,0 +1,82 @@
1
+ # Clodo Framework Documentation
2
+
3
+ > A comprehensive framework for building Clodo-style microservices on Cloudflare Workers + D1
4
+
5
+ ## 📚 Documentation Structure
6
+
7
+ ### **Getting Started**
8
+ - **[Overview](./overview.md)** - Framework philosophy and core concepts
9
+ - **[Developer Guide](./guides/developer-guide.md)** - Comprehensive guide for external developers
10
+ - **[Quick Start Guide](./guides/getting-started.md)** - Build your first service in 5 minutes
11
+ - **[Installation](./guides/installation.md)** - Setup and prerequisites
12
+
13
+ ### **Architecture**
14
+ - **[Framework Architecture Overview](./FRAMEWORK-ARCHITECTURE-OVERVIEW.md)** - User-friendly architecture guide
15
+ - **[Framework Architecture Analysis](./FRAMEWORK-ARCHITECTURE-ANALYSIS.md)** - Detailed technical analysis (internal)
16
+ - **[Core Components](./architecture/components.md)** - Deep dive into framework modules
17
+ - **[Configuration System](./architecture/configuration.md)** - Domain and feature management
18
+ - **[Data Layer](./architecture/data-layer.md)** - Services, schemas, and database integration
19
+ - **[Worker Integration](./architecture/worker-integration.md)** - Cloudflare Workers patterns
20
+
21
+ ### **Guides**
22
+ - **[Creating Services](./guides/creating-services.md)** - Service generation and templates
23
+ - **[Domain Configuration](./guides/domain-configuration.md)** - Multi-tenant setup
24
+ - **[Feature Management](./guides/feature-flags.md)** - Feature flags and runtime control
25
+ - **[Authentication](./guides/authentication.md)** - Security patterns and implementation
26
+ - **[Database Operations](./guides/database-operations.md)** - CRUD patterns and data modeling
27
+
28
+ ### **Deployment**
29
+ - **[Environment Setup](./deployment/environment-setup.md)** - Cloudflare and local development
30
+ - **[Deployment Guide](./deployment/deployment-guide.md)** - Production deployment strategies
31
+ - **[CI/CD Integration](./deployment/ci-cd.md)** - Automated deployment pipelines
32
+ - **[Monitoring](./deployment/monitoring.md)** - Observability and debugging
33
+
34
+ ### **API Reference**
35
+ - **[Core Classes](./api/core-classes.md)** - Framework class references
36
+ - **[Configuration API](./api/configuration.md)** - Domain and feature APIs
37
+ - **[Service API](./api/services.md)** - Data service interfaces
38
+ - **[Worker Helpers](./api/worker-helpers.md)** - Cloudflare Worker utilities
39
+ - **[CLI Tools](./api/cli-tools.md)** - Command-line interface documentation
40
+
41
+ ### **Examples**
42
+ - **[Basic CRUD Service](./examples/basic-crud.md)** - Simple data service example
43
+ - **[Multi-Tenant SaaS](./examples/multi-tenant-saas.md)** - Complex multi-domain setup
44
+ - **[Authentication Service](./examples/auth-service.md)** - JWT-based authentication
45
+ - **[API Gateway](./examples/api-gateway.md)** - Service orchestration patterns
46
+
47
+ ### **Decision Framework**
48
+ - **[When to Use](./decision-framework.md)** - Use cases and anti-patterns
49
+ - **[Alternatives](./alternatives.md)** - Other approaches and trade-offs
50
+ - **[Migration Guide](./migration-guide.md)** - Moving to/from the framework
51
+
52
+ ## 🚀 Quick Navigation
53
+
54
+ | I want to... | Go to |
55
+ |--------------|--------|
56
+ | **Understand the framework** | [Overview](./overview.md) |
57
+ | **Learn comprehensive usage** | [Developer Guide](./guides/developer-guide.md) |
58
+ | **Build my first service** | [Getting Started](./guides/getting-started.md) |
59
+ | **Configure domains** | [Domain Configuration](./guides/domain-configuration.md) |
60
+ | **Deploy to production** | [Deployment Guide](./deployment/deployment-guide.md) |
61
+ | **Find API documentation** | [API Reference](./api/README.md) |
62
+ | **See real examples** | [Examples](./examples/README.md) |
63
+ | **Decide if this is right for me** | [Decision Framework](./decision-framework.md) |
64
+
65
+ ## 🆘 Getting Help
66
+
67
+ - **Documentation Issues**: Open an issue in the repository
68
+ - **Framework Bugs**: Report via GitHub Issues
69
+ - **Questions**: Check existing issues or create a new discussion
70
+ - **Contributing**: See [Contributing Guide](../CONTRIBUTING.md)
71
+
72
+ ## 🔗 External Resources
73
+
74
+ - **[Cloudflare Workers Documentation](https://developers.cloudflare.com/workers/)**
75
+ - **[D1 Database Documentation](https://developers.cloudflare.com/d1/)**
76
+ - **[Wrangler CLI Documentation](https://developers.cloudflare.com/workers/wrangler/)**
77
+
78
+ ---
79
+
80
+ **Framework Version**: 1.0.0
81
+ **Last Updated**: September 27, 2025
82
+ **Cloudflare Workers Runtime**: Compatible with 2023-05-18 and later
@@ -0,0 +1,242 @@
1
+ # Clodo Framework Security Module
2
+
3
+ The Security Module provides comprehensive security validation and management capabilities for Clodo Framework services, preventing insecure configurations from reaching production environments.
4
+
5
+ ## Features
6
+
7
+ - **Configuration Validation**: Automated detection of dummy API keys, weak secrets, and insecure URLs
8
+ - **Environment-Specific Rules**: Different security requirements for development, staging, and production
9
+ - **Secure Key Generation**: Cryptographically secure key generation utilities
10
+ - **Deployment Security**: Pre-deployment validation hooks that block insecure deployments
11
+ - **CLI Tools**: Command-line interface for security operations
12
+
13
+ ## Quick Start
14
+
15
+ ### Basic Usage
16
+
17
+ ```javascript
18
+ import { validateSecurity, generateSecureKey } from '@tamyla/clodo-framework/security';
19
+
20
+ // Validate configuration
21
+ const config = {
22
+ API_KEY: 'my-secret-key',
23
+ DATABASE_URL: 'https://prod-db.example.com'
24
+ };
25
+
26
+ const issues = validateSecurity(config, 'production');
27
+ if (issues.length > 0) {
28
+ console.error('Security issues found:', issues);
29
+ }
30
+
31
+ // Generate secure keys
32
+ const apiKey = generateSecureKey('api', { length: 32 });
33
+ const jwtSecret = generateSecureKey('jwt', { length: 64 });
34
+ ```
35
+
36
+ ### Module Integration
37
+
38
+ ```javascript
39
+ import { securityModule } from '@tamyla/clodo-framework/modules/security';
40
+
41
+ // The security module automatically registers with the framework
42
+ // and provides pre-deployment validation hooks
43
+ ```
44
+
45
+ ### CLI Usage
46
+
47
+ ```bash
48
+ # Validate configuration security
49
+ npx clodo-security validate customer production
50
+
51
+ # Generate secure keys
52
+ npx clodo-security generate-key api
53
+ npx clodo-security generate-key jwt 64
54
+
55
+ # Deploy with security validation
56
+ npx clodo-security deploy customer production
57
+
58
+ # Generate secure configuration
59
+ npx clodo-security generate-config customer production
60
+
61
+ # Check deployment readiness
62
+ npx clodo-security check-readiness customer production
63
+ ```
64
+
65
+ ## Security Validation
66
+
67
+ ### Detected Issues
68
+
69
+ The security validator detects:
70
+
71
+ - **Dummy API Keys**: Common development/test keys that shouldn't be in production
72
+ - **Weak Secrets**: Passwords shorter than required length or using common patterns
73
+ - **Insecure URLs**: HTTP URLs in production or localhost URLs outside development
74
+ - **JWT Security**: Weak JWT secrets with insufficient entropy
75
+ - **Environment Mismatches**: Development settings in production environments
76
+
77
+ ### Environment Requirements
78
+
79
+ | Environment | Min Secret Length | HTTPS Required | Dummy Keys Allowed | Localhost Allowed |
80
+ |-------------|------------------|----------------|-------------------|-------------------|
81
+ | Development | 16 | No | Yes | Yes |
82
+ | Staging | 24 | Yes | No | No |
83
+ | Production | 32 | Yes | No | No |
84
+
85
+ ## API Reference
86
+
87
+ ### ConfigurationValidator
88
+
89
+ ```javascript
90
+ import { ConfigurationValidator } from '@tamyla/clodo-framework/security';
91
+
92
+ // Validate configuration object
93
+ const issues = ConfigurationValidator.validate(config, environment);
94
+
95
+ // Validate customer configuration file
96
+ const result = ConfigurationValidator.validateConfiguration(customer, environment);
97
+ ```
98
+
99
+ ### SecretGenerator
100
+
101
+ ```javascript
102
+ import { SecretGenerator } from '@tamyla/clodo-framework/security';
103
+
104
+ // Generate API key
105
+ const apiKey = SecretGenerator.generateSecureApiKey(length, prefix);
106
+
107
+ // Generate JWT secret
108
+ const jwtSecret = SecretGenerator.generateSecureJwtSecret(length);
109
+
110
+ // Generate service-specific key
111
+ const serviceKey = SecretGenerator.generateServiceKey('content-skimmer', 'prod');
112
+ ```
113
+
114
+ ### DeploymentManager
115
+
116
+ ```javascript
117
+ import { DeploymentManager } from '@tamyla/clodo-framework/security';
118
+
119
+ // Deploy with security validation
120
+ await DeploymentManager.deployWithSecurity({
121
+ customer: 'tamyla',
122
+ environment: 'production',
123
+ dryRun: false
124
+ });
125
+
126
+ // Generate secure configuration
127
+ const config = DeploymentManager.generateSecureConfig(customer, environment);
128
+ ```
129
+
130
+ ## Integration with Services
131
+
132
+ ### Automatic Security Validation
133
+
134
+ When using the Clodo Framework, security validation is automatically applied:
135
+
136
+ 1. **Pre-deployment Hook**: Configuration is validated before deployment
137
+ 2. **Critical Issue Blocking**: Deployments are blocked if critical security issues are found
138
+ 3. **Warning Reporting**: Non-critical issues are reported but don't block deployment
139
+
140
+ ### Manual Integration
141
+
142
+ For services not using the full framework:
143
+
144
+ ```javascript
145
+ import { securityModule } from '@tamyla/clodo-framework/modules/security';
146
+
147
+ // Register security hooks
148
+ moduleManager.registerModule('security', securityModule);
149
+
150
+ // Use security utilities
151
+ const issues = securityModule.validate(config, 'production');
152
+ const secureKey = securityModule.generateSecureKey('api-prefix');
153
+ ```
154
+
155
+ ## Security Patterns
156
+
157
+ ### Insecure Patterns Detected
158
+
159
+ The module maintains a comprehensive database of insecure patterns:
160
+
161
+ - Dummy API keys: `content-skimmer-dev-key`, `test-api-key-*`, etc.
162
+ - Weak secrets: `password`, `admin`, `123456`, etc.
163
+ - Development URLs: `localhost`, `dev.`, `test.`, etc.
164
+ - Weak JWT patterns: Short secrets, common words, simple patterns
165
+
166
+ ### Custom Patterns
167
+
168
+ You can extend the security patterns:
169
+
170
+ ```javascript
171
+ import { INSECURE_PATTERNS } from '@tamyla/clodo-framework/security';
172
+
173
+ // Add custom insecure patterns
174
+ INSECURE_PATTERNS.DUMMY_API_KEYS.push('my-custom-dummy-key');
175
+ ```
176
+
177
+ ## Best Practices
178
+
179
+ ### For Developers
180
+
181
+ 1. **Use Generated Keys**: Always use cryptographically secure generated keys
182
+ 2. **Environment Separation**: Keep development and production configurations separate
183
+ 3. **Regular Validation**: Run security validation before deployments
184
+ 4. **Secret Rotation**: Regularly rotate API keys and secrets
185
+
186
+ ### For Operations
187
+
188
+ 1. **Automated Validation**: Integrate security validation into CI/CD pipelines
189
+ 2. **Monitoring**: Monitor for security validation failures
190
+ 3. **Audit Logging**: Keep logs of security validation results
191
+ 4. **Compliance**: Use security validation for compliance requirements
192
+
193
+ ## Troubleshooting
194
+
195
+ ### Common Issues
196
+
197
+ **"Critical security issues detected"**
198
+ - Check for dummy API keys in production configuration
199
+ - Ensure all secrets meet minimum length requirements
200
+ - Verify HTTPS URLs are used in production
201
+
202
+ **"Deployment blocked by security validation"**
203
+ - Run `npx clodo-security validate <customer> <environment>` to see issues
204
+ - Generate secure keys with `npx clodo-security generate-key`
205
+ - Update configuration with secure values
206
+
207
+ **"Weak secret detected"**
208
+ - Use `SecretGenerator.generateSecureJwtSecret()` for JWT secrets
209
+ - Ensure secrets are at least 32 characters for production
210
+ - Avoid common words or patterns in secrets
211
+
212
+ ## Migration from Legacy Security
213
+
214
+ If migrating from the data-service security implementation:
215
+
216
+ 1. Update imports to use framework security:
217
+ ```javascript
218
+ // Before
219
+ const { ConfigurationSecurityValidator } = require('./tools/security-validator');
220
+
221
+ // After
222
+ const { ConfigurationValidator } = require('@tamyla/clodo-framework/security');
223
+ ```
224
+
225
+ 2. Update CLI commands:
226
+ ```bash
227
+ # Before
228
+ npm run security:validate
229
+
230
+ # After
231
+ npx clodo-security validate customer environment
232
+ ```
233
+
234
+ 3. Update deployment scripts to use framework security module
235
+
236
+ ## Future Enhancements
237
+
238
+ - Secret rotation scheduling
239
+ - External secret management integration
240
+ - Advanced compliance reporting
241
+ - Real-time security monitoring
242
+ - Automated vulnerability scanning