Skip to content

Commit

Permalink
Expressions: Add types to run_pipeline. (elastic#32378)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeelmers committed Mar 4, 2019
1 parent aa008e7 commit 178671f
Showing 1 changed file with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,27 @@ import { fromExpression } from '@kbn/interpreter/common';
// @ts-ignore
import { getInterpreter } from 'plugins/interpreter/interpreter';

export const runPipeline = async (expression: string, context: any, handlers: any) => {
import { Adapters } from 'ui/inspector';
import { Filters, Query, TimeRange } from 'ui/visualize';

interface InitialContextObject {
timeRange?: TimeRange;
filters?: Filters;
query?: Query;
}

type getInitialContextFunction = () => InitialContextObject;

interface RunPipelineHandlers {
getInitialContext: getInitialContextFunction;
inspectorAdapters?: Adapters;
}

export const runPipeline = async (
expression: string,
context: object,
handlers: RunPipelineHandlers
) => {
const ast = fromExpression(expression);
const { interpreter } = await getInterpreter();
const pipelineResponse = await interpreter.interpretAst(ast, context, handlers);
Expand Down

0 comments on commit 178671f

Please sign in to comment.