@scayle/storefront-nuxt 7.43.1 → 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 CHANGED
@@ -1,5 +1,17 @@
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
+
3
15
  ## 7.43.1
4
16
 
5
17
  ### Patch Changes
package/dist/module.json CHANGED
@@ -4,5 +4,5 @@
4
4
  "compatibility": {
5
5
  "nuxt": "^3.7.0"
6
6
  },
7
- "version": "7.43.0"
7
+ "version": "7.43.1"
8
8
  }
@@ -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 { handleError } from "../../utils/error.mjs";
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
- import { HttpStatusCode } from '@scayle/storefront-core';
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, parseErrorData };
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.isAxiosError) {
10
- const err = error;
10
+ if (error instanceof FetchError) {
11
+ const url = error.request?.url ?? String(error.request) ?? "/";
11
12
  return {
12
- statusCode: err.response?.data.code || HttpStatusCode.INTERNAL_SERVER_ERROR,
13
- statusMessage: err.response?.data.message || HttpStatusMessage.INTERNAL_SERVER_ERROR,
14
- url: err.config.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 FetchError) {
18
- const url = error.request?.url || String(error.request) || "/";
18
+ if (error instanceof BAPIFetchError) {
19
+ const url = error.response.url;
19
20
  return {
20
- statusCode: error.status || HttpStatusCode.INTERNAL_SERVER_ERROR,
21
- statusMessage: error.statusText || HttpStatusMessage.INTERNAL_SERVER_ERROR,
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 || HttpStatusCode.INTERNAL_SERVER_ERROR,
28
- statusMessage: error.message || HttpStatusMessage.INTERNAL_SERVER_ERROR,
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 || HttpStatusCode.INTERNAL_SERVER_ERROR,
35
- statusMessage: error.message || HttpStatusMessage.INTERNAL_SERVER_ERROR
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 || HttpStatusMessage.INTERNAL_SERVER_ERROR
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, additionalData) => {
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, data: additionalData };
55
+ return { statusCode, statusMessage, name };
55
56
  };
56
- export { resolveError, parseErrorData };
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.43.1",
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.30.0",
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",
@@ -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 };