@swan-admin/swan-ai-measurements 1.0.56 → 1.0.58
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/auth.js +4 -6
- package/constants.js +21 -25
- package/custom.js +4 -4
- package/fileUpload.js +3 -3
- package/index.js +7 -7
- package/measurement.js +4 -4
- package/package.json +4 -2
- package/poseDetection.js +4 -4
- package/tryOn.js +4 -4
- package/types/auth.d.ts +8 -9
- package/types/auth.js +164 -0
- package/types/constants.d.ts +9 -9
- package/types/constants.js +40 -0
- package/types/custom.d.ts +1 -1
- package/types/custom.js +64 -0
- package/types/fileUpload.d.ts +2 -2
- package/types/fileUpload.js +220 -0
- package/types/index.d.ts +7 -7
- package/types/index.js +33 -0
- package/types/measurement.d.ts +9 -9
- package/types/measurement.js +242 -0
- package/types/poseDetection.d.ts +1 -1
- package/types/poseDetection.js +91 -0
- package/types/tryOn.d.ts +8 -8
- package/types/tryOn.js +348 -0
- package/types/utils.d.ts +5 -5
- package/types/utils.js +106 -0
- package/utils.js +5 -7
package/auth.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Represents a Auth class for handling authentication operations.
|
|
7
7
|
*/
|
|
8
|
-
class Auth {
|
|
8
|
+
export default class Auth {
|
|
9
9
|
#socketRef;
|
|
10
10
|
|
|
11
11
|
/**
|
|
@@ -149,5 +149,3 @@ class Auth {
|
|
|
149
149
|
};
|
|
150
150
|
};
|
|
151
151
|
}
|
|
152
|
-
|
|
153
|
-
module.exports = Auth;
|
package/constants.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
const APP_BASE_URL = "https://fitview-server-staging.ft2a64raup4pg.us-east-1.cs.amazonlightsail.com";
|
|
2
|
-
const APP_AUTH_BASE_URL = "https://staging.api.getswan.co";
|
|
3
|
-
const APP_AUTH_WEBSOCKET_URL = "wss://staging.wsnotify.api.getswan.co";
|
|
4
|
-
const APP_TRY_ON_WEBSOCKET_URL = "wss://bucbzczxjk.execute-api.ap-south-1.amazonaws.com";
|
|
5
|
-
const APP_RECOMMENDATION_WEBSOCKET_URL = "wss://staging.wsnotify.api.getswan.co/scanning";
|
|
6
|
-
const APP_POSE_DETECTION_WEbSOCKET_URL = "https://posedetect-service-staging.ft2a64raup4pg.us-east-1.cs.amazonlightsail.com";
|
|
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
7
|
|
|
8
|
-
const UPPY_FILE_UPLOAD_ENDPOINT = {
|
|
8
|
+
export const UPPY_FILE_UPLOAD_ENDPOINT = {
|
|
9
9
|
UPLOAD_START: "/upload/start",
|
|
10
10
|
UPLOAD_COMPLETE: "/upload/complete",
|
|
11
11
|
UPLOAD_SIGN_PART: "/upload/signpart",
|
|
12
12
|
UPLOAD_ABORT: "/upload/abort",
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
-
const API_ENDPOINTS = {
|
|
15
|
+
export const API_ENDPOINTS = {
|
|
16
16
|
GET_USER_DETAIL: "/api/user",
|
|
17
17
|
REGISTER_USER: "/auth/register",
|
|
18
18
|
VERIFY_USER: "/auth/verify",
|
|
@@ -27,20 +27,16 @@ const API_ENDPOINTS = {
|
|
|
27
27
|
TRY_ON: "/tryon",
|
|
28
28
|
AUTH: "/auth",
|
|
29
29
|
};
|
|
30
|
-
const requiredMetaData = [
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
requiredMetaData,
|
|
44
|
-
API_ENDPOINTS,
|
|
45
|
-
UPPY_FILE_UPLOAD_ENDPOINT,
|
|
46
|
-
};
|
|
30
|
+
export const requiredMetaData = [
|
|
31
|
+
"gender",
|
|
32
|
+
"scan_id",
|
|
33
|
+
"email",
|
|
34
|
+
"focal_length",
|
|
35
|
+
"height",
|
|
36
|
+
"customer_store_url",
|
|
37
|
+
"scan_type",
|
|
38
|
+
"callback_url",
|
|
39
|
+
"clothes_fit",
|
|
40
|
+
];
|
|
41
|
+
export const REQUIRED_MESSAGE = "Please verify required parameters";
|
|
42
|
+
export const REQUIRED_MESSAGE_FOR_META_DATA = "Please verify required parameters in meta data";
|
package/custom.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import axios from "axios";
|
|
2
|
+
import { API_ENDPOINTS, APP_AUTH_BASE_URL, REQUIRED_MESSAGE } from "./constants.js";
|
|
3
|
+
import { checkParameters } from "./utils.js";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Represents a Custom class for handling custom operations.
|
|
@@ -51,4 +51,4 @@ class Custom {
|
|
|
51
51
|
};
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
export default Custom;
|
package/fileUpload.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
3
|
/**
|
|
4
4
|
* Class representing a file uploader using Uppy for multipart uploads.
|
|
5
5
|
*/
|
|
@@ -143,4 +143,4 @@ class FileUpload {
|
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
-
|
|
146
|
+
export default FileUpload;
|
package/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
class Swan {
|
|
8
8
|
#accessKey;
|
|
9
9
|
constructor(accessKey) {
|
|
@@ -22,4 +22,4 @@ class Swan {
|
|
|
22
22
|
tryOn = new TryOn(this.#accessKey);
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
export default Swan;
|
package/measurement.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Class representing measurement-related functionality.
|
|
@@ -208,4 +208,4 @@ class Measurement {
|
|
|
208
208
|
}
|
|
209
209
|
}
|
|
210
210
|
|
|
211
|
-
|
|
211
|
+
export default Measurement;
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@swan-admin/swan-ai-measurements",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.58",
|
|
4
4
|
"description": "provides ai measurement suggestion",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "types/index.d.ts",
|
|
7
|
+
"type": "module",
|
|
7
8
|
"files": [
|
|
8
9
|
"index.js",
|
|
9
10
|
"auth.js",
|
|
@@ -27,7 +28,8 @@
|
|
|
27
28
|
},
|
|
28
29
|
"devDependencies": {
|
|
29
30
|
"nodemon": "^3.1.0",
|
|
30
|
-
"typescript": "^5.4.5"
|
|
31
|
+
"typescript": "^5.4.5",
|
|
32
|
+
"undici": "^6.18.0"
|
|
31
33
|
},
|
|
32
34
|
"scripts": {
|
|
33
35
|
"start": "nodemon index.js",
|
package/poseDetection.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { io } from "socket.io-client";
|
|
2
|
+
import { APP_POSE_DETECTION_WEbSOCKET_URL } from "./constants.js";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Class representing pose detection functionality.
|
|
@@ -22,7 +22,7 @@ class PoseDetection {
|
|
|
22
22
|
*/
|
|
23
23
|
connect() {
|
|
24
24
|
return new Promise((resolve, reject) => {
|
|
25
|
-
this.#socketRef = io.connect(
|
|
25
|
+
this.#socketRef = io.connect(APP_POSE_DETECTION_WEbSOCKET_URL);
|
|
26
26
|
this.#socketRef?.on("connect", () => {
|
|
27
27
|
resolve(this.#socketRef.id);
|
|
28
28
|
});
|
|
@@ -77,4 +77,4 @@ class PoseDetection {
|
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
|
|
80
|
+
export default PoseDetection;
|
package/tryOn.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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";
|
|
4
4
|
|
|
5
5
|
class TryOn {
|
|
6
6
|
#tryOnSocketRef = null;
|
|
@@ -249,4 +249,4 @@ class TryOn {
|
|
|
249
249
|
};
|
|
250
250
|
}
|
|
251
251
|
|
|
252
|
-
|
|
252
|
+
export default TryOn;
|
package/types/auth.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
export = Auth;
|
|
2
1
|
/**
|
|
3
2
|
* Represents a Auth class for handling authentication operations.
|
|
4
3
|
*/
|
|
5
|
-
|
|
4
|
+
export default class Auth {
|
|
6
5
|
/**
|
|
7
6
|
* Constructs a new instance of the Auth class.
|
|
8
7
|
* @param {string} accessKey - The access key used for authentication.
|
|
@@ -21,8 +20,8 @@ declare class Auth {
|
|
|
21
20
|
registerUser({ email, appVerifyUrl, gender, height, username }: {
|
|
22
21
|
email: string;
|
|
23
22
|
appVerifyUrl: string;
|
|
24
|
-
gender?: string;
|
|
25
|
-
height?: string;
|
|
23
|
+
gender?: string | undefined;
|
|
24
|
+
height?: string | undefined;
|
|
26
25
|
username: string;
|
|
27
26
|
}): Promise<any>;
|
|
28
27
|
/**
|
|
@@ -48,7 +47,7 @@ declare class Auth {
|
|
|
48
47
|
name: string;
|
|
49
48
|
height: string;
|
|
50
49
|
gender: string;
|
|
51
|
-
offsetMarketingConsent?: boolean;
|
|
50
|
+
offsetMarketingConsent?: boolean | undefined;
|
|
52
51
|
}) => Promise<any>;
|
|
53
52
|
/**
|
|
54
53
|
* Get user details.
|
|
@@ -69,10 +68,10 @@ declare class Auth {
|
|
|
69
68
|
handleAuthSocket: ({ email, scanId, onError, onSuccess, onClose, onOpen }: {
|
|
70
69
|
email: string;
|
|
71
70
|
scanId: string;
|
|
72
|
-
onError?: Function;
|
|
73
|
-
onSuccess?: Function;
|
|
74
|
-
onClose?: Function;
|
|
75
|
-
onOpen?: Function;
|
|
71
|
+
onError?: Function | undefined;
|
|
72
|
+
onSuccess?: Function | undefined;
|
|
73
|
+
onClose?: Function | undefined;
|
|
74
|
+
onOpen?: Function | undefined;
|
|
76
75
|
}) => void;
|
|
77
76
|
#private;
|
|
78
77
|
}
|
package/types/auth.js
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
13
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
14
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
15
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
16
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
17
|
+
};
|
|
18
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
19
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
20
|
+
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");
|
|
21
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
22
|
+
};
|
|
23
|
+
var _Auth_socketRef, _Auth_accessKey;
|
|
24
|
+
import axios from "axios";
|
|
25
|
+
import { API_ENDPOINTS, APP_AUTH_BASE_URL, APP_AUTH_WEBSOCKET_URL, APP_BASE_URL, REQUIRED_MESSAGE } from "./constants.js";
|
|
26
|
+
import { checkParameters } from "./utils.js";
|
|
27
|
+
/**
|
|
28
|
+
* Represents a Auth class for handling authentication operations.
|
|
29
|
+
*/
|
|
30
|
+
var Auth = /** @class */ (function () {
|
|
31
|
+
/**
|
|
32
|
+
* Constructs a new instance of the Auth class.
|
|
33
|
+
* @param {string} accessKey - The access key used for authentication.
|
|
34
|
+
*/
|
|
35
|
+
function Auth(accessKey) {
|
|
36
|
+
var _this = this;
|
|
37
|
+
_Auth_socketRef.set(this, void 0);
|
|
38
|
+
/**
|
|
39
|
+
* The access key used for authentication.
|
|
40
|
+
* @type {string}
|
|
41
|
+
* @private
|
|
42
|
+
*/
|
|
43
|
+
_Auth_accessKey.set(this, void 0);
|
|
44
|
+
/**
|
|
45
|
+
* Verify a user token.
|
|
46
|
+
* @param {string} token
|
|
47
|
+
* @returns {Promise}
|
|
48
|
+
*/
|
|
49
|
+
this.verifyToken = function (token, accessKey) {
|
|
50
|
+
if (checkParameters(token) === false) {
|
|
51
|
+
throw new Error(REQUIRED_MESSAGE);
|
|
52
|
+
}
|
|
53
|
+
return axios.post("".concat(APP_AUTH_BASE_URL).concat(API_ENDPOINTS.VERIFY_USER), null, {
|
|
54
|
+
params: { token: token },
|
|
55
|
+
headers: { "X-Api-Key": __classPrivateFieldGet(_this, _Auth_accessKey, "f") },
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Add a user.
|
|
60
|
+
* @param {Object} params
|
|
61
|
+
* @param {string} params.scanId - The scan ID.
|
|
62
|
+
* @param {string} params.email - The email of the user.
|
|
63
|
+
* @param {string} params.name - The name of the user.
|
|
64
|
+
* @param {string} params.height - The height of the user.
|
|
65
|
+
* @param {string} params.gender - The gender of the user.
|
|
66
|
+
* @param {boolean} [params.offsetMarketingConsent] - Optional. The marketing consent offset.
|
|
67
|
+
* @returns {Promise} - The axios response promise.
|
|
68
|
+
*/
|
|
69
|
+
this.addUser = function (_a) {
|
|
70
|
+
var scanId = _a.scanId, email = _a.email, name = _a.name, height = _a.height, gender = _a.gender, offsetMarketingConsent = _a.offsetMarketingConsent;
|
|
71
|
+
if (checkParameters(scanId, email, height, gender) === false) {
|
|
72
|
+
throw new Error(REQUIRED_MESSAGE);
|
|
73
|
+
}
|
|
74
|
+
return axios.post("".concat(APP_AUTH_BASE_URL).concat(API_ENDPOINTS.ADD_USER), {
|
|
75
|
+
scan_id: scanId,
|
|
76
|
+
email: email,
|
|
77
|
+
name: name,
|
|
78
|
+
offsetMarketingConsent: offsetMarketingConsent,
|
|
79
|
+
attributes: JSON.stringify({ height: height, gender: gender }),
|
|
80
|
+
}, { headers: { "X-Api-Key": __classPrivateFieldGet(_this, _Auth_accessKey, "f") } });
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* Get user details.
|
|
84
|
+
* @param {string} email
|
|
85
|
+
* @returns {Promise}
|
|
86
|
+
*/
|
|
87
|
+
this.getUserDetail = function (email) {
|
|
88
|
+
if (checkParameters(email) === false) {
|
|
89
|
+
throw new Error(REQUIRED_MESSAGE);
|
|
90
|
+
}
|
|
91
|
+
return axios.get("".concat(APP_BASE_URL).concat(API_ENDPOINTS.GET_USER_DETAIL, "/").concat(email), {
|
|
92
|
+
headers: { "X-Api-Key": __classPrivateFieldGet(_this, _Auth_accessKey, "f") },
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Handle authentication via WebSocket.
|
|
97
|
+
* @param {Object} params
|
|
98
|
+
* @param {string} params.email - The email address of the user.
|
|
99
|
+
* @param {string} params.scanId - The scan ID associated with the user.
|
|
100
|
+
* @param {function} [params.onError] - Optional. Callback function to handle errors.
|
|
101
|
+
* @param {function} [params.onSuccess] - Optional. Callback function to handle successful authentication.
|
|
102
|
+
* @param {function} [params.onClose] - Optional. Callback function to handle the WebSocket close event.
|
|
103
|
+
* @param {function} [params.onOpen] - Optional. Callback function to handle the WebSocket open event.
|
|
104
|
+
*/
|
|
105
|
+
this.handleAuthSocket = function (_a) {
|
|
106
|
+
var _b, _c;
|
|
107
|
+
var email = _a.email, scanId = _a.scanId, onError = _a.onError, onSuccess = _a.onSuccess, onClose = _a.onClose, onOpen = _a.onOpen;
|
|
108
|
+
if (checkParameters(email, scanId) === false) {
|
|
109
|
+
throw new Error(REQUIRED_MESSAGE);
|
|
110
|
+
}
|
|
111
|
+
(_c = (_b = __classPrivateFieldGet(_this, _Auth_socketRef, "f")) === null || _b === void 0 ? void 0 : _b.close) === null || _c === void 0 ? void 0 : _c.call(_b);
|
|
112
|
+
__classPrivateFieldSet(_this, _Auth_socketRef, new WebSocket("".concat(APP_AUTH_WEBSOCKET_URL).concat(API_ENDPOINTS.AUTH)), "f");
|
|
113
|
+
var detailObj = {
|
|
114
|
+
email: email,
|
|
115
|
+
scanId: scanId,
|
|
116
|
+
};
|
|
117
|
+
__classPrivateFieldGet(_this, _Auth_socketRef, "f").onopen = function () {
|
|
118
|
+
__classPrivateFieldGet(_this, _Auth_socketRef, "f").send(JSON.stringify(detailObj));
|
|
119
|
+
onOpen === null || onOpen === void 0 ? void 0 : onOpen();
|
|
120
|
+
};
|
|
121
|
+
__classPrivateFieldGet(_this, _Auth_socketRef, "f").onmessage = function (event) {
|
|
122
|
+
var data = JSON.parse(event.data);
|
|
123
|
+
onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(data);
|
|
124
|
+
};
|
|
125
|
+
__classPrivateFieldGet(_this, _Auth_socketRef, "f").onclose = function () {
|
|
126
|
+
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
127
|
+
};
|
|
128
|
+
__classPrivateFieldGet(_this, _Auth_socketRef, "f").onerror = function (event) {
|
|
129
|
+
onError === null || onError === void 0 ? void 0 : onError(event);
|
|
130
|
+
};
|
|
131
|
+
};
|
|
132
|
+
__classPrivateFieldSet(this, _Auth_accessKey, accessKey, "f");
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Register a new user.
|
|
136
|
+
* @param {Object} params - The parameters for user registration.
|
|
137
|
+
* @param {string} params.email - The email of the user.
|
|
138
|
+
* @param {string} params.appVerifyUrl - The verification URL.
|
|
139
|
+
* @param {string} [params.gender] - Optional. The gender of the user.
|
|
140
|
+
* @param {string} [params.height] - Optional. The height of the user.
|
|
141
|
+
* @param {string} params.username - Optional. The username of the user.
|
|
142
|
+
* @returns {Promise} - The axios response promise.
|
|
143
|
+
*/
|
|
144
|
+
Auth.prototype.registerUser = function (_a) {
|
|
145
|
+
var email = _a.email, appVerifyUrl = _a.appVerifyUrl, gender = _a.gender, height = _a.height, username = _a.username;
|
|
146
|
+
if (checkParameters(email, appVerifyUrl) === false) {
|
|
147
|
+
throw new Error(REQUIRED_MESSAGE);
|
|
148
|
+
}
|
|
149
|
+
var body = {
|
|
150
|
+
username: username,
|
|
151
|
+
email: email,
|
|
152
|
+
appVerifyUrl: appVerifyUrl,
|
|
153
|
+
};
|
|
154
|
+
if (gender && height) {
|
|
155
|
+
body = __assign(__assign({}, body), { attributes: { gender: gender, height: height } });
|
|
156
|
+
}
|
|
157
|
+
return axios.post("".concat(APP_AUTH_BASE_URL).concat(API_ENDPOINTS.REGISTER_USER), body, {
|
|
158
|
+
headers: { "X-Api-Key": __classPrivateFieldGet(this, _Auth_accessKey, "f") },
|
|
159
|
+
});
|
|
160
|
+
};
|
|
161
|
+
return Auth;
|
|
162
|
+
}());
|
|
163
|
+
_Auth_socketRef = new WeakMap(), _Auth_accessKey = new WeakMap();
|
|
164
|
+
export default Auth;
|
package/types/constants.d.ts
CHANGED
|
@@ -4,9 +4,12 @@ export const APP_AUTH_WEBSOCKET_URL: "wss://staging.wsnotify.api.getswan.co";
|
|
|
4
4
|
export const APP_TRY_ON_WEBSOCKET_URL: "wss://bucbzczxjk.execute-api.ap-south-1.amazonaws.com";
|
|
5
5
|
export const APP_RECOMMENDATION_WEBSOCKET_URL: "wss://staging.wsnotify.api.getswan.co/scanning";
|
|
6
6
|
export const APP_POSE_DETECTION_WEbSOCKET_URL: "https://posedetect-service-staging.ft2a64raup4pg.us-east-1.cs.amazonlightsail.com";
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
export namespace UPPY_FILE_UPLOAD_ENDPOINT {
|
|
8
|
+
let UPLOAD_START: string;
|
|
9
|
+
let UPLOAD_COMPLETE: string;
|
|
10
|
+
let UPLOAD_SIGN_PART: string;
|
|
11
|
+
let UPLOAD_ABORT: string;
|
|
12
|
+
}
|
|
10
13
|
export namespace API_ENDPOINTS {
|
|
11
14
|
let GET_USER_DETAIL: string;
|
|
12
15
|
let REGISTER_USER: string;
|
|
@@ -22,9 +25,6 @@ export namespace API_ENDPOINTS {
|
|
|
22
25
|
let TRY_ON: string;
|
|
23
26
|
let AUTH: string;
|
|
24
27
|
}
|
|
25
|
-
export
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
let UPLOAD_SIGN_PART: string;
|
|
29
|
-
let UPLOAD_ABORT: string;
|
|
30
|
-
}
|
|
28
|
+
export const requiredMetaData: string[];
|
|
29
|
+
export const REQUIRED_MESSAGE: "Please verify required parameters";
|
|
30
|
+
export const REQUIRED_MESSAGE_FOR_META_DATA: "Please verify required parameters in meta data";
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export var APP_BASE_URL = "https://fitview-server-staging.ft2a64raup4pg.us-east-1.cs.amazonlightsail.com";
|
|
2
|
+
export var APP_AUTH_BASE_URL = "https://staging.api.getswan.co";
|
|
3
|
+
export var APP_AUTH_WEBSOCKET_URL = "wss://staging.wsnotify.api.getswan.co";
|
|
4
|
+
export var APP_TRY_ON_WEBSOCKET_URL = "wss://bucbzczxjk.execute-api.ap-south-1.amazonaws.com";
|
|
5
|
+
export var APP_RECOMMENDATION_WEBSOCKET_URL = "wss://staging.wsnotify.api.getswan.co/scanning";
|
|
6
|
+
export var APP_POSE_DETECTION_WEbSOCKET_URL = "https://posedetect-service-staging.ft2a64raup4pg.us-east-1.cs.amazonlightsail.com";
|
|
7
|
+
export var UPPY_FILE_UPLOAD_ENDPOINT = {
|
|
8
|
+
UPLOAD_START: "/upload/start",
|
|
9
|
+
UPLOAD_COMPLETE: "/upload/complete",
|
|
10
|
+
UPLOAD_SIGN_PART: "/upload/signpart",
|
|
11
|
+
UPLOAD_ABORT: "/upload/abort",
|
|
12
|
+
};
|
|
13
|
+
export var API_ENDPOINTS = {
|
|
14
|
+
GET_USER_DETAIL: "/api/user",
|
|
15
|
+
REGISTER_USER: "/auth/register",
|
|
16
|
+
VERIFY_USER: "/auth/verify",
|
|
17
|
+
ADD_USER: "/user",
|
|
18
|
+
CUSTOM_CUSTOMER: "/customers/custom",
|
|
19
|
+
MODEL: "/model",
|
|
20
|
+
TRY_ON_SCAN: "/tryon/scan",
|
|
21
|
+
TRY_ON_IMAGE_UPLOAD: "/tryon/user-image-urls/upload",
|
|
22
|
+
TRY_ON_IMAGE_DOWNLOAD: "/tryon/user-image-urls/download",
|
|
23
|
+
TRY_ON_IMAGE_URLS: "/tryon/user-image-urls",
|
|
24
|
+
TRY_ON_RESULT_IMAGE_DOWNLOAD: "/tryon/result-image-urls/download",
|
|
25
|
+
TRY_ON: "/tryon",
|
|
26
|
+
AUTH: "/auth",
|
|
27
|
+
};
|
|
28
|
+
export var requiredMetaData = [
|
|
29
|
+
"gender",
|
|
30
|
+
"scan_id",
|
|
31
|
+
"email",
|
|
32
|
+
"focal_length",
|
|
33
|
+
"height",
|
|
34
|
+
"customer_store_url",
|
|
35
|
+
"scan_type",
|
|
36
|
+
"callback_url",
|
|
37
|
+
"clothes_fit",
|
|
38
|
+
];
|
|
39
|
+
export var REQUIRED_MESSAGE = "Please verify required parameters";
|
|
40
|
+
export var REQUIRED_MESSAGE_FOR_META_DATA = "Please verify required parameters in meta data";
|
package/types/custom.d.ts
CHANGED
package/types/custom.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
5
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
+
};
|
|
7
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
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
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
+
};
|
|
12
|
+
var _Custom_accessKey;
|
|
13
|
+
import axios from "axios";
|
|
14
|
+
import { API_ENDPOINTS, APP_AUTH_BASE_URL, REQUIRED_MESSAGE } from "./constants.js";
|
|
15
|
+
import { checkParameters } from "./utils.js";
|
|
16
|
+
/**
|
|
17
|
+
* Represents a Custom class for handling custom operations.
|
|
18
|
+
*/
|
|
19
|
+
var Custom = /** @class */ (function () {
|
|
20
|
+
/**
|
|
21
|
+
* Constructs a new instance of the Custom class.
|
|
22
|
+
* @param {string} accessKey - The access key used for authentication.
|
|
23
|
+
*/
|
|
24
|
+
function Custom(accessKey) {
|
|
25
|
+
var _this = this;
|
|
26
|
+
/**
|
|
27
|
+
* The access key used for authentication.
|
|
28
|
+
* @type {string}
|
|
29
|
+
* @private
|
|
30
|
+
*/
|
|
31
|
+
_Custom_accessKey.set(this, void 0);
|
|
32
|
+
/**
|
|
33
|
+
* Retrieves custom customer configuration based on the store URL.
|
|
34
|
+
* @param {string} store_url - The URL of the store.
|
|
35
|
+
* @returns {Promise} - A promise that resolves with the custom customer configuration.
|
|
36
|
+
* @throws {Error} - If required parameters are missing.
|
|
37
|
+
*/
|
|
38
|
+
this.getCustomCustomerConfig = function (store_url) {
|
|
39
|
+
if (checkParameters(store_url) === false) {
|
|
40
|
+
throw new Error(REQUIRED_MESSAGE);
|
|
41
|
+
}
|
|
42
|
+
return axios.get("".concat(APP_AUTH_BASE_URL).concat(API_ENDPOINTS.CUSTOM_CUSTOMER), {
|
|
43
|
+
params: { store_url: store_url },
|
|
44
|
+
headers: { "X-Api-Key": __classPrivateFieldGet(_this, _Custom_accessKey, "f") },
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Retrieves the model URL based on the model ID.
|
|
49
|
+
* @param {string} id - The ID of the model.
|
|
50
|
+
* @returns {Promise} - A promise that resolves with the model URL.
|
|
51
|
+
* @throws {Error} - If required parameters are missing.
|
|
52
|
+
*/
|
|
53
|
+
this.getModelUrl = function (id) {
|
|
54
|
+
if (checkParameters(id) === false) {
|
|
55
|
+
throw new Error(REQUIRED_MESSAGE);
|
|
56
|
+
}
|
|
57
|
+
return axios.get("".concat(APP_AUTH_BASE_URL).concat(API_ENDPOINTS.MODEL, "/").concat(id), { headers: { "X-Api-Key": __classPrivateFieldGet(_this, _Custom_accessKey, "f") } });
|
|
58
|
+
};
|
|
59
|
+
__classPrivateFieldSet(this, _Custom_accessKey, accessKey, "f");
|
|
60
|
+
}
|
|
61
|
+
return Custom;
|
|
62
|
+
}());
|
|
63
|
+
_Custom_accessKey = new WeakMap();
|
|
64
|
+
export default Custom;
|
package/types/fileUpload.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export default FileUpload;
|
|
2
2
|
/**
|
|
3
3
|
* Class representing a file uploader using Uppy for multipart uploads.
|
|
4
4
|
*/
|
|
@@ -24,7 +24,7 @@ declare class FileUpload {
|
|
|
24
24
|
*/
|
|
25
25
|
uploadFile({ file, objMetaData, scanId }: {
|
|
26
26
|
file: File;
|
|
27
|
-
objMetaData:
|
|
27
|
+
objMetaData: Object;
|
|
28
28
|
scanId: string;
|
|
29
29
|
}): Promise<any>;
|
|
30
30
|
#private;
|