shelving 1.185.0 → 1.185.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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { AnyCaller } from "../../util/function.js";
|
|
2
2
|
import type { RequestHandler, RequestOptions } from "../../util/http.js";
|
|
3
3
|
import type { AnyEndpoint, Endpoint } from "../endpoint/Endpoint.js";
|
|
4
|
-
import {
|
|
4
|
+
import type { APIProvider } from "./APIProvider.js";
|
|
5
5
|
import { ThroughAPIProvider } from "./ThroughAPIProvider.js";
|
|
6
6
|
export type MockAPIFetchCall = {
|
|
7
7
|
readonly request: Request;
|
|
@@ -28,7 +28,7 @@ export declare class MockAPIProvider<P = unknown, R = unknown> extends ThroughAP
|
|
|
28
28
|
readonly fetchCalls: MockAPIFetchCall[];
|
|
29
29
|
readonly responseCalls: MockAPIResponseCall[];
|
|
30
30
|
readonly handler: RequestHandler;
|
|
31
|
-
constructor(handler?: RequestHandler, source?:
|
|
31
|
+
constructor(handler?: RequestHandler, source?: APIProvider<P, R>);
|
|
32
32
|
getRequest<PP extends P, RR extends R>(endpoint: Endpoint<PP, RR>, payload: PP, options?: RequestOptions, caller?: AnyCaller): Request;
|
|
33
33
|
parseResponse<PP extends P, RR extends R>(endpoint: Endpoint<PP, RR>, response: Response, caller?: AnyCaller): Promise<RR>;
|
|
34
34
|
fetch(request: Request): Promise<Response>;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { debugRequest } from "../../util/debug.js";
|
|
1
2
|
import { ClientAPIProvider } from "./ClientAPIProvider.js";
|
|
2
3
|
import { ThroughAPIProvider } from "./ThroughAPIProvider.js";
|
|
3
4
|
/** Default handler just echoes back the input request as text. */
|
|
4
|
-
async function
|
|
5
|
-
return new Response(
|
|
5
|
+
async function _mockHandler(request) {
|
|
6
|
+
return new Response(`Mocked response to ${debugRequest(request)}`, { status: 200, statusText: "OK" });
|
|
6
7
|
}
|
|
7
8
|
/**
|
|
8
9
|
* Provider that logs API calls without sending network requests.
|
|
@@ -14,7 +15,7 @@ export class MockAPIProvider extends ThroughAPIProvider {
|
|
|
14
15
|
fetchCalls = [];
|
|
15
16
|
responseCalls = [];
|
|
16
17
|
handler;
|
|
17
|
-
constructor(handler =
|
|
18
|
+
constructor(handler = _mockHandler, source = new ClientAPIProvider({ url: "https://api.mock.com" })) {
|
|
18
19
|
super(source);
|
|
19
20
|
this.handler = handler;
|
|
20
21
|
}
|