mock-config-server 3.7.1 → 4.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/README.md +272 -224
- package/dist/bin/bin.js +1 -1
- package/dist/bin/build.d.ts +3 -1
- package/dist/bin/build.js +10 -0
- package/dist/bin/helpers/createTemplate.d.ts +3 -3
- package/dist/bin/helpers/createTemplate.js +1 -1
- package/dist/bin/helpers/index.d.ts +0 -3
- package/dist/bin/helpers/index.js +0 -3
- package/dist/bin/helpers/resolveConfigFile.d.ts +2 -2
- package/dist/bin/helpers/resolveConfigFile.js +2 -2
- package/dist/bin/helpers/resolveConfigFilePath.js +4 -4
- package/dist/bin/helpers/resolveExportsFromSourceCode.js +1 -2
- package/dist/bin/init.js +5 -8
- package/dist/bin/run.d.ts +1 -2
- package/dist/bin/run.js +1 -6
- package/dist/bin/runFlatConfig.d.ts +5 -0
- package/dist/bin/runFlatConfig.js +36 -0
- package/dist/bin/templates/js/full/mock-server.config.js +10 -7
- package/dist/bin/templates/js/graphql/mock-server.config.js +11 -6
- package/dist/bin/templates/js/rest/mock-server.config.js +11 -6
- package/dist/bin/templates/ts/full/mock-server.config.ts +11 -8
- package/dist/bin/templates/ts/graphql/mock-server.config.ts +12 -7
- package/dist/bin/templates/ts/rest/mock-server.config.ts +12 -7
- package/dist/src/core/database/createDatabaseRoutes/createDatabaseRoutes.js +2 -1
- package/dist/src/core/database/createDatabaseRoutes/helpers/createNestedDatabaseRoutes/createNestedDatabaseRoutes.js +8 -12
- package/dist/src/core/database/createDatabaseRoutes/helpers/filter/filter.d.ts +0 -1
- package/dist/src/core/database/createDatabaseRoutes/helpers/pagination/pagination.d.ts +0 -1
- package/dist/src/core/database/createDatabaseRoutes/helpers/search/search.d.ts +0 -1
- package/dist/src/core/database/createDatabaseRoutes/helpers/sort/sort.d.ts +0 -1
- package/dist/src/core/database/createDatabaseRoutes/helpers/splitDatabaseByNesting/splitDatabaseByNesting.d.ts +1 -1
- package/dist/src/core/database/createDatabaseRoutes/storages/File/FileStorage.d.ts +5 -6
- 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/database/createDatabaseRoutes/storages/Memory/MemoryStorage.d.ts +6 -7
- package/dist/src/core/database/createOrm/createOrm.d.ts +2 -0
- package/dist/src/core/database/createOrm/createOrm.js +119 -0
- package/dist/src/core/database/createStorage/createStorage.d.ts +2 -0
- package/dist/src/core/database/createStorage/createStorage.js +13 -0
- package/dist/src/core/database/index.d.ts +2 -0
- package/dist/src/core/database/index.js +2 -0
- package/dist/src/core/graphql/createGraphQLRoutes/createGraphQLRoutes.d.ts +1 -1
- package/dist/src/core/graphql/createGraphQLRoutes/createGraphQLRoutes.js +39 -17
- package/dist/src/core/graphql/createGraphQLRoutes/helpers/prepareGraphQLRequestConfigs/prepareGraphQLRequestConfigs.js +2 -2
- package/dist/src/core/middlewares/contextMiddleware/contextMiddleware.d.ts +2 -2
- package/dist/src/core/middlewares/contextMiddleware/contextMiddleware.js +11 -1
- package/dist/src/core/middlewares/destroyerMiddleware/destroyerMiddleware.d.ts +1 -2
- package/dist/src/core/middlewares/index.d.ts +0 -1
- package/dist/src/core/middlewares/index.js +0 -1
- package/dist/src/core/middlewares/requestInterceptorMiddleware/requestInterceptorMiddleware.d.ts +2 -2
- package/dist/src/core/rest/createRestRoutes/createRestRoutes.d.ts +1 -1
- package/dist/src/core/rest/createRestRoutes/createRestRoutes.js +80 -24
- package/dist/src/server/createDatabaseMockServer/createDatabaseMockServer.d.ts +1 -1
- package/dist/src/server/createDatabaseMockServer/createDatabaseMockServer.js +6 -6
- package/dist/src/server/createFlatMockServer/createFlatMockServer.d.ts +3 -0
- package/dist/src/server/createFlatMockServer/createFlatMockServer.js +127 -0
- package/dist/src/server/createGraphQLMockServer/createGraphQLMockServer.d.ts +1 -1
- package/dist/src/server/createGraphQLMockServer/createGraphQLMockServer.js +3 -6
- package/dist/src/server/createMockServer/createMockServer.d.ts +1 -1
- package/dist/src/server/createMockServer/createMockServer.js +3 -5
- package/dist/src/server/createRestMockServer/createRestMockServer.d.ts +1 -1
- package/dist/src/server/createRestMockServer/createRestMockServer.js +3 -6
- package/dist/src/server/index.d.ts +2 -0
- package/dist/src/server/index.js +2 -0
- package/dist/src/server/startDatabaseMockServer/startDatabaseMockServer.d.ts +1 -2
- package/dist/src/server/startFlatMockServer/startFlatMockServer.d.ts +4 -0
- package/dist/src/server/startFlatMockServer/startFlatMockServer.js +28 -0
- package/dist/src/server/startGraphQLMockServer/startGraphQLMockServer.d.ts +1 -2
- package/dist/src/server/startMockServer/startMockServer.d.ts +1 -2
- package/dist/src/server/startRestMockServer/startRestMockServer.d.ts +1 -2
- package/dist/src/utils/constants/checkModes.d.ts +1 -3
- package/dist/src/utils/constants/checkModes.js +3 -19
- package/dist/src/utils/helpers/config/resolveEntityValues/resolveEntityValues.d.ts +20 -2
- package/dist/src/utils/helpers/config/resolveEntityValues/resolveEntityValues.js +37 -71
- package/dist/src/utils/helpers/files/index.d.ts +1 -0
- package/dist/src/utils/helpers/files/index.js +1 -0
- package/dist/src/utils/helpers/files/isFileDescriptor/isFileDescriptor.d.ts +2 -0
- package/dist/src/utils/helpers/files/isFileDescriptor/isFileDescriptor.js +16 -0
- package/dist/src/utils/helpers/files/isFilePathValid/isFilePathValid.js +3 -3
- package/dist/src/utils/helpers/graphql/getGraphQLInput/getGraphQLInput.js +6 -2
- package/dist/src/utils/helpers/graphql/parseQuery/parseQuery.d.ts +1 -1
- package/dist/src/utils/helpers/index.d.ts +0 -1
- package/dist/src/utils/helpers/index.js +0 -1
- package/dist/src/utils/helpers/interceptors/callRequestInterceptor/callRequestInterceptor.d.ts +1 -1
- package/dist/src/utils/helpers/interceptors/callRequestInterceptor/callRequestInterceptor.js +2 -1
- package/dist/src/utils/helpers/interceptors/callResponseInterceptors/callResponseInterceptors.js +10 -5
- package/dist/src/utils/helpers/logger/callResponseLogger/callResponseLogger.d.ts +1 -1
- package/dist/src/utils/helpers/tests/createTmpDir.js +4 -4
- package/dist/src/utils/helpers/url/convertWin32PathToUnix/convertWin32PathToUnix.js +1 -1
- package/dist/src/utils/helpers/url/urlJoin/urlJoin.js +4 -4
- package/dist/src/utils/types/checkModes.d.ts +14 -7
- package/dist/src/utils/types/database.d.ts +30 -0
- package/dist/src/utils/types/entities.d.ts +13 -43
- package/dist/src/utils/types/files.d.ts +5 -0
- package/dist/src/utils/types/files.js +4 -0
- package/dist/src/utils/types/graphql.d.ts +9 -8
- 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 +21 -16
- package/dist/src/utils/types/logger.d.ts +11 -11
- package/dist/src/utils/types/rest.d.ts +17 -12
- package/dist/src/utils/types/server.d.ts +48 -20
- package/dist/src/utils/types/shared.d.ts +1 -1
- package/dist/src/utils/types/utils.d.ts +4 -4
- package/dist/src/utils/types/values.d.ts +3 -4
- package/dist/{bin/validateMockServerConfig → src/utils/validate}/corsSchema/corsSchema.d.ts +2 -2
- package/dist/{bin/helpers → src/utils/validate}/getMostSpecificPathFromError.d.ts +1 -1
- package/dist/src/utils/validate/getValidationMessageFromPath.d.ts +1 -0
- package/dist/src/utils/validate/graphqlConfigSchema/graphqlConfigSchema.d.ts +535 -0
- package/dist/{bin/validateMockServerConfig → src/utils/validate}/graphqlConfigSchema/graphqlConfigSchema.js +14 -6
- package/dist/{bin/validateMockServerConfig → src/utils/validate}/graphqlConfigSchema/routeConfigSchema/routeConfigSchema.d.ts +20 -5
- package/dist/{bin/validateMockServerConfig → src/utils/validate}/graphqlConfigSchema/routeConfigSchema/routeConfigSchema.js +5 -5
- package/dist/src/utils/validate/index.d.ts +14 -0
- package/dist/src/utils/validate/index.js +31 -0
- package/dist/{bin/helpers → src/utils/validate}/isOnlyRequestedDataResolvingPropertyExists.d.ts +1 -1
- package/dist/src/utils/validate/queueSchema/queueSchema.d.ts +20 -0
- package/dist/src/utils/validate/queueSchema/queueSchema.js +24 -0
- package/dist/src/utils/validate/restConfigSchema/restConfigSchema.d.ts +1659 -0
- package/dist/{bin/validateMockServerConfig → src/utils/validate}/restConfigSchema/restConfigSchema.js +13 -5
- package/dist/{bin/validateMockServerConfig → src/utils/validate}/restConfigSchema/routeConfigSchema/routeConfigSchema.d.ts +21 -6
- package/dist/{bin/validateMockServerConfig → src/utils/validate}/restConfigSchema/routeConfigSchema/routeConfigSchema.js +6 -6
- package/dist/src/utils/validate/utils/checkModeSchema/checkModeSchema.d.ts +23 -0
- package/dist/{bin/validateMockServerConfig → src/utils/validate}/utils/checkModeSchema/checkModeSchema.js +24 -1
- package/dist/src/utils/validate/utils/entitiesSchema/entitiesSchema.d.ts +4 -0
- package/dist/src/utils/validate/utils/entitiesSchema/entitiesSchema.js +94 -0
- package/dist/src/utils/validate/utils/extendedDiscriminatedUnion/extendedDiscriminatedUnion.d.ts +8 -0
- package/dist/src/utils/validate/utils/extendedDiscriminatedUnion/extendedDiscriminatedUnion.js +46 -0
- package/dist/{bin/validateMockServerConfig → src/utils/validate}/utils/index.d.ts +2 -2
- package/dist/{bin/validateMockServerConfig → src/utils/validate}/utils/index.js +2 -2
- package/dist/{bin/validateMockServerConfig → src/utils/validate}/utils/jsonSchema/jsonSchema.d.ts +2 -2
- package/dist/{bin/validateMockServerConfig → src/utils/validate}/utils/jsonSchema/jsonSchema.js +1 -1
- package/dist/src/utils/validate/utils/nestedObjectOrArraySchema/nestedObjectOrArraySchema.d.ts +3 -0
- package/dist/src/utils/validate/utils/nestedObjectOrArraySchema/nestedObjectOrArraySchema.js +22 -0
- package/dist/{bin/validateMockServerConfig → src/utils/validate}/utils/requiredPropertiesSchema/requiredPropertiesSchema.d.ts +1 -1
- package/dist/{bin/validateMockServerConfig → src/utils/validate}/utils/requiredPropertiesSchema/requiredPropertiesSchema.js +1 -1
- package/dist/src/utils/validate/validateApiMockServerConfig.d.ts +2 -0
- package/dist/{bin/validateMockServerConfig → src/utils/validate}/validateApiMockServerConfig.js +4 -3
- package/dist/src/utils/validate/validateFlatMockServerConfig.d.ts +2 -0
- package/dist/src/utils/validate/validateFlatMockServerConfig.js +53 -0
- package/dist/{bin/validateMockServerConfig → src/utils/validate}/validateMockServerConfig.d.ts +1 -1
- package/dist/{bin/validateMockServerConfig → src/utils/validate}/validateMockServerConfig.js +4 -3
- package/package.json +51 -52
- package/dist/bin/helpers/getValidationMessageFromPath.d.ts +0 -1
- package/dist/bin/validateMockServerConfig/graphqlConfigSchema/graphqlConfigSchema.d.ts +0 -258
- package/dist/bin/validateMockServerConfig/queueSchema/queueSchema.d.ts +0 -8
- package/dist/bin/validateMockServerConfig/queueSchema/queueSchema.js +0 -21
- package/dist/bin/validateMockServerConfig/restConfigSchema/restConfigSchema.d.ts +0 -743
- package/dist/bin/validateMockServerConfig/utils/checkModeSchema/checkModeSchema.d.ts +0 -5
- package/dist/bin/validateMockServerConfig/utils/entitiesSchema/entitiesSchema.d.ts +0 -71
- package/dist/bin/validateMockServerConfig/utils/entitiesSchema/entitiesSchema.js +0 -124
- package/dist/bin/validateMockServerConfig/validateApiMockServerConfig.d.ts +0 -2
- package/dist/src/core/middlewares/notFoundMiddleware/helpers/getGraphqlUrlSuggestions/getGraphqlUrlSuggestions.d.ts +0 -11
- package/dist/src/core/middlewares/notFoundMiddleware/helpers/getGraphqlUrlSuggestions/getGraphqlUrlSuggestions.js +0 -25
- package/dist/src/core/middlewares/notFoundMiddleware/helpers/getLevenshteinDistance/getLevenshteinDistance.d.ts +0 -1
- package/dist/src/core/middlewares/notFoundMiddleware/helpers/getLevenshteinDistance/getLevenshteinDistance.js +0 -85
- package/dist/src/core/middlewares/notFoundMiddleware/helpers/getRestUrlSuggestions/getRestUrlSuggestions.d.ts +0 -11
- package/dist/src/core/middlewares/notFoundMiddleware/helpers/getRestUrlSuggestions/getRestUrlSuggestions.js +0 -39
- package/dist/src/core/middlewares/notFoundMiddleware/helpers/getRestUrlSuggestions/helpers/getActualRestUrlMeaningfulString/getActualRestUrlMeaningfulString.d.ts +0 -1
- package/dist/src/core/middlewares/notFoundMiddleware/helpers/getRestUrlSuggestions/helpers/getActualRestUrlMeaningfulString/getActualRestUrlMeaningfulString.js +0 -11
- package/dist/src/core/middlewares/notFoundMiddleware/helpers/getRestUrlSuggestions/helpers/getPatternRestUrlMeaningfulString/getPatternRestUrlMeaningfulString.d.ts +0 -1
- package/dist/src/core/middlewares/notFoundMiddleware/helpers/getRestUrlSuggestions/helpers/getPatternRestUrlMeaningfulString/getPatternRestUrlMeaningfulString.js +0 -11
- package/dist/src/core/middlewares/notFoundMiddleware/helpers/getRestUrlSuggestions/helpers/index.d.ts +0 -2
- package/dist/src/core/middlewares/notFoundMiddleware/helpers/getRestUrlSuggestions/helpers/index.js +0 -19
- package/dist/src/core/middlewares/notFoundMiddleware/helpers/index.d.ts +0 -3
- package/dist/src/core/middlewares/notFoundMiddleware/helpers/index.js +0 -20
- package/dist/src/core/middlewares/notFoundMiddleware/notFoundMiddleware.d.ts +0 -3
- package/dist/src/core/middlewares/notFoundMiddleware/notFoundMiddleware.js +0 -65
- package/dist/src/static/views/assets/icons/scheme-dark.svg +0 -3
- package/dist/src/static/views/assets/icons/scheme-light.svg +0 -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 +0 -88
- package/dist/src/static/views/components/header/index.css +0 -55
- package/dist/src/static/views/components/header/index.ejs +0 -40
- package/dist/src/static/views/components/header/index.js +0 -1
- package/dist/src/static/views/features/scheme/dark.css +0 -13
- package/dist/src/static/views/features/scheme/index.ejs +0 -3
- package/dist/src/static/views/features/scheme/index.js +0 -31
- package/dist/src/static/views/features/scheme/light.css +0 -13
- package/dist/src/static/views/features/tab/index.css +0 -30
- package/dist/src/static/views/features/tab/index.ejs +0 -2
- package/dist/src/static/views/features/tab/index.js +0 -12
- package/dist/src/static/views/pages/404/index.css +0 -10
- package/dist/src/static/views/pages/404/index.ejs +0 -82
- package/dist/src/utils/helpers/isRegExp/isRegExp.d.ts +0 -1
- package/dist/src/utils/helpers/isRegExp/isRegExp.js +0 -11
- package/dist/{bin/validateMockServerConfig → src/utils/validate}/baseUrlSchema/baseUrlSchema.d.ts +0 -0
- package/dist/{bin/validateMockServerConfig → src/utils/validate}/baseUrlSchema/baseUrlSchema.js +0 -0
- package/dist/{bin/validateMockServerConfig → src/utils/validate}/corsSchema/corsSchema.js +0 -0
- package/dist/{bin/validateMockServerConfig → src/utils/validate}/databaseConfigSchema/databaseConfigSchema.d.ts +0 -0
- package/dist/{bin/validateMockServerConfig → src/utils/validate}/databaseConfigSchema/databaseConfigSchema.js +0 -0
- package/dist/{bin/helpers → src/utils/validate}/getMostSpecificPathFromError.js +0 -0
- package/dist/{bin/helpers → src/utils/validate}/getValidationMessageFromPath.js +0 -0
- package/dist/{bin/validateMockServerConfig → src/utils/validate}/interceptorsSchema/interceptorsSchema.d.ts +0 -0
- package/dist/{bin/validateMockServerConfig → src/utils/validate}/interceptorsSchema/interceptorsSchema.js +0 -0
- package/dist/{bin/helpers → src/utils/validate}/isOnlyRequestedDataResolvingPropertyExists.js +0 -0
- package/dist/{bin/validateMockServerConfig → src/utils/validate}/portSchema/portSchema.d.ts +0 -0
- package/dist/{bin/validateMockServerConfig → src/utils/validate}/portSchema/portSchema.js +0 -0
- package/dist/{bin/validateMockServerConfig → src/utils/validate}/settingsSchema/settingsSchema.d.ts +2 -2
- /package/dist/{bin/validateMockServerConfig → src/utils/validate}/settingsSchema/settingsSchema.js +0 -0
- /package/dist/{bin/validateMockServerConfig → src/utils/validate}/staticPathSchema/staticPathSchema.d.ts +0 -0
- /package/dist/{bin/validateMockServerConfig → src/utils/validate}/staticPathSchema/staticPathSchema.js +0 -0
- /package/dist/{bin/validateMockServerConfig → src/utils/validate}/utils/plainObjectSchema/plainObjectSchema.d.ts +0 -0
- /package/dist/{bin/validateMockServerConfig → src/utils/validate}/utils/plainObjectSchema/plainObjectSchema.js +0 -0
- /package/dist/{bin/validateMockServerConfig → src/utils/validate}/utils/sharedSchema/sharedSchema.d.ts +0 -0
- /package/dist/{bin/validateMockServerConfig → src/utils/validate}/utils/sharedSchema/sharedSchema.js +0 -0
|
@@ -2,10 +2,18 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
restConfigSchema: function() {
|
|
8
13
|
return restConfigSchema;
|
|
14
|
+
},
|
|
15
|
+
restRequestConfigSchema: function() {
|
|
16
|
+
return restRequestConfigSchema;
|
|
9
17
|
}
|
|
10
18
|
});
|
|
11
19
|
const _zod = require("zod");
|
|
@@ -22,7 +30,7 @@ const baseRequestConfigSchema = (method)=>_zod.z.strictObject({
|
|
|
22
30
|
routes: _zod.z.array((0, _routeConfigSchema.routeConfigSchema)(method)),
|
|
23
31
|
interceptors: (0, _utils.plainObjectSchema)(_interceptorsSchema.interceptorsSchema).optional()
|
|
24
32
|
});
|
|
25
|
-
const
|
|
33
|
+
const restRequestConfigSchema = _zod.z.union([
|
|
26
34
|
baseRequestConfigSchema('get'),
|
|
27
35
|
baseRequestConfigSchema('post'),
|
|
28
36
|
baseRequestConfigSchema('put'),
|
|
@@ -32,6 +40,6 @@ const requestConfigSchema = _zod.z.union([
|
|
|
32
40
|
]);
|
|
33
41
|
const restConfigSchema = _zod.z.strictObject({
|
|
34
42
|
baseUrl: _baseUrlSchema.baseUrlSchema.optional(),
|
|
35
|
-
configs: _zod.z.array(
|
|
43
|
+
configs: _zod.z.array(restRequestConfigSchema),
|
|
36
44
|
interceptors: (0, _utils.plainObjectSchema)(_interceptorsSchema.interceptorsSchema).optional()
|
|
37
45
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import type { RestMethod } from '
|
|
2
|
+
import type { RestMethod } from '../../../types';
|
|
3
3
|
export declare const routeConfigSchema: (method: RestMethod) => z.ZodUnion<[z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodObject<z.objectUtil.extendShape<{
|
|
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]>;
|
|
@@ -48,21 +48,36 @@ export declare const routeConfigSchema: (method: RestMethod) => z.ZodUnion<[z.Zo
|
|
|
48
48
|
status?: number | undefined;
|
|
49
49
|
delay?: number | undefined;
|
|
50
50
|
}>;
|
|
51
|
-
queue: z.ZodArray<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.
|
|
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, {
|
|
52
55
|
data?: any;
|
|
53
56
|
time?: number | undefined;
|
|
54
|
-
},
|
|
57
|
+
}, {
|
|
55
58
|
data?: any;
|
|
56
59
|
time?: number | undefined;
|
|
57
|
-
}>>,
|
|
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">;
|
|
58
70
|
}, {
|
|
59
71
|
entities: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>;
|
|
60
72
|
interceptors: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>;
|
|
61
73
|
}>, "strict", z.ZodTypeAny, {
|
|
62
|
-
queue: {
|
|
74
|
+
queue: ({
|
|
63
75
|
data?: any;
|
|
64
76
|
time?: number | undefined;
|
|
65
|
-
}
|
|
77
|
+
} | {
|
|
78
|
+
file: string;
|
|
79
|
+
time?: number | undefined;
|
|
80
|
+
})[];
|
|
66
81
|
settings: {
|
|
67
82
|
polling: true;
|
|
68
83
|
status?: number | undefined;
|
|
@@ -9,9 +9,9 @@ Object.defineProperty(exports, "routeConfigSchema", {
|
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
11
|
const _zod = require("zod");
|
|
12
|
-
const _helpers = require("
|
|
13
|
-
const _helpers1 = require("../../../helpers");
|
|
12
|
+
const _helpers = require("../../../helpers");
|
|
14
13
|
const _interceptorsSchema = require("../../interceptorsSchema/interceptorsSchema");
|
|
14
|
+
const _isOnlyRequestedDataResolvingPropertyExists = require("../../isOnlyRequestedDataResolvingPropertyExists");
|
|
15
15
|
const _queueSchema = require("../../queueSchema/queueSchema");
|
|
16
16
|
const _settingsSchema = require("../../settingsSchema/settingsSchema");
|
|
17
17
|
const _utils = require("../../utils");
|
|
@@ -28,7 +28,7 @@ const entitiesByEntityNameSchema = (method)=>{
|
|
|
28
28
|
params: _utils.mappedEntitySchema.optional(),
|
|
29
29
|
query: _utils.mappedEntitySchema.optional(),
|
|
30
30
|
...isMethodWithBody && {
|
|
31
|
-
body: _utils.
|
|
31
|
+
body: _utils.bodyPlainEntitySchema.optional()
|
|
32
32
|
}
|
|
33
33
|
}));
|
|
34
34
|
};
|
|
@@ -58,7 +58,7 @@ const queueRouteConfigSchema = (method)=>_zod.z.strictObject({
|
|
|
58
58
|
queue: _queueSchema.queueSchema
|
|
59
59
|
}).merge(baseRouteConfigSchema(method));
|
|
60
60
|
const routeConfigSchema = (method)=>_zod.z.union([
|
|
61
|
-
_zod.z.custom((value)=>(0, _helpers.isPlainObject)(value) && (0,
|
|
62
|
-
_zod.z.custom((value)=>(0, _helpers.isPlainObject)(value) && (0,
|
|
63
|
-
_zod.z.custom((value)=>(0, _helpers.isPlainObject)(value) && (0,
|
|
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
64
|
]);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const checkActualValueCheckModeSchema: z.ZodEnum<["exists", "notExists"]>;
|
|
3
|
+
export declare const compareWithDescriptorAnyValueCheckModeSchema: z.ZodEnum<["equals", "notEquals"]>;
|
|
4
|
+
export declare const compareWithDescriptorStringValueCheckModeSchema: z.ZodEnum<["includes", "notIncludes", "startsWith", "notStartsWith", "endsWith", "notEndsWith"]>;
|
|
5
|
+
export declare const compareWithDescriptorValueCheckModeSchema: z.ZodEnum<["equals", "notEquals", "includes", "notIncludes", "startsWith", "notStartsWith", "endsWith", "notEndsWith"]>;
|
|
6
|
+
export interface EntityDescriptorSchema {
|
|
7
|
+
(checkModeSchema: typeof checkActualValueCheckModeSchema): z.ZodObject<{
|
|
8
|
+
checkMode: typeof checkModeSchema;
|
|
9
|
+
}, 'strict'>;
|
|
10
|
+
(checkModeSchema: z.ZodLiteral<'function'> | z.ZodLiteral<'regExp'> | typeof compareWithDescriptorAnyValueCheckModeSchema | typeof compareWithDescriptorStringValueCheckModeSchema | typeof compareWithDescriptorValueCheckModeSchema, valueSchema: z.ZodTypeAny): z.ZodDiscriminatedUnion<'oneOf', [
|
|
11
|
+
z.ZodObject<{
|
|
12
|
+
checkMode: typeof checkModeSchema;
|
|
13
|
+
oneOf: z.ZodLiteral<true>;
|
|
14
|
+
value: z.ZodArray<typeof valueSchema>;
|
|
15
|
+
}, 'strict'>,
|
|
16
|
+
z.ZodObject<{
|
|
17
|
+
checkMode: typeof checkModeSchema;
|
|
18
|
+
oneOf: z.ZodOptional<z.ZodLiteral<false>>;
|
|
19
|
+
value: typeof valueSchema;
|
|
20
|
+
}, 'strict'>
|
|
21
|
+
]>;
|
|
22
|
+
}
|
|
23
|
+
export declare const entityDescriptorSchema: EntityDescriptorSchema;
|
|
@@ -20,11 +20,34 @@ _export(exports, {
|
|
|
20
20
|
},
|
|
21
21
|
compareWithDescriptorValueCheckModeSchema: function() {
|
|
22
22
|
return compareWithDescriptorValueCheckModeSchema;
|
|
23
|
+
},
|
|
24
|
+
entityDescriptorSchema: function() {
|
|
25
|
+
return entityDescriptorSchema;
|
|
23
26
|
}
|
|
24
27
|
});
|
|
25
28
|
const _zod = require("zod");
|
|
26
|
-
const _constants = require("
|
|
29
|
+
const _constants = require("../../../constants");
|
|
27
30
|
const checkActualValueCheckModeSchema = _zod.z.enum(_constants.CHECK_ACTUAL_VALUE_CHECK_MODES);
|
|
28
31
|
const compareWithDescriptorAnyValueCheckModeSchema = _zod.z.enum(_constants.COMPARE_WITH_DESCRIPTOR_ANY_VALUE_CHECK_MODES);
|
|
29
32
|
const compareWithDescriptorStringValueCheckModeSchema = _zod.z.enum(_constants.COMPARE_WITH_DESCRIPTOR_STRING_VALUE_CHECK_MODES);
|
|
30
33
|
const compareWithDescriptorValueCheckModeSchema = _zod.z.enum(_constants.COMPARE_WITH_DESCRIPTOR_VALUE_CHECK_MODES);
|
|
34
|
+
const entityDescriptorSchema = (checkModeSchema, valueSchema)=>{
|
|
35
|
+
const isCheckActualValueCheckMode = !valueSchema;
|
|
36
|
+
if (isCheckActualValueCheckMode) {
|
|
37
|
+
return _zod.z.strictObject({
|
|
38
|
+
checkMode: checkModeSchema
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
return _zod.z.discriminatedUnion('oneOf', [
|
|
42
|
+
_zod.z.strictObject({
|
|
43
|
+
checkMode: checkModeSchema,
|
|
44
|
+
value: valueSchema,
|
|
45
|
+
oneOf: _zod.z.literal(false).optional()
|
|
46
|
+
}),
|
|
47
|
+
_zod.z.strictObject({
|
|
48
|
+
checkMode: checkModeSchema,
|
|
49
|
+
value: _zod.z.array(valueSchema),
|
|
50
|
+
oneOf: _zod.z.literal(true)
|
|
51
|
+
})
|
|
52
|
+
]);
|
|
53
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const bodyPlainEntitySchema: z.ZodUnion<[z.ZodEffects<z.ZodType<unknown, z.ZodTypeDef, unknown>, unknown, unknown>, z.ZodPipeline<z.ZodEffects<z.ZodType<unknown, z.ZodTypeDef, unknown>, unknown, unknown>, z.ZodTypeAny>, z.ZodArray<z.ZodUnion<[z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>, z.ZodType<import("../../../types").NestedObjectOrArray<string | number | boolean | null>, z.ZodTypeDef, import("../../../types").NestedObjectOrArray<string | number | boolean | null>>]>, "many">]>;
|
|
3
|
+
export declare const variablesPlainEntitySchema: z.ZodUnion<[z.ZodEffects<z.ZodType<unknown, z.ZodTypeDef, unknown>, unknown, unknown>, z.ZodPipeline<z.ZodEffects<z.ZodType<unknown, z.ZodTypeDef, unknown>, unknown, unknown>, z.ZodTypeAny>]>;
|
|
4
|
+
export declare const mappedEntitySchema: z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
bodyPlainEntitySchema: function() {
|
|
13
|
+
return bodyPlainEntitySchema;
|
|
14
|
+
},
|
|
15
|
+
mappedEntitySchema: function() {
|
|
16
|
+
return mappedEntitySchema;
|
|
17
|
+
},
|
|
18
|
+
variablesPlainEntitySchema: function() {
|
|
19
|
+
return variablesPlainEntitySchema;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
const _zod = require("zod");
|
|
23
|
+
const _helpers = require("../../../helpers");
|
|
24
|
+
const _checkModeSchema = require("../checkModeSchema/checkModeSchema");
|
|
25
|
+
const _extendedDiscriminatedUnion = require("../extendedDiscriminatedUnion/extendedDiscriminatedUnion");
|
|
26
|
+
const _nestedObjectOrArraySchema = require("../nestedObjectOrArraySchema/nestedObjectOrArraySchema");
|
|
27
|
+
const _plainObjectSchema = require("../plainObjectSchema/plainObjectSchema");
|
|
28
|
+
/* ----- Plain entity schema ----- */ const plainEntityPrimitiveValueSchema = _zod.z.union([
|
|
29
|
+
_zod.z.string(),
|
|
30
|
+
_zod.z.number(),
|
|
31
|
+
_zod.z.boolean(),
|
|
32
|
+
_zod.z.null()
|
|
33
|
+
]);
|
|
34
|
+
const plainEntityObjectiveValueSchema = (0, _nestedObjectOrArraySchema.nestedObjectOrArraySchema)(plainEntityPrimitiveValueSchema);
|
|
35
|
+
const topLevelPlainEntityDescriptorSchema = (0, _extendedDiscriminatedUnion.extendedDiscriminatedUnion)('checkMode', [
|
|
36
|
+
(0, _checkModeSchema.entityDescriptorSchema)(_checkModeSchema.checkActualValueCheckModeSchema),
|
|
37
|
+
(0, _checkModeSchema.entityDescriptorSchema)(_zod.z.literal('function'), _zod.z.function()),
|
|
38
|
+
(0, _checkModeSchema.entityDescriptorSchema)(_checkModeSchema.compareWithDescriptorAnyValueCheckModeSchema, plainEntityObjectiveValueSchema)
|
|
39
|
+
]);
|
|
40
|
+
const propertyLevelPlainEntityDescriptorSchema = (0, _extendedDiscriminatedUnion.extendedDiscriminatedUnion)('checkMode', [
|
|
41
|
+
(0, _checkModeSchema.entityDescriptorSchema)(_checkModeSchema.checkActualValueCheckModeSchema),
|
|
42
|
+
(0, _checkModeSchema.entityDescriptorSchema)(_zod.z.literal('function'), _zod.z.function()),
|
|
43
|
+
(0, _checkModeSchema.entityDescriptorSchema)(_zod.z.literal('regExp'), _zod.z.instanceof(RegExp)),
|
|
44
|
+
(0, _checkModeSchema.entityDescriptorSchema)(_checkModeSchema.compareWithDescriptorAnyValueCheckModeSchema, _zod.z.union([
|
|
45
|
+
plainEntityPrimitiveValueSchema,
|
|
46
|
+
plainEntityObjectiveValueSchema
|
|
47
|
+
])),
|
|
48
|
+
(0, _checkModeSchema.entityDescriptorSchema)(_checkModeSchema.compareWithDescriptorStringValueCheckModeSchema, plainEntityPrimitiveValueSchema)
|
|
49
|
+
]);
|
|
50
|
+
const nonCheckModeSchema = (schema)=>_zod.z.custom((value)=>typeof value === 'object').superRefine((value, context)=>{
|
|
51
|
+
if ((0, _helpers.isPlainObject)(value) && 'checkMode' in value) {
|
|
52
|
+
context.addIssue({
|
|
53
|
+
code: _zod.z.ZodIssueCode.custom,
|
|
54
|
+
path: [
|
|
55
|
+
'checkMode'
|
|
56
|
+
],
|
|
57
|
+
fatal: true
|
|
58
|
+
});
|
|
59
|
+
return _zod.z.NEVER;
|
|
60
|
+
}
|
|
61
|
+
}).pipe(schema);
|
|
62
|
+
const topLevelPlainEntityRecordSchema = nonCheckModeSchema(_zod.z.record(_zod.z.union([
|
|
63
|
+
propertyLevelPlainEntityDescriptorSchema,
|
|
64
|
+
nonCheckModeSchema(plainEntityObjectiveValueSchema),
|
|
65
|
+
plainEntityPrimitiveValueSchema
|
|
66
|
+
])));
|
|
67
|
+
const topLevelPlainEntityArraySchema = _zod.z.array(_zod.z.union([
|
|
68
|
+
plainEntityPrimitiveValueSchema,
|
|
69
|
+
plainEntityObjectiveValueSchema
|
|
70
|
+
]));
|
|
71
|
+
const bodyPlainEntitySchema = _zod.z.union([
|
|
72
|
+
topLevelPlainEntityDescriptorSchema,
|
|
73
|
+
topLevelPlainEntityRecordSchema,
|
|
74
|
+
topLevelPlainEntityArraySchema
|
|
75
|
+
]);
|
|
76
|
+
const variablesPlainEntitySchema = _zod.z.union([
|
|
77
|
+
topLevelPlainEntityDescriptorSchema,
|
|
78
|
+
topLevelPlainEntityRecordSchema
|
|
79
|
+
]);
|
|
80
|
+
/* ----- Mapped entity schema ----- */ const mappedEntityValueSchema = _zod.z.union([
|
|
81
|
+
_zod.z.string(),
|
|
82
|
+
_zod.z.number(),
|
|
83
|
+
_zod.z.boolean()
|
|
84
|
+
]);
|
|
85
|
+
const mappedEntityDescriptorSchema = (0, _extendedDiscriminatedUnion.extendedDiscriminatedUnion)('checkMode', [
|
|
86
|
+
(0, _checkModeSchema.entityDescriptorSchema)(_checkModeSchema.checkActualValueCheckModeSchema),
|
|
87
|
+
(0, _checkModeSchema.entityDescriptorSchema)(_zod.z.literal('function'), _zod.z.function()),
|
|
88
|
+
(0, _checkModeSchema.entityDescriptorSchema)(_zod.z.literal('regExp'), _zod.z.instanceof(RegExp)),
|
|
89
|
+
(0, _checkModeSchema.entityDescriptorSchema)(_checkModeSchema.compareWithDescriptorValueCheckModeSchema, mappedEntityValueSchema)
|
|
90
|
+
]);
|
|
91
|
+
const mappedEntitySchema = (0, _plainObjectSchema.plainObjectSchema)(_zod.z.record(_zod.z.union([
|
|
92
|
+
mappedEntityValueSchema,
|
|
93
|
+
mappedEntityDescriptorSchema
|
|
94
|
+
])));
|
package/dist/src/utils/validate/utils/extendedDiscriminatedUnion/extendedDiscriminatedUnion.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
type ExtendedDiscriminatedUnionVariant<Discriminator extends string, Option extends z.ZodObject<{
|
|
3
|
+
[Key in Discriminator]: z.ZodTypeAny;
|
|
4
|
+
}> = z.ZodObject<{
|
|
5
|
+
[Key in Discriminator]: z.ZodTypeAny;
|
|
6
|
+
}>> = Option | z.ZodDiscriminatedUnion<string, [Option, ...Option[]]>;
|
|
7
|
+
export declare const extendedDiscriminatedUnion: <Discriminator extends string>(discriminator: Discriminator, variants: [ExtendedDiscriminatedUnionVariant<Discriminator>, ...ExtendedDiscriminatedUnionVariant<Discriminator>[]]) => z.ZodEffects<z.ZodType<unknown, z.ZodTypeDef, unknown>, unknown, unknown>;
|
|
8
|
+
export {};
|
package/dist/src/utils/validate/utils/extendedDiscriminatedUnion/extendedDiscriminatedUnion.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "extendedDiscriminatedUnion", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return extendedDiscriminatedUnion;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _zod = require("zod");
|
|
12
|
+
const _helpers = require("../../../helpers");
|
|
13
|
+
const _getMostSpecificPathFromError = require("../../getMostSpecificPathFromError");
|
|
14
|
+
const extendedDiscriminatedUnion = (discriminator, variants)=>_zod.z.custom((value)=>(0, _helpers.isPlainObject)(value) && discriminator in value).superRefine((value, context)=>{
|
|
15
|
+
const variantWithMatchedDiscriminator = variants.find((variant)=>{
|
|
16
|
+
const isVariantOption = variant instanceof _zod.z.ZodDiscriminatedUnion;
|
|
17
|
+
if (isVariantOption) {
|
|
18
|
+
return variant.options.some((option)=>option.strip().pick({
|
|
19
|
+
[discriminator]: true
|
|
20
|
+
}).safeParse(value).success);
|
|
21
|
+
}
|
|
22
|
+
return variant.strip().pick({
|
|
23
|
+
[discriminator]: true
|
|
24
|
+
}).safeParse(value).success;
|
|
25
|
+
});
|
|
26
|
+
if (!variantWithMatchedDiscriminator) {
|
|
27
|
+
context.addIssue({
|
|
28
|
+
code: _zod.z.ZodIssueCode.custom,
|
|
29
|
+
path: [
|
|
30
|
+
discriminator
|
|
31
|
+
],
|
|
32
|
+
fatal: true
|
|
33
|
+
});
|
|
34
|
+
return _zod.z.NEVER;
|
|
35
|
+
}
|
|
36
|
+
const valueParseResult = variantWithMatchedDiscriminator.safeParse(value);
|
|
37
|
+
if (!valueParseResult.success) {
|
|
38
|
+
const issuePath = (0, _getMostSpecificPathFromError.getMostSpecificPathFromError)(valueParseResult.error);
|
|
39
|
+
context.addIssue({
|
|
40
|
+
code: _zod.z.ZodIssueCode.custom,
|
|
41
|
+
path: issuePath,
|
|
42
|
+
fatal: true
|
|
43
|
+
});
|
|
44
|
+
return _zod.z.NEVER;
|
|
45
|
+
}
|
|
46
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export * from './checkModeSchema/checkModeSchema';
|
|
2
2
|
export * from './entitiesSchema/entitiesSchema';
|
|
3
|
-
export * from './
|
|
3
|
+
export * from './extendedDiscriminatedUnion/extendedDiscriminatedUnion';
|
|
4
|
+
export * from './nestedObjectOrArraySchema/nestedObjectOrArraySchema';
|
|
4
5
|
export * from './plainObjectSchema/plainObjectSchema';
|
|
5
|
-
export * from './requiredPropertiesSchema/requiredPropertiesSchema';
|
|
6
6
|
export * from './sharedSchema/sharedSchema';
|
|
@@ -4,9 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
_export_star(require("./checkModeSchema/checkModeSchema"), exports);
|
|
6
6
|
_export_star(require("./entitiesSchema/entitiesSchema"), exports);
|
|
7
|
-
_export_star(require("./
|
|
7
|
+
_export_star(require("./extendedDiscriminatedUnion/extendedDiscriminatedUnion"), exports);
|
|
8
|
+
_export_star(require("./nestedObjectOrArraySchema/nestedObjectOrArraySchema"), exports);
|
|
8
9
|
_export_star(require("./plainObjectSchema/plainObjectSchema"), exports);
|
|
9
|
-
_export_star(require("./requiredPropertiesSchema/requiredPropertiesSchema"), exports);
|
|
10
10
|
_export_star(require("./sharedSchema/sharedSchema"), exports);
|
|
11
11
|
function _export_star(from, to) {
|
|
12
12
|
Object.keys(from).forEach(function(k) {
|
package/dist/{bin/validateMockServerConfig → src/utils/validate}/utils/jsonSchema/jsonSchema.d.ts
RENAMED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
export declare const jsonLiteralSchema: z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>;
|
|
3
3
|
type JsonLiteral = z.infer<typeof jsonLiteralSchema>;
|
|
4
|
-
type Json = JsonLiteral | {
|
|
4
|
+
type Json = Json[] | JsonLiteral | {
|
|
5
5
|
[key: string]: Json;
|
|
6
|
-
}
|
|
6
|
+
};
|
|
7
7
|
export declare const jsonSchema: z.ZodType<Json>;
|
|
8
8
|
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "nestedObjectOrArraySchema", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return nestedObjectOrArraySchema;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _zod = require("zod");
|
|
12
|
+
const _helpers = require("../../../helpers");
|
|
13
|
+
const nestedObjectOrArraySchema = (valueSchema)=>{
|
|
14
|
+
const nestedValueSchema = _zod.z.union([
|
|
15
|
+
valueSchema,
|
|
16
|
+
_zod.z.lazy(()=>nestedObjectOrArraySchema(valueSchema))
|
|
17
|
+
]);
|
|
18
|
+
return _zod.z.union([
|
|
19
|
+
_zod.z.array(nestedValueSchema),
|
|
20
|
+
_zod.z.record(nestedValueSchema).and(_zod.z.custom((value)=>(0, _helpers.isPlainObject)(value)))
|
|
21
|
+
]);
|
|
22
|
+
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import type { PlainObject } from '
|
|
2
|
+
import type { PlainObject } from '../../../types';
|
|
3
3
|
export declare const requiredPropertiesSchema: <T extends PlainObject>(schema: z.ZodType<T>, requiredProperties: (keyof T)[]) => z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodType<T, z.ZodTypeDef, T>>;
|
|
@@ -9,5 +9,5 @@ Object.defineProperty(exports, "requiredPropertiesSchema", {
|
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
11
|
const _zod = require("zod");
|
|
12
|
-
const _helpers = require("
|
|
12
|
+
const _helpers = require("../../../helpers");
|
|
13
13
|
const requiredPropertiesSchema = (schema, requiredProperties)=>_zod.z.custom((value)=>(0, _helpers.isPlainObject)(value) && requiredProperties.every((property)=>Object.prototype.hasOwnProperty.call(value, property))).pipe(schema);
|
package/dist/{bin/validateMockServerConfig → src/utils/validate}/validateApiMockServerConfig.js
RENAMED
|
@@ -9,10 +9,11 @@ Object.defineProperty(exports, "validateApiMockServerConfig", {
|
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
11
|
const _zod = require("zod");
|
|
12
|
-
const _helpers = require("../helpers");
|
|
13
12
|
const _baseUrlSchema = require("./baseUrlSchema/baseUrlSchema");
|
|
14
13
|
const _corsSchema = require("./corsSchema/corsSchema");
|
|
15
14
|
const _databaseConfigSchema = require("./databaseConfigSchema/databaseConfigSchema");
|
|
15
|
+
const _getMostSpecificPathFromError = require("./getMostSpecificPathFromError");
|
|
16
|
+
const _getValidationMessageFromPath = require("./getValidationMessageFromPath");
|
|
16
17
|
const _graphqlConfigSchema = require("./graphqlConfigSchema/graphqlConfigSchema");
|
|
17
18
|
const _interceptorsSchema = require("./interceptorsSchema/interceptorsSchema");
|
|
18
19
|
const _portSchema = require("./portSchema/portSchema");
|
|
@@ -40,8 +41,8 @@ const validateApiMockServerConfig = (mockServerConfig, api)=>{
|
|
|
40
41
|
});
|
|
41
42
|
const validationResult = mockServerConfigSchema.safeParse(mockServerConfig);
|
|
42
43
|
if (!validationResult.success) {
|
|
43
|
-
const path = (0,
|
|
44
|
-
const validationMessage = (0,
|
|
44
|
+
const path = (0, _getMostSpecificPathFromError.getMostSpecificPathFromError)(validationResult.error);
|
|
45
|
+
const validationMessage = (0, _getValidationMessageFromPath.getValidationMessageFromPath)(path);
|
|
45
46
|
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`);
|
|
46
47
|
}
|
|
47
48
|
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "validateFlatMockServerConfig", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return validateFlatMockServerConfig;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _zod = require("zod");
|
|
12
|
+
const _baseUrlSchema = require("./baseUrlSchema/baseUrlSchema");
|
|
13
|
+
const _corsSchema = require("./corsSchema/corsSchema");
|
|
14
|
+
const _databaseConfigSchema = require("./databaseConfigSchema/databaseConfigSchema");
|
|
15
|
+
const _getMostSpecificPathFromError = require("./getMostSpecificPathFromError");
|
|
16
|
+
const _getValidationMessageFromPath = require("./getValidationMessageFromPath");
|
|
17
|
+
const _graphqlConfigSchema = require("./graphqlConfigSchema/graphqlConfigSchema");
|
|
18
|
+
const _interceptorsSchema = require("./interceptorsSchema/interceptorsSchema");
|
|
19
|
+
const _portSchema = require("./portSchema/portSchema");
|
|
20
|
+
const _restConfigSchema = require("./restConfigSchema/restConfigSchema");
|
|
21
|
+
const _staticPathSchema = require("./staticPathSchema/staticPathSchema");
|
|
22
|
+
const _utils = require("./utils");
|
|
23
|
+
const validateFlatMockServerConfig = (flatMockServerConfig)=>{
|
|
24
|
+
if (!flatMockServerConfig.length) {
|
|
25
|
+
throw new Error('Flat config should contain at least one element; see our doc (https://github.com/siberiacancode/mock-config-server) for more information');
|
|
26
|
+
}
|
|
27
|
+
const flatMockServerSettingsSchema = _zod.z.strictObject({
|
|
28
|
+
baseUrl: _baseUrlSchema.baseUrlSchema.optional(),
|
|
29
|
+
port: _portSchema.portSchema.optional(),
|
|
30
|
+
staticPath: _staticPathSchema.staticPathSchema.optional(),
|
|
31
|
+
interceptors: (0, _utils.plainObjectSchema)(_interceptorsSchema.interceptorsSchema).optional(),
|
|
32
|
+
cors: _corsSchema.corsSchema.optional(),
|
|
33
|
+
database: _databaseConfigSchema.databaseConfigSchema.optional()
|
|
34
|
+
});
|
|
35
|
+
const flatMockServerComponentSchema = _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 flatMockServerConfigSchema = _zod.z.tuple([
|
|
45
|
+
(0, _utils.plainObjectSchema)(flatMockServerSettingsSchema).or(flatMockServerComponentSchema)
|
|
46
|
+
]).rest(flatMockServerComponentSchema);
|
|
47
|
+
const validationFlatMockServerConfigSchemaResult = flatMockServerConfigSchema.safeParse(flatMockServerConfig);
|
|
48
|
+
if (!validationFlatMockServerConfigSchemaResult.success) {
|
|
49
|
+
const path = (0, _getMostSpecificPathFromError.getMostSpecificPathFromError)(validationFlatMockServerConfigSchemaResult.error);
|
|
50
|
+
const validationMessage = (0, _getValidationMessageFromPath.getValidationMessageFromPath)(path);
|
|
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`);
|
|
52
|
+
}
|
|
53
|
+
};
|
package/dist/{bin/validateMockServerConfig → src/utils/validate}/validateMockServerConfig.d.ts
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { PlainObject } from '
|
|
1
|
+
import type { PlainObject } from '../types';
|
|
2
2
|
export declare const validateMockServerConfig: (mockServerConfig: PlainObject) => void;
|
package/dist/{bin/validateMockServerConfig → src/utils/validate}/validateMockServerConfig.js
RENAMED
|
@@ -9,10 +9,11 @@ Object.defineProperty(exports, "validateMockServerConfig", {
|
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
11
|
const _zod = require("zod");
|
|
12
|
-
const _helpers = require("../helpers");
|
|
13
12
|
const _baseUrlSchema = require("./baseUrlSchema/baseUrlSchema");
|
|
14
13
|
const _corsSchema = require("./corsSchema/corsSchema");
|
|
15
14
|
const _databaseConfigSchema = require("./databaseConfigSchema/databaseConfigSchema");
|
|
15
|
+
const _getMostSpecificPathFromError = require("./getMostSpecificPathFromError");
|
|
16
|
+
const _getValidationMessageFromPath = require("./getValidationMessageFromPath");
|
|
16
17
|
const _graphqlConfigSchema = require("./graphqlConfigSchema/graphqlConfigSchema");
|
|
17
18
|
const _interceptorsSchema = require("./interceptorsSchema/interceptorsSchema");
|
|
18
19
|
const _portSchema = require("./portSchema/portSchema");
|
|
@@ -35,8 +36,8 @@ const validateMockServerConfig = (mockServerConfig)=>{
|
|
|
35
36
|
});
|
|
36
37
|
const validationResult = mockServerConfigSchema.safeParse(mockServerConfig);
|
|
37
38
|
if (!validationResult.success) {
|
|
38
|
-
const path = (0,
|
|
39
|
-
const validationMessage = (0,
|
|
39
|
+
const path = (0, _getMostSpecificPathFromError.getMostSpecificPathFromError)(validationResult.error);
|
|
40
|
+
const validationMessage = (0, _getValidationMessageFromPath.getValidationMessageFromPath)(path);
|
|
40
41
|
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`);
|
|
41
42
|
}
|
|
42
43
|
};
|