kibana/packages/kbn-content-management-utils
Anton Dosov 6fd9909b5e
[CM] Soften response validation (#166919)
## Summary

Close https://github.com/elastic/kibana/issues/167152

Log a warning instead of throwing an error in
`saved_object_content_storage` when response validation failed.

We decided to do this as a precaution and as a follow up to an issue
found in saved search https://github.com/elastic/kibana/pull/166886
where storage started failing because of too strict validation.

As of this PR the saved_object_content_storage covers and this change
cover:

- `search`
- `index_pattern`
- `dashboard`
- `lens`
- `maps`

For other types we agreed with @dej611 that instead of applying the same
change for other types (visualization, graph, annotation) the team would
look into migrating their types to also use
`saved_object_content_storage`
https://github.com/elastic/kibana/issues/167421
2023-09-28 16:33:04 +02:00
..
src [CM] Soften response validation (#166919) 2023-09-28 16:33:04 +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 [CM] Soften response validation (#166919) 2023-09-28 16:33:04 +02: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;