"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
function _export(target, all) {
    for(var name in all)Object.defineProperty(target, name, {
        enumerable: true,
        get: Object.getOwnPropertyDescriptor(all, name).get
    });
}
_export(exports, {
    get AUTH_ERROR_REASON () {
        return AUTH_ERROR_REASON;
    },
    get PERMS () {
        return PERMS;
    },
    get PERM_GROUP () {
        return PERM_GROUP;
    },
    get ROLES () {
        return ROLES;
    },
    get ROLE_PERMS () {
        return ROLE_PERMS;
    },
    get allPerms () {
        return allPerms;
    },
    get flattenPermissionDefinition () {
        return flattenPermissionDefinition;
    }
});
const _lodash = require("lodash");
const AUTH_ERROR_REASON = {
    IncorrectCredentials: "IncorrectCredentials",
    InvalidOrExpiredRefreshToken: "InvalidOrExpiredRefreshToken",
    InvalidOrExpiredAuthToken: "InvalidOrExpiredAuthToken",
    PasswordChangeRequired: "PasswordChangeRequired",
    LoginRequired: "LoginRequired",
    AccountNotVerified: "AccountNotVerified"
};
const PERM_GROUP = {
    PrinterFiles: "PrinterFiles",
    PrinterSettings: "PrinterSettings",
    Jobs: "Jobs",
    Floors: "Floors",
    ServerInfo: "ServerInfo",
    PrinterMaintenanceLog: "PrinterMaintenanceLog"
};
const PERMS = {
    [PERM_GROUP.PrinterFiles]: {
        Default: "PrinterFiles.Default",
        Get: "PrinterFiles.Get",
        Delete: "PrinterFiles.Delete",
        Clear: "PrinterFiles.Clear",
        Upload: "PrinterFiles.Upload",
        Actions: "PrinterFiles.Actions"
    },
    [PERM_GROUP.Jobs]: {
        Default: "Jobs.Default",
        List: "Jobs.List"
    },
    [PERM_GROUP.Floors]: {
        Default: "Floors.Default",
        List: "Floors.List",
        Get: "Floors.Get",
        Create: "Floors.Create",
        Update: "Floors.Update",
        Delete: "Floors.Delete"
    },
    [PERM_GROUP.PrinterSettings]: {
        Default: "PrinterSettings.Default",
        Get: "PrinterSettings.Get"
    },
    [PERM_GROUP.ServerInfo]: {
        Default: "ServerInfo.Default",
        Get: "ServerInfo.Get"
    },
    [PERM_GROUP.PrinterMaintenanceLog]: {
        Default: "PrinterMaintenanceLog.Default",
        List: "PrinterMaintenanceLog.List",
        Get: "PrinterMaintenanceLog.Get",
        Create: "PrinterMaintenanceLog.Create",
        Complete: "PrinterMaintenanceLog.Complete",
        Delete: "PrinterMaintenanceLog.Delete"
    }
};
function flattenPermissionDefinition() {
    const permissions = [];
    for (const key of Object.values(PERM_GROUP)){
        for (const permissionName of Object.values(PERMS[key])){
            permissions.push(permissionName);
        }
    }
    return permissions;
}
function allPerms(group) {
    if (!group || !PERMS[group]) throw new Error(`Permission group name '${group}' was not found`);
    return Object.values(PERMS[group]);
}
const ROLES = {
    ADMIN: "ADMIN",
    OPERATOR: "OPERATOR",
    GUEST: "GUEST"
};
const ROLE_PERMS = {
    [ROLES.ADMIN]: (0, _lodash.union)(allPerms(PERM_GROUP.Jobs), allPerms(PERM_GROUP.Floors), allPerms(PERM_GROUP.PrinterFiles), allPerms(PERM_GROUP.PrinterSettings), allPerms(PERM_GROUP.ServerInfo), allPerms(PERM_GROUP.PrinterMaintenanceLog)),
    [ROLES.OPERATOR]: (0, _lodash.union)(allPerms(PERM_GROUP.Jobs), allPerms(PERM_GROUP.Floors), allPerms(PERM_GROUP.PrinterFiles), allPerms(PERM_GROUP.PrinterSettings), allPerms(PERM_GROUP.PrinterMaintenanceLog)),
    [ROLES.GUEST]: []
};

//# sourceMappingURL=authorization.constants.js.map