From f1fcb8192ea6f6a2b185e4c1eca9d71b8cd171cc Mon Sep 17 00:00:00 2001 From: Paul Kilmurray Date: Wed, 3 Jul 2024 13:27:16 +0100 Subject: [PATCH] add support for hebrew search --- babel.config.js => babel.config.cjs | 3 +++ jest.config.js | 2 +- package.json | 3 ++- src/search-dbs.ts | 2 ++ tests/manager.test.ts | 2 +- 5 files changed, 9 insertions(+), 3 deletions(-) rename babel.config.js => babel.config.cjs (65%) diff --git a/babel.config.js b/babel.config.cjs similarity index 65% rename from babel.config.js rename to babel.config.cjs index e8e4245..95b6735 100644 --- a/babel.config.js +++ b/babel.config.cjs @@ -1,3 +1,6 @@ +/** + * Jest runs Babel synchronously so we need to use the CommonJS module system. + */ module.exports = function (api) { api.cache(true); return { diff --git a/jest.config.js b/jest.config.js index 61e089b..a6e6ff1 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,6 +1,6 @@ const TEST_REGEX = '(/__tests__/.*|(\\.|/)(test|spec))\\.(tsx?|ts?)$'; -module.exports = { +export default { roots: ['/tests'], displayName: '@wcpos/query', preset: 'ts-jest', diff --git a/package.json b/package.json index 0ba5eb3..b04697c 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,11 @@ { "name": "@wcpos/query", - "version": "1.6.7", + "version": "1.6.8", "description": "Query and Replication for WooCommerce POS", "author": "kilbot ", "license": "MIT", "main": "src/index.ts", + "type": "module", "files": [ "src/*" ], diff --git a/src/search-dbs.ts b/src/search-dbs.ts index 108dc1d..2eaa5d6 100644 --- a/src/search-dbs.ts +++ b/src/search-dbs.ts @@ -50,6 +50,7 @@ const localeToLangMap: { [key: string]: string } = { th: 'thai', vi: 'vietnamese', zh: 'chinese', + he: 'hebrew', // Default to English for any other locale }; @@ -59,6 +60,7 @@ const SPLITTERS: Record = { thai: /[^a-zA-Z0-9ก-๙]+/gim, vietnamese: /[^a-zA-Z0-9àáâãèéêìíòóôõùúýăđĩũơưạảấầẩẫậắằẳẵặẹẻẽếềễểệỉịọỏốồổỗộớờởỡợụủứừửữựỳỵỷỹ]+/gim, chinese: /[^a-zA-Z0-9\u4e00-\u9fff]+/gim, + hebrew: /[^a-zA-Z0-9\u0590-\u05FF]+/gim, }; function getTokenizer(locale = '') { diff --git a/tests/manager.test.ts b/tests/manager.test.ts index 7057a69..3392628 100644 --- a/tests/manager.test.ts +++ b/tests/manager.test.ts @@ -14,7 +14,7 @@ describe('Manager', () => { beforeEach(async () => { storeDatabase = await createStoreDatabase(); syncDatabase = await createSyncDatabase(); - manager = new Manager(storeDatabase, httpClientMock); + manager = new Manager(storeDatabase, syncDatabase, httpClientMock); }); afterEach(() => {