import { VALID_ACTIONS } from '../config.js';
export function check_regex(labels, regex) {
    if (regex === '*')
        return;
    const arr = (regex.includes('|'))
        ? regex.split('|')
        : [regex];
    arr.forEach(label => check_label_exists(label, labels));
}
export function check_label_exists(label, labels) {
    if (!labels.includes(label)) {
        throw new Error('label does not exist: ' + label);
    }
}
export function check_expires(timestamp, expires) {
    if (timestamp >= expires) {
        throw new Error(`time is expired:  ${String(timestamp)} >= ${expires}`);
    }
}
export function check_valid_action(action) {
    if (!VALID_ACTIONS.includes(action)) {
        throw new Error('invalid action: ' + action);
    }
}
