mock-config-server 2.4.0 → 3.0.1
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/LICENSE +21 -21
- package/README.md +502 -326
- package/dist/bin/validateMockServerConfig/helpers/index.d.ts +2 -0
- package/dist/bin/validateMockServerConfig/helpers/index.js +18 -0
- package/dist/bin/validateMockServerConfig/helpers/isCheckModeValid/index.d.ts +1 -0
- package/dist/bin/validateMockServerConfig/helpers/isCheckModeValid/index.js +17 -0
- package/dist/bin/validateMockServerConfig/helpers/isCheckModeValid/isCheckModeValid.d.ts +1 -0
- package/dist/bin/validateMockServerConfig/helpers/isCheckModeValid/isCheckModeValid.js +10 -0
- package/dist/bin/validateMockServerConfig/helpers/isDescriptorValueValid/index.d.ts +1 -0
- package/dist/bin/validateMockServerConfig/helpers/isDescriptorValueValid/index.js +17 -0
- package/dist/bin/validateMockServerConfig/helpers/isDescriptorValueValid/isDescriptorValueValid.d.ts +1 -0
- package/dist/bin/validateMockServerConfig/helpers/isDescriptorValueValid/isDescriptorValueValid.js +23 -0
- package/dist/bin/validateMockServerConfig/validateGraphqlConfig/validateRoutes/validateRoutes.js +44 -18
- package/dist/bin/validateMockServerConfig/validateRestConfig/validateRoutes/validateRoutes.js +38 -42
- package/dist/src/core/graphql/createGraphQLRoutes/createGraphQLRoutes.js +17 -6
- package/dist/src/core/graphql/createGraphQLRoutes/helpers/prepareGraphQLRequestConfigs/prepareGraphQLRequestConfigs.js +7 -2
- package/dist/src/core/middlewares/corsMiddleware/corsMiddleware.js +6 -5
- package/dist/src/core/middlewares/errorMiddleware/errorMiddleware.d.ts +2 -0
- package/dist/src/core/middlewares/errorMiddleware/errorMiddleware.js +18 -0
- package/dist/src/core/middlewares/index.d.ts +1 -0
- package/dist/src/core/middlewares/index.js +1 -0
- package/dist/src/core/middlewares/notFoundMiddleware/notFoundMiddleware.d.ts +1 -6
- package/dist/src/core/middlewares/notFoundMiddleware/notFoundMiddleware.js +1 -1
- package/dist/src/core/middlewares/requestInterceptorMiddleware/requestInterceptorMiddleware.js +2 -2
- package/dist/src/core/rest/createRestRoutes/createRestRoutes.js +19 -3
- package/dist/src/core/rest/createRestRoutes/helpers/prepareRestRequestConfigs/prepareRestRequestConfigs.js +6 -1
- package/dist/src/server/createMockServer/createMockServer.js +2 -4
- package/dist/src/static/views/assets/icons/scheme-dark.svg +3 -3
- package/dist/src/static/views/assets/icons/scheme-light.svg +3 -3
- package/dist/src/static/views/assets/images/404.png +0 -0
- package/dist/src/static/views/assets/images/logo.png +0 -0
- package/dist/src/static/views/assets/styles/global.css +88 -88
- package/dist/src/static/views/components/header/index.css +55 -55
- package/dist/src/static/views/components/header/index.ejs +39 -39
- package/dist/src/static/views/features/scheme/dark.css +12 -12
- package/dist/src/static/views/features/scheme/index.ejs +3 -3
- package/dist/src/static/views/features/scheme/light.css +12 -12
- package/dist/src/static/views/features/tab/index.css +30 -30
- package/dist/src/static/views/features/tab/index.ejs +1 -1
- package/dist/src/static/views/pages/404/index.css +10 -10
- package/dist/src/static/views/pages/404/index.ejs +84 -84
- package/dist/src/utils/constants/checkModes.d.ts +9 -0
- package/dist/src/utils/constants/checkModes.js +31 -0
- package/dist/src/utils/constants/default.js +1 -1
- package/dist/src/utils/constants/index.d.ts +1 -0
- package/dist/src/utils/constants/index.js +1 -0
- package/dist/src/utils/helpers/asyncHandler.d.ts +2 -0
- package/dist/src/utils/helpers/asyncHandler.js +5 -0
- package/dist/src/utils/helpers/config/index.d.ts +1 -1
- package/dist/src/utils/helpers/config/index.js +1 -1
- package/dist/src/utils/helpers/config/resolveEntityValues/resolveEntityValues.d.ts +2 -0
- package/dist/src/utils/helpers/config/resolveEntityValues/resolveEntityValues.js +131 -0
- package/dist/src/utils/helpers/entities/convertToEntityDescriptor/convertToEntityDescriptor.d.ts +2 -0
- package/dist/src/utils/helpers/entities/convertToEntityDescriptor/convertToEntityDescriptor.js +8 -0
- package/dist/src/utils/helpers/entities/index.d.ts +2 -0
- package/dist/src/utils/helpers/entities/index.js +18 -0
- package/dist/src/utils/helpers/entities/isEntityDescriptor/isEntityDescriptor.d.ts +1 -0
- package/dist/src/utils/helpers/entities/isEntityDescriptor/isEntityDescriptor.js +6 -0
- package/dist/src/utils/helpers/index.d.ts +4 -0
- package/dist/src/utils/helpers/index.js +4 -0
- package/dist/src/utils/helpers/isPlainObject/isPlainObject.js +4 -1
- package/dist/src/utils/helpers/isPrimitive/isPrimitive.d.ts +2 -0
- package/dist/src/utils/helpers/isPrimitive/isPrimitive.js +5 -0
- package/dist/src/utils/helpers/isRegExp/isRegExp.d.ts +1 -0
- package/dist/src/utils/helpers/isRegExp/isRegExp.js +5 -0
- package/dist/src/utils/types/checkModes.d.ts +12 -0
- package/dist/src/utils/types/checkModes.js +2 -0
- package/dist/src/utils/types/graphql.d.ts +58 -18
- package/dist/src/utils/types/index.d.ts +1 -0
- package/dist/src/utils/types/index.js +1 -0
- package/dist/src/utils/types/interceptors.d.ts +4 -3
- package/dist/src/utils/types/rest.d.ts +61 -23
- package/dist/src/utils/types/server.d.ts +4 -3
- package/dist/src/utils/types/values.d.ts +1 -7
- package/package.json +113 -113
- package/dist/src/static/views/assets/images/success.png +0 -0
- package/dist/src/utils/helpers/config/isEntitiesEqual/isEntityValuesEqual.d.ts +0 -1
- package/dist/src/utils/helpers/config/isEntitiesEqual/isEntityValuesEqual.js +0 -29
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { CookieOptions, Request, Response } from 'express';
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
type RequestInterceptorCookieValue = string | undefined;
|
|
3
|
+
type RequestInterceptorHeaderValue = string | number | string[] | undefined;
|
|
4
4
|
export interface RequestInterceptorParams {
|
|
5
5
|
request: Request;
|
|
6
6
|
setDelay: (delay: number) => Promise<void>;
|
|
@@ -23,8 +23,9 @@ export interface ResponseInterceptorParams {
|
|
|
23
23
|
clearCookie: (name: string, options?: CookieOptions) => void;
|
|
24
24
|
attachment: (filename: string) => void;
|
|
25
25
|
}
|
|
26
|
-
export type ResponseInterceptor<Data
|
|
26
|
+
export type ResponseInterceptor<Data = any> = (data: Data, params: ResponseInterceptorParams) => any;
|
|
27
27
|
export interface Interceptors {
|
|
28
28
|
request?: RequestInterceptor;
|
|
29
29
|
response?: ResponseInterceptor;
|
|
30
30
|
}
|
|
31
|
+
export {};
|
|
@@ -1,39 +1,77 @@
|
|
|
1
1
|
import type { Request } from 'express';
|
|
2
|
+
import type { CalculateByDescriptorValueCheckMode, CheckActualValueCheckMode, CheckFunction, CheckMode, CompareWithDescriptorAnyValueCheckMode, CompareWithDescriptorValueCheckMode } from './checkModes';
|
|
2
3
|
import type { Interceptors } from './interceptors';
|
|
3
|
-
import type {
|
|
4
|
-
export type
|
|
5
|
-
export type
|
|
6
|
-
export type
|
|
7
|
-
|
|
4
|
+
import type { Data, Primitive } from './values';
|
|
5
|
+
export type RestMethod = 'get' | 'post' | 'delete' | 'put' | 'patch' | 'options';
|
|
6
|
+
export type RestEntityName = 'headers' | 'cookies' | 'query' | 'params' | 'body';
|
|
7
|
+
export type RestMappedEntityKey = string;
|
|
8
|
+
type RestMappedEntityValue = string | number | boolean;
|
|
9
|
+
type RestPlainEntityInnerValue = {
|
|
10
|
+
checkMode?: undefined;
|
|
11
|
+
call?: undefined;
|
|
12
|
+
dotAll?: undefined;
|
|
13
|
+
[key: string]: Primitive | RestPlainEntityInnerValue;
|
|
8
14
|
};
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
type RestPlainEntityValue = {
|
|
16
|
+
checkMode?: undefined;
|
|
17
|
+
call?: undefined;
|
|
18
|
+
dotAll?: undefined;
|
|
19
|
+
[key: string]: RestPlainEntityInnerValue | Primitive | RestEntityDescriptor;
|
|
20
|
+
} | (RestPlainEntityInnerValue | Primitive | RestEntityDescriptor)[];
|
|
21
|
+
type RestEntityValue<EntityName = RestEntityName> = EntityName extends 'body' ? RestPlainEntityValue : RestMappedEntityValue;
|
|
22
|
+
type RestEntityValueOrValues<EntityName = RestEntityName> = RestEntityValue<EntityName> | RestEntityValue<EntityName>[];
|
|
23
|
+
type RestEntityDescriptor<EntityName extends RestEntityName = RestEntityName, Check extends CheckMode = CheckMode> = EntityName extends 'body' ? Check extends Extract<CalculateByDescriptorValueCheckMode, 'function'> ? {
|
|
24
|
+
checkMode: Check;
|
|
25
|
+
value: (actualValue: any, checkFunction: CheckFunction) => boolean;
|
|
26
|
+
} : Check extends CompareWithDescriptorAnyValueCheckMode ? {
|
|
27
|
+
checkMode: Check;
|
|
28
|
+
value: RestEntityValueOrValues<EntityName>;
|
|
29
|
+
} : Check extends CheckActualValueCheckMode ? {
|
|
30
|
+
checkMode: Check;
|
|
31
|
+
value?: undefined;
|
|
32
|
+
} : never : Check extends Extract<CalculateByDescriptorValueCheckMode, 'function'> ? {
|
|
33
|
+
checkMode: Check;
|
|
34
|
+
value: (actualValue: any, checkFunction: CheckFunction) => boolean;
|
|
35
|
+
} : Check extends Extract<CalculateByDescriptorValueCheckMode, 'regExp'> ? {
|
|
36
|
+
checkMode: Check;
|
|
37
|
+
value: RegExp | RegExp[];
|
|
38
|
+
} : Check extends CompareWithDescriptorValueCheckMode ? {
|
|
39
|
+
checkMode: Check;
|
|
40
|
+
value: RestEntityValueOrValues<EntityName>;
|
|
41
|
+
} : Check extends CheckActualValueCheckMode ? {
|
|
42
|
+
checkMode: Check;
|
|
43
|
+
value?: undefined;
|
|
44
|
+
} : never;
|
|
45
|
+
export type RestEntityDescriptorOrValue<EntityName extends RestEntityName = RestEntityName> = EntityName extends 'body' ? RestEntityDescriptor<EntityName> | RestEntityValue<EntityName> : Record<RestMappedEntityKey, RestEntityDescriptor<EntityName> | RestEntityValueOrValues<EntityName>>;
|
|
46
|
+
export type RestEntityDescriptorOnly<EntityName extends RestEntityName = RestEntityName> = EntityName extends 'body' ? RestEntityDescriptor<EntityName> : Record<RestMappedEntityKey, RestEntityDescriptor<EntityName>>;
|
|
47
|
+
export interface RestEntityNamesByMethod {
|
|
48
|
+
get: Exclude<RestEntityName, 'body'>;
|
|
49
|
+
delete: Exclude<RestEntityName, 'body'>;
|
|
50
|
+
post: RestEntityName;
|
|
51
|
+
put: RestEntityName;
|
|
52
|
+
patch: RestEntityName;
|
|
53
|
+
options: Exclude<RestEntityName, 'body'>;
|
|
16
54
|
}
|
|
17
|
-
export type
|
|
18
|
-
[
|
|
55
|
+
export type RestEntityByEntityName<Method extends RestMethod> = {
|
|
56
|
+
[EntityName in RestEntityNamesByMethod[Method]]?: RestEntityDescriptorOrValue<EntityName>;
|
|
19
57
|
};
|
|
20
|
-
export interface RestRouteConfig<Method extends RestMethod, Entities extends
|
|
58
|
+
export interface RestRouteConfig<Method extends RestMethod, Entities extends RestEntityByEntityName<Method> = RestEntityByEntityName<Method>> {
|
|
21
59
|
entities?: Entities;
|
|
22
60
|
data: ((request: Request, entities: Entities) => Data | Promise<Data>) | Data;
|
|
23
61
|
interceptors?: Pick<Interceptors, 'response'>;
|
|
24
62
|
}
|
|
25
|
-
export type RestMethod = 'get' | 'post' | 'delete' | 'put' | 'patch' | 'options';
|
|
26
63
|
export type RestPathString = `/${string}`;
|
|
27
|
-
|
|
64
|
+
interface BaseRestRequestConfig<Method extends RestMethod> {
|
|
28
65
|
path: RestPathString | RegExp;
|
|
29
66
|
method: Method;
|
|
30
67
|
routes: RestRouteConfig<Method>[];
|
|
31
68
|
interceptors?: Interceptors;
|
|
32
69
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
70
|
+
type RestGetRequestConfig = BaseRestRequestConfig<'get'>;
|
|
71
|
+
type RestPostRequestConfig = BaseRestRequestConfig<'post'>;
|
|
72
|
+
type RestPutRequestConfig = BaseRestRequestConfig<'put'>;
|
|
73
|
+
type RestDeleteRequestConfig = BaseRestRequestConfig<'delete'>;
|
|
74
|
+
type RestPatchRequestConfig = BaseRestRequestConfig<'patch'>;
|
|
75
|
+
type RestOptionsRequestConfig = BaseRestRequestConfig<'options'>;
|
|
39
76
|
export type RestRequestConfig = RestGetRequestConfig | RestPostRequestConfig | RestPutRequestConfig | RestDeleteRequestConfig | RestPatchRequestConfig | RestOptionsRequestConfig;
|
|
77
|
+
export {};
|
|
@@ -2,12 +2,12 @@ import type { Request } from 'express';
|
|
|
2
2
|
import type { GraphQLRequestConfig } from './graphql';
|
|
3
3
|
import type { Interceptors } from './interceptors';
|
|
4
4
|
import type { RestMethod, RestRequestConfig } from './rest';
|
|
5
|
-
|
|
5
|
+
type StaticPathObject = {
|
|
6
6
|
prefix: `/${string}`;
|
|
7
7
|
path: `/${string}`;
|
|
8
8
|
};
|
|
9
9
|
export type StaticPath = `/${string}` | StaticPathObject | (StaticPathObject | `/${string}`)[];
|
|
10
|
-
|
|
10
|
+
type CorsHeader = string;
|
|
11
11
|
export type CorsOrigin = string | RegExp | (RegExp | string)[];
|
|
12
12
|
export type Cors = {
|
|
13
13
|
origin: CorsOrigin | ((request: Request) => Promise<CorsOrigin> | CorsOrigin);
|
|
@@ -17,7 +17,7 @@ export type Cors = {
|
|
|
17
17
|
credentials?: boolean;
|
|
18
18
|
maxAge?: number;
|
|
19
19
|
};
|
|
20
|
-
|
|
20
|
+
type Port = number;
|
|
21
21
|
export type BaseUrl = `/${string}`;
|
|
22
22
|
export interface RestConfig {
|
|
23
23
|
baseUrl?: BaseUrl;
|
|
@@ -45,3 +45,4 @@ export interface MockServerConfigArgv {
|
|
|
45
45
|
config?: string;
|
|
46
46
|
watch?: boolean;
|
|
47
47
|
}
|
|
48
|
+
export {};
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
import type { ParsedQs } from 'qs';
|
|
2
1
|
export type PlainObject = Record<string, any>;
|
|
3
2
|
export type PlainFunction = (...args: any[]) => any;
|
|
4
|
-
export type
|
|
5
|
-
export type VariablesValue = any;
|
|
6
|
-
export type QueryValue = ParsedQs;
|
|
7
|
-
export type HeadersValue = Record<string, string>;
|
|
8
|
-
export type CookiesValue = Record<string, string>;
|
|
9
|
-
export type ParamsValue = Record<string, string>;
|
|
3
|
+
export type Primitive = boolean | number | bigint | string | null | undefined | symbol;
|
|
10
4
|
export type Data = boolean | number | string | any[] | Record<any, any> | null | undefined;
|
package/package.json
CHANGED
|
@@ -1,113 +1,113 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "mock-config-server",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "Tool that easily and quickly imitates server operation, create full fake api in few steps",
|
|
5
|
-
"author": {
|
|
6
|
-
"name": "SIBERIA CAN CODE 🧊",
|
|
7
|
-
"url": "https://github.com/siberiacancode"
|
|
8
|
-
},
|
|
9
|
-
"contributors": [
|
|
10
|
-
{
|
|
11
|
-
"name": "Dmitry Babin",
|
|
12
|
-
"url": "https://github.com/debabin"
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
"name": "Nursultan Zianurov",
|
|
16
|
-
"url": "https://github.com/MiaInturi"
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
"name": "Sergey Kryavkin",
|
|
20
|
-
"url": "https://github.com/RiceWithMeat"
|
|
21
|
-
}
|
|
22
|
-
],
|
|
23
|
-
"license": "MIT",
|
|
24
|
-
"main": "./dist/index.js",
|
|
25
|
-
"types": "./dist/index.d.ts",
|
|
26
|
-
"bin": {
|
|
27
|
-
"mock-config-server": "dist/bin/bin.js",
|
|
28
|
-
"mcs": "dist/bin/bin.js"
|
|
29
|
-
},
|
|
30
|
-
"files": [
|
|
31
|
-
"dist"
|
|
32
|
-
],
|
|
33
|
-
"engines": {
|
|
34
|
-
"node": ">=14"
|
|
35
|
-
},
|
|
36
|
-
"scripts": {
|
|
37
|
-
"prepare": "husky install",
|
|
38
|
-
"build": "shx rm -rf dist && tsc -p tsconfig.production.json && tsc-alias -p tsconfig.production.json && shx cp -R src/static dist/src/static",
|
|
39
|
-
"start": "yarn build && node ./dist/bin/bin.js",
|
|
40
|
-
"dev": "nodemon --watch src --watch bin --watch mock-server.config.* -e js,ts,ejs --exec \"yarn start\"",
|
|
41
|
-
"test": "jest",
|
|
42
|
-
"type": "tsc --noEmit",
|
|
43
|
-
"lint": "eslint . --ext ts --no-error-on-unmatched-pattern",
|
|
44
|
-
"stylelint": "stylelint \"src/static/**/*.css\"",
|
|
45
|
-
"format": "prettier --write {src,bin}/**/*.ts",
|
|
46
|
-
"pretty": "yarn
|
|
47
|
-
},
|
|
48
|
-
"lint-staged": {
|
|
49
|
-
"*.css": "yarn stylelint",
|
|
50
|
-
"*.js": "yarn format",
|
|
51
|
-
"*.ts": "yarn pretty"
|
|
52
|
-
},
|
|
53
|
-
"dependencies": {
|
|
54
|
-
"@types/body-parser": "^1.19.2",
|
|
55
|
-
"@types/express": "^4.17.17",
|
|
56
|
-
"@types/flat": "^5.0.2",
|
|
57
|
-
"@types/yargs": "^17.0.24",
|
|
58
|
-
"ansi-colors": "^4.1.3",
|
|
59
|
-
"body-parser": "^1.20.0",
|
|
60
|
-
"ejs": "^3.1.9",
|
|
61
|
-
"esbuild": "^0.17
|
|
62
|
-
"express": "^4.18.1",
|
|
63
|
-
"flat": "^5.0.2",
|
|
64
|
-
"graphql": "^16.6.0",
|
|
65
|
-
"please-upgrade-node": "^3.2.0",
|
|
66
|
-
"shx": "^0.3.4",
|
|
67
|
-
"yargs": "^17.7.1"
|
|
68
|
-
},
|
|
69
|
-
"devDependencies": {
|
|
70
|
-
"@types/jest": "^29.4.0",
|
|
71
|
-
"@types/supertest": "^2.0.12",
|
|
72
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
73
|
-
"@typescript-eslint/parser": "^
|
|
74
|
-
"eslint": "^8.35.0",
|
|
75
|
-
"eslint-config-airbnb": "^19.0.4",
|
|
76
|
-
"eslint-config-airbnb-typescript": "^17.0.0",
|
|
77
|
-
"eslint-config-prettier": "^8.7.0",
|
|
78
|
-
"eslint-import-resolver-typescript": "^3.4.1",
|
|
79
|
-
"eslint-plugin-import": "^2.27.5",
|
|
80
|
-
"eslint-plugin-prettier": "^
|
|
81
|
-
"
|
|
82
|
-
"
|
|
83
|
-
"
|
|
84
|
-
"
|
|
85
|
-
"
|
|
86
|
-
"
|
|
87
|
-
"
|
|
88
|
-
"
|
|
89
|
-
"
|
|
90
|
-
"
|
|
91
|
-
"supertest": "^6.3.3",
|
|
92
|
-
"ts-jest": "^29.0.3",
|
|
93
|
-
"tsc-alias": "^1.8.5",
|
|
94
|
-
"typescript": "^
|
|
95
|
-
},
|
|
96
|
-
"homepage": "https://github.com/siberiacancode/mock-config-server",
|
|
97
|
-
"repository": {
|
|
98
|
-
"type": "git",
|
|
99
|
-
"url": "https://github.com/siberiacancode/mock-config-server.git"
|
|
100
|
-
},
|
|
101
|
-
"keywords": [
|
|
102
|
-
"server",
|
|
103
|
-
"fake",
|
|
104
|
-
"REST",
|
|
105
|
-
"rest",
|
|
106
|
-
"API",
|
|
107
|
-
"api",
|
|
108
|
-
"mock",
|
|
109
|
-
"mocking",
|
|
110
|
-
"config",
|
|
111
|
-
"data"
|
|
112
|
-
]
|
|
113
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "mock-config-server",
|
|
3
|
+
"version": "3.0.1",
|
|
4
|
+
"description": "Tool that easily and quickly imitates server operation, create full fake api in few steps",
|
|
5
|
+
"author": {
|
|
6
|
+
"name": "SIBERIA CAN CODE 🧊",
|
|
7
|
+
"url": "https://github.com/siberiacancode"
|
|
8
|
+
},
|
|
9
|
+
"contributors": [
|
|
10
|
+
{
|
|
11
|
+
"name": "Dmitry Babin",
|
|
12
|
+
"url": "https://github.com/debabin"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"name": "Nursultan Zianurov",
|
|
16
|
+
"url": "https://github.com/MiaInturi"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"name": "Sergey Kryavkin",
|
|
20
|
+
"url": "https://github.com/RiceWithMeat"
|
|
21
|
+
}
|
|
22
|
+
],
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"main": "./dist/index.js",
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"bin": {
|
|
27
|
+
"mock-config-server": "dist/bin/bin.js",
|
|
28
|
+
"mcs": "dist/bin/bin.js"
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"dist"
|
|
32
|
+
],
|
|
33
|
+
"engines": {
|
|
34
|
+
"node": ">=14"
|
|
35
|
+
},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"prepare": "husky install && yarn build",
|
|
38
|
+
"build": "shx rm -rf dist && tsc -p tsconfig.production.json && tsc-alias -p tsconfig.production.json && shx cp -R src/static dist/src/static",
|
|
39
|
+
"start": "yarn build && node ./dist/bin/bin.js",
|
|
40
|
+
"dev": "nodemon --watch src --watch bin --watch mock-server.config.* -e js,ts,ejs --exec \"yarn start\"",
|
|
41
|
+
"test": "jest",
|
|
42
|
+
"type": "tsc --noEmit",
|
|
43
|
+
"lint": "eslint . --ext ts --no-error-on-unmatched-pattern",
|
|
44
|
+
"stylelint": "stylelint \"src/static/**/*.css\"",
|
|
45
|
+
"format": "prettier --write \"{src,bin}/**/*.ts\"",
|
|
46
|
+
"pretty": "yarn format && yarn lint --fix && yarn type"
|
|
47
|
+
},
|
|
48
|
+
"lint-staged": {
|
|
49
|
+
"*.css": "yarn stylelint",
|
|
50
|
+
"*.js": "yarn format",
|
|
51
|
+
"*.ts": "yarn pretty"
|
|
52
|
+
},
|
|
53
|
+
"dependencies": {
|
|
54
|
+
"@types/body-parser": "^1.19.2",
|
|
55
|
+
"@types/express": "^4.17.17",
|
|
56
|
+
"@types/flat": "^5.0.2",
|
|
57
|
+
"@types/yargs": "^17.0.24",
|
|
58
|
+
"ansi-colors": "^4.1.3",
|
|
59
|
+
"body-parser": "^1.20.0",
|
|
60
|
+
"ejs": "^3.1.9",
|
|
61
|
+
"esbuild": "^0.18.17",
|
|
62
|
+
"express": "^4.18.1",
|
|
63
|
+
"flat": "^5.0.2",
|
|
64
|
+
"graphql": "^16.6.0",
|
|
65
|
+
"please-upgrade-node": "^3.2.0",
|
|
66
|
+
"shx": "^0.3.4",
|
|
67
|
+
"yargs": "^17.7.1"
|
|
68
|
+
},
|
|
69
|
+
"devDependencies": {
|
|
70
|
+
"@types/jest": "^29.4.0",
|
|
71
|
+
"@types/supertest": "^2.0.12",
|
|
72
|
+
"@typescript-eslint/eslint-plugin": "^6.2.0",
|
|
73
|
+
"@typescript-eslint/parser": "^6.2.0",
|
|
74
|
+
"eslint": "^8.35.0",
|
|
75
|
+
"eslint-config-airbnb": "^19.0.4",
|
|
76
|
+
"eslint-config-airbnb-typescript": "^17.0.0",
|
|
77
|
+
"eslint-config-prettier": "^8.7.0",
|
|
78
|
+
"eslint-import-resolver-typescript": "^3.4.1",
|
|
79
|
+
"eslint-plugin-import": "^2.27.5",
|
|
80
|
+
"eslint-plugin-prettier": "^5.0.0",
|
|
81
|
+
"husky": "^8.0.1",
|
|
82
|
+
"jest": "^29.4.2",
|
|
83
|
+
"lint-staged": "^13.1.1",
|
|
84
|
+
"nodemon": "^3.0.1",
|
|
85
|
+
"prettier": "^3.0.0",
|
|
86
|
+
"style-loader": "^3.3.2",
|
|
87
|
+
"stylelint": "^15.6.1",
|
|
88
|
+
"stylelint-config-prettier": "^9.0.5",
|
|
89
|
+
"stylelint-config-standard": "^34.0.0",
|
|
90
|
+
"stylelint-order": "^6.0.3",
|
|
91
|
+
"supertest": "^6.3.3",
|
|
92
|
+
"ts-jest": "^29.0.3",
|
|
93
|
+
"tsc-alias": "^1.8.5",
|
|
94
|
+
"typescript": "^5.1.6"
|
|
95
|
+
},
|
|
96
|
+
"homepage": "https://github.com/siberiacancode/mock-config-server",
|
|
97
|
+
"repository": {
|
|
98
|
+
"type": "git",
|
|
99
|
+
"url": "https://github.com/siberiacancode/mock-config-server.git"
|
|
100
|
+
},
|
|
101
|
+
"keywords": [
|
|
102
|
+
"server",
|
|
103
|
+
"fake",
|
|
104
|
+
"REST",
|
|
105
|
+
"rest",
|
|
106
|
+
"API",
|
|
107
|
+
"api",
|
|
108
|
+
"mock",
|
|
109
|
+
"mocking",
|
|
110
|
+
"config",
|
|
111
|
+
"data"
|
|
112
|
+
]
|
|
113
|
+
}
|
|
Binary file
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const isEntityValuesEqual: (firstEntityValue: any, secondEntityValue: any) => boolean;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isEntityValuesEqual = void 0;
|
|
4
|
-
const flat_1 = require("flat");
|
|
5
|
-
const isPlainObject_1 = require("../../isPlainObject/isPlainObject");
|
|
6
|
-
const isEntityValuesEqual = (firstEntityValue, secondEntityValue) => {
|
|
7
|
-
const isValuesArePlainObjects = (0, isPlainObject_1.isPlainObject)(firstEntityValue) && (0, isPlainObject_1.isPlainObject)(secondEntityValue);
|
|
8
|
-
if (isValuesArePlainObjects) {
|
|
9
|
-
const flattenFirstEntityValue = (0, flat_1.flatten)(firstEntityValue);
|
|
10
|
-
const flattenSecondEntityValue = (0, flat_1.flatten)(secondEntityValue);
|
|
11
|
-
return Object.keys(flattenFirstEntityValue).every((key) =>
|
|
12
|
-
// ✅ important:
|
|
13
|
-
// call 'toString' for ignore types of values
|
|
14
|
-
flattenFirstEntityValue[key].toString() === flattenSecondEntityValue[key]?.toString());
|
|
15
|
-
}
|
|
16
|
-
const isValuesAreArrays = Array.isArray(firstEntityValue) && Array.isArray(secondEntityValue);
|
|
17
|
-
if (isValuesAreArrays) {
|
|
18
|
-
const flattenFirstEntityValue = (0, flat_1.flatten)(firstEntityValue);
|
|
19
|
-
const flattenSecondEntityValue = (0, flat_1.flatten)(secondEntityValue);
|
|
20
|
-
return (Object.keys(flattenFirstEntityValue).length ===
|
|
21
|
-
Object.keys(flattenSecondEntityValue).length &&
|
|
22
|
-
Object.keys(flattenFirstEntityValue).every((key) =>
|
|
23
|
-
// ✅ important:
|
|
24
|
-
// call 'toString' for ignore types of values
|
|
25
|
-
flattenFirstEntityValue[key].toString() === flattenSecondEntityValue[key].toString()));
|
|
26
|
-
}
|
|
27
|
-
return `${firstEntityValue}` === `${secondEntityValue}`;
|
|
28
|
-
};
|
|
29
|
-
exports.isEntityValuesEqual = isEntityValuesEqual;
|