@sis-cc/dotstatsuite-components 12.1.3 → 12.2.1
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/rules2/src/getDataflowTooltipAttributesIds.js +25 -0
- package/lib/rules2/src/getMSDInformations.js +40 -0
- package/lib/rules2/src/getSidebarData.js +3 -2
- package/lib/rules2/src/index.js +18 -0
- package/lib/rules2/src/parseMetadataSeries.js +3 -2
- package/package.json +2 -2
- package/src/rules2/src/getDataflowTooltipAttributesIds.js +15 -0
- package/src/rules2/src/getMSDInformations.js +20 -0
- package/src/rules2/src/getSidebarData.js +3 -2
- package/src/rules2/src/index.js +2 -0
- package/src/rules2/src/parseMetadataSeries.js +3 -2
- package/test/getDataflowTooltipAttributesIds.js +74 -0
- package/test/getMSDInformations.test.js +35 -0
- package/test/metadata-parsing-perf.test.js +400 -400
- package/test/mocks/MSD_TEST.json +484 -0
- package/test/parseMetadataSeries.test.js +13 -6
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getDataflowTooltipAttributesIds = 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 getDataflowTooltipAttributesIds = exports.getDataflowTooltipAttributesIds = function getDataflowTooltipAttributesIds(sdmxJson, defaults) {
|
|
15
|
+
var dataflowAnnotationsIndexes = R.pathOr([], ['data', 'dataSets', 0, 'annotations'], sdmxJson);
|
|
16
|
+
var dataflowAnnotations = R.props(dataflowAnnotationsIndexes, R.pathOr([], ['data', 'structure', 'annotations'], sdmxJson));
|
|
17
|
+
|
|
18
|
+
var flagsAttrAnnotation = R.find(R.propEq('type', 'LAYOUT_FLAG'), dataflowAnnotations);
|
|
19
|
+
var footnotesAttrAnnotation = R.find(R.propEq('type', 'LAYOUT_NOTE'), dataflowAnnotations);
|
|
20
|
+
|
|
21
|
+
return {
|
|
22
|
+
flags: R.isNil(flagsAttrAnnotation) ? defaults.flags : R.split(',', flagsAttrAnnotation.title),
|
|
23
|
+
footnotes: R.isNil(footnotesAttrAnnotation) ? defaults.footnotes : R.split(',', footnotesAttrAnnotation.title)
|
|
24
|
+
};
|
|
25
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getMSDInformations = 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 getMSDInformations = exports.getMSDInformations = function getMSDInformations(msdJson) {
|
|
25
|
+
var attributesDefinitions = R.pathOr([], ['data', 'metadataStructures', 0, 'metadataStructureComponents', 'reportStructures', 0, 'metadataAttributes'], msdJson);
|
|
26
|
+
|
|
27
|
+
var parseAttributes = function parseAttributes(parent) {
|
|
28
|
+
return R.reduce(function (acc, attribute) {
|
|
29
|
+
var id = attribute.id;
|
|
30
|
+
var format = R.path(['localRepresentation', 'textFormat', 'textType'], attribute);
|
|
31
|
+
if (R.has('metadataAttributes', attribute)) {
|
|
32
|
+
var collection = parseAttributes(attribute.id)(attribute.metadataAttributes);
|
|
33
|
+
return (0, _extends4.default)({}, acc, collection, (0, _defineProperty3.default)({}, id, { format: format, parent: parent }));
|
|
34
|
+
}
|
|
35
|
+
return R.assoc(id, { format: format, parent: parent }, acc);
|
|
36
|
+
}, {});
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
return { attributes: parseAttributes('#ROOT')(attributesDefinitions) };
|
|
40
|
+
};
|
|
@@ -13,13 +13,14 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
|
|
|
13
13
|
|
|
14
14
|
var dimensionValueDisplay = function dimensionValueDisplay(display) {
|
|
15
15
|
return function (data) {
|
|
16
|
+
var name = R.isNil(data.name) ? '[' + data.id + ']' : data.name;
|
|
16
17
|
if (display === 'code') {
|
|
17
18
|
return R.prop('id', data);
|
|
18
19
|
}
|
|
19
20
|
if (display === 'both') {
|
|
20
|
-
return R.prop('id', data) + ': ' +
|
|
21
|
+
return R.prop('id', data) + ': ' + name;
|
|
21
22
|
}
|
|
22
|
-
return
|
|
23
|
+
return name;
|
|
23
24
|
};
|
|
24
25
|
};
|
|
25
26
|
|
package/lib/rules2/src/index.js
CHANGED
|
@@ -44,4 +44,22 @@ Object.defineProperty(exports, 'sdmx_3_0_DataFormatPatch', {
|
|
|
44
44
|
get: function get() {
|
|
45
45
|
return _sdmx.sdmx_3_0_DataFormatPatch;
|
|
46
46
|
}
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
var _getDataflowTooltipAttributesIds = require('./getDataflowTooltipAttributesIds');
|
|
50
|
+
|
|
51
|
+
Object.defineProperty(exports, 'getDataflowTooltipAttributesIds', {
|
|
52
|
+
enumerable: true,
|
|
53
|
+
get: function get() {
|
|
54
|
+
return _getDataflowTooltipAttributesIds.getDataflowTooltipAttributesIds;
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
var _getMSDInformations = require('./getMSDInformations');
|
|
59
|
+
|
|
60
|
+
Object.defineProperty(exports, 'getMSDInformations', {
|
|
61
|
+
enumerable: true,
|
|
62
|
+
get: function get() {
|
|
63
|
+
return _getMSDInformations.getMSDInformations;
|
|
64
|
+
}
|
|
47
65
|
});
|
|
@@ -24,7 +24,7 @@ var dimensionValueDisplay = function dimensionValueDisplay(locale, display) {
|
|
|
24
24
|
return (0, _dotstatsuiteSdmxjs.getLocalisedName)(locale)(data);
|
|
25
25
|
};
|
|
26
26
|
};
|
|
27
|
-
// options = { locale, display, dimensions = [] };
|
|
27
|
+
// options = { locale, display, dimensions = [], attributes = { [id]: { format, parent } } };
|
|
28
28
|
var parseMetadataSeries = exports.parseMetadataSeries = function parseMetadataSeries(metadataJson, options) {
|
|
29
29
|
var metadataAttributes = R.pathOr([], ['data', 'structures', 0, 'attributes', 'dimensionGroup'], metadataJson);
|
|
30
30
|
var metaAttrLength = R.length(metadataAttributes);
|
|
@@ -71,7 +71,8 @@ var parseMetadataSeries = exports.parseMetadataSeries = function parseMetadataSe
|
|
|
71
71
|
return R.append({
|
|
72
72
|
id: attribute.id,
|
|
73
73
|
label: label,
|
|
74
|
-
value: R.is(Object, value) ? R.prop(options.locale, value) : value
|
|
74
|
+
value: R.is(Object, value) ? R.prop(options.locale, value) : value,
|
|
75
|
+
handlerProps: R.pathOr({}, ['attributes', attribute.id], options)
|
|
75
76
|
}, acc);
|
|
76
77
|
}, [], metaIndexes);
|
|
77
78
|
|
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": "12.1
|
|
4
|
+
"version": "12.2.1",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"author": "OECD",
|
|
7
7
|
"license": "MIT",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@react-hook/size": "^2.1.1",
|
|
25
|
-
"@sis-cc/dotstatsuite-d3-charts": "^8.0.
|
|
25
|
+
"@sis-cc/dotstatsuite-d3-charts": "^8.0.1",
|
|
26
26
|
"date-fns": "^1.30.1",
|
|
27
27
|
"lodash": "^4.17.2",
|
|
28
28
|
"lodash.compose": "^2.4.1",
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as R from 'ramda';
|
|
2
|
+
|
|
3
|
+
export const getDataflowTooltipAttributesIds = (sdmxJson, defaults) => {
|
|
4
|
+
const dataflowAnnotationsIndexes = R.pathOr([], ['data', 'dataSets', 0, 'annotations'], sdmxJson);
|
|
5
|
+
const dataflowAnnotations = R.props(dataflowAnnotationsIndexes, R.pathOr([], ['data', 'structure', 'annotations'], sdmxJson));
|
|
6
|
+
|
|
7
|
+
const flagsAttrAnnotation = R.find(R.propEq('type', 'LAYOUT_FLAG'), dataflowAnnotations);
|
|
8
|
+
const footnotesAttrAnnotation = R.find(R.propEq('type', 'LAYOUT_NOTE'), dataflowAnnotations);
|
|
9
|
+
|
|
10
|
+
return ({
|
|
11
|
+
flags: R.isNil(flagsAttrAnnotation) ? defaults.flags : R.split(',', flagsAttrAnnotation.title),
|
|
12
|
+
footnotes: R.isNil(footnotesAttrAnnotation) ? defaults.footnotes : R.split(',', footnotesAttrAnnotation.title),
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as R from 'ramda';
|
|
2
|
+
|
|
3
|
+
export const getMSDInformations = (msdJson) => {
|
|
4
|
+
const attributesDefinitions = R.pathOr([], ['data', 'metadataStructures', 0, 'metadataStructureComponents', 'reportStructures', 0, 'metadataAttributes'], msdJson);
|
|
5
|
+
|
|
6
|
+
const parseAttributes = (parent) => R.reduce(
|
|
7
|
+
(acc, attribute) => {
|
|
8
|
+
const id = attribute.id;
|
|
9
|
+
const format = R.path(['localRepresentation', 'textFormat', 'textType'], attribute);
|
|
10
|
+
if (R.has('metadataAttributes', attribute)) {
|
|
11
|
+
const collection = parseAttributes(attribute.id)(attribute.metadataAttributes);
|
|
12
|
+
return ({ ...acc, ...collection, [id]: { format, parent } });
|
|
13
|
+
}
|
|
14
|
+
return R.assoc(id, { format, parent }, acc);
|
|
15
|
+
},
|
|
16
|
+
{}
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
return ({ attributes: parseAttributes('#ROOT')(attributesDefinitions) });
|
|
20
|
+
};
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import * as R from 'ramda';
|
|
2
2
|
|
|
3
3
|
const dimensionValueDisplay = (display) => data => {
|
|
4
|
+
const name = R.isNil(data.name) ? `[${data.id}]` : data.name;
|
|
4
5
|
if (display === 'code') {
|
|
5
6
|
return R.prop('id', data);
|
|
6
7
|
}
|
|
7
8
|
if (display === 'both') {
|
|
8
|
-
return `${R.prop('id', data)}: ${
|
|
9
|
+
return `${R.prop('id', data)}: ${name}`;
|
|
9
10
|
}
|
|
10
|
-
return
|
|
11
|
+
return name;
|
|
11
12
|
};
|
|
12
13
|
|
|
13
14
|
const sortByCoordinates = (a, b) => {
|
package/src/rules2/src/index.js
CHANGED
|
@@ -6,3 +6,5 @@ export {
|
|
|
6
6
|
export { getSidebarData } from './getSidebarData';
|
|
7
7
|
export { parseMetadataSeries } from './parseMetadataSeries';
|
|
8
8
|
export { sdmx_3_0_DataFormatPatch } from './sdmx3.0DataFormatPatch';
|
|
9
|
+
export { getDataflowTooltipAttributesIds } from './getDataflowTooltipAttributesIds';
|
|
10
|
+
export { getMSDInformations } from './getMSDInformations';
|
|
@@ -10,7 +10,7 @@ const dimensionValueDisplay = (locale, display) => data => {
|
|
|
10
10
|
}
|
|
11
11
|
return getLocalisedName(locale)(data);
|
|
12
12
|
};
|
|
13
|
-
// options = { locale, display, dimensions = [] };
|
|
13
|
+
// options = { locale, display, dimensions = [], attributes = { [id]: { format, parent } } };
|
|
14
14
|
export const parseMetadataSeries = (metadataJson, options) => {
|
|
15
15
|
const metadataAttributes = R.pathOr([], ['data', 'structures', 0, 'attributes', 'dimensionGroup'], metadataJson);
|
|
16
16
|
const metaAttrLength = R.length(metadataAttributes);
|
|
@@ -63,7 +63,8 @@ export const parseMetadataSeries = (metadataJson, options) => {
|
|
|
63
63
|
return R.append({
|
|
64
64
|
id: attribute.id,
|
|
65
65
|
label,
|
|
66
|
-
value: R.is(Object, value) ? R.prop(options.locale, value) : value
|
|
66
|
+
value: R.is(Object, value) ? R.prop(options.locale, value) : value,
|
|
67
|
+
handlerProps: R.pathOr({}, ['attributes', attribute.id], options)
|
|
67
68
|
}, acc);
|
|
68
69
|
},
|
|
69
70
|
[],
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { expect } from 'chai';
|
|
2
|
+
import { getDataflowTooltipAttributesIds } from '../src/rules2/src';
|
|
3
|
+
|
|
4
|
+
const def = {
|
|
5
|
+
flags: ['f0', 'f1'],
|
|
6
|
+
footnotes: ['foot0', 'foot1']
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
describe('getDataflowTooltipAttributesIds tests', () => {
|
|
10
|
+
it('no override', () => {
|
|
11
|
+
const data = {
|
|
12
|
+
dataSets: [{
|
|
13
|
+
annotations: [0, 1]
|
|
14
|
+
}],
|
|
15
|
+
structure: {
|
|
16
|
+
annotations: [
|
|
17
|
+
{ id: 'annot0', title: 'test' },
|
|
18
|
+
{ id: 'annot1', title: 'test' },
|
|
19
|
+
{ id: 'annot2', title: 'test' },
|
|
20
|
+
]
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
expect(getDataflowTooltipAttributesIds({ data }, def)).to.deep.equal(def);
|
|
25
|
+
});
|
|
26
|
+
it('flags override', () => {
|
|
27
|
+
const data = {
|
|
28
|
+
dataSets: [{
|
|
29
|
+
annotations: [0, 1]
|
|
30
|
+
}],
|
|
31
|
+
structure: {
|
|
32
|
+
annotations: [
|
|
33
|
+
{ id: 'annot0', title: 'test' },
|
|
34
|
+
{ id: 'annot1', type: 'LAYOUT_FLAG', title: 'f2,f3' },
|
|
35
|
+
{ id: 'annot2', title: 'test' },
|
|
36
|
+
]
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
expect(getDataflowTooltipAttributesIds({ data }, def)).to.deep.equal({ flags: ['f2', 'f3'], footnotes: ['foot0', 'foot1'] });
|
|
41
|
+
});
|
|
42
|
+
it('footnotes override', () => {
|
|
43
|
+
const data = {
|
|
44
|
+
dataSets: [{
|
|
45
|
+
annotations: [0, 1]
|
|
46
|
+
}],
|
|
47
|
+
structure: {
|
|
48
|
+
annotations: [
|
|
49
|
+
{ id: 'annot0', title: 'test' },
|
|
50
|
+
{ id: 'annot1', type: 'LAYOUT_NOTE', title: 'foot2,foot3' },
|
|
51
|
+
{ id: 'annot2', title: 'test' },
|
|
52
|
+
]
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
expect(getDataflowTooltipAttributesIds({ data }, def)).to.deep.equal({ flags: ['f0', 'f1'], footnotes: ['foot2', 'foot3'] });
|
|
57
|
+
});
|
|
58
|
+
it('flags and footnotes override', () => {
|
|
59
|
+
const data = {
|
|
60
|
+
dataSets: [{
|
|
61
|
+
annotations: [0, 1]
|
|
62
|
+
}],
|
|
63
|
+
structure: {
|
|
64
|
+
annotations: [
|
|
65
|
+
{ id: 'annot0', type: 'LAYOUT_FLAG', title: 'f2,f3' },
|
|
66
|
+
{ id: 'annot1', type: 'LAYOUT_NOTE', title: 'foot2,foot3' },
|
|
67
|
+
{ id: 'annot2', title: 'test' },
|
|
68
|
+
]
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
expect(getDataflowTooltipAttributesIds({ data }, def)).to.deep.equal({ flags: ['f2', 'f3'], footnotes: ['foot2', 'foot3'] });
|
|
73
|
+
});
|
|
74
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { expect } from 'chai';
|
|
2
|
+
import { getMSDInformations } from '../src/rules2/src/getMSDInformations';
|
|
3
|
+
import msd from './mocks/MSD_TEST.json';
|
|
4
|
+
|
|
5
|
+
describe('getMSDInformations tests', () => {
|
|
6
|
+
it('complete test', () => {
|
|
7
|
+
const expected = {
|
|
8
|
+
attributes: {
|
|
9
|
+
STRING_TYPE: { format: 'String', parent: '#ROOT' },
|
|
10
|
+
STRING_MULTILANG_TYPE: { format: 'String', parent: '#ROOT' },
|
|
11
|
+
ALPHANUMERIC_TYPE: { format: 'AlphaNumeric', parent: '#ROOT' },
|
|
12
|
+
ALPHANUMERIC_MULTILANG_TYPE: { format: 'AlphaNumeric', parent: '#ROOT' },
|
|
13
|
+
BOOLEAN_TYPE: { format: 'Boolean', parent: '#ROOT' },
|
|
14
|
+
XHTML_TYPE: { format: 'XHTML', parent: '#ROOT' },
|
|
15
|
+
XHTML_MULTILANG_TYPE: { format: 'XHTML', parent: '#ROOT' },
|
|
16
|
+
INTEGER_TYPE: { format: 'Integer', parent: '#ROOT' },
|
|
17
|
+
INTEGER_MULTILANG_TYPE: { format: 'Integer', parent: '#ROOT' },
|
|
18
|
+
DECIMAL_TYPE: { format: 'Decimal', parent: '#ROOT' },
|
|
19
|
+
DECIMAL_MULTILANG_TYPE: { format: 'Decimal', parent: '#ROOT' },
|
|
20
|
+
DATETIME_TYPE: { format: 'DateTime', parent: '#ROOT' },
|
|
21
|
+
TIME_TYPE: { format: 'Time', parent: '#ROOT' },
|
|
22
|
+
GREGORIANDAY_TYPE: { format: 'GregorianDay', parent: '#ROOT' },
|
|
23
|
+
GREGORIAN_YEAR_TYPE: { format: 'GregorianYear', parent: '#ROOT' },
|
|
24
|
+
GREGORIAN_YEARMONTH_TYPE: { format: 'GregorianYearMonth', parent: '#ROOT' },
|
|
25
|
+
CONTACT: { format: 'String', parent: '#ROOT' },
|
|
26
|
+
CONTACT_NAME: { format: 'String', parent: 'CONTACT' },
|
|
27
|
+
CONTACT_EMAIL: { format: 'String', parent: 'CONTACT' },
|
|
28
|
+
CONTACT_PHONE: { format: 'Numeric', parent: 'CONTACT' },
|
|
29
|
+
CONTACT_ORGANISATION: { format: 'String', parent: 'CONTACT' }
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
expect(getMSDInformations(msd)).to.deep.equal(expected);
|
|
34
|
+
});
|
|
35
|
+
});
|