mock-config-server 3.3.3 → 3.4.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 +107 -3
- package/dist/bin/build.js +1 -1
- package/dist/bin/cli.d.ts +1 -1
- package/dist/bin/cli.js +25 -16
- package/dist/bin/helpers/createTemplate.d.ts +9 -0
- package/dist/bin/helpers/createTemplate.js +25 -0
- package/dist/bin/helpers/getMostSpecificPathFromError.d.ts +2 -0
- package/dist/bin/helpers/getMostSpecificPathFromError.js +36 -0
- package/dist/bin/helpers/getValidationMessageFromPath.d.ts +1 -0
- package/dist/bin/helpers/getValidationMessageFromPath.js +11 -0
- package/dist/bin/helpers/index.d.ts +4 -0
- package/dist/bin/helpers/index.js +44 -0
- package/dist/bin/helpers/isOnlyRequestedDataResolvingPropertyExists.d.ts +4 -0
- package/dist/bin/helpers/isOnlyRequestedDataResolvingPropertyExists.js +9 -0
- package/dist/bin/init.d.ts +2 -0
- package/dist/bin/init.js +101 -0
- package/dist/bin/run.d.ts +1 -1
- package/dist/bin/run.js +23 -2
- package/dist/bin/templates/.eslintrc.js +14 -0
- package/dist/bin/templates/js/full/mock-requests/graphql/index.js +2 -0
- package/dist/bin/templates/js/full/mock-requests/graphql/user.js +35 -0
- package/dist/bin/templates/js/full/mock-requests/graphql/users.js +12 -0
- package/dist/bin/templates/js/full/mock-requests/rest/index.js +2 -0
- package/dist/bin/templates/js/full/mock-requests/rest/user.js +35 -0
- package/dist/bin/templates/js/full/mock-requests/rest/users.js +12 -0
- package/dist/bin/templates/js/full/mock-server.config.js +16 -0
- package/dist/bin/templates/js/graphql/mock-requests/index.js +2 -0
- package/dist/bin/templates/js/graphql/mock-requests/user.js +35 -0
- package/dist/bin/templates/js/graphql/mock-requests/users.js +12 -0
- package/dist/bin/templates/js/graphql/mock-server.config.js +9 -0
- package/dist/bin/templates/js/rest/mock-requests/index.js +2 -0
- package/dist/bin/templates/js/rest/mock-requests/user.js +35 -0
- package/dist/bin/templates/js/rest/mock-requests/users.js +12 -0
- package/dist/bin/templates/js/rest/mock-server.config.js +9 -0
- package/dist/bin/templates/ts/full/mock-requests/graphql/index.ts +2 -0
- package/dist/bin/templates/ts/full/mock-requests/graphql/user.ts +37 -0
- package/dist/bin/templates/ts/full/mock-requests/graphql/users.ts +14 -0
- package/dist/bin/templates/ts/full/mock-requests/rest/index.ts +2 -0
- package/dist/bin/templates/ts/full/mock-requests/rest/user.ts +37 -0
- package/dist/bin/templates/ts/full/mock-requests/rest/users.ts +14 -0
- package/dist/bin/templates/ts/full/mock-server.config.ts +18 -0
- package/dist/bin/templates/ts/graphql/mock-requests/index.ts +2 -0
- package/dist/bin/templates/ts/graphql/mock-requests/user.ts +37 -0
- package/dist/bin/templates/ts/graphql/mock-requests/users.ts +14 -0
- package/dist/bin/templates/ts/graphql/mock-server.config.ts +11 -0
- package/dist/bin/templates/ts/rest/mock-requests/index.ts +2 -0
- package/dist/bin/templates/ts/rest/mock-requests/user.ts +37 -0
- package/dist/bin/templates/ts/rest/mock-requests/users.ts +14 -0
- package/dist/bin/templates/ts/rest/mock-server.config.ts +11 -0
- package/dist/bin/templates/tsconfig.json +11 -0
- package/dist/bin/validateMockServerConfig/baseUrlSchema/baseUrlSchema.d.ts +1 -0
- package/dist/bin/validateMockServerConfig/baseUrlSchema/baseUrlSchema.js +8 -0
- package/dist/bin/validateMockServerConfig/corsSchema/corsSchema.d.ts +23 -0
- package/dist/bin/validateMockServerConfig/corsSchema/corsSchema.js +17 -0
- package/dist/bin/validateMockServerConfig/databaseConfigSchema/databaseConfigSchema.d.ts +11 -0
- package/dist/bin/validateMockServerConfig/databaseConfigSchema/databaseConfigSchema.js +12 -0
- package/dist/bin/validateMockServerConfig/graphqlConfigSchema/graphqlConfigSchema.d.ts +248 -0
- package/dist/bin/validateMockServerConfig/graphqlConfigSchema/graphqlConfigSchema.js +31 -0
- package/dist/bin/validateMockServerConfig/graphqlConfigSchema/routeConfigSchema/routeConfigSchema.d.ts +61 -0
- package/dist/bin/validateMockServerConfig/graphqlConfigSchema/routeConfigSchema/routeConfigSchema.js +37 -0
- package/dist/bin/validateMockServerConfig/interceptorsSchema/interceptorsSchema.d.ts +11 -0
- package/dist/bin/validateMockServerConfig/interceptorsSchema/interceptorsSchema.js +11 -0
- package/dist/bin/validateMockServerConfig/portSchema/portSchema.d.ts +2 -0
- package/dist/bin/validateMockServerConfig/portSchema/portSchema.js +9 -0
- package/dist/bin/validateMockServerConfig/queueSchema/queueSchema.d.ts +8 -0
- package/dist/bin/validateMockServerConfig/queueSchema/queueSchema.js +12 -0
- package/dist/bin/validateMockServerConfig/restConfigSchema/restConfigSchema.d.ts +713 -0
- package/dist/bin/validateMockServerConfig/restConfigSchema/restConfigSchema.js +23 -0
- package/dist/bin/validateMockServerConfig/restConfigSchema/routeConfigSchema/routeConfigSchema.d.ts +77 -0
- package/dist/bin/validateMockServerConfig/restConfigSchema/routeConfigSchema/routeConfigSchema.js +52 -0
- package/dist/bin/validateMockServerConfig/settingsSchema/settingsSchema.d.ts +14 -0
- package/dist/bin/validateMockServerConfig/settingsSchema/settingsSchema.js +12 -0
- package/dist/bin/validateMockServerConfig/staticPathSchema/staticPathSchema.d.ts +20 -0
- package/dist/bin/validateMockServerConfig/staticPathSchema/staticPathSchema.js +14 -0
- package/dist/bin/validateMockServerConfig/utils/checkModeSchema/checkModeSchema.d.ts +5 -0
- package/dist/bin/validateMockServerConfig/utils/checkModeSchema/checkModeSchema.js +12 -0
- package/dist/bin/validateMockServerConfig/utils/entitiesSchema/entitiesSchema.d.ts +75 -0
- package/dist/bin/validateMockServerConfig/utils/entitiesSchema/entitiesSchema.js +67 -0
- package/dist/bin/validateMockServerConfig/utils/index.d.ts +6 -0
- package/dist/bin/validateMockServerConfig/utils/index.js +71 -0
- package/dist/bin/validateMockServerConfig/utils/jsonSchema/jsonSchema.d.ts +8 -0
- package/dist/bin/validateMockServerConfig/utils/jsonSchema/jsonSchema.js +13 -0
- package/dist/bin/validateMockServerConfig/utils/plainObjectSchema/plainObjectSchema.d.ts +2 -0
- package/dist/bin/validateMockServerConfig/utils/plainObjectSchema/plainObjectSchema.js +11 -0
- package/dist/bin/validateMockServerConfig/utils/requiredPropertiesSchema/requiredPropertiesSchema.d.ts +3 -0
- package/dist/bin/validateMockServerConfig/utils/requiredPropertiesSchema/requiredPropertiesSchema.js +10 -0
- package/dist/bin/validateMockServerConfig/utils/sharedSchema/sharedSchema.d.ts +3 -0
- package/dist/bin/validateMockServerConfig/utils/sharedSchema/sharedSchema.js +9 -0
- package/dist/bin/validateMockServerConfig/validateApiMockServerConfig.d.ts +2 -0
- package/dist/bin/validateMockServerConfig/validateApiMockServerConfig.js +44 -0
- package/dist/bin/validateMockServerConfig/validateMockServerConfig.js +27 -20
- package/dist/src/core/database/createDatabaseRoutes/helpers/createNestedDatabaseRoutes/createNestedDatabaseRoutes.js +27 -16
- package/dist/src/core/database/createDatabaseRoutes/helpers/createShallowDatabaseRoutes/createShallowDatabaseRoutes.js +64 -3
- package/dist/src/core/database/createDatabaseRoutes/helpers/filter/filter.d.ts +1 -0
- package/dist/src/core/database/createDatabaseRoutes/helpers/filter/filter.js +46 -6
- package/dist/src/core/database/createDatabaseRoutes/helpers/pagination/pagination.d.ts +1 -0
- package/dist/src/core/database/createDatabaseRoutes/helpers/search/search.d.ts +4 -0
- package/dist/src/core/database/createDatabaseRoutes/helpers/search/search.js +29 -0
- package/dist/src/core/database/createDatabaseRoutes/helpers/sort/sort.d.ts +1 -0
- package/dist/src/core/database/createDatabaseRoutes/helpers/sort/sort.js +3 -4
- package/dist/src/core/database/createDatabaseRoutes/storages/File/FileWriter.js +2 -2
- package/dist/src/core/graphql/createGraphQLRoutes/createGraphQLRoutes.js +13 -7
- package/dist/src/core/graphql/createGraphQLRoutes/helpers/prepareGraphQLRequestConfigs/prepareGraphQLRequestConfigs.js +7 -1
- package/dist/src/core/rest/createRestRoutes/createRestRoutes.js +27 -10
- package/dist/src/core/rest/createRestRoutes/helpers/prepareRestRequestConfigs/prepareRestRequestConfigs.js +6 -0
- package/dist/src/server/createGraphQLMockServer/createGraphQLMockServer.js +1 -1
- package/dist/src/server/createRestMockServer/createRestMockServer.js +1 -1
- package/dist/src/static/views/components/header/index.js +1 -1
- package/dist/src/static/views/features/scheme/index.js +31 -31
- package/dist/src/static/views/features/tab/index.js +12 -12
- package/dist/src/utils/constants/appPath.js +1 -2
- package/dist/src/utils/constants/checkModes.d.ts +8 -9
- package/dist/src/utils/constants/checkModes.js +8 -16
- package/dist/src/utils/constants/default.js +2 -3
- package/dist/src/utils/helpers/files/index.d.ts +1 -0
- package/dist/src/utils/helpers/files/index.js +16 -0
- package/dist/src/utils/helpers/files/isFilePathValid/isFilePathValid.d.ts +1 -0
- package/dist/src/utils/helpers/files/isFilePathValid/isFilePathValid.js +19 -0
- package/dist/src/utils/helpers/index.d.ts +1 -0
- package/dist/src/utils/helpers/index.js +11 -0
- package/dist/src/utils/helpers/tests/createTmpDir.d.ts +1 -0
- package/dist/src/utils/helpers/tests/createTmpDir.js +12 -0
- package/dist/src/utils/helpers/tests/index.d.ts +1 -0
- package/dist/{bin/validateMockServerConfig/helpers/isCheckModeValid → src/utils/helpers/tests}/index.js +4 -4
- package/dist/src/utils/types/entities.d.ts +48 -0
- package/dist/src/utils/types/entities.js +1 -0
- package/dist/src/utils/types/graphql.d.ts +11 -45
- package/dist/src/utils/types/index.d.ts +1 -0
- package/dist/src/utils/types/index.js +11 -0
- package/dist/src/utils/types/rest.d.ts +17 -46
- package/dist/src/utils/types/server.d.ts +5 -4
- package/package.json +35 -27
- package/dist/bin/resolveConfigFilePath/resolveConfigFilePath.d.ts +0 -1
- package/dist/bin/resolveConfigFilePath/resolveConfigFilePath.js +0 -16
- package/dist/bin/validateMockServerConfig/helpers/index.d.ts +0 -2
- package/dist/bin/validateMockServerConfig/helpers/index.js +0 -27
- package/dist/bin/validateMockServerConfig/helpers/isCheckModeValid/index.d.ts +0 -1
- package/dist/bin/validateMockServerConfig/helpers/isCheckModeValid/isCheckModeValid.d.ts +0 -1
- package/dist/bin/validateMockServerConfig/helpers/isCheckModeValid/isCheckModeValid.js +0 -12
- package/dist/bin/validateMockServerConfig/helpers/isDescriptorValueValid/index.d.ts +0 -1
- package/dist/bin/validateMockServerConfig/helpers/isDescriptorValueValid/index.js +0 -16
- package/dist/bin/validateMockServerConfig/helpers/isDescriptorValueValid/isDescriptorValueValid.d.ts +0 -2
- package/dist/bin/validateMockServerConfig/helpers/isDescriptorValueValid/isDescriptorValueValid.js +0 -43
- package/dist/bin/validateMockServerConfig/validateBaseUrl/validateBaseUrl.d.ts +0 -1
- package/dist/bin/validateMockServerConfig/validateBaseUrl/validateBaseUrl.js +0 -15
- package/dist/bin/validateMockServerConfig/validateCors/validateCors.d.ts +0 -1
- package/dist/bin/validateMockServerConfig/validateCors/validateCors.js +0 -84
- package/dist/bin/validateMockServerConfig/validateDatabaseConfig/validateDatabaseConfig.d.ts +0 -1
- package/dist/bin/validateMockServerConfig/validateDatabaseConfig/validateDatabaseConfig.js +0 -45
- package/dist/bin/validateMockServerConfig/validateGraphqlConfig/validateGraphqlConfig.d.ts +0 -1
- package/dist/bin/validateMockServerConfig/validateGraphqlConfig/validateGraphqlConfig.js +0 -58
- package/dist/bin/validateMockServerConfig/validateGraphqlConfig/validateRoutes/validateRoutes.d.ts +0 -2
- package/dist/bin/validateMockServerConfig/validateGraphqlConfig/validateRoutes/validateRoutes.js +0 -153
- package/dist/bin/validateMockServerConfig/validateInterceptors/validateInterceptors.d.ts +0 -1
- package/dist/bin/validateMockServerConfig/validateInterceptors/validateInterceptors.js +0 -27
- package/dist/bin/validateMockServerConfig/validatePort/validatePort.d.ts +0 -1
- package/dist/bin/validateMockServerConfig/validatePort/validatePort.js +0 -12
- package/dist/bin/validateMockServerConfig/validateQueue/validateQueue.d.ts +0 -1
- package/dist/bin/validateMockServerConfig/validateQueue/validateQueue.js +0 -29
- package/dist/bin/validateMockServerConfig/validateRestConfig/validateRestConfig.d.ts +0 -1
- package/dist/bin/validateMockServerConfig/validateRestConfig/validateRestConfig.js +0 -57
- package/dist/bin/validateMockServerConfig/validateRestConfig/validateRoutes/validateRoutes.d.ts +0 -2
- package/dist/bin/validateMockServerConfig/validateRestConfig/validateRoutes/validateRoutes.js +0 -157
- package/dist/bin/validateMockServerConfig/validateSettings/validateSettings.d.ts +0 -1
- package/dist/bin/validateMockServerConfig/validateSettings/validateSettings.js +0 -34
- package/dist/bin/validateMockServerConfig/validateStaticPath/validateStaticPath.d.ts +0 -1
- package/dist/bin/validateMockServerConfig/validateStaticPath/validateStaticPath.js +0 -53
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.restConfigSchema = void 0;
|
|
7
|
+
var _zod = require("zod");
|
|
8
|
+
var _baseUrlSchema = require("../baseUrlSchema/baseUrlSchema");
|
|
9
|
+
var _interceptorsSchema = require("../interceptorsSchema/interceptorsSchema");
|
|
10
|
+
var _utils = require("../utils");
|
|
11
|
+
var _routeConfigSchema = require("./routeConfigSchema/routeConfigSchema");
|
|
12
|
+
const baseRequestConfigSchema = method => _zod.z.strictObject({
|
|
13
|
+
path: _zod.z.union([_utils.stringForwardSlashSchema, _zod.z.instanceof(RegExp)]),
|
|
14
|
+
method: _zod.z.literal(method),
|
|
15
|
+
routes: _zod.z.array((0, _routeConfigSchema.routeConfigSchema)(method)),
|
|
16
|
+
interceptors: (0, _utils.plainObjectSchema)(_interceptorsSchema.interceptorsSchema).optional()
|
|
17
|
+
});
|
|
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
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
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]>;
|
|
5
|
+
settings: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>;
|
|
6
|
+
entities: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>;
|
|
7
|
+
interceptors: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>;
|
|
8
|
+
}, "strict", z.ZodTypeAny, {
|
|
9
|
+
data?: any;
|
|
10
|
+
settings?: any;
|
|
11
|
+
entities?: any;
|
|
12
|
+
interceptors?: any;
|
|
13
|
+
}, {
|
|
14
|
+
data?: any;
|
|
15
|
+
settings?: unknown;
|
|
16
|
+
entities?: unknown;
|
|
17
|
+
interceptors?: unknown;
|
|
18
|
+
}>>, z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodObject<{
|
|
19
|
+
file: z.ZodString;
|
|
20
|
+
settings: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>;
|
|
21
|
+
entities: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>;
|
|
22
|
+
interceptors: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>;
|
|
23
|
+
}, "strict", z.ZodTypeAny, {
|
|
24
|
+
file: string;
|
|
25
|
+
settings?: any;
|
|
26
|
+
entities?: any;
|
|
27
|
+
interceptors?: any;
|
|
28
|
+
}, {
|
|
29
|
+
file: string;
|
|
30
|
+
settings?: unknown;
|
|
31
|
+
entities?: unknown;
|
|
32
|
+
interceptors?: unknown;
|
|
33
|
+
}>>, z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodObject<{
|
|
34
|
+
queue: z.ZodArray<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodType<{
|
|
35
|
+
time?: number | undefined;
|
|
36
|
+
data?: any;
|
|
37
|
+
}, z.ZodTypeDef, {
|
|
38
|
+
time?: number | undefined;
|
|
39
|
+
data?: any;
|
|
40
|
+
}>>, "many">;
|
|
41
|
+
settings: z.ZodObject<{
|
|
42
|
+
status: z.ZodOptional<z.ZodNumber>;
|
|
43
|
+
delay: z.ZodOptional<z.ZodNumber>;
|
|
44
|
+
polling: z.ZodLiteral<true>;
|
|
45
|
+
}, "strict", z.ZodTypeAny, {
|
|
46
|
+
polling: true;
|
|
47
|
+
status?: number | undefined;
|
|
48
|
+
delay?: number | undefined;
|
|
49
|
+
}, {
|
|
50
|
+
polling: true;
|
|
51
|
+
status?: number | undefined;
|
|
52
|
+
delay?: number | undefined;
|
|
53
|
+
}>;
|
|
54
|
+
entities: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>;
|
|
55
|
+
interceptors: z.ZodOptional<z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>>;
|
|
56
|
+
}, "strict", z.ZodTypeAny, {
|
|
57
|
+
queue: {
|
|
58
|
+
time?: number | undefined;
|
|
59
|
+
data?: any;
|
|
60
|
+
}[];
|
|
61
|
+
settings: {
|
|
62
|
+
polling: true;
|
|
63
|
+
status?: number | undefined;
|
|
64
|
+
delay?: number | undefined;
|
|
65
|
+
};
|
|
66
|
+
entities?: any;
|
|
67
|
+
interceptors?: any;
|
|
68
|
+
}, {
|
|
69
|
+
queue: unknown[];
|
|
70
|
+
settings: {
|
|
71
|
+
polling: true;
|
|
72
|
+
status?: number | undefined;
|
|
73
|
+
delay?: number | undefined;
|
|
74
|
+
};
|
|
75
|
+
entities?: unknown;
|
|
76
|
+
interceptors?: unknown;
|
|
77
|
+
}>>]>;
|
package/dist/bin/validateMockServerConfig/restConfigSchema/routeConfigSchema/routeConfigSchema.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.routeConfigSchema = void 0;
|
|
7
|
+
var _zod = require("zod");
|
|
8
|
+
var _helpers = require("../../../../src/utils/helpers");
|
|
9
|
+
var _helpers2 = require("../../../helpers");
|
|
10
|
+
var _interceptorsSchema = require("../../interceptorsSchema/interceptorsSchema");
|
|
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()
|
|
32
|
+
});
|
|
33
|
+
const dataRouteConfigSchema = method => _zod.z.strictObject({
|
|
34
|
+
settings: (0, _utils.plainObjectSchema)(_settingsSchema.settingsSchema.extend({
|
|
35
|
+
polling: _zod.z.literal(false).optional()
|
|
36
|
+
})).optional(),
|
|
37
|
+
data: _zod.z.union([_zod.z.function(), _zod.z.any()])
|
|
38
|
+
}).merge(baseRouteConfigSchema(method));
|
|
39
|
+
const fileRouteConfigSchema = method => _zod.z.strictObject({
|
|
40
|
+
settings: (0, _utils.plainObjectSchema)(_settingsSchema.settingsSchema.extend({
|
|
41
|
+
polling: _zod.z.literal(false).optional()
|
|
42
|
+
})).optional(),
|
|
43
|
+
file: _zod.z.string()
|
|
44
|
+
}).merge(baseRouteConfigSchema(method));
|
|
45
|
+
const queueRouteConfigSchema = method => _zod.z.strictObject({
|
|
46
|
+
settings: _settingsSchema.settingsSchema.extend({
|
|
47
|
+
polling: _zod.z.literal(true)
|
|
48
|
+
}),
|
|
49
|
+
queue: _queueSchema.queueSchema
|
|
50
|
+
}).merge(baseRouteConfigSchema(method));
|
|
51
|
+
const routeConfigSchema = method => _zod.z.union([_zod.z.custom(value => (0, _helpers.isPlainObject)(value) && (0, _helpers2.isOnlyRequestedDataResolvingPropertyExists)(value, 'data')).pipe(dataRouteConfigSchema(method)), _zod.z.custom(value => (0, _helpers.isPlainObject)(value) && (0, _helpers2.isOnlyRequestedDataResolvingPropertyExists)(value, 'file')).pipe(fileRouteConfigSchema(method)), _zod.z.custom(value => (0, _helpers.isPlainObject)(value) && (0, _helpers2.isOnlyRequestedDataResolvingPropertyExists)(value, 'queue')).pipe(queueRouteConfigSchema(method))]);
|
|
52
|
+
exports.routeConfigSchema = routeConfigSchema;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const settingsSchema: z.ZodObject<{
|
|
3
|
+
polling: z.ZodOptional<z.ZodBoolean>;
|
|
4
|
+
status: z.ZodOptional<z.ZodNumber>;
|
|
5
|
+
delay: z.ZodOptional<z.ZodNumber>;
|
|
6
|
+
}, "strict", z.ZodTypeAny, {
|
|
7
|
+
polling?: boolean | undefined;
|
|
8
|
+
status?: number | undefined;
|
|
9
|
+
delay?: number | undefined;
|
|
10
|
+
}, {
|
|
11
|
+
polling?: boolean | undefined;
|
|
12
|
+
status?: number | undefined;
|
|
13
|
+
delay?: number | undefined;
|
|
14
|
+
}>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
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
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const staticPathSchema: z.ZodUnion<[z.ZodUnion<[z.ZodString, z.ZodObject<{
|
|
3
|
+
prefix: z.ZodString;
|
|
4
|
+
path: z.ZodString;
|
|
5
|
+
}, "strict", z.ZodTypeAny, {
|
|
6
|
+
path: string;
|
|
7
|
+
prefix: string;
|
|
8
|
+
}, {
|
|
9
|
+
path: string;
|
|
10
|
+
prefix: string;
|
|
11
|
+
}>]>, z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodObject<{
|
|
12
|
+
prefix: z.ZodString;
|
|
13
|
+
path: z.ZodString;
|
|
14
|
+
}, "strict", z.ZodTypeAny, {
|
|
15
|
+
path: string;
|
|
16
|
+
prefix: string;
|
|
17
|
+
}, {
|
|
18
|
+
path: string;
|
|
19
|
+
prefix: string;
|
|
20
|
+
}>]>, "many">]>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.staticPathSchema = void 0;
|
|
7
|
+
var _zod = require("zod");
|
|
8
|
+
var _utils = require("../utils");
|
|
9
|
+
const staticPathObjectSchema = _zod.z.strictObject({
|
|
10
|
+
prefix: _utils.stringForwardSlashSchema,
|
|
11
|
+
path: _utils.stringForwardSlashSchema
|
|
12
|
+
});
|
|
13
|
+
const staticPathStringOrObjectSchema = _zod.z.union([_utils.stringForwardSlashSchema, staticPathObjectSchema]);
|
|
14
|
+
const staticPathSchema = exports.staticPathSchema = _zod.z.union([staticPathStringOrObjectSchema, _zod.z.array(staticPathStringOrObjectSchema)]);
|
|
@@ -0,0 +1,5 @@
|
|
|
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"]>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.compareWithDescriptorValueCheckModeSchema = exports.compareWithDescriptorStringValueCheckModeSchema = exports.compareWithDescriptorAnyValueCheckModeSchema = exports.checkActualValueCheckModeSchema = void 0;
|
|
7
|
+
var _zod = require("zod");
|
|
8
|
+
var _constants = require("../../../../src/utils/constants");
|
|
9
|
+
const checkActualValueCheckModeSchema = exports.checkActualValueCheckModeSchema = _zod.z.enum(_constants.CHECK_ACTUAL_VALUE_CHECK_MODES);
|
|
10
|
+
const compareWithDescriptorAnyValueCheckModeSchema = exports.compareWithDescriptorAnyValueCheckModeSchema = _zod.z.enum(_constants.COMPARE_WITH_DESCRIPTOR_ANY_VALUE_CHECK_MODES);
|
|
11
|
+
const compareWithDescriptorStringValueCheckModeSchema = exports.compareWithDescriptorStringValueCheckModeSchema = _zod.z.enum(_constants.COMPARE_WITH_DESCRIPTOR_STRING_VALUE_CHECK_MODES);
|
|
12
|
+
const compareWithDescriptorValueCheckModeSchema = exports.compareWithDescriptorValueCheckModeSchema = _zod.z.enum(_constants.COMPARE_WITH_DESCRIPTOR_VALUE_CHECK_MODES);
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const plainEntitySchema: z.ZodUnion<[z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodType<{
|
|
3
|
+
checkMode: "function";
|
|
4
|
+
value: (...args: unknown[]) => unknown;
|
|
5
|
+
} | {
|
|
6
|
+
checkMode: "equals" | "notEquals";
|
|
7
|
+
value: ((string | number | boolean | {
|
|
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)[]) & (string | number | boolean | {
|
|
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;
|
|
12
|
+
} | {
|
|
13
|
+
checkMode: "exists" | "notExists";
|
|
14
|
+
}, z.ZodTypeDef, {
|
|
15
|
+
checkMode: "function";
|
|
16
|
+
value: (...args: unknown[]) => unknown;
|
|
17
|
+
} | {
|
|
18
|
+
checkMode: "equals" | "notEquals";
|
|
19
|
+
value: ((string | number | boolean | {
|
|
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 | {
|
|
22
|
+
[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)[] | undefined)) | null;
|
|
24
|
+
} | {
|
|
25
|
+
checkMode: "exists" | "notExists";
|
|
26
|
+
}>>, z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>, z.ZodArray<z.ZodIntersection<z.ZodType<string | number | boolean | {
|
|
27
|
+
[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;
|
|
28
|
+
} | (string | number | boolean | {
|
|
29
|
+
[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;
|
|
30
|
+
} | (string | number | boolean | {
|
|
31
|
+
[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;
|
|
32
|
+
} | (string | number | boolean | {
|
|
33
|
+
[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;
|
|
34
|
+
} | (string | number | boolean | {
|
|
35
|
+
[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;
|
|
36
|
+
} | (string | number | boolean | {
|
|
37
|
+
[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;
|
|
38
|
+
} | (string | number | boolean | {
|
|
39
|
+
[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;
|
|
40
|
+
} | (string | number | boolean | {
|
|
41
|
+
[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;
|
|
42
|
+
} | (string | number | boolean | {
|
|
43
|
+
[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;
|
|
44
|
+
} | (string | number | boolean | {
|
|
45
|
+
[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;
|
|
46
|
+
} | (string | number | boolean | {
|
|
47
|
+
[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;
|
|
48
|
+
} | (string | number | boolean | {
|
|
49
|
+
[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;
|
|
50
|
+
} | any | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null, z.ZodTypeDef, string | number | boolean | {
|
|
51
|
+
[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;
|
|
52
|
+
} | (string | number | boolean | {
|
|
53
|
+
[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;
|
|
54
|
+
} | (string | number | boolean | {
|
|
55
|
+
[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;
|
|
56
|
+
} | (string | number | boolean | {
|
|
57
|
+
[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;
|
|
58
|
+
} | (string | number | boolean | {
|
|
59
|
+
[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;
|
|
60
|
+
} | (string | number | boolean | {
|
|
61
|
+
[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;
|
|
62
|
+
} | (string | number | boolean | {
|
|
63
|
+
[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;
|
|
64
|
+
} | (string | number | boolean | {
|
|
65
|
+
[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;
|
|
66
|
+
} | (string | number | boolean | {
|
|
67
|
+
[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;
|
|
68
|
+
} | (string | number | boolean | {
|
|
69
|
+
[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;
|
|
70
|
+
} | (string | number | boolean | {
|
|
71
|
+
[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;
|
|
72
|
+
} | (string | number | boolean | {
|
|
73
|
+
[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;
|
|
74
|
+
} | any | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null>, z.ZodType<unknown, z.ZodTypeDef, unknown>>, "many">]>;
|
|
75
|
+
export declare const mappedEntitySchema: z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.plainEntitySchema = exports.mappedEntitySchema = void 0;
|
|
7
|
+
var _zod = require("zod");
|
|
8
|
+
var _checkModeSchema = require("../checkModeSchema/checkModeSchema");
|
|
9
|
+
var _jsonSchema = require("../jsonSchema/jsonSchema");
|
|
10
|
+
var _plainObjectSchema = require("../plainObjectSchema/plainObjectSchema");
|
|
11
|
+
var _requiredPropertiesSchema = require("../requiredPropertiesSchema/requiredPropertiesSchema");
|
|
12
|
+
/* ----- Plain entity schema ----- */
|
|
13
|
+
|
|
14
|
+
const topLevelPlainEntityDescriptorSchema = (0, _requiredPropertiesSchema.requiredPropertiesSchema)(_zod.z.discriminatedUnion('checkMode', [_zod.z.strictObject({
|
|
15
|
+
checkMode: _zod.z.literal('function'),
|
|
16
|
+
value: _zod.z.function()
|
|
17
|
+
}), _zod.z.strictObject({
|
|
18
|
+
checkMode: _checkModeSchema.compareWithDescriptorAnyValueCheckModeSchema,
|
|
19
|
+
value: _jsonSchema.jsonSchema
|
|
20
|
+
}), _zod.z.strictObject({
|
|
21
|
+
checkMode: _checkModeSchema.checkActualValueCheckModeSchema
|
|
22
|
+
})]), ['checkMode']);
|
|
23
|
+
const propertyLevelPlainEntityDescriptorSchema = (0, _requiredPropertiesSchema.requiredPropertiesSchema)(_zod.z.discriminatedUnion('checkMode', [_zod.z.strictObject({
|
|
24
|
+
checkMode: _zod.z.literal('function'),
|
|
25
|
+
value: _zod.z.function()
|
|
26
|
+
}), _zod.z.strictObject({
|
|
27
|
+
checkMode: _checkModeSchema.compareWithDescriptorAnyValueCheckModeSchema,
|
|
28
|
+
value: _jsonSchema.jsonSchema
|
|
29
|
+
}), _zod.z.strictObject({
|
|
30
|
+
checkMode: _zod.z.literal('regExp'),
|
|
31
|
+
value: _zod.z.union([_zod.z.instanceof(RegExp), _zod.z.array(_zod.z.instanceof(RegExp))])
|
|
32
|
+
}), _zod.z.strictObject({
|
|
33
|
+
checkMode: _checkModeSchema.compareWithDescriptorStringValueCheckModeSchema,
|
|
34
|
+
value: _zod.z.union([_jsonSchema.jsonLiteralSchema, _zod.z.array(_jsonSchema.jsonLiteralSchema)])
|
|
35
|
+
}), _zod.z.strictObject({
|
|
36
|
+
checkMode: _checkModeSchema.checkActualValueCheckModeSchema
|
|
37
|
+
})]), ['checkMode']);
|
|
38
|
+
const nonCheckModeRecordSchema = recordSchema => (0, _plainObjectSchema.plainObjectSchema)(recordSchema.and(_zod.z.object({
|
|
39
|
+
checkMode: _zod.z.never().optional()
|
|
40
|
+
})));
|
|
41
|
+
|
|
42
|
+
// ✅ important:
|
|
43
|
+
// 1st property level record disallow checkMode
|
|
44
|
+
const topLevelRecordValueSchema = _zod.z.union([_jsonSchema.jsonLiteralSchema, _zod.z.array(_jsonSchema.jsonSchema), nonCheckModeRecordSchema(_zod.z.record(_jsonSchema.jsonSchema))]);
|
|
45
|
+
|
|
46
|
+
// ✅ important:
|
|
47
|
+
// top level record disallow checkMode
|
|
48
|
+
const topLevelRecordSchema = nonCheckModeRecordSchema(_zod.z.record(_zod.z.union([propertyLevelPlainEntityDescriptorSchema, topLevelRecordValueSchema])));
|
|
49
|
+
const topLevelArraySchema = _zod.z.array(_jsonSchema.jsonSchema.and(_zod.z.custom(value => !_jsonSchema.jsonLiteralSchema.safeParse(value).success)));
|
|
50
|
+
const plainEntitySchema = exports.plainEntitySchema = _zod.z.union([topLevelPlainEntityDescriptorSchema, topLevelRecordSchema, topLevelArraySchema]);
|
|
51
|
+
|
|
52
|
+
/* ----- Mapped entity schema ----- */
|
|
53
|
+
|
|
54
|
+
const mappedEntityValueSchema = _zod.z.union([_zod.z.string(), _zod.z.number(), _zod.z.boolean()]);
|
|
55
|
+
const mappedEntityDescriptorSchema = (0, _requiredPropertiesSchema.requiredPropertiesSchema)(_zod.z.discriminatedUnion('checkMode', [_zod.z.strictObject({
|
|
56
|
+
checkMode: _zod.z.literal('function'),
|
|
57
|
+
value: _zod.z.function()
|
|
58
|
+
}), _zod.z.strictObject({
|
|
59
|
+
checkMode: _zod.z.literal('regExp'),
|
|
60
|
+
value: _zod.z.union([_zod.z.instanceof(RegExp), _zod.z.array(_zod.z.instanceof(RegExp))])
|
|
61
|
+
}), _zod.z.strictObject({
|
|
62
|
+
checkMode: _checkModeSchema.compareWithDescriptorValueCheckModeSchema,
|
|
63
|
+
value: _zod.z.union([mappedEntityValueSchema, _zod.z.array(mappedEntityValueSchema)])
|
|
64
|
+
}), _zod.z.strictObject({
|
|
65
|
+
checkMode: _checkModeSchema.checkActualValueCheckModeSchema
|
|
66
|
+
})]), ['checkMode']);
|
|
67
|
+
const mappedEntitySchema = exports.mappedEntitySchema = (0, _plainObjectSchema.plainObjectSchema)(_zod.z.record(_zod.z.union([mappedEntityValueSchema, _zod.z.array(mappedEntityValueSchema), mappedEntityDescriptorSchema])));
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * from './checkModeSchema/checkModeSchema';
|
|
2
|
+
export * from './entitiesSchema/entitiesSchema';
|
|
3
|
+
export * from './jsonSchema/jsonSchema';
|
|
4
|
+
export * from './plainObjectSchema/plainObjectSchema';
|
|
5
|
+
export * from './requiredPropertiesSchema/requiredPropertiesSchema';
|
|
6
|
+
export * from './sharedSchema/sharedSchema';
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _checkModeSchema = require("./checkModeSchema/checkModeSchema");
|
|
7
|
+
Object.keys(_checkModeSchema).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _checkModeSchema[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _checkModeSchema[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
var _entitiesSchema = require("./entitiesSchema/entitiesSchema");
|
|
18
|
+
Object.keys(_entitiesSchema).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (key in exports && exports[key] === _entitiesSchema[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () {
|
|
24
|
+
return _entitiesSchema[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
var _jsonSchema = require("./jsonSchema/jsonSchema");
|
|
29
|
+
Object.keys(_jsonSchema).forEach(function (key) {
|
|
30
|
+
if (key === "default" || key === "__esModule") return;
|
|
31
|
+
if (key in exports && exports[key] === _jsonSchema[key]) return;
|
|
32
|
+
Object.defineProperty(exports, key, {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function () {
|
|
35
|
+
return _jsonSchema[key];
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
var _plainObjectSchema = require("./plainObjectSchema/plainObjectSchema");
|
|
40
|
+
Object.keys(_plainObjectSchema).forEach(function (key) {
|
|
41
|
+
if (key === "default" || key === "__esModule") return;
|
|
42
|
+
if (key in exports && exports[key] === _plainObjectSchema[key]) return;
|
|
43
|
+
Object.defineProperty(exports, key, {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function () {
|
|
46
|
+
return _plainObjectSchema[key];
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
var _requiredPropertiesSchema = require("./requiredPropertiesSchema/requiredPropertiesSchema");
|
|
51
|
+
Object.keys(_requiredPropertiesSchema).forEach(function (key) {
|
|
52
|
+
if (key === "default" || key === "__esModule") return;
|
|
53
|
+
if (key in exports && exports[key] === _requiredPropertiesSchema[key]) return;
|
|
54
|
+
Object.defineProperty(exports, key, {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function () {
|
|
57
|
+
return _requiredPropertiesSchema[key];
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
var _sharedSchema = require("./sharedSchema/sharedSchema");
|
|
62
|
+
Object.keys(_sharedSchema).forEach(function (key) {
|
|
63
|
+
if (key === "default" || key === "__esModule") return;
|
|
64
|
+
if (key in exports && exports[key] === _sharedSchema[key]) return;
|
|
65
|
+
Object.defineProperty(exports, key, {
|
|
66
|
+
enumerable: true,
|
|
67
|
+
get: function () {
|
|
68
|
+
return _sharedSchema[key];
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const jsonLiteralSchema: z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>;
|
|
3
|
+
type JsonLiteral = z.infer<typeof jsonLiteralSchema>;
|
|
4
|
+
type Json = JsonLiteral | {
|
|
5
|
+
[key: string]: Json;
|
|
6
|
+
} | Json[];
|
|
7
|
+
export declare const jsonSchema: z.ZodType<Json>;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.jsonSchema = exports.jsonLiteralSchema = void 0;
|
|
7
|
+
var _zod = require("zod");
|
|
8
|
+
var _helpers = require("../../../../src/utils/helpers");
|
|
9
|
+
const jsonLiteralSchema = exports.jsonLiteralSchema = _zod.z.union([_zod.z.string(), _zod.z.number(), _zod.z.boolean(), _zod.z.null()]);
|
|
10
|
+
const jsonSchema = exports.jsonSchema = _zod.z.lazy(() => _zod.z.union([jsonLiteralSchema, _zod.z.array(jsonSchema),
|
|
11
|
+
// ✅ important:
|
|
12
|
+
// using 'and' checking instead of 'plainObjectSchema' because of zod types peculiarities
|
|
13
|
+
_zod.z.record(jsonSchema).and(_zod.z.custom(value => (0, _helpers.isPlainObject)(value)))]));
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.plainObjectSchema = void 0;
|
|
7
|
+
var _zod = require("zod");
|
|
8
|
+
// ✅ important:
|
|
9
|
+
// this schema is needed because zod handle RegExps as plain object
|
|
10
|
+
const plainObjectSchema = schema => _zod.z.custom(value => !(value instanceof RegExp)).pipe(schema);
|
|
11
|
+
exports.plainObjectSchema = plainObjectSchema;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { PlainObject } from '../../../../src/utils/types';
|
|
3
|
+
export declare const requiredPropertiesSchema: <T extends PlainObject>(schema: z.ZodType<T, z.ZodTypeDef, T>, requiredProperties: (keyof T)[]) => z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodType<T, z.ZodTypeDef, T>>;
|
package/dist/bin/validateMockServerConfig/utils/requiredPropertiesSchema/requiredPropertiesSchema.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.requiredPropertiesSchema = void 0;
|
|
7
|
+
var _zod = require("zod");
|
|
8
|
+
var _helpers = require("../../../../src/utils/helpers");
|
|
9
|
+
const requiredPropertiesSchema = (schema, requiredProperties) => _zod.z.custom(value => (0, _helpers.isPlainObject)(value) && requiredProperties.every(property => Object.prototype.hasOwnProperty.call(value, property))).pipe(schema);
|
|
10
|
+
exports.requiredPropertiesSchema = requiredPropertiesSchema;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.stringJsonFilenameSchema = exports.stringForwardSlashSchema = void 0;
|
|
7
|
+
var _zod = require("zod");
|
|
8
|
+
const stringForwardSlashSchema = exports.stringForwardSlashSchema = _zod.z.string().startsWith('/');
|
|
9
|
+
const stringJsonFilenameSchema = exports.stringJsonFilenameSchema = _zod.z.string().endsWith('.json');
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.validateApiMockServerConfig = void 0;
|
|
7
|
+
var _zod = require("zod");
|
|
8
|
+
var _helpers = require("../helpers");
|
|
9
|
+
var _baseUrlSchema = require("./baseUrlSchema/baseUrlSchema");
|
|
10
|
+
var _corsSchema = require("./corsSchema/corsSchema");
|
|
11
|
+
var _databaseConfigSchema = require("./databaseConfigSchema/databaseConfigSchema");
|
|
12
|
+
var _graphqlConfigSchema = require("./graphqlConfigSchema/graphqlConfigSchema");
|
|
13
|
+
var _interceptorsSchema = require("./interceptorsSchema/interceptorsSchema");
|
|
14
|
+
var _portSchema = require("./portSchema/portSchema");
|
|
15
|
+
var _restConfigSchema = require("./restConfigSchema/restConfigSchema");
|
|
16
|
+
var _staticPathSchema = require("./staticPathSchema/staticPathSchema");
|
|
17
|
+
var _utils = require("./utils");
|
|
18
|
+
const validateApiMockServerConfig = (mockServerConfig, api) => {
|
|
19
|
+
if (!mockServerConfig.configs && !mockServerConfig.database && !mockServerConfig.staticPath) {
|
|
20
|
+
throw new Error('Configuration should contain at least one of these configs: configs | database | staticPath; see our doc (https://github.com/siberiacancode/mock-config-server) for more information');
|
|
21
|
+
}
|
|
22
|
+
const isConfigsContainAtLeastOneElement = Array.isArray(mockServerConfig.configs) && !!mockServerConfig.configs.length;
|
|
23
|
+
const mockServerConfigSchema = _zod.z.strictObject({
|
|
24
|
+
baseUrl: _baseUrlSchema.baseUrlSchema.optional(),
|
|
25
|
+
port: _portSchema.portSchema.optional(),
|
|
26
|
+
staticPath: _staticPathSchema.staticPathSchema.optional(),
|
|
27
|
+
interceptors: (0, _utils.plainObjectSchema)(_interceptorsSchema.interceptorsSchema).optional(),
|
|
28
|
+
cors: _corsSchema.corsSchema.optional(),
|
|
29
|
+
database: _databaseConfigSchema.databaseConfigSchema.optional(),
|
|
30
|
+
...(isConfigsContainAtLeastOneElement && api === 'graphql' && {
|
|
31
|
+
configs: _graphqlConfigSchema.graphqlConfigSchema.shape.configs
|
|
32
|
+
}),
|
|
33
|
+
...(isConfigsContainAtLeastOneElement && api === 'rest' && {
|
|
34
|
+
configs: _restConfigSchema.restConfigSchema.shape.configs
|
|
35
|
+
})
|
|
36
|
+
});
|
|
37
|
+
const validationResult = mockServerConfigSchema.safeParse(mockServerConfig);
|
|
38
|
+
if (!validationResult.success) {
|
|
39
|
+
const path = (0, _helpers.getMostSpecificPathFromError)(validationResult.error);
|
|
40
|
+
const validationMessage = (0, _helpers.getValidationMessageFromPath)(path);
|
|
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`);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
exports.validateApiMockServerConfig = validateApiMockServerConfig;
|