@friggframework/devtools 2.0.0--canary.549.70ef06a.0 → 2.0.0--canary.545.ccb5010.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 (127) hide show
  1. package/frigg-cli/README.md +1 -1
  2. package/frigg-cli/__tests__/application/use-cases/AddApiModuleToIntegrationUseCase.test.js +326 -0
  3. package/frigg-cli/__tests__/application/use-cases/CreateApiModuleUseCase.test.js +337 -0
  4. package/frigg-cli/__tests__/domain/entities/ApiModule.test.js +373 -0
  5. package/frigg-cli/__tests__/domain/entities/AppDefinition.test.js +313 -0
  6. package/frigg-cli/__tests__/domain/services/IntegrationValidator.test.js +269 -0
  7. package/frigg-cli/__tests__/domain/value-objects/IntegrationName.test.js +82 -0
  8. package/frigg-cli/__tests__/infrastructure/adapters/IntegrationJsUpdater.test.js +408 -0
  9. package/frigg-cli/__tests__/infrastructure/repositories/FileSystemApiModuleRepository.test.js +583 -0
  10. package/frigg-cli/__tests__/infrastructure/repositories/FileSystemAppDefinitionRepository.test.js +314 -0
  11. package/frigg-cli/__tests__/infrastructure/repositories/FileSystemIntegrationRepository.test.js +383 -0
  12. package/frigg-cli/__tests__/unit/commands/build.test.js +1 -1
  13. package/frigg-cli/__tests__/unit/commands/doctor.test.js +0 -2
  14. package/frigg-cli/__tests__/unit/commands/init.test.js +406 -0
  15. package/frigg-cli/__tests__/unit/commands/install.test.js +23 -19
  16. package/frigg-cli/__tests__/unit/commands/provider-dispatch.test.js +383 -0
  17. package/frigg-cli/__tests__/unit/commands/repair.test.js +275 -0
  18. package/frigg-cli/__tests__/unit/dependencies.test.js +2 -2
  19. package/frigg-cli/__tests__/unit/start-command/application/RunPreflightChecksUseCase.test.js +411 -0
  20. package/frigg-cli/__tests__/unit/start-command/infrastructure/DatabaseAdapter.test.js +405 -0
  21. package/frigg-cli/__tests__/unit/start-command/infrastructure/DockerAdapter.test.js +496 -0
  22. package/frigg-cli/__tests__/unit/start-command/presentation/InteractivePromptAdapter.test.js +474 -0
  23. package/frigg-cli/__tests__/unit/utils/output.test.js +196 -0
  24. package/frigg-cli/application/use-cases/AddApiModuleToIntegrationUseCase.js +93 -0
  25. package/frigg-cli/application/use-cases/CreateApiModuleUseCase.js +93 -0
  26. package/frigg-cli/application/use-cases/CreateIntegrationUseCase.js +103 -0
  27. package/frigg-cli/build-command/index.js +123 -11
  28. package/frigg-cli/container.js +172 -0
  29. package/frigg-cli/deploy-command/index.js +83 -1
  30. package/frigg-cli/docs/OUTPUT_MIGRATION_GUIDE.md +286 -0
  31. package/frigg-cli/doctor-command/index.js +37 -16
  32. package/frigg-cli/domain/entities/ApiModule.js +272 -0
  33. package/frigg-cli/domain/entities/AppDefinition.js +227 -0
  34. package/frigg-cli/domain/entities/Integration.js +198 -0
  35. package/frigg-cli/domain/exceptions/DomainException.js +24 -0
  36. package/frigg-cli/domain/ports/IApiModuleRepository.js +53 -0
  37. package/frigg-cli/domain/ports/IAppDefinitionRepository.js +43 -0
  38. package/frigg-cli/domain/ports/IIntegrationRepository.js +61 -0
  39. package/frigg-cli/domain/services/IntegrationValidator.js +185 -0
  40. package/frigg-cli/domain/value-objects/IntegrationId.js +42 -0
  41. package/frigg-cli/domain/value-objects/IntegrationName.js +60 -0
  42. package/frigg-cli/domain/value-objects/SemanticVersion.js +70 -0
  43. package/frigg-cli/generate-iam-command.js +21 -1
  44. package/frigg-cli/index.js +21 -6
  45. package/frigg-cli/index.test.js +7 -2
  46. package/frigg-cli/infrastructure/UnitOfWork.js +46 -0
  47. package/frigg-cli/infrastructure/adapters/BackendJsUpdater.js +197 -0
  48. package/frigg-cli/infrastructure/adapters/FileSystemAdapter.js +224 -0
  49. package/frigg-cli/infrastructure/adapters/IntegrationJsUpdater.js +249 -0
  50. package/frigg-cli/infrastructure/adapters/SchemaValidator.js +92 -0
  51. package/frigg-cli/infrastructure/repositories/FileSystemApiModuleRepository.js +373 -0
  52. package/frigg-cli/infrastructure/repositories/FileSystemAppDefinitionRepository.js +116 -0
  53. package/frigg-cli/infrastructure/repositories/FileSystemIntegrationRepository.js +277 -0
  54. package/frigg-cli/init-command/backend-first-handler.js +124 -42
  55. package/frigg-cli/init-command/index.js +2 -1
  56. package/frigg-cli/init-command/template-handler.js +13 -3
  57. package/frigg-cli/install-command/backend-js.js +3 -3
  58. package/frigg-cli/install-command/environment-variables.js +16 -19
  59. package/frigg-cli/install-command/environment-variables.test.js +12 -13
  60. package/frigg-cli/install-command/index.js +14 -9
  61. package/frigg-cli/install-command/integration-file.js +3 -3
  62. package/frigg-cli/install-command/validate-package.js +5 -9
  63. package/frigg-cli/jest.config.js +4 -1
  64. package/frigg-cli/package-lock.json +16226 -0
  65. package/frigg-cli/repair-command/index.js +121 -128
  66. package/frigg-cli/start-command/application/RunPreflightChecksUseCase.js +376 -0
  67. package/frigg-cli/start-command/index.js +324 -2
  68. package/frigg-cli/start-command/infrastructure/DatabaseAdapter.js +591 -0
  69. package/frigg-cli/start-command/infrastructure/DockerAdapter.js +306 -0
  70. package/frigg-cli/start-command/presentation/InteractivePromptAdapter.js +329 -0
  71. package/frigg-cli/templates/backend/.env.example +62 -0
  72. package/frigg-cli/templates/backend/.eslintrc.json +12 -0
  73. package/frigg-cli/templates/backend/.prettierrc +6 -0
  74. package/frigg-cli/templates/backend/docker-compose.yml +22 -0
  75. package/frigg-cli/templates/backend/index.js +96 -0
  76. package/frigg-cli/templates/backend/infrastructure.js +12 -0
  77. package/frigg-cli/templates/backend/jest.config.js +17 -0
  78. package/frigg-cli/templates/backend/package.json +50 -0
  79. package/frigg-cli/templates/backend/src/api-modules/.gitkeep +10 -0
  80. package/frigg-cli/templates/backend/src/base/.gitkeep +7 -0
  81. package/frigg-cli/templates/backend/src/integrations/.gitkeep +10 -0
  82. package/frigg-cli/templates/backend/src/integrations/ExampleIntegration.js +65 -0
  83. package/frigg-cli/templates/backend/src/utils/.gitkeep +7 -0
  84. package/frigg-cli/templates/backend/test/setup.js +30 -0
  85. package/frigg-cli/templates/backend/ui-extensions/.gitkeep +0 -0
  86. package/frigg-cli/templates/backend/ui-extensions/README.md +77 -0
  87. package/frigg-cli/ui-command/index.js +58 -36
  88. package/frigg-cli/utils/__tests__/provider-helper.test.js +55 -0
  89. package/frigg-cli/utils/__tests__/repo-detection.test.js +436 -0
  90. package/frigg-cli/utils/output.js +382 -0
  91. package/frigg-cli/utils/provider-helper.js +75 -0
  92. package/frigg-cli/utils/repo-detection.js +85 -37
  93. package/frigg-cli/validate-command/__tests__/adapters/validate-command.test.js +205 -0
  94. package/frigg-cli/validate-command/__tests__/application/validate-app-use-case.test.js +104 -0
  95. package/frigg-cli/validate-command/__tests__/domain/fix-suggestion.test.js +153 -0
  96. package/frigg-cli/validate-command/__tests__/domain/validation-error.test.js +162 -0
  97. package/frigg-cli/validate-command/__tests__/domain/validation-result.test.js +152 -0
  98. package/frigg-cli/validate-command/__tests__/infrastructure/api-module-validator.test.js +332 -0
  99. package/frigg-cli/validate-command/__tests__/infrastructure/app-definition-validator.test.js +191 -0
  100. package/frigg-cli/validate-command/__tests__/infrastructure/integration-class-validator.test.js +146 -0
  101. package/frigg-cli/validate-command/__tests__/infrastructure/template-validation.test.js +155 -0
  102. package/frigg-cli/validate-command/adapters/cli/validate-command.js +199 -0
  103. package/frigg-cli/validate-command/application/use-cases/validate-app-use-case.js +35 -0
  104. package/frigg-cli/validate-command/domain/entities/validation-result.js +74 -0
  105. package/frigg-cli/validate-command/domain/value-objects/fix-suggestion.js +74 -0
  106. package/frigg-cli/validate-command/domain/value-objects/validation-error.js +68 -0
  107. package/frigg-cli/validate-command/infrastructure/validators/api-module-validator.js +181 -0
  108. package/frigg-cli/validate-command/infrastructure/validators/app-definition-validator.js +145 -0
  109. package/frigg-cli/validate-command/infrastructure/validators/integration-class-validator.js +113 -0
  110. package/infrastructure/create-frigg-infrastructure.js +93 -0
  111. package/infrastructure/docs/iam-policy-templates.md +1 -1
  112. package/infrastructure/domains/admin-scripts/admin-script-builder.js +200 -0
  113. package/infrastructure/domains/admin-scripts/admin-script-builder.test.js +499 -0
  114. package/infrastructure/domains/admin-scripts/index.js +5 -0
  115. package/infrastructure/domains/networking/vpc-builder.test.js +2 -4
  116. package/infrastructure/domains/networking/vpc-resolver.test.js +1 -1
  117. package/infrastructure/domains/shared/resource-discovery.js +5 -5
  118. package/infrastructure/domains/shared/types/app-definition.js +35 -0
  119. package/infrastructure/domains/shared/types/discovery-result.test.js +1 -1
  120. package/infrastructure/domains/shared/utilities/base-definition-factory.js +10 -1
  121. package/infrastructure/domains/shared/utilities/base-definition-factory.test.js +2 -2
  122. package/infrastructure/infrastructure-composer.js +2 -0
  123. package/infrastructure/infrastructure-composer.test.js +2 -2
  124. package/infrastructure/jest.config.js +16 -0
  125. package/management-ui/README.md +245 -109
  126. package/package.json +8 -7
  127. package/frigg-cli/install-command/logger.js +0 -12
@@ -0,0 +1,269 @@
1
+ const {IntegrationValidator} = require('../../../domain/services/IntegrationValidator');
2
+ const {Integration} = require('../../../domain/entities/Integration');
3
+ const {IntegrationName} = require('../../../domain/value-objects/IntegrationName');
4
+
5
+ // Mock repository
6
+ class MockIntegrationRepository {
7
+ constructor() {
8
+ this.integrations = new Map();
9
+ }
10
+
11
+ async exists(name) {
12
+ const nameStr = typeof name === 'string' ? name : name.value;
13
+ return this.integrations.has(nameStr);
14
+ }
15
+
16
+ addIntegration(name) {
17
+ this.integrations.set(name, true);
18
+ }
19
+ }
20
+
21
+ describe('IntegrationValidator', () => {
22
+ let validator;
23
+ let mockRepository;
24
+
25
+ beforeEach(() => {
26
+ mockRepository = new MockIntegrationRepository();
27
+ validator = new IntegrationValidator(mockRepository);
28
+ });
29
+
30
+ describe('validateUniqueness', () => {
31
+ test('passes when integration does not exist', async () => {
32
+ const name = new IntegrationName('new-integration');
33
+ const result = await validator.validateUniqueness(name);
34
+
35
+ expect(result.isValid).toBe(true);
36
+ expect(result.errors).toHaveLength(0);
37
+ });
38
+
39
+ test('fails when integration already exists', async () => {
40
+ mockRepository.addIntegration('existing-integration');
41
+
42
+ const name = new IntegrationName('existing-integration');
43
+ const result = await validator.validateUniqueness(name);
44
+
45
+ expect(result.isValid).toBe(false);
46
+ expect(result.errors).toHaveLength(1);
47
+ expect(result.errors[0]).toContain('already exists');
48
+ });
49
+ });
50
+
51
+ describe('validateDomainRules', () => {
52
+ test('passes for valid API integration', () => {
53
+ const integration = Integration.create({
54
+ name: 'test-api',
55
+ displayName: 'Test API',
56
+ description: 'Test',
57
+ type: 'api',
58
+ category: 'CRM',
59
+ capabilities: {
60
+ auth: ['oauth2']
61
+ }
62
+ });
63
+
64
+ const result = validator.validateDomainRules(integration);
65
+
66
+ expect(result.isValid).toBe(true);
67
+ expect(result.errors).toHaveLength(0);
68
+ });
69
+
70
+ test('fails when webhook integration has no webhooks capability', () => {
71
+ const integration = Integration.create({
72
+ name: 'test-webhook',
73
+ displayName: 'Test Webhook',
74
+ description: 'Test',
75
+ type: 'webhook',
76
+ category: 'CRM',
77
+ capabilities: {
78
+ webhooks: false
79
+ }
80
+ });
81
+
82
+ const result = validator.validateDomainRules(integration);
83
+
84
+ expect(result.isValid).toBe(false);
85
+ expect(result.errors).toHaveLength(1);
86
+ expect(result.errors[0]).toContain('Webhook integrations must have webhooks capability');
87
+ });
88
+
89
+ test('passes when webhook integration has webhooks capability', () => {
90
+ const integration = Integration.create({
91
+ name: 'test-webhook',
92
+ displayName: 'Test Webhook',
93
+ description: 'Test',
94
+ type: 'webhook',
95
+ category: 'CRM',
96
+ capabilities: {
97
+ webhooks: true
98
+ }
99
+ });
100
+
101
+ const result = validator.validateDomainRules(integration);
102
+
103
+ expect(result.isValid).toBe(true);
104
+ expect(result.errors).toHaveLength(0);
105
+ });
106
+ });
107
+
108
+ describe('validate', () => {
109
+ test('passes for valid new integration', async () => {
110
+ const integration = Integration.create({
111
+ name: 'new-integration',
112
+ displayName: 'New Integration',
113
+ description: 'A new integration',
114
+ type: 'api',
115
+ category: 'CRM',
116
+ capabilities: {}
117
+ });
118
+
119
+ const result = await validator.validate(integration);
120
+
121
+ expect(result.isValid).toBe(true);
122
+ expect(result.errors).toHaveLength(0);
123
+ });
124
+
125
+ test('fails when integration already exists', async () => {
126
+ mockRepository.addIntegration('existing-integration');
127
+
128
+ const integration = Integration.create({
129
+ name: 'existing-integration',
130
+ displayName: 'Existing Integration',
131
+ description: 'Test',
132
+ type: 'api',
133
+ category: 'CRM',
134
+ capabilities: {}
135
+ });
136
+
137
+ const result = await validator.validate(integration);
138
+
139
+ expect(result.isValid).toBe(false);
140
+ expect(result.errors.length).toBeGreaterThan(0);
141
+ expect(result.errors.some(e => e.includes('already exists'))).toBe(true);
142
+ });
143
+
144
+ test('accumulates multiple validation errors', async () => {
145
+ mockRepository.addIntegration('existing-webhook');
146
+
147
+ const integration = Integration.create({
148
+ name: 'existing-webhook',
149
+ displayName: 'Ex', // Too short
150
+ description: '',
151
+ type: 'webhook',
152
+ category: 'CRM',
153
+ capabilities: {
154
+ webhooks: false // Invalid for webhook type
155
+ }
156
+ });
157
+
158
+ const result = await validator.validate(integration);
159
+
160
+ expect(result.isValid).toBe(false);
161
+ expect(result.errors.length).toBeGreaterThan(1);
162
+ });
163
+ });
164
+
165
+ describe('validateUpdate', () => {
166
+ test('passes for valid update', () => {
167
+ const existing = Integration.create({
168
+ name: 'my-integration',
169
+ displayName: 'My Integration',
170
+ type: 'api',
171
+ category: 'CRM'
172
+ });
173
+
174
+ const updated = Integration.create({
175
+ name: 'my-integration',
176
+ displayName: 'My Updated Integration',
177
+ type: 'api',
178
+ category: 'Marketing'
179
+ });
180
+
181
+ const result = validator.validateUpdate(existing, updated);
182
+
183
+ expect(result.isValid).toBe(true);
184
+ expect(result.errors).toHaveLength(0);
185
+ });
186
+
187
+ test('fails when trying to change integration name', () => {
188
+ const existing = Integration.create({
189
+ name: 'original-name',
190
+ displayName: 'Original',
191
+ type: 'api'
192
+ });
193
+
194
+ const updated = Integration.create({
195
+ name: 'new-name',
196
+ displayName: 'Updated',
197
+ type: 'api'
198
+ });
199
+
200
+ const result = validator.validateUpdate(existing, updated);
201
+
202
+ expect(result.isValid).toBe(false);
203
+ expect(result.errors).toContain('Integration name cannot be changed after creation');
204
+ });
205
+
206
+ test('fails when trying to downgrade version', () => {
207
+ const existing = Integration.create({
208
+ name: 'my-integration',
209
+ displayName: 'My Integration',
210
+ type: 'api',
211
+ version: '2.0.0'
212
+ });
213
+
214
+ const updated = Integration.create({
215
+ name: 'my-integration',
216
+ displayName: 'My Integration',
217
+ type: 'api',
218
+ version: '1.0.0'
219
+ });
220
+
221
+ const result = validator.validateUpdate(existing, updated);
222
+
223
+ expect(result.isValid).toBe(false);
224
+ expect(result.errors.some(e => e.includes('Cannot downgrade'))).toBe(true);
225
+ });
226
+ });
227
+
228
+ describe('validateApiModuleAddition', () => {
229
+ test('passes for valid API module addition', () => {
230
+ const integration = Integration.create({
231
+ name: 'my-integration',
232
+ displayName: 'My Integration',
233
+ type: 'api'
234
+ });
235
+
236
+ const result = validator.validateApiModuleAddition(integration, 'new-module', '1.0.0');
237
+
238
+ expect(result.isValid).toBe(true);
239
+ expect(result.errors).toHaveLength(0);
240
+ });
241
+
242
+ test('fails when module already exists', () => {
243
+ const integration = Integration.create({
244
+ name: 'my-integration',
245
+ displayName: 'My Integration',
246
+ type: 'api'
247
+ });
248
+ integration.addApiModule('existing-module', '1.0.0');
249
+
250
+ const result = validator.validateApiModuleAddition(integration, 'existing-module', '2.0.0');
251
+
252
+ expect(result.isValid).toBe(false);
253
+ expect(result.errors).toContain("API module 'existing-module' is already added to this integration");
254
+ });
255
+
256
+ test('fails for invalid version format', () => {
257
+ const integration = Integration.create({
258
+ name: 'my-integration',
259
+ displayName: 'My Integration',
260
+ type: 'api'
261
+ });
262
+
263
+ const result = validator.validateApiModuleAddition(integration, 'my-module', 'invalid-version');
264
+
265
+ expect(result.isValid).toBe(false);
266
+ expect(result.errors.some(e => e.includes('Invalid API module version format'))).toBe(true);
267
+ });
268
+ });
269
+ });
@@ -0,0 +1,82 @@
1
+ const {IntegrationName} = require('../../../domain/value-objects/IntegrationName');
2
+ const {DomainException} = require('../../../domain/exceptions/DomainException');
3
+
4
+ describe('IntegrationName Value Object', () => {
5
+ describe('valid names', () => {
6
+ test('accepts valid kebab-case name', () => {
7
+ const name = new IntegrationName('salesforce-sync');
8
+ expect(name.value).toBe('salesforce-sync');
9
+ });
10
+
11
+ test('accepts name with numbers', () => {
12
+ const name = new IntegrationName('api-module-v2');
13
+ expect(name.value).toBe('api-module-v2');
14
+ });
15
+
16
+ test('accepts two-character name', () => {
17
+ const name = new IntegrationName('ab');
18
+ expect(name.value).toBe('ab');
19
+ });
20
+ });
21
+
22
+ describe('invalid names', () => {
23
+ test('rejects uppercase letters', () => {
24
+ expect(() => new IntegrationName('SalesforceSync'))
25
+ .toThrow(DomainException);
26
+ });
27
+
28
+ test('rejects name starting with hyphen', () => {
29
+ expect(() => new IntegrationName('-salesforce'))
30
+ .toThrow(DomainException);
31
+ });
32
+
33
+ test('rejects name ending with hyphen', () => {
34
+ expect(() => new IntegrationName('salesforce-'))
35
+ .toThrow(DomainException);
36
+ });
37
+
38
+ test('rejects consecutive hyphens', () => {
39
+ expect(() => new IntegrationName('salesforce--sync'))
40
+ .toThrow(DomainException);
41
+ });
42
+
43
+ test('rejects name with spaces', () => {
44
+ expect(() => new IntegrationName('salesforce sync'))
45
+ .toThrow(DomainException);
46
+ });
47
+
48
+ test('rejects name with underscores', () => {
49
+ expect(() => new IntegrationName('salesforce_sync'))
50
+ .toThrow(DomainException);
51
+ });
52
+
53
+ test('rejects single character name', () => {
54
+ expect(() => new IntegrationName('a'))
55
+ .toThrow(DomainException);
56
+ });
57
+
58
+ test('rejects empty name', () => {
59
+ expect(() => new IntegrationName(''))
60
+ .toThrow(DomainException);
61
+ });
62
+
63
+ test('rejects null', () => {
64
+ expect(() => new IntegrationName(null))
65
+ .toThrow(DomainException);
66
+ });
67
+ });
68
+
69
+ describe('equality', () => {
70
+ test('equal names are equal', () => {
71
+ const name1 = new IntegrationName('salesforce-sync');
72
+ const name2 = new IntegrationName('salesforce-sync');
73
+ expect(name1.equals(name2)).toBe(true);
74
+ });
75
+
76
+ test('different names are not equal', () => {
77
+ const name1 = new IntegrationName('salesforce-sync');
78
+ const name2 = new IntegrationName('hubspot-sync');
79
+ expect(name1.equals(name2)).toBe(false);
80
+ });
81
+ });
82
+ });