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

move field_mapping util to saved_objects plugin #79918

Merged
Merged
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

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
| [DataPublicPluginStartUi](./kibana-plugin-plugins-data-public.datapublicpluginstartui.md) | Data plugin prewired UI components |
| [EsQueryConfig](./kibana-plugin-plugins-data-public.esqueryconfig.md) | |
| [FieldFormatConfig](./kibana-plugin-plugins-data-public.fieldformatconfig.md) | |
| [FieldMappingSpec](./kibana-plugin-plugins-data-public.fieldmappingspec.md) | |
| [IDataPluginServices](./kibana-plugin-plugins-data-public.idatapluginservices.md) | |
| [IEsSearchRequest](./kibana-plugin-plugins-data-public.iessearchrequest.md) | |
| [IFieldSubType](./kibana-plugin-plugins-data-public.ifieldsubtype.md) | |
Expand Down Expand Up @@ -108,7 +107,6 @@
| [esFilters](./kibana-plugin-plugins-data-public.esfilters.md) | |
| [esKuery](./kibana-plugin-plugins-data-public.eskuery.md) | |
| [esQuery](./kibana-plugin-plugins-data-public.esquery.md) | |
| [expandShorthand](./kibana-plugin-plugins-data-public.expandshorthand.md) | |
| [extractSearchSourceReferences](./kibana-plugin-plugins-data-public.extractsearchsourcereferences.md) | |
| [fieldFormats](./kibana-plugin-plugins-data-public.fieldformats.md) | |
| [fieldList](./kibana-plugin-plugins-data-public.fieldlist.md) | |
Expand Down Expand Up @@ -163,7 +161,6 @@
| [ISearch](./kibana-plugin-plugins-data-public.isearch.md) | |
| [ISearchGeneric](./kibana-plugin-plugins-data-public.isearchgeneric.md) | |
| [ISearchSource](./kibana-plugin-plugins-data-public.isearchsource.md) | search source interface |
| [MappingObject](./kibana-plugin-plugins-data-public.mappingobject.md) | |
| [MatchAllFilter](./kibana-plugin-plugins-data-public.matchallfilter.md) | |
| [ParsedInterval](./kibana-plugin-plugins-data-public.parsedinterval.md) | |
| [PhraseFilter](./kibana-plugin-plugins-data-public.phrasefilter.md) | |
Expand Down
1 change: 0 additions & 1 deletion src/plugins/data/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
export * from './constants';
export * from './es_query';
export * from './field_formats';
export * from './field_mapping';
export * from './index_patterns';
export * from './kbn_field_types';
export * from './query';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,34 +34,6 @@ class MockFieldFormatter {}

fieldFormatsMock.getInstance = jest.fn().mockImplementation(() => new MockFieldFormatter()) as any;

jest.mock('../../field_mapping', () => {
const originalModule = jest.requireActual('../../field_mapping');

return {
...originalModule,
expandShorthand: jest.fn(() => ({
id: true,
title: true,
fieldFormatMap: {
_serialize: jest.fn().mockImplementation(() => {}),
_deserialize: jest.fn().mockImplementation(() => []),
},
fields: {
_serialize: jest.fn().mockImplementation(() => {}),
_deserialize: jest.fn().mockImplementation((fields) => fields),
},
sourceFilters: {
_serialize: jest.fn().mockImplementation(() => {}),
_deserialize: jest.fn().mockImplementation(() => undefined),
},
typeMeta: {
_serialize: jest.fn().mockImplementation(() => {}),
_deserialize: jest.fn().mockImplementation(() => undefined),
},
})),
};
});

// helper function to create index patterns
function create(id: string) {
const {
Expand Down
2 changes: 0 additions & 2 deletions src/plugins/data/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -463,8 +463,6 @@ export { isTimeRange, isQuery, isFilter, isFilters } from '../common';

export { ACTION_GLOBAL_APPLY_FILTER, ApplyGlobalFilterActionContext } from './actions';

export * from '../common/field_mapping';

/*
* Plugin setup
*/
Expand Down
18 changes: 0 additions & 18 deletions src/plugins/data/public/public.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -651,11 +651,6 @@ export type ExistsFilter = Filter & {
exists?: FilterExistsProperty;
};

// Warning: (ae-forgotten-export) The symbol "ShorthandFieldMapObject" needs to be exported by the entry point index.d.ts
//
// @public (undocumented)
export const expandShorthand: (sh: Record<string, ShorthandFieldMapObject>) => MappingObject;

// Warning: (ae-missing-release-tag) "extractReferences" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
Expand Down Expand Up @@ -782,16 +777,6 @@ export type FieldFormatsStart = Omit<FieldFormatsRegistry, 'init' & 'register'>
// @public (undocumented)
export const fieldList: (specs?: FieldSpec[], shortDotsEnable?: boolean) => IIndexPatternFieldList;

// @public (undocumented)
export interface FieldMappingSpec {
// (undocumented)
_deserialize?: (mapping: string) => any | undefined;
// (undocumented)
_serialize?: (mapping: any) => string | undefined;
// (undocumented)
type: ES_FIELD_TYPES;
}

// Warning: (ae-missing-release-tag) "Filter" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
Expand Down Expand Up @@ -1518,9 +1503,6 @@ export interface KueryNode {
type: keyof NodeTypes;
}

// @public (undocumented)
export type MappingObject = Record<string, FieldMappingSpec>;

// Warning: (ae-missing-release-tag) "MatchAllFilter" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import {
IndexPattern,
injectSearchSourceReferences,
parseSearchSourceJSON,
expandShorthand,
} from '../../../../data/public';
import { expandShorthand } from './field_mapping';

/**
* A given response of and ElasticSearch containing a plain saved object is applied to the given
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import { expandShorthand } from './mapping_setup';
import { ES_FIELD_TYPES } from '../../../data/common';
import { ES_FIELD_TYPES } from '../../../../../data/public';

describe('mapping_setup', () => {
it('allows shortcuts for field types by just setting the value to the type name', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { mapValues, isString } from 'lodash';
import { FieldMappingSpec, MappingObject } from './types';

// import from ./common/types to prevent circular dependency of kibana_utils <-> data plugin
import { ES_FIELD_TYPES } from '../../../data/common/types';
import { ES_FIELD_TYPES } from '../../../../../data/public';

/** @private */
type ShorthandFieldMapObject = FieldMappingSpec | ES_FIELD_TYPES | 'json';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { ES_FIELD_TYPES } from '../../../data/common';
import { ES_FIELD_TYPES } from '../../../../../data/public';

/** @public */
export interface FieldMappingSpec {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
*/
import _ from 'lodash';
import { SavedObject, SavedObjectConfig } from '../../types';
import { extractSearchSourceReferences, expandShorthand } from '../../../../data/public';
import { extractSearchSourceReferences } from '../../../../data/public';
import { expandShorthand } from './field_mapping';

export function serializeSavedObject(savedObject: SavedObject, config: SavedObjectConfig) {
// mapping definition for the fields that this object will expose
Expand Down