"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ACCESS_RIGHTS_ACCESS_MANAGERS_TYPE = exports.ACCESS_RIGHTS_OWNERS_TYPE = exports.ACCESS_RIGHTS_GROUP_TYPE = exports.ACCESS_RIGHT_OWNERS_NODE = exports.ACCESS_RIGHTS_DEFINITION_TYPE = exports.ACCESS_RIGHT_SUBTYPE = exports.AccessRightsPermissions = exports.AccessRightsSet = exports.AccessRightsCRUD = exports.AccessRightsPermission = exports.AccessRightsMgt = exports.AccessRightsScope = exports.AccessRightsEntity = exports.ACCESS_RIGHT_PROVIDER = void 0;
const entity_name_1 = require("../../models/entity-name");
const application_service_1 = require("../application.service");
exports.ACCESS_RIGHT_PROVIDER = 'AccessRightsProvider';
exports.AccessRightsEntity = entity_name_1.EntityName;
var AccessRightsScope;
(function (AccessRightsScope) {
    AccessRightsScope["create"] = "create";
    AccessRightsScope["read"] = "read";
    AccessRightsScope["update"] = "update";
    AccessRightsScope["delete"] = "delete";
    AccessRightsScope["method"] = "method";
    AccessRightsScope["view"] = "view";
})(AccessRightsScope = exports.AccessRightsScope || (exports.AccessRightsScope = {}));
var AccessRightsMgt;
(function (AccessRightsMgt) {
    AccessRightsMgt["access"] = "access";
    AccessRightsMgt["owner"] = "owner";
})(AccessRightsMgt = exports.AccessRightsMgt || (exports.AccessRightsMgt = {}));
var AccessRightsPermission;
(function (AccessRightsPermission) {
    AccessRightsPermission["create"] = "create";
    AccessRightsPermission["read"] = "read";
    AccessRightsPermission["update"] = "update";
    AccessRightsPermission["delete"] = "delete";
    AccessRightsPermission["access"] = "access";
    AccessRightsPermission["owner"] = "owner";
})(AccessRightsPermission = exports.AccessRightsPermission || (exports.AccessRightsPermission = {}));
class AccessRightsCRUD {
    constructor(create = false, read = false, update = false, _delete = false, forcedValues = {}) {
        this.create = create;
        this.read = read;
        this.update = update;
        this.delete = _delete;
        Object.assign(this, forcedValues);
        /*
        for (const scope in forcedValues) {
          this[scope as 'create' | 'read' | 'update' | 'delete'] = forcedValues[
            scope as 'create' | 'read' | 'update' | 'delete'
          ] as boolean;
        }*/
    }
}
exports.AccessRightsCRUD = AccessRightsCRUD;
class AccessRightsSet {
    constructor() {
        this.create = false;
        this.read = false;
        this.update = false;
        this.delete = false;
        this.access = false;
        this.owner = false;
    }
    toAccessRightsCRUD() {
        return new AccessRightsCRUD(this.create, this.read, this.update, this.delete);
    }
}
exports.AccessRightsSet = AccessRightsSet;
class AccessRightsPermissions {
    constructor() {
        this.treeRootNode = new AccessRightsSet();
        this.treeChildrenNodes = new AccessRightsSet();
    }
}
exports.AccessRightsPermissions = AccessRightsPermissions;
exports.ACCESS_RIGHT_SUBTYPE = {
    name: 'Access Rights',
    acl: false,
    owner: false,
    namespace: false,
    tree: true,
    min: 1,
    max: 1,
    exclusions: [],
    mandatories: [],
};
exports.ACCESS_RIGHTS_DEFINITION_TYPE = {
    name: application_service_1.ApplicationService.OBJECT_TYPE_NAMES.ACCESS_RIGHT_DEFINITION,
    contentType: application_service_1.ApplicationService.CONTENT_TYPE.JSON,
    iconView: 'fas fa-shield-alt',
    definition: {
        properties: {
            resetCreate: {
                type: 'boolean',
                title: 'Reset creation rights',
                default: false,
            },
            resetRead: {
                type: 'boolean',
                title: 'Reset read rights',
                default: false,
            },
            resetUpdate: {
                type: 'boolean',
                title: 'Reset update rights',
                default: false,
            },
            resetDelete: {
                type: 'boolean',
                title: 'Reset deletion rights',
                default: false,
            },
        },
    },
};
exports.ACCESS_RIGHT_OWNERS_NODE = {
    name: 'Owners',
    iconView: 'fas fa-id-card',
};
exports.ACCESS_RIGHTS_GROUP_TYPE = {
    name: application_service_1.ApplicationService.OBJECT_TYPE_NAMES.ACCESS_RIGHT_GROUP,
    contentType: application_service_1.ApplicationService.CONTENT_TYPE.JSON,
    iconView: 'fas fa-user-lock',
    definition: {
        properties: {
            grantCreate: {
                type: 'boolean',
                title: 'Grant creation rights',
                default: false,
            },
            grantRead: {
                type: 'boolean',
                title: 'Grant read rights',
                default: false,
            },
            grantUpdate: {
                type: 'boolean',
                title: 'Grant update rights',
                default: false,
            },
            grantDelete: {
                type: 'boolean',
                title: 'Grant deletion rights',
                default: false,
            },
        },
    },
};
exports.ACCESS_RIGHTS_OWNERS_TYPE = {
    name: application_service_1.ApplicationService.OBJECT_TYPE_NAMES.ACCESS_RIGHT_OWNERS,
    contentType: application_service_1.ApplicationService.CONTENT_TYPE.JSON,
    iconView: 'fas fa-user-secret',
    definition: {
        properties: {
            resetOwner: {
                type: 'boolean',
                title: 'Reset owners rights',
                default: false,
            },
        },
    },
};
exports.ACCESS_RIGHTS_ACCESS_MANAGERS_TYPE = {
    name: application_service_1.ApplicationService.OBJECT_TYPE_NAMES.ACCESS_RIGHT_ACCESS_MANAGERS,
    contentType: application_service_1.ApplicationService.CONTENT_TYPE.JSON,
    iconView: 'fas fa-user-shield',
    definition: {
        properties: {
            resetAccess: {
                type: 'boolean',
                title: 'Reset access management rights',
                default: false,
            },
        },
    },
};
//# sourceMappingURL=access-rights.const.js.map