msw 2.2.10 → 2.2.12

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.
Files changed (57) hide show
  1. package/lib/browser/index.js +22 -19
  2. package/lib/browser/index.js.map +1 -1
  3. package/lib/browser/index.mjs +22 -19
  4. package/lib/browser/index.mjs.map +1 -1
  5. package/lib/core/{GraphQLHandler-jOzqbxSK.d.ts → GraphQLHandler-bom2Dn82.d.ts} +3 -3
  6. package/lib/core/{GraphQLHandler-AenIUdwE.d.mts → GraphQLHandler-yJ_I6j54.d.mts} +3 -3
  7. package/lib/core/{HttpResponse-wcp03c7-.d.mts → HttpResponse-3-NyzyF7.d.mts} +3 -3
  8. package/lib/core/{HttpResponse-_514VQ9z.d.ts → HttpResponse-vQNlixkj.d.ts} +3 -3
  9. package/lib/core/HttpResponse.d.mts +1 -1
  10. package/lib/core/HttpResponse.d.ts +1 -1
  11. package/lib/core/HttpResponse.js.map +1 -1
  12. package/lib/core/HttpResponse.mjs.map +1 -1
  13. package/lib/core/SetupApi.d.mts +1 -1
  14. package/lib/core/SetupApi.d.ts +1 -1
  15. package/lib/core/getResponse.d.mts +1 -1
  16. package/lib/core/getResponse.d.ts +1 -1
  17. package/lib/core/graphql.d.mts +8 -6
  18. package/lib/core/graphql.d.ts +8 -6
  19. package/lib/core/graphql.js.map +1 -1
  20. package/lib/core/graphql.mjs.map +1 -1
  21. package/lib/core/handlers/GraphQLHandler.d.mts +2 -2
  22. package/lib/core/handlers/GraphQLHandler.d.ts +2 -2
  23. package/lib/core/handlers/GraphQLHandler.js.map +1 -1
  24. package/lib/core/handlers/GraphQLHandler.mjs.map +1 -1
  25. package/lib/core/handlers/HttpHandler.d.mts +1 -1
  26. package/lib/core/handlers/HttpHandler.d.ts +1 -1
  27. package/lib/core/handlers/RequestHandler.d.mts +1 -1
  28. package/lib/core/handlers/RequestHandler.d.ts +1 -1
  29. package/lib/core/http.d.mts +1 -1
  30. package/lib/core/http.d.ts +1 -1
  31. package/lib/core/index.d.mts +2 -2
  32. package/lib/core/index.d.ts +2 -2
  33. package/lib/core/passthrough.d.mts +1 -1
  34. package/lib/core/passthrough.d.ts +1 -1
  35. package/lib/core/typeUtils.d.mts +6 -1
  36. package/lib/core/typeUtils.d.ts +6 -1
  37. package/lib/core/typeUtils.js.map +1 -1
  38. package/lib/core/utils/HttpResponse/decorators.d.mts +1 -1
  39. package/lib/core/utils/HttpResponse/decorators.d.ts +1 -1
  40. package/lib/core/utils/executeHandlers.d.mts +1 -1
  41. package/lib/core/utils/executeHandlers.d.ts +1 -1
  42. package/lib/core/utils/handleRequest.d.mts +1 -1
  43. package/lib/core/utils/handleRequest.d.ts +1 -1
  44. package/lib/core/utils/internal/parseGraphQLRequest.d.mts +2 -2
  45. package/lib/core/utils/internal/parseGraphQLRequest.d.ts +2 -2
  46. package/lib/core/utils/internal/parseMultipartData.d.mts +1 -1
  47. package/lib/core/utils/internal/parseMultipartData.d.ts +1 -1
  48. package/lib/core/utils/internal/requestHandlerUtils.d.mts +1 -1
  49. package/lib/core/utils/internal/requestHandlerUtils.d.ts +1 -1
  50. package/lib/iife/index.js +22 -19
  51. package/lib/iife/index.js.map +1 -1
  52. package/lib/mockServiceWorker.js +1 -1
  53. package/package.json +2 -2
  54. package/src/core/HttpResponse.ts +3 -2
  55. package/src/core/graphql.ts +6 -3
  56. package/src/core/handlers/GraphQLHandler.ts +7 -4
  57. package/src/core/typeUtils.ts +6 -0
@@ -8,7 +8,7 @@
8
8
  * - Please do NOT serve this file on production.
9
9
  */
10
10
 
11
- const PACKAGE_VERSION = '2.2.10'
11
+ const PACKAGE_VERSION = '2.2.12'
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.10",
3
+ "version": "2.2.12",
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",
@@ -105,7 +105,7 @@
105
105
  "@bundled-es-modules/statuses": "^1.0.1",
106
106
  "@inquirer/confirm": "^3.0.0",
107
107
  "@mswjs/cookies": "^1.1.0",
108
- "@mswjs/interceptors": "^0.25.16",
108
+ "@mswjs/interceptors": "^0.26.12",
109
109
  "@open-draft/until": "^2.1.0",
110
110
  "@types/cookie": "^0.6.0",
111
111
  "@types/statuses": "^2.0.4",
@@ -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)
@@ -31,7 +31,10 @@ export type GraphQLRequestHandler = <
31
31
  | GraphQLHandlerNameSelector
32
32
  | DocumentNode
33
33
  | TypedDocumentNode<Query, Variables>,
34
- resolver: GraphQLResponseResolver<Query, Variables>,
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 Record<string, any>,
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 interface GraphQLResponseBody<BodyType extends DefaultBodyType> {
72
- data?: BodyType | null
73
- errors?: readonly Partial<GraphQLError>[] | null
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,
@@ -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]