Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[data.search] Add search session methods to search service contract #87966

Merged
merged 32 commits into from
Feb 3, 2021
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
c22024f
[data.search] Add search session methods to search service contract
lukasolson Jan 12, 2021
1046c54
Merge branch 'master' into search-session-api
lukasolson Jan 15, 2021
7040716
Fix types
lukasolson Jan 15, 2021
eeddf84
Fix tests and switch to cancel
lukasolson Jan 15, 2021
f09eb38
Update docs
lukasolson Jan 15, 2021
e6124af
Merge branch 'master' into search-session-api
lukasolson Jan 19, 2021
e160019
Fix types/tests
lukasolson Jan 19, 2021
3c08c3d
Fix tests
lukasolson Jan 19, 2021
0cd92ed
Update status of SO before cancelling search requests
lukasolson Jan 19, 2021
f1a1d0b
Add API integration test
lukasolson Jan 19, 2021
552e545
Merge branch 'master' into search-session-api
lukasolson Jan 20, 2021
ee6e337
Merge branch 'master' into search-session-api
lukasolson Jan 25, 2021
32315b7
Fix types
lukasolson Jan 25, 2021
542de95
Update expiration route to use config defaultExpiration
lukasolson Jan 25, 2021
5b22249
Fix test
lukasolson Jan 25, 2021
66420b4
Update docs
lukasolson Jan 25, 2021
8a5e3d3
New logic for extend
lukasolson Jan 26, 2021
71582c7
Remove declare module
lukasolson Jan 26, 2021
65840b3
Review feedback
lukasolson Jan 26, 2021
fdb940b
Merge branch 'master' of github.com:elastic/kibana into pr/87966
Jan 27, 2021
b2bce4b
fix ts
Jan 27, 2021
50081b5
Merge branch 'master' into search-session-api
lukasolson Jan 28, 2021
e24181c
Remove test that is no longer valid
lukasolson Jan 28, 2021
08ed572
Merge remote-tracking branch 'origin/search-session-api' into search-…
lukasolson Jan 28, 2021
44ef260
Merge branch 'master' into search-session-api
lukasolson Jan 28, 2021
99b4ca0
Merge branch 'master' into search-session-api
lukasolson Feb 1, 2021
99dc347
Fix undefined bug
lukasolson Feb 1, 2021
e582910
Merge branch 'master' into search-session-api
lukasolson Feb 2, 2021
fbfc1b1
Fix types
lukasolson Feb 2, 2021
5c564c2
Merge branch 'master' of github.com:elastic/kibana into pr/87966
Feb 3, 2021
3eb8f01
Use DataRequestHandlerContext in maps
Feb 3, 2021
6462da6
ts
Feb 3, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) &gt; [ISearchSessionService](./kibana-plugin-plugins-data-server.isearchsessionservice.md) &gt; [asScopedProvider](./kibana-plugin-plugins-data-server.isearchsessionservice.asscopedprovider.md)

## ISearchSessionService.asScopedProvider property

<b>Signature:</b>

```typescript
asScopedProvider: (core: CoreStart) => (request: KibanaRequest) => IScopedSearchSessionsClient<T>;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) &gt; [ISearchSessionService](./kibana-plugin-plugins-data-server.isearchsessionservice.md)

## ISearchSessionService interface

<b>Signature:</b>

```typescript
export interface ISearchSessionService<T = unknown>
```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [asScopedProvider](./kibana-plugin-plugins-data-server.isearchsessionservice.asscopedprovider.md) | <code>(core: CoreStart) =&gt; (request: KibanaRequest) =&gt; IScopedSearchSessionsClient&lt;T&gt;</code> | |

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

```typescript
asScoped: (request: KibanaRequest) => ISearchClient;
asScoped: (request: KibanaRequest) => IScopedSearchClient;
```
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export interface ISearchStart<SearchStrategyRequest extends IKibanaSearchRequest
| Property | Type | Description |
| --- | --- | --- |
| [aggs](./kibana-plugin-plugins-data-server.isearchstart.aggs.md) | <code>AggsStart</code> | |
| [asScoped](./kibana-plugin-plugins-data-server.isearchstart.asscoped.md) | <code>(request: KibanaRequest) =&gt; ISearchClient</code> | |
| [asScoped](./kibana-plugin-plugins-data-server.isearchstart.asscoped.md) | <code>(request: KibanaRequest) =&gt; IScopedSearchClient</code> | |
| [getSearchStrategy](./kibana-plugin-plugins-data-server.isearchstart.getsearchstrategy.md) | <code>(name?: string) =&gt; ISearchStrategy&lt;SearchStrategyRequest, SearchStrategyResponse&gt;</code> | Get other registered search strategies by name (or, by default, the Elasticsearch strategy). For example, if a new strategy needs to use the already-registered ES search strategy, it can use this function to accomplish that. |
| [searchSource](./kibana-plugin-plugins-data-server.isearchstart.searchsource.md) | <code>{</code><br/><code> asScoped: (request: KibanaRequest) =&gt; Promise&lt;ISearchStartSearchSource&gt;;</code><br/><code> }</code> | |

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@
| [IndexPatternsService](./kibana-plugin-plugins-data-server.indexpatternsservice.md) | |
| [OptionedParamType](./kibana-plugin-plugins-data-server.optionedparamtype.md) | |
| [Plugin](./kibana-plugin-plugins-data-server.plugin.md) | |
<<<<<<< HEAD
| [SearchSessionService](./kibana-plugin-plugins-data-server.searchsessionservice.md) | The OSS session service, which leaves most search session-related logic unimplemented. x-pack/plugins/data\_enhanced/server/search/session/session\_service.ts |
=======
| [SessionService](./kibana-plugin-plugins-data-server.sessionservice.md) | The OSS session service. See data\_enhanced in X-Pack for the search session service. |
>>>>>>> master

## Enumerations

Expand Down Expand Up @@ -53,10 +57,10 @@
| [IFieldType](./kibana-plugin-plugins-data-server.ifieldtype.md) | |
| [IndexPatternAttributes](./kibana-plugin-plugins-data-server.indexpatternattributes.md) | |
| [ISearchOptions](./kibana-plugin-plugins-data-server.isearchoptions.md) | |
| [ISearchSessionService](./kibana-plugin-plugins-data-server.isearchsessionservice.md) | |
| [ISearchSetup](./kibana-plugin-plugins-data-server.isearchsetup.md) | |
| [ISearchStart](./kibana-plugin-plugins-data-server.isearchstart.md) | |
| [ISearchStrategy](./kibana-plugin-plugins-data-server.isearchstrategy.md) | Search strategy interface contains a search method that takes in a request and returns a promise that resolves to a response. |
| [ISessionService](./kibana-plugin-plugins-data-server.isessionservice.md) | |
| [KueryNode](./kibana-plugin-plugins-data-server.kuerynode.md) | |
| [OptionedValueProp](./kibana-plugin-plugins-data-server.optionedvalueprop.md) | |
| [PluginSetup](./kibana-plugin-plugins-data-server.pluginsetup.md) | |
Expand Down
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-plugins-data-server](./kibana-plugin-plugins-data-server.md) &gt; [SearchSessionService](./kibana-plugin-plugins-data-server.searchsessionservice.md) &gt; [(constructor)](./kibana-plugin-plugins-data-server.searchsessionservice._constructor_.md)

## SearchSessionService.(constructor)

Constructs a new instance of the `SearchSessionService` class

<b>Signature:</b>

```typescript
constructor();
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) &gt; [SearchSessionService](./kibana-plugin-plugins-data-server.searchsessionservice.md) &gt; [asScopedProvider](./kibana-plugin-plugins-data-server.searchsessionservice.asscopedprovider.md)

## SearchSessionService.asScopedProvider() method

<b>Signature:</b>

```typescript
asScopedProvider(): () => {
getId: () => never;
trackId: () => Promise<void>;
getSearchIdMapping: () => Promise<Map<string, string>>;
save: () => Promise<never>;
get: () => Promise<never>;
find: () => Promise<never>;
update: () => Promise<never>;
extend: () => Promise<never>;
cancel: () => Promise<never>;
};
```
<b>Returns:</b>

`() => {
getId: () => never;
trackId: () => Promise<void>;
getSearchIdMapping: () => Promise<Map<string, string>>;
save: () => Promise<never>;
get: () => Promise<never>;
find: () => Promise<never>;
update: () => Promise<never>;
extend: () => Promise<never>;
cancel: () => Promise<never>;
}`

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

[Home](./index.md) &gt; [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) &gt; [SearchSessionService](./kibana-plugin-plugins-data-server.searchsessionservice.md)

## SearchSessionService class

The OSS session service, which leaves most search session-related logic unimplemented. x-pack/plugins/data\_enhanced/server/search/session/session\_service.ts

<b>Signature:</b>

```typescript
export declare class SearchSessionService implements ISearchSessionService
```

## Constructors

| Constructor | Modifiers | Description |
| --- | --- | --- |
| [(constructor)()](./kibana-plugin-plugins-data-server.searchsessionservice._constructor_.md) | | Constructs a new instance of the <code>SearchSessionService</code> class |

## Methods

| Method | Modifiers | Description |
| --- | --- | --- |
| [asScopedProvider()](./kibana-plugin-plugins-data-server.searchsessionservice.asscopedprovider.md) | | |

Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ export interface SearchStrategyDependencies
| --- | --- | --- |
| [esClient](./kibana-plugin-plugins-data-server.searchstrategydependencies.esclient.md) | <code>IScopedClusterClient</code> | |
| [savedObjectsClient](./kibana-plugin-plugins-data-server.searchstrategydependencies.savedobjectsclient.md) | <code>SavedObjectsClientContract</code> | |
| [searchSessionsClient](./kibana-plugin-plugins-data-server.searchstrategydependencies.searchsessionsclient.md) | <code>IScopedSearchSessionsClient</code> | |
| [uiSettingsClient](./kibana-plugin-plugins-data-server.searchstrategydependencies.uisettingsclient.md) | <code>IUiSettingsClient</code> | |

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

[Home](./index.md) &gt; [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) &gt; [SearchStrategyDependencies](./kibana-plugin-plugins-data-server.searchstrategydependencies.md) &gt; [searchSessionsClient](./kibana-plugin-plugins-data-server.searchstrategydependencies.searchsessionsclient.md)

## SearchStrategyDependencies.searchSessionsClient property

<b>Signature:</b>

```typescript
searchSessionsClient: IScopedSearchSessionsClient;
```

This file was deleted.

This file was deleted.

This file was deleted.

1 change: 1 addition & 0 deletions src/plugins/data/public/search/session/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export function getSessionsClientMock(): jest.Mocked<ISessionsClient> {
create: jest.fn(),
find: jest.fn(),
update: jest.fn(),
extend: jest.fn(),
delete: jest.fn(),
};
}
Expand Down
6 changes: 6 additions & 0 deletions src/plugins/data/public/search/session/sessions_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ export class SessionsClient {
});
}

public extend(sessionId: string, keepAlive: string): Promise<SavedObjectsFindResponse> {
return this.http!.post(`/internal/session/${encodeURIComponent(sessionId)}/_extend`, {
body: JSON.stringify({ keepAlive }),
lukasolson marked this conversation as resolved.
Show resolved Hide resolved
});
}

public delete(sessionId: string): Promise<void> {
return this.http!.delete(`/internal/session/${encodeURIComponent(sessionId)}`);
}
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/data/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,8 @@ export {
searchUsageObserver,
shimAbortSignal,
SearchUsage,
SessionService,
ISessionService,
SearchSessionService,
ISearchSessionService,
} from './search';

// Search namespace
Expand Down
14 changes: 13 additions & 1 deletion src/plugins/data/server/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@
* under the License.
*/

import { createSearchSetupMock, createSearchStartMock } from './search/mocks';
import { RequestHandlerContext } from 'kibana/server';
import {
createSearchSetupMock,
createSearchStartMock,
createSearchRequestHandlerContext,
} from './search/mocks';
import { createFieldFormatsSetupMock, createFieldFormatsStartMock } from './field_formats/mocks';
import { createIndexPatternsStartMock } from './index_patterns/mocks';

Expand All @@ -36,7 +41,14 @@ function createStartContract() {
};
}

function createRequestHandlerContext() {
return ({
search: createSearchRequestHandlerContext(),
} as unknown) as jest.Mocked<RequestHandlerContext>;
}

export const dataPluginMock = {
createSetupContract,
createStartContract,
createRequestHandlerContext,
};
21 changes: 17 additions & 4 deletions src/plugins/data/server/search/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import { ISearchSetup, ISearchStart } from './types';
import { searchAggsSetupMock, searchAggsStartMock } from './aggs/mocks';
import { searchSourceMock } from './search_source/mocks';

export { createSearchSessionsClientMock } from './session/mocks';

export function createSearchSetupMock(): jest.Mocked<ISearchSetup> {
return {
aggs: searchAggsSetupMock(),
Expand All @@ -33,10 +35,21 @@ export function createSearchStartMock(): jest.Mocked<ISearchStart> {
return {
aggs: searchAggsStartMock(),
getSearchStrategy: jest.fn(),
asScoped: jest.fn().mockReturnValue({
search: jest.fn(),
cancel: jest.fn(),
}),
asScoped: jest.fn().mockReturnValue(createSearchRequestHandlerContext()),
searchSource: searchSourceMock.createStartContract(),
};
}

export function createSearchRequestHandlerContext() {
return {
search: jest.fn(),
cancel: jest.fn(),
extend: jest.fn(),
saveSession: jest.fn(),
getSession: jest.fn(),
findSessions: jest.fn(),
updateSession: jest.fn(),
extendSession: jest.fn(),
cancelSession: jest.fn(),
};
}
Loading