@akinon/next 1.112.0-snapshot-ZERO-3847-20251120130807 → 1.112.0-snapshot-ZERO-3792-20251121121755
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 +5 -1
- package/api/virtual-try-on.ts +83 -9
- package/components/plugin-module.tsx +10 -5
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
package/api/virtual-try-on.ts
CHANGED
|
@@ -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
|
-
|
|
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
|
|
234
|
+
const fetchOptions: RequestInit = {
|
|
167
235
|
method: httpMethod,
|
|
168
|
-
headers: headersToSend
|
|
169
|
-
|
|
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 =
|
|
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
|
);
|
|
@@ -51,6 +51,7 @@ export enum Component {
|
|
|
51
51
|
MultiBasket = 'MultiBasket',
|
|
52
52
|
SavedCard = 'SavedCardOption',
|
|
53
53
|
VirtualTryOnPlugin = 'VirtualTryOnPlugin',
|
|
54
|
+
BasketVirtualTryOn = 'BasketVirtualTryOn',
|
|
54
55
|
IyzicoSavedCard = 'IyzicoSavedCardOption',
|
|
55
56
|
Hepsipay = 'Hepsipay',
|
|
56
57
|
FlowPayment = 'FlowPayment',
|
|
@@ -90,7 +91,11 @@ const PluginComponents = new Map([
|
|
|
90
91
|
[Plugin.SavedCard, [Component.SavedCard, Component.IyzicoSavedCard]],
|
|
91
92
|
[Plugin.SavedCard, [Component.SavedCard]],
|
|
92
93
|
[Plugin.FlowPayment, [Component.FlowPayment]],
|
|
93
|
-
[
|
|
94
|
+
[
|
|
95
|
+
Plugin.VirtualTryOn,
|
|
96
|
+
[Component.VirtualTryOnPlugin, Component.BasketVirtualTryOn]
|
|
97
|
+
],
|
|
98
|
+
[Plugin.Hepsipay, [Component.Hepsipay]],
|
|
94
99
|
[Plugin.Hepsipay, [Component.Hepsipay]],
|
|
95
100
|
[Plugin.MasterpassRest, [Component.MasterpassRest]]
|
|
96
101
|
]);
|
|
@@ -104,10 +109,10 @@ const getPlugin = (component: Component) => {
|
|
|
104
109
|
};
|
|
105
110
|
|
|
106
111
|
export default function PluginModule({
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
112
|
+
component,
|
|
113
|
+
props,
|
|
114
|
+
children
|
|
115
|
+
}: {
|
|
111
116
|
component: Component;
|
|
112
117
|
props?: any;
|
|
113
118
|
children?: React.ReactNode;
|
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.112.0-snapshot-ZERO-
|
|
4
|
+
"version": "1.112.0-snapshot-ZERO-3792-20251121121755",
|
|
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.112.0-snapshot-ZERO-
|
|
38
|
+
"@akinon/eslint-plugin-projectzero": "1.112.0-snapshot-ZERO-3792-20251121121755",
|
|
39
39
|
"@babel/core": "7.26.10",
|
|
40
40
|
"@babel/preset-env": "7.26.9",
|
|
41
41
|
"@babel/preset-typescript": "7.27.0",
|