mirror of
https://github.com/langgenius/dify.git
synced 2026-02-18 00:44:46 +08:00
feat: change subscription field in workflow
This commit is contained in:
parent
bae8e44b32
commit
622d12137a
@ -17,7 +17,7 @@ import {
|
||||
RiClipboardLine,
|
||||
RiInformation2Fill,
|
||||
} from '@remixicon/react'
|
||||
import React, { useEffect, useMemo, useState } from 'react'
|
||||
import React, { useEffect, useState } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { usePluginStore } from '../store'
|
||||
|
||||
@ -48,9 +48,8 @@ export const OAuthClientSettingsModal = ({ oauthConfig, onClose, showOAuthCreate
|
||||
|
||||
const clientFormRef = React.useRef<FormRefObject>(null)
|
||||
|
||||
const providerName = useMemo(() => !detail ? '' : `${detail?.plugin_id}/${detail?.declaration.name}`, [detail])
|
||||
const clientSchema = detail?.declaration.trigger?.oauth_schema?.client_schema || []
|
||||
|
||||
const oauthClientSchema = detail?.declaration.trigger?.subscription_constructor?.oauth_schema?.client_schema || []
|
||||
const providerName = detail?.provider || ''
|
||||
const { mutate: initiateOAuth } = useInitiateTriggerOAuth()
|
||||
const { mutate: verifyBuilder } = useVerifyTriggerSubscriptionBuilder()
|
||||
const { mutate: configureOAuth } = useConfigureTriggerOAuth()
|
||||
@ -226,9 +225,9 @@ export const OAuthClientSettingsModal = ({ oauthConfig, onClose, showOAuthCreate
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
{clientType === ClientTypeEnum.Custom && clientSchema.length > 0 && (
|
||||
{clientType === ClientTypeEnum.Custom && oauthClientSchema.length > 0 && (
|
||||
<Form
|
||||
formSchemas={clientSchema}
|
||||
formSchemas={oauthClientSchema}
|
||||
ref={clientFormRef}
|
||||
defaultValues={oauthConfig?.params}
|
||||
/>
|
||||
|
||||
@ -88,14 +88,16 @@ export type PluginDeclaration = {
|
||||
trigger: PluginTriggerDefinition
|
||||
}
|
||||
|
||||
export type PluginTriggerSubscriptionConstructor = {
|
||||
credentials_schema: CredentialsSchema[]
|
||||
oauth_schema: OauthSchema
|
||||
parameters: ParametersSchema[]
|
||||
}
|
||||
|
||||
export type PluginTriggerDefinition = {
|
||||
events: Trigger[]
|
||||
identity: Identity
|
||||
subscription_constructor: {
|
||||
credentials_schema: CredentialsSchema[]
|
||||
oauth_schema: OauthSchema
|
||||
parameters: ParametersSchema[]
|
||||
}
|
||||
subscription_constructor: PluginTriggerSubscriptionConstructor
|
||||
subscription_schema: ParametersSchema[]
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import type { TypeWithI18N } from '@/app/components/header/account-setting/model-provider-page/declarations'
|
||||
import type { PluginMeta, SupportedCreationMethods } from '../../plugins/types'
|
||||
import type { ParametersSchema, PluginMeta, PluginTriggerSubscriptionConstructor, SupportedCreationMethods } from '../../plugins/types'
|
||||
import type { Collection, Event } from '../../tools/types'
|
||||
|
||||
export enum TabsEnum {
|
||||
@ -200,8 +200,8 @@ export type TriggerProviderApiEntity = {
|
||||
plugin_unique_identifier: string
|
||||
supported_creation_methods: SupportedCreationMethods[]
|
||||
credentials_schema: TriggerCredentialField[]
|
||||
oauth_client_schema: TriggerCredentialField[]
|
||||
subscription_schema: TriggerSubscriptionSchema
|
||||
subscription_constructor: PluginTriggerSubscriptionConstructor
|
||||
subscription_schema: ParametersSchema[]
|
||||
events: TriggerApiEntity[]
|
||||
}
|
||||
|
||||
@ -211,8 +211,9 @@ export type TriggerWithProvider = Collection & {
|
||||
meta: PluginMeta
|
||||
plugin_unique_identifier: string
|
||||
credentials_schema?: TriggerCredentialField[]
|
||||
oauth_client_schema?: TriggerCredentialField[]
|
||||
subscription_schema?: TriggerSubscriptionSchema
|
||||
subscription_constructor: PluginTriggerSubscriptionConstructor
|
||||
subscription_schema?: ParametersSchema[]
|
||||
supported_creation_methods: SupportedCreationMethods[]
|
||||
}
|
||||
|
||||
// ===== API Service Types =====
|
||||
|
||||
@ -22,13 +22,10 @@ export const SubscriptionMenu = memo(({ payload, selectedSubscriptionId, onSubsc
|
||||
provider: currentProvider.name,
|
||||
declaration: {
|
||||
tool: undefined,
|
||||
endpoint: undefined,
|
||||
// @ts-expect-error just remain the necessary fields
|
||||
trigger: {
|
||||
subscription_schema: currentProvider.subscription_schema,
|
||||
credentials_schema: currentProvider.credentials_schema,
|
||||
oauth_schema: {
|
||||
client_schema: currentProvider.oauth_client_schema,
|
||||
},
|
||||
subscription_schema: currentProvider.subscription_schema || [],
|
||||
subscription_constructor: currentProvider.subscription_constructor,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
@ -51,14 +51,6 @@ const useConfig = (id: string, payload: PluginTriggerNodeType) => {
|
||||
)
|
||||
}, [currentProvider, event_name])
|
||||
|
||||
// Dynamic subscription parameters (from subscription_schema.parameters_schema)
|
||||
const subscriptionParameterSchema = useMemo(() => {
|
||||
if (!currentProvider?.subscription_schema?.parameters_schema) return []
|
||||
return toolParametersToFormSchemas(
|
||||
currentProvider.subscription_schema.parameters_schema as any,
|
||||
)
|
||||
}, [currentProvider])
|
||||
|
||||
// Dynamic trigger parameters (from specific trigger.parameters)
|
||||
const triggerSpecificParameterSchema = useMemo(() => {
|
||||
if (!currentEvent) return []
|
||||
@ -126,27 +118,6 @@ const useConfig = (id: string, payload: PluginTriggerNodeType) => {
|
||||
|
||||
const showAuthRequired = !isAuthenticated && !!currentProvider
|
||||
|
||||
// Check supported authentication methods
|
||||
const supportedAuthMethods = useMemo(() => {
|
||||
if (!currentProvider) return []
|
||||
|
||||
const methods = []
|
||||
|
||||
if (
|
||||
currentProvider.oauth_client_schema
|
||||
&& currentProvider.oauth_client_schema.length > 0
|
||||
)
|
||||
methods.push('oauth')
|
||||
|
||||
if (
|
||||
currentProvider.credentials_schema
|
||||
&& currentProvider.credentials_schema.length > 0
|
||||
)
|
||||
methods.push('api_key')
|
||||
|
||||
return methods
|
||||
}, [currentProvider])
|
||||
|
||||
return {
|
||||
readOnly,
|
||||
inputs,
|
||||
@ -154,14 +125,12 @@ const useConfig = (id: string, payload: PluginTriggerNodeType) => {
|
||||
currentTrigger: currentEvent,
|
||||
triggerParameterSchema,
|
||||
triggerParameterValue,
|
||||
subscriptionParameterSchema,
|
||||
setTriggerParameterValue,
|
||||
setInputVar,
|
||||
outputSchema,
|
||||
hasObjectOutput,
|
||||
isAuthenticated,
|
||||
showAuthRequired,
|
||||
supportedAuthMethods,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -58,9 +58,9 @@ const convertToTriggerWithProvider = (provider: TriggerProviderApiEntity): Trigg
|
||||
})),
|
||||
|
||||
// Trigger-specific schema fields
|
||||
credentials_schema: provider.credentials_schema,
|
||||
oauth_client_schema: provider.oauth_client_schema,
|
||||
subscription_constructor: provider.subscription_constructor,
|
||||
subscription_schema: provider.subscription_schema,
|
||||
supported_creation_methods: provider.supported_creation_methods,
|
||||
|
||||
meta: {
|
||||
version: '1.0',
|
||||
|
||||
Loading…
Reference in New Issue
Block a user