Skip to content

Model API reference

This page is generated directly from the SQLAlchemy models in hq/sql_models/template.py by mkdocstrings. It is the authoritative, never-drifting reference for the template table group: the four live model classes (Template, TemplateBlock, SiteBlockOverride, PageType) and their history mirrors.

For the narrative explanations, see Data model overview, Page types, and sources / bind / call / params explained.

SQLAlchemy models for S3-backed CMS template and style registries.

Template and Style hold registry metadata plus bucket-relative s3_key pointers; template shell markup and stylesheets no longer live in the database. PageType and TemplateStyle retain their relational configuration for templates. The models are the schema source of truth used by Base.metadata.create_all() and the CMS drift check.

Template

Bases: CMSBase, Base

A named, versioned S3-backed CMS template a site can adopt.

slug is unique; settings_schema / default_settings are JSON; s3_key points to the template shell in the environment-selected bucket.

Source code in template.py
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
class Template(CMSBase, Base):
    """A named, versioned S3-backed CMS template a site can adopt.

    ``slug`` is unique; ``settings_schema`` / ``default_settings`` are JSON;
    ``s3_key`` points to the template shell in the environment-selected bucket.
    """

    __tablename__ = "templates"

    name: Mapped[str] = mapped_column(String(255), nullable=False)
    slug: Mapped[str] = mapped_column(String(128), nullable=False, unique=True)
    description: Mapped[Optional[str]] = mapped_column(Text, nullable=True)
    version: Mapped[Optional[str]] = mapped_column(String(32), nullable=True)
    preview_image: Mapped[Optional[str]] = mapped_column(String(255), nullable=True)
    settings_schema: Mapped[Optional[Any]] = mapped_column(JSON, nullable=True)
    default_settings: Mapped[Optional[Any]] = mapped_column(JSON, nullable=True)
    # Bucket-relative key of the template shell file in the env-selected
    # ``cms-templates-{env}`` bucket (e.g. ``templates/<slug>/<version>/shell.html``)
    # -- NOT a full path or bucket name; the ENV selects the bucket.
    s3_key: Mapped[Optional[str]] = mapped_column(String(512), nullable=True)
    # Edit-tracking columns (AISD-126): edited_by (FK -> users.id, nullable,
    # indexed) and creator_type (string reference to creator_types.name, NOT a
    # FK). Both nullable (additive).
    edited_by: Mapped[Optional[int]] = mapped_column(
        Integer, ForeignKey("users.id", name="fk_templates_edited_by"), nullable=True, index=True
    )
    creator_type: Mapped[Optional[str]] = mapped_column(String(64), nullable=True)

    page_types: Mapped[List["PageType"]] = relationship(
        "PageType", back_populates="template"
    )
    template_styles: Mapped[List["TemplateStyle"]] = relationship(
        "TemplateStyle", back_populates="template"
    )

PageType

Bases: CMSBase, Base

A data-driven page descriptor a template exposes (AISD P1.b).

One row per (page type, variant) a template renders. It replaces the worker's hardcoded router.ts rules and pages/*.ts orchestrators: the worker reads these rows (served inside the public /settings payload, resolved for the site's active template) and runs one generic match route -> fetch sources -> build -> wrap layout loop.

Scoped to a template_id (a template owns its page types). Unique on (template_id, type, variant).

variant lets one template carry multiple layouts for the same page type (e.g. a "listicle" article alongside the "default" article). It is NOT NULL with a "default" server default so the unique key stays clean (MySQL treats NULLs as distinct). The worker selects the variant from a content field (e.g. content.settings.layout / content_type), falling back to "default" -- so a route resolves to (type) first, then the builder/content picks the variant.

JSON column contract (all interpreted by the worker engine):

  • routes: list of path patterns, e.g. ["/{category}/{slug}"]. {name} segments capture params; a trailing * segment is a catch-all.
  • layout: ordered list of template element_type content slots to render into the page body. NB: header / footer are added by the worker's renderLayout wrapper and must NOT be listed here.
  • sources: list of {bind, call, params, required} declared API calls (call in lists/pages/authors/sitemap/seo). required: false sources degrade to null on failure instead of failing the page.
  • bindings: map of template-context key -> dotted path into the fetched sources, e.g. {"related": "related.items"}.
  • grids / sidebar / partial / seo: declarative fill + SEO hints for pure-data page types (no code).
  • transforms: ordered list of named editorial transforms the worker applies (e.g. article_content_blocks, editors_picks_sidebar).
  • builder: optional named builder transform for page types whose shaping is too bespoke for the declarative fields (WK's existing pages use this for exact parity). When unset, the engine uses the declarative path.
  • position: ascending match-priority hint; literal-segment specificity still wins within equal-length routes.
Source code in template.py
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
class PageType(CMSBase, Base):
    """A data-driven page descriptor a template exposes (AISD P1.b).

    One row per (page type, variant) a template renders. It replaces the
    worker's hardcoded ``router.ts`` rules and ``pages/*.ts`` orchestrators: the
    worker reads these rows (served inside the public ``/settings`` payload,
    resolved for the site's active template) and runs one generic ``match route
    -> fetch sources -> build -> wrap layout`` loop.

    Scoped to a ``template_id`` (a template owns its page types). Unique on
    ``(template_id, type, variant)``.

    ``variant`` lets one template carry **multiple layouts for the same page
    type** (e.g. a ``"listicle"`` article alongside the ``"default"`` article).
    It is NOT NULL with a ``"default"`` server default so the unique key stays
    clean (MySQL treats NULLs as distinct). The worker selects the variant from a
    content field (e.g. ``content.settings.layout`` / ``content_type``), falling
    back to ``"default"`` -- so a route resolves to ``(type)`` first, then the
    builder/content picks the variant.

    JSON column contract (all interpreted by the worker engine):

    - ``routes``: list of path patterns, e.g. ``["/{category}/{slug}"]``. ``{name}``
      segments capture params; a trailing ``*`` segment is a catch-all.
    - ``layout``: ordered list of template ``element_type`` **content** slots to
      render into the page body. NB: ``header`` / ``footer`` are added by the
      worker's ``renderLayout`` wrapper and must NOT be listed here.
    - ``sources``: list of ``{bind, call, params, required}`` declared API calls
      (``call`` in lists/pages/authors/sitemap/seo). ``required: false`` sources
      degrade to ``null`` on failure instead of failing the page.
    - ``bindings``: map of template-context key -> dotted path into the fetched
      sources, e.g. ``{"related": "related.items"}``.
    - ``grids`` / ``sidebar`` / ``partial`` / ``seo``: declarative fill + SEO hints
      for pure-data page types (no code).
    - ``transforms``: ordered list of named editorial transforms the worker
      applies (e.g. ``article_content_blocks``, ``editors_picks_sidebar``).
    - ``builder``: optional named builder transform for page types whose shaping
      is too bespoke for the declarative fields (WK's existing pages use this for
      exact parity). When unset, the engine uses the declarative path.
    - ``position``: ascending match-priority hint; literal-segment specificity
      still wins within equal-length routes.
    """

    __tablename__ = "page_types"
    __table_args__ = (
        UniqueConstraint(
            "template_id", "type", "variant", name="uq_page_types_template_type_variant"
        ),
    )

    template_id: Mapped[int] = mapped_column(
        Integer, ForeignKey("templates.id"), nullable=False, index=True
    )
    type: Mapped[str] = mapped_column(String(64), nullable=False, index=True)
    variant: Mapped[str] = mapped_column(
        String(64), nullable=False, server_default="default"
    )
    routes: Mapped[Any] = mapped_column(JSON, nullable=False)
    layout: Mapped[Any] = mapped_column(JSON, nullable=False)
    ttl: Mapped[int] = mapped_column(Integer, nullable=False, server_default="300")
    sources: Mapped[Optional[Any]] = mapped_column(JSON, nullable=True)
    bindings: Mapped[Optional[Any]] = mapped_column(JSON, nullable=True)
    grids: Mapped[Optional[Any]] = mapped_column(JSON, nullable=True)
    sidebar: Mapped[Optional[Any]] = mapped_column(JSON, nullable=True)
    partial: Mapped[Optional[Any]] = mapped_column(JSON, nullable=True)
    seo: Mapped[Optional[Any]] = mapped_column(JSON, nullable=True)
    transforms: Mapped[Optional[Any]] = mapped_column(JSON, nullable=True)
    builder: Mapped[Optional[str]] = mapped_column(String(64), nullable=True)
    position: Mapped[Optional[int]] = mapped_column(Integer, nullable=True)
    # Edit-tracking columns, mirroring the sibling template tables (AISD-126).
    edited_by: Mapped[Optional[int]] = mapped_column(
        Integer, ForeignKey("users.id", name="fk_page_types_edited_by"), nullable=True, index=True
    )
    creator_type: Mapped[Optional[str]] = mapped_column(String(64), nullable=True)

    template: Mapped["Template"] = relationship("Template", back_populates="page_types")

Style

Bases: CMSBase, Base

A reusable S3-backed stylesheet in the CMS styles registry.

A Style is a first-class, named, versioned stylesheet a site can adopt independently of its structural Template. This decouples skin (CSS) from structure (template layout + page_types): a "reskin" is a new Style row + a site pointer, not a cloned template. A site selects its style via the site_settings key style_slug; cms-api resolves it into the public /settings payload as active_style and serves the CSS at /public/v2/styles/<slug>/css. The worker links + edge-caches it at /_assets/styles/style/<slug>/<version>.css.

slug is unique; version carries a content hash so the worker's URL cache-busts when the S3 object changes -- no worker redeploy needed.

Source code in template.py
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
class Style(CMSBase, Base):
    """A reusable S3-backed stylesheet in the CMS styles registry.

    A ``Style`` is a first-class, named, versioned stylesheet a site can adopt
    independently of its structural ``Template``. This decouples *skin* (CSS)
    from *structure* (template layout + page_types): a "reskin" is a new ``Style``
    row + a site pointer, not a cloned template. A site selects its style via the
    ``site_settings`` key ``style_slug``; cms-api resolves it into the public
    ``/settings`` payload as ``active_style`` and serves the CSS at
    ``/public/v2/styles/<slug>/css``. The worker links + edge-caches it at
    ``/_assets/styles/style/<slug>/<version>.css``.

    ``slug`` is unique; ``version`` carries a content hash so the worker's URL
    cache-busts when the S3 object changes -- no worker redeploy needed.
    """

    __tablename__ = "styles"

    name: Mapped[str] = mapped_column(String(255), nullable=False)
    slug: Mapped[str] = mapped_column(String(128), nullable=False, unique=True)
    description: Mapped[Optional[str]] = mapped_column(Text, nullable=True)
    version: Mapped[Optional[str]] = mapped_column(String(32), nullable=True)
    # Bucket-relative key of the CSS file in the env-selected
    # ``cms-templates-{env}`` bucket (e.g. ``styles/<slug>/<version>.css``) -- NOT
    # a full path or bucket name; the ENV selects the bucket.
    s3_key: Mapped[Optional[str]] = mapped_column(String(512), nullable=True)
    # Edit-tracking columns, mirroring the sibling template tables (AISD-126).
    edited_by: Mapped[Optional[int]] = mapped_column(
        Integer, ForeignKey("users.id", name="fk_styles_edited_by"), nullable=True, index=True
    )
    creator_type: Mapped[Optional[str]] = mapped_column(String(64), nullable=True)
    # Above-the-fold subset of this version's CSS, generated by penthouse
    # (``hq/scripts/generate_critical_css.py``). cms-api hands it to the worker in
    # ``active_style``, which inlines it so the page paints without waiting on the
    # sheet. NULL is the normal state for a style nobody has generated one for,
    # and means "keep the render-blocking <link>" -- never "no CSS".
    critical_css: Mapped[Optional[str]] = mapped_column(MEDIUMTEXT, nullable=True)

    template_styles: Mapped[List["TemplateStyle"]] = relationship(
        "TemplateStyle", back_populates="style"
    )

TemplateStyle

Bases: CMSBase, Base

A known-good (template, style) pairing selectable as one unit (AISD-220).

A style's CSS is authored for a specific template's markup, so pairings are curated, not free-mixed. The site_settings key template_style_id points a site at one row; cms-api resolves it to active_template + active_style (N3). At most one active is_default row per template -- enforced at the app layer (this task's seed + N2's admin CRUD), since MySQL 8 has no partial / filtered unique index to express it. The hard UNIQUE(template_id, style_id) constraint still forbids duplicate pairings. No history mirror is added: epic AISD-207 drops the *_history tables, so a new template_styles_history mirror + trigger would be immediately scheduled for removal.

Source code in template.py
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
class TemplateStyle(CMSBase, Base):
    """A known-good (template, style) pairing selectable as one unit (AISD-220).

    A style's CSS is authored for a specific template's markup, so pairings are
    curated, not free-mixed. The ``site_settings`` key ``template_style_id``
    points a site at one row; cms-api resolves it to ``active_template`` +
    ``active_style`` (N3). At most one active ``is_default`` row per template --
    enforced at the app layer (this task's seed + N2's admin CRUD), since MySQL 8
    has no partial / filtered unique index to express it. The hard
    ``UNIQUE(template_id, style_id)`` constraint still forbids duplicate pairings.
    No history mirror is added: epic AISD-207 drops the ``*_history`` tables, so a
    new ``template_styles_history`` mirror + trigger would be immediately scheduled
    for removal.
    """

    __tablename__ = "template_styles"
    __table_args__ = (
        UniqueConstraint(
            "template_id", "style_id", name="uq_template_styles_template_style"
        ),
    )

    template_id: Mapped[int] = mapped_column(
        Integer, ForeignKey("templates.id"), nullable=False, index=True
    )
    style_id: Mapped[int] = mapped_column(
        Integer, ForeignKey("styles.id"), nullable=False, index=True
    )
    slug: Mapped[str] = mapped_column(String(128), nullable=False, unique=True)
    is_default: Mapped[bool] = mapped_column(
        TINYINT(1), nullable=False, server_default="0"
    )
    # Edit-tracking columns, mirroring the sibling template tables (AISD-126).
    edited_by: Mapped[Optional[int]] = mapped_column(
        Integer,
        ForeignKey("users.id", name="fk_template_styles_edited_by"),
        nullable=True,
        index=True,
    )
    creator_type: Mapped[Optional[str]] = mapped_column(String(64), nullable=True)

    template: Mapped["Template"] = relationship(
        "Template", back_populates="template_styles"
    )
    style: Mapped["Style"] = relationship("Style", back_populates="template_styles")

Action registry models

The forge action-registry table group (Action, Step, ActionStep and their history mirrors). See Action registry (forge recipe) for the narrative.

Forge action-registry models (epic AISD-174, task AISD-175; rename AISD-199).

The action registry lets cms-ai-forge's generation pipeline recipe live in cms_db instead of hardcoded Python. Three tables (ai_ prefix, AISD-199):

  • ai_actions -- a named workflow (the intent key, e.g. site_scaffold).
  • ai_steps -- a reusable step definition: its entity_type, the output_schema a provider result must satisfy, an optional prompt_template and provider_kind.
  • ai_action_steps -- the ordered join binding steps into an action (position, chain flag, per-binding params).

cms-ai-forge's planner reads an action's ordered steps from here (AISD-177) and its executor reads each step's schema/prompt/provider from the ai_steps row (AISD-178), replacing the hardcoded planner._expand_* / GENERATORS path. This task delivers ONLY the schema (models + history triggers); the cms-api admin CRUD (AISD-176) and the seed of today's intents (AISD-179) are siblings.

The task state-machine graph and the provider-call / coercion logic stay in code by design -- only the pipeline composition (which steps, in what order, producing what schema, with what prompt) is data.

ai_actions and ai_steps are operator-editable (via cms-api /admin), so each gets a flat history mirror + AFTER UPDATE trigger (the styles registry pattern, AISD-126/AISD-136). ai_action_steps is a junction and gets none.

Action

Bases: CMSBase, Base

A named generation workflow (the intent an ai-forge job requests).

name is the stable intent key (unique), e.g. site_scaffold or article_batch; description is human-facing. The ordered steps that make up the action live in ai_action_steps. Inherits id / created_at / updated_at / is_active from CMSBase.

Source code in pipeline.py
41
42
43
44
45
46
47
48
49
50
51
52
53
class Action(CMSBase, Base):
    """A named generation workflow (the intent an ai-forge job requests).

    ``name`` is the stable intent key (unique), e.g. ``site_scaffold`` or
    ``article_batch``; ``description`` is human-facing. The ordered steps that
    make up the action live in ``ai_action_steps``. Inherits
    ``id`` / ``created_at`` / ``updated_at`` / ``is_active`` from ``CMSBase``.
    """

    __tablename__ = "ai_actions"

    name: Mapped[str] = mapped_column(String(100), nullable=False, unique=True)
    description: Mapped[Optional[str]] = mapped_column(String(255), nullable=True)

Step

Bases: CMSBase, Base

A reusable pipeline step definition consumed by the ai-forge executor.

A Step describes one entity the executor can generate: slug is its stable identifier (unique), entity_type selects the generation behaviour in code (e.g. article, settings, image), output_schema is the JSON schema a (non-stub) provider result must satisfy, required_keys is an optional JSON list of keys the result must contain, prompt_template is the prompt (with placeholders) sent to the provider, and provider_kind selects the provider (e.g. openai_text, openai_image, stub). A step is reusable across actions via ai_action_steps. Inherits the CMSBase columns.

Source code in pipeline.py
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
class Step(CMSBase, Base):
    """A reusable pipeline step definition consumed by the ai-forge executor.

    A ``Step`` describes one entity the executor can generate: ``slug`` is its
    stable identifier (unique), ``entity_type`` selects the generation behaviour
    in code (e.g. ``article``, ``settings``, ``image``), ``output_schema`` is the
    JSON schema a (non-stub) provider result must satisfy, ``required_keys`` is an
    optional JSON list of keys the result must contain, ``prompt_template`` is the
    prompt (with placeholders) sent to the provider, and ``provider_kind`` selects
    the provider (e.g. ``openai_text``, ``openai_image``, ``stub``). A step is
    reusable across actions via ``ai_action_steps``. Inherits the ``CMSBase`` columns.
    """

    __tablename__ = "ai_steps"

    slug: Mapped[str] = mapped_column(String(100), nullable=False, unique=True)
    entity_type: Mapped[str] = mapped_column(String(50), nullable=False, index=True)
    output_schema: Mapped[Any] = mapped_column(JSON, nullable=False)
    required_keys: Mapped[Optional[Any]] = mapped_column(JSON, nullable=True)
    prompt_template: Mapped[Optional[str]] = mapped_column(Text, nullable=True)
    provider_kind: Mapped[Optional[str]] = mapped_column(String(50), nullable=True)

ActionStep

Bases: IntPKMixin, TimestampMixin, Base

Ordered binding of a :class:Step into an :class:Action.

Junction table (own surrogate id PK, timestamps, no is_active): action_id -> ai_actions.id and step_id -> ai_steps.id, position is the 0-based order within the action, chain mirrors the planner's chain flag (this step's output feeds the next), and params is optional per-binding JSON overrides. Unique on (action_id, position) so an action has exactly one step per position.

Source code in pipeline.py
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
class ActionStep(IntPKMixin, TimestampMixin, Base):
    """Ordered binding of a :class:`Step` into an :class:`Action`.

    Junction table (own surrogate ``id`` PK, timestamps, no ``is_active``):
    ``action_id`` -> ``ai_actions.id`` and ``step_id`` -> ``ai_steps.id``,
    ``position`` is the 0-based order within the action, ``chain`` mirrors the
    planner's chain flag (this step's output feeds the next), and ``params`` is
    optional per-binding JSON overrides. Unique on ``(action_id, position)`` so
    an action has exactly one step per position.
    """

    __tablename__ = "ai_action_steps"
    __table_args__ = (
        UniqueConstraint(
            "action_id", "position", name="uq_ai_action_steps_action_position"
        ),
    )

    action_id: Mapped[int] = mapped_column(
        Integer,
        ForeignKey("ai_actions.id", name="fk_ai_action_steps_action_id"),
        nullable=False,
        index=True,
    )
    step_id: Mapped[int] = mapped_column(
        Integer,
        ForeignKey("ai_steps.id", name="fk_ai_action_steps_step_id"),
        nullable=False,
        index=True,
    )
    position: Mapped[int] = mapped_column(Integer, nullable=False)
    chain: Mapped[bool] = mapped_column(TINYINT(1), nullable=False, server_default="0")
    params: Mapped[Optional[Any]] = mapped_column(JSON, nullable=True)

ActionHistory

Bases: IntPKMixin, Base

A flat audit mirror of an ai_actions row's prior state.

Decoupled mirror per the StyleHistory pattern: own surrogate id PK; a plain indexed action_id INT (the OLD ai_actions.id) with no foreign key; changed_at; every mirrored column nullable, no unique, no FK. Rows are inserted only by the trg_ai_actions_history AFTER UPDATE trigger; the column list stays in lock-step with that trigger's INSERT.

Source code in pipeline.py
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
class ActionHistory(IntPKMixin, Base):
    """A flat audit mirror of an ``ai_actions`` row's prior state.

    Decoupled mirror per the ``StyleHistory`` pattern: own surrogate ``id`` PK; a
    plain indexed ``action_id`` INT (the OLD ``ai_actions.id``) with **no foreign
    key**; ``changed_at``; every mirrored column nullable, no unique, no FK. Rows
    are inserted only by the ``trg_ai_actions_history`` AFTER UPDATE trigger; the
    column list stays in lock-step with that trigger's INSERT.
    """

    __tablename__ = "ai_action_history"

    action_id: Mapped[int] = mapped_column(Integer, nullable=False, index=True)
    changed_at: Mapped[Optional[datetime]] = mapped_column(DateTime, nullable=True)
    name: Mapped[Optional[str]] = mapped_column(String(100), nullable=True)
    description: Mapped[Optional[str]] = mapped_column(String(255), nullable=True)
    is_active: Mapped[Optional[bool]] = mapped_column(TINYINT(1), nullable=True)

StepHistory

Bases: IntPKMixin, Base

A flat audit mirror of an ai_steps row's prior state.

Decoupled mirror per the StyleHistory pattern: own surrogate id PK; a plain indexed step_id INT (the OLD ai_steps.id) with no foreign key; changed_at; every mirrored column nullable, no unique, no FK -- including the JSON output_schema / required_keys so a prior step definition is recoverable. Rows are inserted only by the trg_ai_steps_history AFTER UPDATE trigger; the column list stays in lock-step with that trigger's INSERT.

Source code in pipeline.py
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
class StepHistory(IntPKMixin, Base):
    """A flat audit mirror of an ``ai_steps`` row's prior state.

    Decoupled mirror per the ``StyleHistory`` pattern: own surrogate ``id`` PK; a
    plain indexed ``step_id`` INT (the OLD ``ai_steps.id``) with **no foreign
    key**; ``changed_at``; every mirrored column nullable, no unique, no FK --
    including the JSON ``output_schema`` / ``required_keys`` so a prior step
    definition is recoverable. Rows are inserted only by the
    ``trg_ai_steps_history`` AFTER UPDATE trigger; the column list stays in
    lock-step with that trigger's INSERT.
    """

    __tablename__ = "ai_step_history"

    step_id: Mapped[int] = mapped_column(Integer, nullable=False, index=True)
    changed_at: Mapped[Optional[datetime]] = mapped_column(DateTime, nullable=True)
    slug: Mapped[Optional[str]] = mapped_column(String(100), nullable=True)
    entity_type: Mapped[Optional[str]] = mapped_column(String(50), nullable=True)
    output_schema: Mapped[Optional[Any]] = mapped_column(JSON, nullable=True)
    required_keys: Mapped[Optional[Any]] = mapped_column(JSON, nullable=True)
    prompt_template: Mapped[Optional[str]] = mapped_column(Text, nullable=True)
    provider_kind: Mapped[Optional[str]] = mapped_column(String(50), nullable=True)
    is_active: Mapped[Optional[bool]] = mapped_column(TINYINT(1), nullable=True)