msw 2.2.10 → 2.2.11
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-jOzqbxSK.d.ts → GraphQLHandler-bom2Dn82.d.ts} +3 -3
- package/lib/core/{GraphQLHandler-AenIUdwE.d.mts → GraphQLHandler-yJ_I6j54.d.mts} +3 -3
- package/lib/core/{HttpResponse-wcp03c7-.d.mts → HttpResponse-3-NyzyF7.d.mts} +3 -3
- package/lib/core/{HttpResponse-_514VQ9z.d.ts → HttpResponse-vQNlixkj.d.ts} +3 -3
- package/lib/core/HttpResponse.d.mts +1 -1
- package/lib/core/HttpResponse.d.ts +1 -1
- package/lib/core/HttpResponse.js.map +1 -1
- package/lib/core/HttpResponse.mjs.map +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 +8 -6
- package/lib/core/graphql.d.ts +8 -6
- package/lib/core/graphql.js.map +1 -1
- package/lib/core/graphql.mjs.map +1 -1
- package/lib/core/handlers/GraphQLHandler.d.mts +2 -2
- package/lib/core/handlers/GraphQLHandler.d.ts +2 -2
- package/lib/core/handlers/GraphQLHandler.js.map +1 -1
- package/lib/core/handlers/GraphQLHandler.mjs.map +1 -1
- 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 +1 -1
- package/lib/core/passthrough.d.ts +1 -1
- package/lib/core/typeUtils.d.mts +6 -1
- package/lib/core/typeUtils.d.ts +6 -1
- package/lib/core/typeUtils.js.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/HttpResponse.ts +3 -2
- package/src/core/graphql.ts +6 -3
- package/src/core/handlers/GraphQLHandler.ts +7 -4
- package/src/core/typeUtils.ts +6 -0
package/lib/mockServiceWorker.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* - Please do NOT serve this file on production.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
const PACKAGE_VERSION = '2.2.
|
|
11
|
+
const PACKAGE_VERSION = '2.2.11'
|
|
12
12
|
const INTEGRITY_CHECKSUM = '26357c79639bfa20d64c0efca2a87423'
|
|
13
13
|
const IS_MOCKED_RESPONSE = Symbol('isMockedResponse')
|
|
14
14
|
const activeClientIds = new Set()
|
package/package.json
CHANGED
package/src/core/HttpResponse.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { DefaultBodyType, JsonBodyType } from './handlers/RequestHandler'
|
|
2
|
+
import type { NoInfer } from './typeUtils'
|
|
2
3
|
import {
|
|
3
4
|
decorateResponse,
|
|
4
5
|
normalizeResponseInit,
|
|
@@ -48,7 +49,7 @@ export class HttpResponse extends Response {
|
|
|
48
49
|
* HttpResponse.text('Error', { status: 500 })
|
|
49
50
|
*/
|
|
50
51
|
static text<BodyType extends string>(
|
|
51
|
-
body?: BodyType | null,
|
|
52
|
+
body?: NoInfer<BodyType> | null,
|
|
52
53
|
init?: HttpResponseInit,
|
|
53
54
|
): StrictResponse<BodyType> {
|
|
54
55
|
const responseInit = normalizeResponseInit(init)
|
|
@@ -77,7 +78,7 @@ export class HttpResponse extends Response {
|
|
|
77
78
|
* HttpResponse.json({ error: 'Not Authorized' }, { status: 401 })
|
|
78
79
|
*/
|
|
79
80
|
static json<BodyType extends JsonBodyType>(
|
|
80
|
-
body?: BodyType | null,
|
|
81
|
+
body?: NoInfer<BodyType> | null,
|
|
81
82
|
init?: HttpResponseInit,
|
|
82
83
|
): StrictResponse<BodyType> {
|
|
83
84
|
const responseInit = normalizeResponseInit(init)
|
package/src/core/graphql.ts
CHANGED
|
@@ -31,7 +31,10 @@ export type GraphQLRequestHandler = <
|
|
|
31
31
|
| GraphQLHandlerNameSelector
|
|
32
32
|
| DocumentNode
|
|
33
33
|
| TypedDocumentNode<Query, Variables>,
|
|
34
|
-
resolver: GraphQLResponseResolver<
|
|
34
|
+
resolver: GraphQLResponseResolver<
|
|
35
|
+
[Query] extends [never] ? GraphQLQuery : Query,
|
|
36
|
+
Variables
|
|
37
|
+
>,
|
|
35
38
|
options?: RequestHandlerOptions,
|
|
36
39
|
) => GraphQLHandler
|
|
37
40
|
|
|
@@ -41,7 +44,7 @@ export type GraphQLResponseResolver<
|
|
|
41
44
|
> = ResponseResolver<
|
|
42
45
|
GraphQLResolverExtras<Variables>,
|
|
43
46
|
null,
|
|
44
|
-
GraphQLResponseBody<Query>
|
|
47
|
+
GraphQLResponseBody<[Query] extends [never] ? GraphQLQuery : Query>
|
|
45
48
|
>
|
|
46
49
|
|
|
47
50
|
function createScopedGraphQLHandler(
|
|
@@ -61,7 +64,7 @@ function createScopedGraphQLHandler(
|
|
|
61
64
|
|
|
62
65
|
function createGraphQLOperationHandler(url: Path) {
|
|
63
66
|
return <
|
|
64
|
-
Query extends
|
|
67
|
+
Query extends GraphQLQuery = GraphQLQuery,
|
|
65
68
|
Variables extends GraphQLVariables = GraphQLVariables,
|
|
66
69
|
>(
|
|
67
70
|
resolver: ResponseResolver<
|
|
@@ -68,10 +68,13 @@ export interface GraphQLJsonRequestBody<Variables extends GraphQLVariables> {
|
|
|
68
68
|
variables?: Variables
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
export
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
71
|
+
export type GraphQLResponseBody<BodyType extends DefaultBodyType> =
|
|
72
|
+
| {
|
|
73
|
+
data?: BodyType | null
|
|
74
|
+
errors?: readonly Partial<GraphQLError>[] | null
|
|
75
|
+
}
|
|
76
|
+
| null
|
|
77
|
+
| undefined
|
|
75
78
|
|
|
76
79
|
export function isDocumentNode(
|
|
77
80
|
value: DocumentNode | any,
|
package/src/core/typeUtils.ts
CHANGED
|
@@ -18,3 +18,9 @@ export type RequiredDeep<
|
|
|
18
18
|
: RequiredDeep<NonNullable<Type[Key]>, U>
|
|
19
19
|
}
|
|
20
20
|
: Type
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @fixme Remove this once TS 5.4 is the lowest supported version.
|
|
24
|
+
* Because "NoInfer" is a built-in type utility there.
|
|
25
|
+
*/
|
|
26
|
+
export type NoInfer<T> = [T][T extends any ? 0 : never]
|