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,118 +1,111 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
5
4
  });
6
- exports.resolveEntityValues = void 0;
7
- var _flat = require("flat");
8
- var _constants = require("../../../constants");
9
- var _isPlainObject = require("../../isPlainObject/isPlainObject");
10
- var _isPrimitive = require("../../isPrimitive/isPrimitive");
11
- var _isRegExp = require("../../isRegExp/isRegExp");
12
- const checkFunction = (checkMode, actualValue, descriptorValue) => {
13
- if (checkMode === 'function' && typeof descriptorValue === 'function') return descriptorValue(actualValue, checkFunction);
14
- const actualValueString = String(actualValue);
15
- if (checkMode === 'regExp' && (0, _isRegExp.isRegExp)(descriptorValue)) return descriptorValue.test(actualValueString);
16
- const isActualValueUndefined = typeof actualValue === 'undefined';
17
- if (checkMode === 'exists') return !isActualValueUndefined;
18
- if (checkMode === 'notExists') return isActualValueUndefined;
19
-
20
- // important:
21
- // cast values to string for ignore types of values
22
- const descriptorValueString = String(descriptorValue);
23
- if (checkMode === 'equals') return actualValueString === descriptorValueString;
24
- if (checkMode === 'notEquals') return actualValueString !== descriptorValueString;
25
- if (checkMode === 'includes') return actualValueString.includes(descriptorValueString);
26
- if (checkMode === 'notIncludes') return !actualValueString.includes(descriptorValueString);
27
- if (checkMode === 'startsWith') return actualValueString.startsWith(descriptorValueString);
28
- if (checkMode === 'notStartsWith') return !actualValueString.startsWith(descriptorValueString);
29
- if (checkMode === 'endsWith') return actualValueString.endsWith(descriptorValueString);
30
- if (checkMode === 'notEndsWith') return !actualValueString.endsWith(descriptorValueString);
31
- throw new Error('Wrong checkMode');
5
+ Object.defineProperty(exports, "resolveEntityValues", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return resolveEntityValues;
9
+ }
10
+ });
11
+ const _flat = require("flat");
12
+ const _constants = require("../../../constants");
13
+ const _isPlainObject = require("../../isPlainObject/isPlainObject");
14
+ const _isPrimitive = require("../../isPrimitive/isPrimitive");
15
+ const _isRegExp = require("../../isRegExp/isRegExp");
16
+ const checkFunction = (checkMode, actualValue, descriptorValue)=>{
17
+ if (checkMode === "function" && typeof descriptorValue === "function") return descriptorValue(actualValue, checkFunction);
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;
23
+ // important:
24
+ // cast values to string for ignore types of values
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");
32
35
  };
33
- const resolveEntityValues = (checkMode, actualValue, descriptorValue) => {
34
- if (checkMode === 'function') return descriptorValue(actualValue, checkFunction);
35
- if (checkMode === 'exists' || checkMode === 'notExists') return checkFunction(checkMode, actualValue, descriptorValue);
36
-
37
- // actual: primitive, descriptor: primitive
38
- const isActualValuePrimitive = (0, _isPrimitive.isPrimitive)(actualValue);
39
- const isDescriptorValuePrimitive = (0, _isPrimitive.isPrimitive)(descriptorValue);
40
- if (isActualValuePrimitive && isDescriptorValuePrimitive) return checkFunction(checkMode, actualValue, descriptorValue);
41
-
42
- // actual: primitive, descriptor: array
43
- const isDescriptorValueArray = Array.isArray(descriptorValue);
44
- const isNegativeCheckMode = _constants.NEGATION_CHECK_MODES.includes(checkMode);
45
- if (isActualValuePrimitive && isDescriptorValueArray) {
46
- if (isNegativeCheckMode) {
47
- return descriptorValue.every(descriptorValueElement => checkFunction(checkMode, actualValue, descriptorValueElement));
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);
39
+ // ✅ actual: primitive, descriptor: primitive
40
+ const isActualValuePrimitive = (0, _isPrimitive.isPrimitive)(actualValue);
41
+ const isDescriptorValuePrimitive = (0, _isPrimitive.isPrimitive)(descriptorValue);
42
+ if (isActualValuePrimitive && isDescriptorValuePrimitive) return checkFunction(checkMode, actualValue, descriptorValue);
43
+ // actual: primitive, descriptor: array
44
+ const isDescriptorValueArray = Array.isArray(descriptorValue);
45
+ const isNegativeCheckMode = _constants.NEGATION_CHECK_MODES.includes(checkMode);
46
+ if (isActualValuePrimitive && isDescriptorValueArray) {
47
+ if (isNegativeCheckMode) {
48
+ return descriptorValue.every((descriptorValueElement)=>checkFunction(checkMode, actualValue, descriptorValueElement));
49
+ }
50
+ return descriptorValue.some((descriptorValueElement)=>checkFunction(checkMode, actualValue, descriptorValueElement));
48
51
  }
49
- return descriptorValue.some(descriptorValueElement => checkFunction(checkMode, actualValue, descriptorValueElement));
50
- }
51
-
52
- // actual: primitive, descriptor: object => skip
53
- const isDescriptorValueObject = (0, _isPlainObject.isPlainObject)(descriptorValue) || (0, _isRegExp.isRegExp)(descriptorValue);
54
- if (isActualValuePrimitive && isDescriptorValueObject) {
55
- if (checkMode === 'regExp') return checkFunction(checkMode, actualValue, descriptorValue);
56
- // ✅ important: resolving primitive with object make no sense
57
- return isNegativeCheckMode;
58
- }
59
-
60
- // ✅ actual: array, descriptor: primitive => skip
61
- const isActualValueArray = Array.isArray(actualValue);
62
- // important: resolving array with primitive make no sense
63
- if (isActualValueArray && isDescriptorValuePrimitive) return isNegativeCheckMode;
64
-
65
- // actual: array, descriptor: array
66
- if (isActualValueArray && isDescriptorValueArray) {
67
- if (actualValue.length !== descriptorValue.length) return isNegativeCheckMode;
68
- const flattenActualValue = (0, _flat.flatten)(actualValue);
69
- const flattenDescriptorValue = (0, _flat.flatten)(descriptorValue);
70
- if (Object.keys(flattenActualValue).length === Object.keys(flattenDescriptorValue).length) return Object.keys(flattenDescriptorValue).every(flattenDescriptorValueKey => checkFunction(checkMode, flattenActualValue[flattenDescriptorValueKey], flattenDescriptorValue[flattenDescriptorValueKey]));
71
- return isNegativeCheckMode;
72
- }
73
-
74
- // ✅ actual: array, descriptor: object => skip
75
- if (isActualValueArray && isDescriptorValueObject) {
76
- if (checkMode === 'regExp') return actualValue.some(actualValueElement => checkFunction(checkMode, actualValueElement, descriptorValue));
77
- // ✅ important: resolving array with object make no sense
78
- return isNegativeCheckMode;
79
- }
80
-
81
- // ✅ actual: object, descriptor: primitive => skip
82
- const isActualValueObject = (0, _isPlainObject.isPlainObject)(actualValue);
83
- // ✅ important: resolving object with primitive make no sense
84
- if (isActualValueObject && isDescriptorValuePrimitive) return isNegativeCheckMode;
85
-
86
- // ✅ actual: object, descriptor: array
87
- if (isActualValueObject && isDescriptorValueArray) {
88
- // ✅ important: any object can not pass RegExp check
89
- if (checkMode === 'regExp') return false;
90
- const flattenActualValue = (0, _flat.flatten)(actualValue);
91
- if (isNegativeCheckMode) {
92
- return descriptorValue.every(descriptorValueElement => {
93
- const flattenDescriptorValue = (0, _flat.flatten)(descriptorValueElement);
94
- if (Object.keys(flattenActualValue).length !== Object.keys(flattenDescriptorValue).length) return isNegativeCheckMode;
95
- return Object.keys(flattenActualValue).every(flattenActualValueKey => checkFunction(checkMode, flattenActualValue[flattenActualValueKey], flattenDescriptorValue[flattenActualValueKey]));
96
- });
52
+ // actual: primitive, descriptor: object => skip
53
+ const isDescriptorValueObject = (0, _isPlainObject.isPlainObject)(descriptorValue) || (0, _isRegExp.isRegExp)(descriptorValue);
54
+ if (isActualValuePrimitive && isDescriptorValueObject) {
55
+ if (checkMode === "regExp") return checkFunction(checkMode, actualValue, descriptorValue);
56
+ // important: resolving primitive with object make no sense
57
+ return isNegativeCheckMode;
58
+ }
59
+ // ✅ actual: array, descriptor: primitive => skip
60
+ const isActualValueArray = Array.isArray(actualValue);
61
+ // ✅ important: resolving array with primitive make no sense
62
+ if (isActualValueArray && isDescriptorValuePrimitive) return isNegativeCheckMode;
63
+ // ✅ actual: array, descriptor: array
64
+ if (isActualValueArray && isDescriptorValueArray) {
65
+ if (actualValue.length !== descriptorValue.length) return isNegativeCheckMode;
66
+ const flattenActualValue = (0, _flat.flatten)(actualValue);
67
+ const flattenDescriptorValue = (0, _flat.flatten)(descriptorValue);
68
+ if (Object.keys(flattenActualValue).length === Object.keys(flattenDescriptorValue).length) return Object.keys(flattenDescriptorValue).every((flattenDescriptorValueKey)=>checkFunction(checkMode, flattenActualValue[flattenDescriptorValueKey], flattenDescriptorValue[flattenDescriptorValueKey]));
69
+ return isNegativeCheckMode;
97
70
  }
98
- return descriptorValue.some(descriptorValueElement => {
99
- const flattenDescriptorValue = (0, _flat.flatten)(descriptorValueElement);
100
- if (Object.keys(flattenActualValue).length !== Object.keys(flattenDescriptorValue).length) return isNegativeCheckMode;
101
- return Object.keys(flattenActualValue).every(flattenActualValueKey => checkFunction(checkMode, flattenActualValue[flattenActualValueKey], flattenDescriptorValue[flattenActualValueKey]));
102
- });
103
- }
104
-
105
- // actual: object, descriptor: object
106
- if (isActualValueObject && isDescriptorValueObject) {
107
- // important: any object can not pass RegExp check
108
- if (checkMode === 'regExp') return false;
109
- const flattenActualValue = (0, _flat.flatten)(actualValue);
110
- const flattenDescriptorValue = (0, _flat.flatten)(descriptorValue);
111
- if (Object.keys(flattenActualValue).length !== Object.keys(flattenDescriptorValue).length) return isNegativeCheckMode;
112
- if (isNegativeCheckMode) {
113
- return Object.keys(flattenDescriptorValue).some(flattenDescriptorValueKey => checkFunction(checkMode, flattenActualValue[flattenDescriptorValueKey], flattenDescriptorValue[flattenDescriptorValueKey]));
71
+ // actual: array, descriptor: object => skip
72
+ if (isActualValueArray && isDescriptorValueObject) {
73
+ if (checkMode === "regExp") return actualValue.some((actualValueElement)=>checkFunction(checkMode, actualValueElement, descriptorValue));
74
+ // important: resolving array with object make no sense
75
+ return isNegativeCheckMode;
76
+ }
77
+ // ✅ actual: object, descriptor: primitive => skip
78
+ const isActualValueObject = (0, _isPlainObject.isPlainObject)(actualValue);
79
+ // important: resolving object with primitive make no sense
80
+ if (isActualValueObject && isDescriptorValuePrimitive) return isNegativeCheckMode;
81
+ // actual: object, descriptor: array
82
+ if (isActualValueObject && isDescriptorValueArray) {
83
+ // important: any object can not pass RegExp check
84
+ if (checkMode === "regExp") return false;
85
+ const flattenActualValue = (0, _flat.flatten)(actualValue);
86
+ if (isNegativeCheckMode) {
87
+ return descriptorValue.every((descriptorValueElement)=>{
88
+ const flattenDescriptorValue = (0, _flat.flatten)(descriptorValueElement);
89
+ if (Object.keys(flattenActualValue).length !== Object.keys(flattenDescriptorValue).length) return isNegativeCheckMode;
90
+ return Object.keys(flattenActualValue).every((flattenActualValueKey)=>checkFunction(checkMode, flattenActualValue[flattenActualValueKey], flattenDescriptorValue[flattenActualValueKey]));
91
+ });
92
+ }
93
+ return descriptorValue.some((descriptorValueElement)=>{
94
+ const flattenDescriptorValue = (0, _flat.flatten)(descriptorValueElement);
95
+ if (Object.keys(flattenActualValue).length !== Object.keys(flattenDescriptorValue).length) return isNegativeCheckMode;
96
+ return Object.keys(flattenActualValue).every((flattenActualValueKey)=>checkFunction(checkMode, flattenActualValue[flattenActualValueKey], flattenDescriptorValue[flattenActualValueKey]));
97
+ });
98
+ }
99
+ // ✅ actual: object, descriptor: object
100
+ if (isActualValueObject && isDescriptorValueObject) {
101
+ // ✅ important: any object can not pass RegExp check
102
+ if (checkMode === "regExp") return false;
103
+ const flattenActualValue = (0, _flat.flatten)(actualValue);
104
+ const flattenDescriptorValue = (0, _flat.flatten)(descriptorValue);
105
+ if (Object.keys(flattenActualValue).length !== Object.keys(flattenDescriptorValue).length) return isNegativeCheckMode;
106
+ if (isNegativeCheckMode) {
107
+ return Object.keys(flattenDescriptorValue).some((flattenDescriptorValueKey)=>checkFunction(checkMode, flattenActualValue[flattenDescriptorValueKey], flattenDescriptorValue[flattenDescriptorValueKey]));
108
+ }
109
+ return Object.keys(flattenDescriptorValue).every((flattenDescriptorValueKey)=>checkFunction(checkMode, flattenActualValue[flattenDescriptorValueKey], flattenDescriptorValue[flattenDescriptorValueKey]));
114
110
  }
115
- return Object.keys(flattenDescriptorValue).every(flattenDescriptorValueKey => checkFunction(checkMode, flattenActualValue[flattenDescriptorValueKey], flattenDescriptorValue[flattenDescriptorValueKey]));
116
- }
117
111
  };
118
- exports.resolveEntityValues = resolveEntityValues;
@@ -1,12 +1,15 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
5
4
  });
6
- exports.convertToEntityDescriptor = void 0;
7
- var _isEntityDescriptor = require("../isEntityDescriptor/isEntityDescriptor");
8
- const convertToEntityDescriptor = valueOrDescriptor => (0, _isEntityDescriptor.isEntityDescriptor)(valueOrDescriptor) ? valueOrDescriptor : {
9
- checkMode: 'equals',
10
- value: valueOrDescriptor
11
- };
12
- exports.convertToEntityDescriptor = convertToEntityDescriptor;
5
+ Object.defineProperty(exports, "convertToEntityDescriptor", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return convertToEntityDescriptor;
9
+ }
10
+ });
11
+ const _isEntityDescriptor = require("../isEntityDescriptor/isEntityDescriptor");
12
+ const convertToEntityDescriptor = (valueOrDescriptor)=>(0, _isEntityDescriptor.isEntityDescriptor)(valueOrDescriptor) ? valueOrDescriptor : {
13
+ checkMode: "equals",
14
+ value: valueOrDescriptor
15
+ };
@@ -1,27 +1,19 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
5
4
  });
6
- var _convertToEntityDescriptor = require("./convertToEntityDescriptor/convertToEntityDescriptor");
7
- Object.keys(_convertToEntityDescriptor).forEach(function (key) {
8
- if (key === "default" || key === "__esModule") return;
9
- if (key in exports && exports[key] === _convertToEntityDescriptor[key]) return;
10
- Object.defineProperty(exports, key, {
11
- enumerable: true,
12
- get: function () {
13
- return _convertToEntityDescriptor[key];
14
- }
15
- });
16
- });
17
- var _isEntityDescriptor = require("./isEntityDescriptor/isEntityDescriptor");
18
- Object.keys(_isEntityDescriptor).forEach(function (key) {
19
- if (key === "default" || key === "__esModule") return;
20
- if (key in exports && exports[key] === _isEntityDescriptor[key]) return;
21
- Object.defineProperty(exports, key, {
22
- enumerable: true,
23
- get: function () {
24
- return _isEntityDescriptor[key];
25
- }
26
- });
27
- });
5
+ _export_star(require("./convertToEntityDescriptor/convertToEntityDescriptor"), exports);
6
+ _export_star(require("./isEntityDescriptor/isEntityDescriptor"), exports);
7
+ function _export_star(from, to) {
8
+ Object.keys(from).forEach(function(k) {
9
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
10
+ Object.defineProperty(to, k, {
11
+ enumerable: true,
12
+ get: function() {
13
+ return from[k];
14
+ }
15
+ });
16
+ }
17
+ });
18
+ return from;
19
+ }
@@ -1,9 +1,12 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
5
4
  });
6
- exports.isEntityDescriptor = void 0;
7
- var _isPlainObject = require("../../isPlainObject/isPlainObject");
8
- const isEntityDescriptor = value => (0, _isPlainObject.isPlainObject)(value) && 'checkMode' in value;
9
- exports.isEntityDescriptor = isEntityDescriptor;
5
+ Object.defineProperty(exports, "isEntityDescriptor", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return isEntityDescriptor;
9
+ }
10
+ });
11
+ const _isPlainObject = require("../../isPlainObject/isPlainObject");
12
+ const isEntityDescriptor = (value)=>(0, _isPlainObject.isPlainObject)(value) && "checkMode" in value;
@@ -1,16 +1,18 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
5
4
  });
6
- var _isFilePathValid = require("./isFilePathValid/isFilePathValid");
7
- Object.keys(_isFilePathValid).forEach(function (key) {
8
- if (key === "default" || key === "__esModule") return;
9
- if (key in exports && exports[key] === _isFilePathValid[key]) return;
10
- Object.defineProperty(exports, key, {
11
- enumerable: true,
12
- get: function () {
13
- return _isFilePathValid[key];
14
- }
15
- });
16
- });
5
+ _export_star(require("./isFilePathValid/isFilePathValid"), exports);
6
+ function _export_star(from, to) {
7
+ Object.keys(from).forEach(function(k) {
8
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
9
+ Object.defineProperty(to, k, {
10
+ enumerable: true,
11
+ get: function() {
12
+ return from[k];
13
+ }
14
+ });
15
+ }
16
+ });
17
+ return from;
18
+ }
@@ -1,19 +1,26 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
5
4
  });
6
- exports.isFilePathValid = void 0;
7
- var _fs = _interopRequireDefault(require("fs"));
8
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
- const isFilePathValid = path => {
10
- try {
11
- if (!_fs.default.existsSync(path)) return false;
12
- if (!_fs.default.statSync(path).isFile()) return false;
13
- return true;
14
- } catch (error) {
15
- console.error(error);
16
- return false;
17
- }
5
+ Object.defineProperty(exports, "isFilePathValid", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return isFilePathValid;
9
+ }
10
+ });
11
+ const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
12
+ function _interop_require_default(obj) {
13
+ return obj && obj.__esModule ? obj : {
14
+ default: obj
15
+ };
16
+ }
17
+ const isFilePathValid = (path)=>{
18
+ try {
19
+ if (!_fs.default.existsSync(path)) return false;
20
+ if (!_fs.default.statSync(path).isFile()) return false;
21
+ return true;
22
+ } catch (error) {
23
+ console.error(error);
24
+ return false;
25
+ }
18
26
  };
19
- exports.isFilePathValid = isFilePathValid;
@@ -1,33 +1,29 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
5
4
  });
6
- exports.getGraphQLInput = void 0;
7
- const getGraphQLInput = request => {
8
- if (request.method === 'GET') {
9
- const {
10
- query,
11
- variables
12
- } = request.query;
13
-
14
- // important:
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
- return {
17
- query: query === null || query === void 0 ? void 0 : query.toString(),
18
- variables: typeof variables === 'string' ? JSON.parse(variables) : variables
19
- };
20
- }
21
- if (request.method === 'POST') {
22
- const {
23
- query,
24
- variables
25
- } = request.body;
26
- return {
27
- query,
28
- variables
29
- };
30
- }
31
- throw new Error(`Not allowed request method ${request.method} for graphql request`);
5
+ Object.defineProperty(exports, "getGraphQLInput", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return getGraphQLInput;
9
+ }
10
+ });
11
+ const getGraphQLInput = (request)=>{
12
+ if (request.method === "GET") {
13
+ const { query, variables } = request.query;
14
+ // important:
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
+ return {
17
+ query: query === null || query === void 0 ? void 0 : query.toString(),
18
+ variables: typeof variables === "string" ? JSON.parse(variables) : variables
19
+ };
20
+ }
21
+ if (request.method === "POST") {
22
+ const { query, variables } = request.body;
23
+ return {
24
+ query,
25
+ variables
26
+ };
27
+ }
28
+ throw new Error(`Not allowed request method ${request.method} for graphql request`);
32
29
  };
33
- exports.getGraphQLInput = getGraphQLInput;
@@ -1,38 +1,20 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
5
4
  });
6
- var _getGraphQLInput = require("./getGraphQLInput/getGraphQLInput");
7
- Object.keys(_getGraphQLInput).forEach(function (key) {
8
- if (key === "default" || key === "__esModule") return;
9
- if (key in exports && exports[key] === _getGraphQLInput[key]) return;
10
- Object.defineProperty(exports, key, {
11
- enumerable: true,
12
- get: function () {
13
- return _getGraphQLInput[key];
14
- }
15
- });
16
- });
17
- var _parseGraphQLRequest = require("./parseGraphQLRequest/parseGraphQLRequest");
18
- Object.keys(_parseGraphQLRequest).forEach(function (key) {
19
- if (key === "default" || key === "__esModule") return;
20
- if (key in exports && exports[key] === _parseGraphQLRequest[key]) return;
21
- Object.defineProperty(exports, key, {
22
- enumerable: true,
23
- get: function () {
24
- return _parseGraphQLRequest[key];
25
- }
26
- });
27
- });
28
- var _parseQuery = require("./parseQuery/parseQuery");
29
- Object.keys(_parseQuery).forEach(function (key) {
30
- if (key === "default" || key === "__esModule") return;
31
- if (key in exports && exports[key] === _parseQuery[key]) return;
32
- Object.defineProperty(exports, key, {
33
- enumerable: true,
34
- get: function () {
35
- return _parseQuery[key];
36
- }
37
- });
38
- });
5
+ _export_star(require("./getGraphQLInput/getGraphQLInput"), exports);
6
+ _export_star(require("./parseGraphQLRequest/parseGraphQLRequest"), exports);
7
+ _export_star(require("./parseQuery/parseQuery"), exports);
8
+ function _export_star(from, to) {
9
+ Object.keys(from).forEach(function(k) {
10
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
11
+ Object.defineProperty(to, k, {
12
+ enumerable: true,
13
+ get: function() {
14
+ return from[k];
15
+ }
16
+ });
17
+ }
18
+ });
19
+ return from;
20
+ }
@@ -1,14 +1,17 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
5
4
  });
6
- exports.parseGraphQLRequest = void 0;
7
- var _getGraphQLInput = require("../getGraphQLInput/getGraphQLInput");
8
- var _parseQuery = require("../parseQuery/parseQuery");
9
- const parseGraphQLRequest = request => {
10
- const graphQLInput = (0, _getGraphQLInput.getGraphQLInput)(request);
11
- if (!graphQLInput.query) return null;
12
- return (0, _parseQuery.parseQuery)(graphQLInput.query);
5
+ Object.defineProperty(exports, "parseGraphQLRequest", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return parseGraphQLRequest;
9
+ }
10
+ });
11
+ const _getGraphQLInput = require("../getGraphQLInput/getGraphQLInput");
12
+ const _parseQuery = require("../parseQuery/parseQuery");
13
+ const parseGraphQLRequest = (request)=>{
14
+ const graphQLInput = (0, _getGraphQLInput.getGraphQLInput)(request);
15
+ if (!graphQLInput.query) return null;
16
+ return (0, _parseQuery.parseQuery)(graphQLInput.query);
13
17
  };
14
- exports.parseGraphQLRequest = parseGraphQLRequest;
@@ -1,24 +1,28 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
5
4
  });
6
- exports.parseQuery = void 0;
7
- var _graphql = require("graphql");
8
- const parseDocumentNode = node => {
9
- var _operationDefinition$, _operationDefinition$2;
10
- const operationDefinition = node.definitions.find(definition => definition.kind === 'OperationDefinition');
11
- return {
12
- operationType: operationDefinition.operation,
13
- operationName: (_operationDefinition$ = (_operationDefinition$2 = operationDefinition.name) === null || _operationDefinition$2 === void 0 ? void 0 : _operationDefinition$2.value) !== null && _operationDefinition$ !== void 0 ? _operationDefinition$ : undefined
14
- };
5
+ Object.defineProperty(exports, "parseQuery", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return parseQuery;
9
+ }
10
+ });
11
+ const _graphql = require("graphql");
12
+ const parseDocumentNode = (node)=>{
13
+ var _operationDefinition_name;
14
+ const operationDefinition = node.definitions.find((definition)=>definition.kind === "OperationDefinition");
15
+ var _operationDefinition_name_value;
16
+ return {
17
+ operationType: operationDefinition.operation,
18
+ operationName: (_operationDefinition_name_value = (_operationDefinition_name = operationDefinition.name) === null || _operationDefinition_name === void 0 ? void 0 : _operationDefinition_name.value) !== null && _operationDefinition_name_value !== void 0 ? _operationDefinition_name_value : undefined
19
+ };
15
20
  };
16
- const parseQuery = query => {
17
- try {
18
- const document = (0, _graphql.parse)(query);
19
- return parseDocumentNode(document);
20
- } catch {
21
- return null;
22
- }
21
+ const parseQuery = (query)=>{
22
+ try {
23
+ const document = (0, _graphql.parse)(query);
24
+ return parseDocumentNode(document);
25
+ } catch {
26
+ return null;
27
+ }
23
28
  };
24
- exports.parseQuery = parseQuery;