@barchart/portfolio-client-js 1.1.12 → 1.1.15

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.
@@ -27,8 +27,8 @@
27
27
 
28
28
  that.gateway = null;
29
29
 
30
- that.user = ko.observable('a887b0b1-f7ea-412c-9ffa-3b7f6f6608cc');
31
- that.userLegacy = ko.observable('12153194');
30
+ that.user = ko.observable('4a896279-ad66-4fba-9239-8124dc1d3967');
31
+ that.userLegacy = ko.observable('10000120');
32
32
 
33
33
  that.connected = ko.observable(false);
34
34
  that.connecting = ko.observable(false);
@@ -158,7 +158,13 @@
158
158
  var readPositionSummaries = function() {
159
159
  var action = 'portfolioGateway.readPositionSummaries()';
160
160
 
161
- that.gateway.readPositionSummaries(that.portfolio() || null, that.position() || null)
161
+ var query = {
162
+ portfolio: that.portfolio() || null,
163
+ position: that.position() || null,
164
+ frame: 'YEARLY'
165
+ };
166
+
167
+ that.gateway.readPositionSummaries(query)
162
168
  .then((data) => {
163
169
  writeConsoleText(action, true);
164
170
  writeConsoleObject(data);
@@ -238,17 +244,16 @@
238
244
  });
239
245
  };
240
246
  var createBuyTransaction = function() {
241
- var action = 'portfolioGateway.readTransactions()';
242
-
243
- var portfolio = that.portfolio();
244
- var position = that.position();
247
+ var action = 'portfolioGateway.createTransaction()';
245
248
 
246
- if (!portfolio) {
249
+ if (!that.portfolio()) {
247
250
  toastr.info('A "portfolio" is required.');
248
251
  return;
249
252
  }
250
253
 
251
254
  var transaction = {
255
+ portfolio: that.portfolio(),
256
+ position: that.position() || null,
252
257
  type: Barchart.TransactionType.BUY,
253
258
  instrument: {
254
259
  name: 'International Business Machines',
@@ -265,7 +270,42 @@
265
270
  fee: Barchart.Decimal.ZERO
266
271
  };
267
272
 
268
- that.gateway.createTransaction(that.portfolio(), that.position() || null, transaction)
273
+ that.gateway.createTransaction(transaction)
274
+ .then((data) => {
275
+ writeConsoleText(action, true);
276
+ writeConsoleObject(data);
277
+ }).catch((e) => {
278
+ writeConsoleText(action, true);
279
+ writeConsoleObject(e);
280
+
281
+ that.setConsoleMode();
282
+ });
283
+ };
284
+ var createSellTransaction = function() {
285
+ var action = 'portfolioGateway.createTransaction()';
286
+
287
+ if (!that.portfolio()) {
288
+ toastr.info('A "portfolio" is required.');
289
+ return;
290
+ }
291
+
292
+ if (!that.position()) {
293
+ toastr.info('A "position" is required.');
294
+ return;
295
+ }
296
+
297
+ var transaction = {
298
+ portfolio: that.portfolio(),
299
+ position: that.position(),
300
+ type: Barchart.TransactionType.SELL,
301
+ currency: Barchart.Currency.CAD,
302
+ date: Barchart.Day.getToday(),
303
+ price: Barchart.Decimal.parse(5),
304
+ quantity: Barchart.Decimal.parse(100),
305
+ fee: Barchart.Decimal.ZERO
306
+ };
307
+
308
+ that.gateway.createTransaction(transaction)
269
309
  .then((data) => {
270
310
  writeConsoleText(action, true);
271
311
  writeConsoleObject(data);
@@ -317,6 +357,7 @@
317
357
  { text: 'Get Transactions', action: getTransactions },
318
358
  { text: 'Get Transactions (Formatted)', action: getTransactionsFormatted },
319
359
  { text: 'Create Buy Transaction', action: createBuyTransaction },
360
+ { text: 'Create Sell Transaction', action: createSellTransaction },
320
361
  { text: 'Delete Transaction', action: deleteTransaction }
321
362
  ]);
322
363
 
@@ -355,7 +396,7 @@
355
396
 
356
397
  that.connecting(true);
357
398
 
358
- Barchart.Portfolio.PortfolioGateway.forLocal(Barchart.Portfolio.JwtGateway.forDevelopmentClient(that.user(), that.userLegacy()))
399
+ Barchart.Portfolio.PortfolioGateway.forDevelopment(Barchart.Portfolio.JwtGateway.forDevelopmentClient(that.user(), that.userLegacy()))
359
400
  .then((gateway) => {
360
401
  that.gateway = gateway;
361
402
 
@@ -26,7 +26,7 @@ module.exports = function () {
26
26
  window.Barchart.ValuationType = ValuationType;
27
27
  }();
28
28
 
29
- },{"@barchart/common-js/lang/Currency":28,"@barchart/common-js/lang/Day":29,"@barchart/common-js/lang/Decimal":30,"@barchart/common-js/lang/Timezones":35,"@barchart/portfolio-api-common/lib/data/TransactionType":51,"@barchart/portfolio-api-common/lib/data/ValuationType":52,"@barchart/tgam-jwt-js/lib/JwtGateway":55}],2:[function(require,module,exports){
29
+ },{"@barchart/common-js/lang/Currency":28,"@barchart/common-js/lang/Day":29,"@barchart/common-js/lang/Decimal":30,"@barchart/common-js/lang/Timezones":35,"@barchart/portfolio-api-common/lib/data/TransactionType":52,"@barchart/portfolio-api-common/lib/data/ValuationType":53,"@barchart/tgam-jwt-js/lib/JwtGateway":57}],2:[function(require,module,exports){
30
30
  'use strict';
31
31
 
32
32
  var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
@@ -121,6 +121,7 @@ var assert = require('@barchart/common-js/lang/assert'),
121
121
  var TransactionType = require('@barchart/portfolio-api-common/lib/data/TransactionType');
122
122
 
123
123
  var PortfolioSchema = require('@barchart/portfolio-api-common/lib/serialization/PortfolioSchema'),
124
+ PositionSummarySchema = require('@barchart/portfolio-api-common/lib/serialization/PositionSummarySchema'),
124
125
  TransactionSchema = require('@barchart/portfolio-api-common/lib/serialization/TransactionSchema');
125
126
 
126
127
  var EndpointBuilder = require('@barchart/common-js/api/http/builders/EndpointBuilder'),
@@ -193,9 +194,7 @@ module.exports = function () {
193
194
  pb.withLiteralParameter('portfolios', 'portfolios').withVariableParameter('portfolio', 'portfolio', 'portfolio', false).withLiteralParameter('summaries', 'summaries').withVariableParameter('position', 'position', 'position', false);
194
195
  }).withQueryBuilder(function (qb) {
195
196
  qb.withVariableParameter('frame', 'frame', 'frame', true).withVariableParameter('start', 'start', 'start', true).withVariableParameter('end', 'end', 'end', true);
196
- }).withRequestInterceptor(requestInterceptorToUse)
197
- // .withResponseInterceptor(responseInterceptorForPositionDeserialization)
198
- .withErrorInterceptor(ErrorInterceptor.GENERAL).endpoint;
197
+ }).withRequestInterceptor(RequestInterceptor.PLAIN_TEXT_RESPONSE).withRequestInterceptor(requestInterceptorToUse).withResponseInterceptor(responseInterceptorForPositionSummaryDeserialization).withErrorInterceptor(ErrorInterceptor.GENERAL).endpoint;
199
198
 
200
199
  _this._deletePortfoliosEndpoint = EndpointBuilder.for('delete-portfolio', 'delete portfolios').withVerb(VerbType.DELETE).withProtocol(protocolType).withHost(host).withPort(port).withPathBuilder(function (pb) {
201
200
  pb.withLiteralParameter('portfolios', 'portfolios').withVariableParameter('portfolio', 'portfolio', 'portfolio', false).withLiteralParameter('positions', 'positions').withVariableParameter('position', 'position', 'position', false);
@@ -209,7 +208,7 @@ module.exports = function () {
209
208
 
210
209
  _this._createTransactionEndpoint = EndpointBuilder.for('create-transaction', 'create transaction').withVerb(VerbType.POST).withProtocol(protocolType).withHost(host).withPort(port).withPathBuilder(function (pb) {
211
210
  pb.withLiteralParameter('portfolios', 'portfolios').withVariableParameter('portfolio', 'portfolio', 'portfolio', false).withLiteralParameter('positions', 'positions').withVariableParameter('position', 'position', 'position', false).withLiteralParameter('transactions', 'transactions');
212
- }).withBody('portfolio data').withRequestInterceptor(RequestInterceptor.fromDelegate(createTransactionRequestInterceptor)).withRequestInterceptor(requestInterceptorToUse).withResponseInterceptor(responseInterceptorForPortfolioDeserialization).withErrorInterceptor(ErrorInterceptor.GENERAL).endpoint;
211
+ }).withBody('portfolio data').withRequestInterceptor(RequestInterceptor.PLAIN_TEXT_RESPONSE).withRequestInterceptor(requestInterceptorToUse).withResponseInterceptor(responseInterceptorForTransactionDeserialization).withErrorInterceptor(ErrorInterceptor.GENERAL).endpoint;
213
212
 
214
213
  _this._deleteTransactionsEndpoint = EndpointBuilder.for('read-transactions', 'read transactions').withVerb(VerbType.DELETE).withProtocol(protocolType).withHost(host).withPort(port).withPathBuilder(function (pb) {
215
214
  pb.withLiteralParameter('portfolios', 'portfolios').withVariableParameter('portfolio', 'portfolio', 'portfolio', false).withLiteralParameter('positions', 'positions').withVariableParameter('position', 'position', 'position', false).withLiteralParameter('transactions', 'transactions').withVariableParameter('transaction', 'transaction', 'transaction', false);
@@ -375,18 +374,25 @@ module.exports = function () {
375
374
 
376
375
  }, {
377
376
  key: 'readPositionSummaries',
378
- value: function readPositionSummaries(portfolio, position) {
377
+ value: function readPositionSummaries(data) {
379
378
  var _this8 = this;
380
379
 
381
380
  return Promise.resolve().then(function () {
382
381
  checkStart.call(_this8);
383
382
 
384
- // console
383
+ assert.argumentIsRequired(data, 'data', Object);
384
+ assert.argumentIsOptional(data.portfolio, 'portfolio', String);
385
+ assert.argumentIsOptional(data.position, 'position', String);
385
386
 
386
- assert.argumentIsOptional(portfolio, 'portfolio', String);
387
- assert.argumentIsOptional(position, 'position', String);
387
+ var query = {
388
+ portfolio: data.portfolio || '*',
389
+ position: data.position || '*',
390
+ frame: data.frame,
391
+ start: data.start,
392
+ end: data.end
393
+ };
388
394
 
389
- return Gateway.invoke(_this8._readPositionSummariesEndpoint, { portfolio: portfolio || '*', position: position || '*' });
395
+ return Gateway.invoke(_this8._readPositionSummariesEndpoint, query);
390
396
  });
391
397
  }
392
398
 
@@ -444,7 +450,9 @@ module.exports = function () {
444
450
  transaction.position = 'new';
445
451
  }
446
452
 
447
- return Gateway.invoke(_this10._createTransactionEndpoint, TransactionSchema.forCreate(transaction.type));
453
+ var schema = TransactionSchema.forCreate(transaction.type);
454
+
455
+ return Gateway.invoke(_this10._createTransactionEndpoint, schema.schema.format(transaction));
448
456
  });
449
457
  }
450
458
 
@@ -605,27 +613,9 @@ module.exports = function () {
605
613
  });
606
614
  };
607
615
 
608
- var createTransactionRequestInterceptor = function createTransactionRequestInterceptor(request) {
609
- var transactionData = request.data.transaction;
610
-
611
- return Promise.resolve().then(function () {
612
- var schema = TransactionSchema.fromCode(TransactionSchema, transactionData.type.code);
613
-
614
- return FailureReason.validateSchema(schema, transactionData);
615
- }).then(function () {
616
- request.data = transactionData;
617
-
618
- return Promise.resolve(request);
619
- }).catch(function (e) {
620
- console.error('Error serializing data to create a transaction', e);
621
-
622
- return Promise.reject();
623
- });
624
- };
625
-
626
616
  var responseInterceptorForPortfolioDeserialization = ResponseInterceptor.fromDelegate(function (response, ignored) {
627
617
  try {
628
- return JSON.parse(response.data, PortfolioSchema.COMPLETE.schema.getReviver());
618
+ return JSON.parse(response.data, PortfolioSchema.CLIENT.schema.getReviver());
629
619
  } catch (e) {
630
620
  console.log(e);
631
621
  }
@@ -635,8 +625,22 @@ module.exports = function () {
635
625
  return response.data;
636
626
  });
637
627
 
628
+ var responseInterceptorForPositionSummaryDeserialization = ResponseInterceptor.fromDelegate(function (response, ignored) {
629
+ try {
630
+ return JSON.parse(response.data, PositionSummarySchema.CLIENT.schema.getReviver());
631
+ } catch (e) {
632
+ console.log(e);
633
+ }
634
+ });
635
+
638
636
  var responseInterceptorForTransactionDeserialization = ResponseInterceptor.fromDelegate(function (response, ignored) {
639
- return JSON.parse(response.data, TransactionSchema.COMPLETE.schema.getReviver());
637
+ try {
638
+ return TransactionSchema.CLIENT.schema.revive(response.data);
639
+
640
+ return JSON.parse(response.data, TransactionSchema.CLIENT.schema.getReviver());
641
+ } catch (e) {
642
+ console.error('Error serializing transaction data', e);
643
+ }
640
644
  });
641
645
 
642
646
  function start(gateway) {
@@ -658,7 +662,7 @@ module.exports = function () {
658
662
  return PortfolioGateway;
659
663
  }();
660
664
 
661
- },{"./../common/Configuration":2,"@barchart/common-js/api/failures/FailureReason":6,"@barchart/common-js/api/http/Gateway":9,"@barchart/common-js/api/http/builders/EndpointBuilder":10,"@barchart/common-js/api/http/definitions/ProtocolType":15,"@barchart/common-js/api/http/definitions/VerbType":16,"@barchart/common-js/api/http/interceptors/ErrorInterceptor":20,"@barchart/common-js/api/http/interceptors/RequestInterceptor":21,"@barchart/common-js/api/http/interceptors/ResponseInterceptor":22,"@barchart/common-js/lang/Disposable":31,"@barchart/common-js/lang/Enum":32,"@barchart/common-js/lang/assert":37,"@barchart/common-js/lang/is":40,"@barchart/portfolio-api-common/lib/data/TransactionType":51,"@barchart/portfolio-api-common/lib/serialization/PortfolioSchema":53,"@barchart/portfolio-api-common/lib/serialization/TransactionSchema":54}],4:[function(require,module,exports){
665
+ },{"./../common/Configuration":2,"@barchart/common-js/api/failures/FailureReason":6,"@barchart/common-js/api/http/Gateway":9,"@barchart/common-js/api/http/builders/EndpointBuilder":10,"@barchart/common-js/api/http/definitions/ProtocolType":15,"@barchart/common-js/api/http/definitions/VerbType":16,"@barchart/common-js/api/http/interceptors/ErrorInterceptor":20,"@barchart/common-js/api/http/interceptors/RequestInterceptor":21,"@barchart/common-js/api/http/interceptors/ResponseInterceptor":22,"@barchart/common-js/lang/Disposable":31,"@barchart/common-js/lang/Enum":32,"@barchart/common-js/lang/assert":37,"@barchart/common-js/lang/is":40,"@barchart/portfolio-api-common/lib/data/TransactionType":52,"@barchart/portfolio-api-common/lib/serialization/PortfolioSchema":54,"@barchart/portfolio-api-common/lib/serialization/PositionSummarySchema":55,"@barchart/portfolio-api-common/lib/serialization/TransactionSchema":56}],4:[function(require,module,exports){
662
666
  'use strict';
663
667
 
664
668
  var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
@@ -971,7 +975,7 @@ module.exports = function () {
971
975
  return {
972
976
  JwtGateway: JwtGateway,
973
977
  PortfolioGateway: PortfolioGateway,
974
- version: '1.1.12'
978
+ version: '1.1.15'
975
979
  };
976
980
  }();
977
981
 
@@ -1708,7 +1712,7 @@ module.exports = function () {
1708
1712
  return Gateway;
1709
1713
  }();
1710
1714
 
1711
- },{"./../../lang/array":36,"./../../lang/assert":37,"./../../lang/attributes":38,"./../../lang/promise":42,"./../failures/FailureReason":6,"./../failures/FailureType":8,"./definitions/Endpoint":12,"./definitions/VerbType":16,"axios":56}],10:[function(require,module,exports){
1715
+ },{"./../../lang/array":36,"./../../lang/assert":37,"./../../lang/attributes":38,"./../../lang/promise":42,"./../failures/FailureReason":6,"./../failures/FailureType":8,"./definitions/Endpoint":12,"./definitions/VerbType":16,"axios":59}],10:[function(require,module,exports){
1712
1716
  'use strict';
1713
1717
 
1714
1718
  var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
@@ -5585,7 +5589,7 @@ module.exports = function () {
5585
5589
  return Decimal;
5586
5590
  }();
5587
5591
 
5588
- },{"./Enum":32,"./assert":37,"./is":40,"big.js":81}],31:[function(require,module,exports){
5592
+ },{"./Enum":32,"./assert":37,"./is":40,"big.js":84}],31:[function(require,module,exports){
5589
5593
  'use strict';
5590
5594
 
5591
5595
  var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
@@ -6122,7 +6126,7 @@ module.exports = function () {
6122
6126
  return Timestamp;
6123
6127
  }();
6124
6128
 
6125
- },{"./assert":37,"./is":40,"moment-timezone":86}],35:[function(require,module,exports){
6129
+ },{"./assert":37,"./is":40,"moment-timezone":89}],35:[function(require,module,exports){
6126
6130
  'use strict';
6127
6131
 
6128
6132
  var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
@@ -7565,7 +7569,7 @@ module.exports = function () {
7565
7569
  };
7566
7570
  }();
7567
7571
 
7568
- },{"./assert":37,"moment-timezone/builds/moment-timezone-with-data-2010-2020":84}],44:[function(require,module,exports){
7572
+ },{"./assert":37,"moment-timezone/builds/moment-timezone-with-data-2010-2020":87}],44:[function(require,module,exports){
7569
7573
  'use strict';
7570
7574
 
7571
7575
  var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
@@ -8041,7 +8045,7 @@ module.exports = function () {
8041
8045
  return DataType;
8042
8046
  }();
8043
8047
 
8044
- },{"./../../lang/AdHoc":27,"./../../lang/Day":29,"./../../lang/Decimal":30,"./../../lang/Enum":32,"./../../lang/Timestamp":34,"./../../lang/assert":37,"./../../lang/is":40,"moment":88}],46:[function(require,module,exports){
8048
+ },{"./../../lang/AdHoc":27,"./../../lang/Day":29,"./../../lang/Decimal":30,"./../../lang/Enum":32,"./../../lang/Timestamp":34,"./../../lang/assert":37,"./../../lang/is":40,"moment":91}],46:[function(require,module,exports){
8045
8049
  'use strict';
8046
8050
 
8047
8051
  var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
@@ -8974,6 +8978,154 @@ module.exports = function () {
8974
8978
  }();
8975
8979
 
8976
8980
  },{"./../lang/Disposable":31,"./../lang/assert":37,"./../lang/is":40,"./../lang/object":41,"./../lang/promise":42}],51:[function(require,module,exports){
8981
+ const array = require('@barchart/common-js/lang/array'),
8982
+ assert = require('@barchart/common-js/lang/assert'),
8983
+ Day = require('@barchart/common-js/lang/Day'),
8984
+ Enum = require('@barchart/common-js/lang/Enum'),
8985
+ is = require('@barchart/common-js/lang/is');
8986
+
8987
+ module.exports = (() => {
8988
+ 'use strict';
8989
+
8990
+ /**
8991
+ * An enumeration used to define timeframes for position summaries.
8992
+ *
8993
+ * @public
8994
+ * @extends {Enum}
8995
+ * @param {String} code
8996
+ * @param {String} description
8997
+ * @param {Function} rangeCalculator
8998
+ */
8999
+ class PositionSummaryFrame extends Enum {
9000
+ constructor(code, description, rangeCalculator) {
9001
+ super(code, description);
9002
+
9003
+ assert.argumentIsRequired(rangeCalculator, 'rangeCalculator', Function);
9004
+
9005
+ this._rangeCalculator = rangeCalculator;
9006
+ }
9007
+
9008
+ getRanges(transactions) {
9009
+ assert.argumentIsArray(transactions, 'transactions');
9010
+
9011
+ return this._rangeCalculator(transactions);
9012
+ }
9013
+
9014
+ /**
9015
+ * A summary for a calendar year.
9016
+ *
9017
+ * @public
9018
+ * @returns {PositionSummaryFrame}
9019
+ */
9020
+ static get YEARLY() {
9021
+ return yearly;
9022
+ }
9023
+
9024
+ /**
9025
+ * A summary for a quarter.
9026
+ *
9027
+ * @public
9028
+ * @returns {PositionSummaryFrame}
9029
+ */
9030
+ static get QUARTERLY() {
9031
+ return quarterly;
9032
+ }
9033
+
9034
+ /**
9035
+ * A summary for a calendar month.
9036
+ *
9037
+ * @public
9038
+ * @returns {PositionSummaryFrame}
9039
+ */
9040
+ static get MONTHLY() {
9041
+ return monthly;
9042
+ }
9043
+
9044
+ /**
9045
+ * A summary the current year (to date).
9046
+ *
9047
+ * @public
9048
+ * @returns {PositionSummaryFrame}
9049
+ */
9050
+ static get YTD() {
9051
+ return ytd;
9052
+ }
9053
+
9054
+ toString() {
9055
+ return '[PositionSummaryFrame]';
9056
+ }
9057
+ }
9058
+
9059
+ const yearly = new PositionSummaryFrame('YEARLY', 'year', getYearlyRanges);
9060
+ const quarterly = new PositionSummaryFrame('QUARTER', 'quarter', getQuarterlyRanges);
9061
+ const monthly = new PositionSummaryFrame('MONTH', 'month', getMonthlyRanges);
9062
+ const ytd = new PositionSummaryFrame('YTD', 'year-to-date', getYearToDateRanges);
9063
+
9064
+ function getRange(start, end) {
9065
+ return {
9066
+ start: start,
9067
+ end: end
9068
+ };
9069
+ }
9070
+
9071
+ function getYearlyRanges(transactions) {
9072
+ const ranges = [ ];
9073
+
9074
+ if (transactions.length !== 0) {
9075
+ const first = array.first(transactions);
9076
+ const last = array.last(transactions);
9077
+
9078
+ const firstDate = first.date;
9079
+ const lastDate = last.date;
9080
+
9081
+ let lastYear;
9082
+
9083
+ if (last.snapshot.open.getIsZero()) {
9084
+ lastYear = last.date.year + 1;
9085
+ } else {
9086
+ lastYear = Day.getToday().year;
9087
+ }
9088
+
9089
+ for (let end = new Day(firstDate.year, 12, 31); end.year < lastYear; end = end.addYears(1)) {
9090
+ ranges.push(getRange(end.subtractYears(1), end));
9091
+ }
9092
+ }
9093
+
9094
+ return ranges;
9095
+ }
9096
+
9097
+ function getQuarterlyRanges(transactions) {
9098
+ return [ ];
9099
+ }
9100
+
9101
+ function getMonthlyRanges(transactions) {
9102
+ return [ ];
9103
+ }
9104
+
9105
+ function getYearToDateRanges(transactions) {
9106
+ const ranges = [ ];
9107
+
9108
+ if (transactions.length !== 0) {
9109
+ const first = array.first(transactions);
9110
+ const last = array.last(transactions);
9111
+
9112
+ const currentYear = Day.getToday().year;
9113
+
9114
+ if (!last.snapshot.open.getIsZero() || last.date.year === currentYear) {
9115
+ let end = new Day(Day.getToday().year, 12, 31);
9116
+ let start = end.subtractYears(1);
9117
+
9118
+ ranges.push(getRange(start, end));
9119
+ }
9120
+ }
9121
+
9122
+ return ranges;
9123
+ }
9124
+
9125
+ return PositionSummaryFrame;
9126
+ })();
9127
+
9128
+ },{"@barchart/common-js/lang/Day":29,"@barchart/common-js/lang/Enum":32,"@barchart/common-js/lang/array":36,"@barchart/common-js/lang/assert":37,"@barchart/common-js/lang/is":40}],52:[function(require,module,exports){
8977
9129
  const assert = require('@barchart/common-js/lang/assert'),
8978
9130
  Enum = require('@barchart/common-js/lang/Enum');
8979
9131
 
@@ -9300,7 +9452,7 @@ module.exports = (() => {
9300
9452
  return TransactionType;
9301
9453
  })();
9302
9454
 
9303
- },{"@barchart/common-js/lang/Enum":32,"@barchart/common-js/lang/assert":37}],52:[function(require,module,exports){
9455
+ },{"@barchart/common-js/lang/Enum":32,"@barchart/common-js/lang/assert":37}],53:[function(require,module,exports){
9304
9456
  const assert = require('@barchart/common-js/lang/assert'),
9305
9457
  Enum = require('@barchart/common-js/lang/Enum');
9306
9458
 
@@ -9362,7 +9514,7 @@ module.exports = (() => {
9362
9514
  return ValuationType;
9363
9515
  })();
9364
9516
 
9365
- },{"@barchart/common-js/lang/Enum":32,"@barchart/common-js/lang/assert":37}],53:[function(require,module,exports){
9517
+ },{"@barchart/common-js/lang/Enum":32,"@barchart/common-js/lang/assert":37}],54:[function(require,module,exports){
9366
9518
  const assert = require('@barchart/common-js/lang/assert'),
9367
9519
  Currency = require('@barchart/common-js/lang/Currency'),
9368
9520
  DataType = require('@barchart/common-js/serialization/json/DataType'),
@@ -9513,7 +9665,136 @@ module.exports = (() => {
9513
9665
  return PortfolioSchema;
9514
9666
  })();
9515
9667
 
9516
- },{"./../data/ValuationType":52,"@barchart/common-js/lang/Currency":28,"@barchart/common-js/lang/Enum":32,"@barchart/common-js/lang/Timezones":35,"@barchart/common-js/lang/assert":37,"@barchart/common-js/lang/is":40,"@barchart/common-js/serialization/json/DataType":45,"@barchart/common-js/serialization/json/Schema":47,"@barchart/common-js/serialization/json/builders/SchemaBuilder":49}],54:[function(require,module,exports){
9668
+ },{"./../data/ValuationType":53,"@barchart/common-js/lang/Currency":28,"@barchart/common-js/lang/Enum":32,"@barchart/common-js/lang/Timezones":35,"@barchart/common-js/lang/assert":37,"@barchart/common-js/lang/is":40,"@barchart/common-js/serialization/json/DataType":45,"@barchart/common-js/serialization/json/Schema":47,"@barchart/common-js/serialization/json/builders/SchemaBuilder":49}],55:[function(require,module,exports){
9669
+ const assert = require('@barchart/common-js/lang/assert'),
9670
+ Currency = require('@barchart/common-js/lang/Currency'),
9671
+ DataType = require('@barchart/common-js/serialization/json/DataType'),
9672
+ Enum = require('@barchart/common-js/lang/Enum'),
9673
+ is = require('@barchart/common-js/lang/is'),
9674
+ Schema = require('@barchart/common-js/serialization/json/Schema'),
9675
+ SchemaBuilder = require('@barchart/common-js/serialization/json/builders/SchemaBuilder');
9676
+
9677
+ const PositionSummaryFrame = require('./../data/PositionSummaryFrame');
9678
+
9679
+ module.exports = (() => {
9680
+ 'use strict';
9681
+
9682
+ /**
9683
+ * The schemas which can be used to represent position summary objects.
9684
+ *
9685
+ * @public
9686
+ * @extends {Enum}
9687
+ */
9688
+ class PositionSummarySchema extends Enum {
9689
+ constructor(schema) {
9690
+ super(schema.name, schema.name);
9691
+
9692
+ this._schema = schema;
9693
+ }
9694
+
9695
+ /**
9696
+ * The actual {@link Schema}.
9697
+ *
9698
+ * @public
9699
+ * @returns {Schema}
9700
+ */
9701
+ get schema() {
9702
+ return this._schema;
9703
+ }
9704
+
9705
+ /**
9706
+ * The complete position summary schema.
9707
+ *
9708
+ * @static
9709
+ * @public
9710
+ * @returns {PositionSummarySchema}
9711
+ */
9712
+ static get COMPLETE() {
9713
+ return complete;
9714
+ }
9715
+
9716
+ /**
9717
+ * Position summary data transmitted to the client, omitting some system data.
9718
+ *
9719
+ * @static
9720
+ * @public
9721
+ * @returns {PositionSummarySchema}
9722
+ */
9723
+ static get CLIENT() {
9724
+ return client;
9725
+ }
9726
+
9727
+ toString() {
9728
+ return '[PositionSummarySchema]';
9729
+ }
9730
+ }
9731
+
9732
+ const complete = new PositionSummarySchema(SchemaBuilder.withName('complete')
9733
+ .withField('user', DataType.STRING)
9734
+ .withField('portfolio', DataType.STRING)
9735
+ .withField('position', DataType.STRING)
9736
+ .withField('instrument.id', DataType.STRING)
9737
+ .withField('instrument.name', DataType.STRING)
9738
+ .withField('instrument.type', DataType.STRING)
9739
+ .withField('instrument.currency', DataType.forEnum(Currency, 'Currency'))
9740
+ .withField('instrument.delist', DataType.DAY, true)
9741
+ .withField('instrument.symbol.barchart', DataType.STRING, true)
9742
+ .withField('instrument.symbol.display', DataType.STRING, true)
9743
+ .withField('frame', DataType.forEnum(PositionSummaryFrame, 'PositionSummaryFrame'))
9744
+ .withField('start.date', DataType.DAY)
9745
+ .withField('start.sequence', DataType.NUMBER)
9746
+ .withField('start.open', DataType.DECIMAL)
9747
+ .withField('start.basis', DataType.DECIMAL)
9748
+ .withField('start.value', DataType.DECIMAL)
9749
+ .withField('end.date', DataType.DAY)
9750
+ .withField('end.sequence', DataType.NUMBER)
9751
+ .withField('end.open', DataType.DECIMAL)
9752
+ .withField('end.basis', DataType.DECIMAL)
9753
+ .withField('end.value', DataType.DECIMAL)
9754
+ .withField('period.buys', DataType.DECIMAL)
9755
+ .withField('period.sells', DataType.DECIMAL)
9756
+ .withField('period.income', DataType.DECIMAL)
9757
+ .withField('period.realized', DataType.DECIMAL)
9758
+ .withField('period.unrealized', DataType.DECIMAL)
9759
+ .withField('system.sequence', DataType.NUMBER)
9760
+ .withField('system.version', DataType.STRING)
9761
+ .schema
9762
+ );
9763
+
9764
+ const client = new PositionSummarySchema(SchemaBuilder.withName('client')
9765
+ .withField('user', DataType.STRING)
9766
+ .withField('portfolio', DataType.STRING)
9767
+ .withField('position', DataType.STRING)
9768
+ .withField('instrument.id', DataType.STRING)
9769
+ .withField('instrument.name', DataType.STRING)
9770
+ .withField('instrument.type', DataType.STRING)
9771
+ .withField('instrument.currency', DataType.forEnum(Currency, 'Currency'))
9772
+ .withField('instrument.delist', DataType.DAY, true)
9773
+ .withField('instrument.symbol.barchart', DataType.STRING, true)
9774
+ .withField('instrument.symbol.display', DataType.STRING, true)
9775
+ .withField('frame', DataType.forEnum(PositionSummaryFrame, 'PositionSummaryFrame'))
9776
+ .withField('start.date', DataType.DAY)
9777
+ .withField('start.sequence', DataType.NUMBER)
9778
+ .withField('start.open', DataType.DECIMAL)
9779
+ .withField('start.basis', DataType.DECIMAL)
9780
+ .withField('start.value', DataType.DECIMAL)
9781
+ .withField('end.date', DataType.DAY)
9782
+ .withField('end.sequence', DataType.NUMBER)
9783
+ .withField('end.open', DataType.DECIMAL)
9784
+ .withField('end.basis', DataType.DECIMAL)
9785
+ .withField('end.value', DataType.DECIMAL)
9786
+ .withField('period.buys', DataType.DECIMAL)
9787
+ .withField('period.sells', DataType.DECIMAL)
9788
+ .withField('period.income', DataType.DECIMAL)
9789
+ .withField('period.realized', DataType.DECIMAL)
9790
+ .withField('period.unrealized', DataType.DECIMAL)
9791
+ .schema
9792
+ );
9793
+
9794
+ return PositionSummarySchema;
9795
+ })();
9796
+
9797
+ },{"./../data/PositionSummaryFrame":51,"@barchart/common-js/lang/Currency":28,"@barchart/common-js/lang/Enum":32,"@barchart/common-js/lang/assert":37,"@barchart/common-js/lang/is":40,"@barchart/common-js/serialization/json/DataType":45,"@barchart/common-js/serialization/json/Schema":47,"@barchart/common-js/serialization/json/builders/SchemaBuilder":49}],56:[function(require,module,exports){
9517
9798
  const assert = require('@barchart/common-js/lang/assert'),
9518
9799
  is = require('@barchart/common-js/lang/is'),
9519
9800
  Currency = require('@barchart/common-js/lang/Currency'),
@@ -9571,7 +9852,7 @@ module.exports = (() => {
9571
9852
  let schema;
9572
9853
 
9573
9854
  if (is.string(code)) {
9574
- schema = Enum.fromCode(code);
9855
+ schema = Enum.fromCode(TransactionSchema, code);
9575
9856
  } else {
9576
9857
  schema = null;
9577
9858
  }
@@ -9993,7 +10274,7 @@ module.exports = (() => {
9993
10274
  return TransactionSchema;
9994
10275
  })();
9995
10276
 
9996
- },{"./../data/TransactionType":51,"@barchart/common-js/lang/Currency":28,"@barchart/common-js/lang/Enum":32,"@barchart/common-js/lang/assert":37,"@barchart/common-js/lang/is":40,"@barchart/common-js/serialization/json/DataType":45,"@barchart/common-js/serialization/json/Schema":47,"@barchart/common-js/serialization/json/builders/SchemaBuilder":49}],55:[function(require,module,exports){
10277
+ },{"./../data/TransactionType":52,"@barchart/common-js/lang/Currency":28,"@barchart/common-js/lang/Enum":32,"@barchart/common-js/lang/assert":37,"@barchart/common-js/lang/is":40,"@barchart/common-js/serialization/json/DataType":45,"@barchart/common-js/serialization/json/Schema":47,"@barchart/common-js/serialization/json/builders/SchemaBuilder":49}],57:[function(require,module,exports){
9997
10278
  'use strict';
9998
10279
 
9999
10280
  var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
@@ -10020,6 +10301,8 @@ var EndpointBuilder = require('@barchart/common-js/api/http/builders/EndpointBui
10020
10301
  ResponseInterceptor = require('@barchart/common-js/api/http/interceptors/ResponseInterceptor'),
10021
10302
  VerbType = require('@barchart/common-js/api/http/definitions/VerbType');
10022
10303
 
10304
+ var version = require('./index').version;
10305
+
10023
10306
  module.exports = function () {
10024
10307
  'use strict';
10025
10308
 
@@ -10154,7 +10437,7 @@ module.exports = function () {
10154
10437
 
10155
10438
  cacheDisposable = null;
10156
10439
  cachePromise = null;
10157
- acheTime = null;
10440
+ cacheTime = null;
10158
10441
  }
10159
10442
 
10160
10443
  return Promise.reject(e);
@@ -10177,8 +10460,10 @@ module.exports = function () {
10177
10460
  }
10178
10461
 
10179
10462
  return tokenPromise.then(function (token) {
10463
+ var metadata = (cacheTime ? cacheTime.toString() : 'none') + '-' + getTime().toString() + '-' + version;
10464
+
10180
10465
  options.headers = options.headers || {};
10181
- options.headers.Authorization = 'Bearer ' + token;
10466
+ options.headers.Authorization = 'Bearer ' + token + ' Metadata ' + metadata;
10182
10467
 
10183
10468
  return options;
10184
10469
  }).catch(function (e) {
@@ -10342,9 +10627,23 @@ module.exports = function () {
10342
10627
  return JwtGateway;
10343
10628
  }();
10344
10629
 
10345
- },{"@barchart/common-js/api/failures/FailureReason":6,"@barchart/common-js/api/failures/FailureType":8,"@barchart/common-js/api/http/Gateway":9,"@barchart/common-js/api/http/builders/EndpointBuilder":10,"@barchart/common-js/api/http/definitions/Endpoint":12,"@barchart/common-js/api/http/definitions/ProtocolType":15,"@barchart/common-js/api/http/definitions/VerbType":16,"@barchart/common-js/api/http/interceptors/RequestInterceptor":21,"@barchart/common-js/api/http/interceptors/ResponseInterceptor":22,"@barchart/common-js/lang/Disposable":31,"@barchart/common-js/lang/Enum":32,"@barchart/common-js/lang/assert":37,"@barchart/common-js/lang/is":40,"@barchart/common-js/timing/Scheduler":50}],56:[function(require,module,exports){
10630
+ },{"./index":58,"@barchart/common-js/api/failures/FailureReason":6,"@barchart/common-js/api/failures/FailureType":8,"@barchart/common-js/api/http/Gateway":9,"@barchart/common-js/api/http/builders/EndpointBuilder":10,"@barchart/common-js/api/http/definitions/Endpoint":12,"@barchart/common-js/api/http/definitions/ProtocolType":15,"@barchart/common-js/api/http/definitions/VerbType":16,"@barchart/common-js/api/http/interceptors/RequestInterceptor":21,"@barchart/common-js/api/http/interceptors/ResponseInterceptor":22,"@barchart/common-js/lang/Disposable":31,"@barchart/common-js/lang/Enum":32,"@barchart/common-js/lang/assert":37,"@barchart/common-js/lang/is":40,"@barchart/common-js/timing/Scheduler":50}],58:[function(require,module,exports){
10631
+ 'use strict';
10632
+
10633
+ var JwtGateway = require('./JwtGateway');
10634
+
10635
+ module.exports = function () {
10636
+ 'use strict';
10637
+
10638
+ return {
10639
+ JwtGateway: JwtGateway,
10640
+ version: '1.0.38'
10641
+ };
10642
+ }();
10643
+
10644
+ },{"./JwtGateway":57}],59:[function(require,module,exports){
10346
10645
  module.exports = require('./lib/axios');
10347
- },{"./lib/axios":58}],57:[function(require,module,exports){
10646
+ },{"./lib/axios":61}],60:[function(require,module,exports){
10348
10647
  (function (process){
10349
10648
  'use strict';
10350
10649
 
@@ -10528,7 +10827,7 @@ module.exports = function xhrAdapter(config) {
10528
10827
  };
10529
10828
 
10530
10829
  }).call(this,require('_process'))
10531
- },{"../core/createError":64,"./../core/settle":67,"./../helpers/btoa":71,"./../helpers/buildURL":72,"./../helpers/cookies":74,"./../helpers/isURLSameOrigin":76,"./../helpers/parseHeaders":78,"./../utils":80,"_process":82}],58:[function(require,module,exports){
10830
+ },{"../core/createError":67,"./../core/settle":70,"./../helpers/btoa":74,"./../helpers/buildURL":75,"./../helpers/cookies":77,"./../helpers/isURLSameOrigin":79,"./../helpers/parseHeaders":81,"./../utils":83,"_process":85}],61:[function(require,module,exports){
10532
10831
  'use strict';
10533
10832
 
10534
10833
  var utils = require('./utils');
@@ -10582,7 +10881,7 @@ module.exports = axios;
10582
10881
  // Allow use of default import syntax in TypeScript
10583
10882
  module.exports.default = axios;
10584
10883
 
10585
- },{"./cancel/Cancel":59,"./cancel/CancelToken":60,"./cancel/isCancel":61,"./core/Axios":62,"./defaults":69,"./helpers/bind":70,"./helpers/spread":79,"./utils":80}],59:[function(require,module,exports){
10884
+ },{"./cancel/Cancel":62,"./cancel/CancelToken":63,"./cancel/isCancel":64,"./core/Axios":65,"./defaults":72,"./helpers/bind":73,"./helpers/spread":82,"./utils":83}],62:[function(require,module,exports){
10586
10885
  'use strict';
10587
10886
 
10588
10887
  /**
@@ -10603,7 +10902,7 @@ Cancel.prototype.__CANCEL__ = true;
10603
10902
 
10604
10903
  module.exports = Cancel;
10605
10904
 
10606
- },{}],60:[function(require,module,exports){
10905
+ },{}],63:[function(require,module,exports){
10607
10906
  'use strict';
10608
10907
 
10609
10908
  var Cancel = require('./Cancel');
@@ -10662,14 +10961,14 @@ CancelToken.source = function source() {
10662
10961
 
10663
10962
  module.exports = CancelToken;
10664
10963
 
10665
- },{"./Cancel":59}],61:[function(require,module,exports){
10964
+ },{"./Cancel":62}],64:[function(require,module,exports){
10666
10965
  'use strict';
10667
10966
 
10668
10967
  module.exports = function isCancel(value) {
10669
10968
  return !!(value && value.__CANCEL__);
10670
10969
  };
10671
10970
 
10672
- },{}],62:[function(require,module,exports){
10971
+ },{}],65:[function(require,module,exports){
10673
10972
  'use strict';
10674
10973
 
10675
10974
  var defaults = require('./../defaults');
@@ -10750,7 +11049,7 @@ utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
10750
11049
 
10751
11050
  module.exports = Axios;
10752
11051
 
10753
- },{"./../defaults":69,"./../utils":80,"./InterceptorManager":63,"./dispatchRequest":65}],63:[function(require,module,exports){
11052
+ },{"./../defaults":72,"./../utils":83,"./InterceptorManager":66,"./dispatchRequest":68}],66:[function(require,module,exports){
10754
11053
  'use strict';
10755
11054
 
10756
11055
  var utils = require('./../utils');
@@ -10804,7 +11103,7 @@ InterceptorManager.prototype.forEach = function forEach(fn) {
10804
11103
 
10805
11104
  module.exports = InterceptorManager;
10806
11105
 
10807
- },{"./../utils":80}],64:[function(require,module,exports){
11106
+ },{"./../utils":83}],67:[function(require,module,exports){
10808
11107
  'use strict';
10809
11108
 
10810
11109
  var enhanceError = require('./enhanceError');
@@ -10824,7 +11123,7 @@ module.exports = function createError(message, config, code, request, response)
10824
11123
  return enhanceError(error, config, code, request, response);
10825
11124
  };
10826
11125
 
10827
- },{"./enhanceError":66}],65:[function(require,module,exports){
11126
+ },{"./enhanceError":69}],68:[function(require,module,exports){
10828
11127
  'use strict';
10829
11128
 
10830
11129
  var utils = require('./../utils');
@@ -10912,7 +11211,7 @@ module.exports = function dispatchRequest(config) {
10912
11211
  });
10913
11212
  };
10914
11213
 
10915
- },{"../cancel/isCancel":61,"../defaults":69,"./../helpers/combineURLs":73,"./../helpers/isAbsoluteURL":75,"./../utils":80,"./transformData":68}],66:[function(require,module,exports){
11214
+ },{"../cancel/isCancel":64,"../defaults":72,"./../helpers/combineURLs":76,"./../helpers/isAbsoluteURL":78,"./../utils":83,"./transformData":71}],69:[function(require,module,exports){
10916
11215
  'use strict';
10917
11216
 
10918
11217
  /**
@@ -10935,7 +11234,7 @@ module.exports = function enhanceError(error, config, code, request, response) {
10935
11234
  return error;
10936
11235
  };
10937
11236
 
10938
- },{}],67:[function(require,module,exports){
11237
+ },{}],70:[function(require,module,exports){
10939
11238
  'use strict';
10940
11239
 
10941
11240
  var createError = require('./createError');
@@ -10963,7 +11262,7 @@ module.exports = function settle(resolve, reject, response) {
10963
11262
  }
10964
11263
  };
10965
11264
 
10966
- },{"./createError":64}],68:[function(require,module,exports){
11265
+ },{"./createError":67}],71:[function(require,module,exports){
10967
11266
  'use strict';
10968
11267
 
10969
11268
  var utils = require('./../utils');
@@ -10985,7 +11284,7 @@ module.exports = function transformData(data, headers, fns) {
10985
11284
  return data;
10986
11285
  };
10987
11286
 
10988
- },{"./../utils":80}],69:[function(require,module,exports){
11287
+ },{"./../utils":83}],72:[function(require,module,exports){
10989
11288
  (function (process){
10990
11289
  'use strict';
10991
11290
 
@@ -11081,7 +11380,7 @@ utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
11081
11380
  module.exports = defaults;
11082
11381
 
11083
11382
  }).call(this,require('_process'))
11084
- },{"./adapters/http":57,"./adapters/xhr":57,"./helpers/normalizeHeaderName":77,"./utils":80,"_process":82}],70:[function(require,module,exports){
11383
+ },{"./adapters/http":60,"./adapters/xhr":60,"./helpers/normalizeHeaderName":80,"./utils":83,"_process":85}],73:[function(require,module,exports){
11085
11384
  'use strict';
11086
11385
 
11087
11386
  module.exports = function bind(fn, thisArg) {
@@ -11094,7 +11393,7 @@ module.exports = function bind(fn, thisArg) {
11094
11393
  };
11095
11394
  };
11096
11395
 
11097
- },{}],71:[function(require,module,exports){
11396
+ },{}],74:[function(require,module,exports){
11098
11397
  'use strict';
11099
11398
 
11100
11399
  // btoa polyfill for IE<10 courtesy https://github.com/davidchambers/Base64.js
@@ -11132,7 +11431,7 @@ function btoa(input) {
11132
11431
 
11133
11432
  module.exports = btoa;
11134
11433
 
11135
- },{}],72:[function(require,module,exports){
11434
+ },{}],75:[function(require,module,exports){
11136
11435
  'use strict';
11137
11436
 
11138
11437
  var utils = require('./../utils');
@@ -11202,7 +11501,7 @@ module.exports = function buildURL(url, params, paramsSerializer) {
11202
11501
  return url;
11203
11502
  };
11204
11503
 
11205
- },{"./../utils":80}],73:[function(require,module,exports){
11504
+ },{"./../utils":83}],76:[function(require,module,exports){
11206
11505
  'use strict';
11207
11506
 
11208
11507
  /**
@@ -11218,7 +11517,7 @@ module.exports = function combineURLs(baseURL, relativeURL) {
11218
11517
  : baseURL;
11219
11518
  };
11220
11519
 
11221
- },{}],74:[function(require,module,exports){
11520
+ },{}],77:[function(require,module,exports){
11222
11521
  'use strict';
11223
11522
 
11224
11523
  var utils = require('./../utils');
@@ -11273,7 +11572,7 @@ module.exports = (
11273
11572
  })()
11274
11573
  );
11275
11574
 
11276
- },{"./../utils":80}],75:[function(require,module,exports){
11575
+ },{"./../utils":83}],78:[function(require,module,exports){
11277
11576
  'use strict';
11278
11577
 
11279
11578
  /**
@@ -11289,7 +11588,7 @@ module.exports = function isAbsoluteURL(url) {
11289
11588
  return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url);
11290
11589
  };
11291
11590
 
11292
- },{}],76:[function(require,module,exports){
11591
+ },{}],79:[function(require,module,exports){
11293
11592
  'use strict';
11294
11593
 
11295
11594
  var utils = require('./../utils');
@@ -11359,7 +11658,7 @@ module.exports = (
11359
11658
  })()
11360
11659
  );
11361
11660
 
11362
- },{"./../utils":80}],77:[function(require,module,exports){
11661
+ },{"./../utils":83}],80:[function(require,module,exports){
11363
11662
  'use strict';
11364
11663
 
11365
11664
  var utils = require('../utils');
@@ -11373,7 +11672,7 @@ module.exports = function normalizeHeaderName(headers, normalizedName) {
11373
11672
  });
11374
11673
  };
11375
11674
 
11376
- },{"../utils":80}],78:[function(require,module,exports){
11675
+ },{"../utils":83}],81:[function(require,module,exports){
11377
11676
  'use strict';
11378
11677
 
11379
11678
  var utils = require('./../utils');
@@ -11428,7 +11727,7 @@ module.exports = function parseHeaders(headers) {
11428
11727
  return parsed;
11429
11728
  };
11430
11729
 
11431
- },{"./../utils":80}],79:[function(require,module,exports){
11730
+ },{"./../utils":83}],82:[function(require,module,exports){
11432
11731
  'use strict';
11433
11732
 
11434
11733
  /**
@@ -11457,7 +11756,7 @@ module.exports = function spread(callback) {
11457
11756
  };
11458
11757
  };
11459
11758
 
11460
- },{}],80:[function(require,module,exports){
11759
+ },{}],83:[function(require,module,exports){
11461
11760
  'use strict';
11462
11761
 
11463
11762
  var bind = require('./helpers/bind');
@@ -11762,7 +12061,7 @@ module.exports = {
11762
12061
  trim: trim
11763
12062
  };
11764
12063
 
11765
- },{"./helpers/bind":70,"is-buffer":83}],81:[function(require,module,exports){
12064
+ },{"./helpers/bind":73,"is-buffer":86}],84:[function(require,module,exports){
11766
12065
  /*
11767
12066
  * big.js v5.0.3
11768
12067
  * A small, fast, easy-to-use library for arbitrary-precision decimal arithmetic.
@@ -12703,7 +13002,7 @@ module.exports = {
12703
13002
  }
12704
13003
  })(this);
12705
13004
 
12706
- },{}],82:[function(require,module,exports){
13005
+ },{}],85:[function(require,module,exports){
12707
13006
  // shim for using process in browser
12708
13007
  var process = module.exports = {};
12709
13008
 
@@ -12889,7 +13188,7 @@ process.chdir = function (dir) {
12889
13188
  };
12890
13189
  process.umask = function() { return 0; };
12891
13190
 
12892
- },{}],83:[function(require,module,exports){
13191
+ },{}],86:[function(require,module,exports){
12893
13192
  /*!
12894
13193
  * Determine if an object is a Buffer
12895
13194
  *
@@ -12912,7 +13211,7 @@ function isSlowBuffer (obj) {
12912
13211
  return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0))
12913
13212
  }
12914
13213
 
12915
- },{}],84:[function(require,module,exports){
13214
+ },{}],87:[function(require,module,exports){
12916
13215
  //! moment-timezone.js
12917
13216
  //! version : 0.5.11
12918
13217
  //! Copyright (c) JS Foundation and other contributors
@@ -14114,7 +14413,7 @@ function isSlowBuffer (obj) {
14114
14413
  return moment;
14115
14414
  }));
14116
14415
 
14117
- },{"moment":88}],85:[function(require,module,exports){
14416
+ },{"moment":91}],88:[function(require,module,exports){
14118
14417
  module.exports={
14119
14418
  "version": "2016j",
14120
14419
  "zones": [
@@ -14714,11 +15013,11 @@ module.exports={
14714
15013
  "Pacific/Pohnpei|Pacific/Ponape"
14715
15014
  ]
14716
15015
  }
14717
- },{}],86:[function(require,module,exports){
15016
+ },{}],89:[function(require,module,exports){
14718
15017
  var moment = module.exports = require("./moment-timezone");
14719
15018
  moment.tz.load(require('./data/packed/latest.json'));
14720
15019
 
14721
- },{"./data/packed/latest.json":85,"./moment-timezone":87}],87:[function(require,module,exports){
15020
+ },{"./data/packed/latest.json":88,"./moment-timezone":90}],90:[function(require,module,exports){
14722
15021
  //! moment-timezone.js
14723
15022
  //! version : 0.5.11
14724
15023
  //! Copyright (c) JS Foundation and other contributors
@@ -15321,7 +15620,7 @@ moment.tz.load(require('./data/packed/latest.json'));
15321
15620
  return moment;
15322
15621
  }));
15323
15622
 
15324
- },{"moment":88}],88:[function(require,module,exports){
15623
+ },{"moment":91}],91:[function(require,module,exports){
15325
15624
  //! moment.js
15326
15625
 
15327
15626
  ;(function (global, factory) {
@@ -6,6 +6,7 @@ const assert = require('@barchart/common-js/lang/assert'),
6
6
  const TransactionType = require('@barchart/portfolio-api-common/lib/data/TransactionType');
7
7
 
8
8
  const PortfolioSchema = require('@barchart/portfolio-api-common/lib/serialization/PortfolioSchema'),
9
+ PositionSummarySchema = require('@barchart/portfolio-api-common/lib/serialization/PositionSummarySchema'),
9
10
  TransactionSchema = require('@barchart/portfolio-api-common/lib/serialization/TransactionSchema');
10
11
 
11
12
  const EndpointBuilder = require('@barchart/common-js/api/http/builders/EndpointBuilder'),
@@ -140,8 +141,9 @@ module.exports = (() => {
140
141
  .withVariableParameter('start', 'start', 'start', true)
141
142
  .withVariableParameter('end', 'end', 'end', true);
142
143
  })
144
+ .withRequestInterceptor(RequestInterceptor.PLAIN_TEXT_RESPONSE)
143
145
  .withRequestInterceptor(requestInterceptorToUse)
144
- // .withResponseInterceptor(responseInterceptorForPositionDeserialization)
146
+ .withResponseInterceptor(responseInterceptorForPositionSummaryDeserialization)
145
147
  .withErrorInterceptor(ErrorInterceptor.GENERAL)
146
148
  .endpoint;
147
149
 
@@ -194,9 +196,9 @@ module.exports = (() => {
194
196
  .withLiteralParameter('transactions', 'transactions');
195
197
  })
196
198
  .withBody('portfolio data')
197
- .withRequestInterceptor(RequestInterceptor.fromDelegate(createTransactionRequestInterceptor))
199
+ .withRequestInterceptor(RequestInterceptor.PLAIN_TEXT_RESPONSE)
198
200
  .withRequestInterceptor(requestInterceptorToUse)
199
- .withResponseInterceptor(responseInterceptorForPortfolioDeserialization)
201
+ .withResponseInterceptor(responseInterceptorForTransactionDeserialization)
200
202
  .withErrorInterceptor(ErrorInterceptor.GENERAL)
201
203
  .endpoint;
202
204
 
@@ -211,7 +213,7 @@ module.exports = (() => {
211
213
  .withLiteralParameter('positions', 'positions')
212
214
  .withVariableParameter('position', 'position', 'position', false)
213
215
  .withLiteralParameter('transactions', 'transactions')
214
- .withVariableParameter('transaction', 'transaction', 'transaction', false)
216
+ .withVariableParameter('transaction', 'transaction', 'transaction', false);
215
217
  })
216
218
  .withRequestInterceptor(requestInterceptorToUse)
217
219
  .withErrorInterceptor(ErrorInterceptor.GENERAL)
@@ -363,17 +365,24 @@ module.exports = (() => {
363
365
  * @param {String=} position
364
366
  * @returns {Promise.<Position[]>}
365
367
  */
366
- readPositionSummaries(portfolio, position) {
368
+ readPositionSummaries(data) {
367
369
  return Promise.resolve()
368
370
  .then(() => {
369
371
  checkStart.call(this);
370
372
 
371
- // console
373
+ assert.argumentIsRequired(data, 'data', Object);
374
+ assert.argumentIsOptional(data.portfolio, 'portfolio', String);
375
+ assert.argumentIsOptional(data.position, 'position', String);
372
376
 
373
- assert.argumentIsOptional(portfolio, 'portfolio', String);
374
- assert.argumentIsOptional(position, 'position', String);
377
+ const query = {
378
+ portfolio: data.portfolio || '*',
379
+ position: data.position || '*',
380
+ frame: data.frame,
381
+ start: data.start,
382
+ end: data.end
383
+ };
375
384
 
376
- return Gateway.invoke(this._readPositionSummariesEndpoint, { portfolio: portfolio || '*', position: position || '*' });
385
+ return Gateway.invoke(this._readPositionSummariesEndpoint, query);
377
386
  });
378
387
  }
379
388
 
@@ -423,7 +432,9 @@ module.exports = (() => {
423
432
  transaction.position = 'new';
424
433
  }
425
434
 
426
- return Gateway.invoke(this._createTransactionEndpoint, TransactionSchema.forCreate(transaction.type));
435
+ const schema = TransactionSchema.forCreate(transaction.type);
436
+
437
+ return Gateway.invoke(this._createTransactionEndpoint, schema.schema.format(transaction));
427
438
  });
428
439
  }
429
440
 
@@ -565,30 +576,9 @@ module.exports = (() => {
565
576
  });
566
577
  };
567
578
 
568
- const createTransactionRequestInterceptor = (request) => {
569
- const transactionData = request.data.transaction;
570
-
571
- return Promise.resolve()
572
- .then(() => {
573
- const schema = TransactionSchema.fromCode(TransactionSchema, transactionData.type.code);
574
-
575
- return FailureReason.validateSchema(schema, transactionData)
576
- })
577
- .then(() => {
578
- request.data = transactionData;
579
-
580
- return Promise.resolve(request);
581
- })
582
- .catch(e => {
583
- console.error('Error serializing data to create a transaction', e);
584
-
585
- return Promise.reject();
586
- });
587
- };
588
-
589
579
  const responseInterceptorForPortfolioDeserialization = ResponseInterceptor.fromDelegate((response, ignored) => {
590
580
  try {
591
- return JSON.parse(response.data, PortfolioSchema.COMPLETE.schema.getReviver());
581
+ return JSON.parse(response.data, PortfolioSchema.CLIENT.schema.getReviver());
592
582
  } catch (e) {
593
583
  console.log(e);
594
584
  }
@@ -598,8 +588,22 @@ module.exports = (() => {
598
588
  return response.data;
599
589
  });
600
590
 
591
+ const responseInterceptorForPositionSummaryDeserialization = ResponseInterceptor.fromDelegate((response, ignored) => {
592
+ try {
593
+ return JSON.parse(response.data, PositionSummarySchema.CLIENT.schema.getReviver());
594
+ } catch (e) {
595
+ console.log(e);
596
+ }
597
+ });
598
+
601
599
  const responseInterceptorForTransactionDeserialization = ResponseInterceptor.fromDelegate((response, ignored) => {
602
- return JSON.parse(response.data, TransactionSchema.COMPLETE.schema.getReviver());
600
+ try {
601
+ return TransactionSchema.CLIENT.schema.revive(response.data);
602
+
603
+ return JSON.parse(response.data, TransactionSchema.CLIENT.schema.getReviver());
604
+ } catch (e) {
605
+ console.error('Error serializing transaction data', e);
606
+ }
603
607
  });
604
608
 
605
609
  function start(gateway) {
package/lib/index.js CHANGED
@@ -7,6 +7,6 @@ module.exports = (() => {
7
7
  return {
8
8
  JwtGateway: JwtGateway,
9
9
  PortfolioGateway: PortfolioGateway,
10
- version: '1.1.12'
10
+ version: '1.1.15'
11
11
  };
12
12
  })();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barchart/portfolio-client-js",
3
- "version": "1.1.12",
3
+ "version": "1.1.15",
4
4
  "description": "JavaScript library for interfacing with Barchart's Portfolio API",
5
5
  "author": {
6
6
  "name": "Bryan Ingle",