@warp-drive/holodeck 0.1.0-alpha.64 → 0.1.0-alpha.65
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/dist/index.d.ts +56 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +154 -210
- package/dist/index.js.map +1 -0
- package/dist/mock.d.ts +89 -0
- package/dist/mock.d.ts.map +1 -0
- package/dist/mock.js +179 -133
- package/dist/mock.js.map +1 -0
- package/package.json +15 -16
- package/server/bun.js +12 -9
- package/server/node.js +20 -17
- package/server/utils.js +55 -0
- package/declarations/index.d.ts +0 -52
- package/declarations/mock.d.ts +0 -85
package/declarations/mock.d.ts
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @public
|
|
3
|
-
*/
|
|
4
|
-
export interface Scaffold {
|
|
5
|
-
status: number;
|
|
6
|
-
statusText?: string;
|
|
7
|
-
headers: Record<string, string>;
|
|
8
|
-
body: Record<string, string> | string | null;
|
|
9
|
-
method: string;
|
|
10
|
-
url: string;
|
|
11
|
-
response: Record<string, unknown>;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* @public
|
|
15
|
-
*/
|
|
16
|
-
export type ScaffoldGenerator = () => Scaffold;
|
|
17
|
-
/**
|
|
18
|
-
* @public
|
|
19
|
-
*/
|
|
20
|
-
export type ResponseGenerator = () => Record<string, unknown>;
|
|
21
|
-
/**
|
|
22
|
-
* Sets up Mocking for a GET request on the mock server
|
|
23
|
-
* for the supplied url.
|
|
24
|
-
*
|
|
25
|
-
* The response body is generated by the supplied response function.
|
|
26
|
-
*
|
|
27
|
-
* Available options:
|
|
28
|
-
* - status: the status code to return (default: 200)
|
|
29
|
-
* - headers: the headers to return (default: {})
|
|
30
|
-
* - body: the body to match against for the request (default: null)
|
|
31
|
-
* - RECORD: whether to record the request (default: false)
|
|
32
|
-
*
|
|
33
|
-
* @param url the url to mock, relative to the mock server host (e.g. `users/1`)
|
|
34
|
-
* @param response a function which generates the response to return
|
|
35
|
-
* @param options status, headers for the response, body to match against for the request, and whether to record the request
|
|
36
|
-
* @return
|
|
37
|
-
*/
|
|
38
|
-
export declare function GET(owner: object, url: string, response: ResponseGenerator, options?: Partial<Omit<Scaffold, "response" | "url" | "method">> & {
|
|
39
|
-
RECORD?: boolean;
|
|
40
|
-
}): Promise<void>;
|
|
41
|
-
/**
|
|
42
|
-
* Mock a POST request
|
|
43
|
-
*/
|
|
44
|
-
export declare function POST(owner: object, url: string, response: ResponseGenerator, options?: Partial<Omit<Scaffold, "response" | "url" | "method">> & {
|
|
45
|
-
RECORD?: boolean;
|
|
46
|
-
}): Promise<void>;
|
|
47
|
-
/**
|
|
48
|
-
* mock a PUT request
|
|
49
|
-
*/
|
|
50
|
-
export declare function PUT(owner: object, url: string, response: ResponseGenerator, options?: Partial<Omit<Scaffold, "response" | "url" | "method">> & {
|
|
51
|
-
RECORD?: boolean;
|
|
52
|
-
}): Promise<void>;
|
|
53
|
-
/**
|
|
54
|
-
* mock a PATCH request
|
|
55
|
-
*
|
|
56
|
-
*/
|
|
57
|
-
export declare function PATCH(owner: object, url: string, response: ResponseGenerator, options?: Partial<Omit<Scaffold, "response" | "url" | "method">> & {
|
|
58
|
-
RECORD?: boolean;
|
|
59
|
-
}): Promise<void>;
|
|
60
|
-
/**
|
|
61
|
-
* mock a DELETE request
|
|
62
|
-
*/
|
|
63
|
-
export declare function DELETE(owner: object, url: string, response: ResponseGenerator, options?: Partial<Omit<Scaffold, "response" | "url" | "method">> & {
|
|
64
|
-
RECORD?: boolean;
|
|
65
|
-
}): Promise<void>;
|
|
66
|
-
/**
|
|
67
|
-
* Sets up Mocking for a HEAD request on the mock server
|
|
68
|
-
* for the supplied url.
|
|
69
|
-
*
|
|
70
|
-
* The response body is generated by the supplied response function.
|
|
71
|
-
*
|
|
72
|
-
* Available options:
|
|
73
|
-
* - status: the status code to return (default: 200)
|
|
74
|
-
* - headers: the headers to return (default: {})
|
|
75
|
-
* - body: the body to match against for the request (default: null)
|
|
76
|
-
* - RECORD: whether to record the request (default: false)
|
|
77
|
-
*
|
|
78
|
-
* @param url the url to mock, relative to the mock server host (e.g. `users/1`)
|
|
79
|
-
* @param response a function which generates the response to return
|
|
80
|
-
* @param options status, headers for the response, body to match against for the request, and whether to record the request
|
|
81
|
-
* @return
|
|
82
|
-
*/
|
|
83
|
-
export declare function HEAD(owner: object, url: string, response: ResponseGenerator, options?: Partial<Omit<Scaffold, "response" | "url" | "method">> & {
|
|
84
|
-
RECORD?: boolean;
|
|
85
|
-
}): Promise<void>;
|