@swan-admin/swan-ai-measurements 1.1.76 → 1.1.78

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.
Files changed (56) hide show
  1. package/dist/auth.d.ts +2 -1
  2. package/dist/auth.js +9 -8
  3. package/dist/constants.d.ts +2 -0
  4. package/dist/constants.js +11 -1
  5. package/dist/custom.d.ts +2 -1
  6. package/dist/custom.js +7 -6
  7. package/dist/enum.d.ts +5 -0
  8. package/dist/enum.js +9 -0
  9. package/dist/esm/auth.d.ts +2 -1
  10. package/dist/esm/auth.js +11 -10
  11. package/dist/esm/constants.d.ts +2 -0
  12. package/dist/esm/constants.js +10 -0
  13. package/dist/esm/custom.d.ts +2 -1
  14. package/dist/esm/custom.js +9 -8
  15. package/dist/esm/enum.d.ts +5 -0
  16. package/dist/esm/enum.js +6 -0
  17. package/dist/esm/fileUpload.d.ts +3 -41
  18. package/dist/esm/fileUpload.js +14 -166
  19. package/dist/esm/index.d.ts +2 -1
  20. package/dist/esm/index.js +12 -11
  21. package/dist/esm/interface.d.ts +53 -0
  22. package/dist/esm/interface.js +1 -0
  23. package/dist/esm/measurement.d.ts +2 -1
  24. package/dist/esm/measurement.js +14 -9
  25. package/dist/esm/poseDetection.d.ts +2 -1
  26. package/dist/esm/poseDetection.js +7 -6
  27. package/dist/esm/tryOn.d.ts +2 -1
  28. package/dist/esm/tryOn.js +14 -13
  29. package/dist/esm/utils.d.ts +4 -3
  30. package/dist/esm/utils.js +6 -8
  31. package/dist/fileUpload.d.ts +3 -41
  32. package/dist/fileUpload.js +12 -164
  33. package/dist/index.d.ts +2 -1
  34. package/dist/index.js +10 -9
  35. package/dist/interface.d.ts +53 -0
  36. package/dist/interface.js +2 -0
  37. package/dist/measurement.d.ts +2 -1
  38. package/dist/measurement.js +12 -7
  39. package/dist/poseDetection.d.ts +2 -1
  40. package/dist/poseDetection.js +5 -4
  41. package/dist/tryOn.d.ts +2 -1
  42. package/dist/tryOn.js +12 -11
  43. package/dist/utils.d.ts +4 -3
  44. package/dist/utils.js +5 -7
  45. package/package.json +1 -1
  46. package/src/auth.ts +9 -8
  47. package/src/constants.ts +12 -0
  48. package/src/custom.ts +45 -44
  49. package/src/enum.ts +5 -0
  50. package/src/fileUpload.ts +14 -200
  51. package/src/index.ts +10 -9
  52. package/src/interface.ts +32 -0
  53. package/src/measurement.ts +12 -7
  54. package/src/poseDetection.ts +5 -4
  55. package/src/tryOn.ts +12 -11
  56. package/src/utils.ts +8 -9
package/dist/auth.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { AxiosResponse } from "axios";
2
+ import { URLType } from "./enum.js";
2
3
  interface RegisterUserParams {
3
4
  email: string;
4
5
  appVerifyUrl: string;
@@ -24,7 +25,7 @@ interface AuthSocketParams {
24
25
  }
25
26
  export default class Auth {
26
27
  #private;
27
- constructor(accessKey: string, stagingUrl?: boolean);
28
+ constructor(accessKey: string, urlType?: URLType);
28
29
  registerUser({ email, appVerifyUrl, gender, height, username }: RegisterUserParams): Promise<AxiosResponse>;
29
30
  verifyToken(token: string): Promise<AxiosResponse>;
30
31
  addUser({ scanId, email, name, height, gender, offsetMarketingConsent }: AddUserParams): Promise<AxiosResponse>;
package/dist/auth.js CHANGED
@@ -6,13 +6,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const axios_1 = __importDefault(require("axios"));
7
7
  const constants_js_1 = require("./constants.js");
8
8
  const utils_js_1 = require("./utils.js");
9
+ const enum_js_1 = require("./enum.js");
9
10
  class Auth {
10
11
  #socketRef;
11
12
  #accessKey;
12
- #stagingUrl;
13
- constructor(accessKey, stagingUrl = false) {
13
+ #urlType;
14
+ constructor(accessKey, urlType = enum_js_1.URLType.PROD) {
14
15
  this.#accessKey = accessKey;
15
- this.#stagingUrl = stagingUrl;
16
+ this.#urlType = urlType;
16
17
  }
17
18
  registerUser({ email, appVerifyUrl, gender, height, username }) {
18
19
  if (!(0, utils_js_1.checkParameters)(email, appVerifyUrl)) {
@@ -22,7 +23,7 @@ class Auth {
22
23
  if (gender && height) {
23
24
  body = { ...body, attributes: { gender, height } };
24
25
  }
25
- 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.REGISTER_USER}`, body, {
26
+ return axios_1.default.post(`${(0, utils_js_1.getUrl)({ urlName: constants_js_1.APP_AUTH_BASE_URL, urlType: this.#urlType })}${constants_js_1.API_ENDPOINTS.REGISTER_USER}`, body, {
26
27
  headers: { "X-Api-Key": this.#accessKey },
27
28
  });
28
29
  }
@@ -30,7 +31,7 @@ class Auth {
30
31
  if (!(0, utils_js_1.checkParameters)(token)) {
31
32
  throw new Error(constants_js_1.REQUIRED_MESSAGE);
32
33
  }
33
- 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.VERIFY_USER}`, null, {
34
+ return axios_1.default.post(`${(0, utils_js_1.getUrl)({ urlName: constants_js_1.APP_AUTH_BASE_URL, urlType: this.#urlType })}${constants_js_1.API_ENDPOINTS.VERIFY_USER}`, null, {
34
35
  params: { token },
35
36
  headers: { "X-Api-Key": this.#accessKey },
36
37
  });
@@ -39,13 +40,13 @@ class Auth {
39
40
  if (!(0, utils_js_1.checkParameters)(scanId, email, height, gender)) {
40
41
  throw new Error(constants_js_1.REQUIRED_MESSAGE);
41
42
  }
42
- 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.ADD_USER}`, { scan_id: scanId, email, name, offsetMarketingConsent, attributes: JSON.stringify({ height, gender }) }, { headers: { "X-Api-Key": this.#accessKey } });
43
+ return axios_1.default.post(`${(0, utils_js_1.getUrl)({ urlName: constants_js_1.APP_AUTH_BASE_URL, urlType: this.#urlType })}${constants_js_1.API_ENDPOINTS.ADD_USER}`, { scan_id: scanId, email, name, offsetMarketingConsent, attributes: JSON.stringify({ height, gender }) }, { headers: { "X-Api-Key": this.#accessKey } });
43
44
  }
44
45
  getUserDetail(email) {
45
46
  if (!(0, utils_js_1.checkParameters)(email)) {
46
47
  throw new Error(constants_js_1.REQUIRED_MESSAGE);
47
48
  }
48
- return axios_1.default.get(`${(0, utils_js_1.getUrl)({ urlName: constants_js_1.APP_AUTH_BASE_URL, stagingUrl: this.#stagingUrl })}${constants_js_1.API_ENDPOINTS.GET_USER_DETAIL}/${email}`, {
49
+ return axios_1.default.get(`${(0, utils_js_1.getUrl)({ urlName: constants_js_1.APP_AUTH_BASE_URL, urlType: this.#urlType })}${constants_js_1.API_ENDPOINTS.GET_USER_DETAIL}/${email}`, {
49
50
  headers: { "X-Api-Key": this.#accessKey },
50
51
  });
51
52
  }
@@ -55,7 +56,7 @@ class Auth {
55
56
  }
56
57
  if (this.#socketRef)
57
58
  this.#socketRef.close();
58
- this.#socketRef = new WebSocket(`${(0, utils_js_1.getUrl)({ urlName: constants_js_1.APP_BASE_WEBSOCKET_URL, stagingUrl: this.#stagingUrl })}${constants_js_1.API_ENDPOINTS.AUTH}`);
59
+ this.#socketRef = new WebSocket(`${(0, utils_js_1.getUrl)({ urlName: constants_js_1.APP_BASE_WEBSOCKET_URL, urlType: this.#urlType })}${constants_js_1.API_ENDPOINTS.AUTH}`);
59
60
  const detailObj = { email, scanId };
60
61
  if (this.#socketRef) {
61
62
  this.#socketRef.onopen = () => {
@@ -1,5 +1,7 @@
1
1
  export declare const STAGING_URL: Record<string, string>;
2
2
  export declare const PROD_URL: Record<string, string>;
3
+ export declare const DEV_URL: Record<string, string>;
4
+ export declare const URLS: Record<string, Record<string, string>>;
3
5
  export declare const FILE_UPLOAD_ENDPOINT: {
4
6
  UPLOAD_START: string;
5
7
  UPLOAD_COMPLETE: string;
package/dist/constants.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CHUNK_SIZE = exports.REQUIRED_ERROR_MESSAGE_INVALID_EMAIL = exports.REQUIRED_MESSAGE_FOR_META_DATA = exports.REQUIRED_MESSAGE = exports.requiredFaceScanMetaData = exports.requiredMetaData = exports.API_ENDPOINTS = exports.APP_POSE_DETECTION_WEBSOCKET_URL = exports.APP_BASE_WEBSOCKET_URL = exports.APP_AUTH_BASE_URL = exports.FILE_UPLOAD_ENDPOINT = exports.PROD_URL = exports.STAGING_URL = void 0;
3
+ exports.CHUNK_SIZE = exports.REQUIRED_ERROR_MESSAGE_INVALID_EMAIL = exports.REQUIRED_MESSAGE_FOR_META_DATA = exports.REQUIRED_MESSAGE = exports.requiredFaceScanMetaData = exports.requiredMetaData = exports.API_ENDPOINTS = exports.APP_POSE_DETECTION_WEBSOCKET_URL = exports.APP_BASE_WEBSOCKET_URL = exports.APP_AUTH_BASE_URL = exports.FILE_UPLOAD_ENDPOINT = exports.URLS = exports.DEV_URL = exports.PROD_URL = exports.STAGING_URL = void 0;
4
4
  exports.STAGING_URL = {
5
5
  APP_AUTH_BASE_URL: "https://staging.api.swanvision.ai",
6
6
  APP_BASE_WEBSOCKET_URL: "wss://staging.wsnotify.api.swanvision.ai",
@@ -11,6 +11,16 @@ exports.PROD_URL = {
11
11
  APP_BASE_WEBSOCKET_URL: "wss://wsnotify.api.swanvision.ai",
12
12
  APP_POSE_DETECTION_WEBSOCKET_URL: "https://posedetect-service.uvcn97hn133d6.eu-west-1.cs.amazonlightsail.com",
13
13
  };
14
+ exports.DEV_URL = {
15
+ APP_AUTH_BASE_URL: "https://develop.api.swanvision.ai",
16
+ APP_BASE_WEBSOCKET_URL: "wss://develop.wsnotify.api.swanvision.ai",
17
+ APP_POSE_DETECTION_WEBSOCKET_URL: "https://posedetect-service-staging.ft2a64raup4pg.us-east-1.cs.amazonlightsail.com",
18
+ };
19
+ exports.URLS = {
20
+ dev: exports.DEV_URL,
21
+ staging: exports.STAGING_URL,
22
+ prod: exports.PROD_URL
23
+ };
14
24
  exports.FILE_UPLOAD_ENDPOINT = {
15
25
  UPLOAD_START: "/upload/start",
16
26
  UPLOAD_COMPLETE: "/upload/complete",
package/dist/custom.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { AxiosResponse } from "axios";
2
+ import { URLType } from "./enum.js";
2
3
  interface CreateCustomer {
3
4
  name: string;
4
5
  storeUrl: string;
@@ -9,7 +10,7 @@ interface CreateCustomer {
9
10
  }
10
11
  declare class Custom {
11
12
  #private;
12
- constructor(accessKey: string, stagingUrl?: boolean);
13
+ constructor(accessKey: string, urlType?: URLType);
13
14
  createCustomer(payload: CreateCustomer): Promise<AxiosResponse<any>>;
14
15
  getCustomCustomerConfig: (store_url: string) => Promise<AxiosResponse<any>>;
15
16
  getModelUrl: (id: string) => Promise<AxiosResponse<any>>;
package/dist/custom.js CHANGED
@@ -6,18 +6,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const axios_1 = __importDefault(require("axios"));
7
7
  const constants_js_1 = require("./constants.js");
8
8
  const utils_js_1 = require("./utils.js");
9
+ const enum_js_1 = require("./enum.js");
9
10
  class Custom {
10
11
  #accessKey;
11
- #stagingUrl;
12
- constructor(accessKey, stagingUrl = false) {
12
+ #urlType;
13
+ constructor(accessKey, urlType = enum_js_1.URLType.PROD) {
13
14
  this.#accessKey = accessKey;
14
- this.#stagingUrl = stagingUrl;
15
+ this.#urlType = urlType;
15
16
  }
16
17
  createCustomer(payload) {
17
18
  if ((0, utils_js_1.checkParameters)(payload.name, payload.storeUrl, payload.email, payload.location) === false) {
18
19
  throw new Error(constants_js_1.REQUIRED_MESSAGE);
19
20
  }
20
- 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.CREATE_CUSTOMER}`, {
21
+ return axios_1.default.post(`${(0, utils_js_1.getUrl)({ urlName: constants_js_1.APP_AUTH_BASE_URL, urlType: this.#urlType })}${constants_js_1.API_ENDPOINTS.CREATE_CUSTOMER}`, {
21
22
  ...payload,
22
23
  headers: { "X-Api-Key": this.#accessKey },
23
24
  });
@@ -28,7 +29,7 @@ class Custom {
28
29
  }
29
30
  return axios_1.default.get(`${(0, utils_js_1.getUrl)({
30
31
  urlName: constants_js_1.APP_AUTH_BASE_URL,
31
- stagingUrl: this.#stagingUrl,
32
+ urlType: this.#urlType,
32
33
  })}${constants_js_1.API_ENDPOINTS.CUSTOM_CUSTOMER}`, {
33
34
  params: { store_url },
34
35
  headers: { "X-Api-Key": this.#accessKey },
@@ -38,7 +39,7 @@ class Custom {
38
39
  if ((0, utils_js_1.checkParameters)(id) === false) {
39
40
  throw new Error(constants_js_1.REQUIRED_MESSAGE);
40
41
  }
41
- return axios_1.default.get(`${(0, utils_js_1.getUrl)({ urlName: constants_js_1.APP_AUTH_BASE_URL, stagingUrl: this.#stagingUrl })}${constants_js_1.API_ENDPOINTS.MODEL}/${id}`, {
42
+ return axios_1.default.get(`${(0, utils_js_1.getUrl)({ urlName: constants_js_1.APP_AUTH_BASE_URL, urlType: this.#urlType })}${constants_js_1.API_ENDPOINTS.MODEL}/${id}`, {
42
43
  headers: { "X-Api-Key": this.#accessKey },
43
44
  });
44
45
  };
package/dist/enum.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ export declare enum URLType {
2
+ DEV = "dev",
3
+ STAGING = "staging",
4
+ PROD = "prod"
5
+ }
package/dist/enum.js ADDED
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.URLType = void 0;
4
+ var URLType;
5
+ (function (URLType) {
6
+ URLType["DEV"] = "dev";
7
+ URLType["STAGING"] = "staging";
8
+ URLType["PROD"] = "prod";
9
+ })(URLType || (exports.URLType = URLType = {}));
@@ -1,4 +1,5 @@
1
1
  import { AxiosResponse } from "axios";
2
+ import { URLType } from "./enum.js";
2
3
  interface RegisterUserParams {
3
4
  email: string;
4
5
  appVerifyUrl: string;
@@ -24,7 +25,7 @@ interface AuthSocketParams {
24
25
  }
25
26
  export default class Auth {
26
27
  #private;
27
- constructor(accessKey: string, stagingUrl?: boolean);
28
+ constructor(accessKey: string, urlType?: URLType);
28
29
  registerUser({ email, appVerifyUrl, gender, height, username }: RegisterUserParams): Promise<AxiosResponse>;
29
30
  verifyToken(token: string): Promise<AxiosResponse>;
30
31
  addUser({ scanId, email, name, height, gender, offsetMarketingConsent }: AddUserParams): Promise<AxiosResponse>;
package/dist/esm/auth.js CHANGED
@@ -9,17 +9,18 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
9
9
  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");
10
10
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
11
  };
12
- var _Auth_socketRef, _Auth_accessKey, _Auth_stagingUrl;
12
+ var _Auth_socketRef, _Auth_accessKey, _Auth_urlType;
13
13
  import axios from "axios";
14
14
  import { API_ENDPOINTS, APP_AUTH_BASE_URL, APP_BASE_WEBSOCKET_URL, REQUIRED_MESSAGE } from "./constants.js";
15
15
  import { checkParameters, getUrl } from "./utils.js";
16
+ import { URLType } from "./enum.js";
16
17
  class Auth {
17
- constructor(accessKey, stagingUrl = false) {
18
+ constructor(accessKey, urlType = URLType.PROD) {
18
19
  _Auth_socketRef.set(this, void 0);
19
20
  _Auth_accessKey.set(this, void 0);
20
- _Auth_stagingUrl.set(this, void 0);
21
+ _Auth_urlType.set(this, void 0);
21
22
  __classPrivateFieldSet(this, _Auth_accessKey, accessKey, "f");
22
- __classPrivateFieldSet(this, _Auth_stagingUrl, stagingUrl, "f");
23
+ __classPrivateFieldSet(this, _Auth_urlType, urlType, "f");
23
24
  }
24
25
  registerUser({ email, appVerifyUrl, gender, height, username }) {
25
26
  if (!checkParameters(email, appVerifyUrl)) {
@@ -29,7 +30,7 @@ class Auth {
29
30
  if (gender && height) {
30
31
  body = Object.assign(Object.assign({}, body), { attributes: { gender, height } });
31
32
  }
32
- return axios.post(`${getUrl({ urlName: APP_AUTH_BASE_URL, stagingUrl: __classPrivateFieldGet(this, _Auth_stagingUrl, "f") })}${API_ENDPOINTS.REGISTER_USER}`, body, {
33
+ return axios.post(`${getUrl({ urlName: APP_AUTH_BASE_URL, urlType: __classPrivateFieldGet(this, _Auth_urlType, "f") })}${API_ENDPOINTS.REGISTER_USER}`, body, {
33
34
  headers: { "X-Api-Key": __classPrivateFieldGet(this, _Auth_accessKey, "f") },
34
35
  });
35
36
  }
@@ -37,7 +38,7 @@ class Auth {
37
38
  if (!checkParameters(token)) {
38
39
  throw new Error(REQUIRED_MESSAGE);
39
40
  }
40
- return axios.post(`${getUrl({ urlName: APP_AUTH_BASE_URL, stagingUrl: __classPrivateFieldGet(this, _Auth_stagingUrl, "f") })}${API_ENDPOINTS.VERIFY_USER}`, null, {
41
+ return axios.post(`${getUrl({ urlName: APP_AUTH_BASE_URL, urlType: __classPrivateFieldGet(this, _Auth_urlType, "f") })}${API_ENDPOINTS.VERIFY_USER}`, null, {
41
42
  params: { token },
42
43
  headers: { "X-Api-Key": __classPrivateFieldGet(this, _Auth_accessKey, "f") },
43
44
  });
@@ -46,13 +47,13 @@ class Auth {
46
47
  if (!checkParameters(scanId, email, height, gender)) {
47
48
  throw new Error(REQUIRED_MESSAGE);
48
49
  }
49
- return axios.post(`${getUrl({ urlName: APP_AUTH_BASE_URL, stagingUrl: __classPrivateFieldGet(this, _Auth_stagingUrl, "f") })}${API_ENDPOINTS.ADD_USER}`, { scan_id: scanId, email, name, offsetMarketingConsent, attributes: JSON.stringify({ height, gender }) }, { headers: { "X-Api-Key": __classPrivateFieldGet(this, _Auth_accessKey, "f") } });
50
+ return axios.post(`${getUrl({ urlName: APP_AUTH_BASE_URL, urlType: __classPrivateFieldGet(this, _Auth_urlType, "f") })}${API_ENDPOINTS.ADD_USER}`, { scan_id: scanId, email, name, offsetMarketingConsent, attributes: JSON.stringify({ height, gender }) }, { headers: { "X-Api-Key": __classPrivateFieldGet(this, _Auth_accessKey, "f") } });
50
51
  }
51
52
  getUserDetail(email) {
52
53
  if (!checkParameters(email)) {
53
54
  throw new Error(REQUIRED_MESSAGE);
54
55
  }
55
- return axios.get(`${getUrl({ urlName: APP_AUTH_BASE_URL, stagingUrl: __classPrivateFieldGet(this, _Auth_stagingUrl, "f") })}${API_ENDPOINTS.GET_USER_DETAIL}/${email}`, {
56
+ return axios.get(`${getUrl({ urlName: APP_AUTH_BASE_URL, urlType: __classPrivateFieldGet(this, _Auth_urlType, "f") })}${API_ENDPOINTS.GET_USER_DETAIL}/${email}`, {
56
57
  headers: { "X-Api-Key": __classPrivateFieldGet(this, _Auth_accessKey, "f") },
57
58
  });
58
59
  }
@@ -62,7 +63,7 @@ class Auth {
62
63
  }
63
64
  if (__classPrivateFieldGet(this, _Auth_socketRef, "f"))
64
65
  __classPrivateFieldGet(this, _Auth_socketRef, "f").close();
65
- __classPrivateFieldSet(this, _Auth_socketRef, new WebSocket(`${getUrl({ urlName: APP_BASE_WEBSOCKET_URL, stagingUrl: __classPrivateFieldGet(this, _Auth_stagingUrl, "f") })}${API_ENDPOINTS.AUTH}`), "f");
66
+ __classPrivateFieldSet(this, _Auth_socketRef, new WebSocket(`${getUrl({ urlName: APP_BASE_WEBSOCKET_URL, urlType: __classPrivateFieldGet(this, _Auth_urlType, "f") })}${API_ENDPOINTS.AUTH}`), "f");
66
67
  const detailObj = { email, scanId };
67
68
  if (__classPrivateFieldGet(this, _Auth_socketRef, "f")) {
68
69
  __classPrivateFieldGet(this, _Auth_socketRef, "f").onopen = () => {
@@ -91,5 +92,5 @@ class Auth {
91
92
  }
92
93
  }
93
94
  }
94
- _Auth_socketRef = new WeakMap(), _Auth_accessKey = new WeakMap(), _Auth_stagingUrl = new WeakMap();
95
+ _Auth_socketRef = new WeakMap(), _Auth_accessKey = new WeakMap(), _Auth_urlType = new WeakMap();
95
96
  export default Auth;
@@ -1,5 +1,7 @@
1
1
  export declare const STAGING_URL: Record<string, string>;
2
2
  export declare const PROD_URL: Record<string, string>;
3
+ export declare const DEV_URL: Record<string, string>;
4
+ export declare const URLS: Record<string, Record<string, string>>;
3
5
  export declare const FILE_UPLOAD_ENDPOINT: {
4
6
  UPLOAD_START: string;
5
7
  UPLOAD_COMPLETE: string;
@@ -8,6 +8,16 @@ export const PROD_URL = {
8
8
  APP_BASE_WEBSOCKET_URL: "wss://wsnotify.api.swanvision.ai",
9
9
  APP_POSE_DETECTION_WEBSOCKET_URL: "https://posedetect-service.uvcn97hn133d6.eu-west-1.cs.amazonlightsail.com",
10
10
  };
11
+ export const DEV_URL = {
12
+ APP_AUTH_BASE_URL: "https://develop.api.swanvision.ai",
13
+ APP_BASE_WEBSOCKET_URL: "wss://develop.wsnotify.api.swanvision.ai",
14
+ APP_POSE_DETECTION_WEBSOCKET_URL: "https://posedetect-service-staging.ft2a64raup4pg.us-east-1.cs.amazonlightsail.com",
15
+ };
16
+ export const URLS = {
17
+ dev: DEV_URL,
18
+ staging: STAGING_URL,
19
+ prod: PROD_URL
20
+ };
11
21
  export const FILE_UPLOAD_ENDPOINT = {
12
22
  UPLOAD_START: "/upload/start",
13
23
  UPLOAD_COMPLETE: "/upload/complete",
@@ -1,4 +1,5 @@
1
1
  import { AxiosResponse } from "axios";
2
+ import { URLType } from "./enum.js";
2
3
  interface CreateCustomer {
3
4
  name: string;
4
5
  storeUrl: string;
@@ -9,7 +10,7 @@ interface CreateCustomer {
9
10
  }
10
11
  declare class Custom {
11
12
  #private;
12
- constructor(accessKey: string, stagingUrl?: boolean);
13
+ constructor(accessKey: string, urlType?: URLType);
13
14
  createCustomer(payload: CreateCustomer): Promise<AxiosResponse<any>>;
14
15
  getCustomCustomerConfig: (store_url: string) => Promise<AxiosResponse<any>>;
15
16
  getModelUrl: (id: string) => Promise<AxiosResponse<any>>;
@@ -9,21 +9,22 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
9
9
  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");
10
10
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
11
  };
12
- var _Custom_accessKey, _Custom_stagingUrl;
12
+ var _Custom_accessKey, _Custom_urlType;
13
13
  import axios from "axios";
14
14
  import { API_ENDPOINTS, APP_AUTH_BASE_URL, REQUIRED_MESSAGE } from "./constants.js";
15
15
  import { checkParameters, getUrl } from "./utils.js";
16
+ import { URLType } from "./enum.js";
16
17
  class Custom {
17
- constructor(accessKey, stagingUrl = false) {
18
+ constructor(accessKey, urlType = URLType.PROD) {
18
19
  _Custom_accessKey.set(this, void 0);
19
- _Custom_stagingUrl.set(this, void 0);
20
+ _Custom_urlType.set(this, void 0);
20
21
  this.getCustomCustomerConfig = (store_url) => {
21
22
  if (checkParameters(store_url) === false) {
22
23
  throw new Error(REQUIRED_MESSAGE);
23
24
  }
24
25
  return axios.get(`${getUrl({
25
26
  urlName: APP_AUTH_BASE_URL,
26
- stagingUrl: __classPrivateFieldGet(this, _Custom_stagingUrl, "f"),
27
+ urlType: __classPrivateFieldGet(this, _Custom_urlType, "f"),
27
28
  })}${API_ENDPOINTS.CUSTOM_CUSTOMER}`, {
28
29
  params: { store_url },
29
30
  headers: { "X-Api-Key": __classPrivateFieldGet(this, _Custom_accessKey, "f") },
@@ -33,19 +34,19 @@ class Custom {
33
34
  if (checkParameters(id) === false) {
34
35
  throw new Error(REQUIRED_MESSAGE);
35
36
  }
36
- return axios.get(`${getUrl({ urlName: APP_AUTH_BASE_URL, stagingUrl: __classPrivateFieldGet(this, _Custom_stagingUrl, "f") })}${API_ENDPOINTS.MODEL}/${id}`, {
37
+ return axios.get(`${getUrl({ urlName: APP_AUTH_BASE_URL, urlType: __classPrivateFieldGet(this, _Custom_urlType, "f") })}${API_ENDPOINTS.MODEL}/${id}`, {
37
38
  headers: { "X-Api-Key": __classPrivateFieldGet(this, _Custom_accessKey, "f") },
38
39
  });
39
40
  };
40
41
  __classPrivateFieldSet(this, _Custom_accessKey, accessKey, "f");
41
- __classPrivateFieldSet(this, _Custom_stagingUrl, stagingUrl, "f");
42
+ __classPrivateFieldSet(this, _Custom_urlType, urlType, "f");
42
43
  }
43
44
  createCustomer(payload) {
44
45
  if (checkParameters(payload.name, payload.storeUrl, payload.email, payload.location) === false) {
45
46
  throw new Error(REQUIRED_MESSAGE);
46
47
  }
47
- return axios.post(`${getUrl({ urlName: APP_AUTH_BASE_URL, stagingUrl: __classPrivateFieldGet(this, _Custom_stagingUrl, "f") })}${API_ENDPOINTS.CREATE_CUSTOMER}`, Object.assign(Object.assign({}, payload), { headers: { "X-Api-Key": __classPrivateFieldGet(this, _Custom_accessKey, "f") } }));
48
+ return axios.post(`${getUrl({ urlName: APP_AUTH_BASE_URL, urlType: __classPrivateFieldGet(this, _Custom_urlType, "f") })}${API_ENDPOINTS.CREATE_CUSTOMER}`, Object.assign(Object.assign({}, payload), { headers: { "X-Api-Key": __classPrivateFieldGet(this, _Custom_accessKey, "f") } }));
48
49
  }
49
50
  }
50
- _Custom_accessKey = new WeakMap(), _Custom_stagingUrl = new WeakMap();
51
+ _Custom_accessKey = new WeakMap(), _Custom_urlType = new WeakMap();
51
52
  export default Custom;
@@ -0,0 +1,5 @@
1
+ export declare enum URLType {
2
+ DEV = "dev",
3
+ STAGING = "staging",
4
+ PROD = "prod"
5
+ }
@@ -0,0 +1,6 @@
1
+ export var URLType;
2
+ (function (URLType) {
3
+ URLType["DEV"] = "dev";
4
+ URLType["STAGING"] = "staging";
5
+ URLType["PROD"] = "prod";
6
+ })(URLType || (URLType = {}));
@@ -1,48 +1,10 @@
1
- import { BodyScanObjMetaData, FaceScanObjMetaData } from "./constants.js";
2
- interface SetDeviceInfo {
3
- detection?: string;
4
- model?: string;
5
- gyro: {
6
- alpha?: string;
7
- gamma?: string;
8
- beta?: string;
9
- timestamp?: string;
10
- }[];
11
- scanId: string;
12
- }
13
- interface BodyScanUploadOptions {
14
- file: File;
15
- arrayMetaData: Partial<BodyScanObjMetaData>[];
16
- scanId: string;
17
- email: string;
18
- callBack?: (a: {
19
- eventName: string;
20
- message: string;
21
- scanId?: string;
22
- email?: string;
23
- objectKey?: string;
24
- }) => void;
25
- }
26
- interface FaceScanUploadOptions {
27
- file: File;
28
- arrayMetaData: Partial<FaceScanObjMetaData>[];
29
- objectKey: string;
30
- email: string;
31
- contentType: string;
32
- callBack?: (a: {
33
- eventName: string;
34
- message: string;
35
- objectKey?: string;
36
- email?: string;
37
- scanId?: string;
38
- }) => void;
39
- }
1
+ import { URLType } from "./enum.js";
2
+ import { BodyScanUploadOptions, FaceScanUploadOptions, SetDeviceInfo } from "./interface.js";
40
3
  export default class FileUpload {
41
4
  #private;
42
- constructor(accessKey: string, stagingUrl?: boolean);
5
+ constructor(accessKey: string, urlType?: URLType);
43
6
  uploadFileFrontend({ file, arrayMetaData, scanId, email, callBack }: BodyScanUploadOptions): Promise<unknown>;
44
7
  faceScanFileUploader({ file, arrayMetaData, objectKey, email, callBack }: FaceScanUploadOptions): Promise<unknown>;
45
8
  uploadFile({ file, arrayMetaData, scanId, email }: BodyScanUploadOptions): Promise<unknown>;
46
9
  setDeviceInfo(data: SetDeviceInfo): Promise<import("axios").AxiosResponse<any, any>>;
47
10
  }
48
- export {};