mirror of
https://github.com/langgenius/dify.git
synced 2026-05-06 02:18:08 +08:00
refactor(trigger): rename TriggerApiEntity to EventApiEntity and update related references
- Changed `TriggerApiEntity` to `EventApiEntity` in the trigger provider and subscription models to better reflect its purpose. - Updated the description field type from `EventDescription` to `I18nObject` for improved consistency in event descriptions. - Adjusted imports and references across multiple files to accommodate the renaming and type changes, ensuring proper functionality in trigger processing.
This commit is contained in:
@ -7,7 +7,6 @@ from core.entities.provider_entities import ProviderConfig
|
|||||||
from core.plugin.entities.plugin_daemon import CredentialType
|
from core.plugin.entities.plugin_daemon import CredentialType
|
||||||
from core.tools.entities.common_entities import I18nObject
|
from core.tools.entities.common_entities import I18nObject
|
||||||
from core.trigger.entities.entities import (
|
from core.trigger.entities.entities import (
|
||||||
EventDescription,
|
|
||||||
EventIdentity,
|
EventIdentity,
|
||||||
EventParameter,
|
EventParameter,
|
||||||
SubscriptionConstructor,
|
SubscriptionConstructor,
|
||||||
@ -27,10 +26,10 @@ class TriggerProviderSubscriptionApiEntity(BaseModel):
|
|||||||
workflows_in_use: int = Field(description="The number of workflows using this subscription")
|
workflows_in_use: int = Field(description="The number of workflows using this subscription")
|
||||||
|
|
||||||
|
|
||||||
class TriggerApiEntity(BaseModel):
|
class EventApiEntity(BaseModel):
|
||||||
name: str = Field(description="The name of the trigger")
|
name: str = Field(description="The name of the trigger")
|
||||||
identity: EventIdentity = Field(description="The identity of the trigger")
|
identity: EventIdentity = Field(description="The identity of the trigger")
|
||||||
description: EventDescription = Field(description="The description of the trigger")
|
description: I18nObject = Field(description="The description of the trigger")
|
||||||
parameters: list[EventParameter] = Field(description="The parameters of the trigger")
|
parameters: list[EventParameter] = Field(description="The parameters of the trigger")
|
||||||
output_schema: Optional[Mapping[str, Any]] = Field(description="The output schema of the trigger")
|
output_schema: Optional[Mapping[str, Any]] = Field(description="The output schema of the trigger")
|
||||||
|
|
||||||
@ -60,7 +59,7 @@ class TriggerProviderApiEntity(BaseModel):
|
|||||||
default_factory=list,
|
default_factory=list,
|
||||||
description="The subscription schema of the trigger provider",
|
description="The subscription schema of the trigger provider",
|
||||||
)
|
)
|
||||||
events: list[TriggerApiEntity] = Field(description="The events of the trigger provider")
|
events: list[EventApiEntity] = Field(description="The events of the trigger provider")
|
||||||
|
|
||||||
|
|
||||||
class SubscriptionBuilderApiEntity(BaseModel):
|
class SubscriptionBuilderApiEntity(BaseModel):
|
||||||
@ -74,4 +73,4 @@ class SubscriptionBuilderApiEntity(BaseModel):
|
|||||||
credential_type: CredentialType = Field(description="The credential type of the subscription builder")
|
credential_type: CredentialType = Field(description="The credential type of the subscription builder")
|
||||||
|
|
||||||
|
|
||||||
__all__ = ["TriggerApiEntity", "TriggerProviderApiEntity", "TriggerProviderSubscriptionApiEntity"]
|
__all__ = ["EventApiEntity", "TriggerProviderApiEntity", "TriggerProviderSubscriptionApiEntity"]
|
||||||
|
|||||||
@ -90,15 +90,6 @@ class EventIdentity(BaseModel):
|
|||||||
provider: Optional[str] = Field(default=None, description="The provider of the event")
|
provider: Optional[str] = Field(default=None, description="The provider of the event")
|
||||||
|
|
||||||
|
|
||||||
class EventDescription(BaseModel):
|
|
||||||
"""
|
|
||||||
The description of the event
|
|
||||||
"""
|
|
||||||
|
|
||||||
human: I18nObject = Field(..., description="Human readable description")
|
|
||||||
llm: I18nObject = Field(..., description="LLM readable description")
|
|
||||||
|
|
||||||
|
|
||||||
class EventEntity(BaseModel):
|
class EventEntity(BaseModel):
|
||||||
"""
|
"""
|
||||||
The configuration of an event
|
The configuration of an event
|
||||||
@ -106,7 +97,7 @@ class EventEntity(BaseModel):
|
|||||||
|
|
||||||
identity: EventIdentity = Field(..., description="The identity of the event")
|
identity: EventIdentity = Field(..., description="The identity of the event")
|
||||||
parameters: list[EventParameter] = Field(default=[], description="The parameters of the event")
|
parameters: list[EventParameter] = Field(default=[], description="The parameters of the event")
|
||||||
description: EventDescription = Field(..., description="The description of the event")
|
description: I18nObject = Field(..., description="The description of the event")
|
||||||
output_schema: Optional[Mapping[str, Any]] = Field(
|
output_schema: Optional[Mapping[str, Any]] = Field(
|
||||||
default=None, description="The output schema that this event produces"
|
default=None, description="The output schema that this event produces"
|
||||||
)
|
)
|
||||||
@ -279,7 +270,6 @@ class TriggerCreationMethod(StrEnum):
|
|||||||
|
|
||||||
# Export all entities
|
# Export all entities
|
||||||
__all__: list[str] = [
|
__all__: list[str] = [
|
||||||
"EventDescription",
|
|
||||||
"EventEntity",
|
"EventEntity",
|
||||||
"EventIdentity",
|
"EventIdentity",
|
||||||
"EventParameter",
|
"EventParameter",
|
||||||
|
|||||||
@ -16,7 +16,7 @@ from core.plugin.entities.request import (
|
|||||||
TriggerSubscriptionResponse,
|
TriggerSubscriptionResponse,
|
||||||
)
|
)
|
||||||
from core.plugin.impl.trigger import PluginTriggerManager
|
from core.plugin.impl.trigger import PluginTriggerManager
|
||||||
from core.trigger.entities.api_entities import TriggerApiEntity, TriggerProviderApiEntity
|
from core.trigger.entities.api_entities import EventApiEntity, TriggerProviderApiEntity
|
||||||
from core.trigger.entities.entities import (
|
from core.trigger.entities.entities import (
|
||||||
EventEntity,
|
EventEntity,
|
||||||
ProviderConfig,
|
ProviderConfig,
|
||||||
@ -102,7 +102,7 @@ class PluginTriggerProviderController:
|
|||||||
subscription_schema=self.entity.subscription_schema,
|
subscription_schema=self.entity.subscription_schema,
|
||||||
supported_creation_methods=supported_creation_methods,
|
supported_creation_methods=supported_creation_methods,
|
||||||
events=[
|
events=[
|
||||||
TriggerApiEntity(
|
EventApiEntity(
|
||||||
name=event.identity.name,
|
name=event.identity.name,
|
||||||
identity=event.identity,
|
identity=event.identity,
|
||||||
description=event.description,
|
description=event.description,
|
||||||
|
|||||||
@ -12,7 +12,7 @@ from yarl import URL
|
|||||||
|
|
||||||
import contexts
|
import contexts
|
||||||
from configs import dify_config
|
from configs import dify_config
|
||||||
from core.plugin.entities.plugin_daemon import CredentialType, PluginTriggerProviderEntity
|
from core.plugin.entities.plugin_daemon import CredentialType, PluginDaemonError, PluginTriggerProviderEntity
|
||||||
from core.plugin.entities.request import TriggerInvokeEventResponse
|
from core.plugin.entities.request import TriggerInvokeEventResponse
|
||||||
from core.plugin.impl.exc import PluginInvokeError
|
from core.plugin.impl.exc import PluginInvokeError
|
||||||
from core.plugin.impl.trigger import PluginTriggerManager
|
from core.plugin.impl.trigger import PluginTriggerManager
|
||||||
@ -123,6 +123,8 @@ class TriggerManager:
|
|||||||
)
|
)
|
||||||
plugin_trigger_providers[provider_id_str] = controller
|
plugin_trigger_providers[provider_id_str] = controller
|
||||||
return controller
|
return controller
|
||||||
|
except PluginDaemonError as e:
|
||||||
|
raise e
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.exception("Failed to load trigger provider")
|
logger.exception("Failed to load trigger provider")
|
||||||
raise e
|
raise e
|
||||||
|
|||||||
@ -107,7 +107,7 @@ export type Event = {
|
|||||||
name: string
|
name: string
|
||||||
author: string
|
author: string
|
||||||
label: TypeWithI18N
|
label: TypeWithI18N
|
||||||
description: any
|
description: TypeWithI18N
|
||||||
parameters: TriggerParameter[]
|
parameters: TriggerParameter[]
|
||||||
labels: string[]
|
labels: string[]
|
||||||
output_schema: Record<string, any>
|
output_schema: Record<string, any>
|
||||||
|
|||||||
Reference in New Issue
Block a user