@scayle/storefront-core 8.14.3 → 8.14.4

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,13 @@
1
1
  # @scayle/storefront-core
2
2
 
3
+ ## 8.14.4
4
+
5
+ ### Patch Changes
6
+
7
+ **Dependencies**
8
+
9
+ - Updated dependency to @scayle/storefront-api@18.2.0
10
+
3
11
  ## 8.14.3
4
12
 
5
13
  ### Patch Changes
@@ -178,12 +186,12 @@ To get the default campaign key, you can call the RPC method:
178
186
  ```typescript
179
187
  // Before
180
188
  async function rpcMethod(context) {
181
- const campaignKey = { context }
189
+ const campaignKey = { context };
182
190
  // ...
183
191
  }
184
192
  // After
185
193
  async function rpcMethod(context) {
186
- const campaignKey = await context.callRpc?.('getCampaignKey')
194
+ const campaignKey = await context.callRpc?.("getCampaignKey");
187
195
  // ...
188
196
  }
189
197
  ```
@@ -372,43 +380,43 @@ See [Overriding core RPC Methods](https://scayle.dev/en/storefront-guide/develop
372
380
 
373
381
  ```ts
374
382
  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
383
+ NEW: "new",
384
+ SOLD_OUT: "sold_out",
385
+ ONLINE_EXCLUSIVE: "online_exclusive",
386
+ SUSTAINABLE: "sustainable",
387
+ PREMIUM: "premium",
388
+ DEFAULT: "",
389
+ } as const;
382
390
 
383
391
  type BadgeLabelParamsKeys =
384
- | 'isNew'
385
- | 'isSoldOut'
386
- | 'isOnlineOnly'
387
- | 'isSustainable'
388
- | 'isPremium'
389
- type BadgeLabelParams = Partial<Record<BadgeLabelParamsKeys, boolean>>
392
+ | "isNew"
393
+ | "isSoldOut"
394
+ | "isOnlineOnly"
395
+ | "isSustainable"
396
+ | "isPremium";
397
+ type BadgeLabelParams = Partial<Record<BadgeLabelParamsKeys, boolean>>;
390
398
 
391
399
  const getBadgeLabel = (params: BadgeLabelParams = {}): string => {
392
400
  if (!params) {
393
- return BadgeLabel.DEFAULT
401
+ return BadgeLabel.DEFAULT;
394
402
  }
395
403
  const { isNew, isSoldOut, isOnlineOnly, isSustainable, isPremium } =
396
- params
404
+ params;
397
405
 
398
406
  if (isNew) {
399
- return BadgeLabel.NEW
407
+ return BadgeLabel.NEW;
400
408
  } else if (isSoldOut) {
401
- return BadgeLabel.SOLD_OUT
409
+ return BadgeLabel.SOLD_OUT;
402
410
  } else if (isOnlineOnly) {
403
- return BadgeLabel.ONLINE_EXCLUSIVE
411
+ return BadgeLabel.ONLINE_EXCLUSIVE;
404
412
  } else if (isSustainable) {
405
- return BadgeLabel.SUSTAINABLE
413
+ return BadgeLabel.SUSTAINABLE;
406
414
  } else if (isPremium) {
407
- return BadgeLabel.PREMIUM
415
+ return BadgeLabel.PREMIUM;
408
416
  } else {
409
- return BadgeLabel.DEFAULT
417
+ return BadgeLabel.DEFAULT;
410
418
  }
411
- }
419
+ };
412
420
  ```
413
421
 
414
422
  - **\[💥 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 +432,15 @@ See [Overriding core RPC Methods](https://scayle.dev/en/storefront-guide/develop
424
432
  storefront: {
425
433
  // ...
426
434
  bapi: {
427
- host: '...',
428
- token: '...',
435
+ host: "...",
436
+ token: "...",
429
437
  },
430
438
  // ...
431
439
  },
432
440
  // ...
433
441
  },
434
442
  // ...
435
- }
443
+ };
436
444
  ```
437
445
 
438
446
  - _Legacy Environment Variables:_
@@ -452,15 +460,15 @@ See [Overriding core RPC Methods](https://scayle.dev/en/storefront-guide/develop
452
460
  storefront: {
453
461
  // ...
454
462
  sapi: {
455
- host: '...',
456
- token: '...',
463
+ host: "...",
464
+ token: "...",
457
465
  },
458
466
  // ...
459
467
  },
460
468
  // ...
461
469
  },
462
470
  // ...
463
- }
471
+ };
464
472
  ```
465
473
 
466
474
  - _New Environment Variables:_
@@ -478,19 +486,19 @@ See [Overriding core RPC Methods](https://scayle.dev/en/storefront-guide/develop
478
486
 
479
487
  ```ts
480
488
  const { data, fetching, fetch, error, status } = useUser(
481
- 'getUser',
489
+ "getUser"
482
490
  // ...
483
- )
484
- data.value.user.authentication.storefrontAccessToken
491
+ );
492
+ data.value.user.authentication.storefrontAccessToken;
485
493
  ```
486
494
 
487
495
  - _Current Usage of dedicated `getAccessToken` RPC method:_
488
496
 
489
497
  ```ts
490
498
  const { data: accessToken } = useRpc(
491
- 'getAccessToken',
499
+ "getAccessToken"
492
500
  // ...
493
- )
501
+ );
494
502
  ```
495
503
 
496
504
  - **\[💥 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 +521,7 @@ See [Overriding core RPC Methods](https://scayle.dev/en/storefront-guide/develop
513
521
  // ...
514
522
  },
515
523
  // ...
516
- })
524
+ });
517
525
  ```
518
526
 
519
527
  - **\[💥 BREAKING\]** The attribute `loginShopId` is removed from the `ShopUser` interface as the shop now uses session cookies.
@@ -522,23 +530,23 @@ See [Overriding core RPC Methods](https://scayle.dev/en/storefront-guide/develop
522
530
  - _Previous Usage of `searchProducts` RPC method:_
523
531
 
524
532
  ```ts
525
- const getSearchSuggestionsRpc = useRpcCall('searchProducts')
533
+ const getSearchSuggestionsRpc = useRpcCall("searchProducts");
526
534
 
527
535
  data.value = await searchProducts({
528
536
  term: String(searchQuery.value),
529
537
  ...params,
530
- })
538
+ });
531
539
  ```
532
540
 
533
541
  - _Current Usage of `getSearchSuggestions` RPC method:_
534
542
 
535
543
  ```ts
536
- const getSearchSuggestionsRpc = useRpcCall('getSearchSuggestions')
544
+ const getSearchSuggestionsRpc = useRpcCall("getSearchSuggestions");
537
545
 
538
546
  data.value = await getSearchSuggestionsRpc({
539
547
  term: String(searchQuery.value),
540
548
  ...params,
541
- })
549
+ });
542
550
  ```
543
551
 
544
552
  - **\[💥 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.14.4"}`).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>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scayle/storefront-core",
3
- "version": "8.14.3",
3
+ "version": "8.14.4",
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",