Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
213 commits
Select commit Hold shift + click to select a range
212bfd5
feat: build version alias management system
qiaofenlin Aug 12, 2025
492494a
feat: support executing workflow and chatflow by alias
qiaofenlin Aug 12, 2025
3b74a69
remove badsmell
qiaofenlin Aug 12, 2025
92911b2
Merge remote-tracking branch 'origin/main' into feature/workflow-alia…
qiaofenlin Aug 12, 2025
f36fef1
feat: implement workflow alias management with performance optimizations
qiaofenlin Aug 13, 2025
b975e51
refactor: optimize workflow alias implementation based on review feed…
qiaofenlin Aug 15, 2025
436dcdf
refactor: improve workflow alias management architecture
qiaofenlin Aug 18, 2025
8a5a124
Merge branch 'main' of https://github.com/langgenius/dify into featur…
qiaofenlin Aug 18, 2025
7097568
remove fake code
qiaofenlin Aug 18, 2025
d3e0dd8
[autofix.ci] apply automated fixes
autofix-ci[bot] Aug 18, 2025
aa7ddc3
feat: enhance workflow alias management and support dot notation
qiaofenlin Aug 24, 2025
753dff0
Merge origin/main: resolve conflicts in completion.py and workflow.py…
qiaofenlin Aug 25, 2025
5eff231
[autofix.ci] apply automated fixes
autofix-ci[bot] Aug 25, 2025
41ff9d2
fixed flask_restx
qiaofenlin Aug 25, 2025
23e8e60
Merge branch 'feature/workflow-alias-management' of github.com:qiaofe…
qiaofenlin Aug 25, 2025
0ff1604
fixed
qiaofenlin Aug 25, 2025
8122efb
Merge branch 'langgenius:main' into feature/workflow-alias-management
qiaofenlin Aug 25, 2025
47ff940
Merge remote-tracking branch 'origin/main' into feature/workflow-alia…
qiaofenlin Aug 26, 2025
2b0d4a3
fixed migration file for alias
qiaofenlin Aug 26, 2025
adb2662
Merge remote main branch with workflow alias feature
qiaofenlin Aug 27, 2025
33f2e09
update workflow mdx
qiaofenlin Aug 27, 2025
186d49c
Update api/services/workflow_alias_service.py
qiaofenlin Sep 1, 2025
8c0f59e
Update api/services/workflow_alias_service.py
qiaofenlin Sep 1, 2025
34a951e
Update api/services/workflow_alias_service.py
qiaofenlin Sep 1, 2025
216e6d1
Update api/services/workflow_alias_service.py
qiaofenlin Sep 1, 2025
c325f90
Update api/services/workflow_alias_service.py
qiaofenlin Sep 1, 2025
9029831
Update api/controllers/service_api/app/completion.py
qiaofenlin Sep 1, 2025
66aa081
Update api/controllers/service_api/app/completion.py
qiaofenlin Sep 1, 2025
c0768d4
Update api/controllers/service_api/app/completion.py
qiaofenlin Sep 1, 2025
f508a6a
Update api/controllers/service_api/app/workflow.py
qiaofenlin Sep 1, 2025
800ec91
Update api/controllers/service_api/app/workflow.py
qiaofenlin Sep 1, 2025
4398d9d
[autofix.ci] apply automated fixes
autofix-ci[bot] Sep 1, 2025
1d995f9
Update api/controllers/service_api/app/workflow.py
qiaofenlin Sep 1, 2025
23784bf
Update api/controllers/console/app/workflow_alias.py
qiaofenlin Sep 1, 2025
df61de3
Update api/models/workflow_alias.py
qiaofenlin Sep 1, 2025
5753067
Update api/models/workflow_alias.py
qiaofenlin Sep 1, 2025
8984740
Update api/models/workflow_alias.py
qiaofenlin Sep 1, 2025
d2f6058
Update api/models/workflow_alias.py
qiaofenlin Sep 1, 2025
c5047e6
Update api/models/workflow_alias.py
qiaofenlin Sep 1, 2025
924c900
Update api/models/workflow_alias.py
qiaofenlin Sep 1, 2025
a6e4b19
Update api/models/workflow_alias.py
qiaofenlin Sep 1, 2025
371f5c0
Update api/services/workflow_alias_service.py
qiaofenlin Sep 1, 2025
993dfcc
Update api/services/workflow_alias_service.py
qiaofenlin Sep 1, 2025
f8cb69b
Update api/services/workflow_alias_service.py
qiaofenlin Sep 1, 2025
1c7f74d
[autofix.ci] apply automated fixes
autofix-ci[bot] Sep 1, 2025
92c1fce
fix alias table error
qiaofenlin Sep 1, 2025
36701bb
Merge branch 'langgenius:main' into feature/workflow-alias-management
qiaofenlin Sep 1, 2025
4262517
[autofix.ci] apply automated fixes
autofix-ci[bot] Sep 1, 2025
095dd8d
Merge remote-tracking branch 'origin/main' into feature/workflow-alia…
qiaofenlin Sep 1, 2025
eb361ac
Merge branch 'feature/workflow-alias-management' of github.com:qiaofe…
qiaofenlin Sep 1, 2025
271113b
remove alias type
qiaofenlin Sep 2, 2025
58375b0
[autofix.ci] apply automated fixes
autofix-ci[bot] Sep 2, 2025
8c0d617
fixed workflow_alias to workflow_id error
qiaofenlin Sep 2, 2025
7b0b3f4
Merge branch 'feature/workflow-alias-management' of github.com:qiaofe…
qiaofenlin Sep 2, 2025
4a717d2
[autofix.ci] apply automated fixes
autofix-ci[bot] Sep 2, 2025
c169db7
Merge branch 'langgenius:main' into feature/workflow-alias-management
qiaofenlin Sep 2, 2025
5a069b9
Update db-migration-test.yml
qiaofenlin Sep 2, 2025
af17347
git add .github/workflows/db-migration-test.yml
qiaofenlin Sep 2, 2025
53e2f95
Merge branch 'feature/workflow-alias-management' of github.com:qiaofe…
qiaofenlin Sep 2, 2025
ab425a9
fixed checks error
qiaofenlin Sep 2, 2025
505d31f
Merge branch 'langgenius:main' into main
qiaofenlin Sep 3, 2025
88e9eeb
Merge remote main branch into feature/workflow-alias-management
qiaofenlin Sep 3, 2025
5bb5876
Merge remote-tracking branch 'origin/main' into feature/workflow-alia…
laipz8200 Sep 3, 2025
2de55a8
Merge branch 'main' into feature/workflow-alias-management
laipz8200 Sep 9, 2025
167da1c
[autofix.ci] apply automated fixes
autofix-ci[bot] Sep 9, 2025
8141ceb
Merge branch 'main' into feature/workflow-alias-management
qiaofenlin Sep 10, 2025
cd2beae
Merge branch 'langgenius:main' into main
qiaofenlin Sep 10, 2025
fb37ef0
Update 2025_09_02_0908-398394623b7b_add_workflow_alias_management.py
qiaofenlin Sep 10, 2025
a1a73d2
Merge branch 'main' into feature/workflow-alias-management
qiaofenlin Sep 10, 2025
b136520
Merge branch 'langgenius:main' into main
qiaofenlin Sep 14, 2025
6592e12
Merge main into feature/workflow-alias-management
Sep 14, 2025
f8c1e24
fix: resolve type checking errors
Sep 14, 2025
0ccd0d4
fixed mypy check error
Sep 15, 2025
57067ff
fixed conflicts
Sep 15, 2025
27b0ab2
Merge branch 'langgenius:main' into main
qiaofenlin Sep 15, 2025
9fb21c2
Merge branch 'main' into feature/workflow-alias-management: Resolved …
Sep 15, 2025
d4e9ad2
[autofix.ci] apply automated fixes
autofix-ci[bot] Sep 15, 2025
3b2e70b
fixed del alias error
Sep 15, 2025
ef62fb5
Merge branch 'feature/workflow-alias-management' of github.com:qiaofe…
Sep 15, 2025
6129000
[autofix.ci] apply automated fixes
autofix-ci[bot] Sep 15, 2025
83be2b8
Fix: Correct response format when deleting alias
Sep 15, 2025
b0ffce4
Merge branch 'feature/workflow-alias-management' of github.com:qiaofe…
Sep 15, 2025
399e02d
Merge branch 'main' into feature/workflow-alias-management
qiaofenlin Sep 15, 2025
0749747
Merge branch 'main' into feature/workflow-alias-management
qiaofenlin Sep 15, 2025
5e833bb
[autofix.ci] apply automated fixes
autofix-ci[bot] Sep 15, 2025
0beea52
[autofix.ci] apply automated fixes (attempt 2/3)
autofix-ci[bot] Sep 15, 2025
edbbe7c
fixed migration error
Sep 15, 2025
35bc1df
Merge branch 'main' into feature/workflow-alias-management
qiaofenlin Sep 15, 2025
5c79c52
Merge branch 'main' into feature/workflow-alias-management
qiaofenlin Sep 16, 2025
d086d93
Merge branch 'main' into feature/workflow-alias-management
qiaofenlin Sep 17, 2025
8bf7684
Merge branch 'langgenius:main' into main
qiaofenlin Sep 22, 2025
18fd2fa
Merge branch 'langgenius:main' into main
qiaofenlin Sep 30, 2025
4253ceb
Merge main branch into feature/workflow-alias-management
Sep 30, 2025
5ee617b
[autofix.ci] apply automated fixes
autofix-ci[bot] Sep 30, 2025
1c320f5
Merge branch 'langgenius:main' into feature/workflow-alias-management
qiaofenlin Oct 9, 2025
28171b0
rerun pipline
Oct 10, 2025
8c469de
update migration version
Oct 10, 2025
849d9da
fixed circular import
Oct 10, 2025
29f3f3b
[autofix.ci] apply automated fixes
autofix-ci[bot] Oct 10, 2025
06fef72
fixed basedpyright error
Oct 10, 2025
cf8c49c
Merge branch 'feature/workflow-alias-management' of https://github.co…
Oct 10, 2025
8eb5124
fixed newAliasName is not defined
Oct 10, 2025
3392dcf
Merge branch 'main' into feature/workflow-alias-management
qiaofenlin Oct 10, 2025
db80bb7
Update __init__.py
qiaofenlin Oct 10, 2025
6c7e79b
Merge branch 'main' into feature/workflow-alias-management
qiaofenlin Oct 10, 2025
db20bc2
Merge branch 'main' into feature/workflow-alias-management
qiaofenlin Oct 10, 2025
ca38f28
Merge branch 'main' into feature/workflow-alias-management
qiaofenlin Oct 11, 2025
690b078
Update api/services/workflow_alias_service.py
qiaofenlin Oct 11, 2025
140896f
Update api/libs/helper.py
qiaofenlin Oct 11, 2025
7191aab
Update use-workflow-alias.ts
qiaofenlin Oct 11, 2025
017e05c
Update use-workflow-alias.ts
qiaofenlin Oct 11, 2025
722ad0a
fixed badsmell
Oct 11, 2025
30ab5e4
Update api/models/workflow_alias.py
qiaofenlin Oct 11, 2025
a2521bb
[autofix.ci] apply automated fixes
autofix-ci[bot] Oct 11, 2025
79bce4d
remove badsmell
Oct 11, 2025
a79813b
remove badsmell
Oct 11, 2025
d927e6b
[autofix.ci] apply automated fixes
autofix-ci[bot] Oct 11, 2025
a8f849b
Update api/controllers/console/app/workflow_alias.py
qiaofenlin Oct 11, 2025
babef1b
update alias in8n
Oct 12, 2025
6f993f5
update useTranslation
Oct 12, 2025
1a44ae7
update useTranslation
Oct 12, 2025
55125a8
Merge branch 'main' into feature/workflow-alias-management
qiaofenlin Oct 13, 2025
bd1811b
Merge branch 'main' into feature/workflow-alias-management
qiaofenlin Oct 14, 2025
238898c
Merge branch 'main' into feature/workflow-alias-management
qiaofenlin Oct 15, 2025
095f1a7
Merge branch 'main' into feature/workflow-alias-management
qiaofenlin Oct 15, 2025
9fd11d3
Merge branch 'main' into feature/workflow-alias-management
qiaofenlin Oct 16, 2025
7ff760f
Update 2025_10_10_0908-398394623b7b_add_workflow_alias_management.py
qiaofenlin Oct 16, 2025
66944b3
Update and rename 2025_10_10_0908-398394623b7b_add_workflow_alias_man…
qiaofenlin Oct 16, 2025
c9f66ed
Merge branch 'main' into feature/workflow-alias-management
qiaofenlin Oct 17, 2025
af8be0e
Merge branch 'main' into feature/workflow-alias-management
qiaofenlin Oct 19, 2025
1461936
Merge branch 'main' into feature/workflow-alias-management
qiaofenlin Oct 20, 2025
fac6862
Merge branch 'main' into feature/workflow-alias-management
qiaofenlin Oct 20, 2025
2e9fbfa
Merge branch 'main' into feature/workflow-alias-management
qiaofenlin Oct 21, 2025
4d3b696
Merge branch 'main' into feature/workflow-alias-management
qiaofenlin Oct 24, 2025
9ed97e1
Update and rename 2025_10_16_0908-398394623b7b_add_workflow_alias_man…
qiaofenlin Oct 27, 2025
2af342b
Merge branch 'main' into feature/workflow-alias-management
qiaofenlin Oct 27, 2025
c54e1ff
Merge branch 'main' into feature/workflow-alias-management
qiaofenlin Oct 27, 2025
dbb80a2
Merge branch 'main' into feature/workflow-alias-management
qiaofenlin Oct 28, 2025
514ec88
Merge branch 'main' into feature/workflow-alias-management
laipz8200 Oct 30, 2025
c5ccbd0
Merge branch 'main' into feature/workflow-alias-management
qiaofenlin Oct 31, 2025
a0ff350
Update 2025_10_27_0908-398394623b7b_add_workflow_alias_management.py
qiaofenlin Oct 31, 2025
abc3c5e
fixed type-check error
Oct 31, 2025
7337ac1
Merge branch 'main' into feature/workflow-alias-management
laipz8200 Nov 3, 2025
c1c79f7
Merge branch 'main' into feature/workflow-alias-management
qiaofenlin Nov 6, 2025
b27fdd2
Merge branch 'main' into feature/workflow-alias-management
qiaofenlin Nov 7, 2025
957aac8
remov badsmell
Nov 7, 2025
56139c5
remov badsmell
Nov 7, 2025
949874d
[autofix.ci] apply automated fixes
autofix-ci[bot] Nov 7, 2025
2b55f79
fix: Dark mode styling fixed
Nov 7, 2025
ae1f649
refactor: Move get_workflow_by_alias to WorkflowService
Nov 7, 2025
ac07f83
[autofix.ci] apply automated fixes
autofix-ci[bot] Nov 7, 2025
dec9b41
Merge branch 'main' into feature/workflow-alias-management
qiaofenlin Nov 10, 2025
910f251
Merge branch 'main' into feature/workflow-alias-management
qiaofenlin Nov 10, 2025
ef677e3
Merge branch 'main' into feature/workflow-alias-management
qiaofenlin Nov 10, 2025
d28ad41
Merge branch 'main' into feature/workflow-alias-management
qiaofenlin Nov 11, 2025
2e7eb4a
Merge branch 'main' into feature/workflow-alias-management
qiaofenlin Nov 11, 2025
63098bf
Merge branch 'main' into feature/workflow-alias-management
qiaofenlin Nov 12, 2025
f8aadee
update migration
qiaofenlin Nov 12, 2025
46c1fd4
import cron-parser
Nov 12, 2025
053260c
Merge branch 'main' into feature/workflow-alias-management
qiaofenlin Nov 13, 2025
abbfa4e
Merge branch 'main' into feature/workflow-alias-management
qiaofenlin Nov 13, 2025
444cede
Merge branch 'main' into feature/workflow-alias-management
qiaofenlin Nov 18, 2025
46bff07
Merge branch 'main' into feature/workflow-alias-management
qiaofenlin Nov 21, 2025
119ea8f
Merge branch 'main' into feature/workflow-alias-management
qiaofenlin Nov 24, 2025
d5dc0d9
Update and rename 2025_11_12_0908-398394623b7b_add_workflow_alias_man…
qiaofenlin Nov 24, 2025
d28019f
Merge branch 'main' into feature/workflow-alias-management
qiaofenlin Nov 24, 2025
8e3cfb8
Merge branch 'main' into feature/workflow-alias-management
qiaofenlin Nov 24, 2025
e7967e3
Merge branch 'main' into feature/workflow-alias-management
qiaofenlin Nov 24, 2025
9f5dc03
Merge branch 'main' into feature/workflow-alias-management
qiaofenlin Nov 25, 2025
b9d1142
Merge branch 'main' into feature/workflow-alias-management
qiaofenlin Nov 26, 2025
cb9a3cd
Merge branch 'main' into feature/workflow-alias-management
qiaofenlin Nov 28, 2025
effca28
Update 2025_11_24_0908-398394623b7b_add_workflow_alias_management.py
qiaofenlin Nov 28, 2025
28304dd
Merge branch 'main' into feature/workflow-alias-management
qiaofenlin Nov 30, 2025
ab97415
Merge branch 'main' into feature/workflow-alias-management
qiaofenlin Dec 1, 2025
a8919cd
Merge branch 'main' into feature/workflow-alias-management
qiaofenlin Dec 2, 2025
a8f8a92
Merge branch 'main' into feature/workflow-alias-management
qiaofenlin Dec 2, 2025
1517a2f
Merge branch 'main' into feature/workflow-alias-management
qiaofenlin Dec 3, 2025
39bb0da
Merge branch 'main' into feature/workflow-alias-management
qiaofenlin Dec 3, 2025
bb6e959
Merge branch 'main' into feature/workflow-alias-management
qiaofenlin Dec 4, 2025
8d386ae
Merge branch 'main' into feature/workflow-alias-management
qiaofenlin Dec 5, 2025
84ba95d
Merge branch 'main' into feature/workflow-alias-management
qiaofenlin Dec 8, 2025
a46a4c7
Merge branch 'main' into feature/workflow-alias-management
qiaofenlin Dec 8, 2025
0a5bbc8
[autofix.ci] apply automated fixes
autofix-ci[bot] Dec 8, 2025
c43c10b
Merge branch 'main' into feature/workflow-alias-management
qiaofenlin Dec 8, 2025
ff237ca
Merge branch 'main' into feature/workflow-alias-management
qiaofenlin Dec 9, 2025
4fc713a
Merge branch 'main' into feature/workflow-alias-management
laipz8200 Dec 9, 2025
83d8bc3
fix: uuid_value not import
laipz8200 Dec 9, 2025
8fd7aab
fix: workflow_run_parser not exists
laipz8200 Dec 9, 2025
79c3ea7
chore: update down_revision for the migration file
laipz8200 Dec 9, 2025
fc37749
chore: restore sdk
laipz8200 Dec 9, 2025
9bf1653
Merge branch 'main' into feature/workflow-alias-management
qiaofenlin Dec 9, 2025
795d2ee
fixed workflow_alias
Dec 9, 2025
750f221
fix: improve workflow alias service dependency injection and type safety
Dec 9, 2025
42349b9
[autofix.ci] apply automated fixes
autofix-ci[bot] Dec 9, 2025
b9aef2a
Merge branch 'main' into feature/workflow-alias-management
Jan 16, 2026
191ca33
chore: rebase workflow_alias migration to latest main
Jan 16, 2026
326c3eb
fix: improve workflow identifier validation in chat-messages API
Jan 16, 2026
4895ecd
Merge branch 'main' into feature/workflow-alias-management
qiaofenlin Jan 16, 2026
5d1b5d1
[autofix.ci] apply automated fixes
autofix-ci[bot] Jan 16, 2026
185d733
chore(i18n): organize tag translations and unify terminology
Jan 16, 2026
ef8b326
style: sort import statements alphabetically
Jan 16, 2026
2f293ef
[autofix.ci] apply automated fixes
autofix-ci[bot] Jan 16, 2026
dea2790
refactor(migration): merge workflow tag migration files into single file
Jan 16, 2026
db14add
docs: update workflow API documentation terminology from '别名' to '标签'
Jan 16, 2026
c42fd14
fixed web tests
Jan 16, 2026
f4a8272
Merge branch 'main' into feature/workflow-alias-management
qiaofenlin Jan 18, 2026
32f264d
fix: resolve 6 ESLint errors in web project
Jan 18, 2026
ace989b
Merge branch 'main' into feature/workflow-alias-management
qiaofenlin Jan 19, 2026
8627f6c
Merge branch 'main' into feature/workflow-alias-management
qiaofenlin Jan 19, 2026
4341462
update migration
Jan 19, 2026
eddc56d
Merge branch 'main' into feature/workflow-alias-management
qiaofenlin Jan 29, 2026
901b4b5
Add migration for workflow tag management
qiaofenlin Jan 29, 2026
4472b62
[autofix.ci] apply automated fixes
autofix-ci[bot] Jan 29, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions api/controllers/console/__init__.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
from importlib import import_module
from typing import TYPE_CHECKING

from flask import Blueprint
from flask_restx import Namespace

from libs.external_api import ExternalApi

if TYPE_CHECKING:
from flask_restx import Api

console_ns = Namespace("console", description="Console management API operations", path="/")

bp = Blueprint("console", __name__, url_prefix="/console/api")

api = ExternalApi(
api: "Api" = ExternalApi(
bp,
version="1.0",
title="Console API",
description="Console management APIs for app configuration, monitoring, and administration",
)

console_ns = Namespace("console", description="Console management API operations", path="/")

RESOURCE_MODULES = (
"controllers.console.app.app_import",
"controllers.console.explore.audio",
Expand Down Expand Up @@ -69,6 +73,9 @@
workflow_trigger,
)

# Register workflow tag routes
from .app.workflow_tag import WorkflowTagApi

# Import auth controllers
from .auth import (
activate,
Expand Down Expand Up @@ -133,6 +140,7 @@
workspace,
)

api.add_resource(WorkflowTagApi, "/apps/<uuid:app_id>/workflow-tags", "/apps/<uuid:app_id>/workflow-tags/<uuid:tag_id>")
api.add_namespace(console_ns)

__all__ = [
Expand Down
231 changes: 231 additions & 0 deletions api/controllers/console/app/workflow_tag.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,231 @@
import logging
from dataclasses import dataclass
from typing import Any

from flask_restx import Resource, marshal_with, reqparse
from flask_restx.inputs import int_range
from werkzeug.exceptions import BadRequest, Forbidden

from controllers.console import api
from controllers.console.app.wraps import get_app_model
from controllers.console.wraps import account_initialization_required, setup_required
from extensions.ext_database import db
from fields.workflow_tag_fields import (
workflow_tag_create_update_fields,
workflow_tag_fields,
workflow_tag_list_fields,
)
from libs.helper import tag_name, uuid_value
from libs.login import current_user, login_required
from models import App, AppMode
from models.account import Account
from services.workflow_service import WorkflowService
from services.workflow_tag_service import WorkflowTagArgs, WorkflowTagService

logger = logging.getLogger(__name__)


@dataclass
class PaginatedResponse:
"""Structured pagination response object."""

items: list[Any]
limit: int
offset: int
has_more: bool

@property
def page(self) -> int:
"""Calculate current page from offset and limit."""
return (self.offset // self.limit) + 1

def to_dict(self) -> dict[str, Any]:
"""Convert to dictionary format for API response."""
return {
"items": self.items,
"page": self.page,
"limit": self.limit,
"has_more": self.has_more,
}


def _create_pagination_parser() -> reqparse.RequestParser:
"""Create a parser with validated pagination parameters."""
parser = reqparse.RequestParser()
parser.add_argument(
"workflow_ids", type=str, required=False, location="args", help="Comma-separated list of workflow IDs"
)
parser.add_argument(
"limit",
type=int_range(1, 1000),
required=False,
default=100,
location="args",
help="Number of items to return (1-1000)",
)
parser.add_argument(
"offset",
type=int_range(0, 1000000),
required=False,
default=0,
location="args",
help="Number of items to skip (0-1000000)",
)
return parser


class WorkflowTagApi(Resource):
@setup_required
@login_required
@account_initialization_required
@get_app_model(mode=[AppMode.ADVANCED_CHAT, AppMode.WORKFLOW])
@marshal_with(workflow_tag_list_fields)
@api.doc("get_workflow_tags")
@api.doc(description="Get workflow tags for an app")
@api.doc(params={"app_id": "App ID"})
@api.doc(
responses={
200: "Workflow tags retrieved successfully",
401: "Unauthorized - user not logged in",
403: "Forbidden - user is not an editor",
404: "App not found",
}
)
def get(self, app_model: App):
assert isinstance(current_user, Account)
if not current_user.has_edit_permission:
raise Forbidden()

# Use validated pagination parser
parser = _create_pagination_parser()
args = parser.parse_args()

workflow_ids = args.get("workflow_ids")
if workflow_ids:
workflow_ids = [wid.strip() for wid in workflow_ids.split(",") if wid.strip()]

limit = args["limit"]
offset = args["offset"]

workflow_tag_service = WorkflowTagService(session=db.session)

tags = workflow_tag_service.get_tags_by_app(
app_id=app_model.id,
workflow_ids=workflow_ids,
limit=limit,
offset=offset,
)

return PaginatedResponse(
items=list(tags or []),
limit=limit,
offset=offset,
has_more=len(tags or []) == limit,
).to_dict()

@setup_required
@login_required
@account_initialization_required
@get_app_model(mode=[AppMode.ADVANCED_CHAT, AppMode.WORKFLOW])
@marshal_with(workflow_tag_fields)
@api.doc("create_or_update_workflow_tag")
@api.doc(description="Create or update a workflow tag")
@api.doc(params={"app_id": "App ID"})
@api.expect(workflow_tag_create_update_fields, validate=True)
@api.doc(
responses={
200: "Workflow tag created or updated successfully",
400: "Bad request - invalid parameters",
401: "Unauthorized - user not logged in",
403: "Forbidden - user is not an editor",
404: "App not found",
}
)
def post(self, app_model: App):
assert isinstance(current_user, Account)
if not current_user.has_edit_permission:
raise Forbidden()

parser = reqparse.RequestParser()
parser.add_argument("workflow_id", type=uuid_value, required=True, location="json", help="Workflow ID")
parser.add_argument("name", type=tag_name, required=True, location="json", help="Tag name")

args = parser.parse_args()

workflow_id = args.get("workflow_id")
name = args.get("name")

workflow_service = WorkflowService()
workflow_tag_service = WorkflowTagService(session=db.session)
try:
request = WorkflowTagArgs(
app_id=app_model.id,
workflow_id=workflow_id.strip() if workflow_id else "",
name=name.strip() if name else "",
created_by=current_user.id,
)

# Check if tag already exists to determine create vs update
existing_tag = workflow_service.get_workflow_by_tag(
session=db.session,
app_id=app_model.id,
name=request.name,
)

if existing_tag:
# Update existing tag
tag = workflow_tag_service.update_tag(
request=request,
)
else:
# Create new tag
tag = workflow_tag_service.create_tag(
request=request,
)

db.session.commit()

return tag

except ValueError as e:
raise BadRequest(str(e))
except Exception as e:
logger.exception("Error creating/updating workflow tag")
raise BadRequest("Failed to create or update workflow tag")

@setup_required
@login_required
@account_initialization_required
@get_app_model(mode=[AppMode.ADVANCED_CHAT, AppMode.WORKFLOW])
@api.doc("delete_workflow_tag")
@api.doc(description="Delete a workflow tag")
@api.doc(params={"app_id": "App ID", "tag_id": "Tag ID"})
@api.doc(
responses={
200: "Workflow tag deleted successfully",
401: "Unauthorized - user not logged in",
403: "Forbidden - user is not an editor",
404: "App or tag not found",
}
)
def delete(self, app_model: App, tag_id: str):
assert isinstance(current_user, Account)
if not current_user.has_edit_permission:
raise Forbidden()

workflow_tag_service = WorkflowTagService(session=db.session)

try:
workflow_tag_service.delete_tag(
tag_id=tag_id,
app_id=app_model.id,
)
db.session.commit()

return {"message": "Workflow tag deleted successfully"}

except ValueError as e:
raise BadRequest(str(e))
except Exception as e:
logger.exception("Error deleting workflow tag")
raise BadRequest("Failed to delete workflow tag")
Loading
Loading