@swan-admin/swan-ai-measurements 1.1.26 → 1.1.28

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/Readme.md CHANGED
@@ -1,33 +1,33 @@
1
- ## SWAN Node.js Library
2
-
3
- Swan is an AI Fitting Room that lets shoppers size & try on clothes virtually. For clothing brands and online retailers, Swan powers completely personalised sales – increasing conversion & reducing expensive returns.
4
-
5
- ## Documentation
6
-
7
- See the <a href="https://www.swanvision.ai/docs">SWAN API docs</a> for Node.js.
8
-
9
- ## Requirements
10
-
11
- Node 20 or higher.
12
-
13
- ## Usage
14
-
15
- ##### Installation
16
-
17
- npm i @swan-admin/swan-ai-measurements
18
-
19
- ##### Create Customer
20
-
21
- swan.custom.createCustomer({name, store_url, location, email, emailsTier_1, emailsTier_2})
22
-
23
- ##### Upload file
24
-
25
- swan.fileUpload.uploadFile({ file, arrayMetaData, scanId })
26
-
27
- ##### Get measurements
28
-
29
- swan.measurement.getMeasurementResult(scanId)
30
-
31
- ## Support
32
-
33
- New features and bug fixes are released on the latest major version of the SWAN package. If you are on an older major version, we recommend that you upgrade to the latest in order to use the new features and bug fixes including those for security vulnerabilities. Older major versions of the package will continue to be available for use, but will not be receiving any updates.
1
+ ## SWAN Node.js Library
2
+
3
+ Swan is an AI Fitting Room that lets shoppers size & try on clothes virtually. For clothing brands and online retailers, Swan powers completely personalised sales – increasing conversion & reducing expensive returns.
4
+
5
+ ## Documentation
6
+
7
+ See the <a href="https://www.swanvision.ai/docs">SWAN API docs</a> for Node.js.
8
+
9
+ ## Requirements
10
+
11
+ Node 20 or higher.
12
+
13
+ ## Usage
14
+
15
+ ##### Installation
16
+
17
+ npm i @swan-admin/swan-ai-measurements
18
+
19
+ ##### Create Customer
20
+
21
+ swan.custom.createCustomer({name, store_url, location, email, emailsTier_1, emailsTier_2})
22
+
23
+ ##### Upload file
24
+
25
+ swan.fileUpload.uploadFile({ file, arrayMetaData, scanId })
26
+
27
+ ##### Get measurements
28
+
29
+ swan.measurement.getMeasurementResult(scanId)
30
+
31
+ ## Support
32
+
33
+ New features and bug fixes are released on the latest major version of the SWAN package. If you are on an older major version, we recommend that you upgrade to the latest in order to use the new features and bug fixes including those for security vulnerabilities. Older major versions of the package will continue to be available for use, but will not be receiving any updates.
@@ -1,180 +1,221 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
1
+ var __awaiter =
2
+ (this && this.__awaiter) ||
3
+ function (thisArg, _arguments, P, generator) {
4
+ function adopt(value) {
5
+ return value instanceof P
6
+ ? value
7
+ : new P(function (resolve) {
8
+ resolve(value);
9
+ });
10
+ }
3
11
  return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
12
+ function fulfilled(value) {
13
+ try {
14
+ step(generator.next(value));
15
+ } catch (e) {
16
+ reject(e);
17
+ }
18
+ }
19
+ function rejected(value) {
20
+ try {
21
+ step(generator["throw"](value));
22
+ } catch (e) {
23
+ reject(e);
24
+ }
25
+ }
26
+ function step(result) {
27
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
28
+ }
29
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
30
  });
9
- };
10
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
31
+ };
32
+ var __classPrivateFieldSet =
33
+ (this && this.__classPrivateFieldSet) ||
34
+ function (receiver, state, value, kind, f) {
11
35
  if (kind === "m") throw new TypeError("Private method is not writable");
12
36
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
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");
14
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
15
- };
16
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
37
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
38
+ throw new TypeError("Cannot write private member to an object whose class did not declare it");
39
+ return kind === "a" ? f.call(receiver, value) : f ? (f.value = value) : state.set(receiver, value), value;
40
+ };
41
+ var __classPrivateFieldGet =
42
+ (this && this.__classPrivateFieldGet) ||
43
+ function (receiver, state, kind, f) {
17
44
  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");
45
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
46
+ throw new TypeError("Cannot read private member from an object whose class did not declare it");
19
47
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
20
- };
48
+ };
21
49
  var _FileUpload_uppyIns, _FileUpload_accessKey, _FileUpload_stagingUrl;
22
50
  import axios from "axios";
23
- import { REQUIRED_MESSAGE, REQUIRED_MESSAGE_FOR_META_DATA, FILE_UPLOAD_ENDPOINT, APP_AUTH_BASE_URL, REQUIRED_ERROR_MESSAGE_INVALID_EMAIL, } from "./constants.js";
51
+ import {
52
+ REQUIRED_MESSAGE,
53
+ REQUIRED_MESSAGE_FOR_META_DATA,
54
+ FILE_UPLOAD_ENDPOINT,
55
+ APP_AUTH_BASE_URL,
56
+ REQUIRED_ERROR_MESSAGE_INVALID_EMAIL,
57
+ } from "./constants.js";
24
58
  import { addScanType, checkMetaDataValue, checkParameters, fetchData, getFileChunks, getUrl, isValidEmail } from "./utils.js";
25
- const Uppy = require("fix-esm").require("@uppy/core");
26
- import Uppy from "@uppy/core";
59
+ import Uppy from "@uppy/core";
27
60
  import AwsS3Multipart from "@uppy/aws-s3-multipart";
28
61
  class FileUpload {
29
- constructor(accessKey, stagingUrl = false) {
30
- _FileUpload_uppyIns.set(this, void 0);
31
- _FileUpload_accessKey.set(this, void 0);
32
- _FileUpload_stagingUrl.set(this, void 0);
33
- __classPrivateFieldSet(this, _FileUpload_accessKey, accessKey, "f");
34
- __classPrivateFieldSet(this, _FileUpload_stagingUrl, stagingUrl, "f");
35
- }
36
- uploadFileFrontend(_a) {
37
- return __awaiter(this, arguments, void 0, function* ({ file, arrayMetaData, scanId, email }) {
38
- email = email.trim();
39
- if (!checkParameters(file, arrayMetaData, scanId, email)) {
40
- throw new Error(REQUIRED_MESSAGE);
41
- }
42
- if (!isValidEmail(email)) {
43
- throw new Error(REQUIRED_ERROR_MESSAGE_INVALID_EMAIL);
44
- }
45
- if (!checkMetaDataValue(arrayMetaData)) {
46
- throw new Error(REQUIRED_MESSAGE_FOR_META_DATA);
47
- }
48
- arrayMetaData = addScanType(arrayMetaData, scanId, email);
49
- return new Promise((resolve, reject) => {
50
- if (__classPrivateFieldGet(this, _FileUpload_uppyIns, "f")) {
51
- __classPrivateFieldGet(this, _FileUpload_uppyIns, "f").close();
52
- }
53
- __classPrivateFieldSet(this, _FileUpload_uppyIns, new Uppy({ autoProceed: true }), "f");
54
- __classPrivateFieldGet(this, _FileUpload_uppyIns, "f").use(AwsS3Multipart, {
55
- limit: 10,
56
- retryDelays: [0, 1000, 3000, 5000],
57
- companionUrl: getUrl({ urlName: APP_AUTH_BASE_URL, stagingUrl: __classPrivateFieldGet(this, _FileUpload_stagingUrl, "f") }),
58
- getChunkSize: () => 5 * 1024 * 1024,
59
- createMultipartUpload: (file) => {
60
- const objectKey = `${scanId}.${file.extension}`;
61
- return fetchData({
62
- path: FILE_UPLOAD_ENDPOINT.UPLOAD_START,
63
- apiKey: __classPrivateFieldGet(this, _FileUpload_accessKey, "f"),
64
- stagingUrl: __classPrivateFieldGet(this, _FileUpload_stagingUrl, "f"),
65
- body: {
66
- objectKey,
67
- contentType: file.type,
68
- objectMetadata: arrayMetaData,
69
- },
70
- });
71
- },
72
- completeMultipartUpload: (file, { uploadId, key, parts }) => fetchData({
73
- path: FILE_UPLOAD_ENDPOINT.UPLOAD_COMPLETE,
74
- apiKey: __classPrivateFieldGet(this, _FileUpload_accessKey, "f"),
75
- stagingUrl: __classPrivateFieldGet(this, _FileUpload_stagingUrl, "f"),
76
- body: {
77
- uploadId,
78
- objectKey: key,
79
- parts,
80
- originalFileName: file.name,
81
- },
82
- }),
83
- signPart: (file, partData) => fetchData({
84
- path: FILE_UPLOAD_ENDPOINT.UPLOAD_SIGN_PART,
85
- stagingUrl: __classPrivateFieldGet(this, _FileUpload_stagingUrl, "f"),
86
- apiKey: __classPrivateFieldGet(this, _FileUpload_accessKey, "f"),
87
- body: {
88
- objectKey: partData.key,
89
- uploadId: partData.uploadId,
90
- partNumber: partData.partNumber,
91
- },
92
- }),
93
- });
94
- __classPrivateFieldGet(this, _FileUpload_uppyIns, "f").addFile({
95
- source: "manual",
96
- name: file.name,
97
- type: file.type,
98
- data: file,
99
- });
100
- __classPrivateFieldGet(this, _FileUpload_uppyIns, "f").on("upload-error", (file, error, response) => {
101
- reject(error);
102
- });
103
- __classPrivateFieldGet(this, _FileUpload_uppyIns, "f").on("upload-success", () => {
104
- resolve({ message: "file uploaded successfully" });
105
- });
106
- __classPrivateFieldGet(this, _FileUpload_uppyIns, "f").on("complete", (result) => {
107
- if (__classPrivateFieldGet(this, _FileUpload_uppyIns, "f")) {
108
- __classPrivateFieldGet(this, _FileUpload_uppyIns, "f").close();
109
- }
110
- });
62
+ constructor(accessKey, stagingUrl = false) {
63
+ _FileUpload_uppyIns.set(this, void 0);
64
+ _FileUpload_accessKey.set(this, void 0);
65
+ _FileUpload_stagingUrl.set(this, void 0);
66
+ __classPrivateFieldSet(this, _FileUpload_accessKey, accessKey, "f");
67
+ __classPrivateFieldSet(this, _FileUpload_stagingUrl, stagingUrl, "f");
68
+ }
69
+ uploadFileFrontend(_a) {
70
+ return __awaiter(this, arguments, void 0, function* ({ file, arrayMetaData, scanId, email }) {
71
+ email = email.trim();
72
+ if (!checkParameters(file, arrayMetaData, scanId, email)) {
73
+ throw new Error(REQUIRED_MESSAGE);
74
+ }
75
+ if (!isValidEmail(email)) {
76
+ throw new Error(REQUIRED_ERROR_MESSAGE_INVALID_EMAIL);
77
+ }
78
+ if (!checkMetaDataValue(arrayMetaData)) {
79
+ throw new Error(REQUIRED_MESSAGE_FOR_META_DATA);
80
+ }
81
+ arrayMetaData = addScanType(arrayMetaData, scanId, email);
82
+ return new Promise((resolve, reject) => {
83
+ if (__classPrivateFieldGet(this, _FileUpload_uppyIns, "f")) {
84
+ __classPrivateFieldGet(this, _FileUpload_uppyIns, "f").close();
85
+ }
86
+ __classPrivateFieldSet(this, _FileUpload_uppyIns, new Uppy({ autoProceed: true }), "f");
87
+ __classPrivateFieldGet(this, _FileUpload_uppyIns, "f").use(AwsS3Multipart, {
88
+ limit: 10,
89
+ retryDelays: [0, 1000, 3000, 5000],
90
+ companionUrl: getUrl({ urlName: APP_AUTH_BASE_URL, stagingUrl: __classPrivateFieldGet(this, _FileUpload_stagingUrl, "f") }),
91
+ getChunkSize: () => 5 * 1024 * 1024,
92
+ createMultipartUpload: (file) => {
93
+ const objectKey = `${scanId}.${file.extension}`;
94
+ return fetchData({
95
+ path: FILE_UPLOAD_ENDPOINT.UPLOAD_START,
96
+ apiKey: __classPrivateFieldGet(this, _FileUpload_accessKey, "f"),
97
+ stagingUrl: __classPrivateFieldGet(this, _FileUpload_stagingUrl, "f"),
98
+ body: {
99
+ objectKey,
100
+ contentType: file.type,
101
+ objectMetadata: arrayMetaData,
102
+ },
111
103
  });
104
+ },
105
+ completeMultipartUpload: (file, { uploadId, key, parts }) =>
106
+ fetchData({
107
+ path: FILE_UPLOAD_ENDPOINT.UPLOAD_COMPLETE,
108
+ apiKey: __classPrivateFieldGet(this, _FileUpload_accessKey, "f"),
109
+ stagingUrl: __classPrivateFieldGet(this, _FileUpload_stagingUrl, "f"),
110
+ body: {
111
+ uploadId,
112
+ objectKey: key,
113
+ parts,
114
+ originalFileName: file.name,
115
+ },
116
+ }),
117
+ signPart: (file, partData) =>
118
+ fetchData({
119
+ path: FILE_UPLOAD_ENDPOINT.UPLOAD_SIGN_PART,
120
+ stagingUrl: __classPrivateFieldGet(this, _FileUpload_stagingUrl, "f"),
121
+ apiKey: __classPrivateFieldGet(this, _FileUpload_accessKey, "f"),
122
+ body: {
123
+ objectKey: partData.key,
124
+ uploadId: partData.uploadId,
125
+ partNumber: partData.partNumber,
126
+ },
127
+ }),
112
128
  });
113
- }
114
- uploadFile(_a) {
115
- return __awaiter(this, arguments, void 0, function* ({ file, arrayMetaData, scanId, email }) {
116
- email = email.trim();
117
- if (!checkParameters(file, arrayMetaData, scanId, email)) {
118
- throw new Error(REQUIRED_MESSAGE);
119
- }
120
- if (!isValidEmail(email)) {
121
- throw new Error(REQUIRED_ERROR_MESSAGE_INVALID_EMAIL);
122
- }
123
- if (!checkMetaDataValue(arrayMetaData)) {
124
- throw new Error(REQUIRED_MESSAGE_FOR_META_DATA);
125
- }
126
- arrayMetaData = addScanType(arrayMetaData, scanId, email);
127
- return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
128
- var _b;
129
- try {
130
- const res = yield fetchData({
131
- path: FILE_UPLOAD_ENDPOINT.UPLOAD_START,
132
- apiKey: __classPrivateFieldGet(this, _FileUpload_accessKey, "f"),
133
- stagingUrl: __classPrivateFieldGet(this, _FileUpload_stagingUrl, "f"),
134
- body: {
135
- objectKey: file.name,
136
- contentType: file.type,
137
- objectMetadata: arrayMetaData,
138
- },
139
- throwError: true,
140
- });
141
- const totalChunks = getFileChunks(file);
142
- const parts = [];
143
- for (let i = 0; i < totalChunks.length; i++) {
144
- const data = yield fetchData({
145
- path: FILE_UPLOAD_ENDPOINT.UPLOAD_SIGN_PART,
146
- apiKey: __classPrivateFieldGet(this, _FileUpload_accessKey, "f"),
147
- stagingUrl: __classPrivateFieldGet(this, _FileUpload_stagingUrl, "f"),
148
- body: {
149
- objectKey: res === null || res === void 0 ? void 0 : res.key,
150
- uploadId: res === null || res === void 0 ? void 0 : res.uploadId,
151
- partNumber: i + 1,
152
- },
153
- throwError: true,
154
- });
155
- const val = yield axios.put(data === null || data === void 0 ? void 0 : data.url, totalChunks[i], { headers: { "Content-Type": file.type, "X-Api-Key": __classPrivateFieldGet(this, _FileUpload_accessKey, "f") } });
156
- parts.push({ PartNumber: i + 1, ETag: (_b = val === null || val === void 0 ? void 0 : val.headers) === null || _b === void 0 ? void 0 : _b.etag });
157
- }
158
- const completeValue = yield fetchData({
159
- path: FILE_UPLOAD_ENDPOINT.UPLOAD_COMPLETE,
160
- apiKey: __classPrivateFieldGet(this, _FileUpload_accessKey, "f"),
161
- stagingUrl: __classPrivateFieldGet(this, _FileUpload_stagingUrl, "f"),
162
- body: {
163
- uploadId: res === null || res === void 0 ? void 0 : res.uploadId,
164
- objectKey: res === null || res === void 0 ? void 0 : res.key,
165
- parts,
166
- originalFileName: file.name,
167
- },
168
- throwError: true,
169
- });
170
- resolve({ message: "successfully uploaded", data: completeValue });
171
- }
172
- catch (error) {
173
- reject(error);
174
- }
175
- }));
129
+ __classPrivateFieldGet(this, _FileUpload_uppyIns, "f").addFile({
130
+ source: "manual",
131
+ name: file.name,
132
+ type: file.type,
133
+ data: file,
176
134
  });
177
- }
135
+ __classPrivateFieldGet(this, _FileUpload_uppyIns, "f").on("upload-error", (file, error, response) => {
136
+ reject(error);
137
+ });
138
+ __classPrivateFieldGet(this, _FileUpload_uppyIns, "f").on("upload-success", () => {
139
+ resolve({ message: "file uploaded successfully" });
140
+ });
141
+ __classPrivateFieldGet(this, _FileUpload_uppyIns, "f").on("complete", (result) => {
142
+ if (__classPrivateFieldGet(this, _FileUpload_uppyIns, "f")) {
143
+ __classPrivateFieldGet(this, _FileUpload_uppyIns, "f").close();
144
+ }
145
+ });
146
+ });
147
+ });
148
+ }
149
+ uploadFile(_a) {
150
+ return __awaiter(this, arguments, void 0, function* ({ file, arrayMetaData, scanId, email }) {
151
+ email = email.trim();
152
+ if (!checkParameters(file, arrayMetaData, scanId, email)) {
153
+ throw new Error(REQUIRED_MESSAGE);
154
+ }
155
+ if (!isValidEmail(email)) {
156
+ throw new Error(REQUIRED_ERROR_MESSAGE_INVALID_EMAIL);
157
+ }
158
+ if (!checkMetaDataValue(arrayMetaData)) {
159
+ throw new Error(REQUIRED_MESSAGE_FOR_META_DATA);
160
+ }
161
+ arrayMetaData = addScanType(arrayMetaData, scanId, email);
162
+ return new Promise((resolve, reject) =>
163
+ __awaiter(this, void 0, void 0, function* () {
164
+ var _b;
165
+ try {
166
+ const res = yield fetchData({
167
+ path: FILE_UPLOAD_ENDPOINT.UPLOAD_START,
168
+ apiKey: __classPrivateFieldGet(this, _FileUpload_accessKey, "f"),
169
+ stagingUrl: __classPrivateFieldGet(this, _FileUpload_stagingUrl, "f"),
170
+ body: {
171
+ objectKey: file.name,
172
+ contentType: file.type,
173
+ objectMetadata: arrayMetaData,
174
+ },
175
+ throwError: true,
176
+ });
177
+ const totalChunks = getFileChunks(file);
178
+ const parts = [];
179
+ for (let i = 0; i < totalChunks.length; i++) {
180
+ const data = yield fetchData({
181
+ path: FILE_UPLOAD_ENDPOINT.UPLOAD_SIGN_PART,
182
+ apiKey: __classPrivateFieldGet(this, _FileUpload_accessKey, "f"),
183
+ stagingUrl: __classPrivateFieldGet(this, _FileUpload_stagingUrl, "f"),
184
+ body: {
185
+ objectKey: res === null || res === void 0 ? void 0 : res.key,
186
+ uploadId: res === null || res === void 0 ? void 0 : res.uploadId,
187
+ partNumber: i + 1,
188
+ },
189
+ throwError: true,
190
+ });
191
+ const val = yield axios.put(data === null || data === void 0 ? void 0 : data.url, totalChunks[i], {
192
+ headers: { "Content-Type": file.type, "X-Api-Key": __classPrivateFieldGet(this, _FileUpload_accessKey, "f") },
193
+ });
194
+ parts.push({
195
+ PartNumber: i + 1,
196
+ ETag: (_b = val === null || val === void 0 ? void 0 : val.headers) === null || _b === void 0 ? void 0 : _b.etag,
197
+ });
198
+ }
199
+ const completeValue = yield fetchData({
200
+ path: FILE_UPLOAD_ENDPOINT.UPLOAD_COMPLETE,
201
+ apiKey: __classPrivateFieldGet(this, _FileUpload_accessKey, "f"),
202
+ stagingUrl: __classPrivateFieldGet(this, _FileUpload_stagingUrl, "f"),
203
+ body: {
204
+ uploadId: res === null || res === void 0 ? void 0 : res.uploadId,
205
+ objectKey: res === null || res === void 0 ? void 0 : res.key,
206
+ parts,
207
+ originalFileName: file.name,
208
+ },
209
+ throwError: true,
210
+ });
211
+ resolve({ message: "successfully uploaded", data: completeValue });
212
+ } catch (error) {
213
+ reject(error);
214
+ }
215
+ })
216
+ );
217
+ });
218
+ }
178
219
  }
179
- _FileUpload_uppyIns = new WeakMap(), _FileUpload_accessKey = new WeakMap(), _FileUpload_stagingUrl = new WeakMap();
220
+ (_FileUpload_uppyIns = new WeakMap()), (_FileUpload_accessKey = new WeakMap()), (_FileUpload_stagingUrl = new WeakMap());
180
221
  export default FileUpload;
package/dist/esm/tryOn.js CHANGED
@@ -85,11 +85,10 @@ class TryOn {
85
85
  }
86
86
  }));
87
87
  this.getTryOnResult = ({ userEmail, shopDomain, productName }) => {
88
- userEmail = userEmail.trim();
89
88
  if (checkParameters(shopDomain, userEmail, productName) === false) {
90
89
  throw new Error(REQUIRED_MESSAGE);
91
90
  }
92
- if (!isValidEmail(userEmail)) {
91
+ if (!isValidEmail(userEmail.trim())) {
93
92
  throw new Error(REQUIRED_ERROR_MESSAGE_INVALID_EMAIL);
94
93
  }
95
94
  const payload = {
@@ -108,11 +107,10 @@ class TryOn {
108
107
  uploadFile(_a) {
109
108
  return __awaiter(this, arguments, void 0, function* ({ files, userEmail }) {
110
109
  var _b;
111
- userEmail = userEmail.trim();
112
110
  if (checkParameters(files, userEmail) === false) {
113
111
  throw new Error(REQUIRED_MESSAGE);
114
112
  }
115
- if (!isValidEmail(userEmail)) {
113
+ if (!isValidEmail(userEmail.trim())) {
116
114
  throw new Error(REQUIRED_ERROR_MESSAGE_INVALID_EMAIL);
117
115
  }
118
116
  if ((files === null || files === void 0 ? void 0 : files.length) > 2) {
@@ -138,11 +136,10 @@ class TryOn {
138
136
  });
139
137
  }
140
138
  getUploadedFiles(userEmail) {
141
- userEmail = userEmail.trim();
142
139
  if (checkParameters(userEmail) === false) {
143
140
  throw new Error(REQUIRED_MESSAGE);
144
141
  }
145
- if (!isValidEmail(userEmail)) {
142
+ if (!isValidEmail(userEmail.trim())) {
146
143
  throw new Error(REQUIRED_ERROR_MESSAGE_INVALID_EMAIL);
147
144
  }
148
145
  const payload = {
@@ -153,11 +150,10 @@ class TryOn {
153
150
  });
154
151
  }
155
152
  deleteImage({ userEmail, fileName }) {
156
- userEmail = userEmail.trim();
157
153
  if (checkParameters(userEmail, fileName) === false) {
158
154
  throw new Error(REQUIRED_MESSAGE);
159
155
  }
160
- if (!isValidEmail(userEmail)) {
156
+ if (!isValidEmail(userEmail.trim())) {
161
157
  throw new Error(REQUIRED_ERROR_MESSAGE_INVALID_EMAIL);
162
158
  }
163
159
  const payload = {
@@ -170,7 +166,6 @@ class TryOn {
170
166
  });
171
167
  }
172
168
  handleTryOnSubmit({ userEmail, shopDomain, productName, firstImageName, secondImageName, }) {
173
- userEmail = userEmail.trim();
174
169
  if (checkParameters(shopDomain, userEmail, productName, firstImageName, secondImageName) === false) {
175
170
  throw new Error(REQUIRED_MESSAGE);
176
171
  }
package/dist/tryOn.js CHANGED
@@ -16,11 +16,10 @@ class TryOn {
16
16
  this.#stagingUrl = stagingUrl;
17
17
  }
18
18
  async uploadFile({ files, userEmail }) {
19
- userEmail = userEmail.trim();
20
19
  if ((0, utils_js_1.checkParameters)(files, userEmail) === false) {
21
20
  throw new Error(constants_js_1.REQUIRED_MESSAGE);
22
21
  }
23
- if (!(0, utils_js_1.isValidEmail)(userEmail)) {
22
+ if (!(0, utils_js_1.isValidEmail)(userEmail.trim())) {
24
23
  throw new Error(constants_js_1.REQUIRED_ERROR_MESSAGE_INVALID_EMAIL);
25
24
  }
26
25
  if (files?.length > 2) {
@@ -66,11 +65,10 @@ class TryOn {
66
65
  });
67
66
  }
68
67
  getUploadedFiles(userEmail) {
69
- userEmail = userEmail.trim();
70
68
  if ((0, utils_js_1.checkParameters)(userEmail) === false) {
71
69
  throw new Error(constants_js_1.REQUIRED_MESSAGE);
72
70
  }
73
- if (!(0, utils_js_1.isValidEmail)(userEmail)) {
71
+ if (!(0, utils_js_1.isValidEmail)(userEmail.trim())) {
74
72
  throw new Error(constants_js_1.REQUIRED_ERROR_MESSAGE_INVALID_EMAIL);
75
73
  }
76
74
  const payload = {
@@ -81,11 +79,10 @@ class TryOn {
81
79
  });
82
80
  }
83
81
  deleteImage({ userEmail, fileName }) {
84
- userEmail = userEmail.trim();
85
82
  if ((0, utils_js_1.checkParameters)(userEmail, fileName) === false) {
86
83
  throw new Error(constants_js_1.REQUIRED_MESSAGE);
87
84
  }
88
- if (!(0, utils_js_1.isValidEmail)(userEmail)) {
85
+ if (!(0, utils_js_1.isValidEmail)(userEmail.trim())) {
89
86
  throw new Error(constants_js_1.REQUIRED_ERROR_MESSAGE_INVALID_EMAIL);
90
87
  }
91
88
  const payload = {
@@ -143,7 +140,6 @@ class TryOn {
143
140
  };
144
141
  };
145
142
  handleTryOnSubmit({ userEmail, shopDomain, productName, firstImageName, secondImageName, }) {
146
- userEmail = userEmail.trim();
147
143
  if ((0, utils_js_1.checkParameters)(shopDomain, userEmail, productName, firstImageName, secondImageName) === false) {
148
144
  throw new Error(constants_js_1.REQUIRED_MESSAGE);
149
145
  }
@@ -171,11 +167,10 @@ class TryOn {
171
167
  }
172
168
  };
173
169
  getTryOnResult = ({ userEmail, shopDomain, productName }) => {
174
- userEmail = userEmail.trim();
175
170
  if ((0, utils_js_1.checkParameters)(shopDomain, userEmail, productName) === false) {
176
171
  throw new Error(constants_js_1.REQUIRED_MESSAGE);
177
172
  }
178
- if (!(0, utils_js_1.isValidEmail)(userEmail)) {
173
+ if (!(0, utils_js_1.isValidEmail)(userEmail.trim())) {
179
174
  throw new Error(constants_js_1.REQUIRED_ERROR_MESSAGE_INVALID_EMAIL);
180
175
  }
181
176
  const payload = {