import { DimensionEncoding, ExpressionDSL } from './AST'; /** * First let's understand Encoding. It has a 'fields' object, and a 'context' object * Example: * { * context:{ * gradientContext:["red", "yellow", "green"] * * }, * * fields:{ * field1:{ * value:"selectByPosition(FIRST)|expects(NUMERIC)" * }, * field2:{ * value:"selectByPosition(SECOND)|expects(NUMERIC)", * meta:{ * color:gradient(gradientContext)|toRGB(), * smell: odor('delicious') * } * } * * } * * } * * So we have to fields named 'field1' and 'field2'. Their value is computed at runtime by executing * the DSL for value. A field can also have computed info. Computed fields are gotten by feeding the value, * at runtime, into the DSL expression for the computed field. For example, 'color' is obtained by * running the gradient function. The gradient function refers to gradientContext object. The gradient * function is also explicitly passed the value. * */ export interface Encoding { dimensions: { [key: string]: DimensionEncoding | ExpressionDSL; }; context: { [key: string]: Context; }; } export type Context = any;