@scayle/storefront-core 8.15.0 → 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 CHANGED
@@ -1,5 +1,15 @@
1
1
  # @scayle/storefront-core
2
2
 
3
+ ## 8.16.0
4
+
5
+ ## 8.15.1
6
+
7
+ ### Patch Changes
8
+
9
+ **Dependencies**
10
+
11
+ - Updated dependency to @scayle/storefront-api@18.2.1
12
+
3
13
  ## 8.15.0
4
14
 
5
15
  ### Minor Changes
@@ -192,12 +202,12 @@ To get the default campaign key, you can call the RPC method:
192
202
  ```typescript
193
203
  // Before
194
204
  async function rpcMethod(context) {
195
- const campaignKey = { context };
205
+ const campaignKey = { context }
196
206
  // ...
197
207
  }
198
208
  // After
199
209
  async function rpcMethod(context) {
200
- const campaignKey = await context.callRpc?.("getCampaignKey");
210
+ const campaignKey = await context.callRpc?.('getCampaignKey')
201
211
  // ...
202
212
  }
203
213
  ```
@@ -238,11 +248,11 @@ See [Overriding core RPC Methods](https://scayle.dev/en/storefront-guide/develop
238
248
  This change will primarily affect users who are currently using the CommonJS format of this package. To update your code, you should replace `require` statements with `import` statements and update your build tooling if necessary.
239
249
 
240
250
  ```TypeScript
241
- const { ... } = require('@scayle/storefront-core');
251
+ const { ... } = require('@scayle/storefront-core')
242
252
 
243
253
  // will become
244
254
 
245
- import { ... } from '@scayle/storefront-core';
255
+ import { ... } from '@scayle/storefront-core'
246
256
  ```
247
257
 
248
258
  ### Patch Changes
@@ -260,11 +270,11 @@ See [Overriding core RPC Methods](https://scayle.dev/en/storefront-guide/develop
260
270
  This change will primarily affect users who are currently using the CommonJS format of this package. To update your code, you should replace `require` statements with `import` statements and update your build tooling if necessary.
261
271
 
262
272
  ```TypeScript
263
- const { ... } = require('@scayle/storefront-core');
273
+ const { ... } = require('@scayle/storefront-core')
264
274
 
265
275
  // will become
266
276
 
267
- import { ... } from '@scayle/storefront-core';
277
+ import { ... } from '@scayle/storefront-core'
268
278
  ```
269
279
 
270
280
  ## 8.4.0
@@ -386,43 +396,43 @@ See [Overriding core RPC Methods](https://scayle.dev/en/storefront-guide/develop
386
396
 
387
397
  ```ts
388
398
  const BadgeLabel = {
389
- NEW: "new",
390
- SOLD_OUT: "sold_out",
391
- ONLINE_EXCLUSIVE: "online_exclusive",
392
- SUSTAINABLE: "sustainable",
393
- PREMIUM: "premium",
394
- DEFAULT: "",
395
- } 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
396
406
 
397
407
  type BadgeLabelParamsKeys =
398
- | "isNew"
399
- | "isSoldOut"
400
- | "isOnlineOnly"
401
- | "isSustainable"
402
- | "isPremium";
403
- type BadgeLabelParams = Partial<Record<BadgeLabelParamsKeys, boolean>>;
408
+ | 'isNew'
409
+ | 'isSoldOut'
410
+ | 'isOnlineOnly'
411
+ | 'isSustainable'
412
+ | 'isPremium'
413
+ type BadgeLabelParams = Partial<Record<BadgeLabelParamsKeys, boolean>>
404
414
 
405
415
  const getBadgeLabel = (params: BadgeLabelParams = {}): string => {
406
416
  if (!params) {
407
- return BadgeLabel.DEFAULT;
417
+ return BadgeLabel.DEFAULT
408
418
  }
409
419
  const { isNew, isSoldOut, isOnlineOnly, isSustainable, isPremium } =
410
- params;
420
+ params
411
421
 
412
422
  if (isNew) {
413
- return BadgeLabel.NEW;
423
+ return BadgeLabel.NEW
414
424
  } else if (isSoldOut) {
415
- return BadgeLabel.SOLD_OUT;
425
+ return BadgeLabel.SOLD_OUT
416
426
  } else if (isOnlineOnly) {
417
- return BadgeLabel.ONLINE_EXCLUSIVE;
427
+ return BadgeLabel.ONLINE_EXCLUSIVE
418
428
  } else if (isSustainable) {
419
- return BadgeLabel.SUSTAINABLE;
429
+ return BadgeLabel.SUSTAINABLE
420
430
  } else if (isPremium) {
421
- return BadgeLabel.PREMIUM;
431
+ return BadgeLabel.PREMIUM
422
432
  } else {
423
- return BadgeLabel.DEFAULT;
433
+ return BadgeLabel.DEFAULT
424
434
  }
425
- };
435
+ }
426
436
  ```
427
437
 
428
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`.
@@ -438,15 +448,15 @@ See [Overriding core RPC Methods](https://scayle.dev/en/storefront-guide/develop
438
448
  storefront: {
439
449
  // ...
440
450
  bapi: {
441
- host: "...",
442
- token: "...",
451
+ host: '...',
452
+ token: '...',
443
453
  },
444
454
  // ...
445
455
  },
446
456
  // ...
447
457
  },
448
458
  // ...
449
- };
459
+ }
450
460
  ```
451
461
 
452
462
  - _Legacy Environment Variables:_
@@ -466,15 +476,15 @@ See [Overriding core RPC Methods](https://scayle.dev/en/storefront-guide/develop
466
476
  storefront: {
467
477
  // ...
468
478
  sapi: {
469
- host: "...",
470
- token: "...",
479
+ host: '...',
480
+ token: '...',
471
481
  },
472
482
  // ...
473
483
  },
474
484
  // ...
475
485
  },
476
486
  // ...
477
- };
487
+ }
478
488
  ```
479
489
 
480
490
  - _New Environment Variables:_
@@ -492,19 +502,19 @@ See [Overriding core RPC Methods](https://scayle.dev/en/storefront-guide/develop
492
502
 
493
503
  ```ts
494
504
  const { data, fetching, fetch, error, status } = useUser(
495
- "getUser"
505
+ 'getUser',
496
506
  // ...
497
- );
498
- data.value.user.authentication.storefrontAccessToken;
507
+ )
508
+ data.value.user.authentication.storefrontAccessToken
499
509
  ```
500
510
 
501
511
  - _Current Usage of dedicated `getAccessToken` RPC method:_
502
512
 
503
513
  ```ts
504
514
  const { data: accessToken } = useRpc(
505
- "getAccessToken"
515
+ 'getAccessToken',
506
516
  // ...
507
- );
517
+ )
508
518
  ```
509
519
 
510
520
  - **\[💥 BREAKING\]** We've enhanced security for basket and wishlist keys by switching the default hashing algorithm from MD5 to the more robust SHA256.
@@ -527,7 +537,7 @@ See [Overriding core RPC Methods](https://scayle.dev/en/storefront-guide/develop
527
537
  // ...
528
538
  },
529
539
  // ...
530
- });
540
+ })
531
541
  ```
532
542
 
533
543
  - **\[💥 BREAKING\]** The attribute `loginShopId` is removed from the `ShopUser` interface as the shop now uses session cookies.
@@ -536,23 +546,23 @@ See [Overriding core RPC Methods](https://scayle.dev/en/storefront-guide/develop
536
546
  - _Previous Usage of `searchProducts` RPC method:_
537
547
 
538
548
  ```ts
539
- const getSearchSuggestionsRpc = useRpcCall("searchProducts");
549
+ const getSearchSuggestionsRpc = useRpcCall('searchProducts')
540
550
 
541
551
  data.value = await searchProducts({
542
552
  term: String(searchQuery.value),
543
553
  ...params,
544
- });
554
+ })
545
555
  ```
546
556
 
547
557
  - _Current Usage of `getSearchSuggestions` RPC method:_
548
558
 
549
559
  ```ts
550
- const getSearchSuggestionsRpc = useRpcCall("getSearchSuggestions");
560
+ const getSearchSuggestionsRpc = useRpcCall('getSearchSuggestions')
551
561
 
552
562
  data.value = await getSearchSuggestionsRpc({
553
563
  term: String(searchQuery.value),
554
564
  ...params,
555
- });
565
+ })
556
566
  ```
557
567
 
558
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.15.0"}`).setProtectedHeader({ alg: "HS256", typ: "JWT" }).sign(secret);
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.15.0",
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",
@@ -63,7 +63,7 @@
63
63
  "fishery": "^2.2.3"
64
64
  },
65
65
  "dependencies": {
66
- "@scayle/storefront-api": "18.2.0",
66
+ "@scayle/storefront-api": "18.2.1",
67
67
  "@scayle/unstorage-scayle-kv-driver": "0.1.1",
68
68
  "crypto-js": "^4.2.0",
69
69
  "hookable": "^5.5.3",
@@ -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.13.16",
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",