drapcode-utility 1.5.6 → 1.5.8

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,29 +285,35 @@ 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;
288
292
  };
289
293
  exports.formatCustomCSSClasses = formatCustomCSSClasses;
290
- var replaceDataValueIntoExpression = function (expression, data, user, tenant, sessionValue, envConstants, sessionFormValue, localStorageValue, cookiesValue) {
294
+ var replaceDataValueIntoExpression = function (expression, data, user, tenant, userSetting, sessionValue, envConstants, sessionFormValue, localStorageValue, cookiesValue) {
291
295
  var _a;
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);
311
+ }
312
+ }
313
+ else if (prop.includes("current_settings")) {
314
+ prop = prop.replace("current_settings.", "");
315
+ if (Object.keys(userSetting).length > 0) {
316
+ dataOfItem = (0, exports.parseValueFromData)(userSetting, prop);
307
317
  }
308
318
  }
309
319
  else if (prop.includes("current_session")) {
@@ -350,7 +360,7 @@ var replaceDataValueIntoExpression = function (expression, data, user, tenant, s
350
360
  }
351
361
  else {
352
362
  if (Object.keys(data).length > 0) {
353
- dataOfItem = exports.parseValueFromData(data, prop);
363
+ dataOfItem = (0, exports.parseValueFromData)(data, prop);
354
364
  //TODO: Need better way
355
365
  delete data[prop];
356
366
  }
@@ -450,7 +460,7 @@ var replaceTransferObjectValueIntoExpression = function (expression, transferObj
450
460
  var contentList = (_a = expression
451
461
  .match(/{{(.*?)}}/g)) === null || _a === void 0 ? void 0 : _a.map(function (b) { return b.replace(/{{(.*?)}}/g, "$1"); });
452
462
  contentList === null || contentList === void 0 ? void 0 : contentList.forEach(function (prop) {
453
- var needle = "{{" + prop + "}}";
463
+ var needle = "{{".concat(prop, "}}");
454
464
  var dataOfItem = "";
455
465
  dataOfItem = transferObject[prop] ? transferObject[prop] : "";
456
466
  expression = dataOfItem
@@ -496,8 +506,8 @@ var processFieldsInlcude = function (fieldsInclude) {
496
506
  fieldsInclude = fieldsInclude.filter(function (field) { return !(field.startsWith("RF::") || field.startsWith("DF::")); });
497
507
  var refFields = processReferenceFieldInclude(refFieldsInclude);
498
508
  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);
509
+ var extraField = __spreadArray(__spreadArray([], refFields, true), derivedFields, true).filter(function (value, index, array) { return array.indexOf(value) === index; });
510
+ result = __spreadArray(__spreadArray([], fieldsInclude, true), extraField, true);
501
511
  return result;
502
512
  };
503
513
  exports.processFieldsInlcude = processFieldsInlcude;
@@ -522,16 +532,16 @@ var processDerivedFieldInclude = function (derivedFieldsInclude) {
522
532
  if (arg.name === "expression") {
523
533
  var needleList = (_a = arg.key
524
534
  .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);
535
+ var tempFields = (0, exports.processFieldsInlcude)(needleList);
536
+ fields = __spreadArray(__spreadArray([], fields, true), tempFields, true);
527
537
  }
528
538
  else if (!derivedFieldExcludes.includes(arg.name)) {
529
539
  var tempFields = Array.isArray(arg.key) ? arg.key : [arg.key];
530
- tempFields = exports.processFieldsInlcude(tempFields);
531
- fields = __spreadArray(__spreadArray([], fields), tempFields);
540
+ tempFields = (0, exports.processFieldsInlcude)(tempFields);
541
+ fields = __spreadArray(__spreadArray([], fields, true), tempFields, true);
532
542
  }
533
543
  });
534
- derivedFields = __spreadArray(__spreadArray([], derivedFields), fields);
544
+ derivedFields = __spreadArray(__spreadArray([], derivedFields, true), fields, true);
535
545
  });
536
546
  return derivedFields;
537
547
  };
@@ -607,7 +617,7 @@ var assignFieldValue = function (formattedField, field, fieldName, filledItemdat
607
617
  value = formattedField.extraFieldSetting
608
618
  ? formattedField.extraFieldSetting.defaultValue
609
619
  : filledItemdata[fieldName];
610
- value = format_fields_1.getFormatFieldData(value, field.type);
620
+ value = (0, format_fields_1.getFormatFieldData)(value, field.type);
611
621
  return value;
612
622
  };
613
623
  var validateData = function (fields, data) {
@@ -628,7 +638,7 @@ var validateData = function (fields, data) {
628
638
  fieldValue = JSON.parse(fieldValue);
629
639
  }
630
640
  catch (error) {
631
- errors.push("Error parsing " + fieldTitle + ": " + error.message);
641
+ errors.push("Error parsing ".concat(fieldTitle, ": ").concat(error.message));
632
642
  return;
633
643
  }
634
644
  }
@@ -637,50 +647,50 @@ var validateData = function (fields, data) {
637
647
  if (typeof fieldValue !== "string" &&
638
648
  typeof fieldValue !== "number" &&
639
649
  Object.prototype.toString.call(fieldValue) !== "[object Date]") {
640
- errors.push(fieldTitle + " must be a string");
650
+ errors.push("".concat(fieldTitle, " must be a string"));
641
651
  }
642
652
  break;
643
653
  case "large_text":
644
654
  case "color":
645
655
  if (typeof fieldValue !== "string") {
646
- errors.push(fieldTitle + " must be a string");
656
+ errors.push("".concat(fieldTitle, " must be a string"));
647
657
  }
648
658
  break;
649
659
  case "uuid":
650
- if (typeof fieldValue !== "string" || !uuid_1.validate(fieldValue)) {
651
- errors.push(fieldTitle + " must be a valid UUID string");
660
+ if (typeof fieldValue !== "string" || !(0, uuid_1.validate)(fieldValue)) {
661
+ errors.push("".concat(fieldTitle, " must be a valid UUID string"));
652
662
  }
653
663
  break;
654
664
  case "reference":
655
665
  case "belongsTo":
656
666
  if (!Array.isArray(fieldValue) ||
657
667
  fieldValue.some(function (item) { return typeof item !== "string"; })) {
658
- errors.push(fieldTitle + " must be an array of valid UUID strings");
668
+ errors.push("".concat(fieldTitle, " must be an array of valid UUID strings"));
659
669
  }
660
670
  break;
661
671
  case "createdAt":
662
672
  case "updatedAt":
663
673
  case "date":
664
674
  if (fieldValue && isNaN(Date.parse(fieldValue))) {
665
- errors.push(fieldTitle + " must be a valid date");
675
+ errors.push("".concat(fieldTitle, " must be a valid date"));
666
676
  }
667
677
  break;
668
678
  case "boolean":
669
679
  if (typeof fieldValue !== "boolean") {
670
- errors.push(fieldTitle + " must be a boolean");
680
+ errors.push("".concat(fieldTitle, " must be a boolean"));
671
681
  }
672
682
  break;
673
683
  case "email":
674
684
  if (typeof fieldValue !== "string" ||
675
685
  !/\S+@\S+\.\S+/.test(fieldValue)) {
676
- errors.push(fieldTitle + " must be a valid email address");
686
+ errors.push("".concat(fieldTitle, " must be a valid email address"));
677
687
  break;
678
688
  }
679
689
  break;
680
690
  case "tel":
681
691
  var telPattern = /^\+?(\d{1,3})?[-\s]?(\(\d{1,4}\)|\d{1,4})[-\s]?(\d{1,4}[-\s]?\d{1,4}|\d{7,10})$/;
682
692
  if (typeof fieldValue !== "string" || !telPattern.test(fieldValue)) {
683
- errors.push(fieldTitle + " must be a valid phone number");
693
+ errors.push("".concat(fieldTitle, " must be a valid phone number"));
684
694
  }
685
695
  break;
686
696
  case "static_option":
@@ -690,16 +700,16 @@ var validateData = function (fields, data) {
690
700
  }
691
701
  else if (Array.isArray(fieldValue)) {
692
702
  if (fieldValue.some(function (item) { return typeof item !== "string"; })) {
693
- errors.push(fieldTitle + " must be an array of strings");
703
+ errors.push("".concat(fieldTitle, " must be an array of strings"));
694
704
  }
695
705
  }
696
706
  else {
697
- errors.push(fieldTitle + " must be a string or an array of strings");
707
+ errors.push("".concat(fieldTitle, " must be a string or an array of strings"));
698
708
  }
699
709
  break;
700
710
  case "url":
701
- if (typeof fieldValue !== "string" || !exports.validateUrl(fieldValue)) {
702
- errors.push(fieldTitle + " must be a valid URL");
711
+ if (typeof fieldValue !== "string" || !(0, exports.validateUrl)(fieldValue)) {
712
+ errors.push("".concat(fieldTitle, " must be a valid URL"));
703
713
  }
704
714
  break;
705
715
  case "file":
@@ -709,18 +719,18 @@ var validateData = function (fields, data) {
709
719
  !item.key ||
710
720
  typeof item.key !== "string";
711
721
  })) {
712
- errors.push(fieldTitle + " must be an array of objects with 'key' property as string");
722
+ errors.push("".concat(fieldTitle, " must be an array of objects with 'key' property as string"));
713
723
  }
714
724
  }
715
725
  else if (typeof fieldValue !== "object" ||
716
726
  !fieldValue.key ||
717
727
  typeof fieldValue.key !== "string") {
718
- errors.push(fieldTitle + " must be an object with 'key' property as string");
728
+ errors.push("".concat(fieldTitle, " must be an object with 'key' property as string"));
719
729
  }
720
730
  break;
721
731
  case "number":
722
732
  if (isNaN(Number(fieldValue))) {
723
- errors.push(fieldTitle + " must be a valid number.");
733
+ errors.push("".concat(fieldTitle, " must be a valid number."));
724
734
  }
725
735
  break;
726
736
  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.8",
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",
37
- "drapcode-constant": "^1.4.8",
38
- "drapcode-logger": "^1.1.8",
39
- "drapcode-redis": "^1.0.5",
39
+ "dompurify": "^3.1.7",
40
+ "drapcode-constant": "^1.4.9",
41
+ "drapcode-logger": "^1.1.9",
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
  }