@findlane/server 0.33.0 → 0.35.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/dist/index.d.cts CHANGED
@@ -107,6 +107,13 @@ export type IndexSettings = {
107
107
  variants?: {
108
108
  field: string;
109
109
  } | null;
110
+ /** Facet matches (0.34.0): the facet values a search's query names, such as a category, a brand or a zip, for
111
+ * searches that ask (`facetMatches` in a search). Each of up to 10 fields is a facet, with its values' names
112
+ * read from records beside them (`labelPath`, and `labelKey` when the field isn't beside it: categories.name
113
+ * beside categories.slug), written (`labels`: a value's names, values sharing one matching as one), or the
114
+ * values themselves; `only: "labelled"` leaves the rest out, `hide` lists values that never match, and `link`
115
+ * is where a match goes, with `{value}`. `perField` matches per field, 3 by default. Null for none. */
116
+ facetMatches?: FacetMatchesSetting | null;
110
117
  /** When saving: types for fields no record has yet, so settings can come before the records. Records'
111
118
  * types win once they have the field. Not returned when reading settings. */
112
119
  fieldTypes?: Record<string, "text" | "number" | "boolean" | "text[]" | "number[]" | "boolean[]" | "location">;
@@ -422,6 +429,42 @@ export type SearchRequest = {
422
429
  * unless it says, or `true` for that. Up to 5. Their results come back in `subindexes`; the search and its
423
430
  * subindexes count as one search (0.25.0). */
424
431
  subindexes?: Record<string, Omit<SearchRequest, "subindexes"> | true>;
432
+ /** The facet values the query names (0.34.0): `true` for every field of the index's facetMatches setting, or
433
+ * `{ fields }` for some of them. They come back in `facetMatches`. */
434
+ facetMatches?: boolean | {
435
+ fields?: string[];
436
+ };
437
+ };
438
+ /** The facetMatches setting (0.34.0); see IndexSettings. */
439
+ export type FacetMatchesSetting = {
440
+ fields: Array<{
441
+ field: string;
442
+ labelPath?: string;
443
+ labelKey?: string;
444
+ labels?: Record<string, string | string[]>;
445
+ only?: "labelled";
446
+ hide?: string[];
447
+ link?: string;
448
+ }>;
449
+ perField?: number;
450
+ };
451
+ /** A facet value a query names (0.34.0): the field's `values` it stands for (several when values share a label),
452
+ * its `label`, its `count` of records the search's filters allow, how it matched (`match`: exact, prefix, typo,
453
+ * or contains, a later word of the value), whether it took every word (`whole`), where those words are in `q`
454
+ * (`typed`, UTF-16 offsets), its `link`, a `filter` for it, and whether the search applied it (false for now). */
455
+ export type FacetMatch = {
456
+ field: string;
457
+ values: string[];
458
+ label: string;
459
+ count: number;
460
+ match: "exact" | "prefix" | "typo" | "contains";
461
+ whole: boolean;
462
+ typed?: [number, number];
463
+ link?: string;
464
+ filter: Record<string, {
465
+ in: Array<string | number | boolean>;
466
+ }>;
467
+ applied: boolean;
425
468
  };
426
469
  /** A subindex whose search failed, such as one the index doesn't have (404). */
427
470
  export type SubindexError = {
@@ -589,6 +632,8 @@ export type SearchResponse<T> = {
589
632
  };
590
633
  /** With `subindexes`: each subindex's results by name, or its error (0.25.0). */
591
634
  subindexes?: Record<string, SearchResponse<JsonRecord> | SubindexError>;
635
+ /** With `facetMatches`: the facet values the query names, best first, at most 10 (0.34.0). */
636
+ facetMatches?: FacetMatch[];
592
637
  };
593
638
  /** How a product's recommendations are served (the recommendations add-on). */
594
639
  /** One of an index's lists (docs: Lists): a row of products, such as Popular or New arrivals, from a filter and
@@ -810,6 +855,17 @@ export type ServerEvent = {
810
855
  query?: string;
811
856
  position?: number;
812
857
  timestamp?: number;
858
+ }
859
+ /** A facet match was picked: its field, the value picked (one of the match's values), its label, the search's
860
+ * query, and its place among the rows. */
861
+ | {
862
+ type: "facetMatch";
863
+ field: string;
864
+ value: string;
865
+ label?: string;
866
+ query?: string;
867
+ position?: number;
868
+ timestamp?: number;
813
869
  };
814
870
  /** A category page (a facet field's value, without search words), or a search's exact words. */
815
871
  export type MerchandisingTarget = {
package/dist/index.d.ts CHANGED
@@ -107,6 +107,13 @@ export type IndexSettings = {
107
107
  variants?: {
108
108
  field: string;
109
109
  } | null;
110
+ /** Facet matches (0.34.0): the facet values a search's query names, such as a category, a brand or a zip, for
111
+ * searches that ask (`facetMatches` in a search). Each of up to 10 fields is a facet, with its values' names
112
+ * read from records beside them (`labelPath`, and `labelKey` when the field isn't beside it: categories.name
113
+ * beside categories.slug), written (`labels`: a value's names, values sharing one matching as one), or the
114
+ * values themselves; `only: "labelled"` leaves the rest out, `hide` lists values that never match, and `link`
115
+ * is where a match goes, with `{value}`. `perField` matches per field, 3 by default. Null for none. */
116
+ facetMatches?: FacetMatchesSetting | null;
110
117
  /** When saving: types for fields no record has yet, so settings can come before the records. Records'
111
118
  * types win once they have the field. Not returned when reading settings. */
112
119
  fieldTypes?: Record<string, "text" | "number" | "boolean" | "text[]" | "number[]" | "boolean[]" | "location">;
@@ -422,6 +429,42 @@ export type SearchRequest = {
422
429
  * unless it says, or `true` for that. Up to 5. Their results come back in `subindexes`; the search and its
423
430
  * subindexes count as one search (0.25.0). */
424
431
  subindexes?: Record<string, Omit<SearchRequest, "subindexes"> | true>;
432
+ /** The facet values the query names (0.34.0): `true` for every field of the index's facetMatches setting, or
433
+ * `{ fields }` for some of them. They come back in `facetMatches`. */
434
+ facetMatches?: boolean | {
435
+ fields?: string[];
436
+ };
437
+ };
438
+ /** The facetMatches setting (0.34.0); see IndexSettings. */
439
+ export type FacetMatchesSetting = {
440
+ fields: Array<{
441
+ field: string;
442
+ labelPath?: string;
443
+ labelKey?: string;
444
+ labels?: Record<string, string | string[]>;
445
+ only?: "labelled";
446
+ hide?: string[];
447
+ link?: string;
448
+ }>;
449
+ perField?: number;
450
+ };
451
+ /** A facet value a query names (0.34.0): the field's `values` it stands for (several when values share a label),
452
+ * its `label`, its `count` of records the search's filters allow, how it matched (`match`: exact, prefix, typo,
453
+ * or contains, a later word of the value), whether it took every word (`whole`), where those words are in `q`
454
+ * (`typed`, UTF-16 offsets), its `link`, a `filter` for it, and whether the search applied it (false for now). */
455
+ export type FacetMatch = {
456
+ field: string;
457
+ values: string[];
458
+ label: string;
459
+ count: number;
460
+ match: "exact" | "prefix" | "typo" | "contains";
461
+ whole: boolean;
462
+ typed?: [number, number];
463
+ link?: string;
464
+ filter: Record<string, {
465
+ in: Array<string | number | boolean>;
466
+ }>;
467
+ applied: boolean;
425
468
  };
426
469
  /** A subindex whose search failed, such as one the index doesn't have (404). */
427
470
  export type SubindexError = {
@@ -589,6 +632,8 @@ export type SearchResponse<T> = {
589
632
  };
590
633
  /** With `subindexes`: each subindex's results by name, or its error (0.25.0). */
591
634
  subindexes?: Record<string, SearchResponse<JsonRecord> | SubindexError>;
635
+ /** With `facetMatches`: the facet values the query names, best first, at most 10 (0.34.0). */
636
+ facetMatches?: FacetMatch[];
592
637
  };
593
638
  /** How a product's recommendations are served (the recommendations add-on). */
594
639
  /** One of an index's lists (docs: Lists): a row of products, such as Popular or New arrivals, from a filter and
@@ -810,6 +855,17 @@ export type ServerEvent = {
810
855
  query?: string;
811
856
  position?: number;
812
857
  timestamp?: number;
858
+ }
859
+ /** A facet match was picked: its field, the value picked (one of the match's values), its label, the search's
860
+ * query, and its place among the rows. */
861
+ | {
862
+ type: "facetMatch";
863
+ field: string;
864
+ value: string;
865
+ label?: string;
866
+ query?: string;
867
+ position?: number;
868
+ timestamp?: number;
813
869
  };
814
870
  /** A category page (a facet field's value, without search words), or a search's exact words. */
815
871
  export type MerchandisingTarget = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@findlane/server",
3
- "version": "0.33.0",
3
+ "version": "0.35.0",
4
4
  "description": "Findlane server SDK: upload catalogs, manage index settings, and search with a secret workspace API key.",
5
5
  "keywords": ["findlane", "search", "full-text search", "typo tolerance", "ecommerce search", "search api", "sdk"],
6
6
  "license": "MIT",