@sis-cc/dotstatsuite-components 13.0.4 → 13.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.
- package/lib/rules/src/preparators/enhanceObservations.js +4 -8
- package/lib/rules/src/sdmx-data/index.js +3 -4
- package/lib/rules/src/table/preparators/getOneValueDimensions.js +2 -14
- package/lib/rules/src/table/preparators/parseAttributes.js +3 -10
- package/lib/rules/src/table/preparators/prepareData.js +4 -25
- package/lib/rules/src/table/units/getUnitsArtefacts.js +6 -11
- package/lib/rules/src/v8-transformer.js +39 -23
- package/lib/rules2/src/getNotDisplayedIds.js +42 -0
- package/lib/rules2/src/getSidebarData.js +41 -18
- package/lib/rules2/src/index.js +9 -0
- package/package.json +1 -1
- package/src/rules/src/preparators/enhanceObservations.js +4 -7
- package/src/rules/src/properties/getHeaderProps.js +1 -2
- package/src/rules/src/sdmx-data/index.js +4 -4
- package/src/rules/src/table/preparators/getOneValueDimensions.js +4 -22
- package/src/rules/src/table/preparators/parseAttributes.js +3 -3
- package/src/rules/src/table/preparators/prepareData.js +3 -21
- package/src/rules/src/table/units/getUnitsArtefacts.js +6 -6
- package/src/rules/src/v8-transformer.js +49 -36
- package/src/rules2/src/getNotDisplayedIds.js +40 -0
- package/src/rules2/src/getSidebarData.js +41 -23
- package/src/rules2/src/index.js +1 -0
- package/test/enhanceObservations.test.js +2 -2
- package/test/getNotDisplayedIds.test.js +31 -0
- package/test/getOneValueDimensions.test.js +12 -17
- package/test/getSidebarData.test.js +104 -0
- package/test/getUnitsArtefacts.test.js +10 -14
- package/test/mocks/table-prep-multi-hierarchies--attributes.json +2 -0
- package/test/parseAttributes.test.js +4 -9
- package/test/table-prep-perf.test.js +0 -7
- package/lib/rules/src/preparators/getDisplay.js +0 -32
- package/lib/rules/src/table/preparators/getDisplay.js +0 -32
- package/lib/rules/src/table/preparators/getNoDisplayAnnotationsIndexes.js +0 -16
- package/lib/rules/src/table/preparators/getNoDisplayCodes.js +0 -32
- package/src/rules/src/preparators/getDisplay.js +0 -20
- package/src/rules/src/table/preparators/getDisplay.js +0 -20
- package/src/rules/src/table/preparators/getNoDisplayAnnotationsIndexes.js +0 -9
- package/src/rules/src/table/preparators/getNoDisplayCodes.js +0 -32
- package/test/getNoDisplayAnnotationsIndexes.test.js +0 -18
- package/test/getNoDisplayCodes.test.js +0 -87
|
@@ -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' }]
|
|
23
|
-
{ id: 'A9', relationship: { primaryMeasure: 'OBS_VALUE' }, values: [{ id: 'V1' }, { id: 'V2' }],
|
|
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']
|
|
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']
|
|
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']
|
|
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']
|
|
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']
|
|
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']
|
|
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']
|
|
112
|
-
attributes: { header: {}, series: { A8: { id: 'A8', observations: true, index: 5, relationship: { primaryMeasure: 'OBS_VALUE' }, values: [{ id: 'V1' }, { id: 'V2' }]
|
|
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
|
});
|
|
@@ -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',
|
|
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
|
|
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
|
-
});
|