drapcode-utility 1.5.6 → 1.5.7

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")) {
@@ -350,7 +354,7 @@ var replaceDataValueIntoExpression = function (expression, data, user, tenant, s
350
354
  }
351
355
  else {
352
356
  if (Object.keys(data).length > 0) {
353
- dataOfItem = exports.parseValueFromData(data, prop);
357
+ dataOfItem = (0, exports.parseValueFromData)(data, prop);
354
358
  //TODO: Need better way
355
359
  delete data[prop];
356
360
  }
@@ -450,7 +454,7 @@ var replaceTransferObjectValueIntoExpression = function (expression, transferObj
450
454
  var contentList = (_a = expression
451
455
  .match(/{{(.*?)}}/g)) === null || _a === void 0 ? void 0 : _a.map(function (b) { return b.replace(/{{(.*?)}}/g, "$1"); });
452
456
  contentList === null || contentList === void 0 ? void 0 : contentList.forEach(function (prop) {
453
- var needle = "{{" + prop + "}}";
457
+ var needle = "{{".concat(prop, "}}");
454
458
  var dataOfItem = "";
455
459
  dataOfItem = transferObject[prop] ? transferObject[prop] : "";
456
460
  expression = dataOfItem
@@ -496,8 +500,8 @@ var processFieldsInlcude = function (fieldsInclude) {
496
500
  fieldsInclude = fieldsInclude.filter(function (field) { return !(field.startsWith("RF::") || field.startsWith("DF::")); });
497
501
  var refFields = processReferenceFieldInclude(refFieldsInclude);
498
502
  var derivedFields = processDerivedFieldInclude(derivedFieldsInclude);
499
- var extraField = __spreadArray(__spreadArray([], refFields), derivedFields).filter(function (value, index, array) { return array.indexOf(value) === index; });
500
- result = __spreadArray(__spreadArray([], fieldsInclude), extraField);
503
+ var extraField = __spreadArray(__spreadArray([], refFields, true), derivedFields, true).filter(function (value, index, array) { return array.indexOf(value) === index; });
504
+ result = __spreadArray(__spreadArray([], fieldsInclude, true), extraField, true);
501
505
  return result;
502
506
  };
503
507
  exports.processFieldsInlcude = processFieldsInlcude;
@@ -522,16 +526,16 @@ var processDerivedFieldInclude = function (derivedFieldsInclude) {
522
526
  if (arg.name === "expression") {
523
527
  var needleList = (_a = arg.key
524
528
  .match(/{{(.*?)}}/g)) === null || _a === void 0 ? void 0 : _a.map(function (b) { return b.replace(/{{(.*?)}}/g, "$1"); });
525
- var tempFields = exports.processFieldsInlcude(needleList);
526
- fields = __spreadArray(__spreadArray([], fields), tempFields);
529
+ var tempFields = (0, exports.processFieldsInlcude)(needleList);
530
+ fields = __spreadArray(__spreadArray([], fields, true), tempFields, true);
527
531
  }
528
532
  else if (!derivedFieldExcludes.includes(arg.name)) {
529
533
  var tempFields = Array.isArray(arg.key) ? arg.key : [arg.key];
530
- tempFields = exports.processFieldsInlcude(tempFields);
531
- fields = __spreadArray(__spreadArray([], fields), tempFields);
534
+ tempFields = (0, exports.processFieldsInlcude)(tempFields);
535
+ fields = __spreadArray(__spreadArray([], fields, true), tempFields, true);
532
536
  }
533
537
  });
534
- derivedFields = __spreadArray(__spreadArray([], derivedFields), fields);
538
+ derivedFields = __spreadArray(__spreadArray([], derivedFields, true), fields, true);
535
539
  });
536
540
  return derivedFields;
537
541
  };
@@ -607,7 +611,7 @@ var assignFieldValue = function (formattedField, field, fieldName, filledItemdat
607
611
  value = formattedField.extraFieldSetting
608
612
  ? formattedField.extraFieldSetting.defaultValue
609
613
  : filledItemdata[fieldName];
610
- value = format_fields_1.getFormatFieldData(value, field.type);
614
+ value = (0, format_fields_1.getFormatFieldData)(value, field.type);
611
615
  return value;
612
616
  };
613
617
  var validateData = function (fields, data) {
@@ -628,7 +632,7 @@ var validateData = function (fields, data) {
628
632
  fieldValue = JSON.parse(fieldValue);
629
633
  }
630
634
  catch (error) {
631
- errors.push("Error parsing " + fieldTitle + ": " + error.message);
635
+ errors.push("Error parsing ".concat(fieldTitle, ": ").concat(error.message));
632
636
  return;
633
637
  }
634
638
  }
@@ -637,50 +641,50 @@ var validateData = function (fields, data) {
637
641
  if (typeof fieldValue !== "string" &&
638
642
  typeof fieldValue !== "number" &&
639
643
  Object.prototype.toString.call(fieldValue) !== "[object Date]") {
640
- errors.push(fieldTitle + " must be a string");
644
+ errors.push("".concat(fieldTitle, " must be a string"));
641
645
  }
642
646
  break;
643
647
  case "large_text":
644
648
  case "color":
645
649
  if (typeof fieldValue !== "string") {
646
- errors.push(fieldTitle + " must be a string");
650
+ errors.push("".concat(fieldTitle, " must be a string"));
647
651
  }
648
652
  break;
649
653
  case "uuid":
650
- if (typeof fieldValue !== "string" || !uuid_1.validate(fieldValue)) {
651
- errors.push(fieldTitle + " must be a valid UUID string");
654
+ if (typeof fieldValue !== "string" || !(0, uuid_1.validate)(fieldValue)) {
655
+ errors.push("".concat(fieldTitle, " must be a valid UUID string"));
652
656
  }
653
657
  break;
654
658
  case "reference":
655
659
  case "belongsTo":
656
660
  if (!Array.isArray(fieldValue) ||
657
661
  fieldValue.some(function (item) { return typeof item !== "string"; })) {
658
- errors.push(fieldTitle + " must be an array of valid UUID strings");
662
+ errors.push("".concat(fieldTitle, " must be an array of valid UUID strings"));
659
663
  }
660
664
  break;
661
665
  case "createdAt":
662
666
  case "updatedAt":
663
667
  case "date":
664
668
  if (fieldValue && isNaN(Date.parse(fieldValue))) {
665
- errors.push(fieldTitle + " must be a valid date");
669
+ errors.push("".concat(fieldTitle, " must be a valid date"));
666
670
  }
667
671
  break;
668
672
  case "boolean":
669
673
  if (typeof fieldValue !== "boolean") {
670
- errors.push(fieldTitle + " must be a boolean");
674
+ errors.push("".concat(fieldTitle, " must be a boolean"));
671
675
  }
672
676
  break;
673
677
  case "email":
674
678
  if (typeof fieldValue !== "string" ||
675
679
  !/\S+@\S+\.\S+/.test(fieldValue)) {
676
- errors.push(fieldTitle + " must be a valid email address");
680
+ errors.push("".concat(fieldTitle, " must be a valid email address"));
677
681
  break;
678
682
  }
679
683
  break;
680
684
  case "tel":
681
685
  var telPattern = /^\+?(\d{1,3})?[-\s]?(\(\d{1,4}\)|\d{1,4})[-\s]?(\d{1,4}[-\s]?\d{1,4}|\d{7,10})$/;
682
686
  if (typeof fieldValue !== "string" || !telPattern.test(fieldValue)) {
683
- errors.push(fieldTitle + " must be a valid phone number");
687
+ errors.push("".concat(fieldTitle, " must be a valid phone number"));
684
688
  }
685
689
  break;
686
690
  case "static_option":
@@ -690,16 +694,16 @@ var validateData = function (fields, data) {
690
694
  }
691
695
  else if (Array.isArray(fieldValue)) {
692
696
  if (fieldValue.some(function (item) { return typeof item !== "string"; })) {
693
- errors.push(fieldTitle + " must be an array of strings");
697
+ errors.push("".concat(fieldTitle, " must be an array of strings"));
694
698
  }
695
699
  }
696
700
  else {
697
- errors.push(fieldTitle + " must be a string or an array of strings");
701
+ errors.push("".concat(fieldTitle, " must be a string or an array of strings"));
698
702
  }
699
703
  break;
700
704
  case "url":
701
- if (typeof fieldValue !== "string" || !exports.validateUrl(fieldValue)) {
702
- errors.push(fieldTitle + " must be a valid URL");
705
+ if (typeof fieldValue !== "string" || !(0, exports.validateUrl)(fieldValue)) {
706
+ errors.push("".concat(fieldTitle, " must be a valid URL"));
703
707
  }
704
708
  break;
705
709
  case "file":
@@ -709,18 +713,18 @@ var validateData = function (fields, data) {
709
713
  !item.key ||
710
714
  typeof item.key !== "string";
711
715
  })) {
712
- errors.push(fieldTitle + " must be an array of objects with 'key' property as string");
716
+ errors.push("".concat(fieldTitle, " must be an array of objects with 'key' property as string"));
713
717
  }
714
718
  }
715
719
  else if (typeof fieldValue !== "object" ||
716
720
  !fieldValue.key ||
717
721
  typeof fieldValue.key !== "string") {
718
- errors.push(fieldTitle + " must be an object with 'key' property as string");
722
+ errors.push("".concat(fieldTitle, " must be an object with 'key' property as string"));
719
723
  }
720
724
  break;
721
725
  case "number":
722
726
  if (isNaN(Number(fieldValue))) {
723
- errors.push(fieldTitle + " must be a valid number.");
727
+ errors.push("".concat(fieldTitle, " must be a valid number."));
724
728
  }
725
729
  break;
726
730
  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.6",
3
+ "version": "1.5.7",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -19,6 +19,8 @@
19
19
  "author": "Drapcode",
20
20
  "license": "ISC",
21
21
  "devDependencies": {
22
+ "@types/dompurify": "^3.0.5",
23
+ "@types/jsdom": "^21.1.7",
22
24
  "@types/lodash": "^4.14.179",
23
25
  "@types/mime-types": "^2.1.4",
24
26
  "@types/uuid": "^9.0.8",
@@ -34,15 +36,19 @@
34
36
  "@types/gm": "^1.25.4",
35
37
  "@types/voca": "^1.4.2",
36
38
  "axios": "^1.1.2",
39
+ "dompurify": "^3.1.7",
37
40
  "drapcode-constant": "^1.4.8",
38
41
  "drapcode-logger": "^1.1.8",
39
- "drapcode-redis": "^1.0.5",
42
+ "drapcode-redis": "^1.0.6",
43
+ "exiftool-vendored": "^28.2.1",
40
44
  "express": "^4.17.1",
41
45
  "gm": "^1.25.0",
46
+ "jsdom": "^25.0.1",
42
47
  "lodash": "^4.17.21",
43
48
  "mime-types": "^2.1.35",
44
49
  "moment": "^2.29.0",
45
50
  "stringify-object": "^3.3.0",
51
+ "svgo": "^3.3.2",
46
52
  "uuid": "^8.3.2",
47
53
  "voca": "^1.4.0"
48
54
  }