fix: get plugin input variables from history (#2255)

This commit is contained in:
heheer
2024-08-03 12:31:31 +08:00
committed by GitHub
parent 48f2c95bb9
commit 110bf9391f
4 changed files with 47 additions and 7 deletions

View File

@@ -5,6 +5,20 @@ import { FlowNodeTypeEnum } from '../../workflow/node/constant';
export const getPluginInputsFromStoreNodes = (nodes: StoreNodeItemType[]) => {
return nodes.find((node) => node.flowNodeType === FlowNodeTypeEnum.pluginInput)?.inputs || [];
};
export const getPluginRunContent = (e: { pluginInputs: FlowNodeInputItemType[] }) => {
return JSON.stringify(e);
export const getPluginRunContent = ({
pluginInputs,
variables
}: {
pluginInputs: FlowNodeInputItemType[];
variables: Record<string, any>;
}) => {
const pluginInputsWithValue = pluginInputs.map((input) => {
const { key } = input;
const value = variables?.hasOwnProperty(key) ? variables[key] : input.defaultValue;
return {
...input,
value
};
});
return JSON.stringify(pluginInputsWithValue);
};