Skip to content

Commit

Permalink
Expressions: Add types to run_pipeline. (#32378) (#32427)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeelmers authored Mar 4, 2019
1 parent ec5814b commit d0069e1
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 d0069e1

Please sign in to comment.