@n1k1t/mock-server 0.1.53 → 0.1.56
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/.unitignore +2 -0
- package/README.md +3 -3
- package/lib/package.json +13 -17
- package/lib/src/expectations/models/expectation.d.ts +2 -2
- package/lib/src/expectations/models/storage.d.ts +1 -1
- package/lib/src/expectations/models/storage.d.ts.map +1 -1
- package/lib/src/expectations/models/storage.js +1 -1
- package/lib/src/expectations/models/storage.js.map +1 -1
- package/lib/src/expectations/operators/has.operator.d.ts.map +1 -1
- package/lib/src/expectations/operators/has.operator.js +1 -2
- package/lib/src/expectations/operators/has.operator.js.map +1 -1
- package/lib/src/expectations/operators/merge.operator.d.ts.map +1 -1
- package/lib/src/expectations/operators/merge.operator.js +1 -2
- package/lib/src/expectations/operators/merge.operator.js.map +1 -1
- package/lib/src/expectations/operators/remove.operator.d.ts.map +1 -1
- package/lib/src/expectations/operators/remove.operator.js +1 -2
- 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 +1 -2
- package/lib/src/expectations/operators/set.operator.js.map +1 -1
- package/lib/src/expectations/utils/index.d.ts +4 -0
- package/lib/src/expectations/utils/index.d.ts.map +1 -0
- package/lib/src/expectations/utils/index.js +20 -0
- package/lib/src/expectations/utils/index.js.map +1 -0
- package/lib/src/{utils → expectations/utils}/json.d.ts +0 -9
- package/lib/src/expectations/utils/json.d.ts.map +1 -0
- package/lib/src/{utils → expectations/utils}/json.js +1 -16
- package/lib/src/expectations/utils/json.js.map +1 -0
- package/lib/src/expectations/{utils.d.ts → utils/location.d.ts} +2 -4
- package/lib/src/expectations/utils/location.d.ts.map +1 -0
- package/lib/src/expectations/{utils.js → utils/location.js} +2 -44
- package/lib/src/expectations/{utils.js.map → utils/location.js.map} +1 -1
- package/lib/src/expectations/utils/schema.d.ts +4 -0
- package/lib/src/expectations/utils/schema.d.ts.map +1 -0
- package/lib/src/expectations/utils/schema.js +50 -0
- package/lib/src/expectations/utils/schema.js.map +1 -0
- package/lib/src/gui/app/types/dev.d.ts +7 -0
- package/lib/src/gui/app/types/dev.d.ts.map +1 -0
- package/lib/src/gui/app/types/dev.js +3 -0
- package/lib/src/gui/app/types/dev.js.map +1 -0
- package/lib/src/gui/app/types/index.d.ts +2 -0
- package/lib/src/gui/app/types/index.d.ts.map +1 -0
- package/lib/src/gui/app/types/index.js +18 -0
- package/lib/src/gui/app/types/index.js.map +1 -0
- package/lib/src/server/endpoints/gui.endpoint.d.ts.map +1 -1
- package/lib/src/server/endpoints/gui.endpoint.js +10 -1
- package/lib/src/server/endpoints/gui.endpoint.js.map +1 -1
- package/lib/src/server/index.d.ts +0 -1
- package/lib/src/server/index.d.ts.map +1 -1
- package/lib/src/server/index.js +8 -2
- package/lib/src/server/index.js.map +1 -1
- package/lib/src/server/models/context/index.d.ts +1 -1
- package/lib/src/server/models/context/index.d.ts.map +1 -1
- package/lib/src/server/models/context/index.js +1 -1
- package/lib/src/server/models/context/index.js.map +1 -1
- package/lib/src/server/models/executor/index.js +2 -2
- package/lib/src/server/models/executor/index.js.map +1 -1
- package/lib/src/server/models/history/model.d.ts +1 -1
- package/lib/src/server/models/history/model.d.ts.map +1 -1
- package/lib/src/server/models/history/model.js +1 -1
- package/lib/src/server/models/history/model.js.map +1 -1
- package/lib/src/server/models/history/storage.js +2 -2
- package/lib/src/server/models/history/storage.js.map +1 -1
- package/lib/src/server/models/providers/storage.js +2 -2
- package/lib/src/server/models/providers/storage.js.map +1 -1
- package/lib/src/server/models/transports/storage.js +1 -1
- package/lib/src/server/models/transports/storage.js.map +1 -1
- package/lib/src/server/services/metrics.service.d.ts.map +1 -1
- package/lib/src/server/services/metrics.service.js +4 -1
- package/lib/src/server/services/metrics.service.js.map +1 -1
- package/lib/src/server/transports/http.transport/index.js +2 -2
- package/lib/src/server/transports/http.transport/index.js.map +1 -1
- package/lib/src/server/transports/ws.transport/index.js +2 -2
- package/lib/src/server/transports/ws.transport/index.js.map +1 -1
- package/lib/src/server/types/index.d.ts +1 -1
- package/lib/src/server/types/index.d.ts.map +1 -1
- package/lib/src/{utils/validation.d.ts → server/utils/index.d.ts} +2 -2
- package/lib/src/server/utils/index.d.ts.map +1 -0
- package/lib/src/{utils/validation.js → server/utils/index.js} +1 -1
- package/lib/src/{utils/validation.js.map → server/utils/index.js.map} +1 -1
- package/lib/src/utils/index.d.ts +25 -4
- package/lib/src/utils/index.d.ts.map +1 -1
- package/lib/src/utils/index.js +45 -17
- package/lib/src/utils/index.js.map +1 -1
- package/package.json +13 -17
- package/public/{fonts/fa-regular-400.woff2 → assets/fa-regular-400-nlupHwI1.woff2} +0 -0
- package/public/{fonts/fa-solid-900.woff2 → assets/fa-solid-900-D3IoOn-o.woff2} +0 -0
- package/public/{images/favicon.png → assets/favicon-rsW1wnD3.png} +0 -0
- package/public/assets/index-Dt5tRBvw.js +496 -0
- package/public/assets/index-TxMiEbRI.css +4 -0
- package/public/index.html +4 -4
- package/lib/src/expectations/utils.d.ts.map +0 -1
- package/lib/src/extensions.d.ts +0 -2
- package/lib/src/extensions.d.ts.map +0 -1
- package/lib/src/extensions.js +0 -9
- package/lib/src/extensions.js.map +0 -1
- package/lib/src/utils/common.d.ts +0 -16
- package/lib/src/utils/common.d.ts.map +0 -1
- package/lib/src/utils/common.js +0 -30
- package/lib/src/utils/common.js.map +0 -1
- package/lib/src/utils/json.d.ts.map +0 -1
- package/lib/src/utils/json.js.map +0 -1
- package/lib/src/utils/regexp.d.ts +0 -2
- package/lib/src/utils/regexp.d.ts.map +0 -1
- package/lib/src/utils/regexp.js +0 -9
- package/lib/src/utils/regexp.js.map +0 -1
- package/lib/src/utils/validation.d.ts.map +0 -1
- package/public/scripts/.gitkeep +0 -0
- package/public/scripts/main.js +0 -2
- package/public/scripts/main.js.LICENSE.txt +0 -28
- package/public/styles/fa-all.css +0 -5
- package/public/styles/main.css +0 -1
package/lib/src/utils/index.d.ts
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
1
|
+
import type { FlattenArrays } from '../types';
|
|
2
|
+
export declare const wait: (ms: number) => Promise<unknown>;
|
|
3
|
+
export declare const cast: <T>(payload: T) => T;
|
|
4
|
+
export declare const flattenArrayed: <T extends unknown[][], Q extends FlattenArrays<T>[] = [...T extends (infer R)[] ? R extends unknown[][] ? [...R extends infer T_1 ? T_1 extends R ? T_1 extends (infer R)[] ? R extends unknown[][] ? [...R extends infer T_2 ? T_2 extends R ? T_2 extends (infer R)[] ? R extends unknown[][] ? [...R extends infer T_3 ? T_3 extends R ? T_3 extends (infer R)[] ? R extends unknown[][] ? [...R extends infer T_4 ? T_4 extends R ? T_4 extends (infer R)[] ? R extends unknown[][] ? [...R extends infer T_5 ? T_5 extends R ? T_5 extends (infer R)[] ? R extends unknown[][] ? [...R extends infer T_6 ? T_6 extends R ? T_6 extends (infer R)[] ? R extends unknown[][] ? [...R extends infer T_7 ? T_7 extends R ? T_7 extends (infer R)[] ? R extends unknown[][] ? [...R extends infer T_8 ? T_8 extends R ? T_8 extends (infer R)[] ? R extends unknown[][] ? [...R extends infer T_9 ? T_9 extends R ? T_9 extends (infer R)[] ? R extends unknown[][] ? [...R extends infer T_10 ? T_10 extends R ? T_10 extends (infer R)[] ? R extends unknown[][] ? [.../*elided*/ any] : R : T_10 : never : never] : R : T_9 : never : never] : R : T_8 : never : never] : R : T_7 : never : never] : R : T_6 : never : never] : R : T_5 : never : never] : R : T_4 : never : never] : R : T_3 : never : never] : R : T_2 : never : never] : R : T_1 : never : never] : R : T][]>(payload: T) => Q;
|
|
5
|
+
/**
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* const counter = buildCounter(5);
|
|
9
|
+
*
|
|
10
|
+
* counter() // 6
|
|
11
|
+
* counter() // 7
|
|
12
|
+
* counter(2) // 9
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export declare const buildCounter: (initial?: number, step?: number) => (value?: number) => number;
|
|
16
|
+
export declare const serializeRegExp: (exp: RegExp) => Pick<RegExp, "source" | "flags">;
|
|
17
|
+
export declare const parseJsonSafe: <T extends Record<string, unknown>>(serializedJson: string) => {
|
|
18
|
+
readonly status: "OK";
|
|
19
|
+
readonly result: T;
|
|
20
|
+
readonly error?: undefined;
|
|
21
|
+
} | {
|
|
22
|
+
readonly status: "ERROR";
|
|
23
|
+
readonly error: Error;
|
|
24
|
+
readonly result?: T;
|
|
25
|
+
};
|
|
5
26
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C,eAAO,MAAM,IAAI,OAAQ,MAAM,qBAAsD,CAAC;AACtF,eAAO,MAAM,IAAI,GAAI,CAAC,WAAW,CAAC,MAAY,CAAC;AAE/C,eAAO,MAAM,cAAc,GACzB,CAAC,SAAS,OAAO,EAAE,EAAE,EACrB,CAAC,SAAS,aAAa,CAAC,CAAC,CAAC,EAAE,0wCACnB,CAAC,KAAG,CAQd,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,YAAY,iEAGH,CAAC;AAEvB,eAAO,MAAM,eAAe,QAAS,MAAM,KAAG,IAAI,CAAC,MAAM,EAAE,QAAQ,GAAG,OAAO,CAG3E,CAAC;AAEH,eAAO,MAAM,aAAa,GAAI,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,kBAAkB,MAAM;;qBAIxE,CAAC;;;;;sBAAD,CAAC;CAQf,CAAC"}
|
package/lib/src/utils/index.js
CHANGED
|
@@ -1,21 +1,49 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseJsonSafe = exports.serializeRegExp = exports.buildCounter = exports.flattenArrayed = exports.cast = exports.wait = void 0;
|
|
4
|
+
const wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
5
|
+
exports.wait = wait;
|
|
6
|
+
const cast = (payload) => payload;
|
|
7
|
+
exports.cast = cast;
|
|
8
|
+
const flattenArrayed = (payload) => {
|
|
9
|
+
if (payload?.every?.(Array.isArray)) {
|
|
10
|
+
return payload.reduce((acc, nestedPayload) => acc.concat((0, exports.flattenArrayed)(nestedPayload)), []);
|
|
7
11
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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);
|
|
12
|
+
return Array.isArray(payload)
|
|
13
|
+
? [payload]
|
|
14
|
+
: [[payload]];
|
|
15
15
|
};
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
exports.flattenArrayed = flattenArrayed;
|
|
17
|
+
/**
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* const counter = buildCounter(5);
|
|
21
|
+
*
|
|
22
|
+
* counter() // 6
|
|
23
|
+
* counter() // 7
|
|
24
|
+
* counter(2) // 9
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
const buildCounter = (initial = 0, step = 1) => (value = step) => (initial += value);
|
|
28
|
+
exports.buildCounter = buildCounter;
|
|
29
|
+
const serializeRegExp = (exp) => ({
|
|
30
|
+
source: exp.source,
|
|
31
|
+
flags: exp.flags,
|
|
32
|
+
});
|
|
33
|
+
exports.serializeRegExp = serializeRegExp;
|
|
34
|
+
const parseJsonSafe = (serializedJson) => {
|
|
35
|
+
try {
|
|
36
|
+
return {
|
|
37
|
+
status: 'OK',
|
|
38
|
+
result: JSON.parse(serializedJson),
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
return {
|
|
43
|
+
status: 'ERROR',
|
|
44
|
+
error: error instanceof Error ? error : new Error('Unknown'),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
exports.parseJsonSafe = parseJsonSafe;
|
|
21
49
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":";;;AAEO,MAAM,IAAI,GAAG,CAAC,EAAU,EAAE,EAAE,CAAC,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AAAzE,QAAA,IAAI,QAAqE;AAC/E,MAAM,IAAI,GAAG,CAAI,OAAU,EAAE,EAAE,CAAC,OAAO,CAAC;AAAlC,QAAA,IAAI,QAA8B;AAExC,MAAM,cAAc,GAAG,CAG5B,OAAU,EAAK,EAAE;IACjB,IAAI,OAAO,EAAE,KAAK,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;QACpC,OAAU,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,aAAa,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,IAAA,sBAAc,EAAI,aAAa,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACrG,CAAC;IAED,OAAO,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC;QAC3B,CAAC,CAAI,CAAC,OAAO,CAAC;QACd,CAAC,CAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;AACrB,CAAC,CAAC;AAXW,QAAA,cAAc,kBAWzB;AAEF;;;;;;;;;GASG;AACI,MAAM,YAAY,GACvB,CAAC,OAAO,GAAG,CAAC,EAAE,IAAI,GAAG,CAAC,EAAE,EAAE,CAC1B,CAAC,KAAK,GAAG,IAAI,EAAE,EAAE,CACf,CAAC,OAAO,IAAI,KAAK,CAAC,CAAC;AAHV,QAAA,YAAY,gBAGF;AAEhB,MAAM,eAAe,GAAG,CAAC,GAAW,EAAoC,EAAE,CAAC,CAAC;IACjF,MAAM,EAAE,GAAG,CAAC,MAAM;IAClB,KAAK,EAAE,GAAG,CAAC,KAAK;CACjB,CAAC,CAAC;AAHU,QAAA,eAAe,mBAGzB;AAEI,MAAM,aAAa,GAAG,CAAoC,cAAsB,EAAE,EAAE;IACzF,IAAI,CAAC;QACH,OAAc;YACZ,MAAM,EAAE,IAAI;YACZ,MAAM,EAAK,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC;SACtC,CAAC;IACJ,CAAC;IAAC,OAAM,KAAK,EAAE,CAAC;QACd,OAAc;YACZ,MAAM,EAAE,OAAO;YACf,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,SAAS,CAAC;SAC7D,CAAC;IACJ,CAAC;AACH,CAAC,CAAC;AAZW,QAAA,aAAa,iBAYxB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@n1k1t/mock-server",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.56",
|
|
4
4
|
"description": "Powerful util to setup mocks over HTTP APIs",
|
|
5
5
|
"main": "lib/src/index.js",
|
|
6
6
|
"types": "lib/src/index.d.ts",
|
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
"scripts": {
|
|
11
11
|
"test": "NODE_ENV=test TZ=UTC npx jest",
|
|
12
12
|
"start": "node lib/src/index",
|
|
13
|
-
"start:dev": "npx concurrently --names
|
|
14
|
-
"gui:build": "npx
|
|
15
|
-
"gui:build:check": "npx tsc --noEmit --project src/gui/app
|
|
13
|
+
"start:dev": "NODE_ENV=development npx concurrently --names vite,server -c gray,cyan \"npx vite serve -l error\" \"npx ts-node test\"",
|
|
14
|
+
"gui:build": "npx vite build --mode production",
|
|
15
|
+
"gui:build:check": "npx tsc --noEmit --project src/gui/app",
|
|
16
16
|
"server:build": "rm -rf lib && npx tsc",
|
|
17
17
|
"server:build:check": "npx tsc --noEmit",
|
|
18
18
|
"build": "npm run server:build && npm run gui:build",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
],
|
|
36
36
|
"collectCoverageFrom": [
|
|
37
37
|
"<rootDir>/src/**/*.ts",
|
|
38
|
-
"!<rootDir>/src/gui
|
|
38
|
+
"!<rootDir>/src/gui/**"
|
|
39
39
|
],
|
|
40
40
|
"setupFilesAfterEnv": [
|
|
41
41
|
"jest-extended/all"
|
|
@@ -74,36 +74,31 @@
|
|
|
74
74
|
"author": "n1k1t",
|
|
75
75
|
"license": "MIT",
|
|
76
76
|
"devDependencies": {
|
|
77
|
-
"@
|
|
77
|
+
"@jest/globals": "29.7.0",
|
|
78
|
+
"@n1k1t/unit-generator": "0.1.13",
|
|
78
79
|
"@types/commander": "2.12.2",
|
|
79
80
|
"@types/express": "4.17.13",
|
|
80
81
|
"@types/http-proxy": "1.17.9",
|
|
81
|
-
"@types/jest": "29.5.
|
|
82
|
+
"@types/jest": "29.5.14",
|
|
82
83
|
"@types/lodash": "4.14.184",
|
|
84
|
+
"@types/mime-types": "2.1.4",
|
|
83
85
|
"@types/minimatch": "5.1.2",
|
|
84
86
|
"@types/node": "22.13.4",
|
|
85
87
|
"@types/node-gzip": "1.1.3",
|
|
86
88
|
"@types/uuid": "8.3.4",
|
|
87
|
-
"@types/webpack": "5.28.5",
|
|
88
|
-
"@types/webpack-livereload-plugin": "2.3.6",
|
|
89
89
|
"@types/ws": "8.5.13",
|
|
90
90
|
"chart.js": "4.4.8",
|
|
91
91
|
"concurrently": "9.1.2",
|
|
92
|
-
"css-loader": "7.1.2",
|
|
93
92
|
"fnv1a": "1.1.1",
|
|
94
93
|
"husky": "9.1.7",
|
|
95
94
|
"jest": "29.7.0",
|
|
96
95
|
"jest-extended": "4.0.2",
|
|
97
|
-
"mini-css-extract-plugin": "2.9.2",
|
|
98
|
-
"sass": "1.86.0",
|
|
99
|
-
"sass-loader": "16.0.5",
|
|
100
96
|
"ts-jest": "29.1.1",
|
|
101
|
-
"ts-loader": "9.5.2",
|
|
102
97
|
"ts-node": "10.9.2",
|
|
103
98
|
"typescript": "5.7.2",
|
|
104
|
-
"
|
|
105
|
-
"
|
|
106
|
-
"
|
|
99
|
+
"vite": "6.2.3",
|
|
100
|
+
"vite-plugin-commonjs": "0.10.4",
|
|
101
|
+
"vite-plugin-node-polyfills": "0.23.0"
|
|
107
102
|
},
|
|
108
103
|
"dependencies": {
|
|
109
104
|
"@faker-js/faker": "9.2.0",
|
|
@@ -120,6 +115,7 @@
|
|
|
120
115
|
"ioredis": "5.4.1",
|
|
121
116
|
"jsonpath-plus": "7.2.0",
|
|
122
117
|
"lodash": "4.17.21",
|
|
118
|
+
"mime-types": "2.1.35",
|
|
123
119
|
"minimatch": "5.1.0",
|
|
124
120
|
"mongodb": "4.12.1",
|
|
125
121
|
"node-gzip": "1.1.2",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|