@scayle/storefront-core 8.8.0 → 8.10.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 +85 -0
- package/dist/helpers/advancedAttributeHelpers.d.ts +27 -0
- package/dist/helpers/arrayHelpers.d.ts +7 -0
- package/dist/helpers/attributeHelpers.d.ts +32 -0
- package/dist/helpers/basketHelpers.d.ts +7 -0
- package/dist/helpers/categoryHelper.d.ts +38 -0
- package/dist/helpers/filterHelper.d.ts +96 -10
- package/dist/helpers/formHelpers.d.ts +57 -24
- package/dist/helpers/imageHelpers.d.ts +18 -0
- package/dist/helpers/localization.d.ts +6 -4
- package/dist/helpers/objectHelpers.d.ts +7 -0
- package/dist/helpers/orderHelpers.d.ts +31 -16
- package/dist/helpers/productDisruptorHelper.d.ts +43 -0
- package/dist/helpers/productHelpers.d.ts +169 -0
- package/dist/helpers/sanitizationHelpers.d.ts +61 -0
- package/dist/helpers/sortingHelper.d.ts +16 -0
- package/dist/helpers/stringHelpers.d.ts +14 -0
- package/dist/index.d.ts +3 -1
- package/dist/rpc/methods/basket/basket.d.ts +95 -10
- package/dist/rpc/methods/basket/basket.mjs +4 -5
- package/dist/rpc/methods/brands.d.ts +26 -0
- package/dist/rpc/methods/campaign.d.ts +8 -4
- package/dist/rpc/methods/categories.d.ts +65 -5
- package/dist/rpc/methods/categories.mjs +2 -1
- package/dist/rpc/methods/cbd.d.ts +10 -0
- package/dist/rpc/methods/checkout/checkout.d.ts +42 -3
- package/dist/rpc/methods/checkout/checkout.mjs +2 -3
- package/dist/rpc/methods/checkout/order.d.ts +12 -0
- package/dist/rpc/methods/checkout/shopUser.d.ts +20 -0
- package/dist/rpc/methods/checkout/shopUserAddresses.d.ts +7 -0
- package/dist/rpc/methods/navigationTrees.d.ts +27 -0
- package/dist/rpc/methods/oauth/idp.d.ts +24 -0
- package/dist/rpc/methods/products.d.ts +160 -36
- package/dist/rpc/methods/products.mjs +8 -11
- package/dist/rpc/methods/promotion.d.ts +46 -4
- package/dist/rpc/methods/search.d.ts +17 -12
- package/dist/rpc/methods/search.mjs +4 -2
- package/dist/rpc/methods/session.d.ts +71 -0
- package/dist/rpc/methods/session.mjs +13 -13
- package/dist/rpc/methods/shopConfiguration.d.ts +12 -1
- package/dist/rpc/methods/shopConfiguration.mjs +2 -1
- package/dist/rpc/methods/user.d.ts +34 -4
- package/dist/rpc/methods/variants.d.ts +30 -2
- package/dist/rpc/methods/variants.mjs +1 -2
- package/dist/rpc/methods/wishlist.d.ts +42 -7
- package/dist/rpc/methods/wishlist.mjs +3 -4
- package/dist/test/factories/user.d.ts +10 -0
- package/dist/types/api/auth.d.ts +67 -0
- package/dist/types/api/context.d.ts +82 -1
- package/dist/types/api/rpc.d.ts +19 -0
- package/dist/types/breadcrumb.d.ts +9 -0
- package/dist/types/promises.d.ts +10 -0
- package/dist/types/sapi/basket.d.ts +26 -1
- package/dist/types/sapi/filter.d.ts +37 -0
- package/dist/types/sapi/navigation.d.ts +16 -4
- package/dist/types/sapi/order.d.ts +137 -242
- package/dist/types/sapi/product.d.ts +85 -0
- package/dist/types/sapi/productFilter.d.ts +14 -0
- package/dist/types/sapi/router.d.ts +3 -0
- package/dist/types/sapi/search.d.ts +19 -0
- package/dist/types/sapi/sorting.d.ts +7 -0
- package/dist/types/sapi/wishlist.d.ts +6 -0
- package/dist/types/user.d.ts +102 -0
- package/dist/utils/campaign.d.ts +25 -10
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,11 +1,96 @@
|
|
|
1
1
|
# @scayle/storefront-core
|
|
2
2
|
|
|
3
|
+
## 8.10.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Simplified exported `Order` interface by relying directly on primitive types instead of having multiple intermediate types that resolve to primitives.
|
|
8
|
+
|
|
9
|
+
The following formerly exported intermediate types have been replaces by primitive types:
|
|
10
|
+
|
|
11
|
+
- resolving to `string` now
|
|
12
|
+
- `TimestampOfOrderConfirmation`
|
|
13
|
+
- `CharacterCurrencyCode`
|
|
14
|
+
- `UniqueIdentifierOfTheState`
|
|
15
|
+
- `NameOfTheState`
|
|
16
|
+
- `UniqueIdentifierOfTheState1`
|
|
17
|
+
- `NameOfTheState1`
|
|
18
|
+
- `UniqueIdentifierOfTheState2`
|
|
19
|
+
- `NameOfTheState2`
|
|
20
|
+
- `TimestampOfOrderInvoice`
|
|
21
|
+
- `CharacterCurrencyCode1`
|
|
22
|
+
- `UniqueIdentifierOfTheItem`
|
|
23
|
+
- `TimestampOfItemCreation`
|
|
24
|
+
- `TimestampOfLastItemUpdate`
|
|
25
|
+
- `CarrierShippingTheItem`
|
|
26
|
+
- `LatestExpectedDeliveryDate`
|
|
27
|
+
- `EarliestExpectedDeliveryDate`
|
|
28
|
+
- `ShipmentKeyOfTheItem`
|
|
29
|
+
- `TimestampOfOrderCreation`
|
|
30
|
+
- `TimestampOfLastOrderUpdate`
|
|
31
|
+
- resolving to `number` now
|
|
32
|
+
- `ThisFieldRepresentsTheAdditionalFeesExcludingTheTaxes`
|
|
33
|
+
- `ThisFieldRepresentsTheAdditionalFeesIncludingTheTaxes`
|
|
34
|
+
- `TheIncludedVATAmount`
|
|
35
|
+
- `TheIncludedVATRateInPercentAsIntegerRepresentation`
|
|
36
|
+
- `ThisFieldRepresentsTheDiscountAmountIncludingTheTaxes`
|
|
37
|
+
- `AbsoluteValueOfTheAppliedTax`
|
|
38
|
+
- `UniqueNumericIdentifierOfTheItem`
|
|
39
|
+
- `AvailableQuantityInTheWarehouse`
|
|
40
|
+
- `ThisFieldRepresentsTheDiscountAmountIncludingTheTaxes1`
|
|
41
|
+
- `AbsoluteValueOfTheAppliedTax1`
|
|
42
|
+
- `RelativeValueOfTheAppliedTax`
|
|
43
|
+
- `UndiscountedItemPriceExcludingTaxes`
|
|
44
|
+
- `UndiscountedItemPriceIncludingTaxes`
|
|
45
|
+
- `ItemPriceExcludingTaxes1`
|
|
46
|
+
- `ItemPriceIncludingTaxes1`
|
|
47
|
+
- `ReferenceByWhichThePackageIsIdentified`
|
|
48
|
+
- `ItemPriceExcludingTaxes`
|
|
49
|
+
- `ItemPriceIncludingTaxes`
|
|
50
|
+
- `NumberOfInstallmentsChosenByTheCustomerForTheOrder`
|
|
51
|
+
- resolving to `boolean` now
|
|
52
|
+
- `TheReturnShipmentHasBeenTriggeredByCCI`
|
|
53
|
+
- `WhetherThePaymentMethodIsAGiftCard`
|
|
54
|
+
- `IfTrueTheCustomerElectedToHaveADelayInPaymentCapture`
|
|
55
|
+
- resolving to `null | number` now
|
|
56
|
+
- `PickingWarehouseId`
|
|
57
|
+
- `WarehousePackageReference`
|
|
58
|
+
- resolving to `null | string` now
|
|
59
|
+
- `ReturnIdentCodeOfTheItem`
|
|
60
|
+
|
|
61
|
+
The interface `ThisFieldHoldsDetailsAboutTheIncludedVATTax` has been removed and `amount: number` and `rate: number` have been directly specified under `Order.cost.appliedFees.tax.vat: {amount: number, rate: number}`.
|
|
62
|
+
Additionally we have introduce the types `OrderAddressRecipientGender` and `OrderAddressRecipientType`, as well as the interfaces `OrderAddress` and `OrderForwardingAddress`.
|
|
63
|
+
|
|
64
|
+
## 8.9.0
|
|
65
|
+
|
|
66
|
+
### Minor Changes
|
|
67
|
+
|
|
68
|
+
- Extend `RpcContext` with an `rpcCall` property. This is a utility function that can be used within RPC methods to invoke another RPC method.
|
|
69
|
+
|
|
3
70
|
## 8.8.0
|
|
4
71
|
|
|
5
72
|
### Minor Changes
|
|
6
73
|
|
|
7
74
|
- Deprecate `RpcContext.campaignKey`. The `getCampaignKey` RPC should be used instead.
|
|
8
75
|
|
|
76
|
+
To get the default campaign key, you can call the RPC method:
|
|
77
|
+
|
|
78
|
+
```typescript
|
|
79
|
+
// Before
|
|
80
|
+
async function rpcMethod(context) {
|
|
81
|
+
const campaignKey = { context }
|
|
82
|
+
// ...
|
|
83
|
+
}
|
|
84
|
+
// After
|
|
85
|
+
async function rpcMethod(context) {
|
|
86
|
+
const campaignKey = await context.callRpc?.('getCampaignKey')
|
|
87
|
+
// ...
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
To override the default campaign key, override the getCampaignKey RPC with your own implementation.
|
|
92
|
+
See [Overriding core RPC Methods](https://scayle.dev/en/storefront-guide/developer-guide/basic-setup/rpc-methods#overriding-core-rpc-methods) for more.
|
|
93
|
+
|
|
9
94
|
## 8.7.1
|
|
10
95
|
|
|
11
96
|
### Patch Changes
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import type { FieldSet, GroupSet } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Flattens each object within a FieldSet.
|
|
4
|
+
*
|
|
5
|
+
* @param fieldSet The FieldSet to flatten.
|
|
6
|
+
*
|
|
7
|
+
* @returns An array of flattened objects.
|
|
8
|
+
*/
|
|
2
9
|
export declare const flattenFieldSet: (fieldSet: FieldSet) => {
|
|
3
10
|
[key: string]: string | number | null | undefined;
|
|
4
11
|
}[][];
|
|
@@ -10,14 +17,34 @@ interface FlattenedMaterialComposition {
|
|
|
10
17
|
material: string;
|
|
11
18
|
}[];
|
|
12
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Transforms an array of material compositions into a flattened structure.
|
|
22
|
+
*
|
|
23
|
+
* @param materialCompositions The material compositions to flatten.
|
|
24
|
+
*
|
|
25
|
+
* @returns An array of flattened material compositions.
|
|
26
|
+
*/
|
|
13
27
|
export declare const getFlattenedMaterialComposition: (materialCompositions: Array<{
|
|
14
28
|
fieldSet: FieldSet;
|
|
15
29
|
groupSet: GroupSet;
|
|
16
30
|
}>) => FlattenedMaterialComposition[];
|
|
31
|
+
/**
|
|
32
|
+
* Flattens an attribute group into a generic array.
|
|
33
|
+
*
|
|
34
|
+
* @param attributeGroup The attribute group to flatten.
|
|
35
|
+
*
|
|
36
|
+
* @returns A generically typed array of flattened attributes.
|
|
37
|
+
*/
|
|
17
38
|
export declare const getFlattenedAdvancedAttribute: <T>(attributeGroup: Array<{
|
|
18
39
|
fieldSet: FieldSet;
|
|
19
40
|
groupSet: GroupSet;
|
|
20
41
|
}>) => T[];
|
|
42
|
+
/**
|
|
43
|
+
* Flattens variant cross-selling data into a generic array. This function uses the `getFlattenedAdvancedAttribute` internally.
|
|
44
|
+
*
|
|
45
|
+
* @param variantCrosssellings The variant cross-selling data to flatten.
|
|
46
|
+
* @returns A generically typed array of flattened variant cross-selling data.
|
|
47
|
+
*/
|
|
21
48
|
export declare const getFlattenedVariantCrosssellings: <T>(variantCrosssellings: Array<{
|
|
22
49
|
fieldSet: FieldSet;
|
|
23
50
|
groupSet: GroupSet;
|
|
@@ -1 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flattens an array of arrays with unknown depth into a single-level array.
|
|
3
|
+
*
|
|
4
|
+
* @param array The array to flatten. Its depth will be treated as up to 20 levels due to current TypeScript limitations on inferring infinite depth.
|
|
5
|
+
*
|
|
6
|
+
* @returns The flattened array.
|
|
7
|
+
*/
|
|
1
8
|
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)[] ? /*elided*/ any : InnerArr : InnerArr : InnerArr : InnerArr : InnerArr : InnerArr : InnerArr : InnerArr : InnerArr : InnerArr : T)[];
|
|
@@ -1,5 +1,37 @@
|
|
|
1
1
|
import type { Attributes } from '@scayle/storefront-api';
|
|
2
|
+
/**
|
|
3
|
+
* Retrieves the first attribute value for a given attribute name from a set of attributes.
|
|
4
|
+
*
|
|
5
|
+
* @param attributes The set of attributes.
|
|
6
|
+
* @param attributeName The name of the attribute to retrieve.
|
|
7
|
+
*
|
|
8
|
+
* @returns The first attribute value, or undefined if not found.
|
|
9
|
+
*/
|
|
2
10
|
export declare const getFirstAttributeValue: (attributes: Attributes | undefined, attributeName: string) => import("@scayle/storefront-api").Value | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* Retrieves the value or label of the first attribute value for a given attribute name.
|
|
13
|
+
*
|
|
14
|
+
* @param attributes The set of attributes.
|
|
15
|
+
* @param attributeName The name of the attribute to retrieve.
|
|
16
|
+
*
|
|
17
|
+
* @returns The value or label of the first attribute value, or null if not found.
|
|
18
|
+
*/
|
|
3
19
|
export declare const getAttributeValue: (attributes: Attributes | undefined, attributeName: string) => string | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Retrieves all attribute values for a given attribute name.
|
|
22
|
+
*
|
|
23
|
+
* @param attributes The set of attributes.
|
|
24
|
+
* @param attributeName The name of the attribute to retrieve.
|
|
25
|
+
*
|
|
26
|
+
* @returns An array of attribute values, or an empty array if not found.
|
|
27
|
+
*/
|
|
4
28
|
export declare const getAttributeValueTuples: (attributes: Attributes | undefined, attributeName: string) => import("@scayle/storefront-api").Value[];
|
|
29
|
+
/**
|
|
30
|
+
* Retrieves the first attribute value for multiple attribute names.
|
|
31
|
+
*
|
|
32
|
+
* @param attributes The set of attributes.
|
|
33
|
+
* @param attributeNames An array of attribute names to retrieve.
|
|
34
|
+
*
|
|
35
|
+
* @returns An array of attribute values, filtered to remove any null or undefined values.
|
|
36
|
+
*/
|
|
5
37
|
export declare const getManyAttributeValueTuples: (attributes: Attributes | undefined, attributeNames: string[]) => import("@scayle/storefront-api").Value[];
|
|
@@ -1,2 +1,9 @@
|
|
|
1
1
|
import type { BasketPackageInformation } from '@scayle/storefront-api';
|
|
2
|
+
/**
|
|
3
|
+
* Extracts the earliest and latest delivery dates from an array of basket package information.
|
|
4
|
+
*
|
|
5
|
+
* @param packages An array of basket package information objects.
|
|
6
|
+
*
|
|
7
|
+
* @returns A tuple containing the earliest and latest delivery dates, or null if no dates are found.
|
|
8
|
+
*/
|
|
2
9
|
export declare const getShippingDates: (packages: BasketPackageInformation[]) => (string | null)[];
|
|
@@ -1,7 +1,45 @@
|
|
|
1
1
|
import type { Category, ProductCategory } from '../types/sapi/category';
|
|
2
2
|
import type { BreadcrumbItem } from '../types/breadcrumb';
|
|
3
|
+
/**
|
|
4
|
+
* Generates breadcrumb items from an array of product categories.
|
|
5
|
+
*
|
|
6
|
+
* @param categories An array of product categories.
|
|
7
|
+
*
|
|
8
|
+
* @returns An array of breadcrumb items.
|
|
9
|
+
*/
|
|
3
10
|
export declare const getBreadcrumbsFromProductCategories: (categories: ProductCategory[] | Category[]) => BreadcrumbItem[];
|
|
11
|
+
/**
|
|
12
|
+
* Generates breadcrumb items from a category object, optionally highlighting an active node.
|
|
13
|
+
*
|
|
14
|
+
* @param category The root category object.
|
|
15
|
+
* @param activeNode The currently active category (optional).
|
|
16
|
+
*
|
|
17
|
+
* @returns An array of breadcrumb items.
|
|
18
|
+
*/
|
|
4
19
|
export declare const getBreadcrumbsFromCategory: (category: Category, activeNode?: Category) => BreadcrumbItem[];
|
|
20
|
+
/**
|
|
21
|
+
* Generates breadcrumb items from a path string.
|
|
22
|
+
*
|
|
23
|
+
* @param path The path string.
|
|
24
|
+
* @param shopLocale The shop locale (optional).
|
|
25
|
+
*
|
|
26
|
+
* @returns An array of breadcrumb items.
|
|
27
|
+
*/
|
|
5
28
|
export declare const getBreadcrumbsFromPath: (path?: string, shopLocale?: string) => BreadcrumbItem[];
|
|
29
|
+
/**
|
|
30
|
+
* Generates breadcrumb items based on either product categories or a single category object.
|
|
31
|
+
*
|
|
32
|
+
* @param categories An array of product categories or a single category object.
|
|
33
|
+
* @param activeNode The currently active category (optional, used only when categories is a single Category object).
|
|
34
|
+
*
|
|
35
|
+
* @returns An array of breadcrumb items.
|
|
36
|
+
*/
|
|
6
37
|
export declare const getBreadcrumbs: (categories: ProductCategory[] | Category, activeNode?: Category) => BreadcrumbItem[];
|
|
38
|
+
/**
|
|
39
|
+
* Extracts the back URL from an array of breadcrumb items.
|
|
40
|
+
*
|
|
41
|
+
* @param breadcrumbs An array of breadcrumb items.
|
|
42
|
+
*
|
|
43
|
+
* @returns The back URL or '/' if breadcrumbs is undefined or empty.
|
|
44
|
+
*/
|
|
7
45
|
export declare const getBackurlFromBreadcrumbs: (breadcrumbs?: BreadcrumbItem[]) => string;
|
|
@@ -7,34 +7,99 @@ export interface TransformedFilter {
|
|
|
7
7
|
value: string | number;
|
|
8
8
|
whereCondition: Record<string, any>;
|
|
9
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* Transforms a set of filter conditions into a where clause suitable for product search queries.
|
|
12
|
+
*
|
|
13
|
+
* @param conditions - The filter conditions to transform.
|
|
14
|
+
*
|
|
15
|
+
* @returns A where clause object.
|
|
16
|
+
*/
|
|
10
17
|
export declare const transformToWhereCondition: (conditions: Record<string, any>) => {
|
|
11
18
|
minPrice?: ProductSearchQuery["minPrice"];
|
|
12
19
|
maxPrice?: ProductSearchQuery["maxPrice"];
|
|
13
20
|
attributes: ProductSearchQuery["attributes"];
|
|
14
21
|
};
|
|
15
22
|
/**
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* This method transforms attribute filters with multiple possible values into a flattened
|
|
19
|
-
* list of filters with one filter entry per possible attribute value
|
|
23
|
+
* Computes an array of filters for rendering quick filters.
|
|
24
|
+
* Transforms attribute filters with multiple values into a flattened list.
|
|
20
25
|
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
26
|
+
* @param filters The available product filters.
|
|
27
|
+
* @param filterableKeys Optional array of keys to limit the generated filters.
|
|
28
|
+
* @param options Options object.
|
|
29
|
+
* @param options.sortable Whether to sort the filters alphabetically by display name. Defaults to true.
|
|
23
30
|
*
|
|
24
|
-
* @
|
|
25
|
-
* @param filterableKeys
|
|
31
|
+
* @returns An array of transformed filters.
|
|
26
32
|
*/
|
|
27
33
|
export declare const groupFilterableValuesByKey: (filters: ProductFilter[], filterableKeys?: string[], { sortable }?: {
|
|
28
34
|
sortable: boolean;
|
|
29
35
|
}) => TransformedFilter[];
|
|
36
|
+
/**
|
|
37
|
+
* Merges an array of transformed filters into a single filter object.
|
|
38
|
+
* This function iterates through the provided filter state, which is an object
|
|
39
|
+
* where each key is a string and the value is an array of `TransformedFilter`
|
|
40
|
+
* objects. It then merges all the transformed filters into a single object,
|
|
41
|
+
* presumably used for querying or filtering data. This implementation
|
|
42
|
+
* addresses a previous issue where array values were not appended correctly,
|
|
43
|
+
* ensuring proper merging of filter criteria.
|
|
44
|
+
*
|
|
45
|
+
* @param state An object representing the filter state. Each key is a string,
|
|
46
|
+
* and the value is an array of `TransformedFilter` objects.
|
|
47
|
+
*
|
|
48
|
+
* @returns A single filter object containing the merged filter criteria from all
|
|
49
|
+
* the provided `TransformedFilter` arrays.
|
|
50
|
+
*/
|
|
30
51
|
export declare const transformStateToFilters: (state: {
|
|
31
52
|
[key: string]: TransformedFilter[];
|
|
32
53
|
}) => any;
|
|
54
|
+
/**
|
|
55
|
+
* Merges an array of filters into a single filter object.
|
|
56
|
+
*
|
|
57
|
+
* @param filters The filters to merge.
|
|
58
|
+
*
|
|
59
|
+
* @returns A merged filter object.
|
|
60
|
+
*/
|
|
33
61
|
export declare const mergeFilters: (filters: TransformedFilter[]) => Record<string, any>;
|
|
62
|
+
/**
|
|
63
|
+
* Checks if a filter is active.
|
|
64
|
+
*
|
|
65
|
+
* @param filters The active filters.
|
|
66
|
+
* @param filterToCheck The filter to check.
|
|
67
|
+
*
|
|
68
|
+
* @returns True if the filter is active, false otherwise.
|
|
69
|
+
*/
|
|
34
70
|
export declare const isFilterActive: (filters: Record<string, any>, filterToCheck: TransformedFilter) => any;
|
|
71
|
+
/**
|
|
72
|
+
* Gets the active filters from a set of filters.
|
|
73
|
+
*
|
|
74
|
+
* @param filters All available filters.
|
|
75
|
+
* @param activeFilters The currently active filters.
|
|
76
|
+
*
|
|
77
|
+
* @returns An array of active filters.
|
|
78
|
+
*/
|
|
35
79
|
export declare const getActiveFilters: (filters: Record<string, any>, activeFilters: Record<string, any>) => TransformedFilter[];
|
|
80
|
+
/**
|
|
81
|
+
* Groups filters by key.
|
|
82
|
+
*
|
|
83
|
+
* @param filters The filters to group.
|
|
84
|
+
*
|
|
85
|
+
* @returns A record of grouped filters.
|
|
86
|
+
*/
|
|
36
87
|
export declare const groupFiltersByKey: (filters: TransformedFilter[]) => [string, TransformedFilter[]][];
|
|
88
|
+
/**
|
|
89
|
+
* Transforms min and max prices into a filter object.
|
|
90
|
+
*
|
|
91
|
+
* @param prices An array containing the min and max prices.
|
|
92
|
+
*
|
|
93
|
+
* @returns A filter object with minPrice and maxPrice.
|
|
94
|
+
*/
|
|
37
95
|
export declare const transformMinAndMaxPriceToFilter: (prices: (CentAmount | undefined)[]) => any;
|
|
96
|
+
/**
|
|
97
|
+
* Transforms a sort string into a filter value.
|
|
98
|
+
*
|
|
99
|
+
* @param sort The sort string.
|
|
100
|
+
*
|
|
101
|
+
* @returns The transformed sort value.
|
|
102
|
+
*/
|
|
38
103
|
export declare const transformSortToFilter: (sort: string) => {
|
|
39
104
|
by: "price";
|
|
40
105
|
direction: "desc";
|
|
@@ -65,21 +130,42 @@ export declare const transformSortToFilter: (sort: string) => {
|
|
|
65
130
|
name: "reduction_asc";
|
|
66
131
|
query: "reduction-asc";
|
|
67
132
|
};
|
|
133
|
+
/**
|
|
134
|
+
* Gets grouped filterable values by keys.
|
|
135
|
+
*
|
|
136
|
+
* @param keys Array of filter keys.
|
|
137
|
+
* @param filterableValues The filterable values for products.
|
|
138
|
+
* @param options Options object.
|
|
139
|
+
* @param options.sortable Whether to sort the values. Defaults to `true`.
|
|
140
|
+
*
|
|
141
|
+
* @returns A record of grouped filterable values.
|
|
142
|
+
*/
|
|
68
143
|
export declare const getGroupedFilterableValues: (keys: Array<string>, filterableValues: ProductFilter[], { sortable }?: {
|
|
69
144
|
sortable: boolean;
|
|
70
145
|
}) => Record<string, TransformedFilter[]>;
|
|
146
|
+
/**
|
|
147
|
+
* Gets the filterable price value (min or max).
|
|
148
|
+
*
|
|
149
|
+
* @param filterableValues The filterable values.
|
|
150
|
+
* @param key Whether to retrieve 'min' or 'max' value. Defaults to 'min'.
|
|
151
|
+
*
|
|
152
|
+
* @returns The min or max price value.
|
|
153
|
+
*/
|
|
71
154
|
export declare const getFilterablePriceValue: (filterableValues: Record<string, any>, key?: "min" | "max") => any;
|
|
72
155
|
export type SerializedFilter = Record<string, string>;
|
|
73
156
|
export type Filter = Record<string, string | number | (string | number | null)[]>;
|
|
74
157
|
/**
|
|
75
158
|
* Converts filter values, within a filter object, into their string representation.
|
|
76
159
|
*
|
|
77
|
-
* @param filter
|
|
160
|
+
* @param filter The filter object to serialize.
|
|
161
|
+
*
|
|
162
|
+
* @returns A serialized filter object or undefined if the input filter is empty.
|
|
78
163
|
*/
|
|
79
164
|
export declare const serializeFilters: (filter: Filter) => SerializedFilter | undefined;
|
|
80
165
|
/**
|
|
81
166
|
* Converts filter values back into their original data type.
|
|
82
167
|
*
|
|
83
|
-
* @param serializedFilter
|
|
168
|
+
* @param serializedFilter The serialized filter object.
|
|
169
|
+
* @returns The deserialized filter object.
|
|
84
170
|
*/
|
|
85
171
|
export declare const deserializeFilters: (serializedFilter: SerializedFilter) => Filter;
|
|
@@ -1,48 +1,81 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* @
|
|
2
|
+
* Converts a date string from DD.MM.YYYY to YYYY-MM-DD format.
|
|
3
|
+
*
|
|
4
|
+
* @param date Date string in DD.MM.YYYY format.
|
|
5
|
+
*
|
|
6
|
+
* @returns Date string in YYYY-MM-DD format, or undefined if input is undefined.
|
|
7
|
+
*
|
|
8
|
+
* @deprecated Validation should be handled within the Storefront project itself.
|
|
5
9
|
*/
|
|
6
10
|
export declare const getPayloadDate: (date: string | undefined) => string | undefined;
|
|
7
11
|
/**
|
|
8
|
-
* Validates a date string
|
|
9
|
-
*
|
|
10
|
-
* @
|
|
12
|
+
* Validates a date string in DD.MM.YYYY format.
|
|
13
|
+
*
|
|
14
|
+
* @param date Date string in DD.MM.YYYY format.
|
|
15
|
+
*
|
|
16
|
+
* @returns True if the date is valid, false otherwise.
|
|
17
|
+
*
|
|
18
|
+
* @deprecated Validation should be handled within the Storefront project itself.
|
|
11
19
|
*/
|
|
12
20
|
export declare const dateValidator: (date: string | undefined) => boolean;
|
|
13
21
|
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
22
|
+
* Formats a date string from YYYY-MM-DD or YYYY-MM-DDThh:mm:ss+xx:yy to DD.MM.YYYY format.
|
|
23
|
+
*
|
|
24
|
+
* @param date Date string in YYYY-MM-DD or YYYY-MM-DDThh:mm:ss+xx:yy format.
|
|
25
|
+
*
|
|
26
|
+
* @returns Formatted date string in DD.MM.YYYY format, or an empty string if input is undefined or invalid.
|
|
27
|
+
*
|
|
28
|
+
* @deprecated Validation should be handled within the Storefront project itself.
|
|
16
29
|
*/
|
|
17
30
|
export declare const formatDate: (date: string | undefined) => string;
|
|
18
31
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* @
|
|
32
|
+
* Formats a date string in DD.MM.YYYY format, adding zero padding to day and month.
|
|
33
|
+
*
|
|
34
|
+
* @param date Date string in DD.MM.YYYY format.
|
|
35
|
+
*
|
|
36
|
+
* @returns Formatted date string, or an empty string if input is undefined or invalid.
|
|
37
|
+
*
|
|
38
|
+
* @deprecated Validation should be handled within the Storefront project itself.
|
|
22
39
|
*/
|
|
23
40
|
export declare const convertDate: (date: string | undefined) => string;
|
|
24
41
|
/**
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* @
|
|
42
|
+
* Converts a phone number from +00 1234 567890 format to 0000/1234567890 format.
|
|
43
|
+
*
|
|
44
|
+
* @param phone Phone number in +00 1234 567890 format.
|
|
45
|
+
*
|
|
46
|
+
* @returns Formatted phone number string, or undefined if input is undefined.
|
|
47
|
+
*
|
|
48
|
+
* @deprecated Validation should be handled within the Storefront project itself.
|
|
28
49
|
*/
|
|
29
50
|
export declare const getPayloadPhone: (phone: string | undefined) => string | undefined;
|
|
30
51
|
/**
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
* @
|
|
52
|
+
* Validates a phone number in +00 1234 567890 format.
|
|
53
|
+
*
|
|
54
|
+
* @param phone Phone number string.
|
|
55
|
+
*
|
|
56
|
+
* @returns True if the phone number is valid, false otherwise.
|
|
57
|
+
*
|
|
58
|
+
* @deprecated Validation should be handled within the Storefront project itself.
|
|
34
59
|
*/
|
|
35
60
|
export declare const phoneValidator: (phone: string | undefined) => boolean;
|
|
36
61
|
/**
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* @
|
|
62
|
+
* Formats a phone number from 0000/1234567890 format to +00 1234 567890 format.
|
|
63
|
+
*
|
|
64
|
+
* @param phone Phone number in 0000/1234567890 format.
|
|
65
|
+
*
|
|
66
|
+
* @returns Formatted phone number string.
|
|
67
|
+
*
|
|
68
|
+
* @deprecated Validation should be handled within the Storefront project itself.
|
|
40
69
|
*/
|
|
41
70
|
export declare const formatPhone: (phone: string | undefined) => string;
|
|
42
71
|
/**
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
* @param
|
|
46
|
-
* @
|
|
72
|
+
* Converts a phone number to +00 1234 567890 format.
|
|
73
|
+
*
|
|
74
|
+
* @param phone Phone number in unknown format.
|
|
75
|
+
* @param internationalPrefix International dial code (defaults to 49 for Germany).
|
|
76
|
+
*
|
|
77
|
+
* @returns Formatted phone number string, or undefined if input is undefined.
|
|
78
|
+
*
|
|
79
|
+
* @deprecated Validation should be handled within the Storefront project itself.
|
|
47
80
|
*/
|
|
48
81
|
export declare const convertPhone: (phone: string | undefined, internationalPrefix?: string) => string | undefined;
|
|
@@ -1,4 +1,22 @@
|
|
|
1
1
|
import type { ProductImageType } from '../constants/product';
|
|
2
2
|
import type { Product, ProductImage } from '../index';
|
|
3
|
+
/**
|
|
4
|
+
* Checks if a product image matches a specific image type.
|
|
5
|
+
*
|
|
6
|
+
* @param type The image type to check against.
|
|
7
|
+
* @param image The product image.
|
|
8
|
+
*
|
|
9
|
+
* @returns True if the image matches the type, false otherwise.
|
|
10
|
+
*/
|
|
3
11
|
export declare function isImageType(type: ProductImageType, image: ProductImage): boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Retrieves an image from a list of product images based on image type and view.
|
|
14
|
+
*
|
|
15
|
+
* @param images The list of product images.
|
|
16
|
+
* @param imageType The desired image type.
|
|
17
|
+
* @param imageView The desired image view.
|
|
18
|
+
* @param fallback Whether to return the first image if no match is found. Defaults to true.
|
|
19
|
+
*
|
|
20
|
+
* @returns The matching product image, the first image if fallback is true and no match is found, or null otherwise.
|
|
21
|
+
*/
|
|
4
22
|
export declare const getImageFromList: (images: Product["images"], imageType: string, imageView: string, fallback?: boolean) => ProductImage | null;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* @param
|
|
5
|
-
* @
|
|
2
|
+
* Gets the default number of fraction digits for a given currency and locale.
|
|
3
|
+
*
|
|
4
|
+
* @param locale The locale (e.g., 'en-GB', 'de-DE', 'cs-CZ').
|
|
5
|
+
* @param currency The currency code (e.g., 'EUR', 'USD', 'INR').
|
|
6
|
+
*
|
|
7
|
+
* @returns The default number of fraction digits. Defaults to 2 if not resolvable.
|
|
6
8
|
*/
|
|
7
9
|
export declare const getDefaultFractionDigits: (locale: string, currency: string) => number;
|
|
@@ -1,19 +1,26 @@
|
|
|
1
1
|
import type { Order } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Retrieves unique items from an order based on variant ID.
|
|
4
|
+
*
|
|
5
|
+
* @param order The order object.
|
|
6
|
+
*
|
|
7
|
+
* @returns An array of unique order items.
|
|
8
|
+
*/
|
|
2
9
|
export declare const getUniqueItemsFromOrder: (order: Order) => {
|
|
3
|
-
id?:
|
|
4
|
-
availableQuantity?:
|
|
5
|
-
currency?:
|
|
10
|
+
id?: string;
|
|
11
|
+
availableQuantity?: number;
|
|
12
|
+
currency?: string;
|
|
6
13
|
customData?: {
|
|
7
14
|
[k: string]: unknown;
|
|
8
15
|
};
|
|
9
16
|
deliveryForecast?: import("../types").DeliveryForecastFromWarehouse;
|
|
10
|
-
isManuallyReturnedByCci?:
|
|
17
|
+
isManuallyReturnedByCci?: boolean;
|
|
11
18
|
itemGroup?: null | {
|
|
12
19
|
id: string;
|
|
13
20
|
isMainItem: boolean;
|
|
14
21
|
isRequired: boolean;
|
|
15
22
|
};
|
|
16
|
-
key:
|
|
23
|
+
key: string;
|
|
17
24
|
lowestPriorPrice?: null | {
|
|
18
25
|
relativeDifferenceToPrice: number;
|
|
19
26
|
withTax: number;
|
|
@@ -26,7 +33,7 @@ export declare const getUniqueItemsFromOrder: (order: Order) => {
|
|
|
26
33
|
price: {
|
|
27
34
|
appliedReductions?: {
|
|
28
35
|
amount: {
|
|
29
|
-
absoluteWithTax:
|
|
36
|
+
absoluteWithTax: number;
|
|
30
37
|
relative: number;
|
|
31
38
|
};
|
|
32
39
|
category: "sale" | "campaign" | "voucher";
|
|
@@ -42,14 +49,14 @@ export declare const getUniqueItemsFromOrder: (order: Order) => {
|
|
|
42
49
|
};
|
|
43
50
|
tax: {
|
|
44
51
|
[k: string]: {
|
|
45
|
-
amount:
|
|
46
|
-
rate:
|
|
52
|
+
amount: number;
|
|
53
|
+
rate: number;
|
|
47
54
|
};
|
|
48
55
|
};
|
|
49
|
-
undiscountedWithOutTax?:
|
|
50
|
-
undiscountedWithTax?:
|
|
51
|
-
withoutTax:
|
|
52
|
-
withTax:
|
|
56
|
+
undiscountedWithOutTax?: number;
|
|
57
|
+
undiscountedWithTax?: number;
|
|
58
|
+
withoutTax: number;
|
|
59
|
+
withTax: number;
|
|
53
60
|
};
|
|
54
61
|
product: {
|
|
55
62
|
[k: string]: unknown;
|
|
@@ -59,9 +66,17 @@ export declare const getUniqueItemsFromOrder: (order: Order) => {
|
|
|
59
66
|
variant: {
|
|
60
67
|
[k: string]: unknown;
|
|
61
68
|
};
|
|
62
|
-
warehouseId?:
|
|
63
|
-
warehousePackageGroupId?:
|
|
64
|
-
createdAt:
|
|
65
|
-
updatedAt:
|
|
69
|
+
warehouseId?: null | number;
|
|
70
|
+
warehousePackageGroupId?: null | number;
|
|
71
|
+
createdAt: string;
|
|
72
|
+
updatedAt: string;
|
|
66
73
|
}[] | undefined;
|
|
74
|
+
/**
|
|
75
|
+
* Gets the quantity of a specific item in an order based on its variant ID.
|
|
76
|
+
*
|
|
77
|
+
* @param order The order object.
|
|
78
|
+
* @param variantId The ID of the variant to count.
|
|
79
|
+
*
|
|
80
|
+
* @returns The quantity of the item in the order, or undefined if the order or items are undefined.
|
|
81
|
+
*/
|
|
67
82
|
export declare const getItemQuantityFromOrder: (order: Order, variantId: number) => number | undefined;
|