|
1 | 1 | # counterfact |
2 | 2 |
|
| 3 | +## 2.9.0 |
| 4 | + |
| 5 | +### Minor Changes |
| 6 | + |
| 7 | +- ffc7d53: Add `ApiRunner` class in `src/api-runner.ts` that encapsulates the creation and lifecycle management of all Counterfact sub-systems (Registry, ContextRegistry, ScenarioRegistry, ScenarioFileGenerator, CodeGenerator, Dispatcher, Transpiler, ModuleLoader, and OpenApiDocument) for a single API specification. |
| 8 | + |
| 9 | + Each sub-system is exposed as a public property. The class provides four composite methods — `generate()`, `load()`, `watch()`, and `stopWatching()` — that coordinate across multiple sub-systems based on the supplied configuration. Use the static async `ApiRunner.create(config)` factory method to construct an instance. |
| 10 | + |
| 11 | + `counterfact()` in `app.ts` now uses `ApiRunner` internally. |
| 12 | + |
| 13 | +- a6bb5bc: Add support for multiple API specifications via `ApiRunner`. |
| 14 | + - `ApiRunner.create(config, group?)` now accepts an optional `group` string (default `""`) that places generated code in a subdirectory of `config.basePath`. |
| 15 | + - `ApiRunner` exposes `group` as a public readonly property and `subdirectory` as a computed getter (returns `""` when group is empty, or `"/${group}"`). |
| 16 | + - `CodeGenerator` receives `config.basePath + runner.subdirectory` so each spec's generated files land in the right subdirectory. |
| 17 | + - `createKoaApp` now accepts `runners: ApiRunner[]` (an array) instead of a single `runner`. It loops over all runners to mount per-spec OpenAPI document, Swagger UI, Admin API, and route-dispatching middleware. |
| 18 | + - `counterfact()` accepts an optional `specs: SpecConfig[]` second argument (each entry has `source`, `prefix`, and `group`). When omitted, a single spec is derived from `config.openApiPath` and `config.prefix` for full backward compatibility. The REPL is configured using the first spec's runner. |
| 19 | + - The `spec` key in `counterfact.yaml` can now be a single `{source, prefix, group}` object or an array of such objects to configure multiple APIs from the config file. |
| 20 | + |
| 21 | +- 26e00eb: Add `openApiPath` and `prefix` as public readonly properties on `ApiRunner`. |
| 22 | + |
| 23 | + Refactor `createKoaApp` to accept `runner: ApiRunner` (providing the dispatcher, registry, context registry, OpenAPI path, and route prefix) instead of a `config: Config` monolith plus separate sub-system refs. All other config fields used by `createKoaApp` are now explicit named arguments, laying the groundwork for passing multiple runners to `createKoaApp` in the future. |
| 24 | + |
| 25 | +### Patch Changes |
| 26 | + |
| 27 | +- d0dff90: Warn and skip loading context modules when they fail to import, including syntax errors in \_.context files. |
| 28 | +- 75938e3: Prefer OpenAPI route paths for REPL tab completion and refactor completer lookups into focused helpers. |
| 29 | +- 7a8c0b6: Move MSW (Mock Service Worker) code out of `app.ts` into a dedicated `src/msw.ts` module. The `MockRequest` type, `handleMswRequest`, and `createMswHandlers` are still re-exported from `app.ts` for backward compatibility. Tests for these functions have been moved to `test/msw.test.ts`. |
| 30 | +- 4894f18: Organized Koa middleware into a dedicated `src/server/web-server/` directory. Each middleware constructor now takes its path prefix as the first argument, making `createKoaApp` easier to read at a glance. `openapiMiddleware` simplified to handle a single path only. |
| 31 | +- 3aa8416: Expose grouped REPL context and routes for multi-API runners, and require non-empty unique group names when configuring multiple APIs. |
| 32 | +- b270516: Move CLI logic from bin/counterfact.js into src/cli/ as TypeScript modules |
| 33 | + |
3 | 34 | ## 2.8.1 |
4 | 35 |
|
5 | 36 | ### Patch Changes |
|
0 commit comments