@friggframework/devtools 2.0.0--canary.545.e256e95.0 → 2.0.0--canary.553.dc5f898.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 (129) hide show
  1. package/frigg-cli/README.md +1 -1
  2. package/frigg-cli/__tests__/unit/commands/build.test.js +1 -1
  3. package/frigg-cli/__tests__/unit/commands/doctor.test.js +2 -0
  4. package/frigg-cli/__tests__/unit/commands/install.test.js +19 -23
  5. package/frigg-cli/__tests__/unit/dependencies.test.js +2 -2
  6. package/frigg-cli/build-command/index.js +11 -123
  7. package/frigg-cli/deploy-command/index.js +1 -83
  8. package/frigg-cli/doctor-command/index.js +16 -37
  9. package/frigg-cli/generate-iam-command.js +1 -21
  10. package/frigg-cli/index.js +6 -21
  11. package/frigg-cli/index.test.js +2 -7
  12. package/frigg-cli/init-command/backend-first-handler.js +42 -124
  13. package/frigg-cli/init-command/index.js +1 -2
  14. package/frigg-cli/init-command/template-handler.js +3 -13
  15. package/frigg-cli/install-command/backend-js.js +3 -3
  16. package/frigg-cli/install-command/environment-variables.js +19 -16
  17. package/frigg-cli/install-command/environment-variables.test.js +13 -12
  18. package/frigg-cli/install-command/index.js +9 -14
  19. package/frigg-cli/install-command/integration-file.js +3 -3
  20. package/frigg-cli/install-command/logger.js +12 -0
  21. package/frigg-cli/install-command/validate-package.js +9 -5
  22. package/frigg-cli/jest.config.js +1 -4
  23. package/frigg-cli/repair-command/index.js +128 -121
  24. package/frigg-cli/start-command/index.js +2 -324
  25. package/frigg-cli/ui-command/index.js +36 -58
  26. package/frigg-cli/utils/repo-detection.js +37 -85
  27. package/infrastructure/create-frigg-infrastructure.js +0 -93
  28. package/infrastructure/docs/iam-policy-templates.md +1 -1
  29. package/infrastructure/domains/integration/integration-builder.js +3 -2
  30. package/infrastructure/domains/integration/integration-builder.test.js +54 -2
  31. package/infrastructure/domains/networking/vpc-builder.test.js +4 -2
  32. package/infrastructure/domains/networking/vpc-resolver.test.js +1 -1
  33. package/infrastructure/domains/shared/resource-discovery.js +5 -5
  34. package/infrastructure/domains/shared/types/app-definition.js +0 -35
  35. package/infrastructure/domains/shared/types/discovery-result.test.js +1 -1
  36. package/infrastructure/domains/shared/utilities/base-definition-factory.js +1 -10
  37. package/infrastructure/domains/shared/utilities/base-definition-factory.test.js +2 -2
  38. package/infrastructure/infrastructure-composer.js +0 -2
  39. package/infrastructure/infrastructure-composer.test.js +6 -5
  40. package/management-ui/README.md +109 -245
  41. package/package.json +7 -8
  42. package/frigg-cli/__tests__/application/use-cases/AddApiModuleToIntegrationUseCase.test.js +0 -326
  43. package/frigg-cli/__tests__/application/use-cases/CreateApiModuleUseCase.test.js +0 -337
  44. package/frigg-cli/__tests__/domain/entities/ApiModule.test.js +0 -373
  45. package/frigg-cli/__tests__/domain/entities/AppDefinition.test.js +0 -313
  46. package/frigg-cli/__tests__/domain/services/IntegrationValidator.test.js +0 -269
  47. package/frigg-cli/__tests__/domain/value-objects/IntegrationName.test.js +0 -82
  48. package/frigg-cli/__tests__/infrastructure/adapters/IntegrationJsUpdater.test.js +0 -408
  49. package/frigg-cli/__tests__/infrastructure/repositories/FileSystemApiModuleRepository.test.js +0 -583
  50. package/frigg-cli/__tests__/infrastructure/repositories/FileSystemAppDefinitionRepository.test.js +0 -314
  51. package/frigg-cli/__tests__/infrastructure/repositories/FileSystemIntegrationRepository.test.js +0 -383
  52. package/frigg-cli/__tests__/unit/commands/init.test.js +0 -406
  53. package/frigg-cli/__tests__/unit/commands/provider-dispatch.test.js +0 -383
  54. package/frigg-cli/__tests__/unit/commands/repair.test.js +0 -275
  55. package/frigg-cli/__tests__/unit/start-command/application/RunPreflightChecksUseCase.test.js +0 -411
  56. package/frigg-cli/__tests__/unit/start-command/infrastructure/DatabaseAdapter.test.js +0 -405
  57. package/frigg-cli/__tests__/unit/start-command/infrastructure/DockerAdapter.test.js +0 -496
  58. package/frigg-cli/__tests__/unit/start-command/presentation/InteractivePromptAdapter.test.js +0 -474
  59. package/frigg-cli/__tests__/unit/utils/output.test.js +0 -196
  60. package/frigg-cli/application/use-cases/AddApiModuleToIntegrationUseCase.js +0 -93
  61. package/frigg-cli/application/use-cases/CreateApiModuleUseCase.js +0 -93
  62. package/frigg-cli/application/use-cases/CreateIntegrationUseCase.js +0 -103
  63. package/frigg-cli/container.js +0 -172
  64. package/frigg-cli/docs/OUTPUT_MIGRATION_GUIDE.md +0 -286
  65. package/frigg-cli/domain/entities/ApiModule.js +0 -272
  66. package/frigg-cli/domain/entities/AppDefinition.js +0 -227
  67. package/frigg-cli/domain/entities/Integration.js +0 -198
  68. package/frigg-cli/domain/exceptions/DomainException.js +0 -24
  69. package/frigg-cli/domain/ports/IApiModuleRepository.js +0 -53
  70. package/frigg-cli/domain/ports/IAppDefinitionRepository.js +0 -43
  71. package/frigg-cli/domain/ports/IIntegrationRepository.js +0 -61
  72. package/frigg-cli/domain/services/IntegrationValidator.js +0 -185
  73. package/frigg-cli/domain/value-objects/IntegrationId.js +0 -42
  74. package/frigg-cli/domain/value-objects/IntegrationName.js +0 -60
  75. package/frigg-cli/domain/value-objects/SemanticVersion.js +0 -70
  76. package/frigg-cli/infrastructure/UnitOfWork.js +0 -46
  77. package/frigg-cli/infrastructure/adapters/BackendJsUpdater.js +0 -197
  78. package/frigg-cli/infrastructure/adapters/FileSystemAdapter.js +0 -224
  79. package/frigg-cli/infrastructure/adapters/IntegrationJsUpdater.js +0 -249
  80. package/frigg-cli/infrastructure/adapters/SchemaValidator.js +0 -92
  81. package/frigg-cli/infrastructure/repositories/FileSystemApiModuleRepository.js +0 -373
  82. package/frigg-cli/infrastructure/repositories/FileSystemAppDefinitionRepository.js +0 -116
  83. package/frigg-cli/infrastructure/repositories/FileSystemIntegrationRepository.js +0 -277
  84. package/frigg-cli/package-lock.json +0 -16226
  85. package/frigg-cli/start-command/application/RunPreflightChecksUseCase.js +0 -376
  86. package/frigg-cli/start-command/infrastructure/DatabaseAdapter.js +0 -591
  87. package/frigg-cli/start-command/infrastructure/DockerAdapter.js +0 -306
  88. package/frigg-cli/start-command/presentation/InteractivePromptAdapter.js +0 -329
  89. package/frigg-cli/templates/backend/.env.example +0 -62
  90. package/frigg-cli/templates/backend/.eslintrc.json +0 -12
  91. package/frigg-cli/templates/backend/.prettierrc +0 -6
  92. package/frigg-cli/templates/backend/docker-compose.yml +0 -22
  93. package/frigg-cli/templates/backend/index.js +0 -96
  94. package/frigg-cli/templates/backend/infrastructure.js +0 -12
  95. package/frigg-cli/templates/backend/jest.config.js +0 -17
  96. package/frigg-cli/templates/backend/package.json +0 -50
  97. package/frigg-cli/templates/backend/src/api-modules/.gitkeep +0 -10
  98. package/frigg-cli/templates/backend/src/base/.gitkeep +0 -7
  99. package/frigg-cli/templates/backend/src/integrations/.gitkeep +0 -10
  100. package/frigg-cli/templates/backend/src/integrations/ExampleIntegration.js +0 -65
  101. package/frigg-cli/templates/backend/src/utils/.gitkeep +0 -7
  102. package/frigg-cli/templates/backend/test/setup.js +0 -30
  103. package/frigg-cli/templates/backend/ui-extensions/.gitkeep +0 -0
  104. package/frigg-cli/templates/backend/ui-extensions/README.md +0 -77
  105. package/frigg-cli/utils/__tests__/provider-helper.test.js +0 -55
  106. package/frigg-cli/utils/__tests__/repo-detection.test.js +0 -436
  107. package/frigg-cli/utils/output.js +0 -382
  108. package/frigg-cli/utils/provider-helper.js +0 -75
  109. package/frigg-cli/validate-command/__tests__/adapters/validate-command.test.js +0 -205
  110. package/frigg-cli/validate-command/__tests__/application/validate-app-use-case.test.js +0 -104
  111. package/frigg-cli/validate-command/__tests__/domain/fix-suggestion.test.js +0 -153
  112. package/frigg-cli/validate-command/__tests__/domain/validation-error.test.js +0 -162
  113. package/frigg-cli/validate-command/__tests__/domain/validation-result.test.js +0 -152
  114. package/frigg-cli/validate-command/__tests__/infrastructure/api-module-validator.test.js +0 -332
  115. package/frigg-cli/validate-command/__tests__/infrastructure/app-definition-validator.test.js +0 -191
  116. package/frigg-cli/validate-command/__tests__/infrastructure/integration-class-validator.test.js +0 -146
  117. package/frigg-cli/validate-command/__tests__/infrastructure/template-validation.test.js +0 -155
  118. package/frigg-cli/validate-command/adapters/cli/validate-command.js +0 -199
  119. package/frigg-cli/validate-command/application/use-cases/validate-app-use-case.js +0 -35
  120. package/frigg-cli/validate-command/domain/entities/validation-result.js +0 -74
  121. package/frigg-cli/validate-command/domain/value-objects/fix-suggestion.js +0 -74
  122. package/frigg-cli/validate-command/domain/value-objects/validation-error.js +0 -68
  123. package/frigg-cli/validate-command/infrastructure/validators/api-module-validator.js +0 -181
  124. package/frigg-cli/validate-command/infrastructure/validators/app-definition-validator.js +0 -145
  125. package/frigg-cli/validate-command/infrastructure/validators/integration-class-validator.js +0 -113
  126. package/infrastructure/domains/admin-scripts/admin-script-builder.js +0 -200
  127. package/infrastructure/domains/admin-scripts/admin-script-builder.test.js +0 -499
  128. package/infrastructure/domains/admin-scripts/index.js +0 -5
  129. package/infrastructure/jest.config.js +0 -16
@@ -1,93 +0,0 @@
1
- const {ValidationException} = require('../../domain/exceptions/DomainException');
2
- const {IntegrationValidator} = require('../../domain/services/IntegrationValidator');
3
-
4
- /**
5
- * AddApiModuleToIntegrationUseCase
6
- *
7
- * Application layer use case for adding API modules to existing integrations
8
- * Orchestrates the addition with validation and persistence
9
- */
10
- class AddApiModuleToIntegrationUseCase {
11
- constructor(integrationRepository, apiModuleRepository, unitOfWork, integrationValidator = null, integrationJsUpdater = null) {
12
- this.integrationRepository = integrationRepository;
13
- this.apiModuleRepository = apiModuleRepository;
14
- this.unitOfWork = unitOfWork;
15
- this.integrationValidator = integrationValidator ||
16
- new IntegrationValidator(integrationRepository);
17
- this.integrationJsUpdater = integrationJsUpdater;
18
- }
19
-
20
- /**
21
- * Execute the use case
22
- * @param {object} request - Request data
23
- * @param {string} request.integrationName - Name of the integration
24
- * @param {string} request.moduleName - Name of the API module to add
25
- * @param {string} request.moduleVersion - Version of the API module
26
- * @param {string} request.source - Source of the module (npm, local, git)
27
- * @returns {Promise<{success: boolean, integration: object}>}
28
- */
29
- async execute(request) {
30
- try {
31
- // 1. Load the integration
32
- const integration = await this.integrationRepository.findByName(request.integrationName);
33
- if (!integration) {
34
- throw new ValidationException(`Integration '${request.integrationName}' not found`);
35
- }
36
-
37
- // 2. Verify API module exists
38
- const apiModuleExists = await this.apiModuleRepository.exists(request.moduleName);
39
- if (!apiModuleExists) {
40
- throw new ValidationException(`API module '${request.moduleName}' not found. Create it first with 'frigg create api-module ${request.moduleName}'`);
41
- }
42
-
43
- // 3. Validate API module addition
44
- const validation = this.integrationValidator.validateApiModuleAddition(
45
- integration,
46
- request.moduleName,
47
- request.moduleVersion || '1.0.0'
48
- );
49
-
50
- if (!validation.isValid) {
51
- throw new ValidationException(validation.errors);
52
- }
53
-
54
- // 4. Add the API module to the integration
55
- integration.addApiModule(
56
- request.moduleName,
57
- request.moduleVersion || '1.0.0',
58
- request.source || 'local'
59
- );
60
-
61
- // 5. Save the updated integration
62
- await this.integrationRepository.save(integration);
63
-
64
- // 6. Update Integration.js file to add module import and Definition entry
65
- if (this.integrationJsUpdater) {
66
- const integrationJsExists = await this.integrationJsUpdater.exists(request.integrationName);
67
- if (integrationJsExists) {
68
- await this.integrationJsUpdater.addModuleToIntegration(
69
- request.integrationName,
70
- request.moduleName,
71
- request.source || 'local'
72
- );
73
- }
74
- }
75
-
76
- // 7. Commit transaction
77
- await this.unitOfWork.commit();
78
-
79
- return {
80
- success: true,
81
- integration: integration.toObject(),
82
- message: `API module '${request.moduleName}' added to integration '${request.integrationName}'`
83
- };
84
- } catch (error) {
85
- // Rollback all file operations on error
86
- await this.unitOfWork.rollback();
87
-
88
- throw error;
89
- }
90
- }
91
- }
92
-
93
- module.exports = {AddApiModuleToIntegrationUseCase};
@@ -1,93 +0,0 @@
1
- const {ApiModule} = require('../../domain/entities/ApiModule');
2
- const {ValidationException} = require('../../domain/exceptions/DomainException');
3
-
4
- /**
5
- * CreateApiModuleUseCase
6
- *
7
- * Application layer use case for creating new API modules
8
- * Orchestrates API module creation with validation and persistence
9
- */
10
- class CreateApiModuleUseCase {
11
- constructor(apiModuleRepository, unitOfWork, appDefinitionRepository = null) {
12
- this.apiModuleRepository = apiModuleRepository;
13
- this.unitOfWork = unitOfWork;
14
- this.appDefinitionRepository = appDefinitionRepository;
15
- }
16
-
17
- /**
18
- * Execute the use case
19
- * @param {object} request - Request data
20
- * @param {string} request.name - API module name (kebab-case)
21
- * @param {string} request.displayName - Human-readable name
22
- * @param {string} request.description - Description
23
- * @param {string} request.baseUrl - API base URL
24
- * @param {string} request.authType - Authentication type
25
- * @param {array} request.scopes - OAuth scopes
26
- * @param {array} request.credentials - Required credentials
27
- * @param {object} request.entities - Entity configurations
28
- * @param {object} request.endpoints - API endpoints
29
- * @returns {Promise<{success: boolean, apiModule: object}>}
30
- */
31
- async execute(request) {
32
- try {
33
- // 1. Create domain entity
34
- const apiModule = ApiModule.create({
35
- name: request.name,
36
- displayName: request.displayName,
37
- description: request.description,
38
- apiConfig: {
39
- baseUrl: request.baseUrl || '',
40
- authType: request.authType || 'oauth2',
41
- version: request.apiVersion || 'v1'
42
- },
43
- entities: request.entities || {},
44
- scopes: request.scopes || [],
45
- credentials: request.credentials || [],
46
- endpoints: request.endpoints || {}
47
- });
48
-
49
- // 2. Validate business rules
50
- const validation = apiModule.validate();
51
- if (!validation.isValid) {
52
- throw new ValidationException(validation.errors);
53
- }
54
-
55
- // 3. Check for existing API module (uniqueness)
56
- const exists = await this.apiModuleRepository.exists(apiModule.name);
57
- if (exists) {
58
- throw new ValidationException(`API module '${apiModule.name}' already exists`);
59
- }
60
-
61
- // 4. Save through repository (writes files atomically)
62
- await this.apiModuleRepository.save(apiModule);
63
-
64
- // 5. Register in AppDefinition (if repository is available)
65
- if (this.appDefinitionRepository) {
66
- try {
67
- const appDef = await this.appDefinitionRepository.load();
68
- if (appDef) {
69
- appDef.registerApiModule(apiModule.name, apiModule.version.value, 'local');
70
- await this.appDefinitionRepository.save(appDef);
71
- }
72
- } catch (error) {
73
- console.warn('Could not register API module in app definition:', error.message);
74
- }
75
- }
76
-
77
- // 6. Commit transaction (cleanup backups)
78
- await this.unitOfWork.commit();
79
-
80
- return {
81
- success: true,
82
- apiModule: apiModule.toObject()
83
- };
84
- } catch (error) {
85
- // Rollback all file operations on error
86
- await this.unitOfWork.rollback();
87
-
88
- throw error;
89
- }
90
- }
91
- }
92
-
93
- module.exports = {CreateApiModuleUseCase};
@@ -1,103 +0,0 @@
1
- const {Integration} = require('../../domain/entities/Integration');
2
- const {ValidationException} = require('../../domain/exceptions/DomainException');
3
- const {IntegrationValidator} = require('../../domain/services/IntegrationValidator');
4
-
5
- /**
6
- * CreateIntegrationUseCase
7
- * Application layer use case for creating new integrations
8
- * Uses IntegrationValidator domain service for comprehensive validation
9
- * Automatically registers integration in AppDefinition
10
- */
11
- class CreateIntegrationUseCase {
12
- constructor(integrationRepository, unitOfWork, integrationValidator = null, appDefinitionRepository = null, backendJsUpdater = null) {
13
- this.integrationRepository = integrationRepository;
14
- this.unitOfWork = unitOfWork;
15
- this.appDefinitionRepository = appDefinitionRepository;
16
- this.backendJsUpdater = backendJsUpdater;
17
- // Allow validator injection for testing, or create default
18
- this.integrationValidator = integrationValidator ||
19
- new IntegrationValidator(integrationRepository);
20
- }
21
-
22
- /**
23
- * Execute the use case
24
- * @param {object} request - Request data
25
- * @param {string} request.name - Integration name (kebab-case)
26
- * @param {string} request.displayName - Human-readable name
27
- * @param {string} request.description - Description
28
- * @param {string} request.type - Integration type (api, webhook, sync, etc.)
29
- * @param {string} request.category - Category
30
- * @param {array} request.tags - Tags
31
- * @param {object} request.entities - Entity configuration
32
- * @param {object} request.capabilities - Capabilities
33
- * @param {object} request.requirements - Requirements
34
- * @returns {Promise<{success: boolean, integration: object}>}
35
- */
36
- async execute(request) {
37
- try {
38
- // 1. Create domain entity (validates name format via value object)
39
- const integration = Integration.create({
40
- name: request.name,
41
- displayName: request.displayName,
42
- description: request.description,
43
- type: request.type || 'custom',
44
- category: request.category,
45
- tags: request.tags || [],
46
- entities: request.entities || {},
47
- capabilities: request.capabilities || {},
48
- requirements: request.requirements || {},
49
- options: request.options || {}
50
- });
51
-
52
- // 2. Validate through domain service (entity rules + domain rules + uniqueness)
53
- const validation = await this.integrationValidator.validate(integration);
54
- if (!validation.isValid) {
55
- throw new ValidationException(validation.errors);
56
- }
57
-
58
- // 3. Save through repository (validates schema, writes files atomically)
59
- await this.integrationRepository.save(integration);
60
-
61
- // 4. Register in AppDefinition (if repository is available)
62
- if (this.appDefinitionRepository) {
63
- try {
64
- const appDef = await this.appDefinitionRepository.load();
65
- if (appDef) {
66
- appDef.registerIntegration(integration.name.value);
67
- await this.appDefinitionRepository.save(appDef);
68
- }
69
- } catch (error) {
70
- // Log but don't fail - app definition might not exist yet
71
- console.warn('Could not register integration in app definition:', error.message);
72
- }
73
- }
74
-
75
- // 5. Register in backend.js (if updater is available)
76
- if (this.backendJsUpdater) {
77
- try {
78
- if (await this.backendJsUpdater.exists()) {
79
- await this.backendJsUpdater.registerIntegration(integration.name.value);
80
- }
81
- } catch (error) {
82
- // Log but don't fail - backend.js might not exist or have different structure
83
- console.warn('Could not register integration in backend.js:', error.message);
84
- }
85
- }
86
-
87
- // 6. Commit transaction (cleanup backups)
88
- await this.unitOfWork.commit();
89
-
90
- return {
91
- success: true,
92
- integration: integration.toObject()
93
- };
94
- } catch (error) {
95
- // Rollback all file operations on error
96
- await this.unitOfWork.rollback();
97
-
98
- throw error;
99
- }
100
- }
101
- }
102
-
103
- module.exports = {CreateIntegrationUseCase};
@@ -1,172 +0,0 @@
1
- const path = require('path');
2
- const {findNearestBackendPackageJson} = require('./utils/backend-path');
3
-
4
- // Infrastructure
5
- const {FileSystemAdapter} = require('./infrastructure/adapters/FileSystemAdapter');
6
- const {SchemaValidator} = require('./infrastructure/adapters/SchemaValidator');
7
- const {BackendJsUpdater} = require('./infrastructure/adapters/BackendJsUpdater');
8
- const {IntegrationJsUpdater} = require('./infrastructure/adapters/IntegrationJsUpdater');
9
- const {FileSystemIntegrationRepository} = require('./infrastructure/repositories/FileSystemIntegrationRepository');
10
- const {FileSystemAppDefinitionRepository} = require('./infrastructure/repositories/FileSystemAppDefinitionRepository');
11
- const {FileSystemApiModuleRepository} = require('./infrastructure/repositories/FileSystemApiModuleRepository');
12
- const {UnitOfWork} = require('./infrastructure/UnitOfWork');
13
-
14
- // Domain Services
15
- const {IntegrationValidator} = require('./domain/services/IntegrationValidator');
16
-
17
- // Application
18
- const {CreateIntegrationUseCase} = require('./application/use-cases/CreateIntegrationUseCase');
19
- const {CreateApiModuleUseCase} = require('./application/use-cases/CreateApiModuleUseCase');
20
- const {AddApiModuleToIntegrationUseCase} = require('./application/use-cases/AddApiModuleToIntegrationUseCase');
21
-
22
- /**
23
- * Dependency Injection Container
24
- * Manages object creation and dependency wiring
25
- */
26
- class Container {
27
- constructor(startDir = process.cwd()) {
28
- // Find backend directory
29
- this.backendPath = findNearestBackendPackageJson(startDir);
30
- if (!this.backendPath) {
31
- throw new Error('Could not find backend directory. Make sure you are in a Frigg project.');
32
- }
33
- this.projectRoot = path.dirname(this.backendPath); // For backwards compatibility
34
- this.instances = new Map();
35
- }
36
-
37
- /**
38
- * Get or create singleton instance
39
- */
40
- get(serviceName) {
41
- if (this.instances.has(serviceName)) {
42
- return this.instances.get(serviceName);
43
- }
44
-
45
- const instance = this._create(serviceName);
46
- this.instances.set(serviceName, instance);
47
- return instance;
48
- }
49
-
50
- /**
51
- * Create service instance with dependencies
52
- */
53
- _create(serviceName) {
54
- switch (serviceName) {
55
- // Infrastructure - Adapters
56
- case 'FileSystemAdapter':
57
- return new FileSystemAdapter();
58
-
59
- case 'SchemaValidator':
60
- // Point to schemas package in monorepo
61
- // Schema validator should always use the schemas from the frigg monorepo,
62
- // not relative to the user's project
63
- const schemasPath = path.join(__dirname, '../../schemas/schemas');
64
- return new SchemaValidator(schemasPath);
65
-
66
- case 'BackendJsUpdater':
67
- return new BackendJsUpdater(
68
- this.get('FileSystemAdapter'),
69
- this.backendPath
70
- );
71
-
72
- case 'IntegrationJsUpdater':
73
- return new IntegrationJsUpdater(
74
- this.get('FileSystemAdapter'),
75
- this.backendPath
76
- );
77
-
78
- // Infrastructure - Repositories
79
- case 'IntegrationRepository':
80
- return new FileSystemIntegrationRepository(
81
- this.get('FileSystemAdapter'),
82
- this.backendPath,
83
- this.get('SchemaValidator')
84
- );
85
-
86
- case 'AppDefinitionRepository':
87
- return new FileSystemAppDefinitionRepository(
88
- this.get('FileSystemAdapter'),
89
- this.backendPath,
90
- this.get('SchemaValidator')
91
- );
92
-
93
- case 'ApiModuleRepository':
94
- return new FileSystemApiModuleRepository(
95
- this.get('FileSystemAdapter'),
96
- this.backendPath,
97
- this.get('SchemaValidator')
98
- );
99
-
100
- // Infrastructure - Unit of Work
101
- case 'UnitOfWork':
102
- return new UnitOfWork(
103
- this.get('FileSystemAdapter')
104
- );
105
-
106
- // Domain Services
107
- case 'IntegrationValidator':
108
- return new IntegrationValidator(
109
- this.get('IntegrationRepository')
110
- );
111
-
112
- // Application - Use Cases
113
- case 'CreateIntegrationUseCase':
114
- return new CreateIntegrationUseCase(
115
- this.get('IntegrationRepository'),
116
- this.get('UnitOfWork'),
117
- this.get('IntegrationValidator'),
118
- this.get('AppDefinitionRepository'),
119
- this.get('BackendJsUpdater')
120
- );
121
-
122
- case 'CreateApiModuleUseCase':
123
- return new CreateApiModuleUseCase(
124
- this.get('ApiModuleRepository'),
125
- this.get('UnitOfWork'),
126
- this.get('AppDefinitionRepository')
127
- );
128
-
129
- case 'AddApiModuleToIntegrationUseCase':
130
- return new AddApiModuleToIntegrationUseCase(
131
- this.get('IntegrationRepository'),
132
- this.get('ApiModuleRepository'),
133
- this.get('UnitOfWork'),
134
- this.get('IntegrationValidator'),
135
- this.get('IntegrationJsUpdater')
136
- );
137
-
138
- default:
139
- throw new Error(`Unknown service: ${serviceName}`);
140
- }
141
- }
142
-
143
- /**
144
- * Clear all instances (useful for testing)
145
- */
146
- clear() {
147
- this.instances.clear();
148
- }
149
-
150
- /**
151
- * Set project root directory
152
- */
153
- setProjectRoot(projectRoot) {
154
- this.projectRoot = projectRoot;
155
- this.clear(); // Clear cached instances
156
- }
157
- }
158
-
159
- // Export singleton container
160
- let containerInstance = null;
161
-
162
- module.exports = {
163
- Container,
164
- getContainer: (projectRoot) => {
165
- if (!containerInstance) {
166
- containerInstance = new Container(projectRoot);
167
- } else if (projectRoot) {
168
- containerInstance.setProjectRoot(projectRoot);
169
- }
170
- return containerInstance;
171
- }
172
- };