cadrumo.application.wizard.models module¶
Descriptor models for the schema-driven wizard.
The five strict frozen pydantic v2 records below compose a closed,
declarative description of an operator-facing configuration flow.
WizardFlow is a tuple of WizardSection``s; a section is a tuple
of ``WizardQuestion``s; each question binds zero-or-one
``profile_key to the application profile-key catalogue, declares exactly one
WizardWidget kind, and carries the prompt copy and the optional
WizardCondition that gates its visibility. The descriptor is the
single source of truth: the runtime, the Typer command factory, and
the compile_profile_keys projection all read off these records.
- class WizardWidget(*values)[source]¶
Bases:
StrEnumClosed taxonomy of input primitives the wizard runtime supports.
- TEXT¶
- SECRET¶
- CONFIRM¶
- SELECT¶
- CHECKBOX¶
- PATH¶
- INTEGER¶
- class WizardCondition(**data)[source]¶
Bases:
BaseModelSingle-clause predicate naming one earlier question.
The predicate names an earlier question by id and tests its canonical-token answer (
"true"/"false"for booleans, raw string for SELECT/TEXT, comma-joined token set for CHECKBOX). Exactly one of two clause kinds is set:equals— the answer must equal this literal token. Used for SELECT and CONFIRM gates (entity-type == "legal_entity").contains— the answer, split on commas into a token set, must contain this literal token. Used for CHECKBOX gates (irpf-income-categoriesincludesactividad_economica).
- Parameters:
data (Any)
- question_id: str¶
- equals: str | None¶
- contains: str | None¶
- class WizardVisibility(**data)[source]¶
Bases:
BaseModelDisjunction of
WizardConditionclauses.A question is visible when any clause is satisfied. A single- clause visibility is the common case; a multi-clause visibility expresses “asked when A or B” (e.g.
activityis collected for a legal entity or for a natural person who declared an economic activity).- Parameters:
data (Any)
- any_of: tuple[WizardCondition, ...]¶
- class WizardChoice(**data)[source]¶
Bases:
BaseModelOne entry in a SELECT or CHECKBOX widget’s closed-set choices.
- Parameters:
data (Any)
- value: str¶
- label: tr¶
- description: tr | None¶
- class WizardQuestion(**data)[source]¶
Bases:
BaseModelOne operator-facing question in a wizard flow.
- Parameters:
data (Any)
- id: str¶
- profile_key: str | None¶
- widget: WizardWidget¶
- prompt: tr¶
- help: tr | None¶
- choices: tuple[WizardChoice, ...]¶
- default: str | None¶
- required: bool¶
- visible_when: WizardCondition | WizardVisibility | None¶
- answer_type: type[str] | type[bool] | type[int] | type[Path]¶
- class WizardSection(**data)[source]¶
Bases:
BaseModelOne grouped sequence of questions inside a flow.
- Parameters:
data (Any)
- id: str¶
- title: tr¶
- questions: tuple[WizardQuestion, ...]¶
- class WizardFlow(**data)[source]¶
Bases:
BaseModelThe top-level descriptor for a single wizard surface.
- Parameters:
data (Any)
- id: str¶
- title: tr¶
- description: tr¶
- sections: tuple[WizardSection, ...]¶
- answers_model: type[BaseModel]¶
- iter_conditions(visible_when)[source]¶
Return every
WizardConditionclause in avisible_when.Normalises the three shapes
visible_whencan take —None(no gate), a bareWizardCondition(single clause), or aWizardVisibility(OR of clauses) — into a flat tuple so consumers iterate one uniform sequence.- Return type:
- Parameters:
visible_when (WizardCondition | WizardVisibility | None)