@scayle/storefront-nuxt 7.40.1 → 7.40.2

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,12 @@
1
1
  # @scayle/storefront-nuxt
2
2
 
3
+ ## 7.40.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+ - @scayle/storefront-core@7.27.0
9
+
3
10
  ## 7.40.1
4
11
 
5
12
  ### 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.40.0"
7
+ "version": "7.40.1"
8
8
  }
package/dist/rpc.mjs CHANGED
@@ -8,7 +8,7 @@ const rpcCall = (nuxtApp, method, shop) => {
8
8
  payload: params
9
9
  },
10
10
  headers: {
11
- "x-shop-id": shop.shopId + ""
11
+ "x-shop-id": String(shop.shopId)
12
12
  }
13
13
  });
14
14
  return data;
@@ -1,6 +1,6 @@
1
1
  import type { EventHandler } from 'h3';
2
2
  /**
3
- * Wrap an event handler protected by the authentication specified in cache.auth
3
+ * Wrap an event handler protected by the authentication specified in `cache.auth`
4
4
  * @param handler
5
5
  */
6
6
  export declare const eventHandlerWithCacheAuth: (handler: EventHandler) => EventHandler<import("h3").EventHandlerRequest, Promise<any>>;
@@ -8,7 +8,7 @@ import { HttpStatusCode } from "@scayle/storefront-core";
8
8
  import { useRuntimeConfig } from "#imports";
9
9
  export const eventHandlerWithCacheAuth = (handler) => defineEventHandler(async (event) => {
10
10
  const config = useRuntimeConfig();
11
- const auth = config.cache.auth;
11
+ const auth = config.storefront.cache?.auth;
12
12
  if (!auth) {
13
13
  return await handler(event);
14
14
  }
@@ -17,24 +17,24 @@ export const eventHandlerWithCacheAuth = (handler) => defineEventHandler(async (
17
17
  `${auth.username}:${auth.password}`
18
18
  )(event);
19
19
  });
20
+ const authenticationFailed = (event) => {
21
+ setResponseHeader(
22
+ event,
23
+ "WWW-Authenticate",
24
+ 'Basic realm="Authentication required"'
25
+ );
26
+ setResponseStatus(event, HttpStatusCode.UNAUTHORIZED);
27
+ return "Authentication required";
28
+ };
20
29
  export const eventHandlerWithBasicAuth = (handler, auth) => defineEventHandler(async (event) => {
21
30
  const headers = getRequestHeaders(event);
22
- const authenticationFailed = () => {
23
- setResponseHeader(
24
- event,
25
- "WWW-Authenticate",
26
- 'Basic realm="Authentication required"'
27
- );
28
- setResponseStatus(event, HttpStatusCode.UNAUTHORIZED);
29
- return "Authentication required";
30
- };
31
31
  if (!headers.authorization) {
32
- return authenticationFailed();
32
+ return authenticationFailed(event);
33
33
  }
34
34
  const b64auth = headers.authorization.split(" ")[1] || "";
35
35
  const decodedAuthHeader = Buffer.from(b64auth, "base64").toString();
36
36
  if (decodedAuthHeader !== auth) {
37
- return authenticationFailed();
37
+ return authenticationFailed(event);
38
38
  }
39
39
  return await handler(event);
40
40
  });
@@ -3,10 +3,15 @@ import { HttpStatusCode } from "@scayle/storefront-core";
3
3
  import { eventHandlerWithCacheAuth } from "./cacheAuth.mjs";
4
4
  export default eventHandlerWithCacheAuth(
5
5
  defineEventHandler(async (event) => {
6
+ const logger = event.context.$rpcContext.log.space("purge-all");
6
7
  try {
8
+ logger.debug("purging cache");
7
9
  await event.context.$cache.purgeAll();
8
10
  } catch (e) {
9
11
  setResponseStatus(event, HttpStatusCode.INTERNAL_SERVER_ERROR);
12
+ if (typeof e === "string" || e instanceof Error) {
13
+ logger.error(e);
14
+ }
10
15
  return { success: false };
11
16
  }
12
17
  return { success: true };
@@ -4,6 +4,8 @@ import { eventHandlerWithCacheAuth } from "./cacheAuth.mjs";
4
4
  export default eventHandlerWithCacheAuth(
5
5
  defineEventHandler(async (event) => {
6
6
  const tags = await readBody(event);
7
+ const logger = event.context.$rpcContext.log.space("purge-tags");
8
+ logger.debug(`purging tags: ${tags}`);
7
9
  if (!tags?.length) {
8
10
  setResponseStatus(event, HttpStatusCode.BAD_REQUEST);
9
11
  return { success: false };
@@ -12,6 +14,9 @@ export default eventHandlerWithCacheAuth(
12
14
  await event.context.$cache.purgeTags(tags);
13
15
  } catch (e) {
14
16
  setResponseStatus(event, HttpStatusCode.INTERNAL_SERVER_ERROR);
17
+ if (typeof e === "string" || e instanceof Error) {
18
+ logger.error(e);
19
+ }
15
20
  return { success: false };
16
21
  }
17
22
  return { success: true };
@@ -1,4 +1,4 @@
1
1
  import { defineEventHandler } from "h3";
2
- export default defineEventHandler((_event) => {
2
+ export default defineEventHandler(() => {
3
3
  return { status: "up" };
4
4
  });
@@ -1 +1,2 @@
1
- export declare function useLog(subSpace?: string): any;
1
+ import type { Log } from '@scayle/storefront-core';
2
+ export declare function useLog(subSpace?: string): Log;
@@ -13,7 +13,7 @@ export async function useFacet({
13
13
  `${key}-currentPage`,
14
14
  () => 1
15
15
  );
16
- const currentPerPage = useState(`${key}-itemsPerPAge`, () => 20);
16
+ const currentPerPage = useState(`${key}-itemsPerPage`, () => 20);
17
17
  const currentWhereCondition = useState(
18
18
  `${key}-whereCondition`
19
19
  );
@@ -1 +1 @@
1
- export declare function useCoreLog(subSpace: string): any;
1
+ export declare function useCoreLog(subSpace: string): import("@scayle/storefront-core").Log;
@@ -1,5 +1,4 @@
1
1
  import { Log } from "./log.mjs";
2
- const isProd = process.env.APP_ENV === "production";
3
2
  function prepareData(data) {
4
3
  if (!data) {
5
4
  return data;
@@ -23,9 +22,6 @@ export default function createLog(createConsola, space = "default-storefront") {
23
22
  // set to 3 to skip debug messages
24
23
  });
25
24
  const handler = (entry) => {
26
- if (isProd && entry.level === "debug") {
27
- return;
28
- }
29
25
  const data = prepareData(entry.data);
30
26
  const log = logger[entry.level] || logger.info;
31
27
  const message = `[${entry.space}] ${entry.message}`;
@@ -21,18 +21,21 @@ const parseErrorData = (error) => {
21
21
  statusMessage: error.statusText || HttpStatusMessage.INTERNAL_SERVER_ERROR,
22
22
  url
23
23
  };
24
- } else if (error instanceof BAPIError) {
24
+ }
25
+ if (error instanceof BAPIError) {
25
26
  return {
26
27
  statusCode: error.statusCode || HttpStatusCode.INTERNAL_SERVER_ERROR,
27
28
  statusMessage: error.message || HttpStatusMessage.INTERNAL_SERVER_ERROR,
28
29
  url: error.url
29
30
  };
30
- } else if (error instanceof BaseError) {
31
+ }
32
+ if (error instanceof BaseError) {
31
33
  return {
32
34
  statusCode: error.statusCode || HttpStatusCode.INTERNAL_SERVER_ERROR,
33
35
  statusMessage: error.message || HttpStatusMessage.INTERNAL_SERVER_ERROR
34
36
  };
35
- } else if (error instanceof Error) {
37
+ }
38
+ if (error instanceof Error) {
36
39
  return {
37
40
  statusCode: HttpStatusCode.INTERNAL_SERVER_ERROR,
38
41
  statusMessage: error.message || HttpStatusMessage.INTERNAL_SERVER_ERROR
@@ -1,2 +1,8 @@
1
- declare const _default: import("nuxt/app").Plugin<Record<string, unknown>> & import("nuxt/app").ObjectPlugin<Record<string, unknown>>;
1
+ declare const _default: import("nuxt/app").Plugin<{
2
+ log: import("@scayle/storefront-core").Log;
3
+ coreLog: import("@scayle/storefront-core").Log;
4
+ }> & import("nuxt/app").ObjectPlugin<{
5
+ log: import("@scayle/storefront-core").Log;
6
+ coreLog: import("@scayle/storefront-core").Log;
7
+ }>;
2
8
  export default _default;
@@ -5,7 +5,11 @@ export default defineNuxtPlugin((nuxtApp) => {
5
5
  }
6
6
  const log = nuxtApp.ssrContext.event.context.$rpcContext.log;
7
7
  const coreLog = log.space("sfc");
8
- nuxtApp.provide("log", log);
9
- nuxtApp.provide("coreLog", coreLog);
10
8
  coreLog.debug("Attached server-side logger");
9
+ return {
10
+ provide: {
11
+ log,
12
+ coreLog
13
+ }
14
+ };
11
15
  });
@@ -8,7 +8,7 @@ export const rpcCall = (nuxtApp, method, shop) => {
8
8
  payload: params
9
9
  },
10
10
  headers: {
11
- "x-shop-id": shop.shopId + ""
11
+ "x-shop-id": String(shop.shopId)
12
12
  }
13
13
  });
14
14
  return data;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@scayle/storefront-nuxt",
3
3
  "type": "module",
4
- "version": "7.40.1",
4
+ "version": "7.40.2",
5
5
  "description": "Nuxt integration for the SCAYLE Commerce Engine and Storefront API",
6
6
  "author": "SCAYLE Commerce Engine",
7
7
  "license": "MIT",
@@ -62,12 +62,12 @@
62
62
  "dependencies": {
63
63
  "@nuxt/kit": "3.8.1",
64
64
  "@scayle/h3-session": "0.3.4",
65
- "@scayle/storefront-core": "7.26.0",
65
+ "@scayle/storefront-core": "7.27.0",
66
66
  "@vueuse/core": "10.6.1",
67
67
  "consola": "3.2.3",
68
- "core-js": "3.33.2",
68
+ "core-js": "3.33.3",
69
69
  "defu": "6.1.3",
70
- "h3": "1.8.2",
70
+ "h3": "1.9.0",
71
71
  "jose": "4.15.4",
72
72
  "ofetch": "1.3.3",
73
73
  "radash": "11.0.0",
@@ -81,8 +81,8 @@
81
81
  "@nuxt/test-utils": "3.8.1",
82
82
  "@scayle/eslint-config-storefront": "3.2.5",
83
83
  "@scayle/prettier-config-storefront": "2.0.2",
84
- "@types/node": "20.9.0",
85
- "eslint": "8.53.0",
84
+ "@types/node": "20.9.4",
85
+ "eslint": "8.54.0",
86
86
  "eslint-formatter-gitlab": "5.1.0",
87
87
  "node-mocks-http": "1.13.0",
88
88
  "nuxt": "3.8.1",