@lana-commerce/core 13.0.0-alpha.1 → 13.0.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 +10 -2
- package/cjs/graphql/fragments/ProductSearchResult.js +1 -1
- package/cjs/graphql/operations/SearchProductsAdvancedQuery.js +1 -1
- package/cjs/modules/advancedSearch.js +10 -9
- package/esm/graphql/fragments/ProductSearchResult.js +1 -1
- package/esm/graphql/operations/SearchProductsAdvancedQuery.js +1 -1
- package/esm/modules/advancedSearch.js +9 -9
- package/package.json +1 -1
- package/types/graphql/fragments/ProductSearchResult.d.ts +1 -1
- package/types/graphql/types.d.ts +1 -2
- package/types/json/commerceTypes.d.ts +0 -4
- package/types/json/storefrontTypes.d.ts +0 -4
- package/types/modules/advancedSearch.d.ts +2 -3
package/CHANGELOG.md
CHANGED
|
@@ -6,16 +6,24 @@ This project adheres to [Semantic Versioning][semantic versioning].
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
### Major Changes
|
|
10
|
+
### Minor Changes
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
## [Released]
|
|
14
|
+
|
|
15
|
+
## 13.0.0 (2024-08-12)
|
|
16
|
+
|
|
9
17
|
### Major Changes
|
|
10
18
|
|
|
11
19
|
- Autocomplete APIs are removed in favor of "suggest" APIs.
|
|
20
|
+
- Search API pagination no longer supports keyset pagination, offset-based pagination becomes the only option.
|
|
12
21
|
|
|
13
|
-
### Minor Changes
|
|
14
22
|
### Patch Changes
|
|
15
23
|
|
|
16
24
|
- Update how "productFiltering" converts variant options to API search requests.
|
|
17
25
|
|
|
18
|
-
|
|
26
|
+
------------------------------------------------------------------------------------------------------------------
|
|
19
27
|
|
|
20
28
|
## 12.0.0 (2024-07-18)
|
|
21
29
|
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = "fragment ProductSearchResult on StorefrontProductSearchResult{
|
|
3
|
+
exports.default = "fragment ProductSearchResult on StorefrontProductSearchResult{count items{...SearchProduct}options{...ProductSearchOptionAgg}price_max price_min}\n";
|
|
@@ -21,4 +21,4 @@ exports.default = (CommonCartVariant_js_1.default +
|
|
|
21
21
|
TieredPricing_js_1.default +
|
|
22
22
|
TieredPricingTier_js_1.default +
|
|
23
23
|
VariantOption_js_1.default +
|
|
24
|
-
"query SearchProductsAdvanced($shopID:String!$data:[SearchOption!]!$
|
|
24
|
+
"query SearchProductsAdvanced($shopID:String!$data:[SearchOption!]!$offset:Int!$limit:Int!$sortBy:SearchProductsSortBy!$sortDesc:Boolean!$aggregations:Boolean!){search:storefrontSearchProducts(shop_id:$shopID data:$data offset:$offset limit:$limit sort_by:$sortBy sort_desc:$sortDesc aggregations:$aggregations){...ProductSearchResult}}");
|
|
@@ -16,7 +16,7 @@ exports.defaultSearchData = {
|
|
|
16
16
|
options: [],
|
|
17
17
|
priceRange: null,
|
|
18
18
|
count: 0,
|
|
19
|
-
|
|
19
|
+
nextOffset: 0,
|
|
20
20
|
hasMore: false,
|
|
21
21
|
params: null,
|
|
22
22
|
};
|
|
@@ -44,12 +44,12 @@ function createAdvancedSearch(config) {
|
|
|
44
44
|
const loadProducts = (0, effector_1.createEvent)();
|
|
45
45
|
const loadProductsFx = (0, effector_1.createEffect)((params) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
46
46
|
// reset products iteration?
|
|
47
|
-
const
|
|
47
|
+
const offset = (0, dequal_1.dequal)(params.params, params.currentParams) ? params.offset : 0;
|
|
48
48
|
const p = params.params;
|
|
49
49
|
const data = (0, hierarchicalSearchOption_js_1.flattenHierarchicalSearchOptions)([...p.baseFilter, ...p.filter]);
|
|
50
50
|
const agg = p.filter.length === 0; // do we need options aggregation?
|
|
51
51
|
return (0, mapResponseData_js_1.mapResponseData)(yield (0, request_js_1.request)(config.graphql.searchProductsQuery)({
|
|
52
|
-
|
|
52
|
+
offset,
|
|
53
53
|
data,
|
|
54
54
|
limit: p.limit,
|
|
55
55
|
shopID: p.shopID,
|
|
@@ -57,6 +57,7 @@ function createAdvancedSearch(config) {
|
|
|
57
57
|
sortDesc: p.sortDesc,
|
|
58
58
|
aggregations: agg,
|
|
59
59
|
}, config.opts), (d) => {
|
|
60
|
+
var _a, _b;
|
|
60
61
|
const options = d.options.sort((a, b) => {
|
|
61
62
|
return a.name.localeCompare(b.name);
|
|
62
63
|
});
|
|
@@ -71,10 +72,10 @@ function createAdvancedSearch(config) {
|
|
|
71
72
|
options: agg ? options : "keep",
|
|
72
73
|
priceRange: agg ? { min: d.price_min, max: d.price_max } : "keep",
|
|
73
74
|
count: d.count,
|
|
74
|
-
|
|
75
|
-
hasMore:
|
|
75
|
+
nextOffset: offset + ((_b = (_a = d.items) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0),
|
|
76
|
+
hasMore: offset > 0 && products.length === 0 ? false : true,
|
|
76
77
|
params: p,
|
|
77
|
-
mode:
|
|
78
|
+
mode: offset > 0 ? "append" : "replace",
|
|
78
79
|
};
|
|
79
80
|
});
|
|
80
81
|
}));
|
|
@@ -88,7 +89,7 @@ function createAdvancedSearch(config) {
|
|
|
88
89
|
return {
|
|
89
90
|
products,
|
|
90
91
|
count: r.count,
|
|
91
|
-
|
|
92
|
+
nextOffset: r.nextOffset,
|
|
92
93
|
hasMore: r.hasMore && products.length < r.count,
|
|
93
94
|
options: r.options === "keep" ? prevData.options : r.options,
|
|
94
95
|
priceRange: r.priceRange === "keep" ? prevData.priceRange : r.priceRange,
|
|
@@ -101,7 +102,7 @@ function createAdvancedSearch(config) {
|
|
|
101
102
|
const somethingIsPending = (0, combineSome_js_1.combineSome)(loadProductsFx.pending);
|
|
102
103
|
const everythingIdle = somethingIsPending.map((pending) => !pending);
|
|
103
104
|
(0, effector_1.guard)({
|
|
104
|
-
source: (0, effector_1.sample)((0, effector_1.combine)(configWithJWTAndLocale, data), loadProducts, ([config, data], ev) => (Object.assign({ config,
|
|
105
|
+
source: (0, effector_1.sample)((0, effector_1.combine)(configWithJWTAndLocale, data), loadProducts, ([config, data], ev) => (Object.assign({ config, offset: data.nextOffset, currentParams: data.params }, ev))),
|
|
105
106
|
filter: everythingIdle,
|
|
106
107
|
target: loadProductsFx,
|
|
107
108
|
});
|
|
@@ -109,7 +110,7 @@ function createAdvancedSearch(config) {
|
|
|
109
110
|
(0, effector_1.guard)({
|
|
110
111
|
source: (0, effector_1.sample)((0, effector_1.combine)(configWithJWTAndLocale, data), config.locale, ([config, data]) => ({
|
|
111
112
|
config,
|
|
112
|
-
|
|
113
|
+
offset: 0,
|
|
113
114
|
currentParams: null,
|
|
114
115
|
params: data.params,
|
|
115
116
|
})),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export default "fragment ProductSearchResult on StorefrontProductSearchResult{
|
|
1
|
+
export default "fragment ProductSearchResult on StorefrontProductSearchResult{count items{...SearchProduct}options{...ProductSearchOptionAgg}price_max price_min}\n";
|
|
@@ -18,4 +18,4 @@ export default (CommonCartVariant +
|
|
|
18
18
|
TieredPricing +
|
|
19
19
|
TieredPricingTier +
|
|
20
20
|
VariantOption +
|
|
21
|
-
"query SearchProductsAdvanced($shopID:String!$data:[SearchOption!]!$
|
|
21
|
+
"query SearchProductsAdvanced($shopID:String!$data:[SearchOption!]!$offset:Int!$limit:Int!$sortBy:SearchProductsSortBy!$sortDesc:Boolean!$aggregations:Boolean!){search:storefrontSearchProducts(shop_id:$shopID data:$data offset:$offset limit:$limit sort_by:$sortBy sort_desc:$sortDesc aggregations:$aggregations){...ProductSearchResult}}");
|
|
@@ -12,7 +12,7 @@ export const defaultSearchData = {
|
|
|
12
12
|
options: [],
|
|
13
13
|
priceRange: null,
|
|
14
14
|
count: 0,
|
|
15
|
-
|
|
15
|
+
nextOffset: 0,
|
|
16
16
|
hasMore: false,
|
|
17
17
|
params: null,
|
|
18
18
|
};
|
|
@@ -45,12 +45,12 @@ export function createAdvancedSearch(config) {
|
|
|
45
45
|
const loadProducts = createEvent();
|
|
46
46
|
const loadProductsFx = createEffect(async (params) => {
|
|
47
47
|
// reset products iteration?
|
|
48
|
-
const
|
|
48
|
+
const offset = dequal(params.params, params.currentParams) ? params.offset : 0;
|
|
49
49
|
const p = params.params;
|
|
50
50
|
const data = flattenHierarchicalSearchOptions([...p.baseFilter, ...p.filter]);
|
|
51
51
|
const agg = p.filter.length === 0; // do we need options aggregation?
|
|
52
52
|
return mapResponseData(await request(config.graphql.searchProductsQuery)({
|
|
53
|
-
|
|
53
|
+
offset,
|
|
54
54
|
data,
|
|
55
55
|
limit: p.limit,
|
|
56
56
|
shopID: p.shopID,
|
|
@@ -72,10 +72,10 @@ export function createAdvancedSearch(config) {
|
|
|
72
72
|
options: agg ? options : "keep",
|
|
73
73
|
priceRange: agg ? { min: d.price_min, max: d.price_max } : "keep",
|
|
74
74
|
count: d.count,
|
|
75
|
-
|
|
76
|
-
hasMore:
|
|
75
|
+
nextOffset: offset + (d.items?.length ?? 0),
|
|
76
|
+
hasMore: offset > 0 && products.length === 0 ? false : true,
|
|
77
77
|
params: p,
|
|
78
|
-
mode:
|
|
78
|
+
mode: offset > 0 ? "append" : "replace",
|
|
79
79
|
};
|
|
80
80
|
});
|
|
81
81
|
});
|
|
@@ -89,7 +89,7 @@ export function createAdvancedSearch(config) {
|
|
|
89
89
|
return {
|
|
90
90
|
products,
|
|
91
91
|
count: r.count,
|
|
92
|
-
|
|
92
|
+
nextOffset: r.nextOffset,
|
|
93
93
|
hasMore: r.hasMore && products.length < r.count,
|
|
94
94
|
options: r.options === "keep" ? prevData.options : r.options,
|
|
95
95
|
priceRange: r.priceRange === "keep" ? prevData.priceRange : r.priceRange,
|
|
@@ -104,7 +104,7 @@ export function createAdvancedSearch(config) {
|
|
|
104
104
|
guard({
|
|
105
105
|
source: sample(combine(configWithJWTAndLocale, data), loadProducts, ([config, data], ev) => ({
|
|
106
106
|
config,
|
|
107
|
-
|
|
107
|
+
offset: data.nextOffset,
|
|
108
108
|
currentParams: data.params,
|
|
109
109
|
...ev,
|
|
110
110
|
})),
|
|
@@ -115,7 +115,7 @@ export function createAdvancedSearch(config) {
|
|
|
115
115
|
guard({
|
|
116
116
|
source: sample(combine(configWithJWTAndLocale, data), config.locale, ([config, data]) => ({
|
|
117
117
|
config,
|
|
118
|
-
|
|
118
|
+
offset: 0,
|
|
119
119
|
currentParams: null,
|
|
120
120
|
params: data.params,
|
|
121
121
|
})),
|
package/package.json
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "fragment ProductSearchResult on StorefrontProductSearchResult{
|
|
1
|
+
declare const _default: "fragment ProductSearchResult on StorefrontProductSearchResult{count items{...SearchProduct}options{...ProductSearchOptionAgg}price_max price_min}\n";
|
|
2
2
|
export default _default;
|
package/types/graphql/types.d.ts
CHANGED
|
@@ -1177,7 +1177,6 @@ export interface ProductSearchOptionAggFragment {
|
|
|
1177
1177
|
export interface ProductSearchResultFragment {
|
|
1178
1178
|
count: number;
|
|
1179
1179
|
items: Array<SearchProductFragment | null> | null;
|
|
1180
|
-
last_key: string;
|
|
1181
1180
|
options: Array<ProductSearchOptionAggFragment>;
|
|
1182
1181
|
price_max: number;
|
|
1183
1182
|
price_min: number;
|
|
@@ -2236,8 +2235,8 @@ export interface SearchProductsAdvancedQuery {
|
|
|
2236
2235
|
export interface SearchProductsAdvancedQueryVariables {
|
|
2237
2236
|
aggregations: boolean;
|
|
2238
2237
|
data: Array<SearchOption>;
|
|
2239
|
-
lastKey: string;
|
|
2240
2238
|
limit: number;
|
|
2239
|
+
offset: number;
|
|
2241
2240
|
shopID: string;
|
|
2242
2241
|
sortBy: SearchProductsSortBy;
|
|
2243
2242
|
sortDesc: boolean;
|
|
@@ -5172,8 +5172,6 @@ export interface ProductSearchResult {
|
|
|
5172
5172
|
items: Array<{
|
|
5173
5173
|
id: string;
|
|
5174
5174
|
} | Product | null>;
|
|
5175
|
-
/** Key of the last item for keyset based iteration */
|
|
5176
|
-
last_key: string;
|
|
5177
5175
|
/** Options aggregation */
|
|
5178
5176
|
options: Array<ProductSearchOptionAgg>;
|
|
5179
5177
|
/** Maximum price for given search conditions */
|
|
@@ -13488,8 +13486,6 @@ export interface EndpointSearchOrders extends Endpoint<EndpointSearchOrders, Ord
|
|
|
13488
13486
|
export interface EndpointSearchProducts extends Endpoint<EndpointSearchProducts, ProductSearchResult> {
|
|
13489
13487
|
/** Whether to include aggregations into results or not */
|
|
13490
13488
|
aggregations(v: boolean): EndpointSearchProducts;
|
|
13491
|
-
/** Key of the last item from previous page. See also: [Pagination](/overview/concepts/pagination) */
|
|
13492
|
-
last_key(v: string): EndpointSearchProducts;
|
|
13493
13489
|
/** Return up to N entries (pagination). See also: [Pagination](/overview/concepts/pagination) */
|
|
13494
13490
|
limit(v: number): EndpointSearchProducts;
|
|
13495
13491
|
/** Skip N entries (pagination). See also: [Pagination](/overview/concepts/pagination) */
|
|
@@ -2390,8 +2390,6 @@ export interface StorefrontProductSearchResult {
|
|
|
2390
2390
|
items: Array<{
|
|
2391
2391
|
id: string;
|
|
2392
2392
|
} | StorefrontProduct | null>;
|
|
2393
|
-
/** Key of the last item for keyset based iteration */
|
|
2394
|
-
last_key: string;
|
|
2395
2393
|
/** Options aggregation */
|
|
2396
2394
|
options: Array<ProductSearchOptionAgg>;
|
|
2397
2395
|
/** Maximum price for given search conditions */
|
|
@@ -4659,8 +4657,6 @@ export interface EndpointStorefrontReviewDimensions extends Endpoint<EndpointSto
|
|
|
4659
4657
|
export interface EndpointStorefrontSearchProducts extends Endpoint<EndpointStorefrontSearchProducts, StorefrontProductSearchResult> {
|
|
4660
4658
|
/** Whether to include aggregations into results or not */
|
|
4661
4659
|
aggregations(v: boolean): EndpointStorefrontSearchProducts;
|
|
4662
|
-
/** Key of the last item from previous page. See also: [Pagination](/overview/concepts/pagination) */
|
|
4663
|
-
last_key(v: string): EndpointStorefrontSearchProducts;
|
|
4664
4660
|
/** Return up to N entries (pagination). See also: [Pagination](/overview/concepts/pagination) */
|
|
4665
4661
|
limit(v: number): EndpointStorefrontSearchProducts;
|
|
4666
4662
|
/** Skip N entries (pagination). See also: [Pagination](/overview/concepts/pagination) */
|
|
@@ -20,7 +20,7 @@ export interface SearchData<Product> {
|
|
|
20
20
|
max: number;
|
|
21
21
|
} | null;
|
|
22
22
|
count: number;
|
|
23
|
-
|
|
23
|
+
nextOffset: number;
|
|
24
24
|
hasMore: boolean;
|
|
25
25
|
params: ProductsPageQueryParameters | null;
|
|
26
26
|
}
|
|
@@ -45,7 +45,6 @@ export interface AdvancedSearchConfig<Product> {
|
|
|
45
45
|
search: {
|
|
46
46
|
count: number;
|
|
47
47
|
items: Array<Product | null> | null;
|
|
48
|
-
last_key: string;
|
|
49
48
|
options: Array<OptionAgg>;
|
|
50
49
|
price_max: number;
|
|
51
50
|
price_min: number;
|
|
@@ -53,7 +52,7 @@ export interface AdvancedSearchConfig<Product> {
|
|
|
53
52
|
}, {
|
|
54
53
|
aggregations: boolean;
|
|
55
54
|
data: Array<SearchOption>;
|
|
56
|
-
|
|
55
|
+
offset: number;
|
|
57
56
|
limit: number;
|
|
58
57
|
shopID: string;
|
|
59
58
|
sortBy: SearchProductsSortBy;
|