drapcode-utility 2.6.0 → 2.6.1

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.
Files changed (2) hide show
  1. package/build/utils/util.js +14 -10
  2. package/package.json +1 -1
@@ -635,18 +635,20 @@ const replaceValueFromTenant = (variableName, tenant) => {
635
635
  const fillDefaultValues = (collection, itemdata) => {
636
636
  const filledItemData = { ...itemdata };
637
637
  const fieldsToSkip = drapcode_constant_1.hiddenFormField;
638
- const fieldTypesToSkip = [drapcode_constant_1.FieldTypes.boolean.id];
639
- const allFields = collection.fields.filter((field) => !fieldsToSkip.includes(field.fieldName) &&
640
- !fieldTypesToSkip.includes(field.type));
638
+ // const fieldTypesToSkip = [FieldTypes.boolean.id];
639
+ const allFields = collection.fields.filter((field) => !fieldsToSkip.includes(field.fieldName));
641
640
  allFields.forEach((field) => {
642
641
  const fieldName = field.fieldName;
643
642
  const currentValue = filledItemData[fieldName];
644
643
  const isEmptyArray = Array.isArray(currentValue) && currentValue.length === 0;
644
+ const isBooleanField = field.type === drapcode_constant_1.FieldTypes.boolean.id;
645
+ const isInvalidBoolean = isBooleanField && ![true, false].includes(currentValue);
645
646
  if (!(fieldName in filledItemData) ||
646
- filledItemData[fieldName] === "" ||
647
- filledItemData[fieldName] === 0 ||
648
- filledItemData[fieldName] === false ||
649
- isEmptyArray) {
647
+ currentValue === "" ||
648
+ currentValue === 0 ||
649
+ (!isBooleanField && currentValue === false) ||
650
+ isEmptyArray ||
651
+ isInvalidBoolean) {
650
652
  const formattedField = JSON.parse(JSON.stringify(field));
651
653
  console.log("These are the field types: ", field.type, typeof field.type);
652
654
  if (field.type === "static_option") {
@@ -669,7 +671,9 @@ const assignFieldValue = (formattedField, field, fieldName, filledItemData) => {
669
671
  value = formattedField.extraFieldSetting
670
672
  ? formattedField.extraFieldSetting.defaultValue
671
673
  : filledItemData[fieldName];
674
+ console.log("\n +==+ value 1:", value);
672
675
  value = (0, format_fields_1.getFormatFieldData)(value, field.type);
676
+ console.log("\n +==+ value 2:", value);
673
677
  return value;
674
678
  };
675
679
  const validateData = (fields, data) => {
@@ -1276,10 +1280,10 @@ exports.getAwsSignature = getAwsSignature;
1276
1280
  */
1277
1281
  const createMySqlConnection = async (config) => {
1278
1282
  try {
1279
- const { host, user, password, database, port, sslEnabled, sslCa, sslCert, sslKey } = config || {};
1283
+ const { host, user, password, database, port, sslEnabled, sslCa, sslCert, sslKey, } = config || {};
1280
1284
  console.log("🚀 ~ createMySqlConnection ~ sslEnabled:", sslEnabled);
1281
1285
  console.log("🚀 ~ createMySqlConnection ~ process.env.MYSQL_SSL_CERT_PATH:", process.env.MYSQL_SSL_CERT_PATH);
1282
- const sslCertsPath = process.env.MYSQL_SSL_CERT_PATH || './';
1286
+ const sslCertsPath = process.env.MYSQL_SSL_CERT_PATH || "./";
1283
1287
  console.log("🚀 ~ createMySqlConnection ~ sslCertsPath:", sslCertsPath);
1284
1288
  let connection = null;
1285
1289
  if (sslEnabled) {
@@ -1289,7 +1293,7 @@ const createMySqlConnection = async (config) => {
1289
1293
  password,
1290
1294
  database,
1291
1295
  port,
1292
- ssl: {}
1296
+ ssl: {},
1293
1297
  };
1294
1298
  if (sslCa) {
1295
1299
  connectionOptions.ssl.ca = fs_1.default.readFileSync(`${sslCertsPath}${sslCa}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drapcode-utility",
3
- "version": "2.6.0",
3
+ "version": "2.6.1",
4
4
  "description": "DrapCode Utility",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",