@scayle/storefront-nuxt 7.65.1 → 7.66.1

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,53 @@
1
1
  # @scayle/storefront-nuxt
2
2
 
3
+ ## 7.66.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Fix RpcContext containing outdated data for the remainder of the request after mutating the session data
8
+
9
+ ## 7.66.0
10
+
11
+ ### Minor Changes
12
+
13
+ - Fix variable used before initialization in `useBasket`
14
+
15
+ Breaking: This change removes the `useEventListener` call from `useBasket`. This code was specific to the checkout page and it has been moved to that page in the Storefront Boilerplate (v1.0.0-rc.9). To make the necessary change in your own project, add the following code to `checkout.vue`.
16
+
17
+ ```
18
+ import type { CheckoutEvent } from '@scayle/storefront-nuxt'
19
+ const { fetching, fetch } = await useBasket()
20
+
21
+ const onCheckoutUpdate = async (
22
+ event: MessageEvent<CheckoutEvent>,
23
+ fetching: Boolean,
24
+ fetchCallback: () => Promise<void>,
25
+ ) => {
26
+ if (fetching) {
27
+ return
28
+ } // prevent multiple fetches
29
+ if (event?.data?.type === 'tracking') {
30
+ const actionType = event.data.event?.event
31
+
32
+ if (actionType === 'add_to_cart' || actionType === 'remove_from_cart') {
33
+ await fetchCallback()
34
+ }
35
+ }
36
+ }
37
+
38
+ // Refresh basket if the user changes quantity or removes an item at checkout
39
+ useEventListener(
40
+ 'message',
41
+ (event) => onCheckoutUpdate(event, fetching.value, fetch),
42
+ )
43
+ ```
44
+
45
+ ### Patch Changes
46
+
47
+ - Fixes an issue where the `refreshToken` was not exposed on the `RPCContext` even if the user is logged in.
48
+ - Updated dependencies
49
+ - @scayle/storefront-core@7.48.2
50
+
3
51
  ## 7.65.1
4
52
 
5
53
  ### Patch Changes
package/dist/module.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scayle/storefront-nuxt",
3
- "version": "7.65.0",
3
+ "version": "7.66.0",
4
4
  "configKey": "storefront",
5
5
  "compatibility": {
6
6
  "nuxt": "^3.9.0"
package/dist/module.mjs CHANGED
@@ -40,7 +40,7 @@ export default {
40
40
  }`;
41
41
  }
42
42
  const PACKAGE_NAME = "@scayle/storefront-nuxt";
43
- const PACKAGE_VERSION = "7.65.0";
43
+ const PACKAGE_VERSION = "7.66.0";
44
44
  const module = defineNuxtModule({
45
45
  meta: {
46
46
  name: PACKAGE_NAME,
@@ -8,31 +8,15 @@ import {
8
8
  } from "@scayle/storefront-core";
9
9
  import { useNuxtApp, useAsyncData } from "nuxt/app";
10
10
  import { computed } from "vue";
11
- import { useEventListener } from "@vueuse/core";
12
11
  import { rpcCall } from "../../rpc/rpcCall.mjs";
13
12
  import { useCurrentShop } from "../core/useCurrentShop.mjs";
14
13
  import { toValue, toRef } from "#imports";
15
- const onCheckoutUpdate = async (event, fetching, fetchCallback) => {
16
- if (fetching) {
17
- return;
18
- }
19
- if (event?.data?.type === "tracking") {
20
- const actionType = event.data.event?.event;
21
- if (actionType === "add_to_cart" || actionType === "remove_from_cart") {
22
- await fetchCallback();
23
- }
24
- }
25
- };
26
14
  export async function useBasket({
27
15
  params,
28
16
  key = "useBasket"
29
17
  } = {}) {
30
18
  const nuxtApp = useNuxtApp();
31
19
  const shop = useCurrentShop();
32
- useEventListener(
33
- "message",
34
- (event) => onCheckoutUpdate(event, fetching.value, fetch)
35
- );
36
20
  const {
37
21
  data,
38
22
  pending: fetching,
@@ -37,6 +37,9 @@ async function sessionProperties(context) {
37
37
  get accessToken() {
38
38
  return session.data?.accessToken ?? void 0;
39
39
  },
40
+ get refreshToken() {
41
+ return session.data?.refreshToken ?? void 0;
42
+ },
40
43
  destroySession: async () => {
41
44
  await session.destroy();
42
45
  },
@@ -63,6 +66,7 @@ async function sessionProperties(context) {
63
66
  sessionId: void 0,
64
67
  user: void 0,
65
68
  accessToken: void 0,
69
+ refreshToken: void 0,
66
70
  destroySession: void 0,
67
71
  createUserBoundSession: void 0,
68
72
  updateUser: void 0,
@@ -74,7 +78,7 @@ export const buildContext = async (context) => {
74
78
  const bapiConfig = $shopConfig.bapi ?? $storefront.bapi;
75
79
  const appKeys = $shopConfig.appKeys ?? $storefront.appKeys;
76
80
  const idpConfig = $shopConfig.idp ?? $storefront.idp;
77
- return {
81
+ const baseContext = {
78
82
  cached: new Cached($cache, $log, "", $storefront.cache?.enabled ?? true).execute,
79
83
  bapiClient: initBapi({
80
84
  host: bapiConfig.host,
@@ -82,7 +86,6 @@ export const buildContext = async (context) => {
82
86
  authentication: "token",
83
87
  token: bapiConfig.token
84
88
  }),
85
- ...await sessionProperties(context),
86
89
  auth: {
87
90
  resetPasswordUrl: $shopConfig.auth?.resetPasswordUrl
88
91
  },
@@ -126,4 +129,8 @@ export const buildContext = async (context) => {
126
129
  ip: getRequestIP(event, { xForwardedFor: true }),
127
130
  headers: createAndPurifyHeaders(getRequestHeaders(event))
128
131
  };
132
+ return Object.defineProperties({}, {
133
+ ...Object.getOwnPropertyDescriptors(baseContext),
134
+ ...Object.getOwnPropertyDescriptors(await sessionProperties(context))
135
+ });
129
136
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@scayle/storefront-nuxt",
3
3
  "type": "module",
4
- "version": "7.65.1",
4
+ "version": "7.66.1",
5
5
  "description": "Nuxt integration for the SCAYLE Commerce Engine and Storefront API",
6
6
  "author": "SCAYLE Commerce Engine",
7
7
  "license": "MIT",
@@ -63,7 +63,7 @@
63
63
  "@nuxt/kit": "3.11.1",
64
64
  "@opentelemetry/api": "1.8.0",
65
65
  "@scayle/h3-session": "0.3.6",
66
- "@scayle/storefront-core": "7.48.1",
66
+ "@scayle/storefront-core": "7.48.2",
67
67
  "@scayle/unstorage-compression-driver": "0.1.3",
68
68
  "@vueuse/core": "10.9.0",
69
69
  "consola": "3.2.3",
@@ -93,8 +93,8 @@
93
93
  "node-mocks-http": "1.14.1",
94
94
  "nuxt": "3.11.1",
95
95
  "publint": "0.2.7",
96
- "vitest": "1.4.0",
97
- "vue-tsc": "2.0.12"
96
+ "vitest": "1.5.0",
97
+ "vue-tsc": "2.0.13"
98
98
  },
99
99
  "peerDependencies": {
100
100
  "h3": "^1.10.0",
@@ -109,6 +109,6 @@
109
109
  "@nuxt/schema": "3.11.1"
110
110
  },
111
111
  "volta": {
112
- "node": "20.12.1"
112
+ "node": "20.12.2"
113
113
  }
114
114
  }