mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-27 08:25:07 +00:00
v4.5.2 (#439)
This commit is contained in:
47
packages/global/core/module/utils.ts
Normal file
47
packages/global/core/module/utils.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
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
|
||||
}))
|
||||
: []
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user