msw 0.36.4 → 0.38.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.
- package/README.md +3 -1
- package/lib/esm/RequestHandler-deps.js +5 -6
- package/lib/esm/fetch-deps.js +14 -12
- package/lib/esm/graphql-deps.js +1980 -1804
- package/lib/esm/index.js +59 -44
- package/lib/esm/mockServiceWorker.js +1 -1
- package/lib/iife/index.js +3 -3
- package/lib/iife/mockServiceWorker.js +1 -1
- package/lib/types/graphql.d.ts +6 -6
- package/lib/types/handlers/RequestHandler.d.ts +2 -2
- package/lib/types/response.d.ts +1 -1
- package/lib/types/setupWorker/glossary.d.ts +1 -1
- package/lib/types/utils/logging/prepareResponse.d.ts +2 -2
- package/lib/types/utils/request/onUnhandledRequest.d.ts +5 -1
- package/lib/types/utils/request/parseBody.d.ts +1 -1
- package/lib/umd/index.js +17427 -14532
- package/lib/umd/mockServiceWorker.js +1 -1
- package/native/lib/index.js +2030 -1838
- package/node/lib/index.js +2030 -1838
- package/package.json +34 -26
package/lib/types/graphql.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ declare const standardGraphQLHandlers: {
|
|
|
20
20
|
* })
|
|
21
21
|
* @see {@link https://mswjs.io/docs/api/graphql/operation `graphql.operation()`}
|
|
22
22
|
*/
|
|
23
|
-
operation: <Query extends Record<string, any>, Variables extends GraphQLVariables = GraphQLVariables>(resolver: ResponseResolver<GraphQLRequest<Variables>, GraphQLContext<Query>, any>) => GraphQLHandler<GraphQLRequest<
|
|
23
|
+
operation: <Query extends Record<string, any>, Variables extends GraphQLVariables = GraphQLVariables>(resolver: ResponseResolver<GraphQLRequest<Variables>, GraphQLContext<Query>, any>) => GraphQLHandler<GraphQLRequest<Variables>>;
|
|
24
24
|
/**
|
|
25
25
|
* Captures a GraphQL query by a given name.
|
|
26
26
|
* @example
|
|
@@ -29,7 +29,7 @@ declare const standardGraphQLHandlers: {
|
|
|
29
29
|
* })
|
|
30
30
|
* @see {@link https://mswjs.io/docs/api/graphql/query `graphql.query()`}
|
|
31
31
|
*/
|
|
32
|
-
query: <Query_1 extends Record<string, any>, Variables_1 extends GraphQLVariables = GraphQLVariables>(operationName: GraphQLHandlerNameSelector | TypedDocumentNode<Query_1, Variables_1>, resolver: ResponseResolver<GraphQLRequest<Variables_1>, GraphQLContext<Query_1>, any>) => GraphQLHandler<GraphQLRequest<
|
|
32
|
+
query: <Query_1 extends Record<string, any>, Variables_1 extends GraphQLVariables = GraphQLVariables>(operationName: GraphQLHandlerNameSelector | TypedDocumentNode<Query_1, Variables_1>, resolver: ResponseResolver<GraphQLRequest<Variables_1>, GraphQLContext<Query_1>, any>) => GraphQLHandler<GraphQLRequest<Variables_1>>;
|
|
33
33
|
/**
|
|
34
34
|
* Captures a GraphQL mutation by a given name.
|
|
35
35
|
* @example
|
|
@@ -38,7 +38,7 @@ declare const standardGraphQLHandlers: {
|
|
|
38
38
|
* })
|
|
39
39
|
* @see {@link https://mswjs.io/docs/api/graphql/mutation `graphql.mutation()`}
|
|
40
40
|
*/
|
|
41
|
-
mutation: <Query_1 extends Record<string, any>, Variables_1 extends GraphQLVariables = GraphQLVariables>(operationName: GraphQLHandlerNameSelector | TypedDocumentNode<Query_1, Variables_1>, resolver: ResponseResolver<GraphQLRequest<Variables_1>, GraphQLContext<Query_1>, any>) => GraphQLHandler<GraphQLRequest<
|
|
41
|
+
mutation: <Query_1 extends Record<string, any>, Variables_1 extends GraphQLVariables = GraphQLVariables>(operationName: GraphQLHandlerNameSelector | TypedDocumentNode<Query_1, Variables_1>, resolver: ResponseResolver<GraphQLRequest<Variables_1>, GraphQLContext<Query_1>, any>) => GraphQLHandler<GraphQLRequest<Variables_1>>;
|
|
42
42
|
};
|
|
43
43
|
declare function createGraphQLLink(url: Path): typeof standardGraphQLHandlers;
|
|
44
44
|
export declare const graphql: {
|
|
@@ -51,7 +51,7 @@ export declare const graphql: {
|
|
|
51
51
|
* })
|
|
52
52
|
* @see {@link https://mswjs.io/docs/api/graphql/operation `graphql.operation()`}
|
|
53
53
|
*/
|
|
54
|
-
operation: <Query extends Record<string, any>, Variables extends GraphQLVariables = GraphQLVariables>(resolver: ResponseResolver<GraphQLRequest<Variables>, GraphQLContext<Query>, any>) => GraphQLHandler<GraphQLRequest<
|
|
54
|
+
operation: <Query extends Record<string, any>, Variables extends GraphQLVariables = GraphQLVariables>(resolver: ResponseResolver<GraphQLRequest<Variables>, GraphQLContext<Query>, any>) => GraphQLHandler<GraphQLRequest<Variables>>;
|
|
55
55
|
/**
|
|
56
56
|
* Captures a GraphQL query by a given name.
|
|
57
57
|
* @example
|
|
@@ -60,7 +60,7 @@ export declare const graphql: {
|
|
|
60
60
|
* })
|
|
61
61
|
* @see {@link https://mswjs.io/docs/api/graphql/query `graphql.query()`}
|
|
62
62
|
*/
|
|
63
|
-
query: <Query_1 extends Record<string, any>, Variables_1 extends GraphQLVariables = GraphQLVariables>(operationName: GraphQLHandlerNameSelector | TypedDocumentNode<Query_1, Variables_1>, resolver: ResponseResolver<GraphQLRequest<Variables_1>, GraphQLContext<Query_1>, any>) => GraphQLHandler<GraphQLRequest<
|
|
63
|
+
query: <Query_1 extends Record<string, any>, Variables_1 extends GraphQLVariables = GraphQLVariables>(operationName: GraphQLHandlerNameSelector | TypedDocumentNode<Query_1, Variables_1>, resolver: ResponseResolver<GraphQLRequest<Variables_1>, GraphQLContext<Query_1>, any>) => GraphQLHandler<GraphQLRequest<Variables_1>>;
|
|
64
64
|
/**
|
|
65
65
|
* Captures a GraphQL mutation by a given name.
|
|
66
66
|
* @example
|
|
@@ -69,6 +69,6 @@ export declare const graphql: {
|
|
|
69
69
|
* })
|
|
70
70
|
* @see {@link https://mswjs.io/docs/api/graphql/mutation `graphql.mutation()`}
|
|
71
71
|
*/
|
|
72
|
-
mutation: <Query_1 extends Record<string, any>, Variables_1 extends GraphQLVariables = GraphQLVariables>(operationName: GraphQLHandlerNameSelector | TypedDocumentNode<Query_1, Variables_1>, resolver: ResponseResolver<GraphQLRequest<Variables_1>, GraphQLContext<Query_1>, any>) => GraphQLHandler<GraphQLRequest<
|
|
72
|
+
mutation: <Query_1 extends Record<string, any>, Variables_1 extends GraphQLVariables = GraphQLVariables>(operationName: GraphQLHandlerNameSelector | TypedDocumentNode<Query_1, Variables_1>, resolver: ResponseResolver<GraphQLRequest<Variables_1>, GraphQLContext<Query_1>, any>) => GraphQLHandler<GraphQLRequest<Variables_1>>;
|
|
73
73
|
};
|
|
74
74
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Headers } from 'headers-
|
|
1
|
+
import { Headers } from 'headers-polyfill';
|
|
2
2
|
import { MockedResponse, ResponseComposition } from '../response';
|
|
3
3
|
import { set } from '../context/set';
|
|
4
4
|
import { ResponseResolutionContext } from '../utils/getResponse';
|
|
@@ -10,7 +10,7 @@ export declare const defaultContext: {
|
|
|
10
10
|
fetch: (input: string | MockedRequest<DefaultRequestBody>, requestInit?: RequestInit) => Promise<Response>;
|
|
11
11
|
};
|
|
12
12
|
export declare type DefaultRequestMultipartBody = Record<string, string | File | (string | File)[]>;
|
|
13
|
-
export declare type DefaultRequestBody = Record<string, any> | DefaultRequestMultipartBody | string | number | undefined;
|
|
13
|
+
export declare type DefaultRequestBody = Record<string, any> | DefaultRequestMultipartBody | string | number | boolean | null | undefined;
|
|
14
14
|
export interface MockedRequest<Body = DefaultRequestBody> {
|
|
15
15
|
id: string;
|
|
16
16
|
url: URL;
|
package/lib/types/response.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FlatHeadersObject } from 'headers-
|
|
1
|
+
import { FlatHeadersObject } from 'headers-polyfill';
|
|
2
2
|
import { StrictEventEmitter } from 'strict-event-emitter';
|
|
3
3
|
import { LifeCycleEventEmitter, LifeCycleEventsMap, SharedOptions } from '../sharedOptions';
|
|
4
4
|
import { ServiceWorkerMessage } from '../utils/createBroadcastChannel';
|
|
@@ -3,8 +3,8 @@ import { SerializedResponse } from '../../setupWorker/glossary';
|
|
|
3
3
|
* Formats a mocked response for introspection in the browser's console.
|
|
4
4
|
*/
|
|
5
5
|
export declare function prepareResponse(res: SerializedResponse<any>): {
|
|
6
|
-
body: string | number | Record<string, any> | undefined;
|
|
6
|
+
body: string | number | boolean | Record<string, any> | null | undefined;
|
|
7
7
|
status: number;
|
|
8
8
|
statusText: string;
|
|
9
|
-
headers: import("headers-
|
|
9
|
+
headers: import("headers-polyfill").FlatHeadersObject;
|
|
10
10
|
};
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { MockedRequest, RequestHandler } from '../../handlers/RequestHandler';
|
|
2
|
-
export
|
|
2
|
+
export interface UnhandledRequestPrint {
|
|
3
|
+
warning(): void;
|
|
4
|
+
error(): void;
|
|
5
|
+
}
|
|
6
|
+
export declare type UnhandledRequestCallback = (request: MockedRequest, print: UnhandledRequestPrint) => void;
|
|
3
7
|
export declare type UnhandledRequestStrategy = 'bypass' | 'warn' | 'error' | UnhandledRequestCallback;
|
|
4
8
|
export declare function onUnhandledRequest(request: MockedRequest, handlers: RequestHandler[], strategy?: UnhandledRequestStrategy): void;
|
|
@@ -2,4 +2,4 @@ import { MockedRequest } from '../../handlers/RequestHandler';
|
|
|
2
2
|
/**
|
|
3
3
|
* Parses a given request/response body based on the "Content-Type" header.
|
|
4
4
|
*/
|
|
5
|
-
export declare function parseBody(body?: MockedRequest['body'], headers?: Headers): string | number | Record<string, any> | undefined;
|
|
5
|
+
export declare function parseBody(body?: MockedRequest['body'], headers?: Headers): string | number | boolean | Record<string, any> | null | undefined;
|