@swan-admin/swan-ai-measurements 1.0.44 → 1.0.45
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/constants.js +11 -1
- package/fileUpload.js +4 -1
- package/package.json +1 -1
- package/utils.js +18 -0
package/constants.js
CHANGED
|
@@ -28,5 +28,15 @@ export const API_ENDPOINTS = {
|
|
|
28
28
|
TRY_ON: "/tryon",
|
|
29
29
|
AUTH: "/auth",
|
|
30
30
|
};
|
|
31
|
-
|
|
31
|
+
export const requiredMetaData = [
|
|
32
|
+
"gender",
|
|
33
|
+
"scan_id",
|
|
34
|
+
"email",
|
|
35
|
+
"focal_length",
|
|
36
|
+
"height",
|
|
37
|
+
"customer_store_url",
|
|
38
|
+
"scan_type",
|
|
39
|
+
"callback_url",
|
|
40
|
+
];
|
|
32
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/fileUpload.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import AwsS3Multipart from "@uppy/aws-s3-multipart";
|
|
2
2
|
import Uppy from "@uppy/core";
|
|
3
|
-
import { REQUIRED_MESSAGE, UPPY_FILE_UPLOAD_ENDPOINT } from "./constants.js";
|
|
3
|
+
import { REQUIRED_MESSAGE, REQUIRED_MESSAGE_FOR_META_DATA, UPPY_FILE_UPLOAD_ENDPOINT } from "./constants.js";
|
|
4
4
|
import { checkParameters, fetchData } from "./utils.js";
|
|
5
5
|
|
|
6
6
|
export default class FileUpload {
|
|
@@ -10,6 +10,9 @@ export default class FileUpload {
|
|
|
10
10
|
if (checkParameters(file, objMetaData, scanId, accessKey) === false) {
|
|
11
11
|
throw new Error(REQUIRED_MESSAGE);
|
|
12
12
|
}
|
|
13
|
+
if (checkMetaDataValue(objMetaData) === false) {
|
|
14
|
+
throw new Error(REQUIRED_MESSAGE_FOR_META_DATA);
|
|
15
|
+
}
|
|
13
16
|
return new Promise((resolve, reject) => {
|
|
14
17
|
if (this.#uppyIns) {
|
|
15
18
|
this.#uppyIns.close();
|
package/package.json
CHANGED
package/utils.js
CHANGED
|
@@ -30,3 +30,21 @@ export const checkParameters = (...args) => {
|
|
|
30
30
|
}
|
|
31
31
|
return true;
|
|
32
32
|
};
|
|
33
|
+
|
|
34
|
+
export const checkMetaDataValue = (obj) => {
|
|
35
|
+
for (const key of requiredMetaData) {
|
|
36
|
+
if (
|
|
37
|
+
!obj.hasOwnProperty(key) ||
|
|
38
|
+
obj[key] === undefined ||
|
|
39
|
+
obj[key] === null ||
|
|
40
|
+
obj[key] === "" ||
|
|
41
|
+
typeof obj[key] === "number"
|
|
42
|
+
) {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
if (!obj.callback_url.startsWith("https")) {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
return true;
|
|
50
|
+
};
|