chore: initial commit
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import type {NodeHandler} from '../../../types/bot/workflow/runtime.ts';
|
||||
import type {WorkflowNodeTemplate} from '../../../types/bot/workflow/metadata.ts';
|
||||
import {describe, edge_input_output, failure_port, output, success_port} from '../metadata.ts';
|
||||
|
||||
export const config_template: WorkflowNodeTemplate = {
|
||||
name: 'merge', version: '1.0.0',
|
||||
i18n: describe('分支合流', '按全部入线汇合或每次到达独立继续的方式处理分支,输出本次入线数据。'),
|
||||
config: [
|
||||
{name: 'mode', type: 'select', required: true, default: 'all',
|
||||
i18n: describe('合流方式', '选择是否等待每一条入线;全部入线模式至少需要两条入线且不能作为入口节点。'),
|
||||
options: [
|
||||
{value: 'all', i18n: describe('全部入线', '等待同一轮次的每一条入线均到达后合并状态并执行一次;互斥分支可能导致入线无法到齐。')},
|
||||
{value: 'any', i18n: describe('每次到达', '每条入线每次到达都独立执行,不等待其他入线,也不会只执行首次到达。')},
|
||||
]},
|
||||
],
|
||||
output: {...output('object', '入线数据', '以连线 ID 为键的 inputs 对象;all 包含本轮全部入线,any 包含本次到达的入线。'),
|
||||
nullable: true, additional_properties: edge_input_output},
|
||||
ports: [success_port, failure_port],
|
||||
};
|
||||
|
||||
export const execute: NodeHandler = async (node, state, signal) => {
|
||||
if (node.type !== 'merge') throw new Error('Expected a merge node');
|
||||
signal.throwIfAborted();
|
||||
return {port: 'success', result: {status: 'success', output: state.inputs}};
|
||||
};
|
||||
Reference in New Issue
Block a user