@akinon/next 1.101.0-snapshot-ZERO-3653-20250925093957 → 1.101.0-snapshot-ZERO-3648-20250925201202

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,11 +1,10 @@
1
1
  # @akinon/next
2
2
 
3
- ## 1.101.0-snapshot-ZERO-3653-20250925093957
3
+ ## 1.101.0-snapshot-ZERO-3648-20250925201202
4
4
 
5
5
  ### Minor Changes
6
6
 
7
- - 4ca44c7: ZERO-3634: add register_consumer_card
8
- - 5b50079: ZERO-3634: iyzico saved card
7
+ - fcbbea7: ZERO-3648: Add virtual try-on feature with localization support
9
8
 
10
9
  ## 1.100.0
11
10
 
@@ -0,0 +1,209 @@
1
+ import { NextRequest, NextResponse } from 'next/server';
2
+
3
+ const VIRTUAL_TRY_ON_API_URL = process.env.NEXT_PUBLIC_VIRTUAL_TRY_ON_API_URL;
4
+
5
+ export async function GET(request: NextRequest) {
6
+ try {
7
+ const { searchParams } = new URL(request.url);
8
+ const endpoint = searchParams.get('endpoint');
9
+
10
+ if (endpoint === 'limited-categories') {
11
+ const externalUrl = `${VIRTUAL_TRY_ON_API_URL}/api/v1/limited-categories`;
12
+
13
+ const response = await fetch(externalUrl, {
14
+ method: 'GET',
15
+ headers: {
16
+ Accept: 'application/json',
17
+ ...(request.headers.get('authorization') && {
18
+ Authorization: request.headers.get('authorization')!
19
+ })
20
+ }
21
+ });
22
+
23
+ let responseData: any;
24
+ const responseText = await response.text();
25
+
26
+ try {
27
+ responseData = responseText ? JSON.parse(responseText) : {};
28
+ } catch (parseError) {
29
+ responseData = { category_ids: [] };
30
+ }
31
+
32
+ if (!response.ok) {
33
+ responseData = { category_ids: [] };
34
+ }
35
+
36
+ return NextResponse.json(responseData, {
37
+ status: response.ok ? response.status : 200,
38
+ headers: {
39
+ 'Access-Control-Allow-Origin': '*',
40
+ 'Access-Control-Allow-Methods': 'GET, POST, PUT, OPTIONS',
41
+ 'Access-Control-Allow-Headers': 'Content-Type, Accept, Authorization'
42
+ }
43
+ });
44
+ }
45
+
46
+ return NextResponse.json(
47
+ { error: 'Invalid endpoint for GET method' },
48
+ { status: 400 }
49
+ );
50
+ } catch (error) {
51
+ return NextResponse.json({ category_ids: [] }, { status: 200 });
52
+ }
53
+ }
54
+
55
+ export async function POST(request: NextRequest) {
56
+ try {
57
+ const { searchParams } = new URL(request.url);
58
+ const endpoint = searchParams.get('endpoint');
59
+
60
+ const body = await request.json();
61
+
62
+ let externalUrl: string;
63
+ if (endpoint === 'feedback') {
64
+ externalUrl = `${VIRTUAL_TRY_ON_API_URL}/api/v1/feedback`;
65
+ } else {
66
+ externalUrl = `${VIRTUAL_TRY_ON_API_URL}/api/v1/virtual-try-on`;
67
+ }
68
+
69
+ const httpMethod = endpoint === 'feedback' ? 'PUT' : 'POST';
70
+
71
+ const response = await fetch(externalUrl, {
72
+ method: httpMethod,
73
+ headers: {
74
+ 'Content-Type': 'application/json',
75
+ ...(httpMethod === 'POST' && { Accept: 'application/json' }),
76
+ ...(request.headers.get('authorization') && {
77
+ Authorization: request.headers.get('authorization')!
78
+ })
79
+ },
80
+ body: JSON.stringify(body)
81
+ });
82
+
83
+ let responseData: any;
84
+ const responseText = await response.text();
85
+
86
+ if (endpoint === 'feedback') {
87
+ try {
88
+ responseData = responseText ? JSON.parse(responseText) : {};
89
+ } catch (parseError) {
90
+ responseData = { error: 'Invalid JSON response from feedback API' };
91
+ }
92
+ } else {
93
+ try {
94
+ responseData = responseText ? JSON.parse(responseText) : {};
95
+ } catch (parseError) {
96
+ responseData = { error: 'Invalid JSON response' };
97
+ }
98
+ }
99
+
100
+ if (!response.ok && responseData.error) {
101
+ let userFriendlyMessage = responseData.error;
102
+
103
+ if (
104
+ typeof responseData.error === 'string' &&
105
+ (responseData.error.includes('duplicate key value') ||
106
+ responseData.error.includes('image_pk'))
107
+ ) {
108
+ userFriendlyMessage =
109
+ 'This image has already been processed. Please try with a different image.';
110
+ } else if (responseData.error.includes('bulk insert images')) {
111
+ userFriendlyMessage =
112
+ 'There was an issue processing your image. Please try again with a different image.';
113
+ }
114
+
115
+ return NextResponse.json(
116
+ {
117
+ ...responseData,
118
+ message: userFriendlyMessage
119
+ },
120
+ {
121
+ status: response.status,
122
+ headers: {
123
+ 'Access-Control-Allow-Origin': '*',
124
+ 'Access-Control-Allow-Methods': 'POST, OPTIONS',
125
+ 'Access-Control-Allow-Headers':
126
+ 'Content-Type, Accept, Authorization'
127
+ }
128
+ }
129
+ );
130
+ }
131
+
132
+ return NextResponse.json(responseData, {
133
+ status: response.status,
134
+ headers: {
135
+ 'Access-Control-Allow-Origin': '*',
136
+ 'Access-Control-Allow-Methods': 'POST, OPTIONS',
137
+ 'Access-Control-Allow-Headers': 'Content-Type, Accept, Authorization'
138
+ }
139
+ });
140
+ } catch (error) {
141
+ return NextResponse.json(
142
+ {
143
+ status: 'error',
144
+ message:
145
+ 'Internal server error occurred during virtual try-on processing'
146
+ },
147
+ { status: 500 }
148
+ );
149
+ }
150
+ }
151
+
152
+ export async function PUT(request: NextRequest) {
153
+ try {
154
+ const { searchParams } = new URL(request.url);
155
+ const endpoint = searchParams.get('endpoint');
156
+
157
+ if (endpoint !== 'feedback') {
158
+ return NextResponse.json(
159
+ { error: 'PUT method only supports feedback endpoint' },
160
+ { status: 400 }
161
+ );
162
+ }
163
+
164
+ const body = await request.json();
165
+
166
+ const externalUrl = `${VIRTUAL_TRY_ON_API_URL}/api/v1/feedback`;
167
+
168
+ const response = await fetch(externalUrl, {
169
+ method: 'PUT',
170
+ headers: {
171
+ 'Content-Type': 'application/json',
172
+ ...(request.headers.get('authorization') && {
173
+ Authorization: request.headers.get('authorization')!
174
+ })
175
+ },
176
+ body: JSON.stringify(body)
177
+ });
178
+
179
+ const responseData = await response.json();
180
+
181
+ return NextResponse.json(responseData, {
182
+ status: response.status,
183
+ headers: {
184
+ 'Access-Control-Allow-Origin': '*',
185
+ 'Access-Control-Allow-Methods': 'GET, POST, PUT, OPTIONS',
186
+ 'Access-Control-Allow-Headers': 'Content-Type, Accept, Authorization'
187
+ }
188
+ });
189
+ } catch (error) {
190
+ return NextResponse.json(
191
+ {
192
+ status: 'error',
193
+ message: 'Internal server error occurred during feedback submission'
194
+ },
195
+ { status: 500 }
196
+ );
197
+ }
198
+ }
199
+
200
+ export async function OPTIONS() {
201
+ return new NextResponse(null, {
202
+ status: 200,
203
+ headers: {
204
+ 'Access-Control-Allow-Origin': '*',
205
+ 'Access-Control-Allow-Methods': 'GET, POST, PUT, OPTIONS',
206
+ 'Access-Control-Allow-Headers': 'Content-Type, Accept, Authorization'
207
+ }
208
+ });
209
+ }
@@ -21,7 +21,8 @@ enum Plugin {
21
21
  Akifast = 'pz-akifast',
22
22
  MultiBasket = 'pz-multi-basket',
23
23
  SavedCard = 'pz-saved-card',
24
- FlowPayment = 'pz-flow-payment'
24
+ FlowPayment = 'pz-flow-payment',
25
+ VirtualTryOn = 'pz-virtual-try-on'
25
26
  }
26
27
 
27
28
  export enum Component {
@@ -47,8 +48,8 @@ export enum Component {
47
48
  AkifastCheckoutButton = 'CheckoutButton',
48
49
  MultiBasket = 'MultiBasket',
49
50
  SavedCard = 'SavedCardOption',
50
- IyzicoSavedCard = 'IyzicoSavedCardOption',
51
- FlowPayment = 'FlowPayment'
51
+ FlowPayment = 'FlowPayment',
52
+ VirtualTryOnPlugin = 'VirtualTryOnPlugin'
52
53
  }
53
54
 
54
55
  const PluginComponents = new Map([
@@ -81,8 +82,9 @@ const PluginComponents = new Map([
81
82
  [Component.AkifastQuickLoginButton, Component.AkifastCheckoutButton]
82
83
  ],
83
84
  [Plugin.MultiBasket, [Component.MultiBasket]],
84
- [Plugin.SavedCard, [Component.SavedCard, Component.IyzicoSavedCard]],
85
- [Plugin.FlowPayment, [Component.FlowPayment]]
85
+ [Plugin.SavedCard, [Component.SavedCard]],
86
+ [Plugin.FlowPayment, [Component.FlowPayment]],
87
+ [Plugin.VirtualTryOn, [Component.VirtualTryOnPlugin]]
86
88
  ]);
87
89
 
88
90
  const getPlugin = (component: Component) => {
@@ -149,6 +151,8 @@ export default function PluginModule({
149
151
  promise = import(`${'@akinon/pz-saved-card'}`);
150
152
  } else if (plugin === Plugin.FlowPayment) {
151
153
  promise = import(`${'@akinon/pz-flow-payment'}`);
154
+ } else if (plugin === Plugin.VirtualTryOn) {
155
+ promise = import(`${'@akinon/pz-virtual-try-on'}`);
152
156
  }
153
157
  } catch (error) {
154
158
  logger.error(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": "1.101.0-snapshot-ZERO-3653-20250925093957",
4
+ "version": "1.101.0-snapshot-ZERO-3648-20250925201202",
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-3653-20250925093957",
38
+ "@akinon/eslint-plugin-projectzero": "1.101.0-snapshot-ZERO-3648-20250925201202",
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,6 +31,11 @@ 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
+
34
39
  declare module '@akinon/pz-apple-pay' {}
35
40
 
36
41
  declare module '@akinon/pz-flow-payment' {}
package/plugins.js CHANGED
@@ -16,5 +16,6 @@ module.exports = [
16
16
  'pz-tabby-extension',
17
17
  'pz-apple-pay',
18
18
  'pz-tamara-extension',
19
- 'pz-flow-payment'
19
+ 'pz-flow-payment',
20
+ 'pz-virtual-try-on'
20
21
  ];