mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[Maps] move MapSavedObject type out of telemetry (#60127)
* [Maps] move MapSavedObject type out of telemetry * move SavedObject from server to core/types * review feedback * results from check_published_api_changes
This commit is contained in:
parent
537fa8c1eb
commit
ef3261132a
9 changed files with 93 additions and 90 deletions
|
@ -4,7 +4,6 @@
|
|||
|
||||
## SavedObject interface
|
||||
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
## SavedObject interface
|
||||
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
|
|
|
@ -944,6 +944,8 @@ export type RecursiveReadonly<T> = T extends (...args: any[]) => any ? T : T ext
|
|||
[K in keyof T]: RecursiveReadonly<T[K]>;
|
||||
}> : T;
|
||||
|
||||
// Warning: (ae-missing-release-tag) "SavedObject" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||
//
|
||||
// @public (undocumented)
|
||||
export interface SavedObject<T = unknown> {
|
||||
attributes: T;
|
||||
|
|
|
@ -32,11 +32,6 @@ export {
|
|||
export { SimpleSavedObject } from './simple_saved_object';
|
||||
export { SavedObjectsStart, SavedObjectsService } from './saved_objects_service';
|
||||
export {
|
||||
SavedObject,
|
||||
SavedObjectAttribute,
|
||||
SavedObjectAttributes,
|
||||
SavedObjectAttributeSingle,
|
||||
SavedObjectReference,
|
||||
SavedObjectsBaseOptions,
|
||||
SavedObjectsFindOptions,
|
||||
SavedObjectsMigrationVersion,
|
||||
|
@ -48,3 +43,11 @@ export {
|
|||
SavedObjectsImportError,
|
||||
SavedObjectsImportRetry,
|
||||
} from '../../server/types';
|
||||
|
||||
export {
|
||||
SavedObject,
|
||||
SavedObjectAttribute,
|
||||
SavedObjectAttributes,
|
||||
SavedObjectAttributeSingle,
|
||||
SavedObjectReference,
|
||||
} from '../../types';
|
||||
|
|
|
@ -35,66 +35,17 @@ export {
|
|||
import { LegacyConfig } from '../legacy';
|
||||
import { SavedObjectUnsanitizedDoc } from './serialization';
|
||||
import { SavedObjectsMigrationLogger } from './migrations/core/migration_logger';
|
||||
import { SavedObject } from '../../types';
|
||||
|
||||
export {
|
||||
SavedObjectAttributes,
|
||||
SavedObjectAttribute,
|
||||
SavedObjectAttributeSingle,
|
||||
SavedObject,
|
||||
SavedObjectReference,
|
||||
SavedObjectsMigrationVersion,
|
||||
} from '../../types';
|
||||
|
||||
/**
|
||||
* Information about the migrations that have been applied to this SavedObject.
|
||||
* When Kibana starts up, KibanaMigrator detects outdated documents and
|
||||
* migrates them based on this value. For each migration that has been applied,
|
||||
* the plugin's name is used as a key and the latest migration version as the
|
||||
* value.
|
||||
*
|
||||
* @example
|
||||
* migrationVersion: {
|
||||
* dashboard: '7.1.1',
|
||||
* space: '6.6.6',
|
||||
* }
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface SavedObjectsMigrationVersion {
|
||||
[pluginName: string]: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface SavedObject<T = unknown> {
|
||||
/** The ID of this Saved Object, guaranteed to be unique for all objects of the same `type` */
|
||||
id: string;
|
||||
/** The type of Saved Object. Each plugin can define it's own custom Saved Object types. */
|
||||
type: string;
|
||||
/** An opaque version number which changes on each successful write operation. Can be used for implementing optimistic concurrency control. */
|
||||
version?: string;
|
||||
/** Timestamp of the last time this document had been updated. */
|
||||
updated_at?: string;
|
||||
error?: {
|
||||
message: string;
|
||||
statusCode: number;
|
||||
};
|
||||
/** {@inheritdoc SavedObjectAttributes} */
|
||||
attributes: T;
|
||||
/** {@inheritdoc SavedObjectReference} */
|
||||
references: SavedObjectReference[];
|
||||
/** {@inheritdoc SavedObjectsMigrationVersion} */
|
||||
migrationVersion?: SavedObjectsMigrationVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* A reference to another saved object.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface SavedObjectReference {
|
||||
name: string;
|
||||
type: string;
|
||||
id: string;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @public
|
||||
|
|
|
@ -1595,6 +1595,8 @@ export interface RouteValidatorOptions {
|
|||
// @public
|
||||
export type SafeRouteMethod = 'get' | 'options';
|
||||
|
||||
// Warning: (ae-missing-release-tag) "SavedObject" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||
//
|
||||
// @public (undocumented)
|
||||
export interface SavedObject<T = unknown> {
|
||||
attributes: T;
|
||||
|
|
|
@ -46,3 +46,54 @@ export type SavedObjectAttribute = SavedObjectAttributeSingle | SavedObjectAttri
|
|||
export interface SavedObjectAttributes {
|
||||
[key: string]: SavedObjectAttribute;
|
||||
}
|
||||
|
||||
/**
|
||||
* A reference to another saved object.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface SavedObjectReference {
|
||||
name: string;
|
||||
type: string;
|
||||
id: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Information about the migrations that have been applied to this SavedObject.
|
||||
* When Kibana starts up, KibanaMigrator detects outdated documents and
|
||||
* migrates them based on this value. For each migration that has been applied,
|
||||
* the plugin's name is used as a key and the latest migration version as the
|
||||
* value.
|
||||
*
|
||||
* @example
|
||||
* migrationVersion: {
|
||||
* dashboard: '7.1.1',
|
||||
* space: '6.6.6',
|
||||
* }
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface SavedObjectsMigrationVersion {
|
||||
[pluginName: string]: string;
|
||||
}
|
||||
|
||||
export interface SavedObject<T = unknown> {
|
||||
/** The ID of this Saved Object, guaranteed to be unique for all objects of the same `type` */
|
||||
id: string;
|
||||
/** The type of Saved Object. Each plugin can define it's own custom Saved Object types. */
|
||||
type: string;
|
||||
/** An opaque version number which changes on each successful write operation. Can be used for implementing optimistic concurrency control. */
|
||||
version?: string;
|
||||
/** Timestamp of the last time this document had been updated. */
|
||||
updated_at?: string;
|
||||
error?: {
|
||||
message: string;
|
||||
statusCode: number;
|
||||
};
|
||||
/** {@inheritdoc SavedObjectAttributes} */
|
||||
attributes: T;
|
||||
/** {@inheritdoc SavedObjectReference} */
|
||||
references: SavedObjectReference[];
|
||||
/** {@inheritdoc SavedObjectsMigrationVersion} */
|
||||
migrationVersion?: SavedObjectsMigrationVersion;
|
||||
}
|
||||
|
|
|
@ -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]: {
|
||||
|
@ -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))));
|
||||
|
||||
|
@ -102,7 +76,7 @@ export function buildMapsTelemetry({
|
|||
indexPatternSavedObjects,
|
||||
settings,
|
||||
}: {
|
||||
mapSavedObjects: IMapSavedObject[];
|
||||
mapSavedObjects: MapSavedObject[];
|
||||
indexPatternSavedObjects: IIndexPattern[];
|
||||
settings: SavedObjectAttribute;
|
||||
}): SavedObjectAttributes {
|
||||
|
@ -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
|
||||
);
|
||||
|
|
22
x-pack/plugins/maps/common/map_saved_object_type.ts
Normal file
22
x-pack/plugins/maps/common/map_saved_object_type.ts
Normal file
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* 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 */
|
||||
|
||||
import { SavedObject } from '../../../../src/core/types/saved_objects';
|
||||
|
||||
export type MapSavedObjectAttributes = {
|
||||
title?: string;
|
||||
description?: string;
|
||||
mapStateJSON?: string;
|
||||
layerListJSON?: string;
|
||||
uiStateJSON?: string;
|
||||
bounds?: {
|
||||
type?: string;
|
||||
coordinates?: [];
|
||||
};
|
||||
};
|
||||
|
||||
export type MapSavedObject = SavedObject<MapSavedObjectAttributes>;
|
Loading…
Add table
Add a link
Reference in a new issue