@stuntman/shared 0.1.5 → 0.1.6
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/dist/index.d.ts +16 -3
- package/package.json +6 -3
- package/src/index.ts +18 -3
package/dist/index.d.ts
CHANGED
|
@@ -36,7 +36,7 @@ export type RemotableFunction<T extends Function> = {
|
|
|
36
36
|
};
|
|
37
37
|
export type SerializedRemotableFunction = {
|
|
38
38
|
localFn: string;
|
|
39
|
-
|
|
39
|
+
localVariables?: string;
|
|
40
40
|
remoteFn: string;
|
|
41
41
|
};
|
|
42
42
|
type WithRemotableFunctions<Type> = {
|
|
@@ -83,20 +83,32 @@ export type RequestManipulationFn = (request: Request) => Request;
|
|
|
83
83
|
export type ResponseManipulationFn = (request: Request, response: Response) => Response;
|
|
84
84
|
export type ResponseGenerationFn = (request: Request) => Response;
|
|
85
85
|
export type Actions = {
|
|
86
|
+
proxyPass: true;
|
|
87
|
+
mockResponse?: undefined;
|
|
88
|
+
modifyRequest?: undefined;
|
|
89
|
+
modifyResponse?: undefined;
|
|
90
|
+
} | {
|
|
86
91
|
mockResponse: Response | ResponseGenerationFn;
|
|
92
|
+
proxyPass?: undefined;
|
|
87
93
|
modifyRequest?: undefined;
|
|
88
94
|
modifyResponse?: undefined;
|
|
89
95
|
} | {
|
|
96
|
+
modifyRequest: RequestManipulationFn;
|
|
97
|
+
modifyResponse?: ResponseManipulationFn;
|
|
98
|
+
proxyPass?: true | undefined;
|
|
90
99
|
mockResponse?: undefined;
|
|
100
|
+
} | {
|
|
91
101
|
modifyRequest?: RequestManipulationFn;
|
|
92
|
-
modifyResponse
|
|
102
|
+
modifyResponse: ResponseManipulationFn;
|
|
103
|
+
proxyPass?: true | undefined;
|
|
104
|
+
mockResponse?: undefined;
|
|
93
105
|
};
|
|
94
106
|
export type Rule = {
|
|
95
107
|
id: string;
|
|
96
108
|
priority?: number;
|
|
97
109
|
matches: RuleMatchFunction;
|
|
98
110
|
labels?: string[];
|
|
99
|
-
actions
|
|
111
|
+
actions: Actions;
|
|
100
112
|
disableAfterUse?: boolean | number;
|
|
101
113
|
removeAfterUse?: boolean | number;
|
|
102
114
|
ttlSeconds: number;
|
|
@@ -141,6 +153,7 @@ export type MockConfig = {
|
|
|
141
153
|
timeout: number;
|
|
142
154
|
externalDns: string[];
|
|
143
155
|
rulesPath: string;
|
|
156
|
+
disableProxy?: boolean;
|
|
144
157
|
};
|
|
145
158
|
export type StorageConfig = {
|
|
146
159
|
limitCount: number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stuntman/shared",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"description": "Stuntman - HTTP proxy / mock shared types and utils",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"repository": {
|
|
@@ -36,7 +36,10 @@
|
|
|
36
36
|
"pino": "8.10.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@
|
|
39
|
+
"@jest/globals": "29.4.3",
|
|
40
|
+
"@types/config": "3.3.0",
|
|
41
|
+
"jest": "29.4.3",
|
|
42
|
+
"typescript": "4.9.5"
|
|
40
43
|
},
|
|
41
44
|
"files": [
|
|
42
45
|
"src/**",
|
|
@@ -46,7 +49,7 @@
|
|
|
46
49
|
"CHANGELOG.md"
|
|
47
50
|
],
|
|
48
51
|
"scripts": {
|
|
49
|
-
"test": "
|
|
52
|
+
"test": "SUPPRESS_NO_CONFIG_WARNING=1 jest",
|
|
50
53
|
"clean": "rm -fr dist",
|
|
51
54
|
"build": "tsc",
|
|
52
55
|
"lint": "prettier --check . && eslint . --ext ts",
|
package/src/index.ts
CHANGED
|
@@ -53,7 +53,7 @@ export type RemotableFunction<T extends Function> = {
|
|
|
53
53
|
|
|
54
54
|
export type SerializedRemotableFunction = {
|
|
55
55
|
localFn: string;
|
|
56
|
-
|
|
56
|
+
localVariables?: string;
|
|
57
57
|
remoteFn: string;
|
|
58
58
|
};
|
|
59
59
|
|
|
@@ -117,15 +117,29 @@ export type ResponseManipulationFn = (request: Request, response: Response) => R
|
|
|
117
117
|
export type ResponseGenerationFn = (request: Request) => Response;
|
|
118
118
|
|
|
119
119
|
export type Actions =
|
|
120
|
+
| {
|
|
121
|
+
proxyPass: true;
|
|
122
|
+
mockResponse?: undefined;
|
|
123
|
+
modifyRequest?: undefined;
|
|
124
|
+
modifyResponse?: undefined;
|
|
125
|
+
}
|
|
120
126
|
| {
|
|
121
127
|
mockResponse: Response | ResponseGenerationFn;
|
|
128
|
+
proxyPass?: undefined;
|
|
122
129
|
modifyRequest?: undefined;
|
|
123
130
|
modifyResponse?: undefined;
|
|
124
131
|
}
|
|
125
132
|
| {
|
|
133
|
+
modifyRequest: RequestManipulationFn;
|
|
134
|
+
modifyResponse?: ResponseManipulationFn;
|
|
135
|
+
proxyPass?: true | undefined;
|
|
126
136
|
mockResponse?: undefined;
|
|
137
|
+
}
|
|
138
|
+
| {
|
|
127
139
|
modifyRequest?: RequestManipulationFn;
|
|
128
|
-
modifyResponse
|
|
140
|
+
modifyResponse: ResponseManipulationFn;
|
|
141
|
+
proxyPass?: true | undefined;
|
|
142
|
+
mockResponse?: undefined;
|
|
129
143
|
};
|
|
130
144
|
|
|
131
145
|
export type Rule = {
|
|
@@ -133,7 +147,7 @@ export type Rule = {
|
|
|
133
147
|
priority?: number;
|
|
134
148
|
matches: RuleMatchFunction; // function for picking request to process
|
|
135
149
|
labels?: string[]; // groupping req/res pairs for searching later e.g. ['exoclick', 'testId123']
|
|
136
|
-
actions
|
|
150
|
+
actions: Actions;
|
|
137
151
|
disableAfterUse?: boolean | number; // disable after rule is triggered n-times
|
|
138
152
|
removeAfterUse?: boolean | number; // disable after rule is triggered n-times
|
|
139
153
|
ttlSeconds: number;
|
|
@@ -186,6 +200,7 @@ export type MockConfig = {
|
|
|
186
200
|
timeout: number;
|
|
187
201
|
externalDns: string[];
|
|
188
202
|
rulesPath: string;
|
|
203
|
+
disableProxy?: boolean;
|
|
189
204
|
};
|
|
190
205
|
|
|
191
206
|
export type StorageConfig = {
|