@akinon/next 1.112.0-snapshot-ZERO-3859-20251125183557 → 1.112.0
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 +2 -2
- package/api/virtual-try-on.ts +85 -9
- package/components/plugin-module.tsx +9 -9
- package/package.json +2 -2
- package/plugins.js +1 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# @akinon/next
|
|
2
2
|
|
|
3
|
-
## 1.112.0
|
|
3
|
+
## 1.112.0
|
|
4
4
|
|
|
5
5
|
### Minor Changes
|
|
6
6
|
|
|
7
|
-
-
|
|
7
|
+
- 888fdec: ZERO-3792: Virtual Try On new features are implemented and also basket support implemented.
|
|
8
8
|
|
|
9
9
|
## 1.111.0
|
|
10
10
|
|
package/api/virtual-try-on.ts
CHANGED
|
@@ -122,6 +122,57 @@ 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(
|
|
135
|
+
referenceUrl
|
|
136
|
+
)}`;
|
|
137
|
+
const clientIP = getClientIP(request);
|
|
138
|
+
const locale = getLocaleFromRequest(request);
|
|
139
|
+
|
|
140
|
+
const headersToSend = {
|
|
141
|
+
Accept: 'application/json',
|
|
142
|
+
...(locale && { 'Accept-Language': locale }),
|
|
143
|
+
...(request.headers.get('authorization') && {
|
|
144
|
+
Authorization: request.headers.get('authorization')!
|
|
145
|
+
}),
|
|
146
|
+
...(clientIP && {
|
|
147
|
+
'X-Forwarded-For': clientIP
|
|
148
|
+
})
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
const response = await fetch(externalUrl, {
|
|
152
|
+
method: 'GET',
|
|
153
|
+
headers: headersToSend
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
let responseData: any;
|
|
157
|
+
const responseText = await response.text();
|
|
158
|
+
|
|
159
|
+
try {
|
|
160
|
+
responseData = responseText ? JSON.parse(responseText) : {};
|
|
161
|
+
} catch (parseError) {
|
|
162
|
+
return NextResponse.json(
|
|
163
|
+
{ error: 'Invalid JSON response from job status API' },
|
|
164
|
+
{ status: 500 }
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
return NextResponse.json(responseData, {
|
|
169
|
+
status: response.status,
|
|
170
|
+
headers: {
|
|
171
|
+
'Access-Control-Allow-Origin': '*',
|
|
172
|
+
'Access-Control-Allow-Methods': 'GET, POST, PUT, OPTIONS',
|
|
173
|
+
'Access-Control-Allow-Headers': 'Content-Type, Accept, Authorization'
|
|
174
|
+
}
|
|
175
|
+
});
|
|
125
176
|
}
|
|
126
177
|
|
|
127
178
|
return NextResponse.json(
|
|
@@ -141,13 +192,32 @@ export async function POST(request: NextRequest) {
|
|
|
141
192
|
const body = await request.json();
|
|
142
193
|
|
|
143
194
|
let externalUrl: string;
|
|
195
|
+
let httpMethod = 'POST';
|
|
196
|
+
|
|
144
197
|
if (endpoint === 'feedback') {
|
|
198
|
+
if (!body.url || typeof body.url !== 'string' || !body.url.trim()) {
|
|
199
|
+
return NextResponse.json(
|
|
200
|
+
{ status: 'error', message: 'URL is required for feedback' },
|
|
201
|
+
{ status: 400 }
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
if (typeof body.feedback !== 'boolean') {
|
|
205
|
+
return NextResponse.json(
|
|
206
|
+
{ status: 'error', message: 'Feedback must be a boolean value' },
|
|
207
|
+
{ status: 400 }
|
|
208
|
+
);
|
|
209
|
+
}
|
|
145
210
|
externalUrl = `${VIRTUAL_TRY_ON_API_URL}/api/v1/feedback`;
|
|
211
|
+
httpMethod = 'PUT';
|
|
212
|
+
} else if (endpoint === 'async-multiple-try-on') {
|
|
213
|
+
externalUrl = `${VIRTUAL_TRY_ON_API_URL}/api/async/v1/multiple-virtual-try-on`;
|
|
146
214
|
} else {
|
|
147
|
-
|
|
215
|
+
return NextResponse.json(
|
|
216
|
+
{ error: 'Invalid endpoint specified' },
|
|
217
|
+
{ status: 400 }
|
|
218
|
+
);
|
|
148
219
|
}
|
|
149
220
|
|
|
150
|
-
const httpMethod = endpoint === 'feedback' ? 'PUT' : 'POST';
|
|
151
221
|
const clientIP = getClientIP(request);
|
|
152
222
|
const locale = getLocaleFromRequest(request);
|
|
153
223
|
|
|
@@ -163,13 +233,18 @@ export async function POST(request: NextRequest) {
|
|
|
163
233
|
})
|
|
164
234
|
};
|
|
165
235
|
|
|
166
|
-
const
|
|
236
|
+
const fetchOptions: RequestInit = {
|
|
167
237
|
method: httpMethod,
|
|
168
|
-
headers: headersToSend
|
|
169
|
-
|
|
170
|
-
|
|
238
|
+
headers: headersToSend
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
if (httpMethod !== 'GET') {
|
|
242
|
+
fetchOptions.body = JSON.stringify(body);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
const response = await fetch(externalUrl, fetchOptions);
|
|
171
246
|
|
|
172
|
-
let responseData: any
|
|
247
|
+
let responseData: Record<string, any>;
|
|
173
248
|
const responseText = await response.text();
|
|
174
249
|
|
|
175
250
|
if (endpoint === 'feedback') {
|
|
@@ -273,7 +348,7 @@ export async function PUT(request: NextRequest) {
|
|
|
273
348
|
body: JSON.stringify(body)
|
|
274
349
|
});
|
|
275
350
|
|
|
276
|
-
const responseData =
|
|
351
|
+
const responseData = response?.json() || {};
|
|
277
352
|
|
|
278
353
|
return NextResponse.json(responseData, {
|
|
279
354
|
status: response.status,
|
|
@@ -287,7 +362,8 @@ export async function PUT(request: NextRequest) {
|
|
|
287
362
|
return NextResponse.json(
|
|
288
363
|
{
|
|
289
364
|
status: 'error',
|
|
290
|
-
message: 'Internal server error occurred during feedback submission'
|
|
365
|
+
message: 'Internal server error occurred during feedback submission',
|
|
366
|
+
error: (error as Error).message
|
|
291
367
|
},
|
|
292
368
|
{ status: 500 }
|
|
293
369
|
);
|
|
@@ -24,8 +24,7 @@ enum Plugin {
|
|
|
24
24
|
FlowPayment = 'pz-flow-payment',
|
|
25
25
|
VirtualTryOn = 'pz-virtual-try-on',
|
|
26
26
|
Hepsipay = 'pz-hepsipay',
|
|
27
|
-
MasterpassRest = 'pz-masterpass-rest'
|
|
28
|
-
Haso = 'pz-haso'
|
|
27
|
+
MasterpassRest = 'pz-masterpass-rest'
|
|
29
28
|
}
|
|
30
29
|
|
|
31
30
|
export enum Component {
|
|
@@ -52,11 +51,11 @@ export enum Component {
|
|
|
52
51
|
MultiBasket = 'MultiBasket',
|
|
53
52
|
SavedCard = 'SavedCardOption',
|
|
54
53
|
VirtualTryOnPlugin = 'VirtualTryOnPlugin',
|
|
54
|
+
BasketVirtualTryOn = 'BasketVirtualTryOn',
|
|
55
55
|
IyzicoSavedCard = 'IyzicoSavedCardOption',
|
|
56
56
|
Hepsipay = 'Hepsipay',
|
|
57
57
|
FlowPayment = 'FlowPayment',
|
|
58
|
-
MasterpassRest = 'MasterpassRestOption'
|
|
59
|
-
HasoPaymentGateway = 'HasoPaymentGateway'
|
|
58
|
+
MasterpassRest = 'MasterpassRestOption'
|
|
60
59
|
}
|
|
61
60
|
|
|
62
61
|
const PluginComponents = new Map([
|
|
@@ -92,10 +91,13 @@ const PluginComponents = new Map([
|
|
|
92
91
|
[Plugin.SavedCard, [Component.SavedCard, Component.IyzicoSavedCard]],
|
|
93
92
|
[Plugin.SavedCard, [Component.SavedCard]],
|
|
94
93
|
[Plugin.FlowPayment, [Component.FlowPayment]],
|
|
95
|
-
[
|
|
94
|
+
[
|
|
95
|
+
Plugin.VirtualTryOn,
|
|
96
|
+
[Component.VirtualTryOnPlugin, Component.BasketVirtualTryOn]
|
|
97
|
+
],
|
|
98
|
+
[Plugin.Hepsipay, [Component.Hepsipay]],
|
|
96
99
|
[Plugin.Hepsipay, [Component.Hepsipay]],
|
|
97
|
-
[Plugin.MasterpassRest, [Component.MasterpassRest]]
|
|
98
|
-
[Plugin.Haso, [Component.HasoPaymentGateway]]
|
|
100
|
+
[Plugin.MasterpassRest, [Component.MasterpassRest]]
|
|
99
101
|
]);
|
|
100
102
|
|
|
101
103
|
const getPlugin = (component: Component) => {
|
|
@@ -168,8 +170,6 @@ export default function PluginModule({
|
|
|
168
170
|
promise = import(`${'@akinon/pz-virtual-try-on'}`);
|
|
169
171
|
} else if (plugin === Plugin.MasterpassRest) {
|
|
170
172
|
promise = import(`${'@akinon/pz-masterpass-rest'}`);
|
|
171
|
-
} else if (plugin === Plugin.Haso) {
|
|
172
|
-
promise = import(`${'@akinon/pz-haso'}`);
|
|
173
173
|
}
|
|
174
174
|
} catch (error) {
|
|
175
175
|
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.112.0
|
|
4
|
+
"version": "1.112.0",
|
|
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
|
|
38
|
+
"@akinon/eslint-plugin-projectzero": "1.112.0",
|
|
39
39
|
"@babel/core": "7.26.10",
|
|
40
40
|
"@babel/preset-env": "7.26.9",
|
|
41
41
|
"@babel/preset-typescript": "7.27.0",
|