@stoker-platform/web-app 0.5.12 → 0.5.13

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @stoker-platform/web-app
2
2
 
3
+ ## 0.5.13
4
+
5
+ ### Patch Changes
6
+
7
+ - feat: do not tokenize local full text search
8
+
3
9
  ## 0.5.12
4
10
 
5
11
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stoker-platform/web-app",
3
- "version": "0.5.12",
3
+ "version": "0.5.13",
4
4
  "type": "module",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "scripts": {
@@ -1,17 +1,17 @@
1
1
  import { CollectionSchema, StokerRecord } from "@stoker-platform/types"
2
- import MiniSearch, { SearchResult } from "minisearch"
2
+ import MiniSearch, { Options, SearchResult } from "minisearch"
3
3
 
4
4
  export const localFullTextSearch = (
5
5
  collection: CollectionSchema,
6
6
  query: string,
7
7
  list: StokerRecord[],
8
8
  filter?: (result: SearchResult) => boolean,
9
+ tokenize?: boolean,
9
10
  ) => {
10
11
  const { recordTitleField, fullTextSearch } = collection
11
- const miniSearch = new MiniSearch({
12
+ const miniSearchConfig: Options = {
12
13
  fields: fullTextSearch || [recordTitleField],
13
14
  storeFields: fullTextSearch || [recordTitleField],
14
- tokenize: (string) => [string],
15
15
  searchOptions: {
16
16
  ...(collection.searchOptions || {
17
17
  fuzzy: 0.2,
@@ -19,7 +19,11 @@ export const localFullTextSearch = (
19
19
  }),
20
20
  filter,
21
21
  },
22
- })
22
+ }
23
+ if (tokenize) {
24
+ miniSearchConfig.tokenize = (string) => [string]
25
+ }
26
+ const miniSearch = new MiniSearch(miniSearchConfig)
23
27
  // eslint-disable-next-line security/detect-object-injection
24
28
  miniSearch.addAll(list)
25
29
  const results = miniSearch.search(query)