Skip to content

Latest commit

 

History

History
44 lines (27 loc) · 2.09 KB

evaluator.md

File metadata and controls

44 lines (27 loc) · 2.09 KB

Evaluator API Reference

This reference documents all methods available in the Evaluator API and explains in detail how these methods work.

Index

evaluate

This method evaluates an expression written in CQL.

Check out our quick start guide for an introduction to what is CQL and how it works.

ℹ️️ Note
We currently impose a hard limit of 300 characters on the length of expression. We plan to remove this limitation in the near future.

Signature

The evaluation method has the following signature:

croct.evaluator.evaluate(expression: string, options?: EvaluationOptions): Promise<JsonResult>

These are the currently supported options:

Option Type Description
timeout number The maximum evaluation time in milliseconds. Once reached, the evaluator will abort the evaluator and reject the promise with a timeout error.
attributes JSON This option represents a map of attributes to inject in the evaluation context. For example, passing the attributes {cities: ['New York', 'San Francisco']} you can reference them in expressions like context's cities include location's city.

The return is a Promise that resolves to the evaluation result.

Code Sample

Here's a minimal example showing how evaluate an expression:

croct.evaluator.evaluate('session is starting').then(console.log);