Skip to content

Commit

Permalink
move SavedObject from server to core/types
Browse files Browse the repository at this point in the history
  • Loading branch information
nreese committed Mar 13, 2020
1 parent d569213 commit 8e3b639
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 56 deletions.
59 changes: 5 additions & 54 deletions src/core/server/saved_objects/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
51 changes: 51 additions & 0 deletions src/core/types/saved_objects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
3 changes: 1 addition & 2 deletions x-pack/plugins/maps/common/map_saved_object_type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
*/
/* eslint-disable @typescript-eslint/consistent-type-definitions */

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

export type MapSavedObjectAttributes = {
title?: string;
Expand Down

0 comments on commit 8e3b639

Please sign in to comment.