@akinon/next 1.42.0-rc.9 → 1.43.0-rc.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 +15 -35
- package/api/client.ts +15 -0
- package/components/plugin-module.tsx +8 -3
- package/data/client/api.ts +1 -0
- package/data/client/basket.ts +42 -0
- package/data/urls.ts +5 -1
- package/middlewares/default.ts +28 -2
- package/middlewares/url-redirection.ts +4 -0
- package/package.json +3 -3
- package/types/commerce/basket.ts +1 -0
- package/types/commerce/order.ts +5 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,47 +1,17 @@
|
|
|
1
1
|
# @akinon/next
|
|
2
2
|
|
|
3
|
-
## 1.
|
|
4
|
-
|
|
5
|
-
## 1.42.0-rc.8
|
|
6
|
-
|
|
7
|
-
### Minor Changes
|
|
8
|
-
|
|
9
|
-
- d409996: ZERO-2781: Refactor buildClientRequestUrl function to support caching and options
|
|
10
|
-
|
|
11
|
-
## 1.42.0-rc.7
|
|
12
|
-
|
|
13
|
-
## 1.42.0-rc.6
|
|
14
|
-
|
|
15
|
-
### Minor Changes
|
|
16
|
-
|
|
17
|
-
- 146ea39: ZERO-2774: Update imports
|
|
18
|
-
|
|
19
|
-
## 1.42.0-rc.5
|
|
20
|
-
|
|
21
|
-
## 1.42.0-rc.4
|
|
22
|
-
|
|
23
|
-
### Minor Changes
|
|
24
|
-
|
|
25
|
-
- 46b7aad: ZERO-2775: Add condition and logger for menuitemmodel data
|
|
26
|
-
|
|
27
|
-
## 1.42.0-rc.3
|
|
28
|
-
|
|
29
|
-
### Minor Changes
|
|
30
|
-
|
|
31
|
-
- fda5b92: ZERO-2725: fix invalid import
|
|
32
|
-
|
|
33
|
-
## 1.42.0-rc.2
|
|
34
|
-
|
|
35
|
-
## 1.42.0-rc.1
|
|
36
|
-
|
|
37
|
-
## 1.42.0-rc.0
|
|
3
|
+
## 1.43.0-rc.0
|
|
38
4
|
|
|
39
5
|
### Minor Changes
|
|
40
6
|
|
|
41
7
|
- 90282b5: ZERO-2729: Audit packages for yarn and npm and also update app-template
|
|
42
8
|
- 572d2e8: ZERO-2667: Add iframe support for redirection payment methods
|
|
43
9
|
- a4c8d6a: ZERO-2663: Fix the image url for gif and svgs and return them without options
|
|
10
|
+
- fda5b92: ZERO-2725: fix invalid import
|
|
11
|
+
- 2d9b2b2: ZERO-2816: Add segment to headers
|
|
44
12
|
- c53ea3e: ZERO-2609: Reset additional form fields when selectedFormType is not company
|
|
13
|
+
- 8d9ac9a: ZERO-2794: Add field to order type
|
|
14
|
+
- e9541a1: ZERO-2816: Add headers to url
|
|
45
15
|
- c53ef7b: ZERO-2668: The Link component has been updated to improve the logic for handling href values. Previously, if the href was not a string or started with 'http', it would return the href as is. Now, if the href is not provided, it will default to '#' to prevent any potential errors. Additionally, if the href is a string and does not start with 'http', it will be formatted with the locale and pathname, based on the localeUrlStrategy and defaultLocaleValue. This ensures that the correct href is generated based on the localization settings.
|
|
46
16
|
- 0d3a913: ZERO-2725: Update decimal scale in Price component
|
|
47
17
|
- 1448a96: ZERO-2612: add errors type in CheckoutState
|
|
@@ -49,16 +19,26 @@
|
|
|
49
19
|
- 75080fd: ZERO-2630: Add max limit to postcode area
|
|
50
20
|
- 91265bb: ZERO-2551: Improve pretty url and caching performance
|
|
51
21
|
- bbe18b9: ZERO-2575: Fix build error
|
|
22
|
+
- d409996: ZERO-2781: Refactor buildClientRequestUrl function to support caching and options
|
|
23
|
+
- 94b6928: ZERO-2551: Add cache handler check in url-redirection middleware
|
|
52
24
|
- 98bb8dc: ZERO-2706: Cache getTranlations method
|
|
25
|
+
- 46b7aad: ZERO-2775: Add condition and logger for menuitemmodel data
|
|
53
26
|
- dcc8a15: ZERO-2694: added build step to RC branch pipeline
|
|
54
27
|
- fad2768: ZERO-2739: add gpay to payment plugin map
|
|
55
28
|
- dff0d59: ZERO-2659: add formData support to proxy api requests
|
|
56
29
|
- beb499e: ZERO-2551: Add new tsconfig paths
|
|
30
|
+
- 146ea39: ZERO-2774: Update imports
|
|
57
31
|
- c47be30: ZERO-2744: Update Order and OrderItem types
|
|
58
32
|
- e9a46ac: ZERO-2738: add CVC input to registered cards in Masterpass
|
|
59
33
|
- f046f8e: ZERO-2575: update version for react-number-format
|
|
60
34
|
- 86d2531: ZERO-2693: resolve dependency collision warning for eslint-config-next
|
|
61
35
|
|
|
36
|
+
## 1.42.0
|
|
37
|
+
|
|
38
|
+
### Minor Changes
|
|
39
|
+
|
|
40
|
+
- 5ea00a6: ZERO-2761: Add multi basket package
|
|
41
|
+
|
|
62
42
|
## 1.41.0
|
|
63
43
|
|
|
64
44
|
### Minor Changes
|
package/api/client.ts
CHANGED
|
@@ -4,6 +4,7 @@ import settings from 'settings';
|
|
|
4
4
|
import logger from '../utils/log';
|
|
5
5
|
import formatCookieString from '../utils/format-cookie-string';
|
|
6
6
|
import cookieParser from 'set-cookie-parser';
|
|
7
|
+
import { cookies } from 'next/headers';
|
|
7
8
|
|
|
8
9
|
interface RouteParams {
|
|
9
10
|
params: {
|
|
@@ -74,6 +75,20 @@ async function proxyRequest(...args) {
|
|
|
74
75
|
}
|
|
75
76
|
} as RequestInit;
|
|
76
77
|
|
|
78
|
+
const nextCookies = cookies();
|
|
79
|
+
const segment = nextCookies.get('pz-segment')?.value;
|
|
80
|
+
const currency = nextCookies.get('pz-external-currency')?.value;
|
|
81
|
+
|
|
82
|
+
if (segment) {
|
|
83
|
+
fetchOptions.headers['X-Segment-Id'] = segment;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (currency) {
|
|
87
|
+
fetchOptions.headers = Object.assign({}, fetchOptions.headers, {
|
|
88
|
+
'x-currency': currency
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
|
|
77
92
|
if (options.contentType) {
|
|
78
93
|
fetchOptions.headers['Content-Type'] = options.contentType;
|
|
79
94
|
}
|
|
@@ -18,7 +18,8 @@ enum Plugin {
|
|
|
18
18
|
CreditPayment = 'pz-credit-payment',
|
|
19
19
|
Masterpass = 'pz-masterpass',
|
|
20
20
|
B2B = 'pz-b2b',
|
|
21
|
-
Akifast = 'pz-akifast'
|
|
21
|
+
Akifast = 'pz-akifast',
|
|
22
|
+
MultiBasket = 'pz-multi-basket'
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
export enum Component {
|
|
@@ -41,7 +42,8 @@ export enum Component {
|
|
|
41
42
|
MyQuotationsB2B = 'AccountMyQuotations',
|
|
42
43
|
BasketB2B = 'BasketB2b',
|
|
43
44
|
AkifastQuickLoginButton = 'QuickLoginButton',
|
|
44
|
-
AkifastCheckoutButton = 'CheckoutButton'
|
|
45
|
+
AkifastCheckoutButton = 'CheckoutButton',
|
|
46
|
+
MultiBasket = 'MultiBasket'
|
|
45
47
|
}
|
|
46
48
|
|
|
47
49
|
const PluginComponents = new Map([
|
|
@@ -72,7 +74,8 @@ const PluginComponents = new Map([
|
|
|
72
74
|
[
|
|
73
75
|
Plugin.Akifast,
|
|
74
76
|
[Component.AkifastQuickLoginButton, Component.AkifastCheckoutButton]
|
|
75
|
-
]
|
|
77
|
+
],
|
|
78
|
+
[Plugin.MultiBasket, [Component.MultiBasket]]
|
|
76
79
|
]);
|
|
77
80
|
|
|
78
81
|
const getPlugin = (component: Component) => {
|
|
@@ -133,6 +136,8 @@ export default function PluginModule({
|
|
|
133
136
|
promise = import(`${'@akinon/pz-b2b'}`);
|
|
134
137
|
} else if (plugin === Plugin.Akifast) {
|
|
135
138
|
promise = import(`${'@akinon/pz-akifast'}`);
|
|
139
|
+
} else if (plugin === Plugin.MultiBasket) {
|
|
140
|
+
promise = import('@akinon/pz-multi-basket');
|
|
136
141
|
}
|
|
137
142
|
} catch (error) {
|
|
138
143
|
logger.error(error);
|
package/data/client/api.ts
CHANGED
package/data/client/basket.ts
CHANGED
|
@@ -24,6 +24,44 @@ export const basketApi = api.injectEndpoints({
|
|
|
24
24
|
transformResponse: (response: { basket: Basket }) => response.basket,
|
|
25
25
|
providesTags: ['Basket']
|
|
26
26
|
}),
|
|
27
|
+
getBasketDetail: build.mutation<Basket, { namespace: string }>({
|
|
28
|
+
query: ({ namespace }) => ({
|
|
29
|
+
url: buildClientRequestUrl(basket.getBasketDetail(namespace), {
|
|
30
|
+
contentType: 'application/json'
|
|
31
|
+
}),
|
|
32
|
+
method: 'GET'
|
|
33
|
+
}),
|
|
34
|
+
invalidatesTags: ['AllBaskets']
|
|
35
|
+
}),
|
|
36
|
+
getAllBaskets: build.query<Basket[], void>({
|
|
37
|
+
query: () =>
|
|
38
|
+
buildClientRequestUrl(basket.getAllBaskets, {
|
|
39
|
+
contentType: 'application/json'
|
|
40
|
+
}),
|
|
41
|
+
transformResponse: (response: { baskets: Basket[] }) => response.baskets,
|
|
42
|
+
providesTags: ['AllBaskets']
|
|
43
|
+
}),
|
|
44
|
+
removeBasket: build.mutation<Basket, { pk: number }>({
|
|
45
|
+
query: ({ pk }) => ({
|
|
46
|
+
url: buildClientRequestUrl(basket.removeBasket(pk), {
|
|
47
|
+
contentType: 'application/json'
|
|
48
|
+
}),
|
|
49
|
+
method: 'DELETE',
|
|
50
|
+
body: { pk }
|
|
51
|
+
}),
|
|
52
|
+
invalidatesTags: ['AllBaskets', 'Basket']
|
|
53
|
+
}),
|
|
54
|
+
selectMainBasket: build.mutation<Basket, { pk: number }>({
|
|
55
|
+
query: ({ pk }) => ({
|
|
56
|
+
url: buildClientRequestUrl(basket.selectMainBasket(pk), {
|
|
57
|
+
contentType: 'application/json'
|
|
58
|
+
}),
|
|
59
|
+
method: 'POST',
|
|
60
|
+
body: { pk }
|
|
61
|
+
}),
|
|
62
|
+
transformResponse: (response: { baskets: Basket }) => response.baskets,
|
|
63
|
+
invalidatesTags: ['AllBaskets', 'Basket']
|
|
64
|
+
}),
|
|
27
65
|
updateQuantity: build.mutation<
|
|
28
66
|
UpdateQuantityResponse,
|
|
29
67
|
UpdateQuantityRequest
|
|
@@ -75,6 +113,10 @@ export const basketApi = api.injectEndpoints({
|
|
|
75
113
|
|
|
76
114
|
export const {
|
|
77
115
|
useGetBasketQuery,
|
|
116
|
+
useGetBasketDetailMutation,
|
|
117
|
+
useGetAllBasketsQuery,
|
|
118
|
+
useRemoveBasketMutation,
|
|
119
|
+
useSelectMainBasketMutation,
|
|
78
120
|
useUpdateQuantityMutation,
|
|
79
121
|
useClearBasketMutation,
|
|
80
122
|
useApplyVoucherCodeMutation,
|
package/data/urls.ts
CHANGED
|
@@ -56,7 +56,11 @@ export const address = {
|
|
|
56
56
|
};
|
|
57
57
|
|
|
58
58
|
export const basket = {
|
|
59
|
-
getBasket: '/baskets/basket/'
|
|
59
|
+
getBasket: '/baskets/basket/',
|
|
60
|
+
getBasketDetail: (namespace: string) => `/baskets/basket/${namespace}/`,
|
|
61
|
+
getAllBaskets: '/baskets/basket-list/',
|
|
62
|
+
removeBasket: (pk: number) => `/baskets/basket-list/${pk}/`,
|
|
63
|
+
selectMainBasket: (pk: number) => `/baskets/basket-list/id/${pk}/main/`
|
|
60
64
|
};
|
|
61
65
|
|
|
62
66
|
export const category = {
|
package/middlewares/default.ts
CHANGED
|
@@ -84,14 +84,40 @@ const withPzDefault =
|
|
|
84
84
|
req.nextUrl.pathname.includes('/orders/hooks/') ||
|
|
85
85
|
req.nextUrl.pathname.includes('/orders/checkout-with-token/')
|
|
86
86
|
) {
|
|
87
|
-
|
|
87
|
+
const segment = url.searchParams.get('segment');
|
|
88
|
+
const currency = url.searchParams.get('currency');
|
|
89
|
+
|
|
90
|
+
const headers = {};
|
|
91
|
+
|
|
92
|
+
if (segment) {
|
|
93
|
+
headers['X-Segment-Id'] = segment;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (currency) {
|
|
97
|
+
headers['x-currency'] = currency;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const response = NextResponse.rewrite(
|
|
88
101
|
new URL(
|
|
89
102
|
`${Settings.commerceUrl}${req.nextUrl.pathname.replace(
|
|
90
103
|
urlLocaleMatcherRegex,
|
|
91
104
|
''
|
|
92
105
|
)}`
|
|
93
|
-
)
|
|
106
|
+
),
|
|
107
|
+
{
|
|
108
|
+
headers
|
|
109
|
+
}
|
|
94
110
|
);
|
|
111
|
+
|
|
112
|
+
if (segment) {
|
|
113
|
+
response.cookies.set('pz-segment', segment);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (currency) {
|
|
117
|
+
response.cookies.set('pz-external-currency', currency);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return response;
|
|
95
121
|
}
|
|
96
122
|
|
|
97
123
|
if (req.nextUrl.pathname.startsWith('/orders/redirection/')) {
|
|
@@ -11,6 +11,10 @@ import { ROUTES } from 'routes';
|
|
|
11
11
|
const withUrlRedirection =
|
|
12
12
|
(middleware: NextMiddleware) =>
|
|
13
13
|
async (req: PzNextRequest, event: NextFetchEvent) => {
|
|
14
|
+
if (settings.usePrettyUrlRoute) {
|
|
15
|
+
return middleware(req, event);
|
|
16
|
+
}
|
|
17
|
+
|
|
14
18
|
const url = req.nextUrl.clone();
|
|
15
19
|
const ip = req.headers.get('x-forwarded-for') ?? '';
|
|
16
20
|
const pathnameWithoutLocale = url.pathname.replace(
|
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.
|
|
4
|
+
"version": "1.43.0-rc.0",
|
|
5
5
|
"private": false,
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"bin": {
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"@opentelemetry/sdk-trace-node": "1.19.0",
|
|
21
21
|
"@opentelemetry/semantic-conventions": "1.19.0",
|
|
22
22
|
"@reduxjs/toolkit": "1.9.7",
|
|
23
|
-
"@neshca/cache-handler": "1.
|
|
23
|
+
"@neshca/cache-handler": "1.5.1",
|
|
24
24
|
"cross-spawn": "7.0.3",
|
|
25
25
|
"generic-pool": "3.9.0",
|
|
26
26
|
"react-redux": "8.1.3",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"set-cookie-parser": "2.6.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@akinon/eslint-plugin-projectzero": "1.
|
|
33
|
+
"@akinon/eslint-plugin-projectzero": "1.43.0-rc.0",
|
|
34
34
|
"@types/react-redux": "7.1.30",
|
|
35
35
|
"@types/set-cookie-parser": "2.4.7",
|
|
36
36
|
"@typescript-eslint/eslint-plugin": "6.7.4",
|
package/types/commerce/basket.ts
CHANGED
package/types/commerce/order.ts
CHANGED
|
@@ -109,8 +109,13 @@ export interface Order {
|
|
|
109
109
|
shipping_option: number;
|
|
110
110
|
tracking_number: string;
|
|
111
111
|
tracking_url: string;
|
|
112
|
+
[key: string]: any;
|
|
112
113
|
bank: {
|
|
114
|
+
pk: number;
|
|
115
|
+
name: string;
|
|
116
|
+
slug: string;
|
|
113
117
|
logo: string;
|
|
118
|
+
[key: string]: any;
|
|
114
119
|
};
|
|
115
120
|
}
|
|
116
121
|
|