msw 0.43.0 → 0.44.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,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,52 @@ 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(url: URL, init?: MockedRequestInit);
66
+ /**
67
+ * Get parsed request body. The type is inferred from the content type.
68
+ *
69
+ * @deprecated - Use `req.text()`, `req.json()` or `req.arrayBuffer()`
70
+ * to read the request body as a plain text, JSON, or ArrayBuffer.
71
+ */
72
+ get body(): RequestBody;
73
+ /**
74
+ * Bypass the intercepted request.
75
+ * This will make a call to the actual endpoint requested.
76
+ */
77
+ passthrough(): MockedResponse<null>;
78
+ private getCookies;
79
+ }
80
+
35
81
  /**
36
82
  * Performs a bypassed request inside a request handler.
37
83
  * @example
@@ -165,25 +211,6 @@ declare type DefaultContext = {
165
211
  declare const defaultContext: DefaultContext;
166
212
  declare type DefaultRequestMultipartBody = Record<string, string | File | (string | File)[]>;
167
213
  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
214
  interface RequestHandlerDefaultInfo {
188
215
  header: string;
189
216
  }
@@ -245,11 +272,6 @@ declare abstract class RequestHandler<HandlerInfo extends RequestHandlerDefaultI
245
272
  private wrapResolver;
246
273
  private createExecutionResult;
247
274
  }
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
275
 
254
276
  declare type MaybePromise<ValueType = any> = ValueType | Promise<ValueType>;
255
277
  /**
@@ -329,4 +351,4 @@ interface SetupServerApi {
329
351
  events: LifeCycleEventEmitter<ServerLifecycleEventsMap>;
330
352
  }
331
353
 
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 };
354
+ 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 };