@equinor/fusion-framework-cli 15.2.11-next.0 → 15.3.0-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/README.md +9 -0
  3. package/bin/build/bin.mjs +1 -1
  4. package/bin/build/cli.mjs +3 -3
  5. package/dist/esm/version.js +1 -1
  6. package/dist/types/bin/serve-application.d.ts +4 -0
  7. package/dist/types/bin/start-app-dev-server.d.ts +6 -1
  8. package/dist/types/bin/utils/__tests__/fixtures/dev-mocks/foo.mock.d.ts +6 -0
  9. package/dist/types/bin/utils/__tests__/fixtures/dev-mocks/service.mock.d.ts +6 -0
  10. package/dist/types/bin/utils/apply-dev-server-mocks.d.ts +12 -0
  11. package/dist/types/bin/utils/apply-dev-server-mocks.test.d.ts +1 -0
  12. package/dist/types/bin/utils/create-dev-server-config.d.ts +3 -1
  13. package/dist/types/bin/utils/create-dev-server-config.test.d.ts +1 -0
  14. package/dist/types/bin/utils/discover-dev-server-mocks.d.ts +20 -0
  15. package/dist/types/bin/utils/discover-dev-server-mocks.test.d.ts +1 -0
  16. package/dist/types/bin/utils/normalize-dev-server-config.d.ts +2 -0
  17. package/dist/types/cli/commands/app/dev.command.d.ts +4 -1
  18. package/dist/types/cli/commands/app/dev.command.test.d.ts +1 -0
  19. package/dist/types/cli/commands/app/serve.command.d.ts +1 -0
  20. package/dist/types/cli/commands/index.d.ts +5 -3
  21. package/dist/types/cli/commands/portal/dev.command.d.ts +1 -1
  22. package/dist/types/cli/commands/register-optional-mock-server-command.d.ts +13 -0
  23. package/dist/types/cli/commands/register-optional-mock-server-command.test.d.ts +1 -0
  24. package/dist/types/cli/plugins/is-module-not-found-error.d.ts +8 -0
  25. package/dist/types/cli/plugins/is-module-not-found-error.test.d.ts +1 -0
  26. package/dist/types/cli/plugins/resolve-optional-plugin.d.ts +14 -0
  27. package/dist/types/cli/plugins/resolve-optional-plugin.test.d.ts +1 -0
  28. package/dist/types/version.d.ts +1 -1
  29. package/docs/application.md +17 -1
  30. package/docs/dev-server-config.md +132 -112
  31. package/docs/dev-server.md +39 -50
  32. package/package.json +6 -5
@@ -12,7 +12,7 @@ The Fusion Framework dev-server is your complete local development solution for
12
12
 
13
13
  🛠️ **Flexible Configuration** - Easy setup for both applications and portals with environment-specific overrides
14
14
 
15
- 📝 **Configurable Development** - Optional `dev-server.config.ts` file for API mocking, service discovery customization, and environment variable overrides
15
+ 📝 **Executable Service Mocks** - Reusable `mocks/<service>.mock.ts` modules for local development and browser tests
16
16
 
17
17
  ## Quick Start
18
18
 
@@ -30,11 +30,17 @@ The dev-server automatically detects your project type, loads configuration file
30
30
 
31
31
  For detailed information about configuring the dev-server, see [Dev Server Configuration](dev-server-config.md).
32
32
 
33
- The dev-server automatically loads configuration from a `dev-server.config.ts` file in your project root, allowing you to customize API mocking, service discovery, and development environment settings without modifying your application code.
33
+ The dev server automatically discovers executable `mocks/<service>.mock.ts` modules. Define service
34
+ behavior there with `defineService`, run `ffc mock-server` in a foreground terminal, and use
35
+ `ffc app dev` for real discovery plus local overrides or `ffc app dev --mock` for an isolated mock
36
+ environment. See [Develop with mock services](../../dev-server/docs/mocking.md).
37
+
38
+ Use `dev-server.config.ts` for SPA environment values, logging, discovery endpoints, and shared
39
+ mock-server defaults. It is not the recommended place to handwrite service routes.
34
40
 
35
41
  ## Key Features
36
42
 
37
- - **Service Discovery Integration** - Automatically connects to Fusion service discovery and enables local API mocking
43
+ - **Service Discovery Integration** - Connects to real discovery and overlays visible executable mock modules by service key
38
44
  - **Template Generation** - Dynamic HTML template generation with environment variable injection
39
45
  - **API Proxying** - Seamless API integration with request/response transformation capabilities
40
46
  - **Portal Support** - Full portal development with manifest loading and configuration management
@@ -92,7 +98,7 @@ flowchart TD
92
98
  - **Role**: API service discovery and request handling
93
99
  - **Responsibilities**:
94
100
  - Proxies requests to Fusion service discovery endpoints
95
- - Enables local API mocking and development overrides
101
+ - Proxies discovered services and advanced server-owned development routes
96
102
  - Manages dynamic route mapping for discovered services
97
103
  - Provides request/response transformation capabilities
98
104
 
@@ -156,7 +162,9 @@ This workflow ensures that developers have immediate access to a fully functiona
156
162
 
157
163
  ## Service Discovery
158
164
 
159
- The API plugin (`@equinor/fusion-framework-vite-plugin-api-service`) acts as an intelligent proxy that intercepts and enriches service discovery requests, enabling flexible service integration and local development capabilities. This plugin transforms the development server into a sophisticated service gateway that can dynamically modify service endpoints, inject mock services, and provide seamless integration between local development and production services.
165
+ The API plugin (`@equinor/fusion-framework-vite-plugin-api-service`) proxies discovered services
166
+ through the local origin. During normal app development, the CLI overlays discovery-visible
167
+ `mocks/<service>.mock.ts` definitions by key before the API plugin creates those proxy routes.
160
168
 
161
169
  ### Service Discovery Sequence
162
170
 
@@ -180,59 +188,40 @@ sequenceDiagram
180
188
  2. **Plugin Interception**: The API plugin intercepts this request before it reaches the external service
181
189
  3. **Proxy to Fusion**: The plugin forwards the request to the actual Fusion service discovery endpoint
182
190
  4. **Response Interception**: When the response returns, the plugin intercepts it before sending it back to the user
183
- 5. **Service Enrichment**: The plugin enriches the response by:
184
- - Adding mock services for local development
185
- - Altering service endpoints for testing
186
- - Injecting additional metadata or configuration
187
- - Modifying service capabilities or scopes
188
- 6. **Enhanced Response**: The user receives an enriched list of services that may include both real and mock services
189
-
190
- ## Mocking
191
+ 5. **Service Processing**: The plugin rewrites service URIs to local proxy routes.
192
+ 6. **Response**: The browser receives the processed service list and calls back through the dev server.
191
193
 
192
- The API plugin implements a **middleware pattern** that creates dynamic processing routes for mocking API responses during development. While these middleware routes can handle various request processing tasks, their primary purpose is to provide mock data when backend services aren't available or when you need to test specific scenarios without hitting real APIs.
194
+ ## Mocking services
193
195
 
194
- ```mermaid
195
- sequenceDiagram
196
- participant DevServer as Dev Server
197
- participant Middleware as Middleware
198
- participant MockData as Mock Data
199
- participant Browser
196
+ Application mocks are executable service modules, not dev-server middleware declarations:
200
197
 
201
- DevServer->>Middleware: Initialize middleware stack
202
-
203
- Browser->>DevServer: Execute API request
204
- DevServer->>Middleware: Route through middleware
205
- Middleware->>Middleware: Process request
206
- Middleware->>MockData: Fetch mock data
207
- MockData->>Middleware: Return mock response
208
- Middleware->>DevServer: Return processed response
209
- DevServer->>Browser: Return mock data
198
+ ```text
199
+ mocks/
200
+ inventory.mock.ts
201
+ inventory.openapi.json
210
202
  ```
211
203
 
212
- 1. **Middleware Initialization**: The dev-server initializes the middleware stack with configured routes and processing rules
213
- 2. **Request Interception**: API requests from the browser are routed through the middleware layer
214
- 3. **Request Processing**: The middleware processes the request according to its configured rules and logic
215
- 4. **Data Resolution**: The middleware fetches appropriate data (mock or real) based on the request and configuration
216
- 5. **Response Processing**: The middleware processes and transforms the response before returning it
217
- 6. **Response Delivery**: The processed response is returned to the browser through the dev-server
204
+ `defineService` keeps the service key, discovery intent, OpenAPI schema, deterministic component
205
+ values, operation routes, and request-aware middleware together. The same module works in local
206
+ development and browser tests.
218
207
 
219
- #### Usage Example
208
+ ```mermaid
209
+ flowchart LR
210
+ A["mocks/inventory.mock.ts"] --> B["ffc mock-server"]
211
+ B --> C["inventory.localhost:4010"]
212
+ B --> D["/@fusion-mock/discovery"]
213
+ E["ffc app dev"] --> F["real discovery + visible local modules"]
214
+ G["ffc app dev --mock"] --> H["preset + local modules only"]
215
+ F --> C
216
+ H --> C
217
+ ```
220
218
 
221
- ```typescript
222
- import type { MiddlewareRoute } from '@equinor/fusion-framework-vite-plugin-api-service';
219
+ The mock server is a standalone foreground process and never fetches remote discovery. Plain
220
+ `ffc app dev` still uses real discovery and overlays visible local definitions. `ffc app dev
221
+ --mock` points discovery at the standalone server and is intentionally isolated.
223
222
 
224
- const mockDataRoute: MiddlewareRoute = {
225
- match: '/api/users',
226
- middleware: (req, res, next) => {
227
- // Return mock data for users endpoint
228
- res.setHeader('Content-Type', 'application/json');
229
- res.end(JSON.stringify([
230
- { id: 1, name: 'John Doe' },
231
- { id: 2, name: 'Jane Smith' }
232
- ]));
233
- }
234
- };
235
- ```
223
+ See [Develop with mock services](../../dev-server/docs/mocking.md) for a copyable module and
224
+ discovery-mode guidance.
236
225
 
237
226
  ## Re-Routing requests
238
227
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@equinor/fusion-framework-cli",
3
- "version": "15.2.11-next.0",
3
+ "version": "15.3.0-next.1",
4
4
  "keywords": [
5
5
  "Fusion",
6
6
  "Fusion Framework",
@@ -111,11 +111,11 @@
111
111
  "vite": "^8.0.0",
112
112
  "vite-tsconfig-paths": "^6.0.4",
113
113
  "zod": "^4.4.3",
114
- "@equinor/fusion-framework-dev-portal": "11.0.3-next.0",
115
- "@equinor/fusion-framework-dev-server": "2.0.19-next.1",
114
+ "@equinor/fusion-framework-dev-portal": "11.0.3-next.1",
115
+ "@equinor/fusion-framework-dev-server": "2.1.0-next.2",
116
116
  "@equinor/fusion-framework-module-azure-identity": "0.3.0-next.0",
117
- "@equinor/fusion-imports": "2.0.3-next.0",
118
- "@equinor/fusion-framework-vite-plugin-raw-imports": "2.0.2-next.0"
117
+ "@equinor/fusion-framework-vite-plugin-raw-imports": "2.0.2-next.0",
118
+ "@equinor/fusion-imports": "2.0.3-next.1"
119
119
  },
120
120
  "devDependencies": {
121
121
  "@rollup/plugin-commonjs": "^29.0.0",
@@ -137,6 +137,7 @@
137
137
  "type-fest": "^5.0.0",
138
138
  "typescript": "^7.0.2",
139
139
  "vitest": "^4.1.10",
140
+ "@equinor/fusion-framework-cli-plugin-mock-server": "^0.1.0-next.1",
140
141
  "@equinor/fusion-framework-module": "6.1.3-next.0",
141
142
  "@equinor/fusion-framework-module-app": "8.0.6-next.0",
142
143
  "@equinor/fusion-framework-module-http": "8.1.0-next.0",