#!/usr/bin/env node
/**
 * Schema validation test for requirements extraction
 * Quick test to validate the new schemas work correctly
 */
import { ExplicitRequirementSchema, InferredRequirementSchema, NonFunctionalRequirementSchema, ClarificationQuestionSchema, SuggestedProductRequirementsSchema } from './types.js';
// Test data for schema validation
const testExplicitRequirement = {
    requirement: "User authentication and login system",
    source_text: "users need to be able to log in and create accounts",
    confidence: "high"
};
const testInferredRequirement = {
    requirement: "Real-time notifications for task updates",
    rationale: "Critical for remote teams to stay synchronized",
    domain_pattern: "task-management-standard",
    priority: "high"
};
const testNonFunctionalRequirement = {
    category: "security",
    requirement: "Multi-factor authentication support",
    industry_standard: true,
    customization_needed: false
};
const testClarificationQuestion = {
    category: "scalability",
    question: "What is the expected number of concurrent users?",
    impact_if_unclear: "Affects database scaling and infrastructure decisions",
    suggested_default: "Design for 50 users per organization"
};
const testSuggestedProductRequirements = {
    explicit_requirements: [testExplicitRequirement],
    inferred_functional_requirements: [testInferredRequirement],
    suggested_non_functional_requirements: [testNonFunctionalRequirement],
    requirements_clarification_questions: [testClarificationQuestion]
};
// Run validation tests
function runSchemaTests() {
    console.log('🧪 Running schema validation tests...\n');
    try {
        // Test ExplicitRequirementSchema
        console.log('Testing ExplicitRequirementSchema...');
        const validExplicit = ExplicitRequirementSchema.parse(testExplicitRequirement);
        console.log('✅ ExplicitRequirementSchema validation passed');
        // Test InferredRequirementSchema
        console.log('Testing InferredRequirementSchema...');
        const validInferred = InferredRequirementSchema.parse(testInferredRequirement);
        console.log('✅ InferredRequirementSchema validation passed');
        // Test NonFunctionalRequirementSchema
        console.log('Testing NonFunctionalRequirementSchema...');
        const validNonFunctional = NonFunctionalRequirementSchema.parse(testNonFunctionalRequirement);
        console.log('✅ NonFunctionalRequirementSchema validation passed');
        // Test ClarificationQuestionSchema
        console.log('Testing ClarificationQuestionSchema...');
        const validClarification = ClarificationQuestionSchema.parse(testClarificationQuestion);
        console.log('✅ ClarificationQuestionSchema validation passed');
        // Test SuggestedProductRequirementsSchema
        console.log('Testing SuggestedProductRequirementsSchema...');
        const validRequirements = SuggestedProductRequirementsSchema.parse(testSuggestedProductRequirements);
        console.log('✅ SuggestedProductRequirementsSchema validation passed');
        console.log('\n🎉 All schema validation tests passed!');
        // Test invalid data
        console.log('\n🔍 Testing invalid data handling...');
        try {
            ExplicitRequirementSchema.parse({
                requirement: "Test",
                source_text: "Test",
                confidence: "invalid" // Should fail
            });
            console.log('❌ Should have failed validation for invalid confidence level');
        }
        catch (error) {
            console.log('✅ Correctly rejected invalid confidence level');
        }
        try {
            InferredRequirementSchema.parse({
                requirement: "Test",
                rationale: "Test",
                domain_pattern: "Test"
                // Missing priority - should fail
            });
            console.log('❌ Should have failed validation for missing priority');
        }
        catch (error) {
            console.log('✅ Correctly rejected missing required field');
        }
        console.log('\n✨ All validation tests completed successfully!');
    }
    catch (error) {
        console.error('❌ Schema validation failed:', error);
        process.exit(1);
    }
}
// Run the tests
runSchemaTests();
