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