msw 2.2.13 → 2.3.0-ws.rc-2
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/cli/init.js +0 -0
- package/config/scripts/postinstall.js +0 -0
- package/lib/browser/index.d.mts +7 -6
- package/lib/browser/index.d.ts +7 -6
- package/lib/browser/index.js +26 -7
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/index.mjs +26 -7
- package/lib/browser/index.mjs.map +1 -1
- package/lib/core/{GraphQLHandler-bom2Dn82.d.ts → GraphQLHandler-3gvpA65n.d.ts} +1 -1
- package/lib/core/{GraphQLHandler-yJ_I6j54.d.mts → GraphQLHandler-4DPdxG0R.d.mts} +1 -1
- package/lib/core/{HttpResponse-vQNlixkj.d.ts → HttpResponse-aJY-D0oG.d.ts} +2 -2
- package/lib/core/{HttpResponse-3-NyzyF7.d.mts → HttpResponse-xuSipbNt.d.mts} +2 -2
- package/lib/core/HttpResponse.d.mts +1 -1
- package/lib/core/HttpResponse.d.ts +1 -1
- package/lib/core/SetupApi.d.mts +15 -12
- package/lib/core/SetupApi.d.ts +15 -12
- package/lib/core/SetupApi.js +3 -1
- package/lib/core/SetupApi.js.map +1 -1
- package/lib/core/SetupApi.mjs +3 -1
- package/lib/core/SetupApi.mjs.map +1 -1
- package/lib/core/getResponse.d.mts +1 -1
- package/lib/core/getResponse.d.ts +1 -1
- package/lib/core/graphql.d.mts +2 -2
- package/lib/core/graphql.d.ts +2 -2
- package/lib/core/handlers/GraphQLHandler.d.mts +2 -2
- package/lib/core/handlers/GraphQLHandler.d.ts +2 -2
- 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/WebSocketHandler.d.mts +32 -0
- package/lib/core/handlers/WebSocketHandler.d.ts +32 -0
- package/lib/core/handlers/WebSocketHandler.js +62 -0
- package/lib/core/handlers/WebSocketHandler.js.map +1 -0
- package/lib/core/handlers/WebSocketHandler.mjs +44 -0
- package/lib/core/handlers/WebSocketHandler.mjs.map +1 -0
- package/lib/core/http.d.mts +1 -1
- package/lib/core/http.d.ts +1 -1
- package/lib/core/index.d.mts +5 -2
- package/lib/core/index.d.ts +5 -2
- package/lib/core/index.js +5 -1
- package/lib/core/index.js.map +1 -1
- package/lib/core/index.mjs +7 -1
- package/lib/core/index.mjs.map +1 -1
- package/lib/core/passthrough.d.mts +1 -1
- package/lib/core/passthrough.d.ts +1 -1
- package/lib/core/utils/HttpResponse/decorators.d.mts +1 -1
- package/lib/core/utils/HttpResponse/decorators.d.ts +1 -1
- package/lib/core/utils/executeHandlers.d.mts +1 -1
- package/lib/core/utils/executeHandlers.d.ts +1 -1
- package/lib/core/utils/executeHandlers.js +4 -0
- package/lib/core/utils/executeHandlers.js.map +1 -1
- package/lib/core/utils/executeHandlers.mjs +6 -0
- package/lib/core/utils/executeHandlers.mjs.map +1 -1
- package/lib/core/utils/handleRequest.d.mts +2 -2
- package/lib/core/utils/handleRequest.d.ts +2 -2
- package/lib/core/utils/handleRequest.js.map +1 -1
- package/lib/core/utils/handleRequest.mjs.map +1 -1
- package/lib/core/utils/handleWebSocketEvent.d.mts +16 -0
- package/lib/core/utils/handleWebSocketEvent.d.ts +16 -0
- package/lib/core/utils/handleWebSocketEvent.js +59 -0
- package/lib/core/utils/handleWebSocketEvent.js.map +1 -0
- package/lib/core/utils/handleWebSocketEvent.mjs +39 -0
- package/lib/core/utils/handleWebSocketEvent.mjs.map +1 -0
- package/lib/core/utils/internal/parseGraphQLRequest.d.mts +2 -2
- package/lib/core/utils/internal/parseGraphQLRequest.d.ts +2 -2
- package/lib/core/utils/internal/parseMultipartData.d.mts +1 -1
- package/lib/core/utils/internal/parseMultipartData.d.ts +1 -1
- package/lib/core/utils/internal/requestHandlerUtils.d.mts +1 -1
- package/lib/core/utils/internal/requestHandlerUtils.d.ts +1 -1
- package/lib/core/utils/logging/getTimestamp.d.mts +4 -1
- package/lib/core/utils/logging/getTimestamp.d.ts +4 -1
- package/lib/core/utils/logging/getTimestamp.js +6 -2
- package/lib/core/utils/logging/getTimestamp.js.map +1 -1
- package/lib/core/utils/logging/getTimestamp.mjs +6 -2
- package/lib/core/utils/logging/getTimestamp.mjs.map +1 -1
- package/lib/core/utils/matching/matchRequestUrl.d.mts +2 -1
- package/lib/core/utils/matching/matchRequestUrl.d.ts +2 -1
- package/lib/core/utils/matching/matchRequestUrl.js +4 -0
- package/lib/core/utils/matching/matchRequestUrl.js.map +1 -1
- package/lib/core/utils/matching/matchRequestUrl.mjs +4 -0
- package/lib/core/utils/matching/matchRequestUrl.mjs.map +1 -1
- package/lib/core/ws/WebSocketClientManager.d.mts +64 -0
- package/lib/core/ws/WebSocketClientManager.d.ts +64 -0
- package/lib/core/ws/WebSocketClientManager.js +123 -0
- package/lib/core/ws/WebSocketClientManager.js.map +1 -0
- package/lib/core/ws/WebSocketClientManager.mjs +103 -0
- package/lib/core/ws/WebSocketClientManager.mjs.map +1 -0
- package/lib/core/ws/utils/attachWebSocketLogger.d.mts +34 -0
- package/lib/core/ws/utils/attachWebSocketLogger.d.ts +34 -0
- package/lib/core/ws/utils/attachWebSocketLogger.js +211 -0
- package/lib/core/ws/utils/attachWebSocketLogger.js.map +1 -0
- package/lib/core/ws/utils/attachWebSocketLogger.mjs +191 -0
- package/lib/core/ws/utils/attachWebSocketLogger.mjs.map +1 -0
- package/lib/core/ws/utils/getMessageLength.d.mts +11 -0
- package/lib/core/ws/utils/getMessageLength.d.ts +11 -0
- package/lib/core/ws/utils/getMessageLength.js +33 -0
- package/lib/core/ws/utils/getMessageLength.js.map +1 -0
- package/lib/core/ws/utils/getMessageLength.mjs +13 -0
- package/lib/core/ws/utils/getMessageLength.mjs.map +1 -0
- package/lib/core/ws/utils/getPublicData.d.mts +5 -0
- package/lib/core/ws/utils/getPublicData.d.ts +5 -0
- package/lib/core/ws/utils/getPublicData.js +36 -0
- package/lib/core/ws/utils/getPublicData.js.map +1 -0
- package/lib/core/ws/utils/getPublicData.mjs +16 -0
- package/lib/core/ws/utils/getPublicData.mjs.map +1 -0
- package/lib/core/ws/utils/truncateMessage.d.mts +3 -0
- package/lib/core/ws/utils/truncateMessage.d.ts +3 -0
- package/lib/core/ws/utils/truncateMessage.js +31 -0
- package/lib/core/ws/utils/truncateMessage.js.map +1 -0
- package/lib/core/ws/utils/truncateMessage.mjs +11 -0
- package/lib/core/ws/utils/truncateMessage.mjs.map +1 -0
- package/lib/core/ws/webSocketInterceptor.d.mts +5 -0
- package/lib/core/ws/webSocketInterceptor.d.ts +5 -0
- package/lib/core/ws/webSocketInterceptor.js +26 -0
- package/lib/core/ws/webSocketInterceptor.js.map +1 -0
- package/lib/core/ws/webSocketInterceptor.mjs +6 -0
- package/lib/core/ws/webSocketInterceptor.mjs.map +1 -0
- package/lib/core/ws/ws.d.mts +44 -0
- package/lib/core/ws/ws.d.ts +44 -0
- package/lib/core/ws/ws.js +82 -0
- package/lib/core/ws/ws.js.map +1 -0
- package/lib/core/ws/ws.mjs +65 -0
- package/lib/core/ws/ws.mjs.map +1 -0
- package/lib/iife/index.js +967 -11
- package/lib/iife/index.js.map +1 -1
- package/lib/mockServiceWorker.js +1 -1
- package/lib/native/index.d.mts +6 -5
- package/lib/native/index.d.ts +6 -5
- package/lib/native/index.js +13 -0
- package/lib/native/index.js.map +1 -1
- package/lib/native/index.mjs +13 -0
- package/lib/native/index.mjs.map +1 -1
- package/lib/node/index.d.mts +8 -7
- package/lib/node/index.d.ts +8 -7
- package/lib/node/index.js +13 -0
- package/lib/node/index.js.map +1 -1
- package/lib/node/index.mjs +13 -0
- package/lib/node/index.mjs.map +1 -1
- package/package.json +26 -21
- package/src/browser/setupWorker/glossary.ts +10 -10
- package/src/browser/setupWorker/setupWorker.ts +34 -3
- package/src/core/SetupApi.ts +28 -20
- package/src/core/handlers/WebSocketHandler.ts +71 -0
- package/src/core/index.ts +8 -1
- package/src/core/utils/executeHandlers.ts +6 -2
- package/src/core/utils/handleRequest.ts +1 -2
- package/src/core/utils/handleWebSocketEvent.ts +59 -0
- package/src/core/utils/logging/getTimestamp.test.ts +20 -6
- package/src/core/utils/logging/getTimestamp.ts +11 -6
- package/src/core/utils/matching/matchRequestUrl.test.ts +44 -0
- package/src/core/utils/matching/matchRequestUrl.ts +4 -0
- package/src/core/ws/WebSocketClientManager.test.ts +159 -0
- package/src/core/ws/WebSocketClientManager.ts +170 -0
- package/src/core/ws/utils/attachWebSocketLogger.ts +262 -0
- package/src/core/ws/utils/getMessageLength.test.ts +16 -0
- package/src/core/ws/utils/getMessageLength.ts +19 -0
- package/src/core/ws/utils/getPublicData.test.ts +38 -0
- package/src/core/ws/utils/getPublicData.ts +17 -0
- package/src/core/ws/utils/truncateMessage.test.ts +12 -0
- package/src/core/ws/utils/truncateMessage.ts +9 -0
- package/src/core/ws/webSocketInterceptor.ts +3 -0
- package/src/core/ws/ws.test.ts +23 -0
- package/src/core/ws/ws.ts +108 -0
- package/src/node/SetupServerApi.ts +8 -7
- package/src/node/SetupServerCommonApi.ts +14 -1
- package/src/node/glossary.ts +5 -7
- package/src/node/setupServer.ts +2 -1
package/lib/core/index.js
CHANGED
|
@@ -24,13 +24,15 @@ __export(core_exports, {
|
|
|
24
24
|
HttpMethods: () => import_HttpHandler.HttpMethods,
|
|
25
25
|
RequestHandler: () => import_RequestHandler.RequestHandler,
|
|
26
26
|
SetupApi: () => import_SetupApi.SetupApi,
|
|
27
|
+
WebSocketHandler: () => import_WebSocketHandler.WebSocketHandler,
|
|
27
28
|
bypass: () => import_bypass.bypass,
|
|
28
29
|
cleanUrl: () => import_cleanUrl.cleanUrl,
|
|
29
30
|
getResponse: () => import_getResponse.getResponse,
|
|
30
31
|
graphql: () => import_graphql.graphql,
|
|
31
32
|
http: () => import_http.http,
|
|
32
33
|
matchRequestUrl: () => import_matchRequestUrl.matchRequestUrl,
|
|
33
|
-
passthrough: () => import_passthrough.passthrough
|
|
34
|
+
passthrough: () => import_passthrough.passthrough,
|
|
35
|
+
ws: () => import_ws.ws
|
|
34
36
|
});
|
|
35
37
|
module.exports = __toCommonJS(core_exports);
|
|
36
38
|
var import_checkGlobals = require("./utils/internal/checkGlobals.js");
|
|
@@ -40,6 +42,8 @@ var import_http = require("./http.js");
|
|
|
40
42
|
var import_HttpHandler = require("./handlers/HttpHandler.js");
|
|
41
43
|
var import_graphql = require("./graphql.js");
|
|
42
44
|
var import_GraphQLHandler = require("./handlers/GraphQLHandler.js");
|
|
45
|
+
var import_ws = require("./ws/ws.js");
|
|
46
|
+
var import_WebSocketHandler = require("./handlers/WebSocketHandler.js");
|
|
43
47
|
var import_matchRequestUrl = require("./utils/matching/matchRequestUrl.js");
|
|
44
48
|
__reExport(core_exports, require("./utils/handleRequest.js"), module.exports);
|
|
45
49
|
var import_getResponse = require("./getResponse.js");
|
package/lib/core/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/index.ts"],"sourcesContent":["import { checkGlobals } from './utils/internal/checkGlobals'\n\nexport { SetupApi } from './SetupApi'\n\n/*
|
|
1
|
+
{"version":3,"sources":["../../src/core/index.ts"],"sourcesContent":["import { checkGlobals } from './utils/internal/checkGlobals'\n\nexport { SetupApi } from './SetupApi'\n\n/* HTTP handlers */\nexport { RequestHandler } from './handlers/RequestHandler'\nexport { http } from './http'\nexport { HttpHandler, HttpMethods } from './handlers/HttpHandler'\nexport { graphql } from './graphql'\nexport { GraphQLHandler } from './handlers/GraphQLHandler'\n\n/* WebSocket handler */\nexport { ws } from './ws/ws'\nexport {\n WebSocketHandler,\n type WebSocketHandlerEventMap,\n} from './handlers/WebSocketHandler'\n\n/* Utils */\nexport { matchRequestUrl } from './utils/matching/matchRequestUrl'\nexport * from './utils/handleRequest'\nexport { getResponse } from './getResponse'\nexport { cleanUrl } from './utils/url/cleanUrl'\n\n/**\n * Type definitions.\n */\n\nexport type { SharedOptions, LifeCycleEventsMap } from './sharedOptions'\n\nexport type {\n ResponseResolver,\n ResponseResolverReturnType,\n AsyncResponseResolverReturnType,\n RequestHandlerOptions,\n DefaultBodyType,\n DefaultRequestMultipartBody,\n JsonBodyType,\n} from './handlers/RequestHandler'\n\nexport type {\n RequestQuery,\n HttpRequestParsedResult,\n} from './handlers/HttpHandler'\nexport type { HttpRequestHandler, HttpResponseResolver } from './http'\n\nexport type {\n GraphQLQuery,\n GraphQLVariables,\n GraphQLRequestBody,\n GraphQLJsonRequestBody,\n} from './handlers/GraphQLHandler'\nexport type { GraphQLRequestHandler, GraphQLResponseResolver } from './graphql'\n\nexport type { Path, PathParams, Match } from './utils/matching/matchRequestUrl'\nexport type { ParsedGraphQLRequest } from './utils/internal/parseGraphQLRequest'\n\nexport * from './HttpResponse'\nexport * from './delay'\nexport { bypass } from './bypass'\nexport { passthrough } from './passthrough'\n\n// Validate environmental globals before executing any code.\n// This ensures that the library gives user-friendly errors\n// when ran in the environments that require additional polyfills\n// from the end user.\ncheckGlobals()\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAA6B;AAE7B,sBAAyB;AAGzB,4BAA+B;AAC/B,kBAAqB;AACrB,yBAAyC;AACzC,qBAAwB;AACxB,4BAA+B;AAG/B,gBAAmB;AACnB,8BAGO;AAGP,6BAAgC;AAChC,yBAAc,kCApBd;AAqBA,yBAA4B;AAC5B,sBAAyB;AAmCzB,yBAAc,2BAzDd;AA0DA,yBAAc,oBA1Dd;AA2DA,oBAAuB;AACvB,yBAA4B;AAAA,IAM5B,kCAAa;","names":[]}
|
package/lib/core/index.mjs
CHANGED
|
@@ -5,6 +5,10 @@ import { http } from './http.mjs';
|
|
|
5
5
|
import { HttpHandler, HttpMethods } from './handlers/HttpHandler.mjs';
|
|
6
6
|
import { graphql } from './graphql.mjs';
|
|
7
7
|
import { GraphQLHandler } from './handlers/GraphQLHandler.mjs';
|
|
8
|
+
import { ws } from './ws/ws.mjs';
|
|
9
|
+
import {
|
|
10
|
+
WebSocketHandler
|
|
11
|
+
} from './handlers/WebSocketHandler.mjs';
|
|
8
12
|
import { matchRequestUrl } from './utils/matching/matchRequestUrl.mjs';
|
|
9
13
|
export * from './utils/handleRequest.mjs';
|
|
10
14
|
import { getResponse } from './getResponse.mjs';
|
|
@@ -20,12 +24,14 @@ export {
|
|
|
20
24
|
HttpMethods,
|
|
21
25
|
RequestHandler,
|
|
22
26
|
SetupApi,
|
|
27
|
+
WebSocketHandler,
|
|
23
28
|
bypass,
|
|
24
29
|
cleanUrl,
|
|
25
30
|
getResponse,
|
|
26
31
|
graphql,
|
|
27
32
|
http,
|
|
28
33
|
matchRequestUrl,
|
|
29
|
-
passthrough
|
|
34
|
+
passthrough,
|
|
35
|
+
ws
|
|
30
36
|
};
|
|
31
37
|
//# sourceMappingURL=index.mjs.map
|
package/lib/core/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/index.ts"],"sourcesContent":["import { checkGlobals } from './utils/internal/checkGlobals'\n\nexport { SetupApi } from './SetupApi'\n\n/*
|
|
1
|
+
{"version":3,"sources":["../../src/core/index.ts"],"sourcesContent":["import { checkGlobals } from './utils/internal/checkGlobals'\n\nexport { SetupApi } from './SetupApi'\n\n/* HTTP handlers */\nexport { RequestHandler } from './handlers/RequestHandler'\nexport { http } from './http'\nexport { HttpHandler, HttpMethods } from './handlers/HttpHandler'\nexport { graphql } from './graphql'\nexport { GraphQLHandler } from './handlers/GraphQLHandler'\n\n/* WebSocket handler */\nexport { ws } from './ws/ws'\nexport {\n WebSocketHandler,\n type WebSocketHandlerEventMap,\n} from './handlers/WebSocketHandler'\n\n/* Utils */\nexport { matchRequestUrl } from './utils/matching/matchRequestUrl'\nexport * from './utils/handleRequest'\nexport { getResponse } from './getResponse'\nexport { cleanUrl } from './utils/url/cleanUrl'\n\n/**\n * Type definitions.\n */\n\nexport type { SharedOptions, LifeCycleEventsMap } from './sharedOptions'\n\nexport type {\n ResponseResolver,\n ResponseResolverReturnType,\n AsyncResponseResolverReturnType,\n RequestHandlerOptions,\n DefaultBodyType,\n DefaultRequestMultipartBody,\n JsonBodyType,\n} from './handlers/RequestHandler'\n\nexport type {\n RequestQuery,\n HttpRequestParsedResult,\n} from './handlers/HttpHandler'\nexport type { HttpRequestHandler, HttpResponseResolver } from './http'\n\nexport type {\n GraphQLQuery,\n GraphQLVariables,\n GraphQLRequestBody,\n GraphQLJsonRequestBody,\n} from './handlers/GraphQLHandler'\nexport type { GraphQLRequestHandler, GraphQLResponseResolver } from './graphql'\n\nexport type { Path, PathParams, Match } from './utils/matching/matchRequestUrl'\nexport type { ParsedGraphQLRequest } from './utils/internal/parseGraphQLRequest'\n\nexport * from './HttpResponse'\nexport * from './delay'\nexport { bypass } from './bypass'\nexport { passthrough } from './passthrough'\n\n// Validate environmental globals before executing any code.\n// This ensures that the library gives user-friendly errors\n// when ran in the environments that require additional polyfills\n// from the end user.\ncheckGlobals()\n"],"mappings":"AAAA,SAAS,oBAAoB;AAE7B,SAAS,gBAAgB;AAGzB,SAAS,sBAAsB;AAC/B,SAAS,YAAY;AACrB,SAAS,aAAa,mBAAmB;AACzC,SAAS,eAAe;AACxB,SAAS,sBAAsB;AAG/B,SAAS,UAAU;AACnB;AAAA,EACE;AAAA,OAEK;AAGP,SAAS,uBAAuB;AAChC,cAAc;AACd,SAAS,mBAAmB;AAC5B,SAAS,gBAAgB;AAmCzB,cAAc;AACd,cAAc;AACd,SAAS,cAAc;AACvB,SAAS,mBAAmB;AAM5B,aAAa;","names":[]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { g as HandlersExecutionResult, i as ResponseResolutionContext, j as executeHandlers } from '../HttpResponse-xuSipbNt.mjs';
|
|
2
2
|
import '../typeUtils.mjs';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { g as HandlersExecutionResult, i as ResponseResolutionContext, j as executeHandlers } from '../HttpResponse-aJY-D0oG.js';
|
|
2
2
|
import '../typeUtils.js';
|
|
@@ -21,6 +21,7 @@ __export(executeHandlers_exports, {
|
|
|
21
21
|
executeHandlers: () => executeHandlers
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(executeHandlers_exports);
|
|
24
|
+
var import_RequestHandler = require("../handlers/RequestHandler.js");
|
|
24
25
|
const executeHandlers = async ({
|
|
25
26
|
request,
|
|
26
27
|
requestId,
|
|
@@ -30,6 +31,9 @@ const executeHandlers = async ({
|
|
|
30
31
|
let matchingHandler = null;
|
|
31
32
|
let result = null;
|
|
32
33
|
for (const handler of handlers) {
|
|
34
|
+
if (!(handler instanceof import_RequestHandler.RequestHandler)) {
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
33
37
|
result = await handler.run({ request, requestId, resolutionContext });
|
|
34
38
|
if (result !== null) {
|
|
35
39
|
matchingHandler = handler;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/core/utils/executeHandlers.ts"],"sourcesContent":["import {\n RequestHandler,\n RequestHandlerExecutionResult,\n} from '../handlers/RequestHandler'\n\nexport interface HandlersExecutionResult {\n handler: RequestHandler\n parsedResult?: any\n response?: Response\n}\n\nexport interface ResponseResolutionContext {\n baseUrl?: string\n}\n\n/**\n * Executes the list of request handlers against the given request.\n * Returns the execution result object containing any matching request\n * handler and any mocked response it returned.\n */\nexport const executeHandlers = async <Handlers extends Array<
|
|
1
|
+
{"version":3,"sources":["../../../src/core/utils/executeHandlers.ts"],"sourcesContent":["import {\n RequestHandler,\n type RequestHandlerExecutionResult,\n} from '../handlers/RequestHandler'\n\nexport interface HandlersExecutionResult {\n handler: RequestHandler\n parsedResult?: any\n response?: Response\n}\n\nexport interface ResponseResolutionContext {\n baseUrl?: string\n}\n\n/**\n * Executes the list of request handlers against the given request.\n * Returns the execution result object containing any matching request\n * handler and any mocked response it returned.\n */\nexport const executeHandlers = async <Handlers extends Array<unknown>>({\n request,\n requestId,\n handlers,\n resolutionContext,\n}: {\n request: Request\n requestId: string\n handlers: Handlers\n resolutionContext?: ResponseResolutionContext\n}): Promise<HandlersExecutionResult | null> => {\n let matchingHandler: RequestHandler | null = null\n let result: RequestHandlerExecutionResult<any> | null = null\n\n for (const handler of handlers) {\n if (!(handler instanceof RequestHandler)) {\n continue\n }\n\n result = await handler.run({ request, requestId, resolutionContext })\n\n // If the handler produces some result for this request,\n // it automatically becomes matching.\n if (result !== null) {\n matchingHandler = handler\n }\n\n // Stop the lookup if this handler returns a mocked response.\n // If it doesn't, it will still be considered the last matching\n // handler until any of them returns a response. This way we can\n // distinguish between fallthrough handlers without responses\n // and the lack of a matching handler.\n if (result?.response) {\n break\n }\n }\n\n if (matchingHandler) {\n return {\n handler: matchingHandler,\n parsedResult: result?.parsedResult,\n response: result?.response,\n }\n }\n\n return null\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BAGO;AAiBA,MAAM,kBAAkB,OAAwC;AAAA,EACrE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAK+C;AAC7C,MAAI,kBAAyC;AAC7C,MAAI,SAAoD;AAExD,aAAW,WAAW,UAAU;AAC9B,QAAI,EAAE,mBAAmB,uCAAiB;AACxC;AAAA,IACF;AAEA,aAAS,MAAM,QAAQ,IAAI,EAAE,SAAS,WAAW,kBAAkB,CAAC;AAIpE,QAAI,WAAW,MAAM;AACnB,wBAAkB;AAAA,IACpB;AAOA,QAAI,QAAQ,UAAU;AACpB;AAAA,IACF;AAAA,EACF;AAEA,MAAI,iBAAiB;AACnB,WAAO;AAAA,MACL,SAAS;AAAA,MACT,cAAc,QAAQ;AAAA,MACtB,UAAU,QAAQ;AAAA,IACpB;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
RequestHandler
|
|
3
|
+
} from '../handlers/RequestHandler.mjs';
|
|
1
4
|
const executeHandlers = async ({
|
|
2
5
|
request,
|
|
3
6
|
requestId,
|
|
@@ -7,6 +10,9 @@ const executeHandlers = async ({
|
|
|
7
10
|
let matchingHandler = null;
|
|
8
11
|
let result = null;
|
|
9
12
|
for (const handler of handlers) {
|
|
13
|
+
if (!(handler instanceof RequestHandler)) {
|
|
14
|
+
continue;
|
|
15
|
+
}
|
|
10
16
|
result = await handler.run({ request, requestId, resolutionContext });
|
|
11
17
|
if (result !== null) {
|
|
12
18
|
matchingHandler = handler;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/core/utils/executeHandlers.ts"],"sourcesContent":["import {\n RequestHandler,\n RequestHandlerExecutionResult,\n} from '../handlers/RequestHandler'\n\nexport interface HandlersExecutionResult {\n handler: RequestHandler\n parsedResult?: any\n response?: Response\n}\n\nexport interface ResponseResolutionContext {\n baseUrl?: string\n}\n\n/**\n * Executes the list of request handlers against the given request.\n * Returns the execution result object containing any matching request\n * handler and any mocked response it returned.\n */\nexport const executeHandlers = async <Handlers extends Array<
|
|
1
|
+
{"version":3,"sources":["../../../src/core/utils/executeHandlers.ts"],"sourcesContent":["import {\n RequestHandler,\n type RequestHandlerExecutionResult,\n} from '../handlers/RequestHandler'\n\nexport interface HandlersExecutionResult {\n handler: RequestHandler\n parsedResult?: any\n response?: Response\n}\n\nexport interface ResponseResolutionContext {\n baseUrl?: string\n}\n\n/**\n * Executes the list of request handlers against the given request.\n * Returns the execution result object containing any matching request\n * handler and any mocked response it returned.\n */\nexport const executeHandlers = async <Handlers extends Array<unknown>>({\n request,\n requestId,\n handlers,\n resolutionContext,\n}: {\n request: Request\n requestId: string\n handlers: Handlers\n resolutionContext?: ResponseResolutionContext\n}): Promise<HandlersExecutionResult | null> => {\n let matchingHandler: RequestHandler | null = null\n let result: RequestHandlerExecutionResult<any> | null = null\n\n for (const handler of handlers) {\n if (!(handler instanceof RequestHandler)) {\n continue\n }\n\n result = await handler.run({ request, requestId, resolutionContext })\n\n // If the handler produces some result for this request,\n // it automatically becomes matching.\n if (result !== null) {\n matchingHandler = handler\n }\n\n // Stop the lookup if this handler returns a mocked response.\n // If it doesn't, it will still be considered the last matching\n // handler until any of them returns a response. This way we can\n // distinguish between fallthrough handlers without responses\n // and the lack of a matching handler.\n if (result?.response) {\n break\n }\n }\n\n if (matchingHandler) {\n return {\n handler: matchingHandler,\n parsedResult: result?.parsedResult,\n response: result?.response,\n }\n }\n\n return null\n}\n"],"mappings":"AAAA;AAAA,EACE;AAAA,OAEK;AAiBA,MAAM,kBAAkB,OAAwC;AAAA,EACrE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAK+C;AAC7C,MAAI,kBAAyC;AAC7C,MAAI,SAAoD;AAExD,aAAW,WAAW,UAAU;AAC9B,QAAI,EAAE,mBAAmB,iBAAiB;AACxC;AAAA,IACF;AAEA,aAAS,MAAM,QAAQ,IAAI,EAAE,SAAS,WAAW,kBAAkB,CAAC;AAIpE,QAAI,WAAW,MAAM;AACnB,wBAAkB;AAAA,IACpB;AAOA,QAAI,QAAQ,UAAU;AACpB;AAAA,IACF;AAAA,EACF;AAEA,MAAI,iBAAiB;AACnB,WAAO;AAAA,MACL,SAAS;AAAA,MACT,cAAc,QAAQ;AAAA,MACtB,UAAU,QAAQ;AAAA,IACpB;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Emitter } from 'strict-event-emitter';
|
|
2
|
-
import { h as HandlersExecutionResult, R as RequestHandler } from '../HttpResponse-3-NyzyF7.mjs';
|
|
3
2
|
import { SharedOptions, LifeCycleEventsMap } from '../sharedOptions.mjs';
|
|
4
3
|
import { RequiredDeep } from '../typeUtils.mjs';
|
|
4
|
+
import { g as HandlersExecutionResult } from '../HttpResponse-xuSipbNt.mjs';
|
|
5
5
|
import './request/onUnhandledRequest.mjs';
|
|
6
6
|
|
|
7
7
|
interface HandleRequestOptions {
|
|
@@ -32,6 +32,6 @@ interface HandleRequestOptions {
|
|
|
32
32
|
*/
|
|
33
33
|
onMockedResponse?(response: Response, handler: RequiredDeep<HandlersExecutionResult>): void;
|
|
34
34
|
}
|
|
35
|
-
declare function handleRequest(request: Request, requestId: string, handlers: Array<
|
|
35
|
+
declare function handleRequest(request: Request, requestId: string, handlers: Array<unknown>, options: RequiredDeep<SharedOptions>, emitter: Emitter<LifeCycleEventsMap>, handleRequestOptions?: HandleRequestOptions): Promise<Response | undefined>;
|
|
36
36
|
|
|
37
37
|
export { type HandleRequestOptions, handleRequest };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Emitter } from 'strict-event-emitter';
|
|
2
|
-
import { h as HandlersExecutionResult, R as RequestHandler } from '../HttpResponse-vQNlixkj.js';
|
|
3
2
|
import { SharedOptions, LifeCycleEventsMap } from '../sharedOptions.js';
|
|
4
3
|
import { RequiredDeep } from '../typeUtils.js';
|
|
4
|
+
import { g as HandlersExecutionResult } from '../HttpResponse-aJY-D0oG.js';
|
|
5
5
|
import './request/onUnhandledRequest.js';
|
|
6
6
|
|
|
7
7
|
interface HandleRequestOptions {
|
|
@@ -32,6 +32,6 @@ interface HandleRequestOptions {
|
|
|
32
32
|
*/
|
|
33
33
|
onMockedResponse?(response: Response, handler: RequiredDeep<HandlersExecutionResult>): void;
|
|
34
34
|
}
|
|
35
|
-
declare function handleRequest(request: Request, requestId: string, handlers: Array<
|
|
35
|
+
declare function handleRequest(request: Request, requestId: string, handlers: Array<unknown>, options: RequiredDeep<SharedOptions>, emitter: Emitter<LifeCycleEventsMap>, handleRequestOptions?: HandleRequestOptions): Promise<Response | undefined>;
|
|
36
36
|
|
|
37
37
|
export { type HandleRequestOptions, handleRequest };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/core/utils/handleRequest.ts"],"sourcesContent":["import { until } from '@open-draft/until'\nimport { Emitter } from 'strict-event-emitter'\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/core/utils/handleRequest.ts"],"sourcesContent":["import { until } from '@open-draft/until'\nimport { Emitter } from 'strict-event-emitter'\nimport { LifeCycleEventsMap, SharedOptions } from '../sharedOptions'\nimport { RequiredDeep } from '../typeUtils'\nimport { HandlersExecutionResult, executeHandlers } from './executeHandlers'\nimport { onUnhandledRequest } from './request/onUnhandledRequest'\nimport { readResponseCookies } from './request/readResponseCookies'\n\nexport interface HandleRequestOptions {\n /**\n * `resolutionContext` is not part of the general public api\n * but is exposed to aid in creating extensions like\n * `@mswjs/http-middleware`.\n */\n resolutionContext?: {\n /**\n * A base url to use when resolving relative urls.\n * @note This is primarily used by the `@mswjs/http-middleware`\n * to resolve relative urls in the context of the running server\n */\n baseUrl?: string\n }\n\n /**\n * Transforms a `MockedResponse` instance returned from a handler\n * to a response instance supported by the lower tooling (i.e. interceptors).\n */\n transformResponse?(response: Response): Response\n\n /**\n * Invoked whenever a request is performed as-is.\n */\n onPassthroughResponse?(request: Request): void\n\n /**\n * Invoked when the mocked response is ready to be sent.\n */\n onMockedResponse?(\n response: Response,\n handler: RequiredDeep<HandlersExecutionResult>,\n ): void\n}\n\nexport async function handleRequest(\n request: Request,\n requestId: string,\n handlers: Array<unknown>,\n options: RequiredDeep<SharedOptions>,\n emitter: Emitter<LifeCycleEventsMap>,\n handleRequestOptions?: HandleRequestOptions,\n): Promise<Response | undefined> {\n emitter.emit('request:start', { request, requestId })\n\n // Perform bypassed requests (i.e. wrapped in \"bypass()\") as-is.\n if (request.headers.get('x-msw-intention') === 'bypass') {\n emitter.emit('request:end', { request, requestId })\n handleRequestOptions?.onPassthroughResponse?.(request)\n return\n }\n\n // Resolve a mocked response from the list of request handlers.\n const lookupResult = await until(() => {\n return executeHandlers({\n request,\n requestId,\n handlers,\n resolutionContext: handleRequestOptions?.resolutionContext,\n })\n })\n\n if (lookupResult.error) {\n // Allow developers to react to unhandled exceptions in request handlers.\n emitter.emit('unhandledException', {\n error: lookupResult.error,\n request,\n requestId,\n })\n throw lookupResult.error\n }\n\n // If the handler lookup returned nothing, no request handler was found\n // matching this request. Report the request as unhandled.\n if (!lookupResult.data) {\n await onUnhandledRequest(request, options.onUnhandledRequest)\n emitter.emit('request:unhandled', { request, requestId })\n emitter.emit('request:end', { request, requestId })\n handleRequestOptions?.onPassthroughResponse?.(request)\n return\n }\n\n const { response } = lookupResult.data\n\n // When the handled request returned no mocked response, warn the developer,\n // as it may be an oversight on their part. Perform the request as-is.\n if (!response) {\n emitter.emit('request:end', { request, requestId })\n handleRequestOptions?.onPassthroughResponse?.(request)\n return\n }\n\n // Perform the request as-is when the developer explicitly returned \"req.passthrough()\".\n // This produces no warning as the request was handled.\n if (\n response.status === 302 &&\n response.headers.get('x-msw-intention') === 'passthrough'\n ) {\n emitter.emit('request:end', { request, requestId })\n handleRequestOptions?.onPassthroughResponse?.(request)\n return\n }\n\n // Store all the received response cookies in the virtual cookie store.\n readResponseCookies(request, response)\n\n emitter.emit('request:match', { request, requestId })\n\n const requiredLookupResult =\n lookupResult.data as RequiredDeep<HandlersExecutionResult>\n\n const transformedResponse =\n handleRequestOptions?.transformResponse?.(response) ||\n (response as any as Response)\n\n handleRequestOptions?.onMockedResponse?.(\n transformedResponse,\n requiredLookupResult,\n )\n\n emitter.emit('request:end', { request, requestId })\n\n return transformedResponse\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAsB;AAItB,6BAAyD;AACzD,gCAAmC;AACnC,iCAAoC;AAqCpC,eAAsB,cACpB,SACA,WACA,UACA,SACA,SACA,sBAC+B;AAC/B,UAAQ,KAAK,iBAAiB,EAAE,SAAS,UAAU,CAAC;AAGpD,MAAI,QAAQ,QAAQ,IAAI,iBAAiB,MAAM,UAAU;AACvD,YAAQ,KAAK,eAAe,EAAE,SAAS,UAAU,CAAC;AAClD,0BAAsB,wBAAwB,OAAO;AACrD;AAAA,EACF;AAGA,QAAM,eAAe,UAAM,oBAAM,MAAM;AACrC,eAAO,wCAAgB;AAAA,MACrB;AAAA,MACA;AAAA,MACA;AAAA,MACA,mBAAmB,sBAAsB;AAAA,IAC3C,CAAC;AAAA,EACH,CAAC;AAED,MAAI,aAAa,OAAO;AAEtB,YAAQ,KAAK,sBAAsB;AAAA,MACjC,OAAO,aAAa;AAAA,MACpB;AAAA,MACA;AAAA,IACF,CAAC;AACD,UAAM,aAAa;AAAA,EACrB;AAIA,MAAI,CAAC,aAAa,MAAM;AACtB,cAAM,8CAAmB,SAAS,QAAQ,kBAAkB;AAC5D,YAAQ,KAAK,qBAAqB,EAAE,SAAS,UAAU,CAAC;AACxD,YAAQ,KAAK,eAAe,EAAE,SAAS,UAAU,CAAC;AAClD,0BAAsB,wBAAwB,OAAO;AACrD;AAAA,EACF;AAEA,QAAM,EAAE,SAAS,IAAI,aAAa;AAIlC,MAAI,CAAC,UAAU;AACb,YAAQ,KAAK,eAAe,EAAE,SAAS,UAAU,CAAC;AAClD,0BAAsB,wBAAwB,OAAO;AACrD;AAAA,EACF;AAIA,MACE,SAAS,WAAW,OACpB,SAAS,QAAQ,IAAI,iBAAiB,MAAM,eAC5C;AACA,YAAQ,KAAK,eAAe,EAAE,SAAS,UAAU,CAAC;AAClD,0BAAsB,wBAAwB,OAAO;AACrD;AAAA,EACF;AAGA,sDAAoB,SAAS,QAAQ;AAErC,UAAQ,KAAK,iBAAiB,EAAE,SAAS,UAAU,CAAC;AAEpD,QAAM,uBACJ,aAAa;AAEf,QAAM,sBACJ,sBAAsB,oBAAoB,QAAQ,KACjD;AAEH,wBAAsB;AAAA,IACpB;AAAA,IACA;AAAA,EACF;AAEA,UAAQ,KAAK,eAAe,EAAE,SAAS,UAAU,CAAC;AAElD,SAAO;AACT;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/core/utils/handleRequest.ts"],"sourcesContent":["import { until } from '@open-draft/until'\nimport { Emitter } from 'strict-event-emitter'\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/core/utils/handleRequest.ts"],"sourcesContent":["import { until } from '@open-draft/until'\nimport { Emitter } from 'strict-event-emitter'\nimport { LifeCycleEventsMap, SharedOptions } from '../sharedOptions'\nimport { RequiredDeep } from '../typeUtils'\nimport { HandlersExecutionResult, executeHandlers } from './executeHandlers'\nimport { onUnhandledRequest } from './request/onUnhandledRequest'\nimport { readResponseCookies } from './request/readResponseCookies'\n\nexport interface HandleRequestOptions {\n /**\n * `resolutionContext` is not part of the general public api\n * but is exposed to aid in creating extensions like\n * `@mswjs/http-middleware`.\n */\n resolutionContext?: {\n /**\n * A base url to use when resolving relative urls.\n * @note This is primarily used by the `@mswjs/http-middleware`\n * to resolve relative urls in the context of the running server\n */\n baseUrl?: string\n }\n\n /**\n * Transforms a `MockedResponse` instance returned from a handler\n * to a response instance supported by the lower tooling (i.e. interceptors).\n */\n transformResponse?(response: Response): Response\n\n /**\n * Invoked whenever a request is performed as-is.\n */\n onPassthroughResponse?(request: Request): void\n\n /**\n * Invoked when the mocked response is ready to be sent.\n */\n onMockedResponse?(\n response: Response,\n handler: RequiredDeep<HandlersExecutionResult>,\n ): void\n}\n\nexport async function handleRequest(\n request: Request,\n requestId: string,\n handlers: Array<unknown>,\n options: RequiredDeep<SharedOptions>,\n emitter: Emitter<LifeCycleEventsMap>,\n handleRequestOptions?: HandleRequestOptions,\n): Promise<Response | undefined> {\n emitter.emit('request:start', { request, requestId })\n\n // Perform bypassed requests (i.e. wrapped in \"bypass()\") as-is.\n if (request.headers.get('x-msw-intention') === 'bypass') {\n emitter.emit('request:end', { request, requestId })\n handleRequestOptions?.onPassthroughResponse?.(request)\n return\n }\n\n // Resolve a mocked response from the list of request handlers.\n const lookupResult = await until(() => {\n return executeHandlers({\n request,\n requestId,\n handlers,\n resolutionContext: handleRequestOptions?.resolutionContext,\n })\n })\n\n if (lookupResult.error) {\n // Allow developers to react to unhandled exceptions in request handlers.\n emitter.emit('unhandledException', {\n error: lookupResult.error,\n request,\n requestId,\n })\n throw lookupResult.error\n }\n\n // If the handler lookup returned nothing, no request handler was found\n // matching this request. Report the request as unhandled.\n if (!lookupResult.data) {\n await onUnhandledRequest(request, options.onUnhandledRequest)\n emitter.emit('request:unhandled', { request, requestId })\n emitter.emit('request:end', { request, requestId })\n handleRequestOptions?.onPassthroughResponse?.(request)\n return\n }\n\n const { response } = lookupResult.data\n\n // When the handled request returned no mocked response, warn the developer,\n // as it may be an oversight on their part. Perform the request as-is.\n if (!response) {\n emitter.emit('request:end', { request, requestId })\n handleRequestOptions?.onPassthroughResponse?.(request)\n return\n }\n\n // Perform the request as-is when the developer explicitly returned \"req.passthrough()\".\n // This produces no warning as the request was handled.\n if (\n response.status === 302 &&\n response.headers.get('x-msw-intention') === 'passthrough'\n ) {\n emitter.emit('request:end', { request, requestId })\n handleRequestOptions?.onPassthroughResponse?.(request)\n return\n }\n\n // Store all the received response cookies in the virtual cookie store.\n readResponseCookies(request, response)\n\n emitter.emit('request:match', { request, requestId })\n\n const requiredLookupResult =\n lookupResult.data as RequiredDeep<HandlersExecutionResult>\n\n const transformedResponse =\n handleRequestOptions?.transformResponse?.(response) ||\n (response as any as Response)\n\n handleRequestOptions?.onMockedResponse?.(\n transformedResponse,\n requiredLookupResult,\n )\n\n emitter.emit('request:end', { request, requestId })\n\n return transformedResponse\n}\n"],"mappings":"AAAA,SAAS,aAAa;AAItB,SAAkC,uBAAuB;AACzD,SAAS,0BAA0B;AACnC,SAAS,2BAA2B;AAqCpC,eAAsB,cACpB,SACA,WACA,UACA,SACA,SACA,sBAC+B;AAC/B,UAAQ,KAAK,iBAAiB,EAAE,SAAS,UAAU,CAAC;AAGpD,MAAI,QAAQ,QAAQ,IAAI,iBAAiB,MAAM,UAAU;AACvD,YAAQ,KAAK,eAAe,EAAE,SAAS,UAAU,CAAC;AAClD,0BAAsB,wBAAwB,OAAO;AACrD;AAAA,EACF;AAGA,QAAM,eAAe,MAAM,MAAM,MAAM;AACrC,WAAO,gBAAgB;AAAA,MACrB;AAAA,MACA;AAAA,MACA;AAAA,MACA,mBAAmB,sBAAsB;AAAA,IAC3C,CAAC;AAAA,EACH,CAAC;AAED,MAAI,aAAa,OAAO;AAEtB,YAAQ,KAAK,sBAAsB;AAAA,MACjC,OAAO,aAAa;AAAA,MACpB;AAAA,MACA;AAAA,IACF,CAAC;AACD,UAAM,aAAa;AAAA,EACrB;AAIA,MAAI,CAAC,aAAa,MAAM;AACtB,UAAM,mBAAmB,SAAS,QAAQ,kBAAkB;AAC5D,YAAQ,KAAK,qBAAqB,EAAE,SAAS,UAAU,CAAC;AACxD,YAAQ,KAAK,eAAe,EAAE,SAAS,UAAU,CAAC;AAClD,0BAAsB,wBAAwB,OAAO;AACrD;AAAA,EACF;AAEA,QAAM,EAAE,SAAS,IAAI,aAAa;AAIlC,MAAI,CAAC,UAAU;AACb,YAAQ,KAAK,eAAe,EAAE,SAAS,UAAU,CAAC;AAClD,0BAAsB,wBAAwB,OAAO;AACrD;AAAA,EACF;AAIA,MACE,SAAS,WAAW,OACpB,SAAS,QAAQ,IAAI,iBAAiB,MAAM,eAC5C;AACA,YAAQ,KAAK,eAAe,EAAE,SAAS,UAAU,CAAC;AAClD,0BAAsB,wBAAwB,OAAO;AACrD;AAAA,EACF;AAGA,sBAAoB,SAAS,QAAQ;AAErC,UAAQ,KAAK,iBAAiB,EAAE,SAAS,UAAU,CAAC;AAEpD,QAAM,uBACJ,aAAa;AAEf,QAAM,sBACJ,sBAAsB,oBAAoB,QAAQ,KACjD;AAEH,wBAAsB;AAAA,IACpB;AAAA,IACA;AAAA,EACF;AAEA,UAAQ,KAAK,eAAe,EAAE,SAAS,UAAU,CAAC;AAElD,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { WebSocketConnectionData } from '@mswjs/interceptors/lib/browser/interceptors/WebSocket';
|
|
2
|
+
import { R as RequestHandler } from '../HttpResponse-xuSipbNt.mjs';
|
|
3
|
+
import { WebSocketHandler } from '../handlers/WebSocketHandler.mjs';
|
|
4
|
+
import '../typeUtils.mjs';
|
|
5
|
+
import 'strict-event-emitter';
|
|
6
|
+
import '@mswjs/interceptors/WebSocket';
|
|
7
|
+
import './matching/matchRequestUrl.mjs';
|
|
8
|
+
|
|
9
|
+
interface HandleWebSocketEventOptions {
|
|
10
|
+
getHandlers: () => Array<RequestHandler | WebSocketHandler>;
|
|
11
|
+
onMockedConnection: (connection: WebSocketConnectionData) => void;
|
|
12
|
+
onPassthroughConnection: (onnection: WebSocketConnectionData) => void;
|
|
13
|
+
}
|
|
14
|
+
declare function handleWebSocketEvent(options: HandleWebSocketEventOptions): void;
|
|
15
|
+
|
|
16
|
+
export { handleWebSocketEvent };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { WebSocketConnectionData } from '@mswjs/interceptors/lib/browser/interceptors/WebSocket';
|
|
2
|
+
import { R as RequestHandler } from '../HttpResponse-aJY-D0oG.js';
|
|
3
|
+
import { WebSocketHandler } from '../handlers/WebSocketHandler.js';
|
|
4
|
+
import '../typeUtils.js';
|
|
5
|
+
import 'strict-event-emitter';
|
|
6
|
+
import '@mswjs/interceptors/WebSocket';
|
|
7
|
+
import './matching/matchRequestUrl.js';
|
|
8
|
+
|
|
9
|
+
interface HandleWebSocketEventOptions {
|
|
10
|
+
getHandlers: () => Array<RequestHandler | WebSocketHandler>;
|
|
11
|
+
onMockedConnection: (connection: WebSocketConnectionData) => void;
|
|
12
|
+
onPassthroughConnection: (onnection: WebSocketConnectionData) => void;
|
|
13
|
+
}
|
|
14
|
+
declare function handleWebSocketEvent(options: HandleWebSocketEventOptions): void;
|
|
15
|
+
|
|
16
|
+
export { handleWebSocketEvent };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var handleWebSocketEvent_exports = {};
|
|
20
|
+
__export(handleWebSocketEvent_exports, {
|
|
21
|
+
handleWebSocketEvent: () => handleWebSocketEvent
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(handleWebSocketEvent_exports);
|
|
24
|
+
var import_WebSocketHandler = require("../handlers/WebSocketHandler.js");
|
|
25
|
+
var import_webSocketInterceptor = require("../ws/webSocketInterceptor.js");
|
|
26
|
+
function handleWebSocketEvent(options) {
|
|
27
|
+
import_webSocketInterceptor.webSocketInterceptor.on("connection", (connection) => {
|
|
28
|
+
const handlers = options.getHandlers();
|
|
29
|
+
const connectionEvent = new MessageEvent("connection", {
|
|
30
|
+
data: connection
|
|
31
|
+
});
|
|
32
|
+
const matchingHandlers = handlers.filter(
|
|
33
|
+
(handler) => {
|
|
34
|
+
if (handler instanceof import_WebSocketHandler.WebSocketHandler) {
|
|
35
|
+
return handler.predicate({
|
|
36
|
+
event: connectionEvent,
|
|
37
|
+
parsedResult: handler.parse({
|
|
38
|
+
event: connectionEvent
|
|
39
|
+
})
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
);
|
|
45
|
+
if (matchingHandlers.length > 0) {
|
|
46
|
+
options?.onMockedConnection(connection);
|
|
47
|
+
for (const handler of matchingHandlers) {
|
|
48
|
+
handler[import_WebSocketHandler.kDispatchEvent](connectionEvent);
|
|
49
|
+
}
|
|
50
|
+
} else {
|
|
51
|
+
options?.onPassthroughConnection(connection);
|
|
52
|
+
connection.server.connect();
|
|
53
|
+
connection.client.addEventListener("message", (event) => {
|
|
54
|
+
connection.server.send(event.data);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=handleWebSocketEvent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/core/utils/handleWebSocketEvent.ts"],"sourcesContent":["import type { WebSocketConnectionData } from '@mswjs/interceptors/lib/browser/interceptors/WebSocket'\nimport { RequestHandler } from '../handlers/RequestHandler'\nimport { WebSocketHandler, kDispatchEvent } from '../handlers/WebSocketHandler'\nimport { webSocketInterceptor } from '../ws/webSocketInterceptor'\n\ninterface HandleWebSocketEventOptions {\n getHandlers: () => Array<RequestHandler | WebSocketHandler>\n onMockedConnection: (connection: WebSocketConnectionData) => void\n onPassthroughConnection: (onnection: WebSocketConnectionData) => void\n}\n\nexport function handleWebSocketEvent(options: HandleWebSocketEventOptions) {\n webSocketInterceptor.on('connection', (connection) => {\n const handlers = options.getHandlers()\n\n const connectionEvent = new MessageEvent('connection', {\n data: connection,\n })\n\n // First, filter only those WebSocket handlers that\n // match the \"ws.link()\" endpoint predicate. Don't dispatch\n // anything yet so the logger can be attached to the connection\n // before it potentially sends events.\n const matchingHandlers = handlers.filter<WebSocketHandler>(\n (handler): handler is WebSocketHandler => {\n if (handler instanceof WebSocketHandler) {\n return handler.predicate({\n event: connectionEvent,\n parsedResult: handler.parse({\n event: connectionEvent,\n }),\n })\n }\n\n return false\n },\n )\n\n if (matchingHandlers.length > 0) {\n options?.onMockedConnection(connection)\n\n // Iterate over the handlers and forward the connection\n // event to WebSocket event handlers. This is equivalent\n // to dispatching that event onto multiple listeners.\n for (const handler of matchingHandlers) {\n handler[kDispatchEvent](connectionEvent)\n }\n } else {\n options?.onPassthroughConnection(connection)\n\n // If none of the \"ws\" handlers matched,\n // establish the WebSocket connection as-is.\n connection.server.connect()\n connection.client.addEventListener('message', (event) => {\n connection.server.send(event.data)\n })\n }\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,8BAAiD;AACjD,kCAAqC;AAQ9B,SAAS,qBAAqB,SAAsC;AACzE,mDAAqB,GAAG,cAAc,CAAC,eAAe;AACpD,UAAM,WAAW,QAAQ,YAAY;AAErC,UAAM,kBAAkB,IAAI,aAAa,cAAc;AAAA,MACrD,MAAM;AAAA,IACR,CAAC;AAMD,UAAM,mBAAmB,SAAS;AAAA,MAChC,CAAC,YAAyC;AACxC,YAAI,mBAAmB,0CAAkB;AACvC,iBAAO,QAAQ,UAAU;AAAA,YACvB,OAAO;AAAA,YACP,cAAc,QAAQ,MAAM;AAAA,cAC1B,OAAO;AAAA,YACT,CAAC;AAAA,UACH,CAAC;AAAA,QACH;AAEA,eAAO;AAAA,MACT;AAAA,IACF;AAEA,QAAI,iBAAiB,SAAS,GAAG;AAC/B,eAAS,mBAAmB,UAAU;AAKtC,iBAAW,WAAW,kBAAkB;AACtC,gBAAQ,sCAAc,EAAE,eAAe;AAAA,MACzC;AAAA,IACF,OAAO;AACL,eAAS,wBAAwB,UAAU;AAI3C,iBAAW,OAAO,QAAQ;AAC1B,iBAAW,OAAO,iBAAiB,WAAW,CAAC,UAAU;AACvD,mBAAW,OAAO,KAAK,MAAM,IAAI;AAAA,MACnC,CAAC;AAAA,IACH;AAAA,EACF,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { WebSocketHandler, kDispatchEvent } from '../handlers/WebSocketHandler.mjs';
|
|
2
|
+
import { webSocketInterceptor } from '../ws/webSocketInterceptor.mjs';
|
|
3
|
+
function handleWebSocketEvent(options) {
|
|
4
|
+
webSocketInterceptor.on("connection", (connection) => {
|
|
5
|
+
const handlers = options.getHandlers();
|
|
6
|
+
const connectionEvent = new MessageEvent("connection", {
|
|
7
|
+
data: connection
|
|
8
|
+
});
|
|
9
|
+
const matchingHandlers = handlers.filter(
|
|
10
|
+
(handler) => {
|
|
11
|
+
if (handler instanceof WebSocketHandler) {
|
|
12
|
+
return handler.predicate({
|
|
13
|
+
event: connectionEvent,
|
|
14
|
+
parsedResult: handler.parse({
|
|
15
|
+
event: connectionEvent
|
|
16
|
+
})
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
if (matchingHandlers.length > 0) {
|
|
23
|
+
options?.onMockedConnection(connection);
|
|
24
|
+
for (const handler of matchingHandlers) {
|
|
25
|
+
handler[kDispatchEvent](connectionEvent);
|
|
26
|
+
}
|
|
27
|
+
} else {
|
|
28
|
+
options?.onPassthroughConnection(connection);
|
|
29
|
+
connection.server.connect();
|
|
30
|
+
connection.client.addEventListener("message", (event) => {
|
|
31
|
+
connection.server.send(event.data);
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
export {
|
|
37
|
+
handleWebSocketEvent
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=handleWebSocketEvent.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/core/utils/handleWebSocketEvent.ts"],"sourcesContent":["import type { WebSocketConnectionData } from '@mswjs/interceptors/lib/browser/interceptors/WebSocket'\nimport { RequestHandler } from '../handlers/RequestHandler'\nimport { WebSocketHandler, kDispatchEvent } from '../handlers/WebSocketHandler'\nimport { webSocketInterceptor } from '../ws/webSocketInterceptor'\n\ninterface HandleWebSocketEventOptions {\n getHandlers: () => Array<RequestHandler | WebSocketHandler>\n onMockedConnection: (connection: WebSocketConnectionData) => void\n onPassthroughConnection: (onnection: WebSocketConnectionData) => void\n}\n\nexport function handleWebSocketEvent(options: HandleWebSocketEventOptions) {\n webSocketInterceptor.on('connection', (connection) => {\n const handlers = options.getHandlers()\n\n const connectionEvent = new MessageEvent('connection', {\n data: connection,\n })\n\n // First, filter only those WebSocket handlers that\n // match the \"ws.link()\" endpoint predicate. Don't dispatch\n // anything yet so the logger can be attached to the connection\n // before it potentially sends events.\n const matchingHandlers = handlers.filter<WebSocketHandler>(\n (handler): handler is WebSocketHandler => {\n if (handler instanceof WebSocketHandler) {\n return handler.predicate({\n event: connectionEvent,\n parsedResult: handler.parse({\n event: connectionEvent,\n }),\n })\n }\n\n return false\n },\n )\n\n if (matchingHandlers.length > 0) {\n options?.onMockedConnection(connection)\n\n // Iterate over the handlers and forward the connection\n // event to WebSocket event handlers. This is equivalent\n // to dispatching that event onto multiple listeners.\n for (const handler of matchingHandlers) {\n handler[kDispatchEvent](connectionEvent)\n }\n } else {\n options?.onPassthroughConnection(connection)\n\n // If none of the \"ws\" handlers matched,\n // establish the WebSocket connection as-is.\n connection.server.connect()\n connection.client.addEventListener('message', (event) => {\n connection.server.send(event.data)\n })\n }\n })\n}\n"],"mappings":"AAEA,SAAS,kBAAkB,sBAAsB;AACjD,SAAS,4BAA4B;AAQ9B,SAAS,qBAAqB,SAAsC;AACzE,uBAAqB,GAAG,cAAc,CAAC,eAAe;AACpD,UAAM,WAAW,QAAQ,YAAY;AAErC,UAAM,kBAAkB,IAAI,aAAa,cAAc;AAAA,MACrD,MAAM;AAAA,IACR,CAAC;AAMD,UAAM,mBAAmB,SAAS;AAAA,MAChC,CAAC,YAAyC;AACxC,YAAI,mBAAmB,kBAAkB;AACvC,iBAAO,QAAQ,UAAU;AAAA,YACvB,OAAO;AAAA,YACP,cAAc,QAAQ,MAAM;AAAA,cAC1B,OAAO;AAAA,YACT,CAAC;AAAA,UACH,CAAC;AAAA,QACH;AAEA,eAAO;AAAA,MACT;AAAA,IACF;AAEA,QAAI,iBAAiB,SAAS,GAAG;AAC/B,eAAS,mBAAmB,UAAU;AAKtC,iBAAW,WAAW,kBAAkB;AACtC,gBAAQ,cAAc,EAAE,eAAe;AAAA,MACzC;AAAA,IACF,OAAO;AACL,eAAS,wBAAwB,UAAU;AAI3C,iBAAW,OAAO,QAAQ;AAC1B,iBAAW,OAAO,iBAAiB,WAAW,CAAC,UAAU;AACvD,mBAAW,OAAO,KAAK,MAAM,IAAI;AAAA,MACnC,CAAC;AAAA,IACH;AAAA,EACF,CAAC;AACH;","names":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import 'graphql';
|
|
2
|
-
export { j as GraphQLMultipartRequestBody, i as GraphQLParsedOperationsMap, h as ParsedGraphQLQuery, P as ParsedGraphQLRequest, p as parseDocumentNode, k as parseGraphQLRequest } from '../../GraphQLHandler-
|
|
3
|
-
import '../../HttpResponse-
|
|
2
|
+
export { j as GraphQLMultipartRequestBody, i as GraphQLParsedOperationsMap, h as ParsedGraphQLQuery, P as ParsedGraphQLRequest, p as parseDocumentNode, k as parseGraphQLRequest } from '../../GraphQLHandler-4DPdxG0R.mjs';
|
|
3
|
+
import '../../HttpResponse-xuSipbNt.mjs';
|
|
4
4
|
import '../../typeUtils.mjs';
|
|
5
5
|
import '../matching/matchRequestUrl.mjs';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import 'graphql';
|
|
2
|
-
export { j as GraphQLMultipartRequestBody, i as GraphQLParsedOperationsMap, h as ParsedGraphQLQuery, P as ParsedGraphQLRequest, p as parseDocumentNode, k as parseGraphQLRequest } from '../../GraphQLHandler-
|
|
3
|
-
import '../../HttpResponse-
|
|
2
|
+
export { j as GraphQLMultipartRequestBody, i as GraphQLParsedOperationsMap, h as ParsedGraphQLQuery, P as ParsedGraphQLRequest, p as parseDocumentNode, k as parseGraphQLRequest } from '../../GraphQLHandler-3gvpA65n.js';
|
|
3
|
+
import '../../HttpResponse-aJY-D0oG.js';
|
|
4
4
|
import '../../typeUtils.js';
|
|
5
5
|
import '../matching/matchRequestUrl.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { R as RequestHandler,
|
|
1
|
+
import { R as RequestHandler, h as RequestHandlerDefaultInfo, c as RequestHandlerOptions } from '../../HttpResponse-xuSipbNt.mjs';
|
|
2
2
|
import '../../typeUtils.mjs';
|
|
3
3
|
|
|
4
4
|
declare function use(currentHandlers: Array<RequestHandler>, ...handlers: Array<RequestHandler>): void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { R as RequestHandler,
|
|
1
|
+
import { R as RequestHandler, h as RequestHandlerDefaultInfo, c as RequestHandlerOptions } from '../../HttpResponse-aJY-D0oG.js';
|
|
2
2
|
import '../../typeUtils.js';
|
|
3
3
|
|
|
4
4
|
declare function use(currentHandlers: Array<RequestHandler>, ...handlers: Array<RequestHandler>): void;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
interface GetTimestampOptions {
|
|
2
|
+
milliseconds?: boolean;
|
|
3
|
+
}
|
|
1
4
|
/**
|
|
2
5
|
* Returns a timestamp string in a "HH:MM:SS" format.
|
|
3
6
|
*/
|
|
4
|
-
declare function getTimestamp(): string;
|
|
7
|
+
declare function getTimestamp(options?: GetTimestampOptions): string;
|
|
5
8
|
|
|
6
9
|
export { getTimestamp };
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
interface GetTimestampOptions {
|
|
2
|
+
milliseconds?: boolean;
|
|
3
|
+
}
|
|
1
4
|
/**
|
|
2
5
|
* Returns a timestamp string in a "HH:MM:SS" format.
|
|
3
6
|
*/
|
|
4
|
-
declare function getTimestamp(): string;
|
|
7
|
+
declare function getTimestamp(options?: GetTimestampOptions): string;
|
|
5
8
|
|
|
6
9
|
export { getTimestamp };
|
|
@@ -21,8 +21,12 @@ __export(getTimestamp_exports, {
|
|
|
21
21
|
getTimestamp: () => getTimestamp
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(getTimestamp_exports);
|
|
24
|
-
function getTimestamp() {
|
|
24
|
+
function getTimestamp(options) {
|
|
25
25
|
const now = /* @__PURE__ */ new Date();
|
|
26
|
-
|
|
26
|
+
const timestamp = `${now.getHours().toString().padStart(2, "0")}:${now.getMinutes().toString().padStart(2, "0")}:${now.getSeconds().toString().padStart(2, "0")}`;
|
|
27
|
+
if (options?.milliseconds) {
|
|
28
|
+
return `${timestamp}.${now.getMilliseconds().toString().padStart(3, "0")}`;
|
|
29
|
+
}
|
|
30
|
+
return timestamp;
|
|
27
31
|
}
|
|
28
32
|
//# sourceMappingURL=getTimestamp.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/core/utils/logging/getTimestamp.ts"],"sourcesContent":["/**\n * Returns a timestamp string in a \"HH:MM:SS\" format.\n */\nexport function getTimestamp(): string {\n const now = new Date()\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/core/utils/logging/getTimestamp.ts"],"sourcesContent":["interface GetTimestampOptions {\n milliseconds?: boolean\n}\n\n/**\n * Returns a timestamp string in a \"HH:MM:SS\" format.\n */\nexport function getTimestamp(options?: GetTimestampOptions): string {\n const now = new Date()\n const timestamp = `${now.getHours().toString().padStart(2, '0')}:${now.getMinutes().toString().padStart(2, '0')}:${now.getSeconds().toString().padStart(2, '0')}`\n\n if (options?.milliseconds) {\n return `${timestamp}.${now.getMilliseconds().toString().padStart(3, '0')}`\n }\n\n return timestamp\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOO,SAAS,aAAa,SAAuC;AAClE,QAAM,MAAM,oBAAI,KAAK;AACrB,QAAM,YAAY,GAAG,IAAI,SAAS,EAAE,SAAS,EAAE,SAAS,GAAG,GAAG,CAAC,IAAI,IAAI,WAAW,EAAE,SAAS,EAAE,SAAS,GAAG,GAAG,CAAC,IAAI,IAAI,WAAW,EAAE,SAAS,EAAE,SAAS,GAAG,GAAG,CAAC;AAE/J,MAAI,SAAS,cAAc;AACzB,WAAO,GAAG,SAAS,IAAI,IAAI,gBAAgB,EAAE,SAAS,EAAE,SAAS,GAAG,GAAG,CAAC;AAAA,EAC1E;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
function getTimestamp() {
|
|
1
|
+
function getTimestamp(options) {
|
|
2
2
|
const now = /* @__PURE__ */ new Date();
|
|
3
|
-
|
|
3
|
+
const timestamp = `${now.getHours().toString().padStart(2, "0")}:${now.getMinutes().toString().padStart(2, "0")}:${now.getSeconds().toString().padStart(2, "0")}`;
|
|
4
|
+
if (options?.milliseconds) {
|
|
5
|
+
return `${timestamp}.${now.getMilliseconds().toString().padStart(3, "0")}`;
|
|
6
|
+
}
|
|
7
|
+
return timestamp;
|
|
4
8
|
}
|
|
5
9
|
export {
|
|
6
10
|
getTimestamp
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/core/utils/logging/getTimestamp.ts"],"sourcesContent":["/**\n * Returns a timestamp string in a \"HH:MM:SS\" format.\n */\nexport function getTimestamp(): string {\n const now = new Date()\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/core/utils/logging/getTimestamp.ts"],"sourcesContent":["interface GetTimestampOptions {\n milliseconds?: boolean\n}\n\n/**\n * Returns a timestamp string in a \"HH:MM:SS\" format.\n */\nexport function getTimestamp(options?: GetTimestampOptions): string {\n const now = new Date()\n const timestamp = `${now.getHours().toString().padStart(2, '0')}:${now.getMinutes().toString().padStart(2, '0')}:${now.getSeconds().toString().padStart(2, '0')}`\n\n if (options?.milliseconds) {\n return `${timestamp}.${now.getMilliseconds().toString().padStart(3, '0')}`\n }\n\n return timestamp\n}\n"],"mappings":"AAOO,SAAS,aAAa,SAAuC;AAClE,QAAM,MAAM,oBAAI,KAAK;AACrB,QAAM,YAAY,GAAG,IAAI,SAAS,EAAE,SAAS,EAAE,SAAS,GAAG,GAAG,CAAC,IAAI,IAAI,WAAW,EAAE,SAAS,EAAE,SAAS,GAAG,GAAG,CAAC,IAAI,IAAI,WAAW,EAAE,SAAS,EAAE,SAAS,GAAG,GAAG,CAAC;AAE/J,MAAI,SAAS,cAAc;AACzB,WAAO,GAAG,SAAS,IAAI,IAAI,gBAAgB,EAAE,SAAS,EAAE,SAAS,GAAG,GAAG,CAAC;AAAA,EAC1E;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -15,5 +15,6 @@ declare function coercePath(path: string): string;
|
|
|
15
15
|
* Returns the result of matching given request URL against a mask.
|
|
16
16
|
*/
|
|
17
17
|
declare function matchRequestUrl(url: URL, path: Path, baseUrl?: string): Match;
|
|
18
|
+
declare function isPath(value: unknown): value is Path;
|
|
18
19
|
|
|
19
|
-
export { type Match, type Path, type PathParams, coercePath, matchRequestUrl };
|
|
20
|
+
export { type Match, type Path, type PathParams, coercePath, isPath, matchRequestUrl };
|
|
@@ -15,5 +15,6 @@ declare function coercePath(path: string): string;
|
|
|
15
15
|
* Returns the result of matching given request URL against a mask.
|
|
16
16
|
*/
|
|
17
17
|
declare function matchRequestUrl(url: URL, path: Path, baseUrl?: string): Match;
|
|
18
|
+
declare function isPath(value: unknown): value is Path;
|
|
18
19
|
|
|
19
|
-
export { type Match, type Path, type PathParams, coercePath, matchRequestUrl };
|
|
20
|
+
export { type Match, type Path, type PathParams, coercePath, isPath, matchRequestUrl };
|
|
@@ -19,6 +19,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
19
19
|
var matchRequestUrl_exports = {};
|
|
20
20
|
__export(matchRequestUrl_exports, {
|
|
21
21
|
coercePath: () => coercePath,
|
|
22
|
+
isPath: () => isPath,
|
|
22
23
|
matchRequestUrl: () => matchRequestUrl
|
|
23
24
|
});
|
|
24
25
|
module.exports = __toCommonJS(matchRequestUrl_exports);
|
|
@@ -48,4 +49,7 @@ function matchRequestUrl(url, path, baseUrl) {
|
|
|
48
49
|
params
|
|
49
50
|
};
|
|
50
51
|
}
|
|
52
|
+
function isPath(value) {
|
|
53
|
+
return typeof value === "string" || value instanceof RegExp;
|
|
54
|
+
}
|
|
51
55
|
//# sourceMappingURL=matchRequestUrl.js.map
|