@sis-cc/dotstatsuite-components 10.0.0 → 11.0.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 (52) hide show
  1. package/lib/index.js +8 -3
  2. package/lib/rules/src/table/factories/getCells.js +22 -4
  3. package/lib/rules/src/table/factories/getLayoutWithFlags.js +32 -5
  4. package/lib/rules/src/table/factories/getTableData.js +9 -2
  5. package/lib/rules/src/table/preparators/prepareData.js +37 -2
  6. package/lib/rules/src/v8-transformer.js +5 -9
  7. package/lib/rules2/src/constants.js +7 -0
  8. package/lib/rules2/src/getAdvAttrSeriesAtCoordinates.js +39 -0
  9. package/lib/rules2/src/getAdvancedAttributes.js +126 -0
  10. package/lib/rules2/src/getMetadataCoordinates.js +38 -0
  11. package/lib/rules2/src/getMetadataStructureFromData.js +23 -0
  12. package/lib/rules2/src/getSidebarData.js +76 -0
  13. package/lib/rules2/src/hasCellMetadata.js +19 -0
  14. package/lib/rules2/src/hasLayoutEntryMetadata.js +18 -0
  15. package/lib/rules2/src/index.js +41 -0
  16. package/lib/rules2/src/json2.0DataFormatPatch.js +20 -0
  17. package/lib/rules2/src/parseMetadataSeries.js +83 -0
  18. package/lib/rules2/src/refineMetadataCoordinates.js +34 -0
  19. package/package.json +1 -1
  20. package/src/index.js +2 -0
  21. package/src/rules/src/table/factories/getCells.js +13 -4
  22. package/src/rules/src/table/factories/getLayoutWithFlags.js +36 -10
  23. package/src/rules/src/table/factories/getTableData.js +12 -3
  24. package/src/rules/src/table/preparators/prepareData.js +45 -4
  25. package/src/rules/src/v8-transformer.js +3 -8
  26. package/src/rules2/src/constants.js +2 -0
  27. package/src/rules2/src/getAdvAttrSeriesAtCoordinates.js +29 -0
  28. package/src/rules2/src/getAdvancedAttributes.js +113 -0
  29. package/src/rules2/src/getMetadataCoordinates.js +37 -0
  30. package/src/rules2/src/getMetadataStructureFromData.js +17 -0
  31. package/src/rules2/src/getSidebarData.js +73 -0
  32. package/src/rules2/src/hasCellMetadata.js +11 -0
  33. package/src/rules2/src/hasLayoutEntryMetadata.js +9 -0
  34. package/src/rules2/src/index.js +5 -0
  35. package/src/rules2/src/json2.0DataFormatPatch.js +9 -0
  36. package/src/rules2/src/parseMetadataSeries.js +80 -0
  37. package/src/rules2/src/refineMetadataCoordinates.js +27 -0
  38. package/test/advanced-attributes-parsing-perf.test.js +16 -0
  39. package/test/getCells.test.js +7 -5
  40. package/test/getDataflowAdvancedAttributes.test.js +32 -0
  41. package/test/getLayoutDataWithFlags.test.js +22 -12
  42. package/test/getMetadataCoordinates.test.js +0 -0
  43. package/test/getSeriesAdvancedAttributes.test.js +30 -0
  44. package/test/getSidebarData.test.js +116 -0
  45. package/test/getSubtitleFlags.test.js +1 -1
  46. package/test/getTableData.test.js +2 -1
  47. package/test/metadata-parsing-perf.test.js +487 -0
  48. package/test/mocks/OECD_SNA_TABLE1_1.0_-_AUS_V_metadata.json +152 -0
  49. package/test/mocks/large_metadata_series.json +701 -0
  50. package/test/mocks/observations-advanced-attributes.json +55382 -0
  51. package/test/parseMetadataSeries.test.js +55 -0
  52. package/test/prepareData.test.js +2 -0
@@ -0,0 +1,73 @@
1
+ import * as R from 'ramda';
2
+
3
+ const dimensionValueDisplay = (display) => data => {
4
+ if (display === 'code') {
5
+ return R.prop('id', data);
6
+ }
7
+ if (display === 'both') {
8
+ return `${R.prop('id', data)}: ${R.prop('name', data)}`;
9
+ }
10
+ return R.prop('name', data);
11
+ };
12
+
13
+ const sortByCoordinates = (a, b) => {
14
+ const splitACoord = a.splitCoord;
15
+ const splitBCoord = b.splitCoord;
16
+
17
+ const aWeight = R.pipe(R.reject(R.isEmpty), R.length)(splitACoord);
18
+ const bWeight = R.pipe(R.reject(R.isEmpty), R.length)(splitBCoord);
19
+ if (aWeight !== bWeight) {
20
+ return bWeight - aWeight;
21
+ }
22
+
23
+ let ind = 0;
24
+ while (splitACoord[ind] === splitBCoord[ind]) {
25
+ ind++;
26
+ }
27
+ const _a = R.isEmpty(splitACoord[ind]) ? 0 : Number(splitACoord[ind]);
28
+ const _b = R.isEmpty(splitBCoord[ind]) ? 0 : Number(splitBCoord[ind]);
29
+ return _b - _a;
30
+ };
31
+
32
+ // options = { display, attributesLabel }
33
+ export const getSidebarData = (attributesSeries, metadataSeries, dataflow, dimensions, options) => {
34
+ const coordinates = R.uniq(R.concat(R.keys(attributesSeries), R.keys(metadataSeries)));
35
+ return R.pipe(
36
+ R.map(coordinate => {
37
+ const attributes = R.prop(coordinate, attributesSeries);
38
+ const metadata = R.prop(coordinate, metadataSeries);
39
+ const children = R.concat(
40
+ R.isNil(attributes) ? [] : [{ id: `${coordinate}-attr`, label: options.attributesLabel, children: attributes }],
41
+ R.isNil(metadata) ? [] : metadata,
42
+ );
43
+ const splitCoord = R.split(':', coordinate);
44
+ let label = null;
45
+ if (R.all(R.isEmpty, splitCoord)) {
46
+ label = dimensionValueDisplay(options.display)(dataflow);
47
+ }
48
+ else {
49
+ label = R.pipe(
50
+ R.addIndex(R.reduce)((acc, valIndex, dimIndex) => {
51
+ if (R.isEmpty(valIndex)) {
52
+ return acc;
53
+ }
54
+ const dim = R.nth(dimIndex, dimensions);
55
+ const dimLabel = dimensionValueDisplay(options.display)(dim);
56
+ const value = R.nth(Number(valIndex), dim.values);
57
+ const valLabel = dimensionValueDisplay(options.display)(value);
58
+ return R.append(`${dimLabel}: ${valLabel}`, acc);
59
+ }, []),
60
+ R.join(' - ')
61
+ )(splitCoord);
62
+ }
63
+
64
+ return ({
65
+ id: coordinate,
66
+ splitCoord,
67
+ label,
68
+ children: R.filter(R.identity, children),
69
+ });
70
+ }),
71
+ R.sort(sortByCoordinates)
72
+ )(coordinates);
73
+ };
@@ -0,0 +1,11 @@
1
+ import * as R from 'ramda';
2
+
3
+ export const hasCellMetadata = (metadataCoordinates, cellCoordinates) => {
4
+ return R.pipe(
5
+ R.find(coordinates => {
6
+ const mergedCoord = R.mergeLeft(coordinates, cellCoordinates);
7
+ return R.equals(mergedCoord, cellCoordinates);
8
+ }),
9
+ R.complement(R.isNil)
10
+ )(metadataCoordinates);
11
+ };
@@ -0,0 +1,9 @@
1
+ import * as R from 'ramda';
2
+
3
+ /*
4
+ const layoutData = [{ dimension: { id: 'D1', __index: 2 }, value: { id: 'V', __index: 0 } }];
5
+ */
6
+
7
+ export const getLayoutEntryMetadataCoordinates = (layoutData, metadataSeries) => {
8
+
9
+ };
@@ -0,0 +1,5 @@
1
+ export { SDMX_2_0_JSON_DATA_FORMAT } from './constants';
2
+
3
+ export { getSidebarData } from './getSidebarData';
4
+ export { parseMetadataSeries } from './parseMetadataSeries';
5
+ export { json_2_0_0_DataFormatPatch } from './json2.0DataFormatPatch';
@@ -0,0 +1,9 @@
1
+ import * as R from 'ramda';
2
+
3
+ export const json_2_0_0_DataFormatPatch = (sdmxJson) => {
4
+ const dataSet = R.pipe(R.pathOr({}, ['data', 'dataSets']), R.head)(sdmxJson);
5
+ const structureIndex = R.prop('structure', dataSet);
6
+ const structure = R.pipe(R.pathOr([], ['data', 'structures']), R.nth(structureIndex))(sdmxJson);
7
+
8
+ return R.set(R.lensPath(['data', 'structure']), structure)(sdmxJson);
9
+ };
@@ -0,0 +1,80 @@
1
+ import * as R from 'ramda';
2
+ import { getLocalisedName } from '@sis-cc/dotstatsuite-sdmxjs';
3
+
4
+ const dimensionValueDisplay = (locale, display) => data => {
5
+ if (display === 'code') {
6
+ return R.prop('id', data);
7
+ }
8
+ if (display === 'both') {
9
+ return `${R.prop('id', data)}: ${getLocalisedName(locale)(data)}`;
10
+ }
11
+ return getLocalisedName(locale)(data);
12
+ };
13
+ // options = { locale, display, dimensions = [] };
14
+ export const parseMetadataSeries = (metadataJson, options) => {
15
+ const metadataAttributes = R.pathOr([], ['data', 'structures', 0, 'attributes', 'dimensionGroup'], metadataJson);
16
+ const metaAttrLength = R.length(metadataAttributes);
17
+
18
+ if (!metaAttrLength) {
19
+ return ({});
20
+ }
21
+
22
+ const dimensions = R.pipe(
23
+ R.pathOr([], ['data', 'structures', 0, 'dimensions']),
24
+ ({ series = [], observation = [] }) => R.concat(series, observation),
25
+ dims => R.isEmpty(options.dimensions || [])
26
+ ? dims
27
+ : R.props(R.pluck('id', options.dimensions), R.indexBy(R.prop('id'), dims))
28
+ )(metadataJson);
29
+
30
+ const metadataSeries = R.pipe(
31
+ R.pathOr({}, ['data', 'dataSets', 0, 'dimensionGroupAttributes']),
32
+ series => R.reduce((acc, serieKey) => {
33
+ const indexes = series[serieKey];
34
+ const metaIndexes = R.take(metaAttrLength, indexes);
35
+
36
+ const evolvedKey = R.pipe(
37
+ R.split(':'),
38
+ R.addIndex(R.map)((vInd, dInd) => {
39
+ if (R.isEmpty(vInd)) {
40
+ return vInd;
41
+ }
42
+ const dim = R.nth(dInd, dimensions);
43
+ const val = R.nth(Number(vInd), dim.values || []);
44
+
45
+ const originalVal = R.find(
46
+ R.propEq('id', val.id),
47
+ )(R.propOr([], 'values', R.nth(dInd, options.dimensions)));
48
+ return R.propOr('', '__index', originalVal);
49
+ }),
50
+ R.join(':')
51
+ )(serieKey)
52
+
53
+ const attributes = R.addIndex(R.reduce)(
54
+ (acc, valueIndex, attrIndex) => {
55
+ if (R.isNil(valueIndex)) {
56
+ return acc;
57
+ }
58
+ const attribute = R.nth(attrIndex, metadataAttributes);
59
+ const label = dimensionValueDisplay(options.locale, options.display)(attribute);
60
+
61
+ const value = R.prop('value', R.nth(valueIndex, attribute.values || []));
62
+
63
+ return R.append({
64
+ id: attribute.id,
65
+ label,
66
+ value: R.is(Object, value) ? R.prop(options.locale, value) : value
67
+ }, acc);
68
+ },
69
+ [],
70
+ metaIndexes
71
+ );
72
+
73
+ return R.assoc(evolvedKey, attributes, acc);
74
+ },
75
+ {},
76
+ R.keys(series)
77
+ ))(metadataJson);
78
+
79
+ return metadataSeries;
80
+ };
@@ -0,0 +1,27 @@
1
+ import * as R from 'ramda';
2
+
3
+ export const refineMetadataCoordinates = (metadataCoordinates, layoutIds, headerDimensionsIds) => {
4
+ return R.reduce(
5
+ (acc, coordinates) => {
6
+ const refinedCoord = R.omit(headerDimensionsIds, coordinates);
7
+ if (R.isEmpty(refinedCoord)) {
8
+ return acc;
9
+ }
10
+ const removedHeaderCodes = R.omit(layoutIds.header, refinedCoord);
11
+ if (R.isEmpty(removedHeaderCodes)) {
12
+ return R.over(R.lensProp('layout'), R.append(refinedCoord))(acc);
13
+ }
14
+ const removedSectionCodes = R.omit(layoutIds.sections, refinedCoord);
15
+ if (R.isEmpty(removedSectionCodes)) {
16
+ return R.over(R.lensProp('layout'), R.append(refinedCoord))(acc);
17
+ }
18
+ const removedRowsCodes = R.omit(layoutIds.rows, removedSectionCodes);
19
+ if (R.isEmpty(removedRowsCodes)) {
20
+ return R.over(R.lensProp('layout'), R.append(refinedCoord))(acc);
21
+ }
22
+ return R.over(R.lensProp('cells'), R.append(refinedCoord))(acc);
23
+ },
24
+ { cells: [], layout: [] },
25
+ metadataCoordinates
26
+ );
27
+ };
@@ -0,0 +1,16 @@
1
+ import { expect } from 'chai';
2
+ import {
3
+ getDataflowAdvancedAttributes,
4
+ getObservationsAdvancedAttributes,
5
+ getSeriesAdvancedAttributes
6
+ } from '../src/rules2/src/getAdvancedAttributes';
7
+
8
+ import obsMock from './mocks/table-prep-units--observations.json';
9
+ import obsAdvancedAttributes from './mocks/observations-advanced-attributes.json';
10
+
11
+ describe('advanced attributes parsing performance tests', () => {
12
+ it('1800 observations test', function() {
13
+ this.timeout(1500);
14
+ expect(getObservationsAdvancedAttributes(obsMock, ['CURRENCY', 'OBS_STATUS'])).to.deep.equal(obsAdvancedAttributes);
15
+ });
16
+ });
@@ -24,7 +24,7 @@ describe('getCells tests', () => {
24
24
  }
25
25
  }
26
26
  }, 'label', customAttributes,
27
- { unitsDefinitionCodes: [], unitsSeries: {}, unitsDisplay: 'cells', unitDimension: {} })).to.deep.equal({
27
+ { unitsDefinitionCodes: [], unitsSeries: {}, unitsDisplay: 'cells', unitDimension: {} }, [])).to.deep.equal({
28
28
  a: {
29
29
  value: '33',
30
30
  intValue: 33,
@@ -33,7 +33,8 @@ describe('getCells tests', () => {
33
33
  { label: 'Footnote 1: Footnote 1 Value 1' },
34
34
  { label: 'Footnote 3: Footnote 3 Value 3' }
35
35
  ],
36
- indexedDimValIds: {}
36
+ indexedDimValIds: {},
37
+ sideProps: null
37
38
  }
38
39
  })
39
40
  });
@@ -48,10 +49,10 @@ describe('getCells tests', () => {
48
49
  FT1: { id: 'FT1', name: 'Footnote 1', value: { id: 'FT1.1', name: 'Footnote 1 Value 1' } },
49
50
  FT3: { id: 'FT3', name: 'Footnote 3', value: { id: 'FT3.3', name: 'Footnote 3 Value 3' } },
50
51
  },
51
- indexedDimValIds: {}
52
+ indexedDimValIds: {},
52
53
  }
53
54
  }
54
- }, 'both', customAttributes)).to.deep.equal({
55
+ }, 'both', customAttributes, {}, [])).to.deep.equal({
55
56
  a: {
56
57
  value: '33',
57
58
  intValue: 33,
@@ -60,7 +61,8 @@ describe('getCells tests', () => {
60
61
  { label: '(FT1) Footnote 1: (FT1.1) Footnote 1 Value 1' },
61
62
  { label: '(FT3) Footnote 3: (FT3.3) Footnote 3 Value 3' }
62
63
  ],
63
- indexedDimValIds: {}
64
+ indexedDimValIds: {},
65
+ sideProps: null
64
66
  }
65
67
  })
66
68
  });
@@ -0,0 +1,32 @@
1
+ import { expect } from 'chai';
2
+ import { getDataflowAdvancedAttributes } from '../src/rules2/src/getAdvancedAttributes';
3
+
4
+ describe('getDataflowAdvancedAttributes tests', () => {
5
+ it('complete test', () => {
6
+ const advancedAttributesIds = ['a0', 'a2', 'a4', 'a6'];
7
+ const attributes = {
8
+ a0: { id: 'a0', relationship: { none: {} }, values: [{ id: 'v0' }] },
9
+ a1: { id: 'a1', relationship: { none: {} }, values: [{ id: 'v0' }] },
10
+ a2: { id: 'a2', relationship: { dimensions: ['d0'] }, values: [{ id: 'v0' }] },
11
+ a3: { id: 'a3', relationship: { dimensions: ['d0'] }, values: [{ id: 'v0' }] },
12
+ a4: { id: 'a4', relationship: { dimensions: ['d0', 'd1'] }, values: [{ id: 'v0' }] },
13
+ a5: { id: 'a5', relationship: { dimensions: ['d0', 'd1'] }, values: [{ id: 'v0' }] },
14
+ a6: { id: 'a6', relationship: { dimensions: ['d0', 'd1', 'd2'] }, values: [{ id: 'v0' }] },
15
+ };
16
+ const dimLength = 4;
17
+ const dimensions = {
18
+ d0: { id: 'd0', __index: 1, values: [{ id: 'v0' }] },
19
+ d1: { id: 'd1', __index: 2, values: [{ id: 'v0' }] },
20
+ d2: { id: 'd2', __index: 3, values: [{ id: 'v0' }] },
21
+ };
22
+
23
+ const expected = {
24
+ ':::': { attributes: { a0: { id: 'a0', value: { id: 'v0' } } }, coordinates: {} },
25
+ ':0::': { attributes: { a2: { id: 'a2', value: { id: 'v0' } } }, coordinates: { d0: 'v0' } },
26
+ ':0:0:': { attributes: { a4: { id: 'a4', value: { id: 'v0' } } }, coordinates: { d0: 'v0', d1: 'v0' } },
27
+ ':0:0:0': { attributes: { a6: { id: 'a6', value: { id: 'v0' } } }, coordinates: { d0: 'v0', d1: 'v0', d2: 'v0' } },
28
+ }
29
+
30
+ expect(getDataflowAdvancedAttributes(attributes, dimensions, advancedAttributesIds, dimLength)).to.deep.equal(expected);
31
+ });
32
+ });
@@ -1,7 +1,7 @@
1
1
  import { expect } from 'chai';
2
2
  import { getLayoutDataWithFlags } from '../src/rules/src/table/factories/getLayoutWithFlags';
3
3
 
4
- const customAttributes = { flags: ['a1', 'a2'] };
4
+ const customAttributes = { flags: ['a1', 'a2'], footnotes: ['a3', 'a4'] };
5
5
 
6
6
  const layoutData = {
7
7
  headerData: [
@@ -41,7 +41,8 @@ const expected = {
41
41
  { dimension: { id: 'COL2', label: 'COL2', flags: [] }, value: { id: 'COL2V1', label: 'COL2V1', flags: [] } }
42
42
  ],
43
43
  key: '0:0',
44
- flags: [{ code: 'A1VAL', label: 'A1: A1VAL' }, { label: 'A3: A3VAL' }]
44
+ flags: [{ code: 'A1VAL', label: 'A1: A1VAL' }, { label: 'A3: A3VAL' }],
45
+ sideProps: null
45
46
  },
46
47
  {
47
48
  data: [
@@ -49,7 +50,8 @@ const expected = {
49
50
  { dimension: { id: 'COL2', label: 'COL2', flags: [] }, value: { id: 'COL2V1', label: 'COL2V1', flags: [] } }
50
51
  ],
51
52
  key: '1:0',
52
- flags: []
53
+ flags: [],
54
+ sideProps: null
53
55
  }
54
56
  ],
55
57
  sectionsData: [
@@ -57,7 +59,8 @@ const expected = {
57
59
  {
58
60
  data: [{ dimension: { id: 'SEC', label: 'SEC', flags: [] }, value: { id: 'SECV1', label: 'SECV1', flags: [] } }],
59
61
  key: '0',
60
- flags: []
62
+ flags: [],
63
+ sideProps: null
61
64
  },
62
65
  [
63
66
  {
@@ -66,7 +69,8 @@ const expected = {
66
69
  { dimension: { id: 'ROW2', label: 'ROW2', flags: [] }, value: { id: 'ROW2V1', label: 'ROW2V1', flags: [] } }
67
70
  ],
68
71
  key: '0:0',
69
- flags: []
72
+ flags: [],
73
+ sideProps: null
70
74
  },
71
75
  {
72
76
  data: [
@@ -74,7 +78,8 @@ const expected = {
74
78
  { dimension: { id: 'ROW2', label: 'ROW2', flags: [] }, value: { id: 'ROW2V2', label: 'ROW2V2', flags: [] } }
75
79
  ],
76
80
  key: '0:1',
77
- flags: []
81
+ flags: [],
82
+ sideProps: null
78
83
  },
79
84
  {
80
85
  data: [
@@ -82,7 +87,8 @@ const expected = {
82
87
  { dimension: { id: 'ROW2', label: 'ROW2', flags: [] }, value: { id: 'ROW2V3', label: 'ROW2V3', flags: [] } }
83
88
  ],
84
89
  key: '0:2',
85
- flags: []
90
+ flags: [],
91
+ sideProps: null
86
92
  },
87
93
  ]
88
94
  ],
@@ -90,7 +96,8 @@ const expected = {
90
96
  {
91
97
  data: [{ dimension: { id: 'SEC', label: 'SEC', flags: [] }, value: { id: 'SECV2', label: 'SECV2', flags: [] } }],
92
98
  key: '1',
93
- flags: []
99
+ flags: [],
100
+ sideProps: null
94
101
  },
95
102
  [
96
103
  {
@@ -99,7 +106,8 @@ const expected = {
99
106
  { dimension: { id: 'ROW2', label: 'ROW2', flags: [] }, value: { id: 'ROW2V1', label: 'ROW2V1', flags: [] } }
100
107
  ],
101
108
  key: '0:0',
102
- flags: []
109
+ flags: [],
110
+ sideProps: null
103
111
  },
104
112
  {
105
113
  data: [
@@ -107,7 +115,8 @@ const expected = {
107
115
  { dimension: { id: 'ROW2', label: 'ROW2', flags: [] }, value: { id: 'ROW2V2', label: 'ROW2V2', flags: [] } }
108
116
  ],
109
117
  key: '0:1',
110
- flags: [{ label: 'A4: A4VAL' }]
118
+ flags: [{ label: 'A4: A4VAL' }],
119
+ sideProps: null
111
120
  },
112
121
  {
113
122
  data: [
@@ -115,7 +124,8 @@ const expected = {
115
124
  { dimension: { id: 'ROW2', label: 'ROW2', flags: [] }, value: { id: 'ROW2V3', label: 'ROW2V3', flags: [] } }
116
125
  ],
117
126
  key: '0:2',
118
- flags: []
127
+ flags: [],
128
+ sideProps: null
119
129
  },
120
130
  ]
121
131
  ]
@@ -127,6 +137,6 @@ describe('getLayoutDataWithFlags test', () => {
127
137
  expect(getLayoutDataWithFlags({}, 'label', {})({ headerData: [], sectionsData: [] })).to.deep.equal({ headerData: [], sectionsData: [] });
128
138
  });
129
139
  it('multi cases', () => {
130
- expect(getLayoutDataWithFlags(attributesValues, 'code', customAttributes)(layoutData)).to.deep.equal(expected);
140
+ expect(getLayoutDataWithFlags(attributesValues, 'code', customAttributes, [], [])(layoutData)).to.deep.equal(expected);
131
141
  });
132
142
  });
File without changes
@@ -0,0 +1,30 @@
1
+ import { expect } from 'chai';
2
+ import { getSeriesAdvancedAttributes } from '../src/rules2/src/getAdvancedAttributes';
3
+
4
+ describe('getSeriesAdvancedAttributes tests', () => {
5
+ it('complete case', () => {
6
+ const seriesAttributes = {
7
+ series: {
8
+ '0:0:x:x:x': { attributes: { a0: { id: 'a0' } } },
9
+ '0:1:0:x:x': { attributes: { a0: { id: 'a0' }, a1: { id: 'a1' } } },
10
+ },
11
+ dimensions: {
12
+ '3:0': { attributes: { a0: { id: 'a0' } } },
13
+ '4:1': { attributes: { a0: { id: 'a0' }, a1: { id: 'a1' } } },
14
+ }
15
+ };
16
+ const advancedAttributesIds = ['a1'];
17
+ const dimensions = [
18
+ { id: 'd0', values: [{ id: 'v0' }] },
19
+ { id: 'd1', values: [{ id: 'v0' }, { id: 'v1' }] },
20
+ { id: 'd2', values: [{ id: 'v0' }] },
21
+ { id: 'd3', values: [{ id: 'v0' }] },
22
+ { id: 'd4', values: [{ id: 'v0' }, { id: 'v1' }] },
23
+ ];
24
+
25
+ expect(getSeriesAdvancedAttributes(seriesAttributes, dimensions, advancedAttributesIds)).to.deep.equal({
26
+ '0:1:0::': { attributes: { a1: { id: 'a1' } }, coordinates: { d0: 'v0', d1: 'v1', d2: 'v0' } },
27
+ '::::1': { attributes: { a1: { id: 'a1' } }, coordinates: { d4: 'v1' } }
28
+ });
29
+ });
30
+ });
@@ -0,0 +1,116 @@
1
+ import { expect } from 'chai';
2
+ import { getSidebarData } from '../src/rules2/src/getSidebarData';
3
+
4
+ describe('getSidebarData tests', () => {
5
+ it('complete case', () => {
6
+ const attributes = {
7
+ '::': [
8
+ { id: 'aa0', label: 'advanced attribute 0', value: 'value' },
9
+ { id: 'aa1', label: 'advanced attribute 1', value: 'value' },
10
+ ],
11
+ '0::': [
12
+ { id: 'aa2', label: 'advanced attribute 2', value: 'value' },
13
+ { id: 'aa3', label: 'advanced attribute 3', value: 'value' },
14
+ ]
15
+ };
16
+ const metadata = {
17
+ '0::': [
18
+ { id: 'ma0', label: 'metadata attribute 0', value: 'value' },
19
+ { id: 'ma1', label: 'metadata attribute 1', value: 'value' },
20
+ ],
21
+ '0::0': [
22
+ { id: 'ma2', label: 'metadata attribute 2', value: 'value' },
23
+ { id: 'ma3', label: 'metadata attribute 3', value: 'value' },
24
+ ]
25
+ };
26
+ const options = {
27
+ display: 'code',
28
+ attributesLabel: 'Advanced Attributes'
29
+ };
30
+ const dataflow = {
31
+ id: 'DF',
32
+ name: 'Dataflow'
33
+ };
34
+ const dimensions = [
35
+ { id: 'd0', name: 'dimension 0', values: [{ id: 'd0v0', name: 'value 0' }] },
36
+ { id: 'd1', name: 'dimension 1', values: [{ id: 'd1v0', name: 'value 0' }] },
37
+ { id: 'd2', name: 'dimension 2', values: [{ id: 'd2v0', name: 'value 0' }] },
38
+ ];
39
+
40
+ expect(getSidebarData(attributes, metadata, dataflow, dimensions, options)).to.deep.equal([
41
+ {
42
+ id: '0::0',
43
+ label: 'd0: d0v0 - d2: d2v0',
44
+ splitCoord: ['0', '', '0'],
45
+ children: [
46
+ {
47
+ id: 'ma2',
48
+ label: 'metadata attribute 2',
49
+ value: 'value'
50
+ },
51
+ {
52
+ id: 'ma3',
53
+ label: 'metadata attribute 3',
54
+ value: 'value'
55
+ }
56
+ ]
57
+ },
58
+ {
59
+ id: '0::',
60
+ label: 'd0: d0v0',
61
+ splitCoord: ['0', '', ''],
62
+ children: [
63
+ {
64
+ id: '0::-attr',
65
+ label: 'Advanced Attributes',
66
+ children: [
67
+ {
68
+ id: 'aa2',
69
+ label: 'advanced attribute 2',
70
+ value: 'value'
71
+ },
72
+ {
73
+ id: 'aa3',
74
+ label: 'advanced attribute 3',
75
+ value: 'value'
76
+ }
77
+ ]
78
+ },
79
+ {
80
+ id: 'ma0',
81
+ label: 'metadata attribute 0',
82
+ value: 'value'
83
+ },
84
+ {
85
+ id: 'ma1',
86
+ label: 'metadata attribute 1',
87
+ value: 'value'
88
+ }
89
+ ]
90
+ },
91
+ {
92
+ id: '::',
93
+ label: 'DF',
94
+ splitCoord: ['', '', ''],
95
+ children: [
96
+ {
97
+ id: '::-attr',
98
+ label: 'Advanced Attributes',
99
+ children: [
100
+ {
101
+ id: 'aa0',
102
+ label: 'advanced attribute 0',
103
+ value: 'value'
104
+ },
105
+ {
106
+ id: 'aa1',
107
+ label: 'advanced attribute 1',
108
+ value: 'value'
109
+ }
110
+ ]
111
+ }
112
+ ]
113
+ }
114
+ ]);
115
+ });
116
+ });
@@ -22,7 +22,7 @@ describe('getSubtitleFlags tests', () => {
22
22
  });
23
23
  it('simple test', () => {
24
24
  expect(getSubtitleFlags({
25
- customAttributes: {},
25
+ customAttributes: { flags: [], footnotes: ['f1', 'f2'] },
26
26
  dimensions: {
27
27
  one: {
28
28
  a: {
@@ -14,7 +14,8 @@ const data = {
14
14
  dataflowAttributes: {},
15
15
  dataflowName: undefined,
16
16
  seriesAttributes: [],
17
- seriesAttributesValues: {}
17
+ seriesAttributesValues: {},
18
+ metadataCoordinates: []
18
19
  };
19
20
 
20
21
  const data1 = {