"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.processEntityFeatures = processEntityFeatures;
/**
 * Take an entity's features and merge them with the default features ensuring
 * that only the featires defined in the business rules are allowed through.
 * @param entityFeatures
 * @param defaultFeatures
 * @returns
 */
function processEntityFeatures(entityFeatures, defaultFeatures) {
    // Extend the defaults with the entity values
    const features = Object.assign(Object.assign({}, defaultFeatures), entityFeatures);
    // Remove any features that are not in the default features hash.
    // this prevents enabling features that are not defined in hub business rules
    const defaultKeys = Object.keys(defaultFeatures);
    const keysToRemove = Object.keys(features).reduce((acc, key) => {
        if (!defaultKeys.includes(key)) {
            acc.push(key);
        }
        return acc;
    }, []);
    // remove any keys that are not in the default hash
    keysToRemove.forEach((key) => {
        delete features[key];
    });
    return features;
}
//# sourceMappingURL=processEntityFeatures.js.map