import coerce from 'semver/functions/coerce.js';
import gte from 'semver/functions/gte.js';
export const createVersionPredicate = (featureVersion, comparison) => {
    const coercedFeatureVersion = coerce(featureVersion);
    if (!coercedFeatureVersion) {
        throw new Error(`Could not create predicate version "${featureVersion}" is not valid`);
    }
    return (apiVersion) => {
        const coercedApiVersion = coerce(apiVersion);
        if (!coercedApiVersion) {
            throw new Error(`Version "${apiVersion}" is not valid and could not be coerced`);
        }
        return comparison(coercedApiVersion, coercedFeatureVersion);
    };
};
export const workflowsEnabled = createVersionPredicate('2.0.0', gte);
export const whereClauseEnabled = createVersionPredicate('2.0.0', gte);
