Skip to content

Commit

Permalink
[7.x] 「AppArch」Interpreter 👉 New Platform (#39329) (#40117)
Browse files Browse the repository at this point in the history
* 「AppArch」Interpreter 👉 New Platform (#39329)

* feat: 🎸 set-up NP data plugin

* refactor: 💡 move interpreter functions registry to NP

* refactor: 💡 move interpreter renderer registry to NP plugin

* refactor: 💡 move interpreter typesRegistry to NP

* refactor: 💡 move interpreter types to NP

* chore: 🤖 import typeRegistry from NP and change TS type folder

* refactor: 💡 move interpreter expression types to NP

* refactor: 💡 move rest of interpreter common folder to NP plugin

* fix: 🐛 fix TypeScript errors

* test: 💍 improve typings and test mocks

* refactor: 💡 make Interpreter internal registry impl private

* test: 💍 inline NP backdoor mock creation in test suites

* chore: 🤖 change @kbn/interpreter import paths to try fix errors

* fix: 🐛 improve core Plugin interfaces

* feat: 🎸 add stop() lifecycle to NP data plugins

* refactor: 💡 move interpreter into expressions service data NP

* refactor: 💡 inline Registry @kbn/interpreter class

* refactor: 💡 remove dependency on @kbn/interpreter in data pub

* refactor: 💡 move interpreter common dir into expressions dir

* fix: 🐛 use TS types in kibana_context

* feat: 🎸 add types suggested in PR review

* feat: 🎸 add semantic interpreter registration functions

* refactor: 💡 use require for all @kbn/interpreter imports

* test: 💍 add Karma test mocks, thx @spalger 🙏

* docs: ✏️ update Core docs

* test: 💍 add Sinon stubs for registries

* chore: 🤖 change import syntax in hopes CI will work

* chore: 🤖 set App Architecture as owners of data plugin

* docs: ✏️ add README

* chore: 🤖 change import in hopes to fix optimizer

* fix: 🐛 make stop() plugin life-cycle optional

* docs: ✏️ update Core API docs

* test: 💍 remove unnecessary Jest mock

* chore: 🤖 don't import from deeply inside a plugin

* refactor: 💡 try different interpreter import

* fix: 🐛 fix Karma mocking

* fix: 🐛 fix TypeScript type imports

* test: 💍 fix broken test

* fix: 🐛 use "kibana" version to make it work everywhere

* style: 💄 fix linter error
  • Loading branch information
streamich authored Jul 8, 2019
1 parent 4a4d29e commit b057a93
Show file tree
Hide file tree
Showing 82 changed files with 1,041 additions and 405 deletions.
14 changes: 7 additions & 7 deletions docs/development/core/public/kibana-plugin-public.plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ The interface that should be returned by a `PluginInitializer`<!-- -->.
<b>Signature:</b>

```typescript
export interface Plugin<TSetup, TStart, TPluginsSetup extends Record<string, unknown> = {}, TPluginsStart extends Record<string, unknown> = {}>
export interface Plugin<TSetup = void, TStart = void, TPluginsSetup extends {} = {}, TPluginsStart extends {} = {}>
```

## Properties
## Methods

| Property | Type | Description |
| --- | --- | --- |
| [setup](./kibana-plugin-public.plugin.setup.md) | <code>(core: CoreSetup, plugins: TPluginsSetup) =&gt; TSetup &#124; Promise&lt;TSetup&gt;</code> | |
| [start](./kibana-plugin-public.plugin.start.md) | <code>(core: CoreStart, plugins: TPluginsStart) =&gt; TStart &#124; Promise&lt;TStart&gt;</code> | |
| [stop](./kibana-plugin-public.plugin.stop.md) | <code>() =&gt; void</code> | |
| Method | Description |
| --- | --- |
| [setup(core, plugins)](./kibana-plugin-public.plugin.setup.md) | |
| [start(core, plugins)](./kibana-plugin-public.plugin.start.md) | |
| [stop()](./kibana-plugin-public.plugin.stop.md) | |

16 changes: 14 additions & 2 deletions docs/development/core/public/kibana-plugin-public.plugin.setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,22 @@

[Home](./index.md) &gt; [kibana-plugin-public](./kibana-plugin-public.md) &gt; [Plugin](./kibana-plugin-public.plugin.md) &gt; [setup](./kibana-plugin-public.plugin.setup.md)

## Plugin.setup property
## Plugin.setup() method

<b>Signature:</b>

```typescript
setup: (core: CoreSetup, plugins: TPluginsSetup) => TSetup | Promise<TSetup>;
setup(core: CoreSetup, plugins: TPluginsSetup): TSetup | Promise<TSetup>;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| core | <code>CoreSetup</code> | |
| plugins | <code>TPluginsSetup</code> | |

<b>Returns:</b>

`TSetup | Promise<TSetup>`

16 changes: 14 additions & 2 deletions docs/development/core/public/kibana-plugin-public.plugin.start.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,22 @@

[Home](./index.md) &gt; [kibana-plugin-public](./kibana-plugin-public.md) &gt; [Plugin](./kibana-plugin-public.plugin.md) &gt; [start](./kibana-plugin-public.plugin.start.md)

## Plugin.start property
## Plugin.start() method

<b>Signature:</b>

```typescript
start: (core: CoreStart, plugins: TPluginsStart) => TStart | Promise<TStart>;
start(core: CoreStart, plugins: TPluginsStart): TStart | Promise<TStart>;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| core | <code>CoreStart</code> | |
| plugins | <code>TPluginsStart</code> | |

<b>Returns:</b>

`TStart | Promise<TStart>`

Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@

[Home](./index.md) &gt; [kibana-plugin-public](./kibana-plugin-public.md) &gt; [Plugin](./kibana-plugin-public.plugin.md) &gt; [stop](./kibana-plugin-public.plugin.stop.md)

## Plugin.stop property
## Plugin.stop() method

<b>Signature:</b>

```typescript
stop?: () => void;
stop?(): void;
```
<b>Returns:</b>
`void`
14 changes: 7 additions & 7 deletions docs/development/core/server/kibana-plugin-server.plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ The interface that should be returned by a `PluginInitializer`<!-- -->.
<b>Signature:</b>

```typescript
export interface Plugin<TSetup, TStart, TPluginsSetup extends Record<PluginName, unknown> = {}, TPluginsStart extends Record<PluginName, unknown> = {}>
export interface Plugin<TSetup = void, TStart = void, TPluginsSetup extends {} = {}, TPluginsStart extends {} = {}>
```

## Properties
## Methods

| Property | Type | Description |
| --- | --- | --- |
| [setup](./kibana-plugin-server.plugin.setup.md) | <code>(core: CoreSetup, plugins: TPluginsSetup) =&gt; TSetup &#124; Promise&lt;TSetup&gt;</code> | |
| [start](./kibana-plugin-server.plugin.start.md) | <code>(core: CoreStart, plugins: TPluginsStart) =&gt; TStart &#124; Promise&lt;TStart&gt;</code> | |
| [stop](./kibana-plugin-server.plugin.stop.md) | <code>() =&gt; void</code> | |
| Method | Description |
| --- | --- |
| [setup(core, plugins)](./kibana-plugin-server.plugin.setup.md) | |
| [start(core, plugins)](./kibana-plugin-server.plugin.start.md) | |
| [stop()](./kibana-plugin-server.plugin.stop.md) | |

16 changes: 14 additions & 2 deletions docs/development/core/server/kibana-plugin-server.plugin.setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,22 @@

[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [Plugin](./kibana-plugin-server.plugin.md) &gt; [setup](./kibana-plugin-server.plugin.setup.md)

## Plugin.setup property
## Plugin.setup() method

<b>Signature:</b>

```typescript
setup: (core: CoreSetup, plugins: TPluginsSetup) => TSetup | Promise<TSetup>;
setup(core: CoreSetup, plugins: TPluginsSetup): TSetup | Promise<TSetup>;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| core | <code>CoreSetup</code> | |
| plugins | <code>TPluginsSetup</code> | |

<b>Returns:</b>

`TSetup | Promise<TSetup>`

16 changes: 14 additions & 2 deletions docs/development/core/server/kibana-plugin-server.plugin.start.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,22 @@

[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [Plugin](./kibana-plugin-server.plugin.md) &gt; [start](./kibana-plugin-server.plugin.start.md)

## Plugin.start property
## Plugin.start() method

<b>Signature:</b>

```typescript
start: (core: CoreStart, plugins: TPluginsStart) => TStart | Promise<TStart>;
start(core: CoreStart, plugins: TPluginsStart): TStart | Promise<TStart>;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| core | <code>CoreStart</code> | |
| plugins | <code>TPluginsStart</code> | |

<b>Returns:</b>

`TStart | Promise<TStart>`

Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@

[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [Plugin](./kibana-plugin-server.plugin.md) &gt; [stop](./kibana-plugin-server.plugin.stop.md)

## Plugin.stop property
## Plugin.stop() method

<b>Signature:</b>

```typescript
stop?: () => void;
stop?(): void;
```
<b>Returns:</b>
`void`
14 changes: 7 additions & 7 deletions src/core/public/plugins/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ import { CoreStart, CoreSetup } from '..';
* @public
*/
export interface Plugin<
TSetup,
TStart,
TPluginsSetup extends Record<string, unknown> = {},
TPluginsStart extends Record<string, unknown> = {}
TSetup = void,
TStart = void,
TPluginsSetup extends {} = {},
TPluginsStart extends {} = {}
> {
setup: (core: CoreSetup, plugins: TPluginsSetup) => TSetup | Promise<TSetup>;
start: (core: CoreStart, plugins: TPluginsStart) => TStart | Promise<TStart>;
stop?: () => void;
setup(core: CoreSetup, plugins: TPluginsSetup): TSetup | Promise<TSetup>;
start(core: CoreStart, plugins: TPluginsStart): TStart | Promise<TStart>;
stop?(): void;
}

/**
Expand Down
8 changes: 4 additions & 4 deletions src/core/public/public.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -475,13 +475,13 @@ export interface OverlayStart {
}

// @public
export interface Plugin<TSetup, TStart, TPluginsSetup extends Record<string, unknown> = {}, TPluginsStart extends Record<string, unknown> = {}> {
export interface Plugin<TSetup = void, TStart = void, TPluginsSetup extends {} = {}, TPluginsStart extends {} = {}> {
// (undocumented)
setup: (core: CoreSetup, plugins: TPluginsSetup) => TSetup | Promise<TSetup>;
setup(core: CoreSetup, plugins: TPluginsSetup): TSetup | Promise<TSetup>;
// (undocumented)
start: (core: CoreStart, plugins: TPluginsStart) => TStart | Promise<TStart>;
start(core: CoreStart, plugins: TPluginsStart): TStart | Promise<TStart>;
// (undocumented)
stop?: () => void;
stop?(): void;
}

// @public
Expand Down
14 changes: 7 additions & 7 deletions src/core/server/plugins/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,14 @@ export interface DiscoveredPluginInternal extends DiscoveredPlugin {
* @public
*/
export interface Plugin<
TSetup,
TStart,
TPluginsSetup extends Record<PluginName, unknown> = {},
TPluginsStart extends Record<PluginName, unknown> = {}
TSetup = void,
TStart = void,
TPluginsSetup extends {} = {},
TPluginsStart extends {} = {}
> {
setup: (core: CoreSetup, plugins: TPluginsSetup) => TSetup | Promise<TSetup>;
start: (core: CoreStart, plugins: TPluginsStart) => TStart | Promise<TStart>;
stop?: () => void;
setup(core: CoreSetup, plugins: TPluginsSetup): TSetup | Promise<TSetup>;
start(core: CoreStart, plugins: TPluginsStart): TStart | Promise<TStart>;
stop?(): void;
}

/**
Expand Down
8 changes: 4 additions & 4 deletions src/core/server/server.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -329,13 +329,13 @@ export interface OnPreAuthToolkit {
}

// @public
export interface Plugin<TSetup, TStart, TPluginsSetup extends Record<PluginName, unknown> = {}, TPluginsStart extends Record<PluginName, unknown> = {}> {
export interface Plugin<TSetup = void, TStart = void, TPluginsSetup extends {} = {}, TPluginsStart extends {} = {}> {
// (undocumented)
setup: (core: CoreSetup, plugins: TPluginsSetup) => TSetup | Promise<TSetup>;
setup(core: CoreSetup, plugins: TPluginsSetup): TSetup | Promise<TSetup>;
// (undocumented)
start: (core: CoreStart, plugins: TPluginsStart) => TStart | Promise<TStart>;
start(core: CoreStart, plugins: TPluginsStart): TStart | Promise<TStart>;
// (undocumented)
stop?: () => void;
stop?(): void;
}

// @public
Expand Down
5 changes: 1 addition & 4 deletions src/legacy/core_plugins/data/public/query/query_bar/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,4 @@ export { getQueryLog } from './lib/get_query_log';
// @ts-ignore
export { setupDirective } from './directive';

export interface Query {
query: string | { [key: string]: any };
language: string;
}
export { Query } from '../../../../../../plugins/data/common/query/types';
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import { functionWrapper } from '../../interpreter/test_helpers';
import { inputControlVis } from './input_control_fn';

jest.mock('ui/new_platform', () => require('../../../ui/public/new_platform/index.test.mocks').mockNewPlatformBackdoor());

describe('interpreter/functions#input_control_vis', () => {
const fn = functionWrapper(inputControlVis);
const visConfig = {
Expand Down
8 changes: 7 additions & 1 deletion src/legacy/core_plugins/interpreter/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,10 @@ export {
PointSeriesColumnName,
Render,
Style,
} from './types';
} from '../../../../plugins/data/common/expressions/expression_types';
export const API_ROUTE = '/api/interpreter';
export * from '../../../../plugins/data/common/expressions/serialize_provider';
export { Type } from '../../../../plugins/data/common/expressions/interpreter';
export {
interpreterProvider,
} from '../../../../plugins/data/common/expressions/interpreter_provider';
25 changes: 18 additions & 7 deletions src/legacy/core_plugins/interpreter/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,31 @@
* under the License.
*/

/* eslint-disable max-classes-per-file */

// @ts-ignore
import { register, registryFactory } from '@kbn/interpreter/common';
import { register, registryFactory, Registry, Fn } from '@kbn/interpreter/common';

// @ts-ignore
import { routes } from './server/routes';

// @ts-ignore
import { typeSpecs as types } from '../../../plugins/data/common/expressions/expression_types';

import { Type } from './common';
import { Legacy } from '../../../../kibana';

// @ts-ignore
import { FunctionsRegistry } from './common/functions_registry';
// @ts-ignore
import { typeSpecs as types } from './common/types';
// @ts-ignore
import { TypesRegistry } from './common/types_registry';
export class TypesRegistry extends Registry<any, any> {
wrapper(obj: any) {
return new (Type as any)(obj);
}
}

export class FunctionsRegistry extends Registry<any, any> {
wrapper(obj: any) {
return new Fn(obj);
}
}

export const registries = {
types: new TypesRegistry(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const courierRequestHandlerProvider = CourierRequestHandlerProvider;
const courierRequestHandler = courierRequestHandlerProvider().handler;

import { ExpressionFunction } from '../../types';
import { KibanaContext, KibanaDatatable } from '../../common/types';
import { KibanaContext, KibanaDatatable } from '../../common';

const name = 'esaggs';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import { i18n } from '@kbn/i18n';
import { KibanaDatatable, Range } from '../../common/types';
import { KibanaDatatable, Range } from '../../types';
import { ExpressionFunction } from '../../types';

const name = 'range';
Expand Down
2 changes: 1 addition & 1 deletion src/legacy/core_plugins/interpreter/public/interpreter.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { kfetch } from 'ui/kfetch';
import { ajaxStream } from 'ui/ajax_stream';
import { functions } from './functions';
import { visualization } from './renderers/visualization';
import { typeSpecs } from '../common/types';
import { typeSpecs } from '../../../../plugins/data/common/expressions/expression_types';

// Expose kbnInterpreter.register(specs) and kbnInterpreter.registries() globally so that plugins
// can register without a transpile step.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
* under the License.
*/

import { interpreterProvider } from '../../common/interpreter/interpret';
import { serializeProvider } from '../../common/serialize';
import { interpreterProvider, serializeProvider } from '../../common';
import { createHandlers } from './create_handlers';
import { batchedFetch } from './batched_fetch';
import { FUNCTIONS_URL } from './consts';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@
import { FUNCTIONS_URL } from './consts';
import { initializeInterpreter } from './interpreter';

jest.mock('../../common/interpreter/interpret', () => ({
interpreterProvider: () => () => ({}),
}));

jest.mock('../../common/serialize', () => ({
jest.mock('../../common', () => ({
serializeProvider: () => ({ serialize: () => ({}) }),
}));

Expand Down
Loading

0 comments on commit b057a93

Please sign in to comment.