refactor: name node

This commit is contained in:
TheNoxium
2025-09-12 14:04:28 +05:00
parent 78b6466b14
commit 12e3c65aa0
22 changed files with 127 additions and 127 deletions

View File

@@ -1,62 +0,0 @@
from typing import Dict, Any
from core import VorkNode
from model_nodes.node_if_models import (
IfNodeData,
IfNodeLinks,
IfNodeCoreSchema,
IfNodeCoreSchemaData,
IfNodeDescriptor
)
class VorkNodeIf(VorkNode):
@property
def id(self) -> str:
return "vork_node_if"
@classmethod
def form(cls) -> IfNodeDescriptor:
return IfNodeDescriptor()
def validate(self) -> IfNodeCoreSchema:
"""
Валидирует данные и связи узла с помощью Pydantic моделей
и возвращает схему с валидированными данными.
"""
try:
# Валидируем данные
validated_data = self.validate_data()
# Валидируем связи
validated_links = self.validate_links()
# Создаем вложенную схему с данными портов
node_data = IfNodeCoreSchemaData(
then_port_number=0,
else_port_number=1,
)
# Создаем схему с валидированными данными из экземпляра
return IfNodeCoreSchema(
ps_id=validated_data.ps_id,
node_type=validated_data.node_type,
parent_id=validated_links.parent_id,
parent_port_number=validated_links.parent_port_number,
data=node_data,
)
except Exception as e:
print(f"Node validation error if: {e}")
raise
def validate_data(self) -> IfNodeData:
return IfNodeData(**self.data)
def validate_links(self) -> IfNodeLinks:
return IfNodeLinks(**self.links)
def process(self, context: Any) -> bool:
return True