1
0
Fork 0
mirror of synced 2024-06-29 03:20:34 +12:00

Some fixes after playing around with the new Builder UI.

This commit is contained in:
mike12345567 2020-09-17 16:16:05 +01:00
parent 076ed09c38
commit 22ef6eb4d3
4 changed files with 21 additions and 9 deletions

View file

@ -3,11 +3,16 @@ const validateJs = require("validate.js")
const newid = require("../../db/newid")
function emitEvent(eventType, ctx, record) {
// add syntactic sugar for mustache later
if (record._id) {
record.id = record._id
}
if (record._rev) {
record.revision = record._rev
}
ctx.eventEmitter &&
ctx.eventEmitter.emit(eventType, {
args: {
record,
},
record,
instanceId: ctx.user.instanceId,
})
}

View file

@ -27,8 +27,8 @@ function generateValidator(existing = false) {
// prettier-ignore
return joiValidator.body(Joi.object({
live: Joi.bool(),
id: existing ? Joi.string().required() : Joi.string(),
rev: existing ? Joi.string().required() : Joi.string(),
_id: existing ? Joi.string().required() : Joi.string(),
_rev: existing ? Joi.string().required() : Joi.string(),
name: Joi.string().required(),
type: Joi.string().valid("workflow").required(),
definition: Joi.object({

View file

@ -25,7 +25,7 @@ module.exports.definition = {
schema: {
inputs: {
properties: {
filter: {
field: {
type: "string",
title: "Reference Value",
},
@ -40,7 +40,7 @@ module.exports.definition = {
title: "Comparison Value",
},
},
required: ["filter", "condition", "value"],
required: ["field", "condition", "value"],
},
outputs: {
properties: {
@ -59,10 +59,10 @@ module.exports.run = async function filter({ inputs }) {
let success
if (typeof field !== "object" && typeof value !== "object") {
switch (condition) {
case LogicConditions.EQUALS:
case LogicConditions.EQUAL:
success = field === value
break
case LogicConditions.NOT_EQUALS:
case LogicConditions.NOT_EQUAL:
success = field !== value
break
case LogicConditions.GREATER_THAN:

View file

@ -2,6 +2,8 @@ const mustache = require("mustache")
const actions = require("./actions")
const logic = require("./logic")
const FILTER_STEP_ID = logic.BUILTIN_DEFINITIONS.FILTER.stepId
function cleanMustache(string) {
let charToReplace = {
"[": ".",
@ -47,6 +49,8 @@ function recurseMustache(inputs, context) {
class Orchestrator {
constructor(workflow, triggerOutput) {
this._instanceId = triggerOutput.instanceId
// remove from context
delete triggerOutput.instanceId
// step zero is never used as the mustache is zero indexed for customer facing
this._context = { steps: [{}], trigger: triggerOutput }
this._workflow = workflow
@ -75,6 +79,9 @@ class Orchestrator {
inputs: step.inputs,
instanceId: this._instanceId,
})
if (step.stepId === FILTER_STEP_ID && !outputs.success) {
break
}
this._context.steps.push(outputs)
}
}