msw 2.14.7 → 2.15.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/lib/browser/index.js +1 -1
- package/lib/browser/index.mjs +1 -1
- package/lib/core/{HttpResponse-BTyqrRB6.d.mts → HttpResponse-BE_Y2Ak9.d.mts} +18 -0
- package/lib/core/{HttpResponse-BXyXQFMJ.d.ts → HttpResponse-DL-P1EeG.d.ts} +18 -0
- package/lib/core/HttpResponse.d.mts +1 -1
- package/lib/core/HttpResponse.d.ts +1 -1
- package/lib/core/experimental/compat.d.mts +1 -1
- package/lib/core/experimental/compat.d.ts +1 -1
- package/lib/core/experimental/define-network.d.mts +1 -1
- package/lib/core/experimental/define-network.d.ts +1 -1
- package/lib/core/experimental/frames/http-frame.d.mts +1 -1
- package/lib/core/experimental/frames/http-frame.d.ts +1 -1
- package/lib/core/experimental/frames/network-frame.d.mts +1 -1
- package/lib/core/experimental/frames/network-frame.d.ts +1 -1
- package/lib/core/experimental/frames/websocket-frame.d.mts +1 -1
- package/lib/core/experimental/frames/websocket-frame.d.ts +1 -1
- package/lib/core/experimental/handlers-controller.d.mts +1 -1
- package/lib/core/experimental/handlers-controller.d.ts +1 -1
- package/lib/core/experimental/index.d.mts +1 -1
- package/lib/core/experimental/index.d.ts +1 -1
- package/lib/core/experimental/on-unhandled-frame.d.mts +1 -1
- package/lib/core/experimental/on-unhandled-frame.d.ts +1 -1
- package/lib/core/experimental/setup-api.d.mts +1 -1
- package/lib/core/experimental/setup-api.d.ts +1 -1
- package/lib/core/experimental/sources/interceptor-source.d.mts +1 -1
- package/lib/core/experimental/sources/interceptor-source.d.ts +1 -1
- package/lib/core/experimental/sources/network-source.d.mts +1 -1
- package/lib/core/experimental/sources/network-source.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 +1 -1
- package/lib/core/graphql.d.ts +1 -1
- package/lib/core/handlers/GraphQLHandler.d.mts +1 -1
- package/lib/core/handlers/GraphQLHandler.d.ts +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/handlers/RequestHandler.js +88 -23
- package/lib/core/handlers/RequestHandler.js.map +1 -1
- package/lib/core/handlers/RequestHandler.mjs +88 -23
- package/lib/core/handlers/RequestHandler.mjs.map +1 -1
- package/lib/core/http.d.mts +1 -1
- package/lib/core/http.d.ts +1 -1
- package/lib/core/index.d.mts +1 -1
- package/lib/core/index.d.ts +1 -1
- package/lib/core/passthrough.d.mts +1 -1
- package/lib/core/passthrough.d.ts +1 -1
- package/lib/core/sse.d.mts +2 -2
- package/lib/core/sse.d.ts +2 -2
- package/lib/core/sse.js +66 -48
- package/lib/core/sse.js.map +1 -1
- package/lib/core/sse.mjs +65 -47
- package/lib/core/sse.mjs.map +1 -1
- package/lib/core/utils/HttpResponse/decorators.d.mts +8 -3
- package/lib/core/utils/HttpResponse/decorators.d.ts +8 -3
- package/lib/core/utils/HttpResponse/decorators.js +13 -0
- package/lib/core/utils/HttpResponse/decorators.js.map +1 -1
- package/lib/core/utils/HttpResponse/decorators.mjs +13 -0
- package/lib/core/utils/HttpResponse/decorators.mjs.map +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/attachSiblingHandlers.d.mts +1 -1
- package/lib/core/utils/internal/attachSiblingHandlers.d.ts +1 -1
- package/lib/core/utils/internal/isHandlerKind.d.mts +1 -1
- package/lib/core/utils/internal/isHandlerKind.d.ts +1 -1
- package/lib/core/utils/internal/observe-response-body-stream.d.mts +18 -0
- package/lib/core/utils/internal/observe-response-body-stream.d.ts +18 -0
- package/lib/core/utils/internal/observe-response-body-stream.js +64 -0
- package/lib/core/utils/internal/observe-response-body-stream.js.map +1 -0
- package/lib/core/utils/internal/observe-response-body-stream.mjs +44 -0
- package/lib/core/utils/internal/observe-response-body-stream.mjs.map +1 -0
- package/lib/core/utils/internal/parseGraphQLRequest.d.mts +1 -1
- package/lib/core/utils/internal/parseGraphQLRequest.d.ts +1 -1
- package/lib/core/utils/internal/parseMultipartData.d.mts +1 -1
- package/lib/core/utils/internal/parseMultipartData.d.ts +1 -1
- package/lib/core/ws/handleWebSocketEvent.d.mts +1 -1
- package/lib/core/ws/handleWebSocketEvent.d.ts +1 -1
- package/lib/iife/index.js +270 -137
- package/lib/iife/index.js.map +1 -1
- package/lib/mockServiceWorker.js +21 -9
- package/package.json +2 -2
- package/src/core/handlers/HttpHandler.test.ts +89 -0
- package/src/core/handlers/RequestHandler.ts +142 -32
- package/src/core/sse.ts +85 -53
- package/src/core/utils/HttpResponse/decorators.ts +23 -2
- package/src/core/utils/internal/observe-response-body-stream.test.ts +64 -0
- package/src/core/utils/internal/observe-response-body-stream.ts +77 -0
- package/src/mockServiceWorker.js +19 -7
package/lib/browser/index.js
CHANGED
|
@@ -2545,7 +2545,7 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
2545
2545
|
this.#channel.postMessage("INTEGRITY_CHECK_REQUEST");
|
|
2546
2546
|
this.#channel.once("INTEGRITY_CHECK_RESPONSE", (event) => {
|
|
2547
2547
|
const { checksum, packageVersion } = event.data;
|
|
2548
|
-
if (checksum !== "
|
|
2548
|
+
if (checksum !== "03cb67ac84128e63d7cd722a6e5b7f1e") {
|
|
2549
2549
|
import_devUtils3.devUtils.warn(
|
|
2550
2550
|
`The currently registered Service Worker has been generated by a different version of MSW (${packageVersion}) and may not be fully compatible with the installed version.
|
|
2551
2551
|
|
package/lib/browser/index.mjs
CHANGED
|
@@ -2524,7 +2524,7 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
2524
2524
|
this.#channel.postMessage("INTEGRITY_CHECK_REQUEST");
|
|
2525
2525
|
this.#channel.once("INTEGRITY_CHECK_RESPONSE", (event) => {
|
|
2526
2526
|
const { checksum, packageVersion } = event.data;
|
|
2527
|
-
if (checksum !== "
|
|
2527
|
+
if (checksum !== "03cb67ac84128e63d7cd722a6e5b7f1e") {
|
|
2528
2528
|
devUtils3.warn(
|
|
2529
2529
|
`The currently registered Service Worker has been generated by a different version of MSW (${packageVersion}) and may not be fully compatible with the installed version.
|
|
2530
2530
|
|
|
@@ -172,6 +172,10 @@ type ResponseResolverInfo<ResolverExtraInfo extends Record<string, unknown>, Req
|
|
|
172
172
|
/**
|
|
173
173
|
* Schedule a callback to run after this response resolver completes.
|
|
174
174
|
* Handy for cleaning up the side effects introduced in the resolver.
|
|
175
|
+
*
|
|
176
|
+
* For responses with a `ReadableStream` body (including `sse()` handlers),
|
|
177
|
+
* the callback runs once the response stream settles: it is read to
|
|
178
|
+
* completion, errored, or canceled, or the request is aborted.
|
|
175
179
|
* @example
|
|
176
180
|
* sse('/', ({ client, finalize }) => {
|
|
177
181
|
* const interval = setInterval(() => client.send({ data: 'ping' }))
|
|
@@ -279,7 +283,21 @@ declare abstract class RequestHandler<HandlerInfo extends RequestHandlerDefaultI
|
|
|
279
283
|
private createExecutionResult;
|
|
280
284
|
private scheduleCleanup;
|
|
281
285
|
private exhaustCleanups;
|
|
286
|
+
/**
|
|
287
|
+
* Remove and return the cleanups scheduled for the given request
|
|
288
|
+
* (or the pending iterator cleanups for generator resolvers).
|
|
289
|
+
*/
|
|
290
|
+
private takeScheduledCleanups;
|
|
282
291
|
private runScheduledCleanups;
|
|
292
|
+
/**
|
|
293
|
+
* Conclude the response resolution for the given request.
|
|
294
|
+
* Runs the scheduled cleanups immediately for responses without a
|
|
295
|
+
* `ReadableStream` body. For streamed responses, returns an observed
|
|
296
|
+
* copy of the response and defers the cleanups until its body settles
|
|
297
|
+
* (is read to completion, errored, or canceled) or the request is
|
|
298
|
+
* aborted, whichever comes first.
|
|
299
|
+
*/
|
|
300
|
+
private complete;
|
|
283
301
|
}
|
|
284
302
|
/**
|
|
285
303
|
* Forwards the cookies from the given response to `document.cookie`.
|
|
@@ -172,6 +172,10 @@ type ResponseResolverInfo<ResolverExtraInfo extends Record<string, unknown>, Req
|
|
|
172
172
|
/**
|
|
173
173
|
* Schedule a callback to run after this response resolver completes.
|
|
174
174
|
* Handy for cleaning up the side effects introduced in the resolver.
|
|
175
|
+
*
|
|
176
|
+
* For responses with a `ReadableStream` body (including `sse()` handlers),
|
|
177
|
+
* the callback runs once the response stream settles: it is read to
|
|
178
|
+
* completion, errored, or canceled, or the request is aborted.
|
|
175
179
|
* @example
|
|
176
180
|
* sse('/', ({ client, finalize }) => {
|
|
177
181
|
* const interval = setInterval(() => client.send({ data: 'ping' }))
|
|
@@ -279,7 +283,21 @@ declare abstract class RequestHandler<HandlerInfo extends RequestHandlerDefaultI
|
|
|
279
283
|
private createExecutionResult;
|
|
280
284
|
private scheduleCleanup;
|
|
281
285
|
private exhaustCleanups;
|
|
286
|
+
/**
|
|
287
|
+
* Remove and return the cleanups scheduled for the given request
|
|
288
|
+
* (or the pending iterator cleanups for generator resolvers).
|
|
289
|
+
*/
|
|
290
|
+
private takeScheduledCleanups;
|
|
282
291
|
private runScheduledCleanups;
|
|
292
|
+
/**
|
|
293
|
+
* Conclude the response resolution for the given request.
|
|
294
|
+
* Runs the scheduled cleanups immediately for responses without a
|
|
295
|
+
* `ReadableStream` body. For streamed responses, returns an observed
|
|
296
|
+
* copy of the response and defers the cleanups until its body settles
|
|
297
|
+
* (is read to completion, errored, or canceled) or the request is
|
|
298
|
+
* aborted, whichever comes first.
|
|
299
|
+
*/
|
|
300
|
+
private complete;
|
|
283
301
|
}
|
|
284
302
|
/**
|
|
285
303
|
* Forwards the cookies from the given response to `document.cookie`.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import '@mswjs/interceptors';
|
|
2
|
-
export { Q as DefaultUnsafeFetchResponse, H as HttpResponse, i as HttpResponseInit, S as StrictRequest, o as StrictResponse, T as bodyType, U as kDefaultContentType } from './HttpResponse-
|
|
2
|
+
export { Q as DefaultUnsafeFetchResponse, H as HttpResponse, i as HttpResponseInit, S as StrictRequest, o as StrictResponse, T as bodyType, U as kDefaultContentType } from './HttpResponse-BE_Y2Ak9.mjs';
|
|
3
3
|
import './typeUtils.mjs';
|
|
4
4
|
import './utils/internal/isIterable.mjs';
|
|
5
5
|
import 'graphql';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import '@mswjs/interceptors';
|
|
2
|
-
export { Q as DefaultUnsafeFetchResponse, H as HttpResponse, i as HttpResponseInit, S as StrictRequest, o as StrictResponse, T as bodyType, U as kDefaultContentType } from './HttpResponse-
|
|
2
|
+
export { Q as DefaultUnsafeFetchResponse, H as HttpResponse, i as HttpResponseInit, S as StrictRequest, o as StrictResponse, T as bodyType, U as kDefaultContentType } from './HttpResponse-DL-P1EeG.js';
|
|
3
3
|
import './typeUtils.js';
|
|
4
4
|
import './utils/internal/isIterable.js';
|
|
5
5
|
import 'graphql';
|
|
@@ -2,7 +2,7 @@ import { UnhandledRequestStrategy } from '../utils/request/onUnhandledRequest.mj
|
|
|
2
2
|
import { U as UnhandledFrameCallback } from '../on-unhandled-frame-gkokW4Rr.mjs';
|
|
3
3
|
import 'rettime';
|
|
4
4
|
import './handlers-controller.mjs';
|
|
5
|
-
import '../HttpResponse-
|
|
5
|
+
import '../HttpResponse-BE_Y2Ak9.mjs';
|
|
6
6
|
import '@mswjs/interceptors';
|
|
7
7
|
import '../utils/internal/isIterable.mjs';
|
|
8
8
|
import '../typeUtils.mjs';
|
|
@@ -2,7 +2,7 @@ import { UnhandledRequestStrategy } from '../utils/request/onUnhandledRequest.js
|
|
|
2
2
|
import { U as UnhandledFrameCallback } from '../on-unhandled-frame-0KmwUmeV.js';
|
|
3
3
|
import 'rettime';
|
|
4
4
|
import './handlers-controller.js';
|
|
5
|
-
import '../HttpResponse-
|
|
5
|
+
import '../HttpResponse-DL-P1EeG.js';
|
|
6
6
|
import '@mswjs/interceptors';
|
|
7
7
|
import '../utils/internal/isIterable.js';
|
|
8
8
|
import '../typeUtils.js';
|
|
@@ -2,7 +2,7 @@ import { Emitter, DefaultEventMap } from 'rettime';
|
|
|
2
2
|
import { NetworkSource, ExtractSourceEvents } from './sources/network-source.mjs';
|
|
3
3
|
import { a as NetworkFrameResolutionContext, b as UnhandledFrameHandle } from '../on-unhandled-frame-gkokW4Rr.mjs';
|
|
4
4
|
import { AnyHandler, HandlersController } from './handlers-controller.mjs';
|
|
5
|
-
import '../HttpResponse-
|
|
5
|
+
import '../HttpResponse-BE_Y2Ak9.mjs';
|
|
6
6
|
import '@mswjs/interceptors';
|
|
7
7
|
import '../utils/internal/isIterable.mjs';
|
|
8
8
|
import '../typeUtils.mjs';
|
|
@@ -2,7 +2,7 @@ import { Emitter, DefaultEventMap } from 'rettime';
|
|
|
2
2
|
import { NetworkSource, ExtractSourceEvents } from './sources/network-source.js';
|
|
3
3
|
import { a as NetworkFrameResolutionContext, b as UnhandledFrameHandle } from '../on-unhandled-frame-0KmwUmeV.js';
|
|
4
4
|
import { AnyHandler, HandlersController } from './handlers-controller.js';
|
|
5
|
-
import '../HttpResponse-
|
|
5
|
+
import '../HttpResponse-DL-P1EeG.js';
|
|
6
6
|
import '@mswjs/interceptors';
|
|
7
7
|
import '../utils/internal/isIterable.js';
|
|
8
8
|
import '../typeUtils.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TypedEvent } from 'rettime';
|
|
2
2
|
import { N as NetworkFrame, b as UnhandledFrameHandle, a as NetworkFrameResolutionContext } from '../../on-unhandled-frame-gkokW4Rr.mjs';
|
|
3
3
|
import { HandlersController, AnyHandler } from '../handlers-controller.mjs';
|
|
4
|
-
import { R as RequestHandler } from '../../HttpResponse-
|
|
4
|
+
import { R as RequestHandler } from '../../HttpResponse-BE_Y2Ak9.mjs';
|
|
5
5
|
import '../../handlers/WebSocketHandler.mjs';
|
|
6
6
|
import 'strict-event-emitter';
|
|
7
7
|
import '@mswjs/interceptors/WebSocket';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TypedEvent } from 'rettime';
|
|
2
2
|
import { N as NetworkFrame, b as UnhandledFrameHandle, a as NetworkFrameResolutionContext } from '../../on-unhandled-frame-0KmwUmeV.js';
|
|
3
3
|
import { HandlersController, AnyHandler } from '../handlers-controller.js';
|
|
4
|
-
import { R as RequestHandler } from '../../HttpResponse-
|
|
4
|
+
import { R as RequestHandler } from '../../HttpResponse-DL-P1EeG.js';
|
|
5
5
|
import '../../handlers/WebSocketHandler.js';
|
|
6
6
|
import 'strict-event-emitter';
|
|
7
7
|
import '@mswjs/interceptors/WebSocket';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import 'rettime';
|
|
2
2
|
import '../handlers-controller.mjs';
|
|
3
3
|
export { A as AnyNetworkFrame, E as ExtractFrameEvents, N as NetworkFrame, a as NetworkFrameResolutionContext } from '../../on-unhandled-frame-gkokW4Rr.mjs';
|
|
4
|
-
import '../../HttpResponse-
|
|
4
|
+
import '../../HttpResponse-BE_Y2Ak9.mjs';
|
|
5
5
|
import '@mswjs/interceptors';
|
|
6
6
|
import '../../utils/internal/isIterable.mjs';
|
|
7
7
|
import '../../typeUtils.mjs';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import 'rettime';
|
|
2
2
|
import '../handlers-controller.js';
|
|
3
3
|
export { A as AnyNetworkFrame, E as ExtractFrameEvents, N as NetworkFrame, a as NetworkFrameResolutionContext } from '../../on-unhandled-frame-0KmwUmeV.js';
|
|
4
|
-
import '../../HttpResponse-
|
|
4
|
+
import '../../HttpResponse-DL-P1EeG.js';
|
|
5
5
|
import '@mswjs/interceptors';
|
|
6
6
|
import '../../utils/internal/isIterable.js';
|
|
7
7
|
import '../../typeUtils.js';
|
|
@@ -5,7 +5,7 @@ import { N as NetworkFrame, b as UnhandledFrameHandle, a as NetworkFrameResoluti
|
|
|
5
5
|
import { HandlersController, AnyHandler } from '../handlers-controller.mjs';
|
|
6
6
|
import 'strict-event-emitter';
|
|
7
7
|
import '../../utils/matching/matchRequestUrl.mjs';
|
|
8
|
-
import '../../HttpResponse-
|
|
8
|
+
import '../../HttpResponse-BE_Y2Ak9.mjs';
|
|
9
9
|
import '@mswjs/interceptors';
|
|
10
10
|
import '../../utils/internal/isIterable.mjs';
|
|
11
11
|
import '../../typeUtils.mjs';
|
|
@@ -5,7 +5,7 @@ import { N as NetworkFrame, b as UnhandledFrameHandle, a as NetworkFrameResoluti
|
|
|
5
5
|
import { HandlersController, AnyHandler } from '../handlers-controller.js';
|
|
6
6
|
import 'strict-event-emitter';
|
|
7
7
|
import '../../utils/matching/matchRequestUrl.js';
|
|
8
|
-
import '../../HttpResponse-
|
|
8
|
+
import '../../HttpResponse-DL-P1EeG.js';
|
|
9
9
|
import '@mswjs/interceptors';
|
|
10
10
|
import '../../utils/internal/isIterable.js';
|
|
11
11
|
import '../../typeUtils.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { R as RequestHandler } from '../HttpResponse-
|
|
1
|
+
import { R as RequestHandler } from '../HttpResponse-BE_Y2Ak9.mjs';
|
|
2
2
|
import { WebSocketHandler } from '../handlers/WebSocketHandler.mjs';
|
|
3
3
|
import '@mswjs/interceptors';
|
|
4
4
|
import '../utils/internal/isIterable.mjs';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { R as RequestHandler } from '../HttpResponse-
|
|
1
|
+
import { R as RequestHandler } from '../HttpResponse-DL-P1EeG.js';
|
|
2
2
|
import { WebSocketHandler } from '../handlers/WebSocketHandler.js';
|
|
3
3
|
import '@mswjs/interceptors';
|
|
4
4
|
import '../utils/internal/isIterable.js';
|
|
@@ -8,7 +8,7 @@ export { HandlersController, InMemoryHandlersController } from './handlers-contr
|
|
|
8
8
|
import 'rettime';
|
|
9
9
|
import '@mswjs/interceptors';
|
|
10
10
|
import '@mswjs/interceptors/WebSocket';
|
|
11
|
-
import '../HttpResponse-
|
|
11
|
+
import '../HttpResponse-BE_Y2Ak9.mjs';
|
|
12
12
|
import '../utils/internal/isIterable.mjs';
|
|
13
13
|
import '../typeUtils.mjs';
|
|
14
14
|
import 'graphql';
|
|
@@ -8,7 +8,7 @@ export { HandlersController, InMemoryHandlersController } from './handlers-contr
|
|
|
8
8
|
import 'rettime';
|
|
9
9
|
import '@mswjs/interceptors';
|
|
10
10
|
import '@mswjs/interceptors/WebSocket';
|
|
11
|
-
import '../HttpResponse-
|
|
11
|
+
import '../HttpResponse-DL-P1EeG.js';
|
|
12
12
|
import '../utils/internal/isIterable.js';
|
|
13
13
|
import '../typeUtils.js';
|
|
14
14
|
import 'graphql';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { U as UnhandledFrameCallback, c as UnhandledFrameDefaults, b as UnhandledFrameHandle, d as UnhandledFrameStrategy, e as executeUnhandledFrameHandle } from '../on-unhandled-frame-gkokW4Rr.mjs';
|
|
2
2
|
import 'rettime';
|
|
3
3
|
import './handlers-controller.mjs';
|
|
4
|
-
import '../HttpResponse-
|
|
4
|
+
import '../HttpResponse-BE_Y2Ak9.mjs';
|
|
5
5
|
import '@mswjs/interceptors';
|
|
6
6
|
import '../utils/internal/isIterable.mjs';
|
|
7
7
|
import '../typeUtils.mjs';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { U as UnhandledFrameCallback, c as UnhandledFrameDefaults, b as UnhandledFrameHandle, d as UnhandledFrameStrategy, e as executeUnhandledFrameHandle } from '../on-unhandled-frame-0KmwUmeV.js';
|
|
2
2
|
import 'rettime';
|
|
3
3
|
import './handlers-controller.js';
|
|
4
|
-
import '../HttpResponse-
|
|
4
|
+
import '../HttpResponse-DL-P1EeG.js';
|
|
5
5
|
import '@mswjs/interceptors';
|
|
6
6
|
import '../utils/internal/isIterable.js';
|
|
7
7
|
import '../typeUtils.js';
|
|
@@ -3,7 +3,7 @@ import { LifeCycleEventEmitter } from '../sharedOptions.mjs';
|
|
|
3
3
|
import { HandlersController, AnyHandler } from './handlers-controller.mjs';
|
|
4
4
|
import { Disposable } from '../utils/internal/Disposable.mjs';
|
|
5
5
|
import '../utils/request/onUnhandledRequest.mjs';
|
|
6
|
-
import '../HttpResponse-
|
|
6
|
+
import '../HttpResponse-BE_Y2Ak9.mjs';
|
|
7
7
|
import '@mswjs/interceptors';
|
|
8
8
|
import '../utils/internal/isIterable.mjs';
|
|
9
9
|
import '../typeUtils.mjs';
|
|
@@ -3,7 +3,7 @@ import { LifeCycleEventEmitter } from '../sharedOptions.js';
|
|
|
3
3
|
import { HandlersController, AnyHandler } from './handlers-controller.js';
|
|
4
4
|
import { Disposable } from '../utils/internal/Disposable.js';
|
|
5
5
|
import '../utils/request/onUnhandledRequest.js';
|
|
6
|
-
import '../HttpResponse-
|
|
6
|
+
import '../HttpResponse-DL-P1EeG.js';
|
|
7
7
|
import '@mswjs/interceptors';
|
|
8
8
|
import '../utils/internal/isIterable.js';
|
|
9
9
|
import '../typeUtils.js';
|
|
@@ -4,7 +4,7 @@ import { NetworkSource } from './network-source.mjs';
|
|
|
4
4
|
import 'rettime';
|
|
5
5
|
import '../../on-unhandled-frame-gkokW4Rr.mjs';
|
|
6
6
|
import '../handlers-controller.mjs';
|
|
7
|
-
import '../../HttpResponse-
|
|
7
|
+
import '../../HttpResponse-BE_Y2Ak9.mjs';
|
|
8
8
|
import '../../utils/internal/isIterable.mjs';
|
|
9
9
|
import '../../typeUtils.mjs';
|
|
10
10
|
import 'graphql';
|
|
@@ -4,7 +4,7 @@ import { NetworkSource } from './network-source.js';
|
|
|
4
4
|
import 'rettime';
|
|
5
5
|
import '../../on-unhandled-frame-0KmwUmeV.js';
|
|
6
6
|
import '../handlers-controller.js';
|
|
7
|
-
import '../../HttpResponse-
|
|
7
|
+
import '../../HttpResponse-DL-P1EeG.js';
|
|
8
8
|
import '../../utils/internal/isIterable.js';
|
|
9
9
|
import '../../typeUtils.js';
|
|
10
10
|
import 'graphql';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Emitter, TypedEvent, TypedListenerOptions } from 'rettime';
|
|
2
2
|
import { A as AnyNetworkFrame, E as ExtractFrameEvents } from '../../on-unhandled-frame-gkokW4Rr.mjs';
|
|
3
3
|
import '../handlers-controller.mjs';
|
|
4
|
-
import '../../HttpResponse-
|
|
4
|
+
import '../../HttpResponse-BE_Y2Ak9.mjs';
|
|
5
5
|
import '@mswjs/interceptors';
|
|
6
6
|
import '../../utils/internal/isIterable.mjs';
|
|
7
7
|
import '../../typeUtils.mjs';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Emitter, TypedEvent, TypedListenerOptions } from 'rettime';
|
|
2
2
|
import { A as AnyNetworkFrame, E as ExtractFrameEvents } from '../../on-unhandled-frame-0KmwUmeV.js';
|
|
3
3
|
import '../handlers-controller.js';
|
|
4
|
-
import '../../HttpResponse-
|
|
4
|
+
import '../../HttpResponse-DL-P1EeG.js';
|
|
5
5
|
import '@mswjs/interceptors';
|
|
6
6
|
import '../../utils/internal/isIterable.js';
|
|
7
7
|
import '../../typeUtils.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { R as RequestHandler, k as ResponseResolutionContext } from './HttpResponse-
|
|
1
|
+
import { R as RequestHandler, k as ResponseResolutionContext } from './HttpResponse-BE_Y2Ak9.mjs';
|
|
2
2
|
import '@mswjs/interceptors';
|
|
3
3
|
import './utils/internal/isIterable.mjs';
|
|
4
4
|
import './typeUtils.mjs';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { R as RequestHandler, k as ResponseResolutionContext } from './HttpResponse-
|
|
1
|
+
import { R as RequestHandler, k as ResponseResolutionContext } from './HttpResponse-DL-P1EeG.js';
|
|
2
2
|
import '@mswjs/interceptors';
|
|
3
3
|
import './utils/internal/isIterable.js';
|
|
4
4
|
import './typeUtils.js';
|
package/lib/core/graphql.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { e as GraphQLQuery, h as GraphQLVariables, p as GraphQLPredicate, l as ResponseResolver, q as GraphQLResolverExtras, g as GraphQLResponseBody, j as RequestHandlerOptions, b as GraphQLHandler } from './HttpResponse-
|
|
1
|
+
import { e as GraphQLQuery, h as GraphQLVariables, p as GraphQLPredicate, l as ResponseResolver, q as GraphQLResolverExtras, g as GraphQLResponseBody, j as RequestHandlerOptions, b as GraphQLHandler } from './HttpResponse-BE_Y2Ak9.mjs';
|
|
2
2
|
import { Path } from './utils/matching/matchRequestUrl.mjs';
|
|
3
3
|
import '@mswjs/interceptors';
|
|
4
4
|
import './utils/internal/isIterable.mjs';
|
package/lib/core/graphql.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { e as GraphQLQuery, h as GraphQLVariables, p as GraphQLPredicate, l as ResponseResolver, q as GraphQLResolverExtras, g as GraphQLResponseBody, j as RequestHandlerOptions, b as GraphQLHandler } from './HttpResponse-
|
|
1
|
+
import { e as GraphQLQuery, h as GraphQLVariables, p as GraphQLPredicate, l as ResponseResolver, q as GraphQLResolverExtras, g as GraphQLResponseBody, j as RequestHandlerOptions, b as GraphQLHandler } from './HttpResponse-DL-P1EeG.js';
|
|
2
2
|
import { Path } from './utils/matching/matchRequestUrl.js';
|
|
3
3
|
import '@mswjs/interceptors';
|
|
4
4
|
import './utils/internal/isIterable.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import 'graphql';
|
|
2
|
-
export { z as DocumentTypeDecoration, G as GraphQLCustomPredicate, B as GraphQLCustomPredicateResult, b as GraphQLHandler, C as GraphQLHandlerInfo, E as GraphQLHandlerNameSelector, c as GraphQLJsonRequestBody, d as GraphQLOperationType, p as GraphQLPredicate, e as GraphQLQuery, f as GraphQLRequestBody, F as GraphQLRequestParsedResult, q as GraphQLResolverExtras, g as GraphQLResponseBody, h as GraphQLVariables, I as isDocumentNode } from '../HttpResponse-
|
|
2
|
+
export { z as DocumentTypeDecoration, G as GraphQLCustomPredicate, B as GraphQLCustomPredicateResult, b as GraphQLHandler, C as GraphQLHandlerInfo, E as GraphQLHandlerNameSelector, c as GraphQLJsonRequestBody, d as GraphQLOperationType, p as GraphQLPredicate, e as GraphQLQuery, f as GraphQLRequestBody, F as GraphQLRequestParsedResult, q as GraphQLResolverExtras, g as GraphQLResponseBody, h as GraphQLVariables, I as isDocumentNode } from '../HttpResponse-BE_Y2Ak9.mjs';
|
|
3
3
|
import '../utils/matching/matchRequestUrl.mjs';
|
|
4
4
|
import '@mswjs/interceptors';
|
|
5
5
|
import '../utils/internal/isIterable.mjs';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import 'graphql';
|
|
2
|
-
export { z as DocumentTypeDecoration, G as GraphQLCustomPredicate, B as GraphQLCustomPredicateResult, b as GraphQLHandler, C as GraphQLHandlerInfo, E as GraphQLHandlerNameSelector, c as GraphQLJsonRequestBody, d as GraphQLOperationType, p as GraphQLPredicate, e as GraphQLQuery, f as GraphQLRequestBody, F as GraphQLRequestParsedResult, q as GraphQLResolverExtras, g as GraphQLResponseBody, h as GraphQLVariables, I as isDocumentNode } from '../HttpResponse-
|
|
2
|
+
export { z as DocumentTypeDecoration, G as GraphQLCustomPredicate, B as GraphQLCustomPredicateResult, b as GraphQLHandler, C as GraphQLHandlerInfo, E as GraphQLHandlerNameSelector, c as GraphQLJsonRequestBody, d as GraphQLOperationType, p as GraphQLPredicate, e as GraphQLQuery, f as GraphQLRequestBody, F as GraphQLRequestParsedResult, q as GraphQLResolverExtras, g as GraphQLResponseBody, h as GraphQLVariables, I as isDocumentNode } from '../HttpResponse-DL-P1EeG.js';
|
|
3
3
|
import '../utils/matching/matchRequestUrl.js';
|
|
4
4
|
import '@mswjs/interceptors';
|
|
5
5
|
import '../utils/internal/isIterable.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { R as RequestHandler, r as RequestHandlerDefaultInfo, l as ResponseResolver, j as RequestHandlerOptions, k as ResponseResolutionContext } from '../HttpResponse-
|
|
1
|
+
import { R as RequestHandler, r as RequestHandlerDefaultInfo, l as ResponseResolver, j as RequestHandlerOptions, k as ResponseResolutionContext } from '../HttpResponse-BE_Y2Ak9.mjs';
|
|
2
2
|
import { PathParams, Path, Match } from '../utils/matching/matchRequestUrl.mjs';
|
|
3
3
|
import '@mswjs/interceptors';
|
|
4
4
|
import '../utils/internal/isIterable.mjs';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { R as RequestHandler, r as RequestHandlerDefaultInfo, l as ResponseResolver, j as RequestHandlerOptions, k as ResponseResolutionContext } from '../HttpResponse-
|
|
1
|
+
import { R as RequestHandler, r as RequestHandlerDefaultInfo, l as ResponseResolver, j as RequestHandlerOptions, k as ResponseResolutionContext } from '../HttpResponse-DL-P1EeG.js';
|
|
2
2
|
import { PathParams, Path, Match } from '../utils/matching/matchRequestUrl.js';
|
|
3
3
|
import '@mswjs/interceptors';
|
|
4
4
|
import '../utils/internal/isIterable.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import '../utils/internal/isIterable.mjs';
|
|
2
|
-
export { A as AsyncResponseResolverReturnType, D as DefaultBodyType, a as DefaultRequestMultipartBody, J as JsonBodyType, M as MaybeAsyncResponseResolverReturnType, R as RequestHandler, K as RequestHandlerArgs, r as RequestHandlerDefaultInfo, L as RequestHandlerExecutionResult, N as RequestHandlerInternalInfo, j as RequestHandlerOptions, l as ResponseResolver, m as ResponseResolverInfo, n as ResponseResolverReturnType, O as forwardResponseCookies } from '../HttpResponse-
|
|
2
|
+
export { A as AsyncResponseResolverReturnType, D as DefaultBodyType, a as DefaultRequestMultipartBody, J as JsonBodyType, M as MaybeAsyncResponseResolverReturnType, R as RequestHandler, K as RequestHandlerArgs, r as RequestHandlerDefaultInfo, L as RequestHandlerExecutionResult, N as RequestHandlerInternalInfo, j as RequestHandlerOptions, l as ResponseResolver, m as ResponseResolverInfo, n as ResponseResolverReturnType, O as forwardResponseCookies } from '../HttpResponse-BE_Y2Ak9.mjs';
|
|
3
3
|
import '../typeUtils.mjs';
|
|
4
4
|
import '@mswjs/interceptors';
|
|
5
5
|
import 'graphql';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import '../utils/internal/isIterable.js';
|
|
2
|
-
export { A as AsyncResponseResolverReturnType, D as DefaultBodyType, a as DefaultRequestMultipartBody, J as JsonBodyType, M as MaybeAsyncResponseResolverReturnType, R as RequestHandler, K as RequestHandlerArgs, r as RequestHandlerDefaultInfo, L as RequestHandlerExecutionResult, N as RequestHandlerInternalInfo, j as RequestHandlerOptions, l as ResponseResolver, m as ResponseResolverInfo, n as ResponseResolverReturnType, O as forwardResponseCookies } from '../HttpResponse-
|
|
2
|
+
export { A as AsyncResponseResolverReturnType, D as DefaultBodyType, a as DefaultRequestMultipartBody, J as JsonBodyType, M as MaybeAsyncResponseResolverReturnType, R as RequestHandler, K as RequestHandlerArgs, r as RequestHandlerDefaultInfo, L as RequestHandlerExecutionResult, N as RequestHandlerInternalInfo, j as RequestHandlerOptions, l as ResponseResolver, m as ResponseResolverInfo, n as ResponseResolverReturnType, O as forwardResponseCookies } from '../HttpResponse-DL-P1EeG.js';
|
|
3
3
|
import '../typeUtils.js';
|
|
4
4
|
import '@mswjs/interceptors';
|
|
5
5
|
import 'graphql';
|
|
@@ -28,6 +28,7 @@ var import_isIterable = require("../utils/internal/isIterable");
|
|
|
28
28
|
var import_HttpResponse = require("../HttpResponse");
|
|
29
29
|
var import_devUtils = require("../utils/internal/devUtils");
|
|
30
30
|
var import_decorators = require("../utils/HttpResponse/decorators");
|
|
31
|
+
var import_observe_response_body_stream = require("../utils/internal/observe-response-body-stream");
|
|
31
32
|
class RequestHandler {
|
|
32
33
|
static cache = /* @__PURE__ */ new WeakMap();
|
|
33
34
|
kind = "request";
|
|
@@ -152,18 +153,32 @@ class RequestHandler {
|
|
|
152
153
|
parsedResult
|
|
153
154
|
});
|
|
154
155
|
const listenerController = new AbortController();
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
(
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
156
|
+
let finalizeFunction;
|
|
157
|
+
const getFinalize = () => {
|
|
158
|
+
if (finalizeFunction == null) {
|
|
159
|
+
if (!args.request.signal.aborted) {
|
|
160
|
+
args.request.signal.addEventListener(
|
|
161
|
+
"abort",
|
|
162
|
+
() => this.runScheduledCleanups(args.requestId),
|
|
163
|
+
{
|
|
164
|
+
once: true,
|
|
165
|
+
signal: listenerController.signal
|
|
166
|
+
}
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
finalizeFunction = (callback) => {
|
|
170
|
+
this.scheduleCleanup(args.requestId, callback);
|
|
171
|
+
if (args.request.signal.aborted) {
|
|
172
|
+
void this.runScheduledCleanups(args.requestId);
|
|
173
|
+
}
|
|
174
|
+
};
|
|
161
175
|
}
|
|
162
|
-
|
|
176
|
+
return finalizeFunction;
|
|
177
|
+
};
|
|
163
178
|
const mockedResponsePromise = executeResolver({
|
|
164
179
|
...resolverExtras,
|
|
165
|
-
finalize
|
|
166
|
-
|
|
180
|
+
get finalize() {
|
|
181
|
+
return getFinalize();
|
|
167
182
|
},
|
|
168
183
|
requestId: args.requestId,
|
|
169
184
|
request: args.request
|
|
@@ -200,8 +215,11 @@ class RequestHandler {
|
|
|
200
215
|
throw error;
|
|
201
216
|
}
|
|
202
217
|
if (!(0, import_isIterable.isIterable)(result)) {
|
|
203
|
-
|
|
204
|
-
|
|
218
|
+
return this.complete({
|
|
219
|
+
request: info.request,
|
|
220
|
+
requestId: info.requestId,
|
|
221
|
+
response: result
|
|
222
|
+
});
|
|
205
223
|
}
|
|
206
224
|
const existingCleanups = this.scheduledCleanups.get(info.requestId);
|
|
207
225
|
if (existingCleanups != null && existingCleanups.length > 0) {
|
|
@@ -218,8 +236,11 @@ class RequestHandler {
|
|
|
218
236
|
}
|
|
219
237
|
if (done) {
|
|
220
238
|
this.isUsed = true;
|
|
221
|
-
|
|
222
|
-
|
|
239
|
+
return this.complete({
|
|
240
|
+
request: info.request,
|
|
241
|
+
requestId: info.requestId,
|
|
242
|
+
response: this.resolverIteratorResult?.clone()
|
|
243
|
+
});
|
|
223
244
|
}
|
|
224
245
|
return nextResponse;
|
|
225
246
|
};
|
|
@@ -265,21 +286,65 @@ class RequestHandler {
|
|
|
265
286
|
);
|
|
266
287
|
}
|
|
267
288
|
}
|
|
268
|
-
|
|
289
|
+
/**
|
|
290
|
+
* Remove and return the cleanups scheduled for the given request
|
|
291
|
+
* (or the pending iterator cleanups for generator resolvers).
|
|
292
|
+
*/
|
|
293
|
+
takeScheduledCleanups(requestId) {
|
|
269
294
|
if (this.resolverIterator && this.resolverIteratorCleanups != null && this.resolverIteratorCleanups.length > 0) {
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
this.resolverIteratorCleanups = void 0;
|
|
274
|
-
}
|
|
275
|
-
return;
|
|
295
|
+
const cleanups2 = this.resolverIteratorCleanups;
|
|
296
|
+
this.resolverIteratorCleanups = void 0;
|
|
297
|
+
return cleanups2;
|
|
276
298
|
}
|
|
277
299
|
const cleanups = this.scheduledCleanups.get(requestId);
|
|
278
|
-
if (!cleanups || cleanups.length
|
|
279
|
-
return;
|
|
300
|
+
if (!cleanups || cleanups.length === 0) {
|
|
301
|
+
return void 0;
|
|
280
302
|
}
|
|
281
|
-
await this.exhaustCleanups(cleanups);
|
|
282
303
|
this.scheduledCleanups.delete(requestId);
|
|
304
|
+
return cleanups;
|
|
305
|
+
}
|
|
306
|
+
async runScheduledCleanups(requestId) {
|
|
307
|
+
const cleanups = this.takeScheduledCleanups(requestId);
|
|
308
|
+
if (cleanups) {
|
|
309
|
+
await this.exhaustCleanups(cleanups);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Conclude the response resolution for the given request.
|
|
314
|
+
* Runs the scheduled cleanups immediately for responses without a
|
|
315
|
+
* `ReadableStream` body. For streamed responses, returns an observed
|
|
316
|
+
* copy of the response and defers the cleanups until its body settles
|
|
317
|
+
* (is read to completion, errored, or canceled) or the request is
|
|
318
|
+
* aborted, whichever comes first.
|
|
319
|
+
*/
|
|
320
|
+
async complete(args) {
|
|
321
|
+
const cleanups = this.takeScheduledCleanups(args.requestId);
|
|
322
|
+
if (!cleanups) {
|
|
323
|
+
return args.response;
|
|
324
|
+
}
|
|
325
|
+
const observedResponse = args.response ? (0, import_observe_response_body_stream.observeResponseBodyStream)(args.response) : null;
|
|
326
|
+
if (!observedResponse) {
|
|
327
|
+
await this.exhaustCleanups(cleanups);
|
|
328
|
+
return args.response;
|
|
329
|
+
}
|
|
330
|
+
const listenerController = new AbortController();
|
|
331
|
+
const runCleanupsOnce = () => {
|
|
332
|
+
if (listenerController.signal.aborted) {
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
listenerController.abort();
|
|
336
|
+
void this.exhaustCleanups(cleanups);
|
|
337
|
+
};
|
|
338
|
+
void observedResponse.settled.then(runCleanupsOnce);
|
|
339
|
+
if (args.request.signal.aborted) {
|
|
340
|
+
runCleanupsOnce();
|
|
341
|
+
} else {
|
|
342
|
+
args.request.signal.addEventListener("abort", runCleanupsOnce, {
|
|
343
|
+
once: true,
|
|
344
|
+
signal: listenerController.signal
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
return observedResponse.response;
|
|
283
348
|
}
|
|
284
349
|
}
|
|
285
350
|
function forwardResponseCookies(response) {
|