@akinon/next 1.96.0-rc.57 → 1.96.0-snapshot-ZERO-35861-20250908151109
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 +41 -1246
- package/__tests__/next-config.test.ts +10 -1
- package/api/cache.ts +39 -5
- package/components/accordion.tsx +5 -20
- package/components/file-input.tsx +3 -65
- package/components/input.tsx +0 -2
- package/components/link.tsx +12 -16
- package/components/modal.tsx +16 -32
- package/components/plugin-module.tsx +3 -30
- package/data/client/checkout.ts +4 -5
- package/data/server/category.ts +32 -50
- package/data/server/flatpage.ts +16 -17
- package/data/server/form.ts +4 -1
- package/data/server/landingpage.ts +12 -16
- package/data/server/list.ts +15 -24
- package/data/server/menu.ts +5 -2
- package/data/server/product.ts +41 -67
- package/data/server/special-page.ts +12 -16
- package/data/server/widget.ts +4 -1
- package/data/urls.ts +1 -5
- package/hocs/server/with-segment-defaults.tsx +2 -5
- package/hooks/use-localization.ts +3 -2
- package/jest.config.js +1 -7
- package/lib/cache-handler.mjs +365 -87
- package/lib/cache.ts +252 -25
- package/middlewares/complete-gpay.ts +1 -2
- package/middlewares/complete-masterpass.ts +1 -2
- package/middlewares/default.ts +13 -50
- package/middlewares/locale.ts +1 -9
- package/middlewares/pretty-url.ts +2 -1
- package/middlewares/redirection-payment.ts +1 -2
- package/middlewares/saved-card-redirection.ts +1 -2
- package/middlewares/three-d-redirection.ts +1 -2
- package/middlewares/url-redirection.ts +14 -8
- package/package.json +4 -3
- package/plugins.d.ts +0 -8
- package/plugins.js +1 -3
- package/redux/middlewares/checkout.ts +1 -5
- package/types/commerce/order.ts +0 -1
- package/types/index.ts +2 -34
- package/utils/app-fetch.ts +2 -7
- package/utils/redirect.ts +6 -31
- package/with-pz-config.js +5 -1
- package/__tests__/redirect.test.ts +0 -319
- package/api/image-proxy.ts +0 -75
- package/api/similar-product-list.ts +0 -84
- package/api/similar-products.ts +0 -120
- package/data/server/basket.ts +0 -72
- package/utils/redirect-ignore.ts +0 -35
package/data/server/list.ts
CHANGED
|
@@ -16,29 +16,19 @@ const getListDataHandler = (
|
|
|
16
16
|
return async function () {
|
|
17
17
|
const params = generateCommerceSearchParams(searchParams);
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
headers
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
},
|
|
33
|
-
responseType: FetchResponseType.TEXT
|
|
34
|
-
});
|
|
35
|
-
} catch (error) {
|
|
36
|
-
logger.error('Failed to fetch list data', {
|
|
37
|
-
handler: 'getListDataHandler',
|
|
38
|
-
error: error.message
|
|
39
|
-
});
|
|
40
|
-
return null;
|
|
41
|
-
}
|
|
19
|
+
const rawData = await appFetch<string>({
|
|
20
|
+
url: `${category.list}${params}`,
|
|
21
|
+
locale,
|
|
22
|
+
currency,
|
|
23
|
+
init: {
|
|
24
|
+
headers: {
|
|
25
|
+
Accept: 'application/json',
|
|
26
|
+
'Content-Type': 'application/json',
|
|
27
|
+
...(headers ?? {})
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
responseType: FetchResponseType.TEXT
|
|
31
|
+
});
|
|
42
32
|
|
|
43
33
|
let data: GetCategoryResponse;
|
|
44
34
|
|
|
@@ -81,7 +71,8 @@ export const getListData = async ({
|
|
|
81
71
|
locale,
|
|
82
72
|
getListDataHandler(locale, currency, searchParams, headers),
|
|
83
73
|
{
|
|
84
|
-
expire: 300
|
|
74
|
+
expire: 300,
|
|
75
|
+
compressed: true
|
|
85
76
|
}
|
|
86
77
|
);
|
|
87
78
|
};
|
package/data/server/menu.ts
CHANGED
|
@@ -48,6 +48,9 @@ export const getMenu = async (params?: MenuHandlerParams) => {
|
|
|
48
48
|
return Cache.wrap(
|
|
49
49
|
CacheKey.Menu(params?.depth ?? DEFAULT_DEPTH, params?.parent),
|
|
50
50
|
params?.locale ?? ServerVariables.locale,
|
|
51
|
-
getMenuHandler(params)
|
|
52
|
-
|
|
51
|
+
getMenuHandler(params),
|
|
52
|
+
{
|
|
53
|
+
compressed: true
|
|
54
|
+
}
|
|
55
|
+
);
|
|
53
56
|
};
|
package/data/server/product.ts
CHANGED
|
@@ -35,84 +35,57 @@ const getProductDataHandler = ({
|
|
|
35
35
|
.join('&');
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
headers
|
|
47
|
-
Accept: 'application/json',
|
|
48
|
-
'Content-Type': 'application/json',
|
|
49
|
-
...(headers ?? {})
|
|
50
|
-
}
|
|
38
|
+
const data = await appFetch<ProductResult>({
|
|
39
|
+
url,
|
|
40
|
+
locale,
|
|
41
|
+
currency,
|
|
42
|
+
init: {
|
|
43
|
+
headers: {
|
|
44
|
+
Accept: 'application/json',
|
|
45
|
+
'Content-Type': 'application/json',
|
|
46
|
+
...(headers ?? {})
|
|
51
47
|
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
logger.error('Failed to fetch product data', {
|
|
55
|
-
handler: 'getProductDataHandler',
|
|
56
|
-
pk,
|
|
57
|
-
error: error.message,
|
|
58
|
-
url
|
|
59
|
-
});
|
|
60
|
-
return null;
|
|
61
|
-
}
|
|
48
|
+
}
|
|
49
|
+
});
|
|
62
50
|
|
|
63
51
|
const categoryUrl = product.categoryUrl(data.product.pk);
|
|
64
52
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
init: {
|
|
74
|
-
headers: {
|
|
75
|
-
Accept: 'application/json',
|
|
76
|
-
'Content-Type': 'application/json'
|
|
77
|
-
}
|
|
53
|
+
const productCategoryData = await appFetch<ProductCategoryResult>({
|
|
54
|
+
url: categoryUrl,
|
|
55
|
+
locale,
|
|
56
|
+
currency,
|
|
57
|
+
init: {
|
|
58
|
+
headers: {
|
|
59
|
+
Accept: 'application/json',
|
|
60
|
+
'Content-Type': 'application/json'
|
|
78
61
|
}
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
const menuItemModel = productCategoryData?.results[0]?.menuitemmodel;
|
|
82
|
-
|
|
83
|
-
if (!menuItemModel) {
|
|
84
|
-
logger.warn(
|
|
85
|
-
'menuItemModel is undefined, skipping breadcrumbData fetch',
|
|
86
|
-
{
|
|
87
|
-
handler: 'getProductDataHandler',
|
|
88
|
-
pk
|
|
89
|
-
}
|
|
90
|
-
);
|
|
91
|
-
return { data, breadcrumbData: undefined };
|
|
92
62
|
}
|
|
63
|
+
});
|
|
93
64
|
|
|
94
|
-
|
|
65
|
+
const menuItemModel = productCategoryData?.results[0]?.menuitemmodel;
|
|
95
66
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
locale,
|
|
99
|
-
currency,
|
|
100
|
-
init: {
|
|
101
|
-
headers: {
|
|
102
|
-
Accept: 'application/json',
|
|
103
|
-
'Content-Type': 'application/json'
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
} catch (error) {
|
|
108
|
-
logger.warn('Failed to fetch breadcrumb data', {
|
|
67
|
+
if (!menuItemModel) {
|
|
68
|
+
logger.warn('menuItemModel is undefined, skipping breadcrumbData fetch', {
|
|
109
69
|
handler: 'getProductDataHandler',
|
|
110
|
-
pk
|
|
111
|
-
error: error.message
|
|
70
|
+
pk
|
|
112
71
|
});
|
|
113
|
-
|
|
72
|
+
return { data, breadcrumbData: undefined };
|
|
114
73
|
}
|
|
115
74
|
|
|
75
|
+
const breadcrumbUrl = product.breadcrumbUrl(menuItemModel);
|
|
76
|
+
|
|
77
|
+
const breadcrumbData = await appFetch<any>({
|
|
78
|
+
url: breadcrumbUrl,
|
|
79
|
+
locale,
|
|
80
|
+
currency,
|
|
81
|
+
init: {
|
|
82
|
+
headers: {
|
|
83
|
+
Accept: 'application/json',
|
|
84
|
+
'Content-Type': 'application/json'
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
|
|
116
89
|
return {
|
|
117
90
|
data,
|
|
118
91
|
breadcrumbData: breadcrumbData?.menu
|
|
@@ -143,7 +116,8 @@ export const getProductData = async ({
|
|
|
143
116
|
headers
|
|
144
117
|
}),
|
|
145
118
|
{
|
|
146
|
-
expire: 300
|
|
119
|
+
expire: 300,
|
|
120
|
+
compressed: true
|
|
147
121
|
}
|
|
148
122
|
);
|
|
149
123
|
};
|
|
@@ -15,24 +15,20 @@ const getSpecialPageDataHandler = (
|
|
|
15
15
|
return async function () {
|
|
16
16
|
const params = generateCommerceSearchParams(searchParams);
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
...(headers ?? {})
|
|
28
|
-
}
|
|
18
|
+
const data: GetCategoryResponse = await appFetch({
|
|
19
|
+
url: `${category.getSpecialPageByPk(pk)}${params}`,
|
|
20
|
+
locale,
|
|
21
|
+
currency,
|
|
22
|
+
init: {
|
|
23
|
+
headers: {
|
|
24
|
+
Accept: 'application/json',
|
|
25
|
+
'Content-Type': 'application/json',
|
|
26
|
+
...(headers ?? {})
|
|
29
27
|
}
|
|
30
|
-
}
|
|
28
|
+
}
|
|
29
|
+
});
|
|
31
30
|
|
|
32
|
-
|
|
33
|
-
} catch (error) {
|
|
34
|
-
return null;
|
|
35
|
-
}
|
|
31
|
+
return data;
|
|
36
32
|
};
|
|
37
33
|
};
|
|
38
34
|
|
package/data/server/widget.ts
CHANGED
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 = {
|
|
@@ -72,13 +72,10 @@ const addRootLayoutProps = async (componentProps: RootLayoutProps) => {
|
|
|
72
72
|
const checkRedisVariables = () => {
|
|
73
73
|
const requiredVariableValues = [
|
|
74
74
|
process.env.CACHE_HOST,
|
|
75
|
-
process.env.CACHE_PORT
|
|
75
|
+
process.env.CACHE_PORT,
|
|
76
|
+
process.env.CACHE_SECRET
|
|
76
77
|
];
|
|
77
78
|
|
|
78
|
-
if (!settings.usePrettyUrlRoute) {
|
|
79
|
-
requiredVariableValues.push(process.env.CACHE_SECRET);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
79
|
if (
|
|
83
80
|
!requiredVariableValues.every((v) => v) &&
|
|
84
81
|
process.env.NODE_ENV === 'production'
|
|
@@ -4,6 +4,7 @@ import { LocalizationContext } from '../localization/provider';
|
|
|
4
4
|
import { useContext } from 'react';
|
|
5
5
|
import { setCookie, urlLocaleMatcherRegex } from '../utils';
|
|
6
6
|
import { LocaleUrlStrategy } from '../localization';
|
|
7
|
+
import { useRouter } from 'next/navigation';
|
|
7
8
|
|
|
8
9
|
export const useLocalization = () => {
|
|
9
10
|
const {
|
|
@@ -17,6 +18,8 @@ export const useLocalization = () => {
|
|
|
17
18
|
localeUrlStrategy
|
|
18
19
|
} = useContext(LocalizationContext);
|
|
19
20
|
|
|
21
|
+
const router = useRouter();
|
|
22
|
+
|
|
20
23
|
/**
|
|
21
24
|
* Sets the locale in the URL.
|
|
22
25
|
* @param locale Locale value defined in the settings.
|
|
@@ -27,8 +30,6 @@ export const useLocalization = () => {
|
|
|
27
30
|
|
|
28
31
|
let targetUrl;
|
|
29
32
|
|
|
30
|
-
setCookie('pz-locale', locale);
|
|
31
|
-
|
|
32
33
|
if (localeUrlStrategy === LocaleUrlStrategy.Subdomain) {
|
|
33
34
|
const hostParts = hostname.split('.');
|
|
34
35
|
const subDomain = hostParts[0];
|
package/jest.config.js
CHANGED
|
@@ -1,19 +1,13 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
|
-
const findBaseDir = require('./utils/find-base-dir');
|
|
3
|
-
|
|
4
|
-
const baseDir = findBaseDir();
|
|
5
2
|
|
|
6
3
|
module.exports = {
|
|
7
4
|
preset: 'ts-jest',
|
|
8
5
|
testEnvironment: 'node',
|
|
9
6
|
rootDir: path.resolve(__dirname),
|
|
7
|
+
roots: [],
|
|
10
8
|
testMatch: ['**/*.test.ts'],
|
|
11
9
|
testPathIgnorePatterns: [],
|
|
12
|
-
roots: [path.resolve(__dirname)],
|
|
13
10
|
transformIgnorePatterns: [],
|
|
14
|
-
moduleNameMapper: {
|
|
15
|
-
'^settings$': path.resolve(baseDir, 'src/settings.js')
|
|
16
|
-
},
|
|
17
11
|
transform: {
|
|
18
12
|
'^.+\\.(tsx?|jsx?|mjs?)$': [
|
|
19
13
|
'ts-jest',
|