@@ -0,0 +1,30 @@
|
||||
from typing import Literal
|
||||
from pydantic import BaseModel, Field
|
||||
from .schematic import Diagnostic
|
||||
|
||||
class ApiError(BaseModel):
|
||||
code: str
|
||||
message: str
|
||||
|
||||
class ErrorEnvelope(BaseModel):
|
||||
success: Literal[False] = False
|
||||
error: ApiError
|
||||
|
||||
class RenderStatus(BaseModel):
|
||||
success: bool
|
||||
id: str = Field(description='Unpredictable 192-bit identifier, encoded as 48 hex characters')
|
||||
status: Literal['queued','processing','completed','failed']
|
||||
viewer_url: str = Field(description='Base viewer URL; only initial upload includes private token fragment')
|
||||
expires_at: float = Field(description='Unix timestamp, UTC seconds')
|
||||
access: Literal['private','unlisted']
|
||||
schema_version: str | None = None
|
||||
compatibility: Literal['partial','supported_subset'] | None = None
|
||||
record_count: int | None = None
|
||||
component_count: int | None = None
|
||||
primitive_count: int | None = None
|
||||
diagnostics: list[Diagnostic] | None = None
|
||||
error: ApiError | None = None
|
||||
|
||||
class UploadResponse(RenderStatus):
|
||||
status_url: str
|
||||
viewer_token: str | None = Field(default=None,description='Read capability returned once for a private upload')
|
||||
@@ -0,0 +1,156 @@
|
||||
"""Versioned, JSON-native contract. Coordinates are 10 mil, X right, Y down."""
|
||||
|
||||
from typing import Literal
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
|
||||
class Point(BaseModel):
|
||||
x: float
|
||||
y: float
|
||||
|
||||
|
||||
class Bounds(BaseModel):
|
||||
x: float
|
||||
y: float
|
||||
width: float
|
||||
height: float
|
||||
|
||||
|
||||
class Diagnostic(BaseModel):
|
||||
severity: Literal["info", "warning", "error"]
|
||||
code: str
|
||||
message: str
|
||||
record_id: str | None = None
|
||||
record_type: int | None = None
|
||||
count: int = 1
|
||||
|
||||
|
||||
class Primitive(BaseModel):
|
||||
id: str
|
||||
kind: Literal["path", "text", "image"]
|
||||
bounds: Bounds
|
||||
clip: Bounds | None = None
|
||||
path: str = ""
|
||||
text: str = ""
|
||||
image_data: str = ""
|
||||
keep_aspect: bool = True
|
||||
position: Point = Field(default_factory=lambda: Point(x=0, y=0))
|
||||
rotation: float = 0
|
||||
mirrored: bool = False
|
||||
stroke: str = "#000000"
|
||||
fill: str = "none"
|
||||
width: float = 0.4
|
||||
dash: list[float] = Field(default_factory=list)
|
||||
font_family: str = "Arial"
|
||||
font_size: float = 10
|
||||
bold: bool = False
|
||||
italic: bool = False
|
||||
underline: bool = False
|
||||
anchor: Literal["start", "middle", "end"] = "start"
|
||||
baseline: Literal["alphabetic", "middle", "hanging"] = "alphabetic"
|
||||
layer_id: str | None = None
|
||||
net_id: str | None = None
|
||||
role: str = ""
|
||||
fill_rule: Literal["nonzero", "evenodd"] = "nonzero"
|
||||
object_id: str
|
||||
component_id: str | None = None
|
||||
|
||||
|
||||
class SchematicObject(BaseModel):
|
||||
id: str
|
||||
kind: str
|
||||
record_type: int
|
||||
source_stream: str
|
||||
source_index: int
|
||||
owner_id: str | None = None
|
||||
component_id: str | None = None
|
||||
visible: bool = True
|
||||
layer_id: str | None = None
|
||||
net_id: str | None = None
|
||||
position: Point
|
||||
bounds: Bounds
|
||||
properties: dict[str, str]
|
||||
primitive_ids: list[str] = Field(default_factory=list)
|
||||
connection_points: list[Point] = Field(default_factory=list)
|
||||
|
||||
|
||||
class Pin(BaseModel):
|
||||
id: str
|
||||
name: str
|
||||
number: str
|
||||
electrical_type: str
|
||||
position: Point
|
||||
connection: Point
|
||||
length: float
|
||||
rotation: float
|
||||
visible: bool
|
||||
active: bool
|
||||
net_id: str | None = None
|
||||
|
||||
|
||||
class Component(BaseModel):
|
||||
id: str
|
||||
symbol_id: str
|
||||
designator: str = ""
|
||||
name: str = ""
|
||||
value: str = ""
|
||||
comment: str = ""
|
||||
description: str = ""
|
||||
library_reference: str = ""
|
||||
source_library: str = ""
|
||||
position: Point
|
||||
rotation: float = 0
|
||||
mirrored: bool = False
|
||||
current_part: int = 1
|
||||
bounds: Bounds
|
||||
pins: list[Pin] = Field(default_factory=list)
|
||||
parameters: dict[str, str] = Field(default_factory=dict)
|
||||
primitive_ids: list[str] = Field(default_factory=list)
|
||||
object_ids: list[str] = Field(default_factory=list)
|
||||
|
||||
|
||||
class Symbol(BaseModel):
|
||||
id: str
|
||||
component_id: str
|
||||
primitive_ids: list[str]
|
||||
|
||||
|
||||
class Sheet(BaseModel):
|
||||
id: str = "sheet-0"
|
||||
name: str
|
||||
background: str = "#fffcf8"
|
||||
bounds: Bounds
|
||||
properties: dict[str, str]
|
||||
|
||||
|
||||
class BoardLayer(BaseModel):
|
||||
id: str
|
||||
name: str
|
||||
color: str
|
||||
category: str
|
||||
visible: bool
|
||||
order: int
|
||||
object_count: int = 0
|
||||
|
||||
|
||||
class Net(BaseModel):
|
||||
id: str
|
||||
name: str
|
||||
properties: dict[str, str] = Field(default_factory=dict)
|
||||
|
||||
|
||||
class Document(BaseModel):
|
||||
schema_version: str = "1.0"
|
||||
document_type: Literal["schematic", "pcb"] = "schematic"
|
||||
layers: list[BoardLayer] = Field(default_factory=list)
|
||||
nets: list[Net] = Field(default_factory=list)
|
||||
id: str
|
||||
filename: str
|
||||
metadata: dict
|
||||
sheet: Sheet
|
||||
bounds: Bounds
|
||||
components: list[Component]
|
||||
symbols: list[Symbol]
|
||||
objects: list[SchematicObject]
|
||||
primitives: list[Primitive]
|
||||
diagnostics: list[Diagnostic]
|
||||
مرجع در شماره جدید
مسدود کردن کاربر