Further automation builder refactoring. #15500
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
While working on a previous automation builder refactor I noticed that all of the trigger methods (e.g.
appAction
,rowCreated
, etc.) took both aninputs
and anoutputs
. Theoutputs
were optional and only get used later if/when you callrun
. This confused me and made it difficult to follow the flow of information.I've refactored this flow so that this:
Becomes this:
A few things are happening here:
on
to make them read nicer in-situ (onCron
is admittedly not the nicest example of this, things likeonRowSaved
is much nicer though).createAutomationBuilder
now returns aTriggerBuilder
that you can only use to choose a trigger. Once you do, aStepBuilder<T>
is returned that lets you create steps. This forces you to choose exactly 1 trigger, and types the automation based on the trigger chosen. ThisT
is then used later in the renamedtest
(used to berun
buttest
makes it more clear what API is being used) to know what output type to accept.save
method (whichtest
calls internally) now returns anAutomationRunner<T>
which allows you to calltest
as many times as you want without creating a new automation. This opens up some new use-cases of testing an automation multiple times without having to do gymnastic with the builder API.So in short this new structure makes it more difficult to make mistakes, and more obvious what data is going where and when.