mock-config-server 4.0.3 → 5.0.0-beta.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/README.md +229 -237
- package/dist/bin/build.d.ts +3 -3
- package/dist/bin/build.js +1 -11
- package/dist/bin/helpers/createTemplate.js +6 -6
- package/dist/bin/helpers/resolveConfigFile.d.ts +2 -2
- package/dist/bin/helpers/resolveConfigFile.js +2 -3
- package/dist/bin/helpers/resolveConfigFilePath.js +4 -4
- package/dist/bin/init.d.ts +2 -2
- package/dist/bin/init.js +7 -7
- package/dist/bin/run.d.ts +3 -3
- package/dist/bin/run.js +17 -24
- package/dist/bin/templates/ts/full/mock-server.config.ts +2 -2
- package/dist/bin/templates/ts/graphql/mock-server.config.ts +2 -2
- package/dist/bin/templates/ts/rest/mock-server.config.ts +2 -2
- package/dist/src/core/database/createDatabaseRoutes/helpers/search/search.js +3 -3
- package/dist/src/core/database/createDatabaseRoutes/storages/File/FileStorage.js +4 -4
- package/dist/src/core/database/createDatabaseRoutes/storages/File/FileWriter.js +2 -2
- package/dist/src/core/functions/graphql/graphql.d.ts +54 -0
- package/dist/src/core/functions/graphql/graphql.js +126 -0
- package/dist/src/core/functions/graphql/helpers/createQueueHandler/createQueueHandler.d.ts +5 -0
- package/dist/src/core/functions/graphql/helpers/createQueueHandler/createQueueHandler.js +35 -0
- package/dist/src/core/functions/graphql/helpers/index.d.ts +1 -0
- package/dist/src/core/{rest/createRestRoutes → functions/graphql}/helpers/index.js +1 -1
- package/dist/src/core/functions/index.d.ts +3 -0
- package/dist/src/core/functions/index.js +20 -0
- package/dist/src/core/functions/mock.d.ts +2 -0
- package/dist/src/core/functions/mock.js +11 -0
- package/dist/src/core/functions/rest/helpers/createFileHandler/createFileHandler.d.ts +2 -0
- package/dist/src/core/functions/rest/helpers/createFileHandler/createFileHandler.js +29 -0
- package/dist/src/core/functions/rest/helpers/createQueueHandler/createQueueHandler.d.ts +5 -0
- package/dist/src/core/functions/rest/helpers/createQueueHandler/createQueueHandler.js +35 -0
- package/dist/src/core/functions/rest/helpers/formatSsePayload/formatSsePayload.d.ts +5 -0
- package/dist/src/core/functions/rest/helpers/formatSsePayload/formatSsePayload.js +50 -0
- package/dist/src/core/functions/rest/helpers/index.d.ts +3 -0
- package/dist/src/core/functions/rest/helpers/index.js +20 -0
- package/dist/src/core/functions/rest/index.d.ts +1 -0
- package/dist/src/core/{graphql/createGraphQLRoutes/helpers → functions/rest}/index.js +1 -1
- package/dist/src/core/functions/rest/rest.d.ts +114 -0
- package/dist/src/core/functions/rest/rest.js +171 -0
- package/dist/src/core/graphql/createGraphQLRoute/createGraphQLRoute.d.ts +8 -0
- package/dist/src/core/graphql/createGraphQLRoute/createGraphQLRoute.js +158 -0
- package/dist/src/core/graphql/createGraphQLRoute/helpers/calculateGraphQLRouteConfigWeight/calculateGraphQLRouteConfigWeight.d.ts +2 -0
- package/dist/src/core/graphql/{createGraphQLRoutes/helpers/prepareGraphQLRequestConfigs/prepareGraphQLRequestConfigs.js → createGraphQLRoute/helpers/calculateGraphQLRouteConfigWeight/calculateGraphQLRouteConfigWeight.js} +3 -11
- package/dist/src/core/graphql/createGraphQLRoute/helpers/index.d.ts +3 -0
- package/dist/src/core/graphql/createGraphQLRoute/helpers/index.js +20 -0
- package/dist/src/core/graphql/createGraphQLRoute/helpers/matchGraphQLRequestArtifacts/matchGraphQLRequestArtifacts.d.ts +12 -0
- package/dist/src/core/graphql/createGraphQLRoute/helpers/matchGraphQLRequestArtifacts/matchGraphQLRequestArtifacts.js +28 -0
- package/dist/src/core/graphql/createGraphQLRoute/helpers/prepareGraphQLRequestArtifacts/prepareGraphQLRequestArtifacts.d.ts +2 -0
- package/dist/src/core/graphql/createGraphQLRoute/helpers/prepareGraphQLRequestArtifacts/prepareGraphQLRequestArtifacts.js +11 -0
- package/dist/src/core/graphql/index.d.ts +2 -1
- package/dist/src/core/graphql/index.js +2 -1
- package/dist/src/core/middlewares/contextMiddleware/contextMiddleware.d.ts +6 -4
- package/dist/src/core/rest/createRestRoute/createRestRoute.d.ts +8 -0
- package/dist/src/core/rest/createRestRoute/createRestRoute.js +190 -0
- package/dist/src/core/rest/createRestRoute/helpers/calculateRestRouteConfigWeight/calculateRestRouteConfigWeight.d.ts +2 -0
- package/dist/src/core/rest/createRestRoute/helpers/calculateRestRouteConfigWeight/calculateRestRouteConfigWeight.js +35 -0
- package/dist/src/core/rest/createRestRoute/helpers/index.d.ts +3 -0
- package/dist/src/core/rest/createRestRoute/helpers/index.js +20 -0
- package/dist/src/core/rest/createRestRoute/helpers/matchRestRequestArtifacts/matchRestRequestArtifacts.d.ts +11 -0
- package/dist/src/core/rest/createRestRoute/helpers/matchRestRequestArtifacts/matchRestRequestArtifacts.js +31 -0
- package/dist/src/core/rest/createRestRoute/helpers/prepareRestRequestArtifacts/prepareRestRequestArtifacts.d.ts +2 -0
- package/dist/src/core/rest/createRestRoute/helpers/prepareRestRequestArtifacts/prepareRestRequestArtifacts.js +37 -0
- package/dist/src/core/rest/index.d.ts +2 -1
- package/dist/src/core/rest/index.js +2 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +1 -0
- package/dist/src/server/createMockServer/createMockServer.d.ts +1 -1
- package/dist/src/server/createMockServer/createMockServer.js +76 -45
- package/dist/src/server/index.d.ts +0 -8
- package/dist/src/server/index.js +0 -8
- package/dist/src/server/startMockServer/startMockServer.d.ts +2 -2
- package/dist/src/server/startMockServer/startMockServer.js +4 -3
- package/dist/src/utils/constants/checkModes.js +7 -7
- package/dist/src/utils/helpers/config/resolveEntityValues/resolveEntityValues.js +1 -1
- package/dist/src/utils/helpers/files/isFileDescriptor/isFileDescriptor.js +2 -2
- package/dist/src/utils/helpers/files/isFilePathValid/isFilePathValid.js +3 -3
- package/dist/src/utils/helpers/interceptors/callResponseInterceptors/callResponseInterceptors.d.ts +3 -3
- package/dist/src/utils/helpers/interceptors/callResponseInterceptors/callResponseInterceptors.js +2 -2
- package/dist/src/utils/helpers/tests/createTmpDir.js +4 -4
- package/dist/src/utils/helpers/url/index.d.ts +1 -2
- package/dist/src/utils/helpers/url/index.js +1 -2
- package/dist/src/utils/helpers/url/normalizeUrl/normalizeUrl.d.ts +1 -0
- package/dist/src/utils/helpers/url/normalizeUrl/normalizeUrl.js +15 -0
- package/dist/src/utils/helpers/url/urlJoin/urlJoin.js +4 -4
- package/dist/src/utils/types/graphql.d.ts +44 -18
- package/dist/src/utils/types/rest.d.ts +44 -27
- package/dist/src/utils/types/server.d.ts +7 -24
- package/dist/src/utils/types/values.d.ts +2 -1
- package/dist/src/utils/validate/graphqlConfigSchema/graphqlConfigSchema.d.ts +41 -383
- package/dist/src/utils/validate/graphqlConfigSchema/graphqlConfigSchema.js +3 -3
- package/dist/src/utils/validate/graphqlConfigSchema/routeConfigSchema/routeConfigSchema.d.ts +3 -66
- package/dist/src/utils/validate/graphqlConfigSchema/routeConfigSchema/routeConfigSchema.js +7 -22
- package/dist/src/utils/validate/index.d.ts +0 -2
- package/dist/src/utils/validate/index.js +0 -2
- package/dist/src/utils/validate/queueSchema/queueSchema.d.ts +2 -11
- package/dist/src/utils/validate/queueSchema/queueSchema.js +7 -13
- package/dist/src/utils/validate/restConfigSchema/restConfigSchema.d.ts +101 -1309
- package/dist/src/utils/validate/restConfigSchema/restConfigSchema.js +3 -3
- package/dist/src/utils/validate/restConfigSchema/routeConfigSchema/routeConfigSchema.d.ts +3 -82
- package/dist/src/utils/validate/restConfigSchema/routeConfigSchema/routeConfigSchema.js +6 -28
- package/dist/src/utils/validate/settingsSchema/settingsSchema.d.ts +0 -3
- package/dist/src/utils/validate/settingsSchema/settingsSchema.js +0 -1
- package/dist/src/utils/validate/utils/checkModeSchema/checkModeSchema.js +6 -6
- package/dist/src/utils/validate/utils/entitiesSchema/entitiesSchema.js +4 -4
- package/dist/src/utils/validate/utils/jsonSchema/jsonSchema.js +3 -3
- package/dist/src/utils/validate/utils/requiredPropertiesSchema/requiredPropertiesSchema.js +1 -1
- package/dist/src/utils/validate/utils/sharedSchema/sharedSchema.js +3 -3
- package/dist/src/utils/validate/validateMockServerConfig.js +18 -8
- package/package.json +17 -40
- package/LICENSE +0 -21
- package/dist/bin/runFlatConfig.d.ts +0 -5
- package/dist/bin/runFlatConfig.js +0 -36
- package/dist/src/core/graphql/createGraphQLRoutes/createGraphQLRoutes.d.ts +0 -9
- package/dist/src/core/graphql/createGraphQLRoutes/createGraphQLRoutes.js +0 -160
- package/dist/src/core/graphql/createGraphQLRoutes/helpers/index.d.ts +0 -1
- package/dist/src/core/graphql/createGraphQLRoutes/helpers/prepareGraphQLRequestConfigs/prepareGraphQLRequestConfigs.d.ts +0 -2
- package/dist/src/core/rest/createRestRoutes/createRestRoutes.d.ts +0 -9
- package/dist/src/core/rest/createRestRoutes/createRestRoutes.js +0 -184
- package/dist/src/core/rest/createRestRoutes/helpers/index.d.ts +0 -1
- package/dist/src/core/rest/createRestRoutes/helpers/prepareRestRequestConfigs/prepareRestRequestConfigs.d.ts +0 -2
- package/dist/src/core/rest/createRestRoutes/helpers/prepareRestRequestConfigs/prepareRestRequestConfigs.js +0 -67
- package/dist/src/server/createDatabaseMockServer/createDatabaseMockServer.d.ts +0 -3
- package/dist/src/server/createDatabaseMockServer/createDatabaseMockServer.js +0 -62
- package/dist/src/server/createFlatMockServer/createFlatMockServer.d.ts +0 -3
- package/dist/src/server/createFlatMockServer/createFlatMockServer.js +0 -128
- package/dist/src/server/createGraphQLMockServer/createGraphQLMockServer.d.ts +0 -3
- package/dist/src/server/createGraphQLMockServer/createGraphQLMockServer.js +0 -67
- package/dist/src/server/createRestMockServer/createRestMockServer.d.ts +0 -3
- package/dist/src/server/createRestMockServer/createRestMockServer.js +0 -67
- package/dist/src/server/startDatabaseMockServer/startDatabaseMockServer.d.ts +0 -4
- package/dist/src/server/startDatabaseMockServer/startDatabaseMockServer.js +0 -29
- package/dist/src/server/startFlatMockServer/startFlatMockServer.d.ts +0 -4
- package/dist/src/server/startFlatMockServer/startFlatMockServer.js +0 -30
- package/dist/src/server/startGraphQLMockServer/startGraphQLMockServer.d.ts +0 -4
- package/dist/src/server/startGraphQLMockServer/startGraphQLMockServer.js +0 -29
- package/dist/src/server/startRestMockServer/startRestMockServer.d.ts +0 -4
- package/dist/src/server/startRestMockServer/startRestMockServer.js +0 -29
- package/dist/src/utils/helpers/url/getUrlParts/getUrlParts.d.ts +0 -1
- package/dist/src/utils/helpers/url/getUrlParts/getUrlParts.js +0 -12
- package/dist/src/utils/helpers/url/removeLeadingAndTrailingSlashes/removeLeadingAndTrailingSlashes.d.ts +0 -1
- package/dist/src/utils/helpers/url/removeLeadingAndTrailingSlashes/removeLeadingAndTrailingSlashes.js +0 -11
- package/dist/src/utils/validate/isOnlyRequestedDataResolvingPropertyExists.d.ts +0 -4
- package/dist/src/utils/validate/isOnlyRequestedDataResolvingPropertyExists.js +0 -16
- package/dist/src/utils/validate/validateApiMockServerConfig.d.ts +0 -2
- package/dist/src/utils/validate/validateApiMockServerConfig.js +0 -48
|
@@ -5,14 +5,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
function _export(target, all) {
|
|
6
6
|
for(var name in all)Object.defineProperty(target, name, {
|
|
7
7
|
enumerable: true,
|
|
8
|
-
get: all
|
|
8
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
-
restConfigSchema
|
|
12
|
+
get restConfigSchema () {
|
|
13
13
|
return restConfigSchema;
|
|
14
14
|
},
|
|
15
|
-
restRequestConfigSchema
|
|
15
|
+
get restRequestConfigSchema () {
|
|
16
16
|
return restRequestConfigSchema;
|
|
17
17
|
}
|
|
18
18
|
});
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import type { RestMethod } from '../../../types';
|
|
3
|
-
export declare const routeConfigSchema: (method: RestMethod) => z.
|
|
3
|
+
export declare const routeConfigSchema: (method: RestMethod) => z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodObject<{
|
|
4
4
|
settings: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>;
|
|
5
5
|
data: z.ZodUnion<[z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>, z.ZodAny]>;
|
|
6
|
-
}, {
|
|
7
6
|
entities: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>;
|
|
8
7
|
interceptors: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>;
|
|
9
|
-
}
|
|
8
|
+
}, "strict", z.ZodTypeAny, {
|
|
10
9
|
data?: any;
|
|
11
10
|
interceptors?: any;
|
|
12
11
|
entities?: any;
|
|
@@ -16,82 +15,4 @@ export declare const routeConfigSchema: (method: RestMethod) => z.ZodUnion<[z.Zo
|
|
|
16
15
|
interceptors?: unknown;
|
|
17
16
|
entities?: unknown;
|
|
18
17
|
settings?: unknown;
|
|
19
|
-
}
|
|
20
|
-
settings: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>;
|
|
21
|
-
file: z.ZodString;
|
|
22
|
-
}, {
|
|
23
|
-
entities: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>;
|
|
24
|
-
interceptors: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>;
|
|
25
|
-
}>, "strict", z.ZodTypeAny, {
|
|
26
|
-
file: string;
|
|
27
|
-
interceptors?: any;
|
|
28
|
-
entities?: any;
|
|
29
|
-
settings?: any;
|
|
30
|
-
}, {
|
|
31
|
-
file: string;
|
|
32
|
-
interceptors?: unknown;
|
|
33
|
-
entities?: unknown;
|
|
34
|
-
settings?: unknown;
|
|
35
|
-
}>>, z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodObject<z.objectUtil.extendShape<{
|
|
36
|
-
settings: z.ZodObject<z.objectUtil.extendShape<{
|
|
37
|
-
polling: z.ZodOptional<z.ZodBoolean>;
|
|
38
|
-
status: z.ZodOptional<z.ZodNumber>;
|
|
39
|
-
delay: z.ZodOptional<z.ZodNumber>;
|
|
40
|
-
}, {
|
|
41
|
-
polling: z.ZodLiteral<true>;
|
|
42
|
-
}>, "strict", z.ZodTypeAny, {
|
|
43
|
-
polling: true;
|
|
44
|
-
status?: number | undefined;
|
|
45
|
-
delay?: number | undefined;
|
|
46
|
-
}, {
|
|
47
|
-
polling: true;
|
|
48
|
-
status?: number | undefined;
|
|
49
|
-
delay?: number | undefined;
|
|
50
|
-
}>;
|
|
51
|
-
queue: z.ZodArray<z.ZodUnion<[z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodObject<{
|
|
52
|
-
time: z.ZodOptional<z.ZodNumber>;
|
|
53
|
-
data: z.ZodUnion<[z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>, z.ZodAny]>;
|
|
54
|
-
}, "strict", z.ZodTypeAny, {
|
|
55
|
-
data?: any;
|
|
56
|
-
time?: number | undefined;
|
|
57
|
-
}, {
|
|
58
|
-
data?: any;
|
|
59
|
-
time?: number | undefined;
|
|
60
|
-
}>>, z.ZodObject<{
|
|
61
|
-
time: z.ZodOptional<z.ZodNumber>;
|
|
62
|
-
file: z.ZodString;
|
|
63
|
-
}, "strict", z.ZodTypeAny, {
|
|
64
|
-
file: string;
|
|
65
|
-
time?: number | undefined;
|
|
66
|
-
}, {
|
|
67
|
-
file: string;
|
|
68
|
-
time?: number | undefined;
|
|
69
|
-
}>]>, "many">;
|
|
70
|
-
}, {
|
|
71
|
-
entities: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>;
|
|
72
|
-
interceptors: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>;
|
|
73
|
-
}>, "strict", z.ZodTypeAny, {
|
|
74
|
-
queue: ({
|
|
75
|
-
data?: any;
|
|
76
|
-
time?: number | undefined;
|
|
77
|
-
} | {
|
|
78
|
-
file: string;
|
|
79
|
-
time?: number | undefined;
|
|
80
|
-
})[];
|
|
81
|
-
settings: {
|
|
82
|
-
polling: true;
|
|
83
|
-
status?: number | undefined;
|
|
84
|
-
delay?: number | undefined;
|
|
85
|
-
};
|
|
86
|
-
interceptors?: any;
|
|
87
|
-
entities?: any;
|
|
88
|
-
}, {
|
|
89
|
-
queue: unknown[];
|
|
90
|
-
settings: {
|
|
91
|
-
polling: true;
|
|
92
|
-
status?: number | undefined;
|
|
93
|
-
delay?: number | undefined;
|
|
94
|
-
};
|
|
95
|
-
interceptors?: unknown;
|
|
96
|
-
entities?: unknown;
|
|
97
|
-
}>>]>;
|
|
18
|
+
}>>;
|
|
@@ -11,8 +11,6 @@ Object.defineProperty(exports, "routeConfigSchema", {
|
|
|
11
11
|
const _zod = require("zod");
|
|
12
12
|
const _helpers = require("../../../helpers");
|
|
13
13
|
const _interceptorsSchema = require("../../interceptorsSchema/interceptorsSchema");
|
|
14
|
-
const _isOnlyRequestedDataResolvingPropertyExists = require("../../isOnlyRequestedDataResolvingPropertyExists");
|
|
15
|
-
const _queueSchema = require("../../queueSchema/queueSchema");
|
|
16
14
|
const _settingsSchema = require("../../settingsSchema/settingsSchema");
|
|
17
15
|
const _utils = require("../../utils");
|
|
18
16
|
const METHODS_WITH_BODY = [
|
|
@@ -32,33 +30,13 @@ const entitiesByEntityNameSchema = (method)=>{
|
|
|
32
30
|
}
|
|
33
31
|
}));
|
|
34
32
|
};
|
|
35
|
-
const baseRouteConfigSchema = (method)=>_zod.z.strictObject({
|
|
36
|
-
entities: entitiesByEntityNameSchema(method).optional(),
|
|
37
|
-
interceptors: (0, _utils.plainObjectSchema)(_interceptorsSchema.interceptorsSchema).optional()
|
|
38
|
-
});
|
|
39
33
|
const dataRouteConfigSchema = (method)=>_zod.z.strictObject({
|
|
40
|
-
settings: (0, _utils.plainObjectSchema)(_settingsSchema.settingsSchema.
|
|
41
|
-
polling: _zod.z.literal(false).optional()
|
|
42
|
-
})).optional(),
|
|
34
|
+
settings: (0, _utils.plainObjectSchema)(_settingsSchema.settingsSchema).optional(),
|
|
43
35
|
data: _zod.z.union([
|
|
44
36
|
_zod.z.function(),
|
|
45
37
|
_zod.z.any()
|
|
46
|
-
])
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
})).optional(),
|
|
52
|
-
file: _zod.z.string()
|
|
53
|
-
}).merge(baseRouteConfigSchema(method));
|
|
54
|
-
const queueRouteConfigSchema = (method)=>_zod.z.strictObject({
|
|
55
|
-
settings: _settingsSchema.settingsSchema.extend({
|
|
56
|
-
polling: _zod.z.literal(true)
|
|
57
|
-
}),
|
|
58
|
-
queue: _queueSchema.queueSchema
|
|
59
|
-
}).merge(baseRouteConfigSchema(method));
|
|
60
|
-
const routeConfigSchema = (method)=>_zod.z.union([
|
|
61
|
-
_zod.z.custom((value)=>(0, _helpers.isPlainObject)(value) && (0, _isOnlyRequestedDataResolvingPropertyExists.isOnlyRequestedDataResolvingPropertyExists)(value, 'data')).pipe(dataRouteConfigSchema(method)),
|
|
62
|
-
_zod.z.custom((value)=>(0, _helpers.isPlainObject)(value) && (0, _isOnlyRequestedDataResolvingPropertyExists.isOnlyRequestedDataResolvingPropertyExists)(value, 'file')).pipe(fileRouteConfigSchema(method)),
|
|
63
|
-
_zod.z.custom((value)=>(0, _helpers.isPlainObject)(value) && (0, _isOnlyRequestedDataResolvingPropertyExists.isOnlyRequestedDataResolvingPropertyExists)(value, 'queue')).pipe(queueRouteConfigSchema(method))
|
|
64
|
-
]);
|
|
38
|
+
]),
|
|
39
|
+
entities: entitiesByEntityNameSchema(method).optional(),
|
|
40
|
+
interceptors: (0, _utils.plainObjectSchema)(_interceptorsSchema.interceptorsSchema).optional()
|
|
41
|
+
});
|
|
42
|
+
const routeConfigSchema = (method)=>_zod.z.custom((value)=>(0, _helpers.isPlainObject)(value) && 'data' in value).pipe(dataRouteConfigSchema(method));
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
export declare const settingsSchema: z.ZodObject<{
|
|
3
|
-
polling: z.ZodOptional<z.ZodBoolean>;
|
|
4
3
|
status: z.ZodOptional<z.ZodNumber>;
|
|
5
4
|
delay: z.ZodOptional<z.ZodNumber>;
|
|
6
5
|
}, "strict", z.ZodTypeAny, {
|
|
7
6
|
status?: number | undefined;
|
|
8
|
-
polling?: boolean | undefined;
|
|
9
7
|
delay?: number | undefined;
|
|
10
8
|
}, {
|
|
11
9
|
status?: number | undefined;
|
|
12
|
-
polling?: boolean | undefined;
|
|
13
10
|
delay?: number | undefined;
|
|
14
11
|
}>;
|
|
@@ -10,7 +10,6 @@ Object.defineProperty(exports, "settingsSchema", {
|
|
|
10
10
|
});
|
|
11
11
|
const _zod = require("zod");
|
|
12
12
|
const settingsSchema = _zod.z.strictObject({
|
|
13
|
-
polling: _zod.z.boolean().optional(),
|
|
14
13
|
status: _zod.z.number().min(200).max(599).optional(),
|
|
15
14
|
delay: _zod.z.number().nonnegative().optional()
|
|
16
15
|
});
|
|
@@ -5,23 +5,23 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
function _export(target, all) {
|
|
6
6
|
for(var name in all)Object.defineProperty(target, name, {
|
|
7
7
|
enumerable: true,
|
|
8
|
-
get: all
|
|
8
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
-
checkActualValueCheckModeSchema
|
|
12
|
+
get checkActualValueCheckModeSchema () {
|
|
13
13
|
return checkActualValueCheckModeSchema;
|
|
14
14
|
},
|
|
15
|
-
compareWithDescriptorAnyValueCheckModeSchema
|
|
15
|
+
get compareWithDescriptorAnyValueCheckModeSchema () {
|
|
16
16
|
return compareWithDescriptorAnyValueCheckModeSchema;
|
|
17
17
|
},
|
|
18
|
-
compareWithDescriptorStringValueCheckModeSchema
|
|
18
|
+
get compareWithDescriptorStringValueCheckModeSchema () {
|
|
19
19
|
return compareWithDescriptorStringValueCheckModeSchema;
|
|
20
20
|
},
|
|
21
|
-
compareWithDescriptorValueCheckModeSchema
|
|
21
|
+
get compareWithDescriptorValueCheckModeSchema () {
|
|
22
22
|
return compareWithDescriptorValueCheckModeSchema;
|
|
23
23
|
},
|
|
24
|
-
entityDescriptorSchema
|
|
24
|
+
get entityDescriptorSchema () {
|
|
25
25
|
return entityDescriptorSchema;
|
|
26
26
|
}
|
|
27
27
|
});
|
|
@@ -5,17 +5,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
function _export(target, all) {
|
|
6
6
|
for(var name in all)Object.defineProperty(target, name, {
|
|
7
7
|
enumerable: true,
|
|
8
|
-
get: all
|
|
8
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
-
bodyPlainEntitySchema
|
|
12
|
+
get bodyPlainEntitySchema () {
|
|
13
13
|
return bodyPlainEntitySchema;
|
|
14
14
|
},
|
|
15
|
-
mappedEntitySchema
|
|
15
|
+
get mappedEntitySchema () {
|
|
16
16
|
return mappedEntitySchema;
|
|
17
17
|
},
|
|
18
|
-
variablesPlainEntitySchema
|
|
18
|
+
get variablesPlainEntitySchema () {
|
|
19
19
|
return variablesPlainEntitySchema;
|
|
20
20
|
}
|
|
21
21
|
});
|
|
@@ -5,14 +5,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
function _export(target, all) {
|
|
6
6
|
for(var name in all)Object.defineProperty(target, name, {
|
|
7
7
|
enumerable: true,
|
|
8
|
-
get: all
|
|
8
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
-
jsonLiteralSchema
|
|
12
|
+
get jsonLiteralSchema () {
|
|
13
13
|
return jsonLiteralSchema;
|
|
14
14
|
},
|
|
15
|
-
jsonSchema
|
|
15
|
+
get jsonSchema () {
|
|
16
16
|
return jsonSchema;
|
|
17
17
|
}
|
|
18
18
|
});
|
|
@@ -10,4 +10,4 @@ Object.defineProperty(exports, "requiredPropertiesSchema", {
|
|
|
10
10
|
});
|
|
11
11
|
const _zod = require("zod");
|
|
12
12
|
const _helpers = require("../../../helpers");
|
|
13
|
-
const requiredPropertiesSchema = (schema, requiredProperties)=>_zod.z.custom((value)=>(0, _helpers.isPlainObject)(value) && requiredProperties.every((property)=>Object.
|
|
13
|
+
const requiredPropertiesSchema = (schema, requiredProperties)=>_zod.z.custom((value)=>(0, _helpers.isPlainObject)(value) && requiredProperties.every((property)=>Object.hasOwn(value, property))).pipe(schema);
|
|
@@ -5,14 +5,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
function _export(target, all) {
|
|
6
6
|
for(var name in all)Object.defineProperty(target, name, {
|
|
7
7
|
enumerable: true,
|
|
8
|
-
get: all
|
|
8
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
-
stringForwardSlashSchema
|
|
12
|
+
get stringForwardSlashSchema () {
|
|
13
13
|
return stringForwardSlashSchema;
|
|
14
14
|
},
|
|
15
|
-
stringJsonFilenameSchema
|
|
15
|
+
get stringJsonFilenameSchema () {
|
|
16
16
|
return stringJsonFilenameSchema;
|
|
17
17
|
}
|
|
18
18
|
});
|
|
@@ -21,22 +21,32 @@ const _restConfigSchema = require("./restConfigSchema/restConfigSchema");
|
|
|
21
21
|
const _staticPathSchema = require("./staticPathSchema/staticPathSchema");
|
|
22
22
|
const _utils = require("./utils");
|
|
23
23
|
const validateMockServerConfig = (mockServerConfig)=>{
|
|
24
|
-
if (!mockServerConfig.
|
|
25
|
-
throw new Error('
|
|
24
|
+
if (!mockServerConfig.length) {
|
|
25
|
+
throw new Error('Config should contain at least one element; see our doc (https://github.com/siberiacancode/mock-config-server) for more information');
|
|
26
26
|
}
|
|
27
|
-
const
|
|
27
|
+
const mockServerSettingsSchema = _zod.z.strictObject({
|
|
28
28
|
baseUrl: _baseUrlSchema.baseUrlSchema.optional(),
|
|
29
29
|
port: _portSchema.portSchema.optional(),
|
|
30
30
|
staticPath: _staticPathSchema.staticPathSchema.optional(),
|
|
31
31
|
interceptors: (0, _utils.plainObjectSchema)(_interceptorsSchema.interceptorsSchema).optional(),
|
|
32
32
|
cors: _corsSchema.corsSchema.optional(),
|
|
33
|
-
rest: _restConfigSchema.restConfigSchema.optional(),
|
|
34
|
-
graphql: _graphqlConfigSchema.graphqlConfigSchema.optional(),
|
|
35
33
|
database: _databaseConfigSchema.databaseConfigSchema.optional()
|
|
36
34
|
});
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
const mockServerComponentSchema = _zod.z.strictObject({
|
|
36
|
+
name: _zod.z.string().optional(),
|
|
37
|
+
baseUrl: _baseUrlSchema.baseUrlSchema.optional(),
|
|
38
|
+
interceptors: (0, _utils.plainObjectSchema)(_interceptorsSchema.interceptorsSchema).optional(),
|
|
39
|
+
configs: _zod.z.array(_zod.z.union([
|
|
40
|
+
_restConfigSchema.restRequestConfigSchema,
|
|
41
|
+
_graphqlConfigSchema.graphqlRequestConfigSchema
|
|
42
|
+
]))
|
|
43
|
+
});
|
|
44
|
+
const mockServerConfigSchema = _zod.z.tuple([
|
|
45
|
+
(0, _utils.plainObjectSchema)(mockServerSettingsSchema).or(mockServerComponentSchema)
|
|
46
|
+
]).rest(mockServerComponentSchema);
|
|
47
|
+
const validationMockServerConfigSchemaResult = mockServerConfigSchema.safeParse(mockServerConfig);
|
|
48
|
+
if (!validationMockServerConfigSchemaResult.success) {
|
|
49
|
+
const path = (0, _getMostSpecificPathFromError.getMostSpecificPathFromError)(validationMockServerConfigSchemaResult.error);
|
|
40
50
|
const validationMessage = (0, _getValidationMessageFromPath.getValidationMessageFromPath)(path);
|
|
41
51
|
throw new Error(`Validation Error: configuration${validationMessage} does not match the API schema. Click here to see correct type: https://github.com/siberiacancode/mock-config-server`);
|
|
42
52
|
}
|
package/package.json
CHANGED
|
@@ -1,38 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mock-config-server",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0-beta.1",
|
|
4
4
|
"description": "Tool that easily and quickly imitates server operation, create full fake api in few steps",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "SIBERIA CAN CODE 🧊",
|
|
7
7
|
"url": "https://github.com/siberiacancode"
|
|
8
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
|
-
"name": "Alexander Vasilchuk",
|
|
24
|
-
"url": "https://github.com/anv296"
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
"name": "Daria Bortsova",
|
|
28
|
-
"url": "https://github.com/kvelian"
|
|
29
|
-
}
|
|
30
|
-
],
|
|
31
9
|
"license": "MIT",
|
|
32
|
-
"homepage": "https://github.com/siberiacancode/mock-config
|
|
10
|
+
"homepage": "https://github.com/siberiacancode/mock-config",
|
|
33
11
|
"repository": {
|
|
34
12
|
"type": "git",
|
|
35
|
-
"url": "https://github.com/siberiacancode/mock-config-server.git"
|
|
13
|
+
"url": "git+https://github.com/siberiacancode/mock-config-server.git"
|
|
14
|
+
},
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://github.com/siberiacancode/mock-config/issues"
|
|
36
17
|
},
|
|
37
18
|
"keywords": [
|
|
38
19
|
"server",
|
|
@@ -56,28 +37,29 @@
|
|
|
56
37
|
"dist"
|
|
57
38
|
],
|
|
58
39
|
"engines": {
|
|
59
|
-
"node": "^
|
|
40
|
+
"node": "^16.0.0 || >=17.0.0"
|
|
60
41
|
},
|
|
61
42
|
"scripts": {
|
|
62
43
|
"prepublishOnly": "git diff --exit-code",
|
|
63
|
-
"
|
|
44
|
+
"lint-staged": "lint-staged",
|
|
45
|
+
"prepare": "husky && pnpm build",
|
|
64
46
|
"build:types": "tsc -p tsconfig.production.json && tsc-alias -p tsconfig.production.json",
|
|
65
47
|
"build:swc": "swc bin src index.ts -d dist --extensions .ts --copy-files --ignore **/*.test.ts --ignore bin/templates",
|
|
66
48
|
"build:copy-templates": "shx mkdir -p dist/bin/templates/ts && shx cp -r bin/templates/ts dist/bin/templates && shx mkdir -p dist/bin/templates/js && shx cp -r bin/templates/js dist/bin/templates",
|
|
67
|
-
"build": "shx rm -rf dist &&
|
|
68
|
-
"start": "
|
|
69
|
-
"dev": "nodemon --watch src --watch bin --watch mock-server.config.* -e js,ts --exec \"
|
|
49
|
+
"build": "shx rm -rf dist && pnpm build:types && pnpm build:swc && pnpm build:copy-templates",
|
|
50
|
+
"start": "pnpm build && node ./dist/bin/bin.js",
|
|
51
|
+
"dev": "nodemon --watch src --watch bin --watch mock-server.config.* -e js,ts --exec \"pnpm start\"",
|
|
70
52
|
"type": "tsc --noEmit",
|
|
71
53
|
"unit-test": "vitest",
|
|
72
54
|
"lint": "eslint . --fix",
|
|
73
55
|
"lint-inspector": "npx @eslint/config-inspector",
|
|
74
|
-
"stylelint": "stylelint \"src/static/**/*.css\" --fix",
|
|
75
56
|
"format": "prettier --write \"**/*.(ts|js)\"",
|
|
76
|
-
"pretty": "
|
|
57
|
+
"pretty": "pnpm lint && pnpm format"
|
|
77
58
|
},
|
|
78
59
|
"dependencies": {
|
|
79
60
|
"@types/body-parser": "^1.19.5",
|
|
80
61
|
"@types/express": "^4.17.21",
|
|
62
|
+
"@types/express-serve-static-core": "^5.0.7",
|
|
81
63
|
"@types/flat": "^5.0.5",
|
|
82
64
|
"@types/prompts": "^2.4.9",
|
|
83
65
|
"@types/yargs": "^17.0.33",
|
|
@@ -94,8 +76,6 @@
|
|
|
94
76
|
"zod": "^3.24.1"
|
|
95
77
|
},
|
|
96
78
|
"devDependencies": {
|
|
97
|
-
"@siberiacancode/eslint": "^2.6.0",
|
|
98
|
-
"@siberiacancode/prettier": "^1.1.1",
|
|
99
79
|
"@siberiacancode/vitest": "^1.2.4",
|
|
100
80
|
"@swc/cli": "^0.6.0",
|
|
101
81
|
"@swc/core": "^1.10.7",
|
|
@@ -106,18 +86,15 @@
|
|
|
106
86
|
"shx": "^0.3.4",
|
|
107
87
|
"supertest": "^7.0.0",
|
|
108
88
|
"tsc-alias": "^1.8.10",
|
|
109
|
-
"
|
|
89
|
+
"vitest": "^3.2.4"
|
|
110
90
|
},
|
|
111
91
|
"lint-staged": {
|
|
112
|
-
"*.css": [
|
|
113
|
-
"stylelint --fix"
|
|
114
|
-
],
|
|
115
92
|
"*.js": [
|
|
116
93
|
"prettier --write"
|
|
117
94
|
],
|
|
118
95
|
"*.ts": [
|
|
119
|
-
"
|
|
120
|
-
"
|
|
96
|
+
"eslint --no-error-on-unmatched-pattern --fix",
|
|
97
|
+
"prettier --write"
|
|
121
98
|
]
|
|
122
99
|
}
|
|
123
100
|
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2023 siberiacancode
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import type { FlatMockServerConfig, MockServerConfigArgv } from '../src';
|
|
3
|
-
export declare const runFlatConfig: (flatMockServerConfig: FlatMockServerConfig, { baseUrl, port, staticPath }: MockServerConfigArgv) => (import("http").Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse> & {
|
|
4
|
-
destroy: import("http").Server["close"];
|
|
5
|
-
}) | undefined;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "runFlatConfig", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function() {
|
|
9
|
-
return runFlatConfig;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
const _server = require("../src/server");
|
|
13
|
-
const runFlatConfig = (flatMockServerConfig, { baseUrl, port, staticPath })=>{
|
|
14
|
-
try {
|
|
15
|
-
const [option, ...flatMockServerComponents] = flatMockServerConfig;
|
|
16
|
-
const flatMockServerSettings = !('configs' in option) ? option : undefined;
|
|
17
|
-
const mergedFlatMockServerConfig = [
|
|
18
|
-
{
|
|
19
|
-
...flatMockServerSettings,
|
|
20
|
-
...baseUrl && {
|
|
21
|
-
baseUrl
|
|
22
|
-
},
|
|
23
|
-
...port && {
|
|
24
|
-
port
|
|
25
|
-
},
|
|
26
|
-
...staticPath && {
|
|
27
|
-
staticPath
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
...flatMockServerSettings ? flatMockServerComponents : flatMockServerConfig
|
|
31
|
-
];
|
|
32
|
-
return (0, _server.startFlatMockServer)(mergedFlatMockServerConfig);
|
|
33
|
-
} catch (error) {
|
|
34
|
-
console.error(error.message);
|
|
35
|
-
}
|
|
36
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { IRouter } from 'express';
|
|
2
|
-
import type { GraphqlConfig, Interceptors } from '../../../utils/types';
|
|
3
|
-
interface CreateGraphQLRoutesParams {
|
|
4
|
-
graphqlConfig: GraphqlConfig;
|
|
5
|
-
router: IRouter;
|
|
6
|
-
serverResponseInterceptor?: Interceptors<'graphql'>['response'];
|
|
7
|
-
}
|
|
8
|
-
export declare const createGraphQLRoutes: ({ router, graphqlConfig, serverResponseInterceptor }: CreateGraphQLRoutesParams) => IRouter;
|
|
9
|
-
export {};
|