Skip to content

Commit

Permalink
Merge branch 'master' into securiy-solution-search-strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored Aug 20, 2020
2 parents 8731418 + bcca933 commit a2c7e4e
Show file tree
Hide file tree
Showing 216 changed files with 5,172 additions and 1,900 deletions.
2 changes: 2 additions & 0 deletions docs/development/core/server/kibana-plugin-core-server.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ The plugin integrates with the core system via lifecycle events: `setup`<!-- -->
| [SavedObjectMigrationMap](./kibana-plugin-core-server.savedobjectmigrationmap.md) | A map of [migration functions](./kibana-plugin-core-server.savedobjectmigrationfn.md) to be used for a given type. The map's keys must be valid semver versions.<!-- -->For a given document, only migrations with a higher version number than that of the document will be applied. Migrations are executed in order, starting from the lowest version and ending with the highest one. |
| [SavedObjectReference](./kibana-plugin-core-server.savedobjectreference.md) | A reference to another saved object. |
| [SavedObjectsAddToNamespacesOptions](./kibana-plugin-core-server.savedobjectsaddtonamespacesoptions.md) | |
| [SavedObjectsAddToNamespacesResponse](./kibana-plugin-core-server.savedobjectsaddtonamespacesresponse.md) | |
| [SavedObjectsBaseOptions](./kibana-plugin-core-server.savedobjectsbaseoptions.md) | |
| [SavedObjectsBulkCreateObject](./kibana-plugin-core-server.savedobjectsbulkcreateobject.md) | |
| [SavedObjectsBulkGetObject](./kibana-plugin-core-server.savedobjectsbulkgetobject.md) | |
Expand All @@ -167,6 +168,7 @@ The plugin integrates with the core system via lifecycle events: `setup`<!-- -->
| [SavedObjectsCreateOptions](./kibana-plugin-core-server.savedobjectscreateoptions.md) | |
| [SavedObjectsDeleteByNamespaceOptions](./kibana-plugin-core-server.savedobjectsdeletebynamespaceoptions.md) | |
| [SavedObjectsDeleteFromNamespacesOptions](./kibana-plugin-core-server.savedobjectsdeletefromnamespacesoptions.md) | |
| [SavedObjectsDeleteFromNamespacesResponse](./kibana-plugin-core-server.savedobjectsdeletefromnamespacesresponse.md) | |
| [SavedObjectsDeleteOptions](./kibana-plugin-core-server.savedobjectsdeleteoptions.md) | |
| [SavedObjectsExportOptions](./kibana-plugin-core-server.savedobjectsexportoptions.md) | Options controlling the export operation. |
| [SavedObjectsExportResultDetails](./kibana-plugin-core-server.savedobjectsexportresultdetails.md) | Structure of the export result details entry |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [SavedObjectsAddToNamespacesResponse](./kibana-plugin-core-server.savedobjectsaddtonamespacesresponse.md)

## SavedObjectsAddToNamespacesResponse interface


<b>Signature:</b>

```typescript
export interface SavedObjectsAddToNamespacesResponse
```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [namespaces](./kibana-plugin-core-server.savedobjectsaddtonamespacesresponse.namespaces.md) | <code>string[]</code> | The namespaces the object exists in after this operation is complete. |

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [SavedObjectsAddToNamespacesResponse](./kibana-plugin-core-server.savedobjectsaddtonamespacesresponse.md) &gt; [namespaces](./kibana-plugin-core-server.savedobjectsaddtonamespacesresponse.namespaces.md)

## SavedObjectsAddToNamespacesResponse.namespaces property

The namespaces the object exists in after this operation is complete.

<b>Signature:</b>

```typescript
namespaces: string[];
```
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Adds namespaces to a SavedObject
<b>Signature:</b>

```typescript
addToNamespaces(type: string, id: string, namespaces: string[], options?: SavedObjectsAddToNamespacesOptions): Promise<{}>;
addToNamespaces(type: string, id: string, namespaces: string[], options?: SavedObjectsAddToNamespacesOptions): Promise<SavedObjectsAddToNamespacesResponse>;
```

## Parameters
Expand All @@ -23,5 +23,5 @@ addToNamespaces(type: string, id: string, namespaces: string[], options?: SavedO

<b>Returns:</b>

`Promise<{}>`
`Promise<SavedObjectsAddToNamespacesResponse>`

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Removes namespaces from a SavedObject
<b>Signature:</b>

```typescript
deleteFromNamespaces(type: string, id: string, namespaces: string[], options?: SavedObjectsDeleteFromNamespacesOptions): Promise<{}>;
deleteFromNamespaces(type: string, id: string, namespaces: string[], options?: SavedObjectsDeleteFromNamespacesOptions): Promise<SavedObjectsDeleteFromNamespacesResponse>;
```

## Parameters
Expand All @@ -23,5 +23,5 @@ deleteFromNamespaces(type: string, id: string, namespaces: string[], options?: S

<b>Returns:</b>

`Promise<{}>`
`Promise<SavedObjectsDeleteFromNamespacesResponse>`

Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [SavedObjectsDeleteFromNamespacesResponse](./kibana-plugin-core-server.savedobjectsdeletefromnamespacesresponse.md)

## SavedObjectsDeleteFromNamespacesResponse interface


<b>Signature:</b>

```typescript
export interface SavedObjectsDeleteFromNamespacesResponse
```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [namespaces](./kibana-plugin-core-server.savedobjectsdeletefromnamespacesresponse.namespaces.md) | <code>string[]</code> | The namespaces the object exists in after this operation is complete. An empty array indicates the object was deleted. |

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [SavedObjectsDeleteFromNamespacesResponse](./kibana-plugin-core-server.savedobjectsdeletefromnamespacesresponse.md) &gt; [namespaces](./kibana-plugin-core-server.savedobjectsdeletefromnamespacesresponse.namespaces.md)

## SavedObjectsDeleteFromNamespacesResponse.namespaces property

The namespaces the object exists in after this operation is complete. An empty array indicates the object was deleted.

<b>Signature:</b>

```typescript
namespaces: string[];
```
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Adds one or more namespaces to a given multi-namespace saved object. This method
<b>Signature:</b>

```typescript
addToNamespaces(type: string, id: string, namespaces: string[], options?: SavedObjectsAddToNamespacesOptions): Promise<{}>;
addToNamespaces(type: string, id: string, namespaces: string[], options?: SavedObjectsAddToNamespacesOptions): Promise<SavedObjectsAddToNamespacesResponse>;
```

## Parameters
Expand All @@ -23,5 +23,5 @@ addToNamespaces(type: string, id: string, namespaces: string[], options?: SavedO

<b>Returns:</b>

`Promise<{}>`
`Promise<SavedObjectsAddToNamespacesResponse>`

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Removes one or more namespaces from a given multi-namespace saved object. If no
<b>Signature:</b>

```typescript
deleteFromNamespaces(type: string, id: string, namespaces: string[], options?: SavedObjectsDeleteFromNamespacesOptions): Promise<{}>;
deleteFromNamespaces(type: string, id: string, namespaces: string[], options?: SavedObjectsDeleteFromNamespacesOptions): Promise<SavedObjectsDeleteFromNamespacesResponse>;
```

## Parameters
Expand All @@ -23,5 +23,5 @@ deleteFromNamespaces(type: string, id: string, namespaces: string[], options?: S

<b>Returns:</b>

`Promise<{}>`
`Promise<SavedObjectsDeleteFromNamespacesResponse>`

Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
<b>Signature:</b>

```typescript
export declare type FieldFormatsGetConfigFn = <T = any>(key: string, defaultOverride?: T) => T;
export declare type FieldFormatsGetConfigFn = GetConfigFn;
```
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@

## getSearchParamsFromRequest() function


<b>Signature:</b>

```typescript
export declare function getSearchParamsFromRequest(searchRequest: SearchRequest, dependencies: {
injectedMetadata: CoreStart['injectedMetadata'];
uiSettings: IUiSettingsClient;
esShardTimeout: number;
getConfig: GetConfigFn;
}): ISearchRequestParams;
```

Expand All @@ -18,7 +19,7 @@ export declare function getSearchParamsFromRequest(searchRequest: SearchRequest,
| Parameter | Type | Description |
| --- | --- | --- |
| searchRequest | <code>SearchRequest</code> | |
| dependencies | <code>{</code><br/><code> injectedMetadata: CoreStart['injectedMetadata'];</code><br/><code> uiSettings: IUiSettingsClient;</code><br/><code>}</code> | |
| dependencies | <code>{</code><br/><code> esShardTimeout: number;</code><br/><code> getConfig: GetConfigFn;</code><br/><code>}</code> | |

<b>Returns:</b>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
<b>Signature:</b>

```typescript
export declare type FieldFormatsGetConfigFn = <T = any>(key: string, defaultOverride?: T) => T;
export declare type FieldFormatsGetConfigFn = GetConfigFn;
```
10 changes: 3 additions & 7 deletions examples/embeddable_examples/public/book/book_embeddable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import {
EmbeddableOutput,
SavedObjectEmbeddableInput,
ReferenceOrValueEmbeddable,
Container,
} from '../../../../src/plugins/embeddable/public';
import { BookSavedObjectAttributes } from '../../common';
import { BookEmbeddableComponent } from './book_component';
Expand Down Expand Up @@ -104,16 +103,13 @@ export class BookEmbeddable extends Embeddable<BookEmbeddableInput, BookEmbeddab
};

getInputAsValueType = async (): Promise<BookByValueInput> => {
const input =
this.getRoot() && (this.getRoot() as Container).getInput().panels[this.id].explicitInput
? ((this.getRoot() as Container).getInput().panels[this.id]
.explicitInput as BookEmbeddableInput)
: this.input;
const input = this.attributeService.getExplicitInputFromEmbeddable(this);
return this.attributeService.getInputAsValueType(input);
};

getInputAsRefType = async (): Promise<BookByReferenceInput> => {
return this.attributeService.getInputAsRefType(this.input, { showSaveModal: true });
const input = this.attributeService.getExplicitInputFromEmbeddable(this);
return this.attributeService.getInputAsRefType(input, { showSaveModal: true });
};

public render(node: HTMLElement) {
Expand Down
2 changes: 2 additions & 0 deletions src/core/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,9 @@ export {
SavedObjectsUpdateOptions,
SavedObjectsUpdateResponse,
SavedObjectsAddToNamespacesOptions,
SavedObjectsAddToNamespacesResponse,
SavedObjectsDeleteFromNamespacesOptions,
SavedObjectsDeleteFromNamespacesResponse,
SavedObjectsServiceStart,
SavedObjectsServiceSetup,
SavedObjectStatusMeta,
Expand Down
16 changes: 8 additions & 8 deletions src/core/server/saved_objects/service/lib/repository.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -393,14 +393,14 @@ describe('SavedObjectsRepository', () => {
});

describe('returns', () => {
it(`returns an empty object on success`, async () => {
it(`returns all existing and new namespaces on success`, async () => {
const result = await addToNamespacesSuccess(type, id, [newNs1, newNs2]);
expect(result).toEqual({});
expect(result).toEqual({ namespaces: [currentNs1, currentNs2, newNs1, newNs2] });
});

it(`succeeds when adding existing namespaces`, async () => {
const result = await addToNamespacesSuccess(type, id, [currentNs1]);
expect(result).toEqual({});
expect(result).toEqual({ namespaces: [currentNs1, currentNs2] });
});
});
});
Expand Down Expand Up @@ -3102,17 +3102,17 @@ describe('SavedObjectsRepository', () => {
});

describe('returns', () => {
it(`returns an empty object on success (delete)`, async () => {
it(`returns an empty namespaces array on success (delete)`, async () => {
const test = async (namespaces) => {
const result = await deleteFromNamespacesSuccess(type, id, namespaces, namespaces);
expect(result).toEqual({});
expect(result).toEqual({ namespaces: [] });
client.delete.mockClear();
};
await test([namespace1]);
await test([namespace1, namespace2]);
});

it(`returns an empty object on success (update)`, async () => {
it(`returns remaining namespaces on success (update)`, async () => {
const test = async (remaining) => {
const currentNamespaces = [namespace1].concat(remaining);
const result = await deleteFromNamespacesSuccess(
Expand All @@ -3121,7 +3121,7 @@ describe('SavedObjectsRepository', () => {
[namespace1],
currentNamespaces
);
expect(result).toEqual({});
expect(result).toEqual({ namespaces: remaining });
client.delete.mockClear();
};
await test([namespace2]);
Expand All @@ -3132,7 +3132,7 @@ describe('SavedObjectsRepository', () => {
const namespaces = [namespace2];
const currentNamespaces = [namespace1];
const result = await deleteFromNamespacesSuccess(type, id, namespaces, currentNamespaces);
expect(result).toEqual({});
expect(result).toEqual({ namespaces: currentNamespaces });
});
});
});
Expand Down
12 changes: 7 additions & 5 deletions src/core/server/saved_objects/service/lib/repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ import {
SavedObjectsBulkUpdateOptions,
SavedObjectsDeleteOptions,
SavedObjectsAddToNamespacesOptions,
SavedObjectsAddToNamespacesResponse,
SavedObjectsDeleteFromNamespacesOptions,
SavedObjectsDeleteFromNamespacesResponse,
} from '../saved_objects_client';
import {
SavedObject,
Expand Down Expand Up @@ -947,7 +949,7 @@ export class SavedObjectsRepository {
id: string,
namespaces: string[],
options: SavedObjectsAddToNamespacesOptions = {}
): Promise<{}> {
): Promise<SavedObjectsAddToNamespacesResponse> {
if (!this._allowedTypes.includes(type)) {
throw SavedObjectsErrorHelpers.createGenericNotFoundError(type, id);
}
Expand Down Expand Up @@ -996,7 +998,7 @@ export class SavedObjectsRepository {
throw SavedObjectsErrorHelpers.createGenericNotFoundError(type, id);
}

return {};
return { namespaces: doc.namespaces };
}

/**
Expand All @@ -1009,7 +1011,7 @@ export class SavedObjectsRepository {
id: string,
namespaces: string[],
options: SavedObjectsDeleteFromNamespacesOptions = {}
): Promise<{}> {
): Promise<SavedObjectsDeleteFromNamespacesResponse> {
if (!this._allowedTypes.includes(type)) {
throw SavedObjectsErrorHelpers.createGenericNotFoundError(type, id);
}
Expand Down Expand Up @@ -1063,7 +1065,7 @@ export class SavedObjectsRepository {
// see "404s from missing index" above
throw SavedObjectsErrorHelpers.createGenericNotFoundError(type, id);
}
return {};
return { namespaces: doc.namespaces };
} else {
// if there are no namespaces remaining, delete the saved object
const { body, statusCode } = await this.client.delete<DeleteDocumentResponse>(
Expand All @@ -1080,7 +1082,7 @@ export class SavedObjectsRepository {

const deleted = body.result === 'deleted';
if (deleted) {
return {};
return { namespaces: [] };
}

const deleteDocNotFound = body.result === 'not_found';
Expand Down
22 changes: 20 additions & 2 deletions src/core/server/saved_objects/service/saved_objects_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,15 @@ export interface SavedObjectsAddToNamespacesOptions extends SavedObjectsBaseOpti
refresh?: MutatingOperationRefreshSetting;
}

/**
*
* @public
*/
export interface SavedObjectsAddToNamespacesResponse {
/** The namespaces the object exists in after this operation is complete. */
namespaces: string[];
}

/**
*
* @public
Expand All @@ -144,6 +153,15 @@ export interface SavedObjectsDeleteFromNamespacesOptions extends SavedObjectsBas
refresh?: MutatingOperationRefreshSetting;
}

/**
*
* @public
*/
export interface SavedObjectsDeleteFromNamespacesResponse {
/** The namespaces the object exists in after this operation is complete. An empty array indicates the object was deleted. */
namespaces: string[];
}

/**
*
* @public
Expand Down Expand Up @@ -320,7 +338,7 @@ export class SavedObjectsClient {
id: string,
namespaces: string[],
options: SavedObjectsAddToNamespacesOptions = {}
): Promise<{}> {
): Promise<SavedObjectsAddToNamespacesResponse> {
return await this._repository.addToNamespaces(type, id, namespaces, options);
}

Expand All @@ -337,7 +355,7 @@ export class SavedObjectsClient {
id: string,
namespaces: string[],
options: SavedObjectsDeleteFromNamespacesOptions = {}
): Promise<{}> {
): Promise<SavedObjectsDeleteFromNamespacesResponse> {
return await this._repository.deleteFromNamespaces(type, id, namespaces, options);
}

Expand Down
Loading

0 comments on commit a2c7e4e

Please sign in to comment.