@nosto/search-js 2.0.0 → 2.1.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/README.md +50 -8
- package/dist/core/core.d.ts +1 -1
- package/dist/core/src/search.d.ts +2 -2
- package/dist/core/src/searchWithRetries.d.ts +2 -2
- package/dist/core/src/types.d.ts +2 -2
- package/dist/preact/src/actions/newSearch.d.ts +2 -2
- package/dist/preact/src/actions/updateSearch.d.ts +2 -2
- package/dist/preact/src/config/base/baseConfig.d.ts +2 -2
- package/dist/preact/src/config/pages/autocomplete/config.d.ts +1 -1
- package/dist/preact/src/config/pages/category/config.d.ts +1 -1
- package/dist/preact/src/config/pages/serp/config.d.ts +1 -1
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
# Search JS
|
|
2
2
|
|
|
3
|
-
Search JS is
|
|
4
|
-
* Nosto currency formatting
|
|
5
|
-
* Nosto product thumbnails
|
|
6
|
-
* Retry logic
|
|
3
|
+
Nosto Search JS is an implementation of Nosto Search. In addition to the base search functionality, it also provides the following features:
|
|
7
4
|
|
|
5
|
+
* **Currency formatting**: Format prices based on Nosto settings.
|
|
6
|
+
* **Product thumbnails**: Thumbnail resizing.
|
|
7
|
+
* **Retry logic**: Retry failed search queries automatically.
|
|
8
|
+
* **Preact components**: Build modern search interfaces.
|
|
9
|
+
* **Autocomplete**: Fast and responsive autocomplete tools.
|
|
10
|
+
* **Category search**: Display and filter by categories.
|
|
11
|
+
* **SERPs**: Build search result pages with sorting and pagination.
|
|
12
|
+
* **Utilities**: Helpers for common tasks like array or object merging and equality checks.
|
|
13
|
+
* **Infinite scroll**: Loads more components upon scrolling to the end of results.
|
|
14
|
+
|
|
8
15
|
## Installation
|
|
9
|
-
|
|
10
16
|
To install the package, use your preferred package manager:
|
|
11
17
|
|
|
12
18
|
```bash
|
|
@@ -22,7 +28,43 @@ Read [Nosto Techdocs](https://docs.nosto.com/techdocs/apis/frontend/oss/search-j
|
|
|
22
28
|
[Library TypeDoc page](https://nosto.github.io/search-js/) includes detailed library helpers documentation and examples.
|
|
23
29
|
|
|
24
30
|
## Packages
|
|
25
|
-
### `preact/legacy`
|
|
26
|
-
The `preact/legacy` package is designed to provide backward compatibility for existing Search Template implementations. It serves as a bridge to support legacy functionality.
|
|
27
31
|
|
|
28
|
-
|
|
32
|
+
### `core`
|
|
33
|
+
The `core` package provides the foundational functionality for interacting with Nosto Search. It includes utilities for managing search queries, applying decorators, and handling search results.
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
### `currencies`
|
|
38
|
+
The `currencies` package provides utilities for formatting monetary values and decorating search results with price information.
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
### `preact` packages
|
|
43
|
+
|
|
44
|
+
#### `preact/autocomplete`
|
|
45
|
+
The `preact/autocomplete` package helps you add autocomplete functionality to your search interface.
|
|
46
|
+
|
|
47
|
+
#### `preact/category`
|
|
48
|
+
The `preact/category` package provides tools to show and interact with category-based search results.
|
|
49
|
+
|
|
50
|
+
#### `preact/common`
|
|
51
|
+
The `preact/common` package includes shared components that are used across other `preact` packages.
|
|
52
|
+
|
|
53
|
+
#### `preact/hooks`
|
|
54
|
+
The `preact/hooks` package offers hooks to manage state and actions in your search app.
|
|
55
|
+
|
|
56
|
+
#### `preact/serp`
|
|
57
|
+
The `preact/serp` package provides tools to create Search Engine Results Pages (SERPs) with features like pagination, sorting, and displaying results.
|
|
58
|
+
|
|
59
|
+
#### `preact/legacy`
|
|
60
|
+
The `preact/legacy` package is designed to provide backward compatibility for existing Search Template implementations.
|
|
61
|
+
|
|
62
|
+
> The components included in this package are intended solely for compatibility purposes. They are not recommended for use in new development or as active components in modern applications.
|
|
63
|
+
|
|
64
|
+
### `thumbnails`
|
|
65
|
+
The `thumbnails` package helps you resize thumbnails. It supports different formats, including Shopify and Nosto-specific ones.
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
### `utils`
|
|
70
|
+
The `utils` package includes handy tools for common tasks like array or object merging, checking equality, and generating unique values.
|
package/dist/core/core.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/** @module ./ */
|
|
2
2
|
export { addToCart, type SearchHitWithSku } from './src/addToCart';
|
|
3
3
|
export { search } from './src/search';
|
|
4
|
-
export type { DecoratedProduct, DecoratedResult, HitDecorator,
|
|
4
|
+
export type { DecoratedProduct, DecoratedResult, HitDecorator, SearchOptions, ToIntersection } from './src/types';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SearchQuery } from '@nosto/nosto-js/client';
|
|
2
|
-
import { HitDecorator,
|
|
2
|
+
import { HitDecorator, SearchOptions } from './types';
|
|
3
3
|
/**
|
|
4
4
|
* Performs a search operation using the provided query and options.
|
|
5
5
|
*
|
|
@@ -7,7 +7,7 @@ import { HitDecorator, Options } from './types';
|
|
|
7
7
|
* @param options - An object containing optional parameters for the search.
|
|
8
8
|
* @returns A promise that resolves to the search result.
|
|
9
9
|
*/
|
|
10
|
-
export declare function search<HD extends readonly HitDecorator[]>(query: SearchQuery, options?:
|
|
10
|
+
export declare function search<HD extends readonly HitDecorator[]>(query: SearchQuery, options?: SearchOptions<HD>): Promise<{
|
|
11
11
|
products: {
|
|
12
12
|
hits: import('./types').ToIntersection<ReturnType<HD[number]>>[];
|
|
13
13
|
categoryId?: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { API, SearchQuery, SearchResult } from '@nosto/nosto-js/client';
|
|
2
|
-
import {
|
|
3
|
-
export declare function searchWithRetries(api: API, query: SearchQuery, options:
|
|
2
|
+
import { SearchOptions } from './types';
|
|
3
|
+
export declare function searchWithRetries(api: API, query: SearchQuery, options: SearchOptions<[]>): Promise<SearchResult>;
|
|
4
4
|
/**
|
|
5
5
|
* Should the error trigger a search retry
|
|
6
6
|
*/
|
package/dist/core/src/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { SearchOptions, SearchProduct, SearchResult } from '@nosto/nosto-js/client';
|
|
2
|
-
export type
|
|
1
|
+
import { SearchOptions as BaseOptions, SearchProduct, SearchResult } from '@nosto/nosto-js/client';
|
|
2
|
+
export type SearchOptions<HD extends readonly HitDecorator[] = readonly HitDecorator[]> = BaseOptions & {
|
|
3
3
|
/**
|
|
4
4
|
* Hit decorators to apply to the search results.
|
|
5
5
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SearchOptions } from '../../../core/src/types';
|
|
2
2
|
import { SearchQuery } from '@nosto/nosto-js/client';
|
|
3
3
|
import { ActionContext } from './types';
|
|
4
|
-
export declare function newSearch(context: ActionContext, query: SearchQuery, options?:
|
|
4
|
+
export declare function newSearch(context: ActionContext, query: SearchQuery, options?: SearchOptions): Promise<void>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SearchOptions } from '../../../core/src/types';
|
|
2
2
|
import { SearchQuery } from '@nosto/nosto-js/client';
|
|
3
3
|
import { ActionContext } from './types';
|
|
4
|
-
export declare function updateSearch(context: ActionContext, query: SearchQuery, options?:
|
|
4
|
+
export declare function updateSearch(context: ActionContext, query: SearchQuery, options?: SearchOptions): Promise<void>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SearchOptions } from '../../../../core/src/types';
|
|
2
2
|
import { SearchQuery } from '@nosto/nosto-js/client';
|
|
3
3
|
import { PageType } from '../../api/types';
|
|
4
4
|
export declare const defaultBaseConfig: {
|
|
@@ -13,7 +13,7 @@ export interface BaseConfig {
|
|
|
13
13
|
/**
|
|
14
14
|
* Configuration for the search queries
|
|
15
15
|
*/
|
|
16
|
-
search?:
|
|
16
|
+
search?: SearchOptions;
|
|
17
17
|
/**
|
|
18
18
|
* Custom function, when provided, can be used to modify search query before sending it to the server.
|
|
19
19
|
* A default implementation is provided in the config that returns the query without any modification.
|
|
@@ -8,7 +8,7 @@ export interface AutocompleteConfig extends BaseConfig {
|
|
|
8
8
|
}
|
|
9
9
|
export type PublicAutocompleteConfig = Omit<AutocompleteConfig, keyof typeof defaultAutocompleteConfig | "pageType"> & Partial<Pick<AutocompleteConfig, keyof typeof defaultAutocompleteConfig>>;
|
|
10
10
|
export declare function makeAutocompleteConfig(config: PublicAutocompleteConfig): {
|
|
11
|
-
search?: import('../../../../../core/src/types').
|
|
11
|
+
search?: import('../../../../../core/src/types').SearchOptions | undefined;
|
|
12
12
|
defaultCurrency: string;
|
|
13
13
|
queryModifications: (query: import('@nosto/nosto-js/client').SearchQuery, pageType: import('../../../api/types').PageType | undefined) => import('@nosto/nosto-js/client').SearchQuery;
|
|
14
14
|
pageType: "autocomplete";
|
|
@@ -33,7 +33,7 @@ export interface CategoryConfig extends BaseConfig {
|
|
|
33
33
|
}
|
|
34
34
|
export type PublicCategoryConfig = Omit<CategoryConfig, keyof typeof defaultCategoryConfig | "pageType"> & Partial<Pick<CategoryConfig, keyof typeof defaultCategoryConfig>>;
|
|
35
35
|
export declare function makeCategoryConfig(config: PublicCategoryConfig): {
|
|
36
|
-
search?: import('../../../../../core/src/types').
|
|
36
|
+
search?: import('../../../../../core/src/types').SearchOptions | undefined;
|
|
37
37
|
categoryId: () => string;
|
|
38
38
|
categoryPath: () => string;
|
|
39
39
|
defaultCurrency: string;
|
|
@@ -25,7 +25,7 @@ export interface SerpConfig extends BaseConfig {
|
|
|
25
25
|
}
|
|
26
26
|
export type PublicSerpConfig = Omit<SerpConfig, keyof typeof defaultSerpConfig | "pageType"> & Partial<Pick<SerpConfig, keyof typeof defaultSerpConfig>>;
|
|
27
27
|
export declare function makeSerpConfig(config?: PublicSerpConfig): {
|
|
28
|
-
search?: import('../../../../../core/src/types').
|
|
28
|
+
search?: import('../../../../../core/src/types').SearchOptions | undefined;
|
|
29
29
|
defaultCurrency: string;
|
|
30
30
|
queryModifications: (query: import('@nosto/nosto-js/client').SearchQuery, pageType: import('../../../api/types').PageType | undefined) => import('@nosto/nosto-js/client').SearchQuery;
|
|
31
31
|
persistentSearchCache: boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nosto/search-js",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"license": "ISC",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -84,13 +84,13 @@
|
|
|
84
84
|
"prepare": "husky"
|
|
85
85
|
},
|
|
86
86
|
"devDependencies": {
|
|
87
|
-
"@nosto/nosto-js": "^
|
|
87
|
+
"@nosto/nosto-js": "^2.0.0",
|
|
88
88
|
"@testing-library/dom": "^10.4.0",
|
|
89
89
|
"@types/eslint-config-prettier": "^6.11.3",
|
|
90
90
|
"@types/node": "^22.14.1",
|
|
91
91
|
"concurrently": "^9.1.2",
|
|
92
92
|
"copyfiles": "^2.4.1",
|
|
93
|
-
"eslint": "^9.
|
|
93
|
+
"eslint": "^9.25.0",
|
|
94
94
|
"eslint-config-prettier": "^10.1.2",
|
|
95
95
|
"eslint-plugin-barrel-files": "^3.0.1",
|
|
96
96
|
"eslint-plugin-prettier": "^5.2.6",
|
|
@@ -102,12 +102,12 @@
|
|
|
102
102
|
"isbot": "^5.1.26",
|
|
103
103
|
"jsdom": "^26.1.0",
|
|
104
104
|
"prettier": "^3.5.3",
|
|
105
|
-
"typedoc": "^0.28.
|
|
105
|
+
"typedoc": "^0.28.3",
|
|
106
106
|
"typescript": "^5.8.3",
|
|
107
|
-
"typescript-eslint": "^8.30.
|
|
108
|
-
"vite": "^6.2
|
|
107
|
+
"typescript-eslint": "^8.30.1",
|
|
108
|
+
"vite": "^6.3.2",
|
|
109
109
|
"vite-plugin-dts": "^4.5.3",
|
|
110
|
-
"vitest": "^3.1.
|
|
110
|
+
"vitest": "^3.1.2",
|
|
111
111
|
"@commitlint/cli": "^19.8.0",
|
|
112
112
|
"@commitlint/config-conventional": "^19.8.0"
|
|
113
113
|
},
|