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

Expressions np #47810

Merged
merged 46 commits into from
Oct 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
460856b
refactor: 💡 generalize service getters and setters in expressio
streamich Oct 8, 2019
1126ece
feat: 🎸 create NP-ready plugin for expressions
streamich Oct 8, 2019
b6c6551
refactor: 💡 flatten expressions plugin and remove service
streamich Oct 8, 2019
e1d6860
chore: 🤖 re-export legacy expressions service dir for Lens
streamich Oct 8, 2019
ae5d3ce
refactor: 💡 don't import renderer registry statically
streamich Oct 8, 2019
5891250
test: 💍 mock expressions service renderers registry in Mocha
streamich Oct 9, 2019
4cc00cf
Merge remote-tracking branch 'upstream/master' into functions-to-expr…
streamich Oct 10, 2019
54b8c41
refactor: 💡 clean-up NP expressions pugin
streamich Oct 10, 2019
ac1557a
chore: 🤖 catch-up with master
streamich Oct 10, 2019
0327dd4
refactor: 💡 move Expression fonts to NP
streamich Oct 10, 2019
4e98259
refactor: 💡 register Interpreter entities explicitly
streamich Oct 10, 2019
a90984d
refactor: 💡 move clog Expression function to NP
streamich Oct 10, 2019
32d0b91
refactor: 💡 move font function and style types to NP
streamich Oct 10, 2019
8ebac8f
refactor: 💡 remove ui/chrome from kibana_context function
streamich Oct 10, 2019
e3f6acc
feat: 🎸 add ability to consume start core from setup life-cycle
streamich Oct 10, 2019
dac14ba
refactor: 💡 move kibana_context function to NP
streamich Oct 10, 2019
2d35864
feat: 🎸 improve naming and delete import of missing function
streamich Oct 10, 2019
c6258bb
refactor: 💡 register expression clog and font fn in NP
streamich Oct 10, 2019
77bb9dc
chore: 🤖 set AppArch as GitHub folder owners
streamich Oct 10, 2019
d2d4294
refactor: 💡 move Expression "kibana" function to NP
streamich Oct 10, 2019
8551b4e
refactor: 💡 move range function to visualizations plugin
streamich Oct 10, 2019
00d8116
feat: 🎸 move visDimensions to visualizations plugin
streamich Oct 10, 2019
d134e0c
chore: 🤖 delete unused files
streamich Oct 10, 2019
99aed4a
refactor: 💡 move expression type registration to NP
streamich Oct 10, 2019
a24a064
refactor: 💡 move createHandlers() function to NP
streamich Oct 10, 2019
266159c
feat: 🎸 move Expression executor to NP
streamich Oct 10, 2019
5ebf21b
refactor: 💡 re-implement function registry
streamich Oct 10, 2019
a81a02f
refactor: 💡 convert expression type to class
streamich Oct 10, 2019
00073ab
fix: 🐛 correct TypeScript errors
streamich Oct 10, 2019
380a7e8
feat: 🎸 convert Expressions type registry to class
streamich Oct 10, 2019
239f12b
feat: 🎸 convert render function registry to class
streamich Oct 10, 2019
52d1201
chore: 🤖 catch up with master
streamich Oct 14, 2019
36935f2
fix: 🐛 fix TypeScript errors
streamich Oct 14, 2019
6f03199
fix: 🐛 fix translations after refactor
streamich Oct 14, 2019
f05e51b
refactor: 💡 move Expression types to NP
streamich Oct 14, 2019
f6b67ef
test: 💍 remove unused test
streamich Oct 14, 2019
469d3e3
chore: 🤖 catch up with master
streamich Oct 23, 2019
d49a8a1
fix: 🐛 fix Lens import after merge with master
streamich Oct 23, 2019
63f3af0
Merge remote-tracking branch 'upstream/master' into expressions-np
streamich Oct 23, 2019
abc484a
fix: 🐛 fix TypeScript errors
streamich Oct 23, 2019
ece1a69
chore: 🤖 catch up with master
streamich Oct 28, 2019
a9cae4d
refactor: 💡 update expression types
streamich Oct 28, 2019
3c37389
Merge remote-tracking branch 'upstream/master' into expressions-np
streamich Oct 29, 2019
99a07e0
test: 💍 fix renderer test
streamich Oct 29, 2019
d69711a
chore: 🤖 catch up with master
streamich Oct 29, 2019
285a33c
chore: 🤖 catch up with master
streamich Oct 30, 2019
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
7 changes: 6 additions & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,14 @@

# App Architecture
/src/plugins/data/ @elastic/kibana-app-arch
/src/plugins/kibana_utils/ @elastic/kibana-app-arch
/src/plugins/embeddable/ @elastic/kibana-app-arch
/src/plugins/expressions/ @elastic/kibana-app-arch
/src/plugins/kibana_react/ @elastic/kibana-app-arch
/src/plugins/kibana_utils/ @elastic/kibana-app-arch
/src/plugins/navigation/ @elastic/kibana-app-arch
/src/plugins/ui_actions/ @elastic/kibana-app-arch
/src/plugins/visualizations/ @elastic/kibana-app-arch
/x-pack/plugins/advanced_ui_actions/ @elastic/kibana-app-arch

# APM
/x-pack/legacy/plugins/apm/ @elastic/apm-ui
Expand Down
2 changes: 2 additions & 0 deletions .i18nrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"common.ui": "src/legacy/ui",
"data": ["src/legacy/core_plugins/data", "src/plugins/data"],
"expressions": "src/legacy/core_plugins/expressions",
"expressions_np": "src/plugins/expressions",
"kibana_react": "src/legacy/core_plugins/kibana_react",
"navigation": "src/legacy/core_plugins/navigation",
"server": "src/legacy/server",
Expand All @@ -29,6 +30,7 @@
"kbnESQuery": "packages/kbn-es-query",
"inspector": "src/plugins/inspector",
"kibana-react": "src/plugins/kibana_react",
"visualizations": "src/plugins/visualizations",
"telemetry": "src/legacy/core_plugins/telemetry",
"esUi": "src/plugins/es_ui_shared",
"uiActions": "src/plugins/ui_actions"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { ExpressionDataHandler } from './execute';
import { fromExpression } from '@kbn/interpreter/common';
import { IInterpreterRenderHandlers } from './types';
import { Observable } from 'rxjs';
import { ExpressionAST } from '../../../../../../plugins/expressions/common';
import { ExpressionAST } from '../../../../../../plugins/expressions/public';

const element: HTMLElement = null as any;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ const createExpressionsSetupMock = (): ExpressionsSetup => {
types: {
register: () => {},
} as any,
getExecutor: () => ({
interpreter: {
interpretAst: () => {},
},
}),
},
};
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@

/* eslint-disable */
import { npSetup } from 'ui/new_platform';
import { ExpressionsSetupContract } from '../../../../../../plugins/expressions/public/expressions/expressions_service';
/* eslint-enable */

import { ExpressionsSetup } from '../../../../../../plugins/expressions/public';

import {
CoreSetup,
CoreStart,
Expand All @@ -32,7 +33,7 @@ import {
Start as InspectorStart,
Setup as InspectorSetup,
} from '../../../../../../plugins/inspector/public';
import { IInterpreter } from './types';
import { ExpressionInterpreter } from './types';
import { setInterpreter, setInspector, setRenderersRegistry } from './services';
import { ExpressionRendererImplementation } from './expression_renderer';
import { ExpressionLoader, loader } from './loader';
Expand All @@ -47,7 +48,7 @@ export interface ExpressionsStartDeps {
inspector: InspectorStart;
}

export type ExpressionsSetup = ExpressionsSetupContract;
export { ExpressionsSetup };
export type ExpressionsStart = ReturnType<ExpressionsPublicPlugin['start']>;

export class ExpressionsPublicPlugin
Expand All @@ -61,7 +62,7 @@ export class ExpressionsPublicPlugin
// eslint-disable-next-line
const { getInterpreter } = require('../../../../interpreter/public/interpreter');
getInterpreter()
.then(({ interpreter }: { interpreter: IInterpreter }) => {
.then(({ interpreter }: { interpreter: ExpressionInterpreter }) => {
setInterpreter(interpreter);
})
.catch((e: Error) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export class ExpressionRenderHandler {
try {
// Rendering is asynchronous, completed by handlers.done()
getRenderersRegistry()
.get(data.as)
.get(data.as)!
.render(this.element, data.value, { ...this.handlers, ...extraHandlers });
} catch (e) {
this.renderSubject.next({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@
* under the License.
*/

import { ExpressionInterpreter } from './types';
import { createGetterSetter } from '../../../../../../plugins/kibana_utils/public';
import { IInterpreter } from './types';
import { Start as IInspector } from '../../../../../../plugins/inspector/public';
import { ExpressionsSetup } from './plugin';

export const [getInspector, setInspector] = createGetterSetter<IInspector>('Inspector');
export const [getInterpreter, setInterpreter] = createGetterSetter<IInterpreter>('Interpreter');
export const [getInterpreter, setInterpreter] = createGetterSetter<ExpressionInterpreter>(
'Interpreter'
);
export const [getRenderersRegistry, setRenderersRegistry] = createGetterSetter<
ExpressionsSetup['__LEGACY']['renderers']
>('Renderers registry');
Original file line number Diff line number Diff line change
Expand Up @@ -21,76 +21,6 @@ import { Filter } from '@kbn/es-query';
import { TimeRange } from '../../../../../../plugins/data/public';
import { Adapters } from '../../../../../../plugins/inspector/public';
import { Query } from '../../../../../../plugins/data/public';
import { ExpressionAST } from '../../../../../../plugins/expressions/common';

export { ExpressionAST, TimeRange, Adapters, Filter, Query };

export type RenderId = number;
export type Data = any;
export type event = any;
export type Context = object;

export interface SearchContext {
type: 'kibana_context';
filters?: Filter[];
query?: Query;
timeRange?: TimeRange;
}

export type IGetInitialContext = () => SearchContext | Context;

export interface IExpressionLoaderParams {
searchContext?: SearchContext;
context?: Context;
variables?: Record<string, any>;
disableCaching?: boolean;
customFunctions?: [];
customRenderers?: [];
extraHandlers?: Record<string, any>;
}

export interface IInterpreterHandlers {
getInitialContext: IGetInitialContext;
inspectorAdapters?: Adapters;
abortSignal?: AbortSignal;
}

export interface IInterpreterErrorResult {
type: 'error';
error: { message: string; name: string; stack: string };
}

export interface IInterpreterSuccessResult {
type: string;
as?: string;
value?: unknown;
error?: unknown;
}

export type IInterpreterResult = IInterpreterSuccessResult & IInterpreterErrorResult;

export interface IInterpreterRenderHandlers {
// Done increments the number of rendering successes
done: () => void;
onDestroy: (fn: () => void) => void;
reload: () => void;
update: (params: any) => void;
event: (event: event) => void;
}

export interface IInterpreterRenderFunction<T = unknown> {
name: string;
displayName: string;
help: string;
validate: () => void;
reuseDomNode: boolean;
render: (domNode: Element, data: T, handlers: IInterpreterRenderHandlers) => void | Promise<void>;
}

export interface IInterpreter {
interpretAst(
ast: ExpressionAST,
context: Context,
handlers: IInterpreterHandlers
): Promise<IInterpreterResult>;
}
export { TimeRange, Adapters, Filter, Query };
export * from '../../../../../../plugins/expressions/public';
3 changes: 2 additions & 1 deletion src/legacy/core_plugins/interpreter/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ export {
PointSeriesColumn,
PointSeriesColumnName,
Render,
ExpressionTypeStyle,
Style,
Type,
} from '../../../../plugins/expressions/common';
} from '../../../../plugins/expressions/public';
export const API_ROUTE = '/api/interpreter';
134 changes: 2 additions & 132 deletions src/legacy/core_plugins/interpreter/common/lib/fonts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,135 +17,5 @@
* under the License.
*/

/**
* This type contains a unions of all supported font labels, or the the name of
* the font the user would see in a UI.
*/
export type FontLabel = typeof fonts[number]['label'];

/**
* This type contains a union of all supported font values, equivalent to the CSS
* `font-value` property.
*/
export type FontValue = typeof fonts[number]['value'];

/**
* An interface representing a font in Canvas, with a textual label and the CSS
* `font-value`.
*/
export interface Font {
label: FontLabel;
value: FontValue;
}

// This function allows one to create a strongly-typed font for inclusion in
// the font collection. As a result, the values and labels are known to the
// type system, preventing one from specifying a non-existent font at build
// time.
function createFont<
RawFont extends { value: RawFontValue; label: RawFontLabel },
RawFontValue extends string,
RawFontLabel extends string
>(font: RawFont) {
return font;
}

export const americanTypewriter = createFont({
label: 'American Typewriter',
value: "'American Typewriter', 'Courier New', Courier, Monaco, mono",
});

export const arial = createFont({ label: 'Arial', value: 'Arial, sans-serif' });

export const baskerville = createFont({
label: 'Baskerville',
value: "Baskerville, Georgia, Garamond, 'Times New Roman', Times, serif",
});

export const bookAntiqua = createFont({
label: 'Book Antiqua',
value: "'Book Antiqua', Georgia, Garamond, 'Times New Roman', Times, serif",
});

export const brushScript = createFont({
label: 'Brush Script',
value: "'Brush Script MT', 'Comic Sans', sans-serif",
});

export const chalkboard = createFont({
label: 'Chalkboard',
value: "Chalkboard, 'Comic Sans', sans-serif",
});

export const didot = createFont({
label: 'Didot',
value: "Didot, Georgia, Garamond, 'Times New Roman', Times, serif",
});

export const futura = createFont({
label: 'Futura',
value: 'Futura, Impact, Helvetica, Arial, sans-serif',
});

export const gillSans = createFont({
label: 'Gill Sans',
value:
"'Gill Sans', 'Lucida Grande', 'Lucida Sans Unicode', Verdana, Helvetica, Arial, sans-serif",
});

export const helveticaNeue = createFont({
label: 'Helvetica Neue',
value: "'Helvetica Neue', Helvetica, Arial, sans-serif",
});

export const hoeflerText = createFont({
label: 'Hoefler Text',
value: "'Hoefler Text', Garamond, Georgia, 'Times New Roman', Times, serif",
});

export const lucidaGrande = createFont({
label: 'Lucida Grande',
value: "'Lucida Grande', 'Lucida Sans Unicode', Lucida, Verdana, Helvetica, Arial, sans-serif",
});

export const myriad = createFont({
label: 'Myriad',
value: 'Myriad, Helvetica, Arial, sans-serif',
});

export const openSans = createFont({
label: 'Open Sans',
value: "'Open Sans', Helvetica, Arial, sans-serif",
});

export const optima = createFont({
label: 'Optima',
value: "Optima, 'Lucida Grande', 'Lucida Sans Unicode', Verdana, Helvetica, Arial, sans-serif",
});

export const palatino = createFont({
label: 'Palatino',
value: "Palatino, 'Book Antiqua', Georgia, Garamond, 'Times New Roman', Times, serif",
});

/**
* A collection of supported fonts.
*/
export const fonts = [
americanTypewriter,
arial,
baskerville,
bookAntiqua,
brushScript,
chalkboard,
didot,
futura,
gillSans,
helveticaNeue,
hoeflerText,
lucidaGrande,
myriad,
openSans,
optima,
palatino,
];
// eslint-disable-next-line
export * from '../../../../../plugins/expressions/public/fonts';
2 changes: 1 addition & 1 deletion src/legacy/core_plugins/interpreter/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { register, registryFactory, Registry, Fn } from '@kbn/interpreter/common
// @ts-ignore
import { routes } from './server/routes';

import { typeSpecs as types } from '../../../plugins/expressions/common';
import { typeSpecs as types } from '../../../plugins/expressions/public';

import { Type } from './common';
import { Legacy } from '../../../../kibana';
Expand Down
18 changes: 2 additions & 16 deletions src/legacy/core_plugins/interpreter/public/functions/clog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,5 @@
* under the License.
*/

import { ExpressionFunction } from '../../types';

const name = 'clog';

type Context = any;
type ClogExpressionFunction = ExpressionFunction<typeof name, Context, {}, Context>;

export const clog = (): ClogExpressionFunction => ({
name,
args: {},
help: 'Outputs the context to the console',
fn: context => {
console.log(context); // eslint-disable-line no-console
return context;
},
});
// eslint-disable-next-line
export * from '../../../../../plugins/expressions/public/functions/clog';
Loading