drapcode-utility 1.5.2 → 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.
@@ -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.2",
3
+ "version": "1.5.4",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -31,12 +31,14 @@
31
31
  "@aws-sdk/lib-storage": "^3.499.0",
32
32
  "@types/cookie-session": "^2.0.41",
33
33
  "@types/express": "^4.17.7",
34
+ "@types/gm": "^1.25.4",
34
35
  "@types/voca": "^1.4.2",
35
36
  "axios": "^1.1.2",
36
37
  "drapcode-constant": "^1.4.5",
37
38
  "drapcode-logger": "^1.1.6",
38
39
  "drapcode-redis": "^1.0.5",
39
40
  "express": "^4.17.1",
41
+ "gm": "^1.25.0",
40
42
  "lodash": "^4.17.21",
41
43
  "mime-types": "^2.1.35",
42
44
  "moment": "^2.29.0",