Skip to content

Commit

Permalink
Migrate visualization, annotation, graph to `saved_object_cont…
Browse files Browse the repository at this point in the history
…ent_storage` (elastic#168520)

## Summary

Close elastic#167421

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
2 people authored and dej611 committed Oct 17, 2023
1 parent ad2b2f4 commit 6889ac5
Show file tree
Hide file tree
Showing 22 changed files with 143 additions and 970 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,20 @@ export type UpdateArgsToSoUpdateOptions<Types extends CMCrudTypes> = (
params: Types['UpdateOptions']
) => SavedObjectsUpdateOptions<Types['Attributes']>;

export interface SOContentStorageConstrutorParams<Types extends CMCrudTypes> {
export interface SOContentStorageConstructorParams<Types extends CMCrudTypes> {
savedObjectType: string;
cmServicesDefinition: ServicesDefinitionSet;
// this is necessary since unexpected saved object attributes could cause schema validation to fail
allowedSavedObjectAttributes: string[];
createArgsToSoCreateOptions?: CreateArgsToSoCreateOptions<Types>;
updateArgsToSoUpdateOptions?: UpdateArgsToSoUpdateOptions<Types>;
searchArgsToSOFindOptions?: SearchArgsToSOFindOptions<Types>;
/**
* MSearch is a feature that allows searching across multiple content types
* (for example, could be used in a general content finder or the like)
*
* defaults to false
*/
enableMSearch?: boolean;
mSearchAdditionalSearchFields?: string[];

Expand All @@ -163,7 +169,7 @@ export abstract class SOContentStorage<Types extends CMCrudTypes>
mSearchAdditionalSearchFields,
logger,
throwOnResultValidationError,
}: SOContentStorageConstrutorParams<Types>) {
}: SOContentStorageConstructorParams<Types>) {
this.logger = logger;
this.throwOnResultValidationError = throwOnResultValidationError ?? false;
this.savedObjectType = savedObjectType;
Expand Down Expand Up @@ -219,8 +225,8 @@ export abstract class SOContentStorage<Types extends CMCrudTypes>

private throwOnResultValidationError: boolean;
private logger: Logger;
private savedObjectType: SOContentStorageConstrutorParams<Types>['savedObjectType'];
private cmServicesDefinition: SOContentStorageConstrutorParams<Types>['cmServicesDefinition'];
private savedObjectType: SOContentStorageConstructorParams<Types>['savedObjectType'];
private cmServicesDefinition: SOContentStorageConstructorParams<Types>['cmServicesDefinition'];
private createArgsToSoCreateOptions: CreateArgsToSoCreateOptions<Types>;
private updateArgsToSoUpdateOptions: UpdateArgsToSoUpdateOptions<Types>;
private searchArgsToSOFindOptions: SearchArgsToSOFindOptions<Types>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export type {
EventAnnotationGroupSearchIn,
EventAnnotationGroupSearchOut,
EventAnnotationGroupSearchQuery,
EventAnnotationGroupCrudTypes,
} from './latest';

export * as EventAnnotationGroupV1 from './v1';
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ export type {
EventAnnotationGroupSearchIn,
EventAnnotationGroupSearchOut,
EventAnnotationGroupSearchQuery,
EventAnnotationGroupCrudTypes,
Reference,
} from './types';
11 changes: 11 additions & 0 deletions src/plugins/event_annotation/common/content_management/v1/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
CreateResult,
UpdateResult,
} from '@kbn/content-management-plugin/common';
import { ContentManagementCrudTypes } from '@kbn/content-management-utils';

import type { DataViewSpec } from '@kbn/data-views-plugin/common';
import type { EventAnnotationConfig } from '@kbn/event-annotation-common';
Expand Down Expand Up @@ -125,3 +126,13 @@ export type EventAnnotationGroupSearchIn = SearchIn<
>;

export type EventAnnotationGroupSearchOut = SearchResult<EventAnnotationGroupSavedObject>;

// ----------- CRUD TYPES --------------

export type EventAnnotationGroupCrudTypes = ContentManagementCrudTypes<
EventAnnotationGroupContentType,
EventAnnotationGroupSavedObjectAttributes,
CreateOptions,
UpdateOptions,
{}
>;
1 change: 1 addition & 0 deletions src/plugins/event_annotation/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export type {
EventAnnotationGroupSearchOut,
EventAnnotationGroupDeleteIn,
EventAnnotationGroupDeleteOut,
EventAnnotationGroupCrudTypes,
} from './content_management';
export { CONTENT_ID } from './content_management';
export { ANNOTATIONS_LISTING_VIEW_ID } from './constants';
Loading

0 comments on commit 6889ac5

Please sign in to comment.