[data discovery] Remove deprecated saved object type references (#161683)

## Summary

Cleanup after removing saved object browser client usage. Removing usage
of deprecated types, mostly replacing with non-deprecated versions.

Closes https://github.com/elastic/kibana/issues/157073

---------

Co-authored-by: Jean-Louis Leysens <jloleysens@gmail.com>
This commit is contained in:
Matthew Kime 2023-07-12 14:31:33 -05:00 committed by GitHub
parent 3ba51e4a31
commit 0cd98f1dfb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 14 additions and 41 deletions

View file

@ -6,7 +6,7 @@
* Side Public License, v 1.
*/
import { SavedObjectReference } from '@kbn/core/types';
import type { SavedObjectReference } from '@kbn/core/server';
import { Filter } from '@kbn/es-query';
import { DataViewPersistableStateService } from '@kbn/data-views-plugin/common';
import { SerializedSearchSourceFields } from './types';

View file

@ -6,7 +6,7 @@
* Side Public License, v 1.
*/
import { SavedObjectReference } from '@kbn/core/types';
import type { SavedObjectReference } from '@kbn/core/server';
import { SerializedSearchSourceFields } from './types';
import { injectReferences } from './inject_references';

View file

@ -6,7 +6,7 @@
* Side Public License, v 1.
*/
import { SavedObjectReference } from '@kbn/core/types';
import type { SavedObjectReference } from '@kbn/core/server';
import { DataViewPersistableStateService } from '@kbn/data-views-plugin/common';
import { SerializedSearchSourceFields } from './types';

View file

@ -7,7 +7,7 @@
*/
import { i18n } from '@kbn/i18n';
import type { ApplicationStart, NotificationsStart, SavedObject } from '@kbn/core/public';
import type { ApplicationStart, NotificationsStart } from '@kbn/core/public';
import moment from 'moment';
import { from, race, timer } from 'rxjs';
import { mapTo, tap } from 'rxjs/operators';
@ -26,6 +26,11 @@ import { SearchSessionsConfigSchema } from '../../../../../config';
type LocatorsStart = SharePluginStart['url']['locators'];
interface SearchSessionSavedObject {
id: string;
attributes: PersistedSearchSessionSavedObjectAttributes;
}
function getActions(status: UISearchSessionState) {
const actions: ACTION[] = [];
actions.push(ACTION.INSPECT);
@ -65,9 +70,7 @@ const mapToUISession =
config: SearchSessionsConfigSchema,
sessionStatuses: SearchSessionsFindResponse['statuses']
) =>
async (
savedObject: SavedObject<PersistedSearchSessionSavedObjectAttributes>
): Promise<UISession> => {
async (savedObject: SearchSessionSavedObject): Promise<UISession> => {
const {
name,
appId,
@ -152,9 +155,7 @@ export class SearchSessionsMgmtAPI {
try {
const result = await race(fetch$, timeout$).toPromise();
if (result && result.saved_objects) {
const savedObjects = result.saved_objects as Array<
SavedObject<PersistedSearchSessionSavedObjectAttributes>
>;
const savedObjects = result.saved_objects as SearchSessionSavedObject[];
return await Promise.all(
savedObjects.map(mapToUISession(this.deps.locators, this.config, result.statuses))
);

View file

@ -13,7 +13,7 @@ import {
SearchSessionSavedObjectAttributesPre$8$0$0,
SearchSessionSavedObjectAttributesPre$8$6$0,
} from './search_session_migration';
import { SavedObject } from '@kbn/core/types';
import type { SavedObject } from '@kbn/core/server';
import { SEARCH_SESSION_TYPE, SearchSessionStatus, SearchStatus } from '../../../common';
import { SavedObjectMigrationContext } from '@kbn/core/server';
import { SavedObjectsUtils } from '@kbn/core-saved-objects-utils-server';

View file

@ -7,7 +7,7 @@
*/
import { DataViewPersistableStateService } from './persistable_state';
import { SavedObjectReference } from '@kbn/core/types';
import type { SavedObjectReference } from '@kbn/core/server';
import { DataViewSpec } from '../types';
const { inject, extract } = DataViewPersistableStateService;

View file

@ -8,7 +8,7 @@
import { i18n } from '@kbn/i18n';
import { ExpressionFunctionDefinition } from '@kbn/expressions-plugin/common';
import { SavedObjectReference } from '@kbn/core/types';
import type { SavedObjectReference } from '@kbn/core/server';
import { DataViewsContract } from '../data_views';
import { DataViewSpec } from '..';

View file

@ -1,27 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import type { SavedObjectsClientContract } from '@kbn/core/public';
import { DATA_VIEW_SAVED_OBJECT_TYPE } from '../constants';
import { DataViewAttributes } from '../types';
export async function getTitle(
client: SavedObjectsClientContract,
indexPatternId: string
): Promise<string> {
const savedObject = await client.get<DataViewAttributes>(
DATA_VIEW_SAVED_OBJECT_TYPE,
indexPatternId
);
if (savedObject.error) {
throw new Error(`Unable to get index-pattern title: ${savedObject.error.message}`);
}
return savedObject.attributes.title;
}

View file

@ -7,7 +7,6 @@
*/
export { DataViewMissingIndices } from './errors';
export { getTitle } from './get_title';
export * from './types';
export { validateDataView } from './validate_data_view';