@sis-cc/dotstatsuite-components 21.0.1 → 21.1.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 (234) hide show
  1. package/dist/dotstatsuite-components.js +38112 -0
  2. package/package.json +4 -1
  3. package/.editorconfig +0 -19
  4. package/.gitlab-ci.yml +0 -48
  5. package/prettier.config.js +0 -13
  6. package/src/app.js +0 -13
  7. package/src/bridge-d3-react/README.md +0 -42
  8. package/src/bridge-d3-react/src/app.js +0 -64
  9. package/src/bridge-d3-react/src/index.js +0 -17
  10. package/src/bridge-d3-react/src/mock-choro.js +0 -394
  11. package/src/bridge-d3-react/src/react-chart-factory.js +0 -65
  12. package/src/index.js +0 -12
  13. package/src/rules/README.md +0 -23
  14. package/src/rules/src/chart/getAxisOptions.js +0 -258
  15. package/src/rules/src/chart/getBaseOptions.js +0 -84
  16. package/src/rules/src/chart/getChartOptions.js +0 -118
  17. package/src/rules/src/chart/getGridOptions.js +0 -52
  18. package/src/rules/src/chart/getTooltipOptions.js +0 -230
  19. package/src/rules/src/constants.js +0 -64
  20. package/src/rules/src/date.js +0 -118
  21. package/src/rules/src/dimension-utils.js +0 -54
  22. package/src/rules/src/factories/choro-series.js +0 -65
  23. package/src/rules/src/factories/sample-focus.js +0 -22
  24. package/src/rules/src/factories/sample-series.js +0 -51
  25. package/src/rules/src/factories/scatter-dimension.js +0 -31
  26. package/src/rules/src/factories/scatter-focus.js +0 -39
  27. package/src/rules/src/factories/scatter-series.js +0 -94
  28. package/src/rules/src/factories/stacked-dimension.js +0 -29
  29. package/src/rules/src/factories/stacked-series.js +0 -185
  30. package/src/rules/src/factories/symbol-dimension.js +0 -29
  31. package/src/rules/src/factories/symbol-series.js +0 -62
  32. package/src/rules/src/factories/timeline-focus.js +0 -18
  33. package/src/rules/src/factories/timeline-series.js +0 -91
  34. package/src/rules/src/get-values-enhanced.js +0 -134
  35. package/src/rules/src/header/getDefaultSubtitle.js +0 -40
  36. package/src/rules/src/header/getHeaderUnits.js +0 -17
  37. package/src/rules/src/header/getSubtitleFlags.js +0 -43
  38. package/src/rules/src/header/getTitleFlags.js +0 -8
  39. package/src/rules/src/header/index.js +0 -4
  40. package/src/rules/src/index.js +0 -398
  41. package/src/rules/src/layout.js +0 -113
  42. package/src/rules/src/observation-formater.js +0 -83
  43. package/src/rules/src/preparators/enhanceObservations.js +0 -152
  44. package/src/rules/src/preparators/formatValue.js +0 -84
  45. package/src/rules/src/preparators/getObservations.js +0 -19
  46. package/src/rules/src/preparators/getReportingYearStart.js +0 -16
  47. package/src/rules/src/properties/errors.js +0 -19
  48. package/src/rules/src/properties/focus.js +0 -69
  49. package/src/rules/src/properties/getAvailableChartTypes.js +0 -34
  50. package/src/rules/src/properties/getHeaderProps.js +0 -74
  51. package/src/rules/src/properties/getInformationsStateFromNewProps.js +0 -47
  52. package/src/rules/src/properties/getObservationsType.js +0 -29
  53. package/src/rules/src/properties/getStringifiedSubtitle.js +0 -6
  54. package/src/rules/src/properties/index.js +0 -424
  55. package/src/rules/src/properties/information.js +0 -84
  56. package/src/rules/src/properties/linear.js +0 -129
  57. package/src/rules/src/properties/scatter.js +0 -158
  58. package/src/rules/src/properties/stacked.js +0 -98
  59. package/src/rules/src/properties/symbol.js +0 -79
  60. package/src/rules/src/properties/utils.js +0 -110
  61. package/src/rules/src/sdmx-data/index.js +0 -39
  62. package/src/rules/src/table/factories/getCellValue.js +0 -50
  63. package/src/rules/src/table/index.js +0 -1
  64. package/src/rules/src/v8-transformer.js +0 -176
  65. package/src/rules/test/extractSdmxArtefacts.js +0 -26
  66. package/src/rules/test/get-values-enhanced.test.js +0 -127
  67. package/src/rules/test/oecd-HEALTH_PROT-no-freq.json +0 -2903
  68. package/src/rules/test/oecd-HEALTH_PROT-parsed.js +0 -398
  69. package/src/rules/test/oecd-HEALTH_PROT-wrong-freq.json +0 -2913
  70. package/src/rules/test/oecd-HEALTH_PROT.json +0 -2913
  71. package/src/rules/test/oecd-KEI.json +0 -372
  72. package/src/rules/test/scatter-property.js +0 -455
  73. package/src/rules/test/stacked-property.js +0 -273
  74. package/src/rules/test/symbol-property.js +0 -262
  75. package/src/rules/test/v8-transformer.test.js +0 -90
  76. package/src/rules2/src/applyHierarchicalCodesToDim.js +0 -149
  77. package/src/rules2/src/combinedValuesDisplay.js +0 -74
  78. package/src/rules2/src/constants.js +0 -6
  79. package/src/rules2/src/duplicateObservations.js +0 -35
  80. package/src/rules2/src/enhanceObservations.js +0 -95
  81. package/src/rules2/src/getAdvAttrSeriesAtCoordinates.js +0 -29
  82. package/src/rules2/src/getAttributesSeries.js +0 -36
  83. package/src/rules2/src/getCombinationDefinitions.js +0 -47
  84. package/src/rules2/src/getDataflowAttributes.js +0 -23
  85. package/src/rules2/src/getDataflowTooltipAttributesIds.js +0 -31
  86. package/src/rules2/src/getDimensionValuesIndexes.js +0 -13
  87. package/src/rules2/src/getHCodelistsRefsInData.js +0 -32
  88. package/src/rules2/src/getHeaderCombinations.js +0 -48
  89. package/src/rules2/src/getHeaderCoordinates.js +0 -7
  90. package/src/rules2/src/getHeaderSubtitle.js +0 -34
  91. package/src/rules2/src/getHeaderTitle.js +0 -15
  92. package/src/rules2/src/getMSDInformations.js +0 -23
  93. package/src/rules2/src/getManyValuesDimensions.js +0 -34
  94. package/src/rules2/src/getMetadataCoordinates.js +0 -37
  95. package/src/rules2/src/getMetadataStructureFromData.js +0 -17
  96. package/src/rules2/src/getNotDisplayedIds.js +0 -53
  97. package/src/rules2/src/getOneValueDimensions.js +0 -34
  98. package/src/rules2/src/getSeriesCombinations.js +0 -24
  99. package/src/rules2/src/hasCellMetadata.js +0 -14
  100. package/src/rules2/src/hierarchiseDimensionWithAdvancedHierarchy2.js +0 -57
  101. package/src/rules2/src/hierarchiseDimensionWithNativeHierarchy2.js +0 -35
  102. package/src/rules2/src/index.js +0 -50
  103. package/src/rules2/src/parseAttributes.js +0 -41
  104. package/src/rules2/src/parseCombinations.js +0 -102
  105. package/src/rules2/src/parseHierarchicalCodelist.js +0 -48
  106. package/src/rules2/src/parseMetadataSeries.js +0 -117
  107. package/src/rules2/src/prepareData.js +0 -73
  108. package/src/rules2/src/refineAttributes.js +0 -16
  109. package/src/rules2/src/refineDimensions.js +0 -18
  110. package/src/rules2/src/refineMetadataCoordinates.js +0 -28
  111. package/src/rules2/src/refineTimePeriod.js +0 -127
  112. package/src/rules2/src/sdmx3.0DataFormatPatch.js +0 -9
  113. package/src/rules2/src/table/declineObservationsOverAttributes.js +0 -32
  114. package/src/rules2/src/table/getCells.js +0 -93
  115. package/src/rules2/src/table/getCellsAttributesIds.js +0 -38
  116. package/src/rules2/src/table/getCellsMetadataCoordinates.js +0 -13
  117. package/src/rules2/src/table/getCombinationDimensionsData.js +0 -39
  118. package/src/rules2/src/table/getCuratedCells.js +0 -33
  119. package/src/rules2/src/table/getFlagsAndNotes.js +0 -23
  120. package/src/rules2/src/table/getIndexedCombinationsByDisplay.js +0 -16
  121. package/src/rules2/src/table/getLayout.js +0 -84
  122. package/src/rules2/src/table/getLayoutData2.js +0 -198
  123. package/src/rules2/src/table/getSortedLayoutIndexes.js +0 -124
  124. package/src/rules2/src/table/getTableLabelAccessor.js +0 -9
  125. package/src/rules2/src/table/getTableLayoutIds.js +0 -314
  126. package/src/rules2/src/table/getTableProps.js +0 -75
  127. package/src/rules2/src/table/parseSeriesIndexesHierarchies.js +0 -79
  128. package/src/rules2/src/table/parseValueHierarchy.js +0 -33
  129. package/src/rules2/src/table/refineLayoutSize2.js +0 -321
  130. package/src/rules2/src/utils.js +0 -37
  131. package/src/viewer/mocks/bar.js +0 -33
  132. package/src/viewer/mocks/gpp-symbol.js +0 -93
  133. package/src/viewer/mocks/gpp-time.js +0 -1103
  134. package/src/viewer/mocks/row.js +0 -39
  135. package/src/viewer/mocks/scatter.js +0 -93
  136. package/src/viewer/mocks/stack.js +0 -161
  137. package/src/viewer/src/app/leg.js +0 -36
  138. package/src/viewer/src/app/nodata-res.js +0 -22
  139. package/src/viewer/src/app/nodata-sized.js +0 -23
  140. package/src/viewer/src/app/one-table-cell.js +0 -70
  141. package/src/viewer/src/app/table.js +0 -423
  142. package/src/viewer/src/app/use-case-1.js +0 -33
  143. package/src/viewer/src/app/use-case-2.js +0 -38
  144. package/src/viewer/src/app/use-case-3.js +0 -18
  145. package/src/viewer/src/app.js +0 -116
  146. package/src/viewer/src/chart.js +0 -52
  147. package/src/viewer/src/chartUtils/options.js +0 -30
  148. package/src/viewer/src/chartUtils/series.js +0 -51
  149. package/src/viewer/src/footer.js +0 -24
  150. package/src/viewer/src/header.js +0 -10
  151. package/src/viewer/src/index.js +0 -158
  152. package/src/viewer/src/legends/AxisLegend.js +0 -41
  153. package/src/viewer/src/legends/ChartLegends.js +0 -66
  154. package/src/viewer/src/legends/FocusLegend.js +0 -63
  155. package/src/viewer/src/legends/Legend.js +0 -46
  156. package/src/viewer/src/legends/SeriesLegend.js +0 -78
  157. package/src/viewer/src/utils.js +0 -21
  158. package/test/applyHierarchicalCodesToDim.test.js +0 -160
  159. package/test/combinedValuesDisplay.test.js +0 -66
  160. package/test/duplicateObs.test.js +0 -118
  161. package/test/enhanceObservations2.test.js +0 -257
  162. package/test/getAttributesSeries.test.js +0 -66
  163. package/test/getAxisOptions.test.js +0 -309
  164. package/test/getBaseOptions.test.js +0 -77
  165. package/test/getCellValue.test.js +0 -32
  166. package/test/getCells.test.js +0 -178
  167. package/test/getCellsMetadataCoordinates.test.js +0 -40
  168. package/test/getCombinationDefinitions.test.js +0 -104
  169. package/test/getCombinationDimensionsData.test.js +0 -99
  170. package/test/getDataflowAttributes.test.js +0 -23
  171. package/test/getDataflowTooltipAttributesIds.test.js +0 -146
  172. package/test/getDimensionValuesIndexes.test.js +0 -33
  173. package/test/getGridOptions.test.js +0 -65
  174. package/test/getHCodelistsRefs.test.js +0 -23
  175. package/test/getHeaderCombinations.test.js +0 -62
  176. package/test/getHeaderTitle.test.js +0 -25
  177. package/test/getLayout.test.js +0 -54
  178. package/test/getLayoutData2.test.js +0 -535
  179. package/test/getMSDInformations.test.js +0 -35
  180. package/test/getMetadataCoordinates.test.js +0 -0
  181. package/test/getNotDisplayedIds.test.js +0 -47
  182. package/test/getObservationsType.test.js +0 -55
  183. package/test/getOneValueDimensions.test.js +0 -35
  184. package/test/getReportingYearStart.test.js +0 -59
  185. package/test/getSeriesCombinations.test.js +0 -29
  186. package/test/getSortedLayoutIndexes.test.js +0 -1138
  187. package/test/getTableLabelAccessor.test.js +0 -50
  188. package/test/getTableLayoutIds.test.js +0 -356
  189. package/test/hierarchiseDimensionWithNativeHierarchy2.test.js +0 -109
  190. package/test/isTableLayoutCompatible.test.js +0 -102
  191. package/test/metadata-parsing-perf.test.js +0 -509
  192. package/test/mocks/MSD_TEST.json +0 -490
  193. package/test/mocks/OECD_SNA_TABLE1_1.0_-_AUS_V_metadata.json +0 -152
  194. package/test/mocks/h-codelist.json +0 -2095
  195. package/test/mocks/large_metadata_series.json +0 -701
  196. package/test/mocks/observations-advanced-attributes.json +0 -55382
  197. package/test/mocks/table-invert-time--data.json +0 -80211
  198. package/test/mocks/table-invert-time--inverted.json +0 -80076
  199. package/test/mocks/table-layout-multi-hierarchies--layout.json +0 -621
  200. package/test/mocks/table-layout-multi-hierarchies--layoutData.json +0 -32411
  201. package/test/mocks/table-layout-multi-hierarchies--layoutIndexes.json +0 -2760
  202. package/test/mocks/table-layout-multi-hierarchies--observations.json +0 -30688
  203. package/test/mocks/table-layout-multi-hierarchies--sizedIndexes.json +0 -2762
  204. package/test/mocks/table-layout-truncation1--layout.json +0 -27469
  205. package/test/mocks/table-layout-truncation1--layoutData.json +0 -20358
  206. package/test/mocks/table-layout-truncation1--layoutIndexes.json +0 -7512
  207. package/test/mocks/table-layout-truncation1--observations.json +0 -70002
  208. package/test/mocks/table-layout-truncation1--sizedIndexes.json +0 -3011
  209. package/test/mocks/table-prep-multi-hierarchies--attributes.json +0 -46
  210. package/test/mocks/table-prep-multi-hierarchies--dimensions.json +0 -688
  211. package/test/mocks/table-prep-multi-hierarchies--enhancedObservations.json +0 -19696
  212. package/test/mocks/table-prep-multi-hierarchies--observations.json +0 -8246
  213. package/test/mocks/table-prep-multi-hierarchies--sdmxJson.json +0 -2985
  214. package/test/mocks/table-prep-simple-duplicate--dimensions2.json +0 -858
  215. package/test/mocks/table-prep-simple-duplicate--duplicated2.json +0 -77502
  216. package/test/mocks/table-prep-simple-duplicate--observations2.json +0 -60002
  217. package/test/mocks/table-prep-truncation1--dimensions.json +0 -35057
  218. package/test/mocks/table-prep-truncation1--enhancedObservations.json +0 -70002
  219. package/test/mocks/table-prep-truncation1--observations.json +0 -27502
  220. package/test/mocks/table-prep-truncation1--sdmxJson.json +0 -55103
  221. package/test/mocks/table-prep-units--observations.json +0 -284286
  222. package/test/mocks/table-prep-units--unitsSeries.json +0 -41042
  223. package/test/parseAttributes.test.js +0 -36
  224. package/test/parseCombinations.test.js +0 -172
  225. package/test/parseHierarchicalCodelist.test.js +0 -140
  226. package/test/parseMetadataSeries.test.js +0 -128
  227. package/test/parseSeriesIndexesHierarchies.test.js +0 -345
  228. package/test/parseValueHierarchy.test.js +0 -138
  229. package/test/refineAttributes.test.js +0 -29
  230. package/test/refineLayoutSize2.test.js +0 -3410
  231. package/test/refineMetadataCoordinates.test.js +0 -86
  232. package/test/refineTimePeriod.test.js +0 -580
  233. package/test/refinedDimensions.test.js +0 -35
  234. package/vite.config.mjs +0 -51
@@ -1,117 +0,0 @@
1
- import * as R from 'ramda';
2
- import { EMPTY_ATTACHMENT_LEVEL_CHAR } from './constants';
3
-
4
- const dimensionValueDisplay = (display) => data => {
5
- if (display === 'code') {
6
- return R.prop('id', data);
7
- }
8
- const name = R.prop('name')(data);
9
- if (display === 'both') {
10
- return `${R.prop('id', data)}: ${name}`;
11
- }
12
- return name;
13
- };
14
- // options = { locale, display, dimensions = [], attributes = { [id]: { format, parent } } };
15
- export const parseMetadataSeries = (metadataJson, options) => {
16
- const metadataAttributes = R.pathOr([], ['data', 'structures', 0, 'attributes', 'dimensionGroup'], metadataJson);
17
- const metaAttrLength = R.length(metadataAttributes);
18
-
19
- if (!metaAttrLength) {
20
- return ({});
21
- }
22
-
23
- const dimensions = R.pipe(
24
- R.pathOr([], ['data', 'structures', 0, 'dimensions']),
25
- ({ series = [], observation = [] }) => R.concat(series, observation),
26
- dims => R.isEmpty(options.dimensions || [])
27
- ? dims
28
- : R.props(R.pluck('id', options.dimensions), R.indexBy(R.prop('id'), dims))
29
- )(metadataJson);
30
-
31
- const metadataSeries = R.pipe(
32
- R.pathOr({}, ['data', 'dataSets', 0, 'dimensionGroupAttributes']),
33
- series => R.reduce((acc, serieKey) => {
34
- const indexes = series[serieKey];
35
- const metaIndexes = R.take(metaAttrLength, indexes);
36
-
37
- const evolvedKey = R.pipe(
38
- R.split(':'),
39
- R.addIndex(R.map)((vInd, dInd) => {
40
- if (R.isEmpty(vInd) || R.equals(EMPTY_ATTACHMENT_LEVEL_CHAR, vInd)) {
41
- return '';
42
- }
43
- const dim = R.nth(dInd, dimensions);
44
- const val = R.nth(Number(vInd), dim.values || []);
45
-
46
- const originalVal = R.find(
47
- R.propEq('id', val.id),
48
- )(R.propOr([], 'values', R.nth(dInd, options.dimensions)));
49
- return R.propOr('', '__index', originalVal);
50
- }),
51
- R.join(':')
52
- )(serieKey);
53
-
54
- const attributes = R.pipe(
55
- R.addIndex(R.reduce)(
56
- (acc, valueIndex, attrIndex) => {
57
- const attribute = R.nth(attrIndex, metadataAttributes);
58
- if (R.isNil(valueIndex) && !(attribute.isPresentational)) {
59
- return acc;
60
- }
61
- const attrOptions = R.pathOr({}, ['attributes', attribute.id], options);
62
- const id = attrOptions.id;
63
- const label = dimensionValueDisplay(options.display)({ ...attribute, id });
64
-
65
- const _value = R.prop('value', R.nth(valueIndex, attribute.values || []));
66
- const value = R.is(Object, _value) ? R.prop(options.locale, _value) : _value;
67
-
68
- return R.append({
69
- ...(R.isNil(value) ? {} : { value }),
70
- id: attribute.id,
71
- label,
72
- handlerProps: R.omit(['id'], R.pathOr({}, ['attributes', attribute.id], options))
73
- }, acc);
74
- },
75
- [],
76
- ),
77
- attributes => { // missing parents in metadata response
78
- const groupedAttrs = R.groupBy(R.pathOr('#ROOT', ['handlerProps', 'parent']), attributes);
79
- const indexedAttrs = R.indexBy(R.prop('id'), attributes);
80
-
81
- return R.reduce(
82
- (acc, id) => {
83
- if (R.has(id, indexedAttrs) || id === '#ROOT') {
84
- return acc;
85
- }
86
- return R.append({
87
- id,
88
- label: dimensionValueDisplay(options.display)({ id, name: R.path(['attributes', id, 'name'], options) }),
89
- handlerProps: R.omit(['id'], R.pathOr({}, ['attributes', id], options))
90
- }, acc);
91
- },
92
- attributes,
93
- R.keys(groupedAttrs)
94
- );
95
- },
96
- attributes => {
97
- const groupedAttrs = R.groupBy(R.pathOr('#ROOT', ['handlerProps', 'parent']), attributes);
98
- const makeTree = R.map(attr => {
99
- if (R.has(attr.id, groupedAttrs)) {
100
- const children = makeTree(R.prop(attr.id, groupedAttrs));
101
- return R.assoc('children', children, attr);
102
- }
103
- return attr;
104
- });
105
-
106
- return makeTree(R.propOr([], '#ROOT', groupedAttrs));
107
- },
108
- )(metaIndexes);
109
-
110
- return R.assoc(evolvedKey, attributes, acc);
111
- },
112
- {},
113
- R.keys(series)
114
- ))(metadataJson);
115
-
116
- return metadataSeries;
117
- };
@@ -1,73 +0,0 @@
1
- import * as R from 'ramda';
2
- import { getObservations } from '../../rules/src';
3
- import { refineDimensions } from './refineDimensions';
4
- import { enhanceObservations } from './enhanceObservations';
5
- import { parseAttributes } from './parseAttributes';
6
- import { getCombinationDefinitions, parseCombinationDefinition } from './getCombinationDefinitions';
7
- import { parseCombinations } from './parseCombinations';
8
- import { refineAttributes } from './refineAttributes';
9
- import { duplicateObs } from './duplicateObservations';
10
- import { getMetadataCoordinates } from './getMetadataCoordinates';
11
- import { getAttributesSeries } from './getAttributesSeries';
12
- import { getManyValuesDimensions } from './getManyValuesDimensions';
13
- import { getOneValueDimensions } from './getOneValueDimensions';
14
- import { hierarchiseDimensionWithNativeHierarchy } from './hierarchiseDimensionWithNativeHierarchy2';
15
- import { getDataflowAttributes } from './getDataflowAttributes';
16
- import { getHeaderTitle } from './getHeaderTitle';
17
- import { getHeaderSubtitle } from './getHeaderSubtitle';
18
- import { getHeaderCombinations } from './getHeaderCombinations';
19
- import { getHeaderCoordinates } from './getHeaderCoordinates';
20
- import { applyHierarchicalCodesToDim } from './applyHierarchicalCodesToDim';
21
-
22
- export const prepareData = (sdmxJson, { customAttributes, locale, hierarchies, dataflow, display, defaultCombinations, dataquery }) => {
23
- const dimensions = R.pathOr([], ['data', 'structure', 'dimensions', 'observation'], sdmxJson);
24
- const refinedDimensions = refineDimensions(dimensions, dataquery);
25
- const attributes = R.pathOr([], ['data', 'structure', 'attributes', 'observation'], sdmxJson);
26
- const annotations = R.pathOr([], ['data', 'structure', 'annotations'], sdmxJson);
27
- const observations = getObservations(sdmxJson);
28
- let combinations = getCombinationDefinitions(annotations, locale);
29
- if (R.isEmpty(combinations) && !R.isEmpty(defaultCombinations)) {
30
- const { concepts, names } = defaultCombinations;
31
- combinations = parseCombinationDefinition(locale)(concepts, names);
32
- }
33
- const metadataCoordinates = getMetadataCoordinates(sdmxJson);
34
-
35
- const parsedAttributes = parseAttributes(attributes, refinedDimensions, customAttributes);
36
- const parsedCombinations = parseCombinations(combinations, parsedAttributes, refinedDimensions);
37
- const seriesCombinations = R.filter(R.prop('series'), parsedCombinations);
38
- const refinedAttributes = refineAttributes(parsedAttributes, seriesCombinations);
39
-
40
- const enhancedObservations = enhanceObservations(refinedDimensions, observations, refinedAttributes, { customAttributes });
41
- const attributesSeries = getAttributesSeries(enhancedObservations);
42
- const manyValuesDimensions = getManyValuesDimensions(refinedDimensions, attributesSeries, customAttributes, seriesCombinations);
43
- const oneValueDimensions = getOneValueDimensions(refinedDimensions, parsedAttributes);
44
- const headerCoordinates = getHeaderCoordinates(oneValueDimensions);
45
- const hierarchisedDimensions = R.map(dim => {
46
- if (R.isEmpty(R.propOr({}, dim.id, hierarchies))) {
47
- return hierarchiseDimensionWithNativeHierarchy(dim);
48
- }
49
- return applyHierarchicalCodesToDim(R.prop(dim.id, hierarchies), dim);
50
- }, manyValuesDimensions)
51
- const duplicatedObservations = duplicateObs(R.values(hierarchisedDimensions), enhancedObservations);
52
-
53
- const dataflowAttributes = getDataflowAttributes(parsedAttributes, parsedCombinations);
54
- const headerTitle = getHeaderTitle(dataflow, dataflowAttributes, display, customAttributes);
55
- const headerSubtitle = getHeaderSubtitle(oneValueDimensions, parsedCombinations, customAttributes, display);
56
- const headerCombinations = getHeaderCombinations(parsedCombinations, oneValueDimensions, refinedAttributes, display);
57
-
58
- return ({
59
- observations: duplicatedObservations,
60
- dimensions: hierarchisedDimensions,
61
- combinations: parsedCombinations,
62
- oneValueDimensions,
63
- attributesSeries,
64
- metadataCoordinates,
65
- attributes: refinedAttributes,
66
- header: {
67
- title: headerTitle,
68
- subtitle: headerSubtitle,
69
- combinations: headerCombinations,
70
- coordinates: headerCoordinates
71
- }
72
- });
73
- };
@@ -1,16 +0,0 @@
1
- import * as R from 'ramda';
2
-
3
- export const refineAttributes = (parsedAttributes, seriesCombinations) => {
4
- const indexedRelationships = R.reduce(
5
- (acc, comb) =>
6
- R.reduce((_acc, concept) => R.assoc(concept, comb.relationship, _acc), acc, comb.concepts),
7
- {},
8
- seriesCombinations,
9
- );
10
- return R.map(attr => {
11
- if (R.has(attr.id, indexedRelationships)) {
12
- return { ...attr, series: true, relationship: R.prop(attr.id, indexedRelationships), combined: true };
13
- }
14
- return attr;
15
- }, parsedAttributes);
16
- };
@@ -1,18 +0,0 @@
1
- import * as R from 'ramda';
2
-
3
- export const refineDimensions = (dimensions=[], dataquery='') => {
4
- const selectionIds = R.pipe(R.split('.'), R.map(R.split('+')))(dataquery);
5
-
6
- return R.addIndex(R.map)((dim, index) => {
7
- const selection = R.nth(index, selectionIds);
8
- const values = R.map(val => {
9
- if (R.includes(val.id, selection || []) || R.isNil(selection) || R.length(selection) === 0 || R.isEmpty(R.head(selection))) {
10
- return R.assoc('isSelected', true, val);
11
- }
12
- return R.assoc('empty', true, val);
13
- }, dim.values || []);
14
-
15
- const size = R.length(values);
16
- return { ...dim, values, header: size === 1 || (size > 1 && R.length(selection) === 1 && !R.isEmpty(R.head(selection))) };
17
- }, dimensions);
18
- };
@@ -1,28 +0,0 @@
1
- import * as R from 'ramda';
2
-
3
- export const refineMetadataCoordinates = (metadataCoordinates, layoutIds) => {
4
- const relevantIds = R.pipe(R.values, R.unnest)(layoutIds);
5
- return R.reduce(
6
- (acc, coordinates) => {
7
- const refinedCoord = R.pick(relevantIds, coordinates);
8
- if (R.isEmpty(refinedCoord)) {
9
- return acc;
10
- }
11
- const removedHeaderCodes = R.omit(layoutIds.header, refinedCoord);
12
- if (R.isEmpty(removedHeaderCodes)) {
13
- return R.over(R.lensProp('header'), R.append(refinedCoord))(acc);
14
- }
15
- const removedSectionCodes = R.omit(layoutIds.sections, refinedCoord);
16
- if (R.isEmpty(removedSectionCodes)) {
17
- return R.over(R.lensProp('sections'), R.append(refinedCoord))(acc);
18
- }
19
- const removedRowsCodes = R.omit(layoutIds.rows, removedSectionCodes);
20
- if (R.isEmpty(removedRowsCodes)) {
21
- return R.over(R.lensProp('rows'), R.append(refinedCoord))(acc);
22
- }
23
- return R.over(R.lensProp('cells'), R.append(refinedCoord))(acc);
24
- },
25
- { cells: [], header: [], sections: [], rows: [] },
26
- metadataCoordinates
27
- );
28
- };
@@ -1,127 +0,0 @@
1
- import * as R from 'ramda';
2
- import * as dateFns from 'date-fns';
3
- import { getLocale, dateWithoutTZ } from '../../rules/src/date';
4
-
5
- const computeDisplayFreq = (start, duration) => {
6
- const startMinute = dateFns.startOfMinute(start);
7
- const startHour = dateFns.startOfHour(start);
8
- const startDay = dateFns.startOfDay(start);
9
- if (!dateFns.isEqual(start, startMinute) || duration === 'S') {
10
- return 'S';
11
- }
12
- else if (!dateFns.isEqual(start, startHour) || !dateFns.isEqual(start, startDay)
13
- || duration === 'H' || duration === 'm') {
14
- return 'm';
15
- }
16
- else if (!dateFns.isFirstDayOfMonth(start) || duration === 'D') {
17
- return 'D';
18
- }
19
- else if (dateFns.getMonth(start) !== 0 || duration === 'M') {
20
- return 'M';
21
- }
22
- return 'Y';
23
- };
24
-
25
- const getAdder = (duration) => {
26
- if (duration === 'S')
27
- return dateFns.addSeconds;
28
- if (duration === 'm')
29
- return dateFns.addMinutes;
30
- if (duration === 'H')
31
- return dateFns.addHours;
32
- if (duration === 'D')
33
- return dateFns.addDays;
34
- if (duration === 'M')
35
- return dateFns.addMonths;
36
- return dateFns.addYears;
37
- };
38
-
39
- const getFormat = (freqDisplay) => {
40
- if (freqDisplay === 'Y')
41
- return 'YYYY';
42
- if (freqDisplay === 'D')
43
- return 'YYYY-MM-DD';
44
- if (freqDisplay === 'H' || freqDisplay === 'm') {
45
- return 'HH:mm';
46
- }
47
- if (freqDisplay === 'S') {
48
- return 'HH:mm:ss';
49
- }
50
- return 'YYYY-MMM';
51
- }
52
-
53
- const getEndDate = (start, mult, duration) => {
54
- const adder = getAdder(duration);
55
- const endDate = adder(start, Number(mult));
56
- return dateFns.subSeconds(endDate, 1);
57
- };
58
-
59
- const computeName = (start, end, freqDisplay, locale, format) => {
60
- const opts = { locale: getLocale(locale) };
61
- const isSameDay = dateFns.isSameDay(start, end);
62
- const isSameYear = dateFns.isSameYear(start, end);
63
- if (freqDisplay === 'H' || freqDisplay === 'm' || freqDisplay === 'S') {
64
- const dayFormat = getFormat('D');
65
- if (isSameDay)
66
- return `${dateFns.format(start, dayFormat, opts)} ${dateFns.format(start, format, opts)} - ${dateFns.format(end, format, opts)}`;
67
- return `${dateFns.format(start, `${dayFormat} ${format}`, opts)} - ${dateFns.format(end, `${dayFormat} ${format}`, opts)}`;
68
- }
69
- if (freqDisplay !== 'M') {
70
- return `${dateFns.format(start, format, opts)} - ${dateFns.format(end, format, opts)}`;
71
- }
72
-
73
- if (isSameYear && !R.includes('-', format)) {
74
- const yearFormatMatch = R.match(/([Y]+)/, format);
75
- const monthFormatMatch = R.match(/([M]+|Mo)/, format);
76
- const yearFormat = R.length(yearFormatMatch) >= 2 ? R.nth(1, yearFormatMatch) : null;
77
- const monthFormat = R.length(monthFormatMatch) >= 2 ? R.nth(1, monthFormatMatch) : null;
78
- const formattedYear = yearFormat ? dateFns.format(start, yearFormat, opts) : null;
79
- const formattedMonths = monthFormat ? `${dateFns.format(start, monthFormat, opts)} - ${dateFns.format(end, monthFormat, opts)}` : null;
80
- if (monthFormat) {
81
- return R.pipe(
82
- format => yearFormat ? R.replace(yearFormat, formattedYear, format) : format,
83
- R.replace(monthFormat, formattedMonths)
84
- )(format);
85
- }
86
- }
87
- return `${dateFns.format(start, format, opts)} - ${dateFns.format(end, format, opts)}`;
88
- };
89
-
90
- export const getStartDate = (start) => {
91
- if (!R.includes('T', start) && !R.endsWith('Z', start)) {
92
- return dateWithoutTZ(new Date(start));
93
- }
94
- return new Date(start);
95
- };
96
-
97
- const dateWithTZ = date => dateFns.addMinutes(date, -date.getTimezoneOffset());
98
-
99
- export const refineTimePeriod = (timePeriod, { locale, monthlyFormat='YYYY-MMM' }) => {
100
- const { id } = timePeriod;
101
- const split = R.split('/', id);
102
- if (R.length(split) !== 2) {
103
- const start = getStartDate(R.prop('start', timePeriod));
104
- const end = getStartDate(R.prop('end', timePeriod))
105
- return ({ ...timePeriod, start: dateWithTZ(start).toISOString(), end: dateWithTZ(end).toISOString() });
106
- }
107
- const [start, range] = split;
108
- const startDate = getStartDate(start);
109
- const match = R.match(/^P(T?)(\d+)([YMDHS])$/, range);
110
- if (R.isEmpty(match) || !dateFns.isValid(startDate)) {
111
- return timePeriod;
112
- }
113
- const [timeIndicator, mult, _duration] = R.tail(match);
114
- const duration = !R.isEmpty(timeIndicator) && _duration === 'M' ? 'm' : _duration;
115
- const endDate = getEndDate(startDate, mult, duration);
116
- const freqDisplay = computeDisplayFreq(start, duration);
117
- const format = freqDisplay === 'M' ? monthlyFormat : getFormat(freqDisplay);
118
- const name = computeName(startDate, endDate, freqDisplay, locale, format);
119
-
120
- return ({
121
- ...timePeriod,
122
- id,
123
- name,
124
- start: dateWithTZ(startDate).toISOString(),
125
- end: dateWithTZ(endDate).toISOString()
126
- })
127
- };
@@ -1,9 +0,0 @@
1
- import * as R from 'ramda';
2
-
3
- export const sdmx_3_0_DataFormatPatch = (sdmxJson) => {
4
- const dataSet = R.pipe(R.pathOr({}, ['data', 'dataSets']), R.head)(sdmxJson);
5
- const structureIndex = R.prop('structure', dataSet);
6
- const structure = R.pipe(R.pathOr([], ['data', 'structures']), R.nth(structureIndex))(sdmxJson);
7
-
8
- return R.set(R.lensPath(['data', 'structure']), structure)(sdmxJson);
9
- };
@@ -1,32 +0,0 @@
1
- import * as R from 'ramda';
2
-
3
- export const declineObservationsOverAttributes = (attrsIds, observations) => {
4
- const obsKeys = R.keys(observations);
5
- return R.reduce((acc, obsKey) => {
6
- const obs = R.prop(obsKey, observations);
7
- const enhancedObs = R.pipe(
8
- R.over(R.lensProp('orderedDimIndexes'), R.append(0)),
9
- R.over(R.lensProp('attributes'), R.omit(attrsIds)),
10
- R.assocPath(['indexedDimValIds', 'OBS_ATTRIBUTES'], 'OBS_VALUE')
11
- )(obs);
12
- return R.addIndex(R.reduce)((_acc, attrId, attrIndex) => {
13
- const attr = R.pathOr({}, ['attributes', attrId], obs);
14
- if (R.isEmpty(attr) || R.isNil(R.prop('value', attr)) || !R.pathOr(true, ['value', 'display'], attr)) {
15
- return _acc;
16
- }
17
- const declinedKey = `${obsKey}:${attrIndex+1}`;
18
- const declined = {
19
- ...obs,
20
- attributes: {},
21
- value: R.prop('value', attr),
22
- formattedValue: R.prop('value', attr),
23
- orderedDimIndexes: R.append(attrIndex+1, obs.orderedDimIndexes),
24
- indexedDimValIds: {
25
- ...obs.indexedDimValIds,
26
- OBS_ATTRIBUTES: attr.id
27
- }
28
- };
29
- return R.assoc(declinedKey, declined, _acc);
30
- }, R.assoc(`${obsKey}:0`, enhancedObs, acc), attrsIds);
31
- }, {}, obsKeys);
32
- };
@@ -1,93 +0,0 @@
1
- import * as R from 'ramda';
2
- import { getFlagsAndNotes } from './getFlagsAndNotes';
3
- import { hasCellMetadata } from '../hasCellMetadata';
4
-
5
- export const getCellRelevantAttributes = (attributes, attributesSeries, cellAttributeIds) => R.filter(
6
- (attr) => {
7
- if (R.isNil(attr.value)) {
8
- return false;
9
- }
10
- if (R.has(attr.id, cellAttributeIds)) {
11
- return true;
12
- }
13
- const attrInSerie = R.path([attr.serieKey, attr.id], attributesSeries);
14
- return R.isNil(attrInSerie);
15
- },
16
- attributes
17
- );
18
-
19
- export const getCellCombinedSeries = (attributes, combinations) => R.reduce(
20
- (acc, comb) => {
21
- const values = R.reduce(
22
- (acc, concept) => {
23
- if (R.has(concept, comb.fixedDimValues || {})) {
24
- return R.append(R.prop(concept, comb.fixedDimValues), acc);
25
- }
26
- if (R.has(concept, attributes || {})) {
27
- return R.append(R.path([concept, 'value'], attributes), acc);
28
- }
29
- return acc;
30
- },
31
- [],
32
- comb.concepts
33
- );
34
-
35
- if (R.isEmpty(values)) {
36
- return acc;
37
- }
38
- return R.append({ ...R.pick(['id', 'name'], comb), values }, acc);
39
- },
40
- [],
41
- combinations
42
- );
43
-
44
- // combinations = { cells, layout };
45
- export const getCells = (customAttributes, cellsAttributesId, combinations, attributesSeries, metadataCoordinates) => observations => {
46
- const attributesInLayoutCombination = R.pipe(
47
- R.propOr([], 'layout'),
48
- R.pluck('concepts'),
49
- R.unnest
50
- )(combinations);
51
-
52
- const attributesInCellsCombination = R.pipe(
53
- R.propOr([], 'cells'),
54
- R.pluck('concepts'),
55
- R.unnest
56
- )(combinations);
57
-
58
- const _customAttributes = R.over(
59
- R.lensProp('notes'),
60
- notes => R.pipe(R.concat, R.uniq)(notes || [], attributesInLayoutCombination)
61
- )(customAttributes);
62
-
63
- return R.mapObjIndexed(
64
- obs => {
65
- const isAttrCell = R.pathOr('OBS_VAL', ['indexedDimValIds', 'OBS_ATTR'], obs) !== 'OBS_VAL';
66
- const relevantAttributes = isAttrCell ? [] : getCellRelevantAttributes(obs.attributes, attributesSeries, cellsAttributesId);
67
- const flagsAndNotes = isAttrCell ? [] : getFlagsAndNotes(R.omit(attributesInCellsCombination, relevantAttributes), _customAttributes);
68
- const combinedSeries = isAttrCell ? [] : getCellCombinedSeries(relevantAttributes, combinations.cells || []);
69
- const hasAdvancedAttributes = isAttrCell
70
- ? false : R.pipe(
71
- R.omit(R.unnest([_customAttributes.flags || [], _customAttributes.notes || [], attributesInCellsCombination])),
72
- res => !R.isEmpty(res)
73
- )(relevantAttributes);
74
-
75
- const advancedAttributes = R.omit(
76
- R.unnest([_customAttributes.flags || [], _customAttributes.notes || [], attributesInCellsCombination]),
77
- R.filter(attr => !R.isNil(attr.value), obs.attributes),
78
- );
79
-
80
- const hasMetadata = isAttrCell ? false : hasCellMetadata(metadataCoordinates, obs.indexedDimValIds);
81
-
82
- return ({
83
- ...R.pick(['indexedDimValIds', 'key'], obs),
84
- flags: R.concat(flagsAndNotes, combinedSeries),
85
- sideProps: hasAdvancedAttributes || hasMetadata
86
- ? { hasMetadata, coordinates: obs.indexedDimValIds, advancedAttributes } : null,
87
- intValue: R.is(Number, obs.value) ? obs.value : null,
88
- value: obs.formattedValue,
89
- });
90
- },
91
- observations
92
- );
93
- };
@@ -1,38 +0,0 @@
1
- import * as R from 'ramda';
2
-
3
- export const getCellsAttributesIds = (layoutIds, attributes) => {
4
- return R.reduce(
5
- (acc, attr) => {
6
- if (!attr.series) {
7
- return acc;
8
- }
9
- if (R.isEmpty(attr.relationship || [])) {
10
- return R.assoc(attr.id, attr.id, acc);
11
- }
12
- const indexedHeaderIds = R.indexBy(R.identity, layoutIds.header);
13
- const indexedSectionsIds = R.indexBy(R.identity, layoutIds.sections);
14
- const indexedRowsIds = { ...indexedSectionsIds, ...R.indexBy(R.identity, layoutIds.rows) };
15
- const [idsInHeader, rest] = R.partition(
16
- id => R.has(id, indexedHeaderIds),
17
- attr.relationship,
18
- );
19
- if (R.isEmpty(rest)) {
20
- return acc;
21
- } else if (!R.isEmpty(idsInHeader)) {
22
- return R.assoc(attr.id, attr.id, acc);
23
- } else {
24
- const idsNotInSections = R.reject(id => R.has(id, indexedSectionsIds), attr.relationship);
25
- if (R.isEmpty(idsNotInSections)) {
26
- return acc;
27
- }
28
- const idsNotInRows = R.reject(id => R.has(id, indexedRowsIds), idsNotInSections);
29
- if (R.isEmpty(idsNotInRows)) {
30
- return acc;
31
- }
32
- }
33
- return R.assoc(attr.id, attr.id, acc);
34
- },
35
- {},
36
- attributes,
37
- );
38
- };
@@ -1,13 +0,0 @@
1
- import * as R from 'ramda';
2
-
3
- export const getCellsMetadataCoordinates = (metadataCoordinates, oneValueDimensions, layoutIds) => {
4
- const oneValueDimsIds = R.pluck('id', oneValueDimensions);
5
- return R.reject(coordinates => {
6
- const columnIds = R.concat(layoutIds.header, oneValueDimsIds);
7
- if (R.isEmpty(R.omit(columnIds, coordinates))) {
8
- return true;
9
- }
10
- const rowsIds = [...layoutIds.sections, ...layoutIds.rows, ...oneValueDimsIds];
11
- return R.isEmpty(R.omit(rowsIds, coordinates));
12
- }, metadataCoordinates);
13
- };
@@ -1,39 +0,0 @@
1
- import * as R from 'ramda';
2
- import { parseValueHierarchy, isSameValueAsPrevious } from './parseValueHierarchy';
3
-
4
- export const getCombinationDimensionsData = (indexes, combination, previous, sameSerie) => {
5
- let coordinates = {};
6
- let ids = [];
7
- let _sameSerie = sameSerie;
8
- let hasAdvancedAttributes = false;
9
-
10
- const { dimensions=[] } = combination;
11
- const dimValues = R.addIndex(R.reduce)(
12
- (acc, valIndex, dimIndex) => {
13
- const dimension = R.nth(dimIndex, dimensions);
14
- const value = R.nth(Math.abs(valIndex), R.propOr([], 'values', dimension));
15
- hasAdvancedAttributes = !hasAdvancedAttributes ? value.hasAdvancedAttributes : true;
16
- coordinates = R.assoc(dimension.id, value.id, coordinates);
17
- ids = R.append(`${dimension.id}=${value.id}`, ids);
18
- const previousValue = R.propOr({}, dimension.id, previous);
19
- if (isSameValueAsPrevious(value, previousValue) && _sameSerie) {
20
- return R.assoc(dimension.id, previousValue, acc);
21
- }
22
- else {
23
- const _parsedValue = parseValueHierarchy(value, _sameSerie ? previousValue || {} : {}, dimension.indexedValues);
24
- const parsedValue = R.over(
25
- R.lensProp('display'),
26
- (display=true) => display && R.propOr(true, 'display', dimension)
27
- )(_parsedValue);
28
- if (!R.isNil(previous)) {
29
- _sameSerie = false;
30
- }
31
- return R.assoc(dimension.id, parsedValue, acc);
32
- }
33
- },
34
- {},
35
- indexes
36
- );
37
-
38
- return ({ dimValues, coordinates, ids, sameSerie: _sameSerie, hasAdvancedAttributes });
39
- };
@@ -1,33 +0,0 @@
1
- import * as R from 'ramda';
2
-
3
- export const getCuratedCells = (cells, layout) => {
4
- const layoutIds = R.map(
5
- R.pipe(
6
- R.map(entry =>
7
- R.has('dimensions', entry) ? R.pluck('id', entry.dimensions || []) : entry.id,
8
- ),
9
- R.unnest,
10
- ),
11
- )(layout);
12
- return R.pipe(
13
- R.values,
14
- R.reduce((acc, cell) => {
15
- const keys = R.map(
16
- R.pipe(
17
- R.map(dim => {
18
- const val = R.prop(dim, cell.indexedDimValIds);
19
- return `${dim}=${val}`;
20
- }),
21
- R.join(':'),
22
- ),
23
- layoutIds,
24
- );
25
-
26
- return R.over(
27
- R.lensPath(R.props(['header', 'sections', 'rows'], keys)),
28
- cells => (R.isNil(cells) ? [cell] : R.append(cell, cells)),
29
- acc,
30
- );
31
- }, {}),
32
- )(cells);
33
- };
@@ -1,23 +0,0 @@
1
- import * as R from 'ramda';
2
- import { REJECTED_VALUE_IDS } from '../constants';
3
-
4
- export const getFlagsAndNotes = (attributesValues, customAttributes) => {
5
- const flagsIds = R.propOr([], 'flags', customAttributes);
6
- const notesIds = R.propOr([], 'notes', customAttributes);
7
-
8
- return R.addIndex(R.reduce)(
9
- (acc, id, index) => {
10
- if (!R.has(id, attributesValues)) {
11
- return acc;
12
- }
13
- const attr = R.pick(['id', 'name', 'value', 'display'], R.prop(id, attributesValues));
14
- if (R.isNil(attr.value) || !R.pathOr(true, ['value', 'display'], attr) || !R.propOr(true, 'display', attr)
15
- || R.includes(R.path(['value', 'id'], attr), REJECTED_VALUE_IDS)) {
16
- return acc;
17
- }
18
- return R.append(index < flagsIds.length ? R.assoc('code', R.path(['value', 'id'], attr), attr) : attr, acc);
19
- },
20
- [],
21
- R.concat(flagsIds, notesIds)
22
- );
23
- };