@akinon/next 1.23.0-rc.2 → 1.23.0-rc.4

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,21 @@
1
1
  # @akinon/next
2
2
 
3
+ ## 1.23.0-rc.4
4
+
5
+ ### Minor Changes
6
+
7
+ - 8bc6085: ZERO-2472: RTK Query Invalidate
8
+
9
+ ### Patch Changes
10
+
11
+ - 2e9476c: ZERO-2434: remove error throwing in appFetch
12
+
13
+ ## 1.23.0-rc.3
14
+
15
+ ### Minor Changes
16
+
17
+ - 82fd759: ZERO-2467: Update global and plugins declarations
18
+
3
19
  ## 1.23.0-rc.2
4
20
 
5
21
  ## 1.23.0-rc.1
@@ -32,10 +32,12 @@ const addressApi = api.injectEndpoints({
32
32
  query: () => buildClientRequestUrl(address.getRetailStore)
33
33
  }),
34
34
  getRetailStoreCities: builder.query<GetResponse<any>, string>({
35
- query: (country) => buildClientRequestUrl(address.getRetailStoreCities(country))
35
+ query: (country) =>
36
+ buildClientRequestUrl(address.getRetailStoreCities(country))
36
37
  }),
37
38
  getRetailStoreTownships: builder.query<GetResponse<any>, string>({
38
- query: (city) => buildClientRequestUrl(address.getRetailStoreTownships(city))
39
+ query: (city) =>
40
+ buildClientRequestUrl(address.getRetailStoreTownships(city))
39
41
  }),
40
42
  addAddress: builder.mutation<Address, Partial<Address>>({
41
43
  query: (body) => ({
@@ -48,7 +50,7 @@ const addressApi = api.injectEndpoints({
48
50
  type: body.is_corporate === 'true' ? 'corporate' : 'personal'
49
51
  }
50
52
  }),
51
- invalidatesTags: ['Addresses', 'Checkout'] // TODO: Invalidate one of these tags when necessary (e.g. Address page invalidates Addresses tag, Checkout page invalidates Checkout tag)
53
+ invalidatesTags: (_, error) => (error ? [] : ['Addresses', 'Checkout'])
52
54
  }),
53
55
  editAddress: builder.mutation<Address, Partial<Address>>({
54
56
  query: ({ pk, ...body }) => ({
@@ -62,14 +64,14 @@ const addressApi = api.injectEndpoints({
62
64
  type: body.is_corporate === 'true' ? 'corporate' : 'personal'
63
65
  }
64
66
  }),
65
- invalidatesTags: ['Addresses', 'Checkout'] // TODO: Invalidate one of these tags when necessary (e.g. Address page invalidates Addresses tag, Checkout page invalidates Checkout tag)
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)
66
68
  }),
67
69
  removeAddress: builder.mutation<void, number>({
68
70
  query: (id) => ({
69
71
  url: buildClientRequestUrl(address.removeAddress(id)),
70
72
  method: 'DELETE'
71
73
  }),
72
- invalidatesTags: ['Addresses', 'Checkout'] // TODO: Invalidate one of these tags when necessary (e.g. Address page invalidates Addresses tag, Checkout page invalidates Checkout tag)
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)
73
75
  }),
74
76
  setDefaultAddress: builder.mutation<Address, Partial<Address>>({
75
77
  query: ({ pk, primary }) => ({
@@ -79,7 +81,7 @@ const addressApi = api.injectEndpoints({
79
81
  method: 'PATCH',
80
82
  body: { primary }
81
83
  }),
82
- invalidatesTags: ['Addresses']
84
+ invalidatesTags: (_, error) => (error ? [] : ['Addresses'])
83
85
  }),
84
86
  getStores: builder.query<GetResponse<Address>, void>({
85
87
  query: () => ({
@@ -73,14 +73,14 @@ export const wishlistApi = api.injectEndpoints({
73
73
  product: productPk
74
74
  }
75
75
  }),
76
- invalidatesTags: ['Favorite']
76
+ invalidatesTags: (_, error) => (error ? [] : ['Favorite'])
77
77
  }),
78
78
  removeFavorite: build.mutation<RemoteFavoriteResponse, number>({
79
79
  query: (favPk: number) => ({
80
80
  url: buildClientRequestUrl(wishlist.removeFavorite(favPk)),
81
81
  method: 'DELETE'
82
82
  }),
83
- invalidatesTags: ['Favorite']
83
+ invalidatesTags: (_, error) => (error ? [] : ['Favorite'])
84
84
  }),
85
85
  addStockAlert: build.mutation<AddStockAlertResponse, AddStockAlertRequest>({
86
86
  query: ({ productPk, email }) => ({
package/global.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ /* eslint-disable no-var */
2
+
3
+ declare global {
4
+ var $: any;
5
+
6
+ interface Window {
7
+ MFS?: any;
8
+ }
9
+ }
10
+
11
+ export {};
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.2",
4
+ "version": "1.23.0-rc.4",
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.2",
35
+ "@akinon/eslint-plugin-projectzero": "1.23.0-rc.4",
36
36
  "eslint-config-prettier": "8.5.0"
37
37
  }
38
38
  }
package/plugins.d.ts CHANGED
@@ -1,5 +1,17 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+
1
3
  declare module '@akinon/pz-masterpass' {
2
- export const masterpassReducer: unknown;
4
+ export const masterpassReducer: any;
5
+ }
6
+
7
+ declare module '@akinon/pz-masterpass/src/utils' {
8
+ export const buildDirectPurchaseForm: any;
9
+ export const buildPurchaseForm: any;
10
+ }
11
+
12
+ declare module '@akinon/pz-masterpass/src/redux/reducer' {
13
+ export const setError: any;
14
+ export const setOtpModalVisible: any;
3
15
  }
4
16
 
5
17
  declare module '@akinon/pz-otp' {
@@ -28,7 +28,7 @@ const appFetch = async <T>(
28
28
 
29
29
  if (commerceUrl === 'default') {
30
30
  logger.error('Commerce URL is not set. Current value is "default"');
31
- throw new Error('Commerce URL is not set');
31
+ return undefined;
32
32
  }
33
33
 
34
34
  const requestURL = `${decodeURIComponent(commerceUrl)}${url}`;
@@ -48,10 +48,6 @@ const appFetch = async <T>(
48
48
  status = req.status;
49
49
  logger.debug(`FETCH END ${url}`, { status: req.status, ip });
50
50
 
51
- if (!req.ok) {
52
- throw new Error(`Request failed with status ${status}`);
53
- }
54
-
55
51
  if (responseType === FetchResponseType.JSON) {
56
52
  response = (await req.json()) as T;
57
53
  } else {
@@ -65,13 +61,6 @@ const appFetch = async <T>(
65
61
  if (!url.toString().includes('/cms/seo/')) {
66
62
  logger[logType](`FETCH FAILED`, { url, status, error, ip });
67
63
  }
68
-
69
- // throw the error if it's fatal, so it can be caught and handled at higher levels
70
- if (logType === 'fatal') {
71
- throw error;
72
- }
73
-
74
- return Promise.reject(error);
75
64
  }
76
65
 
77
66
  return response;