57 lines
2.6 KiB
Python
57 lines
2.6 KiB
Python
|
|
from fastapi import APIRouter, FastAPI
|
|||
|
|
from fastapi.responses import JSONResponse
|
|||
|
|
|
|||
|
|
router = APIRouter()
|
|||
|
|
|
|||
|
|
@router.get("/api/schema/manifest")
|
|||
|
|
async def manifest():
|
|||
|
|
data = {
|
|||
|
|
"nodes": {
|
|||
|
|
"DirectoryScanner": {
|
|||
|
|
"display_name": "目录扫描器",
|
|||
|
|
"category": "IO/Scanner",
|
|||
|
|
"description": "扫描目录并输出文件路径列表",
|
|||
|
|
"icon": "📁",
|
|||
|
|
"node_type": "input",
|
|||
|
|
"class_name": "DirectoryScanner",
|
|||
|
|
"node_logic": "standard",
|
|||
|
|
"supports_preview": True,
|
|||
|
|
"inputs": [],
|
|||
|
|
"outputs": [
|
|||
|
|
{"name": "count", "type": "Number", "description": "文件数量"},
|
|||
|
|
{"name": "files", "type": "Array<String>", "description": "文件路径列表(数组)"}
|
|||
|
|
],
|
|||
|
|
"param_schema": [
|
|||
|
|
{"name": "max_files", "type": "Number", "default": 0, "description": "最大文件数(0=无限制)", "min": 0, "step": 1},
|
|||
|
|
{"name": "reverse_sort", "type": "Boolean", "default": False, "description": "反向排序"},
|
|||
|
|
{"name": "sort_by", "type": "String", "default": "name", "description": "排序方式", "options": ["name", "size", "modified", "created", "none"]},
|
|||
|
|
{"name": "recursive", "type": "Boolean", "default": False, "description": "是否递归扫描子目录"},
|
|||
|
|
{"name": "pattern", "type": "String", "default": "*.utrace", "description": "文件匹配模式(支持 glob)", "required": True},
|
|||
|
|
{"name": "directory", "type": "String", "default": "", "description": "要扫描的目录(相对于用户目录)", "required": True}
|
|||
|
|
],
|
|||
|
|
"context_vars": {},
|
|||
|
|
"cache_policy": "none"
|
|||
|
|
},
|
|||
|
|
"TraceLoader": {
|
|||
|
|
"display_name": "Trace Loader",
|
|||
|
|
"category": "IO/Loader",
|
|||
|
|
"description": "加载单个 utrace 文件并解析",
|
|||
|
|
"icon": "📦",
|
|||
|
|
"node_type": "processor",
|
|||
|
|
"class_name": "TraceLoader",
|
|||
|
|
"node_logic": "standard",
|
|||
|
|
"supports_preview": True,
|
|||
|
|
"inputs": [{"name": "file", "type": "String"}],
|
|||
|
|
"outputs": [{"name": "trace", "type": "DataTable"}],
|
|||
|
|
"param_schema": [{"name": "sampleRate", "type": "Number", "default": 10}],
|
|||
|
|
"context_vars": {},
|
|||
|
|
"cache_policy": "none"
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return JSONResponse(content=data)
|
|||
|
|
|
|||
|
|
|
|||
|
|
def register(app: FastAPI):
|
|||
|
|
app.include_router(router)
|