@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
|
@@ -1,7 +1,21 @@
|
|
|
1
1
|
import type { AttributesFilterValue, FilterItemWithValues, IdentifierFilterValue } from '@scayle/storefront-api';
|
|
2
|
+
/**
|
|
3
|
+
* Represents a product filter.
|
|
4
|
+
*/
|
|
2
5
|
export type ProductFilter = FilterItemWithValues;
|
|
6
|
+
/**
|
|
7
|
+
* Represents the values of a product filter.
|
|
8
|
+
*/
|
|
3
9
|
export type ProductFilterValues = ProductFilter['values'];
|
|
10
|
+
/**
|
|
11
|
+
* Represents a single value of a product filter. This can be a value of an attribute filter,
|
|
12
|
+
* a boolean value indicating a filter state (e.g., sale: true/false), or a value of an identifier filter.
|
|
13
|
+
*
|
|
14
|
+
* @see https://scayle.dev/en/developer-guide/products/product-filters#get-filter-values
|
|
15
|
+
*/
|
|
4
16
|
export type ProductFilterValue = AttributesFilterValue | {
|
|
17
|
+
/** The boolean value of the filter, e.g. for a "sale" filter. */
|
|
5
18
|
name: true | false;
|
|
19
|
+
/** The count of products associated with this value. */
|
|
6
20
|
productCount: number;
|
|
7
21
|
} | IdentifierFilterValue;
|
|
@@ -5,20 +5,39 @@ export type { SearchV2With } from '@scayle/storefront-api';
|
|
|
5
5
|
export type { SearchV2SuggestionsEndpointResponseData, SearchV2SuggestionsEndpointParameters, } from '@scayle/storefront-api';
|
|
6
6
|
export type { SearchV2ResolveEndpointResponseData, SearchV2ResolveEndpointParameters, } from '@scayle/storefront-api';
|
|
7
7
|
export type { SearchEntity, CategorySearchSuggestion, ProductSearchSuggestion, NavigationItemSuggestion, } from '@scayle/storefront-api';
|
|
8
|
+
/**
|
|
9
|
+
* Represents the input for a search operation.
|
|
10
|
+
*/
|
|
8
11
|
export interface SearchInput {
|
|
9
12
|
term?: Query;
|
|
10
13
|
slug?: string;
|
|
14
|
+
/** The limit for the number of products. */
|
|
11
15
|
productLimit?: number;
|
|
12
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Options for including additional data with categories.
|
|
19
|
+
*/
|
|
13
20
|
export interface CategoryWith {
|
|
21
|
+
/** Whether to include all parent categories. */
|
|
14
22
|
parents?: 'all';
|
|
23
|
+
/** The number of children to include. */
|
|
15
24
|
children?: number;
|
|
16
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* Options for a search operation.
|
|
28
|
+
*/
|
|
17
29
|
export interface SearchOptions {
|
|
30
|
+
/** The search key. */
|
|
18
31
|
key?: string;
|
|
32
|
+
/** Additional data to include with the search results. */
|
|
19
33
|
with?: {
|
|
34
|
+
/** Additional product data to include. */
|
|
20
35
|
products?: ProductWith;
|
|
36
|
+
/** Additional category data to include. */
|
|
21
37
|
categories?: CategoryWith;
|
|
22
38
|
};
|
|
23
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* Additional data to include with search results.
|
|
42
|
+
*/
|
|
24
43
|
export type SearchWith = TypeaheadSuggestionsEndpointRequestParameters['with'];
|
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
import type { APISortOption, APISortOrder } from '@scayle/storefront-api';
|
|
2
2
|
import type { SortName, SortQuery } from '../../constants';
|
|
3
|
+
/**
|
|
4
|
+
* Represents the keys for available sorting values.
|
|
5
|
+
*/
|
|
3
6
|
export type SortingValueKey = 'topSeller' | 'dateNewest' | 'priceDesc' | 'priceAsc' | 'reductionDesc' | 'reductionAsc';
|
|
7
|
+
/**
|
|
8
|
+
* Represents a sorting value.
|
|
9
|
+
*/
|
|
4
10
|
export interface SortValue {
|
|
5
11
|
name: SortName;
|
|
12
|
+
/** The query string for the sorting option. */
|
|
6
13
|
query: SortQuery;
|
|
7
14
|
by: APISortOption;
|
|
8
15
|
direction?: APISortOrder;
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import type { WishlistResponseData, WishlistWith } from '@scayle/storefront-api';
|
|
2
2
|
export type { WishlistResponseData, WishlistWith };
|
|
3
|
+
/**
|
|
4
|
+
* Wishlist with optional price promotion key.
|
|
5
|
+
*/
|
|
3
6
|
export interface WishlistWithOptions extends WishlistWith {
|
|
4
7
|
pricePromotionKey?: string;
|
|
5
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* Parameters for useWishlist hook/function.
|
|
11
|
+
*/
|
|
6
12
|
export interface UseWishlistParams {
|
|
7
13
|
key?: string;
|
|
8
14
|
with: WishlistWithOptions;
|
package/dist/types/user.d.ts
CHANGED
|
@@ -1,98 +1,200 @@
|
|
|
1
1
|
import type { UseBasketParams } from './sapi/basket';
|
|
2
2
|
import type { UseWishlistParams } from './sapi/wishlist';
|
|
3
|
+
/**
|
|
4
|
+
* Represents the gender of a user.
|
|
5
|
+
*/
|
|
3
6
|
export type Gender = 'm' | 'f' | 'd' | 'n';
|
|
7
|
+
/**
|
|
8
|
+
* Parameters for updating a user's password.
|
|
9
|
+
*/
|
|
4
10
|
export interface UpdatePasswordParams {
|
|
11
|
+
/** The user's current password. */
|
|
5
12
|
oldPassword: string;
|
|
13
|
+
/** The user's new password. */
|
|
6
14
|
newPassword: string;
|
|
7
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* Parameters for fetching user data.
|
|
18
|
+
*/
|
|
8
19
|
export interface UseUserParams {
|
|
20
|
+
/** An optional key for caching or identifying the user. */
|
|
9
21
|
key?: string;
|
|
22
|
+
/** Whether to automatically fetch user data. */
|
|
10
23
|
autoFetch?: boolean;
|
|
11
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Represents a member's role and associated privileges.
|
|
27
|
+
*/
|
|
12
28
|
interface MemberRole {
|
|
29
|
+
/** The discount visibility setting for the role. */
|
|
13
30
|
discountVisibility: string;
|
|
31
|
+
/** The member's priority level. */
|
|
14
32
|
memberPriority: number;
|
|
33
|
+
/** The SAP identifier for the member role. */
|
|
15
34
|
memberRoleSap: string;
|
|
16
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* The type of authentication used by the user.
|
|
38
|
+
*/
|
|
17
39
|
export type AuthenticationType = 'password' | string;
|
|
40
|
+
/**
|
|
41
|
+
* Represents the user's authentication information.
|
|
42
|
+
*/
|
|
18
43
|
interface UserAuthentication {
|
|
44
|
+
/** Data containing access token and user ID. */
|
|
19
45
|
data?: {
|
|
46
|
+
/** The user's access token. */
|
|
20
47
|
accessToken?: string;
|
|
48
|
+
/** The user's ID. */
|
|
21
49
|
userId?: string;
|
|
22
50
|
};
|
|
51
|
+
/** The type of authentication. */
|
|
23
52
|
type: AuthenticationType;
|
|
24
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* Summary information about an order.
|
|
56
|
+
*/
|
|
25
57
|
export interface OrderSummary {
|
|
58
|
+
/** The order ID. */
|
|
26
59
|
id: number;
|
|
60
|
+
/** The date and time the order was confirmed. */
|
|
27
61
|
confirmedAt?: string;
|
|
62
|
+
/** The number of items in the order. */
|
|
28
63
|
itemCount: number | undefined;
|
|
64
|
+
/** The ID of the shop associated with the order. */
|
|
29
65
|
shopId: number;
|
|
66
|
+
/** The current status of the order. */
|
|
30
67
|
status?: string;
|
|
31
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* Represents the status of a shop user.
|
|
71
|
+
*/
|
|
32
72
|
export interface ShopUserStatus {
|
|
73
|
+
/** Whether the user is active. */
|
|
33
74
|
isActive: boolean;
|
|
75
|
+
/** Whether the user is a guest customer. */
|
|
34
76
|
isGuestCustomer: boolean;
|
|
77
|
+
/** Whether the user is a test customer. */
|
|
35
78
|
isTestCustomer: boolean;
|
|
36
79
|
}
|
|
80
|
+
/**
|
|
81
|
+
* Represents a shop user's address.
|
|
82
|
+
*/
|
|
37
83
|
export interface ShopUserAddress {
|
|
84
|
+
/** The address ID. */
|
|
38
85
|
id: number;
|
|
86
|
+
/** An optional reference key for the address. */
|
|
39
87
|
referenceKey?: string;
|
|
88
|
+
/** The street address. */
|
|
40
89
|
street: string;
|
|
90
|
+
/** The house number. */
|
|
41
91
|
houseNumber?: string;
|
|
92
|
+
/** Additional address information. */
|
|
42
93
|
additional?: string;
|
|
94
|
+
/** The zip code. */
|
|
43
95
|
zipCode: string;
|
|
96
|
+
/** The city. */
|
|
44
97
|
city: string;
|
|
98
|
+
/** The country code. */
|
|
45
99
|
countryCode: string;
|
|
100
|
+
/** Information about the collection point, if applicable. */
|
|
46
101
|
collectionPoint?: {
|
|
102
|
+
/** The customer key for the collection point. */
|
|
47
103
|
customerKey?: string;
|
|
104
|
+
/** A description of the collection point. */
|
|
48
105
|
description?: string;
|
|
106
|
+
/** The key for the collection point. */
|
|
49
107
|
key: string;
|
|
108
|
+
/** The type of collection point. */
|
|
50
109
|
type: string;
|
|
51
110
|
};
|
|
111
|
+
/** Whether this is the billing address. */
|
|
52
112
|
isBillingAddress: boolean;
|
|
113
|
+
/** Whether this is the shipping address. */
|
|
53
114
|
isShippingAddress: boolean;
|
|
115
|
+
/** Whether this is the default billing or shipping address. */
|
|
54
116
|
isDefault: {
|
|
117
|
+
/** Whether this is the default billing address. */
|
|
55
118
|
billing: boolean;
|
|
119
|
+
/** Whether this is the default shipping address. */
|
|
56
120
|
shipping: boolean;
|
|
57
121
|
};
|
|
122
|
+
/** The recipient's information. */
|
|
58
123
|
recipient: {
|
|
124
|
+
/** The recipient's first name. */
|
|
59
125
|
firstName?: string;
|
|
126
|
+
/** The recipient's last name. */
|
|
60
127
|
lastName: string;
|
|
128
|
+
/** The recipient's gender. */
|
|
61
129
|
gender?: Gender;
|
|
130
|
+
/** The recipient's title (e.g., Mr., Mrs.). */
|
|
62
131
|
title?: string;
|
|
63
132
|
};
|
|
64
133
|
}
|
|
134
|
+
/**
|
|
135
|
+
* Represents a shop user.
|
|
136
|
+
*/
|
|
65
137
|
export interface ShopUser {
|
|
138
|
+
/** The app ID associated with the user. */
|
|
66
139
|
app_id: number;
|
|
140
|
+
/** The number of completed orders. */
|
|
67
141
|
completed_orders: number;
|
|
142
|
+
/** The date the user was created. */
|
|
68
143
|
created_date?: Date;
|
|
144
|
+
/** The user's zip code. */
|
|
69
145
|
zip_code?: number | undefined;
|
|
146
|
+
/** The user's authentication information. */
|
|
70
147
|
authentication?: UserAuthentication;
|
|
148
|
+
/** The user's first name. */
|
|
71
149
|
firstName: string;
|
|
150
|
+
/** The user's last name. */
|
|
72
151
|
lastName?: string;
|
|
152
|
+
/** The groups the user belongs to. */
|
|
73
153
|
groups?: string[];
|
|
154
|
+
/** The user's birth date. */
|
|
74
155
|
birthDate?: string;
|
|
156
|
+
/** The user's phone number. */
|
|
75
157
|
phone?: string;
|
|
158
|
+
/** The user's public key. */
|
|
76
159
|
publicKey: string;
|
|
160
|
+
/** The user's reference key. */
|
|
77
161
|
referenceKey: string;
|
|
162
|
+
/** The date the user was created in the system. */
|
|
78
163
|
createdAt: string;
|
|
164
|
+
/** The date the user was last updated in the system. */
|
|
79
165
|
updatedAt: string;
|
|
166
|
+
/** The user's email address. */
|
|
80
167
|
email?: string;
|
|
168
|
+
/** Whether user has a connected facebook account*/
|
|
81
169
|
fbook?: boolean;
|
|
170
|
+
/** The user's ID. */
|
|
82
171
|
id: number;
|
|
172
|
+
/** Whether the user is a guest. */
|
|
83
173
|
isGuest: boolean;
|
|
174
|
+
/** Whether the user is a returning customer. */
|
|
84
175
|
isReturningCustomer: boolean;
|
|
176
|
+
/** The user's gender. */
|
|
85
177
|
gender?: Gender;
|
|
178
|
+
/** A summary of the user's orders. */
|
|
86
179
|
orderSummary?: OrderSummary[];
|
|
180
|
+
/** The user's status. */
|
|
87
181
|
status?: ShopUserStatus;
|
|
182
|
+
/** The user's title (e.g., Mr., Mrs.). */
|
|
88
183
|
title?: string;
|
|
184
|
+
/** Custom data associated with the user. */
|
|
89
185
|
customData?: {
|
|
90
186
|
memberRoles?: MemberRole[];
|
|
91
187
|
};
|
|
92
188
|
}
|
|
189
|
+
/**
|
|
190
|
+
* Parameters for user facets.
|
|
191
|
+
*/
|
|
93
192
|
export interface UseUserFacetParams {
|
|
193
|
+
/** User-specific parameters. */
|
|
94
194
|
userParams: UseUserParams;
|
|
195
|
+
/** Basket-related parameters. */
|
|
95
196
|
basketParams: UseBasketParams;
|
|
197
|
+
/** Wishlist-related parameters. */
|
|
96
198
|
wishlistParams: UseWishlistParams;
|
|
97
199
|
}
|
|
98
200
|
export {};
|
package/dist/utils/campaign.d.ts
CHANGED
|
@@ -1,23 +1,38 @@
|
|
|
1
1
|
import type { Campaign } from '@scayle/storefront-api';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Checks if a given campaign is currently active.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* Determines if the current time falls within the campaign's start and end dates.
|
|
6
|
+
*
|
|
7
|
+
* @see https://scayle.dev/en/user-guide/shops/promotions/discounts-and-offers/price-campaigns
|
|
8
|
+
*
|
|
9
|
+
* @param campaign The campaign to check.
|
|
10
|
+
*
|
|
11
|
+
* @returns True if the campaign is active, false otherwise.
|
|
7
12
|
*/
|
|
8
13
|
export declare const isCampaignActive: (campaign?: Campaign) => boolean;
|
|
9
14
|
/**
|
|
10
|
-
*
|
|
15
|
+
* Checks if a given campaign has not yet ended.
|
|
16
|
+
*
|
|
17
|
+
* Compares the campaign's end date with the current time.
|
|
18
|
+
*
|
|
19
|
+
* @see https://scayle.dev/en/user-guide/shops/promotions/discounts-and-offers/price-campaigns
|
|
11
20
|
*
|
|
12
|
-
* @param campaign
|
|
13
|
-
*
|
|
21
|
+
* @param campaign The campaign to check.
|
|
22
|
+
*
|
|
23
|
+
* @returns True if the campaign has not ended, false otherwise.
|
|
14
24
|
*/
|
|
15
25
|
export declare const campaignHasNotEnded: (campaign: Campaign) => boolean;
|
|
16
26
|
/**
|
|
17
|
-
*
|
|
27
|
+
* Sorts campaigns by their start date in ascending order.
|
|
28
|
+
*
|
|
29
|
+
* Uses the difference between start times to determine order.
|
|
30
|
+
*
|
|
31
|
+
* @see https://scayle.dev/en/user-guide/shops/promotions/discounts-and-offers/price-campaigns
|
|
32
|
+
*
|
|
33
|
+
* @param a The first campaign to compare.
|
|
34
|
+
* @param b The second campaign to compare.
|
|
18
35
|
*
|
|
19
|
-
* @
|
|
20
|
-
* @param b The second campaign for comparison
|
|
21
|
-
* @returns A positive value when a should come before b, negative value when b should come before a, or 0 when they are considered equal
|
|
36
|
+
* @returns A negative number if `a` starts before `b`, a positive number if `a` starts after `b`, and 0 if they start at the same time.
|
|
22
37
|
*/
|
|
23
38
|
export declare const sortCampaignsByDateAscending: (a: Campaign, b: Campaign) => number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scayle/storefront-core",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.10.0",
|
|
4
4
|
"description": "Collection of essential utilities to work with the Storefront API",
|
|
5
5
|
"author": "SCAYLE Commerce Engine",
|
|
6
6
|
"license": "MIT",
|
|
@@ -68,17 +68,17 @@
|
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"@scayle/eslint-config-storefront": "4.4.1",
|
|
70
70
|
"@types/crypto-js": "4.2.2",
|
|
71
|
-
"@types/node": "22.13.
|
|
71
|
+
"@types/node": "22.13.5",
|
|
72
72
|
"@types/webpack-env": "1.18.8",
|
|
73
73
|
"@vitest/coverage-v8": "2.1.9",
|
|
74
74
|
"dprint": "0.49.0",
|
|
75
|
-
"eslint": "9.
|
|
75
|
+
"eslint": "9.21.0",
|
|
76
76
|
"eslint-formatter-gitlab": "5.1.0",
|
|
77
77
|
"publint": "0.2.12",
|
|
78
78
|
"rimraf": "6.0.1",
|
|
79
79
|
"typescript": "5.7.3",
|
|
80
80
|
"unbuild": "3.3.1",
|
|
81
|
-
"unstorage": "1.
|
|
81
|
+
"unstorage": "1.15.0",
|
|
82
82
|
"vitest": "2.1.9"
|
|
83
83
|
}
|
|
84
84
|
}
|