@barchart/portfolio-client-js 1.3.4 → 1.3.7

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('portfolios', 'portfolios').withVariableParameter('portfolio', 'portfolio', 'portfolio', false).withLiteralParameter('reports', 'reports').withLiteralParameter('brokerage', 'brokerage').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) {
@@ -291,8 +306,8 @@ module.exports = function () {
291
306
  });
292
307
  }).withRequestInterceptor(requestInterceptorToUse).withRequestInterceptor(RequestInterceptor.PLAIN_TEXT_RESPONSE).withResponseInterceptor(responseInterceptorForBrokerageReportAvailabilityDeserialization).withErrorInterceptor(ErrorInterceptor.GENERAL).endpoint;
293
308
 
294
- _this._brokerageReportUrlGenerator = function (portfolio, frame, end) {
295
- return 'https://' + host + '/binary/reports/portfolios/' + portfolio + '/frames/' + frame.code + '/date/' + end.format();
309
+ _this._brokerageReportUrlGenerator = function (user, portfolio, frame, end) {
310
+ return 'https://' + Configuration.getBrokerageHost(host) + '/reports/portfolios/' + portfolio + '/frames/' + frame.code + '/date/' + end.format() + '/' + user;
296
311
  };
297
312
  return _this;
298
313
  }
@@ -929,6 +944,7 @@ module.exports = function () {
929
944
  * Generates a URL suitable for downloading a brokerage report (as a PDF).
930
945
  *
931
946
  * @public
947
+ * @param {String} user
932
948
  * @param {String} portfolio
933
949
  * @param {PositionSummaryFrame} frame
934
950
  * @param {Day} end
@@ -937,17 +953,18 @@ module.exports = function () {
937
953
 
938
954
  }, {
939
955
  key: 'getBrokerageReportUrl',
940
- value: function getBrokerageReportUrl(portfolio, frame, end) {
956
+ value: function getBrokerageReportUrl(user, portfolio, frame, end) {
941
957
  var _this21 = this;
942
958
 
943
959
  return Promise.resolve().then(function () {
944
960
  checkStart.call(_this21);
945
961
 
962
+ assert.argumentIsRequired(user, 'user', String);
946
963
  assert.argumentIsRequired(portfolio, 'portfolio', String);
947
964
  assert.argumentIsRequired(frame, 'frame', PositionSummaryFrame, 'PositionSummaryFrame');
948
965
  assert.argumentIsRequired(end, 'end', Day, 'Day');
949
966
 
950
- return _this21._brokerageReportUrlGenerator(portfolio, frame, end);
967
+ return _this21._brokerageReportUrlGenerator(user, portfolio, frame, end);
951
968
  });
952
969
  }
953
970
 
@@ -1544,7 +1561,7 @@ module.exports = function () {
1544
1561
 
1545
1562
  function _forDevelopment(userId, legacyUserId) {
1546
1563
  return EndpointBuilder.for('read-jwt-token-for-development', 'lookup user identity').withVerb(VerbType.GET).withProtocol(ProtocolType.HTTPS).withHost(Configuration.developmentHost).withPathBuilder(function (pb) {
1547
- pb.withLiteralParameter('json', 'json').withLiteralParameter('token', 'token').withLiteralParameter('barchart', 'barchart').withLiteralParameter('generator', 'generator');
1564
+ pb.withLiteralParameter('token', 'token').withLiteralParameter('barchart', 'barchart').withLiteralParameter('generator', 'generator');
1548
1565
  }).withQueryBuilder(function (qb) {
1549
1566
  qb.withLiteralParameter('user', 'userId', userId).withLiteralParameter('legacy user', 'userLegacyId', legacyUserId).withLiteralParameter('user context', 'userContext', 'TGAM').withLiteralParameter('user permission level', 'userPermissions', 'registered');
1550
1567
  }).withResponseInterceptor(ResponseInterceptor.DATA).endpoint;
@@ -1552,19 +1569,19 @@ module.exports = function () {
1552
1569
 
1553
1570
  function _forStaging(externalRequestInterceptor) {
1554
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) {
1555
- pb.withLiteralParameter('json', 'json').withLiteralParameter('token', 'token').withLiteralParameter('system', 'tgam').withLiteralParameter('converter', 'converter');
1572
+ pb.withLiteralParameter('token', 'token').withLiteralParameter('system', 'tgam').withLiteralParameter('converter', 'converter');
1556
1573
  }).withRequestInterceptor(externalRequestInterceptor).withResponseInterceptor(ResponseInterceptor.DATA).endpoint;
1557
1574
  }
1558
1575
 
1559
1576
  function _forProduction(externalRequestInterceptor) {
1560
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) {
1561
- pb.withLiteralParameter('json', 'json').withLiteralParameter('token', 'token').withLiteralParameter('system', 'tgam').withLiteralParameter('converter', 'converter');
1578
+ pb.withLiteralParameter('token', 'token').withLiteralParameter('system', 'tgam').withLiteralParameter('converter', 'converter');
1562
1579
  }).withRequestInterceptor(externalRequestInterceptor).withResponseInterceptor(ResponseInterceptor.DATA).endpoint;
1563
1580
  }
1564
1581
 
1565
1582
  function _forAdmin(userId, legacyUserId) {
1566
1583
  return EndpointBuilder.for('read-jwt-token-for-admin', 'lookup user identity').withVerb(VerbType.GET).withProtocol(ProtocolType.HTTPS).withHost(Configuration.adminHost).withPathBuilder(function (pb) {
1567
- pb.withLiteralParameter('json', 'json').withLiteralParameter('token', 'token').withLiteralParameter('barchart', 'barchart').withLiteralParameter('generator', 'generator');
1584
+ pb.withLiteralParameter('token', 'token').withLiteralParameter('barchart', 'barchart').withLiteralParameter('generator', 'generator');
1568
1585
  }).withQueryBuilder(function (qb) {
1569
1586
  if (userId) {
1570
1587
  qb.withLiteralParameter('user', 'userId', userId);
@@ -1593,7 +1610,7 @@ module.exports = function () {
1593
1610
  return {
1594
1611
  JwtGateway: JwtGateway,
1595
1612
  PortfolioGateway: PortfolioGateway,
1596
- version: '1.3.4'
1613
+ version: '1.3.7'
1597
1614
  };
1598
1615
  }();
1599
1616
 
@@ -4381,7 +4398,7 @@ module.exports = function () {
4381
4398
  *
4382
4399
  * @public
4383
4400
  * @param {*} value - The value of the node.
4384
- * @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.
4385
4402
  */
4386
4403
 
4387
4404
  var Tree = function () {
@@ -5418,6 +5435,32 @@ module.exports = function () {
5418
5435
  return this.addYears(years, true);
5419
5436
  }
5420
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
+
5421
5464
  /**
5422
5465
  * Indicates if another {@link Day} occurs before the current instance.
5423
5466
  *
@@ -5558,7 +5601,7 @@ module.exports = function () {
5558
5601
  return this._month;
5559
5602
  }
5560
5603
 
5561
- /**
5604
+ /**day
5562
5605
  * The day of the month.
5563
5606
  *
5564
5607
  * @public
@@ -5579,7 +5622,7 @@ module.exports = function () {
5579
5622
  }
5580
5623
 
5581
5624
  /**
5582
- * 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
5583
5626
  * a {@link Day} instance.
5584
5627
  *
5585
5628
  * @public
@@ -5850,6 +5893,24 @@ module.exports = function () {
5850
5893
  return new Decimal(this._big.div(getBig(other)));
5851
5894
  }
5852
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
+
5853
5914
  /**
5854
5915
  * Returns a new {@link Decimal} with a value resulting from a rounding
5855
5916
  * operation on the current value.
@@ -6014,6 +6075,28 @@ module.exports = function () {
6014
6075
  return this._big.eq(getBig(other));
6015
6076
  }
6016
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
+
6017
6100
  /**
6018
6101
  * Returns true if the current instance is an integer (i.e. has no decimal
6019
6102
  * component).
@@ -7540,8 +7623,62 @@ module.exports = function () {
7540
7623
  }
7541
7624
 
7542
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;
7543
7653
  }
7544
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
+ }
7545
7682
  }();
7546
7683
 
7547
7684
  },{"./assert":37,"./is":40}],37:[function(require,module,exports){
@@ -7997,7 +8134,7 @@ module.exports = function () {
7997
8134
  * @static
7998
8135
  * @public
7999
8136
  * @param {*} candidate
8000
- * @returns {*|boolean}
8137
+ * @returns {boolean}
8001
8138
  */
8002
8139
  negative: function negative(candidate) {
8003
8140
  return this.number(candidate) && candidate < 0;
@@ -9824,7 +9961,7 @@ module.exports = function () {
9824
9961
  *
9825
9962
  * @public
9826
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.
9827
- * @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.
9828
9965
  * @param {string=} actionDescription - Description of the action to attempt, used for logging purposes.
9829
9966
  * @param {number=} maximumAttempts - The number of attempts to before giving up.
9830
9967
  * @param {Function=} failureCallback - If provided, will be invoked if a function is considered to be failing.
@@ -9848,59 +9985,61 @@ module.exports = function () {
9848
9985
  throw new Error('The Scheduler has been disposed.');
9849
9986
  }
9850
9987
 
9851
- var scheduleBackoff = function scheduleBackoff(failureCount, e) {
9852
- if (failureCount > 0 && is.fn(failureCallback)) {
9853
- failureCallback(failureCount);
9854
- }
9855
-
9856
- if (maximumAttempts > 0 && failureCount > maximumAttempts) {
9857
- var message = 'Maximum failures reached for ' + actionDescription;
9988
+ var processAction = function processAction(attempts) {
9989
+ return Promise.resolve().then(function () {
9990
+ var delay = void 0;
9858
9991
 
9859
- var rejection = void 0;
9992
+ if (attempts === 0) {
9993
+ delay = 0;
9994
+ } else {
9995
+ delay = (millisecondDelay || 1000) * Math.pow(2, attempts - 1);
9996
+ }
9860
9997
 
9861
- if (e) {
9862
- e.backoff = message;
9998
+ return _this4.schedule(actionToBackoff, delay, 'Attempt [ ' + attempts + ' ] for [ ' + (actionDescription || 'unnamed action') + ' ]');
9999
+ }).then(function (result) {
10000
+ var resultPromise = void 0;
9863
10001
 
9864
- 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');
9865
10004
  } else {
9866
- rejection = message;
10005
+ resultPromise = Promise.resolve(result);
9867
10006
  }
9868
10007
 
9869
- return Promise.reject(rejection);
9870
- }
10008
+ return resultPromise;
10009
+ }).catch(function (e) {
10010
+ if (is.fn(failureCallback)) {
10011
+ failureCallback(attempts);
10012
+ }
9871
10013
 
9872
- var backoffDelay = void 0;
10014
+ return Promise.reject(e);
10015
+ });
10016
+ };
9873
10017
 
9874
- if (failureCount === 0) {
9875
- backoffDelay = millisecondDelay || 0;
9876
- } else {
9877
- backoffDelay = (millisecondDelay || 1000) * Math.pow(2, failureCount);
9878
- }
10018
+ var attempts = 0;
9879
10019
 
9880
- 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');
9881
10024
 
9882
- if (is.undefined(failureValue)) {
9883
- successPredicate = function successPredicate(value) {
9884
- return value;
9885
- };
9886
- } else {
9887
- successPredicate = function successPredicate(value) {
9888
- return !object.equals(value, failureValue);
9889
- };
9890
- }
10025
+ var rejectPromise = void 0;
9891
10026
 
9892
- return _this4.schedule(actionToBackoff, backoffDelay, (actionDescription || 'unspecified') + ', attempt ' + (failureCount + 1)).then(function (result) {
9893
- if (successPredicate(result)) {
9894
- 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;
9895
10036
  } else {
9896
- return scheduleBackoff(++failureCount);
10037
+ return processActionRecursive();
9897
10038
  }
9898
- }).catch(function (e) {
9899
- return scheduleBackoff(++failureCount, e);
9900
10039
  });
9901
10040
  };
9902
10041
 
9903
- return scheduleBackoff(0);
10042
+ return processActionRecursive();
9904
10043
  });
9905
10044
  }
9906
10045
  }, {
@@ -9961,9 +10100,10 @@ module.exports = (() => {
9961
10100
  *
9962
10101
  * @public
9963
10102
  * @extends {Enum}
10103
+ * @param {String} code
9964
10104
  * @param {String} description
9965
10105
  * @param {String} alternateDescription
9966
- * @param {String} code
10106
+ * @param {Boolean} canExistEmpty
9967
10107
  * @param {Boolean} canReinvest
9968
10108
  * @param {Boolean} canShort
9969
10109
  * @param {Boolean} canSwitchDirection
@@ -9975,10 +10115,11 @@ module.exports = (() => {
9975
10115
  * @param {Function} generator
9976
10116
  */
9977
10117
  class InstrumentType extends Enum {
9978
- 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) {
9979
10119
  super(code, description);
9980
10120
 
9981
10121
  assert.argumentIsRequired(alternateDescription, 'alternateDescription', String);
10122
+ assert.argumentIsRequired(canExistEmpty, 'canExistEmpty', Boolean);
9982
10123
  assert.argumentIsRequired(canReinvest, 'canReinvest', Boolean);
9983
10124
  assert.argumentIsRequired(canShort, 'canShort', Boolean);
9984
10125
  assert.argumentIsRequired(canSwitchDirection, 'canSwitchDirection', Boolean);
@@ -9990,6 +10131,8 @@ module.exports = (() => {
9990
10131
  assert.argumentIsRequired(generator, 'generator', Function);
9991
10132
 
9992
10133
  this._alternateDescription = alternateDescription;
10134
+
10135
+ this._canExistEmpty = canExistEmpty;
9993
10136
  this._canReinvest = canReinvest;
9994
10137
  this._canShort = canShort;
9995
10138
  this._canSwitchDirection = canSwitchDirection;
@@ -10012,6 +10155,16 @@ module.exports = (() => {
10012
10155
  return this._alternateDescription;
10013
10156
  }
10014
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
+
10015
10168
  /**
10016
10169
  * Indicates if the instrument type allows automatic reinvestment.
10017
10170
  *
@@ -10192,10 +10345,10 @@ module.exports = (() => {
10192
10345
  }
10193
10346
  }
10194
10347
 
10195
- const cash = new InstrumentType('CASH', 'cash', 'Cash', false, false, true, false, false, false, false, false, (instrument) => `BARCHART-${instrument.type.code}-${instrument.currency.code}`);
10196
- const equity = new InstrumentType('EQUITY', 'equity', 'Equities', true, true, false, true, true, true, true, true, (instrument) => `BARCHART-${instrument.type.code}-${instrument.symbol.barchart}`);
10197
- const fund = new InstrumentType('FUND', 'mutual fund', 'Funds', true, false, false, true, true, false, true, true, (instrument) => `BARCHART-${instrument.type.code}-${instrument.symbol.barchart}`);
10198
- 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()}`);
10199
10352
 
10200
10353
  const map = { };
10201
10354
 
@@ -10404,7 +10557,7 @@ module.exports = (() => {
10404
10557
  *
10405
10558
  * @public
10406
10559
  * @param {Number} periods
10407
- * @returns {Array.<PositionSummaryRange>}
10560
+ * @returns {PositionSummaryRange[]}
10408
10561
  */
10409
10562
  getRecentRanges(periods) {
10410
10563
  const startDate = this.getStartDate(periods);
@@ -10417,8 +10570,8 @@ module.exports = (() => {
10417
10570
  * Returns the ranges for the set of {@link Transaction} objects.
10418
10571
  *
10419
10572
  * @public
10420
- * @param {Array.<Transaction>} transactions
10421
- * @returns {Array.<PositionSummaryRange>}
10573
+ * @param {Transaction[]} transactions
10574
+ * @returns {PositionSummaryRange[]}
10422
10575
  */
10423
10576
  getRanges(transactions) {
10424
10577
  assert.argumentIsArray(transactions, 'transactions');
@@ -10431,7 +10584,7 @@ module.exports = (() => {
10431
10584
  *
10432
10585
  * @public
10433
10586
  * @param {Day} date
10434
- * @return {Array.<PositionSummaryRange>}
10587
+ * @return {PositionSummaryRange[]}
10435
10588
  */
10436
10589
  getRangesFromDate(date) {
10437
10590
  assert.argumentIsRequired(date, 'date', Day, 'Day');
@@ -10520,8 +10673,8 @@ module.exports = (() => {
10520
10673
  }
10521
10674
 
10522
10675
  const yearly = new PositionSummaryFrame('YEARLY', 'year', false, getYearlyRanges, getYearlyStartDate, getYearlyRangeDescription);
10523
- const quarterly = new PositionSummaryFrame('QUARTER', 'quarter', false, getQuarterlyRanges, getQuarterlyStartDate, getQuarterlyRangeDescription);
10524
- 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);
10525
10678
  const ytd = new PositionSummaryFrame('YTD', 'year-to-date', true, getYearToDateRanges, getYearToDateStartDate, getYearToDateRangeDescription);
10526
10679
 
10527
10680
  /**
@@ -10581,7 +10734,36 @@ module.exports = (() => {
10581
10734
  }
10582
10735
 
10583
10736
  function getMonthlyRanges(transactions) {
10584
- 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;
10585
10767
  }
10586
10768
 
10587
10769
  function getYearToDateRanges(transactions) {
@@ -10618,7 +10800,11 @@ module.exports = (() => {
10618
10800
  }
10619
10801
 
10620
10802
  function getMonthlyStartDate(periods, date) {
10621
- return null;
10803
+ const today = date || Day.getToday();
10804
+
10805
+ return today
10806
+ .subtractMonths(periods)
10807
+ .subtractDays(today.day);
10622
10808
  }
10623
10809
 
10624
10810
  function getYearToDateStartDate(periods, date) {
@@ -10626,7 +10812,7 @@ module.exports = (() => {
10626
10812
  }
10627
10813
 
10628
10814
  function getYearlyRangeDescription(start, end) {
10629
- return `Year ended ${end.year.toString()}`;
10815
+ return `Year ended ${end.format()}`;
10630
10816
  }
10631
10817
 
10632
10818
  function getQuarterlyRangeDescription(start, end) {
@@ -10634,7 +10820,7 @@ module.exports = (() => {
10634
10820
  }
10635
10821
 
10636
10822
  function getMonthlyRangeDescription(start, end) {
10637
- return '';
10823
+ return `Month ended ${end.format()}`;
10638
10824
  }
10639
10825
 
10640
10826
  function getYearToDateRangeDescription(start, end) {
@@ -10679,7 +10865,7 @@ module.exports = (() => {
10679
10865
  * @param {Boolean} corporateAction
10680
10866
  * @param {Boolean} initial
10681
10867
  * @param {Boolean} significant
10682
- * @param {Boolean} eod
10868
+ * @param {Boolean} system
10683
10869
  */
10684
10870
  class TransactionType extends Enum {
10685
10871
  constructor(code, description, display, sequence, purchase, sale, income, opening, closing, fee, corporateAction, initial, significant) {
@@ -11009,6 +11195,17 @@ module.exports = (() => {
11009
11195
  static get DEBIT() {
11010
11196
  return debit;
11011
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
+ }
11012
11209
 
11013
11210
  /**
11014
11211
  * A system-generated deposit, arising from another transaction.
@@ -11058,6 +11255,7 @@ module.exports = (() => {
11058
11255
  const split = new TransactionType('SP', 'Split', 'Split', 1, false, false, false, true, false, false, true, false, false);
11059
11256
  const fee = new TransactionType('F', 'Fee', 'Fee', 0, false, false, false, false, false, true, false, false, false);
11060
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);
11061
11259
 
11062
11260
  const distributionCash = new TransactionType('DC', 'Distribution (Cash)', 'Cash Distribution', 1, false, false, true, false, false, false, true, false, false);
11063
11261
  const distributionReinvest = new TransactionType('DY', 'Distribution (Reinvested)', 'Distribution Reinvest', 1, false, false, false, true, false, false, true, false, false);
@@ -11693,6 +11891,10 @@ module.exports = (() => {
11693
11891
  static get VALUATION() {
11694
11892
  return valuation;
11695
11893
  }
11894
+
11895
+ static get DELIST() {
11896
+ return delist;
11897
+ }
11696
11898
 
11697
11899
  static get INCOME() {
11698
11900
  return income;
@@ -11897,12 +12099,23 @@ module.exports = (() => {
11897
12099
  .withField('sequence', DataType.NUMBER, true)
11898
12100
  .withField('type', DataType.forEnum(TransactionType, 'TransactionType'))
11899
12101
  .withField('date', DataType.DAY)
11900
- .withField('value', DataType.DECIMAL)
12102
+ .withField('rate', DataType.DECIMAL, true)
12103
+ .withField('value', DataType.DECIMAL, true)
11901
12104
  .withField('force', DataType.BOOLEAN, true)
11902
12105
  .schema
11903
12106
  );
11904
-
11905
- 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)
11906
12119
  .withField('portfolio', DataType.STRING)
11907
12120
  .withField('position', DataType.STRING)
11908
12121
  .withField('sequence', DataType.NUMBER, true)
@@ -11928,6 +12141,7 @@ module.exports = (() => {
11928
12141
  addSchemaToMap(TransactionType.DEPOSIT, deposit);
11929
12142
  addSchemaToMap(TransactionType.WITHDRAWAL, withdrawal);
11930
12143
  addSchemaToMap(TransactionType.VALUATION, valuation);
12144
+ addSchemaToMap(TransactionType.DELIST, delist);
11931
12145
  addSchemaToMap(TransactionType.INCOME, income);
11932
12146
 
11933
12147
  return TransactionSchema;
@@ -12060,7 +12274,7 @@ module.exports = function () {
12060
12274
  * containing the current instance
12061
12275
  *
12062
12276
  * @public
12063
- * @returns {Promise.<JwtGateway>}
12277
+ * @returns {Promise<JwtGateway>}
12064
12278
  */
12065
12279
 
12066
12280
 
@@ -12090,7 +12304,7 @@ module.exports = function () {
12090
12304
  * Retrieves a JWT token from the remote server.
12091
12305
  *
12092
12306
  * @public
12093
- * @returns {Promise.<String>}
12307
+ * @returns {Promise<String>}
12094
12308
  */
12095
12309
 
12096
12310
  }, {
@@ -12130,7 +12344,7 @@ module.exports = function () {
12130
12344
  var refreshToken = function refreshToken() {
12131
12345
  var refreshPromise = scheduler.backoff(function () {
12132
12346
  return _this4.readToken();
12133
- }, 100, 'Read JWT token', 3).then(function (token) {
12347
+ }, 0, 'Read JWT token', 3).then(function (token) {
12134
12348
  if (_this4._refreshInterval > 0) {
12135
12349
  cachePromise = refreshPromise;
12136
12350
 
@@ -12198,8 +12412,8 @@ module.exports = function () {
12198
12412
  *
12199
12413
  * @public
12200
12414
  * @static
12201
- * @param {Promise.<Endpoint>|Endpoint} endpoint - The endpoint which vends JWT tokens.
12202
- * @returns {Promise.<JwtGateway>}
12415
+ * @param {Promise<Endpoint>|Endpoint} endpoint - The endpoint which vends JWT tokens.
12416
+ * @returns {Promise<JwtGateway>}
12203
12417
  */
12204
12418
 
12205
12419
  }, {
@@ -12227,8 +12441,8 @@ module.exports = function () {
12227
12441
  *
12228
12442
  * @public
12229
12443
  * @static
12230
- * @param {Promise.<Endpoint>|Endpoint} endpoint - The endpoint which vends JWT tokens.
12231
- * @returns {Promise.<RequestInterceptor>}
12444
+ * @param {Promise<Endpoint>|Endpoint} endpoint - The endpoint which vends JWT tokens.
12445
+ * @returns {Promise<RequestInterceptor>}
12232
12446
  */
12233
12447
 
12234
12448
  }, {
@@ -12244,7 +12458,7 @@ module.exports = function () {
12244
12458
  *
12245
12459
  * @public
12246
12460
  * @static
12247
- * @returns {Promise.<JwtGateway>}
12461
+ * @returns {Promise<JwtGateway>}
12248
12462
  */
12249
12463
 
12250
12464
  }, {
@@ -12258,7 +12472,7 @@ module.exports = function () {
12258
12472
  *
12259
12473
  * @public
12260
12474
  * @static
12261
- * @returns {Promise.<RequestInterceptor>}
12475
+ * @returns {Promise<RequestInterceptor>}
12262
12476
  */
12263
12477
 
12264
12478
  }, {
@@ -12274,7 +12488,7 @@ module.exports = function () {
12274
12488
  *
12275
12489
  * @public
12276
12490
  * @static
12277
- * @returns {Promise.<JwtGateway>}
12491
+ * @returns {Promise<JwtGateway>}
12278
12492
  */
12279
12493
 
12280
12494
  }, {
@@ -12288,7 +12502,7 @@ module.exports = function () {
12288
12502
  *
12289
12503
  * @public
12290
12504
  * @static
12291
- * @returns {Promise.<RequestInterceptor>}
12505
+ * @returns {Promise<RequestInterceptor>}
12292
12506
  */
12293
12507
 
12294
12508
  }, {
@@ -12305,7 +12519,7 @@ module.exports = function () {
12305
12519
  * @public
12306
12520
  * @static
12307
12521
  * @param {Function} tokenGenerator - A function which returns the JWT token.
12308
- * @returns {Promise.<JwtGateway>}
12522
+ * @returns {Promise<JwtGateway>}
12309
12523
  */
12310
12524
 
12311
12525
  }, {
@@ -12322,7 +12536,7 @@ module.exports = function () {
12322
12536
  * @public
12323
12537
  * @static
12324
12538
  * @param {JwtGateway~tokenGenerator} tokenGenerator - A function which returns the JWT token.
12325
- * @returns {Promise.<RequestInterceptor>}
12539
+ * @returns {Promise<RequestInterceptor>}
12326
12540
  */
12327
12541
 
12328
12542
  }, {
@@ -12385,7 +12599,7 @@ module.exports = function () {
12385
12599
  * A function returns a JWT token (or a promise for a JWT token).
12386
12600
  *
12387
12601
  * @callback JwtGateway~tokenGenerator
12388
- * @returns {String|Promise.<String>}
12602
+ * @returns {String|Promise<String>}
12389
12603
  */
12390
12604
 
12391
12605
  return JwtGateway;
@@ -12398,14 +12612,13 @@ module.exports = function () {
12398
12612
  'use strict';
12399
12613
 
12400
12614
  return {
12401
- version: '1.0.42'
12615
+ version: '1.3.2'
12402
12616
  };
12403
12617
  }();
12404
12618
 
12405
12619
  },{}],63:[function(require,module,exports){
12406
12620
  module.exports = require('./lib/axios');
12407
12621
  },{"./lib/axios":65}],64:[function(require,module,exports){
12408
- (function (process){
12409
12622
  'use strict';
12410
12623
 
12411
12624
  var utils = require('./../utils');
@@ -12414,7 +12627,6 @@ var buildURL = require('./../helpers/buildURL');
12414
12627
  var parseHeaders = require('./../helpers/parseHeaders');
12415
12628
  var isURLSameOrigin = require('./../helpers/isURLSameOrigin');
12416
12629
  var createError = require('../core/createError');
12417
- var btoa = (typeof window !== 'undefined' && window.btoa && window.btoa.bind(window)) || require('./../helpers/btoa');
12418
12630
 
12419
12631
  module.exports = function xhrAdapter(config) {
12420
12632
  return new Promise(function dispatchXhrRequest(resolve, reject) {
@@ -12426,22 +12638,6 @@ module.exports = function xhrAdapter(config) {
12426
12638
  }
12427
12639
 
12428
12640
  var request = new XMLHttpRequest();
12429
- var loadEvent = 'onreadystatechange';
12430
- var xDomain = false;
12431
-
12432
- // For IE 8/9 CORS support
12433
- // Only supports POST and GET calls and doesn't returns the response headers.
12434
- // DON'T do this for testing b/c XMLHttpRequest is mocked, not XDomainRequest.
12435
- if (process.env.NODE_ENV !== 'test' &&
12436
- typeof window !== 'undefined' &&
12437
- window.XDomainRequest && !('withCredentials' in request) &&
12438
- !isURLSameOrigin(config.url)) {
12439
- request = new window.XDomainRequest();
12440
- loadEvent = 'onload';
12441
- xDomain = true;
12442
- request.onprogress = function handleProgress() {};
12443
- request.ontimeout = function handleTimeout() {};
12444
- }
12445
12641
 
12446
12642
  // HTTP basic authentication
12447
12643
  if (config.auth) {
@@ -12456,8 +12652,8 @@ module.exports = function xhrAdapter(config) {
12456
12652
  request.timeout = config.timeout;
12457
12653
 
12458
12654
  // Listen for ready state
12459
- request[loadEvent] = function handleLoad() {
12460
- if (!request || (request.readyState !== 4 && !xDomain)) {
12655
+ request.onreadystatechange = function handleLoad() {
12656
+ if (!request || request.readyState !== 4) {
12461
12657
  return;
12462
12658
  }
12463
12659
 
@@ -12474,9 +12670,8 @@ module.exports = function xhrAdapter(config) {
12474
12670
  var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response;
12475
12671
  var response = {
12476
12672
  data: responseData,
12477
- // IE sends 1223 instead of 204 (https://github.com/axios/axios/issues/201)
12478
- status: request.status === 1223 ? 204 : request.status,
12479
- statusText: request.status === 1223 ? 'No Content' : request.statusText,
12673
+ status: request.status,
12674
+ statusText: request.statusText,
12480
12675
  headers: responseHeaders,
12481
12676
  config: config,
12482
12677
  request: request
@@ -12488,6 +12683,18 @@ module.exports = function xhrAdapter(config) {
12488
12683
  request = null;
12489
12684
  };
12490
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
+
12491
12698
  // Handle low level network errors
12492
12699
  request.onerror = function handleError() {
12493
12700
  // Real errors are hidden from us by the browser
@@ -12515,8 +12722,8 @@ module.exports = function xhrAdapter(config) {
12515
12722
 
12516
12723
  // Add xsrf header
12517
12724
  var xsrfValue = (config.withCredentials || isURLSameOrigin(config.url)) && config.xsrfCookieName ?
12518
- cookies.read(config.xsrfCookieName) :
12519
- undefined;
12725
+ cookies.read(config.xsrfCookieName) :
12726
+ undefined;
12520
12727
 
12521
12728
  if (xsrfValue) {
12522
12729
  requestHeaders[config.xsrfHeaderName] = xsrfValue;
@@ -12587,13 +12794,13 @@ module.exports = function xhrAdapter(config) {
12587
12794
  });
12588
12795
  };
12589
12796
 
12590
- }).call(this,require('_process'))
12591
- },{"../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){
12592
12798
  'use strict';
12593
12799
 
12594
12800
  var utils = require('./utils');
12595
12801
  var bind = require('./helpers/bind');
12596
12802
  var Axios = require('./core/Axios');
12803
+ var mergeConfig = require('./core/mergeConfig');
12597
12804
  var defaults = require('./defaults');
12598
12805
 
12599
12806
  /**
@@ -12623,7 +12830,7 @@ axios.Axios = Axios;
12623
12830
 
12624
12831
  // Factory for creating new instances
12625
12832
  axios.create = function create(instanceConfig) {
12626
- return createInstance(utils.merge(defaults, instanceConfig));
12833
+ return createInstance(mergeConfig(axios.defaults, instanceConfig));
12627
12834
  };
12628
12835
 
12629
12836
  // Expose Cancel & CancelToken
@@ -12642,7 +12849,7 @@ module.exports = axios;
12642
12849
  // Allow use of default import syntax in TypeScript
12643
12850
  module.exports.default = axios;
12644
12851
 
12645
- },{"./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){
12646
12853
  'use strict';
12647
12854
 
12648
12855
  /**
@@ -12732,10 +12939,11 @@ module.exports = function isCancel(value) {
12732
12939
  },{}],69:[function(require,module,exports){
12733
12940
  'use strict';
12734
12941
 
12735
- var defaults = require('./../defaults');
12736
12942
  var utils = require('./../utils');
12943
+ var buildURL = require('../helpers/buildURL');
12737
12944
  var InterceptorManager = require('./InterceptorManager');
12738
12945
  var dispatchRequest = require('./dispatchRequest');
12946
+ var mergeConfig = require('./mergeConfig');
12739
12947
 
12740
12948
  /**
12741
12949
  * Create a new instance of Axios
@@ -12759,13 +12967,14 @@ Axios.prototype.request = function request(config) {
12759
12967
  /*eslint no-param-reassign:0*/
12760
12968
  // Allow for axios('example/url'[, config]) a la fetch API
12761
12969
  if (typeof config === 'string') {
12762
- config = utils.merge({
12763
- url: arguments[0]
12764
- }, arguments[1]);
12970
+ config = arguments[1] || {};
12971
+ config.url = arguments[0];
12972
+ } else {
12973
+ config = config || {};
12765
12974
  }
12766
12975
 
12767
- config = utils.merge(defaults, this.defaults, { method: 'get' }, config);
12768
- config.method = config.method.toLowerCase();
12976
+ config = mergeConfig(this.defaults, config);
12977
+ config.method = config.method ? config.method.toLowerCase() : 'get';
12769
12978
 
12770
12979
  // Hook up interceptors middleware
12771
12980
  var chain = [dispatchRequest, undefined];
@@ -12786,6 +12995,11 @@ Axios.prototype.request = function request(config) {
12786
12995
  return promise;
12787
12996
  };
12788
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
+
12789
13003
  // Provide aliases for supported request methods
12790
13004
  utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
12791
13005
  /*eslint func-names:0*/
@@ -12810,7 +13024,7 @@ utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
12810
13024
 
12811
13025
  module.exports = Axios;
12812
13026
 
12813
- },{"./../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){
12814
13028
  'use strict';
12815
13029
 
12816
13030
  var utils = require('./../utils');
@@ -12972,7 +13186,7 @@ module.exports = function dispatchRequest(config) {
12972
13186
  });
12973
13187
  };
12974
13188
 
12975
- },{"../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){
12976
13190
  'use strict';
12977
13191
 
12978
13192
  /**
@@ -12990,14 +13204,88 @@ module.exports = function enhanceError(error, config, code, request, response) {
12990
13204
  if (code) {
12991
13205
  error.code = code;
12992
13206
  }
13207
+
12993
13208
  error.request = request;
12994
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
+ };
12995
13230
  return error;
12996
13231
  };
12997
13232
 
12998
13233
  },{}],74:[function(require,module,exports){
12999
13234
  'use strict';
13000
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
+
13001
13289
  var createError = require('./createError');
13002
13290
 
13003
13291
  /**
@@ -13009,8 +13297,7 @@ var createError = require('./createError');
13009
13297
  */
13010
13298
  module.exports = function settle(resolve, reject, response) {
13011
13299
  var validateStatus = response.config.validateStatus;
13012
- // Note: status is not exposed by XDomainRequest
13013
- if (!response.status || !validateStatus || validateStatus(response.status)) {
13300
+ if (!validateStatus || validateStatus(response.status)) {
13014
13301
  resolve(response);
13015
13302
  } else {
13016
13303
  reject(createError(
@@ -13023,7 +13310,7 @@ module.exports = function settle(resolve, reject, response) {
13023
13310
  }
13024
13311
  };
13025
13312
 
13026
- },{"./createError":71}],75:[function(require,module,exports){
13313
+ },{"./createError":71}],76:[function(require,module,exports){
13027
13314
  'use strict';
13028
13315
 
13029
13316
  var utils = require('./../utils');
@@ -13045,7 +13332,7 @@ module.exports = function transformData(data, headers, fns) {
13045
13332
  return data;
13046
13333
  };
13047
13334
 
13048
- },{"./../utils":87}],76:[function(require,module,exports){
13335
+ },{"./../utils":87}],77:[function(require,module,exports){
13049
13336
  (function (process){
13050
13337
  'use strict';
13051
13338
 
@@ -13064,12 +13351,13 @@ function setContentTypeIfUnset(headers, value) {
13064
13351
 
13065
13352
  function getDefaultAdapter() {
13066
13353
  var adapter;
13067
- if (typeof XMLHttpRequest !== 'undefined') {
13068
- // For browsers use XHR adapter
13069
- adapter = require('./adapters/xhr');
13070
- } 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]') {
13071
13356
  // For node use HTTP adapter
13072
13357
  adapter = require('./adapters/http');
13358
+ } else if (typeof XMLHttpRequest !== 'undefined') {
13359
+ // For browsers use XHR adapter
13360
+ adapter = require('./adapters/xhr');
13073
13361
  }
13074
13362
  return adapter;
13075
13363
  }
@@ -13078,6 +13366,7 @@ var defaults = {
13078
13366
  adapter: getDefaultAdapter(),
13079
13367
 
13080
13368
  transformRequest: [function transformRequest(data, headers) {
13369
+ normalizeHeaderName(headers, 'Accept');
13081
13370
  normalizeHeaderName(headers, 'Content-Type');
13082
13371
  if (utils.isFormData(data) ||
13083
13372
  utils.isArrayBuffer(data) ||
@@ -13112,6 +13401,10 @@ var defaults = {
13112
13401
  return data;
13113
13402
  }],
13114
13403
 
13404
+ /**
13405
+ * A timeout in milliseconds to abort a request. If set to 0 (default) a
13406
+ * timeout is not created.
13407
+ */
13115
13408
  timeout: 0,
13116
13409
 
13117
13410
  xsrfCookieName: 'XSRF-TOKEN',
@@ -13141,7 +13434,7 @@ utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
13141
13434
  module.exports = defaults;
13142
13435
 
13143
13436
  }).call(this,require('_process'))
13144
- },{"./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){
13145
13438
  'use strict';
13146
13439
 
13147
13440
  module.exports = function bind(fn, thisArg) {
@@ -13154,44 +13447,6 @@ module.exports = function bind(fn, thisArg) {
13154
13447
  };
13155
13448
  };
13156
13449
 
13157
- },{}],78:[function(require,module,exports){
13158
- 'use strict';
13159
-
13160
- // btoa polyfill for IE<10 courtesy https://github.com/davidchambers/Base64.js
13161
-
13162
- var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
13163
-
13164
- function E() {
13165
- this.message = 'String contains an invalid character';
13166
- }
13167
- E.prototype = new Error;
13168
- E.prototype.code = 5;
13169
- E.prototype.name = 'InvalidCharacterError';
13170
-
13171
- function btoa(input) {
13172
- var str = String(input);
13173
- var output = '';
13174
- for (
13175
- // initialize result and counter
13176
- var block, charCode, idx = 0, map = chars;
13177
- // if the next str index does not exist:
13178
- // change the mapping table to "="
13179
- // check if d has no fractional digits
13180
- str.charAt(idx | 0) || (map = '=', idx % 1);
13181
- // "8 - idx % 1 * 8" generates the sequence 2, 4, 6, 8
13182
- output += map.charAt(63 & block >> 8 - idx % 1 * 8)
13183
- ) {
13184
- charCode = str.charCodeAt(idx += 3 / 4);
13185
- if (charCode > 0xFF) {
13186
- throw new E();
13187
- }
13188
- block = block << 8 | charCode;
13189
- }
13190
- return output;
13191
- }
13192
-
13193
- module.exports = btoa;
13194
-
13195
13450
  },{}],79:[function(require,module,exports){
13196
13451
  'use strict';
13197
13452
 
@@ -13236,9 +13491,7 @@ module.exports = function buildURL(url, params, paramsSerializer) {
13236
13491
 
13237
13492
  if (utils.isArray(val)) {
13238
13493
  key = key + '[]';
13239
- }
13240
-
13241
- if (!utils.isArray(val)) {
13494
+ } else {
13242
13495
  val = [val];
13243
13496
  }
13244
13497
 
@@ -13256,6 +13509,11 @@ module.exports = function buildURL(url, params, paramsSerializer) {
13256
13509
  }
13257
13510
 
13258
13511
  if (serializedParams) {
13512
+ var hashmarkIndex = url.indexOf('#');
13513
+ if (hashmarkIndex !== -1) {
13514
+ url = url.slice(0, hashmarkIndex);
13515
+ }
13516
+
13259
13517
  url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
13260
13518
  }
13261
13519
 
@@ -13287,50 +13545,50 @@ module.exports = (
13287
13545
  utils.isStandardBrowserEnv() ?
13288
13546
 
13289
13547
  // Standard browser envs support document.cookie
13290
- (function standardBrowserEnv() {
13291
- return {
13292
- write: function write(name, value, expires, path, domain, secure) {
13293
- var cookie = [];
13294
- 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));
13295
13553
 
13296
- if (utils.isNumber(expires)) {
13297
- cookie.push('expires=' + new Date(expires).toGMTString());
13298
- }
13554
+ if (utils.isNumber(expires)) {
13555
+ cookie.push('expires=' + new Date(expires).toGMTString());
13556
+ }
13299
13557
 
13300
- if (utils.isString(path)) {
13301
- cookie.push('path=' + path);
13302
- }
13558
+ if (utils.isString(path)) {
13559
+ cookie.push('path=' + path);
13560
+ }
13303
13561
 
13304
- if (utils.isString(domain)) {
13305
- cookie.push('domain=' + domain);
13306
- }
13562
+ if (utils.isString(domain)) {
13563
+ cookie.push('domain=' + domain);
13564
+ }
13307
13565
 
13308
- if (secure === true) {
13309
- cookie.push('secure');
13310
- }
13566
+ if (secure === true) {
13567
+ cookie.push('secure');
13568
+ }
13311
13569
 
13312
- document.cookie = cookie.join('; ');
13313
- },
13570
+ document.cookie = cookie.join('; ');
13571
+ },
13314
13572
 
13315
- read: function read(name) {
13316
- var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
13317
- return (match ? decodeURIComponent(match[3]) : null);
13318
- },
13573
+ read: function read(name) {
13574
+ var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
13575
+ return (match ? decodeURIComponent(match[3]) : null);
13576
+ },
13319
13577
 
13320
- remove: function remove(name) {
13321
- this.write(name, '', Date.now() - 86400000);
13322
- }
13323
- };
13324
- })() :
13578
+ remove: function remove(name) {
13579
+ this.write(name, '', Date.now() - 86400000);
13580
+ }
13581
+ };
13582
+ })() :
13325
13583
 
13326
13584
  // Non standard browser env (web workers, react-native) lack needed support.
13327
- (function nonStandardBrowserEnv() {
13328
- return {
13329
- write: function write() {},
13330
- read: function read() { return null; },
13331
- remove: function remove() {}
13332
- };
13333
- })()
13585
+ (function nonStandardBrowserEnv() {
13586
+ return {
13587
+ write: function write() {},
13588
+ read: function read() { return null; },
13589
+ remove: function remove() {}
13590
+ };
13591
+ })()
13334
13592
  );
13335
13593
 
13336
13594
  },{"./../utils":87}],82:[function(require,module,exports){
@@ -13359,64 +13617,64 @@ module.exports = (
13359
13617
 
13360
13618
  // Standard browser envs have full support of the APIs needed to test
13361
13619
  // whether the request URL is of the same origin as current location.
13362
- (function standardBrowserEnv() {
13363
- var msie = /(msie|trident)/i.test(navigator.userAgent);
13364
- var urlParsingNode = document.createElement('a');
13365
- var originURL;
13620
+ (function standardBrowserEnv() {
13621
+ var msie = /(msie|trident)/i.test(navigator.userAgent);
13622
+ var urlParsingNode = document.createElement('a');
13623
+ var originURL;
13366
13624
 
13367
- /**
13625
+ /**
13368
13626
  * Parse a URL to discover it's components
13369
13627
  *
13370
13628
  * @param {String} url The URL to be parsed
13371
13629
  * @returns {Object}
13372
13630
  */
13373
- function resolveURL(url) {
13374
- var href = url;
13631
+ function resolveURL(url) {
13632
+ var href = url;
13375
13633
 
13376
- if (msie) {
13634
+ if (msie) {
13377
13635
  // IE needs attribute set twice to normalize properties
13378
- urlParsingNode.setAttribute('href', href);
13379
- href = urlParsingNode.href;
13380
- }
13636
+ urlParsingNode.setAttribute('href', href);
13637
+ href = urlParsingNode.href;
13638
+ }
13381
13639
 
13382
- urlParsingNode.setAttribute('href', href);
13640
+ urlParsingNode.setAttribute('href', href);
13383
13641
 
13384
- // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
13385
- return {
13386
- href: urlParsingNode.href,
13387
- protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
13388
- host: urlParsingNode.host,
13389
- search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
13390
- hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
13391
- hostname: urlParsingNode.hostname,
13392
- port: urlParsingNode.port,
13393
- pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
13394
- urlParsingNode.pathname :
13395
- '/' + urlParsingNode.pathname
13396
- };
13397
- }
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
+ }
13398
13656
 
13399
- originURL = resolveURL(window.location.href);
13657
+ originURL = resolveURL(window.location.href);
13400
13658
 
13401
- /**
13659
+ /**
13402
13660
  * Determine if a URL shares the same origin as the current location
13403
13661
  *
13404
13662
  * @param {String} requestURL The URL to test
13405
13663
  * @returns {boolean} True if URL shares the same origin, otherwise false
13406
13664
  */
13407
- return function isURLSameOrigin(requestURL) {
13408
- var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
13409
- 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 &&
13410
13668
  parsed.host === originURL.host);
13411
- };
13412
- })() :
13669
+ };
13670
+ })() :
13413
13671
 
13414
13672
  // Non standard browser envs (web workers, react-native) lack needed support.
13415
- (function nonStandardBrowserEnv() {
13416
- return function isURLSameOrigin() {
13417
- return true;
13418
- };
13419
- })()
13673
+ (function nonStandardBrowserEnv() {
13674
+ return function isURLSameOrigin() {
13675
+ return true;
13676
+ };
13677
+ })()
13420
13678
  );
13421
13679
 
13422
13680
  },{"./../utils":87}],84:[function(require,module,exports){
@@ -13697,9 +13955,13 @@ function trim(str) {
13697
13955
  *
13698
13956
  * react-native:
13699
13957
  * navigator.product -> 'ReactNative'
13958
+ * nativescript
13959
+ * navigator.product -> 'NativeScript' or 'NS'
13700
13960
  */
13701
13961
  function isStandardBrowserEnv() {
13702
- if (typeof navigator !== 'undefined' && navigator.product === 'ReactNative') {
13962
+ if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' ||
13963
+ navigator.product === 'NativeScript' ||
13964
+ navigator.product === 'NS')) {
13703
13965
  return false;
13704
13966
  }
13705
13967
  return (
@@ -13780,6 +14042,32 @@ function merge(/* obj1, obj2, obj3, ... */) {
13780
14042
  return result;
13781
14043
  }
13782
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
+
13783
14071
  /**
13784
14072
  * Extends object a by mutably adding to it the properties of object b.
13785
14073
  *
@@ -13818,11 +14106,12 @@ module.exports = {
13818
14106
  isStandardBrowserEnv: isStandardBrowserEnv,
13819
14107
  forEach: forEach,
13820
14108
  merge: merge,
14109
+ deepMerge: deepMerge,
13821
14110
  extend: extend,
13822
14111
  trim: trim
13823
14112
  };
13824
14113
 
13825
- },{"./helpers/bind":77,"is-buffer":90}],88:[function(require,module,exports){
14114
+ },{"./helpers/bind":78,"is-buffer":90}],88:[function(require,module,exports){
13826
14115
  /*
13827
14116
  * big.js v5.0.3
13828
14117
  * A small, fast, easy-to-use library for arbitrary-precision decimal arithmetic.
@@ -14957,19 +15246,9 @@ process.umask = function() { return 0; };
14957
15246
  * @license MIT
14958
15247
  */
14959
15248
 
14960
- // The _isBuffer check is for Safari 5-7 support, because it's missing
14961
- // Object.prototype.constructor. Remove this eventually
14962
- module.exports = function (obj) {
14963
- return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer)
14964
- }
14965
-
14966
- function isBuffer (obj) {
14967
- return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
14968
- }
14969
-
14970
- // For Node v0.10 support. Remove this eventually.
14971
- function isSlowBuffer (obj) {
14972
- 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)
14973
15252
  }
14974
15253
 
14975
15254
  },{}],91:[function(require,module,exports){
@@ -18526,22 +18805,36 @@ moment.tz.load(require('./data/packed/latest.json'));
18526
18805
  function createDate (y, m, d, h, M, s, ms) {
18527
18806
  // can't just apply() to create a date:
18528
18807
  // https://stackoverflow.com/q/181348
18529
- var date = new Date(y, m, d, h, M, s, ms);
18530
-
18808
+ var date;
18531
18809
  // the date constructor remaps years 0-99 to 1900-1999
18532
- if (y < 100 && y >= 0 && isFinite(date.getFullYear())) {
18533
- 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);
18534
18818
  }
18819
+
18535
18820
  return date;
18536
18821
  }
18537
18822
 
18538
18823
  function createUTCDate (y) {
18539
- var date = new Date(Date.UTC.apply(null, arguments));
18540
-
18824
+ var date;
18541
18825
  // the Date.UTC function remaps years 0-99 to 1900-1999
18542
- if (y < 100 && y >= 0 && isFinite(date.getUTCFullYear())) {
18543
- 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));
18544
18836
  }
18837
+
18545
18838
  return date;
18546
18839
  }
18547
18840
 
@@ -18643,7 +18936,7 @@ moment.tz.load(require('./data/packed/latest.json'));
18643
18936
 
18644
18937
  var defaultLocaleWeek = {
18645
18938
  dow : 0, // Sunday is the first day of the week.
18646
- 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.
18647
18940
  };
18648
18941
 
18649
18942
  function localeFirstDayOfWeek () {
@@ -18752,25 +19045,28 @@ moment.tz.load(require('./data/packed/latest.json'));
18752
19045
  }
18753
19046
 
18754
19047
  // LOCALES
19048
+ function shiftWeekdays (ws, n) {
19049
+ return ws.slice(n, 7).concat(ws.slice(0, n));
19050
+ }
18755
19051
 
18756
19052
  var defaultLocaleWeekdays = 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_');
18757
19053
  function localeWeekdays (m, format) {
18758
- if (!m) {
18759
- return isArray(this._weekdays) ? this._weekdays :
18760
- this._weekdays['standalone'];
18761
- }
18762
- return isArray(this._weekdays) ? this._weekdays[m.day()] :
18763
- 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;
18764
19058
  }
18765
19059
 
18766
19060
  var defaultLocaleWeekdaysShort = 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_');
18767
19061
  function localeWeekdaysShort (m) {
18768
- 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;
18769
19064
  }
18770
19065
 
18771
19066
  var defaultLocaleWeekdaysMin = 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_');
18772
19067
  function localeWeekdaysMin (m) {
18773
- 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;
18774
19070
  }
18775
19071
 
18776
19072
  function handleStrictParse$1(weekdayName, format, strict) {
@@ -19519,13 +19815,13 @@ moment.tz.load(require('./data/packed/latest.json'));
19519
19815
  weekdayOverflow = true;
19520
19816
  }
19521
19817
  } else if (w.e != null) {
19522
- // local weekday -- counting starts from begining of week
19818
+ // local weekday -- counting starts from beginning of week
19523
19819
  weekday = w.e + dow;
19524
19820
  if (w.e < 0 || w.e > 6) {
19525
19821
  weekdayOverflow = true;
19526
19822
  }
19527
19823
  } else {
19528
- // default to begining of week
19824
+ // default to beginning of week
19529
19825
  weekday = dow;
19530
19826
  }
19531
19827
  }
@@ -20119,7 +20415,7 @@ moment.tz.load(require('./data/packed/latest.json'));
20119
20415
  years = normalizedInput.year || 0,
20120
20416
  quarters = normalizedInput.quarter || 0,
20121
20417
  months = normalizedInput.month || 0,
20122
- weeks = normalizedInput.week || 0,
20418
+ weeks = normalizedInput.week || normalizedInput.isoWeek || 0,
20123
20419
  days = normalizedInput.day || 0,
20124
20420
  hours = normalizedInput.hour || 0,
20125
20421
  minutes = normalizedInput.minute || 0,
@@ -20423,7 +20719,7 @@ moment.tz.load(require('./data/packed/latest.json'));
20423
20719
  ms : toInt(absRound(match[MILLISECOND] * 1000)) * sign // the millisecond decimal point is included in the match
20424
20720
  };
20425
20721
  } else if (!!(match = isoRegex.exec(input))) {
20426
- sign = (match[1] === '-') ? -1 : (match[1] === '+') ? 1 : 1;
20722
+ sign = (match[1] === '-') ? -1 : 1;
20427
20723
  duration = {
20428
20724
  y : parseIso(match[2], sign),
20429
20725
  M : parseIso(match[3], sign),
@@ -20465,7 +20761,7 @@ moment.tz.load(require('./data/packed/latest.json'));
20465
20761
  }
20466
20762
 
20467
20763
  function positiveMomentsDifference(base, other) {
20468
- var res = {milliseconds: 0, months: 0};
20764
+ var res = {};
20469
20765
 
20470
20766
  res.months = other.month() - base.month() +
20471
20767
  (other.year() - base.year()) * 12;
@@ -20574,7 +20870,7 @@ moment.tz.load(require('./data/packed/latest.json'));
20574
20870
  if (!(this.isValid() && localInput.isValid())) {
20575
20871
  return false;
20576
20872
  }
20577
- units = normalizeUnits(!isUndefined(units) ? units : 'millisecond');
20873
+ units = normalizeUnits(units) || 'millisecond';
20578
20874
  if (units === 'millisecond') {
20579
20875
  return this.valueOf() > localInput.valueOf();
20580
20876
  } else {
@@ -20587,7 +20883,7 @@ moment.tz.load(require('./data/packed/latest.json'));
20587
20883
  if (!(this.isValid() && localInput.isValid())) {
20588
20884
  return false;
20589
20885
  }
20590
- units = normalizeUnits(!isUndefined(units) ? units : 'millisecond');
20886
+ units = normalizeUnits(units) || 'millisecond';
20591
20887
  if (units === 'millisecond') {
20592
20888
  return this.valueOf() < localInput.valueOf();
20593
20889
  } else {
@@ -20596,9 +20892,14 @@ moment.tz.load(require('./data/packed/latest.json'));
20596
20892
  }
20597
20893
 
20598
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
+ }
20599
20900
  inclusivity = inclusivity || '()';
20600
- return (inclusivity[0] === '(' ? this.isAfter(from, units) : !this.isBefore(from, units)) &&
20601
- (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));
20602
20903
  }
20603
20904
 
20604
20905
  function isSame (input, units) {
@@ -20607,7 +20908,7 @@ moment.tz.load(require('./data/packed/latest.json'));
20607
20908
  if (!(this.isValid() && localInput.isValid())) {
20608
20909
  return false;
20609
20910
  }
20610
- units = normalizeUnits(units || 'millisecond');
20911
+ units = normalizeUnits(units) || 'millisecond';
20611
20912
  if (units === 'millisecond') {
20612
20913
  return this.valueOf() === localInput.valueOf();
20613
20914
  } else {
@@ -20617,11 +20918,11 @@ moment.tz.load(require('./data/packed/latest.json'));
20617
20918
  }
20618
20919
 
20619
20920
  function isSameOrAfter (input, units) {
20620
- return this.isSame(input, units) || this.isAfter(input,units);
20921
+ return this.isSame(input, units) || this.isAfter(input, units);
20621
20922
  }
20622
20923
 
20623
20924
  function isSameOrBefore (input, units) {
20624
- return this.isSame(input, units) || this.isBefore(input,units);
20925
+ return this.isSame(input, units) || this.isBefore(input, units);
20625
20926
  }
20626
20927
 
20627
20928
  function diff (input, units, asFloat) {
@@ -20798,62 +21099,130 @@ moment.tz.load(require('./data/packed/latest.json'));
20798
21099
  return this._locale;
20799
21100
  }
20800
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
+
20801
21132
  function startOf (units) {
21133
+ var time;
20802
21134
  units = normalizeUnits(units);
20803
- // the following switch intentionally omits break keywords
20804
- // 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
+
20805
21141
  switch (units) {
20806
21142
  case 'year':
20807
- this.month(0);
20808
- /* falls through */
21143
+ time = startOfDate(this.year(), 0, 1);
21144
+ break;
20809
21145
  case 'quarter':
21146
+ time = startOfDate(this.year(), this.month() - this.month() % 3, 1);
21147
+ break;
20810
21148
  case 'month':
20811
- this.date(1);
20812
- /* falls through */
21149
+ time = startOfDate(this.year(), this.month(), 1);
21150
+ break;
20813
21151
  case 'week':
21152
+ time = startOfDate(this.year(), this.month(), this.date() - this.weekday());
21153
+ break;
20814
21154
  case 'isoWeek':
21155
+ time = startOfDate(this.year(), this.month(), this.date() - (this.isoWeekday() - 1));
21156
+ break;
20815
21157
  case 'day':
20816
21158
  case 'date':
20817
- this.hours(0);
20818
- /* falls through */
21159
+ time = startOfDate(this.year(), this.month(), this.date());
21160
+ break;
20819
21161
  case 'hour':
20820
- this.minutes(0);
20821
- /* 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;
20822
21165
  case 'minute':
20823
- this.seconds(0);
20824
- /* falls through */
21166
+ time = this._d.valueOf();
21167
+ time -= mod$1(time, MS_PER_MINUTE);
21168
+ break;
20825
21169
  case 'second':
20826
- this.milliseconds(0);
20827
- }
20828
-
20829
- // weeks are a special case
20830
- if (units === 'week') {
20831
- this.weekday(0);
20832
- }
20833
- if (units === 'isoWeek') {
20834
- this.isoWeekday(1);
20835
- }
20836
-
20837
- // quarters are also special
20838
- if (units === 'quarter') {
20839
- this.month(Math.floor(this.month() / 3) * 3);
21170
+ time = this._d.valueOf();
21171
+ time -= mod$1(time, MS_PER_SECOND);
21172
+ break;
20840
21173
  }
20841
21174
 
21175
+ this._d.setTime(time);
21176
+ hooks.updateOffset(this, true);
20842
21177
  return this;
20843
21178
  }
20844
21179
 
20845
21180
  function endOf (units) {
21181
+ var time;
20846
21182
  units = normalizeUnits(units);
20847
- if (units === undefined || units === 'millisecond') {
21183
+ if (units === undefined || units === 'millisecond' || !this.isValid()) {
20848
21184
  return this;
20849
21185
  }
20850
21186
 
20851
- // 'date' is an alias for 'day', so it should be considered as such.
20852
- if (units === 'date') {
20853
- 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;
20854
21221
  }
20855
21222
 
20856
- 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;
20857
21226
  }
20858
21227
 
20859
21228
  function valueOf () {
@@ -21559,10 +21928,14 @@ moment.tz.load(require('./data/packed/latest.json'));
21559
21928
 
21560
21929
  units = normalizeUnits(units);
21561
21930
 
21562
- if (units === 'month' || units === 'year') {
21563
- days = this._days + milliseconds / 864e5;
21931
+ if (units === 'month' || units === 'quarter' || units === 'year') {
21932
+ days = this._days + milliseconds / 864e5;
21564
21933
  months = this._months + daysToMonths(days);
21565
- 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
+ }
21566
21939
  } else {
21567
21940
  // handle milliseconds separately because of floating point math errors (issue #1867)
21568
21941
  days = this._days + Math.round(monthsToDays(this._months));
@@ -21605,6 +21978,7 @@ moment.tz.load(require('./data/packed/latest.json'));
21605
21978
  var asDays = makeAs('d');
21606
21979
  var asWeeks = makeAs('w');
21607
21980
  var asMonths = makeAs('M');
21981
+ var asQuarters = makeAs('Q');
21608
21982
  var asYears = makeAs('y');
21609
21983
 
21610
21984
  function clone$1 () {
@@ -21796,6 +22170,7 @@ moment.tz.load(require('./data/packed/latest.json'));
21796
22170
  proto$2.asDays = asDays;
21797
22171
  proto$2.asWeeks = asWeeks;
21798
22172
  proto$2.asMonths = asMonths;
22173
+ proto$2.asQuarters = asQuarters;
21799
22174
  proto$2.asYears = asYears;
21800
22175
  proto$2.valueOf = valueOf$1;
21801
22176
  proto$2._bubble = bubble;
@@ -21840,7 +22215,7 @@ moment.tz.load(require('./data/packed/latest.json'));
21840
22215
  // Side effect imports
21841
22216
 
21842
22217
 
21843
- hooks.version = '2.22.2';
22218
+ hooks.version = '2.24.0';
21844
22219
 
21845
22220
  setHookCallback(createLocal);
21846
22221
 
@@ -21881,7 +22256,7 @@ moment.tz.load(require('./data/packed/latest.json'));
21881
22256
  TIME: 'HH:mm', // <input type="time" />
21882
22257
  TIME_SECONDS: 'HH:mm:ss', // <input type="time" step="1" />
21883
22258
  TIME_MS: 'HH:mm:ss.SSS', // <input type="time" step="0.001" />
21884
- WEEK: 'YYYY-[W]WW', // <input type="week" />
22259
+ WEEK: 'GGGG-[W]WW', // <input type="week" />
21885
22260
  MONTH: 'YYYY-MM' // <input type="month" />
21886
22261
  };
21887
22262