from pydantic import BaseModel from typing import Optional PROTOCOLS = ["escpos_tcp"] # extend later as needed # Known printer profiles — (codepage_n, python_encoding) # codepage_n: the n byte in ESC t n sent on connect # python_encoding: used to encode Greek text to bytes PRINTER_PROFILES = { "jolimark": {"label": "Jolimark TP850UE", "codepage_n": 29, "encoding": "cp737"}, "samas": {"label": "S4MAS Giant 100", "codepage_n": 29, "encoding": "cp737"}, "netum": {"label": "NETUM NT8330L", "codepage_n": 14, "encoding": "cp737"}, } DEFAULT_PROFILE = "jolimark" class PrinterBase(BaseModel): name: str ip_address: str port: int = 9100 is_active: bool = True protocol: str = "escpos_tcp" line_width: int = 48 codepage_n: int = 29 class PrinterCreate(PrinterBase): pass class PrinterUpdate(BaseModel): name: Optional[str] = None ip_address: Optional[str] = None port: Optional[int] = None is_active: Optional[bool] = None protocol: Optional[str] = None line_width: Optional[int] = None codepage_n: Optional[int] = None class PrinterOut(PrinterBase): id: int model_config = {"from_attributes": True}