@scayle/storefront-nuxt 7.42.1 → 7.42.3
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 +15 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +35 -0
- package/dist/runtime/composables/storefront/useCategories.mjs +2 -1
- package/dist/runtime/nitro/plugins/nitroRuntimeStorageConfig.mjs +12 -15
- package/dist/runtime/server/middleware/bootstrap.mjs +1 -1
- package/dist/runtime/server/middleware/oauth.mjs +2 -12
- package/package.json +10 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @scayle/storefront-nuxt
|
|
2
2
|
|
|
3
|
+
## 7.42.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fix incorrect parsing of legacy config
|
|
8
|
+
- Include missing unstorage drivers in final build
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
- @scayle/storefront-core@7.28.2
|
|
11
|
+
|
|
12
|
+
## 7.42.2
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Ensure `useNuxtApp` is only called from a composable context in `useCategories`
|
|
17
|
+
|
|
3
18
|
## 7.42.1
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -2,7 +2,29 @@ import { defineNuxtModule, createResolver, extendViteConfig, addServerHandler, a
|
|
|
2
2
|
import yn from 'yn';
|
|
3
3
|
import { rpcMethods } from '@scayle/storefront-core';
|
|
4
4
|
import { defu } from 'defu';
|
|
5
|
+
import { genImport, genSafeVariableName } from 'knitwork';
|
|
6
|
+
import { builtinDrivers } from 'unstorage';
|
|
5
7
|
|
|
8
|
+
function getUsedDrivers(options) {
|
|
9
|
+
const drivers = /* @__PURE__ */ new Set();
|
|
10
|
+
drivers.add("memory");
|
|
11
|
+
if (options.redis || Object.values(options.stores).some((store) => store.redis)) {
|
|
12
|
+
drivers.add("redis");
|
|
13
|
+
}
|
|
14
|
+
const addDriver = (config) => {
|
|
15
|
+
if (config?.cache?.driver) {
|
|
16
|
+
drivers.add(config.cache.driver);
|
|
17
|
+
}
|
|
18
|
+
if (config?.session?.driver) {
|
|
19
|
+
drivers.add(config.session.driver);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
addDriver(options.storage);
|
|
23
|
+
Object.values(options.stores).forEach((store) => {
|
|
24
|
+
addDriver(store.storage);
|
|
25
|
+
});
|
|
26
|
+
return Array.from(drivers);
|
|
27
|
+
}
|
|
6
28
|
const module = defineNuxtModule({
|
|
7
29
|
meta: {
|
|
8
30
|
name: "@scayle/storefront-nuxt",
|
|
@@ -173,6 +195,19 @@ const module = defineNuxtModule({
|
|
|
173
195
|
nitroConfig.replace["process.env.SFC_OMIT_MD5"] = yn(
|
|
174
196
|
process.env.SFC_OMIT_MD5
|
|
175
197
|
);
|
|
198
|
+
const usedDrivers = getUsedDrivers(options);
|
|
199
|
+
nitroConfig.virtual = {
|
|
200
|
+
...nitroConfig.virtual,
|
|
201
|
+
"#virtual/storage-drivers": `
|
|
202
|
+
${usedDrivers.map(
|
|
203
|
+
(driver) => genImport(builtinDrivers[driver], genSafeVariableName(driver))
|
|
204
|
+
).join("\n")}
|
|
205
|
+
|
|
206
|
+
export default {
|
|
207
|
+
${usedDrivers.map((driver) => '"' + driver + '":' + genSafeVariableName(driver) + ",").join("\n")}
|
|
208
|
+
}
|
|
209
|
+
`
|
|
210
|
+
};
|
|
176
211
|
});
|
|
177
212
|
nuxt.options.alias["#rpcMethods"] = appResolve(
|
|
178
213
|
options.rpcDir ?? "./rpcMethods"
|
|
@@ -8,6 +8,7 @@ export async function useCategories({
|
|
|
8
8
|
key = "useCategories"
|
|
9
9
|
} = {}) {
|
|
10
10
|
const currentShop = useCurrentShop();
|
|
11
|
+
const nuxtApp = useNuxtApp();
|
|
11
12
|
const { data, fetching, fetch, error, status } = await useRpc(
|
|
12
13
|
"getCategoriesByPath",
|
|
13
14
|
key,
|
|
@@ -15,7 +16,7 @@ export async function useCategories({
|
|
|
15
16
|
options
|
|
16
17
|
);
|
|
17
18
|
const getCategoryById = rpcCall(
|
|
18
|
-
|
|
19
|
+
nuxtApp,
|
|
19
20
|
"getCategoryById",
|
|
20
21
|
currentShop.value ?? void 0
|
|
21
22
|
);
|
|
@@ -1,34 +1,31 @@
|
|
|
1
1
|
import memoryDriver from "unstorage/drivers/memory";
|
|
2
|
-
import { builtinDrivers } from "unstorage";
|
|
3
2
|
import { createConsola } from "consola";
|
|
4
3
|
import {
|
|
5
4
|
STORAGE_MOUNT_CACHE,
|
|
6
5
|
STORAGE_MOUNT_SESSION
|
|
7
6
|
} from "../../server/utils/cacheStorage.mjs";
|
|
8
7
|
import createLog from "../../createLog.mjs";
|
|
8
|
+
import drivers from "#virtual/storage-drivers";
|
|
9
9
|
import { defineNitroPlugin, useRuntimeConfig, useStorage } from "#imports";
|
|
10
|
-
|
|
10
|
+
function createMountDriver(options) {
|
|
11
11
|
if (options?.driver) {
|
|
12
|
-
const driver =
|
|
13
|
-
// @ts-ignore
|
|
14
|
-
builtinDrivers[options.driver] || options.driver
|
|
15
|
-
).then((r) => r.default || r);
|
|
12
|
+
const driver = drivers[options.driver ?? "memory"];
|
|
16
13
|
return driver(options ?? {});
|
|
17
14
|
}
|
|
18
15
|
return memoryDriver();
|
|
19
16
|
}
|
|
20
|
-
|
|
17
|
+
function mountStorage(storage, options) {
|
|
21
18
|
const { config, base } = options;
|
|
22
19
|
const mounts = storage.getMounts().map((existingMount) => existingMount.base.replace(":", ""));
|
|
23
20
|
if (!mounts.includes(base)) {
|
|
24
21
|
if (config) {
|
|
25
|
-
storage.mount(base,
|
|
22
|
+
storage.mount(base, createMountDriver(config));
|
|
26
23
|
} else {
|
|
27
|
-
storage.mount(base,
|
|
24
|
+
storage.mount(base, createMountDriver());
|
|
28
25
|
}
|
|
29
26
|
}
|
|
30
27
|
}
|
|
31
|
-
function transformLegacyConfig(provider = "
|
|
28
|
+
function transformLegacyConfig(provider = "redis", mode, log, redis, shopId = void 0) {
|
|
32
29
|
log.warn(
|
|
33
30
|
`${shopId ? "Shop " + shopId + " Storage" : "Global Storage"}: Using legacy storage config for ${mode}. The \`provider\` and \`redis\` options are deprecated.`
|
|
34
31
|
);
|
|
@@ -115,7 +112,7 @@ function getShopSessionConfig(config, shop, log) {
|
|
|
115
112
|
shop.shopId
|
|
116
113
|
);
|
|
117
114
|
}
|
|
118
|
-
export default defineNitroPlugin(
|
|
115
|
+
export default defineNitroPlugin(() => {
|
|
119
116
|
const storage = useStorage();
|
|
120
117
|
const config = useRuntimeConfig();
|
|
121
118
|
const log = createLog(
|
|
@@ -126,12 +123,12 @@ export default defineNitroPlugin(async () => {
|
|
|
126
123
|
const shops = config.storefront.stores;
|
|
127
124
|
try {
|
|
128
125
|
const globalCacheConfig = getCacheConfig(config, log);
|
|
129
|
-
|
|
126
|
+
mountStorage(storage, {
|
|
130
127
|
base: STORAGE_MOUNT_CACHE,
|
|
131
128
|
config: globalCacheConfig
|
|
132
129
|
});
|
|
133
130
|
const globalSessionConfig = getSessionConfig(config, log);
|
|
134
|
-
|
|
131
|
+
mountStorage(storage, {
|
|
135
132
|
base: STORAGE_MOUNT_SESSION,
|
|
136
133
|
config: globalSessionConfig
|
|
137
134
|
});
|
|
@@ -140,14 +137,14 @@ export default defineNitroPlugin(async () => {
|
|
|
140
137
|
const shopSessionMount = `${STORAGE_MOUNT_SESSION}:${shop.shopId}`;
|
|
141
138
|
const cacheConfig = getShopCacheConfig(config, shop, log);
|
|
142
139
|
if (cacheConfig) {
|
|
143
|
-
|
|
140
|
+
mountStorage(storage, {
|
|
144
141
|
base: shopCacheMount,
|
|
145
142
|
config: cacheConfig
|
|
146
143
|
});
|
|
147
144
|
}
|
|
148
145
|
const sessionConfig = getShopSessionConfig(config, shop, log);
|
|
149
146
|
if (sessionConfig) {
|
|
150
|
-
|
|
147
|
+
mountStorage(storage, {
|
|
151
148
|
base: shopSessionMount,
|
|
152
149
|
config: sessionConfig
|
|
153
150
|
});
|
|
@@ -44,7 +44,7 @@ async function handleOauth(event, storefrontConfig, log) {
|
|
|
44
44
|
}
|
|
45
45
|
async function bootstrap(event, log, url, $shopConfig, $storefrontConfig, apiBasePath, config) {
|
|
46
46
|
const bootstrapLog = log.space("bootstrap");
|
|
47
|
-
bootstrapLog.debug("Bootstrapping request: "
|
|
47
|
+
bootstrapLog.debug("Bootstrapping request: " + url.toString());
|
|
48
48
|
const $cache = useCacheStorage(
|
|
49
49
|
String($shopConfig.shopId),
|
|
50
50
|
$shopConfig.shopId,
|
|
@@ -7,14 +7,9 @@ async function updateSession(event, data) {
|
|
|
7
7
|
}
|
|
8
8
|
const updateUser = async (event) => {
|
|
9
9
|
const session = event.context.session;
|
|
10
|
-
const checkoutUrl = event.context.$rpcContext.checkout.url;
|
|
11
|
-
const shopId = event.context.$currentShop.shopId;
|
|
12
10
|
const user = await rpcMethods.fetchUser(
|
|
13
11
|
{ accessToken: session.data.accessToken, callback: "" },
|
|
14
|
-
|
|
15
|
-
checkoutUrl,
|
|
16
|
-
shopId
|
|
17
|
-
}
|
|
12
|
+
event.context.$rpcContext
|
|
18
13
|
);
|
|
19
14
|
await updateSession(event, {
|
|
20
15
|
user
|
|
@@ -64,14 +59,9 @@ const revokeTokensAndDestroySession = async (event, log) => {
|
|
|
64
59
|
};
|
|
65
60
|
const updateSessionWithUser = async (event, sessionData, log) => {
|
|
66
61
|
try {
|
|
67
|
-
const checkoutUrl = event.context.$rpcContext.checkout.url;
|
|
68
|
-
const shopId = event.context.$currentShop.shopId;
|
|
69
62
|
const user = await rpcMethods.fetchUser(
|
|
70
63
|
{ accessToken: sessionData.accessToken, callback: "" },
|
|
71
|
-
|
|
72
|
-
checkoutUrl,
|
|
73
|
-
shopId
|
|
74
|
-
}
|
|
64
|
+
event.context.$rpcContext
|
|
75
65
|
);
|
|
76
66
|
await updateSession(event, {
|
|
77
67
|
user
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scayle/storefront-nuxt",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "7.42.
|
|
4
|
+
"version": "7.42.3",
|
|
5
5
|
"description": "Nuxt integration for the SCAYLE Commerce Engine and Storefront API",
|
|
6
6
|
"author": "SCAYLE Commerce Engine",
|
|
7
7
|
"license": "MIT",
|
|
@@ -62,13 +62,14 @@
|
|
|
62
62
|
"dependencies": {
|
|
63
63
|
"@nuxt/kit": "3.8.2",
|
|
64
64
|
"@scayle/h3-session": "0.3.4",
|
|
65
|
-
"@scayle/storefront-core": "7.28.
|
|
66
|
-
"@vueuse/core": "10.
|
|
65
|
+
"@scayle/storefront-core": "7.28.2",
|
|
66
|
+
"@vueuse/core": "10.7.0",
|
|
67
67
|
"consola": "3.2.3",
|
|
68
|
-
"core-js": "3.
|
|
68
|
+
"core-js": "3.34.0",
|
|
69
69
|
"defu": "6.1.3",
|
|
70
70
|
"h3": "1.9.0",
|
|
71
71
|
"jose": "4.15.4",
|
|
72
|
+
"knitwork": "1.0.0",
|
|
72
73
|
"nitropack": "2.8.1",
|
|
73
74
|
"ofetch": "1.3.3",
|
|
74
75
|
"radash": "11.0.0",
|
|
@@ -83,15 +84,15 @@
|
|
|
83
84
|
"@nuxt/test-utils": "3.8.1",
|
|
84
85
|
"@scayle/eslint-config-storefront": "3.2.5",
|
|
85
86
|
"@scayle/prettier-config-storefront": "2.0.2",
|
|
86
|
-
"@types/node": "20.10.
|
|
87
|
-
"eslint": "8.
|
|
87
|
+
"@types/node": "20.10.4",
|
|
88
|
+
"eslint": "8.55.0",
|
|
88
89
|
"eslint-formatter-gitlab": "5.1.0",
|
|
89
90
|
"node-mocks-http": "1.13.0",
|
|
90
91
|
"nuxt": "3.8.2",
|
|
91
92
|
"prettier": "3.0.0",
|
|
92
|
-
"publint": "0.2.
|
|
93
|
-
"vitest": "0.
|
|
94
|
-
"vue-tsc": "1.8.
|
|
93
|
+
"publint": "0.2.6",
|
|
94
|
+
"vitest": "1.0.1",
|
|
95
|
+
"vue-tsc": "1.8.25"
|
|
95
96
|
},
|
|
96
97
|
"peerDependencies": {
|
|
97
98
|
"nuxt": ">=3.8.1",
|