2022-02-27 14:58:41 +00:00
|
|
|
import { JOB_STATUS } from "../constants";
|
|
|
|
import FlowNodeModel from "../models/FlowNode";
|
|
|
|
import { calculate } from "../calculators";
|
|
|
|
|
|
|
|
// @calculation: {
|
|
|
|
// calculator: 'concat',
|
|
|
|
// operands: [
|
|
|
|
// {
|
|
|
|
// type: 'calculation',
|
|
|
|
// options: {
|
|
|
|
// calculator: 'add',
|
|
|
|
// operands: [{ value: 1 }, { value: 2 }]
|
|
|
|
// }
|
|
|
|
// },
|
|
|
|
// {
|
|
|
|
// type: 'constant',
|
|
|
|
// value: '{{$context.data.title}}'
|
|
|
|
// },
|
|
|
|
// {
|
|
|
|
// type: 'context',
|
|
|
|
// options: {
|
|
|
|
// path: 'data.title'
|
|
|
|
// }
|
|
|
|
// },
|
|
|
|
// {
|
|
|
|
// type: 'constant',
|
|
|
|
// value: 1
|
|
|
|
// }
|
|
|
|
// ]
|
|
|
|
// }
|
|
|
|
|
|
|
|
export default {
|
2022-06-24 15:28:49 +00:00
|
|
|
async run(node: FlowNodeModel, prevJob, processor) {
|
|
|
|
const { calculation } = node.config || {};
|
2022-02-27 14:58:41 +00:00
|
|
|
|
|
|
|
const result = calculation
|
|
|
|
? calculate({
|
2022-04-13 16:05:13 +00:00
|
|
|
type: '$calculation',
|
2022-06-20 15:29:21 +00:00
|
|
|
options: processor.getParsedValue(calculation)
|
|
|
|
}, prevJob, processor)
|
2022-02-27 14:58:41 +00:00
|
|
|
: null;
|
|
|
|
|
|
|
|
return {
|
|
|
|
result,
|
|
|
|
status: JOB_STATUS.RESOLVED
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|