SelectoComponents.QueryContract (selecto_components v0.4.8)
Components-facing adapter for Selecto query contracts.
This module keeps SelectoComponents from walking raw domain internals when it needs query metadata for tooling, documentation, or future AI-facing surfaces. It delegates the actual normalization and projection work to core Selecto.
Link to this section Summary
Link to this section Types
diagnostics()
@type diagnostics() :: Selecto.Domain.Diagnostics.t()
result()
@type result() :: {:ok, map(), diagnostics()} | {:error, diagnostics()}
Link to this section Functions
build(input)
Builds a constrained query contract from a domain-shaped input.
Accepted inputs are:
- an authored Selecto domain map
- an already-normalized Selecto domain
- a configured
%Selecto{}or selecto-like map containing:domain
encode_json(input, opts \\ [])
@spec encode_json( term(), keyword() ) :: {:ok, String.t(), diagnostics()} | {:error, diagnostics()}
Encodes the JSON-ready query contract document.
json_document(input, opts \\ [])
Builds a JSON-ready query contract document.
The returned map has string keys and JSON-compatible values so callers can
serve it directly from a future query_contract.json endpoint without leaking
Elixir atoms or structs into the public artifact.
query_contract(input)
Alias for build/1.
validate_intent(input, intent, opts \\ [])
@spec validate_intent(term(), map(), keyword()) :: SelectoComponents.QueryContract.IntentValidator.result()
Validates a generated query intent against a query contract.
The validator is deliberately non-executing. It accepts either an existing query contract artifact or a domain-shaped input that can be projected into a query contract, then checks that the intent only references exposed detail fields, filter comparators, and sort fields.