@gravitee/gamma-modules-sdk 1.0.0-alpha.2-feat-dev-mock-middleware.37cc1ee → 1.0.0-alpha.2-feat-dev-mock-middleware.89c1bf9
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/README.md +31 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -33,7 +33,7 @@ The SDK publishes three entry points:
|
|
|
33
33
|
| ----------------------------------- | ---------------------------- | ------------------------- |
|
|
34
34
|
| `@gravitee/gamma-modules-sdk` | Types + runtime stubs | Remotes (and host barrel) |
|
|
35
35
|
| `@gravitee/gamma-modules-sdk/types` | Interfaces only (no runtime) | Host implementation |
|
|
36
|
-
| `@gravitee/gamma-modules-sdk/dev` | OpenAPI mock middleware
|
|
36
|
+
| `@gravitee/gamma-modules-sdk/dev` | OpenAPI mock middleware | Module dev servers |
|
|
37
37
|
|
|
38
38
|
Remote modules compile and bundle against the stubs. At runtime, the host provides its real implementation as a Module Federation singleton (`additionalShared`), replacing the stubs transparently.
|
|
39
39
|
|
|
@@ -108,6 +108,36 @@ Handles GET list (pagination, `?q=` search), GET by ID, sub-resource filtering,
|
|
|
108
108
|
|
|
109
109
|
Fixture files are named after the last path segment in the spec (e.g. `models.json`, `mcp-servers.json`).
|
|
110
110
|
|
|
111
|
+
#### Setting up standalone dev mode for a new module
|
|
112
|
+
|
|
113
|
+
1. Add `public/constants.json` with `{ "gammaBaseURL": "/gamma" }`
|
|
114
|
+
2. Write your OpenAPI spec (or copy from an existing module)
|
|
115
|
+
3. Add fixture JSON files matching your spec paths (e.g. `models.json` for `/catalog/models`)
|
|
116
|
+
4. In `rsbuild.config.ts`:
|
|
117
|
+
|
|
118
|
+
```typescript
|
|
119
|
+
import { createOpenApiMockMiddleware } from '@gravitee/gamma-modules-sdk/dev';
|
|
120
|
+
|
|
121
|
+
export default defineConfig(() => ({
|
|
122
|
+
dev: {
|
|
123
|
+
setupMiddlewares: [
|
|
124
|
+
(middlewares) => {
|
|
125
|
+
middlewares.unshift(
|
|
126
|
+
createOpenApiMockMiddleware({
|
|
127
|
+
moduleId: 'your-module',
|
|
128
|
+
specs: [join(__dirname, 'path/to/openapi.yaml')],
|
|
129
|
+
fixturesDir: join(__dirname, 'path/to/fixtures'),
|
|
130
|
+
}),
|
|
131
|
+
);
|
|
132
|
+
return middlewares;
|
|
133
|
+
},
|
|
134
|
+
],
|
|
135
|
+
},
|
|
136
|
+
}));
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
5. Run `yarn serve` and open http://localhost:3002
|
|
140
|
+
|
|
111
141
|
### Permissions domain
|
|
112
142
|
|
|
113
143
|
**Types**: `PermissionScope`, `PermissionCheck`, `UserRole`, `PermissionGateProps`, `UseHasPermissionOptions`
|
package/package.json
CHANGED