@n1k1t/mock-server 0.1.2 → 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 +4 -2
- package/lib/src/client/helpers/expectations.d.ts +1 -3
- package/lib/src/client/helpers/expectations.d.ts.map +1 -1
- package/lib/src/client/helpers/expectations.js.map +1 -1
- package/lib/src/client/methods/expectations.create.method.js +1 -1
- package/lib/src/client/methods/expectations.create.method.js.map +1 -1
- package/lib/src/client/methods/expectations.update.method.js +1 -1
- package/lib/src/client/methods/expectations.update.method.js.map +1 -1
- package/lib/src/client/models/client.spec.js +5 -0
- package/lib/src/client/models/client.spec.js.map +1 -1
- package/lib/src/expectations/models/expectation.d.ts +3 -5
- package/lib/src/expectations/models/expectation.d.ts.map +1 -1
- package/lib/src/expectations/models/expectation.js +0 -32
- package/lib/src/expectations/models/expectation.js.map +1 -1
- package/lib/src/expectations/models/operator.d.ts.map +1 -1
- package/lib/src/expectations/models/operator.js +9 -1
- package/lib/src/expectations/models/operator.js.map +1 -1
- package/lib/src/expectations/operators/exec.operator.d.ts.map +1 -1
- package/lib/src/expectations/operators/exec.operator.js +2 -1
- package/lib/src/expectations/operators/exec.operator.js.map +1 -1
- package/lib/src/expectations/operators/has.operator.d.ts.map +1 -1
- package/lib/src/expectations/operators/has.operator.js +8 -5
- package/lib/src/expectations/operators/has.operator.js.map +1 -1
- package/lib/src/expectations/operators/merge.operator.js +2 -2
- package/lib/src/expectations/operators/merge.operator.js.map +1 -1
- package/lib/src/expectations/operators/remove.operator.js +1 -1
- package/lib/src/expectations/operators/remove.operator.js.map +1 -1
- package/lib/src/expectations/operators/set.operator.d.ts.map +1 -1
- package/lib/src/expectations/operators/set.operator.js +6 -8
- package/lib/src/expectations/operators/set.operator.js.map +1 -1
- package/lib/src/expectations/types.d.ts +18 -13
- package/lib/src/expectations/types.d.ts.map +1 -1
- package/lib/src/expectations/types.js +4 -1
- package/lib/src/expectations/types.js.map +1 -1
- package/lib/src/expectations/utils.d.ts +7 -6
- package/lib/src/expectations/utils.d.ts.map +1 -1
- package/lib/src/expectations/utils.js +68 -37
- package/lib/src/expectations/utils.js.map +1 -1
- package/lib/src/server/endpoints/history.get-list.endpoint.d.ts +3 -3
- package/lib/src/server/index.d.ts.map +1 -1
- package/lib/src/server/index.js +15 -7
- package/lib/src/server/index.js.map +1 -1
- package/lib/src/server/middlewares/{handle-expectation-forward.middleware.d.ts → delay.middleware.d.ts} +12 -6
- 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-request.midleware.d.ts → destroy.midleware.d.ts} +12 -6
- package/lib/src/server/middlewares/destroy.midleware.d.ts.map +1 -0
- package/lib/src/server/middlewares/{destroy-request.midleware.js → destroy.midleware.js} +6 -6
- 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/{handle-expectation-forward.middleware.js → forward.middleware.js} +5 -6
- package/lib/src/server/middlewares/forward.middleware.js.map +1 -0
- package/lib/src/server/middlewares/{add-history.middleware.d.ts → history.middleware.d.ts} +9 -3
- package/lib/src/server/middlewares/history.middleware.d.ts.map +1 -0
- package/lib/src/server/middlewares/{add-history.middleware.js → history.middleware.js} +2 -2
- package/lib/src/server/middlewares/history.middleware.js.map +1 -0
- package/lib/src/server/middlewares/index.d.ts +6 -5
- package/lib/src/server/middlewares/index.d.ts.map +1 -1
- package/lib/src/server/middlewares/index.js +13 -11
- package/lib/src/server/middlewares/index.js.map +1 -1
- package/lib/src/server/middlewares/internal-route.middleware.d.ts +8 -2
- package/lib/src/server/middlewares/internal-route.middleware.d.ts.map +1 -1
- package/lib/src/server/middlewares/{handle-expectation-delay.middleware.d.ts → manipulate-expectation.middleware.d.ts} +9 -3
- 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 +8 -2
- package/lib/src/server/middlewares/match-expectation.middleware.d.ts.map +1 -1
- package/lib/src/server/middlewares/match-expectation.middleware.js +4 -4
- package/lib/src/server/middlewares/match-expectation.middleware.js.map +1 -1
- package/lib/src/server/middlewares/{resolve-public.middleware.d.ts → public.middleware.d.ts} +9 -3
- package/lib/src/server/middlewares/public.middleware.d.ts.map +1 -0
- package/lib/src/server/middlewares/{resolve-public.middleware.js → public.middleware.js} +2 -2
- package/lib/src/server/middlewares/public.middleware.js.map +1 -0
- package/lib/src/server/middlewares/reply.middleware.d.ts +8 -2
- package/lib/src/server/middlewares/reply.middleware.d.ts.map +1 -1
- package/lib/src/server/middlewares/reply.middleware.js +4 -4
- package/lib/src/server/middlewares/reply.middleware.js.map +1 -1
- package/lib/src/server/models/middleware.d.ts +4 -1
- package/lib/src/server/models/middleware.d.ts.map +1 -1
- package/lib/src/server/models/request-context/http.d.ts +11 -8
- package/lib/src/server/models/request-context/http.d.ts.map +1 -1
- package/lib/src/server/models/request-context/http.js +31 -11
- package/lib/src/server/models/request-context/http.js.map +1 -1
- package/lib/src/server/models/request-context/types.d.ts +2 -0
- package/lib/src/server/models/request-context/types.d.ts.map +1 -1
- package/lib/test/index.js +36 -0
- package/lib/test/index.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -2
- package/lib/src/server/middlewares/add-history.middleware.d.ts.map +0 -1
- package/lib/src/server/middlewares/add-history.middleware.js.map +0 -1
- package/lib/src/server/middlewares/destroy-request.midleware.d.ts.map +0 -1
- package/lib/src/server/middlewares/destroy-request.midleware.js.map +0 -1
- 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 -17
- package/lib/src/server/middlewares/handle-expectation-delay.middleware.js.map +0 -1
- package/lib/src/server/middlewares/handle-expectation-forward.middleware.d.ts.map +0 -1
- package/lib/src/server/middlewares/handle-expectation-forward.middleware.js.map +0 -1
- 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
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { AxiosProxyConfig } from 'axios';
|
|
2
|
+
import type { faker } from '@faker-js/faker';
|
|
3
|
+
import type dayjs from 'dayjs';
|
|
2
4
|
import type _ from 'lodash';
|
|
3
5
|
import type { HttpRequestContext } from '../server/models';
|
|
4
6
|
import type { TRequestProtocol } from '../types';
|
|
@@ -28,23 +30,26 @@ export declare const LExpectationAttachlessOperator: readonly ["$set", "$remove"
|
|
|
28
30
|
export interface IExpectationMeta {
|
|
29
31
|
executionsCount: number;
|
|
30
32
|
additional: {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
paths?: string[];
|
|
34
|
+
methods?: string[];
|
|
35
|
+
statuses?: number[];
|
|
34
36
|
};
|
|
35
37
|
}
|
|
36
|
-
export interface IExpectationDelay {
|
|
37
|
-
ms: number;
|
|
38
|
-
times?: number;
|
|
39
|
-
}
|
|
40
38
|
export type TExpectationContextLocation = 'request' | 'response';
|
|
41
39
|
export type TExpectationOperatorLocation = ConvertTupleToUnion<typeof LExpectationOperatorLocation>;
|
|
42
|
-
export declare const LExpectationOperatorLocation: readonly ["path", "method", "incoming.body", "incoming.bodyRaw", "incoming.query", "incoming.headers", "outgoing.status", "outgoing.headers", "outgoing.data", "outgoing.dataRaw"];
|
|
40
|
+
export declare const LExpectationOperatorLocation: readonly ["error", "delay", "state", "seed", "path", "method", "incoming.body", "incoming.bodyRaw", "incoming.query", "incoming.headers", "outgoing.status", "outgoing.headers", "outgoing.data", "outgoing.dataRaw"];
|
|
41
|
+
export type TExpectationOperatorObjectLocation = 'state' | 'incoming.body' | 'incoming.headers' | 'incoming.query' | 'outgoing.data' | 'outgoing.headers';
|
|
43
42
|
export type TExpectationOperators = Omit<typeof operators, 'root'>;
|
|
44
|
-
export interface IExpectationOperatorContext extends Pick<HttpRequestContext, 'incoming' | 'outgoing'> {
|
|
43
|
+
export interface IExpectationOperatorContext extends Pick<HttpRequestContext['TPlain'], 'incoming' | 'outgoing'> {
|
|
44
|
+
state: Record<string, unknown>;
|
|
45
|
+
window?: Record<string, unknown>;
|
|
46
|
+
seed?: number;
|
|
47
|
+
delay?: number;
|
|
45
48
|
}
|
|
46
|
-
type ConvertExpectationLocationToContextPath<TLocation extends TExpectationOperatorLocation> = TLocation extends 'path' | 'method' ? {
|
|
49
|
+
type ConvertExpectationLocationToContextPath<TLocation extends TExpectationOperatorLocation> = TLocation extends 'path' | 'method' | 'error' | 'delay' ? {
|
|
47
50
|
path: 'incoming.path';
|
|
51
|
+
delay: 'incoming.delay';
|
|
52
|
+
error: 'incoming.error';
|
|
48
53
|
method: 'incoming.method';
|
|
49
54
|
}[TLocation] : TLocation;
|
|
50
55
|
export type ExtractExpectationContextValueByLocation<TContext extends object, TLocation extends TExpectationOperatorLocation, T = ExtractObjectValueByPath<TContext, ConvertExpectationLocationToContextPath<TLocation>>, U = ExtractObjectValueByPath<IExpectationOperatorContext, ConvertExpectationLocationToContextPath<TLocation>>> = Exclude<T, never> extends never ? Exclude<U, never> extends never ? any : U : T;
|
|
@@ -64,9 +69,7 @@ export interface IExpectationOperatorsSchema<TContext extends PartialDeep<IExpec
|
|
|
64
69
|
$exec?: ExecExpectationOperator<TContext>['TSchema'];
|
|
65
70
|
}
|
|
66
71
|
export interface IExpectationSchema<TContext extends PartialDeep<IExpectationOperatorContext> = {}> {
|
|
67
|
-
|
|
68
|
-
destroy?: 'ECONNABORTED';
|
|
69
|
-
request?: IExpectationOperatorsSchema<TContext, 'path' | 'method' | 'incoming.body' | 'incoming.bodyRaw' | 'incoming.query' | 'incoming.headers'>;
|
|
72
|
+
request?: IExpectationOperatorsSchema<TContext>;
|
|
70
73
|
response?: IExpectationOperatorsSchema<TContext>;
|
|
71
74
|
forward?: {
|
|
72
75
|
url?: string;
|
|
@@ -81,6 +84,8 @@ export interface IExpectationOperatorExecUtils<T extends PartialDeep<IExpectatio
|
|
|
81
84
|
context: IExpectationOperatorContext & T;
|
|
82
85
|
T: <T = any>(payload: unknown) => T;
|
|
83
86
|
_: typeof _;
|
|
87
|
+
d: typeof dayjs;
|
|
88
|
+
faker: typeof faker;
|
|
84
89
|
}
|
|
85
90
|
export {};
|
|
86
91
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/expectations/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAC9C,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAE5B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAEjD,OAAO,KAAK,KAAK,SAAS,MAAM,aAAa,CAAC;AAE9C,OAAO,KAAK,sBAAsB,MAAM,0BAA0B,CAAC;AACnE,OAAO,KAAK,sBAAsB,MAAM,0BAA0B,CAAC;AACnE,OAAO,KAAK,sBAAsB,MAAM,0BAA0B,CAAC;AACnE,OAAO,KAAK,qBAAqB,MAAM,yBAAyB,CAAC;AACjE,OAAO,KAAK,sBAAsB,MAAM,0BAA0B,CAAC;AACnE,OAAO,KAAK,qBAAqB,MAAM,yBAAyB,CAAC;AACjE,OAAO,KAAK,wBAAwB,MAAM,4BAA4B,CAAC;AACvE,OAAO,KAAK,yBAAyB,MAAM,6BAA6B,CAAC;AACzE,OAAO,KAAK,uBAAuB,MAAM,2BAA2B,CAAC;AACrE,OAAO,KAAK,yBAAyB,MAAM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,GAAG,EAAE;IAChG,OAAO,CAAC,EAAE,2BAA2B,CAAC,QAAQ,CAAC,CAAC;IAChD,QAAQ,CAAC,EAAE,2BAA2B,CAAC,QAAQ,CAAC,CAAC;IAEjD,OAAO,CAAC,EAAE;QACR,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,OAAO,CAAC,EAAE,MAAM,CAAC;QAEjB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,KAAK,CAAC,EAAE,gBAAgB,GAAG;YACzB,QAAQ,EAAE,gBAAgB,CAAC;SAC5B,CAAC;KACH,CAAC;CACH;AAED,MAAM,WAAW,6BAA6B,CAAC,CAAC,SAAS,WAAW,CAAC,2BAA2B,CAAC;IAC/F,OAAO,EAAE,2BAA2B,GAAG,CAAC,CAAC;IACzC,CAAC,EAAE,CAAC,CAAC,GAAG,GAAG,EAAE,OAAO,EAAE,OAAO,KAAK,CAAC,CAAC;IAEpC,CAAC,EAAE,OAAO,CAAC,CAAC;IACZ,CAAC,EAAE,OAAO,KAAK,CAAC;IAChB,KAAK,EAAE,OAAO,KAAK,CAAC;CACrB"}
|
|
@@ -8,8 +8,11 @@ exports.LExpectationConditionalOperator = ['$if', '$not', '$and', '$or', '$has']
|
|
|
8
8
|
exports.LExpectationActionalOperator = ['$set', '$remove', '$merge', '$exec'];
|
|
9
9
|
exports.LExpectationAttachlessOperator = [...exports.LExpectationActionalOperator, '$has'];
|
|
10
10
|
;
|
|
11
|
-
;
|
|
12
11
|
exports.LExpectationOperatorLocation = [
|
|
12
|
+
'error',
|
|
13
|
+
'delay',
|
|
14
|
+
'state',
|
|
15
|
+
'seed',
|
|
13
16
|
'path',
|
|
14
17
|
'method',
|
|
15
18
|
'incoming.body',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/expectations/types.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/expectations/types.ts"],"names":[],"mappings":";;;AAsBa,QAAA,gBAAgB,GAAU,CAAC,MAAM,CAAC,CAAC;AAGnC,QAAA,2BAA2B,GAAU,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAGvD,QAAA,uBAAuB,GAAU,CAAC,cAAc,CAAC,CAAC;AAGlD,QAAA,+BAA+B,GAAU,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;AAGhF,QAAA,4BAA4B,GAAU,CAAC,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;AAG7E,QAAA,8BAA8B,GAAU,CAAC,GAAG,oCAA4B,EAAE,MAAM,CAAC,CAAC;AAU9F,CAAC;AAKW,QAAA,4BAA4B,GAAU;IACjD,OAAO;IACP,OAAO;IACP,OAAO;IACP,MAAM;IAEN,MAAM;IACN,QAAQ;IACR,eAAe;IACf,kBAAkB;IAClB,gBAAgB;IAChB,kBAAkB;IAClB,iBAAiB;IACjB,kBAAkB;IAClB,eAAe;IACf,kBAAkB;CACnB,CAAC;AAkBD,CAAC;AA2DD,CAAC;AAeD,CAAC"}
|
|
@@ -4,21 +4,22 @@ type TBaseExtractedContext = {
|
|
|
4
4
|
key: string;
|
|
5
5
|
};
|
|
6
6
|
type TExtractedContext = (TBaseExtractedContext & {
|
|
7
|
-
value
|
|
7
|
+
value?: unknown;
|
|
8
8
|
type: 'object';
|
|
9
9
|
}) | (TBaseExtractedContext & {
|
|
10
|
-
value
|
|
10
|
+
value?: string;
|
|
11
11
|
type: 'string';
|
|
12
12
|
}) | (TBaseExtractedContext & {
|
|
13
|
-
value
|
|
13
|
+
value?: number;
|
|
14
14
|
type: 'number';
|
|
15
15
|
});
|
|
16
|
+
export declare const checkIsLocationInContext: (location: TExpectationOperatorLocation, context: PartialDeep<IExpectationOperatorContext>) => boolean;
|
|
16
17
|
export declare const extractContextByLocation: (location: TExpectationOperatorLocation, context: PartialDeep<IExpectationOperatorContext>) => TExtractedContext | null;
|
|
17
18
|
export declare const introspectExpectationOperatorsSchema: <T extends object = IExpectationSchema<{}>, K extends keyof T = keyof T>(schema: T, handler: (key: K, schema: T, path: string) => unknown, location?: string) => void;
|
|
18
19
|
export declare const extractMetaAdditionalFromExpectationSchema: (schema: IExpectationOperatorsSchema) => {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
paths?: string[];
|
|
21
|
+
methods?: string[];
|
|
22
|
+
statuses?: number[];
|
|
22
23
|
};
|
|
23
24
|
export {};
|
|
24
25
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/expectations/utils.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,kBAAkB,EAIlB,2BAA2B,EAC3B,2BAA2B,EAC3B,4BAA4B,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/expectations/utils.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,kBAAkB,EAIlB,2BAA2B,EAC3B,2BAA2B,EAC3B,4BAA4B,EAC7B,MAAM,SAAS,CAAC;AAEjB,KAAK,qBAAqB,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAC7D,KAAK,iBAAiB,GAClB,CAAC,qBAAqB,GAAG;IAAE,KAAK,CAAC,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,QAAQ,CAAA;CAAE,CAAC,GAC7D,CAAC,qBAAqB,GAAG;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,QAAQ,CAAA;CAAE,CAAC,GAC5D,CAAC,qBAAqB,GAAG;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,QAAQ,CAAA;CAAE,CAAC,CAAC;AAEjE,eAAO,MAAM,wBAAwB,aACzB,4BAA4B,WAC7B,WAAW,CAAC,2BAA2B,CAAC,KAChD,OASF,CAAA;AAED,eAAO,MAAM,wBAAwB,aACzB,4BAA4B,WAC7B,WAAW,CAAC,2BAA2B,CAAC,KAChD,iBAAiB,GAAG,IAsGtB,CAAA;AAED,eAAO,MAAM,oCAAoC,GAAI,CAAC,SAAS,MAAM,2BAAuB,CAAC,SAAS,MAAM,CAAC,oBACnG,CAAC,WACA,CAAC,GAAG,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,KAAK,OAAO,aAC3C,MAAM,KACf,IAUF,CAAA;AAED,eAAO,MAAM,0CAA0C,WAAY,2BAA2B;;;;CA+B7F,CAAA"}
|
|
@@ -3,73 +3,104 @@ 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.extractMetaAdditionalFromExpectationSchema = exports.introspectExpectationOperatorsSchema = exports.extractContextByLocation = void 0;
|
|
6
|
+
exports.extractMetaAdditionalFromExpectationSchema = exports.introspectExpectationOperatorsSchema = exports.extractContextByLocation = exports.checkIsLocationInContext = void 0;
|
|
7
7
|
const lodash_1 = __importDefault(require("lodash"));
|
|
8
8
|
const types_1 = require("./types");
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
const checkIsLocationInContext = (location, context) => {
|
|
10
|
+
switch (location) {
|
|
11
|
+
case 'delay':
|
|
12
|
+
case 'error':
|
|
13
|
+
case 'method':
|
|
14
|
+
case 'path': return lodash_1.default.has(context.incoming, location);
|
|
15
|
+
default: return lodash_1.default.has(context, location);
|
|
12
16
|
}
|
|
17
|
+
};
|
|
18
|
+
exports.checkIsLocationInContext = checkIsLocationInContext;
|
|
19
|
+
const extractContextByLocation = (location, context) => {
|
|
13
20
|
switch (location) {
|
|
14
21
|
case 'path': return {
|
|
15
|
-
key: 'path',
|
|
22
|
+
key: 'incoming.path',
|
|
16
23
|
type: 'string',
|
|
17
|
-
parent: context
|
|
18
|
-
value: context.incoming
|
|
24
|
+
parent: context,
|
|
25
|
+
value: context.incoming?.path,
|
|
19
26
|
};
|
|
20
27
|
case 'method': return {
|
|
21
|
-
key: 'method',
|
|
28
|
+
key: 'incoming.method',
|
|
22
29
|
type: 'string',
|
|
23
|
-
parent: context
|
|
24
|
-
value: context.incoming
|
|
30
|
+
parent: context,
|
|
31
|
+
value: context.incoming?.method,
|
|
25
32
|
};
|
|
26
33
|
case 'incoming.body': return {
|
|
27
|
-
key: 'body',
|
|
34
|
+
key: 'incoming.body',
|
|
28
35
|
type: 'object',
|
|
29
|
-
parent: context
|
|
30
|
-
value: context.incoming
|
|
36
|
+
parent: context,
|
|
37
|
+
value: context.incoming?.body,
|
|
31
38
|
};
|
|
32
39
|
case 'incoming.bodyRaw': return {
|
|
33
|
-
key: 'bodyRaw',
|
|
40
|
+
key: 'incoming.bodyRaw',
|
|
34
41
|
type: 'string',
|
|
35
|
-
parent: context
|
|
36
|
-
value: context.incoming
|
|
42
|
+
parent: context,
|
|
43
|
+
value: context.incoming?.bodyRaw,
|
|
37
44
|
};
|
|
38
45
|
case 'incoming.query': return {
|
|
39
|
-
key: 'query',
|
|
46
|
+
key: 'incoming.query',
|
|
40
47
|
type: 'object',
|
|
41
|
-
parent: context
|
|
42
|
-
value: context.incoming
|
|
48
|
+
parent: context,
|
|
49
|
+
value: context.incoming?.query,
|
|
43
50
|
};
|
|
44
51
|
case 'incoming.headers': return {
|
|
45
|
-
key: 'headers',
|
|
52
|
+
key: 'incoming.headers',
|
|
46
53
|
type: 'object',
|
|
47
|
-
parent: context
|
|
48
|
-
value: context.incoming
|
|
54
|
+
parent: context,
|
|
55
|
+
value: context.incoming?.headers,
|
|
49
56
|
};
|
|
50
57
|
case 'outgoing.data': return {
|
|
51
|
-
key: 'data',
|
|
58
|
+
key: 'outgoing.data',
|
|
52
59
|
type: 'object',
|
|
53
|
-
parent: context
|
|
54
|
-
value: context.outgoing
|
|
60
|
+
parent: context,
|
|
61
|
+
value: context.outgoing?.data,
|
|
55
62
|
};
|
|
56
63
|
case 'outgoing.dataRaw': return {
|
|
57
|
-
key: 'dataRaw',
|
|
64
|
+
key: 'outgoing.dataRaw',
|
|
58
65
|
type: 'string',
|
|
59
|
-
parent: context
|
|
60
|
-
value: context.outgoing
|
|
66
|
+
parent: context,
|
|
67
|
+
value: context.outgoing?.dataRaw,
|
|
61
68
|
};
|
|
62
69
|
case 'outgoing.headers': return {
|
|
63
|
-
key: 'headers',
|
|
70
|
+
key: 'outgoing.headers',
|
|
64
71
|
type: 'object',
|
|
65
|
-
parent: context
|
|
66
|
-
value: context.outgoing
|
|
72
|
+
parent: context,
|
|
73
|
+
value: context.outgoing?.headers,
|
|
67
74
|
};
|
|
68
75
|
case 'outgoing.status': return {
|
|
69
|
-
key: 'status',
|
|
76
|
+
key: 'outgoing.status',
|
|
77
|
+
type: 'number',
|
|
78
|
+
parent: context,
|
|
79
|
+
value: context.outgoing?.status,
|
|
80
|
+
};
|
|
81
|
+
case 'delay': return {
|
|
82
|
+
key: 'incoming.delay',
|
|
70
83
|
type: 'number',
|
|
71
|
-
parent: context
|
|
72
|
-
value: context.
|
|
84
|
+
parent: context,
|
|
85
|
+
value: context.incoming?.delay,
|
|
86
|
+
};
|
|
87
|
+
case 'error': return {
|
|
88
|
+
key: 'incoming.error',
|
|
89
|
+
type: 'string',
|
|
90
|
+
parent: context,
|
|
91
|
+
value: context.incoming?.error,
|
|
92
|
+
};
|
|
93
|
+
case 'seed': return {
|
|
94
|
+
key: 'seed',
|
|
95
|
+
type: 'number',
|
|
96
|
+
parent: context,
|
|
97
|
+
value: context.seed,
|
|
98
|
+
};
|
|
99
|
+
case 'state': return {
|
|
100
|
+
key: 'state',
|
|
101
|
+
type: 'object',
|
|
102
|
+
parent: context,
|
|
103
|
+
value: context.state,
|
|
73
104
|
};
|
|
74
105
|
default: return null;
|
|
75
106
|
}
|
|
@@ -89,7 +120,7 @@ const extractMetaAdditionalFromExpectationSchema = (schema) => {
|
|
|
89
120
|
const acc = {};
|
|
90
121
|
(0, exports.introspectExpectationOperatorsSchema)(schema, (key, segment) => {
|
|
91
122
|
if (key === '$set' && segment[key]?.$location === 'outgoing.status') {
|
|
92
|
-
acc.
|
|
123
|
+
acc.statuses = (acc.statuses ?? []).concat([segment[key]?.$value].filter(Boolean));
|
|
93
124
|
}
|
|
94
125
|
if (key === '$has' && ['method', 'path'].includes(segment[key]?.$location ?? '')) {
|
|
95
126
|
const valuePredicate = segment[key]?.$value
|
|
@@ -102,12 +133,12 @@ const extractMetaAdditionalFromExpectationSchema = (schema) => {
|
|
|
102
133
|
switch (segment[key]?.$location) {
|
|
103
134
|
case 'method':
|
|
104
135
|
{
|
|
105
|
-
acc.
|
|
136
|
+
acc.methods = (acc.methods ?? []).concat(lodash_1.default.flatten([valuePredicate]).map(String));
|
|
106
137
|
break;
|
|
107
138
|
}
|
|
108
139
|
;
|
|
109
140
|
case 'path': {
|
|
110
|
-
acc.
|
|
141
|
+
acc.paths = (acc.paths ?? []).concat(lodash_1.default.flatten([valuePredicate]).map(String));
|
|
111
142
|
break;
|
|
112
143
|
}
|
|
113
144
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/expectations/utils.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAuB;AAEvB,
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/expectations/utils.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAuB;AAEvB,mCAQiB;AAQV,MAAM,wBAAwB,GAAG,CACtC,QAAsC,EACtC,OAAiD,EACxC,EAAE;IACX,QAAO,QAAQ,EAAE,CAAC;QAChB,KAAK,OAAO,CAAC;QACb,KAAK,OAAO,CAAC;QACb,KAAK,QAAQ,CAAC;QACd,KAAK,MAAM,CAAC,CAAC,OAAO,gBAAC,CAAC,GAAG,CAAC,OAAO,CAAC,QAAQ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CAAC,CAAC,CAAC;IAEH,OAAO,GAAG,CAAC;AACb,CAAC,CAAA;AA/BY,QAAA,0CAA0C,8CA+BtD"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { History } from '../history';
|
|
2
2
|
import { Endpoint } from '../models';
|
|
3
|
-
declare const _default: Endpoint<(Pick<History, "
|
|
3
|
+
declare const _default: Endpoint<(Pick<History, "error" | "request" | "id" | "meta" | "forwaded"> & {
|
|
4
4
|
expectation?: import("../../expectations").Expectation<any>["TPlain"];
|
|
5
5
|
})[], {}> & {
|
|
6
6
|
http: {
|
|
@@ -12,9 +12,9 @@ declare const _default: Endpoint<(Pick<History, "request" | "id" | "meta" | "for
|
|
|
12
12
|
readonly path: "history:get";
|
|
13
13
|
};
|
|
14
14
|
} & {
|
|
15
|
-
handler: ({ reply, server }: (import("../models").HttpRequestContext<(Pick<History, "
|
|
15
|
+
handler: ({ reply, server }: (import("../models").HttpRequestContext<(Pick<History, "error" | "request" | "id" | "meta" | "forwaded"> & {
|
|
16
16
|
expectation?: import("../../expectations").Expectation<any>["TPlain"];
|
|
17
|
-
})[]> | import("../models").WsRequestContext<(Pick<History, "
|
|
17
|
+
})[]> | import("../models").WsRequestContext<(Pick<History, "error" | "request" | "id" | "meta" | "forwaded"> & {
|
|
18
18
|
expectation?: import("../../expectations").Expectation<any>["TPlain"];
|
|
19
19
|
})[]>) & {
|
|
20
20
|
incoming: OmitPartial<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/server/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAkC,aAAa,EAAoB,MAAM,UAAU,CAAC;AAK3F,cAAc,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/server/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAkC,aAAa,EAAoB,MAAM,UAAU,CAAC;AAK3F,cAAc,SAAS,CAAC;AA4BxB,qBAAa,UAAU;IAIF,OAAO,EAAE;QAC1B,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;KACd;IANM,SAAS,SAAsD;IAC/D,OAAO,gBAAyB;gBAEpB,OAAO,EAAE;QAC1B,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;KACd;IAED,IAAI,MAAM,8BAET;WAEY,KAAK,CAAC,OAAO,EAAE,UAAU,CAAC,SAAS,CAAC;CA+BlD"}
|
package/lib/src/server/index.js
CHANGED
|
@@ -38,17 +38,25 @@ const router_1 = require("./router");
|
|
|
38
38
|
const middlewares = __importStar(require("./middlewares"));
|
|
39
39
|
__exportStar(require("./proxy"), exports);
|
|
40
40
|
const middlewaresToUse = [
|
|
41
|
-
middlewares.
|
|
41
|
+
middlewares.publicMiddleware,
|
|
42
42
|
middlewares.handleInternalMiddleware,
|
|
43
43
|
middlewares.matchExpectationMiddleware,
|
|
44
|
-
middlewares.
|
|
45
|
-
middlewares.
|
|
46
|
-
middlewares.
|
|
47
|
-
middlewares.
|
|
44
|
+
middlewares.manipulateExpectationMiddleware,
|
|
45
|
+
middlewares.historyMiddleware,
|
|
46
|
+
middlewares.delayMiddleware,
|
|
47
|
+
middlewares.destroyMiddleware,
|
|
48
|
+
middlewares.forwardMiddleware,
|
|
48
49
|
middlewares.replyMiddleware,
|
|
49
50
|
];
|
|
50
|
-
const
|
|
51
|
-
|
|
51
|
+
const handleHttpRequest = async (context) => {
|
|
52
|
+
for (const middleware of middlewaresToUse) {
|
|
53
|
+
if (!middleware.required.every((key) => key in context.shared)) {
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
await new Promise((resolve) => middleware.exec(context, (result) => resolve(context.share(result ?? {}))));
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
const httpRequestListener = (context) => async (request, response) => handleHttpRequest(await models_1.HttpRequestContext.build(context, request, response));
|
|
52
60
|
class MockServer {
|
|
53
61
|
constructor(options) {
|
|
54
62
|
this.options = options;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/server/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAAqE;AACrE,yCAAmC;AACnC,oDAAuB;AAEvB,qCAA2F;AAC3F,qCAAkC;AAElC,2DAA6C;AAE7C,0CAAwB;AAExB,MAAM,gBAAgB,GAAwC;IAC5D,WAAW,CAAC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/server/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAAqE;AACrE,yCAAmC;AACnC,oDAAuB;AAEvB,qCAA2F;AAC3F,qCAAkC;AAElC,2DAA6C;AAE7C,0CAAwB;AAExB,MAAM,gBAAgB,GAAwC;IAC5D,WAAW,CAAC,gBAAgB;IAC5B,WAAW,CAAC,wBAAwB;IACpC,WAAW,CAAC,0BAA0B;IACtC,WAAW,CAAC,+BAA+B;IAC3C,WAAW,CAAC,iBAAiB;IAC7B,WAAW,CAAC,eAAe;IAC3B,WAAW,CAAC,iBAAiB;IAC7B,WAAW,CAAC,iBAAiB;IAC7B,WAAW,CAAC,eAAe;CAC5B,CAAC;AAEF,MAAM,iBAAiB,GAAG,KAAK,EAAE,OAA2B,EAAE,EAAE;IAC9D,KAAK,MAAM,UAAU,IAAI,gBAAgB,EAAE,CAAC;QAC1C,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YAC/D,SAAS;QACX,CAAC;QAED,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,I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CAAC,IAAI,CAAC,IAAI,CAAC;YACtB,IAAI,EAAE,gBAAC,CAAC,KAAK,CAAC,IAAI,CAAC;SACpB,CAAC,CACL,CAAC,CACH,CACF,CAAC;QAEF,MAAM,CAAC,OAAO,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC;QAEpC,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE,CAClC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,GAAG,EAAE;YAC3C,OAAO,CAAC,GAAG,CAAC,0BAA0B,MAAM,CAAC,SAAS,GAAG,CAAC,CAAC;YAC3D,OAAO,CAAC,GAAG,CAAC,wBAAwB,MAAM,CAAC,SAAS,aAAa,CAAC,CAAC;YAEnE,OAAO,EAAE,CAAC;QACZ,CAAC,CAAC,CACH,CAAC;QAEF,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AA5CD,gCA4CC"}
|
|
@@ -1,18 +1,24 @@
|
|
|
1
1
|
import { Middleware } from '../models';
|
|
2
|
-
declare const _default: Middleware<"
|
|
2
|
+
declare const _default: Middleware<"manipulated", import("../models").HttpRequestContext<unknown> & {
|
|
3
3
|
shared: SetRequiredKeys<{
|
|
4
|
+
state: Record<string, unknown>;
|
|
5
|
+
seed?: number;
|
|
4
6
|
expectation?: import("../../expectations").Expectation<Pick<import("../models").HttpRequestContext, "incoming" | "outgoing">>;
|
|
5
|
-
|
|
7
|
+
manipulated?: import("../../expectations").IExpectationOperatorContext;
|
|
6
8
|
forwarded?: Pick<import("../models").HttpRequestContext, "incoming" | "outgoing">;
|
|
7
|
-
|
|
9
|
+
history?: import("../history").History;
|
|
10
|
+
}, "manipulated">;
|
|
8
11
|
}> & {
|
|
9
12
|
handler: TFunction<unknown, [import("../models").HttpRequestContext<unknown> & {
|
|
10
13
|
shared: SetRequiredKeys<{
|
|
14
|
+
state: Record<string, unknown>;
|
|
15
|
+
seed?: number;
|
|
11
16
|
expectation?: import("../../expectations").Expectation<Pick<import("../models").HttpRequestContext, "incoming" | "outgoing">>;
|
|
12
|
-
|
|
17
|
+
manipulated?: import("../../expectations").IExpectationOperatorContext;
|
|
13
18
|
forwarded?: Pick<import("../models").HttpRequestContext, "incoming" | "outgoing">;
|
|
14
|
-
|
|
19
|
+
history?: import("../history").History;
|
|
20
|
+
}, "manipulated">;
|
|
15
21
|
}, (shared?: Partial<import("../models").HttpRequestContext["shared"]>) => unknown]>;
|
|
16
22
|
};
|
|
17
23
|
export default _default;
|
|
18
|
-
//# sourceMappingURL=
|
|
24
|
+
//# sourceMappingURL=delay.middleware.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delay.middleware.d.ts","sourceRoot":"","sources":["../../../../src/server/middlewares/delay.middleware.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;;;;;;;;;;;;;;;;;;;;;;AAGvC,wBAQK"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const models_1 = require("../models");
|
|
4
|
+
const utils_1 = require("../../utils");
|
|
5
|
+
exports.default = models_1.Middleware
|
|
6
|
+
.build(__filename, ['manipulated'])
|
|
7
|
+
.assignHandler(async (context, next) => {
|
|
8
|
+
if (context.shared.manipulated.incoming.delay) {
|
|
9
|
+
await (0, utils_1.wait)(context.shared.manipulated.incoming.delay);
|
|
10
|
+
}
|
|
11
|
+
next();
|
|
12
|
+
});
|
|
13
|
+
//# sourceMappingURL=delay.middleware.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delay.middleware.js","sourceRoot":"","sources":["../../../../src/server/middlewares/delay.middleware.ts"],"names":[],"mappings":";;AAEA,sCAAuC;AACvC,uCAAmC;AAEnC,kBAAe,mBAAU;KACtB,KAAK,CAAC,UAAU,EAAE,CAAC,aAAa,CAAC,CAAC;KAClC,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;IACrC,IAAI,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;QAC9C,MAAM,IAAA,YAAI,EAAC,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACxD,CAAC;IAED,IAAI,EAAE,CAAC;AACT,CAAC,CAAC,CAAC"}
|
package/lib/src/server/middlewares/{destroy-request.midleware.d.ts → destroy.midleware.d.ts}
RENAMED
|
@@ -1,18 +1,24 @@
|
|
|
1
1
|
import { Middleware } from '../models';
|
|
2
|
-
declare const _default: Middleware<"
|
|
2
|
+
declare const _default: Middleware<"manipulated" | "history", import("../models").HttpRequestContext<unknown> & {
|
|
3
3
|
shared: SetRequiredKeys<{
|
|
4
|
+
state: Record<string, unknown>;
|
|
5
|
+
seed?: number;
|
|
4
6
|
expectation?: import("../../expectations").Expectation<Pick<import("../models").HttpRequestContext, "incoming" | "outgoing">>;
|
|
5
|
-
|
|
7
|
+
manipulated?: import("../../expectations").IExpectationOperatorContext;
|
|
6
8
|
forwarded?: Pick<import("../models").HttpRequestContext, "incoming" | "outgoing">;
|
|
7
|
-
|
|
9
|
+
history?: import("../history").History;
|
|
10
|
+
}, "manipulated" | "history">;
|
|
8
11
|
}> & {
|
|
9
12
|
handler: TFunction<unknown, [import("../models").HttpRequestContext<unknown> & {
|
|
10
13
|
shared: SetRequiredKeys<{
|
|
14
|
+
state: Record<string, unknown>;
|
|
15
|
+
seed?: number;
|
|
11
16
|
expectation?: import("../../expectations").Expectation<Pick<import("../models").HttpRequestContext, "incoming" | "outgoing">>;
|
|
12
|
-
|
|
17
|
+
manipulated?: import("../../expectations").IExpectationOperatorContext;
|
|
13
18
|
forwarded?: Pick<import("../models").HttpRequestContext, "incoming" | "outgoing">;
|
|
14
|
-
|
|
19
|
+
history?: import("../history").History;
|
|
20
|
+
}, "manipulated" | "history">;
|
|
15
21
|
}, (shared?: Partial<import("../models").HttpRequestContext["shared"]>) => unknown]>;
|
|
16
22
|
};
|
|
17
23
|
export default _default;
|
|
18
|
-
//# sourceMappingURL=destroy
|
|
24
|
+
//# sourceMappingURL=destroy.midleware.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"destroy.midleware.d.ts","sourceRoot":"","sources":["../../../../src/server/middlewares/destroy.midleware.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;;;;;;;;;;;;;;;;;;;;;;AAEvC,wBAaK"}
|
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const models_1 = require("../models");
|
|
4
4
|
exports.default = models_1.Middleware
|
|
5
|
-
.build(__filename, ['
|
|
5
|
+
.build(__filename, ['manipulated', 'history'])
|
|
6
6
|
.assignHandler((context, next) => {
|
|
7
|
-
if (context.shared.
|
|
7
|
+
if (context.shared.manipulated.incoming.error) {
|
|
8
8
|
context.shared.history
|
|
9
|
-
.assign({ error: { code: context.shared.
|
|
9
|
+
.assign({ error: { code: context.shared.manipulated.incoming.error, isManual: true } })
|
|
10
10
|
.changeState('finished');
|
|
11
|
-
context.server.exchange.ws.publish('history:updated', context.shared.history);
|
|
12
|
-
return context.response.destroy(new Error(context.shared.
|
|
11
|
+
context.server.exchange.ws.publish('history:updated', context.shared.history.toPlain());
|
|
12
|
+
return context.response.destroy(new Error(context.shared.manipulated.incoming.error));
|
|
13
13
|
}
|
|
14
14
|
next();
|
|
15
15
|
});
|
|
16
|
-
//# sourceMappingURL=destroy
|
|
16
|
+
//# sourceMappingURL=destroy.midleware.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"destroy.midleware.js","sourceRoot":"","sources":["../../../../src/server/middlewares/destroy.midleware.ts"],"names":[],"mappings":";;AACA,sCAAuC;AAEvC,kBAAe,mBAAU;KACtB,KAAK,CAAC,UAAU,EAAE,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC;KAC7C,aAAa,CAAC,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE;IAC/B,IAAI,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;QAC9C,OAAO,CAAC,MAAM,CAAC,OAAO;aACnB,MAAM,CAAC,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,CAAC;aACtF,WAAW,CAAC,UAAU,CAAC,CAAC;QAE3B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,OAAO,CAAC,iBAAiB,EAAE,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;QACxF,OAAO,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;IACxF,CAAC;IAED,IAAI,EAAE,CAAC;AACT,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Middleware } from '../models';
|
|
2
|
+
declare const _default: Middleware<"expectation" | "manipulated" | "history", import("../models").HttpRequestContext<unknown> & {
|
|
3
|
+
shared: SetRequiredKeys<{
|
|
4
|
+
state: Record<string, unknown>;
|
|
5
|
+
seed?: number;
|
|
6
|
+
expectation?: import("../../expectations").Expectation<Pick<import("../models").HttpRequestContext, "incoming" | "outgoing">>;
|
|
7
|
+
manipulated?: import("../../expectations").IExpectationOperatorContext;
|
|
8
|
+
forwarded?: Pick<import("../models").HttpRequestContext, "incoming" | "outgoing">;
|
|
9
|
+
history?: import("../history").History;
|
|
10
|
+
}, "expectation" | "manipulated" | "history">;
|
|
11
|
+
}> & {
|
|
12
|
+
handler: TFunction<unknown, [import("../models").HttpRequestContext<unknown> & {
|
|
13
|
+
shared: SetRequiredKeys<{
|
|
14
|
+
state: Record<string, unknown>;
|
|
15
|
+
seed?: number;
|
|
16
|
+
expectation?: import("../../expectations").Expectation<Pick<import("../models").HttpRequestContext, "incoming" | "outgoing">>;
|
|
17
|
+
manipulated?: import("../../expectations").IExpectationOperatorContext;
|
|
18
|
+
forwarded?: Pick<import("../models").HttpRequestContext, "incoming" | "outgoing">;
|
|
19
|
+
history?: import("../history").History;
|
|
20
|
+
}, "expectation" | "manipulated" | "history">;
|
|
21
|
+
}, (shared?: Partial<import("../models").HttpRequestContext["shared"]>) => unknown]>;
|
|
22
|
+
};
|
|
23
|
+
export default _default;
|
|
24
|
+
//# sourceMappingURL=forward.middleware.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"forward.middleware.d.ts","sourceRoot":"","sources":["../../../../src/server/middlewares/forward.middleware.ts"],"names":[],"mappings":"AAIA,OAAO,EAAsB,UAAU,EAAkC,MAAM,WAAW,CAAC;;;;;;;;;;;;;;;;;;;;;;AAE3F,wBAiFK"}
|
|
@@ -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'])
|
|
11
|
+
.build(__filename, ['expectation', 'manipulated', 'history'])
|
|
12
12
|
.assignHandler(async (context, next) => {
|
|
13
13
|
if (!context.shared.expectation.forward) {
|
|
14
14
|
return next();
|
|
15
15
|
}
|
|
16
16
|
const { url, baseUrl, timeout, proxy } = context.shared.expectation.forward;
|
|
17
|
-
const forwarded = context.
|
|
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,7 +30,7 @@ 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);
|
|
33
|
+
context.server.exchange.ws.publish('history:updated', history.toPlain());
|
|
35
34
|
const response = await (0, axios_1.default)({
|
|
36
35
|
timeout: timeout ?? 1000 * 30,
|
|
37
36
|
method: forwarded.incoming.method,
|
|
@@ -50,7 +49,7 @@ exports.default = models_1.Middleware
|
|
|
50
49
|
history
|
|
51
50
|
.assign({ error: lodash_1.default.pick(error, ['message', 'code']) })
|
|
52
51
|
.changeState('finished');
|
|
53
|
-
context.server.exchange.ws.publish('history:updated', history);
|
|
52
|
+
context.server.exchange.ws.publish('history:updated', history.toPlain());
|
|
54
53
|
context.reply.internalError(error.message);
|
|
55
54
|
throw error;
|
|
56
55
|
}
|
|
@@ -69,4 +68,4 @@ exports.default = models_1.Middleware
|
|
|
69
68
|
context.server.exchange.ws.publish('history:updated', history.toPlain());
|
|
70
69
|
return next({ forwarded });
|
|
71
70
|
});
|
|
72
|
-
//# sourceMappingURL=
|
|
71
|
+
//# sourceMappingURL=forward.middleware.js.map
|