Skip to content

Commit

Permalink
Merge branch 'master' into implement/dev-server-no-discovery-part2
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine committed Oct 2, 2020
2 parents 0cf47e9 + f7a18e6 commit 426e640
Show file tree
Hide file tree
Showing 143 changed files with 2,673 additions and 590 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,37 @@ test('tests processing keyword field with multi fields with analyzed text field'
expect(mappings).toEqual(keywordWithAnalyzedMultiFieldsMapping);
});

test('tests processing keyword field with multi fields with normalized keyword field', () => {
const keywordWithNormalizedMultiFieldsLiteralYml = `
- name: keywordWithNormalizedMultiField
type: keyword
multi_fields:
- name: normalized
type: keyword
normalizer: lowercase
`;

const keywordWithNormalizedMultiFieldsMapping = {
properties: {
keywordWithNormalizedMultiField: {
ignore_above: 1024,
type: 'keyword',
fields: {
normalized: {
type: 'keyword',
ignore_above: 1024,
normalizer: 'lowercase',
},
},
},
},
};
const fields: Field[] = safeLoad(keywordWithNormalizedMultiFieldsLiteralYml);
const processedFields = processFields(fields);
const mappings = generateMappings(processedFields);
expect(mappings).toEqual(keywordWithNormalizedMultiFieldsMapping);
});

test('tests processing object field with no other attributes', () => {
const objectFieldLiteralYml = `
- name: objectField
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,9 @@ function generateKeywordMapping(field: Field): IndexTemplateMapping {
if (field.ignore_above) {
mapping.ignore_above = field.ignore_above;
}
if (field.normalizer) {
mapping.normalizer = field.normalizer;
}
return mapping;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export interface Field {
index?: boolean;
required?: boolean;
multi_fields?: Fields;
normalizer?: string;
doc_values?: boolean;
copy_to?: string;
analyzer?: string;
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/lens/public/async_services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ export * from './xy_visualization/xy_visualization';
export * from './indexpattern_datasource/indexpattern';

export * from './editor_frame_service/editor_frame';
export * from './editor_frame_service/embeddable';
export * from './app_plugin/mounter';
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@
*/

export * from './editor_frame';
export * from './state_helpers';
export * from './state_management';
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import { VIS_EVENT_TO_TRIGGER } from '../../../../../../src/plugins/visualizatio
import { coreMock, httpServiceMock } from '../../../../../../src/core/public/mocks';
import { IBasePath } from '../../../../../../src/core/public';
import { AttributeService } from '../../../../../../src/plugins/dashboard/public';
import { Ast } from '@kbn/interpreter/common';
import { LensAttributeService } from '../../lens_attribute_service';

jest.mock('../../../../../../src/plugins/inspector/public/', () => ({
Expand Down Expand Up @@ -103,16 +102,23 @@ describe('embeddable', () => {
indexPatternService: {} as IndexPatternsContract,
editable: true,
getTrigger,
documentToExpression: () => Promise.resolve({} as Ast),
toExpressionString: () => 'my | expression',
documentToExpression: () =>
Promise.resolve({
type: 'expression',
chain: [
{ type: 'function', function: 'my', arguments: {} },
{ type: 'function', function: 'expression', arguments: {} },
],
}),
},
{} as LensEmbeddableInput
);
await embeddable.initializeSavedVis({} as LensEmbeddableInput);
embeddable.render(mountpoint);

expect(expressionRenderer).toHaveBeenCalledTimes(1);
expect(expressionRenderer.mock.calls[0][0]!.expression).toEqual('my | expression');
expect(expressionRenderer.mock.calls[0][0]!.expression).toEqual(`my
| expression`);
});

it('should re-render if new input is pushed', async () => {
Expand All @@ -129,8 +135,14 @@ describe('embeddable', () => {
indexPatternService: {} as IndexPatternsContract,
editable: true,
getTrigger,
documentToExpression: () => Promise.resolve({} as Ast),
toExpressionString: () => 'my | expression',
documentToExpression: () =>
Promise.resolve({
type: 'expression',
chain: [
{ type: 'function', function: 'my', arguments: {} },
{ type: 'function', function: 'expression', arguments: {} },
],
}),
},
{ id: '123' } as LensEmbeddableInput
);
Expand Down Expand Up @@ -162,8 +174,14 @@ describe('embeddable', () => {
indexPatternService: {} as IndexPatternsContract,
editable: true,
getTrigger,
documentToExpression: () => Promise.resolve({} as Ast),
toExpressionString: () => 'my | expression',
documentToExpression: () =>
Promise.resolve({
type: 'expression',
chain: [
{ type: 'function', function: 'my', arguments: {} },
{ type: 'function', function: 'expression', arguments: {} },
],
}),
},
input
);
Expand Down Expand Up @@ -208,8 +226,14 @@ describe('embeddable', () => {
indexPatternService: {} as IndexPatternsContract,
editable: true,
getTrigger,
documentToExpression: () => Promise.resolve({} as Ast),
toExpressionString: () => 'my | expression',
documentToExpression: () =>
Promise.resolve({
type: 'expression',
chain: [
{ type: 'function', function: 'my', arguments: {} },
{ type: 'function', function: 'expression', arguments: {} },
],
}),
},
input
);
Expand Down Expand Up @@ -237,8 +261,14 @@ describe('embeddable', () => {
indexPatternService: {} as IndexPatternsContract,
editable: true,
getTrigger,
documentToExpression: () => Promise.resolve({} as Ast),
toExpressionString: () => 'my | expression',
documentToExpression: () =>
Promise.resolve({
type: 'expression',
chain: [
{ type: 'function', function: 'my', arguments: {} },
{ type: 'function', function: 'expression', arguments: {} },
],
}),
},
{ id: '123' } as LensEmbeddableInput
);
Expand Down Expand Up @@ -270,8 +300,14 @@ describe('embeddable', () => {
indexPatternService: {} as IndexPatternsContract,
editable: true,
getTrigger,
documentToExpression: () => Promise.resolve({} as Ast),
toExpressionString: () => 'my | expression',
documentToExpression: () =>
Promise.resolve({
type: 'expression',
chain: [
{ type: 'function', function: 'my', arguments: {} },
{ type: 'function', function: 'expression', arguments: {} },
],
}),
},
{ id: '123', timeRange, query, filters } as LensEmbeddableInput
);
Expand Down Expand Up @@ -311,8 +347,14 @@ describe('embeddable', () => {
indexPatternService: {} as IndexPatternsContract,
editable: true,
getTrigger,
documentToExpression: () => Promise.resolve({} as Ast),
toExpressionString: () => 'my | expression',
documentToExpression: () =>
Promise.resolve({
type: 'expression',
chain: [
{ type: 'function', function: 'my', arguments: {} },
{ type: 'function', function: 'expression', arguments: {} },
],
}),
},
{ id: '123', timeRange, query, filters } as LensEmbeddableInput
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
import { ExecutionContextSearch } from 'src/plugins/expressions';

import { Subscription } from 'rxjs';
import { Ast } from '@kbn/interpreter/common';
import { toExpression, Ast } from '@kbn/interpreter/common';
import {
ExpressionRendererEvent,
ReactExpressionRendererType,
Expand Down Expand Up @@ -59,7 +59,6 @@ export interface LensEmbeddableOutput extends EmbeddableOutput {
export interface LensEmbeddableDeps {
attributeService: LensAttributeService;
documentToExpression: (doc: Document) => Promise<Ast | null>;
toExpressionString: (astObj: Ast, type?: string) => string;
editable: boolean;
indexPatternService: IndexPatternsContract;
expressionRenderer: ReactExpressionRendererType;
Expand Down Expand Up @@ -135,7 +134,7 @@ export class Embeddable
savedObjectId: (input as LensByReferenceInput)?.savedObjectId,
};
const expression = await this.deps.documentToExpression(this.savedVis);
this.expression = expression ? this.deps.toExpressionString(expression) : null;
this.expression = expression ? toExpression(expression) : null;
await this.initializeOutput();
this.isInitialized = true;
if (this.domNode) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import { Capabilities, HttpSetup } from 'kibana/public';
import { i18n } from '@kbn/i18n';
import { RecursiveReadonly } from '@kbn/utility-types';
import { toExpression, Ast } from '@kbn/interpreter/target/common';
import { Ast } from '@kbn/interpreter/target/common';
import {
IndexPatternsContract,
TimefilterContract,
Expand All @@ -17,7 +17,7 @@ import {
EmbeddableFactoryDefinition,
IContainer,
} from '../../../../../../src/plugins/embeddable/public';
import { Embeddable, LensByReferenceInput, LensEmbeddableInput } from './embeddable';
import { LensByReferenceInput, LensEmbeddableInput } from './embeddable';
import { DOC_TYPE } from '../../persistence';
import { UiActionsStart } from '../../../../../../src/plugins/ui_actions/public';
import { Document } from '../../persistence/saved_object_store';
Expand Down Expand Up @@ -83,6 +83,8 @@ export class EmbeddableFactory implements EmbeddableFactoryDefinition {
indexPatternService,
} = await this.getStartServices();

const { Embeddable } = await import('../../async_services');

return new Embeddable(
{
attributeService,
Expand All @@ -93,7 +95,6 @@ export class EmbeddableFactory implements EmbeddableFactoryDefinition {
basePath: coreHttp.basePath,
getTrigger: uiActions?.getTrigger,
documentToExpression,
toExpressionString: toExpression,
},
input,
parent
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

export * from './embeddable';
6 changes: 3 additions & 3 deletions x-pack/plugins/lens/public/editor_frame_service/service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@ import { Document } from '../persistence/saved_object_store';
import { mergeTables } from './merge_tables';
import { formatColumn } from './format_column';
import { EmbeddableFactory, LensEmbeddableStartServices } from './embeddable/embeddable_factory';
import { getActiveDatasourceIdFromDoc } from './editor_frame/state_management';
import { UiActionsStart } from '../../../../../src/plugins/ui_actions/public';
import { DashboardStart } from '../../../../../src/plugins/dashboard/public';
import { persistedStateToExpression } from './editor_frame/state_helpers';
import { LensAttributeService } from '../lens_attribute_service';

export interface EditorFrameSetupPlugins {
Expand Down Expand Up @@ -77,6 +75,8 @@ export class EditorFrameService {
collectAsyncDefinitions(this.visualizations),
]);

const { persistedStateToExpression } = await import('../async_services');

return await persistedStateToExpression(resolvedDatasources, resolvedVisualizations, doc);
}

Expand Down Expand Up @@ -133,7 +133,7 @@ export class EditorFrameService {
const firstDatasourceId = Object.keys(resolvedDatasources)[0];
const firstVisualizationId = Object.keys(resolvedVisualizations)[0];

const { EditorFrame } = await import('../async_services');
const { EditorFrame, getActiveDatasourceIdFromDoc } = await import('../async_services');

render(
<I18nProvider>
Expand Down
20 changes: 2 additions & 18 deletions x-pack/plugins/lists/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,6 @@ You should see the new exception list created like so:

```sh
{
"_tags": [
"endpoint",
"process",
"malware",
"os:linux"
],
"created_at": "2020-05-28T19:16:31.052Z",
"created_by": "yo",
"description": "This is a sample endpoint type exception",
Expand All @@ -141,12 +135,6 @@ And you can attach exception list items like so:

```ts
{
"_tags": [
"endpoint",
"process",
"malware",
"os:linux"
],
"comments": [],
"created_at": "2020-05-28T19:17:21.099Z",
"created_by": "yo",
Expand All @@ -173,6 +161,7 @@ And you can attach exception list items like so:
"list_id": "endpoint_list",
"name": "Sample Endpoint Exception List",
"namespace_type": "single",
"os_types": ["linux"],
"tags": [
"user added string for a tag",
"malware"
Expand Down Expand Up @@ -222,19 +211,14 @@ or for finding exception lists:
{
"data": [
{
"_tags": [
"endpoint",
"process",
"malware",
"os:linux"
],
"created_at": "2020-05-28T19:16:31.052Z",
"created_by": "yo",
"description": "This is a sample endpoint type exception",
"id": "bcb94680-a117-11ea-ad9d-c71f4820e65b",
"list_id": "endpoint_list",
"name": "Sample Endpoint Exception List",
"namespace_type": "single",
"os_types": ["linux"],
"tags": [
"user added string for a tag",
"malware"
Expand Down
3 changes: 2 additions & 1 deletion x-pack/plugins/lists/common/constants.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/
import moment from 'moment';

import { OsTypeArray } from './schemas/common';
import { EntriesArray } from './schemas/types';
import { EndpointEntriesArray } from './schemas/types/endpoint';
export const DATE_NOW = '2020-04-20T15:25:31.830Z';
Expand Down Expand Up @@ -68,7 +69,7 @@ export const ENDPOINT_ENTRIES: EndpointEntriesArray = [
{ field: 'some.not.nested.field', operator: 'included', type: 'match', value: 'some value' },
];
export const ITEM_TYPE = 'simple';
export const _TAGS = [];
export const OS_TYPES: OsTypeArray = ['windows'];
export const TAGS = [];
export const COMMENTS = [];
export const FILTER = 'name:Nicolas Bourbaki';
Expand Down
Loading

0 comments on commit 426e640

Please sign in to comment.