@scayle/storefront-core 8.14.3 → 8.15.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,19 @@
1
1
  # @scayle/storefront-core
2
2
 
3
+ ## 8.15.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Filter out orders from `user.orderSummary` that are not associated with the current shop ID.
8
+
9
+ ## 8.14.4
10
+
11
+ ### Patch Changes
12
+
13
+ **Dependencies**
14
+
15
+ - Updated dependency to @scayle/storefront-api@18.2.0
16
+
3
17
  ## 8.14.3
4
18
 
5
19
  ### Patch Changes
@@ -178,12 +192,12 @@ To get the default campaign key, you can call the RPC method:
178
192
  ```typescript
179
193
  // Before
180
194
  async function rpcMethod(context) {
181
- const campaignKey = { context }
195
+ const campaignKey = { context };
182
196
  // ...
183
197
  }
184
198
  // After
185
199
  async function rpcMethod(context) {
186
- const campaignKey = await context.callRpc?.('getCampaignKey')
200
+ const campaignKey = await context.callRpc?.("getCampaignKey");
187
201
  // ...
188
202
  }
189
203
  ```
@@ -372,43 +386,43 @@ See [Overriding core RPC Methods](https://scayle.dev/en/storefront-guide/develop
372
386
 
373
387
  ```ts
374
388
  const BadgeLabel = {
375
- NEW: 'new',
376
- SOLD_OUT: 'sold_out',
377
- ONLINE_EXCLUSIVE: 'online_exclusive',
378
- SUSTAINABLE: 'sustainable',
379
- PREMIUM: 'premium',
380
- DEFAULT: '',
381
- } as const
389
+ NEW: "new",
390
+ SOLD_OUT: "sold_out",
391
+ ONLINE_EXCLUSIVE: "online_exclusive",
392
+ SUSTAINABLE: "sustainable",
393
+ PREMIUM: "premium",
394
+ DEFAULT: "",
395
+ } as const;
382
396
 
383
397
  type BadgeLabelParamsKeys =
384
- | 'isNew'
385
- | 'isSoldOut'
386
- | 'isOnlineOnly'
387
- | 'isSustainable'
388
- | 'isPremium'
389
- type BadgeLabelParams = Partial<Record<BadgeLabelParamsKeys, boolean>>
398
+ | "isNew"
399
+ | "isSoldOut"
400
+ | "isOnlineOnly"
401
+ | "isSustainable"
402
+ | "isPremium";
403
+ type BadgeLabelParams = Partial<Record<BadgeLabelParamsKeys, boolean>>;
390
404
 
391
405
  const getBadgeLabel = (params: BadgeLabelParams = {}): string => {
392
406
  if (!params) {
393
- return BadgeLabel.DEFAULT
407
+ return BadgeLabel.DEFAULT;
394
408
  }
395
409
  const { isNew, isSoldOut, isOnlineOnly, isSustainable, isPremium } =
396
- params
410
+ params;
397
411
 
398
412
  if (isNew) {
399
- return BadgeLabel.NEW
413
+ return BadgeLabel.NEW;
400
414
  } else if (isSoldOut) {
401
- return BadgeLabel.SOLD_OUT
415
+ return BadgeLabel.SOLD_OUT;
402
416
  } else if (isOnlineOnly) {
403
- return BadgeLabel.ONLINE_EXCLUSIVE
417
+ return BadgeLabel.ONLINE_EXCLUSIVE;
404
418
  } else if (isSustainable) {
405
- return BadgeLabel.SUSTAINABLE
419
+ return BadgeLabel.SUSTAINABLE;
406
420
  } else if (isPremium) {
407
- return BadgeLabel.PREMIUM
421
+ return BadgeLabel.PREMIUM;
408
422
  } else {
409
- return BadgeLabel.DEFAULT
423
+ return BadgeLabel.DEFAULT;
410
424
  }
411
- }
425
+ };
412
426
  ```
413
427
 
414
428
  - **\[💥 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`.
@@ -424,15 +438,15 @@ See [Overriding core RPC Methods](https://scayle.dev/en/storefront-guide/develop
424
438
  storefront: {
425
439
  // ...
426
440
  bapi: {
427
- host: '...',
428
- token: '...',
441
+ host: "...",
442
+ token: "...",
429
443
  },
430
444
  // ...
431
445
  },
432
446
  // ...
433
447
  },
434
448
  // ...
435
- }
449
+ };
436
450
  ```
437
451
 
438
452
  - _Legacy Environment Variables:_
@@ -452,15 +466,15 @@ See [Overriding core RPC Methods](https://scayle.dev/en/storefront-guide/develop
452
466
  storefront: {
453
467
  // ...
454
468
  sapi: {
455
- host: '...',
456
- token: '...',
469
+ host: "...",
470
+ token: "...",
457
471
  },
458
472
  // ...
459
473
  },
460
474
  // ...
461
475
  },
462
476
  // ...
463
- }
477
+ };
464
478
  ```
465
479
 
466
480
  - _New Environment Variables:_
@@ -478,19 +492,19 @@ See [Overriding core RPC Methods](https://scayle.dev/en/storefront-guide/develop
478
492
 
479
493
  ```ts
480
494
  const { data, fetching, fetch, error, status } = useUser(
481
- 'getUser',
495
+ "getUser"
482
496
  // ...
483
- )
484
- data.value.user.authentication.storefrontAccessToken
497
+ );
498
+ data.value.user.authentication.storefrontAccessToken;
485
499
  ```
486
500
 
487
501
  - _Current Usage of dedicated `getAccessToken` RPC method:_
488
502
 
489
503
  ```ts
490
504
  const { data: accessToken } = useRpc(
491
- 'getAccessToken',
505
+ "getAccessToken"
492
506
  // ...
493
- )
507
+ );
494
508
  ```
495
509
 
496
510
  - **\[💥 BREAKING\]** We've enhanced security for basket and wishlist keys by switching the default hashing algorithm from MD5 to the more robust SHA256.
@@ -513,7 +527,7 @@ See [Overriding core RPC Methods](https://scayle.dev/en/storefront-guide/develop
513
527
  // ...
514
528
  },
515
529
  // ...
516
- })
530
+ });
517
531
  ```
518
532
 
519
533
  - **\[💥 BREAKING\]** The attribute `loginShopId` is removed from the `ShopUser` interface as the shop now uses session cookies.
@@ -522,23 +536,23 @@ See [Overriding core RPC Methods](https://scayle.dev/en/storefront-guide/develop
522
536
  - _Previous Usage of `searchProducts` RPC method:_
523
537
 
524
538
  ```ts
525
- const getSearchSuggestionsRpc = useRpcCall('searchProducts')
539
+ const getSearchSuggestionsRpc = useRpcCall("searchProducts");
526
540
 
527
541
  data.value = await searchProducts({
528
542
  term: String(searchQuery.value),
529
543
  ...params,
530
- })
544
+ });
531
545
  ```
532
546
 
533
547
  - _Current Usage of `getSearchSuggestions` RPC method:_
534
548
 
535
549
  ```ts
536
- const getSearchSuggestionsRpc = useRpcCall('getSearchSuggestions')
550
+ const getSearchSuggestionsRpc = useRpcCall("getSearchSuggestions");
537
551
 
538
552
  data.value = await getSearchSuggestionsRpc({
539
553
  term: String(searchQuery.value),
540
554
  ...params,
541
- })
555
+ });
542
556
  ```
543
557
 
544
558
  - **\[💥 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.14.3"}`).setProtectedHeader({ alg: "HS256", typ: "JWT" }).sign(secret);
39
+ }).setIssuedAt(now).setNotBefore(now).setExpirationTime("1h").setIssuer(`${"@scayle/storefront-core"}@${"8.15.0"}`).setProtectedHeader({ alg: "HS256", typ: "JWT" }).sign(secret);
40
40
  return {
41
41
  accessToken: refreshedAccessToken,
42
42
  checkoutJwt
@@ -1,4 +1,4 @@
1
- import type { PromotionsParams, PromotionsResponseData, RpcContext } from '../../types';
1
+ import type { PromotionsParams, RpcContext } from '../../types';
2
2
  /**
3
3
  * Retrieves promotions based on provided parameters.
4
4
  *
@@ -14,7 +14,7 @@ import type { PromotionsParams, PromotionsResponseData, RpcContext } from '../..
14
14
  * @returns A Promise that resolves with the promotion data.
15
15
  * It will return an `ErrorResponse` if the The Storefront API request fails.
16
16
  */
17
- export declare const getPromotions: (params: Omit<PromotionsParams, "ids"> | undefined, context: RpcContext) => Promise<Response | PromotionsResponseData>;
17
+ export declare const getPromotions: (params: Omit<PromotionsParams, "ids"> | undefined, context: RpcContext) => Promise<any>;
18
18
  /**
19
19
  * Retrieves currently active promotions.
20
20
  *
@@ -30,7 +30,7 @@ export declare const getPromotions: (params: Omit<PromotionsParams, "ids"> | und
30
30
  * @returns A Promise that resolves with the current promotion data.
31
31
  * It will return an `ErrorResponse` if the The Storefront API request fails.
32
32
  */
33
- export declare const getCurrentPromotions: (params: Omit<PromotionsParams, "ids" | "activeAt"> | undefined, context: RpcContext) => Promise<Response | PromotionsResponseData>;
33
+ export declare const getCurrentPromotions: (params: Omit<PromotionsParams, "ids" | "activeAt"> | undefined, context: RpcContext) => Promise<any>;
34
34
  /**
35
35
  * Retrieves promotions by their IDs.
36
36
  *
@@ -43,4 +43,4 @@ export declare const getCurrentPromotions: (params: Omit<PromotionsParams, "ids"
43
43
  * @returns A Promise that resolves with the promotion data.
44
44
  * It will return an `ErrorResponse` if the The Storefront API request fails.
45
45
  */
46
- export declare const getPromotionsByIds: (ids: string[], context: RpcContext) => Promise<Response | PromotionsResponseData>;
46
+ export declare const getPromotionsByIds: (ids: string[], context: RpcContext) => Promise<any>;
@@ -24,6 +24,9 @@ const fetchUser = async function fetchUser2({ accessToken }, context) {
24
24
  type: "idp"
25
25
  };
26
26
  }
27
+ user.orderSummary = user.orderSummary?.filter(
28
+ ({ shopId: shopId2 }) => shopId2 === context.shopId
29
+ );
27
30
  return user;
28
31
  };
29
32
  const refreshUser = async function refreshUser2(context) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scayle/storefront-core",
3
- "version": "8.14.3",
3
+ "version": "8.15.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.1.1",
66
+ "@scayle/storefront-api": "18.2.0",
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.14",
79
+ "@types/node": "22.13.16",
80
80
  "@types/webpack-env": "1.18.8",
81
81
  "@vitest/coverage-v8": "2.1.9",
82
82
  "dprint": "0.49.1",