mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
Exclude migrationVersion and references from getRootPropertiesObjects result (#30081)
This commit is contained in:
parent
6b74470eae
commit
f852812012
2 changed files with 29 additions and 1 deletions
|
@ -33,12 +33,18 @@ import { getRootProperties } from './get_root_properties';
|
|||
* @param {EsMappingsDsl} mappings
|
||||
* @return {EsPropertyMappings}
|
||||
*/
|
||||
|
||||
const blacklist = [
|
||||
'migrationVersion',
|
||||
'references',
|
||||
];
|
||||
|
||||
export function getRootPropertiesObjects(mappings) {
|
||||
const rootProperties = getRootProperties(mappings);
|
||||
return Object.entries(rootProperties).reduce((acc, [key, value]) => {
|
||||
|
||||
// we consider the existence of the properties or type of object to designate that this is an object datatype
|
||||
if (value.properties || value.type === 'object') {
|
||||
if (!blacklist.includes(key) && (value.properties || value.type === 'object')) {
|
||||
acc[key] = value;
|
||||
}
|
||||
|
||||
|
|
|
@ -167,3 +167,25 @@ test(`includes one object with type === 'object' and excludes one object without
|
|||
}
|
||||
});
|
||||
});
|
||||
|
||||
test('excludes references and migrationVersion which are part of the blacklist', () => {
|
||||
const mappings = {
|
||||
properties: {
|
||||
references: {
|
||||
type: 'object',
|
||||
},
|
||||
migrationVersion: {
|
||||
type: 'object',
|
||||
},
|
||||
foo: {
|
||||
type: 'object',
|
||||
},
|
||||
},
|
||||
};
|
||||
const result = getRootPropertiesObjects(mappings);
|
||||
expect(result).toEqual({
|
||||
foo: {
|
||||
type: 'object',
|
||||
},
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue