@sis-cc/dotstatsuite-components 15.0.6 → 15.0.7

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.
@@ -43,9 +43,7 @@ var getUnitsArtefacts = exports.getUnitsArtefacts = function getUnitsArtefacts(_
43
43
 
44
44
  var keyedDimensions = R.indexBy(R.prop('id'), dimensions);
45
45
 
46
- var parsedUnitsAttributes = R.converge(function (datasetLevel, observationLevel) {
47
- return R.over(R.lensProp('header'), R.merge(datasetLevel))(observationLevel);
48
- }, [R.pipe(R.pathOr([], ['data', 'structure', 'attributes', 'dataSet']), R.filter(R.pipe(R.propOr([], 'values'), R.length, R.equals(1))), R.indexBy(R.prop('id')), R.pick(unitsDefinitionCodes), R.filter(R.propOr(true, 'display')), R.mapObjIndexed(R.assoc('datasetLevel', true))), R.pipe(R.pathOr([], ['data', 'structure', 'attributes', 'observation']), R.addIndex(R.reduce)(function (acc, attr, index) {
46
+ var parsedUnitsAttributes = R.pipe(R.pathOr([], ['data', 'structure', 'attributes', 'observation']), R.addIndex(R.reduce)(function (acc, attr, index) {
49
47
  if (!R.includes(attr.id, unitsDefinitionCodes) || R.length(R.propOr([], 'values', attr)) === 0 || !R.propOr(true, 'display', attr)) {
50
48
  return acc;
51
49
  }
@@ -53,6 +51,9 @@ var getUnitsArtefacts = exports.getUnitsArtefacts = function getUnitsArtefacts(_
53
51
  if (length === 0) {
54
52
  return acc;
55
53
  }
54
+ if (R.hasPath(['relationship', 'none'], attr) || R.hasPath(['relationship', 'dataflow'], attr)) {
55
+ return R.assocPath(['header', attr.id], (0, _extends3.default)({}, attr, { index: index, datasetLevel: true }), acc);
56
+ }
56
57
  if (R.path(['relationship', 'primaryMeasure'], attr) === 'OBS_VALUE' || R.hasPath(['relationship', 'observation'], attr)) {
57
58
  return R.assocPath(['series', attr.id], (0, _extends3.default)({}, attr, { index: index, observations: true }), acc);
58
59
  }
@@ -67,7 +68,7 @@ var getUnitsArtefacts = exports.getUnitsArtefacts = function getUnitsArtefacts(_
67
68
  }, attachedDimensions);
68
69
  var level = R.isEmpty(filteredAttachedDimensions) ? 'header' : 'series';
69
70
  return R.assocPath([level, attr.id], (0, _extends3.default)({}, attr, { index: index, relationship: { dimensions: filteredAttachedDimensions } }), acc);
70
- }, { header: {}, series: {} }))])(data);
71
+ }, { header: {}, series: {} }))(data);
71
72
 
72
73
  var hasSeries = R.pipe(R.all(R.isEmpty), R.not)([parsedUnitsDimensions.series, parsedUnitsAttributes.series]);
73
74
 
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.6",
4
+ "version": "15.0.7",
5
5
  "main": "lib/index.js",
6
6
  "author": "OECD",
7
7
  "license": "MIT",
@@ -28,61 +28,48 @@ export const getUnitsArtefacts = ({ unitsDefinitionCodes=[], data }) => {
28
28
 
29
29
  const keyedDimensions = R.indexBy(R.prop('id'), dimensions);
30
30
 
31
- const parsedUnitsAttributes = R.converge(
32
- (datasetLevel, observationLevel) => R.over(
33
- R.lensProp('header'),
34
- R.merge(datasetLevel)
35
- )(observationLevel),
36
- [
37
- R.pipe(
38
- R.pathOr([], ['data', 'structure', 'attributes', 'dataSet']),
39
- R.filter(R.pipe(R.propOr([], 'values'), R.length, R.equals(1))),
40
- R.indexBy(R.prop('id')),
41
- R.pick(unitsDefinitionCodes),
42
- R.filter(R.propOr(true, 'display')),
43
- R.mapObjIndexed(R.assoc('datasetLevel', true))
44
- ),
45
- R.pipe(
46
- R.pathOr([], ['data', 'structure', 'attributes', 'observation']),
47
- R.addIndex(R.reduce)(
48
- (acc, attr, index) => {
49
- if(!R.includes(attr.id, unitsDefinitionCodes) || R.length(R.propOr([], 'values', attr)) === 0
50
- || !R.propOr(true, 'display', attr)) {
51
- return acc;
52
- }
53
- const length = getRelevantLength(attr);
54
- if (length === 0) {
55
- return acc;
56
- }
57
- if ((R.path(['relationship', 'primaryMeasure'], attr) === 'OBS_VALUE')
58
- || (R.hasPath(['relationship', 'observation'], attr))) {
59
- return R.assocPath(['series', attr.id], { ...attr, index, observations: true }, acc);
60
- }
61
- const attachedDimensions = R.path(['relationship', 'dimensions'], attr);
62
- if (R.isNil(attachedDimensions)) {
63
- return acc;
64
- }
65
- const filteredAttachedDimensions = R.filter(
66
- (id) => {
67
- const dimension = R.propOr({}, id, keyedDimensions);
68
- const nValues = R.pipe(R.propOr([], 'values'), R.length)(dimension);
69
- return nValues > 1;
70
- },
71
- attachedDimensions
72
- );
73
- const level = R.isEmpty(filteredAttachedDimensions)
74
- ? 'header'
75
- : 'series';
76
- return R.assocPath(
77
- [level, attr.id],
78
- { ...attr, index, relationship: { dimensions: filteredAttachedDimensions } },
79
- acc
80
- );
31
+ const parsedUnitsAttributes = R.pipe(
32
+ R.pathOr([], ['data', 'structure', 'attributes', 'observation']),
33
+ R.addIndex(R.reduce)(
34
+ (acc, attr, index) => {
35
+ if(!R.includes(attr.id, unitsDefinitionCodes) || R.length(R.propOr([], 'values', attr)) === 0
36
+ || !R.propOr(true, 'display', attr)) {
37
+ return acc;
38
+ }
39
+ const length = getRelevantLength(attr);
40
+ if (length === 0) {
41
+ return acc;
42
+ }
43
+ if (R.hasPath(['relationship', 'none'], attr) || R.hasPath(['relationship', 'dataflow'], attr)) {
44
+ return R.assocPath(['header', attr.id], { ...attr, index, datasetLevel: true }, acc);
45
+ }
46
+ if ((R.path(['relationship', 'primaryMeasure'], attr) === 'OBS_VALUE')
47
+ || (R.hasPath(['relationship', 'observation'], attr))) {
48
+ return R.assocPath(['series', attr.id], { ...attr, index, observations: true }, acc);
49
+ }
50
+ const attachedDimensions = R.path(['relationship', 'dimensions'], attr);
51
+ if (R.isNil(attachedDimensions)) {
52
+ return acc;
53
+ }
54
+ const filteredAttachedDimensions = R.filter(
55
+ (id) => {
56
+ const dimension = R.propOr({}, id, keyedDimensions);
57
+ const nValues = R.pipe(R.propOr([], 'values'), R.length)(dimension);
58
+ return nValues > 1;
81
59
  },
82
- { header: {}, series: {} }
83
- )
84
- )
85
- ]
60
+ attachedDimensions
61
+ );
62
+ const level = R.isEmpty(filteredAttachedDimensions)
63
+ ? 'header'
64
+ : 'series';
65
+ return R.assocPath(
66
+ [level, attr.id],
67
+ { ...attr, index, relationship: { dimensions: filteredAttachedDimensions } },
68
+ acc
69
+ );
70
+ },
71
+ { header: {}, series: {} }
72
+ )
86
73
  )(data);
87
74
 
88
75
  const hasSeries = R.pipe(
@@ -4,11 +4,6 @@ import { getUnitsArtefacts } from '../src/rules/src/table/units/getUnitsArtefact
4
4
  const data = {
5
5
  structure: {
6
6
  attributes: {
7
- dataSet: [
8
- { id: 'A0', values: [] },
9
- { id: 'A1', values: [{ id: 'V1' }] },
10
- { id: 'A2', values: [{ id: 'V1' }, { id: 'V2' }] },
11
- ],
12
7
  observation: [
13
8
  { id: 'A3', values: [] },
14
9
  { id: 'A4', relationship: { dimensions: ['D2'] }, values: [{ id: 'V1' }] },
@@ -18,6 +13,9 @@ const data = {
18
13
  { id: 'A8', relationship: { primaryMeasure: 'OBS_VALUE' }, values: [{ id: 'V1' }, { id: 'V2' }] },
19
14
  { id: 'A9', relationship: { primaryMeasure: 'OBS_VALUE' }, values: [{ id: 'V1' }, { id: 'V2' }], display: false },
20
15
  { id: 'A10', relationship: { observation: {} }, values: [{ id: 'V1' }, { id: 'V2' }] },
16
+ { id: 'A0', relationship: { none: {} }, values: [] },
17
+ { id: 'A1', relationship: { none: {} }, values: [{ id: 'V1' }] },
18
+ { id: 'A2', relationship: { dataflow: {} }, values: [{ id: 'V1' }, { id: 'V2' }] },
21
19
  ]
22
20
  },
23
21
  dimensions: {
@@ -45,7 +43,7 @@ describe('getUnitsArtefacts tests', () => {
45
43
  });
46
44
  it('full header', () => {
47
45
  expect(getUnitsArtefacts({ data: { data }, unitsDefinitionCodes: ['A1', 'D1'] })).to.deep.equal({
48
- attributes: { header: { A1: { id: 'A1', datasetLevel: true, values: [{ id: 'V1' }] } }, series: {} },
46
+ attributes: { header: { A1: { id: 'A1', relationship: { none: {} }, index: 9, datasetLevel: true, values: [{ id: 'V1' }] } }, series: {} },
49
47
  dimensions: { header: { D1: { id: 'D1', header: true, index: 1, values: [{ id: 'V1' }] } }, series: {} },
50
48
  });
51
49
  });
@@ -83,7 +81,7 @@ describe('getUnitsArtefacts tests', () => {
83
81
  expect(getUnitsArtefacts({ data: { data }, unitsDefinitionCodes: ['A1', 'A4', 'A5', 'D2'] })).to.deep.equal({
84
82
  attributes: {
85
83
  series: {
86
- A1: { id: 'A1', datasetLevel: true, values: [{ id: 'V1' }] },
84
+ A1: { id: 'A1', relationship: { none: {} }, index: 9, datasetLevel: true, values: [{ id: 'V1' }] },
87
85
  A4: { id: 'A4', index: 1, relationship: { dimensions: ['D2'] }, values: [{ id: 'V1' }] },
88
86
  A5: { id: 'A5', index: 2, relationship: { dimensions: ['D2'] }, values: [{ id: 'V1' }, { id: 'V2' }] }
89
87
  },