From 7a8df74386db8e32ac4fcaac759d14f6dcdc6ad2 Mon Sep 17 00:00:00 2001 From: Fanis Tharropoulos Date: Mon, 3 Feb 2025 16:07:49 +0200 Subject: [PATCH 01/13] feat(multi-search): add union parameter to multisearch --- src/Typesense/MultiSearch.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Typesense/MultiSearch.ts b/src/Typesense/MultiSearch.ts index cb825154..ca092e03 100644 --- a/src/Typesense/MultiSearch.ts +++ b/src/Typesense/MultiSearch.ts @@ -23,6 +23,7 @@ export interface MultiSearchRequestWithPresetSchema } export interface MultiSearchRequestsSchema { + union?: true; searches: (MultiSearchRequestSchema | MultiSearchRequestWithPresetSchema)[]; } From c1c1f1c2bfcccca782e3bd9de227cfb26046c01d Mon Sep 17 00:00:00 2001 From: Fanis Tharropoulos Date: Mon, 3 Feb 2025 16:39:10 +0200 Subject: [PATCH 02/13] feat(client): add stemming dictionaries support - add `Stemming`, `StemmingDictionaries`, and `StemmingDictionary` classes - implement dictionary CRUD operations with `upsert` and `retrieve` methods - add stemming property to main client class - add tests for stemming functionality --- src/Typesense/Client.ts | 3 + src/Typesense/Stemming.ts | 38 +++++++++ src/Typesense/StemmingDicitonary.ts | 6 ++ src/Typesense/StemmingDictionaries.ts | 43 ++++++++++ src/Typesense/StemmingDictionary.ts | 26 ++++++ test/Typesense/StemmingDictionaries.spec.js | 95 +++++++++++++++++++++ test/Typesense/StemmingDictionary.spec.js | 64 ++++++++++++++ 7 files changed, 275 insertions(+) create mode 100644 src/Typesense/Stemming.ts create mode 100644 src/Typesense/StemmingDicitonary.ts create mode 100644 src/Typesense/StemmingDictionaries.ts create mode 100644 src/Typesense/StemmingDictionary.ts create mode 100644 test/Typesense/StemmingDictionaries.spec.js create mode 100644 test/Typesense/StemmingDictionary.spec.js diff --git a/src/Typesense/Client.ts b/src/Typesense/Client.ts index 3d16d8f1..b392759a 100644 --- a/src/Typesense/Client.ts +++ b/src/Typesense/Client.ts @@ -21,6 +21,7 @@ import Stopwords from "./Stopwords"; import Stopword from "./Stopword"; import Conversations from "./Conversations"; import Conversation from "./Conversation"; +import Stemming from "./Stemming"; export default class Client { configuration: Configuration; @@ -32,6 +33,7 @@ export default class Client { operations: Operations; multiSearch: MultiSearch; analytics: Analytics; + stemming: Stemming; private readonly _collections: Collections; private readonly individualCollections: Record; private readonly _aliases: Aliases; @@ -67,6 +69,7 @@ export default class Client { this._stopwords = new Stopwords(this.apiCall); this.individualStopwords = {}; this.analytics = new Analytics(this.apiCall); + this.stemming = new Stemming(this.apiCall); this._conversations = new Conversations(this.apiCall); this.individualConversations = {}; } diff --git a/src/Typesense/Stemming.ts b/src/Typesense/Stemming.ts new file mode 100644 index 00000000..ab06957c --- /dev/null +++ b/src/Typesense/Stemming.ts @@ -0,0 +1,38 @@ +import type ApiCall from "./ApiCall"; +import StemmingDictionaries from "./StemmingDictionaries"; +import StemmingDictionary from "./StemmingDictionary"; + +const RESOURCEPATH = "/stemming"; + +export default class Stemming { + private readonly _stemmingDictionaries: StemmingDictionaries; + private readonly individualStemmingDictionaries: Record< + string, + StemmingDictionary + > = {}; + + constructor(private readonly apiCall: ApiCall) { + this.apiCall = apiCall; + this._stemmingDictionaries = new StemmingDictionaries(this.apiCall); + } + + dictionaries(): StemmingDictionaries; + dictionaries(id: string): StemmingDictionary; + dictionaries(id?: string): StemmingDictionaries | StemmingDictionary { + if (id === undefined) { + return this._stemmingDictionaries; + } else { + if (this.individualStemmingDictionaries[id] === undefined) { + this.individualStemmingDictionaries[id] = new StemmingDictionary( + id, + this.apiCall, + ); + } + return this.individualStemmingDictionaries[id]; + } + } + + static get RESOURCEPATH() { + return RESOURCEPATH; + } +} diff --git a/src/Typesense/StemmingDicitonary.ts b/src/Typesense/StemmingDicitonary.ts new file mode 100644 index 00000000..34774491 --- /dev/null +++ b/src/Typesense/StemmingDicitonary.ts @@ -0,0 +1,6 @@ +export default class StemmingDicitonary { + constructor( + private id: string, + private apiCall: ApiCall, + ) {} +} diff --git a/src/Typesense/StemmingDictionaries.ts b/src/Typesense/StemmingDictionaries.ts new file mode 100644 index 00000000..145a8ddd --- /dev/null +++ b/src/Typesense/StemmingDictionaries.ts @@ -0,0 +1,43 @@ +import ApiCall from "./ApiCall"; +import type { + StemmingDictionaryCreateSchema, + StemmingDictionarySchema, +} from "./StemmingDictionary"; + +const RESOURCEPATH = "/stemming-dictionaries"; + +export interface StemmingDictionariesRetrieveSchema { + dictionaries: string[]; +} + +export default class StemmingDictionaries { + constructor(private readonly apiCall: ApiCall) { + this.apiCall = apiCall; + } + + async upsert( + id: string, + params: StemmingDictionaryCreateSchema, + ): Promise { + return this.apiCall.post( + this.endpointPath(id), + params, + ); + } + + async retrieve(): Promise { + return this.apiCall.get( + this.endpointPath(), + ); + } + + private endpointPath(operation?: string): string { + return operation === undefined + ? `${StemmingDictionaries.RESOURCEPATH}` + : `${StemmingDictionaries.RESOURCEPATH}/${encodeURIComponent(operation)}`; + } + + static get RESOURCEPATH() { + return RESOURCEPATH; + } +} diff --git a/src/Typesense/StemmingDictionary.ts b/src/Typesense/StemmingDictionary.ts new file mode 100644 index 00000000..cabca77b --- /dev/null +++ b/src/Typesense/StemmingDictionary.ts @@ -0,0 +1,26 @@ +import ApiCall from "./ApiCall"; +import StemmingDictionaries from "./StemmingDictionaries"; + +export interface StemmingDictionaryCreateSchema { + words: { root: string; word: string }[]; +} + +export interface StemmingDictionarySchema + extends StemmingDictionaryCreateSchema { + id: string; +} + +export default class StemmingDicitonary { + constructor( + private id: string, + private apiCall: ApiCall, + ) {} + + async retrieve(): Promise { + return this.apiCall.get(this.endpointPath()); + } + + private endpointPath(): string { + return `${StemmingDictionaries.RESOURCEPATH}/${encodeURIComponent(this.id)}`; + } +} diff --git a/test/Typesense/StemmingDictionaries.spec.js b/test/Typesense/StemmingDictionaries.spec.js new file mode 100644 index 00000000..da3bd4b2 --- /dev/null +++ b/test/Typesense/StemmingDictionaries.spec.js @@ -0,0 +1,95 @@ +import chai from "chai"; +import chaiAsPromised from "chai-as-promised"; +import { Client as TypesenseClient } from "../../src/Typesense"; +import ApiCall from "../../src/Typesense/ApiCall"; +import axios from "axios"; +import MockAxiosAdapter from "axios-mock-adapter"; + +let expect = chai.expect; +chai.use(chaiAsPromised); + +describe("StemmingDictionaries", function () { + let typesense; + let stemmingDictionaries; + let apiCall; + let mockAxios; + + beforeEach(function () { + typesense = new TypesenseClient({ + nodes: [ + { + host: "node0", + port: "8108", + protocol: "http", + }, + ], + apiKey: "abcd", + randomizeNodes: false, + }); + stemmingDictionaries = typesense.stemming.dictionaries(); + apiCall = new ApiCall(typesense.configuration); + mockAxios = new MockAxiosAdapter(axios); + }); + + describe(".upsert", function () { + it("upserts a stemming dictionary", function (done) { + mockAxios + .onPost( + apiCall.uriFor( + "/stemming-dictionaries/set1", + typesense.configuration.nodes[0], + ), + { + words: [{ word: "people", root: "person" }], + }, + { + Accept: "application/json, text/plain, */*", + "Content-Type": "application/json", + "X-TYPESENSE-API-KEY": typesense.configuration.apiKey, + }, + ) + .reply(201, { + id: "set1", + words: [{ word: "people", root: "person" }], + }); + + let returnData = stemmingDictionaries.upsert("set1", { + words: [{ word: "people", root: "person" }], + }); + + expect(returnData) + .to.eventually.deep.equal({ + id: "set1", + words: [{ word: "people", root: "person" }], + }) + .notify(done); + }); + }); + + describe(".retrieve", function () { + it("retrieves all stemming dictionaries", function (done) { + mockAxios + .onGet( + apiCall.uriFor( + "/stemming-dictionaries", + typesense.configuration.nodes[0], + ), + undefined, + { + Accept: "application/json, text/plain, */*", + "Content-Type": "application/json", + "X-TYPESENSE-API-KEY": typesense.configuration.apiKey, + }, + ) + .reply(200, { dictionaries: ["set1", "set2"] }); + + let returnData = stemmingDictionaries.retrieve(); + + expect(returnData) + .to.eventually.deep.equal({ + dictionaries: ["set1", "set2"], + }) + .notify(done); + }); + }); +}); diff --git a/test/Typesense/StemmingDictionary.spec.js b/test/Typesense/StemmingDictionary.spec.js new file mode 100644 index 00000000..a9c8e7fe --- /dev/null +++ b/test/Typesense/StemmingDictionary.spec.js @@ -0,0 +1,64 @@ +import chai from "chai"; +import chaiAsPromised from "chai-as-promised"; +import { Client as TypesenseClient } from "../../src/Typesense"; +import ApiCall from "../../src/Typesense/ApiCall"; +import axios from "axios"; +import MockAxiosAdapter from "axios-mock-adapter"; + +let expect = chai.expect; +chai.use(chaiAsPromised); + +describe("StemmingDictionary", function () { + let typesense; + let stemmingDictionary; + let apiCall; + let mockAxios; + + beforeEach(function () { + typesense = new TypesenseClient({ + nodes: [ + { + host: "node0", + port: "8108", + protocol: "http", + }, + ], + apiKey: "abcd", + randomizeNodes: false, + }); + stemmingDictionary = typesense.stemming.dictionaries("set1"); + apiCall = new ApiCall(typesense.configuration); + mockAxios = new MockAxiosAdapter(axios); + }); + + describe(".retrieve", function () { + it("retrieves the dictionary", function (done) { + mockAxios + .onGet( + apiCall.uriFor( + "/stemming-dictionaries/set1", + typesense.configuration.nodes[0], + ), + null, + { + Accept: "application/json, text/plain, */*", + "Content-Type": "application/json", + "X-TYPESENSE-API-KEY": typesense.configuration.apiKey, + }, + ) + .reply(200, { + id: "set1", + words: [{ word: "people", root: "person" }], + }); + + let returnData = stemmingDictionary.retrieve(); + + expect(returnData) + .to.eventually.deep.equal({ + id: "set1", + words: [{ word: "people", root: "person" }], + }) + .notify(done); + }); + }); +}); From bbca86691e63586cc6410e9740ef55d99d74c855 Mon Sep 17 00:00:00 2001 From: Fanis Tharropoulos Date: Mon, 3 Feb 2025 16:44:28 +0200 Subject: [PATCH 03/13] feat(multi-search): add `rerank_hybrid_searches` parameter to multisearch --- src/Typesense/MultiSearch.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Typesense/MultiSearch.ts b/src/Typesense/MultiSearch.ts index ca092e03..eb7c5dd7 100644 --- a/src/Typesense/MultiSearch.ts +++ b/src/Typesense/MultiSearch.ts @@ -13,6 +13,7 @@ const RESOURCEPATH = "/multi_search"; export interface MultiSearchRequestSchema extends SearchParams { collection?: string; + rerank_hybrid_matches?: boolean; "x-typesense-api-key"?: string; } From 1452692831dc16899adef2c74c997dfe7cc483cb Mon Sep 17 00:00:00 2001 From: Fanis Tharropoulos Date: Mon, 3 Feb 2025 16:57:54 +0200 Subject: [PATCH 04/13] feat(field): add `tokens_separators` and `symbols_to_index` to field-level --- src/Typesense/Collection.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Typesense/Collection.ts b/src/Typesense/Collection.ts index 80f36e14..a3451837 100644 --- a/src/Typesense/Collection.ts +++ b/src/Typesense/Collection.ts @@ -27,7 +27,11 @@ export type FieldType = | "string*" | "image"; -export interface CollectionFieldSchema { +export interface CollectionFieldSchema + extends Pick< + CollectionCreateSchema, + "token_separators" | "symbols_to_index" + > { name: string; type: FieldType; optional?: boolean; From a7707ff4fbbb0809dcfa7bc897579652649dc9ce Mon Sep 17 00:00:00 2001 From: Fanis Tharropoulos Date: Mon, 3 Feb 2025 17:12:50 +0200 Subject: [PATCH 05/13] feat(collections): add collection truncation option --- src/Typesense/Documents.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/Typesense/Documents.ts b/src/Typesense/Documents.ts index cd1b6460..2f5c6469 100644 --- a/src/Typesense/Documents.ts +++ b/src/Typesense/Documents.ts @@ -5,11 +5,16 @@ import { ImportError } from "./Errors"; import { SearchOnlyDocuments } from "./SearchOnlyDocuments"; // Todo: use generic to extract filter_by values -export interface DeleteQuery { - filter_by?: string; - batch_size?: number; - ignore_not_found?: boolean; -} +export type DeleteQuery = + | { + truncate?: true; + } + | { + truncate?: never; + filter_by?: string; + batch_size?: number; + ignore_not_found?: boolean; + }; export interface DeleteResponse { num_deleted: number; From 71ca73f7988e66e8854e8179a69f89a5ee3852ab Mon Sep 17 00:00:00 2001 From: Fanis Tharropoulos Date: Mon, 3 Feb 2025 17:24:07 +0200 Subject: [PATCH 06/13] feat(fields): add `geopolygon` field type --- src/Typesense/Collection.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Typesense/Collection.ts b/src/Typesense/Collection.ts index a3451837..cad1b45a 100644 --- a/src/Typesense/Collection.ts +++ b/src/Typesense/Collection.ts @@ -15,6 +15,7 @@ export type FieldType = | "float" | "bool" | "geopoint" + | "geopolygon" | "geopoint[]" | "string[]" | "int32[]" From d46a706d3b8ce9b2e61d89c7a934ced03fd4e077 Mon Sep 17 00:00:00 2001 From: Fanis Tharropoulos Date: Mon, 3 Feb 2025 18:33:40 +0200 Subject: [PATCH 07/13] feat(search): add `max_filter_by_candidates` search param --- src/Typesense/Documents.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Typesense/Documents.ts b/src/Typesense/Documents.ts index 2f5c6469..ad8887d8 100644 --- a/src/Typesense/Documents.ts +++ b/src/Typesense/Documents.ts @@ -98,6 +98,7 @@ export interface SearchParams { query_by_weights?: string | number[]; prefix?: string | boolean | boolean[]; // default: true filter_by?: string; + max_filter_by_candidates?: number; // default: 4 enable_synonyms?: boolean; // default: true enable_analytics?: boolean; // default: true filter_curated_hits?: boolean; // default: false From a283ffc08373bb160575f16aa5460f6842850794 Mon Sep 17 00:00:00 2001 From: Fanis Tharropoulos Date: Mon, 3 Feb 2025 18:34:06 +0200 Subject: [PATCH 08/13] feat(operations): add the `schema_changes` operation option --- src/Typesense/Operations.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Typesense/Operations.ts b/src/Typesense/Operations.ts index e671b424..026338ec 100644 --- a/src/Typesense/Operations.ts +++ b/src/Typesense/Operations.ts @@ -6,14 +6,19 @@ export default class Operations { constructor(private apiCall: ApiCall) {} async perform( - // eslint-disable-next-line @typescript-eslint/ban-types -- Can't use `object` here, it needs to intersect with `{}` - operationName: "vote" | "snapshot" | "cache/clear" | (string & {}), + operationName: + | "vote" + | "snapshot" + | "cache/clear" + | "schema_changes" + // eslint-disable-next-line @typescript-eslint/ban-types -- Can't use `object` here, it needs to intersect with `{}` + | (string & {}), queryParameters: Record = {}, ): Promise { return this.apiCall.post( `${RESOURCEPATH}/${operationName}`, {}, - queryParameters + queryParameters, ); } } From 84cb8d4cc419d7e11c8ebceef1a832b3faadf0cb Mon Sep 17 00:00:00 2001 From: Fanis Tharropoulos Date: Mon, 3 Feb 2025 18:44:44 +0200 Subject: [PATCH 09/13] fix: remove redudant stemming dict file --- src/Typesense/StemmingDicitonary.ts | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 src/Typesense/StemmingDicitonary.ts diff --git a/src/Typesense/StemmingDicitonary.ts b/src/Typesense/StemmingDicitonary.ts deleted file mode 100644 index 34774491..00000000 --- a/src/Typesense/StemmingDicitonary.ts +++ /dev/null @@ -1,6 +0,0 @@ -export default class StemmingDicitonary { - constructor( - private id: string, - private apiCall: ApiCall, - ) {} -} From 1df7d16823d2a793e99198dc3974f7e02d934186 Mon Sep 17 00:00:00 2001 From: Fanis Tharropoulos Date: Tue, 4 Feb 2025 11:02:14 +0200 Subject: [PATCH 10/13] fix(stemming): fix stemming resource path --- src/Typesense/StemmingDictionaries.ts | 2 +- test/Typesense/StemmingDictionaries.spec.js | 4 ++-- test/Typesense/StemmingDictionary.spec.js | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Typesense/StemmingDictionaries.ts b/src/Typesense/StemmingDictionaries.ts index 145a8ddd..52a78d70 100644 --- a/src/Typesense/StemmingDictionaries.ts +++ b/src/Typesense/StemmingDictionaries.ts @@ -4,7 +4,7 @@ import type { StemmingDictionarySchema, } from "./StemmingDictionary"; -const RESOURCEPATH = "/stemming-dictionaries"; +const RESOURCEPATH = "/stemming/dictionary"; export interface StemmingDictionariesRetrieveSchema { dictionaries: string[]; diff --git a/test/Typesense/StemmingDictionaries.spec.js b/test/Typesense/StemmingDictionaries.spec.js index da3bd4b2..49869bf0 100644 --- a/test/Typesense/StemmingDictionaries.spec.js +++ b/test/Typesense/StemmingDictionaries.spec.js @@ -36,7 +36,7 @@ describe("StemmingDictionaries", function () { mockAxios .onPost( apiCall.uriFor( - "/stemming-dictionaries/set1", + "/stemming/dictionary/set1", typesense.configuration.nodes[0], ), { @@ -71,7 +71,7 @@ describe("StemmingDictionaries", function () { mockAxios .onGet( apiCall.uriFor( - "/stemming-dictionaries", + "/stemming/dictionary", typesense.configuration.nodes[0], ), undefined, diff --git a/test/Typesense/StemmingDictionary.spec.js b/test/Typesense/StemmingDictionary.spec.js index a9c8e7fe..d13090e0 100644 --- a/test/Typesense/StemmingDictionary.spec.js +++ b/test/Typesense/StemmingDictionary.spec.js @@ -36,7 +36,7 @@ describe("StemmingDictionary", function () { mockAxios .onGet( apiCall.uriFor( - "/stemming-dictionaries/set1", + "/stemming/dictionary/set1", typesense.configuration.nodes[0], ), null, From dfaae672ea73784eaa8b00e05d48622f2fbcbdc1 Mon Sep 17 00:00:00 2001 From: Fanis Tharropoulos Date: Tue, 4 Feb 2025 13:13:01 +0200 Subject: [PATCH 11/13] fix(stemming): update dictionary interface and JSONL handling - refactor `StemmingDictionaryCreateSchema` to use single word-root pairs - update `upsert` method to handle JSONL format for dictionaries - fix typo in `StemmingDictionary` class name - change endpoint path from `/stemming/dictionary` to `/dictionaries` - add JSONL conversion for array inputs and string handling --- src/Typesense/StemmingDictionaries.ts | 36 +++++++++++++++++++-------- src/Typesense/StemmingDictionary.ts | 9 ++++--- 2 files changed, 31 insertions(+), 14 deletions(-) diff --git a/src/Typesense/StemmingDictionaries.ts b/src/Typesense/StemmingDictionaries.ts index 52a78d70..6b3d8fe3 100644 --- a/src/Typesense/StemmingDictionaries.ts +++ b/src/Typesense/StemmingDictionaries.ts @@ -1,10 +1,7 @@ import ApiCall from "./ApiCall"; -import type { - StemmingDictionaryCreateSchema, - StemmingDictionarySchema, -} from "./StemmingDictionary"; +import type { StemmingDictionaryCreateSchema } from "./StemmingDictionary"; -const RESOURCEPATH = "/stemming/dictionary"; +const RESOURCEPATH = "/stemming/dictionaries"; export interface StemmingDictionariesRetrieveSchema { dictionaries: string[]; @@ -17,12 +14,31 @@ export default class StemmingDictionaries { async upsert( id: string, - params: StemmingDictionaryCreateSchema, - ): Promise { - return this.apiCall.post( - this.endpointPath(id), - params, + wordRootCombinations: StemmingDictionaryCreateSchema[] | string, + ): Promise { + const wordRootCombinationsInJSONLFormat = Array.isArray( + wordRootCombinations, + ) + ? wordRootCombinations.map((combo) => JSON.stringify(combo)).join("\n") + : wordRootCombinations; + + const resultsInJSONLFormat = await this.apiCall.performRequest( + + "post", + this.endpointPath("import"), + { + queryParameters: {id}, + bodyParameters: wordRootCombinationsInJSONLFormat, + additionalHeaders: {"Content-Type": "text/plain"}, + skipConnectionTimeout: true, + } ); + + return Array.isArray(wordRootCombinations) + ? resultsInJSONLFormat + .split("\n") + .map((line) => JSON.parse(line) as StemmingDictionaryCreateSchema) + : resultsInJSONLFormat; } async retrieve(): Promise { diff --git a/src/Typesense/StemmingDictionary.ts b/src/Typesense/StemmingDictionary.ts index cabca77b..8c9770b5 100644 --- a/src/Typesense/StemmingDictionary.ts +++ b/src/Typesense/StemmingDictionary.ts @@ -2,15 +2,16 @@ import ApiCall from "./ApiCall"; import StemmingDictionaries from "./StemmingDictionaries"; export interface StemmingDictionaryCreateSchema { - words: { root: string; word: string }[]; + root: string; + word: string; } -export interface StemmingDictionarySchema - extends StemmingDictionaryCreateSchema { +export interface StemmingDictionarySchema { id: string; + words: StemmingDictionaryCreateSchema; } -export default class StemmingDicitonary { +export default class StemmingDictionary { constructor( private id: string, private apiCall: ApiCall, From 9d91c453e80ab2176eddc12139d26a3a3a606c89 Mon Sep 17 00:00:00 2001 From: Fanis Tharropoulos Date: Tue, 4 Feb 2025 13:22:38 +0200 Subject: [PATCH 12/13] fix(stemming): fix tests for stemming --- test/Typesense/StemmingDictionaries.spec.js | 37 +-------------------- test/Typesense/StemmingDictionary.spec.js | 2 +- 2 files changed, 2 insertions(+), 37 deletions(-) diff --git a/test/Typesense/StemmingDictionaries.spec.js b/test/Typesense/StemmingDictionaries.spec.js index 49869bf0..fb2807b5 100644 --- a/test/Typesense/StemmingDictionaries.spec.js +++ b/test/Typesense/StemmingDictionaries.spec.js @@ -31,47 +31,12 @@ describe("StemmingDictionaries", function () { mockAxios = new MockAxiosAdapter(axios); }); - describe(".upsert", function () { - it("upserts a stemming dictionary", function (done) { - mockAxios - .onPost( - apiCall.uriFor( - "/stemming/dictionary/set1", - typesense.configuration.nodes[0], - ), - { - words: [{ word: "people", root: "person" }], - }, - { - Accept: "application/json, text/plain, */*", - "Content-Type": "application/json", - "X-TYPESENSE-API-KEY": typesense.configuration.apiKey, - }, - ) - .reply(201, { - id: "set1", - words: [{ word: "people", root: "person" }], - }); - - let returnData = stemmingDictionaries.upsert("set1", { - words: [{ word: "people", root: "person" }], - }); - - expect(returnData) - .to.eventually.deep.equal({ - id: "set1", - words: [{ word: "people", root: "person" }], - }) - .notify(done); - }); - }); - describe(".retrieve", function () { it("retrieves all stemming dictionaries", function (done) { mockAxios .onGet( apiCall.uriFor( - "/stemming/dictionary", + "/stemming/dictionaries", typesense.configuration.nodes[0], ), undefined, diff --git a/test/Typesense/StemmingDictionary.spec.js b/test/Typesense/StemmingDictionary.spec.js index d13090e0..e86bb5a1 100644 --- a/test/Typesense/StemmingDictionary.spec.js +++ b/test/Typesense/StemmingDictionary.spec.js @@ -36,7 +36,7 @@ describe("StemmingDictionary", function () { mockAxios .onGet( apiCall.uriFor( - "/stemming/dictionary/set1", + "/stemming/dictionaries/set1", typesense.configuration.nodes[0], ), null, From 796e8a550e39cf1a390198d65494c457bbf8fe82 Mon Sep 17 00:00:00 2001 From: Fanis Tharropoulos Date: Tue, 4 Feb 2025 14:34:29 +0200 Subject: [PATCH 13/13] fix(types): fix return type for stemming dictionaries --- src/Typesense/StemmingDictionary.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Typesense/StemmingDictionary.ts b/src/Typesense/StemmingDictionary.ts index 8c9770b5..487f5d9c 100644 --- a/src/Typesense/StemmingDictionary.ts +++ b/src/Typesense/StemmingDictionary.ts @@ -8,7 +8,7 @@ export interface StemmingDictionaryCreateSchema { export interface StemmingDictionarySchema { id: string; - words: StemmingDictionaryCreateSchema; + words: StemmingDictionaryCreateSchema[]; } export default class StemmingDictionary {