@swan-admin/swan-ai-measurements 1.1.50 → 1.1.52
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/constants.js +2 -1
- package/dist/esm/constants.js +2 -1
- package/dist/esm/tryOn.d.ts +10 -2
- package/dist/esm/tryOn.js +14 -4
- package/dist/tryOn.d.ts +10 -2
- package/dist/tryOn.js +15 -3
- package/package.json +1 -1
- package/src/constants.ts +2 -1
- package/src/tryOn.ts +20 -4
package/dist/constants.js
CHANGED
|
@@ -38,7 +38,8 @@ exports.API_ENDPOINTS = {
|
|
|
38
38
|
SCANNING: "/scanning",
|
|
39
39
|
RECOMMENDATION: "/recommendation",
|
|
40
40
|
TRY_ON_SHARE: "/tryon/share",
|
|
41
|
-
DEVICE_INFO: "/deviceinfo"
|
|
41
|
+
DEVICE_INFO: "/deviceinfo",
|
|
42
|
+
TRY_ON_PRODUCT_IMAGE_ELIGIBILTY: "/tryon/product-image-eligibility"
|
|
42
43
|
};
|
|
43
44
|
exports.requiredMetaData = ["gender", "focal_length", "height", "customer_store_url", "callback_url", "clothes_fit"];
|
|
44
45
|
exports.REQUIRED_MESSAGE = "Please verify required parameters";
|
package/dist/esm/constants.js
CHANGED
|
@@ -35,7 +35,8 @@ export const API_ENDPOINTS = {
|
|
|
35
35
|
SCANNING: "/scanning",
|
|
36
36
|
RECOMMENDATION: "/recommendation",
|
|
37
37
|
TRY_ON_SHARE: "/tryon/share",
|
|
38
|
-
DEVICE_INFO: "/deviceinfo"
|
|
38
|
+
DEVICE_INFO: "/deviceinfo",
|
|
39
|
+
TRY_ON_PRODUCT_IMAGE_ELIGIBILTY: "/tryon/product-image-eligibility"
|
|
39
40
|
};
|
|
40
41
|
export const requiredMetaData = ["gender", "focal_length", "height", "customer_store_url", "callback_url", "clothes_fit"];
|
|
41
42
|
export const REQUIRED_MESSAGE = "Please verify required parameters";
|
package/dist/esm/tryOn.d.ts
CHANGED
|
@@ -8,6 +8,12 @@ interface DeleteImageParams {
|
|
|
8
8
|
userEmail: string;
|
|
9
9
|
fileName: string;
|
|
10
10
|
}
|
|
11
|
+
interface EligibiltyImageParams {
|
|
12
|
+
storeUrl: string;
|
|
13
|
+
productHandle: string;
|
|
14
|
+
imageURL: string;
|
|
15
|
+
productDescription: string;
|
|
16
|
+
}
|
|
11
17
|
interface HandleTryOnWebSocketParams {
|
|
12
18
|
userEmail: string;
|
|
13
19
|
shopDomain: string;
|
|
@@ -23,9 +29,10 @@ interface HandleForLatestImageParams {
|
|
|
23
29
|
userEmail: string;
|
|
24
30
|
productName: string;
|
|
25
31
|
selectedUserImages: string[];
|
|
26
|
-
onError?: (error: any) => void;
|
|
27
32
|
requestSource?: string;
|
|
28
33
|
callbackUrl?: string;
|
|
34
|
+
openTryonId?: string;
|
|
35
|
+
selectedProductImageUrl?: string;
|
|
29
36
|
}
|
|
30
37
|
interface GetTryOnResultParams {
|
|
31
38
|
shopDomain: string;
|
|
@@ -39,8 +46,9 @@ declare class TryOn {
|
|
|
39
46
|
getUploadedFiles(userEmail: string): Promise<AxiosResponse<any>>;
|
|
40
47
|
deleteImage({ userEmail, fileName }: DeleteImageParams): Promise<AxiosResponse<any>>;
|
|
41
48
|
handleTryOnWebSocket: ({ userEmail, shopDomain, tryonId, productName, onError, onSuccess, onClose, onOpen }: HandleTryOnWebSocketParams) => void;
|
|
42
|
-
handleTryOnSubmit({ userEmail, shopDomain, productName, selectedUserImages, requestSource, callbackUrl, }: HandleForLatestImageParams): Promise<AxiosResponse<any>>;
|
|
49
|
+
handleTryOnSubmit({ userEmail, shopDomain, productName, selectedUserImages, requestSource, callbackUrl, openTryonId, selectedProductImageUrl }: HandleForLatestImageParams): Promise<AxiosResponse<any>>;
|
|
43
50
|
getShareLink(tryonId: string): Promise<AxiosResponse<any, any>>;
|
|
44
51
|
getTryOnResult: ({ userEmail, shopDomain, productName }: GetTryOnResultParams) => Promise<AxiosResponse<any>>;
|
|
52
|
+
getProductImageEligibility({ storeUrl, productHandle, imageURL, productDescription }: EligibiltyImageParams): Promise<AxiosResponse<any, any>>;
|
|
45
53
|
}
|
|
46
54
|
export default TryOn;
|
package/dist/esm/tryOn.js
CHANGED
|
@@ -63,7 +63,7 @@ class TryOn {
|
|
|
63
63
|
data = JSON.parse(event.data);
|
|
64
64
|
}
|
|
65
65
|
catch (error) {
|
|
66
|
-
console.log(data, error, "
|
|
66
|
+
console.log(data, error, "not correct format for data");
|
|
67
67
|
return;
|
|
68
68
|
}
|
|
69
69
|
if ((data === null || data === void 0 ? void 0 : data.status) === "success") {
|
|
@@ -182,7 +182,7 @@ class TryOn {
|
|
|
182
182
|
data: payload,
|
|
183
183
|
});
|
|
184
184
|
}
|
|
185
|
-
handleTryOnSubmit({ userEmail, shopDomain, productName, selectedUserImages, requestSource, callbackUrl, }) {
|
|
185
|
+
handleTryOnSubmit({ userEmail, shopDomain, productName, selectedUserImages, requestSource, callbackUrl, openTryonId, selectedProductImageUrl }) {
|
|
186
186
|
if (checkParameters(shopDomain, userEmail, productName, selectedUserImages) === false) {
|
|
187
187
|
throw new Error(REQUIRED_MESSAGE);
|
|
188
188
|
}
|
|
@@ -192,8 +192,8 @@ class TryOn {
|
|
|
192
192
|
if (!isValidEmail(userEmail.trim())) {
|
|
193
193
|
throw new Error(REQUIRED_ERROR_MESSAGE_INVALID_EMAIL);
|
|
194
194
|
}
|
|
195
|
-
const payload = Object.assign(Object.assign({ productName,
|
|
196
|
-
userEmail, customerStoreUrl: shopDomain, selectedUserImages }, (requestSource !== undefined && requestSource !== null && { requestSource })), (callbackUrl !== undefined && callbackUrl !== null && { callbackUrl }));
|
|
195
|
+
const payload = Object.assign(Object.assign(Object.assign(Object.assign({ productName,
|
|
196
|
+
userEmail, customerStoreUrl: shopDomain, selectedUserImages }, (requestSource !== undefined && requestSource !== null && { requestSource })), (callbackUrl !== undefined && callbackUrl !== null && { callbackUrl })), (openTryonId !== undefined && openTryonId !== null && { openTryonId })), (selectedProductImageUrl !== undefined && selectedProductImageUrl !== null && { selectedProductImageUrl }));
|
|
197
197
|
const url = `${getUrl({ urlName: APP_AUTH_BASE_URL, stagingUrl: __classPrivateFieldGet(this, _TryOn_stagingUrl, "f") })}${API_ENDPOINTS.TRY_ON}`;
|
|
198
198
|
return axios.post(url, payload, {
|
|
199
199
|
headers: { "X-Api-Key": __classPrivateFieldGet(this, _TryOn_accessKey, "f") },
|
|
@@ -204,6 +204,16 @@ class TryOn {
|
|
|
204
204
|
headers: { "X-Api-Key": __classPrivateFieldGet(this, _TryOn_accessKey, "f") },
|
|
205
205
|
});
|
|
206
206
|
}
|
|
207
|
+
getProductImageEligibility({ storeUrl, productHandle, imageURL, productDescription }) {
|
|
208
|
+
if (checkParameters(storeUrl, productHandle, imageURL) === false) {
|
|
209
|
+
throw new Error(REQUIRED_MESSAGE);
|
|
210
|
+
}
|
|
211
|
+
const payload = { storeUrl, productHandle, imageURL, productDescription: productDescription !== null && productDescription !== void 0 ? productDescription : null };
|
|
212
|
+
const url = `${getUrl({ urlName: APP_AUTH_BASE_URL, stagingUrl: __classPrivateFieldGet(this, _TryOn_stagingUrl, "f") })}${API_ENDPOINTS.TRY_ON_PRODUCT_IMAGE_ELIGIBILTY}`;
|
|
213
|
+
return axios.post(url, payload, {
|
|
214
|
+
headers: { "X-Api-Key": __classPrivateFieldGet(this, _TryOn_accessKey, "f") },
|
|
215
|
+
});
|
|
216
|
+
}
|
|
207
217
|
}
|
|
208
218
|
_TryOn_tryOnSocketRef = new WeakMap(), _TryOn_timerWaitingRef = new WeakMap(), _TryOn_accessKey = new WeakMap(), _TryOn_stagingUrl = new WeakMap(), _TryOn_disconnectSocket = new WeakMap(), _TryOn_handleTimeOut = new WeakMap(), _TryOn_handleGetTryOnResult = new WeakMap(), _TryOn_instances = new WeakSet(), _TryOn_getSignedUrl = function _TryOn_getSignedUrl(payload) {
|
|
209
219
|
if (checkParameters(payload) === false) {
|
package/dist/tryOn.d.ts
CHANGED
|
@@ -8,6 +8,12 @@ interface DeleteImageParams {
|
|
|
8
8
|
userEmail: string;
|
|
9
9
|
fileName: string;
|
|
10
10
|
}
|
|
11
|
+
interface EligibiltyImageParams {
|
|
12
|
+
storeUrl: string;
|
|
13
|
+
productHandle: string;
|
|
14
|
+
imageURL: string;
|
|
15
|
+
productDescription: string;
|
|
16
|
+
}
|
|
11
17
|
interface HandleTryOnWebSocketParams {
|
|
12
18
|
userEmail: string;
|
|
13
19
|
shopDomain: string;
|
|
@@ -23,9 +29,10 @@ interface HandleForLatestImageParams {
|
|
|
23
29
|
userEmail: string;
|
|
24
30
|
productName: string;
|
|
25
31
|
selectedUserImages: string[];
|
|
26
|
-
onError?: (error: any) => void;
|
|
27
32
|
requestSource?: string;
|
|
28
33
|
callbackUrl?: string;
|
|
34
|
+
openTryonId?: string;
|
|
35
|
+
selectedProductImageUrl?: string;
|
|
29
36
|
}
|
|
30
37
|
interface GetTryOnResultParams {
|
|
31
38
|
shopDomain: string;
|
|
@@ -39,8 +46,9 @@ declare class TryOn {
|
|
|
39
46
|
getUploadedFiles(userEmail: string): Promise<AxiosResponse<any>>;
|
|
40
47
|
deleteImage({ userEmail, fileName }: DeleteImageParams): Promise<AxiosResponse<any>>;
|
|
41
48
|
handleTryOnWebSocket: ({ userEmail, shopDomain, tryonId, productName, onError, onSuccess, onClose, onOpen }: HandleTryOnWebSocketParams) => void;
|
|
42
|
-
handleTryOnSubmit({ userEmail, shopDomain, productName, selectedUserImages, requestSource, callbackUrl, }: HandleForLatestImageParams): Promise<AxiosResponse<any>>;
|
|
49
|
+
handleTryOnSubmit({ userEmail, shopDomain, productName, selectedUserImages, requestSource, callbackUrl, openTryonId, selectedProductImageUrl }: HandleForLatestImageParams): Promise<AxiosResponse<any>>;
|
|
43
50
|
getShareLink(tryonId: string): Promise<AxiosResponse<any, any>>;
|
|
44
51
|
getTryOnResult: ({ userEmail, shopDomain, productName }: GetTryOnResultParams) => Promise<AxiosResponse<any>>;
|
|
52
|
+
getProductImageEligibility({ storeUrl, productHandle, imageURL, productDescription }: EligibiltyImageParams): Promise<AxiosResponse<any, any>>;
|
|
45
53
|
}
|
|
46
54
|
export default TryOn;
|
package/dist/tryOn.js
CHANGED
|
@@ -130,7 +130,7 @@ class TryOn {
|
|
|
130
130
|
data = JSON.parse(event.data);
|
|
131
131
|
}
|
|
132
132
|
catch (error) {
|
|
133
|
-
console.log(data, error, "
|
|
133
|
+
console.log(data, error, "not correct format for data");
|
|
134
134
|
return;
|
|
135
135
|
}
|
|
136
136
|
if (data?.status === "success") {
|
|
@@ -157,7 +157,7 @@ class TryOn {
|
|
|
157
157
|
console.log("no connection made for websocket");
|
|
158
158
|
}
|
|
159
159
|
};
|
|
160
|
-
handleTryOnSubmit({ userEmail, shopDomain, productName, selectedUserImages, requestSource, callbackUrl, }) {
|
|
160
|
+
handleTryOnSubmit({ userEmail, shopDomain, productName, selectedUserImages, requestSource, callbackUrl, openTryonId, selectedProductImageUrl }) {
|
|
161
161
|
if ((0, utils_js_1.checkParameters)(shopDomain, userEmail, productName, selectedUserImages) === false) {
|
|
162
162
|
throw new Error(constants_js_1.REQUIRED_MESSAGE);
|
|
163
163
|
}
|
|
@@ -173,7 +173,9 @@ class TryOn {
|
|
|
173
173
|
customerStoreUrl: shopDomain,
|
|
174
174
|
selectedUserImages,
|
|
175
175
|
...(requestSource !== undefined && requestSource !== null && { requestSource }),
|
|
176
|
-
...(callbackUrl !== undefined && callbackUrl !== null && { callbackUrl })
|
|
176
|
+
...(callbackUrl !== undefined && callbackUrl !== null && { callbackUrl }),
|
|
177
|
+
...(openTryonId !== undefined && openTryonId !== null && { openTryonId }),
|
|
178
|
+
...(selectedProductImageUrl !== undefined && selectedProductImageUrl !== null && { selectedProductImageUrl })
|
|
177
179
|
};
|
|
178
180
|
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}`;
|
|
179
181
|
return axios_1.default.post(url, payload, {
|
|
@@ -211,5 +213,15 @@ class TryOn {
|
|
|
211
213
|
headers: { "X-Api-Key": this.#accessKey },
|
|
212
214
|
});
|
|
213
215
|
};
|
|
216
|
+
getProductImageEligibility({ storeUrl, productHandle, imageURL, productDescription }) {
|
|
217
|
+
if ((0, utils_js_1.checkParameters)(storeUrl, productHandle, imageURL) === false) {
|
|
218
|
+
throw new Error(constants_js_1.REQUIRED_MESSAGE);
|
|
219
|
+
}
|
|
220
|
+
const payload = { storeUrl, productHandle, imageURL, productDescription: productDescription ?? null };
|
|
221
|
+
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_PRODUCT_IMAGE_ELIGIBILTY}`;
|
|
222
|
+
return axios_1.default.post(url, payload, {
|
|
223
|
+
headers: { "X-Api-Key": this.#accessKey },
|
|
224
|
+
});
|
|
225
|
+
}
|
|
214
226
|
}
|
|
215
227
|
exports.default = TryOn;
|
package/package.json
CHANGED
package/src/constants.ts
CHANGED
|
@@ -45,7 +45,8 @@ export const API_ENDPOINTS: {
|
|
|
45
45
|
SCANNING: "/scanning",
|
|
46
46
|
RECOMMENDATION: "/recommendation",
|
|
47
47
|
TRY_ON_SHARE: "/tryon/share",
|
|
48
|
-
DEVICE_INFO:"/deviceinfo"
|
|
48
|
+
DEVICE_INFO:"/deviceinfo",
|
|
49
|
+
TRY_ON_PRODUCT_IMAGE_ELIGIBILTY:"/tryon/product-image-eligibility"
|
|
49
50
|
};
|
|
50
51
|
export interface ObjMetaData {
|
|
51
52
|
gender: string;
|
package/src/tryOn.ts
CHANGED
|
@@ -16,7 +16,7 @@ interface DeleteImageParams {
|
|
|
16
16
|
fileName: string;
|
|
17
17
|
|
|
18
18
|
}
|
|
19
|
-
|
|
19
|
+
interface EligibiltyImageParams {storeUrl:string,productHandle:string,imageURL:string,productDescription:string}
|
|
20
20
|
interface HandleTryOnWebSocketParams {
|
|
21
21
|
userEmail: string;
|
|
22
22
|
shopDomain: string;
|
|
@@ -33,9 +33,10 @@ interface HandleForLatestImageParams {
|
|
|
33
33
|
userEmail: string;
|
|
34
34
|
productName: string;
|
|
35
35
|
selectedUserImages:string[];
|
|
36
|
-
onError?: (error: any) => void;
|
|
37
36
|
requestSource?: string;
|
|
38
37
|
callbackUrl?: string;
|
|
38
|
+
openTryonId?:string;
|
|
39
|
+
selectedProductImageUrl?:string
|
|
39
40
|
}
|
|
40
41
|
|
|
41
42
|
interface HandleTimeOutParams {
|
|
@@ -185,7 +186,7 @@ class TryOn {
|
|
|
185
186
|
try {
|
|
186
187
|
data = JSON.parse(event.data);
|
|
187
188
|
} catch (error) {
|
|
188
|
-
console.log(data, error, "
|
|
189
|
+
console.log(data, error, "not correct format for data");
|
|
189
190
|
return;
|
|
190
191
|
}
|
|
191
192
|
if (data?.status === "success") {
|
|
@@ -220,6 +221,8 @@ class TryOn {
|
|
|
220
221
|
selectedUserImages,
|
|
221
222
|
requestSource,
|
|
222
223
|
callbackUrl,
|
|
224
|
+
openTryonId,
|
|
225
|
+
selectedProductImageUrl
|
|
223
226
|
}: HandleForLatestImageParams): Promise<AxiosResponse<any>> {
|
|
224
227
|
if (checkParameters(shopDomain, userEmail, productName,selectedUserImages) === false) {
|
|
225
228
|
throw new Error(REQUIRED_MESSAGE);
|
|
@@ -236,7 +239,9 @@ class TryOn {
|
|
|
236
239
|
customerStoreUrl: shopDomain,
|
|
237
240
|
selectedUserImages,
|
|
238
241
|
...(requestSource!==undefined && requestSource!==null &&{requestSource}),
|
|
239
|
-
...(callbackUrl!==undefined && callbackUrl!==null &&{callbackUrl})
|
|
242
|
+
...(callbackUrl!==undefined && callbackUrl!==null &&{callbackUrl}),
|
|
243
|
+
...(openTryonId!==undefined && openTryonId!==null &&{openTryonId}),
|
|
244
|
+
...(selectedProductImageUrl!==undefined && selectedProductImageUrl!==null &&{selectedProductImageUrl})
|
|
240
245
|
};
|
|
241
246
|
const url = `${getUrl({ urlName: APP_AUTH_BASE_URL, stagingUrl: this.#stagingUrl })}${API_ENDPOINTS.TRY_ON}`;
|
|
242
247
|
return axios.post(url, payload, {
|
|
@@ -283,6 +288,17 @@ class TryOn {
|
|
|
283
288
|
headers: { "X-Api-Key": this.#accessKey },
|
|
284
289
|
});
|
|
285
290
|
};
|
|
291
|
+
|
|
292
|
+
getProductImageEligibility({storeUrl,productHandle,imageURL,productDescription}:EligibiltyImageParams){
|
|
293
|
+
if (checkParameters(storeUrl, productHandle, imageURL) === false) {
|
|
294
|
+
throw new Error(REQUIRED_MESSAGE);
|
|
295
|
+
}
|
|
296
|
+
const payload = {storeUrl,productHandle,imageURL,productDescription:productDescription??null};
|
|
297
|
+
const url = `${getUrl({ urlName: APP_AUTH_BASE_URL, stagingUrl: this.#stagingUrl })}${API_ENDPOINTS.TRY_ON_PRODUCT_IMAGE_ELIGIBILTY}`;
|
|
298
|
+
return axios.post(url, payload, {
|
|
299
|
+
headers: { "X-Api-Key": this.#accessKey },
|
|
300
|
+
});
|
|
301
|
+
}
|
|
286
302
|
}
|
|
287
303
|
|
|
288
304
|
export default TryOn;
|