@backstage/plugin-search-common 0.3.2 → 0.3.3-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @backstage/plugin-search-common
2
2
 
3
+ ## 0.3.3-next.0
4
+
5
+ ### Patch Changes
6
+
7
+ - 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.
8
+ - `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.
9
+ - Introduce `IndexableResultSet` type, which wraps `IndexableDocument` instances in the same way as `SearchResultSet`.
10
+
3
11
  ## 0.3.2
4
12
 
5
13
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -15,24 +15,39 @@ interface SearchQuery {
15
15
  /**
16
16
  * @beta
17
17
  */
18
- interface SearchResult {
18
+ interface Result<TDocument extends SearchDocument> {
19
19
  type: string;
20
- document: IndexableDocument;
20
+ document: TDocument;
21
21
  }
22
22
  /**
23
23
  * @beta
24
24
  */
25
- interface SearchResultSet {
26
- results: SearchResult[];
25
+ interface ResultSet<TDocument extends SearchDocument> {
26
+ results: Result<TDocument>[];
27
27
  nextPageCursor?: string;
28
28
  previousPageCursor?: string;
29
29
  }
30
30
  /**
31
- * Base properties that all indexed documents must include, as well as some
32
- * common properties that documents are encouraged to use where appropriate.
33
31
  * @beta
34
32
  */
35
- interface IndexableDocument {
33
+ declare type SearchResult = Result<SearchDocument>;
34
+ /**
35
+ * @beta
36
+ */
37
+ declare type SearchResultSet = ResultSet<SearchDocument>;
38
+ /**
39
+ * @beta
40
+ */
41
+ declare type IndexableResult = Result<IndexableDocument>;
42
+ /**
43
+ * @beta
44
+ */
45
+ declare type IndexableResultSet = ResultSet<IndexableDocument>;
46
+ /**
47
+ * Base properties that all search documents must include.
48
+ * @beta
49
+ */
50
+ interface SearchDocument {
36
51
  /**
37
52
  * The primary name of the document (e.g. name, title, identifier, etc).
38
53
  */
@@ -46,6 +61,15 @@ interface IndexableDocument {
46
61
  * is clicked).
47
62
  */
48
63
  location: string;
64
+ }
65
+ /**
66
+ * Properties related to indexing of documents. This type is only useful for
67
+ * backends working directly with documents being inserted or retrieved from
68
+ * search indexes. When dealing with documents in the frontend, use
69
+ * {@link SearchDocument}.
70
+ * @beta
71
+ */
72
+ declare type IndexableDocument = SearchDocument & {
49
73
  /**
50
74
  * Optional authorization information to be used when determining whether this
51
75
  * search result should be visible to a given user.
@@ -56,7 +80,7 @@ interface IndexableDocument {
56
80
  */
57
81
  resourceRef: string;
58
82
  };
59
- }
83
+ };
60
84
  /**
61
85
  * Information about a specific document type. Intended to be used in the
62
86
  * {@link @backstage/search-backend-node#IndexBuilder} to collect information
@@ -143,7 +167,7 @@ interface SearchEngine {
143
167
  /**
144
168
  * Perform a search query against the SearchEngine.
145
169
  */
146
- query(query: SearchQuery, options?: QueryRequestOptions): Promise<SearchResultSet>;
170
+ query(query: SearchQuery, options?: QueryRequestOptions): Promise<IndexableResultSet>;
147
171
  }
148
172
 
149
- export { DocumentCollatorFactory, DocumentDecoratorFactory, DocumentTypeInfo, IndexableDocument, QueryRequestOptions, QueryTranslator, SearchEngine, SearchQuery, SearchResult, SearchResultSet };
173
+ export { DocumentCollatorFactory, DocumentDecoratorFactory, DocumentTypeInfo, IndexableDocument, IndexableResult, IndexableResultSet, QueryRequestOptions, QueryTranslator, Result, ResultSet, SearchDocument, SearchEngine, SearchQuery, SearchResult, SearchResultSet };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@backstage/plugin-search-common",
3
3
  "description": "Common functionalities for Search, to be shared between various search-enabled plugins",
4
- "version": "0.3.2",
4
+ "version": "0.3.3-next.0",
5
5
  "main": "dist/index.cjs.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "private": false,
@@ -43,12 +43,12 @@
43
43
  "@backstage/types": "^1.0.0"
44
44
  },
45
45
  "devDependencies": {
46
- "@backstage/cli": "^0.16.0"
46
+ "@backstage/cli": "^0.16.1-next.0"
47
47
  },
48
48
  "jest": {
49
49
  "roots": [
50
50
  ".."
51
51
  ]
52
52
  },
53
- "gitHead": "e9496f746b31600dbfac7fa76987479e66426257"
53
+ "gitHead": "6bc4253672337538ce7ea5aadb3e9f60daeb3f80"
54
54
  }