@scayle/storefront-core 8.4.0 → 8.6.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 +40 -0
- package/dist/constants/index.d.ts +0 -1
- package/dist/constants/index.mjs +0 -1
- package/dist/helpers/filterHelper.d.ts +11 -11
- package/dist/helpers/sortingHelper.d.ts +22 -23
- package/dist/helpers/sortingHelper.mjs +11 -11
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +6 -0
- package/dist/rpc/methods/basket/basket.d.ts +1 -1
- package/dist/rpc/methods/basket/basket.mjs +3 -3
- package/dist/rpc/methods/checkout/checkout.mjs +1 -1
- package/dist/rpc/methods/search.d.ts +22 -0
- package/dist/utils/basket.mjs +2 -2
- package/dist/utils/user.d.ts +3 -3
- package/dist/utils/user.mjs +2 -2
- package/package.json +9 -24
- package/dist/api/customer.cjs +0 -164
- package/dist/api/oauth.cjs +0 -238
- package/dist/cache/cache.cjs +0 -1
- package/dist/cache/cached.cjs +0 -90
- package/dist/cache/index.cjs +0 -27
- package/dist/cache/providers/unstorage.cjs +0 -55
- package/dist/constants/basket.cjs +0 -26
- package/dist/constants/basket.d.ts +0 -24
- package/dist/constants/basket.mjs +0 -20
- package/dist/constants/cache.cjs +0 -7
- package/dist/constants/hash.cjs +0 -11
- package/dist/constants/httpStatus.cjs +0 -634
- package/dist/constants/index.cjs +0 -93
- package/dist/constants/product.cjs +0 -10
- package/dist/constants/promotion.cjs +0 -12
- package/dist/constants/sorting.cjs +0 -22
- package/dist/constants/withParameters.cjs +0 -132
- package/dist/errors/errorResponse.cjs +0 -27
- package/dist/errors/index.cjs +0 -16
- package/dist/helpers/advancedAttributeHelpers.cjs +0 -30
- package/dist/helpers/arrayHelpers.cjs +0 -10
- package/dist/helpers/attributeHelpers.cjs +0 -24
- package/dist/helpers/basketHelpers.cjs +0 -12
- package/dist/helpers/categoryHelper.cjs +0 -61
- package/dist/helpers/filterHelper.cjs +0 -185
- package/dist/helpers/formHelpers.cjs +0 -114
- package/dist/helpers/imageHelpers.cjs +0 -20
- package/dist/helpers/index.cjs +0 -181
- package/dist/helpers/localization.cjs +0 -13
- package/dist/helpers/objectHelpers.cjs +0 -19
- package/dist/helpers/orderHelpers.cjs +0 -10
- package/dist/helpers/product.fixture.cjs +0 -766
- package/dist/helpers/productDisruptorHelper.cjs +0 -37
- package/dist/helpers/productHelpers.cjs +0 -156
- package/dist/helpers/sanitizationHelpers.cjs +0 -35
- package/dist/helpers/sortingHelper.cjs +0 -68
- package/dist/helpers/stringHelpers.cjs +0 -8
- package/dist/index.cjs +0 -100
- package/dist/rpc/methods/basket/basket.cjs +0 -270
- package/dist/rpc/methods/brands.cjs +0 -33
- package/dist/rpc/methods/categories.cjs +0 -129
- package/dist/rpc/methods/cbd.cjs +0 -38
- package/dist/rpc/methods/checkout/checkout.cjs +0 -48
- package/dist/rpc/methods/checkout/index.cjs +0 -49
- package/dist/rpc/methods/checkout/order.cjs +0 -42
- package/dist/rpc/methods/checkout/shopUser.cjs +0 -110
- package/dist/rpc/methods/checkout/shopUserAddresses.cjs +0 -12
- package/dist/rpc/methods/index.cjs +0 -225
- package/dist/rpc/methods/navigationTrees.cjs +0 -54
- package/dist/rpc/methods/oauth/idp.cjs +0 -59
- package/dist/rpc/methods/products.cjs +0 -309
- package/dist/rpc/methods/promotion.cjs +0 -51
- package/dist/rpc/methods/search.cjs +0 -40
- package/dist/rpc/methods/session.cjs +0 -257
- package/dist/rpc/methods/shopConfiguration.cjs +0 -15
- package/dist/rpc/methods/user.cjs +0 -103
- package/dist/rpc/methods/variants.cjs +0 -29
- package/dist/rpc/methods/wishlist.cjs +0 -104
- package/dist/server.cjs +0 -47
- package/dist/test/factories/index.cjs +0 -16
- package/dist/types/api/auth.cjs +0 -1
- package/dist/types/api/context.cjs +0 -15
- package/dist/types/api/rpc.cjs +0 -1
- package/dist/types/breadcrumb.cjs +0 -1
- package/dist/types/index.cjs +0 -267
- package/dist/types/promises.cjs +0 -1
- package/dist/types/sapi/basket.cjs +0 -1
- package/dist/types/sapi/brand.cjs +0 -1
- package/dist/types/sapi/campaign.cjs +0 -1
- package/dist/types/sapi/category.cjs +0 -1
- package/dist/types/sapi/filter.cjs +0 -1
- package/dist/types/sapi/navigation.cjs +0 -1
- package/dist/types/sapi/order.cjs +0 -1
- package/dist/types/sapi/product.cjs +0 -1
- package/dist/types/sapi/productFilter.cjs +0 -1
- package/dist/types/sapi/promotion.cjs +0 -1
- package/dist/types/sapi/redirects.cjs +0 -1
- package/dist/types/sapi/router.cjs +0 -1
- package/dist/types/sapi/search.cjs +0 -1
- package/dist/types/sapi/sorting.cjs +0 -1
- package/dist/types/sapi/variant.cjs +0 -1
- package/dist/types/sapi/wishlist.cjs +0 -1
- package/dist/types/user.cjs +0 -1
- package/dist/utils/basket.cjs +0 -14
- package/dist/utils/fetch.cjs +0 -19
- package/dist/utils/hash.cjs +0 -72
- package/dist/utils/index.cjs +0 -49
- package/dist/utils/keys.cjs +0 -67
- package/dist/utils/log.cjs +0 -93
- package/dist/utils/response.cjs +0 -13
- package/dist/utils/sapi.cjs +0 -26
- package/dist/utils/timeout.cjs +0 -18
- package/dist/utils/user.cjs +0 -90
package/dist/constants/index.cjs
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
var _withParameters = require("./withParameters.cjs");
|
|
7
|
-
Object.keys(_withParameters).forEach(function (key) {
|
|
8
|
-
if (key === "default" || key === "__esModule") return;
|
|
9
|
-
if (key in exports && exports[key] === _withParameters[key]) return;
|
|
10
|
-
Object.defineProperty(exports, key, {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function () {
|
|
13
|
-
return _withParameters[key];
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
var _cache = require("./cache.cjs");
|
|
18
|
-
Object.keys(_cache).forEach(function (key) {
|
|
19
|
-
if (key === "default" || key === "__esModule") return;
|
|
20
|
-
if (key in exports && exports[key] === _cache[key]) return;
|
|
21
|
-
Object.defineProperty(exports, key, {
|
|
22
|
-
enumerable: true,
|
|
23
|
-
get: function () {
|
|
24
|
-
return _cache[key];
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
var _basket = require("./basket.cjs");
|
|
29
|
-
Object.keys(_basket).forEach(function (key) {
|
|
30
|
-
if (key === "default" || key === "__esModule") return;
|
|
31
|
-
if (key in exports && exports[key] === _basket[key]) return;
|
|
32
|
-
Object.defineProperty(exports, key, {
|
|
33
|
-
enumerable: true,
|
|
34
|
-
get: function () {
|
|
35
|
-
return _basket[key];
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
var _httpStatus = require("./httpStatus.cjs");
|
|
40
|
-
Object.keys(_httpStatus).forEach(function (key) {
|
|
41
|
-
if (key === "default" || key === "__esModule") return;
|
|
42
|
-
if (key in exports && exports[key] === _httpStatus[key]) return;
|
|
43
|
-
Object.defineProperty(exports, key, {
|
|
44
|
-
enumerable: true,
|
|
45
|
-
get: function () {
|
|
46
|
-
return _httpStatus[key];
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
var _sorting = require("./sorting.cjs");
|
|
51
|
-
Object.keys(_sorting).forEach(function (key) {
|
|
52
|
-
if (key === "default" || key === "__esModule") return;
|
|
53
|
-
if (key in exports && exports[key] === _sorting[key]) return;
|
|
54
|
-
Object.defineProperty(exports, key, {
|
|
55
|
-
enumerable: true,
|
|
56
|
-
get: function () {
|
|
57
|
-
return _sorting[key];
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
var _product = require("./product.cjs");
|
|
62
|
-
Object.keys(_product).forEach(function (key) {
|
|
63
|
-
if (key === "default" || key === "__esModule") return;
|
|
64
|
-
if (key in exports && exports[key] === _product[key]) return;
|
|
65
|
-
Object.defineProperty(exports, key, {
|
|
66
|
-
enumerable: true,
|
|
67
|
-
get: function () {
|
|
68
|
-
return _product[key];
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
var _hash = require("./hash.cjs");
|
|
73
|
-
Object.keys(_hash).forEach(function (key) {
|
|
74
|
-
if (key === "default" || key === "__esModule") return;
|
|
75
|
-
if (key in exports && exports[key] === _hash[key]) return;
|
|
76
|
-
Object.defineProperty(exports, key, {
|
|
77
|
-
enumerable: true,
|
|
78
|
-
get: function () {
|
|
79
|
-
return _hash[key];
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
var _promotion = require("./promotion.cjs");
|
|
84
|
-
Object.keys(_promotion).forEach(function (key) {
|
|
85
|
-
if (key === "default" || key === "__esModule") return;
|
|
86
|
-
if (key in exports && exports[key] === _promotion[key]) return;
|
|
87
|
-
Object.defineProperty(exports, key, {
|
|
88
|
-
enumerable: true,
|
|
89
|
-
get: function () {
|
|
90
|
-
return _promotion[key];
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
});
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.PromotionEffectType = exports.PROMOTION_PER_PAGE_DEFAULT = exports.PROMOTION_PAGE_DEFAULT = void 0;
|
|
7
|
-
const PROMOTION_PAGE_DEFAULT = exports.PROMOTION_PAGE_DEFAULT = 1;
|
|
8
|
-
const PROMOTION_PER_PAGE_DEFAULT = exports.PROMOTION_PER_PAGE_DEFAULT = 100;
|
|
9
|
-
const PromotionEffectType = exports.PromotionEffectType = {
|
|
10
|
-
AUTOMATIC_DISCOUNT: "automatic_discount",
|
|
11
|
-
BUY_X_GET_Y: "buy_x_get_y"
|
|
12
|
-
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.SortQuery = exports.SortName = void 0;
|
|
7
|
-
const SortName = exports.SortName = {
|
|
8
|
-
TOPSELLER: "topseller",
|
|
9
|
-
DATE_NEWEST: "date_newest",
|
|
10
|
-
PRICE_DESC: "price_desc",
|
|
11
|
-
PRICE_ASC: "price_asc",
|
|
12
|
-
REDUCTION_DESC: "reduction_desc",
|
|
13
|
-
REDUCTION_ASC: "reduction_asc"
|
|
14
|
-
};
|
|
15
|
-
const SortQuery = exports.SortQuery = {
|
|
16
|
-
TOPSELLER: "topseller",
|
|
17
|
-
DATE_NEWEST: "date-newest",
|
|
18
|
-
PRICE_DESC: "price-desc",
|
|
19
|
-
PRICE_ASC: "price-asc",
|
|
20
|
-
REDUCTION_DESC: "reduction-desc",
|
|
21
|
-
REDUCTION_ASC: "reduction-asc"
|
|
22
|
-
};
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.MIN_WITH_PARAMS_WISHLIST = exports.MIN_WITH_PARAMS_VARIANT = exports.MIN_WITH_PARAMS_SEARCH = exports.MIN_WITH_PARAMS_PRODUCT = exports.MIN_WITH_PARAMS_BASKET = exports.DEFAULT_WITH_LISTING = void 0;
|
|
7
|
-
const DEFAULT_WITH_LISTING = exports.DEFAULT_WITH_LISTING = {
|
|
8
|
-
items: {
|
|
9
|
-
product: {
|
|
10
|
-
attributes: "all",
|
|
11
|
-
advancedAttributes: "all",
|
|
12
|
-
variants: {
|
|
13
|
-
attributes: "all",
|
|
14
|
-
advancedAttributes: "all"
|
|
15
|
-
},
|
|
16
|
-
images: "all",
|
|
17
|
-
categories: {
|
|
18
|
-
properties: "all"
|
|
19
|
-
},
|
|
20
|
-
priceRange: true
|
|
21
|
-
},
|
|
22
|
-
variant: {
|
|
23
|
-
attributes: "all"
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
const MIN_WITH_PARAMS_SEARCH = exports.MIN_WITH_PARAMS_SEARCH = {
|
|
28
|
-
products: {
|
|
29
|
-
attributes: {
|
|
30
|
-
withKey: ["brand", "color", "colorDetail", "name"]
|
|
31
|
-
},
|
|
32
|
-
variants: {
|
|
33
|
-
attributes: {
|
|
34
|
-
withKey: ["price", "size"]
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
|
-
categories: {
|
|
38
|
-
properties: "all"
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
const MIN_WITH_PARAMS_PRODUCT = exports.MIN_WITH_PARAMS_PRODUCT = {
|
|
43
|
-
attributes: {
|
|
44
|
-
withKey: ["color", "brand", "name", "material", "careSymbol"]
|
|
45
|
-
},
|
|
46
|
-
variants: {
|
|
47
|
-
attributes: {
|
|
48
|
-
withKey: ["price", "size"]
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
images: {
|
|
52
|
-
attributes: {
|
|
53
|
-
withKey: ["imageBackground"]
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
categories: {
|
|
57
|
-
properties: "all"
|
|
58
|
-
},
|
|
59
|
-
siblings: {
|
|
60
|
-
images: {
|
|
61
|
-
attributes: {
|
|
62
|
-
withKey: ["imageBackground"]
|
|
63
|
-
}
|
|
64
|
-
},
|
|
65
|
-
attributes: {
|
|
66
|
-
withKey: ["color", "brand", "name"]
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
const MIN_WITH_PARAMS_BASKET = exports.MIN_WITH_PARAMS_BASKET = {
|
|
71
|
-
items: {
|
|
72
|
-
product: {
|
|
73
|
-
attributes: {
|
|
74
|
-
withKey: ["brand", "name", "color"]
|
|
75
|
-
},
|
|
76
|
-
variants: {
|
|
77
|
-
attributes: {
|
|
78
|
-
withKey: ["brand", "name", "price", "size", "shopSize", "vendorSize"]
|
|
79
|
-
}
|
|
80
|
-
},
|
|
81
|
-
images: {
|
|
82
|
-
attributes: {
|
|
83
|
-
withKey: ["imageBackground"]
|
|
84
|
-
}
|
|
85
|
-
},
|
|
86
|
-
categories: {
|
|
87
|
-
properties: "all"
|
|
88
|
-
},
|
|
89
|
-
priceRange: true,
|
|
90
|
-
lowestPriorPrice: true
|
|
91
|
-
},
|
|
92
|
-
variant: {
|
|
93
|
-
attributes: {
|
|
94
|
-
withKey: ["size", "shopSize", "vendorSize"]
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
const MIN_WITH_PARAMS_WISHLIST = exports.MIN_WITH_PARAMS_WISHLIST = {
|
|
100
|
-
items: {
|
|
101
|
-
product: {
|
|
102
|
-
attributes: {
|
|
103
|
-
withKey: ["brand", "name", "color"]
|
|
104
|
-
},
|
|
105
|
-
variants: {
|
|
106
|
-
attributes: {
|
|
107
|
-
withKey: ["brand", "name", "price", "size", "shopSize", "vendorSize"]
|
|
108
|
-
}
|
|
109
|
-
},
|
|
110
|
-
images: {
|
|
111
|
-
attributes: {
|
|
112
|
-
withKey: ["imageBackground"]
|
|
113
|
-
}
|
|
114
|
-
},
|
|
115
|
-
categories: {
|
|
116
|
-
properties: "all"
|
|
117
|
-
},
|
|
118
|
-
priceRange: true,
|
|
119
|
-
lowestPriorPrice: true
|
|
120
|
-
},
|
|
121
|
-
variant: {
|
|
122
|
-
attributes: {
|
|
123
|
-
withKey: ["size", "shopSize", "vendorSize"]
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
const MIN_WITH_PARAMS_VARIANT = exports.MIN_WITH_PARAMS_VARIANT = {
|
|
129
|
-
attributes: {
|
|
130
|
-
withKey: ["size", "shopSize", "vendorSize"]
|
|
131
|
-
}
|
|
132
|
-
};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.ErrorResponse = void 0;
|
|
7
|
-
class ErrorResponse extends Response {
|
|
8
|
-
title;
|
|
9
|
-
details;
|
|
10
|
-
constructor(statusCode, statusMessage, title, detail) {
|
|
11
|
-
const response = {
|
|
12
|
-
title,
|
|
13
|
-
status: statusCode,
|
|
14
|
-
...detail
|
|
15
|
-
};
|
|
16
|
-
super(JSON.stringify(response, null, 2), {
|
|
17
|
-
status: statusCode,
|
|
18
|
-
statusText: statusMessage,
|
|
19
|
-
headers: {
|
|
20
|
-
"Content-Type": "application/problem+json"
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
this.title = title;
|
|
24
|
-
this.details = detail;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
exports.ErrorResponse = ErrorResponse;
|
package/dist/errors/index.cjs
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
var _errorResponse = require("./errorResponse.cjs");
|
|
7
|
-
Object.keys(_errorResponse).forEach(function (key) {
|
|
8
|
-
if (key === "default" || key === "__esModule") return;
|
|
9
|
-
if (key in exports && exports[key] === _errorResponse[key]) return;
|
|
10
|
-
Object.defineProperty(exports, key, {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function () {
|
|
13
|
-
return _errorResponse[key];
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
});
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getFlattenedVariantCrosssellings = exports.getFlattenedMaterialComposition = exports.getFlattenedAdvancedAttribute = exports.flattenFieldSet = void 0;
|
|
7
|
-
var _arrayHelpers = require("./arrayHelpers.cjs");
|
|
8
|
-
var _objectHelpers = require("./objectHelpers.cjs");
|
|
9
|
-
const flattenFieldSet = fieldSet => {
|
|
10
|
-
return fieldSet.map(_objectHelpers.flattenObject);
|
|
11
|
-
};
|
|
12
|
-
exports.flattenFieldSet = flattenFieldSet;
|
|
13
|
-
const getFlattenedMaterialComposition = materialCompositions => {
|
|
14
|
-
return materialCompositions.map(materialComposition => ({
|
|
15
|
-
...(0, _arrayHelpers.flattenDeep)(flattenFieldSet(materialComposition.fieldSet))[0],
|
|
16
|
-
values: (0, _arrayHelpers.flattenDeep)(materialComposition.groupSet.map(g => flattenFieldSet(g.fieldSet)))
|
|
17
|
-
}));
|
|
18
|
-
};
|
|
19
|
-
exports.getFlattenedMaterialComposition = getFlattenedMaterialComposition;
|
|
20
|
-
const getFlattenedAdvancedAttribute = attributeGroup => {
|
|
21
|
-
return attributeGroup.map(groupItem => ({
|
|
22
|
-
...(0, _arrayHelpers.flattenDeep)(flattenFieldSet(groupItem.fieldSet))[0],
|
|
23
|
-
values: (0, _arrayHelpers.flattenDeep)(groupItem.groupSet.map(g => flattenFieldSet(g.fieldSet)))
|
|
24
|
-
}));
|
|
25
|
-
};
|
|
26
|
-
exports.getFlattenedAdvancedAttribute = getFlattenedAdvancedAttribute;
|
|
27
|
-
const getFlattenedVariantCrosssellings = variantCrosssellings => {
|
|
28
|
-
return getFlattenedAdvancedAttribute(variantCrosssellings);
|
|
29
|
-
};
|
|
30
|
-
exports.getFlattenedVariantCrosssellings = getFlattenedVariantCrosssellings;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getManyAttributeValueTuples = exports.getFirstAttributeValue = exports.getAttributeValueTuples = exports.getAttributeValue = void 0;
|
|
7
|
-
var _storefrontApi = require("@scayle/storefront-api");
|
|
8
|
-
const getFirstAttributeValue = (attributes, attributeName) => {
|
|
9
|
-
return (0, _storefrontApi.getFirstAttributeValue)(attributes, attributeName);
|
|
10
|
-
};
|
|
11
|
-
exports.getFirstAttributeValue = getFirstAttributeValue;
|
|
12
|
-
const getAttributeValue = (attributes, attributeName) => {
|
|
13
|
-
const values = getFirstAttributeValue(attributes, attributeName);
|
|
14
|
-
return values?.value ?? values?.label;
|
|
15
|
-
};
|
|
16
|
-
exports.getAttributeValue = getAttributeValue;
|
|
17
|
-
const getAttributeValueTuples = (attributes, attributeName) => {
|
|
18
|
-
return (0, _storefrontApi.getAttributeValues)(attributes, attributeName);
|
|
19
|
-
};
|
|
20
|
-
exports.getAttributeValueTuples = getAttributeValueTuples;
|
|
21
|
-
const getManyAttributeValueTuples = (attributes, attributeNames) => {
|
|
22
|
-
return attributeNames.map(key => getFirstAttributeValue(attributes, key)).filter(entry => !!entry);
|
|
23
|
-
};
|
|
24
|
-
exports.getManyAttributeValueTuples = getManyAttributeValueTuples;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getShippingDates = void 0;
|
|
7
|
-
const getShippingDates = packages => {
|
|
8
|
-
const min = packages.map(p => p.deliveryDate.min).sort();
|
|
9
|
-
const max = packages.map(p => p.deliveryDate.max).sort();
|
|
10
|
-
return [min?.[0] || null, max?.[max.length - 1] || null];
|
|
11
|
-
};
|
|
12
|
-
exports.getShippingDates = getShippingDates;
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getBreadcrumbsFromProductCategories = exports.getBreadcrumbsFromPath = exports.getBreadcrumbsFromCategory = exports.getBreadcrumbs = exports.getBackurlFromBreadcrumbs = void 0;
|
|
7
|
-
var _sanitizationHelpers = require("./sanitizationHelpers.cjs");
|
|
8
|
-
const getBreadcrumbsFromProductCategories = categories => {
|
|
9
|
-
return categories?.map(category => ({
|
|
10
|
-
value: "categoryName" in category ? category.categoryName : category.name,
|
|
11
|
-
to: "categoryName" in category ? category.categoryUrl : category.slug
|
|
12
|
-
})) || [];
|
|
13
|
-
};
|
|
14
|
-
exports.getBreadcrumbsFromProductCategories = getBreadcrumbsFromProductCategories;
|
|
15
|
-
const getBreadcrumbsFromCategory = (category, activeNode) => {
|
|
16
|
-
if (!category) {
|
|
17
|
-
return [];
|
|
18
|
-
}
|
|
19
|
-
const breadcrumbItems = [];
|
|
20
|
-
const generateBreadcrumbs = category2 => {
|
|
21
|
-
if (category2.children?.length || activeNode?.id === category2.id) {
|
|
22
|
-
breadcrumbItems.push({
|
|
23
|
-
value: category2.name,
|
|
24
|
-
to: category2.path
|
|
25
|
-
});
|
|
26
|
-
category2?.children?.forEach(child => generateBreadcrumbs(child));
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
generateBreadcrumbs(category);
|
|
30
|
-
return breadcrumbItems;
|
|
31
|
-
};
|
|
32
|
-
exports.getBreadcrumbsFromCategory = getBreadcrumbsFromCategory;
|
|
33
|
-
const getBreadcrumbsFromPath = (path = "", shopLocale = "") => {
|
|
34
|
-
if (shopLocale) {
|
|
35
|
-
path = (0, _sanitizationHelpers.stripShopLocaleFromPath)(shopLocale, path);
|
|
36
|
-
}
|
|
37
|
-
const breadcrumbItems = [];
|
|
38
|
-
path.split("/").forEach((segment, index) => {
|
|
39
|
-
if (!segment) {
|
|
40
|
-
breadcrumbItems.push({
|
|
41
|
-
to: "/",
|
|
42
|
-
value: "Home"
|
|
43
|
-
});
|
|
44
|
-
} else {
|
|
45
|
-
breadcrumbItems.push({
|
|
46
|
-
to: breadcrumbItems[index - 1].to === "/" ? `/${segment}` : `${breadcrumbItems[index - 1].to}/${segment}`,
|
|
47
|
-
value: segment
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
return breadcrumbItems;
|
|
52
|
-
};
|
|
53
|
-
exports.getBreadcrumbsFromPath = getBreadcrumbsFromPath;
|
|
54
|
-
const getBreadcrumbs = (categories, activeNode) => {
|
|
55
|
-
return Array.isArray(categories) ? getBreadcrumbsFromProductCategories(categories) : getBreadcrumbsFromCategory(categories, activeNode);
|
|
56
|
-
};
|
|
57
|
-
exports.getBreadcrumbs = getBreadcrumbs;
|
|
58
|
-
const getBackurlFromBreadcrumbs = breadcrumbs => {
|
|
59
|
-
return breadcrumbs?.[breadcrumbs?.length - 1].to ?? "/";
|
|
60
|
-
};
|
|
61
|
-
exports.getBackurlFromBreadcrumbs = getBackurlFromBreadcrumbs;
|
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.transformToWhereCondition = exports.transformStateToFilters = exports.transformSortToFilter = exports.transformMinAndMaxPriceToFilter = exports.serializeFilters = exports.mergeFilters = exports.isFilterActive = exports.groupFiltersByKey = exports.groupFilterableValuesByKey = exports.getGroupedFilterableValues = exports.getFilterablePriceValue = exports.getActiveFilters = exports.deserializeFilters = void 0;
|
|
7
|
-
var _storefrontApi = require("@scayle/storefront-api");
|
|
8
|
-
var _sortingHelper = require("./sortingHelper.cjs");
|
|
9
|
-
const transformToWhereCondition = conditions => {
|
|
10
|
-
const where = {
|
|
11
|
-
attributes: []
|
|
12
|
-
};
|
|
13
|
-
Object.keys(conditions).forEach(key => {
|
|
14
|
-
const value = conditions[key];
|
|
15
|
-
if (["sort", "term"].includes(key)) {
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
if (key === "minPrice" || key === "maxPrice") {
|
|
19
|
-
where[key] = value;
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
const condition = ["true", "false"].includes(value) ? {
|
|
23
|
-
key,
|
|
24
|
-
type: "boolean",
|
|
25
|
-
value: value === "true"
|
|
26
|
-
} : {
|
|
27
|
-
key,
|
|
28
|
-
type: "attributes",
|
|
29
|
-
values: Array.isArray(conditions[key]) ? conditions[key] : [conditions[key]]
|
|
30
|
-
};
|
|
31
|
-
where.attributes.push(condition);
|
|
32
|
-
});
|
|
33
|
-
return where;
|
|
34
|
-
};
|
|
35
|
-
exports.transformToWhereCondition = transformToWhereCondition;
|
|
36
|
-
const _getFilterValueByType = (value, type) => {
|
|
37
|
-
switch (type) {
|
|
38
|
-
case _storefrontApi.FilterTypes.BOOLEAN:
|
|
39
|
-
return value.name;
|
|
40
|
-
case _storefrontApi.FilterTypes.RANGE:
|
|
41
|
-
return {
|
|
42
|
-
min: value.min,
|
|
43
|
-
max: value.max
|
|
44
|
-
};
|
|
45
|
-
default:
|
|
46
|
-
return value.id;
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
const groupFilterableValuesByKey = (filters, filterableKeys, {
|
|
50
|
-
sortable
|
|
51
|
-
} = {
|
|
52
|
-
sortable: true
|
|
53
|
-
}) => {
|
|
54
|
-
const enabledFilters = filterableKeys ? filters.filter(filter => filterableKeys.includes(filter.slug)) : filters;
|
|
55
|
-
const transformedAvailableFilters = enabledFilters.reduce((availableFilters, filter) => {
|
|
56
|
-
filter.values.forEach(value => {
|
|
57
|
-
const isBoolean = filter.type === _storefrontApi.FilterTypes.BOOLEAN;
|
|
58
|
-
const hasNameInValue = "name" in value;
|
|
59
|
-
if (isBoolean && hasNameInValue && value.name === false) {
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
const filterValue = _getFilterValueByType(value, filter.type);
|
|
63
|
-
const nameValue = hasNameInValue ? String(value.name) : "";
|
|
64
|
-
availableFilters.push({
|
|
65
|
-
key: filter.slug,
|
|
66
|
-
displayName: isBoolean ? filter.name : nameValue,
|
|
67
|
-
count: value.productCount,
|
|
68
|
-
value: filterValue,
|
|
69
|
-
whereCondition: {
|
|
70
|
-
[filter.slug]: filterValue
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
return availableFilters;
|
|
75
|
-
}, []);
|
|
76
|
-
return sortable ? transformedAvailableFilters.sort((a, b) => a.displayName.localeCompare(b.displayName)) : transformedAvailableFilters;
|
|
77
|
-
};
|
|
78
|
-
exports.groupFilterableValuesByKey = groupFilterableValuesByKey;
|
|
79
|
-
const generateFilterKeyAndValue = filter => {
|
|
80
|
-
return filter.reduce((objectToReturn, f) => Object.assign(objectToReturn, objectToReturn[f.key] ? objectToReturn[f.key].push(f.value) : {
|
|
81
|
-
[f.key]: [f.value]
|
|
82
|
-
}), {});
|
|
83
|
-
};
|
|
84
|
-
const transformStateToFilters = state => {
|
|
85
|
-
return Object.values(state).reduce((objectToReturn, filter) => Object.assign(objectToReturn, generateFilterKeyAndValue(filter)), {});
|
|
86
|
-
};
|
|
87
|
-
exports.transformStateToFilters = transformStateToFilters;
|
|
88
|
-
const mergeFilters = filters => {
|
|
89
|
-
const mergedFilter = {};
|
|
90
|
-
filters.forEach(item => {
|
|
91
|
-
if (!mergedFilter[item.key]) {
|
|
92
|
-
mergedFilter[item.key] = item.value;
|
|
93
|
-
} else {
|
|
94
|
-
mergedFilter[item.key] = [mergedFilter[item.key], item.value].flat();
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
return mergedFilter;
|
|
98
|
-
};
|
|
99
|
-
exports.mergeFilters = mergeFilters;
|
|
100
|
-
const isFilterActive = (filters, filterToCheck) => {
|
|
101
|
-
const key = filterToCheck.key;
|
|
102
|
-
return filters[key] && (filters[key].toString() === filterToCheck.value.toString() || Array.isArray(filters[key]) && filters[key].includes(filterToCheck.value));
|
|
103
|
-
};
|
|
104
|
-
exports.isFilterActive = isFilterActive;
|
|
105
|
-
const getActiveFilters = (filters, activeFilters) => {
|
|
106
|
-
return [].concat(...Object.values(filters)).filter(item => isFilterActive(activeFilters, item)) || [];
|
|
107
|
-
};
|
|
108
|
-
exports.getActiveFilters = getActiveFilters;
|
|
109
|
-
const groupFiltersByKey = filters => {
|
|
110
|
-
const groupedFilters = filters.reduce((acc, item) => {
|
|
111
|
-
const groupId = item.key;
|
|
112
|
-
if (!acc[groupId]) {
|
|
113
|
-
acc[groupId] = [];
|
|
114
|
-
}
|
|
115
|
-
acc[groupId].push(item);
|
|
116
|
-
return acc;
|
|
117
|
-
}, {});
|
|
118
|
-
return Object.entries(groupedFilters);
|
|
119
|
-
};
|
|
120
|
-
exports.groupFiltersByKey = groupFiltersByKey;
|
|
121
|
-
const transformMinAndMaxPriceToFilter = prices => {
|
|
122
|
-
const [min = 0, max = 1e5] = prices;
|
|
123
|
-
return {
|
|
124
|
-
minPrice: min,
|
|
125
|
-
maxPrice: max
|
|
126
|
-
};
|
|
127
|
-
};
|
|
128
|
-
exports.transformMinAndMaxPriceToFilter = transformMinAndMaxPriceToFilter;
|
|
129
|
-
const transformSortToFilter = sort => {
|
|
130
|
-
return (0, _sortingHelper.getSortByValue)(sort);
|
|
131
|
-
};
|
|
132
|
-
exports.transformSortToFilter = transformSortToFilter;
|
|
133
|
-
const getGroupedFilterableValues = (keys, filterableValues, {
|
|
134
|
-
sortable
|
|
135
|
-
} = {
|
|
136
|
-
sortable: true
|
|
137
|
-
}) => {
|
|
138
|
-
return keys.reduce((filtersGroup, key) => {
|
|
139
|
-
filtersGroup[key] = groupFilterableValuesByKey(filterableValues, [key], {
|
|
140
|
-
sortable
|
|
141
|
-
});
|
|
142
|
-
return filtersGroup;
|
|
143
|
-
}, {});
|
|
144
|
-
};
|
|
145
|
-
exports.getGroupedFilterableValues = getGroupedFilterableValues;
|
|
146
|
-
const getFilterablePriceValue = (filterableValues, key = "min") => {
|
|
147
|
-
const prices = filterableValues.prices[0];
|
|
148
|
-
if (!prices) {
|
|
149
|
-
return key === "min" ? 0 : 1e4;
|
|
150
|
-
}
|
|
151
|
-
return prices.value[key];
|
|
152
|
-
};
|
|
153
|
-
exports.getFilterablePriceValue = getFilterablePriceValue;
|
|
154
|
-
const serializeFilters = filter => {
|
|
155
|
-
if (Object.keys(filter).length === 0) {
|
|
156
|
-
return void 0;
|
|
157
|
-
}
|
|
158
|
-
return Object.assign({}, ...Object.entries(filter).map(([filterName, filterValue]) => {
|
|
159
|
-
if (Array.isArray(filterValue)) {
|
|
160
|
-
return {
|
|
161
|
-
[filterName]: filterValue.join(",")
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
|
-
if (filterValue === null || filterValue === void 0) {
|
|
165
|
-
return {};
|
|
166
|
-
}
|
|
167
|
-
return {
|
|
168
|
-
[filterName]: String(filterValue)
|
|
169
|
-
};
|
|
170
|
-
}));
|
|
171
|
-
};
|
|
172
|
-
exports.serializeFilters = serializeFilters;
|
|
173
|
-
const deserializeFilters = serializedFilter => {
|
|
174
|
-
const toNumberIfNumeric = value => {
|
|
175
|
-
const number = +value;
|
|
176
|
-
if (!isNaN(number)) {
|
|
177
|
-
return number;
|
|
178
|
-
}
|
|
179
|
-
return value;
|
|
180
|
-
};
|
|
181
|
-
return Object.assign({}, ...Object.entries(serializedFilter).map(([filterName, filterValue]) => ({
|
|
182
|
-
[filterName]: typeof filterValue === "string" && filterValue.includes(",") ? filterValue.split(",").map(toNumberIfNumeric) : toNumberIfNumeric(filterValue)
|
|
183
|
-
})));
|
|
184
|
-
};
|
|
185
|
-
exports.deserializeFilters = deserializeFilters;
|