from backend.database.base import db
from backend.database.models import (
    JsonEncoded,
    PrincipalTypeEnum,
    TimestampMixin,
    args,
    fk_prefix,
    string_enum,
    tables_prefix,
)


class AgentShare(db.Model):
    __tablename__ = f"{tables_prefix}agent_shares"
    __table_args__ = args

    agent_id = db.Column(db.String, db.ForeignKey(f"{fk_prefix}agents.id"), primary_key=True)
    principal = db.Column(db.String, primary_key=True)
    principal_type = db.Column(string_enum(PrincipalTypeEnum), nullable=False)


class DraftConversation(db.Model, TimestampMixin):
    __tablename__ = f"{tables_prefix}draft_conversations"
    __table_args__ = args
    agent_id = db.Column(db.String, primary_key=True)
    user_id = db.Column(db.String, primary_key=True)
    convo = db.Column(JsonEncoded, default=dict)
