@akinon/next 1.23.0-rc.6 → 1.23.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,67 +1,10 @@
1
1
  # @akinon/next
2
2
 
3
- ## 1.23.0-rc.6
3
+ ## 1.23.0
4
4
 
5
5
  ### Minor Changes
6
6
 
7
- - 8bc6085: ZERO-2472: RTK Query Invalidate
8
- - 02a3c58: ZERO-2460: Breadcrumb checks for undefined values
9
7
  - 82fd759: ZERO-2467: Update global and plugins declarations
10
- - 0181251: ZERO-2440: move otp popup state to redux
11
- - 07cc81a: Add infinite and more types to pagination
12
- - 8d6caba: ZERO-2434: enhance error handling and logging in appFetch function
13
- - b4452e9: ZERO-2463: Refactor Sentry initialization and add Sentry DSN option to settings
14
- - b2da5e4: Revert ZERO-2435
15
-
16
- ### Patch Changes
17
-
18
- - da1e501: ZERO-2296: Fix ROUTES import
19
- - 2e44646: ZERO-2434: Fix category URL in getCategoryDataHandler function
20
- - 2e9476c: ZERO-2434: remove error throwing in appFetch
21
-
22
- ## 1.23.0-rc.5
23
-
24
- ### Minor Changes
25
-
26
- - 02a3c58: ZERO-2460: Breadcrumb checks for undefined values
27
-
28
- ## 1.23.0-rc.4
29
-
30
- ### Minor Changes
31
-
32
- - 8bc6085: ZERO-2472: RTK Query Invalidate
33
-
34
- ### Patch Changes
35
-
36
- - 2e9476c: ZERO-2434: remove error throwing in appFetch
37
-
38
- ## 1.23.0-rc.3
39
-
40
- ### Minor Changes
41
-
42
- - 82fd759: ZERO-2467: Update global and plugins declarations
43
-
44
- ## 1.23.0-rc.2
45
-
46
- ## 1.23.0-rc.1
47
-
48
- ### Patch Changes
49
-
50
- - 2e44646: ZERO-2434: Fix category URL in getCategoryDataHandler function
51
-
52
- ## 1.23.0-rc.0
53
-
54
- ### Minor Changes
55
-
56
- - 0181251: ZERO-2440: move otp popup state to redux
57
- - 07cc81a: Add infinite and more types to pagination
58
- - 8d6caba: ZERO-2434: enhance error handling and logging in appFetch function
59
- - b4452e9: ZERO-2463: Refactor Sentry initialization and add Sentry DSN option to settings
60
- - b2da5e4: Revert ZERO-2435
61
-
62
- ### Patch Changes
63
-
64
- - da1e501: ZERO-2296: Fix ROUTES import
65
8
 
66
9
  ## 1.22.0
67
10
 
package/api/auth.ts CHANGED
@@ -220,17 +220,6 @@ const nextAuthOptions = (req: NextApiRequest, res: NextApiResponse) => {
220
220
  pages: {
221
221
  signIn: ROUTES.AUTH,
222
222
  error: ROUTES.AUTH
223
- },
224
- cookies: {
225
- sessionToken: {
226
- name: `__Secure-next-auth.session-token`,
227
- options: {
228
- httpOnly: true,
229
- sameSite: 'none',
230
- path: '/',
231
- secure: true
232
- }
233
- }
234
223
  }
235
224
  };
236
225
  };
@@ -32,12 +32,10 @@ const addressApi = api.injectEndpoints({
32
32
  query: () => buildClientRequestUrl(address.getRetailStore)
33
33
  }),
34
34
  getRetailStoreCities: builder.query<GetResponse<any>, string>({
35
- query: (country) =>
36
- buildClientRequestUrl(address.getRetailStoreCities(country))
35
+ query: (country) => buildClientRequestUrl(address.getRetailStoreCities(country))
37
36
  }),
38
37
  getRetailStoreTownships: builder.query<GetResponse<any>, string>({
39
- query: (city) =>
40
- buildClientRequestUrl(address.getRetailStoreTownships(city))
38
+ query: (city) => buildClientRequestUrl(address.getRetailStoreTownships(city))
41
39
  }),
42
40
  addAddress: builder.mutation<Address, Partial<Address>>({
43
41
  query: (body) => ({
@@ -50,7 +48,7 @@ const addressApi = api.injectEndpoints({
50
48
  type: body.is_corporate === 'true' ? 'corporate' : 'personal'
51
49
  }
52
50
  }),
53
- invalidatesTags: (_, error) => (error ? [] : ['Addresses', 'Checkout'])
51
+ invalidatesTags: ['Addresses', 'Checkout'] // TODO: Invalidate one of these tags when necessary (e.g. Address page invalidates Addresses tag, Checkout page invalidates Checkout tag)
54
52
  }),
55
53
  editAddress: builder.mutation<Address, Partial<Address>>({
56
54
  query: ({ pk, ...body }) => ({
@@ -64,14 +62,14 @@ const addressApi = api.injectEndpoints({
64
62
  type: body.is_corporate === 'true' ? 'corporate' : 'personal'
65
63
  }
66
64
  }),
67
- invalidatesTags: (_, error) => (error ? [] : ['Addresses', 'Checkout']) // TODO: Invalidate one of these tags when necessary (e.g. Address page invalidates Addresses tag, Checkout page invalidates Checkout tag)
65
+ invalidatesTags: ['Addresses', 'Checkout'] // TODO: Invalidate one of these tags when necessary (e.g. Address page invalidates Addresses tag, Checkout page invalidates Checkout tag)
68
66
  }),
69
67
  removeAddress: builder.mutation<void, number>({
70
68
  query: (id) => ({
71
69
  url: buildClientRequestUrl(address.removeAddress(id)),
72
70
  method: 'DELETE'
73
71
  }),
74
- invalidatesTags: (_, error) => (error ? [] : ['Addresses', 'Checkout']) // TODO: Invalidate one of these tags when necessary (e.g. Address page invalidates Addresses tag, Checkout page invalidates Checkout tag)
72
+ invalidatesTags: ['Addresses', 'Checkout'] // TODO: Invalidate one of these tags when necessary (e.g. Address page invalidates Addresses tag, Checkout page invalidates Checkout tag)
75
73
  }),
76
74
  setDefaultAddress: builder.mutation<Address, Partial<Address>>({
77
75
  query: ({ pk, primary }) => ({
@@ -81,7 +79,7 @@ const addressApi = api.injectEndpoints({
81
79
  method: 'PATCH',
82
80
  body: { primary }
83
81
  }),
84
- invalidatesTags: (_, error) => (error ? [] : ['Addresses'])
82
+ invalidatesTags: ['Addresses']
85
83
  }),
86
84
  getStores: builder.query<GetResponse<Address>, void>({
87
85
  query: () => ({
@@ -20,8 +20,6 @@ interface GetStockParams {
20
20
  }
21
21
 
22
22
  interface GetFavoritesResponse {
23
- next?: string | null;
24
- previous?: string | null;
25
23
  count: number;
26
24
  results: FavoriteItem[];
27
25
  }
@@ -73,14 +71,14 @@ export const wishlistApi = api.injectEndpoints({
73
71
  product: productPk
74
72
  }
75
73
  }),
76
- invalidatesTags: (_, error) => (error ? [] : ['Favorite'])
74
+ invalidatesTags: ['Favorite']
77
75
  }),
78
76
  removeFavorite: build.mutation<RemoteFavoriteResponse, number>({
79
77
  query: (favPk: number) => ({
80
78
  url: buildClientRequestUrl(wishlist.removeFavorite(favPk)),
81
79
  method: 'DELETE'
82
80
  }),
83
- invalidatesTags: (_, error) => (error ? [] : ['Favorite'])
81
+ invalidatesTags: ['Favorite']
84
82
  }),
85
83
  addStockAlert: build.mutation<AddStockAlertResponse, AddStockAlertRequest>({
86
84
  query: ({ productPk, email }) => ({
@@ -39,7 +39,7 @@ function getCategoryDataHandler(
39
39
  numberValueParser
40
40
  ) as GetCategoryResponse;
41
41
  } catch (error) {
42
- logger.fatal('Error while parsing category data', {
42
+ logger.error('Error while parsing category data', {
43
43
  handler: 'getCategoryDataHandler',
44
44
  error,
45
45
  rawData: rawData.startsWith('<!DOCTYPE html>')
@@ -50,14 +50,6 @@ function getCategoryDataHandler(
50
50
 
51
51
  const menuItemModel = data?.category?.menuitemmodel;
52
52
 
53
- if (!menuItemModel) {
54
- logger.warn('menuItemModel is undefined, skipping breadcrumbData fetch', {
55
- handler: 'getCategoryDataHandler',
56
- pk
57
- });
58
- return { data, breadcrumbData: undefined };
59
- }
60
-
61
53
  const breadcrumbData = await appFetch<any>(
62
54
  product.breadcrumbUrl(menuItemModel),
63
55
  {
@@ -116,7 +108,7 @@ function getCategoryBySlugDataHandler(slug: string) {
116
108
  numberValueParser
117
109
  ) as GetCategoryResponse;
118
110
  } catch (error) {
119
- logger.fatal('Error while parsing category data', {
111
+ logger.error('Error while parsing category data', {
120
112
  handler: 'getCategoryBySlugDataHandler',
121
113
  error,
122
114
  rawData: rawData.startsWith('<!DOCTYPE html>')
@@ -38,7 +38,7 @@ const getListDataHandler = (
38
38
  numberValueParser
39
39
  ) as GetCategoryResponse;
40
40
  } catch (error) {
41
- logger.fatal('Error while parsing list data', {
41
+ logger.error('Error while parsing list data', {
42
42
  error,
43
43
  rawData: rawData.startsWith('<!DOCTYPE html>')
44
44
  ? `${rawData.substring(0, 50)}...`
@@ -70,6 +70,10 @@ export default function usePagination(
70
70
  dispatch({ type: 'setLimit', payload: limit });
71
71
  }, [limit]);
72
72
 
73
+ useEffect(() => {
74
+ window.scrollTo(0, 0);
75
+ }, [state.page, state.limit]);
76
+
73
77
  const setTotal = useCallback(
74
78
  (total: number) => {
75
79
  dispatch({ type: 'setTotal', payload: total });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@akinon/next",
3
3
  "description": "Core package for Project Zero Next",
4
- "version": "1.23.0-rc.6",
4
+ "version": "1.23.0",
5
5
  "private": false,
6
6
  "license": "MIT",
7
7
  "bin": {
@@ -32,7 +32,7 @@
32
32
  "@typescript-eslint/eslint-plugin": "6.7.4",
33
33
  "@typescript-eslint/parser": "6.7.4",
34
34
  "eslint": "^8.14.0",
35
- "@akinon/eslint-plugin-projectzero": "1.23.0-rc.6",
35
+ "@akinon/eslint-plugin-projectzero": "1.23.0",
36
36
  "eslint-config-prettier": "8.5.0"
37
37
  }
38
38
  }
package/plugins.d.ts CHANGED
@@ -13,7 +13,3 @@ declare module '@akinon/pz-masterpass/src/redux/reducer' {
13
13
  export const setError: any;
14
14
  export const setOtpModalVisible: any;
15
15
  }
16
-
17
- declare module '@akinon/pz-otp' {
18
- export const otpReducer: unknown;
19
- }
@@ -6,7 +6,6 @@ import { api } from '../../data/client/api';
6
6
 
7
7
  // Plugin reducers
8
8
  import { masterpassReducer } from '@akinon/pz-masterpass';
9
- import { otpReducer } from '@akinon/pz-otp';
10
9
 
11
10
  const reducers = {
12
11
  [api.reducerPath]: api.reducer,
@@ -14,8 +13,7 @@ const reducers = {
14
13
  checkout: checkoutReducer,
15
14
  config: configReducer,
16
15
  header: headerReducer,
17
- masterpass: masterpassReducer,
18
- otp: otpReducer
16
+ masterpass: masterpassReducer
19
17
  };
20
18
 
21
19
  export default reducers;
package/sentry/index.ts CHANGED
@@ -1,33 +1,27 @@
1
1
  import * as Sentry from '@sentry/nextjs';
2
- import settings from 'settings';
3
2
 
4
3
  const SENTRY_DSN: string =
5
- settings.sentryDsn ||
6
- process.env.SENTRY_DSN ||
7
- process.env.NEXT_PUBLIC_SENTRY_DSN;
4
+ process.env.SENTRY_DSN || process.env.NEXT_PUBLIC_SENTRY_DSN;
8
5
 
9
6
  export const initSentry = (
10
7
  type: 'Server' | 'Client' | 'Edge',
11
- options: Sentry.BrowserOptions | Sentry.NodeOptions | Sentry.EdgeOptions = {
12
- dsn: SENTRY_DSN,
13
- integrations: [],
14
- tracesSampleRate: 1.0
15
- }
8
+ options: Sentry.BrowserOptions | Sentry.NodeOptions | Sentry.EdgeOptions = {}
16
9
  ) => {
17
- const initOptions = {
18
- ...options,
10
+ // TODO: Handle options with ESLint rules
11
+
12
+ // TODO: Remove Zero Project DSN
13
+
14
+ Sentry.init({
15
+ dsn:
16
+ SENTRY_DSN ||
17
+ 'https://d8558ef8997543deacf376c7d8d7cf4b@o64293.ingest.sentry.io/4504338423742464',
19
18
  initialScope: {
20
19
  tags: {
21
- ...((
22
- options.initialScope as {
23
- tags?: Record<string, string>;
24
- }
25
- )?.tags ?? {}),
26
20
  APP_TYPE: 'ProjectZeroNext',
27
21
  TYPE: type
28
22
  }
29
- }
30
- };
31
-
32
- Sentry.init(initOptions);
23
+ },
24
+ tracesSampleRate: 1.0,
25
+ integrations: []
26
+ });
33
27
  };
package/types/index.ts CHANGED
@@ -71,12 +71,6 @@ export interface Currency {
71
71
 
72
72
  export interface Settings {
73
73
  commerceUrl: string;
74
- /**
75
- * This option allows you to track Sentry events on the client side, in addition to server and edge environments.
76
- *
77
- * It overrides process.env.NEXT_PUBLIC_SENTRY_DSN and process.env.SENTRY_DSN.
78
- */
79
- sentryDsn?: string;
80
74
  redis: {
81
75
  defaultExpirationTime: number;
82
76
  };
@@ -12,7 +12,7 @@ const appFetch = async <T>(
12
12
  url: RequestInfo,
13
13
  init: RequestInit = {},
14
14
  responseType = FetchResponseType.JSON
15
- ): Promise<T> => {
15
+ ) => {
16
16
  let response: T;
17
17
  let status: number;
18
18
  let ip = '';
@@ -48,18 +48,18 @@ const appFetch = async <T>(
48
48
  status = req.status;
49
49
  logger.debug(`FETCH END ${url}`, { status: req.status, ip });
50
50
 
51
+ const rawData = await req.text();
52
+
51
53
  if (responseType === FetchResponseType.JSON) {
52
- response = (await req.json()) as T;
54
+ response = JSON.parse(rawData);
53
55
  } else {
54
- response = (await req.text()) as unknown as T;
56
+ response = rawData as unknown as T;
55
57
  }
56
58
 
57
59
  logger.trace(`FETCH RESPONSE`, { url, response, ip });
58
60
  } catch (error) {
59
- const logType = status === 500 ? 'fatal' : 'error';
60
-
61
61
  if (!url.toString().includes('/cms/seo/')) {
62
- logger[logType](`FETCH FAILED`, { url, status, error, ip });
62
+ logger.error(`FETCH FAILED`, { url, status, error, ip });
63
63
  }
64
64
  }
65
65