import type {CapturedResultItem, EnumCapturedResultItemType} from "../core";
import type {EnumMappingStatus} from "./EnumMappingStatus";
import type {EnumValidationStatus} from "./EnumValidationStatus";

/**
 * The ParsedResultItem interface provides a structure representing the result items returned by Dynamsoft Code Parser.
 * @see {@link EnumCapturedResultItemType.CRIT_PARSED_RESULT}
 * */
export interface ParsedResultItem extends CapturedResultItem{
    /**
     * The code type of the parsed result.
     * */
    codeType: string

    /**
     * The parsed result as a JSON formatted string.
     * */
    jsonString: string

    /**
     * Optional fields containing parsed data. Each field represents a specific component
     * of the parsed code, such as a value, mapping status, or validation status.
     * The key is the field name, and the value is an object containing additional details.
     */
    parsedFields?: Record<string, ParsedField>
}


/**
 * The ParsedField interface defines the structure for individual parsed fields within a ParsedResultItem.
 * It provides information about the field value and its statuses.
 */
export interface ParsedField {
    /**
     * The value of the parsed field as a string. This represents the extracted data for the field.
     */
    value?: string,

    /**
     * The mapping status of the field.
     * @see {@link EnumMappingStatus}
     */
    mappingStatus?: EnumMappingStatus | number,

    /**
     * The validation status of the field.
     * @see {@link EnumValidationStatus}
     * */
    validationStatus?: EnumValidationStatus | number
}
