Skip to content

Commit a987ce9

Browse files
committed
fixing error with importing static code into examples
1 parent 46d6952 commit a987ce9

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
5+
* in compliance with, at your election, the Elastic License 2.0 or the Server
6+
* Side Public License, v 1.
7+
*/
8+
9+
import { mergeWith } from 'lodash';
10+
import type { SerializableRecord } from '@kbn/utility-types';
11+
import { MigrateFunctionsObject, MigrateFunction } from '../../../src/plugins/kibana_utils/common';
12+
13+
export const mergeMigrationFunctionMaps = (
14+
obj1: MigrateFunctionsObject,
15+
obj2: MigrateFunctionsObject
16+
) => {
17+
const customizer = (objValue: MigrateFunction, srcValue: MigrateFunction) => {
18+
if (!srcValue || !objValue) {
19+
return srcValue || objValue;
20+
}
21+
return (state: SerializableRecord) => objValue(srcValue(state));
22+
};
23+
24+
return mergeWith({ ...obj1 }, obj2, customizer);
25+
};

examples/embeddable_examples/server/searchable_list_saved_object.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
import { mapValues } from 'lodash';
1010
import { SavedObjectsType, SavedObjectUnsanitizedDoc } from 'kibana/server';
1111
import { EmbeddableSetup } from '../../../src/plugins/embeddable/server';
12-
import { mergeMigrationFunctionMaps } from '../../../src/plugins/kibana_utils/server';
12+
// NOTE: this should rather be imported from 'plugins/kibana_utils/server' but examples at the moment don't
13+
// allow static imports from plugins so this code was duplicated
14+
import { mergeMigrationFunctionMaps } from './merge_migration_function_maps';
1315

1416
export const searchableListSavedObject = (embeddable: EmbeddableSetup) => {
1517
const searchableListSO: SavedObjectsType = {

0 commit comments

Comments
 (0)