refactored for camelCase
This commit is contained in:
parent
c6e2dd3641
commit
0fcd355644
|
|
@ -1,10 +1,16 @@
|
||||||
from uuid import UUID, uuid4
|
from uuid import UUID, uuid4
|
||||||
from pydantic import BaseModel, Field
|
from pydantic import BaseModel, Field
|
||||||
|
from pydantic.alias_generators import to_camel
|
||||||
|
|
||||||
|
|
||||||
|
class BaseConfig:
|
||||||
|
alias_generator = to_camel
|
||||||
|
json_encoders = {UUID: str}
|
||||||
|
arbitrary_types_allowed = True
|
||||||
|
|
||||||
|
|
||||||
class BaseMongoModel(BaseModel):
|
class BaseMongoModel(BaseModel):
|
||||||
id: UUID = Field(default_factory=uuid4, alias="_id")
|
id: UUID = Field(default_factory=uuid4, alias="_id")
|
||||||
|
|
||||||
class Config:
|
class Config(BaseConfig):
|
||||||
json_encoders = {UUID: str}
|
pass
|
||||||
arbitrary_types_allowed = True
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
from .base import BaseMongoModel
|
from .base import BaseConfig, BaseMongoModel
|
||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from pydantic import BaseModel, Field
|
from pydantic import BaseModel, Field
|
||||||
|
|
@ -9,11 +9,17 @@ class WaitAction(BaseModel):
|
||||||
action_type: Literal["wait"]
|
action_type: Literal["wait"]
|
||||||
wait_for: int
|
wait_for: int
|
||||||
|
|
||||||
|
class Config(BaseConfig):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class TextCommentAction(BaseModel):
|
class TextCommentAction(BaseModel):
|
||||||
action_type: Literal["text_comment"]
|
action_type: Literal["text_comment"]
|
||||||
text: str
|
text: str
|
||||||
|
|
||||||
|
class Config(BaseConfig):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
Action = Annotated[
|
Action = Annotated[
|
||||||
Union[WaitAction, TextCommentAction], Field(description="action_type")
|
Union[WaitAction, TextCommentAction], Field(description="action_type")
|
||||||
|
|
@ -25,5 +31,5 @@ class Chain(BaseMongoModel):
|
||||||
actions: Annotated[Optional[List[Action]], Field(default=[])]
|
actions: Annotated[Optional[List[Action]], Field(default=[])]
|
||||||
last_modified: Annotated[datetime, Field(default_factory=datetime.utcnow)]
|
last_modified: Annotated[datetime, Field(default_factory=datetime.utcnow)]
|
||||||
|
|
||||||
class Config(BaseMongoModel.Config):
|
class Config(BaseConfig):
|
||||||
pass
|
pass
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user