From 96cbebc62956bf341eb809aff977642a749fd4c5 Mon Sep 17 00:00:00 2001 From: MT Lewis Date: Mon, 17 Jan 2022 17:48:07 +0000 Subject: [PATCH] search-common: add optional request options with token to SearchEngine#query Signed-off-by: MT Lewis --- .changeset/nervous-walls-exercise.md | 5 +++++ packages/search-common/api-report.md | 12 +++++++++++- packages/search-common/src/types.ts | 9 ++++++++- 3 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 .changeset/nervous-walls-exercise.md diff --git a/.changeset/nervous-walls-exercise.md b/.changeset/nervous-walls-exercise.md new file mode 100644 index 0000000000..58c19d53ca --- /dev/null +++ b/.changeset/nervous-walls-exercise.md @@ -0,0 +1,5 @@ +--- +'@backstage/search-common': patch +--- + +Add optional query request options containing authorization token to SearchEngine#query. diff --git a/packages/search-common/api-report.md b/packages/search-common/api-report.md index dcbbbee1bf..e63caf016f 100644 --- a/packages/search-common/api-report.md +++ b/packages/search-common/api-report.md @@ -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; - query(query: SearchQuery): Promise; + query( + query: SearchQuery, + options?: QueryRequestOptions, + ): Promise; setTranslator(translator: QueryTranslator): void; } diff --git a/packages/search-common/src/types.ts b/packages/search-common/src/types.ts index bac6967d19..e8d21535bb 100644 --- a/packages/search-common/src/types.ts +++ b/packages/search-common/src/types.ts @@ -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; + query( + query: SearchQuery, + options?: QueryRequestOptions, + ): Promise; }