Skip to content

Commit

Permalink
[Maps] move MapSavedObject type out of telemetry
Browse files Browse the repository at this point in the history
  • Loading branch information
nreese committed Mar 13, 2020
1 parent 526972e commit d569213
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 29 deletions.
32 changes: 3 additions & 29 deletions x-pack/legacy/plugins/maps/server/maps_telemetry/maps_telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
// @ts-ignore
} from '../../common/constants';
import { LayerDescriptor } from '../../common/descriptor_types';
import { MapSavedObject } from '../../../../../plugins/maps/common/map_saved_object_type';

interface IStats {
[key: string]: {
Expand All @@ -32,33 +33,6 @@ interface ILayerTypeCount {
[key: string]: number;
}

interface IMapSavedObject {
[key: string]: any;
fields: IFieldType[];
title: string;
id?: string;
type?: string;
timeFieldName?: string;
fieldFormatMap?: Record<
string,
{
id: string;
params: unknown;
}
>;
attributes?: {
title?: string;
description?: string;
mapStateJSON?: string;
layerListJSON?: string;
uiStateJSON?: string;
bounds?: {
type?: string;
coordinates?: [];
};
};
}

function getUniqueLayerCounts(layerCountsList: ILayerTypeCount[], mapsCount: number) {
const uniqueLayerTypes = _.uniq(_.flatten(layerCountsList.map(lTypes => Object.keys(lTypes))));

Expand Down Expand Up @@ -102,7 +76,7 @@ export function buildMapsTelemetry({
indexPatternSavedObjects,
settings,
}: {
mapSavedObjects: IMapSavedObject[];
mapSavedObjects: MapSavedObject[];
indexPatternSavedObjects: IIndexPattern[];
settings: SavedObjectAttribute;
}): SavedObjectAttributes {
Expand Down Expand Up @@ -183,7 +157,7 @@ export async function getMapsTelemetry(
savedObjectsClient: SavedObjectsClientContract,
config: Function
) {
const mapSavedObjects: IMapSavedObject[] = await getMapSavedObjects(savedObjectsClient);
const mapSavedObjects: MapSavedObject[] = await getMapSavedObjects(savedObjectsClient);
const indexPatternSavedObjects: IIndexPattern[] = await getIndexPatternSavedObjects(
savedObjectsClient
);
Expand Down
23 changes: 23 additions & 0 deletions x-pack/plugins/maps/common/map_saved_object_type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* 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.
*/
/* eslint-disable @typescript-eslint/consistent-type-definitions */

// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { SavedObject } from '../../../../src/core/server';

export type MapSavedObjectAttributes = {
title?: string;
description?: string;
mapStateJSON?: string;
layerListJSON?: string;
uiStateJSON?: string;
bounds?: {
type?: string;
coordinates?: [];
};
};

export type MapSavedObject = SavedObject<MapSavedObjectAttributes>;

0 comments on commit d569213

Please sign in to comment.