mock-config-server 3.7.1 → 4.0.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.
- package/README.md +272 -224
- package/dist/bin/bin.js +1 -1
- package/dist/bin/build.d.ts +3 -1
- package/dist/bin/build.js +10 -0
- package/dist/bin/helpers/createTemplate.d.ts +3 -3
- package/dist/bin/helpers/createTemplate.js +1 -1
- package/dist/bin/helpers/index.d.ts +0 -3
- package/dist/bin/helpers/index.js +0 -3
- package/dist/bin/helpers/resolveConfigFile.d.ts +2 -2
- package/dist/bin/helpers/resolveConfigFile.js +2 -2
- package/dist/bin/helpers/resolveConfigFilePath.js +4 -4
- package/dist/bin/helpers/resolveExportsFromSourceCode.js +1 -2
- package/dist/bin/init.js +5 -8
- package/dist/bin/run.d.ts +1 -2
- package/dist/bin/run.js +1 -6
- package/dist/bin/runFlatConfig.d.ts +5 -0
- package/dist/bin/runFlatConfig.js +36 -0
- package/dist/bin/templates/js/full/mock-server.config.js +10 -7
- package/dist/bin/templates/js/graphql/mock-server.config.js +11 -6
- package/dist/bin/templates/js/rest/mock-server.config.js +11 -6
- package/dist/bin/templates/ts/full/mock-server.config.ts +11 -8
- package/dist/bin/templates/ts/graphql/mock-server.config.ts +12 -7
- package/dist/bin/templates/ts/rest/mock-server.config.ts +12 -7
- package/dist/src/core/database/createDatabaseRoutes/createDatabaseRoutes.js +2 -1
- package/dist/src/core/database/createDatabaseRoutes/helpers/createNestedDatabaseRoutes/createNestedDatabaseRoutes.js +8 -12
- package/dist/src/core/database/createDatabaseRoutes/helpers/filter/filter.d.ts +0 -1
- package/dist/src/core/database/createDatabaseRoutes/helpers/pagination/pagination.d.ts +0 -1
- package/dist/src/core/database/createDatabaseRoutes/helpers/search/search.d.ts +0 -1
- package/dist/src/core/database/createDatabaseRoutes/helpers/sort/sort.d.ts +0 -1
- package/dist/src/core/database/createDatabaseRoutes/helpers/splitDatabaseByNesting/splitDatabaseByNesting.d.ts +1 -1
- package/dist/src/core/database/createDatabaseRoutes/storages/File/FileStorage.d.ts +5 -6
- package/dist/src/core/database/createDatabaseRoutes/storages/File/FileStorage.js +4 -4
- package/dist/src/core/database/createDatabaseRoutes/storages/File/FileWriter.js +2 -2
- package/dist/src/core/database/createDatabaseRoutes/storages/Memory/MemoryStorage.d.ts +6 -7
- package/dist/src/core/database/createOrm/createOrm.d.ts +2 -0
- package/dist/src/core/database/createOrm/createOrm.js +119 -0
- package/dist/src/core/database/createStorage/createStorage.d.ts +2 -0
- package/dist/src/core/database/createStorage/createStorage.js +13 -0
- package/dist/src/core/database/index.d.ts +2 -0
- package/dist/src/core/database/index.js +2 -0
- package/dist/src/core/graphql/createGraphQLRoutes/createGraphQLRoutes.d.ts +1 -1
- package/dist/src/core/graphql/createGraphQLRoutes/createGraphQLRoutes.js +39 -17
- package/dist/src/core/graphql/createGraphQLRoutes/helpers/prepareGraphQLRequestConfigs/prepareGraphQLRequestConfigs.js +2 -2
- package/dist/src/core/middlewares/contextMiddleware/contextMiddleware.d.ts +2 -2
- package/dist/src/core/middlewares/contextMiddleware/contextMiddleware.js +11 -1
- package/dist/src/core/middlewares/destroyerMiddleware/destroyerMiddleware.d.ts +1 -2
- package/dist/src/core/middlewares/index.d.ts +0 -1
- package/dist/src/core/middlewares/index.js +0 -1
- package/dist/src/core/middlewares/requestInterceptorMiddleware/requestInterceptorMiddleware.d.ts +2 -2
- package/dist/src/core/rest/createRestRoutes/createRestRoutes.d.ts +1 -1
- package/dist/src/core/rest/createRestRoutes/createRestRoutes.js +80 -24
- package/dist/src/server/createDatabaseMockServer/createDatabaseMockServer.d.ts +1 -1
- package/dist/src/server/createDatabaseMockServer/createDatabaseMockServer.js +6 -6
- package/dist/src/server/createFlatMockServer/createFlatMockServer.d.ts +3 -0
- package/dist/src/server/createFlatMockServer/createFlatMockServer.js +127 -0
- package/dist/src/server/createGraphQLMockServer/createGraphQLMockServer.d.ts +1 -1
- package/dist/src/server/createGraphQLMockServer/createGraphQLMockServer.js +3 -6
- package/dist/src/server/createMockServer/createMockServer.d.ts +1 -1
- package/dist/src/server/createMockServer/createMockServer.js +3 -5
- package/dist/src/server/createRestMockServer/createRestMockServer.d.ts +1 -1
- package/dist/src/server/createRestMockServer/createRestMockServer.js +3 -6
- package/dist/src/server/index.d.ts +2 -0
- package/dist/src/server/index.js +2 -0
- package/dist/src/server/startDatabaseMockServer/startDatabaseMockServer.d.ts +1 -2
- package/dist/src/server/startFlatMockServer/startFlatMockServer.d.ts +4 -0
- package/dist/src/server/startFlatMockServer/startFlatMockServer.js +28 -0
- package/dist/src/server/startGraphQLMockServer/startGraphQLMockServer.d.ts +1 -2
- package/dist/src/server/startMockServer/startMockServer.d.ts +1 -2
- package/dist/src/server/startRestMockServer/startRestMockServer.d.ts +1 -2
- package/dist/src/utils/constants/checkModes.d.ts +1 -3
- package/dist/src/utils/constants/checkModes.js +3 -19
- package/dist/src/utils/helpers/config/resolveEntityValues/resolveEntityValues.d.ts +20 -2
- package/dist/src/utils/helpers/config/resolveEntityValues/resolveEntityValues.js +37 -71
- package/dist/src/utils/helpers/files/index.d.ts +1 -0
- package/dist/src/utils/helpers/files/index.js +1 -0
- package/dist/src/utils/helpers/files/isFileDescriptor/isFileDescriptor.d.ts +2 -0
- package/dist/src/utils/helpers/files/isFileDescriptor/isFileDescriptor.js +16 -0
- package/dist/src/utils/helpers/files/isFilePathValid/isFilePathValid.js +3 -3
- package/dist/src/utils/helpers/graphql/getGraphQLInput/getGraphQLInput.js +6 -2
- package/dist/src/utils/helpers/graphql/parseQuery/parseQuery.d.ts +1 -1
- package/dist/src/utils/helpers/index.d.ts +0 -1
- package/dist/src/utils/helpers/index.js +0 -1
- package/dist/src/utils/helpers/interceptors/callRequestInterceptor/callRequestInterceptor.d.ts +1 -1
- package/dist/src/utils/helpers/interceptors/callRequestInterceptor/callRequestInterceptor.js +2 -1
- package/dist/src/utils/helpers/interceptors/callResponseInterceptors/callResponseInterceptors.js +10 -5
- package/dist/src/utils/helpers/logger/callResponseLogger/callResponseLogger.d.ts +1 -1
- package/dist/src/utils/helpers/tests/createTmpDir.js +4 -4
- package/dist/src/utils/helpers/url/convertWin32PathToUnix/convertWin32PathToUnix.js +1 -1
- package/dist/src/utils/helpers/url/urlJoin/urlJoin.js +4 -4
- package/dist/src/utils/types/checkModes.d.ts +14 -7
- package/dist/src/utils/types/database.d.ts +30 -0
- package/dist/src/utils/types/entities.d.ts +13 -43
- package/dist/src/utils/types/files.d.ts +5 -0
- package/dist/src/utils/types/files.js +4 -0
- package/dist/src/utils/types/graphql.d.ts +9 -8
- package/dist/src/utils/types/index.d.ts +1 -0
- package/dist/src/utils/types/index.js +1 -0
- package/dist/src/utils/types/interceptors.d.ts +21 -16
- package/dist/src/utils/types/logger.d.ts +11 -11
- package/dist/src/utils/types/rest.d.ts +17 -12
- package/dist/src/utils/types/server.d.ts +48 -20
- package/dist/src/utils/types/shared.d.ts +1 -1
- package/dist/src/utils/types/utils.d.ts +4 -4
- package/dist/src/utils/types/values.d.ts +3 -4
- package/dist/{bin/validateMockServerConfig → src/utils/validate}/corsSchema/corsSchema.d.ts +2 -2
- package/dist/{bin/helpers → src/utils/validate}/getMostSpecificPathFromError.d.ts +1 -1
- package/dist/src/utils/validate/getValidationMessageFromPath.d.ts +1 -0
- package/dist/src/utils/validate/graphqlConfigSchema/graphqlConfigSchema.d.ts +535 -0
- package/dist/{bin/validateMockServerConfig → src/utils/validate}/graphqlConfigSchema/graphqlConfigSchema.js +14 -6
- package/dist/{bin/validateMockServerConfig → src/utils/validate}/graphqlConfigSchema/routeConfigSchema/routeConfigSchema.d.ts +20 -5
- package/dist/{bin/validateMockServerConfig → src/utils/validate}/graphqlConfigSchema/routeConfigSchema/routeConfigSchema.js +5 -5
- package/dist/src/utils/validate/index.d.ts +14 -0
- package/dist/src/utils/validate/index.js +31 -0
- package/dist/{bin/helpers → src/utils/validate}/isOnlyRequestedDataResolvingPropertyExists.d.ts +1 -1
- package/dist/src/utils/validate/queueSchema/queueSchema.d.ts +20 -0
- package/dist/src/utils/validate/queueSchema/queueSchema.js +24 -0
- package/dist/src/utils/validate/restConfigSchema/restConfigSchema.d.ts +1659 -0
- package/dist/{bin/validateMockServerConfig → src/utils/validate}/restConfigSchema/restConfigSchema.js +13 -5
- package/dist/{bin/validateMockServerConfig → src/utils/validate}/restConfigSchema/routeConfigSchema/routeConfigSchema.d.ts +21 -6
- package/dist/{bin/validateMockServerConfig → src/utils/validate}/restConfigSchema/routeConfigSchema/routeConfigSchema.js +6 -6
- package/dist/src/utils/validate/utils/checkModeSchema/checkModeSchema.d.ts +23 -0
- package/dist/{bin/validateMockServerConfig → src/utils/validate}/utils/checkModeSchema/checkModeSchema.js +24 -1
- package/dist/src/utils/validate/utils/entitiesSchema/entitiesSchema.d.ts +4 -0
- package/dist/src/utils/validate/utils/entitiesSchema/entitiesSchema.js +94 -0
- package/dist/src/utils/validate/utils/extendedDiscriminatedUnion/extendedDiscriminatedUnion.d.ts +8 -0
- package/dist/src/utils/validate/utils/extendedDiscriminatedUnion/extendedDiscriminatedUnion.js +46 -0
- package/dist/{bin/validateMockServerConfig → src/utils/validate}/utils/index.d.ts +2 -2
- package/dist/{bin/validateMockServerConfig → src/utils/validate}/utils/index.js +2 -2
- package/dist/{bin/validateMockServerConfig → src/utils/validate}/utils/jsonSchema/jsonSchema.d.ts +2 -2
- package/dist/{bin/validateMockServerConfig → src/utils/validate}/utils/jsonSchema/jsonSchema.js +1 -1
- package/dist/src/utils/validate/utils/nestedObjectOrArraySchema/nestedObjectOrArraySchema.d.ts +3 -0
- package/dist/src/utils/validate/utils/nestedObjectOrArraySchema/nestedObjectOrArraySchema.js +22 -0
- package/dist/{bin/validateMockServerConfig → src/utils/validate}/utils/requiredPropertiesSchema/requiredPropertiesSchema.d.ts +1 -1
- package/dist/{bin/validateMockServerConfig → src/utils/validate}/utils/requiredPropertiesSchema/requiredPropertiesSchema.js +1 -1
- package/dist/src/utils/validate/validateApiMockServerConfig.d.ts +2 -0
- package/dist/{bin/validateMockServerConfig → src/utils/validate}/validateApiMockServerConfig.js +4 -3
- package/dist/src/utils/validate/validateFlatMockServerConfig.d.ts +2 -0
- package/dist/src/utils/validate/validateFlatMockServerConfig.js +53 -0
- package/dist/{bin/validateMockServerConfig → src/utils/validate}/validateMockServerConfig.d.ts +1 -1
- package/dist/{bin/validateMockServerConfig → src/utils/validate}/validateMockServerConfig.js +4 -3
- package/package.json +51 -52
- package/dist/bin/helpers/getValidationMessageFromPath.d.ts +0 -1
- package/dist/bin/validateMockServerConfig/graphqlConfigSchema/graphqlConfigSchema.d.ts +0 -258
- package/dist/bin/validateMockServerConfig/queueSchema/queueSchema.d.ts +0 -8
- package/dist/bin/validateMockServerConfig/queueSchema/queueSchema.js +0 -21
- package/dist/bin/validateMockServerConfig/restConfigSchema/restConfigSchema.d.ts +0 -743
- package/dist/bin/validateMockServerConfig/utils/checkModeSchema/checkModeSchema.d.ts +0 -5
- package/dist/bin/validateMockServerConfig/utils/entitiesSchema/entitiesSchema.d.ts +0 -71
- package/dist/bin/validateMockServerConfig/utils/entitiesSchema/entitiesSchema.js +0 -124
- package/dist/bin/validateMockServerConfig/validateApiMockServerConfig.d.ts +0 -2
- package/dist/src/core/middlewares/notFoundMiddleware/helpers/getGraphqlUrlSuggestions/getGraphqlUrlSuggestions.d.ts +0 -11
- package/dist/src/core/middlewares/notFoundMiddleware/helpers/getGraphqlUrlSuggestions/getGraphqlUrlSuggestions.js +0 -25
- package/dist/src/core/middlewares/notFoundMiddleware/helpers/getLevenshteinDistance/getLevenshteinDistance.d.ts +0 -1
- package/dist/src/core/middlewares/notFoundMiddleware/helpers/getLevenshteinDistance/getLevenshteinDistance.js +0 -85
- package/dist/src/core/middlewares/notFoundMiddleware/helpers/getRestUrlSuggestions/getRestUrlSuggestions.d.ts +0 -11
- package/dist/src/core/middlewares/notFoundMiddleware/helpers/getRestUrlSuggestions/getRestUrlSuggestions.js +0 -39
- package/dist/src/core/middlewares/notFoundMiddleware/helpers/getRestUrlSuggestions/helpers/getActualRestUrlMeaningfulString/getActualRestUrlMeaningfulString.d.ts +0 -1
- package/dist/src/core/middlewares/notFoundMiddleware/helpers/getRestUrlSuggestions/helpers/getActualRestUrlMeaningfulString/getActualRestUrlMeaningfulString.js +0 -11
- package/dist/src/core/middlewares/notFoundMiddleware/helpers/getRestUrlSuggestions/helpers/getPatternRestUrlMeaningfulString/getPatternRestUrlMeaningfulString.d.ts +0 -1
- package/dist/src/core/middlewares/notFoundMiddleware/helpers/getRestUrlSuggestions/helpers/getPatternRestUrlMeaningfulString/getPatternRestUrlMeaningfulString.js +0 -11
- package/dist/src/core/middlewares/notFoundMiddleware/helpers/getRestUrlSuggestions/helpers/index.d.ts +0 -2
- package/dist/src/core/middlewares/notFoundMiddleware/helpers/getRestUrlSuggestions/helpers/index.js +0 -19
- package/dist/src/core/middlewares/notFoundMiddleware/helpers/index.d.ts +0 -3
- package/dist/src/core/middlewares/notFoundMiddleware/helpers/index.js +0 -20
- package/dist/src/core/middlewares/notFoundMiddleware/notFoundMiddleware.d.ts +0 -3
- package/dist/src/core/middlewares/notFoundMiddleware/notFoundMiddleware.js +0 -65
- package/dist/src/static/views/assets/icons/scheme-dark.svg +0 -3
- package/dist/src/static/views/assets/icons/scheme-light.svg +0 -3
- package/dist/src/static/views/assets/images/404.png +0 -0
- package/dist/src/static/views/assets/images/logo.png +0 -0
- package/dist/src/static/views/assets/styles/global.css +0 -88
- package/dist/src/static/views/components/header/index.css +0 -55
- package/dist/src/static/views/components/header/index.ejs +0 -40
- package/dist/src/static/views/components/header/index.js +0 -1
- package/dist/src/static/views/features/scheme/dark.css +0 -13
- package/dist/src/static/views/features/scheme/index.ejs +0 -3
- package/dist/src/static/views/features/scheme/index.js +0 -31
- package/dist/src/static/views/features/scheme/light.css +0 -13
- package/dist/src/static/views/features/tab/index.css +0 -30
- package/dist/src/static/views/features/tab/index.ejs +0 -2
- package/dist/src/static/views/features/tab/index.js +0 -12
- package/dist/src/static/views/pages/404/index.css +0 -10
- package/dist/src/static/views/pages/404/index.ejs +0 -82
- package/dist/src/utils/helpers/isRegExp/isRegExp.d.ts +0 -1
- package/dist/src/utils/helpers/isRegExp/isRegExp.js +0 -11
- package/dist/{bin/validateMockServerConfig → src/utils/validate}/baseUrlSchema/baseUrlSchema.d.ts +0 -0
- package/dist/{bin/validateMockServerConfig → src/utils/validate}/baseUrlSchema/baseUrlSchema.js +0 -0
- package/dist/{bin/validateMockServerConfig → src/utils/validate}/corsSchema/corsSchema.js +0 -0
- package/dist/{bin/validateMockServerConfig → src/utils/validate}/databaseConfigSchema/databaseConfigSchema.d.ts +0 -0
- package/dist/{bin/validateMockServerConfig → src/utils/validate}/databaseConfigSchema/databaseConfigSchema.js +0 -0
- package/dist/{bin/helpers → src/utils/validate}/getMostSpecificPathFromError.js +0 -0
- package/dist/{bin/helpers → src/utils/validate}/getValidationMessageFromPath.js +0 -0
- package/dist/{bin/validateMockServerConfig → src/utils/validate}/interceptorsSchema/interceptorsSchema.d.ts +0 -0
- package/dist/{bin/validateMockServerConfig → src/utils/validate}/interceptorsSchema/interceptorsSchema.js +0 -0
- package/dist/{bin/helpers → src/utils/validate}/isOnlyRequestedDataResolvingPropertyExists.js +0 -0
- package/dist/{bin/validateMockServerConfig → src/utils/validate}/portSchema/portSchema.d.ts +0 -0
- package/dist/{bin/validateMockServerConfig → src/utils/validate}/portSchema/portSchema.js +0 -0
- package/dist/{bin/validateMockServerConfig → src/utils/validate}/settingsSchema/settingsSchema.d.ts +2 -2
- /package/dist/{bin/validateMockServerConfig → src/utils/validate}/settingsSchema/settingsSchema.js +0 -0
- /package/dist/{bin/validateMockServerConfig → src/utils/validate}/staticPathSchema/staticPathSchema.d.ts +0 -0
- /package/dist/{bin/validateMockServerConfig → src/utils/validate}/staticPathSchema/staticPathSchema.js +0 -0
- /package/dist/{bin/validateMockServerConfig → src/utils/validate}/utils/plainObjectSchema/plainObjectSchema.d.ts +0 -0
- /package/dist/{bin/validateMockServerConfig → src/utils/validate}/utils/plainObjectSchema/plainObjectSchema.js +0 -0
- /package/dist/{bin/validateMockServerConfig → src/utils/validate}/utils/sharedSchema/sharedSchema.d.ts +0 -0
- /package/dist/{bin/validateMockServerConfig → src/utils/validate}/utils/sharedSchema/sharedSchema.js +0 -0
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
export declare const checkActualValueCheckModeSchema: z.ZodEnum<["exists", "notExists"]>;
|
|
3
|
-
export declare const compareWithDescriptorAnyValueCheckModeSchema: z.ZodEnum<["equals", "notEquals"]>;
|
|
4
|
-
export declare const compareWithDescriptorStringValueCheckModeSchema: z.ZodEnum<["includes", "notIncludes", "startsWith", "notStartsWith", "endsWith", "notEndsWith"]>;
|
|
5
|
-
export declare const compareWithDescriptorValueCheckModeSchema: z.ZodEnum<["equals", "notEquals", "includes", "notIncludes", "startsWith", "notStartsWith", "endsWith", "notEndsWith"]>;
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
export declare const plainEntitySchema: z.ZodUnion<[z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodType<{
|
|
3
|
-
checkMode: "function";
|
|
4
|
-
value: (...args: unknown[]) => unknown;
|
|
5
|
-
} | {
|
|
6
|
-
checkMode: "equals" | "notEquals";
|
|
7
|
-
value: string | number | boolean | {
|
|
8
|
-
[key: string]: string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | any | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null;
|
|
9
|
-
} | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | any | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null;
|
|
10
|
-
} | {
|
|
11
|
-
checkMode: "exists" | "notExists";
|
|
12
|
-
}, z.ZodTypeDef, {
|
|
13
|
-
checkMode: "function";
|
|
14
|
-
value: (...args: unknown[]) => unknown;
|
|
15
|
-
} | {
|
|
16
|
-
checkMode: "equals" | "notEquals";
|
|
17
|
-
value: string | number | boolean | {
|
|
18
|
-
[key: string]: string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | any | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null;
|
|
19
|
-
} | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | any | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null;
|
|
20
|
-
} | {
|
|
21
|
-
checkMode: "exists" | "notExists";
|
|
22
|
-
}>>, z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>, z.ZodArray<z.ZodIntersection<z.ZodType<string | number | boolean | {
|
|
23
|
-
[key: string]: string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | any | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null;
|
|
24
|
-
} | (string | number | boolean | {
|
|
25
|
-
[key: string]: string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | any | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null;
|
|
26
|
-
} | (string | number | boolean | {
|
|
27
|
-
[key: string]: string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | any | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null;
|
|
28
|
-
} | (string | number | boolean | {
|
|
29
|
-
[key: string]: string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | any | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null;
|
|
30
|
-
} | (string | number | boolean | {
|
|
31
|
-
[key: string]: string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | any | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null;
|
|
32
|
-
} | (string | number | boolean | {
|
|
33
|
-
[key: string]: string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | any | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null;
|
|
34
|
-
} | (string | number | boolean | {
|
|
35
|
-
[key: string]: string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | any | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null;
|
|
36
|
-
} | (string | number | boolean | {
|
|
37
|
-
[key: string]: string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | any | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null;
|
|
38
|
-
} | (string | number | boolean | {
|
|
39
|
-
[key: string]: string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | any | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null;
|
|
40
|
-
} | (string | number | boolean | {
|
|
41
|
-
[key: string]: string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | any | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null;
|
|
42
|
-
} | (string | number | boolean | {
|
|
43
|
-
[key: string]: string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | any | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null;
|
|
44
|
-
} | (string | number | boolean | {
|
|
45
|
-
[key: string]: string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | any | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null;
|
|
46
|
-
} | any | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null, z.ZodTypeDef, string | number | boolean | {
|
|
47
|
-
[key: string]: string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | any | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null;
|
|
48
|
-
} | (string | number | boolean | {
|
|
49
|
-
[key: string]: string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | any | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null;
|
|
50
|
-
} | (string | number | boolean | {
|
|
51
|
-
[key: string]: string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | any | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null;
|
|
52
|
-
} | (string | number | boolean | {
|
|
53
|
-
[key: string]: string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | any | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null;
|
|
54
|
-
} | (string | number | boolean | {
|
|
55
|
-
[key: string]: string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | any | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null;
|
|
56
|
-
} | (string | number | boolean | {
|
|
57
|
-
[key: string]: string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | any | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null;
|
|
58
|
-
} | (string | number | boolean | {
|
|
59
|
-
[key: string]: string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | any | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null;
|
|
60
|
-
} | (string | number | boolean | {
|
|
61
|
-
[key: string]: string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | any | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null;
|
|
62
|
-
} | (string | number | boolean | {
|
|
63
|
-
[key: string]: string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | any | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null;
|
|
64
|
-
} | (string | number | boolean | {
|
|
65
|
-
[key: string]: string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | any | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null;
|
|
66
|
-
} | (string | number | boolean | {
|
|
67
|
-
[key: string]: string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | any | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null;
|
|
68
|
-
} | (string | number | boolean | {
|
|
69
|
-
[key: string]: string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | (string | number | boolean | any | any | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null;
|
|
70
|
-
} | any | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null)[] | null>, z.ZodType<unknown, z.ZodTypeDef, unknown>>, "many">]>;
|
|
71
|
-
export declare const mappedEntitySchema: z.ZodPipeline<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeAny>;
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
function _export(target, all) {
|
|
6
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: all[name]
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
_export(exports, {
|
|
12
|
-
mappedEntitySchema: function() {
|
|
13
|
-
return mappedEntitySchema;
|
|
14
|
-
},
|
|
15
|
-
plainEntitySchema: function() {
|
|
16
|
-
return plainEntitySchema;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
const _zod = require("zod");
|
|
20
|
-
const _checkModeSchema = require("../checkModeSchema/checkModeSchema");
|
|
21
|
-
const _jsonSchema = require("../jsonSchema/jsonSchema");
|
|
22
|
-
const _plainObjectSchema = require("../plainObjectSchema/plainObjectSchema");
|
|
23
|
-
const _requiredPropertiesSchema = require("../requiredPropertiesSchema/requiredPropertiesSchema");
|
|
24
|
-
/* ----- Plain entity schema ----- */ const topLevelPlainEntityDescriptorSchema = (0, _requiredPropertiesSchema.requiredPropertiesSchema)(_zod.z.discriminatedUnion('checkMode', [
|
|
25
|
-
_zod.z.strictObject({
|
|
26
|
-
checkMode: _zod.z.literal('function'),
|
|
27
|
-
value: _zod.z.function()
|
|
28
|
-
}),
|
|
29
|
-
_zod.z.strictObject({
|
|
30
|
-
checkMode: _checkModeSchema.compareWithDescriptorAnyValueCheckModeSchema,
|
|
31
|
-
value: _jsonSchema.jsonSchema
|
|
32
|
-
}),
|
|
33
|
-
_zod.z.strictObject({
|
|
34
|
-
checkMode: _checkModeSchema.checkActualValueCheckModeSchema
|
|
35
|
-
})
|
|
36
|
-
]), [
|
|
37
|
-
'checkMode'
|
|
38
|
-
]);
|
|
39
|
-
const propertyLevelPlainEntityDescriptorSchema = (0, _requiredPropertiesSchema.requiredPropertiesSchema)(_zod.z.discriminatedUnion('checkMode', [
|
|
40
|
-
_zod.z.strictObject({
|
|
41
|
-
checkMode: _zod.z.literal('function'),
|
|
42
|
-
value: _zod.z.function()
|
|
43
|
-
}),
|
|
44
|
-
_zod.z.strictObject({
|
|
45
|
-
checkMode: _checkModeSchema.compareWithDescriptorAnyValueCheckModeSchema,
|
|
46
|
-
value: _jsonSchema.jsonSchema
|
|
47
|
-
}),
|
|
48
|
-
_zod.z.strictObject({
|
|
49
|
-
checkMode: _zod.z.literal('regExp'),
|
|
50
|
-
value: _zod.z.union([
|
|
51
|
-
_zod.z.instanceof(RegExp),
|
|
52
|
-
_zod.z.array(_zod.z.instanceof(RegExp))
|
|
53
|
-
])
|
|
54
|
-
}),
|
|
55
|
-
_zod.z.strictObject({
|
|
56
|
-
checkMode: _checkModeSchema.compareWithDescriptorStringValueCheckModeSchema,
|
|
57
|
-
value: _zod.z.union([
|
|
58
|
-
_jsonSchema.jsonLiteralSchema,
|
|
59
|
-
_zod.z.array(_jsonSchema.jsonLiteralSchema)
|
|
60
|
-
])
|
|
61
|
-
}),
|
|
62
|
-
_zod.z.strictObject({
|
|
63
|
-
checkMode: _checkModeSchema.checkActualValueCheckModeSchema
|
|
64
|
-
})
|
|
65
|
-
]), [
|
|
66
|
-
'checkMode'
|
|
67
|
-
]);
|
|
68
|
-
const nonCheckModeRecordSchema = (recordSchema)=>(0, _plainObjectSchema.plainObjectSchema)(recordSchema.and(_zod.z.object({
|
|
69
|
-
checkMode: _zod.z.never().optional()
|
|
70
|
-
})));
|
|
71
|
-
// ✅ important:
|
|
72
|
-
// 1st property level record disallow checkMode
|
|
73
|
-
const topLevelRecordValueSchema = _zod.z.union([
|
|
74
|
-
_jsonSchema.jsonLiteralSchema,
|
|
75
|
-
_zod.z.array(_jsonSchema.jsonSchema),
|
|
76
|
-
nonCheckModeRecordSchema(_zod.z.record(_jsonSchema.jsonSchema))
|
|
77
|
-
]);
|
|
78
|
-
// ✅ important:
|
|
79
|
-
// top level record disallow checkMode
|
|
80
|
-
const topLevelRecordSchema = nonCheckModeRecordSchema(_zod.z.record(_zod.z.union([
|
|
81
|
-
propertyLevelPlainEntityDescriptorSchema,
|
|
82
|
-
topLevelRecordValueSchema
|
|
83
|
-
])));
|
|
84
|
-
const topLevelArraySchema = _zod.z.array(_jsonSchema.jsonSchema.and(_zod.z.custom((value)=>!_jsonSchema.jsonLiteralSchema.safeParse(value).success)));
|
|
85
|
-
const plainEntitySchema = _zod.z.union([
|
|
86
|
-
topLevelPlainEntityDescriptorSchema,
|
|
87
|
-
topLevelRecordSchema,
|
|
88
|
-
topLevelArraySchema
|
|
89
|
-
]);
|
|
90
|
-
/* ----- Mapped entity schema ----- */ const mappedEntityValueSchema = _zod.z.union([
|
|
91
|
-
_zod.z.string(),
|
|
92
|
-
_zod.z.number(),
|
|
93
|
-
_zod.z.boolean()
|
|
94
|
-
]);
|
|
95
|
-
const mappedEntityDescriptorSchema = (0, _requiredPropertiesSchema.requiredPropertiesSchema)(_zod.z.discriminatedUnion('checkMode', [
|
|
96
|
-
_zod.z.strictObject({
|
|
97
|
-
checkMode: _zod.z.literal('function'),
|
|
98
|
-
value: _zod.z.function()
|
|
99
|
-
}),
|
|
100
|
-
_zod.z.strictObject({
|
|
101
|
-
checkMode: _zod.z.literal('regExp'),
|
|
102
|
-
value: _zod.z.union([
|
|
103
|
-
_zod.z.instanceof(RegExp),
|
|
104
|
-
_zod.z.array(_zod.z.instanceof(RegExp))
|
|
105
|
-
])
|
|
106
|
-
}),
|
|
107
|
-
_zod.z.strictObject({
|
|
108
|
-
checkMode: _checkModeSchema.compareWithDescriptorValueCheckModeSchema,
|
|
109
|
-
value: _zod.z.union([
|
|
110
|
-
mappedEntityValueSchema,
|
|
111
|
-
_zod.z.array(mappedEntityValueSchema)
|
|
112
|
-
])
|
|
113
|
-
}),
|
|
114
|
-
_zod.z.strictObject({
|
|
115
|
-
checkMode: _checkModeSchema.checkActualValueCheckModeSchema
|
|
116
|
-
})
|
|
117
|
-
]), [
|
|
118
|
-
'checkMode'
|
|
119
|
-
]);
|
|
120
|
-
const mappedEntitySchema = (0, _plainObjectSchema.plainObjectSchema)(_zod.z.record(_zod.z.union([
|
|
121
|
-
mappedEntityValueSchema,
|
|
122
|
-
_zod.z.array(mappedEntityValueSchema),
|
|
123
|
-
mappedEntityDescriptorSchema
|
|
124
|
-
])));
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { GraphQLOperationType } from '../../../../../utils/types';
|
|
2
|
-
export type GraphqlRequestSuggestionConfigs = {
|
|
3
|
-
operationType: GraphQLOperationType;
|
|
4
|
-
operationName: string;
|
|
5
|
-
}[];
|
|
6
|
-
interface GetGraphqlUrlSuggestionsParams {
|
|
7
|
-
url: URL;
|
|
8
|
-
requestConfigs: GraphqlRequestSuggestionConfigs;
|
|
9
|
-
}
|
|
10
|
-
export declare const getGraphqlUrlSuggestions: ({ url, requestConfigs }: GetGraphqlUrlSuggestionsParams) => GraphqlRequestSuggestionConfigs;
|
|
11
|
-
export {};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "getGraphqlUrlSuggestions", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return getGraphqlUrlSuggestions;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _getLevenshteinDistance = require("../getLevenshteinDistance/getLevenshteinDistance");
|
|
12
|
-
const getGraphqlUrlSuggestions = ({ url, requestConfigs })=>{
|
|
13
|
-
var _url_searchParams_get;
|
|
14
|
-
// ✅ important: operationName is always second word in 'query' query param
|
|
15
|
-
const actualOperationName = (_url_searchParams_get = url.searchParams.get('query')) === null || _url_searchParams_get === void 0 ? void 0 : _url_searchParams_get.split(' ')[1];
|
|
16
|
-
const actualUrlMeaningful = `${url.pathname}/${actualOperationName}`;
|
|
17
|
-
const graphqlUrlSuggestions = requestConfigs.reduce((acc, requestConfig)=>{
|
|
18
|
-
const { operationName } = requestConfig;
|
|
19
|
-
const distance = (0, _getLevenshteinDistance.getLevenshteinDistance)(actualUrlMeaningful, operationName);
|
|
20
|
-
const tolerance = Math.floor(operationName.length / 2);
|
|
21
|
-
if (distance <= tolerance) acc.push(requestConfig);
|
|
22
|
-
return acc;
|
|
23
|
-
}, []);
|
|
24
|
-
return graphqlUrlSuggestions;
|
|
25
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const getLevenshteinDistance: (a: string, b: string) => number;
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
/* eslint-disable eslint-comments/disable-enable-pair, eslint-comments/no-unlimited-disable */ /* eslint-disable */ "use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "getLevenshteinDistance", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return getLevenshteinDistance;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const min = (d0, d1, d2, bx, ay)=>d0 < d1 || d2 < d1 ? d0 > d2 ? d2 + 1 : d0 + 1 : bx === ay ? d1 : d1 + 1;
|
|
12
|
-
const getLevenshteinDistance = (a, b)=>{
|
|
13
|
-
if (a === b) {
|
|
14
|
-
return 0;
|
|
15
|
-
}
|
|
16
|
-
if (a.length > b.length) {
|
|
17
|
-
const tmp = a;
|
|
18
|
-
a = b;
|
|
19
|
-
b = tmp;
|
|
20
|
-
}
|
|
21
|
-
let la = a.length;
|
|
22
|
-
let lb = b.length;
|
|
23
|
-
while(la > 0 && a.charCodeAt(la - 1) === b.charCodeAt(lb - 1)){
|
|
24
|
-
la--;
|
|
25
|
-
lb--;
|
|
26
|
-
}
|
|
27
|
-
let offset = 0;
|
|
28
|
-
while(offset < la && a.charCodeAt(offset) === b.charCodeAt(offset)){
|
|
29
|
-
offset++;
|
|
30
|
-
}
|
|
31
|
-
la -= offset;
|
|
32
|
-
lb -= offset;
|
|
33
|
-
if (la === 0 || lb < 3) {
|
|
34
|
-
return lb;
|
|
35
|
-
}
|
|
36
|
-
let x = 0;
|
|
37
|
-
let y;
|
|
38
|
-
let d0;
|
|
39
|
-
let d1;
|
|
40
|
-
let d2;
|
|
41
|
-
let d3;
|
|
42
|
-
let dd = 0;
|
|
43
|
-
let dy;
|
|
44
|
-
let ay;
|
|
45
|
-
let bx0;
|
|
46
|
-
let bx1;
|
|
47
|
-
let bx2;
|
|
48
|
-
let bx3;
|
|
49
|
-
const vector = [];
|
|
50
|
-
for(y = 0; y < la; y++){
|
|
51
|
-
vector.push(y + 1);
|
|
52
|
-
vector.push(a.charCodeAt(offset + y));
|
|
53
|
-
}
|
|
54
|
-
const len = vector.length - 1;
|
|
55
|
-
for(; x < lb - 3;){
|
|
56
|
-
bx0 = b.charCodeAt(offset + (d0 = x));
|
|
57
|
-
bx1 = b.charCodeAt(offset + (d1 = x + 1));
|
|
58
|
-
bx2 = b.charCodeAt(offset + (d2 = x + 2));
|
|
59
|
-
bx3 = b.charCodeAt(offset + (d3 = x + 3));
|
|
60
|
-
dd = x += 4;
|
|
61
|
-
for(y = 0; y < len; y += 2){
|
|
62
|
-
dy = vector[y];
|
|
63
|
-
ay = vector[y + 1];
|
|
64
|
-
d0 = min(dy, d0, d1, bx0, ay);
|
|
65
|
-
d1 = min(d0, d1, d2, bx1, ay);
|
|
66
|
-
d2 = min(d1, d2, d3, bx2, ay);
|
|
67
|
-
dd = min(d2, d3, dd, bx3, ay);
|
|
68
|
-
vector[y] = dd;
|
|
69
|
-
d3 = d2;
|
|
70
|
-
d2 = d1;
|
|
71
|
-
d1 = d0;
|
|
72
|
-
d0 = dy;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
for(; x < lb;){
|
|
76
|
-
bx0 = b.charCodeAt(offset + (d0 = x));
|
|
77
|
-
dd = ++x;
|
|
78
|
-
for(y = 0; y < len; y += 2){
|
|
79
|
-
dy = vector[y];
|
|
80
|
-
vector[y] = dd = min(dy, d0, dd, bx0, vector[y + 1]);
|
|
81
|
-
d0 = dy;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
return dd;
|
|
85
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { RestMethod, RestPathString } from '../../../../../utils/types';
|
|
2
|
-
export type RestRequestSuggestionConfigs = {
|
|
3
|
-
method: RestMethod;
|
|
4
|
-
path: RestPathString;
|
|
5
|
-
}[];
|
|
6
|
-
interface GetRestUrlSuggestionsParams {
|
|
7
|
-
url: URL;
|
|
8
|
-
requestConfigs: RestRequestSuggestionConfigs;
|
|
9
|
-
}
|
|
10
|
-
export declare const getRestUrlSuggestions: ({ url, requestConfigs }: GetRestUrlSuggestionsParams) => RestRequestSuggestionConfigs;
|
|
11
|
-
export {};
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "getRestUrlSuggestions", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return getRestUrlSuggestions;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _helpers = require("../../../../../utils/helpers");
|
|
12
|
-
const _getLevenshteinDistance = require("../getLevenshteinDistance/getLevenshteinDistance");
|
|
13
|
-
const _helpers1 = require("./helpers");
|
|
14
|
-
const getRestUrlSuggestions = ({ url, requestConfigs })=>{
|
|
15
|
-
const actualUrlParts = (0, _helpers.getUrlParts)(url.pathname);
|
|
16
|
-
const restUrlSuggestions = requestConfigs.reduce((acc, requestConfig)=>{
|
|
17
|
-
const patternUrlParts = (0, _helpers.getUrlParts)(requestConfig.path);
|
|
18
|
-
// ✅ important: ignore patterns with different amount of parts
|
|
19
|
-
if (patternUrlParts.length !== actualUrlParts.length) return acc;
|
|
20
|
-
const actualUrlMeaningfulString = (0, _helpers1.getActualRestUrlMeaningfulString)(actualUrlParts, patternUrlParts);
|
|
21
|
-
const patternUrlMeaningfulString = (0, _helpers1.getPatternRestUrlMeaningfulString)(patternUrlParts);
|
|
22
|
-
const tolerance = Math.floor(patternUrlMeaningfulString.length / 2);
|
|
23
|
-
const distance = (0, _getLevenshteinDistance.getLevenshteinDistance)(actualUrlMeaningfulString, patternUrlMeaningfulString);
|
|
24
|
-
if (distance <= tolerance) {
|
|
25
|
-
// replace param names in pattern with param values from actual url
|
|
26
|
-
const urlSuggestion = patternUrlParts.map((_patternUrlPart, index)=>{
|
|
27
|
-
if (patternUrlParts[index].startsWith(':')) return actualUrlParts[index];
|
|
28
|
-
return patternUrlParts[index];
|
|
29
|
-
}).join('/');
|
|
30
|
-
const suggestionWithQueryParams = `/${urlSuggestion}${url.search}`;
|
|
31
|
-
acc.push({
|
|
32
|
-
...requestConfig,
|
|
33
|
-
path: suggestionWithQueryParams
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
return acc;
|
|
37
|
-
}, []);
|
|
38
|
-
return restUrlSuggestions;
|
|
39
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const getActualRestUrlMeaningfulString: (actualUrlParts: string[], patternUrlParts: string[]) => string;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "getActualRestUrlMeaningfulString", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return getActualRestUrlMeaningfulString;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const getActualRestUrlMeaningfulString = (actualUrlParts, patternUrlParts)=>actualUrlParts.filter((_actualUrlPart, index)=>!patternUrlParts[index].startsWith(':')).join('');
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const getPatternRestUrlMeaningfulString: (patternUrlParts: string[]) => string;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "getPatternRestUrlMeaningfulString", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return getPatternRestUrlMeaningfulString;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const getPatternRestUrlMeaningfulString = (patternUrlParts)=>patternUrlParts.filter((urlPatternPart)=>!urlPatternPart.startsWith(':')).join('');
|
package/dist/src/core/middlewares/notFoundMiddleware/helpers/getRestUrlSuggestions/helpers/index.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
_export_star(require("./getActualRestUrlMeaningfulString/getActualRestUrlMeaningfulString"), exports);
|
|
6
|
-
_export_star(require("./getPatternRestUrlMeaningfulString/getPatternRestUrlMeaningfulString"), 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,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
_export_star(require("./getGraphqlUrlSuggestions/getGraphqlUrlSuggestions"), exports);
|
|
6
|
-
_export_star(require("./getLevenshteinDistance/getLevenshteinDistance"), exports);
|
|
7
|
-
_export_star(require("./getRestUrlSuggestions/getRestUrlSuggestions"), 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,65 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "notFoundMiddleware", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return notFoundMiddleware;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _helpers = require("../../../utils/helpers");
|
|
12
|
-
const _helpers1 = require("./helpers");
|
|
13
|
-
const notFoundMiddleware = (server, mockServerConfig)=>{
|
|
14
|
-
const { baseUrl: serverBaseUrl, rest, graphql } = mockServerConfig;
|
|
15
|
-
var _rest_configs_filter_map;
|
|
16
|
-
const restRequestConfigs = (_rest_configs_filter_map = rest === null || rest === void 0 ? void 0 : rest.configs.filter(({ path })=>!(path instanceof RegExp)).map((request)=>{
|
|
17
|
-
var _rest_baseUrl;
|
|
18
|
-
return {
|
|
19
|
-
method: request.method,
|
|
20
|
-
path: `${serverBaseUrl !== null && serverBaseUrl !== void 0 ? serverBaseUrl : ''}${(_rest_baseUrl = rest === null || rest === void 0 ? void 0 : rest.baseUrl) !== null && _rest_baseUrl !== void 0 ? _rest_baseUrl : ''}${request.path}`
|
|
21
|
-
};
|
|
22
|
-
})) !== null && _rest_configs_filter_map !== void 0 ? _rest_configs_filter_map : [];
|
|
23
|
-
var _graphql_configs_filter_map;
|
|
24
|
-
const graphqlRequestConfigs = (_graphql_configs_filter_map = graphql === null || graphql === void 0 ? void 0 : graphql.configs.filter((request)=>'operationName' in request && !(request.operationName instanceof RegExp)).map((request)=>{
|
|
25
|
-
var _graphql_baseUrl;
|
|
26
|
-
return {
|
|
27
|
-
operationType: request.operationType,
|
|
28
|
-
operationName: `${serverBaseUrl !== null && serverBaseUrl !== void 0 ? serverBaseUrl : ''}${(_graphql_baseUrl = graphql === null || graphql === void 0 ? void 0 : graphql.baseUrl) !== null && _graphql_baseUrl !== void 0 ? _graphql_baseUrl : ''} ${request.operationName}`
|
|
29
|
-
};
|
|
30
|
-
})) !== null && _graphql_configs_filter_map !== void 0 ? _graphql_configs_filter_map : [];
|
|
31
|
-
server.use((request, response)=>{
|
|
32
|
-
var _request_headers_accept, _request_headers_accept1;
|
|
33
|
-
const url = new URL(`${request.protocol}://${request.get('host')}${request.originalUrl}`);
|
|
34
|
-
let restRequestSuggestions = [];
|
|
35
|
-
if (rest) {
|
|
36
|
-
restRequestSuggestions = (0, _helpers1.getRestUrlSuggestions)({
|
|
37
|
-
url,
|
|
38
|
-
requestConfigs: restRequestConfigs
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
let graphqlRequestSuggestions = [];
|
|
42
|
-
if ((request.method === 'GET' || request.method === 'POST') && graphql && (0, _helpers.parseGraphQLRequest)(request)) {
|
|
43
|
-
graphqlRequestSuggestions = (0, _helpers1.getGraphqlUrlSuggestions)({
|
|
44
|
-
url,
|
|
45
|
-
requestConfigs: graphqlRequestConfigs
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
response.status(404);
|
|
49
|
-
const isRequestSupportHtml = ((_request_headers_accept = request.headers.accept) === null || _request_headers_accept === void 0 ? void 0 : _request_headers_accept.includes('text/html')) || ((_request_headers_accept1 = request.headers.accept) === null || _request_headers_accept1 === void 0 ? void 0 : _request_headers_accept1.includes('*/*'));
|
|
50
|
-
if (isRequestSupportHtml) {
|
|
51
|
-
response.render('pages/404', {
|
|
52
|
-
restRequestSuggestions,
|
|
53
|
-
graphqlRequestSuggestions
|
|
54
|
-
});
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
response.json({
|
|
58
|
-
message: 'Request or page not found. Similar requests in data',
|
|
59
|
-
data: {
|
|
60
|
-
restRequestSuggestions,
|
|
61
|
-
graphqlRequestSuggestions
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
<svg width="22" height="22" viewBox="0 0 22 22" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
-
<path d="M11 8C12.65 8 14 9.35 14 11C14 12.65 12.65 14 11 14C9.35 14 8 12.65 8 11C8 9.35 9.35 8 11 8ZM11 6C8.24 6 6 8.24 6 11C6 13.76 8.24 16 11 16C13.76 16 16 13.76 16 11C16 8.24 13.76 6 11 6ZM1 12H3C3.55 12 4 11.55 4 11C4 10.45 3.55 10 3 10H1C0.45 10 0 10.45 0 11C0 11.55 0.45 12 1 12ZM19 12H21C21.55 12 22 11.55 22 11C22 10.45 21.55 10 21 10H19C18.45 10 18 10.45 18 11C18 11.55 18.45 12 19 12ZM10 1V3C10 3.55 10.45 4 11 4C11.55 4 12 3.55 12 3V1C12 0.45 11.55 0 11 0C10.45 0 10 0.45 10 1ZM10 19V21C10 21.55 10.45 22 11 22C11.55 22 12 21.55 12 21V19C12 18.45 11.55 18 11 18C10.45 18 10 18.45 10 19ZM4.99 3.58C4.6 3.19 3.96 3.19 3.58 3.58C3.19 3.97 3.19 4.61 3.58 4.99L4.64 6.05C5.03 6.44 5.67 6.44 6.05 6.05C6.43 5.66 6.44 5.02 6.05 4.64L4.99 3.58ZM17.36 15.95C16.97 15.56 16.33 15.56 15.95 15.95C15.56 16.34 15.56 16.98 15.95 17.36L17.01 18.42C17.4 18.81 18.04 18.81 18.42 18.42C18.81 18.03 18.81 17.39 18.42 17.01L17.36 15.95ZM18.42 4.99C18.81 4.6 18.81 3.96 18.42 3.58C18.03 3.19 17.39 3.19 17.01 3.58L15.95 4.64C15.56 5.03 15.56 5.67 15.95 6.05C16.34 6.43 16.98 6.44 17.36 6.05L18.42 4.99ZM6.05 17.36C6.44 16.97 6.44 16.33 6.05 15.95C5.66 15.56 5.02 15.56 4.64 15.95L3.58 17.01C3.19 17.4 3.19 18.04 3.58 18.42C3.97 18.8 4.61 18.81 4.99 18.42L6.05 17.36Z" fill="white"/>
|
|
3
|
-
</svg>
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
<svg width="18" height="18" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
-
<path fill="#343434" fill-opacity="0.9" d="M6.36997 2.51C6.18997 3.15 6.09997 3.82 6.09997 4.5C6.09997 8.58 9.41997 11.9 13.5 11.9C14.18 11.9 14.85 11.81 15.49 11.63C14.45 14.19 11.93 16 8.99997 16C5.13997 16 1.99997 12.86 1.99997 9C1.99997 6.07 3.80997 3.55 6.36997 2.51ZM8.99997 0C4.02997 0 -3.05176e-05 4.03 -3.05176e-05 9C-3.05176e-05 13.97 4.02997 18 8.99997 18C13.97 18 18 13.97 18 9C18 8.54 17.96 8.08 17.9 7.64C16.92 9.01 15.32 9.9 13.5 9.9C10.52 9.9 8.09997 7.48 8.09997 4.5C8.09997 2.69 8.98997 1.08 10.36 0.0999999C9.91997 0.0399999 9.45997 0 8.99997 0Z"/>
|
|
3
|
-
</svg>
|
|
Binary file
|
|
Binary file
|