@vtex/faststore-plugin-buyer-portal 1.1.106 → 1.1.107

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vtex/faststore-plugin-buyer-portal",
3
- "version": "1.1.106",
3
+ "version": "1.1.107",
4
4
  "description": "A plugin for faststore with buyer portal",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -2,7 +2,7 @@
2
2
 
3
3
  import React from "react";
4
4
 
5
- import { ErrorBoundary } from "../ErrorBoundary/ErrorBoundary";
5
+ // import { ErrorBoundary } from "../ErrorBoundary/ErrorBoundary";
6
6
 
7
7
  type WithErrorBoundaryOptions = {
8
8
  fallback?: React.ReactNode;
@@ -15,15 +15,16 @@ type WithErrorBoundaryOptions = {
15
15
 
16
16
  export function withErrorBoundary<P extends Record<string, unknown>>(
17
17
  WrappedComponent: React.ComponentType<P>,
18
- options: WithErrorBoundaryOptions = {}
18
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
19
+ _options: WithErrorBoundaryOptions = {}
19
20
  ) {
20
- const { onError, tags } = options;
21
+ // const { onError, tags } = options;
21
22
 
22
23
  const ComponentWithErrorBoundary = (props: P) => {
23
24
  return (
24
- <ErrorBoundary onError={onError} tags={tags}>
25
- <WrappedComponent {...props} />
26
- </ErrorBoundary>
25
+ // <ErrorBoundary onError={onError} tags={tags}>
26
+ <WrappedComponent {...props} />
27
+ // </ErrorBoundary>
27
28
  );
28
29
  };
29
30
 
@@ -1,4 +1,4 @@
1
- import { getClientContext } from "./getClientContext";
1
+ // import { getClientContext } from "./getClientContext";
2
2
  import { serializeLoaderData } from "./serializeLoaderData";
3
3
 
4
4
  import type { LoaderData } from "../types";
@@ -11,77 +11,85 @@ interface WithLoaderErrorBoundaryOptions {
11
11
 
12
12
  export function withLoaderErrorBoundary<TQuery, TReturn>(
13
13
  loaderFn: (data: LoaderData<TQuery>) => Promise<TReturn>,
14
- options: WithLoaderErrorBoundaryOptions = {}
14
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
15
+ _options: WithLoaderErrorBoundaryOptions = {}
15
16
  ) {
16
- const { componentName, onError, redirectToError = true } = options;
17
-
17
+ // Bypass: Just call the loader function and serialize the result
18
18
  return async (data: LoaderData<TQuery>): Promise<TReturn> => {
19
- try {
20
- const result = await loaderFn(data);
21
- return serializeLoaderData(result);
22
- } catch (error) {
23
- console.error(`[${componentName || "Loader"}] Error:`, {
24
- message: (error as Error).message,
25
- query: data.query,
26
- });
27
-
28
- if (onError) {
29
- onError(error as Error, data.query);
30
- }
31
-
32
- if (redirectToError) {
33
- let clientContext;
34
- try {
35
- clientContext = await getClientContext(data);
36
- } catch (contextError) {
37
- console.error(
38
- `[${componentName || "Loader"}] Failed to get client context:`,
39
- contextError
40
- );
41
- clientContext = {
42
- cookie: "",
43
- customerId: "",
44
- userId: "",
45
- vtexIdclientAutCookie: "",
46
- };
47
- }
48
-
49
- // Serialize query to ensure it's JSON-safe (use null instead of undefined)
50
- const serializedQuery = data.query
51
- ? JSON.parse(JSON.stringify(data.query))
52
- : null;
53
-
54
- const errorResponse = {
55
- error: {
56
- error: {
57
- message: (error as Error).message,
58
- name: (error as Error).name,
59
- stack: (error as Error).stack || null,
60
- query: serializedQuery,
61
- },
62
- tags: {
63
- component: componentName || "Unknown",
64
- errorType: "loader_error",
65
- },
66
- extra: {
67
- query: serializedQuery,
68
- },
69
- },
70
- hasError: true,
71
- context: {
72
- clientContext,
73
- currentOrgUnit: null,
74
- currentContract: null,
75
- currentUser: null,
76
- },
77
- data: null,
78
- };
79
-
80
- // Ensure error response is also JSON-serializable
81
- return serializeLoaderData(errorResponse) as TReturn;
82
- }
83
-
84
- throw error;
85
- }
19
+ const result = await loaderFn(data);
20
+ return serializeLoaderData(result);
86
21
  };
22
+
23
+ // Old error handling code - commented out for bypass
24
+ // const { componentName, onError, redirectToError = true } = options;
25
+ //
26
+ // return async (data: LoaderData<TQuery>): Promise<TReturn> => {
27
+ // try {
28
+ // const result = await loaderFn(data);
29
+ // return serializeLoaderData(result);
30
+ // } catch (error) {
31
+ // console.error(`[${componentName || "Loader"}] Error:`, {
32
+ // message: (error as Error).message,
33
+ // query: data.query,
34
+ // });
35
+ //
36
+ // if (onError) {
37
+ // onError(error as Error, data.query);
38
+ // }
39
+ //
40
+ // if (redirectToError) {
41
+ // let clientContext;
42
+ // try {
43
+ // clientContext = await getClientContext(data);
44
+ // } catch (contextError) {
45
+ // console.error(
46
+ // `[${componentName || "Loader"}] Failed to get client context:`,
47
+ // contextError
48
+ // );
49
+ // clientContext = {
50
+ // cookie: "",
51
+ // customerId: "",
52
+ // userId: "",
53
+ // vtexIdclientAutCookie: "",
54
+ // };
55
+ // }
56
+ //
57
+ // // Serialize query to ensure it's JSON-safe (use null instead of undefined)
58
+ // const serializedQuery = data.query
59
+ // ? JSON.parse(JSON.stringify(data.query))
60
+ // : null;
61
+ //
62
+ // const errorResponse = {
63
+ // error: {
64
+ // error: {
65
+ // message: (error as Error).message,
66
+ // name: (error as Error).name,
67
+ // stack: (error as Error).stack || null,
68
+ // query: serializedQuery,
69
+ // },
70
+ // tags: {
71
+ // component: componentName || "Unknown",
72
+ // errorType: "loader_error",
73
+ // },
74
+ // extra: {
75
+ // query: serializedQuery,
76
+ // },
77
+ // },
78
+ // hasError: true,
79
+ // context: {
80
+ // clientContext,
81
+ // currentOrgUnit: null,
82
+ // currentContract: null,
83
+ // currentUser: null,
84
+ // },
85
+ // data: null,
86
+ // };
87
+ //
88
+ // // Ensure error response is also JSON-serializable
89
+ // return serializeLoaderData(errorResponse) as TReturn;
90
+ // }
91
+ //
92
+ // throw error;
93
+ // }
94
+ // };
87
95
  }