Scrypath.QueryParams (scrypath v0.3.7)

Copy Markdown View Source

Public request-edge toolkit for turning top-level request params into one stable plain-data Scrypath search-args shape.

%Scrypath.Query{} remains internal normalized query state owned by the common Scrypath.search/3 runtime. Host applications should use this module when they want a framework-light contract that can be cast from request params and then converted into {text, keyword_opts} for a context-owned Scrypath.search/3 call.

Use normalize/1 at the request edge when handling Plug-decoded browser params. It returns either {:ok, query_params} or {:error, error_map} for owned Scrypath namespaces. cast/1 remains available for already-runtime-compatible nested values.

This module is data-only: it does not validate schema-specific search semantics and it does not execute searches.

Summary

Types

t()

Stable public plain-data contract for Scrypath.search/3 args.

Functions

Casts string-keyed or atom-keyed top-level request input into the public Scrypath query-param contract.

Normalizes Plug-decoded request params into the public Scrypath query-param contract.

Converts the public plain-data contract into {text, keyword_opts} for a context-owned Scrypath.search/3 call.

Types

normalize_error_map()

@type normalize_error_map() :: %{
  form_errors: [Scrypath.QueryParams.Error.t()],
  field_errors: %{optional(atom()) => [Scrypath.QueryParams.Error.t()]},
  errors: [Scrypath.QueryParams.Error.t()]
}

t()

@type t() :: %{
  text: String.t(),
  filter: keyword(),
  sort: keyword(),
  page: keyword(),
  facets: [atom()],
  facet_filter: keyword(),
  per_query: map()
}

Stable public plain-data contract for Scrypath.search/3 args.

Functions

cast(params)

@spec cast(map()) :: t()

Casts string-keyed or atom-keyed top-level request input into the public Scrypath query-param contract.

normalize(params)

@spec normalize(map()) :: {:ok, t()} | {:error, normalize_error_map()}

Normalizes Plug-decoded request params into the public Scrypath query-param contract.

Unknown top-level params are ignored, while malformed values inside owned namespaces return aggregate structured issues.

to_search_args(query_params)

@spec to_search_args(t()) :: {String.t(), keyword()}

Converts the public plain-data contract into {text, keyword_opts} for a context-owned Scrypath.search/3 call.