@akinon/next 1.101.0-snapshot-ZERO-3615-20250924130435 → 1.101.0-snapshot-ZERO-3653-20250925093957

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 CHANGED
@@ -1,10 +1,11 @@
1
1
  # @akinon/next
2
2
 
3
- ## 1.101.0-snapshot-ZERO-3615-20250924130435
3
+ ## 1.101.0-snapshot-ZERO-3653-20250925093957
4
4
 
5
5
  ### Minor Changes
6
6
 
7
- - 6b949cb: ZERO-3615: Refactor product data handling and improve 404 error handling
7
+ - 4ca44c7: ZERO-3634: add register_consumer_card
8
+ - 5b50079: ZERO-3634: iyzico saved card
8
9
 
9
10
  ## 1.100.0
10
11
 
@@ -47,6 +47,7 @@ export enum Component {
47
47
  AkifastCheckoutButton = 'CheckoutButton',
48
48
  MultiBasket = 'MultiBasket',
49
49
  SavedCard = 'SavedCardOption',
50
+ IyzicoSavedCard = 'IyzicoSavedCardOption',
50
51
  FlowPayment = 'FlowPayment'
51
52
  }
52
53
 
@@ -80,7 +81,7 @@ const PluginComponents = new Map([
80
81
  [Component.AkifastQuickLoginButton, Component.AkifastCheckoutButton]
81
82
  ],
82
83
  [Plugin.MultiBasket, [Component.MultiBasket]],
83
- [Plugin.SavedCard, [Component.SavedCard]],
84
+ [Plugin.SavedCard, [Component.SavedCard, Component.IyzicoSavedCard]],
84
85
  [Plugin.FlowPayment, [Component.FlowPayment]]
85
86
  ]);
86
87
 
@@ -6,7 +6,7 @@ import { ServerVariables } from '../../utils/server-variables';
6
6
  import logger from '../../utils/log';
7
7
 
8
8
  type GetProduct = {
9
- pk: number | string;
9
+ pk: number;
10
10
  locale?: string;
11
11
  currency?: string;
12
12
  searchParams?: URLSearchParams;
@@ -23,21 +23,9 @@ const getProductDataHandler = ({
23
23
  headers
24
24
  }: GetProduct) => {
25
25
  return async function () {
26
- // Convert pk to number if it's a string and validate
27
- const numericPk = typeof pk === 'string' ? parseInt(pk, 10) : pk;
28
-
29
- if (isNaN(numericPk)) {
30
- logger.warn('Invalid product pk provided', {
31
- handler: 'getProductDataHandler',
32
- pk,
33
- numericPk
34
- });
35
- return null;
36
- }
37
-
38
26
  let url = groupProduct
39
- ? product.getGroupProductByPk(numericPk)
40
- : product.getProductByPk(numericPk);
27
+ ? product.getGroupProductByPk(pk)
28
+ : product.getProductByPk(pk);
41
29
 
42
30
  if (searchParams) {
43
31
  url +=
@@ -47,81 +35,61 @@ const getProductDataHandler = ({
47
35
  .join('&');
48
36
  }
49
37
 
50
- try {
51
- const data = await appFetch<ProductResult>({
52
- url,
53
- locale,
54
- currency,
55
- init: {
56
- headers: {
57
- Accept: 'application/json',
58
- 'Content-Type': 'application/json',
59
- ...(headers ?? {})
60
- }
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 ?? {})
61
47
  }
62
- });
63
-
64
- // If product data is not found, return null to trigger 404
65
- if (!data?.product?.pk) {
66
- logger.warn('Product not found', {
67
- handler: 'getProductDataHandler',
68
- pk: numericPk,
69
- hasData: !!data,
70
- hasProduct: !!data?.product
71
- });
72
- return null;
73
48
  }
49
+ });
74
50
 
75
- const categoryUrl = product.categoryUrl(data.product.pk);
51
+ const categoryUrl = product.categoryUrl(data.product.pk);
76
52
 
77
- const productCategoryData = await appFetch<ProductCategoryResult>({
78
- url: categoryUrl,
79
- locale,
80
- currency,
81
- init: {
82
- headers: {
83
- Accept: 'application/json',
84
- 'Content-Type': 'application/json'
85
- }
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'
86
61
  }
87
- });
88
-
89
- const menuItemModel = productCategoryData?.results[0]?.menuitemmodel;
90
-
91
- if (!menuItemModel) {
92
- logger.warn('menuItemModel is undefined, skipping breadcrumbData fetch', {
93
- handler: 'getProductDataHandler',
94
- pk: numericPk
95
- });
96
- return { data, breadcrumbData: undefined };
97
62
  }
63
+ });
98
64
 
99
- const breadcrumbUrl = product.breadcrumbUrl(menuItemModel);
65
+ const menuItemModel = productCategoryData?.results[0]?.menuitemmodel;
100
66
 
101
- const breadcrumbData = await appFetch<any>({
102
- url: breadcrumbUrl,
103
- locale,
104
- currency,
105
- init: {
106
- headers: {
107
- Accept: 'application/json',
108
- 'Content-Type': 'application/json'
109
- }
110
- }
111
- });
112
-
113
- return {
114
- data,
115
- breadcrumbData: breadcrumbData?.menu
116
- };
117
- } catch (error) {
118
- logger.error('Error in getProductDataHandler', {
67
+ if (!menuItemModel) {
68
+ logger.warn('menuItemModel is undefined, skipping breadcrumbData fetch', {
119
69
  handler: 'getProductDataHandler',
120
- pk: numericPk,
121
- error: error.message
70
+ pk
122
71
  });
123
- return null;
72
+ return { data, breadcrumbData: undefined };
124
73
  }
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
+
89
+ return {
90
+ data,
91
+ breadcrumbData: breadcrumbData?.menu
92
+ };
125
93
  };
126
94
  };
127
95
 
@@ -133,12 +101,9 @@ export const getProductData = async ({
133
101
  groupProduct,
134
102
  headers
135
103
  }: GetProduct) => {
136
- // Convert pk to number for cache key if it's a string
137
- const numericPkForCache = typeof pk === 'string' ? parseInt(pk, 10) : pk;
138
-
139
- const result = await Cache.wrap(
104
+ return Cache.wrap(
140
105
  CacheKey[groupProduct ? 'GroupProduct' : 'Product'](
141
- numericPkForCache,
106
+ pk,
142
107
  searchParams ?? new URLSearchParams()
143
108
  ),
144
109
  locale,
@@ -155,13 +120,4 @@ export const getProductData = async ({
155
120
  compressed: true
156
121
  }
157
122
  );
158
-
159
- // If product data is not found, throw 404 error
160
- if (!result) {
161
- const error = new Error('Product not found') as Error & { status: number };
162
- error.status = 404;
163
- throw error;
164
- }
165
-
166
- return result;
167
123
  };
@@ -214,6 +214,7 @@ const withPzDefault =
214
214
 
215
215
  req.middlewareParams = {
216
216
  commerceUrl,
217
+ found: true,
217
218
  rewrites: {}
218
219
  };
219
220
 
@@ -301,6 +302,19 @@ const withPzDefault =
301
302
  )}`;
302
303
  }
303
304
 
305
+ if (
306
+ !req.middlewareParams.found &&
307
+ Settings.customNotFoundEnabled
308
+ ) {
309
+ const pathname = url.pathname
310
+ .replace(/\/+$/, '')
311
+ .split('/');
312
+ url.pathname = url.pathname.replace(
313
+ pathname.pop(),
314
+ 'pz-not-found'
315
+ );
316
+ }
317
+
304
318
  Settings.rewrites.forEach((rewrite) => {
305
319
  url.pathname = url.pathname.replace(
306
320
  rewrite.source,
@@ -30,6 +30,7 @@ export {
30
30
  export interface PzNextRequest extends NextRequest {
31
31
  middlewareParams: {
32
32
  commerceUrl: string;
33
+ found: boolean;
33
34
  rewrites: {
34
35
  locale?: string;
35
36
  prettyUrl?: string;
@@ -123,6 +123,8 @@ const withPrettyUrl =
123
123
  return middleware(req, event);
124
124
  }
125
125
 
126
+ req.middlewareParams.found = false;
127
+
126
128
  return middleware(req, event);
127
129
  };
128
130
 
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.101.0-snapshot-ZERO-3615-20250924130435",
4
+ "version": "1.101.0-snapshot-ZERO-3653-20250925093957",
5
5
  "private": false,
6
6
  "license": "MIT",
7
7
  "bin": {
@@ -35,7 +35,7 @@
35
35
  "set-cookie-parser": "2.6.0"
36
36
  },
37
37
  "devDependencies": {
38
- "@akinon/eslint-plugin-projectzero": "1.101.0-snapshot-ZERO-3615-20250924130435",
38
+ "@akinon/eslint-plugin-projectzero": "1.101.0-snapshot-ZERO-3653-20250925093957",
39
39
  "@babel/core": "7.26.10",
40
40
  "@babel/preset-env": "7.26.9",
41
41
  "@babel/preset-typescript": "7.27.0",
package/plugins.d.ts CHANGED
@@ -31,11 +31,6 @@ declare module '@akinon/pz-saved-card' {
31
31
  export const SavedCardOption: any;
32
32
  }
33
33
 
34
- declare module '@akinon/pz-iyzico-saved-card' {
35
- export const iyzicoSavedCardReducer: any;
36
- export const iyzicoSavedCardMiddleware: any;
37
- }
38
-
39
34
  declare module '@akinon/pz-apple-pay' {}
40
35
 
41
36
  declare module '@akinon/pz-flow-payment' {}