# `Gno.Service.Setup`
[🔗](https://github.com/rdf-elixir/gno/blob/v0.1.0/lib/gno/service/setup.ex#L1)

Setup and teardown of Gno repositories in the SPARQL store of a `Gno.Service`.

The setup pipeline checks store availability, prepares the store adapter,
initializes repository metadata, and validates the result. 

Application-specific setup logic can be added via `Gno.Service.Setup.Extension`.

For command-line usage, see `mix gno.setup` and `mix gno.teardown`.

# `options`

```elixir
@type options() :: [
  store_options: keyword(),
  repository_data: nil,
  extension: atom() | nil,
  extension_opts: keyword(),
  store_repository_metadata: boolean()
]
```

# `check`

```elixir
@spec check(
  Gno.Service.t(),
  keyword()
) :: :ok | {:error, term()}
```

Checks if the repository is already set up.

# `setup`

```elixir
@spec setup(Gno.Service.t(), options()) :: {:ok, Gno.Service.t()} | {:error, term()}
```

Sets up a new repository for the given service.

## Options

* `:store_options` (`t:keyword/0`) - Options passed to the store adapter's setup functions The default value is `[]`.

* `:repository_data` (`t:RDF.Graph.input/0`) - Additional RDF data to merge into the repository before storing The default value is `[]`.

* `:extension` - Extension module for application-specific setup logic The default value is `nil`.

* `:extension_opts` (`t:keyword/0`) - Options passed to the extension module callbacks The default value is `[]`.

* `:store_repository_metadata` (`t:boolean/0`) - If `false`, skips storing repository metadata in the triple store The default value is `true`.

## Examples

    # Simple setup with defaults
    {:ok, service} = Gno.Service.Setup.setup(service)

    # Setup without storing repository metadata
    {:ok, service} = Gno.Service.Setup.setup(service, store_repository_metadata: false)

    # Setup with extension
    {:ok, service} = Gno.Service.Setup.setup(service,
      extension: MyApp.Setup,
      extension_opts: [history: true, roles: [:admin, :user]]
    )

# `teardown`

```elixir
@spec teardown(Gno.Service.t(), options()) :: :ok | {:error, [term()]}
```

Tears down the repository for the given service.

> ### DESTRUCTIVE OPERATION {: .error}
>
> ⚠️  This will permanently delete repository data. ⚠️
>
> Only use in development/testing environments.

## Options

* `:store_options` (`t:keyword/0`) - Options passed to the store adapter's setup functions The default value is `[]`.

* `:repository_data` (`t:RDF.Graph.input/0`) - Additional RDF data to merge into the repository before storing The default value is `[]`.

* `:extension` - Extension module for application-specific setup logic The default value is `nil`.

* `:extension_opts` (`t:keyword/0`) - Options passed to the extension module callbacks The default value is `[]`.

* `:store_repository_metadata` (`t:boolean/0`) - If `false`, skips storing repository metadata in the triple store The default value is `true`.

## Examples

    # Simple teardown with defaults
    :ok = Gno.Service.Setup.teardown(service)

    # Teardown with extension
    :ok = Gno.Service.Setup.teardown(service,
      extension: MyApp.Setup,
      extension_opts: [history: true, roles: [:admin, :user]]
    )

# `validate`

```elixir
@spec validate(
  Gno.Service.t(),
  keyword()
) :: :ok | {:error, term()}
```

Validates the setup state including basic integrity and extension validations.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
