@stuntman/shared 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/appError.d.ts +13 -0
- package/dist/appError.d.ts.map +1 -0
- package/dist/appError.js +18 -0
- package/dist/appError.js.map +1 -0
- package/dist/config.d.ts +7 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +61 -0
- package/dist/config.js.map +1 -0
- package/dist/constants.d.ts +16 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +19 -0
- package/dist/constants.js.map +1 -0
- package/dist/escapeStringRegexp.d.ts +2 -0
- package/dist/escapeStringRegexp.d.ts.map +1 -0
- package/dist/escapeStringRegexp.js +6 -0
- package/dist/escapeStringRegexp.js.map +1 -0
- package/dist/gqlParser.d.ts +4 -0
- package/dist/gqlParser.d.ts.map +1 -0
- package/dist/gqlParser.js +48 -0
- package/dist/gqlParser.js.map +1 -0
- package/dist/index.d.ts +184 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +45 -0
- package/dist/index.js.map +1 -0
- package/dist/logger.d.ts +10 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +18 -0
- package/dist/logger.js.map +1 -0
- package/dist/rawHeaders.d.ts +13 -0
- package/dist/rawHeaders.d.ts.map +1 -0
- package/dist/rawHeaders.js +88 -0
- package/dist/rawHeaders.js.map +1 -0
- package/dist/stringify.d.ts +2 -0
- package/dist/stringify.d.ts.map +1 -0
- package/dist/stringify.js +11 -0
- package/dist/stringify.js.map +1 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
1
|
# Stuntman proxy/mock shared library
|
|
2
2
|
|
|
3
|
+
[][npmjs]
|
|
4
|
+
[][build]
|
|
5
|
+
[][coverage]
|
|
6
|
+
|
|
7
|
+
[npmjs]: https://www.npmjs.com/package/@stuntman/shared
|
|
8
|
+
[build]: https://github.com/andrzej-woof/stuntman/actions/workflows/ci.yaml
|
|
9
|
+
[coverage]: https://coveralls.io/github/andrzej-woof/stuntman
|
|
10
|
+
|
|
3
11
|
Shared types and utils for [Stunman](https://github.com/andrzej-woof/stuntman#readme)
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type * as Stuntman from '.';
|
|
2
|
+
export interface AppErrorInterface {
|
|
3
|
+
name?: string;
|
|
4
|
+
httpCode: Stuntman.HttpCode;
|
|
5
|
+
message: string;
|
|
6
|
+
isOperational?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare class AppError extends Error {
|
|
9
|
+
readonly httpCode: Stuntman.HttpCode;
|
|
10
|
+
readonly isOperational: boolean;
|
|
11
|
+
constructor(args: AppErrorInterface);
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=appError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"appError.d.ts","sourceRoot":"","sources":["../src/appError.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,QAAQ,MAAM,GAAG,CAAC;AAEnC,MAAM,WAAW,iBAAiB;IAC9B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,QAAQ,CAAC,QAAQ,CAAC;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,qBAAa,QAAS,SAAQ,KAAK;IAC/B,SAAgB,QAAQ,EAAE,QAAQ,CAAC,QAAQ,CAAC;IAC5C,SAAgB,aAAa,EAAE,OAAO,CAAQ;gBAElC,IAAI,EAAE,iBAAiB;CActC"}
|
package/dist/appError.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AppError = void 0;
|
|
4
|
+
class AppError extends Error {
|
|
5
|
+
constructor(args) {
|
|
6
|
+
super(args.message);
|
|
7
|
+
this.isOperational = true;
|
|
8
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
9
|
+
this.name = args.name || 'Error';
|
|
10
|
+
this.httpCode = args.httpCode;
|
|
11
|
+
if (args.isOperational !== undefined) {
|
|
12
|
+
this.isOperational = args.isOperational;
|
|
13
|
+
}
|
|
14
|
+
Error.captureStackTrace(this);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.AppError = AppError;
|
|
18
|
+
//# sourceMappingURL=appError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"appError.js","sourceRoot":"","sources":["../src/appError.ts"],"names":[],"mappings":";;;AASA,MAAa,QAAS,SAAQ,KAAK;IAI/B,YAAY,IAAuB;QAC/B,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAHR,kBAAa,GAAY,IAAI,CAAC;QAK1C,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAElD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,IAAI,OAAO,CAAC;QACjC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;QAE9B,IAAI,IAAI,CAAC,aAAa,KAAK,SAAS,EAAE;YAClC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC;SAC3C;QAED,KAAK,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC;CACJ;AAlBD,4BAkBC"}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,MAAM,EAST,MAAM,GAAG,CAAC;AAwCX,cAAM,aAAa;IACf,IAAI,cAAc,IAAI,MAAM,CAc3B;CACJ;AACD,QAAA,MAAM,aAAa,eAAsB,CAAC;AAE1C,SAAS,aAAa,CAAC"}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
const _1 = require(".");
|
|
6
|
+
const config_1 = __importDefault(require("config"));
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
// TODO safeguards & defaults
|
|
9
|
+
const defaultConfig = {
|
|
10
|
+
api: {
|
|
11
|
+
disabled: false,
|
|
12
|
+
port: _1.DEFAULT_API_PORT,
|
|
13
|
+
apiKeyReadOnly: null,
|
|
14
|
+
apiKeyReadWrite: null,
|
|
15
|
+
},
|
|
16
|
+
mock: {
|
|
17
|
+
domain: _1.DEFAULT_MOCK_DOMAIN,
|
|
18
|
+
externalDns: _1.EXTERNAL_DNS,
|
|
19
|
+
port: _1.DEFAULT_MOCK_PORT,
|
|
20
|
+
timeout: _1.DEFAULT_PROXY_TIMEOUT,
|
|
21
|
+
rulesPath: path_1.default.join(process.cwd(), 'rules'),
|
|
22
|
+
},
|
|
23
|
+
storage: {
|
|
24
|
+
traffic: {
|
|
25
|
+
limitCount: _1.DEFAULT_CACHE_MAX_ENTRIES,
|
|
26
|
+
limitSize: _1.DEFAULT_CACHE_MAX_SIZE,
|
|
27
|
+
ttl: _1.DEFAULT_CACHE_TTL,
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
webgui: {
|
|
31
|
+
disabled: false,
|
|
32
|
+
},
|
|
33
|
+
client: {
|
|
34
|
+
timeout: 60000,
|
|
35
|
+
host: 'localhost',
|
|
36
|
+
protocol: 'http',
|
|
37
|
+
port: _1.DEFAULT_API_PORT,
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
let configFromFile = null;
|
|
41
|
+
class ConfigWrapper {
|
|
42
|
+
get stuntmanConfig() {
|
|
43
|
+
if (!configFromFile) {
|
|
44
|
+
config_1.default.util.setModuleDefaults('stuntman', defaultConfig);
|
|
45
|
+
try {
|
|
46
|
+
configFromFile = config_1.default.get('stuntman');
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
// eslint-disable-next-line no-console
|
|
50
|
+
console.warn('unable to find correct config - starting with defaults');
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (!configFromFile) {
|
|
54
|
+
throw new Error('error getting config');
|
|
55
|
+
}
|
|
56
|
+
return configFromFile;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
const configWrapper = new ConfigWrapper();
|
|
60
|
+
module.exports = configWrapper;
|
|
61
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";;;;AAAA,wBAUW;AACX,oDAA4B;AAC5B,gDAAwB;AAExB,6BAA6B;AAE7B,MAAM,aAAa,GAAW;IAC1B,GAAG,EAAE;QACD,QAAQ,EAAE,KAAK;QACf,IAAI,EAAE,mBAAgB;QACtB,cAAc,EAAE,IAAI;QACpB,eAAe,EAAE,IAAI;KACxB;IACD,IAAI,EAAE;QACF,MAAM,EAAE,sBAAmB;QAC3B,WAAW,EAAE,eAAY;QACzB,IAAI,EAAE,oBAAiB;QACvB,OAAO,EAAE,wBAAqB;QAC9B,SAAS,EAAE,cAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,OAAO,CAAC;KAC/C;IACD,OAAO,EAAE;QACL,OAAO,EAAE;YACL,UAAU,EAAE,4BAAyB;YACrC,SAAS,EAAE,yBAAsB;YACjC,GAAG,EAAE,oBAAiB;SACzB;KACJ;IACD,MAAM,EAAE;QACJ,QAAQ,EAAE,KAAK;KAClB;IACD,MAAM,EAAE;QACJ,OAAO,EAAE,KAAK;QACd,IAAI,EAAE,WAAW;QACjB,QAAQ,EAAE,MAAM;QAChB,IAAI,EAAE,mBAAgB;KACzB;CACJ,CAAC;AAEF,IAAI,cAAc,GAAkB,IAAI,CAAC;AAEzC,MAAM,aAAa;IACf,IAAI,cAAc;QACd,IAAI,CAAC,cAAc,EAAE;YACjB,gBAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC;YACzD,IAAI;gBACA,cAAc,GAAG,gBAAM,CAAC,GAAG,CAAS,UAAU,CAAC,CAAC;aACnD;YAAC,OAAO,KAAK,EAAE;gBACZ,sCAAsC;gBACtC,OAAO,CAAC,IAAI,CAAC,wDAAwD,CAAC,CAAC;aAC1E;SACJ;QACD,IAAI,CAAC,cAAc,EAAE;YACjB,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;SAC3C;QACD,OAAO,cAAc,CAAC;IAC1B,CAAC;CACJ;AACD,MAAM,aAAa,GAAG,IAAI,aAAa,EAAE,CAAC;AAE1C,iBAAS,aAAa,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare const DEFAULT_PROXY_TIMEOUT = 60000;
|
|
2
|
+
export declare const DEFAULT_RULE_PRIORITY = 100;
|
|
3
|
+
export declare const DEFAULT_MOCK_PORT = 2015;
|
|
4
|
+
export declare const DEFAULT_API_PORT = 1985;
|
|
5
|
+
export declare const DEFAULT_CACHE_MAX_ENTRIES = 500;
|
|
6
|
+
export declare const DEFAULT_CACHE_MAX_SIZE: number;
|
|
7
|
+
export declare const DEFAULT_CACHE_TTL: number;
|
|
8
|
+
export declare const DEFAULT_MOCK_DOMAIN = "stuntman";
|
|
9
|
+
export declare const DEFAULT_RULE_TTL_SECONDS: number;
|
|
10
|
+
export declare const MIN_RULE_TTL_SECONDS = 10;
|
|
11
|
+
export declare const MAX_RULE_TTL_SECONDS: number;
|
|
12
|
+
export declare const CATCH_ALL_RULE_PRIORITY: number;
|
|
13
|
+
export declare const CATCH_RULE_NAME = "internal/catch-all";
|
|
14
|
+
export declare const EXTERNAL_DNS: string[];
|
|
15
|
+
export declare const VALID_HOSTNAME_REGEX: RegExp;
|
|
16
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qBAAqB,QAAQ,CAAC;AAC3C,eAAO,MAAM,qBAAqB,MAAM,CAAC;AACzC,eAAO,MAAM,iBAAiB,OAAO,CAAC;AACtC,eAAO,MAAM,gBAAgB,OAAO,CAAC;AACrC,eAAO,MAAM,yBAAyB,MAAM,CAAC;AAC7C,eAAO,MAAM,sBAAsB,QAAoB,CAAC;AACxD,eAAO,MAAM,iBAAiB,QAAiB,CAAC;AAChD,eAAO,MAAM,mBAAmB,aAAa,CAAC;AAC9C,eAAO,MAAM,wBAAwB,QAAU,CAAC;AAChD,eAAO,MAAM,oBAAoB,KAAK,CAAC;AACvC,eAAO,MAAM,oBAAoB,QAAU,CAAC;AAC5C,eAAO,MAAM,uBAAuB,QAAW,CAAC;AAChD,eAAO,MAAM,eAAe,uBAAuB,CAAC;AACpD,eAAO,MAAM,YAAY,UAAyB,CAAC;AACnD,eAAO,MAAM,oBAAoB,QAA2F,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VALID_HOSTNAME_REGEX = exports.EXTERNAL_DNS = exports.CATCH_RULE_NAME = exports.CATCH_ALL_RULE_PRIORITY = exports.MAX_RULE_TTL_SECONDS = exports.MIN_RULE_TTL_SECONDS = exports.DEFAULT_RULE_TTL_SECONDS = exports.DEFAULT_MOCK_DOMAIN = exports.DEFAULT_CACHE_TTL = exports.DEFAULT_CACHE_MAX_SIZE = exports.DEFAULT_CACHE_MAX_ENTRIES = exports.DEFAULT_API_PORT = exports.DEFAULT_MOCK_PORT = exports.DEFAULT_RULE_PRIORITY = exports.DEFAULT_PROXY_TIMEOUT = void 0;
|
|
4
|
+
exports.DEFAULT_PROXY_TIMEOUT = 60000;
|
|
5
|
+
exports.DEFAULT_RULE_PRIORITY = 100;
|
|
6
|
+
exports.DEFAULT_MOCK_PORT = 2015;
|
|
7
|
+
exports.DEFAULT_API_PORT = 1985;
|
|
8
|
+
exports.DEFAULT_CACHE_MAX_ENTRIES = 500;
|
|
9
|
+
exports.DEFAULT_CACHE_MAX_SIZE = 500 * 1024 * 1024;
|
|
10
|
+
exports.DEFAULT_CACHE_TTL = 1000 * 60 * 60;
|
|
11
|
+
exports.DEFAULT_MOCK_DOMAIN = 'stuntman';
|
|
12
|
+
exports.DEFAULT_RULE_TTL_SECONDS = 60 * 10;
|
|
13
|
+
exports.MIN_RULE_TTL_SECONDS = 10;
|
|
14
|
+
exports.MAX_RULE_TTL_SECONDS = 60 * 60;
|
|
15
|
+
exports.CATCH_ALL_RULE_PRIORITY = Infinity;
|
|
16
|
+
exports.CATCH_RULE_NAME = 'internal/catch-all';
|
|
17
|
+
exports.EXTERNAL_DNS = ['8.8.8.8', '1.1.1.1'];
|
|
18
|
+
exports.VALID_HOSTNAME_REGEX = /^(([a-z0-9]|[a-z0-9][a-z0-9\\-]*[a-z0-9])\.)*([a-z0-9]|[a-z0-9][a-z0-9\\-]*[a-z0-9])$/i;
|
|
19
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,qBAAqB,GAAG,KAAK,CAAC;AAC9B,QAAA,qBAAqB,GAAG,GAAG,CAAC;AAC5B,QAAA,iBAAiB,GAAG,IAAI,CAAC;AACzB,QAAA,gBAAgB,GAAG,IAAI,CAAC;AACxB,QAAA,yBAAyB,GAAG,GAAG,CAAC;AAChC,QAAA,sBAAsB,GAAG,GAAG,GAAG,IAAI,GAAG,IAAI,CAAC;AAC3C,QAAA,iBAAiB,GAAG,IAAI,GAAG,EAAE,GAAG,EAAE,CAAC;AACnC,QAAA,mBAAmB,GAAG,UAAU,CAAC;AACjC,QAAA,wBAAwB,GAAG,EAAE,GAAG,EAAE,CAAC;AACnC,QAAA,oBAAoB,GAAG,EAAE,CAAC;AAC1B,QAAA,oBAAoB,GAAG,EAAE,GAAG,EAAE,CAAC;AAC/B,QAAA,uBAAuB,GAAG,QAAQ,CAAC;AACnC,QAAA,eAAe,GAAG,oBAAoB,CAAC;AACvC,QAAA,YAAY,GAAG,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;AACtC,QAAA,oBAAoB,GAAG,wFAAwF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"escapeStringRegexp.d.ts","sourceRoot":"","sources":["../src/escapeStringRegexp.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB,UAAW,MAAM,WAAwE,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.escapeStringRegexp = void 0;
|
|
4
|
+
const escapeStringRegexp = (input) => input.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&').replace(/-/g, '\\x2d');
|
|
5
|
+
exports.escapeStringRegexp = escapeStringRegexp;
|
|
6
|
+
//# sourceMappingURL=escapeStringRegexp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"escapeStringRegexp.js","sourceRoot":"","sources":["../src/escapeStringRegexp.ts"],"names":[],"mappings":";;;AAAO,MAAM,kBAAkB,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AAA5G,QAAA,kBAAkB,sBAA0F"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gqlParser.d.ts","sourceRoot":"","sources":["../src/gqlParser.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,QAAQ,MAAM,SAAS,CAAC;AAGzC,eAAO,MAAM,cAAc,SAAU,MAAM,GAAG,MAAM,KAAG,SAAS,cAAc,GAAG,SAoChF,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.naiveGQLParser = void 0;
|
|
4
|
+
const logger_1 = require("./logger");
|
|
5
|
+
const naiveGQLParser = (body) => {
|
|
6
|
+
// TODO consider real parser :P
|
|
7
|
+
try {
|
|
8
|
+
let json = undefined;
|
|
9
|
+
try {
|
|
10
|
+
json = JSON.parse(Buffer.isBuffer(body) ? body.toString('utf-8') : body);
|
|
11
|
+
}
|
|
12
|
+
catch (kiss) {
|
|
13
|
+
// and swallow
|
|
14
|
+
}
|
|
15
|
+
if (!(json === null || json === void 0 ? void 0 : json.query) && !(json === null || json === void 0 ? void 0 : json.operationName)) {
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
const lines = json.query
|
|
19
|
+
.split('\n')
|
|
20
|
+
.map((l) => l.replace(/^\s+/g, '').trim())
|
|
21
|
+
.filter((l) => !!l);
|
|
22
|
+
if (!lines[0]) {
|
|
23
|
+
throw new Error('unable to find query');
|
|
24
|
+
}
|
|
25
|
+
if (/^query /.test(lines[0])) {
|
|
26
|
+
json.type = 'query';
|
|
27
|
+
}
|
|
28
|
+
else if (/^mutation /.test(lines[0])) {
|
|
29
|
+
json.type = 'mutation';
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
throw new Error(`Unable to resolve query type of ${lines[0]}`);
|
|
33
|
+
}
|
|
34
|
+
if (json.operationName && lines[1]) {
|
|
35
|
+
json.methodName = lines[1].split('(')[0].split('{')[0];
|
|
36
|
+
}
|
|
37
|
+
else if (json.operationName) {
|
|
38
|
+
json.methodName = lines[0].split('(')[0].split('{')[0];
|
|
39
|
+
}
|
|
40
|
+
return json;
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
logger_1.logger.debug(error, 'unable to parse GQL');
|
|
44
|
+
}
|
|
45
|
+
return undefined;
|
|
46
|
+
};
|
|
47
|
+
exports.naiveGQLParser = naiveGQLParser;
|
|
48
|
+
//# sourceMappingURL=gqlParser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gqlParser.js","sourceRoot":"","sources":["../src/gqlParser.ts"],"names":[],"mappings":";;;AACA,qCAAkC;AAE3B,MAAM,cAAc,GAAG,CAAC,IAAqB,EAAuC,EAAE;IACzF,+BAA+B;IAC/B,IAAI;QACA,IAAI,IAAI,GAAwC,SAAS,CAAC;QAC1D,IAAI;YACA,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;SAC5E;QAAC,OAAO,IAAI,EAAE;YACX,cAAc;SACjB;QACD,IAAI,CAAC,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,KAAK,CAAA,IAAI,CAAC,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,aAAa,CAAA,EAAE;YACtC,OAAO,SAAS,CAAC;SACpB;QACD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK;aACnB,KAAK,CAAC,IAAI,CAAC;aACX,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;aACzC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACxB,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE;YACX,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;SAC3C;QACD,IAAI,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE;YAC1B,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC;SACvB;aAAM,IAAI,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE;YACpC,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;SAC1B;aAAM;YACH,MAAM,IAAI,KAAK,CAAC,mCAAmC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;SAClE;QACD,IAAI,IAAI,CAAC,aAAa,IAAI,KAAK,CAAC,CAAC,CAAC,EAAE;YAChC,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAE,CAAC;SAC5D;aAAM,IAAI,IAAI,CAAC,aAAa,EAAE;YAC3B,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAE,CAAC;SAC5D;QACD,OAAO,IAAI,CAAC;KACf;IAAC,OAAO,KAAK,EAAE;QACZ,eAAM,CAAC,KAAK,CAAC,KAAK,EAAE,qBAAqB,CAAC,CAAC;KAC9C;IACD,OAAO,SAAS,CAAC;AACrB,CAAC,CAAC;AApCW,QAAA,cAAc,kBAoCzB"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
export * from './constants';
|
|
2
|
+
export * from './appError';
|
|
3
|
+
export * from './logger';
|
|
4
|
+
export * from './stringify';
|
|
5
|
+
export * from './rawHeaders';
|
|
6
|
+
export * from './gqlParser';
|
|
7
|
+
export * from './escapeStringRegexp';
|
|
8
|
+
export declare const stuntmanConfig: Config;
|
|
9
|
+
export declare const INDEX_DTS: string;
|
|
10
|
+
type NonObject = string | number | boolean | symbol | undefined | null | any[];
|
|
11
|
+
interface SerializableTypesRecord<T> {
|
|
12
|
+
[k: string | number]: T;
|
|
13
|
+
}
|
|
14
|
+
export type RecursivePartial<T> = {
|
|
15
|
+
[P in keyof T]?: T[P] extends (infer U)[] ? RecursivePartial<U>[] : T[P] extends object ? RecursivePartial<T[P]> : T[P];
|
|
16
|
+
};
|
|
17
|
+
type SerializableTypes = string | number | boolean | undefined | null | RegExp | SerializableTypes[] | SerializableTypesRecord<SerializableTypes>;
|
|
18
|
+
export declare enum HttpCode {
|
|
19
|
+
OK = 200,
|
|
20
|
+
NO_CONTENT = 204,
|
|
21
|
+
BAD_REQUEST = 400,
|
|
22
|
+
UNAUTHORIZED = 401,
|
|
23
|
+
NOT_FOUND = 404,
|
|
24
|
+
CONFLICT = 409,
|
|
25
|
+
UNPROCESSABLE_ENTITY = 422,
|
|
26
|
+
INTERNAL_SERVER_ERROR = 500
|
|
27
|
+
}
|
|
28
|
+
export type LocalVariables = Record<string, SerializableTypes>;
|
|
29
|
+
export type RuleMatchResult = boolean | {
|
|
30
|
+
result: boolean;
|
|
31
|
+
enableRuleIds?: string[];
|
|
32
|
+
disableRuleIds?: string[];
|
|
33
|
+
description?: string;
|
|
34
|
+
};
|
|
35
|
+
export type RemotableFunction<T extends Function> = {
|
|
36
|
+
localFn: T;
|
|
37
|
+
localVariables?: LocalVariables;
|
|
38
|
+
};
|
|
39
|
+
export type SerializedRemotableFunction = {
|
|
40
|
+
localFn: string;
|
|
41
|
+
localVariables?: string;
|
|
42
|
+
remoteFn: string;
|
|
43
|
+
};
|
|
44
|
+
type WithRemotableFunctions<Type> = {
|
|
45
|
+
[PropertyKey in keyof Type]: Extract<Type[PropertyKey], Function> extends never ? Exclude<Type[PropertyKey], NonObject> extends never ? Type[PropertyKey] : WithRemotableFunctions<Exclude<Type[PropertyKey], NonObject>> : Exclude<Type[PropertyKey], Function> | RemotableFunction<Extract<Type[PropertyKey], Function>>;
|
|
46
|
+
};
|
|
47
|
+
export type WithSerializedFunctions<Type> = {
|
|
48
|
+
[PropertyKey in keyof Type]: Extract<Type[PropertyKey], RemotableFunction<Function>> extends never ? Exclude<Type[PropertyKey], NonObject> extends never ? Type[PropertyKey] : WithSerializedFunctions<Exclude<Type[PropertyKey], NonObject>> : Exclude<Type[PropertyKey], RemotableFunction<Function>> | SerializedRemotableFunction;
|
|
49
|
+
};
|
|
50
|
+
export interface RawHeadersInterface extends Array<string> {
|
|
51
|
+
get: (name: string) => string | undefined;
|
|
52
|
+
set: (name: string, value: string) => void;
|
|
53
|
+
has: (name: string, value?: string) => boolean;
|
|
54
|
+
add: (name: string, value: string) => void;
|
|
55
|
+
remove: (name: string) => void;
|
|
56
|
+
toHeaderPairs: () => readonly [string, string][];
|
|
57
|
+
}
|
|
58
|
+
export type BaseRequest = {
|
|
59
|
+
rawHeaders: RawHeadersInterface;
|
|
60
|
+
url: string;
|
|
61
|
+
body?: any;
|
|
62
|
+
method: string;
|
|
63
|
+
};
|
|
64
|
+
export type Request = BaseRequest & {
|
|
65
|
+
id: string;
|
|
66
|
+
timestamp: number;
|
|
67
|
+
gqlBody?: GQLRequestBody | undefined;
|
|
68
|
+
};
|
|
69
|
+
export type Response = {
|
|
70
|
+
rawHeaders?: RawHeadersInterface;
|
|
71
|
+
status?: number;
|
|
72
|
+
body?: any;
|
|
73
|
+
timestamp?: number;
|
|
74
|
+
};
|
|
75
|
+
export type LogEntry = {
|
|
76
|
+
originalRequest: Request;
|
|
77
|
+
labels?: string[] | undefined;
|
|
78
|
+
mockRuleId?: string;
|
|
79
|
+
originalResponse?: Response;
|
|
80
|
+
modifiedRequest?: Request;
|
|
81
|
+
modifiedResponse?: Response;
|
|
82
|
+
};
|
|
83
|
+
export type RuleMatchFunction = (request: Request) => RuleMatchResult;
|
|
84
|
+
export type RequestManipulationFn = (request: Request) => Request;
|
|
85
|
+
export type ResponseManipulationFn = (request: Request, response: Response) => Response;
|
|
86
|
+
export type ResponseGenerationFn = (request: Request) => Response;
|
|
87
|
+
export type Actions = {
|
|
88
|
+
proxyPass: true;
|
|
89
|
+
mockResponse?: undefined;
|
|
90
|
+
modifyRequest?: undefined;
|
|
91
|
+
modifyResponse?: undefined;
|
|
92
|
+
} | {
|
|
93
|
+
mockResponse: Response | ResponseGenerationFn;
|
|
94
|
+
proxyPass?: undefined;
|
|
95
|
+
modifyRequest?: undefined;
|
|
96
|
+
modifyResponse?: undefined;
|
|
97
|
+
} | {
|
|
98
|
+
modifyRequest: RequestManipulationFn;
|
|
99
|
+
modifyResponse?: ResponseManipulationFn;
|
|
100
|
+
proxyPass?: true | undefined;
|
|
101
|
+
mockResponse?: undefined;
|
|
102
|
+
} | {
|
|
103
|
+
modifyRequest?: RequestManipulationFn;
|
|
104
|
+
modifyResponse: ResponseManipulationFn;
|
|
105
|
+
proxyPass?: true | undefined;
|
|
106
|
+
mockResponse?: undefined;
|
|
107
|
+
};
|
|
108
|
+
export type Rule = {
|
|
109
|
+
id: string;
|
|
110
|
+
priority?: number;
|
|
111
|
+
matches: RuleMatchFunction;
|
|
112
|
+
labels?: string[];
|
|
113
|
+
actions: Actions;
|
|
114
|
+
disableAfterUse?: boolean | number;
|
|
115
|
+
removeAfterUse?: boolean | number;
|
|
116
|
+
ttlSeconds: number;
|
|
117
|
+
storeTraffic?: boolean;
|
|
118
|
+
isEnabled?: boolean;
|
|
119
|
+
};
|
|
120
|
+
export type DeployedRule = Omit<Rule, 'disableAfterUse' | 'removeAfterUse' | 'ttlSeconds'>;
|
|
121
|
+
export type SerializableRule = WithRemotableFunctions<Rule>;
|
|
122
|
+
export type SerializedRule = WithSerializedFunctions<SerializableRule>;
|
|
123
|
+
export type LiveRule = Rule & {
|
|
124
|
+
counter: number;
|
|
125
|
+
createdTimestamp: number;
|
|
126
|
+
};
|
|
127
|
+
export type GQLRequestBody = {
|
|
128
|
+
operationName: string;
|
|
129
|
+
variables?: any;
|
|
130
|
+
query: string;
|
|
131
|
+
type: 'query' | 'mutation';
|
|
132
|
+
methodName?: string;
|
|
133
|
+
};
|
|
134
|
+
export type WebGuiConfig = {
|
|
135
|
+
disabled: boolean;
|
|
136
|
+
};
|
|
137
|
+
export type ApiConfig = {
|
|
138
|
+
port: number;
|
|
139
|
+
disabled: boolean;
|
|
140
|
+
apiKeyReadWrite: string | null;
|
|
141
|
+
apiKeyReadOnly: string | null;
|
|
142
|
+
};
|
|
143
|
+
export type ClientConfig = {
|
|
144
|
+
protocol: 'http' | 'https';
|
|
145
|
+
host: string;
|
|
146
|
+
port: number;
|
|
147
|
+
timeout: number;
|
|
148
|
+
apiKey?: string;
|
|
149
|
+
};
|
|
150
|
+
export type MockConfig = {
|
|
151
|
+
domain: string;
|
|
152
|
+
port: number;
|
|
153
|
+
httpsPort?: number;
|
|
154
|
+
httpsKey?: string;
|
|
155
|
+
httpsCert?: string;
|
|
156
|
+
timeout: number;
|
|
157
|
+
externalDns: string[];
|
|
158
|
+
rulesPath: string;
|
|
159
|
+
disableProxy?: boolean;
|
|
160
|
+
};
|
|
161
|
+
export type StorageConfig = {
|
|
162
|
+
limitCount: number;
|
|
163
|
+
limitSize: number;
|
|
164
|
+
ttl: number;
|
|
165
|
+
};
|
|
166
|
+
export type Config = {
|
|
167
|
+
webgui: WebGuiConfig;
|
|
168
|
+
api: ApiConfig;
|
|
169
|
+
mock: MockConfig;
|
|
170
|
+
storage: {
|
|
171
|
+
traffic: StorageConfig;
|
|
172
|
+
};
|
|
173
|
+
client: ClientConfig;
|
|
174
|
+
};
|
|
175
|
+
export interface RuleExecutorInterface {
|
|
176
|
+
addRule: (rule: Rule, overwrite?: boolean) => Promise<LiveRule>;
|
|
177
|
+
removeRule: (id: string) => Promise<void>;
|
|
178
|
+
enableRule: (id: string) => void;
|
|
179
|
+
disableRule: (id: string) => void;
|
|
180
|
+
findMatchingRule: (request: Request) => Promise<LiveRule | null>;
|
|
181
|
+
getRules: () => Promise<readonly LiveRule[]>;
|
|
182
|
+
getRule: (id: string) => Promise<LiveRule | undefined>;
|
|
183
|
+
}
|
|
184
|
+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AAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1C,UAAU,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC,WAAW,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,gBAAgB,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC;IACjE,QAAQ,EAAE,MAAM,OAAO,CAAC,SAAS,QAAQ,EAAE,CAAC,CAAC;IAC7C,OAAO,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,QAAQ,GAAG,SAAS,CAAC,CAAC;CAC1D"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.HttpCode = exports.INDEX_DTS = exports.stuntmanConfig = void 0;
|
|
21
|
+
/* eslint-disable @typescript-eslint/ban-types */
|
|
22
|
+
__exportStar(require("./constants"), exports);
|
|
23
|
+
__exportStar(require("./appError"), exports);
|
|
24
|
+
__exportStar(require("./logger"), exports);
|
|
25
|
+
__exportStar(require("./stringify"), exports);
|
|
26
|
+
__exportStar(require("./rawHeaders"), exports);
|
|
27
|
+
__exportStar(require("./gqlParser"), exports);
|
|
28
|
+
__exportStar(require("./escapeStringRegexp"), exports);
|
|
29
|
+
const fs_1 = __importDefault(require("fs"));
|
|
30
|
+
const config_1 = __importDefault(require("./config"));
|
|
31
|
+
exports.stuntmanConfig = config_1.default.stuntmanConfig;
|
|
32
|
+
// TODO this file read sucks
|
|
33
|
+
exports.INDEX_DTS = fs_1.default.readFileSync(`${__dirname}/index.d.ts`, 'utf-8');
|
|
34
|
+
var HttpCode;
|
|
35
|
+
(function (HttpCode) {
|
|
36
|
+
HttpCode[HttpCode["OK"] = 200] = "OK";
|
|
37
|
+
HttpCode[HttpCode["NO_CONTENT"] = 204] = "NO_CONTENT";
|
|
38
|
+
HttpCode[HttpCode["BAD_REQUEST"] = 400] = "BAD_REQUEST";
|
|
39
|
+
HttpCode[HttpCode["UNAUTHORIZED"] = 401] = "UNAUTHORIZED";
|
|
40
|
+
HttpCode[HttpCode["NOT_FOUND"] = 404] = "NOT_FOUND";
|
|
41
|
+
HttpCode[HttpCode["CONFLICT"] = 409] = "CONFLICT";
|
|
42
|
+
HttpCode[HttpCode["UNPROCESSABLE_ENTITY"] = 422] = "UNPROCESSABLE_ENTITY";
|
|
43
|
+
HttpCode[HttpCode["INTERNAL_SERVER_ERROR"] = 500] = "INTERNAL_SERVER_ERROR";
|
|
44
|
+
})(HttpCode = exports.HttpCode || (exports.HttpCode = {}));
|
|
45
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,iDAAiD;AACjD,8CAA4B;AAC5B,6CAA2B;AAC3B,2CAAyB;AACzB,8CAA4B;AAC5B,+CAA6B;AAC7B,8CAA4B;AAC5B,uDAAqC;AACrC,4CAAoB;AAEpB,sDAA8B;AACjB,QAAA,cAAc,GAAG,gBAAM,CAAC,cAAc,CAAC;AAEpD,4BAA4B;AACf,QAAA,SAAS,GAAG,YAAE,CAAC,YAAY,CAAC,GAAG,SAAS,aAAa,EAAE,OAAO,CAAC,CAAC;AAsB7E,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"}
|
package/dist/logger.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,MAAM;;;;;;;;EAQjB,CAAC"}
|
package/dist/logger.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
var _a;
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.logger = void 0;
|
|
8
|
+
const pino_1 = __importDefault(require("pino"));
|
|
9
|
+
exports.logger = (0, pino_1.default)({
|
|
10
|
+
level: (_a = process.env.LOG_LEVEL) !== null && _a !== void 0 ? _a : 'info',
|
|
11
|
+
messageKey: 'message',
|
|
12
|
+
formatters: {
|
|
13
|
+
level(label) {
|
|
14
|
+
return { level: label };
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":";;;;;;;AAAA,gDAAwB;AAEX,QAAA,MAAM,GAAG,IAAA,cAAI,EAAC;IACvB,KAAK,EAAE,MAAA,OAAO,CAAC,GAAG,CAAC,SAAS,mCAAI,MAAM;IACtC,UAAU,EAAE,SAAS;IACrB,UAAU,EAAE;QACR,KAAK,CAAC,KAAK;YACP,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;QAC5B,CAAC;KACJ;CACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type * as Stuntman from '.';
|
|
2
|
+
export declare class RawHeaders extends Array<string> implements Stuntman.RawHeadersInterface {
|
|
3
|
+
get(name: string): string | undefined;
|
|
4
|
+
has(name: string, value?: string): boolean;
|
|
5
|
+
set(name: string, value: string): void;
|
|
6
|
+
add(name: string, value: string): void;
|
|
7
|
+
remove(name: string): void;
|
|
8
|
+
toHeaderPairs(): readonly [string, string][];
|
|
9
|
+
static fromHeaderPairs(headerPairs: [string, string][]): RawHeaders;
|
|
10
|
+
static fromHeadersRecord(headersRecord: Record<string, string | string[] | undefined>): RawHeaders;
|
|
11
|
+
static toHeaderPairs(rawHeaders: string[]): readonly [string, string][];
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=rawHeaders.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rawHeaders.d.ts","sourceRoot":"","sources":["../src/rawHeaders.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,QAAQ,MAAM,GAAG,CAAC;AAEnC,qBAAa,UAAW,SAAQ,KAAK,CAAC,MAAM,CAAE,YAAW,QAAQ,CAAC,mBAAmB;IACjF,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAYrC,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO;IAQ1C,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAiBtC,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAKtC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAe1B,aAAa,IAAI,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE;IAI5C,MAAM,CAAC,eAAe,CAAC,WAAW,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,GAAG,UAAU;IAInE,MAAM,CAAC,iBAAiB,CAAC,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC,GAAG,UAAU;IAclG,MAAM,CAAC,aAAa,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE;CAO1E"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RawHeaders = void 0;
|
|
4
|
+
class RawHeaders extends Array {
|
|
5
|
+
get(name) {
|
|
6
|
+
var _a;
|
|
7
|
+
const headers = this.toHeaderPairs();
|
|
8
|
+
const matchingHeaders = headers.filter((h) => h[0].toLowerCase() === name.toLowerCase());
|
|
9
|
+
if (matchingHeaders.length === 0) {
|
|
10
|
+
return undefined;
|
|
11
|
+
}
|
|
12
|
+
if (matchingHeaders.length === 1) {
|
|
13
|
+
return (_a = matchingHeaders[0]) === null || _a === void 0 ? void 0 : _a[1];
|
|
14
|
+
}
|
|
15
|
+
throw new Error('Multiple headers with same name. Manipulate rawHeaders instead');
|
|
16
|
+
}
|
|
17
|
+
has(name, value) {
|
|
18
|
+
const foundValue = this.get(name);
|
|
19
|
+
if (value === undefined) {
|
|
20
|
+
return foundValue !== undefined;
|
|
21
|
+
}
|
|
22
|
+
return foundValue === value;
|
|
23
|
+
}
|
|
24
|
+
set(name, value) {
|
|
25
|
+
var _a;
|
|
26
|
+
let foundHeaders = 0;
|
|
27
|
+
for (let headerIndex = 0; headerIndex < this.length; headerIndex += 2) {
|
|
28
|
+
if (((_a = this[headerIndex]) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === name.toLowerCase()) {
|
|
29
|
+
this[headerIndex + 1] = value;
|
|
30
|
+
++foundHeaders;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if (foundHeaders === 0) {
|
|
34
|
+
this.add(name, value);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
if (foundHeaders > 1) {
|
|
38
|
+
throw new Error('Multiple headers with same name. Manipulate rawHeaders instead');
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
add(name, value) {
|
|
42
|
+
this.push(name);
|
|
43
|
+
this.push(value);
|
|
44
|
+
}
|
|
45
|
+
remove(name) {
|
|
46
|
+
var _a;
|
|
47
|
+
const headersCopy = [...this];
|
|
48
|
+
let foundHeaders = 0;
|
|
49
|
+
for (let headerIndex = 0; headerIndex < headersCopy.length; headerIndex += 2) {
|
|
50
|
+
if (((_a = this[headerIndex - foundHeaders * 2]) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === name.toLowerCase()) {
|
|
51
|
+
delete this[headerIndex];
|
|
52
|
+
delete this[headerIndex];
|
|
53
|
+
++foundHeaders;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
if (foundHeaders > 1) {
|
|
57
|
+
throw new Error('Multiple headers with same name. Manipulate rawHeaders instead');
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
toHeaderPairs() {
|
|
61
|
+
return RawHeaders.toHeaderPairs(this);
|
|
62
|
+
}
|
|
63
|
+
static fromHeaderPairs(headerPairs) {
|
|
64
|
+
return new RawHeaders(...headerPairs.flatMap((x) => x));
|
|
65
|
+
}
|
|
66
|
+
static fromHeadersRecord(headersRecord) {
|
|
67
|
+
const output = new RawHeaders();
|
|
68
|
+
for (const [key, value] of Object.entries(headersRecord)) {
|
|
69
|
+
if (typeof value === 'string' || value === undefined) {
|
|
70
|
+
output.add(key, value !== null && value !== void 0 ? value : '');
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
for (const subValue of value) {
|
|
74
|
+
output.add(key, subValue);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return output;
|
|
78
|
+
}
|
|
79
|
+
static toHeaderPairs(rawHeaders) {
|
|
80
|
+
const headers = new Array();
|
|
81
|
+
for (let headerIndex = 0; headerIndex < rawHeaders.length; headerIndex += 2) {
|
|
82
|
+
headers.push([rawHeaders[headerIndex], rawHeaders[headerIndex + 1]]);
|
|
83
|
+
}
|
|
84
|
+
return headers;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
exports.RawHeaders = RawHeaders;
|
|
88
|
+
//# sourceMappingURL=rawHeaders.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rawHeaders.js","sourceRoot":"","sources":["../src/rawHeaders.ts"],"names":[],"mappings":";;;AAEA,MAAa,UAAW,SAAQ,KAAa;IACzC,GAAG,CAAC,IAAY;;QACZ,MAAM,OAAO,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;QACrC,MAAM,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,KAAK,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;QACzF,IAAI,eAAe,CAAC,MAAM,KAAK,CAAC,EAAE;YAC9B,OAAO,SAAS,CAAC;SACpB;QACD,IAAI,eAAe,CAAC,MAAM,KAAK,CAAC,EAAE;YAC9B,OAAO,MAAA,eAAe,CAAC,CAAC,CAAC,0CAAG,CAAC,CAAC,CAAC;SAClC;QACD,M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W,GAAG,CAAC,EAAE,WAAW,GAAG,UAAU,CAAC,MAAM,EAAE,WAAW,IAAI,CAAC,EAAE;YACzE,OAAO,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,WAAW,CAAE,EAAE,UAAU,CAAC,WAAW,GAAG,CAAC,CAAE,CAAC,CAAC,CAAC;SAC1E;QACD,OAAO,OAAO,CAAC;IACnB,CAAC;CACJ;AAvFD,gCAuFC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stringify.d.ts","sourceRoot":"","sources":["../src/stringify.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,QAAS,GAAG,WAM5B,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.stringify = void 0;
|
|
4
|
+
const stringify = (obj) => JSON.stringify(obj, (_key, value) => {
|
|
5
|
+
if (typeof value === 'function' || value instanceof RegExp) {
|
|
6
|
+
return value.toString();
|
|
7
|
+
}
|
|
8
|
+
return value;
|
|
9
|
+
});
|
|
10
|
+
exports.stringify = stringify;
|
|
11
|
+
//# sourceMappingURL=stringify.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stringify.js","sourceRoot":"","sources":["../src/stringify.ts"],"names":[],"mappings":";;;AAAO,MAAM,SAAS,GAAG,CAAC,GAAQ,EAAE,EAAE,CAClC,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;IAChC,IAAI,OAAO,KAAK,KAAK,UAAU,IAAI,KAAK,YAAY,MAAM,EAAE;QACxD,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAC;KAC3B;IACD,OAAO,KAAK,CAAC;AACjB,CAAC,CAAC,CAAC;AANM,QAAA,SAAS,aAMf"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stuntman/shared",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"description": "Stuntman - HTTP proxy / mock shared types and utils",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"repository": {
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"CHANGELOG.md"
|
|
50
50
|
],
|
|
51
51
|
"scripts": {
|
|
52
|
-
"test": "SUPPRESS_NO_CONFIG_WARNING=1 jest",
|
|
52
|
+
"test": "SUPPRESS_NO_CONFIG_WARNING=1 jest --coverage",
|
|
53
53
|
"clean": "rm -fr dist",
|
|
54
54
|
"build": "tsc",
|
|
55
55
|
"lint": "prettier --check \"./{src,test}/**/*\" && eslint \"./{src,test}/**/*\"",
|