# 代码节点
工作流的代码执行节点,用于执行自定义代码。
# 数据结构定义
export interface CodeNodeDef {
id: INodeIDValue;
type: WorkflowNodeTypeEnum.Code;
data: {
title: string;
inputsValues: {
script: {
language: IFlowConstantValue, // 脚本类型
content: IFlowFreemarkerValue, // 脚本内容
},
input_params: Record<string, IFlowValue>; // 输入参数
};
inputs: IJsonSchema; // 节点输入数据类型
outputs: IJsonSchema; // 节点输出数据类型
}
}
# 范例
{
id: {random(6)},
type: 'code',
data: {
title: `代码`,
inputsValues: {
script: {
language: 'python', // 脚本类型
content: '', // 脚本内容
},
input_params: {
arg1: { // 输入参数1
type: 'constant',
content: ''
},
}
},
inputs: {
type: 'object',
required: [],
properties: {
script: {
type: 'object',
properties: {
language: { type: 'string' },
content: { type: 'string' },
},
},
input_params: {
type: 'object',
properties: {
arg1: { type: 'string' },
},
},
},
},
outputs: {
type: 'object',
properties: {
result: {
type: 'string',
},
},
},
},
}