forked from hesabix/arc
35 lines
1.6 KiB
Python
35 lines
1.6 KiB
Python
from __future__ import annotations
|
|
|
|
from datetime import datetime
|
|
|
|
from sqlalchemy import Boolean, DateTime, ForeignKey, Integer, String, Text, UniqueConstraint
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
from adapters.db.session import Base
|
|
|
|
|
|
class AIConnector(Base):
|
|
"""کانکتور HTTP خارجی قابل فراخوانی توسط AI (MCP-lite)."""
|
|
|
|
__tablename__ = "ai_connectors"
|
|
__table_args__ = (UniqueConstraint("business_id", "name", name="uq_ai_connectors_business_name"),)
|
|
|
|
id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True)
|
|
business_id: Mapped[int] = mapped_column(
|
|
Integer, ForeignKey("businesses.id", ondelete="CASCADE"), nullable=False, index=True
|
|
)
|
|
user_id: Mapped[int] = mapped_column(
|
|
Integer, ForeignKey("users.id", ondelete="CASCADE"), nullable=False
|
|
)
|
|
name: Mapped[str] = mapped_column(String(128), nullable=False)
|
|
title: Mapped[str] = mapped_column(String(512), nullable=False)
|
|
description: Mapped[str | None] = mapped_column(Text, nullable=True)
|
|
http_method: Mapped[str] = mapped_column(String(16), nullable=False, default="GET")
|
|
url: Mapped[str] = mapped_column(Text, nullable=False)
|
|
headers_json: Mapped[str | None] = mapped_column(Text, nullable=True)
|
|
body_template: Mapped[str | None] = mapped_column(Text, nullable=True)
|
|
is_active: Mapped[bool] = mapped_column(Boolean, nullable=False, default=True)
|
|
created_at: Mapped[datetime] = mapped_column(DateTime, default=datetime.utcnow, nullable=False)
|
|
updated_at: Mapped[datetime] = mapped_column(
|
|
DateTime, default=datetime.utcnow, onupdate=datetime.utcnow, nullable=False
|
|
)
|