from dataclasses import dataclass, field
from typing import NotRequired, TypedDict


def append_tag(tag: str, tags: list[str] | None = None) -> list[str]:
    current_tags = [] if tags is None else list(tags)
    current_tags.append(tag)
    return current_tags


@dataclass
class JobOptions:
    user_ids: list[str] = field(default_factory=list)
    metadata: dict[str, str] = field(default_factory=dict)
    enabled: bool = False
    region: str | None = None
    priority: int | None = None
    max_items: int = 10

    def __post_init__(self):
        self.slug = self.region or "default"


class PayloadShape(TypedDict):
    name: str
    alias: NotRequired[str]


def render_payload(payload: PayloadShape, extras: dict[str, str]) -> str:
    alias = payload.get("alias", payload["name"])
    return f"{payload['name']}:{alias}:{extras['region']}"