"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.buildQuickFixForValidationResult = buildQuickFixForValidationResult;
exports.getQuickFixSupportCatalog = getQuickFixSupportCatalog;
exports.attachQuickFixMetadataToResults = attachQuickFixMetadataToResults;
const createFileQuickFixRuleIds = ['AP-API-001', 'AP-ARCH-001'];
const suggestionOnlyQuickFixRuleIds = ['AP-DEP-005'];
const minimalOpenApiScaffold = `openapi: 3.0.3
info:
  title: Service API
  version: 0.1.0
paths: {}
`;
function buildQuickFixForApiOpenApiMissing(result) {
    if (result.id !== 'AP-API-001' ||
        result.passed ||
        !result.message.includes('contracts/openapi.yaml is missing')) {
        return undefined;
    }
    return {
        available: true,
        type: 'create-file',
        description: 'Create a minimal OpenAPI scaffold at contracts/openapi.yaml.',
        actions: [
            {
                actionType: 'create-file',
                targetPath: 'contracts/openapi.yaml',
                content: minimalOpenApiScaffold,
            },
        ],
    };
}
function buildQuickFixForArchModularStructureMissing(result) {
    if (result.id !== 'AP-ARCH-001' || result.passed) {
        return undefined;
    }
    const configuredRootMatch = result.message.match(/configured module root '([^']+)'/u);
    const modulesRoot = configuredRootMatch?.[1] ?? 'src/modules';
    const normalizedModulesRoot = modulesRoot.replace(/\\/g, '/');
    return {
        available: true,
        type: 'create-file',
        description: `Create a minimal module scaffold under ${normalizedModulesRoot}.`,
        actions: [
            {
                actionType: 'create-file',
                targetPath: `${normalizedModulesRoot}/README.md`,
                content: '# Modules\n\nDefine module boundaries here.\n',
            },
            {
                actionType: 'create-file',
                targetPath: `${normalizedModulesRoot}/placeholder/index.ts`,
                content: 'export {};\n',
            },
        ],
    };
}
function buildQuickFixForDepPublicSurfaceViolation(result) {
    if (result.id !== 'AP-DEP-005' ||
        result.passed ||
        !result.message.includes('imports a non-public path from module')) {
        return undefined;
    }
    return {
        available: true,
        type: 'suggestion',
        description: 'Import from the target module public entrypoint instead of an internal path.',
    };
}
function buildQuickFixForValidationResult(result) {
    return (buildQuickFixForApiOpenApiMissing(result) ??
        buildQuickFixForArchModularStructureMissing(result) ??
        buildQuickFixForDepPublicSurfaceViolation(result));
}
function getQuickFixSupportCatalog() {
    return {
        createFileRuleIds: createFileQuickFixRuleIds,
        suggestionOnlyRuleIds: suggestionOnlyQuickFixRuleIds,
    };
}
function attachQuickFixMetadataToResults(results) {
    return results.map((result) => {
        const quickFix = buildQuickFixForValidationResult(result);
        return quickFix ? { ...result, quickFix } : result;
    });
}
//# sourceMappingURL=quickFixProviders.js.map