feat: listen - start node
This commit is contained in:
@@ -24,8 +24,6 @@ from api.services.user_role_validation import (
|
|||||||
db_user_role_validation_for_list_events_and_process_schema_by_list_event_id,
|
db_user_role_validation_for_list_events_and_process_schema_by_list_event_id,
|
||||||
)
|
)
|
||||||
|
|
||||||
from core import VorkNodeStart
|
|
||||||
from model_nodes import StartNodeData
|
|
||||||
|
|
||||||
from api.db.logic.ps_node import create_ps_node_schema
|
from api.db.logic.ps_node import create_ps_node_schema
|
||||||
|
|
||||||
@@ -35,6 +33,10 @@ from orm.tables.process import NodeType
|
|||||||
|
|
||||||
from api.utils.to_camel_dict import to_camel_dict
|
from api.utils.to_camel_dict import to_camel_dict
|
||||||
|
|
||||||
|
from core import VorkNodeRegistry
|
||||||
|
|
||||||
|
from model_nodes import ListenNodeData
|
||||||
|
|
||||||
|
|
||||||
api_router = APIRouter(
|
api_router = APIRouter(
|
||||||
prefix="/process_schema",
|
prefix="/process_schema",
|
||||||
@@ -42,7 +44,10 @@ api_router = APIRouter(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@api_router.get("", dependencies=[Depends(bearer_schema)], response_model=AllProcessSchemaResponse)
|
@api_router.get("", dependencies=[Depends(bearer_schema)],
|
||||||
|
|
||||||
|
# response_model=AllProcessSchemaResponse
|
||||||
|
)
|
||||||
async def get_all_process_schema_endpoint(
|
async def get_all_process_schema_endpoint(
|
||||||
page: int = Query(1, description="Page number", gt=0),
|
page: int = Query(1, description="Page number", gt=0),
|
||||||
limit: int = Query(10, description="Number of items per page", gt=0),
|
limit: int = Query(10, description="Number of items per page", gt=0),
|
||||||
@@ -106,7 +111,9 @@ async def get_process_schema_endpoint(
|
|||||||
return to_camel_dict(process_schema_validation.model_dump())
|
return to_camel_dict(process_schema_validation.model_dump())
|
||||||
|
|
||||||
|
|
||||||
@api_router.post("", dependencies=[Depends(bearer_schema)], response_model=ProcessSchemaResponse)
|
@api_router.post("", dependencies=[Depends(bearer_schema)],
|
||||||
|
response_model=ProcessSchemaResponse
|
||||||
|
)
|
||||||
async def create_processschema_endpoint(
|
async def create_processschema_endpoint(
|
||||||
process_schema: ProcessSchemaUpdate,
|
process_schema: ProcessSchemaUpdate,
|
||||||
connection: AsyncConnection = Depends(get_connection_dep),
|
connection: AsyncConnection = Depends(get_connection_dep),
|
||||||
@@ -120,22 +127,33 @@ async def create_processschema_endpoint(
|
|||||||
await create_process_schema(connection, process_schema, user_validation.id)
|
await create_process_schema(connection, process_schema, user_validation.id)
|
||||||
process_schema_new = await get_process_schema_by_title(connection, process_schema.title)
|
process_schema_new = await get_process_schema_by_title(connection, process_schema.title)
|
||||||
|
|
||||||
start_node_data = StartNodeData(
|
start_node_data = ListenNodeData(
|
||||||
ps_id=process_schema_new.id,
|
ps_id=process_schema_new.id,
|
||||||
node_type=NodeType.START.value
|
node_type=NodeType.START.value,
|
||||||
|
is_start="True"
|
||||||
)
|
)
|
||||||
|
|
||||||
start_node_links = {}
|
start_node_links = {}
|
||||||
|
|
||||||
start_node = VorkNodeStart(data=start_node_data.model_dump(), links=start_node_links)
|
registery = VorkNodeRegistry()
|
||||||
|
|
||||||
|
vork_node = registery.get("LISTEN")
|
||||||
|
|
||||||
|
node_descriptor = vork_node.form()
|
||||||
|
|
||||||
|
|
||||||
|
start_node = vork_node(data=start_node_data.model_dump(), links=start_node_links)
|
||||||
|
|
||||||
validated_start_schema = start_node.validate()
|
validated_start_schema = start_node.validate()
|
||||||
|
|
||||||
|
print(validated_start_schema)
|
||||||
|
|
||||||
db_start_schema = await create_ps_node_schema(connection, validated_start_schema, user_validation.id)
|
db_start_schema = await create_ps_node_schema(connection, validated_start_schema, user_validation.id)
|
||||||
|
|
||||||
node = ProcessSchemaSettingsNode(
|
node = ProcessSchemaSettingsNode(
|
||||||
id=db_start_schema.id,
|
id=db_start_schema.id,
|
||||||
node_type=NodeType.START.value,
|
node_type=NodeType.LISTEN.value,
|
||||||
data=validated_start_schema.data.model_dump(by_alias=True),
|
data=validated_start_schema.data.model_dump(),
|
||||||
from_node=None,
|
from_node=None,
|
||||||
links=None)
|
links=None)
|
||||||
|
|
||||||
@@ -146,17 +164,17 @@ async def create_processschema_endpoint(
|
|||||||
process_schema_new = await get_process_schema_by_title(connection, process_schema.title)
|
process_schema_new = await get_process_schema_by_title(connection, process_schema.title)
|
||||||
|
|
||||||
ps_node_front_response = Ps_NodeFrontResponse(
|
ps_node_front_response = Ps_NodeFrontResponse(
|
||||||
description=None,
|
description=node_descriptor,
|
||||||
node=Ps_NodeFrontResponseNode(
|
node=Ps_NodeFrontResponseNode(
|
||||||
id=db_start_schema.id,
|
id=db_start_schema.id,
|
||||||
node_type=NodeType.START.value,
|
node_type=NodeType.LISTEN.value,
|
||||||
data=validated_start_schema.data.model_dump()),
|
data=validated_start_schema.data.model_dump()),
|
||||||
link=None)
|
link=None)
|
||||||
|
|
||||||
|
|
||||||
response_data = {
|
response_data = {
|
||||||
"process_schema": process_schema_new.model_dump(),
|
"process_schema": process_schema_new.model_dump(),
|
||||||
"node_start": ps_node_front_response.model_dump()}
|
"node_listen": ps_node_front_response.model_dump()}
|
||||||
|
|
||||||
return to_camel_dict(response_data)
|
return to_camel_dict(response_data)
|
||||||
|
|
||||||
|
@@ -106,7 +106,7 @@ async def create_ps_node_endpoint(
|
|||||||
|
|
||||||
|
|
||||||
ps_node_front_response = Ps_NodeFrontResponse(
|
ps_node_front_response = Ps_NodeFrontResponse(
|
||||||
description=node_descriptor.model_dump(),
|
description=node_descriptor,
|
||||||
node=Ps_NodeFrontResponseNode(
|
node=Ps_NodeFrontResponseNode(
|
||||||
id=db_ps_node.id,
|
id=db_ps_node.id,
|
||||||
node_type=db_ps_node.node_type,
|
node_type=db_ps_node.node_type,
|
||||||
|
@@ -37,4 +37,4 @@ class ProcessSchemaSettingsNode(Base):
|
|||||||
|
|
||||||
class ProcessSchemaResponse(Base):
|
class ProcessSchemaResponse(Base):
|
||||||
process_schema: ProcessSchema
|
process_schema: ProcessSchema
|
||||||
node_start: Ps_NodeFrontResponse
|
node_listen: Ps_NodeFrontResponse
|
||||||
|
2045
api/poetry.lock
generated
2045
api/poetry.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -16,6 +16,7 @@ dependencies = [
|
|||||||
"cryptography (>=44.0.2,<45.0.0)",
|
"cryptography (>=44.0.2,<45.0.0)",
|
||||||
"pydantic[email] (>=2.11.3,<3.0.0)",
|
"pydantic[email] (>=2.11.3,<3.0.0)",
|
||||||
"python-multipart (>=0.0.20,<0.0.21)",
|
"python-multipart (>=0.0.20,<0.0.21)",
|
||||||
|
"requests (>=2.31.0,<3.0.0)",
|
||||||
"fastapi-jwt-auth @ git+https://github.com/vvpreo/fastapi-jwt-auth",
|
"fastapi-jwt-auth @ git+https://github.com/vvpreo/fastapi-jwt-auth",
|
||||||
"core-library @ git+https://gitea.heado.ru/Vorkout/core.git@VORKOUT-18",
|
"core-library @ git+https://gitea.heado.ru/Vorkout/core.git@VORKOUT-18",
|
||||||
]
|
]
|
||||||
|
Reference in New Issue
Block a user