@sis-cc/dotstatsuite-components 15.0.21 → 16.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 (165) hide show
  1. package/lib/rules/src/index.js +1 -145
  2. package/lib/rules/src/table/index.js +0 -42
  3. package/lib/rules2/src/constants.js +4 -1
  4. package/lib/rules2/src/enhanceObservations.js +98 -0
  5. package/lib/rules2/src/getAttributesSeries.js +33 -0
  6. package/lib/rules2/src/getCombinationDefinitions.js +48 -0
  7. package/lib/rules2/src/getHeaderCombinations.js +42 -0
  8. package/lib/rules2/src/getHeaderSubtitle.js +41 -0
  9. package/lib/rules2/src/getManyValuesDimensions.js +39 -0
  10. package/lib/rules2/src/getOneValueDimensions.js +46 -0
  11. package/lib/rules2/src/hasCellMetadata.js +1 -1
  12. package/lib/rules2/src/index.js +186 -18
  13. package/lib/rules2/src/parseAttributes.js +50 -0
  14. package/lib/rules2/src/parseCombinations.js +54 -0
  15. package/lib/rules2/src/parseMetadataSeries.js +4 -2
  16. package/lib/rules2/src/prepareData.js +74 -0
  17. package/lib/{rules/src/table/preparators/getAttributeValue.js → rules2/src/refineAttributes.js} +13 -11
  18. package/lib/rules2/src/table/getCells.js +74 -0
  19. package/lib/rules2/src/table/getCellsAttributesIds.js +63 -0
  20. package/lib/rules2/src/table/getCombinationDimensionsData.js +47 -0
  21. package/lib/rules2/src/table/getCuratedCells.js +28 -0
  22. package/lib/rules2/src/table/getFlagsAndNotes.js +28 -0
  23. package/lib/rules2/src/table/getIndexedCombinationsByDisplay.js +31 -0
  24. package/lib/rules2/src/table/getLayout.js +93 -0
  25. package/lib/rules2/src/table/getLayoutData.js +202 -0
  26. package/lib/{rules/src/table/factories → rules2/src/table}/getSortedLayoutIndexes.js +55 -40
  27. package/lib/rules2/src/table/getTableProps.js +64 -0
  28. package/lib/rules2/src/table/parseValueHierarchy.js +55 -0
  29. package/lib/{rules/src/table/factories → rules2/src/table}/refineLayoutSize.js +17 -8
  30. package/lib/rules2/src/{hasLayoutEntryMetadata.js → utils.js} +9 -6
  31. package/package.json +1 -1
  32. package/src/rules/src/index.js +1 -19
  33. package/src/rules/src/table/index.js +0 -4
  34. package/src/rules2/src/constants.js +3 -0
  35. package/src/rules2/src/enhanceObservations.js +88 -0
  36. package/src/rules2/src/getAttributesSeries.js +29 -0
  37. package/src/rules2/src/getCombinationDefinitions.js +29 -0
  38. package/src/rules2/src/getHeaderCombinations.js +39 -0
  39. package/src/rules2/src/getHeaderSubtitle.js +34 -0
  40. package/src/rules2/src/getManyValuesDimensions.js +34 -0
  41. package/src/rules2/src/getOneValueDimensions.js +33 -0
  42. package/src/rules2/src/hasCellMetadata.js +1 -1
  43. package/src/rules2/src/index.js +21 -6
  44. package/src/rules2/src/parseAttributes.js +36 -0
  45. package/src/rules2/src/parseCombinations.js +36 -0
  46. package/src/rules2/src/parseMetadataSeries.js +3 -2
  47. package/src/rules2/src/prepareData.js +50 -0
  48. package/src/rules2/src/refineAttributes.js +16 -0
  49. package/src/rules2/src/table/getCells.js +72 -0
  50. package/src/rules2/src/table/getCellsAttributesIds.js +38 -0
  51. package/src/rules2/src/table/getCombinationDimensionsData.js +38 -0
  52. package/src/rules2/src/table/getCuratedCells.js +33 -0
  53. package/src/rules2/src/table/getFlagsAndNotes.js +21 -0
  54. package/src/rules2/src/table/getIndexedCombinationsByDisplay.js +16 -0
  55. package/src/rules2/src/table/getLayout.js +80 -0
  56. package/src/rules2/src/table/getLayoutData.js +183 -0
  57. package/src/rules2/src/table/getSortedLayoutIndexes.js +119 -0
  58. package/src/rules2/src/table/getTableProps.js +36 -0
  59. package/src/rules2/src/table/parseValueHierarchy.js +27 -0
  60. package/src/{rules/src/table/factories → rules2/src/table}/refineLayoutSize.js +24 -8
  61. package/src/rules2/src/utils.js +12 -0
  62. package/test/enhanceObservations2.test.js +219 -0
  63. package/test/getAttributesSeries.test.js +58 -0
  64. package/test/getCells.test.js +6 -40
  65. package/test/getCombinationDimensionsData.test.js +48 -0
  66. package/test/getSortedLayoutIndexes.test.js +1025 -3
  67. package/test/mocks/OECD_SNA_TABLE1_1.0_-_AUS_V_metadata.json +2 -2
  68. package/test/parseAttributes.test.js +17 -62
  69. package/test/parseMetadataSeries.test.js +1 -1
  70. package/test/parseValueHierarchy.test.js +88 -0
  71. package/test/refineLayoutSize.test.js +2621 -1
  72. package/lib/rules/src/table/factories/getCells.js +0 -97
  73. package/lib/rules/src/table/factories/getConfirmedSeriesAttributesIds.js +0 -26
  74. package/lib/rules/src/table/factories/getCuratedCells.js +0 -45
  75. package/lib/rules/src/table/factories/getLayoutData.js +0 -168
  76. package/lib/rules/src/table/factories/getLayoutWithFlags.js +0 -133
  77. package/lib/rules/src/table/factories/getTableCells.js +0 -24
  78. package/lib/rules/src/table/factories/getTableData.js +0 -98
  79. package/lib/rules/src/table/preparators/getDimensionsAttributesRegisters.js +0 -43
  80. package/lib/rules/src/table/preparators/getManyValuesDimensions.js +0 -33
  81. package/lib/rules/src/table/preparators/getOneValueDimensions.js +0 -24
  82. package/lib/rules/src/table/preparators/getUniqValuesAttributes.js +0 -36
  83. package/lib/rules/src/table/preparators/parseAttributes.js +0 -84
  84. package/lib/rules/src/table/preparators/parseAttributesValuesFromObservations.js +0 -22
  85. package/lib/rules/src/table/preparators/parseDimensionsIds.js +0 -22
  86. package/lib/rules/src/table/preparators/prepareData.js +0 -191
  87. package/lib/rules/src/table/preparators/refineObservationsAttributesValues.js +0 -31
  88. package/lib/rules/src/table/preparators/refineSeriesAttributesValues.js +0 -23
  89. package/lib/rules/src/table/units/appendUnitsInLayoutData.js +0 -82
  90. package/lib/rules/src/table/units/appendUnitsInLayoutDataEntry.js +0 -45
  91. package/lib/rules/src/table/units/cleanUnitsInLayoutData.js +0 -66
  92. package/lib/rules/src/table/units/getAttachmentSeriesIndexes.js +0 -25
  93. package/lib/rules/src/table/units/getHeaderUnits.js +0 -35
  94. package/lib/rules/src/table/units/getUnitsArtefacts.js +0 -85
  95. package/lib/rules/src/table/units/getUnitsCodes.js +0 -23
  96. package/lib/rules/src/table/units/getUnitsDefinition.js +0 -33
  97. package/lib/rules/src/table/units/getUnitsDisplay.js +0 -33
  98. package/lib/rules/src/table/units/getUnitsSerieIndexes.js +0 -23
  99. package/lib/rules/src/table/units/getUnitsSeries.js +0 -49
  100. package/lib/rules/src/table/units/getUnitsinLayout.js +0 -74
  101. package/lib/rules/src/table/units/refineDimSeriesUnits.js +0 -44
  102. package/lib/rules2/src/getAdvancedAttributes.js +0 -124
  103. package/lib/rules2/src/invertTime.js +0 -33
  104. package/src/rules/src/table/factories/getCells.js +0 -102
  105. package/src/rules/src/table/factories/getConfirmedSeriesAttributesIds.js +0 -27
  106. package/src/rules/src/table/factories/getCuratedCells.js +0 -40
  107. package/src/rules/src/table/factories/getLayoutData.js +0 -171
  108. package/src/rules/src/table/factories/getLayoutWithFlags.js +0 -137
  109. package/src/rules/src/table/factories/getSortedLayoutIndexes.js +0 -108
  110. package/src/rules/src/table/factories/getTableCells.js +0 -16
  111. package/src/rules/src/table/factories/getTableData.js +0 -86
  112. package/src/rules/src/table/preparators/getAttributeValue.js +0 -17
  113. package/src/rules/src/table/preparators/getDimensionsAttributesRegisters.js +0 -51
  114. package/src/rules/src/table/preparators/getManyValuesDimensions.js +0 -19
  115. package/src/rules/src/table/preparators/getOneValueDimensions.js +0 -17
  116. package/src/rules/src/table/preparators/getUniqValuesAttributes.js +0 -24
  117. package/src/rules/src/table/preparators/parseAttributes.js +0 -113
  118. package/src/rules/src/table/preparators/parseAttributesValuesFromObservations.js +0 -16
  119. package/src/rules/src/table/preparators/parseDimensionsIds.js +0 -17
  120. package/src/rules/src/table/preparators/prepareData.js +0 -197
  121. package/src/rules/src/table/preparators/refineObservationsAttributesValues.js +0 -22
  122. package/src/rules/src/table/preparators/refineSeriesAttributesValues.js +0 -11
  123. package/src/rules/src/table/units/appendUnitsInLayoutData.js +0 -56
  124. package/src/rules/src/table/units/appendUnitsInLayoutDataEntry.js +0 -38
  125. package/src/rules/src/table/units/cleanUnitsInLayoutData.js +0 -65
  126. package/src/rules/src/table/units/getAttachmentSeriesIndexes.js +0 -27
  127. package/src/rules/src/table/units/getHeaderUnits.js +0 -32
  128. package/src/rules/src/table/units/getUnitsArtefacts.js +0 -90
  129. package/src/rules/src/table/units/getUnitsCodes.js +0 -22
  130. package/src/rules/src/table/units/getUnitsDefinition.js +0 -34
  131. package/src/rules/src/table/units/getUnitsDisplay.js +0 -19
  132. package/src/rules/src/table/units/getUnitsSerieIndexes.js +0 -12
  133. package/src/rules/src/table/units/getUnitsSeries.js +0 -41
  134. package/src/rules/src/table/units/getUnitsinLayout.js +0 -71
  135. package/src/rules/src/table/units/refineDimSeriesUnits.js +0 -26
  136. package/src/rules2/src/getAdvancedAttributes.js +0 -111
  137. package/src/rules2/src/hasLayoutEntryMetadata.js +0 -9
  138. package/src/rules2/src/invertTime.js +0 -22
  139. package/test/advanced-attributes-parsing-perf.test.js +0 -16
  140. package/test/appendUnitsInLayoutDataEntry.test.js +0 -65
  141. package/test/cleanUnitsInLayoutData.test.js +0 -85
  142. package/test/enhanceObservations.test.js +0 -340
  143. package/test/getAttachmentSeriesIndexes.test.js +0 -35
  144. package/test/getConfirmedSeriesAttributesIds.test.js +0 -27
  145. package/test/getDataflowAdvancedAttributes.test.js +0 -32
  146. package/test/getHeaderUnits.test.js +0 -51
  147. package/test/getLayoutData.test.js +0 -206
  148. package/test/getLayoutDataWithFlags.test.js +0 -142
  149. package/test/getOneValueDimensions.test.js +0 -26
  150. package/test/getSeriesAdvancedAttributes.test.js +0 -32
  151. package/test/getSubtitleFlags.test.js +0 -42
  152. package/test/getTableData.test.js +0 -1317
  153. package/test/getUnitsArtefacts.test.js +0 -117
  154. package/test/getUnitsDefinition.test.js +0 -37
  155. package/test/getUnitsInLayout.test.js +0 -77
  156. package/test/getUnitsSeries.test.js +0 -154
  157. package/test/invertTime.test.js +0 -77
  158. package/test/parseAttributesValuesFromObservations.test.js +0 -45
  159. package/test/parseDimensionsIds.test.js +0 -20
  160. package/test/prepareData.test.js +0 -29
  161. package/test/refineObservationsAttributesValues.test.js +0 -33
  162. package/test/table-invert-time-perf.test.js +0 -11
  163. package/test/table-layout-perf.test.js +0 -74
  164. package/test/table-prep-duplicate-perf.test.js +0 -15
  165. package/test/table-prep-perf.test.js +0 -61
@@ -115,56 +115,224 @@ Object.defineProperty(exports, 'getMetadataCoordinates', {
115
115
  }
116
116
  });
117
117
 
118
- var _getAdvancedAttributes = require('./getAdvancedAttributes');
118
+ var _duplicateObservations = require('./duplicateObservations');
119
119
 
120
- Object.defineProperty(exports, 'getDataflowAdvancedAttributes', {
120
+ Object.defineProperty(exports, 'duplicateObs', {
121
121
  enumerable: true,
122
122
  get: function get() {
123
- return _getAdvancedAttributes.getDataflowAdvancedAttributes;
123
+ return _duplicateObservations.duplicateObs;
124
124
  }
125
125
  });
126
- Object.defineProperty(exports, 'getObservationsAdvancedAttributes', {
126
+ Object.defineProperty(exports, 'hierarchiseDimensionWithAdvancedHierarchy', {
127
127
  enumerable: true,
128
128
  get: function get() {
129
- return _getAdvancedAttributes.getObservationsAdvancedAttributes;
129
+ return _hierarchiseDimensionWithAdvancedHierarchy.hierarchiseDimensionWithAdvancedHierarchy;
130
130
  }
131
131
  });
132
- Object.defineProperty(exports, 'getSeriesAdvancedAttributes', {
132
+
133
+ var _hierarchiseDimensionWithNativeHierarchy = require('./hierarchiseDimensionWithNativeHierarchy');
134
+
135
+ Object.defineProperty(exports, 'hierarchiseDimensionWithNativeHierarchy', {
133
136
  enumerable: true,
134
137
  get: function get() {
135
- return _getAdvancedAttributes.getSeriesAdvancedAttributes;
138
+ return _hierarchiseDimensionWithNativeHierarchy.hierarchiseDimensionWithNativeHierarchy;
136
139
  }
137
140
  });
138
141
 
139
- var _duplicateObservations = require('./duplicateObservations');
142
+ var _getDimensionValuesIndexes = require('./getDimensionValuesIndexes');
140
143
 
141
- Object.defineProperty(exports, 'duplicateObs', {
144
+ Object.defineProperty(exports, 'getDimensionValuesIndexes', {
142
145
  enumerable: true,
143
146
  get: function get() {
144
- return _duplicateObservations.duplicateObs;
147
+ return _getDimensionValuesIndexes.getDimensionValuesIndexes;
145
148
  }
146
149
  });
147
- Object.defineProperty(exports, 'hierarchiseDimensionWithAdvancedHierarchy', {
150
+
151
+ var _getCombinationDefinitions = require('./getCombinationDefinitions');
152
+
153
+ Object.defineProperty(exports, 'getCombinationDefinitions', {
148
154
  enumerable: true,
149
155
  get: function get() {
150
- return _hierarchiseDimensionWithAdvancedHierarchy.hierarchiseDimensionWithAdvancedHierarchy;
156
+ return _getCombinationDefinitions.getCombinationDefinitions;
151
157
  }
152
158
  });
153
159
 
154
- var _hierarchiseDimensionWithNativeHierarchy = require('./hierarchiseDimensionWithNativeHierarchy');
160
+ var _parseAttributes = require('./parseAttributes');
155
161
 
156
- Object.defineProperty(exports, 'hierarchiseDimensionWithNativeHierarchy', {
162
+ Object.defineProperty(exports, 'parseAttributes', {
157
163
  enumerable: true,
158
164
  get: function get() {
159
- return _hierarchiseDimensionWithNativeHierarchy.hierarchiseDimensionWithNativeHierarchy;
165
+ return _parseAttributes.parseAttributes;
160
166
  }
161
167
  });
162
168
 
163
- var _getDimensionValuesIndexes = require('./getDimensionValuesIndexes');
169
+ var _parseCombinations = require('./parseCombinations');
164
170
 
165
- Object.defineProperty(exports, 'getDimensionValuesIndexes', {
171
+ Object.defineProperty(exports, 'parseCombinations', {
166
172
  enumerable: true,
167
173
  get: function get() {
168
- return _getDimensionValuesIndexes.getDimensionValuesIndexes;
174
+ return _parseCombinations.parseCombinations;
175
+ }
176
+ });
177
+
178
+ var _refineAttributes = require('./refineAttributes');
179
+
180
+ Object.defineProperty(exports, 'refineAttributes', {
181
+ enumerable: true,
182
+ get: function get() {
183
+ return _refineAttributes.refineAttributes;
184
+ }
185
+ });
186
+
187
+ var _enhanceObservations = require('./enhanceObservations');
188
+
189
+ Object.defineProperty(exports, 'enhanceObservations', {
190
+ enumerable: true,
191
+ get: function get() {
192
+ return _enhanceObservations.enhanceObservations;
193
+ }
194
+ });
195
+
196
+ var _getAttributesSeries = require('./getAttributesSeries');
197
+
198
+ Object.defineProperty(exports, 'getAttributesSeries', {
199
+ enumerable: true,
200
+ get: function get() {
201
+ return _getAttributesSeries.getAttributesSeries;
202
+ }
203
+ });
204
+
205
+ var _getManyValuesDimensions = require('./getManyValuesDimensions');
206
+
207
+ Object.defineProperty(exports, 'getManyValuesDimensions', {
208
+ enumerable: true,
209
+ get: function get() {
210
+ return _getManyValuesDimensions.getManyValuesDimensions;
211
+ }
212
+ });
213
+
214
+ var _getOneValueDimensions = require('./getOneValueDimensions');
215
+
216
+ Object.defineProperty(exports, 'getOneValueDimensions', {
217
+ enumerable: true,
218
+ get: function get() {
219
+ return _getOneValueDimensions.getOneValueDimensions;
220
+ }
221
+ });
222
+
223
+ var _getHeaderSubtitle = require('./getHeaderSubtitle');
224
+
225
+ Object.defineProperty(exports, 'getHeaderSubtitle', {
226
+ enumerable: true,
227
+ get: function get() {
228
+ return _getHeaderSubtitle.getHeaderSubtitle;
229
+ }
230
+ });
231
+
232
+ var _getHeaderCombinations = require('./getHeaderCombinations');
233
+
234
+ Object.defineProperty(exports, 'getHeaderCombinations', {
235
+ enumerable: true,
236
+ get: function get() {
237
+ return _getHeaderCombinations.getHeaderCombinations;
238
+ }
239
+ });
240
+
241
+ var _getLayout = require('./table/getLayout');
242
+
243
+ Object.defineProperty(exports, 'getLayout', {
244
+ enumerable: true,
245
+ get: function get() {
246
+ return _getLayout.getLayout;
247
+ }
248
+ });
249
+
250
+ var _getSortedLayoutIndexes = require('./table/getSortedLayoutIndexes');
251
+
252
+ Object.defineProperty(exports, 'getSortedLayoutIndexes', {
253
+ enumerable: true,
254
+ get: function get() {
255
+ return _getSortedLayoutIndexes.getSortedLayoutIndexes;
256
+ }
257
+ });
258
+
259
+ var _refineLayoutSize = require('./table/refineLayoutSize');
260
+
261
+ Object.defineProperty(exports, 'refineLayoutSize', {
262
+ enumerable: true,
263
+ get: function get() {
264
+ return _refineLayoutSize.refineLayoutSize;
265
+ }
266
+ });
267
+
268
+ var _getFlagsAndNotes = require('./table/getFlagsAndNotes');
269
+
270
+ Object.defineProperty(exports, 'getFlagsAndNotes', {
271
+ enumerable: true,
272
+ get: function get() {
273
+ return _getFlagsAndNotes.getFlagsAndNotes;
274
+ }
275
+ });
276
+
277
+ var _getLayoutData = require('./table/getLayoutData');
278
+
279
+ Object.defineProperty(exports, 'getLayoutData', {
280
+ enumerable: true,
281
+ get: function get() {
282
+ return _getLayoutData.getLayoutData;
283
+ }
284
+ });
285
+
286
+ var _getCellsAttributesIds = require('./table/getCellsAttributesIds');
287
+
288
+ Object.defineProperty(exports, 'getCellsAttributesIds', {
289
+ enumerable: true,
290
+ get: function get() {
291
+ return _getCellsAttributesIds.getCellsAttributesIds;
292
+ }
293
+ });
294
+
295
+ var _getIndexedCombinationsByDisplay = require('./table/getIndexedCombinationsByDisplay');
296
+
297
+ Object.defineProperty(exports, 'getIndexedCombinationsByDisplay', {
298
+ enumerable: true,
299
+ get: function get() {
300
+ return _getIndexedCombinationsByDisplay.getIndexedCombinationsByDisplay;
301
+ }
302
+ });
303
+
304
+ var _getCells = require('./table/getCells');
305
+
306
+ Object.defineProperty(exports, 'getCells', {
307
+ enumerable: true,
308
+ get: function get() {
309
+ return _getCells.getCells;
310
+ }
311
+ });
312
+
313
+ var _getCuratedCells = require('./table/getCuratedCells');
314
+
315
+ Object.defineProperty(exports, 'getCuratedCells', {
316
+ enumerable: true,
317
+ get: function get() {
318
+ return _getCuratedCells.getCuratedCells;
319
+ }
320
+ });
321
+
322
+ var _prepareData = require('./prepareData');
323
+
324
+ Object.defineProperty(exports, 'prepareData', {
325
+ enumerable: true,
326
+ get: function get() {
327
+ return _prepareData.prepareData;
328
+ }
329
+ });
330
+
331
+ var _getTableProps = require('./table/getTableProps');
332
+
333
+ Object.defineProperty(exports, 'getTableProps', {
334
+ enumerable: true,
335
+ get: function get() {
336
+ return _getTableProps.getTableProps;
169
337
  }
170
338
  });
@@ -0,0 +1,50 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.parseAttributes = undefined;
7
+
8
+ var _extends2 = require('babel-runtime/helpers/extends');
9
+
10
+ var _extends3 = _interopRequireDefault(_extends2);
11
+
12
+ var _ramda = require('ramda');
13
+
14
+ var R = _interopRequireWildcard(_ramda);
15
+
16
+ var _constants = require('./constants');
17
+
18
+ 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; } }
19
+
20
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
+
22
+ var parseAttributes = exports.parseAttributes = function parseAttributes(attributes, dimensions, customAttributes) {
23
+ var indexedDimensions = R.indexBy(R.prop('id'), dimensions);
24
+ return R.addIndex(R.map)(function (attr, index) {
25
+ var res = R.assoc('index', index, attr);
26
+ if (R.isEmpty(attr.values || []) || !R.propOr(true, 'display', attr) || attr.id === _constants.REPORTING_YEAR_START_DAY || attr.id === _constants.REPYEARSTART) {
27
+ return R.assoc('display', false, res);
28
+ }
29
+ if (R.propEq('id', customAttributes.prefscale, attr)) {
30
+ return R.assoc('prefscale', true, res);
31
+ }
32
+ if (R.propEq('id', customAttributes.decimals, attr)) {
33
+ return R.assoc('decimals', true, res);
34
+ }
35
+ if (R.hasPath(['relationship', 'none'], attr) || R.hasPath(['relationship', 'dataflow'], attr)) {
36
+ return (0, _extends3.default)({}, res, { header: true, relationship: [] });
37
+ }
38
+ if (R.hasPath(['relationship', 'primaryMeasure'], attr) || R.hasPath(['relationship', 'observation'], attr)) {
39
+ return (0, _extends3.default)({}, res, { series: true, relationship: [] });
40
+ }
41
+ var seriesDimensions = R.pipe(R.pathOr([], ['relationship', 'dimensions']), R.filter(function (id) {
42
+ var values = R.path([id, 'values'], indexedDimensions);
43
+ return R.length(values) > 1;
44
+ }))(attr);
45
+ if (R.length(seriesDimensions) > 0) {
46
+ return (0, _extends3.default)({}, res, { series: true, relationship: seriesDimensions });
47
+ }
48
+ return (0, _extends3.default)({}, res, { header: true, relationship: R.prop('dimensions', attr.relationship || []) });
49
+ }, attributes);
50
+ };
@@ -0,0 +1,54 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.parseCombinations = undefined;
7
+
8
+ var _defineProperty2 = require('babel-runtime/helpers/defineProperty');
9
+
10
+ var _defineProperty3 = _interopRequireDefault(_defineProperty2);
11
+
12
+ var _extends3 = require('babel-runtime/helpers/extends');
13
+
14
+ var _extends4 = _interopRequireDefault(_extends3);
15
+
16
+ var _ramda = require('ramda');
17
+
18
+ var R = _interopRequireWildcard(_ramda);
19
+
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; } }
21
+
22
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
+
24
+ var parseCombinations = exports.parseCombinations = function parseCombinations(combinations, parsedAttributes, dimensions) {
25
+ var indexedDimensions = R.indexBy(R.prop('id'), dimensions);
26
+ var indexedAttributes = R.indexBy(R.prop('id'), parsedAttributes);
27
+
28
+ return R.map(function (comb) {
29
+ var relationship = [];
30
+ var ids = {};
31
+ var seriesConcepts = R.filter(function (concept) {
32
+ if (R.has(concept, ids)) {
33
+ return false;
34
+ }
35
+ if (R.has(concept, indexedDimensions)) {
36
+ var values = R.path([concept, 'values'], indexedDimensions);
37
+ relationship = R.length(values) > 1 ? R.append(concept, relationship) : relationship;
38
+ ids = (0, _extends4.default)({}, ids, (0, _defineProperty3.default)({}, concept, concept));
39
+ return R.length(values) > 1;
40
+ }
41
+ var attribute = R.prop(concept, indexedAttributes);
42
+ relationship = attribute.series ? R.pipe(R.reject(function (id) {
43
+ return R.has(id, ids);
44
+ }), R.concat(relationship))(attribute.relationship) : relationship;
45
+ ids = attribute.series ? (0, _extends4.default)({}, ids, R.indexBy(R.identity, attribute.relationship)) : ids;
46
+ return true;
47
+ }, comb.concepts);
48
+
49
+ if (R.isEmpty(seriesConcepts) || R.isEmpty(relationship)) {
50
+ return (0, _extends4.default)({}, comb, { header: true });
51
+ }
52
+ return (0, _extends4.default)({}, comb, { series: true, relationship: relationship });
53
+ }, combinations);
54
+ };
@@ -15,6 +15,8 @@ var R = _interopRequireWildcard(_ramda);
15
15
 
16
16
  var _dotstatsuiteSdmxjs = require('@sis-cc/dotstatsuite-sdmxjs');
17
17
 
18
+ var _constants = require('./constants');
19
+
18
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; } }
19
21
 
20
22
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -56,8 +58,8 @@ var parseMetadataSeries = exports.parseMetadataSeries = function parseMetadataSe
56
58
  var metaIndexes = R.take(metaAttrLength, indexes);
57
59
 
58
60
  var evolvedKey = R.pipe(R.split(':'), R.addIndex(R.map)(function (vInd, dInd) {
59
- if (R.isEmpty(vInd)) {
60
- return vInd;
61
+ if (R.isEmpty(vInd) || R.equals(_constants.EMPTY_ATTACHMENT_LEVEL_CHAR, vInd)) {
62
+ return '';
61
63
  }
62
64
  var dim = R.nth(dInd, dimensions);
63
65
  var val = R.nth(Number(vInd), dim.values || []);
@@ -0,0 +1,74 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.prepareData = undefined;
7
+
8
+ var _ramda = require('ramda');
9
+
10
+ var R = _interopRequireWildcard(_ramda);
11
+
12
+ var _src = require('../../rules/src');
13
+
14
+ var _enhanceObservations = require('./enhanceObservations');
15
+
16
+ var _parseAttributes = require('./parseAttributes');
17
+
18
+ var _getCombinationDefinitions = require('./getCombinationDefinitions');
19
+
20
+ var _parseCombinations = require('./parseCombinations');
21
+
22
+ var _refineAttributes = require('./refineAttributes');
23
+
24
+ var _duplicateObservations = require('./duplicateObservations');
25
+
26
+ var _getMetadataCoordinates = require('./getMetadataCoordinates');
27
+
28
+ var _getAttributesSeries = require('./getAttributesSeries');
29
+
30
+ var _getManyValuesDimensions = require('./getManyValuesDimensions');
31
+
32
+ var _getOneValueDimensions = require('./getOneValueDimensions');
33
+
34
+ var _hierarchiseDimensionWithNativeHierarchy = require('./hierarchiseDimensionWithNativeHierarchy');
35
+
36
+ var _hierarchiseDimensionWithAdvancedHierarchy = require('./hierarchiseDimensionWithAdvancedHierarchy');
37
+
38
+ 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
+
40
+ var prepareData = exports.prepareData = function prepareData(sdmxJson, customAttributes, locale, hierarchies) {
41
+ var dimensions = R.pathOr([], ['data', 'structure', 'dimensions', 'observation'], sdmxJson);
42
+ var attributes = R.pathOr([], ['data', 'structure', 'attributes', 'observation'], sdmxJson);
43
+ var annotations = R.pathOr([], ['data', 'structure', 'annotations'], sdmxJson);
44
+ var observations = (0, _src.getObservations)(sdmxJson);
45
+ var combinations = (0, _getCombinationDefinitions.getCombinationDefinitions)(annotations, locale);
46
+ var metadataCoordinates = (0, _getMetadataCoordinates.getMetadataCoordinates)(sdmxJson);
47
+
48
+ var parsedAttributes = (0, _parseAttributes.parseAttributes)(attributes, dimensions, customAttributes);
49
+ var parsedCombinations = (0, _parseCombinations.parseCombinations)(combinations, parsedAttributes, dimensions);
50
+ var seriesCombinations = R.filter(R.prop('series'), parsedCombinations);
51
+ var refinedAttributes = (0, _refineAttributes.refineAttributes)(parsedAttributes, seriesCombinations);
52
+
53
+ var enhancedObservations = (0, _enhanceObservations.enhanceObservations)(dimensions, observations, refinedAttributes, { customAttributes: customAttributes });
54
+ var attributesSeries = (0, _getAttributesSeries.getAttributesSeries)(enhancedObservations);
55
+ var manyValuesDimensions = (0, _getManyValuesDimensions.getManyValuesDimensions)(dimensions, attributesSeries, customAttributes, seriesCombinations);
56
+ var oneValueDimensions = (0, _getOneValueDimensions.getOneValueDimensions)(dimensions, parsedAttributes);
57
+ var hierarchisedDimensions = R.map(function (dim) {
58
+ if (R.isEmpty(R.propOr({}, dim.id, hierarchies))) {
59
+ return (0, _hierarchiseDimensionWithNativeHierarchy.hierarchiseDimensionWithNativeHierarchy)(dim);
60
+ }
61
+ return (0, _hierarchiseDimensionWithAdvancedHierarchy.hierarchiseDimensionWithAdvancedHierarchy)(dim, R.prop(dim.id, hierarchies));
62
+ }, manyValuesDimensions);
63
+ var duplicatedObservations = (0, _duplicateObservations.duplicateObs)(R.values(hierarchisedDimensions), enhancedObservations);
64
+
65
+ return {
66
+ observations: duplicatedObservations,
67
+ dimensions: hierarchisedDimensions,
68
+ combinations: parsedCombinations,
69
+ oneValueDimensions: oneValueDimensions,
70
+ attributesSeries: attributesSeries,
71
+ metadataCoordinates: metadataCoordinates,
72
+ attributes: refinedAttributes
73
+ };
74
+ };
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.getAttributeValue = undefined;
6
+ exports.refineAttributes = undefined;
7
7
 
8
8
  var _extends2 = require('babel-runtime/helpers/extends');
9
9
 
@@ -17,14 +17,16 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
17
17
 
18
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
19
 
20
- var getAttributeValue = exports.getAttributeValue = function getAttributeValue(attribute, valueIndex) {
21
- var value = R.pipe(R.propOr([], 'values'), R.nth(valueIndex))(attribute);
22
-
23
- if (R.isNil(value)) {
24
- return null;
25
- }
26
-
27
- return (0, _extends3.default)({}, R.pick(['id', 'name'], attribute), {
28
- value: R.pick(['id', 'name'], value)
29
- });
20
+ var refineAttributes = exports.refineAttributes = function refineAttributes(parsedAttributes, seriesCombinations) {
21
+ var indexedRelationships = R.reduce(function (acc, comb) {
22
+ return R.reduce(function (_acc, concept) {
23
+ return R.assoc(concept, comb.relationship, _acc);
24
+ }, acc, comb.concepts);
25
+ }, {}, seriesCombinations);
26
+ return R.map(function (attr) {
27
+ if (R.has(attr.id, indexedRelationships)) {
28
+ return (0, _extends3.default)({}, attr, { series: true, relationship: R.prop(attr.id, indexedRelationships) });
29
+ }
30
+ return attr;
31
+ }, parsedAttributes);
30
32
  };
@@ -0,0 +1,74 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getCells = exports.getCellCombinedAttributes = exports.getCellRelevantAttributes = undefined;
7
+
8
+ var _extends2 = require('babel-runtime/helpers/extends');
9
+
10
+ var _extends3 = _interopRequireDefault(_extends2);
11
+
12
+ var _ramda = require('ramda');
13
+
14
+ var R = _interopRequireWildcard(_ramda);
15
+
16
+ var _getFlagsAndNotes = require('./getFlagsAndNotes');
17
+
18
+ var _hasCellMetadata = require('../hasCellMetadata');
19
+
20
+ var _utils = require('../utils');
21
+
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; } }
23
+
24
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25
+
26
+ var getCellRelevantAttributes = exports.getCellRelevantAttributes = function getCellRelevantAttributes(attributes, attributesSeries, cellAttributeIds) {
27
+ return R.filter(function (attr) {
28
+ if (R.has(attr.id, cellAttributeIds)) {
29
+ return true;
30
+ }
31
+ var attrInSerie = R.path([attr.serieKey, attr.id], attributesSeries);
32
+ return R.isNil(attrInSerie);
33
+ }, attributes);
34
+ };
35
+
36
+ var getCellCombinedAttributes = exports.getCellCombinedAttributes = function getCellCombinedAttributes(attributes, combinations) {
37
+ return R.reduce(function (acc, comb) {
38
+ var values = (0, _utils.trimedProps)(comb.concepts, attributes);
39
+ if (R.isEmpty(values)) {
40
+ return acc;
41
+ }
42
+ return R.append((0, _extends3.default)({}, R.pick(['id', 'name'], comb), { values: R.pluck('value', values) }), acc);
43
+ }, [], combinations);
44
+ };
45
+
46
+ // combinations = { cells, layout };
47
+ var getCells = exports.getCells = function getCells(customAttributes, cellsAttributesId, combinations, attributesSeries, metadataCoordinates) {
48
+ return function (observations) {
49
+ var attributesInLayoutCombination = R.pipe(R.propOr([], 'layout'), R.pluck('concepts'), R.unnest)(combinations);
50
+
51
+ var attributesInCellsCombination = R.pipe(R.propOr([], 'cells'), R.pluck('concepts'), R.unnest)(combinations);
52
+
53
+ var _customAttributes = R.over(R.lensProp('notes'), function (notes) {
54
+ return R.concat(notes || [], attributesInLayoutCombination);
55
+ })(customAttributes);
56
+
57
+ return R.mapObjIndexed(function (obs) {
58
+ var relevantAttributes = getCellRelevantAttributes(obs.attributes, attributesSeries, cellsAttributesId);
59
+ var flagsAndNotes = (0, _getFlagsAndNotes.getFlagsAndNotes)(relevantAttributes, _customAttributes);
60
+ var combinedAttributes = getCellCombinedAttributes(relevantAttributes, combinations.cells || []);
61
+
62
+ var hasAdvancedAttributes = R.pipe(R.omit(R.unnest([_customAttributes.flags || [], _customAttributes.notes || [], attributesInCellsCombination])), R.isEmpty, R.not)(relevantAttributes);
63
+
64
+ var hasMetadata = (0, _hasCellMetadata.hasCellMetadata)(metadataCoordinates, obs.indexedDimValIds);
65
+
66
+ return (0, _extends3.default)({}, R.pick(['indexedDimValIds', 'key'], obs), {
67
+ flags: R.concat(flagsAndNotes, combinedAttributes),
68
+ sideProps: hasAdvancedAttributes || hasMetadata ? { hasAdvancedAttributes: hasAdvancedAttributes, hasMetadata: hasMetadata, coordinates: obs.indexedDimValIds } : null,
69
+ intValue: R.is(Number, obs.value) ? obs.value : null,
70
+ value: obs.formattedValue
71
+ });
72
+ }, observations);
73
+ };
74
+ };
@@ -0,0 +1,63 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getCellsAttributesIds = undefined;
7
+
8
+ var _slicedToArray2 = require('babel-runtime/helpers/slicedToArray');
9
+
10
+ var _slicedToArray3 = _interopRequireDefault(_slicedToArray2);
11
+
12
+ var _extends2 = require('babel-runtime/helpers/extends');
13
+
14
+ var _extends3 = _interopRequireDefault(_extends2);
15
+
16
+ var _ramda = require('ramda');
17
+
18
+ var R = _interopRequireWildcard(_ramda);
19
+
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; } }
21
+
22
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
+
24
+ var getCellsAttributesIds = exports.getCellsAttributesIds = function getCellsAttributesIds(layoutIds, attributes) {
25
+ return R.reduce(function (acc, attr) {
26
+ if (!attr.series) {
27
+ return acc;
28
+ }
29
+ if (R.isEmpty(attr.relationship || [])) {
30
+ return R.assoc(attr.id, attr.id, acc);
31
+ }
32
+ var indexedHeaderIds = R.indexBy(R.identity, layoutIds.header);
33
+ var indexedSectionsIds = R.indexBy(R.identity, layoutIds.sections);
34
+ var indexedRowsIds = (0, _extends3.default)({}, indexedSectionsIds, R.indexBy(R.identity, layoutIds.rows));
35
+
36
+ var _R$partition = R.partition(function (id) {
37
+ return R.has(id, indexedHeaderIds);
38
+ }, attr.relationship),
39
+ _R$partition2 = (0, _slicedToArray3.default)(_R$partition, 2),
40
+ idsInHeader = _R$partition2[0],
41
+ rest = _R$partition2[1];
42
+
43
+ if (R.isEmpty(rest)) {
44
+ return acc;
45
+ } else if (!R.isEmpty(idsInHeader)) {
46
+ return R.assoc(attr.id, attr.id, acc);
47
+ } else {
48
+ var idsNotInSections = R.reject(function (id) {
49
+ return R.has(id, indexedSectionsIds);
50
+ }, attr.relationship);
51
+ if (R.isEmpty(idsNotInSections)) {
52
+ return acc;
53
+ }
54
+ var idsNotInRows = R.reject(function (id) {
55
+ return R.has(id, indexedRowsIds);
56
+ }, idsNotInSections);
57
+ if (R.isEmpty(idsNotInRows)) {
58
+ return acc;
59
+ }
60
+ }
61
+ return R.assoc(attr.id, attr.id, acc);
62
+ }, {}, attributes);
63
+ };
@@ -0,0 +1,47 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getCombinationDimensionsData = undefined;
7
+
8
+ var _ramda = require('ramda');
9
+
10
+ var R = _interopRequireWildcard(_ramda);
11
+
12
+ var _parseValueHierarchy = require('./parseValueHierarchy');
13
+
14
+ 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
+
16
+ var getCombinationDimensionsData = exports.getCombinationDimensionsData = function getCombinationDimensionsData(indexes, combination, previous, sameSerie) {
17
+ var coordinates = {};
18
+ var ids = [];
19
+ var _sameSerie = sameSerie;
20
+ var hasAdvancedAttributes = false;
21
+
22
+ var _combination$dimensio = combination.dimensions,
23
+ dimensions = _combination$dimensio === undefined ? [] : _combination$dimensio;
24
+
25
+ var dimValues = R.addIndex(R.reduce)(function (acc, valIndex, dimIndex) {
26
+ var dimension = R.nth(dimIndex, dimensions);
27
+ var value = R.nth(Math.abs(valIndex), R.propOr([], 'values', dimension));
28
+ hasAdvancedAttributes = !hasAdvancedAttributes ? value.hasAdvancedAttributes : true;
29
+ if (!value) {
30
+ return acc;
31
+ }
32
+ coordinates = R.assoc(dimension.id, value.id, coordinates);
33
+ ids = R.append(dimension.id + '=' + value.id, ids);
34
+ var previousValue = R.propOr({}, dimension.id, previous);
35
+ if (value.id === R.prop('id', previousValue || {}) && _sameSerie) {
36
+ return R.assoc(dimension.id, previousValue, acc);
37
+ } else {
38
+ var parsedValue = (0, _parseValueHierarchy.parseValueHierarchy)(value, _sameSerie ? previousValue || {} : {}, dimension.indexedValues);
39
+ if (!R.isNil(previous)) {
40
+ _sameSerie = false;
41
+ }
42
+ return R.assoc(dimension.id, parsedValue, acc);
43
+ }
44
+ }, {}, indexes);
45
+
46
+ return { dimValues: dimValues, coordinates: coordinates, ids: ids, sameSerie: _sameSerie, hasAdvancedAttributes: hasAdvancedAttributes };
47
+ };