@scayle/storefront-core 7.46.1 → 7.47.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/CHANGELOG.md +6 -0
- package/dist/constants/withParameters.d.ts +1 -4
- package/dist/rpc/methods/search.cjs +34 -1
- package/dist/rpc/methods/search.d.ts +4 -0
- package/dist/rpc/methods/search.mjs +21 -0
- package/dist/types/api/context.d.ts +2 -1
- package/dist/types/bapi/search.d.ts +4 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import type { BasketWith } from '
|
|
2
|
-
import type { ProductWith } from '@aboutyou/backbone/types/ProductWith';
|
|
3
|
-
import type { WishlistWith } from '@aboutyou/backbone/endpoints/wishlist/getWishlist';
|
|
4
|
-
import { SearchWith } from '../types';
|
|
1
|
+
import type { SearchWith, BasketWith, ProductWith, WishlistWith } from '../types';
|
|
5
2
|
declare const DEFAULT_WITH_LISTING: {
|
|
6
3
|
items: {
|
|
7
4
|
product: {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.searchProducts = void 0;
|
|
6
|
+
exports.searchProducts = exports.resolveSearch = exports.getSearchSuggestions = void 0;
|
|
7
7
|
var _constants = require("../../constants/index.cjs");
|
|
8
8
|
var _stringHelpers = require("../../helpers/stringHelpers.cjs");
|
|
9
9
|
const searchProducts = exports.searchProducts = async function searchProducts2({
|
|
@@ -25,6 +25,39 @@ const searchProducts = exports.searchProducts = async function searchProducts2({
|
|
|
25
25
|
with: _with ?? withParams?.search ?? _constants.MIN_WITH_PARAMS_SEARCH
|
|
26
26
|
});
|
|
27
27
|
};
|
|
28
|
+
const getSearchSuggestions = exports.getSearchSuggestions = async function getSearchSuggestions2({
|
|
29
|
+
term,
|
|
30
|
+
with: _with,
|
|
31
|
+
categoryId
|
|
32
|
+
}, {
|
|
33
|
+
bapiClient,
|
|
34
|
+
withParams
|
|
35
|
+
}) {
|
|
36
|
+
return await bapiClient.searchv2.suggestions(term, {
|
|
37
|
+
categoryId,
|
|
38
|
+
with: _with ?? withParams?.searchV2
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
const resolveSearch = exports.resolveSearch = async function resolveSearch2({
|
|
42
|
+
term,
|
|
43
|
+
with: _with,
|
|
44
|
+
categoryId
|
|
45
|
+
}, {
|
|
46
|
+
cached,
|
|
47
|
+
bapiClient,
|
|
48
|
+
withParams
|
|
49
|
+
}) {
|
|
50
|
+
const resolvedEntity = await cached(bapiClient.searchv2.resolve, {
|
|
51
|
+
cacheKeyPrefix: `resolve-${term}`
|
|
52
|
+
})(term, {
|
|
53
|
+
categoryId,
|
|
54
|
+
with: _with ?? withParams?.searchV2
|
|
55
|
+
});
|
|
56
|
+
if (!resolvedEntity) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
return resolvedEntity;
|
|
60
|
+
};
|
|
28
61
|
const getCategoryId = async (cached, bapiClient, slug) => {
|
|
29
62
|
if (!slug) {
|
|
30
63
|
return;
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import type { TypeaheadSuggestionsEndpointRequestParameters, TypeaheadSuggestionsEndpointResponseData } from '@aboutyou/backbone/endpoints/typeahead/typeahead';
|
|
2
|
+
import type { SearchV2ResolveEndpointParameters, SearchV2SuggestionsEndpointResponseData, SearchV2SuggestionsEndpointParameters } from '../../types/bapi/search';
|
|
2
3
|
type SearchWith = TypeaheadSuggestionsEndpointRequestParameters['with'];
|
|
4
|
+
/** @deprecated `searchProducts` is deprecated. Please, use `getSuggestions` or `resolve` RPC methods */
|
|
3
5
|
export declare const searchProducts: ({ term, slug, with: _with, productLimit }: {
|
|
4
6
|
term: string;
|
|
5
7
|
slug?: string | undefined;
|
|
6
8
|
with?: SearchWith;
|
|
7
9
|
productLimit?: number | undefined;
|
|
8
10
|
}, { cached, bapiClient, withParams }: import("../../types").RpcContext) => Promise<TypeaheadSuggestionsEndpointResponseData>;
|
|
11
|
+
export declare const getSearchSuggestions: ({ term, with: _with, categoryId }: SearchV2SuggestionsEndpointParameters, { bapiClient, withParams }: import("../../types").RpcContext) => Promise<SearchV2SuggestionsEndpointResponseData>;
|
|
12
|
+
export declare const resolveSearch: ({ term, with: _with, categoryId }: SearchV2ResolveEndpointParameters, { cached, bapiClient, withParams }: import("../../types").RpcContext) => Promise<import("@aboutyou/backbone/types/Search").SearchEntity | null>;
|
|
9
13
|
export {};
|
|
@@ -10,6 +10,27 @@ export const searchProducts = async function searchProducts2({ term, slug, with:
|
|
|
10
10
|
with: _with ?? withParams?.search ?? MIN_WITH_PARAMS_SEARCH
|
|
11
11
|
});
|
|
12
12
|
};
|
|
13
|
+
export const getSearchSuggestions = async function getSearchSuggestions2({ term, with: _with, categoryId }, { bapiClient, withParams }) {
|
|
14
|
+
return await bapiClient.searchv2.suggestions(
|
|
15
|
+
term,
|
|
16
|
+
{
|
|
17
|
+
categoryId,
|
|
18
|
+
with: _with ?? withParams?.searchV2
|
|
19
|
+
}
|
|
20
|
+
);
|
|
21
|
+
};
|
|
22
|
+
export const resolveSearch = async function resolveSearch2({ term, with: _with, categoryId }, { cached, bapiClient, withParams }) {
|
|
23
|
+
const resolvedEntity = await cached(bapiClient.searchv2.resolve, {
|
|
24
|
+
cacheKeyPrefix: `resolve-${term}`
|
|
25
|
+
})(term, {
|
|
26
|
+
categoryId,
|
|
27
|
+
with: _with ?? withParams?.searchV2
|
|
28
|
+
});
|
|
29
|
+
if (!resolvedEntity) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
return resolvedEntity;
|
|
33
|
+
};
|
|
13
34
|
const getCategoryId = async (cached, bapiClient, slug) => {
|
|
14
35
|
if (!slug) {
|
|
15
36
|
return;
|
|
@@ -2,7 +2,7 @@ import type { BapiClient } from '@aboutyou/backbone';
|
|
|
2
2
|
import type { Log } from '../../utils';
|
|
3
3
|
import type { CachedType } from '../../cache/cached';
|
|
4
4
|
import type { ShopUser } from '../user';
|
|
5
|
-
import type { WishlistWithOptions, BasketWithOptions, ProductWith, VariantWith, SearchWith, CategoryWith, ProductCategoryWith } from '../';
|
|
5
|
+
import type { WishlistWithOptions, BasketWithOptions, ProductWith, VariantWith, SearchWith, SearchV2With, CategoryWith, ProductCategoryWith } from '../';
|
|
6
6
|
import { OAuthTokens, IDPConfig } from './auth';
|
|
7
7
|
export type WithParams = Partial<{
|
|
8
8
|
basket: BasketWithOptions;
|
|
@@ -11,6 +11,7 @@ export type WithParams = Partial<{
|
|
|
11
11
|
productCategory: ProductCategoryWith;
|
|
12
12
|
category: CategoryWith;
|
|
13
13
|
search: SearchWith;
|
|
14
|
+
searchV2: SearchV2With;
|
|
14
15
|
variant: VariantWith;
|
|
15
16
|
}>;
|
|
16
17
|
export interface RuntimeConfiguration {
|
|
@@ -2,6 +2,10 @@ import type { ProductWith } from '@aboutyou/backbone/types/ProductWith';
|
|
|
2
2
|
import type { TypeaheadSuggestionsEndpointRequestParameters } from '@aboutyou/backbone/endpoints/typeahead/typeahead';
|
|
3
3
|
import { Query } from '../index';
|
|
4
4
|
export type { BrandOrCategorySuggestion, ProductSuggestion, TypeaheadSuggestion, TypeaheadBrandOrCategorySuggestion, TypeaheadProductSuggestion, TypeaheadSuggestionsEndpointResponseData, } from '@aboutyou/backbone/endpoints/typeahead/typeahead';
|
|
5
|
+
export type { SearchV2With } from '@aboutyou/backbone/endpoints/searchv2/includes';
|
|
6
|
+
export type { SearchV2SuggestionsEndpointResponseData, SearchV2SuggestionsEndpointParameters, } from '@aboutyou/backbone/endpoints/searchv2/suggestions';
|
|
7
|
+
export type { SearchV2ResolveEndpointResponseData, SearchV2ResolveEndpointParameters, } from '@aboutyou/backbone/endpoints/searchv2/resolve';
|
|
8
|
+
export type * from '@aboutyou/backbone/types/Search';
|
|
5
9
|
export type SearchInput = {
|
|
6
10
|
term?: Query;
|
|
7
11
|
slug?: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scayle/storefront-core",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.47.0",
|
|
4
4
|
"description": "Collection of essential utilities to work with the Storefront API",
|
|
5
5
|
"author": "SCAYLE Commerce Engine",
|
|
6
6
|
"license": "MIT",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"devDependencies": {
|
|
72
72
|
"@scayle/eslint-config-storefront": "3.2.6",
|
|
73
73
|
"@types/crypto-js": "4.2.2",
|
|
74
|
-
"@types/node": "20.
|
|
74
|
+
"@types/node": "20.12.3",
|
|
75
75
|
"@types/webpack-env": "1.18.4",
|
|
76
76
|
"@vitest/coverage-v8": "1.4.0",
|
|
77
77
|
"dprint": "0.45.0",
|