Comcast / rulio

Rulio
Apache License 2.0
336 stars 59 forks source link

Want a Rule API action interpreter #17

Open jsccast opened 8 years ago

jsccast commented 8 years ago

Say an action mostly just wants to call a Rules API (like Env.AddRule). Writing a bunch of Javascript that mostly just offers an ugly, embedded JSON object and associated API call is distasteful. Instead, provide an action interpreter that can call the core APIs with an explicit JSON object representation that uses the (silly) notation "??..." to request a logic variable interpolation for bindings given to the action. Also support an optional code property with a Javascript value that can expand the action's bindings.

For example

{
    "when": {"at":"?there"},
    "action": {
        "language":"rulesapi",
        "code": {
            "code": "{'?id':'bart' + '_' + 'simpson'}",
            "addRule": {
                "pattern": {"wants":"?wanted","at":"??there"},
                "condition": {"has":"?wanted"},
                "action": "Env.http('GET', 'https://localhost:1234/' id + '/' + wanted)"
            }
        }
    }
}
boriwo commented 8 years ago

Sounds lovely!