@barchart/portfolio-api-common 1.0.99 → 1.0.100

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.
@@ -145,10 +145,13 @@ module.exports = (() => {
145
145
  return list;
146
146
  }, [ ]);
147
147
 
148
- const missingGroups = array.difference(levelDefinition.requiredGroups.map(group => group.description), populatedGroups.map(group => group.description));
148
+ const missingGroups = array.difference(levelDefinition.requiredGroups.map(group => group.key), populatedGroups.map(group => group.key))
149
+ .map((key) => {
150
+ return levelDefinition.requiredGroups.find(g => g.key === key);
151
+ });
149
152
 
150
- const empty = missingGroups.map((description) => {
151
- return new PositionGroup(this, parent, [ ], levelDefinition.requiredGroups.find(group => group.description === description).currency, null, description);
153
+ const empty = missingGroups.map((group) => {
154
+ return new PositionGroup(this, parent, [ ], group.currency, group.key, group.description);
152
155
  });
153
156
 
154
157
  const compositeGroups = populatedGroups.concat(empty);
@@ -31,9 +31,10 @@ module.exports = (() => {
31
31
 
32
32
  this._dataFormat = { };
33
33
  this._dataActual = { };
34
-
34
+
35
+ this._dataFormat.key = this._key;
35
36
  this._dataFormat.description = this._description;
36
-
37
+
37
38
  this._dataActual.currentPrice = null;
38
39
  this._dataActual.previousPrice = null;
39
40
  this._dataActual.basis = null;
@@ -14,7 +14,7 @@ module.exports = (() => {
14
14
  * @param {PositionLevelDefinition~keySelector} keySelector
15
15
  * @param {PositionLevelDefinition~descriptionSelector} descriptionSelector
16
16
  * @param {PositionLevelDefinition~currencySelector} currencySelector
17
- * @param {Array.<String>=} requiredGroups
17
+ * @param {Array.<PositionLevelDefinition~RequiredGroup>=} requiredGroups
18
18
  * @param {Boolean=} single
19
19
  */
20
20
  class PositionLevelDefinition {
@@ -139,5 +139,16 @@ module.exports = (() => {
139
139
  * @returns {Currency}
140
140
  */
141
141
 
142
+ /**
143
+ * The data required to construct a group.
144
+ *
145
+ * @public
146
+ * @typedef PositionLevelDefinition~RequiredGroup
147
+ * @type {Object}
148
+ * @property {String} key
149
+ * @property {String} description
150
+ * @property {Currency} currency
151
+ */
152
+
142
153
  return PositionLevelDefinition;
143
154
  })();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barchart/portfolio-api-common",
3
- "version": "1.0.99",
3
+ "version": "1.0.100",
4
4
  "description": "Common classes used by the Portfolio system",
5
5
  "author": {
6
6
  "name": "Bryan Ingle",
@@ -861,10 +861,13 @@ module.exports = (() => {
861
861
  return list;
862
862
  }, [ ]);
863
863
 
864
- const missingGroups = array.difference(levelDefinition.requiredGroups.map(group => group.description), populatedGroups.map(group => group.description));
864
+ const missingGroups = array.difference(levelDefinition.requiredGroups.map(group => group.key), populatedGroups.map(group => group.key))
865
+ .map((key) => {
866
+ return levelDefinition.requiredGroups.find(g => g.key === key);
867
+ });
865
868
 
866
- const empty = missingGroups.map((description) => {
867
- return new PositionGroup(this, parent, [ ], levelDefinition.requiredGroups.find(group => group.description === description).currency, null, description);
869
+ const empty = missingGroups.map((group) => {
870
+ return new PositionGroup(this, parent, [ ], group.currency, group.key, group.description);
868
871
  });
869
872
 
870
873
  const compositeGroups = populatedGroups.concat(empty);
@@ -1035,9 +1038,10 @@ module.exports = (() => {
1035
1038
 
1036
1039
  this._dataFormat = { };
1037
1040
  this._dataActual = { };
1038
-
1041
+
1042
+ this._dataFormat.key = this._key;
1039
1043
  this._dataFormat.description = this._description;
1040
-
1044
+
1041
1045
  this._dataActual.currentPrice = null;
1042
1046
  this._dataActual.previousPrice = null;
1043
1047
  this._dataActual.basis = null;
@@ -1578,7 +1582,7 @@ module.exports = (() => {
1578
1582
  * @param {PositionLevelDefinition~keySelector} keySelector
1579
1583
  * @param {PositionLevelDefinition~descriptionSelector} descriptionSelector
1580
1584
  * @param {PositionLevelDefinition~currencySelector} currencySelector
1581
- * @param {Array.<String>=} requiredGroups
1585
+ * @param {Array.<PositionLevelDefinition~RequiredGroup>=} requiredGroups
1582
1586
  * @param {Boolean=} single
1583
1587
  */
1584
1588
  class PositionLevelDefinition {
@@ -1703,6 +1707,17 @@ module.exports = (() => {
1703
1707
  * @returns {Currency}
1704
1708
  */
1705
1709
 
1710
+ /**
1711
+ * The data required to construct a group.
1712
+ *
1713
+ * @public
1714
+ * @typedef PositionLevelDefinition~RequiredGroup
1715
+ * @type {Object}
1716
+ * @property {String} key
1717
+ * @property {String} description
1718
+ * @property {Currency} currency
1719
+ */
1720
+
1706
1721
  return PositionLevelDefinition;
1707
1722
  })();
1708
1723