mirror of
https://github.com/langgenius/dify.git
synced 2025-11-24 08:52:43 +00:00
Signed-off-by: lyzno1 <yuanyouhuilyz@gmail.com> Co-authored-by: Stream <Stream_2@qq.com> Co-authored-by: lyzno1 <92089059+lyzno1@users.noreply.github.com> Co-authored-by: zhsama <torvalds@linux.do> Co-authored-by: Harry <xh001x@hotmail.com> Co-authored-by: lyzno1 <yuanyouhuilyz@gmail.com> Co-authored-by: yessenia <yessenia.contact@gmail.com> Co-authored-by: hjlarry <hjlarry@163.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: WTW0313 <twwu@dify.ai> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
68 lines
1.7 KiB
Python
68 lines
1.7 KiB
Python
from collections.abc import Mapping
|
|
from enum import StrEnum
|
|
from typing import Any
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
class TriggerDebugPoolKey(StrEnum):
|
|
"""Trigger debug pool key."""
|
|
|
|
SCHEDULE = "schedule_trigger_debug_waiting_pool"
|
|
WEBHOOK = "webhook_trigger_debug_waiting_pool"
|
|
PLUGIN = "plugin_trigger_debug_waiting_pool"
|
|
|
|
|
|
class BaseDebugEvent(BaseModel):
|
|
"""Base class for all debug events."""
|
|
|
|
timestamp: int
|
|
|
|
|
|
class ScheduleDebugEvent(BaseDebugEvent):
|
|
"""Debug event for schedule triggers."""
|
|
|
|
node_id: str
|
|
inputs: Mapping[str, Any]
|
|
|
|
|
|
class WebhookDebugEvent(BaseDebugEvent):
|
|
"""Debug event for webhook triggers."""
|
|
|
|
request_id: str
|
|
node_id: str
|
|
payload: dict[str, Any] = Field(default_factory=dict)
|
|
|
|
|
|
def build_webhook_pool_key(tenant_id: str, app_id: str, node_id: str) -> str:
|
|
"""Generate pool key for webhook events.
|
|
|
|
Args:
|
|
tenant_id: Tenant ID
|
|
app_id: App ID
|
|
node_id: Node ID
|
|
"""
|
|
return f"{TriggerDebugPoolKey.WEBHOOK}:{tenant_id}:{app_id}:{node_id}"
|
|
|
|
|
|
class PluginTriggerDebugEvent(BaseDebugEvent):
|
|
"""Debug event for plugin triggers."""
|
|
|
|
name: str
|
|
user_id: str = Field(description="This is end user id, only for trigger the event. no related with account user id")
|
|
request_id: str
|
|
subscription_id: str
|
|
provider_id: str
|
|
|
|
|
|
def build_plugin_pool_key(tenant_id: str, provider_id: str, subscription_id: str, name: str) -> str:
|
|
"""Generate pool key for plugin trigger events.
|
|
|
|
Args:
|
|
name: Event name
|
|
tenant_id: Tenant ID
|
|
provider_id: Provider ID
|
|
subscription_id: Subscription ID
|
|
"""
|
|
return f"{TriggerDebugPoolKey.PLUGIN}:{tenant_id}:{str(provider_id)}:{subscription_id}:{name}"
|