@scayle/storefront-core 8.61.1 → 8.61.2

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 (33) hide show
  1. package/CHANGELOG-V7.md +1 -11
  2. package/CHANGELOG.md +96 -103
  3. package/dist/api/customer.mjs +1 -3
  4. package/dist/api/oauth.mjs +9 -6
  5. package/dist/cache/providers/unstorage.mjs +1 -3
  6. package/dist/constants/withParameters.mjs +2 -16
  7. package/dist/helpers/attributeHelpers.mjs +3 -1
  8. package/dist/helpers/filterHelper.mjs +11 -8
  9. package/dist/helpers/productHelpers.mjs +1 -3
  10. package/dist/helpers/sanitizationHelpers.mjs +1 -4
  11. package/dist/helpers/sortingHelper.mjs +1 -3
  12. package/dist/rpc/methods/basket/basket.d.ts +2 -2
  13. package/dist/rpc/methods/basket/basket.mjs +334 -321
  14. package/dist/rpc/methods/brands.mjs +26 -20
  15. package/dist/rpc/methods/campaign.mjs +32 -23
  16. package/dist/rpc/methods/categories.mjs +156 -135
  17. package/dist/rpc/methods/cbd.mjs +52 -49
  18. package/dist/rpc/methods/checkout/checkout.mjs +42 -39
  19. package/dist/rpc/methods/checkout/order.mjs +46 -40
  20. package/dist/rpc/methods/checkout/shopUser.mjs +112 -106
  21. package/dist/rpc/methods/navigationTrees.mjs +50 -32
  22. package/dist/rpc/methods/oauth/idp.mjs +64 -55
  23. package/dist/rpc/methods/products.mjs +224 -212
  24. package/dist/rpc/methods/promotion.mjs +46 -31
  25. package/dist/rpc/methods/search.mjs +26 -20
  26. package/dist/rpc/methods/session.mjs +289 -260
  27. package/dist/rpc/methods/shopConfiguration.mjs +12 -9
  28. package/dist/rpc/methods/user.mjs +87 -78
  29. package/dist/rpc/methods/variants.mjs +17 -14
  30. package/dist/rpc/methods/wishlist.mjs +71 -62
  31. package/dist/utils/hash.mjs +2 -7
  32. package/dist/utils/sapi.mjs +10 -7
  33. package/package.json +1 -1
package/CHANGELOG-V7.md CHANGED
@@ -440,7 +440,6 @@ This changelog contains all changes of `@scayle/storefront-core` above v6.0.0 an
440
440
  - Upgraded to `@scayle/storefront-api@v17.0.0` and replaced `@aboutyou/backbone`
441
441
 
442
442
  Noticeable changes are:
443
-
444
443
  - Rename `BapiClient` to `StorefrontAPIClient`
445
444
  - Removed basic auth support from `initBapi`
446
445
 
@@ -542,9 +541,7 @@ This changelog contains all changes of `@scayle/storefront-core` above v6.0.0 an
542
541
  For example:
543
542
 
544
543
  ```ts
545
- export const custom: RpcHandler<{ shop: number }> = (
546
- context: RpcContext,
547
- ) => {
544
+ export const custom: RpcHandler<{ shop: number }> = (context: RpcContext) => {
548
545
  return {
549
546
  shop: context.shopId,
550
547
  }
@@ -1064,7 +1061,6 @@ This changelog contains all changes of `@scayle/storefront-core` above v6.0.0 an
1064
1061
  - **Removal**: `sortingValues`
1065
1062
  - instead use `getSortingValues()`
1066
1063
  - **Changed NPM package names**
1067
-
1068
1064
  - **Breaking**: Change package scope and name of `@aboutyou/scayle-sfc-nuxt` to `@scayle/storefront-nuxt2`
1069
1065
  - **Breaking**: Change package scope and name of `@aboutyou/sfc-nuxt3` to `@scayle/storefront-nuxt`
1070
1066
  - **Breaking**: Change package scope and name of `@aboutyou/scayle-sfc-lib` to `@scayle/storefront-core`
@@ -1073,7 +1069,6 @@ This changelog contains all changes of `@scayle/storefront-core` above v6.0.0 an
1073
1069
 
1074
1070
  _NOTE: Due to the changes of the NPM package scope from `@aboutyou` to `@scayle`,
1075
1071
  it is required to change the consuming projects local `.npmrc` file as follows:_
1076
-
1077
1072
  - Before:
1078
1073
 
1079
1074
  ```text
@@ -1101,7 +1096,6 @@ This changelog contains all changes of `@scayle/storefront-core` above v6.0.0 an
1101
1096
  - Support sha256 for basket and wishlist keys
1102
1097
 
1103
1098
  The `appKeys.isHashed` config option has been renamed to `appKeys.hashAlgorithm`. Instead of a boolean, there are now three options.
1104
-
1105
1099
  - `'sha256'` Use the `sha256` function for hashing basket and wishlist keys
1106
1100
  - `'md5'` Use the `md5` function for hashing basket and wishlist keys (Equivalent to `isHashed: true` in v6)
1107
1101
  - `null` Do not hash basket and wishlist keys (Equivalent to `isHashed: false` in v6)
@@ -1151,7 +1145,6 @@ This changelog contains all changes of `@scayle/storefront-core` above v6.0.0 an
1151
1145
  - Support sha256 for basket and wishlist keys
1152
1146
 
1153
1147
  The `appKeys.isHashed` config option has been renamed to `appKeys.hashAlgorithm`. Instead of a boolean, there are now three options.
1154
-
1155
1148
  - `'sha256'` Use the `sha256` function for hashing basket and wishlist keys
1156
1149
  - `'md5'` Use the `md5` function for hashing basket and wishlist keys (Equivalent to `isHashed: true` in v6)
1157
1150
  - `null` Do not hash basket and wishlist keys (Equivalent to `isHashed: false` in v6)
@@ -1210,7 +1203,6 @@ This changelog contains all changes of `@scayle/storefront-core` above v6.0.0 an
1210
1203
  They can no longer be overridden when calling `wishlist.addItem()`, `wishlist.removeItem()`, `wishlist.toggleItem()` and `wishlist.fetch()`.
1211
1204
 
1212
1205
  - **Removed deprecated functions and values**
1213
-
1214
1206
  - `user.fetch()` User is fetched automatically. If you want to refresh the user, use `user.refresh()`
1215
1207
  - `user.forceRefreshUser()` Use `user.refresh()` instead.
1216
1208
  - `useUser()` Use `useUserWithParams()` instead.
@@ -1224,7 +1216,6 @@ This changelog contains all changes of `@scayle/storefront-core` above v6.0.0 an
1224
1216
  - `sortingValues` Use `getSortingValues()` instead.
1225
1217
 
1226
1218
  - **Changed NPM package names**
1227
-
1228
1219
  - **Breaking**: Change package scope and name of `@aboutyou/scayle-sfc-nuxt` to `@scayle/storefront-nuxt2`
1229
1220
  - **Breaking**: Change package scope and name of `@aboutyou/sfc-nuxt3` to `@scayle/storefront-nuxt`
1230
1221
  - **Breaking**: Change package scope and name of `@aboutyou/scayle-sfc-lib` to `@scayle/storefront-core``
@@ -1233,7 +1224,6 @@ This changelog contains all changes of `@scayle/storefront-core` above v6.0.0 an
1233
1224
 
1234
1225
  Due to the changes of the NPM package scope from `@aboutyou` to `@scayle`,
1235
1226
  it is required to change the consuming projects local `.npmrc` file as follows:
1236
-
1237
1227
  - Before: `@aboutyou:registry=https://gitlab.com/api/v4/packages/npm/`
1238
1228
  - After: `@scayle:registry=https://gitlab.com/api/v4/packages/npm/`
1239
1229
 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # @scayle/storefront-core
2
2
 
3
+ ## 8.61.2
4
+
5
+ No changes in this release.
6
+
3
7
  ## 8.61.1
4
8
 
5
9
  No changes in this release.
@@ -13,23 +17,23 @@ No changes in this release.
13
17
  User- and session-specific RPCs (`getBasket`, `getUser`, `fetchUser`, `getWishlist`, `getAccessToken`, `getCheckoutToken`, `getOrderById`, `getCheckoutDataByCbd`, `getShopUserAddress`) intentionally stay on `POST` so their responses are never eligible for CDN or browser caching.
14
18
 
15
19
  ```ts
16
- import { defineRpcHandler, type RpcContext } from "@scayle/storefront-core";
20
+ import { defineRpcHandler, type RpcContext } from '@scayle/storefront-core'
17
21
 
18
22
  // Safe, public read — eligible for CDN/browser caching
19
23
  export const getNavigation = defineRpcHandler(
20
24
  async (context: RpcContext) => {
21
25
  /* ... */
22
26
  },
23
- { method: "GET" }
24
- );
27
+ { method: 'GET' },
28
+ )
25
29
 
26
30
  // User-specific / Mutation — uses POST to prevent cache leakage
27
31
  export const getBasket = defineRpcHandler(
28
32
  async (context: RpcContext) => {
29
33
  /* ... */
30
- }
34
+ },
31
35
  // method defaults to 'POST'
32
- );
36
+ )
33
37
  ```
34
38
 
35
39
  ### Patch Changes
@@ -95,33 +99,33 @@ No changes in this release.
95
99
  **Migration:**
96
100
 
97
101
  ```ts
98
- import baseSlugify from "slugify";
102
+ import baseSlugify from 'slugify'
99
103
 
100
104
  const slugify = (url: string | undefined): string => {
101
- return baseSlugify(url ?? "", {
105
+ return baseSlugify(url ?? '', {
102
106
  lower: true,
103
107
  remove: /[*+~.()'"!:@/#?]/g,
104
- });
105
- };
108
+ })
109
+ }
106
110
 
107
- const localePath = useLocalePath();
111
+ const localePath = useLocalePath()
108
112
 
109
113
  const getProductDetailRoute = (
110
114
  id: number,
111
115
  name?: string,
112
- locale?: Locale
116
+ locale?: Locale,
113
117
  ): string => {
114
118
  return localePath(
115
119
  {
116
- name: "p-productName-id",
120
+ name: 'p-productName-id',
117
121
  params: {
118
122
  productName: slugify(name),
119
123
  id: `${id}`,
120
124
  },
121
125
  },
122
- locale
123
- );
124
- };
126
+ locale,
127
+ )
128
+ }
125
129
  ```
126
130
 
127
131
  ## 8.59.1
@@ -178,7 +182,6 @@ No changes in this release.
178
182
  - **\[Navigation\]** Exported Navigation V2 API types to provide TypeScript support for the new navigation endpoints.
179
183
 
180
184
  The following types are now available from `@scayle/storefront-core`:
181
-
182
185
  - `GetNavigationV2Parameters` - Parameters for fetching navigation trees via the V2 API
183
186
  - `NavigationV2AllEndpointResponseData` - Response type for fetching all navigation trees
184
187
  - `NavigationV2ByReferenceEndpointResponseData` - Response type for fetching a navigation tree by reference key
@@ -302,10 +305,10 @@ No changes in this release.
302
305
  Example:
303
306
 
304
307
  ```ts
305
- import { sha256 } from "@scayle/storefront-core";
308
+ import { sha256 } from '@scayle/storefront-core'
306
309
 
307
- const hash = await sha256("hello");
308
- console.log(hash); // '2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824'
310
+ const hash = await sha256('hello')
311
+ console.log(hash) // '2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824'
309
312
  ```
310
313
 
311
314
  ### Patch Changes
@@ -322,7 +325,6 @@ No changes in this release.
322
325
  - Export `SmartSortingKey` constant containing all predefined smart sorting keys for intelligent product sorting. Smart sorting keys provide advanced sorting algorithms that consider multiple factors like discounts, inventory levels, sales performance, and recency to optimize product listings.
323
326
 
324
327
  Available keys:
325
-
326
328
  - `SmartSortingKey.SALES_PUSH` - Promotes items with highest discounts and oldest inventory
327
329
  - `SmartSortingKey.NEW_ARRIVALS` - Prioritizes recently added products with good availability
328
330
  - `SmartSortingKey.BALANCED_OFFERINGS` - Balances recency, availability, discounts, and sales data
@@ -365,8 +367,8 @@ No changes in this release.
365
367
  customer: {
366
368
  groups: context.user?.groups,
367
369
  },
368
- };
369
- });
370
+ }
371
+ })
370
372
  ```
371
373
 
372
374
  For further information, please refer to the [Overriding Core RPC Methods](https://scayle.dev/en/core-documentation/storefront-guide/storefront-application/technical-foundation/rpc-methods?sourceText=RPC%2520Methods#overriding-core-rpc-methods).
@@ -399,37 +401,36 @@ No changes in this release.
399
401
  #### Looking up by name (existing, now renamed):
400
402
 
401
403
  ```typescript
402
- import { getAttributeValuesByName } from "@scayle/storefront-core";
404
+ import { getAttributeValuesByName } from '@scayle/storefront-core'
403
405
 
404
406
  // Single-select attribute
405
- const sizes = getAttributeValuesByName(product.attributes, "size");
407
+ const sizes = getAttributeValuesByName(product.attributes, 'size')
406
408
  // Returns: [{ id: 1, label: 'M', value: 'medium' }]
407
409
 
408
410
  // Multi-select attribute
409
- const colors = getAttributeValuesByName(product.attributes, "color");
411
+ const colors = getAttributeValuesByName(product.attributes, 'color')
410
412
  // Returns: [{ id: 1, label: 'Red' }, { id: 2, label: 'Blue' }]
411
413
 
412
414
  // Non-existent attribute
413
- const missing = getAttributeValuesByName(product.attributes, "doesNotExist");
415
+ const missing = getAttributeValuesByName(product.attributes, 'doesNotExist')
414
416
  // Returns: []
415
417
  ```
416
418
 
417
419
  #### Looking up by group ID (new):
418
420
 
419
421
  ```typescript
420
- import { getAttributeValuesByGroupId } from "@scayle/storefront-core";
422
+ import { getAttributeValuesByGroupId } from '@scayle/storefront-core'
421
423
 
422
424
  // Look up attribute by its numeric ID from the SCAYLE API
423
- const promotionValues = getAttributeValuesByGroupId(product.attributes, 42);
425
+ const promotionValues = getAttributeValuesByGroupId(product.attributes, 42)
424
426
  // Returns: [{ id: 123, label: 'Summer Sale', value: 'summer-2024' }]
425
427
 
426
428
  // Non-existent attribute group
427
- const missing = getAttributeValuesByGroupId(product.attributes, 9999);
429
+ const missing = getAttributeValuesByGroupId(product.attributes, 9999)
428
430
  // Returns: []
429
431
  ```
430
432
 
431
433
  ### When to Use Each Function
432
-
433
434
  - **`getAttributeValuesByName`**: Use when you know the attribute name key (e.g., 'color', 'size'). This is the most common use case in application code.
434
435
  - **`getAttributeValuesByGroupId`**: Use when you have the numeric attribute group ID from the SCAYLE API, such as when processing API configurations, handling dynamic attribute mappings, or working with attribute group references.
435
436
 
@@ -520,10 +521,10 @@ No changes in this release.
520
521
 
521
522
  ```ts
522
523
  const isComboDealType = (
523
- promotion?: Promotion | null
524
+ promotion?: Promotion | null,
524
525
  ): promotion is Promotion<ComboDealEffect> => {
525
- return promotion?.effect?.type === PromotionEffectType.COMBO_DEAL;
526
- };
526
+ return promotion?.effect?.type === PromotionEffectType.COMBO_DEAL
527
+ }
527
528
  ```
528
529
 
529
530
  ### Patch Changes
@@ -795,23 +796,23 @@ No changes in this release.
795
796
  - Added `minReduction` and `maxReduction` filter parameters to `FetchProductsByCategoryParams.where` and `FetchFiltersParams.where` types, and updated the `getProductsByCategory` and `getFilters` RPC methods to accept and handle these new reduction-based filtering conditions.
796
797
 
797
798
  ```ts
798
- const { data } = useRpc("getFilters", "getFiltersKey", () => ({
799
+ const { data } = useRpc('getFilters', 'getFiltersKey', () => ({
799
800
  where: {
800
801
  minReduction: 10,
801
802
  maxReduction: 20,
802
803
  },
803
- }));
804
+ }))
804
805
 
805
806
  const { data } = useRpc(
806
- "getProductsByCategory",
807
- "getProductsByCategoryKey",
807
+ 'getProductsByCategory',
808
+ 'getProductsByCategoryKey',
808
809
  () => ({
809
810
  where: {
810
811
  minReduction: 10,
811
812
  maxReduction: 20,
812
813
  },
813
- })
814
- );
814
+ }),
815
+ )
815
816
  ```
816
817
 
817
818
  ## 8.30.3
@@ -842,28 +843,28 @@ No changes in this release.
842
843
 
843
844
  ```ts
844
845
  export const existingHandlerWithoutParams = async (_context: RpcContext) => {
845
- return "existing handler";
846
- };
846
+ return 'existing handler'
847
+ }
847
848
 
848
849
  export const existingHandlerWithParams = async (
849
850
  { name }: { name: string },
850
- _context: RpcContext
851
+ _context: RpcContext,
851
852
  ) => {
852
- return name;
853
- };
853
+ return name
854
+ }
854
855
 
855
856
  // will become
856
857
 
857
858
  export const existingHandlerWithoutParams = defineRpcHandler(
858
859
  async (_context: RpcContext) => {
859
- return "existing handler";
860
- }
861
- );
860
+ return 'existing handler'
861
+ },
862
+ )
862
863
  export const existingHandlerWithParams = defineRpcHandler(
863
864
  async ({ name }: { name: string }, _context: RpcContext) => {
864
- return name;
865
- }
866
- );
865
+ return name
866
+ },
867
+ )
867
868
  ```
868
869
 
869
870
  ### Patch Changes
@@ -880,15 +881,15 @@ No changes in this release.
880
881
  - Added an optional `hideEmptyCategories` parameter to `getCategoryTree`. When enabled, the product count for each category is retrieved, and categories (including their children) without any products are removed. Enabling this option may increase response times, especially for large category trees.
881
882
 
882
883
  ```ts
883
- import { rpcMethods } from "@scayle/storefront-core";
884
+ import { rpcMethods } from '@scayle/storefront-core'
884
885
 
885
- rpcMethods.getCategoryTree({ hideEmptyCategories: true }, rpcContext);
886
+ rpcMethods.getCategoryTree({ hideEmptyCategories: true }, rpcContext)
886
887
  ```
887
888
 
888
889
  or
889
890
 
890
891
  ```ts
891
- import { useCategoryTree } from "#storefront/composables";
892
+ import { useCategoryTree } from '#storefront/composables'
892
893
 
893
894
  const { data: rootCategories, status } = useCategoryTree(
894
895
  {
@@ -896,8 +897,8 @@ No changes in this release.
896
897
  hideEmptyCategories: true,
897
898
  },
898
899
  },
899
- "category-navigation-tree"
900
- );
900
+ 'category-navigation-tree',
901
+ )
901
902
  ```
902
903
 
903
904
  ### Patch Changes
@@ -1063,7 +1064,6 @@ No changes in this release.
1063
1064
  ### Minor Changes
1064
1065
 
1065
1066
  - Expose the following filter types from `storefront-api`:
1066
-
1067
1067
  - `FilterItemWithValues`
1068
1068
  - `BooleanFilterItemWithValues`
1069
1069
  - `RangeFilterItemWithValues`
@@ -1258,7 +1258,6 @@ No changes in this release.
1258
1258
  - Simplified exported `Order` interface by relying directly on primitive types instead of having multiple intermediate types that resolve to primitives.
1259
1259
 
1260
1260
  The following formerly exported intermediate types have been replaces by primitive types:
1261
-
1262
1261
  - resolving to `string` now
1263
1262
  - `TimestampOfOrderConfirmation`
1264
1263
  - `CharacterCurrencyCode`
@@ -1329,12 +1328,12 @@ To get the default campaign key, you can call the RPC method:
1329
1328
  ```typescript
1330
1329
  // Before
1331
1330
  async function rpcMethod(context) {
1332
- const campaignKey = { context };
1331
+ const campaignKey = { context }
1333
1332
  // ...
1334
1333
  }
1335
1334
  // After
1336
1335
  async function rpcMethod(context) {
1337
- const campaignKey = await context.callRpc?.("getCampaignKey");
1336
+ const campaignKey = await context.callRpc?.('getCampaignKey')
1338
1337
  // ...
1339
1338
  }
1340
1339
  ```
@@ -1495,7 +1494,6 @@ See [Overriding core RPC Methods](https://scayle.dev/en/core-documentation/store
1495
1494
  ### Minor Changes
1496
1495
 
1497
1496
  - **RPC Methods:** Propagate SAPI response codes through RPC methods. This addresses an issue introduced in Storefront Core v8 where specific status codes were incorrectly reported as generic 500 errors. The following RPC methods are impacted:
1498
-
1499
1497
  - `getBrands`
1500
1498
  - `getBrandById`
1501
1499
  - `getCategoryByPath`
@@ -1517,53 +1515,51 @@ See [Overriding core RPC Methods](https://scayle.dev/en/core-documentation/store
1517
1515
  ### Major Changes
1518
1516
 
1519
1517
  - **\[💥 BREAKING\]** The `getBadgeLabel` helper function has been removed, giving you more control over badge label display.
1520
-
1521
1518
  - **Note:** This change doesn't affect projects using SCAYLE Storefront Boilerplate v1.0 or later.
1522
1519
  - For applications based on older versions or using `getBadgeLabel`, you can refer to the previous implementation below:
1523
1520
 
1524
1521
  ```ts
1525
1522
  const BadgeLabel = {
1526
- NEW: "new",
1527
- SOLD_OUT: "sold_out",
1528
- ONLINE_EXCLUSIVE: "online_exclusive",
1529
- SUSTAINABLE: "sustainable",
1530
- PREMIUM: "premium",
1531
- DEFAULT: "",
1532
- } as const;
1523
+ NEW: 'new',
1524
+ SOLD_OUT: 'sold_out',
1525
+ ONLINE_EXCLUSIVE: 'online_exclusive',
1526
+ SUSTAINABLE: 'sustainable',
1527
+ PREMIUM: 'premium',
1528
+ DEFAULT: '',
1529
+ } as const
1533
1530
 
1534
1531
  type BadgeLabelParamsKeys =
1535
- | "isNew"
1536
- | "isSoldOut"
1537
- | "isOnlineOnly"
1538
- | "isSustainable"
1539
- | "isPremium";
1540
- type BadgeLabelParams = Partial<Record<BadgeLabelParamsKeys, boolean>>;
1532
+ | 'isNew'
1533
+ | 'isSoldOut'
1534
+ | 'isOnlineOnly'
1535
+ | 'isSustainable'
1536
+ | 'isPremium'
1537
+ type BadgeLabelParams = Partial<Record<BadgeLabelParamsKeys, boolean>>
1541
1538
 
1542
1539
  const getBadgeLabel = (params: BadgeLabelParams = {}): string => {
1543
1540
  if (!params) {
1544
- return BadgeLabel.DEFAULT;
1541
+ return BadgeLabel.DEFAULT
1545
1542
  }
1546
1543
  const { isNew, isSoldOut, isOnlineOnly, isSustainable, isPremium } =
1547
- params;
1544
+ params
1548
1545
 
1549
1546
  if (isNew) {
1550
- return BadgeLabel.NEW;
1547
+ return BadgeLabel.NEW
1551
1548
  } else if (isSoldOut) {
1552
- return BadgeLabel.SOLD_OUT;
1549
+ return BadgeLabel.SOLD_OUT
1553
1550
  } else if (isOnlineOnly) {
1554
- return BadgeLabel.ONLINE_EXCLUSIVE;
1551
+ return BadgeLabel.ONLINE_EXCLUSIVE
1555
1552
  } else if (isSustainable) {
1556
- return BadgeLabel.SUSTAINABLE;
1553
+ return BadgeLabel.SUSTAINABLE
1557
1554
  } else if (isPremium) {
1558
- return BadgeLabel.PREMIUM;
1555
+ return BadgeLabel.PREMIUM
1559
1556
  } else {
1560
- return BadgeLabel.DEFAULT;
1557
+ return BadgeLabel.DEFAULT
1561
1558
  }
1562
- };
1559
+ }
1563
1560
  ```
1564
1561
 
1565
1562
  - **\[💥 BREAKING\]** We've standardized our configuration to use `sapi` (Storefront API) throughout the codebase, replacing the deprecated `bapi` keyword. This change improves clarity and consistency by removing the `initBapi` function, replacing the `bapiClient` property with `sapiClient` within the `RPCContext`, and updating all code references accordingly. `BapiConfig` is not exported anymore and has been superseded by `SapiConfig`.
1566
-
1567
1563
  - **NOTE:** These changes impact your environment variables used for deployments. Please check your infrastructure and deployment setup and adapt accordingly!
1568
1564
  - _Previous `bapi` Configuration in `nuxt.config.ts`_
1569
1565
 
@@ -1575,15 +1571,15 @@ See [Overriding core RPC Methods](https://scayle.dev/en/core-documentation/store
1575
1571
  storefront: {
1576
1572
  // ...
1577
1573
  bapi: {
1578
- host: "...",
1579
- token: "...",
1574
+ host: '...',
1575
+ token: '...',
1580
1576
  },
1581
1577
  // ...
1582
1578
  },
1583
1579
  // ...
1584
1580
  },
1585
1581
  // ...
1586
- };
1582
+ }
1587
1583
  ```
1588
1584
 
1589
1585
  - _Legacy Environment Variables:_
@@ -1603,15 +1599,15 @@ See [Overriding core RPC Methods](https://scayle.dev/en/core-documentation/store
1603
1599
  storefront: {
1604
1600
  // ...
1605
1601
  sapi: {
1606
- host: "...",
1607
- token: "...",
1602
+ host: '...',
1603
+ token: '...',
1608
1604
  },
1609
1605
  // ...
1610
1606
  },
1611
1607
  // ...
1612
1608
  },
1613
1609
  // ...
1614
- };
1610
+ }
1615
1611
  ```
1616
1612
 
1617
1613
  - _New Environment Variables:_
@@ -1624,28 +1620,26 @@ See [Overriding core RPC Methods](https://scayle.dev/en/core-documentation/store
1624
1620
  - **\[💥 BREAKING\]** We've streamlined cache management by replacing the outdated `AY_CACHE_DISABLED` environment variable. Now, you can effortlessly control caching using either the `NUXT_STOREFRONT_CACHE_ENABLED` environment variable or the `storefront.cache.enabled` option within your `nuxt.config.ts` file, providing a more user-friendly experience.
1625
1621
  - **\[💥 BREAKING\]** This release removes the `RedisCache` provider. We now use `UnstorageCache` which also supports Redis as a backing store.
1626
1622
  - **\[💥 BREAKING\]** To improve security and streamline token management, we've updated how you access user `accessToken`. Instead of directly accessing the `storefrontAccessToken` field on the `UserAuthentication` interface, you'll now use the dedicated `getAccessToken` RPC. This change ensures a more secure and controlled method for handling sensitive user data within your application.
1627
-
1628
1623
  - _Previous Usage of `user.authentication.storefrontAccessToken`:_
1629
1624
 
1630
1625
  ```ts
1631
1626
  const { data, fetching, fetch, error, status } = useUser(
1632
- "getUser"
1627
+ 'getUser',
1633
1628
  // ...
1634
- );
1635
- data.value.user.authentication.storefrontAccessToken;
1629
+ )
1630
+ data.value.user.authentication.storefrontAccessToken
1636
1631
  ```
1637
1632
 
1638
1633
  - _Current Usage of dedicated `getAccessToken` RPC method:_
1639
1634
 
1640
1635
  ```ts
1641
1636
  const { data: accessToken } = useRpc(
1642
- "getAccessToken"
1637
+ 'getAccessToken',
1643
1638
  // ...
1644
- );
1639
+ )
1645
1640
  ```
1646
1641
 
1647
1642
  - **\[💥 BREAKING\]** We've enhanced security for basket and wishlist keys by switching the default hashing algorithm from MD5 to the more robust SHA256.
1648
-
1649
1643
  - _Overriding default `hashAlgorithm` in `nuxt.config.ts`:_
1650
1644
 
1651
1645
  ```ts
@@ -1664,32 +1658,31 @@ See [Overriding core RPC Methods](https://scayle.dev/en/core-documentation/store
1664
1658
  // ...
1665
1659
  },
1666
1660
  // ...
1667
- });
1661
+ })
1668
1662
  ```
1669
1663
 
1670
1664
  - **\[💥 BREAKING\]** The attribute `loginShopId` is removed from the `ShopUser` interface as the shop now uses session cookies.
1671
1665
  - **\[💥 BREAKING\]** We're streamlining the search experience as we transition to SCAYLE Search v2, focusing on a category-centric approach. To achieve this, we're consolidating search functionality. This means we're replacing the `searchProducts` RPC method with `getSearchSuggestions`, which provides both product suggestions (triggered by product IDs) and category suggestions (triggered by category-like terms, leading to filtered category pages).
1672
-
1673
1666
  - _Previous Usage of `searchProducts` RPC method:_
1674
1667
 
1675
1668
  ```ts
1676
- const getSearchSuggestionsRpc = useRpcCall("searchProducts");
1669
+ const getSearchSuggestionsRpc = useRpcCall('searchProducts')
1677
1670
 
1678
1671
  data.value = await searchProducts({
1679
1672
  term: String(searchQuery.value),
1680
1673
  ...params,
1681
- });
1674
+ })
1682
1675
  ```
1683
1676
 
1684
1677
  - _Current Usage of `getSearchSuggestions` RPC method:_
1685
1678
 
1686
1679
  ```ts
1687
- const getSearchSuggestionsRpc = useRpcCall("getSearchSuggestions");
1680
+ const getSearchSuggestionsRpc = useRpcCall('getSearchSuggestions')
1688
1681
 
1689
1682
  data.value = await getSearchSuggestionsRpc({
1690
1683
  term: String(searchQuery.value),
1691
1684
  ...params,
1692
- });
1685
+ })
1693
1686
  ```
1694
1687
 
1695
1688
  - **\[💥 BREAKING\]** Improved basket updating: Adding an item to your basket with a reduced quantity will now correctly update the basket contents.
@@ -50,9 +50,7 @@ export class CustomerAPIClient {
50
50
  if (response.ok) {
51
51
  return await response.json();
52
52
  }
53
- if ((response.status === HttpStatusCode.UNAUTHORIZED && response.headers.get("WWW-Authenticate")?.includes(
54
- "invalid_token"
55
- ) || response.status === HttpStatusCode.FORBIDDEN) && this.context.accessToken && this.context.refreshToken) {
53
+ if ((response.status === HttpStatusCode.UNAUTHORIZED && response.headers.get("WWW-Authenticate")?.includes("invalid_token") || response.status === HttpStatusCode.FORBIDDEN) && this.context.accessToken && this.context.refreshToken) {
56
54
  if (retry) {
57
55
  const client = getOAuthClient(this.context);
58
56
  try {
@@ -66,12 +66,15 @@ export function getOAuthClient(context) {
66
66
  if (accessHeader) {
67
67
  additionalHeaders["x-internal-access"] = accessHeader;
68
68
  }
69
- return new OAuthClient({
70
- clientId,
71
- clientSecret,
72
- apiHost,
73
- additionalHeaders
74
- }, context.log);
69
+ return new OAuthClient(
70
+ {
71
+ clientId,
72
+ clientSecret,
73
+ apiHost,
74
+ additionalHeaders
75
+ },
76
+ context.log
77
+ );
75
78
  }
76
79
  export class OAuthClient {
77
80
  /**
@@ -53,9 +53,7 @@ export class UnstorageCache {
53
53
  * @param tag The tag to purge.
54
54
  */
55
55
  async purgeTag(tag) {
56
- const keys = await this.storage.getItem(
57
- this.getKey(`tag:${tag}`)
58
- );
56
+ const keys = await this.storage.getItem(this.getKey(`tag:${tag}`));
59
57
  await this.purgeKeys(keys ?? []);
60
58
  await this.storage.removeItem(this.getKey(`tag:${tag}`));
61
59
  }
@@ -67,14 +67,7 @@ const MIN_WITH_PARAMS_BASKET = {
67
67
  },
68
68
  variants: {
69
69
  attributes: {
70
- withKey: [
71
- "brand",
72
- "name",
73
- "price",
74
- "size",
75
- "shopSize",
76
- "vendorSize"
77
- ]
70
+ withKey: ["brand", "name", "price", "size", "shopSize", "vendorSize"]
78
71
  }
79
72
  },
80
73
  images: {
@@ -103,14 +96,7 @@ const MIN_WITH_PARAMS_WISHLIST = {
103
96
  },
104
97
  variants: {
105
98
  attributes: {
106
- withKey: [
107
- "brand",
108
- "name",
109
- "price",
110
- "size",
111
- "shopSize",
112
- "vendorSize"
113
- ]
99
+ withKey: ["brand", "name", "price", "size", "shopSize", "vendorSize"]
114
100
  }
115
101
  },
116
102
  images: {
@@ -22,7 +22,9 @@ export const getAttributeValuesByGroupId = (attributes, groupId) => {
22
22
  if (!attributes) {
23
23
  return [];
24
24
  }
25
- const attribute = Object.values(attributes).find((attribute2) => attribute2?.id === groupId);
25
+ const attribute = Object.values(attributes).find(
26
+ (attribute2) => attribute2?.id === groupId
27
+ );
26
28
  if (!attribute || !attribute.values) {
27
29
  return [];
28
30
  }