import path from "node:path";
import { Paths } from "../../const.js";
import { matchPath, renderPath } from "../../transform/shared.js";
export const isApiFilePath = (filePath) => filePath.startsWith("apis/");
const allApiArtifacts = matchPath("apis/:apiName/**");
export const toGeneratedApiPath = (filePath) => {
    const match = allApiArtifacts(filePath);
    if (match.matched) {
        return renderPath(Paths.GeneratedApis, {
            apiName: `${match.params.apiName}.ts`,
        });
    }
    return undefined;
};
const generatedApis = matchPath(Paths.GeneratedApis);
export const parseGeneratedApiPath = (filePath) => {
    const match = generatedApis(filePath);
    if (match.matched && match.params.apiName.endsWith(".ts")) {
        const { apiName } = match.params;
        return {
            apiName: path.basename(apiName, ".ts"),
        };
    }
    return undefined;
};
export const isDirectPagePath = (filePath) => {
    // if it's pages/xyz.tsx return true
    // if it's other/xyz.tsx return false
    // if it's pages/pageName/xyz.tsx return false
    return /^pages\/[^/]+\.tsx/.test(filePath);
};
//# sourceMappingURL=shared-helpers.js.map