Files
leocrm/app/plugins/builtins/mail/contracts.py
T

46 lines
1.1 KiB
Python
Raw Normal View History

2026-07-25 21:03:46 +02:00
"""Public contract for the mail plugin.
Exposes only the symbols that other builtins plugins need.
Currently the only cross-plugin consumer is ai_proactive, which imports
the ``Mail`` model for querying recent emails by contact.
Importers should use::
from app.plugins.builtins.contracts import get_contract
mail = get_contract("mail")
if mail:
result = await db.execute(select(mail.Mail).where(...))
instead of importing from internal modules directly.
"""
from __future__ import annotations
from app.plugins.builtins.contracts import get_contract_registry
from app.plugins.builtins.mail.models import Mail
class MailContract:
"""Public API surface for the mail plugin.
Exposes the ``Mail`` ORM model so that other plugins can query the
mails table without importing from ``mail.models`` directly.
"""
contract_name = "mail"
# ─── models ───
Mail = Mail
# ─── self-registration ───
_contract = MailContract()
get_contract_registry().register("mail", _contract)
__all__ = [
"MailContract",
"Mail",
]