Prepare AI-ready 1C structure packages
This commit is contained in:
@@ -63,6 +63,11 @@ from api_server.html5_access_controller import (
|
||||
html5_access_publish_plan as _html5_access_publish_plan,
|
||||
html5_access_user_detail as _html5_access_user_detail,
|
||||
)
|
||||
from api_server.ai_structure_service import prepare_ai_structure as _prepare_ai_structure
|
||||
from api_server.html5_ai_structure_controller import (
|
||||
html5_ai_structure_page as _html5_ai_structure_page,
|
||||
html5_ai_structure_run as _html5_ai_structure_run,
|
||||
)
|
||||
from api_server.html5_editor_controller import (
|
||||
html5_editor_page as _html5_editor_page,
|
||||
html5_form_editor_page as _html5_form_editor_page,
|
||||
@@ -840,6 +845,27 @@ class ImportRequest(BaseModel):
|
||||
mode: ImportMode = ImportMode.FULL_REPLACE
|
||||
|
||||
|
||||
class AiStructurePrepareRequest(BaseModel):
|
||||
input_path: str
|
||||
output_path: str
|
||||
project_id: str | None = None
|
||||
structure_only: bool = False
|
||||
|
||||
|
||||
class AiStructurePrepareResponse(BaseModel):
|
||||
version: str
|
||||
project_id: str
|
||||
input_path: str
|
||||
output_path: str
|
||||
status: str
|
||||
files_count: int = 0
|
||||
binary_1c_files: list[dict] = Field(default_factory=list)
|
||||
artifacts: list[str] = Field(default_factory=list)
|
||||
snapshot: dict | None = None
|
||||
normalized: dict | None = None
|
||||
diagnostics: list[str] = Field(default_factory=list)
|
||||
|
||||
|
||||
class AccessProfileDraftRequest(BaseModel):
|
||||
name: str
|
||||
target_objects: list[str] = Field(default_factory=list)
|
||||
@@ -1554,6 +1580,25 @@ async def html5_project_access(project_id: str, profile: str | None = None) -> R
|
||||
)
|
||||
|
||||
|
||||
@app.get("/html5/projects/{project_id}/ai-structure")
|
||||
async def html5_project_ai_structure(project_id: str) -> Response:
|
||||
return _html5_response(
|
||||
_html5_ai_structure_page(project_id=project_id, project_summaries=_project_summaries)
|
||||
)
|
||||
|
||||
|
||||
@app.post("/html5/projects/{project_id}/ai-structure/run")
|
||||
async def html5_project_ai_structure_run(project_id: str, request: Request) -> Response:
|
||||
form = await _html5_form_data(request)
|
||||
return _html5_response(
|
||||
_html5_ai_structure_run(
|
||||
project_id=project_id,
|
||||
form=form,
|
||||
prepare=_prepare_ai_structure,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@app.get("/html5/projects/{project_id}/access/profiles/{profile_name}/plan")
|
||||
async def html5_project_access_profile_plan(project_id: str, profile_name: str) -> Response:
|
||||
return _html5_response(
|
||||
@@ -3318,6 +3363,21 @@ async def runtime_platform() -> dict:
|
||||
}
|
||||
|
||||
|
||||
@app.post("/ai-structure/prepare", response_model=AiStructurePrepareResponse)
|
||||
async def prepare_ai_structure_endpoint(request: AiStructurePrepareRequest) -> AiStructurePrepareResponse:
|
||||
project_id = request.project_id or f"ai-structure-{uuid4()}"
|
||||
try:
|
||||
payload = _prepare_ai_structure(
|
||||
project_id=project_id,
|
||||
input_path=Path(request.input_path),
|
||||
output_path=Path(request.output_path),
|
||||
structure_only=request.structure_only,
|
||||
)
|
||||
except FileNotFoundError as error:
|
||||
raise HTTPException(status_code=404, detail=str(error)) from error
|
||||
return AiStructurePrepareResponse.model_validate(payload)
|
||||
|
||||
|
||||
@app.get("/storage")
|
||||
async def storage() -> dict[str, str]:
|
||||
return {"status": "configured", "path": _storage.root.as_posix()}
|
||||
|
||||
Reference in New Issue
Block a user