@cosmotech/core 1.5.0-dev.1 → 1.5.0-dev.2

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.
package/dist/index.cjs.js CHANGED
@@ -12716,6 +12716,26 @@ var _validateFormat = function _validateFormat(rows, hasHeader, cols, options) {
12716
12716
  return errors;
12717
12717
  };
12718
12718
 
12719
+ var _reformatBoolValue = function _reformatBoolValue(csvCellValue) {
12720
+ csvCellValue = csvCellValue.toLowerCase();
12721
+
12722
+ if (['0', 'false', 'no'].includes(csvCellValue)) {
12723
+ return 'false';
12724
+ } else if (['1', 'true', 'yes'].includes(csvCellValue)) {
12725
+ return 'true';
12726
+ }
12727
+
12728
+ return null;
12729
+ };
12730
+
12731
+ var _reformatValue = function _reformatValue(csvCellValue, colTypes) {
12732
+ if (colTypes && colTypes.includes('bool')) {
12733
+ return _reformatBoolValue(csvCellValue);
12734
+ }
12735
+
12736
+ return csvCellValue;
12737
+ };
12738
+
12719
12739
  var _buildCols = function _buildCols(header) {
12720
12740
  return header.map(function (col) {
12721
12741
  return {
@@ -12732,7 +12752,8 @@ var _buildRows = function _buildRows(rows, hasHeader, cols) {
12732
12752
  var row = {};
12733
12753
 
12734
12754
  for (var colIndex = 0; colIndex < cols.length; colIndex++) {
12735
- row[cols[colIndex].field] = rows[rowIndex][colIndex];
12755
+ var csvCellValue = rows[rowIndex][colIndex];
12756
+ row[cols[colIndex].field] = _reformatValue(csvCellValue, cols[colIndex].type);
12736
12757
  }
12737
12758
 
12738
12759
  formattedData.push(row);
package/dist/index.esm.js CHANGED
@@ -12708,6 +12708,26 @@ var _validateFormat = function _validateFormat(rows, hasHeader, cols, options) {
12708
12708
  return errors;
12709
12709
  };
12710
12710
 
12711
+ var _reformatBoolValue = function _reformatBoolValue(csvCellValue) {
12712
+ csvCellValue = csvCellValue.toLowerCase();
12713
+
12714
+ if (['0', 'false', 'no'].includes(csvCellValue)) {
12715
+ return 'false';
12716
+ } else if (['1', 'true', 'yes'].includes(csvCellValue)) {
12717
+ return 'true';
12718
+ }
12719
+
12720
+ return null;
12721
+ };
12722
+
12723
+ var _reformatValue = function _reformatValue(csvCellValue, colTypes) {
12724
+ if (colTypes && colTypes.includes('bool')) {
12725
+ return _reformatBoolValue(csvCellValue);
12726
+ }
12727
+
12728
+ return csvCellValue;
12729
+ };
12730
+
12711
12731
  var _buildCols = function _buildCols(header) {
12712
12732
  return header.map(function (col) {
12713
12733
  return {
@@ -12724,7 +12744,8 @@ var _buildRows = function _buildRows(rows, hasHeader, cols) {
12724
12744
  var row = {};
12725
12745
 
12726
12746
  for (var colIndex = 0; colIndex < cols.length; colIndex++) {
12727
- row[cols[colIndex].field] = rows[rowIndex][colIndex];
12747
+ var csvCellValue = rows[rowIndex][colIndex];
12748
+ row[cols[colIndex].field] = _reformatValue(csvCellValue, cols[colIndex].type);
12728
12749
  }
12729
12750
 
12730
12751
  formattedData.push(row);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cosmotech/core",
3
3
  "private": false,
4
- "version": "1.5.0-dev.1",
4
+ "version": "1.5.0-dev.2",
5
5
  "description": "",
6
6
  "main": "dist/index.cjs.js",
7
7
  "module": "dist/index.esm.js",