Skip to content

Commit

Permalink
removes all client side WIP for bulkDelete
Browse files Browse the repository at this point in the history
  • Loading branch information
TinaHeiligers committed Aug 26, 2022
1 parent e3cbbc6 commit 82c2539
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 86 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ import type {
SavedObjectsFindOptions,
SavedObjectsUpdateOptions,
SavedObjectsDeleteOptions,
SavedObjectsBulkDeleteObject,
SavedObjectsBulkDeleteOptions,
SavedObjectsBulkDeleteResponse,
// SavedObjectsBulkDeleteObject,
// SavedObjectsBulkDeleteOptions,
// SavedObjectsBulkDeleteResponse,
} from './apis';
import type { SimpleSavedObject } from './simple_saved_object';

Expand Down Expand Up @@ -157,15 +157,4 @@ export interface SavedObjectsClientContract {
bulkUpdate<T = unknown>(
objects: SavedObjectsBulkUpdateObject[]
): Promise<SavedObjectsBatchResponse<T>>;

/**
* Delete multiple documents at once
*
* @param {array} objects - [{ type, id }]
* @returns The result of the delete operation containing both failed and deleted saved objects' ids and types, and success flag (true for deleted, false for errors).
*/
bulkDelete<T = unknown>(
objects: SavedObjectsBulkDeleteObject[],
options?: SavedObjectsBulkDeleteOptions
): Promise<SavedObjectsBulkDeleteResponse>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ import { pick, throttle, cloneDeep } from 'lodash';
import type { HttpSetup, HttpFetchOptions } from '@kbn/core-http-browser';
import type { SavedObject, SavedObjectTypeIdTuple } from '@kbn/core-saved-objects-common';
import type {
SavedObjectsBulkDeleteObject,
SavedObjectsBulkDeleteOptions,
SavedObjectsBulkDeleteResponse,
SavedObjectsBulkResolveResponse as SavedObjectsBulkResolveResponseServer,
SavedObjectsClientContract as SavedObjectsApi,
SavedObjectsFindResponse as SavedObjectsFindResponseServer,
Expand All @@ -21,6 +18,7 @@ import type {
import type {
SavedObjectsClientContract,
SavedObjectsCreateOptions,
// SavedObjectsBulkDeleteObject,
// SavedObjectsBulkDeleteOptions,
SavedObjectsDeleteOptions,
SavedObjectsBatchResponse,
Expand Down Expand Up @@ -259,38 +257,6 @@ export class SavedObjectsClient implements SavedObjectsClientContract {
return this.savedObjectsFetch(this.getPath([type, id]), { method: 'DELETE', query });
};

public bulkDelete = async (
objects: SavedObjectsBulkDeleteObject[],
options?: SavedObjectsBulkDeleteOptions
): Promise<ReturnType<SavedObjectsApi['bulkDelete']>> => {
const filteredObjects = objects.map((obj) => pick(obj, ['id', 'type']));
if (filteredObjects.length === 0) {
return Promise.reject(new Error('objects require type and id'));
}

const query = {
force: !!options?.force,
refresh: !!options?.refresh,
};

return await this.performBulkDelete(filteredObjects, query);
};

private async performBulkDelete<T>(
objects: SavedObjectsBulkDeleteObject[],
query: SavedObjectsBulkDeleteOptions
) {
const path = this.getPath(['_bulk_delete']);
const request: Promise<SavedObjectsBulkDeleteResponse> = this.savedObjectsFetch(path, {
method: 'POST',
body: JSON.stringify(objects),
query: {
...query,
},
});
return request;
}

public find = <T = unknown, A = unknown>(
options: SavedObjectsFindOptions
): Promise<SavedObjectsFindResponse<T>> => {
Expand Down

0 comments on commit 82c2539

Please sign in to comment.