@scayle/storefront-core 8.16.0 → 8.17.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 +16 -0
- package/dist/cache/cached.d.ts +1 -1
- package/dist/cache/cached.mjs +1 -1
- package/dist/helpers/advancedAttributeHelpers.d.ts +1 -3
- package/dist/helpers/arrayHelpers.d.ts +12 -3
- package/dist/helpers/attributeHelpers.d.ts +4 -4
- package/dist/helpers/basketHelpers.d.ts +1 -1
- package/dist/helpers/filterHelper.d.ts +5 -34
- package/dist/helpers/orderHelpers.d.ts +2 -2
- package/dist/helpers/productHelpers.d.ts +5 -5
- package/dist/helpers/productHelpers.mjs +6 -0
- package/dist/helpers/sortingHelper.d.ts +4 -63
- package/dist/index.d.ts +1 -1
- package/dist/rpc/methods/basket/basket.d.ts +2 -13
- package/dist/rpc/methods/checkout/checkout.mjs +1 -1
- package/dist/rpc/methods/wishlist.mjs +9 -7
- package/dist/test/factories/user.d.ts +1 -1
- package/dist/utils/hash.d.ts +1 -1
- package/dist/utils/log.d.ts +1 -1
- package/dist/utils/timeout.d.ts +1 -1
- package/dist/utils/user.d.ts +3 -13
- package/package.json +3 -3
- package/dist/helpers/product.fixture.d.ts +0 -415
- package/dist/helpers/product.fixture.mjs +0 -838
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @scayle/storefront-core
|
|
2
2
|
|
|
3
|
+
## 8.17.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Ensure that the `getAttribute` helper function can handle multi-value attributes.
|
|
8
|
+
|
|
9
|
+
## 8.17.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- Fix return type of `RpcMethodCall` to reflect that it returns a `Promise<TResult>` instead of `TResult`. This change emphasizes that `callRpc` in `RpcContext` is indeed an asynchronous operation.
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- Ensure that `pricePromotionKey` set in the right place when calling the deletion wishlist item operation of SAPI.
|
|
18
|
+
|
|
3
19
|
## 8.16.0
|
|
4
20
|
|
|
5
21
|
## 8.15.1
|
package/dist/cache/cached.d.ts
CHANGED
package/dist/cache/cached.mjs
CHANGED
|
@@ -6,9 +6,7 @@ import type { FieldSet, GroupSet } from '../types';
|
|
|
6
6
|
*
|
|
7
7
|
* @returns An array of flattened objects.
|
|
8
8
|
*/
|
|
9
|
-
export declare const flattenFieldSet: (fieldSet: FieldSet) =>
|
|
10
|
-
[key: string]: string | number | null | undefined;
|
|
11
|
-
}[][];
|
|
9
|
+
export declare const flattenFieldSet: (fieldSet: FieldSet) => FieldSet;
|
|
12
10
|
interface FlattenedMaterialComposition {
|
|
13
11
|
materialGroupName?: string;
|
|
14
12
|
values: {
|
|
@@ -1,8 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Recursive helper type to extract the innermost non-array element types from T.
|
|
3
|
+
* Handles nested arrays and unions of arrays/non-arrays.
|
|
4
|
+
*/
|
|
5
|
+
type FlattenElement<T> = T extends ReadonlyArray<infer U> ? FlattenElement<U> : T;
|
|
1
6
|
/**
|
|
2
7
|
* Flattens an array of arrays with unknown depth into a single-level array.
|
|
3
8
|
*
|
|
4
|
-
* @
|
|
9
|
+
* @template T The type of the potentially nested array. Must extend `readonly unknown[]`.
|
|
10
|
+
*
|
|
11
|
+
* @param array The array to flatten.
|
|
5
12
|
*
|
|
6
|
-
* @returns
|
|
13
|
+
* @returns A new, single-level array containing all the innermost elements
|
|
14
|
+
* extracted from the input array. The element type is inferred recursively.
|
|
7
15
|
*/
|
|
8
|
-
export declare const flattenDeep: <T extends unknown
|
|
16
|
+
export declare const flattenDeep: <T extends ReadonlyArray<unknown>>(array: T) => FlattenElement<T>[];
|
|
17
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Attributes } from '@scayle/storefront-api';
|
|
1
|
+
import type { Attributes, Value } from '@scayle/storefront-api';
|
|
2
2
|
/**
|
|
3
3
|
* Retrieves the first attribute value for a given attribute name from a set of attributes.
|
|
4
4
|
*
|
|
@@ -7,7 +7,7 @@ import type { Attributes } from '@scayle/storefront-api';
|
|
|
7
7
|
*
|
|
8
8
|
* @returns The first attribute value, or undefined if not found.
|
|
9
9
|
*/
|
|
10
|
-
export declare const getFirstAttributeValue: (attributes: Attributes | undefined, attributeName: string) =>
|
|
10
|
+
export declare const getFirstAttributeValue: (attributes: Attributes | undefined, attributeName: string) => Value | undefined;
|
|
11
11
|
/**
|
|
12
12
|
* Retrieves the value or label of the first attribute value for a given attribute name.
|
|
13
13
|
*
|
|
@@ -25,7 +25,7 @@ export declare const getAttributeValue: (attributes: Attributes | undefined, att
|
|
|
25
25
|
*
|
|
26
26
|
* @returns An array of attribute values, or an empty array if not found.
|
|
27
27
|
*/
|
|
28
|
-
export declare const getAttributeValueTuples: (attributes: Attributes | undefined, attributeName: string) =>
|
|
28
|
+
export declare const getAttributeValueTuples: (attributes: Attributes | undefined, attributeName: string) => Value[];
|
|
29
29
|
/**
|
|
30
30
|
* Retrieves the first attribute value for multiple attribute names.
|
|
31
31
|
*
|
|
@@ -34,4 +34,4 @@ export declare const getAttributeValueTuples: (attributes: Attributes | undefine
|
|
|
34
34
|
*
|
|
35
35
|
* @returns An array of attribute values, filtered to remove any null or undefined values.
|
|
36
36
|
*/
|
|
37
|
-
export declare const getManyAttributeValueTuples: (attributes: Attributes | undefined, attributeNames: string[]) =>
|
|
37
|
+
export declare const getManyAttributeValueTuples: (attributes: Attributes | undefined, attributeNames: string[]) => Value[];
|
|
@@ -6,4 +6,4 @@ import type { BasketPackageInformation } from '@scayle/storefront-api';
|
|
|
6
6
|
*
|
|
7
7
|
* @returns A tuple containing the earliest and latest delivery dates, or null if no dates are found.
|
|
8
8
|
*/
|
|
9
|
-
export declare const getShippingDates: (packages: BasketPackageInformation[]) =>
|
|
9
|
+
export declare const getShippingDates: (packages: BasketPackageInformation[]) => [string | null, string | null];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CentAmount, ProductSearchQuery } from '@scayle/storefront-api';
|
|
2
|
-
import type { ProductFilter } from '../types';
|
|
2
|
+
import type { ProductFilter, SortValue } from '../types';
|
|
3
3
|
export interface TransformedFilter {
|
|
4
4
|
key: string;
|
|
5
5
|
displayName: string;
|
|
@@ -50,7 +50,7 @@ export declare const groupFilterableValuesByKey: (filters: ProductFilter[], filt
|
|
|
50
50
|
*/
|
|
51
51
|
export declare const transformStateToFilters: (state: {
|
|
52
52
|
[key: string]: TransformedFilter[];
|
|
53
|
-
}) => any
|
|
53
|
+
}) => Record<string, any>;
|
|
54
54
|
/**
|
|
55
55
|
* Merges an array of filters into a single filter object.
|
|
56
56
|
*
|
|
@@ -67,7 +67,7 @@ export declare const mergeFilters: (filters: TransformedFilter[]) => Record<stri
|
|
|
67
67
|
*
|
|
68
68
|
* @returns True if the filter is active, false otherwise.
|
|
69
69
|
*/
|
|
70
|
-
export declare const isFilterActive: (filters: Record<string, any>, filterToCheck: TransformedFilter) =>
|
|
70
|
+
export declare const isFilterActive: (filters: Record<string, any>, filterToCheck: TransformedFilter) => boolean;
|
|
71
71
|
/**
|
|
72
72
|
* Gets the active filters from a set of filters.
|
|
73
73
|
*
|
|
@@ -100,36 +100,7 @@ export declare const transformMinAndMaxPriceToFilter: (prices: (CentAmount | und
|
|
|
100
100
|
*
|
|
101
101
|
* @returns The transformed sort value.
|
|
102
102
|
*/
|
|
103
|
-
export declare const transformSortToFilter: (sort: string) =>
|
|
104
|
-
by: "price";
|
|
105
|
-
direction: "desc";
|
|
106
|
-
name: "topseller";
|
|
107
|
-
query: "topseller";
|
|
108
|
-
} | {
|
|
109
|
-
by: "new";
|
|
110
|
-
name: "date_newest";
|
|
111
|
-
query: "date-newest";
|
|
112
|
-
} | {
|
|
113
|
-
by: "price";
|
|
114
|
-
direction: "desc";
|
|
115
|
-
name: "price_desc";
|
|
116
|
-
query: "price-desc";
|
|
117
|
-
} | {
|
|
118
|
-
by: "price";
|
|
119
|
-
direction: "asc";
|
|
120
|
-
name: "price_asc";
|
|
121
|
-
query: "price-asc";
|
|
122
|
-
} | {
|
|
123
|
-
by: "reduction";
|
|
124
|
-
direction: "desc";
|
|
125
|
-
name: "reduction_desc";
|
|
126
|
-
query: "reduction-desc";
|
|
127
|
-
} | {
|
|
128
|
-
by: "reduction";
|
|
129
|
-
direction: "asc";
|
|
130
|
-
name: "reduction_asc";
|
|
131
|
-
query: "reduction-asc";
|
|
132
|
-
};
|
|
103
|
+
export declare const transformSortToFilter: (sort: string) => SortValue;
|
|
133
104
|
/**
|
|
134
105
|
* Gets grouped filterable values by keys.
|
|
135
106
|
*
|
|
@@ -151,7 +122,7 @@ export declare const getGroupedFilterableValues: (keys: Array<string>, filterabl
|
|
|
151
122
|
*
|
|
152
123
|
* @returns The min or max price value.
|
|
153
124
|
*/
|
|
154
|
-
export declare const getFilterablePriceValue: (filterableValues: Record<string, any>, key?: "min" | "max") =>
|
|
125
|
+
export declare const getFilterablePriceValue: (filterableValues: Record<string, any>, key?: "min" | "max") => CentAmount;
|
|
155
126
|
export type SerializedFilter = Record<string, string>;
|
|
156
127
|
export type Filter = Record<string, string | number | (string | number | null)[]>;
|
|
157
128
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Order } from '../types';
|
|
1
|
+
import type { Order, OrderItem } from '../types';
|
|
2
2
|
/**
|
|
3
3
|
* Retrieves unique items from an order based on variant ID.
|
|
4
4
|
*
|
|
@@ -8,7 +8,7 @@ import type { Order } from '../types';
|
|
|
8
8
|
*
|
|
9
9
|
* @deprecated getting unique items from order should be handled within the Storefront project itself.
|
|
10
10
|
*/
|
|
11
|
-
export declare const getUniqueItemsFromOrder: <P, V>(order: Order<P, V>) =>
|
|
11
|
+
export declare const getUniqueItemsFromOrder: <P, V>(order: Order<P, V>) => OrderItem<P, V>[] | undefined;
|
|
12
12
|
/**
|
|
13
13
|
* Gets the quantity of a specific item in an order based on its variant ID.
|
|
14
14
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AppliedReduction, BasketItemPrice, Product, Value, Variant, VariantPrice } from '@scayle/storefront-api';
|
|
1
|
+
import type { AppliedReduction, BasketItemPrice, Product, ProductCategory, Value, Variant, VariantPrice } from '@scayle/storefront-api';
|
|
2
2
|
import type { ProductSibling } from '../types/sapi/product';
|
|
3
3
|
interface Route {
|
|
4
4
|
path?: string;
|
|
@@ -97,7 +97,7 @@ export declare const getVariant: (variants: Variant[], id: number) => Variant |
|
|
|
97
97
|
*
|
|
98
98
|
* @returns An array of unique size values.
|
|
99
99
|
*/
|
|
100
|
-
export declare const getAllSizesFromVariants: (variantsAttributes: Variant[], attributeName?: string) =>
|
|
100
|
+
export declare const getAllSizesFromVariants: (variantsAttributes: Variant[], attributeName?: string) => Value[];
|
|
101
101
|
/**
|
|
102
102
|
* Retrieves product siblings including the product itself.
|
|
103
103
|
* Filters out inactive siblings.
|
|
@@ -161,7 +161,7 @@ export declare const isVariantInStock: (variants: Variant[], size: Value, sizeAt
|
|
|
161
161
|
*
|
|
162
162
|
* @returns The attribute value.
|
|
163
163
|
*/
|
|
164
|
-
export declare const getAttribute: (product: Product, key: string) =>
|
|
164
|
+
export declare const getAttribute: (product: Product, key: string) => string | undefined;
|
|
165
165
|
/**
|
|
166
166
|
* Generates the product path based on product name and id
|
|
167
167
|
*
|
|
@@ -178,7 +178,7 @@ export declare const getProductPath: (product: Product) => string;
|
|
|
178
178
|
*
|
|
179
179
|
* @returns An array of categories.
|
|
180
180
|
*/
|
|
181
|
-
export declare const getCategoriesByRoute: (product: Product | null, route: Route | null) =>
|
|
181
|
+
export declare const getCategoriesByRoute: (product: Product | null, route: Route | null) => ProductCategory[];
|
|
182
182
|
/**
|
|
183
183
|
* Retrieves the latest/deepest category from product categories
|
|
184
184
|
*
|
|
@@ -186,7 +186,7 @@ export declare const getCategoriesByRoute: (product: Product | null, route: Rout
|
|
|
186
186
|
*
|
|
187
187
|
* @returns The latest category object or undefined
|
|
188
188
|
*/
|
|
189
|
-
export declare const getLatestCategory: (categories?: Product["categories"]) =>
|
|
189
|
+
export declare const getLatestCategory: (categories?: Product["categories"]) => ProductCategory | undefined;
|
|
190
190
|
/**
|
|
191
191
|
* Retrieves colors from a product and its siblings
|
|
192
192
|
*
|
|
@@ -92,6 +92,12 @@ export const isVariantInStock = (variants, size, sizeAttributeName = "shopSize")
|
|
|
92
92
|
};
|
|
93
93
|
export const getAttribute = (product, key) => {
|
|
94
94
|
const values = product.attributes?.[key]?.values;
|
|
95
|
+
if (!values) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
if (Array.isArray(values)) {
|
|
99
|
+
return values[0]?.value ?? values[0]?.label;
|
|
100
|
+
}
|
|
95
101
|
return values?.value ?? values?.label;
|
|
96
102
|
};
|
|
97
103
|
export const getProductPath = (product) => {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { Query
|
|
1
|
+
import type { Query } from '../index';
|
|
2
|
+
import type { SortingValueKey, SortValue } from '../types/sapi/sorting';
|
|
2
3
|
/**
|
|
3
4
|
* Retrieves a subset of sorting values based on the provided keys.
|
|
4
5
|
* Filters out invalid keys and returns an object mapping valid keys to their sorting configurations.
|
|
@@ -7,38 +8,7 @@ import type { Query, SortingValueKey } from '../index';
|
|
|
7
8
|
*
|
|
8
9
|
* @returns An object mapping valid sorting keys to their configurations.
|
|
9
10
|
*/
|
|
10
|
-
export declare const getSortingValues: (options?:
|
|
11
|
-
[k: string]: {
|
|
12
|
-
by: "price";
|
|
13
|
-
direction: "desc";
|
|
14
|
-
name: "topseller";
|
|
15
|
-
query: "topseller";
|
|
16
|
-
} | {
|
|
17
|
-
by: "new";
|
|
18
|
-
name: "date_newest";
|
|
19
|
-
query: "date-newest";
|
|
20
|
-
} | {
|
|
21
|
-
by: "price";
|
|
22
|
-
direction: "desc";
|
|
23
|
-
name: "price_desc";
|
|
24
|
-
query: "price-desc";
|
|
25
|
-
} | {
|
|
26
|
-
by: "price";
|
|
27
|
-
direction: "asc";
|
|
28
|
-
name: "price_asc";
|
|
29
|
-
query: "price-asc";
|
|
30
|
-
} | {
|
|
31
|
-
by: "reduction";
|
|
32
|
-
direction: "desc";
|
|
33
|
-
name: "reduction_desc";
|
|
34
|
-
query: "reduction-desc";
|
|
35
|
-
} | {
|
|
36
|
-
by: "reduction";
|
|
37
|
-
direction: "asc";
|
|
38
|
-
name: "reduction_asc";
|
|
39
|
-
query: "reduction-asc";
|
|
40
|
-
};
|
|
41
|
-
};
|
|
11
|
+
export declare const getSortingValues: (options?: SortingValueKey[]) => Record<SortingValueKey, SortValue>;
|
|
42
12
|
/**
|
|
43
13
|
* Retrieves the sorting configuration based on the provided query.
|
|
44
14
|
*
|
|
@@ -47,33 +17,4 @@ export declare const getSortingValues: (options?: Array<SortingValueKey>) => {
|
|
|
47
17
|
*
|
|
48
18
|
* @returns The sorting configuration object corresponding to the query or the default sort.
|
|
49
19
|
*/
|
|
50
|
-
export declare const getSortByValue: (query: Query, defaultSort?: SortingValueKey) =>
|
|
51
|
-
by: "price";
|
|
52
|
-
direction: "desc";
|
|
53
|
-
name: "topseller";
|
|
54
|
-
query: "topseller";
|
|
55
|
-
} | {
|
|
56
|
-
by: "new";
|
|
57
|
-
name: "date_newest";
|
|
58
|
-
query: "date-newest";
|
|
59
|
-
} | {
|
|
60
|
-
by: "price";
|
|
61
|
-
direction: "desc";
|
|
62
|
-
name: "price_desc";
|
|
63
|
-
query: "price-desc";
|
|
64
|
-
} | {
|
|
65
|
-
by: "price";
|
|
66
|
-
direction: "asc";
|
|
67
|
-
name: "price_asc";
|
|
68
|
-
query: "price-asc";
|
|
69
|
-
} | {
|
|
70
|
-
by: "reduction";
|
|
71
|
-
direction: "desc";
|
|
72
|
-
name: "reduction_desc";
|
|
73
|
-
query: "reduction-desc";
|
|
74
|
-
} | {
|
|
75
|
-
by: "reduction";
|
|
76
|
-
direction: "asc";
|
|
77
|
-
name: "reduction_asc";
|
|
78
|
-
query: "reduction-asc";
|
|
79
|
-
};
|
|
20
|
+
export declare const getSortByValue: (query: Query, defaultSort?: SortingValueKey) => SortValue;
|
package/dist/index.d.ts
CHANGED
|
@@ -67,5 +67,5 @@ export type RpcMethodParameters<N extends RpcMethodName> = Parameters<RpcMethod<
|
|
|
67
67
|
* @template N The name of the RPC method.
|
|
68
68
|
*/
|
|
69
69
|
export type RpcMethodReturnType<N extends RpcMethodName> = ReturnType<RpcMethod<N>>;
|
|
70
|
-
export type RpcMethodCall = <N extends RpcMethodName, P extends RpcMethodParameters<N>, TResult extends Exclude<Awaited<RpcMethodReturnType<N>>, Response>>(...args: P extends RpcContext ? [N] : [N, P]) => TResult
|
|
70
|
+
export type RpcMethodCall = <N extends RpcMethodName, P extends RpcMethodParameters<N>, TResult extends Exclude<Awaited<RpcMethodReturnType<N>>, Response>>(...args: P extends RpcContext ? [N] : [N, P]) => Promise<TResult>;
|
|
71
71
|
export { ExistingItemHandling, AddToBasketFailureKind, UpdateBasketItemFailureKind, AddToWishlistFailureKind, PromotionEffectType, FilterTypes, APISortOption, APISortOrder, type ProductSortConfig, } from '@scayle/storefront-api';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ExistingItemHandling } from '@scayle/storefront-api';
|
|
2
|
-
import type { AddOrUpdateItemError, UpdateBasketItemQuantity } from '@scayle/storefront-api';
|
|
2
|
+
import type { AddManyItemsBasketResponse, AddOrUpdateItemError, BasketResponse, UpdateBasketItemQuantity } from '@scayle/storefront-api';
|
|
3
3
|
import { ErrorResponse } from '../../../errors';
|
|
4
4
|
import type { AddOrUpdateItemType, BasketResponseData, BasketWithOptions, Product, RpcContext, Variant } from '../../../types';
|
|
5
5
|
/**
|
|
@@ -116,18 +116,7 @@ export declare const mergeBaskets: ({ fromBasketKey, toBasketKey, with: _with, o
|
|
|
116
116
|
toBasketKey: string;
|
|
117
117
|
with?: BasketWithOptions;
|
|
118
118
|
orderCustomData?: Record<string, unknown>;
|
|
119
|
-
}, context: RpcContext) => Promise<
|
|
120
|
-
type: "failure";
|
|
121
|
-
statusCode: number;
|
|
122
|
-
basket: BasketResponseData<Product, Variant>;
|
|
123
|
-
} | {
|
|
124
|
-
readonly type: "success";
|
|
125
|
-
readonly basket: BasketResponseData<Product, Variant>;
|
|
126
|
-
} | {
|
|
127
|
-
readonly type: "failure";
|
|
128
|
-
readonly basket: BasketResponseData<Product, Variant>;
|
|
129
|
-
readonly errors: AddOrUpdateItemError[];
|
|
130
|
-
} | undefined>;
|
|
119
|
+
}, context: RpcContext) => Promise<BasketResponse<Product, Variant> | AddManyItemsBasketResponse<Product, Variant> | undefined>;
|
|
131
120
|
/**
|
|
132
121
|
* Type defining an object containing properties of a basket item than should be
|
|
133
122
|
* applied to the basket item during the update.
|
|
@@ -36,7 +36,7 @@ export const getCheckoutToken = async function getCheckoutToken2(jwtPayload = {}
|
|
|
36
36
|
carrier,
|
|
37
37
|
basketId: context.basketKey,
|
|
38
38
|
campaignKey
|
|
39
|
-
}).setIssuedAt(now).setNotBefore(now).setExpirationTime("1h").setIssuer(`${"@scayle/storefront-core"}@${"8.
|
|
39
|
+
}).setIssuedAt(now).setNotBefore(now).setExpirationTime("1h").setIssuer(`${"@scayle/storefront-core"}@${"8.17.1"}`).setProtectedHeader({ alg: "HS256", typ: "JWT" }).sign(secret);
|
|
40
40
|
return {
|
|
41
41
|
accessToken: refreshedAccessToken,
|
|
42
42
|
checkoutJwt
|
|
@@ -20,13 +20,15 @@ export const getWishlist = async function getWishlist2(options, context) {
|
|
|
20
20
|
}
|
|
21
21
|
const { sapiClient, wishlistKey } = context;
|
|
22
22
|
const campaignKey = await context.callRpc?.("getCampaignKey");
|
|
23
|
-
const resolvedWith = getWithParams({
|
|
23
|
+
const { pricePromotionKey, ...resolvedWith } = getWithParams({
|
|
24
|
+
with: options
|
|
25
|
+
}, context);
|
|
24
26
|
return await mapSAPIFetchErrorToResponse(sapiClient.wishlist.get)(
|
|
25
27
|
wishlistKey,
|
|
26
28
|
{
|
|
27
29
|
with: resolvedWith,
|
|
28
30
|
campaignKey,
|
|
29
|
-
pricePromotionKey:
|
|
31
|
+
pricePromotionKey: pricePromotionKey ?? ""
|
|
30
32
|
}
|
|
31
33
|
);
|
|
32
34
|
};
|
|
@@ -41,8 +43,7 @@ export const addItemToWishlist = async function addItemToWishlist2(options, cont
|
|
|
41
43
|
const { sapiClient, wishlistKey } = context;
|
|
42
44
|
const campaignKey = await context.callRpc?.("getCampaignKey");
|
|
43
45
|
const { productId, variantId } = options;
|
|
44
|
-
const resolvedWith = getWithParams(options, context);
|
|
45
|
-
const pricePromotionKey = resolvedWith?.pricePromotionKey ?? "";
|
|
46
|
+
const { pricePromotionKey, ...resolvedWith } = getWithParams(options, context);
|
|
46
47
|
if (!productId && !variantId) {
|
|
47
48
|
return new ErrorResponse(
|
|
48
49
|
HttpStatusCode.BAD_REQUEST,
|
|
@@ -56,7 +57,7 @@ export const addItemToWishlist = async function addItemToWishlist2(options, cont
|
|
|
56
57
|
{
|
|
57
58
|
with: resolvedWith,
|
|
58
59
|
campaignKey,
|
|
59
|
-
pricePromotionKey
|
|
60
|
+
pricePromotionKey: pricePromotionKey ?? ""
|
|
60
61
|
}
|
|
61
62
|
);
|
|
62
63
|
if (result.type === "success") {
|
|
@@ -77,13 +78,14 @@ export const removeItemFromWishlist = async function removeItemFromWishlist2(opt
|
|
|
77
78
|
}
|
|
78
79
|
const { sapiClient, wishlistKey } = context;
|
|
79
80
|
const campaignKey = await context.callRpc?.("getCampaignKey");
|
|
80
|
-
const resolvedWith = getWithParams(options, context);
|
|
81
|
+
const { pricePromotionKey, ...resolvedWith } = getWithParams(options, context);
|
|
81
82
|
return await mapSAPIFetchErrorToResponse(sapiClient.wishlist.deleteItem)(
|
|
82
83
|
wishlistKey,
|
|
83
84
|
options.itemKey,
|
|
84
85
|
{
|
|
85
86
|
with: resolvedWith,
|
|
86
|
-
campaignKey
|
|
87
|
+
campaignKey,
|
|
88
|
+
pricePromotionKey: pricePromotionKey ?? ""
|
|
87
89
|
}
|
|
88
90
|
);
|
|
89
91
|
};
|
|
@@ -10,4 +10,4 @@ import type { ShopUser } from '../../types';
|
|
|
10
10
|
* const multipleUsers = userFactory.buildList(5) // Generates an array of 5 ShopUser objects.
|
|
11
11
|
* ```
|
|
12
12
|
*/
|
|
13
|
-
export declare const userFactory: Factory<ShopUser
|
|
13
|
+
export declare const userFactory: Factory<ShopUser>;
|
package/dist/utils/hash.d.ts
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
*
|
|
11
11
|
* @throws {Error} If SFC is built without MD5 support (SFC_OMIT_MD5 environment variable is set).
|
|
12
12
|
*/
|
|
13
|
-
export declare const md5: (value: string) => Promise<
|
|
13
|
+
export declare const md5: (value: string) => Promise<string>;
|
|
14
14
|
/**
|
|
15
15
|
* Calculates the SHA256 hash of a string.
|
|
16
16
|
*
|
package/dist/utils/log.d.ts
CHANGED
|
@@ -95,7 +95,7 @@ export declare class Log {
|
|
|
95
95
|
*
|
|
96
96
|
* @returns A Promise that resolves with the result of the timed function.
|
|
97
97
|
*/
|
|
98
|
-
time(message: string, func: () =>
|
|
98
|
+
time<T = any>(message: string, func: () => T): Promise<T>;
|
|
99
99
|
/**
|
|
100
100
|
* Attaches the log instance to a request object.
|
|
101
101
|
* This is typically used in server middleware.
|
package/dist/utils/timeout.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*
|
|
6
6
|
* @returns A Promise that resolves after the specified delay.
|
|
7
7
|
*/
|
|
8
|
-
export declare const wait: (ms: number) => Promise<
|
|
8
|
+
export declare const wait: (ms: number) => Promise<void>;
|
|
9
9
|
/**
|
|
10
10
|
* Wraps a promise with a timeout. Rejects the promise if it doesn't resolve within the given time.
|
|
11
11
|
*
|
package/dist/utils/user.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { BasketResponse, AddManyItemsBasketResponse } from '@scayle/storefront-api';
|
|
2
|
+
import type { BasketWithOptions, Product, RpcContext, Variant } from '../types';
|
|
2
3
|
/**
|
|
3
4
|
* Merges two baskets. Adds the items from the `fromBasketKey` basket to the `toBasketKey` basket
|
|
4
5
|
* and then clears the `fromBasketKey` basket. Handles existing items by adding quantities.
|
|
@@ -12,18 +13,7 @@ import type { BasketWithOptions, RpcContext } from '../types';
|
|
|
12
13
|
*/
|
|
13
14
|
export declare const mergeBaskets: (fromBasketKey: string, toBasketKey: string, withOptions: BasketWithOptions & {
|
|
14
15
|
orderCustomData?: Record<string, unknown>;
|
|
15
|
-
}, context: RpcContext) => Promise<
|
|
16
|
-
type: "failure";
|
|
17
|
-
statusCode: number;
|
|
18
|
-
basket: import("@scayle/storefront-api").BasketResponseData<import("@scayle/storefront-api").Product, import("@scayle/storefront-api").Variant>;
|
|
19
|
-
} | {
|
|
20
|
-
readonly type: "success";
|
|
21
|
-
readonly basket: import("@scayle/storefront-api").BasketResponseData<import("@scayle/storefront-api").Product, import("@scayle/storefront-api").Variant>;
|
|
22
|
-
} | {
|
|
23
|
-
readonly type: "failure";
|
|
24
|
-
readonly basket: import("@scayle/storefront-api").BasketResponseData<import("@scayle/storefront-api").Product, import("@scayle/storefront-api").Variant>;
|
|
25
|
-
readonly errors: import("@scayle/storefront-api").AddOrUpdateItemError[];
|
|
26
|
-
} | undefined>;
|
|
16
|
+
}, context: RpcContext) => Promise<BasketResponse<Product, Variant> | AddManyItemsBasketResponse<Product, Variant> | undefined>;
|
|
27
17
|
/**
|
|
28
18
|
* Merges two wishlists. Adds the items from the `fromWishlistKey` wishlist to the `toWishlistKey` wishlist
|
|
29
19
|
* and then clears the `fromWishlistKey` wishlist.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scayle/storefront-core",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.17.1",
|
|
4
4
|
"description": "Collection of essential utilities to work with the Storefront API",
|
|
5
5
|
"author": "SCAYLE Commerce Engine",
|
|
6
6
|
"license": "MIT",
|
|
@@ -80,12 +80,12 @@
|
|
|
80
80
|
"@types/webpack-env": "1.18.8",
|
|
81
81
|
"@vitest/coverage-v8": "2.1.9",
|
|
82
82
|
"dprint": "0.49.1",
|
|
83
|
-
"eslint": "9.
|
|
83
|
+
"eslint": "9.24.0",
|
|
84
84
|
"eslint-formatter-gitlab": "5.1.0",
|
|
85
85
|
"fishery": "2.2.3",
|
|
86
86
|
"publint": "0.2.12",
|
|
87
87
|
"rimraf": "6.0.1",
|
|
88
|
-
"typescript": "5.8.
|
|
88
|
+
"typescript": "5.8.3",
|
|
89
89
|
"unbuild": "3.5.0",
|
|
90
90
|
"unstorage": "1.15.0",
|
|
91
91
|
"vitest": "2.1.9"
|