refactor(trigger): rename trigger references to event for consistency

- Updated variable names and types from 'trigger' to 'event' across multiple files to enhance clarity and maintain consistency in the codebase.
- Adjusted related data structures and API responses to reflect the new naming convention.
- Improved type annotations and error handling in the workflow trigger run API and associated services.
This commit is contained in:
Harry
2025-10-09 03:12:35 +08:00
parent a33d04d1ac
commit 91318d3d04
22 changed files with 114 additions and 96 deletions

View File

@ -27,7 +27,7 @@ import cn from '@/utils/classnames'
import { Listbox, ListboxButton, ListboxOption, ListboxOptions } from '@headlessui/react'
import { ChevronDownIcon } from '@heroicons/react/20/solid'
import { RiCheckLine, RiLoader4Line } from '@remixicon/react'
import type { Trigger } from '@/app/components/tools/types'
import type { Event } from '@/app/components/tools/types'
type Props = {
readOnly: boolean
@ -36,7 +36,7 @@ type Props = {
value: ResourceVarInputs
onChange: (value: any) => void
inPanel?: boolean
currentTool?: Tool | Trigger
currentTool?: Tool | Event
currentProvider?: ToolWithProvider | TriggerWithProvider
showManageInputField?: boolean
onManageInputField?: () => void

View File

@ -3,7 +3,7 @@ import type { FC } from 'react'
import { useMemo } from 'react'
import { useTranslation } from 'react-i18next'
import type { TriggerWithProvider } from '@/app/components/workflow/block-selector/types'
import type { Trigger } from '@/app/components/tools/types'
import type { Event } from '@/app/components/tools/types'
import { toolCredentialToFormSchemas, toolParametersToFormSchemas } from '@/app/components/tools/utils/to-form-schema'
import TriggerForm from './trigger-form'
import Button from '@/app/components/base/button'
@ -11,7 +11,7 @@ import Input from '@/app/components/base/input'
type ParametersFormProps = {
provider: TriggerWithProvider
trigger?: Trigger
trigger?: Event
builderId: string
parametersValue: Record<string, any>
propertiesValue: Record<string, any>

View File

@ -1,6 +1,6 @@
'use client'
import type { CredentialFormSchema } from '@/app/components/header/account-setting/model-provider-page/declarations'
import type { Trigger } from '@/app/components/tools/types'
import type { Event } from '@/app/components/tools/types'
import type { FC } from 'react'
import type { PluginTriggerVarInputs } from '@/app/components/workflow/nodes/trigger-plugin/types'
import TriggerFormItem from './item'
@ -14,7 +14,7 @@ type Props = {
onChange: (value: PluginTriggerVarInputs) => void
onOpen?: (index: number) => void
inPanel?: boolean
currentTrigger?: Trigger
currentTrigger?: Event
currentProvider?: TriggerWithProvider
extraParams?: Record<string, any>
}

View File

@ -12,7 +12,7 @@ import Tooltip from '@/app/components/base/tooltip'
import FormInputItem from '@/app/components/workflow/nodes/_base/components/form-input-item'
import { useBoolean } from 'ahooks'
import SchemaModal from '@/app/components/plugins/plugin-detail-panel/tool-selector/schema-modal'
import type { Trigger } from '@/app/components/tools/types'
import type { Event } from '@/app/components/tools/types'
import type { TriggerWithProvider } from '@/app/components/workflow/block-selector/types'
type Props = {
@ -22,7 +22,7 @@ type Props = {
value: PluginTriggerVarInputs
onChange: (value: PluginTriggerVarInputs) => void
inPanel?: boolean
currentTrigger?: Trigger
currentTrigger?: Event
currentProvider?: TriggerWithProvider
extraParams?: Record<string, any>
}

View File

@ -13,7 +13,7 @@ const nodeDefault: NodeDefault<PluginTriggerNodeType> = {
metaData,
defaultValue: {
plugin_id: '',
trigger_name: '',
event_name: '',
// event_type: '',
config: {},
},

View File

@ -6,14 +6,14 @@ export type PluginTriggerNodeType = CommonNodeType & {
provider_id: string
provider_type: CollectionType
provider_name: string
trigger_name: string
trigger_label: string
trigger_parameters: PluginTriggerVarInputs
trigger_configurations: Record<string, any>
event_name: string
event_label: string
event_parameters: PluginTriggerVarInputs
event_configurations: Record<string, any>
output_schema: Record<string, any>
parameters_schema?: Record<string, any>[]
version?: string
trigger_node_version?: string
event_node_version?: string
plugin_id?: string
config?: Record<string, any>
}

View File

@ -13,7 +13,7 @@ import {
} from '@/app/components/tools/utils/to-form-schema'
import type { InputVar } from '@/app/components/workflow/types'
import type { TriggerWithProvider } from '@/app/components/workflow/block-selector/types'
import type { Trigger } from '@/app/components/tools/types'
import type { Event } from '@/app/components/tools/types'
const useConfig = (id: string, payload: PluginTriggerNodeType) => {
const { nodesReadOnly: readOnly } = useNodesReadOnly()
@ -24,7 +24,7 @@ const useConfig = (id: string, payload: PluginTriggerNodeType) => {
payload,
)
const { provider_id, provider_name, trigger_name, config } = inputs
const { provider_id, provider_name, event_name: event_name, config } = inputs
// Construct provider for authentication check
const authProvider = useMemo(() => {
@ -45,11 +45,11 @@ const useConfig = (id: string, payload: PluginTriggerNodeType) => {
)
}, [triggerPlugins, provider_name, provider_id])
const currentTrigger = useMemo<Trigger | undefined>(() => {
return currentProvider?.triggers.find(
trigger => trigger.name === trigger_name,
const currentEvent = useMemo<Event | undefined>(() => {
return currentProvider?.events.find(
event => event.name === event_name,
)
}, [currentProvider, trigger_name])
}, [currentProvider, event_name])
// Dynamic subscription parameters (from subscription_schema.parameters_schema)
const subscriptionParameterSchema = useMemo(() => {
@ -61,9 +61,9 @@ const useConfig = (id: string, payload: PluginTriggerNodeType) => {
// Dynamic trigger parameters (from specific trigger.parameters)
const triggerSpecificParameterSchema = useMemo(() => {
if (!currentTrigger) return []
return toolParametersToFormSchemas(currentTrigger.parameters)
}, [currentTrigger])
if (!currentEvent) return []
return toolParametersToFormSchemas(currentEvent.parameters)
}, [currentEvent])
// Combined parameter schema (subscription + trigger specific)
const triggerParameterSchema = useMemo(() => {
@ -106,8 +106,8 @@ const useConfig = (id: string, payload: PluginTriggerNodeType) => {
// Get output schema
const outputSchema = useMemo(() => {
return currentTrigger?.output_schema || {}
}, [currentTrigger])
return currentEvent?.output_schema || {}
}, [currentEvent])
// Check if trigger has complex output structure
const hasObjectOutput = useMemo(() => {
@ -151,7 +151,7 @@ const useConfig = (id: string, payload: PluginTriggerNodeType) => {
readOnly,
inputs,
currentProvider,
currentTrigger,
currentTrigger: currentEvent,
triggerParameterSchema,
triggerParameterValue,
subscriptionParameterSchema,