@scayle/storefront-nuxt 7.87.2 → 7.88.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 +25 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +1 -1
- package/dist/runtime/composables/storefront/useNavigationTree.d.ts +11 -1
- package/dist/runtime/composables/storefront/useNavigationTree.js +15 -2
- package/dist/runtime/server/middleware/redirects.js +38 -16
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
# @scayle/storefront-nuxt
|
|
2
2
|
|
|
3
|
+
## 7.88.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependency `@vueuse/core@11.1.0` to `@vueuse/core@11.2.0`
|
|
8
|
+
- Handle error when reading from or saving to the redirect cache
|
|
9
|
+
|
|
10
|
+
With this change, when the application fails to read from the redirect cache it will log the error and fallback to using the SAPI endpoint.
|
|
11
|
+
**Dependencies**
|
|
12
|
+
|
|
13
|
+
- Updated dependency to @scayle/storefront-core@7.66.1
|
|
14
|
+
|
|
15
|
+
## 7.88.0
|
|
16
|
+
|
|
17
|
+
### Minor Changes
|
|
18
|
+
|
|
19
|
+
- Add `useNavigationTreeByName` and `useNavigationTreeById` composables.
|
|
20
|
+
Deprecate `useNavigationTree` composable in favor of `useNavigationTreeById`.
|
|
21
|
+
|
|
22
|
+
### Patch Changes
|
|
23
|
+
|
|
24
|
+
**Dependencies**
|
|
25
|
+
|
|
26
|
+
- Updated dependency to @scayle/storefront-core@7.66.0
|
|
27
|
+
|
|
3
28
|
## 7.87.2
|
|
4
29
|
|
|
5
30
|
### Patch Changes
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
import type { RpcMethodParameters } from '@scayle/storefront-core';
|
|
2
2
|
import type { UseRpcOptions, UseRpcReturn, NormalizedRpcResponse, KeysOf } from '../core/useRpc.js';
|
|
3
3
|
import type { MaybeRefOrGetter } from '#imports';
|
|
4
|
-
export declare function
|
|
4
|
+
export declare function useNavigationTreeById<DataT = NormalizedRpcResponse<'fetchNavigationTreeById'>, PickKeys extends KeysOf<DataT> = KeysOf<DataT>, DefaultT = null>({ params, options, key: _key, }?: Partial<{
|
|
5
5
|
params: MaybeRefOrGetter<RpcMethodParameters<'fetchNavigationTreeById'>>;
|
|
6
6
|
options: UseRpcOptions<'fetchNavigationTreeById', DataT, PickKeys, DefaultT>;
|
|
7
7
|
/** @deprecated use the second argument of the composable to define the key */
|
|
8
8
|
key: string;
|
|
9
9
|
}>, key?: string): UseRpcReturn<'fetchNavigationTreeById', DataT, PickKeys, DefaultT>;
|
|
10
|
+
/**
|
|
11
|
+
* @deprecated This composable was renamed to {@link useNavigationTreeById}.
|
|
12
|
+
*/
|
|
13
|
+
export declare const useNavigationTree: typeof useNavigationTreeById;
|
|
14
|
+
export declare function useNavigationTreeByName<DataT = NormalizedRpcResponse<'fetchNavigationTreeById'>, PickKeys extends KeysOf<DataT> = KeysOf<DataT>, DefaultT = null>({ params, options, key: _key, }?: Partial<{
|
|
15
|
+
params: MaybeRefOrGetter<RpcMethodParameters<'fetchNavigationTreeByName'>>;
|
|
16
|
+
options: UseRpcOptions<'fetchNavigationTreeById', DataT, PickKeys, DefaultT>;
|
|
17
|
+
/** @deprecated use the second argument of the composable to define the key */
|
|
18
|
+
key: string;
|
|
19
|
+
}>, key?: string): UseRpcReturn<'fetchNavigationTreeByName', DataT, PickKeys, DefaultT>;
|
|
@@ -1,12 +1,25 @@
|
|
|
1
1
|
import { useRpc } from "../core/useRpc.js";
|
|
2
|
-
export function
|
|
2
|
+
export function useNavigationTreeById({
|
|
3
3
|
params,
|
|
4
4
|
options,
|
|
5
5
|
key: _key
|
|
6
6
|
} = {}, key) {
|
|
7
7
|
return useRpc(
|
|
8
8
|
"fetchNavigationTreeById",
|
|
9
|
-
_key ?? key ?? "
|
|
9
|
+
_key ?? key ?? "useNavigationTreeById",
|
|
10
|
+
params,
|
|
11
|
+
options
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
export const useNavigationTree = useNavigationTreeById;
|
|
15
|
+
export function useNavigationTreeByName({
|
|
16
|
+
params,
|
|
17
|
+
options,
|
|
18
|
+
key: _key
|
|
19
|
+
} = {}, key) {
|
|
20
|
+
return useRpc(
|
|
21
|
+
"fetchNavigationTreeByName",
|
|
22
|
+
_key ?? key ?? "useNavigationTreeByName",
|
|
10
23
|
params,
|
|
11
24
|
options
|
|
12
25
|
);
|
|
@@ -5,13 +5,17 @@ import { useRuntimeConfig } from "#imports";
|
|
|
5
5
|
const REDIS_REDIRECT_PREFIX = ":REDIRECT";
|
|
6
6
|
const REDIRECT_NOT_SET = "REDIRECT_NOT_SET";
|
|
7
7
|
const REDIRECT_CACHE_TTL = 120;
|
|
8
|
-
async function fetchRedirectWithCache(sourceUrl, storefrontAPIClient, redirectCache, log) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
if (cachedResult
|
|
12
|
-
|
|
8
|
+
async function fetchRedirectWithCache(sourceUrl, storefrontAPIClient, redirectCache, log, waitUntil) {
|
|
9
|
+
try {
|
|
10
|
+
const cachedResult = await redirectCache.get(sourceUrl);
|
|
11
|
+
if (cachedResult) {
|
|
12
|
+
if (cachedResult === REDIRECT_NOT_SET) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
return cachedResult;
|
|
13
16
|
}
|
|
14
|
-
|
|
17
|
+
} catch (e) {
|
|
18
|
+
log.error("Error fetching redirect from cache", e);
|
|
15
19
|
}
|
|
16
20
|
log.debug("No cached result for redirect; querying SAPI");
|
|
17
21
|
let sapiResult;
|
|
@@ -27,16 +31,22 @@ async function fetchRedirectWithCache(sourceUrl, storefrontAPIClient, redirectCa
|
|
|
27
31
|
return redirect && redirect?.source && redirect?.target && redirect.source !== redirect.target;
|
|
28
32
|
};
|
|
29
33
|
if (!sapiResult || !isValidRedirect(sapiResult)) {
|
|
30
|
-
|
|
34
|
+
waitUntil(
|
|
35
|
+
redirectCache.set(sourceUrl, REDIRECT_NOT_SET, REDIRECT_CACHE_TTL).catch(
|
|
36
|
+
(e) => log.error("Error saving redirect to cache", e)
|
|
37
|
+
)
|
|
38
|
+
);
|
|
31
39
|
return null;
|
|
32
40
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
41
|
+
waitUntil(
|
|
42
|
+
redirectCache.set(
|
|
43
|
+
sapiResult.source,
|
|
44
|
+
{
|
|
45
|
+
target: sapiResult.target,
|
|
46
|
+
statusCode: sapiResult.statusCode
|
|
47
|
+
},
|
|
48
|
+
REDIRECT_CACHE_TTL
|
|
49
|
+
).catch((e) => log.error("Error saving redirect to cache", e))
|
|
40
50
|
);
|
|
41
51
|
return sapiResult;
|
|
42
52
|
}
|
|
@@ -62,8 +72,20 @@ export async function useRedirects(event) {
|
|
|
62
72
|
queryParamWhitelist
|
|
63
73
|
);
|
|
64
74
|
const [relativeRedirect, absoluteRedirect] = await Promise.all([
|
|
65
|
-
fetchRedirectWithCache(
|
|
66
|
-
|
|
75
|
+
fetchRedirectWithCache(
|
|
76
|
+
relativeSourceUrl,
|
|
77
|
+
sapiClient,
|
|
78
|
+
redirectCache,
|
|
79
|
+
log,
|
|
80
|
+
event.waitUntil
|
|
81
|
+
),
|
|
82
|
+
fetchRedirectWithCache(
|
|
83
|
+
absoluteSourceUrl,
|
|
84
|
+
sapiClient,
|
|
85
|
+
redirectCache,
|
|
86
|
+
log,
|
|
87
|
+
event.waitUntil
|
|
88
|
+
)
|
|
67
89
|
]);
|
|
68
90
|
if (relativeRedirect && absoluteRedirect) {
|
|
69
91
|
log.info(`There are multiple valid redirects for: ${url.toString()}`);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scayle/storefront-nuxt",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "7.
|
|
4
|
+
"version": "7.88.1",
|
|
5
5
|
"description": "Nuxt integration for the SCAYLE Commerce Engine and Storefront API",
|
|
6
6
|
"author": "SCAYLE Commerce Engine",
|
|
7
7
|
"license": "MIT",
|
|
@@ -65,9 +65,9 @@
|
|
|
65
65
|
"@nuxt/kit": "^3.12.2",
|
|
66
66
|
"@opentelemetry/api": "^1.9.0",
|
|
67
67
|
"@scayle/h3-session": "^0.4.1",
|
|
68
|
-
"@scayle/storefront-core": "7.
|
|
68
|
+
"@scayle/storefront-core": "7.66.1",
|
|
69
69
|
"@scayle/unstorage-compression-driver": "^0.1.4",
|
|
70
|
-
"@vueuse/core": "11.
|
|
70
|
+
"@vueuse/core": "11.2.0",
|
|
71
71
|
"consola": "^3.2.3",
|
|
72
72
|
"core-js": "^3.37.1",
|
|
73
73
|
"defu": "^6.1.4",
|
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
"@nuxt/test-utils": "3.14.4",
|
|
90
90
|
"@scayle/eslint-config-storefront": "4.3.2",
|
|
91
91
|
"@scayle/eslint-plugin-vue-composable": "0.2.1",
|
|
92
|
-
"@types/node": "22.8.
|
|
92
|
+
"@types/node": "22.8.5",
|
|
93
93
|
"dprint": "0.47.5",
|
|
94
94
|
"eslint": "9.13.0",
|
|
95
95
|
"eslint-formatter-gitlab": "5.1.0",
|
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
"nuxt": "3.13.2",
|
|
101
101
|
"publint": "0.2.12",
|
|
102
102
|
"vitest": "2.1.4",
|
|
103
|
-
"vue-tsc": "2.1.
|
|
103
|
+
"vue-tsc": "2.1.10"
|
|
104
104
|
},
|
|
105
105
|
"peerDependencies": {
|
|
106
106
|
"h3": "^1.10.0",
|