@sis-cc/dotstatsuite-components 9.1.2 → 9.2.2

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 (77) hide show
  1. package/lib/rules/src/preparators/enhanceObservations.js +155 -0
  2. package/lib/rules/src/preparators/formatValue.js +77 -0
  3. package/lib/rules/src/preparators/getDimensions.js +55 -0
  4. package/lib/rules/src/preparators/getDisplay.js +32 -0
  5. package/lib/rules/src/preparators/getObservations.js +27 -0
  6. package/lib/rules/src/table/factories/getCells.js +1 -3
  7. package/lib/rules/src/table/factories/getLayoutData.js +118 -159
  8. package/lib/rules/src/table/factories/getSortedLayoutIndexes.js +118 -0
  9. package/lib/rules/src/table/factories/getTableData.js +12 -10
  10. package/lib/rules/src/table/factories/refineLayoutSize.js +210 -0
  11. package/lib/rules/src/table/preparators/prepareData.js +23 -23
  12. package/lib/rules/src/table/units/getAttachmentSeriesIndexes.js +1 -1
  13. package/lib/rules/src/table/units/getUnitsSeries.js +31 -0
  14. package/lib/rules/src/v8-transformer.js +2 -1
  15. package/package.json +2 -2
  16. package/src/rules/src/preparators/enhanceObservations.js +163 -0
  17. package/src/rules/src/preparators/formatValue.js +73 -0
  18. package/src/rules/src/preparators/getDimensions.js +49 -0
  19. package/src/rules/src/preparators/getDisplay.js +20 -0
  20. package/src/rules/src/preparators/getObservations.js +19 -0
  21. package/src/rules/src/table/factories/getCells.js +3 -7
  22. package/src/rules/src/table/factories/getLayoutData.js +150 -184
  23. package/src/rules/src/table/factories/getSortedLayoutIndexes.js +108 -0
  24. package/src/rules/src/table/factories/getTableData.js +10 -10
  25. package/src/rules/src/table/factories/refineLayoutSize.js +224 -0
  26. package/src/rules/src/table/preparators/prepareData.js +23 -32
  27. package/src/rules/src/table/units/getAttachmentSeriesIndexes.js +2 -1
  28. package/src/rules/src/table/units/getUnitsSeries.js +20 -0
  29. package/src/rules/src/v8-transformer.js +2 -1
  30. package/test/appendUnitsInLayoutDataEntry.test.js +3 -3
  31. package/test/enhanceObservations.test.js +270 -0
  32. package/test/getAttachmentSeriesIndexes.test.js +1 -1
  33. package/test/getCells.test.js +4 -39
  34. package/test/getLayoutData.test.js +193 -298
  35. package/test/getOneValueDimensions.test.js +1 -1
  36. package/test/getSortedLayoutIndexes.test.js +80 -0
  37. package/test/getUnitsArtefacts.test.js +1 -1
  38. package/test/getUnitsSeries.test.js +64 -0
  39. package/test/mocks/table-layout-multi-hierarchies--layout.json +621 -0
  40. package/test/mocks/table-layout-multi-hierarchies--layoutData.json +32410 -0
  41. package/test/mocks/table-layout-multi-hierarchies--layoutIndexes.json +2760 -0
  42. package/test/mocks/table-layout-multi-hierarchies--observations.json +30688 -0
  43. package/test/mocks/table-layout-multi-hierarchies--sizedIndexes.json +2761 -0
  44. package/test/mocks/table-layout-truncation1--layout.json +27469 -0
  45. package/test/mocks/table-layout-truncation1--layoutData.json +20357 -0
  46. package/test/mocks/table-layout-truncation1--layoutIndexes.json +7512 -0
  47. package/test/mocks/table-layout-truncation1--observations.json +70002 -0
  48. package/test/mocks/table-layout-truncation1--sizedIndexes.json +3010 -0
  49. package/test/mocks/table-prep-multi-hierarchies--attributes.json +44 -0
  50. package/test/mocks/table-prep-multi-hierarchies--dimensions.json +688 -0
  51. package/test/mocks/table-prep-multi-hierarchies--enhancedObservations.json +19696 -0
  52. package/test/mocks/table-prep-multi-hierarchies--observations.json +8246 -0
  53. package/test/mocks/table-prep-multi-hierarchies--sdmxJson.json +2985 -0
  54. package/test/mocks/table-prep-truncation1--dimensions.json +35057 -0
  55. package/test/mocks/table-prep-truncation1--enhancedObservations.json +70002 -0
  56. package/test/mocks/table-prep-truncation1--observations.json +27502 -0
  57. package/test/mocks/table-prep-truncation1--sdmxJson.json +55103 -0
  58. package/test/mocks/table-prep-units--observations.json +284286 -0
  59. package/test/mocks/table-prep-units--unitsSeries.json +41042 -0
  60. package/test/parseAttributes.test.js +1 -1
  61. package/test/refineLayoutSize.test.js +415 -0
  62. package/test/table-layout-perf.test.js +74 -0
  63. package/test/table-prep-perf.test.js +65 -0
  64. package/lib/rules/src/table/factories/getSortedLayoutData.js +0 -145
  65. package/lib/rules/src/table/factories/refineLayoutHierarchy.js +0 -61
  66. package/lib/rules/src/table/preparators/parseObservations.js +0 -76
  67. package/lib/rules/src/table/units/getUnitsSeriesOccurences.js +0 -39
  68. package/src/rules/src/table/factories/getSortedLayoutData.js +0 -133
  69. package/src/rules/src/table/factories/refineLayoutHierarchy.js +0 -64
  70. package/src/rules/src/table/preparators/parseObservations.js +0 -81
  71. package/src/rules/src/table/units/getUnitsSeriesOccurences.js +0 -51
  72. package/test/appendUnitsInLayoutData.test.js +0 -248
  73. package/test/getSortedLayoutData.test.js +0 -382
  74. package/test/getUnitsSeriesOccurences.test.js +0 -133
  75. package/test/parseObservations.test.js +0 -116
  76. package/test/refineDimSeriesUnits.test.js +0 -24
  77. package/test/refineLayoutHierarchy.test.js +0 -79
@@ -1,133 +0,0 @@
1
- import { expect } from 'chai';
2
- import { getUnitsSeriesOccurences } from '../src/rules/src/table/units/getUnitsSeriesOccurences';
3
- import { intersection } from 'ramda';
4
-
5
-
6
- const attachmentSeriesIndexes = [0, 1];
7
- const observations = {
8
- 0: {
9
- dimValuesIndexes: ['0', '0', '0', '0'],
10
- attrValuesIndexes: ['0', null, '0'],
11
- key: '0:0:0:0',
12
- units: {
13
- A: { value: { index: 0 } },
14
- B: { value: { index: 0 } },
15
- C: { value: { index: 0 } }
16
- }
17
- },
18
- 1: {
19
- dimValuesIndexes: ['0', '0', '1', '0'],
20
- attrValuesIndexes: ['0', null, '1'],
21
- key: '0:0:1:0',
22
- units: {
23
- A: { value: { index: 0 } },
24
- B: { value: { index: 0 } },
25
- C: { value: { index: 1 } }
26
- }
27
- },
28
- 2: {
29
- dimValuesIndexes: ['1', '0', '0', '0'],
30
- attrValuesIndexes: ['1', null, '0'],
31
- key: '1:0:0:0',
32
- units: {
33
- A: { value: { index: 1 } },
34
- B: { value: { index: 1 } },
35
- C: { value: { index: 0 } }
36
- }
37
- },
38
- 3: {
39
- dimValuesIndexes: ['1', '0', '1', '0'],
40
- attrValuesIndexes: ['1', null, '0'],
41
- key: '1:0:1:0',
42
- units: {
43
- A: { value: { index: 1 } },
44
- B: { value: { index: 1 } },
45
- C: { value: { index: 0 } }
46
- }
47
- },
48
- 4: {
49
- dimValuesIndexes: ['2', '0', '0', '0'],
50
- attrValuesIndexes: ['0', null, '0'],
51
- key: '2:0:0:0',
52
- units: {
53
- A: { value: { index: 2 } },
54
- B: { value: { index: 0 } },
55
- C: { value: { index: 0 } }
56
- }
57
- }
58
- };
59
-
60
- describe('getUnitsSeriesOccurences tests', () => {
61
- it('blank test', () => {
62
- expect(getUnitsSeriesOccurences({
63
- attachmentSeriesIndexes: []
64
- })({})).to.deep.equal({ rawUnitsSeries: {}, obs: {} });
65
- });
66
- it('basic test', () => {
67
- expect(getUnitsSeriesOccurences({ attachmentSeriesIndexes })(observations))
68
- .to.deep.equal({
69
- rawUnitsSeries: {
70
- '0:0:x:x': { A: [0, 0], B: [0, 0], C: [0, 1], observations: 2 },
71
- '1:0:x:x': { A: [1, 1], B: [1, 1], C: [0, 0], observations: 2 },
72
- '2:0:x:x': { A: [2], B: [0], C: [0], observations: 1 }
73
- },
74
- obs: {
75
- '0:0:0:0': {
76
- dimValuesIndexes: ['0', '0', '0', '0'],
77
- attrValuesIndexes: ['0', null, '0'],
78
- key: '0:0:0:0',
79
- units: {
80
- A: { value: { index: 0 } },
81
- B: { value: { index: 0 } },
82
- C: { value: { index: 0 } },
83
- serieKey: '0:0:x:x'
84
- }
85
- },
86
- '0:0:1:0': {
87
- dimValuesIndexes: ['0', '0', '1', '0'],
88
- attrValuesIndexes: ['0', null, '1'],
89
- key: '0:0:1:0',
90
- units: {
91
- A: { value: { index: 0 } },
92
- B: { value: { index: 0 } },
93
- C: { value: { index: 1 } },
94
- serieKey: '0:0:x:x'
95
- }
96
- },
97
- '1:0:0:0': {
98
- dimValuesIndexes: ['1', '0', '0', '0'],
99
- attrValuesIndexes: ['1', null, '0'],
100
- key: '1:0:0:0',
101
- units: {
102
- A: { value: { index: 1 } },
103
- B: { value: { index: 1 } },
104
- C: { value: { index: 0 } },
105
- serieKey: '1:0:x:x'
106
- }
107
- },
108
- '1:0:1:0': {
109
- dimValuesIndexes: ['1', '0', '1', '0'],
110
- attrValuesIndexes: ['1', null, '0'],
111
- key: '1:0:1:0',
112
- units: {
113
- A: { value: { index: 1 } },
114
- B: { value: { index: 1 } },
115
- C: { value: { index: 0 } },
116
- serieKey: '1:0:x:x'
117
- }
118
- },
119
- '2:0:0:0': {
120
- dimValuesIndexes: ['2', '0', '0', '0'],
121
- attrValuesIndexes: ['0', null, '0'],
122
- key: '2:0:0:0',
123
- units: {
124
- A: { value: { index: 2 } },
125
- B: { value: { index: 0 } },
126
- C: { value: { index: 0 } },
127
- serieKey: '2:0:x:x'
128
- }
129
- }
130
- }
131
- })
132
- });
133
- });
@@ -1,116 +0,0 @@
1
- import { expect } from 'chai';
2
- import { parseObservations } from '../src/rules/src/table/preparators/parseObservations';
3
- import { getDisplay } from '../src/rules/src/table/preparators/getDisplay';
4
-
5
- const observationsAttributes = {
6
- a: { index: 0, values: [{ id: 'a0' }, { id: 'a1' }] },
7
- b: { index: 1, id: 'b', name: 'B', values: [{ id: 'b0' }] },
8
- };
9
-
10
- const formatAttributes = {
11
- f1: { index: 2 },
12
- f2: { index: 3, values: [{ id: 'f2.1' }, null] },
13
- };
14
-
15
-
16
- const dimensions = [
17
- { id: 'd0', values: [{ id: 'v0', __index: 0 }, { id: 'v1', __index: 1 }, { id: 'v2', __index: 2 }, { id: 'v3', __index: 3 }] },
18
- { id: 'd1', values: [{ id: 'v0', __index: 0 }] },
19
- { id: 'd2', values: [{ id: 'v0', __index: 0 }] },
20
- { id: 'd3', values: [{ id: 'v0', __index: 0 }, { id: 'v1', __index: 1 }] },
21
- { id: 'd4', values: [{ id: 'v0', __index: 0 }] },
22
- ];
23
-
24
- const observations = {
25
- '0:0:0:0:0': [22, 0, 0, 0, 0, 0],
26
- '0:0:0:1:0': [17, 1, 0, 1, 1, 0],
27
- '1:0:0:0:0': [55, 2, 0, null, null, 0],
28
- '2:0:0:0:0': [35, 2, 0, null, null, null],
29
- '3:0:0:0:0': [35, 2, 0, null, null, null],
30
- };
31
-
32
- const unitsArtefacts = {
33
- dimensions: { series: { D0: { id: 'D0', index: 0, values: [{ id: 'V0' }, { id: 'V1' }, { id: 'V2' }, { id: 'V3' }] } } },
34
- attributes: { series: { A4: { id: 'A4', index: 4, values: [{ id: 'V0' }] } } }
35
- };
36
-
37
- describe('parseObservations test', () => {
38
- it('complete case', () => {
39
- expect(parseObservations(
40
- observations,
41
- dimensions,
42
- observationsAttributes,
43
- formatAttributes,
44
- unitsArtefacts,
45
- getDisplay({ noDisplayIndexes: [], notDisplayedCodes: { D0: { values: { V3: 'V3' } } } })
46
- )).to.deep.equal({
47
- '0:0:0:0:0': {
48
- key: '0:0:0:0:0',
49
- value: 22,
50
- units: { D0: { id: 'D0', value: { id: 'V0', index: 0 } }, A4: { id: 'A4', value: { id: 'V0', index: 0 } } },
51
- attrValuesIndexes: [0, 0, 0, 0, 0],
52
- dimValuesIndexes: ['0', '0', '0', '0', '0'],
53
- indexedDimValIds: { d0: 'v0', d1: 'v0', d2: 'v0', d3: 'v0', d4: 'v0', },
54
- attributes: {
55
- a: { value: { id: 'a0' } },
56
- b: { id: 'b', name: 'B', value: { id: 'b0' } }
57
- },
58
- f1: null,
59
- f2: 'f2.1'
60
- },
61
- '0:0:0:1:0': {
62
- key: '0:0:0:1:0',
63
- value: 17,
64
- units: { D0: { id: 'D0', value: { id: 'V0', index: 0 } }, A4: { id: 'A4', value: { id: 'V0', index: 0 } } },
65
- attrValuesIndexes: [1, 0, 1, 1, 0],
66
- dimValuesIndexes: ['0', '0', '0', '1', '0'],
67
- indexedDimValIds: { d0: 'v0', d1: 'v0', d2: 'v0', d3: 'v1', d4: 'v0', },
68
- attributes: {
69
- a: { value: { id: 'a1' } },
70
- b: { id: 'b', name: 'B', value: { id: 'b0' } }
71
- },
72
- f1: null,
73
- f2: null
74
- },
75
- '1:0:0:0:0': {
76
- key: '1:0:0:0:0',
77
- value: 55,
78
- units: { D0: { id: 'D0', value: { id: 'V1', index: 1 } }, A4: { id: 'A4', value: { id: 'V0', index: 0 } } },
79
- attrValuesIndexes: [2, 0, null, null, 0],
80
- dimValuesIndexes: ['1', '0', '0', '0', '0'],
81
- indexedDimValIds: { d0: 'v1', d1: 'v0', d2: 'v0', d3: 'v0', d4: 'v0', },
82
- attributes: {
83
- b: { id: 'b', name: 'B', value: { id: 'b0' } }
84
- },
85
- f1: null,
86
- f2: null
87
- },
88
- '2:0:0:0:0': {
89
- key: '2:0:0:0:0',
90
- value: 35,
91
- units: { D0: { id: 'D0', value: { id: 'V2', index: 2 } }, A4: null },
92
- attrValuesIndexes: [2, 0, null, null, null],
93
- dimValuesIndexes: ['2', '0', '0', '0', '0'],
94
- indexedDimValIds: { d0: 'v2', d1: 'v0', d2: 'v0', d3: 'v0', d4: 'v0', },
95
- attributes: {
96
- b: { id: 'b', name: 'B', value: { id: 'b0' } }
97
- },
98
- f1: null,
99
- f2: null,
100
- },
101
- '3:0:0:0:0': {
102
- key: '3:0:0:0:0',
103
- value: 35,
104
- units: { D0: null, A4: null },
105
- attrValuesIndexes: [2, 0, null, null, null],
106
- dimValuesIndexes: ['3', '0', '0', '0', '0'],
107
- indexedDimValIds: { d0: 'v3', d1: 'v0', d2: 'v0', d3: 'v0', d4: 'v0', },
108
- attributes: {
109
- b: { id: 'b', name: 'B', value: { id: 'b0' } }
110
- },
111
- f1: null,
112
- f2: null
113
- }
114
- });
115
- });
116
- });
@@ -1,24 +0,0 @@
1
- import { expect } from 'chai';
2
- import { refineDimSeriesUnits } from '../src/rules/src/table/units/refineDimSeriesUnits';
3
-
4
- describe('refineDimSeriesUnits tests', () => {
5
- it('blank test', () => {
6
- expect(refineDimSeriesUnits({})({})).to.deep.equal({});
7
- });
8
- it('complete test', () => {
9
- expect(refineDimSeriesUnits({
10
- unitsArtefacts: {
11
- A: { id: 'A', name: 'a', values: [{ id: 'a1' }] },
12
- B: { id: 'B', name: 'b', values: [{ id: 'b1' }, { id: 'b2' }] },
13
- C: { id: 'C', name: 'c', values: [{ id: 'c1' }, { id: 'c2' }] },
14
- },
15
- rejectedValueIds: ['b1', 'c2']
16
- })({
17
- s1: { observations: 3, A: [0, 0], B: [0, 1, 0], C: [0, 0, 0] },
18
- s2: { observations: 2, A: [0, 0], B: [0, 0], C: [2, 2] }
19
- })).to.deep.equal({
20
- s1: { C: { id: 'C', name: 'c', value: { id: 'c1' } } },
21
- s2: { A: { id: 'A', name: 'a', value: { id: 'a1' } } }
22
- });
23
- });
24
- });
@@ -1,79 +0,0 @@
1
- import { expect } from 'chai';
2
- import { refineLayoutHierarchy } from '../src/rules/src/table/factories/refineLayoutHierarchy';
3
-
4
- const values = [
5
- { id: '1', name: '1', parents: [] },
6
- { id: '1.1', name: '1.1', parents: ['1'] },
7
- { id: '1.1.1', name: '1.1.1', parents: ['1', '1.1'] },
8
- { id: '1.1.1.1', name: '1.1.1.1', parents: ['1', '1.1', '1.1.1'] },
9
- { id: '2', name: '2', parents: [] },
10
- { id: '3', name: '3', parents: [] }
11
- ];
12
-
13
- describe('refineLayoutHierarchy tests', () => {
14
- it('one missing parent', () => {
15
- const sections = [[[], [
16
- [{}, {}, { value: values[0] }],
17
- [{}, {}, { value: values[2] }],
18
- [{}, {}, { value: values[3] }],
19
- [{}, {}, { value: values[4] }],
20
- [{}, {}, { value: values[5] }],
21
- ]]];
22
- expect(refineLayoutHierarchy(sections, { values })).to.deep.equal([[[], [
23
- [{}, {}, { value: values[0] }],
24
- [{}, {}, { value: { id: '1.1.1', name: '1.1 > 1.1.1', parents: ['1'] } }],
25
- [{}, {}, { value: { id: '1.1.1.1', name: '1.1.1.1', parents: ['1', '1.1.1'] } }],
26
- [{}, {}, { value: values[4] }],
27
- [{}, {}, { value: values[5] }],
28
- ]]]);
29
- });
30
- it('many missing parents consecutives', () => {
31
- const sections = [[[], [
32
- [{}, {}, { value: values[0] }],
33
- [{}, {}, { value: values[3] }],
34
- [{}, {}, { value: values[4] }],
35
- [{}, {}, { value: values[5] }],
36
- ]]];
37
- expect(refineLayoutHierarchy(sections, { values })).to.deep.equal([[[], [
38
- [{}, {}, { value: values[0] }],
39
- [{}, {}, { value: { id: '1.1.1.1', name: '1.1 > 1.1.1 > 1.1.1.1', parents: ['1'] } }],
40
- [{}, {}, { value: values[4] }],
41
- [{}, {}, { value: values[5] }],
42
- ]]]);
43
- });
44
- it('holes in the tree', () => {
45
- const sections = [[[], [
46
- [{}, {}, { value: values[1] }],
47
- [{}, {}, { value: values[3] }],
48
- [{}, {}, { value: values[4] }],
49
- [{}, {}, { value: values[5] }],
50
- ]]];
51
- expect(refineLayoutHierarchy(sections, { values })).to.deep.equal([[[], [
52
- [{}, {}, { value: { id: '1.1', name: '1 > 1.1', parents: [] } }],
53
- [{}, {}, { value: { id: '1.1.1.1', name: '1.1.1 > 1.1.1.1', parents: ['1.1'] } }],
54
- [{}, {}, { value: values[4] }],
55
- [{}, {}, { value: values[5] }],
56
- ]]]);
57
- });
58
- it('no missing parents', () => {
59
- const sections = [[[], [
60
- [{}, {}, { value: values[0] }],
61
- [{}, {}, { value: values[1] }],
62
- [{}, {}, { value: values[2] }],
63
- [{}, {}, { value: values[3] }],
64
- [{}, {}, { value: values[4] }],
65
- [{}, {}, { value: values[5] }],
66
- ]]];
67
- expect(refineLayoutHierarchy(sections, { values })).to.deep.equal(sections);
68
- });
69
- it('no hierarchy', () => {
70
- const values = [{ id: '1' }, { id: '2' }, { id: '3' }, { id: '4' }];
71
- const sections = [[[], [
72
- [{}, {}, {}, {}, { value: values[0] }],
73
- [{}, {}, {}, {}, { value: values[1] }],
74
- [{}, {}, {}, {}, { value: values[2] }],
75
- [{}, {}, {}, {}, { value: values[3] }],
76
- ]]];
77
- expect(refineLayoutHierarchy(sections, { values })).to.deep.equal(sections);
78
- });
79
- });