kibana/packages/kbn-content-management-utils
Anton Dosov 304cb256cf
Make SavedObjectFinder backward compatible (#162904)
## Summary

close https://github.com/elastic/kibana/issues/161545
close https://github.com/elastic/kibana/issues/153257

This PR makes `SavedObjectFinder` component backward compatible. It is
achieved by going through content- management layer, more technical
details
[here](https://docs.google.com/document/d/1ssYmqSEUPrsuCR4iz8DohkEWekoYrm2yL4QR_fVxXLg/edit)

### Testing

`SavedObjectFinder` is this component that allows to pick a saved object
(supports: `search` `index-pattern` `map` `visualization` `lens`
`event-annotation-group`:

![Screenshot 2023-08-07 at 16 53
32](5c283ea5-3682-4dc8-a8ff-422e6f4f3195)


It is used in the following places: 

- Dashboard 
  - Add panel
  - Replace panel 
- Discover - Open Search 
- Visualization - Select search as a source for new viz
- Graph - select source
- Cases - markdown editor add lens 
- ML (3 places) 
- Canvas - select embeddable panel 
- Transform 
- Lens > select event annotation 




### Risks / Follow up 

The `SavedObjectFinder` should stay mostly the same, the only notable
functional change is that now `SavedObjectFinder` doesn't support
`includeFields` which allowed partial saved object returns, this was
done to make the call backward-compatible without making the system even
more complicated as otherwise we'll need a way to abstract
`includeFields` from so attributes and allow to run migrations on it
before making a search. follow up issue to bring it back
https://github.com/elastic/kibana/issues/163043

The risk with that is that some client that have a lot of large objects
might run into performance issues when using `SavedObjectFinder`. This
can be mitigated by changing listing limit in advanced setting from
default 1000 to something lower
2023-08-08 13:10:29 +02:00
..
src Make SavedObjectFinder backward compatible (#162904) 2023-08-08 13:10:29 +02:00
index.ts Add content management mSearch to viz, lens, and event annotation group (#162450) 2023-07-26 06:37:45 -07:00
jest.config.js [content management / maps] Create abstract types for saved object usage with content management api (#154985) 2023-04-24 20:58:22 -05:00
kibana.jsonc [content management / maps] Create abstract types for saved object usage with content management api (#154985) 2023-04-24 20:58:22 -05:00
package.json [content management / maps] Create abstract types for saved object usage with content management api (#154985) 2023-04-24 20:58:22 -05:00
README.md [content management / maps] Create abstract types for saved object usage with content management api (#154985) 2023-04-24 20:58:22 -05:00
tsconfig.json [content mgmt / maps] Saved Object wrapper for Content Management API (#155680) 2023-05-16 07:11:21 -07:00

Content management utils

Utilities to ease the implementation of the Content Management API with Saved Objects.

import type {
  ContentManagementCrudTypes,
  CreateOptions,
  SearchOptions,
  UpdateOptions,
} from '@kbn/content-management-utils';
import { MapContentType } from '../types';

export type MapCrudTypes = ContentManagementCrudTypes<MapContentType, MapAttributes>;

/* eslint-disable-next-line @typescript-eslint/consistent-type-definitions */
export type MapAttributes = {
  title: string;
  description?: string;
  mapStateJSON?: string;
  layerListJSON?: string;
  uiStateJSON?: string;
};

export type MapItem = MapCrudTypes['Item'];
export type PartialMapItem = MapCrudTypes['PartialItem'];

// ----------- GET --------------

export type MapGetIn = MapCrudTypes['GetIn'];
export type MapGetOut = MapCrudTypes['GetOut'];

// ----------- CREATE --------------

export type MapCreateIn = MapCrudTypes['CreateIn'];
export type MapCreateOut = MapCrudTypes['CreateOut'];
export type MapCreateOptions = CreateOptions;

// ----------- UPDATE --------------

export type MapUpdateIn = MapCrudTypes['UpdateIn'];
export type MapUpdateOut = MapCrudTypes['UpdateOut'];
export type MapUpdateOptions = UpdateOptions;

// ----------- DELETE --------------

export type MapDeleteIn = MapCrudTypes['DeleteIn'];
export type MapDeleteOut = MapCrudTypes['DeleteOut'];

// ----------- SEARCH --------------

export type MapSearchIn = MapCrudTypes['SearchIn'];
export type MapSearchOut = MapCrudTypes['SearchOut'];
export type MapSearchOptions = SearchOptions;