JSON Format

Compositions are encoded as JSON dictionaries prior to deployment. For instance the composition in demo.js is encoded as:

{
    "type": "if",
    "test": {
        "type": "action",
        "name": "/_/authenticate",
        "action": {
            "exec": {
                "kind": "nodejs:default",
                "code": "const main = function ({ password }) { return { value: password === 'abc123' } }"
            }
        }
    },
    "consequent": {
        "type": "action",
        "name": "/_/success",
        "action": {
            "exec": {
                "kind": "nodejs:default",
                "code": "const main = function () { return { message: 'success' } }"
            }
        }
    },
    "alternate": {
        "type": "action",
        "name": "/_/failure",
        "action": {
            "exec": {
                "kind": "nodejs:default",
                "code": "const main = function () { return { message: 'failure' } }"
            }
        }
    }
}

This json dictionary has one mandatory field named type with the name of the combinator and possible other fields that depend on the specific combinator. The values of some of these fields may be themselves composition dictionaries. In this example, the test, consequent, and alternate fields are compositions of type action.

The field names and types typically match the combinator method signatures:

TypeFields
actionname:string, action:optional object
functionfunction:object
literal or valuevalue:json value
empty
sequence or seqcomponents:array of compositions
letdeclarations:object, components:array of compositions
maskcomponents:array of compositions
if and if_nosavetest:composition, consequent:composition, alternate:composition
while and while_nosavetest:composition, body:composition
dowhile and dowhile_nosavebody:composition, test:composition
repeatcount:number, components:array of compositions
trybody:composition, handler:composition
finallybody:composition, finalizer:composition
retrycount:number, components:array of compositions
retain and retain_catchcomponents:array of compositions
asyncbody:composition