|
|
|
@ -20,6 +20,7 @@ from fields.workflow_run_fields import workflow_run_node_execution_fields
|
|
|
|
from libs import helper
|
|
|
|
from libs import helper
|
|
|
|
from libs.helper import TimestampField, uuid_value
|
|
|
|
from libs.helper import TimestampField, uuid_value
|
|
|
|
from libs.login import current_user, login_required
|
|
|
|
from libs.login import current_user, login_required
|
|
|
|
|
|
|
|
from models.account import Account
|
|
|
|
from models.model import App, AppMode
|
|
|
|
from models.model import App, AppMode
|
|
|
|
from services.app_dsl_service import AppDslService
|
|
|
|
from services.app_dsl_service import AppDslService
|
|
|
|
from services.app_generate_service import AppGenerateService
|
|
|
|
from services.app_generate_service import AppGenerateService
|
|
|
|
@ -97,6 +98,9 @@ class DraftWorkflowApi(Resource):
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
abort(415)
|
|
|
|
abort(415)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if not isinstance(current_user, Account):
|
|
|
|
|
|
|
|
raise Forbidden()
|
|
|
|
|
|
|
|
|
|
|
|
workflow_service = WorkflowService()
|
|
|
|
workflow_service = WorkflowService()
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
@ -137,6 +141,9 @@ class DraftWorkflowImportApi(Resource):
|
|
|
|
if not current_user.is_editor:
|
|
|
|
if not current_user.is_editor:
|
|
|
|
raise Forbidden()
|
|
|
|
raise Forbidden()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if not isinstance(current_user, Account):
|
|
|
|
|
|
|
|
raise Forbidden()
|
|
|
|
|
|
|
|
|
|
|
|
parser = reqparse.RequestParser()
|
|
|
|
parser = reqparse.RequestParser()
|
|
|
|
parser.add_argument("data", type=str, required=True, nullable=False, location="json")
|
|
|
|
parser.add_argument("data", type=str, required=True, nullable=False, location="json")
|
|
|
|
args = parser.parse_args()
|
|
|
|
args = parser.parse_args()
|
|
|
|
@ -161,6 +168,9 @@ class AdvancedChatDraftWorkflowRunApi(Resource):
|
|
|
|
if not current_user.is_editor:
|
|
|
|
if not current_user.is_editor:
|
|
|
|
raise Forbidden()
|
|
|
|
raise Forbidden()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if not isinstance(current_user, Account):
|
|
|
|
|
|
|
|
raise Forbidden()
|
|
|
|
|
|
|
|
|
|
|
|
parser = reqparse.RequestParser()
|
|
|
|
parser = reqparse.RequestParser()
|
|
|
|
parser.add_argument("inputs", type=dict, location="json")
|
|
|
|
parser.add_argument("inputs", type=dict, location="json")
|
|
|
|
parser.add_argument("query", type=str, required=True, location="json", default="")
|
|
|
|
parser.add_argument("query", type=str, required=True, location="json", default="")
|
|
|
|
@ -198,6 +208,9 @@ class AdvancedChatDraftRunIterationNodeApi(Resource):
|
|
|
|
if not current_user.is_editor:
|
|
|
|
if not current_user.is_editor:
|
|
|
|
raise Forbidden()
|
|
|
|
raise Forbidden()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if not isinstance(current_user, Account):
|
|
|
|
|
|
|
|
raise Forbidden()
|
|
|
|
|
|
|
|
|
|
|
|
parser = reqparse.RequestParser()
|
|
|
|
parser = reqparse.RequestParser()
|
|
|
|
parser.add_argument("inputs", type=dict, location="json")
|
|
|
|
parser.add_argument("inputs", type=dict, location="json")
|
|
|
|
args = parser.parse_args()
|
|
|
|
args = parser.parse_args()
|
|
|
|
@ -232,6 +245,9 @@ class WorkflowDraftRunIterationNodeApi(Resource):
|
|
|
|
if not current_user.is_editor:
|
|
|
|
if not current_user.is_editor:
|
|
|
|
raise Forbidden()
|
|
|
|
raise Forbidden()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if not isinstance(current_user, Account):
|
|
|
|
|
|
|
|
raise Forbidden()
|
|
|
|
|
|
|
|
|
|
|
|
parser = reqparse.RequestParser()
|
|
|
|
parser = reqparse.RequestParser()
|
|
|
|
parser.add_argument("inputs", type=dict, location="json")
|
|
|
|
parser.add_argument("inputs", type=dict, location="json")
|
|
|
|
args = parser.parse_args()
|
|
|
|
args = parser.parse_args()
|
|
|
|
@ -266,6 +282,9 @@ class DraftWorkflowRunApi(Resource):
|
|
|
|
if not current_user.is_editor:
|
|
|
|
if not current_user.is_editor:
|
|
|
|
raise Forbidden()
|
|
|
|
raise Forbidden()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if not isinstance(current_user, Account):
|
|
|
|
|
|
|
|
raise Forbidden()
|
|
|
|
|
|
|
|
|
|
|
|
parser = reqparse.RequestParser()
|
|
|
|
parser = reqparse.RequestParser()
|
|
|
|
parser.add_argument("inputs", type=dict, required=True, nullable=False, location="json")
|
|
|
|
parser.add_argument("inputs", type=dict, required=True, nullable=False, location="json")
|
|
|
|
parser.add_argument("files", type=list, required=False, location="json")
|
|
|
|
parser.add_argument("files", type=list, required=False, location="json")
|
|
|
|
@ -316,13 +335,20 @@ class DraftWorkflowNodeRunApi(Resource):
|
|
|
|
if not current_user.is_editor:
|
|
|
|
if not current_user.is_editor:
|
|
|
|
raise Forbidden()
|
|
|
|
raise Forbidden()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if not isinstance(current_user, Account):
|
|
|
|
|
|
|
|
raise Forbidden()
|
|
|
|
|
|
|
|
|
|
|
|
parser = reqparse.RequestParser()
|
|
|
|
parser = reqparse.RequestParser()
|
|
|
|
parser.add_argument("inputs", type=dict, required=True, nullable=False, location="json")
|
|
|
|
parser.add_argument("inputs", type=dict, required=True, nullable=False, location="json")
|
|
|
|
args = parser.parse_args()
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inputs = args.get("inputs")
|
|
|
|
|
|
|
|
if inputs == None:
|
|
|
|
|
|
|
|
raise ValueError("missing inputs")
|
|
|
|
|
|
|
|
|
|
|
|
workflow_service = WorkflowService()
|
|
|
|
workflow_service = WorkflowService()
|
|
|
|
workflow_node_execution = workflow_service.run_draft_workflow_node(
|
|
|
|
workflow_node_execution = workflow_service.run_draft_workflow_node(
|
|
|
|
app_model=app_model, node_id=node_id, user_inputs=args.get("inputs"), account=current_user
|
|
|
|
app_model=app_model, node_id=node_id, user_inputs=inputs, account=current_user
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
return workflow_node_execution
|
|
|
|
return workflow_node_execution
|
|
|
|
@ -361,6 +387,9 @@ class PublishedWorkflowApi(Resource):
|
|
|
|
if not current_user.is_editor:
|
|
|
|
if not current_user.is_editor:
|
|
|
|
raise Forbidden()
|
|
|
|
raise Forbidden()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if not isinstance(current_user, Account):
|
|
|
|
|
|
|
|
raise Forbidden()
|
|
|
|
|
|
|
|
|
|
|
|
workflow_service = WorkflowService()
|
|
|
|
workflow_service = WorkflowService()
|
|
|
|
workflow = workflow_service.publish_workflow(app_model=app_model, account=current_user)
|
|
|
|
workflow = workflow_service.publish_workflow(app_model=app_model, account=current_user)
|
|
|
|
|
|
|
|
|
|
|
|
@ -398,14 +427,19 @@ class DefaultBlockConfigApi(Resource):
|
|
|
|
if not current_user.is_editor:
|
|
|
|
if not current_user.is_editor:
|
|
|
|
raise Forbidden()
|
|
|
|
raise Forbidden()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if not isinstance(current_user, Account):
|
|
|
|
|
|
|
|
raise Forbidden()
|
|
|
|
|
|
|
|
|
|
|
|
parser = reqparse.RequestParser()
|
|
|
|
parser = reqparse.RequestParser()
|
|
|
|
parser.add_argument("q", type=str, location="args")
|
|
|
|
parser.add_argument("q", type=str, location="args")
|
|
|
|
args = parser.parse_args()
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
q = args.get("q")
|
|
|
|
|
|
|
|
|
|
|
|
filters = None
|
|
|
|
filters = None
|
|
|
|
if args.get("q"):
|
|
|
|
if q:
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
filters = json.loads(args.get("q"))
|
|
|
|
filters = json.loads(q)
|
|
|
|
except json.JSONDecodeError:
|
|
|
|
except json.JSONDecodeError:
|
|
|
|
raise ValueError("Invalid filters")
|
|
|
|
raise ValueError("Invalid filters")
|
|
|
|
|
|
|
|
|
|
|
|
@ -429,6 +463,9 @@ class ConvertToWorkflowApi(Resource):
|
|
|
|
if not current_user.is_editor:
|
|
|
|
if not current_user.is_editor:
|
|
|
|
raise Forbidden()
|
|
|
|
raise Forbidden()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if not isinstance(current_user, Account):
|
|
|
|
|
|
|
|
raise Forbidden()
|
|
|
|
|
|
|
|
|
|
|
|
if request.data:
|
|
|
|
if request.data:
|
|
|
|
parser = reqparse.RequestParser()
|
|
|
|
parser = reqparse.RequestParser()
|
|
|
|
parser.add_argument("name", type=str, required=False, nullable=True, location="json")
|
|
|
|
parser.add_argument("name", type=str, required=False, nullable=True, location="json")
|
|
|
|
|