@akinon/next 2.0.22-rc.0 → 2.0.22
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 +2 -23
- package/bin/pz-generate-routes.js +1 -4
- package/components/plugin-module.tsx +1 -0
- package/data/client/checkout.ts +1 -0
- package/data/server/category.ts +2 -14
- package/data/server/list.ts +1 -13
- package/data/server/product.ts +0 -10
- package/data/server/special-page.ts +1 -14
- package/data/server/widget.ts +1 -14
- package/data/urls.ts +1 -5
- package/hooks/use-captcha.tsx +1 -1
- package/lib/cache.ts +5 -25
- package/middlewares/default.ts +249 -254
- package/middlewares/masterpass-rest-callback.ts +202 -89
- package/package.json +2 -2
- package/plugins.d.ts +0 -10
- package/plugins.js +0 -1
- package/redux/middlewares/checkout.ts +3 -45
- package/redux/middlewares/pre-order/installment-option.ts +1 -9
- package/types/index.ts +9 -20
- package/utils/csrf.ts +1 -1
- package/with-pz-config.js +1 -2
- package/utils/payload-optimizer.ts +0 -481
package/CHANGELOG.md
CHANGED
|
@@ -1,31 +1,10 @@
|
|
|
1
1
|
# @akinon/next
|
|
2
2
|
|
|
3
|
-
## 2.0.22
|
|
3
|
+
## 2.0.22
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
- 324f97d5: ZERO-4219: replace masterpass-rest-complete with masterpass-rest-callback
|
|
9
|
-
- 51ea0688: ZERO-4377: Fix checkout card type state being cleared after valid bin number responses.
|
|
10
|
-
- ZERO-4160: Enhance oauth-login middleware with improved request handling and logging
|
|
11
|
-
- b55acb768: ZERO-2577: Fix pagination bug and update usePagination hook and ensure pagination controls rendering correctly
|
|
12
|
-
- 760258c1: ZERO-4160: Enhance oauth-login middleware to handle fetch errors and improve response handling
|
|
13
|
-
- 143be2b9d: ZERO-3457: Crop styles are customizable and logic improved for rendering similar products modal
|
|
14
|
-
- 7889b08f: ZERO-4276: Enhance route generation by adding .env loading and custom skip segments support
|
|
15
|
-
- 9f8cd3bc5: ZERO-3449: AI Search Active Filters & Crop Style changes have been implemented
|
|
16
|
-
- d51fa68e: ZERO-4399: add card rewards to pz-masterpass-rest
|
|
17
|
-
- bfafa3f4: ZERO-4160: Refactor oauth-login middleware to use fetchCommerce for API calls and improve cookie handling
|
|
18
|
-
- 57d7eb30: ZERO-4276: Refactor route generation logic by removing environment loading and simplifying skip segments handling
|
|
19
|
-
- d99a6a7d5: ZERO-3457_1: Fixed the settings prop and made sure everything is customizable.
|
|
20
|
-
- 9db81a71: ZERO-4365: Remove brand `@theme/*` alias imports from library packages
|
|
21
|
-
- 591e345e: ZERO-3855: Enhance credit card payment handling in checkout middlewares
|
|
22
|
-
- 4de5303c5: ZERO-2504: add cookie filter to api client request
|
|
23
|
-
- 95b139dc1: ZERO-3795: Remove duplicate entry for SavedCard in PluginComponents map
|
|
24
|
-
- 1d00f2d0: BRDG-16664: Set secure flag for CSRF token cookies in useCaptcha and default middleware
|
|
25
|
-
- 4ac7b2a1: ZERO-4219: fix masterpass-rest callback route format and double-encoded error cookie
|
|
26
|
-
- 4998a963: ZERO-4168: Add server-side payload optimization
|
|
27
|
-
- 3909d322: Edit the duplicate Plugin.SimilarProducts in the plugin-module.
|
|
28
|
-
- e18836b2: ZERO-4160: Restore scope in Sentry addon configuration in akinon.json
|
|
7
|
+
- 4ce6928: ZERO-4493: Revert URLSearchParams CacheKey normalization. The helper was shipped on the hypothesis that the PCardin product detail variant bug was caused by JSON.stringify on URLSearchParams collapsing every variant onto one cache entry, but bumping the brand to the helper version did not resolve the bug — the real root cause is elsewhere. Rolling back the change to keep the surface clean while the actual fix is investigated.
|
|
29
8
|
|
|
30
9
|
## 2.0.21
|
|
31
10
|
|
|
@@ -6,7 +6,6 @@ const findBaseDir = require('../utils/find-base-dir');
|
|
|
6
6
|
|
|
7
7
|
const generateRoutes = () => {
|
|
8
8
|
const baseDir = findBaseDir();
|
|
9
|
-
|
|
10
9
|
const srcDir = path.join(baseDir, 'src');
|
|
11
10
|
const appDir = path.join(srcDir, 'app');
|
|
12
11
|
|
|
@@ -35,10 +34,8 @@ const generateRoutes = () => {
|
|
|
35
34
|
'[segment]',
|
|
36
35
|
'[url]',
|
|
37
36
|
'[theme]',
|
|
38
|
-
'[member_type]'
|
|
39
|
-
'[clienttype]'
|
|
37
|
+
'[member_type]'
|
|
40
38
|
];
|
|
41
|
-
|
|
42
39
|
const skipCatchAllRoutes = ['[...prettyurl]', '[...not_found]'];
|
|
43
40
|
|
|
44
41
|
const walkDirectory = (dir, basePath = '') => {
|
package/data/client/checkout.ts
CHANGED
|
@@ -738,6 +738,7 @@ export const checkoutApi = api.injectEndpoints({
|
|
|
738
738
|
},
|
|
739
739
|
async onQueryStarted(arg, { dispatch, queryFulfilled }) {
|
|
740
740
|
dispatch(setPaymentStepBusy(true));
|
|
741
|
+
dispatch(setCardType(arg));
|
|
741
742
|
await queryFulfilled;
|
|
742
743
|
dispatch(setPaymentStepBusy(false));
|
|
743
744
|
}
|
package/data/server/category.ts
CHANGED
|
@@ -7,8 +7,6 @@ import { parse } from 'lossless-json';
|
|
|
7
7
|
import logger from '../../utils/log';
|
|
8
8
|
import { headers as nHeaders } from 'next/headers';
|
|
9
9
|
import { ServerVariables } from '../../utils/server-variables';
|
|
10
|
-
import { optimizeCategoryResponse } from '../../utils/payload-optimizer';
|
|
11
|
-
import settings from 'settings';
|
|
12
10
|
|
|
13
11
|
function getCategoryDataHandler(
|
|
14
12
|
pk: number,
|
|
@@ -82,7 +80,7 @@ function getCategoryDataHandler(
|
|
|
82
80
|
};
|
|
83
81
|
}
|
|
84
82
|
|
|
85
|
-
export const getCategoryData =
|
|
83
|
+
export const getCategoryData = ({
|
|
86
84
|
pk,
|
|
87
85
|
searchParams,
|
|
88
86
|
headers,
|
|
@@ -95,7 +93,7 @@ export const getCategoryData = async ({
|
|
|
95
93
|
searchParams?: SearchParams;
|
|
96
94
|
headers?: Record<string, string>;
|
|
97
95
|
}) => {
|
|
98
|
-
|
|
96
|
+
return Cache.wrap(
|
|
99
97
|
CacheKey.Category(pk, searchParams, headers),
|
|
100
98
|
locale,
|
|
101
99
|
getCategoryDataHandler(pk, locale, currency, searchParams, headers),
|
|
@@ -104,16 +102,6 @@ export const getCategoryData = async ({
|
|
|
104
102
|
compressed: true
|
|
105
103
|
}
|
|
106
104
|
);
|
|
107
|
-
|
|
108
|
-
if (settings.payloadOptimization?.enabled && result?.data) {
|
|
109
|
-
try {
|
|
110
|
-
return { ...result, data: optimizeCategoryResponse(result.data, settings.payloadOptimization) };
|
|
111
|
-
} catch (e) {
|
|
112
|
-
logger.error('Payload optimization failed for category', { pk, error: (e as Error).message });
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
return result;
|
|
117
105
|
};
|
|
118
106
|
|
|
119
107
|
function getCategoryBySlugDataHandler(
|
package/data/server/list.ts
CHANGED
|
@@ -6,8 +6,6 @@ import appFetch, { FetchResponseType } from '../../utils/app-fetch';
|
|
|
6
6
|
import { parse } from 'lossless-json';
|
|
7
7
|
import logger from '../../utils/log';
|
|
8
8
|
import { ServerVariables } from '../../utils/server-variables';
|
|
9
|
-
import { optimizeCategoryResponse } from '../../utils/payload-optimizer';
|
|
10
|
-
import settings from 'settings';
|
|
11
9
|
|
|
12
10
|
const getListDataHandler = (
|
|
13
11
|
locale,
|
|
@@ -68,7 +66,7 @@ export const getListData = async ({
|
|
|
68
66
|
searchParams: SearchParams;
|
|
69
67
|
headers?: Record<string, string>;
|
|
70
68
|
}) => {
|
|
71
|
-
|
|
69
|
+
return Cache.wrap(
|
|
72
70
|
CacheKey.List(searchParams, headers),
|
|
73
71
|
locale,
|
|
74
72
|
getListDataHandler(locale, currency, searchParams, headers),
|
|
@@ -77,14 +75,4 @@ export const getListData = async ({
|
|
|
77
75
|
compressed: true
|
|
78
76
|
}
|
|
79
77
|
);
|
|
80
|
-
|
|
81
|
-
if (settings.payloadOptimization?.enabled && result) {
|
|
82
|
-
try {
|
|
83
|
-
return optimizeCategoryResponse(result, settings.payloadOptimization);
|
|
84
|
-
} catch (e) {
|
|
85
|
-
logger.error('Payload optimization failed for list', { error: (e as Error).message });
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
return result;
|
|
90
78
|
};
|
package/data/server/product.ts
CHANGED
|
@@ -4,8 +4,6 @@ import { ProductCategoryResult, ProductResult, SearchParams } from '../../types'
|
|
|
4
4
|
import appFetch from '../../utils/app-fetch';
|
|
5
5
|
import { ServerVariables } from '../../utils/server-variables';
|
|
6
6
|
import logger from '../../utils/log';
|
|
7
|
-
import { optimizeProductResponse } from '../../utils/payload-optimizer';
|
|
8
|
-
import settings from 'settings';
|
|
9
7
|
|
|
10
8
|
type GetProduct = {
|
|
11
9
|
pk: number | string;
|
|
@@ -165,13 +163,5 @@ export const getProductData = async ({
|
|
|
165
163
|
throw error;
|
|
166
164
|
}
|
|
167
165
|
|
|
168
|
-
if (settings.payloadOptimization?.enabled && result?.data) {
|
|
169
|
-
try {
|
|
170
|
-
return { ...result, data: optimizeProductResponse(result.data, settings.payloadOptimization) };
|
|
171
|
-
} catch (e) {
|
|
172
|
-
logger.error('Payload optimization failed for product', { pk, error: (e as Error).message });
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
|
|
176
166
|
return result;
|
|
177
167
|
};
|
|
@@ -4,9 +4,6 @@ import { GetCategoryResponse, SearchParams } from '../../types';
|
|
|
4
4
|
import { generateCommerceSearchParams } from '../../utils';
|
|
5
5
|
import appFetch from '../../utils/app-fetch';
|
|
6
6
|
import { ServerVariables } from '../../utils/server-variables';
|
|
7
|
-
import { optimizeCategoryResponse } from '../../utils/payload-optimizer';
|
|
8
|
-
import logger from '../../utils/log';
|
|
9
|
-
import settings from 'settings';
|
|
10
7
|
|
|
11
8
|
const getSpecialPageDataHandler = (
|
|
12
9
|
pk: number,
|
|
@@ -48,7 +45,7 @@ export const getSpecialPageData = async ({
|
|
|
48
45
|
searchParams: SearchParams;
|
|
49
46
|
headers?: Record<string, string>;
|
|
50
47
|
}) => {
|
|
51
|
-
|
|
48
|
+
return Cache.wrap(
|
|
52
49
|
CacheKey.SpecialPage(pk, searchParams, headers),
|
|
53
50
|
locale,
|
|
54
51
|
getSpecialPageDataHandler(pk, locale, currency, searchParams, headers),
|
|
@@ -57,14 +54,4 @@ export const getSpecialPageData = async ({
|
|
|
57
54
|
compressed: true
|
|
58
55
|
}
|
|
59
56
|
);
|
|
60
|
-
|
|
61
|
-
if (settings.payloadOptimization?.enabled && result) {
|
|
62
|
-
try {
|
|
63
|
-
return optimizeCategoryResponse(result, settings.payloadOptimization);
|
|
64
|
-
} catch (e) {
|
|
65
|
-
logger.error('Payload optimization failed for special-page', { pk, error: (e as Error).message });
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
return result;
|
|
70
57
|
};
|
package/data/server/widget.ts
CHANGED
|
@@ -4,9 +4,6 @@ import { CacheOptions, WidgetResultType, WidgetSchemaType } from '../../types';
|
|
|
4
4
|
import appFetch from '../../utils/app-fetch';
|
|
5
5
|
import { widgets } from '../urls';
|
|
6
6
|
import { ServerVariables } from '../../utils/server-variables';
|
|
7
|
-
import { optimizeWidgetResponse } from '../../utils/payload-optimizer';
|
|
8
|
-
import logger from '../../utils/log';
|
|
9
|
-
import settings from 'settings';
|
|
10
7
|
|
|
11
8
|
const getWidgetDataHandler =
|
|
12
9
|
(
|
|
@@ -56,7 +53,7 @@ export const getWidgetData = async <T>({
|
|
|
56
53
|
cacheOptions?: CacheOptions;
|
|
57
54
|
headers?: Record<string, string>;
|
|
58
55
|
}): Promise<WidgetResultType<T>> => {
|
|
59
|
-
|
|
56
|
+
return Cache.wrap(
|
|
60
57
|
CacheKey.Widget(slug),
|
|
61
58
|
locale,
|
|
62
59
|
getWidgetDataHandler(slug, locale, currency, headers),
|
|
@@ -65,16 +62,6 @@ export const getWidgetData = async <T>({
|
|
|
65
62
|
...cacheOptions
|
|
66
63
|
}
|
|
67
64
|
);
|
|
68
|
-
|
|
69
|
-
if (settings.payloadOptimization?.enabled && result) {
|
|
70
|
-
try {
|
|
71
|
-
return optimizeWidgetResponse(result, settings.payloadOptimization) as WidgetResultType<T>;
|
|
72
|
-
} catch (e) {
|
|
73
|
-
logger.error('Payload optimization failed for widget', { slug, error: (e as Error).message });
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
return result as WidgetResultType<T>;
|
|
78
65
|
};
|
|
79
66
|
|
|
80
67
|
const getCollectionWidgetDataHandler =
|
package/data/urls.ts
CHANGED
|
@@ -183,11 +183,7 @@ export const product = {
|
|
|
183
183
|
breadcrumbUrl: (menuitemmodel: string) =>
|
|
184
184
|
`/menus/generate_breadcrumb/?item=${menuitemmodel}&generator_name=menu_item`,
|
|
185
185
|
bundleProduct: (productPk: string, queryString: string) =>
|
|
186
|
-
`/bundle-product/${productPk}/?${queryString}
|
|
187
|
-
similarProducts: (params?: string) =>
|
|
188
|
-
`/similar-products${params ? `?${params}` : ''}`,
|
|
189
|
-
similarProductsList: (params?: string) =>
|
|
190
|
-
`/similar-product-list${params ? `?${params}` : ''}`
|
|
186
|
+
`/bundle-product/${productPk}/?${queryString}`
|
|
191
187
|
};
|
|
192
188
|
|
|
193
189
|
export const wishlist = {
|
package/hooks/use-captcha.tsx
CHANGED
package/lib/cache.ts
CHANGED
|
@@ -77,29 +77,9 @@ const hashCacheKey = (object?: Record<string, string>) => {
|
|
|
77
77
|
|
|
78
78
|
return `_${encodeURIComponent(cacheKey)}`;
|
|
79
79
|
};
|
|
80
|
-
|
|
81
|
-
// JSON.stringify on a URLSearchParams instance always returns "{}" because its
|
|
82
|
-
// entries live on the prototype, not as own enumerable properties. withSegmentDefaults
|
|
83
|
-
// normalizes Next 16's plain searchParams object into a URLSearchParams instance for
|
|
84
|
-
// v1 brand compatibility, which means every CacheKey below that took JSON.stringify
|
|
85
|
-
// of searchParams was collapsing every variant of a route onto a single cache entry —
|
|
86
|
-
// product detail variant changes served stale data and the add-to-cart button stuck
|
|
87
|
-
// in its loading state. Convert URLSearchParams to a plain object before serializing
|
|
88
|
-
// so the resulting key reflects the actual params.
|
|
89
|
-
const stringifySearchParams = (searchParams?: SearchParams) => {
|
|
90
|
-
if (!searchParams) return JSON.stringify(searchParams);
|
|
91
|
-
if (
|
|
92
|
-
typeof URLSearchParams !== 'undefined' &&
|
|
93
|
-
searchParams instanceof URLSearchParams
|
|
94
|
-
) {
|
|
95
|
-
return JSON.stringify(Object.fromEntries(searchParams));
|
|
96
|
-
}
|
|
97
|
-
return JSON.stringify(searchParams);
|
|
98
|
-
};
|
|
99
|
-
|
|
100
80
|
export const CacheKey = {
|
|
101
81
|
List: (searchParams: SearchParams, headers?: Record<string, string>) =>
|
|
102
|
-
`list_${encodeURIComponent(
|
|
82
|
+
`list_${encodeURIComponent(JSON.stringify(searchParams))}${hashCacheKey(
|
|
103
83
|
headers
|
|
104
84
|
)}`,
|
|
105
85
|
Category: (
|
|
@@ -108,7 +88,7 @@ export const CacheKey = {
|
|
|
108
88
|
headers?: Record<string, string>
|
|
109
89
|
) =>
|
|
110
90
|
`category_${pk}_${encodeURIComponent(
|
|
111
|
-
|
|
91
|
+
JSON.stringify(searchParams)
|
|
112
92
|
)}${hashCacheKey(headers)}`,
|
|
113
93
|
Basket: (namespace?: string) => `basket${namespace ? `_${namespace}` : ''}`,
|
|
114
94
|
AllBaskets: () => 'all_baskets',
|
|
@@ -119,12 +99,12 @@ export const CacheKey = {
|
|
|
119
99
|
headers?: Record<string, string>
|
|
120
100
|
) =>
|
|
121
101
|
`special_page_${pk}_${encodeURIComponent(
|
|
122
|
-
|
|
102
|
+
JSON.stringify(searchParams)
|
|
123
103
|
)}${hashCacheKey(headers)}`,
|
|
124
104
|
Product: (pk: number, searchParams: SearchParams) =>
|
|
125
|
-
`product_${pk}_${encodeURIComponent(
|
|
105
|
+
`product_${pk}_${encodeURIComponent(JSON.stringify(searchParams))}`,
|
|
126
106
|
GroupProduct: (pk: number, searchParams: SearchParams) =>
|
|
127
|
-
`group_product_${pk}_${encodeURIComponent(
|
|
107
|
+
`group_product_${pk}_${encodeURIComponent(JSON.stringify(searchParams))}`,
|
|
128
108
|
FlatPage: (pk: number) => `flat_page_${pk}`,
|
|
129
109
|
LandingPage: (pk: number) => `landing_page_${pk}`,
|
|
130
110
|
Widget: (slug: string) => `widget_${slug}`,
|