msw 2.1.5 → 2.1.6
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/lib/core/{GraphQLHandler-rZ7XkeDz.d.mts → GraphQLHandler-AenIUdwE.d.mts} +1 -1
- package/lib/core/{GraphQLHandler-eJejgV5u.d.ts → GraphQLHandler-jOzqbxSK.d.ts} +1 -1
- package/lib/core/HttpResponse.d.mts +1 -1
- package/lib/core/HttpResponse.d.ts +1 -1
- package/lib/core/SetupApi.d.mts +1 -1
- package/lib/core/SetupApi.d.ts +1 -1
- package/lib/core/getResponse.d.mts +1 -1
- package/lib/core/getResponse.d.ts +1 -1
- package/lib/core/graphql.d.mts +2 -2
- package/lib/core/graphql.d.ts +2 -2
- package/lib/core/handlers/GraphQLHandler.d.mts +2 -2
- package/lib/core/handlers/GraphQLHandler.d.ts +2 -2
- package/lib/core/handlers/HttpHandler.d.mts +1 -1
- package/lib/core/handlers/HttpHandler.d.ts +1 -1
- package/lib/core/handlers/RequestHandler.d.mts +1 -1
- package/lib/core/handlers/RequestHandler.d.ts +1 -1
- package/lib/core/http.d.mts +1 -1
- package/lib/core/http.d.ts +1 -1
- package/lib/core/index.d.mts +2 -2
- package/lib/core/index.d.ts +2 -2
- package/lib/core/passthrough.d.mts +4 -1
- package/lib/core/passthrough.d.ts +4 -1
- package/lib/core/passthrough.js.map +1 -1
- package/lib/core/passthrough.mjs.map +1 -1
- package/lib/core/utils/HttpResponse/decorators.d.mts +1 -1
- package/lib/core/utils/HttpResponse/decorators.d.ts +1 -1
- package/lib/core/utils/executeHandlers.d.mts +1 -1
- package/lib/core/utils/executeHandlers.d.ts +1 -1
- package/lib/core/utils/handleRequest.d.mts +1 -1
- package/lib/core/utils/handleRequest.d.ts +1 -1
- package/lib/core/utils/internal/parseGraphQLRequest.d.mts +2 -2
- package/lib/core/utils/internal/parseGraphQLRequest.d.ts +2 -2
- package/lib/core/utils/internal/parseMultipartData.d.mts +1 -1
- package/lib/core/utils/internal/parseMultipartData.d.ts +1 -1
- package/lib/core/utils/internal/requestHandlerUtils.d.mts +1 -1
- package/lib/core/utils/internal/requestHandlerUtils.d.ts +1 -1
- package/lib/iife/index.js.map +1 -1
- package/lib/mockServiceWorker.js +1 -1
- package/package.json +1 -1
- package/src/core/passthrough.ts +4 -2
- package/lib/core/{RequestHandler-CwjkprZE.d.ts → HttpResponse-_514VQ9z.d.ts} +68 -68
- package/lib/core/{RequestHandler-MAVTMsma.d.mts → HttpResponse-wcp03c7-.d.mts} +68 -68
package/lib/mockServiceWorker.js
CHANGED
package/package.json
CHANGED
package/src/core/passthrough.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { StrictResponse } from './HttpResponse'
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Performs the intercepted request as-is.
|
|
3
5
|
*
|
|
@@ -12,12 +14,12 @@
|
|
|
12
14
|
*
|
|
13
15
|
* @see {@link https://mswjs.io/docs/api/passthrough `passthrough()` API reference}
|
|
14
16
|
*/
|
|
15
|
-
export function passthrough():
|
|
17
|
+
export function passthrough(): StrictResponse<any> {
|
|
16
18
|
return new Response(null, {
|
|
17
19
|
status: 302,
|
|
18
20
|
statusText: 'Passthrough',
|
|
19
21
|
headers: {
|
|
20
22
|
'x-msw-intention': 'passthrough',
|
|
21
23
|
},
|
|
22
|
-
})
|
|
24
|
+
}) as StrictResponse<any>
|
|
23
25
|
}
|
|
@@ -20,74 +20,6 @@ declare const executeHandlers: <Handlers extends RequestHandler<RequestHandlerDe
|
|
|
20
20
|
resolutionContext?: ResponseResolutionContext | undefined;
|
|
21
21
|
}) => Promise<HandlersExecutionResult | null>;
|
|
22
22
|
|
|
23
|
-
interface HttpResponseInit extends ResponseInit {
|
|
24
|
-
type?: ResponseType;
|
|
25
|
-
}
|
|
26
|
-
declare const bodyType: unique symbol;
|
|
27
|
-
interface StrictRequest<BodyType extends DefaultBodyType> extends Request {
|
|
28
|
-
json(): Promise<BodyType>;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Opaque `Response` type that supports strict body type.
|
|
32
|
-
*/
|
|
33
|
-
interface StrictResponse<BodyType extends DefaultBodyType> extends Response {
|
|
34
|
-
readonly [bodyType]: BodyType;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* A drop-in replacement for the standard `Response` class
|
|
38
|
-
* to allow additional features, like mocking the response `Set-Cookie` header.
|
|
39
|
-
*
|
|
40
|
-
* @example
|
|
41
|
-
* new HttpResponse('Hello world', { status: 201 })
|
|
42
|
-
* HttpResponse.json({ name: 'John' })
|
|
43
|
-
* HttpResponse.formData(form)
|
|
44
|
-
*
|
|
45
|
-
* @see {@link https://mswjs.io/docs/api/http-response `HttpResponse` API reference}
|
|
46
|
-
*/
|
|
47
|
-
declare class HttpResponse extends Response {
|
|
48
|
-
constructor(body?: BodyInit | null, init?: HttpResponseInit);
|
|
49
|
-
/**
|
|
50
|
-
* Create a `Response` with a `Content-Type: "text/plain"` body.
|
|
51
|
-
* @example
|
|
52
|
-
* HttpResponse.text('hello world')
|
|
53
|
-
* HttpResponse.text('Error', { status: 500 })
|
|
54
|
-
*/
|
|
55
|
-
static text<BodyType extends string>(body?: BodyType | null, init?: HttpResponseInit): StrictResponse<BodyType>;
|
|
56
|
-
/**
|
|
57
|
-
* Create a `Response` with a `Content-Type: "application/json"` body.
|
|
58
|
-
* @example
|
|
59
|
-
* HttpResponse.json({ firstName: 'John' })
|
|
60
|
-
* HttpResponse.json({ error: 'Not Authorized' }, { status: 401 })
|
|
61
|
-
*/
|
|
62
|
-
static json<BodyType extends JsonBodyType>(body?: BodyType | null, init?: HttpResponseInit): StrictResponse<BodyType>;
|
|
63
|
-
/**
|
|
64
|
-
* Create a `Response` with a `Content-Type: "application/xml"` body.
|
|
65
|
-
* @example
|
|
66
|
-
* HttpResponse.xml(`<user name="John" />`)
|
|
67
|
-
* HttpResponse.xml(`<article id="abc-123" />`, { status: 201 })
|
|
68
|
-
*/
|
|
69
|
-
static xml<BodyType extends string>(body?: BodyType | null, init?: HttpResponseInit): Response;
|
|
70
|
-
/**
|
|
71
|
-
* Create a `Response` with an `ArrayBuffer` body.
|
|
72
|
-
* @example
|
|
73
|
-
* const buffer = new ArrayBuffer(3)
|
|
74
|
-
* const view = new Uint8Array(buffer)
|
|
75
|
-
* view.set([1, 2, 3])
|
|
76
|
-
*
|
|
77
|
-
* HttpResponse.arrayBuffer(buffer)
|
|
78
|
-
*/
|
|
79
|
-
static arrayBuffer(body?: ArrayBuffer, init?: HttpResponseInit): Response;
|
|
80
|
-
/**
|
|
81
|
-
* Create a `Response` with a `FormData` body.
|
|
82
|
-
* @example
|
|
83
|
-
* const data = new FormData()
|
|
84
|
-
* data.set('name', 'Alice')
|
|
85
|
-
*
|
|
86
|
-
* HttpResponse.formData(data)
|
|
87
|
-
*/
|
|
88
|
-
static formData(body?: FormData, init?: HttpResponseInit): Response;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
23
|
type DefaultRequestMultipartBody = Record<string, string | File | Array<string | File>>;
|
|
92
24
|
type DefaultBodyType = Record<string, any> | DefaultRequestMultipartBody | string | number | boolean | null | undefined;
|
|
93
25
|
type JsonBodyType = Record<string, any> | string | number | boolean | null | undefined;
|
|
@@ -186,4 +118,72 @@ declare abstract class RequestHandler<HandlerInfo extends RequestHandlerDefaultI
|
|
|
186
118
|
private createExecutionResult;
|
|
187
119
|
}
|
|
188
120
|
|
|
121
|
+
interface HttpResponseInit extends ResponseInit {
|
|
122
|
+
type?: ResponseType;
|
|
123
|
+
}
|
|
124
|
+
declare const bodyType: unique symbol;
|
|
125
|
+
interface StrictRequest<BodyType extends DefaultBodyType> extends Request {
|
|
126
|
+
json(): Promise<BodyType>;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Opaque `Response` type that supports strict body type.
|
|
130
|
+
*/
|
|
131
|
+
interface StrictResponse<BodyType extends DefaultBodyType> extends Response {
|
|
132
|
+
readonly [bodyType]: BodyType;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* A drop-in replacement for the standard `Response` class
|
|
136
|
+
* to allow additional features, like mocking the response `Set-Cookie` header.
|
|
137
|
+
*
|
|
138
|
+
* @example
|
|
139
|
+
* new HttpResponse('Hello world', { status: 201 })
|
|
140
|
+
* HttpResponse.json({ name: 'John' })
|
|
141
|
+
* HttpResponse.formData(form)
|
|
142
|
+
*
|
|
143
|
+
* @see {@link https://mswjs.io/docs/api/http-response `HttpResponse` API reference}
|
|
144
|
+
*/
|
|
145
|
+
declare class HttpResponse extends Response {
|
|
146
|
+
constructor(body?: BodyInit | null, init?: HttpResponseInit);
|
|
147
|
+
/**
|
|
148
|
+
* Create a `Response` with a `Content-Type: "text/plain"` body.
|
|
149
|
+
* @example
|
|
150
|
+
* HttpResponse.text('hello world')
|
|
151
|
+
* HttpResponse.text('Error', { status: 500 })
|
|
152
|
+
*/
|
|
153
|
+
static text<BodyType extends string>(body?: BodyType | null, init?: HttpResponseInit): StrictResponse<BodyType>;
|
|
154
|
+
/**
|
|
155
|
+
* Create a `Response` with a `Content-Type: "application/json"` body.
|
|
156
|
+
* @example
|
|
157
|
+
* HttpResponse.json({ firstName: 'John' })
|
|
158
|
+
* HttpResponse.json({ error: 'Not Authorized' }, { status: 401 })
|
|
159
|
+
*/
|
|
160
|
+
static json<BodyType extends JsonBodyType>(body?: BodyType | null, init?: HttpResponseInit): StrictResponse<BodyType>;
|
|
161
|
+
/**
|
|
162
|
+
* Create a `Response` with a `Content-Type: "application/xml"` body.
|
|
163
|
+
* @example
|
|
164
|
+
* HttpResponse.xml(`<user name="John" />`)
|
|
165
|
+
* HttpResponse.xml(`<article id="abc-123" />`, { status: 201 })
|
|
166
|
+
*/
|
|
167
|
+
static xml<BodyType extends string>(body?: BodyType | null, init?: HttpResponseInit): Response;
|
|
168
|
+
/**
|
|
169
|
+
* Create a `Response` with an `ArrayBuffer` body.
|
|
170
|
+
* @example
|
|
171
|
+
* const buffer = new ArrayBuffer(3)
|
|
172
|
+
* const view = new Uint8Array(buffer)
|
|
173
|
+
* view.set([1, 2, 3])
|
|
174
|
+
*
|
|
175
|
+
* HttpResponse.arrayBuffer(buffer)
|
|
176
|
+
*/
|
|
177
|
+
static arrayBuffer(body?: ArrayBuffer, init?: HttpResponseInit): Response;
|
|
178
|
+
/**
|
|
179
|
+
* Create a `Response` with a `FormData` body.
|
|
180
|
+
* @example
|
|
181
|
+
* const data = new FormData()
|
|
182
|
+
* data.set('name', 'Alice')
|
|
183
|
+
*
|
|
184
|
+
* HttpResponse.formData(data)
|
|
185
|
+
*/
|
|
186
|
+
static formData(body?: FormData, init?: HttpResponseInit): Response;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
189
|
export { type AsyncResponseResolverReturnType as A, type DefaultBodyType as D, type HttpResponseInit as H, type JsonBodyType as J, type MaybeAsyncResponseResolverReturnType as M, RequestHandler as R, type StrictRequest as S, type ResponseResolver as a, type ResponseResolverReturnType as b, type RequestHandlerOptions as c, type DefaultRequestMultipartBody as d, type StrictResponse as e, HttpResponse as f, type RequestHandlerDefaultInfo as g, type HandlersExecutionResult as h, type ResponseResolutionContext as i, executeHandlers as j, type RequestHandlerInternalInfo as k, type ResponseResolverInfo as l, type RequestHandlerArgs as m, type RequestHandlerExecutionResult as n };
|
|
@@ -20,74 +20,6 @@ declare const executeHandlers: <Handlers extends RequestHandler<RequestHandlerDe
|
|
|
20
20
|
resolutionContext?: ResponseResolutionContext | undefined;
|
|
21
21
|
}) => Promise<HandlersExecutionResult | null>;
|
|
22
22
|
|
|
23
|
-
interface HttpResponseInit extends ResponseInit {
|
|
24
|
-
type?: ResponseType;
|
|
25
|
-
}
|
|
26
|
-
declare const bodyType: unique symbol;
|
|
27
|
-
interface StrictRequest<BodyType extends DefaultBodyType> extends Request {
|
|
28
|
-
json(): Promise<BodyType>;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Opaque `Response` type that supports strict body type.
|
|
32
|
-
*/
|
|
33
|
-
interface StrictResponse<BodyType extends DefaultBodyType> extends Response {
|
|
34
|
-
readonly [bodyType]: BodyType;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* A drop-in replacement for the standard `Response` class
|
|
38
|
-
* to allow additional features, like mocking the response `Set-Cookie` header.
|
|
39
|
-
*
|
|
40
|
-
* @example
|
|
41
|
-
* new HttpResponse('Hello world', { status: 201 })
|
|
42
|
-
* HttpResponse.json({ name: 'John' })
|
|
43
|
-
* HttpResponse.formData(form)
|
|
44
|
-
*
|
|
45
|
-
* @see {@link https://mswjs.io/docs/api/http-response `HttpResponse` API reference}
|
|
46
|
-
*/
|
|
47
|
-
declare class HttpResponse extends Response {
|
|
48
|
-
constructor(body?: BodyInit | null, init?: HttpResponseInit);
|
|
49
|
-
/**
|
|
50
|
-
* Create a `Response` with a `Content-Type: "text/plain"` body.
|
|
51
|
-
* @example
|
|
52
|
-
* HttpResponse.text('hello world')
|
|
53
|
-
* HttpResponse.text('Error', { status: 500 })
|
|
54
|
-
*/
|
|
55
|
-
static text<BodyType extends string>(body?: BodyType | null, init?: HttpResponseInit): StrictResponse<BodyType>;
|
|
56
|
-
/**
|
|
57
|
-
* Create a `Response` with a `Content-Type: "application/json"` body.
|
|
58
|
-
* @example
|
|
59
|
-
* HttpResponse.json({ firstName: 'John' })
|
|
60
|
-
* HttpResponse.json({ error: 'Not Authorized' }, { status: 401 })
|
|
61
|
-
*/
|
|
62
|
-
static json<BodyType extends JsonBodyType>(body?: BodyType | null, init?: HttpResponseInit): StrictResponse<BodyType>;
|
|
63
|
-
/**
|
|
64
|
-
* Create a `Response` with a `Content-Type: "application/xml"` body.
|
|
65
|
-
* @example
|
|
66
|
-
* HttpResponse.xml(`<user name="John" />`)
|
|
67
|
-
* HttpResponse.xml(`<article id="abc-123" />`, { status: 201 })
|
|
68
|
-
*/
|
|
69
|
-
static xml<BodyType extends string>(body?: BodyType | null, init?: HttpResponseInit): Response;
|
|
70
|
-
/**
|
|
71
|
-
* Create a `Response` with an `ArrayBuffer` body.
|
|
72
|
-
* @example
|
|
73
|
-
* const buffer = new ArrayBuffer(3)
|
|
74
|
-
* const view = new Uint8Array(buffer)
|
|
75
|
-
* view.set([1, 2, 3])
|
|
76
|
-
*
|
|
77
|
-
* HttpResponse.arrayBuffer(buffer)
|
|
78
|
-
*/
|
|
79
|
-
static arrayBuffer(body?: ArrayBuffer, init?: HttpResponseInit): Response;
|
|
80
|
-
/**
|
|
81
|
-
* Create a `Response` with a `FormData` body.
|
|
82
|
-
* @example
|
|
83
|
-
* const data = new FormData()
|
|
84
|
-
* data.set('name', 'Alice')
|
|
85
|
-
*
|
|
86
|
-
* HttpResponse.formData(data)
|
|
87
|
-
*/
|
|
88
|
-
static formData(body?: FormData, init?: HttpResponseInit): Response;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
23
|
type DefaultRequestMultipartBody = Record<string, string | File | Array<string | File>>;
|
|
92
24
|
type DefaultBodyType = Record<string, any> | DefaultRequestMultipartBody | string | number | boolean | null | undefined;
|
|
93
25
|
type JsonBodyType = Record<string, any> | string | number | boolean | null | undefined;
|
|
@@ -186,4 +118,72 @@ declare abstract class RequestHandler<HandlerInfo extends RequestHandlerDefaultI
|
|
|
186
118
|
private createExecutionResult;
|
|
187
119
|
}
|
|
188
120
|
|
|
121
|
+
interface HttpResponseInit extends ResponseInit {
|
|
122
|
+
type?: ResponseType;
|
|
123
|
+
}
|
|
124
|
+
declare const bodyType: unique symbol;
|
|
125
|
+
interface StrictRequest<BodyType extends DefaultBodyType> extends Request {
|
|
126
|
+
json(): Promise<BodyType>;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Opaque `Response` type that supports strict body type.
|
|
130
|
+
*/
|
|
131
|
+
interface StrictResponse<BodyType extends DefaultBodyType> extends Response {
|
|
132
|
+
readonly [bodyType]: BodyType;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* A drop-in replacement for the standard `Response` class
|
|
136
|
+
* to allow additional features, like mocking the response `Set-Cookie` header.
|
|
137
|
+
*
|
|
138
|
+
* @example
|
|
139
|
+
* new HttpResponse('Hello world', { status: 201 })
|
|
140
|
+
* HttpResponse.json({ name: 'John' })
|
|
141
|
+
* HttpResponse.formData(form)
|
|
142
|
+
*
|
|
143
|
+
* @see {@link https://mswjs.io/docs/api/http-response `HttpResponse` API reference}
|
|
144
|
+
*/
|
|
145
|
+
declare class HttpResponse extends Response {
|
|
146
|
+
constructor(body?: BodyInit | null, init?: HttpResponseInit);
|
|
147
|
+
/**
|
|
148
|
+
* Create a `Response` with a `Content-Type: "text/plain"` body.
|
|
149
|
+
* @example
|
|
150
|
+
* HttpResponse.text('hello world')
|
|
151
|
+
* HttpResponse.text('Error', { status: 500 })
|
|
152
|
+
*/
|
|
153
|
+
static text<BodyType extends string>(body?: BodyType | null, init?: HttpResponseInit): StrictResponse<BodyType>;
|
|
154
|
+
/**
|
|
155
|
+
* Create a `Response` with a `Content-Type: "application/json"` body.
|
|
156
|
+
* @example
|
|
157
|
+
* HttpResponse.json({ firstName: 'John' })
|
|
158
|
+
* HttpResponse.json({ error: 'Not Authorized' }, { status: 401 })
|
|
159
|
+
*/
|
|
160
|
+
static json<BodyType extends JsonBodyType>(body?: BodyType | null, init?: HttpResponseInit): StrictResponse<BodyType>;
|
|
161
|
+
/**
|
|
162
|
+
* Create a `Response` with a `Content-Type: "application/xml"` body.
|
|
163
|
+
* @example
|
|
164
|
+
* HttpResponse.xml(`<user name="John" />`)
|
|
165
|
+
* HttpResponse.xml(`<article id="abc-123" />`, { status: 201 })
|
|
166
|
+
*/
|
|
167
|
+
static xml<BodyType extends string>(body?: BodyType | null, init?: HttpResponseInit): Response;
|
|
168
|
+
/**
|
|
169
|
+
* Create a `Response` with an `ArrayBuffer` body.
|
|
170
|
+
* @example
|
|
171
|
+
* const buffer = new ArrayBuffer(3)
|
|
172
|
+
* const view = new Uint8Array(buffer)
|
|
173
|
+
* view.set([1, 2, 3])
|
|
174
|
+
*
|
|
175
|
+
* HttpResponse.arrayBuffer(buffer)
|
|
176
|
+
*/
|
|
177
|
+
static arrayBuffer(body?: ArrayBuffer, init?: HttpResponseInit): Response;
|
|
178
|
+
/**
|
|
179
|
+
* Create a `Response` with a `FormData` body.
|
|
180
|
+
* @example
|
|
181
|
+
* const data = new FormData()
|
|
182
|
+
* data.set('name', 'Alice')
|
|
183
|
+
*
|
|
184
|
+
* HttpResponse.formData(data)
|
|
185
|
+
*/
|
|
186
|
+
static formData(body?: FormData, init?: HttpResponseInit): Response;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
189
|
export { type AsyncResponseResolverReturnType as A, type DefaultBodyType as D, type HttpResponseInit as H, type JsonBodyType as J, type MaybeAsyncResponseResolverReturnType as M, RequestHandler as R, type StrictRequest as S, type ResponseResolver as a, type ResponseResolverReturnType as b, type RequestHandlerOptions as c, type DefaultRequestMultipartBody as d, type StrictResponse as e, HttpResponse as f, type RequestHandlerDefaultInfo as g, type HandlersExecutionResult as h, type ResponseResolutionContext as i, executeHandlers as j, type RequestHandlerInternalInfo as k, type ResponseResolverInfo as l, type RequestHandlerArgs as m, type RequestHandlerExecutionResult as n };
|