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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/auth.js CHANGED
@@ -1,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
- _Auth_socketRef.set(this, void 0);
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 = Object.assign(Object.assign({}, body), { attributes: { gender, height } });
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": __classPrivateFieldGet(this, _Auth_accessKey, "f") },
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": __classPrivateFieldGet(this, _Auth_accessKey, "f") },
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": __classPrivateFieldGet(this, _Auth_accessKey, "f") } });
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": __classPrivateFieldGet(this, _Auth_accessKey, "f") },
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 (__classPrivateFieldGet(this, _Auth_socketRef, "f"))
67
- __classPrivateFieldGet(this, _Auth_socketRef, "f").close();
68
- __classPrivateFieldSet(this, _Auth_socketRef, new WebSocket(`${constants_1.APP_AUTH_WEBSOCKET_URL}${constants_1.API_ENDPOINTS.AUTH}`), "f");
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
- __classPrivateFieldGet(this, _Auth_socketRef, "f").onopen = () => {
71
- var _a;
72
- (_a = __classPrivateFieldGet(this, _Auth_socketRef, "f")) === null || _a === void 0 ? void 0 : _a.send(JSON.stringify(detailObj));
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
- __classPrivateFieldGet(this, _Auth_socketRef, "f").onmessage = (event) => {
62
+ this.#socketRef.onmessage = (event) => {
76
63
  const data = JSON.parse(event.data);
77
- onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(data);
64
+ onSuccess?.(data);
78
65
  };
79
- __classPrivateFieldGet(this, _Auth_socketRef, "f").onclose = () => {
80
- onClose === null || onClose === void 0 ? void 0 : onClose();
66
+ this.#socketRef.onclose = () => {
67
+ onClose?.();
81
68
  };
82
- __classPrivateFieldGet(this, _Auth_socketRef, "f").onerror = (event) => {
83
- onError === null || onError === void 0 ? void 0 : onError(event);
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
- _Custom_accessKey.set(this, void 0);
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;
@@ -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");
32
+ __classPrivateFieldGet(this, _FileUpload_instances, "m", _FileUpload_initializeModules).call(this);
33
33
  }
34
34
  uploadFile(_a) {
35
35
  return __awaiter(this, arguments, void 0, function* ({ file, arrayMetaData, scanId }) {
36
- if (checkParameters(file, arrayMetaData, scanId) === false) {
36
+ if (!checkParameters(file, arrayMetaData, scanId)) {
37
37
  throw new Error(REQUIRED_MESSAGE);
38
38
  }
39
- if (checkMetaDataValue(arrayMetaData) === false) {
39
+ if (!checkMetaDataValue(arrayMetaData)) {
40
40
  throw new Error(REQUIRED_MESSAGE_FOR_META_DATA);
41
41
  }
42
- if (!__classPrivateFieldGet(this, _FileUpload_Uppy, "f") || !__classPrivateFieldGet(this, _FileUpload_AwsS3Multipart, "f")) {
43
- yield __classPrivateFieldGet(this, _FileUpload_instances, "m", _FileUpload_initializeModules).call(this);
44
- }
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,15 @@ 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
- __classPrivateFieldSet(this, _FileUpload_Uppy, (yield import("@uppy/core")).default, "f");
119
- __classPrivateFieldSet(this, _FileUpload_AwsS3Multipart, (yield import("@uppy/aws-s3-multipart")).default, "f");
115
+ if (!__classPrivateFieldGet(this, _FileUpload_Uppy, "f") || !__classPrivateFieldGet(this, _FileUpload_AwsS3Multipart, "f")) {
116
+ // const fetch = (...args) => import('node-fetch').then(({default: fetch}) => fetch(...args));
117
+ const Uppy = () => import("@uppy/core").then(({ default: Uppy }) => Uppy);
118
+ const AwsS3Multipart = () => import("@uppy/aws-s3-multipart").then(({ default: AwsS3Multipart }) => AwsS3Multipart);
119
+ // const { default: Uppy } = await import("@uppy/core");
120
+ // const { default: AwsS3Multipart } = await import("@uppy/aws-s3-multipart");
121
+ __classPrivateFieldSet(this, _FileUpload_Uppy, Uppy, "f");
122
+ __classPrivateFieldSet(this, _FileUpload_AwsS3Multipart, AwsS3Multipart, "f");
123
+ }
120
124
  });
121
125
  };
122
126
  export default FileUpload;
@@ -22,126 +22,104 @@ 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
- _FileUpload_instances.add(this);
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;
35
+ this.#initializeModules();
58
36
  }
59
- uploadFile(_a) {
60
- return __awaiter(this, arguments, void 0, function* ({ file, arrayMetaData, scanId }) {
61
- if ((0, utils_1.checkParameters)(file, arrayMetaData, scanId) === false) {
62
- throw new Error(constants_1.REQUIRED_MESSAGE);
63
- }
64
- if ((0, utils_1.checkMetaDataValue)(arrayMetaData) === false) {
65
- throw new Error(constants_1.REQUIRED_MESSAGE_FOR_META_DATA);
66
- }
67
- if (!__classPrivateFieldGet(this, _FileUpload_Uppy, "f") || !__classPrivateFieldGet(this, _FileUpload_AwsS3Multipart, "f")) {
68
- yield __classPrivateFieldGet(this, _FileUpload_instances, "m", _FileUpload_initializeModules).call(this);
37
+ async #initializeModules() {
38
+ if (!this.#Uppy || !this.#AwsS3Multipart) {
39
+ // const fetch = (...args) => import('node-fetch').then(({default: fetch}) => fetch(...args));
40
+ const Uppy = () => Promise.resolve().then(() => __importStar(require("@uppy/core"))).then(({ default: Uppy }) => Uppy);
41
+ const AwsS3Multipart = () => Promise.resolve().then(() => __importStar(require("@uppy/aws-s3-multipart"))).then(({ default: AwsS3Multipart }) => AwsS3Multipart);
42
+ // const { default: Uppy } = await import("@uppy/core");
43
+ // const { default: AwsS3Multipart } = await import("@uppy/aws-s3-multipart");
44
+ this.#Uppy = Uppy;
45
+ this.#AwsS3Multipart = AwsS3Multipart;
46
+ }
47
+ }
48
+ async uploadFile({ file, arrayMetaData, scanId }) {
49
+ if (!(0, utils_1.checkParameters)(file, arrayMetaData, scanId)) {
50
+ throw new Error(constants_1.REQUIRED_MESSAGE);
51
+ }
52
+ if (!(0, utils_1.checkMetaDataValue)(arrayMetaData)) {
53
+ throw new Error(constants_1.REQUIRED_MESSAGE_FOR_META_DATA);
54
+ }
55
+ return new Promise((resolve, reject) => {
56
+ if (this.#uppyIns) {
57
+ this.#uppyIns.close();
69
58
  }
70
- return new Promise((resolve, reject) => {
71
- if (__classPrivateFieldGet(this, _FileUpload_uppyIns, "f")) {
72
- __classPrivateFieldGet(this, _FileUpload_uppyIns, "f").close();
73
- }
74
- __classPrivateFieldSet(this, _FileUpload_uppyIns, new (__classPrivateFieldGet(this, _FileUpload_Uppy, "f"))({ autoProceed: true }), "f");
75
- __classPrivateFieldGet(this, _FileUpload_uppyIns, "f").use(__classPrivateFieldGet(this, _FileUpload_AwsS3Multipart, "f"), {
76
- limit: 10,
77
- retryDelays: [0, 1000, 3000, 5000],
78
- getChunkSize: () => 5 * 1024 * 1024,
79
- createMultipartUpload: (file) => {
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"),
59
+ this.#uppyIns = new this.#Uppy({ autoProceed: true });
60
+ this.#uppyIns.use(this.#AwsS3Multipart, {
61
+ limit: 10,
62
+ retryDelays: [0, 1000, 3000, 5000],
63
+ getChunkSize: () => 5 * 1024 * 1024,
64
+ createMultipartUpload: (file) => {
65
+ const objectKey = `${scanId}.${file.extension}`;
66
+ return (0, utils_1.fetchData)({
67
+ path: constants_1.UPPY_FILE_UPLOAD_ENDPOINT.UPLOAD_START,
68
+ apiKey: this.#accessKey,
94
69
  body: {
95
- uploadId,
96
- objectKey: key,
97
- parts,
98
- originalFileName: file.name,
70
+ objectKey,
71
+ contentType: file.type,
72
+ objectMetadata: arrayMetaData,
99
73
  },
100
- }),
101
- signPart: (file, partData) => (0, utils_1.fetchData)({
102
- path: constants_1.UPPY_FILE_UPLOAD_ENDPOINT.UPLOAD_SIGN_PART,
103
- apiKey: __classPrivateFieldGet(this, _FileUpload_accessKey, "f"),
104
- body: {
105
- objectKey: partData.key,
106
- uploadId: partData.uploadId,
107
- partNumber: partData.partNumber,
108
- },
109
- }),
110
- abortMultipartUpload: (file, { uploadId, key }) => (0, utils_1.fetchData)({
111
- path: constants_1.UPPY_FILE_UPLOAD_ENDPOINT.UPLOAD_ABORT,
112
- apiKey: __classPrivateFieldGet(this, _FileUpload_accessKey, "f"),
113
- body: {
114
- uploadId,
115
- objectKey: key,
116
- originalFileName: file.name,
117
- },
118
- }),
119
- });
120
- __classPrivateFieldGet(this, _FileUpload_uppyIns, "f").addFile({
121
- source: "manual",
122
- name: file.name,
123
- type: file.type,
124
- data: file,
125
- });
126
- __classPrivateFieldGet(this, _FileUpload_uppyIns, "f").on("upload-error", (file, error, response) => {
127
- reject(error);
128
- });
129
- __classPrivateFieldGet(this, _FileUpload_uppyIns, "f").on("upload-success", () => {
130
- resolve({ message: "file uploaded successfully" });
131
- });
132
- __classPrivateFieldGet(this, _FileUpload_uppyIns, "f").on("complete", (result) => {
133
- if (__classPrivateFieldGet(this, _FileUpload_uppyIns, "f")) {
134
- __classPrivateFieldGet(this, _FileUpload_uppyIns, "f").close();
135
- }
136
- });
74
+ });
75
+ },
76
+ completeMultipartUpload: (file, { uploadId, key, parts }) => (0, utils_1.fetchData)({
77
+ path: constants_1.UPPY_FILE_UPLOAD_ENDPOINT.UPLOAD_COMPLETE,
78
+ apiKey: this.#accessKey,
79
+ body: {
80
+ uploadId,
81
+ objectKey: key,
82
+ parts,
83
+ originalFileName: file.name,
84
+ },
85
+ }),
86
+ signPart: (file, partData) => (0, utils_1.fetchData)({
87
+ path: constants_1.UPPY_FILE_UPLOAD_ENDPOINT.UPLOAD_SIGN_PART,
88
+ apiKey: this.#accessKey,
89
+ body: {
90
+ objectKey: partData.key,
91
+ uploadId: partData.uploadId,
92
+ partNumber: partData.partNumber,
93
+ },
94
+ }),
95
+ abortMultipartUpload: (file, { uploadId, key }) => (0, utils_1.fetchData)({
96
+ path: constants_1.UPPY_FILE_UPLOAD_ENDPOINT.UPLOAD_ABORT,
97
+ apiKey: this.#accessKey,
98
+ body: {
99
+ uploadId,
100
+ objectKey: key,
101
+ originalFileName: file.name,
102
+ },
103
+ }),
104
+ });
105
+ this.#uppyIns.addFile({
106
+ source: "manual",
107
+ name: file.name,
108
+ type: file.type,
109
+ data: file,
110
+ });
111
+ this.#uppyIns.on("upload-error", (file, error, response) => {
112
+ reject(error);
113
+ });
114
+ this.#uppyIns.on("upload-success", () => {
115
+ resolve({ message: "file uploaded successfully" });
116
+ });
117
+ this.#uppyIns.on("complete", (result) => {
118
+ if (this.#uppyIns) {
119
+ this.#uppyIns.close();
120
+ }
137
121
  });
138
122
  });
139
123
  }
140
124
  }
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
125
  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
- _Swan_accessKey.set(this, void 0);
27
- __classPrivateFieldSet(this, _Swan_accessKey, accessKey, "f");
28
- this.auth = new auth_1.default(__classPrivateFieldGet(this, _Swan_accessKey, "f"));
29
- this.custom = new custom_1.default(__classPrivateFieldGet(this, _Swan_accessKey, "f"));
30
- this.fileUpload = new fileUpload_1.default(__classPrivateFieldGet(this, _Swan_accessKey, "f"));
31
- this.measurement = new measurement_1.default(__classPrivateFieldGet(this, _Swan_accessKey, "f"));
32
- this.poseDetection = new poseDetection_1.default(__classPrivateFieldGet(this, _Swan_accessKey, "f"));
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;