Merging
Blocks act as synchronous functions with optional metadata in the form of Addons. Blocks don’t know what order they’re run in or what other Blocks exist. They only know to map Addons and Options inputs to output Creations.
Addons
At runtime, the create
engine will often need to re-run Blocks continuously as they receive Addons from other Blocks.
Blocks will be re-run whenever other Blocks signal new Addon data to them that they haven’t yet seen.
This allows Blocks to not need any explicit indication of what order to run in.
Addons are merged by concatenating arrays and removing duplicate elements.
Duplicates are detected by hash-object
object hashing.
For example, given the following two Addons to be merged:
The merged result would be:
Creations
Each of the four other Creations from Blocks has their own merging logic:
Files
File objects are recursively merged:
false
andundefined
values are ignored- Files are deduplicated if they have the same value, and an error is thrown if they do not
For example, given the following two files
Creations to be merged:
The merged result would be:
Requests
Requests are deduplicated based on their id
.
Later-created requests will override any previously created requests with the same id
.
For example, given the following two requests
Creations to be merged:
The merged result would be just the latter Creation:
Scripts
Scripts are deduplicated based on whether they include a phase
:
- “Phase” scripts are deduplicated if any’s arrays of
commands
are the same as any other - “Standalone” scripts provided as
string
are deduplicated and run in parallel after scripts with phases
For example, given the following two scripts
Creations to be merged:
The merged result would be:
Suggestions
Suggestions are deduplicated by identity.
For example, given the following two suggestions
Creations to be merged:
The merged result would be: