@scayle/storefront-core 8.15.1 → 8.16.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 +42 -40
- package/dist/rpc/methods/checkout/checkout.mjs +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# @scayle/storefront-core
|
|
2
2
|
|
|
3
|
+
## 8.16.0
|
|
4
|
+
|
|
3
5
|
## 8.15.1
|
|
4
6
|
|
|
5
7
|
### Patch Changes
|
|
@@ -200,12 +202,12 @@ To get the default campaign key, you can call the RPC method:
|
|
|
200
202
|
```typescript
|
|
201
203
|
// Before
|
|
202
204
|
async function rpcMethod(context) {
|
|
203
|
-
const campaignKey = { context }
|
|
205
|
+
const campaignKey = { context }
|
|
204
206
|
// ...
|
|
205
207
|
}
|
|
206
208
|
// After
|
|
207
209
|
async function rpcMethod(context) {
|
|
208
|
-
const campaignKey = await context.callRpc?.(
|
|
210
|
+
const campaignKey = await context.callRpc?.('getCampaignKey')
|
|
209
211
|
// ...
|
|
210
212
|
}
|
|
211
213
|
```
|
|
@@ -394,43 +396,43 @@ See [Overriding core RPC Methods](https://scayle.dev/en/storefront-guide/develop
|
|
|
394
396
|
|
|
395
397
|
```ts
|
|
396
398
|
const BadgeLabel = {
|
|
397
|
-
NEW:
|
|
398
|
-
SOLD_OUT:
|
|
399
|
-
ONLINE_EXCLUSIVE:
|
|
400
|
-
SUSTAINABLE:
|
|
401
|
-
PREMIUM:
|
|
402
|
-
DEFAULT:
|
|
403
|
-
} as const
|
|
399
|
+
NEW: 'new',
|
|
400
|
+
SOLD_OUT: 'sold_out',
|
|
401
|
+
ONLINE_EXCLUSIVE: 'online_exclusive',
|
|
402
|
+
SUSTAINABLE: 'sustainable',
|
|
403
|
+
PREMIUM: 'premium',
|
|
404
|
+
DEFAULT: '',
|
|
405
|
+
} as const
|
|
404
406
|
|
|
405
407
|
type BadgeLabelParamsKeys =
|
|
406
|
-
|
|
|
407
|
-
|
|
|
408
|
-
|
|
|
409
|
-
|
|
|
410
|
-
|
|
|
411
|
-
type BadgeLabelParams = Partial<Record<BadgeLabelParamsKeys, boolean
|
|
408
|
+
| 'isNew'
|
|
409
|
+
| 'isSoldOut'
|
|
410
|
+
| 'isOnlineOnly'
|
|
411
|
+
| 'isSustainable'
|
|
412
|
+
| 'isPremium'
|
|
413
|
+
type BadgeLabelParams = Partial<Record<BadgeLabelParamsKeys, boolean>>
|
|
412
414
|
|
|
413
415
|
const getBadgeLabel = (params: BadgeLabelParams = {}): string => {
|
|
414
416
|
if (!params) {
|
|
415
|
-
return BadgeLabel.DEFAULT
|
|
417
|
+
return BadgeLabel.DEFAULT
|
|
416
418
|
}
|
|
417
419
|
const { isNew, isSoldOut, isOnlineOnly, isSustainable, isPremium } =
|
|
418
|
-
params
|
|
420
|
+
params
|
|
419
421
|
|
|
420
422
|
if (isNew) {
|
|
421
|
-
return BadgeLabel.NEW
|
|
423
|
+
return BadgeLabel.NEW
|
|
422
424
|
} else if (isSoldOut) {
|
|
423
|
-
return BadgeLabel.SOLD_OUT
|
|
425
|
+
return BadgeLabel.SOLD_OUT
|
|
424
426
|
} else if (isOnlineOnly) {
|
|
425
|
-
return BadgeLabel.ONLINE_EXCLUSIVE
|
|
427
|
+
return BadgeLabel.ONLINE_EXCLUSIVE
|
|
426
428
|
} else if (isSustainable) {
|
|
427
|
-
return BadgeLabel.SUSTAINABLE
|
|
429
|
+
return BadgeLabel.SUSTAINABLE
|
|
428
430
|
} else if (isPremium) {
|
|
429
|
-
return BadgeLabel.PREMIUM
|
|
431
|
+
return BadgeLabel.PREMIUM
|
|
430
432
|
} else {
|
|
431
|
-
return BadgeLabel.DEFAULT
|
|
433
|
+
return BadgeLabel.DEFAULT
|
|
432
434
|
}
|
|
433
|
-
}
|
|
435
|
+
}
|
|
434
436
|
```
|
|
435
437
|
|
|
436
438
|
- **\[💥 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`.
|
|
@@ -446,15 +448,15 @@ See [Overriding core RPC Methods](https://scayle.dev/en/storefront-guide/develop
|
|
|
446
448
|
storefront: {
|
|
447
449
|
// ...
|
|
448
450
|
bapi: {
|
|
449
|
-
host:
|
|
450
|
-
token:
|
|
451
|
+
host: '...',
|
|
452
|
+
token: '...',
|
|
451
453
|
},
|
|
452
454
|
// ...
|
|
453
455
|
},
|
|
454
456
|
// ...
|
|
455
457
|
},
|
|
456
458
|
// ...
|
|
457
|
-
}
|
|
459
|
+
}
|
|
458
460
|
```
|
|
459
461
|
|
|
460
462
|
- _Legacy Environment Variables:_
|
|
@@ -474,15 +476,15 @@ See [Overriding core RPC Methods](https://scayle.dev/en/storefront-guide/develop
|
|
|
474
476
|
storefront: {
|
|
475
477
|
// ...
|
|
476
478
|
sapi: {
|
|
477
|
-
host:
|
|
478
|
-
token:
|
|
479
|
+
host: '...',
|
|
480
|
+
token: '...',
|
|
479
481
|
},
|
|
480
482
|
// ...
|
|
481
483
|
},
|
|
482
484
|
// ...
|
|
483
485
|
},
|
|
484
486
|
// ...
|
|
485
|
-
}
|
|
487
|
+
}
|
|
486
488
|
```
|
|
487
489
|
|
|
488
490
|
- _New Environment Variables:_
|
|
@@ -500,19 +502,19 @@ See [Overriding core RPC Methods](https://scayle.dev/en/storefront-guide/develop
|
|
|
500
502
|
|
|
501
503
|
```ts
|
|
502
504
|
const { data, fetching, fetch, error, status } = useUser(
|
|
503
|
-
|
|
505
|
+
'getUser',
|
|
504
506
|
// ...
|
|
505
|
-
)
|
|
506
|
-
data.value.user.authentication.storefrontAccessToken
|
|
507
|
+
)
|
|
508
|
+
data.value.user.authentication.storefrontAccessToken
|
|
507
509
|
```
|
|
508
510
|
|
|
509
511
|
- _Current Usage of dedicated `getAccessToken` RPC method:_
|
|
510
512
|
|
|
511
513
|
```ts
|
|
512
514
|
const { data: accessToken } = useRpc(
|
|
513
|
-
|
|
515
|
+
'getAccessToken',
|
|
514
516
|
// ...
|
|
515
|
-
)
|
|
517
|
+
)
|
|
516
518
|
```
|
|
517
519
|
|
|
518
520
|
- **\[💥 BREAKING\]** We've enhanced security for basket and wishlist keys by switching the default hashing algorithm from MD5 to the more robust SHA256.
|
|
@@ -535,7 +537,7 @@ See [Overriding core RPC Methods](https://scayle.dev/en/storefront-guide/develop
|
|
|
535
537
|
// ...
|
|
536
538
|
},
|
|
537
539
|
// ...
|
|
538
|
-
})
|
|
540
|
+
})
|
|
539
541
|
```
|
|
540
542
|
|
|
541
543
|
- **\[💥 BREAKING\]** The attribute `loginShopId` is removed from the `ShopUser` interface as the shop now uses session cookies.
|
|
@@ -544,23 +546,23 @@ See [Overriding core RPC Methods](https://scayle.dev/en/storefront-guide/develop
|
|
|
544
546
|
- _Previous Usage of `searchProducts` RPC method:_
|
|
545
547
|
|
|
546
548
|
```ts
|
|
547
|
-
const getSearchSuggestionsRpc = useRpcCall(
|
|
549
|
+
const getSearchSuggestionsRpc = useRpcCall('searchProducts')
|
|
548
550
|
|
|
549
551
|
data.value = await searchProducts({
|
|
550
552
|
term: String(searchQuery.value),
|
|
551
553
|
...params,
|
|
552
|
-
})
|
|
554
|
+
})
|
|
553
555
|
```
|
|
554
556
|
|
|
555
557
|
- _Current Usage of `getSearchSuggestions` RPC method:_
|
|
556
558
|
|
|
557
559
|
```ts
|
|
558
|
-
const getSearchSuggestionsRpc = useRpcCall(
|
|
560
|
+
const getSearchSuggestionsRpc = useRpcCall('getSearchSuggestions')
|
|
559
561
|
|
|
560
562
|
data.value = await getSearchSuggestionsRpc({
|
|
561
563
|
term: String(searchQuery.value),
|
|
562
564
|
...params,
|
|
563
|
-
})
|
|
565
|
+
})
|
|
564
566
|
```
|
|
565
567
|
|
|
566
568
|
- **\[💥 BREAKING\]** Improved basket updating: Adding an item to your basket with a reduced quantity will now correctly update the basket contents.
|
|
@@ -36,7 +36,7 @@ export const getCheckoutToken = async function getCheckoutToken2(jwtPayload = {}
|
|
|
36
36
|
carrier,
|
|
37
37
|
basketId: context.basketKey,
|
|
38
38
|
campaignKey
|
|
39
|
-
}).setIssuedAt(now).setNotBefore(now).setExpirationTime("1h").setIssuer(`${"@scayle/storefront-core"}@${"8.
|
|
39
|
+
}).setIssuedAt(now).setNotBefore(now).setExpirationTime("1h").setIssuer(`${"@scayle/storefront-core"}@${"8.16.0"}`).setProtectedHeader({ alg: "HS256", typ: "JWT" }).sign(secret);
|
|
40
40
|
return {
|
|
41
41
|
accessToken: refreshedAccessToken,
|
|
42
42
|
checkoutJwt
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scayle/storefront-core",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.16.0",
|
|
4
4
|
"description": "Collection of essential utilities to work with the Storefront API",
|
|
5
5
|
"author": "SCAYLE Commerce Engine",
|
|
6
6
|
"license": "MIT",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"devDependencies": {
|
|
77
77
|
"@scayle/eslint-config-storefront": "4.5.0",
|
|
78
78
|
"@types/crypto-js": "4.2.2",
|
|
79
|
-
"@types/node": "22.
|
|
79
|
+
"@types/node": "22.14.0",
|
|
80
80
|
"@types/webpack-env": "1.18.8",
|
|
81
81
|
"@vitest/coverage-v8": "2.1.9",
|
|
82
82
|
"dprint": "0.49.1",
|