danielduarte / flowed

A fast and reliable flow engine for orchestration and more uses in Node.js, Deno and the browser
https://danielduarte.github.io/flowed
MIT License
151 stars 21 forks source link

Feeding the Conditional resolver true/false results without using parameters #41

Closed dieeisenefaust closed 1 year ago

dieeisenefaust commented 1 year ago

From the examples I have looked over and the testing I have run, it does not appear that trueResult/FalseResult parameters can be set to a hardcoded line of text, but have to be fed their values from an entry in the parameter object.

If you have a flow spec with multiple conditionals which each have different true/false results, it would be easier to be able to write those directly in the params instead of having to feed in multiple different key/value pairs in hte parameters object.

Ex.

          resolver: {
            name: 'flowed::Conditional',
            params: { condition: 'intervalsCreated', trueResult: 'This is the text for true' , falseResult: 'This is the text for false' },
            results: {onTrue: 'ontrue', onFalse: 'onfalse'},
          },

And/or also being able to reference values in the context object

Ex.

        resolver: {
          name: 'flowed::Conditional',
          params: { condition: 'intervalsCreated', trueResult: 'context.context_true' , falseResult: 'context.context_false' },
          results: {onTrue: 'ontrue', onFalse: 'onfalse'},
        },
danielduarte commented 1 year ago

Hi @dieeisenefaust, You can set hardcoded values by using an object with the property val , just like in this example:

      resolver: {
        name: 'flowed::Conditional',
        params: {
          condition: 'intervalsCreated',
          trueResult: { val: 'This is the text for true' },
          falseResult: { val: 'This is the text for false' }
        },
        results: {onTrue: 'ontrue', onFalse: 'onfalse'},
      },

That way Flowed knows it has to be taken as a literal value. Using a string, it is taken as a "token" to be taken from the requires clause.

dieeisenefaust commented 1 year ago

Awesome! I figured you had it covered but couldn't find it in the documentation.

If you are okay with me pinging you with some more questions down the line and start a wiki page for the project, I would be happy to help add to the documentation from the standpoint of a user without knowledge of the core code.

dieeisenefaust commented 1 year ago

Should have tested this before responding but just a note that the property name needs to be value, not val, in the example above.

danielduarte commented 1 year ago

Yeah, you're right, it is value actually, thanks for correcting me! I'm OK with you pinging me with questions, and glad to know about the missing doc from the user's perspective. Also, I know I owe more doc to the community.