-- SPDX-FileCopyrightText: 2026 Alexandra de Wit
--
-- SPDX-License-Identifier: MIT

{- | The ecosystem adapter registry: which ecosystems this build supports, independent of what an
operator configures. An unsupported ecosystem resolves to 'Nothing' here and an unconfigured one is
never activated, so the composition root can tell a missing adapter from an unconfigured mount.
-}
module Ecluse.Core.Registry.Adapter (
    -- * The capability record
    RegistryAdapter (..),
    AdapterServe (..),

    -- * Registration
    adapterFor,
) where

import Ecluse.Core.Ecosystem (Ecosystem (Npm, PyPI, RubyGems))
import Ecluse.Core.Registry.Adapter.Types (AdapterServe (..), RegistryAdapter (..))
import Ecluse.Core.Registry.Npm.Adapter (npmAdapter)
import Ecluse.Core.Registry.PyPI.Adapter (pypiAdapter)

{- | Resolve an ecosystem to its registered 'RegistryAdapter'. Every arm is explicit, so an added
'Ecosystem' surfaces here as a compiler error rather than a silent 'Nothing'.
-}
adapterFor :: Ecosystem -> Maybe RegistryAdapter
adapterFor :: Ecosystem -> Maybe RegistryAdapter
adapterFor = \case
    Ecosystem
Npm -> RegistryAdapter -> Maybe RegistryAdapter
forall a. a -> Maybe a
Just RegistryAdapter
npmAdapter
    Ecosystem
PyPI -> RegistryAdapter -> Maybe RegistryAdapter
forall a. a -> Maybe a
Just RegistryAdapter
pypiAdapter
    Ecosystem
RubyGems -> Maybe RegistryAdapter
forall a. Maybe a
Nothing