fix(plugin-workflow): fix condition config param (#1483)
This commit is contained in:
parent
33f6bb4c63
commit
a18918576b
@ -44,7 +44,7 @@ describe('workflow > instructions > condition', () => {
|
||||
type: 'condition',
|
||||
config: {
|
||||
engine: 'math.js',
|
||||
calculation: '1 == 1'
|
||||
expression: '1 == 1'
|
||||
}
|
||||
});
|
||||
|
||||
@ -81,7 +81,7 @@ describe('workflow > instructions > condition', () => {
|
||||
config: {
|
||||
engine: 'math.js',
|
||||
// false
|
||||
calculation: '0 == 1'
|
||||
expression: '0 == 1'
|
||||
}
|
||||
});
|
||||
|
||||
@ -117,13 +117,12 @@ describe('workflow > instructions > condition', () => {
|
||||
const n1 = await workflow.createNode({
|
||||
type: 'condition',
|
||||
config: {
|
||||
engine: 'math.js',
|
||||
calculation: {
|
||||
group: {
|
||||
type: 'and',
|
||||
calculations: [
|
||||
'1 == 1',
|
||||
'1 == 1',
|
||||
{ calculator: 'equal', operands: [1, 1] },
|
||||
{ calculator: 'equal', operands: [1, 1] }
|
||||
]
|
||||
}
|
||||
}
|
||||
@ -143,13 +142,12 @@ describe('workflow > instructions > condition', () => {
|
||||
const n1 = await workflow.createNode({
|
||||
type: 'condition',
|
||||
config: {
|
||||
engine: 'math.js',
|
||||
calculation: {
|
||||
group: {
|
||||
type: 'and',
|
||||
calculations: [
|
||||
'1 == 1',
|
||||
'0 == 1',
|
||||
{ calculator: 'equal', operands: [1, 1] },
|
||||
{ calculator: 'equal', operands: [0, 1] }
|
||||
]
|
||||
}
|
||||
}
|
||||
@ -169,13 +167,12 @@ describe('workflow > instructions > condition', () => {
|
||||
const n1 = await workflow.createNode({
|
||||
type: 'condition',
|
||||
config: {
|
||||
engine: 'math.js',
|
||||
calculation: {
|
||||
group: {
|
||||
type: 'or',
|
||||
calculations: [
|
||||
'1 == 1',
|
||||
'0 == 1',
|
||||
{ calculator: 'equal', operands: [1, 1] },
|
||||
{ calculator: 'equal', operands: [0, 1] }
|
||||
]
|
||||
}
|
||||
}
|
||||
@ -195,13 +192,12 @@ describe('workflow > instructions > condition', () => {
|
||||
const n1 = await workflow.createNode({
|
||||
type: 'condition',
|
||||
config: {
|
||||
engine: 'math.js',
|
||||
calculation: {
|
||||
group: {
|
||||
type: 'and',
|
||||
calculations: [
|
||||
'0 == 1',
|
||||
'0 == 1',
|
||||
{ calculator: 'equal', operands: [0, 1] },
|
||||
{ calculator: 'equal', operands: [0, 1] }
|
||||
]
|
||||
}
|
||||
}
|
||||
@ -221,18 +217,17 @@ describe('workflow > instructions > condition', () => {
|
||||
const n1 = await workflow.createNode({
|
||||
type: 'condition',
|
||||
config: {
|
||||
engine: 'math.js',
|
||||
calculation: {
|
||||
group: {
|
||||
type: 'and',
|
||||
calculations: [
|
||||
'1 == 1',
|
||||
{ calculator: 'equal', operands: [1, 1] },
|
||||
{
|
||||
group: {
|
||||
type: 'or',
|
||||
calculations: [
|
||||
'0 == 1',
|
||||
'0 == 1',
|
||||
{ calculator: 'equal', operands: [0, 1] },
|
||||
{ calculator: 'equal', operands: [0, 1] }
|
||||
]
|
||||
}
|
||||
}
|
||||
@ -306,7 +301,7 @@ describe('workflow > instructions > condition', () => {
|
||||
type: 'condition',
|
||||
config: {
|
||||
engine: 'math.js',
|
||||
calculation: '1 == 1'
|
||||
expression: '1 == 1'
|
||||
}
|
||||
});
|
||||
|
||||
@ -327,7 +322,7 @@ describe('workflow > instructions > condition', () => {
|
||||
type: 'condition',
|
||||
config: {
|
||||
engine: 'formula.js',
|
||||
calculation: '1 == 1'
|
||||
expression: '1 == 1'
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -21,7 +21,7 @@ export default {
|
||||
async run(node: FlowNodeModel, prevJob, processor: Processor) {
|
||||
// TODO(optimize): loading of jobs could be reduced and turned into incrementally in processor
|
||||
// const jobs = await processor.getJobs();
|
||||
const { engine = 'basic', calculation, rejectOnFalse } = node.config || {};
|
||||
const { engine = 'basic', calculation, expression, rejectOnFalse } = node.config || {};
|
||||
const evaluator = <Evaluator | undefined>processor.options.plugin.calculators.get(engine);
|
||||
if (!evaluator) {
|
||||
return {
|
||||
@ -34,7 +34,7 @@ export default {
|
||||
let result = true;
|
||||
|
||||
try {
|
||||
result = logicCalculate(processor.getParsedValue(calculation), evaluator, scope);
|
||||
result = logicCalculate(engine === 'basic' ? processor.getParsedValue(calculation) : expression, evaluator, scope);
|
||||
} catch (e) {
|
||||
return {
|
||||
result: e.toString(),
|
||||
|
Loading…
Reference in New Issue
Block a user