@sis-cc/dotstatsuite-components 13.0.4 → 13.3.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 (51) hide show
  1. package/lib/rules/src/factories/timeline-series.js +0 -26
  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 +46 -37
  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/rules2/src/parseMetadataSeries.js +5 -4
  13. package/lib/viewer/src/index.js +5 -3
  14. package/package.json +2 -2
  15. package/src/rules/src/factories/choro-series.js +1 -1
  16. package/src/rules/src/factories/timeline-series.js +1 -40
  17. package/src/rules/src/preparators/enhanceObservations.js +4 -7
  18. package/src/rules/src/properties/getHeaderProps.js +1 -2
  19. package/src/rules/src/properties/scatter.js +0 -1
  20. package/src/rules/src/sdmx-data/index.js +4 -4
  21. package/src/rules/src/table/preparators/getOneValueDimensions.js +4 -22
  22. package/src/rules/src/table/preparators/parseAttributes.js +3 -3
  23. package/src/rules/src/table/preparators/prepareData.js +3 -21
  24. package/src/rules/src/table/units/getUnitsArtefacts.js +6 -6
  25. package/src/rules/src/v8-transformer.js +57 -47
  26. package/src/rules2/src/getNotDisplayedIds.js +40 -0
  27. package/src/rules2/src/getSidebarData.js +41 -23
  28. package/src/rules2/src/index.js +1 -0
  29. package/src/rules2/src/parseMetadataSeries.js +6 -5
  30. package/src/viewer/src/index.js +7 -7
  31. package/test/enhanceObservations.test.js +2 -2
  32. package/test/getNotDisplayedIds.test.js +31 -0
  33. package/test/getOneValueDimensions.test.js +12 -17
  34. package/test/getSidebarData.test.js +104 -0
  35. package/test/getUnitsArtefacts.test.js +10 -14
  36. package/test/mocks/large_metadata_series.json +20 -20
  37. package/test/mocks/table-prep-multi-hierarchies--attributes.json +2 -0
  38. package/test/parseAttributes.test.js +4 -9
  39. package/test/table-prep-perf.test.js +0 -7
  40. package/lib/rules/src/preparators/getDimensions.js +0 -55
  41. package/lib/rules/src/preparators/getDisplay.js +0 -32
  42. package/lib/rules/src/table/preparators/getDisplay.js +0 -32
  43. package/lib/rules/src/table/preparators/getNoDisplayAnnotationsIndexes.js +0 -16
  44. package/lib/rules/src/table/preparators/getNoDisplayCodes.js +0 -32
  45. package/src/rules/src/preparators/getDimensions.js +0 -49
  46. package/src/rules/src/preparators/getDisplay.js +0 -20
  47. package/src/rules/src/table/preparators/getDisplay.js +0 -20
  48. package/src/rules/src/table/preparators/getNoDisplayAnnotationsIndexes.js +0 -9
  49. package/src/rules/src/table/preparators/getNoDisplayCodes.js +0 -32
  50. package/test/getNoDisplayAnnotationsIndexes.test.js +0 -18
  51. package/test/getNoDisplayCodes.test.js +0 -87
@@ -1,55 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getDimensions = exports.isDisplayedFromOwnAnnotations = 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 _dotstatsuiteSdmxjs = require('@sis-cc/dotstatsuite-sdmxjs');
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 isDisplayedFromOwnAnnotations = exports.isDisplayedFromOwnAnnotations = function isDisplayedFromOwnAnnotations(artefact) {
23
- var artefactAnnotations = R.propOr([], 'annotations', artefact);
24
- return R.pipe(R.propOr([], 'annotations'), R.find(R.propEq('type', 'NOT_DISPLAYED')), R.isNil)(artefact);
25
- };
26
-
27
- // sdmxJson
28
-
29
- var getDimensions = exports.getDimensions = function getDimensions(sdmxJson) {
30
- var annotations = R.pathOr([], ['data', 'structure', 'annotations'], sdmxJson);
31
- var locale = R.path([], ['meta', 'contentLanguage'], sdmxJson);
32
-
33
- var enhanceValues = R.addIndex(R.map)(function (val, __index) {
34
- var annotationsIndexes = R.propOr([], 'annotations', val);
35
- var valueAnnotations = R.props(annotationsIndexes, annotations);
36
-
37
- return (0, _extends3.default)({}, value, {
38
- __index: __index,
39
- annotations: valueAnnotations,
40
- name: R.pathOr('[' + val.id + ']', ['names', locale], val)
41
- });
42
- });
43
-
44
- return R.pipe(R.pathOr([], ['data', 'structure', 'dimensions']), R.addIndex(R.map)(function (dimension, __index) {
45
- var annotationsIndexes = R.propOr([], 'annotations', dimension);
46
- var dimensionAnnotations = R.props(annotationsIndexes, annotations);
47
-
48
- return (0, _extends3.default)({}, dimension, {
49
- __index: __index,
50
- name: R.pathOr('[' + val.id + ']', ['names', locale], val),
51
- annotations: dimensionAnnotations,
52
- values: enhanceValues(R.propOr([], 'values', dimension))
53
- });
54
- }))(sdmxJson);
55
- };
@@ -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,49 +0,0 @@
1
- import * as R from 'ramda';
2
- import {
3
- getCodeOrder,
4
- isTimePeriodDimension
5
- } from '@sis-cc/dotstatsuite-sdmxjs';
6
-
7
- export const isDisplayedFromOwnAnnotations = artefact => {
8
- const artefactAnnotations = R.propOr([], 'annotations', artefact);
9
- return R.pipe(
10
- R.propOr([], 'annotations'),
11
- R.find(R.propEq('type', 'NOT_DISPLAYED')),
12
- R.isNil
13
- )(artefact);
14
- };
15
-
16
- // sdmxJson
17
-
18
- export const getDimensions = sdmxJson => {
19
- const annotations = R.pathOr([], ['data', 'structure', 'annotations'], sdmxJson);
20
- const locale = R.path([], ['meta', 'contentLanguage'], sdmxJson);
21
-
22
- const enhanceValues = R.addIndex(R.map)((val, __index) => {
23
- const annotationsIndexes = R.propOr([], 'annotations', val);
24
- const valueAnnotations = R.props(annotationsIndexes, annotations);
25
-
26
- return ({
27
- ...value,
28
- __index,
29
- annotations: valueAnnotations,
30
- name: R.pathOr(`[${val.id}]`, ['names', locale], val),
31
- });
32
- });
33
-
34
- return R.pipe(
35
- R.pathOr([], ['data', 'structure', 'dimensions']),
36
- R.addIndex(R.map)((dimension, __index) => {
37
- const annotationsIndexes = R.propOr([], 'annotations', dimension);
38
- const dimensionAnnotations = R.props(annotationsIndexes, annotations);
39
-
40
- return ({
41
- ...dimension,
42
- __index,
43
- name: R.pathOr(`[${val.id}]`, ['names', locale], val),
44
- annotations: dimensionAnnotations,
45
- values: enhanceValues(R.propOr([], 'values', dimension))
46
- });
47
- })
48
- )(sdmxJson);
49
- };
@@ -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
- });