@swan-admin/swan-ai-measurements 1.1.70 → 1.1.72

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.
@@ -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({ userEmail, shopDomain, products, selectedUserImages, requestSource, callbackUrl, openTryonId, selectedProductImageUrl }: HandleForLatestImageParams): Promise<AxiosResponse<any>>;
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
@@ -40,7 +40,7 @@ class TryOn {
40
40
  __classPrivateFieldSet(this, _TryOn_timerWaitingRef, setTimeout(() => {
41
41
  __classPrivateFieldGet(this, _TryOn_handleGetTryOnResult, "f").call(this, { onSuccess, onError, tryonId });
42
42
  __classPrivateFieldGet(this, _TryOn_disconnectSocket, "f").call(this);
43
- }, 150000), "f");
43
+ }, 300000), "f");
44
44
  });
45
45
  this.handleTryOnWebSocket = ({ tryonId, onError, onSuccess, onClose, onOpen }) => {
46
46
  if (checkParameters(tryonId) === false) {
@@ -171,18 +171,18 @@ class TryOn {
171
171
  data: payload,
172
172
  });
173
173
  }
174
- handleTryOnSubmit({ userEmail, shopDomain, products, selectedUserImages, requestSource, callbackUrl, openTryonId, selectedProductImageUrl }) {
175
- if (checkParameters(shopDomain, userEmail, products) === false) {
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
- if (!isValidEmail(userEmail.trim())) {
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: { "X-Api-Key": __classPrivateFieldGet(this, _TryOn_accessKey, "f") },
185
+ headers,
186
186
  });
187
187
  }
188
188
  getShareLink(tryonId) {
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({ userEmail, shopDomain, products, selectedUserImages, requestSource, callbackUrl, openTryonId, selectedProductImageUrl }: HandleForLatestImageParams): Promise<AxiosResponse<any>>;
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
@@ -107,7 +107,7 @@ class TryOn {
107
107
  this.#timerWaitingRef = setTimeout(() => {
108
108
  this.#handleGetTryOnResult({ onSuccess, onError, tryonId });
109
109
  this.#disconnectSocket();
110
- }, 150000);
110
+ }, 300000);
111
111
  };
112
112
  handleTryOnWebSocket = ({ tryonId, onError, onSuccess, onClose, onOpen }) => {
113
113
  if ((0, utils_js_1.checkParameters)(tryonId) === false) {
@@ -154,16 +154,12 @@ class TryOn {
154
154
  console.log("no connection made for websocket");
155
155
  }
156
156
  };
157
- handleTryOnSubmit({ userEmail, shopDomain, products, selectedUserImages, requestSource, callbackUrl, openTryonId, selectedProductImageUrl }) {
158
- if ((0, utils_js_1.checkParameters)(shopDomain, userEmail, products) === false) {
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: { "X-Api-Key": this.#accessKey },
176
+ headers,
177
177
  });
178
178
  }
179
179
  #handleGetTryOnResult = async ({ onSuccess, onError, tryonId }) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swan-admin/swan-ai-measurements",
3
- "version": "1.1.70",
3
+ "version": "1.1.72",
4
4
  "description": "provides ai measurement suggestion",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/esm/index.js",
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 {
@@ -163,7 +163,7 @@ class TryOn {
163
163
  this.#timerWaitingRef = setTimeout(() => {
164
164
  this.#handleGetTryOnResult({ onSuccess, onError,tryonId });
165
165
  this.#disconnectSocket();
166
- }, 150000);
166
+ }, 300000);
167
167
  };
168
168
 
169
169
  handleTryOnWebSocket = ({ tryonId, onError, onSuccess, onClose, onOpen }: HandleTryOnWebSocketParams): void => {
@@ -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, userEmail, products) === false) {
224
+ if (checkParameters(shopDomain, products,token) === false) {
225
225
  throw new Error(REQUIRED_MESSAGE);
226
226
  }
227
- if (!isValidEmail(userEmail.trim())) {
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: { "X-Api-Key": this.#accessKey },
243
+ headers,
243
244
  });
244
245
  }
245
246