diff --git a/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.executor.extract.md b/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.executor.extract.md new file mode 100644 index 0000000000000..6f30bd49013b0 --- /dev/null +++ b/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.executor.extract.md @@ -0,0 +1,28 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-expressions-public](./kibana-plugin-plugins-expressions-public.md) > [Executor](./kibana-plugin-plugins-expressions-public.executor.md) > [extract](./kibana-plugin-plugins-expressions-public.executor.extract.md) + +## Executor.extract() method + +Signature: + +```typescript +extract(ast: ExpressionAstExpression): { + state: ExpressionAstExpression; + references: SavedObjectReference[]; + }; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| ast | ExpressionAstExpression | | + +Returns: + +`{ + state: ExpressionAstExpression; + references: SavedObjectReference[]; + }` + diff --git a/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.executor.inject.md b/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.executor.inject.md new file mode 100644 index 0000000000000..8f5a8a3e06724 --- /dev/null +++ b/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.executor.inject.md @@ -0,0 +1,23 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-expressions-public](./kibana-plugin-plugins-expressions-public.md) > [Executor](./kibana-plugin-plugins-expressions-public.executor.md) > [inject](./kibana-plugin-plugins-expressions-public.executor.inject.md) + +## Executor.inject() method + +Signature: + +```typescript +inject(ast: ExpressionAstExpression, references: SavedObjectReference[]): ExpressionAstExpression; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| ast | ExpressionAstExpression | | +| references | SavedObjectReference[] | | + +Returns: + +`ExpressionAstExpression` + diff --git a/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.executor.md b/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.executor.md index b71c8c79c068f..2f96ad6e040bd 100644 --- a/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.executor.md +++ b/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.executor.md @@ -7,7 +7,7 @@ Signature: ```typescript -export declare class Executor = Record> +export declare class Executor = Record> implements PersistableState ``` ## Constructors @@ -32,12 +32,15 @@ export declare class Executor = Recordstatic | | | [extendContext(extraContext)](./kibana-plugin-plugins-expressions-public.executor.extendcontext.md) | | | +| [extract(ast)](./kibana-plugin-plugins-expressions-public.executor.extract.md) | | | | [fork()](./kibana-plugin-plugins-expressions-public.executor.fork.md) | | | | [getFunction(name)](./kibana-plugin-plugins-expressions-public.executor.getfunction.md) | | | | [getFunctions()](./kibana-plugin-plugins-expressions-public.executor.getfunctions.md) | | | | [getType(name)](./kibana-plugin-plugins-expressions-public.executor.gettype.md) | | | | [getTypes()](./kibana-plugin-plugins-expressions-public.executor.gettypes.md) | | | +| [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)](./kibana-plugin-plugins-expressions-public.executor.run.md) | | Execute expression and return result. | +| [telemetry(ast, telemetryData)](./kibana-plugin-plugins-expressions-public.executor.telemetry.md) | | | diff --git a/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.executor.telemetry.md b/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.executor.telemetry.md new file mode 100644 index 0000000000000..de4c640f4fe97 --- /dev/null +++ b/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.executor.telemetry.md @@ -0,0 +1,23 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-expressions-public](./kibana-plugin-plugins-expressions-public.md) > [Executor](./kibana-plugin-plugins-expressions-public.executor.md) > [telemetry](./kibana-plugin-plugins-expressions-public.executor.telemetry.md) + +## Executor.telemetry() method + +Signature: + +```typescript +telemetry(ast: ExpressionAstExpression, telemetryData: Record): Record; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| ast | ExpressionAstExpression | | +| telemetryData | Record<string, any> | | + +Returns: + +`Record` + diff --git a/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionastexpression.chain.md b/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionastexpression.chain.md deleted file mode 100644 index b50ac83036ffe..0000000000000 --- a/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionastexpression.chain.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-plugins-expressions-public](./kibana-plugin-plugins-expressions-public.md) > [ExpressionAstExpression](./kibana-plugin-plugins-expressions-public.expressionastexpression.md) > [chain](./kibana-plugin-plugins-expressions-public.expressionastexpression.chain.md) - -## ExpressionAstExpression.chain property - -Signature: - -```typescript -chain: ExpressionAstFunction[]; -``` diff --git a/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionastexpression.md b/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionastexpression.md index 537659c51dce8..623c49bf08cdd 100644 --- a/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionastexpression.md +++ b/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionastexpression.md @@ -2,18 +2,13 @@ [Home](./index.md) > [kibana-plugin-plugins-expressions-public](./kibana-plugin-plugins-expressions-public.md) > [ExpressionAstExpression](./kibana-plugin-plugins-expressions-public.expressionastexpression.md) -## ExpressionAstExpression interface +## ExpressionAstExpression type Signature: ```typescript -export interface ExpressionAstExpression +export declare type ExpressionAstExpression = { + type: 'expression'; + chain: ExpressionAstFunction[]; +}; ``` - -## Properties - -| Property | Type | Description | -| --- | --- | --- | -| [chain](./kibana-plugin-plugins-expressions-public.expressionastexpression.chain.md) | ExpressionAstFunction[] | | -| [type](./kibana-plugin-plugins-expressions-public.expressionastexpression.type.md) | 'expression' | | - diff --git a/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionastexpression.type.md b/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionastexpression.type.md deleted file mode 100644 index 34a86e235a911..0000000000000 --- a/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionastexpression.type.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-plugins-expressions-public](./kibana-plugin-plugins-expressions-public.md) > [ExpressionAstExpression](./kibana-plugin-plugins-expressions-public.expressionastexpression.md) > [type](./kibana-plugin-plugins-expressions-public.expressionastexpression.type.md) - -## ExpressionAstExpression.type property - -Signature: - -```typescript -type: 'expression'; -``` diff --git a/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionastfunction.arguments.md b/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionastfunction.arguments.md deleted file mode 100644 index 72b44e8319542..0000000000000 --- a/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionastfunction.arguments.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-plugins-expressions-public](./kibana-plugin-plugins-expressions-public.md) > [ExpressionAstFunction](./kibana-plugin-plugins-expressions-public.expressionastfunction.md) > [arguments](./kibana-plugin-plugins-expressions-public.expressionastfunction.arguments.md) - -## ExpressionAstFunction.arguments property - -Signature: - -```typescript -arguments: Record; -``` diff --git a/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionastfunction.debug.md b/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionastfunction.debug.md deleted file mode 100644 index 36101a110979a..0000000000000 --- a/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionastfunction.debug.md +++ /dev/null @@ -1,13 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-plugins-expressions-public](./kibana-plugin-plugins-expressions-public.md) > [ExpressionAstFunction](./kibana-plugin-plugins-expressions-public.expressionastfunction.md) > [debug](./kibana-plugin-plugins-expressions-public.expressionastfunction.debug.md) - -## ExpressionAstFunction.debug property - -Debug information added to each function when expression is executed in \*debug mode\*. - -Signature: - -```typescript -debug?: ExpressionAstFunctionDebug; -``` diff --git a/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionastfunction.function.md b/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionastfunction.function.md deleted file mode 100644 index 1840fff4b625f..0000000000000 --- a/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionastfunction.function.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-plugins-expressions-public](./kibana-plugin-plugins-expressions-public.md) > [ExpressionAstFunction](./kibana-plugin-plugins-expressions-public.expressionastfunction.md) > [function](./kibana-plugin-plugins-expressions-public.expressionastfunction.function.md) - -## ExpressionAstFunction.function property - -Signature: - -```typescript -function: string; -``` diff --git a/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionastfunction.md b/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionastfunction.md index 1004e58759806..d21f2c1750161 100644 --- a/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionastfunction.md +++ b/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionastfunction.md @@ -2,20 +2,15 @@ [Home](./index.md) > [kibana-plugin-plugins-expressions-public](./kibana-plugin-plugins-expressions-public.md) > [ExpressionAstFunction](./kibana-plugin-plugins-expressions-public.expressionastfunction.md) -## ExpressionAstFunction interface +## ExpressionAstFunction type Signature: ```typescript -export interface ExpressionAstFunction +export declare type ExpressionAstFunction = { + type: 'function'; + function: string; + arguments: Record; + debug?: ExpressionAstFunctionDebug; +}; ``` - -## Properties - -| Property | Type | Description | -| --- | --- | --- | -| [arguments](./kibana-plugin-plugins-expressions-public.expressionastfunction.arguments.md) | Record<string, ExpressionAstArgument[]> | | -| [debug](./kibana-plugin-plugins-expressions-public.expressionastfunction.debug.md) | ExpressionAstFunctionDebug | Debug information added to each function when expression is executed in \*debug mode\*. | -| [function](./kibana-plugin-plugins-expressions-public.expressionastfunction.function.md) | string | | -| [type](./kibana-plugin-plugins-expressions-public.expressionastfunction.type.md) | 'function' | | - diff --git a/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionastfunction.type.md b/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionfunction.disabled.md similarity index 52% rename from docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionastfunction.type.md rename to docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionfunction.disabled.md index f7f8786430191..f07d5b3b36d04 100644 --- a/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionastfunction.type.md +++ b/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionfunction.disabled.md @@ -1,11 +1,11 @@ -[Home](./index.md) > [kibana-plugin-plugins-expressions-public](./kibana-plugin-plugins-expressions-public.md) > [ExpressionAstFunction](./kibana-plugin-plugins-expressions-public.expressionastfunction.md) > [type](./kibana-plugin-plugins-expressions-public.expressionastfunction.type.md) +[Home](./index.md) > [kibana-plugin-plugins-expressions-public](./kibana-plugin-plugins-expressions-public.md) > [ExpressionFunction](./kibana-plugin-plugins-expressions-public.expressionfunction.md) > [disabled](./kibana-plugin-plugins-expressions-public.expressionfunction.disabled.md) -## ExpressionAstFunction.type property +## ExpressionFunction.disabled property Signature: ```typescript -type: 'function'; +disabled: boolean; ``` diff --git a/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionfunction.extract.md b/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionfunction.extract.md new file mode 100644 index 0000000000000..c5d726849cdc2 --- /dev/null +++ b/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionfunction.extract.md @@ -0,0 +1,14 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-expressions-public](./kibana-plugin-plugins-expressions-public.md) > [ExpressionFunction](./kibana-plugin-plugins-expressions-public.expressionfunction.md) > [extract](./kibana-plugin-plugins-expressions-public.expressionfunction.extract.md) + +## ExpressionFunction.extract property + +Signature: + +```typescript +extract: (state: ExpressionAstFunction['arguments']) => { + state: ExpressionAstFunction['arguments']; + references: SavedObjectReference[]; + }; +``` diff --git a/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionfunction.inject.md b/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionfunction.inject.md new file mode 100644 index 0000000000000..6f27a6fbab96a --- /dev/null +++ b/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionfunction.inject.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-expressions-public](./kibana-plugin-plugins-expressions-public.md) > [ExpressionFunction](./kibana-plugin-plugins-expressions-public.expressionfunction.md) > [inject](./kibana-plugin-plugins-expressions-public.expressionfunction.inject.md) + +## ExpressionFunction.inject property + +Signature: + +```typescript +inject: (state: ExpressionAstFunction['arguments'], references: SavedObjectReference[]) => ExpressionAstFunction['arguments']; +``` diff --git a/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionfunction.md b/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionfunction.md index 5ca67e40c93ec..1815d63d804b1 100644 --- a/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionfunction.md +++ b/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionfunction.md @@ -7,7 +7,7 @@ Signature: ```typescript -export declare class ExpressionFunction +export declare class ExpressionFunction implements PersistableState ``` ## Constructors @@ -23,9 +23,13 @@ export declare class ExpressionFunction | [accepts](./kibana-plugin-plugins-expressions-public.expressionfunction.accepts.md) | | (type: string) => boolean | | | [aliases](./kibana-plugin-plugins-expressions-public.expressionfunction.aliases.md) | | string[] | Aliases that can be used instead of name. | | [args](./kibana-plugin-plugins-expressions-public.expressionfunction.args.md) | | Record<string, ExpressionFunctionParameter> | Specification of expression function parameters. | +| [disabled](./kibana-plugin-plugins-expressions-public.expressionfunction.disabled.md) | | boolean | | +| [extract](./kibana-plugin-plugins-expressions-public.expressionfunction.extract.md) | | (state: ExpressionAstFunction['arguments']) => {
state: ExpressionAstFunction['arguments'];
references: SavedObjectReference[];
} | | | [fn](./kibana-plugin-plugins-expressions-public.expressionfunction.fn.md) | | (input: ExpressionValue, params: Record<string, any>, handlers: object) => ExpressionValue | Function to run function (context, args) | | [help](./kibana-plugin-plugins-expressions-public.expressionfunction.help.md) | | string | A short help text. | +| [inject](./kibana-plugin-plugins-expressions-public.expressionfunction.inject.md) | | (state: ExpressionAstFunction['arguments'], references: SavedObjectReference[]) => ExpressionAstFunction['arguments'] | | | [inputTypes](./kibana-plugin-plugins-expressions-public.expressionfunction.inputtypes.md) | | string[] | undefined | Type of inputs that this function supports. | | [name](./kibana-plugin-plugins-expressions-public.expressionfunction.name.md) | | string | Name of function | +| [telemetry](./kibana-plugin-plugins-expressions-public.expressionfunction.telemetry.md) | | (state: ExpressionAstFunction['arguments'], telemetryData: Record<string, any>) => Record<string, any> | | | [type](./kibana-plugin-plugins-expressions-public.expressionfunction.type.md) | | string | Return type of function. This SHOULD be supplied. We use it for UI and autocomplete hinting. We may also use it for optimizations in the future. | diff --git a/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionfunction.telemetry.md b/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionfunction.telemetry.md new file mode 100644 index 0000000000000..249c99f50fc7b --- /dev/null +++ b/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionfunction.telemetry.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-expressions-public](./kibana-plugin-plugins-expressions-public.md) > [ExpressionFunction](./kibana-plugin-plugins-expressions-public.expressionfunction.md) > [telemetry](./kibana-plugin-plugins-expressions-public.expressionfunction.telemetry.md) + +## ExpressionFunction.telemetry property + +Signature: + +```typescript +telemetry: (state: ExpressionAstFunction['arguments'], telemetryData: Record) => Record; +``` diff --git a/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionfunctiondefinition.disabled.md b/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionfunctiondefinition.disabled.md new file mode 100644 index 0000000000000..e6aefd17fceb2 --- /dev/null +++ b/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionfunctiondefinition.disabled.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-expressions-public](./kibana-plugin-plugins-expressions-public.md) > [ExpressionFunctionDefinition](./kibana-plugin-plugins-expressions-public.expressionfunctiondefinition.md) > [disabled](./kibana-plugin-plugins-expressions-public.expressionfunctiondefinition.disabled.md) + +## ExpressionFunctionDefinition.disabled property + +if set to true function will be disabled (but its migrate function will still be available) + +Signature: + +```typescript +disabled?: boolean; +``` diff --git a/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionfunctiondefinition.md b/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionfunctiondefinition.md index bc801542f81ac..449cc66cb3335 100644 --- a/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionfunctiondefinition.md +++ b/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionfunctiondefinition.md @@ -9,7 +9,7 @@ Signature: ```typescript -export interface ExpressionFunctionDefinition, Output, Context extends ExecutionContext = ExecutionContext> +export interface ExpressionFunctionDefinition, Output, Context extends ExecutionContext = ExecutionContext> extends PersistableStateDefinition ``` ## Properties @@ -19,6 +19,7 @@ export interface ExpressionFunctionDefinitionstring[] | What is this? | | [args](./kibana-plugin-plugins-expressions-public.expressionfunctiondefinition.args.md) | {
[key in keyof Arguments]: ArgumentType<Arguments[key]>;
} | Specification of arguments that function supports. This list will also be used for autocomplete functionality when your function is being edited. | | [context](./kibana-plugin-plugins-expressions-public.expressionfunctiondefinition.context.md) | {
types: AnyExpressionFunctionDefinition['inputTypes'];
} | | +| [disabled](./kibana-plugin-plugins-expressions-public.expressionfunctiondefinition.disabled.md) | boolean | if set to true function will be disabled (but its migrate function will still be available) | | [help](./kibana-plugin-plugins-expressions-public.expressionfunctiondefinition.help.md) | string | Help text displayed in the Expression editor. This text should be internationalized. | | [inputTypes](./kibana-plugin-plugins-expressions-public.expressionfunctiondefinition.inputtypes.md) | Array<TypeToString<Input>> | List of allowed type names for input value of this function. If this property is set the input of function will be cast to the first possible type in this list. If this property is missing the input will be provided to the function as-is. | | [name](./kibana-plugin-plugins-expressions-public.expressionfunctiondefinition.name.md) | Name | The name of the function, as will be used in expression. | diff --git a/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionsservice.extract.md b/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionsservice.extract.md new file mode 100644 index 0000000000000..90f1f59c90dea --- /dev/null +++ b/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionsservice.extract.md @@ -0,0 +1,16 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-expressions-public](./kibana-plugin-plugins-expressions-public.md) > [ExpressionsService](./kibana-plugin-plugins-expressions-public.expressionsservice.md) > [extract](./kibana-plugin-plugins-expressions-public.expressionsservice.extract.md) + +## ExpressionsService.extract property + +Extracts saved object references from expression AST + +Signature: + +```typescript +readonly extract: (state: ExpressionAstExpression) => { + state: ExpressionAstExpression; + references: SavedObjectReference[]; + }; +``` diff --git a/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionsservice.inject.md b/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionsservice.inject.md new file mode 100644 index 0000000000000..8ccc673ef24db --- /dev/null +++ b/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionsservice.inject.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-expressions-public](./kibana-plugin-plugins-expressions-public.md) > [ExpressionsService](./kibana-plugin-plugins-expressions-public.expressionsservice.md) > [inject](./kibana-plugin-plugins-expressions-public.expressionsservice.inject.md) + +## ExpressionsService.inject property + +Injects saved object references into expression AST + +Signature: + +```typescript +readonly inject: (state: ExpressionAstExpression, references: SavedObjectReference[]) => ExpressionAstExpression; +``` diff --git a/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionsservice.md b/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionsservice.md index fa93435bffc38..041d66b22dd50 100644 --- a/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionsservice.md +++ b/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionsservice.md @@ -15,7 +15,7 @@ so that JSDoc appears in developers IDE when they use those `plugins.expressions Signature: ```typescript -export declare class ExpressionsService +export declare class ExpressionsService implements PersistableState ``` ## Constructors @@ -30,6 +30,7 @@ export declare class ExpressionsService | --- | --- | --- | --- | | [execute](./kibana-plugin-plugins-expressions-public.expressionsservice.execute.md) | | ExpressionsServiceStart['execute'] | | | [executor](./kibana-plugin-plugins-expressions-public.expressionsservice.executor.md) | | Executor | | +| [extract](./kibana-plugin-plugins-expressions-public.expressionsservice.extract.md) | | (state: ExpressionAstExpression) => {
state: ExpressionAstExpression;
references: SavedObjectReference[];
} | Extracts saved object references from expression AST | | [fork](./kibana-plugin-plugins-expressions-public.expressionsservice.fork.md) | | () => ExpressionsService | | | [getFunction](./kibana-plugin-plugins-expressions-public.expressionsservice.getfunction.md) | | ExpressionsServiceStart['getFunction'] | | | [getFunctions](./kibana-plugin-plugins-expressions-public.expressionsservice.getfunctions.md) | | () => ReturnType<Executor['getFunctions']> | Returns POJO map of all registered expression functions, where keys are names of the functions and values are ExpressionFunction instances. | @@ -37,6 +38,7 @@ export declare class ExpressionsService | [getRenderers](./kibana-plugin-plugins-expressions-public.expressionsservice.getrenderers.md) | | () => ReturnType<ExpressionRendererRegistry['toJS']> | Returns POJO map of all registered expression renderers, where keys are names of the renderers and values are ExpressionRenderer instances. | | [getType](./kibana-plugin-plugins-expressions-public.expressionsservice.gettype.md) | | ExpressionsServiceStart['getType'] | | | [getTypes](./kibana-plugin-plugins-expressions-public.expressionsservice.gettypes.md) | | () => ReturnType<Executor['getTypes']> | Returns POJO map of all registered expression types, where keys are names of the types and values are ExpressionType instances. | +| [inject](./kibana-plugin-plugins-expressions-public.expressionsservice.inject.md) | | (state: ExpressionAstExpression, references: SavedObjectReference[]) => ExpressionAstExpression | Injects saved object references into expression AST | | [registerFunction](./kibana-plugin-plugins-expressions-public.expressionsservice.registerfunction.md) | | (functionDefinition: AnyExpressionFunctionDefinition | (() => AnyExpressionFunctionDefinition)) => void | Register an expression function, which will be possible to execute as part of the expression pipeline.Below we register a function which simply sleeps for given number of milliseconds to delay the execution and outputs its input as-is. ```ts expressions.registerFunction({ @@ -61,6 +63,7 @@ The actual function is defined in the fn key. The function can be \ | [registerType](./kibana-plugin-plugins-expressions-public.expressionsservice.registertype.md) | | (typeDefinition: AnyExpressionTypeDefinition | (() => AnyExpressionTypeDefinition)) => void | | | [renderers](./kibana-plugin-plugins-expressions-public.expressionsservice.renderers.md) | | ExpressionRendererRegistry | | | [run](./kibana-plugin-plugins-expressions-public.expressionsservice.run.md) | | ExpressionsServiceStart['run'] | | +| [telemetry](./kibana-plugin-plugins-expressions-public.expressionsservice.telemetry.md) | | (state: ExpressionAstExpression, telemetryData?: Record<string, any>) => Record<string, any> | Extracts telemetry from expression AST | ## Methods diff --git a/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionsservice.telemetry.md b/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionsservice.telemetry.md new file mode 100644 index 0000000000000..5f28eb732e389 --- /dev/null +++ b/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionsservice.telemetry.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-expressions-public](./kibana-plugin-plugins-expressions-public.md) > [ExpressionsService](./kibana-plugin-plugins-expressions-public.expressionsservice.md) > [telemetry](./kibana-plugin-plugins-expressions-public.expressionsservice.telemetry.md) + +## ExpressionsService.telemetry property + +Extracts telemetry from expression AST + +Signature: + +```typescript +readonly telemetry: (state: ExpressionAstExpression, telemetryData?: Record) => Record; +``` diff --git a/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionvalueerror.md b/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionvalueerror.md index 4a714fe62424f..1dee4a139c660 100644 --- a/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionvalueerror.md +++ b/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.expressionvalueerror.md @@ -8,13 +8,7 @@ ```typescript export declare type ExpressionValueError = ExpressionValueBoxed<'error', { - error: { - message: string; - type?: string; - name?: string; - stack?: string; - original?: Error; - }; - info?: unknown; + error: ErrorLike; + info?: SerializableState; }>; ``` diff --git a/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.md b/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.md index ead6f14e0d1d7..b0c732188a46e 100644 --- a/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.md +++ b/docs/development/plugins/expressions/public/kibana-plugin-plugins-expressions-public.md @@ -55,9 +55,7 @@ | [ExecutionParams](./kibana-plugin-plugins-expressions-public.executionparams.md) | | | [ExecutionState](./kibana-plugin-plugins-expressions-public.executionstate.md) | | | [ExecutorState](./kibana-plugin-plugins-expressions-public.executorstate.md) | | -| [ExpressionAstExpression](./kibana-plugin-plugins-expressions-public.expressionastexpression.md) | | | [ExpressionAstExpressionBuilder](./kibana-plugin-plugins-expressions-public.expressionastexpressionbuilder.md) | | -| [ExpressionAstFunction](./kibana-plugin-plugins-expressions-public.expressionastfunction.md) | | | [ExpressionAstFunctionBuilder](./kibana-plugin-plugins-expressions-public.expressionastfunctionbuilder.md) | | | [ExpressionExecutor](./kibana-plugin-plugins-expressions-public.expressionexecutor.md) | | | [ExpressionFunctionDefinition](./kibana-plugin-plugins-expressions-public.expressionfunctiondefinition.md) | ExpressionFunctionDefinition is the interface plugins have to implement to register a function in expressions plugin. | @@ -102,6 +100,8 @@ | [ExecutionContainer](./kibana-plugin-plugins-expressions-public.executioncontainer.md) | | | [ExecutorContainer](./kibana-plugin-plugins-expressions-public.executorcontainer.md) | | | [ExpressionAstArgument](./kibana-plugin-plugins-expressions-public.expressionastargument.md) | | +| [ExpressionAstExpression](./kibana-plugin-plugins-expressions-public.expressionastexpression.md) | | +| [ExpressionAstFunction](./kibana-plugin-plugins-expressions-public.expressionastfunction.md) | | | [ExpressionAstNode](./kibana-plugin-plugins-expressions-public.expressionastnode.md) | | | [ExpressionFunctionKibana](./kibana-plugin-plugins-expressions-public.expressionfunctionkibana.md) | | | [ExpressionRendererComponent](./kibana-plugin-plugins-expressions-public.expressionrenderercomponent.md) | | diff --git a/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.executor.extract.md b/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.executor.extract.md new file mode 100644 index 0000000000000..0829824732e74 --- /dev/null +++ b/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.executor.extract.md @@ -0,0 +1,28 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-expressions-server](./kibana-plugin-plugins-expressions-server.md) > [Executor](./kibana-plugin-plugins-expressions-server.executor.md) > [extract](./kibana-plugin-plugins-expressions-server.executor.extract.md) + +## Executor.extract() method + +Signature: + +```typescript +extract(ast: ExpressionAstExpression): { + state: ExpressionAstExpression; + references: SavedObjectReference[]; + }; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| ast | ExpressionAstExpression | | + +Returns: + +`{ + state: ExpressionAstExpression; + references: SavedObjectReference[]; + }` + diff --git a/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.executor.inject.md b/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.executor.inject.md new file mode 100644 index 0000000000000..bbc5f7a3cece7 --- /dev/null +++ b/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.executor.inject.md @@ -0,0 +1,23 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-expressions-server](./kibana-plugin-plugins-expressions-server.md) > [Executor](./kibana-plugin-plugins-expressions-server.executor.md) > [inject](./kibana-plugin-plugins-expressions-server.executor.inject.md) + +## Executor.inject() method + +Signature: + +```typescript +inject(ast: ExpressionAstExpression, references: SavedObjectReference[]): ExpressionAstExpression; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| ast | ExpressionAstExpression | | +| references | SavedObjectReference[] | | + +Returns: + +`ExpressionAstExpression` + diff --git a/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.executor.md b/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.executor.md index 7e6bb8c7ded5e..ec4e0bdcc4569 100644 --- a/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.executor.md +++ b/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.executor.md @@ -7,7 +7,7 @@ Signature: ```typescript -export declare class Executor = Record> +export declare class Executor = Record> implements PersistableState ``` ## Constructors @@ -32,12 +32,15 @@ export declare class Executor = Recordstatic | | | [extendContext(extraContext)](./kibana-plugin-plugins-expressions-server.executor.extendcontext.md) | | | +| [extract(ast)](./kibana-plugin-plugins-expressions-server.executor.extract.md) | | | | [fork()](./kibana-plugin-plugins-expressions-server.executor.fork.md) | | | | [getFunction(name)](./kibana-plugin-plugins-expressions-server.executor.getfunction.md) | | | | [getFunctions()](./kibana-plugin-plugins-expressions-server.executor.getfunctions.md) | | | | [getType(name)](./kibana-plugin-plugins-expressions-server.executor.gettype.md) | | | | [getTypes()](./kibana-plugin-plugins-expressions-server.executor.gettypes.md) | | | +| [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)](./kibana-plugin-plugins-expressions-server.executor.run.md) | | Execute expression and return result. | +| [telemetry(ast, telemetryData)](./kibana-plugin-plugins-expressions-server.executor.telemetry.md) | | | diff --git a/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.executor.telemetry.md b/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.executor.telemetry.md new file mode 100644 index 0000000000000..68100c38cfa5b --- /dev/null +++ b/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.executor.telemetry.md @@ -0,0 +1,23 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-expressions-server](./kibana-plugin-plugins-expressions-server.md) > [Executor](./kibana-plugin-plugins-expressions-server.executor.md) > [telemetry](./kibana-plugin-plugins-expressions-server.executor.telemetry.md) + +## Executor.telemetry() method + +Signature: + +```typescript +telemetry(ast: ExpressionAstExpression, telemetryData: Record): Record; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| ast | ExpressionAstExpression | | +| telemetryData | Record<string, any> | | + +Returns: + +`Record` + diff --git a/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.expressionastexpression.chain.md b/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.expressionastexpression.chain.md deleted file mode 100644 index cc8006b918dec..0000000000000 --- a/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.expressionastexpression.chain.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-plugins-expressions-server](./kibana-plugin-plugins-expressions-server.md) > [ExpressionAstExpression](./kibana-plugin-plugins-expressions-server.expressionastexpression.md) > [chain](./kibana-plugin-plugins-expressions-server.expressionastexpression.chain.md) - -## ExpressionAstExpression.chain property - -Signature: - -```typescript -chain: ExpressionAstFunction[]; -``` diff --git a/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.expressionastexpression.md b/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.expressionastexpression.md index b5f83d1af7cb7..9606cb9e36960 100644 --- a/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.expressionastexpression.md +++ b/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.expressionastexpression.md @@ -2,18 +2,13 @@ [Home](./index.md) > [kibana-plugin-plugins-expressions-server](./kibana-plugin-plugins-expressions-server.md) > [ExpressionAstExpression](./kibana-plugin-plugins-expressions-server.expressionastexpression.md) -## ExpressionAstExpression interface +## ExpressionAstExpression type Signature: ```typescript -export interface ExpressionAstExpression +export declare type ExpressionAstExpression = { + type: 'expression'; + chain: ExpressionAstFunction[]; +}; ``` - -## Properties - -| Property | Type | Description | -| --- | --- | --- | -| [chain](./kibana-plugin-plugins-expressions-server.expressionastexpression.chain.md) | ExpressionAstFunction[] | | -| [type](./kibana-plugin-plugins-expressions-server.expressionastexpression.type.md) | 'expression' | | - diff --git a/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.expressionastexpression.type.md b/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.expressionastexpression.type.md deleted file mode 100644 index 46cd60cecaa84..0000000000000 --- a/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.expressionastexpression.type.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-plugins-expressions-server](./kibana-plugin-plugins-expressions-server.md) > [ExpressionAstExpression](./kibana-plugin-plugins-expressions-server.expressionastexpression.md) > [type](./kibana-plugin-plugins-expressions-server.expressionastexpression.type.md) - -## ExpressionAstExpression.type property - -Signature: - -```typescript -type: 'expression'; -``` diff --git a/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.expressionastfunction.arguments.md b/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.expressionastfunction.arguments.md deleted file mode 100644 index 052cadffb9bdb..0000000000000 --- a/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.expressionastfunction.arguments.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-plugins-expressions-server](./kibana-plugin-plugins-expressions-server.md) > [ExpressionAstFunction](./kibana-plugin-plugins-expressions-server.expressionastfunction.md) > [arguments](./kibana-plugin-plugins-expressions-server.expressionastfunction.arguments.md) - -## ExpressionAstFunction.arguments property - -Signature: - -```typescript -arguments: Record; -``` diff --git a/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.expressionastfunction.debug.md b/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.expressionastfunction.debug.md deleted file mode 100644 index b3227c2ac5822..0000000000000 --- a/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.expressionastfunction.debug.md +++ /dev/null @@ -1,13 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-plugins-expressions-server](./kibana-plugin-plugins-expressions-server.md) > [ExpressionAstFunction](./kibana-plugin-plugins-expressions-server.expressionastfunction.md) > [debug](./kibana-plugin-plugins-expressions-server.expressionastfunction.debug.md) - -## ExpressionAstFunction.debug property - -Debug information added to each function when expression is executed in \*debug mode\*. - -Signature: - -```typescript -debug?: ExpressionAstFunctionDebug; -``` diff --git a/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.expressionastfunction.function.md b/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.expressionastfunction.function.md deleted file mode 100644 index 9964409f49119..0000000000000 --- a/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.expressionastfunction.function.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-plugins-expressions-server](./kibana-plugin-plugins-expressions-server.md) > [ExpressionAstFunction](./kibana-plugin-plugins-expressions-server.expressionastfunction.md) > [function](./kibana-plugin-plugins-expressions-server.expressionastfunction.function.md) - -## ExpressionAstFunction.function property - -Signature: - -```typescript -function: string; -``` diff --git a/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.expressionastfunction.md b/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.expressionastfunction.md index 1d49de44b571d..7fbcf2dcfd141 100644 --- a/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.expressionastfunction.md +++ b/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.expressionastfunction.md @@ -2,20 +2,15 @@ [Home](./index.md) > [kibana-plugin-plugins-expressions-server](./kibana-plugin-plugins-expressions-server.md) > [ExpressionAstFunction](./kibana-plugin-plugins-expressions-server.expressionastfunction.md) -## ExpressionAstFunction interface +## ExpressionAstFunction type Signature: ```typescript -export interface ExpressionAstFunction +export declare type ExpressionAstFunction = { + type: 'function'; + function: string; + arguments: Record; + debug?: ExpressionAstFunctionDebug; +}; ``` - -## Properties - -| Property | Type | Description | -| --- | --- | --- | -| [arguments](./kibana-plugin-plugins-expressions-server.expressionastfunction.arguments.md) | Record<string, ExpressionAstArgument[]> | | -| [debug](./kibana-plugin-plugins-expressions-server.expressionastfunction.debug.md) | ExpressionAstFunctionDebug | Debug information added to each function when expression is executed in \*debug mode\*. | -| [function](./kibana-plugin-plugins-expressions-server.expressionastfunction.function.md) | string | | -| [type](./kibana-plugin-plugins-expressions-server.expressionastfunction.type.md) | 'function' | | - diff --git a/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.expressionastfunction.type.md b/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.expressionfunction.disabled.md similarity index 52% rename from docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.expressionastfunction.type.md rename to docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.expressionfunction.disabled.md index 3fd10524c1599..8ae51645f5df9 100644 --- a/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.expressionastfunction.type.md +++ b/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.expressionfunction.disabled.md @@ -1,11 +1,11 @@ -[Home](./index.md) > [kibana-plugin-plugins-expressions-server](./kibana-plugin-plugins-expressions-server.md) > [ExpressionAstFunction](./kibana-plugin-plugins-expressions-server.expressionastfunction.md) > [type](./kibana-plugin-plugins-expressions-server.expressionastfunction.type.md) +[Home](./index.md) > [kibana-plugin-plugins-expressions-server](./kibana-plugin-plugins-expressions-server.md) > [ExpressionFunction](./kibana-plugin-plugins-expressions-server.expressionfunction.md) > [disabled](./kibana-plugin-plugins-expressions-server.expressionfunction.disabled.md) -## ExpressionAstFunction.type property +## ExpressionFunction.disabled property Signature: ```typescript -type: 'function'; +disabled: boolean; ``` diff --git a/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.expressionfunction.extract.md b/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.expressionfunction.extract.md new file mode 100644 index 0000000000000..e7ecad4a6c9e4 --- /dev/null +++ b/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.expressionfunction.extract.md @@ -0,0 +1,14 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-expressions-server](./kibana-plugin-plugins-expressions-server.md) > [ExpressionFunction](./kibana-plugin-plugins-expressions-server.expressionfunction.md) > [extract](./kibana-plugin-plugins-expressions-server.expressionfunction.extract.md) + +## ExpressionFunction.extract property + +Signature: + +```typescript +extract: (state: ExpressionAstFunction['arguments']) => { + state: ExpressionAstFunction['arguments']; + references: SavedObjectReference[]; + }; +``` diff --git a/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.expressionfunction.inject.md b/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.expressionfunction.inject.md new file mode 100644 index 0000000000000..85c98ef9193da --- /dev/null +++ b/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.expressionfunction.inject.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-expressions-server](./kibana-plugin-plugins-expressions-server.md) > [ExpressionFunction](./kibana-plugin-plugins-expressions-server.expressionfunction.md) > [inject](./kibana-plugin-plugins-expressions-server.expressionfunction.inject.md) + +## ExpressionFunction.inject property + +Signature: + +```typescript +inject: (state: ExpressionAstFunction['arguments'], references: SavedObjectReference[]) => ExpressionAstFunction['arguments']; +``` diff --git a/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.expressionfunction.md b/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.expressionfunction.md index aac3878b8c859..7fcda94968d13 100644 --- a/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.expressionfunction.md +++ b/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.expressionfunction.md @@ -7,7 +7,7 @@ Signature: ```typescript -export declare class ExpressionFunction +export declare class ExpressionFunction implements PersistableState ``` ## Constructors @@ -23,9 +23,13 @@ export declare class ExpressionFunction | [accepts](./kibana-plugin-plugins-expressions-server.expressionfunction.accepts.md) | | (type: string) => boolean | | | [aliases](./kibana-plugin-plugins-expressions-server.expressionfunction.aliases.md) | | string[] | Aliases that can be used instead of name. | | [args](./kibana-plugin-plugins-expressions-server.expressionfunction.args.md) | | Record<string, ExpressionFunctionParameter> | Specification of expression function parameters. | +| [disabled](./kibana-plugin-plugins-expressions-server.expressionfunction.disabled.md) | | boolean | | +| [extract](./kibana-plugin-plugins-expressions-server.expressionfunction.extract.md) | | (state: ExpressionAstFunction['arguments']) => {
state: ExpressionAstFunction['arguments'];
references: SavedObjectReference[];
} | | | [fn](./kibana-plugin-plugins-expressions-server.expressionfunction.fn.md) | | (input: ExpressionValue, params: Record<string, any>, handlers: object) => ExpressionValue | Function to run function (context, args) | | [help](./kibana-plugin-plugins-expressions-server.expressionfunction.help.md) | | string | A short help text. | +| [inject](./kibana-plugin-plugins-expressions-server.expressionfunction.inject.md) | | (state: ExpressionAstFunction['arguments'], references: SavedObjectReference[]) => ExpressionAstFunction['arguments'] | | | [inputTypes](./kibana-plugin-plugins-expressions-server.expressionfunction.inputtypes.md) | | string[] | undefined | Type of inputs that this function supports. | | [name](./kibana-plugin-plugins-expressions-server.expressionfunction.name.md) | | string | Name of function | +| [telemetry](./kibana-plugin-plugins-expressions-server.expressionfunction.telemetry.md) | | (state: ExpressionAstFunction['arguments'], telemetryData: Record<string, any>) => Record<string, any> | | | [type](./kibana-plugin-plugins-expressions-server.expressionfunction.type.md) | | string | Return type of function. This SHOULD be supplied. We use it for UI and autocomplete hinting. We may also use it for optimizations in the future. | diff --git a/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.expressionfunction.telemetry.md b/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.expressionfunction.telemetry.md new file mode 100644 index 0000000000000..2894486847b27 --- /dev/null +++ b/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.expressionfunction.telemetry.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-expressions-server](./kibana-plugin-plugins-expressions-server.md) > [ExpressionFunction](./kibana-plugin-plugins-expressions-server.expressionfunction.md) > [telemetry](./kibana-plugin-plugins-expressions-server.expressionfunction.telemetry.md) + +## ExpressionFunction.telemetry property + +Signature: + +```typescript +telemetry: (state: ExpressionAstFunction['arguments'], telemetryData: Record) => Record; +``` diff --git a/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.expressionfunctiondefinition.disabled.md b/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.expressionfunctiondefinition.disabled.md new file mode 100644 index 0000000000000..88456c8700aec --- /dev/null +++ b/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.expressionfunctiondefinition.disabled.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-expressions-server](./kibana-plugin-plugins-expressions-server.md) > [ExpressionFunctionDefinition](./kibana-plugin-plugins-expressions-server.expressionfunctiondefinition.md) > [disabled](./kibana-plugin-plugins-expressions-server.expressionfunctiondefinition.disabled.md) + +## ExpressionFunctionDefinition.disabled property + +if set to true function will be disabled (but its migrate function will still be available) + +Signature: + +```typescript +disabled?: boolean; +``` diff --git a/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.expressionfunctiondefinition.md b/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.expressionfunctiondefinition.md index 6463c6ac537b9..51240f094b181 100644 --- a/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.expressionfunctiondefinition.md +++ b/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.expressionfunctiondefinition.md @@ -9,7 +9,7 @@ Signature: ```typescript -export interface ExpressionFunctionDefinition, Output, Context extends ExecutionContext = ExecutionContext> +export interface ExpressionFunctionDefinition, Output, Context extends ExecutionContext = ExecutionContext> extends PersistableStateDefinition ``` ## Properties @@ -19,6 +19,7 @@ export interface ExpressionFunctionDefinitionstring[] | What is this? | | [args](./kibana-plugin-plugins-expressions-server.expressionfunctiondefinition.args.md) | {
[key in keyof Arguments]: ArgumentType<Arguments[key]>;
} | Specification of arguments that function supports. This list will also be used for autocomplete functionality when your function is being edited. | | [context](./kibana-plugin-plugins-expressions-server.expressionfunctiondefinition.context.md) | {
types: AnyExpressionFunctionDefinition['inputTypes'];
} | | +| [disabled](./kibana-plugin-plugins-expressions-server.expressionfunctiondefinition.disabled.md) | boolean | if set to true function will be disabled (but its migrate function will still be available) | | [help](./kibana-plugin-plugins-expressions-server.expressionfunctiondefinition.help.md) | string | Help text displayed in the Expression editor. This text should be internationalized. | | [inputTypes](./kibana-plugin-plugins-expressions-server.expressionfunctiondefinition.inputtypes.md) | Array<TypeToString<Input>> | List of allowed type names for input value of this function. If this property is set the input of function will be cast to the first possible type in this list. If this property is missing the input will be provided to the function as-is. | | [name](./kibana-plugin-plugins-expressions-server.expressionfunctiondefinition.name.md) | Name | The name of the function, as will be used in expression. | diff --git a/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.expressionvalueerror.md b/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.expressionvalueerror.md index b90e4360e055a..c8132948a8993 100644 --- a/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.expressionvalueerror.md +++ b/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.expressionvalueerror.md @@ -8,13 +8,7 @@ ```typescript export declare type ExpressionValueError = ExpressionValueBoxed<'error', { - error: { - message: string; - type?: string; - name?: string; - stack?: string; - original?: Error; - }; - info?: unknown; + error: ErrorLike; + info?: SerializableState; }>; ``` diff --git a/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.md b/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.md index c9fed2e00c66c..dd7c7af466bd0 100644 --- a/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.md +++ b/docs/development/plugins/expressions/server/kibana-plugin-plugins-expressions-server.md @@ -52,9 +52,7 @@ | [ExecutionParams](./kibana-plugin-plugins-expressions-server.executionparams.md) | | | [ExecutionState](./kibana-plugin-plugins-expressions-server.executionstate.md) | | | [ExecutorState](./kibana-plugin-plugins-expressions-server.executorstate.md) | | -| [ExpressionAstExpression](./kibana-plugin-plugins-expressions-server.expressionastexpression.md) | | | [ExpressionAstExpressionBuilder](./kibana-plugin-plugins-expressions-server.expressionastexpressionbuilder.md) | | -| [ExpressionAstFunction](./kibana-plugin-plugins-expressions-server.expressionastfunction.md) | | | [ExpressionAstFunctionBuilder](./kibana-plugin-plugins-expressions-server.expressionastfunctionbuilder.md) | | | [ExpressionFunctionDefinition](./kibana-plugin-plugins-expressions-server.expressionfunctiondefinition.md) | ExpressionFunctionDefinition is the interface plugins have to implement to register a function in expressions plugin. | | [ExpressionFunctionDefinitions](./kibana-plugin-plugins-expressions-server.expressionfunctiondefinitions.md) | A mapping of ExpressionFunctionDefinitions for functions which the Expressions services provides out-of-the-box. Any new functions registered by the Expressions plugin should have their types added here. | @@ -86,6 +84,8 @@ | [ExecutionContainer](./kibana-plugin-plugins-expressions-server.executioncontainer.md) | | | [ExecutorContainer](./kibana-plugin-plugins-expressions-server.executorcontainer.md) | | | [ExpressionAstArgument](./kibana-plugin-plugins-expressions-server.expressionastargument.md) | | +| [ExpressionAstExpression](./kibana-plugin-plugins-expressions-server.expressionastexpression.md) | | +| [ExpressionAstFunction](./kibana-plugin-plugins-expressions-server.expressionastfunction.md) | | | [ExpressionAstNode](./kibana-plugin-plugins-expressions-server.expressionastnode.md) | | | [ExpressionFunctionKibana](./kibana-plugin-plugins-expressions-server.expressionfunctionkibana.md) | | | [ExpressionsServerSetup](./kibana-plugin-plugins-expressions-server.expressionsserversetup.md) | | diff --git a/src/plugins/expressions/.eslintrc.json b/src/plugins/expressions/.eslintrc.json new file mode 100644 index 0000000000000..2aab6c2d9093b --- /dev/null +++ b/src/plugins/expressions/.eslintrc.json @@ -0,0 +1,5 @@ +{ + "rules": { + "@typescript-eslint/consistent-type-definitions": 0 + } +} diff --git a/src/plugins/expressions/common/ast/types.ts b/src/plugins/expressions/common/ast/types.ts index 09fb4fae3f201..e8cf497774569 100644 --- a/src/plugins/expressions/common/ast/types.ts +++ b/src/plugins/expressions/common/ast/types.ts @@ -24,12 +24,12 @@ export type ExpressionAstNode = | ExpressionAstFunction | ExpressionAstArgument; -export interface ExpressionAstExpression { +export type ExpressionAstExpression = { type: 'expression'; chain: ExpressionAstFunction[]; -} +}; -export interface ExpressionAstFunction { +export type ExpressionAstFunction = { type: 'function'; function: string; arguments: Record; @@ -38,9 +38,9 @@ export interface ExpressionAstFunction { * Debug information added to each function when expression is executed in *debug mode*. */ debug?: ExpressionAstFunctionDebug; -} +}; -export interface ExpressionAstFunctionDebug { +export type ExpressionAstFunctionDebug = { /** * True if function successfully returned output, false if function threw. */ @@ -83,6 +83,6 @@ export interface ExpressionAstFunctionDebug { * timing starts after the arguments have been resolved. */ duration: number | undefined; -} +}; export type ExpressionAstArgument = string | boolean | number | ExpressionAstExpression; diff --git a/src/plugins/expressions/common/execution/execution.ts b/src/plugins/expressions/common/execution/execution.ts index d4c9b0a25d45b..69140453f486d 100644 --- a/src/plugins/expressions/common/execution/execution.ts +++ b/src/plugins/expressions/common/execution/execution.ts @@ -17,6 +17,7 @@ * under the License. */ +import { i18n } from '@kbn/i18n'; import { keys, last, mapValues, reduce, zipObject } from 'lodash'; import { Executor, ExpressionExecOptions } from '../executor'; import { createExecutionContainer, ExecutionContainer } from './container'; @@ -217,7 +218,27 @@ export class Execution< const fn = getByAlias(this.state.get().functions, fnName); if (!fn) { - return createError({ message: `Function ${fnName} could not be found.` }); + return createError({ + name: 'fn not found', + message: i18n.translate('expressions.execution.functionNotFound', { + defaultMessage: `Function {fnName} could not be found.`, + values: { + fnName, + }, + }), + }); + } + + if (fn.disabled) { + return createError({ + name: 'fn is disabled', + message: i18n.translate('expressions.execution.functionDisabled', { + defaultMessage: `Function {fnName} is disabled.`, + values: { + fnName, + }, + }), + }); } let args: Record = {}; diff --git a/src/plugins/expressions/common/execution/execution_contract.ts b/src/plugins/expressions/common/execution/execution_contract.ts index 20c5b2dd434b5..79bb4c58ab48d 100644 --- a/src/plugins/expressions/common/execution/execution_contract.ts +++ b/src/plugins/expressions/common/execution/execution_contract.ts @@ -62,7 +62,7 @@ export class ExecutionContract< return { type: 'error', error: { - type: e.type, + name: e.name, message: e.message, stack: e.stack, }, diff --git a/src/plugins/expressions/common/executor/executor.test.ts b/src/plugins/expressions/common/executor/executor.test.ts index 81845401d32e4..a658d3457407c 100644 --- a/src/plugins/expressions/common/executor/executor.test.ts +++ b/src/plugins/expressions/common/executor/executor.test.ts @@ -21,7 +21,7 @@ import { Executor } from './executor'; import * as expressionTypes from '../expression_types'; import * as expressionFunctions from '../expression_functions'; import { Execution } from '../execution'; -import { parseExpression } from '../ast'; +import { ExpressionAstFunction, parseExpression } from '../ast'; describe('Executor', () => { test('can instantiate', () => { @@ -152,4 +152,47 @@ describe('Executor', () => { }); }); }); + + describe('.inject', () => { + const executor = new Executor(); + + const injectFn = jest.fn().mockImplementation((args, references) => args); + const extractFn = jest.fn().mockReturnValue({ args: {}, references: [] }); + + const fooFn = { + name: 'foo', + help: 'test', + args: { + bar: { + types: ['string'], + help: 'test', + }, + }, + extract: (state: ExpressionAstFunction['arguments']) => { + return extractFn(state); + }, + inject: (state: ExpressionAstFunction['arguments']) => { + return injectFn(state); + }, + fn: jest.fn(), + }; + executor.registerFunction(fooFn); + + test('calls inject function for every expression function in expression', () => { + executor.inject( + parseExpression('foo bar="baz" | foo bar={foo bar="baz" | foo bar={foo bar="baz"}}'), + [] + ); + expect(injectFn).toBeCalledTimes(5); + }); + + describe('.extract', () => { + test('calls extract function for every expression function in expression', () => { + executor.extract( + parseExpression('foo bar="baz" | foo bar={foo bar="baz" | foo bar={foo bar="baz"}}') + ); + expect(extractFn).toBeCalledTimes(5); + }); + }); + }); }); diff --git a/src/plugins/expressions/common/executor/executor.ts b/src/plugins/expressions/common/executor/executor.ts index 2b5f9f2556d89..28aae8c8f4834 100644 --- a/src/plugins/expressions/common/executor/executor.ts +++ b/src/plugins/expressions/common/executor/executor.ts @@ -19,6 +19,7 @@ /* eslint-disable max-classes-per-file */ +import { cloneDeep, mapValues } from 'lodash'; import { ExecutorState, ExecutorContainer } from './container'; import { createExecutorContainer } from './container'; import { AnyExpressionFunctionDefinition, ExpressionFunction } from '../expression_functions'; @@ -26,9 +27,12 @@ import { Execution, ExecutionParams } from '../execution/execution'; import { IRegistry } from '../types'; import { ExpressionType } from '../expression_types/expression_type'; import { AnyExpressionTypeDefinition } from '../expression_types/types'; -import { ExpressionAstExpression } from '../ast'; +import { ExpressionAstExpression, ExpressionAstFunction } from '../ast'; import { typeSpecs } from '../expression_types/specs'; import { functionSpecs } from '../expression_functions/specs'; +import { getByAlias } from '../util'; +import { SavedObjectReference } from '../../../../core/types'; +import { PersistableState } from '../../../kibana_utils/common'; export interface ExpressionExecOptions { /** @@ -83,7 +87,8 @@ export class FunctionsRegistry implements IRegistry { } } -export class Executor = Record> { +export class Executor = Record> + implements PersistableState { static createWithDefaults = Record>( state?: ExecutorState ): Executor { @@ -197,6 +202,56 @@ export class Executor = Record void + ) { + for (const link of ast.chain) { + const { function: fnName, arguments: fnArgs } = link; + const fn = getByAlias(this.state.get().functions, fnName); + + if (fn) { + // if any of arguments are expressions we should migrate those first + link.arguments = mapValues(fnArgs, (asts, argName) => { + return asts.map((arg) => { + if (typeof arg === 'object') { + return this.walkAst(arg, action); + } + return arg; + }); + }); + + action(fn, link); + } + } + + return ast; + } + + public inject(ast: ExpressionAstExpression, references: SavedObjectReference[]) { + return this.walkAst(cloneDeep(ast), (fn, link) => { + link.arguments = fn.inject(link.arguments, references); + }); + } + + public extract(ast: ExpressionAstExpression) { + const allReferences: SavedObjectReference[] = []; + const newAst = this.walkAst(cloneDeep(ast), (fn, link) => { + const { state, references } = fn.extract(link.arguments); + link.arguments = state; + allReferences.push(...references); + }); + return { state: newAst, references: allReferences }; + } + + public telemetry(ast: ExpressionAstExpression, telemetryData: Record) { + this.walkAst(cloneDeep(ast), (fn, link) => { + telemetryData = fn.telemetry(link.arguments, telemetryData); + }); + + return telemetryData; + } + public fork(): Executor { const initialState = this.state.get(); const fork = new Executor(initialState); diff --git a/src/plugins/expressions/common/expression_functions/expression_function.ts b/src/plugins/expressions/common/expression_functions/expression_function.ts index 71f0d91510136..0b56d3c169ff4 100644 --- a/src/plugins/expressions/common/expression_functions/expression_function.ts +++ b/src/plugins/expressions/common/expression_functions/expression_function.ts @@ -17,12 +17,16 @@ * under the License. */ +import { identity } from 'lodash'; import { AnyExpressionFunctionDefinition } from './types'; import { ExpressionFunctionParameter } from './expression_function_parameter'; import { ExpressionValue } from '../expression_types/types'; import { ExecutionContext } from '../execution'; +import { ExpressionAstFunction } from '../ast'; +import { SavedObjectReference } from '../../../../core/types'; +import { PersistableState } from '../../../kibana_utils/common'; -export class ExpressionFunction { +export class ExpressionFunction implements PersistableState { /** * Name of function */ @@ -60,8 +64,34 @@ export class ExpressionFunction { */ inputTypes: string[] | undefined; + disabled: boolean; + telemetry: ( + state: ExpressionAstFunction['arguments'], + telemetryData: Record + ) => Record; + extract: ( + state: ExpressionAstFunction['arguments'] + ) => { state: ExpressionAstFunction['arguments']; references: SavedObjectReference[] }; + inject: ( + state: ExpressionAstFunction['arguments'], + references: SavedObjectReference[] + ) => ExpressionAstFunction['arguments']; + constructor(functionDefinition: AnyExpressionFunctionDefinition) { - const { name, type, aliases, fn, help, args, inputTypes, context } = functionDefinition; + const { + name, + type, + aliases, + fn, + help, + args, + inputTypes, + context, + disabled, + telemetry, + inject, + extract, + } = functionDefinition; this.name = name; this.type = type; @@ -70,6 +100,10 @@ export class ExpressionFunction { Promise.resolve(fn(input, params, handlers as ExecutionContext)); this.help = help || ''; this.inputTypes = inputTypes || context?.types; + this.disabled = disabled || false; + this.telemetry = telemetry || ((s, c) => c); + this.inject = inject || identity; + this.extract = extract || ((s) => ({ state: s, references: [] })); for (const [key, arg] of Object.entries(args || {})) { this.args[key] = new ExpressionFunctionParameter(key, arg); diff --git a/src/plugins/expressions/common/expression_functions/types.ts b/src/plugins/expressions/common/expression_functions/types.ts index d58d872aff722..caaef541aefd5 100644 --- a/src/plugins/expressions/common/expression_functions/types.ts +++ b/src/plugins/expressions/common/expression_functions/types.ts @@ -30,6 +30,8 @@ import { ExpressionFunctionVar, ExpressionFunctionTheme, } from './specs'; +import { ExpressionAstFunction } from '../ast'; +import { PersistableStateDefinition } from '../../../kibana_utils/common'; /** * `ExpressionFunctionDefinition` is the interface plugins have to implement to @@ -41,12 +43,17 @@ export interface ExpressionFunctionDefinition< Arguments extends Record, Output, Context extends ExecutionContext = ExecutionContext -> { +> extends PersistableStateDefinition { /** * The name of the function, as will be used in expression. */ name: Name; + /** + * if set to true function will be disabled (but its migrate function will still be available) + */ + disabled?: boolean; + /** * Name of type of value this function outputs. */ diff --git a/src/plugins/expressions/common/expression_types/specs/error.ts b/src/plugins/expressions/common/expression_types/specs/error.ts index ebaedcbba0d23..7607945d8a664 100644 --- a/src/plugins/expressions/common/expression_types/specs/error.ts +++ b/src/plugins/expressions/common/expression_types/specs/error.ts @@ -20,20 +20,16 @@ import { ExpressionTypeDefinition, ExpressionValueBoxed } from '../types'; import { ExpressionValueRender } from './render'; import { getType } from '../get_type'; +import { SerializableState } from '../../../../kibana_utils/common'; +import { ErrorLike } from '../../util'; const name = 'error'; export type ExpressionValueError = ExpressionValueBoxed< 'error', { - error: { - message: string; - type?: string; - name?: string; - stack?: string; - original?: Error; - }; - info?: unknown; + error: ErrorLike; + info?: SerializableState; } >; diff --git a/src/plugins/expressions/common/service/expressions_services.ts b/src/plugins/expressions/common/service/expressions_services.ts index b5c98fada07c4..4a87fd9e7f331 100644 --- a/src/plugins/expressions/common/service/expressions_services.ts +++ b/src/plugins/expressions/common/service/expressions_services.ts @@ -23,6 +23,8 @@ import { ExpressionAstExpression } from '../ast'; import { ExecutionContract } from '../execution/execution_contract'; import { AnyExpressionTypeDefinition } from '../expression_types'; import { AnyExpressionFunctionDefinition } from '../expression_functions'; +import { SavedObjectReference } from '../../../../core/types'; +import { PersistableState } from '../../../kibana_utils/common'; /** * The public contract that `ExpressionsService` provides to other plugins @@ -154,7 +156,7 @@ export interface ExpressionServiceParams { * * so that JSDoc appears in developers IDE when they use those `plugins.expressions.registerFunction(`. */ -export class ExpressionsService { +export class ExpressionsService implements PersistableState { public readonly executor: Executor; public readonly renderers: ExpressionRendererRegistry; @@ -256,6 +258,36 @@ export class ExpressionsService { return fork; }; + /** + * Extracts telemetry from expression AST + * @param state expression AST to extract references from + */ + public readonly telemetry = ( + state: ExpressionAstExpression, + telemetryData: Record = {} + ) => { + return this.executor.telemetry(state, telemetryData); + }; + + /** + * Extracts saved object references from expression AST + * @param state expression AST to extract references from + * @returns new expression AST with references removed and array of references + */ + public readonly extract = (state: ExpressionAstExpression) => { + return this.executor.extract(state); + }; + + /** + * Injects saved object references into expression AST + * @param state expression AST to update + * @param references array of saved object references + * @returns new expression AST with references injected + */ + public readonly inject = (state: ExpressionAstExpression, references: SavedObjectReference[]) => { + return this.executor.inject(state, references); + }; + /** * Returns Kibana Platform *setup* life-cycle contract. Useful to return the * same contract on server-side and browser-side. diff --git a/src/plugins/expressions/common/util/create_error.ts b/src/plugins/expressions/common/util/create_error.ts index 9bdab74efd6f9..46306d3fbbf66 100644 --- a/src/plugins/expressions/common/util/create_error.ts +++ b/src/plugins/expressions/common/util/create_error.ts @@ -19,9 +19,17 @@ import { ExpressionValueError } from '../../common'; -type ErrorLike = Partial>; +export type SerializedError = { + name: string; + message: string; + stack?: string; +}; -export const createError = (err: string | Error | ErrorLike): ExpressionValueError => ({ +export type ErrorLike = SerializedError & { + original?: SerializedError; +}; + +export const createError = (err: string | ErrorLike): ExpressionValueError => ({ type: 'error', error: { stack: @@ -32,6 +40,6 @@ export const createError = (err: string | Error | ErrorLike): ExpressionValueErr : undefined, message: typeof err === 'string' ? err : String(err.message), name: typeof err === 'object' ? err.name || 'Error' : 'Error', - original: err instanceof Error ? err : undefined, + original: err instanceof Error ? (err as SerializedError) : undefined, }, }); diff --git a/src/plugins/expressions/public/public.api.md b/src/plugins/expressions/public/public.api.md index 763147df6d922..355bd502df3be 100644 --- a/src/plugins/expressions/public/public.api.md +++ b/src/plugins/expressions/public/public.api.md @@ -189,10 +189,11 @@ export interface ExecutionState extends ExecutorState state: 'not-started' | 'pending' | 'result' | 'error'; } +// Warning: (ae-forgotten-export) The symbol "PersistableState" needs to be exported by the entry point index.d.ts // Warning: (ae-missing-release-tag) "Executor" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) -export class Executor = Record> { +export class Executor = Record> implements PersistableState { constructor(state?: ExecutorState); // (undocumented) get context(): Record; @@ -203,6 +204,11 @@ export class Executor = Record): void; // (undocumented) + extract(ast: ExpressionAstExpression): { + state: ExpressionAstExpression; + references: SavedObjectReference[]; + }; + // (undocumented) fork(): Executor; // @deprecated (undocumented) readonly functions: FunctionsRegistry; @@ -214,6 +220,10 @@ export class Executor = Record; + // Warning: (ae-forgotten-export) The symbol "SavedObjectReference" needs to be exported by the entry point index.d.ts + // + // (undocumented) + inject(ast: ExpressionAstExpression, references: SavedObjectReference[]): ExpressionAstExpression; // (undocumented) registerFunction(functionDefinition: AnyExpressionFunctionDefinition | (() => AnyExpressionFunctionDefinition)): void; // (undocumented) @@ -221,9 +231,11 @@ export class Executor = Record = Record>(ast: string | ExpressionAstExpression, input: Input, context?: ExtraContext): Promise; // (undocumented) readonly state: ExecutorContainer; + // (undocumented) + telemetry(ast: ExpressionAstExpression, telemetryData: Record): Record; // @deprecated (undocumented) readonly types: TypesRegistry; -} + } // Warning: (ae-forgotten-export) The symbol "ExecutorPureTransitions" needs to be exported by the entry point index.d.ts // Warning: (ae-forgotten-export) The symbol "ExecutorPureSelectors" needs to be exported by the entry point index.d.ts @@ -252,12 +264,10 @@ export type ExpressionAstArgument = string | boolean | number | ExpressionAstExp // Warning: (ae-missing-release-tag) "ExpressionAstExpression" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) -export interface ExpressionAstExpression { - // (undocumented) - chain: ExpressionAstFunction[]; - // (undocumented) +export type ExpressionAstExpression = { type: 'expression'; -} + chain: ExpressionAstFunction[]; +}; // Warning: (ae-missing-release-tag) "ExpressionAstExpressionBuilder" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // @@ -273,16 +283,12 @@ export interface ExpressionAstExpressionBuilder { // Warning: (ae-missing-release-tag) "ExpressionAstFunction" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) -export interface ExpressionAstFunction { - // (undocumented) +export type ExpressionAstFunction = { + type: 'function'; + function: string; arguments: Record; - // Warning: (ae-forgotten-export) The symbol "ExpressionAstFunctionDebug" needs to be exported by the entry point index.d.ts debug?: ExpressionAstFunctionDebug; - // (undocumented) - function: string; - // (undocumented) - type: 'function'; -} +}; // Warning: (ae-missing-release-tag) "ExpressionAstFunctionBuilder" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // @@ -320,23 +326,35 @@ export interface ExpressionExecutor { // Warning: (ae-missing-release-tag) "ExpressionFunction" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) -export class ExpressionFunction { +export class ExpressionFunction implements PersistableState { constructor(functionDefinition: AnyExpressionFunctionDefinition); // (undocumented) accepts: (type: string) => boolean; aliases: string[]; args: Record; + // (undocumented) + disabled: boolean; + // (undocumented) + extract: (state: ExpressionAstFunction['arguments']) => { + state: ExpressionAstFunction['arguments']; + references: SavedObjectReference[]; + }; fn: (input: ExpressionValue, params: Record, handlers: object) => ExpressionValue; help: string; + // (undocumented) + inject: (state: ExpressionAstFunction['arguments'], references: SavedObjectReference[]) => ExpressionAstFunction['arguments']; inputTypes: string[] | undefined; name: string; + // (undocumented) + telemetry: (state: ExpressionAstFunction['arguments'], telemetryData: Record) => Record; type: string; } +// Warning: (ae-forgotten-export) The symbol "PersistableStateDefinition" needs to be exported by the entry point index.d.ts // Warning: (ae-missing-release-tag) "ExpressionFunctionDefinition" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public -export interface ExpressionFunctionDefinition, Output, Context extends ExecutionContext = ExecutionContext> { +export interface ExpressionFunctionDefinition, Output, Context extends ExecutionContext = ExecutionContext> extends PersistableStateDefinition { aliases?: string[]; args: { [key in keyof Arguments]: ArgumentType; @@ -345,6 +363,7 @@ export interface ExpressionFunctionDefinition>; @@ -540,13 +559,17 @@ export { ExpressionsPublicPlugin as Plugin } // Warning: (ae-missing-release-tag) "ExpressionsService" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public -export class ExpressionsService { +export class ExpressionsService implements PersistableState { // Warning: (ae-forgotten-export) The symbol "ExpressionServiceParams" needs to be exported by the entry point index.d.ts constructor({ executor, renderers, }?: ExpressionServiceParams); // (undocumented) readonly execute: ExpressionsServiceStart['execute']; // (undocumented) readonly executor: Executor; + readonly extract: (state: ExpressionAstExpression) => { + state: ExpressionAstExpression; + references: SavedObjectReference[]; + }; // (undocumented) readonly fork: () => ExpressionsService; // (undocumented) @@ -558,6 +581,7 @@ export class ExpressionsService { // (undocumented) readonly getType: ExpressionsServiceStart['getType']; readonly getTypes: () => ReturnType; + readonly inject: (state: ExpressionAstExpression, references: SavedObjectReference[]) => ExpressionAstExpression; readonly registerFunction: (functionDefinition: AnyExpressionFunctionDefinition | (() => AnyExpressionFunctionDefinition)) => void; // (undocumented) readonly registerRenderer: (definition: AnyExpressionRenderDefinition | (() => AnyExpressionRenderDefinition)) => void; @@ -571,6 +595,7 @@ export class ExpressionsService { start(): ExpressionsServiceStart; // (undocumented) stop(): void; + readonly telemetry: (state: ExpressionAstExpression, telemetryData?: Record) => Record; } // Warning: (ae-missing-release-tag) "ExpressionsServiceSetup" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) @@ -705,14 +730,8 @@ export type ExpressionValueConverter; // Warning: (ae-missing-release-tag) "ExpressionValueFilter" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) @@ -1162,6 +1181,12 @@ export type TypeToString = KnownTypeToString | UnmappedTypeStrings; export type UnmappedTypeStrings = 'date' | 'filter'; +// Warnings were encountered during analysis: +// +// src/plugins/expressions/common/ast/types.ts:40:3 - (ae-forgotten-export) The symbol "ExpressionAstFunctionDebug" needs to be exported by the entry point index.d.ts +// src/plugins/expressions/common/expression_types/specs/error.ts:31:5 - (ae-forgotten-export) The symbol "ErrorLike" needs to be exported by the entry point index.d.ts +// src/plugins/expressions/common/expression_types/specs/error.ts:32:5 - (ae-forgotten-export) The symbol "SerializableState" needs to be exported by the entry point index.d.ts + // (No @packageDocumentation comment for this package) ``` diff --git a/src/plugins/expressions/server/server.api.md b/src/plugins/expressions/server/server.api.md index 8266789664d44..1a905de4a3bdf 100644 --- a/src/plugins/expressions/server/server.api.md +++ b/src/plugins/expressions/server/server.api.md @@ -171,10 +171,11 @@ export interface ExecutionState extends ExecutorState state: 'not-started' | 'pending' | 'result' | 'error'; } +// Warning: (ae-forgotten-export) The symbol "PersistableState" needs to be exported by the entry point index.d.ts // Warning: (ae-missing-release-tag) "Executor" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) -export class Executor = Record> { +export class Executor = Record> implements PersistableState { constructor(state?: ExecutorState); // (undocumented) get context(): Record; @@ -185,6 +186,11 @@ export class Executor = Record): void; // (undocumented) + extract(ast: ExpressionAstExpression): { + state: ExpressionAstExpression; + references: SavedObjectReference[]; + }; + // (undocumented) fork(): Executor; // @deprecated (undocumented) readonly functions: FunctionsRegistry; @@ -196,6 +202,10 @@ export class Executor = Record; + // Warning: (ae-forgotten-export) The symbol "SavedObjectReference" needs to be exported by the entry point index.d.ts + // + // (undocumented) + inject(ast: ExpressionAstExpression, references: SavedObjectReference[]): ExpressionAstExpression; // (undocumented) registerFunction(functionDefinition: AnyExpressionFunctionDefinition | (() => AnyExpressionFunctionDefinition)): void; // (undocumented) @@ -203,9 +213,11 @@ export class Executor = Record = Record>(ast: string | ExpressionAstExpression, input: Input, context?: ExtraContext): Promise; // (undocumented) readonly state: ExecutorContainer; + // (undocumented) + telemetry(ast: ExpressionAstExpression, telemetryData: Record): Record; // @deprecated (undocumented) readonly types: TypesRegistry; -} + } // Warning: (ae-forgotten-export) The symbol "ExecutorPureTransitions" needs to be exported by the entry point index.d.ts // Warning: (ae-forgotten-export) The symbol "ExecutorPureSelectors" needs to be exported by the entry point index.d.ts @@ -234,12 +246,10 @@ export type ExpressionAstArgument = string | boolean | number | ExpressionAstExp // Warning: (ae-missing-release-tag) "ExpressionAstExpression" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) -export interface ExpressionAstExpression { - // (undocumented) - chain: ExpressionAstFunction[]; - // (undocumented) +export type ExpressionAstExpression = { type: 'expression'; -} + chain: ExpressionAstFunction[]; +}; // Warning: (ae-missing-release-tag) "ExpressionAstExpressionBuilder" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // @@ -255,16 +265,12 @@ export interface ExpressionAstExpressionBuilder { // Warning: (ae-missing-release-tag) "ExpressionAstFunction" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) -export interface ExpressionAstFunction { - // (undocumented) +export type ExpressionAstFunction = { + type: 'function'; + function: string; arguments: Record; - // Warning: (ae-forgotten-export) The symbol "ExpressionAstFunctionDebug" needs to be exported by the entry point index.d.ts debug?: ExpressionAstFunctionDebug; - // (undocumented) - function: string; - // (undocumented) - type: 'function'; -} +}; // Warning: (ae-missing-release-tag) "ExpressionAstFunctionBuilder" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // @@ -292,23 +298,35 @@ export type ExpressionAstNode = ExpressionAstExpression | ExpressionAstFunction // Warning: (ae-missing-release-tag) "ExpressionFunction" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) -export class ExpressionFunction { +export class ExpressionFunction implements PersistableState { constructor(functionDefinition: AnyExpressionFunctionDefinition); // (undocumented) accepts: (type: string) => boolean; aliases: string[]; args: Record; + // (undocumented) + disabled: boolean; + // (undocumented) + extract: (state: ExpressionAstFunction['arguments']) => { + state: ExpressionAstFunction['arguments']; + references: SavedObjectReference[]; + }; fn: (input: ExpressionValue, params: Record, handlers: object) => ExpressionValue; help: string; + // (undocumented) + inject: (state: ExpressionAstFunction['arguments'], references: SavedObjectReference[]) => ExpressionAstFunction['arguments']; inputTypes: string[] | undefined; name: string; + // (undocumented) + telemetry: (state: ExpressionAstFunction['arguments'], telemetryData: Record) => Record; type: string; } +// Warning: (ae-forgotten-export) The symbol "PersistableStateDefinition" needs to be exported by the entry point index.d.ts // Warning: (ae-missing-release-tag) "ExpressionFunctionDefinition" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public -export interface ExpressionFunctionDefinition, Output, Context extends ExecutionContext = ExecutionContext> { +export interface ExpressionFunctionDefinition, Output, Context extends ExecutionContext = ExecutionContext> extends PersistableStateDefinition { aliases?: string[]; args: { [key in keyof Arguments]: ArgumentType; @@ -317,6 +335,7 @@ export interface ExpressionFunctionDefinition>; @@ -565,14 +584,8 @@ export type ExpressionValueConverter; // Warning: (ae-missing-release-tag) "ExpressionValueFilter" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) @@ -966,6 +979,12 @@ export type TypeToString = KnownTypeToString | UnmappedTypeStrings; export type UnmappedTypeStrings = 'date' | 'filter'; +// Warnings were encountered during analysis: +// +// src/plugins/expressions/common/ast/types.ts:40:3 - (ae-forgotten-export) The symbol "ExpressionAstFunctionDebug" needs to be exported by the entry point index.d.ts +// src/plugins/expressions/common/expression_types/specs/error.ts:31:5 - (ae-forgotten-export) The symbol "ErrorLike" needs to be exported by the entry point index.d.ts +// src/plugins/expressions/common/expression_types/specs/error.ts:32:5 - (ae-forgotten-export) The symbol "SerializableState" needs to be exported by the entry point index.d.ts + // (No @packageDocumentation comment for this package) ```