@sis-cc/dotstatsuite-components 13.0.3 → 13.2.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 (44) hide show
  1. package/lib/rules/src/dimension-utils.js +3 -2
  2. package/lib/rules/src/preparators/enhanceObservations.js +4 -8
  3. package/lib/rules/src/sdmx-data/index.js +3 -4
  4. package/lib/rules/src/table/preparators/getOneValueDimensions.js +2 -14
  5. package/lib/rules/src/table/preparators/parseAttributes.js +3 -10
  6. package/lib/rules/src/table/preparators/prepareData.js +4 -25
  7. package/lib/rules/src/table/units/getUnitsArtefacts.js +6 -11
  8. package/lib/rules/src/v8-transformer.js +39 -23
  9. package/lib/rules2/src/getNotDisplayedIds.js +42 -0
  10. package/lib/rules2/src/getSidebarData.js +41 -18
  11. package/lib/rules2/src/index.js +9 -0
  12. package/lib/viewer/src/index.js +5 -3
  13. package/package.json +1 -1
  14. package/src/rules/src/dimension-utils.js +4 -4
  15. package/src/rules/src/preparators/enhanceObservations.js +4 -7
  16. package/src/rules/src/properties/getHeaderProps.js +1 -2
  17. package/src/rules/src/sdmx-data/index.js +4 -4
  18. package/src/rules/src/table/preparators/getOneValueDimensions.js +4 -22
  19. package/src/rules/src/table/preparators/parseAttributes.js +3 -3
  20. package/src/rules/src/table/preparators/prepareData.js +3 -21
  21. package/src/rules/src/table/units/getUnitsArtefacts.js +6 -6
  22. package/src/rules/src/v8-transformer.js +49 -36
  23. package/src/rules2/src/getNotDisplayedIds.js +40 -0
  24. package/src/rules2/src/getSidebarData.js +41 -23
  25. package/src/rules2/src/index.js +1 -0
  26. package/src/viewer/src/index.js +7 -7
  27. package/test/enhanceObservations.test.js +2 -2
  28. package/test/getNotDisplayedIds.test.js +31 -0
  29. package/test/getOneValueDimensions.test.js +12 -17
  30. package/test/getSidebarData.test.js +104 -0
  31. package/test/getUnitsArtefacts.test.js +10 -14
  32. package/test/mocks/table-prep-multi-hierarchies--attributes.json +2 -0
  33. package/test/parseAttributes.test.js +4 -9
  34. package/test/table-prep-perf.test.js +0 -7
  35. package/lib/rules/src/preparators/getDisplay.js +0 -32
  36. package/lib/rules/src/table/preparators/getDisplay.js +0 -32
  37. package/lib/rules/src/table/preparators/getNoDisplayAnnotationsIndexes.js +0 -16
  38. package/lib/rules/src/table/preparators/getNoDisplayCodes.js +0 -32
  39. package/src/rules/src/preparators/getDisplay.js +0 -20
  40. package/src/rules/src/table/preparators/getDisplay.js +0 -20
  41. package/src/rules/src/table/preparators/getNoDisplayAnnotationsIndexes.js +0 -9
  42. package/src/rules/src/table/preparators/getNoDisplayCodes.js +0 -32
  43. package/test/getNoDisplayAnnotationsIndexes.test.js +0 -18
  44. package/test/getNoDisplayCodes.test.js +0 -87
@@ -113,4 +113,108 @@ describe('getSidebarData tests', () => {
113
113
  }
114
114
  ]);
115
115
  });
116
+ it('non displayed dimensions handling', () => {
117
+ const attributes = {
118
+ '::': [
119
+ { id: 'aa0', label: 'advanced attribute 0', value: 'value' },
120
+ { id: 'aa1', label: 'advanced attribute 1', value: 'value' },
121
+ ],
122
+ '0::': [
123
+ { id: 'aa2', label: 'advanced attribute 2', value: 'value' },
124
+ { id: 'aa3', label: 'advanced attribute 3', value: 'value' },
125
+ ]
126
+ };
127
+ const metadata = {
128
+ '0::': [
129
+ { id: 'ma0', label: 'metadata attribute 0', value: 'value' },
130
+ { id: 'ma1', label: 'metadata attribute 1', value: 'value' },
131
+ ],
132
+ '0::0': [
133
+ { id: 'ma2', label: 'metadata attribute 2', value: 'value' },
134
+ { id: 'ma3', label: 'metadata attribute 3', value: 'value' },
135
+ ]
136
+ };
137
+ const options = {
138
+ display: 'code',
139
+ attributesLabel: 'Advanced Attributes'
140
+ };
141
+ const dataflow = {
142
+ id: 'DF',
143
+ name: 'Dataflow'
144
+ };
145
+ const dimensions = [
146
+ { id: 'd0', name: 'dimension 0', values: [{ id: 'd0v0', name: 'value 0' }] },
147
+ { id: 'd1', name: 'dimension 1', values: [{ id: 'd1v0', name: 'value 0' }] },
148
+ { id: 'd2', name: 'dimension 2', display: false, values: [{ id: 'd2v0', name: 'value 0' }] },
149
+ ];
150
+
151
+ expect(getSidebarData(attributes, metadata, dataflow, dimensions, options)).to.deep.equal([
152
+ {
153
+ id: '0::',
154
+ label: 'd0: d0v0',
155
+ splitCoord: ['0', '', ''],
156
+ children: [
157
+ {
158
+ id: '0::-attr',
159
+ label: 'Advanced Attributes',
160
+ children: [
161
+ {
162
+ id: 'aa2',
163
+ label: 'advanced attribute 2',
164
+ value: 'value'
165
+ },
166
+ {
167
+ id: 'aa3',
168
+ label: 'advanced attribute 3',
169
+ value: 'value'
170
+ }
171
+ ]
172
+ },
173
+ {
174
+ id: 'ma0',
175
+ label: 'metadata attribute 0',
176
+ value: 'value'
177
+ },
178
+ {
179
+ id: 'ma1',
180
+ label: 'metadata attribute 1',
181
+ value: 'value'
182
+ },
183
+ {
184
+ id: 'ma2',
185
+ label: 'metadata attribute 2',
186
+ value: 'value'
187
+ },
188
+ {
189
+ id: 'ma3',
190
+ label: 'metadata attribute 3',
191
+ value: 'value'
192
+ }
193
+ ]
194
+ },
195
+ {
196
+ id: '::',
197
+ label: 'DF',
198
+ splitCoord: ['', '', ''],
199
+ children: [
200
+ {
201
+ id: '::-attr',
202
+ label: 'Advanced Attributes',
203
+ children: [
204
+ {
205
+ id: 'aa0',
206
+ label: 'advanced attribute 0',
207
+ value: 'value'
208
+ },
209
+ {
210
+ id: 'aa1',
211
+ label: 'advanced attribute 1',
212
+ value: 'value'
213
+ }
214
+ ]
215
+ }
216
+ ]
217
+ }
218
+ ]);
219
+ });
116
220
  });
@@ -1,9 +1,5 @@
1
1
  import { expect } from 'chai';
2
2
  import { getUnitsArtefacts } from '../src/rules/src/table/units/getUnitsArtefacts';
3
- import { getDisplay } from '../src/rules/src/preparators/getDisplay';
4
-
5
- const noDisplayIndexes = [0, 1];
6
- const _getDisplay = getDisplay({ noDisplayIndexes });
7
3
 
8
4
  const data = {
9
5
  structure: {
@@ -19,8 +15,8 @@ const data = {
19
15
  { id: 'A5', relationship: { dimensions: ['D2'] }, values: [{ id: 'V1' }, { id: 'V2' }] },
20
16
  { id: 'A6', relationship: { dimensions: ['D1'] }, values: [{ id: 'V1' }] },
21
17
  { id: 'A7', relationship: { dimensions: ['D1', 'D2'] }, values: [{ id: 'V1' }] },
22
- { id: 'A8', relationship: { primaryMeasure: 'OBS_VALUE' }, values: [{ id: 'V1' }, { id: 'V2' }], annotations: [2, 3, 4] },
23
- { id: 'A9', relationship: { primaryMeasure: 'OBS_VALUE' }, values: [{ id: 'V1' }, { id: 'V2' }], annotations: [0, 5] },
18
+ { id: 'A8', relationship: { primaryMeasure: 'OBS_VALUE' }, values: [{ id: 'V1' }, { id: 'V2' }] },
19
+ { id: 'A9', relationship: { primaryMeasure: 'OBS_VALUE' }, values: [{ id: 'V1' }, { id: 'V2' }], display: false },
24
20
  ]
25
21
  },
26
22
  dimensions: {
@@ -47,13 +43,13 @@ describe('getUnitsArtefacts tests', () => {
47
43
  });
48
44
  });
49
45
  it('full header', () => {
50
- expect(getUnitsArtefacts({ data: { data }, unitsDefinitionCodes: ['A1', 'D1'], getDisplay: _getDisplay })).to.deep.equal({
46
+ expect(getUnitsArtefacts({ data: { data }, unitsDefinitionCodes: ['A1', 'D1'] })).to.deep.equal({
51
47
  attributes: { header: { A1: { id: 'A1', datasetLevel: true, values: [{ id: 'V1' }] } }, series: {} },
52
48
  dimensions: { header: { D1: { id: 'D1', header: true, index: 1, values: [{ id: 'V1' }] } }, series: {} },
53
49
  });
54
50
  });
55
51
  it('full series', () => {
56
- expect(getUnitsArtefacts({ data: { data }, unitsDefinitionCodes: ['A4', 'A5', 'D2'], getDisplay: _getDisplay })).to.deep.equal({
52
+ expect(getUnitsArtefacts({ data: { data }, unitsDefinitionCodes: ['A4', 'A5', 'D2'] })).to.deep.equal({
57
53
  attributes: {
58
54
  series: {
59
55
  A4: { id: 'A4', index: 1, relationship: { dimensions: ['D2'] }, values: [{ id: 'V1' }] },
@@ -65,7 +61,7 @@ describe('getUnitsArtefacts tests', () => {
65
61
  });
66
62
  });
67
63
  it('header dimensions with series', () => {
68
- expect(getUnitsArtefacts({ data: { data }, unitsDefinitionCodes: ['A4', 'A5', 'D1', 'D2'], getDisplay: _getDisplay })).to.deep.equal({
64
+ expect(getUnitsArtefacts({ data: { data }, unitsDefinitionCodes: ['A4', 'A5', 'D1', 'D2'] })).to.deep.equal({
69
65
  attributes: {
70
66
  series: {
71
67
  A4: { id: 'A4', index: 1, relationship: { dimensions: ['D2'] }, values: [{ id: 'V1' }] },
@@ -83,7 +79,7 @@ describe('getUnitsArtefacts tests', () => {
83
79
  });
84
80
  });
85
81
  it('header attributes with series', () => {
86
- expect(getUnitsArtefacts({ data: { data }, unitsDefinitionCodes: ['A1', 'A4', 'A5', 'D2'], getDisplay: _getDisplay })).to.deep.equal({
82
+ expect(getUnitsArtefacts({ data: { data }, unitsDefinitionCodes: ['A1', 'A4', 'A5', 'D2'] })).to.deep.equal({
87
83
  attributes: {
88
84
  series: {
89
85
  A1: { id: 'A1', datasetLevel: true, values: [{ id: 'V1' }] },
@@ -96,20 +92,20 @@ describe('getUnitsArtefacts tests', () => {
96
92
  });
97
93
  });
98
94
  it('all attached dimensions single value makes a header', () => {
99
- expect(getUnitsArtefacts({ data: { data }, unitsDefinitionCodes: ['A6'], getDisplay: _getDisplay })).to.deep.equal({
95
+ expect(getUnitsArtefacts({ data: { data }, unitsDefinitionCodes: ['A6'] })).to.deep.equal({
100
96
  attributes: { header: { A6: { id: 'A6', index: 3, relationship: { dimensions: [] }, values: [{ id: 'V1' }] }, }, series: {} },
101
97
  dimensions: { header: {}, series: {} },
102
98
  });
103
99
  });
104
100
  it('series attributes keeps only multi values dimensions in attachment', () => {
105
- expect(getUnitsArtefacts({ data: { data }, unitsDefinitionCodes: ['A7'], getDisplay: _getDisplay })).to.deep.equal({
101
+ expect(getUnitsArtefacts({ data: { data }, unitsDefinitionCodes: ['A7'] })).to.deep.equal({
106
102
  attributes: { series: { A7: { id: 'A7', index: 4, relationship: { dimensions: ['D2'] }, values: [{ id: 'V1' }] }, }, header: {} },
107
103
  dimensions: { header: {}, series: {} },
108
104
  });
109
105
  });
110
106
  it('no display annotations', () => {
111
- expect(getUnitsArtefacts({ data: { data }, unitsDefinitionCodes: ['A8', 'A9'], getDisplay: _getDisplay })).to.deep.equal({
112
- attributes: { header: {}, series: { A8: { id: 'A8', observations: true, index: 5, relationship: { primaryMeasure: 'OBS_VALUE' }, values: [{ id: 'V1' }, { id: 'V2' }], annotations: [2, 3, 4] } } },
107
+ expect(getUnitsArtefacts({ data: { data }, unitsDefinitionCodes: ['A8', 'A9'] })).to.deep.equal({
108
+ attributes: { header: {}, series: { A8: { id: 'A8', observations: true, index: 5, relationship: { primaryMeasure: 'OBS_VALUE' }, values: [{ id: 'V1' }, { id: 'V2' }] } } },
113
109
  dimensions: { header: {}, series: {} },
114
110
  });
115
111
  });
@@ -12,6 +12,7 @@
12
12
  "values": [
13
13
  {
14
14
  "id": "A",
15
+ "display": false,
15
16
  "order": 0,
16
17
  "name": "Normal value",
17
18
  "names": {
@@ -33,6 +34,7 @@
33
34
  "values": [
34
35
  {
35
36
  "id": "0",
37
+ "display": false,
36
38
  "order": 0,
37
39
  "name": "Units",
38
40
  "names": {
@@ -1,13 +1,8 @@
1
1
  import { expect } from 'chai';
2
2
  import { parseAttributes } from '../src/rules/src/table/preparators/parseAttributes';
3
- import { getDisplay } from '../src/rules/src/preparators/getDisplay';
4
-
5
- const noDisplayIndexes = [0, 5, 10];
6
- const notDisplayedCodes = { a17: { id: 'a17' }, a18: { values: { a18v2: 'a18v2' } } };
7
-
8
3
 
9
4
  const attributes = [
10
- { id: 'a0', annotations: [0, 4, 9], relationship: { primaryMeasure: 'OBS_VALUE' }, values: [{ id: 'a0v1' }] }, // no display
5
+ { id: 'a0', display: false, relationship: { primaryMeasure: 'OBS_VALUE' }, values: [{ id: 'a0v1' }] }, // no display
11
6
  { id: 'a1', relationship: { primaryMeasure: 'OBS_VALUE' } }, // no values
12
7
  { id: 'a2', relationship: { primaryMeasure: 'OBS_VALUE' }, values: [] }, // empty values
13
8
  { id: 'a3', values: [{ id: 'a3v1' }] }, // no relationship definition
@@ -24,8 +19,8 @@ const attributes = [
24
19
  { id: 'a14', relationship: { dimensions: ['d1'] }, values: [{ id: 'a14v1' }] }, // not recognised as footnote
25
20
  { id: 'a15', relationship: { dimensions: ['d3'] }, values: [{ id: 'a15v1' }] }, // recognised as prefscale
26
21
  { id: 'a16', relationship: { dimensions: ['d6'] }, values: [{ id: 'a16v1' }] }, // recognised as decimals
27
- { id: 'a17', relationship: { primaryMeasure: 'OBS_VALUE' }, values: [{ id: 'a17v1' }] }, // blacklisted
28
- { id: 'a18', relationship: { primaryMeasure: 'OBS_VALUE' }, values: [{ id: 'a18v1' }, { id: 'a18v2' }] }, // blacklisted value
22
+ { id: 'a17', display: false, relationship: { primaryMeasure: 'OBS_VALUE' }, values: [{ id: 'a17v1' }] }, // blacklisted
23
+ { id: 'a18', relationship: { primaryMeasure: 'OBS_VALUE' }, values: [{ id: 'a18v1' }, { id: 'a18v2', display: false }] }, // blacklisted value
29
24
  { id: 'a19', relationship: { none: {} }, values: [{ id: 'a19v1' }] }, // dataset relationship
30
25
  { id: 'a20', relationship: { primaryMeasure: 'OBS_VALUE' }, values: [{ id: 'a20v1' }] }, // units attribute
31
26
  { id: 'a21', relationship: { dataflow: {} }, values: [{ id: 'a21v0' }] }, // alternative dataflow relationship
@@ -46,7 +41,7 @@ const parsedDimensionsIds = {
46
41
  describe('parseAttributes test', () => {
47
42
  it('complete case', () => {
48
43
  expect(parseAttributes({
49
- attributes, parsedDimensionsIds, customAttributes, getDisplay: getDisplay({ noDisplayIndexes, notDisplayedCodes })
44
+ attributes, parsedDimensionsIds, customAttributes
50
45
  })).to.deep.equal({
51
46
  attributesIndexedByIds: {
52
47
  a6: { id: 'a6', index: 6, relationship: { primaryMeasure: 'OBS_VALUE' }, values: [{ id: 'a6v1' }] },
@@ -28,11 +28,6 @@ describe('table preparators performance tests', () => {
28
28
  decimals: 'DECIMALS',
29
29
  prefscale: 'PREF_SCALE'
30
30
  },
31
- noDisplayIndexes: [4],
32
- notDisplayedCodes: {
33
- OBS_STATUS: { id: 'OBS_STATUS', values: { A: 'A' } },
34
- UNIT_MULT: { id: 'UNIT_MULT', values: { '0': '0' } }
35
- },
36
31
  unitsIds: ['UNIT_MULT', 'BASE_PER']
37
32
  };
38
33
  expect(
@@ -50,8 +45,6 @@ describe('table preparators performance tests', () => {
50
45
  decimals: 'DECIMALS',
51
46
  prefscale: 'PREF_SCALE'
52
47
  },
53
- noDisplayIndexes: [],
54
- notDisplayedCodes: {},
55
48
  unitsIds: ['UNIT_MEASURE', 'UNIT_MULT', 'BASE_PER']
56
49
  };
57
50
  expect(
@@ -1,32 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getDisplay = undefined;
7
-
8
- var _ramda = require('ramda');
9
-
10
- var R = _interopRequireWildcard(_ramda);
11
-
12
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
13
-
14
- var getDisplay = exports.getDisplay = function getDisplay(_ref) {
15
- var _ref$noDisplayIndexes = _ref.noDisplayIndexes,
16
- noDisplayIndexes = _ref$noDisplayIndexes === undefined ? [] : _ref$noDisplayIndexes,
17
- _ref$notDisplayedCode = _ref.notDisplayedCodes,
18
- notDisplayedCodes = _ref$notDisplayedCode === undefined ? {} : _ref$notDisplayedCode;
19
-
20
- var annotationsValidator = R.pipe(R.propOr([], 'annotations'), R.intersection(noDisplayIndexes), R.isEmpty);
21
-
22
- var blacklistValidator = R.ifElse(R.has('values'), function (_ref2) {
23
- var id = _ref2.id;
24
- return R.anyPass([R.complement(R.has)(id), R.hasPath([id, 'values'])])(notDisplayedCodes);
25
- }, function (_ref3) {
26
- var id = _ref3.id,
27
- parent = _ref3.parent;
28
- return R.complement(R.hasPath)([parent, 'values', id], notDisplayedCodes);
29
- });
30
-
31
- return R.allPass([annotationsValidator, blacklistValidator]);
32
- };
@@ -1,32 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getDisplay = undefined;
7
-
8
- var _ramda = require('ramda');
9
-
10
- var R = _interopRequireWildcard(_ramda);
11
-
12
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
13
-
14
- var getDisplay = exports.getDisplay = function getDisplay(_ref) {
15
- var _ref$noDisplayIndexes = _ref.noDisplayIndexes,
16
- noDisplayIndexes = _ref$noDisplayIndexes === undefined ? [] : _ref$noDisplayIndexes,
17
- _ref$notDisplayedCode = _ref.notDisplayedCodes,
18
- notDisplayedCodes = _ref$notDisplayedCode === undefined ? {} : _ref$notDisplayedCode;
19
-
20
- var annotationsValidator = R.pipe(R.propOr([], 'annotations'), R.intersection(noDisplayIndexes), R.isEmpty);
21
-
22
- var blacklistValidator = R.ifElse(R.has('values'), function (_ref2) {
23
- var id = _ref2.id;
24
- return R.anyPass([R.complement(R.has)(id), R.hasPath([id, 'values'])])(notDisplayedCodes);
25
- }, function (_ref3) {
26
- var id = _ref3.id,
27
- parent = _ref3.parent;
28
- return R.complement(R.hasPath)([parent, 'values', id], notDisplayedCodes);
29
- });
30
-
31
- return R.allPass([annotationsValidator, blacklistValidator]);
32
- };
@@ -1,16 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getNoDisplayAnnotationsIndexes = undefined;
7
-
8
- var _ramda = require('ramda');
9
-
10
- var R = _interopRequireWildcard(_ramda);
11
-
12
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
13
-
14
- var getNoDisplayAnnotationsIndexes = exports.getNoDisplayAnnotationsIndexes = R.addIndex(R.reduce)(function (acc, annotation, annotationIndex) {
15
- return R.when(R.always(R.pipe(R.prop('type'), R.equals('NOT_DISPLAYED'))(annotation)), R.append(annotationIndex))(acc);
16
- }, []);
@@ -1,32 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getNoDisplayCodes = undefined;
7
-
8
- var _ramda = require('ramda');
9
-
10
- var R = _interopRequireWildcard(_ramda);
11
-
12
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
13
-
14
- var getNoDisplayCodes = exports.getNoDisplayCodes = function getNoDisplayCodes(_ref) {
15
- var noDisplayIndexes = _ref.noDisplayIndexes,
16
- annotations = _ref.annotations,
17
- datasetIndexes = _ref.datasetIndexes;
18
-
19
- var datasetLevelNoDisplayIndexes = R.intersection(noDisplayIndexes, datasetIndexes);
20
-
21
- return R.pipe(R.nth(R.head(datasetLevelNoDisplayIndexes)), R.when(R.isNil, R.always({})),
22
- // duplicate from sdmxjs
23
- R.propOr('', 'title'), R.split(','), R.reduce(function (acc, entry) {
24
- if (R.isEmpty(entry)) {
25
- return acc;
26
- }
27
- var parse = R.split('=', entry);
28
- var id = R.head(parse);
29
- var values = R.ifElse(R.pipe(R.length, R.equals(1)), R.always(null), R.pipe(R.last, R.split('+'), R.reject(R.isEmpty), R.indexBy(R.identity)))(parse);
30
- return R.pipe(R.set(R.lensProp(id), { id: id }), R.when(R.always(!R.isNil(values) && !R.isEmpty(values)), R.set(R.lensPath([id, 'values']), values)))(acc);
31
- }, {}))(annotations);
32
- };
@@ -1,20 +0,0 @@
1
- import * as R from 'ramda';
2
-
3
- export const getDisplay = ({ noDisplayIndexes = [], notDisplayedCodes = {} }) => {
4
- const annotationsValidator = R.pipe(
5
- R.propOr([], 'annotations'),
6
- R.intersection(noDisplayIndexes),
7
- R.isEmpty
8
- );
9
-
10
- const blacklistValidator = R.ifElse(
11
- R.has('values'),
12
- ({ id }) => R.anyPass([
13
- R.complement(R.has)(id),
14
- R.hasPath([id, 'values'])
15
- ])(notDisplayedCodes),
16
- ({ id, parent }) => R.complement(R.hasPath)([parent, 'values', id], notDisplayedCodes)
17
- );
18
-
19
- return R.allPass([annotationsValidator, blacklistValidator]);
20
- };
@@ -1,20 +0,0 @@
1
- import * as R from 'ramda';
2
-
3
- export const getDisplay = ({ noDisplayIndexes = [], notDisplayedCodes = {} }) => {
4
- const annotationsValidator = R.pipe(
5
- R.propOr([], 'annotations'),
6
- R.intersection(noDisplayIndexes),
7
- R.isEmpty
8
- );
9
-
10
- const blacklistValidator = R.ifElse(
11
- R.has('values'),
12
- ({ id }) => R.anyPass([
13
- R.complement(R.has)(id),
14
- R.hasPath([id, 'values'])
15
- ])(notDisplayedCodes),
16
- ({ id, parent }) => R.complement(R.hasPath)([parent, 'values', id], notDisplayedCodes)
17
- );
18
-
19
- return R.allPass([annotationsValidator, blacklistValidator]);
20
- };
@@ -1,9 +0,0 @@
1
- import * as R from 'ramda';
2
-
3
- export const getNoDisplayAnnotationsIndexes = R.addIndex(R.reduce)(
4
- (acc, annotation, annotationIndex) => R.when(
5
- R.always(R.pipe(R.prop('type'), R.equals('NOT_DISPLAYED'))(annotation)),
6
- R.append(annotationIndex)
7
- )(acc),
8
- []
9
- );
@@ -1,32 +0,0 @@
1
- import * as R from 'ramda';
2
-
3
- export const getNoDisplayCodes = ({ noDisplayIndexes, annotations, datasetIndexes }) => {
4
- const datasetLevelNoDisplayIndexes = R.intersection(noDisplayIndexes, datasetIndexes);
5
-
6
- return R.pipe(
7
- R.nth(R.head(datasetLevelNoDisplayIndexes)),
8
- R.when(R.isNil, R.always({})),
9
- // duplicate from sdmxjs
10
- R.propOr('', 'title'),
11
- R.split(','),
12
- R.reduce((acc, entry) => {
13
- if (R.isEmpty(entry)) {
14
- return acc;
15
- }
16
- const parse = R.split('=', entry);
17
- const id = R.head(parse);
18
- const values = R.ifElse(
19
- R.pipe(R.length, R.equals(1)),
20
- R.always(null),
21
- R.pipe(R.last, R.split('+'), R.reject(R.isEmpty), R.indexBy(R.identity)),
22
- )(parse);
23
- return R.pipe(
24
- R.set(R.lensProp(id), { id }),
25
- R.when(
26
- R.always(!R.isNil(values) && !R.isEmpty(values)),
27
- R.set(R.lensPath([id, 'values']), values),
28
- ),
29
- )(acc);
30
- }, {})
31
- )(annotations);
32
- };
@@ -1,18 +0,0 @@
1
- import { expect } from 'chai';
2
- import { getNoDisplayAnnotationsIndexes } from '../src/rules/src/table/preparators/getNoDisplayAnnotationsIndexes';
3
-
4
- describe('getNoDisplayAnnotationsIndexes test', () => {
5
- it('basic test', () => {
6
- const annotations = [
7
- {},
8
- { random: 'test' },
9
- { type: 'wrong' },
10
- { type: 'NOT_DISPLAYED', text: 'correct case' },
11
- { type: 'NOT_DISPLAYED', message: 'other one' },
12
- { other: 'random' },
13
- { type: 'NOT_DISPLAYED', information: 'one last' }
14
- ];
15
-
16
- expect(getNoDisplayAnnotationsIndexes(annotations)).to.deep.equal([3, 4, 6]);
17
- });
18
- });
@@ -1,87 +0,0 @@
1
- import { expect } from 'chai';
2
- import { getNoDisplayCodes } from '../src/rules/src/table/preparators/getNoDisplayCodes';
3
-
4
- const annotations = [
5
- {},
6
- { title: '' },
7
- { title: 'Toto' },
8
- { title: 'Toto=Africa' },
9
- { title: 'JM_Jarre=Oxygen+Equinoxe' },
10
- { title: 'Toto,JM_Jarre' },
11
- { title: 'Toto,JM_Jarre=Oxygen+Equinoxe' },
12
- { title: 'Toto=Africa,JM_Jarre=Oxygen+Equinoxe' }
13
- ];
14
-
15
- const noDisplayIndexes = [0, 1, 2, 3, 4, 5, 6, 7];
16
-
17
- describe('getNoDisplayCodes tests', () => {
18
- it('no indexes match', () => {
19
- expect(getNoDisplayCodes({
20
- noDisplayIndexes,
21
- annotations,
22
- datasetIndexes: [8, 9]
23
- })).to.deep.equal({});
24
- });
25
- it('no title', () => {
26
- expect(getNoDisplayCodes({
27
- noDisplayIndexes,
28
- annotations,
29
- datasetIndexes: [0, 1]
30
- })).to.deep.equal({});
31
- });
32
- it('empty title', () => {
33
- expect(getNoDisplayCodes({
34
- noDisplayIndexes,
35
- annotations,
36
- datasetIndexes: [1, 2]
37
- })).to.deep.equal({});
38
- });
39
- it('dimension', () => {
40
- expect(getNoDisplayCodes({
41
- noDisplayIndexes,
42
- annotations,
43
- datasetIndexes: [2]
44
- })).to.deep.equal({ Toto: { id: 'Toto' } });
45
- });
46
- it('dimension value', () => {
47
- expect(getNoDisplayCodes({
48
- noDisplayIndexes,
49
- annotations,
50
- datasetIndexes: [3, 4, 5]
51
- })).to.deep.equal({ Toto: { id: 'Toto', values: { Africa: 'Africa' } } });
52
- });
53
- it('dimension values', () => {
54
- expect(getNoDisplayCodes({
55
- noDisplayIndexes,
56
- annotations,
57
- datasetIndexes: [4, 5]
58
- })).to.deep.equal({ JM_Jarre: { id: 'JM_Jarre', values: { Oxygen: 'Oxygen', Equinoxe: 'Equinoxe' } } });
59
- });
60
- it('dimensions', () => {
61
- expect(getNoDisplayCodes({
62
- noDisplayIndexes,
63
- annotations,
64
- datasetIndexes: [5, 9, 10]
65
- })).to.deep.equal({ Toto: { id: 'Toto' }, JM_Jarre: { id: 'JM_Jarre' } });
66
- });
67
- it('dimension plus dimension values', () => {
68
- expect(getNoDisplayCodes({
69
- noDisplayIndexes,
70
- annotations,
71
- datasetIndexes: [18, 6, 2]
72
- })).to.deep.equal({
73
- Toto: { id: 'Toto' },
74
- JM_Jarre: { id: 'JM_Jarre', values: { Oxygen: 'Oxygen', Equinoxe: 'Equinoxe' } }
75
- });
76
- });
77
- it('dimension value plus dimension values', () => {
78
- expect(getNoDisplayCodes({
79
- noDisplayIndexes,
80
- annotations,
81
- datasetIndexes: [7, 8, 9]
82
- })).to.deep.equal({
83
- Toto: { id: 'Toto', values: { Africa: 'Africa' } },
84
- JM_Jarre: { id: 'JM_Jarre', values: { Oxygen: 'Oxygen', Equinoxe: 'Equinoxe' } }
85
- });
86
- });
87
- });