Public plain-data composition seam for reusable search presets and additive scopes.
Host apps define feature-level or context-owned fragments such as %{defaults: ...}
and %{fixed: ...}. This module composes those fragments into the same plain-data
criteria vocabulary already accepted by Scrypath.search/3.
Scrypath.Composition is data-only:
- it never executes search
- it never exposes
%Scrypath.Query{} - it does not move composition ownership onto schemas or
Scrypath.Phoenix
The composed result stays a plain map that includes final criteria plus coarse
visibility buckets: applied, defaulted, fixed, and optional sources
or warnings.
Summary
Types
Caller-facing criteria vocabulary aligned with Scrypath.search/3.
Allowed fragment fixed constraints for filter-bearing fields only.
Public fragment envelope used to compose presets and scopes.
Allowed fragment defaults for all public search fields.
Public multi-search entry spec consumed by compose_many/2.
Public multi-search composition result. Shared composition lowers defaults only,
per-entry composition stays canonical, and to_search_many_args/1 emits the
existing tuple/shared-option contract for Scrypath.search_many/2.
Functions
Composes one fragment or a list of fragments with caller criteria.
Like compose/2, but raises ArgumentError instead of returning {:error, reason}.
Composes multi-search entries into the existing tuple/shared-option contract.
Like compose_many/2, but raises ArgumentError instead of returning
{:error, reason}.
Converts the composed plain-data result into {text, keyword_opts} for a
context-owned Scrypath.search/3 call.
Lowers a multi-search composition result into {entries, shared_opts} for a
context-owned Scrypath.search_many/2 call.
Types
@type criteria() :: %{ optional(:text) => String.t(), optional(:filter) => keyword(), optional(:sort) => keyword(), optional(:page) => keyword(), optional(:facets) => [atom()], optional(:facet_filter) => keyword(), optional(:per_query) => map() }
Caller-facing criteria vocabulary aligned with Scrypath.search/3.
Allowed fragment fixed constraints for filter-bearing fields only.
@type fragment() :: %{ optional(:defaults) => fragment_criteria(), optional(:fixed) => fixed_criteria(), optional(:sources) => map(), optional(:warnings) => map() }
Public fragment envelope used to compose presets and scopes.
@type fragment_criteria() :: criteria()
Allowed fragment defaults for all public search fields.
@type many_entry_spec() :: %{ :schema => module() | :all, :text => String.t(), optional(:fragments) => fragment() | [fragment()], optional(:criteria) => criteria() }
Public multi-search entry spec consumed by compose_many/2.
Public multi-search composition result. Shared composition lowers defaults only,
per-entry composition stays canonical, and to_search_many_args/1 emits the
existing tuple/shared-option contract for Scrypath.search_many/2.
@type result() :: Scrypath.Composition.Result.t()
Stable public result returned by compose/2.
Functions
Composes one fragment or a list of fragments with caller criteria.
Like compose/2, but raises ArgumentError instead of returning {:error, reason}.
@spec compose_many( [many_entry_spec() | tuple()], keyword() ) :: {:ok, many_result()} | {:error, term()}
Composes multi-search entries into the existing tuple/shared-option contract.
Shared composition lowers defaults only. Shared fixed constraints are not
supported, and multi-search-only rails such as federation weights or
max_schemas stay outside this helper.
@spec compose_many!( [many_entry_spec() | tuple()], keyword() ) :: many_result()
Like compose_many/2, but raises ArgumentError instead of returning
{:error, reason}.
Converts the composed plain-data result into {text, keyword_opts} for a
context-owned Scrypath.search/3 call.
@spec to_search_many_args(many_result()) :: {list(), keyword()}
Lowers a multi-search composition result into {entries, shared_opts} for a
context-owned Scrypath.search_many/2 call.