mirror of
https://github.com/elastic/kibana.git
synced 2025-04-25 02:09:32 -04:00
Saved objects: improve typesafety (#140099)
* Remove SavedObjectAttributes from examples * Remove SavedObjectAttributes from dev_docs * Deprecate SavedObjectAttributes type * Remove SavedObjectAttributes from kibana_usage_collection plugin * Remove low hanging SavedObjectAttributes in security_solution * Remove low hanging SavedObjectAttributes in upgrade_assistant * Remove low hanging SavedObjectAttributes in lens * Stricter types for SavedObjectsServiceSetup.registerType * Review feedback * Some more low hanging fruit Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
c9628fc0be
commit
191bfbc97e
28 changed files with 47 additions and 89 deletions
|
@ -19,7 +19,7 @@ export interface SavedObjectsBulkUpdateObject<T = unknown>
|
|||
id: string;
|
||||
/** The type of this Saved Object. Each plugin can define it's own custom Saved Object types. */
|
||||
type: string;
|
||||
/** {@inheritdoc SavedObjectAttributes} */
|
||||
/** The data for a Saved Object is stored as an object in the `attributes` property. **/
|
||||
attributes: Partial<T>;
|
||||
/**
|
||||
* Optional namespace string to use when searching for this object. If this is defined, it will supersede the namespace ID that is in
|
||||
|
|
|
@ -31,6 +31,7 @@ export type SavedObjectAttribute = SavedObjectAttributeSingle | SavedObjectAttri
|
|||
* property.
|
||||
*
|
||||
* @public
|
||||
* @deprecated This type reduces the type safety of your code. Create an interface for your specific saved object type or use `unknown` instead.
|
||||
*/
|
||||
export interface SavedObjectAttributes {
|
||||
[key: string]: SavedObjectAttribute;
|
||||
|
@ -76,7 +77,7 @@ export interface SavedObject<T = unknown> {
|
|||
/** Timestamp of the last time this document had been updated. */
|
||||
updated_at?: string;
|
||||
error?: SavedObjectError;
|
||||
/** {@inheritdoc SavedObjectAttributes} */
|
||||
/** The data for a Saved Object is stored as an object in the `attributes` property. **/
|
||||
attributes: T;
|
||||
/** {@inheritdoc SavedObjectReference} */
|
||||
references: SavedObjectReference[];
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
*/
|
||||
|
||||
import type { KibanaRequest } from '@kbn/core-http-server';
|
||||
import type { SavedObjectAttributes } from '@kbn/core-saved-objects-common';
|
||||
import type {
|
||||
SavedObjectsClientContract,
|
||||
ISavedObjectsRepository,
|
||||
|
@ -124,9 +123,7 @@ export interface SavedObjectsServiceSetup {
|
|||
* }
|
||||
* ```
|
||||
*/
|
||||
registerType: <Attributes extends SavedObjectAttributes = any>(
|
||||
type: SavedObjectsType<Attributes>
|
||||
) => void;
|
||||
registerType: <Attributes = unknown>(type: SavedObjectsType<Attributes>) => void;
|
||||
|
||||
/**
|
||||
* Returns the default index used for saved objects.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue