-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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] Server-side background session service #81099
Changes from 38 commits
26c47bd
36b8fcb
8274226
c7296f0
d77c009
9dadfb2
ab55bcb
2b3d2a0
7a048a0
2d0da67
f7cb5a1
6c9aec5
5b9b0c9
260e46c
1ae55ef
4634fb4
c35fb49
1567995
5f7c9ab
f1b515d
a1d67ae
9dbd645
e32a435
b1ece61
6f3e33c
71d5bd8
8fbe317
fda7a79
e06d8da
c24f83d
0b10e22
700f2a0
0f34c4c
c4e63c2
5c15656
06e83fb
967214d
645146b
dc6104c
8d81f39
9bbfa3a
a3dc0d8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [ISearchOptions](./kibana-plugin-plugins-data-public.isearchoptions.md) > [isRestore](./kibana-plugin-plugins-data-public.isearchoptions.isrestore.md) | ||
|
||
## ISearchOptions.isRestore property | ||
|
||
Whether the session is restored (i.e. search requests should re-use the stored search IDs, rather than starting from scratch) | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
isRestore?: boolean; | ||
``` |
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) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [ISearchOptions](./kibana-plugin-plugins-data-public.isearchoptions.md) > [isStored](./kibana-plugin-plugins-data-public.isearchoptions.isstored.md) | ||
|
||
## ISearchOptions.isStored property | ||
|
||
Whether the session is already saved (i.e. sent to background) | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
isStored?: boolean; | ||
``` |
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) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [ISessionService](./kibana-plugin-plugins-data-public.isessionservice.md) > [delete](./kibana-plugin-plugins-data-public.isessionservice.delete.md) | ||
|
||
## ISessionService.delete property | ||
|
||
Deletes a session | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
delete: (sessionId: string) => Promise<any>; | ||
``` |
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) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [ISessionService](./kibana-plugin-plugins-data-public.isessionservice.md) > [find](./kibana-plugin-plugins-data-public.isessionservice.find.md) | ||
|
||
## ISessionService.find property | ||
|
||
Gets a list of saved sessions | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
find: (options: SearchSessionFindOptions) => Promise<any>; | ||
``` |
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) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [ISessionService](./kibana-plugin-plugins-data-public.isessionservice.md) > [get](./kibana-plugin-plugins-data-public.isessionservice.get.md) | ||
|
||
## ISessionService.get property | ||
|
||
Gets a saved session | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
get: (sessionId: string) => Promise<any>; | ||
``` |
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) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [ISessionService](./kibana-plugin-plugins-data-public.isessionservice.md) > [isRestore](./kibana-plugin-plugins-data-public.isessionservice.isrestore.md) | ||
|
||
## ISessionService.isRestore property | ||
|
||
Whether the active session is restored (i.e. reusing previous search IDs) | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
isRestore: () => boolean; | ||
``` |
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) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [ISessionService](./kibana-plugin-plugins-data-public.isessionservice.md) > [isStored](./kibana-plugin-plugins-data-public.isessionservice.isstored.md) | ||
|
||
## ISessionService.isStored property | ||
|
||
Whether the active session is already saved (i.e. sent to background) | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
isStored: () => boolean; | ||
``` |
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) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [ISessionService](./kibana-plugin-plugins-data-public.isessionservice.md) > [save](./kibana-plugin-plugins-data-public.isessionservice.save.md) | ||
|
||
## ISessionService.save property | ||
|
||
Saves a session | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
save: (name: string, url: string) => Promise<any>; | ||
``` |
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) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [ISessionService](./kibana-plugin-plugins-data-public.isessionservice.md) > [update](./kibana-plugin-plugins-data-public.isessionservice.update.md) | ||
|
||
## ISessionService.update property | ||
|
||
Updates a session | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
update: (sessionId: string, attributes: Partial<BackgroundSessionSavedObjectAttributes>) => Promise<any>; | ||
``` |
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) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [ISearchOptions](./kibana-plugin-plugins-data-server.isearchoptions.md) > [isRestore](./kibana-plugin-plugins-data-server.isearchoptions.isrestore.md) | ||
|
||
## ISearchOptions.isRestore property | ||
|
||
Whether the session is restored (i.e. search requests should re-use the stored search IDs, rather than starting from scratch) | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
isRestore?: boolean; | ||
``` |
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) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [ISearchOptions](./kibana-plugin-plugins-data-server.isearchoptions.md) > [isStored](./kibana-plugin-plugins-data-server.isearchoptions.isstored.md) | ||
|
||
## ISearchOptions.isStored property | ||
|
||
Whether the session is already saved (i.e. sent to background) | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
isStored?: boolean; | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,4 +17,5 @@ | |
* under the License. | ||
*/ | ||
|
||
export * from './status'; | ||
export * from './types'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
export enum BackgroundSessionStatus { | ||
INCOMPLETE = 'incomplete', | ||
ERROR = 'error', | ||
COMPLETE = 'complete', | ||
CANCELLED = 'cancelled', | ||
EXPIRED = 'expired', | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ | |
*/ | ||
|
||
import { Observable } from 'rxjs'; | ||
import type { SavedObject, SavedObjectsFindResponse } from 'kibana/server'; | ||
|
||
export interface ISessionService { | ||
/** | ||
|
@@ -30,6 +31,17 @@ export interface ISessionService { | |
* @returns `Observable` | ||
*/ | ||
getSession$: () => Observable<string | undefined>; | ||
|
||
/** | ||
* Whether the active session is already saved (i.e. sent to background) | ||
*/ | ||
isStored: () => boolean; | ||
|
||
/** | ||
* Whether the active session is restored (i.e. reusing previous search IDs) | ||
*/ | ||
isRestore: () => boolean; | ||
|
||
/** | ||
* Starts a new session | ||
*/ | ||
|
@@ -38,10 +50,57 @@ export interface ISessionService { | |
/** | ||
* Restores existing session | ||
*/ | ||
restore: (sessionId: string) => void; | ||
restore: (sessionId: string) => Promise<SavedObject<BackgroundSessionSavedObjectAttributes>>; | ||
|
||
/** | ||
* Clears the active session. | ||
*/ | ||
clear: () => void; | ||
|
||
/** | ||
* Saves a session | ||
*/ | ||
save: (name: string, url: string) => Promise<SavedObject<BackgroundSessionSavedObjectAttributes>>; | ||
|
||
/** | ||
* Gets a saved session | ||
*/ | ||
get: (sessionId: string) => Promise<SavedObject<BackgroundSessionSavedObjectAttributes>>; | ||
|
||
/** | ||
* Gets a list of saved sessions | ||
*/ | ||
find: ( | ||
options: SearchSessionFindOptions | ||
) => Promise<SavedObjectsFindResponse<BackgroundSessionSavedObjectAttributes>>; | ||
|
||
/** | ||
* Updates a session | ||
*/ | ||
update: ( | ||
sessionId: string, | ||
attributes: Partial<BackgroundSessionSavedObjectAttributes> | ||
) => Promise<any>; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would would be the proper return types for this CRUD methods? |
||
|
||
/** | ||
* Deletes a session | ||
*/ | ||
delete: (sessionId: string) => Promise<any>; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Returns There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, probably |
||
} | ||
|
||
export interface BackgroundSessionSavedObjectAttributes { | ||
name: string; | ||
url: string; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thing we shouldn't have a URL, but an app name and two sets of parameters generated using the URL Generator (original and restore URLs) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are you okay with leaving this to the PR that integrates with the URL generator? If you prefer, I can leave out the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lets leave it out then |
||
created: string; | ||
expires: string; | ||
status: string; | ||
idMapping: Record<string, string>; | ||
} | ||
|
||
export interface SearchSessionFindOptions { | ||
page?: number; | ||
perPage?: number; | ||
sortField?: string; | ||
sortOrder?: string; | ||
filter?: string; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import { of } from 'rxjs'; | ||
import { tapFirst } from './tap_first'; | ||
|
||
describe('tapFirst', () => { | ||
it('should tap the first and only the first', () => { | ||
const fn = jest.fn(); | ||
of(1, 2, 3).pipe(tapFirst(fn)).subscribe(); | ||
expect(fn).toBeCalledTimes(1); | ||
expect(fn).lastCalledWith(1); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
//nit IN_PROGRESS?