Last active
August 12, 2022 22:46
-
-
Save scarabaeus/59c11c747a3131eac9a881b8425a50b9 to your computer and use it in GitHub Desktop.
[email protected] Generic-ish transform to dump an entire context into a sendEvent call
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Merges the original context with the expected contract and then filters out the original context's properties | |
$ ~> | $ | | |
{ | |
"instanceId": $.originatorId, | |
"event": "CONTINUE", | |
"context": $ ~> | $ | {}, ["originatorId"] | | |
}, [ | |
$filter($keys($), | |
function($key) { | |
$key != "instanceId" and $key != "context" and $key != "event" | |
}) | |
] | |
| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Renamed "instanceId" to "originatorId" as to not confuse the instanceId of the parent machine (origin) and the child machine. | |
{ | |
"originatorId": "12345", | |
"tenantId": "initech" | |
"firstName": "Steve", | |
"phoneNumber": "+14155551212", | |
/* ...whatever else you need in the payload */ | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// { | |
// "instanceId": "12345", | |
// "event": "CONTINUE", | |
// "context": { | |
// "firstName": "Steve", | |
// "phoneNumber": "+14155551212", | |
// "tenantId": "initech" | |
// } | |
// } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
FYI The "
function
" is not a raw JavaScript function, but a JSONata evaluated function.