feat: implement full arch design dashboard #1
|
|
@ -0,0 +1,22 @@
|
|||
from dataclasses import dataclass
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
@dataclass
|
||||
class EditableFile:
|
||||
path: str
|
||||
format: str # csv, md, yaml, openapi
|
||||
content: str
|
||||
last_modified: datetime
|
||||
|
||||
|
||||
@dataclass
|
||||
class AffectedFile:
|
||||
path: str
|
||||
reason: str
|
||||
|
||||
|
||||
@dataclass
|
||||
class ImpactResult:
|
||||
source_file: str
|
||||
affected_files: list[AffectedFile]
|
||||
35
backend/app/modules/editor/infrastructure/file_io.py
Normal file
35
backend/app/modules/editor/infrastructure/file_io.py
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
from datetime import datetime, timezone
|
||||
from pathlib import Path
|
||||
|
||||
from app.modules.editor.domain.entities import EditableFile
|
||||
from app.shared.infrastructure.filesystem import read_text, write_text
|
||||
|
||||
|
||||
def detect_format(file_path: Path) -> str:
|
||||
suffix = file_path.suffix.lower()
|
||||
if suffix == ".csv":
|
||||
return "csv"
|
||||
elif suffix == ".md":
|
||||
return "md"
|
||||
elif suffix in (".yaml", ".yml"):
|
||||
if "openapi" in file_path.name or "api-contracts" in file_path.name:
|
||||
return "openapi"
|
||||
return "yaml"
|
||||
return "unknown"
|
||||
|
||||
|
||||
def read_file(base_dir: Path, relative_path: str) -> EditableFile:
|
||||
full_path = base_dir / relative_path
|
||||
content = read_text(full_path)
|
||||
stat = full_path.stat()
|
||||
return EditableFile(
|
||||
path=relative_path,
|
||||
format=detect_format(full_path),
|
||||
content=content,
|
||||
last_modified=datetime.fromtimestamp(stat.st_mtime, tz=timezone.utc),
|
||||
)
|
||||
|
||||
|
||||
def write_file(base_dir: Path, relative_path: str, content: str) -> None:
|
||||
full_path = base_dir / relative_path
|
||||
write_text(full_path, content)
|
||||
Loading…
Reference in New Issue
Block a user