Merged
Conversation
e03c4b5 to
0893624
Compare
0893624 to
0119e62
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR was opened by the Changesets release GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated.
Releases
counterfact@2.9.0
Minor Changes
ffc7d53: Add
ApiRunnerclass insrc/api-runner.tsthat 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.Each sub-system is exposed as a public property. The class provides four composite methods —
generate(),load(),watch(), andstopWatching()— that coordinate across multiple sub-systems based on the supplied configuration. Use the static asyncApiRunner.create(config)factory method to construct an instance.counterfact()inapp.tsnow usesApiRunnerinternally.a6bb5bc: Add support for multiple API specifications via
ApiRunner.ApiRunner.create(config, group?)now accepts an optionalgroupstring (default"") that places generated code in a subdirectory ofconfig.basePath.ApiRunnerexposesgroupas a public readonly property andsubdirectoryas a computed getter (returns""when group is empty, or"/${group}").CodeGeneratorreceivesconfig.basePath + runner.subdirectoryso each spec's generated files land in the right subdirectory.createKoaAppnow acceptsrunners: ApiRunner[](an array) instead of a singlerunner. It loops over all runners to mount per-spec OpenAPI document, Swagger UI, Admin API, and route-dispatching middleware.counterfact()accepts an optionalspecs: SpecConfig[]second argument (each entry hassource,prefix, andgroup). When omitted, a single spec is derived fromconfig.openApiPathandconfig.prefixfor full backward compatibility. The REPL is configured using the first spec's runner.speckey incounterfact.yamlcan now be a single{source, prefix, group}object or an array of such objects to configure multiple APIs from the config file.26e00eb: Add
openApiPathandprefixas public readonly properties onApiRunner.Refactor
createKoaAppto acceptrunner: ApiRunner(providing the dispatcher, registry, context registry, OpenAPI path, and route prefix) instead of aconfig: Configmonolith plus separate sub-system refs. All other config fields used bycreateKoaAppare now explicit named arguments, laying the groundwork for passing multiple runners tocreateKoaAppin the future.Patch Changes
.scenario <group> <path>in multi-API REPL sessions while preserving single-runner syntax.app.tsinto a dedicatedsrc/msw.tsmodule. TheMockRequesttype,handleMswRequest, andcreateMswHandlersare still re-exported fromapp.tsfor backward compatibility. Tests for these functions have been moved totest/msw.test.ts.src/server/web-server/directory. Each middleware constructor now takes its path prefix as the first argument, makingcreateKoaAppeasier to read at a glance.openapiMiddlewaresimplified to handle a single path only..scenariotab completion to suggest groups first in multi-API mode and group-scoped scenarios after selection.