Initial commit

This commit is contained in:
shiyu
2025-08-24 18:49:00 +08:00
parent 99866befe1
commit 6b0f2bd4fa
129 changed files with 11587 additions and 0 deletions
+12
View File
@@ -0,0 +1,12 @@
from .adapters import AdapterCreate, AdapterOut
from .mounts import MountCreate, MountOut
from .fs import MkdirRequest, MoveRequest
__all__ = [
"AdapterCreate",
"AdapterOut",
"MountCreate",
"MountOut",
"MkdirRequest",
"MoveRequest",
]
+32
View File
@@ -0,0 +1,32 @@
from typing import Dict, Optional
from pydantic import BaseModel, Field, validator
class AdapterCreate(BaseModel):
name: str
type: str = Field(pattern=r"^[a-zA-Z0-9_]+$")
config: Dict = Field(default_factory=dict)
enabled: bool = True
mount_path: str
sub_path: Optional[str] = None
@staticmethod
def normalize_mount_path(p: str) -> str:
p = p.strip()
if not p.startswith('/'):
p = '/' + p
p = p.rstrip('/')
return p or '/'
@validator("mount_path")
def _v_mount(cls, v: str):
if not v:
raise ValueError("mount_path required")
return cls.normalize_mount_path(v)
class AdapterOut(AdapterCreate):
id: int
class Config:
from_attributes = True
+32
View File
@@ -0,0 +1,32 @@
from pydantic import BaseModel
from typing import List, Optional
class VfsEntry(BaseModel):
name: str
is_dir: bool
size: int
mtime: int
type: Optional[str] = None
is_image: Optional[bool] = None
class DirListing(BaseModel):
path: str
entries: List[VfsEntry]
pagination: Optional[dict] = None
class SearchResultItem(BaseModel):
id: int | str
path: str
score: float
class MkdirRequest(BaseModel):
path: str
class MoveRequest(BaseModel):
src: str
dst: str
+23
View File
@@ -0,0 +1,23 @@
from typing import Optional
from pydantic import BaseModel
class MountCreate(BaseModel):
path: str
adapter_id: int
sub_path: Optional[str] = None
enabled: bool = True
@staticmethod
def normalize(path: str) -> str:
return (path if path.startswith('/') else '/' + path).rstrip('/') or '/'
def model_post_init(self, __context):
self.path = self.normalize(self.path)
class MountOut(MountCreate):
id: int
class Config:
from_attributes = True
+31
View File
@@ -0,0 +1,31 @@
from pydantic import BaseModel
from typing import Optional, Dict, Any
class AutomationTaskBase(BaseModel):
name: str
event: str
path_pattern: Optional[str] = None
filename_regex: Optional[str] = None
processor_type: str
processor_config: Dict[str, Any] = {}
enabled: bool = True
class AutomationTaskCreate(AutomationTaskBase):
pass
class AutomationTaskUpdate(AutomationTaskBase):
name: Optional[str] = None
event: Optional[str] = None
processor_type: Optional[str] = None
processor_config: Optional[Dict[str, Any]] = None
enabled: Optional[bool] = None
class AutomationTaskRead(AutomationTaskBase):
id: int
class Config:
orm_mode = True