/**
 * Domain-Specific Rule File Type Definitions
 *
 * Defines the structure for different types of inference rule files.
 * Each rule file type serves a specific purpose and has an optimized structure.
 */
// ============================================================================
// Type Guards
// ============================================================================
export function isPatternInferenceFile(file) {
    return file.ruleFileType === 'pattern-inference';
}
export function isConfigurationFile(file) {
    return file.ruleFileType === 'configuration';
}
export function isExpansionTemplateFile(file) {
    return file.ruleFileType === 'expansion-template';
}
export function isDeploymentFile(file) {
    return file.ruleFileType === 'deployment';
}
export function isLegacyRuleFile(file) {
    return !file.ruleFileType && file.logical_inference !== undefined;
}
// ============================================================================
// Format Detection Utilities
// ============================================================================
export function detectRuleFileType(content) {
    if (content.ruleFileType) {
        return content.ruleFileType;
    }
    // Legacy detection - check for either logical_inference OR deployment_inference
    if (content.logical_inference) {
        return 'legacy';
    }
    // Also check for deployment_inference (legacy format for deployment rules)
    if (content.deployment_inference) {
        return 'legacy';
    }
    throw new Error('Unable to detect rule file type - missing ruleFileType field');
}
export function migrateLegacyToNewFormat(legacy) {
    const result = [];
    for (const category in legacy.logical_inference) {
        const categoryData = legacy.logical_inference[category];
        // v3.1 pattern-based rules (arrays)
        if (Array.isArray(categoryData)) {
            result.push({
                ruleFileType: 'pattern-inference',
                version: legacy.version,
                description: legacy.description,
                category: category,
                rules: categoryData
            });
        }
        // v3.4 component mappings
        else if (category === 'component_type_mapping') {
            result.push({
                ruleFileType: 'configuration',
                version: legacy.version,
                description: legacy.description,
                category: 'component-mappings',
                mappings: categoryData
            });
        }
        // v3.4 specialist views
        else if (category === 'specialist_views') {
            result.push({
                ruleFileType: 'expansion-template',
                version: legacy.version,
                description: legacy.description,
                category: 'specialist-views',
                templates: categoryData
            });
        }
    }
    return result;
}
//# sourceMappingURL=rule-file-types.js.map