rules-machine icon indicating copy to clipboard operation
rules-machine copied to clipboard

Design async data injection mechanism

Open justsml opened this issue 2 years ago • 1 comments

Sometimes business rules need access to external data (from a Database, HTTP API, AI/ML Service, etc.)

Goals

  • [ ] Support JSON config-style declaration.
  • [ ] Securely reference API keys.
  • [ ] Pluggable / layered design. (Similar to inputMap & outputMap designs.)
  • [ ] Rely on existing 'client' APIs. (fetch, pg, etc)

justsml avatar Jul 19 '22 21:07 justsml

Are you thinking something like this?

{
  map: '$IO::fetchItems()',
  run: { return: '$item.id' },
}

// fetchItems.config.json
{
  "url": "items.com/api?key=$ApiKey",
  "ApiKey": "SECURE_ENV_VAR",
  "method": "GET",
  "headers": [...],
  "dataPath": "body.data.items",
  "validator": "./validator.js"
}

chhatch avatar Oct 30 '22 13:10 chhatch