@scayle/storefront-core 8.9.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.
Files changed (61) hide show
  1. package/CHANGELOG.md +61 -0
  2. package/dist/helpers/advancedAttributeHelpers.d.ts +27 -0
  3. package/dist/helpers/arrayHelpers.d.ts +7 -0
  4. package/dist/helpers/attributeHelpers.d.ts +32 -0
  5. package/dist/helpers/basketHelpers.d.ts +7 -0
  6. package/dist/helpers/categoryHelper.d.ts +38 -0
  7. package/dist/helpers/filterHelper.d.ts +96 -10
  8. package/dist/helpers/formHelpers.d.ts +57 -24
  9. package/dist/helpers/imageHelpers.d.ts +18 -0
  10. package/dist/helpers/localization.d.ts +6 -4
  11. package/dist/helpers/objectHelpers.d.ts +7 -0
  12. package/dist/helpers/orderHelpers.d.ts +31 -16
  13. package/dist/helpers/productDisruptorHelper.d.ts +43 -0
  14. package/dist/helpers/productHelpers.d.ts +169 -0
  15. package/dist/helpers/sanitizationHelpers.d.ts +61 -0
  16. package/dist/helpers/sortingHelper.d.ts +16 -0
  17. package/dist/helpers/stringHelpers.d.ts +14 -0
  18. package/dist/index.d.ts +1 -1
  19. package/dist/rpc/methods/basket/basket.d.ts +95 -10
  20. package/dist/rpc/methods/brands.d.ts +26 -0
  21. package/dist/rpc/methods/campaign.d.ts +8 -4
  22. package/dist/rpc/methods/categories.d.ts +65 -5
  23. package/dist/rpc/methods/categories.mjs +2 -1
  24. package/dist/rpc/methods/cbd.d.ts +10 -0
  25. package/dist/rpc/methods/checkout/checkout.d.ts +40 -0
  26. package/dist/rpc/methods/checkout/checkout.mjs +1 -1
  27. package/dist/rpc/methods/checkout/order.d.ts +12 -0
  28. package/dist/rpc/methods/checkout/shopUser.d.ts +20 -0
  29. package/dist/rpc/methods/checkout/shopUserAddresses.d.ts +7 -0
  30. package/dist/rpc/methods/navigationTrees.d.ts +27 -0
  31. package/dist/rpc/methods/oauth/idp.d.ts +24 -0
  32. package/dist/rpc/methods/products.d.ts +150 -7
  33. package/dist/rpc/methods/products.mjs +1 -3
  34. package/dist/rpc/methods/promotion.d.ts +46 -4
  35. package/dist/rpc/methods/search.d.ts +17 -12
  36. package/dist/rpc/methods/search.mjs +4 -2
  37. package/dist/rpc/methods/session.d.ts +71 -0
  38. package/dist/rpc/methods/session.mjs +13 -13
  39. package/dist/rpc/methods/shopConfiguration.d.ts +12 -1
  40. package/dist/rpc/methods/shopConfiguration.mjs +2 -1
  41. package/dist/rpc/methods/user.d.ts +34 -4
  42. package/dist/rpc/methods/variants.d.ts +28 -0
  43. package/dist/rpc/methods/wishlist.d.ts +35 -0
  44. package/dist/test/factories/user.d.ts +10 -0
  45. package/dist/types/api/auth.d.ts +67 -0
  46. package/dist/types/api/context.d.ts +61 -0
  47. package/dist/types/api/rpc.d.ts +19 -0
  48. package/dist/types/breadcrumb.d.ts +9 -0
  49. package/dist/types/promises.d.ts +10 -0
  50. package/dist/types/sapi/basket.d.ts +26 -1
  51. package/dist/types/sapi/filter.d.ts +37 -0
  52. package/dist/types/sapi/navigation.d.ts +16 -4
  53. package/dist/types/sapi/order.d.ts +137 -242
  54. package/dist/types/sapi/product.d.ts +85 -0
  55. package/dist/types/sapi/productFilter.d.ts +14 -0
  56. package/dist/types/sapi/router.d.ts +3 -0
  57. package/dist/types/sapi/search.d.ts +19 -0
  58. package/dist/types/sapi/sorting.d.ts +7 -0
  59. package/dist/types/sapi/wishlist.d.ts +6 -0
  60. package/dist/types/user.d.ts +102 -0
  61. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,66 @@
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
+
3
64
  ## 8.9.0
4
65
 
5
66
  ### Minor 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
- * Compute an array of filters that can be used to render the quick filters, for example.
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
- * By providing filterableKeys you can limit the generated list of filters to specific
22
- * keys you would like to filter by.
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
- * @param filters
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
- * Returns date in YYYY-MM-DD format
3
- * @param date in DD.MM.YYYY format
4
- * @returns formatted date string
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
- * @param date in DD.MM.YYYY format
10
- * @returns boolean
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
- * @param date in YYYY-MM-DD or YYYY-MM-DDThh:mm:ss+xx:yy format
15
- * @returns formatted date string in DD.MM.YYYY format
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
- * Returns formatted date after adding 0 padding to day and month
20
- * @param date in in DD.MM.YYYY format
21
- * @returns formatted date string
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
- * Returns phone number in 0000/1234567890 format
26
- * @param phone in +00 1234 567890 format
27
- * @returns formatted phone number string
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
- * Returns phone number in 0000/1234567890 format
32
- * @param phone in +00 1234 567890 format
33
- * @returns formatted phone number string
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
- * Returns phone number in +00 1234 567890 format
38
- * @param phone in 0000/1234567890 format
39
- * @returns formatted phone number string
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
- * Returns phone number in +00 1234 567890 format
44
- * @param phone in unknown format
45
- * @param internationalPrefix international dial code, defaults to 49 (Germany)
46
- * @returns formatted phone number string
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
- * Get default number of fraction digits of a currency
3
- * @param locale {String} - Locale, eg 'en-GB', 'de-DE', 'cs-CZ'
4
- * @param currency {String} - Currency like 'EUR', 'USD', 'INR'
5
- * @returns number
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 +1,8 @@
1
+ /**
2
+ * Flattens a nested object into a single-level object.
3
+ *
4
+ * @param object The object to flatten.
5
+ *
6
+ * @returns The flattened object.
7
+ */
1
8
  export declare const flattenObject: <T extends Record<string, any>>(object: T) => T;
@@ -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?: import("../types").UniqueNumericIdentifierOfTheItem;
4
- availableQuantity?: import("../types").AvailableQuantityInTheWarehouse;
5
- currency?: import("../types").CharacterCurrencyCode1;
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?: import("../types").TheReturnShipmentHasBeenTriggeredByCCI;
17
+ isManuallyReturnedByCci?: boolean;
11
18
  itemGroup?: null | {
12
19
  id: string;
13
20
  isMainItem: boolean;
14
21
  isRequired: boolean;
15
22
  };
16
- key: import("../types").UniqueIdentifierOfTheItem;
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: import("../types").ThisFieldRepresentsTheDiscountAmountIncludingTheTaxes1;
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: import("../types").AbsoluteValueOfTheAppliedTax1;
46
- rate: import("../types").RelativeValueOfTheAppliedTax;
52
+ amount: number;
53
+ rate: number;
47
54
  };
48
55
  };
49
- undiscountedWithOutTax?: import("../types").UndiscountedItemPriceExcludingTaxes;
50
- undiscountedWithTax?: import("../types").UndiscountedItemPriceIncludingTaxes;
51
- withoutTax: import("../types").ItemPriceExcludingTaxes1;
52
- withTax: import("../types").ItemPriceIncludingTaxes1;
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?: import("../types").PickingWarehouseId;
63
- warehousePackageGroupId?: import("../types").WarehousePackageReference;
64
- createdAt: import("../types").TimestampOfItemCreation;
65
- updatedAt: import("../types").TimestampOfLastItemUpdate;
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;
@@ -1,10 +1,53 @@
1
+ /**
2
+ * Calculates the row index for an item given its overall index and pagination options.
3
+ *
4
+ * @param index The overall index of the item.
5
+ * @param options Pagination options. Defaults to 2 columns, page 1, and 24 items per page.
6
+ * @param options.columns
7
+ * @param options.page
8
+ * @param options.perPage
9
+ *
10
+ * @returns The calculated row index.
11
+ *
12
+ * @deprecated Row Disruption and associated functionality should be handled within the Storefront project itself.
13
+ */
1
14
  export declare const getRowByIndex: (index: number, options?: {
2
15
  columns: number;
3
16
  page: number;
4
17
  perPage: number;
5
18
  }) => number;
19
+ /**
20
+ * Filters disruptors for a specific row.
21
+ *
22
+ * @param row The row number.
23
+ * @param disruptors An array of disruptor objects.
24
+ *
25
+ * @returns An array of disruptors belonging to the specified row.
26
+ *
27
+ * @deprecated Row Disruption and associated functionality should be handled within the Storefront project itself.
28
+ */
6
29
  export declare const getDisruptorsForRow: (row: number, disruptors: {
7
30
  insert_in_row: string;
8
31
  }[]) => object[];
32
+ /**
33
+ * Checks if the given index is the first index of a row.
34
+ *
35
+ * @param index The index to check.
36
+ * @param columns The number of columns.
37
+ *
38
+ * @returns True if the index is the first of a row, false otherwise.
39
+ *
40
+ * @deprecated Row Disruption and associated functionality should be handled within the Storefront project itself.
41
+ */
9
42
  export declare const isFirstIndexOfRow: (index: number, columns: number) => boolean;
43
+ /**
44
+ * Checks if a disruptor exists at a specific row.
45
+ *
46
+ * @param row The row number.
47
+ * @param disruptorRows An array of disruptor row numbers as strings.
48
+ *
49
+ * @returns True if a disruptor exists at the specified row, false otherwise.
50
+ *
51
+ * @deprecated Row Disruption and associated functionality should be handled within the Storefront project itself.
52
+ */
10
53
  export declare const hasDisruptorAtRow: (row: number, disruptorRows: string[]) => boolean;