@friggframework/devtools 2.0.0--canary.400.bed3308.0 → 2.0.0--canary.404.e9d4980.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 (182) hide show
  1. package/frigg-cli/build-command/index.js +3 -18
  2. package/frigg-cli/deploy-command/index.js +3 -19
  3. package/frigg-cli/index.js +1 -73
  4. package/frigg-cli/install-command/index.js +2 -15
  5. package/frigg-cli/start-command/index.js +2 -17
  6. package/infrastructure/create-frigg-infrastructure.js +2 -2
  7. package/infrastructure/serverless-template.js +79 -529
  8. package/package.json +5 -9
  9. package/frigg-cli/.eslintrc.js +0 -141
  10. package/frigg-cli/__tests__/jest.config.js +0 -102
  11. package/frigg-cli/__tests__/unit/commands/build.test.js +0 -483
  12. package/frigg-cli/__tests__/unit/commands/install.test.js +0 -418
  13. package/frigg-cli/__tests__/unit/commands/ui.test.js +0 -592
  14. package/frigg-cli/__tests__/utils/command-tester.js +0 -170
  15. package/frigg-cli/__tests__/utils/mock-factory.js +0 -270
  16. package/frigg-cli/__tests__/utils/test-fixtures.js +0 -463
  17. package/frigg-cli/__tests__/utils/test-setup.js +0 -286
  18. package/frigg-cli/generate-command/__tests__/generate-command.test.js +0 -312
  19. package/frigg-cli/generate-command/azure-generator.js +0 -43
  20. package/frigg-cli/generate-command/gcp-generator.js +0 -47
  21. package/frigg-cli/generate-command/index.js +0 -350
  22. package/frigg-cli/generate-command/terraform-generator.js +0 -555
  23. package/frigg-cli/generate-iam-command.js +0 -115
  24. package/frigg-cli/package.json +0 -75
  25. package/frigg-cli/ui-command/index.js +0 -167
  26. package/frigg-cli/utils/app-resolver.js +0 -319
  27. package/frigg-cli/utils/backend-path.js +0 -38
  28. package/frigg-cli/utils/process-manager.js +0 -199
  29. package/frigg-cli/utils/repo-detection.js +0 -405
  30. package/infrastructure/AWS-DISCOVERY-TROUBLESHOOTING.md +0 -245
  31. package/infrastructure/AWS-IAM-CREDENTIAL-NEEDS.md +0 -620
  32. package/infrastructure/DEPLOYMENT-INSTRUCTIONS.md +0 -268
  33. package/infrastructure/GENERATE-IAM-DOCS.md +0 -253
  34. package/infrastructure/IAM-POLICY-TEMPLATES.md +0 -176
  35. package/infrastructure/README-TESTING.md +0 -332
  36. package/infrastructure/README.md +0 -421
  37. package/infrastructure/WEBSOCKET-CONFIGURATION.md +0 -105
  38. package/infrastructure/__tests__/fixtures/mock-aws-resources.js +0 -391
  39. package/infrastructure/__tests__/helpers/test-utils.js +0 -277
  40. package/infrastructure/aws-discovery.js +0 -568
  41. package/infrastructure/aws-discovery.test.js +0 -373
  42. package/infrastructure/build-time-discovery.js +0 -206
  43. package/infrastructure/build-time-discovery.test.js +0 -375
  44. package/infrastructure/frigg-deployment-iam-stack.yaml +0 -393
  45. package/infrastructure/iam-generator.js +0 -810
  46. package/infrastructure/iam-generator.test.js +0 -169
  47. package/infrastructure/iam-policy-basic.json +0 -236
  48. package/infrastructure/iam-policy-full.json +0 -305
  49. package/infrastructure/integration.test.js +0 -383
  50. package/infrastructure/run-discovery.js +0 -110
  51. package/infrastructure/serverless-template.test.js +0 -553
  52. package/management-ui/.eslintrc.js +0 -22
  53. package/management-ui/README.md +0 -203
  54. package/management-ui/components.json +0 -21
  55. package/management-ui/index.html +0 -13
  56. package/management-ui/merge-conflict-cleaner.py +0 -371
  57. package/management-ui/package-lock.json +0 -10997
  58. package/management-ui/package.json +0 -76
  59. package/management-ui/postcss.config.js +0 -6
  60. package/management-ui/server/api/backend.js +0 -256
  61. package/management-ui/server/api/cli.js +0 -315
  62. package/management-ui/server/api/codegen.js +0 -663
  63. package/management-ui/server/api/connections.js +0 -857
  64. package/management-ui/server/api/discovery.js +0 -185
  65. package/management-ui/server/api/environment/index.js +0 -1
  66. package/management-ui/server/api/environment/router.js +0 -378
  67. package/management-ui/server/api/environment.js +0 -328
  68. package/management-ui/server/api/integrations.js +0 -479
  69. package/management-ui/server/api/logs.js +0 -248
  70. package/management-ui/server/api/monitoring.js +0 -282
  71. package/management-ui/server/api/open-ide.js +0 -31
  72. package/management-ui/server/api/project.js +0 -553
  73. package/management-ui/server/api/users/sessions.js +0 -371
  74. package/management-ui/server/api/users/simulation.js +0 -254
  75. package/management-ui/server/api/users.js +0 -362
  76. package/management-ui/server/api-contract.md +0 -275
  77. package/management-ui/server/index.js +0 -428
  78. package/management-ui/server/middleware/errorHandler.js +0 -70
  79. package/management-ui/server/middleware/security.js +0 -32
  80. package/management-ui/server/processManager.js +0 -296
  81. package/management-ui/server/server.js +0 -188
  82. package/management-ui/server/services/aws-monitor.js +0 -413
  83. package/management-ui/server/services/npm-registry.js +0 -347
  84. package/management-ui/server/services/template-engine.js +0 -538
  85. package/management-ui/server/utils/cliIntegration.js +0 -220
  86. package/management-ui/server/utils/environment/auditLogger.js +0 -471
  87. package/management-ui/server/utils/environment/awsParameterStore.js +0 -264
  88. package/management-ui/server/utils/environment/encryption.js +0 -278
  89. package/management-ui/server/utils/environment/envFileManager.js +0 -286
  90. package/management-ui/server/utils/import-commonjs.js +0 -28
  91. package/management-ui/server/utils/response.js +0 -83
  92. package/management-ui/server/websocket/handler.js +0 -325
  93. package/management-ui/src/App.jsx +0 -51
  94. package/management-ui/src/assets/FriggLogo.svg +0 -1
  95. package/management-ui/src/components/AppRouter.jsx +0 -65
  96. package/management-ui/src/components/Button.jsx +0 -2
  97. package/management-ui/src/components/Card.jsx +0 -9
  98. package/management-ui/src/components/EnvironmentCompare.jsx +0 -400
  99. package/management-ui/src/components/EnvironmentEditor.jsx +0 -372
  100. package/management-ui/src/components/EnvironmentImportExport.jsx +0 -469
  101. package/management-ui/src/components/EnvironmentSchema.jsx +0 -491
  102. package/management-ui/src/components/EnvironmentSecurity.jsx +0 -463
  103. package/management-ui/src/components/ErrorBoundary.jsx +0 -73
  104. package/management-ui/src/components/IntegrationCard.jsx +0 -199
  105. package/management-ui/src/components/IntegrationCardEnhanced.jsx +0 -490
  106. package/management-ui/src/components/IntegrationExplorer.jsx +0 -379
  107. package/management-ui/src/components/IntegrationStatus.jsx +0 -235
  108. package/management-ui/src/components/Layout.jsx +0 -250
  109. package/management-ui/src/components/LoadingSpinner.jsx +0 -45
  110. package/management-ui/src/components/RepositoryPicker.jsx +0 -248
  111. package/management-ui/src/components/SessionMonitor.jsx +0 -255
  112. package/management-ui/src/components/StatusBadge.jsx +0 -70
  113. package/management-ui/src/components/UserContextSwitcher.jsx +0 -154
  114. package/management-ui/src/components/UserSimulation.jsx +0 -299
  115. package/management-ui/src/components/Welcome.jsx +0 -434
  116. package/management-ui/src/components/codegen/APIEndpointGenerator.jsx +0 -637
  117. package/management-ui/src/components/codegen/APIModuleSelector.jsx +0 -227
  118. package/management-ui/src/components/codegen/CodeGenerationWizard.jsx +0 -247
  119. package/management-ui/src/components/codegen/CodePreviewEditor.jsx +0 -316
  120. package/management-ui/src/components/codegen/DynamicModuleForm.jsx +0 -271
  121. package/management-ui/src/components/codegen/FormBuilder.jsx +0 -737
  122. package/management-ui/src/components/codegen/IntegrationGenerator.jsx +0 -855
  123. package/management-ui/src/components/codegen/ProjectScaffoldWizard.jsx +0 -797
  124. package/management-ui/src/components/codegen/SchemaBuilder.jsx +0 -303
  125. package/management-ui/src/components/codegen/TemplateSelector.jsx +0 -586
  126. package/management-ui/src/components/codegen/index.js +0 -10
  127. package/management-ui/src/components/connections/ConnectionConfigForm.jsx +0 -362
  128. package/management-ui/src/components/connections/ConnectionHealthMonitor.jsx +0 -182
  129. package/management-ui/src/components/connections/ConnectionTester.jsx +0 -200
  130. package/management-ui/src/components/connections/EntityRelationshipMapper.jsx +0 -292
  131. package/management-ui/src/components/connections/OAuthFlow.jsx +0 -204
  132. package/management-ui/src/components/connections/index.js +0 -5
  133. package/management-ui/src/components/index.js +0 -21
  134. package/management-ui/src/components/monitoring/APIGatewayMetrics.jsx +0 -222
  135. package/management-ui/src/components/monitoring/LambdaMetrics.jsx +0 -169
  136. package/management-ui/src/components/monitoring/MetricsChart.jsx +0 -197
  137. package/management-ui/src/components/monitoring/MonitoringDashboard.jsx +0 -393
  138. package/management-ui/src/components/monitoring/SQSMetrics.jsx +0 -246
  139. package/management-ui/src/components/monitoring/index.js +0 -6
  140. package/management-ui/src/components/monitoring/monitoring.css +0 -218
  141. package/management-ui/src/components/theme-provider.jsx +0 -52
  142. package/management-ui/src/components/theme-toggle.jsx +0 -39
  143. package/management-ui/src/components/ui/badge.tsx +0 -36
  144. package/management-ui/src/components/ui/button.test.jsx +0 -56
  145. package/management-ui/src/components/ui/button.tsx +0 -57
  146. package/management-ui/src/components/ui/card.tsx +0 -76
  147. package/management-ui/src/components/ui/dropdown-menu.tsx +0 -199
  148. package/management-ui/src/components/ui/select.tsx +0 -157
  149. package/management-ui/src/components/ui/skeleton.jsx +0 -15
  150. package/management-ui/src/hooks/useFrigg.jsx +0 -387
  151. package/management-ui/src/hooks/useSocket.jsx +0 -58
  152. package/management-ui/src/index.css +0 -194
  153. package/management-ui/src/lib/utils.ts +0 -6
  154. package/management-ui/src/main.jsx +0 -10
  155. package/management-ui/src/pages/CodeGeneration.jsx +0 -14
  156. package/management-ui/src/pages/Connections.jsx +0 -252
  157. package/management-ui/src/pages/ConnectionsEnhanced.jsx +0 -427
  158. package/management-ui/src/pages/Dashboard.jsx +0 -311
  159. package/management-ui/src/pages/Environment.jsx +0 -314
  160. package/management-ui/src/pages/IntegrationConfigure.jsx +0 -544
  161. package/management-ui/src/pages/IntegrationDiscovery.jsx +0 -479
  162. package/management-ui/src/pages/IntegrationTest.jsx +0 -494
  163. package/management-ui/src/pages/Integrations.jsx +0 -254
  164. package/management-ui/src/pages/Monitoring.jsx +0 -17
  165. package/management-ui/src/pages/Simulation.jsx +0 -155
  166. package/management-ui/src/pages/Users.jsx +0 -492
  167. package/management-ui/src/services/api.js +0 -41
  168. package/management-ui/src/services/apiModuleService.js +0 -193
  169. package/management-ui/src/services/websocket-handlers.js +0 -120
  170. package/management-ui/src/test/api/project.test.js +0 -273
  171. package/management-ui/src/test/components/Welcome.test.jsx +0 -378
  172. package/management-ui/src/test/mocks/server.js +0 -178
  173. package/management-ui/src/test/setup.js +0 -61
  174. package/management-ui/src/test/utils/test-utils.jsx +0 -134
  175. package/management-ui/src/utils/repository.js +0 -98
  176. package/management-ui/src/utils/repository.test.js +0 -118
  177. package/management-ui/src/workflows/phase2-integration-workflows.js +0 -884
  178. package/management-ui/tailwind.config.js +0 -63
  179. package/management-ui/tsconfig.json +0 -37
  180. package/management-ui/tsconfig.node.json +0 -10
  181. package/management-ui/vite.config.js +0 -26
  182. package/management-ui/vitest.config.js +0 -38
@@ -1,855 +0,0 @@
1
- import React, { useState, useCallback, useEffect } from 'react';
2
- import { Card } from '../Card';
3
- import { Button } from '../Button';
4
- import FormBuilder from './FormBuilder';
5
- import SchemaBuilder from './SchemaBuilder';
6
- import APIModuleSelector from './APIModuleSelector';
7
- import apiModuleService from '../../services/apiModuleService';
8
-
9
- const API_MODULE_TYPES = {
10
- API: 'api',
11
- OAUTH1: 'oauth1',
12
- OAUTH2: 'oauth2',
13
- BASIC_AUTH: 'basic-auth',
14
- CUSTOM: 'custom'
15
- };
16
-
17
- const AUTHENTICATION_FIELDS = {
18
- [API_MODULE_TYPES.API]: [
19
- { name: 'apiKey', label: 'API Key', type: 'string', required: true, encrypted: false }
20
- ],
21
- [API_MODULE_TYPES.OAUTH2]: [
22
- { name: 'access_token', label: 'Access Token', type: 'string', required: true, encrypted: false },
23
- { name: 'refresh_token', label: 'Refresh Token', type: 'string', required: false, encrypted: false },
24
- { name: 'expires_at', label: 'Expires At', type: 'date', required: false, encrypted: false },
25
- { name: 'scope', label: 'Scope', type: 'string', required: false, encrypted: false }
26
- ],
27
- [API_MODULE_TYPES.BASIC_AUTH]: [
28
- { name: 'username', label: 'Username', type: 'string', required: true, encrypted: false },
29
- { name: 'password', label: 'Password', type: 'string', required: true, encrypted: true }
30
- ],
31
- [API_MODULE_TYPES.OAUTH1]: [
32
- { name: 'oauth_token', label: 'OAuth Token', type: 'string', required: true, encrypted: false },
33
- { name: 'oauth_token_secret', label: 'OAuth Token Secret', type: 'string', required: true, encrypted: true }
34
- ]
35
- };
36
-
37
- const IntegrationGenerator = ({ onGenerate }) => {
38
- const [formData, setFormData] = useState({
39
- name: '',
40
- displayName: '',
41
- description: '',
42
- category: 'API Module',
43
- type: API_MODULE_TYPES.API,
44
- baseURL: '',
45
- authorizationURL: '',
46
- tokenURL: '',
47
- scope: '',
48
- apiEndpoints: [],
49
- entitySchema: [],
50
- useExistingModule: false,
51
- selectedModule: null,
52
- moduleDetails: null
53
- });
54
-
55
- const [currentTab, setCurrentTab] = useState('basic');
56
- const [moduleDetailsLoading, setModuleDetailsLoading] = useState(false);
57
-
58
- const handleInputChange = useCallback((field, value) => {
59
- setFormData(prev => ({
60
- ...prev,
61
- [field]: value
62
- }));
63
- }, []);
64
-
65
- const handleModuleSelect = useCallback(async (moduleName) => {
66
- setFormData(prev => ({
67
- ...prev,
68
- selectedModule: moduleName
69
- }));
70
-
71
- if (moduleName) {
72
- setModuleDetailsLoading(true);
73
- try {
74
- const details = await apiModuleService.getModuleDetails(moduleName);
75
- setFormData(prev => ({
76
- ...prev,
77
- moduleDetails: details,
78
- // Auto-fill form fields based on module
79
- name: details.name.replace('@friggframework/api-module-', ''),
80
- displayName: details.displayName,
81
- description: details.description || prev.description,
82
- type: details.authType === 'oauth2' ? INTEGRATION_TYPES.OAUTH2 :
83
- details.authType === 'api-key' ? INTEGRATION_TYPES.API :
84
- details.authType === 'basic-auth' ? INTEGRATION_TYPES.BASIC_AUTH :
85
- INTEGRATION_TYPES.CUSTOM
86
- }));
87
- } catch (error) {
88
- console.error('Error loading module details:', error);
89
- } finally {
90
- setModuleDetailsLoading(false);
91
- }
92
- }
93
- }, []);
94
-
95
- const handleEndpointAdd = useCallback(() => {
96
- setFormData(prev => ({
97
- ...prev,
98
- apiEndpoints: [
99
- ...prev.apiEndpoints,
100
- {
101
- id: Date.now(),
102
- name: '',
103
- method: 'GET',
104
- path: '',
105
- description: '',
106
- parameters: [],
107
- responseSchema: {}
108
- }
109
- ]
110
- }));
111
- }, []);
112
-
113
- const handleEndpointUpdate = useCallback((id, updates) => {
114
- setFormData(prev => ({
115
- ...prev,
116
- apiEndpoints: prev.apiEndpoints.map(endpoint =>
117
- endpoint.id === id ? { ...endpoint, ...updates } : endpoint
118
- )
119
- }));
120
- }, []);
121
-
122
- const handleEndpointRemove = useCallback((id) => {
123
- setFormData(prev => ({
124
- ...prev,
125
- apiEndpoints: prev.apiEndpoints.filter(endpoint => endpoint.id !== id)
126
- }));
127
- }, []);
128
-
129
- const generateIntegrationCode = useCallback(() => {
130
- const className = formData.name.replace(/-/g, '_').replace(/(?:^|_)(\w)/g, (_, c) => c.toUpperCase());
131
-
132
- // If using existing module, generate wrapper code
133
- if (formData.useExistingModule && formData.selectedModule) {
134
- return generateModuleWrapperCode();
135
- }
136
-
137
- // Otherwise generate full custom integration
138
- const authFields = AUTHENTICATION_FIELDS[formData.type] || [];
139
- const allEntityFields = [...authFields, ...formData.entitySchema, { name: 'user_id', label: 'User ID', type: 'string', required: true }];
140
-
141
- // Generate Entity class
142
- const entityCode = `class ${className}Entity extends Entity {
143
- static tableName = '${formData.name}';
144
-
145
- static getSchema() {
146
- return {
147
- ${allEntityFields.map(field =>
148
- ` ${field.name}: { type: '${field.type}', required: ${field.required}${field.encrypted ? ', encrypted: true' : ''}${field.default ? `, default: '${field.default}'` : ''} }`
149
- ).join(',\n')}
150
- };
151
- }
152
- }`;
153
-
154
- // Generate API class
155
- const apiMethods = formData.apiEndpoints.map(endpoint => {
156
- const methodName = endpoint.name || `${endpoint.method.toLowerCase()}${endpoint.path.replace(/[^a-zA-Z0-9]/g, '')}`;
157
- const hasParams = endpoint.parameters && endpoint.parameters.length > 0;
158
-
159
- return ` async ${methodName}(${hasParams ? 'params = {}' : ''}) {
160
- const response = await this.${endpoint.method.toLowerCase()}('${endpoint.path}'${hasParams ? ', params' : ''});
161
- return response.data;
162
- }`;
163
- }).join('\n\n');
164
-
165
- const apiCode = `class ${className}Api extends Api {
166
- constructor(config) {
167
- super(config);
168
- this.baseURL = '${formData.baseURL || 'https://api.example.com'}';
169
- this.headers = {
170
- 'Content-Type': 'application/json'
171
- };
172
- }
173
-
174
- ${formData.type === INTEGRATION_TYPES.API ? ` setApiKey(apiKey) {
175
- this.headers['Authorization'] = \`Bearer \${apiKey}\`;
176
- }` : ''}
177
-
178
- ${formData.type === INTEGRATION_TYPES.BASIC_AUTH ? ` setCredentials(username, password) {
179
- const credentials = Buffer.from(\`\${username}:\${password}\`).toString('base64');
180
- this.headers['Authorization'] = \`Basic \${credentials}\`;
181
- }` : ''}
182
-
183
- ${formData.type === INTEGRATION_TYPES.OAUTH2 ? ` setAccessToken(token) {
184
- this.headers['Authorization'] = \`Bearer \${token}\`;
185
- }` : ''}
186
-
187
- async testConnection() {
188
- const response = await this.get('/ping');
189
- return response.data;
190
- }
191
-
192
- ${apiMethods || ' // Add your API methods here'}
193
- }`;
194
-
195
- // Generate Integration class
196
- const integrationCode = `class ${className}Integration extends IntegrationBase {
197
- static Entity = ${className}Entity;
198
- static Api = ${className}Api;
199
- static type = '${formData.name}';
200
-
201
- static Config = {
202
- name: '${formData.name}',
203
- displayName: '${formData.displayName}',
204
- description: '${formData.description}',
205
- category: '${formData.category}',
206
- version: '1.0.0',
207
- supportedVersions: ['1.0.0']
208
- };
209
-
210
- async connect(params) {
211
- const api = new ${className}Api();
212
-
213
- // Set authentication
214
- ${formData.type === INTEGRATION_TYPES.API ? ` api.setApiKey(params.apiKey);` : ''}
215
- ${formData.type === INTEGRATION_TYPES.BASIC_AUTH ? ` api.setCredentials(params.username, params.password);` : ''}
216
- ${formData.type === INTEGRATION_TYPES.OAUTH2 ? ` api.setAccessToken(params.access_token);` : ''}
217
-
218
- try {
219
- await api.testConnection();
220
- } catch (error) {
221
- throw new Error('Connection failed: ' + error.message);
222
- }
223
-
224
- const entity = await ${className}Entity.create({
225
- ${authFields.map(field => ` ${field.name}: params.${field.name}`).join(',\n')},
226
- user_id: params.userId
227
- });
228
-
229
- return entity;
230
- }
231
-
232
- static async checkConnection(entity) {
233
- const api = new ${className}Api();
234
-
235
- ${formData.type === INTEGRATION_TYPES.API ? ` api.setApiKey(entity.apiKey);` : ''}
236
- ${formData.type === INTEGRATION_TYPES.BASIC_AUTH ? ` api.setCredentials(entity.username, entity.password);` : ''}
237
- ${formData.type === INTEGRATION_TYPES.OAUTH2 ? ` api.setAccessToken(entity.access_token);` : ''}
238
-
239
- try {
240
- await api.testConnection();
241
- return true;
242
- } catch (error) {
243
- return false;
244
- }
245
- }
246
- }`;
247
-
248
- const fullCode = `const { Api, Entity, IntegrationBase } = require('@friggframework/core');
249
- ${formData.type === INTEGRATION_TYPES.OAUTH2 ? "const { OAuth2AuthorizationCode } = require('@friggframework/oauth2');" : ''}
250
-
251
- ${entityCode}
252
-
253
- ${apiCode}
254
-
255
- ${integrationCode}
256
-
257
- module.exports = ${className}Integration;`;
258
-
259
- const metadata = {
260
- name: formData.name,
261
- className,
262
- type: formData.type,
263
- files: [
264
- { name: 'index.js', content: fullCode },
265
- { name: 'package.json', content: generatePackageJson() },
266
- { name: 'README.md', content: generateReadme() },
267
- { name: '__tests__/index.test.js', content: generateTestFile() }
268
- ]
269
- };
270
-
271
- onGenerate(formData, fullCode, metadata);
272
- }, [formData, onGenerate]);
273
-
274
- const generateModuleWrapperCode = () => {
275
- const className = formData.name.replace(/-/g, '_').replace(/(?:^|_)(\w)/g, (_, c) => c.toUpperCase());
276
- const moduleName = formData.selectedModule;
277
- const moduleDetails = formData.moduleDetails || {};
278
-
279
- // Generate wrapper code that extends the npm module
280
- const wrapperCode = `const ${className}Module = require('${moduleName}');
281
- const { IntegrationBase } = require('@friggframework/core');
282
-
283
- // Wrapper class that extends the npm module with custom functionality
284
- class ${className}Integration extends IntegrationBase {
285
- static Api = ${className}Module.Api;
286
- static Entity = ${className}Module.Entity;
287
- static Config = {
288
- ...${className}Module.Config,
289
- // Override or extend configuration
290
- displayName: '${formData.displayName || moduleDetails.displayName}',
291
- description: '${formData.description || moduleDetails.description}'
292
- };
293
-
294
- constructor(config) {
295
- super(config);
296
- // Initialize the base module
297
- this.module = new ${className}Module(config);
298
- }
299
-
300
- async connect(params) {
301
- // Delegate to the module's connect method
302
- return this.module.connect(params);
303
- }
304
-
305
- static async checkConnection(entity) {
306
- // Delegate to the module's checkConnection method
307
- return ${className}Module.checkConnection(entity);
308
- }
309
-
310
- // Add custom methods here
311
- ${formData.apiEndpoints.map(endpoint => {
312
- const methodName = endpoint.name || `${endpoint.method.toLowerCase()}${endpoint.path.replace(/[^a-zA-Z0-9]/g, '')}`;
313
- return ` async ${methodName}(params = {}) {
314
- const api = new ${className}Module.Api(this.entity);
315
- return api.${endpoint.method.toLowerCase()}('${endpoint.path}', params);
316
- }`;
317
- }).join('\n\n')}
318
- }
319
-
320
- module.exports = ${className}Integration;`;
321
-
322
- const packageJson = {
323
- name: `@your-org/${formData.name}-integration`,
324
- version: '0.1.0',
325
- description: formData.description || `Integration wrapper for ${moduleName}`,
326
- main: 'index.js',
327
- scripts: {
328
- test: 'jest',
329
- 'test:watch': 'jest --watch'
330
- },
331
- keywords: ['frigg', 'integration', formData.name],
332
- dependencies: {
333
- '@friggframework/core': '^1.0.0',
334
- [moduleName]: `^${moduleDetails.version || 'latest'}`
335
- },
336
- devDependencies: {
337
- '@jest/globals': '^29.0.0',
338
- 'jest': '^29.0.0'
339
- }
340
- };
341
-
342
- const readme = `# ${formData.displayName || moduleDetails.displayName} Integration
343
-
344
- ${formData.description || moduleDetails.description}
345
-
346
- This integration extends the [${moduleName}](https://www.npmjs.com/package/${moduleName}) module.
347
-
348
- ## Installation
349
-
350
- \`\`\`bash
351
- npm install ${moduleName}
352
- \`\`\`
353
-
354
- ## Configuration
355
-
356
- ${moduleDetails.requiredFields?.map(field => `- **${field.label}**: ${field.type}${field.required ? ' (required)' : ''}`).join('\n') || 'See module documentation for required configuration.'}
357
-
358
- ## Usage
359
-
360
- \`\`\`javascript
361
- const ${className}Integration = require('./index');
362
-
363
- const integration = new ${className}Integration(config);
364
-
365
- // Connect
366
- const entity = await integration.connect({
367
- ${moduleDetails.requiredFields?.map(field => ` ${field.name}: 'your-${field.name}'`).join(',\n') || ' // Add required parameters'}
368
- });
369
- \`\`\`
370
-
371
- ## API Methods
372
-
373
- ${formData.apiEndpoints.map(endpoint => `- \`${endpoint.name || 'endpoint'}\`: ${endpoint.description || 'No description'}`).join('\n') || 'See module documentation for available methods.'}
374
- `;
375
-
376
- const metadata = {
377
- name: formData.name,
378
- className,
379
- type: 'module-wrapper',
380
- baseModule: moduleName,
381
- files: [
382
- { name: 'index.js', content: wrapperCode },
383
- { name: 'package.json', content: JSON.stringify(packageJson, null, 2) },
384
- { name: 'README.md', content: readme }
385
- ]
386
- };
387
-
388
- onGenerate(formData, wrapperCode, metadata);
389
- };
390
-
391
- const generatePackageJson = () => {
392
- const className = formData.name.replace(/-/g, '_').replace(/(?:^|_)(\w)/g, (_, c) => c.toUpperCase());
393
- return JSON.stringify({
394
- name: `@friggframework/${formData.name}`,
395
- version: '0.1.0',
396
- description: formData.description,
397
- main: 'index.js',
398
- scripts: {
399
- test: 'jest',
400
- 'test:watch': 'jest --watch'
401
- },
402
- keywords: ['frigg', 'integration', formData.name],
403
- dependencies: {
404
- '@friggframework/core': '^1.0.0',
405
- ...(formData.type === INTEGRATION_TYPES.OAUTH2 ? { '@friggframework/oauth2': '^1.0.0' } : {})
406
- },
407
- devDependencies: {
408
- '@jest/globals': '^29.0.0',
409
- 'jest': '^29.0.0'
410
- }
411
- }, null, 2);
412
- };
413
-
414
- const generateReadme = () => {
415
- const className = formData.name.replace(/-/g, '_').replace(/(?:^|_)(\w)/g, (_, c) => c.toUpperCase());
416
- return `# ${formData.displayName} Integration
417
-
418
- ${formData.description}
419
-
420
- ## Installation
421
-
422
- \`\`\`bash
423
- npm install @friggframework/${formData.name}
424
- \`\`\`
425
-
426
- ## Usage
427
-
428
- \`\`\`javascript
429
- const ${className}Integration = require('@friggframework/${formData.name}');
430
-
431
- const integration = new ${className}Integration();
432
-
433
- // Connect
434
- const entity = await integration.connect({
435
- ${AUTHENTICATION_FIELDS[formData.type]?.map(field => ` ${field.name}: 'your-${field.name.replace(/_/g, '-')}'`).join(',\n') || ' // Add your authentication parameters'}
436
- userId: 'user-123'
437
- });
438
-
439
- // Check connection
440
- const isConnected = await ${className}Integration.checkConnection(entity);
441
- \`\`\`
442
-
443
- ## API Methods
444
-
445
- ${formData.apiEndpoints.map(endpoint => `- \`${endpoint.name || 'endpoint'}\`: ${endpoint.description || 'No description'}`).join('\n') || '- Add your API methods here'}
446
-
447
- ## License
448
-
449
- MIT`;
450
- };
451
-
452
- const generateTestFile = () => {
453
- const className = formData.name.replace(/-/g, '_').replace(/(?:^|_)(\w)/g, (_, c) => c.toUpperCase());
454
- return `const { describe, it, expect } = require('@jest/globals');
455
- const ${className}Integration = require('../index');
456
-
457
- describe('${className}Integration', () => {
458
- it('should have correct configuration', () => {
459
- expect(${className}Integration.Config.name).toBe('${formData.name}');
460
- expect(${className}Integration.type).toBe('${formData.name}');
461
- });
462
-
463
- it('should have Entity and Api classes', () => {
464
- expect(${className}Integration.Entity).toBeDefined();
465
- expect(${className}Integration.Api).toBeDefined();
466
- });
467
-
468
- describe('Entity', () => {
469
- it('should have correct table name', () => {
470
- expect(${className}Integration.Entity.tableName).toBe('${formData.name}');
471
- });
472
-
473
- it('should have valid schema', () => {
474
- const schema = ${className}Integration.Entity.getSchema();
475
- expect(schema).toBeDefined();
476
- expect(schema.user_id).toBeDefined();
477
- });
478
- });
479
-
480
- describe('Api', () => {
481
- it('should initialize with correct baseURL', () => {
482
- const api = new ${className}Integration.Api();
483
- expect(api.baseURL).toBe('${formData.baseURL || 'https://api.example.com'}');
484
- });
485
- });
486
- });`;
487
- };
488
-
489
- const tabs = [
490
- { id: 'module', label: 'Module Selection', icon: '📦' },
491
- { id: 'basic', label: 'Basic Info', icon: '📝' },
492
- { id: 'auth', label: 'Authentication', icon: '🔐' },
493
- { id: 'endpoints', label: 'API Endpoints', icon: '🔗' },
494
- { id: 'schema', label: 'Entity Schema', icon: '📊' }
495
- ];
496
-
497
- return (
498
- <div className="space-y-6">
499
- <h2 className="text-2xl font-bold">Integration Generator</h2>
500
-
501
- {/* Tab Navigation */}
502
- <div className="border-b border-gray-200">
503
- <nav className="-mb-px flex space-x-8">
504
- {tabs.map((tab) => (
505
- <button
506
- key={tab.id}
507
- onClick={() => setCurrentTab(tab.id)}
508
- className={`py-2 px-1 border-b-2 font-medium text-sm ${
509
- currentTab === tab.id
510
- ? 'border-blue-500 text-blue-600'
511
- : 'border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300'
512
- }`}
513
- >
514
- <span className="mr-2">{tab.icon}</span>
515
- {tab.label}
516
- </button>
517
- ))}
518
- </nav>
519
- </div>
520
-
521
- {/* Tab Content */}
522
- <Card className="p-6">
523
- {currentTab === 'module' && (
524
- <div className="space-y-4">
525
- <div className="mb-6">
526
- <label className="flex items-center space-x-3">
527
- <input
528
- type="checkbox"
529
- checked={formData.useExistingModule}
530
- onChange={(e) => handleInputChange('useExistingModule', e.target.checked)}
531
- className="h-4 w-4 text-blue-600 rounded focus:ring-blue-500"
532
- />
533
- <span className="text-sm font-medium text-gray-700">
534
- Use existing Frigg API module from npm
535
- </span>
536
- </label>
537
- <p className="text-sm text-gray-500 mt-1 ml-7">
538
- Select from pre-built API modules or create a custom integration from scratch
539
- </p>
540
- </div>
541
-
542
- {formData.useExistingModule && (
543
- <APIModuleSelector
544
- selectedModule={formData.selectedModule}
545
- onSelect={handleModuleSelect}
546
- />
547
- )}
548
-
549
- {!formData.useExistingModule && (
550
- <div className="bg-gray-50 rounded-lg p-6 text-center">
551
- <svg className="w-12 h-12 text-gray-400 mx-auto mb-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
552
- <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M10 20l4-16m4 4l4 4-4 4M6 16l-4-4 4-4" />
553
- </svg>
554
- <h3 className="text-lg font-medium text-gray-900 mb-2">Custom Integration</h3>
555
- <p className="text-sm text-gray-600">
556
- Build a custom integration from scratch with full control over the implementation
557
- </p>
558
- </div>
559
- )}
560
- </div>
561
- )}
562
-
563
- {currentTab === 'basic' && (
564
- <div className="space-y-4">
565
- {formData.useExistingModule && formData.selectedModule && (
566
- <div className="bg-blue-50 border border-blue-200 rounded-lg p-4 mb-4">
567
- <div className="flex items-start">
568
- <svg className="w-5 h-5 text-blue-600 mt-0.5 mr-2" fill="currentColor" viewBox="0 0 20 20">
569
- <path fillRule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z" clipRule="evenodd" />
570
- </svg>
571
- <div>
572
- <p className="text-sm text-blue-800">
573
- Using <strong>{formData.moduleDetails?.displayName || formData.selectedModule}</strong> as base module.
574
- Some fields have been auto-filled from the module configuration.
575
- </p>
576
- </div>
577
- </div>
578
- </div>
579
- )}
580
-
581
- <div className="grid grid-cols-1 md:grid-cols-2 gap-4">
582
- <div>
583
- <label className="block text-sm font-medium text-gray-700 mb-2">
584
- Integration Name *
585
- </label>
586
- <input
587
- type="text"
588
- value={formData.name}
589
- onChange={(e) => handleInputChange('name', e.target.value)}
590
- placeholder="e.g., salesforce, hubspot"
591
- className="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"
592
- disabled={formData.useExistingModule && moduleDetailsLoading}
593
- />
594
- </div>
595
- <div>
596
- <label className="block text-sm font-medium text-gray-700 mb-2">
597
- Display Name
598
- </label>
599
- <input
600
- type="text"
601
- value={formData.displayName}
602
- onChange={(e) => handleInputChange('displayName', e.target.value)}
603
- placeholder="e.g., Salesforce, HubSpot"
604
- className="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"
605
- />
606
- </div>
607
- </div>
608
-
609
- <div>
610
- <label className="block text-sm font-medium text-gray-700 mb-2">
611
- Description
612
- </label>
613
- <textarea
614
- value={formData.description}
615
- onChange={(e) => handleInputChange('description', e.target.value)}
616
- placeholder="Brief description of the integration"
617
- rows={3}
618
- className="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"
619
- />
620
- </div>
621
-
622
- <div className="grid grid-cols-1 md:grid-cols-2 gap-4">
623
- <div>
624
- <label className="block text-sm font-medium text-gray-700 mb-2">
625
- Category
626
- </label>
627
- <select
628
- value={formData.category}
629
- onChange={(e) => handleInputChange('category', e.target.value)}
630
- className="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"
631
- >
632
- <option value="API Integration">API Integration</option>
633
- <option value="CRM">CRM</option>
634
- <option value="Marketing">Marketing</option>
635
- <option value="Sales">Sales</option>
636
- <option value="Support">Support</option>
637
- <option value="Analytics">Analytics</option>
638
- <option value="Communication">Communication</option>
639
- <option value="Other">Other</option>
640
- </select>
641
- </div>
642
- <div>
643
- <label className="block text-sm font-medium text-gray-700 mb-2">
644
- Base URL *
645
- </label>
646
- <input
647
- type="url"
648
- value={formData.baseURL}
649
- onChange={(e) => handleInputChange('baseURL', e.target.value)}
650
- placeholder="https://api.example.com"
651
- className="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"
652
- />
653
- </div>
654
- </div>
655
- </div>
656
- )}
657
-
658
- {currentTab === 'auth' && (
659
- <div className="space-y-4">
660
- <div>
661
- <label className="block text-sm font-medium text-gray-700 mb-2">
662
- Authentication Type
663
- </label>
664
- <select
665
- value={formData.type}
666
- onChange={(e) => handleInputChange('type', e.target.value)}
667
- className="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"
668
- >
669
- <option value={INTEGRATION_TYPES.API}>API Key</option>
670
- <option value={INTEGRATION_TYPES.OAUTH2}>OAuth 2.0</option>
671
- <option value={INTEGRATION_TYPES.BASIC_AUTH}>Basic Auth</option>
672
- <option value={INTEGRATION_TYPES.OAUTH1}>OAuth 1.0</option>
673
- <option value={INTEGRATION_TYPES.CUSTOM}>Custom</option>
674
- </select>
675
- </div>
676
-
677
- {formData.type === INTEGRATION_TYPES.OAUTH2 && (
678
- <div className="grid grid-cols-1 md:grid-cols-2 gap-4">
679
- <div>
680
- <label className="block text-sm font-medium text-gray-700 mb-2">
681
- Authorization URL
682
- </label>
683
- <input
684
- type="url"
685
- value={formData.authorizationURL}
686
- onChange={(e) => handleInputChange('authorizationURL', e.target.value)}
687
- placeholder="https://example.com/oauth/authorize"
688
- className="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"
689
- />
690
- </div>
691
- <div>
692
- <label className="block text-sm font-medium text-gray-700 mb-2">
693
- Token URL
694
- </label>
695
- <input
696
- type="url"
697
- value={formData.tokenURL}
698
- onChange={(e) => handleInputChange('tokenURL', e.target.value)}
699
- placeholder="https://example.com/oauth/token"
700
- className="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"
701
- />
702
- </div>
703
- <div className="md:col-span-2">
704
- <label className="block text-sm font-medium text-gray-700 mb-2">
705
- OAuth Scope
706
- </label>
707
- <input
708
- type="text"
709
- value={formData.scope}
710
- onChange={(e) => handleInputChange('scope', e.target.value)}
711
- placeholder="read write"
712
- className="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"
713
- />
714
- </div>
715
- </div>
716
- )}
717
-
718
- <div className="bg-gray-50 p-4 rounded-md">
719
- <h4 className="font-medium text-gray-900 mb-2">Authentication Fields</h4>
720
- <p className="text-sm text-gray-600 mb-3">
721
- The following fields will be included in the Entity schema based on your authentication type:
722
- </p>
723
- <div className="space-y-2">
724
- {AUTHENTICATION_FIELDS[formData.type]?.map((field, index) => (
725
- <div key={index} className="flex items-center justify-between text-sm">
726
- <span className="font-medium">{field.label}</span>
727
- <div className="flex items-center space-x-2">
728
- <span className="text-gray-500">{field.type}</span>
729
- {field.required && <span className="text-red-500">Required</span>}
730
- {field.encrypted && <span className="text-blue-500">Encrypted</span>}
731
- </div>
732
- </div>
733
- )) || <span className="text-gray-500">No standard fields for custom authentication</span>}
734
- </div>
735
- </div>
736
- </div>
737
- )}
738
-
739
- {currentTab === 'endpoints' && (
740
- <div className="space-y-4">
741
- <div className="flex justify-between items-center">
742
- <h3 className="text-lg font-medium">API Endpoints</h3>
743
- <Button onClick={handleEndpointAdd}>Add Endpoint</Button>
744
- </div>
745
-
746
- {formData.apiEndpoints.length === 0 && (
747
- <div className="text-center py-8 text-gray-500">
748
- No endpoints defined. Click "Add Endpoint" to get started.
749
- </div>
750
- )}
751
-
752
- {formData.apiEndpoints.map((endpoint) => (
753
- <Card key={endpoint.id} className="p-4">
754
- <div className="flex justify-between items-start mb-4">
755
- <h4 className="font-medium">Endpoint {endpoint.id}</h4>
756
- <Button
757
- variant="outline"
758
- size="sm"
759
- onClick={() => handleEndpointRemove(endpoint.id)}
760
- className="text-red-600 hover:text-red-700"
761
- >
762
- Remove
763
- </Button>
764
- </div>
765
-
766
- <div className="grid grid-cols-1 md:grid-cols-3 gap-4">
767
- <div>
768
- <label className="block text-sm font-medium text-gray-700 mb-2">
769
- Method
770
- </label>
771
- <select
772
- value={endpoint.method}
773
- onChange={(e) => handleEndpointUpdate(endpoint.id, { method: e.target.value })}
774
- className="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"
775
- >
776
- <option value="GET">GET</option>
777
- <option value="POST">POST</option>
778
- <option value="PUT">PUT</option>
779
- <option value="DELETE">DELETE</option>
780
- <option value="PATCH">PATCH</option>
781
- </select>
782
- </div>
783
- <div>
784
- <label className="block text-sm font-medium text-gray-700 mb-2">
785
- Path
786
- </label>
787
- <input
788
- type="text"
789
- value={endpoint.path}
790
- onChange={(e) => handleEndpointUpdate(endpoint.id, { path: e.target.value })}
791
- placeholder="/users"
792
- className="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"
793
- />
794
- </div>
795
- <div>
796
- <label className="block text-sm font-medium text-gray-700 mb-2">
797
- Method Name
798
- </label>
799
- <input
800
- type="text"
801
- value={endpoint.name}
802
- onChange={(e) => handleEndpointUpdate(endpoint.id, { name: e.target.value })}
803
- placeholder="getUsers"
804
- className="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"
805
- />
806
- </div>
807
- </div>
808
-
809
- <div className="mt-4">
810
- <label className="block text-sm font-medium text-gray-700 mb-2">
811
- Description
812
- </label>
813
- <input
814
- type="text"
815
- value={endpoint.description}
816
- onChange={(e) => handleEndpointUpdate(endpoint.id, { description: e.target.value })}
817
- placeholder="Retrieves a list of users"
818
- className="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"
819
- />
820
- </div>
821
- </Card>
822
- ))}
823
- </div>
824
- )}
825
-
826
- {currentTab === 'schema' && (
827
- <div className="space-y-4">
828
- <h3 className="text-lg font-medium">Custom Entity Fields</h3>
829
- <p className="text-sm text-gray-600">
830
- Add custom fields to store additional data in your integration entity.
831
- Authentication fields are automatically included.
832
- </p>
833
-
834
- <SchemaBuilder
835
- schema={formData.entitySchema}
836
- onChange={(schema) => handleInputChange('entitySchema', schema)}
837
- />
838
- </div>
839
- )}
840
- </Card>
841
-
842
- <div className="flex justify-end">
843
- <Button
844
- onClick={generateIntegrationCode}
845
- disabled={!formData.name || (!formData.baseURL && !formData.useExistingModule) || (formData.useExistingModule && !formData.selectedModule)}
846
- className="bg-blue-600 hover:bg-blue-700"
847
- >
848
- Generate Integration Code
849
- </Button>
850
- </div>
851
- </div>
852
- );
853
- };
854
-
855
- export default IntegrationGenerator;