Current section

Files

Jump to
Raw

mix.exs

# SPDX-FileCopyrightText: 2026 BaseLabs Holdings LLC
#
# SPDX-License-Identifier: MIT

defmodule AshArcadic.MixProject do
  use Mix.Project

  @version "3.2.0"
  @source_url "https://github.com/baselabs/ash_arcadic"

  def project do
    [
      app: :ash_arcadic,
      version: @version,
      elixir: "~> 1.18",
      start_permanent: Mix.env() == :prod,
      elixirc_paths: elixirc_paths(Mix.env()),
      # Spark records declaration locations only when debug info is enabled.
      test_elixirc_options: [debug_info: true],
      consolidate_protocols: Mix.env() != :test,
      deps: deps(),
      package: package(),
      # Evaluate Spark search data after ExDoc loads the compiled extensions.
      docs: &docs/0,
      aliases: aliases(),
      name: "AshArcadic",
      description: "Ash Framework data layer for ArcadeDB using native OpenCypher.",
      source_url: @source_url,
      homepage_url: @source_url,
      dialyzer: [
        plt_add_apps: [:mix, :ex_unit],
        plt_core_path: "priv/plts",
        plt_local_path: "priv/plts"
      ]
    ]
  end

  def cli do
    [preferred_envs: [credo: :test, dialyzer: :test]]
  end

  def application do
    [extra_applications: [:crypto, :logger]]
  end

  defp elixirc_paths(:test), do: ["lib", "test/support"]
  defp elixirc_paths(_), do: ["lib"]

  defp deps do
    [
      # Runtime
      # ash >= 3.38.1 closes GHSA-m5v6-3qwf-6w9r (forged keyset cursors) and
      # GHSA-rwmx-99mc-qr2x (Ash.Type.Keyword input validation).
      {:ash, ">= 3.38.1 and < 4.0.0-0"},
      {:spark, ">= 2.3.3 and < 3.0.0-0"},
      {:splode, "~> 0.3"},
      {:arcadic, "~> 3.0"},
      # The CDC transport for the optional `AshArcadic.Replicant.*` sink. `optional: true`
      # so non-CDC hosts don't pull it (nor its Postgrex replication deps); a host that
      # uses the sink adds `replicant` to its own deps.
      {:replicant, ">= 1.6.0 and < 3.0.0-0", optional: true},
      # CVE floor for a transitive dependency (a library's mix.lock does not govern consumers'
      # resolution): db_connection, reached only through replicant's Postgrex, must be 2.10.3
      # or later, which closes EEF-CVE-2026-133555 (code execution via the :log option of
      # forged DBConnection.Stream structs). Optional, so it binds only where it is present.
      {:db_connection, ">= 2.10.3 and < 3.0.0-0", optional: true},
      {:jason, "~> 1.4"},
      {:telemetry, "~> 1.0"},
      # SAT solver required by Ash.Policy.Authorizer (Ash lists it as an optional dep;
      # the policy solver raises "No SAT solver available" at DSL-verify/read time without
      # one). Pure Elixir, no NIF — CI-portable, no C toolchain.
      {:simple_sat, "~> 0.1"},

      # Dev/Test
      {:ex_doc, "~> 0.31", only: [:dev, :test], runtime: false},
      {:ex_check, "~> 0.16", only: [:dev, :test], runtime: false},
      {:credo, "~> 1.7", only: [:dev, :test], runtime: false},
      {:dialyxir, "~> 1.4", only: [:dev, :test], runtime: false},
      {:sobelow, ">= 0.0.0", only: [:dev, :test], runtime: false},
      {:mix_audit, "~> 2.1", only: [:dev, :test], runtime: false},
      # Build-time only: powers `mix spark.cheat_sheets` (DSL doc generation). Optional dep of
      # spark; never a runtime dep of the published library.
      {:igniter, "~> 0.8", only: [:dev, :test], runtime: false}
    ]
  end

  defp package do
    [
      maintainers: ["rjpalermo"],
      files:
        ~w(lib .formatter.exs mix.exs README* LICENSE LICENSES CHANGELOG* SECURITY.md CODE_OF_CONDUCT.md CONTRIBUTING.md usage-rules.md documentation),
      licenses: ["MIT"],
      links: %{
        "GitHub" => @source_url,
        "Changelog" => "#{@source_url}/blob/main/CHANGELOG.md"
      }
    ]
  end

  defp docs do
    [
      main: "readme",
      source_ref: "baselabs_ash_arcadic-v#{@version}",
      source_url: @source_url,
      extras: extras(),
      skip_undefined_reference_warnings_on: ["CHANGELOG.md"],
      groups_for_extras: [
        Tutorials: ~r"documentation/tutorials/",
        Resources: ~r"documentation/topics/resources/",
        Queries: ~r"documentation/topics/queries/",
        Replication: ~r"documentation/topics/replication/",
        "How-to": ~r"documentation/how-to/",
        Reference: ~r"documentation/(dsls|topics/operations)/",
        "About AshArcadic": [
          "documentation/topics/about-ash-arcadic/compatibility.md",
          "CHANGELOG.md",
          "SECURITY.md",
          "CONTRIBUTING.md",
          "CODE_OF_CONDUCT.md",
          "LICENSE",
          "usage-rules.md"
        ]
      ],
      groups_for_modules: [
        "Data layer": [AshArcadic, AshArcadic.DataLayer, AshArcadic.Client],
        Introspection: [AshArcadic.DataLayer.Info, AshArcadic.Replicant.Info],
        Declarations: [
          AshArcadic.CustomIndex,
          AshArcadic.Edge,
          AshArcadic.VectorIndex,
          AshArcadic.SparseVectorIndex,
          AshArcadic.FullTextIndex
        ],
        "Actions and maintenance": [
          AshArcadic.Changes.CreateEdge,
          AshArcadic.Changes.DestroyEdge,
          AshArcadic.ManualRelationships.Traverse,
          AshArcadic.Preparations.VectorSearch,
          AshArcadic.StoredValueBackfill
        ],
        Replication: [
          AshArcadic.Replicant,
          AshArcadic.ReplicantCheckpoint,
          AshArcadic.ReplicantSink,
          AshArcadic.Replicant.Pipeline
        ],
        Errors: ~r"^AshArcadic\.(Errors\.|Replicant\.Error$)"
      ]
    ]
  end

  # Every shipped notebook is also a docs page.
  defp extras do
    notebooks = Enum.sort(Path.wildcard("documentation/tutorials/**/*.livemd"))

    [{"README.md", title: "Home"} | notebooks] ++
      [
        "documentation/topics/resources/resources.md",
        "documentation/topics/resources/multitenancy.md",
        "documentation/topics/resources/relationships.md",
        "documentation/topics/queries/reads.md",
        "documentation/topics/queries/writes.md",
        "documentation/topics/queries/ranked-search.md",
        "documentation/topics/replication/cdc.md",
        "documentation/topics/operations/telemetry.md",
        "documentation/topics/about-ash-arcadic/compatibility.md",
        "documentation/how-to/generate-migrations.md",
        "documentation/how-to/troubleshooting.md",
        "documentation/how-to/performance.md",
        "documentation/how-to/upgrading.md",
        "documentation/how-to/verify-release.md",
        {"documentation/dsls/DSL-AshArcadic.DataLayer.md",
         search_data: Spark.Docs.search_data_for(AshArcadic.DataLayer)},
        {"documentation/dsls/DSL-AshArcadic.Replicant.md",
         search_data: Spark.Docs.search_data_for(AshArcadic.Replicant)},
        "usage-rules.md",
        "CHANGELOG.md",
        "SECURITY.md",
        "CONTRIBUTING.md",
        "CODE_OF_CONDUCT.md",
        "LICENSE"
      ]
  end

  defp aliases do
    [
      credo: "credo --strict",
      sobelow: "sobelow --skip",
      audit: ["deps.unlock --check-unused", "hex.audit", "deps.audit"],
      # Regenerate the `arcade do … end` / `replicant do … end` DSL cheat sheets before
      # building docs so hexdocs always ships the current DSL reference.
      docs: ["spark.cheat_sheets --extensions AshArcadic.DataLayer,AshArcadic.Replicant", "docs"]
    ]
  end
end