@sis-cc/dotstatsuite-components 15.0.20 → 16.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 (167) hide show
  1. package/LICENSE +1 -1
  2. package/lib/rules/src/index.js +1 -145
  3. package/lib/rules/src/table/index.js +0 -42
  4. package/lib/rules/src/v8-transformer.js +6 -5
  5. package/lib/rules2/src/constants.js +3 -1
  6. package/lib/rules2/src/enhanceObservations.js +98 -0
  7. package/lib/rules2/src/getAttributesSeries.js +33 -0
  8. package/lib/rules2/src/getCombinationDefinitions.js +48 -0
  9. package/lib/rules2/src/getHeaderCombinations.js +42 -0
  10. package/lib/rules2/src/getHeaderSubtitle.js +41 -0
  11. package/lib/rules2/src/getManyValuesDimensions.js +39 -0
  12. package/lib/rules2/src/getNotDisplayedIds.js +5 -1
  13. package/lib/rules2/src/getOneValueDimensions.js +46 -0
  14. package/lib/rules2/src/hasCellMetadata.js +1 -1
  15. package/lib/rules2/src/index.js +186 -18
  16. package/lib/rules2/src/parseAttributes.js +50 -0
  17. package/lib/rules2/src/parseCombinations.js +54 -0
  18. package/lib/rules2/src/prepareData.js +74 -0
  19. package/lib/{rules/src/table/preparators/getAttributeValue.js → rules2/src/refineAttributes.js} +13 -11
  20. package/lib/rules2/src/table/getCells.js +74 -0
  21. package/lib/rules2/src/table/getCellsAttributesIds.js +63 -0
  22. package/lib/rules2/src/table/getCombinationDimensionsData.js +47 -0
  23. package/lib/rules2/src/table/getCuratedCells.js +28 -0
  24. package/lib/rules2/src/table/getFlagsAndNotes.js +28 -0
  25. package/lib/rules2/src/table/getIndexedCombinationsByDisplay.js +31 -0
  26. package/lib/rules2/src/table/getLayout.js +93 -0
  27. package/lib/rules2/src/table/getLayoutData.js +202 -0
  28. package/lib/{rules/src/table/factories → rules2/src/table}/getSortedLayoutIndexes.js +55 -40
  29. package/lib/rules2/src/table/getTableProps.js +64 -0
  30. package/lib/rules2/src/table/parseValueHierarchy.js +55 -0
  31. package/lib/{rules/src/table/factories → rules2/src/table}/refineLayoutSize.js +17 -8
  32. package/lib/rules2/src/{hasLayoutEntryMetadata.js → utils.js} +9 -6
  33. package/package.json +1 -1
  34. package/src/rules/src/index.js +1 -19
  35. package/src/rules/src/table/index.js +0 -4
  36. package/src/rules/src/v8-transformer.js +75 -74
  37. package/src/rules2/src/constants.js +2 -0
  38. package/src/rules2/src/enhanceObservations.js +88 -0
  39. package/src/rules2/src/getAttributesSeries.js +29 -0
  40. package/src/rules2/src/getCombinationDefinitions.js +29 -0
  41. package/src/rules2/src/getHeaderCombinations.js +39 -0
  42. package/src/rules2/src/getHeaderSubtitle.js +34 -0
  43. package/src/rules2/src/getManyValuesDimensions.js +34 -0
  44. package/src/rules2/src/getNotDisplayedIds.js +5 -1
  45. package/src/rules2/src/getOneValueDimensions.js +33 -0
  46. package/src/rules2/src/hasCellMetadata.js +1 -1
  47. package/src/rules2/src/index.js +21 -6
  48. package/src/rules2/src/parseAttributes.js +36 -0
  49. package/src/rules2/src/parseCombinations.js +36 -0
  50. package/src/rules2/src/prepareData.js +50 -0
  51. package/src/rules2/src/refineAttributes.js +16 -0
  52. package/src/rules2/src/table/getCells.js +72 -0
  53. package/src/rules2/src/table/getCellsAttributesIds.js +38 -0
  54. package/src/rules2/src/table/getCombinationDimensionsData.js +38 -0
  55. package/src/rules2/src/table/getCuratedCells.js +33 -0
  56. package/src/rules2/src/table/getFlagsAndNotes.js +21 -0
  57. package/src/rules2/src/table/getIndexedCombinationsByDisplay.js +16 -0
  58. package/src/rules2/src/table/getLayout.js +80 -0
  59. package/src/rules2/src/table/getLayoutData.js +183 -0
  60. package/src/rules2/src/table/getSortedLayoutIndexes.js +119 -0
  61. package/src/rules2/src/table/getTableProps.js +36 -0
  62. package/src/rules2/src/table/parseValueHierarchy.js +27 -0
  63. package/src/{rules/src/table/factories → rules2/src/table}/refineLayoutSize.js +24 -8
  64. package/src/rules2/src/utils.js +12 -0
  65. package/test/enhanceObservations2.test.js +219 -0
  66. package/test/getAttributesSeries.test.js +58 -0
  67. package/test/getCells.test.js +6 -40
  68. package/test/getCombinationDimensionsData.test.js +48 -0
  69. package/test/getNotDisplayedIds.test.js +15 -2
  70. package/test/getSortedLayoutIndexes.test.js +1025 -3
  71. package/test/parseAttributes.test.js +17 -62
  72. package/test/parseValueHierarchy.test.js +88 -0
  73. package/test/refineLayoutSize.test.js +2621 -1
  74. package/lib/rules/src/table/factories/getCells.js +0 -97
  75. package/lib/rules/src/table/factories/getConfirmedSeriesAttributesIds.js +0 -26
  76. package/lib/rules/src/table/factories/getCuratedCells.js +0 -45
  77. package/lib/rules/src/table/factories/getLayoutData.js +0 -168
  78. package/lib/rules/src/table/factories/getLayoutWithFlags.js +0 -133
  79. package/lib/rules/src/table/factories/getTableCells.js +0 -24
  80. package/lib/rules/src/table/factories/getTableData.js +0 -98
  81. package/lib/rules/src/table/preparators/getDimensionsAttributesRegisters.js +0 -43
  82. package/lib/rules/src/table/preparators/getManyValuesDimensions.js +0 -33
  83. package/lib/rules/src/table/preparators/getOneValueDimensions.js +0 -24
  84. package/lib/rules/src/table/preparators/getUniqValuesAttributes.js +0 -36
  85. package/lib/rules/src/table/preparators/parseAttributes.js +0 -84
  86. package/lib/rules/src/table/preparators/parseAttributesValuesFromObservations.js +0 -22
  87. package/lib/rules/src/table/preparators/parseDimensionsIds.js +0 -22
  88. package/lib/rules/src/table/preparators/prepareData.js +0 -191
  89. package/lib/rules/src/table/preparators/refineObservationsAttributesValues.js +0 -31
  90. package/lib/rules/src/table/preparators/refineSeriesAttributesValues.js +0 -23
  91. package/lib/rules/src/table/units/appendUnitsInLayoutData.js +0 -82
  92. package/lib/rules/src/table/units/appendUnitsInLayoutDataEntry.js +0 -45
  93. package/lib/rules/src/table/units/cleanUnitsInLayoutData.js +0 -66
  94. package/lib/rules/src/table/units/getAttachmentSeriesIndexes.js +0 -25
  95. package/lib/rules/src/table/units/getHeaderUnits.js +0 -35
  96. package/lib/rules/src/table/units/getUnitsArtefacts.js +0 -85
  97. package/lib/rules/src/table/units/getUnitsCodes.js +0 -23
  98. package/lib/rules/src/table/units/getUnitsDefinition.js +0 -33
  99. package/lib/rules/src/table/units/getUnitsDisplay.js +0 -33
  100. package/lib/rules/src/table/units/getUnitsSerieIndexes.js +0 -23
  101. package/lib/rules/src/table/units/getUnitsSeries.js +0 -49
  102. package/lib/rules/src/table/units/getUnitsinLayout.js +0 -74
  103. package/lib/rules/src/table/units/refineDimSeriesUnits.js +0 -44
  104. package/lib/rules2/src/getAdvancedAttributes.js +0 -124
  105. package/lib/rules2/src/invertTime.js +0 -33
  106. package/src/rules/src/table/factories/getCells.js +0 -102
  107. package/src/rules/src/table/factories/getConfirmedSeriesAttributesIds.js +0 -27
  108. package/src/rules/src/table/factories/getCuratedCells.js +0 -40
  109. package/src/rules/src/table/factories/getLayoutData.js +0 -171
  110. package/src/rules/src/table/factories/getLayoutWithFlags.js +0 -137
  111. package/src/rules/src/table/factories/getSortedLayoutIndexes.js +0 -108
  112. package/src/rules/src/table/factories/getTableCells.js +0 -16
  113. package/src/rules/src/table/factories/getTableData.js +0 -86
  114. package/src/rules/src/table/preparators/getAttributeValue.js +0 -17
  115. package/src/rules/src/table/preparators/getDimensionsAttributesRegisters.js +0 -51
  116. package/src/rules/src/table/preparators/getManyValuesDimensions.js +0 -19
  117. package/src/rules/src/table/preparators/getOneValueDimensions.js +0 -17
  118. package/src/rules/src/table/preparators/getUniqValuesAttributes.js +0 -24
  119. package/src/rules/src/table/preparators/parseAttributes.js +0 -113
  120. package/src/rules/src/table/preparators/parseAttributesValuesFromObservations.js +0 -16
  121. package/src/rules/src/table/preparators/parseDimensionsIds.js +0 -17
  122. package/src/rules/src/table/preparators/prepareData.js +0 -197
  123. package/src/rules/src/table/preparators/refineObservationsAttributesValues.js +0 -22
  124. package/src/rules/src/table/preparators/refineSeriesAttributesValues.js +0 -11
  125. package/src/rules/src/table/units/appendUnitsInLayoutData.js +0 -56
  126. package/src/rules/src/table/units/appendUnitsInLayoutDataEntry.js +0 -38
  127. package/src/rules/src/table/units/cleanUnitsInLayoutData.js +0 -65
  128. package/src/rules/src/table/units/getAttachmentSeriesIndexes.js +0 -27
  129. package/src/rules/src/table/units/getHeaderUnits.js +0 -32
  130. package/src/rules/src/table/units/getUnitsArtefacts.js +0 -90
  131. package/src/rules/src/table/units/getUnitsCodes.js +0 -22
  132. package/src/rules/src/table/units/getUnitsDefinition.js +0 -34
  133. package/src/rules/src/table/units/getUnitsDisplay.js +0 -19
  134. package/src/rules/src/table/units/getUnitsSerieIndexes.js +0 -12
  135. package/src/rules/src/table/units/getUnitsSeries.js +0 -41
  136. package/src/rules/src/table/units/getUnitsinLayout.js +0 -71
  137. package/src/rules/src/table/units/refineDimSeriesUnits.js +0 -26
  138. package/src/rules2/src/getAdvancedAttributes.js +0 -111
  139. package/src/rules2/src/hasLayoutEntryMetadata.js +0 -9
  140. package/src/rules2/src/invertTime.js +0 -22
  141. package/test/advanced-attributes-parsing-perf.test.js +0 -16
  142. package/test/appendUnitsInLayoutDataEntry.test.js +0 -65
  143. package/test/cleanUnitsInLayoutData.test.js +0 -85
  144. package/test/enhanceObservations.test.js +0 -340
  145. package/test/getAttachmentSeriesIndexes.test.js +0 -35
  146. package/test/getConfirmedSeriesAttributesIds.test.js +0 -27
  147. package/test/getDataflowAdvancedAttributes.test.js +0 -32
  148. package/test/getHeaderUnits.test.js +0 -51
  149. package/test/getLayoutData.test.js +0 -206
  150. package/test/getLayoutDataWithFlags.test.js +0 -142
  151. package/test/getOneValueDimensions.test.js +0 -26
  152. package/test/getSeriesAdvancedAttributes.test.js +0 -32
  153. package/test/getSubtitleFlags.test.js +0 -42
  154. package/test/getTableData.test.js +0 -1317
  155. package/test/getUnitsArtefacts.test.js +0 -117
  156. package/test/getUnitsDefinition.test.js +0 -37
  157. package/test/getUnitsInLayout.test.js +0 -77
  158. package/test/getUnitsSeries.test.js +0 -154
  159. package/test/invertTime.test.js +0 -77
  160. package/test/parseAttributesValuesFromObservations.test.js +0 -45
  161. package/test/parseDimensionsIds.test.js +0 -20
  162. package/test/prepareData.test.js +0 -29
  163. package/test/refineObservationsAttributesValues.test.js +0 -33
  164. package/test/table-invert-time-perf.test.js +0 -11
  165. package/test/table-layout-perf.test.js +0 -74
  166. package/test/table-prep-duplicate-perf.test.js +0 -15
  167. package/test/table-prep-perf.test.js +0 -61
@@ -25,12 +25,21 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
25
25
 
26
26
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
27
27
 
28
+ var toKey = function toKey(indexes) {
29
+ return R.reduce(function (acc, _ind) {
30
+ var ind = R.is(Array, _ind) ? toKey(_ind) : Math.abs(_ind);
31
+ return R.isEmpty(acc) ? String(ind) : acc + ':' + ind;
32
+ }, '', indexes);
33
+ };
34
+
28
35
  var getPivotKey = function getPivotKey(indexes) {
29
36
  return R.pipe(R.props(indexes), R.join(':'));
30
37
  };
31
38
 
32
39
  var getPivots = function getPivots(layout, shape) {
33
- return R.pipe(R.props(shape), R.map(R.pipe(R.pluck('__index'), getPivotKey)))(layout);
40
+ return R.pipe(R.props(shape), R.map(R.pipe(R.map(function (entry) {
41
+ return R.has('dimensions', entry) ? R.pluck('__index', entry.dimensions || []) : entry.__index;
42
+ }), R.unnest, getPivotKey)))(layout);
34
43
  };
35
44
 
36
45
  var indexWithPivots = function indexWithPivots(pivots, observations) {
@@ -53,9 +62,9 @@ var getCuratedCells = exports.getCuratedCells = function getCuratedCells(_ref) {
53
62
 
54
63
  var refineSections = exports.refineSections = function refineSections(sections, extractedKeys, curatedObs) {
55
64
  return R.pipe(R.map(function (section) {
56
- var sectionKey = R.join(':', R.head(section) || []);
65
+ var sectionKey = toKey(R.head(section) || []);
57
66
  return R.over(R.lensIndex(1), R.filter(function (rowData) {
58
- var rowKey = R.join(':', rowData);
67
+ var rowKey = toKey(rowData);
59
68
  return R.pipe(R.path([sectionKey, rowKey]), R.omit(extractedKeys), R.isEmpty, R.not)(curatedObs);
60
69
  }))(section);
61
70
  }), R.filter(R.pipe(R.nth(1), R.isEmpty, R.not)))(sections);
@@ -64,7 +73,7 @@ var refineSections = exports.refineSections = function refineSections(sections,
64
73
  var refineHeader = exports.refineHeader = function refineHeader(header, extractedKeys, curatedObs) {
65
74
  return R.filter( // extracted : { [sectionKey]: [...rowKeys] }
66
75
  function (header) {
67
- var headerKey = R.join(':', header);
76
+ var headerKey = toKey(header);
68
77
  return R.pipe(R.prop(headerKey), function (sections) {
69
78
  return R.pickBy(function (rows, section) {
70
79
  return R.pipe(R.omit(R.propOr([], section, extractedKeys)), R.isEmpty, R.not)(rows);
@@ -81,7 +90,7 @@ var truncateSectionRows = exports.truncateSectionRows = function truncateSection
81
90
  var lastSection = R.last(truncated);
82
91
  var rows = lastSection[1];
83
92
  var rowsLength = R.length(rows);
84
- var sectionKey = R.join(':', R.head(lastSection));
93
+ var sectionKey = toKey(R.head(lastSection));
85
94
  if (rowsLength > _n) {
86
95
  var _R$splitAt = R.splitAt(R.negate(_n), rows),
87
96
  _R$splitAt2 = (0, _slicedToArray3.default)(_R$splitAt, 2),
@@ -90,11 +99,11 @@ var truncateSectionRows = exports.truncateSectionRows = function truncateSection
90
99
 
91
100
  var updatedSection = R.set(R.lensIndex(1), rest)(lastSection);
92
101
  truncated = R.set(R.lensIndex(-1), updatedSection)(truncated);
93
- extractedKeys = (0, _extends5.default)({}, extractedKeys, (0, _defineProperty3.default)({}, sectionKey, R.map(R.join(':'), extracted)));
102
+ extractedKeys = (0, _extends5.default)({}, extractedKeys, (0, _defineProperty3.default)({}, sectionKey, R.map(toKey, extracted)));
94
103
  _n = 0;
95
104
  } else {
96
105
  truncated = R.dropLast(1, truncated);
97
- extractedKeys = (0, _extends5.default)({}, extractedKeys, (0, _defineProperty3.default)({}, sectionKey, R.map(R.join(':'), rows)));
106
+ extractedKeys = (0, _extends5.default)({}, extractedKeys, (0, _defineProperty3.default)({}, sectionKey, R.map(toKey, rows)));
98
107
  _n = _n - rowsLength;
99
108
  }
100
109
  }
@@ -107,7 +116,7 @@ var truncateHeader = exports.truncateHeader = function truncateHeader(n, headerD
107
116
  truncated = _R$splitAt4[0],
108
117
  extracted = _R$splitAt4[1];
109
118
 
110
- return { truncated: truncated, extractedKeys: R.map(R.join(':'), extracted) };
119
+ return { truncated: truncated, extractedKeys: R.map(toKey, extracted) };
111
120
  };
112
121
 
113
122
  var truncateLayout = function truncateLayout(isVertical) {
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.getLayoutEntryMetadataCoordinates = undefined;
6
+ exports.trimedProps = undefined;
7
7
 
8
8
  var _ramda = require('ramda');
9
9
 
@@ -11,8 +11,11 @@ var R = _interopRequireWildcard(_ramda);
11
11
 
12
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
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) {};
14
+ var trimedProps = exports.trimedProps = function trimedProps(properties, obj) {
15
+ return R.reduce(function (acc, prop) {
16
+ if (!R.has(prop, obj)) {
17
+ return acc;
18
+ }
19
+ return R.append(obj[prop], acc);
20
+ }, [], properties);
21
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sis-cc/dotstatsuite-components",
3
3
  "description": "Set components based on React.",
4
- "version": "15.0.20",
4
+ "version": "16.0.0",
5
5
  "main": "lib/index.js",
6
6
  "author": "OECD",
7
7
  "license": "MIT",
@@ -381,10 +381,7 @@ export {
381
381
  } from './properties';
382
382
  export { dataTransformer as v8Transformer } from './v8-transformer';
383
383
  export {
384
- prepareData,
385
384
  getCellValue,
386
- getTableProps,
387
- getFlags,
388
385
  } from './table';
389
386
  export {
390
387
  getFullName,
@@ -396,20 +393,5 @@ export { getObservationsType } from './properties/getObservationsType';
396
393
  export { getAvailableChartTypes } from './properties/getAvailableChartTypes';
397
394
  export { isSharedLayoutCompatible } from './layout';
398
395
 
399
- export { parseDimensionsIds } from './table/preparators/parseDimensionsIds';
400
- export { parseAttributes } from './table/preparators/parseAttributes';
401
- export { getDimensionsAttributesRegisters } from './table/preparators/getDimensionsAttributesRegisters';
402
- export { parseAttributesValuesFromObservations } from './table/preparators/parseAttributesValuesFromObservations';
403
- export { getOneValueDimensions } from './table/preparators/getOneValueDimensions';
404
- export { getManyValuesDimensions } from './table/preparators/getManyValuesDimensions';
405
- export { getAttributeValue } from './table/preparators/getAttributeValue';
406
- export { refineSeriesAttributesValues } from './table/preparators/refineSeriesAttributesValues';
407
-
408
- export { getUnitsDefinition } from './table/units/getUnitsDefinition';
409
- export { getUnitsArtefacts } from './table/units/getUnitsArtefacts';
410
- export { getHeaderUnits } from './table/units/getHeaderUnits';
411
- export { getAttachmentSeriesIndexes } from './table/units/getAttachmentSeriesIndexes';
412
- export { getUnitsSeries } from './table/units/getUnitsSeries';
413
-
414
396
  export { getObservations } from './preparators/getObservations';
415
- export { enhanceObservations } from './preparators/enhanceObservations';
397
+
@@ -1,5 +1 @@
1
- export { prepareData } from './preparators/prepareData';
2
- export { getCells, getFlags } from './factories/getCells';
3
- export { getTableCells } from './factories/getTableCells';
4
- export { getTableProps } from './factories/getTableData';
5
1
  export { getCellValue } from './factories/getCellValue';
@@ -2,7 +2,8 @@ import * as R from 'ramda';
2
2
  import dateFns from 'date-fns';
3
3
  import { getCodeOrder, getRefinedName, isTimePeriodDimension } from '@sis-cc/dotstatsuite-sdmxjs';
4
4
  import {
5
- getRelationnalAnnotations, setAnnotationsLayout, getIsHidden } from './sdmx-data';
5
+ getRelationnalAnnotations, setAnnotationsLayout, getIsHidden
6
+ } from './sdmx-data';
6
7
  import { getReportedTimePeriodLabel, getReportedTimePeriodNote, getReportedTimePeriod } from './date';
7
8
  import { getReportingYearStart } from './preparators/getReportingYearStart';
8
9
  import { getNotDisplayedIds } from '../../rules2/src';
@@ -10,18 +11,18 @@ import { getNotDisplayedIds } from '../../rules2/src';
10
11
  const TIME_PERIOD_ID = 'TIME_PERIOD';
11
12
 
12
13
  export const dataTransformer = (dataNew, options = {}) => {
13
- const { locale } = options;
14
+ const { locale, hiddenIds: _hiddenIds } = options;
14
15
  const reportYearStart = getReportingYearStart(dataNew);
15
16
 
16
17
  //---------------------------------------------------------------------------------------Annotations
17
- const getStructure = R.pathOr({},['data', 'structure']);
18
+ const getStructure = R.pathOr({}, ['data', 'structure']);
18
19
  const structure = getStructure(dataNew);
19
20
  const getAnnotations = R.propOr([], 'annotations');
20
21
  const annotations = getAnnotations(structure);
21
- const getDataSets = R.pathOr({},['data', 'dataSets']);
22
+ const getDataSets = R.pathOr({}, ['data', 'dataSets']);
22
23
  const dataSets = getDataSets(dataNew);
23
24
 
24
- const dataSetsAnnotations = R.props(R.pathOr([],[0, 'annotations'], dataSets), annotations);
25
+ const dataSetsAnnotations = R.props(R.pathOr([], [0, 'annotations'], dataSets), annotations);
25
26
 
26
27
  const hiddenIds = getNotDisplayedIds(dataSetsAnnotations);
27
28
 
@@ -35,64 +36,64 @@ export const dataTransformer = (dataNew, options = {}) => {
35
36
  });
36
37
  }, values);
37
38
 
38
- const getValuesEnhanced = (locale, annotations, isTimeDimension, parent) =>
39
- R.pipe(
40
- R.addIndex(R.map)((value, __index) => {
41
- const valueAnnotations = R.pipe(
42
- R.propOr([], 'annotations'),
43
- R.flip(R.props)(annotations)
44
- )(value);
45
- const isHidden = R.has(`${parent}.${value.id}`, hiddenIds) || getIsHidden(valueAnnotations);
46
- const name = getRefinedName(value);
47
- let __indexPosition = NaN;
48
- let notes = [];
49
- let start = null;
50
- let end = null;
51
- if (isTimeDimension) {
52
- const reported = getReportedTimePeriod(reportYearStart, value, options.frequency);
53
- start = reported.start;
54
- end = reported.end;
55
- const reportTimeNote = getReportedTimePeriodNote(reportYearStart, start, end, options.frequency, options.isRtl);
56
- notes = R.isNil(reportTimeNote) ? notes : R.append(reportTimeNote, notes);
57
- __indexPosition = dateFns.getTime(new Date(R.prop('start', value)));
58
- }
59
- if (isNaN(__indexPosition)) {
60
- __indexPosition = getCodeOrder({ annotations: valueAnnotations });
61
- }
62
- const timeFormat = R.prop('timeFormat', options);
63
- return ({
64
- ...value,
65
- id: R.pipe(
66
- R.when(
67
- R.isNil,
68
- R.always(`${parent}-${__index}`)
69
- ),
70
- R.when(
39
+ const getValuesEnhanced = (locale, annotations, isTimeDimension, parent) =>
40
+ R.pipe(
41
+ R.addIndex(R.map)((value, __index) => {
42
+ const valueAnnotations = R.pipe(
43
+ R.propOr([], 'annotations'),
44
+ R.flip(R.props)(annotations)
45
+ )(value);
46
+ const isHidden = (_hiddenIds[parent] && R.includes(value.id, _hiddenIds[parent])) || R.has(`${parent}.${value.id}`, hiddenIds) || getIsHidden(valueAnnotations);
47
+ const name = getRefinedName(value);
48
+ let __indexPosition = NaN;
49
+ let notes = [];
50
+ let start = null;
51
+ let end = null;
52
+ if (isTimeDimension) {
53
+ const reported = getReportedTimePeriod(reportYearStart, value, options.frequency);
54
+ start = reported.start;
55
+ end = reported.end;
56
+ const reportTimeNote = getReportedTimePeriodNote(reportYearStart, start, end, options.frequency, options.isRtl);
57
+ notes = R.isNil(reportTimeNote) ? notes : R.append(reportTimeNote, notes);
58
+ __indexPosition = dateFns.getTime(new Date(R.prop('start', value)));
59
+ }
60
+ if (isNaN(__indexPosition)) {
61
+ __indexPosition = getCodeOrder({ annotations: valueAnnotations });
62
+ }
63
+ const timeFormat = R.prop('timeFormat', options);
64
+ return ({
65
+ ...value,
66
+ id: R.pipe(
67
+ R.when(
68
+ R.isNil,
69
+ R.always(`${parent}-${__index}`)
70
+ ),
71
+ R.when(
72
+ R.always(isTimeDimension),
73
+ R.replace(/M/g, '')
74
+ )
75
+ )(value.id),
76
+ display: !isHidden,
77
+ name: R.when(
71
78
  R.always(isTimeDimension),
72
- R.replace(/M/g, '')
73
- )
74
- )(value.id),
75
- display: !isHidden,
76
- name: R.when(
77
- R.always(isTimeDimension),
78
- R.always(getReportedTimePeriodLabel(options.frequency, timeFormat, locale)(reportYearStart, { id: value.id, reportedStart: start, start: new Date(value.start) }))
79
- )(name),
80
- start: start ? start.toISOString() : null,
81
- notes,
82
- __indexPosition,
83
- __index,
84
- });
85
- }),
86
- R.sortWith([
87
- R.ascend(R.prop('__indexPosition')),
88
- R.ascend(R.propOr(-1, 'order'))
89
- ]),
90
- R.addIndex(R.map)((val, index) => R.assoc('__indexPosition', index, val)),
91
- /* NEW */
92
- R.sortBy(R.prop('__index'))
93
- );
94
-
95
- //--------------------------------------------------------------------------------------------Header
79
+ R.always(getReportedTimePeriodLabel(options.frequency, timeFormat, locale)(reportYearStart, { id: value.id, reportedStart: start, start: new Date(value.start) }))
80
+ )(name),
81
+ start: start ? start.toISOString() : null,
82
+ notes,
83
+ __indexPosition,
84
+ __index,
85
+ });
86
+ }),
87
+ R.sortWith([
88
+ R.ascend(R.prop('__indexPosition')),
89
+ R.ascend(R.propOr(-1, 'order'))
90
+ ]),
91
+ R.addIndex(R.map)((val, index) => R.assoc('__indexPosition', index, val)),
92
+ /* NEW */
93
+ R.sortBy(R.prop('__index'))
94
+ );
95
+
96
+ //--------------------------------------------------------------------------------------------Header
96
97
  const getMeta = R.propOr({}, 'meta');
97
98
  const meta = getMeta(dataNew);
98
99
 
@@ -101,10 +102,10 @@ export const dataTransformer = (dataNew, options = {}) => {
101
102
 
102
103
  const resHeader = {
103
104
  ...meta,
104
- sender: {...sender, name: getRefinedName(sender)},
105
+ sender: { ...sender, name: getRefinedName(sender) },
105
106
  };
106
107
 
107
- //----------------------------------------------------------------------------------------Attributes
108
+ //----------------------------------------------------------------------------------------Attributes
108
109
  const getAttributes = R.propOr({}, 'attributes');
109
110
  const attributes = getAttributes(structure);
110
111
 
@@ -140,7 +141,7 @@ export const dataTransformer = (dataNew, options = {}) => {
140
141
  observation: R.concat(resAttrObservations, datasetAttributes)
141
142
  };
142
143
 
143
- //----------------------------------------------------------------------------------------Dimensions
144
+ //----------------------------------------------------------------------------------------Dimensions
144
145
  const getDimensions = R.propOr({}, 'dimensions');
145
146
  const dimensions = getDimensions(structure);
146
147
 
@@ -149,25 +150,25 @@ export const dataTransformer = (dataNew, options = {}) => {
149
150
 
150
151
  const getObservations = locale => R.addIndex(R.reduce)((acc, observation, obsIndex) => {
151
152
  const id = R.prop('id')(observation);
152
- const dimAnnotations = getRelationnalAnnotations(R.propOr([],'annotations')(observation))(annotations)
153
- const isHidden = R.has(id, hiddenIds) || getIsHidden(dimAnnotations);
153
+ const dimAnnotations = getRelationnalAnnotations(R.propOr([], 'annotations')(observation))(annotations)
154
154
  const isTime = isTimePeriodDimension(observation);
155
- const values = getValuesEnhanced(locale, annotations, isTime, id)(R.propOr([],'values', observation));
156
-
155
+ const values = getValuesEnhanced(locale, annotations, isTime, id)(R.propOr([], 'values', observation));
156
+ const _idHidden = _hiddenIds[id] && R.isEmpty(R.difference(_hiddenIds[id], R.pluck('id')(values)))
157
+ const isHidden = _idHidden || R.has(id, hiddenIds) || getIsHidden(dimAnnotations);
157
158
  return ({
158
159
  observation: R.append({
159
160
  ...observation,
160
161
  display: !isHidden,
161
162
  __index: obsIndex,
162
163
  name: getRefinedName(observation),
163
- values,
164
+ values: _idHidden ? [] : values,
164
165
  role: isTime ? TIME_PERIOD_ID : R.head(R.propOr([], 'roles', observation)),
165
166
  })(acc.observation),
166
167
  dimensionsLayout: setAnnotationsLayout(id, acc.dimensionsLayout)(dimAnnotations),
167
168
  });
168
- }, { observation: [], dimensionsLayout: {}});
169
+ }, { observation: [], dimensionsLayout: {} });
169
170
 
170
- //-----------------------------------------------------------------------------------------Structure
171
+ //-----------------------------------------------------------------------------------------Structure
171
172
  const { dimensionsLayout, observation } = getObservations(locale)(dimObservations);
172
173
  const resStructure = {
173
174
  ...structure,
@@ -177,12 +178,12 @@ export const dataTransformer = (dataNew, options = {}) => {
177
178
  dimensions: { observation },
178
179
  };
179
180
 
180
- //------------------------------------------------------------------------------------------------------Layout
181
+ //------------------------------------------------------------------------------------------------------Layout
181
182
  const dataSetsLayout = R.reduce((acc, dataSetsAnnotation) => {
182
183
  const title = R.propOr('', 'title')(dataSetsAnnotation);
183
184
  if (R.isEmpty(title)) return acc;
184
185
  return setAnnotationsLayout(title, acc)([dataSetsAnnotation])
185
186
  }, {})(dataSetsAnnotations);
186
187
 
187
- return ({ data: { header: resHeader, dataSets, structure: resStructure }, layout: R.mergeRight(dimensionsLayout, dataSetsLayout)});
188
+ return ({ data: { header: resHeader, dataSets, structure: resStructure }, layout: R.mergeRight(dimensionsLayout, dataSetsLayout) });
188
189
  };
@@ -1,2 +1,4 @@
1
1
  export const SDMX_3_0_JSON_DATA_FORMAT = 'application/vnd.sdmx.data+json;version=2.0';
2
2
  export const SDMX_3_0_CSV_DATA_FORMAT = 'application/vnd.sdmx.data+csv;version=2.0';
3
+ export const REPORTING_YEAR_START_DAY = 'REPORTING_YEAR_START_DAY';
4
+ export const REPYEARSTART = 'REPYEARSTART';
@@ -0,0 +1,88 @@
1
+ import * as R from 'ramda';
2
+ import { formatValue } from '../../rules/src/preparators/formatValue';
3
+
4
+ /*
5
+ options = {
6
+ customAttributes: {
7
+ decimals: id,
8
+ prefscale: id,
9
+ },
10
+ rejectedValueIds,
11
+ }
12
+ */
13
+
14
+ const parseAttributesValues = (obs, attributes, indexedDimensions, rejectedValueIds) => {
15
+ const { attrValuesIndexes, dimValuesIndexes } = obs;
16
+ return R.addIndex(R.reduce)(
17
+ (acc, valueIndex, attrIndex) => {
18
+ const attribute = R.nth(attrIndex, attributes);
19
+ if (R.isNil(attribute) || !R.propOr(true, 'display', attribute) || !R.prop('series', attribute)) {
20
+ return acc;
21
+ }
22
+ let value = R.nth(valueIndex, attribute.values || []);
23
+ if (!R.propOr(true, 'display', value) || R.includes(R.prop('id', value), rejectedValueIds)) {
24
+ value = null;
25
+ }
26
+ const relationship = R.propOr([], 'relationship', attribute);
27
+ let coordinates = {};
28
+ const serieKey = R.pipe(
29
+ dims => R.isEmpty(relationship) ? R.values(dims) : R.props(relationship, dims),
30
+ R.map(dim => {
31
+ const valueIndex = R.nth(dim.__index, dimValuesIndexes);
32
+ const valueId = R.path(['values', valueIndex, 'id'], dim);
33
+ coordinates = R.assoc(dim.id, valueId, coordinates);
34
+ return `${dim.id}=${valueId}`;
35
+ }),
36
+ R.ifElse(R.isEmpty, R.always(null), R.join(':'))
37
+ )(indexedDimensions);
38
+
39
+ return R.assoc(attribute.id, { ...R.pick(['id', 'name', 'relationship'], attribute), value, serieKey, coordinates, isObs: R.isEmpty(relationship) }, acc);
40
+ },
41
+ {},
42
+ attrValuesIndexes
43
+ );
44
+ };
45
+
46
+ const getFormatAttributesIndexes = (attributes, customAttributes) => R.addIndex(R.reduce)(
47
+ (acc, attribute, index) => {
48
+ if (R.equals(attribute.id, customAttributes.decimals)) {
49
+ return ({ ...acc, decimals: index });
50
+ }
51
+ if (R.equals(attribute.id, customAttributes.prefscale)) {
52
+ return ({ ...acc, prefscale: index });
53
+ }
54
+ return acc;
55
+ },
56
+ { prefscale: null, decimals: null },
57
+ attributes
58
+ );
59
+
60
+ export const enhanceObservations = (dimensions = [], observations = {}, attributes = [], options = {}) => {
61
+ const formatAttributesIndexes = getFormatAttributesIndexes(attributes, R.propOr({}, 'customAttributes', options));
62
+ const indexedDimensions = R.indexBy(R.prop('id'), dimensions);
63
+
64
+ return R.mapObjIndexed(
65
+ (observation) => {
66
+ const { dimValuesIndexes } = observation;
67
+
68
+ const indexedDimValIds = R.addIndex(R.reduce)(
69
+ (acc, dimension, dimensionIndex) => {
70
+ const id = dimension.id;
71
+ const valueIndex = R.nth(dimensionIndex, dimValuesIndexes);
72
+ const valueId = R.path(['values', Number(valueIndex), 'id'], dimension);
73
+ return R.assoc(id, valueId, acc);
74
+ },
75
+ {},
76
+ dimensions
77
+ );
78
+
79
+ return ({
80
+ ...observation,
81
+ attributes: parseAttributesValues(observation, attributes, indexedDimensions, R.propOr([], 'rejectedValueIds', options)),
82
+ formattedValue: formatValue(observation, formatAttributesIndexes, attributes),
83
+ indexedDimValIds,
84
+ });
85
+ },
86
+ observations
87
+ );
88
+ };
@@ -0,0 +1,29 @@
1
+ import * as R from 'ramda';
2
+
3
+ export const getAttributesSeries = observations => R.pipe(
4
+ R.values,
5
+ R.reduce(
6
+ (acc, { attributes }) => {
7
+ let res = acc.res;
8
+ let rejected = acc.rejected;
9
+ R.forEachObjIndexed(
10
+ (attribute) => {
11
+ if (!R.isNil(attribute.serieKey)) {
12
+ const valueInRes = R.path([attribute.serieKey, attribute.id, 'value', 'id'], res);
13
+ if (!R.isNil(valueInRes) && valueInRes !== R.path(['value', 'id'], attribute)) {
14
+ res = R.dissocPath([attribute.serieKey, attribute.id], res);
15
+ rejected = R.assocPath([attribute.serieKey, attribute.id], true, rejected);
16
+ }
17
+ else {
18
+ res = R.assocPath([attribute.serieKey, attribute.id], attribute, res);
19
+ }
20
+ }
21
+ },
22
+ attributes
23
+ );
24
+ return ({ res, rejected });
25
+ },
26
+ { res: {}, rejected: {}, }
27
+ ),
28
+ R.prop('res')
29
+ )(observations);
@@ -0,0 +1,29 @@
1
+ import * as R from 'ramda';
2
+
3
+ export const getCombinationDefinitions = (annotations, locale) => {
4
+ const annotation = R.find(annot => annot.type === 'COMBINED_CONCEPTS', annotations);
5
+ if (R.isNil(annotation)) {
6
+ return [];
7
+ }
8
+ const title = R.propOr('', 'title', annotation);
9
+ const texts = R.propOr({}, 'texts', annotation);
10
+
11
+ return R.useWith(
12
+ (titles, texts) =>
13
+ R.addIndex(R.map)((title, index) => {
14
+ const split = R.split(':', title);
15
+ if (R.length(split !== 2)) {
16
+ return null;
17
+ }
18
+ const [id, codes] = split;
19
+ return {
20
+ id,
21
+ concepts: R.split(',', codes),
22
+ name: R.has(locale, texts)
23
+ ? R.pipe(R.prop(locale), R.nth(index), R.split(':'), R.last)(texts)
24
+ : `[${id}]`,
25
+ };
26
+ }, titles),
27
+ [R.split(';'), R.map(R.split(';'))],
28
+ )(title, texts);
29
+ };
@@ -0,0 +1,39 @@
1
+ import * as R from 'ramda';
2
+ import { dimensionValueDisplay } from '../../rules/src';
3
+
4
+ export const getHeaderCombinations = (combinations, dimensions, attributes, display) => {
5
+ const indexedDimensions = R.indexBy(R.prop('id'), dimensions);
6
+ const indexedAttributes = R.indexBy(R.prop('id'), attributes);
7
+ return R.reduce(
8
+ (acc, comb) => {
9
+ if (!R.prop('header', comb)) {
10
+ return acc;
11
+ }
12
+
13
+ const header = dimensionValueDisplay(display)(comb);
14
+
15
+ const values = R.pipe(
16
+ R.reduce((_acc, concept) => {
17
+ const artefact = R.has(concept, indexedDimensions)
18
+ ? R.prop(concept, indexedDimensions)
19
+ : R.prop(concept, indexedAttributes);
20
+ if (R.isNil(artefact) || !R.prop('display', artefact || {})) {
21
+ return _acc;
22
+ }
23
+ const value = R.path(['values', 0], artefact);
24
+ if (R.isNil(value) || !R.prop('display', value || {})) {
25
+ return _acc;
26
+ }
27
+ return R.append(dimensionValueDisplay(display)(value), _acc);
28
+ }, []),
29
+ R.join(', '),
30
+ )(comb.concepts || []);
31
+ if (R.isEmpty(values)) {
32
+ return acc;
33
+ }
34
+ return R.append({ header, label: values }, acc);
35
+ },
36
+ [],
37
+ combinations,
38
+ );
39
+ };
@@ -0,0 +1,34 @@
1
+ import * as R from 'ramda';
2
+ import { getFlagsAndNotes } from './table/getFlagsAndNotes';
3
+ import { dimensionValueDisplay } from '../../rules/src/';
4
+
5
+ export const getHeaderSubtitle = (dimensions, combinations, customAttributes, display, microdataDimension) => {
6
+ const combinationsConepts = R.pipe(R.pluck('concepts'), R.unnest)(combinations);
7
+ const DEFAULT_REJECTED_SUBTITLE_IDS = ['_L', '_T', '_Z'];
8
+
9
+ return R.reduce(
10
+ (acc, dim) => {
11
+ if (!R.propOr(true, 'display', dim) || R.propEq('id', microdataDimension, dim)
12
+ || R.includes(dim.id, combinationsConepts)) {
13
+ return acc;
14
+ }
15
+ const value = R.path(['values', 0], dim);
16
+ if (!R.propOr(true, 'display', value) || R.includes(value.id, DEFAULT_REJECTED_SUBTITLE_IDS)) {
17
+ return acc;
18
+ }
19
+ const header = `${dimensionValueDisplay(display)(dim)}:`;
20
+ const label = dimensionValueDisplay(display)(value);
21
+ const flags = R.pipe(
22
+ getFlagsAndNotes,
23
+ R.map(entry => ({
24
+ code: entry.code,
25
+ header: `${dimensionValueDisplay(display)(entry)}:`,
26
+ label: dimensionValueDisplay(display)(entry.value),
27
+ })),
28
+ )(dim.attrValues, customAttributes);
29
+ return R.append({ header, label, flags }, acc);
30
+ },
31
+ [],
32
+ dimensions,
33
+ );
34
+ };
@@ -0,0 +1,34 @@
1
+ import * as R from 'ramda';
2
+ import { getFlagsAndNotes } from './table/getFlagsAndNotes';
3
+
4
+ export const getManyValuesDimensions = (dimensions, attributesSeries, customAttributes, combinations) => {
5
+ const combConceptsIds = R.pipe(R.pluck('concepts'), R.unnest)(combinations);
6
+ return R.reduce(
7
+ (acc, dim) => {
8
+ if (R.length(dim.values || []) < 2) {
9
+ return acc;
10
+ }
11
+ const enhancedValues = R.map(val => {
12
+ const attrSeries = R.propOr({}, `${dim.id}=${val.id}`, attributesSeries);
13
+ if (R.isEmpty(attrSeries)) {
14
+ return val;
15
+ }
16
+ const flags = getFlagsAndNotes(attrSeries, customAttributes);
17
+ const hasAdvancedAttributes = R.pipe(
18
+ R.omit(
19
+ R.unnest([
20
+ customAttributes.flags || [],
21
+ customAttributes.notes || [],
22
+ combConceptsIds,
23
+ ]),
24
+ ),
25
+ R.complement(R.isEmpty),
26
+ )(attrSeries);
27
+ return { ...val, flags, hasAdvancedAttributes };
28
+ }, dim.values);
29
+ return R.append(R.assoc('values', enhancedValues, dim), acc);
30
+ },
31
+ [],
32
+ dimensions,
33
+ );
34
+ };
@@ -23,10 +23,14 @@ export const getNotDisplayedIds = (annotations) => R.pipe(
23
23
  }
24
24
  return R.reduce(
25
25
  (_acc, val) => {
26
+ let _val = val
26
27
  if (R.isEmpty(val)) {
27
28
  return _acc;
28
29
  }
29
- const key = `${dimensionId}.${val}`;
30
+ if (R.test('/[()]/')) {
31
+ _val = R.replace(/[()]/g, '')(val)
32
+ }
33
+ const key = R.isEmpty(_val) ? dimensionId : `${dimensionId}.${_val}`;
30
34
  return R.assoc(key, key, _acc);
31
35
  },
32
36
  acc,