mock-config-server 3.4.1 → 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.
- package/dist/bin/bin.js +5 -8
- package/dist/bin/build.js +52 -50
- package/dist/bin/cli.js +50 -43
- package/dist/bin/helpers/createTemplate.js +29 -21
- package/dist/bin/helpers/getMostSpecificPathFromError.js +34 -30
- package/dist/bin/helpers/getValidationMessageFromPath.js +11 -8
- package/dist/bin/helpers/index.js +21 -79
- package/dist/bin/helpers/isOnlyRequestedDataResolvingPropertyExists.js +13 -6
- package/dist/bin/helpers/resolveConfigFile.js +22 -19
- package/dist/bin/helpers/resolveConfigFilePath.js +19 -12
- package/dist/bin/helpers/resolveExportsFromSourceCode.js +13 -10
- package/dist/bin/init.js +114 -97
- package/dist/bin/run.js +42 -43
- package/dist/bin/validateMockServerConfig/baseUrlSchema/baseUrlSchema.js +9 -5
- package/dist/bin/validateMockServerConfig/corsSchema/corsSchema.js +32 -14
- package/dist/bin/validateMockServerConfig/databaseConfigSchema/databaseConfigSchema.js +19 -9
- package/dist/bin/validateMockServerConfig/graphqlConfigSchema/graphqlConfigSchema.js +38 -22
- package/dist/bin/validateMockServerConfig/graphqlConfigSchema/routeConfigSchema/routeConfigSchema.js +38 -28
- package/dist/bin/validateMockServerConfig/interceptorsSchema/interceptorsSchema.js +12 -8
- package/dist/bin/validateMockServerConfig/portSchema/portSchema.js +9 -5
- package/dist/bin/validateMockServerConfig/queueSchema/queueSchema.js +18 -9
- package/dist/bin/validateMockServerConfig/restConfigSchema/restConfigSchema.js +33 -19
- package/dist/bin/validateMockServerConfig/restConfigSchema/routeConfigSchema/routeConfigSchema.js +62 -48
- package/dist/bin/validateMockServerConfig/settingsSchema/settingsSchema.js +13 -9
- package/dist/bin/validateMockServerConfig/staticPathSchema/staticPathSchema.js +19 -9
- package/dist/bin/validateMockServerConfig/utils/checkModeSchema/checkModeSchema.js +27 -9
- package/dist/bin/validateMockServerConfig/utils/entitiesSchema/entitiesSchema.js +117 -60
- package/dist/bin/validateMockServerConfig/utils/index.js +20 -68
- package/dist/bin/validateMockServerConfig/utils/jsonSchema/jsonSchema.js +30 -10
- package/dist/bin/validateMockServerConfig/utils/plainObjectSchema/plainObjectSchema.js +9 -8
- package/dist/bin/validateMockServerConfig/utils/requiredPropertiesSchema/requiredPropertiesSchema.js +10 -7
- package/dist/bin/validateMockServerConfig/utils/sharedSchema/sharedSchema.js +18 -6
- package/dist/bin/validateMockServerConfig/validateApiMockServerConfig.js +43 -40
- package/dist/bin/validateMockServerConfig/validateMockServerConfig.js +38 -35
- package/dist/index.js +15 -13
- package/dist/src/core/database/createDatabaseRoutes/createDatabaseRoutes.js +25 -28
- package/dist/src/core/database/createDatabaseRoutes/helpers/array/createNewId/createNewId.js +14 -11
- package/dist/src/core/database/createDatabaseRoutes/helpers/array/findIndexById/findIndexById.js +8 -5
- package/dist/src/core/database/createDatabaseRoutes/helpers/array/index.js +17 -35
- package/dist/src/core/database/createDatabaseRoutes/helpers/array/isIndex/isIndex.js +8 -5
- package/dist/src/core/database/createDatabaseRoutes/helpers/createNestedDatabaseRoutes/createNestedDatabaseRoutes.js +157 -143
- package/dist/src/core/database/createDatabaseRoutes/helpers/createRewrittenDatabaseRoutes/createRewrittenDatabaseRoutes.js +15 -8
- package/dist/src/core/database/createDatabaseRoutes/helpers/createShallowDatabaseRoutes/createShallowDatabaseRoutes.js +88 -94
- package/dist/src/core/database/createDatabaseRoutes/helpers/filter/filter.js +44 -47
- package/dist/src/core/database/createDatabaseRoutes/helpers/index.js +19 -57
- package/dist/src/core/database/createDatabaseRoutes/helpers/pagination/pagination.js +32 -31
- package/dist/src/core/database/createDatabaseRoutes/helpers/search/search.js +34 -24
- package/dist/src/core/database/createDatabaseRoutes/helpers/sort/sort.js +38 -34
- package/dist/src/core/database/createDatabaseRoutes/helpers/splitDatabaseByNesting/splitDatabaseByNesting.js +26 -25
- package/dist/src/core/database/createDatabaseRoutes/storages/File/FileStorage.js +65 -50
- package/dist/src/core/database/createDatabaseRoutes/storages/File/FileWriter.js +55 -48
- package/dist/src/core/database/createDatabaseRoutes/storages/Memory/MemoryStorage.js +51 -41
- package/dist/src/core/database/createDatabaseRoutes/storages/index.js +16 -24
- package/dist/src/core/database/index.js +15 -13
- package/dist/src/core/graphql/createGraphQLRoutes/createGraphQLRoutes.js +126 -140
- package/dist/src/core/graphql/createGraphQLRoutes/helpers/index.js +15 -13
- package/dist/src/core/graphql/createGraphQLRoutes/helpers/prepareGraphQLRequestConfigs/prepareGraphQLRequestConfigs.js +36 -41
- package/dist/src/core/graphql/index.js +15 -13
- package/dist/src/core/middlewares/cookieParseMiddleware/cookieParseMiddleware.js +16 -13
- package/dist/src/core/middlewares/cookieParseMiddleware/helpers/index.js +15 -13
- package/dist/src/core/middlewares/cookieParseMiddleware/helpers/parseCookie/parseCookie.js +18 -15
- package/dist/src/core/middlewares/corsMiddleware/corsMiddleware.js +50 -47
- package/dist/src/core/middlewares/corsMiddleware/helpers/getAllowedOrigins/getAllowedOrigins.js +17 -12
- package/dist/src/core/middlewares/corsMiddleware/helpers/index.js +15 -13
- package/dist/src/core/middlewares/destroyerMiddleware/destroyerMiddleware.js +23 -20
- package/dist/src/core/middlewares/errorMiddleware/errorMiddleware.js +23 -17
- package/dist/src/core/middlewares/index.js +23 -91
- package/dist/src/core/middlewares/noCorsMiddleware/noCorsMiddleware.js +22 -19
- package/dist/src/core/middlewares/notFoundMiddleware/helpers/getGraphqlUrlSuggestions/getGraphqlUrlSuggestions.js +21 -23
- package/dist/src/core/middlewares/notFoundMiddleware/helpers/getLevenshteinDistance/getLevenshteinDistance.js +80 -80
- package/dist/src/core/middlewares/notFoundMiddleware/helpers/getRestUrlSuggestions/getRestUrlSuggestions.js +34 -34
- package/dist/src/core/middlewares/notFoundMiddleware/helpers/getRestUrlSuggestions/helpers/getActualRestUrlMeaningfulString/getActualRestUrlMeaningfulString.js +8 -5
- package/dist/src/core/middlewares/notFoundMiddleware/helpers/getRestUrlSuggestions/helpers/getPatternRestUrlMeaningfulString/getPatternRestUrlMeaningfulString.js +8 -5
- package/dist/src/core/middlewares/notFoundMiddleware/helpers/getRestUrlSuggestions/helpers/index.js +16 -24
- package/dist/src/core/middlewares/notFoundMiddleware/helpers/index.js +17 -35
- package/dist/src/core/middlewares/notFoundMiddleware/notFoundMiddleware.js +58 -60
- package/dist/src/core/middlewares/requestInterceptorMiddleware/requestInterceptorMiddleware.js +16 -17
- package/dist/src/core/middlewares/staticMiddleware/staticMiddleware.js +32 -25
- package/dist/src/core/rest/createRestRoutes/createRestRoutes.js +120 -130
- package/dist/src/core/rest/createRestRoutes/helpers/index.js +15 -13
- package/dist/src/core/rest/createRestRoutes/helpers/prepareRestRequestConfigs/prepareRestRequestConfigs.js +37 -43
- package/dist/src/core/rest/index.js +15 -13
- package/dist/src/index.js +16 -24
- package/dist/src/server/createDatabaseMockServer/createDatabaseMockServer.js +56 -53
- package/dist/src/server/createGraphQLMockServer/createGraphQLMockServer.js +64 -62
- package/dist/src/server/createMockServer/createMockServer.js +94 -91
- package/dist/src/server/createRestMockServer/createRestMockServer.js +64 -62
- package/dist/src/server/index.js +23 -91
- package/dist/src/server/startDatabaseMockServer/startDatabaseMockServer.js +25 -19
- package/dist/src/server/startGraphQLMockServer/startGraphQLMockServer.js +25 -19
- package/dist/src/server/startMockServer/startMockServer.js +25 -19
- package/dist/src/server/startRestMockServer/startRestMockServer.js +25 -19
- package/dist/src/utils/constants/appPath.js +8 -4
- package/dist/src/utils/constants/checkModes.js +74 -11
- package/dist/src/utils/constants/default.js +18 -14
- package/dist/src/utils/constants/index.js +17 -35
- package/dist/src/utils/helpers/asyncHandler.js +8 -5
- package/dist/src/utils/helpers/config/index.js +15 -13
- package/dist/src/utils/helpers/config/resolveEntityValues/resolveEntityValues.js +103 -110
- package/dist/src/utils/helpers/entities/convertToEntityDescriptor/convertToEntityDescriptor.js +12 -9
- package/dist/src/utils/helpers/entities/index.js +16 -24
- package/dist/src/utils/helpers/entities/isEntityDescriptor/isEntityDescriptor.js +9 -6
- package/dist/src/utils/helpers/files/index.js +15 -13
- package/dist/src/utils/helpers/files/isFilePathValid/isFilePathValid.js +22 -15
- package/dist/src/utils/helpers/graphql/getGraphQLInput/getGraphQLInput.js +25 -29
- package/dist/src/utils/helpers/graphql/index.js +17 -35
- package/dist/src/utils/helpers/graphql/parseGraphQLRequest/parseGraphQLRequest.js +13 -10
- package/dist/src/utils/helpers/graphql/parseQuery/parseQuery.js +23 -19
- package/dist/src/utils/helpers/index.js +26 -124
- package/dist/src/utils/helpers/interceptors/callRequestInterceptor/callRequestInterceptor.js +21 -21
- package/dist/src/utils/helpers/interceptors/callResponseInterceptors/callResponseInterceptors.js +62 -64
- package/dist/src/utils/helpers/interceptors/helpers/setDelay.js +10 -7
- package/dist/src/utils/helpers/interceptors/index.js +16 -24
- package/dist/src/utils/helpers/isPlainObject/isPlainObject.js +8 -5
- package/dist/src/utils/helpers/isPrimitive/isPrimitive.js +8 -5
- package/dist/src/utils/helpers/isRegExp/isRegExp.js +8 -5
- package/dist/src/utils/helpers/sleep.js +9 -6
- package/dist/src/utils/helpers/tests/createTmpDir.js +16 -9
- package/dist/src/utils/helpers/tests/index.js +15 -13
- package/dist/src/utils/helpers/url/convertWin32PathToUnix/convertWin32PathToUnix.js +8 -5
- package/dist/src/utils/helpers/url/getUrlParts/getUrlParts.js +9 -6
- package/dist/src/utils/helpers/url/index.js +18 -46
- package/dist/src/utils/helpers/url/removeLeadingAndTrailingSlashes/removeLeadingAndTrailingSlashes.js +8 -5
- package/dist/src/utils/helpers/url/urlJoin/urlJoin.js +18 -11
- package/dist/src/utils/types/checkModes.js +4 -1
- package/dist/src/utils/types/database.js +4 -1
- package/dist/src/utils/types/entities.js +4 -1
- package/dist/src/utils/types/graphql.js +4 -1
- package/dist/src/utils/types/index.js +24 -102
- package/dist/src/utils/types/interceptors.js +4 -1
- package/dist/src/utils/types/rest.js +4 -1
- package/dist/src/utils/types/server.js +4 -1
- package/dist/src/utils/types/utils.js +4 -1
- package/dist/src/utils/types/values.js +4 -1
- package/package.json +8 -9
- package/dist/bin/templates/.eslintrc.js +0 -14
- package/dist/bin/templates/tsconfig.json +0 -11
|
@@ -1,118 +1,111 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
|
|
3
|
+
value: true
|
|
5
4
|
});
|
|
6
|
-
exports
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
// ✅
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
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;
|
package/dist/src/utils/helpers/entities/convertToEntityDescriptor/convertToEntityDescriptor.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
|
|
3
|
+
value: true
|
|
5
4
|
});
|
|
6
|
-
exports
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
};
|
|
12
|
-
|
|
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
|
-
|
|
3
|
+
value: true
|
|
5
4
|
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
-
|
|
3
|
+
value: true
|
|
5
4
|
});
|
|
6
|
-
exports
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
|
|
3
|
+
value: true
|
|
5
4
|
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
|
|
3
|
+
value: true
|
|
5
4
|
});
|
|
6
|
-
exports
|
|
7
|
-
|
|
8
|
-
function
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
-
|
|
3
|
+
value: true
|
|
5
4
|
});
|
|
6
|
-
exports
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
-
|
|
3
|
+
value: true
|
|
5
4
|
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
-
|
|
3
|
+
value: true
|
|
5
4
|
});
|
|
6
|
-
exports
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
-
|
|
3
|
+
value: true
|
|
5
4
|
});
|
|
6
|
-
exports
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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;
|