
import {
    SetMedia,
    MediaAddLabel,
    MediaRemoveLabel
} from "./functions/media.mjs";

import {
    SetPrinter,
    DeletePrinter,
    GetPrinter,
    GetPrinters
} from "./functions/printer.mjs";




function checkPermissions(userPermissions, requestedPermission) {
    let result = false;

    for (let counter = requestedPermission.split(".").length; counter > 0; counter--) {
        if (userPermissions.includes(requestedPermission)) {
            result = true;
            break;
        }

        requestedPermission = requestedPermission.substr(0, requestedPermission.lastIndexOf("."))
    }

    return result;
}

// Beispielverwendung:
const userPermissions = [
    "mongo"
];

const permissionsResult = checkPermissions(userPermissions, "settings.printer");
