@swan-admin/swan-ai-measurements 1.1.49 → 1.1.51

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 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";
@@ -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";
@@ -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;
@@ -22,9 +28,9 @@ interface HandleForLatestImageParams {
22
28
  shopDomain: string;
23
29
  userEmail: string;
24
30
  productName: string;
25
- firstImageName: string;
26
- secondImageName: string;
27
- onError?: (error: any) => void;
31
+ selectedUserImages: string[];
32
+ requestSource?: string;
33
+ callbackUrl?: string;
28
34
  }
29
35
  interface GetTryOnResultParams {
30
36
  shopDomain: string;
@@ -38,8 +44,9 @@ declare class TryOn {
38
44
  getUploadedFiles(userEmail: string): Promise<AxiosResponse<any>>;
39
45
  deleteImage({ userEmail, fileName }: DeleteImageParams): Promise<AxiosResponse<any>>;
40
46
  handleTryOnWebSocket: ({ userEmail, shopDomain, tryonId, productName, onError, onSuccess, onClose, onOpen }: HandleTryOnWebSocketParams) => void;
41
- handleTryOnSubmit({ userEmail, shopDomain, productName, firstImageName, secondImageName, }: HandleForLatestImageParams): Promise<AxiosResponse<any>>;
47
+ handleTryOnSubmit({ userEmail, shopDomain, productName, selectedUserImages, requestSource, callbackUrl, }: HandleForLatestImageParams): Promise<AxiosResponse<any>>;
42
48
  getShareLink(tryonId: string): Promise<AxiosResponse<any, any>>;
43
49
  getTryOnResult: ({ userEmail, shopDomain, productName }: GetTryOnResultParams) => Promise<AxiosResponse<any>>;
50
+ getProductImageEligibility({ storeUrl, productHandle, imageURL, productDescription }: EligibiltyImageParams): Promise<AxiosResponse<any, any>>;
44
51
  }
45
52
  export default TryOn;
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, firstImageName, secondImageName, }) {
186
- if (checkParameters(shopDomain, userEmail, productName, firstImageName, secondImageName) === false) {
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
- productName,
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") },
@@ -205,6 +204,16 @@ class TryOn {
205
204
  headers: { "X-Api-Key": __classPrivateFieldGet(this, _TryOn_accessKey, "f") },
206
205
  });
207
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
+ }
208
217
  }
209
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) {
210
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;
@@ -22,9 +28,9 @@ interface HandleForLatestImageParams {
22
28
  shopDomain: string;
23
29
  userEmail: string;
24
30
  productName: string;
25
- firstImageName: string;
26
- secondImageName: string;
27
- onError?: (error: any) => void;
31
+ selectedUserImages: string[];
32
+ requestSource?: string;
33
+ callbackUrl?: string;
28
34
  }
29
35
  interface GetTryOnResultParams {
30
36
  shopDomain: string;
@@ -38,8 +44,9 @@ declare class TryOn {
38
44
  getUploadedFiles(userEmail: string): Promise<AxiosResponse<any>>;
39
45
  deleteImage({ userEmail, fileName }: DeleteImageParams): Promise<AxiosResponse<any>>;
40
46
  handleTryOnWebSocket: ({ userEmail, shopDomain, tryonId, productName, onError, onSuccess, onClose, onOpen }: HandleTryOnWebSocketParams) => void;
41
- handleTryOnSubmit({ userEmail, shopDomain, productName, firstImageName, secondImageName, }: HandleForLatestImageParams): Promise<AxiosResponse<any>>;
47
+ handleTryOnSubmit({ userEmail, shopDomain, productName, selectedUserImages, requestSource, callbackUrl, }: HandleForLatestImageParams): Promise<AxiosResponse<any>>;
42
48
  getShareLink(tryonId: string): Promise<AxiosResponse<any, any>>;
43
49
  getTryOnResult: ({ userEmail, shopDomain, productName }: GetTryOnResultParams) => Promise<AxiosResponse<any>>;
50
+ getProductImageEligibility({ storeUrl, productHandle, imageURL, productDescription }: EligibiltyImageParams): Promise<AxiosResponse<any, any>>;
44
51
  }
45
52
  export default TryOn;
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, firstImageName, secondImageName, }) {
161
- if ((0, utils_js_1.checkParameters)(shopDomain, userEmail, productName, firstImageName, secondImageName) === false) {
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: [firstImageName, secondImageName],
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, {
@@ -206,5 +211,15 @@ class TryOn {
206
211
  headers: { "X-Api-Key": this.#accessKey },
207
212
  });
208
213
  };
214
+ getProductImageEligibility({ storeUrl, productHandle, imageURL, productDescription }) {
215
+ if ((0, utils_js_1.checkParameters)(storeUrl, productHandle, imageURL) === false) {
216
+ throw new Error(constants_js_1.REQUIRED_MESSAGE);
217
+ }
218
+ const payload = { storeUrl, productHandle, imageURL, productDescription: productDescription ?? null };
219
+ 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}`;
220
+ return axios_1.default.post(url, payload, {
221
+ headers: { "X-Api-Key": this.#accessKey },
222
+ });
223
+ }
209
224
  }
210
225
  exports.default = TryOn;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swan-admin/swan-ai-measurements",
3
- "version": "1.1.49",
3
+ "version": "1.1.51",
4
4
  "description": "provides ai measurement suggestion",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/esm/index.js",
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;
@@ -29,12 +29,12 @@ interface HandleTryOnWebSocketParams {
29
29
  }
30
30
 
31
31
  interface HandleForLatestImageParams {
32
- shopDomain: string;
33
- userEmail: string;
34
- productName: string;
35
- firstImageName: string;
36
- secondImageName: string;
37
- onError?: (error: any) => void;
32
+ shopDomain: string;
33
+ userEmail: string;
34
+ productName: string;
35
+ selectedUserImages:string[];
36
+ requestSource?: string;
37
+ callbackUrl?: string;
38
38
  }
39
39
 
40
40
  interface HandleTimeOutParams {
@@ -213,31 +213,35 @@ class TryOn {
213
213
  };
214
214
 
215
215
  handleTryOnSubmit({
216
- userEmail,
217
- shopDomain,
218
- productName,
219
- firstImageName,
220
- secondImageName,
221
- }: HandleForLatestImageParams): Promise<AxiosResponse<any>> {
222
- if (checkParameters(shopDomain, userEmail, productName, firstImageName, secondImageName) === false) {
223
- throw new Error(REQUIRED_MESSAGE);
224
- }
225
-
226
- if (!isValidEmail(userEmail.trim())) {
227
- throw new Error(REQUIRED_ERROR_MESSAGE_INVALID_EMAIL);
228
- }
229
- const payload = {
230
- productName,
231
- userEmail,
232
- customerStoreUrl: shopDomain,
233
- selectedUserImages: [firstImageName, secondImageName],
234
- };
235
-
236
- const url = `${getUrl({ urlName: APP_AUTH_BASE_URL, stagingUrl: this.#stagingUrl })}${API_ENDPOINTS.TRY_ON}`;
237
- return axios.post(url, payload, {
216
+ userEmail,
217
+ shopDomain,
218
+ productName,
219
+ selectedUserImages,
220
+ requestSource,
221
+ callbackUrl,
222
+ }: HandleForLatestImageParams): Promise<AxiosResponse<any>> {
223
+ if (checkParameters(shopDomain, userEmail, productName,selectedUserImages) === false) {
224
+ throw new Error(REQUIRED_MESSAGE);
225
+ }
226
+ if (!selectedUserImages.length) {
227
+ throw new Error("No user images found!");
228
+ }
229
+ if (!isValidEmail(userEmail.trim())) {
230
+ throw new Error(REQUIRED_ERROR_MESSAGE_INVALID_EMAIL);
231
+ }
232
+ const payload = {
233
+ productName,
234
+ userEmail,
235
+ customerStoreUrl: shopDomain,
236
+ selectedUserImages,
237
+ ...(requestSource!==undefined && requestSource!==null &&{requestSource}),
238
+ ...(callbackUrl!==undefined && callbackUrl!==null &&{callbackUrl})
239
+ };
240
+ const url = `${getUrl({ urlName: APP_AUTH_BASE_URL, stagingUrl: this.#stagingUrl })}${API_ENDPOINTS.TRY_ON}`;
241
+ return axios.post(url, payload, {
238
242
  headers: { "X-Api-Key": this.#accessKey },
239
- });
240
- }
243
+ });
244
+ }
241
245
 
242
246
  #handleGetTryOnResult = async ({ onSuccess, onError, shopDomain, userEmail, productName }: HandleTimeOutParams): Promise<void> => {
243
247
  try {
@@ -278,6 +282,17 @@ class TryOn {
278
282
  headers: { "X-Api-Key": this.#accessKey },
279
283
  });
280
284
  };
285
+
286
+ getProductImageEligibility({storeUrl,productHandle,imageURL,productDescription}:EligibiltyImageParams){
287
+ if (checkParameters(storeUrl, productHandle, imageURL) === false) {
288
+ throw new Error(REQUIRED_MESSAGE);
289
+ }
290
+ const payload = {storeUrl,productHandle,imageURL,productDescription:productDescription??null};
291
+ const url = `${getUrl({ urlName: APP_AUTH_BASE_URL, stagingUrl: this.#stagingUrl })}${API_ENDPOINTS.TRY_ON_PRODUCT_IMAGE_ELIGIBILTY}`;
292
+ return axios.post(url, payload, {
293
+ headers: { "X-Api-Key": this.#accessKey },
294
+ });
295
+ }
281
296
  }
282
297
 
283
298
  export default TryOn;