Source code for buffalo_wings.airfoil.internal.schema.document

"""Top-level schema container for named airfoil and curve definitions."""

from __future__ import annotations

from dataclasses import dataclass, field
from typing import TYPE_CHECKING

from buffalo_core.schema import SchemaField

if TYPE_CHECKING:  # pragma: no cover
    from . import AirfoilDefinitionSpec
    from .curve import CurveDefinitionSpec


[docs] @dataclass(slots=True) class AirfoilDocumentSpec: """ Top-level airfoil schema document. The document owns the mapping from unique airfoil names to individual airfoil definitions and the mapping from unique curve names to open section-curve definitions. Individual airfoil definition specs intentionally do not carry their own schema-level names because the same definition may be referenced under different document-level roles. """ #: Schema version number for the serialized airfoil definition document. schema_version: int = field( metadata=SchemaField( value_kind="integer", required=True, label="Schema Version", order=10, short_help="Serialized airfoil-schema version number.", choices=(1,), notes="Version 1 is the active Buffalo Wings airfoil schema.", ).to_metadata() ) #: Named airfoil definitions keyed by their document-level identifiers. airfoils: dict[str, AirfoilDefinitionSpec] = field( default_factory=dict, metadata=SchemaField( value_kind="mapping", required=False, label="Airfoils", order=20, short_help="Named airfoil definitions available to a document.", item_kind="AirfoilDefinitionSpec", collection_add_label="Add Airfoil", collection_key_label="Airfoil Name", collection_key_format_hint=( "unique airfoil identifier used by embedding documents" ), collection_item_creation_hint=( "Choose an airfoil spec family for the new entry." ), notes=( "Dataclass field metadata is the authoritative machine-" "readable source for GUI and editor constraints." ), ).to_metadata(), ) #: Named open section-curve definitions keyed by document identifiers. curves: dict[str, CurveDefinitionSpec] = field( default_factory=dict, metadata=SchemaField( value_kind="mapping", required=False, label="Curves", order=30, short_help="Named open section curves available to a document.", item_kind="CurveDefinitionSpec", collection_add_label="Add Curve", collection_key_label="Curve Name", collection_key_format_hint=( "unique curve identifier used by embedding documents" ), collection_item_creation_hint=( "Choose a curve spec family for the new entry." ), notes=( "Use this mapping for open geometry such as airfoil-derived " "camber lines and future non-airfoil section curves." ), ).to_metadata(), )