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