search-common: add optional request options with token to SearchEngine#query

Signed-off-by: MT Lewis <mtlewis@users.noreply.github.com>
This commit is contained in:
MT Lewis
2022-01-17 17:48:07 +00:00
parent b2e918fa0b
commit 96cbebc629
3 changed files with 24 additions and 2 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/search-common': patch
---
Add optional query request options containing authorization token to SearchEngine#query.
+11 -1
View File
@@ -35,6 +35,13 @@ export interface IndexableDocument {
title: string;
}
// Warning: (ae-missing-release-tag) "QueryRequestOptions" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export type QueryRequestOptions = {
token?: string;
};
// Warning: (ae-missing-release-tag) "QueryTranslator" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public
@@ -45,7 +52,10 @@ export type QueryTranslator = (query: SearchQuery) => unknown;
// @public
export interface SearchEngine {
index(type: string, documents: IndexableDocument[]): Promise<void>;
query(query: SearchQuery): Promise<SearchResultSet>;
query(
query: SearchQuery,
options?: QueryRequestOptions,
): Promise<SearchResultSet>;
setTranslator(translator: QueryTranslator): void;
}
+8 -1
View File
@@ -99,6 +99,10 @@ export interface DocumentDecorator {
*/
export type QueryTranslator = (query: SearchQuery) => unknown;
export type QueryRequestOptions = {
token?: string;
};
/**
* Interface that must be implemented by specific search engines, responsible
* for performing indexing and querying and translating abstract queries into
@@ -118,5 +122,8 @@ export interface SearchEngine {
/**
* Perform a search query against the SearchEngine.
*/
query(query: SearchQuery): Promise<SearchResultSet>;
query(
query: SearchQuery,
options?: QueryRequestOptions,
): Promise<SearchResultSet>;
}