@akinon/next 2.0.34-rc.0 → 2.0.34
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 +2 -24
- package/api/virtual-try-on.ts +264 -242
- package/bin/pz-generate-routes.js +1 -4
- package/components/plugin-module.tsx +1 -0
- package/data/client/checkout.ts +1 -0
- package/data/server/category.ts +1 -13
- package/data/server/list.ts +0 -12
- package/data/server/product.ts +0 -10
- package/data/server/special-page.ts +0 -13
- package/data/server/widget.ts +1 -14
- package/data/urls.ts +4 -9
- package/hooks/use-captcha.tsx +1 -1
- package/middlewares/default.ts +205 -252
- package/package.json +2 -2
- package/plugins.d.ts +0 -10
- package/plugins.js +0 -1
- package/redux/middlewares/checkout.ts +3 -45
- package/redux/middlewares/pre-order/installment-option.ts +1 -9
- package/types/index.ts +9 -20
- package/utils/csrf.ts +1 -1
- package/with-pz-config.js +2 -3
- package/utils/payload-optimizer.ts +0 -481
package/data/server/category.ts
CHANGED
|
@@ -8,8 +8,6 @@ import { parse } from 'lossless-json';
|
|
|
8
8
|
import logger from '../../utils/log';
|
|
9
9
|
import { headers as nHeaders } from 'next/headers';
|
|
10
10
|
import { ServerVariables } from '../../utils/server-variables';
|
|
11
|
-
import { optimizeCategoryResponse } from '../../utils/payload-optimizer';
|
|
12
|
-
import settings from 'settings';
|
|
13
11
|
|
|
14
12
|
function getCategoryDataHandler(
|
|
15
13
|
pk: number,
|
|
@@ -83,7 +81,7 @@ function getCategoryDataHandler(
|
|
|
83
81
|
};
|
|
84
82
|
}
|
|
85
83
|
|
|
86
|
-
export const getCategoryData =
|
|
84
|
+
export const getCategoryData = ({
|
|
87
85
|
pk,
|
|
88
86
|
searchParams,
|
|
89
87
|
headers,
|
|
@@ -107,16 +105,6 @@ export const getCategoryData = async ({
|
|
|
107
105
|
compressed: true
|
|
108
106
|
}
|
|
109
107
|
);
|
|
110
|
-
|
|
111
|
-
if (settings.payloadOptimization?.enabled && result?.data) {
|
|
112
|
-
try {
|
|
113
|
-
return { ...result, data: optimizeCategoryResponse(result.data, settings.payloadOptimization) };
|
|
114
|
-
} catch (e) {
|
|
115
|
-
logger.error('Payload optimization failed for category', { pk, error: (e as Error).message });
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
return result;
|
|
120
108
|
};
|
|
121
109
|
|
|
122
110
|
function getCategoryBySlugDataHandler(
|
package/data/server/list.ts
CHANGED
|
@@ -7,8 +7,6 @@ import appFetch, { FetchResponseType } from '../../utils/app-fetch';
|
|
|
7
7
|
import { parse } from 'lossless-json';
|
|
8
8
|
import logger from '../../utils/log';
|
|
9
9
|
import { ServerVariables } from '../../utils/server-variables';
|
|
10
|
-
import { optimizeCategoryResponse } from '../../utils/payload-optimizer';
|
|
11
|
-
import settings from 'settings';
|
|
12
10
|
|
|
13
11
|
const getListDataHandler = (
|
|
14
12
|
locale,
|
|
@@ -80,14 +78,4 @@ export const getListData = async ({
|
|
|
80
78
|
compressed: true
|
|
81
79
|
}
|
|
82
80
|
);
|
|
83
|
-
|
|
84
|
-
if (settings.payloadOptimization?.enabled && result) {
|
|
85
|
-
try {
|
|
86
|
-
return optimizeCategoryResponse(result, settings.payloadOptimization);
|
|
87
|
-
} catch (e) {
|
|
88
|
-
logger.error('Payload optimization failed for list', { error: (e as Error).message });
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
return result;
|
|
93
81
|
};
|
package/data/server/product.ts
CHANGED
|
@@ -5,8 +5,6 @@ import appFetch from '../../utils/app-fetch';
|
|
|
5
5
|
import { normalizeSearchParams } from '../../utils/normalize-search-params';
|
|
6
6
|
import { ServerVariables } from '../../utils/server-variables';
|
|
7
7
|
import logger from '../../utils/log';
|
|
8
|
-
import { optimizeProductResponse } from '../../utils/payload-optimizer';
|
|
9
|
-
import settings from 'settings';
|
|
10
8
|
|
|
11
9
|
type GetProduct = {
|
|
12
10
|
pk: number | string;
|
|
@@ -168,13 +166,5 @@ export const getProductData = async ({
|
|
|
168
166
|
throw error;
|
|
169
167
|
}
|
|
170
168
|
|
|
171
|
-
if (settings.payloadOptimization?.enabled && result?.data) {
|
|
172
|
-
try {
|
|
173
|
-
return { ...result, data: optimizeProductResponse(result.data, settings.payloadOptimization) };
|
|
174
|
-
} catch (e) {
|
|
175
|
-
logger.error('Payload optimization failed for product', { pk, error: (e as Error).message });
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
|
|
179
169
|
return result;
|
|
180
170
|
};
|
|
@@ -5,9 +5,6 @@ import { generateCommerceSearchParams } from '../../utils';
|
|
|
5
5
|
import { normalizeSearchParams } from '../../utils/normalize-search-params';
|
|
6
6
|
import appFetch from '../../utils/app-fetch';
|
|
7
7
|
import { ServerVariables } from '../../utils/server-variables';
|
|
8
|
-
import { optimizeCategoryResponse } from '../../utils/payload-optimizer';
|
|
9
|
-
import logger from '../../utils/log';
|
|
10
|
-
import settings from 'settings';
|
|
11
8
|
|
|
12
9
|
const getSpecialPageDataHandler = (
|
|
13
10
|
pk: number,
|
|
@@ -60,14 +57,4 @@ export const getSpecialPageData = async ({
|
|
|
60
57
|
compressed: true
|
|
61
58
|
}
|
|
62
59
|
);
|
|
63
|
-
|
|
64
|
-
if (settings.payloadOptimization?.enabled && result) {
|
|
65
|
-
try {
|
|
66
|
-
return optimizeCategoryResponse(result, settings.payloadOptimization);
|
|
67
|
-
} catch (e) {
|
|
68
|
-
logger.error('Payload optimization failed for special-page', { pk, error: (e as Error).message });
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
return result;
|
|
73
60
|
};
|
package/data/server/widget.ts
CHANGED
|
@@ -4,9 +4,6 @@ import { CacheOptions, WidgetResultType, WidgetSchemaType } from '../../types';
|
|
|
4
4
|
import appFetch from '../../utils/app-fetch';
|
|
5
5
|
import { widgets } from '../urls';
|
|
6
6
|
import { ServerVariables } from '../../utils/server-variables';
|
|
7
|
-
import { optimizeWidgetResponse } from '../../utils/payload-optimizer';
|
|
8
|
-
import logger from '../../utils/log';
|
|
9
|
-
import settings from 'settings';
|
|
10
7
|
|
|
11
8
|
const getWidgetDataHandler =
|
|
12
9
|
(
|
|
@@ -56,7 +53,7 @@ export const getWidgetData = async <T>({
|
|
|
56
53
|
cacheOptions?: CacheOptions;
|
|
57
54
|
headers?: Record<string, string>;
|
|
58
55
|
}): Promise<WidgetResultType<T>> => {
|
|
59
|
-
|
|
56
|
+
return Cache.wrap(
|
|
60
57
|
CacheKey.Widget(slug),
|
|
61
58
|
locale,
|
|
62
59
|
getWidgetDataHandler(slug, locale, currency, headers),
|
|
@@ -65,16 +62,6 @@ export const getWidgetData = async <T>({
|
|
|
65
62
|
...cacheOptions
|
|
66
63
|
}
|
|
67
64
|
);
|
|
68
|
-
|
|
69
|
-
if (settings.payloadOptimization?.enabled && result) {
|
|
70
|
-
try {
|
|
71
|
-
return optimizeWidgetResponse(result, settings.payloadOptimization) as WidgetResultType<T>;
|
|
72
|
-
} catch (e) {
|
|
73
|
-
logger.error('Payload optimization failed for widget', { slug, error: (e as Error).message });
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
return result as WidgetResultType<T>;
|
|
78
65
|
};
|
|
79
66
|
|
|
80
67
|
const getCollectionWidgetDataHandler =
|
package/data/urls.ts
CHANGED
|
@@ -40,11 +40,10 @@ export const account = {
|
|
|
40
40
|
shipping_option_slug
|
|
41
41
|
? `&shipping_option_slug${shipping_option_operator}${shipping_option_slug}`
|
|
42
42
|
: ''
|
|
43
|
-
}${currency ? `¤cy=${currency}` : ''}
|
|
44
|
-
|
|
45
|
-
}`,
|
|
43
|
+
}${currency ? `¤cy=${currency}` : ''}
|
|
44
|
+
${filterType && filterValue ? `&${filterType}=${filterValue}` : ''}`,
|
|
46
45
|
getOldOrders: ({ page, limit }: { page?: number; limit?: number }) =>
|
|
47
|
-
`/users/old-orders/?page=${page || 1}&limit=${limit || 12}`,
|
|
46
|
+
`/users/old-orders/?page=${page || 1}&limit=${limit || 12}}`,
|
|
48
47
|
getQuotations: (page?: number, status?: string, limit?: number) =>
|
|
49
48
|
`/b2b/my-quotations/?page=${page || 1}` +
|
|
50
49
|
(status ? `&status=${status}` : '') +
|
|
@@ -184,11 +183,7 @@ export const product = {
|
|
|
184
183
|
breadcrumbUrl: (menuitemmodel: string) =>
|
|
185
184
|
`/menus/generate_breadcrumb/?item=${menuitemmodel}&generator_name=menu_item`,
|
|
186
185
|
bundleProduct: (productPk: string, queryString: string) =>
|
|
187
|
-
`/bundle-product/${productPk}/?${queryString}
|
|
188
|
-
similarProducts: (params?: string) =>
|
|
189
|
-
`/similar-products${params ? `?${params}` : ''}`,
|
|
190
|
-
similarProductsList: (params?: string) =>
|
|
191
|
-
`/similar-product-list${params ? `?${params}` : ''}`
|
|
186
|
+
`/bundle-product/${productPk}/?${queryString}`
|
|
192
187
|
};
|
|
193
188
|
|
|
194
189
|
export const wishlist = {
|
package/hooks/use-captcha.tsx
CHANGED