@swan-admin/swan-ai-measurements 1.0.67 → 1.0.69

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,59 +1,54 @@
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_1 = require("./constants");
8
- const utils_1 = require("./utils");
9
- class Auth {
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 {
10
5
  #socketRef;
11
6
  #accessKey;
12
7
  constructor(accessKey) {
13
8
  this.#accessKey = accessKey;
14
9
  }
15
10
  registerUser({ email, appVerifyUrl, gender, height, username }) {
16
- if (!(0, utils_1.checkParameters)(email, appVerifyUrl)) {
17
- throw new Error(constants_1.REQUIRED_MESSAGE);
11
+ if (!checkParameters(email, appVerifyUrl)) {
12
+ throw new Error(REQUIRED_MESSAGE);
18
13
  }
19
14
  let body = { username, email, appVerifyUrl };
20
15
  if (gender && height) {
21
16
  body = { ...body, attributes: { gender, height } };
22
17
  }
23
- return axios_1.default.post(`${constants_1.APP_AUTH_BASE_URL}${constants_1.API_ENDPOINTS.REGISTER_USER}`, body, {
18
+ return axios.post(`${APP_AUTH_BASE_URL}${API_ENDPOINTS.REGISTER_USER}`, body, {
24
19
  headers: { "X-Api-Key": this.#accessKey },
25
20
  });
26
21
  }
27
22
  verifyToken(token) {
28
- if (!(0, utils_1.checkParameters)(token)) {
29
- throw new Error(constants_1.REQUIRED_MESSAGE);
23
+ if (!checkParameters(token)) {
24
+ throw new Error(REQUIRED_MESSAGE);
30
25
  }
31
- return axios_1.default.post(`${constants_1.APP_AUTH_BASE_URL}${constants_1.API_ENDPOINTS.VERIFY_USER}`, null, {
26
+ return axios.post(`${APP_AUTH_BASE_URL}${API_ENDPOINTS.VERIFY_USER}`, null, {
32
27
  params: { token },
33
28
  headers: { "X-Api-Key": this.#accessKey },
34
29
  });
35
30
  }
36
31
  addUser({ scanId, email, name, height, gender, offsetMarketingConsent }) {
37
- if (!(0, utils_1.checkParameters)(scanId, email, height, gender)) {
38
- throw new Error(constants_1.REQUIRED_MESSAGE);
32
+ if (!checkParameters(scanId, email, height, gender)) {
33
+ throw new Error(REQUIRED_MESSAGE);
39
34
  }
40
- return axios_1.default.post(`${constants_1.APP_AUTH_BASE_URL}${constants_1.API_ENDPOINTS.ADD_USER}`, { scan_id: scanId, email, name, offsetMarketingConsent, attributes: JSON.stringify({ height, gender }) }, { headers: { "X-Api-Key": this.#accessKey } });
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 } });
41
36
  }
42
37
  getUserDetail(email) {
43
- if (!(0, utils_1.checkParameters)(email)) {
44
- throw new Error(constants_1.REQUIRED_MESSAGE);
38
+ if (!checkParameters(email)) {
39
+ throw new Error(REQUIRED_MESSAGE);
45
40
  }
46
- return axios_1.default.get(`${constants_1.APP_BASE_URL}${constants_1.API_ENDPOINTS.GET_USER_DETAIL}/${email}`, {
41
+ return axios.get(`${APP_BASE_URL}${API_ENDPOINTS.GET_USER_DETAIL}/${email}`, {
47
42
  headers: { "X-Api-Key": this.#accessKey },
48
43
  });
49
44
  }
50
45
  handleAuthSocket({ email, scanId, onError, onSuccess, onClose, onOpen }) {
51
- if (!(0, utils_1.checkParameters)(email, scanId)) {
52
- throw new Error(constants_1.REQUIRED_MESSAGE);
46
+ if (!checkParameters(email, scanId)) {
47
+ throw new Error(REQUIRED_MESSAGE);
53
48
  }
54
49
  if (this.#socketRef)
55
50
  this.#socketRef.close();
56
- this.#socketRef = new WebSocket(`${constants_1.APP_AUTH_WEBSOCKET_URL}${constants_1.API_ENDPOINTS.AUTH}`);
51
+ this.#socketRef = new WebSocket(`${APP_AUTH_WEBSOCKET_URL}${API_ENDPOINTS.AUTH}`);
57
52
  const detailObj = { email, scanId };
58
53
  this.#socketRef.onopen = () => {
59
54
  this.#socketRef?.send(JSON.stringify(detailObj));
@@ -71,4 +66,3 @@ class Auth {
71
66
  };
72
67
  }
73
68
  }
74
- exports.default = Auth;
package/dist/constants.js CHANGED
@@ -1,19 +1,16 @@
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 = {
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 = {
11
8
  UPLOAD_START: "/upload/start",
12
9
  UPLOAD_COMPLETE: "/upload/complete",
13
10
  UPLOAD_SIGN_PART: "/upload/signpart",
14
11
  UPLOAD_ABORT: "/upload/abort",
15
12
  };
16
- exports.API_ENDPOINTS = {
13
+ export const API_ENDPOINTS = {
17
14
  GET_USER_DETAIL: "/api/user",
18
15
  REGISTER_USER: "/auth/register",
19
16
  VERIFY_USER: "/auth/verify",
@@ -28,7 +25,7 @@ exports.API_ENDPOINTS = {
28
25
  TRY_ON: "/tryon",
29
26
  AUTH: "/auth",
30
27
  };
31
- exports.requiredMetaData = [
28
+ export const requiredMetaData = [
32
29
  "gender",
33
30
  "scan_id",
34
31
  "email",
@@ -39,5 +36,5 @@ exports.requiredMetaData = [
39
36
  "callback_url",
40
37
  "clothes_fit",
41
38
  ];
42
- exports.REQUIRED_MESSAGE = "Please verify required parameters";
43
- exports.REQUIRED_MESSAGE_FOR_META_DATA = "Please verify required parameters in meta data";
39
+ export const REQUIRED_MESSAGE = "Please verify required parameters";
40
+ export const REQUIRED_MESSAGE_FOR_META_DATA = "Please verify required parameters in meta data";
package/dist/custom.js CHANGED
@@ -1,30 +1,25 @@
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_1 = require("./constants");
8
- const utils_1 = require("./utils");
1
+ import axios from "axios";
2
+ import { API_ENDPOINTS, APP_AUTH_BASE_URL, REQUIRED_MESSAGE } from "./constants.js";
3
+ import { checkParameters } from "./utils.js";
9
4
  class Custom {
10
5
  #accessKey;
11
6
  constructor(accessKey) {
12
7
  this.#accessKey = accessKey;
13
8
  }
14
9
  getCustomCustomerConfig = (store_url) => {
15
- if ((0, utils_1.checkParameters)(store_url) === false) {
16
- throw new Error(constants_1.REQUIRED_MESSAGE);
10
+ if (checkParameters(store_url) === false) {
11
+ throw new Error(REQUIRED_MESSAGE);
17
12
  }
18
- return axios_1.default.get(`${constants_1.APP_AUTH_BASE_URL}${constants_1.API_ENDPOINTS.CUSTOM_CUSTOMER}`, {
13
+ return axios.get(`${APP_AUTH_BASE_URL}${API_ENDPOINTS.CUSTOM_CUSTOMER}`, {
19
14
  params: { store_url },
20
15
  headers: { "X-Api-Key": this.#accessKey },
21
16
  });
22
17
  };
23
18
  getModelUrl = (id) => {
24
- if ((0, utils_1.checkParameters)(id) === false) {
25
- throw new Error(constants_1.REQUIRED_MESSAGE);
19
+ if (checkParameters(id) === false) {
20
+ throw new Error(REQUIRED_MESSAGE);
26
21
  }
27
- return axios_1.default.get(`${constants_1.APP_AUTH_BASE_URL}${constants_1.API_ENDPOINTS.MODEL}/${id}`, { headers: { "X-Api-Key": this.#accessKey } });
22
+ return axios.get(`${APP_AUTH_BASE_URL}${API_ENDPOINTS.MODEL}/${id}`, { headers: { "X-Api-Key": this.#accessKey } });
28
23
  };
29
24
  }
30
- exports.default = Custom;
25
+ export default Custom;
package/dist/esm/auth.js CHANGED
@@ -11,8 +11,8 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
11
11
  };
12
12
  var _Auth_socketRef, _Auth_accessKey;
13
13
  import axios from "axios";
14
- import { API_ENDPOINTS, APP_AUTH_BASE_URL, APP_AUTH_WEBSOCKET_URL, APP_BASE_URL, REQUIRED_MESSAGE } from "./constants";
15
- import { checkParameters } from "./utils";
14
+ import { API_ENDPOINTS, APP_AUTH_BASE_URL, APP_AUTH_WEBSOCKET_URL, APP_BASE_URL, REQUIRED_MESSAGE } from "./constants.js";
15
+ import { checkParameters } from "./utils.js";
16
16
  class Auth {
17
17
  constructor(accessKey) {
18
18
  _Auth_socketRef.set(this, void 0);
@@ -11,8 +11,8 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
11
11
  };
12
12
  var _Custom_accessKey;
13
13
  import axios from "axios";
14
- import { API_ENDPOINTS, APP_AUTH_BASE_URL, REQUIRED_MESSAGE } from "./constants";
15
- import { checkParameters } from "./utils";
14
+ import { API_ENDPOINTS, APP_AUTH_BASE_URL, REQUIRED_MESSAGE } from "./constants.js";
15
+ import { checkParameters } from "./utils.js";
16
16
  class Custom {
17
17
  constructor(accessKey) {
18
18
  _Custom_accessKey.set(this, void 0);
@@ -18,18 +18,16 @@ 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 _FileUpload_instances, _FileUpload_uppyIns, _FileUpload_accessKey, _FileUpload_Uppy, _FileUpload_AwsS3Multipart, _FileUpload_initializeModules;
22
- import { REQUIRED_MESSAGE, REQUIRED_MESSAGE_FOR_META_DATA, UPPY_FILE_UPLOAD_ENDPOINT } from "./constants";
23
- import { checkMetaDataValue, checkParameters, fetchData } from "./utils";
21
+ var _FileUpload_uppyIns, _FileUpload_accessKey;
22
+ import { REQUIRED_MESSAGE, REQUIRED_MESSAGE_FOR_META_DATA, UPPY_FILE_UPLOAD_ENDPOINT } from "./constants.js";
23
+ import { checkMetaDataValue, checkParameters, fetchData } from "./utils.js";
24
+ import Uppy from "@uppy/core";
25
+ import AwsS3Multipart from "@uppy/aws-s3-multipart";
24
26
  class FileUpload {
25
27
  constructor(accessKey) {
26
- _FileUpload_instances.add(this);
27
28
  _FileUpload_uppyIns.set(this, void 0);
28
29
  _FileUpload_accessKey.set(this, void 0);
29
- _FileUpload_Uppy.set(this, void 0);
30
- _FileUpload_AwsS3Multipart.set(this, void 0);
31
30
  __classPrivateFieldSet(this, _FileUpload_accessKey, accessKey, "f");
32
- __classPrivateFieldGet(this, _FileUpload_instances, "m", _FileUpload_initializeModules).call(this);
33
31
  }
34
32
  uploadFile(_a) {
35
33
  return __awaiter(this, arguments, void 0, function* ({ file, arrayMetaData, scanId }) {
@@ -43,8 +41,8 @@ class FileUpload {
43
41
  if (__classPrivateFieldGet(this, _FileUpload_uppyIns, "f")) {
44
42
  __classPrivateFieldGet(this, _FileUpload_uppyIns, "f").close();
45
43
  }
46
- __classPrivateFieldSet(this, _FileUpload_uppyIns, new (__classPrivateFieldGet(this, _FileUpload_Uppy, "f"))({ autoProceed: true }), "f");
47
- __classPrivateFieldGet(this, _FileUpload_uppyIns, "f").use(__classPrivateFieldGet(this, _FileUpload_AwsS3Multipart, "f"), {
44
+ __classPrivateFieldSet(this, _FileUpload_uppyIns, new Uppy({ autoProceed: true }), "f");
45
+ __classPrivateFieldGet(this, _FileUpload_uppyIns, "f").use(AwsS3Multipart, {
48
46
  limit: 10,
49
47
  retryDelays: [0, 1000, 3000, 5000],
50
48
  getChunkSize: () => 5 * 1024 * 1024,
@@ -110,17 +108,5 @@ class FileUpload {
110
108
  });
111
109
  }
112
110
  }
113
- _FileUpload_uppyIns = new WeakMap(), _FileUpload_accessKey = new WeakMap(), _FileUpload_Uppy = new WeakMap(), _FileUpload_AwsS3Multipart = new WeakMap(), _FileUpload_instances = new WeakSet(), _FileUpload_initializeModules = function _FileUpload_initializeModules() {
114
- return __awaiter(this, void 0, void 0, function* () {
115
- if (!__classPrivateFieldGet(this, _FileUpload_Uppy, "f") || !__classPrivateFieldGet(this, _FileUpload_AwsS3Multipart, "f")) {
116
- // const fetch = (...args) => import('node-fetch').then(({default: fetch}) => fetch(...args));
117
- const Uppy = () => import("@uppy/core").then(({ default: Uppy }) => Uppy);
118
- const AwsS3Multipart = () => import("@uppy/aws-s3-multipart").then(({ default: AwsS3Multipart }) => AwsS3Multipart);
119
- // const { default: Uppy } = await import("@uppy/core");
120
- // const { default: AwsS3Multipart } = await import("@uppy/aws-s3-multipart");
121
- __classPrivateFieldSet(this, _FileUpload_Uppy, Uppy, "f");
122
- __classPrivateFieldSet(this, _FileUpload_AwsS3Multipart, AwsS3Multipart, "f");
123
- }
124
- });
125
- };
111
+ _FileUpload_uppyIns = new WeakMap(), _FileUpload_accessKey = new WeakMap();
126
112
  export default FileUpload;
@@ -1,9 +1,9 @@
1
- import Auth from "./auth";
2
- import Custom from "./custom";
3
- import FileUpload from "./fileUpload";
4
- import Measurement from "./measurement";
5
- import PoseDetection from "./poseDetection";
6
- import TryOn from "./tryOn";
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";
7
7
  declare class Swan {
8
8
  #private;
9
9
  auth: Auth;
package/dist/esm/index.js CHANGED
@@ -10,12 +10,12 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
10
10
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
11
  };
12
12
  var _Swan_accessKey;
13
- import Auth from "./auth";
14
- import Custom from "./custom";
15
- import FileUpload from "./fileUpload";
16
- import Measurement from "./measurement";
17
- import PoseDetection from "./poseDetection";
18
- import TryOn from "./tryOn";
13
+ import Auth from "./auth.js";
14
+ import Custom from "./custom.js";
15
+ import FileUpload from "./fileUpload.js";
16
+ import Measurement from "./measurement.js";
17
+ import PoseDetection from "./poseDetection.js";
18
+ import TryOn from "./tryOn.js";
19
19
  class Swan {
20
20
  constructor(accessKey) {
21
21
  _Swan_accessKey.set(this, void 0);
@@ -20,8 +20,8 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
20
20
  };
21
21
  var _Measurement_instances, _Measurement_tryOnSocketRef, _Measurement_measurementSocketRef, _Measurement_timerPollingRef, _Measurement_timerWaitingRef, _Measurement_count, _Measurement_accessKey, _Measurement_getMeasurementsCheck, _Measurement_handlePolling, _Measurement_disconnectSocket, _Measurement_handleTimeOut;
22
22
  import axios from "axios";
23
- import { API_ENDPOINTS, APP_AUTH_BASE_URL, APP_RECOMMENDATION_WEBSOCKET_URL, APP_TRY_ON_WEBSOCKET_URL, REQUIRED_MESSAGE } from "./constants";
24
- import { checkParameters } from "./utils";
23
+ import { API_ENDPOINTS, APP_AUTH_BASE_URL, APP_RECOMMENDATION_WEBSOCKET_URL, APP_TRY_ON_WEBSOCKET_URL, REQUIRED_MESSAGE } from "./constants.js";
24
+ import { checkParameters } from "./utils.js";
25
25
  class Measurement {
26
26
  constructor(accessKey) {
27
27
  _Measurement_instances.add(this);
@@ -11,7 +11,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
11
11
  };
12
12
  var _PoseDetection_socketRef, _PoseDetection_accessKey;
13
13
  import { io } from "socket.io-client";
14
- import { APP_POSE_DETECTION_WEBSOCKET_URL } from "./constants";
14
+ import { APP_POSE_DETECTION_WEBSOCKET_URL } from "./constants.js";
15
15
  class PoseDetection {
16
16
  constructor(accessKey) {
17
17
  _PoseDetection_socketRef.set(this, null);
package/dist/esm/tryOn.js CHANGED
@@ -20,8 +20,8 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
20
20
  };
21
21
  var _TryOn_instances, _TryOn_tryOnSocketRef, _TryOn_timerWaitingRef, _TryOn_accessKey, _TryOn_getSignedUrl, _TryOn_s3Upload, _TryOn_disconnectSocket, _TryOn_handleTimeOut, _TryOn_handleGetTryOnResult;
22
22
  import axios from "axios";
23
- import { API_ENDPOINTS, APP_AUTH_BASE_URL, APP_AUTH_WEBSOCKET_URL, REQUIRED_MESSAGE } from "./constants";
24
- import { checkParameters } from "./utils";
23
+ import { API_ENDPOINTS, APP_AUTH_BASE_URL, APP_AUTH_WEBSOCKET_URL, REQUIRED_MESSAGE } from "./constants.js";
24
+ import { checkParameters } from "./utils.js";
25
25
  class TryOn {
26
26
  constructor(accessKey) {
27
27
  _TryOn_instances.add(this);
@@ -1,4 +1,4 @@
1
- import { ObjMetaData } from "./constants";
1
+ import { ObjMetaData } from "./constants.js";
2
2
  export interface FetchDataOptions {
3
3
  path: string;
4
4
  body?: any;
package/dist/esm/utils.js CHANGED
@@ -8,7 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import axios from "axios";
11
- import { APP_AUTH_BASE_URL, requiredMetaData } from "./constants";
11
+ import { APP_AUTH_BASE_URL, requiredMetaData } from "./constants.js";
12
12
  export function fetchData(options) {
13
13
  return __awaiter(this, void 0, void 0, function* () {
14
14
  const { path, body, queryParams, baseUrl = APP_AUTH_BASE_URL, apiKey = "", headers = { "X-Api-Key": apiKey, "Content-Type": "application/json" }, } = options;
@@ -1,70 +1,33 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- const constants_1 = require("./constants");
27
- const utils_1 = require("./utils");
28
- class FileUpload {
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 {
29
6
  #uppyIns;
30
7
  #accessKey;
31
- #Uppy;
32
- #AwsS3Multipart;
33
8
  constructor(accessKey) {
34
9
  this.#accessKey = accessKey;
35
- this.#initializeModules();
36
- }
37
- async #initializeModules() {
38
- if (!this.#Uppy || !this.#AwsS3Multipart) {
39
- // const fetch = (...args) => import('node-fetch').then(({default: fetch}) => fetch(...args));
40
- const Uppy = () => Promise.resolve().then(() => __importStar(require("@uppy/core"))).then(({ default: Uppy }) => Uppy);
41
- const AwsS3Multipart = () => Promise.resolve().then(() => __importStar(require("@uppy/aws-s3-multipart"))).then(({ default: AwsS3Multipart }) => AwsS3Multipart);
42
- // const { default: Uppy } = await import("@uppy/core");
43
- // const { default: AwsS3Multipart } = await import("@uppy/aws-s3-multipart");
44
- this.#Uppy = Uppy;
45
- this.#AwsS3Multipart = AwsS3Multipart;
46
- }
47
10
  }
48
11
  async uploadFile({ file, arrayMetaData, scanId }) {
49
- if (!(0, utils_1.checkParameters)(file, arrayMetaData, scanId)) {
50
- throw new Error(constants_1.REQUIRED_MESSAGE);
12
+ if (!checkParameters(file, arrayMetaData, scanId)) {
13
+ throw new Error(REQUIRED_MESSAGE);
51
14
  }
52
- if (!(0, utils_1.checkMetaDataValue)(arrayMetaData)) {
53
- throw new Error(constants_1.REQUIRED_MESSAGE_FOR_META_DATA);
15
+ if (!checkMetaDataValue(arrayMetaData)) {
16
+ throw new Error(REQUIRED_MESSAGE_FOR_META_DATA);
54
17
  }
55
18
  return new Promise((resolve, reject) => {
56
19
  if (this.#uppyIns) {
57
20
  this.#uppyIns.close();
58
21
  }
59
- this.#uppyIns = new this.#Uppy({ autoProceed: true });
60
- this.#uppyIns.use(this.#AwsS3Multipart, {
22
+ this.#uppyIns = new Uppy({ autoProceed: true });
23
+ this.#uppyIns.use(AwsS3Multipart, {
61
24
  limit: 10,
62
25
  retryDelays: [0, 1000, 3000, 5000],
63
26
  getChunkSize: () => 5 * 1024 * 1024,
64
27
  createMultipartUpload: (file) => {
65
28
  const objectKey = `${scanId}.${file.extension}`;
66
- return (0, utils_1.fetchData)({
67
- path: constants_1.UPPY_FILE_UPLOAD_ENDPOINT.UPLOAD_START,
29
+ return fetchData({
30
+ path: UPPY_FILE_UPLOAD_ENDPOINT.UPLOAD_START,
68
31
  apiKey: this.#accessKey,
69
32
  body: {
70
33
  objectKey,
@@ -73,8 +36,8 @@ class FileUpload {
73
36
  },
74
37
  });
75
38
  },
76
- completeMultipartUpload: (file, { uploadId, key, parts }) => (0, utils_1.fetchData)({
77
- path: constants_1.UPPY_FILE_UPLOAD_ENDPOINT.UPLOAD_COMPLETE,
39
+ completeMultipartUpload: (file, { uploadId, key, parts }) => fetchData({
40
+ path: UPPY_FILE_UPLOAD_ENDPOINT.UPLOAD_COMPLETE,
78
41
  apiKey: this.#accessKey,
79
42
  body: {
80
43
  uploadId,
@@ -83,8 +46,8 @@ class FileUpload {
83
46
  originalFileName: file.name,
84
47
  },
85
48
  }),
86
- signPart: (file, partData) => (0, utils_1.fetchData)({
87
- path: constants_1.UPPY_FILE_UPLOAD_ENDPOINT.UPLOAD_SIGN_PART,
49
+ signPart: (file, partData) => fetchData({
50
+ path: UPPY_FILE_UPLOAD_ENDPOINT.UPLOAD_SIGN_PART,
88
51
  apiKey: this.#accessKey,
89
52
  body: {
90
53
  objectKey: partData.key,
@@ -92,8 +55,8 @@ class FileUpload {
92
55
  partNumber: partData.partNumber,
93
56
  },
94
57
  }),
95
- abortMultipartUpload: (file, { uploadId, key }) => (0, utils_1.fetchData)({
96
- path: constants_1.UPPY_FILE_UPLOAD_ENDPOINT.UPLOAD_ABORT,
58
+ abortMultipartUpload: (file, { uploadId, key }) => fetchData({
59
+ path: UPPY_FILE_UPLOAD_ENDPOINT.UPLOAD_ABORT,
97
60
  apiKey: this.#accessKey,
98
61
  body: {
99
62
  uploadId,
@@ -122,4 +85,3 @@ class FileUpload {
122
85
  });
123
86
  }
124
87
  }
125
- exports.default = FileUpload;
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- import Auth from "./auth";
2
- import Custom from "./custom";
3
- import FileUpload from "./fileUpload";
4
- import Measurement from "./measurement";
5
- import PoseDetection from "./poseDetection";
6
- import TryOn from "./tryOn";
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";
7
7
  declare class Swan {
8
8
  #private;
9
9
  auth: Auth;
package/dist/index.js CHANGED
@@ -1,14 +1,9 @@
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_1 = __importDefault(require("./auth"));
7
- const custom_1 = __importDefault(require("./custom"));
8
- const fileUpload_1 = __importDefault(require("./fileUpload"));
9
- const measurement_1 = __importDefault(require("./measurement"));
10
- const poseDetection_1 = __importDefault(require("./poseDetection"));
11
- const tryOn_1 = __importDefault(require("./tryOn"));
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";
12
7
  class Swan {
13
8
  #accessKey;
14
9
  auth;
@@ -19,12 +14,12 @@ class Swan {
19
14
  tryOn;
20
15
  constructor(accessKey) {
21
16
  this.#accessKey = accessKey;
22
- this.auth = new auth_1.default(this.#accessKey);
23
- this.custom = new custom_1.default(this.#accessKey);
24
- this.fileUpload = new fileUpload_1.default(this.#accessKey);
25
- this.measurement = new measurement_1.default(this.#accessKey);
26
- this.poseDetection = new poseDetection_1.default(this.#accessKey);
27
- this.tryOn = new tryOn_1.default(this.#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);
28
23
  }
29
24
  }
30
- exports.default = Swan;
25
+ export default Swan;
@@ -1,11 +1,6 @@
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_1 = require("./constants");
8
- const utils_1 = require("./utils");
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";
9
4
  class Measurement {
10
5
  #tryOnSocketRef = null;
11
6
  #measurementSocketRef = null;
@@ -17,28 +12,28 @@ class Measurement {
17
12
  this.#accessKey = accessKey;
18
13
  }
19
14
  getMeasurementResult(scanId) {
20
- if (!(0, utils_1.checkParameters)(scanId)) {
21
- throw new Error(constants_1.REQUIRED_MESSAGE);
15
+ if (!checkParameters(scanId)) {
16
+ throw new Error(REQUIRED_MESSAGE);
22
17
  }
23
- const url = `${constants_1.APP_AUTH_BASE_URL}/measurements?scanId=${scanId}`;
24
- return axios_1.default.get(url, {
18
+ const url = `${APP_AUTH_BASE_URL}/measurements?scanId=${scanId}`;
19
+ return axios.get(url, {
25
20
  headers: { "X-Api-Key": this.#accessKey },
26
21
  });
27
22
  }
28
23
  getTryOnMeasurements({ scanId, shopDomain, productName }) {
29
- if (!(0, utils_1.checkParameters)(scanId, shopDomain, productName)) {
30
- throw new Error(constants_1.REQUIRED_MESSAGE);
24
+ if (!checkParameters(scanId, shopDomain, productName)) {
25
+ throw new Error(REQUIRED_MESSAGE);
31
26
  }
32
- const tryOnUrl = `${constants_1.APP_AUTH_BASE_URL}${constants_1.API_ENDPOINTS.TRY_ON_SCAN}/${scanId}/shop/${shopDomain}/product/${productName}`;
33
- return axios_1.default.get(tryOnUrl, { headers: { "X-Api-Key": this.#accessKey } });
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 } });
34
29
  }
35
30
  handleTryOnSocket(options) {
36
31
  const { shopDomain, scanId, productName, onError, onSuccess, onClose, onOpen } = options;
37
- if (!(0, utils_1.checkParameters)(shopDomain, scanId, productName)) {
38
- throw new Error(constants_1.REQUIRED_MESSAGE);
32
+ if (!checkParameters(shopDomain, scanId, productName)) {
33
+ throw new Error(REQUIRED_MESSAGE);
39
34
  }
40
35
  this.#tryOnSocketRef?.close();
41
- const url = `${constants_1.APP_TRY_ON_WEBSOCKET_URL}/develop?store_url=${shopDomain}&product_name=${productName}&scan_id=${scanId}`;
36
+ const url = `${APP_TRY_ON_WEBSOCKET_URL}/develop?store_url=${shopDomain}&product_name=${productName}&scan_id=${scanId}`;
42
37
  this.#tryOnSocketRef = new WebSocket(url);
43
38
  this.#tryOnSocketRef.onopen = () => {
44
39
  onOpen?.();
@@ -115,12 +110,12 @@ class Measurement {
115
110
  }
116
111
  handleMeasurementSocket(options) {
117
112
  const { scanId, onError, onSuccess, onClose, onOpen } = options;
118
- if (!(0, utils_1.checkParameters)(scanId)) {
119
- throw new Error(constants_1.REQUIRED_MESSAGE);
113
+ if (!checkParameters(scanId)) {
114
+ throw new Error(REQUIRED_MESSAGE);
120
115
  }
121
116
  setTimeout(() => {
122
117
  this.#disconnectSocket();
123
- const url = `${constants_1.APP_RECOMMENDATION_WEBSOCKET_URL}?scanId=${scanId}`;
118
+ const url = `${APP_RECOMMENDATION_WEBSOCKET_URL}?scanId=${scanId}`;
124
119
  this.#measurementSocketRef = new WebSocket(url);
125
120
  this.#measurementSocketRef.onopen = () => {
126
121
  onOpen?.();
@@ -147,4 +142,4 @@ class Measurement {
147
142
  }, 5000);
148
143
  }
149
144
  }
150
- exports.default = Measurement;
145
+ export default Measurement;
@@ -1,7 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const socket_io_client_1 = require("socket.io-client");
4
- const constants_1 = require("./constants");
1
+ import { io } from "socket.io-client";
2
+ import { APP_POSE_DETECTION_WEBSOCKET_URL } from "./constants.js";
5
3
  class PoseDetection {
6
4
  #socketRef = null;
7
5
  #accessKey;
@@ -10,7 +8,7 @@ class PoseDetection {
10
8
  }
11
9
  connect() {
12
10
  return new Promise((resolve, reject) => {
13
- this.#socketRef = (0, socket_io_client_1.io)(constants_1.APP_POSE_DETECTION_WEBSOCKET_URL, {
11
+ this.#socketRef = io(APP_POSE_DETECTION_WEBSOCKET_URL, {
14
12
  auth: {
15
13
  token: this.#accessKey,
16
14
  },
@@ -53,4 +51,4 @@ class PoseDetection {
53
51
  return !!this.#socketRef?.connected;
54
52
  }
55
53
  }
56
- exports.default = PoseDetection;
54
+ export default PoseDetection;
package/dist/tryOn.js CHANGED
@@ -1,11 +1,6 @@
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_1 = require("./constants");
8
- const utils_1 = require("./utils");
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";
9
4
  class TryOn {
10
5
  #tryOnSocketRef = null;
11
6
  #timerWaitingRef = null;
@@ -33,7 +28,7 @@ class TryOn {
33
28
  }
34
29
  }
35
30
  #getSignedUrl(payload) {
36
- return axios_1.default.post(`${constants_1.APP_AUTH_BASE_URL}${constants_1.API_ENDPOINTS.TRY_ON_IMAGE_UPLOAD}`, payload, {
31
+ return axios.post(`${APP_AUTH_BASE_URL}${API_ENDPOINTS.TRY_ON_IMAGE_UPLOAD}`, payload, {
37
32
  headers: {
38
33
  "Content-Type": "application/json",
39
34
  "X-Api-Key": this.#accessKey,
@@ -41,25 +36,25 @@ class TryOn {
41
36
  });
42
37
  }
43
38
  #s3Upload(url, file) {
44
- return axios_1.default.put(url, file, {
39
+ return axios.put(url, file, {
45
40
  headers: {
46
41
  "Content-Type": file.type,
47
42
  },
48
43
  });
49
44
  }
50
45
  getUploadedFiles(userId) {
51
- if ((0, utils_1.checkParameters)(userId) === false) {
52
- throw new Error(constants_1.REQUIRED_MESSAGE);
46
+ if (checkParameters(userId) === false) {
47
+ throw new Error(REQUIRED_MESSAGE);
53
48
  }
54
- return axios_1.default.post(`${constants_1.APP_AUTH_BASE_URL}${constants_1.API_ENDPOINTS.TRY_ON_IMAGE_DOWNLOAD}?userId=${userId}`, null, {
49
+ return axios.post(`${APP_AUTH_BASE_URL}${API_ENDPOINTS.TRY_ON_IMAGE_DOWNLOAD}?userId=${userId}`, null, {
55
50
  headers: { "X-Api-Key": this.#accessKey },
56
51
  });
57
52
  }
58
53
  deleteImage({ userId, fileName }) {
59
- if ((0, utils_1.checkParameters)(userId, fileName) === false) {
60
- throw new Error(constants_1.REQUIRED_MESSAGE);
54
+ if (checkParameters(userId, fileName) === false) {
55
+ throw new Error(REQUIRED_MESSAGE);
61
56
  }
62
- return axios_1.default.delete(`${constants_1.APP_AUTH_BASE_URL}${constants_1.API_ENDPOINTS.TRY_ON_IMAGE_URLS}?userId=${userId}&file=${fileName}`, {
57
+ return axios.delete(`${APP_AUTH_BASE_URL}${API_ENDPOINTS.TRY_ON_IMAGE_URLS}?userId=${userId}&file=${fileName}`, {
63
58
  headers: { "X-Api-Key": this.#accessKey },
64
59
  });
65
60
  }
@@ -76,11 +71,11 @@ class TryOn {
76
71
  }, 120000);
77
72
  };
78
73
  handleTryOnWebSocket = ({ shopDomain, userId, productName, onError, onSuccess, onClose, onOpen }) => {
79
- if ((0, utils_1.checkParameters)(shopDomain, userId, productName) === false) {
80
- throw new Error(constants_1.REQUIRED_MESSAGE);
74
+ if (checkParameters(shopDomain, userId, productName) === false) {
75
+ throw new Error(REQUIRED_MESSAGE);
81
76
  }
82
77
  this.#disconnectSocket();
83
- const url = `${constants_1.APP_AUTH_WEBSOCKET_URL}${constants_1.API_ENDPOINTS.TRY_ON}/?store_url=${shopDomain}&product_name=${productName}&scan_id=${userId}`;
78
+ const url = `${APP_AUTH_WEBSOCKET_URL}${API_ENDPOINTS.TRY_ON}/?store_url=${shopDomain}&product_name=${productName}&scan_id=${userId}`;
84
79
  this.#tryOnSocketRef = new WebSocket(url);
85
80
  this.#tryOnSocketRef.onopen = async () => {
86
81
  onOpen?.();
@@ -115,12 +110,12 @@ class TryOn {
115
110
  };
116
111
  };
117
112
  handleForLatestImage = async ({ userId, shopDomain, productName, onError }) => {
118
- if ((0, utils_1.checkParameters)(shopDomain, userId, productName) === false) {
119
- throw new Error(constants_1.REQUIRED_MESSAGE);
113
+ if (checkParameters(shopDomain, userId, productName) === false) {
114
+ throw new Error(REQUIRED_MESSAGE);
120
115
  }
121
116
  try {
122
- const url = `${constants_1.APP_AUTH_BASE_URL}${constants_1.API_ENDPOINTS.TRY_ON}/?scan_id=${userId}&store_url=${shopDomain}&product_name=${productName}`;
123
- const res = await axios_1.default.post(url, null, {
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, {
124
119
  headers: { "X-Api-Key": this.#accessKey },
125
120
  });
126
121
  if (res?.data?.tryOnProcessStatus === "failed") {
@@ -147,13 +142,13 @@ class TryOn {
147
142
  }
148
143
  };
149
144
  getTryOnResult = ({ userId, shopDomain, productName }) => {
150
- if ((0, utils_1.checkParameters)(shopDomain, userId, productName) === false) {
151
- throw new Error(constants_1.REQUIRED_MESSAGE);
145
+ if (checkParameters(shopDomain, userId, productName) === false) {
146
+ throw new Error(REQUIRED_MESSAGE);
152
147
  }
153
- const url = `${constants_1.APP_AUTH_BASE_URL}${constants_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, {
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, {
155
150
  headers: { "X-Api-Key": this.#accessKey },
156
151
  });
157
152
  };
158
153
  }
159
- exports.default = TryOn;
154
+ export default TryOn;
package/dist/utils.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ObjMetaData } from "./constants";
1
+ import { ObjMetaData } from "./constants.js";
2
2
  export interface FetchDataOptions {
3
3
  path: string;
4
4
  body?: any;
package/dist/utils.js CHANGED
@@ -1,16 +1,10 @@
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_1 = require("./constants");
9
- async function fetchData(options) {
10
- const { path, body, queryParams, baseUrl = constants_1.APP_AUTH_BASE_URL, apiKey = "", headers = { "X-Api-Key": apiKey, "Content-Type": "application/json" }, } = options;
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;
11
5
  const apiUrl = `${baseUrl}${path}${queryParams ? `?${new URLSearchParams(queryParams)}` : ""}`;
12
6
  try {
13
- const res = await axios_1.default.post(apiUrl, body, { headers });
7
+ const res = await axios.post(apiUrl, body, { headers });
14
8
  if (res.status >= 200 && res.status < 300) {
15
9
  return res.data;
16
10
  }
@@ -22,8 +16,7 @@ async function fetchData(options) {
22
16
  return {};
23
17
  }
24
18
  }
25
- exports.fetchData = fetchData;
26
- function checkParameters(...args) {
19
+ export function checkParameters(...args) {
27
20
  for (const element of args) {
28
21
  if (!element) {
29
22
  return false;
@@ -31,9 +24,8 @@ function checkParameters(...args) {
31
24
  }
32
25
  return true;
33
26
  }
34
- exports.checkParameters = checkParameters;
35
- function checkMetaDataValue(arr) {
36
- for (const key of constants_1.requiredMetaData) {
27
+ export function checkMetaDataValue(arr) {
28
+ for (const key of requiredMetaData) {
37
29
  let hasRequiredKey = false;
38
30
  for (const obj of arr) {
39
31
  if (obj.hasOwnProperty(key) && obj[key] !== undefined && obj[key] !== null && obj[key] !== "" && typeof obj[key] !== "number") {
@@ -56,4 +48,3 @@ function checkMetaDataValue(arr) {
56
48
  }
57
49
  return true;
58
50
  }
59
- exports.checkMetaDataValue = checkMetaDataValue;
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "@swan-admin/swan-ai-measurements",
3
- "version": "1.0.67",
3
+ "version": "1.0.69",
4
4
  "description": "provides ai measurement suggestion",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/esm/index.js",
7
7
  "types": "dist/index.d.ts",
8
+ "type": "module",
8
9
  "exports": {
9
10
  ".": {
10
11
  "require": "./dist/index.js",
@@ -14,8 +15,8 @@
14
15
  "dependencies": {
15
16
  "@types/axios": "^0.14.0",
16
17
  "@types/node": "^20.12.12",
17
- "@uppy/aws-s3-multipart": "^3.10.2",
18
- "@uppy/core": "^3.9.3",
18
+ "@uppy/aws-s3-multipart": "^3.11.1",
19
+ "@uppy/core": "^3.11.3",
19
20
  "axios": "^1.6.7",
20
21
  "socket.io": "^4.7.5",
21
22
  "socket.io-client": "^4.7.5",
package/src/auth.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import axios, { AxiosResponse } from "axios";
2
- import { API_ENDPOINTS, APP_AUTH_BASE_URL, APP_AUTH_WEBSOCKET_URL, APP_BASE_URL, REQUIRED_MESSAGE } from "./constants";
3
- import { checkParameters } from "./utils";
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
4
 
5
5
  interface RegisterUserParams {
6
6
  email: string;
package/src/custom.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import axios, { AxiosResponse } from "axios";
2
- import { API_ENDPOINTS, APP_AUTH_BASE_URL, REQUIRED_MESSAGE } from "./constants";
3
- import { checkParameters } from "./utils";
2
+ import { API_ENDPOINTS, APP_AUTH_BASE_URL, REQUIRED_MESSAGE } from "./constants.js";
3
+ import { checkParameters } from "./utils.js";
4
4
 
5
5
  class Custom {
6
6
  #accessKey: string;
package/src/fileUpload.ts CHANGED
@@ -1,6 +1,7 @@
1
- import { REQUIRED_MESSAGE, REQUIRED_MESSAGE_FOR_META_DATA, UPPY_FILE_UPLOAD_ENDPOINT } from "./constants";
2
- import { checkMetaDataValue, checkParameters, fetchData } from "./utils";
3
-
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";
4
5
  interface ObjMetaData {
5
6
  gender: string;
6
7
  scan_id: string;
@@ -22,24 +23,9 @@ interface UploadOptions {
22
23
  export default class FileUpload {
23
24
  #uppyIns: any;
24
25
  #accessKey: string;
25
- #Uppy: any;
26
- #AwsS3Multipart: any;
27
26
 
28
27
  constructor(accessKey: string) {
29
28
  this.#accessKey = accessKey;
30
- this.#initializeModules();
31
- }
32
-
33
- async #initializeModules() {
34
- if (!this.#Uppy || !this.#AwsS3Multipart) {
35
- // const fetch = (...args) => import('node-fetch').then(({default: fetch}) => fetch(...args));
36
- const Uppy = () => import("@uppy/core").then(({ default: Uppy }) => Uppy);
37
- const AwsS3Multipart = () => import("@uppy/aws-s3-multipart").then(({ default: AwsS3Multipart }) => AwsS3Multipart);
38
- // const { default: Uppy } = await import("@uppy/core");
39
- // const { default: AwsS3Multipart } = await import("@uppy/aws-s3-multipart");
40
- this.#Uppy = Uppy;
41
- this.#AwsS3Multipart = AwsS3Multipart;
42
- }
43
29
  }
44
30
 
45
31
  async uploadFile({ file, arrayMetaData, scanId }: UploadOptions) {
@@ -54,8 +40,8 @@ export default class FileUpload {
54
40
  if (this.#uppyIns) {
55
41
  this.#uppyIns.close();
56
42
  }
57
- this.#uppyIns = new this.#Uppy({ autoProceed: true });
58
- this.#uppyIns.use(this.#AwsS3Multipart, {
43
+ this.#uppyIns = new Uppy({ autoProceed: true });
44
+ this.#uppyIns.use(AwsS3Multipart, {
59
45
  limit: 10,
60
46
  retryDelays: [0, 1000, 3000, 5000],
61
47
  getChunkSize: () => 5 * 1024 * 1024,
package/src/index.ts CHANGED
@@ -1,9 +1,9 @@
1
- import Auth from "./auth";
2
- import Custom from "./custom";
3
- import FileUpload from "./fileUpload";
4
- import Measurement from "./measurement";
5
- import PoseDetection from "./poseDetection";
6
- import TryOn from "./tryOn";
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";
7
7
 
8
8
  class Swan {
9
9
  #accessKey: string;
@@ -1,6 +1,6 @@
1
1
  import axios, { AxiosResponse } from "axios";
2
- import { API_ENDPOINTS, APP_AUTH_BASE_URL, APP_RECOMMENDATION_WEBSOCKET_URL, APP_TRY_ON_WEBSOCKET_URL, REQUIRED_MESSAGE } from "./constants";
3
- import { checkParameters } from "./utils";
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";
4
4
 
5
5
  interface TryOnSocketOptions {
6
6
  shopDomain: string;
@@ -1,5 +1,5 @@
1
1
  import { io, Socket } from "socket.io-client";
2
- import { APP_POSE_DETECTION_WEBSOCKET_URL } from "./constants";
2
+ import { APP_POSE_DETECTION_WEBSOCKET_URL } from "./constants.js";
3
3
 
4
4
  interface VideoEmitOptions {
5
5
  image: string;
package/src/tryOn.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import axios, { AxiosResponse } from "axios";
2
- import { API_ENDPOINTS, APP_AUTH_BASE_URL, APP_AUTH_WEBSOCKET_URL, REQUIRED_MESSAGE } from "./constants";
3
- import { checkParameters } from "./utils";
2
+ import { API_ENDPOINTS, APP_AUTH_BASE_URL, APP_AUTH_WEBSOCKET_URL, REQUIRED_MESSAGE } from "./constants.js";
3
+ import { checkParameters } from "./utils.js";
4
4
 
5
5
  interface UploadFileParams {
6
6
  files: File[];
package/src/utils.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import axios, { AxiosResponse } from "axios";
2
- import { APP_AUTH_BASE_URL, ObjMetaData, requiredMetaData } from "./constants";
2
+ import { APP_AUTH_BASE_URL, ObjMetaData, requiredMetaData } from "./constants.js";
3
3
 
4
4
  export interface FetchDataOptions {
5
5
  path: string;
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": "commonjs",
4
+ "module": "ES2022",
5
5
  "moduleResolution": "node",
6
6
  "outDir": "./dist",
7
7
  "declaration": true,