msw 2.2.9 → 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/README.md +7 -2
- package/lib/core/{GraphQLHandler-DqVT0Gbq.d.ts → GraphQLHandler-bom2Dn82.d.ts} +3 -3
- package/lib/core/{GraphQLHandler-BumTfgY4.d.mts → GraphQLHandler-yJ_I6j54.d.mts} +3 -3
- package/lib/core/{HttpResponse-jHZ0p2dL.d.ts → HttpResponse-3-NyzyF7.d.mts} +3 -3
- package/lib/core/{HttpResponse-C94XLD-W.d.mts → 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/HttpHandler.js +1 -1
- package/lib/core/handlers/HttpHandler.js.map +1 -1
- package/lib/core/handlers/HttpHandler.mjs +1 -1
- package/lib/core/handlers/HttpHandler.mjs.map +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 +1 -1
- package/lib/iife/index.js.map +1 -1
- package/lib/mockServiceWorker.js +1 -1
- package/package.json +3 -3
- 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/handlers/HttpHandler.ts +1 -1
- 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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "msw",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.11",
|
|
4
4
|
"description": "Seamless REST/GraphQL API mocking library for browser and Node.js.",
|
|
5
5
|
"main": "./lib/core/index.js",
|
|
6
6
|
"module": "./lib/core/index.mjs",
|
|
@@ -162,7 +162,7 @@
|
|
|
162
162
|
"typescript": "^5.4.2",
|
|
163
163
|
"undici": "^5.20.0",
|
|
164
164
|
"url-loader": "^4.1.1",
|
|
165
|
-
"vitest": "^
|
|
165
|
+
"vitest": "^1.2.2",
|
|
166
166
|
"vitest-environment-miniflare": "^2.14.1",
|
|
167
167
|
"webpack": "^5.89.0",
|
|
168
168
|
"webpack-http-server": "^0.5.0"
|
|
@@ -199,7 +199,7 @@
|
|
|
199
199
|
"test:browser": "playwright test -c ./test/browser/playwright.config.ts",
|
|
200
200
|
"test:modules:node": "vitest --config=./test/modules/node/vitest.config.ts",
|
|
201
201
|
"test:modules:browser": "playwright test -c ./test/modules/browser/playwright.config.ts",
|
|
202
|
-
"test:ts": "
|
|
202
|
+
"test:ts": "vitest --typecheck --config=./test/typings/vitest.config.ts",
|
|
203
203
|
"release": "release publish",
|
|
204
204
|
"postinstall": "node -e \"try{require('./config/scripts/postinstall')}catch(e){}\""
|
|
205
205
|
}
|
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,
|
|
@@ -102,7 +102,7 @@ export class HttpHandler extends RequestHandler<
|
|
|
102
102
|
})
|
|
103
103
|
|
|
104
104
|
devUtils.warn(
|
|
105
|
-
`Found a redundant usage of query parameters in the request handler URL for "${method} ${path}". Please match against a path instead and access query parameters
|
|
105
|
+
`Found a redundant usage of query parameters in the request handler URL for "${method} ${path}". Please match against a path instead and access query parameters using "new URL(request.url).searchParams" instead. Learn more: https://mswjs.io/docs/recipes/query-parameters`,
|
|
106
106
|
)
|
|
107
107
|
}
|
|
108
108
|
|
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]
|