mock-config-server 3.5.0 → 3.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/README.md +2 -0
  2. package/dist/bin/bin.js +3 -3
  3. package/dist/bin/build.js +5 -5
  4. package/dist/bin/cli.js +18 -18
  5. package/dist/bin/helpers/createTemplate.js +4 -4
  6. package/dist/bin/helpers/getValidationMessageFromPath.js +2 -2
  7. package/dist/bin/helpers/isOnlyRequestedDataResolvingPropertyExists.js +3 -3
  8. package/dist/bin/helpers/resolveConfigFile.js +3 -3
  9. package/dist/bin/helpers/resolveExportsFromSourceCode.js +1 -1
  10. package/dist/bin/init.js +36 -36
  11. package/dist/bin/run.js +6 -6
  12. package/dist/bin/validateMockServerConfig/corsSchema/corsSchema.d.ts +2 -2
  13. package/dist/bin/validateMockServerConfig/corsSchema/corsSchema.js +6 -6
  14. package/dist/bin/validateMockServerConfig/graphqlConfigSchema/graphqlConfigSchema.d.ts +82 -72
  15. package/dist/bin/validateMockServerConfig/graphqlConfigSchema/graphqlConfigSchema.js +4 -4
  16. package/dist/bin/validateMockServerConfig/graphqlConfigSchema/routeConfigSchema/routeConfigSchema.d.ts +25 -21
  17. package/dist/bin/validateMockServerConfig/graphqlConfigSchema/routeConfigSchema/routeConfigSchema.js +3 -5
  18. package/dist/bin/validateMockServerConfig/queueSchema/queueSchema.d.ts +2 -2
  19. package/dist/bin/validateMockServerConfig/queueSchema/queueSchema.js +1 -1
  20. package/dist/bin/validateMockServerConfig/restConfigSchema/restConfigSchema.d.ts +270 -240
  21. package/dist/bin/validateMockServerConfig/restConfigSchema/restConfigSchema.js +6 -6
  22. package/dist/bin/validateMockServerConfig/restConfigSchema/routeConfigSchema/routeConfigSchema.d.ts +33 -28
  23. package/dist/bin/validateMockServerConfig/restConfigSchema/routeConfigSchema/routeConfigSchema.js +7 -9
  24. package/dist/bin/validateMockServerConfig/utils/entitiesSchema/entitiesSchema.d.ts +4 -8
  25. package/dist/bin/validateMockServerConfig/utils/entitiesSchema/entitiesSchema.js +11 -11
  26. package/dist/bin/validateMockServerConfig/utils/requiredPropertiesSchema/requiredPropertiesSchema.d.ts +1 -1
  27. package/dist/bin/validateMockServerConfig/utils/sharedSchema/sharedSchema.js +2 -2
  28. package/dist/bin/validateMockServerConfig/validateApiMockServerConfig.js +3 -3
  29. package/dist/bin/validateMockServerConfig/validateMockServerConfig.js +1 -1
  30. package/dist/src/core/database/createDatabaseRoutes/createDatabaseRoutes.js +3 -3
  31. package/dist/src/core/database/createDatabaseRoutes/helpers/array/createNewId/createNewId.js +1 -1
  32. package/dist/src/core/database/createDatabaseRoutes/helpers/createNestedDatabaseRoutes/createNestedDatabaseRoutes.js +15 -13
  33. package/dist/src/core/database/createDatabaseRoutes/helpers/createShallowDatabaseRoutes/createShallowDatabaseRoutes.js +15 -13
  34. package/dist/src/core/database/createDatabaseRoutes/helpers/filter/filter.js +19 -13
  35. package/dist/src/core/database/createDatabaseRoutes/helpers/search/search.js +3 -3
  36. package/dist/src/core/database/createDatabaseRoutes/helpers/sort/sort.js +5 -5
  37. package/dist/src/core/database/createDatabaseRoutes/helpers/splitDatabaseByNesting/splitDatabaseByNesting.js +1 -1
  38. package/dist/src/core/database/createDatabaseRoutes/storages/File/FileStorage.js +1 -1
  39. package/dist/src/core/database/createDatabaseRoutes/storages/File/FileWriter.js +1 -1
  40. package/dist/src/core/graphql/createGraphQLRoutes/createGraphQLRoutes.js +24 -19
  41. package/dist/src/core/graphql/createGraphQLRoutes/helpers/prepareGraphQLRequestConfigs/prepareGraphQLRequestConfigs.js +1 -1
  42. package/dist/src/core/middlewares/cookieParseMiddleware/helpers/parseCookie/parseCookie.js +3 -3
  43. package/dist/src/core/middlewares/corsMiddleware/corsMiddleware.js +8 -8
  44. package/dist/src/core/middlewares/corsMiddleware/helpers/getAllowedOrigins/getAllowedOrigins.js +2 -2
  45. package/dist/src/core/middlewares/destroyerMiddleware/destroyerMiddleware.js +2 -2
  46. package/dist/src/core/middlewares/errorMiddleware/errorMiddleware.js +1 -1
  47. package/dist/src/core/middlewares/noCorsMiddleware/noCorsMiddleware.js +7 -7
  48. package/dist/src/core/middlewares/notFoundMiddleware/helpers/getGraphqlUrlSuggestions/getGraphqlUrlSuggestions.js +1 -1
  49. package/dist/src/core/middlewares/notFoundMiddleware/helpers/getRestUrlSuggestions/getRestUrlSuggestions.js +2 -2
  50. package/dist/src/core/middlewares/notFoundMiddleware/helpers/getRestUrlSuggestions/helpers/getActualRestUrlMeaningfulString/getActualRestUrlMeaningfulString.js +1 -1
  51. package/dist/src/core/middlewares/notFoundMiddleware/helpers/getRestUrlSuggestions/helpers/getPatternRestUrlMeaningfulString/getPatternRestUrlMeaningfulString.js +1 -1
  52. package/dist/src/core/middlewares/notFoundMiddleware/notFoundMiddleware.js +7 -7
  53. package/dist/src/core/middlewares/requestInterceptorMiddleware/requestInterceptorMiddleware.js +1 -1
  54. package/dist/src/core/middlewares/staticMiddleware/staticMiddleware.js +2 -2
  55. package/dist/src/core/rest/createRestRoutes/createRestRoutes.js +19 -14
  56. package/dist/src/core/rest/createRestRoutes/helpers/prepareRestRequestConfigs/prepareRestRequestConfigs.js +26 -2
  57. package/dist/src/server/createDatabaseMockServer/createDatabaseMockServer.js +6 -6
  58. package/dist/src/server/createGraphQLMockServer/createGraphQLMockServer.js +6 -6
  59. package/dist/src/server/createMockServer/createMockServer.js +8 -8
  60. package/dist/src/server/createRestMockServer/createRestMockServer.js +6 -6
  61. package/dist/src/utils/constants/checkModes.js +18 -18
  62. package/dist/src/utils/constants/default.js +4 -4
  63. package/dist/src/utils/helpers/config/resolveEntityValues/resolveEntityValues.js +20 -20
  64. package/dist/src/utils/helpers/entities/convertToEntityDescriptor/convertToEntityDescriptor.js +1 -1
  65. package/dist/src/utils/helpers/entities/isEntityDescriptor/isEntityDescriptor.js +1 -1
  66. package/dist/src/utils/helpers/graphql/getGraphQLInput/getGraphQLInput.js +3 -3
  67. package/dist/src/utils/helpers/graphql/parseQuery/parseQuery.js +1 -1
  68. package/dist/src/utils/helpers/isPlainObject/isPlainObject.js +1 -1
  69. package/dist/src/utils/helpers/url/convertWin32PathToUnix/convertWin32PathToUnix.js +1 -1
  70. package/dist/src/utils/helpers/url/getUrlParts/getUrlParts.js +1 -1
  71. package/dist/src/utils/helpers/url/removeLeadingAndTrailingSlashes/removeLeadingAndTrailingSlashes.js +1 -1
  72. package/dist/src/utils/helpers/url/urlJoin/urlJoin.js +1 -1
  73. package/dist/src/utils/types/graphql.d.ts +1 -1
  74. package/dist/src/utils/types/rest.d.ts +1 -1
  75. package/package.json +21 -23
@@ -23,16 +23,16 @@ function _interop_require_default(obj) {
23
23
  const createMockServer = (mockServerConfig, server = (0, _express.default)())=>{
24
24
  var _mockServerConfig_interceptors;
25
25
  const { cors, staticPath, rest, graphql, database, interceptors } = mockServerConfig;
26
- server.set("view engine", "ejs");
27
- server.set("views", (0, _helpers.urlJoin)(__dirname, "../../static/views"));
28
- server.use(_express.default.static((0, _helpers.urlJoin)(__dirname, "../../static/views")));
26
+ server.set('view engine', 'ejs');
27
+ server.set('views', (0, _helpers.urlJoin)(__dirname, '../../static/views'));
28
+ server.use(_express.default.static((0, _helpers.urlJoin)(__dirname, '../../static/views')));
29
29
  server.use(_bodyparser.default.urlencoded({
30
30
  extended: false
31
31
  }));
32
32
  server.use(_bodyparser.default.json({
33
- limit: "10mb"
33
+ limit: '10mb'
34
34
  }));
35
- server.set("json spaces", 2);
35
+ server.set('json spaces', 2);
36
36
  server.use(_bodyparser.default.text());
37
37
  (0, _middlewares.cookieParseMiddleware)(server);
38
38
  const serverRequestInterceptor = (_mockServerConfig_interceptors = mockServerConfig.interceptors) === null || _mockServerConfig_interceptors === void 0 ? void 0 : _mockServerConfig_interceptors.request;
@@ -43,7 +43,7 @@ const createMockServer = (mockServerConfig, server = (0, _express.default)())=>{
43
43
  });
44
44
  }
45
45
  var _mockServerConfig_baseUrl;
46
- const baseUrl = (_mockServerConfig_baseUrl = mockServerConfig.baseUrl) !== null && _mockServerConfig_baseUrl !== void 0 ? _mockServerConfig_baseUrl : "/";
46
+ const baseUrl = (_mockServerConfig_baseUrl = mockServerConfig.baseUrl) !== null && _mockServerConfig_baseUrl !== void 0 ? _mockServerConfig_baseUrl : '/';
47
47
  if (cors) {
48
48
  (0, _middlewares.corsMiddleware)(server, cors);
49
49
  } else {
@@ -60,7 +60,7 @@ const createMockServer = (mockServerConfig, server = (0, _express.default)())=>{
60
60
  serverResponseInterceptor: interceptors === null || interceptors === void 0 ? void 0 : interceptors.response
61
61
  });
62
62
  var _rest_baseUrl;
63
- const restBaseUrl = (0, _helpers.urlJoin)(baseUrl, (_rest_baseUrl = rest.baseUrl) !== null && _rest_baseUrl !== void 0 ? _rest_baseUrl : "/");
63
+ const restBaseUrl = (0, _helpers.urlJoin)(baseUrl, (_rest_baseUrl = rest.baseUrl) !== null && _rest_baseUrl !== void 0 ? _rest_baseUrl : '/');
64
64
  const apiRequestInterceptor = (_rest_interceptors = rest.interceptors) === null || _rest_interceptors === void 0 ? void 0 : _rest_interceptors.request;
65
65
  if (apiRequestInterceptor) {
66
66
  (0, _middlewares.requestInterceptorMiddleware)({
@@ -79,7 +79,7 @@ const createMockServer = (mockServerConfig, server = (0, _express.default)())=>{
79
79
  serverResponseInterceptor: interceptors === null || interceptors === void 0 ? void 0 : interceptors.response
80
80
  });
81
81
  var _graphql_baseUrl;
82
- const graphqlBaseUrl = (0, _helpers.urlJoin)(baseUrl, (_graphql_baseUrl = graphql.baseUrl) !== null && _graphql_baseUrl !== void 0 ? _graphql_baseUrl : "/");
82
+ const graphqlBaseUrl = (0, _helpers.urlJoin)(baseUrl, (_graphql_baseUrl = graphql.baseUrl) !== null && _graphql_baseUrl !== void 0 ? _graphql_baseUrl : '/');
83
83
  const apiRequestInterceptor = (_graphql_interceptors = graphql.interceptors) === null || _graphql_interceptors === void 0 ? void 0 : _graphql_interceptors.request;
84
84
  if (apiRequestInterceptor) {
85
85
  (0, _middlewares.requestInterceptorMiddleware)({
@@ -22,16 +22,16 @@ function _interop_require_default(obj) {
22
22
  const createRestMockServer = (restMockServerConfig, server = (0, _express.default)())=>{
23
23
  var _restMockServerConfig_interceptors;
24
24
  const { cors, staticPath, configs, database, interceptors } = restMockServerConfig;
25
- server.set("view engine", "ejs");
26
- server.set("views", (0, _helpers.urlJoin)(__dirname, "../../static/views"));
27
- server.use(_express.default.static((0, _helpers.urlJoin)(__dirname, "../../static/views")));
25
+ server.set('view engine', 'ejs');
26
+ server.set('views', (0, _helpers.urlJoin)(__dirname, '../../static/views'));
27
+ server.use(_express.default.static((0, _helpers.urlJoin)(__dirname, '../../static/views')));
28
28
  server.use(_bodyparser.default.urlencoded({
29
29
  extended: false
30
30
  }));
31
31
  server.use(_bodyparser.default.json({
32
- limit: "10mb"
32
+ limit: '10mb'
33
33
  }));
34
- server.set("json spaces", 2);
34
+ server.set('json spaces', 2);
35
35
  server.use(_bodyparser.default.text());
36
36
  (0, _middlewares.cookieParseMiddleware)(server);
37
37
  const serverRequestInterceptor = (_restMockServerConfig_interceptors = restMockServerConfig.interceptors) === null || _restMockServerConfig_interceptors === void 0 ? void 0 : _restMockServerConfig_interceptors.request;
@@ -42,7 +42,7 @@ const createRestMockServer = (restMockServerConfig, server = (0, _express.defaul
42
42
  });
43
43
  }
44
44
  var _restMockServerConfig_baseUrl;
45
- const baseUrl = (_restMockServerConfig_baseUrl = restMockServerConfig.baseUrl) !== null && _restMockServerConfig_baseUrl !== void 0 ? _restMockServerConfig_baseUrl : "/";
45
+ const baseUrl = (_restMockServerConfig_baseUrl = restMockServerConfig.baseUrl) !== null && _restMockServerConfig_baseUrl !== void 0 ? _restMockServerConfig_baseUrl : '/';
46
46
  if (cors) {
47
47
  (0, _middlewares.corsMiddleware)(server, cors);
48
48
  } else {
@@ -35,28 +35,28 @@ _export(exports, {
35
35
  }
36
36
  });
37
37
  const CHECK_ACTUAL_VALUE_CHECK_MODES = [
38
- "exists",
39
- "notExists"
38
+ 'exists',
39
+ 'notExists'
40
40
  ];
41
41
  const COMPARE_WITH_DESCRIPTOR_ANY_VALUE_CHECK_MODES = [
42
- "equals",
43
- "notEquals"
42
+ 'equals',
43
+ 'notEquals'
44
44
  ];
45
45
  const COMPARE_WITH_DESCRIPTOR_STRING_VALUE_CHECK_MODES = [
46
- "includes",
47
- "notIncludes",
48
- "startsWith",
49
- "notStartsWith",
50
- "endsWith",
51
- "notEndsWith"
46
+ 'includes',
47
+ 'notIncludes',
48
+ 'startsWith',
49
+ 'notStartsWith',
50
+ 'endsWith',
51
+ 'notEndsWith'
52
52
  ];
53
53
  const COMPARE_WITH_DESCRIPTOR_VALUE_CHECK_MODES = [
54
54
  ...COMPARE_WITH_DESCRIPTOR_ANY_VALUE_CHECK_MODES,
55
55
  ...COMPARE_WITH_DESCRIPTOR_STRING_VALUE_CHECK_MODES
56
56
  ];
57
57
  const CALCULATE_BY_DESCRIPTOR_VALUE_CHECK_MODES = [
58
- "regExp",
59
- "function"
58
+ 'regExp',
59
+ 'function'
60
60
  ];
61
61
  const CHECK_MODES = [
62
62
  ...CHECK_ACTUAL_VALUE_CHECK_MODES,
@@ -66,12 +66,12 @@ const CHECK_MODES = [
66
66
  const PLAIN_ENTITY_CHECK_MODES = [
67
67
  ...CHECK_ACTUAL_VALUE_CHECK_MODES,
68
68
  ...COMPARE_WITH_DESCRIPTOR_ANY_VALUE_CHECK_MODES,
69
- "function"
69
+ 'function'
70
70
  ];
71
71
  const NEGATION_CHECK_MODES = [
72
- "notExists",
73
- "notEquals",
74
- "notIncludes",
75
- "notStartsWith",
76
- "notEndsWith"
72
+ 'notExists',
73
+ 'notEquals',
74
+ 'notIncludes',
75
+ 'notStartsWith',
76
+ 'notEndsWith'
77
77
  ];
@@ -11,10 +11,10 @@ Object.defineProperty(exports, "DEFAULT", {
11
11
  const DEFAULT = {
12
12
  PORT: 31299,
13
13
  CORS: {
14
- ORIGIN: "*",
15
- METHODS: "GET,OPTIONS,PUT,PATCH,POST,DELETE",
16
- ALLOWED_HEADERS: "*",
17
- EXPOSED_HEADERS: "*",
14
+ ORIGIN: '*',
15
+ METHODS: 'GET,OPTIONS,PUT,PATCH,POST,DELETE',
16
+ ALLOWED_HEADERS: '*',
17
+ EXPOSED_HEADERS: '*',
18
18
  CREDENTIALS: true,
19
19
  MAX_AGE: 3600
20
20
  }
@@ -14,28 +14,28 @@ const _isPlainObject = require("../../isPlainObject/isPlainObject");
14
14
  const _isPrimitive = require("../../isPrimitive/isPrimitive");
15
15
  const _isRegExp = require("../../isRegExp/isRegExp");
16
16
  const checkFunction = (checkMode, actualValue, descriptorValue)=>{
17
- if (checkMode === "function" && typeof descriptorValue === "function") return descriptorValue(actualValue, checkFunction);
17
+ if (checkMode === 'function' && typeof descriptorValue === 'function') return descriptorValue(actualValue, checkFunction);
18
18
  const actualValueString = String(actualValue);
19
- if (checkMode === "regExp" && (0, _isRegExp.isRegExp)(descriptorValue)) return descriptorValue.test(actualValueString);
20
- const isActualValueUndefined = typeof actualValue === "undefined";
21
- if (checkMode === "exists") return !isActualValueUndefined;
22
- if (checkMode === "notExists") return isActualValueUndefined;
19
+ if (checkMode === 'regExp' && (0, _isRegExp.isRegExp)(descriptorValue)) return descriptorValue.test(actualValueString);
20
+ const isActualValueUndefined = typeof actualValue === 'undefined';
21
+ if (checkMode === 'exists') return !isActualValueUndefined;
22
+ if (checkMode === 'notExists') return isActualValueUndefined;
23
23
  // ✅ important:
24
24
  // cast values to string for ignore types of values
25
25
  const descriptorValueString = String(descriptorValue);
26
- if (checkMode === "equals") return actualValueString === descriptorValueString;
27
- if (checkMode === "notEquals") return actualValueString !== descriptorValueString;
28
- if (checkMode === "includes") return actualValueString.includes(descriptorValueString);
29
- if (checkMode === "notIncludes") return !actualValueString.includes(descriptorValueString);
30
- if (checkMode === "startsWith") return actualValueString.startsWith(descriptorValueString);
31
- if (checkMode === "notStartsWith") return !actualValueString.startsWith(descriptorValueString);
32
- if (checkMode === "endsWith") return actualValueString.endsWith(descriptorValueString);
33
- if (checkMode === "notEndsWith") return !actualValueString.endsWith(descriptorValueString);
34
- throw new Error("Wrong checkMode");
26
+ if (checkMode === 'equals') return actualValueString === descriptorValueString;
27
+ if (checkMode === 'notEquals') return actualValueString !== descriptorValueString;
28
+ if (checkMode === 'includes') return actualValueString.includes(descriptorValueString);
29
+ if (checkMode === 'notIncludes') return !actualValueString.includes(descriptorValueString);
30
+ if (checkMode === 'startsWith') return actualValueString.startsWith(descriptorValueString);
31
+ if (checkMode === 'notStartsWith') return !actualValueString.startsWith(descriptorValueString);
32
+ if (checkMode === 'endsWith') return actualValueString.endsWith(descriptorValueString);
33
+ if (checkMode === 'notEndsWith') return !actualValueString.endsWith(descriptorValueString);
34
+ throw new Error('Wrong checkMode');
35
35
  };
36
36
  const resolveEntityValues = (checkMode, actualValue, descriptorValue)=>{
37
- if (checkMode === "function") return descriptorValue(actualValue, checkFunction);
38
- if (checkMode === "exists" || checkMode === "notExists") return checkFunction(checkMode, actualValue, descriptorValue);
37
+ if (checkMode === 'function') return descriptorValue(actualValue, checkFunction);
38
+ if (checkMode === 'exists' || checkMode === 'notExists') return checkFunction(checkMode, actualValue, descriptorValue);
39
39
  // ✅ actual: primitive, descriptor: primitive
40
40
  const isActualValuePrimitive = (0, _isPrimitive.isPrimitive)(actualValue);
41
41
  const isDescriptorValuePrimitive = (0, _isPrimitive.isPrimitive)(descriptorValue);
@@ -52,7 +52,7 @@ const resolveEntityValues = (checkMode, actualValue, descriptorValue)=>{
52
52
  // ✅ actual: primitive, descriptor: object => skip
53
53
  const isDescriptorValueObject = (0, _isPlainObject.isPlainObject)(descriptorValue) || (0, _isRegExp.isRegExp)(descriptorValue);
54
54
  if (isActualValuePrimitive && isDescriptorValueObject) {
55
- if (checkMode === "regExp") return checkFunction(checkMode, actualValue, descriptorValue);
55
+ if (checkMode === 'regExp') return checkFunction(checkMode, actualValue, descriptorValue);
56
56
  // ✅ important: resolving primitive with object make no sense
57
57
  return isNegativeCheckMode;
58
58
  }
@@ -70,7 +70,7 @@ const resolveEntityValues = (checkMode, actualValue, descriptorValue)=>{
70
70
  }
71
71
  // ✅ actual: array, descriptor: object => skip
72
72
  if (isActualValueArray && isDescriptorValueObject) {
73
- if (checkMode === "regExp") return actualValue.some((actualValueElement)=>checkFunction(checkMode, actualValueElement, descriptorValue));
73
+ if (checkMode === 'regExp') return actualValue.some((actualValueElement)=>checkFunction(checkMode, actualValueElement, descriptorValue));
74
74
  // ✅ important: resolving array with object make no sense
75
75
  return isNegativeCheckMode;
76
76
  }
@@ -81,7 +81,7 @@ const resolveEntityValues = (checkMode, actualValue, descriptorValue)=>{
81
81
  // ✅ actual: object, descriptor: array
82
82
  if (isActualValueObject && isDescriptorValueArray) {
83
83
  // ✅ important: any object can not pass RegExp check
84
- if (checkMode === "regExp") return false;
84
+ if (checkMode === 'regExp') return false;
85
85
  const flattenActualValue = (0, _flat.flatten)(actualValue);
86
86
  if (isNegativeCheckMode) {
87
87
  return descriptorValue.every((descriptorValueElement)=>{
@@ -99,7 +99,7 @@ const resolveEntityValues = (checkMode, actualValue, descriptorValue)=>{
99
99
  // ✅ actual: object, descriptor: object
100
100
  if (isActualValueObject && isDescriptorValueObject) {
101
101
  // ✅ important: any object can not pass RegExp check
102
- if (checkMode === "regExp") return false;
102
+ if (checkMode === 'regExp') return false;
103
103
  const flattenActualValue = (0, _flat.flatten)(actualValue);
104
104
  const flattenDescriptorValue = (0, _flat.flatten)(descriptorValue);
105
105
  if (Object.keys(flattenActualValue).length !== Object.keys(flattenDescriptorValue).length) return isNegativeCheckMode;
@@ -10,6 +10,6 @@ Object.defineProperty(exports, "convertToEntityDescriptor", {
10
10
  });
11
11
  const _isEntityDescriptor = require("../isEntityDescriptor/isEntityDescriptor");
12
12
  const convertToEntityDescriptor = (valueOrDescriptor)=>(0, _isEntityDescriptor.isEntityDescriptor)(valueOrDescriptor) ? valueOrDescriptor : {
13
- checkMode: "equals",
13
+ checkMode: 'equals',
14
14
  value: valueOrDescriptor
15
15
  };
@@ -9,4 +9,4 @@ Object.defineProperty(exports, "isEntityDescriptor", {
9
9
  }
10
10
  });
11
11
  const _isPlainObject = require("../../isPlainObject/isPlainObject");
12
- const isEntityDescriptor = (value)=>(0, _isPlainObject.isPlainObject)(value) && "checkMode" in value;
12
+ const isEntityDescriptor = (value)=>(0, _isPlainObject.isPlainObject)(value) && 'checkMode' in value;
@@ -9,16 +9,16 @@ Object.defineProperty(exports, "getGraphQLInput", {
9
9
  }
10
10
  });
11
11
  const getGraphQLInput = (request)=>{
12
- if (request.method === "GET") {
12
+ if (request.method === 'GET') {
13
13
  const { query, variables } = request.query;
14
14
  // ✅ important:
15
15
  // if 'variables' was sent as encoded uri component then it already decoded into object and we do not need to use JSON.parse
16
16
  return {
17
17
  query: query === null || query === void 0 ? void 0 : query.toString(),
18
- variables: typeof variables === "string" ? JSON.parse(variables) : variables
18
+ variables: typeof variables === 'string' ? JSON.parse(variables) : variables
19
19
  };
20
20
  }
21
- if (request.method === "POST") {
21
+ if (request.method === 'POST') {
22
22
  const { query, variables } = request.body;
23
23
  return {
24
24
  query,
@@ -11,7 +11,7 @@ Object.defineProperty(exports, "parseQuery", {
11
11
  const _graphql = require("graphql");
12
12
  const parseDocumentNode = (node)=>{
13
13
  var _operationDefinition_name;
14
- const operationDefinition = node.definitions.find((definition)=>definition.kind === "OperationDefinition");
14
+ const operationDefinition = node.definitions.find((definition)=>definition.kind === 'OperationDefinition');
15
15
  var _operationDefinition_name_value;
16
16
  return {
17
17
  operationType: operationDefinition.operation,
@@ -8,4 +8,4 @@ Object.defineProperty(exports, "isPlainObject", {
8
8
  return isPlainObject;
9
9
  }
10
10
  });
11
- const isPlainObject = (value)=>typeof value === "object" && !Array.isArray(value) && value !== null && !(value instanceof RegExp);
11
+ const isPlainObject = (value)=>typeof value === 'object' && !Array.isArray(value) && value !== null && !(value instanceof RegExp);
@@ -8,4 +8,4 @@ Object.defineProperty(exports, "convertWin32PathToUnix", {
8
8
  return convertWin32PathToUnix;
9
9
  }
10
10
  });
11
- const convertWin32PathToUnix = (win32Path)=>win32Path.replace(/^\\\\\?\\/, "").replace(/\\/g, "/").replace(/\/\/+/g, "/");
11
+ const convertWin32PathToUnix = (win32Path)=>win32Path.replace(/^\\\\\?\\/, '').replace(/\\/g, '/').replace(/\/\/+/g, '/');
@@ -9,4 +9,4 @@ Object.defineProperty(exports, "getUrlParts", {
9
9
  }
10
10
  });
11
11
  const _removeLeadingAndTrailingSlashes = require("../removeLeadingAndTrailingSlashes/removeLeadingAndTrailingSlashes");
12
- const getUrlParts = (url)=>(0, _removeLeadingAndTrailingSlashes.removeLeadingAndTrailingSlashes)(url).split("/");
12
+ const getUrlParts = (url)=>(0, _removeLeadingAndTrailingSlashes.removeLeadingAndTrailingSlashes)(url).split('/');
@@ -8,4 +8,4 @@ Object.defineProperty(exports, "removeLeadingAndTrailingSlashes", {
8
8
  return removeLeadingAndTrailingSlashes;
9
9
  }
10
10
  });
11
- const removeLeadingAndTrailingSlashes = (string)=>string.replace(/^\/+|\/+$/g, "");
11
+ const removeLeadingAndTrailingSlashes = (string)=>string.replace(/^\/+|\/+$/g, '');
@@ -17,6 +17,6 @@ function _interop_require_default(obj) {
17
17
  };
18
18
  }
19
19
  const urlJoin = (...paths)=>{
20
- const pathsToJoin = _os.default.platform() === "win32" ? paths.map((path)=>(0, _convertWin32PathToUnix.convertWin32PathToUnix)(path)) : paths;
20
+ const pathsToJoin = _os.default.platform() === 'win32' ? paths.map((path)=>(0, _convertWin32PathToUnix.convertWin32PathToUnix)(path)) : paths;
21
21
  return _path.default.posix.join(...pathsToJoin);
22
22
  };
@@ -32,7 +32,7 @@ export type GraphQLRouteConfig = ({
32
32
  data: ((request: Request, entities: GraphQLEntitiesByEntityName) => Data | Promise<Data>) | Data;
33
33
  }) & {
34
34
  entities?: GraphQLEntitiesByEntityName;
35
- interceptors?: Pick<Interceptors, 'response'>;
35
+ interceptors?: Interceptors;
36
36
  };
37
37
  interface BaseGraphQLRequestConfig {
38
38
  operationType: GraphQLOperationType;
@@ -36,7 +36,7 @@ export type RestRouteConfig<Method extends RestMethod> = ({
36
36
  file: string;
37
37
  }) & {
38
38
  entities?: RestEntitiesByEntityName<Method>;
39
- interceptors?: Pick<Interceptors, 'response'>;
39
+ interceptors?: Interceptors;
40
40
  };
41
41
  export type RestPathString = `/${string}`;
42
42
  interface BaseRestRequestConfig<Method extends RestMethod> {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mock-config-server",
3
- "version": "3.5.0",
3
+ "version": "3.6.1",
4
4
  "description": "Tool that easily and quickly imitates server operation, create full fake api in few steps",
5
5
  "author": {
6
6
  "name": "SIBERIA CAN CODE 🧊",
@@ -50,7 +50,7 @@
50
50
  "build": "shx rm -rf dist && yarn build:types && yarn build:swc && yarn build:copy-templates",
51
51
  "start": "yarn build && node ./dist/bin/bin.js",
52
52
  "dev": "nodemon --watch src --watch bin --watch mock-server.config.* -e js,ts,ejs --exec \"yarn start\"",
53
- "test": "jest",
53
+ "unit-test": "vitest",
54
54
  "lint": "eslint . --ext .ts --no-error-on-unmatched-pattern --fix",
55
55
  "stylelint": "stylelint \"src/static/**/*.css\" --fix",
56
56
  "format": "prettier --write \"**/*.(ts|js)\"",
@@ -71,40 +71,38 @@
71
71
  "dependencies": {
72
72
  "@types/body-parser": "^1.19.5",
73
73
  "@types/express": "^4.17.21",
74
- "@types/flat": "^5.0.2",
74
+ "@types/flat": "^5.0.5",
75
75
  "@types/prompts": "^2.4.9",
76
76
  "@types/yargs": "^17.0.32",
77
77
  "ansi-colors": "^4.1.3",
78
78
  "body-parser": "^1.20.2",
79
- "ejs": "^3.1.9",
80
- "esbuild": "^0.19.11",
81
- "express": "^4.18.2",
82
- "express-urlrewrite": "^2.0.1",
79
+ "ejs": "^3.1.10",
80
+ "esbuild": "^0.21.4",
81
+ "express": "^4.19.2",
82
+ "express-urlrewrite": "^2.0.2",
83
83
  "flat": "^5.0.2",
84
- "graphql": "^16.6.0",
84
+ "graphql": "^16.8.1",
85
85
  "please-upgrade-node": "^3.2.0",
86
86
  "prompts": "^2.4.2",
87
87
  "yargs": "^17.7.2",
88
- "zod": "^3.22.4"
88
+ "zod": "^3.23.8"
89
89
  },
90
90
  "devDependencies": {
91
- "@siberiacancode/eslint": "^1.0.3",
92
- "@siberiacancode/jest": "^1.0.2",
93
- "@siberiacancode/prettier": "^1.0.1",
94
- "@siberiacancode/stylelint": "^1.0.2",
91
+ "@siberiacancode/eslint": "^1.1.1",
92
+ "@siberiacancode/prettier": "^1.1.1",
93
+ "@siberiacancode/stylelint": "^1.1.1",
94
+ "@siberiacancode/vitest": "^1.2.3",
95
95
  "@swc/cli": "^0.3.12",
96
- "@swc/core": "^1.4.12",
97
- "@swc/jest": "^0.2.36",
98
- "@types/jest": "^29.5.11",
96
+ "@swc/core": "^1.5.24",
99
97
  "@types/supertest": "^6.0.2",
100
- "husky": "^8.0.3",
101
- "lint-staged": "^15.2.0",
102
- "nodemon": "^3.0.3",
98
+ "husky": "^9.0.11",
99
+ "lint-staged": "^15.2.5",
100
+ "nodemon": "^3.1.2",
103
101
  "shx": "^0.3.4",
104
- "style-loader": "^3.3.4",
105
- "supertest": "^6.3.4",
106
- "tsc-alias": "^1.8.8",
107
- "typescript": "^5.3.3"
102
+ "style-loader": "^4.0.0",
103
+ "supertest": "^7.0.0",
104
+ "tsc-alias": "^1.8.10",
105
+ "typescript": "^5.4.5"
108
106
  },
109
107
  "homepage": "https://github.com/siberiacancode/mock-config-server",
110
108
  "repository": {