@swan-admin/swan-ai-measurements 1.1.18 → 1.1.19

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/constants.js CHANGED
@@ -21,7 +21,7 @@ exports.APP_AUTH_BASE_URL = "APP_AUTH_BASE_URL";
21
21
  exports.APP_BASE_WEBSOCKET_URL = "APP_BASE_WEBSOCKET_URL";
22
22
  exports.APP_POSE_DETECTION_WEBSOCKET_URL = "APP_POSE_DETECTION_WEBSOCKET_URL";
23
23
  exports.API_ENDPOINTS = {
24
- GET_USER_DETAIL: "/api/user",
24
+ GET_USER_DETAIL: "/user",
25
25
  REGISTER_USER: "/auth/register",
26
26
  VERIFY_USER: "/auth/verify",
27
27
  ADD_USER: "/user",
@@ -18,7 +18,7 @@ export const APP_AUTH_BASE_URL = "APP_AUTH_BASE_URL";
18
18
  export const APP_BASE_WEBSOCKET_URL = "APP_BASE_WEBSOCKET_URL";
19
19
  export const APP_POSE_DETECTION_WEBSOCKET_URL = "APP_POSE_DETECTION_WEBSOCKET_URL";
20
20
  export const API_ENDPOINTS = {
21
- GET_USER_DETAIL: "/api/user",
21
+ GET_USER_DETAIL: "/user",
22
22
  REGISTER_USER: "/auth/register",
23
23
  VERIFY_USER: "/auth/verify",
24
24
  ADD_USER: "/user",
package/dist/esm/tryOn.js CHANGED
@@ -129,6 +129,12 @@ class TryOn {
129
129
  uploadFile(_a) {
130
130
  return __awaiter(this, arguments, void 0, function* ({ files, userId }) {
131
131
  var _b;
132
+ if (checkParameters(files, userId) === false) {
133
+ throw new Error(REQUIRED_MESSAGE);
134
+ }
135
+ if ((files === null || files === void 0 ? void 0 : files.length) > 2) {
136
+ throw new Error("Cannot allow more than 2 files.");
137
+ }
132
138
  try {
133
139
  const payload = {
134
140
  userId,
@@ -166,6 +172,9 @@ class TryOn {
166
172
  }
167
173
  }
168
174
  _TryOn_tryOnSocketRef = new WeakMap(), _TryOn_timerWaitingRef = new WeakMap(), _TryOn_accessKey = new WeakMap(), _TryOn_stagingUrl = new WeakMap(), _TryOn_disconnectSocket = new WeakMap(), _TryOn_handleTimeOut = new WeakMap(), _TryOn_handleGetTryOnResult = new WeakMap(), _TryOn_instances = new WeakSet(), _TryOn_getSignedUrl = function _TryOn_getSignedUrl(payload) {
175
+ if (checkParameters(payload) === false) {
176
+ throw new Error(REQUIRED_MESSAGE);
177
+ }
169
178
  return axios.post(`${getUrl({ urlName: APP_AUTH_BASE_URL, stagingUrl: __classPrivateFieldGet(this, _TryOn_stagingUrl, "f") })}${API_ENDPOINTS.TRY_ON_IMAGE_UPLOAD}`, payload, {
170
179
  headers: {
171
180
  "Content-Type": "application/json",
@@ -173,6 +182,9 @@ _TryOn_tryOnSocketRef = new WeakMap(), _TryOn_timerWaitingRef = new WeakMap(), _
173
182
  },
174
183
  });
175
184
  }, _TryOn_s3Upload = function _TryOn_s3Upload(url, file) {
185
+ if (checkParameters(url, file) === false) {
186
+ throw new Error(REQUIRED_MESSAGE);
187
+ }
176
188
  return axios.put(url, file, {
177
189
  headers: {
178
190
  "Content-Type": file.type,
package/dist/tryOn.js CHANGED
@@ -16,6 +16,12 @@ class TryOn {
16
16
  this.#stagingUrl = stagingUrl;
17
17
  }
18
18
  async uploadFile({ files, userId }) {
19
+ if ((0, utils_js_1.checkParameters)(files, userId) === false) {
20
+ throw new Error(constants_js_1.REQUIRED_MESSAGE);
21
+ }
22
+ if (files?.length > 2) {
23
+ throw new Error("Cannot allow more than 2 files.");
24
+ }
19
25
  try {
20
26
  const payload = {
21
27
  userId,
@@ -35,6 +41,9 @@ class TryOn {
35
41
  }
36
42
  }
37
43
  #getSignedUrl(payload) {
44
+ if ((0, utils_js_1.checkParameters)(payload) === false) {
45
+ throw new Error(constants_js_1.REQUIRED_MESSAGE);
46
+ }
38
47
  return axios_1.default.post(`${(0, utils_js_1.getUrl)({ urlName: constants_js_1.APP_AUTH_BASE_URL, stagingUrl: this.#stagingUrl })}${constants_js_1.API_ENDPOINTS.TRY_ON_IMAGE_UPLOAD}`, payload, {
39
48
  headers: {
40
49
  "Content-Type": "application/json",
@@ -43,6 +52,9 @@ class TryOn {
43
52
  });
44
53
  }
45
54
  #s3Upload(url, file) {
55
+ if ((0, utils_js_1.checkParameters)(url, file) === false) {
56
+ throw new Error(constants_js_1.REQUIRED_MESSAGE);
57
+ }
46
58
  return axios_1.default.put(url, file, {
47
59
  headers: {
48
60
  "Content-Type": file.type,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swan-admin/swan-ai-measurements",
3
- "version": "1.1.18",
3
+ "version": "1.1.19",
4
4
  "description": "provides ai measurement suggestion",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/esm/index.js",
package/src/constants.ts CHANGED
@@ -28,7 +28,7 @@ export const APP_POSE_DETECTION_WEBSOCKET_URL = "APP_POSE_DETECTION_WEBSOCKET_UR
28
28
  export const API_ENDPOINTS: {
29
29
  [key: string]: string;
30
30
  } = {
31
- GET_USER_DETAIL: "/api/user",
31
+ GET_USER_DETAIL: "/user",
32
32
  REGISTER_USER: "/auth/register",
33
33
  VERIFY_USER: "/auth/verify",
34
34
  ADD_USER: "/user",
package/src/tryOn.ts CHANGED
@@ -54,6 +54,12 @@ class TryOn {
54
54
  }
55
55
 
56
56
  async uploadFile({ files, userId }: UploadFileParams): Promise<string> {
57
+ if (checkParameters(files, userId) === false) {
58
+ throw new Error(REQUIRED_MESSAGE);
59
+ }
60
+ if (files?.length > 2) {
61
+ throw new Error("Cannot allow more than 2 files.");
62
+ }
57
63
  try {
58
64
  const payload = {
59
65
  userId,
@@ -73,6 +79,9 @@ class TryOn {
73
79
  }
74
80
 
75
81
  #getSignedUrl(payload: { userId: string; userImages: string[] }): Promise<AxiosResponse<any>> {
82
+ if (checkParameters(payload) === false) {
83
+ throw new Error(REQUIRED_MESSAGE);
84
+ }
76
85
  return axios.post(`${getUrl({ urlName: APP_AUTH_BASE_URL, stagingUrl: this.#stagingUrl })}${API_ENDPOINTS.TRY_ON_IMAGE_UPLOAD}`, payload, {
77
86
  headers: {
78
87
  "Content-Type": "application/json",
@@ -82,6 +91,9 @@ class TryOn {
82
91
  }
83
92
 
84
93
  #s3Upload(url: string, file: File): Promise<AxiosResponse<any>> {
94
+ if (checkParameters(url, file) === false) {
95
+ throw new Error(REQUIRED_MESSAGE);
96
+ }
85
97
  return axios.put(url, file, {
86
98
  headers: {
87
99
  "Content-Type": file.type,