@counterfact/client 0.2.0 → 0.2.2
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 +12 -0
- package/dist/route-builder.d.ts +3 -3
- package/dist/route-builder.js +6 -3
- package/dist/route-catalog.js +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @counterfact/client
|
|
2
2
|
|
|
3
|
+
## 0.2.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 0d35a14: Handle prototype-named cookie/query inputs as ordinary own data properties, preserve unchanged context initializers containing an own `__proto__` key, and ignore inherited names when completing scenario groups.
|
|
8
|
+
|
|
9
|
+
## 0.2.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 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.
|
|
14
|
+
|
|
3
15
|
## 0.2.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
package/dist/route-builder.d.ts
CHANGED
|
@@ -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
|
|
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;
|
package/dist/route-builder.js
CHANGED
|
@@ -190,6 +190,7 @@ export class RouteBuilder {
|
|
|
190
190
|
}
|
|
191
191
|
getHeaderValue(name) {
|
|
192
192
|
const key = findHeaderKey(this._headerParams, name);
|
|
193
|
+
// eslint-disable-next-line security/detect-object-injection -- key comes from own header enumeration; arbitrary header names are supported.
|
|
193
194
|
return key === undefined ? undefined : this._headerParams[key];
|
|
194
195
|
}
|
|
195
196
|
getHeaderCookies() {
|
|
@@ -208,7 +209,8 @@ export class RouteBuilder {
|
|
|
208
209
|
return cookies;
|
|
209
210
|
}
|
|
210
211
|
getCookieValue(name) {
|
|
211
|
-
if (
|
|
212
|
+
if (Object.hasOwn(this._cookieParams, name))
|
|
213
|
+
// eslint-disable-next-line security/detect-object-injection -- The own-property check above limits this read to explicitly supplied cookie parameters.
|
|
212
214
|
return this._cookieParams[name];
|
|
213
215
|
return this.getHeaderCookies().get(name);
|
|
214
216
|
}
|
|
@@ -481,7 +483,8 @@ export class RouteBuilder {
|
|
|
481
483
|
const qs = new URLSearchParams(queryEntries.map(([k, v]) => [k, String(v)])).toString();
|
|
482
484
|
url = `${url}?${qs}`;
|
|
483
485
|
}
|
|
484
|
-
const
|
|
486
|
+
const port = typeof this._port === "function" ? this._port() : this._port;
|
|
487
|
+
const client = new RawHttpClient(this._host, port);
|
|
485
488
|
const headers = Object.fromEntries(Object.entries(this._headerParams).map(([k, v]) => [k, String(v)]));
|
|
486
489
|
const cookiePairs = Object.entries(this._cookieParams).map(([name, value]) => `${encodeURIComponent(name)}=${encodeURIComponent(String(value))}`);
|
|
487
490
|
if (cookiePairs.length > 0) {
|
|
@@ -610,7 +613,7 @@ export class RouteBuilder {
|
|
|
610
613
|
* given route path, pre-configured with the server's host, port, and OpenAPI
|
|
611
614
|
* route catalog.
|
|
612
615
|
*
|
|
613
|
-
* @param port - The port
|
|
616
|
+
* @param port - The listening port, or a getter resolved when sending a request.
|
|
614
617
|
* @param host - The server hostname (default `"localhost"`).
|
|
615
618
|
* @param routeCatalog - Optional route catalog for parameter introspection.
|
|
616
619
|
* @returns A function `(routePath: string) => RouteBuilder`.
|
package/dist/route-catalog.js
CHANGED
|
@@ -23,11 +23,11 @@ export function createOpenApiRouteCatalog(document) {
|
|
|
23
23
|
return {
|
|
24
24
|
getOperation(routePath, method) {
|
|
25
25
|
const normalizedPath = routePath.toLowerCase();
|
|
26
|
-
const matchingPath = Object.
|
|
26
|
+
const matchingPath = Object.entries(document.paths).find(([path]) => path.toLowerCase() === normalizedPath);
|
|
27
27
|
if (matchingPath === undefined) {
|
|
28
28
|
return undefined;
|
|
29
29
|
}
|
|
30
|
-
const pathItem =
|
|
30
|
+
const pathItem = matchingPath[1];
|
|
31
31
|
const operation = pathItem?.[method.toLowerCase()];
|
|
32
32
|
if (!operation) {
|
|
33
33
|
return undefined;
|