@swan-admin/swan-ai-measurements 1.0.59 → 1.0.62
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.d.ts +31 -74
- package/dist/auth.js +64 -112
- package/dist/constants.d.ts +30 -29
- package/dist/constants.js +14 -11
- package/dist/custom.d.ts +5 -23
- package/dist/custom.js +36 -45
- package/dist/fileUpload.d.ts +20 -29
- package/dist/fileUpload.js +114 -126
- package/dist/index.d.ts +10 -12
- package/dist/index.js +30 -15
- package/dist/measurement.d.ts +23 -66
- package/dist/measurement.js +140 -166
- package/dist/poseDetection.d.ts +9 -37
- package/dist/poseDetection.js +47 -47
- package/dist/tryOn.d.ts +37 -87
- package/dist/tryOn.js +156 -219
- package/dist/utils.d.ts +12 -13
- package/dist/utils.js +40 -22
- package/package.json +22 -27
- package/src/auth.ts +114 -0
- package/src/constants.ts +63 -0
- package/src/custom.ts +30 -0
- package/{fileUpload.js → src/fileUpload.ts} +40 -64
- package/src/index.ts +29 -0
- package/src/measurement.ts +202 -0
- package/src/poseDetection.ts +72 -0
- package/src/tryOn.ts +203 -0
- package/src/utils.ts +68 -0
- package/tsconfig.json +12 -0
- package/auth.js +0 -151
- package/constants.js +0 -42
- package/custom.js +0 -54
- package/index.js +0 -25
- package/measurement.js +0 -211
- package/poseDetection.js +0 -80
- package/tryOn.js +0 -252
- package/utils.js +0 -57
package/dist/auth.d.ts
CHANGED
|
@@ -1,77 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { AxiosResponse } from "axios";
|
|
2
|
+
interface RegisterUserParams {
|
|
3
|
+
email: string;
|
|
4
|
+
appVerifyUrl: string;
|
|
5
|
+
gender?: string;
|
|
6
|
+
height?: number;
|
|
7
|
+
username?: string;
|
|
8
|
+
}
|
|
9
|
+
interface AddUserParams {
|
|
10
|
+
scanId: string;
|
|
11
|
+
email: string;
|
|
12
|
+
name?: string;
|
|
13
|
+
height: number;
|
|
14
|
+
gender: string;
|
|
15
|
+
offsetMarketingConsent?: boolean;
|
|
16
|
+
}
|
|
17
|
+
interface AuthSocketParams {
|
|
18
|
+
email: string;
|
|
19
|
+
scanId: string;
|
|
20
|
+
onError?: (event: Event) => void;
|
|
21
|
+
onSuccess?: (data: any) => void;
|
|
22
|
+
onClose?: () => void;
|
|
23
|
+
onOpen?: () => void;
|
|
24
|
+
}
|
|
4
25
|
export default class Auth {
|
|
5
|
-
/**
|
|
6
|
-
* Constructs a new instance of the Auth class.
|
|
7
|
-
* @param {string} accessKey - The access key used for authentication.
|
|
8
|
-
*/
|
|
9
|
-
constructor(accessKey: string);
|
|
10
|
-
/**
|
|
11
|
-
* Register a new user.
|
|
12
|
-
* @param {Object} params - The parameters for user registration.
|
|
13
|
-
* @param {string} params.email - The email of the user.
|
|
14
|
-
* @param {string} params.appVerifyUrl - The verification URL.
|
|
15
|
-
* @param {string} [params.gender] - Optional. The gender of the user.
|
|
16
|
-
* @param {string} [params.height] - Optional. The height of the user.
|
|
17
|
-
* @param {string} params.username - Optional. The username of the user.
|
|
18
|
-
* @returns {Promise} - The axios response promise.
|
|
19
|
-
*/
|
|
20
|
-
registerUser({ email, appVerifyUrl, gender, height, username }: {
|
|
21
|
-
email: string;
|
|
22
|
-
appVerifyUrl: string;
|
|
23
|
-
gender?: string | undefined;
|
|
24
|
-
height?: string | undefined;
|
|
25
|
-
username: string;
|
|
26
|
-
}): Promise<any>;
|
|
27
|
-
/**
|
|
28
|
-
* Verify a user token.
|
|
29
|
-
* @param {string} token
|
|
30
|
-
* @returns {Promise}
|
|
31
|
-
*/
|
|
32
|
-
verifyToken: (token: string, accessKey: any) => Promise<any>;
|
|
33
|
-
/**
|
|
34
|
-
* Add a user.
|
|
35
|
-
* @param {Object} params
|
|
36
|
-
* @param {string} params.scanId - The scan ID.
|
|
37
|
-
* @param {string} params.email - The email of the user.
|
|
38
|
-
* @param {string} params.name - The name of the user.
|
|
39
|
-
* @param {string} params.height - The height of the user.
|
|
40
|
-
* @param {string} params.gender - The gender of the user.
|
|
41
|
-
* @param {boolean} [params.offsetMarketingConsent] - Optional. The marketing consent offset.
|
|
42
|
-
* @returns {Promise} - The axios response promise.
|
|
43
|
-
*/
|
|
44
|
-
addUser: ({ scanId, email, name, height, gender, offsetMarketingConsent }: {
|
|
45
|
-
scanId: string;
|
|
46
|
-
email: string;
|
|
47
|
-
name: string;
|
|
48
|
-
height: string;
|
|
49
|
-
gender: string;
|
|
50
|
-
offsetMarketingConsent?: boolean | undefined;
|
|
51
|
-
}) => Promise<any>;
|
|
52
|
-
/**
|
|
53
|
-
* Get user details.
|
|
54
|
-
* @param {string} email
|
|
55
|
-
* @returns {Promise}
|
|
56
|
-
*/
|
|
57
|
-
getUserDetail: (email: string) => Promise<any>;
|
|
58
|
-
/**
|
|
59
|
-
* Handle authentication via WebSocket.
|
|
60
|
-
* @param {Object} params
|
|
61
|
-
* @param {string} params.email - The email address of the user.
|
|
62
|
-
* @param {string} params.scanId - The scan ID associated with the user.
|
|
63
|
-
* @param {function} [params.onError] - Optional. Callback function to handle errors.
|
|
64
|
-
* @param {function} [params.onSuccess] - Optional. Callback function to handle successful authentication.
|
|
65
|
-
* @param {function} [params.onClose] - Optional. Callback function to handle the WebSocket close event.
|
|
66
|
-
* @param {function} [params.onOpen] - Optional. Callback function to handle the WebSocket open event.
|
|
67
|
-
*/
|
|
68
|
-
handleAuthSocket: ({ email, scanId, onError, onSuccess, onClose, onOpen }: {
|
|
69
|
-
email: string;
|
|
70
|
-
scanId: string;
|
|
71
|
-
onError?: Function | undefined;
|
|
72
|
-
onSuccess?: Function | undefined;
|
|
73
|
-
onClose?: Function | undefined;
|
|
74
|
-
onOpen?: Function | undefined;
|
|
75
|
-
}) => void;
|
|
76
26
|
#private;
|
|
27
|
+
constructor(accessKey: string);
|
|
28
|
+
registerUser({ email, appVerifyUrl, gender, height, username }: RegisterUserParams): Promise<AxiosResponse>;
|
|
29
|
+
verifyToken(token: string): Promise<AxiosResponse>;
|
|
30
|
+
addUser({ scanId, email, name, height, gender, offsetMarketingConsent }: AddUserParams): Promise<AxiosResponse>;
|
|
31
|
+
getUserDetail(email: string): Promise<AxiosResponse>;
|
|
32
|
+
handleAuthSocket({ email, scanId, onError, onSuccess, onClose, onOpen }: AuthSocketParams): void;
|
|
77
33
|
}
|
|
34
|
+
export {};
|
package/dist/auth.js
CHANGED
|
@@ -1,133 +1,85 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
+
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");
|
|
6
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
+
};
|
|
8
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
+
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");
|
|
11
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
+
};
|
|
13
|
+
var _Auth_socketRef, _Auth_accessKey;
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const axios_1 = require("axios");
|
|
16
|
+
const constants_1 = require("./constants");
|
|
17
|
+
const utils_1 = require("./utils");
|
|
18
|
+
class Auth {
|
|
19
19
|
constructor(accessKey) {
|
|
20
|
-
this
|
|
20
|
+
_Auth_socketRef.set(this, void 0);
|
|
21
|
+
_Auth_accessKey.set(this, void 0);
|
|
22
|
+
__classPrivateFieldSet(this, _Auth_accessKey, accessKey, "f");
|
|
21
23
|
}
|
|
22
|
-
/**
|
|
23
|
-
* Register a new user.
|
|
24
|
-
* @param {Object} params - The parameters for user registration.
|
|
25
|
-
* @param {string} params.email - The email of the user.
|
|
26
|
-
* @param {string} params.appVerifyUrl - The verification URL.
|
|
27
|
-
* @param {string} [params.gender] - Optional. The gender of the user.
|
|
28
|
-
* @param {string} [params.height] - Optional. The height of the user.
|
|
29
|
-
* @param {string} params.username - Optional. The username of the user.
|
|
30
|
-
* @returns {Promise} - The axios response promise.
|
|
31
|
-
*/
|
|
32
24
|
registerUser({ email, appVerifyUrl, gender, height, username }) {
|
|
33
|
-
if (checkParameters(email, appVerifyUrl)
|
|
34
|
-
throw new Error(REQUIRED_MESSAGE);
|
|
25
|
+
if (!(0, utils_1.checkParameters)(email, appVerifyUrl)) {
|
|
26
|
+
throw new Error(constants_1.REQUIRED_MESSAGE);
|
|
35
27
|
}
|
|
36
|
-
let body = {
|
|
37
|
-
username,
|
|
38
|
-
email,
|
|
39
|
-
appVerifyUrl,
|
|
40
|
-
};
|
|
28
|
+
let body = { username, email, appVerifyUrl };
|
|
41
29
|
if (gender && height) {
|
|
42
|
-
body = {
|
|
30
|
+
body = Object.assign(Object.assign({}, body), { attributes: { gender, height } });
|
|
43
31
|
}
|
|
44
|
-
return
|
|
45
|
-
headers: { "X-Api-Key": this
|
|
32
|
+
return axios_1.default.post(`${constants_1.APP_AUTH_BASE_URL}${constants_1.API_ENDPOINTS.REGISTER_USER}`, body, {
|
|
33
|
+
headers: { "X-Api-Key": __classPrivateFieldGet(this, _Auth_accessKey, "f") },
|
|
46
34
|
});
|
|
47
35
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
* @returns {Promise}
|
|
52
|
-
*/
|
|
53
|
-
verifyToken = (token, accessKey) => {
|
|
54
|
-
if (checkParameters(token) === false) {
|
|
55
|
-
throw new Error(REQUIRED_MESSAGE);
|
|
36
|
+
verifyToken(token) {
|
|
37
|
+
if (!(0, utils_1.checkParameters)(token)) {
|
|
38
|
+
throw new Error(constants_1.REQUIRED_MESSAGE);
|
|
56
39
|
}
|
|
57
|
-
return
|
|
40
|
+
return axios_1.default.post(`${constants_1.APP_AUTH_BASE_URL}${constants_1.API_ENDPOINTS.VERIFY_USER}`, null, {
|
|
58
41
|
params: { token },
|
|
59
|
-
headers: { "X-Api-Key": this
|
|
42
|
+
headers: { "X-Api-Key": __classPrivateFieldGet(this, _Auth_accessKey, "f") },
|
|
60
43
|
});
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
* @param {string} params.scanId - The scan ID.
|
|
66
|
-
* @param {string} params.email - The email of the user.
|
|
67
|
-
* @param {string} params.name - The name of the user.
|
|
68
|
-
* @param {string} params.height - The height of the user.
|
|
69
|
-
* @param {string} params.gender - The gender of the user.
|
|
70
|
-
* @param {boolean} [params.offsetMarketingConsent] - Optional. The marketing consent offset.
|
|
71
|
-
* @returns {Promise} - The axios response promise.
|
|
72
|
-
*/
|
|
73
|
-
addUser = ({ scanId, email, name, height, gender, offsetMarketingConsent }) => {
|
|
74
|
-
if (checkParameters(scanId, email, height, gender) === false) {
|
|
75
|
-
throw new Error(REQUIRED_MESSAGE);
|
|
44
|
+
}
|
|
45
|
+
addUser({ scanId, email, name, height, gender, offsetMarketingConsent }) {
|
|
46
|
+
if (!(0, utils_1.checkParameters)(scanId, email, height, gender)) {
|
|
47
|
+
throw new Error(constants_1.REQUIRED_MESSAGE);
|
|
76
48
|
}
|
|
77
|
-
return
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
attributes: JSON.stringify({ height, gender }),
|
|
83
|
-
}, { headers: { "X-Api-Key": this.#accessKey } });
|
|
84
|
-
};
|
|
85
|
-
/**
|
|
86
|
-
* Get user details.
|
|
87
|
-
* @param {string} email
|
|
88
|
-
* @returns {Promise}
|
|
89
|
-
*/
|
|
90
|
-
getUserDetail = (email) => {
|
|
91
|
-
if (checkParameters(email) === false) {
|
|
92
|
-
throw new Error(REQUIRED_MESSAGE);
|
|
49
|
+
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": __classPrivateFieldGet(this, _Auth_accessKey, "f") } });
|
|
50
|
+
}
|
|
51
|
+
getUserDetail(email) {
|
|
52
|
+
if (!(0, utils_1.checkParameters)(email)) {
|
|
53
|
+
throw new Error(constants_1.REQUIRED_MESSAGE);
|
|
93
54
|
}
|
|
94
|
-
return
|
|
95
|
-
headers: { "X-Api-Key": this
|
|
55
|
+
return axios_1.default.get(`${constants_1.APP_BASE_URL}${constants_1.API_ENDPOINTS.GET_USER_DETAIL}/${email}`, {
|
|
56
|
+
headers: { "X-Api-Key": __classPrivateFieldGet(this, _Auth_accessKey, "f") },
|
|
96
57
|
});
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
* @param {string} params.email - The email address of the user.
|
|
102
|
-
* @param {string} params.scanId - The scan ID associated with the user.
|
|
103
|
-
* @param {function} [params.onError] - Optional. Callback function to handle errors.
|
|
104
|
-
* @param {function} [params.onSuccess] - Optional. Callback function to handle successful authentication.
|
|
105
|
-
* @param {function} [params.onClose] - Optional. Callback function to handle the WebSocket close event.
|
|
106
|
-
* @param {function} [params.onOpen] - Optional. Callback function to handle the WebSocket open event.
|
|
107
|
-
*/
|
|
108
|
-
handleAuthSocket = ({ email, scanId, onError, onSuccess, onClose, onOpen }) => {
|
|
109
|
-
if (checkParameters(email, scanId) === false) {
|
|
110
|
-
throw new Error(REQUIRED_MESSAGE);
|
|
58
|
+
}
|
|
59
|
+
handleAuthSocket({ email, scanId, onError, onSuccess, onClose, onOpen }) {
|
|
60
|
+
if (!(0, utils_1.checkParameters)(email, scanId)) {
|
|
61
|
+
throw new Error(constants_1.REQUIRED_MESSAGE);
|
|
111
62
|
}
|
|
112
|
-
this
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
onOpen?.();
|
|
63
|
+
if (__classPrivateFieldGet(this, _Auth_socketRef, "f"))
|
|
64
|
+
__classPrivateFieldGet(this, _Auth_socketRef, "f").close();
|
|
65
|
+
__classPrivateFieldSet(this, _Auth_socketRef, new WebSocket(`${constants_1.APP_AUTH_WEBSOCKET_URL}${constants_1.API_ENDPOINTS.AUTH}`), "f");
|
|
66
|
+
const detailObj = { email, scanId };
|
|
67
|
+
__classPrivateFieldGet(this, _Auth_socketRef, "f").onopen = () => {
|
|
68
|
+
var _a;
|
|
69
|
+
(_a = __classPrivateFieldGet(this, _Auth_socketRef, "f")) === null || _a === void 0 ? void 0 : _a.send(JSON.stringify(detailObj));
|
|
70
|
+
onOpen === null || onOpen === void 0 ? void 0 : onOpen();
|
|
121
71
|
};
|
|
122
|
-
this
|
|
72
|
+
__classPrivateFieldGet(this, _Auth_socketRef, "f").onmessage = (event) => {
|
|
123
73
|
const data = JSON.parse(event.data);
|
|
124
|
-
onSuccess
|
|
74
|
+
onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(data);
|
|
125
75
|
};
|
|
126
|
-
this
|
|
127
|
-
onClose
|
|
76
|
+
__classPrivateFieldGet(this, _Auth_socketRef, "f").onclose = () => {
|
|
77
|
+
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
128
78
|
};
|
|
129
|
-
this
|
|
130
|
-
onError
|
|
79
|
+
__classPrivateFieldGet(this, _Auth_socketRef, "f").onerror = (event) => {
|
|
80
|
+
onError === null || onError === void 0 ? void 0 : onError(event);
|
|
131
81
|
};
|
|
132
|
-
}
|
|
82
|
+
}
|
|
133
83
|
}
|
|
84
|
+
_Auth_socketRef = new WeakMap(), _Auth_accessKey = new WeakMap();
|
|
85
|
+
exports.default = Auth;
|
package/dist/constants.d.ts
CHANGED
|
@@ -1,30 +1,31 @@
|
|
|
1
|
-
export const APP_BASE_URL:
|
|
2
|
-
export const APP_AUTH_BASE_URL:
|
|
3
|
-
export const APP_AUTH_WEBSOCKET_URL:
|
|
4
|
-
export const APP_TRY_ON_WEBSOCKET_URL:
|
|
5
|
-
export const APP_RECOMMENDATION_WEBSOCKET_URL:
|
|
6
|
-
export const
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
export declare const APP_BASE_URL: string;
|
|
2
|
+
export declare const APP_AUTH_BASE_URL: string;
|
|
3
|
+
export declare const APP_AUTH_WEBSOCKET_URL: string;
|
|
4
|
+
export declare const APP_TRY_ON_WEBSOCKET_URL: string;
|
|
5
|
+
export declare const APP_RECOMMENDATION_WEBSOCKET_URL: string;
|
|
6
|
+
export declare const APP_POSE_DETECTION_WEBSOCKET_URL: string;
|
|
7
|
+
export declare const UPPY_FILE_UPLOAD_ENDPOINT: {
|
|
8
|
+
UPLOAD_START: string;
|
|
9
|
+
UPLOAD_COMPLETE: string;
|
|
10
|
+
UPLOAD_SIGN_PART: string;
|
|
11
|
+
UPLOAD_ABORT: string;
|
|
12
|
+
};
|
|
13
|
+
export declare const API_ENDPOINTS: {
|
|
14
|
+
[key: string]: string;
|
|
15
|
+
};
|
|
16
|
+
export interface ObjMetaData {
|
|
17
|
+
gender: string;
|
|
18
|
+
scan_id: string;
|
|
19
|
+
email: string;
|
|
20
|
+
focal_length: string;
|
|
21
|
+
height: string;
|
|
22
|
+
customer_store_url: string;
|
|
23
|
+
clothes_fit: string;
|
|
24
|
+
scan_type: string;
|
|
25
|
+
callback_url: string;
|
|
12
26
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
let CUSTOM_CUSTOMER: string;
|
|
19
|
-
let MODEL: string;
|
|
20
|
-
let TRY_ON_SCAN: string;
|
|
21
|
-
let TRY_ON_IMAGE_UPLOAD: string;
|
|
22
|
-
let TRY_ON_IMAGE_DOWNLOAD: string;
|
|
23
|
-
let TRY_ON_IMAGE_URLS: string;
|
|
24
|
-
let TRY_ON_RESULT_IMAGE_DOWNLOAD: string;
|
|
25
|
-
let TRY_ON: string;
|
|
26
|
-
let AUTH: string;
|
|
27
|
-
}
|
|
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";
|
|
27
|
+
type RequiredMetaDataKeys = keyof ObjMetaData;
|
|
28
|
+
export declare const requiredMetaData: RequiredMetaDataKeys[];
|
|
29
|
+
export declare const REQUIRED_MESSAGE: string;
|
|
30
|
+
export declare const REQUIRED_MESSAGE_FOR_META_DATA: string;
|
|
31
|
+
export {};
|
package/dist/constants.js
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.REQUIRED_MESSAGE_FOR_META_DATA = exports.REQUIRED_MESSAGE = exports.requiredMetaData = exports.API_ENDPOINTS = exports.UPPY_FILE_UPLOAD_ENDPOINT = exports.APP_POSE_DETECTION_WEBSOCKET_URL = exports.APP_RECOMMENDATION_WEBSOCKET_URL = exports.APP_TRY_ON_WEBSOCKET_URL = exports.APP_AUTH_WEBSOCKET_URL = exports.APP_AUTH_BASE_URL = exports.APP_BASE_URL = void 0;
|
|
4
|
+
exports.APP_BASE_URL = "https://fitview-server-staging.ft2a64raup4pg.us-east-1.cs.amazonlightsail.com";
|
|
5
|
+
exports.APP_AUTH_BASE_URL = "https://staging.api.getswan.co";
|
|
6
|
+
exports.APP_AUTH_WEBSOCKET_URL = "wss://staging.wsnotify.api.getswan.co";
|
|
7
|
+
exports.APP_TRY_ON_WEBSOCKET_URL = "wss://bucbzczxjk.execute-api.ap-south-1.amazonaws.com";
|
|
8
|
+
exports.APP_RECOMMENDATION_WEBSOCKET_URL = "wss://staging.wsnotify.api.getswan.co/scanning";
|
|
9
|
+
exports.APP_POSE_DETECTION_WEBSOCKET_URL = "https://posedetect-service-staging.ft2a64raup4pg.us-east-1.cs.amazonlightsail.com";
|
|
10
|
+
exports.UPPY_FILE_UPLOAD_ENDPOINT = {
|
|
8
11
|
UPLOAD_START: "/upload/start",
|
|
9
12
|
UPLOAD_COMPLETE: "/upload/complete",
|
|
10
13
|
UPLOAD_SIGN_PART: "/upload/signpart",
|
|
11
14
|
UPLOAD_ABORT: "/upload/abort",
|
|
12
15
|
};
|
|
13
|
-
|
|
16
|
+
exports.API_ENDPOINTS = {
|
|
14
17
|
GET_USER_DETAIL: "/api/user",
|
|
15
18
|
REGISTER_USER: "/auth/register",
|
|
16
19
|
VERIFY_USER: "/auth/verify",
|
|
@@ -25,7 +28,7 @@ export const API_ENDPOINTS = {
|
|
|
25
28
|
TRY_ON: "/tryon",
|
|
26
29
|
AUTH: "/auth",
|
|
27
30
|
};
|
|
28
|
-
|
|
31
|
+
exports.requiredMetaData = [
|
|
29
32
|
"gender",
|
|
30
33
|
"scan_id",
|
|
31
34
|
"email",
|
|
@@ -36,5 +39,5 @@ export const requiredMetaData = [
|
|
|
36
39
|
"callback_url",
|
|
37
40
|
"clothes_fit",
|
|
38
41
|
];
|
|
39
|
-
|
|
40
|
-
|
|
42
|
+
exports.REQUIRED_MESSAGE = "Please verify required parameters";
|
|
43
|
+
exports.REQUIRED_MESSAGE_FOR_META_DATA = "Please verify required parameters in meta data";
|
package/dist/custom.d.ts
CHANGED
|
@@ -1,26 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* Represents a Custom class for handling custom operations.
|
|
4
|
-
*/
|
|
1
|
+
import { AxiosResponse } from "axios";
|
|
5
2
|
declare class Custom {
|
|
6
|
-
/**
|
|
7
|
-
* Constructs a new instance of the Custom class.
|
|
8
|
-
* @param {string} accessKey - The access key used for authentication.
|
|
9
|
-
*/
|
|
10
|
-
constructor(accessKey: string);
|
|
11
|
-
/**
|
|
12
|
-
* Retrieves custom customer configuration based on the store URL.
|
|
13
|
-
* @param {string} store_url - The URL of the store.
|
|
14
|
-
* @returns {Promise} - A promise that resolves with the custom customer configuration.
|
|
15
|
-
* @throws {Error} - If required parameters are missing.
|
|
16
|
-
*/
|
|
17
|
-
getCustomCustomerConfig: (store_url: string) => Promise<any>;
|
|
18
|
-
/**
|
|
19
|
-
* Retrieves the model URL based on the model ID.
|
|
20
|
-
* @param {string} id - The ID of the model.
|
|
21
|
-
* @returns {Promise} - A promise that resolves with the model URL.
|
|
22
|
-
* @throws {Error} - If required parameters are missing.
|
|
23
|
-
*/
|
|
24
|
-
getModelUrl: (id: string) => Promise<any>;
|
|
25
3
|
#private;
|
|
4
|
+
constructor(accessKey: string);
|
|
5
|
+
getCustomCustomerConfig: (store_url: string) => Promise<AxiosResponse<any>>;
|
|
6
|
+
getModelUrl: (id: string) => Promise<AxiosResponse<any>>;
|
|
26
7
|
}
|
|
8
|
+
export default Custom;
|
package/dist/custom.js
CHANGED
|
@@ -1,49 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
+
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");
|
|
6
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
+
};
|
|
8
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
+
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");
|
|
11
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
+
};
|
|
13
|
+
var _Custom_accessKey;
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const axios_1 = require("axios");
|
|
16
|
+
const constants_1 = require("./constants");
|
|
17
|
+
const utils_1 = require("./utils");
|
|
7
18
|
class Custom {
|
|
8
|
-
/**
|
|
9
|
-
* The access key used for authentication.
|
|
10
|
-
* @type {string}
|
|
11
|
-
* @private
|
|
12
|
-
*/
|
|
13
|
-
#accessKey;
|
|
14
|
-
/**
|
|
15
|
-
* Constructs a new instance of the Custom class.
|
|
16
|
-
* @param {string} accessKey - The access key used for authentication.
|
|
17
|
-
*/
|
|
18
19
|
constructor(accessKey) {
|
|
19
|
-
this
|
|
20
|
+
_Custom_accessKey.set(this, void 0);
|
|
21
|
+
this.getCustomCustomerConfig = (store_url) => {
|
|
22
|
+
if ((0, utils_1.checkParameters)(store_url) === false) {
|
|
23
|
+
throw new Error(constants_1.REQUIRED_MESSAGE);
|
|
24
|
+
}
|
|
25
|
+
return axios_1.default.get(`${constants_1.APP_AUTH_BASE_URL}${constants_1.API_ENDPOINTS.CUSTOM_CUSTOMER}`, {
|
|
26
|
+
params: { store_url },
|
|
27
|
+
headers: { "X-Api-Key": __classPrivateFieldGet(this, _Custom_accessKey, "f") },
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
this.getModelUrl = (id) => {
|
|
31
|
+
if ((0, utils_1.checkParameters)(id) === false) {
|
|
32
|
+
throw new Error(constants_1.REQUIRED_MESSAGE);
|
|
33
|
+
}
|
|
34
|
+
return axios_1.default.get(`${constants_1.APP_AUTH_BASE_URL}${constants_1.API_ENDPOINTS.MODEL}/${id}`, { headers: { "X-Api-Key": __classPrivateFieldGet(this, _Custom_accessKey, "f") } });
|
|
35
|
+
};
|
|
36
|
+
__classPrivateFieldSet(this, _Custom_accessKey, accessKey, "f");
|
|
20
37
|
}
|
|
21
|
-
/**
|
|
22
|
-
* Retrieves custom customer configuration based on the store URL.
|
|
23
|
-
* @param {string} store_url - The URL of the store.
|
|
24
|
-
* @returns {Promise} - A promise that resolves with the custom customer configuration.
|
|
25
|
-
* @throws {Error} - If required parameters are missing.
|
|
26
|
-
*/
|
|
27
|
-
getCustomCustomerConfig = (store_url) => {
|
|
28
|
-
if (checkParameters(store_url) === false) {
|
|
29
|
-
throw new Error(REQUIRED_MESSAGE);
|
|
30
|
-
}
|
|
31
|
-
return axios.get(`${APP_AUTH_BASE_URL}${API_ENDPOINTS.CUSTOM_CUSTOMER}`, {
|
|
32
|
-
params: { store_url },
|
|
33
|
-
headers: { "X-Api-Key": this.#accessKey },
|
|
34
|
-
});
|
|
35
|
-
};
|
|
36
|
-
/**
|
|
37
|
-
* Retrieves the model URL based on the model ID.
|
|
38
|
-
* @param {string} id - The ID of the model.
|
|
39
|
-
* @returns {Promise} - A promise that resolves with the model URL.
|
|
40
|
-
* @throws {Error} - If required parameters are missing.
|
|
41
|
-
*/
|
|
42
|
-
getModelUrl = (id) => {
|
|
43
|
-
if (checkParameters(id) === false) {
|
|
44
|
-
throw new Error(REQUIRED_MESSAGE);
|
|
45
|
-
}
|
|
46
|
-
return axios.get(`${APP_AUTH_BASE_URL}${API_ENDPOINTS.MODEL}/${id}`, { headers: { "X-Api-Key": this.#accessKey } });
|
|
47
|
-
};
|
|
48
38
|
}
|
|
49
|
-
|
|
39
|
+
_Custom_accessKey = new WeakMap();
|
|
40
|
+
exports.default = Custom;
|
package/dist/fileUpload.d.ts
CHANGED
|
@@ -1,31 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
* @param {Object} params - The parameters for file upload.
|
|
19
|
-
* @param {File} params.file - The file to upload.
|
|
20
|
-
* @param {Object} params.objMetaData - Optional. Metadata associated with the file.
|
|
21
|
-
* @param {string} params.scanId - Optional. The ID of the scan.
|
|
22
|
-
* @returns {Promise} - A promise that resolves when the file is uploaded successfully.
|
|
23
|
-
* @throws {Error} - If required parameters are missing or metadata value is invalid.
|
|
24
|
-
*/
|
|
25
|
-
uploadFile({ file, objMetaData, scanId }: {
|
|
26
|
-
file: File;
|
|
27
|
-
objMetaData: Object;
|
|
28
|
-
scanId: string;
|
|
29
|
-
}): Promise<any>;
|
|
1
|
+
interface ObjMetaData {
|
|
2
|
+
gender: string;
|
|
3
|
+
scan_id: string;
|
|
4
|
+
email: string;
|
|
5
|
+
focal_length: string;
|
|
6
|
+
height: string;
|
|
7
|
+
customer_store_url: string;
|
|
8
|
+
clothes_fit: string;
|
|
9
|
+
scan_type: string;
|
|
10
|
+
callback_url: string;
|
|
11
|
+
}
|
|
12
|
+
interface UploadOptions {
|
|
13
|
+
file: any;
|
|
14
|
+
arrayMetaData: ObjMetaData[];
|
|
15
|
+
scanId: string;
|
|
16
|
+
}
|
|
17
|
+
export default class FileUpload {
|
|
30
18
|
#private;
|
|
19
|
+
constructor(accessKey: string);
|
|
20
|
+
uploadFile({ file, arrayMetaData, scanId }: UploadOptions): Promise<unknown>;
|
|
31
21
|
}
|
|
22
|
+
export {};
|