# This file was auto-generated by Fern from our API Definition.

import typing

import typing_extensions
from ..core.serialization import FieldMetadata
from ..types.json_object import JsonObject
from ..types.legacy_processor_run_type import LegacyProcessorRunType
from ..types.legacy_processor_status import LegacyProcessorStatus
from .file import FileParams
from .legacy_document_processor_run_credits import LegacyDocumentProcessorRunCreditsParams
from .legacy_extraction_output_edits import LegacyExtractionOutputEditsParams
from .legacy_processor_output import LegacyProcessorOutputParams
from .legacy_processor_run_config import LegacyProcessorRunConfigParams
from .legacy_processor_run_merged_processors_item import LegacyProcessorRunMergedProcessorsItemParams


class LegacyProcessorRunParams(typing_extensions.TypedDict):
    object: str
    """
    The type of response. In this case, it will always be `"document_processor_run"`.
    """

    id: str
    """
    The unique identifier for this processor run.
    
    Example: `"exr_Xj8mK2pL9nR4vT7qY5wZ"`
    """

    processor_id: typing_extensions.Annotated[str, FieldMetadata(alias="processorId")]
    """
    The ID of the processor used for this run.
    
    Example: `"ex_Xj8mK2pL9nR4vT7qY5wZ"`
    """

    processor_version_id: typing_extensions.Annotated[str, FieldMetadata(alias="processorVersionId")]
    """
    The ID of the specific processor version used.
    """

    processor_name: typing_extensions.Annotated[str, FieldMetadata(alias="processorName")]
    """
    The name of the processor.
    
    Example: `"Invoice Processor"`
    """

    status: LegacyProcessorStatus
    output: LegacyProcessorOutputParams
    """
    The final output, either reviewed or initial.
    
    Conforms to the shape of output types and depends on the processor type and configuration shape.
    """

    failure_reason: typing_extensions.NotRequired[
        typing_extensions.Annotated[str, FieldMetadata(alias="failureReason")]
    ]
    """
    If the run failed, indicates the reason for failure.
    """

    failure_message: typing_extensions.NotRequired[
        typing_extensions.Annotated[str, FieldMetadata(alias="failureMessage")]
    ]
    """
    If the run failed, provides a detailed message about the failure.
    """

    metadata: typing_extensions.NotRequired[JsonObject]
    """
    Any metadata that was provided when creating the processor run.
    """

    reviewed: bool
    """
    Indicates whether the run has been reviewed.
    """

    edited: bool
    """
    Indicates whether the run results have been edited.
    """

    edits: typing.Dict[str, LegacyExtractionOutputEditsParams]
    type: LegacyProcessorRunType
    """
    The type of processor:
    * `"CLASSIFY"` - Classifies documents into categories
    * `"EXTRACT"` - Extracts structured data from documents
    * `"SPLITTER"` - Splits documents into multiple parts
    """

    config: LegacyProcessorRunConfigParams
    """
    The configuration used for this processor run. The type of configuration will match the processor type.
    """

    initial_output: typing_extensions.NotRequired[
        typing_extensions.Annotated[LegacyProcessorOutputParams, FieldMetadata(alias="initialOutput")]
    ]
    """
    The initial output from the processor run. The type of output will match the processor type.
    """

    reviewed_output: typing_extensions.NotRequired[
        typing_extensions.Annotated[LegacyProcessorOutputParams, FieldMetadata(alias="reviewedOutput")]
    ]
    """
    The output after review, if any.
    """

    files: typing.Sequence[FileParams]
    """
    Details of the processed files.
    
    If this was a file generated from a splitter processor, this will be the sub file.
    
    See the File object for more details.
    """

    merged_processors: typing_extensions.Annotated[
        typing.Sequence[LegacyProcessorRunMergedProcessorsItemParams], FieldMetadata(alias="mergedProcessors")
    ]
    """
    An array of processors that were merged to create this output. Will be an empty array unless this output was the result of a MergeExtraction step in a workflow.
    """

    url: str
    """
    The URL to view the processor run.
    """

    usage: typing_extensions.NotRequired[LegacyDocumentProcessorRunCreditsParams]
