From 2b388684b70a7407c0206858ae6ffcc611b53479 Mon Sep 17 00:00:00 2001 From: Hailong Cui Date: Fri, 13 Oct 2023 10:37:09 +0800 Subject: [PATCH] fix merge issue Signed-off-by: Hailong Cui --- src/core/server/index.ts | 2 +- .../service/lib/repository.test.js | 10 +-- .../saved_objects/service/lib/repository.ts | 70 +++++++++---------- .../service/saved_objects_client.ts | 9 --- 4 files changed, 40 insertions(+), 51 deletions(-) diff --git a/src/core/server/index.ts b/src/core/server/index.ts index 92bcfed7ffe1..01b24777b0bd 100644 --- a/src/core/server/index.ts +++ b/src/core/server/index.ts @@ -477,7 +477,7 @@ export interface CoreSetup = () => Promise<[CoreStart, TPluginsStart, TStart]>; +> = () => Promise<[CoreStart, TPluginsStart, TStart]>; /** * Context passed to the plugins `start` method. diff --git a/src/core/server/saved_objects/service/lib/repository.test.js b/src/core/server/saved_objects/service/lib/repository.test.js index 6cc9808d02e4..816d1013e5be 100644 --- a/src/core/server/saved_objects/service/lib/repository.test.js +++ b/src/core/server/saved_objects/service/lib/repository.test.js @@ -175,8 +175,9 @@ describe('SavedObjectsRepository', () => { return { // NOTE: OpenSearch returns more fields (_index, _type) but the SavedObjectsRepository method ignores these found: true, - _id: `${registry.isSingleNamespace(type) && namespaceId ? `${namespaceId}:` : '' - }${type}:${id}`, + _id: `${ + registry.isSingleNamespace(type) && namespaceId ? `${namespaceId}:` : '' + }${type}:${id}`, ...mockVersionProps, _source: { ...(registry.isSingleNamespace(type) && { namespace: namespaceId }), @@ -1443,8 +1444,9 @@ describe('SavedObjectsRepository', () => { const getMockBulkUpdateResponse = (objects, options, includeOriginId) => ({ items: objects.map(({ type, id }) => ({ update: { - _id: `${registry.isSingleNamespace(type) && options?.namespace ? `${options?.namespace}:` : '' - }${type}:${id}`, + _id: `${ + registry.isSingleNamespace(type) && options?.namespace ? `${options?.namespace}:` : '' + }${type}:${id}`, ...mockVersionProps, get: { _source: { diff --git a/src/core/server/saved_objects/service/lib/repository.ts b/src/core/server/saved_objects/service/lib/repository.ts index 94589c504a28..a8fd54ef6cfe 100644 --- a/src/core/server/saved_objects/service/lib/repository.ts +++ b/src/core/server/saved_objects/service/lib/repository.ts @@ -421,13 +421,13 @@ export class SavedObjectsRepository { })); const bulkGetResponse = bulkGetDocs.length ? await this.client.mget( - { - body: { - docs: bulkGetDocs, + { + body: { + docs: bulkGetDocs, + }, }, - }, - { ignore: [404] } - ) + { ignore: [404] } + ) : undefined; let bulkRequestIndexCounter = 0; @@ -562,9 +562,9 @@ export class SavedObjectsRepository { const bulkResponse = bulkCreateParams.length ? await this.client.bulk({ - refresh, - body: bulkCreateParams, - }) + refresh, + body: bulkCreateParams, + }) : undefined; return { @@ -643,13 +643,13 @@ export class SavedObjectsRepository { })); const bulkGetResponse = bulkGetDocs.length ? await this.client.mget( - { - body: { - docs: bulkGetDocs, + { + body: { + docs: bulkGetDocs, + }, }, - }, - { ignore: [404] } - ) + { ignore: [404] } + ) : undefined; const errors: SavedObjectsCheckConflictsResponse['errors'] = []; @@ -804,11 +804,7 @@ export class SavedObjectsRepository { } /** -<<<<<<< HEAD - * Deletes all objects from the provided workspace. It used when delete a workspace. -======= * Deletes all objects from the provided workspace. It used when deleting a workspace. ->>>>>>> 7773811875 ([API] Delete saved objects by workspace (#216)) * * @param {string} workspace * @param options SavedObjectsDeleteByWorkspaceOptions @@ -1063,13 +1059,13 @@ export class SavedObjectsRepository { })); const bulkGetResponse = bulkGetDocs.length ? await this.client.mget( - { - body: { - docs: bulkGetDocs, + { + body: { + docs: bulkGetDocs, + }, }, - }, - { ignore: [404] } - ) + { ignore: [404] } + ) : undefined; return { @@ -1696,15 +1692,15 @@ export class SavedObjectsRepository { })); const bulkGetResponse = bulkGetDocs.length ? await this.client.mget( - { - body: { - docs: bulkGetDocs, + { + body: { + docs: bulkGetDocs, + }, }, - }, - { - ignore: [404], - } - ) + { + ignore: [404], + } + ) : undefined; let bulkUpdateRequestIndexCounter = 0; @@ -1787,10 +1783,10 @@ export class SavedObjectsRepository { const { refresh = DEFAULT_REFRESH_SETTING } = options; const bulkUpdateResponse = bulkUpdateParams.length ? await this.client.bulk({ - refresh, - body: bulkUpdateParams, - _source_includes: ['originId'], - }) + refresh, + body: bulkUpdateParams, + _source_includes: ['originId'], + }) : undefined; return { diff --git a/src/core/server/saved_objects/service/saved_objects_client.ts b/src/core/server/saved_objects/service/saved_objects_client.ts index e3efbcf552de..4f430d7f7134 100644 --- a/src/core/server/saved_objects/service/saved_objects_client.ts +++ b/src/core/server/saved_objects/service/saved_objects_client.ts @@ -309,15 +309,6 @@ export interface SavedObjectsUpdateResponse references: SavedObjectReference[] | undefined; } -/** - * - * @public - */ -export interface SavedObjectsDeleteByWorkspaceOptions extends SavedObjectsBaseOptions { - /** The OpenSearch supports only boolean flag for this operation */ - refresh?: boolean; -} - /** * * @public