@cosmotech/core 1.10.0 → 1.10.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.
package/dist/index.esm.js CHANGED
@@ -2,17 +2,14 @@ import require$$0 from 'stream';
2
2
 
3
3
  function ownKeys(object, enumerableOnly) {
4
4
  var keys = Object.keys(object);
5
-
6
5
  if (Object.getOwnPropertySymbols) {
7
6
  var symbols = Object.getOwnPropertySymbols(object);
8
7
  enumerableOnly && (symbols = symbols.filter(function (sym) {
9
8
  return Object.getOwnPropertyDescriptor(object, sym).enumerable;
10
9
  })), keys.push.apply(keys, symbols);
11
10
  }
12
-
13
11
  return keys;
14
12
  }
15
-
16
13
  function _objectSpread2(target) {
17
14
  for (var i = 1; i < arguments.length; i++) {
18
15
  var source = null != arguments[i] ? arguments[i] : {};
@@ -22,10 +19,8 @@ function _objectSpread2(target) {
22
19
  Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
23
20
  });
24
21
  }
25
-
26
22
  return target;
27
23
  }
28
-
29
24
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
30
25
  try {
31
26
  var info = gen[key](arg);
@@ -34,34 +29,28 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
34
29
  reject(error);
35
30
  return;
36
31
  }
37
-
38
32
  if (info.done) {
39
33
  resolve(value);
40
34
  } else {
41
35
  Promise.resolve(value).then(_next, _throw);
42
36
  }
43
37
  }
44
-
45
38
  function _asyncToGenerator(fn) {
46
39
  return function () {
47
40
  var self = this,
48
- args = arguments;
41
+ args = arguments;
49
42
  return new Promise(function (resolve, reject) {
50
43
  var gen = fn.apply(self, args);
51
-
52
44
  function _next(value) {
53
45
  asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
54
46
  }
55
-
56
47
  function _throw(err) {
57
48
  asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
58
49
  }
59
-
60
50
  _next(undefined);
61
51
  });
62
52
  };
63
53
  }
64
-
65
54
  function _defineProperty$w(obj, key, value) {
66
55
  if (key in obj) {
67
56
  Object.defineProperty(obj, key, {
@@ -73,7 +62,6 @@ function _defineProperty$w(obj, key, value) {
73
62
  } else {
74
63
  obj[key] = value;
75
64
  }
76
-
77
65
  return obj;
78
66
  }
79
67
 
@@ -148,7 +136,7 @@ var Parser$1 = /** @class */ (function () {
148
136
  if (rows.length === 0) {
149
137
  return [];
150
138
  }
151
- var headers_1 = rows.shift();
139
+ var headers_1 = rows.shift().map(function (k) { return k.trim(); });
152
140
  return rows.map(function (row) { return headers_1.reduce(function (data, k, i) {
153
141
  data[k] = row[i];
154
142
  return data;
@@ -591,17 +579,14 @@ __export(CSV);
591
579
  }(dist));
592
580
 
593
581
  // Copyright (c) Cosmo Tech.
594
-
595
582
  var read$1 = dataStr => {
596
583
  return dist.parse(dataStr).map(row => {
597
584
  return row.map(cell => cell.trim());
598
585
  });
599
586
  };
600
-
601
587
  var write = dataArray => {
602
588
  return dist.stringify(dataArray);
603
589
  };
604
-
605
590
  var CSVUtils = {
606
591
  read: read$1,
607
592
  write
@@ -20029,14 +20014,11 @@ var _castCellValueToStr = cellValue => {
20029
20014
  if (cellValue === null || cellValue === undefined) {
20030
20015
  return '';
20031
20016
  }
20032
-
20033
20017
  return '' + cellValue;
20034
20018
  };
20035
-
20036
20019
  var read = /*#__PURE__*/function () {
20037
20020
  var _ref = _asyncToGenerator(function* (fileBlob, forceStr, emptyCols) {
20038
20021
  var data;
20039
-
20040
20022
  try {
20041
20023
  var buffer = yield fileBlob.arrayBuffer();
20042
20024
  var workbook = readSync(buffer);
@@ -20051,21 +20033,17 @@ var read = /*#__PURE__*/function () {
20051
20033
  } catch (err) {
20052
20034
  throw new Error("Can't parse file. Please provide a valid XLSX file.");
20053
20035
  }
20054
-
20055
20036
  if (forceStr) {
20056
20037
  data = data.map(row => {
20057
20038
  return row.map(cell => _castCellValueToStr(cell));
20058
20039
  });
20059
20040
  }
20060
-
20061
20041
  return data;
20062
20042
  });
20063
-
20064
20043
  return function read(_x, _x2, _x3) {
20065
20044
  return _ref.apply(this, arguments);
20066
20045
  };
20067
20046
  }();
20068
-
20069
20047
  var XLSXUtils = {
20070
20048
  read
20071
20049
  };
@@ -33559,7 +33537,6 @@ function isMatch(dateString, formatString, options) {
33559
33537
  }
33560
33538
 
33561
33539
  // Copyright (c) Cosmo Tech.
33562
-
33563
33540
  var parse = (dateStr, dateFormat) => {
33564
33541
  try {
33565
33542
  return parse$1(dateStr, dateFormat, new Date());
@@ -33567,10 +33544,8 @@ var parse = (dateStr, dateFormat) => {
33567
33544
  console.error(error);
33568
33545
  }
33569
33546
  };
33570
-
33571
33547
  var format = function format(date) {
33572
33548
  var dateFormat = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "yyyy-MM-dd'T'HH:mm:ss.SSSX";
33573
-
33574
33549
  if (date) {
33575
33550
  try {
33576
33551
  return format$1(date, dateFormat);
@@ -33578,46 +33553,39 @@ var format = function format(date) {
33578
33553
  console.error(error);
33579
33554
  }
33580
33555
  }
33581
-
33582
33556
  return '';
33583
33557
  };
33584
-
33585
33558
  var isValid$1 = (dateStr, dateFormat) => {
33586
33559
  return isMatch(dateStr, dateFormat);
33587
33560
  };
33588
-
33589
33561
  var min = (dateA, dateB) => {
33590
33562
  if (dateA && dateB) {
33591
33563
  return dateA < dateB ? dateA : dateB;
33592
33564
  }
33593
33565
  };
33594
-
33595
33566
  var max = (dateA, dateB) => {
33596
33567
  if (dateA && dateB) {
33597
33568
  return dateA > dateB ? dateA : dateB;
33598
33569
  }
33599
- }; // Same as min, but accepts string parameters and returns a string value
33600
-
33570
+ };
33601
33571
 
33572
+ // Same as min, but accepts string parameters and returns a string value
33602
33573
  var strMin = (dateStrA, dateStrB, dateFormat) => {
33603
33574
  var dateA = parse(dateStrA, dateFormat);
33604
33575
  var dateB = parse(dateStrB, dateFormat);
33605
-
33606
33576
  if (dateA && dateB) {
33607
33577
  return dateA < dateB ? dateStrA : dateStrB;
33608
33578
  }
33609
- }; // Same as max, but accepts string parameters and returns a string value
33610
-
33579
+ };
33611
33580
 
33581
+ // Same as max, but accepts string parameters and returns a string value
33612
33582
  var strMax = (dateStrA, dateStrB, dateFormat) => {
33613
33583
  var dateA = parse(dateStrA, dateFormat);
33614
33584
  var dateB = parse(dateStrB, dateFormat);
33615
-
33616
33585
  if (dateA && dateB) {
33617
33586
  return dateA > dateB ? dateStrA : dateStrB;
33618
33587
  }
33619
33588
  };
33620
-
33621
33589
  var DateUtils = {
33622
33590
  parse,
33623
33591
  format,
@@ -33629,75 +33597,57 @@ var DateUtils = {
33629
33597
  };
33630
33598
 
33631
33599
  // Copyright (c) Cosmo Tech.
33632
-
33633
33600
  var isBool = dataStr => {
33634
33601
  return validator.isBoolean(dataStr, {
33635
33602
  loose: true
33636
33603
  });
33637
33604
  };
33638
-
33639
33605
  var isDate = (dataStr, dateFormat) => {
33640
33606
  return DateUtils.isValid(dataStr, dateFormat);
33641
33607
  };
33642
-
33643
33608
  var isEnum = (dataStr, enumValues) => {
33644
33609
  return enumValues.indexOf(dataStr) !== -1;
33645
33610
  };
33646
-
33647
33611
  var isInt = dataStr => {
33648
33612
  return validator.isInt(dataStr);
33649
33613
  };
33650
-
33651
33614
  var isNumber = dataStr => {
33652
33615
  return validator.isNumeric(dataStr);
33653
33616
  };
33654
-
33655
33617
  var isString = data => {
33656
33618
  return typeof data === 'string';
33657
33619
  };
33658
-
33659
33620
  var isValid = function isValid(dataStr, type, options) {
33660
33621
  var canBeEmpty = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
33661
-
33662
33622
  if (canBeEmpty && dataStr === '') {
33663
33623
  return true;
33664
33624
  }
33665
-
33666
33625
  switch (type) {
33667
33626
  case 'bool':
33668
33627
  return isBool(dataStr);
33669
-
33670
33628
  case 'date':
33671
33629
  if (!options.dateFormat) {
33672
33630
  console.error("Missing option dateFormat, can't perform date validation.");
33673
33631
  return false;
33674
33632
  }
33675
-
33676
33633
  return isDate(dataStr, options.dateFormat);
33677
-
33678
33634
  case 'enum':
33679
33635
  if (!options.enumValues) {
33680
33636
  console.error("Missing option enumValues, can't perform enum validation.");
33681
33637
  return false;
33682
33638
  }
33683
-
33684
33639
  return isEnum(dataStr, options.enumValues);
33685
-
33686
33640
  case 'int':
33687
33641
  return isInt(dataStr);
33688
-
33689
33642
  case 'number':
33690
33643
  return isNumber(dataStr);
33691
-
33692
33644
  case 'string':
33693
33645
  return isString(dataStr);
33694
-
33695
33646
  default:
33696
33647
  console.error("Unknown type \"".concat(type, "\", can't perform type validation."));
33697
33648
  return false;
33698
33649
  }
33699
33650
  };
33700
-
33701
33651
  var ValidationUtils = {
33702
33652
  isBool,
33703
33653
  isDate,
@@ -33709,17 +33659,16 @@ var ValidationUtils = {
33709
33659
 
33710
33660
  // Copyright (c) Cosmo Tech.
33711
33661
  // Licensed under the MIT license.
33662
+
33712
33663
  class Error$1 {
33713
33664
  constructor(summary, loc, context) {
33714
33665
  this.summary = summary;
33715
33666
  this.loc = loc;
33716
33667
  this.context = context;
33717
33668
  }
33718
-
33719
33669
  toString() {
33720
33670
  return "Summary: ".concat(this.summary, "\n") + "Loc: ".concat(this.loc, "\n") + "Context: ".concat(this.context);
33721
33671
  }
33722
-
33723
33672
  }
33724
33673
 
33725
33674
  var _buildColumnsCountError = (missingColsCount, rowIndex, expectedColsCount, colsCount, expectedColsName, row) => {
@@ -33728,26 +33677,21 @@ var _buildColumnsCountError = (missingColsCount, rowIndex, expectedColsCount, co
33728
33677
  var errorContext = "".concat(errorSummary, " (").concat(errorLoc, ") : ").concat(expectedColsCount, " fields expected, ") + "but only ".concat(colsCount, " field").concat(colsCount > 1 ? 's' : '', " found\n") + "Expected data format : \"".concat(expectedColsName, "\"\n") + "Incorrect Row : \"".concat(row, "\"");
33729
33678
  return new Error$1(errorSummary, errorLoc, errorContext);
33730
33679
  };
33731
-
33732
33680
  var _buildTypeError = (type, rowIndex, colIndex, colsData, value, expected) => {
33733
33681
  var errorSummary = "Incorrect ".concat(type, " value");
33734
33682
  var errorLoc = "Line ".concat(rowIndex, " , Column ").concat(colIndex, " (\"").concat(colsData[colIndex].field, "\")");
33735
33683
  var errorContext = "".concat(errorSummary, " (").concat(errorLoc, ")\n") + "Incorrect value : \"".concat(value, "\" for type ").concat(type);
33736
-
33737
33684
  if (!expected || expected.length === 0) {
33738
33685
  return new Error$1(errorSummary, errorLoc, errorContext);
33739
33686
  }
33740
-
33741
33687
  return new Error$1(errorSummary, errorLoc, errorContext + '\n' + expected);
33742
33688
  };
33743
-
33744
33689
  var DEFAULT_CSV_EXPORT_OPTIONS = {
33745
33690
  colSep: ',',
33746
33691
  dateFormat: 'yyyy-MM-dd',
33747
33692
  rowSep: '\n',
33748
33693
  writeHeader: true
33749
33694
  };
33750
-
33751
33695
  var _forgeColumnsCountError = (row, rowIndex, expectedCols) => {
33752
33696
  var colsCount = Object.values(row).filter(el => el !== undefined).length;
33753
33697
  var expectedColsCount = expectedCols.length;
@@ -33755,32 +33699,26 @@ var _forgeColumnsCountError = (row, rowIndex, expectedCols) => {
33755
33699
  var missingColsCount = expectedColsCount - colsCount;
33756
33700
  return _buildColumnsCountError(missingColsCount, rowIndex, expectedColsCount, colsCount, expectedColsName, row);
33757
33701
  };
33758
-
33759
33702
  var _forgeTypeError = (value, rowIndex, type, options, colsData, colIndex) => {
33760
33703
  var expected = '';
33761
-
33762
33704
  if (type === 'enum') {
33763
33705
  expected = "Expected values: [".concat(options.enumValues.join(), "]");
33764
33706
  } else if (type === 'date') {
33765
33707
  expected = "Expected format: ".concat(options.dateFormat);
33766
33708
  }
33767
-
33768
33709
  return _buildTypeError(type, rowIndex, colIndex, colsData, value, expected);
33769
33710
  };
33770
-
33771
33711
  var _getColTypeFromTypeArray = typeArray => {
33772
33712
  if (!typeArray || typeArray.length === 0) {
33773
33713
  return 'string'; // Fall back to default type
33774
33714
  }
33775
33715
 
33776
33716
  var knownTypes = ['bool', 'date', 'enum', 'int', 'number'];
33777
-
33778
33717
  for (var type of knownTypes) {
33779
33718
  if (typeArray.indexOf(type) !== -1) {
33780
33719
  return type;
33781
33720
  }
33782
33721
  }
33783
-
33784
33722
  return 'string'; // Fall back to default type
33785
33723
  };
33786
33724
 
@@ -33791,29 +33729,21 @@ var _validateFormat = (rows, hasHeader, cols, options) => {
33791
33729
  var errors = [];
33792
33730
  var knownColsCount = colsData.length;
33793
33731
  var startIndex = hasHeader ? 1 : 0;
33794
-
33795
33732
  var _loop = function _loop(rowIndex) {
33796
33733
  var row = rows[rowIndex];
33797
-
33798
33734
  if (row.length < knownColsCount || row.includes(undefined)) {
33799
33735
  errors.push(_forgeColumnsCountError(rows[rowIndex], rowIndex, colsData));
33800
33736
  }
33801
-
33802
33737
  row.forEach((rowCell, colIndex) => {
33803
33738
  if (colIndex < knownColsCount) {
33804
33739
  var colType = colsData[colIndex].type;
33805
-
33806
33740
  if (colType && rowCell !== undefined) {
33807
33741
  var _colsData$colIndex, _colsData$colIndex2, _colsData$colIndex2$c, _colsData$colIndex$ce, _colsData$colIndex$ce2;
33808
-
33809
33742
  var enumValues = ((_colsData$colIndex = colsData[colIndex]) === null || _colsData$colIndex === void 0 ? void 0 : _colsData$colIndex.enumValues) || ((_colsData$colIndex2 = colsData[colIndex]) === null || _colsData$colIndex2 === void 0 ? void 0 : (_colsData$colIndex2$c = _colsData$colIndex2.cellEditorParams) === null || _colsData$colIndex2$c === void 0 ? void 0 : _colsData$colIndex2$c.enumValues);
33810
-
33811
33743
  var colOptions = _objectSpread2(_objectSpread2({}, options), {}, {
33812
33744
  enumValues: enumValues
33813
33745
  });
33814
-
33815
33746
  var acceptsEmptyFields = (_colsData$colIndex$ce = (_colsData$colIndex$ce2 = colsData[colIndex].cellEditorParams) === null || _colsData$colIndex$ce2 === void 0 ? void 0 : _colsData$colIndex$ce2.acceptsEmptyFields) !== null && _colsData$colIndex$ce !== void 0 ? _colsData$colIndex$ce : false;
33816
-
33817
33747
  if (!ValidationUtils.isValid(rowCell, colType, colOptions, acceptsEmptyFields)) {
33818
33748
  errors.push(_forgeTypeError(rowCell, rowIndex, colType, colOptions, colsData, colIndex));
33819
33749
  }
@@ -33821,93 +33751,71 @@ var _validateFormat = (rows, hasHeader, cols, options) => {
33821
33751
  }
33822
33752
  });
33823
33753
  };
33824
-
33825
33754
  for (var rowIndex = startIndex; rowIndex < rows.length; rowIndex++) {
33826
33755
  _loop(rowIndex);
33827
33756
  }
33828
-
33829
33757
  return errors;
33830
33758
  };
33831
-
33832
33759
  var _reformatBoolValue = csvCellValue => {
33833
33760
  csvCellValue = csvCellValue.toLowerCase();
33834
-
33835
33761
  if (['0', 'false', 'no'].includes(csvCellValue)) {
33836
33762
  return 'false';
33837
33763
  } else if (['1', 'true', 'yes'].includes(csvCellValue)) {
33838
33764
  return 'true';
33839
33765
  }
33840
33766
  };
33841
-
33842
33767
  var _reformatValue = (csvCellValue, colTypes) => {
33843
33768
  if (colTypes && colTypes.includes('bool')) {
33844
33769
  return _reformatBoolValue(csvCellValue);
33845
33770
  }
33846
-
33847
33771
  return csvCellValue;
33848
33772
  };
33849
-
33850
33773
  var _buildCols = header => header.map(col => ({
33851
33774
  field: col
33852
33775
  }));
33853
-
33854
33776
  var _calculateEmptyCols = cols => {
33855
33777
  if (cols === undefined) {
33856
33778
  return [];
33857
33779
  }
33858
-
33859
33780
  return cols.map((_, index) => index).filter(colIndex => {
33860
33781
  var _cols$colIndex$cellEd;
33861
-
33862
33782
  return (_cols$colIndex$cellEd = cols[colIndex].cellEditorParams) === null || _cols$colIndex$cellEd === void 0 ? void 0 : _cols$colIndex$cellEd.acceptsEmptyFields;
33863
33783
  });
33864
33784
  };
33865
-
33866
33785
  var _processTableToTransformNonAcceptableEmptyCols = (lines, emptyCols) => {
33867
33786
  return lines.map(line => line.map((cell, index) => cell === '' && !emptyCols.includes(index) ? undefined : cell));
33868
33787
  };
33869
-
33870
33788
  var _buildRows = (rows, hasHeader, cols) => {
33871
33789
  var formattedData = [];
33872
33790
  var startIndex = hasHeader ? 1 : 0;
33873
-
33874
33791
  for (var rowIndex = startIndex; rowIndex < rows.length; rowIndex++) {
33875
33792
  var row = {};
33876
-
33877
33793
  for (var colIndex = 0; colIndex < cols.length; colIndex++) {
33878
33794
  var csvCellValue = rows[rowIndex][colIndex];
33879
33795
  row[cols[colIndex].field] = _reformatValue(csvCellValue, cols[colIndex].type);
33880
33796
  }
33881
-
33882
33797
  formattedData.push(row);
33883
33798
  }
33884
-
33885
33799
  return formattedData;
33886
33800
  };
33887
-
33888
33801
  var fromCSV = function fromCSV(dataStr) {
33889
33802
  var hasHeader = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
33890
33803
  var cols = arguments.length > 2 ? arguments[2] : undefined;
33891
33804
  var options = arguments.length > 3 ? arguments[3] : undefined;
33892
-
33893
33805
  if (!hasHeader && !cols) {
33894
33806
  return {
33895
33807
  error: [new Error$1('cols must be defined if hasHeader=false', null, null)]
33896
33808
  };
33897
33809
  }
33898
-
33899
33810
  if (!dataStr || dataStr.length === 0) {
33900
33811
  return {
33901
33812
  cols: [],
33902
33813
  rows: []
33903
33814
  };
33904
33815
  }
33905
-
33906
33816
  var rows = [];
33907
33817
  var csvLines;
33908
-
33909
33818
  var emptyCols = _calculateEmptyCols(cols);
33910
-
33911
33819
  try {
33912
33820
  csvLines = _processTableToTransformNonAcceptableEmptyCols(CSVUtils.read(dataStr), emptyCols);
33913
33821
  } catch (err) {
@@ -33915,13 +33823,10 @@ var fromCSV = function fromCSV(dataStr) {
33915
33823
  error: [err]
33916
33824
  };
33917
33825
  }
33918
-
33919
33826
  if (!cols) {
33920
33827
  cols = _buildCols(csvLines[0]);
33921
33828
  }
33922
-
33923
33829
  var errors = _validateFormat(csvLines, hasHeader, cols, options);
33924
-
33925
33830
  if (errors.length > 0) return {
33926
33831
  error: errors
33927
33832
  };
@@ -33931,75 +33836,58 @@ var fromCSV = function fromCSV(dataStr) {
33931
33836
  rows: rows
33932
33837
  };
33933
33838
  };
33934
-
33935
33839
  var _generateHeader = function _generateHeader(cols) {
33936
33840
  var separator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ',';
33937
33841
  return cols.map(col => col.field).join(separator);
33938
33842
  };
33939
-
33940
33843
  var _generateRow = function _generateRow(row, cols) {
33941
33844
  var separator = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ',';
33942
33845
  return cols.map(col => row[col.field]).join(separator);
33943
33846
  };
33944
-
33945
33847
  var _generateRows = function _generateRows(rows, cols) {
33946
33848
  var colSep = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ',';
33947
33849
  var rowSep = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '\n';
33948
33850
  return rows.map(row => _generateRow(row, cols, colSep)).join(rowSep);
33949
33851
  };
33950
-
33951
33852
  var toCSV = (rows, cols, options) => {
33952
33853
  if (cols == null || cols.length === 0) {
33953
33854
  return {
33954
33855
  error: ["Cols must be defined"]
33955
33856
  };
33956
33857
  }
33957
-
33958
33858
  if (!rows) {
33959
33859
  rows = [];
33960
33860
  }
33961
-
33962
33861
  options = _objectSpread2(_objectSpread2({}, DEFAULT_CSV_EXPORT_OPTIONS), options);
33963
-
33964
33862
  var rowsStr = _generateRows(rows, cols, options.colSep, options.rowSep);
33965
-
33966
33863
  var header = '';
33967
-
33968
33864
  if (options.writeHeader) {
33969
33865
  header = _generateHeader(cols);
33970
-
33971
33866
  if (rowsStr.length > 0) {
33972
33867
  header = header.concat(options.rowSep);
33973
33868
  }
33974
33869
  }
33975
-
33976
33870
  return header.concat(rowsStr);
33977
33871
  };
33978
-
33979
33872
  var fromXLSX = /*#__PURE__*/function () {
33980
33873
  var _ref = _asyncToGenerator(function* (fileBlob) {
33981
33874
  var hasHeader = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
33982
33875
  var cols = arguments.length > 2 ? arguments[2] : undefined;
33983
33876
  var options = arguments.length > 3 ? arguments[3] : undefined;
33984
-
33985
33877
  if (!hasHeader && !cols) {
33986
33878
  return {
33987
33879
  error: [new Error$1('cols must be defined if hasHeader=false', null, null)]
33988
33880
  };
33989
33881
  }
33990
-
33991
33882
  if (!fileBlob) {
33992
33883
  return {
33993
33884
  cols: [],
33994
33885
  rows: []
33995
33886
  };
33996
33887
  }
33997
-
33998
33888
  var rows = [];
33999
33889
  var xlsxLines;
34000
-
34001
33890
  var emptyCols = _calculateEmptyCols(cols);
34002
-
34003
33891
  try {
34004
33892
  xlsxLines = yield XLSXUtils.read(fileBlob, true, emptyCols.length > 0);
34005
33893
  if (emptyCols.length > 0) xlsxLines = _processTableToTransformNonAcceptableEmptyCols(xlsxLines, emptyCols);
@@ -34008,13 +33896,10 @@ var fromXLSX = /*#__PURE__*/function () {
34008
33896
  error: [new Error$1((err === null || err === void 0 ? void 0 : err.message) || err, fileBlob.name, (err === null || err === void 0 ? void 0 : err.stack) || null)]
34009
33897
  };
34010
33898
  }
34011
-
34012
33899
  if (!cols) {
34013
33900
  cols = _buildCols(xlsxLines[0]);
34014
33901
  }
34015
-
34016
33902
  var errors = _validateFormat(xlsxLines, hasHeader, cols, options);
34017
-
34018
33903
  if (errors.length > 0) return {
34019
33904
  error: errors
34020
33905
  };
@@ -34024,12 +33909,10 @@ var fromXLSX = /*#__PURE__*/function () {
34024
33909
  rows: rows
34025
33910
  };
34026
33911
  });
34027
-
34028
33912
  return function fromXLSX(_x) {
34029
33913
  return _ref.apply(this, arguments);
34030
33914
  };
34031
33915
  }();
34032
-
34033
33916
  var AgGridUtils = {
34034
33917
  fromCSV,
34035
33918
  fromXLSX,
@@ -34073,24 +33956,19 @@ var fileDownload = function(data, filename, mime, bom) {
34073
33956
  };
34074
33957
 
34075
33958
  // Copyright (c) Cosmo Tech.
34076
-
34077
33959
  function downloadFileFromData(fileData, fileName) {
34078
33960
  fileDownload(fileData, fileName);
34079
33961
  }
34080
-
34081
33962
  function readFileBlobAsync(fileBlob) {
34082
33963
  return new Promise((resolve, reject) => {
34083
33964
  var reader = new FileReader();
34084
-
34085
33965
  reader.onload = () => {
34086
33966
  resolve(reader.result);
34087
33967
  };
34088
-
34089
33968
  reader.onerror = reject;
34090
33969
  reader.readAsText(fileBlob);
34091
33970
  });
34092
33971
  }
34093
-
34094
33972
  var FileBlobUtils = {
34095
33973
  downloadFileFromData,
34096
33974
  readFileBlobAsync
@@ -34098,38 +33976,31 @@ var FileBlobUtils = {
34098
33976
 
34099
33977
  // Copyright (c) Cosmo Tech.
34100
33978
  // Licensed under the MIT license.
33979
+
34101
33980
  var getBaseNameFromFileName = fileName => {
34102
33981
  if (fileName.indexOf('.') === -1) {
34103
33982
  return fileName;
34104
33983
  }
34105
-
34106
33984
  var nameParts = fileName.split('.');
34107
33985
  var extension = nameParts.pop();
34108
33986
  var baseName = nameParts.join('.');
34109
-
34110
33987
  if (extension.length === 0 || baseName.length === 0) {
34111
33988
  return fileName;
34112
33989
  }
34113
-
34114
33990
  return baseName;
34115
33991
  };
34116
-
34117
33992
  var getExtensionFromFileName = fileName => {
34118
33993
  if (fileName.indexOf('.') === -1) {
34119
33994
  return '';
34120
33995
  }
34121
-
34122
33996
  var nameParts = fileName.split('.');
34123
33997
  var extension = nameParts.pop();
34124
33998
  var baseName = nameParts.join('.');
34125
-
34126
33999
  if (extension.length === 0 || baseName.length === 0) {
34127
34000
  return '';
34128
34001
  }
34129
-
34130
34002
  return extension;
34131
34003
  };
34132
-
34133
34004
  var PathUtils = {
34134
34005
  getBaseNameFromFileName,
34135
34006
  getExtensionFromFileName
@@ -34137,6 +34008,7 @@ var PathUtils = {
34137
34008
 
34138
34009
  // Copyright (c) Cosmo Tech.
34139
34010
  // Licensed under the MIT license.
34011
+
34140
34012
  // Functions to read & write from storage.
34141
34013
  // Notes : local storage works on Chromium but not on Firefox if "Delete
34142
34014
  // cookies and site data when Firefox is closed" is selected (for more
@@ -34144,22 +34016,19 @@ var PathUtils = {
34144
34016
  function writeToStorage(key, value) {
34145
34017
  localStorage.setItem(key, value);
34146
34018
  }
34147
-
34148
34019
  function readFromStorage(key) {
34149
34020
  return localStorage.getItem(key);
34150
34021
  }
34151
-
34152
34022
  function clearFromStorage(key) {
34153
34023
  localStorage.removeItem(key);
34154
- } // Currently selected provider
34155
-
34156
-
34157
- var currentProvider; // Dict of registered providers
34158
-
34159
- var providers = {}; // List of callbacks to call on authentication data change
34024
+ }
34160
34025
 
34026
+ // Currently selected provider
34027
+ var currentProvider;
34028
+ // Dict of registered providers
34029
+ var providers = {};
34030
+ // List of callbacks to call on authentication data change
34161
34031
  var onAuthChangeCallbacks = [];
34162
-
34163
34032
  function addProvider(newProvider) {
34164
34033
  // Check that provider name is defined
34165
34034
  if (newProvider.name === undefined) {
@@ -34172,135 +34041,105 @@ function addProvider(newProvider) {
34172
34041
  // Otherwise, store new provider
34173
34042
  providers[newProvider.name] = newProvider;
34174
34043
  }
34175
-
34176
34044
  return providers[newProvider.name];
34177
34045
  }
34178
-
34179
34046
  function setProvider(providerName) {
34180
34047
  // Set new provider if it exists
34181
34048
  if (providers[providerName] === undefined) {
34182
34049
  console.error('Provider "' + providerName + '" does not exist, you have ' + 'to register authentication providers with "addProvider" function ' + 'before using them');
34183
34050
  currentProvider = undefined;
34184
34051
  } else {
34185
- currentProvider = providers[providerName]; // Update callbacks for the new provider
34186
-
34052
+ currentProvider = providers[providerName];
34053
+ // Update callbacks for the new provider
34187
34054
  if (currentProvider.setAuthChangeCallbacks) {
34188
34055
  currentProvider.setAuthChangeCallbacks(onAuthChangeCallbacks);
34189
- } // Store the provider used in local storage
34190
-
34191
-
34056
+ }
34057
+ // Store the provider used in local storage
34192
34058
  writeToStorage('authProvider', providerName);
34193
34059
  }
34194
- } // If no provider is currently selected but local storage has the information
34060
+ }
34061
+
34062
+ // If no provider is currently selected but local storage has the information
34195
34063
  // of a provider used (in another tab or before a page refresh, for instance),
34196
34064
  // this provider will be selected
34197
-
34198
-
34199
34065
  function initProviderIfNull() {
34200
34066
  if (currentProvider === undefined) {
34201
34067
  var newProviderName = readFromStorage('authProvider');
34202
-
34203
34068
  if (newProviderName !== undefined && newProviderName !== null) {
34204
34069
  setProvider(newProviderName);
34205
34070
  }
34206
34071
  }
34207
34072
  }
34208
-
34209
34073
  function signIn$1() {
34210
34074
  return currentProvider.signIn();
34211
34075
  }
34212
-
34213
34076
  function signOut$1() {
34214
- initProviderIfNull(); // Clear last auth provider used from local storage
34215
-
34077
+ initProviderIfNull();
34078
+ // Clear last auth provider used from local storage
34216
34079
  clearFromStorage('authProvider');
34217
34080
  return currentProvider.signOut();
34218
34081
  }
34219
-
34220
34082
  function onAuthStateChanged(newCallback) {
34221
34083
  onAuthChangeCallbacks.push(newCallback);
34222
34084
  }
34223
-
34224
34085
  function isAsync$1() {
34225
34086
  initProviderIfNull();
34226
-
34227
34087
  if (currentProvider && currentProvider.isAsync) {
34228
34088
  return currentProvider.isAsync();
34229
34089
  }
34230
-
34231
34090
  return false;
34232
34091
  }
34233
-
34234
34092
  function acquireTokens$1(callback) {
34235
34093
  initProviderIfNull();
34236
-
34237
34094
  if (currentProvider === undefined) {
34238
34095
  return undefined;
34239
34096
  }
34240
-
34241
34097
  return currentProvider.acquireTokens(callback);
34242
34098
  }
34243
-
34244
34099
  function acquireTokensByRequest$1(tokenReq) {
34245
34100
  initProviderIfNull();
34246
-
34247
34101
  if (currentProvider === undefined) {
34248
34102
  return undefined;
34249
34103
  }
34250
-
34251
34104
  return currentProvider.acquireTokensByRequest(tokenReq);
34252
34105
  }
34253
-
34254
34106
  function isUserSignedIn$1(callback) {
34255
34107
  initProviderIfNull();
34256
-
34257
34108
  if (currentProvider === undefined) {
34258
34109
  return false;
34259
34110
  }
34260
-
34261
34111
  return currentProvider.isUserSignedIn(callback);
34262
34112
  }
34263
-
34264
34113
  function getUserEmail() {
34265
34114
  if (currentProvider === undefined) {
34266
34115
  return undefined;
34267
34116
  }
34268
-
34269
34117
  return currentProvider.getUserEmail();
34270
34118
  }
34271
-
34272
34119
  function getUserName$1() {
34273
34120
  if (currentProvider === undefined) {
34274
34121
  return undefined;
34275
34122
  }
34276
-
34277
34123
  return currentProvider.getUserName();
34278
34124
  }
34279
-
34280
34125
  function getUserRoles$1() {
34281
34126
  if (currentProvider === undefined) {
34282
34127
  return undefined;
34283
34128
  }
34284
-
34285
34129
  return currentProvider.getUserRoles();
34286
34130
  }
34287
-
34288
34131
  function getUserId$1() {
34289
34132
  if (currentProvider === undefined) {
34290
34133
  return undefined;
34291
34134
  }
34292
-
34293
34135
  return currentProvider.getUserId();
34294
34136
  }
34295
-
34296
34137
  function getUserPicUrl$1() {
34297
34138
  if (currentProvider === undefined) {
34298
34139
  return undefined;
34299
34140
  }
34300
-
34301
34141
  return currentProvider.getUserPicUrl();
34302
34142
  }
34303
-
34304
34143
  var Auth = {
34305
34144
  addProvider,
34306
34145
  setProvider,
@@ -34320,9 +34159,9 @@ var Auth = {
34320
34159
 
34321
34160
  // Copyright (c) Cosmo Tech.
34322
34161
  // Licensed under the MIT license.
34162
+
34323
34163
  var name = 'auth-dev';
34324
34164
  var authData = null;
34325
-
34326
34165
  function setDefaultUser() {
34327
34166
  authData = {
34328
34167
  userId: 1,
@@ -34330,61 +34169,47 @@ function setDefaultUser() {
34330
34169
  roles: ['Organization.User']
34331
34170
  };
34332
34171
  }
34333
-
34334
34172
  function signIn() {
34335
34173
  setDefaultUser();
34336
34174
  window.location.href = '/';
34337
34175
  }
34338
-
34339
34176
  function signOut() {
34340
34177
  window.location.href = '/';
34341
34178
  }
34342
-
34343
34179
  function isAsync() {
34344
34180
  return false;
34345
34181
  }
34346
-
34347
34182
  function isUserSignedIn() {
34348
34183
  setDefaultUser();
34349
34184
  return true;
34350
34185
  }
34351
-
34352
34186
  function getUserName() {
34353
34187
  if (authData) {
34354
34188
  return authData.userName;
34355
34189
  }
34356
-
34357
34190
  return undefined;
34358
34191
  }
34359
-
34360
34192
  function acquireTokens() {
34361
34193
  return undefined;
34362
34194
  }
34363
-
34364
34195
  function acquireTokensByRequest(tokenReq) {
34365
34196
  return undefined;
34366
34197
  }
34367
-
34368
34198
  function getUserId() {
34369
34199
  if (authData) {
34370
34200
  return authData.userId;
34371
34201
  }
34372
-
34373
34202
  return undefined;
34374
34203
  }
34375
-
34376
34204
  function getUserRoles() {
34377
34205
  if (authData) {
34378
34206
  return authData.roles;
34379
34207
  }
34380
-
34381
34208
  return undefined;
34382
34209
  }
34383
-
34384
34210
  function getUserPicUrl() {
34385
34211
  return undefined;
34386
34212
  }
34387
-
34388
34213
  var AuthDev = {
34389
34214
  name,
34390
34215
  signIn,
@@ -34401,43 +34226,37 @@ var AuthDev = {
34401
34226
 
34402
34227
  // Copyright (c) Cosmo Tech.
34403
34228
  // Licensed under the MIT license.
34229
+
34404
34230
  var getDatasetNames = (datasets, scenarioDatasets) => {
34405
34231
  if (!scenarioDatasets || !datasets) {
34406
34232
  return '';
34407
34233
  }
34408
-
34409
34234
  var names = [];
34410
-
34411
34235
  var _loop = function _loop(datasetId) {
34412
34236
  var dataset = datasets.find(el => el.id === datasetId);
34413
-
34414
34237
  if (dataset) {
34415
34238
  names.push(dataset.name);
34416
34239
  }
34417
34240
  };
34418
-
34419
34241
  for (var datasetId of scenarioDatasets) {
34420
34242
  _loop(datasetId);
34421
34243
  }
34422
-
34423
34244
  return names.join(', ');
34424
34245
  };
34425
-
34426
34246
  var DatasetUtils = {
34427
34247
  getDatasetNames
34428
34248
  };
34429
34249
 
34430
34250
  // Copyright (c) Cosmo Tech.
34431
34251
  // Licensed under the MIT license.
34252
+
34432
34253
  var NAME_VALIDATOR = /^[a-zA-Z0-9][\w\s.-]*$/;
34433
34254
 
34434
34255
  // Copyright (c) Cosmo Tech.
34435
-
34436
34256
  var scenarioExistsInList = (scenarioName, scenarioList) => {
34437
34257
  scenarioName = scenarioName.trim();
34438
34258
  return scenarioList.find(scenario => scenario.name.trim() === scenarioName) !== undefined;
34439
34259
  };
34440
-
34441
34260
  var scenarioExistsInTree = (scenarioName, scenarioTree) => {
34442
34261
  var treeSearch = node => {
34443
34262
  for (var scenario of node) {
@@ -34445,16 +34264,12 @@ var scenarioExistsInTree = (scenarioName, scenarioTree) => {
34445
34264
  return true;
34446
34265
  }
34447
34266
  }
34448
-
34449
34267
  return false;
34450
34268
  };
34451
-
34452
34269
  return treeSearch(scenarioTree);
34453
34270
  };
34454
-
34455
34271
  var scenarioNameIsValid = (scenarioName, scenarioList) => {
34456
34272
  scenarioName = scenarioName.trimEnd();
34457
-
34458
34273
  if (scenarioName.length === 0) {
34459
34274
  return 'emptyScenarioName';
34460
34275
  } else {
@@ -34464,50 +34279,39 @@ var scenarioNameIsValid = (scenarioName, scenarioList) => {
34464
34279
  return 'existingScenarioName';
34465
34280
  }
34466
34281
  }
34467
-
34468
34282
  return null;
34469
34283
  };
34470
-
34471
34284
  var getScenarioTree = (scenarioList, compareFn) => {
34472
- var scenarioTree = []; // Sort scenario list based on optional user-defined function
34473
-
34474
- scenarioList.sort(compareFn); // Set master & orphan scenarios as root scenarios, and add all their children
34475
-
34285
+ var scenarioTree = [];
34286
+ // Sort scenario list based on optional user-defined function
34287
+ scenarioList.sort(compareFn);
34288
+ // Set master & orphan scenarios as root scenarios, and add all their children
34476
34289
  var _loop = function _loop(parentScenario) {
34477
34290
  if (!parentScenario.parentId || scenarioList.find(grandParent => grandParent.id === parentScenario.parentId) === undefined) {
34478
34291
  scenarioTree.push(parentScenario);
34479
34292
  }
34480
-
34481
34293
  parentScenario.children = [];
34482
-
34483
34294
  for (var childScenario of scenarioList) {
34484
34295
  if (childScenario.parentId === parentScenario.id) {
34485
34296
  parentScenario.children.push(childScenario);
34486
34297
  }
34487
34298
  }
34488
34299
  };
34489
-
34490
34300
  for (var parentScenario of scenarioList) {
34491
34301
  _loop(parentScenario);
34492
34302
  }
34493
-
34494
34303
  return scenarioTree;
34495
34304
  };
34496
-
34497
34305
  function countScenariosInTree(treeData) {
34498
34306
  if (!treeData) {
34499
34307
  return 0;
34500
34308
  }
34501
-
34502
34309
  var count = treeData.length;
34503
-
34504
34310
  for (var node of treeData) {
34505
34311
  count += countScenariosInTree(node.children);
34506
34312
  }
34507
-
34508
34313
  return count;
34509
34314
  }
34510
-
34511
34315
  var ScenarioUtils = {
34512
34316
  scenarioExistsInList,
34513
34317
  scenarioExistsInTree,