"""What the criteria page's examples send — the brief, written once.

``docs/integrator/criteria.md`` searches ``PEOPLE``: a workspace of ten invented experts
(a country each, and their profiles and call transcripts registered as documents about
them) that the documentation's test harness builds through the public verbs
(``tests/test_docs_examples_execute.py``, ``seed_people_workspace``). The page's first
example writes its request out in full; the later ones import the same brief from here so
each can show the one thing it is about.

Nothing here is a product default: ``EUROPE`` is an ordinary constraint over the one
relation that workspace holds, ``NICHE`` is a condition no relation of it can express,
and ``FACETS`` is one caller's own split of that text.
"""
from __future__ import annotations

from typing import Any, Dict, List

#: The ordinary condition — something a FIELD decides. It runs first, and only the
#: people it leaves are read.
EUROPE: List[Dict[str, Any]] = [
    {"relation": "based_in", "slot": "place", "op": "eq", "value": "Europe"}]

#: The niche — the WHOLE of it as one text, in plain words.
NICHE = "20+ years marketing baby formula in European markets"

#: A caller's own split of ``NICHE``: each facet in the text's exact words. ``value``
#: names the ONE vocabulary term a condition means ("in European markets" → Europe), so
#: the reader can refuse a quote that names another place.
FACETS: List[Dict[str, Any]] = [
    {"key": "duration", "kind": "duration", "text": "20+ years", "min_years": 20},
    {"key": "function", "kind": "condition", "text": "marketing"},
    {"key": "product", "kind": "condition", "text": "baby formula"},
    {"key": "market", "kind": "condition", "text": "in European markets", "value": "Europe"},
]


def search(client: Any, workspace_id: str, **body: Any) -> Dict[str, Any]:
    """``POST /v1/public/search`` with ``body``; the response body of a 200, and a
    ``RuntimeError`` carrying the refusal otherwise."""
    response = client.post("/v1/public/search", json={"workspace_id": workspace_id, **body})
    if response.status_code != 200:
        raise RuntimeError(f"search answered {response.status_code}: {response.text}")
    return response.json()


__all__ = ["EUROPE", "NICHE", "FACETS", "search"]
