@friggframework/devtools 2.0.0-next.6 → 2.0.0-next.61
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/frigg-cli/README.md +1289 -0
- package/frigg-cli/__tests__/unit/commands/build.test.js +279 -0
- package/frigg-cli/__tests__/unit/commands/db-setup.test.js +649 -0
- package/frigg-cli/__tests__/unit/commands/deploy.test.js +320 -0
- package/frigg-cli/__tests__/unit/commands/doctor.test.js +309 -0
- package/frigg-cli/__tests__/unit/commands/install.test.js +400 -0
- package/frigg-cli/__tests__/unit/commands/ui.test.js +346 -0
- package/frigg-cli/__tests__/unit/dependencies.test.js +74 -0
- package/frigg-cli/__tests__/unit/utils/database-validator.test.js +397 -0
- package/frigg-cli/__tests__/unit/utils/error-messages.test.js +345 -0
- package/frigg-cli/__tests__/unit/version-detection.test.js +171 -0
- package/frigg-cli/__tests__/utils/mock-factory.js +270 -0
- package/frigg-cli/__tests__/utils/prisma-mock.js +194 -0
- package/frigg-cli/__tests__/utils/test-fixtures.js +463 -0
- package/frigg-cli/__tests__/utils/test-setup.js +287 -0
- package/frigg-cli/build-command/index.js +53 -14
- package/frigg-cli/db-setup-command/index.js +246 -0
- package/frigg-cli/deploy-command/SPEC-DEPLOY-DRY-RUN.md +981 -0
- package/frigg-cli/deploy-command/index.js +295 -17
- package/frigg-cli/doctor-command/index.js +335 -0
- package/frigg-cli/generate-command/__tests__/generate-command.test.js +301 -0
- package/frigg-cli/generate-command/azure-generator.js +43 -0
- package/frigg-cli/generate-command/gcp-generator.js +47 -0
- package/frigg-cli/generate-command/index.js +332 -0
- package/frigg-cli/generate-command/terraform-generator.js +555 -0
- package/frigg-cli/generate-iam-command.js +118 -0
- package/frigg-cli/index.js +142 -1
- package/frigg-cli/index.test.js +1 -4
- package/frigg-cli/init-command/backend-first-handler.js +756 -0
- package/frigg-cli/init-command/index.js +93 -0
- package/frigg-cli/init-command/template-handler.js +143 -0
- package/frigg-cli/install-command/index.js +1 -4
- package/frigg-cli/jest.config.js +124 -0
- package/frigg-cli/package.json +63 -0
- package/frigg-cli/repair-command/index.js +564 -0
- package/frigg-cli/start-command/index.js +125 -6
- package/frigg-cli/start-command/start-command.test.js +297 -0
- package/frigg-cli/test/init-command.test.js +180 -0
- package/frigg-cli/test/npm-registry.test.js +319 -0
- package/frigg-cli/ui-command/index.js +154 -0
- package/frigg-cli/utils/app-resolver.js +319 -0
- package/frigg-cli/utils/backend-path.js +16 -17
- package/frigg-cli/utils/database-validator.js +167 -0
- package/frigg-cli/utils/error-messages.js +329 -0
- package/frigg-cli/utils/npm-registry.js +167 -0
- package/frigg-cli/utils/process-manager.js +199 -0
- package/frigg-cli/utils/repo-detection.js +405 -0
- package/infrastructure/ARCHITECTURE.md +487 -0
- package/infrastructure/CLAUDE.md +481 -0
- package/infrastructure/HEALTH.md +468 -0
- package/infrastructure/README.md +522 -0
- package/infrastructure/__tests__/fixtures/mock-aws-resources.js +391 -0
- package/infrastructure/__tests__/helpers/test-utils.js +277 -0
- package/infrastructure/__tests__/postgres-config.test.js +914 -0
- package/infrastructure/__tests__/template-generation.test.js +687 -0
- package/infrastructure/create-frigg-infrastructure.js +129 -20
- package/infrastructure/docs/POSTGRES-CONFIGURATION.md +630 -0
- package/infrastructure/docs/PRE-DEPLOYMENT-HEALTH-CHECK-SPEC.md +1317 -0
- package/infrastructure/docs/WEBSOCKET-CONFIGURATION.md +105 -0
- package/infrastructure/docs/deployment-instructions.md +268 -0
- package/infrastructure/docs/generate-iam-command.md +278 -0
- package/infrastructure/docs/iam-policy-templates.md +193 -0
- package/infrastructure/domains/database/aurora-builder.js +809 -0
- package/infrastructure/domains/database/aurora-builder.test.js +950 -0
- package/infrastructure/domains/database/aurora-discovery.js +87 -0
- package/infrastructure/domains/database/aurora-discovery.test.js +188 -0
- package/infrastructure/domains/database/aurora-resolver.js +210 -0
- package/infrastructure/domains/database/aurora-resolver.test.js +347 -0
- package/infrastructure/domains/database/migration-builder.js +701 -0
- package/infrastructure/domains/database/migration-builder.test.js +321 -0
- package/infrastructure/domains/database/migration-resolver.js +163 -0
- package/infrastructure/domains/database/migration-resolver.test.js +337 -0
- package/infrastructure/domains/health/application/ports/IPropertyReconciler.js +164 -0
- package/infrastructure/domains/health/application/ports/IResourceDetector.js +129 -0
- package/infrastructure/domains/health/application/ports/IResourceImporter.js +142 -0
- package/infrastructure/domains/health/application/ports/IStackRepository.js +131 -0
- package/infrastructure/domains/health/application/ports/index.js +26 -0
- package/infrastructure/domains/health/application/use-cases/__tests__/execute-resource-import-use-case.test.js +679 -0
- package/infrastructure/domains/health/application/use-cases/__tests__/mismatch-analyzer-method-name.test.js +167 -0
- package/infrastructure/domains/health/application/use-cases/__tests__/repair-via-import-use-case.test.js +1130 -0
- package/infrastructure/domains/health/application/use-cases/execute-resource-import-use-case.js +221 -0
- package/infrastructure/domains/health/application/use-cases/reconcile-properties-use-case.js +152 -0
- package/infrastructure/domains/health/application/use-cases/reconcile-properties-use-case.test.js +343 -0
- package/infrastructure/domains/health/application/use-cases/repair-via-import-use-case.js +535 -0
- package/infrastructure/domains/health/application/use-cases/repair-via-import-use-case.test.js +376 -0
- package/infrastructure/domains/health/application/use-cases/run-health-check-use-case.js +213 -0
- package/infrastructure/domains/health/application/use-cases/run-health-check-use-case.test.js +441 -0
- package/infrastructure/domains/health/docs/ACME-DEV-DRIFT-ANALYSIS.md +267 -0
- package/infrastructure/domains/health/docs/BUILD-VS-DEPLOYED-TEMPLATE-ANALYSIS.md +324 -0
- package/infrastructure/domains/health/docs/ORPHAN-DETECTION-ANALYSIS.md +386 -0
- package/infrastructure/domains/health/docs/SPEC-CLEANUP-COMMAND.md +1419 -0
- package/infrastructure/domains/health/docs/TDD-IMPLEMENTATION-SUMMARY.md +391 -0
- package/infrastructure/domains/health/docs/TEMPLATE-COMPARISON-IMPLEMENTATION.md +551 -0
- package/infrastructure/domains/health/domain/entities/issue.js +299 -0
- package/infrastructure/domains/health/domain/entities/issue.test.js +528 -0
- package/infrastructure/domains/health/domain/entities/property-mismatch.js +108 -0
- package/infrastructure/domains/health/domain/entities/property-mismatch.test.js +275 -0
- package/infrastructure/domains/health/domain/entities/resource.js +159 -0
- package/infrastructure/domains/health/domain/entities/resource.test.js +432 -0
- package/infrastructure/domains/health/domain/entities/stack-health-report.js +306 -0
- package/infrastructure/domains/health/domain/entities/stack-health-report.test.js +601 -0
- package/infrastructure/domains/health/domain/services/__tests__/health-score-percentage-based.test.js +380 -0
- package/infrastructure/domains/health/domain/services/__tests__/import-progress-monitor.test.js +971 -0
- package/infrastructure/domains/health/domain/services/__tests__/import-template-generator.test.js +1150 -0
- package/infrastructure/domains/health/domain/services/__tests__/logical-id-mapper.test.js +672 -0
- package/infrastructure/domains/health/domain/services/__tests__/template-parser.test.js +496 -0
- package/infrastructure/domains/health/domain/services/__tests__/update-progress-monitor.test.js +419 -0
- package/infrastructure/domains/health/domain/services/health-score-calculator.js +248 -0
- package/infrastructure/domains/health/domain/services/health-score-calculator.test.js +504 -0
- package/infrastructure/domains/health/domain/services/import-progress-monitor.js +195 -0
- package/infrastructure/domains/health/domain/services/import-template-generator.js +435 -0
- package/infrastructure/domains/health/domain/services/logical-id-mapper.js +345 -0
- package/infrastructure/domains/health/domain/services/mismatch-analyzer.js +234 -0
- package/infrastructure/domains/health/domain/services/mismatch-analyzer.test.js +431 -0
- package/infrastructure/domains/health/domain/services/property-mutability-config.js +382 -0
- package/infrastructure/domains/health/domain/services/template-parser.js +245 -0
- package/infrastructure/domains/health/domain/services/update-progress-monitor.js +192 -0
- package/infrastructure/domains/health/domain/value-objects/health-score.js +138 -0
- package/infrastructure/domains/health/domain/value-objects/health-score.test.js +267 -0
- package/infrastructure/domains/health/domain/value-objects/property-mutability.js +161 -0
- package/infrastructure/domains/health/domain/value-objects/property-mutability.test.js +198 -0
- package/infrastructure/domains/health/domain/value-objects/resource-state.js +167 -0
- package/infrastructure/domains/health/domain/value-objects/resource-state.test.js +196 -0
- package/infrastructure/domains/health/domain/value-objects/stack-identifier.js +192 -0
- package/infrastructure/domains/health/domain/value-objects/stack-identifier.test.js +262 -0
- package/infrastructure/domains/health/infrastructure/adapters/__tests__/orphan-detection-cfn-tagged.test.js +312 -0
- package/infrastructure/domains/health/infrastructure/adapters/__tests__/orphan-detection-multi-stack.test.js +367 -0
- package/infrastructure/domains/health/infrastructure/adapters/__tests__/orphan-detection-relationship-analysis.test.js +432 -0
- package/infrastructure/domains/health/infrastructure/adapters/aws-property-reconciler.js +784 -0
- package/infrastructure/domains/health/infrastructure/adapters/aws-property-reconciler.test.js +1133 -0
- package/infrastructure/domains/health/infrastructure/adapters/aws-resource-detector.js +565 -0
- package/infrastructure/domains/health/infrastructure/adapters/aws-resource-detector.test.js +554 -0
- package/infrastructure/domains/health/infrastructure/adapters/aws-resource-importer.js +318 -0
- package/infrastructure/domains/health/infrastructure/adapters/aws-resource-importer.test.js +398 -0
- package/infrastructure/domains/health/infrastructure/adapters/aws-stack-repository.js +777 -0
- package/infrastructure/domains/health/infrastructure/adapters/aws-stack-repository.test.js +580 -0
- package/infrastructure/domains/integration/integration-builder.js +404 -0
- package/infrastructure/domains/integration/integration-builder.test.js +690 -0
- package/infrastructure/domains/integration/integration-resolver.js +170 -0
- package/infrastructure/domains/integration/integration-resolver.test.js +369 -0
- package/infrastructure/domains/integration/websocket-builder.js +69 -0
- package/infrastructure/domains/integration/websocket-builder.test.js +195 -0
- package/infrastructure/domains/networking/vpc-builder.js +2051 -0
- package/infrastructure/domains/networking/vpc-builder.test.js +1960 -0
- package/infrastructure/domains/networking/vpc-discovery.js +177 -0
- package/infrastructure/domains/networking/vpc-discovery.test.js +350 -0
- package/infrastructure/domains/networking/vpc-resolver.js +505 -0
- package/infrastructure/domains/networking/vpc-resolver.test.js +801 -0
- package/infrastructure/domains/parameters/ssm-builder.js +79 -0
- package/infrastructure/domains/parameters/ssm-builder.test.js +189 -0
- package/infrastructure/domains/parameters/ssm-discovery.js +84 -0
- package/infrastructure/domains/parameters/ssm-discovery.test.js +210 -0
- package/infrastructure/domains/security/iam-generator.js +816 -0
- package/infrastructure/domains/security/iam-generator.test.js +204 -0
- package/infrastructure/domains/security/kms-builder.js +415 -0
- package/infrastructure/domains/security/kms-builder.test.js +392 -0
- package/infrastructure/domains/security/kms-discovery.js +80 -0
- package/infrastructure/domains/security/kms-discovery.test.js +177 -0
- package/infrastructure/domains/security/kms-resolver.js +96 -0
- package/infrastructure/domains/security/kms-resolver.test.js +216 -0
- package/infrastructure/domains/security/templates/frigg-deployment-iam-stack.yaml +401 -0
- package/infrastructure/domains/security/templates/iam-policy-basic.json +218 -0
- package/infrastructure/domains/security/templates/iam-policy-full.json +288 -0
- package/infrastructure/domains/shared/base-builder.js +112 -0
- package/infrastructure/domains/shared/base-resolver.js +186 -0
- package/infrastructure/domains/shared/base-resolver.test.js +305 -0
- package/infrastructure/domains/shared/builder-orchestrator.js +212 -0
- package/infrastructure/domains/shared/builder-orchestrator.test.js +213 -0
- package/infrastructure/domains/shared/cloudformation-discovery-v2.js +334 -0
- package/infrastructure/domains/shared/cloudformation-discovery.js +672 -0
- package/infrastructure/domains/shared/cloudformation-discovery.test.js +985 -0
- package/infrastructure/domains/shared/environment-builder.js +119 -0
- package/infrastructure/domains/shared/environment-builder.test.js +247 -0
- package/infrastructure/domains/shared/providers/aws-provider-adapter.js +579 -0
- package/infrastructure/domains/shared/providers/aws-provider-adapter.test.js +416 -0
- package/infrastructure/domains/shared/providers/azure-provider-adapter.stub.js +93 -0
- package/infrastructure/domains/shared/providers/cloud-provider-adapter.js +136 -0
- package/infrastructure/domains/shared/providers/gcp-provider-adapter.stub.js +82 -0
- package/infrastructure/domains/shared/providers/provider-factory.js +108 -0
- package/infrastructure/domains/shared/providers/provider-factory.test.js +170 -0
- package/infrastructure/domains/shared/resource-discovery.enhanced.test.js +306 -0
- package/infrastructure/domains/shared/resource-discovery.js +233 -0
- package/infrastructure/domains/shared/resource-discovery.test.js +588 -0
- package/infrastructure/domains/shared/types/app-definition.js +205 -0
- package/infrastructure/domains/shared/types/discovery-result.js +106 -0
- package/infrastructure/domains/shared/types/discovery-result.test.js +258 -0
- package/infrastructure/domains/shared/types/index.js +46 -0
- package/infrastructure/domains/shared/types/resource-ownership.js +108 -0
- package/infrastructure/domains/shared/types/resource-ownership.test.js +101 -0
- package/infrastructure/domains/shared/utilities/base-definition-factory.js +394 -0
- package/infrastructure/domains/shared/utilities/base-definition-factory.js.bak +338 -0
- package/infrastructure/domains/shared/utilities/base-definition-factory.test.js +291 -0
- package/infrastructure/domains/shared/utilities/handler-path-resolver.js +134 -0
- package/infrastructure/domains/shared/utilities/handler-path-resolver.test.js +268 -0
- package/infrastructure/domains/shared/utilities/prisma-layer-manager.js +159 -0
- package/infrastructure/domains/shared/utilities/prisma-layer-manager.test.js +444 -0
- package/infrastructure/domains/shared/validation/env-validator.js +78 -0
- package/infrastructure/domains/shared/validation/env-validator.test.js +173 -0
- package/infrastructure/domains/shared/validation/plugin-validator.js +187 -0
- package/infrastructure/domains/shared/validation/plugin-validator.test.js +323 -0
- package/infrastructure/esbuild.config.js +53 -0
- package/infrastructure/infrastructure-composer.js +117 -0
- package/infrastructure/infrastructure-composer.test.js +1895 -0
- package/infrastructure/integration.test.js +383 -0
- package/infrastructure/scripts/build-prisma-layer.js +701 -0
- package/infrastructure/scripts/build-prisma-layer.test.js +170 -0
- package/infrastructure/scripts/build-time-discovery.js +238 -0
- package/infrastructure/scripts/build-time-discovery.test.js +379 -0
- package/infrastructure/scripts/run-discovery.js +110 -0
- package/infrastructure/scripts/verify-prisma-layer.js +72 -0
- 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 +203 -0
- 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 +35 -14
- package/test/index.js +2 -4
- package/test/mock-integration.js +4 -14
- package/infrastructure/app-handler-helpers.js +0 -57
- package/infrastructure/backend-utils.js +0 -87
- package/infrastructure/routers/auth.js +0 -26
- package/infrastructure/routers/integration-defined-routers.js +0 -42
- package/infrastructure/routers/middleware/loadUser.js +0 -15
- package/infrastructure/routers/middleware/requireLoggedInUser.js +0 -12
- package/infrastructure/routers/user.js +0 -41
- package/infrastructure/routers/websocket.js +0 -55
- package/infrastructure/serverless-template.js +0 -291
- package/infrastructure/workers/integration-defined-workers.js +0 -24
- package/test/auther-definition-tester.js +0 -125
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
import React, { useState, useEffect } from 'react'
|
|
2
|
+
import { Button } from '../Button'
|
|
3
|
+
import api from '../../services/api'
|
|
4
|
+
|
|
5
|
+
const ConnectionConfigForm = ({ connection, integration, onSave, onCancel }) => {
|
|
6
|
+
const [config, setConfig] = useState({
|
|
7
|
+
name: '',
|
|
8
|
+
description: '',
|
|
9
|
+
syncInterval: 'hourly',
|
|
10
|
+
autoSync: true,
|
|
11
|
+
webhookEnabled: false,
|
|
12
|
+
webhookUrl: '',
|
|
13
|
+
rateLimitOverride: '',
|
|
14
|
+
customHeaders: {},
|
|
15
|
+
entityMappings: [],
|
|
16
|
+
advanced: {}
|
|
17
|
+
})
|
|
18
|
+
const [loading, setLoading] = useState(false)
|
|
19
|
+
const [error, setError] = useState(null)
|
|
20
|
+
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
if (connection) {
|
|
23
|
+
// Load existing configuration
|
|
24
|
+
setConfig({
|
|
25
|
+
name: connection.name || '',
|
|
26
|
+
description: connection.description || '',
|
|
27
|
+
syncInterval: connection.syncInterval || 'hourly',
|
|
28
|
+
autoSync: connection.autoSync !== false,
|
|
29
|
+
webhookEnabled: connection.webhookEnabled || false,
|
|
30
|
+
webhookUrl: connection.webhookUrl || '',
|
|
31
|
+
rateLimitOverride: connection.rateLimitOverride || '',
|
|
32
|
+
customHeaders: connection.customHeaders || {},
|
|
33
|
+
entityMappings: connection.entityMappings || [],
|
|
34
|
+
advanced: connection.advanced || {}
|
|
35
|
+
})
|
|
36
|
+
}
|
|
37
|
+
}, [connection])
|
|
38
|
+
|
|
39
|
+
const handleSubmit = async (e) => {
|
|
40
|
+
e.preventDefault()
|
|
41
|
+
setLoading(true)
|
|
42
|
+
setError(null)
|
|
43
|
+
|
|
44
|
+
try {
|
|
45
|
+
const endpoint = connection
|
|
46
|
+
? `/api/connections/${connection.id}/config`
|
|
47
|
+
: '/api/connections/config'
|
|
48
|
+
|
|
49
|
+
const method = connection ? 'put' : 'post'
|
|
50
|
+
|
|
51
|
+
const response = await api[method](endpoint, {
|
|
52
|
+
...config,
|
|
53
|
+
integrationId: integration.id
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
onSave(response.data)
|
|
57
|
+
} catch (err) {
|
|
58
|
+
setError(err.response?.data?.error || 'Failed to save configuration')
|
|
59
|
+
} finally {
|
|
60
|
+
setLoading(false)
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const addCustomHeader = () => {
|
|
65
|
+
const key = prompt('Header name:')
|
|
66
|
+
if (key) {
|
|
67
|
+
const value = prompt('Header value:')
|
|
68
|
+
if (value) {
|
|
69
|
+
setConfig(prev => ({
|
|
70
|
+
...prev,
|
|
71
|
+
customHeaders: {
|
|
72
|
+
...prev.customHeaders,
|
|
73
|
+
[key]: value
|
|
74
|
+
}
|
|
75
|
+
}))
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const removeCustomHeader = (key) => {
|
|
81
|
+
setConfig(prev => {
|
|
82
|
+
const { [key]: _, ...rest } = prev.customHeaders
|
|
83
|
+
return { ...prev, customHeaders: rest }
|
|
84
|
+
})
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const addEntityMapping = () => {
|
|
88
|
+
setConfig(prev => ({
|
|
89
|
+
...prev,
|
|
90
|
+
entityMappings: [
|
|
91
|
+
...prev.entityMappings,
|
|
92
|
+
{
|
|
93
|
+
id: Date.now(),
|
|
94
|
+
sourceType: '',
|
|
95
|
+
targetType: '',
|
|
96
|
+
fieldMappings: {}
|
|
97
|
+
}
|
|
98
|
+
]
|
|
99
|
+
}))
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const updateEntityMapping = (id, updates) => {
|
|
103
|
+
setConfig(prev => ({
|
|
104
|
+
...prev,
|
|
105
|
+
entityMappings: prev.entityMappings.map(mapping =>
|
|
106
|
+
mapping.id === id ? { ...mapping, ...updates } : mapping
|
|
107
|
+
)
|
|
108
|
+
}))
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const removeEntityMapping = (id) => {
|
|
112
|
+
setConfig(prev => ({
|
|
113
|
+
...prev,
|
|
114
|
+
entityMappings: prev.entityMappings.filter(mapping => mapping.id !== id)
|
|
115
|
+
}))
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return (
|
|
119
|
+
<form onSubmit={handleSubmit} className="space-y-6">
|
|
120
|
+
{error && (
|
|
121
|
+
<div className="p-3 bg-destructive/10 border border-destructive/20 rounded-md">
|
|
122
|
+
<p className="text-sm text-destructive">{error}</p>
|
|
123
|
+
</div>
|
|
124
|
+
)}
|
|
125
|
+
|
|
126
|
+
{/* Basic Configuration */}
|
|
127
|
+
<div className="bg-card rounded-lg shadow p-6 border border-border">
|
|
128
|
+
<h3 className="text-lg font-semibold text-card-foreground mb-4">Basic Configuration</h3>
|
|
129
|
+
|
|
130
|
+
<div className="space-y-4">
|
|
131
|
+
<div>
|
|
132
|
+
<label htmlFor="name" className="block text-sm font-medium text-foreground">
|
|
133
|
+
Connection Name
|
|
134
|
+
</label>
|
|
135
|
+
<input
|
|
136
|
+
type="text"
|
|
137
|
+
id="name"
|
|
138
|
+
value={config.name}
|
|
139
|
+
onChange={(e) => setConfig(prev => ({ ...prev, name: e.target.value }))}
|
|
140
|
+
className="mt-1 block w-full rounded-md border-input bg-background text-foreground shadow-sm focus:border-ring focus:ring-ring sm:text-sm"
|
|
141
|
+
placeholder={`My ${integration.displayName} Connection`}
|
|
142
|
+
/>
|
|
143
|
+
</div>
|
|
144
|
+
|
|
145
|
+
<div>
|
|
146
|
+
<label htmlFor="description" className="block text-sm font-medium text-foreground">
|
|
147
|
+
Description
|
|
148
|
+
</label>
|
|
149
|
+
<textarea
|
|
150
|
+
id="description"
|
|
151
|
+
value={config.description}
|
|
152
|
+
onChange={(e) => setConfig(prev => ({ ...prev, description: e.target.value }))}
|
|
153
|
+
rows={3}
|
|
154
|
+
className="mt-1 block w-full rounded-md border-input bg-background text-foreground shadow-sm focus:border-ring focus:ring-ring sm:text-sm"
|
|
155
|
+
placeholder="Optional description for this connection"
|
|
156
|
+
/>
|
|
157
|
+
</div>
|
|
158
|
+
</div>
|
|
159
|
+
</div>
|
|
160
|
+
|
|
161
|
+
{/* Sync Configuration */}
|
|
162
|
+
<div className="bg-card rounded-lg shadow p-6 border border-border">
|
|
163
|
+
<h3 className="text-lg font-semibold text-card-foreground mb-4">Sync Configuration</h3>
|
|
164
|
+
|
|
165
|
+
<div className="space-y-4">
|
|
166
|
+
<div>
|
|
167
|
+
<label className="flex items-center">
|
|
168
|
+
<input
|
|
169
|
+
type="checkbox"
|
|
170
|
+
checked={config.autoSync}
|
|
171
|
+
onChange={(e) => setConfig(prev => ({ ...prev, autoSync: e.target.checked }))}
|
|
172
|
+
className="rounded border-input text-primary shadow-sm focus:border-ring focus:ring-ring"
|
|
173
|
+
/>
|
|
174
|
+
<span className="ml-2 text-sm text-foreground">Enable automatic synchronization</span>
|
|
175
|
+
</label>
|
|
176
|
+
</div>
|
|
177
|
+
|
|
178
|
+
{config.autoSync && (
|
|
179
|
+
<div>
|
|
180
|
+
<label htmlFor="syncInterval" className="block text-sm font-medium text-foreground">
|
|
181
|
+
Sync Interval
|
|
182
|
+
</label>
|
|
183
|
+
<select
|
|
184
|
+
id="syncInterval"
|
|
185
|
+
value={config.syncInterval}
|
|
186
|
+
onChange={(e) => setConfig(prev => ({ ...prev, syncInterval: e.target.value }))}
|
|
187
|
+
className="mt-1 block w-full rounded-md border-input bg-background text-foreground shadow-sm focus:border-ring focus:ring-ring sm:text-sm"
|
|
188
|
+
>
|
|
189
|
+
<option value="realtime">Real-time</option>
|
|
190
|
+
<option value="5min">Every 5 minutes</option>
|
|
191
|
+
<option value="15min">Every 15 minutes</option>
|
|
192
|
+
<option value="hourly">Hourly</option>
|
|
193
|
+
<option value="daily">Daily</option>
|
|
194
|
+
<option value="weekly">Weekly</option>
|
|
195
|
+
</select>
|
|
196
|
+
</div>
|
|
197
|
+
)}
|
|
198
|
+
</div>
|
|
199
|
+
</div>
|
|
200
|
+
|
|
201
|
+
{/* Webhook Configuration */}
|
|
202
|
+
<div className="bg-card rounded-lg shadow p-6 border border-border">
|
|
203
|
+
<h3 className="text-lg font-semibold text-card-foreground mb-4">Webhook Configuration</h3>
|
|
204
|
+
|
|
205
|
+
<div className="space-y-4">
|
|
206
|
+
<div>
|
|
207
|
+
<label className="flex items-center">
|
|
208
|
+
<input
|
|
209
|
+
type="checkbox"
|
|
210
|
+
checked={config.webhookEnabled}
|
|
211
|
+
onChange={(e) => setConfig(prev => ({ ...prev, webhookEnabled: e.target.checked }))}
|
|
212
|
+
className="rounded border-input text-primary shadow-sm focus:border-ring focus:ring-ring"
|
|
213
|
+
/>
|
|
214
|
+
<span className="ml-2 text-sm text-foreground">Enable webhooks for real-time updates</span>
|
|
215
|
+
</label>
|
|
216
|
+
</div>
|
|
217
|
+
|
|
218
|
+
{config.webhookEnabled && (
|
|
219
|
+
<div>
|
|
220
|
+
<label htmlFor="webhookUrl" className="block text-sm font-medium text-foreground">
|
|
221
|
+
Webhook URL
|
|
222
|
+
</label>
|
|
223
|
+
<div className="mt-1 flex rounded-md shadow-sm">
|
|
224
|
+
<span className="inline-flex items-center px-3 rounded-l-md border border-r-0 border-input bg-muted text-muted-foreground text-sm">
|
|
225
|
+
{window.location.origin}/api/webhooks/
|
|
226
|
+
</span>
|
|
227
|
+
<input
|
|
228
|
+
type="text"
|
|
229
|
+
id="webhookUrl"
|
|
230
|
+
value={config.webhookUrl}
|
|
231
|
+
onChange={(e) => setConfig(prev => ({ ...prev, webhookUrl: e.target.value }))}
|
|
232
|
+
className="flex-1 block w-full rounded-none rounded-r-md border-input bg-background text-foreground focus:border-ring focus:ring-ring sm:text-sm"
|
|
233
|
+
placeholder="connection-id"
|
|
234
|
+
disabled
|
|
235
|
+
/>
|
|
236
|
+
</div>
|
|
237
|
+
<p className="mt-2 text-sm text-muted-foreground">
|
|
238
|
+
This URL will be automatically generated when the connection is created.
|
|
239
|
+
</p>
|
|
240
|
+
</div>
|
|
241
|
+
)}
|
|
242
|
+
</div>
|
|
243
|
+
</div>
|
|
244
|
+
|
|
245
|
+
{/* Advanced Configuration */}
|
|
246
|
+
<div className="bg-card rounded-lg shadow p-6 border border-border">
|
|
247
|
+
<h3 className="text-lg font-semibold text-card-foreground mb-4">Advanced Configuration</h3>
|
|
248
|
+
|
|
249
|
+
<div className="space-y-4">
|
|
250
|
+
<div>
|
|
251
|
+
<label htmlFor="rateLimitOverride" className="block text-sm font-medium text-foreground">
|
|
252
|
+
Rate Limit Override (requests per minute)
|
|
253
|
+
</label>
|
|
254
|
+
<input
|
|
255
|
+
type="number"
|
|
256
|
+
id="rateLimitOverride"
|
|
257
|
+
value={config.rateLimitOverride}
|
|
258
|
+
onChange={(e) => setConfig(prev => ({ ...prev, rateLimitOverride: e.target.value }))}
|
|
259
|
+
className="mt-1 block w-full rounded-md border-input bg-background text-foreground shadow-sm focus:border-ring focus:ring-ring sm:text-sm"
|
|
260
|
+
placeholder="Leave empty to use default"
|
|
261
|
+
/>
|
|
262
|
+
</div>
|
|
263
|
+
|
|
264
|
+
<div>
|
|
265
|
+
<div className="flex items-center justify-between mb-2">
|
|
266
|
+
<label className="block text-sm font-medium text-foreground">
|
|
267
|
+
Custom Headers
|
|
268
|
+
</label>
|
|
269
|
+
<Button type="button" onClick={addCustomHeader} size="sm" variant="secondary">
|
|
270
|
+
Add Header
|
|
271
|
+
</Button>
|
|
272
|
+
</div>
|
|
273
|
+
{Object.keys(config.customHeaders).length > 0 ? (
|
|
274
|
+
<div className="space-y-2">
|
|
275
|
+
{Object.entries(config.customHeaders).map(([key, value]) => (
|
|
276
|
+
<div key={key} className="flex items-center space-x-2 p-2 bg-muted/50 rounded">
|
|
277
|
+
<code className="text-sm font-mono flex-1">{key}: {value}</code>
|
|
278
|
+
<button
|
|
279
|
+
type="button"
|
|
280
|
+
onClick={() => removeCustomHeader(key)}
|
|
281
|
+
className="text-destructive hover:text-destructive/80"
|
|
282
|
+
>
|
|
283
|
+
Remove
|
|
284
|
+
</button>
|
|
285
|
+
</div>
|
|
286
|
+
))}
|
|
287
|
+
</div>
|
|
288
|
+
) : (
|
|
289
|
+
<p className="text-sm text-muted-foreground">No custom headers configured</p>
|
|
290
|
+
)}
|
|
291
|
+
</div>
|
|
292
|
+
</div>
|
|
293
|
+
</div>
|
|
294
|
+
|
|
295
|
+
{/* Entity Mappings */}
|
|
296
|
+
<div className="bg-card rounded-lg shadow p-6 border border-border">
|
|
297
|
+
<div className="flex items-center justify-between mb-4">
|
|
298
|
+
<h3 className="text-lg font-semibold text-gray-900">Entity Mappings</h3>
|
|
299
|
+
<Button type="button" onClick={addEntityMapping} size="sm" variant="secondary">
|
|
300
|
+
Add Mapping
|
|
301
|
+
</Button>
|
|
302
|
+
</div>
|
|
303
|
+
|
|
304
|
+
{config.entityMappings.length > 0 ? (
|
|
305
|
+
<div className="space-y-4">
|
|
306
|
+
{config.entityMappings.map((mapping) => (
|
|
307
|
+
<div key={mapping.id} className="border border-gray-200 rounded-lg p-4">
|
|
308
|
+
<div className="grid grid-cols-2 gap-4">
|
|
309
|
+
<div>
|
|
310
|
+
<label className="block text-sm font-medium text-foreground">
|
|
311
|
+
Source Type
|
|
312
|
+
</label>
|
|
313
|
+
<input
|
|
314
|
+
type="text"
|
|
315
|
+
value={mapping.sourceType}
|
|
316
|
+
onChange={(e) => updateEntityMapping(mapping.id, { sourceType: e.target.value })}
|
|
317
|
+
className="mt-1 block w-full rounded-md border-input bg-background text-foreground shadow-sm focus:border-ring focus:ring-ring sm:text-sm"
|
|
318
|
+
placeholder="e.g., Contact"
|
|
319
|
+
/>
|
|
320
|
+
</div>
|
|
321
|
+
<div>
|
|
322
|
+
<label className="block text-sm font-medium text-foreground">
|
|
323
|
+
Target Type
|
|
324
|
+
</label>
|
|
325
|
+
<input
|
|
326
|
+
type="text"
|
|
327
|
+
value={mapping.targetType}
|
|
328
|
+
onChange={(e) => updateEntityMapping(mapping.id, { targetType: e.target.value })}
|
|
329
|
+
className="mt-1 block w-full rounded-md border-input bg-background text-foreground shadow-sm focus:border-ring focus:ring-ring sm:text-sm"
|
|
330
|
+
placeholder="e.g., User"
|
|
331
|
+
/>
|
|
332
|
+
</div>
|
|
333
|
+
</div>
|
|
334
|
+
<button
|
|
335
|
+
type="button"
|
|
336
|
+
onClick={() => removeEntityMapping(mapping.id)}
|
|
337
|
+
className="mt-2 text-sm text-red-600 hover:text-red-800"
|
|
338
|
+
>
|
|
339
|
+
Remove Mapping
|
|
340
|
+
</button>
|
|
341
|
+
</div>
|
|
342
|
+
))}
|
|
343
|
+
</div>
|
|
344
|
+
) : (
|
|
345
|
+
<p className="text-sm text-gray-500">No entity mappings configured</p>
|
|
346
|
+
)}
|
|
347
|
+
</div>
|
|
348
|
+
|
|
349
|
+
{/* Form Actions */}
|
|
350
|
+
<div className="flex justify-end space-x-3">
|
|
351
|
+
<Button type="button" onClick={onCancel} variant="secondary">
|
|
352
|
+
Cancel
|
|
353
|
+
</Button>
|
|
354
|
+
<Button type="submit" variant="primary" disabled={loading}>
|
|
355
|
+
{loading ? 'Saving...' : 'Save Configuration'}
|
|
356
|
+
</Button>
|
|
357
|
+
</div>
|
|
358
|
+
</form>
|
|
359
|
+
)
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
export default ConnectionConfigForm
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import React, { useState, useEffect } from 'react'
|
|
2
|
+
import { useSocket } from '../../hooks/useSocket'
|
|
3
|
+
import StatusBadge from '../StatusBadge'
|
|
4
|
+
import api from '../../services/api'
|
|
5
|
+
|
|
6
|
+
const ConnectionHealthMonitor = ({ connectionId, compact = false }) => {
|
|
7
|
+
const socket = useSocket()
|
|
8
|
+
const [health, setHealth] = useState({
|
|
9
|
+
status: 'unknown',
|
|
10
|
+
lastCheck: null,
|
|
11
|
+
uptime: 0,
|
|
12
|
+
latency: null,
|
|
13
|
+
errorRate: 0,
|
|
14
|
+
apiCalls: {
|
|
15
|
+
total: 0,
|
|
16
|
+
successful: 0,
|
|
17
|
+
failed: 0
|
|
18
|
+
}
|
|
19
|
+
})
|
|
20
|
+
const [loading, setLoading] = useState(true)
|
|
21
|
+
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
// Fetch initial health data
|
|
24
|
+
fetchHealthData()
|
|
25
|
+
|
|
26
|
+
// Subscribe to real-time health updates
|
|
27
|
+
if (socket) {
|
|
28
|
+
socket.on(`connection-health-${connectionId}`, handleHealthUpdate)
|
|
29
|
+
socket.emit('subscribe', { topics: [`connection-health-${connectionId}`] })
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Set up periodic health checks
|
|
33
|
+
const interval = setInterval(fetchHealthData, 60000) // Check every minute
|
|
34
|
+
|
|
35
|
+
return () => {
|
|
36
|
+
if (socket) {
|
|
37
|
+
socket.off(`connection-health-${connectionId}`, handleHealthUpdate)
|
|
38
|
+
socket.emit('unsubscribe', { topics: [`connection-health-${connectionId}`] })
|
|
39
|
+
}
|
|
40
|
+
clearInterval(interval)
|
|
41
|
+
}
|
|
42
|
+
}, [connectionId, socket])
|
|
43
|
+
|
|
44
|
+
const fetchHealthData = async () => {
|
|
45
|
+
try {
|
|
46
|
+
const response = await api.get(`/api/connections/${connectionId}/health`)
|
|
47
|
+
setHealth(response.data)
|
|
48
|
+
setLoading(false)
|
|
49
|
+
} catch (error) {
|
|
50
|
+
console.error('Failed to fetch health data:', error)
|
|
51
|
+
setHealth(prev => ({ ...prev, status: 'error' }))
|
|
52
|
+
setLoading(false)
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const handleHealthUpdate = (data) => {
|
|
57
|
+
setHealth(prev => ({
|
|
58
|
+
...prev,
|
|
59
|
+
...data,
|
|
60
|
+
lastCheck: new Date().toISOString()
|
|
61
|
+
}))
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const getHealthStatus = () => {
|
|
65
|
+
if (health.status === 'healthy' && health.errorRate < 5) {
|
|
66
|
+
return { color: 'success', text: 'Healthy' }
|
|
67
|
+
} else if (health.status === 'healthy' && health.errorRate < 20) {
|
|
68
|
+
return { color: 'warning', text: 'Degraded' }
|
|
69
|
+
} else if (health.status === 'error' || health.errorRate >= 20) {
|
|
70
|
+
return { color: 'error', text: 'Unhealthy' }
|
|
71
|
+
}
|
|
72
|
+
return { color: 'default', text: 'Unknown' }
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const formatUptime = (seconds) => {
|
|
76
|
+
const days = Math.floor(seconds / 86400)
|
|
77
|
+
const hours = Math.floor((seconds % 86400) / 3600)
|
|
78
|
+
const minutes = Math.floor((seconds % 3600) / 60)
|
|
79
|
+
|
|
80
|
+
if (days > 0) {
|
|
81
|
+
return `${days}d ${hours}h`
|
|
82
|
+
} else if (hours > 0) {
|
|
83
|
+
return `${hours}h ${minutes}m`
|
|
84
|
+
}
|
|
85
|
+
return `${minutes}m`
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const healthStatus = getHealthStatus()
|
|
89
|
+
|
|
90
|
+
if (loading) {
|
|
91
|
+
return (
|
|
92
|
+
<div className="animate-pulse">
|
|
93
|
+
<div className="h-4 bg-gray-200 rounded w-24"></div>
|
|
94
|
+
</div>
|
|
95
|
+
)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (compact) {
|
|
99
|
+
return (
|
|
100
|
+
<div className="flex items-center space-x-2">
|
|
101
|
+
<StatusBadge status={healthStatus.color} text={healthStatus.text} />
|
|
102
|
+
{health.latency && (
|
|
103
|
+
<span className="text-xs text-gray-500">{health.latency}ms</span>
|
|
104
|
+
)}
|
|
105
|
+
</div>
|
|
106
|
+
)
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return (
|
|
110
|
+
<div className="bg-white rounded-lg shadow p-6">
|
|
111
|
+
<div className="flex items-center justify-between mb-4">
|
|
112
|
+
<h3 className="text-lg font-semibold text-gray-900">Connection Health</h3>
|
|
113
|
+
<StatusBadge status={healthStatus.color} text={healthStatus.text} />
|
|
114
|
+
</div>
|
|
115
|
+
|
|
116
|
+
<div className="grid grid-cols-2 gap-4">
|
|
117
|
+
<div>
|
|
118
|
+
<p className="text-sm text-gray-500">Uptime</p>
|
|
119
|
+
<p className="text-lg font-medium text-gray-900">
|
|
120
|
+
{formatUptime(health.uptime)}
|
|
121
|
+
</p>
|
|
122
|
+
</div>
|
|
123
|
+
|
|
124
|
+
<div>
|
|
125
|
+
<p className="text-sm text-gray-500">Response Time</p>
|
|
126
|
+
<p className="text-lg font-medium text-gray-900">
|
|
127
|
+
{health.latency ? `${health.latency}ms` : 'N/A'}
|
|
128
|
+
</p>
|
|
129
|
+
</div>
|
|
130
|
+
|
|
131
|
+
<div>
|
|
132
|
+
<p className="text-sm text-gray-500">Success Rate</p>
|
|
133
|
+
<p className="text-lg font-medium text-gray-900">
|
|
134
|
+
{health.apiCalls.total > 0
|
|
135
|
+
? `${Math.round((health.apiCalls.successful / health.apiCalls.total) * 100)}%`
|
|
136
|
+
: 'N/A'}
|
|
137
|
+
</p>
|
|
138
|
+
</div>
|
|
139
|
+
|
|
140
|
+
<div>
|
|
141
|
+
<p className="text-sm text-gray-500">Total API Calls</p>
|
|
142
|
+
<p className="text-lg font-medium text-gray-900">
|
|
143
|
+
{health.apiCalls.total.toLocaleString()}
|
|
144
|
+
</p>
|
|
145
|
+
</div>
|
|
146
|
+
</div>
|
|
147
|
+
|
|
148
|
+
{health.apiCalls.failed > 0 && (
|
|
149
|
+
<div className="mt-4 p-3 bg-red-50 border border-red-200 rounded-md">
|
|
150
|
+
<p className="text-sm text-red-800">
|
|
151
|
+
{health.apiCalls.failed} failed API calls in the last 24 hours
|
|
152
|
+
</p>
|
|
153
|
+
</div>
|
|
154
|
+
)}
|
|
155
|
+
|
|
156
|
+
{health.lastCheck && (
|
|
157
|
+
<p className="mt-4 text-xs text-gray-500">
|
|
158
|
+
Last checked: {new Date(health.lastCheck).toLocaleTimeString()}
|
|
159
|
+
</p>
|
|
160
|
+
)}
|
|
161
|
+
|
|
162
|
+
<div className="mt-6 pt-4 border-t border-gray-200">
|
|
163
|
+
<h4 className="text-sm font-semibold text-gray-900 mb-3">Recent Activity</h4>
|
|
164
|
+
|
|
165
|
+
<div className="space-y-2">
|
|
166
|
+
{health.recentEvents?.map((event, index) => (
|
|
167
|
+
<div key={index} className="flex items-center justify-between text-sm">
|
|
168
|
+
<span className="text-gray-600">{event.type}</span>
|
|
169
|
+
<span className="text-gray-500 text-xs">
|
|
170
|
+
{new Date(event.timestamp).toLocaleTimeString()}
|
|
171
|
+
</span>
|
|
172
|
+
</div>
|
|
173
|
+
)) || (
|
|
174
|
+
<p className="text-sm text-gray-500">No recent activity</p>
|
|
175
|
+
)}
|
|
176
|
+
</div>
|
|
177
|
+
</div>
|
|
178
|
+
</div>
|
|
179
|
+
)
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export default ConnectionHealthMonitor
|