@n1k1t/mock-server 0.1.2 → 0.1.4

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 (282) hide show
  1. package/bin/index.ts +2 -0
  2. package/lib/bin/index.d.ts +1 -0
  3. package/lib/bin/index.js +1 -0
  4. package/lib/bin/index.js.map +1 -1
  5. package/lib/package.json +6 -4
  6. package/lib/src/client/helpers/expectations.d.ts +2 -3
  7. package/lib/src/client/helpers/expectations.d.ts.map +1 -1
  8. package/lib/src/client/helpers/expectations.js.map +1 -1
  9. package/lib/src/client/methods/expectations.create.method.js +1 -1
  10. package/lib/src/client/methods/expectations.create.method.js.map +1 -1
  11. package/lib/src/client/methods/expectations.update.method.js +1 -1
  12. package/lib/src/client/methods/expectations.update.method.js.map +1 -1
  13. package/lib/src/client/models/client.d.ts +1 -0
  14. package/lib/src/client/models/client.d.ts.map +1 -1
  15. package/lib/src/client/models/client.js.map +1 -1
  16. package/lib/src/client/models/client.spec.js +6 -1
  17. package/lib/src/client/models/client.spec.js.map +1 -1
  18. package/lib/src/client/types.d.ts +1 -0
  19. package/lib/src/client/types.d.ts.map +1 -1
  20. package/lib/src/config/index.d.ts +2 -9
  21. package/lib/src/config/index.d.ts.map +1 -1
  22. package/lib/src/config/index.js +2 -15
  23. package/lib/src/config/index.js.map +1 -1
  24. package/lib/src/config/model.d.ts +23 -0
  25. package/lib/src/config/model.d.ts.map +1 -0
  26. package/lib/src/config/model.js +39 -0
  27. package/lib/src/config/model.js.map +1 -0
  28. package/lib/src/expectations/__utils__/index.d.ts +1 -0
  29. package/lib/src/expectations/__utils__/index.d.ts.map +1 -1
  30. package/lib/src/expectations/__utils__/index.js.map +1 -1
  31. package/lib/src/expectations/models/expectation.d.ts +3 -5
  32. package/lib/src/expectations/models/expectation.d.ts.map +1 -1
  33. package/lib/src/expectations/models/expectation.js +0 -32
  34. package/lib/src/expectations/models/expectation.js.map +1 -1
  35. package/lib/src/expectations/models/operator.d.ts +3 -2
  36. package/lib/src/expectations/models/operator.d.ts.map +1 -1
  37. package/lib/src/expectations/models/operator.js +19 -5
  38. package/lib/src/expectations/models/operator.js.map +1 -1
  39. package/lib/src/expectations/models/storage.d.ts +1 -0
  40. package/lib/src/expectations/models/storage.d.ts.map +1 -1
  41. package/lib/src/expectations/models/storage.js.map +1 -1
  42. package/lib/src/expectations/operators/and.operator.d.ts +1 -0
  43. package/lib/src/expectations/operators/and.operator.d.ts.map +1 -1
  44. package/lib/src/expectations/operators/and.operator.js.map +1 -1
  45. package/lib/src/expectations/operators/exec.operator.d.ts +2 -1
  46. package/lib/src/expectations/operators/exec.operator.d.ts.map +1 -1
  47. package/lib/src/expectations/operators/exec.operator.js +3 -2
  48. package/lib/src/expectations/operators/exec.operator.js.map +1 -1
  49. package/lib/src/expectations/operators/has.operator.d.ts +2 -1
  50. package/lib/src/expectations/operators/has.operator.d.ts.map +1 -1
  51. package/lib/src/expectations/operators/has.operator.js +11 -8
  52. package/lib/src/expectations/operators/has.operator.js.map +1 -1
  53. package/lib/src/expectations/operators/if.operator.d.ts +1 -0
  54. package/lib/src/expectations/operators/if.operator.d.ts.map +1 -1
  55. package/lib/src/expectations/operators/if.operator.js.map +1 -1
  56. package/lib/src/expectations/operators/merge.operator.d.ts +1 -0
  57. package/lib/src/expectations/operators/merge.operator.d.ts.map +1 -1
  58. package/lib/src/expectations/operators/merge.operator.js +2 -2
  59. package/lib/src/expectations/operators/merge.operator.js.map +1 -1
  60. package/lib/src/expectations/operators/not.operator.d.ts +1 -0
  61. package/lib/src/expectations/operators/not.operator.d.ts.map +1 -1
  62. package/lib/src/expectations/operators/not.operator.js.map +1 -1
  63. package/lib/src/expectations/operators/or.operator.d.ts +1 -0
  64. package/lib/src/expectations/operators/or.operator.d.ts.map +1 -1
  65. package/lib/src/expectations/operators/or.operator.js.map +1 -1
  66. package/lib/src/expectations/operators/remove.operator.d.ts +1 -0
  67. package/lib/src/expectations/operators/remove.operator.d.ts.map +1 -1
  68. package/lib/src/expectations/operators/remove.operator.js +1 -1
  69. package/lib/src/expectations/operators/remove.operator.js.map +1 -1
  70. package/lib/src/expectations/operators/root.operator.d.ts +1 -0
  71. package/lib/src/expectations/operators/root.operator.d.ts.map +1 -1
  72. package/lib/src/expectations/operators/root.operator.js +4 -2
  73. package/lib/src/expectations/operators/root.operator.js.map +1 -1
  74. package/lib/src/expectations/operators/set.operator.d.ts +2 -1
  75. package/lib/src/expectations/operators/set.operator.d.ts.map +1 -1
  76. package/lib/src/expectations/operators/set.operator.js +7 -9
  77. package/lib/src/expectations/operators/set.operator.js.map +1 -1
  78. package/lib/src/expectations/operators/switch.operator.d.ts +2 -1
  79. package/lib/src/expectations/operators/switch.operator.d.ts.map +1 -1
  80. package/lib/src/expectations/operators/switch.operator.js +1 -1
  81. package/lib/src/expectations/operators/switch.operator.js.map +1 -1
  82. package/lib/src/expectations/types.d.ts +24 -14
  83. package/lib/src/expectations/types.d.ts.map +1 -1
  84. package/lib/src/expectations/types.js +4 -1
  85. package/lib/src/expectations/types.js.map +1 -1
  86. package/lib/src/expectations/utils.d.ts +8 -6
  87. package/lib/src/expectations/utils.d.ts.map +1 -1
  88. package/lib/src/expectations/utils.js +68 -37
  89. package/lib/src/expectations/utils.js.map +1 -1
  90. package/lib/src/index.d.ts +4 -1
  91. package/lib/src/index.d.ts.map +1 -1
  92. package/lib/src/index.js +9 -1
  93. package/lib/src/index.js.map +1 -1
  94. package/lib/src/logger/index.d.ts +23 -0
  95. package/lib/src/logger/index.d.ts.map +1 -0
  96. package/lib/src/logger/index.js +81 -0
  97. package/lib/src/logger/index.js.map +1 -0
  98. package/lib/src/logger/types.d.ts +4 -0
  99. package/lib/src/logger/types.d.ts.map +1 -0
  100. package/lib/src/{types.js.map → logger/types.js.map} +1 -1
  101. package/lib/src/logger/utils.d.ts +6 -0
  102. package/lib/src/logger/utils.d.ts.map +1 -0
  103. package/lib/src/logger/utils.js +24 -0
  104. package/lib/src/logger/utils.js.map +1 -0
  105. package/lib/src/meta/index.d.ts +5 -0
  106. package/lib/src/meta/index.d.ts.map +1 -0
  107. package/lib/src/meta/index.js +22 -0
  108. package/lib/src/meta/index.js.map +1 -0
  109. package/lib/src/meta/model.d.ts +13 -0
  110. package/lib/src/meta/model.d.ts.map +1 -0
  111. package/lib/src/meta/model.js +28 -0
  112. package/lib/src/meta/model.js.map +1 -0
  113. package/lib/src/meta/storage.d.ts +9 -0
  114. package/lib/src/meta/storage.d.ts.map +1 -0
  115. package/lib/src/meta/storage.js +21 -0
  116. package/lib/src/meta/storage.js.map +1 -0
  117. package/lib/src/process.js +3 -3
  118. package/lib/src/process.js.map +1 -1
  119. package/lib/src/server/endpoints/config.get.endpoint.d.ts +48 -6
  120. package/lib/src/server/endpoints/config.get.endpoint.d.ts.map +1 -1
  121. package/lib/src/server/endpoints/config.get.endpoint.js +5 -1
  122. package/lib/src/server/endpoints/config.get.endpoint.js.map +1 -1
  123. package/lib/src/server/endpoints/expectations.create.endpoint.d.ts +1 -1
  124. package/lib/src/server/endpoints/expectations.delete.endpoint.d.ts +1 -1
  125. package/lib/src/server/endpoints/expectations.get-list.endpoint.d.ts +1 -1
  126. package/lib/src/server/endpoints/expectations.update.endpoint.d.ts +1 -1
  127. package/lib/src/server/endpoints/history.get-list.endpoint.d.ts +4 -4
  128. package/lib/src/server/endpoints/ping.endpoint.d.ts +1 -1
  129. package/lib/src/server/history/storage.d.ts.map +1 -1
  130. package/lib/src/server/history/storage.js +2 -2
  131. package/lib/src/server/history/storage.js.map +1 -1
  132. package/lib/src/server/index.d.ts +0 -1
  133. package/lib/src/server/index.d.ts.map +1 -1
  134. package/lib/src/server/index.js +37 -14
  135. package/lib/src/server/index.js.map +1 -1
  136. package/lib/src/server/middlewares/delay.middleware.d.ts +26 -0
  137. package/lib/src/server/middlewares/delay.middleware.d.ts.map +1 -0
  138. package/lib/src/server/middlewares/delay.middleware.js +13 -0
  139. package/lib/src/server/middlewares/delay.middleware.js.map +1 -0
  140. package/lib/src/server/middlewares/destroy.midleware.d.ts +26 -0
  141. package/lib/src/server/middlewares/destroy.midleware.d.ts.map +1 -0
  142. package/lib/src/server/middlewares/destroy.midleware.js +17 -0
  143. package/lib/src/server/middlewares/destroy.midleware.js.map +1 -0
  144. package/lib/src/server/middlewares/forward.middleware.d.ts +26 -0
  145. package/lib/src/server/middlewares/forward.middleware.d.ts.map +1 -0
  146. package/lib/src/server/middlewares/{handle-expectation-forward.middleware.js → forward.middleware.js} +15 -14
  147. package/lib/src/server/middlewares/forward.middleware.js.map +1 -0
  148. package/lib/src/server/middlewares/{add-history.middleware.d.ts → history.middleware.d.ts} +15 -7
  149. package/lib/src/server/middlewares/history.middleware.d.ts.map +1 -0
  150. package/lib/src/server/middlewares/{add-history.middleware.js → history.middleware.js} +4 -4
  151. package/lib/src/server/middlewares/history.middleware.js.map +1 -0
  152. package/lib/src/server/middlewares/index.d.ts +7 -6
  153. package/lib/src/server/middlewares/index.d.ts.map +1 -1
  154. package/lib/src/server/middlewares/index.js +15 -13
  155. package/lib/src/server/middlewares/index.js.map +1 -1
  156. package/lib/src/server/middlewares/{resolve-public.middleware.d.ts → internal.middleware.d.ts} +15 -7
  157. package/lib/src/server/middlewares/internal.middleware.d.ts.map +1 -0
  158. package/lib/src/server/middlewares/{internal-route.middleware.js → internal.middleware.js} +7 -4
  159. package/lib/src/server/middlewares/internal.middleware.js.map +1 -0
  160. package/lib/src/server/middlewares/{handle-expectation-delay.middleware.d.ts → manipulate-expectation.middleware.d.ts} +15 -7
  161. package/lib/src/server/middlewares/manipulate-expectation.middleware.d.ts.map +1 -0
  162. package/lib/src/server/middlewares/manipulate-expectation.middleware.js +13 -0
  163. package/lib/src/server/middlewares/manipulate-expectation.middleware.js.map +1 -0
  164. package/lib/src/server/middlewares/match-expectation.middleware.d.ts +14 -6
  165. package/lib/src/server/middlewares/match-expectation.middleware.d.ts.map +1 -1
  166. package/lib/src/server/middlewares/match-expectation.middleware.js +7 -6
  167. package/lib/src/server/middlewares/match-expectation.middleware.js.map +1 -1
  168. package/lib/src/server/middlewares/{internal-route.middleware.d.ts → public.middleware.d.ts} +15 -7
  169. package/lib/src/server/middlewares/public.middleware.d.ts.map +1 -0
  170. package/lib/src/server/middlewares/public.middleware.js +38 -0
  171. package/lib/src/server/middlewares/public.middleware.js.map +1 -0
  172. package/lib/src/server/middlewares/reply.middleware.d.ts +17 -9
  173. package/lib/src/server/middlewares/reply.middleware.d.ts.map +1 -1
  174. package/lib/src/server/middlewares/reply.middleware.js +9 -10
  175. package/lib/src/server/middlewares/reply.middleware.js.map +1 -1
  176. package/lib/src/server/models/endpoint.d.ts +2 -1
  177. package/lib/src/server/models/endpoint.d.ts.map +1 -1
  178. package/lib/src/server/models/endpoint.js.map +1 -1
  179. package/lib/src/server/models/index.d.ts +2 -1
  180. package/lib/src/server/models/index.d.ts.map +1 -1
  181. package/lib/src/server/models/index.js +2 -1
  182. package/lib/src/server/models/index.js.map +1 -1
  183. package/lib/src/server/models/middleware.d.ts +14 -5
  184. package/lib/src/server/models/middleware.d.ts.map +1 -1
  185. package/lib/src/server/models/middleware.js +5 -11
  186. package/lib/src/server/models/middleware.js.map +1 -1
  187. package/lib/src/server/models/plugins.d.ts +29 -0
  188. package/lib/src/server/models/plugins.d.ts.map +1 -0
  189. package/lib/src/server/models/plugins.js +32 -0
  190. package/lib/src/server/models/plugins.js.map +1 -0
  191. package/lib/src/server/models/{reply-service → reply}/index.d.ts +3 -3
  192. package/lib/src/server/models/reply/index.d.ts.map +1 -0
  193. package/lib/src/server/models/{reply-service → reply}/index.js +4 -4
  194. package/lib/src/server/models/reply/index.js.map +1 -0
  195. package/lib/src/server/models/reply/types.d.ts.map +1 -0
  196. package/lib/src/server/models/reply/types.js.map +1 -0
  197. package/lib/src/server/models/request-context/http.d.ts +28 -12
  198. package/lib/src/server/models/request-context/http.d.ts.map +1 -1
  199. package/lib/src/server/models/request-context/http.js +47 -20
  200. package/lib/src/server/models/request-context/http.js.map +1 -1
  201. package/lib/src/server/models/request-context/model.d.ts +7 -2
  202. package/lib/src/server/models/request-context/model.d.ts.map +1 -1
  203. package/lib/src/server/models/request-context/model.js +5 -0
  204. package/lib/src/server/models/request-context/model.js.map +1 -1
  205. package/lib/src/server/models/request-context/types.d.ts +2 -0
  206. package/lib/src/server/models/request-context/types.d.ts.map +1 -1
  207. package/lib/src/server/models/request-context/utils.d.ts +4 -1
  208. package/lib/src/server/models/request-context/utils.d.ts.map +1 -1
  209. package/lib/src/server/models/request-context/utils.js +2 -2
  210. package/lib/src/server/models/request-context/utils.js.map +1 -1
  211. package/lib/src/server/models/request-context/ws.d.ts +4 -3
  212. package/lib/src/server/models/request-context/ws.d.ts.map +1 -1
  213. package/lib/src/server/models/request-context/ws.js +2 -2
  214. package/lib/src/server/models/request-context/ws.js.map +1 -1
  215. package/lib/src/server/models/server-context.d.ts +2 -9
  216. package/lib/src/server/models/server-context.d.ts.map +1 -1
  217. package/lib/src/server/models/server-context.js +2 -5
  218. package/lib/src/server/models/server-context.js.map +1 -1
  219. package/lib/src/server/router.d.ts +1 -0
  220. package/lib/src/server/router.d.ts.map +1 -1
  221. package/lib/src/server/router.js.map +1 -1
  222. package/lib/src/types/common.d.ts +73 -0
  223. package/lib/src/types/common.d.ts.map +1 -0
  224. package/lib/{types/common.global.js → src/types/common.js} +1 -1
  225. package/lib/src/types/common.js.map +1 -0
  226. package/lib/src/{types.d.ts → types/index.d.ts} +2 -1
  227. package/lib/src/types/index.d.ts.map +1 -0
  228. package/lib/{types/lib.js → src/types/index.js} +2 -4
  229. package/lib/src/types/index.js.map +1 -0
  230. package/lib/src/utils/common.d.ts +1 -0
  231. package/lib/src/utils/common.d.ts.map +1 -1
  232. package/lib/src/utils/common.js.map +1 -1
  233. package/lib/src/utils/validation.d.ts +1 -0
  234. package/lib/src/utils/validation.d.ts.map +1 -1
  235. package/lib/src/utils/validation.js.map +1 -1
  236. package/lib/tsconfig.tsbuildinfo +1 -1
  237. package/package.json +6 -4
  238. package/lib/src/server/middlewares/add-history.middleware.d.ts.map +0 -1
  239. package/lib/src/server/middlewares/add-history.middleware.js.map +0 -1
  240. package/lib/src/server/middlewares/destroy-request.midleware.d.ts +0 -18
  241. package/lib/src/server/middlewares/destroy-request.midleware.d.ts.map +0 -1
  242. package/lib/src/server/middlewares/destroy-request.midleware.js +0 -16
  243. package/lib/src/server/middlewares/destroy-request.midleware.js.map +0 -1
  244. package/lib/src/server/middlewares/handle-expectation-delay.middleware.d.ts.map +0 -1
  245. package/lib/src/server/middlewares/handle-expectation-delay.middleware.js +0 -17
  246. package/lib/src/server/middlewares/handle-expectation-delay.middleware.js.map +0 -1
  247. package/lib/src/server/middlewares/handle-expectation-forward.middleware.d.ts +0 -18
  248. package/lib/src/server/middlewares/handle-expectation-forward.middleware.d.ts.map +0 -1
  249. package/lib/src/server/middlewares/handle-expectation-forward.middleware.js.map +0 -1
  250. package/lib/src/server/middlewares/internal-route.middleware.d.ts.map +0 -1
  251. package/lib/src/server/middlewares/internal-route.middleware.js.map +0 -1
  252. package/lib/src/server/middlewares/resolve-public.middleware.d.ts.map +0 -1
  253. package/lib/src/server/middlewares/resolve-public.middleware.js +0 -37
  254. package/lib/src/server/middlewares/resolve-public.middleware.js.map +0 -1
  255. package/lib/src/server/models/reply-service/index.d.ts.map +0 -1
  256. package/lib/src/server/models/reply-service/index.js.map +0 -1
  257. package/lib/src/server/models/reply-service/types.d.ts.map +0 -1
  258. package/lib/src/server/models/reply-service/types.js.map +0 -1
  259. package/lib/src/server/proxy.d.ts +0 -9
  260. package/lib/src/server/proxy.d.ts.map +0 -1
  261. package/lib/src/server/proxy.js +0 -16
  262. package/lib/src/server/proxy.js.map +0 -1
  263. package/lib/src/types.d.ts.map +0 -1
  264. package/lib/task-processor.d.ts +0 -2
  265. package/lib/task-processor.d.ts.map +0 -1
  266. package/lib/task-processor.js +0 -75
  267. package/lib/task-processor.js.map +0 -1
  268. package/lib/test/index.d.ts +0 -2
  269. package/lib/test/index.d.ts.map +0 -1
  270. package/lib/test/index.js +0 -124
  271. package/lib/test/index.js.map +0 -1
  272. package/lib/types/common.global.d.ts +0 -76
  273. package/lib/types/common.global.d.ts.map +0 -1
  274. package/lib/types/common.global.js.map +0 -1
  275. package/lib/types/lib.d.ts +0 -4
  276. package/lib/types/lib.d.ts.map +0 -1
  277. package/lib/types/lib.js.map +0 -1
  278. package/types/common.global.ts +0 -131
  279. package/types/lib.ts +0 -3
  280. /package/lib/src/{server/models/reply-service → logger}/types.js +0 -0
  281. /package/lib/src/server/models/{reply-service → reply}/types.d.ts +0 -0
  282. /package/lib/src/{types.js → server/models/reply/types.js} +0 -0
@@ -8,14 +8,13 @@ const https_proxy_agent_1 = __importDefault(require("https-proxy-agent"));
8
8
  const lodash_1 = __importDefault(require("lodash"));
9
9
  const models_1 = require("../models");
10
10
  exports.default = models_1.Middleware
11
- .build(__filename, ['expectation', 'history'])
12
- .assignHandler(async (context, next) => {
11
+ .build(__filename, ['expectation', 'manipulated', 'history'])
12
+ .assignHandler(async (context, { logger }) => {
13
13
  if (!context.shared.expectation.forward) {
14
- return next();
14
+ return null;
15
15
  }
16
16
  const { url, baseUrl, timeout, proxy } = context.shared.expectation.forward;
17
- const forwarded = context.toPlain({ locations: ['incoming'], clone: true });
18
- context.shared.expectation.request?.manipulate(forwarded);
17
+ const forwarded = context.shared.manipulated;
19
18
  const incomingType = (0, models_1.extractPayloadType)(forwarded.incoming.headers);
20
19
  const body = forwarded.incoming.body === undefined ? forwarded.incoming.bodyRaw : forwarded.incoming.body;
21
20
  const bodyRaw = Buffer.from(typeof body === 'object' ? (0, models_1.serializePayload)(incomingType, body) : String(body));
@@ -31,8 +30,8 @@ exports.default = models_1.Middleware
31
30
  },
32
31
  });
33
32
  const history = context.shared.history.extendForwarded(forwarded);
34
- context.server.exchange.ws.publish('history:updated', history);
35
- const response = await (0, axios_1.default)({
33
+ context.server.exchange.ws.publish('history:updated', history.toPlain());
34
+ const configuration = await context.server.plugins.exec('forward.request', {
36
35
  timeout: timeout ?? 1000 * 30,
37
36
  method: forwarded.incoming.method,
38
37
  headers: forwarded.incoming.headers,
@@ -45,28 +44,30 @@ exports.default = models_1.Middleware
45
44
  proxy,
46
45
  httpsAgent: (0, https_proxy_agent_1.default)(proxy.host)
47
46
  }),
48
- }).catch((error) => {
47
+ }, context);
48
+ const response = await axios_1.default.request(configuration).catch((error) => {
49
49
  if (!error.response) {
50
50
  history
51
51
  .assign({ error: lodash_1.default.pick(error, ['message', 'code']) })
52
52
  .changeState('finished');
53
- context.server.exchange.ws.publish('history:updated', history);
53
+ context.server.exchange.ws.publish('history:updated', history.toPlain());
54
54
  context.reply.internalError(error.message);
55
+ logger.error('Got error while forwaring', error?.stack ?? error);
55
56
  throw error;
56
57
  }
57
58
  return error.response;
58
59
  });
60
+ const parsed = await context.server.plugins.exec('forward.response', response, context);
59
61
  const outgoingType = (0, models_1.extractPayloadType)(response.headers);
60
- const dataRaw = response.data?.toString() ?? '';
61
62
  forwarded.outgoing = {
62
63
  type: outgoingType,
63
64
  status: response.status,
64
65
  headers: response.headers,
65
- dataRaw,
66
- data: (0, models_1.parsePayload)(outgoingType, dataRaw),
66
+ dataRaw: parsed.raw,
67
+ data: 'payload' in parsed ? parsed.payload : (0, models_1.parsePayload)(outgoingType, parsed.raw),
67
68
  };
68
69
  history.extendForwarded(forwarded);
69
70
  context.server.exchange.ws.publish('history:updated', history.toPlain());
70
- return next({ forwarded });
71
+ context.share({ forwarded });
71
72
  });
72
- //# sourceMappingURL=handle-expectation-forward.middleware.js.map
73
+ //# sourceMappingURL=forward.middleware.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"forward.middleware.js","sourceRoot":"","sources":["../../../../src/server/middlewares/forward.middleware.ts"],"names":[],"mappings":";;;;;AAAA,kDAA0C;AAC1C,0EAAgD;AAChD,oDAAuB;AAEvB,sCAA2F;AAE3F,kBAAe,mBAAU;KACtB,KAAK,CAAC,UAAU,EAAE,CAAC,aAAa,EAAE,aAAa,EAAE,SAAS,CAAC,CAAC;KA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,QAAQ,CAAC,EAAE,CAAC,OAAO,CAAC,iBAAiB,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;YACzE,OAAO,CAAC,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YAE3C,MAAM,CAAC,KAAK,CAAC,2BAA2B,EAAE,KAAK,EAAE,KAAK,IAAI,KAAK,CAAC,CAAC;YACjE,MAAM,KAAK,CAAC;QACd,CAAC;QAED,OAAO,KAAK,CAAC,QAAQ,CAAC;IACxB,CAAC,CAAC,CAAC;IAEH,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,kBAAkB,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;IACxF,MAAM,YAAY,GAAG,IAAA,2BAAkB,EAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAE1D,SAAS,CAAC,QAAQ,GAAG;QACnB,IAAI,EAAE,YAAY;QAElB,MAAM,EAAE,QAAQ,CAAC,MAAM;QACvB,OAAO,EAAE,QAAQ,CAAC,OAAO;QAEzB,OAAO,EAAE,MAAM,CAAC,GAAG;QACnB,IAAI,EAAE,SAAS,IAAI,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,IAAA,qBAAY,EAAC,YAAY,EAAE,MAAM,CAAC,GAAG,CAAC;KACpF,CAAC;IAEF,OAAO,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;IAEnC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,OAAO,CAAC,iBAAiB,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;IACzE,OAAO,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC;AAC/B,CAAC,CAAC,CAAC"}
@@ -1,18 +1,26 @@
1
1
  import { Middleware } from '../models';
2
2
  declare const _default: Middleware<"expectation", import("../models").HttpRequestContext<unknown> & {
3
- shared: SetRequiredKeys<{
3
+ shared: import("../..").SetRequiredKeys<{
4
+ state: Record<string, unknown>;
5
+ seed?: number;
4
6
  expectation?: import("../../expectations").Expectation<Pick<import("../models").HttpRequestContext, "incoming" | "outgoing">>;
5
- history?: import("../history").History;
7
+ manipulated?: import("../../expectations").IExpectationOperatorContext;
6
8
  forwarded?: Pick<import("../models").HttpRequestContext, "incoming" | "outgoing">;
9
+ history?: import("../history").History;
7
10
  }, "expectation">;
8
11
  }> & {
9
- handler: TFunction<unknown, [import("../models").HttpRequestContext<unknown> & {
10
- shared: SetRequiredKeys<{
12
+ handler: import("../..").TFunction<unknown, [import("../models").HttpRequestContext<unknown> & {
13
+ shared: import("../..").SetRequiredKeys<{
14
+ state: Record<string, unknown>;
15
+ seed?: number;
11
16
  expectation?: import("../../expectations").Expectation<Pick<import("../models").HttpRequestContext, "incoming" | "outgoing">>;
12
- history?: import("../history").History;
17
+ manipulated?: import("../../expectations").IExpectationOperatorContext;
13
18
  forwarded?: Pick<import("../models").HttpRequestContext, "incoming" | "outgoing">;
19
+ history?: import("../history").History;
14
20
  }, "expectation">;
15
- }, (shared?: Partial<import("../models").HttpRequestContext["shared"]>) => unknown]>;
21
+ }, {
22
+ logger: import("../..").Logger;
23
+ }]>;
16
24
  };
17
25
  export default _default;
18
- //# sourceMappingURL=add-history.middleware.d.ts.map
26
+ //# sourceMappingURL=history.middleware.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"history.middleware.d.ts","sourceRoot":"","sources":["../../../../src/server/middlewares/history.middleware.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;;;;;;;;;;;;;;;;;;;;;;;;AAEvC,wBASK"}
@@ -3,11 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const models_1 = require("../models");
4
4
  exports.default = models_1.Middleware
5
5
  .build(__filename, ['expectation'])
6
- .assignHandler((context, next) => {
6
+ .assignHandler((context) => {
7
7
  const history = context.server.storage.history
8
8
  .register(context.toPlain({ locations: ['incoming'] }))
9
9
  .assign({ expectation: context.shared.expectation });
10
- context.server.exchange.ws.publish('history:added', history);
11
- next({ history });
10
+ context.server.exchange.ws.publish('history:added', history.toPlain());
11
+ context.share({ history });
12
12
  });
13
- //# sourceMappingURL=add-history.middleware.js.map
13
+ //# sourceMappingURL=history.middleware.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"history.middleware.js","sourceRoot":"","sources":["../../../../src/server/middlewares/history.middleware.ts"],"names":[],"mappings":";;AACA,sCAAuC;AAEvC,kBAAe,mBAAU;KACtB,KAAK,CAAC,UAAU,EAAE,CAAC,aAAa,CAAC,CAAC;KAClC,aAAa,CAAC,CAAC,OAAO,EAAE,EAAE;IACzB,MAAM,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO;SAC3C,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,SAAS,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;SACtD,MAAM,CAAC,EAAE,WAAW,EAAE,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC;IAEvD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,OAAO,CAAC,eAAe,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;IACvE,OAAO,CAAC,KAAK,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;AAC7B,CAAC,CAAC,CAAC"}
@@ -1,9 +1,10 @@
1
- export { default as handleExpectationForwardMiddleware } from './handle-expectation-forward.middleware';
2
- export { default as handleExpectationDelayMiddleware } from './handle-expectation-delay.middleware';
3
- export { default as buildDestroyRequestMiddleware } from './destroy-request.midleware';
1
+ export { default as forwardMiddleware } from './forward.middleware';
2
+ export { default as delayMiddleware } from './delay.middleware';
3
+ export { default as destroyMiddleware } from './destroy.midleware';
4
4
  export { default as matchExpectationMiddleware } from './match-expectation.middleware';
5
- export { default as handleInternalMiddleware } from './internal-route.middleware';
6
- export { default as resolvePublicMiddleware } from './resolve-public.middleware';
7
- export { default as addHistoryMiddleware } from './add-history.middleware';
5
+ export { default as manipulateExpectationMiddleware } from './manipulate-expectation.middleware';
6
+ export { default as internalMiddleware } from './internal.middleware';
7
+ export { default as publicMiddleware } from './public.middleware';
8
+ export { default as historyMiddleware } from './history.middleware';
8
9
  export { default as replyMiddleware } from './reply.middleware';
9
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/server/middlewares/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,kCAAkC,EAAE,MAAM,yCAAyC,CAAC;AACxG,OAAO,EAAE,OAAO,IAAI,gCAAgC,EAAE,MAAM,uCAAuC,CAAC;AACpG,OAAO,EAAE,OAAO,IAAI,6BAA6B,EAAE,MAAM,6BAA6B,CAAC;AACvF,OAAO,EAAE,OAAO,IAAI,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AACvF,OAAO,EAAE,OAAO,IAAI,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AAClF,OAAO,EAAE,OAAO,IAAI,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AACjF,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAC3E,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/server/middlewares/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,OAAO,IAAI,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AACvF,OAAO,EAAE,OAAO,IAAI,+BAA+B,EAAE,MAAM,qCAAqC,CAAC;AACjG,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,oBAAoB,CAAC"}
@@ -3,21 +3,23 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.replyMiddleware = exports.addHistoryMiddleware = exports.resolvePublicMiddleware = exports.handleInternalMiddleware = exports.matchExpectationMiddleware = exports.buildDestroyRequestMiddleware = exports.handleExpectationDelayMiddleware = exports.handleExpectationForwardMiddleware = void 0;
7
- var handle_expectation_forward_middleware_1 = require("./handle-expectation-forward.middleware");
8
- Object.defineProperty(exports, "handleExpectationForwardMiddleware", { enumerable: true, get: function () { return __importDefault(handle_expectation_forward_middleware_1).default; } });
9
- var handle_expectation_delay_middleware_1 = require("./handle-expectation-delay.middleware");
10
- Object.defineProperty(exports, "handleExpectationDelayMiddleware", { enumerable: true, get: function () { return __importDefault(handle_expectation_delay_middleware_1).default; } });
11
- var destroy_request_midleware_1 = require("./destroy-request.midleware");
12
- Object.defineProperty(exports, "buildDestroyRequestMiddleware", { enumerable: true, get: function () { return __importDefault(destroy_request_midleware_1).default; } });
6
+ exports.replyMiddleware = exports.historyMiddleware = exports.publicMiddleware = exports.internalMiddleware = exports.manipulateExpectationMiddleware = exports.matchExpectationMiddleware = exports.destroyMiddleware = exports.delayMiddleware = exports.forwardMiddleware = void 0;
7
+ var forward_middleware_1 = require("./forward.middleware");
8
+ Object.defineProperty(exports, "forwardMiddleware", { enumerable: true, get: function () { return __importDefault(forward_middleware_1).default; } });
9
+ var delay_middleware_1 = require("./delay.middleware");
10
+ Object.defineProperty(exports, "delayMiddleware", { enumerable: true, get: function () { return __importDefault(delay_middleware_1).default; } });
11
+ var destroy_midleware_1 = require("./destroy.midleware");
12
+ Object.defineProperty(exports, "destroyMiddleware", { enumerable: true, get: function () { return __importDefault(destroy_midleware_1).default; } });
13
13
  var match_expectation_middleware_1 = require("./match-expectation.middleware");
14
14
  Object.defineProperty(exports, "matchExpectationMiddleware", { enumerable: true, get: function () { return __importDefault(match_expectation_middleware_1).default; } });
15
- var internal_route_middleware_1 = require("./internal-route.middleware");
16
- Object.defineProperty(exports, "handleInternalMiddleware", { enumerable: true, get: function () { return __importDefault(internal_route_middleware_1).default; } });
17
- var resolve_public_middleware_1 = require("./resolve-public.middleware");
18
- Object.defineProperty(exports, "resolvePublicMiddleware", { enumerable: true, get: function () { return __importDefault(resolve_public_middleware_1).default; } });
19
- var add_history_middleware_1 = require("./add-history.middleware");
20
- Object.defineProperty(exports, "addHistoryMiddleware", { enumerable: true, get: function () { return __importDefault(add_history_middleware_1).default; } });
15
+ var manipulate_expectation_middleware_1 = require("./manipulate-expectation.middleware");
16
+ Object.defineProperty(exports, "manipulateExpectationMiddleware", { enumerable: true, get: function () { return __importDefault(manipulate_expectation_middleware_1).default; } });
17
+ var internal_middleware_1 = require("./internal.middleware");
18
+ Object.defineProperty(exports, "internalMiddleware", { enumerable: true, get: function () { return __importDefault(internal_middleware_1).default; } });
19
+ var public_middleware_1 = require("./public.middleware");
20
+ Object.defineProperty(exports, "publicMiddleware", { enumerable: true, get: function () { return __importDefault(public_middleware_1).default; } });
21
+ var history_middleware_1 = require("./history.middleware");
22
+ Object.defineProperty(exports, "historyMiddleware", { enumerable: true, get: function () { return __importDefault(history_middleware_1).default; } });
21
23
  var reply_middleware_1 = require("./reply.middleware");
22
24
  Object.defineProperty(exports, "replyMiddleware", { enumerable: true, get: function () { return __importDefault(reply_middleware_1).default; } });
23
25
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/server/middlewares/index.ts"],"names":[],"mappings":";;;;;;AAAA,iGAAwG;AAA/F,4KAAA,OAAO,OAAsC;AACtD,6FAAoG;AAA3F,wKAAA,OAAO,OAAoC;AACpD,yEAAuF;AAA9E,2JAAA,OAAO,OAAiC;AACjD,+EAAuF;AAA9E,2JAAA,OAAO,OAA8B;AAC9C,yEAAkF;AAAzE,sJAAA,OAAO,OAA4B;AAC5C,yEAAiF;AAAxE,qJAAA,OAAO,OAA2B;AAC3C,mEAA2E;AAAlE,+IAAA,OAAO,OAAwB;AACxC,uDAAgE;AAAvD,oIAAA,OAAO,OAAmB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/server/middlewares/index.ts"],"names":[],"mappings":";;;;;;AAAA,2DAAoE;AAA3D,wIAAA,OAAO,OAAqB;AACrC,uDAAgE;AAAvD,oIAAA,OAAO,OAAmB;AACnC,yDAAmE;AAA1D,uIAAA,OAAO,OAAqB;AACrC,+EAAuF;AAA9E,2JAAA,OAAO,OAA8B;AAC9C,yFAAiG;AAAxF,qKAAA,OAAO,OAAmC;AACnD,6DAAsE;AAA7D,0IAAA,OAAO,OAAsB;AACtC,yDAAkE;AAAzD,sIAAA,OAAO,OAAoB;AACpC,2DAAoE;AAA3D,wIAAA,OAAO,OAAqB;AACrC,uDAAgE;AAAvD,oIAAA,OAAO,OAAmB"}
@@ -1,18 +1,26 @@
1
1
  import { Middleware } from '../models';
2
2
  declare const _default: Middleware<never, import("../models").HttpRequestContext<unknown> & {
3
- shared: SetRequiredKeys<{
3
+ shared: import("../..").SetRequiredKeys<{
4
+ state: Record<string, unknown>;
5
+ seed?: number;
4
6
  expectation?: import("../../expectations").Expectation<Pick<import("../models").HttpRequestContext, "incoming" | "outgoing">>;
5
- history?: import("../history").History;
7
+ manipulated?: import("../../expectations").IExpectationOperatorContext;
6
8
  forwarded?: Pick<import("../models").HttpRequestContext, "incoming" | "outgoing">;
9
+ history?: import("../history").History;
7
10
  }, never>;
8
11
  }> & {
9
- handler: TFunction<unknown, [import("../models").HttpRequestContext<unknown> & {
10
- shared: SetRequiredKeys<{
12
+ handler: import("../..").TFunction<unknown, [import("../models").HttpRequestContext<unknown> & {
13
+ shared: import("../..").SetRequiredKeys<{
14
+ state: Record<string, unknown>;
15
+ seed?: number;
11
16
  expectation?: import("../../expectations").Expectation<Pick<import("../models").HttpRequestContext, "incoming" | "outgoing">>;
12
- history?: import("../history").History;
17
+ manipulated?: import("../../expectations").IExpectationOperatorContext;
13
18
  forwarded?: Pick<import("../models").HttpRequestContext, "incoming" | "outgoing">;
19
+ history?: import("../history").History;
14
20
  }, never>;
15
- }, (shared?: Partial<import("../models").HttpRequestContext["shared"]>) => unknown]>;
21
+ }, {
22
+ logger: import("../..").Logger;
23
+ }]>;
16
24
  };
17
25
  export default _default;
18
- //# sourceMappingURL=resolve-public.middleware.d.ts.map
26
+ //# sourceMappingURL=internal.middleware.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internal.middleware.d.ts","sourceRoot":"","sources":["../../../../src/server/middlewares/internal.middleware.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;;;;;;;;;;;;;;;;;;;;;;;;AAGvC,wBAUK"}
@@ -1,12 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const router_1 = require("../router");
4
3
  const models_1 = require("../models");
4
+ const router_1 = require("../router");
5
5
  exports.default = models_1.Middleware
6
6
  .build(__filename)
7
- .assignHandler((context, next) => {
7
+ .assignHandler(async (context) => {
8
8
  const key = [context.incoming.method, context.incoming.path].join(':');
9
9
  const endpoint = router_1.routes[context.type][key];
10
- return endpoint?.handler ? endpoint.handler(context) : next();
10
+ if (endpoint?.handler) {
11
+ await endpoint.handler(context);
12
+ context.complete();
13
+ }
11
14
  });
12
- //# sourceMappingURL=internal-route.middleware.js.map
15
+ //# sourceMappingURL=internal.middleware.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internal.middleware.js","sourceRoot":"","sources":["../../../../src/server/middlewares/internal.middleware.ts"],"names":[],"mappings":";;AAEA,sCAAuC;AACvC,sCAAmC;AAEnC,kBAAe,mBAAU;KACtB,KAAK,CAAC,UAAU,CAAC;KACjB,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;IAC/B,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACvE,MAAM,QAAQ,GAAG,eAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;IAE3C,IAAI,QAAQ,EAAE,OAAO,EAAE,CAAC;QACtB,MAAM,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAChC,OAAO,CAAC,QAAQ,EAAE,CAAC;IACrB,CAAC;AACH,CAAC,CAAC,CAAC"}
@@ -1,18 +1,26 @@
1
1
  import { Middleware } from '../models';
2
2
  declare const _default: Middleware<"expectation", import("../models").HttpRequestContext<unknown> & {
3
- shared: SetRequiredKeys<{
3
+ shared: import("../..").SetRequiredKeys<{
4
+ state: Record<string, unknown>;
5
+ seed?: number;
4
6
  expectation?: import("../../expectations").Expectation<Pick<import("../models").HttpRequestContext, "incoming" | "outgoing">>;
5
- history?: import("../history").History;
7
+ manipulated?: import("../../expectations").IExpectationOperatorContext;
6
8
  forwarded?: Pick<import("../models").HttpRequestContext, "incoming" | "outgoing">;
9
+ history?: import("../history").History;
7
10
  }, "expectation">;
8
11
  }> & {
9
- handler: TFunction<unknown, [import("../models").HttpRequestContext<unknown> & {
10
- shared: SetRequiredKeys<{
12
+ handler: import("../..").TFunction<unknown, [import("../models").HttpRequestContext<unknown> & {
13
+ shared: import("../..").SetRequiredKeys<{
14
+ state: Record<string, unknown>;
15
+ seed?: number;
11
16
  expectation?: import("../../expectations").Expectation<Pick<import("../models").HttpRequestContext, "incoming" | "outgoing">>;
12
- history?: import("../history").History;
17
+ manipulated?: import("../../expectations").IExpectationOperatorContext;
13
18
  forwarded?: Pick<import("../models").HttpRequestContext, "incoming" | "outgoing">;
19
+ history?: import("../history").History;
14
20
  }, "expectation">;
15
- }, (shared?: Partial<import("../models").HttpRequestContext["shared"]>) => unknown]>;
21
+ }, {
22
+ logger: import("../..").Logger;
23
+ }]>;
16
24
  };
17
25
  export default _default;
18
- //# sourceMappingURL=handle-expectation-delay.middleware.d.ts.map
26
+ //# sourceMappingURL=manipulate-expectation.middleware.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manipulate-expectation.middleware.d.ts","sourceRoot":"","sources":["../../../../src/server/middlewares/manipulate-expectation.middleware.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;;;;;;;;;;;;;;;;;;;;;;;;AAEvC,wBAWK"}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const models_1 = require("../models");
4
+ exports.default = models_1.Middleware
5
+ .build(__filename, ['expectation'])
6
+ .assignHandler((context) => {
7
+ const manipulated = context.shared.expectation.request?.manipulate(context.toPlain({ clone: true, locations: ['incoming'] }));
8
+ context.share({
9
+ manipulated,
10
+ ...(manipulated?.seed !== undefined && { seed: manipulated.seed }),
11
+ });
12
+ });
13
+ //# sourceMappingURL=manipulate-expectation.middleware.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manipulate-expectation.middleware.js","sourceRoot":"","sources":["../../../../src/server/middlewares/manipulate-expectation.middleware.ts"],"names":[],"mappings":";;AACA,sCAAuC;AAEvC,kBAAe,mBAAU;KACtB,KAAK,CAAC,UAAU,EAAE,CAAC,aAAa,CAAC,CAAC;KAClC,aAAa,CAAC,CAAC,OAAO,EAAE,EAAE;IACzB,MAAM,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,OAAO,EAAE,UAAU,CAChE,OAAO,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC,CAC1D,CAAC;IAEF,OAAO,CAAC,KAAK,CAAC;QACZ,WAAW;QACX,GAAG,CAAC,WAAW,EAAE,IAAI,KAAK,SAAS,IAAI,EAAE,IAAI,EAAE,WAAW,CAAC,IAAI,EAAE,CAAC;KACnE,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,18 +1,26 @@
1
1
  import { Middleware } from '../models';
2
2
  declare const _default: Middleware<never, import("../models").HttpRequestContext<unknown> & {
3
- shared: SetRequiredKeys<{
3
+ shared: import("../..").SetRequiredKeys<{
4
+ state: Record<string, unknown>;
5
+ seed?: number;
4
6
  expectation?: import("../../expectations").Expectation<Pick<import("../models").HttpRequestContext, "incoming" | "outgoing">>;
5
- history?: import("../history").History;
7
+ manipulated?: import("../../expectations").IExpectationOperatorContext;
6
8
  forwarded?: Pick<import("../models").HttpRequestContext, "incoming" | "outgoing">;
9
+ history?: import("../history").History;
7
10
  }, never>;
8
11
  }> & {
9
- handler: TFunction<unknown, [import("../models").HttpRequestContext<unknown> & {
10
- shared: SetRequiredKeys<{
12
+ handler: import("../..").TFunction<unknown, [import("../models").HttpRequestContext<unknown> & {
13
+ shared: import("../..").SetRequiredKeys<{
14
+ state: Record<string, unknown>;
15
+ seed?: number;
11
16
  expectation?: import("../../expectations").Expectation<Pick<import("../models").HttpRequestContext, "incoming" | "outgoing">>;
12
- history?: import("../history").History;
17
+ manipulated?: import("../../expectations").IExpectationOperatorContext;
13
18
  forwarded?: Pick<import("../models").HttpRequestContext, "incoming" | "outgoing">;
19
+ history?: import("../history").History;
14
20
  }, never>;
15
- }, (shared?: Partial<import("../models").HttpRequestContext["shared"]>) => unknown]>;
21
+ }, {
22
+ logger: import("../..").Logger;
23
+ }]>;
16
24
  };
17
25
  export default _default;
18
26
  //# sourceMappingURL=match-expectation.middleware.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"match-expectation.middleware.d.ts","sourceRoot":"","sources":["../../../../src/server/middlewares/match-expectation.middleware.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;;;;;;;;;;;;;;;;AAEvC,wBAmBK"}
1
+ {"version":3,"file":"match-expectation.middleware.d.ts","sourceRoot":"","sources":["../../../../src/server/middlewares/match-expectation.middleware.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;;;;;;;;;;;;;;;;;;;;;;;;AAEvC,wBAqBK"}
@@ -3,18 +3,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const models_1 = require("../models");
4
4
  exports.default = models_1.Middleware
5
5
  .build(__filename)
6
- .assignHandler((context, next) => {
7
- const plain = context.toPlain();
6
+ .assignHandler((context, { logger }) => {
7
+ const plain = context.toPlain({ locations: ['incoming'] });
8
8
  const expectation = context.server.storage.expectations.match('request', plain);
9
9
  if (!expectation) {
10
- const historyRecord = context.server.storage.history
10
+ const history = context.server.storage.history
11
11
  .register(plain)
12
12
  .changeState('finished');
13
- context.server.exchange.ws.publish('history:added', historyRecord);
13
+ context.server.exchange.ws.publish('history:added', history.toPlain());
14
14
  return context.reply.notFound();
15
15
  }
16
+ logger.info('Has matched with', `"${expectation.name}" [${expectation.id}]`);
16
17
  expectation.increaseExecutionsCounter();
17
- context.server.exchange.ws.publish('expectation:updated', expectation);
18
- return next({ expectation });
18
+ context.server.exchange.ws.publish('expectation:updated', expectation.toPlain());
19
+ context.share({ expectation });
19
20
  });
20
21
  //# sourceMappingURL=match-expectation.middleware.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"match-expectation.middleware.js","sourceRoot":"","sources":["../../../../src/server/middlewares/match-expectation.middleware.ts"],"names":[],"mappings":";;AACA,sCAAuC;AAEvC,kBAAe,mBAAU;KACtB,KAAK,CAAC,UAAU,CAAC;KACjB,aAAa,CAAC,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE;IAC/B,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAChC,MAAM,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,KAAK,CAAM,SAAS,EAAE,KAAK,CAAC,CAAC;IAErF,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,MAAM,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO;aACjD,QAAQ,CAAC,KAAK,CAAC;aACf,WAAW,CAAC,UAAU,CAAC,CAAC;QAE3B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,OAAO,CAAC,eAAe,EAAE,aAAa,CAAC,CAAC;QACnE,OAAO,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;IAClC,CAAC;IAED,WAAW,CAAC,yBAAyB,EAAE,CAAC;IACxC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,OAAO,CAAC,qBAAqB,EAAE,WAAW,CAAC,CAAC;IAEvE,OAAO,IAAI,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC;AAC/B,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"match-expectation.middleware.js","sourceRoot":"","sources":["../../../../src/server/middlewares/match-expectation.middleware.ts"],"names":[],"mappings":";;AACA,sCAAuC;AAEvC,kBAAe,mBAAU;KACtB,KAAK,CAAC,UAAU,CAAC;KACjB,aAAa,CAAC,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;IACrC,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,EAAE,SAAS,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;IAC3D,MAAM,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,KAAK,CAAM,SAAS,EAAE,KAAK,CAAC,CAAC;IAErF,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,MAAM,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO;aAC3C,QAAQ,CAAC,KAAK,CAAC;aACf,WAAW,CAAC,UAAU,CAAC,CAAC;QAE3B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,OAAO,CAAC,eAAe,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;QACvE,OAAO,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;IAClC,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,kBAAkB,EAAE,IAAI,WAAW,CAAC,IAAI,MAAM,WAAW,CAAC,EAAE,GAAG,CAAC,CAAC;IAE7E,WAAW,CAAC,yBAAyB,EAAE,CAAC;IAExC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,OAAO,CAAC,qBAAqB,EAAE,WAAW,CAAC,OAAO,EAAE,CAAC,CAAC;IACjF,OAAO,CAAC,KAAK,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC;AACjC,CAAC,CAAC,CAAC"}
@@ -1,18 +1,26 @@
1
1
  import { Middleware } from '../models';
2
2
  declare const _default: Middleware<never, import("../models").HttpRequestContext<unknown> & {
3
- shared: SetRequiredKeys<{
3
+ shared: import("../..").SetRequiredKeys<{
4
+ state: Record<string, unknown>;
5
+ seed?: number;
4
6
  expectation?: import("../../expectations").Expectation<Pick<import("../models").HttpRequestContext, "incoming" | "outgoing">>;
5
- history?: import("../history").History;
7
+ manipulated?: import("../../expectations").IExpectationOperatorContext;
6
8
  forwarded?: Pick<import("../models").HttpRequestContext, "incoming" | "outgoing">;
9
+ history?: import("../history").History;
7
10
  }, never>;
8
11
  }> & {
9
- handler: TFunction<unknown, [import("../models").HttpRequestContext<unknown> & {
10
- shared: SetRequiredKeys<{
12
+ handler: import("../..").TFunction<unknown, [import("../models").HttpRequestContext<unknown> & {
13
+ shared: import("../..").SetRequiredKeys<{
14
+ state: Record<string, unknown>;
15
+ seed?: number;
11
16
  expectation?: import("../../expectations").Expectation<Pick<import("../models").HttpRequestContext, "incoming" | "outgoing">>;
12
- history?: import("../history").History;
17
+ manipulated?: import("../../expectations").IExpectationOperatorContext;
13
18
  forwarded?: Pick<import("../models").HttpRequestContext, "incoming" | "outgoing">;
19
+ history?: import("../history").History;
14
20
  }, never>;
15
- }, (shared?: Partial<import("../models").HttpRequestContext["shared"]>) => unknown]>;
21
+ }, {
22
+ logger: import("../..").Logger;
23
+ }]>;
16
24
  };
17
25
  export default _default;
18
- //# sourceMappingURL=internal-route.middleware.d.ts.map
26
+ //# sourceMappingURL=public.middleware.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"public.middleware.d.ts","sourceRoot":"","sources":["../../../../src/server/middlewares/public.middleware.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;;;;;;;;;;;;;;;;;;;;;;;;AAGvC,wBAiCK"}
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const fs_1 = require("fs");
7
+ const path_1 = __importDefault(require("path"));
8
+ const promises_1 = __importDefault(require("fs/promises"));
9
+ const models_1 = require("../models");
10
+ const config_1 = __importDefault(require("../../config"));
11
+ exports.default = models_1.Middleware
12
+ .build(__filename)
13
+ .assignHandler(async (context) => {
14
+ const gui = config_1.default.get('gui');
15
+ const statics = config_1.default.get('statics');
16
+ if (!context.incoming.path.includes(gui.route)) {
17
+ return null;
18
+ }
19
+ const requestPath = context.incoming.path.replace(gui.route, '');
20
+ const requestPathDetails = path_1.default.parse(requestPath);
21
+ if (!requestPath) {
22
+ context.response.writeHead(301, 'Moved', { Location: path_1.default.join(gui.route, '/') }).end();
23
+ return context.complete();
24
+ }
25
+ if (requestPathDetails.dir === '/' && !requestPathDetails.ext) {
26
+ context.response.writeHead(200, 'Ok', { 'Content-type': 'text/html;charset=utf-8' });
27
+ (0, fs_1.createReadStream)(path_1.default.join(statics.public.dir, '/index.html')).pipe(context.response);
28
+ return context.complete();
29
+ }
30
+ const fileStat = await promises_1.default.stat(path_1.default.join(statics.public.dir, requestPath)).catch(() => null);
31
+ if (fileStat === null) {
32
+ context.response.writeHead(404, 'Not found').end();
33
+ return context.complete();
34
+ }
35
+ (0, fs_1.createReadStream)(path_1.default.join(statics.public.dir, requestPath)).pipe(context.response);
36
+ context.complete();
37
+ });
38
+ //# sourceMappingURL=public.middleware.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"public.middleware.js","sourceRoot":"","sources":["../../../../src/server/middlewares/public.middleware.ts"],"names":[],"mappings":";;;;;AAAA,2BAAsC;AACtC,gDAAwB;AACxB,2DAA6B;AAG7B,sCAAuC;AACvC,0DAAkC;AAElC,kBAAe,mBAAU;KACtB,KAAK,CAAC,UAAU,CAAC;KACjB,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;IAC/B,MAAM,GAAG,GAAG,gBAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAC9B,MAAM,OAAO,GAAG,gBAAM,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IAEtC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;QAC/C,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IACjE,MAAM,kBAAkB,GAAG,cAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IAEnD,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,GAAG,E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Context, Middleware } from '../models';
2
- declare const _default: Middleware<"expectation" | "history", HttpRequestContext<unknown> & {
3
- shared: SetRequiredKeys<{
2
+ declare const _default: Middleware<"history" | "expectation", HttpRequestContext<unknown> & {
3
+ shared: import("../..").SetRequiredKeys<{
4
+ state: Record<string, unknown>;
5
+ seed?: number;
4
6
  expectation?: import("../../expectations").Expectation<Pick<HttpRequestContext, "incoming" | "outgoing">>;
5
- history?: import("../history").History;
7
+ manipulated?: import("../../expectations").IExpectationOperatorContext;
6
8
  forwarded?: Pick<HttpRequestContext, "incoming" | "outgoing">;
7
- }, "expectation" | "history">;
9
+ history?: import("../history").History;
10
+ }, "history" | "expectation">;
8
11
  }> & {
9
- handler: TFunction<unknown, [HttpRequestContext<unknown> & {
10
- shared: SetRequiredKeys<{
12
+ handler: import("../..").TFunction<unknown, [HttpRequestContext<unknown> & {
13
+ shared: import("../..").SetRequiredKeys<{
14
+ state: Record<string, unknown>;
15
+ seed?: number;
11
16
  expectation?: import("../../expectations").Expectation<Pick<HttpRequestContext, "incoming" | "outgoing">>;
12
- history?: import("../history").History;
17
+ manipulated?: import("../../expectations").IExpectationOperatorContext;
13
18
  forwarded?: Pick<HttpRequestContext, "incoming" | "outgoing">;
14
- }, "expectation" | "history">;
15
- }, (shared?: Partial<HttpRequestContext["shared"]>) => unknown]>;
19
+ history?: import("../history").History;
20
+ }, "history" | "expectation">;
21
+ }, {
22
+ logger: import("../..").Logger;
23
+ }]>;
16
24
  };
17
25
  export default _default;
18
26
  //# sourceMappingURL=reply.middleware.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"reply.middleware.d.ts","sourceRoot":"","sources":["../../../../src/server/middlewares/reply.middleware.ts"],"names":[],"mappings":"AACA,OAAO,EAAsB,kBAAkB,EAAoD,UAAU,EAAoB,MAAM,WAAW,CAAC;;;;;;;;;;;;;;;;AAkBnJ,wBAiCK"}
1
+ {"version":3,"file":"reply.middleware.d.ts","sourceRoot":"","sources":["../../../../src/server/middlewares/reply.middleware.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,kBAAkB,EAGlB,UAAU,EAEX,MAAM,WAAW,CAAC;;;;;;;;;;;;;;;;;;;;;;;;AAkBnB,wBAgCK"}
@@ -15,14 +15,14 @@ const buildEmptyOutgoing = (incoming) => ({
15
15
  },
16
16
  });
17
17
  exports.default = models_1.Middleware
18
- .build(__dirname, ['history', 'expectation'])
19
- .assignHandler((context) => {
20
- const { incoming, forwarded } = context.toPlain({ locations: ['incoming', 'forwarded.outgoing'], clone: true });
18
+ .build(__filename, ['history', 'expectation'])
19
+ .assignHandler(async (context) => {
20
+ const plain = context.toPlain({ locations: ['incoming', 'forwarded.outgoing'], clone: true });
21
21
  const manipulated = context.shared.expectation.response?.manipulate({
22
- incoming,
23
- outgoing: forwarded?.outgoing ?? buildEmptyOutgoing(context.incoming),
22
+ ...plain,
23
+ outgoing: plain.forwarded?.outgoing ?? buildEmptyOutgoing(context.incoming),
24
24
  });
25
- const outgoing = manipulated?.outgoing ?? forwarded?.outgoing ?? buildEmptyOutgoing(context.incoming);
25
+ const outgoing = manipulated?.outgoing ?? plain.forwarded?.outgoing ?? buildEmptyOutgoing(context.incoming);
26
26
  const type = (0, models_1.extractPayloadType)(outgoing.headers);
27
27
  const data = outgoing.data === undefined ? outgoing.dataRaw : outgoing.data;
28
28
  const dataRaw = Buffer.from(typeof data === 'object' ? (0, models_1.serializePayload)(type, data) : String(data));
@@ -35,10 +35,9 @@ exports.default = models_1.Middleware
35
35
  }),
36
36
  })
37
37
  });
38
- context.response.writeHead(outgoing.status ?? 200, outgoing.headers);
39
- context.response.write(outgoing.dataRaw);
40
- context.response.end();
41
- context.shared.history.assignOutgoing(outgoing).changeState('finished');
38
+ await context.server.plugins.exec('outgoing.response', context.response, context.assignOutgoing(outgoing));
39
+ context.shared.history.assignOutgoing(context.outgoing).changeState('finished');
42
40
  context.server.exchange.ws.publish('history:updated', context.shared.history.toPlain());
41
+ context.complete();
43
42
  });
44
43
  //# sourceMappingURL=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AAE,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;IAExF,OAAO,CAAC,QAAQ,EAAE,CAAC;AACrB,CAAC,CAAC,CAAC"}
@@ -1,5 +1,6 @@
1
1
  import type { HttpRequestContext, IRequestContextIncoming, WsRequestContext } from './request-context';
2
- import type { IBaseRouteResponse } from './reply-service';
2
+ import type { OmitPartial, TFunction } from '../../types';
3
+ import type { IBaseRouteResponse } from './reply';
3
4
  export declare class Endpoint<TResponse = unknown, TRequest extends Partial<Pick<IRequestContextIncoming, 'body' | 'query'>> = {}> {
4
5
  TResponse: IBaseRouteResponse<TResponse>;
5
6
  TParameters: {