drapcode-utility 1.5.3 → 1.5.4

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.
@@ -25,7 +25,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
25
25
  function verb(n) { return function (v) { return step([n, v]); }; }
26
26
  function step(op) {
27
27
  if (f) throw new TypeError("Generator is already executing.");
28
- while (_) try {
28
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
29
29
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
30
30
  if (y = 0, t) op = [op[0] & 2, t.value];
31
31
  switch (op[0]) {
@@ -74,12 +74,12 @@ var createS3Client = function (awsConfig) {
74
74
  return s3client;
75
75
  };
76
76
  exports.createS3Client = createS3Client;
77
- var fileUploadToS3 = function (files, s3Client, s3Config, publicS3Client, publicS3Config, encryption, options) {
77
+ var fileUploadToS3 = function (files, s3Client, s3Config, publicS3Client, publicS3Config, isGenerateIcons, encryption, options) {
78
78
  if (options === void 0) { options = {}; }
79
79
  return __awaiter(void 0, void 0, void 0, function () {
80
- var awsConfig, encryptionType, dataKey, accessKeyId, secretAccessKey, region, config, plainTextData, fileOptions, s3Key, _a, _b, _i, index, file, fileSlug, fileObj, fileSlug, fileObj;
81
- return __generator(this, function (_c) {
82
- switch (_c.label) {
80
+ var awsConfig, encryptionType, dataKey, accessKeyId, secretAccessKey, region, config, plainTextData, fileOptions, s3Key, _a, _b, _c, _i, index, file, fileSlug, fileObj, fileSlug, fileObj;
81
+ return __generator(this, function (_d) {
82
+ switch (_d.label) {
83
83
  case 0:
84
84
  if (!encryption) return [3 /*break*/, 2];
85
85
  awsConfig = encryption.awsConfig, encryptionType = encryption.encryptionType, dataKey = encryption.dataKey;
@@ -90,27 +90,30 @@ var fileUploadToS3 = function (files, s3Client, s3Config, publicS3Client, public
90
90
  accessKeyId: accessKeyId,
91
91
  secretAccessKey: secretAccessKey,
92
92
  };
93
- return [4 /*yield*/, encryption_2.processKMSDecryption(config, dataKey, {})];
93
+ return [4 /*yield*/, (0, encryption_2.processKMSDecryption)(config, dataKey, {})];
94
94
  case 1:
95
- plainTextData = _c.sent();
95
+ plainTextData = _d.sent();
96
96
  if (plainTextData.status === "FAILED") {
97
97
  return [2 /*return*/, plainTextData];
98
98
  }
99
99
  encryption.dataKey = plainTextData.data;
100
- _c.label = 2;
100
+ _d.label = 2;
101
101
  case 2:
102
102
  if (!Array.isArray(files)) return [3 /*break*/, 7];
103
103
  console.log("I have multiple file");
104
104
  fileOptions = [];
105
105
  s3Key = s3Config.key;
106
- _a = [];
107
- for (_b in files)
108
- _a.push(_b);
106
+ _a = files;
107
+ _b = [];
108
+ for (_c in _a)
109
+ _b.push(_c);
109
110
  _i = 0;
110
- _c.label = 3;
111
+ _d.label = 3;
111
112
  case 3:
112
- if (!(_i < _a.length)) return [3 /*break*/, 6];
113
- index = _a[_i];
113
+ if (!(_i < _b.length)) return [3 /*break*/, 6];
114
+ _c = _b[_i];
115
+ if (!(_c in _a)) return [3 /*break*/, 5];
116
+ index = _c;
114
117
  file = files[index];
115
118
  fileSlug = file.originalname
116
119
  .replace(/\.[^/.]+$/, "")
@@ -118,15 +121,15 @@ var fileUploadToS3 = function (files, s3Client, s3Config, publicS3Client, public
118
121
  .replace(/[^a-zA-Z0-9_]/g, "")
119
122
  .toLowerCase();
120
123
  if (s3Config.append) {
121
- s3Config.key = s3Key + "/" + uuid_1.v4() + "/" + fileSlug;
124
+ s3Config.key = "".concat(s3Key, "/").concat((0, uuid_1.v4)(), "/").concat(fileSlug);
122
125
  }
123
- return [4 /*yield*/, processFileUploadToS3(file, s3Client, s3Config, publicS3Client, publicS3Config, encryption, options, encryption ? true : false)];
126
+ return [4 /*yield*/, processFileUploadToS3(file, s3Client, s3Config, publicS3Client, publicS3Config, isGenerateIcons, encryption, options, encryption ? true : false)];
124
127
  case 4:
125
- fileObj = _c.sent();
128
+ fileObj = _d.sent();
126
129
  if (fileObj) {
127
130
  fileOptions.push(fileObj);
128
131
  }
129
- _c.label = 5;
132
+ _d.label = 5;
130
133
  case 5:
131
134
  _i++;
132
135
  return [3 /*break*/, 3];
@@ -139,18 +142,18 @@ var fileUploadToS3 = function (files, s3Client, s3Config, publicS3Client, public
139
142
  .replace(/[^a-zA-Z0-9_]/g, "")
140
143
  .toLowerCase();
141
144
  if (s3Config.append) {
142
- s3Config.key = s3Config.key + "/" + uuid_1.v4() + "/" + fileSlug;
145
+ s3Config.key = "".concat(s3Config.key, "/").concat((0, uuid_1.v4)(), "/").concat(fileSlug);
143
146
  }
144
- return [4 /*yield*/, processFileUploadToS3(files, s3Client, s3Config, publicS3Client, publicS3Config, encryption, options, encryption ? true : false)];
147
+ return [4 /*yield*/, processFileUploadToS3(files, s3Client, s3Config, publicS3Client, publicS3Config, isGenerateIcons, encryption, options, encryption ? true : false)];
145
148
  case 8:
146
- fileObj = _c.sent();
149
+ fileObj = _d.sent();
147
150
  return [2 /*return*/, fileObj];
148
151
  }
149
152
  });
150
153
  });
151
154
  };
152
155
  exports.fileUploadToS3 = fileUploadToS3;
153
- var processFileUploadToS3 = function (file, s3Client, s3Config, publicS3Client, publicS3Config, encryption, options, encrypt) {
156
+ var processFileUploadToS3 = function (file, s3Client, s3Config, publicS3Client, publicS3Config, isGenerateIcons, encryption, options, encrypt) {
154
157
  if (options === void 0) { options = {}; }
155
158
  if (encrypt === void 0) { encrypt = false; }
156
159
  return __awaiter(void 0, void 0, void 0, function () {
@@ -164,7 +167,7 @@ var processFileUploadToS3 = function (file, s3Client, s3Config, publicS3Client,
164
167
  params = null;
165
168
  encryptedFilePath = null;
166
169
  if (!encrypt) return [3 /*break*/, 2];
167
- return [4 /*yield*/, encryption_1.cryptFile(file.path, encryption, false)];
170
+ return [4 /*yield*/, (0, encryption_1.cryptFile)(file.path, encryption, false)];
168
171
  case 1:
169
172
  encryptedFilePath = _b.sent();
170
173
  params = __assign({ Bucket: bucket, ACL: acl, Key: key, Body: fs_1.default.createReadStream(encryptedFilePath), ContentType: contentType }, options);
@@ -177,13 +180,15 @@ var processFileUploadToS3 = function (file, s3Client, s3Config, publicS3Client,
177
180
  return [4 /*yield*/, parallelUploads3.done()];
178
181
  case 4:
179
182
  data = _b.sent();
180
- return [4 /*yield*/, handleIconUpload(file.path, contentType, publicS3Client, publicS3Config, key, options)];
183
+ return [4 /*yield*/, handleIconUpload(file, contentType, publicS3Client, publicS3Config, isGenerateIcons, key, options)];
181
184
  case 5:
182
185
  _a = _b.sent(), smallIcon = _a.smallIcon, mediumIcon = _a.mediumIcon, largeIcon = _a.largeIcon;
183
- if (encryptedFilePath) {
184
- fs_1.default.unlinkSync(encryptedFilePath);
186
+ if (data) {
187
+ if (encryptedFilePath) {
188
+ fs_1.default.unlinkSync(encryptedFilePath);
189
+ }
190
+ fs_1.default.unlinkSync(file.path);
185
191
  }
186
- fs_1.default.unlinkSync(file.path);
187
192
  originalname = file.originalname, mimetype = file.mimetype, size = file.size;
188
193
  return [2 /*return*/, {
189
194
  originalname: originalname,
@@ -204,20 +209,23 @@ var processFileUploadToS3 = function (file, s3Client, s3Config, publicS3Client,
204
209
  });
205
210
  });
206
211
  };
207
- var handleIconUpload = function (filePath, contentType, publicS3Client, publicS3Config, key, options) {
212
+ var handleIconUpload = function (file, contentType, publicS3Client, publicS3Config, isGenerateIcons, key, options) {
208
213
  if (options === void 0) { options = {}; }
209
214
  return __awaiter(void 0, void 0, void 0, function () {
210
- var iconSizes, iconLabels, iconFiles, bucket_1, acl_1, iconUploads, _a, smallKey, mediumKey, largeKey, iconError_1;
215
+ var filePath, fileSize, iconSizes, iconLabels, iconFiles, bucket_1, acl_1, iconUploads, _a, smallKey, mediumKey, largeKey, iconError_1;
211
216
  return __generator(this, function (_b) {
212
217
  switch (_b.label) {
213
218
  case 0:
219
+ filePath = file.path, fileSize = file.size;
214
220
  iconSizes = [200, 300, 500];
215
221
  iconLabels = ["small", "medium", "large"];
216
222
  _b.label = 1;
217
223
  case 1:
218
224
  _b.trys.push([1, 6, , 7]);
219
- if (!["image/png", "image/jpeg", "image/gif", "application/pdf"].includes(contentType)) return [3 /*break*/, 4];
220
- return [4 /*yield*/, generateDynamicIcons(filePath, iconSizes)];
225
+ if (!(isGenerateIcons &&
226
+ fileSize < 157286400 && //150mb
227
+ ["image/png", "image/jpeg", "image/gif", "application/pdf"].includes(contentType))) return [3 /*break*/, 4];
228
+ return [4 /*yield*/, generateDynamicIcons(filePath, iconSizes, contentType)];
221
229
  case 2:
222
230
  iconFiles = _b.sent();
223
231
  bucket_1 = publicS3Config.bucket, acl_1 = publicS3Config.acl;
@@ -227,7 +235,7 @@ var handleIconUpload = function (filePath, contentType, publicS3Client, publicS3
227
235
  switch (_a.label) {
228
236
  case 0:
229
237
  iconLabel = iconLabels[index];
230
- iconKey = key + "/icons/" + uuid_1.v4() + "_" + iconLabel + ".png";
238
+ iconKey = "".concat(key, "/icons/").concat((0, uuid_1.v4)(), "_").concat(iconLabel, ".png");
231
239
  iconParams = __assign({ Bucket: bucket_1, ACL: acl_1, Key: iconKey, Body: fs_1.default.createReadStream(iconFilePath), ContentType: "image/png" }, options);
232
240
  iconUpload = new lib_storage_1.Upload({
233
241
  client: publicS3Client,
@@ -246,13 +254,13 @@ var handleIconUpload = function (filePath, contentType, publicS3Client, publicS3
246
254
  _a = _b.sent(), smallKey = _a[0], mediumKey = _a[1], largeKey = _a[2];
247
255
  return [2 /*return*/, {
248
256
  smallIcon: smallKey
249
- ? "https://" + bucket_1 + ".s3.amazonaws.com/" + smallKey
257
+ ? "https://".concat(bucket_1, ".s3.amazonaws.com/").concat(smallKey)
250
258
  : null,
251
259
  mediumIcon: mediumKey
252
- ? "https://" + bucket_1 + ".s3.amazonaws.com/" + mediumKey
260
+ ? "https://".concat(bucket_1, ".s3.amazonaws.com/").concat(mediumKey)
253
261
  : null,
254
262
  largeIcon: largeKey
255
- ? "https://" + bucket_1 + ".s3.amazonaws.com/" + largeKey
263
+ ? "https://".concat(bucket_1, ".s3.amazonaws.com/").concat(largeKey)
256
264
  : null,
257
265
  }];
258
266
  case 4: return [2 /*return*/, generateStaticIcons(contentType)];
@@ -266,13 +274,15 @@ var handleIconUpload = function (filePath, contentType, publicS3Client, publicS3
266
274
  });
267
275
  });
268
276
  };
269
- var generateDynamicIcons = function (filePath, sizes) {
277
+ var generateDynamicIcons = function (filePath, sizes, contentType) {
270
278
  return Promise.all(sizes.map(function (size) {
271
- var outputFilePath = filePath + "_" + size + ".png";
279
+ var outputFilePath = "".concat(filePath, "_").concat(size, ".png");
272
280
  return new Promise(function (resolve, reject) {
273
- gm_1.default(filePath)
274
- .resize(size, size)
275
- .write(outputFilePath, function (err) {
281
+ var gmInstance = (0, gm_1.default)(filePath);
282
+ if (contentType === "application/pdf") {
283
+ gmInstance = gmInstance.selectFrame(0);
284
+ }
285
+ gmInstance.resize(size, size).write(outputFilePath, function (err) {
276
286
  if (err) {
277
287
  reject(err);
278
288
  }
@@ -14,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
14
14
  function verb(n) { return function (v) { return step([n, v]); }; }
15
15
  function step(op) {
16
16
  if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
18
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
19
  if (y = 0, t) op = [op[0] & 2, t.value];
20
20
  switch (op[0]) {
@@ -56,8 +56,8 @@ var generateToken = function (projectId) { return __awaiter(void 0, void 0, void
56
56
  randomIndex = Math.floor(Math.random() * characters.length);
57
57
  token += characters.charAt(randomIndex);
58
58
  }
59
- token = token + "." + timestamp;
60
- return [4 /*yield*/, drapcode_redis_1.redis_get_method(uniqueSessionId)];
59
+ token = "".concat(token, ".").concat(timestamp);
60
+ return [4 /*yield*/, (0, drapcode_redis_1.redis_get_method)(uniqueSessionId)];
61
61
  case 2:
62
62
  data = _b.sent();
63
63
  if (!data || !data[projectId] || !data[projectId].length) {
@@ -1,6 +1,6 @@
1
1
  export declare const validateString: (str: string) => false | "String should not contain special characters" | "String should not contain any number";
2
2
  export declare const camelize: (str: string) => string;
3
- export declare const clearSpaceAndReformat: (text: string, separator?: string | undefined) => string;
3
+ export declare const clearSpaceAndReformat: (text: string, separator?: string) => string;
4
4
  export declare const isEmpty: (obj: any) => boolean;
5
5
  export declare const isEmptyObject: (object: any) => boolean;
6
6
  export declare const isObject: (item: any) => any;
@@ -21,10 +21,14 @@ var __rest = (this && this.__rest) || function (s, e) {
21
21
  }
22
22
  return t;
23
23
  };
24
- var __spreadArray = (this && this.__spreadArray) || function (to, from) {
25
- for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
26
- to[j] = from[i];
27
- return to;
24
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
25
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
26
+ if (ar || !(i in from)) {
27
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
28
+ ar[i] = from[i];
29
+ }
30
+ }
31
+ return to.concat(ar || Array.prototype.slice.call(from));
28
32
  };
29
33
  var __importDefault = (this && this.__importDefault) || function (mod) {
30
34
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -77,7 +81,7 @@ var validateString = function (str) {
77
81
  };
78
82
  exports.validateString = validateString;
79
83
  var camelize = function (str) {
80
- str = exports.clearSpaceAndReformat(str);
84
+ str = (0, exports.clearSpaceAndReformat)(str);
81
85
  return str.replace(/(?:^\w|[A-Z]|\b\w)/g, function (word, index) {
82
86
  return index === 0 ? word.toLowerCase() : word.toUpperCase();
83
87
  });
@@ -204,8 +208,8 @@ var cleanCollectionAndFieldName = function (str) {
204
208
  };
205
209
  exports.cleanCollectionAndFieldName = cleanCollectionAndFieldName;
206
210
  var formatCollectionAndFieldName = function (str) {
207
- var updateString = exports.cleanCollectionAndFieldName(str);
208
- return exports.clearSpaceAndReformat(updateString.trim(), "_");
211
+ var updateString = (0, exports.cleanCollectionAndFieldName)(str);
212
+ return (0, exports.clearSpaceAndReformat)(updateString.trim(), "_");
209
213
  };
210
214
  exports.formatCollectionAndFieldName = formatCollectionAndFieldName;
211
215
  var restructureData = function (data) {
@@ -236,7 +240,7 @@ var restructureData = function (data) {
236
240
  exports.restructureData = restructureData;
237
241
  var checkAndCompareValue = function (input1, input2) {
238
242
  return Array.isArray(input2)
239
- ? exports.arraysEqual(input1, input2.map(function (key) { return key.value; }))
243
+ ? (0, exports.arraysEqual)(input1, input2.map(function (key) { return key.value; }))
240
244
  : input1 === input2.value;
241
245
  };
242
246
  exports.checkAndCompareValue = checkAndCompareValue;
@@ -246,7 +250,7 @@ var arraysEqual = function (array1, array2) {
246
250
  return false;
247
251
  for (var i = 0; i < array1.length; i++ // assert each element equal
248
252
  )
249
- if (!exports.arraysEqual(array1[i], array2[i]))
253
+ if (!(0, exports.arraysEqual)(array1[i], array2[i]))
250
254
  return false;
251
255
  return true;
252
256
  }
@@ -281,7 +285,7 @@ var formatCustomCSSClasses = function (customClasses) {
281
285
  .replace(/"([^"]+)"/g, "$1")
282
286
  .split(",")
283
287
  .join(";");
284
- projectCustomCSSClassesData += "" + (element.class.startsWith(".") ? element.class : "." + element.class) + (element.pseudoClass ? ":" + element.pseudoClass : "") + unquotedClassWithProp + " ";
288
+ projectCustomCSSClassesData += "".concat(element.class.startsWith(".") ? element.class : "." + element.class).concat(element.pseudoClass ? ":" + element.pseudoClass : "").concat(unquotedClassWithProp, " ");
285
289
  }
286
290
  });
287
291
  return projectCustomCSSClassesData;
@@ -292,18 +296,18 @@ var replaceDataValueIntoExpression = function (expression, data, user, tenant, s
292
296
  var contentList = (_a = expression
293
297
  .match(/{{(.*?)}}/g)) === null || _a === void 0 ? void 0 : _a.map(function (b) { return b.replace(/{{(.*?)}}/g, "$1"); });
294
298
  contentList === null || contentList === void 0 ? void 0 : contentList.forEach(function (prop) {
295
- var needle = "{{" + prop + "}}";
299
+ var needle = "{{".concat(prop, "}}");
296
300
  var dataOfItem = "";
297
301
  if (prop.includes("current_user")) {
298
302
  prop = prop.replace("current_user.", "");
299
303
  if (Object.keys(user).length > 0) {
300
- dataOfItem = exports.parseValueFromData(user, prop);
304
+ dataOfItem = (0, exports.parseValueFromData)(user, prop);
301
305
  }
302
306
  }
303
307
  else if (prop.includes("current_tenant")) {
304
308
  prop = prop.replace("current_tenant.", "");
305
309
  if (Object.keys(tenant).length > 0) {
306
- dataOfItem = exports.parseValueFromData(tenant, prop);
310
+ dataOfItem = (0, exports.parseValueFromData)(tenant, prop);
307
311
  }
308
312
  }
309
313
  else if (prop.includes("current_session")) {
@@ -329,7 +333,7 @@ var replaceDataValueIntoExpression = function (expression, data, user, tenant, s
329
333
  }
330
334
  else {
331
335
  if (Object.keys(data).length > 0) {
332
- dataOfItem = exports.parseValueFromData(data, prop);
336
+ dataOfItem = (0, exports.parseValueFromData)(data, prop);
333
337
  //TODO: Need better way
334
338
  delete data[prop];
335
339
  }
@@ -429,7 +433,7 @@ var replaceTransferObjectValueIntoExpression = function (expression, transferObj
429
433
  var contentList = (_a = expression
430
434
  .match(/{{(.*?)}}/g)) === null || _a === void 0 ? void 0 : _a.map(function (b) { return b.replace(/{{(.*?)}}/g, "$1"); });
431
435
  contentList === null || contentList === void 0 ? void 0 : contentList.forEach(function (prop) {
432
- var needle = "{{" + prop + "}}";
436
+ var needle = "{{".concat(prop, "}}");
433
437
  var dataOfItem = "";
434
438
  dataOfItem = transferObject[prop] ? transferObject[prop] : "";
435
439
  expression = dataOfItem
@@ -475,8 +479,8 @@ var processFieldsInlcude = function (fieldsInclude) {
475
479
  fieldsInclude = fieldsInclude.filter(function (field) { return !(field.startsWith("RF::") || field.startsWith("DF::")); });
476
480
  var refFields = processReferenceFieldInclude(refFieldsInclude);
477
481
  var derivedFields = processDerivedFieldInclude(derivedFieldsInclude);
478
- var extraField = __spreadArray(__spreadArray([], refFields), derivedFields).filter(function (value, index, array) { return array.indexOf(value) === index; });
479
- result = __spreadArray(__spreadArray([], fieldsInclude), extraField);
482
+ var extraField = __spreadArray(__spreadArray([], refFields, true), derivedFields, true).filter(function (value, index, array) { return array.indexOf(value) === index; });
483
+ result = __spreadArray(__spreadArray([], fieldsInclude, true), extraField, true);
480
484
  return result;
481
485
  };
482
486
  exports.processFieldsInlcude = processFieldsInlcude;
@@ -501,16 +505,16 @@ var processDerivedFieldInclude = function (derivedFieldsInclude) {
501
505
  if (arg.name === "expression") {
502
506
  var needleList = (_a = arg.key
503
507
  .match(/{{(.*?)}}/g)) === null || _a === void 0 ? void 0 : _a.map(function (b) { return b.replace(/{{(.*?)}}/g, "$1"); });
504
- var tempFields = exports.processFieldsInlcude(needleList);
505
- fields = __spreadArray(__spreadArray([], fields), tempFields);
508
+ var tempFields = (0, exports.processFieldsInlcude)(needleList);
509
+ fields = __spreadArray(__spreadArray([], fields, true), tempFields, true);
506
510
  }
507
511
  else if (!derivedFieldExcludes.includes(arg.name)) {
508
512
  var tempFields = Array.isArray(arg.key) ? arg.key : [arg.key];
509
- tempFields = exports.processFieldsInlcude(tempFields);
510
- fields = __spreadArray(__spreadArray([], fields), tempFields);
513
+ tempFields = (0, exports.processFieldsInlcude)(tempFields);
514
+ fields = __spreadArray(__spreadArray([], fields, true), tempFields, true);
511
515
  }
512
516
  });
513
- derivedFields = __spreadArray(__spreadArray([], derivedFields), fields);
517
+ derivedFields = __spreadArray(__spreadArray([], derivedFields, true), fields, true);
514
518
  });
515
519
  return derivedFields;
516
520
  };
@@ -586,7 +590,7 @@ var assignFieldValue = function (formattedField, field, fieldName, filledItemdat
586
590
  value = formattedField.extraFieldSetting
587
591
  ? formattedField.extraFieldSetting.defaultValue
588
592
  : filledItemdata[fieldName];
589
- value = format_fields_1.getFormatFieldData(value, field.type);
593
+ value = (0, format_fields_1.getFormatFieldData)(value, field.type);
590
594
  return value;
591
595
  };
592
596
  var validateData = function (fields, data) {
@@ -607,7 +611,7 @@ var validateData = function (fields, data) {
607
611
  fieldValue = JSON.parse(fieldValue);
608
612
  }
609
613
  catch (error) {
610
- errors.push("Error parsing " + fieldTitle + ": " + error.message);
614
+ errors.push("Error parsing ".concat(fieldTitle, ": ").concat(error.message));
611
615
  return;
612
616
  }
613
617
  }
@@ -616,50 +620,50 @@ var validateData = function (fields, data) {
616
620
  if (typeof fieldValue !== "string" &&
617
621
  typeof fieldValue !== "number" &&
618
622
  Object.prototype.toString.call(fieldValue) !== "[object Date]") {
619
- errors.push(fieldTitle + " must be a string");
623
+ errors.push("".concat(fieldTitle, " must be a string"));
620
624
  }
621
625
  break;
622
626
  case "large_text":
623
627
  case "color":
624
628
  if (typeof fieldValue !== "string") {
625
- errors.push(fieldTitle + " must be a string");
629
+ errors.push("".concat(fieldTitle, " must be a string"));
626
630
  }
627
631
  break;
628
632
  case "uuid":
629
- if (typeof fieldValue !== "string" || !uuid_1.validate(fieldValue)) {
630
- errors.push(fieldTitle + " must be a valid UUID string");
633
+ if (typeof fieldValue !== "string" || !(0, uuid_1.validate)(fieldValue)) {
634
+ errors.push("".concat(fieldTitle, " must be a valid UUID string"));
631
635
  }
632
636
  break;
633
637
  case "reference":
634
638
  case "belongsTo":
635
639
  if (!Array.isArray(fieldValue) ||
636
640
  fieldValue.some(function (item) { return typeof item !== "string"; })) {
637
- errors.push(fieldTitle + " must be an array of valid UUID strings");
641
+ errors.push("".concat(fieldTitle, " must be an array of valid UUID strings"));
638
642
  }
639
643
  break;
640
644
  case "createdAt":
641
645
  case "updatedAt":
642
646
  case "date":
643
647
  if (fieldValue && isNaN(Date.parse(fieldValue))) {
644
- errors.push(fieldTitle + " must be a valid date");
648
+ errors.push("".concat(fieldTitle, " must be a valid date"));
645
649
  }
646
650
  break;
647
651
  case "boolean":
648
652
  if (typeof fieldValue !== "boolean") {
649
- errors.push(fieldTitle + " must be a boolean");
653
+ errors.push("".concat(fieldTitle, " must be a boolean"));
650
654
  }
651
655
  break;
652
656
  case "email":
653
657
  if (typeof fieldValue !== "string" ||
654
658
  !/\S+@\S+\.\S+/.test(fieldValue)) {
655
- errors.push(fieldTitle + " must be a valid email address");
659
+ errors.push("".concat(fieldTitle, " must be a valid email address"));
656
660
  break;
657
661
  }
658
662
  break;
659
663
  case "tel":
660
664
  var telPattern = /^\+?(\d{1,3})?[-\s]?(\(\d{1,4}\)|\d{1,4})[-\s]?(\d{1,4}[-\s]?\d{1,4}|\d{7,10})$/;
661
665
  if (typeof fieldValue !== "string" || !telPattern.test(fieldValue)) {
662
- errors.push(fieldTitle + " must be a valid phone number");
666
+ errors.push("".concat(fieldTitle, " must be a valid phone number"));
663
667
  }
664
668
  break;
665
669
  case "static_option":
@@ -669,16 +673,16 @@ var validateData = function (fields, data) {
669
673
  }
670
674
  else if (Array.isArray(fieldValue)) {
671
675
  if (fieldValue.some(function (item) { return typeof item !== "string"; })) {
672
- errors.push(fieldTitle + " must be an array of strings");
676
+ errors.push("".concat(fieldTitle, " must be an array of strings"));
673
677
  }
674
678
  }
675
679
  else {
676
- errors.push(fieldTitle + " must be a string or an array of strings");
680
+ errors.push("".concat(fieldTitle, " must be a string or an array of strings"));
677
681
  }
678
682
  break;
679
683
  case "url":
680
- if (typeof fieldValue !== "string" || !exports.validateUrl(fieldValue)) {
681
- errors.push(fieldTitle + " must be a valid URL");
684
+ if (typeof fieldValue !== "string" || !(0, exports.validateUrl)(fieldValue)) {
685
+ errors.push("".concat(fieldTitle, " must be a valid URL"));
682
686
  }
683
687
  break;
684
688
  case "file":
@@ -688,18 +692,18 @@ var validateData = function (fields, data) {
688
692
  !item.key ||
689
693
  typeof item.key !== "string";
690
694
  })) {
691
- errors.push(fieldTitle + " must be an array of objects with 'key' property as string");
695
+ errors.push("".concat(fieldTitle, " must be an array of objects with 'key' property as string"));
692
696
  }
693
697
  }
694
698
  else if (typeof fieldValue !== "object" ||
695
699
  !fieldValue.key ||
696
700
  typeof fieldValue.key !== "string") {
697
- errors.push(fieldTitle + " must be an object with 'key' property as string");
701
+ errors.push("".concat(fieldTitle, " must be an object with 'key' property as string"));
698
702
  }
699
703
  break;
700
704
  case "number":
701
705
  if (isNaN(Number(fieldValue))) {
702
- errors.push(fieldTitle + " must be a valid number.");
706
+ errors.push("".concat(fieldTitle, " must be a valid number."));
703
707
  }
704
708
  break;
705
709
  default:
@@ -38,10 +38,10 @@ var nextGeneratedString = function (str, prepend, minLength, append, algorithm)
38
38
  finalValue = voca_1.default.padLeft(finalValue, minLength, "0");
39
39
  }
40
40
  if (prepend) {
41
- finalValue = "" + prepend + finalValue;
41
+ finalValue = "".concat(prepend).concat(finalValue);
42
42
  }
43
43
  if (append) {
44
- finalValue = "" + finalValue + append;
44
+ finalValue = "".concat(finalValue).concat(append);
45
45
  }
46
46
  return finalValue;
47
47
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drapcode-utility",
3
- "version": "1.5.3",
3
+ "version": "1.5.4",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",