@n1k1t/mock-server 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/package.json +5 -2
- package/lib/src/client/helpers/expectations.d.ts +89 -0
- package/lib/src/client/helpers/expectations.d.ts.map +1 -0
- package/lib/src/client/helpers/expectations.js +66 -0
- package/lib/src/client/helpers/expectations.js.map +1 -0
- package/lib/src/client/helpers/index.d.ts +2 -0
- package/lib/src/client/helpers/index.d.ts.map +1 -0
- package/lib/src/client/helpers/index.js +18 -0
- package/lib/src/client/helpers/index.js.map +1 -0
- package/lib/src/client/index.d.ts +1 -0
- package/lib/src/client/index.d.ts.map +1 -1
- package/lib/src/client/index.js +1 -0
- package/lib/src/client/index.js.map +1 -1
- package/lib/src/client/methods/expectations.create.method.d.ts +1 -3
- package/lib/src/client/methods/expectations.create.method.d.ts.map +1 -1
- package/lib/src/client/methods/expectations.create.method.js +3 -3
- package/lib/src/client/methods/expectations.create.method.js.map +1 -1
- package/lib/src/client/methods/expectations.update.method.d.ts +2 -2
- package/lib/src/client/methods/expectations.update.method.js +6 -6
- package/lib/src/client/methods/expectations.update.method.js.map +1 -1
- package/lib/src/client/methods/ping.method.d.ts +1 -1
- package/lib/src/client/methods/ping.method.js.map +1 -1
- package/lib/src/client/models/client.d.ts +40 -0
- package/lib/src/client/models/client.d.ts.map +1 -0
- package/lib/src/client/models/client.js +33 -0
- package/lib/src/client/models/client.js.map +1 -0
- package/lib/src/client/models/client.spec.d.ts +2 -0
- package/lib/src/client/models/client.spec.d.ts.map +1 -0
- package/lib/src/client/models/client.spec.js +224 -0
- package/lib/src/client/models/client.spec.js.map +1 -0
- package/lib/src/client/models/index.d.ts +1 -0
- package/lib/src/client/models/index.d.ts.map +1 -1
- package/lib/src/client/models/index.js +1 -0
- package/lib/src/client/models/index.js.map +1 -1
- package/lib/src/client/models/method.d.ts +4 -4
- package/lib/src/client/models/method.d.ts.map +1 -1
- package/lib/src/client/models/method.js.map +1 -1
- package/lib/src/client/onsite.d.ts +4 -3
- package/lib/src/client/onsite.d.ts.map +1 -1
- package/lib/src/client/onsite.js +8 -6
- package/lib/src/client/onsite.js.map +1 -1
- package/lib/src/client/remote.d.ts +4 -4
- package/lib/src/client/remote.d.ts.map +1 -1
- package/lib/src/client/remote.js +11 -10
- package/lib/src/client/remote.js.map +1 -1
- package/lib/src/client/types.d.ts +2 -0
- package/lib/src/client/types.d.ts.map +1 -1
- package/lib/src/client/utils.d.ts +2 -2
- package/lib/src/client/utils.d.ts.map +1 -1
- package/lib/src/client/utils.js +25 -12
- package/lib/src/client/utils.js.map +1 -1
- package/lib/src/expectations/__utils__/index.d.ts +2 -2
- package/lib/src/expectations/__utils__/index.d.ts.map +1 -1
- package/lib/src/expectations/__utils__/index.js +31 -23
- package/lib/src/expectations/__utils__/index.js.map +1 -1
- package/lib/src/expectations/index.d.ts +1 -2
- package/lib/src/expectations/index.d.ts.map +1 -1
- package/lib/src/expectations/index.js +1 -2
- package/lib/src/expectations/index.js.map +1 -1
- package/lib/src/expectations/models/expectation.d.ts +33 -0
- package/lib/src/expectations/models/expectation.d.ts.map +1 -0
- package/lib/src/expectations/models/expectation.js +81 -0
- package/lib/src/expectations/models/expectation.js.map +1 -0
- package/lib/src/expectations/models/index.d.ts +4 -0
- package/lib/src/expectations/models/index.d.ts.map +1 -0
- package/lib/src/expectations/models/index.js +20 -0
- package/lib/src/expectations/models/index.js.map +1 -0
- package/lib/src/expectations/models/operator.d.ts +20 -0
- package/lib/src/expectations/models/operator.d.ts.map +1 -0
- package/lib/src/expectations/models/operator.js +49 -0
- package/lib/src/expectations/models/operator.js.map +1 -0
- package/lib/src/expectations/models/storage.d.ts +15 -0
- package/lib/src/expectations/models/storage.d.ts.map +1 -0
- package/lib/src/expectations/{storage.js → models/storage.js} +4 -14
- package/lib/src/expectations/models/storage.js.map +1 -0
- package/lib/src/expectations/models/storage.spec.d.ts +2 -0
- package/lib/src/expectations/models/storage.spec.d.ts.map +1 -0
- package/lib/src/expectations/models/storage.spec.js +111 -0
- package/lib/src/expectations/models/storage.spec.js.map +1 -0
- package/lib/src/expectations/operators/and.operator.d.ts +7 -2
- package/lib/src/expectations/operators/and.operator.d.ts.map +1 -1
- package/lib/src/expectations/operators/and.operator.js +21 -2
- package/lib/src/expectations/operators/and.operator.js.map +1 -1
- package/lib/src/expectations/operators/and.operator.spec.js +57 -39
- package/lib/src/expectations/operators/and.operator.spec.js.map +1 -1
- package/lib/src/expectations/operators/exec.operator.d.ts +7 -2
- package/lib/src/expectations/operators/exec.operator.d.ts.map +1 -1
- package/lib/src/expectations/operators/exec.operator.js +14 -18
- package/lib/src/expectations/operators/exec.operator.js.map +1 -1
- package/lib/src/expectations/operators/exec.operator.spec.js +49 -18
- package/lib/src/expectations/operators/exec.operator.spec.js.map +1 -1
- package/lib/src/expectations/operators/has.operator.d.ts +27 -2
- package/lib/src/expectations/operators/has.operator.d.ts.map +1 -1
- package/lib/src/expectations/operators/has.operator.js +108 -69
- package/lib/src/expectations/operators/has.operator.js.map +1 -1
- package/lib/src/expectations/operators/has.operator.spec.js +422 -161
- package/lib/src/expectations/operators/has.operator.spec.js.map +1 -1
- package/lib/src/expectations/operators/if.operator.d.ts +15 -2
- package/lib/src/expectations/operators/if.operator.d.ts.map +1 -1
- package/lib/src/expectations/operators/if.operator.js +44 -10
- package/lib/src/expectations/operators/if.operator.js.map +1 -1
- package/lib/src/expectations/operators/if.operator.spec.js +89 -65
- package/lib/src/expectations/operators/if.operator.spec.js.map +1 -1
- package/lib/src/expectations/operators/index.d.ts +2 -0
- package/lib/src/expectations/operators/index.d.ts.map +1 -1
- package/lib/src/expectations/operators/index.js +5 -1
- package/lib/src/expectations/operators/index.js.map +1 -1
- package/lib/src/expectations/operators/merge.operator.d.ts +13 -2
- package/lib/src/expectations/operators/merge.operator.d.ts.map +1 -1
- package/lib/src/expectations/operators/merge.operator.js +23 -19
- package/lib/src/expectations/operators/merge.operator.js.map +1 -1
- package/lib/src/expectations/operators/merge.operator.spec.js +43 -33
- package/lib/src/expectations/operators/merge.operator.spec.js.map +1 -1
- package/lib/src/expectations/operators/not.operator.d.ts +7 -2
- package/lib/src/expectations/operators/not.operator.d.ts.map +1 -1
- package/lib/src/expectations/operators/not.operator.js +21 -2
- package/lib/src/expectations/operators/not.operator.js.map +1 -1
- package/lib/src/expectations/operators/not.operator.spec.js +28 -9
- package/lib/src/expectations/operators/not.operator.spec.js.map +1 -1
- package/lib/src/expectations/operators/or.operator.d.ts +7 -2
- package/lib/src/expectations/operators/or.operator.d.ts.map +1 -1
- package/lib/src/expectations/operators/or.operator.js +21 -6
- package/lib/src/expectations/operators/or.operator.js.map +1 -1
- package/lib/src/expectations/operators/or.operator.spec.js +58 -39
- package/lib/src/expectations/operators/or.operator.spec.js.map +1 -1
- package/lib/src/expectations/operators/remove.operator.d.ts +12 -2
- package/lib/src/expectations/operators/remove.operator.d.ts.map +1 -1
- package/lib/src/expectations/operators/remove.operator.js +22 -17
- package/lib/src/expectations/operators/remove.operator.js.map +1 -1
- package/lib/src/expectations/operators/remove.operator.spec.js +40 -28
- package/lib/src/expectations/operators/remove.operator.spec.js.map +1 -1
- package/lib/src/expectations/operators/root.operator.d.ts +8 -0
- package/lib/src/expectations/operators/root.operator.d.ts.map +1 -0
- package/lib/src/expectations/operators/root.operator.js +36 -0
- package/lib/src/expectations/operators/root.operator.js.map +1 -0
- package/lib/src/expectations/operators/set.operator.d.ts +20 -2
- package/lib/src/expectations/operators/set.operator.d.ts.map +1 -1
- package/lib/src/expectations/operators/set.operator.js +38 -23
- package/lib/src/expectations/operators/set.operator.js.map +1 -1
- package/lib/src/expectations/operators/set.operator.spec.js +87 -43
- package/lib/src/expectations/operators/set.operator.spec.js.map +1 -1
- package/lib/src/expectations/operators/switch.operator.d.ts +25 -0
- package/lib/src/expectations/operators/switch.operator.d.ts.map +1 -0
- package/lib/src/expectations/operators/switch.operator.js +68 -0
- package/lib/src/expectations/operators/switch.operator.js.map +1 -0
- package/lib/src/expectations/operators/switch.operator.spec.d.ts +2 -0
- package/lib/src/expectations/operators/switch.operator.spec.d.ts.map +1 -0
- package/lib/src/expectations/operators/switch.operator.spec.js +129 -0
- package/lib/src/expectations/operators/switch.operator.spec.js.map +1 -0
- package/lib/src/expectations/types.d.ts +67 -63
- package/lib/src/expectations/types.d.ts.map +1 -1
- package/lib/src/expectations/types.js +17 -3
- package/lib/src/expectations/types.js.map +1 -1
- package/lib/src/expectations/utils.d.ts +23 -10
- package/lib/src/expectations/utils.d.ts.map +1 -1
- package/lib/src/expectations/utils.js +111 -53
- package/lib/src/expectations/utils.js.map +1 -1
- package/lib/src/server/endpoints/config.get.endpoint.d.ts +8 -3
- package/lib/src/server/endpoints/config.get.endpoint.d.ts.map +1 -1
- package/lib/src/server/endpoints/config.get.endpoint.js +2 -4
- package/lib/src/server/endpoints/config.get.endpoint.js.map +1 -1
- package/lib/src/server/endpoints/expectations.create.endpoint.d.ts +9 -11
- package/lib/src/server/endpoints/expectations.create.endpoint.d.ts.map +1 -1
- package/lib/src/server/endpoints/expectations.create.endpoint.js +2 -3
- package/lib/src/server/endpoints/expectations.create.endpoint.js.map +1 -1
- package/lib/src/server/endpoints/expectations.delete.endpoint.d.ts +8 -5
- package/lib/src/server/endpoints/expectations.delete.endpoint.d.ts.map +1 -1
- package/lib/src/server/endpoints/expectations.delete.endpoint.js +2 -2
- package/lib/src/server/endpoints/expectations.delete.endpoint.js.map +1 -1
- package/lib/src/server/endpoints/expectations.get-list.endpoint.d.ts +8 -3
- package/lib/src/server/endpoints/expectations.get-list.endpoint.d.ts.map +1 -1
- package/lib/src/server/endpoints/expectations.get-list.endpoint.js +2 -2
- package/lib/src/server/endpoints/expectations.get-list.endpoint.js.map +1 -1
- package/lib/src/server/endpoints/expectations.update.endpoint.d.ts +13 -11
- package/lib/src/server/endpoints/expectations.update.endpoint.d.ts.map +1 -1
- package/lib/src/server/endpoints/expectations.update.endpoint.js +4 -6
- package/lib/src/server/endpoints/expectations.update.endpoint.js.map +1 -1
- package/lib/src/server/endpoints/history.get-list.endpoint.d.ts +27 -0
- package/lib/src/server/endpoints/history.get-list.endpoint.d.ts.map +1 -0
- package/lib/src/server/endpoints/history.get-list.endpoint.js +11 -0
- package/lib/src/server/endpoints/history.get-list.endpoint.js.map +1 -0
- package/lib/src/server/endpoints/index.d.ts +1 -1
- package/lib/src/server/endpoints/index.d.ts.map +1 -1
- package/lib/src/server/endpoints/index.js +3 -3
- package/lib/src/server/endpoints/index.js.map +1 -1
- package/lib/src/server/endpoints/ping.endpoint.d.ts +8 -3
- package/lib/src/server/endpoints/ping.endpoint.d.ts.map +1 -1
- package/lib/src/server/endpoints/ping.endpoint.js +1 -1
- package/lib/src/server/endpoints/ping.endpoint.js.map +1 -1
- package/lib/src/server/history/model.d.ts +16 -16
- package/lib/src/server/history/model.d.ts.map +1 -1
- package/lib/src/server/history/model.js +21 -6
- package/lib/src/server/history/model.js.map +1 -1
- package/lib/src/server/history/storage.d.ts +3 -4
- package/lib/src/server/history/storage.d.ts.map +1 -1
- package/lib/src/server/history/storage.js +2 -2
- package/lib/src/server/history/storage.js.map +1 -1
- package/lib/src/server/index.d.ts +10 -6
- package/lib/src/server/index.d.ts.map +1 -1
- package/lib/src/server/index.js +21 -22
- package/lib/src/server/index.js.map +1 -1
- package/lib/src/server/middlewares/delay.middleware.d.ts +24 -0
- package/lib/src/server/middlewares/delay.middleware.d.ts.map +1 -0
- package/lib/src/server/middlewares/delay.middleware.js +13 -0
- package/lib/src/server/middlewares/delay.middleware.js.map +1 -0
- package/lib/src/server/middlewares/destroy.midleware.d.ts +24 -0
- package/lib/src/server/middlewares/destroy.midleware.d.ts.map +1 -0
- package/lib/src/server/middlewares/destroy.midleware.js +16 -0
- package/lib/src/server/middlewares/destroy.midleware.js.map +1 -0
- package/lib/src/server/middlewares/forward.middleware.d.ts +24 -0
- package/lib/src/server/middlewares/forward.middleware.d.ts.map +1 -0
- package/lib/src/server/middlewares/forward.middleware.js +71 -0
- package/lib/src/server/middlewares/forward.middleware.js.map +1 -0
- package/lib/src/server/middlewares/history.middleware.d.ts +24 -0
- package/lib/src/server/middlewares/history.middleware.d.ts.map +1 -0
- package/lib/src/server/middlewares/history.middleware.js +13 -0
- package/lib/src/server/middlewares/history.middleware.js.map +1 -0
- package/lib/src/server/middlewares/index.d.ts +7 -6
- package/lib/src/server/middlewares/index.d.ts.map +1 -1
- package/lib/src/server/middlewares/index.js +15 -13
- package/lib/src/server/middlewares/index.js.map +1 -1
- package/lib/src/server/middlewares/internal-route.middleware.d.ts +20 -2
- package/lib/src/server/middlewares/internal-route.middleware.d.ts.map +1 -1
- package/lib/src/server/middlewares/internal-route.middleware.js +4 -3
- package/lib/src/server/middlewares/internal-route.middleware.js.map +1 -1
- package/lib/src/server/middlewares/manipulate-expectation.middleware.d.ts +24 -0
- package/lib/src/server/middlewares/manipulate-expectation.middleware.d.ts.map +1 -0
- package/lib/src/server/middlewares/manipulate-expectation.middleware.js +13 -0
- package/lib/src/server/middlewares/manipulate-expectation.middleware.js.map +1 -0
- package/lib/src/server/middlewares/match-expectation.middleware.d.ts +24 -0
- package/lib/src/server/middlewares/match-expectation.middleware.d.ts.map +1 -0
- package/lib/src/server/middlewares/match-expectation.middleware.js +20 -0
- package/lib/src/server/middlewares/match-expectation.middleware.js.map +1 -0
- package/lib/src/server/middlewares/public.middleware.d.ts +24 -0
- package/lib/src/server/middlewares/public.middleware.d.ts.map +1 -0
- package/lib/src/server/middlewares/{resolve-public.middleware.js → public.middleware.js} +13 -13
- package/lib/src/server/middlewares/public.middleware.js.map +1 -0
- package/lib/src/server/middlewares/reply.middleware.d.ts +21 -5
- package/lib/src/server/middlewares/reply.middleware.d.ts.map +1 -1
- package/lib/src/server/middlewares/reply.middleware.js +34 -25
- package/lib/src/server/middlewares/reply.middleware.js.map +1 -1
- package/lib/src/server/models/endpoint.d.ts +19 -13
- package/lib/src/server/models/endpoint.d.ts.map +1 -1
- package/lib/src/server/models/endpoint.js +2 -2
- package/lib/src/server/models/endpoint.js.map +1 -1
- package/lib/src/server/models/middleware.d.ts +21 -20
- package/lib/src/server/models/middleware.d.ts.map +1 -1
- package/lib/src/server/models/middleware.js +6 -10
- package/lib/src/server/models/middleware.js.map +1 -1
- package/lib/src/server/models/reply-service/index.d.ts +6 -6
- package/lib/src/server/models/reply-service/index.d.ts.map +1 -1
- package/lib/src/server/models/reply-service/index.js +24 -24
- package/lib/src/server/models/reply-service/index.js.map +1 -1
- package/lib/src/server/models/request-context/http.d.ts +45 -0
- package/lib/src/server/models/request-context/http.d.ts.map +1 -0
- package/lib/src/server/models/request-context/http.js +71 -0
- package/lib/src/server/models/request-context/http.js.map +1 -0
- package/lib/src/server/models/request-context/index.d.ts +4 -57
- package/lib/src/server/models/request-context/index.d.ts.map +1 -1
- package/lib/src/server/models/request-context/index.js +4 -57
- package/lib/src/server/models/request-context/index.js.map +1 -1
- package/lib/src/server/models/request-context/model.d.ts +13 -0
- package/lib/src/server/models/request-context/model.d.ts.map +1 -0
- package/lib/src/server/models/request-context/model.js +14 -0
- package/lib/src/server/models/request-context/model.js.map +1 -0
- package/lib/src/server/models/request-context/types.d.ts +16 -18
- package/lib/src/server/models/request-context/types.d.ts.map +1 -1
- package/lib/src/server/models/request-context/utils.d.ts +7 -3
- package/lib/src/server/models/request-context/utils.d.ts.map +1 -1
- package/lib/src/server/models/request-context/utils.js +48 -25
- package/lib/src/server/models/request-context/utils.js.map +1 -1
- package/lib/src/server/models/request-context/ws.d.ts +21 -0
- package/lib/src/server/models/request-context/ws.d.ts.map +1 -0
- package/lib/src/server/models/request-context/ws.js +22 -0
- package/lib/src/server/models/request-context/ws.js.map +1 -0
- package/lib/src/server/models/server-context.d.ts +4 -4
- package/lib/src/server/models/server-context.d.ts.map +1 -1
- package/lib/src/server/models/server-context.js +5 -5
- package/lib/src/server/models/server-context.js.map +1 -1
- package/lib/src/server/router.d.ts +4 -7
- package/lib/src/server/router.d.ts.map +1 -1
- package/lib/src/server/router.js +5 -12
- package/lib/src/server/router.js.map +1 -1
- package/lib/src/server/ws-exchange/index.d.ts +5 -0
- package/lib/src/server/ws-exchange/index.d.ts.map +1 -0
- package/lib/src/server/{web-socket-exchange → ws-exchange}/index.js +3 -3
- package/lib/src/server/ws-exchange/index.js.map +1 -0
- package/lib/src/server/ws-exchange/types.d.ts +12 -0
- package/lib/src/server/ws-exchange/types.d.ts.map +1 -0
- package/lib/src/server/ws-exchange/types.js.map +1 -0
- package/lib/src/types.d.ts +0 -1
- package/lib/src/types.d.ts.map +1 -1
- package/lib/src/utils/index.d.ts +1 -0
- package/lib/src/utils/index.d.ts.map +1 -1
- package/lib/src/utils/index.js +1 -0
- package/lib/src/utils/index.js.map +1 -1
- package/lib/src/utils/json.d.ts +1 -1
- package/lib/src/utils/json.d.ts.map +1 -1
- package/lib/src/utils/json.js +3 -3
- package/lib/src/utils/json.js.map +1 -1
- package/lib/src/utils/regexp.d.ts +2 -0
- package/lib/src/utils/regexp.d.ts.map +1 -0
- package/lib/src/utils/regexp.js +9 -0
- package/lib/src/utils/regexp.js.map +1 -0
- package/lib/test/index.js +140 -136
- package/lib/test/index.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types/common.global.d.ts +13 -6
- package/lib/types/common.global.d.ts.map +1 -1
- package/lib/types/lib.d.ts +1 -0
- package/lib/types/lib.d.ts.map +1 -1
- package/lib/types/lib.js +1 -0
- package/lib/types/lib.js.map +1 -1
- package/package.json +5 -2
- package/types/common.global.ts +21 -2
- package/types/lib.ts +1 -0
- package/lib/src/expectations/model.d.ts +0 -39
- package/lib/src/expectations/model.d.ts.map +0 -1
- package/lib/src/expectations/model.js +0 -90
- package/lib/src/expectations/model.js.map +0 -1
- package/lib/src/expectations/operators/utils.d.ts +0 -20
- package/lib/src/expectations/operators/utils.d.ts.map +0 -1
- package/lib/src/expectations/operators/utils.js +0 -67
- package/lib/src/expectations/operators/utils.js.map +0 -1
- package/lib/src/expectations/storage.d.ts +0 -19
- package/lib/src/expectations/storage.d.ts.map +0 -1
- package/lib/src/expectations/storage.js.map +0 -1
- package/lib/src/expectations/utils.spec.d.ts +0 -2
- package/lib/src/expectations/utils.spec.d.ts.map +0 -1
- package/lib/src/expectations/utils.spec.js +0 -59
- package/lib/src/expectations/utils.spec.js.map +0 -1
- package/lib/src/expectations/validation-schemas.d.ts +0 -14
- package/lib/src/expectations/validation-schemas.d.ts.map +0 -1
- package/lib/src/expectations/validation-schemas.js +0 -36
- package/lib/src/expectations/validation-schemas.js.map +0 -1
- package/lib/src/server/endpoints/history-records.get-list.endpoint.d.ts +0 -16
- package/lib/src/server/endpoints/history-records.get-list.endpoint.d.ts.map +0 -1
- package/lib/src/server/endpoints/history-records.get-list.endpoint.js +0 -9
- package/lib/src/server/endpoints/history-records.get-list.endpoint.js.map +0 -1
- package/lib/src/server/middlewares/add-history.middleware.d.ts +0 -8
- package/lib/src/server/middlewares/add-history.middleware.d.ts.map +0 -1
- package/lib/src/server/middlewares/add-history.middleware.js +0 -14
- package/lib/src/server/middlewares/add-history.middleware.js.map +0 -1
- package/lib/src/server/middlewares/destroy-request.midleware.d.ts +0 -8
- package/lib/src/server/middlewares/destroy-request.midleware.d.ts.map +0 -1
- package/lib/src/server/middlewares/destroy-request.midleware.js +0 -17
- package/lib/src/server/middlewares/destroy-request.midleware.js.map +0 -1
- package/lib/src/server/middlewares/handle-expectation-delay.middleware.d.ts +0 -8
- package/lib/src/server/middlewares/handle-expectation-delay.middleware.d.ts.map +0 -1
- package/lib/src/server/middlewares/handle-expectation-delay.middleware.js +0 -18
- package/lib/src/server/middlewares/handle-expectation-delay.middleware.js.map +0 -1
- package/lib/src/server/middlewares/handle-expectation-forward.middleware.d.ts +0 -8
- package/lib/src/server/middlewares/handle-expectation-forward.middleware.d.ts.map +0 -1
- package/lib/src/server/middlewares/handle-expectation-forward.middleware.js +0 -86
- package/lib/src/server/middlewares/handle-expectation-forward.middleware.js.map +0 -1
- package/lib/src/server/middlewares/resolve-public.middleware.d.ts +0 -6
- package/lib/src/server/middlewares/resolve-public.middleware.d.ts.map +0 -1
- package/lib/src/server/middlewares/resolve-public.middleware.js.map +0 -1
- package/lib/src/server/middlewares/validate-expectation-request.middleware.d.ts +0 -6
- package/lib/src/server/middlewares/validate-expectation-request.middleware.d.ts.map +0 -1
- package/lib/src/server/middlewares/validate-expectation-request.middleware.js +0 -20
- package/lib/src/server/middlewares/validate-expectation-request.middleware.js.map +0 -1
- package/lib/src/server/types.d.ts +0 -6
- package/lib/src/server/types.d.ts.map +0 -1
- package/lib/src/server/types.js.map +0 -1
- package/lib/src/server/web-socket-exchange/index.d.ts +0 -5
- package/lib/src/server/web-socket-exchange/index.d.ts.map +0 -1
- package/lib/src/server/web-socket-exchange/index.js.map +0 -1
- package/lib/src/server/web-socket-exchange/types.d.ts +0 -12
- package/lib/src/server/web-socket-exchange/types.d.ts.map +0 -1
- package/lib/src/server/web-socket-exchange/types.js +0 -3
- package/lib/src/server/web-socket-exchange/types.js.map +0 -1
- /package/lib/src/server/{types.js → ws-exchange/types.js} +0 -0
|
@@ -1,35 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const models_1 = require("../models");
|
|
4
|
+
const buildEmptyOutgoing = (incoming) => ({
|
|
5
|
+
type: incoming.type,
|
|
6
|
+
status: 200,
|
|
7
|
+
data: incoming.type === 'plain' ? '' : {},
|
|
8
|
+
dataRaw: '',
|
|
9
|
+
headers: {
|
|
10
|
+
'content-type': incoming.type === 'json'
|
|
11
|
+
? 'application/json'
|
|
12
|
+
: incoming.type === 'xml'
|
|
13
|
+
? 'application/xml'
|
|
14
|
+
: incoming.headers['content-type'] ?? 'text/plain',
|
|
15
|
+
},
|
|
16
|
+
});
|
|
4
17
|
exports.default = models_1.Middleware
|
|
5
|
-
.build(__dirname)
|
|
6
|
-
.requires(['historyRecord', 'expectation'])
|
|
18
|
+
.build(__dirname, ['history', 'expectation'])
|
|
7
19
|
.assignHandler((context) => {
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
Object.assign(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
...
|
|
22
|
-
...((!responseContext.headers?.['transfer-encoding'] && !context.http.request.headers['transfer-encoding']) && {
|
|
20
|
+
const plain = context.toPlain({ locations: ['incoming', 'forwarded.outgoing'], clone: true });
|
|
21
|
+
const manipulated = context.shared.expectation.response?.manipulate({
|
|
22
|
+
...plain,
|
|
23
|
+
outgoing: plain.forwarded?.outgoing ?? buildEmptyOutgoing(context.incoming),
|
|
24
|
+
});
|
|
25
|
+
const outgoing = manipulated?.outgoing ?? plain.forwarded?.outgoing ?? buildEmptyOutgoing(context.incoming);
|
|
26
|
+
const type = (0, models_1.extractPayloadType)(outgoing.headers);
|
|
27
|
+
const data = outgoing.data === undefined ? outgoing.dataRaw : outgoing.data;
|
|
28
|
+
const dataRaw = Buffer.from(typeof data === 'object' ? (0, models_1.serializePayload)(type, data) : String(data));
|
|
29
|
+
Object.assign(outgoing, {
|
|
30
|
+
type,
|
|
31
|
+
dataRaw,
|
|
32
|
+
headers: Object.assign(outgoing.headers, {
|
|
33
|
+
...((!outgoing.headers?.['transfer-encoding'] && !context.request.headers['transfer-encoding']) && {
|
|
23
34
|
'content-length': String(dataRaw.length),
|
|
24
35
|
}),
|
|
25
|
-
}
|
|
36
|
+
})
|
|
26
37
|
});
|
|
27
|
-
context.
|
|
28
|
-
context.
|
|
29
|
-
context.
|
|
30
|
-
context.shared.
|
|
31
|
-
|
|
32
|
-
.changeState('finished');
|
|
33
|
-
context.exchange.ws.publish('history:updated', context.shared.historyRecord);
|
|
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');
|
|
42
|
+
context.server.exchange.ws.publish('history:updated', context.shared.history.toPlain());
|
|
34
43
|
});
|
|
35
44
|
//# sourceMappingURL=reply.middleware.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reply.middleware.js","sourceRoot":"","sources":["../../../../src/server/middlewares/reply.middleware.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"reply.middleware.js","sourceRoot":"","sources":["../../../../src/server/middlewares/reply.middleware.ts"],"names":[],"mappings":";;AAEA,sCAOmB;AAEnB,MAAM,kBAAkB,GAAG,CAAC,QAAiC,EAA2B,EAAE,CAAC,CAAC;IAC1F,IAAI,EAAE,QAAQ,CAAC,IAAI;IACnB,MAAM,EAAE,GAAG;IAEX,IAAI,EAAE,QAAQ,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE;IACzC,OAAO,EAAE,EAAE;IAEX,OAAO,EAAE;QACP,cAAc,EAAE,QAAQ,CAAC,IAAI,KAAK,MAAM;YACtC,CAAC,CAAC,kBAAkB;YACpB,CAAC,CAAC,QAAQ,CAAC,IAAI,KAAK,KAAK;gBACzB,CAAC,CAAC,iBAAiB;gBACnB,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,YAAY;KACrD;CACF,CAAC,CAAC;AAEH,kBAAe,mBAAU;KACtB,KAAK,CAAC,SAAS,EAAE,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;KAC5C,aAAa,CAAC,CAAC,OAAO,EAAE,EAAE;IACzB,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,EAAE,SAAS,EAAE,CAAC,UAAU,EAAE,oBAAoB,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IAC9F,MAAM,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,QAAQ,EAAE,UAAU,CAAC;QAClE,GA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IACzC,OAAO,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC;IAEvB,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;IACxE,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,OAAO,CAAC,iBAAiB,EAAE,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;AAC1F,CAAC,CAAC,CAAC"}
|
|
@@ -1,26 +1,32 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { HttpRequestContext, IRequestContextIncoming, WsRequestContext } from './request-context';
|
|
2
2
|
import type { IBaseRouteResponse } from './reply-service';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
export declare class Endpoint<TResponse = unknown, TRequest extends Partial<Pick<IRequestContextIncoming, 'body' | 'query'>> = {}> {
|
|
4
|
+
TResponse: IBaseRouteResponse<TResponse>;
|
|
5
|
+
TParameters: {
|
|
6
|
+
body: 'body' extends keyof TRequest ? TRequest['body'] : (void | undefined);
|
|
7
|
+
query: 'query' extends keyof TRequest ? TRequest['query'] : (void | undefined);
|
|
8
|
+
};
|
|
9
|
+
handler?: TFunction<unknown, [
|
|
10
|
+
(HttpRequestContext<TResponse> | WsRequestContext<TResponse>) & {
|
|
11
|
+
incoming: OmitPartial<Endpoint<TResponse, TRequest>['TParameters']>;
|
|
12
|
+
}
|
|
13
|
+
]>;
|
|
14
|
+
ws?: {
|
|
9
15
|
path: string;
|
|
10
16
|
};
|
|
11
17
|
http?: {
|
|
12
|
-
method:
|
|
18
|
+
method: string;
|
|
13
19
|
path: string;
|
|
14
20
|
};
|
|
15
|
-
bindToHttp<This extends NonNullable<Endpoint<
|
|
21
|
+
bindToHttp<This extends NonNullable<Endpoint<TResponse, TRequest>['http']>>(http: This): this & {
|
|
16
22
|
http: This;
|
|
17
23
|
};
|
|
18
|
-
|
|
19
|
-
|
|
24
|
+
bindToWs<Q extends NonNullable<Endpoint<TResponse, TRequest>['ws']>>(ws: Q): this & {
|
|
25
|
+
ws: Q;
|
|
20
26
|
};
|
|
21
|
-
assignHandler<Q extends NonNullable<Endpoint<
|
|
27
|
+
assignHandler<Q extends NonNullable<Endpoint<TResponse, TRequest>['handler']>>(handler: Q): this & {
|
|
22
28
|
handler: Q;
|
|
23
29
|
};
|
|
24
|
-
static build<
|
|
30
|
+
static build<TResponse = unknown, TRequest extends Partial<Pick<IRequestContextIncoming, 'body' | 'query'>> = {}>(): Endpoint<TResponse, TRequest>;
|
|
25
31
|
}
|
|
26
32
|
//# sourceMappingURL=endpoint.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"endpoint.d.ts","sourceRoot":"","sources":["../../../../src/server/models/endpoint.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"endpoint.d.ts","sourceRoot":"","sources":["../../../../src/server/models/endpoint.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACvG,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAE1D,qBAAa,QAAQ,CACnB,SAAS,GAAG,OAAO,EACnB,QAAQ,SAAS,OAAO,CAAC,IAAI,CAAC,uBAAuB,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,EAAE;IAEvE,SAAS,EAAG,kBAAkB,CAAC,SAAS,CAAC,CAAC;IAC1C,WAAW,EAAG;QACnB,IAAI,EAAE,MAAM,SAAS,MAAM,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,GAAG,SAAS,CAAC,CAAC;QAC5E,KAAK,EAAE,OAAO,SAAS,MAAM,QAAQ,GAAG,QAAQ,CAAC,OAAO,C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}
|
|
11
11
|
assignHandler(handler) {
|
|
12
12
|
return Object.assign(this, { handler });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"endpoint.js","sourceRoot":"","sources":["../../../../src/server/models/endpoint.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"endpoint.js","sourceRoot":"","sources":["../../../../src/server/models/endpoint.ts"],"names":[],"mappings":";;;AAGA,MAAa,QAAQ;IAyBZ,UAAU,CAAkE,IAAU;QAC3F,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;IACvC,CAAC;IAEM,QAAQ,CAA6D,EAAK;QAC/E,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;IACrC,CAAC;IAEM,aAAa,CAAkE,OAAU;QAC9F,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;IAC1C,CAAC;IAED,MAAM,CAAC,KAAK;QAIV,OAAO,IAAI,QAAQ,EAAuB,CAAC;IAC7C,CAAC;CACF;AA3CD,4BA2CC"}
|
|
@@ -1,25 +1,26 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export
|
|
3
|
-
SetRequiredKeys<
|
|
4
|
-
|
|
5
|
-
},
|
|
6
|
-
(result?: Partial<RequestContext['shared']>) => unknown
|
|
7
|
-
]>;
|
|
8
|
-
export declare class Middleware {
|
|
1
|
+
import type { HttpRequestContext } from '../models';
|
|
2
|
+
export declare class Middleware<TRequired extends keyof HttpRequestContext['shared'] = never, TContext extends HttpRequestContext = HttpRequestContext & {
|
|
3
|
+
shared: SetRequiredKeys<HttpRequestContext['shared'], TRequired>;
|
|
4
|
+
}> {
|
|
9
5
|
name: string;
|
|
10
|
-
required
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
assignHandler<This extends Middleware, K extends This['required'] extends string[] ? ConvertTupleToUnion<This['required']> : never>(this: This, handler: TMiddlewareHandler<K>): This & {
|
|
17
|
-
handler: TMiddlewareHandler<K>;
|
|
18
|
-
};
|
|
19
|
-
compile<This extends SetRequiredKeys<Middleware, 'handler'>>(this: This, context: RequestContext): {
|
|
20
|
-
exec: This["handler"];
|
|
6
|
+
required: TRequired[];
|
|
7
|
+
TCompiled: SetRequiredKeys<Middleware<TRequired, TContext>, 'handler'>;
|
|
8
|
+
handler?: TFunction<unknown, [TContext, (shared?: Partial<HttpRequestContext['shared']>) => unknown]>;
|
|
9
|
+
constructor(name: string, required?: TRequired[]);
|
|
10
|
+
assignHandler(handler: NonNullable<Middleware<TRequired, TContext>['handler']>): this & {
|
|
11
|
+
handler: TFunction<unknown, [TContext, (shared?: Partial<HttpRequestContext["shared"]>) => unknown]>;
|
|
21
12
|
};
|
|
13
|
+
exec<This extends this['TCompiled']>(this: This, context: TContext, next: (result?: Partial<HttpRequestContext['shared']>) => unknown): unknown;
|
|
22
14
|
private check;
|
|
23
|
-
static build(name: string): Middleware
|
|
15
|
+
static build<TRequired extends keyof HttpRequestContext['shared'] = never>(name: string, required?: TRequired[]): Middleware<TRequired, HttpRequestContext<unknown> & {
|
|
16
|
+
shared: SetRequiredKeys<{
|
|
17
|
+
state: Record<string, unknown>;
|
|
18
|
+
seed?: number;
|
|
19
|
+
expectation?: import("../../expectations").Expectation<Pick<HttpRequestContext, "incoming" | "outgoing">>;
|
|
20
|
+
manipulated?: import("../../expectations").IExpectationOperatorContext;
|
|
21
|
+
forwarded?: Pick<HttpRequestContext, "incoming" | "outgoing">;
|
|
22
|
+
history?: import("../history").History;
|
|
23
|
+
}, TRequired>;
|
|
24
|
+
}>;
|
|
24
25
|
}
|
|
25
26
|
//# sourceMappingURL=middleware.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../../../src/server/models/middleware.ts"],"names":[],"mappings":"AAGA,OAAO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G,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,SAAS,EAAE;;;;;;;;;;CAGhH"}
|
|
@@ -7,19 +7,15 @@ exports.Middleware = void 0;
|
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const lodash_1 = __importDefault(require("lodash"));
|
|
9
9
|
class Middleware {
|
|
10
|
-
constructor(name) {
|
|
10
|
+
constructor(name, required = []) {
|
|
11
11
|
this.name = name;
|
|
12
|
-
|
|
13
|
-
requires(required) {
|
|
14
|
-
return Object.assign(this, { required });
|
|
12
|
+
this.required = required;
|
|
15
13
|
}
|
|
16
14
|
assignHandler(handler) {
|
|
17
15
|
return Object.assign(this, { handler });
|
|
18
16
|
}
|
|
19
|
-
|
|
20
|
-
return
|
|
21
|
-
exec: this.check(context).handler,
|
|
22
|
-
};
|
|
17
|
+
exec(context, next) {
|
|
18
|
+
return this.check(context).handler(context, next);
|
|
23
19
|
}
|
|
24
20
|
check(context) {
|
|
25
21
|
const notExistentRequiredKeys = this.required?.filter((key) => !lodash_1.default.has(context.shared, key)) ?? [];
|
|
@@ -28,8 +24,8 @@ class Middleware {
|
|
|
28
24
|
}
|
|
29
25
|
return this;
|
|
30
26
|
}
|
|
31
|
-
static build(name) {
|
|
32
|
-
return new Middleware(path_1.default.parse(name).name);
|
|
27
|
+
static build(name, required) {
|
|
28
|
+
return new Middleware(path_1.default.parse(name).name, required);
|
|
33
29
|
}
|
|
34
30
|
}
|
|
35
31
|
exports.Middleware = Middleware;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware.js","sourceRoot":"","sources":["../../../../src/server/models/middleware.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AACxB,oDAAuB;
|
|
1
|
+
{"version":3,"file":"middleware.js","sourceRoot":"","sources":["../../../../src/server/models/middleware.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AACxB,oDAAuB;AAIvB,MAAa,UAAU;IASrB,YAAmB,IAAY,EAAS,WAAwB,EAAE;QAA/C,SAAI,GAAJ,IAAI,CAAQ;QAAS,aAAQ,GAAR,QAAQ,CAAkB;IAAG,CAAC;IAE/D,aAAa,CAAC,OAAgE;QACnF,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;IAC1C,CAAC;IAEM,IAAI,CAET,OAAiB,EACjB,IAAiE;QAEjE,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACpD,CAAC;IAEO,KAAK,CAAC,OAA2B;QACvC,MAAM,uBAAuB,GAAG,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,gBAAC,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;QAClG,IAAI,uBAAuB,CAAC,MAAM,EAAE,CAAC;YACnC,MAAM,IAAI,KAAK,CAAC,eAAe,IAAI,CAAC,IAAI,eAAe,uBAAuB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC/F,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,CAAC,KAAK,CAA+D,IAAY,EAAE,QAAsB;QAC7G,OAAO,IAAI,UAAU,CAAC,cAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IACzD,CAAC;CACF;AAnCD,gCAmCC"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { HttpRequestContext, WsRequestContext } from '../../models/request-context';
|
|
2
2
|
export * from './types';
|
|
3
|
-
export declare class ReplyService<
|
|
4
|
-
context:
|
|
5
|
-
constructor(context:
|
|
6
|
-
ok(payload:
|
|
3
|
+
export declare class ReplyService<TResponse = unknown> {
|
|
4
|
+
context: HttpRequestContext | WsRequestContext;
|
|
5
|
+
constructor(context: HttpRequestContext | WsRequestContext);
|
|
6
|
+
ok(payload: TResponse): void;
|
|
7
7
|
internalError(message?: string): void;
|
|
8
8
|
validationError(reasons: unknown[]): void;
|
|
9
9
|
notFound(): void;
|
|
10
|
-
static build<T>(context:
|
|
10
|
+
static build<T>(context: HttpRequestContext | WsRequestContext): ReplyService<unknown>;
|
|
11
11
|
}
|
|
12
12
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/server/models/reply-service/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/server/models/reply-service/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAkB,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAMzG,cAAc,SAAS,CAAC;AAExB,qBAAa,YAAY,CAAC,SAAS,GAAG,OAAO;IACxB,OAAO,EAAE,kBAAkB,GAAG,gBAAgB;gBAA9C,OAAO,EAAE,kBAAkB,GAAG,gBAAgB;IAE1D,EAAE,CAAC,OAAO,EAAE,SAAS;IAarB,aAAa,CAAC,OAAO,GAAE,MAA+B;IAatD,eAAe,CAAC,OAAO,EAAE,OAAO,EAAE;IAalC,QAAQ;IAaf,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,OAAO,EAAE,kBAAkB,GAAG,gBAAgB;CAG/D"}
|
|
@@ -26,46 +26,46 @@ class ReplyService {
|
|
|
26
26
|
}
|
|
27
27
|
ok(payload) {
|
|
28
28
|
const data = (0, utils_1.cast)({ status: 'OK', data: payload });
|
|
29
|
-
if (this.context.
|
|
30
|
-
this.context.
|
|
31
|
-
this.context.
|
|
32
|
-
this.context.
|
|
29
|
+
if (this.context.is('http')) {
|
|
30
|
+
this.context.response.writeHead(200, defaultHeaders);
|
|
31
|
+
this.context.response.write(JSON.stringify(data));
|
|
32
|
+
this.context.response.end();
|
|
33
33
|
}
|
|
34
|
-
if (this.context.
|
|
35
|
-
this.context.
|
|
34
|
+
if (this.context.is('ws')) {
|
|
35
|
+
this.context.request.callback(data);
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
internalError(message = 'Something went wrong') {
|
|
39
39
|
const data = (0, utils_1.cast)({ status: 'INTERNAL_ERROR', data: { message } });
|
|
40
|
-
if (this.context.
|
|
41
|
-
this.context.
|
|
42
|
-
this.context.
|
|
43
|
-
this.context.
|
|
40
|
+
if (this.context.is('http')) {
|
|
41
|
+
this.context.response.writeHead(500, defaultHeaders);
|
|
42
|
+
this.context.response.write(JSON.stringify(data));
|
|
43
|
+
this.context.response.end();
|
|
44
44
|
}
|
|
45
|
-
if (this.context.
|
|
46
|
-
this.context.
|
|
45
|
+
if (this.context.is('ws')) {
|
|
46
|
+
this.context.request.callback(data);
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
validationError(reasons) {
|
|
50
50
|
const data = (0, utils_1.cast)({ status: 'VALIDATION_ERROR', data: { reasons } });
|
|
51
|
-
if (this.context.
|
|
52
|
-
this.context.
|
|
53
|
-
this.context.
|
|
54
|
-
this.context.
|
|
51
|
+
if (this.context.is('http')) {
|
|
52
|
+
this.context.response.writeHead(400, defaultHeaders);
|
|
53
|
+
this.context.response.write(JSON.stringify(data));
|
|
54
|
+
this.context.response.end();
|
|
55
55
|
}
|
|
56
|
-
if (this.context.
|
|
57
|
-
this.context.
|
|
56
|
+
if (this.context.is('ws')) {
|
|
57
|
+
this.context.request.callback(data);
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
notFound() {
|
|
61
61
|
const data = (0, utils_1.cast)({ status: 'NOT_FOUND', data: null });
|
|
62
|
-
if (this.context.
|
|
63
|
-
this.context.
|
|
64
|
-
this.context.
|
|
65
|
-
this.context.
|
|
62
|
+
if (this.context.is('http')) {
|
|
63
|
+
this.context.response.writeHead(404, defaultHeaders);
|
|
64
|
+
this.context.response.write(JSON.stringify(data));
|
|
65
|
+
this.context.response.end();
|
|
66
66
|
}
|
|
67
|
-
if (this.context.
|
|
68
|
-
this.context.
|
|
67
|
+
if (this.context.is('ws')) {
|
|
68
|
+
this.context.request.callback(data);
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
static build(context) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/server/models/reply-service/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,0CAAsC;AAItC,MAAM,cAAc,GAAG;IACrB,cAAc,EAAE,kBAAkB;CACnC,CAAC;AAEF,0CAAwB;AAExB,MAAa,YAAY;IACvB,YAAmB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/server/models/reply-service/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,0CAAsC;AAItC,MAAM,cAAc,GAAG;IACrB,cAAc,EAAE,kBAAkB;CACnC,CAAC;AAEF,0CAAwB;AAExB,MAAa,YAAY;IACvB,YAAmB,OAA8C;QAA9C,YAAO,GAAP,OAAO,CAAuC;IAAG,CAAC;IAE9D,EAAE,CAAC,OAAkB;QAC1B,MAAM,IAAI,GAAG,IAAA,YAAI,EAA8B,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;QAEhF,IAAI,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC;YAC5B,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,GAAG,EAAE,cAAc,CAAC,CAAA;YACpD,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;YAClD,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC;QAC9B,CAAC;QACD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AAC,CAAC;YAClD,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC;QAC9B,CAAC;QACD,IAAI,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;YAC1B,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACtC,CAAC;IACH,CAAC;IAEM,QAAQ;QACb,MAAM,IAAI,GAAG,IAAA,YAAI,EAA2B,EAAE,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QAEjF,IAAI,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC;YAC5B,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,GAAG,EAAE,cAAc,CAAC,CAAA;YACpD,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;YAClD,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC;QAC9B,CAAC;QACD,IAAI,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;YAC1B,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACtC,CAAC;IACH,CAAC;IAED,MAAM,CAAC,KAAK,CAAI,OAA8C;QAC5D,OAAO,IAAI,YAAY,CAAC,OAAO,CAAC,CAAC;IACnC,CAAC;CACF;AA1DD,oCA0DC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { IncomingMessage, ServerResponse } from 'http';
|
|
2
|
+
import type { Expectation, IExpectationOperatorContext } from '../../../expectations';
|
|
3
|
+
import type { IRequestContextOutgoing } from './types';
|
|
4
|
+
import type { ServerContext } from '../server-context';
|
|
5
|
+
import type { History } from '../../history';
|
|
6
|
+
import { RequestContext } from './model';
|
|
7
|
+
import { ReplyService } from '../reply-service';
|
|
8
|
+
export declare class HttpRequestContext<TResponse = unknown> extends RequestContext<'http'> {
|
|
9
|
+
server: ServerContext;
|
|
10
|
+
request: IncomingMessage & {
|
|
11
|
+
incomingBodyRaw: string;
|
|
12
|
+
};
|
|
13
|
+
response: ServerResponse;
|
|
14
|
+
TPlain: Pick<HttpRequestContext, 'incoming' | 'outgoing'> & Pick<HttpRequestContext['shared'], 'forwarded' | 'state' | 'seed'>;
|
|
15
|
+
reply: ReplyService<TResponse>;
|
|
16
|
+
incoming: import("./types").IRequestContextIncoming;
|
|
17
|
+
outgoing?: IRequestContextOutgoing;
|
|
18
|
+
shared: {
|
|
19
|
+
state: Record<string, unknown>;
|
|
20
|
+
seed?: number;
|
|
21
|
+
expectation?: Expectation<Pick<HttpRequestContext, 'incoming' | 'outgoing'>>;
|
|
22
|
+
manipulated?: IExpectationOperatorContext;
|
|
23
|
+
forwarded?: Pick<HttpRequestContext, 'incoming' | 'outgoing'>;
|
|
24
|
+
history?: History;
|
|
25
|
+
};
|
|
26
|
+
constructor(server: ServerContext, request: IncomingMessage & {
|
|
27
|
+
incomingBodyRaw: string;
|
|
28
|
+
}, response: ServerResponse);
|
|
29
|
+
share<T extends Partial<HttpRequestContext['shared']>>(shared: T): this & {
|
|
30
|
+
shared: {
|
|
31
|
+
state: Record<string, unknown>;
|
|
32
|
+
seed?: number;
|
|
33
|
+
expectation?: Expectation<Pick<HttpRequestContext, "incoming" | "outgoing">>;
|
|
34
|
+
manipulated?: IExpectationOperatorContext;
|
|
35
|
+
forwarded?: Pick<HttpRequestContext, "incoming" | "outgoing">;
|
|
36
|
+
history?: History;
|
|
37
|
+
} & T;
|
|
38
|
+
};
|
|
39
|
+
toPlain<K extends 'incoming' | 'outgoing' | 'forwarded.incoming' | 'forwarded.outgoing'>(options?: {
|
|
40
|
+
locations?: K[];
|
|
41
|
+
clone?: boolean;
|
|
42
|
+
}): HttpRequestContext<TResponse>['TPlain'];
|
|
43
|
+
static build(server: ServerContext, request: IncomingMessage, response: ServerResponse): Promise<HttpRequestContext<unknown>>;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=http.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../../../src/server/models/request-context/http.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAIvD,OAAO,KAAK,EAAE,WAAW,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AACtF,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AACvD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAG7C,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAIhD,qBAAa,kBAAkB,CAAC,SAAS,GAAG,OAAO,CAAE,SAAQ,cAAc,CAAC,MAAM,CAAC;IAgCxE,MAAM,EAAE,aAAa;IACrB,OAAO,EAAE,eAAe,GAAG;QAAE,eAAe,EAAE,MAAM,CAAA;KAAE;IACtD,QAAQ,EAAE,cAAc;IAjC1B,MAAM,EAAG,IAAI,CAAC,kBAAkB,EAAE,UAAU,GAAG,UAAU,CAAC,GAAG,IAAI,CACtE,kBAAkB,CAAC,QAAQ,CAAC,EAAE,WAAW,GAAG,OAAO,GAAG,MAAM,CAC7D,CAAC;IAEK,KAAK,EAAE,YAAY,CAAC,SAAS,CAAC,CAA4B;IAE1D,QAAQ,4CAAgD;IACxD,QAAQ,CAAC,EAAE,uBAAuB,CAAC;IAEnC,MAAM,EAAE;QACb,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC/B,IAAI,CAAC,EAAE,MAAM,CAAC;QAEd,WAAW,CAAC,EAAE,WAAW,CAAC,IAAI,CAAC,kBAAkB,EAAE,UAAU,GAAG,UAAU,CAAC,CAAC,CAAC;QAC7E,WAAW,CAAC,EAAE,2BAA2B,CAAC;QAE1C,SAAS,CAAC,EAAE,IAAI,CAAC,kBAAkB,EAAE,UAAU,GAAG,UAAU,CAAC,CAAC;QAC9D,OAAO,CAAC,EAAE,OAAO,CAAC;KACnB,CAUC;gBAGO,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE,eAAe,GAAG;QAAE,eAAe,EAAE,MAAM,CAAA;KAAE,EACtD,QAAQ,EAAE,cAAc;IAK1B,KAAK,CAAC,CAAC,SAAS,OAAO,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC;;mBA5B9D,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;mBACvB,MAAM;0BAEC,WAAW,CAAC,IAAI,CAAC,kBAAkB,EAAE,UAAU,GAAG,UAAU,CAAC,CAAC;0BAC9D,2BAA2B;wBAE7B,IAAI,CAAC,kBAAkB,EAAE,UAAU,GAAG,UAAU,CAAC;sBACnD,OAAO;;;IAyBZ,OAAO,CAAC,CAAC,SAAS,UAAU,GAAG,UAAU,GAAG,oBAAoB,GAAG,oBAAoB,EAC5F,OAAO,CAAC,EAAE;QACR,SAAS,CAAC,EAAE,CAAC,EAAE,CAAC;QAChB,KAAK,CAAC,EAAE,OAAO,CAAC;KACjB,GACA,kBAAkB,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC;WAsC7B,KAAK,CAAC,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,cAAc;CAQ7F"}
|
|
@@ -0,0 +1,71 @@
|
|
|
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
|
+
exports.HttpRequestContext = void 0;
|
|
7
|
+
const rfdc_1 = __importDefault(require("rfdc"));
|
|
8
|
+
const utils_1 = require("./utils");
|
|
9
|
+
const model_1 = require("./model");
|
|
10
|
+
const reply_service_1 = require("../reply-service");
|
|
11
|
+
const clone = (0, rfdc_1.default)();
|
|
12
|
+
class HttpRequestContext extends model_1.RequestContext {
|
|
13
|
+
constructor(server, request, response) {
|
|
14
|
+
super('http', server);
|
|
15
|
+
this.server = server;
|
|
16
|
+
this.request = request;
|
|
17
|
+
this.response = response;
|
|
18
|
+
this.reply = reply_service_1.ReplyService.build(this);
|
|
19
|
+
this.incoming = (0, utils_1.extractHttpIncommingParameters)(this.request);
|
|
20
|
+
this.shared = {
|
|
21
|
+
state: {},
|
|
22
|
+
...(this.incoming.headers['x-use-mock-seed'] && {
|
|
23
|
+
seed: Number(this.incoming.headers['x-use-mock-seed']),
|
|
24
|
+
}),
|
|
25
|
+
...(this.incoming.headers['x-use-mock-state'] && {
|
|
26
|
+
state: JSON.parse(Buffer.from(String(this.incoming.headers['x-use-mock-state']), 'base64').toString()),
|
|
27
|
+
}),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
share(shared) {
|
|
31
|
+
return Object.assign(this, { shared: Object.assign(this.shared, shared) });
|
|
32
|
+
}
|
|
33
|
+
toPlain(options) {
|
|
34
|
+
const shouldInclude = {
|
|
35
|
+
incoming: options?.locations?.includes('incoming') ?? true,
|
|
36
|
+
outgoing: (options?.locations?.includes('outgoing') ?? true) && this.outgoing,
|
|
37
|
+
forwarded: {
|
|
38
|
+
incoming: (options?.locations?.includes('forwarded.incoming') ?? true) && this.shared.forwarded?.incoming,
|
|
39
|
+
outgoing: (options?.locations?.includes('forwarded.outgoing') ?? true) && this.shared.forwarded?.outgoing,
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
return {
|
|
43
|
+
state: options?.clone ? clone(this.shared.state) : this.shared.state,
|
|
44
|
+
...(this.shared.seed !== undefined && { seed: this.shared.seed }),
|
|
45
|
+
...(shouldInclude.incoming && {
|
|
46
|
+
incoming: options?.clone ? clone(this.incoming) : this.incoming,
|
|
47
|
+
}),
|
|
48
|
+
...(shouldInclude.outgoing && {
|
|
49
|
+
outgoing: options?.clone ? clone(this.outgoing) : this.outgoing,
|
|
50
|
+
}),
|
|
51
|
+
...((shouldInclude.forwarded.incoming || shouldInclude.forwarded.outgoing) && {
|
|
52
|
+
forwarded: {
|
|
53
|
+
...(shouldInclude.forwarded.incoming && {
|
|
54
|
+
incoming: options?.clone ? clone(this.shared.forwarded.incoming) : this.shared.forwarded.incoming,
|
|
55
|
+
}),
|
|
56
|
+
...(shouldInclude.forwarded.outgoing && {
|
|
57
|
+
outgoing: options?.clone ? clone(this.shared.forwarded.outgoing) : this.shared.forwarded.outgoing,
|
|
58
|
+
}),
|
|
59
|
+
},
|
|
60
|
+
}),
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
static async build(server, request, response) {
|
|
64
|
+
let incomingBodyRaw = '';
|
|
65
|
+
request.on('data', chunk => incomingBodyRaw += chunk);
|
|
66
|
+
await new Promise(resolve => request.on('end', resolve));
|
|
67
|
+
return new HttpRequestContext(server, Object.assign(request, { incomingBodyRaw }), response);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
exports.HttpRequestContext = HttpRequestContext;
|
|
71
|
+
//# sourceMappingURL=http.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../../../../../src/server/models/request-context/http.ts"],"names":[],"mappings":";;;;;;AACA,gDAAwB;AAQxB,mCAAyD;AACzD,mCAAyC;AACzC,oDAAgD;AAEhD,MAAM,KAAK,GAAG,IAAA,cAAI,GAAE,CAAC;AAErB,MAAa,kBAAwC,SAAQ,sBAAsB;IA+BjF,YACS,MAAqB,EACrB,OAAsD,EACtD,QAAwB;QAE/B,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QA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,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,SAAU,CAAC,QAAQ;qBACpG,CAAC;oBAEF,GAAG,CAAC,aAAa,CAAC,SAAS,CAAC,QAAQ,IAAI;wBACtC,QAAQ,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,SAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,SAAU,CAAC,QAAQ;qBACpG,CAAC;iBACH;aACF,CAAC;SACH,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,MAAqB,EAAE,OAAwB,EAAE,QAAwB;QAC1F,IAAI,eAAe,GAAG,EAAE,CAAC;QAEzB,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,IAAI,KAAK,CAAC,CAAC;QACtD,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC;QAEzD,OAAO,IAAI,kBAAkB,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,eAAe,EAAE,CAAC,EAAE,QAAQ,CAAC,CAAC;IAC/F,CAAC;CACF;AA9FD,gDA8FC"}
|
|
@@ -1,59 +1,6 @@
|
|
|
1
|
-
import { IncomingMessage, ServerResponse } from 'http';
|
|
2
|
-
import { IHttpRequestIncommingContext, IRequestPlainContext, IResponsePlainContext, TRequestFlow } from './types';
|
|
3
|
-
import { TRequestMethod, TRequestPayloadType } from '../../../types';
|
|
4
|
-
import type { Expectation } from '../../../expectations';
|
|
5
|
-
import type { HistoryRecord } from '../../history';
|
|
6
|
-
import { ServerContext } from '../server-context';
|
|
7
|
-
import { ReplyService } from '../reply-service';
|
|
8
1
|
export * from './types';
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
body: T['body'];
|
|
14
|
-
bodyRaw: string;
|
|
15
|
-
query: T["query"];
|
|
16
|
-
headers: T["headers"];
|
|
17
|
-
http?: {
|
|
18
|
-
request: IncomingMessage;
|
|
19
|
-
response: ServerResponse;
|
|
20
|
-
};
|
|
21
|
-
ws?: {
|
|
22
|
-
callback: TFunction<void>;
|
|
23
|
-
};
|
|
24
|
-
flow: TRequestFlow;
|
|
25
|
-
reply: ReplyService<U>;
|
|
26
|
-
shared: {
|
|
27
|
-
expectation?: Expectation;
|
|
28
|
-
historyRecord?: HistoryRecord;
|
|
29
|
-
forwarded?: {
|
|
30
|
-
request: IRequestPlainContext;
|
|
31
|
-
response: IResponsePlainContext;
|
|
32
|
-
};
|
|
33
|
-
};
|
|
34
|
-
isFlow<K extends TRequestFlow>(flow: K): this is SetRequiredKeys<this, K>;
|
|
35
|
-
extendWithServerContext<Q extends ServerContext>(context: Q): this & Q;
|
|
36
|
-
extendShared<Q extends Partial<RequestContext<T, U>['shared']>>(sourceShared: Q): this & {
|
|
37
|
-
shared: {
|
|
38
|
-
expectation?: Expectation;
|
|
39
|
-
historyRecord?: HistoryRecord;
|
|
40
|
-
forwarded?: {
|
|
41
|
-
request: IRequestPlainContext;
|
|
42
|
-
response: IResponsePlainContext;
|
|
43
|
-
};
|
|
44
|
-
} & Q;
|
|
45
|
-
};
|
|
46
|
-
assignFlow<K extends TRequestFlow>(flow: K, flowContext: NonNullable<RequestContext<T, U>[K]>): this & {
|
|
47
|
-
[KN in K]: NonNullable<RequestContext<T, U>[K]>;
|
|
48
|
-
} & {
|
|
49
|
-
flow: K;
|
|
50
|
-
};
|
|
51
|
-
assignPayloadType<K extends TRequestPayloadType>(payloadType: K): this & {
|
|
52
|
-
payloadType: K;
|
|
53
|
-
};
|
|
54
|
-
prepareHttpIncommingContext<Q extends SetRequiredKeys<RequestContext, 'http'>>(this: Q): Promise<Q & IRequestPlainContext<IHttpRequestIncommingContext>>;
|
|
55
|
-
assign<T extends Partial<IRequestPlainContext>>(context: T): this & T;
|
|
56
|
-
toPlain(): IRequestPlainContext;
|
|
57
|
-
static build<T extends IHttpRequestIncommingContext = IHttpRequestIncommingContext>(): RequestContext<T, unknown>;
|
|
58
|
-
}
|
|
2
|
+
export * from './utils';
|
|
3
|
+
export * from './model';
|
|
4
|
+
export * from './http';
|
|
5
|
+
export * from './ws';
|
|
59
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/server/models/request-context/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/server/models/request-context/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,MAAM,CAAC"}
|