msw 0.43.1 → 0.44.0

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,5 +1,5 @@
1
1
  import { PartialDeep } from 'type-fest';
2
- import { IsomorphicResponse } from '@mswjs/interceptors';
2
+ import { RequestInit as RequestInit$1, IsomorphicRequest, IsomorphicResponse } from '@mswjs/interceptors';
3
3
  import { FlatHeadersObject, Headers } from 'headers-polyfill';
4
4
  import { StrictEventEmitter } from 'strict-event-emitter';
5
5
 
@@ -32,6 +32,53 @@ declare type DelayMode = 'real' | 'infinite';
32
32
  */
33
33
  declare const delay: (durationOrMode?: DelayMode | number) => ResponseTransformer;
34
34
 
35
+ declare type RequestCache = 'default' | 'no-store' | 'reload' | 'no-cache' | 'force-cache' | 'only-if-cached';
36
+ declare type RequestMode = 'navigate' | 'same-origin' | 'no-cors' | 'cors';
37
+ declare type RequestRedirect = 'follow' | 'error' | 'manual';
38
+ declare type RequestDestination = '' | 'audio' | 'audioworklet' | 'document' | 'embed' | 'font' | 'frame' | 'iframe' | 'image' | 'manifest' | 'object' | 'paintworklet' | 'report' | 'script' | 'sharedworker' | 'style' | 'track' | 'video' | 'xslt' | 'worker';
39
+ declare type RequestPriority = 'high' | 'low' | 'auto';
40
+ declare type RequestReferrerPolicy = '' | 'no-referrer' | 'no-referrer-when-downgrade' | 'origin' | 'origin-when-cross-origin' | 'same-origin' | 'strict-origin' | 'strict-origin-when-cross-origin' | 'unsafe-url';
41
+ interface MockedRequestInit extends RequestInit$1 {
42
+ id?: string;
43
+ cache?: RequestCache;
44
+ redirect?: RequestRedirect;
45
+ integrity?: string;
46
+ keepalive?: boolean;
47
+ mode?: RequestMode;
48
+ priority?: RequestPriority;
49
+ destination?: RequestDestination;
50
+ referrer?: string;
51
+ referrerPolicy?: RequestReferrerPolicy;
52
+ cookies?: Record<string, string>;
53
+ }
54
+ declare class MockedRequest<RequestBody extends DefaultBodyType = DefaultBodyType> extends IsomorphicRequest {
55
+ readonly cache: RequestCache;
56
+ readonly cookies: Record<string, string>;
57
+ readonly destination: RequestDestination;
58
+ readonly integrity: string;
59
+ readonly keepalive: boolean;
60
+ readonly mode: RequestMode;
61
+ readonly priority: RequestPriority;
62
+ readonly redirect: RequestRedirect;
63
+ readonly referrer: string;
64
+ readonly referrerPolicy: RequestReferrerPolicy;
65
+ constructor(request: IsomorphicRequest);
66
+ constructor(url: URL, init?: MockedRequestInit);
67
+ /**
68
+ * Get parsed request body. The type is inferred from the content type.
69
+ *
70
+ * @deprecated - Use `req.text()`, `req.json()` or `req.arrayBuffer()`
71
+ * to read the request body as a plain text, JSON, or ArrayBuffer.
72
+ */
73
+ get body(): RequestBody;
74
+ /**
75
+ * Bypass the intercepted request.
76
+ * This will make a call to the actual endpoint requested.
77
+ */
78
+ passthrough(): MockedResponse<null>;
79
+ private getCookies;
80
+ }
81
+
35
82
  /**
36
83
  * Performs a bypassed request inside a request handler.
37
84
  * @example
@@ -165,25 +212,6 @@ declare type DefaultContext = {
165
212
  declare const defaultContext: DefaultContext;
166
213
  declare type DefaultRequestMultipartBody = Record<string, string | File | (string | File)[]>;
167
214
  declare type DefaultBodyType = Record<string, any> | DefaultRequestMultipartBody | string | number | boolean | null | undefined;
168
- interface MockedRequest<Body = DefaultBodyType> {
169
- id: string;
170
- url: URL;
171
- method: Request['method'];
172
- headers: Headers;
173
- cookies: Record<string, string>;
174
- mode: Request['mode'];
175
- keepalive: Request['keepalive'];
176
- cache: Request['cache'];
177
- destination: Request['destination'];
178
- integrity: Request['integrity'];
179
- credentials: Request['credentials'];
180
- redirect: Request['redirect'];
181
- referrer: Request['referrer'];
182
- referrerPolicy: Request['referrerPolicy'];
183
- body: Body;
184
- bodyUsed: Request['bodyUsed'];
185
- passthrough: typeof passthrough;
186
- }
187
215
  interface RequestHandlerDefaultInfo {
188
216
  header: string;
189
217
  }
@@ -245,11 +273,6 @@ declare abstract class RequestHandler<HandlerInfo extends RequestHandlerDefaultI
245
273
  private wrapResolver;
246
274
  private createExecutionResult;
247
275
  }
248
- /**
249
- * Bypass this intercepted request.
250
- * This will make a call to the actual endpoint requested.
251
- */
252
- declare function passthrough(): MockedResponse<null>;
253
276
 
254
277
  declare type MaybePromise<ValueType = any> = ValueType | Promise<ValueType>;
255
278
  /**
@@ -329,4 +352,4 @@ interface SetupServerApi {
329
352
  events: LifeCycleEventEmitter<ServerLifecycleEventsMap>;
330
353
  }
331
354
 
332
- export { AsyncResponseResolverReturnType as A, DefaultContext as D, MockedRequest as M, ResponseTransformer as R, SetupWorkerApi as S, set as a, RequestHandler as b, DefaultBodyType as c, delay as d, ResponseResolver as e, fetch as f, ResponseResolutionContext as g, SerializedResponse as h, RequestHandlerDefaultInfo as i, MockedResponse as j, ResponseLookupResult as k, SharedOptions as l, ServerLifecycleEventsMap as m, defaultResponse as n, createResponseComposition as o, defaultContext as p, StartOptions as q, response as r, status as s, ResponseResolverReturnType as t, DefaultRequestMultipartBody as u, ResponseComposition as v, ResponseCompositionOptions as w, ResponseFunction as x, DelayMode as y, SetupServerApi as z };
355
+ export { AsyncResponseResolverReturnType as A, RequestMode as B, RequestRedirect as C, DefaultContext as D, RequestDestination as E, RequestPriority as F, RequestReferrerPolicy as G, MockedRequestInit as H, SetupServerApi as I, MockedRequest as M, ResponseTransformer as R, SetupWorkerApi as S, set as a, RequestHandler as b, DefaultBodyType as c, delay as d, ResponseResolver as e, fetch as f, ResponseResolutionContext as g, SerializedResponse as h, RequestHandlerDefaultInfo as i, MockedResponse as j, ResponseLookupResult as k, SharedOptions as l, ServerLifecycleEventsMap as m, defaultResponse as n, createResponseComposition as o, defaultContext as p, StartOptions as q, response as r, status as s, ResponseResolverReturnType as t, DefaultRequestMultipartBody as u, ResponseComposition as v, ResponseCompositionOptions as w, ResponseFunction as x, DelayMode as y, RequestCache as z };