mock-config-server 3.4.0 → 3.5.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.
Files changed (155) hide show
  1. package/dist/bin/bin.js +5 -8
  2. package/dist/bin/build.js +52 -50
  3. package/dist/bin/cli.js +50 -43
  4. package/dist/bin/helpers/createTemplate.js +29 -21
  5. package/dist/bin/helpers/getMostSpecificPathFromError.js +34 -30
  6. package/dist/bin/helpers/getValidationMessageFromPath.js +11 -8
  7. package/dist/bin/helpers/index.js +21 -79
  8. package/dist/bin/helpers/isOnlyRequestedDataResolvingPropertyExists.js +13 -6
  9. package/dist/bin/helpers/resolveConfigFile.js +22 -19
  10. package/dist/bin/helpers/resolveConfigFilePath.js +19 -12
  11. package/dist/bin/helpers/resolveExportsFromSourceCode.js +13 -10
  12. package/dist/bin/init.js +114 -97
  13. package/dist/bin/run.js +42 -37
  14. package/dist/bin/templates/js/full/mock-server.config.js +16 -16
  15. package/dist/bin/templates/js/graphql/mock-server.config.js +9 -9
  16. package/dist/bin/templates/js/rest/mock-server.config.js +9 -9
  17. package/dist/bin/templates/ts/full/mock-requests/graphql/index.ts +2 -2
  18. package/dist/bin/templates/ts/full/mock-requests/graphql/user.ts +37 -37
  19. package/dist/bin/templates/ts/full/mock-requests/graphql/users.ts +14 -14
  20. package/dist/bin/templates/ts/full/mock-requests/rest/index.ts +2 -2
  21. package/dist/bin/templates/ts/full/mock-requests/rest/user.ts +37 -37
  22. package/dist/bin/templates/ts/full/mock-requests/rest/users.ts +14 -14
  23. package/dist/bin/templates/ts/full/mock-server.config.ts +18 -18
  24. package/dist/bin/templates/ts/graphql/mock-requests/index.ts +2 -2
  25. package/dist/bin/templates/ts/graphql/mock-requests/user.ts +37 -37
  26. package/dist/bin/templates/ts/graphql/mock-requests/users.ts +14 -14
  27. package/dist/bin/templates/ts/graphql/mock-server.config.ts +11 -11
  28. package/dist/bin/templates/ts/rest/mock-requests/index.ts +2 -2
  29. package/dist/bin/templates/ts/rest/mock-requests/user.ts +37 -37
  30. package/dist/bin/templates/ts/rest/mock-requests/users.ts +14 -14
  31. package/dist/bin/templates/ts/rest/mock-server.config.ts +11 -11
  32. package/dist/bin/validateMockServerConfig/baseUrlSchema/baseUrlSchema.js +9 -5
  33. package/dist/bin/validateMockServerConfig/corsSchema/corsSchema.js +32 -14
  34. package/dist/bin/validateMockServerConfig/databaseConfigSchema/databaseConfigSchema.js +19 -9
  35. package/dist/bin/validateMockServerConfig/graphqlConfigSchema/graphqlConfigSchema.js +38 -22
  36. package/dist/bin/validateMockServerConfig/graphqlConfigSchema/routeConfigSchema/routeConfigSchema.js +38 -28
  37. package/dist/bin/validateMockServerConfig/interceptorsSchema/interceptorsSchema.js +12 -8
  38. package/dist/bin/validateMockServerConfig/portSchema/portSchema.js +9 -5
  39. package/dist/bin/validateMockServerConfig/queueSchema/queueSchema.js +18 -9
  40. package/dist/bin/validateMockServerConfig/restConfigSchema/restConfigSchema.js +33 -19
  41. package/dist/bin/validateMockServerConfig/restConfigSchema/routeConfigSchema/routeConfigSchema.js +62 -48
  42. package/dist/bin/validateMockServerConfig/settingsSchema/settingsSchema.js +13 -9
  43. package/dist/bin/validateMockServerConfig/staticPathSchema/staticPathSchema.js +19 -9
  44. package/dist/bin/validateMockServerConfig/utils/checkModeSchema/checkModeSchema.js +27 -9
  45. package/dist/bin/validateMockServerConfig/utils/entitiesSchema/entitiesSchema.js +117 -60
  46. package/dist/bin/validateMockServerConfig/utils/index.js +20 -68
  47. package/dist/bin/validateMockServerConfig/utils/jsonSchema/jsonSchema.js +30 -10
  48. package/dist/bin/validateMockServerConfig/utils/plainObjectSchema/plainObjectSchema.js +9 -8
  49. package/dist/bin/validateMockServerConfig/utils/requiredPropertiesSchema/requiredPropertiesSchema.js +10 -7
  50. package/dist/bin/validateMockServerConfig/utils/sharedSchema/sharedSchema.js +18 -6
  51. package/dist/bin/validateMockServerConfig/validateApiMockServerConfig.js +43 -40
  52. package/dist/bin/validateMockServerConfig/validateMockServerConfig.js +38 -35
  53. package/dist/index.js +15 -13
  54. package/dist/src/core/database/createDatabaseRoutes/createDatabaseRoutes.js +25 -28
  55. package/dist/src/core/database/createDatabaseRoutes/helpers/array/createNewId/createNewId.js +14 -11
  56. package/dist/src/core/database/createDatabaseRoutes/helpers/array/findIndexById/findIndexById.js +8 -5
  57. package/dist/src/core/database/createDatabaseRoutes/helpers/array/index.js +17 -35
  58. package/dist/src/core/database/createDatabaseRoutes/helpers/array/isIndex/isIndex.js +8 -5
  59. package/dist/src/core/database/createDatabaseRoutes/helpers/createNestedDatabaseRoutes/createNestedDatabaseRoutes.js +157 -143
  60. package/dist/src/core/database/createDatabaseRoutes/helpers/createRewrittenDatabaseRoutes/createRewrittenDatabaseRoutes.js +15 -8
  61. package/dist/src/core/database/createDatabaseRoutes/helpers/createShallowDatabaseRoutes/createShallowDatabaseRoutes.js +88 -94
  62. package/dist/src/core/database/createDatabaseRoutes/helpers/filter/filter.js +44 -47
  63. package/dist/src/core/database/createDatabaseRoutes/helpers/index.js +19 -57
  64. package/dist/src/core/database/createDatabaseRoutes/helpers/pagination/pagination.js +32 -31
  65. package/dist/src/core/database/createDatabaseRoutes/helpers/search/search.js +34 -24
  66. package/dist/src/core/database/createDatabaseRoutes/helpers/sort/sort.js +38 -34
  67. package/dist/src/core/database/createDatabaseRoutes/helpers/splitDatabaseByNesting/splitDatabaseByNesting.js +26 -25
  68. package/dist/src/core/database/createDatabaseRoutes/storages/File/FileStorage.js +65 -50
  69. package/dist/src/core/database/createDatabaseRoutes/storages/File/FileWriter.js +55 -48
  70. package/dist/src/core/database/createDatabaseRoutes/storages/Memory/MemoryStorage.js +51 -41
  71. package/dist/src/core/database/createDatabaseRoutes/storages/index.js +16 -24
  72. package/dist/src/core/database/index.js +15 -13
  73. package/dist/src/core/graphql/createGraphQLRoutes/createGraphQLRoutes.js +126 -140
  74. package/dist/src/core/graphql/createGraphQLRoutes/helpers/index.js +15 -13
  75. package/dist/src/core/graphql/createGraphQLRoutes/helpers/prepareGraphQLRequestConfigs/prepareGraphQLRequestConfigs.js +36 -41
  76. package/dist/src/core/graphql/index.js +15 -13
  77. package/dist/src/core/middlewares/cookieParseMiddleware/cookieParseMiddleware.js +16 -13
  78. package/dist/src/core/middlewares/cookieParseMiddleware/helpers/index.js +15 -13
  79. package/dist/src/core/middlewares/cookieParseMiddleware/helpers/parseCookie/parseCookie.js +18 -15
  80. package/dist/src/core/middlewares/corsMiddleware/corsMiddleware.js +50 -47
  81. package/dist/src/core/middlewares/corsMiddleware/helpers/getAllowedOrigins/getAllowedOrigins.js +17 -12
  82. package/dist/src/core/middlewares/corsMiddleware/helpers/index.js +15 -13
  83. package/dist/src/core/middlewares/destroyerMiddleware/destroyerMiddleware.js +23 -20
  84. package/dist/src/core/middlewares/errorMiddleware/errorMiddleware.js +23 -17
  85. package/dist/src/core/middlewares/index.js +23 -91
  86. package/dist/src/core/middlewares/noCorsMiddleware/noCorsMiddleware.js +22 -19
  87. package/dist/src/core/middlewares/notFoundMiddleware/helpers/getGraphqlUrlSuggestions/getGraphqlUrlSuggestions.js +21 -23
  88. package/dist/src/core/middlewares/notFoundMiddleware/helpers/getLevenshteinDistance/getLevenshteinDistance.js +80 -80
  89. package/dist/src/core/middlewares/notFoundMiddleware/helpers/getRestUrlSuggestions/getRestUrlSuggestions.js +34 -34
  90. package/dist/src/core/middlewares/notFoundMiddleware/helpers/getRestUrlSuggestions/helpers/getActualRestUrlMeaningfulString/getActualRestUrlMeaningfulString.js +8 -5
  91. package/dist/src/core/middlewares/notFoundMiddleware/helpers/getRestUrlSuggestions/helpers/getPatternRestUrlMeaningfulString/getPatternRestUrlMeaningfulString.js +8 -5
  92. package/dist/src/core/middlewares/notFoundMiddleware/helpers/getRestUrlSuggestions/helpers/index.js +16 -24
  93. package/dist/src/core/middlewares/notFoundMiddleware/helpers/index.js +17 -35
  94. package/dist/src/core/middlewares/notFoundMiddleware/notFoundMiddleware.js +58 -60
  95. package/dist/src/core/middlewares/requestInterceptorMiddleware/requestInterceptorMiddleware.js +16 -17
  96. package/dist/src/core/middlewares/staticMiddleware/staticMiddleware.js +32 -25
  97. package/dist/src/core/rest/createRestRoutes/createRestRoutes.js +120 -130
  98. package/dist/src/core/rest/createRestRoutes/helpers/index.js +15 -13
  99. package/dist/src/core/rest/createRestRoutes/helpers/prepareRestRequestConfigs/prepareRestRequestConfigs.js +37 -43
  100. package/dist/src/core/rest/index.js +15 -13
  101. package/dist/src/index.js +16 -24
  102. package/dist/src/server/createDatabaseMockServer/createDatabaseMockServer.js +56 -53
  103. package/dist/src/server/createGraphQLMockServer/createGraphQLMockServer.js +64 -62
  104. package/dist/src/server/createMockServer/createMockServer.js +94 -91
  105. package/dist/src/server/createRestMockServer/createRestMockServer.js +64 -62
  106. package/dist/src/server/index.js +23 -91
  107. package/dist/src/server/startDatabaseMockServer/startDatabaseMockServer.js +25 -19
  108. package/dist/src/server/startGraphQLMockServer/startGraphQLMockServer.js +25 -19
  109. package/dist/src/server/startMockServer/startMockServer.js +25 -19
  110. package/dist/src/server/startRestMockServer/startRestMockServer.js +25 -19
  111. package/dist/src/utils/constants/appPath.js +8 -4
  112. package/dist/src/utils/constants/checkModes.js +74 -11
  113. package/dist/src/utils/constants/default.js +18 -14
  114. package/dist/src/utils/constants/index.js +17 -35
  115. package/dist/src/utils/helpers/asyncHandler.js +8 -5
  116. package/dist/src/utils/helpers/config/index.js +15 -13
  117. package/dist/src/utils/helpers/config/resolveEntityValues/resolveEntityValues.js +103 -110
  118. package/dist/src/utils/helpers/entities/convertToEntityDescriptor/convertToEntityDescriptor.js +12 -9
  119. package/dist/src/utils/helpers/entities/index.js +16 -24
  120. package/dist/src/utils/helpers/entities/isEntityDescriptor/isEntityDescriptor.js +9 -6
  121. package/dist/src/utils/helpers/files/index.js +15 -13
  122. package/dist/src/utils/helpers/files/isFilePathValid/isFilePathValid.js +22 -15
  123. package/dist/src/utils/helpers/graphql/getGraphQLInput/getGraphQLInput.js +25 -29
  124. package/dist/src/utils/helpers/graphql/index.js +17 -35
  125. package/dist/src/utils/helpers/graphql/parseGraphQLRequest/parseGraphQLRequest.js +13 -10
  126. package/dist/src/utils/helpers/graphql/parseQuery/parseQuery.js +23 -19
  127. package/dist/src/utils/helpers/index.js +26 -124
  128. package/dist/src/utils/helpers/interceptors/callRequestInterceptor/callRequestInterceptor.js +21 -21
  129. package/dist/src/utils/helpers/interceptors/callResponseInterceptors/callResponseInterceptors.js +62 -64
  130. package/dist/src/utils/helpers/interceptors/helpers/setDelay.js +10 -7
  131. package/dist/src/utils/helpers/interceptors/index.js +16 -24
  132. package/dist/src/utils/helpers/isPlainObject/isPlainObject.js +8 -5
  133. package/dist/src/utils/helpers/isPrimitive/isPrimitive.js +8 -5
  134. package/dist/src/utils/helpers/isRegExp/isRegExp.js +8 -5
  135. package/dist/src/utils/helpers/sleep.js +9 -6
  136. package/dist/src/utils/helpers/tests/createTmpDir.js +16 -9
  137. package/dist/src/utils/helpers/tests/index.js +15 -13
  138. package/dist/src/utils/helpers/url/convertWin32PathToUnix/convertWin32PathToUnix.js +8 -5
  139. package/dist/src/utils/helpers/url/getUrlParts/getUrlParts.js +9 -6
  140. package/dist/src/utils/helpers/url/index.js +18 -46
  141. package/dist/src/utils/helpers/url/removeLeadingAndTrailingSlashes/removeLeadingAndTrailingSlashes.js +8 -5
  142. package/dist/src/utils/helpers/url/urlJoin/urlJoin.js +18 -11
  143. package/dist/src/utils/types/checkModes.js +4 -1
  144. package/dist/src/utils/types/database.js +4 -1
  145. package/dist/src/utils/types/entities.js +4 -1
  146. package/dist/src/utils/types/graphql.js +4 -1
  147. package/dist/src/utils/types/index.js +24 -102
  148. package/dist/src/utils/types/interceptors.js +4 -1
  149. package/dist/src/utils/types/rest.js +4 -1
  150. package/dist/src/utils/types/server.js +4 -1
  151. package/dist/src/utils/types/utils.js +4 -1
  152. package/dist/src/utils/types/values.js +4 -1
  153. package/package.json +8 -9
  154. package/dist/bin/templates/.eslintrc.js +0 -14
  155. package/dist/bin/templates/tsconfig.json +0 -11
@@ -1,52 +1,66 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
5
4
  });
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()
5
+ Object.defineProperty(exports, "routeConfigSchema", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return routeConfigSchema;
9
+ }
32
10
  });
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;
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.pick({
38
+ response: true
39
+ })).optional()
40
+ });
41
+ const dataRouteConfigSchema = (method)=>_zod.z.strictObject({
42
+ settings: (0, _utils.plainObjectSchema)(_settingsSchema.settingsSchema.extend({
43
+ polling: _zod.z.literal(false).optional()
44
+ })).optional(),
45
+ data: _zod.z.union([
46
+ _zod.z.function(),
47
+ _zod.z.any()
48
+ ])
49
+ }).merge(baseRouteConfigSchema(method));
50
+ const fileRouteConfigSchema = (method)=>_zod.z.strictObject({
51
+ settings: (0, _utils.plainObjectSchema)(_settingsSchema.settingsSchema.extend({
52
+ polling: _zod.z.literal(false).optional()
53
+ })).optional(),
54
+ file: _zod.z.string()
55
+ }).merge(baseRouteConfigSchema(method));
56
+ const queueRouteConfigSchema = (method)=>_zod.z.strictObject({
57
+ settings: _settingsSchema.settingsSchema.extend({
58
+ polling: _zod.z.literal(true)
59
+ }),
60
+ queue: _queueSchema.queueSchema
61
+ }).merge(baseRouteConfigSchema(method));
62
+ const routeConfigSchema = (method)=>_zod.z.union([
63
+ _zod.z.custom((value)=>(0, _helpers.isPlainObject)(value) && (0, _helpers1.isOnlyRequestedDataResolvingPropertyExists)(value, "data")).pipe(dataRouteConfigSchema(method)),
64
+ _zod.z.custom((value)=>(0, _helpers.isPlainObject)(value) && (0, _helpers1.isOnlyRequestedDataResolvingPropertyExists)(value, "file")).pipe(fileRouteConfigSchema(method)),
65
+ _zod.z.custom((value)=>(0, _helpers.isPlainObject)(value) && (0, _helpers1.isOnlyRequestedDataResolvingPropertyExists)(value, "queue")).pipe(queueRouteConfigSchema(method))
66
+ ]);
@@ -1,12 +1,16 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
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
- value: true
3
+ value: true
5
4
  });
6
- exports.staticPathSchema = void 0;
7
- var _zod = require("zod");
8
- var _utils = require("../utils");
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
- prefix: _utils.stringForwardSlashSchema,
11
- path: _utils.stringForwardSlashSchema
14
+ prefix: _utils.stringForwardSlashSchema,
15
+ path: _utils.stringForwardSlashSchema
12
16
  });
13
- const staticPathStringOrObjectSchema = _zod.z.union([_utils.stringForwardSlashSchema, staticPathObjectSchema]);
14
- const staticPathSchema = exports.staticPathSchema = _zod.z.union([staticPathStringOrObjectSchema, _zod.z.array(staticPathStringOrObjectSchema)]);
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
- value: true
3
+ value: true
5
4
  });
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);
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);
@@ -1,67 +1,124 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
5
4
  });
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
-
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([_jsonSchema.jsonLiteralSchema, _zod.z.array(_jsonSchema.jsonSchema), nonCheckModeRecordSchema(_zod.z.record(_jsonSchema.jsonSchema))]);
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([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])));
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
+ ])));
@@ -1,71 +1,23 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
5
4
  });
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
- });
5
+ _export_star(require("./checkModeSchema/checkModeSchema"), exports);
6
+ _export_star(require("./entitiesSchema/entitiesSchema"), exports);
7
+ _export_star(require("./jsonSchema/jsonSchema"), exports);
8
+ _export_star(require("./plainObjectSchema/plainObjectSchema"), exports);
9
+ _export_star(require("./requiredPropertiesSchema/requiredPropertiesSchema"), exports);
10
+ _export_star(require("./sharedSchema/sharedSchema"), exports);
11
+ function _export_star(from, to) {
12
+ Object.keys(from).forEach(function(k) {
13
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
14
+ Object.defineProperty(to, k, {
15
+ enumerable: true,
16
+ get: function() {
17
+ return from[k];
18
+ }
19
+ });
20
+ }
21
+ });
22
+ return from;
23
+ }
@@ -1,13 +1,33 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
5
4
  });
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)))]));
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
+ jsonLiteralSchema: function() {
13
+ return jsonLiteralSchema;
14
+ },
15
+ jsonSchema: function() {
16
+ return jsonSchema;
17
+ }
18
+ });
19
+ const _zod = require("zod");
20
+ const _helpers = require("../../../../src/utils/helpers");
21
+ const jsonLiteralSchema = _zod.z.union([
22
+ _zod.z.string(),
23
+ _zod.z.number(),
24
+ _zod.z.boolean(),
25
+ _zod.z.null()
26
+ ]);
27
+ const jsonSchema = _zod.z.lazy(()=>_zod.z.union([
28
+ jsonLiteralSchema,
29
+ _zod.z.array(jsonSchema),
30
+ // ✅ important:
31
+ // using 'and' checking instead of 'plainObjectSchema' because of zod types peculiarities
32
+ _zod.z.record(jsonSchema).and(_zod.z.custom((value)=>(0, _helpers.isPlainObject)(value)))
33
+ ]));
@@ -1,11 +1,12 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
5
4
  });
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;
5
+ Object.defineProperty(exports, "plainObjectSchema", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return plainObjectSchema;
9
+ }
10
+ });
11
+ const _zod = require("zod");
12
+ const plainObjectSchema = (schema)=>_zod.z.custom((value)=>!(value instanceof RegExp)).pipe(schema);
@@ -1,10 +1,13 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
5
4
  });
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;
5
+ Object.defineProperty(exports, "requiredPropertiesSchema", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return requiredPropertiesSchema;
9
+ }
10
+ });
11
+ const _zod = require("zod");
12
+ const _helpers = require("../../../../src/utils/helpers");
13
+ const requiredPropertiesSchema = (schema, requiredProperties)=>_zod.z.custom((value)=>(0, _helpers.isPlainObject)(value) && requiredProperties.every((property)=>Object.prototype.hasOwnProperty.call(value, property))).pipe(schema);
@@ -1,9 +1,21 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
5
4
  });
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');
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
+ stringForwardSlashSchema: function() {
13
+ return stringForwardSlashSchema;
14
+ },
15
+ stringJsonFilenameSchema: function() {
16
+ return stringJsonFilenameSchema;
17
+ }
18
+ });
19
+ const _zod = require("zod");
20
+ const stringForwardSlashSchema = _zod.z.string().startsWith("/");
21
+ const stringJsonFilenameSchema = _zod.z.string().endsWith(".json");