@counterfact/client 0.2.0 → 0.2.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @counterfact/client
2
2
 
3
+ ## 0.2.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 96b565d: Add simulator.reset() to reconstruct stores, dependent contexts, source routes and startup state without restarting HTTP, and simulator.scenario(path, group?) to await named scenarios with the REPL arguments. Document request gating, reset failure recovery, reference lifetimes, and worker-scoped Playwright integration.
8
+
3
9
  ## 0.2.0
4
10
 
5
11
  ### Minor Changes
@@ -21,7 +21,7 @@ export interface RouteBuilderOptions {
21
21
  host?: string;
22
22
  method?: string;
23
23
  pathParams?: RouteParams;
24
- port: number;
24
+ port: number | (() => number);
25
25
  queryParams?: RouteParams;
26
26
  routeCatalog?: RouteCatalog;
27
27
  }
@@ -138,9 +138,9 @@ export declare class RouteBuilder {
138
138
  * given route path, pre-configured with the server's host, port, and OpenAPI
139
139
  * route catalog.
140
140
  *
141
- * @param port - The port the Counterfact server is listening on.
141
+ * @param port - The listening port, or a getter resolved when sending a request.
142
142
  * @param host - The server hostname (default `"localhost"`).
143
143
  * @param routeCatalog - Optional route catalog for parameter introspection.
144
144
  * @returns A function `(routePath: string) => RouteBuilder`.
145
145
  */
146
- export declare function createRouteFunction(port: number, host?: string, routeCatalog?: RouteCatalog): (routePath: string) => RouteBuilder;
146
+ export declare function createRouteFunction(port: number | (() => number), host?: string, routeCatalog?: RouteCatalog): (routePath: string) => RouteBuilder;
@@ -481,7 +481,8 @@ export class RouteBuilder {
481
481
  const qs = new URLSearchParams(queryEntries.map(([k, v]) => [k, String(v)])).toString();
482
482
  url = `${url}?${qs}`;
483
483
  }
484
- const client = new RawHttpClient(this._host, this._port);
484
+ const port = typeof this._port === "function" ? this._port() : this._port;
485
+ const client = new RawHttpClient(this._host, port);
485
486
  const headers = Object.fromEntries(Object.entries(this._headerParams).map(([k, v]) => [k, String(v)]));
486
487
  const cookiePairs = Object.entries(this._cookieParams).map(([name, value]) => `${encodeURIComponent(name)}=${encodeURIComponent(String(value))}`);
487
488
  if (cookiePairs.length > 0) {
@@ -610,7 +611,7 @@ export class RouteBuilder {
610
611
  * given route path, pre-configured with the server's host, port, and OpenAPI
611
612
  * route catalog.
612
613
  *
613
- * @param port - The port the Counterfact server is listening on.
614
+ * @param port - The listening port, or a getter resolved when sending a request.
614
615
  * @param host - The server hostname (default `"localhost"`).
615
616
  * @param routeCatalog - Optional route catalog for parameter introspection.
616
617
  * @returns A function `(routePath: string) => RouteBuilder`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@counterfact/client",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Build and send reusable OpenAPI-aware HTTP requests without starting Counterfact.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",