@findlane/browser 0.29.0 → 0.30.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.
Files changed (2) hide show
  1. package/dist/index.d.ts +34 -0
  2. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -66,6 +66,12 @@ export type SearchRequest = {
66
66
  * unless it says, or `true` for that. Up to 5. Their results come back in `subindexes`; the search and its
67
67
  * subindexes count as one search (0.22.0). */
68
68
  subindexes?: Record<string, SubindexSearch | true>;
69
+ /** The facet values the query names, such as a category, a brand or a zip, to offer beside the results
70
+ * (0.30.0): `true` for every field of the index's facet matches setting, or `{ fields }` for some of them.
71
+ * They come back in `facetMatches`, in the same search. */
72
+ facetMatches?: boolean | {
73
+ fields?: string[];
74
+ };
69
75
  };
70
76
  /** A subindex's own search, in a search that asks for it. */
71
77
  export type SubindexSearch = Omit<SearchRequest, "subindexes">;
@@ -165,6 +171,34 @@ export type SearchResponse<T> = {
165
171
  id: string;
166
172
  variant: "a" | "b";
167
173
  };
174
+ /** With `facetMatches`: the facet values the query names, best first, at most 10 (0.30.0). Empty when it
175
+ * names none or the index has no facet matches setting. */
176
+ facetMatches?: FacetMatch[];
177
+ };
178
+ /** A facet value a query names (0.30.0), such as the category Prótein for "prót":
179
+ * - `values`: the field's values it stands for, as facet counts write them; several when values share a label,
180
+ * as a town's zips do.
181
+ * - `label`: its name, from the records beside the value, the setting, or the value itself.
182
+ * - `count`: its records that the search's filters allow.
183
+ * - `match`: how the query named it: `exact`, `prefix` (a word still being typed), `typo`, or `contains` (the
184
+ * whole query is a later word of the value).
185
+ * - `whole`: it took every word of the query. `typed`: where those words are in `q`, as UTF-16 offsets (end
186
+ * exclusive), so they can be set apart.
187
+ * - `link`: where the setting links it, with its values. `filter`: filters for it, to add to a search's `filters`.
188
+ * - `applied`: whether this search used the filter itself; false for now. */
189
+ export type FacetMatch = {
190
+ field: string;
191
+ values: string[];
192
+ label: string;
193
+ count: number;
194
+ match: "exact" | "prefix" | "typo" | "contains";
195
+ whole: boolean;
196
+ typed?: [number, number];
197
+ link?: string;
198
+ filter: Record<string, {
199
+ in: Array<string | number | boolean>;
200
+ }>;
201
+ applied: boolean;
168
202
  };
169
203
  /** One search of a multi-index search (multiSearch): its index's public ID, the client's own when left out. */
170
204
  export type MultiSearchQuery = SearchRequest & {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@findlane/browser",
3
- "version": "0.29.0",
3
+ "version": "0.30.0",
4
4
  "description": "Findlane browser SDK: fast, typo-tolerant public search from the browser with an index's public ID, plus React hooks and components.",
5
5
  "keywords": ["findlane", "search", "full-text search", "typo tolerance", "instant search", "ecommerce search", "browser", "react", "autocomplete"],
6
6
  "license": "MIT",