@swan-admin/swan-ai-measurements 1.1.65 → 1.1.67

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.
@@ -28,7 +28,6 @@ export interface FaceScanObjMetaData {
28
28
  face_scan_id: string;
29
29
  email?: string;
30
30
  focal_length: string;
31
- height: string;
32
31
  customer_store_url: string;
33
32
  scan_type: string;
34
33
  callback_url: string;
@@ -28,7 +28,6 @@ export interface FaceScanObjMetaData {
28
28
  face_scan_id: string;
29
29
  email?: string;
30
30
  focal_length: string;
31
- height: string;
32
31
  customer_store_url: string;
33
32
  scan_type: string;
34
33
  callback_url: string;
@@ -10,6 +10,7 @@ interface MeasurementSocketOptions {
10
10
  onSuccess?: (data: any) => void;
11
11
  onClose?: () => void;
12
12
  onOpen?: () => void;
13
+ isFallback?: boolean;
13
14
  }
14
15
  declare class Measurement {
15
16
  #private;
@@ -50,7 +50,7 @@ class Measurement {
50
50
  return axios.get(`${getUrl({ urlName: APP_AUTH_BASE_URL, stagingUrl: __classPrivateFieldGet(this, _Measurement_stagingUrl, "f") })}${API_ENDPOINTS.RECOMMENDATION}/scan/${scanId}/shop/${shopDomain}/product/${productName}`, { headers: { "X-Api-Key": __classPrivateFieldGet(this, _Measurement_accessKey, "f") } });
51
51
  }
52
52
  handleMeasurementSocket(options) {
53
- const { scanId, onError, onSuccess, onClose, onOpen } = options;
53
+ const { scanId, onError, onSuccess, onClose, onOpen, isFallback = true } = options;
54
54
  if (!checkParameters(scanId)) {
55
55
  throw new Error(REQUIRED_MESSAGE);
56
56
  }
@@ -60,7 +60,9 @@ class Measurement {
60
60
  __classPrivateFieldSet(this, _Measurement_measurementSocketRef, new WebSocket(url), "f");
61
61
  __classPrivateFieldGet(this, _Measurement_measurementSocketRef, "f").onopen = () => {
62
62
  onOpen === null || onOpen === void 0 ? void 0 : onOpen();
63
- __classPrivateFieldGet(this, _Measurement_instances, "m", _Measurement_handleTimeOut).call(this, { scanId, onSuccess, onError });
63
+ if (isFallback) {
64
+ __classPrivateFieldGet(this, _Measurement_instances, "m", _Measurement_handleTimeOut).call(this, { scanId, onSuccess, onError });
65
+ }
64
66
  };
65
67
  __classPrivateFieldGet(this, _Measurement_measurementSocketRef, "f").onmessage = (event) => {
66
68
  const data = JSON.parse(event.data);
@@ -10,6 +10,7 @@ interface MeasurementSocketOptions {
10
10
  onSuccess?: (data: any) => void;
11
11
  onClose?: () => void;
12
12
  onOpen?: () => void;
13
+ isFallback?: boolean;
13
14
  }
14
15
  declare class Measurement {
15
16
  #private;
@@ -87,7 +87,7 @@ class Measurement {
87
87
  }, 2 * 60000);
88
88
  }
89
89
  handleMeasurementSocket(options) {
90
- const { scanId, onError, onSuccess, onClose, onOpen } = options;
90
+ const { scanId, onError, onSuccess, onClose, onOpen, isFallback = true } = options;
91
91
  if (!(0, utils_js_1.checkParameters)(scanId)) {
92
92
  throw new Error(constants_js_1.REQUIRED_MESSAGE);
93
93
  }
@@ -97,7 +97,9 @@ class Measurement {
97
97
  this.#measurementSocketRef = new WebSocket(url);
98
98
  this.#measurementSocketRef.onopen = () => {
99
99
  onOpen?.();
100
- this.#handleTimeOut({ scanId, onSuccess, onError });
100
+ if (isFallback) {
101
+ this.#handleTimeOut({ scanId, onSuccess, onError });
102
+ }
101
103
  };
102
104
  this.#measurementSocketRef.onmessage = (event) => {
103
105
  const data = JSON.parse(event.data);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swan-admin/swan-ai-measurements",
3
- "version": "1.1.65",
3
+ "version": "1.1.67",
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
@@ -64,7 +64,6 @@ export interface FaceScanObjMetaData {
64
64
  face_scan_id: string;
65
65
  email?: string;
66
66
  focal_length: string;
67
- height: string;
68
67
  customer_store_url: string;
69
68
  scan_type: string;
70
69
  callback_url:string
@@ -13,6 +13,7 @@ interface MeasurementSocketOptions {
13
13
  onSuccess?: (data: any) => void;
14
14
  onClose?: () => void;
15
15
  onOpen?: () => void;
16
+ isFallback?:boolean
16
17
  }
17
18
 
18
19
  interface GetMeasurementsCheckOptions {
@@ -129,7 +130,7 @@ class Measurement {
129
130
  }
130
131
 
131
132
  handleMeasurementSocket(options: MeasurementSocketOptions): void {
132
- const { scanId, onError, onSuccess, onClose, onOpen } = options;
133
+ const { scanId, onError, onSuccess, onClose, onOpen,isFallback=true } = options;
133
134
 
134
135
  if (!checkParameters(scanId)) {
135
136
  throw new Error(REQUIRED_MESSAGE);
@@ -141,7 +142,9 @@ class Measurement {
141
142
  this.#measurementSocketRef = new WebSocket(url);
142
143
  this.#measurementSocketRef.onopen = () => {
143
144
  onOpen?.();
144
- this.#handleTimeOut({ scanId, onSuccess, onError });
145
+ if (isFallback) {
146
+ this.#handleTimeOut({ scanId, onSuccess, onError });
147
+ }
145
148
  };
146
149
 
147
150
  this.#measurementSocketRef.onmessage = (event: MessageEvent) => {