UNPKG

1.45 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.defaultDisallowedKeys = exports.filterCustomRequestConfig = void 0;
4var util_1 = require("@sap-cloud-sdk/util");
5var logger = (0, util_1.createLogger)({
6 package: 'core',
7 messageContext: 'http-request-config'
8});
9/**
10 * Filter disallowed keys from a given custom request config object.
11 * @param customRequestConfig - a given custom request config object to be filtered
12 * @param disallowedKeys - A list of keys that are not allowed to be customized.
13 * @returns Filtered custom request config object.
14 */
15function filterCustomRequestConfig(customRequestConfig, disallowedKeys) {
16 if (disallowedKeys === void 0) { disallowedKeys = exports.defaultDisallowedKeys; }
17 var removedKeys = Object.keys(customRequestConfig).filter(function (key) {
18 return disallowedKeys.includes(key);
19 });
20 if (removedKeys.length) {
21 logger.warn("The following keys are found in the custom request config that will be removed: ".concat(removedKeys.join(', ')));
22 }
23 return (0, util_1.exclude)(disallowedKeys, customRequestConfig);
24}
25exports.filterCustomRequestConfig = filterCustomRequestConfig;
26/**
27 * A list of request config keys that are not allowed to be customized by default.
28 */
29exports.defaultDisallowedKeys = [
30 'method',
31 'url',
32 'baseURL',
33 'data',
34 'headers',
35 'params'
36];
37//# sourceMappingURL=http-request-config.js.map
\No newline at end of file