from dataclasses import dataclass
from typing import Optional, Literal


ActivityKind = Literal[
    "CREATE_THREAT",
    "CREATE_COUNTERMEASURE",
    "AUTO_RESOLVE",
    "CREATE_RISK_PATTERN",
]


@dataclass
class Activity:
    kind: ActivityKind
    value: str


@dataclass
class RelationRule:
    name: str
    source_type: str
    relation_type: str
    target_type: str
    activity: Activity
    salience: Optional[int] = None
    no_loop: bool = False

    origin: str = "custom"
    editable: bool = True
    module: Optional[str] = None
    raw_drl: Optional[str] = None


@dataclass
class CanonicalRule:
    id: str
    kind: str
    source_type: str
    relation_type: str
    target_type: str
    action_kind: str
    action_value: str
    origin: str
    editable: bool
    raw_drl: Optional[str] = None


@dataclass
class SvgObject:
    id: str
    type: str
    label: Optional[str] = None


@dataclass
class SvgRelation:
    source_id: str
    target_id: str
    relation_type: str


@dataclass
class RuleEvaluation:
    applies: bool
    reasons: list[str]
    failed: list[str]
