@backstage/plugin-search-common
Advanced tools
Comparing version 0.3.2 to 0.3.3-next.0
# @backstage/plugin-search-common | ||
## 0.3.3-next.0 | ||
### Patch Changes | ||
- c8b295f2fb: - Introduce `SearchDocument` type. This type contains the subset of `IndexableDocument` properties relevant to the frontend, and is intended to be used for documents returned to the frontend from the search API. | ||
- `SearchResultSet` is now a wrapper for documents of type `SearchDocument`, and is intended to be used in the frontend. This isn't a breaking change, since `IndexableDocument`s are valid `SearchDocument`s, so the old and new types are compatible. | ||
- Introduce `IndexableResultSet` type, which wraps `IndexableDocument` instances in the same way as `SearchResultSet`. | ||
## 0.3.2 | ||
@@ -4,0 +12,0 @@ |
@@ -18,5 +18,5 @@ /// <reference types="node" /> | ||
*/ | ||
interface SearchResult { | ||
interface Result<TDocument extends SearchDocument> { | ||
type: string; | ||
document: IndexableDocument; | ||
document: TDocument; | ||
} | ||
@@ -26,4 +26,4 @@ /** | ||
*/ | ||
interface SearchResultSet { | ||
results: SearchResult[]; | ||
interface ResultSet<TDocument extends SearchDocument> { | ||
results: Result<TDocument>[]; | ||
nextPageCursor?: string; | ||
@@ -33,7 +33,22 @@ previousPageCursor?: string; | ||
/** | ||
* Base properties that all indexed documents must include, as well as some | ||
* common properties that documents are encouraged to use where appropriate. | ||
* @beta | ||
*/ | ||
interface IndexableDocument { | ||
declare type SearchResult = Result<SearchDocument>; | ||
/** | ||
* @beta | ||
*/ | ||
declare type SearchResultSet = ResultSet<SearchDocument>; | ||
/** | ||
* @beta | ||
*/ | ||
declare type IndexableResult = Result<IndexableDocument>; | ||
/** | ||
* @beta | ||
*/ | ||
declare type IndexableResultSet = ResultSet<IndexableDocument>; | ||
/** | ||
* Base properties that all search documents must include. | ||
* @beta | ||
*/ | ||
interface SearchDocument { | ||
/** | ||
@@ -52,2 +67,11 @@ * The primary name of the document (e.g. name, title, identifier, etc). | ||
location: string; | ||
} | ||
/** | ||
* Properties related to indexing of documents. This type is only useful for | ||
* backends working directly with documents being inserted or retrieved from | ||
* search indexes. When dealing with documents in the frontend, use | ||
* {@link SearchDocument}. | ||
* @beta | ||
*/ | ||
declare type IndexableDocument = SearchDocument & { | ||
/** | ||
@@ -63,3 +87,3 @@ * Optional authorization information to be used when determining whether this | ||
}; | ||
} | ||
}; | ||
/** | ||
@@ -151,5 +175,5 @@ * Information about a specific document type. Intended to be used in the | ||
*/ | ||
query(query: SearchQuery, options?: QueryRequestOptions): Promise<SearchResultSet>; | ||
query(query: SearchQuery, options?: QueryRequestOptions): Promise<IndexableResultSet>; | ||
} | ||
export { DocumentCollatorFactory, DocumentDecoratorFactory, DocumentTypeInfo, IndexableDocument, QueryRequestOptions, QueryTranslator, SearchEngine, SearchQuery, SearchResult, SearchResultSet }; | ||
export { DocumentCollatorFactory, DocumentDecoratorFactory, DocumentTypeInfo, IndexableDocument, IndexableResult, IndexableResultSet, QueryRequestOptions, QueryTranslator, Result, ResultSet, SearchDocument, SearchEngine, SearchQuery, SearchResult, SearchResultSet }; |
{ | ||
"name": "@backstage/plugin-search-common", | ||
"description": "Common functionalities for Search, to be shared between various search-enabled plugins", | ||
"version": "0.3.2", | ||
"version": "0.3.3-next.0", | ||
"main": "dist/index.cjs.js", | ||
@@ -46,3 +46,3 @@ "types": "dist/index.d.ts", | ||
"devDependencies": { | ||
"@backstage/cli": "^0.16.0" | ||
"@backstage/cli": "^0.16.1-next.0" | ||
}, | ||
@@ -54,3 +54,3 @@ "jest": { | ||
}, | ||
"gitHead": "e9496f746b31600dbfac7fa76987479e66426257" | ||
"gitHead": "6bc4253672337538ce7ea5aadb3e9f60daeb3f80" | ||
} |
23991
174