@sis-cc/dotstatsuite-components 9.3.5 → 12.0.0

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.
Files changed (56) hide show
  1. package/lib/index.js +8 -3
  2. package/lib/rules/src/table/factories/getCells.js +22 -4
  3. package/lib/rules/src/table/factories/getLayoutWithFlags.js +32 -5
  4. package/lib/rules/src/table/factories/getTableData.js +9 -2
  5. package/lib/rules/src/table/preparators/prepareData.js +37 -2
  6. package/lib/rules/src/v8-transformer.js +5 -9
  7. package/lib/rules2/src/constants.js +7 -0
  8. package/lib/rules2/src/getAdvAttrSeriesAtCoordinates.js +39 -0
  9. package/lib/rules2/src/getAdvancedAttributes.js +126 -0
  10. package/lib/rules2/src/getMetadataCoordinates.js +38 -0
  11. package/lib/rules2/src/getMetadataStructureFromData.js +23 -0
  12. package/lib/rules2/src/getSidebarData.js +76 -0
  13. package/lib/rules2/src/hasCellMetadata.js +19 -0
  14. package/lib/rules2/src/hasLayoutEntryMetadata.js +18 -0
  15. package/lib/rules2/src/index.js +47 -0
  16. package/lib/rules2/src/parseMetadataSeries.js +83 -0
  17. package/lib/rules2/src/refineMetadataCoordinates.js +34 -0
  18. package/lib/rules2/src/sdmx3.0DataFormatPatch.js +20 -0
  19. package/lib/viewer/src/chart.js +48 -41
  20. package/lib/viewer/src/index.js +76 -56
  21. package/package.json +9 -10
  22. package/src/index.js +2 -0
  23. package/src/rules/src/table/factories/getCells.js +13 -4
  24. package/src/rules/src/table/factories/getLayoutWithFlags.js +36 -10
  25. package/src/rules/src/table/factories/getTableData.js +12 -3
  26. package/src/rules/src/table/preparators/prepareData.js +45 -4
  27. package/src/rules/src/v8-transformer.js +3 -8
  28. package/src/rules2/src/constants.js +2 -0
  29. package/src/rules2/src/getAdvAttrSeriesAtCoordinates.js +29 -0
  30. package/src/rules2/src/getAdvancedAttributes.js +113 -0
  31. package/src/rules2/src/getMetadataCoordinates.js +37 -0
  32. package/src/rules2/src/getMetadataStructureFromData.js +17 -0
  33. package/src/rules2/src/getSidebarData.js +73 -0
  34. package/src/rules2/src/hasCellMetadata.js +11 -0
  35. package/src/rules2/src/hasLayoutEntryMetadata.js +9 -0
  36. package/src/rules2/src/index.js +8 -0
  37. package/src/rules2/src/parseMetadataSeries.js +80 -0
  38. package/src/rules2/src/refineMetadataCoordinates.js +27 -0
  39. package/src/rules2/src/sdmx3.0DataFormatPatch.js +9 -0
  40. package/src/viewer/src/chart.js +15 -14
  41. package/src/viewer/src/index.js +35 -26
  42. package/test/advanced-attributes-parsing-perf.test.js +16 -0
  43. package/test/getCells.test.js +7 -5
  44. package/test/getDataflowAdvancedAttributes.test.js +32 -0
  45. package/test/getLayoutDataWithFlags.test.js +22 -12
  46. package/test/getMetadataCoordinates.test.js +0 -0
  47. package/test/getSeriesAdvancedAttributes.test.js +30 -0
  48. package/test/getSidebarData.test.js +116 -0
  49. package/test/getSubtitleFlags.test.js +1 -1
  50. package/test/getTableData.test.js +2 -1
  51. package/test/metadata-parsing-perf.test.js +487 -0
  52. package/test/mocks/OECD_SNA_TABLE1_1.0_-_AUS_V_metadata.json +152 -0
  53. package/test/mocks/large_metadata_series.json +701 -0
  54. package/test/mocks/observations-advanced-attributes.json +55382 -0
  55. package/test/parseMetadataSeries.test.js +55 -0
  56. package/test/prepareData.test.js +2 -0
package/lib/index.js CHANGED
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.Viewer = exports.RulesDriver = exports.bridgeD3React = exports.rules = undefined;
6
+ exports.Viewer = exports.RulesDriver = exports.bridgeD3React = exports.rules2 = exports.rules = undefined;
7
7
 
8
8
  var _src = require('./rules-driver/src');
9
9
 
@@ -31,9 +31,13 @@ var _src3 = require('./rules/src');
31
31
 
32
32
  var rules = _interopRequireWildcard(_src3);
33
33
 
34
- var _src4 = require('./bridge-d3-react/src');
34
+ var _src4 = require('./rules2/src');
35
35
 
36
- var bridgeD3React = _interopRequireWildcard(_src4);
36
+ var rules2 = _interopRequireWildcard(_src4);
37
+
38
+ var _src5 = require('./bridge-d3-react/src');
39
+
40
+ var bridgeD3React = _interopRequireWildcard(_src5);
37
41
 
38
42
  function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
39
43
 
@@ -42,4 +46,5 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
42
46
  console.info(_package2.default.name + '@' + _package2.default.version);
43
47
 
44
48
  exports.rules = rules;
49
+ exports.rules2 = rules2;
45
50
  exports.bridgeD3React = bridgeD3React;
@@ -5,14 +5,22 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.getCells = exports.getFlags = undefined;
7
7
 
8
+ var _toConsumableArray2 = require('babel-runtime/helpers/toConsumableArray');
9
+
10
+ var _toConsumableArray3 = _interopRequireDefault(_toConsumableArray2);
11
+
8
12
  var _ramda = require('ramda');
9
13
 
10
14
  var R = _interopRequireWildcard(_ramda);
11
15
 
12
16
  var _dimensionUtils = require('../../dimension-utils');
13
17
 
18
+ var _hasCellMetadata = require('../../../../rules2/src/hasCellMetadata');
19
+
14
20
  function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
15
21
 
22
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
+
16
24
  var getAttrLabel = function getAttrLabel(display) {
17
25
  return function (attribute) {
18
26
  return display(attribute) + ': ' + display(R.propOr({}, 'value', attribute));
@@ -28,7 +36,7 @@ var getFlags = exports.getFlags = function getFlags(customAttributesIds, display
28
36
 
29
37
  var refinedAttributes = R.omit(R.propOr([], 'rejected', customAttributesIds), attributes);
30
38
  var flags = R.pipe(R.pick(R.propOr([], 'flags', customAttributesIds)), R.values)(refinedAttributes);
31
- var footnotes = R.pipe(R.omit(R.propOr([], 'flags', customAttributesIds)), R.values)(refinedAttributes);
39
+ var footnotes = R.pipe(R.pick(R.propOr([], 'footnotes', customAttributesIds)), R.values)(refinedAttributes);
32
40
 
33
41
  var unitsDisplay = R.prop('unitsDisplay', unitsProps);
34
42
  var rejectedUnitsValueIds = R.propOr([], 'rejectedValueIds', unitsProps);
@@ -66,10 +74,20 @@ var getFlags = exports.getFlags = function getFlags(customAttributesIds, display
66
74
  };
67
75
  };
68
76
 
69
- var isValidNumber = R.both(R.is(Number), R.complement(R.equals(NaN)));
77
+ var getSideProps = function getSideProps(_ref2, customAttributes, metadataCoordinates) {
78
+ var attributes = _ref2.attributes,
79
+ indexedDimValIds = _ref2.indexedDimValIds;
80
+
81
+ var rejected = [].concat((0, _toConsumableArray3.default)(customAttributes.flags || []), (0, _toConsumableArray3.default)(customAttributes.footnotes || []), (0, _toConsumableArray3.default)(customAttributes.rejected || []));
82
+ var advancedAttributes = R.omit(rejected, attributes);
83
+ var hasAdvancedAttributes = !R.isEmpty(advancedAttributes);
84
+ var hasMetadata = (0, _hasCellMetadata.hasCellMetadata)(metadataCoordinates, indexedDimValIds);
85
+
86
+ return hasAdvancedAttributes || hasMetadata ? { hasAdvancedAttributes: hasAdvancedAttributes, hasMetadata: hasMetadata, coordinates: indexedDimValIds } : null;
87
+ };
70
88
 
71
- var getCells = exports.getCells = function getCells(data, display, customAttributes, unitsProps) {
89
+ var getCells = exports.getCells = function getCells(data, display, customAttributes, unitsProps, metadataCoordinates) {
72
90
  return R.mapObjIndexed(function (observation) {
73
- return R.pipe(R.set(R.lensProp('flags'), getFlags(customAttributes, (0, _dimensionUtils.dimensionValueDisplay)(display), unitsProps)(observation)), R.set(R.lensProp('intValue'), R.prop('value', observation)), R.set(R.lensProp('value'), R.prop('formattedValue', observation)), R.assoc('indexedDimValIds', R.prop('indexedDimValIds', observation)))({});
91
+ return R.pipe(R.set(R.lensProp('flags'), getFlags(customAttributes, (0, _dimensionUtils.dimensionValueDisplay)(display), unitsProps)(observation)), R.set(R.lensProp('intValue'), R.prop('value', observation)), R.set(R.lensProp('value'), R.prop('formattedValue', observation)), R.assoc('indexedDimValIds', R.prop('indexedDimValIds', observation)), R.assoc('sideProps', getSideProps(observation, customAttributes, metadataCoordinates)))({});
74
92
  }, R.propOr({}, 'observations', data));
75
93
  };
@@ -17,6 +17,8 @@ var _getCells = require('./getCells');
17
17
 
18
18
  var _dimensionUtils = require('../../dimension-utils');
19
19
 
20
+ var _hasCellMetadata = require('../../../../rules2/src/hasCellMetadata');
21
+
20
22
  function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
21
23
 
22
24
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -73,11 +75,36 @@ var getSerieKey = R.pipe(R.reduce(function (acc, entry) {
73
75
  return R.append(index, acc);
74
76
  }, []), R.join(':'));
75
77
 
76
- var getLayoutDataWithFlags = exports.getLayoutDataWithFlags = function getLayoutDataWithFlags(seriesAttributes, display, customAttributes) {
78
+ var getCoordinates = function getCoordinates(data, unitsId) {
79
+ return R.reduce(function (acc, entry) {
80
+ var dimId = R.path(['dimension', 'id'], entry);
81
+ var valId = R.path(['value', 'id'], entry);
82
+ if (dimId === unitsId) {
83
+ return acc;
84
+ }
85
+ return R.assoc(dimId, valId, acc);
86
+ }, {}, data);
87
+ };
88
+
89
+ var getLayoutDataWithFlags = exports.getLayoutDataWithFlags = function getLayoutDataWithFlags(seriesAttributes, display, customAttributes, metadataCoordinates, unitsId) {
90
+ var regularAttrsIds = R.concat(customAttributes.flags || [], customAttributes.footnotes || []);
77
91
  var formatSublayout = function formatSublayout(getAttributes) {
78
- return R.converge(function (data, key, flags) {
79
- return { data: data, key: key, flags: flags };
80
- }, [getSublayoutDataCells(display, customAttributes), getSerieKey, R.pipe(getAttributes, getFlagsFromSeriesAttributes(display, customAttributes))]);
92
+ var supplData = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
93
+ return function (data) {
94
+ var attributes = getAttributes(data);
95
+ var key = getSerieKey(data);
96
+ var cells = getSublayoutDataCells(display, customAttributes)(data);
97
+ var flags = getFlagsFromSeriesAttributes(display, customAttributes)(attributes);
98
+ var coordinates = getCoordinates(R.concat(supplData, data), unitsId);
99
+ var hasMetadata = (0, _hasCellMetadata.hasCellMetadata)(metadataCoordinates, coordinates);
100
+ var advancedAttributesSeries = R.isNil(attributes) ? {} : R.filter(function (serie) {
101
+ return !R.isEmpty(R.omit(regularAttrsIds, R.propOr({}, 'attributes', serie)));
102
+ }, attributes);
103
+ var hasAdvancedAttributes = !R.isEmpty(advancedAttributesSeries);
104
+ var sideProps = hasMetadata || hasAdvancedAttributes ? { hasAdvancedAttributes: hasAdvancedAttributes, hasMetadata: hasMetadata, coordinates: coordinates } : null;
105
+
106
+ return { data: cells, key: key, flags: flags, sideProps: sideProps };
107
+ };
81
108
  };
82
109
 
83
110
  return R.evolve({
@@ -91,7 +118,7 @@ var getLayoutDataWithFlags = exports.getLayoutDataWithFlags = function getLayout
91
118
  return sectionAttributes;
92
119
  })(sectionSerie), R.map(formatSublayout(function (rowData) {
93
120
  return getLayoutSerieAttributes(R.concat(sectionSerie, rowData), R.omit(R.keys(sectionAttributes), seriesAttributes));
94
- }))(R.last(sectionData))];
121
+ }, sectionSerie))(R.last(sectionData))];
95
122
  })
96
123
  });
97
124
  };
@@ -35,6 +35,8 @@ var _refineLayoutSize = require('./refineLayoutSize');
35
35
 
36
36
  var _getLayoutData = require('./getLayoutData');
37
37
 
38
+ var _refineMetadataCoordinates = require('../../../../rules2/src/refineMetadataCoordinates');
39
+
38
40
  function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
39
41
 
40
42
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -51,6 +53,10 @@ var getTableProps = exports.getTableProps = function getTableProps(_ref) {
51
53
 
52
54
  var confirmedSeriesAttributesIds = (0, _getConfirmedSeriesAttributesIds.getConfirmedSeriesAttributesIds)(seriesAttributes, layoutIds);
53
55
 
56
+ var headerDimensionsIds = R.pluck('id', R.concat(R.pathOr([], ['units', 'headerUnits'], data), R.values(R.pathOr({}, ['dimensions', 'one'], data))));
57
+
58
+ var refinedMetadataCoordinates = (0, _refineMetadataCoordinates.refineMetadataCoordinates)(data.metadataCoordinates, layoutIds, headerDimensionsIds);
59
+
54
60
  var _R$propOr = R.propOr({}, 'units', data),
55
61
  rejectedValueIds = _R$propOr.rejectedValueIds,
56
62
  unitDimension = _R$propOr.unitDimension,
@@ -68,7 +74,7 @@ var getTableProps = exports.getTableProps = function getTableProps(_ref) {
68
74
  var cells = (0, _getCells.getCells)(data, display, R.assoc('rejected', confirmedSeriesAttributesIds, customAttributes), {
69
75
  unitsDefinitionCodes: unitsDefinitionCodes, unitsSeries: unitsSeries, unitsDisplay: unitsLevelDisplay,
70
76
  unitDimension: unitDimension, rejectedValueIds: rejectedValueIds, layoutDimsIds: layoutDimsIds
71
- }, data.observationsType);
77
+ }, refinedMetadataCoordinates.cells, data.observationsType);
72
78
 
73
79
  var dimensions = R.mapObjIndexed(R.pipe(R.when( // invert TimeDimension Values
74
80
  R.allPass([_dotstatsuiteSdmxjs.isTimePeriodDimension, R.always(isTimeInverted)]), function (dim) {
@@ -90,7 +96,8 @@ var getTableProps = exports.getTableProps = function getTableProps(_ref) {
90
96
  display: display, unitDimension: unitDimension, unitsDisplay: unitsLevelDisplay, unitsSeries: unitsSeries,
91
97
  unitsDefinitionCodes: unitsDefinitionCodes, unitsIndexes: unitsAttachmentIndexesInLayout,
92
98
  partialUnitSerieIndexes: partialUnitSerieIndexes, rejectedValueIds: rejectedValueIds, layoutIds: layoutIds
93
- }), (0, _getLayoutWithFlags.getLayoutDataWithFlags)(seriesAttributesValues, display, customAttributes), (0, _cleanUnitsInLayoutData.cleanUnitsInLayoutData)({ unitsDisplay: unitsLevelDisplay, unitsLayoutIndexes: unitsIndexesInLayout }))(layout, R.propOr({}, 'observations', data));
99
+ }), (0, _getLayoutWithFlags.getLayoutDataWithFlags)(seriesAttributesValues, display, customAttributes, refinedMetadataCoordinates.layout, unitDimension.id), (0, _cleanUnitsInLayoutData.cleanUnitsInLayoutData)({ unitsDisplay: unitsLevelDisplay, unitsLayoutIndexes: unitsIndexesInLayout }))(layout, R.propOr({}, 'observations', data));
100
+
94
101
  return (0, _extends3.default)({
95
102
  cells: (0, _getCuratedCells.getCuratedCells)({ layout: layout, observations: cells, shape: ['header', 'sections', 'rows'] }),
96
103
  layout: layout
@@ -5,6 +5,10 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.prepareData = undefined;
7
7
 
8
+ var _extends2 = require('babel-runtime/helpers/extends');
9
+
10
+ var _extends3 = _interopRequireDefault(_extends2);
11
+
8
12
  var _ramda = require('ramda');
9
13
 
10
14
  var R = _interopRequireWildcard(_ramda);
@@ -47,8 +51,14 @@ var _getObservations = require('../../preparators/getObservations');
47
51
 
48
52
  var _enhanceObservations = require('../../preparators/enhanceObservations');
49
53
 
54
+ var _getMetadataCoordinates = require('../../../../rules2/src/getMetadataCoordinates');
55
+
56
+ var _getAdvancedAttributes = require('../../../../rules2/src/getAdvancedAttributes');
57
+
50
58
  function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
51
59
 
60
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
61
+
52
62
  var prepareData = exports.prepareData = function prepareData(sdmxJson, customAttributes) {
53
63
  var unitsProps = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
54
64
 
@@ -130,7 +140,30 @@ var prepareData = exports.prepareData = function prepareData(sdmxJson, customAtt
130
140
 
131
141
  var manyValuesDimensions = (0, _getManyValuesDimensions.getManyValuesDimensions)(dimensionsIndexedByIds, parsedDimensionsIds.manyValues, dimensionsAttributesValues.dimensions, attributesIndexedByIds);
132
142
 
133
- var seriesAttributesValues = (0, _refineSeriesAttributesValues.refineSeriesAttributesValues)(dimensionsAttributesValues.series, attributesIndexedByIds);
143
+ var seriesAttributesValues = R.map(function (series) {
144
+ return (0, _refineSeriesAttributesValues.refineSeriesAttributesValues)(series, attributesIndexedByIds);
145
+ }, dimensionsAttributesValues);
146
+
147
+ var metadataCoordinates = (0, _getMetadataCoordinates.getMetadataCoordinates)(sdmxJson);
148
+ var headerAttributesIds = R.concat(attributesIdsIndexedByTargets.dataflow || [], attributesIdsIndexedByTargets.oneValueDimensions || []);
149
+ var headerAttributes = R.pick(headerAttributesIds, attributesIndexedByIds);
150
+ var headerAdvancedAttrIds = R.pipe(R.filter(function (id) {
151
+ return !R.includes(id, customAttributes.flags || []) && !R.includes(id, customAttributes.footnotes || []);
152
+ }))(headerAttributesIds);
153
+
154
+ var dataflowAdvancedAttributes = (0, _getAdvancedAttributes.getDataflowAdvancedAttributes)(headerAttributes, oneValueDimensions, headerAdvancedAttrIds, R.length(dimensions));
155
+
156
+ var observationsAdvancedAttributesIds = R.filter(function (id) {
157
+ return !R.includes(id, customAttributes.flags || []) && !R.includes(id, customAttributes.footnotes || []);
158
+ }, attributesIdsIndexedByTargets.observations || []);
159
+ var observationsAdvancedAttributes = (0, _getAdvancedAttributes.getObservationsAdvancedAttributes)(observations, observationsAdvancedAttributesIds);
160
+
161
+ var seriesAdvancedAttributesIds = R.filter(function (id) {
162
+ return !R.includes(id, customAttributes.flags || []) && !R.includes(id, customAttributes.footnotes || []);
163
+ }, R.concat(attributesIdsIndexedByTargets.series || [], attributesIdsIndexedByTargets.manyValuesDimensions || []));
164
+
165
+ var seriesAdvancedAttributes = (0, _getAdvancedAttributes.getSeriesAdvancedAttributes)(seriesAttributesValues, dimensions, seriesAdvancedAttributesIds);
166
+
134
167
  return {
135
168
  dimensions: {
136
169
  one: oneValueDimensions,
@@ -144,11 +177,13 @@ var prepareData = exports.prepareData = function prepareData(sdmxJson, customAtt
144
177
  unitsAttachmentSeriesIds: unitsAttachmentSeriesIds,
145
178
  unitsSeries: unitsSeries
146
179
  },
180
+ metadataCoordinates: metadataCoordinates,
181
+ advancedAttributes: (0, _extends3.default)({}, dataflowAdvancedAttributes, observationsAdvancedAttributes, seriesAdvancedAttributes),
147
182
  observations: observations,
148
183
  observationsType: (0, _getObservationsType.getObservationsType)(sdmxJson.data),
149
184
  dataflowAttributes: dataflowAttributes,
150
185
  dataflowName: R.path(['data', 'structure', 'name'], sdmxJson),
151
186
  seriesAttributes: R.props(seriesAttributesIds, attributesIndexedByIds),
152
- seriesAttributesValues: seriesAttributesValues
187
+ seriesAttributesValues: seriesAttributesValues.series || {}
153
188
  };
154
189
  };
@@ -105,24 +105,20 @@ var dataTransformer = exports.dataTransformer = function dataTransformer(dataNew
105
105
  var getAttrObservations = R.propOr([], 'observation');
106
106
  var attrObservations = getAttrObservations(attributes);
107
107
 
108
- var getAttrDataset = R.propOr([], 'dataset');
109
- var attrDataset = getAttrDataset(attributes);
110
-
111
- var mergeAttr = R.concat(attrDataset, attrObservations);
112
-
113
108
  var resAttrObservations = R.map(function (observation) {
114
109
  return (0, _extends3.default)({}, observation, {
115
110
  name: getLocalisedProp('names', observation),
116
- values: getValues(observation.values),
111
+ values: getValues(observation.values || []),
117
112
  roles: !R.isNil(observation.role) ? R.head(observation.role) : null
118
113
  });
119
- }, mergeAttr);
114
+ }, attrObservations);
120
115
 
121
116
  var resAttributes = (0, _extends3.default)({}, attributes, {
122
117
  observation: resAttrObservations
118
+ });
123
119
 
124
- //----------------------------------------------------------------------------------------Dimensions
125
- });var getDimensions = R.propOr({}, 'dimensions');
120
+ //----------------------------------------------------------------------------------------Dimensions
121
+ var getDimensions = R.propOr({}, 'dimensions');
126
122
  var dimensions = getDimensions(structure);
127
123
 
128
124
  var getDimObservations = R.propOr([], 'observation');
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var SDMX_3_0_JSON_DATA_FORMAT = exports.SDMX_3_0_JSON_DATA_FORMAT = 'application/vnd.sdmx.data+json;version=2.0';
7
+ var SDMX_3_0_CSV_DATA_FORMAT = exports.SDMX_3_0_CSV_DATA_FORMAT = 'application/vnd.sdmx.data+csv;version=2.0';
@@ -0,0 +1,39 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getAdvAttrSeriesAtCoordinates = undefined;
7
+
8
+ var _ramda = require('ramda');
9
+
10
+ var R = _interopRequireWildcard(_ramda);
11
+
12
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
13
+
14
+ var attribueValueDisplay = function attribueValueDisplay(display) {
15
+ return function (data) {
16
+ if (display === 'code') {
17
+ return R.prop('id', data);
18
+ }
19
+ if (display === 'both') {
20
+ return R.prop('id', data) + ': ' + R.prop('name', data);
21
+ }
22
+ return R.prop('name', data);
23
+ };
24
+ };
25
+
26
+ var getAdvAttrSeriesAtCoordinates = exports.getAdvAttrSeriesAtCoordinates = function getAdvAttrSeriesAtCoordinates(coordinates, advancedAttributes, display) {
27
+ return R.pipe(R.filter(function (serie) {
28
+ var mergedCoord = R.mergeLeft(serie.coordinates, coordinates);
29
+ return R.equals(mergedCoord, coordinates);
30
+ }), R.map(function (serie) {
31
+ return R.pipe(R.propOr({}, 'attributes'), R.values, R.map(function (attribute) {
32
+ return {
33
+ id: attribute.id,
34
+ label: attribueValueDisplay(display)(attribute),
35
+ value: attribueValueDisplay(display)(attribute.value)
36
+ };
37
+ }))(serie);
38
+ }))(advancedAttributes);
39
+ };
@@ -0,0 +1,126 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getSeriesAdvancedAttributes = exports.getDataflowAdvancedAttributes = exports.getObservationsAdvancedAttributes = undefined;
7
+
8
+ var _slicedToArray2 = require('babel-runtime/helpers/slicedToArray');
9
+
10
+ var _slicedToArray3 = _interopRequireDefault(_slicedToArray2);
11
+
12
+ var _defineProperty2 = require('babel-runtime/helpers/defineProperty');
13
+
14
+ var _defineProperty3 = _interopRequireDefault(_defineProperty2);
15
+
16
+ var _extends3 = require('babel-runtime/helpers/extends');
17
+
18
+ var _extends4 = _interopRequireDefault(_extends3);
19
+
20
+ var _ramda = require('ramda');
21
+
22
+ var R = _interopRequireWildcard(_ramda);
23
+
24
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
25
+
26
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
27
+
28
+ var getObservationsAdvancedAttributes = exports.getObservationsAdvancedAttributes = function getObservationsAdvancedAttributes(observations, advancedAttributesIds) {
29
+ return R.pipe(R.map(function (obs) {
30
+ return { attributes: R.pick(advancedAttributesIds, obs.attributes || {}), coordinates: obs.indexedDimValIds || {} };
31
+ }), R.filter(function (entry) {
32
+ return !R.isEmpty(entry.attributes);
33
+ }))(observations);
34
+ };
35
+
36
+ var getDataflowAdvancedAttributes = exports.getDataflowAdvancedAttributes = function getDataflowAdvancedAttributes(attributes, dimensions, advancedAttributesIds, dimLength) {
37
+ var advancedAttributes = R.pick(advancedAttributesIds, attributes);
38
+ var keyTemplate = R.times(R.always(''), dimLength);
39
+ return R.reduce(function (acc, attribute) {
40
+ var value = R.head(attribute.values || []);
41
+ var attr = (0, _extends4.default)({}, R.pick(['id', 'name'], attribute), { value: value });
42
+ var coordinates = {};
43
+ var key = keyTemplate;
44
+
45
+ if (!R.isEmpty(R.pathOr([], ['relationship', 'dimensions'], attribute))) {
46
+ var attrDimensionsIds = R.pathOr([], ['relationship', 'dimensions'], attribute);
47
+ var attrDimensions = R.props(attrDimensionsIds, dimensions);
48
+ R.forEach(function (dim) {
49
+ var dId = dim.id;
50
+ var dIndex = dim.__index;
51
+ var vId = R.path(['values', 0, 'id'], dim);
52
+ coordinates = (0, _extends4.default)({}, coordinates, (0, _defineProperty3.default)({}, dId, vId));
53
+ key = R.set(R.lensIndex(dIndex), 0)(key);
54
+ }, attrDimensions);
55
+ }
56
+
57
+ key = R.join(':', key);
58
+ return R.over(R.lensProp(key), function (entry) {
59
+ return R.isNil(entry) ? { attributes: (0, _defineProperty3.default)({}, attribute.id, attr), coordinates: coordinates } : R.over(R.lensProp('attributes'), R.assoc(attribute.id, attr))(entry);
60
+ })(acc);
61
+ }, {}, R.values(advancedAttributes));
62
+ };
63
+
64
+ /*
65
+ {
66
+ series: {
67
+ '0:0:x:x:x': { attributes: { a2: { id, value } } }
68
+ },
69
+ dimensions: {
70
+ '3:0': { attributes: { a1: { id, value } } },
71
+ }
72
+ }
73
+
74
+ */
75
+
76
+ var getSeriesAdvancedAttributes = exports.getSeriesAdvancedAttributes = function getSeriesAdvancedAttributes(seriesAttributes, dimensions, advancedAttributesIds) {
77
+ var seriesAdvancedAttributes = R.pipe(R.propOr({}, 'series'), function (series) {
78
+ return R.reduce(function (acc, key) {
79
+ var serie = series[key];
80
+ var advancedAttributes = R.pick(advancedAttributesIds, serie.attributes);
81
+ if (R.isEmpty(advancedAttributes)) {
82
+ return acc;
83
+ }
84
+ var splitKey = R.split(':', key);
85
+
86
+ var _R$addIndex = R.addIndex(R.reduce)(function (acc, vInd, dInd) {
87
+ if (vInd === 'x') {
88
+ return (0, _extends4.default)({}, acc, { refinedKey: R.append('', acc.refinedKey) });
89
+ }
90
+ var _refined = R.append(vInd, acc.refinedKey);
91
+ var dim = R.nth(dInd, dimensions);
92
+ var valId = R.path(['values', Number(vInd), 'id'], dim);
93
+ var _coordinates = R.assoc(dim.id, valId, acc.coordinates);
94
+ return { coordinates: _coordinates, refinedKey: _refined };
95
+ }, { coordinates: {}, refinedKey: [] }, splitKey),
96
+ coordinates = _R$addIndex.coordinates,
97
+ refinedKey = _R$addIndex.refinedKey;
98
+
99
+ return R.assoc(R.join(':', refinedKey), { attributes: advancedAttributes, coordinates: coordinates }, acc);
100
+ }, {}, R.keys(series));
101
+ })(seriesAttributes);
102
+ var keyTemplate = R.map(R.always(''), dimensions);
103
+ var dimensionsAdvancedAttributes = R.pipe(R.propOr({}, 'dimensions'), function (series) {
104
+ return R.reduce(function (acc, key) {
105
+ var serie = series[key];
106
+ var advancedAttributes = R.pick(advancedAttributesIds, serie.attributes);
107
+ if (R.isEmpty(advancedAttributes)) {
108
+ return acc;
109
+ }
110
+
111
+ var _R$split = R.split(':', key),
112
+ _R$split2 = (0, _slicedToArray3.default)(_R$split, 2),
113
+ dInd = _R$split2[0],
114
+ vInd = _R$split2[1];
115
+
116
+ var dim = R.nth(Number(dInd), dimensions);
117
+ var valId = R.path(['values', Number(vInd), 'id'], dim);
118
+ var coordinates = (0, _defineProperty3.default)({}, dim.id, valId);
119
+ var refinedKey = keyTemplate;
120
+ refinedKey[Number(dInd)] = vInd;
121
+ return R.assoc(R.join(':', refinedKey), { attributes: advancedAttributes, coordinates: coordinates }, acc);
122
+ }, {}, R.keys(series));
123
+ })(seriesAttributes);
124
+
125
+ return R.merge(seriesAdvancedAttributes, dimensionsAdvancedAttributes);
126
+ };
@@ -0,0 +1,38 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getMetadataCoordinates = undefined;
7
+
8
+ var _ramda = require('ramda');
9
+
10
+ var R = _interopRequireWildcard(_ramda);
11
+
12
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
13
+
14
+ var getMetadataCoordinates = exports.getMetadataCoordinates = function getMetadataCoordinates(sdmxJson) {
15
+ var dimensions = R.pathOr([], ['data', 'structure', 'dimensions', 'observation'], sdmxJson);
16
+ var annotations = R.pathOr([], ['data', 'structure', 'annotations'], sdmxJson);
17
+ var metadataAvailKeys = R.pipe(R.pathOr([], ['data', 'dataSets', 0, 'dimensionGroupAttributes']), R.map(function (indexes) {
18
+ return R.props(indexes, annotations);
19
+ }), R.filter(R.find(R.propEq('type', 'HAS_METADATA'))), R.keys)(sdmxJson);
20
+
21
+ return R.map(function (key) {
22
+ var indexes = R.split(':', key);
23
+ return R.addIndex(R.reduce)(function (acc, vIndex, dimIndex) {
24
+ if (R.isNil(vIndex) || R.isEmpty(vIndex)) {
25
+ return acc;
26
+ }
27
+ var dim = R.nth(dimIndex, dimensions);
28
+ if (R.isNil(dim)) {
29
+ return acc;
30
+ }
31
+ var val = R.path(['values', Number(vIndex)], dim);
32
+ if (R.isNil(val)) {
33
+ return acc;
34
+ }
35
+ return R.assoc(dim.id, val.id, acc);
36
+ }, {}, indexes);
37
+ }, metadataAvailKeys);
38
+ };
@@ -0,0 +1,23 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getDataflowMetadataStructure = undefined;
7
+
8
+ var _ramda = require('ramda');
9
+
10
+ var R = _interopRequireWildcard(_ramda);
11
+
12
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
13
+
14
+ var getDataflowMetadataStructure = exports.getDataflowMetadataStructure = function getDataflowMetadataStructure(sdmxJson) {
15
+ var annotations = R.pathOr([], ['data', 'stucture', 'annotations'], sdmxJson);
16
+ var dataSetAnnotIndexes = R.pathOr([], ['data', 'dataSets', 0, 'annotations'], sdmxJson);
17
+ var dataSetAnnotations = R.props(dataSetAnnotIndexes, annotations);
18
+ var metadataAnnotation = R.find(R.propEq('type', 'METADATA'), dataSetAnnotations);
19
+ if (!metadataAnnotation) {
20
+ return null;
21
+ }
22
+ return R.pipe(R.propOr('', 'title'), R.split('='), R.last)(metadataAnnotation);
23
+ };
@@ -0,0 +1,76 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getSidebarData = undefined;
7
+
8
+ var _ramda = require('ramda');
9
+
10
+ var R = _interopRequireWildcard(_ramda);
11
+
12
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
13
+
14
+ var dimensionValueDisplay = function dimensionValueDisplay(display) {
15
+ return function (data) {
16
+ if (display === 'code') {
17
+ return R.prop('id', data);
18
+ }
19
+ if (display === 'both') {
20
+ return R.prop('id', data) + ': ' + R.prop('name', data);
21
+ }
22
+ return R.prop('name', data);
23
+ };
24
+ };
25
+
26
+ var sortByCoordinates = function sortByCoordinates(a, b) {
27
+ var splitACoord = a.splitCoord;
28
+ var splitBCoord = b.splitCoord;
29
+
30
+ var aWeight = R.pipe(R.reject(R.isEmpty), R.length)(splitACoord);
31
+ var bWeight = R.pipe(R.reject(R.isEmpty), R.length)(splitBCoord);
32
+ if (aWeight !== bWeight) {
33
+ return bWeight - aWeight;
34
+ }
35
+
36
+ var ind = 0;
37
+ while (splitACoord[ind] === splitBCoord[ind]) {
38
+ ind++;
39
+ }
40
+ var _a = R.isEmpty(splitACoord[ind]) ? 0 : Number(splitACoord[ind]);
41
+ var _b = R.isEmpty(splitBCoord[ind]) ? 0 : Number(splitBCoord[ind]);
42
+ return _b - _a;
43
+ };
44
+
45
+ // options = { display, attributesLabel }
46
+ var getSidebarData = exports.getSidebarData = function getSidebarData(attributesSeries, metadataSeries, dataflow, dimensions, options) {
47
+ var coordinates = R.uniq(R.concat(R.keys(attributesSeries), R.keys(metadataSeries)));
48
+ return R.pipe(R.map(function (coordinate) {
49
+ var attributes = R.prop(coordinate, attributesSeries);
50
+ var metadata = R.prop(coordinate, metadataSeries);
51
+ var children = R.concat(R.isNil(attributes) ? [] : [{ id: coordinate + '-attr', label: options.attributesLabel, children: attributes }], R.isNil(metadata) ? [] : metadata);
52
+ var splitCoord = R.split(':', coordinate);
53
+ var label = null;
54
+ if (R.all(R.isEmpty, splitCoord)) {
55
+ label = dimensionValueDisplay(options.display)(dataflow);
56
+ } else {
57
+ label = R.pipe(R.addIndex(R.reduce)(function (acc, valIndex, dimIndex) {
58
+ if (R.isEmpty(valIndex)) {
59
+ return acc;
60
+ }
61
+ var dim = R.nth(dimIndex, dimensions);
62
+ var dimLabel = dimensionValueDisplay(options.display)(dim);
63
+ var value = R.nth(Number(valIndex), dim.values);
64
+ var valLabel = dimensionValueDisplay(options.display)(value);
65
+ return R.append(dimLabel + ': ' + valLabel, acc);
66
+ }, []), R.join(' - '))(splitCoord);
67
+ }
68
+
69
+ return {
70
+ id: coordinate,
71
+ splitCoord: splitCoord,
72
+ label: label,
73
+ children: R.filter(R.identity, children)
74
+ };
75
+ }), R.sort(sortByCoordinates))(coordinates);
76
+ };
@@ -0,0 +1,19 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.hasCellMetadata = undefined;
7
+
8
+ var _ramda = require('ramda');
9
+
10
+ var R = _interopRequireWildcard(_ramda);
11
+
12
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
13
+
14
+ var hasCellMetadata = exports.hasCellMetadata = function hasCellMetadata(metadataCoordinates, cellCoordinates) {
15
+ return R.pipe(R.find(function (coordinates) {
16
+ var mergedCoord = R.mergeLeft(coordinates, cellCoordinates);
17
+ return R.equals(mergedCoord, cellCoordinates);
18
+ }), R.complement(R.isNil))(metadataCoordinates);
19
+ };
@@ -0,0 +1,18 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getLayoutEntryMetadataCoordinates = undefined;
7
+
8
+ var _ramda = require('ramda');
9
+
10
+ var R = _interopRequireWildcard(_ramda);
11
+
12
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
13
+
14
+ /*
15
+ const layoutData = [{ dimension: { id: 'D1', __index: 2 }, value: { id: 'V', __index: 0 } }];
16
+ */
17
+
18
+ var getLayoutEntryMetadataCoordinates = exports.getLayoutEntryMetadataCoordinates = function getLayoutEntryMetadataCoordinates(layoutData, metadataSeries) {};