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

import typing

import typing_extensions
from ..core.serialization import FieldMetadata
from ..types.created_at import CreatedAt
from ..types.processor_run_status import ProcessorRunStatus
from ..types.run_metadata import RunMetadata
from ..types.updated_at import UpdatedAt
from .file_summary import FileSummaryParams
from .run_usage import RunUsageParams
from .split_config import SplitConfigParams
from .split_output import SplitOutputParams
from .splitter_summary import SplitterSummaryParams
from .splitter_version_summary import SplitterVersionSummaryParams


class SplitRunParams(typing_extensions.TypedDict):
    """
    Split run object.
    """

    object: typing.Literal["split_run"]
    """
    The type of object. Will always be `"split_run"`.
    """

    id: str
    """
    The unique identifier for this split run.
    
    Example: `"splr_Xj8mK2pL9nR4vT7qY5wZ"`
    """

    splitter: typing.Optional[SplitterSummaryParams]
    """
    The splitter that was used for this run.
    
    **Availability:** Present when a splitter reference was provided. Not present when using inline `config`.
    """

    splitter_version: typing_extensions.Annotated[
        typing.Optional[SplitterVersionSummaryParams], FieldMetadata(alias="splitterVersion")
    ]
    """
    The version of the splitter that was used for this run.
    
    **Availability:** Present when a splitter reference was provided. Not present when using inline `config`.
    """

    status: ProcessorRunStatus
    output: typing.Optional[SplitOutputParams]
    """
    The final output, either reviewed or initial.
    
    **Availability:** Present when `status` is `"PROCESSED"`.
    """

    initial_output: typing_extensions.Annotated[
        typing.Optional[SplitOutputParams], FieldMetadata(alias="initialOutput")
    ]
    """
    The initial output from the split run, before any review edits.
    
    **Availability:** Present when `reviewed` is `true`.
    """

    reviewed_output: typing_extensions.Annotated[
        typing.Optional[SplitOutputParams], FieldMetadata(alias="reviewedOutput")
    ]
    """
    The output after human review.
    
    **Availability:** Present when `reviewed` is `true`.
    """

    failure_reason: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="failureReason")]
    """
    The reason for failure.
    
    **Availability:** Present when `status` is `"FAILED"`.
    
    Possible values include:
    * `ABORTED` - The run was aborted by the user
    * `INTERNAL_ERROR` - An unexpected internal error occurred
    * `FAILED_TO_PROCESS_FILE` - Failed to process the file (e.g., OCR failure, file access issues)
    * `INVALID_PROCESSOR` - The processor configuration is invalid
    * `INVALID_CONFIGURATION` - The provided configuration is incompatible with the selected model
    * `PARSING_ERROR` - Failed to parse the splitting output
    * `PRE_PROCESSING_FAILURE` - An error occurred during preprocessing
    * `POST_PROCESSING_FAILURE` - An error occurred during postprocessing
    * `OUT_OF_CREDITS` - Insufficient credits to run the splitter
    
    **Note:** Additional failure reasons may be added in the future. Your integration should handle unknown values gracefully.
    """

    failure_message: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="failureMessage")]
    """
    A detailed message about the failure.
    
    **Availability:** Present when `status` is `"FAILED"`.
    """

    metadata: typing.Optional[RunMetadata]
    """
    Any metadata that was provided when creating the split run.
    
    **Availability:** Present when metadata was provided during creation.
    """

    reviewed: bool
    """
    Indicates whether the run has been reviewed by a human.
    """

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

    config: SplitConfigParams
    """
    The configuration used for this split run.
    """

    file: FileSummaryParams
    """
    The file that was processed.
    """

    parse_run_id: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="parseRunId")]
    """
    The ID of the parse run that was used for this split run.
    
    **Availability:** Present when a parse run was created.
    """

    dashboard_url: typing_extensions.Annotated[str, FieldMetadata(alias="dashboardUrl")]
    """
    The URL to view the split run in the Extend dashboard.
    """

    usage: typing.Optional[RunUsageParams]
    """
    Usage credits consumed by this run.
    
    **Availability:** Present when `status` is `"PROCESSED"`.
    """

    created_at: typing_extensions.Annotated[CreatedAt, FieldMetadata(alias="createdAt")]
    updated_at: typing_extensions.Annotated[UpdatedAt, FieldMetadata(alias="updatedAt")]
