@scayle/storefront-nuxt 8.55.0 → 8.56.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,73 @@
|
|
|
1
1
|
# @scayle/storefront-nuxt
|
|
2
2
|
|
|
3
|
+
## 8.56.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- **\[Session\]** Added support for storing and managing custom data in sessions through the RPC context.
|
|
8
|
+
|
|
9
|
+
The `RpcContext` now exposes a `sessionCustomData` property to read custom session data and an `updateSessionCustomData` method to update it.
|
|
10
|
+
The `sessionCustomData` property may be `undefined` when no session exists or when no custom data has been set.
|
|
11
|
+
The `SessionCustomData` interface can be augmented with TypeScript module augmentation to provide type safety for custom session properties.
|
|
12
|
+
|
|
13
|
+
- **Type Augmentation Example:**
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
// templates/nuxt/types/session.ts
|
|
17
|
+
import '@scayle/storefront-nuxt'
|
|
18
|
+
|
|
19
|
+
declare module '@scayle/storefront-nuxt' {
|
|
20
|
+
interface SessionCustomData {
|
|
21
|
+
yourCustomDataKey?: string
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
- **Setting Custom Session Data Example:**
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
// templates/nuxt/server/plugins/session-plugin.ts
|
|
30
|
+
import { hasSession } from '@scayle/storefront-nuxt'
|
|
31
|
+
import { defineNitroPlugin } from '#imports'
|
|
32
|
+
|
|
33
|
+
export default defineNitroPlugin((nitroApp) => {
|
|
34
|
+
nitroApp.hooks.hook('storefront:afterLogin', async (_data, context) => {
|
|
35
|
+
if (!hasSession(context)) {
|
|
36
|
+
return
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const sessionCustomData = context.sessionCustomData
|
|
40
|
+
|
|
41
|
+
if (!sessionCustomData) {
|
|
42
|
+
return
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
context.updateSessionCustomData({
|
|
46
|
+
...sessionCustomData,
|
|
47
|
+
yourCustomDataKey: 'Your Session CustomData Value',
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
console.log(context.sessionCustomData?.yourCustomDataKey)
|
|
51
|
+
})
|
|
52
|
+
})
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Patch Changes
|
|
56
|
+
|
|
57
|
+
**Dependencies**
|
|
58
|
+
|
|
59
|
+
- Updated dependency to @scayle/unstorage-compression-driver@1.2.4
|
|
60
|
+
|
|
61
|
+
**@scayle/storefront-core v8.56.0**
|
|
62
|
+
|
|
63
|
+
- Minor
|
|
64
|
+
|
|
65
|
+
- Added support for custom session data in the RPC context type definitions.
|
|
66
|
+
|
|
67
|
+
The `ContextWithSession` interface now includes a `sessionCustomData` property (which may be `undefined`) to read custom session data and an `updateSessionCustomData` method to update it.
|
|
68
|
+
The `ContextWithoutSession` interface has been updated accordingly to maintain type consistency.
|
|
69
|
+
The `SessionCustomData` interface can be augmented using TypeScript module augmentation to provide type safety for custom session properties.
|
|
70
|
+
|
|
3
71
|
## 8.55.0
|
|
4
72
|
|
|
5
73
|
### Patch Changes
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
package/dist/runtime/context.js
CHANGED
|
@@ -143,6 +143,9 @@ export const buildContext = async (context) => {
|
|
|
143
143
|
get refreshToken() {
|
|
144
144
|
return session?.data?.refreshToken ?? void 0;
|
|
145
145
|
},
|
|
146
|
+
get sessionCustomData() {
|
|
147
|
+
return session?.data?.customData ?? void 0;
|
|
148
|
+
},
|
|
146
149
|
destroySession: session ? async () => {
|
|
147
150
|
await session.destroy();
|
|
148
151
|
} : void 0,
|
|
@@ -153,6 +156,10 @@ export const buildContext = async (context) => {
|
|
|
153
156
|
session.data = data;
|
|
154
157
|
await session.save();
|
|
155
158
|
} : void 0,
|
|
159
|
+
updateSessionCustomData: session ? async (customData) => {
|
|
160
|
+
session.data.customData = customData;
|
|
161
|
+
await session.save();
|
|
162
|
+
} : void 0,
|
|
156
163
|
updateUser: session ? async (user) => {
|
|
157
164
|
session.data.user = user;
|
|
158
165
|
await session.save();
|
|
@@ -1,16 +1,7 @@
|
|
|
1
|
-
import type { ShopUser } from '@scayle/storefront-core';
|
|
2
|
-
/**
|
|
3
|
-
* Interface for shop session data.
|
|
4
|
-
*
|
|
5
|
-
* user: The shop user.
|
|
6
|
-
* accessToken: The access token.
|
|
7
|
-
* refreshToken: The refresh token.
|
|
8
|
-
* shopId: The shop ID.
|
|
9
|
-
*/
|
|
1
|
+
import type { ShopUser, SessionCustomData } from '@scayle/storefront-core';
|
|
2
|
+
/** Interface for shop session data.*/
|
|
10
3
|
export interface ShopSessionData {
|
|
11
|
-
/**
|
|
12
|
-
* The shop user object containing detailed information about the current user.
|
|
13
|
-
*/
|
|
4
|
+
/** The shop user object containing detailed information about the current user. */
|
|
14
5
|
user?: ShopUser;
|
|
15
6
|
/**
|
|
16
7
|
* The OAuth 2.0 access token.
|
|
@@ -23,6 +14,8 @@ export interface ShopSessionData {
|
|
|
23
14
|
*/
|
|
24
15
|
refreshToken?: string;
|
|
25
16
|
shopId?: number;
|
|
17
|
+
/** The session custom data to be stored in the session. */
|
|
18
|
+
customData?: SessionCustomData;
|
|
26
19
|
}
|
|
27
20
|
declare module '@scayle/h3-session' {
|
|
28
21
|
interface SessionDataT extends ShopSessionData {
|
package/dist/test/factories.mjs
CHANGED
|
@@ -87,9 +87,11 @@ const rpcContextFactory = Factory.define(({ transientParams }) => {
|
|
|
87
87
|
user: void 0,
|
|
88
88
|
accessToken: void 0,
|
|
89
89
|
refreshToken: void 0,
|
|
90
|
+
sessionCustomData: void 0,
|
|
90
91
|
destroySession: () => Promise.resolve(),
|
|
91
92
|
createUserBoundSession: () => Promise.resolve(),
|
|
92
93
|
updateUser: () => Promise.resolve(),
|
|
94
|
+
updateSessionCustomData: () => Promise.resolve(),
|
|
93
95
|
updateTokens: () => Promise.resolve()
|
|
94
96
|
} : {
|
|
95
97
|
wishlistKey: "logged-out-wishlist-key",
|
|
@@ -98,9 +100,11 @@ const rpcContextFactory = Factory.define(({ transientParams }) => {
|
|
|
98
100
|
user: void 0,
|
|
99
101
|
accessToken: void 0,
|
|
100
102
|
refreshToken: void 0,
|
|
103
|
+
sessionCustomData: void 0,
|
|
101
104
|
destroySession: void 0,
|
|
102
105
|
createUserBoundSession: void 0,
|
|
103
106
|
updateUser: void 0,
|
|
107
|
+
updateSessionCustomData: void 0,
|
|
104
108
|
updateTokens: void 0
|
|
105
109
|
}
|
|
106
110
|
};
|
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.56.0",
|
|
5
5
|
"description": "Nuxt integration for the SCAYLE Commerce Engine and Storefront API",
|
|
6
6
|
"author": "SCAYLE Commerce Engine",
|
|
7
7
|
"license": "MIT",
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
"utility-types": "^3.11.0",
|
|
91
91
|
"vue-router": "^4.4.0",
|
|
92
92
|
"zod": "^4.0.0",
|
|
93
|
-
"@scayle/storefront-core": "8.
|
|
93
|
+
"@scayle/storefront-core": "8.56.0",
|
|
94
94
|
"@scayle/unstorage-compression-driver": "1.2.4"
|
|
95
95
|
},
|
|
96
96
|
"devDependencies": {
|
|
@@ -103,7 +103,7 @@
|
|
|
103
103
|
"@nuxt/schema": "3.20.0",
|
|
104
104
|
"@nuxt/test-utils": "3.20.1",
|
|
105
105
|
"@types/node": "22.19.1",
|
|
106
|
-
"@vitest/coverage-v8": "4.0.
|
|
106
|
+
"@vitest/coverage-v8": "4.0.15",
|
|
107
107
|
"dprint": "0.50.2",
|
|
108
108
|
"eslint-formatter-gitlab": "7.0.0",
|
|
109
109
|
"eslint": "9.39.1",
|
|
@@ -116,10 +116,10 @@
|
|
|
116
116
|
"publint": "0.3.15",
|
|
117
117
|
"typescript": "5.9.3",
|
|
118
118
|
"unbuild": "3.6.1",
|
|
119
|
-
"vitest": "4.0.
|
|
119
|
+
"vitest": "4.0.15",
|
|
120
120
|
"vue-tsc": "3.1.5",
|
|
121
121
|
"happy-dom": "20.0.11",
|
|
122
|
-
"@scayle/eslint-config-storefront": "4.7.
|
|
122
|
+
"@scayle/eslint-config-storefront": "4.7.16",
|
|
123
123
|
"@scayle/eslint-plugin-vue-composable": "0.2.2",
|
|
124
124
|
"@scayle/vitest-config-storefront": "1.0.0",
|
|
125
125
|
"@scayle/unstorage-scayle-kv-driver": "2.0.9"
|