@sis-cc/dotstatsuite-components 17.12.5 → 17.13.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 (31) hide show
  1. package/lib/rules2/src/{hierarchiseDimensionWithAdvancedHierarchy.js → hierarchiseDimensionWithAdvancedHierarchy2.js} +22 -17
  2. package/lib/rules2/src/{hierarchiseDimensionWithNativeHierarchy.js → hierarchiseDimensionWithNativeHierarchy2.js} +10 -5
  3. package/lib/rules2/src/index.js +21 -12
  4. package/lib/rules2/src/parseCombinations.js +26 -3
  5. package/lib/rules2/src/prepareData.js +2 -2
  6. package/lib/rules2/src/refineDimensions.js +3 -6
  7. package/lib/rules2/src/table/getLayoutData2.js +218 -0
  8. package/lib/rules2/src/table/getTableProps.js +6 -9
  9. package/lib/rules2/src/table/parseSeriesIndexesHierarchies.js +96 -0
  10. package/lib/rules2/src/table/{refineLayoutSize.js → refineLayoutSize2.js} +53 -34
  11. package/package.json +1 -1
  12. package/src/rules2/src/{hierarchiseDimensionWithAdvancedHierarchy.js → hierarchiseDimensionWithAdvancedHierarchy2.js} +24 -23
  13. package/src/rules2/src/{hierarchiseDimensionWithNativeHierarchy.js → hierarchiseDimensionWithNativeHierarchy2.js} +31 -28
  14. package/src/rules2/src/index.js +5 -5
  15. package/src/rules2/src/parseCombinations.js +84 -42
  16. package/src/rules2/src/prepareData.js +2 -2
  17. package/src/rules2/src/refineDimensions.js +3 -6
  18. package/src/rules2/src/table/getLayoutData2.js +175 -0
  19. package/src/rules2/src/table/getTableProps.js +8 -4
  20. package/src/rules2/src/table/parseSeriesIndexesHierarchies.js +62 -0
  21. package/src/rules2/src/table/{refineLayoutSize.js → refineLayoutSize2.js} +50 -21
  22. package/test/getLayoutData2.test.js +268 -0
  23. package/test/{hierarchiseDimensionWithAdvancedHierarchy.test.js → hierarchiseDimensionWithAdvancedHierarchy2.test.js} +34 -69
  24. package/test/{hierarchiseDimensionWithNativeHierarchy.test.js → hierarchiseDimensionWithNativeHierarchy2.test.js} +14 -14
  25. package/test/parseCombinations.test.js +134 -20
  26. package/test/parseSeriesIndexesHierarchies.test.js +104 -0
  27. package/test/{refineLayoutSize.test.js → refineLayoutSize2.test.js} +63 -64
  28. package/test/refinedDimensions.test.js +8 -8
  29. package/lib/rules2/src/table/getLayoutData.js +0 -209
  30. package/src/rules2/src/table/getLayoutData.js +0 -193
  31. package/test/getLayoutData.test.js +0 -284
@@ -1,284 +0,0 @@
1
- import { expect } from 'chai';
2
- import { getLayoutData } from '../src/rules2/src/';
3
-
4
- describe('getLayoutData tests', () => {
5
- it('basic case with combination', () => {
6
- const layout = {
7
- header: [],
8
- sections: [{ id: 'S', values: [{ id: 'S_V1' }, { id: 'S_V2' }] }],
9
- rows: [{
10
- id: 'COMB',
11
- concepts: ['R1', 'R2', 'ATTR'],
12
- dimensions: [
13
- { id: 'R1', values: [{ id: 'R1_V1' }, { id: 'R1_V2' }] },
14
- { id: 'R2', values: [{ id: 'R2_V1' }, { id: 'R2_V2', display: false }] },
15
- ]
16
- }]
17
- };
18
-
19
- const attributesSeries = {
20
- 'R1=R1_V1:R2=R2_V1': {
21
- ATTR: { id: 'ATTR', value: { id: 'ATTR_V1' }, coordinates: { R1: 'R1_V1', R2: 'R2_V1' } },
22
- },
23
- 'R1=R1_V1:R2=R2_V2': {
24
- ATTR: { id: 'ATTR', value: { id: 'ATTR_V2' }, coordinates: { R1: 'R1_V1', R2: 'R2_V2' } },
25
- },
26
- 'R1=R1_V2:R2=R2_V1': {
27
- ATTR: { id: 'ATTR', value: { id: 'ATTR_V3' }, coordinates: { R1: 'R1_V2', R2: 'R2_V1' } },
28
- },
29
- 'R1=R1_V2:R2=R2_V2': {
30
- ATTR: { id: 'ATTR', value: { id: 'ATTR_V4' }, coordinates: { R1: 'R1_V2', R2: 'R2_V2' } },
31
- },
32
- };
33
-
34
- const layoutIndexes = {
35
- header: [],
36
- sections: [
37
- [
38
- [0],
39
- [
40
- [[0, 0]],
41
- [[0, 1]],
42
- [[1, 0]],
43
- [[1, 1]],
44
- ]
45
- ],
46
- [
47
- [1],
48
- [
49
- [[0, 0]],
50
- [[0, 1]],
51
- [[1, 0]],
52
- [[1, 1]],
53
- ]
54
- ]
55
- ]
56
- };
57
-
58
- expect(getLayoutData(layoutIndexes, layout, { attributesSeries, metadataCoordinates: [], customAttributes: { flags: [], notes: [] } })).to.deep.equal({
59
- headerData: [],
60
- sectionsData: [
61
- [
62
- { data: [{ dimension: { id: 'S' }, value: { id: 'S_V1' } }], key: 'S=S_V1', flags: [], sideProps: null, coordinates: { S: 'S_V1' } },
63
- [
64
- {
65
- data: [{ dimension: { id: 'COMB' }, values: [{ id: 'R1_V1', display: true }, { id: 'R2_V1', display: true }, { id: 'ATTR_V1' }] }],
66
- key: 'R1=R1_V1:R2=R2_V1',
67
- coordinates: { R1: 'R1_V1', R2: 'R2_V1', S: 'S_V1' },
68
- flags: [],
69
- sideProps: null
70
- },
71
- {
72
- data: [{ dimension: { id: 'COMB' }, values: [{ id: 'R1_V1', display: true }, { id: 'R2_V2', display: false }, { id: 'ATTR_V2' }] }],
73
- key: 'R1=R1_V1:R2=R2_V2',
74
- coordinates: { R1: 'R1_V1', R2: 'R2_V2', S: 'S_V1' },
75
- flags: [],
76
- sideProps: null
77
- },
78
- {
79
- data: [{ dimension: { id: 'COMB' }, values: [{ id: 'R1_V2', display: true }, { id: 'R2_V1', display: true }, { id: 'ATTR_V3' }] }],
80
- key: 'R1=R1_V2:R2=R2_V1',
81
- coordinates: { R1: 'R1_V2', R2: 'R2_V1', S: 'S_V1' },
82
- flags: [],
83
- sideProps: null
84
- },
85
- {
86
- data: [{ dimension: { id: 'COMB' }, values: [{ id: 'R1_V2', display: true }, { id: 'R2_V2', display: false }, { id: 'ATTR_V4' }] }],
87
- key: 'R1=R1_V2:R2=R2_V2',
88
- coordinates: { R1: 'R1_V2', R2: 'R2_V2', S: 'S_V1' },
89
- flags: [],
90
- sideProps: null
91
- },
92
- ]
93
- ],
94
- [
95
- { data: [{ dimension: { id: 'S' }, value: { id: 'S_V2' } }], key: 'S=S_V2', flags: [], sideProps: null, coordinates: { S: 'S_V2' } },
96
- [
97
- {
98
- data: [{ dimension: { id: 'COMB' }, values: [{ id: 'R1_V1', display: true }, { id: 'R2_V1', display: true }, { id: 'ATTR_V1' }] }],
99
- key: 'R1=R1_V1:R2=R2_V1',
100
- coordinates: { R1: 'R1_V1', R2: 'R2_V1', S: 'S_V2' },
101
- flags: [],
102
- sideProps: null
103
- },
104
- {
105
- data: [{ dimension: { id: 'COMB' }, values: [{ id: 'R1_V1', display: true }, { id: 'R2_V2', display: false }, { id: 'ATTR_V2' }] }],
106
- key: 'R1=R1_V1:R2=R2_V2',
107
- coordinates: { R1: 'R1_V1', R2: 'R2_V2', S: 'S_V2' },
108
- flags: [],
109
- sideProps: null
110
- },
111
- {
112
- data: [{ dimension: { id: 'COMB' }, values: [{ id: 'R1_V2', display: true }, { id: 'R2_V1', display: true }, { id: 'ATTR_V3' }] }],
113
- key: 'R1=R1_V2:R2=R2_V1',
114
- coordinates: { R1: 'R1_V2', R2: 'R2_V1', S: 'S_V2' },
115
- flags: [],
116
- sideProps: null
117
- },
118
- {
119
- data: [{ dimension: { id: 'COMB' }, values: [{ id: 'R1_V2', display: true }, { id: 'R2_V2', display: false }, { id: 'ATTR_V4' }] }],
120
- key: 'R1=R1_V2:R2=R2_V2',
121
- coordinates: { R1: 'R1_V2', R2: 'R2_V2', S: 'S_V2' },
122
- flags: [],
123
- sideProps: null
124
- },
125
- ]
126
- ]
127
- ]
128
- })
129
- });
130
- it('not displayed combination', () => {
131
- const layout = {
132
- header: [{ id: 'H', values: [{ id: 'H_V1' }, { id: 'H_V2' }] }],
133
- sections: [],
134
- rows: [
135
- { id: 'R1', values: [{ id: 'R1_V1' }, { id: 'R1_V2' }] },
136
- {
137
- id: 'COMB',
138
- display: false,
139
- concepts: ['R2', 'ATTR'],
140
- dimensions: [
141
- { id: 'R2', values: [{ id: 'R2_V1' }, { id: 'R2_V2' }] },
142
- ]
143
- }
144
- ]
145
- };
146
-
147
- const attributesSeries = {
148
- 'R1=R1_V1:R2=R2_V1': {
149
- ATTR: { id: 'ATTR', value: { id: 'ATTR_V1' }, coordinates: { R1: 'R1_V1', R2: 'R2_V1' } },
150
- },
151
- 'R1=R1_V2:R2=R2_V2': {
152
- ATTR: { id: 'ATTR', value: { id: 'ATTR_V4' }, coordinates: { R1: 'R1_V2', R2: 'R2_V2' } },
153
- },
154
- };
155
-
156
- const layoutIndexes = {
157
- header: [[0], [1]],
158
- sections: [
159
- [
160
- [],
161
- [
162
- [0, [0]],
163
- [1, [1]]
164
- ]
165
- ]
166
- ]
167
- };
168
-
169
- expect(getLayoutData(layoutIndexes, layout, { attributesSeries, metadataCoordinates: [], customAttributes: { flags: [], notes: [] } })).to.deep.equal({
170
- headerData: [
171
- { data: [{ dimension: { id: 'H' }, value: { id: 'H_V1' } }], key: 'H=H_V1', flags: [], sideProps: null, coordinates: { H: 'H_V1' } },
172
- { data: [{ dimension: { id: 'H' }, value: { id: 'H_V2' } }], key: 'H=H_V2', flags: [], sideProps: null, coordinates: { H: 'H_V2' } }
173
- ],
174
- sectionsData: [
175
- [
176
- { data: [], key: '', flags: [], sideProps: null, coordinates: {} },
177
- [
178
- { data: [{ dimension: { id: 'R1' }, value: { id: 'R1_V1' } }], key: 'R1=R1_V1:R2=R2_V1', flags: [], sideProps: null, coordinates: { R1: 'R1_V1', R2: 'R2_V1' } },
179
- { data: [{ dimension: { id: 'R1' }, value: { id: 'R1_V2' } }], key: 'R1=R1_V2:R2=R2_V2', flags: [], sideProps: null, coordinates: { R1: 'R1_V2', R2: 'R2_V2' } }
180
- ]
181
- ]
182
- ]
183
- });
184
- });
185
- it('flags, advanced attributes and metadata availability', () => {
186
- const customAttributes = { flags: ['FL'], notes: ['FT'] };
187
- const topCoordinates = { FREQ: 'A' };
188
- const layout = {
189
- header: [
190
- { id: 'TIME_PERIOD', values: [{ id: '2020' }, { id: '2021' }] }
191
- ],
192
- sections: [
193
- { id: 'TRANSACT', values: [{ id: 'TRANSACT1' }, { id: 'TRANSACT2' }] }
194
- ],
195
- rows: [
196
- { id: 'REF_AREA', values: [{ id: 'US' }, { id: 'AUS' }, { id: 'FRA' }] },
197
- { id: 'COMB_UNIT', concepts: ['TRANSACT', "MEASURE", 'UNIT_MULT'], dimensions: [{ id: 'MEASURE', values: [{ id: 'USD' }, { id: 'AUSD' }, { id: 'EUR' }] }] }
198
- ]
199
- };
200
-
201
- const metadataCoordinates = [
202
- {},
203
- { TIME_PERIOD: '2021', FREQ: 'A' },
204
- { TRANSACT: 'TRANSACT1' },
205
- { TRANSACT: 'TRANSACT2', REF_AREA: 'AUS', FREQ: 'A' }
206
- ];
207
-
208
- const attributesSeries = {
209
- 'TIME_PERIOD=2020:FREQ=A': {
210
- FL: { id: 'FL', serieKey: 'TIME_PERIOD=2020:FREQ=A', coordinates: { TIME_PERIOD: '2020', FREQ: 'A' }, value: { id: 'FL_V' } },
211
- FT: { id: 'FT', serieKey: 'TIME_PERIOD=2020:FREQ=A', coordinates: { TIME_PERIOD: '2020', FREQ: 'A' }, value: { id: 'FT_V0' } }
212
- },
213
- 'TRANSACT=TRANSACT1:MEASURE=USD': {
214
- UNIT_MULT: { id: 'UNIT_MULT', serieKey: 'TRANSACT=TRANSACT1:MEASURE=USD', coordinates: { TRANSACT: 'TRANSACT1', MEASURE: 'USD' }, value: { id: 'BILL' } }
215
- },
216
- 'TRANSACT=TRANSACT1:MEASURE=AUSD': {
217
- UNIT_MULT: { id: 'UNIT_MULT', serieKey: 'TRANSACT=TRANSACT1:MEASURE=AUSD', coordinates: { TRANSACT: 'TRANSACT1', MEASURE: 'AUSD' }, value: { id: '0' } }
218
- },
219
- 'TRANSACT=TRANSACT1:MEASURE=EUR': {
220
- UNIT_MULT: { id: 'UNIT_MULT', serieKey: 'TRANSACT=TRANSACT1:MEASURE=EUR', coordinates: { TRANSACT: 'TRANSACT1', MEASURE: 'EUR' }, value: { id: 'MILL' } }
221
- },
222
- 'TRANSACT=TRANSACT2:MEASURE=USD': {
223
- UNIT_MULT: { id: 'UNIT_MULT', serieKey: 'TRANSACT=TRANSACT2:MEASURE=USD', coordinates: { TRANSACT: 'TRANSACT2', MEASURE: 'USD' }, value: { id: 'BILL' } }
224
- },
225
- 'TRANSACT=TRANSACT2:MEASURE=AUSD': {
226
- UNIT_MULT: { id: 'UNIT_MULT', serieKey: 'TRANSACT=TRANSACT2:MEASURE=AUSD', coordinates: { TRANSACT: 'TRANSACT2', MEASURE: 'AUSD' }, value: { id: '0' } }
227
- },
228
- 'TRANSACT=TRANSACT2:MEASURE=EUR': {
229
- UNIT_MULT: { id: 'UNIT_MULT', serieKey: 'TRANSACT=TRANSACT2:MEASURE=EUR', coordinates: { TRANSACT: 'TRANSACT2', MEASURE: 'EUR' }, value: { id: 'MILL' } }
230
- },
231
- 'TRANSACT=TRANSACT1:FREQ=A': {
232
- FT: { id: 'FT', serieKey: 'TRANSACT=TRANSACT1:FREQ=A', coordinates: { TRANSACT: 'TRANSACT1', FREQ: 'A' }, value: { id: 'FT_V1' } },
233
- ADV: { id: 'ADV', serieKey: 'TRANSACT=TRANSACT1:FREQ=A', coordinates: { TRANSACT: 'TRANSACT1', FREQ: 'A' }, value: { id: 'ADV_V0' } }
234
- },
235
- 'TRANSACT=TRANSACT2:REF_AREA=FRA': {
236
- FT: { id: 'FT', serieKey: 'TRANSACT=TRANSACT2:REF_AREA=FRA', coordinates: { TRANSACT: 'TRANSACT2', REF_AREA: 'FRA' }, value: { id: 'FT_V2' } }
237
- },
238
- 'TRANSACT=TRANSACT2:MEASURE=USD:FREQ=A': {
239
- ADV: { id: 'ADV', serieKey: 'TRANSACT=TRANSACT2:MEASURE=USD:FREQ=A', coordinates: { TRANSACT: 'TRANSACT2', MEASURE: 'USD', FREQ: 'A' }, value: { id: 'ADV_V1' } }
240
- },
241
- };
242
-
243
- const layoutIndexes = {
244
- header: [[0], [1]],
245
- sections: [
246
- [
247
- [0],
248
- [[0, [0]], [1, [1]], [2, [2]]],
249
- ],
250
- [
251
- [1],
252
- [[0, [0]], [1, [1]], [2, [2]]],
253
- ]
254
- ]
255
- };
256
-
257
- const layoutData = {
258
- headerData: [
259
- { data: [{ dimension: { id: 'TIME_PERIOD' }, value: { id: '2020' } }], flags: [{ id: 'FL', code: 'FL_V', value: { id: 'FL_V' } }, { id: 'FT', value: { id: 'FT_V0' } }], key: 'TIME_PERIOD=2020', sideProps: null, coordinates: { TIME_PERIOD: '2020', FREQ: 'A' } },
260
- { data: [{ dimension: { id: 'TIME_PERIOD' }, value: { id: '2021' } }], flags: [], key: 'TIME_PERIOD=2021', sideProps: { hasMetadata: true, hasAdvancedAttributes: false, coordinates: { TIME_PERIOD: '2021', FREQ: 'A' } }, coordinates: { TIME_PERIOD: '2021', FREQ: 'A' } },
261
- ],
262
- sectionsData: [
263
- [
264
- { data: [{ dimension: { id: 'TRANSACT' }, value: { id: 'TRANSACT1' } }], flags: [{ id: 'FT', value: { id: 'FT_V1' } }], key: 'TRANSACT=TRANSACT1', sideProps: { hasAdvancedAttributes: true, hasMetadata: true, coordinates: { TRANSACT: 'TRANSACT1', FREQ: 'A' } }, coordinates: { TRANSACT: 'TRANSACT1', FREQ: 'A' } },
265
- [
266
- { data: [{ dimension: { id: 'REF_AREA' }, value: { id: 'US' } }, { dimension: { id: 'COMB_UNIT' }, values: [{ id: 'USD', display: true }, { id: 'BILL' }] }], flags: [], key: 'REF_AREA=US:MEASURE=USD', sideProps: null, coordinates: { TRANSACT: 'TRANSACT1', REF_AREA: 'US', MEASURE: 'USD', FREQ: 'A' } },
267
- { data: [{ dimension: { id: 'REF_AREA' }, value: { id: 'AUS' } }, { dimension: { id: 'COMB_UNIT' }, values: [{ id: 'AUSD', display: true }, { id: '0' }] }], flags: [], key: 'REF_AREA=AUS:MEASURE=AUSD', sideProps: null, coordinates: { TRANSACT: 'TRANSACT1', REF_AREA: 'AUS', MEASURE: 'AUSD', FREQ: 'A' } },
268
- { data: [{ dimension: { id: 'REF_AREA' }, value: { id: 'FRA' } }, { dimension: { id: 'COMB_UNIT' }, values: [{ id: 'EUR', display: true }, { id: 'MILL' }] }], flags: [], key: 'REF_AREA=FRA:MEASURE=EUR', sideProps: null, coordinates: { TRANSACT: 'TRANSACT1', REF_AREA: 'FRA', MEASURE: 'EUR', FREQ: 'A' } },
269
- ]
270
- ],
271
- [
272
- { data: [{ dimension: { id: 'TRANSACT' }, value: { id: 'TRANSACT2' } }], flags: [], key: 'TRANSACT=TRANSACT2', sideProps: null, coordinates: { TRANSACT: 'TRANSACT2', FREQ: 'A' } },
273
- [
274
- { data: [{ dimension: { id: 'REF_AREA' }, value: { id: 'US' } }, { dimension: { id: 'COMB_UNIT' }, values: [{ id: 'USD', display: true }, { id: 'BILL' }] }], flags: [], key: 'REF_AREA=US:MEASURE=USD', sideProps: { hasAdvancedAttributes: true, hasMetadata: false, coordinates: { TRANSACT: 'TRANSACT2', REF_AREA: 'US', MEASURE: 'USD', FREQ: 'A' } }, coordinates: { TRANSACT: 'TRANSACT2', REF_AREA: 'US', MEASURE: 'USD', FREQ: 'A' } },
275
- { data: [{ dimension: { id: 'REF_AREA' }, value: { id: 'AUS' } }, { dimension: { id: 'COMB_UNIT' }, values: [{ id: 'AUSD', display: true }, { id: '0' }] }], flags: [], key: 'REF_AREA=AUS:MEASURE=AUSD', sideProps: { hasAdvancedAttributes: false, hasMetadata: true, coordinates: { TRANSACT: 'TRANSACT2', REF_AREA: 'AUS', MEASURE: 'AUSD', FREQ: 'A' } }, coordinates: { TRANSACT: 'TRANSACT2', REF_AREA: 'AUS', MEASURE: 'AUSD', FREQ: 'A' } },
276
- { data: [{ dimension: { id: 'REF_AREA' }, value: { id: 'FRA' } }, { dimension: { id: 'COMB_UNIT' }, values: [{ id: 'EUR', display: true }, { id: 'MILL' }] }], flags: [{ id: 'FT', value: { id: 'FT_V2' } }], key: 'REF_AREA=FRA:MEASURE=EUR', sideProps: null, coordinates: { TRANSACT: 'TRANSACT2', REF_AREA: 'FRA', MEASURE: 'EUR', FREQ: 'A' } },
277
- ]
278
- ],
279
- ]
280
- };
281
-
282
- expect(getLayoutData(layoutIndexes, layout, { attributesSeries, metadataCoordinates, customAttributes, topCoordinates })).to.deep.equal(layoutData);
283
- });
284
- });