drapcode-utility 1.5.4 → 1.5.6

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 (g && (g = 0, op[0] && (_ = 0)), _) try {
28
+ while (_) 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]) {
@@ -77,9 +77,9 @@ exports.createS3Client = createS3Client;
77
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, _c, _i, index, file, fileSlug, fileObj, fileSlug, fileObj;
81
- return __generator(this, function (_d) {
82
- switch (_d.label) {
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) {
83
83
  case 0:
84
84
  if (!encryption) return [3 /*break*/, 2];
85
85
  awsConfig = encryption.awsConfig, encryptionType = encryption.encryptionType, dataKey = encryption.dataKey;
@@ -90,30 +90,27 @@ var fileUploadToS3 = function (files, s3Client, s3Config, publicS3Client, public
90
90
  accessKeyId: accessKeyId,
91
91
  secretAccessKey: secretAccessKey,
92
92
  };
93
- return [4 /*yield*/, (0, encryption_2.processKMSDecryption)(config, dataKey, {})];
93
+ return [4 /*yield*/, encryption_2.processKMSDecryption(config, dataKey, {})];
94
94
  case 1:
95
- plainTextData = _d.sent();
95
+ plainTextData = _c.sent();
96
96
  if (plainTextData.status === "FAILED") {
97
97
  return [2 /*return*/, plainTextData];
98
98
  }
99
99
  encryption.dataKey = plainTextData.data;
100
- _d.label = 2;
100
+ _c.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 = files;
107
- _b = [];
108
- for (_c in _a)
109
- _b.push(_c);
106
+ _a = [];
107
+ for (_b in files)
108
+ _a.push(_b);
110
109
  _i = 0;
111
- _d.label = 3;
110
+ _c.label = 3;
112
111
  case 3:
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;
112
+ if (!(_i < _a.length)) return [3 /*break*/, 6];
113
+ index = _a[_i];
117
114
  file = files[index];
118
115
  fileSlug = file.originalname
119
116
  .replace(/\.[^/.]+$/, "")
@@ -121,15 +118,15 @@ var fileUploadToS3 = function (files, s3Client, s3Config, publicS3Client, public
121
118
  .replace(/[^a-zA-Z0-9_]/g, "")
122
119
  .toLowerCase();
123
120
  if (s3Config.append) {
124
- s3Config.key = "".concat(s3Key, "/").concat((0, uuid_1.v4)(), "/").concat(fileSlug);
121
+ s3Config.key = s3Key + "/" + uuid_1.v4() + "/" + fileSlug;
125
122
  }
126
123
  return [4 /*yield*/, processFileUploadToS3(file, s3Client, s3Config, publicS3Client, publicS3Config, isGenerateIcons, encryption, options, encryption ? true : false)];
127
124
  case 4:
128
- fileObj = _d.sent();
125
+ fileObj = _c.sent();
129
126
  if (fileObj) {
130
127
  fileOptions.push(fileObj);
131
128
  }
132
- _d.label = 5;
129
+ _c.label = 5;
133
130
  case 5:
134
131
  _i++;
135
132
  return [3 /*break*/, 3];
@@ -142,11 +139,11 @@ var fileUploadToS3 = function (files, s3Client, s3Config, publicS3Client, public
142
139
  .replace(/[^a-zA-Z0-9_]/g, "")
143
140
  .toLowerCase();
144
141
  if (s3Config.append) {
145
- s3Config.key = "".concat(s3Config.key, "/").concat((0, uuid_1.v4)(), "/").concat(fileSlug);
142
+ s3Config.key = s3Config.key + "/" + uuid_1.v4() + "/" + fileSlug;
146
143
  }
147
144
  return [4 /*yield*/, processFileUploadToS3(files, s3Client, s3Config, publicS3Client, publicS3Config, isGenerateIcons, encryption, options, encryption ? true : false)];
148
145
  case 8:
149
- fileObj = _d.sent();
146
+ fileObj = _c.sent();
150
147
  return [2 /*return*/, fileObj];
151
148
  }
152
149
  });
@@ -167,7 +164,7 @@ var processFileUploadToS3 = function (file, s3Client, s3Config, publicS3Client,
167
164
  params = null;
168
165
  encryptedFilePath = null;
169
166
  if (!encrypt) return [3 /*break*/, 2];
170
- return [4 /*yield*/, (0, encryption_1.cryptFile)(file.path, encryption, false)];
167
+ return [4 /*yield*/, encryption_1.cryptFile(file.path, encryption, false)];
171
168
  case 1:
172
169
  encryptedFilePath = _b.sent();
173
170
  params = __assign({ Bucket: bucket, ACL: acl, Key: key, Body: fs_1.default.createReadStream(encryptedFilePath), ContentType: contentType }, options);
@@ -235,7 +232,7 @@ var handleIconUpload = function (file, contentType, publicS3Client, publicS3Conf
235
232
  switch (_a.label) {
236
233
  case 0:
237
234
  iconLabel = iconLabels[index];
238
- iconKey = "".concat(key, "/icons/").concat((0, uuid_1.v4)(), "_").concat(iconLabel, ".png");
235
+ iconKey = key + "/icons/" + uuid_1.v4() + "_" + iconLabel + ".png";
239
236
  iconParams = __assign({ Bucket: bucket_1, ACL: acl_1, Key: iconKey, Body: fs_1.default.createReadStream(iconFilePath), ContentType: "image/png" }, options);
240
237
  iconUpload = new lib_storage_1.Upload({
241
238
  client: publicS3Client,
@@ -254,13 +251,13 @@ var handleIconUpload = function (file, contentType, publicS3Client, publicS3Conf
254
251
  _a = _b.sent(), smallKey = _a[0], mediumKey = _a[1], largeKey = _a[2];
255
252
  return [2 /*return*/, {
256
253
  smallIcon: smallKey
257
- ? "https://".concat(bucket_1, ".s3.amazonaws.com/").concat(smallKey)
254
+ ? "https://" + bucket_1 + ".s3.amazonaws.com/" + smallKey
258
255
  : null,
259
256
  mediumIcon: mediumKey
260
- ? "https://".concat(bucket_1, ".s3.amazonaws.com/").concat(mediumKey)
257
+ ? "https://" + bucket_1 + ".s3.amazonaws.com/" + mediumKey
261
258
  : null,
262
259
  largeIcon: largeKey
263
- ? "https://".concat(bucket_1, ".s3.amazonaws.com/").concat(largeKey)
260
+ ? "https://" + bucket_1 + ".s3.amazonaws.com/" + largeKey
264
261
  : null,
265
262
  }];
266
263
  case 4: return [2 /*return*/, generateStaticIcons(contentType)];
@@ -276,9 +273,9 @@ var handleIconUpload = function (file, contentType, publicS3Client, publicS3Conf
276
273
  };
277
274
  var generateDynamicIcons = function (filePath, sizes, contentType) {
278
275
  return Promise.all(sizes.map(function (size) {
279
- var outputFilePath = "".concat(filePath, "_").concat(size, ".png");
276
+ var outputFilePath = filePath + "_" + size + ".png";
280
277
  return new Promise(function (resolve, reject) {
281
- var gmInstance = (0, gm_1.default)(filePath);
278
+ var gmInstance = gm_1.default(filePath);
282
279
  if (contentType === "application/pdf") {
283
280
  gmInstance = gmInstance.selectFrame(0);
284
281
  }
@@ -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 (g && (g = 0, op[0] && (_ = 0)), _) try {
17
+ while (_) 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 = "".concat(token, ".").concat(timestamp);
60
- return [4 /*yield*/, (0, drapcode_redis_1.redis_get_method)(uniqueSessionId)];
59
+ token = token + "." + timestamp;
60
+ return [4 /*yield*/, 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) => string;
3
+ export declare const clearSpaceAndReformat: (text: string, separator?: string | undefined) => 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;
@@ -20,7 +20,7 @@ export declare const arraysEqual: (array1: any, array2: any) => boolean;
20
20
  export declare const convertItemToArray: (itemValue: any) => any[];
21
21
  export declare const validateAlphanumericString: (str: string) => false | "String should contain only numbers and letters";
22
22
  export declare const formatCustomCSSClasses: (customClasses: any) => string;
23
- export declare const replaceDataValueIntoExpression: (expression: string, data: any, user: any, tenant: any, sessionValue: any, envConstants: any, sessionFormValue: any) => string;
23
+ export declare const replaceDataValueIntoExpression: (expression: string, data: any, user: any, tenant: any, sessionValue: any, envConstants: any, sessionFormValue: any, localStorageValue: any, cookiesValue: any) => string;
24
24
  export declare const parseJsonString: (str: string) => any;
25
25
  export declare const parseValueFromData: (data: any, fieldName: string) => any;
26
26
  export declare const unflattenObject: (obj: any) => {};
@@ -21,14 +21,10 @@ 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, 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));
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;
32
28
  };
33
29
  var __importDefault = (this && this.__importDefault) || function (mod) {
34
30
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -81,7 +77,7 @@ var validateString = function (str) {
81
77
  };
82
78
  exports.validateString = validateString;
83
79
  var camelize = function (str) {
84
- str = (0, exports.clearSpaceAndReformat)(str);
80
+ str = exports.clearSpaceAndReformat(str);
85
81
  return str.replace(/(?:^\w|[A-Z]|\b\w)/g, function (word, index) {
86
82
  return index === 0 ? word.toLowerCase() : word.toUpperCase();
87
83
  });
@@ -208,8 +204,8 @@ var cleanCollectionAndFieldName = function (str) {
208
204
  };
209
205
  exports.cleanCollectionAndFieldName = cleanCollectionAndFieldName;
210
206
  var formatCollectionAndFieldName = function (str) {
211
- var updateString = (0, exports.cleanCollectionAndFieldName)(str);
212
- return (0, exports.clearSpaceAndReformat)(updateString.trim(), "_");
207
+ var updateString = exports.cleanCollectionAndFieldName(str);
208
+ return exports.clearSpaceAndReformat(updateString.trim(), "_");
213
209
  };
214
210
  exports.formatCollectionAndFieldName = formatCollectionAndFieldName;
215
211
  var restructureData = function (data) {
@@ -240,7 +236,7 @@ var restructureData = function (data) {
240
236
  exports.restructureData = restructureData;
241
237
  var checkAndCompareValue = function (input1, input2) {
242
238
  return Array.isArray(input2)
243
- ? (0, exports.arraysEqual)(input1, input2.map(function (key) { return key.value; }))
239
+ ? exports.arraysEqual(input1, input2.map(function (key) { return key.value; }))
244
240
  : input1 === input2.value;
245
241
  };
246
242
  exports.checkAndCompareValue = checkAndCompareValue;
@@ -250,7 +246,7 @@ var arraysEqual = function (array1, array2) {
250
246
  return false;
251
247
  for (var i = 0; i < array1.length; i++ // assert each element equal
252
248
  )
253
- if (!(0, exports.arraysEqual)(array1[i], array2[i]))
249
+ if (!exports.arraysEqual(array1[i], array2[i]))
254
250
  return false;
255
251
  return true;
256
252
  }
@@ -285,29 +281,29 @@ var formatCustomCSSClasses = function (customClasses) {
285
281
  .replace(/"([^"]+)"/g, "$1")
286
282
  .split(",")
287
283
  .join(";");
288
- projectCustomCSSClassesData += "".concat(element.class.startsWith(".") ? element.class : "." + element.class).concat(element.pseudoClass ? ":" + element.pseudoClass : "").concat(unquotedClassWithProp, " ");
284
+ projectCustomCSSClassesData += "" + (element.class.startsWith(".") ? element.class : "." + element.class) + (element.pseudoClass ? ":" + element.pseudoClass : "") + unquotedClassWithProp + " ";
289
285
  }
290
286
  });
291
287
  return projectCustomCSSClassesData;
292
288
  };
293
289
  exports.formatCustomCSSClasses = formatCustomCSSClasses;
294
- var replaceDataValueIntoExpression = function (expression, data, user, tenant, sessionValue, envConstants, sessionFormValue) {
290
+ var replaceDataValueIntoExpression = function (expression, data, user, tenant, sessionValue, envConstants, sessionFormValue, localStorageValue, cookiesValue) {
295
291
  var _a;
296
292
  var contentList = (_a = expression
297
293
  .match(/{{(.*?)}}/g)) === null || _a === void 0 ? void 0 : _a.map(function (b) { return b.replace(/{{(.*?)}}/g, "$1"); });
298
294
  contentList === null || contentList === void 0 ? void 0 : contentList.forEach(function (prop) {
299
- var needle = "{{".concat(prop, "}}");
295
+ var needle = "{{" + prop + "}}";
300
296
  var dataOfItem = "";
301
297
  if (prop.includes("current_user")) {
302
298
  prop = prop.replace("current_user.", "");
303
299
  if (Object.keys(user).length > 0) {
304
- dataOfItem = (0, exports.parseValueFromData)(user, prop);
300
+ dataOfItem = exports.parseValueFromData(user, prop);
305
301
  }
306
302
  }
307
303
  else if (prop.includes("current_tenant")) {
308
304
  prop = prop.replace("current_tenant.", "");
309
305
  if (Object.keys(tenant).length > 0) {
310
- dataOfItem = (0, exports.parseValueFromData)(tenant, prop);
306
+ dataOfItem = exports.parseValueFromData(tenant, prop);
311
307
  }
312
308
  }
313
309
  else if (prop.includes("current_session")) {
@@ -324,6 +320,27 @@ var replaceDataValueIntoExpression = function (expression, data, user, tenant, s
324
320
  dataOfItem = lodash_1.default.get(sessionFormValue, prop);
325
321
  }
326
322
  }
323
+ else if (prop.includes("SESSION_STORAGE")) {
324
+ prop = prop.replace("SESSION_STORAGE.", "");
325
+ if (Object.keys(sessionValue).length > 0) {
326
+ //Session will contain multi level data
327
+ dataOfItem = lodash_1.default.get(sessionValue, prop);
328
+ }
329
+ }
330
+ else if (prop.includes("LOCAL_STORAGE")) {
331
+ prop = prop.replace("LOCAL_STORAGE.", "");
332
+ if (Object.keys(localStorageValue).length > 0) {
333
+ //Session will contain multi level data
334
+ dataOfItem = lodash_1.default.get(localStorageValue, prop);
335
+ }
336
+ }
337
+ else if (prop.includes("COOKIES")) {
338
+ prop = prop.replace("COOKIES.", "");
339
+ if (Object.keys(cookiesValue).length > 0) {
340
+ //Session will contain multi level data
341
+ dataOfItem = lodash_1.default.get(cookiesValue, prop);
342
+ }
343
+ }
327
344
  else if (prop.includes("environment_variable")) {
328
345
  prop = prop.replace("environment_variable.", "");
329
346
  if (Object.keys(envConstants).length > 0) {
@@ -333,7 +350,7 @@ var replaceDataValueIntoExpression = function (expression, data, user, tenant, s
333
350
  }
334
351
  else {
335
352
  if (Object.keys(data).length > 0) {
336
- dataOfItem = (0, exports.parseValueFromData)(data, prop);
353
+ dataOfItem = exports.parseValueFromData(data, prop);
337
354
  //TODO: Need better way
338
355
  delete data[prop];
339
356
  }
@@ -433,7 +450,7 @@ var replaceTransferObjectValueIntoExpression = function (expression, transferObj
433
450
  var contentList = (_a = expression
434
451
  .match(/{{(.*?)}}/g)) === null || _a === void 0 ? void 0 : _a.map(function (b) { return b.replace(/{{(.*?)}}/g, "$1"); });
435
452
  contentList === null || contentList === void 0 ? void 0 : contentList.forEach(function (prop) {
436
- var needle = "{{".concat(prop, "}}");
453
+ var needle = "{{" + prop + "}}";
437
454
  var dataOfItem = "";
438
455
  dataOfItem = transferObject[prop] ? transferObject[prop] : "";
439
456
  expression = dataOfItem
@@ -479,8 +496,8 @@ var processFieldsInlcude = function (fieldsInclude) {
479
496
  fieldsInclude = fieldsInclude.filter(function (field) { return !(field.startsWith("RF::") || field.startsWith("DF::")); });
480
497
  var refFields = processReferenceFieldInclude(refFieldsInclude);
481
498
  var derivedFields = processDerivedFieldInclude(derivedFieldsInclude);
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);
499
+ var extraField = __spreadArray(__spreadArray([], refFields), derivedFields).filter(function (value, index, array) { return array.indexOf(value) === index; });
500
+ result = __spreadArray(__spreadArray([], fieldsInclude), extraField);
484
501
  return result;
485
502
  };
486
503
  exports.processFieldsInlcude = processFieldsInlcude;
@@ -505,16 +522,16 @@ var processDerivedFieldInclude = function (derivedFieldsInclude) {
505
522
  if (arg.name === "expression") {
506
523
  var needleList = (_a = arg.key
507
524
  .match(/{{(.*?)}}/g)) === null || _a === void 0 ? void 0 : _a.map(function (b) { return b.replace(/{{(.*?)}}/g, "$1"); });
508
- var tempFields = (0, exports.processFieldsInlcude)(needleList);
509
- fields = __spreadArray(__spreadArray([], fields, true), tempFields, true);
525
+ var tempFields = exports.processFieldsInlcude(needleList);
526
+ fields = __spreadArray(__spreadArray([], fields), tempFields);
510
527
  }
511
528
  else if (!derivedFieldExcludes.includes(arg.name)) {
512
529
  var tempFields = Array.isArray(arg.key) ? arg.key : [arg.key];
513
- tempFields = (0, exports.processFieldsInlcude)(tempFields);
514
- fields = __spreadArray(__spreadArray([], fields, true), tempFields, true);
530
+ tempFields = exports.processFieldsInlcude(tempFields);
531
+ fields = __spreadArray(__spreadArray([], fields), tempFields);
515
532
  }
516
533
  });
517
- derivedFields = __spreadArray(__spreadArray([], derivedFields, true), fields, true);
534
+ derivedFields = __spreadArray(__spreadArray([], derivedFields), fields);
518
535
  });
519
536
  return derivedFields;
520
537
  };
@@ -590,7 +607,7 @@ var assignFieldValue = function (formattedField, field, fieldName, filledItemdat
590
607
  value = formattedField.extraFieldSetting
591
608
  ? formattedField.extraFieldSetting.defaultValue
592
609
  : filledItemdata[fieldName];
593
- value = (0, format_fields_1.getFormatFieldData)(value, field.type);
610
+ value = format_fields_1.getFormatFieldData(value, field.type);
594
611
  return value;
595
612
  };
596
613
  var validateData = function (fields, data) {
@@ -611,7 +628,7 @@ var validateData = function (fields, data) {
611
628
  fieldValue = JSON.parse(fieldValue);
612
629
  }
613
630
  catch (error) {
614
- errors.push("Error parsing ".concat(fieldTitle, ": ").concat(error.message));
631
+ errors.push("Error parsing " + fieldTitle + ": " + error.message);
615
632
  return;
616
633
  }
617
634
  }
@@ -620,50 +637,50 @@ var validateData = function (fields, data) {
620
637
  if (typeof fieldValue !== "string" &&
621
638
  typeof fieldValue !== "number" &&
622
639
  Object.prototype.toString.call(fieldValue) !== "[object Date]") {
623
- errors.push("".concat(fieldTitle, " must be a string"));
640
+ errors.push(fieldTitle + " must be a string");
624
641
  }
625
642
  break;
626
643
  case "large_text":
627
644
  case "color":
628
645
  if (typeof fieldValue !== "string") {
629
- errors.push("".concat(fieldTitle, " must be a string"));
646
+ errors.push(fieldTitle + " must be a string");
630
647
  }
631
648
  break;
632
649
  case "uuid":
633
- if (typeof fieldValue !== "string" || !(0, uuid_1.validate)(fieldValue)) {
634
- errors.push("".concat(fieldTitle, " must be a valid UUID string"));
650
+ if (typeof fieldValue !== "string" || !uuid_1.validate(fieldValue)) {
651
+ errors.push(fieldTitle + " must be a valid UUID string");
635
652
  }
636
653
  break;
637
654
  case "reference":
638
655
  case "belongsTo":
639
656
  if (!Array.isArray(fieldValue) ||
640
657
  fieldValue.some(function (item) { return typeof item !== "string"; })) {
641
- errors.push("".concat(fieldTitle, " must be an array of valid UUID strings"));
658
+ errors.push(fieldTitle + " must be an array of valid UUID strings");
642
659
  }
643
660
  break;
644
661
  case "createdAt":
645
662
  case "updatedAt":
646
663
  case "date":
647
664
  if (fieldValue && isNaN(Date.parse(fieldValue))) {
648
- errors.push("".concat(fieldTitle, " must be a valid date"));
665
+ errors.push(fieldTitle + " must be a valid date");
649
666
  }
650
667
  break;
651
668
  case "boolean":
652
669
  if (typeof fieldValue !== "boolean") {
653
- errors.push("".concat(fieldTitle, " must be a boolean"));
670
+ errors.push(fieldTitle + " must be a boolean");
654
671
  }
655
672
  break;
656
673
  case "email":
657
674
  if (typeof fieldValue !== "string" ||
658
675
  !/\S+@\S+\.\S+/.test(fieldValue)) {
659
- errors.push("".concat(fieldTitle, " must be a valid email address"));
676
+ errors.push(fieldTitle + " must be a valid email address");
660
677
  break;
661
678
  }
662
679
  break;
663
680
  case "tel":
664
681
  var telPattern = /^\+?(\d{1,3})?[-\s]?(\(\d{1,4}\)|\d{1,4})[-\s]?(\d{1,4}[-\s]?\d{1,4}|\d{7,10})$/;
665
682
  if (typeof fieldValue !== "string" || !telPattern.test(fieldValue)) {
666
- errors.push("".concat(fieldTitle, " must be a valid phone number"));
683
+ errors.push(fieldTitle + " must be a valid phone number");
667
684
  }
668
685
  break;
669
686
  case "static_option":
@@ -673,16 +690,16 @@ var validateData = function (fields, data) {
673
690
  }
674
691
  else if (Array.isArray(fieldValue)) {
675
692
  if (fieldValue.some(function (item) { return typeof item !== "string"; })) {
676
- errors.push("".concat(fieldTitle, " must be an array of strings"));
693
+ errors.push(fieldTitle + " must be an array of strings");
677
694
  }
678
695
  }
679
696
  else {
680
- errors.push("".concat(fieldTitle, " must be a string or an array of strings"));
697
+ errors.push(fieldTitle + " must be a string or an array of strings");
681
698
  }
682
699
  break;
683
700
  case "url":
684
- if (typeof fieldValue !== "string" || !(0, exports.validateUrl)(fieldValue)) {
685
- errors.push("".concat(fieldTitle, " must be a valid URL"));
701
+ if (typeof fieldValue !== "string" || !exports.validateUrl(fieldValue)) {
702
+ errors.push(fieldTitle + " must be a valid URL");
686
703
  }
687
704
  break;
688
705
  case "file":
@@ -692,18 +709,18 @@ var validateData = function (fields, data) {
692
709
  !item.key ||
693
710
  typeof item.key !== "string";
694
711
  })) {
695
- errors.push("".concat(fieldTitle, " must be an array of objects with 'key' property as string"));
712
+ errors.push(fieldTitle + " must be an array of objects with 'key' property as string");
696
713
  }
697
714
  }
698
715
  else if (typeof fieldValue !== "object" ||
699
716
  !fieldValue.key ||
700
717
  typeof fieldValue.key !== "string") {
701
- errors.push("".concat(fieldTitle, " must be an object with 'key' property as string"));
718
+ errors.push(fieldTitle + " must be an object with 'key' property as string");
702
719
  }
703
720
  break;
704
721
  case "number":
705
722
  if (isNaN(Number(fieldValue))) {
706
- errors.push("".concat(fieldTitle, " must be a valid number."));
723
+ errors.push(fieldTitle + " must be a valid number.");
707
724
  }
708
725
  break;
709
726
  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 = "".concat(prepend).concat(finalValue);
41
+ finalValue = "" + prepend + finalValue;
42
42
  }
43
43
  if (append) {
44
- finalValue = "".concat(finalValue).concat(append);
44
+ finalValue = "" + finalValue + 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.4",
3
+ "version": "1.5.6",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -34,8 +34,8 @@
34
34
  "@types/gm": "^1.25.4",
35
35
  "@types/voca": "^1.4.2",
36
36
  "axios": "^1.1.2",
37
- "drapcode-constant": "^1.4.5",
38
- "drapcode-logger": "^1.1.6",
37
+ "drapcode-constant": "^1.4.8",
38
+ "drapcode-logger": "^1.1.8",
39
39
  "drapcode-redis": "^1.0.5",
40
40
  "express": "^4.17.1",
41
41
  "gm": "^1.25.0",