import { v4 as uuid } from 'uuid';
export default class Policy {
    constructor() {
        this.uuidStr = uuid();
        this.dataAttributesList = [];
        this.dissemList = [];
    }
    // private schemaVersionStr = Policy.CURRENT_VERSION;
    /**
     * Adds a group of entities, to the Policy's dissem list
     *
     * @param entities The entities will be added to the policy and
     * they will have access to the TDF
     */
    addEntities(entities) {
        this.dissemList.concat(entities);
        // Remove any duplicates
        this.dissemList = this.dissemList.filter(function (elem, index, self) {
            return index === self.indexOf(elem);
        });
    }
    /**
     *
     * Adds an Attribute object to the policy
     *
     * @param attribute will be added to the policy
     */
    addAttribute(attribute) {
        this.dataAttributesList.push(attribute);
    }
    /**
     * Returns the JSON string of Policy object
     *
     * @return {string} [The constructed Policy object as JSON string]
     */
    toJSON() {
        return JSON.stringify({
            uuid: this.uuidStr,
            body: {
                dataAttributes: this.dataAttributesList,
                dissem: this.dissemList,
            },
        });
    }
}
Policy.CURRENT_VERSION = '1.1.0';
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiUG9saWN5LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vc3JjL3RkZi9Qb2xpY3kudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsT0FBTyxFQUFFLEVBQUUsSUFBSSxJQUFJLEVBQUUsTUFBTSxNQUFNLENBQUM7QUFFbEMsTUFBTSxDQUFDLE9BQU8sT0FBTyxNQUFNO0lBQTNCO1FBR1UsWUFBTyxHQUFHLElBQUksRUFBRSxDQUFDO1FBQ2pCLHVCQUFrQixHQUFzQixFQUFFLENBQUM7UUFDM0MsZUFBVSxHQUFhLEVBQUUsQ0FBQztJQTBDcEMsQ0FBQztJQXpDQyxxREFBcUQ7SUFFckQ7Ozs7O09BS0c7SUFDSCxXQUFXLENBQUMsUUFBa0I7UUFDNUIsSUFBSSxDQUFDLFVBQVUsQ0FBQyxNQUFNLENBQUMsUUFBUSxDQUFDLENBQUM7U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