@tamyla/clodo-framework 3.1.5 → 3.1.9

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 (132) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/bin/clodo-service.js +29 -947
  3. package/bin/database/enterprise-db-manager.js +7 -5
  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 +0 -0
  7. package/bin/shared/cloudflare/domain-discovery.js +11 -10
  8. package/bin/shared/cloudflare/ops.js +1 -1
  9. package/bin/shared/config/ConfigurationManager.js +539 -0
  10. package/bin/shared/config/index.js +13 -1
  11. package/bin/shared/database/connection-manager.js +2 -2
  12. package/bin/shared/database/orchestrator.js +5 -4
  13. package/bin/shared/deployment/auditor.js +9 -8
  14. package/bin/shared/logging/Logger.js +214 -0
  15. package/bin/shared/monitoring/production-monitor.js +21 -9
  16. package/bin/shared/utils/ErrorHandler.js +675 -0
  17. package/bin/shared/utils/error-recovery.js +33 -13
  18. package/bin/shared/utils/file-manager.js +162 -0
  19. package/bin/shared/utils/formatters.js +247 -0
  20. package/bin/shared/utils/index.js +14 -4
  21. package/bin/shared/validation/ValidationRegistry.js +143 -0
  22. package/dist/bin/clodo-service-old.js +868 -0
  23. package/dist/bin/clodo-service-test.js +10 -0
  24. package/dist/bin/clodo-service.js +62 -0
  25. package/dist/bin/commands/assess.js +76 -0
  26. package/dist/bin/commands/create.js +56 -0
  27. package/dist/bin/commands/deploy.js +196 -0
  28. package/dist/bin/commands/diagnose.js +70 -0
  29. package/dist/bin/commands/helpers.js +138 -0
  30. package/dist/bin/commands/update.js +55 -0
  31. package/dist/bin/commands/validate.js +26 -0
  32. package/dist/bin/database/deployment-db-manager.js +423 -0
  33. package/dist/bin/database/enterprise-db-manager.js +457 -0
  34. package/dist/bin/database/wrangler-d1-manager.js +685 -0
  35. package/dist/bin/deployment/enterprise-deploy.js +877 -0
  36. package/dist/bin/deployment/master-deploy.js +1376 -0
  37. package/dist/bin/deployment/modular-enterprise-deploy.js +466 -0
  38. package/dist/bin/deployment/modules/DeploymentConfiguration.js +395 -0
  39. package/dist/bin/deployment/modules/DeploymentOrchestrator.js +492 -0
  40. package/dist/bin/deployment/modules/EnvironmentManager.js +517 -0
  41. package/dist/bin/deployment/modules/MonitoringIntegration.js +560 -0
  42. package/dist/bin/deployment/modules/ValidationManager.js +342 -0
  43. package/dist/bin/deployment/orchestration/BaseDeploymentOrchestrator.js +426 -0
  44. package/dist/bin/deployment/orchestration/EnterpriseOrchestrator.js +401 -0
  45. package/dist/bin/deployment/orchestration/PortfolioOrchestrator.js +273 -0
  46. package/dist/bin/deployment/orchestration/SingleServiceOrchestrator.js +231 -0
  47. package/dist/bin/deployment/orchestration/UnifiedDeploymentOrchestrator.js +662 -0
  48. package/dist/bin/deployment/test-interactive-utils.js +66 -0
  49. package/dist/bin/portfolio/portfolio-manager.js +487 -0
  50. package/dist/bin/security/security-cli.js +108 -0
  51. package/dist/bin/service-management/create-service.js +122 -0
  52. package/dist/bin/service-management/init-service.js +79 -0
  53. package/dist/{shared → bin/shared}/cloudflare/domain-discovery.js +11 -10
  54. package/dist/{shared → bin/shared}/cloudflare/ops.js +1 -1
  55. package/dist/bin/shared/config/ConfigurationManager.js +519 -0
  56. package/dist/{shared → bin/shared}/config/index.js +5 -1
  57. package/dist/{shared → bin/shared}/database/connection-manager.js +2 -2
  58. package/dist/{shared → bin/shared}/database/orchestrator.js +13 -4
  59. package/dist/{deployment → bin/shared/deployment}/auditor.js +23 -8
  60. package/dist/bin/shared/logging/Logger.js +209 -0
  61. package/dist/{shared → bin/shared}/monitoring/production-monitor.js +24 -8
  62. package/dist/{utils → bin/shared/utils}/ErrorHandler.js +306 -28
  63. package/dist/{utils → bin/shared/utils}/error-recovery.js +33 -13
  64. package/dist/bin/shared/utils/file-manager.js +155 -0
  65. package/dist/bin/shared/utils/formatters.js +215 -0
  66. package/dist/bin/shared/utils/index.js +19 -0
  67. package/dist/bin/shared/validation/ValidationRegistry.js +126 -0
  68. package/dist/deployment/index.js +10 -9
  69. package/dist/deployment/orchestration/BaseDeploymentOrchestrator.js +426 -0
  70. package/dist/deployment/orchestration/EnterpriseOrchestrator.js +401 -0
  71. package/dist/deployment/orchestration/PortfolioOrchestrator.js +273 -0
  72. package/dist/deployment/orchestration/SingleServiceOrchestrator.js +231 -0
  73. package/dist/deployment/orchestration/UnifiedDeploymentOrchestrator.js +662 -0
  74. package/dist/deployment/orchestration/index.js +17 -0
  75. package/dist/deployment/rollback-manager.js +21 -508
  76. package/dist/index.js +12 -0
  77. package/dist/orchestration/modules/DomainResolver.js +8 -6
  78. package/dist/orchestration/multi-domain-orchestrator.js +13 -1
  79. package/dist/security/index.js +2 -2
  80. package/dist/service-management/ConfirmationEngine.js +8 -7
  81. package/dist/service-management/ErrorTracker.js +7 -2
  82. package/dist/service-management/InputCollector.js +18 -12
  83. package/dist/service-management/ServiceCreator.js +22 -7
  84. package/dist/service-management/ServiceInitializer.js +12 -18
  85. package/dist/utils/config/unified-config-manager.js +14 -12
  86. package/dist/utils/deployment/config-cache.js +3 -1
  87. package/dist/utils/deployment/secret-generator.js +32 -29
  88. package/dist/utils/framework-config.js +6 -3
  89. package/dist/utils/ui-structures-loader.js +3 -0
  90. package/dist/worker/integration.js +11 -1
  91. package/package.json +36 -8
  92. package/dist/config/FeatureManager.js +0 -426
  93. package/dist/config/features.js +0 -230
  94. package/dist/shared/deployment/auditor.js +0 -971
  95. package/dist/shared/deployment/validator.js +0 -670
  96. package/dist/shared/production-tester/api-tester.js +0 -80
  97. package/dist/shared/production-tester/auth-tester.js +0 -129
  98. package/dist/shared/production-tester/core.js +0 -217
  99. package/dist/shared/production-tester/database-tester.js +0 -105
  100. package/dist/shared/production-tester/index.js +0 -74
  101. package/dist/shared/production-tester/load-tester.js +0 -120
  102. package/dist/shared/production-tester/performance-tester.js +0 -105
  103. package/dist/shared/utils/error-recovery.js +0 -240
  104. package/dist/shared/utils/index.js +0 -9
  105. /package/dist/{shared → bin/shared}/cloudflare/domain-manager.js +0 -0
  106. /package/dist/{shared → bin/shared}/cloudflare/index.js +0 -0
  107. /package/dist/{shared → bin/shared}/config/cache.js +0 -0
  108. /package/dist/{shared → bin/shared}/config/command-config-manager.js +0 -0
  109. /package/dist/{shared → bin/shared}/config/manager.js +0 -0
  110. /package/dist/{shared → bin/shared}/database/index.js +0 -0
  111. /package/dist/{shared → bin/shared}/deployment/index.js +0 -0
  112. /package/dist/{shared → bin/shared}/deployment/rollback-manager.js +0 -0
  113. /package/dist/{deployment → bin/shared/deployment}/validator.js +0 -0
  114. /package/dist/{shared → bin/shared}/index.js +0 -0
  115. /package/dist/{shared → bin/shared}/monitoring/health-checker.js +0 -0
  116. /package/dist/{shared → bin/shared}/monitoring/index.js +0 -0
  117. /package/dist/{shared → bin/shared}/monitoring/memory-manager.js +0 -0
  118. /package/dist/{deployment/testers → bin/shared/production-tester}/api-tester.js +0 -0
  119. /package/dist/{deployment/testers → bin/shared/production-tester}/auth-tester.js +0 -0
  120. /package/dist/{deployment/testers → bin/shared/production-tester}/core.js +0 -0
  121. /package/dist/{deployment/testers → bin/shared/production-tester}/database-tester.js +0 -0
  122. /package/dist/{deployment/testers → bin/shared/production-tester}/index.js +0 -0
  123. /package/dist/{deployment/testers → bin/shared/production-tester}/load-tester.js +0 -0
  124. /package/dist/{deployment/testers → bin/shared/production-tester}/performance-tester.js +0 -0
  125. /package/dist/{shared → bin/shared}/security/api-token-manager.js +0 -0
  126. /package/dist/{shared → bin/shared}/security/index.js +0 -0
  127. /package/dist/{shared → bin/shared}/security/secret-generator.js +0 -0
  128. /package/dist/{shared → bin/shared}/security/secure-token-manager.js +0 -0
  129. /package/dist/{shared → bin/shared}/utils/graceful-shutdown-manager.js +0 -0
  130. /package/dist/{shared → bin/shared}/utils/interactive-prompts.js +0 -0
  131. /package/dist/{shared → bin/shared}/utils/interactive-utils.js +0 -0
  132. /package/dist/{shared → bin/shared}/utils/rate-limiter.js +0 -0
@@ -0,0 +1,122 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Clodo Framework - Service Template Generator
5
+ * Creates new ser console.log(`✓ Using Clodo Framework ServiceCreator module`);ices from predefined templates
6
+ */
7
+ import { ServiceCreator } from '../../dist/service-management/ServiceCreator.js';
8
+ const SERVICE_TYPES = ['data-service', 'auth-service', 'content-service', 'api-gateway', 'generic'];
9
+ function showUsage() {
10
+ console.log(`
11
+ Clodo Framework - Service Template Generator
12
+
13
+ Usage: clodo-create-service <service-name> [options]
14
+
15
+ Arguments:
16
+ service-name Name of the service to create (required)
17
+
18
+ Options:
19
+ -t, --type <type> Service type: ${SERVICE_TYPES.join(', ')} (default: generic)
20
+ -o, --output <path> Output directory (default: current directory)
21
+ -f, --force Overwrite existing service directory
22
+ -h, --help Show this help message
23
+
24
+ Examples:
25
+ clodo-create-service my-data-service --type data-service
26
+ clodo-create-service auth-api --type auth-service --output ./services
27
+ clodo-create-service my-service --force
28
+ `);
29
+ }
30
+ function parseArgs(args) {
31
+ const options = {
32
+ type: 'generic',
33
+ output: process.cwd(),
34
+ force: false
35
+ };
36
+ let serviceName = null;
37
+ for (let i = 0; i < args.length; i++) {
38
+ const arg = args[i];
39
+ switch (arg) {
40
+ case '-t':
41
+ case '--type':
42
+ options.type = args[++i];
43
+ break;
44
+ case '-o':
45
+ case '--output':
46
+ options.output = args[++i];
47
+ break;
48
+ case '-f':
49
+ case '--force':
50
+ options.force = true;
51
+ break;
52
+ case '-h':
53
+ case '--help':
54
+ showUsage();
55
+ process.exit(0);
56
+ break;
57
+ default:
58
+ if (!arg.startsWith('-') && !serviceName) {
59
+ serviceName = arg;
60
+ } else {
61
+ console.error(`Unknown option: ${arg}`);
62
+ showUsage();
63
+ process.exit(1);
64
+ }
65
+ }
66
+ }
67
+ if (!serviceName) {
68
+ console.error('Error: Service name is required');
69
+ showUsage();
70
+ process.exit(1);
71
+ }
72
+ if (!SERVICE_TYPES.includes(options.type)) {
73
+ console.error(`Error: Invalid service type. Must be one of: ${SERVICE_TYPES.join(', ')}`);
74
+ process.exit(1);
75
+ }
76
+ return {
77
+ serviceName,
78
+ options
79
+ };
80
+ }
81
+
82
+ // Main execution
83
+ async function main() {
84
+ try {
85
+ const args = process.argv.slice(2);
86
+ const {
87
+ serviceName,
88
+ options
89
+ } = parseArgs(args);
90
+ console.log(`🚀 Creating ${options.type} service: ${serviceName}`);
91
+ console.log(`✓ Using Clodo Framework ServiceCreator module`);
92
+ console.log('');
93
+ const creator = new ServiceCreator();
94
+ const result = await creator.createService(serviceName, options);
95
+ if (result.success) {
96
+ console.log('✅ Service created successfully!');
97
+ console.log('');
98
+ console.log('📝 Next steps:');
99
+ console.log(` cd ${result.serviceDir.split('/').pop() || result.serviceDir.split('\\').pop()}`);
100
+ console.log(' npm install');
101
+ console.log(' npm run setup # Configure domain and Cloudflare settings');
102
+ console.log(' npm run dev # Start development server');
103
+ console.log('');
104
+ console.log('📚 Documentation:');
105
+ console.log(' README.md # Service documentation');
106
+ console.log(' API.md # API documentation');
107
+ console.log('');
108
+ console.log('🔗 Useful commands:');
109
+ console.log(' npm test # Run tests');
110
+ console.log(' npm run deploy # Deploy to Cloudflare');
111
+ } else {
112
+ console.error('❌ Service creation failed:', result.error);
113
+ process.exit(1);
114
+ }
115
+ } catch (error) {
116
+ console.error('❌ Unexpected error:', error.message);
117
+ process.exit(1);
118
+ }
119
+ }
120
+
121
+ // Run the generator
122
+ main();
@@ -0,0 +1,79 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Clodo Framework - Service Initializer
5
+ *
6
+ * Initializes a new service with auto-generated configurations,
7
+ * eliminating the need for manual wrangler.toml and domains.js setup.
8
+ *
9
+ * This solves the workflow order problem by making configuration
10
+ * generation the first step, not a prerequisite.
11
+ */
12
+ import { program } from 'commander';
13
+ import { ServiceInitializer } from '../../dist/service-management/ServiceInitializer.js';
14
+ const SERVICE_TYPES = ['generic', 'data-service', 'auth-service', 'content-service', 'api-gateway'];
15
+ class ServiceInitializerCLI {
16
+ constructor() {
17
+ this.setupCLI();
18
+ }
19
+ setupCLI() {
20
+ program.name('clodo-init-service').description('Initialize a Clodo Framework service with auto-generated configurations').version('1.0.0').argument('<service-name>', 'Name of the service to initialize').option('-t, --type <type>', 'Service type', 'generic').option('-d, --domains <domains>', 'Comma-separated list of domains (can include account info)').option('-e, --env <environment>', 'Target environment', 'development').option('--api-token <token>', 'Cloudflare API token for domain discovery').option('--account-id <id>', 'Default Cloudflare account ID').option('--zone-id <id>', 'Default Cloudflare zone ID').option('-o, --output <path>', 'Output directory (services will be created in a services/ subdirectory)', process.cwd()).option('-f, --force', 'Overwrite existing service directory').option('--dry-run', 'Show what would be created without creating files').option('--multi-domain', 'Generate configurations for multiple domains').action((serviceName, options) => {
21
+ this.initializeService(serviceName, options);
22
+ });
23
+ program.on('--help', () => {
24
+ console.log('\nExamples:');
25
+ console.log(' clodo-init-service my-api --type api-gateway --domains "api.example.com,staging.example.com"');
26
+ console.log(' clodo-init-service data-service --type data-service --api-token $CF_TOKEN');
27
+ console.log(' clodo-init-service my-service --env production --account-id $CF_ACCOUNT_ID');
28
+ console.log('\nServices are created in: ./services/{service-name}/');
29
+ console.log('\nEnvironment Variables:');
30
+ console.log(' CLOUDFLARE_API_TOKEN - API token for domain discovery');
31
+ console.log(' CLOUDFLARE_ACCOUNT_ID - Account ID for configurations');
32
+ console.log(' CLOUDFLARE_ZONE_ID - Zone ID for domain configurations');
33
+ });
34
+ }
35
+ async initializeService(serviceName, options) {
36
+ try {
37
+ console.log('🚀 Clodo Framework - Service Initializer');
38
+ console.log('='.repeat(50));
39
+ console.log('📦 Using Clodo Framework ServiceInitializer module');
40
+ console.log('');
41
+ const initializer = new ServiceInitializer();
42
+ const result = await initializer.initializeService(serviceName, {
43
+ type: options.type,
44
+ domains: options.domains,
45
+ env: options.env,
46
+ apiToken: options.apiToken,
47
+ accountId: options.accountId,
48
+ zoneId: options.zoneId,
49
+ output: options.output,
50
+ force: options.force,
51
+ dryRun: options.dryRun
52
+ });
53
+ if (result.success) {
54
+ if (result.dryRun) {
55
+ console.log('📋 Dry run - would create the following:');
56
+ const configs = Array.isArray(result.configs) ? result.configs : [result.configs];
57
+ console.log('Files:', configs.filter(Boolean).join(', '));
58
+ return;
59
+ }
60
+ console.log('\n✅ Service initialized successfully!');
61
+ console.log('\n📝 Next steps:');
62
+ console.log(` cd services/${serviceName}`);
63
+ console.log(' npm install');
64
+ console.log(' npm run dev # Start development server');
65
+ console.log(' npm run deploy # Deploy to Cloudflare');
66
+ } else {
67
+ console.error('\n❌ Initialization failed:', result.error);
68
+ process.exit(1);
69
+ }
70
+ } catch (error) {
71
+ console.error('\n❌ Unexpected error:', error.message);
72
+ process.exit(1);
73
+ }
74
+ }
75
+ }
76
+
77
+ // Run the CLI
78
+ const cli = new ServiceInitializerCLI();
79
+ program.parse();
@@ -9,6 +9,7 @@
9
9
  import { readFileSync, writeFileSync, existsSync, mkdirSync, readdirSync } from 'fs';
10
10
  import { join, dirname } from 'path';
11
11
  import { fileURLToPath } from 'url';
12
+ import { NameFormatters, UrlFormatters, ResourceFormatters, EnvironmentFormatters } from '../utils/Formatters.js';
12
13
  const __filename = fileURLToPath(import.meta.url);
13
14
  const __dirname = dirname(__filename);
14
15
 
@@ -185,7 +186,7 @@ export class DomainDiscovery {
185
186
  const config = {
186
187
  // Basic domain information
187
188
  name: cleanDomainName,
188
- displayName: this.capitalizeFirst(cleanDomainName),
189
+ displayName: NameFormatters.toDisplayName(cleanDomainName),
189
190
  fullDomain: domainName,
190
191
  // Cloudflare infrastructure
191
192
  accountId: account.id,
@@ -204,19 +205,19 @@ export class DomainDiscovery {
204
205
  // Service URLs
205
206
  services: {
206
207
  frontend: {
207
- production: `https://${domainName}`,
208
- staging: `https://staging.${domainName}`,
209
- development: `https://dev.${domainName}`
208
+ production: UrlFormatters.buildProductionUrl('www', domainName),
209
+ staging: UrlFormatters.buildStagingUrl('www', domainName),
210
+ development: UrlFormatters.buildDevUrl('www', domainName)
210
211
  },
211
212
  api: {
212
- production: `https://api.${domainName}`,
213
- staging: `https://api-staging.${domainName}`,
214
- development: `https://api-dev.${domainName}`
213
+ production: UrlFormatters.buildProductionUrl('api', domainName),
214
+ staging: UrlFormatters.buildStagingUrl('api', domainName),
215
+ development: UrlFormatters.buildDevUrl('api', domainName)
215
216
  },
216
217
  auth: {
217
- production: `https://auth.${domainName}`,
218
- staging: `https://auth-staging.${domainName}`,
219
- development: `https://auth-dev.${domainName}`
218
+ production: UrlFormatters.buildProductionUrl('auth', domainName),
219
+ staging: UrlFormatters.buildStagingUrl('auth', domainName),
220
+ development: UrlFormatters.buildDevUrl('auth', domainName)
220
221
  }
221
222
  },
222
223
  // CORS configuration
@@ -8,7 +8,7 @@
8
8
  import { exec } from 'child_process';
9
9
  import { promisify } from 'util';
10
10
  import { executeWithRateLimit } from '../utils/rate-limiter.js';
11
- import { ErrorRecoveryManager } from '../utils/error-recovery.js';
11
+ import { ErrorRecoveryManager } from '../utils/index.js';
12
12
  import { SecureTokenManager } from '../security/secure-token-manager.js';
13
13
  import { ProductionMonitor } from '../monitoring/production-monitor.js';
14
14
  import { DatabaseConnectionManager } from '../database/connection-manager.js';