mirror of
https://github.com/labring/FastGPT.git
synced 2025-10-18 09:24:03 +00:00
48 lines
1.2 KiB
TypeScript
48 lines
1.2 KiB
TypeScript
import {
|
|
FlowNodeInputTypeEnum,
|
|
FlowNodeSpecialInputKeyEnum,
|
|
FlowNodeTypeEnum
|
|
} from './node/constant';
|
|
import { FlowNodeInputItemType, FlowNodeOutputItemType } from './node/type';
|
|
import { ModuleItemType } from './type';
|
|
|
|
export function getPluginTemplatePluginIdInput(pluginId: string) {
|
|
return {
|
|
key: FlowNodeSpecialInputKeyEnum.pluginId,
|
|
type: FlowNodeInputTypeEnum.hidden,
|
|
label: 'pluginId',
|
|
value: pluginId,
|
|
connected: true
|
|
};
|
|
}
|
|
|
|
export function formatPluginIOModules(
|
|
pluginId: string,
|
|
modules: ModuleItemType[]
|
|
): {
|
|
inputs: FlowNodeInputItemType[];
|
|
outputs: FlowNodeOutputItemType[];
|
|
} {
|
|
const pluginInput = modules.find((module) => module.flowType === FlowNodeTypeEnum.pluginInput);
|
|
const customOutput = modules.find((module) => module.flowType === FlowNodeTypeEnum.pluginOutput);
|
|
|
|
return {
|
|
inputs: pluginInput
|
|
? [
|
|
getPluginTemplatePluginIdInput(pluginId),
|
|
...pluginInput.inputs.map((item) => ({
|
|
...item,
|
|
edit: false,
|
|
connected: false
|
|
}))
|
|
]
|
|
: [],
|
|
outputs: customOutput
|
|
? customOutput.outputs.map((item) => ({
|
|
...item,
|
|
edit: false
|
|
}))
|
|
: []
|
|
};
|
|
}
|