@scayle/storefront-core 8.61.1 → 8.61.3
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-V7.md +1 -11
- package/CHANGELOG.md +102 -103
- package/dist/api/customer.mjs +2 -4
- package/dist/api/oauth.mjs +9 -6
- package/dist/cache/providers/unstorage.mjs +1 -3
- package/dist/constants/withParameters.mjs +2 -16
- package/dist/helpers/attributeHelpers.mjs +3 -1
- package/dist/helpers/filterHelper.mjs +11 -8
- package/dist/helpers/productHelpers.mjs +1 -3
- package/dist/helpers/sanitizationHelpers.mjs +1 -4
- package/dist/helpers/sortingHelper.mjs +1 -3
- package/dist/rpc/methods/basket/basket.d.ts +2 -2
- package/dist/rpc/methods/basket/basket.mjs +334 -321
- package/dist/rpc/methods/brands.mjs +26 -20
- package/dist/rpc/methods/campaign.mjs +32 -23
- package/dist/rpc/methods/categories.mjs +156 -135
- package/dist/rpc/methods/cbd.mjs +52 -49
- package/dist/rpc/methods/checkout/checkout.mjs +42 -39
- package/dist/rpc/methods/checkout/order.mjs +46 -40
- package/dist/rpc/methods/checkout/shopUser.mjs +112 -106
- package/dist/rpc/methods/navigationTrees.mjs +50 -32
- package/dist/rpc/methods/oauth/idp.mjs +64 -55
- package/dist/rpc/methods/products.mjs +224 -212
- package/dist/rpc/methods/promotion.mjs +46 -31
- package/dist/rpc/methods/search.mjs +26 -20
- package/dist/rpc/methods/session.mjs +291 -262
- package/dist/rpc/methods/shopConfiguration.mjs +12 -9
- package/dist/rpc/methods/user.mjs +87 -78
- package/dist/rpc/methods/variants.mjs +17 -14
- package/dist/rpc/methods/wishlist.mjs +71 -62
- package/dist/types/api/context.d.ts +2 -2
- package/dist/utils/hash.mjs +2 -7
- package/dist/utils/sapi.mjs +10 -7
- package/package.json +6 -7
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,15 @@
|
|
|
1
1
|
# @scayle/storefront-core
|
|
2
2
|
|
|
3
|
+
## 8.61.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fix `updateTokens` and `updateUser` return type from `void` to `Promise<void>` in `ContextWithSession`. The underlying implementations were already async (`await session.save()`), but the incorrect `void` type prevented call sites from knowing they needed to await the result. All call sites in the RPC methods and customer API now correctly await these calls, ensuring session state is persisted before execution continues.
|
|
8
|
+
|
|
9
|
+
## 8.61.2
|
|
10
|
+
|
|
11
|
+
No changes in this release.
|
|
12
|
+
|
|
3
13
|
## 8.61.1
|
|
4
14
|
|
|
5
15
|
No changes in this release.
|
|
@@ -13,23 +23,23 @@ No changes in this release.
|
|
|
13
23
|
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
24
|
|
|
15
25
|
```ts
|
|
16
|
-
import { defineRpcHandler, type RpcContext } from
|
|
26
|
+
import { defineRpcHandler, type RpcContext } from '@scayle/storefront-core'
|
|
17
27
|
|
|
18
28
|
// Safe, public read — eligible for CDN/browser caching
|
|
19
29
|
export const getNavigation = defineRpcHandler(
|
|
20
30
|
async (context: RpcContext) => {
|
|
21
31
|
/* ... */
|
|
22
32
|
},
|
|
23
|
-
{ method:
|
|
24
|
-
)
|
|
33
|
+
{ method: 'GET' },
|
|
34
|
+
)
|
|
25
35
|
|
|
26
36
|
// User-specific / Mutation — uses POST to prevent cache leakage
|
|
27
37
|
export const getBasket = defineRpcHandler(
|
|
28
38
|
async (context: RpcContext) => {
|
|
29
39
|
/* ... */
|
|
30
|
-
}
|
|
40
|
+
},
|
|
31
41
|
// method defaults to 'POST'
|
|
32
|
-
)
|
|
42
|
+
)
|
|
33
43
|
```
|
|
34
44
|
|
|
35
45
|
### Patch Changes
|
|
@@ -95,33 +105,33 @@ No changes in this release.
|
|
|
95
105
|
**Migration:**
|
|
96
106
|
|
|
97
107
|
```ts
|
|
98
|
-
import baseSlugify from
|
|
108
|
+
import baseSlugify from 'slugify'
|
|
99
109
|
|
|
100
110
|
const slugify = (url: string | undefined): string => {
|
|
101
|
-
return baseSlugify(url ??
|
|
111
|
+
return baseSlugify(url ?? '', {
|
|
102
112
|
lower: true,
|
|
103
113
|
remove: /[*+~.()'"!:@/#?]/g,
|
|
104
|
-
})
|
|
105
|
-
}
|
|
114
|
+
})
|
|
115
|
+
}
|
|
106
116
|
|
|
107
|
-
const localePath = useLocalePath()
|
|
117
|
+
const localePath = useLocalePath()
|
|
108
118
|
|
|
109
119
|
const getProductDetailRoute = (
|
|
110
120
|
id: number,
|
|
111
121
|
name?: string,
|
|
112
|
-
locale?: Locale
|
|
122
|
+
locale?: Locale,
|
|
113
123
|
): string => {
|
|
114
124
|
return localePath(
|
|
115
125
|
{
|
|
116
|
-
name:
|
|
126
|
+
name: 'p-productName-id',
|
|
117
127
|
params: {
|
|
118
128
|
productName: slugify(name),
|
|
119
129
|
id: `${id}`,
|
|
120
130
|
},
|
|
121
131
|
},
|
|
122
|
-
locale
|
|
123
|
-
)
|
|
124
|
-
}
|
|
132
|
+
locale,
|
|
133
|
+
)
|
|
134
|
+
}
|
|
125
135
|
```
|
|
126
136
|
|
|
127
137
|
## 8.59.1
|
|
@@ -178,7 +188,6 @@ No changes in this release.
|
|
|
178
188
|
- **\[Navigation\]** Exported Navigation V2 API types to provide TypeScript support for the new navigation endpoints.
|
|
179
189
|
|
|
180
190
|
The following types are now available from `@scayle/storefront-core`:
|
|
181
|
-
|
|
182
191
|
- `GetNavigationV2Parameters` - Parameters for fetching navigation trees via the V2 API
|
|
183
192
|
- `NavigationV2AllEndpointResponseData` - Response type for fetching all navigation trees
|
|
184
193
|
- `NavigationV2ByReferenceEndpointResponseData` - Response type for fetching a navigation tree by reference key
|
|
@@ -302,10 +311,10 @@ No changes in this release.
|
|
|
302
311
|
Example:
|
|
303
312
|
|
|
304
313
|
```ts
|
|
305
|
-
import { sha256 } from
|
|
314
|
+
import { sha256 } from '@scayle/storefront-core'
|
|
306
315
|
|
|
307
|
-
const hash = await sha256(
|
|
308
|
-
console.log(hash)
|
|
316
|
+
const hash = await sha256('hello')
|
|
317
|
+
console.log(hash) // '2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824'
|
|
309
318
|
```
|
|
310
319
|
|
|
311
320
|
### Patch Changes
|
|
@@ -322,7 +331,6 @@ No changes in this release.
|
|
|
322
331
|
- 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
332
|
|
|
324
333
|
Available keys:
|
|
325
|
-
|
|
326
334
|
- `SmartSortingKey.SALES_PUSH` - Promotes items with highest discounts and oldest inventory
|
|
327
335
|
- `SmartSortingKey.NEW_ARRIVALS` - Prioritizes recently added products with good availability
|
|
328
336
|
- `SmartSortingKey.BALANCED_OFFERINGS` - Balances recency, availability, discounts, and sales data
|
|
@@ -365,8 +373,8 @@ No changes in this release.
|
|
|
365
373
|
customer: {
|
|
366
374
|
groups: context.user?.groups,
|
|
367
375
|
},
|
|
368
|
-
}
|
|
369
|
-
})
|
|
376
|
+
}
|
|
377
|
+
})
|
|
370
378
|
```
|
|
371
379
|
|
|
372
380
|
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 +407,36 @@ No changes in this release.
|
|
|
399
407
|
#### Looking up by name (existing, now renamed):
|
|
400
408
|
|
|
401
409
|
```typescript
|
|
402
|
-
import { getAttributeValuesByName } from
|
|
410
|
+
import { getAttributeValuesByName } from '@scayle/storefront-core'
|
|
403
411
|
|
|
404
412
|
// Single-select attribute
|
|
405
|
-
const sizes = getAttributeValuesByName(product.attributes,
|
|
413
|
+
const sizes = getAttributeValuesByName(product.attributes, 'size')
|
|
406
414
|
// Returns: [{ id: 1, label: 'M', value: 'medium' }]
|
|
407
415
|
|
|
408
416
|
// Multi-select attribute
|
|
409
|
-
const colors = getAttributeValuesByName(product.attributes,
|
|
417
|
+
const colors = getAttributeValuesByName(product.attributes, 'color')
|
|
410
418
|
// Returns: [{ id: 1, label: 'Red' }, { id: 2, label: 'Blue' }]
|
|
411
419
|
|
|
412
420
|
// Non-existent attribute
|
|
413
|
-
const missing = getAttributeValuesByName(product.attributes,
|
|
421
|
+
const missing = getAttributeValuesByName(product.attributes, 'doesNotExist')
|
|
414
422
|
// Returns: []
|
|
415
423
|
```
|
|
416
424
|
|
|
417
425
|
#### Looking up by group ID (new):
|
|
418
426
|
|
|
419
427
|
```typescript
|
|
420
|
-
import { getAttributeValuesByGroupId } from
|
|
428
|
+
import { getAttributeValuesByGroupId } from '@scayle/storefront-core'
|
|
421
429
|
|
|
422
430
|
// Look up attribute by its numeric ID from the SCAYLE API
|
|
423
|
-
const promotionValues = getAttributeValuesByGroupId(product.attributes, 42)
|
|
431
|
+
const promotionValues = getAttributeValuesByGroupId(product.attributes, 42)
|
|
424
432
|
// Returns: [{ id: 123, label: 'Summer Sale', value: 'summer-2024' }]
|
|
425
433
|
|
|
426
434
|
// Non-existent attribute group
|
|
427
|
-
const missing = getAttributeValuesByGroupId(product.attributes, 9999)
|
|
435
|
+
const missing = getAttributeValuesByGroupId(product.attributes, 9999)
|
|
428
436
|
// Returns: []
|
|
429
437
|
```
|
|
430
438
|
|
|
431
439
|
### When to Use Each Function
|
|
432
|
-
|
|
433
440
|
- **`getAttributeValuesByName`**: Use when you know the attribute name key (e.g., 'color', 'size'). This is the most common use case in application code.
|
|
434
441
|
- **`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
442
|
|
|
@@ -520,10 +527,10 @@ No changes in this release.
|
|
|
520
527
|
|
|
521
528
|
```ts
|
|
522
529
|
const isComboDealType = (
|
|
523
|
-
promotion?: Promotion | null
|
|
530
|
+
promotion?: Promotion | null,
|
|
524
531
|
): promotion is Promotion<ComboDealEffect> => {
|
|
525
|
-
return promotion?.effect?.type === PromotionEffectType.COMBO_DEAL
|
|
526
|
-
}
|
|
532
|
+
return promotion?.effect?.type === PromotionEffectType.COMBO_DEAL
|
|
533
|
+
}
|
|
527
534
|
```
|
|
528
535
|
|
|
529
536
|
### Patch Changes
|
|
@@ -795,23 +802,23 @@ No changes in this release.
|
|
|
795
802
|
- 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
803
|
|
|
797
804
|
```ts
|
|
798
|
-
const { data } = useRpc(
|
|
805
|
+
const { data } = useRpc('getFilters', 'getFiltersKey', () => ({
|
|
799
806
|
where: {
|
|
800
807
|
minReduction: 10,
|
|
801
808
|
maxReduction: 20,
|
|
802
809
|
},
|
|
803
|
-
}))
|
|
810
|
+
}))
|
|
804
811
|
|
|
805
812
|
const { data } = useRpc(
|
|
806
|
-
|
|
807
|
-
|
|
813
|
+
'getProductsByCategory',
|
|
814
|
+
'getProductsByCategoryKey',
|
|
808
815
|
() => ({
|
|
809
816
|
where: {
|
|
810
817
|
minReduction: 10,
|
|
811
818
|
maxReduction: 20,
|
|
812
819
|
},
|
|
813
|
-
})
|
|
814
|
-
)
|
|
820
|
+
}),
|
|
821
|
+
)
|
|
815
822
|
```
|
|
816
823
|
|
|
817
824
|
## 8.30.3
|
|
@@ -842,28 +849,28 @@ No changes in this release.
|
|
|
842
849
|
|
|
843
850
|
```ts
|
|
844
851
|
export const existingHandlerWithoutParams = async (_context: RpcContext) => {
|
|
845
|
-
return
|
|
846
|
-
}
|
|
852
|
+
return 'existing handler'
|
|
853
|
+
}
|
|
847
854
|
|
|
848
855
|
export const existingHandlerWithParams = async (
|
|
849
856
|
{ name }: { name: string },
|
|
850
|
-
_context: RpcContext
|
|
857
|
+
_context: RpcContext,
|
|
851
858
|
) => {
|
|
852
|
-
return name
|
|
853
|
-
}
|
|
859
|
+
return name
|
|
860
|
+
}
|
|
854
861
|
|
|
855
862
|
// will become
|
|
856
863
|
|
|
857
864
|
export const existingHandlerWithoutParams = defineRpcHandler(
|
|
858
865
|
async (_context: RpcContext) => {
|
|
859
|
-
return
|
|
860
|
-
}
|
|
861
|
-
)
|
|
866
|
+
return 'existing handler'
|
|
867
|
+
},
|
|
868
|
+
)
|
|
862
869
|
export const existingHandlerWithParams = defineRpcHandler(
|
|
863
870
|
async ({ name }: { name: string }, _context: RpcContext) => {
|
|
864
|
-
return name
|
|
865
|
-
}
|
|
866
|
-
)
|
|
871
|
+
return name
|
|
872
|
+
},
|
|
873
|
+
)
|
|
867
874
|
```
|
|
868
875
|
|
|
869
876
|
### Patch Changes
|
|
@@ -880,15 +887,15 @@ No changes in this release.
|
|
|
880
887
|
- 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
888
|
|
|
882
889
|
```ts
|
|
883
|
-
import { rpcMethods } from
|
|
890
|
+
import { rpcMethods } from '@scayle/storefront-core'
|
|
884
891
|
|
|
885
|
-
rpcMethods.getCategoryTree({ hideEmptyCategories: true }, rpcContext)
|
|
892
|
+
rpcMethods.getCategoryTree({ hideEmptyCategories: true }, rpcContext)
|
|
886
893
|
```
|
|
887
894
|
|
|
888
895
|
or
|
|
889
896
|
|
|
890
897
|
```ts
|
|
891
|
-
import { useCategoryTree } from
|
|
898
|
+
import { useCategoryTree } from '#storefront/composables'
|
|
892
899
|
|
|
893
900
|
const { data: rootCategories, status } = useCategoryTree(
|
|
894
901
|
{
|
|
@@ -896,8 +903,8 @@ No changes in this release.
|
|
|
896
903
|
hideEmptyCategories: true,
|
|
897
904
|
},
|
|
898
905
|
},
|
|
899
|
-
|
|
900
|
-
)
|
|
906
|
+
'category-navigation-tree',
|
|
907
|
+
)
|
|
901
908
|
```
|
|
902
909
|
|
|
903
910
|
### Patch Changes
|
|
@@ -1063,7 +1070,6 @@ No changes in this release.
|
|
|
1063
1070
|
### Minor Changes
|
|
1064
1071
|
|
|
1065
1072
|
- Expose the following filter types from `storefront-api`:
|
|
1066
|
-
|
|
1067
1073
|
- `FilterItemWithValues`
|
|
1068
1074
|
- `BooleanFilterItemWithValues`
|
|
1069
1075
|
- `RangeFilterItemWithValues`
|
|
@@ -1258,7 +1264,6 @@ No changes in this release.
|
|
|
1258
1264
|
- Simplified exported `Order` interface by relying directly on primitive types instead of having multiple intermediate types that resolve to primitives.
|
|
1259
1265
|
|
|
1260
1266
|
The following formerly exported intermediate types have been replaces by primitive types:
|
|
1261
|
-
|
|
1262
1267
|
- resolving to `string` now
|
|
1263
1268
|
- `TimestampOfOrderConfirmation`
|
|
1264
1269
|
- `CharacterCurrencyCode`
|
|
@@ -1329,12 +1334,12 @@ To get the default campaign key, you can call the RPC method:
|
|
|
1329
1334
|
```typescript
|
|
1330
1335
|
// Before
|
|
1331
1336
|
async function rpcMethod(context) {
|
|
1332
|
-
const campaignKey = { context }
|
|
1337
|
+
const campaignKey = { context }
|
|
1333
1338
|
// ...
|
|
1334
1339
|
}
|
|
1335
1340
|
// After
|
|
1336
1341
|
async function rpcMethod(context) {
|
|
1337
|
-
const campaignKey = await context.callRpc?.(
|
|
1342
|
+
const campaignKey = await context.callRpc?.('getCampaignKey')
|
|
1338
1343
|
// ...
|
|
1339
1344
|
}
|
|
1340
1345
|
```
|
|
@@ -1495,7 +1500,6 @@ See [Overriding core RPC Methods](https://scayle.dev/en/core-documentation/store
|
|
|
1495
1500
|
### Minor Changes
|
|
1496
1501
|
|
|
1497
1502
|
- **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
1503
|
- `getBrands`
|
|
1500
1504
|
- `getBrandById`
|
|
1501
1505
|
- `getCategoryByPath`
|
|
@@ -1517,53 +1521,51 @@ See [Overriding core RPC Methods](https://scayle.dev/en/core-documentation/store
|
|
|
1517
1521
|
### Major Changes
|
|
1518
1522
|
|
|
1519
1523
|
- **\[💥 BREAKING\]** The `getBadgeLabel` helper function has been removed, giving you more control over badge label display.
|
|
1520
|
-
|
|
1521
1524
|
- **Note:** This change doesn't affect projects using SCAYLE Storefront Boilerplate v1.0 or later.
|
|
1522
1525
|
- For applications based on older versions or using `getBadgeLabel`, you can refer to the previous implementation below:
|
|
1523
1526
|
|
|
1524
1527
|
```ts
|
|
1525
1528
|
const BadgeLabel = {
|
|
1526
|
-
NEW:
|
|
1527
|
-
SOLD_OUT:
|
|
1528
|
-
ONLINE_EXCLUSIVE:
|
|
1529
|
-
SUSTAINABLE:
|
|
1530
|
-
PREMIUM:
|
|
1531
|
-
DEFAULT:
|
|
1532
|
-
} as const
|
|
1529
|
+
NEW: 'new',
|
|
1530
|
+
SOLD_OUT: 'sold_out',
|
|
1531
|
+
ONLINE_EXCLUSIVE: 'online_exclusive',
|
|
1532
|
+
SUSTAINABLE: 'sustainable',
|
|
1533
|
+
PREMIUM: 'premium',
|
|
1534
|
+
DEFAULT: '',
|
|
1535
|
+
} as const
|
|
1533
1536
|
|
|
1534
1537
|
type BadgeLabelParamsKeys =
|
|
1535
|
-
|
|
|
1536
|
-
|
|
|
1537
|
-
|
|
|
1538
|
-
|
|
|
1539
|
-
|
|
|
1540
|
-
type BadgeLabelParams = Partial<Record<BadgeLabelParamsKeys, boolean
|
|
1538
|
+
| 'isNew'
|
|
1539
|
+
| 'isSoldOut'
|
|
1540
|
+
| 'isOnlineOnly'
|
|
1541
|
+
| 'isSustainable'
|
|
1542
|
+
| 'isPremium'
|
|
1543
|
+
type BadgeLabelParams = Partial<Record<BadgeLabelParamsKeys, boolean>>
|
|
1541
1544
|
|
|
1542
1545
|
const getBadgeLabel = (params: BadgeLabelParams = {}): string => {
|
|
1543
1546
|
if (!params) {
|
|
1544
|
-
return BadgeLabel.DEFAULT
|
|
1547
|
+
return BadgeLabel.DEFAULT
|
|
1545
1548
|
}
|
|
1546
1549
|
const { isNew, isSoldOut, isOnlineOnly, isSustainable, isPremium } =
|
|
1547
|
-
params
|
|
1550
|
+
params
|
|
1548
1551
|
|
|
1549
1552
|
if (isNew) {
|
|
1550
|
-
return BadgeLabel.NEW
|
|
1553
|
+
return BadgeLabel.NEW
|
|
1551
1554
|
} else if (isSoldOut) {
|
|
1552
|
-
return BadgeLabel.SOLD_OUT
|
|
1555
|
+
return BadgeLabel.SOLD_OUT
|
|
1553
1556
|
} else if (isOnlineOnly) {
|
|
1554
|
-
return BadgeLabel.ONLINE_EXCLUSIVE
|
|
1557
|
+
return BadgeLabel.ONLINE_EXCLUSIVE
|
|
1555
1558
|
} else if (isSustainable) {
|
|
1556
|
-
return BadgeLabel.SUSTAINABLE
|
|
1559
|
+
return BadgeLabel.SUSTAINABLE
|
|
1557
1560
|
} else if (isPremium) {
|
|
1558
|
-
return BadgeLabel.PREMIUM
|
|
1561
|
+
return BadgeLabel.PREMIUM
|
|
1559
1562
|
} else {
|
|
1560
|
-
return BadgeLabel.DEFAULT
|
|
1563
|
+
return BadgeLabel.DEFAULT
|
|
1561
1564
|
}
|
|
1562
|
-
}
|
|
1565
|
+
}
|
|
1563
1566
|
```
|
|
1564
1567
|
|
|
1565
1568
|
- **\[💥 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
1569
|
- **NOTE:** These changes impact your environment variables used for deployments. Please check your infrastructure and deployment setup and adapt accordingly!
|
|
1568
1570
|
- _Previous `bapi` Configuration in `nuxt.config.ts`_
|
|
1569
1571
|
|
|
@@ -1575,15 +1577,15 @@ See [Overriding core RPC Methods](https://scayle.dev/en/core-documentation/store
|
|
|
1575
1577
|
storefront: {
|
|
1576
1578
|
// ...
|
|
1577
1579
|
bapi: {
|
|
1578
|
-
host:
|
|
1579
|
-
token:
|
|
1580
|
+
host: '...',
|
|
1581
|
+
token: '...',
|
|
1580
1582
|
},
|
|
1581
1583
|
// ...
|
|
1582
1584
|
},
|
|
1583
1585
|
// ...
|
|
1584
1586
|
},
|
|
1585
1587
|
// ...
|
|
1586
|
-
}
|
|
1588
|
+
}
|
|
1587
1589
|
```
|
|
1588
1590
|
|
|
1589
1591
|
- _Legacy Environment Variables:_
|
|
@@ -1603,15 +1605,15 @@ See [Overriding core RPC Methods](https://scayle.dev/en/core-documentation/store
|
|
|
1603
1605
|
storefront: {
|
|
1604
1606
|
// ...
|
|
1605
1607
|
sapi: {
|
|
1606
|
-
host:
|
|
1607
|
-
token:
|
|
1608
|
+
host: '...',
|
|
1609
|
+
token: '...',
|
|
1608
1610
|
},
|
|
1609
1611
|
// ...
|
|
1610
1612
|
},
|
|
1611
1613
|
// ...
|
|
1612
1614
|
},
|
|
1613
1615
|
// ...
|
|
1614
|
-
}
|
|
1616
|
+
}
|
|
1615
1617
|
```
|
|
1616
1618
|
|
|
1617
1619
|
- _New Environment Variables:_
|
|
@@ -1624,28 +1626,26 @@ See [Overriding core RPC Methods](https://scayle.dev/en/core-documentation/store
|
|
|
1624
1626
|
- **\[💥 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
1627
|
- **\[💥 BREAKING\]** This release removes the `RedisCache` provider. We now use `UnstorageCache` which also supports Redis as a backing store.
|
|
1626
1628
|
- **\[💥 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
1629
|
- _Previous Usage of `user.authentication.storefrontAccessToken`:_
|
|
1629
1630
|
|
|
1630
1631
|
```ts
|
|
1631
1632
|
const { data, fetching, fetch, error, status } = useUser(
|
|
1632
|
-
|
|
1633
|
+
'getUser',
|
|
1633
1634
|
// ...
|
|
1634
|
-
)
|
|
1635
|
-
data.value.user.authentication.storefrontAccessToken
|
|
1635
|
+
)
|
|
1636
|
+
data.value.user.authentication.storefrontAccessToken
|
|
1636
1637
|
```
|
|
1637
1638
|
|
|
1638
1639
|
- _Current Usage of dedicated `getAccessToken` RPC method:_
|
|
1639
1640
|
|
|
1640
1641
|
```ts
|
|
1641
1642
|
const { data: accessToken } = useRpc(
|
|
1642
|
-
|
|
1643
|
+
'getAccessToken',
|
|
1643
1644
|
// ...
|
|
1644
|
-
)
|
|
1645
|
+
)
|
|
1645
1646
|
```
|
|
1646
1647
|
|
|
1647
1648
|
- **\[💥 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
1649
|
- _Overriding default `hashAlgorithm` in `nuxt.config.ts`:_
|
|
1650
1650
|
|
|
1651
1651
|
```ts
|
|
@@ -1664,32 +1664,31 @@ See [Overriding core RPC Methods](https://scayle.dev/en/core-documentation/store
|
|
|
1664
1664
|
// ...
|
|
1665
1665
|
},
|
|
1666
1666
|
// ...
|
|
1667
|
-
})
|
|
1667
|
+
})
|
|
1668
1668
|
```
|
|
1669
1669
|
|
|
1670
1670
|
- **\[💥 BREAKING\]** The attribute `loginShopId` is removed from the `ShopUser` interface as the shop now uses session cookies.
|
|
1671
1671
|
- **\[💥 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
1672
|
- _Previous Usage of `searchProducts` RPC method:_
|
|
1674
1673
|
|
|
1675
1674
|
```ts
|
|
1676
|
-
const getSearchSuggestionsRpc = useRpcCall(
|
|
1675
|
+
const getSearchSuggestionsRpc = useRpcCall('searchProducts')
|
|
1677
1676
|
|
|
1678
1677
|
data.value = await searchProducts({
|
|
1679
1678
|
term: String(searchQuery.value),
|
|
1680
1679
|
...params,
|
|
1681
|
-
})
|
|
1680
|
+
})
|
|
1682
1681
|
```
|
|
1683
1682
|
|
|
1684
1683
|
- _Current Usage of `getSearchSuggestions` RPC method:_
|
|
1685
1684
|
|
|
1686
1685
|
```ts
|
|
1687
|
-
const getSearchSuggestionsRpc = useRpcCall(
|
|
1686
|
+
const getSearchSuggestionsRpc = useRpcCall('getSearchSuggestions')
|
|
1688
1687
|
|
|
1689
1688
|
data.value = await getSearchSuggestionsRpc({
|
|
1690
1689
|
term: String(searchQuery.value),
|
|
1691
1690
|
...params,
|
|
1692
|
-
})
|
|
1691
|
+
})
|
|
1693
1692
|
```
|
|
1694
1693
|
|
|
1695
1694
|
- **\[💥 BREAKING\]** Improved basket updating: Adding an item to your basket with a reduced quantity will now correctly update the basket contents.
|
package/dist/api/customer.mjs
CHANGED
|
@@ -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 {
|
|
@@ -60,7 +58,7 @@ export class CustomerAPIClient {
|
|
|
60
58
|
grant_type: "refresh_token",
|
|
61
59
|
refresh_token: this.context.refreshToken
|
|
62
60
|
});
|
|
63
|
-
this.context.updateTokens({
|
|
61
|
+
await this.context.updateTokens({
|
|
64
62
|
accessToken: tokens?.access_token,
|
|
65
63
|
refreshToken: tokens?.refresh_token
|
|
66
64
|
});
|
package/dist/api/oauth.mjs
CHANGED
|
@@ -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
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
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: {
|