msw 2.14.7 → 3.0.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 +8 -0
- package/cli/init.js +12 -9
- package/cli/invariant.js +2 -2
- package/lib/_chunks/attach-sibling-handlers.js +360 -0
- package/lib/_chunks/attach-sibling-handlers.js.map +1 -0
- package/lib/_chunks/colors.js +18 -0
- package/lib/_chunks/colors.js.map +1 -0
- package/lib/_chunks/cookie-store.js +348 -0
- package/lib/_chunks/cookie-store.js.map +1 -0
- package/lib/_chunks/execute-handlers.js +29 -0
- package/lib/_chunks/execute-handlers.js.map +1 -0
- package/lib/_chunks/handlers-controller.d.ts +262 -0
- package/lib/_chunks/has-ref-counted.js +9 -0
- package/lib/_chunks/has-ref-counted.js.map +1 -0
- package/lib/_chunks/http-handler.d.ts +72 -0
- package/lib/_chunks/http-handler.js +182 -0
- package/lib/_chunks/http-handler.js.map +1 -0
- package/lib/_chunks/http-response.js +137 -0
- package/lib/_chunks/http-response.js.map +1 -0
- package/lib/{core → _chunks}/http.d.ts +15 -18
- package/lib/_chunks/http.js +30 -0
- package/lib/_chunks/http.js.map +1 -0
- package/lib/_chunks/interceptor-source.d.ts +163 -0
- package/lib/_chunks/interceptor-source.js +756 -0
- package/lib/_chunks/interceptor-source.js.map +1 -0
- package/lib/_chunks/is-object.js +11 -0
- package/lib/_chunks/is-object.js.map +1 -0
- package/lib/_chunks/match-request-url.d.ts +14 -0
- package/lib/_chunks/request-handler.d.ts +295 -0
- package/lib/_chunks/request-handler.js +369 -0
- package/lib/_chunks/request-handler.js.map +1 -0
- package/lib/_chunks/shared-options.d.ts +20 -0
- package/lib/_chunks/sse.d.ts +95 -0
- package/lib/_chunks/sse.js +599 -0
- package/lib/_chunks/sse.js.map +1 -0
- package/lib/_chunks/symbols.js +22 -0
- package/lib/_chunks/symbols.js.map +1 -0
- package/lib/_chunks/websocket-upgrade.js +46 -0
- package/lib/_chunks/websocket-upgrade.js.map +1 -0
- package/lib/_chunks/ws.d.ts +133 -0
- package/lib/_chunks/ws.js +293 -0
- package/lib/_chunks/ws.js.map +1 -0
- package/lib/browser/index.d.ts +225 -96
- package/lib/browser/index.js +555 -3694
- package/lib/browser/index.js.map +1 -1
- package/lib/core/experimental/index.d.ts +3 -17
- package/lib/core/experimental/index.js +2 -38
- package/lib/core/index.d.ts +15 -27
- package/lib/core/index.js +15 -64
- package/lib/graphql/index.d.ts +550 -0
- package/lib/graphql/index.js +1244 -0
- package/lib/graphql/index.js.map +1 -0
- package/lib/http/index.d.ts +4 -0
- package/lib/http/index.js +4 -0
- package/lib/iife/index.js +35857 -28289
- package/lib/iife/index.js.map +1 -1
- package/lib/mockServiceWorker.js +204 -93
- package/lib/node/index.d.ts +79 -104
- package/lib/node/index.js +103 -201
- package/lib/node/index.js.map +1 -1
- package/lib/sse/index.d.ts +2 -0
- package/lib/sse/index.js +2 -0
- package/lib/{core → utils}/bypass.d.ts +5 -4
- package/lib/utils/bypass.js +41 -0
- package/lib/utils/bypass.js.map +1 -0
- package/lib/utils/delay.d.ts +15 -0
- package/lib/utils/delay.js +45 -0
- package/lib/utils/delay.js.map +1 -0
- package/lib/utils/get-clean-url-string.d.ts +9 -0
- package/lib/utils/get-clean-url-string.js +15 -0
- package/lib/utils/get-clean-url-string.js.map +1 -0
- package/lib/utils/get-response.d.ts +13 -0
- package/lib/utils/get-response.js +23 -0
- package/lib/utils/get-response.js.map +1 -0
- package/lib/utils/is-common-asset-request.d.ts +22 -0
- package/lib/utils/is-common-asset-request.js +31 -0
- package/lib/utils/is-common-asset-request.js.map +1 -0
- package/lib/utils/passthrough.d.ts +31 -0
- package/lib/utils/passthrough.js +41 -0
- package/lib/utils/passthrough.js.map +1 -0
- package/lib/vite/index.d.ts +44 -0
- package/lib/vite/index.js +90 -0
- package/lib/vite/index.js.map +1 -0
- package/lib/vite/runtime.d.ts +6 -0
- package/lib/vite/runtime.js +77 -0
- package/lib/vite/runtime.js.map +1 -0
- package/lib/ws/index.d.ts +4 -0
- package/lib/ws/index.js +4 -0
- package/package.json +93 -201
- package/src/browser/default-network-options.ts +31 -0
- package/src/browser/glossary.ts +11 -23
- package/src/browser/index.ts +5 -1
- package/src/browser/setup-worker.ts +15 -68
- package/src/browser/sources/fallback-http-source.ts +1 -1
- package/src/browser/sources/service-worker-source.ts +76 -69
- package/src/browser/tsconfig.browser.json +4 -2
- package/src/browser/utils/{deserializeRequest.ts → deserialize-request.ts} +3 -4
- package/src/browser/utils/{getAbsoluteWorkerUrl.test.ts → get-absolute-worker-url.test.ts} +3 -3
- package/src/browser/utils/get-worker-instance.ts +2 -2
- package/src/browser/utils/should-invalidate-worker.test.ts +11 -11
- package/src/browser/utils/should-invalidate-worker.ts +1 -1
- package/src/browser/utils/validate-worker-scope.ts +1 -1
- package/src/browser/utils/{workerChannel.ts → worker-channel.ts} +42 -20
- package/src/core/experimental/define-network.test.ts +43 -8
- package/src/core/experimental/define-network.ts +32 -13
- package/src/core/experimental/frames/http-frame.test.ts +15 -13
- package/src/core/experimental/frames/http-frame.ts +10 -9
- package/src/core/experimental/frames/websocket-frame.test.ts +129 -15
- package/src/core/experimental/frames/websocket-frame.ts +71 -20
- package/src/core/experimental/handlers-controller.test.ts +141 -34
- package/src/core/experimental/handlers-controller.ts +107 -30
- package/src/core/experimental/index.ts +1 -0
- package/src/core/experimental/on-unhandled-frame.test.ts +19 -19
- package/src/core/experimental/on-unhandled-frame.ts +7 -12
- package/src/core/experimental/request-utils.test.ts +4 -29
- package/src/core/experimental/request-utils.ts +0 -14
- package/src/core/experimental/sources/interceptor-source.ts +44 -29
- package/src/core/experimental/sources/network-source.test.ts +3 -3
- package/src/core/experimental/sources/network-source.ts +3 -3
- package/src/core/handlers/handler.ts +42 -0
- package/src/core/handlers/{RequestHandler.ts → request-handler.ts} +168 -73
- package/src/core/index.ts +35 -58
- package/src/core/shared-options.ts +21 -0
- package/src/core/type-utils.ts +18 -0
- package/src/core/utils/{cookieStore.ts → cookie-store.ts} +14 -9
- package/src/core/utils/{executeHandlers.ts → execute-handlers.ts} +2 -2
- package/src/core/utils/http-status-messages.ts +69 -0
- package/src/core/utils/internal/{attachSiblingHandlers.ts → attach-sibling-handlers.ts} +20 -0
- package/src/core/utils/internal/{devUtils.test.ts → dev-utils.test.ts} +3 -3
- package/src/core/utils/internal/{Disposable.ts → disposable.ts} +1 -1
- package/src/core/utils/internal/{getCallFrame.test.ts → get-call-frame.test.ts} +1 -1
- package/src/core/utils/internal/{getCallFrame.ts → get-call-frame.ts} +1 -1
- package/src/core/utils/internal/{hasRefCounted.test.ts → has-ref-counted.test.ts} +4 -4
- package/src/core/utils/internal/{hasRefCounted.ts → has-ref-counted.ts} +1 -1
- package/src/core/utils/internal/{isIterable.test.ts → is-iterable.test.ts} +1 -1
- package/src/core/utils/internal/is-iterable.ts +16 -0
- package/src/core/utils/internal/{isObject.test.ts → is-object.test.ts} +1 -1
- package/src/core/utils/internal/{isStringEqual.test.ts → is-string-equal.test.ts} +7 -7
- package/src/core/utils/internal/{jsonParse.test.ts → json-parse.test.ts} +1 -1
- package/src/core/utils/internal/observe-response-body-stream.test.ts +64 -0
- package/src/core/utils/internal/observe-response-body-stream.ts +76 -0
- package/src/core/utils/internal/{parseMultipartData.test.ts → parse-multipart-data.test.ts} +1 -1
- package/src/core/utils/internal/{parseMultipartData.ts → parse-multipart-data.ts} +1 -1
- package/src/core/utils/internal/{toReadonlyArray.test.ts → to-readonly-array.test.ts} +4 -4
- package/src/core/utils/logging/colors.ts +13 -0
- package/src/core/utils/logging/{getStatusCodeColor.test.ts → get-status-code-color.test.ts} +1 -1
- package/src/core/utils/logging/{getTimestamp.test.ts → get-timestamp.test.ts} +1 -1
- package/src/core/utils/logging/{serializeRequest.test.ts → serialize-request.test.ts} +1 -1
- package/src/core/utils/logging/{serializeResponse.test.ts → serialize-response.test.ts} +8 -10
- package/src/core/utils/logging/{serializeResponse.ts → serialize-response.ts} +2 -4
- package/src/core/utils/matching/match-request-url.test.ts +90 -0
- package/src/core/utils/matching/match-request-url.ts +45 -0
- package/src/core/utils/matching/{normalizePath.node.test.ts → normalize-path.node.test.ts} +2 -4
- package/src/core/utils/matching/{normalizePath.test.ts → normalize-path.test.ts} +2 -4
- package/src/core/utils/matching/{normalizePath.ts → normalize-path.ts} +8 -5
- package/src/core/utils/request/{getAllAcceptedMimeTypes.test.ts → get-all-accepted-mime-types.test.ts} +14 -14
- package/src/core/utils/request/get-request-cookies.ts +76 -0
- package/src/core/utils/request/store-response-cookies.ts +15 -0
- package/src/core/utils/request/{toPublicUrl.node.test.ts → to-public-url.node.test.ts} +1 -1
- package/src/core/utils/request/{toPublicUrl.test.ts → to-public-url.test.ts} +2 -2
- package/src/core/utils/{HttpResponse/decorators.ts → response-decorators.ts} +28 -9
- package/src/core/utils/url/{getAbsoluteUrl.node.test.ts → get-absolute-url.node.test.ts} +5 -7
- package/src/core/utils/url/{getAbsoluteUrl.test.ts → get-absolute-url.test.ts} +7 -7
- package/src/core/utils/url/{getAbsoluteUrl.ts → get-absolute-url.ts} +1 -1
- package/src/core/utils/url/is-absolute-url.test.ts +30 -0
- package/src/{core/handlers/GraphQLHandler.test.ts → graphql/graphql-handler.test.ts} +37 -36
- package/src/{core/handlers/GraphQLHandler.ts → graphql/graphql-handler.ts} +54 -41
- package/src/graphql/graphql-subscription-event.ts +39 -0
- package/src/graphql/graphql-subscription.test.ts +208 -0
- package/src/graphql/graphql-subscription.ts +1487 -0
- package/src/graphql/graphql.test.ts +14 -0
- package/src/graphql/graphql.ts +179 -0
- package/src/graphql/index.ts +34 -0
- package/src/{core/utils/internal/parseGraphQLRequest.test.ts → graphql/parse-graphql-request.test.ts} +47 -6
- package/src/{core/utils/internal/parseGraphQLRequest.ts → graphql/parse-graphql-request.ts} +59 -32
- package/src/{core/handlers/HttpHandler.test.ts → http/http-handler.test.ts} +107 -18
- package/src/{core/handlers/HttpHandler.ts → http/http-handler.ts} +16 -18
- package/src/{core/HttpResponse.test.ts → http/http-response.test.ts} +25 -27
- package/src/{core/HttpResponse.ts → http/http-response.ts} +15 -17
- package/src/{core → http}/http.ts +7 -7
- package/src/http/index.test.ts +19 -0
- package/src/http/index.ts +22 -0
- package/src/http/symbols.ts +19 -0
- package/src/iife/index.ts +2 -0
- package/src/mockServiceWorker.js +202 -91
- package/src/node/async-handlers-controller.test.ts +4 -4
- package/src/node/glossary.ts +8 -4
- package/src/node/index.ts +1 -6
- package/src/node/setup-server-common.ts +16 -73
- package/src/node/setup-server.ts +9 -40
- package/src/sse/index.test.ts +14 -0
- package/src/sse/index.ts +7 -0
- package/src/{core → sse}/sse.ts +105 -69
- package/src/tsconfig.core.build.json +5 -1
- package/src/tsconfig.core.json +8 -1
- package/src/tsconfig.node.json +1 -1
- package/src/tsconfig.src.json +1 -1
- package/src/{core → utils}/bypass.test.ts +22 -5
- package/src/{core → utils}/bypass.ts +11 -0
- package/src/{core → utils}/delay.ts +5 -5
- package/src/utils/get-clean-url-string.test.ts +24 -0
- package/src/utils/get-clean-url-string.ts +16 -0
- package/src/{core/getResponse.test.ts → utils/get-response.test.ts} +9 -9
- package/src/{core/getResponse.ts → utils/get-response.ts} +2 -2
- package/src/{core/isCommonAssetRequest.ts → utils/is-common-asset-request.ts} +4 -3
- package/src/utils/passthrough.test.ts +41 -0
- package/src/utils/passthrough.ts +46 -0
- package/src/vite/client.d.ts +16 -0
- package/src/vite/index.ts +4 -0
- package/src/vite/options.d.ts +5 -0
- package/src/vite/plugin.test.ts +918 -0
- package/src/vite/plugin.ts +133 -0
- package/src/vite/runtime.ts +117 -0
- package/src/vite/tsconfig.build.json +7 -0
- package/src/ws/index.ts +23 -0
- package/src/{core/ws/utils/attachWebSocketLogger.ts → ws/utils/attach-websocket-logger.ts} +45 -23
- package/src/{core/ws/utils/getMessageLength.test.ts → ws/utils/get-message-length.test.ts} +4 -4
- package/src/{core/ws/utils/getMessageLength.ts → ws/utils/get-message-length.ts} +1 -1
- package/src/{core/ws/utils/getPublicData.test.ts → ws/utils/get-public-data.test.ts} +7 -7
- package/src/ws/utils/get-public-data.ts +23 -0
- package/src/{core/ws/utils/truncateMessage.test.ts → ws/utils/truncate-message.test.ts} +3 -3
- package/src/{core/ws/WebSocketClientManager.test.ts → ws/websocket-client-manager.test.ts} +8 -9
- package/src/{core/ws/WebSocketClientManager.ts → ws/websocket-client-manager.ts} +24 -28
- package/src/{core/ws/WebSocketClientStore.ts → ws/websocket-client-store.ts} +2 -2
- package/src/{core/handlers/WebSocketHandler.test.ts → ws/websocket-handler.test.ts} +15 -15
- package/src/{core/handlers/WebSocketHandler.ts → ws/websocket-handler.ts} +144 -32
- package/src/{core/ws/WebSocketIndexedDBClientStore.ts → ws/websocket-indexeddb-client-store.ts} +12 -13
- package/src/{core/ws/WebSocketMemoryClientStore.ts → ws/websocket-memory-client-store.ts} +4 -4
- package/src/ws/websocket-upgrade.ts +83 -0
- package/src/{core → ws}/ws.test.ts +3 -4
- package/src/{core → ws}/ws.ts +106 -53
- package/browser/package.json +0 -31
- package/cli/package.json +0 -3
- package/config/package.json +0 -3
- package/config/scripts/postinstall.js +0 -36
- package/lib/browser/index.d.mts +0 -112
- package/lib/browser/index.mjs +0 -3706
- package/lib/browser/index.mjs.map +0 -1
- package/lib/core/HttpResponse-BTyqrRB6.d.mts +0 -371
- package/lib/core/HttpResponse-BXyXQFMJ.d.ts +0 -371
- package/lib/core/HttpResponse.d.mts +0 -6
- package/lib/core/HttpResponse.d.ts +0 -6
- package/lib/core/HttpResponse.js +0 -176
- package/lib/core/HttpResponse.js.map +0 -1
- package/lib/core/HttpResponse.mjs +0 -159
- package/lib/core/HttpResponse.mjs.map +0 -1
- package/lib/core/bypass.d.mts +0 -16
- package/lib/core/bypass.js +0 -42
- package/lib/core/bypass.js.map +0 -1
- package/lib/core/bypass.mjs +0 -22
- package/lib/core/bypass.mjs.map +0 -1
- package/lib/core/delay.d.mts +0 -18
- package/lib/core/delay.d.ts +0 -18
- package/lib/core/delay.js +0 -77
- package/lib/core/delay.js.map +0 -1
- package/lib/core/delay.mjs +0 -57
- package/lib/core/delay.mjs.map +0 -1
- package/lib/core/experimental/compat.d.mts +0 -17
- package/lib/core/experimental/compat.d.ts +0 -17
- package/lib/core/experimental/compat.js +0 -55
- package/lib/core/experimental/compat.js.map +0 -1
- package/lib/core/experimental/compat.mjs +0 -37
- package/lib/core/experimental/compat.mjs.map +0 -1
- package/lib/core/experimental/define-network.d.mts +0 -75
- package/lib/core/experimental/define-network.d.ts +0 -75
- package/lib/core/experimental/define-network.js +0 -134
- package/lib/core/experimental/define-network.js.map +0 -1
- package/lib/core/experimental/define-network.mjs +0 -119
- package/lib/core/experimental/define-network.mjs.map +0 -1
- package/lib/core/experimental/frames/http-frame.d.mts +0 -77
- package/lib/core/experimental/frames/http-frame.d.ts +0 -77
- package/lib/core/experimental/frames/http-frame.js +0 -197
- package/lib/core/experimental/frames/http-frame.js.map +0 -1
- package/lib/core/experimental/frames/http-frame.mjs +0 -181
- package/lib/core/experimental/frames/http-frame.mjs.map +0 -1
- package/lib/core/experimental/frames/network-frame.d.mts +0 -12
- package/lib/core/experimental/frames/network-frame.d.ts +0 -12
- package/lib/core/experimental/frames/network-frame.js +0 -35
- package/lib/core/experimental/frames/network-frame.js.map +0 -1
- package/lib/core/experimental/frames/network-frame.mjs +0 -15
- package/lib/core/experimental/frames/network-frame.mjs.map +0 -1
- package/lib/core/experimental/frames/websocket-frame.d.mts +0 -55
- package/lib/core/experimental/frames/websocket-frame.d.ts +0 -55
- package/lib/core/experimental/frames/websocket-frame.js +0 -131
- package/lib/core/experimental/frames/websocket-frame.js.map +0 -1
- package/lib/core/experimental/frames/websocket-frame.mjs +0 -118
- package/lib/core/experimental/frames/websocket-frame.mjs.map +0 -1
- package/lib/core/experimental/handlers-controller.d.mts +0 -36
- package/lib/core/experimental/handlers-controller.d.ts +0 -36
- package/lib/core/experimental/handlers-controller.js +0 -146
- package/lib/core/experimental/handlers-controller.js.map +0 -1
- package/lib/core/experimental/handlers-controller.mjs +0 -126
- package/lib/core/experimental/handlers-controller.mjs.map +0 -1
- package/lib/core/experimental/index.d.mts +0 -17
- package/lib/core/experimental/index.js.map +0 -1
- package/lib/core/experimental/index.mjs +0 -27
- package/lib/core/experimental/index.mjs.map +0 -1
- package/lib/core/experimental/on-unhandled-frame.d.mts +0 -12
- package/lib/core/experimental/on-unhandled-frame.d.ts +0 -12
- package/lib/core/experimental/on-unhandled-frame.js +0 -91
- package/lib/core/experimental/on-unhandled-frame.js.map +0 -1
- package/lib/core/experimental/on-unhandled-frame.mjs +0 -71
- package/lib/core/experimental/on-unhandled-frame.mjs.map +0 -1
- package/lib/core/experimental/request-utils.d.mts +0 -12
- package/lib/core/experimental/request-utils.d.ts +0 -12
- package/lib/core/experimental/request-utils.js +0 -50
- package/lib/core/experimental/request-utils.js.map +0 -1
- package/lib/core/experimental/request-utils.mjs +0 -30
- package/lib/core/experimental/request-utils.mjs.map +0 -1
- package/lib/core/experimental/setup-api.d.mts +0 -33
- package/lib/core/experimental/setup-api.d.ts +0 -33
- package/lib/core/experimental/setup-api.js +0 -58
- package/lib/core/experimental/setup-api.js.map +0 -1
- package/lib/core/experimental/setup-api.mjs +0 -40
- package/lib/core/experimental/setup-api.mjs.map +0 -1
- package/lib/core/experimental/sources/interceptor-source.d.mts +0 -28
- package/lib/core/experimental/sources/interceptor-source.d.ts +0 -28
- package/lib/core/experimental/sources/interceptor-source.js +0 -155
- package/lib/core/experimental/sources/interceptor-source.js.map +0 -1
- package/lib/core/experimental/sources/interceptor-source.mjs +0 -135
- package/lib/core/experimental/sources/interceptor-source.mjs.map +0 -1
- package/lib/core/experimental/sources/network-source.d.mts +0 -31
- package/lib/core/experimental/sources/network-source.d.ts +0 -31
- package/lib/core/experimental/sources/network-source.js +0 -51
- package/lib/core/experimental/sources/network-source.js.map +0 -1
- package/lib/core/experimental/sources/network-source.mjs +0 -32
- package/lib/core/experimental/sources/network-source.mjs.map +0 -1
- package/lib/core/getResponse.d.mts +0 -18
- package/lib/core/getResponse.d.ts +0 -18
- package/lib/core/getResponse.js +0 -35
- package/lib/core/getResponse.js.map +0 -1
- package/lib/core/getResponse.mjs +0 -17
- package/lib/core/getResponse.mjs.map +0 -1
- package/lib/core/graphql.d.mts +0 -76
- package/lib/core/graphql.d.ts +0 -76
- package/lib/core/graphql.js +0 -91
- package/lib/core/graphql.js.map +0 -1
- package/lib/core/graphql.mjs +0 -74
- package/lib/core/graphql.mjs.map +0 -1
- package/lib/core/handlers/GraphQLHandler.d.mts +0 -6
- package/lib/core/handlers/GraphQLHandler.d.ts +0 -6
- package/lib/core/handlers/GraphQLHandler.js +0 -232
- package/lib/core/handlers/GraphQLHandler.js.map +0 -1
- package/lib/core/handlers/GraphQLHandler.mjs +0 -221
- package/lib/core/handlers/GraphQLHandler.mjs.map +0 -1
- package/lib/core/handlers/HttpHandler.d.mts +0 -75
- package/lib/core/handlers/HttpHandler.d.ts +0 -75
- package/lib/core/handlers/HttpHandler.js +0 -129
- package/lib/core/handlers/HttpHandler.js.map +0 -1
- package/lib/core/handlers/HttpHandler.mjs +0 -113
- package/lib/core/handlers/HttpHandler.mjs.map +0 -1
- package/lib/core/handlers/RequestHandler.d.mts +0 -6
- package/lib/core/handlers/RequestHandler.d.ts +0 -6
- package/lib/core/handlers/RequestHandler.js +0 -300
- package/lib/core/handlers/RequestHandler.js.map +0 -1
- package/lib/core/handlers/RequestHandler.mjs +0 -283
- package/lib/core/handlers/RequestHandler.mjs.map +0 -1
- package/lib/core/handlers/WebSocketHandler.d.mts +0 -49
- package/lib/core/handlers/WebSocketHandler.d.ts +0 -49
- package/lib/core/handlers/WebSocketHandler.js +0 -178
- package/lib/core/handlers/WebSocketHandler.js.map +0 -1
- package/lib/core/handlers/WebSocketHandler.mjs +0 -160
- package/lib/core/handlers/WebSocketHandler.mjs.map +0 -1
- package/lib/core/http.d.mts +0 -31
- package/lib/core/http.js +0 -41
- package/lib/core/http.js.map +0 -1
- package/lib/core/http.mjs +0 -25
- package/lib/core/http.mjs.map +0 -1
- package/lib/core/index.d.mts +0 -27
- package/lib/core/index.js.map +0 -1
- package/lib/core/index.mjs +0 -52
- package/lib/core/index.mjs.map +0 -1
- package/lib/core/isCommonAssetRequest.d.mts +0 -20
- package/lib/core/isCommonAssetRequest.d.ts +0 -20
- package/lib/core/isCommonAssetRequest.js +0 -42
- package/lib/core/isCommonAssetRequest.js.map +0 -1
- package/lib/core/isCommonAssetRequest.mjs +0 -22
- package/lib/core/isCommonAssetRequest.mjs.map +0 -1
- package/lib/core/on-unhandled-frame-0KmwUmeV.d.ts +0 -56
- package/lib/core/on-unhandled-frame-gkokW4Rr.d.mts +0 -56
- package/lib/core/passthrough.d.mts +0 -24
- package/lib/core/passthrough.d.ts +0 -24
- package/lib/core/passthrough.js +0 -33
- package/lib/core/passthrough.js.map +0 -1
- package/lib/core/passthrough.mjs +0 -13
- package/lib/core/passthrough.mjs.map +0 -1
- package/lib/core/sharedOptions.d.mts +0 -68
- package/lib/core/sharedOptions.d.ts +0 -68
- package/lib/core/sharedOptions.js +0 -17
- package/lib/core/sharedOptions.js.map +0 -1
- package/lib/core/sharedOptions.mjs +0 -1
- package/lib/core/sharedOptions.mjs.map +0 -1
- package/lib/core/sse.d.mts +0 -102
- package/lib/core/sse.d.ts +0 -102
- package/lib/core/sse.js +0 -672
- package/lib/core/sse.js.map +0 -1
- package/lib/core/sse.mjs +0 -654
- package/lib/core/sse.mjs.map +0 -1
- package/lib/core/typeUtils.d.mts +0 -12
- package/lib/core/typeUtils.d.ts +0 -12
- package/lib/core/typeUtils.js +0 -17
- package/lib/core/typeUtils.js.map +0 -1
- package/lib/core/typeUtils.mjs +0 -1
- package/lib/core/typeUtils.mjs.map +0 -1
- package/lib/core/utils/HttpResponse/decorators.d.mts +0 -17
- package/lib/core/utils/HttpResponse/decorators.d.ts +0 -17
- package/lib/core/utils/HttpResponse/decorators.js +0 -71
- package/lib/core/utils/HttpResponse/decorators.js.map +0 -1
- package/lib/core/utils/HttpResponse/decorators.mjs +0 -41
- package/lib/core/utils/HttpResponse/decorators.mjs.map +0 -1
- package/lib/core/utils/cookieStore.d.mts +0 -13
- package/lib/core/utils/cookieStore.d.ts +0 -13
- package/lib/core/utils/cookieStore.js +0 -90
- package/lib/core/utils/cookieStore.js.map +0 -1
- package/lib/core/utils/cookieStore.mjs +0 -74
- package/lib/core/utils/cookieStore.mjs.map +0 -1
- package/lib/core/utils/executeHandlers.d.mts +0 -6
- package/lib/core/utils/executeHandlers.d.ts +0 -6
- package/lib/core/utils/executeHandlers.js +0 -51
- package/lib/core/utils/executeHandlers.js.map +0 -1
- package/lib/core/utils/executeHandlers.mjs +0 -31
- package/lib/core/utils/executeHandlers.mjs.map +0 -1
- package/lib/core/utils/handleRequest.d.mts +0 -30
- package/lib/core/utils/handleRequest.d.ts +0 -30
- package/lib/core/utils/handleRequest.js +0 -76
- package/lib/core/utils/handleRequest.js.map +0 -1
- package/lib/core/utils/handleRequest.mjs +0 -58
- package/lib/core/utils/handleRequest.mjs.map +0 -1
- package/lib/core/utils/internal/Disposable.d.mts +0 -7
- package/lib/core/utils/internal/Disposable.d.ts +0 -7
- package/lib/core/utils/internal/Disposable.js +0 -51
- package/lib/core/utils/internal/Disposable.js.map +0 -1
- package/lib/core/utils/internal/Disposable.mjs +0 -31
- package/lib/core/utils/internal/Disposable.mjs.map +0 -1
- package/lib/core/utils/internal/attachSiblingHandlers.d.mts +0 -15
- package/lib/core/utils/internal/attachSiblingHandlers.d.ts +0 -15
- package/lib/core/utils/internal/attachSiblingHandlers.js +0 -44
- package/lib/core/utils/internal/attachSiblingHandlers.js.map +0 -1
- package/lib/core/utils/internal/attachSiblingHandlers.mjs +0 -24
- package/lib/core/utils/internal/attachSiblingHandlers.mjs.map +0 -1
- package/lib/core/utils/internal/checkGlobals.d.mts +0 -3
- package/lib/core/utils/internal/checkGlobals.d.ts +0 -3
- package/lib/core/utils/internal/checkGlobals.js +0 -34
- package/lib/core/utils/internal/checkGlobals.js.map +0 -1
- package/lib/core/utils/internal/checkGlobals.mjs +0 -14
- package/lib/core/utils/internal/checkGlobals.mjs.map +0 -1
- package/lib/core/utils/internal/devUtils.d.mts +0 -28
- package/lib/core/utils/internal/devUtils.d.ts +0 -28
- package/lib/core/utils/internal/devUtils.js +0 -48
- package/lib/core/utils/internal/devUtils.js.map +0 -1
- package/lib/core/utils/internal/devUtils.mjs +0 -28
- package/lib/core/utils/internal/devUtils.mjs.map +0 -1
- package/lib/core/utils/internal/getCallFrame.d.mts +0 -6
- package/lib/core/utils/internal/getCallFrame.d.ts +0 -6
- package/lib/core/utils/internal/getCallFrame.js +0 -41
- package/lib/core/utils/internal/getCallFrame.js.map +0 -1
- package/lib/core/utils/internal/getCallFrame.mjs +0 -21
- package/lib/core/utils/internal/getCallFrame.mjs.map +0 -1
- package/lib/core/utils/internal/hasRefCounted.d.mts +0 -3
- package/lib/core/utils/internal/hasRefCounted.d.ts +0 -3
- package/lib/core/utils/internal/hasRefCounted.js +0 -34
- package/lib/core/utils/internal/hasRefCounted.js.map +0 -1
- package/lib/core/utils/internal/hasRefCounted.mjs +0 -14
- package/lib/core/utils/internal/hasRefCounted.mjs.map +0 -1
- package/lib/core/utils/internal/isHandlerKind.d.mts +0 -19
- package/lib/core/utils/internal/isHandlerKind.d.ts +0 -19
- package/lib/core/utils/internal/isHandlerKind.js +0 -30
- package/lib/core/utils/internal/isHandlerKind.js.map +0 -1
- package/lib/core/utils/internal/isHandlerKind.mjs +0 -10
- package/lib/core/utils/internal/isHandlerKind.mjs.map +0 -1
- package/lib/core/utils/internal/isIterable.d.mts +0 -20
- package/lib/core/utils/internal/isIterable.d.ts +0 -20
- package/lib/core/utils/internal/isIterable.js +0 -30
- package/lib/core/utils/internal/isIterable.js.map +0 -1
- package/lib/core/utils/internal/isIterable.mjs +0 -10
- package/lib/core/utils/internal/isIterable.mjs.map +0 -1
- package/lib/core/utils/internal/isObject.d.mts +0 -6
- package/lib/core/utils/internal/isObject.d.ts +0 -6
- package/lib/core/utils/internal/isObject.js +0 -27
- package/lib/core/utils/internal/isObject.js.map +0 -1
- package/lib/core/utils/internal/isObject.mjs +0 -7
- package/lib/core/utils/internal/isObject.mjs.map +0 -1
- package/lib/core/utils/internal/isStringEqual.d.mts +0 -6
- package/lib/core/utils/internal/isStringEqual.d.ts +0 -6
- package/lib/core/utils/internal/isStringEqual.js +0 -27
- package/lib/core/utils/internal/isStringEqual.js.map +0 -1
- package/lib/core/utils/internal/isStringEqual.mjs +0 -7
- package/lib/core/utils/internal/isStringEqual.mjs.map +0 -1
- package/lib/core/utils/internal/jsonParse.d.mts +0 -7
- package/lib/core/utils/internal/jsonParse.d.ts +0 -7
- package/lib/core/utils/internal/jsonParse.js +0 -31
- package/lib/core/utils/internal/jsonParse.js.map +0 -1
- package/lib/core/utils/internal/jsonParse.mjs +0 -11
- package/lib/core/utils/internal/jsonParse.mjs.map +0 -1
- package/lib/core/utils/internal/mergeRight.d.mts +0 -7
- package/lib/core/utils/internal/mergeRight.d.ts +0 -7
- package/lib/core/utils/internal/mergeRight.js +0 -43
- package/lib/core/utils/internal/mergeRight.js.map +0 -1
- package/lib/core/utils/internal/mergeRight.mjs +0 -23
- package/lib/core/utils/internal/mergeRight.mjs.map +0 -1
- package/lib/core/utils/internal/parseGraphQLRequest.d.mts +0 -6
- package/lib/core/utils/internal/parseGraphQLRequest.d.ts +0 -6
- package/lib/core/utils/internal/parseGraphQLRequest.js +0 -146
- package/lib/core/utils/internal/parseGraphQLRequest.js.map +0 -1
- package/lib/core/utils/internal/parseGraphQLRequest.mjs +0 -129
- package/lib/core/utils/internal/parseGraphQLRequest.mjs.map +0 -1
- package/lib/core/utils/internal/parseMultipartData.d.mts +0 -14
- package/lib/core/utils/internal/parseMultipartData.d.ts +0 -14
- package/lib/core/utils/internal/parseMultipartData.js +0 -84
- package/lib/core/utils/internal/parseMultipartData.js.map +0 -1
- package/lib/core/utils/internal/parseMultipartData.mjs +0 -64
- package/lib/core/utils/internal/parseMultipartData.mjs.map +0 -1
- package/lib/core/utils/internal/pipeEvents.d.mts +0 -8
- package/lib/core/utils/internal/pipeEvents.d.ts +0 -8
- package/lib/core/utils/internal/pipeEvents.js +0 -37
- package/lib/core/utils/internal/pipeEvents.js.map +0 -1
- package/lib/core/utils/internal/pipeEvents.mjs +0 -17
- package/lib/core/utils/internal/pipeEvents.mjs.map +0 -1
- package/lib/core/utils/internal/toReadonlyArray.d.mts +0 -6
- package/lib/core/utils/internal/toReadonlyArray.d.ts +0 -6
- package/lib/core/utils/internal/toReadonlyArray.js +0 -29
- package/lib/core/utils/internal/toReadonlyArray.js.map +0 -1
- package/lib/core/utils/internal/toReadonlyArray.mjs +0 -9
- package/lib/core/utils/internal/toReadonlyArray.mjs.map +0 -1
- package/lib/core/utils/internal/tryCatch.d.mts +0 -3
- package/lib/core/utils/internal/tryCatch.d.ts +0 -3
- package/lib/core/utils/internal/tryCatch.js +0 -32
- package/lib/core/utils/internal/tryCatch.js.map +0 -1
- package/lib/core/utils/internal/tryCatch.mjs +0 -12
- package/lib/core/utils/internal/tryCatch.mjs.map +0 -1
- package/lib/core/utils/logging/getStatusCodeColor.d.mts +0 -11
- package/lib/core/utils/logging/getStatusCodeColor.d.ts +0 -11
- package/lib/core/utils/logging/getStatusCodeColor.js +0 -40
- package/lib/core/utils/logging/getStatusCodeColor.js.map +0 -1
- package/lib/core/utils/logging/getStatusCodeColor.mjs +0 -20
- package/lib/core/utils/logging/getStatusCodeColor.mjs.map +0 -1
- package/lib/core/utils/logging/getTimestamp.d.mts +0 -9
- package/lib/core/utils/logging/getTimestamp.d.ts +0 -9
- package/lib/core/utils/logging/getTimestamp.js +0 -32
- package/lib/core/utils/logging/getTimestamp.js.map +0 -1
- package/lib/core/utils/logging/getTimestamp.mjs +0 -12
- package/lib/core/utils/logging/getTimestamp.mjs.map +0 -1
- package/lib/core/utils/logging/serializeRequest.d.mts +0 -12
- package/lib/core/utils/logging/serializeRequest.d.ts +0 -12
- package/lib/core/utils/logging/serializeRequest.js +0 -34
- package/lib/core/utils/logging/serializeRequest.js.map +0 -1
- package/lib/core/utils/logging/serializeRequest.mjs +0 -14
- package/lib/core/utils/logging/serializeRequest.mjs.map +0 -1
- package/lib/core/utils/logging/serializeResponse.d.mts +0 -9
- package/lib/core/utils/logging/serializeResponse.d.ts +0 -9
- package/lib/core/utils/logging/serializeResponse.js +0 -48
- package/lib/core/utils/logging/serializeResponse.js.map +0 -1
- package/lib/core/utils/logging/serializeResponse.mjs +0 -18
- package/lib/core/utils/logging/serializeResponse.mjs.map +0 -1
- package/lib/core/utils/matching/matchRequestUrl.d.mts +0 -20
- package/lib/core/utils/matching/matchRequestUrl.d.ts +0 -20
- package/lib/core/utils/matching/matchRequestUrl.js +0 -55
- package/lib/core/utils/matching/matchRequestUrl.js.map +0 -1
- package/lib/core/utils/matching/matchRequestUrl.mjs +0 -35
- package/lib/core/utils/matching/matchRequestUrl.mjs.map +0 -1
- package/lib/core/utils/matching/normalizePath.d.mts +0 -13
- package/lib/core/utils/matching/normalizePath.d.ts +0 -13
- package/lib/core/utils/matching/normalizePath.js +0 -33
- package/lib/core/utils/matching/normalizePath.js.map +0 -1
- package/lib/core/utils/matching/normalizePath.mjs +0 -13
- package/lib/core/utils/matching/normalizePath.mjs.map +0 -1
- package/lib/core/utils/request/getAllAcceptedMimeTypes.d.mts +0 -14
- package/lib/core/utils/request/getAllAcceptedMimeTypes.d.ts +0 -14
- package/lib/core/utils/request/getAllAcceptedMimeTypes.js +0 -61
- package/lib/core/utils/request/getAllAcceptedMimeTypes.js.map +0 -1
- package/lib/core/utils/request/getAllAcceptedMimeTypes.mjs +0 -41
- package/lib/core/utils/request/getAllAcceptedMimeTypes.mjs.map +0 -1
- package/lib/core/utils/request/getRequestCookies.d.mts +0 -3
- package/lib/core/utils/request/getRequestCookies.d.ts +0 -3
- package/lib/core/utils/request/getRequestCookies.js +0 -79
- package/lib/core/utils/request/getRequestCookies.js.map +0 -1
- package/lib/core/utils/request/getRequestCookies.mjs +0 -62
- package/lib/core/utils/request/getRequestCookies.mjs.map +0 -1
- package/lib/core/utils/request/onUnhandledRequest.d.mts +0 -9
- package/lib/core/utils/request/onUnhandledRequest.d.ts +0 -9
- package/lib/core/utils/request/onUnhandledRequest.js +0 -76
- package/lib/core/utils/request/onUnhandledRequest.js.map +0 -1
- package/lib/core/utils/request/onUnhandledRequest.mjs +0 -56
- package/lib/core/utils/request/onUnhandledRequest.mjs.map +0 -1
- package/lib/core/utils/request/storeResponseCookies.d.mts +0 -3
- package/lib/core/utils/request/storeResponseCookies.d.ts +0 -3
- package/lib/core/utils/request/storeResponseCookies.js +0 -32
- package/lib/core/utils/request/storeResponseCookies.js.map +0 -1
- package/lib/core/utils/request/storeResponseCookies.mjs +0 -12
- package/lib/core/utils/request/storeResponseCookies.mjs.map +0 -1
- package/lib/core/utils/request/toPublicUrl.d.mts +0 -7
- package/lib/core/utils/request/toPublicUrl.d.ts +0 -7
- package/lib/core/utils/request/toPublicUrl.js +0 -31
- package/lib/core/utils/request/toPublicUrl.js.map +0 -1
- package/lib/core/utils/request/toPublicUrl.mjs +0 -11
- package/lib/core/utils/request/toPublicUrl.mjs.map +0 -1
- package/lib/core/utils/toResponseInit.d.mts +0 -3
- package/lib/core/utils/toResponseInit.d.ts +0 -3
- package/lib/core/utils/toResponseInit.js +0 -31
- package/lib/core/utils/toResponseInit.js.map +0 -1
- package/lib/core/utils/toResponseInit.mjs +0 -11
- package/lib/core/utils/toResponseInit.mjs.map +0 -1
- package/lib/core/utils/url/cleanUrl.d.mts +0 -7
- package/lib/core/utils/url/cleanUrl.d.ts +0 -7
- package/lib/core/utils/url/cleanUrl.js +0 -31
- package/lib/core/utils/url/cleanUrl.js.map +0 -1
- package/lib/core/utils/url/cleanUrl.mjs +0 -11
- package/lib/core/utils/url/cleanUrl.mjs.map +0 -1
- package/lib/core/utils/url/getAbsoluteUrl.d.mts +0 -6
- package/lib/core/utils/url/getAbsoluteUrl.d.ts +0 -6
- package/lib/core/utils/url/getAbsoluteUrl.js +0 -38
- package/lib/core/utils/url/getAbsoluteUrl.js.map +0 -1
- package/lib/core/utils/url/getAbsoluteUrl.mjs +0 -18
- package/lib/core/utils/url/getAbsoluteUrl.mjs.map +0 -1
- package/lib/core/utils/url/isAbsoluteUrl.d.mts +0 -6
- package/lib/core/utils/url/isAbsoluteUrl.d.ts +0 -6
- package/lib/core/utils/url/isAbsoluteUrl.js +0 -27
- package/lib/core/utils/url/isAbsoluteUrl.js.map +0 -1
- package/lib/core/utils/url/isAbsoluteUrl.mjs +0 -7
- package/lib/core/utils/url/isAbsoluteUrl.mjs.map +0 -1
- package/lib/core/ws/WebSocketClientManager.d.mts +0 -65
- package/lib/core/ws/WebSocketClientManager.d.ts +0 -65
- package/lib/core/ws/WebSocketClientManager.js +0 -163
- package/lib/core/ws/WebSocketClientManager.js.map +0 -1
- package/lib/core/ws/WebSocketClientManager.mjs +0 -143
- package/lib/core/ws/WebSocketClientManager.mjs.map +0 -1
- package/lib/core/ws/WebSocketClientStore.d.mts +0 -13
- package/lib/core/ws/WebSocketClientStore.d.ts +0 -13
- package/lib/core/ws/WebSocketClientStore.js +0 -26
- package/lib/core/ws/WebSocketClientStore.js.map +0 -1
- package/lib/core/ws/WebSocketClientStore.mjs +0 -6
- package/lib/core/ws/WebSocketClientStore.mjs.map +0 -1
- package/lib/core/ws/WebSocketIndexedDBClientStore.d.mts +0 -14
- package/lib/core/ws/WebSocketIndexedDBClientStore.d.ts +0 -14
- package/lib/core/ws/WebSocketIndexedDBClientStore.js +0 -131
- package/lib/core/ws/WebSocketIndexedDBClientStore.js.map +0 -1
- package/lib/core/ws/WebSocketIndexedDBClientStore.mjs +0 -111
- package/lib/core/ws/WebSocketIndexedDBClientStore.mjs.map +0 -1
- package/lib/core/ws/WebSocketMemoryClientStore.d.mts +0 -12
- package/lib/core/ws/WebSocketMemoryClientStore.d.ts +0 -12
- package/lib/core/ws/WebSocketMemoryClientStore.js +0 -42
- package/lib/core/ws/WebSocketMemoryClientStore.js.map +0 -1
- package/lib/core/ws/WebSocketMemoryClientStore.mjs +0 -22
- package/lib/core/ws/WebSocketMemoryClientStore.mjs.map +0 -1
- package/lib/core/ws/handleWebSocketEvent.d.mts +0 -20
- package/lib/core/ws/handleWebSocketEvent.d.ts +0 -20
- package/lib/core/ws/handleWebSocketEvent.js +0 -61
- package/lib/core/ws/handleWebSocketEvent.js.map +0 -1
- package/lib/core/ws/handleWebSocketEvent.mjs +0 -43
- package/lib/core/ws/handleWebSocketEvent.mjs.map +0 -1
- package/lib/core/ws/utils/attachWebSocketLogger.d.mts +0 -18
- package/lib/core/ws/utils/attachWebSocketLogger.d.ts +0 -18
- package/lib/core/ws/utils/attachWebSocketLogger.js +0 -228
- package/lib/core/ws/utils/attachWebSocketLogger.js.map +0 -1
- package/lib/core/ws/utils/attachWebSocketLogger.mjs +0 -208
- package/lib/core/ws/utils/attachWebSocketLogger.mjs.map +0 -1
- package/lib/core/ws/utils/getMessageLength.d.mts +0 -11
- package/lib/core/ws/utils/getMessageLength.d.ts +0 -11
- package/lib/core/ws/utils/getMessageLength.js +0 -34
- package/lib/core/ws/utils/getMessageLength.js.map +0 -1
- package/lib/core/ws/utils/getMessageLength.mjs +0 -14
- package/lib/core/ws/utils/getMessageLength.mjs.map +0 -1
- package/lib/core/ws/utils/getPublicData.d.mts +0 -5
- package/lib/core/ws/utils/getPublicData.d.ts +0 -5
- package/lib/core/ws/utils/getPublicData.js +0 -37
- package/lib/core/ws/utils/getPublicData.js.map +0 -1
- package/lib/core/ws/utils/getPublicData.mjs +0 -17
- package/lib/core/ws/utils/getPublicData.mjs.map +0 -1
- package/lib/core/ws/utils/truncateMessage.d.mts +0 -3
- package/lib/core/ws/utils/truncateMessage.d.ts +0 -3
- package/lib/core/ws/utils/truncateMessage.js +0 -31
- package/lib/core/ws/utils/truncateMessage.js.map +0 -1
- package/lib/core/ws/utils/truncateMessage.mjs +0 -11
- package/lib/core/ws/utils/truncateMessage.mjs.map +0 -1
- package/lib/core/ws/webSocketInterceptor.d.mts +0 -5
- package/lib/core/ws/webSocketInterceptor.d.ts +0 -5
- package/lib/core/ws/webSocketInterceptor.js +0 -26
- package/lib/core/ws/webSocketInterceptor.js.map +0 -1
- package/lib/core/ws/webSocketInterceptor.mjs +0 -6
- package/lib/core/ws/webSocketInterceptor.mjs.map +0 -1
- package/lib/core/ws.d.mts +0 -88
- package/lib/core/ws.d.ts +0 -88
- package/lib/core/ws.js +0 -94
- package/lib/core/ws.js.map +0 -1
- package/lib/core/ws.mjs +0 -80
- package/lib/core/ws.mjs.map +0 -1
- package/lib/native/index.d.mts +0 -66
- package/lib/native/index.d.ts +0 -66
- package/lib/native/index.js +0 -88
- package/lib/native/index.js.map +0 -1
- package/lib/native/index.mjs +0 -67
- package/lib/native/index.mjs.map +0 -1
- package/lib/node/index.d.mts +0 -113
- package/lib/node/index.mjs +0 -185
- package/lib/node/index.mjs.map +0 -1
- package/lib/shims/cookie.d.mts +0 -7
- package/lib/shims/cookie.d.ts +0 -7
- package/lib/shims/cookie.js +0 -294
- package/lib/shims/cookie.mjs +0 -286
- package/lib/shims/statuses.d.mts +0 -6
- package/lib/shims/statuses.d.ts +0 -6
- package/lib/shims/statuses.js +0 -195
- package/lib/shims/statuses.mjs +0 -187
- package/native/package.json +0 -30
- package/node/package.json +0 -33
- package/src/browser/utils/pruneGetRequestBody.test.ts +0 -51
- package/src/browser/utils/pruneGetRequestBody.ts +0 -21
- package/src/core/experimental/compat.ts +0 -50
- package/src/core/experimental/setup-api.ts +0 -55
- package/src/core/graphql.test.ts +0 -11
- package/src/core/graphql.ts +0 -136
- package/src/core/passthrough.test.ts +0 -11
- package/src/core/passthrough.ts +0 -25
- package/src/core/sharedOptions.ts +0 -71
- package/src/core/typeUtils.ts +0 -26
- package/src/core/utils/handleRequest.test.ts +0 -574
- package/src/core/utils/handleRequest.ts +0 -117
- package/src/core/utils/internal/checkGlobals.ts +0 -17
- package/src/core/utils/internal/isHandlerKind.test.ts +0 -62
- package/src/core/utils/internal/isHandlerKind.ts +0 -17
- package/src/core/utils/internal/isIterable.ts +0 -32
- package/src/core/utils/internal/mergeRight.test.ts +0 -43
- package/src/core/utils/internal/mergeRight.ts +0 -30
- package/src/core/utils/internal/pipeEvents.test.ts +0 -14
- package/src/core/utils/internal/pipeEvents.ts +0 -26
- package/src/core/utils/internal/tryCatch.test.ts +0 -29
- package/src/core/utils/internal/tryCatch.ts +0 -11
- package/src/core/utils/matching/matchRequestUrl.test.ts +0 -267
- package/src/core/utils/matching/matchRequestUrl.ts +0 -77
- package/src/core/utils/request/getRequestCookies.ts +0 -88
- package/src/core/utils/request/onUnhandledRequest.node.test.ts +0 -62
- package/src/core/utils/request/onUnhandledRequest.test.ts +0 -226
- package/src/core/utils/request/onUnhandledRequest.ts +0 -81
- package/src/core/utils/request/storeResponseCookies.ts +0 -15
- package/src/core/utils/url/cleanUrl.test.ts +0 -22
- package/src/core/utils/url/cleanUrl.ts +0 -16
- package/src/core/utils/url/isAbsoluteUrl.test.ts +0 -32
- package/src/core/ws/handleWebSocketEvent.ts +0 -68
- package/src/core/ws/utils/getPublicData.ts +0 -18
- package/src/core/ws/webSocketInterceptor.ts +0 -3
- package/src/native/index.ts +0 -44
- package/src/package.json +0 -3
- package/src/shims/cookie.ts +0 -7
- package/src/shims/statuses.ts +0 -6
- /package/src/browser/utils/{getAbsoluteWorkerUrl.ts → get-absolute-worker-url.ts} +0 -0
- /package/src/core/utils/internal/{devUtils.ts → dev-utils.ts} +0 -0
- /package/src/core/utils/internal/{isObject.ts → is-object.ts} +0 -0
- /package/src/core/utils/internal/{isStringEqual.ts → is-string-equal.ts} +0 -0
- /package/src/core/utils/internal/{jsonParse.ts → json-parse.ts} +0 -0
- /package/src/core/utils/internal/{toReadonlyArray.ts → to-readonly-array.ts} +0 -0
- /package/src/core/utils/logging/{getStatusCodeColor.ts → get-status-code-color.ts} +0 -0
- /package/src/core/utils/logging/{getTimestamp.ts → get-timestamp.ts} +0 -0
- /package/src/core/utils/logging/{serializeRequest.ts → serialize-request.ts} +0 -0
- /package/src/core/utils/request/{getAllAcceptedMimeTypes.ts → get-all-accepted-mime-types.ts} +0 -0
- /package/src/core/utils/request/{toPublicUrl.ts → to-public-url.ts} +0 -0
- /package/src/core/utils/{toResponseInit.ts → to-response-init.ts} +0 -0
- /package/src/core/utils/url/{isAbsoluteUrl.ts → is-absolute-url.ts} +0 -0
- /package/src/{core → http}/http.test.ts +0 -0
- /package/src/{core/ws/utils/truncateMessage.ts → ws/utils/truncate-message.ts} +0 -0
|
@@ -1,574 +0,0 @@
|
|
|
1
|
-
// @vitest-environment jsdom
|
|
2
|
-
import { Emitter } from 'strict-event-emitter'
|
|
3
|
-
import { createRequestId } from '@mswjs/interceptors'
|
|
4
|
-
import type { LifeCycleEventsMap, SharedOptions } from '../sharedOptions'
|
|
5
|
-
import type { RequestHandler } from '../handlers/RequestHandler'
|
|
6
|
-
import { http } from '../http'
|
|
7
|
-
import type { HandleRequestOptions } from './handleRequest'
|
|
8
|
-
import { handleRequest } from './handleRequest'
|
|
9
|
-
import type { RequiredDeep } from '../typeUtils'
|
|
10
|
-
import { HttpResponse } from '../HttpResponse'
|
|
11
|
-
import { passthrough } from '../passthrough'
|
|
12
|
-
|
|
13
|
-
const options: RequiredDeep<SharedOptions> = {
|
|
14
|
-
onUnhandledRequest: vi.fn(),
|
|
15
|
-
}
|
|
16
|
-
const handleRequestOptions: Partial<Record<keyof HandleRequestOptions, any>> = {
|
|
17
|
-
onPassthroughResponse: vi.fn(),
|
|
18
|
-
onMockedResponse: vi.fn(),
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function setup() {
|
|
22
|
-
const emitter = new Emitter<LifeCycleEventsMap>()
|
|
23
|
-
const listener = vi.fn()
|
|
24
|
-
|
|
25
|
-
const createMockListener = (name: string) => {
|
|
26
|
-
return (...args: any) => {
|
|
27
|
-
listener(name, ...args)
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
emitter.on('request:start', createMockListener('request:start'))
|
|
32
|
-
emitter.on('request:match', createMockListener('request:match'))
|
|
33
|
-
emitter.on('request:unhandled', createMockListener('request:unhandled'))
|
|
34
|
-
emitter.on('request:end', createMockListener('request:end'))
|
|
35
|
-
emitter.on('response:mocked', createMockListener('response:mocked'))
|
|
36
|
-
emitter.on('response:bypass', createMockListener('response:bypass'))
|
|
37
|
-
|
|
38
|
-
const events = listener.mock.calls
|
|
39
|
-
return { emitter, events }
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
beforeEach(() => {
|
|
43
|
-
vi.spyOn(global.console, 'warn').mockImplementation(() => void 0)
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
afterEach(() => {
|
|
47
|
-
vi.resetAllMocks()
|
|
48
|
-
})
|
|
49
|
-
|
|
50
|
-
test('returns undefined for a request with the "accept: msw/passthrough" header equal to "bypass"', async () => {
|
|
51
|
-
const { emitter, events } = setup()
|
|
52
|
-
|
|
53
|
-
const requestId = createRequestId()
|
|
54
|
-
const request = new Request(new URL('http://localhost/user'), {
|
|
55
|
-
headers: new Headers({
|
|
56
|
-
accept: 'msw/passthrough',
|
|
57
|
-
}),
|
|
58
|
-
})
|
|
59
|
-
const handlers: Array<RequestHandler> = []
|
|
60
|
-
|
|
61
|
-
const result = await handleRequest(
|
|
62
|
-
request,
|
|
63
|
-
requestId,
|
|
64
|
-
handlers,
|
|
65
|
-
options,
|
|
66
|
-
emitter,
|
|
67
|
-
handleRequestOptions,
|
|
68
|
-
)
|
|
69
|
-
|
|
70
|
-
expect(result).toBeUndefined()
|
|
71
|
-
expect(events).toEqual([
|
|
72
|
-
['request:start', { request, requestId }],
|
|
73
|
-
['request:end', { request, requestId }],
|
|
74
|
-
])
|
|
75
|
-
expect(options.onUnhandledRequest).not.toHaveBeenCalled()
|
|
76
|
-
expect(handleRequestOptions.onPassthroughResponse).toHaveBeenNthCalledWith(
|
|
77
|
-
1,
|
|
78
|
-
request,
|
|
79
|
-
)
|
|
80
|
-
expect(handleRequestOptions.onMockedResponse).not.toHaveBeenCalled()
|
|
81
|
-
})
|
|
82
|
-
|
|
83
|
-
test('does not bypass a request with "accept: msw/*" header set to arbitrary value', async () => {
|
|
84
|
-
const { emitter } = setup()
|
|
85
|
-
|
|
86
|
-
const request = new Request(new URL('http://localhost/user'), {
|
|
87
|
-
headers: new Headers({
|
|
88
|
-
accept: 'msw/invalid',
|
|
89
|
-
}),
|
|
90
|
-
})
|
|
91
|
-
const handlers: Array<RequestHandler> = [
|
|
92
|
-
http.get('/user', () => {
|
|
93
|
-
return HttpResponse.text('hello world')
|
|
94
|
-
}),
|
|
95
|
-
]
|
|
96
|
-
|
|
97
|
-
const result = await handleRequest(
|
|
98
|
-
request,
|
|
99
|
-
createRequestId(),
|
|
100
|
-
handlers,
|
|
101
|
-
options,
|
|
102
|
-
emitter,
|
|
103
|
-
handleRequestOptions,
|
|
104
|
-
)
|
|
105
|
-
|
|
106
|
-
expect(result).not.toBeUndefined()
|
|
107
|
-
expect(options.onUnhandledRequest).not.toHaveBeenCalled()
|
|
108
|
-
expect(handleRequestOptions.onMockedResponse).toHaveBeenCalledTimes(1)
|
|
109
|
-
})
|
|
110
|
-
|
|
111
|
-
test('reports request as unhandled when it has no matching request handlers', async () => {
|
|
112
|
-
const { emitter, events } = setup()
|
|
113
|
-
|
|
114
|
-
const requestId = createRequestId()
|
|
115
|
-
const request = new Request(new URL('http://localhost/user'))
|
|
116
|
-
const handlers: Array<RequestHandler> = []
|
|
117
|
-
|
|
118
|
-
const result = await handleRequest(
|
|
119
|
-
request,
|
|
120
|
-
requestId,
|
|
121
|
-
handlers,
|
|
122
|
-
options,
|
|
123
|
-
emitter,
|
|
124
|
-
handleRequestOptions,
|
|
125
|
-
)
|
|
126
|
-
|
|
127
|
-
expect(result).toBeUndefined()
|
|
128
|
-
expect(events).toEqual([
|
|
129
|
-
['request:start', { request, requestId }],
|
|
130
|
-
['request:unhandled', { request, requestId }],
|
|
131
|
-
['request:end', { request, requestId }],
|
|
132
|
-
])
|
|
133
|
-
expect(options.onUnhandledRequest).toHaveBeenNthCalledWith(1, request, {
|
|
134
|
-
warning: expect.any(Function),
|
|
135
|
-
error: expect.any(Function),
|
|
136
|
-
})
|
|
137
|
-
expect(handleRequestOptions.onPassthroughResponse).toHaveBeenNthCalledWith(
|
|
138
|
-
1,
|
|
139
|
-
request,
|
|
140
|
-
)
|
|
141
|
-
expect(handleRequestOptions.onMockedResponse).not.toHaveBeenCalled()
|
|
142
|
-
})
|
|
143
|
-
|
|
144
|
-
test('returns undefined on a request handler that returns no response', async () => {
|
|
145
|
-
const { emitter, events } = setup()
|
|
146
|
-
|
|
147
|
-
const requestId = createRequestId()
|
|
148
|
-
const request = new Request(new URL('http://localhost/user'))
|
|
149
|
-
const handlers: Array<RequestHandler> = [
|
|
150
|
-
http.get('/user', () => {
|
|
151
|
-
// Intentionally blank response resolver.
|
|
152
|
-
return
|
|
153
|
-
}),
|
|
154
|
-
]
|
|
155
|
-
|
|
156
|
-
const result = await handleRequest(
|
|
157
|
-
request,
|
|
158
|
-
requestId,
|
|
159
|
-
handlers,
|
|
160
|
-
options,
|
|
161
|
-
emitter,
|
|
162
|
-
handleRequestOptions,
|
|
163
|
-
)
|
|
164
|
-
|
|
165
|
-
expect(result).toBeUndefined()
|
|
166
|
-
expect(events).toEqual([
|
|
167
|
-
['request:start', { request, requestId }],
|
|
168
|
-
['request:end', { request, requestId }],
|
|
169
|
-
])
|
|
170
|
-
expect(options.onUnhandledRequest).not.toHaveBeenCalled()
|
|
171
|
-
expect(handleRequestOptions.onPassthroughResponse).toHaveBeenNthCalledWith(
|
|
172
|
-
1,
|
|
173
|
-
request,
|
|
174
|
-
)
|
|
175
|
-
expect(handleRequestOptions.onMockedResponse).not.toHaveBeenCalled()
|
|
176
|
-
|
|
177
|
-
/**
|
|
178
|
-
* @note Returning undefined from a resolver no longer prints a warning.
|
|
179
|
-
*/
|
|
180
|
-
expect(console.warn).toHaveBeenCalledTimes(0)
|
|
181
|
-
})
|
|
182
|
-
|
|
183
|
-
test('returns the mocked response for a request with a matching request handler', async () => {
|
|
184
|
-
const { emitter, events } = setup()
|
|
185
|
-
|
|
186
|
-
const requestId = createRequestId()
|
|
187
|
-
const request = new Request(new URL('http://localhost/user'))
|
|
188
|
-
const mockedResponse = HttpResponse.json({ firstName: 'John' })
|
|
189
|
-
const handlers: Array<RequestHandler> = [
|
|
190
|
-
http.get('/user', () => {
|
|
191
|
-
return mockedResponse
|
|
192
|
-
}),
|
|
193
|
-
]
|
|
194
|
-
const lookupResult = {
|
|
195
|
-
handler: handlers[0],
|
|
196
|
-
response: mockedResponse,
|
|
197
|
-
request,
|
|
198
|
-
parsedResult: {
|
|
199
|
-
match: { matches: true, params: {} },
|
|
200
|
-
cookies: {},
|
|
201
|
-
},
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
const result = await handleRequest(
|
|
205
|
-
request,
|
|
206
|
-
requestId,
|
|
207
|
-
handlers,
|
|
208
|
-
options,
|
|
209
|
-
emitter,
|
|
210
|
-
handleRequestOptions,
|
|
211
|
-
)
|
|
212
|
-
|
|
213
|
-
expect(result).toEqual(mockedResponse)
|
|
214
|
-
expect(events).toEqual([
|
|
215
|
-
['request:start', { request, requestId }],
|
|
216
|
-
['request:match', { request, requestId }],
|
|
217
|
-
['request:end', { request, requestId }],
|
|
218
|
-
])
|
|
219
|
-
expect(handleRequestOptions.onPassthroughResponse).not.toHaveBeenCalled()
|
|
220
|
-
|
|
221
|
-
expect(handleRequestOptions.onMockedResponse).toHaveBeenCalledTimes(1)
|
|
222
|
-
const [mockedResponseParam, lookupResultParam] =
|
|
223
|
-
handleRequestOptions.onMockedResponse.mock.calls[0]
|
|
224
|
-
|
|
225
|
-
expect(mockedResponseParam.status).toBe(mockedResponse.status)
|
|
226
|
-
expect(mockedResponseParam.statusText).toBe(mockedResponse.statusText)
|
|
227
|
-
expect(Object.fromEntries(mockedResponseParam.headers.entries())).toEqual(
|
|
228
|
-
Object.fromEntries(mockedResponse.headers.entries()),
|
|
229
|
-
)
|
|
230
|
-
|
|
231
|
-
expect(lookupResultParam).toEqual({
|
|
232
|
-
handler: lookupResult.handler,
|
|
233
|
-
parsedResult: lookupResult.parsedResult,
|
|
234
|
-
response: expect.objectContaining({
|
|
235
|
-
status: lookupResult.response.status,
|
|
236
|
-
statusText: lookupResult.response.statusText,
|
|
237
|
-
}),
|
|
238
|
-
})
|
|
239
|
-
})
|
|
240
|
-
|
|
241
|
-
it('returns undefined without warning on a passthrough request', async () => {
|
|
242
|
-
const { emitter, events } = setup()
|
|
243
|
-
|
|
244
|
-
const requestId = createRequestId()
|
|
245
|
-
const request = new Request(new URL('http://localhost/user'))
|
|
246
|
-
const handlers: Array<RequestHandler> = [
|
|
247
|
-
http.get('/user', () => {
|
|
248
|
-
return passthrough()
|
|
249
|
-
}),
|
|
250
|
-
]
|
|
251
|
-
|
|
252
|
-
const result = await handleRequest(
|
|
253
|
-
request,
|
|
254
|
-
requestId,
|
|
255
|
-
handlers,
|
|
256
|
-
options,
|
|
257
|
-
emitter,
|
|
258
|
-
handleRequestOptions,
|
|
259
|
-
)
|
|
260
|
-
|
|
261
|
-
expect(result).toBeUndefined()
|
|
262
|
-
expect(events).toEqual([
|
|
263
|
-
['request:start', { request, requestId }],
|
|
264
|
-
['request:end', { request, requestId }],
|
|
265
|
-
])
|
|
266
|
-
expect(options.onUnhandledRequest).not.toHaveBeenCalled()
|
|
267
|
-
expect(handleRequestOptions.onPassthroughResponse).toHaveBeenNthCalledWith(
|
|
268
|
-
1,
|
|
269
|
-
request,
|
|
270
|
-
)
|
|
271
|
-
expect(handleRequestOptions.onMockedResponse).not.toHaveBeenCalled()
|
|
272
|
-
})
|
|
273
|
-
|
|
274
|
-
it('calls the handler with the requestId', async () => {
|
|
275
|
-
const { emitter } = setup()
|
|
276
|
-
|
|
277
|
-
const requestId = createRequestId()
|
|
278
|
-
const request = new Request(new URL('http://localhost/user'))
|
|
279
|
-
const handlerFn = vi.fn()
|
|
280
|
-
const handlers: Array<RequestHandler> = [http.get('/user', handlerFn)]
|
|
281
|
-
|
|
282
|
-
await handleRequest(
|
|
283
|
-
request,
|
|
284
|
-
requestId,
|
|
285
|
-
handlers,
|
|
286
|
-
options,
|
|
287
|
-
emitter,
|
|
288
|
-
handleRequestOptions,
|
|
289
|
-
)
|
|
290
|
-
|
|
291
|
-
expect(handlerFn).toHaveBeenCalledWith(expect.objectContaining({ requestId }))
|
|
292
|
-
})
|
|
293
|
-
|
|
294
|
-
it('marks the first matching one-time handler as used', async () => {
|
|
295
|
-
const { emitter } = setup()
|
|
296
|
-
|
|
297
|
-
const oneTimeHandler = http.get(
|
|
298
|
-
'/resource',
|
|
299
|
-
() => {
|
|
300
|
-
return HttpResponse.text('One-time')
|
|
301
|
-
},
|
|
302
|
-
{ once: true },
|
|
303
|
-
)
|
|
304
|
-
const anotherHandler = http.get('/resource', () => {
|
|
305
|
-
return HttpResponse.text('Another')
|
|
306
|
-
})
|
|
307
|
-
const handlers: Array<RequestHandler> = [oneTimeHandler, anotherHandler]
|
|
308
|
-
|
|
309
|
-
const requestId = createRequestId()
|
|
310
|
-
const request = new Request('http://localhost/resource')
|
|
311
|
-
const firstResult = await handleRequest(
|
|
312
|
-
request,
|
|
313
|
-
requestId,
|
|
314
|
-
handlers,
|
|
315
|
-
options,
|
|
316
|
-
emitter,
|
|
317
|
-
handleRequestOptions,
|
|
318
|
-
)
|
|
319
|
-
|
|
320
|
-
expect(await firstResult?.text()).toBe('One-time')
|
|
321
|
-
expect(oneTimeHandler.isUsed).toBe(true)
|
|
322
|
-
expect(anotherHandler.isUsed).toBe(false)
|
|
323
|
-
|
|
324
|
-
const secondResult = await handleRequest(
|
|
325
|
-
request,
|
|
326
|
-
requestId,
|
|
327
|
-
handlers,
|
|
328
|
-
options,
|
|
329
|
-
emitter,
|
|
330
|
-
handleRequestOptions,
|
|
331
|
-
)
|
|
332
|
-
|
|
333
|
-
expect(await secondResult?.text()).toBe('Another')
|
|
334
|
-
expect(anotherHandler.isUsed).toBe(true)
|
|
335
|
-
expect(oneTimeHandler.isUsed).toBe(true)
|
|
336
|
-
})
|
|
337
|
-
|
|
338
|
-
it('does not mark non-matching one-time handlers as used', async () => {
|
|
339
|
-
const { emitter } = setup()
|
|
340
|
-
|
|
341
|
-
const oneTimeHandler = http.get(
|
|
342
|
-
'/resource',
|
|
343
|
-
() => {
|
|
344
|
-
return HttpResponse.text('One-time')
|
|
345
|
-
},
|
|
346
|
-
{ once: true },
|
|
347
|
-
)
|
|
348
|
-
const anotherHandler = http.get(
|
|
349
|
-
'/another',
|
|
350
|
-
() => {
|
|
351
|
-
return HttpResponse.text('Another')
|
|
352
|
-
},
|
|
353
|
-
{ once: true },
|
|
354
|
-
)
|
|
355
|
-
const handlers: Array<RequestHandler> = [oneTimeHandler, anotherHandler]
|
|
356
|
-
|
|
357
|
-
const requestId = createRequestId()
|
|
358
|
-
const firstResult = await handleRequest(
|
|
359
|
-
new Request('http://localhost/another'),
|
|
360
|
-
requestId,
|
|
361
|
-
handlers,
|
|
362
|
-
options,
|
|
363
|
-
emitter,
|
|
364
|
-
handleRequestOptions,
|
|
365
|
-
)
|
|
366
|
-
|
|
367
|
-
expect(await firstResult?.text()).toBe('Another')
|
|
368
|
-
expect(oneTimeHandler.isUsed).toBe(false)
|
|
369
|
-
expect(anotherHandler.isUsed).toBe(true)
|
|
370
|
-
|
|
371
|
-
const secondResult = await handleRequest(
|
|
372
|
-
new Request('http://localhost/resource'),
|
|
373
|
-
requestId,
|
|
374
|
-
handlers,
|
|
375
|
-
options,
|
|
376
|
-
emitter,
|
|
377
|
-
handleRequestOptions,
|
|
378
|
-
)
|
|
379
|
-
|
|
380
|
-
expect(await secondResult?.text()).toBe('One-time')
|
|
381
|
-
expect(anotherHandler.isUsed).toBe(true)
|
|
382
|
-
expect(oneTimeHandler.isUsed).toBe(true)
|
|
383
|
-
})
|
|
384
|
-
|
|
385
|
-
it('handles parallel requests with one-time handlers', async () => {
|
|
386
|
-
const { emitter } = setup()
|
|
387
|
-
|
|
388
|
-
const oneTimeHandler = http.get(
|
|
389
|
-
'/resource',
|
|
390
|
-
() => {
|
|
391
|
-
return HttpResponse.text('One-time')
|
|
392
|
-
},
|
|
393
|
-
{ once: true },
|
|
394
|
-
)
|
|
395
|
-
const anotherHandler = http.get('/resource', () => {
|
|
396
|
-
return HttpResponse.text('Another')
|
|
397
|
-
})
|
|
398
|
-
const handlers: Array<RequestHandler> = [oneTimeHandler, anotherHandler]
|
|
399
|
-
|
|
400
|
-
const requestId = createRequestId()
|
|
401
|
-
const request = new Request('http://localhost/resource')
|
|
402
|
-
const firstResultPromise = handleRequest(
|
|
403
|
-
request,
|
|
404
|
-
requestId,
|
|
405
|
-
handlers,
|
|
406
|
-
options,
|
|
407
|
-
emitter,
|
|
408
|
-
handleRequestOptions,
|
|
409
|
-
)
|
|
410
|
-
const secondResultPromise = handleRequest(
|
|
411
|
-
request,
|
|
412
|
-
requestId,
|
|
413
|
-
handlers,
|
|
414
|
-
options,
|
|
415
|
-
emitter,
|
|
416
|
-
handleRequestOptions,
|
|
417
|
-
)
|
|
418
|
-
|
|
419
|
-
const firstResult = await firstResultPromise
|
|
420
|
-
const secondResult = await secondResultPromise
|
|
421
|
-
|
|
422
|
-
expect(await firstResult?.text()).toBe('One-time')
|
|
423
|
-
expect(await secondResult?.text()).toBe('Another')
|
|
424
|
-
expect(oneTimeHandler.isUsed).toBe(true)
|
|
425
|
-
expect(anotherHandler.isUsed).toBe(true)
|
|
426
|
-
})
|
|
427
|
-
|
|
428
|
-
describe('[Private] - resolutionContext - used for extensions', () => {
|
|
429
|
-
describe('#baseUrl', () => {
|
|
430
|
-
test('when defined, handle requests to that base url only defining pathnames in the handler', async () => {
|
|
431
|
-
const { emitter } = setup()
|
|
432
|
-
|
|
433
|
-
const baseUrl = 'http://this-base-url-works.com'
|
|
434
|
-
const handleRequestOptionsWithBaseUrl: HandleRequestOptions = {
|
|
435
|
-
...handleRequestOptions,
|
|
436
|
-
resolutionContext: { baseUrl },
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
const handler = http.get('/resource', () => {
|
|
440
|
-
return HttpResponse.text('Mocked response')
|
|
441
|
-
})
|
|
442
|
-
|
|
443
|
-
const handlers: Array<RequestHandler> = [handler]
|
|
444
|
-
|
|
445
|
-
const requestId = createRequestId()
|
|
446
|
-
const request = new Request(new URL('/resource', baseUrl))
|
|
447
|
-
const response = await handleRequest(
|
|
448
|
-
request,
|
|
449
|
-
requestId,
|
|
450
|
-
handlers,
|
|
451
|
-
options,
|
|
452
|
-
emitter,
|
|
453
|
-
handleRequestOptionsWithBaseUrl,
|
|
454
|
-
)
|
|
455
|
-
|
|
456
|
-
expect(await response?.text()).toBe('Mocked response')
|
|
457
|
-
})
|
|
458
|
-
|
|
459
|
-
test('when defined, do not handle requests to different base urls when defining pathnames in the handler', async () => {
|
|
460
|
-
const { emitter } = setup()
|
|
461
|
-
|
|
462
|
-
const baseUrl = 'http://this-base-url-works.com'
|
|
463
|
-
const handleRequestOptionsWithBaseUrl: HandleRequestOptions = {
|
|
464
|
-
...handleRequestOptions,
|
|
465
|
-
resolutionContext: { baseUrl },
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
const handler = http.get('/resource', () => {
|
|
469
|
-
return HttpResponse.text('Mocked response')
|
|
470
|
-
})
|
|
471
|
-
|
|
472
|
-
const handlers: Array<RequestHandler> = [handler]
|
|
473
|
-
|
|
474
|
-
const requestId = createRequestId()
|
|
475
|
-
const request = new Request(
|
|
476
|
-
new URL('/resource', `http://not-the-base-url.com`),
|
|
477
|
-
)
|
|
478
|
-
const response = await handleRequest(
|
|
479
|
-
request,
|
|
480
|
-
requestId,
|
|
481
|
-
handlers,
|
|
482
|
-
options,
|
|
483
|
-
emitter,
|
|
484
|
-
handleRequestOptionsWithBaseUrl,
|
|
485
|
-
)
|
|
486
|
-
|
|
487
|
-
expect(response).toBeUndefined()
|
|
488
|
-
})
|
|
489
|
-
})
|
|
490
|
-
})
|
|
491
|
-
|
|
492
|
-
describe('handler with custom predicate', () => {
|
|
493
|
-
test('matches if custom predicate returns true', async () => {
|
|
494
|
-
const { emitter, events } = setup()
|
|
495
|
-
|
|
496
|
-
const requestId = createRequestId()
|
|
497
|
-
const request = new Request(new URL('http://localhost/login'), {
|
|
498
|
-
method: 'POST',
|
|
499
|
-
body: JSON.stringify({ username: 'test', password: 'password' }),
|
|
500
|
-
headers: { 'Content-Type': 'application/json' },
|
|
501
|
-
})
|
|
502
|
-
const handlers: Array<RequestHandler> = [
|
|
503
|
-
http.post(
|
|
504
|
-
async ({ request }) => {
|
|
505
|
-
const body = await request.clone().json()
|
|
506
|
-
return body.username === 'test' && body.password === 'password'
|
|
507
|
-
},
|
|
508
|
-
() =>
|
|
509
|
-
HttpResponse.json({
|
|
510
|
-
success: true,
|
|
511
|
-
}),
|
|
512
|
-
),
|
|
513
|
-
]
|
|
514
|
-
|
|
515
|
-
const result = await handleRequest(
|
|
516
|
-
request,
|
|
517
|
-
requestId,
|
|
518
|
-
handlers,
|
|
519
|
-
options,
|
|
520
|
-
emitter,
|
|
521
|
-
handleRequestOptions,
|
|
522
|
-
)
|
|
523
|
-
|
|
524
|
-
expect(result).toBeDefined()
|
|
525
|
-
expect(await result?.json()).toStrictEqual({ success: true })
|
|
526
|
-
expect(events).toEqual([
|
|
527
|
-
['request:start', { request, requestId }],
|
|
528
|
-
['request:match', { request, requestId }],
|
|
529
|
-
['request:end', { request, requestId }],
|
|
530
|
-
])
|
|
531
|
-
expect(handleRequestOptions.onMockedResponse).toHaveBeenCalledTimes(1)
|
|
532
|
-
})
|
|
533
|
-
|
|
534
|
-
test('does not match if custom predicate returns false', async () => {
|
|
535
|
-
const { emitter, events } = setup()
|
|
536
|
-
|
|
537
|
-
const requestId = createRequestId()
|
|
538
|
-
const request = new Request(new URL('http://localhost/login'), {
|
|
539
|
-
method: 'POST',
|
|
540
|
-
body: JSON.stringify({ username: 'test', password: 'passwordd' }),
|
|
541
|
-
headers: { 'Content-Type': 'application/json' },
|
|
542
|
-
})
|
|
543
|
-
const handlers: Array<RequestHandler> = [
|
|
544
|
-
http.post(
|
|
545
|
-
async ({ request }) => {
|
|
546
|
-
const body = await request.clone().json()
|
|
547
|
-
return body.username === 'test' && body.password === 'password'
|
|
548
|
-
},
|
|
549
|
-
() =>
|
|
550
|
-
HttpResponse.json({
|
|
551
|
-
success: true,
|
|
552
|
-
}),
|
|
553
|
-
),
|
|
554
|
-
]
|
|
555
|
-
|
|
556
|
-
const result = await handleRequest(
|
|
557
|
-
request,
|
|
558
|
-
requestId,
|
|
559
|
-
handlers,
|
|
560
|
-
options,
|
|
561
|
-
emitter,
|
|
562
|
-
handleRequestOptions,
|
|
563
|
-
)
|
|
564
|
-
|
|
565
|
-
expect(result).toBeUndefined()
|
|
566
|
-
expect(events).toEqual([
|
|
567
|
-
['request:start', { request, requestId }],
|
|
568
|
-
['request:unhandled', { request, requestId }],
|
|
569
|
-
['request:end', { request, requestId }],
|
|
570
|
-
])
|
|
571
|
-
expect(options.onUnhandledRequest).toHaveBeenCalledTimes(1)
|
|
572
|
-
expect(handleRequestOptions.onPassthroughResponse).toHaveBeenCalledTimes(1)
|
|
573
|
-
})
|
|
574
|
-
})
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import { until } from 'until-async'
|
|
2
|
-
import type { Emitter } from 'strict-event-emitter'
|
|
3
|
-
import type { LifeCycleEventsMap, SharedOptions } from '../sharedOptions'
|
|
4
|
-
import type { RequiredDeep } from '../typeUtils'
|
|
5
|
-
import type { RequestHandler } from '../handlers/RequestHandler'
|
|
6
|
-
import {
|
|
7
|
-
type HandlersExecutionResult,
|
|
8
|
-
type ResponseResolutionContext,
|
|
9
|
-
executeHandlers,
|
|
10
|
-
} from './executeHandlers'
|
|
11
|
-
import { onUnhandledRequest } from './request/onUnhandledRequest'
|
|
12
|
-
import { storeResponseCookies } from './request/storeResponseCookies'
|
|
13
|
-
|
|
14
|
-
export interface HandleRequestOptions {
|
|
15
|
-
/**
|
|
16
|
-
* `resolutionContext` is not part of the general public api
|
|
17
|
-
* but is exposed to aid in creating extensions like
|
|
18
|
-
* `@mswjs/http-middleware`.
|
|
19
|
-
*/
|
|
20
|
-
resolutionContext?: ResponseResolutionContext
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Invoked whenever a request is performed as-is.
|
|
24
|
-
*/
|
|
25
|
-
onPassthroughResponse?(request: Request): void
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Invoked when the mocked response is ready to be sent.
|
|
29
|
-
*/
|
|
30
|
-
onMockedResponse?(
|
|
31
|
-
response: Response,
|
|
32
|
-
handler: RequiredDeep<HandlersExecutionResult>,
|
|
33
|
-
): void
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export async function handleRequest(
|
|
37
|
-
request: Request,
|
|
38
|
-
requestId: string,
|
|
39
|
-
handlers: Array<RequestHandler>,
|
|
40
|
-
options: RequiredDeep<SharedOptions>,
|
|
41
|
-
emitter: Emitter<LifeCycleEventsMap>,
|
|
42
|
-
handleRequestOptions?: HandleRequestOptions,
|
|
43
|
-
): Promise<Response | undefined> {
|
|
44
|
-
emitter.emit('request:start', { request, requestId })
|
|
45
|
-
|
|
46
|
-
// Perform requests wrapped in "bypass()" as-is.
|
|
47
|
-
if (request.headers.get('accept')?.includes('msw/passthrough')) {
|
|
48
|
-
emitter.emit('request:end', { request, requestId })
|
|
49
|
-
handleRequestOptions?.onPassthroughResponse?.(request)
|
|
50
|
-
return
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// Resolve a mocked response from the list of request handlers.
|
|
54
|
-
const [lookupError, lookupResult] = await until(() => {
|
|
55
|
-
return executeHandlers({
|
|
56
|
-
request,
|
|
57
|
-
requestId,
|
|
58
|
-
handlers,
|
|
59
|
-
resolutionContext: handleRequestOptions?.resolutionContext,
|
|
60
|
-
})
|
|
61
|
-
})
|
|
62
|
-
|
|
63
|
-
if (lookupError) {
|
|
64
|
-
// Allow developers to react to unhandled exceptions in request handlers.
|
|
65
|
-
emitter.emit('unhandledException', {
|
|
66
|
-
error: lookupError,
|
|
67
|
-
request,
|
|
68
|
-
requestId,
|
|
69
|
-
})
|
|
70
|
-
throw lookupError
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// If the handler lookup returned nothing, no request handler was found
|
|
74
|
-
// matching this request. Report the request as unhandled.
|
|
75
|
-
if (!lookupResult) {
|
|
76
|
-
await onUnhandledRequest(request, options.onUnhandledRequest)
|
|
77
|
-
emitter.emit('request:unhandled', { request, requestId })
|
|
78
|
-
emitter.emit('request:end', { request, requestId })
|
|
79
|
-
handleRequestOptions?.onPassthroughResponse?.(request)
|
|
80
|
-
return
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
const { response } = lookupResult
|
|
84
|
-
|
|
85
|
-
// When the handled request returned no mocked response, warn the developer,
|
|
86
|
-
// as it may be an oversight on their part. Perform the request as-is.
|
|
87
|
-
if (!response) {
|
|
88
|
-
emitter.emit('request:end', { request, requestId })
|
|
89
|
-
handleRequestOptions?.onPassthroughResponse?.(request)
|
|
90
|
-
return
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
// Perform the request as-is when the developer explicitly returned "req.passthrough()".
|
|
94
|
-
// This produces no warning as the request was handled.
|
|
95
|
-
if (
|
|
96
|
-
response.status === 302 &&
|
|
97
|
-
response.headers.get('x-msw-intention') === 'passthrough'
|
|
98
|
-
) {
|
|
99
|
-
emitter.emit('request:end', { request, requestId })
|
|
100
|
-
handleRequestOptions?.onPassthroughResponse?.(request)
|
|
101
|
-
return
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// Store all the received response cookies in the cookie jar.
|
|
105
|
-
await storeResponseCookies(request, response)
|
|
106
|
-
|
|
107
|
-
emitter.emit('request:match', { request, requestId })
|
|
108
|
-
|
|
109
|
-
const requiredLookupResult =
|
|
110
|
-
lookupResult as RequiredDeep<HandlersExecutionResult>
|
|
111
|
-
|
|
112
|
-
handleRequestOptions?.onMockedResponse?.(response, requiredLookupResult)
|
|
113
|
-
|
|
114
|
-
emitter.emit('request:end', { request, requestId })
|
|
115
|
-
|
|
116
|
-
return response
|
|
117
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { invariant } from 'outvariant'
|
|
2
|
-
import { devUtils } from './devUtils'
|
|
3
|
-
|
|
4
|
-
export function checkGlobals() {
|
|
5
|
-
/**
|
|
6
|
-
* MSW expects the "URL" constructor to be defined.
|
|
7
|
-
* It's not present in React Native so suggest a polyfill
|
|
8
|
-
* instead of failing silently.
|
|
9
|
-
* @see https://github.com/mswjs/msw/issues/1408
|
|
10
|
-
*/
|
|
11
|
-
invariant(
|
|
12
|
-
typeof URL !== 'undefined',
|
|
13
|
-
devUtils.formatMessage(
|
|
14
|
-
`Global "URL" class is not defined. This likely means that you're running MSW in an environment that doesn't support all Node.js standard API (e.g. React Native). If that's the case, please use an appropriate polyfill for the "URL" class, like "react-native-url-polyfill".`,
|
|
15
|
-
),
|
|
16
|
-
)
|
|
17
|
-
}
|