mock-config-server 2.4.0 → 3.0.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/LICENSE +21 -21
- package/README.md +502 -326
- package/package.json +113 -113
- package/dist/bin/bin.d.ts +0 -2
- package/dist/bin/bin.js +0 -8
- package/dist/bin/build.d.ts +0 -2
- package/dist/bin/build.js +0 -49
- package/dist/bin/cli.d.ts +0 -1
- package/dist/bin/cli.js +0 -48
- package/dist/bin/helpers/index.d.ts +0 -3
- package/dist/bin/helpers/index.js +0 -19
- package/dist/bin/helpers/resolveConfigFile.d.ts +0 -2
- package/dist/bin/helpers/resolveConfigFile.js +0 -20
- package/dist/bin/helpers/resolveConfigFilePath.d.ts +0 -1
- package/dist/bin/helpers/resolveConfigFilePath.js +0 -39
- package/dist/bin/helpers/resolveExportsFromSourceCode.d.ts +0 -1
- package/dist/bin/helpers/resolveExportsFromSourceCode.js +0 -11
- package/dist/bin/resolveConfigFilePath/resolveConfigFilePath.d.ts +0 -1
- package/dist/bin/resolveConfigFilePath/resolveConfigFilePath.js +0 -39
- package/dist/bin/run.d.ts +0 -6
- package/dist/bin/run.js +0 -17
- package/dist/bin/validateMockServerConfig/validateBaseUrl/validateBaseUrl.d.ts +0 -1
- package/dist/bin/validateMockServerConfig/validateBaseUrl/validateBaseUrl.js +0 -12
- package/dist/bin/validateMockServerConfig/validateCors/validateCors.d.ts +0 -1
- package/dist/bin/validateMockServerConfig/validateCors/validateCors.js +0 -82
- package/dist/bin/validateMockServerConfig/validateGraphqlConfig/validateGraphqlConfig.d.ts +0 -1
- package/dist/bin/validateMockServerConfig/validateGraphqlConfig/validateGraphqlConfig.js +0 -48
- package/dist/bin/validateMockServerConfig/validateGraphqlConfig/validateRoutes/validateRoutes.d.ts +0 -2
- package/dist/bin/validateMockServerConfig/validateGraphqlConfig/validateRoutes/validateRoutes.js +0 -71
- package/dist/bin/validateMockServerConfig/validateInterceptors/validateInterceptors.d.ts +0 -1
- package/dist/bin/validateMockServerConfig/validateInterceptors/validateInterceptors.js +0 -21
- package/dist/bin/validateMockServerConfig/validateMockServerConfig.d.ts +0 -2
- package/dist/bin/validateMockServerConfig/validateMockServerConfig.js +0 -30
- package/dist/bin/validateMockServerConfig/validatePort/validatePort.d.ts +0 -1
- package/dist/bin/validateMockServerConfig/validatePort/validatePort.js +0 -9
- package/dist/bin/validateMockServerConfig/validateRestConfig/validateRestConfig.d.ts +0 -1
- package/dist/bin/validateMockServerConfig/validateRestConfig/validateRestConfig.js +0 -52
- package/dist/bin/validateMockServerConfig/validateRestConfig/validateRoutes/validateRoutes.d.ts +0 -2
- package/dist/bin/validateMockServerConfig/validateRestConfig/validateRoutes/validateRoutes.js +0 -105
- package/dist/bin/validateMockServerConfig/validateStaticPath/validateStaticPath.d.ts +0 -1
- package/dist/bin/validateMockServerConfig/validateStaticPath/validateStaticPath.js +0 -44
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -17
- package/dist/src/core/graphql/createGraphQLRoutes/createGraphQLRoutes.d.ts +0 -3
- package/dist/src/core/graphql/createGraphQLRoutes/createGraphQLRoutes.js +0 -78
- package/dist/src/core/graphql/createGraphQLRoutes/helpers/index.d.ts +0 -1
- package/dist/src/core/graphql/createGraphQLRoutes/helpers/index.js +0 -17
- package/dist/src/core/graphql/createGraphQLRoutes/helpers/prepareGraphQLRequestConfigs/prepareGraphQLRequestConfigs.d.ts +0 -2
- package/dist/src/core/graphql/createGraphQLRoutes/helpers/prepareGraphQLRequestConfigs/prepareGraphQLRequestConfigs.js +0 -30
- package/dist/src/core/graphql/index.d.ts +0 -1
- package/dist/src/core/graphql/index.js +0 -17
- package/dist/src/core/middlewares/cookieParseMiddleware/cookieParseMiddleware.d.ts +0 -2
- package/dist/src/core/middlewares/cookieParseMiddleware/cookieParseMiddleware.js +0 -16
- package/dist/src/core/middlewares/cookieParseMiddleware/helpers/index.d.ts +0 -1
- package/dist/src/core/middlewares/cookieParseMiddleware/helpers/index.js +0 -17
- package/dist/src/core/middlewares/cookieParseMiddleware/helpers/parseCookie/parseCookie.d.ts +0 -3
- package/dist/src/core/middlewares/cookieParseMiddleware/helpers/parseCookie/parseCookie.js +0 -17
- package/dist/src/core/middlewares/corsMiddleware/corsMiddleware.d.ts +0 -3
- package/dist/src/core/middlewares/corsMiddleware/corsMiddleware.js +0 -44
- package/dist/src/core/middlewares/corsMiddleware/helpers/getAllowedOrigins/getAllowedOrigins.d.ts +0 -2
- package/dist/src/core/middlewares/corsMiddleware/helpers/getAllowedOrigins/getAllowedOrigins.js +0 -13
- package/dist/src/core/middlewares/corsMiddleware/helpers/index.d.ts +0 -1
- package/dist/src/core/middlewares/corsMiddleware/helpers/index.js +0 -17
- package/dist/src/core/middlewares/destroyerMiddleware/destroyerMiddleware.d.ts +0 -7
- package/dist/src/core/middlewares/destroyerMiddleware/destroyerMiddleware.js +0 -23
- package/dist/src/core/middlewares/index.d.ts +0 -7
- package/dist/src/core/middlewares/index.js +0 -23
- package/dist/src/core/middlewares/noCorsMiddleware/noCorsMiddleware.d.ts +0 -2
- package/dist/src/core/middlewares/noCorsMiddleware/noCorsMiddleware.js +0 -24
- package/dist/src/core/middlewares/notFoundMiddleware/helpers/getGraphqlUrlSuggestions/getGraphqlUrlSuggestions.d.ts +0 -11
- package/dist/src/core/middlewares/notFoundMiddleware/helpers/getGraphqlUrlSuggestions/getGraphqlUrlSuggestions.js +0 -19
- package/dist/src/core/middlewares/notFoundMiddleware/helpers/getLevenshteinDistance/getLevenshteinDistance.d.ts +0 -1
- package/dist/src/core/middlewares/notFoundMiddleware/helpers/getLevenshteinDistance/getLevenshteinDistance.js +0 -80
- package/dist/src/core/middlewares/notFoundMiddleware/helpers/getRestUrlSuggestions/getRestUrlSuggestions.d.ts +0 -11
- package/dist/src/core/middlewares/notFoundMiddleware/helpers/getRestUrlSuggestions/getRestUrlSuggestions.js +0 -34
- 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 -7
- 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 -5
- 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 -18
- package/dist/src/core/middlewares/notFoundMiddleware/helpers/index.d.ts +0 -3
- package/dist/src/core/middlewares/notFoundMiddleware/helpers/index.js +0 -19
- package/dist/src/core/middlewares/notFoundMiddleware/notFoundMiddleware.d.ts +0 -8
- package/dist/src/core/middlewares/notFoundMiddleware/notFoundMiddleware.js +0 -53
- package/dist/src/core/middlewares/requestInterceptorMiddleware/requestInterceptorMiddleware.d.ts +0 -3
- package/dist/src/core/middlewares/requestInterceptorMiddleware/requestInterceptorMiddleware.js +0 -11
- package/dist/src/core/middlewares/staticMiddleware/staticMiddleware.d.ts +0 -3
- package/dist/src/core/middlewares/staticMiddleware/staticMiddleware.js +0 -30
- package/dist/src/core/rest/createRestRoutes/createRestRoutes.d.ts +0 -3
- package/dist/src/core/rest/createRestRoutes/createRestRoutes.js +0 -44
- package/dist/src/core/rest/createRestRoutes/helpers/index.d.ts +0 -1
- package/dist/src/core/rest/createRestRoutes/helpers/index.js +0 -17
- package/dist/src/core/rest/createRestRoutes/helpers/prepareRestRequestConfigs/prepareRestRequestConfigs.d.ts +0 -2
- package/dist/src/core/rest/createRestRoutes/helpers/prepareRestRequestConfigs/prepareRestRequestConfigs.js +0 -32
- package/dist/src/core/rest/index.d.ts +0 -1
- package/dist/src/core/rest/index.js +0 -17
- package/dist/src/index.d.ts +0 -3
- package/dist/src/index.js +0 -19
- package/dist/src/server/createMockServer/createMockServer.d.ts +0 -3
- package/dist/src/server/createMockServer/createMockServer.js +0 -60
- package/dist/src/server/index.d.ts +0 -2
- package/dist/src/server/index.js +0 -18
- package/dist/src/server/startMockServer/startMockServer.d.ts +0 -5
- package/dist/src/server/startMockServer/startMockServer.js +0 -20
- 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/images/success.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 -12
- 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 -12
- 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 -85
- package/dist/src/utils/constants/appPath.d.ts +0 -1
- package/dist/src/utils/constants/appPath.js +0 -4
- package/dist/src/utils/constants/default.d.ts +0 -11
- package/dist/src/utils/constants/default.js +0 -14
- package/dist/src/utils/constants/index.d.ts +0 -2
- package/dist/src/utils/constants/index.js +0 -18
- package/dist/src/utils/helpers/config/index.d.ts +0 -1
- package/dist/src/utils/helpers/config/index.js +0 -17
- package/dist/src/utils/helpers/config/isEntitiesEqual/isEntityValuesEqual.d.ts +0 -1
- package/dist/src/utils/helpers/config/isEntitiesEqual/isEntityValuesEqual.js +0 -29
- package/dist/src/utils/helpers/graphql/getGraphQLInput/getGraphQLInput.d.ts +0 -3
- package/dist/src/utils/helpers/graphql/getGraphQLInput/getGraphQLInput.js +0 -21
- package/dist/src/utils/helpers/graphql/index.d.ts +0 -3
- package/dist/src/utils/helpers/graphql/index.js +0 -19
- package/dist/src/utils/helpers/graphql/parseGraphQLRequest/parseGraphQLRequest.d.ts +0 -3
- package/dist/src/utils/helpers/graphql/parseGraphQLRequest/parseGraphQLRequest.js +0 -12
- package/dist/src/utils/helpers/graphql/parseQuery/parseQuery.d.ts +0 -7
- package/dist/src/utils/helpers/graphql/parseQuery/parseQuery.js +0 -21
- package/dist/src/utils/helpers/index.d.ts +0 -6
- package/dist/src/utils/helpers/index.js +0 -22
- package/dist/src/utils/helpers/interceptors/callRequestInterceptor/callRequestInterceptor.d.ts +0 -8
- package/dist/src/utils/helpers/interceptors/callRequestInterceptor/callRequestInterceptor.js +0 -19
- package/dist/src/utils/helpers/interceptors/callResponseInterceptors/callResponseInterceptors.d.ts +0 -15
- package/dist/src/utils/helpers/interceptors/callResponseInterceptors/callResponseInterceptors.js +0 -52
- package/dist/src/utils/helpers/interceptors/helpers/setDelay.d.ts +0 -1
- package/dist/src/utils/helpers/interceptors/helpers/setDelay.js +0 -8
- package/dist/src/utils/helpers/interceptors/index.d.ts +0 -2
- package/dist/src/utils/helpers/interceptors/index.js +0 -18
- package/dist/src/utils/helpers/isPlainObject/isPlainObject.d.ts +0 -1
- package/dist/src/utils/helpers/isPlainObject/isPlainObject.js +0 -5
- package/dist/src/utils/helpers/sleep.d.ts +0 -1
- package/dist/src/utils/helpers/sleep.js +0 -7
- package/dist/src/utils/helpers/url/convertWin32PathToUnix/convertWin32PathToUnix.d.ts +0 -1
- package/dist/src/utils/helpers/url/convertWin32PathToUnix/convertWin32PathToUnix.js +0 -8
- package/dist/src/utils/helpers/url/getUrlParts/getUrlParts.d.ts +0 -1
- package/dist/src/utils/helpers/url/getUrlParts/getUrlParts.js +0 -6
- package/dist/src/utils/helpers/url/index.d.ts +0 -4
- package/dist/src/utils/helpers/url/index.js +0 -20
- package/dist/src/utils/helpers/url/removeLeadingAndTrailingSlashes/removeLeadingAndTrailingSlashes.d.ts +0 -1
- package/dist/src/utils/helpers/url/removeLeadingAndTrailingSlashes/removeLeadingAndTrailingSlashes.js +0 -5
- package/dist/src/utils/helpers/url/urlJoin/urlJoin.d.ts +0 -1
- package/dist/src/utils/helpers/url/urlJoin/urlJoin.js +0 -14
- package/dist/src/utils/types/graphql.d.ts +0 -34
- package/dist/src/utils/types/graphql.js +0 -2
- package/dist/src/utils/types/index.d.ts +0 -5
- package/dist/src/utils/types/index.js +0 -21
- package/dist/src/utils/types/interceptors.d.ts +0 -30
- package/dist/src/utils/types/interceptors.js +0 -2
- package/dist/src/utils/types/rest.d.ts +0 -39
- package/dist/src/utils/types/rest.js +0 -2
- package/dist/src/utils/types/server.d.ts +0 -47
- package/dist/src/utils/types/server.js +0 -2
- package/dist/src/utils/types/values.d.ts +0 -10
- package/dist/src/utils/types/values.js +0 -2
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DEFAULT = void 0;
|
|
4
|
-
exports.DEFAULT = {
|
|
5
|
-
PORT: 31299,
|
|
6
|
-
CORS: {
|
|
7
|
-
ORIGIN: '*',
|
|
8
|
-
METHODS: '*',
|
|
9
|
-
ALLOWED_HEADERS: '*',
|
|
10
|
-
EXPOSED_HEADERS: '*',
|
|
11
|
-
CREDENTIALS: true,
|
|
12
|
-
MAX_AGE: 3600
|
|
13
|
-
}
|
|
14
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./appPath"), exports);
|
|
18
|
-
__exportStar(require("./default"), exports);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './isEntitiesEqual/isEntityValuesEqual';
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./isEntitiesEqual/isEntityValuesEqual"), exports);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const isEntityValuesEqual: (firstEntityValue: any, secondEntityValue: any) => boolean;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isEntityValuesEqual = void 0;
|
|
4
|
-
const flat_1 = require("flat");
|
|
5
|
-
const isPlainObject_1 = require("../../isPlainObject/isPlainObject");
|
|
6
|
-
const isEntityValuesEqual = (firstEntityValue, secondEntityValue) => {
|
|
7
|
-
const isValuesArePlainObjects = (0, isPlainObject_1.isPlainObject)(firstEntityValue) && (0, isPlainObject_1.isPlainObject)(secondEntityValue);
|
|
8
|
-
if (isValuesArePlainObjects) {
|
|
9
|
-
const flattenFirstEntityValue = (0, flat_1.flatten)(firstEntityValue);
|
|
10
|
-
const flattenSecondEntityValue = (0, flat_1.flatten)(secondEntityValue);
|
|
11
|
-
return Object.keys(flattenFirstEntityValue).every((key) =>
|
|
12
|
-
// ✅ important:
|
|
13
|
-
// call 'toString' for ignore types of values
|
|
14
|
-
flattenFirstEntityValue[key].toString() === flattenSecondEntityValue[key]?.toString());
|
|
15
|
-
}
|
|
16
|
-
const isValuesAreArrays = Array.isArray(firstEntityValue) && Array.isArray(secondEntityValue);
|
|
17
|
-
if (isValuesAreArrays) {
|
|
18
|
-
const flattenFirstEntityValue = (0, flat_1.flatten)(firstEntityValue);
|
|
19
|
-
const flattenSecondEntityValue = (0, flat_1.flatten)(secondEntityValue);
|
|
20
|
-
return (Object.keys(flattenFirstEntityValue).length ===
|
|
21
|
-
Object.keys(flattenSecondEntityValue).length &&
|
|
22
|
-
Object.keys(flattenFirstEntityValue).every((key) =>
|
|
23
|
-
// ✅ important:
|
|
24
|
-
// call 'toString' for ignore types of values
|
|
25
|
-
flattenFirstEntityValue[key].toString() === flattenSecondEntityValue[key].toString()));
|
|
26
|
-
}
|
|
27
|
-
return `${firstEntityValue}` === `${secondEntityValue}`;
|
|
28
|
-
};
|
|
29
|
-
exports.isEntityValuesEqual = isEntityValuesEqual;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getGraphQLInput = void 0;
|
|
4
|
-
const getGraphQLInput = (request) => {
|
|
5
|
-
if (request.method === 'GET') {
|
|
6
|
-
const { query, variables } = request.query;
|
|
7
|
-
return {
|
|
8
|
-
query: query?.toString(),
|
|
9
|
-
variables: JSON.parse(variables ?? '{}')
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
if (request.method === 'POST') {
|
|
13
|
-
const { query, variables } = request.body;
|
|
14
|
-
return {
|
|
15
|
-
query,
|
|
16
|
-
variables: variables ?? {}
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
throw new Error('Not allowed request method for graphql request');
|
|
20
|
-
};
|
|
21
|
-
exports.getGraphQLInput = getGraphQLInput;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./parseGraphQLRequest/parseGraphQLRequest"), exports);
|
|
18
|
-
__exportStar(require("./parseQuery/parseQuery"), exports);
|
|
19
|
-
__exportStar(require("./getGraphQLInput/getGraphQLInput"), exports);
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseGraphQLRequest = void 0;
|
|
4
|
-
const getGraphQLInput_1 = require("../getGraphQLInput/getGraphQLInput");
|
|
5
|
-
const parseQuery_1 = require("../parseQuery/parseQuery");
|
|
6
|
-
const parseGraphQLRequest = (request) => {
|
|
7
|
-
const graphQLInput = (0, getGraphQLInput_1.getGraphQLInput)(request);
|
|
8
|
-
if (!graphQLInput.query)
|
|
9
|
-
return null;
|
|
10
|
-
return (0, parseQuery_1.parseQuery)(graphQLInput.query);
|
|
11
|
-
};
|
|
12
|
-
exports.parseGraphQLRequest = parseGraphQLRequest;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseQuery = void 0;
|
|
4
|
-
const graphql_1 = require("graphql");
|
|
5
|
-
const parseDocumentNode = (node) => {
|
|
6
|
-
const operationDefinition = node.definitions.find((definition) => definition.kind === 'OperationDefinition');
|
|
7
|
-
return {
|
|
8
|
-
operationType: operationDefinition.operation,
|
|
9
|
-
operationName: operationDefinition.name?.value ?? ''
|
|
10
|
-
};
|
|
11
|
-
};
|
|
12
|
-
const parseQuery = (query) => {
|
|
13
|
-
try {
|
|
14
|
-
const document = (0, graphql_1.parse)(query);
|
|
15
|
-
return parseDocumentNode(document);
|
|
16
|
-
}
|
|
17
|
-
catch {
|
|
18
|
-
return null;
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
exports.parseQuery = parseQuery;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./isPlainObject/isPlainObject"), exports);
|
|
18
|
-
__exportStar(require("./sleep"), exports);
|
|
19
|
-
__exportStar(require("./url"), exports);
|
|
20
|
-
__exportStar(require("./config"), exports);
|
|
21
|
-
__exportStar(require("./interceptors"), exports);
|
|
22
|
-
__exportStar(require("./graphql"), exports);
|
package/dist/src/utils/helpers/interceptors/callRequestInterceptor/callRequestInterceptor.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { Request } from 'express';
|
|
2
|
-
import type { RequestInterceptor } from '../../../types';
|
|
3
|
-
interface CallRequestInterceptorParams {
|
|
4
|
-
request: Request;
|
|
5
|
-
interceptor: RequestInterceptor;
|
|
6
|
-
}
|
|
7
|
-
export declare const callRequestInterceptor: (params: CallRequestInterceptorParams) => Promise<void>;
|
|
8
|
-
export {};
|
package/dist/src/utils/helpers/interceptors/callRequestInterceptor/callRequestInterceptor.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.callRequestInterceptor = void 0;
|
|
4
|
-
const setDelay_1 = require("../helpers/setDelay");
|
|
5
|
-
const callRequestInterceptor = async (params) => {
|
|
6
|
-
const { request, interceptor } = params;
|
|
7
|
-
const getHeader = (field) => request.headers[field];
|
|
8
|
-
const getHeaders = () => request.headers;
|
|
9
|
-
const getCookie = (name) => request.cookies[name];
|
|
10
|
-
const requestInterceptorParams = {
|
|
11
|
-
request,
|
|
12
|
-
setDelay: setDelay_1.setDelay,
|
|
13
|
-
getHeader,
|
|
14
|
-
getHeaders,
|
|
15
|
-
getCookie
|
|
16
|
-
};
|
|
17
|
-
await interceptor(requestInterceptorParams);
|
|
18
|
-
};
|
|
19
|
-
exports.callRequestInterceptor = callRequestInterceptor;
|
package/dist/src/utils/helpers/interceptors/callResponseInterceptors/callResponseInterceptors.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { Request, Response } from 'express';
|
|
2
|
-
import type { Data, ResponseInterceptor } from '../../../types';
|
|
3
|
-
interface CallResponseInterceptorsParams {
|
|
4
|
-
data: Data;
|
|
5
|
-
request: Request;
|
|
6
|
-
response: Response;
|
|
7
|
-
interceptors?: {
|
|
8
|
-
routeInterceptor?: ResponseInterceptor;
|
|
9
|
-
requestInterceptor?: ResponseInterceptor;
|
|
10
|
-
apiInterceptor?: ResponseInterceptor;
|
|
11
|
-
serverInterceptor?: ResponseInterceptor;
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
export declare const callResponseInterceptors: (params: CallResponseInterceptorsParams) => Promise<Data>;
|
|
15
|
-
export {};
|
package/dist/src/utils/helpers/interceptors/callResponseInterceptors/callResponseInterceptors.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.callResponseInterceptors = void 0;
|
|
4
|
-
const setDelay_1 = require("../helpers/setDelay");
|
|
5
|
-
const callResponseInterceptors = async (params) => {
|
|
6
|
-
const { data, request, response, interceptors } = params;
|
|
7
|
-
const getHeader = (field) => response.getHeader(field);
|
|
8
|
-
const getHeaders = () => response.getHeaders();
|
|
9
|
-
const getCookie = (name) => request.cookies[name];
|
|
10
|
-
const setStatusCode = (statusCode) => {
|
|
11
|
-
response.statusCode = statusCode;
|
|
12
|
-
};
|
|
13
|
-
const setHeader = (field, value) => response.set(field, value);
|
|
14
|
-
const appendHeader = (field, value) => response.append(field, value);
|
|
15
|
-
const setCookie = (name, value, options) => {
|
|
16
|
-
if (options) {
|
|
17
|
-
response.cookie(name, value, options);
|
|
18
|
-
}
|
|
19
|
-
response.cookie(name, value);
|
|
20
|
-
};
|
|
21
|
-
const clearCookie = (name, options) => response.clearCookie(name, options);
|
|
22
|
-
const attachment = (filename) => response.attachment(filename);
|
|
23
|
-
const ResponseInterceptorParams = {
|
|
24
|
-
request,
|
|
25
|
-
response,
|
|
26
|
-
setDelay: setDelay_1.setDelay,
|
|
27
|
-
setStatusCode,
|
|
28
|
-
setHeader,
|
|
29
|
-
appendHeader,
|
|
30
|
-
getHeader,
|
|
31
|
-
getHeaders,
|
|
32
|
-
setCookie,
|
|
33
|
-
getCookie,
|
|
34
|
-
clearCookie,
|
|
35
|
-
attachment
|
|
36
|
-
};
|
|
37
|
-
let updatedData = data;
|
|
38
|
-
if (interceptors?.routeInterceptor) {
|
|
39
|
-
updatedData = await interceptors.routeInterceptor(updatedData, ResponseInterceptorParams);
|
|
40
|
-
}
|
|
41
|
-
if (interceptors?.requestInterceptor) {
|
|
42
|
-
updatedData = await interceptors.requestInterceptor(updatedData, ResponseInterceptorParams);
|
|
43
|
-
}
|
|
44
|
-
if (interceptors?.apiInterceptor) {
|
|
45
|
-
updatedData = await interceptors.apiInterceptor(updatedData, ResponseInterceptorParams);
|
|
46
|
-
}
|
|
47
|
-
if (interceptors?.serverInterceptor) {
|
|
48
|
-
updatedData = await interceptors.serverInterceptor(updatedData, ResponseInterceptorParams);
|
|
49
|
-
}
|
|
50
|
-
return updatedData;
|
|
51
|
-
};
|
|
52
|
-
exports.callResponseInterceptors = callResponseInterceptors;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const setDelay: (delay: number) => Promise<void>;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.setDelay = void 0;
|
|
4
|
-
const sleep_1 = require("../../sleep");
|
|
5
|
-
const setDelay = async (delay) => {
|
|
6
|
-
await (0, sleep_1.sleep)(delay === Infinity ? 99999999 : delay);
|
|
7
|
-
};
|
|
8
|
-
exports.setDelay = setDelay;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./callRequestInterceptor/callRequestInterceptor"), exports);
|
|
18
|
-
__exportStar(require("./callResponseInterceptors/callResponseInterceptors"), exports);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const isPlainObject: (value: any) => value is Record<string, unknown>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const sleep: (milliseconds: number) => Promise<unknown>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const convertWin32PathToUnix: (win32Path: string) => string;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.convertWin32PathToUnix = void 0;
|
|
4
|
-
const convertWin32PathToUnix = (win32Path) => win32Path
|
|
5
|
-
.replace(/^\\\\\?\\/, '')
|
|
6
|
-
.replace(/\\/g, '/')
|
|
7
|
-
.replace(/\/\/+/g, '/');
|
|
8
|
-
exports.convertWin32PathToUnix = convertWin32PathToUnix;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const getUrlParts: (url: string) => string[];
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getUrlParts = void 0;
|
|
4
|
-
const removeLeadingAndTrailingSlashes_1 = require("../removeLeadingAndTrailingSlashes/removeLeadingAndTrailingSlashes");
|
|
5
|
-
const getUrlParts = (url) => (0, removeLeadingAndTrailingSlashes_1.removeLeadingAndTrailingSlashes)(url).split('/');
|
|
6
|
-
exports.getUrlParts = getUrlParts;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./convertWin32PathToUnix/convertWin32PathToUnix"), exports);
|
|
18
|
-
__exportStar(require("./getUrlParts/getUrlParts"), exports);
|
|
19
|
-
__exportStar(require("./removeLeadingAndTrailingSlashes/removeLeadingAndTrailingSlashes"), exports);
|
|
20
|
-
__exportStar(require("./urlJoin/urlJoin"), exports);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const removeLeadingAndTrailingSlashes: (string: string) => string;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.removeLeadingAndTrailingSlashes = void 0;
|
|
4
|
-
const removeLeadingAndTrailingSlashes = (string) => string.replace(/^\/+|\/+$/g, '');
|
|
5
|
-
exports.removeLeadingAndTrailingSlashes = removeLeadingAndTrailingSlashes;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const urlJoin: (...paths: string[]) => string;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.urlJoin = void 0;
|
|
7
|
-
const os_1 = __importDefault(require("os"));
|
|
8
|
-
const path_1 = __importDefault(require("path"));
|
|
9
|
-
const convertWin32PathToUnix_1 = require("../convertWin32PathToUnix/convertWin32PathToUnix");
|
|
10
|
-
const urlJoin = (...paths) => {
|
|
11
|
-
const pathsToJoin = os_1.default.platform() === 'win32' ? paths.map((path) => (0, convertWin32PathToUnix_1.convertWin32PathToUnix)(path)) : paths;
|
|
12
|
-
return path_1.default.posix.join(...pathsToJoin);
|
|
13
|
-
};
|
|
14
|
-
exports.urlJoin = urlJoin;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import type { Request } from 'express';
|
|
2
|
-
import type { Interceptors } from './interceptors';
|
|
3
|
-
import type { Data, PlainObject, VariablesValue } from './values';
|
|
4
|
-
export type GraphQLVariables = Record<string, any>;
|
|
5
|
-
export interface GraphQLInput {
|
|
6
|
-
query?: string;
|
|
7
|
-
variables: GraphQLVariables;
|
|
8
|
-
}
|
|
9
|
-
export type GraphQLEntities = 'headers' | 'cookies' | 'query' | 'variables';
|
|
10
|
-
export type GraphQLEntitiesValues = {
|
|
11
|
-
[Key in GraphQLEntities]: Key extends 'variables' ? VariablesValue : PlainObject;
|
|
12
|
-
};
|
|
13
|
-
export interface GraphQLOperationsEntities {
|
|
14
|
-
query: GraphQLEntities;
|
|
15
|
-
mutation: GraphQLEntities;
|
|
16
|
-
}
|
|
17
|
-
export type GraphQLOperationType = 'query' | 'mutation';
|
|
18
|
-
export type GraphQLOperationName = string | RegExp;
|
|
19
|
-
export type GraphQLRouteConfigEntities = {
|
|
20
|
-
[Key in GraphQLOperationsEntities[GraphQLOperationType]]?: GraphQLEntitiesValues[Key];
|
|
21
|
-
};
|
|
22
|
-
export interface GraphQLRouteConfig<Entities extends GraphQLRouteConfigEntities = GraphQLRouteConfigEntities> {
|
|
23
|
-
entities?: Entities;
|
|
24
|
-
data: ((request: Request, entities: Entities) => Data | Promise<Data>) | Data;
|
|
25
|
-
interceptors?: Pick<Interceptors, 'response'>;
|
|
26
|
-
}
|
|
27
|
-
export interface GraphQLQuery {
|
|
28
|
-
operationType: GraphQLOperationType;
|
|
29
|
-
operationName: GraphQLOperationName;
|
|
30
|
-
}
|
|
31
|
-
export interface GraphQLRequestConfig extends GraphQLQuery {
|
|
32
|
-
routes: GraphQLRouteConfig[];
|
|
33
|
-
interceptors?: Interceptors;
|
|
34
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./graphql"), exports);
|
|
18
|
-
__exportStar(require("./interceptors"), exports);
|
|
19
|
-
__exportStar(require("./rest"), exports);
|
|
20
|
-
__exportStar(require("./server"), exports);
|
|
21
|
-
__exportStar(require("./values"), exports);
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import type { CookieOptions, Request, Response } from 'express';
|
|
2
|
-
export type RequestInterceptorCookieValue = string | undefined;
|
|
3
|
-
export type RequestInterceptorHeaderValue = string | number | string[] | undefined;
|
|
4
|
-
export interface RequestInterceptorParams {
|
|
5
|
-
request: Request;
|
|
6
|
-
setDelay: (delay: number) => Promise<void>;
|
|
7
|
-
getCookie: (name: string) => RequestInterceptorCookieValue;
|
|
8
|
-
getHeader: (field: string) => RequestInterceptorHeaderValue;
|
|
9
|
-
getHeaders: () => Record<string, RequestInterceptorHeaderValue>;
|
|
10
|
-
}
|
|
11
|
-
export type RequestInterceptor = (params: RequestInterceptorParams) => void;
|
|
12
|
-
export interface ResponseInterceptorParams {
|
|
13
|
-
request: Request;
|
|
14
|
-
response: Response;
|
|
15
|
-
setDelay: (delay: number) => Promise<void>;
|
|
16
|
-
setStatusCode: (statusCode: number) => void;
|
|
17
|
-
setHeader: (field: string, value?: string | string[]) => void;
|
|
18
|
-
appendHeader: (field: string, value?: string[] | string) => void;
|
|
19
|
-
getHeader: (field: string) => RequestInterceptorHeaderValue;
|
|
20
|
-
getHeaders: () => Record<string, RequestInterceptorHeaderValue>;
|
|
21
|
-
setCookie: (name: string, value: string, options?: CookieOptions) => void;
|
|
22
|
-
getCookie: (name: string) => RequestInterceptorCookieValue;
|
|
23
|
-
clearCookie: (name: string, options?: CookieOptions) => void;
|
|
24
|
-
attachment: (filename: string) => void;
|
|
25
|
-
}
|
|
26
|
-
export type ResponseInterceptor<Data extends any = any> = (data: Data, params: ResponseInterceptorParams) => any;
|
|
27
|
-
export interface Interceptors {
|
|
28
|
-
request?: RequestInterceptor;
|
|
29
|
-
response?: ResponseInterceptor;
|
|
30
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import type { Request } from 'express';
|
|
2
|
-
import type { Interceptors } from './interceptors';
|
|
3
|
-
import type { BodyValue, CookiesValue, Data, HeadersValue, ParamsValue, QueryValue } from './values';
|
|
4
|
-
export type RestEntities = 'headers' | 'cookies' | 'query' | 'params' | 'body';
|
|
5
|
-
export type RestEntitiesValue = BodyValue | QueryValue | HeadersValue | CookiesValue | ParamsValue;
|
|
6
|
-
export type RestEntitiesValues = {
|
|
7
|
-
[Key in RestEntities]: Key extends 'body' ? BodyValue : Key extends 'query' ? QueryValue : Key extends 'headers' ? HeadersValue : Key extends 'cookies' ? CookiesValue : Key extends 'params' ? ParamsValue : never;
|
|
8
|
-
};
|
|
9
|
-
export interface RestMethodsEntities {
|
|
10
|
-
get: Exclude<RestEntities, 'body'>;
|
|
11
|
-
delete: Exclude<RestEntities, 'body'>;
|
|
12
|
-
post: RestEntities;
|
|
13
|
-
put: RestEntities;
|
|
14
|
-
patch: RestEntities;
|
|
15
|
-
options: Exclude<RestEntities, 'body'>;
|
|
16
|
-
}
|
|
17
|
-
export type RestRouteConfigEntities<Method extends RestMethod> = {
|
|
18
|
-
[Key in RestMethodsEntities[Method]]?: RestEntitiesValues[Key];
|
|
19
|
-
};
|
|
20
|
-
export interface RestRouteConfig<Method extends RestMethod, Entities extends RestRouteConfigEntities<Method> = RestRouteConfigEntities<Method>> {
|
|
21
|
-
entities?: Entities;
|
|
22
|
-
data: ((request: Request, entities: Entities) => Data | Promise<Data>) | Data;
|
|
23
|
-
interceptors?: Pick<Interceptors, 'response'>;
|
|
24
|
-
}
|
|
25
|
-
export type RestMethod = 'get' | 'post' | 'delete' | 'put' | 'patch' | 'options';
|
|
26
|
-
export type RestPathString = `/${string}`;
|
|
27
|
-
export interface BaseRestRequestConfig<Method extends RestMethod> {
|
|
28
|
-
path: RestPathString | RegExp;
|
|
29
|
-
method: Method;
|
|
30
|
-
routes: RestRouteConfig<Method>[];
|
|
31
|
-
interceptors?: Interceptors;
|
|
32
|
-
}
|
|
33
|
-
export type RestGetRequestConfig = BaseRestRequestConfig<'get'>;
|
|
34
|
-
export type RestPostRequestConfig = BaseRestRequestConfig<'post'>;
|
|
35
|
-
export type RestPutRequestConfig = BaseRestRequestConfig<'put'>;
|
|
36
|
-
export type RestDeleteRequestConfig = BaseRestRequestConfig<'delete'>;
|
|
37
|
-
export type RestPatchRequestConfig = BaseRestRequestConfig<'patch'>;
|
|
38
|
-
export type RestOptionsRequestConfig = BaseRestRequestConfig<'options'>;
|
|
39
|
-
export type RestRequestConfig = RestGetRequestConfig | RestPostRequestConfig | RestPutRequestConfig | RestDeleteRequestConfig | RestPatchRequestConfig | RestOptionsRequestConfig;
|