@swan-admin/swan-ai-measurements 1.0.69 → 1.0.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/auth.js CHANGED
@@ -1,54 +1,59 @@
1
- import axios from "axios";
2
- import { API_ENDPOINTS, APP_AUTH_BASE_URL, APP_AUTH_WEBSOCKET_URL, APP_BASE_URL, REQUIRED_MESSAGE } from "./constants.js";
3
- import { checkParameters } from "./utils.js";
4
- export default class Auth {
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const axios_1 = __importDefault(require("axios"));
7
+ const constants_js_1 = require("./constants.js");
8
+ const utils_js_1 = require("./utils.js");
9
+ class Auth {
5
10
  #socketRef;
6
11
  #accessKey;
7
12
  constructor(accessKey) {
8
13
  this.#accessKey = accessKey;
9
14
  }
10
15
  registerUser({ email, appVerifyUrl, gender, height, username }) {
11
- if (!checkParameters(email, appVerifyUrl)) {
12
- throw new Error(REQUIRED_MESSAGE);
16
+ if (!(0, utils_js_1.checkParameters)(email, appVerifyUrl)) {
17
+ throw new Error(constants_js_1.REQUIRED_MESSAGE);
13
18
  }
14
19
  let body = { username, email, appVerifyUrl };
15
20
  if (gender && height) {
16
21
  body = { ...body, attributes: { gender, height } };
17
22
  }
18
- return axios.post(`${APP_AUTH_BASE_URL}${API_ENDPOINTS.REGISTER_USER}`, body, {
23
+ return axios_1.default.post(`${constants_js_1.APP_AUTH_BASE_URL}${constants_js_1.API_ENDPOINTS.REGISTER_USER}`, body, {
19
24
  headers: { "X-Api-Key": this.#accessKey },
20
25
  });
21
26
  }
22
27
  verifyToken(token) {
23
- if (!checkParameters(token)) {
24
- throw new Error(REQUIRED_MESSAGE);
28
+ if (!(0, utils_js_1.checkParameters)(token)) {
29
+ throw new Error(constants_js_1.REQUIRED_MESSAGE);
25
30
  }
26
- return axios.post(`${APP_AUTH_BASE_URL}${API_ENDPOINTS.VERIFY_USER}`, null, {
31
+ return axios_1.default.post(`${constants_js_1.APP_AUTH_BASE_URL}${constants_js_1.API_ENDPOINTS.VERIFY_USER}`, null, {
27
32
  params: { token },
28
33
  headers: { "X-Api-Key": this.#accessKey },
29
34
  });
30
35
  }
31
36
  addUser({ scanId, email, name, height, gender, offsetMarketingConsent }) {
32
- if (!checkParameters(scanId, email, height, gender)) {
33
- throw new Error(REQUIRED_MESSAGE);
37
+ if (!(0, utils_js_1.checkParameters)(scanId, email, height, gender)) {
38
+ throw new Error(constants_js_1.REQUIRED_MESSAGE);
34
39
  }
35
- return axios.post(`${APP_AUTH_BASE_URL}${API_ENDPOINTS.ADD_USER}`, { scan_id: scanId, email, name, offsetMarketingConsent, attributes: JSON.stringify({ height, gender }) }, { headers: { "X-Api-Key": this.#accessKey } });
40
+ return axios_1.default.post(`${constants_js_1.APP_AUTH_BASE_URL}${constants_js_1.API_ENDPOINTS.ADD_USER}`, { scan_id: scanId, email, name, offsetMarketingConsent, attributes: JSON.stringify({ height, gender }) }, { headers: { "X-Api-Key": this.#accessKey } });
36
41
  }
37
42
  getUserDetail(email) {
38
- if (!checkParameters(email)) {
39
- throw new Error(REQUIRED_MESSAGE);
43
+ if (!(0, utils_js_1.checkParameters)(email)) {
44
+ throw new Error(constants_js_1.REQUIRED_MESSAGE);
40
45
  }
41
- return axios.get(`${APP_BASE_URL}${API_ENDPOINTS.GET_USER_DETAIL}/${email}`, {
46
+ return axios_1.default.get(`${constants_js_1.APP_BASE_URL}${constants_js_1.API_ENDPOINTS.GET_USER_DETAIL}/${email}`, {
42
47
  headers: { "X-Api-Key": this.#accessKey },
43
48
  });
44
49
  }
45
50
  handleAuthSocket({ email, scanId, onError, onSuccess, onClose, onOpen }) {
46
- if (!checkParameters(email, scanId)) {
47
- throw new Error(REQUIRED_MESSAGE);
51
+ if (!(0, utils_js_1.checkParameters)(email, scanId)) {
52
+ throw new Error(constants_js_1.REQUIRED_MESSAGE);
48
53
  }
49
54
  if (this.#socketRef)
50
55
  this.#socketRef.close();
51
- this.#socketRef = new WebSocket(`${APP_AUTH_WEBSOCKET_URL}${API_ENDPOINTS.AUTH}`);
56
+ this.#socketRef = new WebSocket(`${constants_js_1.APP_AUTH_WEBSOCKET_URL}${constants_js_1.API_ENDPOINTS.AUTH}`);
52
57
  const detailObj = { email, scanId };
53
58
  this.#socketRef.onopen = () => {
54
59
  this.#socketRef?.send(JSON.stringify(detailObj));
@@ -66,3 +71,4 @@ export default class Auth {
66
71
  };
67
72
  }
68
73
  }
74
+ exports.default = Auth;
package/dist/constants.js CHANGED
@@ -1,16 +1,19 @@
1
- export const APP_BASE_URL = "https://fitview-server-staging.ft2a64raup4pg.us-east-1.cs.amazonlightsail.com";
2
- export const APP_AUTH_BASE_URL = "https://staging.api.getswan.co";
3
- export const APP_AUTH_WEBSOCKET_URL = "wss://staging.wsnotify.api.getswan.co";
4
- export const APP_TRY_ON_WEBSOCKET_URL = "wss://bucbzczxjk.execute-api.ap-south-1.amazonaws.com";
5
- export const APP_RECOMMENDATION_WEBSOCKET_URL = "wss://staging.wsnotify.api.getswan.co/scanning";
6
- export const APP_POSE_DETECTION_WEBSOCKET_URL = "https://posedetect-service-staging.ft2a64raup4pg.us-east-1.cs.amazonlightsail.com";
7
- export const UPPY_FILE_UPLOAD_ENDPOINT = {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.REQUIRED_MESSAGE_FOR_META_DATA = exports.REQUIRED_MESSAGE = exports.requiredMetaData = exports.API_ENDPOINTS = exports.UPPY_FILE_UPLOAD_ENDPOINT = exports.APP_POSE_DETECTION_WEBSOCKET_URL = exports.APP_RECOMMENDATION_WEBSOCKET_URL = exports.APP_TRY_ON_WEBSOCKET_URL = exports.APP_AUTH_WEBSOCKET_URL = exports.APP_AUTH_BASE_URL = exports.APP_BASE_URL = void 0;
4
+ exports.APP_BASE_URL = "https://fitview-server-staging.ft2a64raup4pg.us-east-1.cs.amazonlightsail.com";
5
+ exports.APP_AUTH_BASE_URL = "https://staging.api.getswan.co";
6
+ exports.APP_AUTH_WEBSOCKET_URL = "wss://staging.wsnotify.api.getswan.co";
7
+ exports.APP_TRY_ON_WEBSOCKET_URL = "wss://bucbzczxjk.execute-api.ap-south-1.amazonaws.com";
8
+ exports.APP_RECOMMENDATION_WEBSOCKET_URL = "wss://staging.wsnotify.api.getswan.co/scanning";
9
+ exports.APP_POSE_DETECTION_WEBSOCKET_URL = "https://posedetect-service-staging.ft2a64raup4pg.us-east-1.cs.amazonlightsail.com";
10
+ exports.UPPY_FILE_UPLOAD_ENDPOINT = {
8
11
  UPLOAD_START: "/upload/start",
9
12
  UPLOAD_COMPLETE: "/upload/complete",
10
13
  UPLOAD_SIGN_PART: "/upload/signpart",
11
14
  UPLOAD_ABORT: "/upload/abort",
12
15
  };
13
- export const API_ENDPOINTS = {
16
+ exports.API_ENDPOINTS = {
14
17
  GET_USER_DETAIL: "/api/user",
15
18
  REGISTER_USER: "/auth/register",
16
19
  VERIFY_USER: "/auth/verify",
@@ -25,7 +28,7 @@ export const API_ENDPOINTS = {
25
28
  TRY_ON: "/tryon",
26
29
  AUTH: "/auth",
27
30
  };
28
- export const requiredMetaData = [
31
+ exports.requiredMetaData = [
29
32
  "gender",
30
33
  "scan_id",
31
34
  "email",
@@ -36,5 +39,5 @@ export const requiredMetaData = [
36
39
  "callback_url",
37
40
  "clothes_fit",
38
41
  ];
39
- export const REQUIRED_MESSAGE = "Please verify required parameters";
40
- export const REQUIRED_MESSAGE_FOR_META_DATA = "Please verify required parameters in meta data";
42
+ exports.REQUIRED_MESSAGE = "Please verify required parameters";
43
+ exports.REQUIRED_MESSAGE_FOR_META_DATA = "Please verify required parameters in meta data";
package/dist/custom.js CHANGED
@@ -1,25 +1,30 @@
1
- import axios from "axios";
2
- import { API_ENDPOINTS, APP_AUTH_BASE_URL, REQUIRED_MESSAGE } from "./constants.js";
3
- import { checkParameters } from "./utils.js";
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const axios_1 = __importDefault(require("axios"));
7
+ const constants_js_1 = require("./constants.js");
8
+ const utils_js_1 = require("./utils.js");
4
9
  class Custom {
5
10
  #accessKey;
6
11
  constructor(accessKey) {
7
12
  this.#accessKey = accessKey;
8
13
  }
9
14
  getCustomCustomerConfig = (store_url) => {
10
- if (checkParameters(store_url) === false) {
11
- throw new Error(REQUIRED_MESSAGE);
15
+ if ((0, utils_js_1.checkParameters)(store_url) === false) {
16
+ throw new Error(constants_js_1.REQUIRED_MESSAGE);
12
17
  }
13
- return axios.get(`${APP_AUTH_BASE_URL}${API_ENDPOINTS.CUSTOM_CUSTOMER}`, {
18
+ return axios_1.default.get(`${constants_js_1.APP_AUTH_BASE_URL}${constants_js_1.API_ENDPOINTS.CUSTOM_CUSTOMER}`, {
14
19
  params: { store_url },
15
20
  headers: { "X-Api-Key": this.#accessKey },
16
21
  });
17
22
  };
18
23
  getModelUrl = (id) => {
19
- if (checkParameters(id) === false) {
20
- throw new Error(REQUIRED_MESSAGE);
24
+ if ((0, utils_js_1.checkParameters)(id) === false) {
25
+ throw new Error(constants_js_1.REQUIRED_MESSAGE);
21
26
  }
22
- return axios.get(`${APP_AUTH_BASE_URL}${API_ENDPOINTS.MODEL}/${id}`, { headers: { "X-Api-Key": this.#accessKey } });
27
+ return axios_1.default.get(`${constants_js_1.APP_AUTH_BASE_URL}${constants_js_1.API_ENDPOINTS.MODEL}/${id}`, { headers: { "X-Api-Key": this.#accessKey } });
23
28
  };
24
29
  }
25
- export default Custom;
30
+ exports.default = Custom;
@@ -21,8 +21,8 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
21
21
  var _FileUpload_uppyIns, _FileUpload_accessKey;
22
22
  import { REQUIRED_MESSAGE, REQUIRED_MESSAGE_FOR_META_DATA, UPPY_FILE_UPLOAD_ENDPOINT } from "./constants.js";
23
23
  import { checkMetaDataValue, checkParameters, fetchData } from "./utils.js";
24
- import Uppy from "@uppy/core";
25
- import AwsS3Multipart from "@uppy/aws-s3-multipart";
24
+ const Uppy = require("fix-esm").require("@uppy/core");
25
+ const AwsS3Multipart = require("fix-esm").require("@uppy/aws-s3-multipart");
26
26
  class FileUpload {
27
27
  constructor(accessKey) {
28
28
  _FileUpload_uppyIns.set(this, void 0);
@@ -41,8 +41,8 @@ class FileUpload {
41
41
  if (__classPrivateFieldGet(this, _FileUpload_uppyIns, "f")) {
42
42
  __classPrivateFieldGet(this, _FileUpload_uppyIns, "f").close();
43
43
  }
44
- __classPrivateFieldSet(this, _FileUpload_uppyIns, new Uppy({ autoProceed: true }), "f");
45
- __classPrivateFieldGet(this, _FileUpload_uppyIns, "f").use(AwsS3Multipart, {
44
+ __classPrivateFieldSet(this, _FileUpload_uppyIns, new Uppy.default({ autoProceed: true }), "f");
45
+ __classPrivateFieldGet(this, _FileUpload_uppyIns, "f").use(AwsS3Multipart.default, {
46
46
  limit: 10,
47
47
  retryDelays: [0, 1000, 3000, 5000],
48
48
  getChunkSize: () => 5 * 1024 * 1024,
@@ -1,33 +1,35 @@
1
- import { REQUIRED_MESSAGE, REQUIRED_MESSAGE_FOR_META_DATA, UPPY_FILE_UPLOAD_ENDPOINT } from "./constants.js";
2
- import { checkMetaDataValue, checkParameters, fetchData } from "./utils.js";
3
- import Uppy from "@uppy/core";
4
- import AwsS3Multipart from "@uppy/aws-s3-multipart";
5
- export default class FileUpload {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const constants_js_1 = require("./constants.js");
4
+ const utils_js_1 = require("./utils.js");
5
+ const Uppy = require("fix-esm").require("@uppy/core");
6
+ const AwsS3Multipart = require("fix-esm").require("@uppy/aws-s3-multipart");
7
+ class FileUpload {
6
8
  #uppyIns;
7
9
  #accessKey;
8
10
  constructor(accessKey) {
9
11
  this.#accessKey = accessKey;
10
12
  }
11
13
  async uploadFile({ file, arrayMetaData, scanId }) {
12
- if (!checkParameters(file, arrayMetaData, scanId)) {
13
- throw new Error(REQUIRED_MESSAGE);
14
+ if (!(0, utils_js_1.checkParameters)(file, arrayMetaData, scanId)) {
15
+ throw new Error(constants_js_1.REQUIRED_MESSAGE);
14
16
  }
15
- if (!checkMetaDataValue(arrayMetaData)) {
16
- throw new Error(REQUIRED_MESSAGE_FOR_META_DATA);
17
+ if (!(0, utils_js_1.checkMetaDataValue)(arrayMetaData)) {
18
+ throw new Error(constants_js_1.REQUIRED_MESSAGE_FOR_META_DATA);
17
19
  }
18
20
  return new Promise((resolve, reject) => {
19
21
  if (this.#uppyIns) {
20
22
  this.#uppyIns.close();
21
23
  }
22
- this.#uppyIns = new Uppy({ autoProceed: true });
23
- this.#uppyIns.use(AwsS3Multipart, {
24
+ this.#uppyIns = new Uppy.default({ autoProceed: true });
25
+ this.#uppyIns.use(AwsS3Multipart.default, {
24
26
  limit: 10,
25
27
  retryDelays: [0, 1000, 3000, 5000],
26
28
  getChunkSize: () => 5 * 1024 * 1024,
27
29
  createMultipartUpload: (file) => {
28
30
  const objectKey = `${scanId}.${file.extension}`;
29
- return fetchData({
30
- path: UPPY_FILE_UPLOAD_ENDPOINT.UPLOAD_START,
31
+ return (0, utils_js_1.fetchData)({
32
+ path: constants_js_1.UPPY_FILE_UPLOAD_ENDPOINT.UPLOAD_START,
31
33
  apiKey: this.#accessKey,
32
34
  body: {
33
35
  objectKey,
@@ -36,8 +38,8 @@ export default class FileUpload {
36
38
  },
37
39
  });
38
40
  },
39
- completeMultipartUpload: (file, { uploadId, key, parts }) => fetchData({
40
- path: UPPY_FILE_UPLOAD_ENDPOINT.UPLOAD_COMPLETE,
41
+ completeMultipartUpload: (file, { uploadId, key, parts }) => (0, utils_js_1.fetchData)({
42
+ path: constants_js_1.UPPY_FILE_UPLOAD_ENDPOINT.UPLOAD_COMPLETE,
41
43
  apiKey: this.#accessKey,
42
44
  body: {
43
45
  uploadId,
@@ -46,8 +48,8 @@ export default class FileUpload {
46
48
  originalFileName: file.name,
47
49
  },
48
50
  }),
49
- signPart: (file, partData) => fetchData({
50
- path: UPPY_FILE_UPLOAD_ENDPOINT.UPLOAD_SIGN_PART,
51
+ signPart: (file, partData) => (0, utils_js_1.fetchData)({
52
+ path: constants_js_1.UPPY_FILE_UPLOAD_ENDPOINT.UPLOAD_SIGN_PART,
51
53
  apiKey: this.#accessKey,
52
54
  body: {
53
55
  objectKey: partData.key,
@@ -55,8 +57,8 @@ export default class FileUpload {
55
57
  partNumber: partData.partNumber,
56
58
  },
57
59
  }),
58
- abortMultipartUpload: (file, { uploadId, key }) => fetchData({
59
- path: UPPY_FILE_UPLOAD_ENDPOINT.UPLOAD_ABORT,
60
+ abortMultipartUpload: (file, { uploadId, key }) => (0, utils_js_1.fetchData)({
61
+ path: constants_js_1.UPPY_FILE_UPLOAD_ENDPOINT.UPLOAD_ABORT,
60
62
  apiKey: this.#accessKey,
61
63
  body: {
62
64
  uploadId,
@@ -85,3 +87,4 @@ export default class FileUpload {
85
87
  });
86
88
  }
87
89
  }
90
+ exports.default = FileUpload;
package/dist/index.js CHANGED
@@ -1,9 +1,14 @@
1
- import Auth from "./auth.js";
2
- import Custom from "./custom.js";
3
- import FileUpload from "./fileUpload.js";
4
- import Measurement from "./measurement.js";
5
- import PoseDetection from "./poseDetection.js";
6
- import TryOn from "./tryOn.js";
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const auth_js_1 = __importDefault(require("./auth.js"));
7
+ const custom_js_1 = __importDefault(require("./custom.js"));
8
+ const fileUpload_js_1 = __importDefault(require("./fileUpload.js"));
9
+ const measurement_js_1 = __importDefault(require("./measurement.js"));
10
+ const poseDetection_js_1 = __importDefault(require("./poseDetection.js"));
11
+ const tryOn_js_1 = __importDefault(require("./tryOn.js"));
7
12
  class Swan {
8
13
  #accessKey;
9
14
  auth;
@@ -14,12 +19,12 @@ class Swan {
14
19
  tryOn;
15
20
  constructor(accessKey) {
16
21
  this.#accessKey = accessKey;
17
- this.auth = new Auth(this.#accessKey);
18
- this.custom = new Custom(this.#accessKey);
19
- this.fileUpload = new FileUpload(this.#accessKey);
20
- this.measurement = new Measurement(this.#accessKey);
21
- this.poseDetection = new PoseDetection(this.#accessKey);
22
- this.tryOn = new TryOn(this.#accessKey);
22
+ this.auth = new auth_js_1.default(this.#accessKey);
23
+ this.custom = new custom_js_1.default(this.#accessKey);
24
+ this.fileUpload = new fileUpload_js_1.default(this.#accessKey);
25
+ this.measurement = new measurement_js_1.default(this.#accessKey);
26
+ this.poseDetection = new poseDetection_js_1.default(this.#accessKey);
27
+ this.tryOn = new tryOn_js_1.default(this.#accessKey);
23
28
  }
24
29
  }
25
- export default Swan;
30
+ exports.default = Swan;
@@ -1,6 +1,11 @@
1
- import axios from "axios";
2
- import { API_ENDPOINTS, APP_AUTH_BASE_URL, APP_RECOMMENDATION_WEBSOCKET_URL, APP_TRY_ON_WEBSOCKET_URL, REQUIRED_MESSAGE } from "./constants.js";
3
- import { checkParameters } from "./utils.js";
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const axios_1 = __importDefault(require("axios"));
7
+ const constants_js_1 = require("./constants.js");
8
+ const utils_js_1 = require("./utils.js");
4
9
  class Measurement {
5
10
  #tryOnSocketRef = null;
6
11
  #measurementSocketRef = null;
@@ -12,28 +17,28 @@ class Measurement {
12
17
  this.#accessKey = accessKey;
13
18
  }
14
19
  getMeasurementResult(scanId) {
15
- if (!checkParameters(scanId)) {
16
- throw new Error(REQUIRED_MESSAGE);
20
+ if (!(0, utils_js_1.checkParameters)(scanId)) {
21
+ throw new Error(constants_js_1.REQUIRED_MESSAGE);
17
22
  }
18
- const url = `${APP_AUTH_BASE_URL}/measurements?scanId=${scanId}`;
19
- return axios.get(url, {
23
+ const url = `${constants_js_1.APP_AUTH_BASE_URL}/measurements?scanId=${scanId}`;
24
+ return axios_1.default.get(url, {
20
25
  headers: { "X-Api-Key": this.#accessKey },
21
26
  });
22
27
  }
23
28
  getTryOnMeasurements({ scanId, shopDomain, productName }) {
24
- if (!checkParameters(scanId, shopDomain, productName)) {
25
- throw new Error(REQUIRED_MESSAGE);
29
+ if (!(0, utils_js_1.checkParameters)(scanId, shopDomain, productName)) {
30
+ throw new Error(constants_js_1.REQUIRED_MESSAGE);
26
31
  }
27
- const tryOnUrl = `${APP_AUTH_BASE_URL}${API_ENDPOINTS.TRY_ON_SCAN}/${scanId}/shop/${shopDomain}/product/${productName}`;
28
- return axios.get(tryOnUrl, { headers: { "X-Api-Key": this.#accessKey } });
32
+ const tryOnUrl = `${constants_js_1.APP_AUTH_BASE_URL}${constants_js_1.API_ENDPOINTS.TRY_ON_SCAN}/${scanId}/shop/${shopDomain}/product/${productName}`;
33
+ return axios_1.default.get(tryOnUrl, { headers: { "X-Api-Key": this.#accessKey } });
29
34
  }
30
35
  handleTryOnSocket(options) {
31
36
  const { shopDomain, scanId, productName, onError, onSuccess, onClose, onOpen } = options;
32
- if (!checkParameters(shopDomain, scanId, productName)) {
33
- throw new Error(REQUIRED_MESSAGE);
37
+ if (!(0, utils_js_1.checkParameters)(shopDomain, scanId, productName)) {
38
+ throw new Error(constants_js_1.REQUIRED_MESSAGE);
34
39
  }
35
40
  this.#tryOnSocketRef?.close();
36
- const url = `${APP_TRY_ON_WEBSOCKET_URL}/develop?store_url=${shopDomain}&product_name=${productName}&scan_id=${scanId}`;
41
+ const url = `${constants_js_1.APP_TRY_ON_WEBSOCKET_URL}/develop?store_url=${shopDomain}&product_name=${productName}&scan_id=${scanId}`;
37
42
  this.#tryOnSocketRef = new WebSocket(url);
38
43
  this.#tryOnSocketRef.onopen = () => {
39
44
  onOpen?.();
@@ -110,12 +115,12 @@ class Measurement {
110
115
  }
111
116
  handleMeasurementSocket(options) {
112
117
  const { scanId, onError, onSuccess, onClose, onOpen } = options;
113
- if (!checkParameters(scanId)) {
114
- throw new Error(REQUIRED_MESSAGE);
118
+ if (!(0, utils_js_1.checkParameters)(scanId)) {
119
+ throw new Error(constants_js_1.REQUIRED_MESSAGE);
115
120
  }
116
121
  setTimeout(() => {
117
122
  this.#disconnectSocket();
118
- const url = `${APP_RECOMMENDATION_WEBSOCKET_URL}?scanId=${scanId}`;
123
+ const url = `${constants_js_1.APP_RECOMMENDATION_WEBSOCKET_URL}?scanId=${scanId}`;
119
124
  this.#measurementSocketRef = new WebSocket(url);
120
125
  this.#measurementSocketRef.onopen = () => {
121
126
  onOpen?.();
@@ -142,4 +147,4 @@ class Measurement {
142
147
  }, 5000);
143
148
  }
144
149
  }
145
- export default Measurement;
150
+ exports.default = Measurement;
@@ -1,5 +1,7 @@
1
- import { io } from "socket.io-client";
2
- import { APP_POSE_DETECTION_WEBSOCKET_URL } from "./constants.js";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const socket_io_client_1 = require("socket.io-client");
4
+ const constants_js_1 = require("./constants.js");
3
5
  class PoseDetection {
4
6
  #socketRef = null;
5
7
  #accessKey;
@@ -8,7 +10,7 @@ class PoseDetection {
8
10
  }
9
11
  connect() {
10
12
  return new Promise((resolve, reject) => {
11
- this.#socketRef = io(APP_POSE_DETECTION_WEBSOCKET_URL, {
13
+ this.#socketRef = (0, socket_io_client_1.io)(constants_js_1.APP_POSE_DETECTION_WEBSOCKET_URL, {
12
14
  auth: {
13
15
  token: this.#accessKey,
14
16
  },
@@ -51,4 +53,4 @@ class PoseDetection {
51
53
  return !!this.#socketRef?.connected;
52
54
  }
53
55
  }
54
- export default PoseDetection;
56
+ exports.default = PoseDetection;
package/dist/tryOn.js CHANGED
@@ -1,6 +1,11 @@
1
- import axios from "axios";
2
- import { API_ENDPOINTS, APP_AUTH_BASE_URL, APP_AUTH_WEBSOCKET_URL, REQUIRED_MESSAGE } from "./constants.js";
3
- import { checkParameters } from "./utils.js";
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const axios_1 = __importDefault(require("axios"));
7
+ const constants_js_1 = require("./constants.js");
8
+ const utils_js_1 = require("./utils.js");
4
9
  class TryOn {
5
10
  #tryOnSocketRef = null;
6
11
  #timerWaitingRef = null;
@@ -28,7 +33,7 @@ class TryOn {
28
33
  }
29
34
  }
30
35
  #getSignedUrl(payload) {
31
- return axios.post(`${APP_AUTH_BASE_URL}${API_ENDPOINTS.TRY_ON_IMAGE_UPLOAD}`, payload, {
36
+ return axios_1.default.post(`${constants_js_1.APP_AUTH_BASE_URL}${constants_js_1.API_ENDPOINTS.TRY_ON_IMAGE_UPLOAD}`, payload, {
32
37
  headers: {
33
38
  "Content-Type": "application/json",
34
39
  "X-Api-Key": this.#accessKey,
@@ -36,25 +41,25 @@ class TryOn {
36
41
  });
37
42
  }
38
43
  #s3Upload(url, file) {
39
- return axios.put(url, file, {
44
+ return axios_1.default.put(url, file, {
40
45
  headers: {
41
46
  "Content-Type": file.type,
42
47
  },
43
48
  });
44
49
  }
45
50
  getUploadedFiles(userId) {
46
- if (checkParameters(userId) === false) {
47
- throw new Error(REQUIRED_MESSAGE);
51
+ if ((0, utils_js_1.checkParameters)(userId) === false) {
52
+ throw new Error(constants_js_1.REQUIRED_MESSAGE);
48
53
  }
49
- return axios.post(`${APP_AUTH_BASE_URL}${API_ENDPOINTS.TRY_ON_IMAGE_DOWNLOAD}?userId=${userId}`, null, {
54
+ return axios_1.default.post(`${constants_js_1.APP_AUTH_BASE_URL}${constants_js_1.API_ENDPOINTS.TRY_ON_IMAGE_DOWNLOAD}?userId=${userId}`, null, {
50
55
  headers: { "X-Api-Key": this.#accessKey },
51
56
  });
52
57
  }
53
58
  deleteImage({ userId, fileName }) {
54
- if (checkParameters(userId, fileName) === false) {
55
- throw new Error(REQUIRED_MESSAGE);
59
+ if ((0, utils_js_1.checkParameters)(userId, fileName) === false) {
60
+ throw new Error(constants_js_1.REQUIRED_MESSAGE);
56
61
  }
57
- return axios.delete(`${APP_AUTH_BASE_URL}${API_ENDPOINTS.TRY_ON_IMAGE_URLS}?userId=${userId}&file=${fileName}`, {
62
+ return axios_1.default.delete(`${constants_js_1.APP_AUTH_BASE_URL}${constants_js_1.API_ENDPOINTS.TRY_ON_IMAGE_URLS}?userId=${userId}&file=${fileName}`, {
58
63
  headers: { "X-Api-Key": this.#accessKey },
59
64
  });
60
65
  }
@@ -71,11 +76,11 @@ class TryOn {
71
76
  }, 120000);
72
77
  };
73
78
  handleTryOnWebSocket = ({ shopDomain, userId, productName, onError, onSuccess, onClose, onOpen }) => {
74
- if (checkParameters(shopDomain, userId, productName) === false) {
75
- throw new Error(REQUIRED_MESSAGE);
79
+ if ((0, utils_js_1.checkParameters)(shopDomain, userId, productName) === false) {
80
+ throw new Error(constants_js_1.REQUIRED_MESSAGE);
76
81
  }
77
82
  this.#disconnectSocket();
78
- const url = `${APP_AUTH_WEBSOCKET_URL}${API_ENDPOINTS.TRY_ON}/?store_url=${shopDomain}&product_name=${productName}&scan_id=${userId}`;
83
+ const url = `${constants_js_1.APP_AUTH_WEBSOCKET_URL}${constants_js_1.API_ENDPOINTS.TRY_ON}/?store_url=${shopDomain}&product_name=${productName}&scan_id=${userId}`;
79
84
  this.#tryOnSocketRef = new WebSocket(url);
80
85
  this.#tryOnSocketRef.onopen = async () => {
81
86
  onOpen?.();
@@ -110,12 +115,12 @@ class TryOn {
110
115
  };
111
116
  };
112
117
  handleForLatestImage = async ({ userId, shopDomain, productName, onError }) => {
113
- if (checkParameters(shopDomain, userId, productName) === false) {
114
- throw new Error(REQUIRED_MESSAGE);
118
+ if ((0, utils_js_1.checkParameters)(shopDomain, userId, productName) === false) {
119
+ throw new Error(constants_js_1.REQUIRED_MESSAGE);
115
120
  }
116
121
  try {
117
- const url = `${APP_AUTH_BASE_URL}${API_ENDPOINTS.TRY_ON}/?scan_id=${userId}&store_url=${shopDomain}&product_name=${productName}`;
118
- const res = await axios.post(url, null, {
122
+ const url = `${constants_js_1.APP_AUTH_BASE_URL}${constants_js_1.API_ENDPOINTS.TRY_ON}/?scan_id=${userId}&store_url=${shopDomain}&product_name=${productName}`;
123
+ const res = await axios_1.default.post(url, null, {
119
124
  headers: { "X-Api-Key": this.#accessKey },
120
125
  });
121
126
  if (res?.data?.tryOnProcessStatus === "failed") {
@@ -142,13 +147,13 @@ class TryOn {
142
147
  }
143
148
  };
144
149
  getTryOnResult = ({ userId, shopDomain, productName }) => {
145
- if (checkParameters(shopDomain, userId, productName) === false) {
146
- throw new Error(REQUIRED_MESSAGE);
150
+ if ((0, utils_js_1.checkParameters)(shopDomain, userId, productName) === false) {
151
+ throw new Error(constants_js_1.REQUIRED_MESSAGE);
147
152
  }
148
- const url = `${APP_AUTH_BASE_URL}${API_ENDPOINTS.TRY_ON_RESULT_IMAGE_DOWNLOAD}?scan_id=${userId}&store_url=${shopDomain}&product_name=${productName}`;
149
- return axios.post(url, null, {
153
+ const url = `${constants_js_1.APP_AUTH_BASE_URL}${constants_js_1.API_ENDPOINTS.TRY_ON_RESULT_IMAGE_DOWNLOAD}?scan_id=${userId}&store_url=${shopDomain}&product_name=${productName}`;
154
+ return axios_1.default.post(url, null, {
150
155
  headers: { "X-Api-Key": this.#accessKey },
151
156
  });
152
157
  };
153
158
  }
154
- export default TryOn;
159
+ exports.default = TryOn;
package/dist/utils.js CHANGED
@@ -1,10 +1,16 @@
1
- import axios from "axios";
2
- import { APP_AUTH_BASE_URL, requiredMetaData } from "./constants.js";
3
- export async function fetchData(options) {
4
- const { path, body, queryParams, baseUrl = APP_AUTH_BASE_URL, apiKey = "", headers = { "X-Api-Key": apiKey, "Content-Type": "application/json" }, } = options;
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.checkMetaDataValue = exports.checkParameters = exports.fetchData = void 0;
7
+ const axios_1 = __importDefault(require("axios"));
8
+ const constants_js_1 = require("./constants.js");
9
+ async function fetchData(options) {
10
+ const { path, body, queryParams, baseUrl = constants_js_1.APP_AUTH_BASE_URL, apiKey = "", headers = { "X-Api-Key": apiKey, "Content-Type": "application/json" }, } = options;
5
11
  const apiUrl = `${baseUrl}${path}${queryParams ? `?${new URLSearchParams(queryParams)}` : ""}`;
6
12
  try {
7
- const res = await axios.post(apiUrl, body, { headers });
13
+ const res = await axios_1.default.post(apiUrl, body, { headers });
8
14
  if (res.status >= 200 && res.status < 300) {
9
15
  return res.data;
10
16
  }
@@ -16,7 +22,8 @@ export async function fetchData(options) {
16
22
  return {};
17
23
  }
18
24
  }
19
- export function checkParameters(...args) {
25
+ exports.fetchData = fetchData;
26
+ function checkParameters(...args) {
20
27
  for (const element of args) {
21
28
  if (!element) {
22
29
  return false;
@@ -24,8 +31,9 @@ export function checkParameters(...args) {
24
31
  }
25
32
  return true;
26
33
  }
27
- export function checkMetaDataValue(arr) {
28
- for (const key of requiredMetaData) {
34
+ exports.checkParameters = checkParameters;
35
+ function checkMetaDataValue(arr) {
36
+ for (const key of constants_js_1.requiredMetaData) {
29
37
  let hasRequiredKey = false;
30
38
  for (const obj of arr) {
31
39
  if (obj.hasOwnProperty(key) && obj[key] !== undefined && obj[key] !== null && obj[key] !== "" && typeof obj[key] !== "number") {
@@ -48,3 +56,4 @@ export function checkMetaDataValue(arr) {
48
56
  }
49
57
  return true;
50
58
  }
59
+ exports.checkMetaDataValue = checkMetaDataValue;
package/package.json CHANGED
@@ -1,58 +1,58 @@
1
- {
2
- "name": "@swan-admin/swan-ai-measurements",
3
- "version": "1.0.69",
4
- "description": "provides ai measurement suggestion",
5
- "main": "dist/index.js",
6
- "module": "dist/esm/index.js",
7
- "types": "dist/index.d.ts",
8
- "type": "module",
9
- "exports": {
10
- ".": {
11
- "require": "./dist/index.js",
12
- "import": "./dist/esm/index.js"
13
- }
14
- },
15
- "dependencies": {
16
- "@types/axios": "^0.14.0",
17
- "@types/node": "^20.12.12",
18
- "@uppy/aws-s3-multipart": "^3.11.1",
19
- "@uppy/core": "^3.11.3",
20
- "axios": "^1.6.7",
21
- "socket.io": "^4.7.5",
22
- "socket.io-client": "^4.7.5",
23
- "tslib": "^2.6.2",
24
- "typescript": "^5.4.5"
25
- },
26
- "scripts": {
27
- "start": "nodemon dist/index.js",
28
- "build": "tsc && tsc --project tsconfig.esm.json",
29
- "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
30
- "start:dev": "nodemon src/index.ts",
31
- "start:debug": "nodemon --inspect-brk src/index.ts",
32
- "start:prod": "node dist/index.js",
33
- "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
34
- "test": "jest",
35
- "test:watch": "jest --watch",
36
- "test:cov": "jest --coverage",
37
- "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
38
- "test:e2e": "jest --config ./test/jest-e2e.json"
39
- },
40
- "repository": {
41
- "type": "git",
42
- "url": "https://github.com/paras-swan/swan-ai-measurements.git"
43
- },
44
- "keywords": [
45
- "swan",
46
- "ai",
47
- "fitview"
48
- ],
49
- "author": "paras",
50
- "license": "ISC",
51
- "bugs": {
52
- "url": "https://github.com/paras-swan/swan-ai-measurements/issues"
53
- },
54
- "homepage": "https://github.com/paras-swan/swan-ai-measurements#readme",
55
- "devDependencies": {
56
- "nodemon": "^3.1.0"
57
- }
58
- }
1
+ {
2
+ "name": "@swan-admin/swan-ai-measurements",
3
+ "version": "1.0.71",
4
+ "description": "provides ai measurement suggestion",
5
+ "main": "dist/index.js",
6
+ "module": "dist/esm/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "require": "./dist/index.js",
11
+ "import": "./dist/esm/index.js"
12
+ }
13
+ },
14
+ "dependencies": {
15
+ "@types/axios": "^0.14.0",
16
+ "@types/node": "^20.12.12",
17
+ "@uppy/aws-s3-multipart": "^3.11.1",
18
+ "@uppy/core": "^3.11.3",
19
+ "axios": "^1.6.7",
20
+ "socket.io": "^4.7.5",
21
+ "socket.io-client": "^4.7.5",
22
+ "tslib": "^2.6.2",
23
+ "typescript": "^5.4.5",
24
+ "fix-esm": "^1.0.1"
25
+ },
26
+ "scripts": {
27
+ "start": "nodemon dist/index.js",
28
+ "build": "tsc && tsc --project tsconfig.esm.json",
29
+ "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
30
+ "start:dev": "nodemon src/index.ts",
31
+ "start:debug": "nodemon --inspect-brk src/index.ts",
32
+ "start:prod": "node dist/index.js",
33
+ "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
34
+ "test": "jest",
35
+ "test:watch": "jest --watch",
36
+ "test:cov": "jest --coverage",
37
+ "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
38
+ "test:e2e": "jest --config ./test/jest-e2e.json"
39
+ },
40
+ "repository": {
41
+ "type": "git",
42
+ "url": "https://github.com/paras-swan/swan-ai-measurements.git"
43
+ },
44
+ "keywords": [
45
+ "swan",
46
+ "ai",
47
+ "fitview"
48
+ ],
49
+ "author": "paras",
50
+ "license": "ISC",
51
+ "bugs": {
52
+ "url": "https://github.com/paras-swan/swan-ai-measurements/issues"
53
+ },
54
+ "homepage": "https://github.com/paras-swan/swan-ai-measurements#readme",
55
+ "devDependencies": {
56
+ "nodemon": "^3.1.0"
57
+ }
58
+ }
package/src/fileUpload.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { REQUIRED_MESSAGE, REQUIRED_MESSAGE_FOR_META_DATA, UPPY_FILE_UPLOAD_ENDPOINT } from "./constants.js";
2
2
  import { checkMetaDataValue, checkParameters, fetchData } from "./utils.js";
3
- import Uppy from "@uppy/core";
4
- import AwsS3Multipart from "@uppy/aws-s3-multipart";
3
+ const Uppy = require("fix-esm").require("@uppy/core");
4
+ const AwsS3Multipart = require("fix-esm").require("@uppy/aws-s3-multipart");
5
5
  interface ObjMetaData {
6
6
  gender: string;
7
7
  scan_id: string;
@@ -40,8 +40,8 @@ export default class FileUpload {
40
40
  if (this.#uppyIns) {
41
41
  this.#uppyIns.close();
42
42
  }
43
- this.#uppyIns = new Uppy({ autoProceed: true });
44
- this.#uppyIns.use(AwsS3Multipart, {
43
+ this.#uppyIns = new Uppy.default({ autoProceed: true });
44
+ this.#uppyIns.use(AwsS3Multipart.default, {
45
45
  limit: 10,
46
46
  retryDelays: [0, 1000, 3000, 5000],
47
47
  getChunkSize: () => 5 * 1024 * 1024,
package/tsconfig.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "compilerOptions": {
3
3
  "target": "esnext", // Ensure ESNext to support dynamic imports
4
- "module": "ES2022",
4
+ "module": "commonjs",
5
5
  "moduleResolution": "node",
6
6
  "outDir": "./dist",
7
7
  "declaration": true,