@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.
Files changed (49) hide show
  1. package/CHANGELOG.md +41 -1246
  2. package/__tests__/next-config.test.ts +10 -1
  3. package/api/cache.ts +39 -5
  4. package/components/accordion.tsx +5 -20
  5. package/components/file-input.tsx +3 -65
  6. package/components/input.tsx +0 -2
  7. package/components/link.tsx +12 -16
  8. package/components/modal.tsx +16 -32
  9. package/components/plugin-module.tsx +3 -30
  10. package/data/client/checkout.ts +4 -5
  11. package/data/server/category.ts +32 -50
  12. package/data/server/flatpage.ts +16 -17
  13. package/data/server/form.ts +4 -1
  14. package/data/server/landingpage.ts +12 -16
  15. package/data/server/list.ts +15 -24
  16. package/data/server/menu.ts +5 -2
  17. package/data/server/product.ts +41 -67
  18. package/data/server/special-page.ts +12 -16
  19. package/data/server/widget.ts +4 -1
  20. package/data/urls.ts +1 -5
  21. package/hocs/server/with-segment-defaults.tsx +2 -5
  22. package/hooks/use-localization.ts +3 -2
  23. package/jest.config.js +1 -7
  24. package/lib/cache-handler.mjs +365 -87
  25. package/lib/cache.ts +252 -25
  26. package/middlewares/complete-gpay.ts +1 -2
  27. package/middlewares/complete-masterpass.ts +1 -2
  28. package/middlewares/default.ts +13 -50
  29. package/middlewares/locale.ts +1 -9
  30. package/middlewares/pretty-url.ts +2 -1
  31. package/middlewares/redirection-payment.ts +1 -2
  32. package/middlewares/saved-card-redirection.ts +1 -2
  33. package/middlewares/three-d-redirection.ts +1 -2
  34. package/middlewares/url-redirection.ts +14 -8
  35. package/package.json +4 -3
  36. package/plugins.d.ts +0 -8
  37. package/plugins.js +1 -3
  38. package/redux/middlewares/checkout.ts +1 -5
  39. package/types/commerce/order.ts +0 -1
  40. package/types/index.ts +2 -34
  41. package/utils/app-fetch.ts +2 -7
  42. package/utils/redirect.ts +6 -31
  43. package/with-pz-config.js +5 -1
  44. package/__tests__/redirect.test.ts +0 -319
  45. package/api/image-proxy.ts +0 -75
  46. package/api/similar-product-list.ts +0 -84
  47. package/api/similar-products.ts +0 -120
  48. package/data/server/basket.ts +0 -72
  49. package/utils/redirect-ignore.ts +0 -35
@@ -16,29 +16,19 @@ const getListDataHandler = (
16
16
  return async function () {
17
17
  const params = generateCommerceSearchParams(searchParams);
18
18
 
19
- let rawData: string;
20
-
21
- try {
22
- rawData = await appFetch<string>({
23
- url: `${category.list}${params}`,
24
- locale,
25
- currency,
26
- init: {
27
- headers: {
28
- Accept: 'application/json',
29
- 'Content-Type': 'application/json',
30
- ...(headers ?? {})
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
  };
@@ -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
  };
@@ -35,84 +35,57 @@ const getProductDataHandler = ({
35
35
  .join('&');
36
36
  }
37
37
 
38
- let data: ProductResult;
39
-
40
- try {
41
- data = await appFetch<ProductResult>({
42
- url,
43
- locale,
44
- currency,
45
- init: {
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
- } catch (error) {
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
- let productCategoryData: ProductCategoryResult;
66
- let breadcrumbData: { menu?: unknown } = {};
67
-
68
- try {
69
- productCategoryData = await appFetch<ProductCategoryResult>({
70
- url: categoryUrl,
71
- locale,
72
- currency,
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
- const breadcrumbUrl = product.breadcrumbUrl(menuItemModel);
65
+ const menuItemModel = productCategoryData?.results[0]?.menuitemmodel;
95
66
 
96
- breadcrumbData = await appFetch<{ menu?: unknown }>({
97
- url: breadcrumbUrl,
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
- // Continue without breadcrumb data
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
- try {
19
- const data: GetCategoryResponse = await appFetch({
20
- url: `${category.getSpecialPageByPk(pk)}${params}`,
21
- locale,
22
- currency,
23
- init: {
24
- headers: {
25
- Accept: 'application/json',
26
- 'Content-Type': 'application/json',
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
- return data;
33
- } catch (error) {
34
- return null;
35
- }
31
+ return data;
36
32
  };
37
33
  };
38
34
 
@@ -44,6 +44,9 @@ export const getWidgetData = async <T>({
44
44
  CacheKey.Widget(slug),
45
45
  locale,
46
46
  getWidgetDataHandler(slug, locale, currency, headers),
47
- cacheOptions
47
+ {
48
+ ...cacheOptions,
49
+ compressed: true
50
+ }
48
51
  );
49
52
  };
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',