@scayle/storefront-nuxt 7.43.0 → 7.44.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 +19 -0
- package/dist/module.json +1 -1
- package/dist/runtime/composables/core/useRpc.mjs +6 -2
- package/dist/runtime/error/handler.d.ts +2 -10
- package/dist/runtime/error/handler.mjs +20 -19
- package/dist/runtime/nitro/plugins/nitroRuntimeStorageConfig.mjs +1 -1
- package/package.json +5 -5
- package/dist/runtime/utils/error.d.ts +0 -5
- package/dist/runtime/utils/error.mjs +0 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @scayle/storefront-nuxt
|
|
2
2
|
|
|
3
|
+
## 7.44.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Update SAPI SDK to v16
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Fix error when mounting vercelKV driver with default options
|
|
12
|
+
- Updated dependencies
|
|
13
|
+
- @scayle/storefront-core@7.31.0
|
|
14
|
+
|
|
15
|
+
## 7.43.1
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Updated dependencies
|
|
20
|
+
- @scayle/storefront-core@7.30.0
|
|
21
|
+
|
|
3
22
|
## 7.43.0
|
|
4
23
|
|
|
5
24
|
### Minor Changes
|
package/dist/module.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { useNuxtApp, useState } from "nuxt/app";
|
|
1
|
+
import { useNuxtApp, useState, createError } from "nuxt/app";
|
|
2
2
|
import { useCoreLog } from "../useCoreLog.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { resolveError } from "../../error/handler.mjs";
|
|
4
4
|
import { useCurrentShop } from "./useCurrentShop.mjs";
|
|
5
5
|
import { toValue } from "#imports";
|
|
6
6
|
function getFetch(nuxtApp, log) {
|
|
@@ -10,6 +10,10 @@ function getFetch(nuxtApp, log) {
|
|
|
10
10
|
}
|
|
11
11
|
return fetch;
|
|
12
12
|
}
|
|
13
|
+
const handleError = (error) => {
|
|
14
|
+
const data = resolveError(error);
|
|
15
|
+
return createError(data);
|
|
16
|
+
};
|
|
13
17
|
export const useRpc = async (method, key, params, options = { autoFetch: true, lazy: false }) => {
|
|
14
18
|
const currentShop = useCurrentShop();
|
|
15
19
|
const log = useCoreLog("rpc");
|
|
@@ -1,14 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
import { FetchError } from 'ofetch';
|
|
3
|
-
declare const parseErrorData: (error: unknown) => {
|
|
4
|
-
statusCode: HttpStatusCode;
|
|
5
|
-
statusMessage: string;
|
|
6
|
-
url?: string;
|
|
7
|
-
};
|
|
8
|
-
declare const resolveError: (error: FetchError | Error | unknown, additionalData?: unknown) => {
|
|
1
|
+
declare const resolveError: (error: Error | unknown) => {
|
|
9
2
|
statusCode: 401 | 500 | 400 | 100 | 101 | 102 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 226 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 421 | 422 | 423 | 424 | 426 | 428 | 429 | 431 | 451 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511;
|
|
10
3
|
statusMessage: string;
|
|
11
4
|
name: string;
|
|
12
|
-
data: unknown;
|
|
13
5
|
};
|
|
14
|
-
export { resolveError
|
|
6
|
+
export { resolveError };
|
|
@@ -2,43 +2,44 @@ import {
|
|
|
2
2
|
BAPIError,
|
|
3
3
|
BaseError,
|
|
4
4
|
HttpStatusCode,
|
|
5
|
-
HttpStatusMessage
|
|
5
|
+
HttpStatusMessage,
|
|
6
|
+
BAPIFetchError
|
|
6
7
|
} from "@scayle/storefront-core";
|
|
7
8
|
import { FetchError } from "ofetch";
|
|
8
9
|
const parseErrorData = (error) => {
|
|
9
|
-
if (error
|
|
10
|
-
const
|
|
10
|
+
if (error instanceof FetchError) {
|
|
11
|
+
const url = error.request?.url ?? String(error.request) ?? "/";
|
|
11
12
|
return {
|
|
12
|
-
statusCode:
|
|
13
|
-
statusMessage:
|
|
14
|
-
url
|
|
13
|
+
statusCode: error.status ?? HttpStatusCode.INTERNAL_SERVER_ERROR,
|
|
14
|
+
statusMessage: error.statusText ?? HttpStatusMessage.INTERNAL_SERVER_ERROR,
|
|
15
|
+
url
|
|
15
16
|
};
|
|
16
17
|
}
|
|
17
|
-
if (error instanceof
|
|
18
|
-
const url = error.
|
|
18
|
+
if (error instanceof BAPIFetchError) {
|
|
19
|
+
const url = error.response.url;
|
|
19
20
|
return {
|
|
20
|
-
statusCode: error.status
|
|
21
|
-
statusMessage: error.statusText
|
|
21
|
+
statusCode: error.response.status ?? HttpStatusCode.INTERNAL_SERVER_ERROR,
|
|
22
|
+
statusMessage: error.response.statusText ?? HttpStatusMessage.INTERNAL_SERVER_ERROR,
|
|
22
23
|
url
|
|
23
24
|
};
|
|
24
25
|
}
|
|
25
26
|
if (error instanceof BAPIError) {
|
|
26
27
|
return {
|
|
27
|
-
statusCode: error.statusCode
|
|
28
|
-
statusMessage: error.message
|
|
28
|
+
statusCode: error.statusCode ?? HttpStatusCode.INTERNAL_SERVER_ERROR,
|
|
29
|
+
statusMessage: error.message ?? HttpStatusMessage.INTERNAL_SERVER_ERROR,
|
|
29
30
|
url: error.url
|
|
30
31
|
};
|
|
31
32
|
}
|
|
32
33
|
if (error instanceof BaseError) {
|
|
33
34
|
return {
|
|
34
|
-
statusCode: error.statusCode
|
|
35
|
-
statusMessage: error.message
|
|
35
|
+
statusCode: error.statusCode ?? HttpStatusCode.INTERNAL_SERVER_ERROR,
|
|
36
|
+
statusMessage: error.message ?? HttpStatusMessage.INTERNAL_SERVER_ERROR
|
|
36
37
|
};
|
|
37
38
|
}
|
|
38
39
|
if (error instanceof Error) {
|
|
39
40
|
return {
|
|
40
41
|
statusCode: HttpStatusCode.INTERNAL_SERVER_ERROR,
|
|
41
|
-
statusMessage: error.message
|
|
42
|
+
statusMessage: error.message ?? HttpStatusMessage.INTERNAL_SERVER_ERROR
|
|
42
43
|
};
|
|
43
44
|
}
|
|
44
45
|
return {
|
|
@@ -46,11 +47,11 @@ const parseErrorData = (error) => {
|
|
|
46
47
|
statusMessage: HttpStatusMessage.INTERNAL_SERVER_ERROR
|
|
47
48
|
};
|
|
48
49
|
};
|
|
49
|
-
const resolveError = (error
|
|
50
|
+
const resolveError = (error) => {
|
|
50
51
|
const { statusCode, statusMessage } = parseErrorData(error);
|
|
51
|
-
const [key] = Object.entries(HttpStatusCode).find(([_, code]) => code === statusCode)
|
|
52
|
+
const [key] = Object.entries(HttpStatusCode).find(([_, code]) => code === statusCode) ?? [];
|
|
52
53
|
const statusCodeKey = key;
|
|
53
54
|
const name = statusCodeKey ? HttpStatusMessage[statusCodeKey] : HttpStatusMessage.INTERNAL_SERVER_ERROR;
|
|
54
|
-
return { statusCode, statusMessage, name
|
|
55
|
+
return { statusCode, statusMessage, name };
|
|
55
56
|
};
|
|
56
|
-
export { resolveError
|
|
57
|
+
export { resolveError };
|
|
@@ -11,7 +11,7 @@ function createMountDriver(options) {
|
|
|
11
11
|
const compression = options?.compression;
|
|
12
12
|
const isCompressionEnabled = !!compression && compression !== "none";
|
|
13
13
|
const driver = drivers[options.driver ?? "memory"];
|
|
14
|
-
const createdDriver = driver(options);
|
|
14
|
+
const createdDriver = driver({ ...options });
|
|
15
15
|
return isCompressionEnabled ? drivers.compression({
|
|
16
16
|
...options,
|
|
17
17
|
encoding: compression,
|
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.44.0",
|
|
5
5
|
"description": "Nuxt integration for the SCAYLE Commerce Engine and Storefront API",
|
|
6
6
|
"author": "SCAYLE Commerce Engine",
|
|
7
7
|
"license": "MIT",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"dependencies": {
|
|
63
63
|
"@nuxt/kit": "3.8.2",
|
|
64
64
|
"@scayle/h3-session": "0.3.4",
|
|
65
|
-
"@scayle/storefront-core": "7.
|
|
65
|
+
"@scayle/storefront-core": "7.31.0",
|
|
66
66
|
"@scayle/unstorage-compression-driver": "0.1.1",
|
|
67
67
|
"@vueuse/core": "10.7.0",
|
|
68
68
|
"consola": "3.2.3",
|
|
@@ -83,16 +83,16 @@
|
|
|
83
83
|
"@nuxt/module-builder": "0.5.4",
|
|
84
84
|
"@nuxt/schema": "3.8.2",
|
|
85
85
|
"@nuxt/test-utils": "3.8.1",
|
|
86
|
-
"@scayle/eslint-config-storefront": "3.2.
|
|
86
|
+
"@scayle/eslint-config-storefront": "3.2.6",
|
|
87
87
|
"@scayle/prettier-config-storefront": "2.0.2",
|
|
88
88
|
"@types/node": "20.10.4",
|
|
89
89
|
"eslint": "8.55.0",
|
|
90
90
|
"eslint-formatter-gitlab": "5.1.0",
|
|
91
|
-
"node-mocks-http": "1.
|
|
91
|
+
"node-mocks-http": "1.14.0",
|
|
92
92
|
"nuxt": "3.8.2",
|
|
93
93
|
"prettier": "3.0.0",
|
|
94
94
|
"publint": "0.2.6",
|
|
95
|
-
"vitest": "1.0.
|
|
95
|
+
"vitest": "1.0.4",
|
|
96
96
|
"vue-tsc": "1.8.25"
|
|
97
97
|
},
|
|
98
98
|
"peerDependencies": {
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { NuxtError } from 'nuxt/app';
|
|
2
|
-
import type { FetchError } from 'ofetch';
|
|
3
|
-
import { parseErrorData } from '../error/handler';
|
|
4
|
-
declare const handleError: (error: FetchError | Error | unknown, additionalData?: unknown) => NuxtError;
|
|
5
|
-
export { handleError, parseErrorData };
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { createError } from "nuxt/app";
|
|
2
|
-
import { parseErrorData, resolveError } from "../error/handler.mjs";
|
|
3
|
-
const handleError = (error, additionalData) => {
|
|
4
|
-
const data = resolveError(error, additionalData);
|
|
5
|
-
return createError(data);
|
|
6
|
-
};
|
|
7
|
-
export { handleError, parseErrorData };
|