"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 END () {
        return END;
    },
    get MIGRATION_PREFIX () {
        return MIGRATION_PREFIX;
    },
    get START () {
        return START;
    },
    get STEP_PREFIX () {
        return STEP_PREFIX;
    },
    get migrationFile () {
        return migrationFile;
    },
    get needsMigration () {
        return needsMigration;
    },
    get needsStep () {
        return needsStep;
    },
    get onlyMigrations () {
        return onlyMigrations;
    },
    get onlySteps () {
        return onlySteps;
    },
    get stepFile () {
        return stepFile;
    }
});
const _nodepath = require("node:path");
const START = ':start:';
const END = ':end:';
const MIGRATION_PREFIX = 'migration/';
const STEP_PREFIX = 'upgrade/';
const needsStep = (step)=>{
    const re = /^(?<file>.+?)(\/(?<index>\d+))?$/;
    const { file, index } = re.exec(step)?.groups || {};
    if (!file) throw new Error(`Invalid step name: ${step}`);
    if (!index) throw new Error('You must provide an index when depending on upgrade steps');
    return `upgrade/${(0, _nodepath.basename)(file, (0, _nodepath.extname)(file))}/${index}`;
};
const needsMigration = (mig)=>`migration/${(0, _nodepath.basename)(mig, (0, _nodepath.extname)(mig))}`;
const onlySteps = (needs)=>needs.filter((need)=>need.startsWith(STEP_PREFIX));
const onlyMigrations = (needs)=>needs.filter((need)=>need.startsWith(MIGRATION_PREFIX));
const stepFile = (str)=>str.split('/')[1] + '.js';
const migrationFile = (str)=>str.split('/')[1] + '.js';

//# sourceMappingURL=step.js.map