forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from Dosant/d/2022-04-26-script-based-visualiza…
…tions Add simple search proxy
- Loading branch information
Showing
8 changed files
with
112 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
export * from './kibana_api'; |
37 changes: 37 additions & 0 deletions
37
src/plugins/vis_type_script/public/kibana_api/kibana_api.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import type * as estypes from '@elastic/elasticsearch/lib/api/types'; | ||
import { lastValueFrom } from 'rxjs'; | ||
import { DataPublicPluginStart } from '../../../data/public'; | ||
import { VisSearchContext } from '../types'; | ||
|
||
export interface VisTypeScriptKibanaApiDeps { | ||
data: DataPublicPluginStart; | ||
} | ||
|
||
export class VisTypeScriptKibanaApi { | ||
constructor( | ||
private readonly deps: VisTypeScriptKibanaApiDeps, | ||
private readonly visSearchContext: VisSearchContext | ||
) {} | ||
|
||
async esSearch( | ||
payload: estypes.SearchRequest, | ||
{ useKibanaContext = true } = { useKibanaContext: true } | ||
): Promise<estypes.SearchResponse> { | ||
if (useKibanaContext) { | ||
// TODO: adjust request based on this.visSearchContext | ||
// eslint-disable-next-line no-console | ||
console.log(this.visSearchContext); | ||
} | ||
|
||
const response = await lastValueFrom(this.deps.data.search.search({ params: payload })); | ||
return response.rawResponse; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters