@scayle/storefront-nuxt 8.61.3 → 8.62.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,70 @@
1
1
  # @scayle/storefront-nuxt
2
2
 
3
+ ## 8.62.0
4
+
5
+ ### Minor Changes
6
+
7
+ - **\[Promotions\]** Enabled promotion segmentation on the client for `usePromotions`, `useCurrentPromotions`, and `usePromotionsByIds`.
8
+
9
+ These composables inject `segmentation: true` when `import.meta.client` is true, so logged-in shoppers receive promotions tailored to their customer segment without passing the flag manually. Server-side calls keep `segmentation: false` and continue to use the cached anonymous promotion list so customer-specific promotions are not stored in shared cache responses.
10
+
11
+ The public `params` type omits `segmentation` on these composables so storefront code does not set it directly.
12
+
13
+ **\[BREAKING\]** `usePromotionsByIds` now accepts `{ ids: string[] }` for `params` instead of `string[]`.
14
+ - Before:
15
+
16
+ ```ts
17
+ const { data } = usePromotionsByIds({
18
+ params: ['promo-1', 'promo-2'],
19
+ })
20
+ ```
21
+
22
+ - After:
23
+
24
+ ```ts
25
+ const { data } = usePromotionsByIds({
26
+ params: {
27
+ ids: ['promo-1', 'promo-2'],
28
+ },
29
+ })
30
+ ```
31
+
32
+ Segmentation is applied automatically on the client, same as `usePromotions` and `useCurrentPromotions`.
33
+
34
+ ### Patch Changes
35
+
36
+ **Dependencies**
37
+
38
+ **@scayle/storefront-core v8.62.0**
39
+
40
+ - Minor
41
+ - **\[Promotions\]** Added customer-segmented promotion fetches when a valid session token is present.
42
+
43
+ `getPromotions`, `getCurrentPromotions`, and `getPromotionsByIds` accept a `segmentation` flag. When it is `true` and the request has a non-expired access token, the handlers call the Storefront API with `customerToken` and skip the shared cache so results match the logged-in customer. When it is `false`, handlers use the cached anonymous promotion list so customer-specific promotions are not stored in shared cache responses.
44
+
45
+ **\[BREAKING\]** `getPromotionsByIds` now expects `{ ids: string[], segmentation: boolean }` instead of a bare `string[]` array.
46
+ - Before (custom RPC handler via `context.callRpc`):
47
+
48
+ ```ts
49
+ const promotions = await context.callRpc?.('getPromotionsByIds', [
50
+ 'promo-1',
51
+ 'promo-2',
52
+ ])
53
+ ```
54
+
55
+ - After:
56
+
57
+ ```ts
58
+ const promotions = await context.callRpc?.('getPromotionsByIds', {
59
+ ids: ['promo-1', 'promo-2'],
60
+ segmentation: true,
61
+ })
62
+ ```
63
+
64
+ Promotion list handlers use `POST` instead of `GET` so `segmentation` and `customerToken` are not sent in the URL.
65
+
66
+ **\[User\]** Exported `getValidatedAccessToken` to return a JWT only when it is present and not expired. Basket merge and promotion handlers use it when passing `customerToken` to the Storefront API.
67
+
3
68
  ## 8.61.3
4
69
 
5
70
  ### Patch Changes
package/dist/module.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scayle/storefront-nuxt",
3
- "version": "8.61.3",
3
+ "version": "8.62.0",
4
4
  "configKey": "storefront",
5
5
  "compatibility": {
6
6
  "nuxt": ">=3.13"
package/dist/module.mjs CHANGED
@@ -57,7 +57,7 @@ export default {
57
57
  }`;
58
58
  }
59
59
  const PACKAGE_NAME = "@scayle/storefront-nuxt";
60
- const PACKAGE_VERSION = "8.61.3";
60
+ const PACKAGE_VERSION = "8.62.0";
61
61
  const logger = createConsola({
62
62
  fancy: true,
63
63
  formatOptions: {
@@ -26,6 +26,6 @@ import type { MaybeRefOrGetter } from 'vue';
26
26
  * loading state, and any error information.
27
27
  */
28
28
  export declare function useCurrentPromotions<DataT = NormalizedRpcResponse<'getCurrentPromotions'>, PickKeys extends KeysOf<DataT> = KeysOf<DataT>, DefaultT = null>({ params, options, }?: Partial<{
29
- params: MaybeRefOrGetter<RpcMethodParameters<'getCurrentPromotions'>>;
29
+ params: MaybeRefOrGetter<Omit<RpcMethodParameters<'getCurrentPromotions'>, 'segmentation'>>;
30
30
  options: UseRpcOptions<'getCurrentPromotions', DataT, PickKeys, DefaultT>;
31
31
  }>, key?: UseRpcCacheKey): UseRpcReturn<'getCurrentPromotions', DataT, PickKeys, DefaultT>;
@@ -1,9 +1,16 @@
1
1
  import { useRpc } from "../core/useRpc.js";
2
+ import { toValue } from "vue";
2
3
  export function useCurrentPromotions({
3
4
  params,
4
5
  options
5
6
  } = {}, key = "useCurrentPromotions") {
6
- return useRpc("getCurrentPromotions", key, params, {
7
+ const paramsWithSegmentation = () => {
8
+ return {
9
+ ...toValue(params),
10
+ segmentation: import.meta.client
11
+ };
12
+ };
13
+ return useRpc("getCurrentPromotions", key, paramsWithSegmentation, {
7
14
  getCachedData(cacheKey, nuxtApp) {
8
15
  const hydrationData = nuxtApp.isHydrating ? nuxtApp.payload.data[cacheKey] : nuxtApp.static.data[cacheKey];
9
16
  return hydrationData ?? nuxtApp._asyncData[cacheKey]?.data.value;
@@ -23,6 +23,6 @@ import type { MaybeRefOrGetter } from 'vue';
23
23
  * loading state, and any error information.
24
24
  */
25
25
  export declare function usePromotions<DataT = NormalizedRpcResponse<'getPromotions'>, PickKeys extends KeysOf<DataT> = KeysOf<DataT>, DefaultT = null>({ params, options, }?: Partial<{
26
- params: MaybeRefOrGetter<RpcMethodParameters<'getPromotions'>>;
26
+ params: MaybeRefOrGetter<Omit<RpcMethodParameters<'getPromotions'>, 'segmentation'>>;
27
27
  options: UseRpcOptions<'getPromotions', DataT, PickKeys, DefaultT>;
28
28
  }>, key?: UseRpcCacheKey): UseRpcReturn<'getPromotions', DataT, PickKeys, DefaultT>;
@@ -1,7 +1,14 @@
1
1
  import { useRpc } from "../core/useRpc.js";
2
+ import { toValue } from "vue";
2
3
  export function usePromotions({
3
4
  params,
4
5
  options
5
6
  } = {}, key = "usePromotions") {
6
- return useRpc("getPromotions", key, params, options);
7
+ const paramsWithSegmentation = () => {
8
+ return {
9
+ ...toValue(params),
10
+ segmentation: import.meta.client
11
+ };
12
+ };
13
+ return useRpc("getPromotions", key, paramsWithSegmentation, options);
7
14
  }
@@ -23,6 +23,6 @@ import type { MaybeRefOrGetter } from 'vue';
23
23
  * loading state, and any error information.
24
24
  */
25
25
  export declare function usePromotionsByIds<DataT = NormalizedRpcResponse<'getPromotionsByIds'>, PickKeys extends KeysOf<DataT> = KeysOf<DataT>, DefaultT = null>({ params, options, }?: Partial<{
26
- params: MaybeRefOrGetter<RpcMethodParameters<'getPromotionsByIds'>>;
26
+ params: MaybeRefOrGetter<Omit<RpcMethodParameters<'getPromotionsByIds'>, 'segmentation'>>;
27
27
  options: UseRpcOptions<'getPromotionsByIds', DataT, PickKeys, DefaultT>;
28
28
  }>, key?: UseRpcCacheKey): UseRpcReturn<'getPromotionsByIds', DataT, PickKeys, DefaultT>;
@@ -1,7 +1,15 @@
1
1
  import { useRpc } from "../core/useRpc.js";
2
+ import { toValue } from "vue";
2
3
  export function usePromotionsByIds({
3
4
  params,
4
5
  options
5
6
  } = {}, key = "usePromotionsByIds") {
6
- return useRpc("getPromotionsByIds", key, params, options);
7
+ const paramsWithSegmentation = () => {
8
+ const base = toValue(params);
9
+ return {
10
+ ids: base?.ids ?? [],
11
+ segmentation: import.meta.client
12
+ };
13
+ };
14
+ return useRpc("getPromotionsByIds", key, paramsWithSegmentation, options);
7
15
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@scayle/storefront-nuxt",
3
3
  "type": "module",
4
- "version": "8.61.3",
4
+ "version": "8.62.0",
5
5
  "description": "Nuxt integration for the SCAYLE Commerce Engine and Storefront API",
6
6
  "author": "SCAYLE Commerce Engine",
7
7
  "license": "MIT",
@@ -68,7 +68,7 @@
68
68
  },
69
69
  "peerDependencies": {
70
70
  "@nuxt/kit": ">=3.13.0 || >=4.2.0",
71
- "@scayle/storefront-api": "^19.0.0",
71
+ "@scayle/storefront-api": "^19.1.0",
72
72
  "fishery": "^2.2.2",
73
73
  "h3": "^1.10.0",
74
74
  "nitropack": "^2.9.7",
@@ -97,7 +97,7 @@
97
97
  "vue-router": "^4.4.0",
98
98
  "zod": "^4.0.0",
99
99
  "@scayle/h3-session": "0.7.0",
100
- "@scayle/storefront-core": "8.61.3"
100
+ "@scayle/storefront-core": "8.62.0"
101
101
  },
102
102
  "devDependencies": {
103
103
  "@arethetypeswrong/cli": "0.18.2",