mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
cleaning up expression service types (#80643)
This commit is contained in:
parent
b04066bfdb
commit
48adb07411
58 changed files with 252 additions and 291 deletions
|
@ -9,12 +9,12 @@ Constructs a new instance of the `Execution` class
|
|||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
constructor(params: ExecutionParams<ExtraContext>);
|
||||
constructor(execution: ExecutionParams);
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| params | <code>ExecutionParams<ExtraContext></code> | |
|
||||
| execution | <code>ExecutionParams</code> | |
|
||||
|
||||
|
|
|
@ -9,5 +9,5 @@ Execution context - object that allows to do side-effects. Context is passed to
|
|||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
readonly context: ExecutionContext<Input, InspectorAdapters> & ExtraContext;
|
||||
readonly context: ExecutionContext<InspectorAdapters>;
|
||||
```
|
||||
|
|
|
@ -9,5 +9,5 @@ Contract is a public representation of `Execution` instances. Contract we can re
|
|||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
readonly contract: ExecutionContract<ExtraContext, Input, Output, InspectorAdapters>;
|
||||
readonly contract: ExecutionContract<Input, Output, InspectorAdapters>;
|
||||
```
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-plugins-expressions-public](./kibana-plugin-plugins-expressions-public.md) > [Execution](./kibana-plugin-plugins-expressions-public.execution.md) > [params](./kibana-plugin-plugins-expressions-public.execution.params.md)
|
||||
[Home](./index.md) > [kibana-plugin-plugins-expressions-public](./kibana-plugin-plugins-expressions-public.md) > [Execution](./kibana-plugin-plugins-expressions-public.execution.md) > [execution](./kibana-plugin-plugins-expressions-public.execution.execution.md)
|
||||
|
||||
## Execution.params property
|
||||
## Execution.execution property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
readonly params: ExecutionParams<ExtraContext>;
|
||||
readonly execution: ExecutionParams;
|
||||
```
|
|
@ -7,7 +7,7 @@
|
|||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
interpret<T>(ast: ExpressionAstNode, input: T, options?: ExpressionExecOptions): Promise<unknown>;
|
||||
interpret<T>(ast: ExpressionAstNode, input: T): Promise<unknown>;
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
@ -16,7 +16,6 @@ interpret<T>(ast: ExpressionAstNode, input: T, options?: ExpressionExecOptions):
|
|||
| --- | --- | --- |
|
||||
| ast | <code>ExpressionAstNode</code> | |
|
||||
| input | <code>T</code> | |
|
||||
| options | <code>ExpressionExecOptions</code> | |
|
||||
|
||||
<b>Returns:</b>
|
||||
|
||||
|
|
|
@ -7,25 +7,25 @@
|
|||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
export declare class Execution<ExtraContext extends Record<string, unknown> = Record<string, unknown>, Input = unknown, Output = unknown, InspectorAdapters extends Adapters = ExtraContext['inspectorAdapters'] extends object ? ExtraContext['inspectorAdapters'] : DefaultInspectorAdapters>
|
||||
export declare class Execution<Input = unknown, Output = unknown, InspectorAdapters extends Adapters = ExpressionExecutionParams['inspectorAdapters'] extends object ? ExpressionExecutionParams['inspectorAdapters'] : DefaultInspectorAdapters>
|
||||
```
|
||||
|
||||
## Constructors
|
||||
|
||||
| Constructor | Modifiers | Description |
|
||||
| --- | --- | --- |
|
||||
| [(constructor)(params)](./kibana-plugin-plugins-expressions-public.execution._constructor_.md) | | Constructs a new instance of the <code>Execution</code> class |
|
||||
| [(constructor)(execution)](./kibana-plugin-plugins-expressions-public.execution._constructor_.md) | | Constructs a new instance of the <code>Execution</code> class |
|
||||
|
||||
## Properties
|
||||
|
||||
| Property | Modifiers | Type | Description |
|
||||
| --- | --- | --- | --- |
|
||||
| [context](./kibana-plugin-plugins-expressions-public.execution.context.md) | | <code>ExecutionContext<Input, InspectorAdapters> & ExtraContext</code> | Execution context - object that allows to do side-effects. Context is passed to every function. |
|
||||
| [contract](./kibana-plugin-plugins-expressions-public.execution.contract.md) | | <code>ExecutionContract<ExtraContext, Input, Output, InspectorAdapters></code> | Contract is a public representation of <code>Execution</code> instances. Contract we can return to other plugins for their consumption. |
|
||||
| [context](./kibana-plugin-plugins-expressions-public.execution.context.md) | | <code>ExecutionContext<InspectorAdapters></code> | Execution context - object that allows to do side-effects. Context is passed to every function. |
|
||||
| [contract](./kibana-plugin-plugins-expressions-public.execution.contract.md) | | <code>ExecutionContract<Input, Output, InspectorAdapters></code> | Contract is a public representation of <code>Execution</code> instances. Contract we can return to other plugins for their consumption. |
|
||||
| [execution](./kibana-plugin-plugins-expressions-public.execution.execution.md) | | <code>ExecutionParams</code> | |
|
||||
| [expression](./kibana-plugin-plugins-expressions-public.execution.expression.md) | | <code>string</code> | |
|
||||
| [input](./kibana-plugin-plugins-expressions-public.execution.input.md) | | <code>Input</code> | Initial input of the execution.<!-- -->N.B. It is initialized to <code>null</code> rather than <code>undefined</code> for legacy reasons, because in legacy interpreter it was set to <code>null</code> by default. |
|
||||
| [inspectorAdapters](./kibana-plugin-plugins-expressions-public.execution.inspectoradapters.md) | | <code>InspectorAdapters</code> | |
|
||||
| [params](./kibana-plugin-plugins-expressions-public.execution.params.md) | | <code>ExecutionParams<ExtraContext></code> | |
|
||||
| [result](./kibana-plugin-plugins-expressions-public.execution.result.md) | | <code>Promise<Output | ExpressionValueError></code> | |
|
||||
| [state](./kibana-plugin-plugins-expressions-public.execution.state.md) | | <code>ExecutionContainer<Output | ExpressionValueError></code> | Dynamic state of the execution. |
|
||||
|
||||
|
@ -35,7 +35,7 @@ export declare class Execution<ExtraContext extends Record<string, unknown> = Re
|
|||
| --- | --- | --- |
|
||||
| [cancel()](./kibana-plugin-plugins-expressions-public.execution.cancel.md) | | Stop execution of expression. |
|
||||
| [cast(value, toTypeNames)](./kibana-plugin-plugins-expressions-public.execution.cast.md) | | |
|
||||
| [interpret(ast, input, options)](./kibana-plugin-plugins-expressions-public.execution.interpret.md) | | |
|
||||
| [interpret(ast, input)](./kibana-plugin-plugins-expressions-public.execution.interpret.md) | | |
|
||||
| [invokeChain(chainArr, input)](./kibana-plugin-plugins-expressions-public.execution.invokechain.md) | | |
|
||||
| [invokeFunction(fn, input, args)](./kibana-plugin-plugins-expressions-public.execution.invokefunction.md) | | |
|
||||
| [resolveArgs(fnDef, input, argAsts)](./kibana-plugin-plugins-expressions-public.execution.resolveargs.md) | | |
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-plugins-expressions-public](./kibana-plugin-plugins-expressions-public.md) > [ExecutionContext](./kibana-plugin-plugins-expressions-public.executioncontext.md) > [getInitialInput](./kibana-plugin-plugins-expressions-public.executioncontext.getinitialinput.md)
|
||||
[Home](./index.md) > [kibana-plugin-plugins-expressions-public](./kibana-plugin-plugins-expressions-public.md) > [ExecutionContext](./kibana-plugin-plugins-expressions-public.executioncontext.md) > [getSearchContext](./kibana-plugin-plugins-expressions-public.executioncontext.getsearchcontext.md)
|
||||
|
||||
## ExecutionContext.getInitialInput property
|
||||
## ExecutionContext.getSearchContext property
|
||||
|
||||
Get initial input with which execution started.
|
||||
Get search context of the expression.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
getInitialInput: () => Input;
|
||||
getSearchContext: () => ExecutionContextSearch;
|
||||
```
|
|
@ -1,13 +1,13 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-plugins-expressions-public](./kibana-plugin-plugins-expressions-public.md) > [ExecutionContext](./kibana-plugin-plugins-expressions-public.executioncontext.md) > [search](./kibana-plugin-plugins-expressions-public.executioncontext.search.md)
|
||||
[Home](./index.md) > [kibana-plugin-plugins-expressions-public](./kibana-plugin-plugins-expressions-public.md) > [ExecutionContext](./kibana-plugin-plugins-expressions-public.executioncontext.md) > [getSearchSessionId](./kibana-plugin-plugins-expressions-public.executioncontext.getsearchsessionid.md)
|
||||
|
||||
## ExecutionContext.search property
|
||||
## ExecutionContext.getSearchSessionId property
|
||||
|
||||
Search context in which expression should operate.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
search?: ExecutionContextSearch;
|
||||
getSearchSessionId: () => string | undefined;
|
||||
```
|
|
@ -9,7 +9,7 @@
|
|||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
export interface ExecutionContext<Input = unknown, InspectorAdapters extends Adapters = Adapters>
|
||||
export interface ExecutionContext<InspectorAdapters extends Adapters = Adapters>
|
||||
```
|
||||
|
||||
## Properties
|
||||
|
@ -17,10 +17,10 @@ export interface ExecutionContext<Input = unknown, InspectorAdapters extends Ada
|
|||
| Property | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| [abortSignal](./kibana-plugin-plugins-expressions-public.executioncontext.abortsignal.md) | <code>AbortSignal</code> | Adds ability to abort current execution. |
|
||||
| [getInitialInput](./kibana-plugin-plugins-expressions-public.executioncontext.getinitialinput.md) | <code>() => Input</code> | Get initial input with which execution started. |
|
||||
| [getSavedObject](./kibana-plugin-plugins-expressions-public.executioncontext.getsavedobject.md) | <code><T extends SavedObjectAttributes = SavedObjectAttributes>(type: string, id: string) => Promise<SavedObject<T>></code> | Allows to fetch saved objects from ElasticSearch. In browser <code>getSavedObject</code> function is provided automatically by the Expressions plugin. On the server the caller of the expression has to provide this context function. The reason is because on the browser we always know the user who tries to fetch a saved object, thus saved object client is scoped automatically to that user. However, on the server we can scope that saved object client to any user, or even not scope it at all and execute it as an "internal" user. |
|
||||
| [getSearchContext](./kibana-plugin-plugins-expressions-public.executioncontext.getsearchcontext.md) | <code>() => ExecutionContextSearch</code> | Get search context of the expression. |
|
||||
| [getSearchSessionId](./kibana-plugin-plugins-expressions-public.executioncontext.getsearchsessionid.md) | <code>() => string | undefined</code> | Search context in which expression should operate. |
|
||||
| [inspectorAdapters](./kibana-plugin-plugins-expressions-public.executioncontext.inspectoradapters.md) | <code>InspectorAdapters</code> | Adapters for <code>inspector</code> plugin. |
|
||||
| [search](./kibana-plugin-plugins-expressions-public.executioncontext.search.md) | <code>ExecutionContextSearch</code> | Search context in which expression should operate. |
|
||||
| [types](./kibana-plugin-plugins-expressions-public.executioncontext.types.md) | <code>Record<string, ExpressionType></code> | A map of available expression types. |
|
||||
| [variables](./kibana-plugin-plugins-expressions-public.executioncontext.variables.md) | <code>Record<string, unknown></code> | Context variables that can be consumed using <code>var</code> and <code>var_set</code> functions. |
|
||||
|
||||
|
|
|
@ -9,12 +9,12 @@ Constructs a new instance of the `ExecutionContract` class
|
|||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
constructor(execution: Execution<ExtraContext, Input, Output, InspectorAdapters>);
|
||||
constructor(execution: Execution<Input, Output, InspectorAdapters>);
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| execution | <code>Execution<ExtraContext, Input, Output, InspectorAdapters></code> | |
|
||||
| execution | <code>Execution<Input, Output, InspectorAdapters></code> | |
|
||||
|
||||
|
|
|
@ -7,5 +7,5 @@
|
|||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
protected readonly execution: Execution<ExtraContext, Input, Output, InspectorAdapters>;
|
||||
protected readonly execution: Execution<Input, Output, InspectorAdapters>;
|
||||
```
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
export declare class ExecutionContract<ExtraContext extends Record<string, unknown> = Record<string, unknown>, Input = unknown, Output = unknown, InspectorAdapters = unknown>
|
||||
export declare class ExecutionContract<Input = unknown, Output = unknown, InspectorAdapters = unknown>
|
||||
```
|
||||
|
||||
## Constructors
|
||||
|
@ -23,7 +23,7 @@ export declare class ExecutionContract<ExtraContext extends Record<string, unkno
|
|||
| Property | Modifiers | Type | Description |
|
||||
| --- | --- | --- | --- |
|
||||
| [cancel](./kibana-plugin-plugins-expressions-public.executioncontract.cancel.md) | | <code>() => void</code> | Cancel the execution of the expression. This will set abort signal (available in execution context) to aborted state, letting expression functions to stop their execution. |
|
||||
| [execution](./kibana-plugin-plugins-expressions-public.executioncontract.execution.md) | | <code>Execution<ExtraContext, Input, Output, InspectorAdapters></code> | |
|
||||
| [execution](./kibana-plugin-plugins-expressions-public.executioncontract.execution.md) | | <code>Execution<Input, Output, InspectorAdapters></code> | |
|
||||
| [getAst](./kibana-plugin-plugins-expressions-public.executioncontract.getast.md) | | <code>() => ExpressionAstExpression</code> | Get AST used to execute the expression. |
|
||||
| [getData](./kibana-plugin-plugins-expressions-public.executioncontract.getdata.md) | | <code>() => Promise<Output | ExpressionValueError></code> | Returns the final output of expression, if any error happens still wraps that error into <code>ExpressionValueError</code> type and returns that. This function never throws. |
|
||||
| [getExpression](./kibana-plugin-plugins-expressions-public.executioncontract.getexpression.md) | | <code>() => string</code> | Get string representation of the expression. Returns the original string if execution was started from a string. If execution was started from an AST this method returns a string generated from AST. |
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-plugins-expressions-public](./kibana-plugin-plugins-expressions-public.md) > [ExecutionParams](./kibana-plugin-plugins-expressions-public.executionparams.md) > [debug](./kibana-plugin-plugins-expressions-public.executionparams.debug.md)
|
||||
|
||||
## ExecutionParams.debug property
|
||||
|
||||
Whether to execute expression in \*debug mode\*. In \*debug mode\* inputs and outputs as well as all resolved arguments and time it took to execute each function are saved and are available for introspection.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
debug?: boolean;
|
||||
```
|
|
@ -7,7 +7,7 @@
|
|||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
export interface ExecutionParams<ExtraContext extends Record<string, unknown> = Record<string, unknown>>
|
||||
export interface ExecutionParams
|
||||
```
|
||||
|
||||
## Properties
|
||||
|
@ -15,8 +15,7 @@ export interface ExecutionParams<ExtraContext extends Record<string, unknown> =
|
|||
| Property | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| [ast](./kibana-plugin-plugins-expressions-public.executionparams.ast.md) | <code>ExpressionAstExpression</code> | |
|
||||
| [context](./kibana-plugin-plugins-expressions-public.executionparams.context.md) | <code>ExtraContext</code> | |
|
||||
| [debug](./kibana-plugin-plugins-expressions-public.executionparams.debug.md) | <code>boolean</code> | Whether to execute expression in \*debug mode\*. In \*debug mode\* inputs and outputs as well as all resolved arguments and time it took to execute each function are saved and are available for introspection. |
|
||||
| [executor](./kibana-plugin-plugins-expressions-public.executionparams.executor.md) | <code>Executor<any></code> | |
|
||||
| [expression](./kibana-plugin-plugins-expressions-public.executionparams.expression.md) | <code>string</code> | |
|
||||
| [params](./kibana-plugin-plugins-expressions-public.executionparams.params.md) | <code>ExpressionExecutionParams</code> | |
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-plugins-expressions-public](./kibana-plugin-plugins-expressions-public.md) > [ExecutionParams](./kibana-plugin-plugins-expressions-public.executionparams.md) > [context](./kibana-plugin-plugins-expressions-public.executionparams.context.md)
|
||||
[Home](./index.md) > [kibana-plugin-plugins-expressions-public](./kibana-plugin-plugins-expressions-public.md) > [ExecutionParams](./kibana-plugin-plugins-expressions-public.executionparams.md) > [params](./kibana-plugin-plugins-expressions-public.executionparams.params.md)
|
||||
|
||||
## ExecutionParams.context property
|
||||
## ExecutionParams.params property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
context?: ExtraContext;
|
||||
params: ExpressionExecutionParams;
|
||||
```
|
|
@ -7,7 +7,7 @@
|
|||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
createExecution<ExtraContext extends Record<string, unknown> = Record<string, unknown>, Input = unknown, Output = unknown>(ast: string | ExpressionAstExpression, context?: ExtraContext, { debug }?: ExpressionExecOptions): Execution<Context & ExtraContext, Input, Output>;
|
||||
createExecution<Input = unknown, Output = unknown>(ast: string | ExpressionAstExpression, params?: ExpressionExecutionParams): Execution<Input, Output>;
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
@ -15,10 +15,9 @@ createExecution<ExtraContext extends Record<string, unknown> = Record<string, un
|
|||
| Parameter | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| ast | <code>string | ExpressionAstExpression</code> | |
|
||||
| context | <code>ExtraContext</code> | |
|
||||
| { debug } | <code>ExpressionExecOptions</code> | |
|
||||
| params | <code>ExpressionExecutionParams</code> | |
|
||||
|
||||
<b>Returns:</b>
|
||||
|
||||
`Execution<Context & ExtraContext, Input, Output>`
|
||||
`Execution<Input, Output>`
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ export declare class Executor<Context extends Record<string, unknown> = Record<s
|
|||
|
||||
| Method | Modifiers | Description |
|
||||
| --- | --- | --- |
|
||||
| [createExecution(ast, context, { debug })](./kibana-plugin-plugins-expressions-public.executor.createexecution.md) | | |
|
||||
| [createExecution(ast, params)](./kibana-plugin-plugins-expressions-public.executor.createexecution.md) | | |
|
||||
| [createWithDefaults(state)](./kibana-plugin-plugins-expressions-public.executor.createwithdefaults.md) | <code>static</code> | |
|
||||
| [extendContext(extraContext)](./kibana-plugin-plugins-expressions-public.executor.extendcontext.md) | | |
|
||||
| [extract(ast)](./kibana-plugin-plugins-expressions-public.executor.extract.md) | | |
|
||||
|
@ -41,6 +41,6 @@ export declare class Executor<Context extends Record<string, unknown> = Record<s
|
|||
| [inject(ast, references)](./kibana-plugin-plugins-expressions-public.executor.inject.md) | | |
|
||||
| [registerFunction(functionDefinition)](./kibana-plugin-plugins-expressions-public.executor.registerfunction.md) | | |
|
||||
| [registerType(typeDefinition)](./kibana-plugin-plugins-expressions-public.executor.registertype.md) | | |
|
||||
| [run(ast, input, context, options)](./kibana-plugin-plugins-expressions-public.executor.run.md) | | Execute expression and return result. |
|
||||
| [run(ast, input, params)](./kibana-plugin-plugins-expressions-public.executor.run.md) | | Execute expression and return result. |
|
||||
| [telemetry(ast, telemetryData)](./kibana-plugin-plugins-expressions-public.executor.telemetry.md) | | |
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ Execute expression and return result.
|
|||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
run<Input, Output, ExtraContext extends Record<string, unknown> = Record<string, unknown>>(ast: string | ExpressionAstExpression, input: Input, context?: ExtraContext, options?: ExpressionExecOptions): Promise<Output>;
|
||||
run<Input, Output>(ast: string | ExpressionAstExpression, input: Input, params?: ExpressionExecutionParams): Promise<Output>;
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
@ -18,8 +18,7 @@ run<Input, Output, ExtraContext extends Record<string, unknown> = Record<string,
|
|||
| --- | --- | --- |
|
||||
| ast | <code>string | ExpressionAstExpression</code> | |
|
||||
| input | <code>Input</code> | |
|
||||
| context | <code>ExtraContext</code> | |
|
||||
| options | <code>ExpressionExecOptions</code> | |
|
||||
| params | <code>ExpressionExecutionParams</code> | |
|
||||
|
||||
<b>Returns:</b>
|
||||
|
||||
|
|
|
@ -9,5 +9,5 @@ Starts expression execution and immediately returns `ExecutionContract` instance
|
|||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
execute: <Input = unknown, Output = unknown, ExtraContext extends Record<string, unknown> = Record<string, unknown>>(ast: string | ExpressionAstExpression, input: Input, context?: ExtraContext, options?: ExpressionExecOptions) => ExecutionContract<ExtraContext, Input, Output>;
|
||||
execute: <Input = unknown, Output = unknown>(ast: string | ExpressionAstExpression, input: Input, params?: ExpressionExecutionParams) => ExecutionContract<Input, Output>;
|
||||
```
|
||||
|
|
|
@ -16,12 +16,12 @@ export interface ExpressionsServiceStart
|
|||
|
||||
| Property | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| [execute](./kibana-plugin-plugins-expressions-public.expressionsservicestart.execute.md) | <code><Input = unknown, Output = unknown, ExtraContext extends Record<string, unknown> = Record<string, unknown>>(ast: string | ExpressionAstExpression, input: Input, context?: ExtraContext, options?: ExpressionExecOptions) => ExecutionContract<ExtraContext, Input, Output></code> | Starts expression execution and immediately returns <code>ExecutionContract</code> instance that tracks the progress of the execution and can be used to interact with the execution. |
|
||||
| [execute](./kibana-plugin-plugins-expressions-public.expressionsservicestart.execute.md) | <code><Input = unknown, Output = unknown>(ast: string | ExpressionAstExpression, input: Input, params?: ExpressionExecutionParams) => ExecutionContract<Input, Output></code> | Starts expression execution and immediately returns <code>ExecutionContract</code> instance that tracks the progress of the execution and can be used to interact with the execution. |
|
||||
| [fork](./kibana-plugin-plugins-expressions-public.expressionsservicestart.fork.md) | <code>() => ExpressionsService</code> | Create a new instance of <code>ExpressionsService</code>. The new instance inherits all state of the original <code>ExpressionsService</code>, including all expression types, expression functions and context. Also, all new types and functions registered in the original services AFTER the forking event will be available in the forked instance. However, all new types and functions registered in the forked instances will NOT be available to the original service. |
|
||||
| [getFunction](./kibana-plugin-plugins-expressions-public.expressionsservicestart.getfunction.md) | <code>(name: string) => ReturnType<Executor['getFunction']></code> | Get a registered <code>ExpressionFunction</code> by its name, which was registered using the <code>registerFunction</code> method. The returned <code>ExpressionFunction</code> instance is an internal representation of the function in Expressions service - do not mutate that object. |
|
||||
| [getRenderer](./kibana-plugin-plugins-expressions-public.expressionsservicestart.getrenderer.md) | <code>(name: string) => ReturnType<ExpressionRendererRegistry['get']></code> | Get a registered <code>ExpressionRenderer</code> by its name, which was registered using the <code>registerRenderer</code> method. The returned <code>ExpressionRenderer</code> instance is an internal representation of the renderer in Expressions service - do not mutate that object. |
|
||||
| [getType](./kibana-plugin-plugins-expressions-public.expressionsservicestart.gettype.md) | <code>(name: string) => ReturnType<Executor['getType']></code> | Get a registered <code>ExpressionType</code> by its name, which was registered using the <code>registerType</code> method. The returned <code>ExpressionType</code> instance is an internal representation of the type in Expressions service - do not mutate that object. |
|
||||
| [run](./kibana-plugin-plugins-expressions-public.expressionsservicestart.run.md) | <code><Input, Output, ExtraContext extends Record<string, unknown> = Record<string, unknown>>(ast: string | ExpressionAstExpression, input: Input, context?: ExtraContext, options?: ExpressionExecOptions) => Promise<Output></code> | Executes expression string or a parsed expression AST and immediately returns the result.<!-- -->Below example will execute <code>sleep 100 | clog</code> expression with <code>123</code> initial input to the first function.
|
||||
| [run](./kibana-plugin-plugins-expressions-public.expressionsservicestart.run.md) | <code><Input, Output>(ast: string | ExpressionAstExpression, input: Input, params?: ExpressionExecutionParams) => Promise<Output></code> | Executes expression string or a parsed expression AST and immediately returns the result.<!-- -->Below example will execute <code>sleep 100 | clog</code> expression with <code>123</code> initial input to the first function.
|
||||
```ts
|
||||
expressions.run('sleep 100 | clog', 123);
|
||||
|
||||
|
|
|
@ -24,5 +24,5 @@ expressions.run('...', null, { elasticsearchClient });
|
|||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
run: <Input, Output, ExtraContext extends Record<string, unknown> = Record<string, unknown>>(ast: string | ExpressionAstExpression, input: Input, context?: ExtraContext, options?: ExpressionExecOptions) => Promise<Output>;
|
||||
run: <Input, Output>(ast: string | ExpressionAstExpression, input: Input, params?: ExpressionExecutionParams) => Promise<Output>;
|
||||
```
|
||||
|
|
|
@ -22,6 +22,7 @@ export interface IExpressionLoaderParams
|
|||
| [inspectorAdapters](./kibana-plugin-plugins-expressions-public.iexpressionloaderparams.inspectoradapters.md) | <code>Adapters</code> | |
|
||||
| [onRenderError](./kibana-plugin-plugins-expressions-public.iexpressionloaderparams.onrendererror.md) | <code>RenderErrorHandlerFnType</code> | |
|
||||
| [searchContext](./kibana-plugin-plugins-expressions-public.iexpressionloaderparams.searchcontext.md) | <code>ExecutionContextSearch</code> | |
|
||||
| [searchSessionId](./kibana-plugin-plugins-expressions-public.iexpressionloaderparams.searchsessionid.md) | <code>string</code> | |
|
||||
| [uiState](./kibana-plugin-plugins-expressions-public.iexpressionloaderparams.uistate.md) | <code>unknown</code> | |
|
||||
| [variables](./kibana-plugin-plugins-expressions-public.iexpressionloaderparams.variables.md) | <code>Record<string, any></code> | |
|
||||
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-plugins-expressions-public](./kibana-plugin-plugins-expressions-public.md) > [IExpressionLoaderParams](./kibana-plugin-plugins-expressions-public.iexpressionloaderparams.md) > [searchSessionId](./kibana-plugin-plugins-expressions-public.iexpressionloaderparams.searchsessionid.md)
|
||||
|
||||
## IExpressionLoaderParams.searchSessionId property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
searchSessionId?: string;
|
||||
```
|
|
@ -9,12 +9,12 @@ Constructs a new instance of the `Execution` class
|
|||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
constructor(params: ExecutionParams<ExtraContext>);
|
||||
constructor(execution: ExecutionParams);
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| params | <code>ExecutionParams<ExtraContext></code> | |
|
||||
| execution | <code>ExecutionParams</code> | |
|
||||
|
||||
|
|
|
@ -9,5 +9,5 @@ Execution context - object that allows to do side-effects. Context is passed to
|
|||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
readonly context: ExecutionContext<Input, InspectorAdapters> & ExtraContext;
|
||||
readonly context: ExecutionContext<InspectorAdapters>;
|
||||
```
|
||||
|
|
|
@ -9,5 +9,5 @@ Contract is a public representation of `Execution` instances. Contract we can re
|
|||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
readonly contract: ExecutionContract<ExtraContext, Input, Output, InspectorAdapters>;
|
||||
readonly contract: ExecutionContract<Input, Output, InspectorAdapters>;
|
||||
```
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-plugins-expressions-server](./kibana-plugin-plugins-expressions-server.md) > [Execution](./kibana-plugin-plugins-expressions-server.execution.md) > [params](./kibana-plugin-plugins-expressions-server.execution.params.md)
|
||||
[Home](./index.md) > [kibana-plugin-plugins-expressions-server](./kibana-plugin-plugins-expressions-server.md) > [Execution](./kibana-plugin-plugins-expressions-server.execution.md) > [execution](./kibana-plugin-plugins-expressions-server.execution.execution.md)
|
||||
|
||||
## Execution.params property
|
||||
## Execution.execution property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
readonly params: ExecutionParams<ExtraContext>;
|
||||
readonly execution: ExecutionParams;
|
||||
```
|
|
@ -7,7 +7,7 @@
|
|||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
interpret<T>(ast: ExpressionAstNode, input: T, options?: ExpressionExecOptions): Promise<unknown>;
|
||||
interpret<T>(ast: ExpressionAstNode, input: T): Promise<unknown>;
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
@ -16,7 +16,6 @@ interpret<T>(ast: ExpressionAstNode, input: T, options?: ExpressionExecOptions):
|
|||
| --- | --- | --- |
|
||||
| ast | <code>ExpressionAstNode</code> | |
|
||||
| input | <code>T</code> | |
|
||||
| options | <code>ExpressionExecOptions</code> | |
|
||||
|
||||
<b>Returns:</b>
|
||||
|
||||
|
|
|
@ -7,25 +7,25 @@
|
|||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
export declare class Execution<ExtraContext extends Record<string, unknown> = Record<string, unknown>, Input = unknown, Output = unknown, InspectorAdapters extends Adapters = ExtraContext['inspectorAdapters'] extends object ? ExtraContext['inspectorAdapters'] : DefaultInspectorAdapters>
|
||||
export declare class Execution<Input = unknown, Output = unknown, InspectorAdapters extends Adapters = ExpressionExecutionParams['inspectorAdapters'] extends object ? ExpressionExecutionParams['inspectorAdapters'] : DefaultInspectorAdapters>
|
||||
```
|
||||
|
||||
## Constructors
|
||||
|
||||
| Constructor | Modifiers | Description |
|
||||
| --- | --- | --- |
|
||||
| [(constructor)(params)](./kibana-plugin-plugins-expressions-server.execution._constructor_.md) | | Constructs a new instance of the <code>Execution</code> class |
|
||||
| [(constructor)(execution)](./kibana-plugin-plugins-expressions-server.execution._constructor_.md) | | Constructs a new instance of the <code>Execution</code> class |
|
||||
|
||||
## Properties
|
||||
|
||||
| Property | Modifiers | Type | Description |
|
||||
| --- | --- | --- | --- |
|
||||
| [context](./kibana-plugin-plugins-expressions-server.execution.context.md) | | <code>ExecutionContext<Input, InspectorAdapters> & ExtraContext</code> | Execution context - object that allows to do side-effects. Context is passed to every function. |
|
||||
| [contract](./kibana-plugin-plugins-expressions-server.execution.contract.md) | | <code>ExecutionContract<ExtraContext, Input, Output, InspectorAdapters></code> | Contract is a public representation of <code>Execution</code> instances. Contract we can return to other plugins for their consumption. |
|
||||
| [context](./kibana-plugin-plugins-expressions-server.execution.context.md) | | <code>ExecutionContext<InspectorAdapters></code> | Execution context - object that allows to do side-effects. Context is passed to every function. |
|
||||
| [contract](./kibana-plugin-plugins-expressions-server.execution.contract.md) | | <code>ExecutionContract<Input, Output, InspectorAdapters></code> | Contract is a public representation of <code>Execution</code> instances. Contract we can return to other plugins for their consumption. |
|
||||
| [execution](./kibana-plugin-plugins-expressions-server.execution.execution.md) | | <code>ExecutionParams</code> | |
|
||||
| [expression](./kibana-plugin-plugins-expressions-server.execution.expression.md) | | <code>string</code> | |
|
||||
| [input](./kibana-plugin-plugins-expressions-server.execution.input.md) | | <code>Input</code> | Initial input of the execution.<!-- -->N.B. It is initialized to <code>null</code> rather than <code>undefined</code> for legacy reasons, because in legacy interpreter it was set to <code>null</code> by default. |
|
||||
| [inspectorAdapters](./kibana-plugin-plugins-expressions-server.execution.inspectoradapters.md) | | <code>InspectorAdapters</code> | |
|
||||
| [params](./kibana-plugin-plugins-expressions-server.execution.params.md) | | <code>ExecutionParams<ExtraContext></code> | |
|
||||
| [result](./kibana-plugin-plugins-expressions-server.execution.result.md) | | <code>Promise<Output | ExpressionValueError></code> | |
|
||||
| [state](./kibana-plugin-plugins-expressions-server.execution.state.md) | | <code>ExecutionContainer<Output | ExpressionValueError></code> | Dynamic state of the execution. |
|
||||
|
||||
|
@ -35,7 +35,7 @@ export declare class Execution<ExtraContext extends Record<string, unknown> = Re
|
|||
| --- | --- | --- |
|
||||
| [cancel()](./kibana-plugin-plugins-expressions-server.execution.cancel.md) | | Stop execution of expression. |
|
||||
| [cast(value, toTypeNames)](./kibana-plugin-plugins-expressions-server.execution.cast.md) | | |
|
||||
| [interpret(ast, input, options)](./kibana-plugin-plugins-expressions-server.execution.interpret.md) | | |
|
||||
| [interpret(ast, input)](./kibana-plugin-plugins-expressions-server.execution.interpret.md) | | |
|
||||
| [invokeChain(chainArr, input)](./kibana-plugin-plugins-expressions-server.execution.invokechain.md) | | |
|
||||
| [invokeFunction(fn, input, args)](./kibana-plugin-plugins-expressions-server.execution.invokefunction.md) | | |
|
||||
| [resolveArgs(fnDef, input, argAsts)](./kibana-plugin-plugins-expressions-server.execution.resolveargs.md) | | |
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-plugins-expressions-server](./kibana-plugin-plugins-expressions-server.md) > [ExecutionContext](./kibana-plugin-plugins-expressions-server.executioncontext.md) > [getInitialInput](./kibana-plugin-plugins-expressions-server.executioncontext.getinitialinput.md)
|
||||
[Home](./index.md) > [kibana-plugin-plugins-expressions-server](./kibana-plugin-plugins-expressions-server.md) > [ExecutionContext](./kibana-plugin-plugins-expressions-server.executioncontext.md) > [getSearchContext](./kibana-plugin-plugins-expressions-server.executioncontext.getsearchcontext.md)
|
||||
|
||||
## ExecutionContext.getInitialInput property
|
||||
## ExecutionContext.getSearchContext property
|
||||
|
||||
Get initial input with which execution started.
|
||||
Get search context of the expression.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
getInitialInput: () => Input;
|
||||
getSearchContext: () => ExecutionContextSearch;
|
||||
```
|
|
@ -1,13 +1,13 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-plugins-expressions-server](./kibana-plugin-plugins-expressions-server.md) > [ExecutionContext](./kibana-plugin-plugins-expressions-server.executioncontext.md) > [search](./kibana-plugin-plugins-expressions-server.executioncontext.search.md)
|
||||
[Home](./index.md) > [kibana-plugin-plugins-expressions-server](./kibana-plugin-plugins-expressions-server.md) > [ExecutionContext](./kibana-plugin-plugins-expressions-server.executioncontext.md) > [getSearchSessionId](./kibana-plugin-plugins-expressions-server.executioncontext.getsearchsessionid.md)
|
||||
|
||||
## ExecutionContext.search property
|
||||
## ExecutionContext.getSearchSessionId property
|
||||
|
||||
Search context in which expression should operate.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
search?: ExecutionContextSearch;
|
||||
getSearchSessionId: () => string | undefined;
|
||||
```
|
|
@ -9,7 +9,7 @@
|
|||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
export interface ExecutionContext<Input = unknown, InspectorAdapters extends Adapters = Adapters>
|
||||
export interface ExecutionContext<InspectorAdapters extends Adapters = Adapters>
|
||||
```
|
||||
|
||||
## Properties
|
||||
|
@ -17,10 +17,10 @@ export interface ExecutionContext<Input = unknown, InspectorAdapters extends Ada
|
|||
| Property | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| [abortSignal](./kibana-plugin-plugins-expressions-server.executioncontext.abortsignal.md) | <code>AbortSignal</code> | Adds ability to abort current execution. |
|
||||
| [getInitialInput](./kibana-plugin-plugins-expressions-server.executioncontext.getinitialinput.md) | <code>() => Input</code> | Get initial input with which execution started. |
|
||||
| [getSavedObject](./kibana-plugin-plugins-expressions-server.executioncontext.getsavedobject.md) | <code><T extends SavedObjectAttributes = SavedObjectAttributes>(type: string, id: string) => Promise<SavedObject<T>></code> | Allows to fetch saved objects from ElasticSearch. In browser <code>getSavedObject</code> function is provided automatically by the Expressions plugin. On the server the caller of the expression has to provide this context function. The reason is because on the browser we always know the user who tries to fetch a saved object, thus saved object client is scoped automatically to that user. However, on the server we can scope that saved object client to any user, or even not scope it at all and execute it as an "internal" user. |
|
||||
| [getSearchContext](./kibana-plugin-plugins-expressions-server.executioncontext.getsearchcontext.md) | <code>() => ExecutionContextSearch</code> | Get search context of the expression. |
|
||||
| [getSearchSessionId](./kibana-plugin-plugins-expressions-server.executioncontext.getsearchsessionid.md) | <code>() => string | undefined</code> | Search context in which expression should operate. |
|
||||
| [inspectorAdapters](./kibana-plugin-plugins-expressions-server.executioncontext.inspectoradapters.md) | <code>InspectorAdapters</code> | Adapters for <code>inspector</code> plugin. |
|
||||
| [search](./kibana-plugin-plugins-expressions-server.executioncontext.search.md) | <code>ExecutionContextSearch</code> | Search context in which expression should operate. |
|
||||
| [types](./kibana-plugin-plugins-expressions-server.executioncontext.types.md) | <code>Record<string, ExpressionType></code> | A map of available expression types. |
|
||||
| [variables](./kibana-plugin-plugins-expressions-server.executioncontext.variables.md) | <code>Record<string, unknown></code> | Context variables that can be consumed using <code>var</code> and <code>var_set</code> functions. |
|
||||
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-plugins-expressions-server](./kibana-plugin-plugins-expressions-server.md) > [ExecutionParams](./kibana-plugin-plugins-expressions-server.executionparams.md) > [debug](./kibana-plugin-plugins-expressions-server.executionparams.debug.md)
|
||||
|
||||
## ExecutionParams.debug property
|
||||
|
||||
Whether to execute expression in \*debug mode\*. In \*debug mode\* inputs and outputs as well as all resolved arguments and time it took to execute each function are saved and are available for introspection.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
debug?: boolean;
|
||||
```
|
|
@ -7,7 +7,7 @@
|
|||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
export interface ExecutionParams<ExtraContext extends Record<string, unknown> = Record<string, unknown>>
|
||||
export interface ExecutionParams
|
||||
```
|
||||
|
||||
## Properties
|
||||
|
@ -15,8 +15,7 @@ export interface ExecutionParams<ExtraContext extends Record<string, unknown> =
|
|||
| Property | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| [ast](./kibana-plugin-plugins-expressions-server.executionparams.ast.md) | <code>ExpressionAstExpression</code> | |
|
||||
| [context](./kibana-plugin-plugins-expressions-server.executionparams.context.md) | <code>ExtraContext</code> | |
|
||||
| [debug](./kibana-plugin-plugins-expressions-server.executionparams.debug.md) | <code>boolean</code> | Whether to execute expression in \*debug mode\*. In \*debug mode\* inputs and outputs as well as all resolved arguments and time it took to execute each function are saved and are available for introspection. |
|
||||
| [executor](./kibana-plugin-plugins-expressions-server.executionparams.executor.md) | <code>Executor<any></code> | |
|
||||
| [expression](./kibana-plugin-plugins-expressions-server.executionparams.expression.md) | <code>string</code> | |
|
||||
| [params](./kibana-plugin-plugins-expressions-server.executionparams.params.md) | <code>ExpressionExecutionParams</code> | |
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-plugins-expressions-server](./kibana-plugin-plugins-expressions-server.md) > [ExecutionParams](./kibana-plugin-plugins-expressions-server.executionparams.md) > [context](./kibana-plugin-plugins-expressions-server.executionparams.context.md)
|
||||
[Home](./index.md) > [kibana-plugin-plugins-expressions-server](./kibana-plugin-plugins-expressions-server.md) > [ExecutionParams](./kibana-plugin-plugins-expressions-server.executionparams.md) > [params](./kibana-plugin-plugins-expressions-server.executionparams.params.md)
|
||||
|
||||
## ExecutionParams.context property
|
||||
## ExecutionParams.params property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
context?: ExtraContext;
|
||||
params: ExpressionExecutionParams;
|
||||
```
|
|
@ -7,7 +7,7 @@
|
|||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
createExecution<ExtraContext extends Record<string, unknown> = Record<string, unknown>, Input = unknown, Output = unknown>(ast: string | ExpressionAstExpression, context?: ExtraContext, { debug }?: ExpressionExecOptions): Execution<Context & ExtraContext, Input, Output>;
|
||||
createExecution<Input = unknown, Output = unknown>(ast: string | ExpressionAstExpression, params?: ExpressionExecutionParams): Execution<Input, Output>;
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
@ -15,10 +15,9 @@ createExecution<ExtraContext extends Record<string, unknown> = Record<string, un
|
|||
| Parameter | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| ast | <code>string | ExpressionAstExpression</code> | |
|
||||
| context | <code>ExtraContext</code> | |
|
||||
| { debug } | <code>ExpressionExecOptions</code> | |
|
||||
| params | <code>ExpressionExecutionParams</code> | |
|
||||
|
||||
<b>Returns:</b>
|
||||
|
||||
`Execution<Context & ExtraContext, Input, Output>`
|
||||
`Execution<Input, Output>`
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ export declare class Executor<Context extends Record<string, unknown> = Record<s
|
|||
|
||||
| Method | Modifiers | Description |
|
||||
| --- | --- | --- |
|
||||
| [createExecution(ast, context, { debug })](./kibana-plugin-plugins-expressions-server.executor.createexecution.md) | | |
|
||||
| [createExecution(ast, params)](./kibana-plugin-plugins-expressions-server.executor.createexecution.md) | | |
|
||||
| [createWithDefaults(state)](./kibana-plugin-plugins-expressions-server.executor.createwithdefaults.md) | <code>static</code> | |
|
||||
| [extendContext(extraContext)](./kibana-plugin-plugins-expressions-server.executor.extendcontext.md) | | |
|
||||
| [extract(ast)](./kibana-plugin-plugins-expressions-server.executor.extract.md) | | |
|
||||
|
@ -41,6 +41,6 @@ export declare class Executor<Context extends Record<string, unknown> = Record<s
|
|||
| [inject(ast, references)](./kibana-plugin-plugins-expressions-server.executor.inject.md) | | |
|
||||
| [registerFunction(functionDefinition)](./kibana-plugin-plugins-expressions-server.executor.registerfunction.md) | | |
|
||||
| [registerType(typeDefinition)](./kibana-plugin-plugins-expressions-server.executor.registertype.md) | | |
|
||||
| [run(ast, input, context, options)](./kibana-plugin-plugins-expressions-server.executor.run.md) | | Execute expression and return result. |
|
||||
| [run(ast, input, params)](./kibana-plugin-plugins-expressions-server.executor.run.md) | | Execute expression and return result. |
|
||||
| [telemetry(ast, telemetryData)](./kibana-plugin-plugins-expressions-server.executor.telemetry.md) | | |
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ Execute expression and return result.
|
|||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
run<Input, Output, ExtraContext extends Record<string, unknown> = Record<string, unknown>>(ast: string | ExpressionAstExpression, input: Input, context?: ExtraContext, options?: ExpressionExecOptions): Promise<Output>;
|
||||
run<Input, Output>(ast: string | ExpressionAstExpression, input: Input, params?: ExpressionExecutionParams): Promise<Output>;
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
@ -18,8 +18,7 @@ run<Input, Output, ExtraContext extends Record<string, unknown> = Record<string,
|
|||
| --- | --- | --- |
|
||||
| ast | <code>string | ExpressionAstExpression</code> | |
|
||||
| input | <code>Input</code> | |
|
||||
| context | <code>ExtraContext</code> | |
|
||||
| options | <code>ExpressionExecOptions</code> | |
|
||||
| params | <code>ExpressionExecutionParams</code> | |
|
||||
|
||||
<b>Returns:</b>
|
||||
|
||||
|
|
|
@ -36,8 +36,7 @@ const createExecution = (
|
|||
const execution = new Execution({
|
||||
executor,
|
||||
ast: parseExpression(expression),
|
||||
context,
|
||||
debug,
|
||||
params: { ...context, debug },
|
||||
});
|
||||
return execution;
|
||||
};
|
||||
|
|
|
@ -38,8 +38,10 @@ const createExecution = (
|
|||
const execution = new Execution({
|
||||
executor,
|
||||
ast: parseExpression(expression),
|
||||
context,
|
||||
debug,
|
||||
params: {
|
||||
...context,
|
||||
debug,
|
||||
},
|
||||
});
|
||||
return execution;
|
||||
};
|
||||
|
@ -68,7 +70,7 @@ describe('Execution', () => {
|
|||
test('creates default ExecutionContext', () => {
|
||||
const execution = createExecution();
|
||||
expect(execution.context).toMatchObject({
|
||||
getInitialInput: expect.any(Function),
|
||||
getSearchContext: expect.any(Function),
|
||||
variables: expect.any(Object),
|
||||
types: expect.any(Object),
|
||||
});
|
||||
|
@ -143,6 +145,7 @@ describe('Execution', () => {
|
|||
const execution = new Execution({
|
||||
executor,
|
||||
expression,
|
||||
params: {},
|
||||
});
|
||||
expect(execution.expression).toBe(expression);
|
||||
});
|
||||
|
@ -153,6 +156,7 @@ describe('Execution', () => {
|
|||
const execution = new Execution({
|
||||
ast: parseExpression(expression),
|
||||
executor,
|
||||
params: {},
|
||||
});
|
||||
expect(execution.expression).toBe(expression);
|
||||
});
|
||||
|
@ -619,7 +623,7 @@ describe('Execution', () => {
|
|||
const execution = new Execution({
|
||||
executor,
|
||||
ast: parseExpression('add val=1 | throws | add val=3'),
|
||||
debug: true,
|
||||
params: { debug: true },
|
||||
});
|
||||
execution.start(0);
|
||||
await execution.result;
|
||||
|
@ -637,7 +641,7 @@ describe('Execution', () => {
|
|||
const execution = new Execution({
|
||||
executor,
|
||||
ast: parseExpression('add val=1 | throws | add val=3'),
|
||||
debug: true,
|
||||
params: { debug: true },
|
||||
});
|
||||
execution.start(0);
|
||||
await execution.result;
|
||||
|
@ -658,7 +662,7 @@ describe('Execution', () => {
|
|||
const execution = new Execution({
|
||||
executor,
|
||||
ast: parseExpression('add val=1 | throws | add val=3'),
|
||||
debug: true,
|
||||
params: { debug: true },
|
||||
});
|
||||
execution.start(0);
|
||||
await execution.result;
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { keys, last, mapValues, reduce, zipObject } from 'lodash';
|
||||
import { Executor, ExpressionExecOptions } from '../executor';
|
||||
import { Executor } from '../executor';
|
||||
import { createExecutionContainer, ExecutionContainer } from './container';
|
||||
import { createError } from '../util';
|
||||
import { Defer, now } from '../../../kibana_utils/common';
|
||||
|
@ -39,6 +39,7 @@ import { getType, ExpressionValue } from '../expression_types';
|
|||
import { ArgumentType, ExpressionFunction } from '../expression_functions';
|
||||
import { getByAlias } from '../util/get_by_alias';
|
||||
import { ExecutionContract } from './execution_contract';
|
||||
import { ExpressionExecutionParams } from '../service';
|
||||
|
||||
const createAbortErrorValue = () =>
|
||||
createError({
|
||||
|
@ -46,20 +47,11 @@ const createAbortErrorValue = () =>
|
|||
name: 'AbortError',
|
||||
});
|
||||
|
||||
export interface ExecutionParams<
|
||||
ExtraContext extends Record<string, unknown> = Record<string, unknown>
|
||||
> {
|
||||
export interface ExecutionParams {
|
||||
executor: Executor<any>;
|
||||
ast?: ExpressionAstExpression;
|
||||
expression?: string;
|
||||
context?: ExtraContext;
|
||||
|
||||
/**
|
||||
* Whether to execute expression in *debug mode*. In *debug mode* inputs and
|
||||
* outputs as well as all resolved arguments and time it took to execute each
|
||||
* function are saved and are available for introspection.
|
||||
*/
|
||||
debug?: boolean;
|
||||
params: ExpressionExecutionParams;
|
||||
}
|
||||
|
||||
const createDefaultInspectorAdapters = (): DefaultInspectorAdapters => ({
|
||||
|
@ -68,11 +60,10 @@ const createDefaultInspectorAdapters = (): DefaultInspectorAdapters => ({
|
|||
});
|
||||
|
||||
export class Execution<
|
||||
ExtraContext extends Record<string, unknown> = Record<string, unknown>,
|
||||
Input = unknown,
|
||||
Output = unknown,
|
||||
InspectorAdapters extends Adapters = ExtraContext['inspectorAdapters'] extends object
|
||||
? ExtraContext['inspectorAdapters']
|
||||
InspectorAdapters extends Adapters = ExpressionExecutionParams['inspectorAdapters'] extends object
|
||||
? ExpressionExecutionParams['inspectorAdapters']
|
||||
: DefaultInspectorAdapters
|
||||
> {
|
||||
/**
|
||||
|
@ -92,7 +83,7 @@ export class Execution<
|
|||
* Execution context - object that allows to do side-effects. Context is passed
|
||||
* to every function.
|
||||
*/
|
||||
public readonly context: ExecutionContext<Input, InspectorAdapters> & ExtraContext;
|
||||
public readonly context: ExecutionContext<InspectorAdapters>;
|
||||
|
||||
/**
|
||||
* AbortController to cancel this Execution.
|
||||
|
@ -126,11 +117,10 @@ export class Execution<
|
|||
* can return to other plugins for their consumption.
|
||||
*/
|
||||
public readonly contract: ExecutionContract<
|
||||
ExtraContext,
|
||||
Input,
|
||||
Output,
|
||||
InspectorAdapters
|
||||
> = new ExecutionContract<ExtraContext, Input, Output, InspectorAdapters>(this);
|
||||
> = new ExecutionContract<Input, Output, InspectorAdapters>(this);
|
||||
|
||||
public readonly expression: string;
|
||||
|
||||
|
@ -142,17 +132,17 @@ export class Execution<
|
|||
return this.context.inspectorAdapters;
|
||||
}
|
||||
|
||||
constructor(public readonly params: ExecutionParams<ExtraContext>) {
|
||||
const { executor } = params;
|
||||
constructor(public readonly execution: ExecutionParams) {
|
||||
const { executor } = execution;
|
||||
|
||||
if (!params.ast && !params.expression) {
|
||||
if (!execution.ast && !execution.expression) {
|
||||
throw new TypeError('Execution params should contain at least .ast or .expression key.');
|
||||
} else if (params.ast && params.expression) {
|
||||
} else if (execution.ast && execution.expression) {
|
||||
throw new TypeError('Execution params cannot contain both .ast and .expression key.');
|
||||
}
|
||||
|
||||
this.expression = params.expression || formatExpression(params.ast!);
|
||||
const ast = params.ast || parseExpression(this.expression);
|
||||
this.expression = execution.expression || formatExpression(execution.ast!);
|
||||
const ast = execution.ast || parseExpression(this.expression);
|
||||
|
||||
this.state = createExecutionContainer<Output | ExpressionValueError>({
|
||||
...executor.state.get(),
|
||||
|
@ -161,14 +151,13 @@ export class Execution<
|
|||
});
|
||||
|
||||
this.context = {
|
||||
getInitialInput: () => this.input,
|
||||
variables: {},
|
||||
getSearchContext: () => this.execution.params.searchContext || {},
|
||||
getSearchSessionId: () => execution.params.searchSessionId,
|
||||
variables: execution.params.variables || {},
|
||||
types: executor.getTypes(),
|
||||
abortSignal: this.abortController.signal,
|
||||
...(params.context || ({} as ExtraContext)),
|
||||
inspectorAdapters: (params.context && params.context.inspectorAdapters
|
||||
? params.context.inspectorAdapters
|
||||
: createDefaultInspectorAdapters()) as InspectorAdapters,
|
||||
inspectorAdapters: execution.params.inspectorAdapters || createDefaultInspectorAdapters(),
|
||||
...(execution.params as any).extraContext,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -249,10 +238,10 @@ export class Execution<
|
|||
// actually have a `then` function which would be treated as a `Promise`.
|
||||
const { resolvedArgs } = await this.race(this.resolveArgs(fn, input, fnArgs));
|
||||
args = resolvedArgs;
|
||||
timeStart = this.params.debug ? now() : 0;
|
||||
timeStart = this.execution.params.debug ? now() : 0;
|
||||
const output = await this.race(this.invokeFunction(fn, input, resolvedArgs));
|
||||
|
||||
if (this.params.debug) {
|
||||
if (this.execution.params.debug) {
|
||||
const timeEnd: number = now();
|
||||
(link as ExpressionAstFunction).debug = {
|
||||
success: true,
|
||||
|
@ -267,11 +256,11 @@ export class Execution<
|
|||
if (getType(output) === 'error') return output;
|
||||
input = output;
|
||||
} catch (rawError) {
|
||||
const timeEnd: number = this.params.debug ? now() : 0;
|
||||
const timeEnd: number = this.execution.params.debug ? now() : 0;
|
||||
const error = createError(rawError) as ExpressionValueError;
|
||||
error.error.message = `[${fnName}] > ${error.error.message}`;
|
||||
|
||||
if (this.params.debug) {
|
||||
if (this.execution.params.debug) {
|
||||
(link as ExpressionAstFunction).debug = {
|
||||
success: false,
|
||||
fn: fn.name,
|
||||
|
@ -404,9 +393,7 @@ export class Execution<
|
|||
const resolveArgFns = mapValues(argAstsWithDefaults, (asts, argName) => {
|
||||
return asts.map((item: ExpressionAstExpression) => {
|
||||
return async (subInput = input) => {
|
||||
const output = await this.interpret(item, subInput, {
|
||||
debug: this.params.debug,
|
||||
});
|
||||
const output = await this.interpret(item, subInput);
|
||||
if (isExpressionValueError(output)) throw output.error;
|
||||
const casted = this.cast(output, argDefs[argName as any].types);
|
||||
return casted;
|
||||
|
@ -438,17 +425,12 @@ export class Execution<
|
|||
return { resolvedArgs };
|
||||
}
|
||||
|
||||
public async interpret<T>(
|
||||
ast: ExpressionAstNode,
|
||||
input: T,
|
||||
options?: ExpressionExecOptions
|
||||
): Promise<unknown> {
|
||||
public async interpret<T>(ast: ExpressionAstNode, input: T): Promise<unknown> {
|
||||
switch (getType(ast)) {
|
||||
case 'expression':
|
||||
const execution = this.params.executor.createExecution(
|
||||
const execution = this.execution.executor.createExecution(
|
||||
ast as ExpressionAstExpression,
|
||||
this.context,
|
||||
options
|
||||
this.execution.params
|
||||
);
|
||||
execution.start(input);
|
||||
return await execution.result;
|
||||
|
|
|
@ -30,7 +30,7 @@ const createExecution = (
|
|||
const execution = new Execution({
|
||||
executor,
|
||||
ast: parseExpression(expression),
|
||||
context,
|
||||
params: { ...context },
|
||||
});
|
||||
return execution;
|
||||
};
|
||||
|
|
|
@ -25,21 +25,14 @@ import { ExpressionAstExpression } from '../ast';
|
|||
* `ExecutionContract` is a wrapper around `Execution` class. It provides the
|
||||
* same functionality but does not expose Expressions plugin internals.
|
||||
*/
|
||||
export class ExecutionContract<
|
||||
ExtraContext extends Record<string, unknown> = Record<string, unknown>,
|
||||
Input = unknown,
|
||||
Output = unknown,
|
||||
InspectorAdapters = unknown
|
||||
> {
|
||||
export class ExecutionContract<Input = unknown, Output = unknown, InspectorAdapters = unknown> {
|
||||
public get isPending(): boolean {
|
||||
const state = this.execution.state.get().state;
|
||||
const finished = state === 'error' || state === 'result';
|
||||
return !finished;
|
||||
}
|
||||
|
||||
constructor(
|
||||
protected readonly execution: Execution<ExtraContext, Input, Output, InspectorAdapters>
|
||||
) {}
|
||||
constructor(protected readonly execution: Execution<Input, Output, InspectorAdapters>) {}
|
||||
|
||||
/**
|
||||
* Cancel the execution of the expression. This will set abort signal
|
||||
|
|
|
@ -26,11 +26,11 @@ import { SavedObject, SavedObjectAttributes } from '../../../../core/public';
|
|||
* `ExecutionContext` is an object available to all functions during a single execution;
|
||||
* it provides various methods to perform side-effects.
|
||||
*/
|
||||
export interface ExecutionContext<Input = unknown, InspectorAdapters extends Adapters = Adapters> {
|
||||
export interface ExecutionContext<InspectorAdapters extends Adapters = Adapters> {
|
||||
/**
|
||||
* Get initial input with which execution started.
|
||||
* Get search context of the expression.
|
||||
*/
|
||||
getInitialInput: () => Input;
|
||||
getSearchContext: () => ExecutionContextSearch;
|
||||
|
||||
/**
|
||||
* Context variables that can be consumed using `var` and `var_set` functions.
|
||||
|
@ -55,7 +55,7 @@ export interface ExecutionContext<Input = unknown, InspectorAdapters extends Ada
|
|||
/**
|
||||
* Search context in which expression should operate.
|
||||
*/
|
||||
search?: ExecutionContextSearch;
|
||||
getSearchSessionId: () => string | undefined;
|
||||
|
||||
/**
|
||||
* Allows to fetch saved objects from ElasticSearch. In browser `getSavedObject`
|
||||
|
|
|
@ -33,6 +33,7 @@ import { functionSpecs } from '../expression_functions/specs';
|
|||
import { getByAlias } from '../util';
|
||||
import { SavedObjectReference } from '../../../../core/types';
|
||||
import { PersistableState } from '../../../kibana_utils/common';
|
||||
import { ExpressionExecutionParams } from '../service';
|
||||
|
||||
export interface ExpressionExecOptions {
|
||||
/**
|
||||
|
@ -166,43 +167,34 @@ export class Executor<Context extends Record<string, unknown> = Record<string, u
|
|||
* @param context Extra global context object that will be merged into the
|
||||
* expression global context object that is provided to each function to allow side-effects.
|
||||
*/
|
||||
public async run<
|
||||
Input,
|
||||
Output,
|
||||
ExtraContext extends Record<string, unknown> = Record<string, unknown>
|
||||
>(
|
||||
public async run<Input, Output>(
|
||||
ast: string | ExpressionAstExpression,
|
||||
input: Input,
|
||||
context?: ExtraContext,
|
||||
options?: ExpressionExecOptions
|
||||
params: ExpressionExecutionParams = {}
|
||||
) {
|
||||
const execution = this.createExecution(ast, context, options);
|
||||
const execution = this.createExecution(ast, params);
|
||||
execution.start(input);
|
||||
return (await execution.result) as Output;
|
||||
}
|
||||
|
||||
public createExecution<
|
||||
ExtraContext extends Record<string, unknown> = Record<string, unknown>,
|
||||
Input = unknown,
|
||||
Output = unknown
|
||||
>(
|
||||
public createExecution<Input = unknown, Output = unknown>(
|
||||
ast: string | ExpressionAstExpression,
|
||||
context: ExtraContext = {} as ExtraContext,
|
||||
{ debug }: ExpressionExecOptions = {} as ExpressionExecOptions
|
||||
): Execution<Context & ExtraContext, Input, Output> {
|
||||
const params: ExecutionParams<Context & ExtraContext> = {
|
||||
params: ExpressionExecutionParams = {}
|
||||
): Execution<Input, Output> {
|
||||
const executionParams: ExecutionParams = {
|
||||
executor: this,
|
||||
context: {
|
||||
...this.context,
|
||||
...context,
|
||||
} as Context & ExtraContext,
|
||||
debug,
|
||||
params: {
|
||||
...params,
|
||||
// for canvas we are passing this in,
|
||||
// canvas should be refactored to not pass any extra context in
|
||||
extraContext: this.context,
|
||||
} as any,
|
||||
};
|
||||
|
||||
if (typeof ast === 'string') params.expression = ast;
|
||||
else params.ast = ast;
|
||||
if (typeof ast === 'string') executionParams.expression = ast;
|
||||
else executionParams.ast = ast;
|
||||
|
||||
const execution = new Execution<Context & ExtraContext, Input, Output>(params);
|
||||
const execution = new Execution<Input, Output>(executionParams);
|
||||
|
||||
return execution;
|
||||
}
|
||||
|
|
|
@ -44,15 +44,15 @@ export const kibana: ExpressionFunctionKibana = {
|
|||
|
||||
args: {},
|
||||
|
||||
fn(input, _, { search = {} }) {
|
||||
fn(input, _, { getSearchContext }) {
|
||||
const output: ExpressionValueSearchContext = {
|
||||
// TODO: This spread is left here for legacy reasons, possibly Lens uses it.
|
||||
// TODO: But it shouldn't be need.
|
||||
...input,
|
||||
type: 'kibana_context',
|
||||
query: [...toArray(search.query), ...toArray((input || {}).query)],
|
||||
filters: [...(search.filters || []), ...((input || {}).filters || [])],
|
||||
timeRange: search.timeRange || (input ? input.timeRange : undefined),
|
||||
query: [...toArray(getSearchContext().query), ...toArray((input || {}).query)],
|
||||
filters: [...(getSearchContext().filters || []), ...((input || {}).filters || [])],
|
||||
timeRange: getSearchContext().timeRange || (input ? input.timeRange : undefined),
|
||||
};
|
||||
|
||||
return output;
|
||||
|
|
|
@ -46,8 +46,8 @@ describe('interpreter/functions#kibana', () => {
|
|||
timeRange: { from: '2', to: '3' },
|
||||
};
|
||||
context = {
|
||||
search,
|
||||
getInitialInput: () => input,
|
||||
getSearchContext: () => search,
|
||||
getSearchSessionId: () => undefined,
|
||||
types: {},
|
||||
variables: {},
|
||||
abortSignal: {} as any,
|
||||
|
|
|
@ -37,7 +37,8 @@ describe('expression_functions', () => {
|
|||
};
|
||||
|
||||
context = {
|
||||
getInitialInput: () => {},
|
||||
getSearchContext: () => ({} as any),
|
||||
getSearchSessionId: () => undefined,
|
||||
types: {},
|
||||
variables: { theme: themeProps },
|
||||
abortSignal: {} as any,
|
||||
|
|
|
@ -31,7 +31,8 @@ describe('expression_functions', () => {
|
|||
beforeEach(() => {
|
||||
input = { timeRange: { from: '0', to: '1' } };
|
||||
context = {
|
||||
getInitialInput: () => input,
|
||||
getSearchContext: () => input,
|
||||
getSearchSessionId: () => undefined,
|
||||
types: {},
|
||||
variables: { test: 1 },
|
||||
abortSignal: {} as any,
|
||||
|
|
|
@ -32,7 +32,8 @@ describe('expression_functions', () => {
|
|||
beforeEach(() => {
|
||||
input = { timeRange: { from: '0', to: '1' } };
|
||||
context = {
|
||||
getInitialInput: () => input,
|
||||
getSearchContext: () => input,
|
||||
getSearchSessionId: () => undefined,
|
||||
types: {},
|
||||
variables: { test: 1 },
|
||||
abortSignal: {} as any,
|
||||
|
|
|
@ -23,7 +23,8 @@ export const createMockExecutionContext = <ExtraContext extends object = object>
|
|||
extraContext: ExtraContext = {} as ExtraContext
|
||||
): ExecutionContext & ExtraContext => {
|
||||
const executionContext: ExecutionContext = {
|
||||
getInitialInput: jest.fn(),
|
||||
getSearchContext: jest.fn(),
|
||||
getSearchSessionId: jest.fn(),
|
||||
variables: {},
|
||||
types: {},
|
||||
abortSignal: {
|
||||
|
@ -37,7 +38,6 @@ export const createMockExecutionContext = <ExtraContext extends object = object>
|
|||
requests: {} as any,
|
||||
data: {} as any,
|
||||
},
|
||||
search: {},
|
||||
};
|
||||
|
||||
return {
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { Executor, ExpressionExecOptions } from '../executor';
|
||||
import { Executor } from '../executor';
|
||||
import { AnyExpressionRenderDefinition, ExpressionRendererRegistry } from '../expression_renderers';
|
||||
import { ExpressionAstExpression } from '../ast';
|
||||
import { ExecutionContract } from '../execution/execution_contract';
|
||||
|
@ -25,6 +25,8 @@ import { AnyExpressionTypeDefinition } from '../expression_types';
|
|||
import { AnyExpressionFunctionDefinition } from '../expression_functions';
|
||||
import { SavedObjectReference } from '../../../../core/types';
|
||||
import { PersistableState } from '../../../kibana_utils/common';
|
||||
import { Adapters } from '../../../inspector/common/adapters';
|
||||
import { ExecutionContextSearch } from '../execution';
|
||||
|
||||
/**
|
||||
* The public contract that `ExpressionsService` provides to other plugins
|
||||
|
@ -45,6 +47,23 @@ export type ExpressionsServiceSetup = Pick<
|
|||
| 'fork'
|
||||
>;
|
||||
|
||||
export interface ExpressionExecutionParams {
|
||||
searchContext?: ExecutionContextSearch;
|
||||
|
||||
variables?: Record<string, any>;
|
||||
|
||||
/**
|
||||
* Whether to execute expression in *debug mode*. In *debug mode* inputs and
|
||||
* outputs as well as all resolved arguments and time it took to execute each
|
||||
* function are saved and are available for introspection.
|
||||
*/
|
||||
debug?: boolean;
|
||||
|
||||
searchSessionId?: string;
|
||||
|
||||
inspectorAdapters?: Adapters;
|
||||
}
|
||||
|
||||
/**
|
||||
* The public contract that `ExpressionsService` provides to other plugins
|
||||
* in Kibana Platform in *start* life-cycle.
|
||||
|
@ -98,11 +117,10 @@ export interface ExpressionsServiceStart {
|
|||
* expressions.run('...', null, { elasticsearchClient });
|
||||
* ```
|
||||
*/
|
||||
run: <Input, Output, ExtraContext extends Record<string, unknown> = Record<string, unknown>>(
|
||||
run: <Input, Output>(
|
||||
ast: string | ExpressionAstExpression,
|
||||
input: Input,
|
||||
context?: ExtraContext,
|
||||
options?: ExpressionExecOptions
|
||||
params?: ExpressionExecutionParams
|
||||
) => Promise<Output>;
|
||||
|
||||
/**
|
||||
|
@ -110,17 +128,12 @@ export interface ExpressionsServiceStart {
|
|||
* instance that tracks the progress of the execution and can be used to
|
||||
* interact with the execution.
|
||||
*/
|
||||
execute: <
|
||||
Input = unknown,
|
||||
Output = unknown,
|
||||
ExtraContext extends Record<string, unknown> = Record<string, unknown>
|
||||
>(
|
||||
execute: <Input = unknown, Output = unknown>(
|
||||
ast: string | ExpressionAstExpression,
|
||||
// This any is for legacy reasons.
|
||||
input: Input,
|
||||
context?: ExtraContext,
|
||||
options?: ExpressionExecOptions
|
||||
) => ExecutionContract<ExtraContext, Input, Output>;
|
||||
params?: ExpressionExecutionParams
|
||||
) => ExecutionContract<Input, Output>;
|
||||
|
||||
/**
|
||||
* Create a new instance of `ExpressionsService`. The new instance inherits
|
||||
|
@ -214,8 +227,8 @@ export class ExpressionsService implements PersistableState<ExpressionAstExpress
|
|||
definition: AnyExpressionRenderDefinition | (() => AnyExpressionRenderDefinition)
|
||||
): void => this.renderers.register(definition);
|
||||
|
||||
public readonly run: ExpressionsServiceStart['run'] = (ast, input, context, options) =>
|
||||
this.executor.run(ast, input, context, options);
|
||||
public readonly run: ExpressionsServiceStart['run'] = (ast, input, params) =>
|
||||
this.executor.run(ast, input, params);
|
||||
|
||||
public readonly getFunction: ExpressionsServiceStart['getFunction'] = (name) =>
|
||||
this.executor.getFunction(name);
|
||||
|
@ -246,8 +259,8 @@ export class ExpressionsService implements PersistableState<ExpressionAstExpress
|
|||
*/
|
||||
public readonly getTypes = (): ReturnType<Executor['getTypes']> => this.executor.getTypes();
|
||||
|
||||
public readonly execute: ExpressionsServiceStart['execute'] = ((ast, input, context, options) => {
|
||||
const execution = this.executor.createExecution(ast, context, options);
|
||||
public readonly execute: ExpressionsServiceStart['execute'] = ((ast, input, params) => {
|
||||
const execution = this.executor.createExecution(ast, params);
|
||||
execution.start(input);
|
||||
return execution.contract;
|
||||
}) as ExpressionsServiceStart['execute'];
|
||||
|
|
|
@ -145,18 +145,13 @@ export class ExpressionLoader {
|
|||
this.execution.cancel();
|
||||
}
|
||||
this.setParams(params);
|
||||
this.execution = getExpressionsService().execute(
|
||||
expression,
|
||||
params.context,
|
||||
{
|
||||
search: params.searchContext,
|
||||
variables: params.variables || {},
|
||||
inspectorAdapters: params.inspectorAdapters,
|
||||
},
|
||||
{
|
||||
debug: params.debug,
|
||||
}
|
||||
);
|
||||
this.execution = getExpressionsService().execute(expression, params.context, {
|
||||
searchContext: params.searchContext,
|
||||
variables: params.variables || {},
|
||||
inspectorAdapters: params.inspectorAdapters,
|
||||
searchSessionId: params.searchSessionId,
|
||||
debug: params.debug,
|
||||
});
|
||||
|
||||
const prevDataHandler = this.execution;
|
||||
const data = await prevDataHandler.getData();
|
||||
|
@ -188,6 +183,9 @@ export class ExpressionLoader {
|
|||
if (params.variables && this.params) {
|
||||
this.params.variables = params.variables;
|
||||
}
|
||||
if (params.searchSessionId && this.params) {
|
||||
this.params.searchSessionId = params.searchSessionId;
|
||||
}
|
||||
this.params.debug = Boolean(params.debug);
|
||||
|
||||
this.params.inspectorAdapters = (params.inspectorAdapters ||
|
||||
|
|
|
@ -90,33 +90,32 @@ export type DatatableColumnType = '_source' | 'attachment' | 'boolean' | 'date'
|
|||
export type DatatableRow = Record<string, any>;
|
||||
|
||||
// Warning: (ae-forgotten-export) The symbol "Adapters" needs to be exported by the entry point index.d.ts
|
||||
// Warning: (ae-forgotten-export) The symbol "ExpressionExecutionParams" needs to be exported by the entry point index.d.ts
|
||||
// Warning: (ae-forgotten-export) The symbol "DefaultInspectorAdapters" needs to be exported by the entry point index.d.ts
|
||||
// Warning: (ae-missing-release-tag) "Execution" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||
//
|
||||
// @public (undocumented)
|
||||
export class Execution<ExtraContext extends Record<string, unknown> = Record<string, unknown>, Input = unknown, Output = unknown, InspectorAdapters extends Adapters = ExtraContext['inspectorAdapters'] extends object ? ExtraContext['inspectorAdapters'] : DefaultInspectorAdapters> {
|
||||
constructor(params: ExecutionParams<ExtraContext>);
|
||||
export class Execution<Input = unknown, Output = unknown, InspectorAdapters extends Adapters = ExpressionExecutionParams['inspectorAdapters'] extends object ? ExpressionExecutionParams['inspectorAdapters'] : DefaultInspectorAdapters> {
|
||||
constructor(execution: ExecutionParams);
|
||||
cancel(): void;
|
||||
// (undocumented)
|
||||
cast(value: any, toTypeNames?: string[]): any;
|
||||
readonly context: ExecutionContext<Input, InspectorAdapters> & ExtraContext;
|
||||
readonly contract: ExecutionContract<ExtraContext, Input, Output, InspectorAdapters>;
|
||||
readonly context: ExecutionContext<InspectorAdapters>;
|
||||
readonly contract: ExecutionContract<Input, Output, InspectorAdapters>;
|
||||
// (undocumented)
|
||||
readonly execution: ExecutionParams;
|
||||
// (undocumented)
|
||||
readonly expression: string;
|
||||
input: Input;
|
||||
// (undocumented)
|
||||
get inspectorAdapters(): InspectorAdapters;
|
||||
// Warning: (ae-forgotten-export) The symbol "ExpressionExecOptions" needs to be exported by the entry point index.d.ts
|
||||
//
|
||||
// (undocumented)
|
||||
interpret<T>(ast: ExpressionAstNode, input: T, options?: ExpressionExecOptions): Promise<unknown>;
|
||||
interpret<T>(ast: ExpressionAstNode, input: T): Promise<unknown>;
|
||||
// (undocumented)
|
||||
invokeChain(chainArr: ExpressionAstFunction[], input: unknown): Promise<any>;
|
||||
// (undocumented)
|
||||
invokeFunction(fn: ExpressionFunction, input: unknown, args: Record<string, unknown>): Promise<any>;
|
||||
// (undocumented)
|
||||
readonly params: ExecutionParams<ExtraContext>;
|
||||
// (undocumented)
|
||||
resolveArgs(fnDef: ExpressionFunction, input: unknown, argAsts: any): Promise<any>;
|
||||
// (undocumented)
|
||||
get result(): Promise<Output | ExpressionValueError>;
|
||||
|
@ -134,15 +133,15 @@ export type ExecutionContainer<Output = ExpressionValue> = StateContainer<Execut
|
|||
// Warning: (ae-missing-release-tag) "ExecutionContext" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||
//
|
||||
// @public
|
||||
export interface ExecutionContext<Input = unknown, InspectorAdapters extends Adapters = Adapters> {
|
||||
export interface ExecutionContext<InspectorAdapters extends Adapters = Adapters> {
|
||||
abortSignal: AbortSignal;
|
||||
getInitialInput: () => Input;
|
||||
// Warning: (ae-forgotten-export) The symbol "SavedObjectAttributes" needs to be exported by the entry point index.d.ts
|
||||
// Warning: (ae-forgotten-export) The symbol "SavedObject" needs to be exported by the entry point index.d.ts
|
||||
getSavedObject?: <T extends SavedObjectAttributes = SavedObjectAttributes>(type: string, id: string) => Promise<SavedObject<T>>;
|
||||
inspectorAdapters: InspectorAdapters;
|
||||
// Warning: (ae-forgotten-export) The symbol "ExecutionContextSearch" needs to be exported by the entry point index.d.ts
|
||||
search?: ExecutionContextSearch;
|
||||
getSearchContext: () => ExecutionContextSearch;
|
||||
getSearchSessionId: () => string | undefined;
|
||||
inspectorAdapters: InspectorAdapters;
|
||||
types: Record<string, ExpressionType>;
|
||||
variables: Record<string, unknown>;
|
||||
}
|
||||
|
@ -150,11 +149,11 @@ export interface ExecutionContext<Input = unknown, InspectorAdapters extends Ada
|
|||
// Warning: (ae-missing-release-tag) "ExecutionContract" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||
//
|
||||
// @public
|
||||
export class ExecutionContract<ExtraContext extends Record<string, unknown> = Record<string, unknown>, Input = unknown, Output = unknown, InspectorAdapters = unknown> {
|
||||
constructor(execution: Execution<ExtraContext, Input, Output, InspectorAdapters>);
|
||||
export class ExecutionContract<Input = unknown, Output = unknown, InspectorAdapters = unknown> {
|
||||
constructor(execution: Execution<Input, Output, InspectorAdapters>);
|
||||
cancel: () => void;
|
||||
// (undocumented)
|
||||
protected readonly execution: Execution<ExtraContext, Input, Output, InspectorAdapters>;
|
||||
protected readonly execution: Execution<Input, Output, InspectorAdapters>;
|
||||
getAst: () => ExpressionAstExpression;
|
||||
getData: () => Promise<Output | ExpressionValueError>;
|
||||
getExpression: () => string;
|
||||
|
@ -166,16 +165,15 @@ export class ExecutionContract<ExtraContext extends Record<string, unknown> = Re
|
|||
// Warning: (ae-missing-release-tag) "ExecutionParams" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||
//
|
||||
// @public (undocumented)
|
||||
export interface ExecutionParams<ExtraContext extends Record<string, unknown> = Record<string, unknown>> {
|
||||
export interface ExecutionParams {
|
||||
// (undocumented)
|
||||
ast?: ExpressionAstExpression;
|
||||
// (undocumented)
|
||||
context?: ExtraContext;
|
||||
debug?: boolean;
|
||||
// (undocumented)
|
||||
executor: Executor<any>;
|
||||
// (undocumented)
|
||||
expression?: string;
|
||||
// (undocumented)
|
||||
params: ExpressionExecutionParams;
|
||||
}
|
||||
|
||||
// Warning: (ae-missing-release-tag) "ExecutionState" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||
|
@ -198,7 +196,7 @@ export class Executor<Context extends Record<string, unknown> = Record<string, u
|
|||
// (undocumented)
|
||||
get context(): Record<string, unknown>;
|
||||
// (undocumented)
|
||||
createExecution<ExtraContext extends Record<string, unknown> = Record<string, unknown>, Input = unknown, Output = unknown>(ast: string | ExpressionAstExpression, context?: ExtraContext, { debug }?: ExpressionExecOptions): Execution<Context & ExtraContext, Input, Output>;
|
||||
createExecution<Input = unknown, Output = unknown>(ast: string | ExpressionAstExpression, params?: ExpressionExecutionParams): Execution<Input, Output>;
|
||||
// (undocumented)
|
||||
static createWithDefaults<Ctx extends Record<string, unknown> = Record<string, unknown>>(state?: ExecutorState<Ctx>): Executor<Ctx>;
|
||||
// (undocumented)
|
||||
|
@ -228,7 +226,7 @@ export class Executor<Context extends Record<string, unknown> = Record<string, u
|
|||
registerFunction(functionDefinition: AnyExpressionFunctionDefinition | (() => AnyExpressionFunctionDefinition)): void;
|
||||
// (undocumented)
|
||||
registerType(typeDefinition: AnyExpressionTypeDefinition | (() => AnyExpressionTypeDefinition)): void;
|
||||
run<Input, Output, ExtraContext extends Record<string, unknown> = Record<string, unknown>>(ast: string | ExpressionAstExpression, input: Input, context?: ExtraContext, options?: ExpressionExecOptions): Promise<Output>;
|
||||
run<Input, Output>(ast: string | ExpressionAstExpression, input: Input, params?: ExpressionExecutionParams): Promise<Output>;
|
||||
// (undocumented)
|
||||
readonly state: ExecutorContainer<Context>;
|
||||
// (undocumented)
|
||||
|
@ -613,12 +611,12 @@ export type ExpressionsServiceSetup = Pick<ExpressionsService, 'getFunction' | '
|
|||
//
|
||||
// @public
|
||||
export interface ExpressionsServiceStart {
|
||||
execute: <Input = unknown, Output = unknown, ExtraContext extends Record<string, unknown> = Record<string, unknown>>(ast: string | ExpressionAstExpression, input: Input, context?: ExtraContext, options?: ExpressionExecOptions) => ExecutionContract<ExtraContext, Input, Output>;
|
||||
execute: <Input = unknown, Output = unknown>(ast: string | ExpressionAstExpression, input: Input, params?: ExpressionExecutionParams) => ExecutionContract<Input, Output>;
|
||||
fork: () => ExpressionsService;
|
||||
getFunction: (name: string) => ReturnType<Executor['getFunction']>;
|
||||
getRenderer: (name: string) => ReturnType<ExpressionRendererRegistry['get']>;
|
||||
getType: (name: string) => ReturnType<Executor['getType']>;
|
||||
run: <Input, Output, ExtraContext extends Record<string, unknown> = Record<string, unknown>>(ast: string | ExpressionAstExpression, input: Input, context?: ExtraContext, options?: ExpressionExecOptions) => Promise<Output>;
|
||||
run: <Input, Output>(ast: string | ExpressionAstExpression, input: Input, params?: ExpressionExecutionParams) => Promise<Output>;
|
||||
}
|
||||
|
||||
// Warning: (ae-missing-release-tag) "ExpressionsSetup" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||
|
@ -894,6 +892,8 @@ export interface IExpressionLoaderParams {
|
|||
// (undocumented)
|
||||
searchContext?: ExecutionContextSearch;
|
||||
// (undocumented)
|
||||
searchSessionId?: string;
|
||||
// (undocumented)
|
||||
uiState?: unknown;
|
||||
// (undocumented)
|
||||
variables?: Record<string, any>;
|
||||
|
|
|
@ -53,6 +53,7 @@ export interface IExpressionLoaderParams {
|
|||
uiState?: unknown;
|
||||
inspectorAdapters?: Adapters;
|
||||
onRenderError?: RenderErrorHandlerFnType;
|
||||
searchSessionId?: string;
|
||||
}
|
||||
|
||||
export interface ExpressionRenderError extends Error {
|
||||
|
|
|
@ -87,34 +87,33 @@ export type DatatableColumnType = '_source' | 'attachment' | 'boolean' | 'date'
|
|||
export type DatatableRow = Record<string, any>;
|
||||
|
||||
// Warning: (ae-forgotten-export) The symbol "Adapters" needs to be exported by the entry point index.d.ts
|
||||
// Warning: (ae-forgotten-export) The symbol "ExpressionExecutionParams" needs to be exported by the entry point index.d.ts
|
||||
// Warning: (ae-forgotten-export) The symbol "DefaultInspectorAdapters" needs to be exported by the entry point index.d.ts
|
||||
// Warning: (ae-missing-release-tag) "Execution" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||
//
|
||||
// @public (undocumented)
|
||||
export class Execution<ExtraContext extends Record<string, unknown> = Record<string, unknown>, Input = unknown, Output = unknown, InspectorAdapters extends Adapters = ExtraContext['inspectorAdapters'] extends object ? ExtraContext['inspectorAdapters'] : DefaultInspectorAdapters> {
|
||||
constructor(params: ExecutionParams<ExtraContext>);
|
||||
export class Execution<Input = unknown, Output = unknown, InspectorAdapters extends Adapters = ExpressionExecutionParams['inspectorAdapters'] extends object ? ExpressionExecutionParams['inspectorAdapters'] : DefaultInspectorAdapters> {
|
||||
constructor(execution: ExecutionParams);
|
||||
cancel(): void;
|
||||
// (undocumented)
|
||||
cast(value: any, toTypeNames?: string[]): any;
|
||||
readonly context: ExecutionContext<Input, InspectorAdapters> & ExtraContext;
|
||||
readonly context: ExecutionContext<InspectorAdapters>;
|
||||
// Warning: (ae-forgotten-export) The symbol "ExecutionContract" needs to be exported by the entry point index.d.ts
|
||||
readonly contract: ExecutionContract<ExtraContext, Input, Output, InspectorAdapters>;
|
||||
readonly contract: ExecutionContract<Input, Output, InspectorAdapters>;
|
||||
// (undocumented)
|
||||
readonly execution: ExecutionParams;
|
||||
// (undocumented)
|
||||
readonly expression: string;
|
||||
input: Input;
|
||||
// (undocumented)
|
||||
get inspectorAdapters(): InspectorAdapters;
|
||||
// Warning: (ae-forgotten-export) The symbol "ExpressionExecOptions" needs to be exported by the entry point index.d.ts
|
||||
//
|
||||
// (undocumented)
|
||||
interpret<T>(ast: ExpressionAstNode, input: T, options?: ExpressionExecOptions): Promise<unknown>;
|
||||
interpret<T>(ast: ExpressionAstNode, input: T): Promise<unknown>;
|
||||
// (undocumented)
|
||||
invokeChain(chainArr: ExpressionAstFunction[], input: unknown): Promise<any>;
|
||||
// (undocumented)
|
||||
invokeFunction(fn: ExpressionFunction, input: unknown, args: Record<string, unknown>): Promise<any>;
|
||||
// (undocumented)
|
||||
readonly params: ExecutionParams<ExtraContext>;
|
||||
// (undocumented)
|
||||
resolveArgs(fnDef: ExpressionFunction, input: unknown, argAsts: any): Promise<any>;
|
||||
// (undocumented)
|
||||
get result(): Promise<Output | ExpressionValueError>;
|
||||
|
@ -132,15 +131,15 @@ export type ExecutionContainer<Output = ExpressionValue> = StateContainer<Execut
|
|||
// Warning: (ae-missing-release-tag) "ExecutionContext" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||
//
|
||||
// @public
|
||||
export interface ExecutionContext<Input = unknown, InspectorAdapters extends Adapters = Adapters> {
|
||||
export interface ExecutionContext<InspectorAdapters extends Adapters = Adapters> {
|
||||
abortSignal: AbortSignal;
|
||||
getInitialInput: () => Input;
|
||||
// Warning: (ae-forgotten-export) The symbol "SavedObjectAttributes" needs to be exported by the entry point index.d.ts
|
||||
// Warning: (ae-forgotten-export) The symbol "SavedObject" needs to be exported by the entry point index.d.ts
|
||||
getSavedObject?: <T extends SavedObjectAttributes = SavedObjectAttributes>(type: string, id: string) => Promise<SavedObject<T>>;
|
||||
inspectorAdapters: InspectorAdapters;
|
||||
// Warning: (ae-forgotten-export) The symbol "ExecutionContextSearch" needs to be exported by the entry point index.d.ts
|
||||
search?: ExecutionContextSearch;
|
||||
getSearchContext: () => ExecutionContextSearch;
|
||||
getSearchSessionId: () => string | undefined;
|
||||
inspectorAdapters: InspectorAdapters;
|
||||
types: Record<string, ExpressionType>;
|
||||
variables: Record<string, unknown>;
|
||||
}
|
||||
|
@ -148,16 +147,15 @@ export interface ExecutionContext<Input = unknown, InspectorAdapters extends Ada
|
|||
// Warning: (ae-missing-release-tag) "ExecutionParams" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||
//
|
||||
// @public (undocumented)
|
||||
export interface ExecutionParams<ExtraContext extends Record<string, unknown> = Record<string, unknown>> {
|
||||
export interface ExecutionParams {
|
||||
// (undocumented)
|
||||
ast?: ExpressionAstExpression;
|
||||
// (undocumented)
|
||||
context?: ExtraContext;
|
||||
debug?: boolean;
|
||||
// (undocumented)
|
||||
executor: Executor<any>;
|
||||
// (undocumented)
|
||||
expression?: string;
|
||||
// (undocumented)
|
||||
params: ExpressionExecutionParams;
|
||||
}
|
||||
|
||||
// Warning: (ae-missing-release-tag) "ExecutionState" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||
|
@ -180,7 +178,7 @@ export class Executor<Context extends Record<string, unknown> = Record<string, u
|
|||
// (undocumented)
|
||||
get context(): Record<string, unknown>;
|
||||
// (undocumented)
|
||||
createExecution<ExtraContext extends Record<string, unknown> = Record<string, unknown>, Input = unknown, Output = unknown>(ast: string | ExpressionAstExpression, context?: ExtraContext, { debug }?: ExpressionExecOptions): Execution<Context & ExtraContext, Input, Output>;
|
||||
createExecution<Input = unknown, Output = unknown>(ast: string | ExpressionAstExpression, params?: ExpressionExecutionParams): Execution<Input, Output>;
|
||||
// (undocumented)
|
||||
static createWithDefaults<Ctx extends Record<string, unknown> = Record<string, unknown>>(state?: ExecutorState<Ctx>): Executor<Ctx>;
|
||||
// (undocumented)
|
||||
|
@ -210,7 +208,7 @@ export class Executor<Context extends Record<string, unknown> = Record<string, u
|
|||
registerFunction(functionDefinition: AnyExpressionFunctionDefinition | (() => AnyExpressionFunctionDefinition)): void;
|
||||
// (undocumented)
|
||||
registerType(typeDefinition: AnyExpressionTypeDefinition | (() => AnyExpressionTypeDefinition)): void;
|
||||
run<Input, Output, ExtraContext extends Record<string, unknown> = Record<string, unknown>>(ast: string | ExpressionAstExpression, input: Input, context?: ExtraContext, options?: ExpressionExecOptions): Promise<Output>;
|
||||
run<Input, Output>(ast: string | ExpressionAstExpression, input: Input, params?: ExpressionExecutionParams): Promise<Output>;
|
||||
// (undocumented)
|
||||
readonly state: ExecutorContainer<Context>;
|
||||
// (undocumented)
|
||||
|
|
|
@ -53,7 +53,7 @@ export const createVegaFn = (
|
|||
Input,
|
||||
Arguments,
|
||||
Output,
|
||||
ExecutionContext<unknown, VegaInspectorAdapters>
|
||||
ExecutionContext<VegaInspectorAdapters>
|
||||
> => ({
|
||||
name: 'vega',
|
||||
type: 'render',
|
||||
|
|
|
@ -63,7 +63,7 @@ class Main extends React.Component<{}, State> {
|
|||
return getExpressions()
|
||||
.execute(expression, context || { type: 'null' }, {
|
||||
inspectorAdapters: adapters,
|
||||
search: initialContext as any,
|
||||
searchContext: initialContext as any,
|
||||
})
|
||||
.getData();
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue