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