fix: descriptor (listen, set, if, )deprecated typings
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
from __future__ import annotations
|
||||
from typing import Optional, Annotated, Literal, List
|
||||
from typing import Optional, Annotated, Literal, Any
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
|
||||
class LinkPort(BaseModel):
|
||||
id: str
|
||||
id: int
|
||||
label: str
|
||||
is_addable: Optional[bool] = None
|
||||
|
||||
@@ -14,6 +14,7 @@ class LineElement(BaseModel):
|
||||
name: str
|
||||
label: str
|
||||
placeholder: Optional[str] = None
|
||||
value: str = None
|
||||
|
||||
|
||||
class AreaElement(BaseModel):
|
||||
@@ -21,15 +22,17 @@ class AreaElement(BaseModel):
|
||||
name: str
|
||||
label: str
|
||||
placeholder: Optional[str] = None
|
||||
value: str = None
|
||||
|
||||
|
||||
class SelectElement(BaseModel):
|
||||
type: Literal['select']
|
||||
name: str
|
||||
label: str
|
||||
data: List[str]
|
||||
data: list[str]
|
||||
default: Optional[str] = None
|
||||
placeholder: Optional[str] = None
|
||||
value: Optional[Any] = None
|
||||
|
||||
|
||||
class NumberElement(BaseModel):
|
||||
@@ -37,6 +40,7 @@ class NumberElement(BaseModel):
|
||||
name: str
|
||||
label: str
|
||||
placeholder: Optional[str] = None
|
||||
value: int | float
|
||||
|
||||
|
||||
class DateElement(BaseModel):
|
||||
@@ -44,6 +48,7 @@ class DateElement(BaseModel):
|
||||
name: str
|
||||
label: str
|
||||
placeholder: Optional[str] = None
|
||||
value: str = None
|
||||
|
||||
|
||||
FieldElement = Annotated[
|
||||
@@ -57,11 +62,11 @@ class RowElement(BaseModel):
|
||||
name: str
|
||||
label: str
|
||||
link_port: Optional[LinkPort] = None
|
||||
elements: Optional[List[FieldElement]] = None
|
||||
elements: Optional[list[FieldElement]] = None
|
||||
|
||||
|
||||
class FormDescriptor(BaseModel):
|
||||
elements: List[RowElement]
|
||||
elements: list[RowElement]
|
||||
|
||||
|
||||
# Descriptor-suffixed aliases for clarity (backward compatible)
|
||||
|
||||
@@ -36,14 +36,18 @@ class IfNodeCoreSchema(BaseModel):
|
||||
data: Optional[IfNodeCoreSchemaData] = Field(default=None, description="Данные узла")
|
||||
|
||||
|
||||
# Дескриптор формы узла IF
|
||||
IF_FORM_DESCRIPTOR = FormDescriptor(
|
||||
elements=[
|
||||
RowElement(
|
||||
name="condition_row_label",
|
||||
type="row",
|
||||
label="condition_name",
|
||||
),
|
||||
RowElement(
|
||||
name="condition_row",
|
||||
type="row",
|
||||
label="Condition",
|
||||
link_port=LinkPort(id="then_output", label="Then"),
|
||||
label="condition",
|
||||
link_port=LinkPort(id=0, label="Then"),
|
||||
elements=[
|
||||
AreaElement(
|
||||
name="condition",
|
||||
@@ -56,8 +60,8 @@ IF_FORM_DESCRIPTOR = FormDescriptor(
|
||||
RowElement(
|
||||
name="else_row",
|
||||
type="row",
|
||||
label="Alternative path",
|
||||
link_port=LinkPort(id="else_output", label="Else"),
|
||||
label="alternative_path",
|
||||
link_port=LinkPort(id=1, label="Else"),
|
||||
),
|
||||
]
|
||||
)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from typing import Optional, Dict, Any
|
||||
from typing import Optional
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
|
||||
|
||||
@@ -43,36 +43,36 @@ class ListenNodeCoreSchema(BaseModel):
|
||||
LISTEN_FORM_DESCRIPTOR = FormDescriptor(
|
||||
elements=[
|
||||
RowElement(
|
||||
name="event_row",
|
||||
name="listen_row_label",
|
||||
type="row",
|
||||
label="Event",
|
||||
label="listen_name",
|
||||
),
|
||||
RowElement(
|
||||
name="listen_row",
|
||||
type="row",
|
||||
label="event_input",
|
||||
elements=[
|
||||
LineElement(
|
||||
name="event_name",
|
||||
name="event_id",
|
||||
type="line",
|
||||
label="Event",
|
||||
label="event_id",
|
||||
placeholder="Event identifier",
|
||||
)
|
||||
],
|
||||
),
|
||||
RowElement(
|
||||
name="condition_row",
|
||||
name="listen_row",
|
||||
type="row",
|
||||
label="Condition",
|
||||
label="condition_input",
|
||||
link_port=LinkPort(id=0, label="Then"),
|
||||
elements=[
|
||||
AreaElement(
|
||||
name="condition",
|
||||
name="listen_condition",
|
||||
type="area",
|
||||
label="Condition",
|
||||
label="listen_condition",
|
||||
placeholder="If P([condition(i), [AND, OR]]) == true",
|
||||
)
|
||||
],
|
||||
),
|
||||
RowElement(
|
||||
name="then_row",
|
||||
type="row",
|
||||
label="Then",
|
||||
link_port=LinkPort(id="then_output", label="Then"),
|
||||
),
|
||||
]
|
||||
)
|
||||
|
||||
@@ -41,22 +41,14 @@ class SetNodeCoreSchema(BaseModel):
|
||||
SET_FORM_DESCRIPTOR = FormDescriptor(
|
||||
elements=[
|
||||
RowElement(
|
||||
name="variable_row",
|
||||
name="set_row_label",
|
||||
type="row",
|
||||
label="Parameter name",
|
||||
elements=[
|
||||
LineElement(
|
||||
name="variable",
|
||||
type="line",
|
||||
label="Parameter name",
|
||||
placeholder="Enter parameter name",
|
||||
)
|
||||
],
|
||||
label="set_row_name",
|
||||
),
|
||||
RowElement(
|
||||
name="value_row",
|
||||
type="row",
|
||||
label="Value",
|
||||
label="set_value",
|
||||
elements=[
|
||||
AreaElement(
|
||||
name="value",
|
||||
@@ -65,13 +57,7 @@ SET_FORM_DESCRIPTOR = FormDescriptor(
|
||||
placeholder="Enter value",
|
||||
)
|
||||
],
|
||||
),
|
||||
RowElement(
|
||||
name="link_row",
|
||||
type="row",
|
||||
label="Link",
|
||||
link_port=LinkPort(id="then_output", label="then"),
|
||||
elements=[],
|
||||
link_port=LinkPort(id=0, label="then"),
|
||||
),
|
||||
]
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user