Erste Produktivversion
This commit is contained in:
29
backend/app/schemas_sync.py
Normal file
29
backend/app/schemas_sync.py
Normal file
@@ -0,0 +1,29 @@
|
||||
from typing import Any, Literal
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
OpKind = Literal["item.create", "item.update", "item.delete", "items.clear_bought"]
|
||||
|
||||
|
||||
class OpIn(BaseModel):
|
||||
# Vom Client vergeben, bevor gesendet wird. Grundlage der Idempotenz:
|
||||
# dieselbe op_id wird nie zweimal ausgefuehrt.
|
||||
op_id: str = Field(min_length=8, max_length=64)
|
||||
kind: OpKind
|
||||
payload: dict[str, Any] = Field(default_factory=dict)
|
||||
|
||||
|
||||
class OpBatchIn(BaseModel):
|
||||
ops: list[OpIn] = Field(default_factory=list, max_length=200)
|
||||
|
||||
|
||||
class OpResult(BaseModel):
|
||||
op_id: str
|
||||
status: Literal["applied", "duplicate", "rejected"]
|
||||
result_id: str | None = None
|
||||
error: str | None = None
|
||||
|
||||
|
||||
class OpBatchOut(BaseModel):
|
||||
rev: int
|
||||
results: list[OpResult]
|
||||
Reference in New Issue
Block a user