@swan-admin/swan-ai-measurements 1.1.69 → 1.1.71
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/measurement.js +1 -1
- package/dist/esm/tryOn.d.ts +2 -2
- package/dist/esm/tryOn.js +8 -8
- package/dist/measurement.js +1 -1
- package/dist/tryOn.d.ts +2 -2
- package/dist/tryOn.js +7 -7
- package/package.json +1 -1
- package/src/measurement.ts +1 -1
- package/src/tryOn.ts +11 -10
package/dist/esm/measurement.js
CHANGED
|
@@ -63,7 +63,7 @@ class Measurement {
|
|
|
63
63
|
if (!checkParameters(faceScanId)) {
|
|
64
64
|
throw new Error(REQUIRED_MESSAGE);
|
|
65
65
|
}
|
|
66
|
-
__classPrivateFieldGet(this, _Measurement_instances, "m", _Measurement_handleSocket).call(this, { onOpen, faceScanId, onSuccess, onError, onClose, paramsKey: "faceScanId", isFallback: false, delay:
|
|
66
|
+
__classPrivateFieldGet(this, _Measurement_instances, "m", _Measurement_handleSocket).call(this, { onOpen, faceScanId, onSuccess, onError, onClose, paramsKey: "faceScanId", isFallback: false, delay: 1000 });
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
_Measurement_measurementSocketRef = new WeakMap(), _Measurement_timerPollingRef = new WeakMap(), _Measurement_timerWaitingRef = new WeakMap(), _Measurement_count = new WeakMap(), _Measurement_accessKey = new WeakMap(), _Measurement_stagingUrl = new WeakMap(), _Measurement_instances = new WeakSet(), _Measurement_getMeasurementsCheck = function _Measurement_getMeasurementsCheck(options) {
|
package/dist/esm/tryOn.d.ts
CHANGED
|
@@ -29,13 +29,13 @@ interface Products {
|
|
|
29
29
|
}
|
|
30
30
|
interface HandleForLatestImageParams {
|
|
31
31
|
shopDomain: string;
|
|
32
|
-
userEmail: string;
|
|
33
32
|
products: Products[];
|
|
34
33
|
selectedUserImages?: string[];
|
|
35
34
|
requestSource?: string;
|
|
36
35
|
callbackUrl?: string;
|
|
37
36
|
openTryonId?: string;
|
|
38
37
|
selectedProductImageUrl?: string;
|
|
38
|
+
token: string;
|
|
39
39
|
}
|
|
40
40
|
interface GetTryOnResultParams {
|
|
41
41
|
tryonId: string;
|
|
@@ -47,7 +47,7 @@ declare class TryOn {
|
|
|
47
47
|
getUploadedFiles(userEmail: string): Promise<AxiosResponse<any>>;
|
|
48
48
|
deleteImage({ userEmail, fileName }: DeleteImageParams): Promise<AxiosResponse<any>>;
|
|
49
49
|
handleTryOnWebSocket: ({ tryonId, onError, onSuccess, onClose, onOpen }: HandleTryOnWebSocketParams) => void;
|
|
50
|
-
handleTryOnSubmit({
|
|
50
|
+
handleTryOnSubmit({ shopDomain, products, selectedUserImages, requestSource, callbackUrl, openTryonId, selectedProductImageUrl, token }: HandleForLatestImageParams): Promise<AxiosResponse<any>>;
|
|
51
51
|
getShareLink(tryonId: string): Promise<AxiosResponse<any, any>>;
|
|
52
52
|
getTryOnResult: ({ tryonId }: GetTryOnResultParams) => Promise<AxiosResponse<any>>;
|
|
53
53
|
getProductImageEligibility({ storeUrl, productHandle, imageURL, productDescription }: EligibiltyImageParams): Promise<AxiosResponse<any, any>>;
|
package/dist/esm/tryOn.js
CHANGED
|
@@ -171,18 +171,18 @@ class TryOn {
|
|
|
171
171
|
data: payload,
|
|
172
172
|
});
|
|
173
173
|
}
|
|
174
|
-
handleTryOnSubmit({
|
|
175
|
-
if (checkParameters(shopDomain,
|
|
174
|
+
handleTryOnSubmit({ shopDomain, products, selectedUserImages, requestSource, callbackUrl, openTryonId, selectedProductImageUrl, token }) {
|
|
175
|
+
if (checkParameters(shopDomain, products, token) === false) {
|
|
176
176
|
throw new Error(REQUIRED_MESSAGE);
|
|
177
177
|
}
|
|
178
|
-
|
|
179
|
-
throw new Error(REQUIRED_ERROR_MESSAGE_INVALID_EMAIL);
|
|
180
|
-
}
|
|
181
|
-
const payload = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ products,
|
|
182
|
-
userEmail, customerStoreUrl: shopDomain }, (selectedUserImages !== undefined && selectedUserImages !== null && { selectedUserImages })), (requestSource !== undefined && requestSource !== null && { requestSource })), (callbackUrl !== undefined && callbackUrl !== null && { callbackUrl })), (openTryonId !== undefined && openTryonId !== null && { openTryonId })), (selectedProductImageUrl !== undefined && selectedProductImageUrl !== null && { selectedProductImageUrl }));
|
|
178
|
+
const payload = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ products, customerStoreUrl: shopDomain }, (selectedUserImages !== undefined && selectedUserImages !== null && { selectedUserImages })), (requestSource !== undefined && requestSource !== null && { requestSource })), (callbackUrl !== undefined && callbackUrl !== null && { callbackUrl })), (openTryonId !== undefined && openTryonId !== null && { openTryonId })), (selectedProductImageUrl !== undefined && selectedProductImageUrl !== null && { selectedProductImageUrl }));
|
|
183
179
|
const url = `${getUrl({ urlName: APP_AUTH_BASE_URL, stagingUrl: __classPrivateFieldGet(this, _TryOn_stagingUrl, "f") })}${API_ENDPOINTS.TRY_ON}`;
|
|
180
|
+
const headers = { "X-Api-Key": __classPrivateFieldGet(this, _TryOn_accessKey, "f") };
|
|
181
|
+
if (token) {
|
|
182
|
+
headers["Authorization"] = `Bearer ${token}`;
|
|
183
|
+
}
|
|
184
184
|
return axios.post(url, payload, {
|
|
185
|
-
headers
|
|
185
|
+
headers,
|
|
186
186
|
});
|
|
187
187
|
}
|
|
188
188
|
getShareLink(tryonId) {
|
package/dist/measurement.js
CHANGED
|
@@ -100,7 +100,7 @@ class Measurement {
|
|
|
100
100
|
if (!(0, utils_js_1.checkParameters)(faceScanId)) {
|
|
101
101
|
throw new Error(constants_js_1.REQUIRED_MESSAGE);
|
|
102
102
|
}
|
|
103
|
-
this.#handleSocket({ onOpen, faceScanId, onSuccess, onError, onClose, paramsKey: "faceScanId", isFallback: false, delay:
|
|
103
|
+
this.#handleSocket({ onOpen, faceScanId, onSuccess, onError, onClose, paramsKey: "faceScanId", isFallback: false, delay: 1000 });
|
|
104
104
|
}
|
|
105
105
|
#handleSocket({ onOpen, isFallback, scanId, onSuccess, onError, onClose, paramsKey, faceScanId, delay }) {
|
|
106
106
|
setTimeout(() => {
|
package/dist/tryOn.d.ts
CHANGED
|
@@ -29,13 +29,13 @@ interface Products {
|
|
|
29
29
|
}
|
|
30
30
|
interface HandleForLatestImageParams {
|
|
31
31
|
shopDomain: string;
|
|
32
|
-
userEmail: string;
|
|
33
32
|
products: Products[];
|
|
34
33
|
selectedUserImages?: string[];
|
|
35
34
|
requestSource?: string;
|
|
36
35
|
callbackUrl?: string;
|
|
37
36
|
openTryonId?: string;
|
|
38
37
|
selectedProductImageUrl?: string;
|
|
38
|
+
token: string;
|
|
39
39
|
}
|
|
40
40
|
interface GetTryOnResultParams {
|
|
41
41
|
tryonId: string;
|
|
@@ -47,7 +47,7 @@ declare class TryOn {
|
|
|
47
47
|
getUploadedFiles(userEmail: string): Promise<AxiosResponse<any>>;
|
|
48
48
|
deleteImage({ userEmail, fileName }: DeleteImageParams): Promise<AxiosResponse<any>>;
|
|
49
49
|
handleTryOnWebSocket: ({ tryonId, onError, onSuccess, onClose, onOpen }: HandleTryOnWebSocketParams) => void;
|
|
50
|
-
handleTryOnSubmit({
|
|
50
|
+
handleTryOnSubmit({ shopDomain, products, selectedUserImages, requestSource, callbackUrl, openTryonId, selectedProductImageUrl, token }: HandleForLatestImageParams): Promise<AxiosResponse<any>>;
|
|
51
51
|
getShareLink(tryonId: string): Promise<AxiosResponse<any, any>>;
|
|
52
52
|
getTryOnResult: ({ tryonId }: GetTryOnResultParams) => Promise<AxiosResponse<any>>;
|
|
53
53
|
getProductImageEligibility({ storeUrl, productHandle, imageURL, productDescription }: EligibiltyImageParams): Promise<AxiosResponse<any, any>>;
|
package/dist/tryOn.js
CHANGED
|
@@ -154,16 +154,12 @@ class TryOn {
|
|
|
154
154
|
console.log("no connection made for websocket");
|
|
155
155
|
}
|
|
156
156
|
};
|
|
157
|
-
handleTryOnSubmit({
|
|
158
|
-
if ((0, utils_js_1.checkParameters)(shopDomain,
|
|
157
|
+
handleTryOnSubmit({ shopDomain, products, selectedUserImages, requestSource, callbackUrl, openTryonId, selectedProductImageUrl, token }) {
|
|
158
|
+
if ((0, utils_js_1.checkParameters)(shopDomain, products, token) === false) {
|
|
159
159
|
throw new Error(constants_js_1.REQUIRED_MESSAGE);
|
|
160
160
|
}
|
|
161
|
-
if (!(0, utils_js_1.isValidEmail)(userEmail.trim())) {
|
|
162
|
-
throw new Error(constants_js_1.REQUIRED_ERROR_MESSAGE_INVALID_EMAIL);
|
|
163
|
-
}
|
|
164
161
|
const payload = {
|
|
165
162
|
products,
|
|
166
|
-
userEmail,
|
|
167
163
|
customerStoreUrl: shopDomain,
|
|
168
164
|
...(selectedUserImages !== undefined && selectedUserImages !== null && { selectedUserImages }),
|
|
169
165
|
...(requestSource !== undefined && requestSource !== null && { requestSource }),
|
|
@@ -172,8 +168,12 @@ class TryOn {
|
|
|
172
168
|
...(selectedProductImageUrl !== undefined && selectedProductImageUrl !== null && { selectedProductImageUrl })
|
|
173
169
|
};
|
|
174
170
|
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}`;
|
|
171
|
+
const headers = { "X-Api-Key": this.#accessKey };
|
|
172
|
+
if (token) {
|
|
173
|
+
headers["Authorization"] = `Bearer ${token}`;
|
|
174
|
+
}
|
|
175
175
|
return axios_1.default.post(url, payload, {
|
|
176
|
-
headers
|
|
176
|
+
headers,
|
|
177
177
|
});
|
|
178
178
|
}
|
|
179
179
|
#handleGetTryOnResult = async ({ onSuccess, onError, tryonId }) => {
|
package/package.json
CHANGED
package/src/measurement.ts
CHANGED
|
@@ -149,7 +149,7 @@ class Measurement {
|
|
|
149
149
|
if (!checkParameters(faceScanId)) {
|
|
150
150
|
throw new Error(REQUIRED_MESSAGE);
|
|
151
151
|
}
|
|
152
|
-
this.#handleSocket({ onOpen, faceScanId, onSuccess, onError, onClose, paramsKey: "faceScanId", isFallback: false,delay:
|
|
152
|
+
this.#handleSocket({ onOpen, faceScanId, onSuccess, onError, onClose, paramsKey: "faceScanId", isFallback: false,delay:1000 });
|
|
153
153
|
}
|
|
154
154
|
#handleSocket({ onOpen, isFallback, scanId, onSuccess, onError, onClose, paramsKey, faceScanId,delay }: HandleSocket) {
|
|
155
155
|
setTimeout(() => {
|
package/src/tryOn.ts
CHANGED
|
@@ -34,13 +34,13 @@ interface Products
|
|
|
34
34
|
|
|
35
35
|
interface HandleForLatestImageParams {
|
|
36
36
|
shopDomain: string;
|
|
37
|
-
userEmail: string;
|
|
38
37
|
products:Products[];
|
|
39
38
|
selectedUserImages?:string[];
|
|
40
39
|
requestSource?: string;
|
|
41
40
|
callbackUrl?: string;
|
|
42
41
|
openTryonId?:string;
|
|
43
|
-
selectedProductImageUrl?:string
|
|
42
|
+
selectedProductImageUrl?:string;
|
|
43
|
+
token: string;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
interface HandleTimeOutParams {
|
|
@@ -212,24 +212,21 @@ class TryOn {
|
|
|
212
212
|
};
|
|
213
213
|
|
|
214
214
|
handleTryOnSubmit({
|
|
215
|
-
userEmail,
|
|
216
215
|
shopDomain,
|
|
217
216
|
products,
|
|
218
217
|
selectedUserImages,
|
|
219
218
|
requestSource,
|
|
220
219
|
callbackUrl,
|
|
221
220
|
openTryonId,
|
|
222
|
-
selectedProductImageUrl
|
|
221
|
+
selectedProductImageUrl,
|
|
222
|
+
token
|
|
223
223
|
}: HandleForLatestImageParams): Promise<AxiosResponse<any>> {
|
|
224
|
-
if (checkParameters(shopDomain,
|
|
224
|
+
if (checkParameters(shopDomain, products,token) === false) {
|
|
225
225
|
throw new Error(REQUIRED_MESSAGE);
|
|
226
226
|
}
|
|
227
|
-
|
|
228
|
-
throw new Error(REQUIRED_ERROR_MESSAGE_INVALID_EMAIL);
|
|
229
|
-
}
|
|
227
|
+
|
|
230
228
|
const payload = {
|
|
231
229
|
products,
|
|
232
|
-
userEmail,
|
|
233
230
|
customerStoreUrl:shopDomain,
|
|
234
231
|
...(selectedUserImages!==undefined && selectedUserImages!==null &&{selectedUserImages}),
|
|
235
232
|
...(requestSource!==undefined && requestSource!==null &&{requestSource}),
|
|
@@ -238,8 +235,12 @@ class TryOn {
|
|
|
238
235
|
...(selectedProductImageUrl!==undefined && selectedProductImageUrl!==null &&{selectedProductImageUrl})
|
|
239
236
|
};
|
|
240
237
|
const url = `${getUrl({ urlName: APP_AUTH_BASE_URL, stagingUrl: this.#stagingUrl })}${API_ENDPOINTS.TRY_ON}`;
|
|
238
|
+
const headers: Record<string, string> = { "X-Api-Key": this.#accessKey };
|
|
239
|
+
if (token) {
|
|
240
|
+
headers["Authorization"] = `Bearer ${token}`;
|
|
241
|
+
}
|
|
241
242
|
return axios.post(url, payload, {
|
|
242
|
-
headers
|
|
243
|
+
headers,
|
|
243
244
|
});
|
|
244
245
|
}
|
|
245
246
|
|