@swan-admin/swan-ai-measurements 1.1.39 → 1.1.41

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,6 +38,7 @@ exports.API_ENDPOINTS = {
38
38
  SCANNING: "/scanning",
39
39
  RECOMMENDATION: "/recommendation",
40
40
  TRY_ON_SHARE: "/tryon/share",
41
+ DEVICE_INFO: "/deviceinfo"
41
42
  };
42
43
  exports.requiredMetaData = ["gender", "focal_length", "height", "customer_store_url", "callback_url", "clothes_fit"];
43
44
  exports.REQUIRED_MESSAGE = "Please verify required parameters";
@@ -35,6 +35,7 @@ export const API_ENDPOINTS = {
35
35
  SCANNING: "/scanning",
36
36
  RECOMMENDATION: "/recommendation",
37
37
  TRY_ON_SHARE: "/tryon/share",
38
+ DEVICE_INFO: "/deviceinfo"
38
39
  };
39
40
  export const requiredMetaData = ["gender", "focal_length", "height", "customer_store_url", "callback_url", "clothes_fit"];
40
41
  export const REQUIRED_MESSAGE = "Please verify required parameters";
@@ -8,7 +8,17 @@ interface ObjMetaData {
8
8
  clothes_fit: string;
9
9
  scan_type?: string;
10
10
  callback_url: string;
11
- gyro?: string;
11
+ }
12
+ interface SetDeviceInfo {
13
+ detection?: string;
14
+ model?: string;
15
+ gyro: {
16
+ alpha?: string;
17
+ gamma?: string;
18
+ beta?: string;
19
+ timestamp?: string;
20
+ }[];
21
+ scanId: string;
12
22
  }
13
23
  interface UploadOptions {
14
24
  file: File;
@@ -21,5 +31,6 @@ export default class FileUpload {
21
31
  constructor(accessKey: string, stagingUrl?: boolean);
22
32
  uploadFileFrontend({ file, arrayMetaData, scanId, email }: UploadOptions): Promise<unknown>;
23
33
  uploadFile({ file, arrayMetaData, scanId, email }: UploadOptions): Promise<unknown>;
34
+ setDeviceInfo(data: SetDeviceInfo): Promise<import("axios").AxiosResponse<any, any>>;
24
35
  }
25
36
  export {};
@@ -18,9 +18,20 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
18
18
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
19
19
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
20
20
  };
21
+ var __rest = (this && this.__rest) || function (s, e) {
22
+ var t = {};
23
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
24
+ t[p] = s[p];
25
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
26
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
27
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
28
+ t[p[i]] = s[p[i]];
29
+ }
30
+ return t;
31
+ };
21
32
  var _FileUpload_uppyIns, _FileUpload_accessKey, _FileUpload_stagingUrl;
22
33
  import axios from "axios";
23
- import { REQUIRED_MESSAGE, REQUIRED_MESSAGE_FOR_META_DATA, FILE_UPLOAD_ENDPOINT, APP_AUTH_BASE_URL, REQUIRED_ERROR_MESSAGE_INVALID_EMAIL, } from "./constants.js";
34
+ import { REQUIRED_MESSAGE, REQUIRED_MESSAGE_FOR_META_DATA, FILE_UPLOAD_ENDPOINT, APP_AUTH_BASE_URL, REQUIRED_ERROR_MESSAGE_INVALID_EMAIL, API_ENDPOINTS, } from "./constants.js";
24
35
  import { addScanType, checkMetaDataValue, checkParameters, fetchData, getFileChunks, getUrl, isValidEmail } from "./utils.js";
25
36
  import Uppy from "@uppy/core";
26
37
  import AwsS3Multipart from "@uppy/aws-s3-multipart";
@@ -172,6 +183,17 @@ class FileUpload {
172
183
  }));
173
184
  });
174
185
  }
186
+ setDeviceInfo(data) {
187
+ return __awaiter(this, void 0, void 0, function* () {
188
+ const { scanId } = data, rest = __rest(data, ["scanId"]);
189
+ if (checkParameters(scanId) === false) {
190
+ throw new Error(REQUIRED_MESSAGE);
191
+ }
192
+ return axios.post(`${getUrl({ urlName: APP_AUTH_BASE_URL, stagingUrl: __classPrivateFieldGet(this, _FileUpload_stagingUrl, "f") })}${API_ENDPOINTS.DEVICE_INFO}/${scanId}`, { device_info: Object.assign({}, rest) }, {
193
+ headers: { "X-Api-Key": __classPrivateFieldGet(this, _FileUpload_accessKey, "f") },
194
+ });
195
+ });
196
+ }
175
197
  }
176
198
  _FileUpload_uppyIns = new WeakMap(), _FileUpload_accessKey = new WeakMap(), _FileUpload_stagingUrl = new WeakMap();
177
199
  export default FileUpload;
@@ -8,7 +8,17 @@ interface ObjMetaData {
8
8
  clothes_fit: string;
9
9
  scan_type?: string;
10
10
  callback_url: string;
11
- gyro?: string;
11
+ }
12
+ interface SetDeviceInfo {
13
+ detection?: string;
14
+ model?: string;
15
+ gyro: {
16
+ alpha?: string;
17
+ gamma?: string;
18
+ beta?: string;
19
+ timestamp?: string;
20
+ }[];
21
+ scanId: string;
12
22
  }
13
23
  interface UploadOptions {
14
24
  file: File;
@@ -21,5 +31,6 @@ export default class FileUpload {
21
31
  constructor(accessKey: string, stagingUrl?: boolean);
22
32
  uploadFileFrontend({ file, arrayMetaData, scanId, email }: UploadOptions): Promise<unknown>;
23
33
  uploadFile({ file, arrayMetaData, scanId, email }: UploadOptions): Promise<unknown>;
34
+ setDeviceInfo(data: SetDeviceInfo): Promise<import("axios").AxiosResponse<any, any>>;
24
35
  }
25
36
  export {};
@@ -151,5 +151,14 @@ class FileUpload {
151
151
  }
152
152
  });
153
153
  }
154
+ async setDeviceInfo(data) {
155
+ const { scanId, ...rest } = data;
156
+ if ((0, utils_js_1.checkParameters)(scanId) === false) {
157
+ throw new Error(constants_js_1.REQUIRED_MESSAGE);
158
+ }
159
+ return axios_1.default.post(`${(0, utils_js_1.getUrl)({ urlName: constants_js_1.APP_AUTH_BASE_URL, stagingUrl: this.#stagingUrl })}${constants_js_1.API_ENDPOINTS.DEVICE_INFO}/${scanId}`, { device_info: { ...rest } }, {
160
+ headers: { "X-Api-Key": this.#accessKey },
161
+ });
162
+ }
154
163
  }
155
164
  exports.default = FileUpload;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swan-admin/swan-ai-measurements",
3
- "version": "1.1.39",
3
+ "version": "1.1.41",
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,6 +45,7 @@ export const API_ENDPOINTS: {
45
45
  SCANNING: "/scanning",
46
46
  RECOMMENDATION: "/recommendation",
47
47
  TRY_ON_SHARE: "/tryon/share",
48
+ DEVICE_INFO:"/deviceinfo"
48
49
  };
49
50
  export interface ObjMetaData {
50
51
  gender: string;
package/src/fileUpload.ts CHANGED
@@ -5,6 +5,7 @@ import {
5
5
  FILE_UPLOAD_ENDPOINT,
6
6
  APP_AUTH_BASE_URL,
7
7
  REQUIRED_ERROR_MESSAGE_INVALID_EMAIL,
8
+ API_ENDPOINTS,
8
9
  } from "./constants.js";
9
10
  import { addScanType, checkMetaDataValue, checkParameters, fetchData, getFileChunks, getUrl, isValidEmail } from "./utils.js";
10
11
  import Uppy from "@uppy/core";
@@ -19,7 +20,13 @@ interface ObjMetaData {
19
20
  clothes_fit: string;
20
21
  scan_type?: string;
21
22
  callback_url: string;
22
- gyro?:string;
23
+ }
24
+
25
+ interface SetDeviceInfo {
26
+ detection?: string;
27
+ model?: string;
28
+ gyro: { alpha?: string; gamma?: string; beta?: string; timestamp?: string }[];
29
+ scanId:string
23
30
  }
24
31
 
25
32
  interface UploadOptions {
@@ -119,7 +126,6 @@ export default class FileUpload {
119
126
  });
120
127
  });
121
128
  }
122
-
123
129
  async uploadFile({ file, arrayMetaData, scanId, email }: UploadOptions) {
124
130
  if (!checkParameters(file, arrayMetaData, scanId, email)) {
125
131
  throw new Error(REQUIRED_MESSAGE);
@@ -179,4 +185,13 @@ export default class FileUpload {
179
185
  }
180
186
  });
181
187
  }
188
+ async setDeviceInfo(data:SetDeviceInfo) {
189
+ const {scanId,...rest} = data;
190
+ if (checkParameters(scanId) === false) {
191
+ throw new Error(REQUIRED_MESSAGE);
192
+ }
193
+ return axios.post(`${getUrl({ urlName: APP_AUTH_BASE_URL, stagingUrl: this.#stagingUrl })}${API_ENDPOINTS.DEVICE_INFO}/${scanId}`,{device_info:{...rest}} , {
194
+ headers: { "X-Api-Key": this.#accessKey },
195
+ });
196
+ }
182
197
  }