@akinon/next 1.93.0-rc.49 → 1.93.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 +36 -1260
- package/__tests__/next-config.test.ts +10 -1
- package/bin/pz-prebuild.js +1 -0
- 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 -35
- package/components/selected-payment-option-view.tsx +0 -11
- package/data/client/checkout.ts +4 -25
- package/data/server/category.ts +28 -48
- package/data/server/flatpage.ts +12 -16
- package/data/server/landingpage.ts +12 -16
- package/data/server/list.ts +13 -23
- package/data/server/product.ts +39 -66
- package/data/server/special-page.ts +12 -16
- package/data/urls.ts +2 -7
- package/hocs/server/with-segment-defaults.tsx +2 -5
- package/hooks/use-localization.ts +3 -2
- package/instrumentation/node.ts +13 -15
- package/jest.config.js +1 -7
- package/lib/cache.ts +0 -2
- package/middlewares/checkout-provider.ts +1 -1
- package/middlewares/complete-gpay.ts +2 -6
- package/middlewares/complete-masterpass.ts +2 -7
- package/middlewares/default.ts +183 -232
- package/middlewares/index.ts +1 -3
- package/middlewares/locale.ts +1 -9
- package/middlewares/redirection-payment.ts +2 -6
- package/middlewares/saved-card-redirection.ts +2 -7
- package/middlewares/three-d-redirection.ts +2 -7
- package/middlewares/url-redirection.ts +15 -9
- package/package.json +3 -3
- package/plugins.d.ts +0 -10
- package/plugins.js +1 -4
- package/redux/middlewares/checkout.ts +2 -15
- package/redux/reducers/checkout.ts +1 -9
- package/sentry/index.ts +17 -54
- package/types/commerce/order.ts +0 -1
- package/types/index.ts +1 -42
- package/utils/app-fetch.ts +2 -7
- package/utils/index.ts +10 -34
- package/utils/redirect.ts +6 -31
- package/with-pz-config.js +5 -1
- package/__tests__/redirect.test.ts +0 -758
- 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/hooks/use-loyalty-availability.ts +0 -21
- package/middlewares/wallet-complete-redirection.ts +0 -203
- package/utils/redirect-ignore.ts +0 -35
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
|
|
@@ -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/urls.ts
CHANGED
|
@@ -142,8 +142,7 @@ export const checkout = {
|
|
|
142
142
|
setOrderSelectionPage: '/orders/checkout/?page=OrderSelectionPage',
|
|
143
143
|
loyaltyCardPage: '/orders/checkout/?page=LoyaltyCardPage',
|
|
144
144
|
sendSmsPage: '/orders/checkout/?page=SendSmsPage',
|
|
145
|
-
verifySmsPage: '/orders/checkout/?page=VerifySmsPage'
|
|
146
|
-
saveSampleProducts: '/orders/checkout/?page=SampleProductPage'
|
|
145
|
+
verifySmsPage: '/orders/checkout/?page=VerifySmsPage'
|
|
147
146
|
};
|
|
148
147
|
|
|
149
148
|
export const flatpage = {
|
|
@@ -183,11 +182,7 @@ export const product = {
|
|
|
183
182
|
breadcrumbUrl: (menuitemmodel: string) =>
|
|
184
183
|
`/menus/generate_breadcrumb/?item=${menuitemmodel}&generator_name=menu_item`,
|
|
185
184
|
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}` : ''}`
|
|
185
|
+
`/bundle-product/${productPk}/?${queryString}`
|
|
191
186
|
};
|
|
192
187
|
|
|
193
188
|
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/instrumentation/node.ts
CHANGED
|
@@ -4,19 +4,17 @@ import { Resource } from '@opentelemetry/resources';
|
|
|
4
4
|
import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions';
|
|
5
5
|
import { SimpleSpanProcessor } from '@opentelemetry/sdk-trace-node';
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
});
|
|
7
|
+
const sdk = new NodeSDK({
|
|
8
|
+
resource: new Resource({
|
|
9
|
+
[SemanticResourceAttributes.SERVICE_NAME]: 'pz-next-app'
|
|
10
|
+
}),
|
|
11
|
+
spanProcessor: new SimpleSpanProcessor(
|
|
12
|
+
new OTLPTraceExporter({
|
|
13
|
+
url: `${
|
|
14
|
+
process.env.PZ_DASHBOARD_URL ?? 'http://localhost:3005'
|
|
15
|
+
}/api/traces`
|
|
16
|
+
})
|
|
17
|
+
)
|
|
18
|
+
});
|
|
20
19
|
|
|
21
|
-
|
|
22
|
-
}
|
|
20
|
+
sdk.start();
|
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',
|
package/lib/cache.ts
CHANGED
|
@@ -31,8 +31,6 @@ export const CacheKey = {
|
|
|
31
31
|
`category_${pk}_${encodeURIComponent(
|
|
32
32
|
JSON.stringify(searchParams)
|
|
33
33
|
)}${hashCacheKey(headers)}`,
|
|
34
|
-
Basket: (namespace?: string) => `basket${namespace ? `_${namespace}` : ''}`,
|
|
35
|
-
AllBaskets: () => 'all_baskets',
|
|
36
34
|
CategorySlug: (slug: string) => `category_${slug}`,
|
|
37
35
|
SpecialPage: (
|
|
38
36
|
pk: number,
|
|
@@ -64,7 +64,7 @@ const withCheckoutProvider =
|
|
|
64
64
|
const location = request.headers.get('location');
|
|
65
65
|
const redirectUrl = new URL(
|
|
66
66
|
request.headers.get('location'),
|
|
67
|
-
location.startsWith('http') ? '' :
|
|
67
|
+
location.startsWith('http') ? '' : process.env.NEXT_PUBLIC_URL
|
|
68
68
|
);
|
|
69
69
|
|
|
70
70
|
redirectUrl.pathname = getUrlPathWithLocale(
|
|
@@ -34,7 +34,6 @@ const withCompleteGpay =
|
|
|
34
34
|
const url = req.nextUrl.clone();
|
|
35
35
|
const ip = req.headers.get('x-forwarded-for') ?? '';
|
|
36
36
|
const sessionId = req.cookies.get('osessionid');
|
|
37
|
-
const currentLocale = req.middlewareParams?.rewrites?.locale;
|
|
38
37
|
|
|
39
38
|
if (url.search.indexOf('GPayCompletePage') === -1) {
|
|
40
39
|
return middleware(req, event);
|
|
@@ -46,9 +45,7 @@ const withCompleteGpay =
|
|
|
46
45
|
'Content-Type': 'application/x-www-form-urlencoded',
|
|
47
46
|
Cookie: req.headers.get('cookie') ?? '',
|
|
48
47
|
'x-currency': req.cookies.get('pz-currency')?.value ?? '',
|
|
49
|
-
'x-forwarded-for': ip
|
|
50
|
-
'Accept-Language':
|
|
51
|
-
currentLocale ?? req.cookies.get('pz-locale')?.value ?? ''
|
|
48
|
+
'x-forwarded-for': ip
|
|
52
49
|
};
|
|
53
50
|
|
|
54
51
|
try {
|
|
@@ -148,8 +145,7 @@ const withCompleteGpay =
|
|
|
148
145
|
logger.info('Redirecting to order success page', {
|
|
149
146
|
middleware: 'complete-gpay',
|
|
150
147
|
redirectUrlWithLocale,
|
|
151
|
-
ip
|
|
152
|
-
setCookie: request.headers.get('set-cookie')
|
|
148
|
+
ip
|
|
153
149
|
});
|
|
154
150
|
|
|
155
151
|
// Using POST method while redirecting causes an error,
|
|
@@ -4,7 +4,6 @@ import { Buffer } from 'buffer';
|
|
|
4
4
|
import logger from '../utils/log';
|
|
5
5
|
import { getUrlPathWithLocale } from '../utils/localization';
|
|
6
6
|
import { PzNextRequest } from '.';
|
|
7
|
-
import { ServerVariables } from '../utils/server-variables';
|
|
8
7
|
|
|
9
8
|
const streamToString = async (stream: ReadableStream<Uint8Array> | null) => {
|
|
10
9
|
if (stream) {
|
|
@@ -35,7 +34,6 @@ const withCompleteMasterpass =
|
|
|
35
34
|
const url = req.nextUrl.clone();
|
|
36
35
|
const ip = req.headers.get('x-forwarded-for') ?? '';
|
|
37
36
|
const sessionId = req.cookies.get('osessionid');
|
|
38
|
-
const currentLocale = req.middlewareParams?.rewrites?.locale;
|
|
39
37
|
|
|
40
38
|
if (url.search.indexOf('MasterpassCompletePage') === -1) {
|
|
41
39
|
return middleware(req, event);
|
|
@@ -47,9 +45,7 @@ const withCompleteMasterpass =
|
|
|
47
45
|
'Content-Type': 'application/x-www-form-urlencoded',
|
|
48
46
|
Cookie: req.headers.get('cookie') ?? '',
|
|
49
47
|
'x-currency': req.cookies.get('pz-currency')?.value ?? '',
|
|
50
|
-
'x-forwarded-for': ip
|
|
51
|
-
'Accept-Language':
|
|
52
|
-
currentLocale ?? req.cookies.get('pz-locale')?.value ?? ''
|
|
48
|
+
'x-forwarded-for': ip
|
|
53
49
|
};
|
|
54
50
|
|
|
55
51
|
try {
|
|
@@ -149,8 +145,7 @@ const withCompleteMasterpass =
|
|
|
149
145
|
logger.info('Redirecting to order success page', {
|
|
150
146
|
middleware: 'complete-masterpass',
|
|
151
147
|
redirectUrlWithLocale,
|
|
152
|
-
ip
|
|
153
|
-
setCookie: request.headers.get('set-cookie')
|
|
148
|
+
ip
|
|
154
149
|
});
|
|
155
150
|
|
|
156
151
|
// Using POST method while redirecting causes an error,
|