msw 2.5.2 → 2.6.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.
Files changed (190) hide show
  1. package/lib/browser/index.d.mts +7 -6
  2. package/lib/browser/index.d.ts +7 -6
  3. package/lib/browser/index.js +29 -1
  4. package/lib/browser/index.js.map +1 -1
  5. package/lib/browser/index.mjs +29 -1
  6. package/lib/browser/index.mjs.map +1 -1
  7. package/lib/core/{GraphQLHandler-ClMB0BOy.d.mts → GraphQLHandler-Doool6Q_.d.mts} +1 -1
  8. package/lib/core/{GraphQLHandler-D6mLMXGZ.d.ts → GraphQLHandler-udzgBRPf.d.ts} +1 -1
  9. package/lib/core/{HttpResponse-vn-Pb4Bi.d.mts → HttpResponse-BLGmJolh.d.mts} +1 -1
  10. package/lib/core/{HttpResponse-DaYkf3ml.d.ts → HttpResponse-Cgbkdkje.d.ts} +1 -1
  11. package/lib/core/HttpResponse.d.mts +1 -1
  12. package/lib/core/HttpResponse.d.ts +1 -1
  13. package/lib/core/SetupApi.d.mts +15 -12
  14. package/lib/core/SetupApi.d.ts +15 -12
  15. package/lib/core/SetupApi.js +3 -1
  16. package/lib/core/SetupApi.js.map +1 -1
  17. package/lib/core/SetupApi.mjs +3 -1
  18. package/lib/core/SetupApi.mjs.map +1 -1
  19. package/lib/core/getResponse.d.mts +1 -1
  20. package/lib/core/getResponse.d.ts +1 -1
  21. package/lib/core/graphql.d.mts +2 -2
  22. package/lib/core/graphql.d.ts +2 -2
  23. package/lib/core/handlers/GraphQLHandler.d.mts +2 -2
  24. package/lib/core/handlers/GraphQLHandler.d.ts +2 -2
  25. package/lib/core/handlers/HttpHandler.d.mts +1 -1
  26. package/lib/core/handlers/HttpHandler.d.ts +1 -1
  27. package/lib/core/handlers/RequestHandler.d.mts +1 -1
  28. package/lib/core/handlers/RequestHandler.d.ts +1 -1
  29. package/lib/core/handlers/WebSocketHandler.d.mts +33 -0
  30. package/lib/core/handlers/WebSocketHandler.d.ts +33 -0
  31. package/lib/core/handlers/WebSocketHandler.js +120 -0
  32. package/lib/core/handlers/WebSocketHandler.js.map +1 -0
  33. package/lib/core/handlers/WebSocketHandler.mjs +102 -0
  34. package/lib/core/handlers/WebSocketHandler.mjs.map +1 -0
  35. package/lib/core/http.d.mts +1 -1
  36. package/lib/core/http.d.ts +1 -1
  37. package/lib/core/index.d.mts +5 -2
  38. package/lib/core/index.d.ts +5 -2
  39. package/lib/core/index.js +5 -1
  40. package/lib/core/index.js.map +1 -1
  41. package/lib/core/index.mjs +7 -1
  42. package/lib/core/index.mjs.map +1 -1
  43. package/lib/core/passthrough.d.mts +1 -1
  44. package/lib/core/passthrough.d.ts +1 -1
  45. package/lib/core/utils/HttpResponse/decorators.d.mts +1 -1
  46. package/lib/core/utils/HttpResponse/decorators.d.ts +1 -1
  47. package/lib/core/utils/executeHandlers.d.mts +1 -1
  48. package/lib/core/utils/executeHandlers.d.ts +1 -1
  49. package/lib/core/utils/executeHandlers.js +4 -0
  50. package/lib/core/utils/executeHandlers.js.map +1 -1
  51. package/lib/core/utils/executeHandlers.mjs +6 -0
  52. package/lib/core/utils/executeHandlers.mjs.map +1 -1
  53. package/lib/core/utils/handleRequest.d.mts +2 -2
  54. package/lib/core/utils/handleRequest.d.ts +2 -2
  55. package/lib/core/utils/handleRequest.js.map +1 -1
  56. package/lib/core/utils/handleRequest.mjs.map +1 -1
  57. package/lib/core/utils/internal/parseGraphQLRequest.d.mts +2 -2
  58. package/lib/core/utils/internal/parseGraphQLRequest.d.ts +2 -2
  59. package/lib/core/utils/internal/parseMultipartData.d.mts +1 -1
  60. package/lib/core/utils/internal/parseMultipartData.d.ts +1 -1
  61. package/lib/core/utils/internal/requestHandlerUtils.d.mts +1 -1
  62. package/lib/core/utils/internal/requestHandlerUtils.d.ts +1 -1
  63. package/lib/core/utils/logging/getTimestamp.d.mts +4 -1
  64. package/lib/core/utils/logging/getTimestamp.d.ts +4 -1
  65. package/lib/core/utils/logging/getTimestamp.js +6 -2
  66. package/lib/core/utils/logging/getTimestamp.js.map +1 -1
  67. package/lib/core/utils/logging/getTimestamp.mjs +6 -2
  68. package/lib/core/utils/logging/getTimestamp.mjs.map +1 -1
  69. package/lib/core/utils/matching/matchRequestUrl.d.mts +2 -1
  70. package/lib/core/utils/matching/matchRequestUrl.d.ts +2 -1
  71. package/lib/core/utils/matching/matchRequestUrl.js +4 -0
  72. package/lib/core/utils/matching/matchRequestUrl.js.map +1 -1
  73. package/lib/core/utils/matching/matchRequestUrl.mjs +4 -0
  74. package/lib/core/utils/matching/matchRequestUrl.mjs.map +1 -1
  75. package/lib/core/ws/WebSocketClientManager.d.mts +63 -0
  76. package/lib/core/ws/WebSocketClientManager.d.ts +63 -0
  77. package/lib/core/ws/WebSocketClientManager.js +149 -0
  78. package/lib/core/ws/WebSocketClientManager.js.map +1 -0
  79. package/lib/core/ws/WebSocketClientManager.mjs +129 -0
  80. package/lib/core/ws/WebSocketClientManager.mjs.map +1 -0
  81. package/lib/core/ws/WebSocketClientStore.d.mts +13 -0
  82. package/lib/core/ws/WebSocketClientStore.d.ts +13 -0
  83. package/lib/core/ws/WebSocketClientStore.js +26 -0
  84. package/lib/core/ws/WebSocketClientStore.js.map +1 -0
  85. package/lib/core/ws/WebSocketClientStore.mjs +6 -0
  86. package/lib/core/ws/WebSocketClientStore.mjs.map +1 -0
  87. package/lib/core/ws/WebSocketIndexedDBClientStore.d.mts +15 -0
  88. package/lib/core/ws/WebSocketIndexedDBClientStore.d.ts +15 -0
  89. package/lib/core/ws/WebSocketIndexedDBClientStore.js +130 -0
  90. package/lib/core/ws/WebSocketIndexedDBClientStore.js.map +1 -0
  91. package/lib/core/ws/WebSocketIndexedDBClientStore.mjs +110 -0
  92. package/lib/core/ws/WebSocketIndexedDBClientStore.mjs.map +1 -0
  93. package/lib/core/ws/WebSocketMemoryClientStore.d.mts +13 -0
  94. package/lib/core/ws/WebSocketMemoryClientStore.d.ts +13 -0
  95. package/lib/core/ws/WebSocketMemoryClientStore.js +41 -0
  96. package/lib/core/ws/WebSocketMemoryClientStore.js.map +1 -0
  97. package/lib/core/ws/WebSocketMemoryClientStore.mjs +21 -0
  98. package/lib/core/ws/WebSocketMemoryClientStore.mjs.map +1 -0
  99. package/lib/core/ws/handleWebSocketEvent.d.mts +19 -0
  100. package/lib/core/ws/handleWebSocketEvent.d.ts +19 -0
  101. package/lib/core/ws/handleWebSocketEvent.js +73 -0
  102. package/lib/core/ws/handleWebSocketEvent.js.map +1 -0
  103. package/lib/core/ws/handleWebSocketEvent.mjs +55 -0
  104. package/lib/core/ws/handleWebSocketEvent.mjs.map +1 -0
  105. package/lib/core/ws/utils/attachWebSocketLogger.d.mts +12 -0
  106. package/lib/core/ws/utils/attachWebSocketLogger.d.ts +12 -0
  107. package/lib/core/ws/utils/attachWebSocketLogger.js +198 -0
  108. package/lib/core/ws/utils/attachWebSocketLogger.js.map +1 -0
  109. package/lib/core/ws/utils/attachWebSocketLogger.mjs +178 -0
  110. package/lib/core/ws/utils/attachWebSocketLogger.mjs.map +1 -0
  111. package/lib/core/ws/utils/getMessageLength.d.mts +11 -0
  112. package/lib/core/ws/utils/getMessageLength.d.ts +11 -0
  113. package/lib/core/ws/utils/getMessageLength.js +33 -0
  114. package/lib/core/ws/utils/getMessageLength.js.map +1 -0
  115. package/lib/core/ws/utils/getMessageLength.mjs +13 -0
  116. package/lib/core/ws/utils/getMessageLength.mjs.map +1 -0
  117. package/lib/core/ws/utils/getPublicData.d.mts +5 -0
  118. package/lib/core/ws/utils/getPublicData.d.ts +5 -0
  119. package/lib/core/ws/utils/getPublicData.js +36 -0
  120. package/lib/core/ws/utils/getPublicData.js.map +1 -0
  121. package/lib/core/ws/utils/getPublicData.mjs +16 -0
  122. package/lib/core/ws/utils/getPublicData.mjs.map +1 -0
  123. package/lib/core/ws/utils/truncateMessage.d.mts +3 -0
  124. package/lib/core/ws/utils/truncateMessage.d.ts +3 -0
  125. package/lib/core/ws/utils/truncateMessage.js +31 -0
  126. package/lib/core/ws/utils/truncateMessage.js.map +1 -0
  127. package/lib/core/ws/utils/truncateMessage.mjs +11 -0
  128. package/lib/core/ws/utils/truncateMessage.mjs.map +1 -0
  129. package/lib/core/ws/webSocketInterceptor.d.mts +5 -0
  130. package/lib/core/ws/webSocketInterceptor.d.ts +5 -0
  131. package/lib/core/ws/webSocketInterceptor.js +26 -0
  132. package/lib/core/ws/webSocketInterceptor.js.map +1 -0
  133. package/lib/core/ws/webSocketInterceptor.mjs +6 -0
  134. package/lib/core/ws/webSocketInterceptor.mjs.map +1 -0
  135. package/lib/core/ws.d.mts +75 -0
  136. package/lib/core/ws.d.ts +75 -0
  137. package/lib/core/ws.js +71 -0
  138. package/lib/core/ws.js.map +1 -0
  139. package/lib/core/ws.mjs +54 -0
  140. package/lib/core/ws.mjs.map +1 -0
  141. package/lib/iife/index.js +1413 -85
  142. package/lib/iife/index.js.map +1 -1
  143. package/lib/mockServiceWorker.js +1 -1
  144. package/lib/native/index.d.mts +6 -5
  145. package/lib/native/index.d.ts +6 -5
  146. package/lib/native/index.js +22 -4
  147. package/lib/native/index.js.map +1 -1
  148. package/lib/native/index.mjs +22 -4
  149. package/lib/native/index.mjs.map +1 -1
  150. package/lib/node/index.d.mts +8 -7
  151. package/lib/node/index.d.ts +8 -7
  152. package/lib/node/index.js +22 -4
  153. package/lib/node/index.js.map +1 -1
  154. package/lib/node/index.mjs +22 -4
  155. package/lib/node/index.mjs.map +1 -1
  156. package/package.json +10 -1
  157. package/src/browser/setupWorker/glossary.ts +10 -10
  158. package/src/browser/setupWorker/setupWorker.ts +32 -3
  159. package/src/browser/setupWorker/start/createRequestListener.ts +7 -1
  160. package/src/browser/setupWorker/start/createStartHandler.ts +5 -0
  161. package/src/browser/setupWorker/stop/createStop.ts +6 -0
  162. package/src/core/SetupApi.ts +28 -20
  163. package/src/core/handlers/WebSocketHandler.ts +142 -0
  164. package/src/core/index.ts +11 -1
  165. package/src/core/utils/executeHandlers.ts +6 -2
  166. package/src/core/utils/handleRequest.ts +1 -1
  167. package/src/core/utils/logging/getTimestamp.test.ts +20 -6
  168. package/src/core/utils/logging/getTimestamp.ts +11 -6
  169. package/src/core/utils/matching/matchRequestUrl.test.ts +44 -0
  170. package/src/core/utils/matching/matchRequestUrl.ts +4 -0
  171. package/src/core/ws/WebSocketClientManager.test.ts +164 -0
  172. package/src/core/ws/WebSocketClientManager.ts +211 -0
  173. package/src/core/ws/WebSocketClientStore.ts +14 -0
  174. package/src/core/ws/WebSocketIndexedDBClientStore.ts +145 -0
  175. package/src/core/ws/WebSocketMemoryClientStore.ts +27 -0
  176. package/src/core/ws/handleWebSocketEvent.ts +82 -0
  177. package/src/core/ws/utils/attachWebSocketLogger.ts +259 -0
  178. package/src/core/ws/utils/getMessageLength.test.ts +16 -0
  179. package/src/core/ws/utils/getMessageLength.ts +19 -0
  180. package/src/core/ws/utils/getPublicData.test.ts +38 -0
  181. package/src/core/ws/utils/getPublicData.ts +17 -0
  182. package/src/core/ws/utils/truncateMessage.test.ts +12 -0
  183. package/src/core/ws/utils/truncateMessage.ts +9 -0
  184. package/src/core/ws/webSocketInterceptor.ts +3 -0
  185. package/src/core/ws.test.ts +23 -0
  186. package/src/core/ws.ts +166 -0
  187. package/src/node/SetupServerApi.ts +8 -7
  188. package/src/node/SetupServerCommonApi.ts +29 -5
  189. package/src/node/glossary.ts +5 -7
  190. package/src/node/setupServer.ts +2 -1
@@ -0,0 +1,102 @@
1
+ import { Emitter } from "strict-event-emitter";
2
+ import { createRequestId } from "@mswjs/interceptors";
3
+ import {
4
+ matchRequestUrl
5
+ } from '../utils/matching/matchRequestUrl.mjs';
6
+ import { getCallFrame } from '../utils/internal/getCallFrame.mjs';
7
+ const kEmitter = Symbol("kEmitter");
8
+ const kDispatchEvent = Symbol("kDispatchEvent");
9
+ const kSender = Symbol("kSender");
10
+ const kStopPropagationPatched = Symbol("kStopPropagationPatched");
11
+ const KOnStopPropagation = Symbol("KOnStopPropagation");
12
+ class WebSocketHandler {
13
+ constructor(url) {
14
+ this.url = url;
15
+ this.id = createRequestId();
16
+ this[kEmitter] = new Emitter();
17
+ this.callFrame = getCallFrame(new Error());
18
+ }
19
+ id;
20
+ callFrame;
21
+ [kEmitter];
22
+ parse(args) {
23
+ const connection = args.event.data;
24
+ const match = matchRequestUrl(connection.client.url, this.url);
25
+ return {
26
+ match
27
+ };
28
+ }
29
+ predicate(args) {
30
+ return args.parsedResult.match.matches;
31
+ }
32
+ async [kDispatchEvent](event) {
33
+ const parsedResult = this.parse({ event });
34
+ const connection = event.data;
35
+ const resolvedConnection = {
36
+ ...connection,
37
+ params: parsedResult.match.params || {}
38
+ };
39
+ connection.client.addEventListener(
40
+ "message",
41
+ createStopPropagationListener(this)
42
+ );
43
+ connection.client.addEventListener(
44
+ "close",
45
+ createStopPropagationListener(this)
46
+ );
47
+ connection.server.addEventListener(
48
+ "open",
49
+ createStopPropagationListener(this)
50
+ );
51
+ connection.server.addEventListener(
52
+ "message",
53
+ createStopPropagationListener(this)
54
+ );
55
+ connection.server.addEventListener(
56
+ "error",
57
+ createStopPropagationListener(this)
58
+ );
59
+ connection.server.addEventListener(
60
+ "close",
61
+ createStopPropagationListener(this)
62
+ );
63
+ this[kEmitter].emit("connection", resolvedConnection);
64
+ }
65
+ }
66
+ function createStopPropagationListener(handler) {
67
+ return function stopPropagationListener(event) {
68
+ const propagationStoppedAt = Reflect.get(event, "kPropagationStoppedAt");
69
+ if (propagationStoppedAt && handler.id !== propagationStoppedAt) {
70
+ event.stopImmediatePropagation();
71
+ return;
72
+ }
73
+ Object.defineProperty(event, KOnStopPropagation, {
74
+ value() {
75
+ Object.defineProperty(event, "kPropagationStoppedAt", {
76
+ value: handler.id
77
+ });
78
+ },
79
+ configurable: true
80
+ });
81
+ if (!Reflect.get(event, kStopPropagationPatched)) {
82
+ event.stopPropagation = new Proxy(event.stopPropagation, {
83
+ apply: (target, thisArg, args) => {
84
+ Reflect.get(event, KOnStopPropagation)?.call(handler);
85
+ return Reflect.apply(target, thisArg, args);
86
+ }
87
+ });
88
+ Object.defineProperty(event, kStopPropagationPatched, {
89
+ value: true,
90
+ // If something else attempts to redefine this, throw.
91
+ configurable: false
92
+ });
93
+ }
94
+ };
95
+ }
96
+ export {
97
+ WebSocketHandler,
98
+ kDispatchEvent,
99
+ kEmitter,
100
+ kSender
101
+ };
102
+ //# sourceMappingURL=WebSocketHandler.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/core/handlers/WebSocketHandler.ts"],"sourcesContent":["import { Emitter } from 'strict-event-emitter'\nimport { createRequestId } from '@mswjs/interceptors'\nimport type { WebSocketConnectionData } from '@mswjs/interceptors/WebSocket'\nimport {\n type Match,\n type Path,\n type PathParams,\n matchRequestUrl,\n} from '../utils/matching/matchRequestUrl'\nimport { getCallFrame } from '../utils/internal/getCallFrame'\n\ntype WebSocketHandlerParsedResult = {\n match: Match\n}\n\nexport type WebSocketHandlerEventMap = {\n connection: [args: WebSocketHandlerConnection]\n}\n\nexport interface WebSocketHandlerConnection extends WebSocketConnectionData {\n params: PathParams\n}\n\nexport const kEmitter = Symbol('kEmitter')\nexport const kDispatchEvent = Symbol('kDispatchEvent')\nexport const kSender = Symbol('kSender')\nconst kStopPropagationPatched = Symbol('kStopPropagationPatched')\nconst KOnStopPropagation = Symbol('KOnStopPropagation')\n\nexport class WebSocketHandler {\n public id: string\n public callFrame?: string\n\n protected [kEmitter]: Emitter<WebSocketHandlerEventMap>\n\n constructor(private readonly url: Path) {\n this.id = createRequestId()\n\n this[kEmitter] = new Emitter()\n this.callFrame = getCallFrame(new Error())\n }\n\n public parse(args: {\n event: MessageEvent<WebSocketConnectionData>\n }): WebSocketHandlerParsedResult {\n const connection = args.event.data\n const match = matchRequestUrl(connection.client.url, this.url)\n\n return {\n match,\n }\n }\n\n public predicate(args: {\n event: MessageEvent<WebSocketConnectionData>\n parsedResult: WebSocketHandlerParsedResult\n }): boolean {\n return args.parsedResult.match.matches\n }\n\n async [kDispatchEvent](\n event: MessageEvent<WebSocketConnectionData>,\n ): Promise<void> {\n const parsedResult = this.parse({ event })\n const connection = event.data\n\n const resolvedConnection: WebSocketHandlerConnection = {\n ...connection,\n params: parsedResult.match.params || {},\n }\n\n // Support `event.stopPropagation()` for various client/server events.\n connection.client.addEventListener(\n 'message',\n createStopPropagationListener(this),\n )\n connection.client.addEventListener(\n 'close',\n createStopPropagationListener(this),\n )\n\n connection.server.addEventListener(\n 'open',\n createStopPropagationListener(this),\n )\n connection.server.addEventListener(\n 'message',\n createStopPropagationListener(this),\n )\n connection.server.addEventListener(\n 'error',\n createStopPropagationListener(this),\n )\n connection.server.addEventListener(\n 'close',\n createStopPropagationListener(this),\n )\n\n // Emit the connection event on the handler.\n // This is what the developer adds listeners for.\n this[kEmitter].emit('connection', resolvedConnection)\n }\n}\n\nfunction createStopPropagationListener(handler: WebSocketHandler) {\n return function stopPropagationListener(event: Event) {\n const propagationStoppedAt = Reflect.get(event, 'kPropagationStoppedAt') as\n | string\n | undefined\n\n if (propagationStoppedAt && handler.id !== propagationStoppedAt) {\n event.stopImmediatePropagation()\n return\n }\n\n Object.defineProperty(event, KOnStopPropagation, {\n value(this: WebSocketHandler) {\n Object.defineProperty(event, 'kPropagationStoppedAt', {\n value: handler.id,\n })\n },\n configurable: true,\n })\n\n // Since the same event instance is shared between all client/server objects,\n // make sure to patch its `stopPropagation` method only once.\n if (!Reflect.get(event, kStopPropagationPatched)) {\n event.stopPropagation = new Proxy(event.stopPropagation, {\n apply: (target, thisArg, args) => {\n Reflect.get(event, KOnStopPropagation)?.call(handler)\n return Reflect.apply(target, thisArg, args)\n },\n })\n\n Object.defineProperty(event, kStopPropagationPatched, {\n value: true,\n // If something else attempts to redefine this, throw.\n configurable: false,\n })\n }\n }\n}\n"],"mappings":"AAAA,SAAS,eAAe;AACxB,SAAS,uBAAuB;AAEhC;AAAA,EAIE;AAAA,OACK;AACP,SAAS,oBAAoB;AActB,MAAM,WAAW,OAAO,UAAU;AAClC,MAAM,iBAAiB,OAAO,gBAAgB;AAC9C,MAAM,UAAU,OAAO,SAAS;AACvC,MAAM,0BAA0B,OAAO,yBAAyB;AAChE,MAAM,qBAAqB,OAAO,oBAAoB;AAE/C,MAAM,iBAAiB;AAAA,EAM5B,YAA6B,KAAW;AAAX;AAC3B,SAAK,KAAK,gBAAgB;AAE1B,SAAK,QAAQ,IAAI,IAAI,QAAQ;AAC7B,SAAK,YAAY,aAAa,IAAI,MAAM,CAAC;AAAA,EAC3C;AAAA,EAVO;AAAA,EACA;AAAA,EAEP,CAAW,QAAQ;AAAA,EASZ,MAAM,MAEoB;AAC/B,UAAM,aAAa,KAAK,MAAM;AAC9B,UAAM,QAAQ,gBAAgB,WAAW,OAAO,KAAK,KAAK,GAAG;AAE7D,WAAO;AAAA,MACL;AAAA,IACF;AAAA,EACF;AAAA,EAEO,UAAU,MAGL;AACV,WAAO,KAAK,aAAa,MAAM;AAAA,EACjC;AAAA,EAEA,OAAO,cAAc,EACnB,OACe;AACf,UAAM,eAAe,KAAK,MAAM,EAAE,MAAM,CAAC;AACzC,UAAM,aAAa,MAAM;AAEzB,UAAM,qBAAiD;AAAA,MACrD,GAAG;AAAA,MACH,QAAQ,aAAa,MAAM,UAAU,CAAC;AAAA,IACxC;AAGA,eAAW,OAAO;AAAA,MAChB;AAAA,MACA,8BAA8B,IAAI;AAAA,IACpC;AACA,eAAW,OAAO;AAAA,MAChB;AAAA,MACA,8BAA8B,IAAI;AAAA,IACpC;AAEA,eAAW,OAAO;AAAA,MAChB;AAAA,MACA,8BAA8B,IAAI;AAAA,IACpC;AACA,eAAW,OAAO;AAAA,MAChB;AAAA,MACA,8BAA8B,IAAI;AAAA,IACpC;AACA,eAAW,OAAO;AAAA,MAChB;AAAA,MACA,8BAA8B,IAAI;AAAA,IACpC;AACA,eAAW,OAAO;AAAA,MAChB;AAAA,MACA,8BAA8B,IAAI;AAAA,IACpC;AAIA,SAAK,QAAQ,EAAE,KAAK,cAAc,kBAAkB;AAAA,EACtD;AACF;AAEA,SAAS,8BAA8B,SAA2B;AAChE,SAAO,SAAS,wBAAwB,OAAc;AACpD,UAAM,uBAAuB,QAAQ,IAAI,OAAO,uBAAuB;AAIvE,QAAI,wBAAwB,QAAQ,OAAO,sBAAsB;AAC/D,YAAM,yBAAyB;AAC/B;AAAA,IACF;AAEA,WAAO,eAAe,OAAO,oBAAoB;AAAA,MAC/C,QAA8B;AAC5B,eAAO,eAAe,OAAO,yBAAyB;AAAA,UACpD,OAAO,QAAQ;AAAA,QACjB,CAAC;AAAA,MACH;AAAA,MACA,cAAc;AAAA,IAChB,CAAC;AAID,QAAI,CAAC,QAAQ,IAAI,OAAO,uBAAuB,GAAG;AAChD,YAAM,kBAAkB,IAAI,MAAM,MAAM,iBAAiB;AAAA,QACvD,OAAO,CAAC,QAAQ,SAAS,SAAS;AAChC,kBAAQ,IAAI,OAAO,kBAAkB,GAAG,KAAK,OAAO;AACpD,iBAAO,QAAQ,MAAM,QAAQ,SAAS,IAAI;AAAA,QAC5C;AAAA,MACF,CAAC;AAED,aAAO,eAAe,OAAO,yBAAyB;AAAA,QACpD,OAAO;AAAA;AAAA,QAEP,cAAc;AAAA,MAChB,CAAC;AAAA,IACH;AAAA,EACF;AACF;","names":[]}
@@ -1,4 +1,4 @@
1
- import { D as DefaultBodyType, c as RequestHandlerOptions, a as ResponseResolver } from './HttpResponse-vn-Pb4Bi.mjs';
1
+ import { D as DefaultBodyType, c as RequestHandlerOptions, a as ResponseResolver } from './HttpResponse-BLGmJolh.mjs';
2
2
  import { HttpHandler, HttpRequestResolverExtras } from './handlers/HttpHandler.mjs';
3
3
  import { PathParams, Path } from './utils/matching/matchRequestUrl.mjs';
4
4
  import './utils/internal/isIterable.mjs';
@@ -1,4 +1,4 @@
1
- import { D as DefaultBodyType, c as RequestHandlerOptions, a as ResponseResolver } from './HttpResponse-DaYkf3ml.js';
1
+ import { D as DefaultBodyType, c as RequestHandlerOptions, a as ResponseResolver } from './HttpResponse-Cgbkdkje.js';
2
2
  import { HttpHandler, HttpRequestResolverExtras } from './handlers/HttpHandler.js';
3
3
  import { PathParams, Path } from './utils/matching/matchRequestUrl.js';
4
4
  import './utils/internal/isIterable.js';
@@ -1,9 +1,11 @@
1
1
  export { SetupApi } from './SetupApi.mjs';
2
- export { A as AsyncResponseResolverReturnType, D as DefaultBodyType, d as DefaultRequestMultipartBody, f as HttpResponse, H as HttpResponseInit, J as JsonBodyType, R as RequestHandler, c as RequestHandlerOptions, a as ResponseResolver, b as ResponseResolverReturnType, S as StrictRequest, e as StrictResponse } from './HttpResponse-vn-Pb4Bi.mjs';
2
+ export { A as AsyncResponseResolverReturnType, D as DefaultBodyType, d as DefaultRequestMultipartBody, f as HttpResponse, H as HttpResponseInit, J as JsonBodyType, R as RequestHandler, c as RequestHandlerOptions, a as ResponseResolver, b as ResponseResolverReturnType, S as StrictRequest, e as StrictResponse } from './HttpResponse-BLGmJolh.mjs';
3
3
  export { HttpRequestHandler, HttpResponseResolver, http } from './http.mjs';
4
4
  export { HttpHandler, HttpMethods, HttpRequestParsedResult, RequestQuery } from './handlers/HttpHandler.mjs';
5
5
  export { GraphQLRequestHandler, GraphQLResponseResolver, graphql } from './graphql.mjs';
6
- export { G as GraphQLHandler, d as GraphQLJsonRequestBody, a as GraphQLQuery, c as GraphQLRequestBody, b as GraphQLVariables, P as ParsedGraphQLRequest } from './GraphQLHandler-ClMB0BOy.mjs';
6
+ export { G as GraphQLHandler, d as GraphQLJsonRequestBody, a as GraphQLQuery, c as GraphQLRequestBody, b as GraphQLVariables, P as ParsedGraphQLRequest } from './GraphQLHandler-Doool6Q_.mjs';
7
+ export { WebSocketEventListener, WebSocketLink, ws } from './ws.mjs';
8
+ export { WebSocketHandler, WebSocketHandlerConnection, WebSocketHandlerEventMap } from './handlers/WebSocketHandler.mjs';
7
9
  export { Match, Path, PathParams, matchRequestUrl } from './utils/matching/matchRequestUrl.mjs';
8
10
  export { HandleRequestOptions, handleRequest } from './utils/handleRequest.mjs';
9
11
  export { getResponse } from './getResponse.mjs';
@@ -12,6 +14,7 @@ export { LifeCycleEventsMap, SharedOptions } from './sharedOptions.mjs';
12
14
  export { DelayMode, MAX_SERVER_RESPONSE_TIME, MIN_SERVER_RESPONSE_TIME, NODE_SERVER_RESPONSE_TIME, SET_TIMEOUT_MAX_ALLOWED_INT, delay } from './delay.mjs';
13
15
  export { bypass } from './bypass.mjs';
14
16
  export { passthrough } from './passthrough.mjs';
17
+ export { WebSocketData } from '@mswjs/interceptors/WebSocket';
15
18
  import 'strict-event-emitter';
16
19
  import './utils/internal/Disposable.mjs';
17
20
  import './utils/internal/isIterable.mjs';
@@ -1,9 +1,11 @@
1
1
  export { SetupApi } from './SetupApi.js';
2
- export { A as AsyncResponseResolverReturnType, D as DefaultBodyType, d as DefaultRequestMultipartBody, f as HttpResponse, H as HttpResponseInit, J as JsonBodyType, R as RequestHandler, c as RequestHandlerOptions, a as ResponseResolver, b as ResponseResolverReturnType, S as StrictRequest, e as StrictResponse } from './HttpResponse-DaYkf3ml.js';
2
+ export { A as AsyncResponseResolverReturnType, D as DefaultBodyType, d as DefaultRequestMultipartBody, f as HttpResponse, H as HttpResponseInit, J as JsonBodyType, R as RequestHandler, c as RequestHandlerOptions, a as ResponseResolver, b as ResponseResolverReturnType, S as StrictRequest, e as StrictResponse } from './HttpResponse-Cgbkdkje.js';
3
3
  export { HttpRequestHandler, HttpResponseResolver, http } from './http.js';
4
4
  export { HttpHandler, HttpMethods, HttpRequestParsedResult, RequestQuery } from './handlers/HttpHandler.js';
5
5
  export { GraphQLRequestHandler, GraphQLResponseResolver, graphql } from './graphql.js';
6
- export { G as GraphQLHandler, d as GraphQLJsonRequestBody, a as GraphQLQuery, c as GraphQLRequestBody, b as GraphQLVariables, P as ParsedGraphQLRequest } from './GraphQLHandler-D6mLMXGZ.js';
6
+ export { G as GraphQLHandler, d as GraphQLJsonRequestBody, a as GraphQLQuery, c as GraphQLRequestBody, b as GraphQLVariables, P as ParsedGraphQLRequest } from './GraphQLHandler-udzgBRPf.js';
7
+ export { WebSocketEventListener, WebSocketLink, ws } from './ws.js';
8
+ export { WebSocketHandler, WebSocketHandlerConnection, WebSocketHandlerEventMap } from './handlers/WebSocketHandler.js';
7
9
  export { Match, Path, PathParams, matchRequestUrl } from './utils/matching/matchRequestUrl.js';
8
10
  export { HandleRequestOptions, handleRequest } from './utils/handleRequest.js';
9
11
  export { getResponse } from './getResponse.js';
@@ -12,6 +14,7 @@ export { LifeCycleEventsMap, SharedOptions } from './sharedOptions.js';
12
14
  export { DelayMode, MAX_SERVER_RESPONSE_TIME, MIN_SERVER_RESPONSE_TIME, NODE_SERVER_RESPONSE_TIME, SET_TIMEOUT_MAX_ALLOWED_INT, delay } from './delay.js';
13
15
  export { bypass } from './bypass.js';
14
16
  export { passthrough } from './passthrough.js';
17
+ export { WebSocketData } from '@mswjs/interceptors/WebSocket';
15
18
  import 'strict-event-emitter';
16
19
  import './utils/internal/Disposable.js';
17
20
  import './utils/internal/isIterable.js';
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.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");
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/core/index.ts"],"sourcesContent":["import { checkGlobals } from './utils/internal/checkGlobals'\n\nexport { SetupApi } from './SetupApi'\n\n/* Request 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/* 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,0BAA6B;AAE7B,sBAAyB;AAGzB,4BAA+B;AAC/B,kBAAqB;AACrB,yBAAyC;AACzC,qBAAwB;AACxB,4BAA+B;AAG/B,6BAAgC;AAChC,yBAAc,kCAbd;AAcA,yBAA4B;AAC5B,sBAAyB;AAmCzB,yBAAc,2BAlDd;AAmDA,yBAAc,oBAnDd;AAoDA,oBAAuB;AACvB,yBAA4B;AAAA,IAM5B,kCAAa;","names":[]}
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, type WebSocketLink } from './ws'\nexport {\n WebSocketHandler,\n type WebSocketHandlerEventMap,\n type WebSocketHandlerConnection,\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 { WebSocketData, WebSocketEventListener } from './ws'\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,gBAAuC;AACvC,8BAIO;AAGP,6BAAgC;AAChC,yBAAc,kCArBd;AAsBA,yBAA4B;AAC5B,sBAAyB;AAqCzB,yBAAc,2BA5Dd;AA6DA,yBAAc,oBA7Dd;AA8DA,oBAAuB;AACvB,yBAA4B;AAAA,IAM5B,kCAAa;","names":[]}
@@ -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.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
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/core/index.ts"],"sourcesContent":["import { checkGlobals } from './utils/internal/checkGlobals'\n\nexport { SetupApi } from './SetupApi'\n\n/* Request 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/* 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,uBAAuB;AAChC,cAAc;AACd,SAAS,mBAAmB;AAC5B,SAAS,gBAAgB;AAmCzB,cAAc;AACd,cAAc;AACd,SAAS,cAAc;AACvB,SAAS,mBAAmB;AAM5B,aAAa;","names":[]}
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, type WebSocketLink } from './ws'\nexport {\n WebSocketHandler,\n type WebSocketHandlerEventMap,\n type WebSocketHandlerConnection,\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 { WebSocketData, WebSocketEventListener } from './ws'\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,UAA8B;AACvC;AAAA,EACE;AAAA,OAGK;AAGP,SAAS,uBAAuB;AAChC,cAAc;AACd,SAAS,mBAAmB;AAC5B,SAAS,gBAAgB;AAqCzB,cAAc;AACd,cAAc;AACd,SAAS,cAAc;AACvB,SAAS,mBAAmB;AAM5B,aAAa;","names":[]}
@@ -1,4 +1,4 @@
1
- import { e as StrictResponse } from './HttpResponse-vn-Pb4Bi.mjs';
1
+ import { e as StrictResponse } from './HttpResponse-BLGmJolh.mjs';
2
2
  import './utils/internal/isIterable.mjs';
3
3
  import './typeUtils.mjs';
4
4
 
@@ -1,4 +1,4 @@
1
- import { e as StrictResponse } from './HttpResponse-DaYkf3ml.js';
1
+ import { e as StrictResponse } from './HttpResponse-Cgbkdkje.js';
2
2
  import './utils/internal/isIterable.js';
3
3
  import './typeUtils.js';
4
4
 
@@ -1,4 +1,4 @@
1
- import { H as HttpResponseInit } from '../../HttpResponse-vn-Pb4Bi.mjs';
1
+ import { H as HttpResponseInit } from '../../HttpResponse-BLGmJolh.mjs';
2
2
  import '../internal/isIterable.mjs';
3
3
  import '../../typeUtils.mjs';
4
4
 
@@ -1,4 +1,4 @@
1
- import { H as HttpResponseInit } from '../../HttpResponse-DaYkf3ml.js';
1
+ import { H as HttpResponseInit } from '../../HttpResponse-Cgbkdkje.js';
2
2
  import '../internal/isIterable.js';
3
3
  import '../../typeUtils.js';
4
4
 
@@ -1,3 +1,3 @@
1
- export { i as HandlersExecutionResult, h as ResponseResolutionContext, j as executeHandlers } from '../HttpResponse-vn-Pb4Bi.mjs';
1
+ export { i as HandlersExecutionResult, h as ResponseResolutionContext, j as executeHandlers } from '../HttpResponse-BLGmJolh.mjs';
2
2
  import './internal/isIterable.mjs';
3
3
  import '../typeUtils.mjs';
@@ -1,3 +1,3 @@
1
- export { i as HandlersExecutionResult, h as ResponseResolutionContext, j as executeHandlers } from '../HttpResponse-DaYkf3ml.js';
1
+ export { i as HandlersExecutionResult, h as ResponseResolutionContext, j as executeHandlers } from '../HttpResponse-Cgbkdkje.js';
2
2
  import './internal/isIterable.js';
3
3
  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<RequestHandler>>({\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 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;AAoBO,MAAM,kBAAkB,OAA+C;AAAA,EAC5E;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAK+C;AAC7C,MAAI,kBAAyC;AAC7C,MAAI,SAAoD;AAExD,aAAW,WAAW,UAAU;AAC9B,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
+ {"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<RequestHandler>>({\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 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":"AAoBO,MAAM,kBAAkB,OAA+C;AAAA,EAC5E;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAK+C;AAC7C,MAAI,kBAAyC;AAC7C,MAAI,SAAoD;AAExD,aAAW,WAAW,UAAU;AAC9B,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
+ {"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,9 +1,9 @@
1
1
  import { Emitter } from 'strict-event-emitter';
2
- import { i as HandlersExecutionResult, R as RequestHandler } from '../HttpResponse-vn-Pb4Bi.mjs';
3
2
  import { SharedOptions, LifeCycleEventsMap } from '../sharedOptions.mjs';
4
3
  import { RequiredDeep } from '../typeUtils.mjs';
5
- import './internal/isIterable.mjs';
4
+ import { i as HandlersExecutionResult, R as RequestHandler } from '../HttpResponse-BLGmJolh.mjs';
6
5
  import './request/onUnhandledRequest.mjs';
6
+ import './internal/isIterable.mjs';
7
7
 
8
8
  interface HandleRequestOptions {
9
9
  /**
@@ -1,9 +1,9 @@
1
1
  import { Emitter } from 'strict-event-emitter';
2
- import { i as HandlersExecutionResult, R as RequestHandler } from '../HttpResponse-DaYkf3ml.js';
3
2
  import { SharedOptions, LifeCycleEventsMap } from '../sharedOptions.js';
4
3
  import { RequiredDeep } from '../typeUtils.js';
5
- import './internal/isIterable.js';
4
+ import { i as HandlersExecutionResult, R as RequestHandler } from '../HttpResponse-Cgbkdkje.js';
6
5
  import './request/onUnhandledRequest.js';
6
+ import './internal/isIterable.js';
7
7
 
8
8
  interface HandleRequestOptions {
9
9
  /**
@@ -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 { RequestHandler } from '../handlers/RequestHandler'\nimport { LifeCycleEventsMap, SharedOptions } from '../sharedOptions'\nimport { RequiredDeep } from '../typeUtils'\nimport { HandlersExecutionResult, executeHandlers } from './executeHandlers'\nimport { onUnhandledRequest } from './request/onUnhandledRequest'\nimport { storeResponseCookies } from './request/storeResponseCookies'\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<RequestHandler>,\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 cookie jar.\n storeResponseCookies(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;AAKtB,6BAAyD;AACzD,gCAAmC;AACnC,kCAAqC;AAqCrC,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,wDAAqB,SAAS,QAAQ;AAEtC,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
+ {"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 type { RequestHandler } from '../handlers/RequestHandler'\nimport { HandlersExecutionResult, executeHandlers } from './executeHandlers'\nimport { onUnhandledRequest } from './request/onUnhandledRequest'\nimport { storeResponseCookies } from './request/storeResponseCookies'\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<RequestHandler>,\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 cookie jar.\n storeResponseCookies(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;AAKtB,6BAAyD;AACzD,gCAAmC;AACnC,kCAAqC;AAqCrC,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,wDAAqB,SAAS,QAAQ;AAEtC,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 { RequestHandler } from '../handlers/RequestHandler'\nimport { LifeCycleEventsMap, SharedOptions } from '../sharedOptions'\nimport { RequiredDeep } from '../typeUtils'\nimport { HandlersExecutionResult, executeHandlers } from './executeHandlers'\nimport { onUnhandledRequest } from './request/onUnhandledRequest'\nimport { storeResponseCookies } from './request/storeResponseCookies'\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<RequestHandler>,\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 cookie jar.\n storeResponseCookies(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;AAKtB,SAAkC,uBAAuB;AACzD,SAAS,0BAA0B;AACnC,SAAS,4BAA4B;AAqCrC,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,uBAAqB,SAAS,QAAQ;AAEtC,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
+ {"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 type { RequestHandler } from '../handlers/RequestHandler'\nimport { HandlersExecutionResult, executeHandlers } from './executeHandlers'\nimport { onUnhandledRequest } from './request/onUnhandledRequest'\nimport { storeResponseCookies } from './request/storeResponseCookies'\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<RequestHandler>,\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 cookie jar.\n storeResponseCookies(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;AAKtB,SAAkC,uBAAuB;AACzD,SAAS,0BAA0B;AACnC,SAAS,4BAA4B;AAqCrC,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,uBAAqB,SAAS,QAAQ;AAEtC,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,6 +1,6 @@
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-ClMB0BOy.mjs';
3
- import '../../HttpResponse-vn-Pb4Bi.mjs';
2
+ export { j as GraphQLMultipartRequestBody, i as GraphQLParsedOperationsMap, h as ParsedGraphQLQuery, P as ParsedGraphQLRequest, p as parseDocumentNode, k as parseGraphQLRequest } from '../../GraphQLHandler-Doool6Q_.mjs';
3
+ import '../../HttpResponse-BLGmJolh.mjs';
4
4
  import './isIterable.mjs';
5
5
  import '../../typeUtils.mjs';
6
6
  import '../matching/matchRequestUrl.mjs';
@@ -1,6 +1,6 @@
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-D6mLMXGZ.js';
3
- import '../../HttpResponse-DaYkf3ml.js';
2
+ export { j as GraphQLMultipartRequestBody, i as GraphQLParsedOperationsMap, h as ParsedGraphQLQuery, P as ParsedGraphQLRequest, p as parseDocumentNode, k as parseGraphQLRequest } from '../../GraphQLHandler-udzgBRPf.js';
3
+ import '../../HttpResponse-Cgbkdkje.js';
4
4
  import './isIterable.js';
5
5
  import '../../typeUtils.js';
6
6
  import '../matching/matchRequestUrl.js';
@@ -1,4 +1,4 @@
1
- import { d as DefaultRequestMultipartBody } from '../../HttpResponse-vn-Pb4Bi.mjs';
1
+ import { d as DefaultRequestMultipartBody } from '../../HttpResponse-BLGmJolh.mjs';
2
2
  import './isIterable.mjs';
3
3
  import '../../typeUtils.mjs';
4
4
 
@@ -1,4 +1,4 @@
1
- import { d as DefaultRequestMultipartBody } from '../../HttpResponse-DaYkf3ml.js';
1
+ import { d as DefaultRequestMultipartBody } from '../../HttpResponse-Cgbkdkje.js';
2
2
  import './isIterable.js';
3
3
  import '../../typeUtils.js';
4
4
 
@@ -1,4 +1,4 @@
1
- import { R as RequestHandler, g as RequestHandlerDefaultInfo, c as RequestHandlerOptions } from '../../HttpResponse-vn-Pb4Bi.mjs';
1
+ import { R as RequestHandler, g as RequestHandlerDefaultInfo, c as RequestHandlerOptions } from '../../HttpResponse-BLGmJolh.mjs';
2
2
  import './isIterable.mjs';
3
3
  import '../../typeUtils.mjs';
4
4
 
@@ -1,4 +1,4 @@
1
- import { R as RequestHandler, g as RequestHandlerDefaultInfo, c as RequestHandlerOptions } from '../../HttpResponse-DaYkf3ml.js';
1
+ import { R as RequestHandler, g as RequestHandlerDefaultInfo, c as RequestHandlerOptions } from '../../HttpResponse-Cgbkdkje.js';
2
2
  import './isIterable.js';
3
3
  import '../../typeUtils.js';
4
4
 
@@ -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
- return [now.getHours(), now.getMinutes(), now.getSeconds()].map(String).map((chunk) => chunk.slice(0, 2)).map((chunk) => chunk.padStart(2, "0")).join(":");
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\n return [now.getHours(), now.getMinutes(), now.getSeconds()]\n .map(String)\n .map((chunk) => chunk.slice(0, 2))\n .map((chunk) => chunk.padStart(2, '0'))\n .join(':')\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGO,SAAS,eAAuB;AACrC,QAAM,MAAM,oBAAI,KAAK;AAErB,SAAO,CAAC,IAAI,SAAS,GAAG,IAAI,WAAW,GAAG,IAAI,WAAW,CAAC,EACvD,IAAI,MAAM,EACV,IAAI,CAAC,UAAU,MAAM,MAAM,GAAG,CAAC,CAAC,EAChC,IAAI,CAAC,UAAU,MAAM,SAAS,GAAG,GAAG,CAAC,EACrC,KAAK,GAAG;AACb;","names":[]}
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
- return [now.getHours(), now.getMinutes(), now.getSeconds()].map(String).map((chunk) => chunk.slice(0, 2)).map((chunk) => chunk.padStart(2, "0")).join(":");
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\n return [now.getHours(), now.getMinutes(), now.getSeconds()]\n .map(String)\n .map((chunk) => chunk.slice(0, 2))\n .map((chunk) => chunk.padStart(2, '0'))\n .join(':')\n}\n"],"mappings":"AAGO,SAAS,eAAuB;AACrC,QAAM,MAAM,oBAAI,KAAK;AAErB,SAAO,CAAC,IAAI,SAAS,GAAG,IAAI,WAAW,GAAG,IAAI,WAAW,CAAC,EACvD,IAAI,MAAM,EACV,IAAI,CAAC,UAAU,MAAM,MAAM,GAAG,CAAC,CAAC,EAChC,IAAI,CAAC,UAAU,MAAM,SAAS,GAAG,GAAG,CAAC,EACrC,KAAK,GAAG;AACb;","names":[]}
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 };