@friggframework/devtools 2.0.0-next.7 → 2.0.0-next.71
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/auth-command/CLAUDE.md +293 -0
- package/frigg-cli/auth-command/README.md +450 -0
- package/frigg-cli/auth-command/api-key-flow.js +153 -0
- package/frigg-cli/auth-command/auth-tester.js +344 -0
- package/frigg-cli/auth-command/credential-storage.js +182 -0
- package/frigg-cli/auth-command/index.js +256 -0
- package/frigg-cli/auth-command/json-schema-form.js +67 -0
- package/frigg-cli/auth-command/module-loader.js +172 -0
- package/frigg-cli/auth-command/oauth-callback-server.js +431 -0
- package/frigg-cli/auth-command/oauth-flow.js +195 -0
- package/frigg-cli/auth-command/utils/browser.js +30 -0
- package/frigg-cli/build-command/index.js +45 -12
- 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 -23
- 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 +174 -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 +118 -5
- 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/scheduler/scheduler-builder.js +211 -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 +408 -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 +119 -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/management-ui/README.md +203 -0
- package/package.json +44 -14
- package/test/index.js +2 -4
- package/test/mock-api.js +1 -3
- package/test/mock-integration.js +4 -14
- package/.eslintrc.json +0 -3
- package/CHANGELOG.md +0 -132
- 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,203 @@
|
|
|
1
|
+
# Frigg Management UI
|
|
2
|
+
|
|
3
|
+
A modern React-based management interface for Frigg development environment. Built with Vite, React, and Tailwind CSS, this application provides developers with a comprehensive dashboard to manage integrations, users, connections, and environment variables.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Dashboard**: Server control, metrics, and activity monitoring
|
|
8
|
+
- **Integration Discovery**: Browse, install, and manage Frigg integrations
|
|
9
|
+
- **Environment Management**: Configure environment variables and settings
|
|
10
|
+
- **User Management**: Create and manage test users
|
|
11
|
+
- **Connection Management**: Monitor and manage integration connections
|
|
12
|
+
- **Real-time Updates**: WebSocket-based live updates
|
|
13
|
+
- **Responsive Design**: Mobile-friendly interface
|
|
14
|
+
- **Error Boundaries**: Robust error handling
|
|
15
|
+
|
|
16
|
+
## Tech Stack
|
|
17
|
+
|
|
18
|
+
- **React 18.3**: Modern React with hooks and functional components
|
|
19
|
+
- **Vite**: Fast development and build tooling
|
|
20
|
+
- **React Router**: Client-side routing
|
|
21
|
+
- **Tailwind CSS**: Utility-first CSS framework
|
|
22
|
+
- **Lucide React**: Modern icon library
|
|
23
|
+
- **Socket.io**: Real-time communication
|
|
24
|
+
- **Axios**: HTTP client
|
|
25
|
+
- **@friggframework/ui**: Shared UI components
|
|
26
|
+
|
|
27
|
+
## Getting Started
|
|
28
|
+
|
|
29
|
+
### Prerequisites
|
|
30
|
+
|
|
31
|
+
- Node.js 16+ and npm
|
|
32
|
+
- Running Frigg backend server
|
|
33
|
+
|
|
34
|
+
### Installation
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
# Install dependencies
|
|
38
|
+
npm install
|
|
39
|
+
|
|
40
|
+
# Start development server (frontend only)
|
|
41
|
+
npm run dev
|
|
42
|
+
|
|
43
|
+
# Start both frontend and backend
|
|
44
|
+
npm run dev:server
|
|
45
|
+
|
|
46
|
+
# Build for production
|
|
47
|
+
npm run build
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Available Scripts
|
|
51
|
+
|
|
52
|
+
- `npm run dev` - Start Vite development server
|
|
53
|
+
- `npm run dev:server` - Start both frontend and backend concurrently
|
|
54
|
+
- `npm run build` - Build for production
|
|
55
|
+
- `npm run preview` - Preview production build
|
|
56
|
+
- `npm run server` - Start backend server only
|
|
57
|
+
- `npm run server:dev` - Start backend server with nodemon
|
|
58
|
+
- `npm run lint` - Run ESLint
|
|
59
|
+
- `npm run lint:fix` - Fix ESLint issues
|
|
60
|
+
- `npm run typecheck` - Run TypeScript type checking
|
|
61
|
+
|
|
62
|
+
## Project Structure
|
|
63
|
+
|
|
64
|
+
```
|
|
65
|
+
src/
|
|
66
|
+
├── components/ # Reusable UI components
|
|
67
|
+
│ ├── Button.jsx # Custom button component
|
|
68
|
+
│ ├── Card.jsx # Card container components
|
|
69
|
+
│ ├── ErrorBoundary.jsx
|
|
70
|
+
│ ├── IntegrationCard.jsx
|
|
71
|
+
│ ├── Layout.jsx # Main layout component
|
|
72
|
+
│ ├── LoadingSpinner.jsx
|
|
73
|
+
│ ├── StatusBadge.jsx
|
|
74
|
+
│ └── index.js # Component exports
|
|
75
|
+
├── hooks/ # React hooks
|
|
76
|
+
│ ├── useFrigg.jsx # Main Frigg state management
|
|
77
|
+
│ └── useSocket.jsx # WebSocket connection
|
|
78
|
+
├── pages/ # Page components
|
|
79
|
+
│ ├── Dashboard.jsx # Main dashboard
|
|
80
|
+
│ ├── Integrations.jsx
|
|
81
|
+
│ ├── Environment.jsx
|
|
82
|
+
│ ├── Users.jsx
|
|
83
|
+
│ └── Connections.jsx
|
|
84
|
+
├── services/ # API services
|
|
85
|
+
│ └── api.js # Axios configuration
|
|
86
|
+
├── utils/ # Utility functions
|
|
87
|
+
│ └── cn.js # Class name utility
|
|
88
|
+
├── App.jsx # Root component
|
|
89
|
+
├── main.jsx # Application entry point
|
|
90
|
+
└── index.css # Global styles
|
|
91
|
+
|
|
92
|
+
server/
|
|
93
|
+
├── api/ # Backend API routes
|
|
94
|
+
├── middleware/ # Express middleware
|
|
95
|
+
├── utils/ # Server utilities
|
|
96
|
+
├── websocket/ # WebSocket handlers
|
|
97
|
+
└── index.js # Server entry point
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Component Architecture
|
|
101
|
+
|
|
102
|
+
### Layout Components
|
|
103
|
+
- **Layout**: Main application layout with responsive sidebar
|
|
104
|
+
- **ErrorBoundary**: Catches and displays errors gracefully
|
|
105
|
+
|
|
106
|
+
### UI Components
|
|
107
|
+
- **Button**: Customizable button with variants and sizes
|
|
108
|
+
- **Card**: Container components for content sections
|
|
109
|
+
- **StatusBadge**: Displays server status with color coding
|
|
110
|
+
- **LoadingSpinner**: Loading indicators
|
|
111
|
+
- **IntegrationCard**: Rich integration display component
|
|
112
|
+
|
|
113
|
+
### State Management
|
|
114
|
+
- **useFrigg**: Central state management for Frigg data
|
|
115
|
+
- **useSocket**: WebSocket connection and real-time updates
|
|
116
|
+
|
|
117
|
+
## API Integration
|
|
118
|
+
|
|
119
|
+
The management UI communicates with the Frigg backend through:
|
|
120
|
+
|
|
121
|
+
1. **REST API**: Standard CRUD operations
|
|
122
|
+
2. **WebSocket**: Real-time updates and notifications
|
|
123
|
+
|
|
124
|
+
### API Endpoints
|
|
125
|
+
|
|
126
|
+
- `GET /api/frigg/status` - Server status
|
|
127
|
+
- `POST /api/frigg/start` - Start Frigg server
|
|
128
|
+
- `POST /api/frigg/stop` - Stop Frigg server
|
|
129
|
+
- `GET /api/integrations` - List integrations
|
|
130
|
+
- `POST /api/integrations/install` - Install integration
|
|
131
|
+
- `GET /api/environment` - Environment variables
|
|
132
|
+
- `PUT /api/environment` - Update environment variables
|
|
133
|
+
- `GET /api/users` - List test users
|
|
134
|
+
- `POST /api/users` - Create test user
|
|
135
|
+
- `GET /api/connections` - List connections
|
|
136
|
+
|
|
137
|
+
## Styling
|
|
138
|
+
|
|
139
|
+
This project uses Tailwind CSS for styling with:
|
|
140
|
+
|
|
141
|
+
- **Design System**: Consistent spacing, colors, and typography
|
|
142
|
+
- **Responsive Design**: Mobile-first approach
|
|
143
|
+
- **Component Variants**: Button and component style variants
|
|
144
|
+
- **Dark Mode Ready**: CSS custom properties for theming
|
|
145
|
+
|
|
146
|
+
### Custom Utilities
|
|
147
|
+
|
|
148
|
+
- `cn()`: Utility for combining Tailwind classes with conditional logic
|
|
149
|
+
|
|
150
|
+
## Error Handling
|
|
151
|
+
|
|
152
|
+
- **Error Boundaries**: React error boundaries catch component errors
|
|
153
|
+
- **API Error Handling**: Axios interceptors handle API errors
|
|
154
|
+
- **Loading States**: Loading spinners and disabled states
|
|
155
|
+
- **Validation**: Form validation and user feedback
|
|
156
|
+
|
|
157
|
+
## Development
|
|
158
|
+
|
|
159
|
+
### Code Style
|
|
160
|
+
|
|
161
|
+
- **ESLint**: Linting with React and React Hooks rules
|
|
162
|
+
- **Prettier**: Code formatting (recommended)
|
|
163
|
+
- **TypeScript Ready**: Prepared for TypeScript migration
|
|
164
|
+
|
|
165
|
+
### Best Practices
|
|
166
|
+
|
|
167
|
+
- Functional components with hooks
|
|
168
|
+
- Component composition over inheritance
|
|
169
|
+
- Separation of concerns (UI, state, logic)
|
|
170
|
+
- Error boundaries for robustness
|
|
171
|
+
- Loading states for better UX
|
|
172
|
+
- Responsive design principles
|
|
173
|
+
|
|
174
|
+
## Building and Deployment
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
# Build for production
|
|
178
|
+
npm run build
|
|
179
|
+
|
|
180
|
+
# Preview production build
|
|
181
|
+
npm run preview
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
The build output will be in the `dist/` directory and can be served by any static file server.
|
|
185
|
+
|
|
186
|
+
## Environment Variables
|
|
187
|
+
|
|
188
|
+
The application automatically detects the environment:
|
|
189
|
+
|
|
190
|
+
- **Development**: API calls to `http://localhost:3001`
|
|
191
|
+
- **Production**: API calls to the same origin
|
|
192
|
+
|
|
193
|
+
## Contributing
|
|
194
|
+
|
|
195
|
+
1. Follow the existing code style and patterns
|
|
196
|
+
2. Add error handling for new features
|
|
197
|
+
3. Include loading states for async operations
|
|
198
|
+
4. Write tests for new components (when testing is set up)
|
|
199
|
+
5. Update documentation for significant changes
|
|
200
|
+
|
|
201
|
+
## License
|
|
202
|
+
|
|
203
|
+
This project is part of the Frigg Framework and follows the same licensing terms.
|
package/package.json
CHANGED
|
@@ -1,19 +1,41 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@friggframework/devtools",
|
|
3
3
|
"prettier": "@friggframework/prettier-config",
|
|
4
|
-
"version": "2.0.0-next.
|
|
4
|
+
"version": "2.0.0-next.71",
|
|
5
|
+
"bin": {
|
|
6
|
+
"frigg": "./frigg-cli/index.js"
|
|
7
|
+
},
|
|
8
|
+
"files": [
|
|
9
|
+
"frigg-cli/",
|
|
10
|
+
"infrastructure/",
|
|
11
|
+
"migrations/",
|
|
12
|
+
"management-ui/dist/",
|
|
13
|
+
"test/",
|
|
14
|
+
"index.js",
|
|
15
|
+
"README.md"
|
|
16
|
+
],
|
|
5
17
|
"dependencies": {
|
|
18
|
+
"@aws-sdk/client-cloudformation": "^3.705.0",
|
|
19
|
+
"@aws-sdk/client-ec2": "^3.835.0",
|
|
20
|
+
"@aws-sdk/client-kms": "^3.835.0",
|
|
21
|
+
"@aws-sdk/client-rds": "^3.906.0",
|
|
22
|
+
"@aws-sdk/client-s3": "^3.917.0",
|
|
23
|
+
"@aws-sdk/client-secrets-manager": "^3.906.0",
|
|
24
|
+
"@aws-sdk/client-sts": "^3.835.0",
|
|
6
25
|
"@babel/eslint-parser": "^7.18.9",
|
|
7
26
|
"@babel/parser": "^7.25.3",
|
|
8
27
|
"@babel/traverse": "^7.25.3",
|
|
9
|
-
"@friggframework/core": "2.0.0-next.
|
|
10
|
-
"@friggframework/
|
|
11
|
-
"@
|
|
28
|
+
"@friggframework/core": "2.0.0-next.71",
|
|
29
|
+
"@friggframework/schemas": "2.0.0-next.71",
|
|
30
|
+
"@friggframework/test": "2.0.0-next.71",
|
|
31
|
+
"@hapi/boom": "^10.0.1",
|
|
12
32
|
"@inquirer/prompts": "^5.3.8",
|
|
13
33
|
"axios": "^1.7.2",
|
|
14
34
|
"body-parser": "^1.20.2",
|
|
35
|
+
"chalk": "^4.1.2",
|
|
15
36
|
"commander": "^12.1.0",
|
|
16
37
|
"cors": "^2.8.5",
|
|
38
|
+
"cross-spawn": "^7.0.3",
|
|
17
39
|
"dotenv": "^16.4.5",
|
|
18
40
|
"eslint": "^8.22.0",
|
|
19
41
|
"eslint-config-prettier": "^8.5.0",
|
|
@@ -24,25 +46,33 @@
|
|
|
24
46
|
"express": "^4.19.2",
|
|
25
47
|
"express-async-handler": "^1.2.0",
|
|
26
48
|
"fs-extra": "^11.2.0",
|
|
27
|
-
"
|
|
28
|
-
"
|
|
49
|
+
"js-yaml": "^4.1.0",
|
|
50
|
+
"lodash": "4.17.21",
|
|
51
|
+
"node-cache": "^5.1.2",
|
|
52
|
+
"open": "^8.4.2",
|
|
53
|
+
"semver": "^7.6.0",
|
|
54
|
+
"serverless-http": "^2.7.0",
|
|
55
|
+
"validate-npm-package-name": "^5.0.0"
|
|
29
56
|
},
|
|
30
57
|
"devDependencies": {
|
|
31
|
-
"@friggframework/eslint-config": "2.0.0-next.
|
|
32
|
-
"@friggframework/prettier-config": "2.0.0-next.
|
|
33
|
-
"
|
|
58
|
+
"@friggframework/eslint-config": "2.0.0-next.71",
|
|
59
|
+
"@friggframework/prettier-config": "2.0.0-next.71",
|
|
60
|
+
"aws-sdk-client-mock": "^4.1.0",
|
|
61
|
+
"aws-sdk-client-mock-jest": "^4.1.0",
|
|
62
|
+
"jest": "^30.1.3",
|
|
63
|
+
"osls": "^3.40.1",
|
|
64
|
+
"prettier": "^2.7.1",
|
|
34
65
|
"serverless-dotenv-plugin": "^6.0.0",
|
|
66
|
+
"serverless-esbuild": "^1.54.3",
|
|
67
|
+
"serverless-kms-grants": "^1.0.0",
|
|
35
68
|
"serverless-offline": "^13.8.0",
|
|
36
69
|
"serverless-offline-sqs": "^8.0.0",
|
|
37
|
-
"serverless-
|
|
70
|
+
"serverless-plugin-monorepo": "^0.11.0"
|
|
38
71
|
},
|
|
39
72
|
"scripts": {
|
|
40
73
|
"lint:fix": "prettier --write --loglevel error . && eslint . --fix",
|
|
41
74
|
"test": "jest --passWithNoTests # TODO"
|
|
42
75
|
},
|
|
43
|
-
"bin": {
|
|
44
|
-
"frigg": "./frigg-cli/index.js"
|
|
45
|
-
},
|
|
46
76
|
"author": "",
|
|
47
77
|
"license": "MIT",
|
|
48
78
|
"main": "index.js",
|
|
@@ -58,5 +88,5 @@
|
|
|
58
88
|
"publishConfig": {
|
|
59
89
|
"access": "public"
|
|
60
90
|
},
|
|
61
|
-
"gitHead": "
|
|
91
|
+
"gitHead": "a0fd3deb90390dbb9d01d7ac8fdb5e5f5b8f9c78"
|
|
62
92
|
}
|
package/test/index.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
const {testDefinitionRequiredAuthMethods} = require('./auther-definition-method-tester');
|
|
2
|
-
const {createMockIntegration, createMockApiObject} = require('./mock-integration');
|
|
3
|
-
const { testAutherDefinition } = require('./auther-definition-tester');
|
|
1
|
+
const { testDefinitionRequiredAuthMethods } = require('./auther-definition-method-tester');
|
|
2
|
+
const { createMockIntegration, createMockApiObject } = require('./mock-integration');
|
|
4
3
|
|
|
5
4
|
|
|
6
5
|
module.exports = {
|
|
7
6
|
createMockIntegration,
|
|
8
7
|
createMockApiObject,
|
|
9
8
|
testDefinitionRequiredAuthMethods,
|
|
10
|
-
testAutherDefinition,
|
|
11
9
|
};
|
package/test/mock-api.js
CHANGED
|
@@ -219,8 +219,7 @@ const mockApi = (Api, classOptionByName = {}) => {
|
|
|
219
219
|
// TODO read authentication mode from module package
|
|
220
220
|
if (authenticationMode === 'client_credentials') {
|
|
221
221
|
// TODO make generic (tied to crossbeam api)
|
|
222
|
-
api.
|
|
223
|
-
api.refreshAccessToken = api.getTokenFromClientCredentials;
|
|
222
|
+
api.grant_type = 'client_credentials';
|
|
224
223
|
|
|
225
224
|
if (process.env.CROSSBEAM_API_BASE_URL)
|
|
226
225
|
api.baseUrl = process.env.CROSSBEAM_API_BASE_URL;
|
|
@@ -231,7 +230,6 @@ const mockApi = (Api, classOptionByName = {}) => {
|
|
|
231
230
|
|
|
232
231
|
api.client_secret = process.env.CROSSBEAM_TEST_CLIENT_SECRET;
|
|
233
232
|
api.client_id = process.env.CROSSBEAM_TEST_CLIENT_ID;
|
|
234
|
-
api.refreshAccessToken = api.getTokenFromClientCredentials;
|
|
235
233
|
|
|
236
234
|
this.tokenResponse = await api.getTokenFromClientCredentials();
|
|
237
235
|
} else if (authenticationMode === 'puppet') {
|
package/test/mock-integration.js
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
const {
|
|
2
|
-
Auther,
|
|
3
|
-
Credential,
|
|
4
|
-
Entity,
|
|
5
|
-
IntegrationFactory,
|
|
6
2
|
createObjectId,
|
|
7
3
|
} = require('@friggframework/core');
|
|
8
4
|
|
|
@@ -11,7 +7,6 @@ async function createMockIntegration(
|
|
|
11
7
|
userId = null,
|
|
12
8
|
config = { type: IntegrationClass.Definition.name }
|
|
13
9
|
) {
|
|
14
|
-
const integrationFactory = new IntegrationFactory([IntegrationClass]);
|
|
15
10
|
userId = userId || createObjectId();
|
|
16
11
|
|
|
17
12
|
const insertOptions = {
|
|
@@ -24,10 +19,8 @@ async function createMockIntegration(
|
|
|
24
19
|
const entities = [];
|
|
25
20
|
for (const moduleName in IntegrationClass.modules) {
|
|
26
21
|
const ModuleDef = IntegrationClass.Definition.modules[moduleName];
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
userId: userId,
|
|
30
|
-
});
|
|
22
|
+
// todo: create module using the new architecture
|
|
23
|
+
const module = {}
|
|
31
24
|
const credential = await module.CredentialModel.findOneAndUpdate(
|
|
32
25
|
user,
|
|
33
26
|
{ $set: user },
|
|
@@ -51,11 +44,8 @@ async function createMockIntegration(
|
|
|
51
44
|
);
|
|
52
45
|
}
|
|
53
46
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
userId,
|
|
57
|
-
config
|
|
58
|
-
);
|
|
47
|
+
// todo: create integration using the new architecture
|
|
48
|
+
const integration = {}
|
|
59
49
|
|
|
60
50
|
integration.id = integration.record._id;
|
|
61
51
|
|
package/.eslintrc.json
DELETED
package/CHANGELOG.md
DELETED
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
# v1.2.0 (Tue Aug 06 2024)
|
|
2
|
-
|
|
3
|
-
#### 🚀 Enhancement
|
|
4
|
-
|
|
5
|
-
- CLI for Frigg - Install command for now [#322](https://github.com/friggframework/frigg/pull/322) ([@seanspeaks](https://github.com/seanspeaks))
|
|
6
|
-
|
|
7
|
-
#### 🐛 Bug Fix
|
|
8
|
-
|
|
9
|
-
- Add READMEs that will need updating, but for version releasing [#324](https://github.com/friggframework/frigg/pull/324) ([@seanspeaks](https://github.com/seanspeaks))
|
|
10
|
-
- Add READMEs that will need updating, but for version releasing ([@seanspeaks](https://github.com/seanspeaks))
|
|
11
|
-
- small update to integration testing / tooling [#304](https://github.com/friggframework/frigg/pull/304) ([@MichaelRyanWebber](https://github.com/MichaelRyanWebber))
|
|
12
|
-
- Added missing dependencies ([@seanspeaks](https://github.com/seanspeaks))
|
|
13
|
-
- Added a missing dependency ([@seanspeaks](https://github.com/seanspeaks))
|
|
14
|
-
- Updated to handle envs properly, also further refactoring, and better templating. ([@seanspeaks](https://github.com/seanspeaks))
|
|
15
|
-
- WIP with help from Tabnine AI chat. ([@seanspeaks](https://github.com/seanspeaks))
|
|
16
|
-
- Bump version to: v1.1.8 \[skip ci\] ([@seanspeaks](https://github.com/seanspeaks))
|
|
17
|
-
- use the factory methods for creating the mock integration so that everything is set up (mostly events and userActions) ([@MichaelRyanWebber](https://github.com/MichaelRyanWebber))
|
|
18
|
-
- Bump version to: v1.1.5 \[skip ci\] ([@seanspeaks](https://github.com/seanspeaks))
|
|
19
|
-
|
|
20
|
-
#### Authors: 2
|
|
21
|
-
|
|
22
|
-
- [@MichaelRyanWebber](https://github.com/MichaelRyanWebber)
|
|
23
|
-
- Sean Matthews ([@seanspeaks](https://github.com/seanspeaks))
|
|
24
|
-
|
|
25
|
-
---
|
|
26
|
-
|
|
27
|
-
# v1.1.8 (Thu Jul 18 2024)
|
|
28
|
-
|
|
29
|
-
#### 🐛 Bug Fix
|
|
30
|
-
|
|
31
|
-
- Revert open to support commonjs [#319](https://github.com/friggframework/frigg/pull/319) ([@MichaelRyanWebber](https://github.com/MichaelRyanWebber))
|
|
32
|
-
- Bump version to: v1.1.6 \[skip ci\] ([@seanspeaks](https://github.com/seanspeaks))
|
|
33
|
-
|
|
34
|
-
#### Authors: 2
|
|
35
|
-
|
|
36
|
-
- [@MichaelRyanWebber](https://github.com/MichaelRyanWebber)
|
|
37
|
-
- Sean Matthews ([@seanspeaks](https://github.com/seanspeaks))
|
|
38
|
-
|
|
39
|
-
---
|
|
40
|
-
|
|
41
|
-
# v1.1.7 (Mon Jul 15 2024)
|
|
42
|
-
|
|
43
|
-
#### 🐛 Bug Fix
|
|
44
|
-
|
|
45
|
-
- getAuthorizationRequirements() async [#318](https://github.com/friggframework/frigg/pull/318) ([@MichaelRyanWebber](https://github.com/MichaelRyanWebber))
|
|
46
|
-
- await getAuthorizeRequirements() ([@MichaelRyanWebber](https://github.com/MichaelRyanWebber))
|
|
47
|
-
- Bump version to: v1.1.6 \[skip ci\] ([@seanspeaks](https://github.com/seanspeaks))
|
|
48
|
-
|
|
49
|
-
#### Authors: 2
|
|
50
|
-
|
|
51
|
-
- [@MichaelRyanWebber](https://github.com/MichaelRyanWebber)
|
|
52
|
-
- Sean Matthews ([@seanspeaks](https://github.com/seanspeaks))
|
|
53
|
-
|
|
54
|
-
---
|
|
55
|
-
|
|
56
|
-
# v1.1.6 (Fri Apr 26 2024)
|
|
57
|
-
|
|
58
|
-
#### 🐛 Bug Fix
|
|
59
|
-
|
|
60
|
-
- Small fix to validation errors and cleanup [#307](https://github.com/friggframework/frigg/pull/307) ([@MichaelRyanWebber](https://github.com/MichaelRyanWebber))
|
|
61
|
-
- also cleanup devtools since all versions will bump ([@MichaelRyanWebber](https://github.com/MichaelRyanWebber))
|
|
62
|
-
- Bump version to: v1.1.5 \[skip ci\] ([@seanspeaks](https://github.com/seanspeaks))
|
|
63
|
-
|
|
64
|
-
#### Authors: 2
|
|
65
|
-
|
|
66
|
-
- [@MichaelRyanWebber](https://github.com/MichaelRyanWebber)
|
|
67
|
-
- Sean Matthews ([@seanspeaks](https://github.com/seanspeaks))
|
|
68
|
-
|
|
69
|
-
---
|
|
70
|
-
|
|
71
|
-
# v1.1.5 (Tue Apr 09 2024)
|
|
72
|
-
|
|
73
|
-
#### 🐛 Bug Fix
|
|
74
|
-
|
|
75
|
-
- update router to include options and refresh [#301](https://github.com/friggframework/frigg/pull/301) ([@MichaelRyanWebber](https://github.com/MichaelRyanWebber))
|
|
76
|
-
- Bump version to: v1.1.4 \[skip ci\] ([@seanspeaks](https://github.com/seanspeaks))
|
|
77
|
-
- Bump version to: v1.1.3 \[skip ci\] ([@seanspeaks](https://github.com/seanspeaks))
|
|
78
|
-
|
|
79
|
-
#### Authors: 2
|
|
80
|
-
|
|
81
|
-
- [@MichaelRyanWebber](https://github.com/MichaelRyanWebber)
|
|
82
|
-
- Sean Matthews ([@seanspeaks](https://github.com/seanspeaks))
|
|
83
|
-
|
|
84
|
-
---
|
|
85
|
-
|
|
86
|
-
# v2.0.0 (Sat Mar 30 2024)
|
|
87
|
-
|
|
88
|
-
#### 💥 Breaking Change
|
|
89
|
-
|
|
90
|
-
- revert HEAD to a corrected v1-connectwise release [#283](https://github.com/friggframework/frigg/pull/283) ([@MichaelRyanWebber](https://github.com/MichaelRyanWebber))
|
|
91
|
-
|
|
92
|
-
#### 🚀 Enhancement
|
|
93
|
-
|
|
94
|
-
- Package redo [#294](https://github.com/friggframework/frigg/pull/294) ([@MichaelRyanWebber](https://github.com/MichaelRyanWebber))
|
|
95
|
-
|
|
96
|
-
#### 🐛 Bug Fix
|
|
97
|
-
|
|
98
|
-
- delete all node_modules and regenerate lock file to potentially address known bug ([@MichaelRyanWebber](https://github.com/MichaelRyanWebber))
|
|
99
|
-
- add back the direct dependency on eslint as this might be leading to a deploy issue ([@MichaelRyanWebber](https://github.com/MichaelRyanWebber))
|
|
100
|
-
- create test, eslint-config and prettier-config packages as base shared dependencies ([@MichaelRyanWebber](https://github.com/MichaelRyanWebber))
|
|
101
|
-
- slight fix to mock integration module instantiation [#290](https://github.com/friggframework/frigg/pull/290) ([@MichaelRyanWebber](https://github.com/MichaelRyanWebber))
|
|
102
|
-
- slight fix to mock integration module instantiation ([@MichaelRyanWebber](https://github.com/MichaelRyanWebber))
|
|
103
|
-
- Publish ([@seanspeaks](https://github.com/seanspeaks))
|
|
104
|
-
- Bump node and npm version for the whole repo (Fix CI) [#274](https://github.com/friggframework/frigg/pull/274) ([@seanspeaks](https://github.com/seanspeaks))
|
|
105
|
-
- Revert main to last release [#284](https://github.com/friggframework/frigg/pull/284) ([@MichaelRyanWebber](https://github.com/MichaelRyanWebber))
|
|
106
|
-
- Revert "set test environment STAGE to dev" ([@MichaelRyanWebber](https://github.com/MichaelRyanWebber))
|
|
107
|
-
- Add stage to test env [#282](https://github.com/friggframework/frigg/pull/282) ([@MichaelRyanWebber](https://github.com/MichaelRyanWebber))
|
|
108
|
-
- set test environment STAGE to dev ([@MichaelRyanWebber](https://github.com/MichaelRyanWebber))
|
|
109
|
-
- Bump independent versions \[skip ci\] ([@seanspeaks](https://github.com/seanspeaks))
|
|
110
|
-
|
|
111
|
-
#### Authors: 2
|
|
112
|
-
|
|
113
|
-
- [@MichaelRyanWebber](https://github.com/MichaelRyanWebber)
|
|
114
|
-
- Sean Matthews ([@seanspeaks](https://github.com/seanspeaks))
|
|
115
|
-
|
|
116
|
-
---
|
|
117
|
-
|
|
118
|
-
# v1.1.0 (Wed Mar 20 2024)
|
|
119
|
-
|
|
120
|
-
#### 🚀 Enhancement
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
#### 🐛 Bug Fix
|
|
124
|
-
|
|
125
|
-
- correct some bad automated edits, though they are not in relevant files ([@MichaelRyanWebber](https://github.com/MichaelRyanWebber))
|
|
126
|
-
|
|
127
|
-
#### Authors: 4
|
|
128
|
-
|
|
129
|
-
- [@MichaelRyanWebber](https://github.com/MichaelRyanWebber)
|
|
130
|
-
- Nicolas Leal ([@nicolasmelo1](https://github.com/nicolasmelo1))
|
|
131
|
-
- nmilcoff ([@nmilcoff](https://github.com/nmilcoff))
|
|
132
|
-
- Sean Matthews ([@seanspeaks](https://github.com/seanspeaks))
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
const { createHandler, flushDebugLog } = require('@friggframework/core');
|
|
2
|
-
const express = require('express');
|
|
3
|
-
const bodyParser = require('body-parser');
|
|
4
|
-
const cors = require('cors');
|
|
5
|
-
const Boom = require('@hapi/boom');
|
|
6
|
-
const loadUserManager = require('./routers/middleware/loadUser');
|
|
7
|
-
const serverlessHttp = require('serverless-http');
|
|
8
|
-
|
|
9
|
-
const createApp = (applyMiddleware) => {
|
|
10
|
-
const app = express();
|
|
11
|
-
|
|
12
|
-
app.use(bodyParser.json({ limit: '10mb' }));
|
|
13
|
-
app.use(bodyParser.urlencoded({ extended: true }));
|
|
14
|
-
app.use(
|
|
15
|
-
cors({
|
|
16
|
-
origin: '*',
|
|
17
|
-
credentials: true,
|
|
18
|
-
})
|
|
19
|
-
);
|
|
20
|
-
|
|
21
|
-
app.use(loadUserManager);
|
|
22
|
-
|
|
23
|
-
if (applyMiddleware) applyMiddleware(app);
|
|
24
|
-
|
|
25
|
-
// Handle sending error response and logging server errors to console
|
|
26
|
-
app.use((err, req, res, next) => {
|
|
27
|
-
const boomError = err.isBoom ? err : Boom.boomify(err);
|
|
28
|
-
const {
|
|
29
|
-
output: { statusCode = 500 },
|
|
30
|
-
} = boomError;
|
|
31
|
-
|
|
32
|
-
if (statusCode >= 500) {
|
|
33
|
-
flushDebugLog(boomError);
|
|
34
|
-
res.status(statusCode).json({ error: 'Internal Server Error' });
|
|
35
|
-
} else {
|
|
36
|
-
res.status(statusCode).json({ error: err.message });
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
return app;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
function createAppHandler(eventName, router, shouldUseDatabase = true) {
|
|
44
|
-
const app = createApp((app) => {
|
|
45
|
-
app.use(router);
|
|
46
|
-
});
|
|
47
|
-
return createHandler({
|
|
48
|
-
eventName,
|
|
49
|
-
method: serverlessHttp(app),
|
|
50
|
-
shouldUseDatabase,
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
module.exports = {
|
|
55
|
-
createApp,
|
|
56
|
-
createAppHandler,
|
|
57
|
-
};
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
const { createFriggBackend, Worker } = require('@friggframework/core');
|
|
2
|
-
const {
|
|
3
|
-
findNearestBackendPackageJson,
|
|
4
|
-
} = require('../frigg-cli/utils/backend-path');
|
|
5
|
-
const path = require('node:path');
|
|
6
|
-
const fs = require('fs-extra');
|
|
7
|
-
|
|
8
|
-
const backendPath = findNearestBackendPackageJson();
|
|
9
|
-
if (!backendPath) {
|
|
10
|
-
throw new Error('Could not find backend package.json');
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const backendDir = path.dirname(backendPath);
|
|
14
|
-
const backendFilePath = path.join(backendDir, 'index.js');
|
|
15
|
-
if (!fs.existsSync(backendFilePath)) {
|
|
16
|
-
throw new Error('Could not find index.js');
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const backendJsFile = require(backendFilePath);
|
|
20
|
-
const { Router } = require('express');
|
|
21
|
-
const appDefinition = backendJsFile.Definition;
|
|
22
|
-
|
|
23
|
-
const backend = createFriggBackend(appDefinition);
|
|
24
|
-
const loadRouterFromObject = (IntegrationClass, routerObject) => {
|
|
25
|
-
const router = Router();
|
|
26
|
-
const { path, method, event } = routerObject;
|
|
27
|
-
console.log(
|
|
28
|
-
`Registering ${method} ${path} for ${IntegrationClass.Definition.name}`
|
|
29
|
-
);
|
|
30
|
-
router[method.toLowerCase()](path, async (req, res, next) => {
|
|
31
|
-
try {
|
|
32
|
-
const integration = new IntegrationClass({});
|
|
33
|
-
await integration.loadModules();
|
|
34
|
-
await integration.registerEventHandlers();
|
|
35
|
-
const result = await integration.send(event, {req, res, next});
|
|
36
|
-
res.json(result);
|
|
37
|
-
} catch (error) {
|
|
38
|
-
next(error);
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
return router;
|
|
43
|
-
};
|
|
44
|
-
const createQueueWorker = (integrationClass) => {
|
|
45
|
-
class QueueWorker extends Worker {
|
|
46
|
-
async _run(params, context) {
|
|
47
|
-
try {
|
|
48
|
-
let instance;
|
|
49
|
-
if (!params.integrationId) {
|
|
50
|
-
instance = new integrationClass({});
|
|
51
|
-
await instance.loadModules();
|
|
52
|
-
// await instance.loadUserActions();
|
|
53
|
-
await instance.registerEventHandlers();
|
|
54
|
-
console.log(
|
|
55
|
-
`${params.event} for ${integrationClass.Definition.name} integration with no integrationId`
|
|
56
|
-
);
|
|
57
|
-
} else {
|
|
58
|
-
instance =
|
|
59
|
-
await integrationClass.getInstanceFromIntegrationId({
|
|
60
|
-
integrationId: params.integrationId,
|
|
61
|
-
});
|
|
62
|
-
console.log(
|
|
63
|
-
`${params.event} for ${instance.integration.config.type} of integrationId: ${params.integrationId}`
|
|
64
|
-
);
|
|
65
|
-
}
|
|
66
|
-
const res = await instance.send(params.event, {
|
|
67
|
-
data: params.data,
|
|
68
|
-
context,
|
|
69
|
-
});
|
|
70
|
-
return res;
|
|
71
|
-
} catch (error) {
|
|
72
|
-
console.error(
|
|
73
|
-
`Error in ${params.event} for ${integrationClass.Definition.name}:`,
|
|
74
|
-
error
|
|
75
|
-
);
|
|
76
|
-
throw error;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
return QueueWorker;
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
module.exports = {
|
|
84
|
-
...backend,
|
|
85
|
-
loadRouterFromObject,
|
|
86
|
-
createQueueWorker,
|
|
87
|
-
};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
const { createIntegrationRouter } = require('@friggframework/core');
|
|
2
|
-
const { createAppHandler } = require('./../app-handler-helpers');
|
|
3
|
-
const { requireLoggedInUser } = require('./middleware/requireLoggedInUser');
|
|
4
|
-
const {
|
|
5
|
-
moduleFactory,
|
|
6
|
-
integrationFactory,
|
|
7
|
-
IntegrationHelper,
|
|
8
|
-
} = require('./../backend-utils');
|
|
9
|
-
|
|
10
|
-
const router = createIntegrationRouter({
|
|
11
|
-
factory: { moduleFactory, integrationFactory, IntegrationHelper },
|
|
12
|
-
requireLoggedInUser,
|
|
13
|
-
getUserId: (req) => req.user.getUserId(),
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
router.route('/redirect/:appId').get((req, res) => {
|
|
17
|
-
res.redirect(
|
|
18
|
-
`${process.env.FRONTEND_URI}/redirect/${
|
|
19
|
-
req.params.appId
|
|
20
|
-
}?${new URLSearchParams(req.query)}`
|
|
21
|
-
);
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
const handler = createAppHandler('HTTP Event: Auth', router);
|
|
25
|
-
|
|
26
|
-
module.exports = { handler, router };
|