@stuntman/client 0.1.7 → 0.1.9
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/README.md +8 -0
- package/dist/apiClient.d.ts +16 -0
- package/dist/apiClient.d.ts.map +1 -0
- package/dist/apiClient.js +169 -0
- package/dist/apiClient.js.map +1 -0
- package/dist/clientError.d.ts +19 -0
- package/dist/clientError.d.ts.map +1 -0
- package/dist/clientError.js +25 -0
- package/dist/clientError.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/ruleBuilder.d.ts +80 -0
- package/dist/ruleBuilder.d.ts.map +1 -0
- package/dist/ruleBuilder.js +535 -0
- package/dist/ruleBuilder.js.map +1 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Stuntman API client
|
|
2
2
|
|
|
3
|
+
[][npmjs]
|
|
4
|
+
[][build]
|
|
5
|
+
[][coverage]
|
|
6
|
+
|
|
7
|
+
[npmjs]: https://www.npmjs.com/package/@stuntman/client
|
|
8
|
+
[build]: https://github.com/andrzej-woof/stuntman/actions/workflows/ci.yaml
|
|
9
|
+
[coverage]: https://coveralls.io/github/andrzej-woof/stuntman
|
|
10
|
+
|
|
3
11
|
Client for [Stuntman](https://github.com/andrzej-woof/stuntman) proxy/mock server API
|
|
4
12
|
|
|
5
13
|
## Example usage
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type * as Stuntman from '@stuntman/shared';
|
|
2
|
+
export declare class Client {
|
|
3
|
+
private options;
|
|
4
|
+
private get baseUrl();
|
|
5
|
+
constructor(options?: Partial<Stuntman.ClientConfig>);
|
|
6
|
+
private fetch;
|
|
7
|
+
getRules(): Promise<Stuntman.LiveRule[]>;
|
|
8
|
+
getRule(id: string): Promise<Stuntman.LiveRule>;
|
|
9
|
+
disableRule(id: string): Promise<void>;
|
|
10
|
+
enableRule(id: string): Promise<void>;
|
|
11
|
+
removeRule(id: string): Promise<void>;
|
|
12
|
+
addRule(rule: Stuntman.SerializableRule): Promise<Stuntman.Rule>;
|
|
13
|
+
getTraffic(rule: Stuntman.Rule): Promise<Stuntman.LogEntry[]>;
|
|
14
|
+
getTraffic(ruleIdOrLabel: string): Promise<Stuntman.LogEntry[]>;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=apiClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apiClient.d.ts","sourceRoot":"","sources":["../src/apiClient.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,QAAQ,MAAM,kBAAkB,CAAC;AAqFlD,qBAAa,MAAM;IAGf,OAAO,CAAC,OAAO,CAAwB;IAEvC,OAAO,KAAK,OAAO,GAElB;gBAEW,OAAO,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC;YAQtC,KAAK;IAiCb,QAAQ,IAAI,OAAO,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC;IAKxC,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC;IAK/C,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAItC,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIrC,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIrC,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,gBAAgB,GAAG,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC;IAWhE,UAAU,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,GAAG,OAAO,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC;IAC7D,UAAU,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC;CAMxE"}
|
|
@@ -0,0 +1,169 @@
|
|
|
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.Client = void 0;
|
|
7
|
+
const serialize_javascript_1 = __importDefault(require("serialize-javascript"));
|
|
8
|
+
const clientError_1 = require("./clientError");
|
|
9
|
+
const shared_1 = require("@stuntman/shared");
|
|
10
|
+
const SERIALIZE_JAVASCRIPT_OPTIONS = {
|
|
11
|
+
unsafe: true,
|
|
12
|
+
ignoreFunction: true,
|
|
13
|
+
};
|
|
14
|
+
const getFunctionParams = (func) => {
|
|
15
|
+
const funstr = func.toString();
|
|
16
|
+
const params = funstr.slice(funstr.indexOf('(') + 1, funstr.indexOf(')')).match(/([^\s,]+)/g) || new Array();
|
|
17
|
+
if (params.includes('=')) {
|
|
18
|
+
throw new Error('default argument values are not supported');
|
|
19
|
+
}
|
|
20
|
+
return params;
|
|
21
|
+
};
|
|
22
|
+
const serializeApiFunction = (fn, variables) => {
|
|
23
|
+
const variableInitializer = [];
|
|
24
|
+
const functionParams = getFunctionParams(fn);
|
|
25
|
+
if (variables) {
|
|
26
|
+
for (const varName of Object.keys(variables)) {
|
|
27
|
+
let varValue = variables[varName];
|
|
28
|
+
if (varValue === undefined || varValue === null || typeof varValue === 'number' || typeof varValue === 'boolean') {
|
|
29
|
+
varValue = `${varValue}`;
|
|
30
|
+
}
|
|
31
|
+
else if (typeof varValue === 'string') {
|
|
32
|
+
varValue = `${(0, serialize_javascript_1.default)(variables[varName], SERIALIZE_JAVASCRIPT_OPTIONS)}`;
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
varValue = `eval('(${(0, serialize_javascript_1.default)(variables[varName], SERIALIZE_JAVASCRIPT_OPTIONS).replace(/'/g, "\\'")})')`;
|
|
36
|
+
}
|
|
37
|
+
variableInitializer.push(`const ${varName} = ${varValue};`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
const functionString = fn.toString();
|
|
41
|
+
const serializedHeader = `return ((${functionParams.map((_param, index) => `____arg${index}`).join(',')}) => {`;
|
|
42
|
+
const serializedParams = `${functionParams
|
|
43
|
+
.map((_param, index) => `const ${functionParams[index]} = ____arg${index};`)
|
|
44
|
+
.join('\n')}`;
|
|
45
|
+
const serializedVariables = `${variableInitializer.join('\n')}`;
|
|
46
|
+
// prettier-ignore
|
|
47
|
+
const serializedFunction = `return (${functionString.substring(0, functionString.indexOf('('))}()${functionString.substring(functionString.indexOf(')') + 1)})(); })(${functionParams.map((_param, index) => `____arg${index}`).join(',')})`;
|
|
48
|
+
if (!serializedParams && !serializedVariables) {
|
|
49
|
+
return `${serializedHeader}${serializedFunction}`;
|
|
50
|
+
}
|
|
51
|
+
return [serializedHeader, serializedParams, serializedVariables, serializedFunction].filter((x) => !!x).join('\n');
|
|
52
|
+
};
|
|
53
|
+
const keysOf = (obj) => {
|
|
54
|
+
return Array.from(Object.keys(obj));
|
|
55
|
+
};
|
|
56
|
+
const serializeRemotableFunctions = (obj) => {
|
|
57
|
+
const objectKeys = keysOf(obj);
|
|
58
|
+
if (!objectKeys || objectKeys.length === 0) {
|
|
59
|
+
return obj;
|
|
60
|
+
}
|
|
61
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
62
|
+
// @ts-ignore
|
|
63
|
+
const output = {};
|
|
64
|
+
for (const key of objectKeys) {
|
|
65
|
+
if (typeof obj[key] === 'object') {
|
|
66
|
+
if ('localFn' in obj[key]) {
|
|
67
|
+
const remotableFunction = obj[key];
|
|
68
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
69
|
+
// @ts-ignore
|
|
70
|
+
output[key] = {
|
|
71
|
+
remoteFn: serializeApiFunction(remotableFunction.localFn, remotableFunction.localVariables),
|
|
72
|
+
localFn: remotableFunction.localFn.toString(),
|
|
73
|
+
localVariables: (0, serialize_javascript_1.default)(remotableFunction.localVariables, SERIALIZE_JAVASCRIPT_OPTIONS),
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
78
|
+
// @ts-ignore
|
|
79
|
+
output[key] = serializeRemotableFunctions(obj[key]);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
84
|
+
// @ts-ignore
|
|
85
|
+
output[key] = obj[key];
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return output;
|
|
89
|
+
};
|
|
90
|
+
class Client {
|
|
91
|
+
get baseUrl() {
|
|
92
|
+
return `${this.options.protocol}://${this.options.host}${this.options.port ? `:${this.options.port}` : ''}`;
|
|
93
|
+
}
|
|
94
|
+
constructor(options) {
|
|
95
|
+
this.options = {
|
|
96
|
+
...shared_1.stuntmanConfig.client,
|
|
97
|
+
...options,
|
|
98
|
+
port: (options === null || options === void 0 ? void 0 : options.port) || (options === null || options === void 0 ? void 0 : options.protocol) ? (options.protocol === 'https' ? 443 : 80) : shared_1.stuntmanConfig.client.port,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
async fetch(url, init) {
|
|
102
|
+
var _a;
|
|
103
|
+
const controller = new AbortController();
|
|
104
|
+
const timeout = setTimeout(() => {
|
|
105
|
+
controller.abort();
|
|
106
|
+
}, this.options.timeout);
|
|
107
|
+
try {
|
|
108
|
+
const response = await fetch(url, {
|
|
109
|
+
...init,
|
|
110
|
+
headers: {
|
|
111
|
+
...(this.options.apiKey && { 'x-api-key': this.options.apiKey }),
|
|
112
|
+
...init === null || init === void 0 ? void 0 : init.headers,
|
|
113
|
+
},
|
|
114
|
+
signal: (_a = init === null || init === void 0 ? void 0 : init.signal) !== null && _a !== void 0 ? _a : controller.signal,
|
|
115
|
+
});
|
|
116
|
+
if (!response.ok) {
|
|
117
|
+
const text = await response.text();
|
|
118
|
+
let json;
|
|
119
|
+
try {
|
|
120
|
+
json = JSON.parse(text);
|
|
121
|
+
}
|
|
122
|
+
catch (kiss) {
|
|
123
|
+
// and swallow
|
|
124
|
+
}
|
|
125
|
+
if (json && 'error' in json) {
|
|
126
|
+
throw new clientError_1.ClientError(json.error);
|
|
127
|
+
}
|
|
128
|
+
throw new Error(`Unexpected errror: ${text}`);
|
|
129
|
+
}
|
|
130
|
+
return response;
|
|
131
|
+
}
|
|
132
|
+
finally {
|
|
133
|
+
clearTimeout(timeout);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
async getRules() {
|
|
137
|
+
const response = await this.fetch(`${this.baseUrl}/rules`);
|
|
138
|
+
return (await response.json());
|
|
139
|
+
}
|
|
140
|
+
async getRule(id) {
|
|
141
|
+
const response = await this.fetch(`${this.baseUrl}/rule/${encodeURIComponent(id)}`);
|
|
142
|
+
return (await response.json());
|
|
143
|
+
}
|
|
144
|
+
async disableRule(id) {
|
|
145
|
+
await this.fetch(`${this.baseUrl}/rule/${encodeURIComponent(id)}/disable`);
|
|
146
|
+
}
|
|
147
|
+
async enableRule(id) {
|
|
148
|
+
await this.fetch(`${this.baseUrl}/rule/${encodeURIComponent(id)}/enable`);
|
|
149
|
+
}
|
|
150
|
+
async removeRule(id) {
|
|
151
|
+
await this.fetch(`${this.baseUrl}/rule/${encodeURIComponent(id)}/remove`);
|
|
152
|
+
}
|
|
153
|
+
async addRule(rule) {
|
|
154
|
+
const serializedRule = serializeRemotableFunctions(rule);
|
|
155
|
+
const response = await this.fetch(`${this.baseUrl}/rule`, {
|
|
156
|
+
method: 'POST',
|
|
157
|
+
body: JSON.stringify(serializedRule),
|
|
158
|
+
headers: { 'content-type': 'application/json' },
|
|
159
|
+
});
|
|
160
|
+
return (await response.json());
|
|
161
|
+
}
|
|
162
|
+
async getTraffic(ruleOrIdOrLabel) {
|
|
163
|
+
const ruleId = typeof ruleOrIdOrLabel === 'object' ? ruleOrIdOrLabel.id : ruleOrIdOrLabel;
|
|
164
|
+
const response = await this.fetch(`${this.baseUrl}/traffic${ruleId ? `/${encodeURIComponent(ruleId)}` : ''}`);
|
|
165
|
+
return (await response.json());
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
exports.Client = Client;
|
|
169
|
+
//# sourceMappingURL=apiClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apiClient.js","sourceRoot":"","sources":["../src/apiClient.ts"],"names":[],"mappings":";;;;;;AAAA,gFAAuD;AACvD,+CAA4C;AAC5C,6CAAkD;AAGlD,MAAM,4BAA4B,GAA2C;IACzE,MAAM,EAAE,IAAI;IACZ,cAAc,EAAE,IAAI;CACvB,CAAC;AAEF,MAAM,iBAAiB,GAAG,CAAC,IAAe,EAAE,EAAE;IAC1C,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;IAC/B,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,IAAI,KAAK,EAAU,CAAC;IACrH,IAAI,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;QACtB,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;KAChE;IACD,OAAO,MAAM,CAAC;AAClB,CAAC,CAAC;AAEF,MAAM,oBAAoB,GAAG,CAAC,EAA2B,EAAE,SAAmC,EAAU,EAAE;IACtG,MAAM,mBAAmB,GAAa,EAAE,CAAC;IACzC,MAAM,cAAc,GAAG,iBAAiB,CAAC,EAAE,CAAC,CAAC;IAC7C,IAAI,SAAS,EAAE;QACX,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE;YAC1C,IAAI,QAAQ,GAAG,SAAS,CAA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;IAKD,KAAK,CAAC,UAAU,CAAC,eAAuC;QACpD,MAAM,MAAM,GAAG,OAAO,eAAe,KAAK,QAAQ,CAAC,CAAC,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC,CAAC,eAAe,CAAC;QAC1F,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,OAAO,WAAW,MAAM,CAAC,CAAC,CAAC,IAAI,kBAAkB,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QAC9G,OAAO,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAwB,CAAC;IAC1D,CAAC;CACJ;AA1FD,wBA0FC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { AppError } from '@stuntman/shared';
|
|
2
|
+
import type * as Stuntman from '@stuntman/shared';
|
|
3
|
+
export declare enum HttpCode {
|
|
4
|
+
OK = 200,
|
|
5
|
+
NO_CONTENT = 204,
|
|
6
|
+
BAD_REQUEST = 400,
|
|
7
|
+
UNAUTHORIZED = 401,
|
|
8
|
+
NOT_FOUND = 404,
|
|
9
|
+
CONFLICT = 409,
|
|
10
|
+
UNPROCESSABLE_ENTITY = 422,
|
|
11
|
+
INTERNAL_SERVER_ERROR = 500
|
|
12
|
+
}
|
|
13
|
+
export declare class ClientError extends AppError {
|
|
14
|
+
readonly originalStack?: string;
|
|
15
|
+
constructor(args: Stuntman.AppError & {
|
|
16
|
+
stack?: string;
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=clientError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clientError.d.ts","sourceRoot":"","sources":["../src/clientError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,KAAK,KAAK,QAAQ,MAAM,kBAAkB,CAAC;AAElD,oBAAY,QAAQ;IAChB,EAAE,MAAM;IACR,UAAU,MAAM;IAChB,WAAW,MAAM;IACjB,YAAY,MAAM;IAClB,SAAS,MAAM;IACf,QAAQ,MAAM;IACd,oBAAoB,MAAM;IAC1B,qBAAqB,MAAM;CAC9B;AAED,qBAAa,WAAY,SAAQ,QAAQ;IACrC,SAAgB,aAAa,CAAC,EAAE,MAAM,CAAC;gBAE3B,IAAI,EAAE,QAAQ,CAAC,QAAQ,GAAG;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE;CAM3D"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ClientError = exports.HttpCode = void 0;
|
|
4
|
+
const shared_1 = require("@stuntman/shared");
|
|
5
|
+
var HttpCode;
|
|
6
|
+
(function (HttpCode) {
|
|
7
|
+
HttpCode[HttpCode["OK"] = 200] = "OK";
|
|
8
|
+
HttpCode[HttpCode["NO_CONTENT"] = 204] = "NO_CONTENT";
|
|
9
|
+
HttpCode[HttpCode["BAD_REQUEST"] = 400] = "BAD_REQUEST";
|
|
10
|
+
HttpCode[HttpCode["UNAUTHORIZED"] = 401] = "UNAUTHORIZED";
|
|
11
|
+
HttpCode[HttpCode["NOT_FOUND"] = 404] = "NOT_FOUND";
|
|
12
|
+
HttpCode[HttpCode["CONFLICT"] = 409] = "CONFLICT";
|
|
13
|
+
HttpCode[HttpCode["UNPROCESSABLE_ENTITY"] = 422] = "UNPROCESSABLE_ENTITY";
|
|
14
|
+
HttpCode[HttpCode["INTERNAL_SERVER_ERROR"] = 500] = "INTERNAL_SERVER_ERROR";
|
|
15
|
+
})(HttpCode = exports.HttpCode || (exports.HttpCode = {}));
|
|
16
|
+
class ClientError extends shared_1.AppError {
|
|
17
|
+
constructor(args) {
|
|
18
|
+
super(args);
|
|
19
|
+
if (args.stack) {
|
|
20
|
+
this.originalStack = args.stack;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.ClientError = ClientError;
|
|
25
|
+
//# sourceMappingURL=clientError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clientError.js","sourceRoot":"","sources":["../src/clientError.ts"],"names":[],"mappings":";;;AAAA,6CAA4C;AAG5C,IAAY,QASX;AATD,WAAY,QAAQ;IAChB,qCAAQ,CAAA;IACR,qDAAgB,CAAA;IAChB,uDAAiB,CAAA;IACjB,yDAAkB,CAAA;IAClB,mDAAe,CAAA;IACf,iDAAc,CAAA;IACd,yEAA0B,CAAA;IAC1B,2EAA2B,CAAA;AAC/B,CAAC,EATW,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QASnB;AAED,MAAa,WAAY,SAAQ,iBAAQ;IAGrC,YAAY,IAA4C;QACpD,KAAK,CAAC,IAAI,CAAC,CAAC;QACZ,IAAI,IAAI,CAAC,KAAK,EAAE;YACZ,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,KAAK,CAAC;SACnC;IACL,CAAC;CACJ;AATD,kCASC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,cAAc,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ruleBuilder = exports.StuntmanClient = void 0;
|
|
4
|
+
var apiClient_1 = require("./apiClient");
|
|
5
|
+
Object.defineProperty(exports, "StuntmanClient", { enumerable: true, get: function () { return apiClient_1.Client; } });
|
|
6
|
+
var ruleBuilder_1 = require("./ruleBuilder");
|
|
7
|
+
Object.defineProperty(exports, "ruleBuilder", { enumerable: true, get: function () { return ruleBuilder_1.ruleBuilder; } });
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,yCAAuD;AAA9C,2GAAA,MAAM,OAAkB;AACjC,6CAA4C;AAAnC,0GAAA,WAAW,OAAA"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type * as Stuntman from '@stuntman/shared';
|
|
2
|
+
type KeyValueMatcher = string | RegExp | {
|
|
3
|
+
key: string;
|
|
4
|
+
value?: string | RegExp;
|
|
5
|
+
};
|
|
6
|
+
type ObjectValueMatcher = string | RegExp | number | boolean | null;
|
|
7
|
+
type ObjectKeyValueMatcher = {
|
|
8
|
+
key: string;
|
|
9
|
+
value?: ObjectValueMatcher;
|
|
10
|
+
};
|
|
11
|
+
type GQLRequestMatcher = {
|
|
12
|
+
operationName?: string | RegExp;
|
|
13
|
+
variables?: ObjectKeyValueMatcher[];
|
|
14
|
+
query?: string | RegExp;
|
|
15
|
+
type?: 'query' | 'mutation';
|
|
16
|
+
methodName?: string | RegExp;
|
|
17
|
+
};
|
|
18
|
+
type MatchBuilderVariables = {
|
|
19
|
+
filter?: string | RegExp;
|
|
20
|
+
hostname?: string | RegExp;
|
|
21
|
+
pathname?: string | RegExp;
|
|
22
|
+
port?: number | string | RegExp;
|
|
23
|
+
searchParams?: KeyValueMatcher[];
|
|
24
|
+
headers?: KeyValueMatcher[];
|
|
25
|
+
bodyText?: string | RegExp | null;
|
|
26
|
+
bodyJson?: ObjectKeyValueMatcher[];
|
|
27
|
+
bodyGql?: GQLRequestMatcher;
|
|
28
|
+
};
|
|
29
|
+
declare class RuleBuilderBaseBase {
|
|
30
|
+
protected rule: Stuntman.SerializableRule;
|
|
31
|
+
protected _matchBuilderVariables: MatchBuilderVariables;
|
|
32
|
+
constructor(rule?: Stuntman.SerializableRule, _matchBuilderVariables?: MatchBuilderVariables);
|
|
33
|
+
}
|
|
34
|
+
declare class RuleBuilderBase extends RuleBuilderBaseBase {
|
|
35
|
+
limitedUse(hitCount: number): this;
|
|
36
|
+
singleUse(): this;
|
|
37
|
+
storeTraffic(): this;
|
|
38
|
+
disabled(): void;
|
|
39
|
+
}
|
|
40
|
+
declare class RuleBuilder extends RuleBuilderBase {
|
|
41
|
+
raisePriority(by?: number): this;
|
|
42
|
+
decreasePriority(by?: number): this;
|
|
43
|
+
customTtl(ttlSeconds: number): this;
|
|
44
|
+
customId(id: string): this;
|
|
45
|
+
onRequestTo(filter: string | RegExp): RuleBuilderInitialized;
|
|
46
|
+
onRequestToHostname(hostname: string | RegExp): RuleBuilderInitialized;
|
|
47
|
+
onRequestToPathname(pathname: string | RegExp): RuleBuilderInitialized;
|
|
48
|
+
onRequestToPort(port: string | number | RegExp): RuleBuilderInitialized;
|
|
49
|
+
onAnyRequest(): RuleBuilderInitialized;
|
|
50
|
+
}
|
|
51
|
+
declare class RuleBuilderInitialized extends RuleBuilderBase {
|
|
52
|
+
withHostname(hostname: string | RegExp): this;
|
|
53
|
+
withPathname(pathname: string | RegExp): this;
|
|
54
|
+
withPort(port: number | string | RegExp): this;
|
|
55
|
+
withSearchParam(key: string | RegExp): RuleBuilderInitialized;
|
|
56
|
+
withSearchParam(key: string, value?: string | RegExp): RuleBuilderInitialized;
|
|
57
|
+
withSearchParams(params: KeyValueMatcher[]): RuleBuilderInitialized;
|
|
58
|
+
withHeader(key: string | RegExp): RuleBuilderInitialized;
|
|
59
|
+
withHeader(key: string, value?: string | RegExp): RuleBuilderInitialized;
|
|
60
|
+
withHeaders(...headers: KeyValueMatcher[]): RuleBuilderInitialized;
|
|
61
|
+
withBodyText(includes: string): RuleBuilderInitialized;
|
|
62
|
+
withBodyText(matches: RegExp): RuleBuilderInitialized;
|
|
63
|
+
withoutBody(): RuleBuilderInitialized;
|
|
64
|
+
withBodyJson(hasKey: string): RuleBuilderInitialized;
|
|
65
|
+
withBodyJson(hasKey: string, withValue: ObjectValueMatcher): RuleBuilderInitialized;
|
|
66
|
+
withBodyJson(matches: ObjectKeyValueMatcher): RuleBuilderInitialized;
|
|
67
|
+
withBodyGql(gqlMatcher: GQLRequestMatcher): RuleBuilderInitialized;
|
|
68
|
+
proxyPass(): Stuntman.SerializableRule;
|
|
69
|
+
mockResponse(staticResponse: Stuntman.Response): Stuntman.SerializableRule;
|
|
70
|
+
mockResponse(generationFunction: Stuntman.RemotableFunction<Stuntman.ResponseGenerationFn>): Stuntman.SerializableRule;
|
|
71
|
+
mockResponse(localFn: Stuntman.ResponseGenerationFn, localVariables?: Stuntman.LocalVariables): Stuntman.SerializableRule;
|
|
72
|
+
modifyRequest(modifyFunction: Stuntman.RequestManipulationFn | Stuntman.RemotableFunction<Stuntman.RequestManipulationFn>, localVariables?: Stuntman.LocalVariables): RuleBuilderRequestInitialized;
|
|
73
|
+
modifyResponse(modifyFunction: Stuntman.ResponseManipulationFn | Stuntman.RemotableFunction<Stuntman.ResponseManipulationFn>, localVariables?: Stuntman.LocalVariables): Stuntman.SerializableRule;
|
|
74
|
+
}
|
|
75
|
+
declare class RuleBuilderRequestInitialized extends RuleBuilderBase {
|
|
76
|
+
modifyResponse(modifyFunction: Stuntman.ResponseManipulationFn | Stuntman.RemotableFunction<Stuntman.ResponseManipulationFn>, localVariables?: Stuntman.LocalVariables): Stuntman.SerializableRule;
|
|
77
|
+
}
|
|
78
|
+
export declare const ruleBuilder: () => RuleBuilder;
|
|
79
|
+
export {};
|
|
80
|
+
//# sourceMappingURL=ruleBuilder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ruleBuilder.d.ts","sourceRoot":"","sources":["../src/ruleBuilder.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,QAAQ,MAAM,kBAAkB,CAAC;AAGlD,KAAK,eAAe,GAAG,MAAM,GAAG,MAAM,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,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C,EAAE,QAAQ,CAAC,cAAc,GACzC,QAAQ,CAAC,gBAAgB;CAc/B;AAED,eAAO,MAAM,WAAW,mBAA0B,CAAC"}
|
|
@@ -0,0 +1,535 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ruleBuilder = void 0;
|
|
4
|
+
const uuid_1 = require("uuid");
|
|
5
|
+
const shared_1 = require("@stuntman/shared");
|
|
6
|
+
// TODO add fluent match on multipart from data
|
|
7
|
+
class RuleBuilderBaseBase {
|
|
8
|
+
constructor(rule, _matchBuilderVariables) {
|
|
9
|
+
this._matchBuilderVariables = _matchBuilderVariables || {};
|
|
10
|
+
this.rule = rule || {
|
|
11
|
+
id: (0, uuid_1.v4)(),
|
|
12
|
+
ttlSeconds: shared_1.DEFAULT_RULE_TTL_SECONDS,
|
|
13
|
+
priority: shared_1.DEFAULT_RULE_PRIORITY,
|
|
14
|
+
actions: {
|
|
15
|
+
mockResponse: { status: 200 },
|
|
16
|
+
},
|
|
17
|
+
matches: {
|
|
18
|
+
localFn: (req) => {
|
|
19
|
+
var _a, _b, _c, _d;
|
|
20
|
+
const ___url = new URL(req.url);
|
|
21
|
+
const ___headers = req.rawHeaders;
|
|
22
|
+
const arrayIndexerRegex = /\[(?<arrayIndex>[0-9]*)\]/i;
|
|
23
|
+
const matchObject = (obj, path, value, parentPath) => {
|
|
24
|
+
var _a, _b, _c, _d;
|
|
25
|
+
if (!obj) {
|
|
26
|
+
return { result: false, description: `${parentPath} is falsey` };
|
|
27
|
+
}
|
|
28
|
+
const [rawKey, ...rest] = path.split('.');
|
|
29
|
+
const key = (rawKey !== null && rawKey !== void 0 ? rawKey : '').replace(arrayIndexerRegex, '');
|
|
30
|
+
const shouldBeArray = rawKey ? arrayIndexerRegex.test(rawKey) : false;
|
|
31
|
+
const arrayIndex = rawKey && (((_b = (_a = arrayIndexerRegex.exec(rawKey)) === null || _a === void 0 ? void 0 : _a.groups) === null || _b === void 0 ? void 0 : _b.arrayIndex) || '').length > 0
|
|
32
|
+
? Number((_d = (_c = arrayIndexerRegex.exec(rawKey)) === null || _c === void 0 ? void 0 : _c.groups) === null || _d === void 0 ? void 0 : _d.arrayIndex)
|
|
33
|
+
: Number.NaN;
|
|
34
|
+
const actualValue = key ? obj[key] : obj;
|
|
35
|
+
const currentPath = `${parentPath ? `${parentPath}.` : ''}${rawKey}`;
|
|
36
|
+
if (value === undefined && actualValue === undefined) {
|
|
37
|
+
return { result: false, description: `${currentPath}=undefined` };
|
|
38
|
+
}
|
|
39
|
+
if (rest.length === 0) {
|
|
40
|
+
if (shouldBeArray &&
|
|
41
|
+
(!Array.isArray(actualValue) ||
|
|
42
|
+
(Number.isInteger(arrayIndex) && actualValue.length <= Number(arrayIndex)))) {
|
|
43
|
+
return { result: false, description: `${currentPath} empty array` };
|
|
44
|
+
}
|
|
45
|
+
if (value === undefined) {
|
|
46
|
+
const result = shouldBeArray
|
|
47
|
+
? !Number.isInteger(arrayIndex) || actualValue.length >= Number(arrayIndex)
|
|
48
|
+
: actualValue !== undefined;
|
|
49
|
+
return { result, description: `${currentPath} === undefined` };
|
|
50
|
+
}
|
|
51
|
+
if (!shouldBeArray) {
|
|
52
|
+
const result = value instanceof RegExp ? value.test(actualValue) : value === actualValue;
|
|
53
|
+
return { result, description: `${currentPath} === "${actualValue}"` };
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
if (shouldBeArray) {
|
|
57
|
+
if (Number.isInteger(arrayIndex)) {
|
|
58
|
+
return matchObject(actualValue[Number(arrayIndex)], rest.join('.'), value, currentPath);
|
|
59
|
+
}
|
|
60
|
+
const hasArrayMatch = actualValue.some((arrayValue) => matchObject(arrayValue, rest.join('.'), value, currentPath).result);
|
|
61
|
+
return { result: hasArrayMatch, description: `array match ${currentPath}` };
|
|
62
|
+
}
|
|
63
|
+
if (typeof actualValue !== 'object') {
|
|
64
|
+
return { result: false, description: `${currentPath} not an object` };
|
|
65
|
+
}
|
|
66
|
+
return matchObject(actualValue, rest.join('.'), value, currentPath);
|
|
67
|
+
};
|
|
68
|
+
const ___matchesValue = (matcher, value) => {
|
|
69
|
+
if (matcher === undefined) {
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
if (typeof matcher !== 'string' && !(matcher instanceof RegExp) && typeof matcher !== 'number') {
|
|
73
|
+
throw new Error('invalid matcher');
|
|
74
|
+
}
|
|
75
|
+
if (typeof matcher === 'string' && matcher !== value) {
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
if (matcher instanceof RegExp && (typeof value !== 'string' || !matcher.test(value))) {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
if (typeof matcher === 'number' && (typeof value !== 'number' || matcher !== value)) {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
return true;
|
|
85
|
+
};
|
|
86
|
+
if (!___matchesValue(matchBuilderVariables.filter, req.url)) {
|
|
87
|
+
return {
|
|
88
|
+
result: false,
|
|
89
|
+
description: `url ${req.url} doesn't match ${(_a = matchBuilderVariables.filter) === null || _a === void 0 ? void 0 : _a.toString()}`,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
if (!___matchesValue(matchBuilderVariables.hostname, ___url.hostname)) {
|
|
93
|
+
return {
|
|
94
|
+
result: false,
|
|
95
|
+
description: `hostname ${___url.hostname} doesn't match ${(_b = matchBuilderVariables.hostname) === null || _b === void 0 ? void 0 : _b.toString()}`,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
if (!___matchesValue(matchBuilderVariables.pathname, ___url.pathname)) {
|
|
99
|
+
return {
|
|
100
|
+
result: false,
|
|
101
|
+
description: `pathname ${___url.pathname} doesn't match ${(_c = matchBuilderVariables.pathname) === null || _c === void 0 ? void 0 : _c.toString()}`,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
if (matchBuilderVariables.port) {
|
|
105
|
+
const port = ___url.port && ___url.port !== '' ? ___url.port : ___url.protocol === 'https:' ? '443' : '80';
|
|
106
|
+
if (!___matchesValue(matchBuilderVariables.port instanceof RegExp
|
|
107
|
+
? matchBuilderVariables.port
|
|
108
|
+
: `${matchBuilderVariables.port}`, port)) {
|
|
109
|
+
return {
|
|
110
|
+
result: false,
|
|
111
|
+
description: `port ${port} doesn't match ${(_d = matchBuilderVariables.port) === null || _d === void 0 ? void 0 : _d.toString()}`,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
if (matchBuilderVariables.searchParams) {
|
|
116
|
+
for (const searchParamMatcher of matchBuilderVariables.searchParams) {
|
|
117
|
+
if (typeof searchParamMatcher === 'string') {
|
|
118
|
+
const result = ___url.searchParams.has(searchParamMatcher);
|
|
119
|
+
return { result, description: `searchParams.has("${searchParamMatcher}")` };
|
|
120
|
+
}
|
|
121
|
+
if (searchParamMatcher instanceof RegExp) {
|
|
122
|
+
const result = Array.from(___url.searchParams.keys()).some((key) => searchParamMatcher.test(key));
|
|
123
|
+
return { result, description: `searchParams.keys() matches ${searchParamMatcher.toString()}` };
|
|
124
|
+
}
|
|
125
|
+
if (!___url.searchParams.has(searchParamMatcher.key)) {
|
|
126
|
+
return { result: false, description: `searchParams.has("${searchParamMatcher.key}")` };
|
|
127
|
+
}
|
|
128
|
+
if (searchParamMatcher.value) {
|
|
129
|
+
const value = ___url.searchParams.get(searchParamMatcher.key);
|
|
130
|
+
if (value === null) {
|
|
131
|
+
return {
|
|
132
|
+
result: false,
|
|
133
|
+
description: `searchParams.get("${searchParamMatcher.key}") === null`,
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
if (!___matchesValue(searchParamMatcher.value, value)) {
|
|
137
|
+
return {
|
|
138
|
+
result: false,
|
|
139
|
+
description: `searchParams.get("${searchParamMatcher.key}") = "${searchParamMatcher.value}"`,
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
if (matchBuilderVariables.headers) {
|
|
146
|
+
for (const headerMatcher of matchBuilderVariables.headers) {
|
|
147
|
+
if (typeof headerMatcher === 'string') {
|
|
148
|
+
const result = ___headers.has(headerMatcher);
|
|
149
|
+
if (result) {
|
|
150
|
+
continue;
|
|
151
|
+
}
|
|
152
|
+
return { result: false, description: `headers.has("${headerMatcher}")` };
|
|
153
|
+
}
|
|
154
|
+
if (headerMatcher instanceof RegExp) {
|
|
155
|
+
const result = ___headers.toHeaderPairs().some(([key]) => headerMatcher.test(key));
|
|
156
|
+
if (result) {
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
return { result: false, description: `headers.keys matches ${headerMatcher.toString()}` };
|
|
160
|
+
}
|
|
161
|
+
if (!___headers.has(headerMatcher.key)) {
|
|
162
|
+
return { result: false, description: `headers.has("${headerMatcher.key}")` };
|
|
163
|
+
}
|
|
164
|
+
if (headerMatcher.value) {
|
|
165
|
+
const value = ___headers.get(headerMatcher.key);
|
|
166
|
+
if (value === null) {
|
|
167
|
+
return { result: false, description: `headers.get("${headerMatcher.key}") === null` };
|
|
168
|
+
}
|
|
169
|
+
if (!___matchesValue(headerMatcher.value, value)) {
|
|
170
|
+
return {
|
|
171
|
+
result: false,
|
|
172
|
+
description: `headerMatcher.get("${headerMatcher.key}") = "${headerMatcher.value}"`,
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
if (matchBuilderVariables.bodyText === null && !!req.body) {
|
|
179
|
+
return { result: false, description: `empty body` };
|
|
180
|
+
}
|
|
181
|
+
if (matchBuilderVariables.bodyText) {
|
|
182
|
+
if (!req.body) {
|
|
183
|
+
return { result: false, description: `empty body` };
|
|
184
|
+
}
|
|
185
|
+
if (matchBuilderVariables.bodyText instanceof RegExp) {
|
|
186
|
+
if (!___matchesValue(matchBuilderVariables.bodyText, req.body)) {
|
|
187
|
+
return {
|
|
188
|
+
result: false,
|
|
189
|
+
description: `body text doesn't match ${matchBuilderVariables.bodyText.toString()}`,
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
else if (!req.body.includes(matchBuilderVariables.bodyText)) {
|
|
194
|
+
return {
|
|
195
|
+
result: false,
|
|
196
|
+
description: `body text doesn't include "${matchBuilderVariables.bodyText}"`,
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
if (matchBuilderVariables.bodyJson) {
|
|
201
|
+
let json;
|
|
202
|
+
try {
|
|
203
|
+
json = JSON.parse(req.body);
|
|
204
|
+
}
|
|
205
|
+
catch (kiss) {
|
|
206
|
+
return { result: false, description: `unparseable json` };
|
|
207
|
+
}
|
|
208
|
+
if (!json) {
|
|
209
|
+
return { result: false, description: `empty json object` };
|
|
210
|
+
}
|
|
211
|
+
for (const jsonMatcher of Array.isArray(matchBuilderVariables.bodyJson)
|
|
212
|
+
? matchBuilderVariables.bodyJson
|
|
213
|
+
: [matchBuilderVariables.bodyJson]) {
|
|
214
|
+
const matchObjectResult = matchObject(json, jsonMatcher.key, jsonMatcher.value);
|
|
215
|
+
if (!matchObjectResult.result) {
|
|
216
|
+
return { result: false, description: `$.${jsonMatcher.key} != "${jsonMatcher.value}"` };
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
if (matchBuilderVariables.bodyGql) {
|
|
221
|
+
if (!req.gqlBody) {
|
|
222
|
+
return { result: false, description: `not a gql body` };
|
|
223
|
+
}
|
|
224
|
+
if (!___matchesValue(matchBuilderVariables.bodyGql.methodName, req.gqlBody.methodName)) {
|
|
225
|
+
return {
|
|
226
|
+
result: false,
|
|
227
|
+
description: `methodName "${matchBuilderVariables.bodyGql.methodName}" !== "${req.gqlBody.methodName}"`,
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
if (!___matchesValue(matchBuilderVariables.bodyGql.operationName, req.gqlBody.operationName)) {
|
|
231
|
+
return {
|
|
232
|
+
result: false,
|
|
233
|
+
description: `operationName "${matchBuilderVariables.bodyGql.operationName}" !== "${req.gqlBody.operationName}"`,
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
if (!___matchesValue(matchBuilderVariables.bodyGql.query, req.gqlBody.query)) {
|
|
237
|
+
return {
|
|
238
|
+
result: false,
|
|
239
|
+
description: `query "${matchBuilderVariables.bodyGql.query}" !== "${req.gqlBody.query}"`,
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
if (!___matchesValue(matchBuilderVariables.bodyGql.type, req.gqlBody.type)) {
|
|
243
|
+
return {
|
|
244
|
+
result: false,
|
|
245
|
+
description: `type "${matchBuilderVariables.bodyGql.type}" !== "${req.gqlBody.type}"`,
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
if (matchBuilderVariables.bodyGql.variables) {
|
|
249
|
+
for (const jsonMatcher of Array.isArray(matchBuilderVariables.bodyGql.variables)
|
|
250
|
+
? matchBuilderVariables.bodyGql.variables
|
|
251
|
+
: [matchBuilderVariables.bodyGql.variables]) {
|
|
252
|
+
const matchObjectResult = matchObject(req.gqlBody.variables, jsonMatcher.key, jsonMatcher.value);
|
|
253
|
+
if (!matchObjectResult.result) {
|
|
254
|
+
return {
|
|
255
|
+
result: false,
|
|
256
|
+
description: `GQL variable ${jsonMatcher.key} != "${jsonMatcher.value}". Detail: ${matchObjectResult.description}`,
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
return { result: true, description: 'match' };
|
|
263
|
+
},
|
|
264
|
+
localVariables: { matchBuilderVariables: this._matchBuilderVariables },
|
|
265
|
+
},
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
class RuleBuilderBase extends RuleBuilderBaseBase {
|
|
270
|
+
limitedUse(hitCount) {
|
|
271
|
+
if (this.rule.removeAfterUse) {
|
|
272
|
+
throw new Error(`limit already set at ${this.rule.removeAfterUse}`);
|
|
273
|
+
}
|
|
274
|
+
if (Number.isNaN(hitCount) || !Number.isFinite(hitCount) || !Number.isInteger(hitCount) || hitCount <= 0) {
|
|
275
|
+
throw new Error('Invalid hitCount');
|
|
276
|
+
}
|
|
277
|
+
this.rule.removeAfterUse = hitCount;
|
|
278
|
+
return this;
|
|
279
|
+
}
|
|
280
|
+
singleUse() {
|
|
281
|
+
return this.limitedUse(1);
|
|
282
|
+
}
|
|
283
|
+
storeTraffic() {
|
|
284
|
+
this.rule.storeTraffic = true;
|
|
285
|
+
return this;
|
|
286
|
+
}
|
|
287
|
+
disabled() {
|
|
288
|
+
this.rule.isEnabled = false;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
class RuleBuilder extends RuleBuilderBase {
|
|
292
|
+
raisePriority(by) {
|
|
293
|
+
if (this.rule.priority !== shared_1.DEFAULT_RULE_PRIORITY) {
|
|
294
|
+
throw new Error('you should not alter rule priority more than once');
|
|
295
|
+
}
|
|
296
|
+
const subtract = by !== null && by !== void 0 ? by : 1;
|
|
297
|
+
if (subtract >= shared_1.DEFAULT_RULE_PRIORITY) {
|
|
298
|
+
throw new Error(`Unable to raise priority over the default ${shared_1.DEFAULT_RULE_PRIORITY}`);
|
|
299
|
+
}
|
|
300
|
+
this.rule.priority = shared_1.DEFAULT_RULE_PRIORITY - subtract;
|
|
301
|
+
return this;
|
|
302
|
+
}
|
|
303
|
+
decreasePriority(by) {
|
|
304
|
+
if (this.rule.priority !== shared_1.DEFAULT_RULE_PRIORITY) {
|
|
305
|
+
throw new Error('you should not alter rule priority more than once');
|
|
306
|
+
}
|
|
307
|
+
const add = by !== null && by !== void 0 ? by : 1;
|
|
308
|
+
this.rule.priority = shared_1.DEFAULT_RULE_PRIORITY + add;
|
|
309
|
+
return this;
|
|
310
|
+
}
|
|
311
|
+
customTtl(ttlSeconds) {
|
|
312
|
+
if (Number.isNaN(ttlSeconds) || !Number.isInteger(ttlSeconds) || !Number.isFinite(ttlSeconds) || ttlSeconds < 0) {
|
|
313
|
+
throw new Error('Invalid ttl');
|
|
314
|
+
}
|
|
315
|
+
if (ttlSeconds < shared_1.MIN_RULE_TTL_SECONDS || ttlSeconds > shared_1.MAX_RULE_TTL_SECONDS) {
|
|
316
|
+
throw new Error(`ttl of ${ttlSeconds} seconds is outside range min: ${shared_1.MIN_RULE_TTL_SECONDS}, max:${shared_1.MAX_RULE_TTL_SECONDS}`);
|
|
317
|
+
}
|
|
318
|
+
this.rule.ttlSeconds = ttlSeconds;
|
|
319
|
+
return this;
|
|
320
|
+
}
|
|
321
|
+
customId(id) {
|
|
322
|
+
this.rule.id = id;
|
|
323
|
+
return this;
|
|
324
|
+
}
|
|
325
|
+
onRequestTo(filter) {
|
|
326
|
+
this._matchBuilderVariables.filter = filter;
|
|
327
|
+
return new RuleBuilderInitialized(this.rule, this._matchBuilderVariables);
|
|
328
|
+
}
|
|
329
|
+
onRequestToHostname(hostname) {
|
|
330
|
+
this._matchBuilderVariables.hostname = hostname;
|
|
331
|
+
return new RuleBuilderInitialized(this.rule, this._matchBuilderVariables);
|
|
332
|
+
}
|
|
333
|
+
onRequestToPathname(pathname) {
|
|
334
|
+
this._matchBuilderVariables.pathname = pathname;
|
|
335
|
+
return new RuleBuilderInitialized(this.rule, this._matchBuilderVariables);
|
|
336
|
+
}
|
|
337
|
+
onRequestToPort(port) {
|
|
338
|
+
this._matchBuilderVariables.port = port;
|
|
339
|
+
return new RuleBuilderInitialized(this.rule, this._matchBuilderVariables);
|
|
340
|
+
}
|
|
341
|
+
onAnyRequest() {
|
|
342
|
+
return new RuleBuilderInitialized(this.rule, this._matchBuilderVariables);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
class RuleBuilderInitialized extends RuleBuilderBase {
|
|
346
|
+
withHostname(hostname) {
|
|
347
|
+
if (this._matchBuilderVariables.hostname) {
|
|
348
|
+
throw new Error('hostname already set');
|
|
349
|
+
}
|
|
350
|
+
this._matchBuilderVariables.hostname = hostname;
|
|
351
|
+
return this;
|
|
352
|
+
}
|
|
353
|
+
withPathname(pathname) {
|
|
354
|
+
if (this._matchBuilderVariables.pathname) {
|
|
355
|
+
throw new Error('pathname already set');
|
|
356
|
+
}
|
|
357
|
+
this._matchBuilderVariables.pathname = pathname;
|
|
358
|
+
return this;
|
|
359
|
+
}
|
|
360
|
+
withPort(port) {
|
|
361
|
+
if (this._matchBuilderVariables.port) {
|
|
362
|
+
throw new Error('port already set');
|
|
363
|
+
}
|
|
364
|
+
this._matchBuilderVariables.port = port;
|
|
365
|
+
return this;
|
|
366
|
+
}
|
|
367
|
+
withSearchParam(key, value) {
|
|
368
|
+
if (!this._matchBuilderVariables.searchParams) {
|
|
369
|
+
this._matchBuilderVariables.searchParams = [];
|
|
370
|
+
}
|
|
371
|
+
if (!key) {
|
|
372
|
+
throw new Error('key cannot be empty');
|
|
373
|
+
}
|
|
374
|
+
if (!value) {
|
|
375
|
+
this._matchBuilderVariables.searchParams.push(key);
|
|
376
|
+
return this;
|
|
377
|
+
}
|
|
378
|
+
if (key instanceof RegExp) {
|
|
379
|
+
throw new Error('Unsupported regex param key with value');
|
|
380
|
+
}
|
|
381
|
+
this._matchBuilderVariables.searchParams.push({ key, value });
|
|
382
|
+
return this;
|
|
383
|
+
}
|
|
384
|
+
withSearchParams(params) {
|
|
385
|
+
if (!this._matchBuilderVariables.searchParams) {
|
|
386
|
+
this._matchBuilderVariables.searchParams = [];
|
|
387
|
+
}
|
|
388
|
+
for (const param of params) {
|
|
389
|
+
if (typeof param === 'string' || param instanceof RegExp) {
|
|
390
|
+
this.withSearchParam(param);
|
|
391
|
+
}
|
|
392
|
+
else {
|
|
393
|
+
this.withSearchParam(param.key, param.value);
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
return this;
|
|
397
|
+
}
|
|
398
|
+
withHeader(key, value) {
|
|
399
|
+
if (!this._matchBuilderVariables.headers) {
|
|
400
|
+
this._matchBuilderVariables.headers = [];
|
|
401
|
+
}
|
|
402
|
+
if (!key) {
|
|
403
|
+
throw new Error('key cannot be empty');
|
|
404
|
+
}
|
|
405
|
+
if (!value) {
|
|
406
|
+
this._matchBuilderVariables.headers.push(key);
|
|
407
|
+
return this;
|
|
408
|
+
}
|
|
409
|
+
if (key instanceof RegExp) {
|
|
410
|
+
throw new Error('Unsupported regex param key with value');
|
|
411
|
+
}
|
|
412
|
+
this._matchBuilderVariables.headers.push({ key, value });
|
|
413
|
+
return this;
|
|
414
|
+
}
|
|
415
|
+
withHeaders(...headers) {
|
|
416
|
+
if (!this._matchBuilderVariables.headers) {
|
|
417
|
+
this._matchBuilderVariables.headers = [];
|
|
418
|
+
}
|
|
419
|
+
for (const header of headers) {
|
|
420
|
+
if (typeof header === 'string' || header instanceof RegExp) {
|
|
421
|
+
this.withHeader(header);
|
|
422
|
+
}
|
|
423
|
+
else {
|
|
424
|
+
this.withHeader(header.key, header.value);
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
return this;
|
|
428
|
+
}
|
|
429
|
+
withBodyText(includesOrMatches) {
|
|
430
|
+
if (this._matchBuilderVariables.bodyText) {
|
|
431
|
+
throw new Error('bodyText already set');
|
|
432
|
+
}
|
|
433
|
+
if (this._matchBuilderVariables.bodyText === null) {
|
|
434
|
+
throw new Error('cannot use both withBodyText and withoutBody');
|
|
435
|
+
}
|
|
436
|
+
this._matchBuilderVariables.bodyText = includesOrMatches;
|
|
437
|
+
return this;
|
|
438
|
+
}
|
|
439
|
+
withoutBody() {
|
|
440
|
+
if (this._matchBuilderVariables.bodyText) {
|
|
441
|
+
throw new Error('cannot use both withBodyText and withoutBody');
|
|
442
|
+
}
|
|
443
|
+
this._matchBuilderVariables.bodyText = null;
|
|
444
|
+
return this;
|
|
445
|
+
}
|
|
446
|
+
withBodyJson(keyOrMatcher, withValue) {
|
|
447
|
+
const keyRegex = /^(?:(?:[a-z0-9_-]+)|(?:\[[0-9]*\]))(?:\.(?:(?:[a-z0-9_-]+)|(?:\[[0-9]*\])))*$/i;
|
|
448
|
+
if (!this._matchBuilderVariables.bodyJson) {
|
|
449
|
+
this._matchBuilderVariables.bodyJson = [];
|
|
450
|
+
}
|
|
451
|
+
if (typeof keyOrMatcher === 'string') {
|
|
452
|
+
if (!keyRegex.test(keyOrMatcher)) {
|
|
453
|
+
throw new Error(`invalid key "${keyOrMatcher}"`);
|
|
454
|
+
}
|
|
455
|
+
if (withValue === undefined) {
|
|
456
|
+
this._matchBuilderVariables.bodyJson.push({ key: keyOrMatcher });
|
|
457
|
+
}
|
|
458
|
+
else {
|
|
459
|
+
this._matchBuilderVariables.bodyJson.push({ key: keyOrMatcher, value: withValue });
|
|
460
|
+
}
|
|
461
|
+
return this;
|
|
462
|
+
}
|
|
463
|
+
if (withValue !== undefined) {
|
|
464
|
+
throw new Error('invalid usage');
|
|
465
|
+
}
|
|
466
|
+
if (!keyRegex.test(keyOrMatcher.key)) {
|
|
467
|
+
throw new Error(`invalid key "${keyOrMatcher}"`);
|
|
468
|
+
}
|
|
469
|
+
this._matchBuilderVariables.bodyJson.push(keyOrMatcher);
|
|
470
|
+
return this;
|
|
471
|
+
}
|
|
472
|
+
withBodyGql(gqlMatcher) {
|
|
473
|
+
if (this._matchBuilderVariables.bodyGql) {
|
|
474
|
+
throw new Error('gqlMatcher already set');
|
|
475
|
+
}
|
|
476
|
+
this._matchBuilderVariables.bodyGql = gqlMatcher;
|
|
477
|
+
return this;
|
|
478
|
+
}
|
|
479
|
+
proxyPass() {
|
|
480
|
+
this.rule.actions = { proxyPass: true };
|
|
481
|
+
return this.rule;
|
|
482
|
+
}
|
|
483
|
+
mockResponse(response, localVariables) {
|
|
484
|
+
if (typeof response === 'function') {
|
|
485
|
+
this.rule.actions = { mockResponse: { localFn: response, localVariables: localVariables !== null && localVariables !== void 0 ? localVariables : {} } };
|
|
486
|
+
return this.rule;
|
|
487
|
+
}
|
|
488
|
+
if (localVariables) {
|
|
489
|
+
throw new Error('invalid call - localVariables cannot be used together with Response or RemotableFunction');
|
|
490
|
+
}
|
|
491
|
+
this.rule.actions = { mockResponse: response };
|
|
492
|
+
return this.rule;
|
|
493
|
+
}
|
|
494
|
+
modifyRequest(modifyFunction, localVariables) {
|
|
495
|
+
if (typeof modifyFunction === 'function') {
|
|
496
|
+
this.rule.actions = { modifyRequest: { localFn: modifyFunction, localVariables: localVariables !== null && localVariables !== void 0 ? localVariables : {} } };
|
|
497
|
+
return new RuleBuilderRequestInitialized(this.rule, this._matchBuilderVariables);
|
|
498
|
+
}
|
|
499
|
+
if (localVariables) {
|
|
500
|
+
throw new Error('invalid call - localVariables cannot be used together with Response or RemotableFunction');
|
|
501
|
+
}
|
|
502
|
+
this.rule.actions = { modifyRequest: modifyFunction };
|
|
503
|
+
return new RuleBuilderRequestInitialized(this.rule, this._matchBuilderVariables);
|
|
504
|
+
}
|
|
505
|
+
modifyResponse(modifyFunction, localVariables) {
|
|
506
|
+
if (typeof modifyFunction === 'function') {
|
|
507
|
+
this.rule.actions = { modifyResponse: { localFn: modifyFunction, localVariables: localVariables !== null && localVariables !== void 0 ? localVariables : {} } };
|
|
508
|
+
return this.rule;
|
|
509
|
+
}
|
|
510
|
+
if (localVariables) {
|
|
511
|
+
throw new Error('invalid call - localVariables cannot be used together with Response or RemotableFunction');
|
|
512
|
+
}
|
|
513
|
+
this.rule.actions = { modifyResponse: modifyFunction };
|
|
514
|
+
return this.rule;
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
class RuleBuilderRequestInitialized extends RuleBuilderBase {
|
|
518
|
+
modifyResponse(modifyFunction, localVariables) {
|
|
519
|
+
if (!this.rule.actions) {
|
|
520
|
+
throw new Error('rule.actions not defined - builder implementation error');
|
|
521
|
+
}
|
|
522
|
+
if (typeof modifyFunction === 'function') {
|
|
523
|
+
this.rule.actions = { modifyResponse: { localFn: modifyFunction, localVariables: localVariables !== null && localVariables !== void 0 ? localVariables : {} } };
|
|
524
|
+
return this.rule;
|
|
525
|
+
}
|
|
526
|
+
if (localVariables) {
|
|
527
|
+
throw new Error('invalid call - localVariables cannot be used together with Response or RemotableFunction');
|
|
528
|
+
}
|
|
529
|
+
this.rule.actions.modifyResponse = modifyFunction;
|
|
530
|
+
return this.rule;
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
const ruleBuilder = () => new RuleBuilder();
|
|
534
|
+
exports.ruleBuilder = ruleBuilder;
|
|
535
|
+
//# sourceMappingURL=ruleBuilder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ruleBuilder.js","sourceRoot":"","sources":["../src/ruleBuilder.ts"],"names":[],"mappings":";;;AAAA,+BAAoC;AAEpC,6CAA+H;AA4B/H,+CAA+C;AAE/C,MAAM,mBAAmB;IAIrB,YAAY,IAAgC,EAAE,sBAA8C;QACxF,IAAI,CAAC,sBAAsB,GAAG,sBAAsB,IAAI,EAAE,CAAC;QAC3D,IAAI,CAAC,IAAI,GAAG,IAAI,IAAI;YAChB,EAAE,EAAE,IAAA,SAAM,GAAE;YACZ,UAAU,EAAE,iCAAwB;YACpC,QAAQ,EAAE,8BAAqB;YAC/B,OAAO,EAAE;gBACL,YAAY,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE;aAChC;YACD,OAAO,EAAE;gBACL,OAAO,EAAE,CAAC,GAAqB,EAA4B,EAAE;;oBACzD,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;oBAChC,MAAM,UAAU,GAAG,GAAG,CAAC,UAAU,CAAC;oBAElC,MAAM,iBAAiB,GAAG,4BAA4B,CAAC;oBACvD,MAAM,WAAW,GAAG,CAChB,GAAQ,EACR,IAAY,EACZ,KAAiD,EACjD,UAAmB,EACuB,EAAE;;wBAC5C,IAAI,CAAC,GAAG,EAAE;4BACN,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,UAAU,YAAY,EAAE,CAAC;yBACpE;wBACD,MAAM,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;wBAC1C,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cAAc,cAAd,cAAc,GAAI,EAAE,EAAE,EAAE,CAAC;YAC1G,OAAO,IAAI,CAAC,IAAI,CAAC;SACpB;QACD,IAAI,cAAc,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,0FAA0F,CAAC,CAAC;SAC/G;QACD,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,GAAG,cAAc,CAAC;QAClD,OAAO,IAAI,CAAC,IAAI,CAAC;IACrB,CAAC;CACJ;AAEM,MAAM,WAAW,GAAG,GAAG,EAAE,CAAC,IAAI,WAAW,EAAE,CAAC;AAAtC,QAAA,WAAW,eAA2B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stuntman/client",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"description": "Stuntman - HTTP proxy / mock API client",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"repository": {
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"CHANGELOG.md"
|
|
53
53
|
],
|
|
54
54
|
"scripts": {
|
|
55
|
-
"test": "SUPPRESS_NO_CONFIG_WARNING=1 jest",
|
|
55
|
+
"test": "SUPPRESS_NO_CONFIG_WARNING=1 jest --coverage",
|
|
56
56
|
"clean": "rm -fr dist",
|
|
57
57
|
"build": "tsc",
|
|
58
58
|
"lint": "prettier --check \"./{src,test}/**/*\" && eslint \"./{src,test}/**/*\"",
|