Skip to content

Commit 426e640

Browse files
Merge branch 'master' into implement/dev-server-no-discovery-part2
2 parents 0cf47e9 + f7a18e6 commit 426e640

File tree

143 files changed

+2673
-590
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

143 files changed

+2673
-590
lines changed

x-pack/plugins/ingest_manager/server/services/epm/elasticsearch/template/template.test.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,37 @@ test('tests processing keyword field with multi fields with analyzed text field'
212212
expect(mappings).toEqual(keywordWithAnalyzedMultiFieldsMapping);
213213
});
214214

215+
test('tests processing keyword field with multi fields with normalized keyword field', () => {
216+
const keywordWithNormalizedMultiFieldsLiteralYml = `
217+
- name: keywordWithNormalizedMultiField
218+
type: keyword
219+
multi_fields:
220+
- name: normalized
221+
type: keyword
222+
normalizer: lowercase
223+
`;
224+
225+
const keywordWithNormalizedMultiFieldsMapping = {
226+
properties: {
227+
keywordWithNormalizedMultiField: {
228+
ignore_above: 1024,
229+
type: 'keyword',
230+
fields: {
231+
normalized: {
232+
type: 'keyword',
233+
ignore_above: 1024,
234+
normalizer: 'lowercase',
235+
},
236+
},
237+
},
238+
},
239+
};
240+
const fields: Field[] = safeLoad(keywordWithNormalizedMultiFieldsLiteralYml);
241+
const processedFields = processFields(fields);
242+
const mappings = generateMappings(processedFields);
243+
expect(mappings).toEqual(keywordWithNormalizedMultiFieldsMapping);
244+
});
245+
215246
test('tests processing object field with no other attributes', () => {
216247
const objectFieldLiteralYml = `
217248
- name: objectField

x-pack/plugins/ingest_manager/server/services/epm/elasticsearch/template/template.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,9 @@ function generateKeywordMapping(field: Field): IndexTemplateMapping {
189189
if (field.ignore_above) {
190190
mapping.ignore_above = field.ignore_above;
191191
}
192+
if (field.normalizer) {
193+
mapping.normalizer = field.normalizer;
194+
}
192195
return mapping;
193196
}
194197

x-pack/plugins/ingest_manager/server/services/epm/fields/field.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export interface Field {
2020
index?: boolean;
2121
required?: boolean;
2222
multi_fields?: Fields;
23+
normalizer?: string;
2324
doc_values?: boolean;
2425
copy_to?: string;
2526
analyzer?: string;

x-pack/plugins/lens/public/async_services.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@ export * from './xy_visualization/xy_visualization';
2121
export * from './indexpattern_datasource/indexpattern';
2222

2323
export * from './editor_frame_service/editor_frame';
24+
export * from './editor_frame_service/embeddable';
2425
export * from './app_plugin/mounter';

x-pack/plugins/lens/public/editor_frame_service/editor_frame/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@
55
*/
66

77
export * from './editor_frame';
8+
export * from './state_helpers';
9+
export * from './state_management';

x-pack/plugins/lens/public/editor_frame_service/embeddable/embeddable.test.tsx

Lines changed: 58 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import { VIS_EVENT_TO_TRIGGER } from '../../../../../../src/plugins/visualizatio
2626
import { coreMock, httpServiceMock } from '../../../../../../src/core/public/mocks';
2727
import { IBasePath } from '../../../../../../src/core/public';
2828
import { AttributeService } from '../../../../../../src/plugins/dashboard/public';
29-
import { Ast } from '@kbn/interpreter/common';
3029
import { LensAttributeService } from '../../lens_attribute_service';
3130

3231
jest.mock('../../../../../../src/plugins/inspector/public/', () => ({
@@ -103,16 +102,23 @@ describe('embeddable', () => {
103102
indexPatternService: {} as IndexPatternsContract,
104103
editable: true,
105104
getTrigger,
106-
documentToExpression: () => Promise.resolve({} as Ast),
107-
toExpressionString: () => 'my | expression',
105+
documentToExpression: () =>
106+
Promise.resolve({
107+
type: 'expression',
108+
chain: [
109+
{ type: 'function', function: 'my', arguments: {} },
110+
{ type: 'function', function: 'expression', arguments: {} },
111+
],
112+
}),
108113
},
109114
{} as LensEmbeddableInput
110115
);
111116
await embeddable.initializeSavedVis({} as LensEmbeddableInput);
112117
embeddable.render(mountpoint);
113118

114119
expect(expressionRenderer).toHaveBeenCalledTimes(1);
115-
expect(expressionRenderer.mock.calls[0][0]!.expression).toEqual('my | expression');
120+
expect(expressionRenderer.mock.calls[0][0]!.expression).toEqual(`my
121+
| expression`);
116122
});
117123

118124
it('should re-render if new input is pushed', async () => {
@@ -129,8 +135,14 @@ describe('embeddable', () => {
129135
indexPatternService: {} as IndexPatternsContract,
130136
editable: true,
131137
getTrigger,
132-
documentToExpression: () => Promise.resolve({} as Ast),
133-
toExpressionString: () => 'my | expression',
138+
documentToExpression: () =>
139+
Promise.resolve({
140+
type: 'expression',
141+
chain: [
142+
{ type: 'function', function: 'my', arguments: {} },
143+
{ type: 'function', function: 'expression', arguments: {} },
144+
],
145+
}),
134146
},
135147
{ id: '123' } as LensEmbeddableInput
136148
);
@@ -162,8 +174,14 @@ describe('embeddable', () => {
162174
indexPatternService: {} as IndexPatternsContract,
163175
editable: true,
164176
getTrigger,
165-
documentToExpression: () => Promise.resolve({} as Ast),
166-
toExpressionString: () => 'my | expression',
177+
documentToExpression: () =>
178+
Promise.resolve({
179+
type: 'expression',
180+
chain: [
181+
{ type: 'function', function: 'my', arguments: {} },
182+
{ type: 'function', function: 'expression', arguments: {} },
183+
],
184+
}),
167185
},
168186
input
169187
);
@@ -208,8 +226,14 @@ describe('embeddable', () => {
208226
indexPatternService: {} as IndexPatternsContract,
209227
editable: true,
210228
getTrigger,
211-
documentToExpression: () => Promise.resolve({} as Ast),
212-
toExpressionString: () => 'my | expression',
229+
documentToExpression: () =>
230+
Promise.resolve({
231+
type: 'expression',
232+
chain: [
233+
{ type: 'function', function: 'my', arguments: {} },
234+
{ type: 'function', function: 'expression', arguments: {} },
235+
],
236+
}),
213237
},
214238
input
215239
);
@@ -237,8 +261,14 @@ describe('embeddable', () => {
237261
indexPatternService: {} as IndexPatternsContract,
238262
editable: true,
239263
getTrigger,
240-
documentToExpression: () => Promise.resolve({} as Ast),
241-
toExpressionString: () => 'my | expression',
264+
documentToExpression: () =>
265+
Promise.resolve({
266+
type: 'expression',
267+
chain: [
268+
{ type: 'function', function: 'my', arguments: {} },
269+
{ type: 'function', function: 'expression', arguments: {} },
270+
],
271+
}),
242272
},
243273
{ id: '123' } as LensEmbeddableInput
244274
);
@@ -270,8 +300,14 @@ describe('embeddable', () => {
270300
indexPatternService: {} as IndexPatternsContract,
271301
editable: true,
272302
getTrigger,
273-
documentToExpression: () => Promise.resolve({} as Ast),
274-
toExpressionString: () => 'my | expression',
303+
documentToExpression: () =>
304+
Promise.resolve({
305+
type: 'expression',
306+
chain: [
307+
{ type: 'function', function: 'my', arguments: {} },
308+
{ type: 'function', function: 'expression', arguments: {} },
309+
],
310+
}),
275311
},
276312
{ id: '123', timeRange, query, filters } as LensEmbeddableInput
277313
);
@@ -311,8 +347,14 @@ describe('embeddable', () => {
311347
indexPatternService: {} as IndexPatternsContract,
312348
editable: true,
313349
getTrigger,
314-
documentToExpression: () => Promise.resolve({} as Ast),
315-
toExpressionString: () => 'my | expression',
350+
documentToExpression: () =>
351+
Promise.resolve({
352+
type: 'expression',
353+
chain: [
354+
{ type: 'function', function: 'my', arguments: {} },
355+
{ type: 'function', function: 'expression', arguments: {} },
356+
],
357+
}),
316358
},
317359
{ id: '123', timeRange, query, filters } as LensEmbeddableInput
318360
);

x-pack/plugins/lens/public/editor_frame_service/embeddable/embeddable.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
import { ExecutionContextSearch } from 'src/plugins/expressions';
1919

2020
import { Subscription } from 'rxjs';
21-
import { Ast } from '@kbn/interpreter/common';
21+
import { toExpression, Ast } from '@kbn/interpreter/common';
2222
import {
2323
ExpressionRendererEvent,
2424
ReactExpressionRendererType,
@@ -59,7 +59,6 @@ export interface LensEmbeddableOutput extends EmbeddableOutput {
5959
export interface LensEmbeddableDeps {
6060
attributeService: LensAttributeService;
6161
documentToExpression: (doc: Document) => Promise<Ast | null>;
62-
toExpressionString: (astObj: Ast, type?: string) => string;
6362
editable: boolean;
6463
indexPatternService: IndexPatternsContract;
6564
expressionRenderer: ReactExpressionRendererType;
@@ -135,7 +134,7 @@ export class Embeddable
135134
savedObjectId: (input as LensByReferenceInput)?.savedObjectId,
136135
};
137136
const expression = await this.deps.documentToExpression(this.savedVis);
138-
this.expression = expression ? this.deps.toExpressionString(expression) : null;
137+
this.expression = expression ? toExpression(expression) : null;
139138
await this.initializeOutput();
140139
this.isInitialized = true;
141140
if (this.domNode) {

x-pack/plugins/lens/public/editor_frame_service/embeddable/embeddable_factory.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import { Capabilities, HttpSetup } from 'kibana/public';
88
import { i18n } from '@kbn/i18n';
99
import { RecursiveReadonly } from '@kbn/utility-types';
10-
import { toExpression, Ast } from '@kbn/interpreter/target/common';
10+
import { Ast } from '@kbn/interpreter/target/common';
1111
import {
1212
IndexPatternsContract,
1313
TimefilterContract,
@@ -17,7 +17,7 @@ import {
1717
EmbeddableFactoryDefinition,
1818
IContainer,
1919
} from '../../../../../../src/plugins/embeddable/public';
20-
import { Embeddable, LensByReferenceInput, LensEmbeddableInput } from './embeddable';
20+
import { LensByReferenceInput, LensEmbeddableInput } from './embeddable';
2121
import { DOC_TYPE } from '../../persistence';
2222
import { UiActionsStart } from '../../../../../../src/plugins/ui_actions/public';
2323
import { Document } from '../../persistence/saved_object_store';
@@ -83,6 +83,8 @@ export class EmbeddableFactory implements EmbeddableFactoryDefinition {
8383
indexPatternService,
8484
} = await this.getStartServices();
8585

86+
const { Embeddable } = await import('../../async_services');
87+
8688
return new Embeddable(
8789
{
8890
attributeService,
@@ -93,7 +95,6 @@ export class EmbeddableFactory implements EmbeddableFactoryDefinition {
9395
basePath: coreHttp.basePath,
9496
getTrigger: uiActions?.getTrigger,
9597
documentToExpression,
96-
toExpressionString: toExpression,
9798
},
9899
input,
99100
parent
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License;
4+
* you may not use this file except in compliance with the Elastic License.
5+
*/
6+
7+
export * from './embeddable';

x-pack/plugins/lens/public/editor_frame_service/service.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,8 @@ import { Document } from '../persistence/saved_object_store';
2525
import { mergeTables } from './merge_tables';
2626
import { formatColumn } from './format_column';
2727
import { EmbeddableFactory, LensEmbeddableStartServices } from './embeddable/embeddable_factory';
28-
import { getActiveDatasourceIdFromDoc } from './editor_frame/state_management';
2928
import { UiActionsStart } from '../../../../../src/plugins/ui_actions/public';
3029
import { DashboardStart } from '../../../../../src/plugins/dashboard/public';
31-
import { persistedStateToExpression } from './editor_frame/state_helpers';
3230
import { LensAttributeService } from '../lens_attribute_service';
3331

3432
export interface EditorFrameSetupPlugins {
@@ -77,6 +75,8 @@ export class EditorFrameService {
7775
collectAsyncDefinitions(this.visualizations),
7876
]);
7977

78+
const { persistedStateToExpression } = await import('../async_services');
79+
8080
return await persistedStateToExpression(resolvedDatasources, resolvedVisualizations, doc);
8181
}
8282

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

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

138138
render(
139139
<I18nProvider>

0 commit comments

Comments
 (0)