@scayle/storefront-core 7.22.1
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 +480 -0
- package/LICENSE +21 -0
- package/README.md +29 -0
- package/dist/bapi/init.cjs +30 -0
- package/dist/bapi/init.d.ts +14 -0
- package/dist/bapi/init.mjs +23 -0
- package/dist/cache/cache.cjs +1 -0
- package/dist/cache/cache.d.ts +8 -0
- package/dist/cache/cache.mjs +0 -0
- package/dist/cache/cached.cjs +89 -0
- package/dist/cache/cached.d.ts +24 -0
- package/dist/cache/cached.mjs +92 -0
- package/dist/cache/index.cjs +38 -0
- package/dist/cache/index.d.ts +3 -0
- package/dist/cache/index.mjs +3 -0
- package/dist/cache/providers/redis.cjs +94 -0
- package/dist/cache/providers/redis.d.ts +28 -0
- package/dist/cache/providers/redis.mjs +86 -0
- package/dist/cache/providers/unstorage.cjs +54 -0
- package/dist/cache/providers/unstorage.d.ts +16 -0
- package/dist/cache/providers/unstorage.mjs +49 -0
- package/dist/cache/types.cjs +11 -0
- package/dist/cache/types.d.ts +6 -0
- package/dist/cache/types.mjs +4 -0
- package/dist/constants/basket.cjs +13 -0
- package/dist/constants/basket.d.ts +8 -0
- package/dist/constants/basket.mjs +6 -0
- package/dist/constants/cache.cjs +8 -0
- package/dist/constants/cache.d.ts +1 -0
- package/dist/constants/cache.mjs +1 -0
- package/dist/constants/hash.cjs +11 -0
- package/dist/constants/hash.d.ts +6 -0
- package/dist/constants/hash.mjs +4 -0
- package/dist/constants/httpStatus.cjs +636 -0
- package/dist/constants/httpStatus.d.ts +632 -0
- package/dist/constants/httpStatus.mjs +629 -0
- package/dist/constants/index.cjs +93 -0
- package/dist/constants/index.d.ts +8 -0
- package/dist/constants/index.mjs +8 -0
- package/dist/constants/product.cjs +11 -0
- package/dist/constants/product.d.ts +6 -0
- package/dist/constants/product.mjs +4 -0
- package/dist/constants/promotion.cjs +10 -0
- package/dist/constants/promotion.d.ts +2 -0
- package/dist/constants/promotion.mjs +2 -0
- package/dist/constants/sorting.cjs +24 -0
- package/dist/constants/sorting.d.ts +20 -0
- package/dist/constants/sorting.mjs +17 -0
- package/dist/constants/withParameters.cjs +138 -0
- package/dist/constants/withParameters.d.ts +30 -0
- package/dist/constants/withParameters.mjs +132 -0
- package/dist/errors/BAPIError.cjs +16 -0
- package/dist/errors/BAPIError.d.ts +6 -0
- package/dist/errors/BAPIError.mjs +9 -0
- package/dist/errors/baseError.cjs +17 -0
- package/dist/errors/baseError.d.ts +5 -0
- package/dist/errors/baseError.mjs +10 -0
- package/dist/errors/index.cjs +27 -0
- package/dist/errors/index.d.ts +2 -0
- package/dist/errors/index.mjs +2 -0
- package/dist/helpers/advancedAttributeHelpers.cjs +26 -0
- package/dist/helpers/advancedAttributeHelpers.d.ts +12 -0
- package/dist/helpers/advancedAttributeHelpers.mjs +21 -0
- package/dist/helpers/arrayHelpers.cjs +10 -0
- package/dist/helpers/arrayHelpers.d.ts +1 -0
- package/dist/helpers/arrayHelpers.mjs +3 -0
- package/dist/helpers/attributeHelpers.cjs +24 -0
- package/dist/helpers/attributeHelpers.d.ts +5 -0
- package/dist/helpers/attributeHelpers.mjs +17 -0
- package/dist/helpers/autobind.cjs +44 -0
- package/dist/helpers/autobind.d.ts +39 -0
- package/dist/helpers/autobind.mjs +35 -0
- package/dist/helpers/basketHelpers.cjs +12 -0
- package/dist/helpers/basketHelpers.d.ts +2 -0
- package/dist/helpers/basketHelpers.mjs +5 -0
- package/dist/helpers/categoryHelper.cjs +61 -0
- package/dist/helpers/categoryHelper.d.ts +7 -0
- package/dist/helpers/categoryHelper.mjs +44 -0
- package/dist/helpers/filterHelper.cjs +156 -0
- package/dist/helpers/filterHelper.d.ts +82 -0
- package/dist/helpers/filterHelper.mjs +147 -0
- package/dist/helpers/formHelpers.cjs +114 -0
- package/dist/helpers/formHelpers.d.ts +48 -0
- package/dist/helpers/formHelpers.mjs +106 -0
- package/dist/helpers/imageHelpers.cjs +20 -0
- package/dist/helpers/imageHelpers.d.ts +4 -0
- package/dist/helpers/imageHelpers.mjs +14 -0
- package/dist/helpers/index.cjs +192 -0
- package/dist/helpers/index.d.ts +17 -0
- package/dist/helpers/index.mjs +17 -0
- package/dist/helpers/localization.cjs +13 -0
- package/dist/helpers/localization.d.ts +7 -0
- package/dist/helpers/localization.mjs +6 -0
- package/dist/helpers/objectHelpers.cjs +19 -0
- package/dist/helpers/objectHelpers.d.ts +1 -0
- package/dist/helpers/objectHelpers.mjs +6 -0
- package/dist/helpers/orderHelpers.cjs +10 -0
- package/dist/helpers/orderHelpers.d.ts +67 -0
- package/dist/helpers/orderHelpers.mjs +4 -0
- package/dist/helpers/product.fixture.cjs +770 -0
- package/dist/helpers/product.fixture.d.ts +415 -0
- package/dist/helpers/product.fixture.mjs +838 -0
- package/dist/helpers/productDisruptorHelper.cjs +37 -0
- package/dist/helpers/productDisruptorHelper.d.ts +10 -0
- package/dist/helpers/productDisruptorHelper.mjs +23 -0
- package/dist/helpers/productHelpers.cjs +188 -0
- package/dist/helpers/productHelpers.d.ts +41 -0
- package/dist/helpers/productHelpers.mjs +170 -0
- package/dist/helpers/sanitizationHelpers.cjs +15 -0
- package/dist/helpers/sanitizationHelpers.d.ts +2 -0
- package/dist/helpers/sanitizationHelpers.mjs +6 -0
- package/dist/helpers/sortingHelper.cjs +67 -0
- package/dist/helpers/sortingHelper.d.ts +69 -0
- package/dist/helpers/sortingHelper.mjs +66 -0
- package/dist/helpers/stringHelpers.cjs +8 -0
- package/dist/helpers/stringHelpers.d.ts +2 -0
- package/dist/helpers/stringHelpers.mjs +2 -0
- package/dist/index.cjs +85 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.mjs +8 -0
- package/dist/rpc/methods/basket/basket.cjs +183 -0
- package/dist/rpc/methods/basket/basket.d.ts +23 -0
- package/dist/rpc/methods/basket/basket.mjs +181 -0
- package/dist/rpc/methods/brands.cjs +34 -0
- package/dist/rpc/methods/brands.d.ts +5 -0
- package/dist/rpc/methods/brands.mjs +16 -0
- package/dist/rpc/methods/categories.cjs +102 -0
- package/dist/rpc/methods/categories.d.ts +21 -0
- package/dist/rpc/methods/categories.mjs +64 -0
- package/dist/rpc/methods/cbd.cjs +45 -0
- package/dist/rpc/methods/cbd.d.ts +4 -0
- package/dist/rpc/methods/cbd.mjs +36 -0
- package/dist/rpc/methods/checkout/index.cjs +38 -0
- package/dist/rpc/methods/checkout/index.d.ts +3 -0
- package/dist/rpc/methods/checkout/index.mjs +3 -0
- package/dist/rpc/methods/checkout/order.cjs +55 -0
- package/dist/rpc/methods/checkout/order.d.ts +4 -0
- package/dist/rpc/methods/checkout/order.mjs +43 -0
- package/dist/rpc/methods/checkout/shopUser.cjs +126 -0
- package/dist/rpc/methods/checkout/shopUser.d.ts +7 -0
- package/dist/rpc/methods/checkout/shopUser.mjs +109 -0
- package/dist/rpc/methods/checkout/shopUserAddresses.cjs +25 -0
- package/dist/rpc/methods/checkout/shopUserAddresses.d.ts +3 -0
- package/dist/rpc/methods/checkout/shopUserAddresses.mjs +19 -0
- package/dist/rpc/methods/index.cjs +159 -0
- package/dist/rpc/methods/index.d.ts +14 -0
- package/dist/rpc/methods/index.mjs +14 -0
- package/dist/rpc/methods/navigationTrees.cjs +33 -0
- package/dist/rpc/methods/navigationTrees.d.ts +5 -0
- package/dist/rpc/methods/navigationTrees.mjs +10 -0
- package/dist/rpc/methods/products.cjs +261 -0
- package/dist/rpc/methods/products.d.ts +13 -0
- package/dist/rpc/methods/products.mjs +217 -0
- package/dist/rpc/methods/promotion.cjs +53 -0
- package/dist/rpc/methods/promotion.d.ts +4 -0
- package/dist/rpc/methods/promotion.mjs +38 -0
- package/dist/rpc/methods/search.cjs +38 -0
- package/dist/rpc/methods/search.d.ts +10 -0
- package/dist/rpc/methods/search.mjs +22 -0
- package/dist/rpc/methods/session.cjs +274 -0
- package/dist/rpc/methods/session.d.ts +20 -0
- package/dist/rpc/methods/session.mjs +309 -0
- package/dist/rpc/methods/shopConfiguration.cjs +15 -0
- package/dist/rpc/methods/shopConfiguration.d.ts +4 -0
- package/dist/rpc/methods/shopConfiguration.mjs +6 -0
- package/dist/rpc/methods/user.cjs +89 -0
- package/dist/rpc/methods/user.d.ts +20 -0
- package/dist/rpc/methods/user.mjs +56 -0
- package/dist/rpc/methods/variants.cjs +29 -0
- package/dist/rpc/methods/variants.d.ts +8 -0
- package/dist/rpc/methods/variants.mjs +12 -0
- package/dist/rpc/methods/wishlist.cjs +85 -0
- package/dist/rpc/methods/wishlist.d.ts +13 -0
- package/dist/rpc/methods/wishlist.mjs +61 -0
- package/dist/server.cjs +39 -0
- package/dist/server.d.ts +5 -0
- package/dist/server.mjs +4 -0
- package/dist/types/api/auth.cjs +1 -0
- package/dist/types/api/auth.d.ts +63 -0
- package/dist/types/api/auth.mjs +0 -0
- package/dist/types/api/context.cjs +1 -0
- package/dist/types/api/context.d.ts +61 -0
- package/dist/types/api/context.mjs +0 -0
- package/dist/types/api/rpc.cjs +1 -0
- package/dist/types/api/rpc.d.ts +4 -0
- package/dist/types/api/rpc.mjs +0 -0
- package/dist/types/bapi/basket.cjs +1 -0
- package/dist/types/bapi/basket.d.ts +25 -0
- package/dist/types/bapi/basket.mjs +0 -0
- package/dist/types/bapi/brand.cjs +1 -0
- package/dist/types/bapi/brand.d.ts +2 -0
- package/dist/types/bapi/brand.mjs +0 -0
- package/dist/types/bapi/category.cjs +1 -0
- package/dist/types/bapi/category.d.ts +6 -0
- package/dist/types/bapi/category.mjs +0 -0
- package/dist/types/bapi/filter.cjs +1 -0
- package/dist/types/bapi/filter.d.ts +49 -0
- package/dist/types/bapi/filter.mjs +0 -0
- package/dist/types/bapi/navigation.cjs +1 -0
- package/dist/types/bapi/navigation.d.ts +10 -0
- package/dist/types/bapi/navigation.mjs +0 -0
- package/dist/types/bapi/order.cjs +1 -0
- package/dist/types/bapi/order.d.ts +554 -0
- package/dist/types/bapi/order.mjs +0 -0
- package/dist/types/bapi/pagination.cjs +1 -0
- package/dist/types/bapi/pagination.d.ts +13 -0
- package/dist/types/bapi/pagination.mjs +0 -0
- package/dist/types/bapi/product.cjs +1 -0
- package/dist/types/bapi/product.d.ts +84 -0
- package/dist/types/bapi/product.mjs +0 -0
- package/dist/types/bapi/productFilter.cjs +1 -0
- package/dist/types/bapi/productFilter.d.ts +7 -0
- package/dist/types/bapi/productFilter.mjs +0 -0
- package/dist/types/bapi/promotion.cjs +1 -0
- package/dist/types/bapi/promotion.d.ts +2 -0
- package/dist/types/bapi/promotion.mjs +0 -0
- package/dist/types/bapi/redirects.cjs +1 -0
- package/dist/types/bapi/redirects.d.ts +1 -0
- package/dist/types/bapi/redirects.mjs +0 -0
- package/dist/types/bapi/router.cjs +1 -0
- package/dist/types/bapi/router.d.ts +1 -0
- package/dist/types/bapi/router.mjs +0 -0
- package/dist/types/bapi/search.cjs +1 -0
- package/dist/types/bapi/search.d.ts +21 -0
- package/dist/types/bapi/search.mjs +0 -0
- package/dist/types/bapi/sorting.cjs +5 -0
- package/dist/types/bapi/sorting.d.ts +10 -0
- package/dist/types/bapi/sorting.mjs +1 -0
- package/dist/types/bapi/wishlist.cjs +1 -0
- package/dist/types/bapi/wishlist.d.ts +9 -0
- package/dist/types/bapi/wishlist.mjs +0 -0
- package/dist/types/breadcrumb.cjs +1 -0
- package/dist/types/breadcrumb.d.ts +4 -0
- package/dist/types/breadcrumb.mjs +0 -0
- package/dist/types/index.cjs +236 -0
- package/dist/types/index.d.ts +22 -0
- package/dist/types/index.mjs +21 -0
- package/dist/types/promises.cjs +1 -0
- package/dist/types/promises.d.ts +2 -0
- package/dist/types/promises.mjs +0 -0
- package/dist/types/user.cjs +1 -0
- package/dist/types/user.d.ts +100 -0
- package/dist/types/user.mjs +0 -0
- package/dist/utils/compression.cjs +24 -0
- package/dist/utils/compression.d.ts +2 -0
- package/dist/utils/compression.mjs +16 -0
- package/dist/utils/hash.cjs +68 -0
- package/dist/utils/hash.d.ts +8 -0
- package/dist/utils/hash.mjs +61 -0
- package/dist/utils/index.cjs +27 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.mjs +2 -0
- package/dist/utils/keys.cjs +67 -0
- package/dist/utils/keys.d.ts +24 -0
- package/dist/utils/keys.mjs +56 -0
- package/dist/utils/log.cjs +93 -0
- package/dist/utils/log.d.ts +43 -0
- package/dist/utils/log.mjs +75 -0
- package/dist/utils/rpc.cjs +41 -0
- package/dist/utils/rpc.d.ts +6 -0
- package/dist/utils/rpc.mjs +35 -0
- package/dist/utils/timeout.cjs +17 -0
- package/dist/utils/timeout.d.ts +2 -0
- package/dist/utils/timeout.mjs +9 -0
- package/dist/utils/user.cjs +75 -0
- package/dist/utils/user.d.ts +14 -0
- package/dist/utils/user.mjs +65 -0
- package/package.json +97 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { flattenDeep } from "./arrayHelpers.mjs";
|
|
2
|
+
import { flattenObject } from "./objectHelpers.mjs";
|
|
3
|
+
export const flattenFieldSet = (fieldSet) => {
|
|
4
|
+
return fieldSet.map(flattenObject);
|
|
5
|
+
};
|
|
6
|
+
export const getFlattenedMaterialComposition = (materialCompositions) => {
|
|
7
|
+
return materialCompositions.map((materialComposition) => ({
|
|
8
|
+
...flattenDeep(flattenFieldSet(materialComposition.fieldSet))[0],
|
|
9
|
+
values: flattenDeep(
|
|
10
|
+
materialComposition.groupSet.map((g) => flattenFieldSet(g.fieldSet))
|
|
11
|
+
)
|
|
12
|
+
}));
|
|
13
|
+
};
|
|
14
|
+
export const getFlattenedVariantCrosssellings = (variantCrosssellings) => {
|
|
15
|
+
return variantCrosssellings.map((variantCrossselling) => ({
|
|
16
|
+
...flattenDeep(flattenFieldSet(variantCrossselling.fieldSet))[0],
|
|
17
|
+
values: flattenDeep(
|
|
18
|
+
variantCrossselling.groupSet.map((g) => flattenFieldSet(g.fieldSet))
|
|
19
|
+
)
|
|
20
|
+
}));
|
|
21
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const flattenDeep: <T extends unknown[]>(array: T) => (T extends readonly (infer InnerArr)[] ? InnerArr extends readonly (infer InnerArr)[] ? InnerArr extends readonly (infer InnerArr)[] ? InnerArr extends readonly (infer InnerArr)[] ? InnerArr extends readonly (infer InnerArr)[] ? InnerArr extends readonly (infer InnerArr)[] ? InnerArr extends readonly (infer InnerArr)[] ? InnerArr extends readonly (infer InnerArr)[] ? InnerArr extends readonly (infer InnerArr)[] ? InnerArr extends readonly (infer InnerArr)[] ? InnerArr extends readonly (infer InnerArr)[] ? any : InnerArr : InnerArr : InnerArr : InnerArr : InnerArr : InnerArr : InnerArr : InnerArr : InnerArr : InnerArr : T)[];
|
|
@@ -0,0 +1,24 @@
|
|
|
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 _backbone = require("@aboutyou/backbone");
|
|
8
|
+
const getFirstAttributeValue = (attributes, attributeName) => {
|
|
9
|
+
return (0, _backbone.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, _backbone.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;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Attributes } from '@aboutyou/backbone/types/BapiProduct';
|
|
2
|
+
export declare const getFirstAttributeValue: (attributes: Attributes | undefined, attributeName: string) => import("@aboutyou/backbone").Value | undefined;
|
|
3
|
+
export declare const getAttributeValue: (attributes: Attributes | undefined, attributeName: string) => string | undefined;
|
|
4
|
+
export declare const getAttributeValueTuples: (attributes: Attributes | undefined, attributeName: string) => import("@aboutyou/backbone").Value[];
|
|
5
|
+
export declare const getManyAttributeValueTuples: (attributes: Attributes | undefined, attributeNames: string[]) => (import("@aboutyou/backbone").Value | undefined)[];
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getAttributeValues as _getAttributeValues,
|
|
3
|
+
getFirstAttributeValue as _getFirstAttributeValue
|
|
4
|
+
} from "@aboutyou/backbone";
|
|
5
|
+
export const getFirstAttributeValue = (attributes, attributeName) => {
|
|
6
|
+
return _getFirstAttributeValue(attributes, attributeName);
|
|
7
|
+
};
|
|
8
|
+
export const getAttributeValue = (attributes, attributeName) => {
|
|
9
|
+
const values = getFirstAttributeValue(attributes, attributeName);
|
|
10
|
+
return values?.value ?? values?.label;
|
|
11
|
+
};
|
|
12
|
+
export const getAttributeValueTuples = (attributes, attributeName) => {
|
|
13
|
+
return _getAttributeValues(attributes, attributeName);
|
|
14
|
+
};
|
|
15
|
+
export const getManyAttributeValueTuples = (attributes, attributeNames) => {
|
|
16
|
+
return attributeNames.map((key) => getFirstAttributeValue(attributes, key)).filter((entry) => !!entry);
|
|
17
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.autobind = autobind;
|
|
7
|
+
const getAllProperties = obj => {
|
|
8
|
+
const properties = /* @__PURE__ */new Set();
|
|
9
|
+
if (!obj) {
|
|
10
|
+
return properties;
|
|
11
|
+
}
|
|
12
|
+
do {
|
|
13
|
+
for (const key of Reflect.ownKeys(obj)) {
|
|
14
|
+
properties.add([obj, key]);
|
|
15
|
+
}
|
|
16
|
+
} while ((obj = Reflect.getPrototypeOf(obj)) && obj !== Object.prototype);
|
|
17
|
+
return properties;
|
|
18
|
+
};
|
|
19
|
+
function autobind(self, {
|
|
20
|
+
include,
|
|
21
|
+
exclude
|
|
22
|
+
} = {}) {
|
|
23
|
+
const filter = key => {
|
|
24
|
+
const match = pattern => typeof pattern === "string" ? key === pattern : pattern.test(key);
|
|
25
|
+
if (include) {
|
|
26
|
+
return include.some(match);
|
|
27
|
+
}
|
|
28
|
+
if (exclude) {
|
|
29
|
+
return !exclude.some(match);
|
|
30
|
+
}
|
|
31
|
+
return true;
|
|
32
|
+
};
|
|
33
|
+
for (const it of getAllProperties(self.constructor.prototype)) {
|
|
34
|
+
const [object, key] = it;
|
|
35
|
+
if (key === "constructor" || !filter(key)) {
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
const descriptor = Reflect.getOwnPropertyDescriptor(object, key);
|
|
39
|
+
if (descriptor && typeof descriptor.value === "function") {
|
|
40
|
+
self[key] = self[key].bind(self);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return self;
|
|
44
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
type Options = Partial<{
|
|
2
|
+
readonly include: ReadonlyArray<string | RegExp>;
|
|
3
|
+
readonly exclude: ReadonlyArray<string | RegExp>;
|
|
4
|
+
}>;
|
|
5
|
+
/**
|
|
6
|
+
* Automatically bind methods to their class instance.
|
|
7
|
+
* @param self - An object with methods to bind.
|
|
8
|
+
* @example
|
|
9
|
+
```
|
|
10
|
+
import { autobind } from '@scayle/storefront-core'
|
|
11
|
+
|
|
12
|
+
class Unicorn {
|
|
13
|
+
constructor(name) {
|
|
14
|
+
this.name = name;
|
|
15
|
+
autobind(this);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
message() {
|
|
19
|
+
return `${this.name} is awesome!`;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const unicorn = new Unicorn('Rainbow');
|
|
24
|
+
|
|
25
|
+
// Grab the method off the class instance
|
|
26
|
+
const message = unicorn.message;
|
|
27
|
+
|
|
28
|
+
// Still bound to the class instance
|
|
29
|
+
message();
|
|
30
|
+
// => 'Rainbow is awesome!'
|
|
31
|
+
|
|
32
|
+
// Without `autobind(this)`, the above would have resulted in
|
|
33
|
+
|
|
34
|
+
message();
|
|
35
|
+
//=> Error: Cannot read property 'name' of undefined
|
|
36
|
+
```
|
|
37
|
+
*/
|
|
38
|
+
export declare function autobind<SelfType extends Record<string, any>>(self: SelfType, { include, exclude }?: Options): SelfType;
|
|
39
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
const getAllProperties = (obj) => {
|
|
2
|
+
const properties = /* @__PURE__ */ new Set();
|
|
3
|
+
if (!obj) {
|
|
4
|
+
return properties;
|
|
5
|
+
}
|
|
6
|
+
do {
|
|
7
|
+
for (const key of Reflect.ownKeys(obj)) {
|
|
8
|
+
properties.add([obj, key]);
|
|
9
|
+
}
|
|
10
|
+
} while ((obj = Reflect.getPrototypeOf(obj)) && obj !== Object.prototype);
|
|
11
|
+
return properties;
|
|
12
|
+
};
|
|
13
|
+
export function autobind(self, { include, exclude } = {}) {
|
|
14
|
+
const filter = (key) => {
|
|
15
|
+
const match = (pattern) => typeof pattern === "string" ? key === pattern : pattern.test(key);
|
|
16
|
+
if (include) {
|
|
17
|
+
return include.some(match);
|
|
18
|
+
}
|
|
19
|
+
if (exclude) {
|
|
20
|
+
return !exclude.some(match);
|
|
21
|
+
}
|
|
22
|
+
return true;
|
|
23
|
+
};
|
|
24
|
+
for (const it of getAllProperties(self.constructor.prototype)) {
|
|
25
|
+
const [object, key] = it;
|
|
26
|
+
if (key === "constructor" || !filter(key)) {
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
const descriptor = Reflect.getOwnPropertyDescriptor(object, key);
|
|
30
|
+
if (descriptor && typeof descriptor.value === "function") {
|
|
31
|
+
self[key] = self[key].bind(self);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return self;
|
|
35
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
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;
|
|
@@ -0,0 +1,61 @@
|
|
|
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;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Category, ProductCategory } from '../types/bapi/category';
|
|
2
|
+
import { BreadcrumbItem } from '../types/breadcrumb';
|
|
3
|
+
export declare const getBreadcrumbsFromProductCategories: (categories: ProductCategory[] | Category[]) => BreadcrumbItem[];
|
|
4
|
+
export declare const getBreadcrumbsFromCategory: (category: Category, activeNode?: Category) => BreadcrumbItem[];
|
|
5
|
+
export declare const getBreadcrumbsFromPath: (path?: string, shopLocale?: string) => BreadcrumbItem[];
|
|
6
|
+
export declare const getBreadcrumbs: (categories: ProductCategory[] | Category, activeNode?: Category) => BreadcrumbItem[];
|
|
7
|
+
export declare const getBackurlFromBreadcrumbs: (breadcrumbs?: BreadcrumbItem[]) => string;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { stripShopLocaleFromPath } from "./sanitizationHelpers.mjs";
|
|
2
|
+
export const getBreadcrumbsFromProductCategories = (categories) => {
|
|
3
|
+
return categories?.map((category) => ({
|
|
4
|
+
value: "categoryName" in category ? category.categoryName : category.name,
|
|
5
|
+
to: "categoryName" in category ? category.categoryUrl : category.slug
|
|
6
|
+
})) || [];
|
|
7
|
+
};
|
|
8
|
+
export const getBreadcrumbsFromCategory = (category, activeNode) => {
|
|
9
|
+
if (!category) {
|
|
10
|
+
return [];
|
|
11
|
+
}
|
|
12
|
+
const breadcrumbItems = [];
|
|
13
|
+
const generateBreadcrumbs = (category2) => {
|
|
14
|
+
if (category2.children?.length || activeNode?.id === category2.id) {
|
|
15
|
+
breadcrumbItems.push({ value: category2.name, to: category2.path });
|
|
16
|
+
category2?.children?.forEach((child) => generateBreadcrumbs(child));
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
generateBreadcrumbs(category);
|
|
20
|
+
return breadcrumbItems;
|
|
21
|
+
};
|
|
22
|
+
export const getBreadcrumbsFromPath = (path = "", shopLocale = "") => {
|
|
23
|
+
if (shopLocale) {
|
|
24
|
+
path = stripShopLocaleFromPath(shopLocale, path);
|
|
25
|
+
}
|
|
26
|
+
const breadcrumbItems = [];
|
|
27
|
+
path.split("/").forEach((segment, index) => {
|
|
28
|
+
if (!segment) {
|
|
29
|
+
breadcrumbItems.push({ to: "/", value: "Home" });
|
|
30
|
+
} else {
|
|
31
|
+
breadcrumbItems.push({
|
|
32
|
+
to: breadcrumbItems[index - 1].to === "/" ? `/${segment}` : `${breadcrumbItems[index - 1].to}/${segment}`,
|
|
33
|
+
value: segment
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
return breadcrumbItems;
|
|
38
|
+
};
|
|
39
|
+
export const getBreadcrumbs = (categories, activeNode) => {
|
|
40
|
+
return Array.isArray(categories) ? getBreadcrumbsFromProductCategories(categories) : getBreadcrumbsFromCategory(categories, activeNode);
|
|
41
|
+
};
|
|
42
|
+
export const getBackurlFromBreadcrumbs = (breadcrumbs) => {
|
|
43
|
+
return breadcrumbs?.[breadcrumbs?.length - 1].to ?? "/";
|
|
44
|
+
};
|
|
@@ -0,0 +1,156 @@
|
|
|
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 _backbone = require("@aboutyou/backbone");
|
|
8
|
+
var _radash = require("radash");
|
|
9
|
+
var _sortingHelper = require("./sortingHelper.cjs");
|
|
10
|
+
const transformToWhereCondition = conditions => {
|
|
11
|
+
const where = {
|
|
12
|
+
attributes: []
|
|
13
|
+
};
|
|
14
|
+
Object.keys(conditions).forEach(key => {
|
|
15
|
+
const value = conditions[key];
|
|
16
|
+
if (["sort", "term"].includes(key)) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
if (key === "minPrice" || key === "maxPrice") {
|
|
20
|
+
where[key] = value;
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const condition = ["true", "false"].includes(value) ? {
|
|
24
|
+
key,
|
|
25
|
+
type: "boolean",
|
|
26
|
+
value: value === "true"
|
|
27
|
+
} : {
|
|
28
|
+
key,
|
|
29
|
+
type: "attributes",
|
|
30
|
+
values: Array.isArray(conditions[key]) ? conditions[key] : [conditions[key]]
|
|
31
|
+
};
|
|
32
|
+
where.attributes.push(condition);
|
|
33
|
+
});
|
|
34
|
+
return where;
|
|
35
|
+
};
|
|
36
|
+
exports.transformToWhereCondition = transformToWhereCondition;
|
|
37
|
+
const groupFilterableValuesByKey = (filters, filterableKeys) => {
|
|
38
|
+
const enabledFilters = filterableKeys ? filters.filter(filter => filterableKeys.includes(filter.slug)) : filters;
|
|
39
|
+
const availableFilters = [];
|
|
40
|
+
enabledFilters.forEach(filter => {
|
|
41
|
+
;
|
|
42
|
+
filter.values.forEach(value => {
|
|
43
|
+
if (filter.type === "boolean" && value.name === false) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const filterValue = _getFilterValueByType(value, filter.type);
|
|
47
|
+
availableFilters.push({
|
|
48
|
+
key: filter.slug,
|
|
49
|
+
displayName: filter.type === "boolean" ? filter.name : value.name,
|
|
50
|
+
count: value.productCount,
|
|
51
|
+
value: filterValue,
|
|
52
|
+
whereCondition: {
|
|
53
|
+
[filter.slug]: filterValue
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
return availableFilters.sort((a, b) => a.displayName < b.displayName ? -1 : 1);
|
|
59
|
+
};
|
|
60
|
+
exports.groupFilterableValuesByKey = groupFilterableValuesByKey;
|
|
61
|
+
const transformStateToFilters = state => {
|
|
62
|
+
return Object.values(state).reduce((objectToReturn, filter) => Object.assign(objectToReturn, generateFilterKeyAndValue(filter)), {});
|
|
63
|
+
};
|
|
64
|
+
exports.transformStateToFilters = transformStateToFilters;
|
|
65
|
+
const generateFilterKeyAndValue = filter => {
|
|
66
|
+
return filter.reduce((objectToReturn, f) => Object.assign(objectToReturn, objectToReturn[f.key] ? objectToReturn[f.key].push(f.value) : {
|
|
67
|
+
[f.key]: [f.value]
|
|
68
|
+
}), {});
|
|
69
|
+
};
|
|
70
|
+
const mergeFilters = filters => {
|
|
71
|
+
const mergedFilter = {};
|
|
72
|
+
filters.forEach(item => {
|
|
73
|
+
if (!mergedFilter[item.key]) {
|
|
74
|
+
mergedFilter[item.key] = item.value;
|
|
75
|
+
} else {
|
|
76
|
+
mergedFilter[item.key] = [mergedFilter[item.key], item.value].flat();
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
return mergedFilter;
|
|
80
|
+
};
|
|
81
|
+
exports.mergeFilters = mergeFilters;
|
|
82
|
+
const getActiveFilters = (filters, activeFilters) => {
|
|
83
|
+
return [].concat(...Object.values(filters)).filter(item => isFilterActive(activeFilters, item)) || [];
|
|
84
|
+
};
|
|
85
|
+
exports.getActiveFilters = getActiveFilters;
|
|
86
|
+
const groupFiltersByKey = filters => {
|
|
87
|
+
return Object.entries((0, _radash.group)(filters, it => it.key));
|
|
88
|
+
};
|
|
89
|
+
exports.groupFiltersByKey = groupFiltersByKey;
|
|
90
|
+
const transformMinAndMaxPriceToFilter = prices => {
|
|
91
|
+
const [min = 0, max = 1e5] = prices;
|
|
92
|
+
return {
|
|
93
|
+
minPrice: min,
|
|
94
|
+
maxPrice: max
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
exports.transformMinAndMaxPriceToFilter = transformMinAndMaxPriceToFilter;
|
|
98
|
+
const transformSortToFilter = sort => {
|
|
99
|
+
return (0, _sortingHelper.getSortByValue)(sort);
|
|
100
|
+
};
|
|
101
|
+
exports.transformSortToFilter = transformSortToFilter;
|
|
102
|
+
const getGroupedFilterableValues = (keys, filterableValues) => {
|
|
103
|
+
return keys.reduce((acc, key) => {
|
|
104
|
+
acc[key] = groupFilterableValuesByKey(filterableValues, [key]);
|
|
105
|
+
return acc;
|
|
106
|
+
}, {});
|
|
107
|
+
};
|
|
108
|
+
exports.getGroupedFilterableValues = getGroupedFilterableValues;
|
|
109
|
+
const isFilterActive = (filters, filterToCheck) => {
|
|
110
|
+
const key = filterToCheck.key;
|
|
111
|
+
return filters[key] && (filters[key].toString() === filterToCheck.value.toString() || Array.isArray(filters[key]) && filters[key].includes(filterToCheck.value));
|
|
112
|
+
};
|
|
113
|
+
exports.isFilterActive = isFilterActive;
|
|
114
|
+
const getFilterablePriceValue = (filterableValues, key = "min") => {
|
|
115
|
+
const prices = filterableValues.prices[0];
|
|
116
|
+
if (!prices) {
|
|
117
|
+
return key === "min" ? 0 : 1e4;
|
|
118
|
+
}
|
|
119
|
+
return prices.value[key];
|
|
120
|
+
};
|
|
121
|
+
exports.getFilterablePriceValue = getFilterablePriceValue;
|
|
122
|
+
const _getFilterValueByType = (value, type) => {
|
|
123
|
+
switch (type) {
|
|
124
|
+
case _backbone.FilterTypes.BOOLEAN:
|
|
125
|
+
return value.name;
|
|
126
|
+
case _backbone.FilterTypes.RANGE:
|
|
127
|
+
return {
|
|
128
|
+
min: value.min,
|
|
129
|
+
max: value.max
|
|
130
|
+
};
|
|
131
|
+
default:
|
|
132
|
+
return value.id;
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
const serializeFilters = filter => {
|
|
136
|
+
if ((0, _radash.isEmpty)(filter)) {
|
|
137
|
+
return void 0;
|
|
138
|
+
}
|
|
139
|
+
return Object.assign({}, ...Object.entries(filter).map(([filterName, filterValue]) => ({
|
|
140
|
+
[filterName]: Array.isArray(filterValue) ? filterValue.join(",") : String(filterValue)
|
|
141
|
+
})));
|
|
142
|
+
};
|
|
143
|
+
exports.serializeFilters = serializeFilters;
|
|
144
|
+
const deserializeFilters = serializedFilter => {
|
|
145
|
+
const toNumberIfNumeric = value => {
|
|
146
|
+
const number = +value;
|
|
147
|
+
if (!isNaN(number)) {
|
|
148
|
+
return number;
|
|
149
|
+
}
|
|
150
|
+
return value;
|
|
151
|
+
};
|
|
152
|
+
return Object.assign({}, ...Object.entries(serializedFilter).map(([filterName, filterValue]) => ({
|
|
153
|
+
[filterName]: typeof filterValue === "string" && filterValue.includes(",") ? filterValue.split(",").map(toNumberIfNumeric) : toNumberIfNumeric(filterValue)
|
|
154
|
+
})));
|
|
155
|
+
};
|
|
156
|
+
exports.deserializeFilters = deserializeFilters;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { ProductSearchQuery } from '@aboutyou/backbone/types/ProductSearchQuery';
|
|
2
|
+
import type { CentAmount } from '@aboutyou/backbone/types/BapiProduct';
|
|
3
|
+
import type { ProductFilter } from '../types';
|
|
4
|
+
export type TransformedFilter = {
|
|
5
|
+
key: string;
|
|
6
|
+
displayName: string;
|
|
7
|
+
count: number;
|
|
8
|
+
value: string | number;
|
|
9
|
+
whereCondition: Record<string, any>;
|
|
10
|
+
};
|
|
11
|
+
export declare const transformToWhereCondition: (conditions: Record<string, any>) => {
|
|
12
|
+
minPrice?: ProductSearchQuery['minPrice'];
|
|
13
|
+
maxPrice?: ProductSearchQuery['maxPrice'];
|
|
14
|
+
attributes: ProductSearchQuery['attributes'];
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Compute an array of filters that can be used to render the quick filters, for example.
|
|
18
|
+
*
|
|
19
|
+
* This method transforms attribute filters with multiple possible values into a flattened
|
|
20
|
+
* list of filters with one filter entry per possible attribute value
|
|
21
|
+
*
|
|
22
|
+
* By providing filterableKeys you can limit the generated list of filters to specific
|
|
23
|
+
* keys you would like to filter by.
|
|
24
|
+
*
|
|
25
|
+
* @param filters
|
|
26
|
+
* @param filterableKeys
|
|
27
|
+
*/
|
|
28
|
+
export declare const groupFilterableValuesByKey: (filters: ProductFilter[], filterableKeys?: Array<string>) => Array<TransformedFilter>;
|
|
29
|
+
export declare const transformStateToFilters: (state: {
|
|
30
|
+
[key: string]: TransformedFilter[];
|
|
31
|
+
}) => any;
|
|
32
|
+
export declare const mergeFilters: (filters: TransformedFilter[]) => Record<string, any>;
|
|
33
|
+
export declare const getActiveFilters: (filters: Record<string, any>, activeFilters: Record<string, any>) => TransformedFilter[];
|
|
34
|
+
export declare const groupFiltersByKey: (filters: TransformedFilter[]) => any[];
|
|
35
|
+
export declare const transformMinAndMaxPriceToFilter: (prices: (CentAmount | undefined)[]) => any;
|
|
36
|
+
export declare const transformSortToFilter: (sort: string) => {
|
|
37
|
+
by: import("@aboutyou/backbone").APISortOption;
|
|
38
|
+
direction: import("@aboutyou/backbone").APISortOrder;
|
|
39
|
+
name: "topseller";
|
|
40
|
+
query: "topseller";
|
|
41
|
+
} | {
|
|
42
|
+
by: import("@aboutyou/backbone").APISortOption;
|
|
43
|
+
name: "date_newest";
|
|
44
|
+
query: "date-newest";
|
|
45
|
+
} | {
|
|
46
|
+
by: import("@aboutyou/backbone").APISortOption;
|
|
47
|
+
direction: import("@aboutyou/backbone").APISortOrder;
|
|
48
|
+
name: "price_desc";
|
|
49
|
+
query: "price-desc";
|
|
50
|
+
} | {
|
|
51
|
+
by: import("@aboutyou/backbone").APISortOption;
|
|
52
|
+
direction: import("@aboutyou/backbone").APISortOrder;
|
|
53
|
+
name: "price_asc";
|
|
54
|
+
query: "price-asc";
|
|
55
|
+
} | {
|
|
56
|
+
by: import("@aboutyou/backbone").APISortOption;
|
|
57
|
+
direction: import("@aboutyou/backbone").APISortOrder;
|
|
58
|
+
name: "reduction_desc";
|
|
59
|
+
query: "reduction-desc";
|
|
60
|
+
} | {
|
|
61
|
+
by: import("@aboutyou/backbone").APISortOption;
|
|
62
|
+
direction: import("@aboutyou/backbone").APISortOrder;
|
|
63
|
+
name: "reduction_asc";
|
|
64
|
+
query: "reduction-asc";
|
|
65
|
+
};
|
|
66
|
+
export declare const getGroupedFilterableValues: (keys: Array<string>, filterableValues: ProductFilter[]) => Record<string, any>;
|
|
67
|
+
export declare const isFilterActive: (filters: Record<string, any>, filterToCheck: TransformedFilter) => any;
|
|
68
|
+
export declare const getFilterablePriceValue: (filterableValues: Record<string, any>, key?: 'min' | 'max') => any;
|
|
69
|
+
export type SerializedFilter = Record<string, string>;
|
|
70
|
+
export type Filter = Record<string, string | number | (string | number | null)[]>;
|
|
71
|
+
/**
|
|
72
|
+
* Converts filter values, within a filter object, into their string representation.
|
|
73
|
+
*
|
|
74
|
+
* @param filter
|
|
75
|
+
*/
|
|
76
|
+
export declare const serializeFilters: (filter: Filter) => SerializedFilter;
|
|
77
|
+
/**
|
|
78
|
+
* Converts filter values back into their original data type.
|
|
79
|
+
*
|
|
80
|
+
* @param filters
|
|
81
|
+
*/
|
|
82
|
+
export declare const deserializeFilters: (serializedFilter: SerializedFilter) => Filter;
|