@sis-cc/dotstatsuite-components 13.0.0 → 13.0.3

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.
@@ -123,8 +123,6 @@ var enhanceObservations = exports.enhanceObservations = function enhanceObservat
123
123
  }, attributes);
124
124
  var _obsAttributes = R.pipe(R.indexBy(R.prop('id')), R.props(options.attributesIds || []))(_attributes);
125
125
 
126
- var seriesDimensions = R.filter(R.pipe(R.propOr([], 'values'), R.length, R.lt(1)), dimensions);
127
-
128
126
  return R.mapObjIndexed(function (observation) {
129
127
  var attrValuesIndexes = observation.attrValuesIndexes,
130
128
  dimValuesIndexes = observation.dimValuesIndexes;
@@ -148,7 +146,7 @@ var enhanceObservations = exports.enhanceObservations = function enhanceObservat
148
146
  attributes: obsAttributes,
149
147
  formattedValue: (0, _formatValue.formatValue)(observation, formatAttributesIndexes, attributes),
150
148
  orderedDimIndexes: getOrderedDimensionsIndexes(dimensions, dimValuesIndexes),
151
- units: getObservationUnits(observation, seriesDimensions, _attributes, options),
149
+ units: getObservationUnits(observation, dimensions, _attributes, options),
152
150
  indexedDimValIds: indexedDimValIds
153
151
  });
154
152
  }, observations);
@@ -32,7 +32,7 @@ var getAttributeRegisters = function getAttributeRegisters(attribute, parsedDime
32
32
  if (R.propEq('id', customAttributes.decimals, attribute)) {
33
33
  return [registerAttrId(['decimals'], attribute.id), registerAttr(attribute)];
34
34
  }
35
- if (R.hasPath(['relationship', 'none'], attribute)) {
35
+ if (R.hasPath(['relationship', 'none'], attribute) || R.hasPath(['relationship', 'dataflow'], attribute)) {
36
36
  return [registerAttrId(['dataflow'], attribute.id), registerAttr(attribute)];
37
37
  }
38
38
  if (R.pathEq(['relationship', 'primaryMeasure'], 'OBS_VALUE', attribute) || R.hasPath(['relationship', 'observation'], attribute)) {
@@ -116,7 +116,7 @@ var prepareData = exports.prepareData = function prepareData(sdmxJson, customAtt
116
116
  var attributes = _ref.attributes,
117
117
  dimensions = _ref.dimensions;
118
118
  return R.merge(attributes.series || {}, dimensions.series || {});
119
- }, R.values, R.pluck('id'))(unitsArtefacts);
119
+ }, R.keys)(unitsArtefacts);
120
120
  var options = {
121
121
  attachmentSeriesIndexes: attachmentSeriesIndexes,
122
122
  customAttributes: customAttributes,
@@ -156,7 +156,9 @@ var prepareData = exports.prepareData = function prepareData(sdmxJson, customAtt
156
156
  return !R.includes(id, customAttributes.flags || []) && !R.includes(id, customAttributes.notes || []);
157
157
  }))(headerAttributesIds);
158
158
 
159
- var dataflowAdvancedAttributes = (0, _getAdvancedAttributes.getDataflowAdvancedAttributes)(headerAttributes, oneValueDimensions, headerAdvancedAttrIds, R.length(dimensions));
159
+ var dataflowAdvancedAttributes = (0, _getAdvancedAttributes.getDataflowAdvancedAttributes)(headerAttributes,
160
+ //oneValueDimensions,
161
+ R.pick(R.keys(parsedDimensionsIds.oneValue), dimensionsIndexedByIds), headerAdvancedAttrIds, R.length(dimensions));
160
162
 
161
163
  var observationsAdvancedAttributesIds = R.filter(function (id) {
162
164
  return !R.includes(id, customAttributes.flags || []) && !R.includes(id, customAttributes.notes || []);
@@ -113,8 +113,15 @@ var dataTransformer = exports.dataTransformer = function dataTransformer(dataNew
113
113
  });
114
114
  }, attrObservations);
115
115
 
116
+ var datasetAttributes = R.map(function (attr) {
117
+ return (0, _extends3.default)({}, attr, {
118
+ name: getLocalisedProp('names', observation),
119
+ values: getValues(attr.values || [])
120
+ });
121
+ }, R.propOr([], 'dataSet', attributes));
122
+
116
123
  var resAttributes = (0, _extends3.default)({}, attributes, {
117
- observation: resAttrObservations
124
+ observation: R.concat(resAttrObservations, datasetAttributes)
118
125
  });
119
126
 
120
127
  //----------------------------------------------------------------------------------------Dimensions
@@ -51,7 +51,7 @@ var getDataflowAdvancedAttributes = exports.getDataflowAdvancedAttributes = func
51
51
  var vId = R.path(['values', 0, 'id'], dim);
52
52
  coordinates = (0, _extends4.default)({}, coordinates, (0, _defineProperty3.default)({}, dId, vId));
53
53
  key = R.set(R.lensIndex(dIndex), 0)(key);
54
- }, attrDimensions);
54
+ }, R.reject(R.isNil, attrDimensions));
55
55
  }
56
56
 
57
57
  key = R.join(':', key);
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": "13.0.0",
4
+ "version": "13.0.3",
5
5
  "main": "lib/index.js",
6
6
  "author": "OECD",
7
7
  "license": "MIT",
@@ -121,8 +121,6 @@ export const enhanceObservations = (dimensions = [], observations = {}, attribut
121
121
  R.props(options.attributesIds || [])
122
122
  )(_attributes);
123
123
 
124
- const seriesDimensions = R.filter(R.pipe(R.propOr([], 'values'), R.length, R.lt(1)), dimensions);
125
-
126
124
  return R.mapObjIndexed(
127
125
  (observation) => {
128
126
  const { attrValuesIndexes, dimValuesIndexes } = observation;
@@ -154,7 +152,7 @@ export const enhanceObservations = (dimensions = [], observations = {}, attribut
154
152
  attributes: obsAttributes,
155
153
  formattedValue: formatValue(observation, formatAttributesIndexes, attributes),
156
154
  orderedDimIndexes: getOrderedDimensionsIndexes(dimensions, dimValuesIndexes),
157
- units: getObservationUnits(observation, seriesDimensions, _attributes, options),
155
+ units: getObservationUnits(observation, dimensions, _attributes, options),
158
156
  indexedDimValIds,
159
157
  });
160
158
  },
@@ -17,7 +17,7 @@ const getAttributeRegisters = (attribute, parsedDimensionsIds, customAttributes)
17
17
  if (R.propEq('id', customAttributes.decimals, attribute)) {
18
18
  return [registerAttrId(['decimals'], attribute.id), registerAttr(attribute)];
19
19
  }
20
- if (R.hasPath(['relationship', 'none'], attribute)) {
20
+ if (R.hasPath(['relationship', 'none'], attribute) || R.hasPath(['relationship', 'dataflow'], attribute)) {
21
21
  return [registerAttrId(['dataflow'], attribute.id), registerAttr(attribute)];
22
22
  }
23
23
  if (R.pathEq(['relationship', 'primaryMeasure'], 'OBS_VALUE', attribute) || R.hasPath(['relationship', 'observation'], attribute)) {
@@ -81,8 +81,7 @@ export const prepareData = (sdmxJson, customAttributes, unitsProps={}) => {
81
81
  const observationsAttributesIds = R.propOr([], 'observations', attributesIdsIndexedByTargets);
82
82
  const obsUnitsIds = R.pipe(
83
83
  ({ attributes, dimensions }) => R.merge(attributes.series || {}, dimensions.series || {}),
84
- R.values,
85
- R.pluck('id')
84
+ R.keys
86
85
  )(unitsArtefacts);
87
86
  const options = {
88
87
  attachmentSeriesIndexes,
@@ -156,7 +155,8 @@ export const prepareData = (sdmxJson, customAttributes, unitsProps={}) => {
156
155
 
157
156
  const dataflowAdvancedAttributes = getDataflowAdvancedAttributes(
158
157
  headerAttributes,
159
- oneValueDimensions,
158
+ //oneValueDimensions,
159
+ R.pick(R.keys(parsedDimensionsIds.oneValue), dimensionsIndexedByIds),
160
160
  headerAdvancedAttrIds,
161
161
  R.length(dimensions)
162
162
  );
@@ -102,9 +102,18 @@ export const dataTransformer = (dataNew, options = {}) => {
102
102
  roles: !R.isNil(observation.role) ? R.head(observation.role) : null,
103
103
  }), attrObservations);
104
104
 
105
+ const datasetAttributes = R.map(
106
+ (attr) => ({
107
+ ...attr,
108
+ name: getLocalisedProp('names', observation),
109
+ values: getValues(attr.values || [])
110
+ }),
111
+ R.propOr([], 'dataSet', attributes)
112
+ )
113
+
105
114
  const resAttributes = {
106
115
  ...attributes,
107
- observation: resAttrObservations,
116
+ observation: R.concat(resAttrObservations, datasetAttributes)
108
117
  };
109
118
 
110
119
  //----------------------------------------------------------------------------------------Dimensions
@@ -26,7 +26,7 @@ export const getDataflowAdvancedAttributes = (attributes, dimensions, advancedAt
26
26
  coordinates = { ...coordinates, [dId]: vId };
27
27
  key = R.set(R.lensIndex(dIndex), 0)(key);
28
28
  },
29
- attrDimensions
29
+ R.reject(R.isNil, attrDimensions)
30
30
  );
31
31
  }
32
32
 
@@ -27,7 +27,9 @@ const attributes = [
27
27
  { id: 'a17', relationship: { primaryMeasure: 'OBS_VALUE' }, values: [{ id: 'a17v1' }] }, // blacklisted
28
28
  { id: 'a18', relationship: { primaryMeasure: 'OBS_VALUE' }, values: [{ id: 'a18v1' }, { id: 'a18v2' }] }, // blacklisted value
29
29
  { id: 'a19', relationship: { none: {} }, values: [{ id: 'a19v1' }] }, // dataset relationship
30
- { id: 'a20', relationship: { primaryMeasure: 'OBS_VALUE' }, values: [{ id: 'a20v1' }] } // units attribute
30
+ { id: 'a20', relationship: { primaryMeasure: 'OBS_VALUE' }, values: [{ id: 'a20v1' }] }, // units attribute
31
+ { id: 'a21', relationship: { dataflow: {} }, values: [{ id: 'a21v0' }] }, // alternative dataflow relationship
32
+ { id: 'a22', relationship: { observation: {} }, values: [{ id: 'a22v0' }] }, // alternative observation relationship
31
33
  ];
32
34
 
33
35
  const customAttributes = {
@@ -58,13 +60,15 @@ describe('parseAttributes test', () => {
58
60
  a15: { id: 'a15', index: 15, relationship: { dimensions: ['d3'] }, values: [{ id: 'a15v1' }] },
59
61
  a16: { id: 'a16', index: 16, relationship: { dimensions: ['d6'] }, values: [{ id: 'a16v1' }] },
60
62
  a18: { id: 'a18', index: 18, relationship: { primaryMeasure: 'OBS_VALUE' }, values: [{ id: 'a18v1' }, null] },
61
- a19: { id: 'a19', index: 19, relationship: { none: {} }, values: [{ id: 'a19v1' }] }
63
+ a19: { id: 'a19', index: 19, relationship: { none: {} }, values: [{ id: 'a19v1' }] },
64
+ a21: { id: 'a21', index: 21, relationship: { dataflow: {} }, values: [{ id: 'a21v0' }] },
65
+ a22: { id: 'a22', index: 22, relationship: { observation: {} }, values: [{ id: 'a22v0' }] },
62
66
  },
63
67
  attributesIdsIndexedByTargets: {
64
- observations: ['a6', 'a18'],
68
+ observations: ['a6', 'a18', 'a22'],
65
69
  oneValueDimensions: { d1: ['a8', 'a14'] },
66
70
  manyValuesDimensions: ['a9', 'a11'],
67
- dataflow: ['a10', 'a19'],
71
+ dataflow: ['a10', 'a19', 'a21'],
68
72
  series: ['a12', 'a13'],
69
73
  prefscale: ['a15'],
70
74
  decimals: ['a16'],
@@ -33,7 +33,7 @@ describe('table preparators performance tests', () => {
33
33
  OBS_STATUS: { id: 'OBS_STATUS', values: { A: 'A' } },
34
34
  UNIT_MULT: { id: 'UNIT_MULT', values: { '0': '0' } }
35
35
  },
36
- unitsIds: ['UNIT_MEASURE', 'UNIT_MULT', 'BASE_PER']
36
+ unitsIds: ['UNIT_MULT', 'BASE_PER']
37
37
  };
38
38
  expect(
39
39
  enhanceObservations(multiHierRowsDim, multiHierRowsObs, multiHierRowsAttr, options)