mock-config-server 3.4.1 → 3.6.0
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 +2 -0
- package/dist/bin/bin.js +3 -6
- package/dist/bin/build.js +52 -50
- package/dist/bin/cli.js +50 -43
- package/dist/bin/helpers/createTemplate.js +29 -21
- package/dist/bin/helpers/getMostSpecificPathFromError.js +34 -30
- package/dist/bin/helpers/getValidationMessageFromPath.js +11 -8
- package/dist/bin/helpers/index.js +21 -79
- package/dist/bin/helpers/isOnlyRequestedDataResolvingPropertyExists.js +13 -6
- package/dist/bin/helpers/resolveConfigFile.js +22 -19
- package/dist/bin/helpers/resolveConfigFilePath.js +19 -12
- package/dist/bin/helpers/resolveExportsFromSourceCode.js +13 -10
- package/dist/bin/init.js +114 -97
- package/dist/bin/run.js +42 -43
- package/dist/bin/validateMockServerConfig/baseUrlSchema/baseUrlSchema.js +9 -5
- package/dist/bin/validateMockServerConfig/corsSchema/corsSchema.d.ts +2 -2
- package/dist/bin/validateMockServerConfig/corsSchema/corsSchema.js +32 -14
- package/dist/bin/validateMockServerConfig/databaseConfigSchema/databaseConfigSchema.js +19 -9
- package/dist/bin/validateMockServerConfig/graphqlConfigSchema/graphqlConfigSchema.d.ts +82 -72
- package/dist/bin/validateMockServerConfig/graphqlConfigSchema/graphqlConfigSchema.js +38 -22
- package/dist/bin/validateMockServerConfig/graphqlConfigSchema/routeConfigSchema/routeConfigSchema.d.ts +25 -21
- package/dist/bin/validateMockServerConfig/graphqlConfigSchema/routeConfigSchema/routeConfigSchema.js +36 -28
- package/dist/bin/validateMockServerConfig/interceptorsSchema/interceptorsSchema.js +12 -8
- package/dist/bin/validateMockServerConfig/portSchema/portSchema.js +9 -5
- package/dist/bin/validateMockServerConfig/queueSchema/queueSchema.d.ts +2 -2
- package/dist/bin/validateMockServerConfig/queueSchema/queueSchema.js +18 -9
- package/dist/bin/validateMockServerConfig/restConfigSchema/restConfigSchema.d.ts +270 -240
- package/dist/bin/validateMockServerConfig/restConfigSchema/restConfigSchema.js +33 -19
- package/dist/bin/validateMockServerConfig/restConfigSchema/routeConfigSchema/routeConfigSchema.d.ts +33 -28
- package/dist/bin/validateMockServerConfig/restConfigSchema/routeConfigSchema/routeConfigSchema.js +60 -48
- package/dist/bin/validateMockServerConfig/settingsSchema/settingsSchema.js +13 -9
- package/dist/bin/validateMockServerConfig/staticPathSchema/staticPathSchema.js +19 -9
- package/dist/bin/validateMockServerConfig/utils/checkModeSchema/checkModeSchema.js +27 -9
- package/dist/bin/validateMockServerConfig/utils/entitiesSchema/entitiesSchema.d.ts +4 -8
- package/dist/bin/validateMockServerConfig/utils/entitiesSchema/entitiesSchema.js +117 -60
- package/dist/bin/validateMockServerConfig/utils/index.js +20 -68
- package/dist/bin/validateMockServerConfig/utils/jsonSchema/jsonSchema.js +30 -10
- package/dist/bin/validateMockServerConfig/utils/plainObjectSchema/plainObjectSchema.js +9 -8
- package/dist/bin/validateMockServerConfig/utils/requiredPropertiesSchema/requiredPropertiesSchema.d.ts +1 -1
- package/dist/bin/validateMockServerConfig/utils/requiredPropertiesSchema/requiredPropertiesSchema.js +10 -7
- package/dist/bin/validateMockServerConfig/utils/sharedSchema/sharedSchema.js +18 -6
- package/dist/bin/validateMockServerConfig/validateApiMockServerConfig.js +43 -40
- package/dist/bin/validateMockServerConfig/validateMockServerConfig.js +38 -35
- package/dist/index.js +15 -13
- package/dist/src/core/database/createDatabaseRoutes/createDatabaseRoutes.js +25 -28
- package/dist/src/core/database/createDatabaseRoutes/helpers/array/createNewId/createNewId.js +14 -11
- package/dist/src/core/database/createDatabaseRoutes/helpers/array/findIndexById/findIndexById.js +8 -5
- package/dist/src/core/database/createDatabaseRoutes/helpers/array/index.js +17 -35
- package/dist/src/core/database/createDatabaseRoutes/helpers/array/isIndex/isIndex.js +8 -5
- package/dist/src/core/database/createDatabaseRoutes/helpers/createNestedDatabaseRoutes/createNestedDatabaseRoutes.js +159 -143
- package/dist/src/core/database/createDatabaseRoutes/helpers/createRewrittenDatabaseRoutes/createRewrittenDatabaseRoutes.js +15 -8
- package/dist/src/core/database/createDatabaseRoutes/helpers/createShallowDatabaseRoutes/createShallowDatabaseRoutes.js +90 -94
- package/dist/src/core/database/createDatabaseRoutes/helpers/filter/filter.js +49 -46
- package/dist/src/core/database/createDatabaseRoutes/helpers/index.js +19 -57
- package/dist/src/core/database/createDatabaseRoutes/helpers/pagination/pagination.js +32 -31
- package/dist/src/core/database/createDatabaseRoutes/helpers/search/search.js +34 -24
- package/dist/src/core/database/createDatabaseRoutes/helpers/sort/sort.js +37 -33
- package/dist/src/core/database/createDatabaseRoutes/helpers/splitDatabaseByNesting/splitDatabaseByNesting.js +26 -25
- package/dist/src/core/database/createDatabaseRoutes/storages/File/FileStorage.js +65 -50
- package/dist/src/core/database/createDatabaseRoutes/storages/File/FileWriter.js +55 -48
- package/dist/src/core/database/createDatabaseRoutes/storages/Memory/MemoryStorage.js +51 -41
- package/dist/src/core/database/createDatabaseRoutes/storages/index.js +16 -24
- package/dist/src/core/database/index.js +15 -13
- package/dist/src/core/graphql/createGraphQLRoutes/createGraphQLRoutes.js +131 -140
- package/dist/src/core/graphql/createGraphQLRoutes/helpers/index.js +15 -13
- package/dist/src/core/graphql/createGraphQLRoutes/helpers/prepareGraphQLRequestConfigs/prepareGraphQLRequestConfigs.js +36 -41
- package/dist/src/core/graphql/index.js +15 -13
- package/dist/src/core/middlewares/cookieParseMiddleware/cookieParseMiddleware.js +16 -13
- package/dist/src/core/middlewares/cookieParseMiddleware/helpers/index.js +15 -13
- package/dist/src/core/middlewares/cookieParseMiddleware/helpers/parseCookie/parseCookie.js +18 -15
- package/dist/src/core/middlewares/corsMiddleware/corsMiddleware.js +50 -47
- package/dist/src/core/middlewares/corsMiddleware/helpers/getAllowedOrigins/getAllowedOrigins.js +17 -12
- package/dist/src/core/middlewares/corsMiddleware/helpers/index.js +15 -13
- package/dist/src/core/middlewares/destroyerMiddleware/destroyerMiddleware.js +23 -20
- package/dist/src/core/middlewares/errorMiddleware/errorMiddleware.js +23 -17
- package/dist/src/core/middlewares/index.js +23 -91
- package/dist/src/core/middlewares/noCorsMiddleware/noCorsMiddleware.js +22 -19
- package/dist/src/core/middlewares/notFoundMiddleware/helpers/getGraphqlUrlSuggestions/getGraphqlUrlSuggestions.js +21 -23
- package/dist/src/core/middlewares/notFoundMiddleware/helpers/getLevenshteinDistance/getLevenshteinDistance.js +80 -80
- package/dist/src/core/middlewares/notFoundMiddleware/helpers/getRestUrlSuggestions/getRestUrlSuggestions.js +34 -34
- package/dist/src/core/middlewares/notFoundMiddleware/helpers/getRestUrlSuggestions/helpers/getActualRestUrlMeaningfulString/getActualRestUrlMeaningfulString.js +8 -5
- package/dist/src/core/middlewares/notFoundMiddleware/helpers/getRestUrlSuggestions/helpers/getPatternRestUrlMeaningfulString/getPatternRestUrlMeaningfulString.js +8 -5
- package/dist/src/core/middlewares/notFoundMiddleware/helpers/getRestUrlSuggestions/helpers/index.js +16 -24
- package/dist/src/core/middlewares/notFoundMiddleware/helpers/index.js +17 -35
- package/dist/src/core/middlewares/notFoundMiddleware/notFoundMiddleware.js +58 -60
- package/dist/src/core/middlewares/requestInterceptorMiddleware/requestInterceptorMiddleware.js +16 -17
- package/dist/src/core/middlewares/staticMiddleware/staticMiddleware.js +32 -25
- package/dist/src/core/rest/createRestRoutes/createRestRoutes.js +125 -130
- package/dist/src/core/rest/createRestRoutes/helpers/index.js +15 -13
- package/dist/src/core/rest/createRestRoutes/helpers/prepareRestRequestConfigs/prepareRestRequestConfigs.js +37 -43
- package/dist/src/core/rest/index.js +15 -13
- package/dist/src/index.js +16 -24
- package/dist/src/server/createDatabaseMockServer/createDatabaseMockServer.js +56 -53
- package/dist/src/server/createGraphQLMockServer/createGraphQLMockServer.js +64 -62
- package/dist/src/server/createMockServer/createMockServer.js +94 -91
- package/dist/src/server/createRestMockServer/createRestMockServer.js +64 -62
- package/dist/src/server/index.js +23 -91
- package/dist/src/server/startDatabaseMockServer/startDatabaseMockServer.js +25 -19
- package/dist/src/server/startGraphQLMockServer/startGraphQLMockServer.js +25 -19
- package/dist/src/server/startMockServer/startMockServer.js +25 -19
- package/dist/src/server/startRestMockServer/startRestMockServer.js +25 -19
- package/dist/src/utils/constants/appPath.js +8 -4
- package/dist/src/utils/constants/checkModes.js +74 -11
- package/dist/src/utils/constants/default.js +18 -14
- package/dist/src/utils/constants/index.js +17 -35
- package/dist/src/utils/helpers/asyncHandler.js +8 -5
- package/dist/src/utils/helpers/config/index.js +15 -13
- package/dist/src/utils/helpers/config/resolveEntityValues/resolveEntityValues.js +103 -110
- package/dist/src/utils/helpers/entities/convertToEntityDescriptor/convertToEntityDescriptor.js +12 -9
- package/dist/src/utils/helpers/entities/index.js +16 -24
- package/dist/src/utils/helpers/entities/isEntityDescriptor/isEntityDescriptor.js +9 -6
- package/dist/src/utils/helpers/files/index.js +15 -13
- package/dist/src/utils/helpers/files/isFilePathValid/isFilePathValid.js +22 -15
- package/dist/src/utils/helpers/graphql/getGraphQLInput/getGraphQLInput.js +25 -29
- package/dist/src/utils/helpers/graphql/index.js +17 -35
- package/dist/src/utils/helpers/graphql/parseGraphQLRequest/parseGraphQLRequest.js +13 -10
- package/dist/src/utils/helpers/graphql/parseQuery/parseQuery.js +23 -19
- package/dist/src/utils/helpers/index.js +26 -124
- package/dist/src/utils/helpers/interceptors/callRequestInterceptor/callRequestInterceptor.js +21 -21
- package/dist/src/utils/helpers/interceptors/callResponseInterceptors/callResponseInterceptors.js +62 -64
- package/dist/src/utils/helpers/interceptors/helpers/setDelay.js +10 -7
- package/dist/src/utils/helpers/interceptors/index.js +16 -24
- package/dist/src/utils/helpers/isPlainObject/isPlainObject.js +8 -5
- package/dist/src/utils/helpers/isPrimitive/isPrimitive.js +8 -5
- package/dist/src/utils/helpers/isRegExp/isRegExp.js +8 -5
- package/dist/src/utils/helpers/sleep.js +9 -6
- package/dist/src/utils/helpers/tests/createTmpDir.js +16 -9
- package/dist/src/utils/helpers/tests/index.js +15 -13
- package/dist/src/utils/helpers/url/convertWin32PathToUnix/convertWin32PathToUnix.js +8 -5
- package/dist/src/utils/helpers/url/getUrlParts/getUrlParts.js +9 -6
- package/dist/src/utils/helpers/url/index.js +18 -46
- package/dist/src/utils/helpers/url/removeLeadingAndTrailingSlashes/removeLeadingAndTrailingSlashes.js +8 -5
- package/dist/src/utils/helpers/url/urlJoin/urlJoin.js +18 -11
- package/dist/src/utils/types/checkModes.js +4 -1
- package/dist/src/utils/types/database.js +4 -1
- package/dist/src/utils/types/entities.js +4 -1
- package/dist/src/utils/types/graphql.d.ts +1 -1
- package/dist/src/utils/types/graphql.js +4 -1
- package/dist/src/utils/types/index.js +24 -102
- package/dist/src/utils/types/interceptors.js +4 -1
- package/dist/src/utils/types/rest.d.ts +1 -1
- package/dist/src/utils/types/rest.js +4 -1
- package/dist/src/utils/types/server.js +4 -1
- package/dist/src/utils/types/utils.js +4 -1
- package/dist/src/utils/types/values.js +4 -1
- package/package.json +26 -29
- package/dist/bin/templates/.eslintrc.js +0 -14
- package/dist/bin/templates/tsconfig.json +0 -11
|
@@ -1,23 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
|
|
3
|
+
value: true
|
|
5
4
|
});
|
|
6
|
-
exports
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
5
|
+
Object.defineProperty(exports, "restConfigSchema", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return restConfigSchema;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _zod = require("zod");
|
|
12
|
+
const _baseUrlSchema = require("../baseUrlSchema/baseUrlSchema");
|
|
13
|
+
const _interceptorsSchema = require("../interceptorsSchema/interceptorsSchema");
|
|
14
|
+
const _utils = require("../utils");
|
|
15
|
+
const _routeConfigSchema = require("./routeConfigSchema/routeConfigSchema");
|
|
16
|
+
const baseRequestConfigSchema = (method)=>_zod.z.strictObject({
|
|
17
|
+
path: _zod.z.union([
|
|
18
|
+
_utils.stringForwardSlashSchema,
|
|
19
|
+
_zod.z.instanceof(RegExp)
|
|
20
|
+
]),
|
|
21
|
+
method: _zod.z.literal(method),
|
|
22
|
+
routes: _zod.z.array((0, _routeConfigSchema.routeConfigSchema)(method)),
|
|
23
|
+
interceptors: (0, _utils.plainObjectSchema)(_interceptorsSchema.interceptorsSchema).optional()
|
|
24
|
+
});
|
|
25
|
+
const requestConfigSchema = _zod.z.union([
|
|
26
|
+
baseRequestConfigSchema('get'),
|
|
27
|
+
baseRequestConfigSchema('post'),
|
|
28
|
+
baseRequestConfigSchema('put'),
|
|
29
|
+
baseRequestConfigSchema('delete'),
|
|
30
|
+
baseRequestConfigSchema('patch'),
|
|
31
|
+
baseRequestConfigSchema('options')
|
|
32
|
+
]);
|
|
33
|
+
const restConfigSchema = _zod.z.strictObject({
|
|
34
|
+
baseUrl: _baseUrlSchema.baseUrlSchema.optional(),
|
|
35
|
+
configs: _zod.z.array(requestConfigSchema),
|
|
36
|
+
interceptors: (0, _utils.plainObjectSchema)(_interceptorsSchema.interceptorsSchema).optional()
|
|
17
37
|
});
|
|
18
|
-
const requestConfigSchema = _zod.z.union([baseRequestConfigSchema('get'), baseRequestConfigSchema('post'), baseRequestConfigSchema('put'), baseRequestConfigSchema('delete'), baseRequestConfigSchema('patch'), baseRequestConfigSchema('options')]);
|
|
19
|
-
const restConfigSchema = exports.restConfigSchema = _zod.z.strictObject({
|
|
20
|
-
baseUrl: _baseUrlSchema.baseUrlSchema.optional(),
|
|
21
|
-
configs: _zod.z.array(requestConfigSchema),
|
|
22
|
-
interceptors: (0, _utils.plainObjectSchema)(_interceptorsSchema.interceptorsSchema).optional()
|
|
23
|
-
});
|
package/dist/bin/validateMockServerConfig/restConfigSchema/routeConfigSchema/routeConfigSchema.d.ts
CHANGED
|
@@ -1,48 +1,45 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import type { RestMethod } from '../../../../src/utils/types';
|
|
3
|
-
export declare const routeConfigSchema: (method: RestMethod) => z.ZodUnion<[z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodObject<{
|
|
4
|
-
data: z.ZodUnion<[z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>, z.ZodAny]>;
|
|
3
|
+
export declare const routeConfigSchema: (method: RestMethod) => z.ZodUnion<[z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodObject<z.objectUtil.extendShape<{
|
|
5
4
|
settings: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>;
|
|
5
|
+
data: z.ZodUnion<[z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>, z.ZodAny]>;
|
|
6
|
+
}, {
|
|
6
7
|
entities: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>;
|
|
7
8
|
interceptors: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>;
|
|
8
|
-
}
|
|
9
|
+
}>, "strict", z.ZodTypeAny, {
|
|
9
10
|
data?: any;
|
|
10
|
-
settings?: any;
|
|
11
|
-
entities?: any;
|
|
12
11
|
interceptors?: any;
|
|
12
|
+
entities?: any;
|
|
13
|
+
settings?: any;
|
|
13
14
|
}, {
|
|
14
15
|
data?: any;
|
|
15
|
-
settings?: unknown;
|
|
16
|
-
entities?: unknown;
|
|
17
16
|
interceptors?: unknown;
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
entities?: unknown;
|
|
18
|
+
settings?: unknown;
|
|
19
|
+
}>>, z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodObject<z.objectUtil.extendShape<{
|
|
20
20
|
settings: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>;
|
|
21
|
+
file: z.ZodString;
|
|
22
|
+
}, {
|
|
21
23
|
entities: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>;
|
|
22
24
|
interceptors: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>;
|
|
23
|
-
}
|
|
25
|
+
}>, "strict", z.ZodTypeAny, {
|
|
24
26
|
file: string;
|
|
25
|
-
settings?: any;
|
|
26
|
-
entities?: any;
|
|
27
27
|
interceptors?: any;
|
|
28
|
+
entities?: any;
|
|
29
|
+
settings?: any;
|
|
28
30
|
}, {
|
|
29
31
|
file: string;
|
|
30
|
-
settings?: unknown;
|
|
31
|
-
entities?: unknown;
|
|
32
32
|
interceptors?: unknown;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
time?: number | undefined;
|
|
39
|
-
data?: any;
|
|
40
|
-
}>>, "many">;
|
|
41
|
-
settings: z.ZodObject<{
|
|
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>;
|
|
42
38
|
status: z.ZodOptional<z.ZodNumber>;
|
|
43
39
|
delay: z.ZodOptional<z.ZodNumber>;
|
|
40
|
+
}, {
|
|
44
41
|
polling: z.ZodLiteral<true>;
|
|
45
|
-
}
|
|
42
|
+
}>, "strict", z.ZodTypeAny, {
|
|
46
43
|
polling: true;
|
|
47
44
|
status?: number | undefined;
|
|
48
45
|
delay?: number | undefined;
|
|
@@ -51,20 +48,28 @@ export declare const routeConfigSchema: (method: RestMethod) => z.ZodUnion<[z.Zo
|
|
|
51
48
|
status?: number | undefined;
|
|
52
49
|
delay?: number | undefined;
|
|
53
50
|
}>;
|
|
51
|
+
queue: z.ZodArray<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodType<{
|
|
52
|
+
data?: any;
|
|
53
|
+
time?: number | undefined;
|
|
54
|
+
}, z.ZodTypeDef, {
|
|
55
|
+
data?: any;
|
|
56
|
+
time?: number | undefined;
|
|
57
|
+
}>>, "many">;
|
|
58
|
+
}, {
|
|
54
59
|
entities: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>;
|
|
55
60
|
interceptors: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>;
|
|
56
|
-
}
|
|
61
|
+
}>, "strict", z.ZodTypeAny, {
|
|
57
62
|
queue: {
|
|
58
|
-
time?: number | undefined;
|
|
59
63
|
data?: any;
|
|
64
|
+
time?: number | undefined;
|
|
60
65
|
}[];
|
|
61
66
|
settings: {
|
|
62
67
|
polling: true;
|
|
63
68
|
status?: number | undefined;
|
|
64
69
|
delay?: number | undefined;
|
|
65
70
|
};
|
|
66
|
-
entities?: any;
|
|
67
71
|
interceptors?: any;
|
|
72
|
+
entities?: any;
|
|
68
73
|
}, {
|
|
69
74
|
queue: unknown[];
|
|
70
75
|
settings: {
|
|
@@ -72,6 +77,6 @@ export declare const routeConfigSchema: (method: RestMethod) => z.ZodUnion<[z.Zo
|
|
|
72
77
|
status?: number | undefined;
|
|
73
78
|
delay?: number | undefined;
|
|
74
79
|
};
|
|
75
|
-
entities?: unknown;
|
|
76
80
|
interceptors?: unknown;
|
|
81
|
+
entities?: unknown;
|
|
77
82
|
}>>]>;
|
package/dist/bin/validateMockServerConfig/restConfigSchema/routeConfigSchema/routeConfigSchema.js
CHANGED
|
@@ -1,52 +1,64 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
|
|
3
|
+
value: true
|
|
5
4
|
});
|
|
6
|
-
exports
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var _queueSchema = require("../../queueSchema/queueSchema");
|
|
12
|
-
var _settingsSchema = require("../../settingsSchema/settingsSchema");
|
|
13
|
-
var _utils = require("../../utils");
|
|
14
|
-
const METHODS_WITH_BODY = ['post', 'put', 'patch'];
|
|
15
|
-
const entitiesByEntityNameSchema = method => {
|
|
16
|
-
const isMethodWithBody = METHODS_WITH_BODY.includes(method);
|
|
17
|
-
return (0, _utils.plainObjectSchema)(_zod.z.strictObject({
|
|
18
|
-
headers: _utils.mappedEntitySchema.optional(),
|
|
19
|
-
cookies: _utils.mappedEntitySchema.optional(),
|
|
20
|
-
params: _utils.mappedEntitySchema.optional(),
|
|
21
|
-
query: _utils.mappedEntitySchema.optional(),
|
|
22
|
-
...(isMethodWithBody && {
|
|
23
|
-
body: _utils.plainEntitySchema.optional()
|
|
24
|
-
})
|
|
25
|
-
}));
|
|
26
|
-
};
|
|
27
|
-
const baseRouteConfigSchema = method => _zod.z.strictObject({
|
|
28
|
-
entities: entitiesByEntityNameSchema(method).optional(),
|
|
29
|
-
interceptors: (0, _utils.plainObjectSchema)(_interceptorsSchema.interceptorsSchema.pick({
|
|
30
|
-
response: true
|
|
31
|
-
})).optional()
|
|
5
|
+
Object.defineProperty(exports, "routeConfigSchema", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return routeConfigSchema;
|
|
9
|
+
}
|
|
32
10
|
});
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
11
|
+
const _zod = require("zod");
|
|
12
|
+
const _helpers = require("../../../../src/utils/helpers");
|
|
13
|
+
const _helpers1 = require("../../../helpers");
|
|
14
|
+
const _interceptorsSchema = require("../../interceptorsSchema/interceptorsSchema");
|
|
15
|
+
const _queueSchema = require("../../queueSchema/queueSchema");
|
|
16
|
+
const _settingsSchema = require("../../settingsSchema/settingsSchema");
|
|
17
|
+
const _utils = require("../../utils");
|
|
18
|
+
const METHODS_WITH_BODY = [
|
|
19
|
+
'post',
|
|
20
|
+
'put',
|
|
21
|
+
'patch'
|
|
22
|
+
];
|
|
23
|
+
const entitiesByEntityNameSchema = (method)=>{
|
|
24
|
+
const isMethodWithBody = METHODS_WITH_BODY.includes(method);
|
|
25
|
+
return (0, _utils.plainObjectSchema)(_zod.z.strictObject({
|
|
26
|
+
headers: _utils.mappedEntitySchema.optional(),
|
|
27
|
+
cookies: _utils.mappedEntitySchema.optional(),
|
|
28
|
+
params: _utils.mappedEntitySchema.optional(),
|
|
29
|
+
query: _utils.mappedEntitySchema.optional(),
|
|
30
|
+
...isMethodWithBody && {
|
|
31
|
+
body: _utils.plainEntitySchema.optional()
|
|
32
|
+
}
|
|
33
|
+
}));
|
|
34
|
+
};
|
|
35
|
+
const baseRouteConfigSchema = (method)=>_zod.z.strictObject({
|
|
36
|
+
entities: entitiesByEntityNameSchema(method).optional(),
|
|
37
|
+
interceptors: (0, _utils.plainObjectSchema)(_interceptorsSchema.interceptorsSchema).optional()
|
|
38
|
+
});
|
|
39
|
+
const dataRouteConfigSchema = (method)=>_zod.z.strictObject({
|
|
40
|
+
settings: (0, _utils.plainObjectSchema)(_settingsSchema.settingsSchema.extend({
|
|
41
|
+
polling: _zod.z.literal(false).optional()
|
|
42
|
+
})).optional(),
|
|
43
|
+
data: _zod.z.union([
|
|
44
|
+
_zod.z.function(),
|
|
45
|
+
_zod.z.any()
|
|
46
|
+
])
|
|
47
|
+
}).merge(baseRouteConfigSchema(method));
|
|
48
|
+
const fileRouteConfigSchema = (method)=>_zod.z.strictObject({
|
|
49
|
+
settings: (0, _utils.plainObjectSchema)(_settingsSchema.settingsSchema.extend({
|
|
50
|
+
polling: _zod.z.literal(false).optional()
|
|
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, _helpers1.isOnlyRequestedDataResolvingPropertyExists)(value, 'data')).pipe(dataRouteConfigSchema(method)),
|
|
62
|
+
_zod.z.custom((value)=>(0, _helpers.isPlainObject)(value) && (0, _helpers1.isOnlyRequestedDataResolvingPropertyExists)(value, 'file')).pipe(fileRouteConfigSchema(method)),
|
|
63
|
+
_zod.z.custom((value)=>(0, _helpers.isPlainObject)(value) && (0, _helpers1.isOnlyRequestedDataResolvingPropertyExists)(value, 'queue')).pipe(queueRouteConfigSchema(method))
|
|
64
|
+
]);
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "settingsSchema", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return settingsSchema;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _zod = require("zod");
|
|
12
|
+
const settingsSchema = _zod.z.strictObject({
|
|
13
|
+
polling: _zod.z.boolean().optional(),
|
|
14
|
+
status: _zod.z.number().min(200).max(599).optional(),
|
|
15
|
+
delay: _zod.z.number().nonnegative().optional()
|
|
5
16
|
});
|
|
6
|
-
exports.settingsSchema = void 0;
|
|
7
|
-
var _zod = require("zod");
|
|
8
|
-
const settingsSchema = exports.settingsSchema = _zod.z.strictObject({
|
|
9
|
-
polling: _zod.z.boolean().optional(),
|
|
10
|
-
status: _zod.z.number().min(200).max(599).optional(),
|
|
11
|
-
delay: _zod.z.number().nonnegative().optional()
|
|
12
|
-
});
|
|
@@ -1,14 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
|
|
3
|
+
value: true
|
|
5
4
|
});
|
|
6
|
-
exports
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
Object.defineProperty(exports, "staticPathSchema", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return staticPathSchema;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _zod = require("zod");
|
|
12
|
+
const _utils = require("../utils");
|
|
9
13
|
const staticPathObjectSchema = _zod.z.strictObject({
|
|
10
|
-
|
|
11
|
-
|
|
14
|
+
prefix: _utils.stringForwardSlashSchema,
|
|
15
|
+
path: _utils.stringForwardSlashSchema
|
|
12
16
|
});
|
|
13
|
-
const staticPathStringOrObjectSchema = _zod.z.union([
|
|
14
|
-
|
|
17
|
+
const staticPathStringOrObjectSchema = _zod.z.union([
|
|
18
|
+
_utils.stringForwardSlashSchema,
|
|
19
|
+
staticPathObjectSchema
|
|
20
|
+
]);
|
|
21
|
+
const staticPathSchema = _zod.z.union([
|
|
22
|
+
staticPathStringOrObjectSchema,
|
|
23
|
+
_zod.z.array(staticPathStringOrObjectSchema)
|
|
24
|
+
]);
|
|
@@ -1,12 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
|
|
3
|
+
value: true
|
|
5
4
|
});
|
|
6
|
-
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
+
checkActualValueCheckModeSchema: function() {
|
|
13
|
+
return checkActualValueCheckModeSchema;
|
|
14
|
+
},
|
|
15
|
+
compareWithDescriptorAnyValueCheckModeSchema: function() {
|
|
16
|
+
return compareWithDescriptorAnyValueCheckModeSchema;
|
|
17
|
+
},
|
|
18
|
+
compareWithDescriptorStringValueCheckModeSchema: function() {
|
|
19
|
+
return compareWithDescriptorStringValueCheckModeSchema;
|
|
20
|
+
},
|
|
21
|
+
compareWithDescriptorValueCheckModeSchema: function() {
|
|
22
|
+
return compareWithDescriptorValueCheckModeSchema;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
const _zod = require("zod");
|
|
26
|
+
const _constants = require("../../../../src/utils/constants");
|
|
27
|
+
const checkActualValueCheckModeSchema = _zod.z.enum(_constants.CHECK_ACTUAL_VALUE_CHECK_MODES);
|
|
28
|
+
const compareWithDescriptorAnyValueCheckModeSchema = _zod.z.enum(_constants.COMPARE_WITH_DESCRIPTOR_ANY_VALUE_CHECK_MODES);
|
|
29
|
+
const compareWithDescriptorStringValueCheckModeSchema = _zod.z.enum(_constants.COMPARE_WITH_DESCRIPTOR_STRING_VALUE_CHECK_MODES);
|
|
30
|
+
const compareWithDescriptorValueCheckModeSchema = _zod.z.enum(_constants.COMPARE_WITH_DESCRIPTOR_VALUE_CHECK_MODES);
|
|
@@ -4,11 +4,9 @@ export declare const plainEntitySchema: z.ZodUnion<[z.ZodPipeline<z.ZodType<unkn
|
|
|
4
4
|
value: (...args: unknown[]) => unknown;
|
|
5
5
|
} | {
|
|
6
6
|
checkMode: "equals" | "notEquals";
|
|
7
|
-
value:
|
|
7
|
+
value: string | number | boolean | {
|
|
8
8
|
[key: string]: string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | any | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null;
|
|
9
|
-
} | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | any | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[]
|
|
10
|
-
[key: string]: string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | any | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null;
|
|
11
|
-
} | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | any | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | undefined)) | null;
|
|
9
|
+
} | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | any | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null;
|
|
12
10
|
} | {
|
|
13
11
|
checkMode: "exists" | "notExists";
|
|
14
12
|
}, z.ZodTypeDef, {
|
|
@@ -16,11 +14,9 @@ export declare const plainEntitySchema: z.ZodUnion<[z.ZodPipeline<z.ZodType<unkn
|
|
|
16
14
|
value: (...args: unknown[]) => unknown;
|
|
17
15
|
} | {
|
|
18
16
|
checkMode: "equals" | "notEquals";
|
|
19
|
-
value:
|
|
20
|
-
[key: string]: string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | any | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null;
|
|
21
|
-
} | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | any | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[]) & (string | number | boolean | {
|
|
17
|
+
value: string | number | boolean | {
|
|
22
18
|
[key: string]: string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | any | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null;
|
|
23
|
-
} | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | any | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] |
|
|
19
|
+
} | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | any | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null;
|
|
24
20
|
} | {
|
|
25
21
|
checkMode: "exists" | "notExists";
|
|
26
22
|
}>>, z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>, z.ZodArray<z.ZodIntersection<z.ZodType<string | number | boolean | {
|
|
@@ -1,67 +1,124 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
|
|
3
|
+
value: true
|
|
5
4
|
});
|
|
6
|
-
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}),
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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
|
+
mappedEntitySchema: function() {
|
|
13
|
+
return mappedEntitySchema;
|
|
14
|
+
},
|
|
15
|
+
plainEntitySchema: function() {
|
|
16
|
+
return plainEntitySchema;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
const _zod = require("zod");
|
|
20
|
+
const _checkModeSchema = require("../checkModeSchema/checkModeSchema");
|
|
21
|
+
const _jsonSchema = require("../jsonSchema/jsonSchema");
|
|
22
|
+
const _plainObjectSchema = require("../plainObjectSchema/plainObjectSchema");
|
|
23
|
+
const _requiredPropertiesSchema = require("../requiredPropertiesSchema/requiredPropertiesSchema");
|
|
24
|
+
/* ----- Plain entity schema ----- */ const topLevelPlainEntityDescriptorSchema = (0, _requiredPropertiesSchema.requiredPropertiesSchema)(_zod.z.discriminatedUnion('checkMode', [
|
|
25
|
+
_zod.z.strictObject({
|
|
26
|
+
checkMode: _zod.z.literal('function'),
|
|
27
|
+
value: _zod.z.function()
|
|
28
|
+
}),
|
|
29
|
+
_zod.z.strictObject({
|
|
30
|
+
checkMode: _checkModeSchema.compareWithDescriptorAnyValueCheckModeSchema,
|
|
31
|
+
value: _jsonSchema.jsonSchema
|
|
32
|
+
}),
|
|
33
|
+
_zod.z.strictObject({
|
|
34
|
+
checkMode: _checkModeSchema.checkActualValueCheckModeSchema
|
|
35
|
+
})
|
|
36
|
+
]), [
|
|
37
|
+
'checkMode'
|
|
38
|
+
]);
|
|
39
|
+
const propertyLevelPlainEntityDescriptorSchema = (0, _requiredPropertiesSchema.requiredPropertiesSchema)(_zod.z.discriminatedUnion('checkMode', [
|
|
40
|
+
_zod.z.strictObject({
|
|
41
|
+
checkMode: _zod.z.literal('function'),
|
|
42
|
+
value: _zod.z.function()
|
|
43
|
+
}),
|
|
44
|
+
_zod.z.strictObject({
|
|
45
|
+
checkMode: _checkModeSchema.compareWithDescriptorAnyValueCheckModeSchema,
|
|
46
|
+
value: _jsonSchema.jsonSchema
|
|
47
|
+
}),
|
|
48
|
+
_zod.z.strictObject({
|
|
49
|
+
checkMode: _zod.z.literal('regExp'),
|
|
50
|
+
value: _zod.z.union([
|
|
51
|
+
_zod.z.instanceof(RegExp),
|
|
52
|
+
_zod.z.array(_zod.z.instanceof(RegExp))
|
|
53
|
+
])
|
|
54
|
+
}),
|
|
55
|
+
_zod.z.strictObject({
|
|
56
|
+
checkMode: _checkModeSchema.compareWithDescriptorStringValueCheckModeSchema,
|
|
57
|
+
value: _zod.z.union([
|
|
58
|
+
_jsonSchema.jsonLiteralSchema,
|
|
59
|
+
_zod.z.array(_jsonSchema.jsonLiteralSchema)
|
|
60
|
+
])
|
|
61
|
+
}),
|
|
62
|
+
_zod.z.strictObject({
|
|
63
|
+
checkMode: _checkModeSchema.checkActualValueCheckModeSchema
|
|
64
|
+
})
|
|
65
|
+
]), [
|
|
66
|
+
'checkMode'
|
|
67
|
+
]);
|
|
68
|
+
const nonCheckModeRecordSchema = (recordSchema)=>(0, _plainObjectSchema.plainObjectSchema)(recordSchema.and(_zod.z.object({
|
|
69
|
+
checkMode: _zod.z.never().optional()
|
|
70
|
+
})));
|
|
42
71
|
// ✅ important:
|
|
43
72
|
// 1st property level record disallow checkMode
|
|
44
|
-
const topLevelRecordValueSchema = _zod.z.union([
|
|
45
|
-
|
|
73
|
+
const topLevelRecordValueSchema = _zod.z.union([
|
|
74
|
+
_jsonSchema.jsonLiteralSchema,
|
|
75
|
+
_zod.z.array(_jsonSchema.jsonSchema),
|
|
76
|
+
nonCheckModeRecordSchema(_zod.z.record(_jsonSchema.jsonSchema))
|
|
77
|
+
]);
|
|
46
78
|
// ✅ important:
|
|
47
79
|
// top level record disallow checkMode
|
|
48
|
-
const topLevelRecordSchema = nonCheckModeRecordSchema(_zod.z.record(_zod.z.union([
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
80
|
+
const topLevelRecordSchema = nonCheckModeRecordSchema(_zod.z.record(_zod.z.union([
|
|
81
|
+
propertyLevelPlainEntityDescriptorSchema,
|
|
82
|
+
topLevelRecordValueSchema
|
|
83
|
+
])));
|
|
84
|
+
const topLevelArraySchema = _zod.z.array(_jsonSchema.jsonSchema.and(_zod.z.custom((value)=>!_jsonSchema.jsonLiteralSchema.safeParse(value).success)));
|
|
85
|
+
const plainEntitySchema = _zod.z.union([
|
|
86
|
+
topLevelPlainEntityDescriptorSchema,
|
|
87
|
+
topLevelRecordSchema,
|
|
88
|
+
topLevelArraySchema
|
|
89
|
+
]);
|
|
90
|
+
/* ----- Mapped entity schema ----- */ const mappedEntityValueSchema = _zod.z.union([
|
|
91
|
+
_zod.z.string(),
|
|
92
|
+
_zod.z.number(),
|
|
93
|
+
_zod.z.boolean()
|
|
94
|
+
]);
|
|
95
|
+
const mappedEntityDescriptorSchema = (0, _requiredPropertiesSchema.requiredPropertiesSchema)(_zod.z.discriminatedUnion('checkMode', [
|
|
96
|
+
_zod.z.strictObject({
|
|
97
|
+
checkMode: _zod.z.literal('function'),
|
|
98
|
+
value: _zod.z.function()
|
|
99
|
+
}),
|
|
100
|
+
_zod.z.strictObject({
|
|
101
|
+
checkMode: _zod.z.literal('regExp'),
|
|
102
|
+
value: _zod.z.union([
|
|
103
|
+
_zod.z.instanceof(RegExp),
|
|
104
|
+
_zod.z.array(_zod.z.instanceof(RegExp))
|
|
105
|
+
])
|
|
106
|
+
}),
|
|
107
|
+
_zod.z.strictObject({
|
|
108
|
+
checkMode: _checkModeSchema.compareWithDescriptorValueCheckModeSchema,
|
|
109
|
+
value: _zod.z.union([
|
|
110
|
+
mappedEntityValueSchema,
|
|
111
|
+
_zod.z.array(mappedEntityValueSchema)
|
|
112
|
+
])
|
|
113
|
+
}),
|
|
114
|
+
_zod.z.strictObject({
|
|
115
|
+
checkMode: _checkModeSchema.checkActualValueCheckModeSchema
|
|
116
|
+
})
|
|
117
|
+
]), [
|
|
118
|
+
'checkMode'
|
|
119
|
+
]);
|
|
120
|
+
const mappedEntitySchema = (0, _plainObjectSchema.plainObjectSchema)(_zod.z.record(_zod.z.union([
|
|
121
|
+
mappedEntityValueSchema,
|
|
122
|
+
_zod.z.array(mappedEntityValueSchema),
|
|
123
|
+
mappedEntityDescriptorSchema
|
|
124
|
+
])));
|