@hestia-earth/ui-components 0.0.10 → 0.0.11

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.
@@ -572,7 +572,7 @@
572
572
  }] });
573
573
 
574
574
  var _a$6;
575
- var get$4 = require('lodash.get');
575
+ var get$5 = require('lodash.get');
576
576
  var gitHome = 'https://gitlab.com/hestia-earth';
577
577
  var gitRawBaseUrl = 'https://glcdn.githack.com/hestia-earth';
578
578
  var gitBranch = function () { return ['dev', 'staging'].some(function (env) { return baseUrl().includes(env); }) ? 'develop' : 'master'; };
@@ -584,7 +584,7 @@
584
584
  'https://www.hestia.earth'; };
585
585
  var isExternal = function () { return baseUrl() !== window.location.origin; };
586
586
  var parseErrorStatus = function (error) { return ((error === null || error === void 0 ? void 0 : error.statusText) || '').toLowerCase().replace(/\s/g, '-'); };
587
- var parseErrorMessage = function (error) { return get$4(error, 'error.error', get$4(error, 'error.message', get$4(error, 'error', get$4(error, 'message', error)))); };
587
+ var parseErrorMessage = function (error) { return get$5(error, 'error.error', get$5(error, 'error.message', get$5(error, 'error', get$5(error, 'message', error)))); };
588
588
  var handleAPIError = function (error) {
589
589
  try {
590
590
  error = parseErrorMessage(error);
@@ -686,7 +686,7 @@
686
686
  group[termId].values[nodeId].nodes.push(blankNode);
687
687
  group[termId].values[nodeId].value = concatBlankNodeValue(group[termId].values[nodeId].value, blankNode.value);
688
688
  grouppedValueKeys.forEach(function (arrayKey) {
689
- var newValue = get$4(blankNode, arrayKey, []);
689
+ var newValue = get$5(blankNode, arrayKey, []);
690
690
  group[termId].values[nodeId][arrayKey] = __spreadArray(__spreadArray([], __read((group[termId].values[nodeId][arrayKey] || []))), __read((Array.isArray(newValue) ? newValue : [newValue])));
691
691
  });
692
692
  return group;
@@ -696,7 +696,7 @@
696
696
  Object.keys(group.values).map(function (nodeId) {
697
697
  var index = group.values[nodeId].index;
698
698
  var termId = group.term['@id'];
699
- var originalValue = get$4(originalValues, "[" + index + "]." + key, []).filter(function (val) { return val.term['@id'] === termId; });
699
+ var originalValue = get$5(originalValues, "[" + index + "]." + key, []).filter(function (val) { return val.term['@id'] === termId; });
700
700
  if (originalValue.length > 0) {
701
701
  var value = originalValue.reduce(function (array, curr) { return concatBlankNodeValue(array, curr.value); }, []);
702
702
  group.originalValues[nodeId] = { value: propertyValue$1(value) };
@@ -2347,13 +2347,13 @@
2347
2347
  args: ['document:click', ['$event']]
2348
2348
  }] } });
2349
2349
 
2350
- var get$3 = require('lodash.get');
2350
+ var get$4 = require('lodash.get');
2351
2351
  var GetPipe = /** @class */ (function () {
2352
2352
  function GetPipe() {
2353
2353
  }
2354
2354
  GetPipe.prototype.transform = function (value, key, defaultValue) {
2355
2355
  if (defaultValue === void 0) { defaultValue = ''; }
2356
- return get$3(value, key, defaultValue);
2356
+ return get$4(value, key, defaultValue);
2357
2357
  };
2358
2358
  return GetPipe;
2359
2359
  }());
@@ -5280,7 +5280,7 @@
5280
5280
  type: i0.Input
5281
5281
  }] } });
5282
5282
 
5283
- var get$2 = require('lodash.get');
5283
+ var get$3 = require('lodash.get');
5284
5284
  var orderBy$4 = require('lodash.orderby');
5285
5285
  var reduceValues = function (values) { return values.length ? values.reduce(function (p, v) { return p + propertyValue$1(v.value); }, 0) : null; };
5286
5286
  var logSubValue = function (logs, key, prop) { return logs[key][prop] ? {
@@ -5351,7 +5351,7 @@
5351
5351
  case 4:
5352
5352
  _e.allTerms = _f.sent();
5353
5353
  this.allBlankNodes = this.allTerms.flatMap(function (term) {
5354
- var emissionLogs = get$2(_this.logs, term['@id'], {});
5354
+ var emissionLogs = get$3(_this.logs, term['@id'], {});
5355
5355
  var original = originalValues.filter(function (v) { return term['@id'] === v.term['@id']; });
5356
5356
  var recalculated = recalculatedValues.filter(function (v) { return term['@id'] === v.term['@id']; });
5357
5357
  var hasData = !!original.length || !!recalculated.length || Object.keys(emissionLogs).length > 0;
@@ -5411,7 +5411,7 @@
5411
5411
  };
5412
5412
  NodeLogsModelsComponent.prototype.validSubValue = function (node, index, subValue) {
5413
5413
  var methodId = this.getMethodIdAt(node, index, subValue);
5414
- return !(subValue === null || subValue === void 0 ? void 0 : subValue.value) || get$2(node.logs[methodId], subValue === null || subValue === void 0 ? void 0 : subValue.key, null) === (subValue === null || subValue === void 0 ? void 0 : subValue.value);
5414
+ return !(subValue === null || subValue === void 0 ? void 0 : subValue.value) || get$3(node.logs[methodId], subValue === null || subValue === void 0 ? void 0 : subValue.key, null) === (subValue === null || subValue === void 0 ? void 0 : subValue.value);
5415
5415
  };
5416
5416
  NodeLogsModelsComponent.prototype.getMethodIdAt = function (node, index, subValue) {
5417
5417
  var configModels = (subValue || node).configModels;
@@ -6316,6 +6316,7 @@
6316
6316
  var _f;
6317
6317
  var mapErrorMessage = 'does not contain latitude and longitude';
6318
6318
  var parseDataPath = function (dataPath) {
6319
+ if (dataPath === void 0) { dataPath = ''; }
6319
6320
  var _f = __read(dataPath.split('.')), _ = _f[0], paths = _f.slice(1);
6320
6321
  return paths.map(function (path) { return ({ path: path, label: keyToLabel(path.replace(/\[\d+\]/g, '')) }); });
6321
6322
  };
@@ -6510,7 +6511,7 @@
6510
6511
 
6511
6512
  var _d;
6512
6513
  /* eslint-disable complexity */
6513
- var get$1 = require('lodash.get');
6514
+ var get$2 = require('lodash.get');
6514
6515
  var ARRAY_DELIMITER = ';';
6515
6516
  var privateKeys = [
6516
6517
  'filepath'
@@ -6520,6 +6521,7 @@
6520
6521
  var nonExpandableArrayDataPath = function (key) { return key.replace(/\[\d+\]$/, ''); };
6521
6522
  var keyToDataPath = function (key) { return (key === null || key === void 0 ? void 0 : key.length) ? "." + key : ''; };
6522
6523
  var dataPathToKey = function (dataPath, trimArray) {
6524
+ if (dataPath === void 0) { dataPath = ''; }
6523
6525
  if (trimArray === void 0) { trimArray = false; }
6524
6526
  return trimArray ? nonExpandableArrayDataPath(dataPath.substring(1)) : dataPath.substring(1);
6525
6527
  };
@@ -6694,7 +6696,7 @@
6694
6696
  };
6695
6697
  var nodeAvailableProperties = function (node, _d) {
6696
6698
  var fullKey = _d.fullKey, schema = _d.schema, schemaType = _d.schemaType;
6697
- return availableProperties(schema, schemaType, fullKey ? get$1(node, fullKey, {}) : node, fullKey.length > 0);
6699
+ return availableProperties(schema, schemaType, fullKey ? get$2(node, fullKey, {}) : node, fullKey.length > 0);
6698
6700
  };
6699
6701
  var isAddPropertyEnabled = function (node, schemaType, schema, fullKey) {
6700
6702
  if (fullKey === void 0) { fullKey = ''; }
@@ -6735,7 +6737,7 @@
6735
6737
  var _d = __read(fullKey.split('.')), parent = _d[0], keys = _d.slice(1);
6736
6738
  var properties = schema.properties || {};
6737
6739
  var examples = (parent in properties ? properties[parent] : { examples: [] }).examples;
6738
- return (examples === null || examples === void 0 ? void 0 : examples.length) && typeof examples[0] === 'object' ? get$1(examples[0], keys.join('.'), null) : null;
6740
+ return (examples === null || examples === void 0 ? void 0 : examples.length) && typeof examples[0] === 'object' ? get$2(examples[0], keys.join('.'), null) : null;
6739
6741
  };
6740
6742
  var propertyPlaceholder = function (schema, valueType, fullKey, parentSchema) {
6741
6743
  if (fullKey === void 0) { fullKey = ''; }
@@ -6900,7 +6902,7 @@
6900
6902
  var _d = __read(fullKey.split('.')), _t = _d[0], keys = _d.slice(1);
6901
6903
  var key = keys.pop();
6902
6904
  var parent = keys.join('.');
6903
- var parentNode = parent.length ? get$1(node, parent) : node;
6905
+ var parentNode = parent.length ? get$2(node, parent) : node;
6904
6906
  var schemaType = schema.typeToSchemaType(parentNode.type || parentNode['@type']);
6905
6907
  var parentSchema = schemas[schemaType];
6906
6908
  return propertyFromNode(schemas, errors, parentSchema, true, parent, parentNode)(key);
@@ -7112,6 +7114,73 @@
7112
7114
  return moment__namespace(endDate.value).locale('en-gb').subtract(cycleDuration.value, 'days').format('YYYY-MM-DD');
7113
7115
  };
7114
7116
 
7117
+ var get$1 = require('lodash.get');
7118
+ var nodeTerm = function (node, key) {
7119
+ var termType = get$1(node, key + ".type", get$1(node, key + ".@type", null));
7120
+ return termType === schema.SchemaType.Term ? get$1(node, key, null) : null;
7121
+ };
7122
+ var findNodeTerm = function (node, _b) {
7123
+ var dataPath = _b.dataPath;
7124
+ return nodeTerm(node, dataPathToKey(dataPath)) ||
7125
+ nodeTerm(node, dataPathToKey(dataPath) + ".term") ||
7126
+ nodeTerm(node, dataPathToKey(dataPath, true)) ||
7127
+ nodeTerm(node, dataPathToKey(dataPath, true) + ".term");
7128
+ };
7129
+ var uniqueTerms = function (errors) { return utils.unique(errors
7130
+ .map(function (_b) {
7131
+ var term = _b.term;
7132
+ return term ? nodeLink(term) || code(term.name || term['@id'] || term.id) : null;
7133
+ })
7134
+ .filter(Boolean)); };
7135
+ var summaryShowErrors = function (summaryData, _b) {
7136
+ var path = _b.path, level = _b.level, message = _b.message;
7137
+ var _a;
7138
+ return ((_a = summaryData.find(function (summary) { return summary.path === path && summary.level === level && summary.message === message; })) === null || _a === void 0 ? void 0 : _a.showErrors) || true;
7139
+ };
7140
+ /**
7141
+ * Build the summary objects.
7142
+ *
7143
+ * @param nodes The list of nodes.
7144
+ * @param errors The list of errors per node.
7145
+ * @param summaryData The previously computed summary objects.
7146
+ * @returns
7147
+ */
7148
+ var buildSummary = function (nodes, errors, summaryData) {
7149
+ if (nodes === void 0) { nodes = []; }
7150
+ if (errors === void 0) { errors = []; }
7151
+ if (summaryData === void 0) { summaryData = []; }
7152
+ return rxjs.from(errors).pipe(operators.mergeMap(function (error) { return 'error' in error ? error.error : error; }), operators.filter(filterError), operators.reduce(function (prev, error) {
7153
+ var _a;
7154
+ var message = error.message;
7155
+ var _b = __read(parseDataPath(error.dataPath), 1), dataPath = _b[0];
7156
+ var node = get$1(nodes, error.nodeIndex, null);
7157
+ var label = dataPath ? dataPath.label : node === null || node === void 0 ? void 0 : node.type;
7158
+ var term = ((_a = error.params) === null || _a === void 0 ? void 0 : _a.term) || findNodeTerm(node, error);
7159
+ prev[message] = prev[message] || { level: error.level, paths: {} };
7160
+ prev[message].paths[label] = prev[message].paths[label] || [];
7161
+ prev[message].paths[label].push({ node: node, error: error, term: term });
7162
+ return prev;
7163
+ }, {}), operators.mergeMap(function (data) { return rxjs.from(Object.keys(data)).pipe(operators.filter(function (message) { return !!message; }), operators.mergeMap(function (message) { return Object.keys(data[message].paths).map(function (path) {
7164
+ var _a;
7165
+ return ({
7166
+ level: data[message].level,
7167
+ path: path,
7168
+ message: message,
7169
+ formattedMessage: (_a = formatError(data[message].paths[path][0].error, data[message].paths[path].length)) === null || _a === void 0 ? void 0 : _a.message,
7170
+ terms: uniqueTerms(data[message].paths[path]).join(' ; '),
7171
+ errors: data[message].paths[path],
7172
+ count: data[message].paths[path].length,
7173
+ showErrors: summaryShowErrors(summaryData, { level: data[message].level, path: path, message: message })
7174
+ });
7175
+ }); }), operators.filter(function (_b) {
7176
+ var formattedMessage = _b.formattedMessage;
7177
+ return !!formattedMessage;
7178
+ })); }), operators.toArray(), operators.map(function (values) { return values.sort(function (_b) {
7179
+ var level = _b.level;
7180
+ return level === 'error' ? -1 : 1;
7181
+ }); }));
7182
+ };
7183
+
7115
7184
  var isSite = function (_a) {
7116
7185
  var type = _a["@type"], id = _a["@id"];
7117
7186
  return type === schema.NodeType.Site && !!id;
@@ -8924,6 +8993,7 @@
8924
8993
  exports.availableProperties = availableProperties;
8925
8994
  exports.baseUrl = baseUrl;
8926
8995
  exports.bottom = bottom;
8996
+ exports.buildSummary = buildSummary;
8927
8997
  exports.calculateCycleDuration = calculateCycleDuration;
8928
8998
  exports.calculateCycleDurationEnabled = calculateCycleDurationEnabled;
8929
8999
  exports.calculateCycleStartDate = calculateCycleStartDate;