@akinon/next 1.76.0-rc.0 → 2.0.0-beta.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 +5 -740
- package/components/input.tsx +0 -2
- package/components/link.tsx +12 -16
- package/data/server/flatpage.ts +4 -8
- package/data/server/form.ts +4 -12
- package/data/server/landingpage.ts +4 -8
- package/data/server/menu.ts +2 -7
- package/data/server/product.ts +4 -15
- package/data/server/seo.ts +4 -11
- package/data/server/widget.ts +4 -19
- package/hocs/server/with-segment-defaults.tsx +2 -5
- package/instrumentation/index.ts +0 -7
- package/lib/cache-handler.mjs +2 -2
- package/lib/cache.ts +0 -2
- package/middlewares/complete-gpay.ts +1 -2
- package/middlewares/complete-masterpass.ts +1 -2
- package/middlewares/default.ts +1 -3
- package/middlewares/redirection-payment.ts +1 -2
- package/middlewares/saved-card-redirection.ts +1 -2
- package/middlewares/three-d-redirection.ts +1 -2
- package/package.json +3 -3
- package/types/commerce/order.ts +0 -1
- package/utils/app-fetch.ts +2 -2
- package/with-pz-config.js +1 -1
- package/data/server/basket.ts +0 -72
package/components/input.tsx
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import clsx from 'clsx';
|
|
2
2
|
import { forwardRef, FocusEvent, useState, Ref } from 'react';
|
|
3
3
|
import { Controller } from 'react-hook-form';
|
|
4
|
-
|
|
5
|
-
// @ts-ignore
|
|
6
4
|
import { PatternFormat, PatternFormatProps } from 'react-number-format';
|
|
7
5
|
import { InputProps } from '../types';
|
|
8
6
|
import { twMerge } from 'tailwind-merge';
|
package/components/link.tsx
CHANGED
|
@@ -10,9 +10,7 @@ type LinkProps = Omit<
|
|
|
10
10
|
React.AnchorHTMLAttributes<HTMLAnchorElement>,
|
|
11
11
|
keyof NextLinkProps
|
|
12
12
|
> &
|
|
13
|
-
NextLinkProps
|
|
14
|
-
href: string;
|
|
15
|
-
};
|
|
13
|
+
NextLinkProps;
|
|
16
14
|
|
|
17
15
|
export const Link = ({ children, href, ...rest }: LinkProps) => {
|
|
18
16
|
const { locale, defaultLocaleValue, localeUrlStrategy } = useLocalization();
|
|
@@ -28,21 +26,19 @@ export const Link = ({ children, href, ...rest }: LinkProps) => {
|
|
|
28
26
|
return href;
|
|
29
27
|
}
|
|
30
28
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
return hrefWithLocale;
|
|
42
|
-
}
|
|
29
|
+
const pathnameWithoutLocale = href.replace(urlLocaleMatcherRegex, '');
|
|
30
|
+
const hrefWithLocale = `/${locale}${pathnameWithoutLocale}`;
|
|
31
|
+
|
|
32
|
+
if (localeUrlStrategy === LocaleUrlStrategy.ShowAllLocales) {
|
|
33
|
+
return hrefWithLocale;
|
|
34
|
+
} else if (
|
|
35
|
+
localeUrlStrategy === LocaleUrlStrategy.HideDefaultLocale &&
|
|
36
|
+
locale !== defaultLocaleValue
|
|
37
|
+
) {
|
|
38
|
+
return hrefWithLocale;
|
|
43
39
|
}
|
|
44
40
|
|
|
45
|
-
return href;
|
|
41
|
+
return href || '#';
|
|
46
42
|
}, [href, defaultLocaleValue, locale, localeUrlStrategy]);
|
|
47
43
|
|
|
48
44
|
return (
|
package/data/server/flatpage.ts
CHANGED
|
@@ -7,8 +7,7 @@ import { ServerVariables } from '../../utils/server-variables';
|
|
|
7
7
|
const getFlatPageDataHandler = (
|
|
8
8
|
pk: number,
|
|
9
9
|
locale: string,
|
|
10
|
-
currency: string
|
|
11
|
-
headers?: Record<string, string>
|
|
10
|
+
currency: string
|
|
12
11
|
) => {
|
|
13
12
|
return async function () {
|
|
14
13
|
const data = await appFetch<FlatPage>({
|
|
@@ -18,8 +17,7 @@ const getFlatPageDataHandler = (
|
|
|
18
17
|
init: {
|
|
19
18
|
headers: {
|
|
20
19
|
Accept: 'application/json',
|
|
21
|
-
'Content-Type': 'application/json'
|
|
22
|
-
...(headers ?? {})
|
|
20
|
+
'Content-Type': 'application/json'
|
|
23
21
|
}
|
|
24
22
|
}
|
|
25
23
|
});
|
|
@@ -31,17 +29,15 @@ const getFlatPageDataHandler = (
|
|
|
31
29
|
export const getFlatPageData = ({
|
|
32
30
|
pk,
|
|
33
31
|
locale = ServerVariables.locale,
|
|
34
|
-
currency = ServerVariables.currency
|
|
35
|
-
headers
|
|
32
|
+
currency = ServerVariables.currency
|
|
36
33
|
}: {
|
|
37
34
|
pk: number;
|
|
38
35
|
locale?: string;
|
|
39
36
|
currency?: string;
|
|
40
|
-
headers?: Record<string, string>;
|
|
41
37
|
}) => {
|
|
42
38
|
return Cache.wrap(
|
|
43
39
|
CacheKey.FlatPage(pk),
|
|
44
40
|
locale,
|
|
45
|
-
getFlatPageDataHandler(pk, locale, currency
|
|
41
|
+
getFlatPageDataHandler(pk, locale, currency)
|
|
46
42
|
);
|
|
47
43
|
};
|
package/data/server/form.ts
CHANGED
|
@@ -5,12 +5,7 @@ import appFetch from '../../utils/app-fetch';
|
|
|
5
5
|
import { ServerVariables } from '../../utils/server-variables';
|
|
6
6
|
import { form } from '../urls';
|
|
7
7
|
|
|
8
|
-
const getFormDataHandler = (
|
|
9
|
-
pk: number,
|
|
10
|
-
locale: string,
|
|
11
|
-
currency: string,
|
|
12
|
-
headers?: Record<string, string>
|
|
13
|
-
) => {
|
|
8
|
+
const getFormDataHandler = (pk: number, locale: string, currency: string) => {
|
|
14
9
|
return async function () {
|
|
15
10
|
const data = await appFetch<FormType>({
|
|
16
11
|
url: form.getForm(pk),
|
|
@@ -19,8 +14,7 @@ const getFormDataHandler = (
|
|
|
19
14
|
init: {
|
|
20
15
|
headers: {
|
|
21
16
|
Accept: 'application/json',
|
|
22
|
-
'Content-Type': 'application/json'
|
|
23
|
-
...(headers ?? {})
|
|
17
|
+
'Content-Type': 'application/json'
|
|
24
18
|
}
|
|
25
19
|
}
|
|
26
20
|
});
|
|
@@ -32,17 +26,15 @@ const getFormDataHandler = (
|
|
|
32
26
|
export const getFormData = ({
|
|
33
27
|
pk,
|
|
34
28
|
locale = ServerVariables.locale,
|
|
35
|
-
currency = ServerVariables.currency
|
|
36
|
-
headers
|
|
29
|
+
currency = ServerVariables.currency
|
|
37
30
|
}: {
|
|
38
31
|
pk: number;
|
|
39
32
|
locale?: string;
|
|
40
33
|
currency?: string;
|
|
41
|
-
headers?: Record<string, string>;
|
|
42
34
|
}) => {
|
|
43
35
|
return Cache.wrap(
|
|
44
36
|
CacheKey.Form(pk),
|
|
45
37
|
locale,
|
|
46
|
-
getFormDataHandler(pk, locale, currency
|
|
38
|
+
getFormDataHandler(pk, locale, currency)
|
|
47
39
|
);
|
|
48
40
|
};
|
|
@@ -7,8 +7,7 @@ import { ServerVariables } from '../../utils/server-variables';
|
|
|
7
7
|
const getLandingPageHandler = (
|
|
8
8
|
pk: number,
|
|
9
9
|
locale: string,
|
|
10
|
-
currency: string
|
|
11
|
-
headers?: Record<string, string>
|
|
10
|
+
currency: string
|
|
12
11
|
) => {
|
|
13
12
|
return async function () {
|
|
14
13
|
const data = await appFetch<LandingPage>({
|
|
@@ -18,8 +17,7 @@ const getLandingPageHandler = (
|
|
|
18
17
|
init: {
|
|
19
18
|
headers: {
|
|
20
19
|
Accept: 'application/json',
|
|
21
|
-
'Content-Type': 'application/json'
|
|
22
|
-
...(headers ?? {})
|
|
20
|
+
'Content-Type': 'application/json'
|
|
23
21
|
}
|
|
24
22
|
}
|
|
25
23
|
});
|
|
@@ -31,17 +29,15 @@ const getLandingPageHandler = (
|
|
|
31
29
|
export const getLandingPageData = ({
|
|
32
30
|
pk,
|
|
33
31
|
locale = ServerVariables.locale,
|
|
34
|
-
currency = ServerVariables.currency
|
|
35
|
-
headers
|
|
32
|
+
currency = ServerVariables.currency
|
|
36
33
|
}: {
|
|
37
34
|
pk: number;
|
|
38
35
|
locale?: string;
|
|
39
36
|
currency?: string;
|
|
40
|
-
headers?: Record<string, string>;
|
|
41
37
|
}) => {
|
|
42
38
|
return Cache.wrap(
|
|
43
39
|
CacheKey.LandingPage(pk),
|
|
44
40
|
locale,
|
|
45
|
-
getLandingPageHandler(pk, locale, currency
|
|
41
|
+
getLandingPageHandler(pk, locale, currency)
|
|
46
42
|
);
|
|
47
43
|
};
|
package/data/server/menu.ts
CHANGED
|
@@ -13,7 +13,6 @@ interface MenuHandlerParams {
|
|
|
13
13
|
currency?: string;
|
|
14
14
|
depth?: number;
|
|
15
15
|
parent?: string;
|
|
16
|
-
headers?: Record<string, string>;
|
|
17
16
|
}
|
|
18
17
|
|
|
19
18
|
const DEFAULT_DEPTH = 3;
|
|
@@ -23,17 +22,13 @@ const getMenuHandler =
|
|
|
23
22
|
locale = ServerVariables.locale,
|
|
24
23
|
currency = ServerVariables.currency,
|
|
25
24
|
depth,
|
|
26
|
-
parent
|
|
27
|
-
headers
|
|
25
|
+
parent
|
|
28
26
|
}: MenuHandlerParams = {}) =>
|
|
29
27
|
async () => {
|
|
30
28
|
const response = await appFetch<MenuResponse>({
|
|
31
29
|
url: misc.menus(depth ?? DEFAULT_DEPTH, parent),
|
|
32
30
|
locale,
|
|
33
|
-
currency
|
|
34
|
-
init: {
|
|
35
|
-
headers
|
|
36
|
-
}
|
|
31
|
+
currency
|
|
37
32
|
});
|
|
38
33
|
|
|
39
34
|
return response?.menu;
|
package/data/server/product.ts
CHANGED
|
@@ -11,7 +11,6 @@ type GetProduct = {
|
|
|
11
11
|
currency?: string;
|
|
12
12
|
searchParams?: URLSearchParams;
|
|
13
13
|
groupProduct?: boolean;
|
|
14
|
-
headers?: Record<string, string>;
|
|
15
14
|
};
|
|
16
15
|
|
|
17
16
|
const getProductDataHandler = ({
|
|
@@ -19,8 +18,7 @@ const getProductDataHandler = ({
|
|
|
19
18
|
locale,
|
|
20
19
|
currency,
|
|
21
20
|
searchParams,
|
|
22
|
-
groupProduct
|
|
23
|
-
headers
|
|
21
|
+
groupProduct
|
|
24
22
|
}: GetProduct) => {
|
|
25
23
|
return async function () {
|
|
26
24
|
let url = groupProduct
|
|
@@ -42,8 +40,7 @@ const getProductDataHandler = ({
|
|
|
42
40
|
init: {
|
|
43
41
|
headers: {
|
|
44
42
|
Accept: 'application/json',
|
|
45
|
-
'Content-Type': 'application/json'
|
|
46
|
-
...(headers ?? {})
|
|
43
|
+
'Content-Type': 'application/json'
|
|
47
44
|
}
|
|
48
45
|
}
|
|
49
46
|
});
|
|
@@ -98,8 +95,7 @@ export const getProductData = async ({
|
|
|
98
95
|
locale = ServerVariables.locale,
|
|
99
96
|
currency = ServerVariables.currency,
|
|
100
97
|
searchParams,
|
|
101
|
-
groupProduct
|
|
102
|
-
headers
|
|
98
|
+
groupProduct
|
|
103
99
|
}: GetProduct) => {
|
|
104
100
|
return Cache.wrap(
|
|
105
101
|
CacheKey[groupProduct ? 'GroupProduct' : 'Product'](
|
|
@@ -107,14 +103,7 @@ export const getProductData = async ({
|
|
|
107
103
|
searchParams ?? new URLSearchParams()
|
|
108
104
|
),
|
|
109
105
|
locale,
|
|
110
|
-
getProductDataHandler({
|
|
111
|
-
pk,
|
|
112
|
-
locale,
|
|
113
|
-
currency,
|
|
114
|
-
searchParams,
|
|
115
|
-
groupProduct,
|
|
116
|
-
headers
|
|
117
|
-
}),
|
|
106
|
+
getProductDataHandler({ pk, locale, currency, searchParams, groupProduct }),
|
|
118
107
|
{
|
|
119
108
|
expire: 300
|
|
120
109
|
}
|
package/data/server/seo.ts
CHANGED
|
@@ -7,10 +7,9 @@ interface SeoDataParams {
|
|
|
7
7
|
url: string;
|
|
8
8
|
locale?: string;
|
|
9
9
|
currency?: string;
|
|
10
|
-
headers?: Record<string, string>;
|
|
11
10
|
}
|
|
12
11
|
|
|
13
|
-
function getSeoDataHandler({ url, locale, currency
|
|
12
|
+
function getSeoDataHandler({ url, locale, currency }: SeoDataParams) {
|
|
14
13
|
return async function () {
|
|
15
14
|
let data = {} as {
|
|
16
15
|
title: string;
|
|
@@ -20,12 +19,7 @@ function getSeoDataHandler({ url, locale, currency, headers }: SeoDataParams) {
|
|
|
20
19
|
};
|
|
21
20
|
|
|
22
21
|
try {
|
|
23
|
-
data = await appFetch({
|
|
24
|
-
url: misc.cmsSeo(url),
|
|
25
|
-
locale,
|
|
26
|
-
currency,
|
|
27
|
-
init: { headers }
|
|
28
|
-
});
|
|
22
|
+
data = await appFetch({ url: misc.cmsSeo(url), locale, currency });
|
|
29
23
|
} catch (error) {
|
|
30
24
|
// logger.error('Error while fetching seo data', { url, error });
|
|
31
25
|
}
|
|
@@ -37,12 +31,11 @@ function getSeoDataHandler({ url, locale, currency, headers }: SeoDataParams) {
|
|
|
37
31
|
export const getSeoData = async (
|
|
38
32
|
url,
|
|
39
33
|
locale = ServerVariables.locale,
|
|
40
|
-
currency = ServerVariables.currency
|
|
41
|
-
headers?: Record<string, string>
|
|
34
|
+
currency = ServerVariables.currency
|
|
42
35
|
) => {
|
|
43
36
|
return Cache.wrap(
|
|
44
37
|
CacheKey.Seo(url),
|
|
45
38
|
locale,
|
|
46
|
-
getSeoDataHandler({ url, locale, currency
|
|
39
|
+
getSeoDataHandler({ url, locale, currency })
|
|
47
40
|
);
|
|
48
41
|
};
|
package/data/server/widget.ts
CHANGED
|
@@ -6,44 +6,29 @@ import { widgets } from '../urls';
|
|
|
6
6
|
import { ServerVariables } from '../../utils/server-variables';
|
|
7
7
|
|
|
8
8
|
const getWidgetDataHandler =
|
|
9
|
-
(
|
|
10
|
-
slug: string,
|
|
11
|
-
locale: string,
|
|
12
|
-
currency: string,
|
|
13
|
-
headers?: Record<string, string>
|
|
14
|
-
) =>
|
|
15
|
-
async () => {
|
|
9
|
+
(slug: string, locale: string, currency: string) => async () => {
|
|
16
10
|
if (!slug) {
|
|
17
11
|
return null;
|
|
18
12
|
}
|
|
19
13
|
|
|
20
|
-
return await appFetch({
|
|
21
|
-
url: widgets.getWidget(slug),
|
|
22
|
-
locale,
|
|
23
|
-
currency,
|
|
24
|
-
init: {
|
|
25
|
-
headers
|
|
26
|
-
}
|
|
27
|
-
});
|
|
14
|
+
return await appFetch({ url: widgets.getWidget(slug), locale, currency });
|
|
28
15
|
};
|
|
29
16
|
|
|
30
17
|
export const getWidgetData = async <T>({
|
|
31
18
|
slug,
|
|
32
19
|
locale = ServerVariables.locale,
|
|
33
20
|
currency = ServerVariables.currency,
|
|
34
|
-
cacheOptions
|
|
35
|
-
headers
|
|
21
|
+
cacheOptions
|
|
36
22
|
}: {
|
|
37
23
|
slug: string;
|
|
38
24
|
locale?: string;
|
|
39
25
|
currency?: string;
|
|
40
26
|
cacheOptions?: CacheOptions;
|
|
41
|
-
headers?: Record<string, string>;
|
|
42
27
|
}): Promise<WidgetResultType<T>> => {
|
|
43
28
|
return Cache.wrap(
|
|
44
29
|
CacheKey.Widget(slug),
|
|
45
30
|
locale,
|
|
46
|
-
getWidgetDataHandler(slug, locale, currency
|
|
31
|
+
getWidgetDataHandler(slug, locale, currency),
|
|
47
32
|
cacheOptions
|
|
48
33
|
);
|
|
49
34
|
};
|
|
@@ -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'
|
package/instrumentation/index.ts
CHANGED
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
import { initSentry } from '../sentry';
|
|
2
|
-
|
|
3
1
|
export async function register() {
|
|
4
2
|
if (process.env.NEXT_RUNTIME === 'nodejs') {
|
|
5
3
|
await import('./node');
|
|
6
|
-
initSentry('Server');
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
if (process.env.NEXT_RUNTIME === 'edge') {
|
|
10
|
-
initSentry('Edge');
|
|
11
4
|
}
|
|
12
5
|
}
|
package/lib/cache-handler.mjs
CHANGED
|
@@ -23,10 +23,10 @@ CacheHandler.onCreation(async () => {
|
|
|
23
23
|
timeoutMs: 5000
|
|
24
24
|
});
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
const localHandler = createLruHandler();
|
|
27
27
|
|
|
28
28
|
return {
|
|
29
|
-
handlers: [redisHandler]
|
|
29
|
+
handlers: [redisHandler, localHandler]
|
|
30
30
|
};
|
|
31
31
|
});
|
|
32
32
|
|
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,
|
|
@@ -145,8 +145,7 @@ const withCompleteGpay =
|
|
|
145
145
|
logger.info('Redirecting to order success page', {
|
|
146
146
|
middleware: 'complete-gpay',
|
|
147
147
|
redirectUrlWithLocale,
|
|
148
|
-
ip
|
|
149
|
-
setCookie: request.headers.get('set-cookie')
|
|
148
|
+
ip
|
|
150
149
|
});
|
|
151
150
|
|
|
152
151
|
// Using POST method while redirecting causes an error,
|
|
@@ -145,8 +145,7 @@ const withCompleteMasterpass =
|
|
|
145
145
|
logger.info('Redirecting to order success page', {
|
|
146
146
|
middleware: 'complete-masterpass',
|
|
147
147
|
redirectUrlWithLocale,
|
|
148
|
-
ip
|
|
149
|
-
setCookie: request.headers.get('set-cookie')
|
|
148
|
+
ip
|
|
150
149
|
});
|
|
151
150
|
|
|
152
151
|
// Using POST method while redirecting causes an error,
|
package/middlewares/default.ts
CHANGED
|
@@ -285,9 +285,7 @@ const withPzDefault =
|
|
|
285
285
|
url.pathname =
|
|
286
286
|
url.pathname +
|
|
287
287
|
(/\/$/.test(url.pathname) ? '' : '/') +
|
|
288
|
-
`searchparams|${url.searchParams
|
|
289
|
-
.toString()
|
|
290
|
-
.replace(/%26/g, '--amp--')}`;
|
|
288
|
+
`searchparams|${url.searchParams.toString()}`;
|
|
291
289
|
}
|
|
292
290
|
|
|
293
291
|
if (
|
|
@@ -146,8 +146,7 @@ const withRedirectionPayment =
|
|
|
146
146
|
logger.info('Redirecting to order success page', {
|
|
147
147
|
middleware: 'redirection-payment',
|
|
148
148
|
redirectUrlWithLocale,
|
|
149
|
-
ip
|
|
150
|
-
setCookie: request.headers.get('set-cookie')
|
|
149
|
+
ip
|
|
151
150
|
});
|
|
152
151
|
|
|
153
152
|
// Using POST method while redirecting causes an error,
|
|
@@ -145,8 +145,7 @@ const withSavedCardRedirection =
|
|
|
145
145
|
logger.info('Redirecting to order success page', {
|
|
146
146
|
middleware: 'saved-card-redirection',
|
|
147
147
|
redirectUrlWithLocale,
|
|
148
|
-
ip
|
|
149
|
-
setCookie: request.headers.get('set-cookie')
|
|
148
|
+
ip
|
|
150
149
|
});
|
|
151
150
|
|
|
152
151
|
// Using POST method while redirecting causes an error,
|
|
@@ -145,8 +145,7 @@ const withThreeDRedirection =
|
|
|
145
145
|
logger.info('Redirecting to order success page', {
|
|
146
146
|
middleware: 'three-d-redirection',
|
|
147
147
|
redirectUrlWithLocale,
|
|
148
|
-
ip
|
|
149
|
-
setCookie: request.headers.get('set-cookie')
|
|
148
|
+
ip
|
|
150
149
|
});
|
|
151
150
|
|
|
152
151
|
// Using POST method while redirecting causes an error,
|
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": "
|
|
4
|
+
"version": "2.0.0-beta.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": "
|
|
33
|
+
"@akinon/eslint-plugin-projectzero": "2.0.0-beta.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/order.ts
CHANGED
package/utils/app-fetch.ts
CHANGED
|
@@ -43,12 +43,12 @@ const appFetch = async <T>({
|
|
|
43
43
|
const requestURL = `${decodeURIComponent(commerceUrl)}${url}`;
|
|
44
44
|
|
|
45
45
|
init.headers = {
|
|
46
|
-
cookie: nextCookies.toString(),
|
|
47
46
|
...(init.headers ?? {}),
|
|
48
47
|
...(ServerVariables.globalHeaders ?? {}),
|
|
49
48
|
'Accept-Language': currentLocale.apiValue,
|
|
50
49
|
'x-currency': currency,
|
|
51
|
-
'x-forwarded-for': ip
|
|
50
|
+
'x-forwarded-for': ip,
|
|
51
|
+
cookie: nextCookies.toString()
|
|
52
52
|
};
|
|
53
53
|
|
|
54
54
|
init.next = {
|
package/with-pz-config.js
CHANGED
package/data/server/basket.ts
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { Cache, CacheKey } from '../../lib/cache';
|
|
2
|
-
import { basket } from '../../data/urls';
|
|
3
|
-
import { Basket } from '../../types';
|
|
4
|
-
import appFetch from '../../utils/app-fetch';
|
|
5
|
-
import { ServerVariables } from '../../utils/server-variables';
|
|
6
|
-
import logger from '../../utils/log';
|
|
7
|
-
|
|
8
|
-
type GetBasketParams = {
|
|
9
|
-
locale?: string;
|
|
10
|
-
currency?: string;
|
|
11
|
-
namespace?: string;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
const getBasketDataHandler = ({
|
|
15
|
-
locale,
|
|
16
|
-
currency,
|
|
17
|
-
namespace
|
|
18
|
-
}: GetBasketParams) => {
|
|
19
|
-
return async function () {
|
|
20
|
-
try {
|
|
21
|
-
const url = namespace
|
|
22
|
-
? basket.getBasketDetail(namespace)
|
|
23
|
-
: basket.getBasket;
|
|
24
|
-
|
|
25
|
-
const basketData = await appFetch<{ basket: Basket }>({
|
|
26
|
-
url,
|
|
27
|
-
locale,
|
|
28
|
-
currency,
|
|
29
|
-
init: {
|
|
30
|
-
headers: {
|
|
31
|
-
Accept: 'application/json',
|
|
32
|
-
'Content-Type': 'application/json'
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
if (!basketData?.basket) {
|
|
38
|
-
logger.warn('Basket data is undefined', {
|
|
39
|
-
handler: 'getBasketDataHandler',
|
|
40
|
-
namespace
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return basketData;
|
|
45
|
-
} catch (error) {
|
|
46
|
-
logger.error('Error fetching basket data', {
|
|
47
|
-
handler: 'getBasketDataHandler',
|
|
48
|
-
error,
|
|
49
|
-
namespace
|
|
50
|
-
});
|
|
51
|
-
throw error;
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
export const getBasketData = async ({
|
|
57
|
-
locale = ServerVariables.locale,
|
|
58
|
-
currency = ServerVariables.currency,
|
|
59
|
-
namespace
|
|
60
|
-
}: GetBasketParams = {}) => {
|
|
61
|
-
return Cache.wrap(
|
|
62
|
-
CacheKey.Basket(namespace),
|
|
63
|
-
locale,
|
|
64
|
-
getBasketDataHandler({ locale, currency, namespace }),
|
|
65
|
-
{
|
|
66
|
-
expire: 0,
|
|
67
|
-
cache: false
|
|
68
|
-
}
|
|
69
|
-
);
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
|