Files
gsfdc/demo-dify/dify/api/services/trigger/app_trigger_store.py
T
wuzilongandCursor 6519682885 chore: 纳入本地 Dify 1.19.0 源码及品牌与免登改动
演示目录只保留可重建的源码。运行密钥、数据卷、依赖和带口令的本地配置不进入仓库。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-18 13:59:25 +08:00

48 lines
1.3 KiB
Python

"""Detached records and persistence contract for Console app trigger management."""
from dataclasses import dataclass
from datetime import datetime
from typing import Protocol
from machinery.context import RequestContext
class WebhookTriggerNotFoundError(Exception):
"""The requested node has no webhook in the admitted app and workspace."""
class AppTriggerNotFoundError(Exception):
"""The trigger does not belong to the admitted app and workspace."""
@dataclass(frozen=True, slots=True)
class AppTriggerRecord:
"""Persisted values; None preserves a missing legacy node or provider name."""
id: str
trigger_type: str
title: str
node_id: str | None
provider_name: str | None
status: str
created_at: datetime
updated_at: datetime
@dataclass(frozen=True, slots=True)
class WebhookTriggerRecord:
id: str
webhook_id: str
node_id: str
created_at: datetime
class AppTriggerStore(Protocol):
def get_webhook(self, context: RequestContext, app_id: str, node_id: str) -> WebhookTriggerRecord: ...
def list_triggers(self, context: RequestContext, app_id: str) -> tuple[AppTriggerRecord, ...]: ...
def set_enabled(
self, context: RequestContext, app_id: str, trigger_id: str, *, enabled: bool
) -> AppTriggerRecord: ...