@findlane/server 0.4.1 → 0.5.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
@@ -32,6 +32,8 @@ export type IndexSettings = {
32
32
  * search that finds nothing. Off by default. */
33
33
  didYouMean?: boolean;
34
34
  normalizationProfile?: "default-v2" | "default-v1" | "icelandic-ascii-v1";
35
+ /** An object field of lat and lng numbers, such as `_geoloc`, that `near` and `within` search; null for none. */
36
+ locationField?: string | null;
35
37
  [key: string]: unknown;
36
38
  };
37
39
  /** A settings change running in the background (with the settings it applies), or the last one's
@@ -72,6 +74,8 @@ export type PublicSearchPolicy = {
72
74
  facetFields: string[];
73
75
  sortIds: string[];
74
76
  defaultSort: string;
77
+ /** Whether browser search may use `near` and `within`, which show roughly where each record is. */
78
+ location?: boolean;
75
79
  };
76
80
  export type PublicSearchAccess = {
77
81
  publicId: string;
@@ -91,7 +95,7 @@ export type RecordSnapshot<T> = {
91
95
  };
92
96
  export type SearchRequest = {
93
97
  q?: string;
94
- /** A sort ID from the index settings, or "relevance". */
98
+ /** A sort ID from the index settings, "relevance", or "distance" (with `near`). */
95
99
  sort?: string;
96
100
  /** Field values to keep: a value, `{ in: [...] }`, or a range `{ gte, lte }` for numbers and dates. */
97
101
  filters?: Record<string, unknown>;
@@ -115,12 +119,35 @@ export type SearchRequest = {
115
119
  preTag?: string;
116
120
  postTag?: string;
117
121
  };
122
+ /** Nearest first from a point, with each hit's `distance` in meters; `radius` (meters) keeps only what's
123
+ * within it. With a query, the best matches come first and distance orders them. Needs the index's
124
+ * location field. Records without a location are left out. */
125
+ near?: GeoPoint & {
126
+ radius?: number;
127
+ };
128
+ /** Only records inside a box, in degrees, such as a map's visible area. West greater than east crosses the
129
+ * antimeridian. */
130
+ within?: GeoBox;
131
+ };
132
+ /** A point in degrees: lat from -90 to 90, lng from -180 to 180. */
133
+ export type GeoPoint = {
134
+ lat: number;
135
+ lng: number;
136
+ };
137
+ /** A box in degrees, such as a map's bounds. */
138
+ export type GeoBox = {
139
+ north: number;
140
+ south: number;
141
+ east: number;
142
+ west: number;
118
143
  };
119
144
  export type SearchResponse<T> = {
120
145
  hits: {
121
146
  id: string;
122
147
  score: number | null;
123
148
  record: T;
149
+ /** With `near`: meters from the point. */
150
+ distance?: number;
124
151
  /** With `highlight`: matched searchable fields by path; list fields give one string per value. */
125
152
  highlights?: Record<string, string | string[]>;
126
153
  }[];
@@ -137,6 +164,8 @@ export type SearchResponse<T> = {
137
164
  }>;
138
165
  tookMs: number;
139
166
  sort?: string;
167
+ /** With `near`: the point distances are from, or null when the visitor's location isn't known. */
168
+ near?: GeoPoint | null;
140
169
  /** With the index's `didYouMean` setting: the query with the words typo tolerance corrected, when the
141
170
  * results matched some words only by typo ("Showing results for …"), else null. */
142
171
  didYouMean?: DidYouMean | null;
package/dist/index.d.ts CHANGED
@@ -32,6 +32,8 @@ export type IndexSettings = {
32
32
  * search that finds nothing. Off by default. */
33
33
  didYouMean?: boolean;
34
34
  normalizationProfile?: "default-v2" | "default-v1" | "icelandic-ascii-v1";
35
+ /** An object field of lat and lng numbers, such as `_geoloc`, that `near` and `within` search; null for none. */
36
+ locationField?: string | null;
35
37
  [key: string]: unknown;
36
38
  };
37
39
  /** A settings change running in the background (with the settings it applies), or the last one's
@@ -72,6 +74,8 @@ export type PublicSearchPolicy = {
72
74
  facetFields: string[];
73
75
  sortIds: string[];
74
76
  defaultSort: string;
77
+ /** Whether browser search may use `near` and `within`, which show roughly where each record is. */
78
+ location?: boolean;
75
79
  };
76
80
  export type PublicSearchAccess = {
77
81
  publicId: string;
@@ -91,7 +95,7 @@ export type RecordSnapshot<T> = {
91
95
  };
92
96
  export type SearchRequest = {
93
97
  q?: string;
94
- /** A sort ID from the index settings, or "relevance". */
98
+ /** A sort ID from the index settings, "relevance", or "distance" (with `near`). */
95
99
  sort?: string;
96
100
  /** Field values to keep: a value, `{ in: [...] }`, or a range `{ gte, lte }` for numbers and dates. */
97
101
  filters?: Record<string, unknown>;
@@ -115,12 +119,35 @@ export type SearchRequest = {
115
119
  preTag?: string;
116
120
  postTag?: string;
117
121
  };
122
+ /** Nearest first from a point, with each hit's `distance` in meters; `radius` (meters) keeps only what's
123
+ * within it. With a query, the best matches come first and distance orders them. Needs the index's
124
+ * location field. Records without a location are left out. */
125
+ near?: GeoPoint & {
126
+ radius?: number;
127
+ };
128
+ /** Only records inside a box, in degrees, such as a map's visible area. West greater than east crosses the
129
+ * antimeridian. */
130
+ within?: GeoBox;
131
+ };
132
+ /** A point in degrees: lat from -90 to 90, lng from -180 to 180. */
133
+ export type GeoPoint = {
134
+ lat: number;
135
+ lng: number;
136
+ };
137
+ /** A box in degrees, such as a map's bounds. */
138
+ export type GeoBox = {
139
+ north: number;
140
+ south: number;
141
+ east: number;
142
+ west: number;
118
143
  };
119
144
  export type SearchResponse<T> = {
120
145
  hits: {
121
146
  id: string;
122
147
  score: number | null;
123
148
  record: T;
149
+ /** With `near`: meters from the point. */
150
+ distance?: number;
124
151
  /** With `highlight`: matched searchable fields by path; list fields give one string per value. */
125
152
  highlights?: Record<string, string | string[]>;
126
153
  }[];
@@ -137,6 +164,8 @@ export type SearchResponse<T> = {
137
164
  }>;
138
165
  tookMs: number;
139
166
  sort?: string;
167
+ /** With `near`: the point distances are from, or null when the visitor's location isn't known. */
168
+ near?: GeoPoint | null;
140
169
  /** With the index's `didYouMean` setting: the query with the words typo tolerance corrected, when the
141
170
  * results matched some words only by typo ("Showing results for …"), else null. */
142
171
  didYouMean?: DidYouMean | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@findlane/server",
3
- "version": "0.4.1",
3
+ "version": "0.5.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",