@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.
- package/CHANGELOG.md +9 -0
- package/README.md +53 -0
- package/dist/bin/clodo-service.js +47 -15
- package/dist/bin/commands/deploy.js +115 -83
- package/dist/bin/commands/helpers/deployment-ui.js +138 -0
- package/dist/bin/commands/helpers/deployment-verification.js +251 -0
- package/dist/bin/commands/helpers/error-recovery.js +80 -0
- package/dist/bin/commands/helpers/resource-detection.js +113 -0
- package/dist/bin/commands/validate.js +1 -1
- package/dist/bin/security/security-cli.js +1 -1
- package/dist/bin/shared/cache/configuration-cache.js +82 -0
- package/dist/bin/shared/cloudflare/domain-manager.js +1 -1
- package/dist/bin/shared/cloudflare/index.js +1 -1
- package/dist/bin/shared/cloudflare/ops.js +6 -4
- package/dist/bin/shared/config/ConfigurationManager.js +23 -1
- package/dist/bin/shared/config/command-config-manager.js +19 -3
- package/dist/bin/shared/config/index.js +1 -1
- package/dist/bin/shared/deployment/credential-collector.js +30 -7
- package/dist/bin/shared/deployment/index.js +2 -2
- package/dist/bin/shared/deployment/rollback-manager.js +4 -520
- package/dist/bin/shared/deployment/utilities/d1-error-recovery.js +177 -0
- package/dist/bin/shared/deployment/validator.js +40 -10
- package/dist/bin/shared/deployment/workflows/deployment-summary.js +214 -0
- package/dist/bin/shared/deployment/workflows/interactive-confirmation.js +188 -0
- package/dist/bin/shared/deployment/workflows/interactive-database-workflow.js +234 -0
- package/dist/bin/shared/deployment/workflows/interactive-domain-info-gatherer.js +240 -0
- package/dist/bin/shared/deployment/workflows/interactive-secret-workflow.js +228 -0
- package/dist/bin/shared/deployment/workflows/interactive-testing-workflow.js +235 -0
- package/dist/bin/shared/deployment/workflows/interactive-validation.js +218 -0
- package/dist/bin/shared/error-handling/error-classifier.js +46 -0
- package/dist/bin/shared/monitoring/health-checker.js +129 -1
- package/dist/bin/shared/monitoring/memory-manager.js +17 -6
- package/dist/bin/shared/routing/domain-router.js +1 -1
- package/dist/bin/shared/utils/deployment-validator.js +97 -0
- package/dist/bin/shared/utils/formatters.js +10 -0
- package/dist/bin/shared/utils/index.js +13 -1
- package/dist/bin/shared/utils/interactive-prompts.js +34 -18
- package/dist/bin/shared/utils/progress-manager.js +2 -2
- package/dist/bin/shared/utils/progress-spinner.js +53 -0
- package/dist/bin/shared/utils/sensitive-redactor.js +91 -0
- package/dist/bin/shared/validation/ValidationRegistry.js +1 -1
- package/dist/security/index.js +1 -1
- package/dist/security/patterns/insecure-patterns.js +1 -1
- package/dist/utils/constants.js +102 -0
- package/dist/utils/deployment/wrangler-config-manager.js +215 -48
- package/dist/utils/framework-config.js +2 -2
- package/dist/utils/interactive-prompts.js +10 -59
- package/package.json +16 -8
- package/dist/bin/clodo-service-old.js +0 -868
- package/dist/bin/clodo-service-test.js +0 -10
- package/dist/bin/commands/assess.js +0 -91
- package/dist/bin/commands/create.js +0 -77
- package/dist/bin/commands/diagnose.js +0 -83
- package/dist/bin/commands/helpers.js +0 -138
- package/dist/bin/commands/update.js +0 -75
- package/dist/bin/database/deployment-db-manager.js +0 -423
- package/dist/bin/database/enterprise-db-manager.js +0 -457
- package/dist/bin/database/wrangler-d1-manager.js +0 -685
- package/dist/bin/deployment/enterprise-deploy.js +0 -877
- package/dist/bin/deployment/master-deploy.js +0 -1376
- package/dist/bin/deployment/modular-enterprise-deploy.js +0 -466
- package/dist/bin/deployment/modules/DeploymentConfiguration.js +0 -395
- package/dist/bin/deployment/modules/DeploymentOrchestrator.js +0 -492
- package/dist/bin/deployment/modules/EnvironmentManager.js +0 -517
- package/dist/bin/deployment/modules/MonitoringIntegration.js +0 -560
- package/dist/bin/deployment/modules/ValidationManager.js +0 -342
- package/dist/bin/deployment/orchestration/BaseDeploymentOrchestrator.js +0 -426
- package/dist/bin/deployment/orchestration/EnterpriseOrchestrator.js +0 -401
- package/dist/bin/deployment/orchestration/PortfolioOrchestrator.js +0 -273
- package/dist/bin/deployment/orchestration/SingleServiceOrchestrator.js +0 -231
- package/dist/bin/deployment/orchestration/UnifiedDeploymentOrchestrator.js +0 -662
- package/dist/bin/deployment/test-interactive-utils.js +0 -66
- package/dist/bin/portfolio/portfolio-manager.js +0 -487
- package/dist/bin/service-management/create-service.js +0 -122
- package/dist/bin/service-management/init-service.js +0 -79
- package/dist/config/customers.js +0 -623
- package/dist/config/domains.js +0 -186
- package/dist/config/index.js +0 -6
- package/dist/database/database-orchestrator.js +0 -795
- package/dist/database/index.js +0 -4
- package/dist/deployment/index.js +0 -11
- package/dist/deployment/orchestration/BaseDeploymentOrchestrator.js +0 -426
- package/dist/deployment/orchestration/EnterpriseOrchestrator.js +0 -401
- package/dist/deployment/orchestration/PortfolioOrchestrator.js +0 -273
- package/dist/deployment/orchestration/SingleServiceOrchestrator.js +0 -231
- package/dist/deployment/orchestration/UnifiedDeploymentOrchestrator.js +0 -662
- package/dist/deployment/orchestration/index.js +0 -17
- package/dist/deployment/rollback-manager.js +0 -36
- package/dist/deployment/wrangler-deployer.js +0 -640
- package/dist/handlers/GenericRouteHandler.js +0 -532
- package/dist/migration/MigrationAdapters.js +0 -562
- package/dist/modules/ModuleManager.js +0 -668
- package/dist/modules/security.js +0 -96
- package/dist/orchestration/cross-domain-coordinator.js +0 -1083
- package/dist/orchestration/index.js +0 -5
- package/dist/orchestration/modules/DeploymentCoordinator.js +0 -368
- package/dist/orchestration/modules/DomainResolver.js +0 -198
- package/dist/orchestration/modules/StateManager.js +0 -332
- package/dist/orchestration/multi-domain-orchestrator.js +0 -724
- package/dist/routing/EnhancedRouter.js +0 -158
- package/dist/schema/SchemaManager.js +0 -778
- package/dist/service-management/ConfirmationEngine.js +0 -412
- package/dist/service-management/ErrorTracker.js +0 -299
- package/dist/service-management/GenerationEngine.js +0 -447
- package/dist/service-management/InputCollector.js +0 -619
- package/dist/service-management/ServiceCreator.js +0 -265
- package/dist/service-management/ServiceInitializer.js +0 -453
- package/dist/service-management/ServiceOrchestrator.js +0 -633
- package/dist/service-management/generators/BaseGenerator.js +0 -233
- package/dist/service-management/generators/GeneratorRegistry.js +0 -254
- package/dist/service-management/generators/cicd/CiWorkflowGenerator.js +0 -87
- package/dist/service-management/generators/cicd/DeployWorkflowGenerator.js +0 -106
- package/dist/service-management/generators/code/ServiceHandlersGenerator.js +0 -235
- package/dist/service-management/generators/code/ServiceMiddlewareGenerator.js +0 -116
- package/dist/service-management/generators/code/ServiceUtilsGenerator.js +0 -246
- package/dist/service-management/generators/code/WorkerIndexGenerator.js +0 -143
- package/dist/service-management/generators/config/DevelopmentEnvGenerator.js +0 -101
- package/dist/service-management/generators/config/DomainsConfigGenerator.js +0 -175
- package/dist/service-management/generators/config/EnvExampleGenerator.js +0 -178
- package/dist/service-management/generators/config/ProductionEnvGenerator.js +0 -97
- package/dist/service-management/generators/config/StagingEnvGenerator.js +0 -97
- package/dist/service-management/generators/config/WranglerTomlGenerator.js +0 -238
- package/dist/service-management/generators/core/PackageJsonGenerator.js +0 -243
- package/dist/service-management/generators/core/SiteConfigGenerator.js +0 -115
- package/dist/service-management/generators/documentation/ApiDocsGenerator.js +0 -331
- package/dist/service-management/generators/documentation/ConfigurationDocsGenerator.js +0 -294
- package/dist/service-management/generators/documentation/DeploymentDocsGenerator.js +0 -244
- package/dist/service-management/generators/documentation/ReadmeGenerator.js +0 -196
- package/dist/service-management/generators/schemas/ServiceSchemaGenerator.js +0 -190
- package/dist/service-management/generators/scripts/DeployScriptGenerator.js +0 -123
- package/dist/service-management/generators/scripts/HealthCheckScriptGenerator.js +0 -101
- package/dist/service-management/generators/scripts/SetupScriptGenerator.js +0 -88
- package/dist/service-management/generators/service-types/StaticSiteGenerator.js +0 -342
- package/dist/service-management/generators/testing/EslintConfigGenerator.js +0 -85
- package/dist/service-management/generators/testing/IntegrationTestsGenerator.js +0 -237
- package/dist/service-management/generators/testing/JestConfigGenerator.js +0 -72
- package/dist/service-management/generators/testing/UnitTestsGenerator.js +0 -277
- package/dist/service-management/generators/tooling/DockerComposeGenerator.js +0 -71
- package/dist/service-management/generators/tooling/GitignoreGenerator.js +0 -143
- package/dist/service-management/generators/utils/FileWriter.js +0 -179
- package/dist/service-management/generators/utils/PathResolver.js +0 -157
- package/dist/service-management/generators/utils/ServiceManifestGenerator.js +0 -111
- package/dist/service-management/generators/utils/TemplateEngine.js +0 -185
- package/dist/service-management/generators/utils/index.js +0 -18
- package/dist/service-management/handlers/ConfirmationHandler.js +0 -71
- package/dist/service-management/handlers/GenerationHandler.js +0 -80
- package/dist/service-management/handlers/InputHandler.js +0 -59
- package/dist/service-management/handlers/ValidationHandler.js +0 -203
- package/dist/service-management/index.js +0 -14
- package/dist/service-management/routing/DomainRouteMapper.js +0 -311
- package/dist/service-management/routing/RouteGenerator.js +0 -266
- package/dist/service-management/routing/WranglerRoutesBuilder.js +0 -273
- package/dist/service-management/routing/index.js +0 -14
- package/dist/service-management/services/DirectoryStructureService.js +0 -56
- package/dist/service-management/services/GenerationCoordinator.js +0 -208
- package/dist/service-management/services/GeneratorRegistry.js +0 -174
- package/dist/services/GenericDataService.js +0 -501
- package/dist/ui-structures/concepts/second-order-acquisition-strategy.md +0 -286
- package/dist/ui-structures/concepts/service-lifecycle-management.md +0 -150
- package/dist/ui-structures/concepts/service-manifest-guide.md +0 -309
- package/dist/ui-structures/concepts/three-tier-categorization-strategy.md +0 -231
- package/dist/ui-structures/creation/automated-generation-ui.json +0 -246
- package/dist/ui-structures/creation/core-inputs-ui.json +0 -217
- package/dist/ui-structures/creation/smart-confirmable-ui.json +0 -451
- package/dist/ui-structures/reference/absolutely-required-inputs.json +0 -315
- package/dist/ui-structures/reference/service-manifest-template.json +0 -342
- package/dist/version/VersionDetector.js +0 -723
- package/dist/worker/index.js +0 -4
- package/dist/worker/integration.js +0 -351
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { BaseGenerator } from '../BaseGenerator.js';
|
|
2
|
-
import { join } from 'path';
|
|
3
|
-
import { writeFileSync } from 'fs';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* ESLint Configuration Generator
|
|
7
|
-
* Generates ESLint linting configuration for code quality
|
|
8
|
-
*/
|
|
9
|
-
export class EslintConfigGenerator extends BaseGenerator {
|
|
10
|
-
/**
|
|
11
|
-
* Generate ESLint configuration
|
|
12
|
-
* @param {Object} context - Generation context
|
|
13
|
-
* @returns {Promise<string>} Path to generated config 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 eslintConfig = this._generateEslintConfig(coreInputs, confirmedValues);
|
|
25
|
-
const filePath = join(servicePath, '.eslintrc.js');
|
|
26
|
-
writeFileSync(filePath, eslintConfig, 'utf8');
|
|
27
|
-
return filePath;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Generate ESLint configuration content
|
|
32
|
-
* @private
|
|
33
|
-
*/
|
|
34
|
-
_generateEslintConfig(coreInputs, confirmedValues) {
|
|
35
|
-
return `export default [
|
|
36
|
-
{
|
|
37
|
-
languageOptions: {
|
|
38
|
-
ecmaVersion: 2022,
|
|
39
|
-
sourceType: 'module',
|
|
40
|
-
globals: {
|
|
41
|
-
console: 'readonly',
|
|
42
|
-
process: 'readonly',
|
|
43
|
-
Buffer: 'readonly',
|
|
44
|
-
crypto: 'readonly',
|
|
45
|
-
fetch: 'readonly',
|
|
46
|
-
Request: 'readonly',
|
|
47
|
-
Response: 'readonly',
|
|
48
|
-
URL: 'readonly',
|
|
49
|
-
Headers: 'readonly',
|
|
50
|
-
describe: 'readonly',
|
|
51
|
-
test: 'readonly',
|
|
52
|
-
expect: 'readonly',
|
|
53
|
-
beforeAll: 'readonly',
|
|
54
|
-
afterAll: 'readonly',
|
|
55
|
-
beforeEach: 'readonly',
|
|
56
|
-
afterEach: 'readonly'
|
|
57
|
-
}
|
|
58
|
-
},
|
|
59
|
-
rules: {
|
|
60
|
-
'no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
|
|
61
|
-
'no-console': 'off', // Cloudflare Workers use console
|
|
62
|
-
'prefer-const': 'error',
|
|
63
|
-
'no-var': 'error',
|
|
64
|
-
'object-shorthand': 'error',
|
|
65
|
-
'prefer-arrow-callback': 'error',
|
|
66
|
-
'no-multiple-empty-lines': ['error', { max: 2, maxEOF: 0 }],
|
|
67
|
-
'semi': ['error', 'always'],
|
|
68
|
-
'quotes': ['error', 'single', { avoidEscape: true }],
|
|
69
|
-
'comma-dangle': ['error', 'never'],
|
|
70
|
-
'indent': ['error', 2, { SwitchCase: 1 }],
|
|
71
|
-
'linebreak-style': ['error', 'unix'],
|
|
72
|
-
'eol-last': ['error', 'always']
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
];
|
|
76
|
-
`;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Determine if generator should run
|
|
81
|
-
*/
|
|
82
|
-
shouldGenerate(context) {
|
|
83
|
-
return true; // Always generate ESLint config
|
|
84
|
-
}
|
|
85
|
-
}
|
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
import { BaseGenerator } from '../BaseGenerator.js';
|
|
2
|
-
import { join } from 'path';
|
|
3
|
-
import { writeFileSync, mkdirSync } from 'fs';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Integration Tests Generator
|
|
7
|
-
* Generates integration tests for end-to-end service testing
|
|
8
|
-
*/
|
|
9
|
-
export class IntegrationTestsGenerator extends BaseGenerator {
|
|
10
|
-
/**
|
|
11
|
-
* Generate integration tests
|
|
12
|
-
* @param {Object} context - Generation context
|
|
13
|
-
* @returns {Promise<string>} Path to generated test 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 test/integration directory exists
|
|
26
|
-
const testDir = join(servicePath, 'test', 'integration');
|
|
27
|
-
mkdirSync(testDir, {
|
|
28
|
-
recursive: true
|
|
29
|
-
});
|
|
30
|
-
const integrationTestContent = this._generateIntegrationTestContent(coreInputs, confirmedValues);
|
|
31
|
-
const filePath = join(testDir, 'service.integration.test.js');
|
|
32
|
-
writeFileSync(filePath, integrationTestContent, 'utf8');
|
|
33
|
-
return filePath;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Generate integration test content
|
|
38
|
-
* @private
|
|
39
|
-
*/
|
|
40
|
-
_generateIntegrationTestContent(coreInputs, confirmedValues) {
|
|
41
|
-
return `import { describe, test, expect, beforeAll, afterAll } from '@jest/globals';
|
|
42
|
-
|
|
43
|
-
describe('${confirmedValues.displayName} - Integration Tests', () => {
|
|
44
|
-
let baseUrl;
|
|
45
|
-
|
|
46
|
-
beforeAll(() => {
|
|
47
|
-
baseUrl = process.env.TEST_URL || '${confirmedValues.developmentUrl}';
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
afterAll(() => {
|
|
51
|
-
// Cleanup after tests
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
describe('Health Check Endpoint', () => {
|
|
55
|
-
test('responds with 200 status', async () => {
|
|
56
|
-
const response = await fetch(\`\${baseUrl}${confirmedValues.healthCheckPath}\`);
|
|
57
|
-
expect(response.status).toBe(200);
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
test('returns valid health check response', async () => {
|
|
61
|
-
const response = await fetch(\`\${baseUrl}${confirmedValues.healthCheckPath}\`);
|
|
62
|
-
const json = await response.json();
|
|
63
|
-
|
|
64
|
-
expect(json.status).toBe('healthy');
|
|
65
|
-
expect(json.service).toBe('${coreInputs.serviceName}');
|
|
66
|
-
expect(json.version).toBe('${confirmedValues.version}');
|
|
67
|
-
expect(json.timestamp).toBeDefined();
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
test('includes health checks', async () => {
|
|
71
|
-
const response = await fetch(\`\${baseUrl}${confirmedValues.healthCheckPath}\`);
|
|
72
|
-
const json = await response.json();
|
|
73
|
-
|
|
74
|
-
expect(Array.isArray(json.checks)).toBe(true);
|
|
75
|
-
expect(json.checks.length).toBeGreaterThan(0);
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
describe('API Endpoints', () => {
|
|
80
|
-
test('base API path is accessible', async () => {
|
|
81
|
-
const response = await fetch(\`\${baseUrl}${confirmedValues.apiBasePath}\`);
|
|
82
|
-
expect(response.status).toBeLessThan(500); // Should not be a server error
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
${this._generateServiceTypeTests(coreInputs.serviceType, confirmedValues)}
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
${confirmedValues.features.caching ? `
|
|
89
|
-
describe('Caching', () => {
|
|
90
|
-
test('cache headers are present', async () => {
|
|
91
|
-
const response = await fetch(\`\${baseUrl}${confirmedValues.healthCheckPath}\`);
|
|
92
|
-
|
|
93
|
-
// Check for cache-related headers
|
|
94
|
-
const cacheControl = response.headers.get('cache-control');
|
|
95
|
-
expect(cacheControl).toBeDefined();
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
test('repeated requests use cache', async () => {
|
|
99
|
-
const response1 = await fetch(\`\${baseUrl}${confirmedValues.healthCheckPath}\`);
|
|
100
|
-
const response2 = await fetch(\`\${baseUrl}${confirmedValues.healthCheckPath}\`);
|
|
101
|
-
|
|
102
|
-
expect(response1.status).toBe(200);
|
|
103
|
-
expect(response2.status).toBe(200);
|
|
104
|
-
});
|
|
105
|
-
});` : ''}
|
|
106
|
-
|
|
107
|
-
${confirmedValues.features.database ? `
|
|
108
|
-
describe('Database Integration', () => {
|
|
109
|
-
test('database connectivity', async () => {
|
|
110
|
-
const response = await fetch(\`\${baseUrl}${confirmedValues.healthCheckPath}\`);
|
|
111
|
-
const json = await response.json();
|
|
112
|
-
|
|
113
|
-
const dbCheck = json.checks.find(check => check.name === 'database');
|
|
114
|
-
expect(dbCheck).toBeDefined();
|
|
115
|
-
expect(dbCheck.status).toBe('healthy');
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
test('CRUD operations', async () => {
|
|
119
|
-
// Test Create, Read, Update, Delete operations
|
|
120
|
-
expect(true).toBe(true); // Placeholder
|
|
121
|
-
});
|
|
122
|
-
});` : `
|
|
123
|
-
describe('Database Integration', () => {
|
|
124
|
-
test.skip('database tests skipped - not enabled for this service type', () => {
|
|
125
|
-
expect(true).toBe(true);
|
|
126
|
-
});
|
|
127
|
-
});`}
|
|
128
|
-
|
|
129
|
-
describe('Middleware Integration', () => {
|
|
130
|
-
test('request headers added', async () => {
|
|
131
|
-
const response = await fetch(\`\${baseUrl}${confirmedValues.healthCheckPath}\`);
|
|
132
|
-
|
|
133
|
-
expect(response.headers.get('x-service')).toBe('${coreInputs.serviceName}');
|
|
134
|
-
expect(response.headers.get('x-version')).toBe('${confirmedValues.version}');
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
${confirmedValues.features.authentication ? `
|
|
138
|
-
test('authentication middleware', async () => {
|
|
139
|
-
// Test authentication requirements
|
|
140
|
-
expect(true).toBe(true); // Placeholder
|
|
141
|
-
});` : ''}
|
|
142
|
-
|
|
143
|
-
${confirmedValues.features.authorization ? `
|
|
144
|
-
test('authorization middleware', async () => {
|
|
145
|
-
// Test authorization checks
|
|
146
|
-
expect(true).toBe(true); // Placeholder
|
|
147
|
-
});` : ''}
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
describe('Error Handling', () => {
|
|
151
|
-
test('graceful error responses', async () => {
|
|
152
|
-
// Test error scenarios
|
|
153
|
-
expect(true).toBe(true); // Placeholder
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
test('error logging', async () => {
|
|
157
|
-
// Test error logging functionality
|
|
158
|
-
expect(true).toBe(true); // Placeholder
|
|
159
|
-
});
|
|
160
|
-
});
|
|
161
|
-
});
|
|
162
|
-
`;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* Generate service-type specific integration tests
|
|
167
|
-
* @private
|
|
168
|
-
*/
|
|
169
|
-
_generateServiceTypeTests(serviceType, confirmedValues) {
|
|
170
|
-
switch (serviceType) {
|
|
171
|
-
case 'data-service':
|
|
172
|
-
return `test('data retrieval endpoint', async () => {
|
|
173
|
-
const response = await fetch(\`\${baseUrl}${confirmedValues.apiBasePath}/data\`);
|
|
174
|
-
expect(response.status).toBeLessThan(500);
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
test('data storage endpoint', async () => {
|
|
178
|
-
const response = await fetch(\`\${baseUrl}${confirmedValues.apiBasePath}/data\`, {
|
|
179
|
-
method: 'POST',
|
|
180
|
-
headers: { 'Content-Type': 'application/json' },
|
|
181
|
-
body: JSON.stringify({ test: 'data' })
|
|
182
|
-
});
|
|
183
|
-
expect(response.status).toBeLessThan(500);
|
|
184
|
-
});`;
|
|
185
|
-
case 'auth-service':
|
|
186
|
-
return `test('login endpoint', async () => {
|
|
187
|
-
const response = await fetch(\`\${baseUrl}${confirmedValues.apiBasePath}/login\`, {
|
|
188
|
-
method: 'POST',
|
|
189
|
-
headers: { 'Content-Type': 'application/json' },
|
|
190
|
-
body: JSON.stringify({ username: 'test', password: 'test' })
|
|
191
|
-
});
|
|
192
|
-
expect(response.status).toBeLessThan(500);
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
test('token validation endpoint', async () => {
|
|
196
|
-
const response = await fetch(\`\${baseUrl}${confirmedValues.apiBasePath}/validate\`);
|
|
197
|
-
expect(response.status).toBeLessThan(500);
|
|
198
|
-
});`;
|
|
199
|
-
case 'content-service':
|
|
200
|
-
return `test('content retrieval endpoint', async () => {
|
|
201
|
-
const response = await fetch(\`\${baseUrl}${confirmedValues.apiBasePath}/content\`);
|
|
202
|
-
expect(response.status).toBeLessThan(500);
|
|
203
|
-
});
|
|
204
|
-
|
|
205
|
-
test('content creation endpoint', async () => {
|
|
206
|
-
const response = await fetch(\`\${baseUrl}${confirmedValues.apiBasePath}/content\`, {
|
|
207
|
-
method: 'POST',
|
|
208
|
-
headers: { 'Content-Type': 'application/json' },
|
|
209
|
-
body: JSON.stringify({ title: 'Test', body: 'Content' })
|
|
210
|
-
});
|
|
211
|
-
expect(response.status).toBeLessThan(500);
|
|
212
|
-
});`;
|
|
213
|
-
case 'api-gateway':
|
|
214
|
-
return `test('gateway routing', async () => {
|
|
215
|
-
const response = await fetch(\`\${baseUrl}${confirmedValues.apiBasePath}/route\`);
|
|
216
|
-
expect(response.status).toBeLessThan(500);
|
|
217
|
-
});
|
|
218
|
-
|
|
219
|
-
test('service proxying', async () => {
|
|
220
|
-
const response = await fetch(\`\${baseUrl}${confirmedValues.apiBasePath}/proxy\`);
|
|
221
|
-
expect(response.status).toBeLessThan(500);
|
|
222
|
-
});`;
|
|
223
|
-
default:
|
|
224
|
-
return `test('service endpoints are accessible', async () => {
|
|
225
|
-
const response = await fetch(\`\${baseUrl}${confirmedValues.apiBasePath}\`);
|
|
226
|
-
expect(response.status).toBeLessThan(500);
|
|
227
|
-
});`;
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
/**
|
|
232
|
-
* Determine if generator should run
|
|
233
|
-
*/
|
|
234
|
-
shouldGenerate(context) {
|
|
235
|
-
return true; // Always generate integration tests
|
|
236
|
-
}
|
|
237
|
-
}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { BaseGenerator } from '../BaseGenerator.js';
|
|
2
|
-
import { join } from 'path';
|
|
3
|
-
import { writeFileSync } from 'fs';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Jest Configuration Generator
|
|
7
|
-
* Generates Jest test runner configuration
|
|
8
|
-
*/
|
|
9
|
-
export class JestConfigGenerator extends BaseGenerator {
|
|
10
|
-
/**
|
|
11
|
-
* Generate Jest configuration
|
|
12
|
-
* @param {Object} context - Generation context
|
|
13
|
-
* @returns {Promise<string>} Path to generated config 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 jestConfig = this._generateJestConfig(coreInputs, confirmedValues);
|
|
25
|
-
const filePath = join(servicePath, 'jest.config.js');
|
|
26
|
-
writeFileSync(filePath, jestConfig, 'utf8');
|
|
27
|
-
return filePath;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Generate Jest configuration content
|
|
32
|
-
* @private
|
|
33
|
-
*/
|
|
34
|
-
_generateJestConfig(coreInputs, confirmedValues) {
|
|
35
|
-
return `/** @type {import('jest').Config} */
|
|
36
|
-
export default {
|
|
37
|
-
testEnvironment: 'node',
|
|
38
|
-
testMatch: [
|
|
39
|
-
'<rootDir>/test/**/*.test.js'
|
|
40
|
-
],
|
|
41
|
-
collectCoverageFrom: [
|
|
42
|
-
'src/**/*.js',
|
|
43
|
-
'!src/worker/index.js' // Worker code runs in different environment
|
|
44
|
-
],
|
|
45
|
-
coverageDirectory: 'coverage',
|
|
46
|
-
coverageReporters: ['text', 'lcov', 'html'],
|
|
47
|
-
coverageThreshold: {
|
|
48
|
-
global: {
|
|
49
|
-
branches: 70,
|
|
50
|
-
functions: 80,
|
|
51
|
-
lines: 80,
|
|
52
|
-
statements: 80
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
setupFilesAfterEnv: ['<rootDir>/test/setup.js'],
|
|
56
|
-
testTimeout: 10000,
|
|
57
|
-
verbose: true,
|
|
58
|
-
transform: {},
|
|
59
|
-
moduleNameMapper: {
|
|
60
|
-
'^(\\.{1,2}/.*)\\.js$': '$1'
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
`;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Determine if generator should run
|
|
68
|
-
*/
|
|
69
|
-
shouldGenerate(context) {
|
|
70
|
-
return true; // Always generate Jest config
|
|
71
|
-
}
|
|
72
|
-
}
|
|
@@ -1,277 +0,0 @@
|
|
|
1
|
-
import { BaseGenerator } from '../BaseGenerator.js';
|
|
2
|
-
import { join } from 'path';
|
|
3
|
-
import { writeFileSync, mkdirSync } from 'fs';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Unit Tests Generator
|
|
7
|
-
* Generates comprehensive unit test suites for service components
|
|
8
|
-
*/
|
|
9
|
-
export class UnitTestsGenerator extends BaseGenerator {
|
|
10
|
-
/**
|
|
11
|
-
* Generate unit tests
|
|
12
|
-
* @param {Object} context - Generation context
|
|
13
|
-
* @param {Object} context.coreInputs - Core service inputs
|
|
14
|
-
* @param {Object} context.confirmedValues - Confirmed configuration values
|
|
15
|
-
* @param {string} context.servicePath - Service directory path
|
|
16
|
-
* @returns {Promise<string>} Path to generated test file
|
|
17
|
-
*/
|
|
18
|
-
async generate(context) {
|
|
19
|
-
const {
|
|
20
|
-
coreInputs,
|
|
21
|
-
confirmedValues,
|
|
22
|
-
servicePath
|
|
23
|
-
} = this.extractContext(context);
|
|
24
|
-
if (!this.shouldGenerate(context)) {
|
|
25
|
-
return null;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// Ensure test/unit directory exists
|
|
29
|
-
const testDir = join(servicePath, 'test', 'unit');
|
|
30
|
-
mkdirSync(testDir, {
|
|
31
|
-
recursive: true
|
|
32
|
-
});
|
|
33
|
-
const unitTestContent = this._generateUnitTestContent(coreInputs, confirmedValues);
|
|
34
|
-
const filePath = join(testDir, 'service.test.js');
|
|
35
|
-
writeFileSync(filePath, unitTestContent, 'utf8');
|
|
36
|
-
return filePath;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Generate unit test content
|
|
41
|
-
* @private
|
|
42
|
-
*/
|
|
43
|
-
_generateUnitTestContent(coreInputs, confirmedValues) {
|
|
44
|
-
return `import { describe, test, expect } from '@jest/globals';
|
|
45
|
-
import serviceHandlers from '../../src/handlers/service-handlers.js';
|
|
46
|
-
import serviceMiddleware from '../../src/middleware/service-middleware.js';
|
|
47
|
-
import serviceUtils from '../../src/utils/service-utils.js';
|
|
48
|
-
import serviceSchema from '../../src/schemas/service-schema.js';
|
|
49
|
-
|
|
50
|
-
describe('${confirmedValues.displayName} - Unit Tests', () => {
|
|
51
|
-
describe('Handlers', () => {
|
|
52
|
-
test('exports required handler functions', () => {
|
|
53
|
-
expect(typeof serviceHandlers.handleRequest).toBe('function');
|
|
54
|
-
expect(typeof serviceHandlers.handleError).toBe('function');
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
test('handleError returns proper error response', async () => {
|
|
58
|
-
const error = new Error('Test error');
|
|
59
|
-
const request = new Request('https://example.com/test');
|
|
60
|
-
|
|
61
|
-
const response = await serviceHandlers.handleError(error, request);
|
|
62
|
-
expect(response.status).toBeGreaterThanOrEqual(400);
|
|
63
|
-
|
|
64
|
-
const json = await response.json();
|
|
65
|
-
expect(json.success).toBe(false);
|
|
66
|
-
expect(json.error).toBeDefined();
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
${confirmedValues.features.caching ? `
|
|
70
|
-
test('cache handlers work correctly', () => {
|
|
71
|
-
expect(typeof serviceHandlers.handleCacheHit).toBe('function');
|
|
72
|
-
expect(typeof serviceHandlers.handleCacheMiss).toBe('function');
|
|
73
|
-
});` : ''}
|
|
74
|
-
|
|
75
|
-
${confirmedValues.features.database ? `
|
|
76
|
-
test('database handlers are defined', () => {
|
|
77
|
-
expect(typeof serviceHandlers.handleDatabaseQuery).toBe('function');
|
|
78
|
-
expect(typeof serviceHandlers.handleDatabaseError).toBe('function');
|
|
79
|
-
});` : ''}
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
describe('Middleware', () => {
|
|
83
|
-
test('exports middleware functions', () => {
|
|
84
|
-
expect(typeof serviceMiddleware.addHeaders).toBe('function');
|
|
85
|
-
expect(typeof serviceMiddleware.handleCors).toBe('function');
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
test('addHeaders adds service headers', () => {
|
|
89
|
-
const headers = new Headers();
|
|
90
|
-
serviceMiddleware.addHeaders(headers);
|
|
91
|
-
|
|
92
|
-
expect(headers.get('x-service')).toBe('${coreInputs.serviceName}');
|
|
93
|
-
expect(headers.get('x-version')).toBe('${confirmedValues.version}');
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
test('handleCors adds CORS headers', () => {
|
|
97
|
-
const headers = new Headers();
|
|
98
|
-
serviceMiddleware.handleCors(headers);
|
|
99
|
-
|
|
100
|
-
expect(headers.has('Access-Control-Allow-Origin')).toBe(true);
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
${confirmedValues.features.authentication ? `
|
|
104
|
-
test('authentication middleware validates tokens', () => {
|
|
105
|
-
expect(typeof serviceMiddleware.authenticateRequest).toBe('function');
|
|
106
|
-
});` : ''}
|
|
107
|
-
|
|
108
|
-
${confirmedValues.features.authorization ? `
|
|
109
|
-
test('authorization middleware checks permissions', () => {
|
|
110
|
-
expect(typeof serviceMiddleware.authorizeRequest).toBe('function');
|
|
111
|
-
});` : ''}
|
|
112
|
-
|
|
113
|
-
${confirmedValues.features.rateLimiting ? `
|
|
114
|
-
test('rate limiting middleware tracks requests', () => {
|
|
115
|
-
expect(typeof serviceMiddleware.checkRateLimit).toBe('function');
|
|
116
|
-
});` : ''}
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
describe('Utilities', () => {
|
|
120
|
-
test('exports utility functions', () => {
|
|
121
|
-
expect(typeof serviceUtils.formatResponse).toBe('function');
|
|
122
|
-
expect(typeof serviceUtils.validateInput).toBe('function');
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
test('formatResponse creates proper response format', () => {
|
|
126
|
-
const data = { test: 'value' };
|
|
127
|
-
const formatted = serviceUtils.formatResponse(data);
|
|
128
|
-
|
|
129
|
-
expect(formatted.success).toBe(true);
|
|
130
|
-
expect(formatted.data).toEqual(data);
|
|
131
|
-
expect(formatted.timestamp).toBeDefined();
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
test('validateInput uses service schema', () => {
|
|
135
|
-
const result = serviceUtils.validateInput({}, serviceSchema);
|
|
136
|
-
expect(result).toBeDefined();
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
${confirmedValues.features.database ? `
|
|
140
|
-
test('database utilities handle connections', () => {
|
|
141
|
-
expect(typeof serviceUtils.getDatabaseConnection).toBe('function');
|
|
142
|
-
});` : ''}
|
|
143
|
-
|
|
144
|
-
${confirmedValues.features.caching ? `
|
|
145
|
-
test('cache utilities manage cache operations', () => {
|
|
146
|
-
expect(typeof serviceUtils.getCacheKey).toBe('function');
|
|
147
|
-
expect(typeof serviceUtils.setCacheValue).toBe('function');
|
|
148
|
-
});` : ''}
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
describe('Schema Validation', () => {
|
|
152
|
-
test('service schema is properly defined', () => {
|
|
153
|
-
expect(serviceSchema).toBeDefined();
|
|
154
|
-
expect(typeof serviceSchema.parse).toBe('function');
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
${this._generateSchemaTests(coreInputs.serviceType, confirmedValues)}
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
describe('Configuration', () => {
|
|
161
|
-
test('service configuration is valid', () => {
|
|
162
|
-
expect('${coreInputs.serviceName}').toMatch(/^[a-z][a-z0-9-]*$/);
|
|
163
|
-
expect('${confirmedValues.version}').toMatch(/^\\d+\\.\\d+\\.\\d+$/);
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
test('environment variables are accessible', () => {
|
|
167
|
-
// Test environment variable access patterns
|
|
168
|
-
expect(typeof process.env).toBe('object');
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
test('domains configuration is valid', () => {
|
|
172
|
-
const domainsConfig = {
|
|
173
|
-
primary: '${coreInputs.domainName}',
|
|
174
|
-
environments: {
|
|
175
|
-
production: '${confirmedValues.productionUrl}',
|
|
176
|
-
staging: '${confirmedValues.stagingUrl}',
|
|
177
|
-
development: '${confirmedValues.developmentUrl}'
|
|
178
|
-
}
|
|
179
|
-
};
|
|
180
|
-
|
|
181
|
-
expect(domainsConfig.primary).toBeDefined();
|
|
182
|
-
expect(domainsConfig.environments.production).toContain('${coreInputs.domainName}');
|
|
183
|
-
});
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
describe('Error Handling', () => {
|
|
187
|
-
test('errors are properly formatted', () => {
|
|
188
|
-
const error = new Error('Test error');
|
|
189
|
-
const formatted = serviceUtils.formatError(error);
|
|
190
|
-
|
|
191
|
-
expect(formatted.success).toBe(false);
|
|
192
|
-
expect(formatted.error).toBeDefined();
|
|
193
|
-
expect(formatted.timestamp).toBeDefined();
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
test('handles validation errors', () => {
|
|
197
|
-
try {
|
|
198
|
-
serviceSchema.parse({ invalid: 'data' });
|
|
199
|
-
} catch (error) {
|
|
200
|
-
expect(error).toBeDefined();
|
|
201
|
-
}
|
|
202
|
-
});
|
|
203
|
-
});
|
|
204
|
-
});
|
|
205
|
-
`;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
/**
|
|
209
|
-
* Generate service-type specific schema tests
|
|
210
|
-
* @private
|
|
211
|
-
*/
|
|
212
|
-
_generateSchemaTests(serviceType, confirmedValues) {
|
|
213
|
-
switch (serviceType) {
|
|
214
|
-
case 'data-service':
|
|
215
|
-
return `test('data schema validates records', () => {
|
|
216
|
-
const validData = {
|
|
217
|
-
id: '123',
|
|
218
|
-
data: { test: 'value' },
|
|
219
|
-
timestamp: new Date().toISOString()
|
|
220
|
-
};
|
|
221
|
-
expect(() => serviceSchema.parse(validData)).not.toThrow();
|
|
222
|
-
});
|
|
223
|
-
|
|
224
|
-
test('data schema rejects invalid data', () => {
|
|
225
|
-
const invalidData = { invalid: 'structure' };
|
|
226
|
-
expect(() => serviceSchema.parse(invalidData)).toThrow();
|
|
227
|
-
});`;
|
|
228
|
-
case 'auth-service':
|
|
229
|
-
return `test('auth schema validates credentials', () => {
|
|
230
|
-
const validAuth = {
|
|
231
|
-
username: 'testuser',
|
|
232
|
-
password: 'testpass123'
|
|
233
|
-
};
|
|
234
|
-
expect(() => serviceSchema.parse(validAuth)).not.toThrow();
|
|
235
|
-
});
|
|
236
|
-
|
|
237
|
-
test('auth schema validates tokens', () => {
|
|
238
|
-
const validToken = {
|
|
239
|
-
token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...',
|
|
240
|
-
expiresAt: new Date().toISOString()
|
|
241
|
-
};
|
|
242
|
-
expect(() => serviceSchema.parse(validToken)).not.toThrow();
|
|
243
|
-
});`;
|
|
244
|
-
case 'content-service':
|
|
245
|
-
return `test('content schema validates content structure', () => {
|
|
246
|
-
const validContent = {
|
|
247
|
-
id: '123',
|
|
248
|
-
title: 'Test Content',
|
|
249
|
-
body: 'Content body',
|
|
250
|
-
author: 'test-author'
|
|
251
|
-
};
|
|
252
|
-
expect(() => serviceSchema.parse(validContent)).not.toThrow();
|
|
253
|
-
});`;
|
|
254
|
-
case 'api-gateway':
|
|
255
|
-
return `test('api schema validates requests', () => {
|
|
256
|
-
const validRequest = {
|
|
257
|
-
method: 'GET',
|
|
258
|
-
path: '/test',
|
|
259
|
-
headers: {}
|
|
260
|
-
};
|
|
261
|
-
expect(() => serviceSchema.parse(validRequest)).not.toThrow();
|
|
262
|
-
});`;
|
|
263
|
-
default:
|
|
264
|
-
return `test('service schema validates input', () => {
|
|
265
|
-
// Add service-specific schema tests
|
|
266
|
-
expect(serviceSchema).toBeDefined();
|
|
267
|
-
});`;
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
/**
|
|
272
|
-
* Determine if generator should run
|
|
273
|
-
*/
|
|
274
|
-
shouldGenerate(context) {
|
|
275
|
-
return true; // Always generate unit tests
|
|
276
|
-
}
|
|
277
|
-
}
|