@friggframework/devtools 2.0.0--canary.522.cbd3d5a.0 → 2.0.0--canary.517.21b69ac.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.
- package/.eslintrc.json +3 -0
- package/CHANGELOG.md +132 -0
- package/frigg-cli/README.md +1 -1
- package/frigg-cli/__tests__/unit/commands/doctor.test.js +2 -0
- package/frigg-cli/__tests__/unit/commands/install.test.js +17 -21
- package/frigg-cli/doctor-command/index.js +16 -17
- package/frigg-cli/index.js +6 -21
- package/frigg-cli/index.test.js +1 -7
- package/frigg-cli/init-command/backend-first-handler.js +42 -124
- package/frigg-cli/init-command/index.js +1 -2
- package/frigg-cli/init-command/template-handler.js +3 -13
- package/frigg-cli/install-command/backend-js.js +3 -3
- package/frigg-cli/install-command/environment-variables.js +19 -16
- package/frigg-cli/install-command/environment-variables.test.js +13 -12
- package/frigg-cli/install-command/index.js +9 -14
- package/frigg-cli/install-command/integration-file.js +3 -3
- package/frigg-cli/install-command/logger.js +12 -0
- package/frigg-cli/install-command/validate-package.js +9 -5
- package/frigg-cli/jest.config.js +1 -4
- package/frigg-cli/repair-command/index.js +128 -101
- package/frigg-cli/start-command/index.js +2 -246
- package/frigg-cli/ui-command/index.js +36 -58
- package/frigg-cli/utils/repo-detection.js +37 -85
- package/infrastructure/docs/iam-policy-templates.md +1 -1
- package/infrastructure/domains/networking/vpc-builder.test.js +4 -2
- package/infrastructure/domains/networking/vpc-resolver.test.js +1 -1
- package/infrastructure/domains/shared/cloudformation-discovery.test.js +7 -4
- package/infrastructure/domains/shared/resource-discovery.js +5 -5
- package/infrastructure/domains/shared/types/discovery-result.test.js +1 -1
- package/infrastructure/domains/shared/utilities/base-definition-factory.js +2 -25
- package/infrastructure/domains/shared/utilities/base-definition-factory.test.js +2 -2
- package/infrastructure/infrastructure-composer.test.js +2 -2
- package/layers/prisma/.build-complete +3 -0
- package/layers/prisma/nodejs/package.json +8 -0
- package/management-ui/.eslintrc.js +22 -0
- package/management-ui/README.md +109 -245
- package/management-ui/components.json +21 -0
- package/management-ui/docs/phase2-integration-guide.md +320 -0
- package/management-ui/index.html +13 -0
- package/management-ui/package.json +76 -0
- package/management-ui/packages/devtools/frigg-cli/ui-command/index.js +302 -0
- package/management-ui/postcss.config.js +6 -0
- package/management-ui/server/api/backend.js +256 -0
- package/management-ui/server/api/cli.js +315 -0
- package/management-ui/server/api/codegen.js +663 -0
- package/management-ui/server/api/connections.js +857 -0
- package/management-ui/server/api/discovery.js +185 -0
- package/management-ui/server/api/environment/index.js +1 -0
- package/management-ui/server/api/environment/router.js +378 -0
- package/management-ui/server/api/environment.js +328 -0
- package/management-ui/server/api/integrations.js +876 -0
- package/management-ui/server/api/logs.js +248 -0
- package/management-ui/server/api/monitoring.js +282 -0
- package/management-ui/server/api/open-ide.js +31 -0
- package/management-ui/server/api/project.js +1029 -0
- package/management-ui/server/api/users/sessions.js +371 -0
- package/management-ui/server/api/users/simulation.js +254 -0
- package/management-ui/server/api/users.js +362 -0
- package/management-ui/server/api-contract.md +275 -0
- package/management-ui/server/index.js +873 -0
- package/management-ui/server/middleware/errorHandler.js +93 -0
- package/management-ui/server/middleware/security.js +32 -0
- package/management-ui/server/processManager.js +296 -0
- package/management-ui/server/server.js +346 -0
- package/management-ui/server/services/aws-monitor.js +413 -0
- package/management-ui/server/services/npm-registry.js +347 -0
- package/management-ui/server/services/template-engine.js +538 -0
- package/management-ui/server/utils/cliIntegration.js +220 -0
- package/management-ui/server/utils/environment/auditLogger.js +471 -0
- package/management-ui/server/utils/environment/awsParameterStore.js +275 -0
- package/management-ui/server/utils/environment/encryption.js +278 -0
- package/management-ui/server/utils/environment/envFileManager.js +286 -0
- package/management-ui/server/utils/import-commonjs.js +28 -0
- package/management-ui/server/utils/response.js +83 -0
- package/management-ui/server/websocket/handler.js +325 -0
- package/management-ui/src/App.jsx +25 -0
- package/management-ui/src/assets/FriggLogo.svg +1 -0
- package/management-ui/src/components/AppRouter.jsx +65 -0
- package/management-ui/src/components/Button.jsx +70 -0
- package/management-ui/src/components/Card.jsx +97 -0
- package/management-ui/src/components/EnvironmentCompare.jsx +400 -0
- package/management-ui/src/components/EnvironmentEditor.jsx +372 -0
- package/management-ui/src/components/EnvironmentImportExport.jsx +469 -0
- package/management-ui/src/components/EnvironmentSchema.jsx +491 -0
- package/management-ui/src/components/EnvironmentSecurity.jsx +463 -0
- package/management-ui/src/components/ErrorBoundary.jsx +73 -0
- package/management-ui/src/components/IntegrationCard.jsx +481 -0
- package/management-ui/src/components/IntegrationCardEnhanced.jsx +770 -0
- package/management-ui/src/components/IntegrationExplorer.jsx +379 -0
- package/management-ui/src/components/IntegrationStatus.jsx +336 -0
- package/management-ui/src/components/Layout.jsx +716 -0
- package/management-ui/src/components/LoadingSpinner.jsx +113 -0
- package/management-ui/src/components/RepositoryPicker.jsx +248 -0
- package/management-ui/src/components/SessionMonitor.jsx +350 -0
- package/management-ui/src/components/StatusBadge.jsx +208 -0
- package/management-ui/src/components/UserContextSwitcher.jsx +212 -0
- package/management-ui/src/components/UserSimulation.jsx +327 -0
- package/management-ui/src/components/Welcome.jsx +434 -0
- package/management-ui/src/components/codegen/APIEndpointGenerator.jsx +637 -0
- package/management-ui/src/components/codegen/APIModuleSelector.jsx +227 -0
- package/management-ui/src/components/codegen/CodeGenerationWizard.jsx +247 -0
- package/management-ui/src/components/codegen/CodePreviewEditor.jsx +316 -0
- package/management-ui/src/components/codegen/DynamicModuleForm.jsx +271 -0
- package/management-ui/src/components/codegen/FormBuilder.jsx +737 -0
- package/management-ui/src/components/codegen/IntegrationGenerator.jsx +855 -0
- package/management-ui/src/components/codegen/ProjectScaffoldWizard.jsx +797 -0
- package/management-ui/src/components/codegen/SchemaBuilder.jsx +303 -0
- package/management-ui/src/components/codegen/TemplateSelector.jsx +586 -0
- package/management-ui/src/components/codegen/index.js +10 -0
- package/management-ui/src/components/connections/ConnectionConfigForm.jsx +362 -0
- package/management-ui/src/components/connections/ConnectionHealthMonitor.jsx +182 -0
- package/management-ui/src/components/connections/ConnectionTester.jsx +200 -0
- package/management-ui/src/components/connections/EntityRelationshipMapper.jsx +292 -0
- package/management-ui/src/components/connections/OAuthFlow.jsx +204 -0
- package/management-ui/src/components/connections/index.js +5 -0
- package/management-ui/src/components/index.js +21 -0
- package/management-ui/src/components/monitoring/APIGatewayMetrics.jsx +222 -0
- package/management-ui/src/components/monitoring/LambdaMetrics.jsx +169 -0
- package/management-ui/src/components/monitoring/MetricsChart.jsx +197 -0
- package/management-ui/src/components/monitoring/MonitoringDashboard.jsx +393 -0
- package/management-ui/src/components/monitoring/SQSMetrics.jsx +246 -0
- package/management-ui/src/components/monitoring/index.js +6 -0
- package/management-ui/src/components/monitoring/monitoring.css +218 -0
- package/management-ui/src/components/theme-provider.jsx +52 -0
- package/management-ui/src/components/theme-toggle.jsx +39 -0
- package/management-ui/src/components/ui/badge.tsx +36 -0
- package/management-ui/src/components/ui/button.test.jsx +56 -0
- package/management-ui/src/components/ui/button.tsx +57 -0
- package/management-ui/src/components/ui/card.tsx +76 -0
- package/management-ui/src/components/ui/dropdown-menu.tsx +199 -0
- package/management-ui/src/components/ui/select.tsx +157 -0
- package/management-ui/src/components/ui/skeleton.jsx +15 -0
- package/management-ui/src/hooks/useFrigg.jsx +387 -0
- package/management-ui/src/hooks/useSocket.jsx +58 -0
- package/management-ui/src/index.css +193 -0
- package/management-ui/src/lib/utils.ts +6 -0
- package/management-ui/src/main.jsx +10 -0
- package/management-ui/src/pages/CodeGeneration.jsx +14 -0
- package/management-ui/src/pages/Connections.jsx +252 -0
- package/management-ui/src/pages/ConnectionsEnhanced.jsx +633 -0
- package/management-ui/src/pages/Dashboard.jsx +311 -0
- package/management-ui/src/pages/Environment.jsx +314 -0
- package/management-ui/src/pages/IntegrationConfigure.jsx +669 -0
- package/management-ui/src/pages/IntegrationDiscovery.jsx +567 -0
- package/management-ui/src/pages/IntegrationTest.jsx +742 -0
- package/management-ui/src/pages/Integrations.jsx +253 -0
- package/management-ui/src/pages/Monitoring.jsx +17 -0
- package/management-ui/src/pages/Simulation.jsx +155 -0
- package/management-ui/src/pages/Users.jsx +492 -0
- package/management-ui/src/services/api.js +41 -0
- package/management-ui/src/services/apiModuleService.js +193 -0
- package/management-ui/src/services/websocket-handlers.js +120 -0
- package/management-ui/src/test/api/project.test.js +273 -0
- package/management-ui/src/test/components/Welcome.test.jsx +378 -0
- package/management-ui/src/test/mocks/server.js +178 -0
- package/management-ui/src/test/setup.js +61 -0
- package/management-ui/src/test/utils/test-utils.jsx +134 -0
- package/management-ui/src/utils/repository.js +98 -0
- package/management-ui/src/utils/repository.test.js +118 -0
- package/management-ui/src/workflows/phase2-integration-workflows.js +884 -0
- package/management-ui/tailwind.config.js +63 -0
- package/management-ui/tsconfig.json +37 -0
- package/management-ui/tsconfig.node.json +10 -0
- package/management-ui/vite.config.js +26 -0
- package/management-ui/vitest.config.js +38 -0
- package/package.json +7 -17
- package/frigg-cli/__tests__/application/use-cases/AddApiModuleToIntegrationUseCase.test.js +0 -326
- package/frigg-cli/__tests__/application/use-cases/CreateApiModuleUseCase.test.js +0 -337
- package/frigg-cli/__tests__/domain/entities/ApiModule.test.js +0 -373
- package/frigg-cli/__tests__/domain/entities/AppDefinition.test.js +0 -313
- package/frigg-cli/__tests__/domain/services/IntegrationValidator.test.js +0 -269
- package/frigg-cli/__tests__/domain/value-objects/IntegrationName.test.js +0 -82
- package/frigg-cli/__tests__/infrastructure/adapters/IntegrationJsUpdater.test.js +0 -408
- package/frigg-cli/__tests__/infrastructure/repositories/FileSystemApiModuleRepository.test.js +0 -583
- package/frigg-cli/__tests__/infrastructure/repositories/FileSystemAppDefinitionRepository.test.js +0 -314
- package/frigg-cli/__tests__/infrastructure/repositories/FileSystemIntegrationRepository.test.js +0 -430
- package/frigg-cli/__tests__/unit/commands/init.test.js +0 -406
- package/frigg-cli/__tests__/unit/commands/repair.test.js +0 -275
- package/frigg-cli/__tests__/unit/start-command/application/RunPreflightChecksUseCase.test.js +0 -411
- package/frigg-cli/__tests__/unit/start-command/infrastructure/DatabaseAdapter.test.js +0 -405
- package/frigg-cli/__tests__/unit/start-command/infrastructure/DockerAdapter.test.js +0 -496
- package/frigg-cli/__tests__/unit/start-command/presentation/InteractivePromptAdapter.test.js +0 -474
- package/frigg-cli/__tests__/unit/utils/output.test.js +0 -196
- package/frigg-cli/application/use-cases/AddApiModuleToIntegrationUseCase.js +0 -93
- package/frigg-cli/application/use-cases/CreateApiModuleUseCase.js +0 -93
- package/frigg-cli/application/use-cases/CreateIntegrationUseCase.js +0 -103
- package/frigg-cli/container.js +0 -172
- package/frigg-cli/docs/OUTPUT_MIGRATION_GUIDE.md +0 -286
- package/frigg-cli/domain/entities/ApiModule.js +0 -272
- package/frigg-cli/domain/entities/AppDefinition.js +0 -227
- package/frigg-cli/domain/entities/Integration.js +0 -198
- package/frigg-cli/domain/exceptions/DomainException.js +0 -24
- package/frigg-cli/domain/ports/IApiModuleRepository.js +0 -53
- package/frigg-cli/domain/ports/IAppDefinitionRepository.js +0 -43
- package/frigg-cli/domain/ports/IIntegrationRepository.js +0 -61
- package/frigg-cli/domain/services/IntegrationValidator.js +0 -185
- package/frigg-cli/domain/value-objects/IntegrationId.js +0 -42
- package/frigg-cli/domain/value-objects/IntegrationName.js +0 -60
- package/frigg-cli/domain/value-objects/SemanticVersion.js +0 -70
- package/frigg-cli/infrastructure/UnitOfWork.js +0 -46
- package/frigg-cli/infrastructure/adapters/BackendJsUpdater.js +0 -197
- package/frigg-cli/infrastructure/adapters/FileSystemAdapter.js +0 -224
- package/frigg-cli/infrastructure/adapters/IntegrationJsUpdater.js +0 -249
- package/frigg-cli/infrastructure/adapters/SchemaValidator.js +0 -92
- package/frigg-cli/infrastructure/repositories/FileSystemApiModuleRepository.js +0 -373
- package/frigg-cli/infrastructure/repositories/FileSystemAppDefinitionRepository.js +0 -116
- package/frigg-cli/infrastructure/repositories/FileSystemIntegrationRepository.js +0 -277
- package/frigg-cli/package-lock.json +0 -16226
- package/frigg-cli/start-command/application/RunPreflightChecksUseCase.js +0 -376
- package/frigg-cli/start-command/infrastructure/DatabaseAdapter.js +0 -591
- package/frigg-cli/start-command/infrastructure/DockerAdapter.js +0 -306
- package/frigg-cli/start-command/presentation/InteractivePromptAdapter.js +0 -329
- package/frigg-cli/templates/backend/.env.example +0 -62
- package/frigg-cli/templates/backend/.eslintrc.json +0 -12
- package/frigg-cli/templates/backend/.prettierrc +0 -6
- package/frigg-cli/templates/backend/docker-compose.yml +0 -22
- package/frigg-cli/templates/backend/index.js +0 -96
- package/frigg-cli/templates/backend/infrastructure.js +0 -12
- package/frigg-cli/templates/backend/jest.config.js +0 -17
- package/frigg-cli/templates/backend/package.json +0 -50
- package/frigg-cli/templates/backend/src/api-modules/.gitkeep +0 -10
- package/frigg-cli/templates/backend/src/base/.gitkeep +0 -7
- package/frigg-cli/templates/backend/src/integrations/.gitkeep +0 -10
- package/frigg-cli/templates/backend/src/integrations/ExampleIntegration.js +0 -65
- package/frigg-cli/templates/backend/src/utils/.gitkeep +0 -7
- package/frigg-cli/templates/backend/test/setup.js +0 -30
- package/frigg-cli/templates/backend/ui-extensions/.gitkeep +0 -0
- package/frigg-cli/templates/backend/ui-extensions/README.md +0 -77
- package/frigg-cli/utils/__tests__/repo-detection.test.js +0 -436
- package/frigg-cli/utils/output.js +0 -382
- package/frigg-cli/validate-command/__tests__/adapters/validate-command.test.js +0 -205
- package/frigg-cli/validate-command/__tests__/application/validate-app-use-case.test.js +0 -104
- package/frigg-cli/validate-command/__tests__/domain/fix-suggestion.test.js +0 -153
- package/frigg-cli/validate-command/__tests__/domain/validation-error.test.js +0 -162
- package/frigg-cli/validate-command/__tests__/domain/validation-result.test.js +0 -152
- package/frigg-cli/validate-command/__tests__/infrastructure/api-module-validator.test.js +0 -332
- package/frigg-cli/validate-command/__tests__/infrastructure/app-definition-validator.test.js +0 -191
- package/frigg-cli/validate-command/__tests__/infrastructure/integration-class-validator.test.js +0 -146
- package/frigg-cli/validate-command/__tests__/infrastructure/template-validation.test.js +0 -155
- package/frigg-cli/validate-command/adapters/cli/validate-command.js +0 -199
- package/frigg-cli/validate-command/application/use-cases/validate-app-use-case.js +0 -35
- package/frigg-cli/validate-command/domain/entities/validation-result.js +0 -74
- package/frigg-cli/validate-command/domain/value-objects/fix-suggestion.js +0 -74
- package/frigg-cli/validate-command/domain/value-objects/validation-error.js +0 -68
- package/frigg-cli/validate-command/infrastructure/validators/api-module-validator.js +0 -181
- package/frigg-cli/validate-command/infrastructure/validators/app-definition-validator.js +0 -128
- package/frigg-cli/validate-command/infrastructure/validators/integration-class-validator.js +0 -113
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
const { validateApiModuleDefinition } = require('@friggframework/schemas');
|
|
2
|
-
const { ValidationResult } = require('../../domain/entities/validation-result');
|
|
3
|
-
const { ValidationError } = require('../../domain/value-objects/validation-error');
|
|
4
|
-
|
|
5
|
-
const REQUIRED_MODULE_METHODS = ['getToken', 'getEntityDetails', 'getCredentialDetails'];
|
|
6
|
-
|
|
7
|
-
class ApiModuleValidator {
|
|
8
|
-
/**
|
|
9
|
-
* Validate API module definitions within an integration
|
|
10
|
-
* @param {object} integrationDefinition - The integration's Definition object
|
|
11
|
-
* @param {number} integrationIndex - Index of the integration in the app
|
|
12
|
-
* @returns {ValidationResult}
|
|
13
|
-
*/
|
|
14
|
-
validate(integrationDefinition, integrationIndex) {
|
|
15
|
-
const result = ValidationResult.create();
|
|
16
|
-
const prefix = `integrations[${integrationIndex}].Definition.modules`;
|
|
17
|
-
|
|
18
|
-
if (!integrationDefinition.modules || typeof integrationDefinition.modules !== 'object') {
|
|
19
|
-
return result;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
Object.entries(integrationDefinition.modules).forEach(([moduleName, moduleConfig]) => {
|
|
23
|
-
const modulePath = `${prefix}.${moduleName}`;
|
|
24
|
-
|
|
25
|
-
if (!moduleConfig.definition) {
|
|
26
|
-
result.addError(ValidationError.create({
|
|
27
|
-
path: `${modulePath}.definition`,
|
|
28
|
-
message: `Module '${moduleName}' must have a definition property`,
|
|
29
|
-
severity: 'error',
|
|
30
|
-
code: 'MISSING_DEFINITION'
|
|
31
|
-
}));
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
this._validateModuleDefinitionWithSchema(moduleConfig.definition, modulePath, moduleName, result);
|
|
36
|
-
this._validateRequiredMethods(moduleConfig.definition, modulePath, moduleName, result);
|
|
37
|
-
this._validateApiPropertiesToPersist(moduleConfig.definition, modulePath, moduleName, result);
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
return result;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
_validateModuleDefinitionWithSchema(definition, modulePath, moduleName, result) {
|
|
44
|
-
// Sanitize the definition before JSON Schema validation
|
|
45
|
-
// API module definitions contain functions and classes that JSON Schema can't validate
|
|
46
|
-
const sanitizedDefinition = this._sanitizeForSchemaValidation(definition);
|
|
47
|
-
const schemaResult = validateApiModuleDefinition(sanitizedDefinition);
|
|
48
|
-
|
|
49
|
-
if (!schemaResult.valid && schemaResult.errors) {
|
|
50
|
-
schemaResult.errors.forEach(error => {
|
|
51
|
-
const path = error.instancePath
|
|
52
|
-
? `${modulePath}.definition${error.instancePath.replace(/\//g, '.')}`
|
|
53
|
-
: `${modulePath}.definition`;
|
|
54
|
-
|
|
55
|
-
result.addError(ValidationError.create({
|
|
56
|
-
path,
|
|
57
|
-
message: this._formatSchemaErrorMessage(error),
|
|
58
|
-
severity: 'error',
|
|
59
|
-
code: error.keyword?.toUpperCase() || 'SCHEMA_ERROR'
|
|
60
|
-
}));
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Create a copy of the module definition safe for JSON Schema validation.
|
|
67
|
-
* Converts functions to descriptors but preserves all properties so that
|
|
68
|
-
* unknown properties can be properly rejected by the schema.
|
|
69
|
-
*/
|
|
70
|
-
_sanitizeForSchemaValidation(definition) {
|
|
71
|
-
if (!definition) return definition;
|
|
72
|
-
|
|
73
|
-
const sanitized = {};
|
|
74
|
-
|
|
75
|
-
// Copy ALL properties, converting functions/classes to descriptors
|
|
76
|
-
// This allows JSON Schema to properly reject unknown properties
|
|
77
|
-
for (const key of Object.keys(definition)) {
|
|
78
|
-
sanitized[key] = this._sanitizeValue(definition[key]);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
return sanitized;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Recursively sanitize a value for JSON Schema validation.
|
|
86
|
-
* Functions become {type: "function"} descriptors.
|
|
87
|
-
* Classes become {type: "object"} descriptors.
|
|
88
|
-
*/
|
|
89
|
-
_sanitizeValue(value) {
|
|
90
|
-
if (value === null || value === undefined) {
|
|
91
|
-
return value;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
// Convert functions to descriptors
|
|
95
|
-
if (typeof value === 'function') {
|
|
96
|
-
return { type: 'function', name: value.name || 'anonymous' };
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
// Handle arrays
|
|
100
|
-
if (Array.isArray(value)) {
|
|
101
|
-
return value.map(item => this._sanitizeValue(item));
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// Handle objects (but not class instances with constructors other than Object)
|
|
105
|
-
if (typeof value === 'object') {
|
|
106
|
-
// Check if it's a class instance (not a plain object)
|
|
107
|
-
if (value.constructor && value.constructor.name !== 'Object') {
|
|
108
|
-
return { type: 'object', className: value.constructor.name };
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
// Recursively sanitize plain objects
|
|
112
|
-
const sanitizedObj = {};
|
|
113
|
-
for (const [key, val] of Object.entries(value)) {
|
|
114
|
-
sanitizedObj[key] = this._sanitizeValue(val);
|
|
115
|
-
}
|
|
116
|
-
return sanitizedObj;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
// Primitives pass through unchanged
|
|
120
|
-
return value;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
_formatSchemaErrorMessage(error) {
|
|
124
|
-
let message = error.message;
|
|
125
|
-
if (error.params?.allowedValues) {
|
|
126
|
-
message += ` (allowed: ${error.params.allowedValues.join(', ')})`;
|
|
127
|
-
}
|
|
128
|
-
if (error.params?.additionalProperty) {
|
|
129
|
-
message += `: ${error.params.additionalProperty}`;
|
|
130
|
-
}
|
|
131
|
-
if (error.params?.missingProperty) {
|
|
132
|
-
message = `must have required property '${error.params.missingProperty}'`;
|
|
133
|
-
}
|
|
134
|
-
return message;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
_validateRequiredMethods(definition, modulePath, moduleName, result) {
|
|
138
|
-
if (!definition.requiredAuthMethods) {
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
REQUIRED_MODULE_METHODS.forEach(method => {
|
|
143
|
-
if (!definition.requiredAuthMethods[method]) {
|
|
144
|
-
result.addError(ValidationError.create({
|
|
145
|
-
path: `${modulePath}.definition.requiredAuthMethods.${method}`,
|
|
146
|
-
message: `Module '${moduleName}' should implement ${method} method`,
|
|
147
|
-
severity: 'warning',
|
|
148
|
-
code: 'MISSING_METHOD'
|
|
149
|
-
}));
|
|
150
|
-
}
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
_validateApiPropertiesToPersist(definition, modulePath, moduleName, result) {
|
|
155
|
-
const props = definition.requiredAuthMethods?.apiPropertiesToPersist;
|
|
156
|
-
|
|
157
|
-
if (!props) {
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
if (!props.credential || !Array.isArray(props.credential) || props.credential.length === 0) {
|
|
162
|
-
result.addError(ValidationError.create({
|
|
163
|
-
path: `${modulePath}.definition.requiredAuthMethods.apiPropertiesToPersist.credential`,
|
|
164
|
-
message: `Module '${moduleName}' should specify credential properties to persist`,
|
|
165
|
-
severity: 'warning',
|
|
166
|
-
code: 'MISSING_CREDENTIAL_PROPS'
|
|
167
|
-
}));
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
if (!props.entity || !Array.isArray(props.entity) || props.entity.length === 0) {
|
|
171
|
-
result.addError(ValidationError.create({
|
|
172
|
-
path: `${modulePath}.definition.requiredAuthMethods.apiPropertiesToPersist.entity`,
|
|
173
|
-
message: `Module '${moduleName}' should specify entity properties to persist`,
|
|
174
|
-
severity: 'warning',
|
|
175
|
-
code: 'MISSING_ENTITY_PROPS'
|
|
176
|
-
}));
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
module.exports = { ApiModuleValidator };
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
const { validateAppDefinition } = require('@friggframework/schemas');
|
|
2
|
-
const { ValidationResult } = require('../../domain/entities/validation-result');
|
|
3
|
-
const { ValidationError } = require('../../domain/value-objects/validation-error');
|
|
4
|
-
|
|
5
|
-
class AppDefinitionValidator {
|
|
6
|
-
validate(definition) {
|
|
7
|
-
const result = ValidationResult.create();
|
|
8
|
-
|
|
9
|
-
// Create a sanitized copy for JSON Schema validation
|
|
10
|
-
// Integrations contain classes/functions which JSON Schema can't validate
|
|
11
|
-
// IntegrationClassValidator handles those separately
|
|
12
|
-
const sanitizedDefinition = this._sanitizeForSchemaValidation(definition);
|
|
13
|
-
const schemaResult = validateAppDefinition(sanitizedDefinition);
|
|
14
|
-
|
|
15
|
-
if (!schemaResult.valid && schemaResult.errors) {
|
|
16
|
-
schemaResult.errors.forEach(error => {
|
|
17
|
-
result.addError(ValidationError.create({
|
|
18
|
-
path: this._convertPath(error.instancePath) || 'root',
|
|
19
|
-
message: this._formatErrorMessage(error),
|
|
20
|
-
severity: 'error',
|
|
21
|
-
code: error.keyword?.toUpperCase() || 'SCHEMA_ERROR'
|
|
22
|
-
}));
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
this._validateIntegrationDuplicates(definition, result);
|
|
27
|
-
this._validateIntegrationDefinitions(definition, result);
|
|
28
|
-
|
|
29
|
-
return result;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Create a copy of the definition safe for JSON Schema validation.
|
|
34
|
-
* Replaces integration classes with stub objects since JSON Schema
|
|
35
|
-
* cannot validate JavaScript classes/functions.
|
|
36
|
-
*/
|
|
37
|
-
_sanitizeForSchemaValidation(definition) {
|
|
38
|
-
if (!definition) return definition;
|
|
39
|
-
|
|
40
|
-
const sanitized = { ...definition };
|
|
41
|
-
|
|
42
|
-
// Replace integration classes with stub objects
|
|
43
|
-
// The actual class validation is handled by IntegrationClassValidator
|
|
44
|
-
if (Array.isArray(definition.integrations)) {
|
|
45
|
-
sanitized.integrations = definition.integrations.map(integration => {
|
|
46
|
-
if (typeof integration === 'function') {
|
|
47
|
-
// Return a stub object representing the class
|
|
48
|
-
return { _isClass: true, name: integration.name };
|
|
49
|
-
}
|
|
50
|
-
return integration;
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return sanitized;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
_convertPath(jsonPointerPath) {
|
|
58
|
-
if (!jsonPointerPath) return '';
|
|
59
|
-
return jsonPointerPath
|
|
60
|
-
.replace(/^\//, '')
|
|
61
|
-
.replace(/\/(\d+)/g, '[$1]')
|
|
62
|
-
.replace(/\//g, '.');
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
_formatErrorMessage(error) {
|
|
66
|
-
let message = error.message;
|
|
67
|
-
if (error.params?.allowedValues) {
|
|
68
|
-
message += ` (allowed: ${error.params.allowedValues.join(', ')})`;
|
|
69
|
-
}
|
|
70
|
-
if (error.params?.additionalProperty) {
|
|
71
|
-
message += `: ${error.params.additionalProperty}`;
|
|
72
|
-
}
|
|
73
|
-
if (error.params?.missingProperty) {
|
|
74
|
-
message = `must have required property '${error.params.missingProperty}'`;
|
|
75
|
-
}
|
|
76
|
-
return message;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
_validateIntegrationDefinitions(definition, result) {
|
|
80
|
-
if (!definition.integrations || !Array.isArray(definition.integrations)) {
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
definition.integrations.forEach((integration, index) => {
|
|
85
|
-
if (typeof integration === 'function') {
|
|
86
|
-
if (!integration.Definition) {
|
|
87
|
-
result.addError(ValidationError.create({
|
|
88
|
-
path: `integrations[${index}]`,
|
|
89
|
-
message: 'Integration class must have a static Definition property',
|
|
90
|
-
severity: 'error',
|
|
91
|
-
code: 'MISSING_DEFINITION'
|
|
92
|
-
}));
|
|
93
|
-
} else if (!integration.Definition.name) {
|
|
94
|
-
result.addError(ValidationError.create({
|
|
95
|
-
path: `integrations[${index}].Definition.name`,
|
|
96
|
-
message: 'Integration Definition must have a name property',
|
|
97
|
-
severity: 'error',
|
|
98
|
-
code: 'REQUIRED_FIELD'
|
|
99
|
-
}));
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
_validateIntegrationDuplicates(definition, result) {
|
|
106
|
-
if (!definition.integrations || !Array.isArray(definition.integrations)) {
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
const names = [];
|
|
111
|
-
definition.integrations.forEach((integration, index) => {
|
|
112
|
-
const name = integration.Definition?.name;
|
|
113
|
-
if (name) {
|
|
114
|
-
if (names.includes(name)) {
|
|
115
|
-
result.addError(ValidationError.create({
|
|
116
|
-
path: `integrations[${index}].Definition.name`,
|
|
117
|
-
message: `duplicate integration name: ${name}`,
|
|
118
|
-
severity: 'warning',
|
|
119
|
-
code: 'DUPLICATE_NAME'
|
|
120
|
-
}));
|
|
121
|
-
}
|
|
122
|
-
names.push(name);
|
|
123
|
-
}
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
module.exports = { AppDefinitionValidator };
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
const { validateIntegrationDefinition } = require('@friggframework/schemas');
|
|
2
|
-
const { ValidationResult } = require('../../domain/entities/validation-result');
|
|
3
|
-
const { ValidationError } = require('../../domain/value-objects/validation-error');
|
|
4
|
-
const { FixSuggestion } = require('../../domain/value-objects/fix-suggestion');
|
|
5
|
-
|
|
6
|
-
const LIFECYCLE_METHODS = ['onCreate', 'getConfigOptions', 'testAuth'];
|
|
7
|
-
|
|
8
|
-
class IntegrationClassValidator {
|
|
9
|
-
validate(integrationClass, index) {
|
|
10
|
-
const result = ValidationResult.create();
|
|
11
|
-
const prefix = `integrations[${index}]`;
|
|
12
|
-
|
|
13
|
-
if (typeof integrationClass !== 'function') {
|
|
14
|
-
result.addError(ValidationError.create({
|
|
15
|
-
path: prefix,
|
|
16
|
-
message: 'Integration must be a class (function)',
|
|
17
|
-
severity: 'error',
|
|
18
|
-
code: 'INVALID_TYPE'
|
|
19
|
-
}));
|
|
20
|
-
return result;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
if (!integrationClass.Definition) {
|
|
24
|
-
result.addError(ValidationError.create({
|
|
25
|
-
path: `${prefix}.Definition`,
|
|
26
|
-
message: 'Integration class must have a static Definition property',
|
|
27
|
-
severity: 'error',
|
|
28
|
-
code: 'MISSING_DEFINITION',
|
|
29
|
-
fix: FixSuggestion.create({
|
|
30
|
-
action: 'add',
|
|
31
|
-
description: 'Add static Definition property to integration class',
|
|
32
|
-
codeSnippet: `static Definition = {\n name: 'my-integration',\n version: '1.0.0',\n modules: {}\n};`
|
|
33
|
-
})
|
|
34
|
-
}));
|
|
35
|
-
return result;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
this._validateDefinitionWithSchema(integrationClass.Definition, prefix, result);
|
|
39
|
-
this._validateModuleNames(integrationClass.Definition, prefix, result);
|
|
40
|
-
this._validateLifecycleMethods(integrationClass, prefix, result);
|
|
41
|
-
|
|
42
|
-
return result;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
_validateDefinitionWithSchema(definition, prefix, result) {
|
|
46
|
-
const schemaResult = validateIntegrationDefinition(definition);
|
|
47
|
-
|
|
48
|
-
if (!schemaResult.valid && schemaResult.errors) {
|
|
49
|
-
schemaResult.errors.forEach(error => {
|
|
50
|
-
const path = error.instancePath
|
|
51
|
-
? `${prefix}.Definition${error.instancePath.replace(/\//g, '.')}`
|
|
52
|
-
: `${prefix}.Definition`;
|
|
53
|
-
|
|
54
|
-
result.addError(ValidationError.create({
|
|
55
|
-
path,
|
|
56
|
-
message: this._formatSchemaErrorMessage(error),
|
|
57
|
-
severity: 'error',
|
|
58
|
-
code: error.keyword?.toUpperCase() || 'SCHEMA_ERROR'
|
|
59
|
-
}));
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
_formatSchemaErrorMessage(error) {
|
|
65
|
-
let message = error.message;
|
|
66
|
-
if (error.params?.allowedValues) {
|
|
67
|
-
message += ` (allowed: ${error.params.allowedValues.join(', ')})`;
|
|
68
|
-
}
|
|
69
|
-
if (error.params?.additionalProperty) {
|
|
70
|
-
message += `: ${error.params.additionalProperty}`;
|
|
71
|
-
}
|
|
72
|
-
if (error.params?.missingProperty) {
|
|
73
|
-
message = `must have required property '${error.params.missingProperty}'`;
|
|
74
|
-
}
|
|
75
|
-
return message;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
_validateModuleNames(definition, prefix, result) {
|
|
79
|
-
if (!definition.modules) {
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
Object.entries(definition.modules).forEach(([moduleName, moduleConfig]) => {
|
|
84
|
-
// Check for moduleName (the correct property per API module schema and core Module class)
|
|
85
|
-
// Note: getName() method returns definition.moduleName, not definition.name
|
|
86
|
-
if (moduleConfig.definition && !moduleConfig.definition.moduleName) {
|
|
87
|
-
result.addError(ValidationError.create({
|
|
88
|
-
path: `${prefix}.Definition.modules.${moduleName}.definition.moduleName`,
|
|
89
|
-
message: `Module ${moduleName} definition should have a moduleName property`,
|
|
90
|
-
severity: 'warning',
|
|
91
|
-
code: 'MISSING_MODULE_NAME'
|
|
92
|
-
}));
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
_validateLifecycleMethods(integrationClass, prefix, result) {
|
|
98
|
-
const proto = integrationClass.prototype;
|
|
99
|
-
|
|
100
|
-
LIFECYCLE_METHODS.forEach(method => {
|
|
101
|
-
if (typeof proto[method] !== 'function') {
|
|
102
|
-
result.addError(ValidationError.create({
|
|
103
|
-
path: `${prefix}.${method}`,
|
|
104
|
-
message: `Integration should implement ${method}() method`,
|
|
105
|
-
severity: 'warning',
|
|
106
|
-
code: 'MISSING_METHOD'
|
|
107
|
-
}));
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
module.exports = { IntegrationClassValidator };
|