@akinon/next 1.110.0 → 1.111.0-snapshot-ZERO-3792-20251107072714

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,5 +1,11 @@
1
1
  # @akinon/next
2
2
 
3
+ ## 1.111.0-snapshot-ZERO-3792-20251107072714
4
+
5
+ ### Minor Changes
6
+
7
+ - 888fdec: ZERO-3792: Virtual Try On new features are implemented and also basket support implemented.
8
+
3
9
  ## 1.110.0
4
10
 
5
11
  ### Minor Changes
@@ -122,6 +122,55 @@ export async function GET(request: NextRequest) {
122
122
  'X-Virtual-Try-On-Cache-Status': 'MISS'
123
123
  }
124
124
  });
125
+ } else if (endpoint === 'job-status') {
126
+ const referenceUrl = searchParams.get('reference_url');
127
+ if (!referenceUrl) {
128
+ return NextResponse.json(
129
+ { error: 'reference_url is required' },
130
+ { status: 400 }
131
+ );
132
+ }
133
+
134
+ const externalUrl = `${VIRTUAL_TRY_ON_API_URL}/api/async/v1/job-status?reference_url=${encodeURIComponent(referenceUrl)}`;
135
+ const clientIP = getClientIP(request);
136
+ const locale = getLocaleFromRequest(request);
137
+
138
+ const headersToSend = {
139
+ Accept: 'application/json',
140
+ ...(locale && { 'Accept-Language': locale }),
141
+ ...(request.headers.get('authorization') && {
142
+ Authorization: request.headers.get('authorization')!
143
+ }),
144
+ ...(clientIP && {
145
+ 'X-Forwarded-For': clientIP
146
+ })
147
+ };
148
+
149
+ const response = await fetch(externalUrl, {
150
+ method: 'GET',
151
+ headers: headersToSend
152
+ });
153
+
154
+ let responseData: any;
155
+ const responseText = await response.text();
156
+
157
+ try {
158
+ responseData = responseText ? JSON.parse(responseText) : {};
159
+ } catch (parseError) {
160
+ return NextResponse.json(
161
+ { error: 'Invalid JSON response from job status API' },
162
+ { status: 500 }
163
+ );
164
+ }
165
+
166
+ return NextResponse.json(responseData, {
167
+ status: response.status,
168
+ headers: {
169
+ 'Access-Control-Allow-Origin': '*',
170
+ 'Access-Control-Allow-Methods': 'GET, POST, PUT, OPTIONS',
171
+ 'Access-Control-Allow-Headers': 'Content-Type, Accept, Authorization'
172
+ }
173
+ });
125
174
  }
126
175
 
127
176
  return NextResponse.json(
@@ -141,13 +190,32 @@ export async function POST(request: NextRequest) {
141
190
  const body = await request.json();
142
191
 
143
192
  let externalUrl: string;
193
+ let httpMethod = 'POST';
194
+
144
195
  if (endpoint === 'feedback') {
196
+ if (!body.url || typeof body.url !== 'string' || !body.url.trim()) {
197
+ return NextResponse.json(
198
+ { status: 'error', message: 'URL is required for feedback' },
199
+ { status: 400 }
200
+ );
201
+ }
202
+ if (typeof body.feedback !== 'boolean') {
203
+ return NextResponse.json(
204
+ { status: 'error', message: 'Feedback must be a boolean value' },
205
+ { status: 400 }
206
+ );
207
+ }
145
208
  externalUrl = `${VIRTUAL_TRY_ON_API_URL}/api/v1/feedback`;
209
+ httpMethod = 'PUT';
210
+ } else if (endpoint === 'async-multiple-try-on') {
211
+ externalUrl = `${VIRTUAL_TRY_ON_API_URL}/api/async/v1/multiple-virtual-try-on`;
146
212
  } else {
147
- externalUrl = `${VIRTUAL_TRY_ON_API_URL}/api/v1/virtual-try-on`;
213
+ return NextResponse.json(
214
+ { error: 'Invalid endpoint specified' },
215
+ { status: 400 }
216
+ );
148
217
  }
149
218
 
150
- const httpMethod = endpoint === 'feedback' ? 'PUT' : 'POST';
151
219
  const clientIP = getClientIP(request);
152
220
  const locale = getLocaleFromRequest(request);
153
221
 
@@ -163,13 +231,18 @@ export async function POST(request: NextRequest) {
163
231
  })
164
232
  };
165
233
 
166
- const response = await fetch(externalUrl, {
234
+ const fetchOptions: RequestInit = {
167
235
  method: httpMethod,
168
- headers: headersToSend,
169
- body: JSON.stringify(body)
170
- });
236
+ headers: headersToSend
237
+ };
238
+
239
+ if (httpMethod !== 'GET') {
240
+ fetchOptions.body = JSON.stringify(body);
241
+ }
242
+
243
+ const response = await fetch(externalUrl, fetchOptions);
171
244
 
172
- let responseData: any;
245
+ let responseData: Record<string, any>;
173
246
  const responseText = await response.text();
174
247
 
175
248
  if (endpoint === 'feedback') {
@@ -273,7 +346,7 @@ export async function PUT(request: NextRequest) {
273
346
  body: JSON.stringify(body)
274
347
  });
275
348
 
276
- const responseData = await response.json();
349
+ const responseData = response?.json() || {};
277
350
 
278
351
  return NextResponse.json(responseData, {
279
352
  status: response.status,
@@ -287,7 +360,8 @@ export async function PUT(request: NextRequest) {
287
360
  return NextResponse.json(
288
361
  {
289
362
  status: 'error',
290
- message: 'Internal server error occurred during feedback submission'
363
+ message: 'Internal server error occurred during feedback submission',
364
+ error: (error as Error).message
291
365
  },
292
366
  { status: 500 }
293
367
  );
@@ -50,6 +50,7 @@ export enum Component {
50
50
  MultiBasket = 'MultiBasket',
51
51
  SavedCard = 'SavedCardOption',
52
52
  VirtualTryOnPlugin = 'VirtualTryOnPlugin',
53
+ BasketVirtualTryOn = 'BasketVirtualTryOn',
53
54
  IyzicoSavedCard = 'IyzicoSavedCardOption',
54
55
  Hepsipay = 'Hepsipay',
55
56
  FlowPayment = 'FlowPayment'
@@ -88,7 +89,10 @@ const PluginComponents = new Map([
88
89
  [Plugin.SavedCard, [Component.SavedCard, Component.IyzicoSavedCard]],
89
90
  [Plugin.SavedCard, [Component.SavedCard]],
90
91
  [Plugin.FlowPayment, [Component.FlowPayment]],
91
- [Plugin.VirtualTryOn, [Component.VirtualTryOnPlugin]],
92
+ [
93
+ Plugin.VirtualTryOn,
94
+ [Component.VirtualTryOnPlugin, Component.BasketVirtualTryOn]
95
+ ],
92
96
  [Plugin.Hepsipay, [Component.Hepsipay]]
93
97
  ]);
94
98
 
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.110.0",
4
+ "version": "1.111.0-snapshot-ZERO-3792-20251107072714",
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.110.0",
38
+ "@akinon/eslint-plugin-projectzero": "1.111.0-snapshot-ZERO-3792-20251107072714",
39
39
  "@babel/core": "7.26.10",
40
40
  "@babel/preset-env": "7.26.9",
41
41
  "@babel/preset-typescript": "7.27.0",