Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC] Allow 'leasing' of Expression constructs #105164

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-plugins-expressions-public](./kibana-plugin-plugins-expressions-public.md) &gt; [Executor](./kibana-plugin-plugins-expressions-public.executor.md) &gt; [leaseFunctions](./kibana-plugin-plugins-expressions-public.executor.leasefunctions.md)

## Executor.leaseFunctions() method

Register a collection of functions meant to be deregegistered by the registering context, when they are no longer to be used, which can be done with the callback returned.

<b>Signature:</b>

```typescript
leaseFunctions(functionDefinitions: FunctionDefinition[]): () => ExecutorState<Record<string, unknown>>;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| functionDefinitions | <code>FunctionDefinition[]</code> | |

<b>Returns:</b>

`() => ExecutorState<Record<string, unknown>>`

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-plugins-expressions-public](./kibana-plugin-plugins-expressions-public.md) &gt; [Executor](./kibana-plugin-plugins-expressions-public.executor.md) &gt; [leaseTypes](./kibana-plugin-plugins-expressions-public.executor.leasetypes.md)

## Executor.leaseTypes() method

Register a collection of types meant to be deregegistered by the registering context when they are no longer to be used, which can be done with the callback returned.

<b>Signature:</b>

```typescript
leaseTypes(typeDefinitions: TypeDefinition[]): () => ExecutorState<Record<string, unknown>>;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| typeDefinitions | <code>TypeDefinition[]</code> | |

<b>Returns:</b>

`() => ExecutorState<Record<string, unknown>>`

Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,13 @@ export declare class Executor<Context extends Record<string, unknown> = Record<s
| [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) | | |
| [leaseFunctions(functionDefinitions)](./kibana-plugin-plugins-expressions-public.executor.leasefunctions.md) | | Register a collection of functions meant to be deregegistered by the registering context, when they are no longer to be used, which can be done with the callback returned. |
| [leaseTypes(typeDefinitions)](./kibana-plugin-plugins-expressions-public.executor.leasetypes.md) | | Register a collection of types meant to be deregegistered by the registering context when they are no longer to be used, which can be done with the callback returned. |
| [migrate(ast, version)](./kibana-plugin-plugins-expressions-public.executor.migrate.md) | | |
| [registerFunction(functionDefinition)](./kibana-plugin-plugins-expressions-public.executor.registerfunction.md) | | |
| [registerType(typeDefinition)](./kibana-plugin-plugins-expressions-public.executor.registertype.md) | | |
| [registerFunction(functionDefinition)](./kibana-plugin-plugins-expressions-public.executor.registerfunction.md) | | Register a single function with the executor. |
| [registerFunctions(functionDefinitions)](./kibana-plugin-plugins-expressions-public.executor.registerfunctions.md) | | Register a collection of functions with the executor. |
| [registerType(typeDefinition)](./kibana-plugin-plugins-expressions-public.executor.registertype.md) | | Register a single type with the executor. |
| [registerTypes(typeDefinitions)](./kibana-plugin-plugins-expressions-public.executor.registertypes.md) | | Register a collection of types with the executor. |
| [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) | | |

Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@

## Executor.registerFunction() method

Register a single function with the executor.

<b>Signature:</b>

```typescript
registerFunction(functionDefinition: AnyExpressionFunctionDefinition | (() => AnyExpressionFunctionDefinition)): void;
registerFunction(functionDefinition: FunctionDefinition): void;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| functionDefinition | <code>AnyExpressionFunctionDefinition &#124; (() =&gt; AnyExpressionFunctionDefinition)</code> | |
| functionDefinition | <code>FunctionDefinition</code> | |

<b>Returns:</b>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-plugins-expressions-public](./kibana-plugin-plugins-expressions-public.md) &gt; [Executor](./kibana-plugin-plugins-expressions-public.executor.md) &gt; [registerFunctions](./kibana-plugin-plugins-expressions-public.executor.registerfunctions.md)

## Executor.registerFunctions() method

Register a collection of functions with the executor.

<b>Signature:</b>

```typescript
registerFunctions(functionDefinitions: FunctionDefinition[]): void;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| functionDefinitions | <code>FunctionDefinition[]</code> | |

<b>Returns:</b>

`void`

Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@

## Executor.registerType() method

Register a single type with the executor.

<b>Signature:</b>

```typescript
registerType(typeDefinition: AnyExpressionTypeDefinition | (() => AnyExpressionTypeDefinition)): void;
registerType(typeDefinition: TypeDefinition): void;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| typeDefinition | <code>AnyExpressionTypeDefinition &#124; (() =&gt; AnyExpressionTypeDefinition)</code> | |
| typeDefinition | <code>TypeDefinition</code> | |

<b>Returns:</b>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-plugins-expressions-public](./kibana-plugin-plugins-expressions-public.md) &gt; [Executor](./kibana-plugin-plugins-expressions-public.executor.md) &gt; [registerTypes](./kibana-plugin-plugins-expressions-public.executor.registertypes.md)

## Executor.registerTypes() method

Register a collection of types with the executor.

<b>Signature:</b>

```typescript
registerTypes(typeDefinitions: TypeDefinition[]): void;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| typeDefinitions | <code>TypeDefinition[]</code> | |

<b>Returns:</b>

`void`

Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export declare class ExpressionRendererRegistry implements IRegistry<ExpressionR
| --- | --- | --- |
| [get(id)](./kibana-plugin-plugins-expressions-public.expressionrendererregistry.get.md) | | |
| [register(definition)](./kibana-plugin-plugins-expressions-public.expressionrendererregistry.register.md) | | |
| [remove(name)](./kibana-plugin-plugins-expressions-public.expressionrendererregistry.remove.md) | | |
| [toArray()](./kibana-plugin-plugins-expressions-public.expressionrendererregistry.toarray.md) | | |
| [toJS()](./kibana-plugin-plugins-expressions-public.expressionrendererregistry.tojs.md) | | |

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-plugins-expressions-public](./kibana-plugin-plugins-expressions-public.md) &gt; [ExpressionRendererRegistry](./kibana-plugin-plugins-expressions-public.expressionrendererregistry.md) &gt; [remove](./kibana-plugin-plugins-expressions-public.expressionrendererregistry.remove.md)

## ExpressionRendererRegistry.remove() method

<b>Signature:</b>

```typescript
remove(name: string): void;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| name | <code>string</code> | |

<b>Returns:</b>

`void`

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-plugins-expressions-public](./kibana-plugin-plugins-expressions-public.md) &gt; [ExpressionsService](./kibana-plugin-plugins-expressions-public.expressionsservice.md) &gt; [leaseFunctions](./kibana-plugin-plugins-expressions-public.expressionsservice.leasefunctions.md)

## ExpressionsService.leaseFunctions property

Register a collection of expression functions that are meant to be deregistered by the registering context, (e.g. a plugin leases on mount and deregisters on unmount). This call returns a simple callback to make registering easier.

<b>Signature:</b>

```typescript
readonly leaseFunctions: Executor['leaseFunctions'];
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-plugins-expressions-public](./kibana-plugin-plugins-expressions-public.md) &gt; [ExpressionsService](./kibana-plugin-plugins-expressions-public.expressionsservice.md) &gt; [leaseRenderers](./kibana-plugin-plugins-expressions-public.expressionsservice.leaserenderers.md)

## ExpressionsService.leaseRenderers property

<b>Signature:</b>

```typescript
readonly leaseRenderers: (definitions: Array<AnyExpressionRenderDefinition | (() => AnyExpressionRenderDefinition)>) => () => void;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-plugins-expressions-public](./kibana-plugin-plugins-expressions-public.md) &gt; [ExpressionsService](./kibana-plugin-plugins-expressions-public.expressionsservice.md) &gt; [leaseTypes](./kibana-plugin-plugins-expressions-public.expressionsservice.leasetypes.md)

## ExpressionsService.leaseTypes property

<b>Signature:</b>

```typescript
readonly leaseTypes: Executor['leaseTypes'];
```
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,11 @@ export declare class ExpressionsService implements PersistableStateService<Expre
| [getType](./kibana-plugin-plugins-expressions-public.expressionsservice.gettype.md) | | <code>ExpressionsServiceStart['getType']</code> | |
| [getTypes](./kibana-plugin-plugins-expressions-public.expressionsservice.gettypes.md) | | <code>() =&gt; ReturnType&lt;Executor['getTypes']&gt;</code> | Returns POJO map of all registered expression types, where keys are names of the types and values are <code>ExpressionType</code> instances. |
| [inject](./kibana-plugin-plugins-expressions-public.expressionsservice.inject.md) | | <code>(state: ExpressionAstExpression, references: SavedObjectReference[]) =&gt; ExpressionAstExpression</code> | Injects saved object references into expression AST |
| [leaseFunctions](./kibana-plugin-plugins-expressions-public.expressionsservice.leasefunctions.md) | | <code>Executor['leaseFunctions']</code> | Register a collection of expression functions that are meant to be deregistered by the registering context, (e.g. a plugin leases on mount and deregisters on unmount). This call returns a simple callback to make registering easier. |
| [leaseRenderers](./kibana-plugin-plugins-expressions-public.expressionsservice.leaserenderers.md) | | <code>(definitions: Array&lt;AnyExpressionRenderDefinition &#124; (() =&gt; AnyExpressionRenderDefinition)&gt;) =&gt; () =&gt; void</code> | |
| [leaseTypes](./kibana-plugin-plugins-expressions-public.expressionsservice.leasetypes.md) | | <code>Executor['leaseTypes']</code> | |
| [migrate](./kibana-plugin-plugins-expressions-public.expressionsservice.migrate.md) | | <code>(state: SerializableState, version: string) =&gt; ExpressionAstExpression</code> | Runs the migration (if it exists) for specified version. This will run a single migration step (ie from 7.10.0 to 7.10.1) |
| [registerFunction](./kibana-plugin-plugins-expressions-public.expressionsservice.registerfunction.md) | | <code>(functionDefinition: AnyExpressionFunctionDefinition &#124; (() =&gt; AnyExpressionFunctionDefinition)) =&gt; void</code> | 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.
| [registerFunction](./kibana-plugin-plugins-expressions-public.expressionsservice.registerfunction.md) | | <code>Executor['registerFunction']</code> | 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({
name: 'sleep',
Expand All @@ -60,8 +63,11 @@ expressions.registerFunction({

```
The actual function is defined in the <code>fn</code> key. The function can be \*async\*. It receives three arguments: (1) <code>input</code> is the output of the previous function or the initial input of the expression if the function is first in chain; (2) <code>args</code> are function arguments as defined in expression string, that can be edited by user (e.g in case of Canvas); (3) <code>context</code> is a shared object passed to all functions that can be used for side-effects. |
| [registerRenderer](./kibana-plugin-plugins-expressions-public.expressionsservice.registerrenderer.md) | | <code>(definition: AnyExpressionRenderDefinition &#124; (() =&gt; AnyExpressionRenderDefinition)) =&gt; void</code> | |
| [registerType](./kibana-plugin-plugins-expressions-public.expressionsservice.registertype.md) | | <code>(typeDefinition: AnyExpressionTypeDefinition &#124; (() =&gt; AnyExpressionTypeDefinition)) =&gt; void</code> | |
| [registerFunctions](./kibana-plugin-plugins-expressions-public.expressionsservice.registerfunctions.md) | | <code>Executor['registerFunctions']</code> | Register a collection of expression functions. See <code>registerFunction</code> for details. |
| [registerRenderer](./kibana-plugin-plugins-expressions-public.expressionsservice.registerrenderer.md) | | <code>ExpressionRendererRegistry['register']</code> | |
| [registerRenderers](./kibana-plugin-plugins-expressions-public.expressionsservice.registerrenderers.md) | | <code>(definitions: Array&lt;AnyExpressionRenderDefinition &#124; (() =&gt; AnyExpressionRenderDefinition)&gt;) =&gt; void</code> | |
| [registerType](./kibana-plugin-plugins-expressions-public.expressionsservice.registertype.md) | | <code>Executor['registerType']</code> | |
| [registerTypes](./kibana-plugin-plugins-expressions-public.expressionsservice.registertypes.md) | | <code>Executor['registerTypes']</code> | |
| [renderers](./kibana-plugin-plugins-expressions-public.expressionsservice.renderers.md) | | <code>ExpressionRendererRegistry</code> | |
| [run](./kibana-plugin-plugins-expressions-public.expressionsservice.run.md) | | <code>ExpressionsServiceStart['run']</code> | |
| [telemetry](./kibana-plugin-plugins-expressions-public.expressionsservice.telemetry.md) | | <code>(state: ExpressionAstExpression, telemetryData?: Record&lt;string, any&gt;) =&gt; Record&lt;string, any&gt;</code> | Extracts telemetry from expression AST |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ The actual function is defined in the `fn` key. The function can be \*async\*. I
<b>Signature:</b>

```typescript
readonly registerFunction: (functionDefinition: AnyExpressionFunctionDefinition | (() => AnyExpressionFunctionDefinition)) => void;
readonly registerFunction: Executor['registerFunction'];
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-plugins-expressions-public](./kibana-plugin-plugins-expressions-public.md) &gt; [ExpressionsService](./kibana-plugin-plugins-expressions-public.expressionsservice.md) &gt; [registerFunctions](./kibana-plugin-plugins-expressions-public.expressionsservice.registerfunctions.md)

## ExpressionsService.registerFunctions property

Register a collection of expression functions. See `registerFunction` for details.

<b>Signature:</b>

```typescript
readonly registerFunctions: Executor['registerFunctions'];
```
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
<b>Signature:</b>

```typescript
readonly registerRenderer: (definition: AnyExpressionRenderDefinition | (() => AnyExpressionRenderDefinition)) => void;
readonly registerRenderer: ExpressionRendererRegistry['register'];
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-plugins-expressions-public](./kibana-plugin-plugins-expressions-public.md) &gt; [ExpressionsService](./kibana-plugin-plugins-expressions-public.expressionsservice.md) &gt; [registerRenderers](./kibana-plugin-plugins-expressions-public.expressionsservice.registerrenderers.md)

## ExpressionsService.registerRenderers property

<b>Signature:</b>

```typescript
readonly registerRenderers: (definitions: Array<AnyExpressionRenderDefinition | (() => AnyExpressionRenderDefinition)>) => void;
```
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
<b>Signature:</b>

```typescript
readonly registerType: (typeDefinition: AnyExpressionTypeDefinition | (() => AnyExpressionTypeDefinition)) => void;
readonly registerType: Executor['registerType'];
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-plugins-expressions-public](./kibana-plugin-plugins-expressions-public.md) &gt; [ExpressionsService](./kibana-plugin-plugins-expressions-public.expressionsservice.md) &gt; [registerTypes](./kibana-plugin-plugins-expressions-public.expressionsservice.registertypes.md)

## ExpressionsService.registerTypes property

<b>Signature:</b>

```typescript
readonly registerTypes: Executor['registerTypes'];
```
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ The public contract that `ExpressionsService` provides to other plugins in Kiban
<b>Signature:</b>

```typescript
export declare type ExpressionsServiceSetup = Pick<ExpressionsService, 'getFunction' | 'getFunctions' | 'getRenderer' | 'getRenderers' | 'getType' | 'getTypes' | 'registerFunction' | 'registerRenderer' | 'registerType' | 'run' | 'fork'>;
export declare type ExpressionsServiceSetup = Pick<ExpressionsService, 'getFunction' | 'getFunctions' | 'leaseFunctions' | 'getRenderer' | 'getRenderers' | 'getType' | 'getTypes' | 'leaseTypes' | 'registerFunction' | 'registerFunctions' | 'registerRenderer' | 'registerRenderers' | 'leaseRenderers' | 'registerType' | 'registerTypes' | 'run' | 'fork'>;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-plugins-expressions-server](./kibana-plugin-plugins-expressions-server.md) &gt; [Executor](./kibana-plugin-plugins-expressions-server.executor.md) &gt; [leaseFunctions](./kibana-plugin-plugins-expressions-server.executor.leasefunctions.md)

## Executor.leaseFunctions() method

Register a collection of functions meant to be deregegistered by the registering context, when they are no longer to be used, which can be done with the callback returned.

<b>Signature:</b>

```typescript
leaseFunctions(functionDefinitions: FunctionDefinition[]): () => ExecutorState<Record<string, unknown>>;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| functionDefinitions | <code>FunctionDefinition[]</code> | |

<b>Returns:</b>

`() => ExecutorState<Record<string, unknown>>`

Loading