@scayle/storefront-core 8.9.0 → 8.11.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 (62) hide show
  1. package/CHANGELOG.md +67 -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/order.mjs +0 -10
  29. package/dist/rpc/methods/checkout/shopUser.d.ts +20 -0
  30. package/dist/rpc/methods/checkout/shopUserAddresses.d.ts +7 -0
  31. package/dist/rpc/methods/navigationTrees.d.ts +27 -0
  32. package/dist/rpc/methods/oauth/idp.d.ts +24 -0
  33. package/dist/rpc/methods/products.d.ts +150 -7
  34. package/dist/rpc/methods/products.mjs +1 -3
  35. package/dist/rpc/methods/promotion.d.ts +46 -4
  36. package/dist/rpc/methods/search.d.ts +17 -12
  37. package/dist/rpc/methods/search.mjs +4 -2
  38. package/dist/rpc/methods/session.d.ts +71 -0
  39. package/dist/rpc/methods/session.mjs +13 -13
  40. package/dist/rpc/methods/shopConfiguration.d.ts +12 -1
  41. package/dist/rpc/methods/shopConfiguration.mjs +2 -1
  42. package/dist/rpc/methods/user.d.ts +34 -4
  43. package/dist/rpc/methods/variants.d.ts +28 -0
  44. package/dist/rpc/methods/wishlist.d.ts +35 -0
  45. package/dist/test/factories/user.d.ts +10 -0
  46. package/dist/types/api/auth.d.ts +67 -0
  47. package/dist/types/api/context.d.ts +61 -0
  48. package/dist/types/api/rpc.d.ts +19 -0
  49. package/dist/types/breadcrumb.d.ts +9 -0
  50. package/dist/types/promises.d.ts +10 -0
  51. package/dist/types/sapi/basket.d.ts +26 -1
  52. package/dist/types/sapi/filter.d.ts +37 -0
  53. package/dist/types/sapi/navigation.d.ts +16 -4
  54. package/dist/types/sapi/order.d.ts +137 -242
  55. package/dist/types/sapi/product.d.ts +85 -0
  56. package/dist/types/sapi/productFilter.d.ts +14 -0
  57. package/dist/types/sapi/router.d.ts +3 -0
  58. package/dist/types/sapi/search.d.ts +19 -0
  59. package/dist/types/sapi/sorting.d.ts +7 -0
  60. package/dist/types/sapi/wishlist.d.ts +6 -0
  61. package/dist/types/user.d.ts +102 -0
  62. package/package.json +1 -1
@@ -9,46 +9,98 @@ export type { AdvancedAttribute, AdvancedAttributes, Attributes, Product, Varian
9
9
  export type { ProductSortConfig, ProductsSearchEndpointParameters, ProductsSearchEndpointResponseData, } from '@scayle/storefront-api';
10
10
  export type { ProductWith, VariantWith, ProductSearchQuery };
11
11
  export type VariantId = number;
12
+ /**
13
+ * Represents a set of fields within an Attribute Group.
14
+ * This is a two-dimensional array used for structured attribute data,
15
+ * particularly in Complex Attribute Groups which handle combinations of
16
+ * different attributes (e.g., material composition).
17
+ * Each inner array represents a group of fields, and each object within
18
+ * represents a single field with key-value pairs (string, number, null, or undefined values).
19
+ *
20
+ * Example: In a "Material Composition" attribute group,
21
+ * a `FieldSet` might represent "cotton" with fields like
22
+ * `"material name"`: `"cotton"`, `"percentage"`: `70`.
23
+ *
24
+ * @see https://scayle.dev/en/user-guide/settings/product-structure/attribute-groups#advanced-attribute-groups
25
+ */
12
26
  export type FieldSet = Array<Array<{
13
27
  [key: string]: string | number | null | undefined;
14
28
  }>>;
29
+ /**
30
+ * Represents a hierarchical group of attributes, used for structured data
31
+ * like material composition. Contains a `fieldSet` for the current group's fields
32
+ * and a `groupSet` for nested groups, enabling complex structures.
33
+ * Values are managed in the SCAYLE Panel.
34
+ * Attribute Groups containing dates or numbers should not be translatable.
35
+ *
36
+ * Example:
37
+ * - Simple: `"material: 70% cotton, 30% polyester"`
38
+ * - Complex: `"inner material: 100% polyester, upper material: 70% cotton, 30% polyester"`
39
+ *
40
+ * @see https://scayle.dev/en/user-guide/settings/product-structure/attribute-groups#advanced-attribute-groups
41
+ */
15
42
  export declare type GroupSet = Array<{
16
43
  fieldSet: FieldSet;
17
44
  groupSet: GroupSet;
18
45
  }>;
46
+ /**
47
+ * Represents a product color.
48
+ */
19
49
  export interface ProductColor {
20
50
  id: number;
21
51
  label: string;
22
52
  value: string;
23
53
  }
54
+ /**
55
+ * Parameters for fetching a single product.
56
+ */
24
57
  export interface FetchProductParams {
25
58
  id: number;
59
+ /** Additional data to include with the product. */
26
60
  with?: ProductWith;
27
61
  pricePromotionKey?: string;
28
62
  includeSellableForFree?: boolean;
29
63
  }
64
+ /**
65
+ * Parameters for fetching multiple products.
66
+ */
30
67
  export interface FetchProductsParams {
31
68
  ids: number[];
69
+ /** Additional data to include with the products. */
32
70
  with?: ProductWith;
33
71
  pricePromotionKey?: string;
34
72
  includeSellableForFree?: boolean;
35
73
  }
74
+ /**
75
+ * Parameters for fetching multiple products by their IDs.
76
+ */
36
77
  export interface FetchProductsByIdsParams {
37
78
  ids: number[];
79
+ /** Additional data to include with the products. */
38
80
  with?: ProductWith;
39
81
  pricePromotionKey?: string;
40
82
  }
83
+ /**
84
+ * Parameters for fetching multiple products by their reference keys.
85
+ */
41
86
  export interface FetchProductsByReferenceKeysParams {
87
+ /** The reference keys of the products to fetch. */
42
88
  referenceKeys: string[];
89
+ /** Additional data to include with the products. */
43
90
  with?: ProductWith;
44
91
  pricePromotionKey?: string;
45
92
  }
93
+ /**
94
+ * Parameters for fetching products by category.
95
+ */
46
96
  export type FetchProductsByCategoryParams = {
97
+ /** Additional data to include with the products. */
47
98
  with?: ProductWith;
48
99
  cache?: CacheOptions;
49
100
  includedFilters?: Array<string>;
50
101
  perPage?: number;
51
102
  page?: number;
103
+ /** Search query parameters. */
52
104
  where?: {
53
105
  term?: ProductSearchQuery['term'];
54
106
  minPrice?: ProductSearchQuery['minPrice'];
@@ -57,11 +109,18 @@ export type FetchProductsByCategoryParams = {
57
109
  disableFuzziness?: ProductSearchQuery['disableFuzziness'];
58
110
  whitelistAttributes?: ProductSearchQuery['attributes'];
59
111
  };
112
+ /** Sort parameters. */
60
113
  sort?: FilterParams['sort'];
61
114
  pricePromotionKey?: string;
62
115
  includeSellableForFree?: boolean;
63
116
  includeSoldOut?: boolean;
117
+ /** OR filters operator. */
64
118
  orFiltersOperator?: ProductsSearchEndpointParameters['orFiltersOperator'];
119
+ /**
120
+ * Whether to track search analytics event.
121
+ *
122
+ * @see https://scayle.dev/en/developer-guide/products/search#search-analytics-and-tracking
123
+ */
65
124
  trackSearchAnalyticsEvent?: boolean;
66
125
  } & ({
67
126
  category?: string;
@@ -70,11 +129,20 @@ export type FetchProductsByCategoryParams = {
70
129
  categoryId: number;
71
130
  category?: undefined;
72
131
  });
132
+ /**
133
+ * Response from fetching products by category.
134
+ */
73
135
  export interface FetchProductsByCategoryResponse {
136
+ /** The fetched products. */
74
137
  products: Product[];
138
+ /** Pagination information. */
75
139
  pagination: ProductsByIdsEndpointResponseData['pagination'];
76
140
  }
141
+ /**
142
+ * Parameters for fetching the count of products.
143
+ */
77
144
  export type FetchProductsCountParams = {
145
+ /** Search query parameters. */
78
146
  where?: {
79
147
  term?: ProductSearchQuery['term'];
80
148
  minPrice?: ProductSearchQuery['minPrice'];
@@ -86,6 +154,7 @@ export type FetchProductsCountParams = {
86
154
  includedFilters?: Array<string>;
87
155
  includeSoldOut?: boolean;
88
156
  includeSellableForFree?: boolean;
157
+ /** OR filters operator. */
89
158
  orFiltersOperator?: ProductsSearchEndpointParameters['orFiltersOperator'];
90
159
  } & ({
91
160
  category?: string;
@@ -94,11 +163,27 @@ export type FetchProductsCountParams = {
94
163
  categoryId: number;
95
164
  category?: undefined;
96
165
  });
166
+ /**
167
+ * Response from fetching the count of products.
168
+ */
97
169
  export interface FetchProductsCountResponse {
98
170
  count: number;
99
171
  }
172
+ /**
173
+ * Represents a simplified view of a product sibling, used for displaying related products.
174
+ * Includes only ID, a representative image, and available colors.
175
+ * This simplified representation is used within the `getProductSiblings` function.
176
+ */
100
177
  export interface ProductSibling {
101
178
  id: number;
179
+ /**
180
+ * The URL of the product's bust image, front view.
181
+ * May be null if no suitable image is found.
182
+ */
102
183
  image: ProductImage | null;
184
+ /**
185
+ * An array of color values for the sibling product.
186
+ * May be an empty array if the specified color attribute is not found on the product.
187
+ */
103
188
  colors: Value[];
104
189
  }
@@ -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;
@@ -1 +1,4 @@
1
+ /**
2
+ * Represents a search query. Can be a single string or an array of strings (or null).
3
+ */
1
4
  export type Query = string | (string | null)[];
@@ -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;
@@ -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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scayle/storefront-core",
3
- "version": "8.9.0",
3
+ "version": "8.11.0",
4
4
  "description": "Collection of essential utilities to work with the Storefront API",
5
5
  "author": "SCAYLE Commerce Engine",
6
6
  "license": "MIT",