@swan-admin/swan-ai-measurements 1.0.64 → 1.0.66
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 +20 -34
- package/dist/custom.js +17 -30
- package/dist/esm/fileUpload.js +14 -13
- package/dist/fileUpload.js +84 -109
- package/dist/index.js +14 -21
- package/dist/measurement.js +90 -115
- package/dist/poseDetection.js +16 -32
- package/dist/tryOn.js +126 -152
- package/dist/utils.js +14 -25
- package/package.json +7 -1
- package/src/fileUpload.ts +13 -8
- package/tsconfig.json +1 -1
package/dist/auth.js
CHANGED
|
@@ -1,28 +1,16 @@
|
|
|
1
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
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
4
|
};
|
|
16
|
-
var _Auth_socketRef, _Auth_accessKey;
|
|
17
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
6
|
const axios_1 = __importDefault(require("axios"));
|
|
19
7
|
const constants_1 = require("./constants");
|
|
20
8
|
const utils_1 = require("./utils");
|
|
21
9
|
class Auth {
|
|
10
|
+
#socketRef;
|
|
11
|
+
#accessKey;
|
|
22
12
|
constructor(accessKey) {
|
|
23
|
-
|
|
24
|
-
_Auth_accessKey.set(this, void 0);
|
|
25
|
-
__classPrivateFieldSet(this, _Auth_accessKey, accessKey, "f");
|
|
13
|
+
this.#accessKey = accessKey;
|
|
26
14
|
}
|
|
27
15
|
registerUser({ email, appVerifyUrl, gender, height, username }) {
|
|
28
16
|
if (!(0, utils_1.checkParameters)(email, appVerifyUrl)) {
|
|
@@ -30,10 +18,10 @@ class Auth {
|
|
|
30
18
|
}
|
|
31
19
|
let body = { username, email, appVerifyUrl };
|
|
32
20
|
if (gender && height) {
|
|
33
|
-
body =
|
|
21
|
+
body = { ...body, attributes: { gender, height } };
|
|
34
22
|
}
|
|
35
23
|
return axios_1.default.post(`${constants_1.APP_AUTH_BASE_URL}${constants_1.API_ENDPOINTS.REGISTER_USER}`, body, {
|
|
36
|
-
headers: { "X-Api-Key":
|
|
24
|
+
headers: { "X-Api-Key": this.#accessKey },
|
|
37
25
|
});
|
|
38
26
|
}
|
|
39
27
|
verifyToken(token) {
|
|
@@ -42,47 +30,45 @@ class Auth {
|
|
|
42
30
|
}
|
|
43
31
|
return axios_1.default.post(`${constants_1.APP_AUTH_BASE_URL}${constants_1.API_ENDPOINTS.VERIFY_USER}`, null, {
|
|
44
32
|
params: { token },
|
|
45
|
-
headers: { "X-Api-Key":
|
|
33
|
+
headers: { "X-Api-Key": this.#accessKey },
|
|
46
34
|
});
|
|
47
35
|
}
|
|
48
36
|
addUser({ scanId, email, name, height, gender, offsetMarketingConsent }) {
|
|
49
37
|
if (!(0, utils_1.checkParameters)(scanId, email, height, gender)) {
|
|
50
38
|
throw new Error(constants_1.REQUIRED_MESSAGE);
|
|
51
39
|
}
|
|
52
|
-
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":
|
|
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 } });
|
|
53
41
|
}
|
|
54
42
|
getUserDetail(email) {
|
|
55
43
|
if (!(0, utils_1.checkParameters)(email)) {
|
|
56
44
|
throw new Error(constants_1.REQUIRED_MESSAGE);
|
|
57
45
|
}
|
|
58
46
|
return axios_1.default.get(`${constants_1.APP_BASE_URL}${constants_1.API_ENDPOINTS.GET_USER_DETAIL}/${email}`, {
|
|
59
|
-
headers: { "X-Api-Key":
|
|
47
|
+
headers: { "X-Api-Key": this.#accessKey },
|
|
60
48
|
});
|
|
61
49
|
}
|
|
62
50
|
handleAuthSocket({ email, scanId, onError, onSuccess, onClose, onOpen }) {
|
|
63
51
|
if (!(0, utils_1.checkParameters)(email, scanId)) {
|
|
64
52
|
throw new Error(constants_1.REQUIRED_MESSAGE);
|
|
65
53
|
}
|
|
66
|
-
if (
|
|
67
|
-
|
|
68
|
-
|
|
54
|
+
if (this.#socketRef)
|
|
55
|
+
this.#socketRef.close();
|
|
56
|
+
this.#socketRef = new WebSocket(`${constants_1.APP_AUTH_WEBSOCKET_URL}${constants_1.API_ENDPOINTS.AUTH}`);
|
|
69
57
|
const detailObj = { email, scanId };
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
(
|
|
73
|
-
onOpen === null || onOpen === void 0 ? void 0 : onOpen();
|
|
58
|
+
this.#socketRef.onopen = () => {
|
|
59
|
+
this.#socketRef?.send(JSON.stringify(detailObj));
|
|
60
|
+
onOpen?.();
|
|
74
61
|
};
|
|
75
|
-
|
|
62
|
+
this.#socketRef.onmessage = (event) => {
|
|
76
63
|
const data = JSON.parse(event.data);
|
|
77
|
-
onSuccess
|
|
64
|
+
onSuccess?.(data);
|
|
78
65
|
};
|
|
79
|
-
|
|
80
|
-
onClose
|
|
66
|
+
this.#socketRef.onclose = () => {
|
|
67
|
+
onClose?.();
|
|
81
68
|
};
|
|
82
|
-
|
|
83
|
-
onError
|
|
69
|
+
this.#socketRef.onerror = (event) => {
|
|
70
|
+
onError?.(event);
|
|
84
71
|
};
|
|
85
72
|
}
|
|
86
73
|
}
|
|
87
|
-
_Auth_socketRef = new WeakMap(), _Auth_accessKey = new WeakMap();
|
|
88
74
|
exports.default = Auth;
|
package/dist/custom.js
CHANGED
|
@@ -1,43 +1,30 @@
|
|
|
1
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
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
4
|
};
|
|
16
|
-
var _Custom_accessKey;
|
|
17
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
6
|
const axios_1 = __importDefault(require("axios"));
|
|
19
7
|
const constants_1 = require("./constants");
|
|
20
8
|
const utils_1 = require("./utils");
|
|
21
9
|
class Custom {
|
|
10
|
+
#accessKey;
|
|
22
11
|
constructor(accessKey) {
|
|
23
|
-
|
|
24
|
-
this.getCustomCustomerConfig = (store_url) => {
|
|
25
|
-
if ((0, utils_1.checkParameters)(store_url) === false) {
|
|
26
|
-
throw new Error(constants_1.REQUIRED_MESSAGE);
|
|
27
|
-
}
|
|
28
|
-
return axios_1.default.get(`${constants_1.APP_AUTH_BASE_URL}${constants_1.API_ENDPOINTS.CUSTOM_CUSTOMER}`, {
|
|
29
|
-
params: { store_url },
|
|
30
|
-
headers: { "X-Api-Key": __classPrivateFieldGet(this, _Custom_accessKey, "f") },
|
|
31
|
-
});
|
|
32
|
-
};
|
|
33
|
-
this.getModelUrl = (id) => {
|
|
34
|
-
if ((0, utils_1.checkParameters)(id) === false) {
|
|
35
|
-
throw new Error(constants_1.REQUIRED_MESSAGE);
|
|
36
|
-
}
|
|
37
|
-
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") } });
|
|
38
|
-
};
|
|
39
|
-
__classPrivateFieldSet(this, _Custom_accessKey, accessKey, "f");
|
|
12
|
+
this.#accessKey = accessKey;
|
|
40
13
|
}
|
|
14
|
+
getCustomCustomerConfig = (store_url) => {
|
|
15
|
+
if ((0, utils_1.checkParameters)(store_url) === false) {
|
|
16
|
+
throw new Error(constants_1.REQUIRED_MESSAGE);
|
|
17
|
+
}
|
|
18
|
+
return axios_1.default.get(`${constants_1.APP_AUTH_BASE_URL}${constants_1.API_ENDPOINTS.CUSTOM_CUSTOMER}`, {
|
|
19
|
+
params: { store_url },
|
|
20
|
+
headers: { "X-Api-Key": this.#accessKey },
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
getModelUrl = (id) => {
|
|
24
|
+
if ((0, utils_1.checkParameters)(id) === false) {
|
|
25
|
+
throw new Error(constants_1.REQUIRED_MESSAGE);
|
|
26
|
+
}
|
|
27
|
+
return axios_1.default.get(`${constants_1.APP_AUTH_BASE_URL}${constants_1.API_ENDPOINTS.MODEL}/${id}`, { headers: { "X-Api-Key": this.#accessKey } });
|
|
28
|
+
};
|
|
41
29
|
}
|
|
42
|
-
_Custom_accessKey = new WeakMap();
|
|
43
30
|
exports.default = Custom;
|
package/dist/esm/fileUpload.js
CHANGED
|
@@ -7,17 +7,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
11
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
12
|
-
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");
|
|
13
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
14
|
-
};
|
|
15
10
|
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
16
11
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
17
12
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
18
13
|
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");
|
|
19
14
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
20
15
|
};
|
|
16
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
17
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
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
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
20
|
+
};
|
|
21
21
|
var _FileUpload_instances, _FileUpload_uppyIns, _FileUpload_accessKey, _FileUpload_Uppy, _FileUpload_AwsS3Multipart, _FileUpload_initializeModules;
|
|
22
22
|
import { REQUIRED_MESSAGE, REQUIRED_MESSAGE_FOR_META_DATA, UPPY_FILE_UPLOAD_ENDPOINT } from "./constants";
|
|
23
23
|
import { checkMetaDataValue, checkParameters, fetchData } from "./utils";
|
|
@@ -28,20 +28,17 @@ class FileUpload {
|
|
|
28
28
|
_FileUpload_accessKey.set(this, void 0);
|
|
29
29
|
_FileUpload_Uppy.set(this, void 0);
|
|
30
30
|
_FileUpload_AwsS3Multipart.set(this, void 0);
|
|
31
|
-
__classPrivateFieldGet(this, _FileUpload_instances, "m", _FileUpload_initializeModules).call(this);
|
|
32
31
|
__classPrivateFieldSet(this, _FileUpload_accessKey, accessKey, "f");
|
|
33
32
|
}
|
|
34
33
|
uploadFile(_a) {
|
|
35
34
|
return __awaiter(this, arguments, void 0, function* ({ file, arrayMetaData, scanId }) {
|
|
36
|
-
if (checkParameters(file, arrayMetaData, scanId)
|
|
35
|
+
if (!checkParameters(file, arrayMetaData, scanId)) {
|
|
37
36
|
throw new Error(REQUIRED_MESSAGE);
|
|
38
37
|
}
|
|
39
|
-
if (checkMetaDataValue(arrayMetaData)
|
|
38
|
+
if (!checkMetaDataValue(arrayMetaData)) {
|
|
40
39
|
throw new Error(REQUIRED_MESSAGE_FOR_META_DATA);
|
|
41
40
|
}
|
|
42
|
-
|
|
43
|
-
yield __classPrivateFieldGet(this, _FileUpload_instances, "m", _FileUpload_initializeModules).call(this);
|
|
44
|
-
}
|
|
41
|
+
yield __classPrivateFieldGet(this, _FileUpload_instances, "m", _FileUpload_initializeModules).call(this);
|
|
45
42
|
return new Promise((resolve, reject) => {
|
|
46
43
|
if (__classPrivateFieldGet(this, _FileUpload_uppyIns, "f")) {
|
|
47
44
|
__classPrivateFieldGet(this, _FileUpload_uppyIns, "f").close();
|
|
@@ -115,8 +112,12 @@ class FileUpload {
|
|
|
115
112
|
}
|
|
116
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() {
|
|
117
114
|
return __awaiter(this, void 0, void 0, function* () {
|
|
118
|
-
|
|
119
|
-
|
|
115
|
+
if (!__classPrivateFieldGet(this, _FileUpload_Uppy, "f") || !__classPrivateFieldGet(this, _FileUpload_AwsS3Multipart, "f")) {
|
|
116
|
+
const { default: Uppy } = yield import("@uppy/core");
|
|
117
|
+
const { default: AwsS3Multipart } = yield import("@uppy/aws-s3-multipart");
|
|
118
|
+
__classPrivateFieldSet(this, _FileUpload_Uppy, Uppy, "f");
|
|
119
|
+
__classPrivateFieldSet(this, _FileUpload_AwsS3Multipart, AwsS3Multipart, "f");
|
|
120
|
+
}
|
|
120
121
|
});
|
|
121
122
|
};
|
|
122
123
|
export default FileUpload;
|
package/dist/fileUpload.js
CHANGED
|
@@ -22,126 +22,101 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
35
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
36
|
-
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");
|
|
37
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
38
|
-
};
|
|
39
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
40
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
41
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
42
|
-
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");
|
|
43
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
44
|
-
};
|
|
45
|
-
var _FileUpload_instances, _FileUpload_uppyIns, _FileUpload_accessKey, _FileUpload_Uppy, _FileUpload_AwsS3Multipart, _FileUpload_initializeModules;
|
|
46
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
47
26
|
const constants_1 = require("./constants");
|
|
48
27
|
const utils_1 = require("./utils");
|
|
49
28
|
class FileUpload {
|
|
29
|
+
#uppyIns;
|
|
30
|
+
#accessKey;
|
|
31
|
+
#Uppy;
|
|
32
|
+
#AwsS3Multipart;
|
|
50
33
|
constructor(accessKey) {
|
|
51
|
-
|
|
52
|
-
_FileUpload_uppyIns.set(this, void 0);
|
|
53
|
-
_FileUpload_accessKey.set(this, void 0);
|
|
54
|
-
_FileUpload_Uppy.set(this, void 0);
|
|
55
|
-
_FileUpload_AwsS3Multipart.set(this, void 0);
|
|
56
|
-
__classPrivateFieldGet(this, _FileUpload_instances, "m", _FileUpload_initializeModules).call(this);
|
|
57
|
-
__classPrivateFieldSet(this, _FileUpload_accessKey, accessKey, "f");
|
|
34
|
+
this.#accessKey = accessKey;
|
|
58
35
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
36
|
+
async #initializeModules() {
|
|
37
|
+
if (!this.#Uppy || !this.#AwsS3Multipart) {
|
|
38
|
+
const { default: Uppy } = await Promise.resolve().then(() => __importStar(require("@uppy/core")));
|
|
39
|
+
const { default: AwsS3Multipart } = await Promise.resolve().then(() => __importStar(require("@uppy/aws-s3-multipart")));
|
|
40
|
+
this.#Uppy = Uppy;
|
|
41
|
+
this.#AwsS3Multipart = AwsS3Multipart;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
async uploadFile({ file, arrayMetaData, scanId }) {
|
|
45
|
+
if (!(0, utils_1.checkParameters)(file, arrayMetaData, scanId)) {
|
|
46
|
+
throw new Error(constants_1.REQUIRED_MESSAGE);
|
|
47
|
+
}
|
|
48
|
+
if (!(0, utils_1.checkMetaDataValue)(arrayMetaData)) {
|
|
49
|
+
throw new Error(constants_1.REQUIRED_MESSAGE_FOR_META_DATA);
|
|
50
|
+
}
|
|
51
|
+
await this.#initializeModules();
|
|
52
|
+
return new Promise((resolve, reject) => {
|
|
53
|
+
if (this.#uppyIns) {
|
|
54
|
+
this.#uppyIns.close();
|
|
69
55
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
const objectKey = `${scanId}.${file.extension}`;
|
|
81
|
-
return (0, utils_1.fetchData)({
|
|
82
|
-
path: constants_1.UPPY_FILE_UPLOAD_ENDPOINT.UPLOAD_START,
|
|
83
|
-
apiKey: __classPrivateFieldGet(this, _FileUpload_accessKey, "f"),
|
|
84
|
-
body: {
|
|
85
|
-
objectKey,
|
|
86
|
-
contentType: file.type,
|
|
87
|
-
objectMetadata: arrayMetaData,
|
|
88
|
-
},
|
|
89
|
-
});
|
|
90
|
-
},
|
|
91
|
-
completeMultipartUpload: (file, { uploadId, key, parts }) => (0, utils_1.fetchData)({
|
|
92
|
-
path: constants_1.UPPY_FILE_UPLOAD_ENDPOINT.UPLOAD_COMPLETE,
|
|
93
|
-
apiKey: __classPrivateFieldGet(this, _FileUpload_accessKey, "f"),
|
|
56
|
+
this.#uppyIns = new this.#Uppy({ autoProceed: true });
|
|
57
|
+
this.#uppyIns.use(this.#AwsS3Multipart, {
|
|
58
|
+
limit: 10,
|
|
59
|
+
retryDelays: [0, 1000, 3000, 5000],
|
|
60
|
+
getChunkSize: () => 5 * 1024 * 1024,
|
|
61
|
+
createMultipartUpload: (file) => {
|
|
62
|
+
const objectKey = `${scanId}.${file.extension}`;
|
|
63
|
+
return (0, utils_1.fetchData)({
|
|
64
|
+
path: constants_1.UPPY_FILE_UPLOAD_ENDPOINT.UPLOAD_START,
|
|
65
|
+
apiKey: this.#accessKey,
|
|
94
66
|
body: {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
originalFileName: file.name,
|
|
67
|
+
objectKey,
|
|
68
|
+
contentType: file.type,
|
|
69
|
+
objectMetadata: arrayMetaData,
|
|
99
70
|
},
|
|
100
|
-
})
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
71
|
+
});
|
|
72
|
+
},
|
|
73
|
+
completeMultipartUpload: (file, { uploadId, key, parts }) => (0, utils_1.fetchData)({
|
|
74
|
+
path: constants_1.UPPY_FILE_UPLOAD_ENDPOINT.UPLOAD_COMPLETE,
|
|
75
|
+
apiKey: this.#accessKey,
|
|
76
|
+
body: {
|
|
77
|
+
uploadId,
|
|
78
|
+
objectKey: key,
|
|
79
|
+
parts,
|
|
80
|
+
originalFileName: file.name,
|
|
81
|
+
},
|
|
82
|
+
}),
|
|
83
|
+
signPart: (file, partData) => (0, utils_1.fetchData)({
|
|
84
|
+
path: constants_1.UPPY_FILE_UPLOAD_ENDPOINT.UPLOAD_SIGN_PART,
|
|
85
|
+
apiKey: this.#accessKey,
|
|
86
|
+
body: {
|
|
87
|
+
objectKey: partData.key,
|
|
88
|
+
uploadId: partData.uploadId,
|
|
89
|
+
partNumber: partData.partNumber,
|
|
90
|
+
},
|
|
91
|
+
}),
|
|
92
|
+
abortMultipartUpload: (file, { uploadId, key }) => (0, utils_1.fetchData)({
|
|
93
|
+
path: constants_1.UPPY_FILE_UPLOAD_ENDPOINT.UPLOAD_ABORT,
|
|
94
|
+
apiKey: this.#accessKey,
|
|
95
|
+
body: {
|
|
96
|
+
uploadId,
|
|
97
|
+
objectKey: key,
|
|
98
|
+
originalFileName: file.name,
|
|
99
|
+
},
|
|
100
|
+
}),
|
|
101
|
+
});
|
|
102
|
+
this.#uppyIns.addFile({
|
|
103
|
+
source: "manual",
|
|
104
|
+
name: file.name,
|
|
105
|
+
type: file.type,
|
|
106
|
+
data: file,
|
|
107
|
+
});
|
|
108
|
+
this.#uppyIns.on("upload-error", (file, error, response) => {
|
|
109
|
+
reject(error);
|
|
110
|
+
});
|
|
111
|
+
this.#uppyIns.on("upload-success", () => {
|
|
112
|
+
resolve({ message: "file uploaded successfully" });
|
|
113
|
+
});
|
|
114
|
+
this.#uppyIns.on("complete", (result) => {
|
|
115
|
+
if (this.#uppyIns) {
|
|
116
|
+
this.#uppyIns.close();
|
|
117
|
+
}
|
|
137
118
|
});
|
|
138
119
|
});
|
|
139
120
|
}
|
|
140
121
|
}
|
|
141
|
-
_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() {
|
|
142
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
143
|
-
__classPrivateFieldSet(this, _FileUpload_Uppy, (yield Promise.resolve().then(() => __importStar(require("@uppy/core")))).default, "f");
|
|
144
|
-
__classPrivateFieldSet(this, _FileUpload_AwsS3Multipart, (yield Promise.resolve().then(() => __importStar(require("@uppy/aws-s3-multipart")))).default, "f");
|
|
145
|
-
});
|
|
146
|
-
};
|
|
147
122
|
exports.default = FileUpload;
|
package/dist/index.js
CHANGED
|
@@ -1,19 +1,7 @@
|
|
|
1
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
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
4
|
};
|
|
16
|
-
var _Swan_accessKey;
|
|
17
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
6
|
const auth_1 = __importDefault(require("./auth"));
|
|
19
7
|
const custom_1 = __importDefault(require("./custom"));
|
|
@@ -22,16 +10,21 @@ const measurement_1 = __importDefault(require("./measurement"));
|
|
|
22
10
|
const poseDetection_1 = __importDefault(require("./poseDetection"));
|
|
23
11
|
const tryOn_1 = __importDefault(require("./tryOn"));
|
|
24
12
|
class Swan {
|
|
13
|
+
#accessKey;
|
|
14
|
+
auth;
|
|
15
|
+
custom;
|
|
16
|
+
fileUpload;
|
|
17
|
+
measurement;
|
|
18
|
+
poseDetection;
|
|
19
|
+
tryOn;
|
|
25
20
|
constructor(accessKey) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
this.
|
|
29
|
-
this.
|
|
30
|
-
this.
|
|
31
|
-
this.
|
|
32
|
-
this.
|
|
33
|
-
this.tryOn = new tryOn_1.default(__classPrivateFieldGet(this, _Swan_accessKey, "f"));
|
|
21
|
+
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);
|
|
34
28
|
}
|
|
35
29
|
}
|
|
36
|
-
_Swan_accessKey = new WeakMap();
|
|
37
30
|
exports.default = Swan;
|