@cosmotech/core 1.5.0-dev.1 → 1.5.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
@@ -7995,7 +7995,7 @@ function buildLocalizeFn(args) {
7995
7995
  valuesArray = args.values[_width] || args.values[_defaultWidth];
7996
7996
  }
7997
7997
 
7998
- var index = args.argumentCallback ? args.argumentCallback(dirtyIndex) : dirtyIndex; // @ts-ignore: For some reason TypeScript just don't want to match it, no matter how hard we try. I challange you to try to remove it!
7998
+ var index = args.argumentCallback ? args.argumentCallback(dirtyIndex) : dirtyIndex; // @ts-ignore: For some reason TypeScript just don't want to match it, no matter how hard we try. I challenge you to try to remove it!
7999
7999
 
8000
8000
  return valuesArray[index];
8001
8001
  };
@@ -8562,7 +8562,7 @@ function startOfUTCWeek(dirtyDate, dirtyOptions) {
8562
8562
 
8563
8563
  function getUTCWeekYear(dirtyDate, dirtyOptions) {
8564
8564
  requiredArgs(1, arguments);
8565
- var date = toDate(dirtyDate, dirtyOptions);
8565
+ var date = toDate(dirtyDate);
8566
8566
  var year = date.getUTCFullYear();
8567
8567
  var options = dirtyOptions || {};
8568
8568
  var locale = options.locale;
@@ -9448,7 +9448,7 @@ var formatters = {
9448
9448
  }
9449
9449
  };
9450
9450
 
9451
- function formatTimezoneShort(offset, dirtyDelimiter) {
9451
+ function formatTimezoneShort(offset, delimiter) {
9452
9452
  var sign = offset > 0 ? '-' : '+';
9453
9453
  var absOffset = Math.abs(offset);
9454
9454
  var hours = Math.floor(absOffset / 60);
@@ -9458,7 +9458,6 @@ function formatTimezoneShort(offset, dirtyDelimiter) {
9458
9458
  return sign + String(hours);
9459
9459
  }
9460
9460
 
9461
- var delimiter = dirtyDelimiter || '';
9462
9461
  return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);
9463
9462
  }
9464
9463
 
@@ -9533,7 +9532,7 @@ function timeLongFormatter(pattern, formatLong) {
9533
9532
  }
9534
9533
 
9535
9534
  function dateTimeLongFormatter(pattern, formatLong) {
9536
- var matchResult = pattern.match(/(P+)(p+)?/);
9535
+ var matchResult = pattern.match(/(P+)(p+)?/) || [];
9537
9536
  var datePattern = matchResult[1];
9538
9537
  var timePattern = matchResult[2];
9539
9538
 
@@ -12716,6 +12715,26 @@ var _validateFormat = function _validateFormat(rows, hasHeader, cols, options) {
12716
12715
  return errors;
12717
12716
  };
12718
12717
 
12718
+ var _reformatBoolValue = function _reformatBoolValue(csvCellValue) {
12719
+ csvCellValue = csvCellValue.toLowerCase();
12720
+
12721
+ if (['0', 'false', 'no'].includes(csvCellValue)) {
12722
+ return 'false';
12723
+ } else if (['1', 'true', 'yes'].includes(csvCellValue)) {
12724
+ return 'true';
12725
+ }
12726
+
12727
+ return null;
12728
+ };
12729
+
12730
+ var _reformatValue = function _reformatValue(csvCellValue, colTypes) {
12731
+ if (colTypes && colTypes.includes('bool')) {
12732
+ return _reformatBoolValue(csvCellValue);
12733
+ }
12734
+
12735
+ return csvCellValue;
12736
+ };
12737
+
12719
12738
  var _buildCols = function _buildCols(header) {
12720
12739
  return header.map(function (col) {
12721
12740
  return {
@@ -12732,7 +12751,8 @@ var _buildRows = function _buildRows(rows, hasHeader, cols) {
12732
12751
  var row = {};
12733
12752
 
12734
12753
  for (var colIndex = 0; colIndex < cols.length; colIndex++) {
12735
- row[cols[colIndex].field] = rows[rowIndex][colIndex];
12754
+ var csvCellValue = rows[rowIndex][colIndex];
12755
+ row[cols[colIndex].field] = _reformatValue(csvCellValue, cols[colIndex].type);
12736
12756
  }
12737
12757
 
12738
12758
  formattedData.push(row);
package/dist/index.esm.js CHANGED
@@ -7987,7 +7987,7 @@ function buildLocalizeFn(args) {
7987
7987
  valuesArray = args.values[_width] || args.values[_defaultWidth];
7988
7988
  }
7989
7989
 
7990
- var index = args.argumentCallback ? args.argumentCallback(dirtyIndex) : dirtyIndex; // @ts-ignore: For some reason TypeScript just don't want to match it, no matter how hard we try. I challange you to try to remove it!
7990
+ var index = args.argumentCallback ? args.argumentCallback(dirtyIndex) : dirtyIndex; // @ts-ignore: For some reason TypeScript just don't want to match it, no matter how hard we try. I challenge you to try to remove it!
7991
7991
 
7992
7992
  return valuesArray[index];
7993
7993
  };
@@ -8554,7 +8554,7 @@ function startOfUTCWeek(dirtyDate, dirtyOptions) {
8554
8554
 
8555
8555
  function getUTCWeekYear(dirtyDate, dirtyOptions) {
8556
8556
  requiredArgs(1, arguments);
8557
- var date = toDate(dirtyDate, dirtyOptions);
8557
+ var date = toDate(dirtyDate);
8558
8558
  var year = date.getUTCFullYear();
8559
8559
  var options = dirtyOptions || {};
8560
8560
  var locale = options.locale;
@@ -9440,7 +9440,7 @@ var formatters = {
9440
9440
  }
9441
9441
  };
9442
9442
 
9443
- function formatTimezoneShort(offset, dirtyDelimiter) {
9443
+ function formatTimezoneShort(offset, delimiter) {
9444
9444
  var sign = offset > 0 ? '-' : '+';
9445
9445
  var absOffset = Math.abs(offset);
9446
9446
  var hours = Math.floor(absOffset / 60);
@@ -9450,7 +9450,6 @@ function formatTimezoneShort(offset, dirtyDelimiter) {
9450
9450
  return sign + String(hours);
9451
9451
  }
9452
9452
 
9453
- var delimiter = dirtyDelimiter || '';
9454
9453
  return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);
9455
9454
  }
9456
9455
 
@@ -9525,7 +9524,7 @@ function timeLongFormatter(pattern, formatLong) {
9525
9524
  }
9526
9525
 
9527
9526
  function dateTimeLongFormatter(pattern, formatLong) {
9528
- var matchResult = pattern.match(/(P+)(p+)?/);
9527
+ var matchResult = pattern.match(/(P+)(p+)?/) || [];
9529
9528
  var datePattern = matchResult[1];
9530
9529
  var timePattern = matchResult[2];
9531
9530
 
@@ -12708,6 +12707,26 @@ var _validateFormat = function _validateFormat(rows, hasHeader, cols, options) {
12708
12707
  return errors;
12709
12708
  };
12710
12709
 
12710
+ var _reformatBoolValue = function _reformatBoolValue(csvCellValue) {
12711
+ csvCellValue = csvCellValue.toLowerCase();
12712
+
12713
+ if (['0', 'false', 'no'].includes(csvCellValue)) {
12714
+ return 'false';
12715
+ } else if (['1', 'true', 'yes'].includes(csvCellValue)) {
12716
+ return 'true';
12717
+ }
12718
+
12719
+ return null;
12720
+ };
12721
+
12722
+ var _reformatValue = function _reformatValue(csvCellValue, colTypes) {
12723
+ if (colTypes && colTypes.includes('bool')) {
12724
+ return _reformatBoolValue(csvCellValue);
12725
+ }
12726
+
12727
+ return csvCellValue;
12728
+ };
12729
+
12711
12730
  var _buildCols = function _buildCols(header) {
12712
12731
  return header.map(function (col) {
12713
12732
  return {
@@ -12724,7 +12743,8 @@ var _buildRows = function _buildRows(rows, hasHeader, cols) {
12724
12743
  var row = {};
12725
12744
 
12726
12745
  for (var colIndex = 0; colIndex < cols.length; colIndex++) {
12727
- row[cols[colIndex].field] = rows[rowIndex][colIndex];
12746
+ var csvCellValue = rows[rowIndex][colIndex];
12747
+ row[cols[colIndex].field] = _reformatValue(csvCellValue, cols[colIndex].type);
12728
12748
  }
12729
12749
 
12730
12750
  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.2",
5
5
  "description": "",
6
6
  "main": "dist/index.cjs.js",
7
7
  "module": "dist/index.esm.js",