# This file is auto-generated by alef — DO NOT EDIT.
# alef:hash:4e15143f4af1ae8bafbdb1506ef057da924484c66a19483966333558ad437e75
# To regenerate: alef generate
# To verify freshness: alef verify --exit-code
# Issues & docs: https://github.com/kreuzberg-dev/alef
defmodule Kreuzberg.ExtractionResult do
  @moduledoc """
  General extraction result used by the core extraction API.

  This is the main result type returned by all extraction functions.
  """

  @typedoc "General extraction result used by the core extraction API."
  @type t :: %__MODULE__{
          content: String.t() | nil,
          mime_type: String.t() | nil,
          metadata: map(),
          extraction_method: String.t() | nil | nil,
          tables: [map()],
          detected_languages: [String.t()] | nil,
          chunks: [map()] | nil,
          images: [map()] | nil,
          pages: [map()] | nil,
          elements: [map()] | nil,
          djot_content: map() | nil,
          ocr_elements: [map()] | nil,
          document: map() | nil,
          extracted_keywords: [map()] | nil,
          quality_score: float() | nil,
          processing_warnings: [map()],
          annotations: [map()] | nil,
          children: [map()] | nil,
          uris: [map()] | nil,
          revisions: [map()] | nil,
          structured_output: String.t() | nil,
          code_intelligence: String.t() | nil,
          llm_usage: [map()] | nil,
          formatted_content: String.t() | nil,
          ocr_internal_document: String.t() | nil
        }

  defstruct content: nil,
            mime_type: nil,
            metadata: nil,
            extraction_method: nil,
            tables: [],
            detected_languages: nil,
            chunks: nil,
            images: nil,
            pages: nil,
            elements: nil,
            djot_content: nil,
            ocr_elements: nil,
            document: nil,
            extracted_keywords: nil,
            quality_score: nil,
            processing_warnings: [],
            annotations: nil,
            children: nil,
            uris: nil,
            revisions: nil,
            structured_output: nil,
            code_intelligence: nil,
            llm_usage: nil,
            formatted_content: nil,
            ocr_internal_document: nil

  defimpl Jason.Encoder do
    @doc false
    def encode(value, opts) do
      value
      |> Map.from_struct()
      |> Enum.reject(fn {_k, v} -> v == nil end)
      |> Enum.into(%{})
      |> Jason.Encoder.encode(opts)
    end
  end
end
