UNPKG

@sap-cloud-sdk/core

Version:
37 lines 1.45 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.defaultDisallowedKeys = exports.filterCustomRequestConfig = void 0; var util_1 = require("@sap-cloud-sdk/util"); var logger = (0, util_1.createLogger)({ package: 'core', messageContext: 'http-request-config' }); /** * Filter disallowed keys from a given custom request config object. * @param customRequestConfig - a given custom request config object to be filtered * @param disallowedKeys - A list of keys that are not allowed to be customized. * @returns Filtered custom request config object. */ function filterCustomRequestConfig(customRequestConfig, disallowedKeys) { if (disallowedKeys === void 0) { disallowedKeys = exports.defaultDisallowedKeys; } var removedKeys = Object.keys(customRequestConfig).filter(function (key) { return disallowedKeys.includes(key); }); if (removedKeys.length) { logger.warn("The following keys are found in the custom request config that will be removed: ".concat(removedKeys.join(', '))); } return (0, util_1.exclude)(disallowedKeys, customRequestConfig); } exports.filterCustomRequestConfig = filterCustomRequestConfig; /** * A list of request config keys that are not allowed to be customized by default. */ exports.defaultDisallowedKeys = [ 'method', 'url', 'baseURL', 'data', 'headers', 'params' ]; //# sourceMappingURL=http-request-config.js.map