OpusCapita / fsm-workflow

FSM workflow (for Node.js)
https://demo.core.dev.opuscapita.com/fsm-workflow/master
Apache License 2.0
28 stars 3 forks source link

Added inspectTransitions function, refactored conditions evaluation #73

Closed estambakio-sc closed 6 years ago

estambakio-sc commented 6 years ago

72

API remains the same as before, but internals work differently: findAvailableTransitions delegates to inspectTransitions. It acts similar to previous findAvailableTransitions but produces a verbose output which can be then filtered in many ways.

inspectTransitions is a low-level API and is mainly meant for debugging purposes.

Shape of output:

[
  {
    transition: <transition as it is defined in schema>,
    result: {
      guards: [
        {
          condition: <guard as defined in schema>,
          result: <evaluation result, boolean>
        },
        ...
      ],
      automatic: <boolean if defined as boolean> OR [
        {
          condition: <automatic as defined in schema>,
          result: <evaluation result, boolean>
        },
        ...
      ],
    }
  }
]

So, from this point you can find out why certain transition is not available, etc.