@akinon/next 1.101.0-rc.76 → 1.101.0-snapshot-ZERO-3615-20250924121313

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 (45) hide show
  1. package/CHANGELOG.md +46 -1327
  2. package/__tests__/next-config.test.ts +10 -1
  3. package/bin/pz-prebuild.js +0 -1
  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 +4 -32
  10. package/data/client/checkout.ts +2 -4
  11. package/data/server/category.ts +24 -44
  12. package/data/server/flatpage.ts +12 -16
  13. package/data/server/landingpage.ts +12 -16
  14. package/data/server/list.ts +13 -23
  15. package/data/server/product.ts +55 -38
  16. package/data/server/special-page.ts +12 -16
  17. package/data/urls.ts +2 -6
  18. package/hocs/server/with-segment-defaults.tsx +2 -5
  19. package/hooks/use-localization.ts +3 -2
  20. package/middlewares/complete-gpay.ts +1 -2
  21. package/middlewares/complete-masterpass.ts +1 -2
  22. package/middlewares/default.ts +0 -50
  23. package/middlewares/index.ts +0 -1
  24. package/middlewares/locale.ts +1 -9
  25. package/middlewares/pretty-url.ts +0 -2
  26. package/middlewares/redirection-payment.ts +1 -2
  27. package/middlewares/saved-card-redirection.ts +1 -2
  28. package/middlewares/three-d-redirection.ts +2 -2
  29. package/middlewares/url-redirection.ts +14 -8
  30. package/package.json +2 -2
  31. package/plugins.d.ts +5 -8
  32. package/plugins.js +1 -3
  33. package/redux/middlewares/checkout.ts +2 -6
  34. package/types/commerce/order.ts +0 -1
  35. package/types/index.ts +1 -34
  36. package/utils/app-fetch.ts +2 -7
  37. package/utils/redirect.ts +3 -22
  38. package/with-pz-config.js +5 -1
  39. package/__tests__/redirect.test.ts +0 -319
  40. package/api/form.ts +0 -84
  41. package/api/image-proxy.ts +0 -75
  42. package/api/similar-product-list.ts +0 -84
  43. package/api/similar-products.ts +0 -120
  44. package/data/server/basket.ts +0 -72
  45. package/utils/redirect-ignore.ts +0 -35
@@ -1,120 +0,0 @@
1
- import { NextResponse } from 'next/server';
2
- import Settings from 'settings';
3
-
4
- const IMAGE_SEARCH_API_URL = Settings.commerceUrl + '/image-search/';
5
-
6
- const errorResponse = (message: string, status: number) => {
7
- return NextResponse.json({ error: message }, { status });
8
- };
9
-
10
- export async function GET(request: Request) {
11
- const { searchParams } = new URL(request.url);
12
- const limit = searchParams.get('limit') || '20';
13
- const url = searchParams.get('url');
14
- const excludedProductIds = searchParams.get('excluded_product_ids');
15
- const text = searchParams.get('text');
16
-
17
- if (!url) {
18
- return errorResponse('URL parameter is required', 400);
19
- }
20
-
21
- if (Settings.commerceUrl === 'default') {
22
- return errorResponse('Commerce URL is not configured', 500);
23
- }
24
-
25
- const apiParams = new URLSearchParams();
26
- apiParams.append('limit', limit);
27
- apiParams.append('url', url);
28
-
29
- if (excludedProductIds) {
30
- apiParams.append('excluded_product_ids', excludedProductIds);
31
- }
32
-
33
- if (text) {
34
- apiParams.append('text', text);
35
- }
36
-
37
- const apiUrl = `${IMAGE_SEARCH_API_URL}?${apiParams.toString()}`;
38
-
39
- try {
40
- const response = await fetch(apiUrl, {
41
- method: 'GET',
42
- headers: {
43
- Accept: 'application/json'
44
- }
45
- });
46
-
47
- if (!response.ok) {
48
- const errorText = await response.text();
49
- return errorResponse(
50
- errorText || `API request failed with status: ${response.status}`,
51
- response.status
52
- );
53
- }
54
-
55
- const responseText = await response.text();
56
-
57
- return NextResponse.json(JSON.parse(responseText));
58
- } catch (error) {
59
- return errorResponse((error as Error).message, 500);
60
- }
61
- }
62
-
63
- export async function POST(request: Request) {
64
- const { searchParams } = new URL(request.url);
65
- const limit = searchParams.get('limit') || '20';
66
-
67
- if (Settings.commerceUrl === 'default') {
68
- return errorResponse('Commerce URL is not configured', 500);
69
- }
70
-
71
- let requestBody;
72
- try {
73
- requestBody = await request.json();
74
- } catch (error) {
75
- return errorResponse('Invalid JSON in request body', 400);
76
- }
77
-
78
- if (!requestBody.image) {
79
- return errorResponse('Image data is required in request body', 400);
80
- }
81
-
82
- const apiParams = new URLSearchParams();
83
- apiParams.append('limit', limit);
84
-
85
- const apiUrl = `${IMAGE_SEARCH_API_URL}?${apiParams.toString()}`;
86
-
87
- const bodyData: any = { image: requestBody.image };
88
-
89
- if (requestBody.excluded_product_ids) {
90
- bodyData.excluded_product_ids = requestBody.excluded_product_ids;
91
- }
92
-
93
- if (requestBody.text) {
94
- bodyData.text = requestBody.text;
95
- }
96
-
97
- try {
98
- const response = await fetch(apiUrl, {
99
- method: 'POST',
100
- headers: {
101
- 'Content-Type': 'application/json',
102
- Accept: 'application/json'
103
- },
104
- body: JSON.stringify(bodyData)
105
- });
106
-
107
- if (!response.ok) {
108
- const errorText = await response.text();
109
- return errorResponse(
110
- errorText || `API request failed with status: ${response.status}`,
111
- response.status
112
- );
113
- }
114
-
115
- const responseData = await response.json();
116
- return NextResponse.json(responseData);
117
- } catch (error) {
118
- return errorResponse((error as Error).message, 500);
119
- }
120
- }
@@ -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
-
@@ -1,35 +0,0 @@
1
- import settings from 'settings';
2
- import { getUrlPathWithLocale } from './localization';
3
-
4
- type IgnorePath = string | RegExp;
5
-
6
- const defaultIgnoreList: string[] = [];
7
-
8
- const extraIgnores: IgnorePath[] = Array.isArray(
9
- settings.commerceRedirectionIgnoreList
10
- )
11
- ? settings.commerceRedirectionIgnoreList.map((path) => {
12
- if (path === '/users/reset') {
13
- return /^\/users\/reset\/[^/]+\/[^/]+\/$/;
14
- }
15
- return path;
16
- })
17
- : [];
18
-
19
- export function shouldIgnoreRedirect(
20
- pathname: string,
21
- locale: string
22
- ): boolean {
23
- if (!pathname) return false;
24
-
25
- const rawIgnoreList: IgnorePath[] = [...defaultIgnoreList, ...extraIgnores];
26
-
27
- return rawIgnoreList.some((ignorePath) => {
28
- if (ignorePath instanceof RegExp) {
29
- return ignorePath.test(pathname);
30
- }
31
-
32
- const localized = getUrlPathWithLocale(ignorePath, locale);
33
- return localized === pathname;
34
- });
35
- }