Compare commits

...

1 Commits

Author SHA1 Message Date
seer-by-sentry[bot]
944e34f319 feat(backend): Add public endpoint to retrieve shared graph executions 2025-09-16 20:08:12 +00:00
2 changed files with 85 additions and 0 deletions

View File

@@ -1170,6 +1170,27 @@ async def set_execution_kv_data(
return type_utils.convert(resp.data, type[Any]) if resp and resp.data else None
async def get_graph_execution_by_share_token(
share_token: str,
) -> GraphExecutionWithNodes | None:
"""Get graph execution by share token for public sharing endpoints."""
# Note: This is a reconstructed function based on the error context
# The actual implementation may need to be adapted based on the sharing mechanism
# For now, we'll search by the share_token as if it were an execution ID
# This should be updated to match the actual sharing token schema
execution = await AgentGraphExecution.prisma().find_first(
where={"id": share_token, "isDeleted": False},
include=GRAPH_EXECUTION_INCLUDE_WITH_NODES,
)
if not execution:
return None
# Use the existing from_db method to ensure consistency with other parts of the codebase
return GraphExecutionWithNodes.from_db(execution)
async def get_block_error_stats(
start_time: datetime, end_time: datetime
) -> list[BlockErrorStats]:

View File

@@ -667,6 +667,22 @@ async def create_new_graph(
return await on_graph_activate(graph, user_id=user_id)
@v1_router.get(
path="/public/shared/{share_token}",
summary="Get shared execution by token",
tags=["executions", "public"],
dependencies=[], # No authentication required for public endpoints
)
async def get_shared_execution(
share_token: str = Path(..., description="The share token for the execution"),
) -> execution_db.GraphExecutionWithNodes:
"""Get a shared execution by its share token."""
execution = await execution_db.get_graph_execution_by_share_token(share_token)
if not execution:
raise HTTPException(status_code=404, detail="Shared execution not found")
return execution
@v1_router.delete(
path="/graphs/{graph_id}",
summary="Delete graph permanently",
@@ -942,6 +958,22 @@ async def get_graph_execution(
return result
@v1_router.get(
path="/public/shared/{share_token}",
summary="Get shared execution by token",
tags=["executions", "public"],
dependencies=[], # No authentication required for public endpoints
)
async def get_shared_execution(
share_token: str = Path(..., description="The share token for the execution"),
) -> execution_db.GraphExecutionWithNodes:
"""Get a shared execution by its share token."""
execution = await execution_db.get_graph_execution_by_share_token(share_token)
if not execution:
raise HTTPException(status_code=404, detail="Shared execution not found")
return execution
@v1_router.delete(
path="/executions/{graph_exec_id}",
summary="Delete graph execution",
@@ -1052,6 +1084,22 @@ async def list_all_graphs_execution_schedules(
return await get_scheduler_client().get_execution_schedules(user_id=user_id)
@v1_router.get(
path="/public/shared/{share_token}",
summary="Get shared execution by token",
tags=["executions", "public"],
dependencies=[], # No authentication required for public endpoints
)
async def get_shared_execution(
share_token: str = Path(..., description="The share token for the execution"),
) -> execution_db.GraphExecutionWithNodes:
"""Get a shared execution by its share token."""
execution = await execution_db.get_graph_execution_by_share_token(share_token)
if not execution:
raise HTTPException(status_code=404, detail="Shared execution not found")
return execution
@v1_router.delete(
path="/schedules/{schedule_id}",
summary="Delete execution schedule",
@@ -1125,6 +1173,22 @@ async def get_api_key(
return api_key
@v1_router.get(
path="/public/shared/{share_token}",
summary="Get shared execution by token",
tags=["executions", "public"],
dependencies=[], # No authentication required for public endpoints
)
async def get_shared_execution(
share_token: str = Path(..., description="The share token for the execution"),
) -> execution_db.GraphExecutionWithNodes:
"""Get a shared execution by its share token."""
execution = await execution_db.get_graph_execution_by_share_token(share_token)
if not execution:
raise HTTPException(status_code=404, detail="Shared execution not found")
return execution
@v1_router.delete(
"/api-keys/{key_id}",
summary="Revoke API key",