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: StrEnum

Closed taxonomy of input primitives the wizard runtime supports.

TEXT
SECRET
CONFIRM
SELECT
CHECKBOX
PATH
INTEGER
class WizardCondition(**data)[source]

Bases: BaseModel

Single-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-categories includes actividad_economica).

Parameters:

data (Any)

question_id: str
equals: str | None
contains: str | None
class WizardVisibility(**data)[source]

Bases: BaseModel

Disjunction of WizardCondition clauses.

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. activity is 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: BaseModel

One 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: BaseModel

One 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: BaseModel

One grouped sequence of questions inside a flow.

Parameters:

data (Any)

id: str
title: tr
questions: tuple[WizardQuestion, ...]
class WizardFlow(**data)[source]

Bases: BaseModel

The 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 WizardCondition clause in a visible_when.

Normalises the three shapes visible_when can take — None (no gate), a bare WizardCondition (single clause), or a WizardVisibility (OR of clauses) — into a flat tuple so consumers iterate one uniform sequence.

Return type:

tuple[WizardCondition, ...]

Parameters:

visible_when (WizardCondition | WizardVisibility | None)