@barchart/portfolio-client-js 1.3.3 → 1.3.6

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.
@@ -47,21 +47,36 @@ module.exports = function () {
47
47
  _classCallCheck(this, Configuration);
48
48
  }
49
49
 
50
- /**
51
- * The host of the development system.
52
- *
53
- * @public
54
- * @static
55
- * @returns {String}
56
- */
57
-
58
-
59
50
  _createClass(Configuration, [{
60
51
  key: 'toString',
61
52
  value: function toString() {
62
53
  return '[Configuration]';
63
54
  }
64
55
  }], [{
56
+ key: 'getBrokerageHost',
57
+ value: function getBrokerageHost(host) {
58
+ if (host === Configuration.developmentHost) {
59
+ return '7enbtpamgg.execute-api.us-east-1.amazonaws.com/dev';
60
+ } else if (host === Configuration.stagingHost) {
61
+ return '';
62
+ } else if (host === Configuration.productionHost) {
63
+ return '';
64
+ } else if (host === Configuration.adminHost) {
65
+ return '';
66
+ } else {
67
+ return '';
68
+ }
69
+ }
70
+
71
+ /**
72
+ * The host of the development system.
73
+ *
74
+ * @public
75
+ * @static
76
+ * @returns {String}
77
+ */
78
+
79
+ }, {
65
80
  key: 'developmentHost',
66
81
  get: function get() {
67
82
  return 'portfolio-dev.aws.barchart.com';
@@ -194,37 +209,37 @@ module.exports = function () {
194
209
  }
195
210
 
196
211
  _this._readPortfoliosEndpoint = EndpointBuilder.for('read-portfolios', 'read portfolios').withVerb(VerbType.GET).withProtocol(protocolType).withHost(host).withPort(port).withPathBuilder(function (pb) {
197
- pb.withLiteralParameter('json', 'json').withLiteralParameter('portfolios', 'portfolios').withVariableParameter('portfolio', 'portfolio', 'portfolio', false);
212
+ pb.withLiteralParameter('portfolios', 'portfolios').withVariableParameter('portfolio', 'portfolio', 'portfolio', false);
198
213
  }).withRequestInterceptor(RequestInterceptor.PLAIN_TEXT_RESPONSE).withRequestInterceptor(requestInterceptorToUse).withResponseInterceptor(responseInterceptorForPortfolioDeserialization).withErrorInterceptor(ErrorInterceptor.GENERAL).endpoint;
199
214
 
200
215
  _this._createPortfolioEndpoint = EndpointBuilder.for('create-portfolio', 'create portfolio').withVerb(VerbType.POST).withProtocol(protocolType).withHost(host).withPort(port).withPathBuilder(function (pb) {
201
- pb.withLiteralParameter('json', 'json').withLiteralParameter('portfolios', 'portfolios');
216
+ pb.withLiteralParameter('portfolios', 'portfolios');
202
217
  }).withBody('portfolio').withRequestInterceptor(RequestInterceptor.PLAIN_TEXT_RESPONSE).withRequestInterceptor(RequestInterceptor.fromDelegate(createPortfolioRequestInterceptor)).withRequestInterceptor(requestInterceptorToUse).withResponseInterceptor(responseInterceptorForPortfolioDeserialization).withErrorInterceptor(ErrorInterceptor.GENERAL).endpoint;
203
218
 
204
219
  _this._updatePortfolioEndpoint = EndpointBuilder.for('update-portfolio', 'update portfolio').withVerb(VerbType.PUT).withProtocol(protocolType).withHost(host).withPort(port).withPathBuilder(function (pb) {
205
- pb.withLiteralParameter('json', 'json').withLiteralParameter('portfolios', 'portfolios').withVariableParameter('portfolio', 'portfolio', 'portfolio', false);
220
+ pb.withLiteralParameter('portfolios', 'portfolios').withVariableParameter('portfolio', 'portfolio', 'portfolio', false);
206
221
  }).withBody('portfolio').withRequestInterceptor(RequestInterceptor.PLAIN_TEXT_RESPONSE).withRequestInterceptor(RequestInterceptor.fromDelegate(updatePortfolioRequestInterceptor)).withRequestInterceptor(requestInterceptorToUse).withResponseInterceptor(responseInterceptorForPortfolioDeserialization).withErrorInterceptor(ErrorInterceptor.GENERAL).endpoint;
207
222
 
208
223
  _this._deletePortfolioEndpoint = EndpointBuilder.for('delete-portfolio', 'delete portfolio').withVerb(VerbType.DELETE).withProtocol(protocolType).withHost(host).withPort(port).withPathBuilder(function (pb) {
209
- pb.withLiteralParameter('json', 'json').withLiteralParameter('portfolios', 'portfolios').withVariableParameter('portfolio', 'portfolio', 'portfolio', false);
224
+ pb.withLiteralParameter('portfolios', 'portfolios').withVariableParameter('portfolio', 'portfolio', 'portfolio', false);
210
225
  }).withRequestInterceptor(requestInterceptorToUse).withErrorInterceptor(ErrorInterceptor.GENERAL).endpoint;
211
226
 
212
227
  _this._readPositionsEndpoint = EndpointBuilder.for('read-positions', 'read positions').withVerb(VerbType.GET).withProtocol(protocolType).withHost(host).withPort(port).withPathBuilder(function (pb) {
213
- pb.withLiteralParameter('json', 'json').withLiteralParameter('portfolios', 'portfolios').withVariableParameter('portfolio', 'portfolio', 'portfolio', false).withLiteralParameter('positions', 'positions').withVariableParameter('position', 'position', 'position', false);
228
+ pb.withLiteralParameter('portfolios', 'portfolios').withVariableParameter('portfolio', 'portfolio', 'portfolio', false).withLiteralParameter('positions', 'positions').withVariableParameter('position', 'position', 'position', false);
214
229
  }).withQueryBuilder(function (qb) {
215
230
  qb.withVariableParameter('includePreviousPrice', 'includePreviousPrice', 'includePreviousPrice', true);
216
231
  }).withRequestInterceptor(requestInterceptorToUse).withRequestInterceptor(RequestInterceptor.PLAIN_TEXT_RESPONSE).withResponseInterceptor(responseInterceptorForPositionDeserialization).withErrorInterceptor(ErrorInterceptor.GENERAL).endpoint;
217
232
 
218
233
  _this._updatePositionEndpoint = EndpointBuilder.for('update-position', 'update position').withVerb(VerbType.PUT).withProtocol(protocolType).withHost(host).withPort(port).withPathBuilder(function (pb) {
219
- pb.withLiteralParameter('json', 'json').withLiteralParameter('portfolios', 'portfolios').withVariableParameter('portfolio', 'portfolio', 'portfolio', false).withLiteralParameter('positions', 'positions').withVariableParameter('position', 'position', 'position', false);
234
+ pb.withLiteralParameter('portfolios', 'portfolios').withVariableParameter('portfolio', 'portfolio', 'portfolio', false).withLiteralParameter('positions', 'positions').withVariableParameter('position', 'position', 'position', false);
220
235
  }).withBody('portfolio').withRequestInterceptor(RequestInterceptor.fromDelegate(updatePositionRequestInterceptor)).withRequestInterceptor(requestInterceptorToUse).withResponseInterceptor(responseInterceptorForPositionMutateDeserialization).withErrorInterceptor(ErrorInterceptor.GENERAL).endpoint;
221
236
 
222
237
  _this._deletePositionEndpoint = EndpointBuilder.for('delete-position', 'delete position').withVerb(VerbType.DELETE).withProtocol(protocolType).withHost(host).withPort(port).withPathBuilder(function (pb) {
223
- pb.withLiteralParameter('json', 'json').withLiteralParameter('portfolios', 'portfolios').withVariableParameter('portfolio', 'portfolio', 'portfolio', false).withLiteralParameter('positions', 'positions').withVariableParameter('position', 'position', 'position', false);
238
+ pb.withLiteralParameter('portfolios', 'portfolios').withVariableParameter('portfolio', 'portfolio', 'portfolio', false).withLiteralParameter('positions', 'positions').withVariableParameter('position', 'position', 'position', false);
224
239
  }).withBody('transaction').withRequestInterceptor(requestInterceptorToUse).withResponseInterceptor(responseInterceptorForPositionMutateDeserialization).withErrorInterceptor(ErrorInterceptor.GENERAL).endpoint;
225
240
 
226
241
  _this._readPositionSummariesEndpoint = EndpointBuilder.for('read-position-summaries', 'read position summaries').withVerb(VerbType.GET).withProtocol(protocolType).withHost(host).withPort(port).withPathBuilder(function (pb) {
227
- pb.withLiteralParameter('json', 'json').withLiteralParameter('portfolios', 'portfolios').withVariableParameter('portfolio', 'portfolio', 'portfolio', false).withLiteralParameter('summaries', 'summaries').withVariableParameter('position', 'position', 'position', false);
242
+ pb.withLiteralParameter('portfolios', 'portfolios').withVariableParameter('portfolio', 'portfolio', 'portfolio', false).withLiteralParameter('summaries', 'summaries').withVariableParameter('position', 'position', 'position', false);
228
243
  }).withQueryBuilder(function (qb) {
229
244
  qb.withVariableParameter('frames', 'frames', 'frames', true, function (frames) {
230
245
  return frames.map(function (f) {
@@ -236,13 +251,13 @@ module.exports = function () {
236
251
  }).withRequestInterceptor(requestInterceptorToUse).withRequestInterceptor(RequestInterceptor.PLAIN_TEXT_RESPONSE).withResponseInterceptor(responseInterceptorForPositionSummaryDeserialization).withErrorInterceptor(ErrorInterceptor.GENERAL).endpoint;
237
252
 
238
253
  _this._readTransactionsEndpoint = EndpointBuilder.for('read-transactions', 'read transactions').withVerb(VerbType.GET).withProtocol(protocolType).withHost(host).withPort(port).withPathBuilder(function (pb) {
239
- pb.withLiteralParameter('json', 'json').withLiteralParameter('portfolios', 'portfolios').withVariableParameter('portfolio', 'portfolio', 'portfolio', false).withLiteralParameter('positions', 'positions').withVariableParameter('position', 'position', 'position', false).withLiteralParameter('transactions', 'transactions');
254
+ pb.withLiteralParameter('portfolios', 'portfolios').withVariableParameter('portfolio', 'portfolio', 'portfolio', false).withLiteralParameter('positions', 'positions').withVariableParameter('position', 'position', 'position', false).withLiteralParameter('transactions', 'transactions');
240
255
  }).withQueryBuilder(function (qb) {
241
256
  qb.withLiteralParameter('mode', 'mode', 'text');
242
257
  }).withRequestInterceptor(RequestInterceptor.PLAIN_TEXT_RESPONSE).withRequestInterceptor(requestInterceptorToUse).withResponseInterceptor(responseInterceptorForTransactionDeserialization).withErrorInterceptor(ErrorInterceptor.GENERAL).endpoint;
243
258
 
244
259
  _this._createTransactionEndpoint = EndpointBuilder.for('create-transaction', 'create transaction').withVerb(VerbType.POST).withProtocol(protocolType).withHost(host).withPort(port).withPathBuilder(function (pb) {
245
- pb.withLiteralParameter('json', 'json').withLiteralParameter('portfolios', 'portfolios').withVariableParameter('portfolio', 'portfolio', 'portfolio', false).withLiteralParameter('positions', 'positions').withVariableParameter('position', 'position', 'position', false).withLiteralParameter('transactions', 'transactions');
260
+ pb.withLiteralParameter('portfolios', 'portfolios').withVariableParameter('portfolio', 'portfolio', 'portfolio', false).withLiteralParameter('positions', 'positions').withVariableParameter('position', 'position', 'position', false).withLiteralParameter('transactions', 'transactions');
246
261
  }).withQueryBuilder(function (qb) {
247
262
  qb.withVariableParameter('type', 'type', 'type', false, function (x) {
248
263
  return x.code;
@@ -250,11 +265,11 @@ module.exports = function () {
250
265
  }).withBody('transaction').withRequestInterceptor(requestInterceptorToUse).withResponseInterceptor(responseInterceptorForPositionMutateDeserialization).withErrorInterceptor(ErrorInterceptor.GENERAL).endpoint;
251
266
 
252
267
  _this._batchTransactionEndpoint = EndpointBuilder.for('batch-transactions', 'batch transactions').withVerb(VerbType.POST).withProtocol(protocolType).withHost(host).withPort(port).withPathBuilder(function (pb) {
253
- pb.withLiteralParameter('json', 'json').withLiteralParameter('portfolios', 'portfolios').withVariableParameter('portfolio', 'portfolio', 'portfolio', false).withLiteralParameter('positions', 'positions').withLiteralParameter('multiple', 'multiple').withLiteralParameter('transactions', 'transactions');
268
+ pb.withLiteralParameter('portfolios', 'portfolios').withVariableParameter('portfolio', 'portfolio', 'portfolio', false).withLiteralParameter('positions', 'positions').withLiteralParameter('multiple', 'multiple').withLiteralParameter('transactions', 'transactions');
254
269
  }).withBody('transactions').withRequestInterceptor(requestInterceptorToUse).withResponseInterceptor(ResponseInterceptor.DATA).withErrorInterceptor(ErrorInterceptor.GENERAL).endpoint;
255
270
 
256
271
  _this._editTransactionEndpoint = EndpointBuilder.for('edit-transaction', 'edit transaction').withVerb(VerbType.POST).withProtocol(protocolType).withHost(host).withPort(port).withPathBuilder(function (pb) {
257
- pb.withLiteralParameter('json', 'json').withLiteralParameter('portfolios', 'portfolios').withVariableParameter('portfolio', 'portfolio', 'portfolio', false).withLiteralParameter('positions', 'positions').withVariableParameter('position', 'position', 'position', false).withLiteralParameter('transactions', 'transactions').withVariableParameter('sequence', 'sequence', 'sequence', false);
272
+ pb.withLiteralParameter('portfolios', 'portfolios').withVariableParameter('portfolio', 'portfolio', 'portfolio', false).withLiteralParameter('positions', 'positions').withVariableParameter('position', 'position', 'position', false).withLiteralParameter('transactions', 'transactions').withVariableParameter('sequence', 'sequence', 'sequence', false);
258
273
  }).withQueryBuilder(function (qb) {
259
274
  qb.withVariableParameter('type', 'type', 'type', false, function (x) {
260
275
  return x.code;
@@ -262,7 +277,7 @@ module.exports = function () {
262
277
  }).withBody('transaction').withRequestInterceptor(requestInterceptorToUse).withResponseInterceptor(responseInterceptorForPositionMutateDeserialization).withErrorInterceptor(ErrorInterceptor.GENERAL).endpoint;
263
278
 
264
279
  _this._deleteTransactionEndpoint = EndpointBuilder.for('delete-transaction', 'delete transaction').withVerb(VerbType.DELETE).withProtocol(protocolType).withHost(host).withPort(port).withPathBuilder(function (pb) {
265
- pb.withLiteralParameter('json', 'json').withLiteralParameter('portfolios', 'portfolios').withVariableParameter('portfolio', 'portfolio', 'portfolio', false).withLiteralParameter('positions', 'positions').withVariableParameter('position', 'position', 'position', false).withLiteralParameter('transactions', 'transactions').withVariableParameter('sequence', 'sequence', 'sequence', false);
280
+ pb.withLiteralParameter('portfolios', 'portfolios').withVariableParameter('portfolio', 'portfolio', 'portfolio', false).withLiteralParameter('positions', 'positions').withVariableParameter('position', 'position', 'position', false).withLiteralParameter('transactions', 'transactions').withVariableParameter('sequence', 'sequence', 'sequence', false);
266
281
  }).withQueryBuilder(function (qb) {
267
282
  qb.withVariableParameter('force', 'force', 'force', false).withVariableParameter('echoStart', 'echoStart', 'echoStart', true, function (x) {
268
283
  return x.format();
@@ -272,7 +287,7 @@ module.exports = function () {
272
287
  }).withRequestInterceptor(requestInterceptorToUse).withResponseInterceptor(responseInterceptorForPositionMutateDeserialization).withErrorInterceptor(ErrorInterceptor.GENERAL).endpoint;
273
288
 
274
289
  _this._readTransactionsReportEndpoint = EndpointBuilder.for('read-transaction-report', 'read transaction report').withVerb(VerbType.GET).withProtocol(protocolType).withHost(host).withPort(port).withPathBuilder(function (pb) {
275
- pb.withLiteralParameter('json', 'json').withLiteralParameter('portfolios', 'portfolios').withVariableParameter('portfolio', 'portfolio', 'portfolio', false).withLiteralParameter('positions', 'positions').withVariableParameter('position', 'position', 'position', true).withLiteralParameter('transactions', 'transactions').withLiteralParameter('formatted', 'formatted');
290
+ pb.withLiteralParameter('portfolios', 'portfolios').withVariableParameter('portfolio', 'portfolio', 'portfolio', false).withLiteralParameter('positions', 'positions').withVariableParameter('position', 'position', 'position', true).withLiteralParameter('transactions', 'transactions').withLiteralParameter('formatted', 'formatted');
276
291
  }).withQueryBuilder(function (qb) {
277
292
  qb.withVariableParameter('start', 'start', 'start', true, function (x) {
278
293
  return x.format();
@@ -282,7 +297,7 @@ module.exports = function () {
282
297
  }).withRequestInterceptor(requestInterceptorToUse).withResponseInterceptor(ResponseInterceptor.DATA).withErrorInterceptor(ErrorInterceptor.GENERAL).endpoint;
283
298
 
284
299
  _this._readBrokerageReportAvailabilityEndpoint = EndpointBuilder.for('read-brokerage-report-availability', 'read brokerage report availability').withVerb(VerbType.GET).withProtocol(protocolType).withHost(host).withPort(port).withPathBuilder(function (pb) {
285
- pb.withLiteralParameter('json', 'json').withLiteralParameter('reports', 'reports').withLiteralParameter('portfolios', 'portfolios').withVariableParameter('portfolio', 'portfolio', 'portfolio', false).withLiteralParameter('availability', 'availability');
300
+ pb.withLiteralParameter('portfolios', 'portfolios').withVariableParameter('portfolio', 'portfolio', 'portfolio', false).withLiteralParameter('reports', 'reports').withLiteralParameter('brokerage', 'brokerage').withLiteralParameter('availability', 'availability');
286
301
  }).withQueryBuilder(function (qb) {
287
302
  qb.withVariableParameter('frames', 'frames', 'frames', true, function (frames) {
288
303
  return frames.map(function (f) {
@@ -290,6 +305,10 @@ module.exports = function () {
290
305
  }).join();
291
306
  });
292
307
  }).withRequestInterceptor(requestInterceptorToUse).withRequestInterceptor(RequestInterceptor.PLAIN_TEXT_RESPONSE).withResponseInterceptor(responseInterceptorForBrokerageReportAvailabilityDeserialization).withErrorInterceptor(ErrorInterceptor.GENERAL).endpoint;
308
+
309
+ _this._brokerageReportUrlGenerator = function (user, portfolio, frame, end) {
310
+ return 'https://' + Configuration.getBrokerageHost(host) + '/binary/reports/portfolios/' + portfolio + '/frames/' + frame.code + '/date/' + end.format() + '/' + user;
311
+ };
293
312
  return _this;
294
313
  }
295
314
 
@@ -920,19 +939,32 @@ module.exports = function () {
920
939
  return Gateway.invoke(_this20._readBrokerageReportAvailabilityEndpoint, payload);
921
940
  });
922
941
  }
942
+
943
+ /**
944
+ * Generates a URL suitable for downloading a brokerage report (as a PDF).
945
+ *
946
+ * @public
947
+ * @param {String} user
948
+ * @param {String} portfolio
949
+ * @param {PositionSummaryFrame} frame
950
+ * @param {Day} end
951
+ * @return {Promise<String>}
952
+ */
953
+
923
954
  }, {
924
955
  key: 'getBrokerageReportUrl',
925
- value: function getBrokerageReportUrl(portfolio, frame, start) {
956
+ value: function getBrokerageReportUrl(user, portfolio, frame, end) {
926
957
  var _this21 = this;
927
958
 
928
959
  return Promise.resolve().then(function () {
929
960
  checkStart.call(_this21);
930
961
 
962
+ assert.argumentIsRequired(user, 'user', String);
931
963
  assert.argumentIsRequired(portfolio, 'portfolio', String);
932
964
  assert.argumentIsRequired(frame, 'frame', PositionSummaryFrame, 'PositionSummaryFrame');
933
- assert.argumentIsRequired(start, 'start', Day, 'Day');
965
+ assert.argumentIsRequired(end, 'end', Day, 'Day');
934
966
 
935
- return 'https://portfolio-dev.aws.barchart.com/binary/reports/portfolios/9555fb81-f640-4a95-8766-aa59f38d2abd/frames/MONTHLY/date/2017-06-30';
967
+ return _this21._brokerageReportUrlGenerator(user, portfolio, frame, end);
936
968
  });
937
969
  }
938
970
 
@@ -1529,7 +1561,7 @@ module.exports = function () {
1529
1561
 
1530
1562
  function _forDevelopment(userId, legacyUserId) {
1531
1563
  return EndpointBuilder.for('read-jwt-token-for-development', 'lookup user identity').withVerb(VerbType.GET).withProtocol(ProtocolType.HTTPS).withHost(Configuration.developmentHost).withPathBuilder(function (pb) {
1532
- pb.withLiteralParameter('json', 'json').withLiteralParameter('token', 'token').withLiteralParameter('barchart', 'barchart').withLiteralParameter('generator', 'generator');
1564
+ pb.withLiteralParameter('token', 'token').withLiteralParameter('barchart', 'barchart').withLiteralParameter('generator', 'generator');
1533
1565
  }).withQueryBuilder(function (qb) {
1534
1566
  qb.withLiteralParameter('user', 'userId', userId).withLiteralParameter('legacy user', 'userLegacyId', legacyUserId).withLiteralParameter('user context', 'userContext', 'TGAM').withLiteralParameter('user permission level', 'userPermissions', 'registered');
1535
1567
  }).withResponseInterceptor(ResponseInterceptor.DATA).endpoint;
@@ -1537,19 +1569,19 @@ module.exports = function () {
1537
1569
 
1538
1570
  function _forStaging(externalRequestInterceptor) {
1539
1571
  return EndpointBuilder.for('translate-jwt-token-for-staging', 'lookup Barchart user identity').withVerb(VerbType.GET).withProtocol(ProtocolType.HTTPS).withHost(Configuration.stagingHost).withPathBuilder(function (pb) {
1540
- pb.withLiteralParameter('json', 'json').withLiteralParameter('token', 'token').withLiteralParameter('system', 'tgam').withLiteralParameter('converter', 'converter');
1572
+ pb.withLiteralParameter('token', 'token').withLiteralParameter('system', 'tgam').withLiteralParameter('converter', 'converter');
1541
1573
  }).withRequestInterceptor(externalRequestInterceptor).withResponseInterceptor(ResponseInterceptor.DATA).endpoint;
1542
1574
  }
1543
1575
 
1544
1576
  function _forProduction(externalRequestInterceptor) {
1545
1577
  return EndpointBuilder.for('translate-jwt-token-for-production', 'lookup Barchart user identity').withVerb(VerbType.GET).withProtocol(ProtocolType.HTTPS).withHost(Configuration.productionHost).withPathBuilder(function (pb) {
1546
- pb.withLiteralParameter('json', 'json').withLiteralParameter('token', 'token').withLiteralParameter('system', 'tgam').withLiteralParameter('converter', 'converter');
1578
+ pb.withLiteralParameter('token', 'token').withLiteralParameter('system', 'tgam').withLiteralParameter('converter', 'converter');
1547
1579
  }).withRequestInterceptor(externalRequestInterceptor).withResponseInterceptor(ResponseInterceptor.DATA).endpoint;
1548
1580
  }
1549
1581
 
1550
1582
  function _forAdmin(userId, legacyUserId) {
1551
1583
  return EndpointBuilder.for('read-jwt-token-for-admin', 'lookup user identity').withVerb(VerbType.GET).withProtocol(ProtocolType.HTTPS).withHost(Configuration.adminHost).withPathBuilder(function (pb) {
1552
- pb.withLiteralParameter('json', 'json').withLiteralParameter('token', 'token').withLiteralParameter('barchart', 'barchart').withLiteralParameter('generator', 'generator');
1584
+ pb.withLiteralParameter('token', 'token').withLiteralParameter('barchart', 'barchart').withLiteralParameter('generator', 'generator');
1553
1585
  }).withQueryBuilder(function (qb) {
1554
1586
  if (userId) {
1555
1587
  qb.withLiteralParameter('user', 'userId', userId);
@@ -1578,7 +1610,7 @@ module.exports = function () {
1578
1610
  return {
1579
1611
  JwtGateway: JwtGateway,
1580
1612
  PortfolioGateway: PortfolioGateway,
1581
- version: '1.3.3'
1613
+ version: '1.3.6'
1582
1614
  };
1583
1615
  }();
1584
1616
 
@@ -4366,7 +4398,7 @@ module.exports = function () {
4366
4398
  *
4367
4399
  * @public
4368
4400
  * @param {*} value - The value of the node.
4369
- * @param {Tree} parent - The parent node. If not supplied, this will be the root node.
4401
+ * @param {Tree=} parent - The parent node. If not supplied, this will be the root node.
4370
4402
  */
4371
4403
 
4372
4404
  var Tree = function () {
@@ -5403,6 +5435,32 @@ module.exports = function () {
5403
5435
  return this.addYears(years, true);
5404
5436
  }
5405
5437
 
5438
+ /**
5439
+ * Returns a new {@link Day} instance for the start of the month referenced by the current instance.
5440
+ *
5441
+ * @public
5442
+ * @returns {Day}
5443
+ */
5444
+
5445
+ }, {
5446
+ key: 'getStartOfMonth',
5447
+ value: function getStartOfMonth() {
5448
+ return new Day(this.year, this.month, 1);
5449
+ }
5450
+
5451
+ /**
5452
+ * Returns a new instance for the {@link Day} end of the month referenced by the current instance.
5453
+ *
5454
+ * @public
5455
+ * @returns {Day}
5456
+ */
5457
+
5458
+ }, {
5459
+ key: 'getEndOfMonth',
5460
+ value: function getEndOfMonth() {
5461
+ return new Day(this.year, this.month, Day.getDaysInMonth(this.year, this.month));
5462
+ }
5463
+
5406
5464
  /**
5407
5465
  * Indicates if another {@link Day} occurs before the current instance.
5408
5466
  *
@@ -5543,7 +5601,7 @@ module.exports = function () {
5543
5601
  return this._month;
5544
5602
  }
5545
5603
 
5546
- /**
5604
+ /**day
5547
5605
  * The day of the month.
5548
5606
  *
5549
5607
  * @public
@@ -5564,7 +5622,7 @@ module.exports = function () {
5564
5622
  }
5565
5623
 
5566
5624
  /**
5567
- * Converts a string (which matches the output of {@link Day#format} into
5625
+ * Converts a string (which matches the output of {@link Day#format}) into
5568
5626
  * a {@link Day} instance.
5569
5627
  *
5570
5628
  * @public
@@ -5835,6 +5893,24 @@ module.exports = function () {
5835
5893
  return new Decimal(this._big.div(getBig(other)));
5836
5894
  }
5837
5895
 
5896
+ /**
5897
+ * Returns a new {@link Decimal} instance with a value that results
5898
+ * from raising the current instance to the power of the exponent
5899
+ * provided.
5900
+ *
5901
+ * @public
5902
+ * @param {Decimal|Number|String} exponent
5903
+ * @returns {Decimal}
5904
+ */
5905
+
5906
+ }, {
5907
+ key: 'raise',
5908
+ value: function raise(exponent) {
5909
+ assert.argumentIsRequired(exponent, 'exponent', Number);
5910
+
5911
+ return new Decimal(this._big.pow(exponent));
5912
+ }
5913
+
5838
5914
  /**
5839
5915
  * Returns a new {@link Decimal} with a value resulting from a rounding
5840
5916
  * operation on the current value.
@@ -5999,6 +6075,28 @@ module.exports = function () {
5999
6075
  return this._big.eq(getBig(other));
6000
6076
  }
6001
6077
 
6078
+ /**
6079
+ * Returns true is close to another value.
6080
+ *
6081
+ * @public
6082
+ * @param {Decimal|Number|String} other - The value to compare.
6083
+ * @param {Number} places - The significant digits.
6084
+ * @returns {Boolean}
6085
+ */
6086
+
6087
+ }, {
6088
+ key: 'getIsApproximate',
6089
+ value: function getIsApproximate(other, places) {
6090
+ if (places === 0) {
6091
+ return this.getIsEqual(other);
6092
+ }
6093
+
6094
+ var difference = this.subtract(other).absolute();
6095
+ var tolerance = Decimal.ONE.divide(new Decimal(10).raise(places));
6096
+
6097
+ return difference.getIsLessThan(tolerance);
6098
+ }
6099
+
6002
6100
  /**
6003
6101
  * Returns true if the current instance is an integer (i.e. has no decimal
6004
6102
  * component).
@@ -7525,8 +7623,62 @@ module.exports = function () {
7525
7623
  }
7526
7624
 
7527
7625
  return found;
7626
+ },
7627
+
7628
+
7629
+ /**
7630
+ * Inserts an item into an array using a binary search is used to determine the
7631
+ * proper point for insertion and returns the same array.
7632
+ *
7633
+ * @static
7634
+ * @public
7635
+ * @param {Array} a
7636
+ * @param {*} item
7637
+ * @param {Function} comparator
7638
+ * @returns {Array}
7639
+ */
7640
+ insert: function insert(a, item, comparator) {
7641
+ assert.argumentIsArray(a, 'a');
7642
+ assert.argumentIsRequired(comparator, 'comparator', Function);
7643
+
7644
+ if (a.length === 0 || !(comparator(item, a[a.length - 1]) < 0)) {
7645
+ a.push(item);
7646
+ } else if (comparator(item, a[0]) < 0) {
7647
+ a.unshift(item);
7648
+ } else {
7649
+ a.splice(binarySearch(a, item, comparator, 0, a.length - 1), 0, item);
7650
+ }
7651
+
7652
+ return a;
7528
7653
  }
7529
7654
  };
7655
+
7656
+ function binarySearch(array, item, comparator, start, end) {
7657
+ var size = end - start;
7658
+
7659
+ var midpointIndex = start + Math.floor(size / 2);
7660
+ var midpointItem = array[midpointIndex];
7661
+
7662
+ var comparison = comparator(item, midpointItem) > 0;
7663
+
7664
+ if (size < 2) {
7665
+ if (comparison > 0) {
7666
+ var finalIndex = array.length - 1;
7667
+
7668
+ if (end === finalIndex && comparator(item, array[finalIndex]) > 0) {
7669
+ return end + 1;
7670
+ } else {
7671
+ return end;
7672
+ }
7673
+ } else {
7674
+ return start;
7675
+ }
7676
+ } else if (comparison > 0) {
7677
+ return binarySearch(array, item, comparator, midpointIndex, end);
7678
+ } else {
7679
+ return binarySearch(array, item, comparator, start, midpointIndex);
7680
+ }
7681
+ }
7530
7682
  }();
7531
7683
 
7532
7684
  },{"./assert":37,"./is":40}],37:[function(require,module,exports){
@@ -7982,7 +8134,7 @@ module.exports = function () {
7982
8134
  * @static
7983
8135
  * @public
7984
8136
  * @param {*} candidate
7985
- * @returns {*|boolean}
8137
+ * @returns {boolean}
7986
8138
  */
7987
8139
  negative: function negative(candidate) {
7988
8140
  return this.number(candidate) && candidate < 0;
@@ -9809,7 +9961,7 @@ module.exports = function () {
9809
9961
  *
9810
9962
  * @public
9811
9963
  * @param {Function} actionToBackoff - The action to attempt. If it fails -- because an error is thrown, a promise is rejected, or the function returns a falsey value -- the action will be invoked again.
9812
- * @param {number=} millisecondDelay - The amount of time to wait to execute the action. Subsequent failures are multiply this value by 2 ^ [number of failures]. So, a 1000 millisecond backoff would schedule attempts using the following delays: 0, 1000, 2000, 4000, 8000, etc. If not specified, the first attemopt will execute immediately, then a value of 1000 will be used.
9964
+ * @param {number=} millisecondDelay - The amount of time to wait to execute the action. Subsequent failures are multiply this value by 2 ^ [number of failures]. So, a 1000 millisecond backoff would schedule attempts using the following delays: 0, 1000, 2000, 4000, 8000, etc. If not specified, the first attempt will execute immediately, then a value of 1000 will be used.
9813
9965
  * @param {string=} actionDescription - Description of the action to attempt, used for logging purposes.
9814
9966
  * @param {number=} maximumAttempts - The number of attempts to before giving up.
9815
9967
  * @param {Function=} failureCallback - If provided, will be invoked if a function is considered to be failing.
@@ -9833,59 +9985,61 @@ module.exports = function () {
9833
9985
  throw new Error('The Scheduler has been disposed.');
9834
9986
  }
9835
9987
 
9836
- var scheduleBackoff = function scheduleBackoff(failureCount, e) {
9837
- if (failureCount > 0 && is.fn(failureCallback)) {
9838
- failureCallback(failureCount);
9839
- }
9840
-
9841
- if (maximumAttempts > 0 && failureCount > maximumAttempts) {
9842
- var message = 'Maximum failures reached for ' + actionDescription;
9988
+ var processAction = function processAction(attempts) {
9989
+ return Promise.resolve().then(function () {
9990
+ var delay = void 0;
9843
9991
 
9844
- var rejection = void 0;
9992
+ if (attempts === 0) {
9993
+ delay = 0;
9994
+ } else {
9995
+ delay = (millisecondDelay || 1000) * Math.pow(2, attempts - 1);
9996
+ }
9845
9997
 
9846
- if (e) {
9847
- e.backoff = message;
9998
+ return _this4.schedule(actionToBackoff, delay, 'Attempt [ ' + attempts + ' ] for [ ' + (actionDescription || 'unnamed action') + ' ]');
9999
+ }).then(function (result) {
10000
+ var resultPromise = void 0;
9848
10001
 
9849
- rejection = e;
10002
+ if (!is.undefined(failureValue) && object.equals(result, failureValue)) {
10003
+ resultPromise = Promise.reject('Attempt [ ' + attempts + ' ] for [ ' + (actionDescription || 'unnamed action') + ' ] failed due to invalid result');
9850
10004
  } else {
9851
- rejection = message;
10005
+ resultPromise = Promise.resolve(result);
9852
10006
  }
9853
10007
 
9854
- return Promise.reject(rejection);
9855
- }
10008
+ return resultPromise;
10009
+ }).catch(function (e) {
10010
+ if (is.fn(failureCallback)) {
10011
+ failureCallback(attempts);
10012
+ }
9856
10013
 
9857
- var backoffDelay = void 0;
10014
+ return Promise.reject(e);
10015
+ });
10016
+ };
9858
10017
 
9859
- if (failureCount === 0) {
9860
- backoffDelay = millisecondDelay || 0;
9861
- } else {
9862
- backoffDelay = (millisecondDelay || 1000) * Math.pow(2, failureCount);
9863
- }
10018
+ var attempts = 0;
9864
10019
 
9865
- var successPredicate = void 0;
10020
+ var processActionRecursive = function processActionRecursive() {
10021
+ return processAction(attempts++).catch(function (e) {
10022
+ if (maximumAttempts > 0 && attempts === maximumAttempts) {
10023
+ var message = 'Maximum failures reached for ' + (actionDescription || 'unnamed action');
9866
10024
 
9867
- if (is.undefined(failureValue)) {
9868
- successPredicate = function successPredicate(value) {
9869
- return value;
9870
- };
9871
- } else {
9872
- successPredicate = function successPredicate(value) {
9873
- return !object.equals(value, failureValue);
9874
- };
9875
- }
10025
+ var rejectPromise = void 0;
9876
10026
 
9877
- return _this4.schedule(actionToBackoff, backoffDelay, (actionDescription || 'unspecified') + ', attempt ' + (failureCount + 1)).then(function (result) {
9878
- if (successPredicate(result)) {
9879
- return result;
10027
+ if (is.object(e)) {
10028
+ e.backoff = message;
10029
+
10030
+ rejectPromise = Promise.reject(e);
10031
+ } else {
10032
+ rejectPromise = Promise.reject(message);
10033
+ }
10034
+
10035
+ return rejectPromise;
9880
10036
  } else {
9881
- return scheduleBackoff(++failureCount);
10037
+ return processActionRecursive();
9882
10038
  }
9883
- }).catch(function (e) {
9884
- return scheduleBackoff(++failureCount, e);
9885
10039
  });
9886
10040
  };
9887
10041
 
9888
- return scheduleBackoff(0);
10042
+ return processActionRecursive();
9889
10043
  });
9890
10044
  }
9891
10045
  }, {
@@ -9946,9 +10100,10 @@ module.exports = (() => {
9946
10100
  *
9947
10101
  * @public
9948
10102
  * @extends {Enum}
10103
+ * @param {String} code
9949
10104
  * @param {String} description
9950
10105
  * @param {String} alternateDescription
9951
- * @param {String} code
10106
+ * @param {Boolean} canExistEmpty
9952
10107
  * @param {Boolean} canReinvest
9953
10108
  * @param {Boolean} canShort
9954
10109
  * @param {Boolean} canSwitchDirection
@@ -9960,10 +10115,11 @@ module.exports = (() => {
9960
10115
  * @param {Function} generator
9961
10116
  */
9962
10117
  class InstrumentType extends Enum {
9963
- constructor(code, description, alternateDescription, canReinvest, canShort, canSwitchDirection, usesSymbols, hasCorporateActions, closeFractional, roundQuantity, strictOrdering, generator) {
10118
+ constructor(code, description, alternateDescription, canExistEmpty, canReinvest, canShort, canSwitchDirection, usesSymbols, hasCorporateActions, closeFractional, roundQuantity, strictOrdering, generator) {
9964
10119
  super(code, description);
9965
10120
 
9966
10121
  assert.argumentIsRequired(alternateDescription, 'alternateDescription', String);
10122
+ assert.argumentIsRequired(canExistEmpty, 'canExistEmpty', Boolean);
9967
10123
  assert.argumentIsRequired(canReinvest, 'canReinvest', Boolean);
9968
10124
  assert.argumentIsRequired(canShort, 'canShort', Boolean);
9969
10125
  assert.argumentIsRequired(canSwitchDirection, 'canSwitchDirection', Boolean);
@@ -9975,6 +10131,8 @@ module.exports = (() => {
9975
10131
  assert.argumentIsRequired(generator, 'generator', Function);
9976
10132
 
9977
10133
  this._alternateDescription = alternateDescription;
10134
+
10135
+ this._canExistEmpty = canExistEmpty;
9978
10136
  this._canReinvest = canReinvest;
9979
10137
  this._canShort = canShort;
9980
10138
  this._canSwitchDirection = canSwitchDirection;
@@ -9997,6 +10155,16 @@ module.exports = (() => {
9997
10155
  return this._alternateDescription;
9998
10156
  }
9999
10157
 
10158
+ /**
10159
+ * Indicates if the position can exist without any associated transactions.
10160
+ *
10161
+ * @public
10162
+ * @returns {Boolean}
10163
+ */
10164
+ get canExistEmpty() {
10165
+ return this._canExistEmpty;
10166
+ }
10167
+
10000
10168
  /**
10001
10169
  * Indicates if the instrument type allows automatic reinvestment.
10002
10170
  *
@@ -10177,10 +10345,10 @@ module.exports = (() => {
10177
10345
  }
10178
10346
  }
10179
10347
 
10180
- const cash = new InstrumentType('CASH', 'cash', 'Cash', false, false, true, false, false, false, false, false, (instrument) => `BARCHART-${instrument.type.code}-${instrument.currency.code}`);
10181
- const equity = new InstrumentType('EQUITY', 'equity', 'Equities', true, true, false, true, true, true, true, true, (instrument) => `BARCHART-${instrument.type.code}-${instrument.symbol.barchart}`);
10182
- const fund = new InstrumentType('FUND', 'mutual fund', 'Funds', true, false, false, true, true, false, true, true, (instrument) => `BARCHART-${instrument.type.code}-${instrument.symbol.barchart}`);
10183
- const other = new InstrumentType('OTHER', 'other', 'Other', false, false, false, false, false, false, true, true, (instrument) => `BARCHART-${instrument.type.code}-${uuid.v4()}`);
10348
+ const cash = new InstrumentType('CASH', 'cash', 'Cash', true, false, false, true, false, false, false, false, false, (instrument) => `BARCHART-${instrument.type.code}-${instrument.currency.code}`);
10349
+ const equity = new InstrumentType('EQUITY', 'equity', 'Equities', false, true, true, false, true, true, true, true, true, (instrument) => `BARCHART-${instrument.type.code}-${instrument.symbol.barchart}`);
10350
+ const fund = new InstrumentType('FUND', 'mutual fund', 'Funds', false, true, false, false, true, true, false, true, true, (instrument) => `BARCHART-${instrument.type.code}-${instrument.symbol.barchart}`);
10351
+ const other = new InstrumentType('OTHER', 'other', 'Other', false, false, false, false, false, false, false, true, true, (instrument) => `BARCHART-${instrument.type.code}-${uuid.v4()}`);
10184
10352
 
10185
10353
  const map = { };
10186
10354
 
@@ -10389,7 +10557,7 @@ module.exports = (() => {
10389
10557
  *
10390
10558
  * @public
10391
10559
  * @param {Number} periods
10392
- * @returns {Array.<PositionSummaryRange>}
10560
+ * @returns {PositionSummaryRange[]}
10393
10561
  */
10394
10562
  getRecentRanges(periods) {
10395
10563
  const startDate = this.getStartDate(periods);
@@ -10402,8 +10570,8 @@ module.exports = (() => {
10402
10570
  * Returns the ranges for the set of {@link Transaction} objects.
10403
10571
  *
10404
10572
  * @public
10405
- * @param {Array.<Transaction>} transactions
10406
- * @returns {Array.<PositionSummaryRange>}
10573
+ * @param {Transaction[]} transactions
10574
+ * @returns {PositionSummaryRange[]}
10407
10575
  */
10408
10576
  getRanges(transactions) {
10409
10577
  assert.argumentIsArray(transactions, 'transactions');
@@ -10416,7 +10584,7 @@ module.exports = (() => {
10416
10584
  *
10417
10585
  * @public
10418
10586
  * @param {Day} date
10419
- * @return {Array.<PositionSummaryRange>}
10587
+ * @return {PositionSummaryRange[]}
10420
10588
  */
10421
10589
  getRangesFromDate(date) {
10422
10590
  assert.argumentIsRequired(date, 'date', Day, 'Day');
@@ -10505,8 +10673,8 @@ module.exports = (() => {
10505
10673
  }
10506
10674
 
10507
10675
  const yearly = new PositionSummaryFrame('YEARLY', 'year', false, getYearlyRanges, getYearlyStartDate, getYearlyRangeDescription);
10508
- const quarterly = new PositionSummaryFrame('QUARTER', 'quarter', false, getQuarterlyRanges, getQuarterlyStartDate, getQuarterlyRangeDescription);
10509
- const monthly = new PositionSummaryFrame('MONTH', 'month', false, getMonthlyRanges, getMonthlyStartDate, getMonthlyRangeDescription);
10676
+ const quarterly = new PositionSummaryFrame('QUARTERLY', 'quarter', false, getQuarterlyRanges, getQuarterlyStartDate, getQuarterlyRangeDescription);
10677
+ const monthly = new PositionSummaryFrame('MONTHLY', 'month', false, getMonthlyRanges, getMonthlyStartDate, getMonthlyRangeDescription);
10510
10678
  const ytd = new PositionSummaryFrame('YTD', 'year-to-date', true, getYearToDateRanges, getYearToDateStartDate, getYearToDateRangeDescription);
10511
10679
 
10512
10680
  /**
@@ -10566,7 +10734,36 @@ module.exports = (() => {
10566
10734
  }
10567
10735
 
10568
10736
  function getMonthlyRanges(transactions) {
10569
- return [ ];
10737
+ const ranges = [ ];
10738
+
10739
+ if (transactions.length !== 0) {
10740
+ const today = Day.getToday();
10741
+
10742
+ const first = array.first(transactions);
10743
+ const last = array.last(transactions);
10744
+
10745
+ const firstDate = first.date;
10746
+
10747
+ let lastDate;
10748
+
10749
+ if (last.snapshot.open.getIsZero()) {
10750
+ lastDate = last.date;
10751
+ } else {
10752
+ lastDate = today;
10753
+ }
10754
+
10755
+ if (today.month === lastDate.month && today.year === lastDate.year) {
10756
+ lastDate = lastDate.subtractMonths(1);
10757
+ }
10758
+
10759
+ lastDate = lastDate.getEndOfMonth();
10760
+
10761
+ for (let end = firstDate.getEndOfMonth(); !end.getIsAfter(lastDate); end = end.addMonths(1).getEndOfMonth()) {
10762
+ ranges.push(getRange(end.subtractMonths(1).getEndOfMonth(), end));
10763
+ }
10764
+ }
10765
+
10766
+ return ranges;
10570
10767
  }
10571
10768
 
10572
10769
  function getYearToDateRanges(transactions) {
@@ -10603,7 +10800,11 @@ module.exports = (() => {
10603
10800
  }
10604
10801
 
10605
10802
  function getMonthlyStartDate(periods, date) {
10606
- return null;
10803
+ const today = date || Day.getToday();
10804
+
10805
+ return today
10806
+ .subtractMonths(periods)
10807
+ .subtractDays(today.day);
10607
10808
  }
10608
10809
 
10609
10810
  function getYearToDateStartDate(periods, date) {
@@ -10611,7 +10812,7 @@ module.exports = (() => {
10611
10812
  }
10612
10813
 
10613
10814
  function getYearlyRangeDescription(start, end) {
10614
- return `Year ended ${end.year.toString()}`;
10815
+ return `Year ended ${end.format()}`;
10615
10816
  }
10616
10817
 
10617
10818
  function getQuarterlyRangeDescription(start, end) {
@@ -10619,7 +10820,7 @@ module.exports = (() => {
10619
10820
  }
10620
10821
 
10621
10822
  function getMonthlyRangeDescription(start, end) {
10622
- return '';
10823
+ return `Month ended ${end.format()}`;
10623
10824
  }
10624
10825
 
10625
10826
  function getYearToDateRangeDescription(start, end) {
@@ -10664,7 +10865,7 @@ module.exports = (() => {
10664
10865
  * @param {Boolean} corporateAction
10665
10866
  * @param {Boolean} initial
10666
10867
  * @param {Boolean} significant
10667
- * @param {Boolean} eod
10868
+ * @param {Boolean} system
10668
10869
  */
10669
10870
  class TransactionType extends Enum {
10670
10871
  constructor(code, description, display, sequence, purchase, sale, income, opening, closing, fee, corporateAction, initial, significant) {
@@ -10994,6 +11195,17 @@ module.exports = (() => {
10994
11195
  static get DEBIT() {
10995
11196
  return debit;
10996
11197
  }
11198
+
11199
+ /**
11200
+ * A system-generated transaction, indicating the security has stopped active trading.
11201
+ *
11202
+ * @public
11203
+ * @static
11204
+ * @returns {TransactionType}
11205
+ */
11206
+ static get DELIST() {
11207
+ return delist;
11208
+ }
10997
11209
 
10998
11210
  /**
10999
11211
  * A system-generated deposit, arising from another transaction.
@@ -11043,6 +11255,7 @@ module.exports = (() => {
11043
11255
  const split = new TransactionType('SP', 'Split', 'Split', 1, false, false, false, true, false, false, true, false, false);
11044
11256
  const fee = new TransactionType('F', 'Fee', 'Fee', 0, false, false, false, false, false, true, false, false, false);
11045
11257
  const feeUnits = new TransactionType('FU', 'Fee Units', 'Fee', 0, false, false, false, false, true, false, false, false, false);
11258
+ const delist = new TransactionType('DL', 'Delist', 'Delist', 1, false, false, false, false, false, false, true, false, false);
11046
11259
 
11047
11260
  const distributionCash = new TransactionType('DC', 'Distribution (Cash)', 'Cash Distribution', 1, false, false, true, false, false, false, true, false, false);
11048
11261
  const distributionReinvest = new TransactionType('DY', 'Distribution (Reinvested)', 'Distribution Reinvest', 1, false, false, false, true, false, false, true, false, false);
@@ -11678,6 +11891,10 @@ module.exports = (() => {
11678
11891
  static get VALUATION() {
11679
11892
  return valuation;
11680
11893
  }
11894
+
11895
+ static get DELIST() {
11896
+ return delist;
11897
+ }
11681
11898
 
11682
11899
  static get INCOME() {
11683
11900
  return income;
@@ -11882,12 +12099,23 @@ module.exports = (() => {
11882
12099
  .withField('sequence', DataType.NUMBER, true)
11883
12100
  .withField('type', DataType.forEnum(TransactionType, 'TransactionType'))
11884
12101
  .withField('date', DataType.DAY)
11885
- .withField('value', DataType.DECIMAL)
12102
+ .withField('rate', DataType.DECIMAL, true)
12103
+ .withField('value', DataType.DECIMAL, true)
11886
12104
  .withField('force', DataType.BOOLEAN, true)
11887
12105
  .schema
11888
12106
  );
11889
-
11890
- const income = new TransactionSchema(SchemaBuilder.withName(TransactionType.INCOME.code)
12107
+
12108
+ const delist = new TransactionSchema(SchemaBuilder.withName(TransactionType.DELIST.code)
12109
+ .withField('portfolio', DataType.STRING)
12110
+ .withField('position', DataType.STRING)
12111
+ .withField('sequence', DataType.NUMBER, true)
12112
+ .withField('type', DataType.forEnum(TransactionType, 'TransactionType'))
12113
+ .withField('date', DataType.DAY)
12114
+ .withField('force', DataType.BOOLEAN, true)
12115
+ .schema
12116
+ );
12117
+
12118
+ const income = new TransactionSchema(SchemaBuilder.withName(TransactionType.INCOME.code)
11891
12119
  .withField('portfolio', DataType.STRING)
11892
12120
  .withField('position', DataType.STRING)
11893
12121
  .withField('sequence', DataType.NUMBER, true)
@@ -11913,6 +12141,7 @@ module.exports = (() => {
11913
12141
  addSchemaToMap(TransactionType.DEPOSIT, deposit);
11914
12142
  addSchemaToMap(TransactionType.WITHDRAWAL, withdrawal);
11915
12143
  addSchemaToMap(TransactionType.VALUATION, valuation);
12144
+ addSchemaToMap(TransactionType.DELIST, delist);
11916
12145
  addSchemaToMap(TransactionType.INCOME, income);
11917
12146
 
11918
12147
  return TransactionSchema;
@@ -12045,7 +12274,7 @@ module.exports = function () {
12045
12274
  * containing the current instance
12046
12275
  *
12047
12276
  * @public
12048
- * @returns {Promise.<JwtGateway>}
12277
+ * @returns {Promise<JwtGateway>}
12049
12278
  */
12050
12279
 
12051
12280
 
@@ -12075,7 +12304,7 @@ module.exports = function () {
12075
12304
  * Retrieves a JWT token from the remote server.
12076
12305
  *
12077
12306
  * @public
12078
- * @returns {Promise.<String>}
12307
+ * @returns {Promise<String>}
12079
12308
  */
12080
12309
 
12081
12310
  }, {
@@ -12115,7 +12344,7 @@ module.exports = function () {
12115
12344
  var refreshToken = function refreshToken() {
12116
12345
  var refreshPromise = scheduler.backoff(function () {
12117
12346
  return _this4.readToken();
12118
- }, 100, 'Read JWT token', 3).then(function (token) {
12347
+ }, 0, 'Read JWT token', 3).then(function (token) {
12119
12348
  if (_this4._refreshInterval > 0) {
12120
12349
  cachePromise = refreshPromise;
12121
12350
 
@@ -12183,8 +12412,8 @@ module.exports = function () {
12183
12412
  *
12184
12413
  * @public
12185
12414
  * @static
12186
- * @param {Promise.<Endpoint>|Endpoint} endpoint - The endpoint which vends JWT tokens.
12187
- * @returns {Promise.<JwtGateway>}
12415
+ * @param {Promise<Endpoint>|Endpoint} endpoint - The endpoint which vends JWT tokens.
12416
+ * @returns {Promise<JwtGateway>}
12188
12417
  */
12189
12418
 
12190
12419
  }, {
@@ -12212,8 +12441,8 @@ module.exports = function () {
12212
12441
  *
12213
12442
  * @public
12214
12443
  * @static
12215
- * @param {Promise.<Endpoint>|Endpoint} endpoint - The endpoint which vends JWT tokens.
12216
- * @returns {Promise.<RequestInterceptor>}
12444
+ * @param {Promise<Endpoint>|Endpoint} endpoint - The endpoint which vends JWT tokens.
12445
+ * @returns {Promise<RequestInterceptor>}
12217
12446
  */
12218
12447
 
12219
12448
  }, {
@@ -12229,7 +12458,7 @@ module.exports = function () {
12229
12458
  *
12230
12459
  * @public
12231
12460
  * @static
12232
- * @returns {Promise.<JwtGateway>}
12461
+ * @returns {Promise<JwtGateway>}
12233
12462
  */
12234
12463
 
12235
12464
  }, {
@@ -12243,7 +12472,7 @@ module.exports = function () {
12243
12472
  *
12244
12473
  * @public
12245
12474
  * @static
12246
- * @returns {Promise.<RequestInterceptor>}
12475
+ * @returns {Promise<RequestInterceptor>}
12247
12476
  */
12248
12477
 
12249
12478
  }, {
@@ -12259,7 +12488,7 @@ module.exports = function () {
12259
12488
  *
12260
12489
  * @public
12261
12490
  * @static
12262
- * @returns {Promise.<JwtGateway>}
12491
+ * @returns {Promise<JwtGateway>}
12263
12492
  */
12264
12493
 
12265
12494
  }, {
@@ -12273,7 +12502,7 @@ module.exports = function () {
12273
12502
  *
12274
12503
  * @public
12275
12504
  * @static
12276
- * @returns {Promise.<RequestInterceptor>}
12505
+ * @returns {Promise<RequestInterceptor>}
12277
12506
  */
12278
12507
 
12279
12508
  }, {
@@ -12290,7 +12519,7 @@ module.exports = function () {
12290
12519
  * @public
12291
12520
  * @static
12292
12521
  * @param {Function} tokenGenerator - A function which returns the JWT token.
12293
- * @returns {Promise.<JwtGateway>}
12522
+ * @returns {Promise<JwtGateway>}
12294
12523
  */
12295
12524
 
12296
12525
  }, {
@@ -12307,7 +12536,7 @@ module.exports = function () {
12307
12536
  * @public
12308
12537
  * @static
12309
12538
  * @param {JwtGateway~tokenGenerator} tokenGenerator - A function which returns the JWT token.
12310
- * @returns {Promise.<RequestInterceptor>}
12539
+ * @returns {Promise<RequestInterceptor>}
12311
12540
  */
12312
12541
 
12313
12542
  }, {
@@ -12370,7 +12599,7 @@ module.exports = function () {
12370
12599
  * A function returns a JWT token (or a promise for a JWT token).
12371
12600
  *
12372
12601
  * @callback JwtGateway~tokenGenerator
12373
- * @returns {String|Promise.<String>}
12602
+ * @returns {String|Promise<String>}
12374
12603
  */
12375
12604
 
12376
12605
  return JwtGateway;
@@ -12383,14 +12612,13 @@ module.exports = function () {
12383
12612
  'use strict';
12384
12613
 
12385
12614
  return {
12386
- version: '1.0.42'
12615
+ version: '1.3.2'
12387
12616
  };
12388
12617
  }();
12389
12618
 
12390
12619
  },{}],63:[function(require,module,exports){
12391
12620
  module.exports = require('./lib/axios');
12392
12621
  },{"./lib/axios":65}],64:[function(require,module,exports){
12393
- (function (process){
12394
12622
  'use strict';
12395
12623
 
12396
12624
  var utils = require('./../utils');
@@ -12399,7 +12627,6 @@ var buildURL = require('./../helpers/buildURL');
12399
12627
  var parseHeaders = require('./../helpers/parseHeaders');
12400
12628
  var isURLSameOrigin = require('./../helpers/isURLSameOrigin');
12401
12629
  var createError = require('../core/createError');
12402
- var btoa = (typeof window !== 'undefined' && window.btoa && window.btoa.bind(window)) || require('./../helpers/btoa');
12403
12630
 
12404
12631
  module.exports = function xhrAdapter(config) {
12405
12632
  return new Promise(function dispatchXhrRequest(resolve, reject) {
@@ -12411,22 +12638,6 @@ module.exports = function xhrAdapter(config) {
12411
12638
  }
12412
12639
 
12413
12640
  var request = new XMLHttpRequest();
12414
- var loadEvent = 'onreadystatechange';
12415
- var xDomain = false;
12416
-
12417
- // For IE 8/9 CORS support
12418
- // Only supports POST and GET calls and doesn't returns the response headers.
12419
- // DON'T do this for testing b/c XMLHttpRequest is mocked, not XDomainRequest.
12420
- if (process.env.NODE_ENV !== 'test' &&
12421
- typeof window !== 'undefined' &&
12422
- window.XDomainRequest && !('withCredentials' in request) &&
12423
- !isURLSameOrigin(config.url)) {
12424
- request = new window.XDomainRequest();
12425
- loadEvent = 'onload';
12426
- xDomain = true;
12427
- request.onprogress = function handleProgress() {};
12428
- request.ontimeout = function handleTimeout() {};
12429
- }
12430
12641
 
12431
12642
  // HTTP basic authentication
12432
12643
  if (config.auth) {
@@ -12441,8 +12652,8 @@ module.exports = function xhrAdapter(config) {
12441
12652
  request.timeout = config.timeout;
12442
12653
 
12443
12654
  // Listen for ready state
12444
- request[loadEvent] = function handleLoad() {
12445
- if (!request || (request.readyState !== 4 && !xDomain)) {
12655
+ request.onreadystatechange = function handleLoad() {
12656
+ if (!request || request.readyState !== 4) {
12446
12657
  return;
12447
12658
  }
12448
12659
 
@@ -12459,9 +12670,8 @@ module.exports = function xhrAdapter(config) {
12459
12670
  var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response;
12460
12671
  var response = {
12461
12672
  data: responseData,
12462
- // IE sends 1223 instead of 204 (https://github.com/axios/axios/issues/201)
12463
- status: request.status === 1223 ? 204 : request.status,
12464
- statusText: request.status === 1223 ? 'No Content' : request.statusText,
12673
+ status: request.status,
12674
+ statusText: request.statusText,
12465
12675
  headers: responseHeaders,
12466
12676
  config: config,
12467
12677
  request: request
@@ -12473,6 +12683,18 @@ module.exports = function xhrAdapter(config) {
12473
12683
  request = null;
12474
12684
  };
12475
12685
 
12686
+ // Handle browser request cancellation (as opposed to a manual cancellation)
12687
+ request.onabort = function handleAbort() {
12688
+ if (!request) {
12689
+ return;
12690
+ }
12691
+
12692
+ reject(createError('Request aborted', config, 'ECONNABORTED', request));
12693
+
12694
+ // Clean up request
12695
+ request = null;
12696
+ };
12697
+
12476
12698
  // Handle low level network errors
12477
12699
  request.onerror = function handleError() {
12478
12700
  // Real errors are hidden from us by the browser
@@ -12500,8 +12722,8 @@ module.exports = function xhrAdapter(config) {
12500
12722
 
12501
12723
  // Add xsrf header
12502
12724
  var xsrfValue = (config.withCredentials || isURLSameOrigin(config.url)) && config.xsrfCookieName ?
12503
- cookies.read(config.xsrfCookieName) :
12504
- undefined;
12725
+ cookies.read(config.xsrfCookieName) :
12726
+ undefined;
12505
12727
 
12506
12728
  if (xsrfValue) {
12507
12729
  requestHeaders[config.xsrfHeaderName] = xsrfValue;
@@ -12572,13 +12794,13 @@ module.exports = function xhrAdapter(config) {
12572
12794
  });
12573
12795
  };
12574
12796
 
12575
- }).call(this,require('_process'))
12576
- },{"../core/createError":71,"./../core/settle":74,"./../helpers/btoa":78,"./../helpers/buildURL":79,"./../helpers/cookies":81,"./../helpers/isURLSameOrigin":83,"./../helpers/parseHeaders":85,"./../utils":87,"_process":89}],65:[function(require,module,exports){
12797
+ },{"../core/createError":71,"./../core/settle":75,"./../helpers/buildURL":79,"./../helpers/cookies":81,"./../helpers/isURLSameOrigin":83,"./../helpers/parseHeaders":85,"./../utils":87}],65:[function(require,module,exports){
12577
12798
  'use strict';
12578
12799
 
12579
12800
  var utils = require('./utils');
12580
12801
  var bind = require('./helpers/bind');
12581
12802
  var Axios = require('./core/Axios');
12803
+ var mergeConfig = require('./core/mergeConfig');
12582
12804
  var defaults = require('./defaults');
12583
12805
 
12584
12806
  /**
@@ -12608,7 +12830,7 @@ axios.Axios = Axios;
12608
12830
 
12609
12831
  // Factory for creating new instances
12610
12832
  axios.create = function create(instanceConfig) {
12611
- return createInstance(utils.merge(defaults, instanceConfig));
12833
+ return createInstance(mergeConfig(axios.defaults, instanceConfig));
12612
12834
  };
12613
12835
 
12614
12836
  // Expose Cancel & CancelToken
@@ -12627,7 +12849,7 @@ module.exports = axios;
12627
12849
  // Allow use of default import syntax in TypeScript
12628
12850
  module.exports.default = axios;
12629
12851
 
12630
- },{"./cancel/Cancel":66,"./cancel/CancelToken":67,"./cancel/isCancel":68,"./core/Axios":69,"./defaults":76,"./helpers/bind":77,"./helpers/spread":86,"./utils":87}],66:[function(require,module,exports){
12852
+ },{"./cancel/Cancel":66,"./cancel/CancelToken":67,"./cancel/isCancel":68,"./core/Axios":69,"./core/mergeConfig":74,"./defaults":77,"./helpers/bind":78,"./helpers/spread":86,"./utils":87}],66:[function(require,module,exports){
12631
12853
  'use strict';
12632
12854
 
12633
12855
  /**
@@ -12717,10 +12939,11 @@ module.exports = function isCancel(value) {
12717
12939
  },{}],69:[function(require,module,exports){
12718
12940
  'use strict';
12719
12941
 
12720
- var defaults = require('./../defaults');
12721
12942
  var utils = require('./../utils');
12943
+ var buildURL = require('../helpers/buildURL');
12722
12944
  var InterceptorManager = require('./InterceptorManager');
12723
12945
  var dispatchRequest = require('./dispatchRequest');
12946
+ var mergeConfig = require('./mergeConfig');
12724
12947
 
12725
12948
  /**
12726
12949
  * Create a new instance of Axios
@@ -12744,13 +12967,14 @@ Axios.prototype.request = function request(config) {
12744
12967
  /*eslint no-param-reassign:0*/
12745
12968
  // Allow for axios('example/url'[, config]) a la fetch API
12746
12969
  if (typeof config === 'string') {
12747
- config = utils.merge({
12748
- url: arguments[0]
12749
- }, arguments[1]);
12970
+ config = arguments[1] || {};
12971
+ config.url = arguments[0];
12972
+ } else {
12973
+ config = config || {};
12750
12974
  }
12751
12975
 
12752
- config = utils.merge(defaults, this.defaults, { method: 'get' }, config);
12753
- config.method = config.method.toLowerCase();
12976
+ config = mergeConfig(this.defaults, config);
12977
+ config.method = config.method ? config.method.toLowerCase() : 'get';
12754
12978
 
12755
12979
  // Hook up interceptors middleware
12756
12980
  var chain = [dispatchRequest, undefined];
@@ -12771,6 +12995,11 @@ Axios.prototype.request = function request(config) {
12771
12995
  return promise;
12772
12996
  };
12773
12997
 
12998
+ Axios.prototype.getUri = function getUri(config) {
12999
+ config = mergeConfig(this.defaults, config);
13000
+ return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, '');
13001
+ };
13002
+
12774
13003
  // Provide aliases for supported request methods
12775
13004
  utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
12776
13005
  /*eslint func-names:0*/
@@ -12795,7 +13024,7 @@ utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
12795
13024
 
12796
13025
  module.exports = Axios;
12797
13026
 
12798
- },{"./../defaults":76,"./../utils":87,"./InterceptorManager":70,"./dispatchRequest":72}],70:[function(require,module,exports){
13027
+ },{"../helpers/buildURL":79,"./../utils":87,"./InterceptorManager":70,"./dispatchRequest":72,"./mergeConfig":74}],70:[function(require,module,exports){
12799
13028
  'use strict';
12800
13029
 
12801
13030
  var utils = require('./../utils');
@@ -12957,7 +13186,7 @@ module.exports = function dispatchRequest(config) {
12957
13186
  });
12958
13187
  };
12959
13188
 
12960
- },{"../cancel/isCancel":68,"../defaults":76,"./../helpers/combineURLs":80,"./../helpers/isAbsoluteURL":82,"./../utils":87,"./transformData":75}],73:[function(require,module,exports){
13189
+ },{"../cancel/isCancel":68,"../defaults":77,"./../helpers/combineURLs":80,"./../helpers/isAbsoluteURL":82,"./../utils":87,"./transformData":76}],73:[function(require,module,exports){
12961
13190
  'use strict';
12962
13191
 
12963
13192
  /**
@@ -12975,14 +13204,88 @@ module.exports = function enhanceError(error, config, code, request, response) {
12975
13204
  if (code) {
12976
13205
  error.code = code;
12977
13206
  }
13207
+
12978
13208
  error.request = request;
12979
13209
  error.response = response;
13210
+ error.isAxiosError = true;
13211
+
13212
+ error.toJSON = function() {
13213
+ return {
13214
+ // Standard
13215
+ message: this.message,
13216
+ name: this.name,
13217
+ // Microsoft
13218
+ description: this.description,
13219
+ number: this.number,
13220
+ // Mozilla
13221
+ fileName: this.fileName,
13222
+ lineNumber: this.lineNumber,
13223
+ columnNumber: this.columnNumber,
13224
+ stack: this.stack,
13225
+ // Axios
13226
+ config: this.config,
13227
+ code: this.code
13228
+ };
13229
+ };
12980
13230
  return error;
12981
13231
  };
12982
13232
 
12983
13233
  },{}],74:[function(require,module,exports){
12984
13234
  'use strict';
12985
13235
 
13236
+ var utils = require('../utils');
13237
+
13238
+ /**
13239
+ * Config-specific merge-function which creates a new config-object
13240
+ * by merging two configuration objects together.
13241
+ *
13242
+ * @param {Object} config1
13243
+ * @param {Object} config2
13244
+ * @returns {Object} New object resulting from merging config2 to config1
13245
+ */
13246
+ module.exports = function mergeConfig(config1, config2) {
13247
+ // eslint-disable-next-line no-param-reassign
13248
+ config2 = config2 || {};
13249
+ var config = {};
13250
+
13251
+ utils.forEach(['url', 'method', 'params', 'data'], function valueFromConfig2(prop) {
13252
+ if (typeof config2[prop] !== 'undefined') {
13253
+ config[prop] = config2[prop];
13254
+ }
13255
+ });
13256
+
13257
+ utils.forEach(['headers', 'auth', 'proxy'], function mergeDeepProperties(prop) {
13258
+ if (utils.isObject(config2[prop])) {
13259
+ config[prop] = utils.deepMerge(config1[prop], config2[prop]);
13260
+ } else if (typeof config2[prop] !== 'undefined') {
13261
+ config[prop] = config2[prop];
13262
+ } else if (utils.isObject(config1[prop])) {
13263
+ config[prop] = utils.deepMerge(config1[prop]);
13264
+ } else if (typeof config1[prop] !== 'undefined') {
13265
+ config[prop] = config1[prop];
13266
+ }
13267
+ });
13268
+
13269
+ utils.forEach([
13270
+ 'baseURL', 'transformRequest', 'transformResponse', 'paramsSerializer',
13271
+ 'timeout', 'withCredentials', 'adapter', 'responseType', 'xsrfCookieName',
13272
+ 'xsrfHeaderName', 'onUploadProgress', 'onDownloadProgress', 'maxContentLength',
13273
+ 'validateStatus', 'maxRedirects', 'httpAgent', 'httpsAgent', 'cancelToken',
13274
+ 'socketPath'
13275
+ ], function defaultToConfig2(prop) {
13276
+ if (typeof config2[prop] !== 'undefined') {
13277
+ config[prop] = config2[prop];
13278
+ } else if (typeof config1[prop] !== 'undefined') {
13279
+ config[prop] = config1[prop];
13280
+ }
13281
+ });
13282
+
13283
+ return config;
13284
+ };
13285
+
13286
+ },{"../utils":87}],75:[function(require,module,exports){
13287
+ 'use strict';
13288
+
12986
13289
  var createError = require('./createError');
12987
13290
 
12988
13291
  /**
@@ -12994,8 +13297,7 @@ var createError = require('./createError');
12994
13297
  */
12995
13298
  module.exports = function settle(resolve, reject, response) {
12996
13299
  var validateStatus = response.config.validateStatus;
12997
- // Note: status is not exposed by XDomainRequest
12998
- if (!response.status || !validateStatus || validateStatus(response.status)) {
13300
+ if (!validateStatus || validateStatus(response.status)) {
12999
13301
  resolve(response);
13000
13302
  } else {
13001
13303
  reject(createError(
@@ -13008,7 +13310,7 @@ module.exports = function settle(resolve, reject, response) {
13008
13310
  }
13009
13311
  };
13010
13312
 
13011
- },{"./createError":71}],75:[function(require,module,exports){
13313
+ },{"./createError":71}],76:[function(require,module,exports){
13012
13314
  'use strict';
13013
13315
 
13014
13316
  var utils = require('./../utils');
@@ -13030,7 +13332,7 @@ module.exports = function transformData(data, headers, fns) {
13030
13332
  return data;
13031
13333
  };
13032
13334
 
13033
- },{"./../utils":87}],76:[function(require,module,exports){
13335
+ },{"./../utils":87}],77:[function(require,module,exports){
13034
13336
  (function (process){
13035
13337
  'use strict';
13036
13338
 
@@ -13049,12 +13351,13 @@ function setContentTypeIfUnset(headers, value) {
13049
13351
 
13050
13352
  function getDefaultAdapter() {
13051
13353
  var adapter;
13052
- if (typeof XMLHttpRequest !== 'undefined') {
13053
- // For browsers use XHR adapter
13054
- adapter = require('./adapters/xhr');
13055
- } else if (typeof process !== 'undefined') {
13354
+ // Only Node.JS has a process variable that is of [[Class]] process
13355
+ if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {
13056
13356
  // For node use HTTP adapter
13057
13357
  adapter = require('./adapters/http');
13358
+ } else if (typeof XMLHttpRequest !== 'undefined') {
13359
+ // For browsers use XHR adapter
13360
+ adapter = require('./adapters/xhr');
13058
13361
  }
13059
13362
  return adapter;
13060
13363
  }
@@ -13063,6 +13366,7 @@ var defaults = {
13063
13366
  adapter: getDefaultAdapter(),
13064
13367
 
13065
13368
  transformRequest: [function transformRequest(data, headers) {
13369
+ normalizeHeaderName(headers, 'Accept');
13066
13370
  normalizeHeaderName(headers, 'Content-Type');
13067
13371
  if (utils.isFormData(data) ||
13068
13372
  utils.isArrayBuffer(data) ||
@@ -13097,6 +13401,10 @@ var defaults = {
13097
13401
  return data;
13098
13402
  }],
13099
13403
 
13404
+ /**
13405
+ * A timeout in milliseconds to abort a request. If set to 0 (default) a
13406
+ * timeout is not created.
13407
+ */
13100
13408
  timeout: 0,
13101
13409
 
13102
13410
  xsrfCookieName: 'XSRF-TOKEN',
@@ -13126,7 +13434,7 @@ utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
13126
13434
  module.exports = defaults;
13127
13435
 
13128
13436
  }).call(this,require('_process'))
13129
- },{"./adapters/http":64,"./adapters/xhr":64,"./helpers/normalizeHeaderName":84,"./utils":87,"_process":89}],77:[function(require,module,exports){
13437
+ },{"./adapters/http":64,"./adapters/xhr":64,"./helpers/normalizeHeaderName":84,"./utils":87,"_process":89}],78:[function(require,module,exports){
13130
13438
  'use strict';
13131
13439
 
13132
13440
  module.exports = function bind(fn, thisArg) {
@@ -13139,44 +13447,6 @@ module.exports = function bind(fn, thisArg) {
13139
13447
  };
13140
13448
  };
13141
13449
 
13142
- },{}],78:[function(require,module,exports){
13143
- 'use strict';
13144
-
13145
- // btoa polyfill for IE<10 courtesy https://github.com/davidchambers/Base64.js
13146
-
13147
- var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
13148
-
13149
- function E() {
13150
- this.message = 'String contains an invalid character';
13151
- }
13152
- E.prototype = new Error;
13153
- E.prototype.code = 5;
13154
- E.prototype.name = 'InvalidCharacterError';
13155
-
13156
- function btoa(input) {
13157
- var str = String(input);
13158
- var output = '';
13159
- for (
13160
- // initialize result and counter
13161
- var block, charCode, idx = 0, map = chars;
13162
- // if the next str index does not exist:
13163
- // change the mapping table to "="
13164
- // check if d has no fractional digits
13165
- str.charAt(idx | 0) || (map = '=', idx % 1);
13166
- // "8 - idx % 1 * 8" generates the sequence 2, 4, 6, 8
13167
- output += map.charAt(63 & block >> 8 - idx % 1 * 8)
13168
- ) {
13169
- charCode = str.charCodeAt(idx += 3 / 4);
13170
- if (charCode > 0xFF) {
13171
- throw new E();
13172
- }
13173
- block = block << 8 | charCode;
13174
- }
13175
- return output;
13176
- }
13177
-
13178
- module.exports = btoa;
13179
-
13180
13450
  },{}],79:[function(require,module,exports){
13181
13451
  'use strict';
13182
13452
 
@@ -13221,9 +13491,7 @@ module.exports = function buildURL(url, params, paramsSerializer) {
13221
13491
 
13222
13492
  if (utils.isArray(val)) {
13223
13493
  key = key + '[]';
13224
- }
13225
-
13226
- if (!utils.isArray(val)) {
13494
+ } else {
13227
13495
  val = [val];
13228
13496
  }
13229
13497
 
@@ -13241,6 +13509,11 @@ module.exports = function buildURL(url, params, paramsSerializer) {
13241
13509
  }
13242
13510
 
13243
13511
  if (serializedParams) {
13512
+ var hashmarkIndex = url.indexOf('#');
13513
+ if (hashmarkIndex !== -1) {
13514
+ url = url.slice(0, hashmarkIndex);
13515
+ }
13516
+
13244
13517
  url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
13245
13518
  }
13246
13519
 
@@ -13272,50 +13545,50 @@ module.exports = (
13272
13545
  utils.isStandardBrowserEnv() ?
13273
13546
 
13274
13547
  // Standard browser envs support document.cookie
13275
- (function standardBrowserEnv() {
13276
- return {
13277
- write: function write(name, value, expires, path, domain, secure) {
13278
- var cookie = [];
13279
- cookie.push(name + '=' + encodeURIComponent(value));
13548
+ (function standardBrowserEnv() {
13549
+ return {
13550
+ write: function write(name, value, expires, path, domain, secure) {
13551
+ var cookie = [];
13552
+ cookie.push(name + '=' + encodeURIComponent(value));
13280
13553
 
13281
- if (utils.isNumber(expires)) {
13282
- cookie.push('expires=' + new Date(expires).toGMTString());
13283
- }
13554
+ if (utils.isNumber(expires)) {
13555
+ cookie.push('expires=' + new Date(expires).toGMTString());
13556
+ }
13284
13557
 
13285
- if (utils.isString(path)) {
13286
- cookie.push('path=' + path);
13287
- }
13558
+ if (utils.isString(path)) {
13559
+ cookie.push('path=' + path);
13560
+ }
13288
13561
 
13289
- if (utils.isString(domain)) {
13290
- cookie.push('domain=' + domain);
13291
- }
13562
+ if (utils.isString(domain)) {
13563
+ cookie.push('domain=' + domain);
13564
+ }
13292
13565
 
13293
- if (secure === true) {
13294
- cookie.push('secure');
13295
- }
13566
+ if (secure === true) {
13567
+ cookie.push('secure');
13568
+ }
13296
13569
 
13297
- document.cookie = cookie.join('; ');
13298
- },
13570
+ document.cookie = cookie.join('; ');
13571
+ },
13299
13572
 
13300
- read: function read(name) {
13301
- var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
13302
- return (match ? decodeURIComponent(match[3]) : null);
13303
- },
13573
+ read: function read(name) {
13574
+ var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
13575
+ return (match ? decodeURIComponent(match[3]) : null);
13576
+ },
13304
13577
 
13305
- remove: function remove(name) {
13306
- this.write(name, '', Date.now() - 86400000);
13307
- }
13308
- };
13309
- })() :
13578
+ remove: function remove(name) {
13579
+ this.write(name, '', Date.now() - 86400000);
13580
+ }
13581
+ };
13582
+ })() :
13310
13583
 
13311
13584
  // Non standard browser env (web workers, react-native) lack needed support.
13312
- (function nonStandardBrowserEnv() {
13313
- return {
13314
- write: function write() {},
13315
- read: function read() { return null; },
13316
- remove: function remove() {}
13317
- };
13318
- })()
13585
+ (function nonStandardBrowserEnv() {
13586
+ return {
13587
+ write: function write() {},
13588
+ read: function read() { return null; },
13589
+ remove: function remove() {}
13590
+ };
13591
+ })()
13319
13592
  );
13320
13593
 
13321
13594
  },{"./../utils":87}],82:[function(require,module,exports){
@@ -13344,64 +13617,64 @@ module.exports = (
13344
13617
 
13345
13618
  // Standard browser envs have full support of the APIs needed to test
13346
13619
  // whether the request URL is of the same origin as current location.
13347
- (function standardBrowserEnv() {
13348
- var msie = /(msie|trident)/i.test(navigator.userAgent);
13349
- var urlParsingNode = document.createElement('a');
13350
- var originURL;
13620
+ (function standardBrowserEnv() {
13621
+ var msie = /(msie|trident)/i.test(navigator.userAgent);
13622
+ var urlParsingNode = document.createElement('a');
13623
+ var originURL;
13351
13624
 
13352
- /**
13625
+ /**
13353
13626
  * Parse a URL to discover it's components
13354
13627
  *
13355
13628
  * @param {String} url The URL to be parsed
13356
13629
  * @returns {Object}
13357
13630
  */
13358
- function resolveURL(url) {
13359
- var href = url;
13631
+ function resolveURL(url) {
13632
+ var href = url;
13360
13633
 
13361
- if (msie) {
13634
+ if (msie) {
13362
13635
  // IE needs attribute set twice to normalize properties
13363
- urlParsingNode.setAttribute('href', href);
13364
- href = urlParsingNode.href;
13365
- }
13636
+ urlParsingNode.setAttribute('href', href);
13637
+ href = urlParsingNode.href;
13638
+ }
13366
13639
 
13367
- urlParsingNode.setAttribute('href', href);
13640
+ urlParsingNode.setAttribute('href', href);
13368
13641
 
13369
- // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
13370
- return {
13371
- href: urlParsingNode.href,
13372
- protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
13373
- host: urlParsingNode.host,
13374
- search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
13375
- hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
13376
- hostname: urlParsingNode.hostname,
13377
- port: urlParsingNode.port,
13378
- pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
13379
- urlParsingNode.pathname :
13380
- '/' + urlParsingNode.pathname
13381
- };
13382
- }
13642
+ // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
13643
+ return {
13644
+ href: urlParsingNode.href,
13645
+ protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
13646
+ host: urlParsingNode.host,
13647
+ search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
13648
+ hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
13649
+ hostname: urlParsingNode.hostname,
13650
+ port: urlParsingNode.port,
13651
+ pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
13652
+ urlParsingNode.pathname :
13653
+ '/' + urlParsingNode.pathname
13654
+ };
13655
+ }
13383
13656
 
13384
- originURL = resolveURL(window.location.href);
13657
+ originURL = resolveURL(window.location.href);
13385
13658
 
13386
- /**
13659
+ /**
13387
13660
  * Determine if a URL shares the same origin as the current location
13388
13661
  *
13389
13662
  * @param {String} requestURL The URL to test
13390
13663
  * @returns {boolean} True if URL shares the same origin, otherwise false
13391
13664
  */
13392
- return function isURLSameOrigin(requestURL) {
13393
- var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
13394
- return (parsed.protocol === originURL.protocol &&
13665
+ return function isURLSameOrigin(requestURL) {
13666
+ var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
13667
+ return (parsed.protocol === originURL.protocol &&
13395
13668
  parsed.host === originURL.host);
13396
- };
13397
- })() :
13669
+ };
13670
+ })() :
13398
13671
 
13399
13672
  // Non standard browser envs (web workers, react-native) lack needed support.
13400
- (function nonStandardBrowserEnv() {
13401
- return function isURLSameOrigin() {
13402
- return true;
13403
- };
13404
- })()
13673
+ (function nonStandardBrowserEnv() {
13674
+ return function isURLSameOrigin() {
13675
+ return true;
13676
+ };
13677
+ })()
13405
13678
  );
13406
13679
 
13407
13680
  },{"./../utils":87}],84:[function(require,module,exports){
@@ -13682,9 +13955,13 @@ function trim(str) {
13682
13955
  *
13683
13956
  * react-native:
13684
13957
  * navigator.product -> 'ReactNative'
13958
+ * nativescript
13959
+ * navigator.product -> 'NativeScript' or 'NS'
13685
13960
  */
13686
13961
  function isStandardBrowserEnv() {
13687
- if (typeof navigator !== 'undefined' && navigator.product === 'ReactNative') {
13962
+ if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' ||
13963
+ navigator.product === 'NativeScript' ||
13964
+ navigator.product === 'NS')) {
13688
13965
  return false;
13689
13966
  }
13690
13967
  return (
@@ -13765,6 +14042,32 @@ function merge(/* obj1, obj2, obj3, ... */) {
13765
14042
  return result;
13766
14043
  }
13767
14044
 
14045
+ /**
14046
+ * Function equal to merge with the difference being that no reference
14047
+ * to original objects is kept.
14048
+ *
14049
+ * @see merge
14050
+ * @param {Object} obj1 Object to merge
14051
+ * @returns {Object} Result of all merge properties
14052
+ */
14053
+ function deepMerge(/* obj1, obj2, obj3, ... */) {
14054
+ var result = {};
14055
+ function assignValue(val, key) {
14056
+ if (typeof result[key] === 'object' && typeof val === 'object') {
14057
+ result[key] = deepMerge(result[key], val);
14058
+ } else if (typeof val === 'object') {
14059
+ result[key] = deepMerge({}, val);
14060
+ } else {
14061
+ result[key] = val;
14062
+ }
14063
+ }
14064
+
14065
+ for (var i = 0, l = arguments.length; i < l; i++) {
14066
+ forEach(arguments[i], assignValue);
14067
+ }
14068
+ return result;
14069
+ }
14070
+
13768
14071
  /**
13769
14072
  * Extends object a by mutably adding to it the properties of object b.
13770
14073
  *
@@ -13803,11 +14106,12 @@ module.exports = {
13803
14106
  isStandardBrowserEnv: isStandardBrowserEnv,
13804
14107
  forEach: forEach,
13805
14108
  merge: merge,
14109
+ deepMerge: deepMerge,
13806
14110
  extend: extend,
13807
14111
  trim: trim
13808
14112
  };
13809
14113
 
13810
- },{"./helpers/bind":77,"is-buffer":90}],88:[function(require,module,exports){
14114
+ },{"./helpers/bind":78,"is-buffer":90}],88:[function(require,module,exports){
13811
14115
  /*
13812
14116
  * big.js v5.0.3
13813
14117
  * A small, fast, easy-to-use library for arbitrary-precision decimal arithmetic.
@@ -14942,19 +15246,9 @@ process.umask = function() { return 0; };
14942
15246
  * @license MIT
14943
15247
  */
14944
15248
 
14945
- // The _isBuffer check is for Safari 5-7 support, because it's missing
14946
- // Object.prototype.constructor. Remove this eventually
14947
- module.exports = function (obj) {
14948
- return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer)
14949
- }
14950
-
14951
- function isBuffer (obj) {
14952
- return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
14953
- }
14954
-
14955
- // For Node v0.10 support. Remove this eventually.
14956
- function isSlowBuffer (obj) {
14957
- return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0))
15249
+ module.exports = function isBuffer (obj) {
15250
+ return obj != null && obj.constructor != null &&
15251
+ typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
14958
15252
  }
14959
15253
 
14960
15254
  },{}],91:[function(require,module,exports){
@@ -18511,22 +18805,36 @@ moment.tz.load(require('./data/packed/latest.json'));
18511
18805
  function createDate (y, m, d, h, M, s, ms) {
18512
18806
  // can't just apply() to create a date:
18513
18807
  // https://stackoverflow.com/q/181348
18514
- var date = new Date(y, m, d, h, M, s, ms);
18515
-
18808
+ var date;
18516
18809
  // the date constructor remaps years 0-99 to 1900-1999
18517
- if (y < 100 && y >= 0 && isFinite(date.getFullYear())) {
18518
- date.setFullYear(y);
18810
+ if (y < 100 && y >= 0) {
18811
+ // preserve leap years using a full 400 year cycle, then reset
18812
+ date = new Date(y + 400, m, d, h, M, s, ms);
18813
+ if (isFinite(date.getFullYear())) {
18814
+ date.setFullYear(y);
18815
+ }
18816
+ } else {
18817
+ date = new Date(y, m, d, h, M, s, ms);
18519
18818
  }
18819
+
18520
18820
  return date;
18521
18821
  }
18522
18822
 
18523
18823
  function createUTCDate (y) {
18524
- var date = new Date(Date.UTC.apply(null, arguments));
18525
-
18824
+ var date;
18526
18825
  // the Date.UTC function remaps years 0-99 to 1900-1999
18527
- if (y < 100 && y >= 0 && isFinite(date.getUTCFullYear())) {
18528
- date.setUTCFullYear(y);
18826
+ if (y < 100 && y >= 0) {
18827
+ var args = Array.prototype.slice.call(arguments);
18828
+ // preserve leap years using a full 400 year cycle, then reset
18829
+ args[0] = y + 400;
18830
+ date = new Date(Date.UTC.apply(null, args));
18831
+ if (isFinite(date.getUTCFullYear())) {
18832
+ date.setUTCFullYear(y);
18833
+ }
18834
+ } else {
18835
+ date = new Date(Date.UTC.apply(null, arguments));
18529
18836
  }
18837
+
18530
18838
  return date;
18531
18839
  }
18532
18840
 
@@ -18628,7 +18936,7 @@ moment.tz.load(require('./data/packed/latest.json'));
18628
18936
 
18629
18937
  var defaultLocaleWeek = {
18630
18938
  dow : 0, // Sunday is the first day of the week.
18631
- doy : 6 // The week that contains Jan 1st is the first week of the year.
18939
+ doy : 6 // The week that contains Jan 6th is the first week of the year.
18632
18940
  };
18633
18941
 
18634
18942
  function localeFirstDayOfWeek () {
@@ -18737,25 +19045,28 @@ moment.tz.load(require('./data/packed/latest.json'));
18737
19045
  }
18738
19046
 
18739
19047
  // LOCALES
19048
+ function shiftWeekdays (ws, n) {
19049
+ return ws.slice(n, 7).concat(ws.slice(0, n));
19050
+ }
18740
19051
 
18741
19052
  var defaultLocaleWeekdays = 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_');
18742
19053
  function localeWeekdays (m, format) {
18743
- if (!m) {
18744
- return isArray(this._weekdays) ? this._weekdays :
18745
- this._weekdays['standalone'];
18746
- }
18747
- return isArray(this._weekdays) ? this._weekdays[m.day()] :
18748
- this._weekdays[this._weekdays.isFormat.test(format) ? 'format' : 'standalone'][m.day()];
19054
+ var weekdays = isArray(this._weekdays) ? this._weekdays :
19055
+ this._weekdays[(m && m !== true && this._weekdays.isFormat.test(format)) ? 'format' : 'standalone'];
19056
+ return (m === true) ? shiftWeekdays(weekdays, this._week.dow)
19057
+ : (m) ? weekdays[m.day()] : weekdays;
18749
19058
  }
18750
19059
 
18751
19060
  var defaultLocaleWeekdaysShort = 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_');
18752
19061
  function localeWeekdaysShort (m) {
18753
- return (m) ? this._weekdaysShort[m.day()] : this._weekdaysShort;
19062
+ return (m === true) ? shiftWeekdays(this._weekdaysShort, this._week.dow)
19063
+ : (m) ? this._weekdaysShort[m.day()] : this._weekdaysShort;
18754
19064
  }
18755
19065
 
18756
19066
  var defaultLocaleWeekdaysMin = 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_');
18757
19067
  function localeWeekdaysMin (m) {
18758
- return (m) ? this._weekdaysMin[m.day()] : this._weekdaysMin;
19068
+ return (m === true) ? shiftWeekdays(this._weekdaysMin, this._week.dow)
19069
+ : (m) ? this._weekdaysMin[m.day()] : this._weekdaysMin;
18759
19070
  }
18760
19071
 
18761
19072
  function handleStrictParse$1(weekdayName, format, strict) {
@@ -19504,13 +19815,13 @@ moment.tz.load(require('./data/packed/latest.json'));
19504
19815
  weekdayOverflow = true;
19505
19816
  }
19506
19817
  } else if (w.e != null) {
19507
- // local weekday -- counting starts from begining of week
19818
+ // local weekday -- counting starts from beginning of week
19508
19819
  weekday = w.e + dow;
19509
19820
  if (w.e < 0 || w.e > 6) {
19510
19821
  weekdayOverflow = true;
19511
19822
  }
19512
19823
  } else {
19513
- // default to begining of week
19824
+ // default to beginning of week
19514
19825
  weekday = dow;
19515
19826
  }
19516
19827
  }
@@ -20104,7 +20415,7 @@ moment.tz.load(require('./data/packed/latest.json'));
20104
20415
  years = normalizedInput.year || 0,
20105
20416
  quarters = normalizedInput.quarter || 0,
20106
20417
  months = normalizedInput.month || 0,
20107
- weeks = normalizedInput.week || 0,
20418
+ weeks = normalizedInput.week || normalizedInput.isoWeek || 0,
20108
20419
  days = normalizedInput.day || 0,
20109
20420
  hours = normalizedInput.hour || 0,
20110
20421
  minutes = normalizedInput.minute || 0,
@@ -20408,7 +20719,7 @@ moment.tz.load(require('./data/packed/latest.json'));
20408
20719
  ms : toInt(absRound(match[MILLISECOND] * 1000)) * sign // the millisecond decimal point is included in the match
20409
20720
  };
20410
20721
  } else if (!!(match = isoRegex.exec(input))) {
20411
- sign = (match[1] === '-') ? -1 : (match[1] === '+') ? 1 : 1;
20722
+ sign = (match[1] === '-') ? -1 : 1;
20412
20723
  duration = {
20413
20724
  y : parseIso(match[2], sign),
20414
20725
  M : parseIso(match[3], sign),
@@ -20450,7 +20761,7 @@ moment.tz.load(require('./data/packed/latest.json'));
20450
20761
  }
20451
20762
 
20452
20763
  function positiveMomentsDifference(base, other) {
20453
- var res = {milliseconds: 0, months: 0};
20764
+ var res = {};
20454
20765
 
20455
20766
  res.months = other.month() - base.month() +
20456
20767
  (other.year() - base.year()) * 12;
@@ -20559,7 +20870,7 @@ moment.tz.load(require('./data/packed/latest.json'));
20559
20870
  if (!(this.isValid() && localInput.isValid())) {
20560
20871
  return false;
20561
20872
  }
20562
- units = normalizeUnits(!isUndefined(units) ? units : 'millisecond');
20873
+ units = normalizeUnits(units) || 'millisecond';
20563
20874
  if (units === 'millisecond') {
20564
20875
  return this.valueOf() > localInput.valueOf();
20565
20876
  } else {
@@ -20572,7 +20883,7 @@ moment.tz.load(require('./data/packed/latest.json'));
20572
20883
  if (!(this.isValid() && localInput.isValid())) {
20573
20884
  return false;
20574
20885
  }
20575
- units = normalizeUnits(!isUndefined(units) ? units : 'millisecond');
20886
+ units = normalizeUnits(units) || 'millisecond';
20576
20887
  if (units === 'millisecond') {
20577
20888
  return this.valueOf() < localInput.valueOf();
20578
20889
  } else {
@@ -20581,9 +20892,14 @@ moment.tz.load(require('./data/packed/latest.json'));
20581
20892
  }
20582
20893
 
20583
20894
  function isBetween (from, to, units, inclusivity) {
20895
+ var localFrom = isMoment(from) ? from : createLocal(from),
20896
+ localTo = isMoment(to) ? to : createLocal(to);
20897
+ if (!(this.isValid() && localFrom.isValid() && localTo.isValid())) {
20898
+ return false;
20899
+ }
20584
20900
  inclusivity = inclusivity || '()';
20585
- return (inclusivity[0] === '(' ? this.isAfter(from, units) : !this.isBefore(from, units)) &&
20586
- (inclusivity[1] === ')' ? this.isBefore(to, units) : !this.isAfter(to, units));
20901
+ return (inclusivity[0] === '(' ? this.isAfter(localFrom, units) : !this.isBefore(localFrom, units)) &&
20902
+ (inclusivity[1] === ')' ? this.isBefore(localTo, units) : !this.isAfter(localTo, units));
20587
20903
  }
20588
20904
 
20589
20905
  function isSame (input, units) {
@@ -20592,7 +20908,7 @@ moment.tz.load(require('./data/packed/latest.json'));
20592
20908
  if (!(this.isValid() && localInput.isValid())) {
20593
20909
  return false;
20594
20910
  }
20595
- units = normalizeUnits(units || 'millisecond');
20911
+ units = normalizeUnits(units) || 'millisecond';
20596
20912
  if (units === 'millisecond') {
20597
20913
  return this.valueOf() === localInput.valueOf();
20598
20914
  } else {
@@ -20602,11 +20918,11 @@ moment.tz.load(require('./data/packed/latest.json'));
20602
20918
  }
20603
20919
 
20604
20920
  function isSameOrAfter (input, units) {
20605
- return this.isSame(input, units) || this.isAfter(input,units);
20921
+ return this.isSame(input, units) || this.isAfter(input, units);
20606
20922
  }
20607
20923
 
20608
20924
  function isSameOrBefore (input, units) {
20609
- return this.isSame(input, units) || this.isBefore(input,units);
20925
+ return this.isSame(input, units) || this.isBefore(input, units);
20610
20926
  }
20611
20927
 
20612
20928
  function diff (input, units, asFloat) {
@@ -20783,62 +21099,130 @@ moment.tz.load(require('./data/packed/latest.json'));
20783
21099
  return this._locale;
20784
21100
  }
20785
21101
 
21102
+ var MS_PER_SECOND = 1000;
21103
+ var MS_PER_MINUTE = 60 * MS_PER_SECOND;
21104
+ var MS_PER_HOUR = 60 * MS_PER_MINUTE;
21105
+ var MS_PER_400_YEARS = (365 * 400 + 97) * 24 * MS_PER_HOUR;
21106
+
21107
+ // actual modulo - handles negative numbers (for dates before 1970):
21108
+ function mod$1(dividend, divisor) {
21109
+ return (dividend % divisor + divisor) % divisor;
21110
+ }
21111
+
21112
+ function localStartOfDate(y, m, d) {
21113
+ // the date constructor remaps years 0-99 to 1900-1999
21114
+ if (y < 100 && y >= 0) {
21115
+ // preserve leap years using a full 400 year cycle, then reset
21116
+ return new Date(y + 400, m, d) - MS_PER_400_YEARS;
21117
+ } else {
21118
+ return new Date(y, m, d).valueOf();
21119
+ }
21120
+ }
21121
+
21122
+ function utcStartOfDate(y, m, d) {
21123
+ // Date.UTC remaps years 0-99 to 1900-1999
21124
+ if (y < 100 && y >= 0) {
21125
+ // preserve leap years using a full 400 year cycle, then reset
21126
+ return Date.UTC(y + 400, m, d) - MS_PER_400_YEARS;
21127
+ } else {
21128
+ return Date.UTC(y, m, d);
21129
+ }
21130
+ }
21131
+
20786
21132
  function startOf (units) {
21133
+ var time;
20787
21134
  units = normalizeUnits(units);
20788
- // the following switch intentionally omits break keywords
20789
- // to utilize falling through the cases.
21135
+ if (units === undefined || units === 'millisecond' || !this.isValid()) {
21136
+ return this;
21137
+ }
21138
+
21139
+ var startOfDate = this._isUTC ? utcStartOfDate : localStartOfDate;
21140
+
20790
21141
  switch (units) {
20791
21142
  case 'year':
20792
- this.month(0);
20793
- /* falls through */
21143
+ time = startOfDate(this.year(), 0, 1);
21144
+ break;
20794
21145
  case 'quarter':
21146
+ time = startOfDate(this.year(), this.month() - this.month() % 3, 1);
21147
+ break;
20795
21148
  case 'month':
20796
- this.date(1);
20797
- /* falls through */
21149
+ time = startOfDate(this.year(), this.month(), 1);
21150
+ break;
20798
21151
  case 'week':
21152
+ time = startOfDate(this.year(), this.month(), this.date() - this.weekday());
21153
+ break;
20799
21154
  case 'isoWeek':
21155
+ time = startOfDate(this.year(), this.month(), this.date() - (this.isoWeekday() - 1));
21156
+ break;
20800
21157
  case 'day':
20801
21158
  case 'date':
20802
- this.hours(0);
20803
- /* falls through */
21159
+ time = startOfDate(this.year(), this.month(), this.date());
21160
+ break;
20804
21161
  case 'hour':
20805
- this.minutes(0);
20806
- /* falls through */
21162
+ time = this._d.valueOf();
21163
+ time -= mod$1(time + (this._isUTC ? 0 : this.utcOffset() * MS_PER_MINUTE), MS_PER_HOUR);
21164
+ break;
20807
21165
  case 'minute':
20808
- this.seconds(0);
20809
- /* falls through */
21166
+ time = this._d.valueOf();
21167
+ time -= mod$1(time, MS_PER_MINUTE);
21168
+ break;
20810
21169
  case 'second':
20811
- this.milliseconds(0);
20812
- }
20813
-
20814
- // weeks are a special case
20815
- if (units === 'week') {
20816
- this.weekday(0);
20817
- }
20818
- if (units === 'isoWeek') {
20819
- this.isoWeekday(1);
20820
- }
20821
-
20822
- // quarters are also special
20823
- if (units === 'quarter') {
20824
- this.month(Math.floor(this.month() / 3) * 3);
21170
+ time = this._d.valueOf();
21171
+ time -= mod$1(time, MS_PER_SECOND);
21172
+ break;
20825
21173
  }
20826
21174
 
21175
+ this._d.setTime(time);
21176
+ hooks.updateOffset(this, true);
20827
21177
  return this;
20828
21178
  }
20829
21179
 
20830
21180
  function endOf (units) {
21181
+ var time;
20831
21182
  units = normalizeUnits(units);
20832
- if (units === undefined || units === 'millisecond') {
21183
+ if (units === undefined || units === 'millisecond' || !this.isValid()) {
20833
21184
  return this;
20834
21185
  }
20835
21186
 
20836
- // 'date' is an alias for 'day', so it should be considered as such.
20837
- if (units === 'date') {
20838
- units = 'day';
21187
+ var startOfDate = this._isUTC ? utcStartOfDate : localStartOfDate;
21188
+
21189
+ switch (units) {
21190
+ case 'year':
21191
+ time = startOfDate(this.year() + 1, 0, 1) - 1;
21192
+ break;
21193
+ case 'quarter':
21194
+ time = startOfDate(this.year(), this.month() - this.month() % 3 + 3, 1) - 1;
21195
+ break;
21196
+ case 'month':
21197
+ time = startOfDate(this.year(), this.month() + 1, 1) - 1;
21198
+ break;
21199
+ case 'week':
21200
+ time = startOfDate(this.year(), this.month(), this.date() - this.weekday() + 7) - 1;
21201
+ break;
21202
+ case 'isoWeek':
21203
+ time = startOfDate(this.year(), this.month(), this.date() - (this.isoWeekday() - 1) + 7) - 1;
21204
+ break;
21205
+ case 'day':
21206
+ case 'date':
21207
+ time = startOfDate(this.year(), this.month(), this.date() + 1) - 1;
21208
+ break;
21209
+ case 'hour':
21210
+ time = this._d.valueOf();
21211
+ time += MS_PER_HOUR - mod$1(time + (this._isUTC ? 0 : this.utcOffset() * MS_PER_MINUTE), MS_PER_HOUR) - 1;
21212
+ break;
21213
+ case 'minute':
21214
+ time = this._d.valueOf();
21215
+ time += MS_PER_MINUTE - mod$1(time, MS_PER_MINUTE) - 1;
21216
+ break;
21217
+ case 'second':
21218
+ time = this._d.valueOf();
21219
+ time += MS_PER_SECOND - mod$1(time, MS_PER_SECOND) - 1;
21220
+ break;
20839
21221
  }
20840
21222
 
20841
- return this.startOf(units).add(1, (units === 'isoWeek' ? 'week' : units)).subtract(1, 'ms');
21223
+ this._d.setTime(time);
21224
+ hooks.updateOffset(this, true);
21225
+ return this;
20842
21226
  }
20843
21227
 
20844
21228
  function valueOf () {
@@ -21544,10 +21928,14 @@ moment.tz.load(require('./data/packed/latest.json'));
21544
21928
 
21545
21929
  units = normalizeUnits(units);
21546
21930
 
21547
- if (units === 'month' || units === 'year') {
21548
- days = this._days + milliseconds / 864e5;
21931
+ if (units === 'month' || units === 'quarter' || units === 'year') {
21932
+ days = this._days + milliseconds / 864e5;
21549
21933
  months = this._months + daysToMonths(days);
21550
- return units === 'month' ? months : months / 12;
21934
+ switch (units) {
21935
+ case 'month': return months;
21936
+ case 'quarter': return months / 3;
21937
+ case 'year': return months / 12;
21938
+ }
21551
21939
  } else {
21552
21940
  // handle milliseconds separately because of floating point math errors (issue #1867)
21553
21941
  days = this._days + Math.round(monthsToDays(this._months));
@@ -21590,6 +21978,7 @@ moment.tz.load(require('./data/packed/latest.json'));
21590
21978
  var asDays = makeAs('d');
21591
21979
  var asWeeks = makeAs('w');
21592
21980
  var asMonths = makeAs('M');
21981
+ var asQuarters = makeAs('Q');
21593
21982
  var asYears = makeAs('y');
21594
21983
 
21595
21984
  function clone$1 () {
@@ -21781,6 +22170,7 @@ moment.tz.load(require('./data/packed/latest.json'));
21781
22170
  proto$2.asDays = asDays;
21782
22171
  proto$2.asWeeks = asWeeks;
21783
22172
  proto$2.asMonths = asMonths;
22173
+ proto$2.asQuarters = asQuarters;
21784
22174
  proto$2.asYears = asYears;
21785
22175
  proto$2.valueOf = valueOf$1;
21786
22176
  proto$2._bubble = bubble;
@@ -21825,7 +22215,7 @@ moment.tz.load(require('./data/packed/latest.json'));
21825
22215
  // Side effect imports
21826
22216
 
21827
22217
 
21828
- hooks.version = '2.22.2';
22218
+ hooks.version = '2.24.0';
21829
22219
 
21830
22220
  setHookCallback(createLocal);
21831
22221
 
@@ -21866,7 +22256,7 @@ moment.tz.load(require('./data/packed/latest.json'));
21866
22256
  TIME: 'HH:mm', // <input type="time" />
21867
22257
  TIME_SECONDS: 'HH:mm:ss', // <input type="time" step="1" />
21868
22258
  TIME_MS: 'HH:mm:ss.SSS', // <input type="time" step="0.001" />
21869
- WEEK: 'YYYY-[W]WW', // <input type="week" />
22259
+ WEEK: 'GGGG-[W]WW', // <input type="week" />
21870
22260
  MONTH: 'YYYY-MM' // <input type="month" />
21871
22261
  };
21872
22262