@scayle/storefront-nuxt 8.61.2 → 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 +79 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +4 -2
- package/dist/runtime/composables/storefront/useCurrentPromotions.d.ts +1 -1
- package/dist/runtime/composables/storefront/useCurrentPromotions.js +8 -1
- package/dist/runtime/composables/storefront/usePromotions.d.ts +1 -1
- package/dist/runtime/composables/storefront/usePromotions.js +8 -1
- package/dist/runtime/composables/storefront/usePromotionsByIds.d.ts +1 -1
- package/dist/runtime/composables/storefront/usePromotionsByIds.js +9 -1
- package/package.json +12 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,84 @@
|
|
|
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
|
+
|
|
68
|
+
## 8.61.3
|
|
69
|
+
|
|
70
|
+
### Patch Changes
|
|
71
|
+
|
|
72
|
+
- Updated dependency `@vercel/nft@1.4.0` to `@vercel/nft@1.5.0`
|
|
73
|
+
- Fix `updateTokens` and `updateUser` return type from `void` to `Promise<void>` in `ContextWithSession`. The underlying implementations were already async (`await session.save()`), but the incorrect `void` type prevented call sites from knowing they needed to await the result. All call sites in the RPC methods and customer API now correctly await these calls, ensuring session state is persisted before execution continues.
|
|
74
|
+
|
|
75
|
+
**Dependencies**
|
|
76
|
+
|
|
77
|
+
**@scayle/storefront-core v8.61.3**
|
|
78
|
+
|
|
79
|
+
- Patch
|
|
80
|
+
- Fix `updateTokens` and `updateUser` return type from `void` to `Promise<void>` in `ContextWithSession`. The underlying implementations were already async (`await session.save()`), but the incorrect `void` type prevented call sites from knowing they needed to await the result. All call sites in the RPC methods and customer API now correctly await these calls, ensuring session state is persisted before execution continues.
|
|
81
|
+
|
|
3
82
|
## 8.61.2
|
|
4
83
|
|
|
5
84
|
### Patch Changes
|
package/dist/module.json
CHANGED
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.
|
|
60
|
+
const PACKAGE_VERSION = "8.62.0";
|
|
61
61
|
const logger = createConsola({
|
|
62
62
|
fancy: true,
|
|
63
63
|
formatOptions: {
|
|
@@ -131,7 +131,9 @@ async function resolveAliasChain(target, resolveOpts) {
|
|
|
131
131
|
}
|
|
132
132
|
current = next;
|
|
133
133
|
}
|
|
134
|
-
logger.warn(
|
|
134
|
+
logger.warn(
|
|
135
|
+
`Alias chain for ${target} resolved to ${current} but maximum depth of 10 was reached`
|
|
136
|
+
);
|
|
135
137
|
return current;
|
|
136
138
|
}
|
|
137
139
|
async function buildResolvedNuxtAliasMap(nuxt) {
|
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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.
|
|
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.
|
|
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",
|
|
@@ -77,10 +77,10 @@
|
|
|
77
77
|
"vue": "^3.4.0"
|
|
78
78
|
},
|
|
79
79
|
"dependencies": {
|
|
80
|
-
"@opentelemetry/api": "^1.9.
|
|
80
|
+
"@opentelemetry/api": "^1.9.1",
|
|
81
81
|
"@scayle/unstorage-compression-driver": "1.5.0",
|
|
82
|
-
"@vercel/nft": "1.
|
|
83
|
-
"@vueuse/core": "14.
|
|
82
|
+
"@vercel/nft": "1.5.0",
|
|
83
|
+
"@vueuse/core": "14.3.0",
|
|
84
84
|
"consola": "^3.4.2",
|
|
85
85
|
"core-js": "^3.37.1",
|
|
86
86
|
"defu": "^6.1.7",
|
|
@@ -97,13 +97,13 @@
|
|
|
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.
|
|
100
|
+
"@scayle/storefront-core": "8.62.0"
|
|
101
101
|
},
|
|
102
102
|
"devDependencies": {
|
|
103
103
|
"@arethetypeswrong/cli": "0.18.2",
|
|
104
104
|
"@nuxt/eslint-config": "1.15.2",
|
|
105
105
|
"@nuxt/kit": "^3.20.2",
|
|
106
|
-
"@nuxtjs/i18n": "10.
|
|
106
|
+
"@nuxtjs/i18n": "10.4.0",
|
|
107
107
|
"@nuxt/module-builder": "1.0.2",
|
|
108
108
|
"@nuxt/schema": "^3.20.2",
|
|
109
109
|
"@nuxt/test-utils": "4.0.0",
|
|
@@ -111,8 +111,8 @@
|
|
|
111
111
|
"@scayle/eslint-plugin-vue-composable": "^1.1.0",
|
|
112
112
|
"@scayle/unstorage-scayle-kv-driver": "^2.1.0",
|
|
113
113
|
"@types/node": "24.12.2",
|
|
114
|
-
"@vitest/coverage-v8": "4.1.
|
|
115
|
-
"eslint": "10.
|
|
114
|
+
"@vitest/coverage-v8": "4.1.7",
|
|
115
|
+
"eslint": "10.4.0",
|
|
116
116
|
"eslint-formatter-gitlab": "7.1.0",
|
|
117
117
|
"fishery": "2.4.0",
|
|
118
118
|
"h3": "1.15.11",
|
|
@@ -121,11 +121,11 @@
|
|
|
121
121
|
"nitropack": "2.13.4",
|
|
122
122
|
"node-mocks-http": "1.17.2",
|
|
123
123
|
"nuxt": "^3.20.2",
|
|
124
|
-
"publint": "0.3.
|
|
124
|
+
"publint": "0.3.21",
|
|
125
125
|
"typescript": "6.0.3",
|
|
126
126
|
"unbuild": "3.6.1",
|
|
127
|
-
"vitest": "4.1.
|
|
128
|
-
"vue-tsc": "3.2
|
|
127
|
+
"vitest": "4.1.7",
|
|
128
|
+
"vue-tsc": "3.3.2",
|
|
129
129
|
"@scayle/vitest-config-storefront": "1.0.0"
|
|
130
130
|
},
|
|
131
131
|
"scripts": {
|