@scayle/storefront-core 8.14.2 → 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,19 @@
|
|
|
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
|
+
|
|
11
|
+
## 8.14.3
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Export the `BasketItemUpdateData` type.
|
|
16
|
+
|
|
3
17
|
## 8.14.2
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -172,12 +186,12 @@ To get the default campaign key, you can call the RPC method:
|
|
|
172
186
|
```typescript
|
|
173
187
|
// Before
|
|
174
188
|
async function rpcMethod(context) {
|
|
175
|
-
const campaignKey = { context }
|
|
189
|
+
const campaignKey = { context };
|
|
176
190
|
// ...
|
|
177
191
|
}
|
|
178
192
|
// After
|
|
179
193
|
async function rpcMethod(context) {
|
|
180
|
-
const campaignKey = await context.callRpc?.(
|
|
194
|
+
const campaignKey = await context.callRpc?.("getCampaignKey");
|
|
181
195
|
// ...
|
|
182
196
|
}
|
|
183
197
|
```
|
|
@@ -366,43 +380,43 @@ See [Overriding core RPC Methods](https://scayle.dev/en/storefront-guide/develop
|
|
|
366
380
|
|
|
367
381
|
```ts
|
|
368
382
|
const BadgeLabel = {
|
|
369
|
-
NEW:
|
|
370
|
-
SOLD_OUT:
|
|
371
|
-
ONLINE_EXCLUSIVE:
|
|
372
|
-
SUSTAINABLE:
|
|
373
|
-
PREMIUM:
|
|
374
|
-
DEFAULT:
|
|
375
|
-
} 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;
|
|
376
390
|
|
|
377
391
|
type BadgeLabelParamsKeys =
|
|
378
|
-
|
|
|
379
|
-
|
|
|
380
|
-
|
|
|
381
|
-
|
|
|
382
|
-
|
|
|
383
|
-
type BadgeLabelParams = Partial<Record<BadgeLabelParamsKeys, boolean
|
|
392
|
+
| "isNew"
|
|
393
|
+
| "isSoldOut"
|
|
394
|
+
| "isOnlineOnly"
|
|
395
|
+
| "isSustainable"
|
|
396
|
+
| "isPremium";
|
|
397
|
+
type BadgeLabelParams = Partial<Record<BadgeLabelParamsKeys, boolean>>;
|
|
384
398
|
|
|
385
399
|
const getBadgeLabel = (params: BadgeLabelParams = {}): string => {
|
|
386
400
|
if (!params) {
|
|
387
|
-
return BadgeLabel.DEFAULT
|
|
401
|
+
return BadgeLabel.DEFAULT;
|
|
388
402
|
}
|
|
389
403
|
const { isNew, isSoldOut, isOnlineOnly, isSustainable, isPremium } =
|
|
390
|
-
params
|
|
404
|
+
params;
|
|
391
405
|
|
|
392
406
|
if (isNew) {
|
|
393
|
-
return BadgeLabel.NEW
|
|
407
|
+
return BadgeLabel.NEW;
|
|
394
408
|
} else if (isSoldOut) {
|
|
395
|
-
return BadgeLabel.SOLD_OUT
|
|
409
|
+
return BadgeLabel.SOLD_OUT;
|
|
396
410
|
} else if (isOnlineOnly) {
|
|
397
|
-
return BadgeLabel.ONLINE_EXCLUSIVE
|
|
411
|
+
return BadgeLabel.ONLINE_EXCLUSIVE;
|
|
398
412
|
} else if (isSustainable) {
|
|
399
|
-
return BadgeLabel.SUSTAINABLE
|
|
413
|
+
return BadgeLabel.SUSTAINABLE;
|
|
400
414
|
} else if (isPremium) {
|
|
401
|
-
return BadgeLabel.PREMIUM
|
|
415
|
+
return BadgeLabel.PREMIUM;
|
|
402
416
|
} else {
|
|
403
|
-
return BadgeLabel.DEFAULT
|
|
417
|
+
return BadgeLabel.DEFAULT;
|
|
404
418
|
}
|
|
405
|
-
}
|
|
419
|
+
};
|
|
406
420
|
```
|
|
407
421
|
|
|
408
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`.
|
|
@@ -418,15 +432,15 @@ See [Overriding core RPC Methods](https://scayle.dev/en/storefront-guide/develop
|
|
|
418
432
|
storefront: {
|
|
419
433
|
// ...
|
|
420
434
|
bapi: {
|
|
421
|
-
host:
|
|
422
|
-
token:
|
|
435
|
+
host: "...",
|
|
436
|
+
token: "...",
|
|
423
437
|
},
|
|
424
438
|
// ...
|
|
425
439
|
},
|
|
426
440
|
// ...
|
|
427
441
|
},
|
|
428
442
|
// ...
|
|
429
|
-
}
|
|
443
|
+
};
|
|
430
444
|
```
|
|
431
445
|
|
|
432
446
|
- _Legacy Environment Variables:_
|
|
@@ -446,15 +460,15 @@ See [Overriding core RPC Methods](https://scayle.dev/en/storefront-guide/develop
|
|
|
446
460
|
storefront: {
|
|
447
461
|
// ...
|
|
448
462
|
sapi: {
|
|
449
|
-
host:
|
|
450
|
-
token:
|
|
463
|
+
host: "...",
|
|
464
|
+
token: "...",
|
|
451
465
|
},
|
|
452
466
|
// ...
|
|
453
467
|
},
|
|
454
468
|
// ...
|
|
455
469
|
},
|
|
456
470
|
// ...
|
|
457
|
-
}
|
|
471
|
+
};
|
|
458
472
|
```
|
|
459
473
|
|
|
460
474
|
- _New Environment Variables:_
|
|
@@ -472,19 +486,19 @@ See [Overriding core RPC Methods](https://scayle.dev/en/storefront-guide/develop
|
|
|
472
486
|
|
|
473
487
|
```ts
|
|
474
488
|
const { data, fetching, fetch, error, status } = useUser(
|
|
475
|
-
|
|
489
|
+
"getUser"
|
|
476
490
|
// ...
|
|
477
|
-
)
|
|
478
|
-
data.value.user.authentication.storefrontAccessToken
|
|
491
|
+
);
|
|
492
|
+
data.value.user.authentication.storefrontAccessToken;
|
|
479
493
|
```
|
|
480
494
|
|
|
481
495
|
- _Current Usage of dedicated `getAccessToken` RPC method:_
|
|
482
496
|
|
|
483
497
|
```ts
|
|
484
498
|
const { data: accessToken } = useRpc(
|
|
485
|
-
|
|
499
|
+
"getAccessToken"
|
|
486
500
|
// ...
|
|
487
|
-
)
|
|
501
|
+
);
|
|
488
502
|
```
|
|
489
503
|
|
|
490
504
|
- **\[💥 BREAKING\]** We've enhanced security for basket and wishlist keys by switching the default hashing algorithm from MD5 to the more robust SHA256.
|
|
@@ -507,7 +521,7 @@ See [Overriding core RPC Methods](https://scayle.dev/en/storefront-guide/develop
|
|
|
507
521
|
// ...
|
|
508
522
|
},
|
|
509
523
|
// ...
|
|
510
|
-
})
|
|
524
|
+
});
|
|
511
525
|
```
|
|
512
526
|
|
|
513
527
|
- **\[💥 BREAKING\]** The attribute `loginShopId` is removed from the `ShopUser` interface as the shop now uses session cookies.
|
|
@@ -516,23 +530,23 @@ See [Overriding core RPC Methods](https://scayle.dev/en/storefront-guide/develop
|
|
|
516
530
|
- _Previous Usage of `searchProducts` RPC method:_
|
|
517
531
|
|
|
518
532
|
```ts
|
|
519
|
-
const getSearchSuggestionsRpc = useRpcCall(
|
|
533
|
+
const getSearchSuggestionsRpc = useRpcCall("searchProducts");
|
|
520
534
|
|
|
521
535
|
data.value = await searchProducts({
|
|
522
536
|
term: String(searchQuery.value),
|
|
523
537
|
...params,
|
|
524
|
-
})
|
|
538
|
+
});
|
|
525
539
|
```
|
|
526
540
|
|
|
527
541
|
- _Current Usage of `getSearchSuggestions` RPC method:_
|
|
528
542
|
|
|
529
543
|
```ts
|
|
530
|
-
const getSearchSuggestionsRpc = useRpcCall(
|
|
544
|
+
const getSearchSuggestionsRpc = useRpcCall("getSearchSuggestions");
|
|
531
545
|
|
|
532
546
|
data.value = await getSearchSuggestionsRpc({
|
|
533
547
|
term: String(searchQuery.value),
|
|
534
548
|
...params,
|
|
535
|
-
})
|
|
549
|
+
});
|
|
536
550
|
```
|
|
537
551
|
|
|
538
552
|
- **\[💥 BREAKING\]** Improved basket updating: Adding an item to your basket with a reduced quantity will now correctly update the basket contents.
|
package/dist/index.d.ts
CHANGED
|
@@ -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.
|
|
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,
|
|
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<
|
|
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<
|
|
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<
|
|
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
|
+
"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.
|
|
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",
|
|
@@ -74,13 +74,13 @@
|
|
|
74
74
|
"utility-types": "^3.11.0"
|
|
75
75
|
},
|
|
76
76
|
"devDependencies": {
|
|
77
|
-
"@scayle/eslint-config-storefront": "4.
|
|
77
|
+
"@scayle/eslint-config-storefront": "4.5.0",
|
|
78
78
|
"@types/crypto-js": "4.2.2",
|
|
79
|
-
"@types/node": "22.13.
|
|
79
|
+
"@types/node": "22.13.14",
|
|
80
80
|
"@types/webpack-env": "1.18.8",
|
|
81
81
|
"@vitest/coverage-v8": "2.1.9",
|
|
82
82
|
"dprint": "0.49.1",
|
|
83
|
-
"eslint": "9.
|
|
83
|
+
"eslint": "9.23.0",
|
|
84
84
|
"eslint-formatter-gitlab": "5.1.0",
|
|
85
85
|
"fishery": "2.2.3",
|
|
86
86
|
"publint": "0.2.12",
|