@scayle/storefront-nuxt 8.55.0 → 8.57.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 +100 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +1 -1
- package/dist/runtime/context.js +7 -0
- package/dist/runtime/server/middleware/bootstrap.d.ts +5 -12
- package/dist/test/factories.mjs +4 -0
- package/package.json +14 -14
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,105 @@
|
|
|
1
1
|
# @scayle/storefront-nuxt
|
|
2
2
|
|
|
3
|
+
## 8.57.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
**Dependencies**
|
|
8
|
+
|
|
9
|
+
- Updated dependency to @scayle/unstorage-compression-driver@1.2.4
|
|
10
|
+
|
|
11
|
+
**@scayle/storefront-core v8.57.0**
|
|
12
|
+
|
|
13
|
+
- Minor
|
|
14
|
+
|
|
15
|
+
- **\[Navigation\]** Exported Navigation V2 API types to provide TypeScript support for the new navigation endpoints.
|
|
16
|
+
|
|
17
|
+
The following types are now available from `@scayle/storefront-core`:
|
|
18
|
+
|
|
19
|
+
- `GetNavigationV2Parameters` - Parameters for fetching navigation trees via the V2 API
|
|
20
|
+
- `NavigationV2AllEndpointResponseData` - Response type for fetching all navigation trees
|
|
21
|
+
- `NavigationV2ByReferenceEndpointResponseData` - Response type for fetching a navigation tree by reference key
|
|
22
|
+
|
|
23
|
+
These types enable full TypeScript support when working with the Navigation V2 API, which uses reference keys instead of numeric IDs for more flexible navigation management.
|
|
24
|
+
|
|
25
|
+
## 8.56.0
|
|
26
|
+
|
|
27
|
+
### Minor Changes
|
|
28
|
+
|
|
29
|
+
- **\[Session\]** Added support for storing and managing custom data in sessions through the RPC context.
|
|
30
|
+
|
|
31
|
+
The `RpcContext` now exposes a `sessionCustomData` property to read custom session data and an `updateSessionCustomData` method to update it.
|
|
32
|
+
The `sessionCustomData` property may be `undefined` when no session exists or when no custom data has been set.
|
|
33
|
+
The `SessionCustomData` interface can be augmented with TypeScript module augmentation to provide type safety for custom session properties.
|
|
34
|
+
|
|
35
|
+
- **Type Augmentation Example:**
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
// types/session.ts
|
|
39
|
+
import '@scayle/storefront-nuxt'
|
|
40
|
+
|
|
41
|
+
declare module '@scayle/storefront-nuxt' {
|
|
42
|
+
interface SessionCustomData {
|
|
43
|
+
yourCustomDataKey?: string
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
- **Setting Custom Session Data Example:**
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
// server/plugins/session-plugin.ts
|
|
52
|
+
import { hasSession } from '@scayle/storefront-nuxt'
|
|
53
|
+
import { defineNitroPlugin } from '#imports'
|
|
54
|
+
|
|
55
|
+
export default defineNitroPlugin((nitroApp) => {
|
|
56
|
+
nitroApp.hooks.hook('storefront:afterLogin', async (_data, context) => {
|
|
57
|
+
// Check if we actually have a RpcContext with proper session data
|
|
58
|
+
if (!hasSession(context)) {
|
|
59
|
+
return
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Should you have set custom session data already in another hook,
|
|
63
|
+
// it might be necessary to get existing data first.
|
|
64
|
+
const sessionCustomData = context.sessionCustomData
|
|
65
|
+
|
|
66
|
+
// The update functions overrides the customData object on a session.
|
|
67
|
+
// Should you have set custom session data already in another hooks,
|
|
68
|
+
// you need to pass it in addition to your new custom session data.
|
|
69
|
+
context.updateSessionCustomData({
|
|
70
|
+
...sessionCustomData,
|
|
71
|
+
yourCustomDataKey: 'Your Session CustomData Value',
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
// Before accessing your session custom data, you might want to use an
|
|
75
|
+
// explicit early return conditional.
|
|
76
|
+
if (!sessionCustomData) {
|
|
77
|
+
return
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Your custom session data can also be accessedd directly via
|
|
81
|
+
// nullish coalescing depending on your needs.
|
|
82
|
+
console.log(context.sessionCustomData?.yourCustomDataKey)
|
|
83
|
+
})
|
|
84
|
+
})
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Patch Changes
|
|
88
|
+
|
|
89
|
+
**Dependencies**
|
|
90
|
+
|
|
91
|
+
- Updated dependency to @scayle/unstorage-compression-driver@1.2.4
|
|
92
|
+
|
|
93
|
+
**@scayle/storefront-core v8.56.0**
|
|
94
|
+
|
|
95
|
+
- Minor
|
|
96
|
+
|
|
97
|
+
- Added support for custom session data in the RPC context type definitions.
|
|
98
|
+
|
|
99
|
+
The `ContextWithSession` interface now includes a `sessionCustomData` property (which may be `undefined`) to read custom session data and an `updateSessionCustomData` method to update it.
|
|
100
|
+
The `ContextWithoutSession` interface has been updated accordingly to maintain type consistency.
|
|
101
|
+
The `SessionCustomData` interface can be augmented using TypeScript module augmentation to provide type safety for custom session properties.
|
|
102
|
+
|
|
3
103
|
## 8.55.0
|
|
4
104
|
|
|
5
105
|
### 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.57.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,36 +90,36 @@
|
|
|
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.57.0",
|
|
94
94
|
"@scayle/unstorage-compression-driver": "1.2.4"
|
|
95
95
|
},
|
|
96
96
|
"devDependencies": {
|
|
97
97
|
"@arethetypeswrong/cli": "0.18.2",
|
|
98
98
|
"@eslint/eslintrc": "3.3.3",
|
|
99
|
-
"@nuxt/eslint": "1.
|
|
100
|
-
"@nuxt/eslint-config": "1.
|
|
99
|
+
"@nuxt/eslint": "1.12.1",
|
|
100
|
+
"@nuxt/eslint-config": "1.12.1",
|
|
101
101
|
"@nuxt/kit": "3.20.0",
|
|
102
102
|
"@nuxt/module-builder": "1.0.2",
|
|
103
103
|
"@nuxt/schema": "3.20.0",
|
|
104
|
-
"@nuxt/test-utils": "3.
|
|
105
|
-
"@types/node": "22.19.
|
|
106
|
-
"@vitest/coverage-v8": "4.0.
|
|
104
|
+
"@nuxt/test-utils": "3.21.0",
|
|
105
|
+
"@types/node": "22.19.3",
|
|
106
|
+
"@vitest/coverage-v8": "4.0.15",
|
|
107
107
|
"dprint": "0.50.2",
|
|
108
|
-
"eslint-formatter-gitlab": "7.0.
|
|
109
|
-
"eslint": "9.39.
|
|
110
|
-
"fishery": "2.
|
|
108
|
+
"eslint-formatter-gitlab": "7.0.1",
|
|
109
|
+
"eslint": "9.39.2",
|
|
110
|
+
"fishery": "2.4.0",
|
|
111
111
|
"h3": "1.15.4",
|
|
112
112
|
"nitro-test-utils": "0.10.1",
|
|
113
113
|
"nitropack": "2.12.8",
|
|
114
114
|
"node-mocks-http": "1.17.2",
|
|
115
115
|
"nuxt": "3.20.0",
|
|
116
|
-
"publint": "0.3.
|
|
116
|
+
"publint": "0.3.16",
|
|
117
117
|
"typescript": "5.9.3",
|
|
118
118
|
"unbuild": "3.6.1",
|
|
119
|
-
"vitest": "4.0.
|
|
120
|
-
"vue-tsc": "3.1.
|
|
119
|
+
"vitest": "4.0.15",
|
|
120
|
+
"vue-tsc": "3.1.8",
|
|
121
121
|
"happy-dom": "20.0.11",
|
|
122
|
-
"@scayle/eslint-config-storefront": "4.7.
|
|
122
|
+
"@scayle/eslint-config-storefront": "4.7.17",
|
|
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"
|