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; }