@swan-admin/swan-ai-measurements 1.1.49 → 1.1.50
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/dist/esm/tryOn.d.ts +4 -3
- package/dist/esm/tryOn.js +7 -8
- package/dist/tryOn.d.ts +4 -3
- package/dist/tryOn.js +8 -3
- package/package.json +1 -1
- package/src/tryOn.ts +35 -30
package/dist/esm/tryOn.d.ts
CHANGED
|
@@ -22,9 +22,10 @@ interface HandleForLatestImageParams {
|
|
|
22
22
|
shopDomain: string;
|
|
23
23
|
userEmail: string;
|
|
24
24
|
productName: string;
|
|
25
|
-
|
|
26
|
-
secondImageName: string;
|
|
25
|
+
selectedUserImages: string[];
|
|
27
26
|
onError?: (error: any) => void;
|
|
27
|
+
requestSource?: string;
|
|
28
|
+
callbackUrl?: string;
|
|
28
29
|
}
|
|
29
30
|
interface GetTryOnResultParams {
|
|
30
31
|
shopDomain: string;
|
|
@@ -38,7 +39,7 @@ declare class TryOn {
|
|
|
38
39
|
getUploadedFiles(userEmail: string): Promise<AxiosResponse<any>>;
|
|
39
40
|
deleteImage({ userEmail, fileName }: DeleteImageParams): Promise<AxiosResponse<any>>;
|
|
40
41
|
handleTryOnWebSocket: ({ userEmail, shopDomain, tryonId, productName, onError, onSuccess, onClose, onOpen }: HandleTryOnWebSocketParams) => void;
|
|
41
|
-
handleTryOnSubmit({ userEmail, shopDomain, productName,
|
|
42
|
+
handleTryOnSubmit({ userEmail, shopDomain, productName, selectedUserImages, requestSource, callbackUrl, }: HandleForLatestImageParams): Promise<AxiosResponse<any>>;
|
|
42
43
|
getShareLink(tryonId: string): Promise<AxiosResponse<any, any>>;
|
|
43
44
|
getTryOnResult: ({ userEmail, shopDomain, productName }: GetTryOnResultParams) => Promise<AxiosResponse<any>>;
|
|
44
45
|
}
|
package/dist/esm/tryOn.js
CHANGED
|
@@ -182,19 +182,18 @@ class TryOn {
|
|
|
182
182
|
data: payload,
|
|
183
183
|
});
|
|
184
184
|
}
|
|
185
|
-
handleTryOnSubmit({ userEmail, shopDomain, productName,
|
|
186
|
-
if (checkParameters(shopDomain, userEmail, productName,
|
|
185
|
+
handleTryOnSubmit({ userEmail, shopDomain, productName, selectedUserImages, requestSource, callbackUrl, }) {
|
|
186
|
+
if (checkParameters(shopDomain, userEmail, productName, selectedUserImages) === false) {
|
|
187
187
|
throw new Error(REQUIRED_MESSAGE);
|
|
188
188
|
}
|
|
189
|
+
if (!selectedUserImages.length) {
|
|
190
|
+
throw new Error("No user images found!");
|
|
191
|
+
}
|
|
189
192
|
if (!isValidEmail(userEmail.trim())) {
|
|
190
193
|
throw new Error(REQUIRED_ERROR_MESSAGE_INVALID_EMAIL);
|
|
191
194
|
}
|
|
192
|
-
const payload = {
|
|
193
|
-
|
|
194
|
-
userEmail,
|
|
195
|
-
customerStoreUrl: shopDomain,
|
|
196
|
-
selectedUserImages: [firstImageName, secondImageName],
|
|
197
|
-
};
|
|
195
|
+
const payload = Object.assign(Object.assign({ productName,
|
|
196
|
+
userEmail, customerStoreUrl: shopDomain, selectedUserImages }, (requestSource !== undefined && requestSource !== null && { requestSource })), (callbackUrl !== undefined && callbackUrl !== null && { callbackUrl }));
|
|
198
197
|
const url = `${getUrl({ urlName: APP_AUTH_BASE_URL, stagingUrl: __classPrivateFieldGet(this, _TryOn_stagingUrl, "f") })}${API_ENDPOINTS.TRY_ON}`;
|
|
199
198
|
return axios.post(url, payload, {
|
|
200
199
|
headers: { "X-Api-Key": __classPrivateFieldGet(this, _TryOn_accessKey, "f") },
|
package/dist/tryOn.d.ts
CHANGED
|
@@ -22,9 +22,10 @@ interface HandleForLatestImageParams {
|
|
|
22
22
|
shopDomain: string;
|
|
23
23
|
userEmail: string;
|
|
24
24
|
productName: string;
|
|
25
|
-
|
|
26
|
-
secondImageName: string;
|
|
25
|
+
selectedUserImages: string[];
|
|
27
26
|
onError?: (error: any) => void;
|
|
27
|
+
requestSource?: string;
|
|
28
|
+
callbackUrl?: string;
|
|
28
29
|
}
|
|
29
30
|
interface GetTryOnResultParams {
|
|
30
31
|
shopDomain: string;
|
|
@@ -38,7 +39,7 @@ declare class TryOn {
|
|
|
38
39
|
getUploadedFiles(userEmail: string): Promise<AxiosResponse<any>>;
|
|
39
40
|
deleteImage({ userEmail, fileName }: DeleteImageParams): Promise<AxiosResponse<any>>;
|
|
40
41
|
handleTryOnWebSocket: ({ userEmail, shopDomain, tryonId, productName, onError, onSuccess, onClose, onOpen }: HandleTryOnWebSocketParams) => void;
|
|
41
|
-
handleTryOnSubmit({ userEmail, shopDomain, productName,
|
|
42
|
+
handleTryOnSubmit({ userEmail, shopDomain, productName, selectedUserImages, requestSource, callbackUrl, }: HandleForLatestImageParams): Promise<AxiosResponse<any>>;
|
|
42
43
|
getShareLink(tryonId: string): Promise<AxiosResponse<any, any>>;
|
|
43
44
|
getTryOnResult: ({ userEmail, shopDomain, productName }: GetTryOnResultParams) => Promise<AxiosResponse<any>>;
|
|
44
45
|
}
|
package/dist/tryOn.js
CHANGED
|
@@ -157,10 +157,13 @@ class TryOn {
|
|
|
157
157
|
console.log("no connection made for websocket");
|
|
158
158
|
}
|
|
159
159
|
};
|
|
160
|
-
handleTryOnSubmit({ userEmail, shopDomain, productName,
|
|
161
|
-
if ((0, utils_js_1.checkParameters)(shopDomain, userEmail, productName,
|
|
160
|
+
handleTryOnSubmit({ userEmail, shopDomain, productName, selectedUserImages, requestSource, callbackUrl, }) {
|
|
161
|
+
if ((0, utils_js_1.checkParameters)(shopDomain, userEmail, productName, selectedUserImages) === false) {
|
|
162
162
|
throw new Error(constants_js_1.REQUIRED_MESSAGE);
|
|
163
163
|
}
|
|
164
|
+
if (!selectedUserImages.length) {
|
|
165
|
+
throw new Error("No user images found!");
|
|
166
|
+
}
|
|
164
167
|
if (!(0, utils_js_1.isValidEmail)(userEmail.trim())) {
|
|
165
168
|
throw new Error(constants_js_1.REQUIRED_ERROR_MESSAGE_INVALID_EMAIL);
|
|
166
169
|
}
|
|
@@ -168,7 +171,9 @@ class TryOn {
|
|
|
168
171
|
productName,
|
|
169
172
|
userEmail,
|
|
170
173
|
customerStoreUrl: shopDomain,
|
|
171
|
-
selectedUserImages
|
|
174
|
+
selectedUserImages,
|
|
175
|
+
...(requestSource !== undefined && requestSource !== null && { requestSource }),
|
|
176
|
+
...(callbackUrl !== undefined && callbackUrl !== null && { callbackUrl })
|
|
172
177
|
};
|
|
173
178
|
const url = `${(0, utils_js_1.getUrl)({ urlName: constants_js_1.APP_AUTH_BASE_URL, stagingUrl: this.#stagingUrl })}${constants_js_1.API_ENDPOINTS.TRY_ON}`;
|
|
174
179
|
return axios_1.default.post(url, payload, {
|
package/package.json
CHANGED
package/src/tryOn.ts
CHANGED
|
@@ -29,12 +29,13 @@ interface HandleTryOnWebSocketParams {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
interface HandleForLatestImageParams {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
32
|
+
shopDomain: string;
|
|
33
|
+
userEmail: string;
|
|
34
|
+
productName: string;
|
|
35
|
+
selectedUserImages:string[];
|
|
36
|
+
onError?: (error: any) => void;
|
|
37
|
+
requestSource?: string;
|
|
38
|
+
callbackUrl?: string;
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
interface HandleTimeOutParams {
|
|
@@ -213,31 +214,35 @@ class TryOn {
|
|
|
213
214
|
};
|
|
214
215
|
|
|
215
216
|
handleTryOnSubmit({
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
217
|
+
userEmail,
|
|
218
|
+
shopDomain,
|
|
219
|
+
productName,
|
|
220
|
+
selectedUserImages,
|
|
221
|
+
requestSource,
|
|
222
|
+
callbackUrl,
|
|
223
|
+
}: HandleForLatestImageParams): Promise<AxiosResponse<any>> {
|
|
224
|
+
if (checkParameters(shopDomain, userEmail, productName,selectedUserImages) === false) {
|
|
225
|
+
throw new Error(REQUIRED_MESSAGE);
|
|
226
|
+
}
|
|
227
|
+
if (!selectedUserImages.length) {
|
|
228
|
+
throw new Error("No user images found!");
|
|
229
|
+
}
|
|
230
|
+
if (!isValidEmail(userEmail.trim())) {
|
|
231
|
+
throw new Error(REQUIRED_ERROR_MESSAGE_INVALID_EMAIL);
|
|
232
|
+
}
|
|
233
|
+
const payload = {
|
|
234
|
+
productName,
|
|
235
|
+
userEmail,
|
|
236
|
+
customerStoreUrl: shopDomain,
|
|
237
|
+
selectedUserImages,
|
|
238
|
+
...(requestSource!==undefined && requestSource!==null &&{requestSource}),
|
|
239
|
+
...(callbackUrl!==undefined && callbackUrl!==null &&{callbackUrl})
|
|
240
|
+
};
|
|
241
|
+
const url = `${getUrl({ urlName: APP_AUTH_BASE_URL, stagingUrl: this.#stagingUrl })}${API_ENDPOINTS.TRY_ON}`;
|
|
242
|
+
return axios.post(url, payload, {
|
|
238
243
|
headers: { "X-Api-Key": this.#accessKey },
|
|
239
|
-
|
|
240
|
-
|
|
244
|
+
});
|
|
245
|
+
}
|
|
241
246
|
|
|
242
247
|
#handleGetTryOnResult = async ({ onSuccess, onError, shopDomain, userEmail, productName }: HandleTimeOutParams): Promise<void> => {
|
|
243
248
|
try {
|