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.
- 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 -37
- package/dist/bin/templates/js/full/mock-server.config.js +16 -16
- package/dist/bin/templates/js/graphql/mock-server.config.js +9 -9
- package/dist/bin/templates/js/rest/mock-server.config.js +9 -9
- package/dist/bin/templates/ts/full/mock-requests/graphql/index.ts +2 -2
- package/dist/bin/templates/ts/full/mock-requests/graphql/user.ts +37 -37
- package/dist/bin/templates/ts/full/mock-requests/graphql/users.ts +14 -14
- package/dist/bin/templates/ts/full/mock-requests/rest/index.ts +2 -2
- package/dist/bin/templates/ts/full/mock-requests/rest/user.ts +37 -37
- package/dist/bin/templates/ts/full/mock-requests/rest/users.ts +14 -14
- package/dist/bin/templates/ts/full/mock-server.config.ts +18 -18
- package/dist/bin/templates/ts/graphql/mock-requests/index.ts +2 -2
- package/dist/bin/templates/ts/graphql/mock-requests/user.ts +37 -37
- package/dist/bin/templates/ts/graphql/mock-requests/users.ts +14 -14
- package/dist/bin/templates/ts/graphql/mock-server.config.ts +11 -11
- package/dist/bin/templates/ts/rest/mock-requests/index.ts +2 -2
- package/dist/bin/templates/ts/rest/mock-requests/user.ts +37 -37
- package/dist/bin/templates/ts/rest/mock-requests/users.ts +14 -14
- package/dist/bin/templates/ts/rest/mock-server.config.ts +11 -11
- 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,37 +1,37 @@
|
|
|
1
|
-
import type { GraphQLRequestConfig } from 'mock-config-server';
|
|
2
|
-
|
|
3
|
-
export const getUserQuery: GraphQLRequestConfig = {
|
|
4
|
-
operationName: 'getUser',
|
|
5
|
-
operationType: 'query',
|
|
6
|
-
routes: [
|
|
7
|
-
{
|
|
8
|
-
data: { id: 1, emoji: '🎉' }
|
|
9
|
-
},
|
|
10
|
-
{
|
|
11
|
-
data: { id: 2, emoji: '🔥' },
|
|
12
|
-
entities: {
|
|
13
|
-
variables: {
|
|
14
|
-
id: 2
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
]
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export const createUserMutation: GraphQLRequestConfig = {
|
|
22
|
-
operationName: 'createUser',
|
|
23
|
-
operationType: 'mutation',
|
|
24
|
-
routes: [
|
|
25
|
-
{
|
|
26
|
-
data: { id: 1, emoji: '🎉' }
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
data: { id: 2, emoji: '🔥' },
|
|
30
|
-
entities: {
|
|
31
|
-
variables: {
|
|
32
|
-
emoji: '🔥'
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
]
|
|
37
|
-
};
|
|
1
|
+
import type { GraphQLRequestConfig } from 'mock-config-server';
|
|
2
|
+
|
|
3
|
+
export const getUserQuery: GraphQLRequestConfig = {
|
|
4
|
+
operationName: 'getUser',
|
|
5
|
+
operationType: 'query',
|
|
6
|
+
routes: [
|
|
7
|
+
{
|
|
8
|
+
data: { id: 1, emoji: '🎉' }
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
data: { id: 2, emoji: '🔥' },
|
|
12
|
+
entities: {
|
|
13
|
+
variables: {
|
|
14
|
+
id: 2
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
]
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const createUserMutation: GraphQLRequestConfig = {
|
|
22
|
+
operationName: 'createUser',
|
|
23
|
+
operationType: 'mutation',
|
|
24
|
+
routes: [
|
|
25
|
+
{
|
|
26
|
+
data: { id: 1, emoji: '🎉' }
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
data: { id: 2, emoji: '🔥' },
|
|
30
|
+
entities: {
|
|
31
|
+
variables: {
|
|
32
|
+
emoji: '🔥'
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
]
|
|
37
|
+
};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import type { GraphQLRequestConfig } from 'mock-config-server';
|
|
2
|
-
|
|
3
|
-
export const getUsersQuery: GraphQLRequestConfig = {
|
|
4
|
-
operationName: 'getUsers',
|
|
5
|
-
operationType: 'query',
|
|
6
|
-
routes: [
|
|
7
|
-
{
|
|
8
|
-
data: [
|
|
9
|
-
{ id: 1, emoji: '🎉' },
|
|
10
|
-
{ id: 2, emoji: '🔥' }
|
|
11
|
-
]
|
|
12
|
-
}
|
|
13
|
-
]
|
|
14
|
-
};
|
|
1
|
+
import type { GraphQLRequestConfig } from 'mock-config-server';
|
|
2
|
+
|
|
3
|
+
export const getUsersQuery: GraphQLRequestConfig = {
|
|
4
|
+
operationName: 'getUsers',
|
|
5
|
+
operationType: 'query',
|
|
6
|
+
routes: [
|
|
7
|
+
{
|
|
8
|
+
data: [
|
|
9
|
+
{ id: 1, emoji: '🎉' },
|
|
10
|
+
{ id: 2, emoji: '🔥' }
|
|
11
|
+
]
|
|
12
|
+
}
|
|
13
|
+
]
|
|
14
|
+
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { GraphQLMockServerConfig } from 'mock-config-server';
|
|
2
|
-
|
|
3
|
-
import { createUserMutation, getUserQuery, getUsersQuery } from './mock-requests';
|
|
4
|
-
|
|
5
|
-
const restMockServerConfig: GraphQLMockServerConfig = {
|
|
6
|
-
port: 31299,
|
|
7
|
-
baseUrl: '/',
|
|
8
|
-
configs: [getUserQuery, getUsersQuery, createUserMutation]
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export default restMockServerConfig;
|
|
1
|
+
import type { GraphQLMockServerConfig } from 'mock-config-server';
|
|
2
|
+
|
|
3
|
+
import { createUserMutation, getUserQuery, getUsersQuery } from './mock-requests';
|
|
4
|
+
|
|
5
|
+
const restMockServerConfig: GraphQLMockServerConfig = {
|
|
6
|
+
port: 31299,
|
|
7
|
+
baseUrl: '/',
|
|
8
|
+
configs: [getUserQuery, getUsersQuery, createUserMutation]
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export default restMockServerConfig;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './user';
|
|
2
|
-
export * from './users';
|
|
1
|
+
export * from './user';
|
|
2
|
+
export * from './users';
|
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
import type { RestRequestConfig } from 'mock-config-server';
|
|
2
|
-
|
|
3
|
-
export const getUserRequest: RestRequestConfig = {
|
|
4
|
-
method: 'get',
|
|
5
|
-
path: '/users/:id',
|
|
6
|
-
routes: [
|
|
7
|
-
{
|
|
8
|
-
data: { id: 1, emoji: '🎉' }
|
|
9
|
-
},
|
|
10
|
-
{
|
|
11
|
-
data: { id: 2, emoji: '🔥' },
|
|
12
|
-
entities: {
|
|
13
|
-
params: {
|
|
14
|
-
id: 2
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
]
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export const postUserRequest: RestRequestConfig = {
|
|
22
|
-
method: 'post',
|
|
23
|
-
path: '/users',
|
|
24
|
-
routes: [
|
|
25
|
-
{
|
|
26
|
-
data: { id: 1, emoji: '🎉' }
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
data: { id: 2, emoji: '🔥' },
|
|
30
|
-
entities: {
|
|
31
|
-
body: {
|
|
32
|
-
emoji: '🔥'
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
]
|
|
37
|
-
};
|
|
1
|
+
import type { RestRequestConfig } from 'mock-config-server';
|
|
2
|
+
|
|
3
|
+
export const getUserRequest: RestRequestConfig = {
|
|
4
|
+
method: 'get',
|
|
5
|
+
path: '/users/:id',
|
|
6
|
+
routes: [
|
|
7
|
+
{
|
|
8
|
+
data: { id: 1, emoji: '🎉' }
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
data: { id: 2, emoji: '🔥' },
|
|
12
|
+
entities: {
|
|
13
|
+
params: {
|
|
14
|
+
id: 2
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
]
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const postUserRequest: RestRequestConfig = {
|
|
22
|
+
method: 'post',
|
|
23
|
+
path: '/users',
|
|
24
|
+
routes: [
|
|
25
|
+
{
|
|
26
|
+
data: { id: 1, emoji: '🎉' }
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
data: { id: 2, emoji: '🔥' },
|
|
30
|
+
entities: {
|
|
31
|
+
body: {
|
|
32
|
+
emoji: '🔥'
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
]
|
|
37
|
+
};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import type { RestRequestConfig } from 'mock-config-server';
|
|
2
|
-
|
|
3
|
-
export const getUsersRequest: RestRequestConfig = {
|
|
4
|
-
path: '/users',
|
|
5
|
-
method: 'get',
|
|
6
|
-
routes: [
|
|
7
|
-
{
|
|
8
|
-
data: [
|
|
9
|
-
{ id: 1, emoji: '🎉' },
|
|
10
|
-
{ id: 2, emoji: '🔥' }
|
|
11
|
-
]
|
|
12
|
-
}
|
|
13
|
-
]
|
|
14
|
-
};
|
|
1
|
+
import type { RestRequestConfig } from 'mock-config-server';
|
|
2
|
+
|
|
3
|
+
export const getUsersRequest: RestRequestConfig = {
|
|
4
|
+
path: '/users',
|
|
5
|
+
method: 'get',
|
|
6
|
+
routes: [
|
|
7
|
+
{
|
|
8
|
+
data: [
|
|
9
|
+
{ id: 1, emoji: '🎉' },
|
|
10
|
+
{ id: 2, emoji: '🔥' }
|
|
11
|
+
]
|
|
12
|
+
}
|
|
13
|
+
]
|
|
14
|
+
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { RestMockServerConfig } from 'mock-config-server';
|
|
2
|
-
|
|
3
|
-
import { getUserRequest, getUsersRequest, postUserRequest } from './mock-requests';
|
|
4
|
-
|
|
5
|
-
const restMockServerConfig: RestMockServerConfig = {
|
|
6
|
-
port: 31299,
|
|
7
|
-
baseUrl: '/',
|
|
8
|
-
configs: [getUserRequest, getUsersRequest, postUserRequest]
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export default restMockServerConfig;
|
|
1
|
+
import type { RestMockServerConfig } from 'mock-config-server';
|
|
2
|
+
|
|
3
|
+
import { getUserRequest, getUsersRequest, postUserRequest } from './mock-requests';
|
|
4
|
+
|
|
5
|
+
const restMockServerConfig: RestMockServerConfig = {
|
|
6
|
+
port: 31299,
|
|
7
|
+
baseUrl: '/',
|
|
8
|
+
configs: [getUserRequest, getUsersRequest, postUserRequest]
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export default restMockServerConfig;
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
|
|
3
|
+
value: true
|
|
5
4
|
});
|
|
6
|
-
exports
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
Object.defineProperty(exports, "baseUrlSchema", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return baseUrlSchema;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _utils = require("../utils");
|
|
12
|
+
const baseUrlSchema = _utils.stringForwardSlashSchema;
|
|
@@ -1,17 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "corsSchema", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return corsSchema;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _zod = require("zod");
|
|
12
|
+
const stringOrRegExpSchema = _zod.z.union([
|
|
13
|
+
_zod.z.string(),
|
|
14
|
+
_zod.z.instanceof(RegExp)
|
|
15
|
+
]);
|
|
16
|
+
const originSchema = _zod.z.union([
|
|
17
|
+
stringOrRegExpSchema,
|
|
18
|
+
_zod.z.array(stringOrRegExpSchema),
|
|
19
|
+
_zod.z.function()
|
|
20
|
+
]);
|
|
21
|
+
const corsSchema = _zod.z.strictObject({
|
|
22
|
+
origin: originSchema,
|
|
23
|
+
methods: _zod.z.array(_zod.z.enum([
|
|
24
|
+
"GET",
|
|
25
|
+
"POST",
|
|
26
|
+
"PUT",
|
|
27
|
+
"DELETE",
|
|
28
|
+
"PATCH",
|
|
29
|
+
"OPTIONS"
|
|
30
|
+
])).optional(),
|
|
31
|
+
allowedHeaders: _zod.z.array(_zod.z.string()).optional(),
|
|
32
|
+
exposedHeaders: _zod.z.array(_zod.z.string()).optional(),
|
|
33
|
+
credentials: _zod.z.boolean().optional(),
|
|
34
|
+
maxAge: _zod.z.number().int().positive().optional()
|
|
5
35
|
});
|
|
6
|
-
exports.corsSchema = void 0;
|
|
7
|
-
var _zod = require("zod");
|
|
8
|
-
const stringOrRegExpSchema = _zod.z.union([_zod.z.string(), _zod.z.instanceof(RegExp)]);
|
|
9
|
-
const originSchema = _zod.z.union([stringOrRegExpSchema, _zod.z.array(stringOrRegExpSchema), _zod.z.function()]);
|
|
10
|
-
const corsSchema = exports.corsSchema = _zod.z.strictObject({
|
|
11
|
-
origin: originSchema,
|
|
12
|
-
methods: _zod.z.array(_zod.z.enum(['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'OPTIONS'])).optional(),
|
|
13
|
-
allowedHeaders: _zod.z.array(_zod.z.string()).optional(),
|
|
14
|
-
exposedHeaders: _zod.z.array(_zod.z.string()).optional(),
|
|
15
|
-
credentials: _zod.z.boolean().optional(),
|
|
16
|
-
maxAge: _zod.z.number().int().positive().optional()
|
|
17
|
-
});
|
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "databaseConfigSchema", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return databaseConfigSchema;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _zod = require("zod");
|
|
12
|
+
const _utils = require("../utils");
|
|
13
|
+
const databaseConfigSchema = _zod.z.strictObject({
|
|
14
|
+
data: _zod.z.union([
|
|
15
|
+
(0, _utils.plainObjectSchema)(_zod.z.record(_zod.z.unknown())),
|
|
16
|
+
_utils.stringJsonFilenameSchema
|
|
17
|
+
]),
|
|
18
|
+
routes: _zod.z.union([
|
|
19
|
+
(0, _utils.plainObjectSchema)(_zod.z.record(_utils.stringForwardSlashSchema, _utils.stringForwardSlashSchema)),
|
|
20
|
+
_utils.stringJsonFilenameSchema
|
|
21
|
+
]).optional()
|
|
5
22
|
});
|
|
6
|
-
exports.databaseConfigSchema = void 0;
|
|
7
|
-
var _zod = require("zod");
|
|
8
|
-
var _utils = require("../utils");
|
|
9
|
-
const databaseConfigSchema = exports.databaseConfigSchema = _zod.z.strictObject({
|
|
10
|
-
data: _zod.z.union([(0, _utils.plainObjectSchema)(_zod.z.record(_zod.z.unknown())), _utils.stringJsonFilenameSchema]),
|
|
11
|
-
routes: _zod.z.union([(0, _utils.plainObjectSchema)(_zod.z.record(_utils.stringForwardSlashSchema, _utils.stringForwardSlashSchema)), _utils.stringJsonFilenameSchema]).optional()
|
|
12
|
-
});
|
|
@@ -1,31 +1,47 @@
|
|
|
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, "graphqlConfigSchema", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return graphqlConfigSchema;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _zod = require("zod");
|
|
12
|
+
const _helpers = require("../../../src/utils/helpers");
|
|
13
|
+
const _baseUrlSchema = require("../baseUrlSchema/baseUrlSchema");
|
|
14
|
+
const _interceptorsSchema = require("../interceptorsSchema/interceptorsSchema");
|
|
15
|
+
const _utils = require("../utils");
|
|
16
|
+
const _routeConfigSchema = require("./routeConfigSchema/routeConfigSchema");
|
|
13
17
|
const baseRequestConfigSchema = _zod.z.strictObject({
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
18
|
+
operationType: _zod.z.enum([
|
|
19
|
+
"query",
|
|
20
|
+
"mutation"
|
|
21
|
+
]),
|
|
22
|
+
routes: _zod.z.array(_routeConfigSchema.routeConfigSchema),
|
|
23
|
+
interceptors: (0, _utils.plainObjectSchema)(_interceptorsSchema.interceptorsSchema).optional()
|
|
17
24
|
});
|
|
18
25
|
const operationNameRequestConfigSchema = _zod.z.strictObject({
|
|
19
|
-
|
|
20
|
-
|
|
26
|
+
operationName: _zod.z.union([
|
|
27
|
+
_zod.z.string(),
|
|
28
|
+
_zod.z.instanceof(RegExp)
|
|
29
|
+
]),
|
|
30
|
+
query: _zod.z.string().optional()
|
|
21
31
|
}).merge(baseRequestConfigSchema);
|
|
22
32
|
const queryRequestConfigSchema = _zod.z.strictObject({
|
|
23
|
-
|
|
24
|
-
|
|
33
|
+
operationName: _zod.z.union([
|
|
34
|
+
_zod.z.string(),
|
|
35
|
+
_zod.z.instanceof(RegExp)
|
|
36
|
+
]).optional(),
|
|
37
|
+
query: _zod.z.string()
|
|
25
38
|
}).merge(baseRequestConfigSchema);
|
|
26
|
-
const requestConfigSchema = _zod.z.union([
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
39
|
+
const requestConfigSchema = _zod.z.union([
|
|
40
|
+
_zod.z.custom((value)=>(0, _helpers.isPlainObject)(value) && "operationName" in value).pipe(operationNameRequestConfigSchema),
|
|
41
|
+
_zod.z.custom((value)=>(0, _helpers.isPlainObject)(value) && "query" in value).pipe(queryRequestConfigSchema)
|
|
42
|
+
]);
|
|
43
|
+
const graphqlConfigSchema = _zod.z.strictObject({
|
|
44
|
+
baseUrl: _baseUrlSchema.baseUrlSchema.optional(),
|
|
45
|
+
configs: _zod.z.array(requestConfigSchema),
|
|
46
|
+
interceptors: (0, _utils.plainObjectSchema)(_interceptorsSchema.interceptorsSchema).optional()
|
|
47
|
+
});
|
package/dist/bin/validateMockServerConfig/graphqlConfigSchema/routeConfigSchema/routeConfigSchema.js
CHANGED
|
@@ -1,37 +1,47 @@
|
|
|
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
|
-
|
|
5
|
+
Object.defineProperty(exports, "routeConfigSchema", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return routeConfigSchema;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _zod = require("zod");
|
|
12
|
+
const _helpers = require("../../../../src/utils/helpers");
|
|
13
|
+
const _helpers1 = require("../../../helpers");
|
|
14
|
+
const _interceptorsSchema = require("../../interceptorsSchema/interceptorsSchema");
|
|
15
|
+
const _queueSchema = require("../../queueSchema/queueSchema");
|
|
16
|
+
const _settingsSchema = require("../../settingsSchema/settingsSchema");
|
|
17
|
+
const _utils = require("../../utils");
|
|
14
18
|
const baseRouteConfigSchema = _zod.z.strictObject({
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
entities: (0, _utils.plainObjectSchema)(_zod.z.strictObject({
|
|
20
|
+
headers: _utils.mappedEntitySchema.optional(),
|
|
21
|
+
cookies: _utils.mappedEntitySchema.optional(),
|
|
22
|
+
query: _utils.mappedEntitySchema.optional(),
|
|
23
|
+
variables: _utils.plainEntitySchema.optional()
|
|
24
|
+
})).optional(),
|
|
25
|
+
interceptors: (0, _utils.plainObjectSchema)(_interceptorsSchema.interceptorsSchema.pick({
|
|
26
|
+
response: true
|
|
27
|
+
})).optional()
|
|
24
28
|
});
|
|
25
29
|
const dataRouteConfigSchema = _zod.z.strictObject({
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
+
settings: (0, _utils.plainObjectSchema)(_settingsSchema.settingsSchema.extend({
|
|
31
|
+
polling: _zod.z.literal(false).optional()
|
|
32
|
+
})).optional(),
|
|
33
|
+
data: _zod.z.union([
|
|
34
|
+
_zod.z.function(),
|
|
35
|
+
_zod.z.any()
|
|
36
|
+
])
|
|
30
37
|
}).merge(baseRouteConfigSchema);
|
|
31
38
|
const queueRouteConfigSchema = _zod.z.strictObject({
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
39
|
+
settings: _settingsSchema.settingsSchema.extend({
|
|
40
|
+
polling: _zod.z.literal(true)
|
|
41
|
+
}),
|
|
42
|
+
queue: _queueSchema.queueSchema
|
|
36
43
|
}).merge(baseRouteConfigSchema);
|
|
37
|
-
const routeConfigSchema =
|
|
44
|
+
const routeConfigSchema = _zod.z.union([
|
|
45
|
+
_zod.z.custom((value)=>(0, _helpers.isPlainObject)(value) && (0, _helpers1.isOnlyRequestedDataResolvingPropertyExists)(value, "data")).pipe(dataRouteConfigSchema),
|
|
46
|
+
_zod.z.custom((value)=>(0, _helpers.isPlainObject)(value) && (0, _helpers1.isOnlyRequestedDataResolvingPropertyExists)(value, "queue")).pipe(queueRouteConfigSchema)
|
|
47
|
+
]);
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "interceptorsSchema", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return interceptorsSchema;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _zod = require("zod");
|
|
12
|
+
const interceptorsSchema = _zod.z.strictObject({
|
|
13
|
+
request: _zod.z.function().optional(),
|
|
14
|
+
response: _zod.z.function().optional()
|
|
5
15
|
});
|
|
6
|
-
exports.interceptorsSchema = void 0;
|
|
7
|
-
var _zod = require("zod");
|
|
8
|
-
const interceptorsSchema = exports.interceptorsSchema = _zod.z.strictObject({
|
|
9
|
-
request: _zod.z.function().optional(),
|
|
10
|
-
response: _zod.z.function().optional()
|
|
11
|
-
});
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
|
|
3
|
+
value: true
|
|
5
4
|
});
|
|
6
|
-
exports
|
|
7
|
-
|
|
5
|
+
Object.defineProperty(exports, "portSchema", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return portSchema;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _zod = require("zod");
|
|
8
12
|
const MAX_PORT = 65535;
|
|
9
|
-
const portSchema =
|
|
13
|
+
const portSchema = _zod.z.number().int().nonnegative().max(MAX_PORT);
|
|
@@ -1,12 +1,21 @@
|
|
|
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, "queueSchema", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return queueSchema;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _zod = require("zod");
|
|
12
|
+
const _utils = require("../utils");
|
|
13
|
+
const queueSchema = _zod.z.array((0, _utils.requiredPropertiesSchema)(_zod.z.strictObject({
|
|
14
|
+
time: _zod.z.number().int().nonnegative().optional(),
|
|
15
|
+
data: _zod.z.union([
|
|
16
|
+
_zod.z.function(),
|
|
17
|
+
_zod.z.any()
|
|
18
|
+
])
|
|
19
|
+
}), [
|
|
20
|
+
"data"
|
|
21
|
+
]));
|
|
@@ -1,23 +1,37 @@
|
|
|
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
|
-
|
|
5
|
+
Object.defineProperty(exports, "restConfigSchema", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return restConfigSchema;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _zod = require("zod");
|
|
12
|
+
const _baseUrlSchema = require("../baseUrlSchema/baseUrlSchema");
|
|
13
|
+
const _interceptorsSchema = require("../interceptorsSchema/interceptorsSchema");
|
|
14
|
+
const _utils = require("../utils");
|
|
15
|
+
const _routeConfigSchema = require("./routeConfigSchema/routeConfigSchema");
|
|
16
|
+
const baseRequestConfigSchema = (method)=>_zod.z.strictObject({
|
|
17
|
+
path: _zod.z.union([
|
|
18
|
+
_utils.stringForwardSlashSchema,
|
|
19
|
+
_zod.z.instanceof(RegExp)
|
|
20
|
+
]),
|
|
21
|
+
method: _zod.z.literal(method),
|
|
22
|
+
routes: _zod.z.array((0, _routeConfigSchema.routeConfigSchema)(method)),
|
|
23
|
+
interceptors: (0, _utils.plainObjectSchema)(_interceptorsSchema.interceptorsSchema).optional()
|
|
24
|
+
});
|
|
25
|
+
const requestConfigSchema = _zod.z.union([
|
|
26
|
+
baseRequestConfigSchema("get"),
|
|
27
|
+
baseRequestConfigSchema("post"),
|
|
28
|
+
baseRequestConfigSchema("put"),
|
|
29
|
+
baseRequestConfigSchema("delete"),
|
|
30
|
+
baseRequestConfigSchema("patch"),
|
|
31
|
+
baseRequestConfigSchema("options")
|
|
32
|
+
]);
|
|
33
|
+
const restConfigSchema = _zod.z.strictObject({
|
|
34
|
+
baseUrl: _baseUrlSchema.baseUrlSchema.optional(),
|
|
35
|
+
configs: _zod.z.array(requestConfigSchema),
|
|
36
|
+
interceptors: (0, _utils.plainObjectSchema)(_interceptorsSchema.interceptorsSchema).optional()
|
|
17
37
|
});
|
|
18
|
-
const requestConfigSchema = _zod.z.union([baseRequestConfigSchema('get'), baseRequestConfigSchema('post'), baseRequestConfigSchema('put'), baseRequestConfigSchema('delete'), baseRequestConfigSchema('patch'), baseRequestConfigSchema('options')]);
|
|
19
|
-
const restConfigSchema = exports.restConfigSchema = _zod.z.strictObject({
|
|
20
|
-
baseUrl: _baseUrlSchema.baseUrlSchema.optional(),
|
|
21
|
-
configs: _zod.z.array(requestConfigSchema),
|
|
22
|
-
interceptors: (0, _utils.plainObjectSchema)(_interceptorsSchema.interceptorsSchema).optional()
|
|
23
|
-
});
|