@gravitee/gamma-modules-sdk 1.0.0-alpha.2-feat-dev-mock-middleware.c567ce0 → 1.0.0-alpha.2-feat-dev-mock-middleware.9ea8d98

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/dist/dev.d.ts CHANGED
@@ -1,36 +1,38 @@
1
1
  import { IncomingMessage, ServerResponse } from 'http';
2
- export interface DevMockMiddlewareOptions {
2
+ export interface OpenApiMockOptions {
3
3
  /** Gamma module identifier (e.g. "aim"). */
4
4
  moduleId: string;
5
- /** Absolute path to the directory containing fixture JSON files. */
5
+ /** Paths to OpenAPI spec files (YAML or JSON). */
6
+ specs: string[];
7
+ /** Optional directory with fixture JSON files named after the last path segment (e.g. models.json). */
8
+ fixturesDir?: string;
9
+ orgId?: string;
10
+ envId?: string;
11
+ }
12
+ /** @deprecated Use createOpenApiMockMiddleware instead. */
13
+ export interface DevMockMiddlewareOptions {
14
+ moduleId: string;
6
15
  fixturesDir: string;
7
- /**
8
- * Map of route suffixes to fixture file names.
9
- * The key is the path after `/catalog` (e.g. "/models"), the value is the fixture filename.
10
- */
11
16
  routes: Record<string, string>;
12
- /** Organization ID for the mock context. Defaults to "DEFAULT". */
13
17
  orgId?: string;
14
- /** Environment ID for the mock context. Defaults to "DEFAULT". */
15
18
  envId?: string;
16
19
  }
17
20
  /**
18
- * Creates a Connect-compatible middleware that mocks the Gamma bootstrap endpoint
19
- * and serves fixture data for catalog-style APIs. Intended for standalone dev mode
20
- * (`rsbuild dev` / `vite dev`) so modules can run without a backend.
21
+ * Creates a Connect-compatible middleware that reads OpenAPI specs and serves
22
+ * mock responses for all declared paths. Fixtures override spec examples.
21
23
  *
22
24
  * Usage in rsbuild.config.ts:
23
25
  * ```ts
24
- * import { createDevMockMiddleware } from '@gravitee/gamma-modules-sdk/dev';
26
+ * import { createOpenApiMockMiddleware } from '@gravitee/gamma-modules-sdk/dev';
25
27
  *
26
- * setupMiddlewares: [(mw) => mw.unshift(createDevMockMiddleware({
28
+ * setupMiddlewares: [(mw) => mw.unshift(createOpenApiMockMiddleware({
27
29
  * moduleId: 'aim',
30
+ * specs: [join(__dirname, 'src/main/resources/openapi/openapi-catalog.yaml')],
28
31
  * fixturesDir: join(__dirname, 'src/main/resources/catalog-fixtures'),
29
- * routes: { '/models': 'models.json', '/mcp-servers': 'mcp-servers.json' },
30
32
  * }))]
31
33
  * ```
32
- *
33
- * Requires a `public/constants.json` with `{ "gammaBaseURL": "/gamma" }` in the module root.
34
34
  */
35
+ export declare function createOpenApiMockMiddleware(options: OpenApiMockOptions): (req: IncomingMessage, res: ServerResponse, next: () => void) => void;
36
+ /** @deprecated Use createOpenApiMockMiddleware instead. */
35
37
  export declare function createDevMockMiddleware(options: DevMockMiddlewareOptions): (req: IncomingMessage, res: ServerResponse, next: () => void) => void;
36
38
  //# sourceMappingURL=dev.d.ts.map
package/dist/dev.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../src/dev.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAG5D,MAAM,WAAW,wBAAwB;IACvC,4CAA4C;IAC5C,QAAQ,EAAE,MAAM,CAAC;IACjB,oEAAoE;IACpE,WAAW,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,mEAAmE;IACnE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,kEAAkE;IAClE,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAeD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,wBAAwB,IAI/D,KAAK,eAAe,EAAE,KAAK,cAAc,EAAE,MAAM,MAAM,IAAI,UAsDpE"}
1
+ {"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../src/dev.ts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