@findlane/server 0.2.0 → 0.3.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.ts +24 -0
- package/dist/index.js +1 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -28,6 +28,9 @@ export type IndexSettings = {
|
|
|
28
28
|
synonyms?: string[][];
|
|
29
29
|
/** Languages whose common words queries drop, and whose plurals and alternative spellings match. */
|
|
30
30
|
languages?: Array<"da" | "de" | "en" | "is" | "no" | "sv">;
|
|
31
|
+
/** Searches say which words typo tolerance corrected, and `suggest()` offers a corrected query for a
|
|
32
|
+
* search that finds nothing. Off by default. */
|
|
33
|
+
didYouMean?: boolean;
|
|
31
34
|
normalizationProfile?: "default-v2" | "default-v1" | "icelandic-ascii-v1";
|
|
32
35
|
[key: string]: unknown;
|
|
33
36
|
};
|
|
@@ -93,6 +96,9 @@ export type SearchRequest = {
|
|
|
93
96
|
/** Field values to keep: a value, `{ in: [...] }`, or a range `{ gte, lte }` for numbers and dates. */
|
|
94
97
|
filters?: Record<string, unknown>;
|
|
95
98
|
facets?: string[];
|
|
99
|
+
/** Facets (also in `facets`) counted without the filter on their own field, so a list of choices
|
|
100
|
+
* keeps its other values, with counts, after one is chosen. */
|
|
101
|
+
disjunctiveFacets?: string[];
|
|
96
102
|
limit?: number;
|
|
97
103
|
offset?: number;
|
|
98
104
|
attributesToRetrieve?: string[];
|
|
@@ -122,6 +128,20 @@ export type SearchResponse<T> = {
|
|
|
122
128
|
facets: Record<string, Record<string, number>>;
|
|
123
129
|
tookMs: number;
|
|
124
130
|
sort?: string;
|
|
131
|
+
/** With the index's `didYouMean` setting: the query with the words typo tolerance corrected, when the
|
|
132
|
+
* results matched some words only by typo ("Showing results for …"), else null. */
|
|
133
|
+
didYouMean?: DidYouMean | null;
|
|
134
|
+
};
|
|
135
|
+
/** A corrected query. `applied`: the results are already for `q` (a search's "Showing results for");
|
|
136
|
+
* otherwise searching `q` finds results that the query didn't ("Did you mean"). `changes` lists each
|
|
137
|
+
* changed part of the query as typed. */
|
|
138
|
+
export type DidYouMean = {
|
|
139
|
+
q: string;
|
|
140
|
+
applied: boolean;
|
|
141
|
+
changes: {
|
|
142
|
+
from: string;
|
|
143
|
+
to: string;
|
|
144
|
+
}[];
|
|
125
145
|
};
|
|
126
146
|
export type ConditionalWriteOptions = {
|
|
127
147
|
expectedVersion: number;
|
|
@@ -178,6 +198,10 @@ export declare class SearchServerClient {
|
|
|
178
198
|
} = JsonRecord>(name: string): {
|
|
179
199
|
/** Searches the index; the API key needs the `search` scope. */
|
|
180
200
|
search: <R = T>(query?: SearchRequest, signal?: AbortSignal) => Promise<SearchResponse<R>>;
|
|
201
|
+
/** Did you mean: for a search that found nothing, a query that finds something, or null. Takes the
|
|
202
|
+
* same request (its q, filters, and fields matter). Needs the `didYouMean` setting; not counted as
|
|
203
|
+
* a search. */
|
|
204
|
+
suggest: (query: SearchRequest, signal?: AbortSignal) => Promise<DidYouMean | null>;
|
|
181
205
|
upsert: (records: T[], signal?: AbortSignal) => Promise<WriteReceipt>;
|
|
182
206
|
getRecord: (objectID: string, signal?: AbortSignal) => Promise<RecordSnapshot<T>>;
|
|
183
207
|
upsertOne: (record: T, options: ConditionalWriteOptions) => Promise<WriteReceipt>;
|
package/dist/index.js
CHANGED
|
@@ -97,6 +97,7 @@ class SearchServerClient {
|
|
|
97
97
|
};
|
|
98
98
|
return {
|
|
99
99
|
search: (query = {}, signal) => request("/search", "POST", query, signal),
|
|
100
|
+
suggest: async (query, signal) => (await request("/suggest", "POST", query, signal)).didYouMean,
|
|
100
101
|
upsert: (records, signal) => request("/records", "POST", { records }, signal),
|
|
101
102
|
getRecord: (objectID, signal) => request(`/records/${encodeURIComponent(objectID)}`, "GET", undefined, signal),
|
|
102
103
|
upsertOne: (record, options) => writeOne("upsert", record.objectID, record, options),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@findlane/server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.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",
|