@barchart/portfolio-client-js 1.3.2 → 1.3.5

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.
@@ -194,37 +194,37 @@ module.exports = function () {
194
194
  }
195
195
 
196
196
  _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);
197
+ pb.withLiteralParameter('portfolios', 'portfolios').withVariableParameter('portfolio', 'portfolio', 'portfolio', false);
198
198
  }).withRequestInterceptor(RequestInterceptor.PLAIN_TEXT_RESPONSE).withRequestInterceptor(requestInterceptorToUse).withResponseInterceptor(responseInterceptorForPortfolioDeserialization).withErrorInterceptor(ErrorInterceptor.GENERAL).endpoint;
199
199
 
200
200
  _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');
201
+ pb.withLiteralParameter('portfolios', 'portfolios');
202
202
  }).withBody('portfolio').withRequestInterceptor(RequestInterceptor.PLAIN_TEXT_RESPONSE).withRequestInterceptor(RequestInterceptor.fromDelegate(createPortfolioRequestInterceptor)).withRequestInterceptor(requestInterceptorToUse).withResponseInterceptor(responseInterceptorForPortfolioDeserialization).withErrorInterceptor(ErrorInterceptor.GENERAL).endpoint;
203
203
 
204
204
  _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);
205
+ pb.withLiteralParameter('portfolios', 'portfolios').withVariableParameter('portfolio', 'portfolio', 'portfolio', false);
206
206
  }).withBody('portfolio').withRequestInterceptor(RequestInterceptor.PLAIN_TEXT_RESPONSE).withRequestInterceptor(RequestInterceptor.fromDelegate(updatePortfolioRequestInterceptor)).withRequestInterceptor(requestInterceptorToUse).withResponseInterceptor(responseInterceptorForPortfolioDeserialization).withErrorInterceptor(ErrorInterceptor.GENERAL).endpoint;
207
207
 
208
208
  _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);
209
+ pb.withLiteralParameter('portfolios', 'portfolios').withVariableParameter('portfolio', 'portfolio', 'portfolio', false);
210
210
  }).withRequestInterceptor(requestInterceptorToUse).withErrorInterceptor(ErrorInterceptor.GENERAL).endpoint;
211
211
 
212
212
  _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);
213
+ pb.withLiteralParameter('portfolios', 'portfolios').withVariableParameter('portfolio', 'portfolio', 'portfolio', false).withLiteralParameter('positions', 'positions').withVariableParameter('position', 'position', 'position', false);
214
214
  }).withQueryBuilder(function (qb) {
215
215
  qb.withVariableParameter('includePreviousPrice', 'includePreviousPrice', 'includePreviousPrice', true);
216
216
  }).withRequestInterceptor(requestInterceptorToUse).withRequestInterceptor(RequestInterceptor.PLAIN_TEXT_RESPONSE).withResponseInterceptor(responseInterceptorForPositionDeserialization).withErrorInterceptor(ErrorInterceptor.GENERAL).endpoint;
217
217
 
218
218
  _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);
219
+ pb.withLiteralParameter('portfolios', 'portfolios').withVariableParameter('portfolio', 'portfolio', 'portfolio', false).withLiteralParameter('positions', 'positions').withVariableParameter('position', 'position', 'position', false);
220
220
  }).withBody('portfolio').withRequestInterceptor(RequestInterceptor.fromDelegate(updatePositionRequestInterceptor)).withRequestInterceptor(requestInterceptorToUse).withResponseInterceptor(responseInterceptorForPositionMutateDeserialization).withErrorInterceptor(ErrorInterceptor.GENERAL).endpoint;
221
221
 
222
222
  _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);
223
+ pb.withLiteralParameter('portfolios', 'portfolios').withVariableParameter('portfolio', 'portfolio', 'portfolio', false).withLiteralParameter('positions', 'positions').withVariableParameter('position', 'position', 'position', false);
224
224
  }).withBody('transaction').withRequestInterceptor(requestInterceptorToUse).withResponseInterceptor(responseInterceptorForPositionMutateDeserialization).withErrorInterceptor(ErrorInterceptor.GENERAL).endpoint;
225
225
 
226
226
  _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);
227
+ pb.withLiteralParameter('portfolios', 'portfolios').withVariableParameter('portfolio', 'portfolio', 'portfolio', false).withLiteralParameter('summaries', 'summaries').withVariableParameter('position', 'position', 'position', false);
228
228
  }).withQueryBuilder(function (qb) {
229
229
  qb.withVariableParameter('frames', 'frames', 'frames', true, function (frames) {
230
230
  return frames.map(function (f) {
@@ -236,13 +236,13 @@ module.exports = function () {
236
236
  }).withRequestInterceptor(requestInterceptorToUse).withRequestInterceptor(RequestInterceptor.PLAIN_TEXT_RESPONSE).withResponseInterceptor(responseInterceptorForPositionSummaryDeserialization).withErrorInterceptor(ErrorInterceptor.GENERAL).endpoint;
237
237
 
238
238
  _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');
239
+ pb.withLiteralParameter('portfolios', 'portfolios').withVariableParameter('portfolio', 'portfolio', 'portfolio', false).withLiteralParameter('positions', 'positions').withVariableParameter('position', 'position', 'position', false).withLiteralParameter('transactions', 'transactions');
240
240
  }).withQueryBuilder(function (qb) {
241
241
  qb.withLiteralParameter('mode', 'mode', 'text');
242
242
  }).withRequestInterceptor(RequestInterceptor.PLAIN_TEXT_RESPONSE).withRequestInterceptor(requestInterceptorToUse).withResponseInterceptor(responseInterceptorForTransactionDeserialization).withErrorInterceptor(ErrorInterceptor.GENERAL).endpoint;
243
243
 
244
244
  _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');
245
+ pb.withLiteralParameter('portfolios', 'portfolios').withVariableParameter('portfolio', 'portfolio', 'portfolio', false).withLiteralParameter('positions', 'positions').withVariableParameter('position', 'position', 'position', false).withLiteralParameter('transactions', 'transactions');
246
246
  }).withQueryBuilder(function (qb) {
247
247
  qb.withVariableParameter('type', 'type', 'type', false, function (x) {
248
248
  return x.code;
@@ -250,11 +250,11 @@ module.exports = function () {
250
250
  }).withBody('transaction').withRequestInterceptor(requestInterceptorToUse).withResponseInterceptor(responseInterceptorForPositionMutateDeserialization).withErrorInterceptor(ErrorInterceptor.GENERAL).endpoint;
251
251
 
252
252
  _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');
253
+ pb.withLiteralParameter('portfolios', 'portfolios').withVariableParameter('portfolio', 'portfolio', 'portfolio', false).withLiteralParameter('positions', 'positions').withLiteralParameter('multiple', 'multiple').withLiteralParameter('transactions', 'transactions');
254
254
  }).withBody('transactions').withRequestInterceptor(requestInterceptorToUse).withResponseInterceptor(ResponseInterceptor.DATA).withErrorInterceptor(ErrorInterceptor.GENERAL).endpoint;
255
255
 
256
256
  _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);
257
+ 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
258
  }).withQueryBuilder(function (qb) {
259
259
  qb.withVariableParameter('type', 'type', 'type', false, function (x) {
260
260
  return x.code;
@@ -262,7 +262,7 @@ module.exports = function () {
262
262
  }).withBody('transaction').withRequestInterceptor(requestInterceptorToUse).withResponseInterceptor(responseInterceptorForPositionMutateDeserialization).withErrorInterceptor(ErrorInterceptor.GENERAL).endpoint;
263
263
 
264
264
  _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);
265
+ 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
266
  }).withQueryBuilder(function (qb) {
267
267
  qb.withVariableParameter('force', 'force', 'force', false).withVariableParameter('echoStart', 'echoStart', 'echoStart', true, function (x) {
268
268
  return x.format();
@@ -272,7 +272,7 @@ module.exports = function () {
272
272
  }).withRequestInterceptor(requestInterceptorToUse).withResponseInterceptor(responseInterceptorForPositionMutateDeserialization).withErrorInterceptor(ErrorInterceptor.GENERAL).endpoint;
273
273
 
274
274
  _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');
275
+ pb.withLiteralParameter('portfolios', 'portfolios').withVariableParameter('portfolio', 'portfolio', 'portfolio', false).withLiteralParameter('positions', 'positions').withVariableParameter('position', 'position', 'position', true).withLiteralParameter('transactions', 'transactions').withLiteralParameter('formatted', 'formatted');
276
276
  }).withQueryBuilder(function (qb) {
277
277
  qb.withVariableParameter('start', 'start', 'start', true, function (x) {
278
278
  return x.format();
@@ -282,7 +282,7 @@ module.exports = function () {
282
282
  }).withRequestInterceptor(requestInterceptorToUse).withResponseInterceptor(ResponseInterceptor.DATA).withErrorInterceptor(ErrorInterceptor.GENERAL).endpoint;
283
283
 
284
284
  _this._readBrokerageReportAvailabilityEndpoint = EndpointBuilder.for('read-brokerage-report-availability', 'read brokerage report availability').withVerb(VerbType.GET).withProtocol(protocolType).withHost(host).withPort(port).withPathBuilder(function (pb) {
285
- pb.withLiteralParameter('json', 'json').withLiteralParameter('reports', 'reports').withLiteralParameter('portfolios', 'portfolios').withVariableParameter('portfolio', 'portfolio', 'portfolio', false).withLiteralParameter('availability', 'availability');
285
+ pb.withLiteralParameter('portfolios', 'portfolios').withVariableParameter('portfolio', 'portfolio', 'portfolio', false).withLiteralParameter('reports', 'reports').withLiteralParameter('brokerage', 'brokerage').withLiteralParameter('availability', 'availability');
286
286
  }).withQueryBuilder(function (qb) {
287
287
  qb.withVariableParameter('frames', 'frames', 'frames', true, function (frames) {
288
288
  return frames.map(function (f) {
@@ -290,6 +290,10 @@ module.exports = function () {
290
290
  }).join();
291
291
  });
292
292
  }).withRequestInterceptor(requestInterceptorToUse).withRequestInterceptor(RequestInterceptor.PLAIN_TEXT_RESPONSE).withResponseInterceptor(responseInterceptorForBrokerageReportAvailabilityDeserialization).withErrorInterceptor(ErrorInterceptor.GENERAL).endpoint;
293
+
294
+ _this._brokerageReportUrlGenerator = function (user, portfolio, frame, end) {
295
+ return 'https://' + host + '/binary/reports/portfolios/' + portfolio + '/frames/' + frame.code + '/date/' + end.format() + '/' + user;
296
+ };
293
297
  return _this;
294
298
  }
295
299
 
@@ -921,6 +925,34 @@ module.exports = function () {
921
925
  });
922
926
  }
923
927
 
928
+ /**
929
+ * Generates a URL suitable for downloading a brokerage report (as a PDF).
930
+ *
931
+ * @public
932
+ * @param {String} user
933
+ * @param {String} portfolio
934
+ * @param {PositionSummaryFrame} frame
935
+ * @param {Day} end
936
+ * @return {Promise<String>}
937
+ */
938
+
939
+ }, {
940
+ key: 'getBrokerageReportUrl',
941
+ value: function getBrokerageReportUrl(user, portfolio, frame, end) {
942
+ var _this21 = this;
943
+
944
+ return Promise.resolve().then(function () {
945
+ checkStart.call(_this21);
946
+
947
+ assert.argumentIsRequired(user, 'user', String);
948
+ assert.argumentIsRequired(portfolio, 'portfolio', String);
949
+ assert.argumentIsRequired(frame, 'frame', PositionSummaryFrame, 'PositionSummaryFrame');
950
+ assert.argumentIsRequired(end, 'end', Day, 'Day');
951
+
952
+ return _this21._brokerageReportUrlGenerator(user, portfolio, frame, end);
953
+ });
954
+ }
955
+
924
956
  /**
925
957
  * Creates and starts a new {@link PortfolioGateway} for use in the development environment.
926
958
  *
@@ -1514,7 +1546,7 @@ module.exports = function () {
1514
1546
 
1515
1547
  function _forDevelopment(userId, legacyUserId) {
1516
1548
  return EndpointBuilder.for('read-jwt-token-for-development', 'lookup user identity').withVerb(VerbType.GET).withProtocol(ProtocolType.HTTPS).withHost(Configuration.developmentHost).withPathBuilder(function (pb) {
1517
- pb.withLiteralParameter('json', 'json').withLiteralParameter('token', 'token').withLiteralParameter('barchart', 'barchart').withLiteralParameter('generator', 'generator');
1549
+ pb.withLiteralParameter('token', 'token').withLiteralParameter('barchart', 'barchart').withLiteralParameter('generator', 'generator');
1518
1550
  }).withQueryBuilder(function (qb) {
1519
1551
  qb.withLiteralParameter('user', 'userId', userId).withLiteralParameter('legacy user', 'userLegacyId', legacyUserId).withLiteralParameter('user context', 'userContext', 'TGAM').withLiteralParameter('user permission level', 'userPermissions', 'registered');
1520
1552
  }).withResponseInterceptor(ResponseInterceptor.DATA).endpoint;
@@ -1522,19 +1554,19 @@ module.exports = function () {
1522
1554
 
1523
1555
  function _forStaging(externalRequestInterceptor) {
1524
1556
  return EndpointBuilder.for('translate-jwt-token-for-staging', 'lookup Barchart user identity').withVerb(VerbType.GET).withProtocol(ProtocolType.HTTPS).withHost(Configuration.stagingHost).withPathBuilder(function (pb) {
1525
- pb.withLiteralParameter('json', 'json').withLiteralParameter('token', 'token').withLiteralParameter('system', 'tgam').withLiteralParameter('converter', 'converter');
1557
+ pb.withLiteralParameter('token', 'token').withLiteralParameter('system', 'tgam').withLiteralParameter('converter', 'converter');
1526
1558
  }).withRequestInterceptor(externalRequestInterceptor).withResponseInterceptor(ResponseInterceptor.DATA).endpoint;
1527
1559
  }
1528
1560
 
1529
1561
  function _forProduction(externalRequestInterceptor) {
1530
1562
  return EndpointBuilder.for('translate-jwt-token-for-production', 'lookup Barchart user identity').withVerb(VerbType.GET).withProtocol(ProtocolType.HTTPS).withHost(Configuration.productionHost).withPathBuilder(function (pb) {
1531
- pb.withLiteralParameter('json', 'json').withLiteralParameter('token', 'token').withLiteralParameter('system', 'tgam').withLiteralParameter('converter', 'converter');
1563
+ pb.withLiteralParameter('token', 'token').withLiteralParameter('system', 'tgam').withLiteralParameter('converter', 'converter');
1532
1564
  }).withRequestInterceptor(externalRequestInterceptor).withResponseInterceptor(ResponseInterceptor.DATA).endpoint;
1533
1565
  }
1534
1566
 
1535
1567
  function _forAdmin(userId, legacyUserId) {
1536
1568
  return EndpointBuilder.for('read-jwt-token-for-admin', 'lookup user identity').withVerb(VerbType.GET).withProtocol(ProtocolType.HTTPS).withHost(Configuration.adminHost).withPathBuilder(function (pb) {
1537
- pb.withLiteralParameter('json', 'json').withLiteralParameter('token', 'token').withLiteralParameter('barchart', 'barchart').withLiteralParameter('generator', 'generator');
1569
+ pb.withLiteralParameter('token', 'token').withLiteralParameter('barchart', 'barchart').withLiteralParameter('generator', 'generator');
1538
1570
  }).withQueryBuilder(function (qb) {
1539
1571
  if (userId) {
1540
1572
  qb.withLiteralParameter('user', 'userId', userId);
@@ -1563,7 +1595,7 @@ module.exports = function () {
1563
1595
  return {
1564
1596
  JwtGateway: JwtGateway,
1565
1597
  PortfolioGateway: PortfolioGateway,
1566
- version: '1.3.2'
1598
+ version: '1.3.5'
1567
1599
  };
1568
1600
  }();
1569
1601
 
@@ -4351,7 +4383,7 @@ module.exports = function () {
4351
4383
  *
4352
4384
  * @public
4353
4385
  * @param {*} value - The value of the node.
4354
- * @param {Tree} parent - The parent node. If not supplied, this will be the root node.
4386
+ * @param {Tree=} parent - The parent node. If not supplied, this will be the root node.
4355
4387
  */
4356
4388
 
4357
4389
  var Tree = function () {
@@ -5388,6 +5420,32 @@ module.exports = function () {
5388
5420
  return this.addYears(years, true);
5389
5421
  }
5390
5422
 
5423
+ /**
5424
+ * Returns a new {@link Day} instance for the start of the month referenced by the current instance.
5425
+ *
5426
+ * @public
5427
+ * @returns {Day}
5428
+ */
5429
+
5430
+ }, {
5431
+ key: 'getStartOfMonth',
5432
+ value: function getStartOfMonth() {
5433
+ return new Day(this.year, this.month, 1);
5434
+ }
5435
+
5436
+ /**
5437
+ * Returns a new instance for the {@link Day} end of the month referenced by the current instance.
5438
+ *
5439
+ * @public
5440
+ * @returns {Day}
5441
+ */
5442
+
5443
+ }, {
5444
+ key: 'getEndOfMonth',
5445
+ value: function getEndOfMonth() {
5446
+ return new Day(this.year, this.month, Day.getDaysInMonth(this.year, this.month));
5447
+ }
5448
+
5391
5449
  /**
5392
5450
  * Indicates if another {@link Day} occurs before the current instance.
5393
5451
  *
@@ -5528,7 +5586,7 @@ module.exports = function () {
5528
5586
  return this._month;
5529
5587
  }
5530
5588
 
5531
- /**
5589
+ /**day
5532
5590
  * The day of the month.
5533
5591
  *
5534
5592
  * @public
@@ -5549,7 +5607,7 @@ module.exports = function () {
5549
5607
  }
5550
5608
 
5551
5609
  /**
5552
- * Converts a string (which matches the output of {@link Day#format} into
5610
+ * Converts a string (which matches the output of {@link Day#format}) into
5553
5611
  * a {@link Day} instance.
5554
5612
  *
5555
5613
  * @public
@@ -5820,6 +5878,24 @@ module.exports = function () {
5820
5878
  return new Decimal(this._big.div(getBig(other)));
5821
5879
  }
5822
5880
 
5881
+ /**
5882
+ * Returns a new {@link Decimal} instance with a value that results
5883
+ * from raising the current instance to the power of the exponent
5884
+ * provided.
5885
+ *
5886
+ * @public
5887
+ * @param {Decimal|Number|String} exponent
5888
+ * @returns {Decimal}
5889
+ */
5890
+
5891
+ }, {
5892
+ key: 'raise',
5893
+ value: function raise(exponent) {
5894
+ assert.argumentIsRequired(exponent, 'exponent', Number);
5895
+
5896
+ return new Decimal(this._big.pow(exponent));
5897
+ }
5898
+
5823
5899
  /**
5824
5900
  * Returns a new {@link Decimal} with a value resulting from a rounding
5825
5901
  * operation on the current value.
@@ -5984,6 +6060,28 @@ module.exports = function () {
5984
6060
  return this._big.eq(getBig(other));
5985
6061
  }
5986
6062
 
6063
+ /**
6064
+ * Returns true is close to another value.
6065
+ *
6066
+ * @public
6067
+ * @param {Decimal|Number|String} other - The value to compare.
6068
+ * @param {Number} places - The significant digits.
6069
+ * @returns {Boolean}
6070
+ */
6071
+
6072
+ }, {
6073
+ key: 'getIsApproximate',
6074
+ value: function getIsApproximate(other, places) {
6075
+ if (places === 0) {
6076
+ return this.getIsEqual(other);
6077
+ }
6078
+
6079
+ var difference = this.subtract(other).absolute();
6080
+ var tolerance = Decimal.ONE.divide(new Decimal(10).raise(places));
6081
+
6082
+ return difference.getIsLessThan(tolerance);
6083
+ }
6084
+
5987
6085
  /**
5988
6086
  * Returns true if the current instance is an integer (i.e. has no decimal
5989
6087
  * component).
@@ -7510,8 +7608,62 @@ module.exports = function () {
7510
7608
  }
7511
7609
 
7512
7610
  return found;
7611
+ },
7612
+
7613
+
7614
+ /**
7615
+ * Inserts an item into an array using a binary search is used to determine the
7616
+ * proper point for insertion and returns the same array.
7617
+ *
7618
+ * @static
7619
+ * @public
7620
+ * @param {Array} a
7621
+ * @param {*} item
7622
+ * @param {Function} comparator
7623
+ * @returns {Array}
7624
+ */
7625
+ insert: function insert(a, item, comparator) {
7626
+ assert.argumentIsArray(a, 'a');
7627
+ assert.argumentIsRequired(comparator, 'comparator', Function);
7628
+
7629
+ if (a.length === 0 || !(comparator(item, a[a.length - 1]) < 0)) {
7630
+ a.push(item);
7631
+ } else if (comparator(item, a[0]) < 0) {
7632
+ a.unshift(item);
7633
+ } else {
7634
+ a.splice(binarySearch(a, item, comparator, 0, a.length - 1), 0, item);
7635
+ }
7636
+
7637
+ return a;
7513
7638
  }
7514
7639
  };
7640
+
7641
+ function binarySearch(array, item, comparator, start, end) {
7642
+ var size = end - start;
7643
+
7644
+ var midpointIndex = start + Math.floor(size / 2);
7645
+ var midpointItem = array[midpointIndex];
7646
+
7647
+ var comparison = comparator(item, midpointItem) > 0;
7648
+
7649
+ if (size < 2) {
7650
+ if (comparison > 0) {
7651
+ var finalIndex = array.length - 1;
7652
+
7653
+ if (end === finalIndex && comparator(item, array[finalIndex]) > 0) {
7654
+ return end + 1;
7655
+ } else {
7656
+ return end;
7657
+ }
7658
+ } else {
7659
+ return start;
7660
+ }
7661
+ } else if (comparison > 0) {
7662
+ return binarySearch(array, item, comparator, midpointIndex, end);
7663
+ } else {
7664
+ return binarySearch(array, item, comparator, start, midpointIndex);
7665
+ }
7666
+ }
7515
7667
  }();
7516
7668
 
7517
7669
  },{"./assert":37,"./is":40}],37:[function(require,module,exports){
@@ -7967,7 +8119,7 @@ module.exports = function () {
7967
8119
  * @static
7968
8120
  * @public
7969
8121
  * @param {*} candidate
7970
- * @returns {*|boolean}
8122
+ * @returns {boolean}
7971
8123
  */
7972
8124
  negative: function negative(candidate) {
7973
8125
  return this.number(candidate) && candidate < 0;
@@ -9794,7 +9946,7 @@ module.exports = function () {
9794
9946
  *
9795
9947
  * @public
9796
9948
  * @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.
9797
- * @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.
9949
+ * @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.
9798
9950
  * @param {string=} actionDescription - Description of the action to attempt, used for logging purposes.
9799
9951
  * @param {number=} maximumAttempts - The number of attempts to before giving up.
9800
9952
  * @param {Function=} failureCallback - If provided, will be invoked if a function is considered to be failing.
@@ -9818,59 +9970,61 @@ module.exports = function () {
9818
9970
  throw new Error('The Scheduler has been disposed.');
9819
9971
  }
9820
9972
 
9821
- var scheduleBackoff = function scheduleBackoff(failureCount, e) {
9822
- if (failureCount > 0 && is.fn(failureCallback)) {
9823
- failureCallback(failureCount);
9824
- }
9825
-
9826
- if (maximumAttempts > 0 && failureCount > maximumAttempts) {
9827
- var message = 'Maximum failures reached for ' + actionDescription;
9973
+ var processAction = function processAction(attempts) {
9974
+ return Promise.resolve().then(function () {
9975
+ var delay = void 0;
9828
9976
 
9829
- var rejection = void 0;
9977
+ if (attempts === 0) {
9978
+ delay = 0;
9979
+ } else {
9980
+ delay = (millisecondDelay || 1000) * Math.pow(2, attempts - 1);
9981
+ }
9830
9982
 
9831
- if (e) {
9832
- e.backoff = message;
9983
+ return _this4.schedule(actionToBackoff, delay, 'Attempt [ ' + attempts + ' ] for [ ' + (actionDescription || 'unnamed action') + ' ]');
9984
+ }).then(function (result) {
9985
+ var resultPromise = void 0;
9833
9986
 
9834
- rejection = e;
9987
+ if (!is.undefined(failureValue) && object.equals(result, failureValue)) {
9988
+ resultPromise = Promise.reject('Attempt [ ' + attempts + ' ] for [ ' + (actionDescription || 'unnamed action') + ' ] failed due to invalid result');
9835
9989
  } else {
9836
- rejection = message;
9990
+ resultPromise = Promise.resolve(result);
9837
9991
  }
9838
9992
 
9839
- return Promise.reject(rejection);
9840
- }
9993
+ return resultPromise;
9994
+ }).catch(function (e) {
9995
+ if (is.fn(failureCallback)) {
9996
+ failureCallback(attempts);
9997
+ }
9998
+
9999
+ return Promise.reject(e);
10000
+ });
10001
+ };
9841
10002
 
9842
- var backoffDelay = void 0;
10003
+ var attempts = 0;
9843
10004
 
9844
- if (failureCount === 0) {
9845
- backoffDelay = millisecondDelay || 0;
9846
- } else {
9847
- backoffDelay = (millisecondDelay || 1000) * Math.pow(2, failureCount);
9848
- }
10005
+ var processActionRecursive = function processActionRecursive() {
10006
+ return processAction(attempts++).catch(function (e) {
10007
+ if (maximumAttempts > 0 && attempts === maximumAttempts) {
10008
+ var message = 'Maximum failures reached for ' + (actionDescription || 'unnamed action');
9849
10009
 
9850
- var successPredicate = void 0;
10010
+ var rejectPromise = void 0;
9851
10011
 
9852
- if (is.undefined(failureValue)) {
9853
- successPredicate = function successPredicate(value) {
9854
- return value;
9855
- };
9856
- } else {
9857
- successPredicate = function successPredicate(value) {
9858
- return !object.equals(value, failureValue);
9859
- };
9860
- }
10012
+ if (is.object(e)) {
10013
+ e.backoff = message;
9861
10014
 
9862
- return _this4.schedule(actionToBackoff, backoffDelay, (actionDescription || 'unspecified') + ', attempt ' + (failureCount + 1)).then(function (result) {
9863
- if (successPredicate(result)) {
9864
- return result;
10015
+ rejectPromise = Promise.reject(e);
10016
+ } else {
10017
+ rejectPromise = Promise.reject(message);
10018
+ }
10019
+
10020
+ return rejectPromise;
9865
10021
  } else {
9866
- return scheduleBackoff(++failureCount);
10022
+ return processActionRecursive();
9867
10023
  }
9868
- }).catch(function (e) {
9869
- return scheduleBackoff(++failureCount, e);
9870
10024
  });
9871
10025
  };
9872
10026
 
9873
- return scheduleBackoff(0);
10027
+ return processActionRecursive();
9874
10028
  });
9875
10029
  }
9876
10030
  }, {
@@ -9931,9 +10085,10 @@ module.exports = (() => {
9931
10085
  *
9932
10086
  * @public
9933
10087
  * @extends {Enum}
10088
+ * @param {String} code
9934
10089
  * @param {String} description
9935
10090
  * @param {String} alternateDescription
9936
- * @param {String} code
10091
+ * @param {Boolean} canExistEmpty
9937
10092
  * @param {Boolean} canReinvest
9938
10093
  * @param {Boolean} canShort
9939
10094
  * @param {Boolean} canSwitchDirection
@@ -9945,10 +10100,11 @@ module.exports = (() => {
9945
10100
  * @param {Function} generator
9946
10101
  */
9947
10102
  class InstrumentType extends Enum {
9948
- constructor(code, description, alternateDescription, canReinvest, canShort, canSwitchDirection, usesSymbols, hasCorporateActions, closeFractional, roundQuantity, strictOrdering, generator) {
10103
+ constructor(code, description, alternateDescription, canExistEmpty, canReinvest, canShort, canSwitchDirection, usesSymbols, hasCorporateActions, closeFractional, roundQuantity, strictOrdering, generator) {
9949
10104
  super(code, description);
9950
10105
 
9951
10106
  assert.argumentIsRequired(alternateDescription, 'alternateDescription', String);
10107
+ assert.argumentIsRequired(canExistEmpty, 'canExistEmpty', Boolean);
9952
10108
  assert.argumentIsRequired(canReinvest, 'canReinvest', Boolean);
9953
10109
  assert.argumentIsRequired(canShort, 'canShort', Boolean);
9954
10110
  assert.argumentIsRequired(canSwitchDirection, 'canSwitchDirection', Boolean);
@@ -9960,6 +10116,8 @@ module.exports = (() => {
9960
10116
  assert.argumentIsRequired(generator, 'generator', Function);
9961
10117
 
9962
10118
  this._alternateDescription = alternateDescription;
10119
+
10120
+ this._canExistEmpty = canExistEmpty;
9963
10121
  this._canReinvest = canReinvest;
9964
10122
  this._canShort = canShort;
9965
10123
  this._canSwitchDirection = canSwitchDirection;
@@ -9982,6 +10140,16 @@ module.exports = (() => {
9982
10140
  return this._alternateDescription;
9983
10141
  }
9984
10142
 
10143
+ /**
10144
+ * Indicates if the position can exist without any associated transactions.
10145
+ *
10146
+ * @public
10147
+ * @returns {Boolean}
10148
+ */
10149
+ get canExistEmpty() {
10150
+ return this._canExistEmpty;
10151
+ }
10152
+
9985
10153
  /**
9986
10154
  * Indicates if the instrument type allows automatic reinvestment.
9987
10155
  *
@@ -10162,10 +10330,10 @@ module.exports = (() => {
10162
10330
  }
10163
10331
  }
10164
10332
 
10165
- const cash = new InstrumentType('CASH', 'cash', 'Cash', false, false, true, false, false, false, false, false, (instrument) => `BARCHART-${instrument.type.code}-${instrument.currency.code}`);
10166
- const equity = new InstrumentType('EQUITY', 'equity', 'Equities', true, true, false, true, true, true, true, true, (instrument) => `BARCHART-${instrument.type.code}-${instrument.symbol.barchart}`);
10167
- const fund = new InstrumentType('FUND', 'mutual fund', 'Funds', true, false, false, true, true, false, true, true, (instrument) => `BARCHART-${instrument.type.code}-${instrument.symbol.barchart}`);
10168
- const other = new InstrumentType('OTHER', 'other', 'Other', false, false, false, false, false, false, true, true, (instrument) => `BARCHART-${instrument.type.code}-${uuid.v4()}`);
10333
+ const cash = new InstrumentType('CASH', 'cash', 'Cash', true, false, false, true, false, false, false, false, false, (instrument) => `BARCHART-${instrument.type.code}-${instrument.currency.code}`);
10334
+ const equity = new InstrumentType('EQUITY', 'equity', 'Equities', false, true, true, false, true, true, true, true, true, (instrument) => `BARCHART-${instrument.type.code}-${instrument.symbol.barchart}`);
10335
+ 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}`);
10336
+ const other = new InstrumentType('OTHER', 'other', 'Other', false, false, false, false, false, false, false, true, true, (instrument) => `BARCHART-${instrument.type.code}-${uuid.v4()}`);
10169
10337
 
10170
10338
  const map = { };
10171
10339
 
@@ -10374,7 +10542,7 @@ module.exports = (() => {
10374
10542
  *
10375
10543
  * @public
10376
10544
  * @param {Number} periods
10377
- * @returns {Array.<PositionSummaryRange>}
10545
+ * @returns {PositionSummaryRange[]}
10378
10546
  */
10379
10547
  getRecentRanges(periods) {
10380
10548
  const startDate = this.getStartDate(periods);
@@ -10387,8 +10555,8 @@ module.exports = (() => {
10387
10555
  * Returns the ranges for the set of {@link Transaction} objects.
10388
10556
  *
10389
10557
  * @public
10390
- * @param {Array.<Transaction>} transactions
10391
- * @returns {Array.<PositionSummaryRange>}
10558
+ * @param {Transaction[]} transactions
10559
+ * @returns {PositionSummaryRange[]}
10392
10560
  */
10393
10561
  getRanges(transactions) {
10394
10562
  assert.argumentIsArray(transactions, 'transactions');
@@ -10401,7 +10569,7 @@ module.exports = (() => {
10401
10569
  *
10402
10570
  * @public
10403
10571
  * @param {Day} date
10404
- * @return {Array.<PositionSummaryRange>}
10572
+ * @return {PositionSummaryRange[]}
10405
10573
  */
10406
10574
  getRangesFromDate(date) {
10407
10575
  assert.argumentIsRequired(date, 'date', Day, 'Day');
@@ -10490,8 +10658,8 @@ module.exports = (() => {
10490
10658
  }
10491
10659
 
10492
10660
  const yearly = new PositionSummaryFrame('YEARLY', 'year', false, getYearlyRanges, getYearlyStartDate, getYearlyRangeDescription);
10493
- const quarterly = new PositionSummaryFrame('QUARTER', 'quarter', false, getQuarterlyRanges, getQuarterlyStartDate, getQuarterlyRangeDescription);
10494
- const monthly = new PositionSummaryFrame('MONTH', 'month', false, getMonthlyRanges, getMonthlyStartDate, getMonthlyRangeDescription);
10661
+ const quarterly = new PositionSummaryFrame('QUARTERLY', 'quarter', false, getQuarterlyRanges, getQuarterlyStartDate, getQuarterlyRangeDescription);
10662
+ const monthly = new PositionSummaryFrame('MONTHLY', 'month', false, getMonthlyRanges, getMonthlyStartDate, getMonthlyRangeDescription);
10495
10663
  const ytd = new PositionSummaryFrame('YTD', 'year-to-date', true, getYearToDateRanges, getYearToDateStartDate, getYearToDateRangeDescription);
10496
10664
 
10497
10665
  /**
@@ -10551,7 +10719,36 @@ module.exports = (() => {
10551
10719
  }
10552
10720
 
10553
10721
  function getMonthlyRanges(transactions) {
10554
- return [ ];
10722
+ const ranges = [ ];
10723
+
10724
+ if (transactions.length !== 0) {
10725
+ const today = Day.getToday();
10726
+
10727
+ const first = array.first(transactions);
10728
+ const last = array.last(transactions);
10729
+
10730
+ const firstDate = first.date;
10731
+
10732
+ let lastDate;
10733
+
10734
+ if (last.snapshot.open.getIsZero()) {
10735
+ lastDate = last.date;
10736
+ } else {
10737
+ lastDate = today;
10738
+ }
10739
+
10740
+ if (today.month === lastDate.month && today.year === lastDate.year) {
10741
+ lastDate = lastDate.subtractMonths(1);
10742
+ }
10743
+
10744
+ lastDate = lastDate.getEndOfMonth();
10745
+
10746
+ for (let end = firstDate.getEndOfMonth(); !end.getIsAfter(lastDate); end = end.addMonths(1).getEndOfMonth()) {
10747
+ ranges.push(getRange(end.subtractMonths(1).getEndOfMonth(), end));
10748
+ }
10749
+ }
10750
+
10751
+ return ranges;
10555
10752
  }
10556
10753
 
10557
10754
  function getYearToDateRanges(transactions) {
@@ -10588,7 +10785,11 @@ module.exports = (() => {
10588
10785
  }
10589
10786
 
10590
10787
  function getMonthlyStartDate(periods, date) {
10591
- return null;
10788
+ const today = date || Day.getToday();
10789
+
10790
+ return today
10791
+ .subtractMonths(periods)
10792
+ .subtractDays(today.day);
10592
10793
  }
10593
10794
 
10594
10795
  function getYearToDateStartDate(periods, date) {
@@ -10596,7 +10797,7 @@ module.exports = (() => {
10596
10797
  }
10597
10798
 
10598
10799
  function getYearlyRangeDescription(start, end) {
10599
- return `Year ended ${end.year.toString()}`;
10800
+ return `Year ended ${end.format()}`;
10600
10801
  }
10601
10802
 
10602
10803
  function getQuarterlyRangeDescription(start, end) {
@@ -10604,7 +10805,7 @@ module.exports = (() => {
10604
10805
  }
10605
10806
 
10606
10807
  function getMonthlyRangeDescription(start, end) {
10607
- return '';
10808
+ return `Month ended ${end.format()}`;
10608
10809
  }
10609
10810
 
10610
10811
  function getYearToDateRangeDescription(start, end) {
@@ -10649,7 +10850,7 @@ module.exports = (() => {
10649
10850
  * @param {Boolean} corporateAction
10650
10851
  * @param {Boolean} initial
10651
10852
  * @param {Boolean} significant
10652
- * @param {Boolean} eod
10853
+ * @param {Boolean} system
10653
10854
  */
10654
10855
  class TransactionType extends Enum {
10655
10856
  constructor(code, description, display, sequence, purchase, sale, income, opening, closing, fee, corporateAction, initial, significant) {
@@ -10979,6 +11180,17 @@ module.exports = (() => {
10979
11180
  static get DEBIT() {
10980
11181
  return debit;
10981
11182
  }
11183
+
11184
+ /**
11185
+ * A system-generated transaction, indicating the security has stopped active trading.
11186
+ *
11187
+ * @public
11188
+ * @static
11189
+ * @returns {TransactionType}
11190
+ */
11191
+ static get DELIST() {
11192
+ return delist;
11193
+ }
10982
11194
 
10983
11195
  /**
10984
11196
  * A system-generated deposit, arising from another transaction.
@@ -11028,6 +11240,7 @@ module.exports = (() => {
11028
11240
  const split = new TransactionType('SP', 'Split', 'Split', 1, false, false, false, true, false, false, true, false, false);
11029
11241
  const fee = new TransactionType('F', 'Fee', 'Fee', 0, false, false, false, false, false, true, false, false, false);
11030
11242
  const feeUnits = new TransactionType('FU', 'Fee Units', 'Fee', 0, false, false, false, false, true, false, false, false, false);
11243
+ const delist = new TransactionType('DL', 'Delist', 'Delist', 1, false, false, false, false, false, false, true, false, false);
11031
11244
 
11032
11245
  const distributionCash = new TransactionType('DC', 'Distribution (Cash)', 'Cash Distribution', 1, false, false, true, false, false, false, true, false, false);
11033
11246
  const distributionReinvest = new TransactionType('DY', 'Distribution (Reinvested)', 'Distribution Reinvest', 1, false, false, false, true, false, false, true, false, false);
@@ -11663,6 +11876,10 @@ module.exports = (() => {
11663
11876
  static get VALUATION() {
11664
11877
  return valuation;
11665
11878
  }
11879
+
11880
+ static get DELIST() {
11881
+ return delist;
11882
+ }
11666
11883
 
11667
11884
  static get INCOME() {
11668
11885
  return income;
@@ -11867,12 +12084,23 @@ module.exports = (() => {
11867
12084
  .withField('sequence', DataType.NUMBER, true)
11868
12085
  .withField('type', DataType.forEnum(TransactionType, 'TransactionType'))
11869
12086
  .withField('date', DataType.DAY)
11870
- .withField('value', DataType.DECIMAL)
12087
+ .withField('rate', DataType.DECIMAL, true)
12088
+ .withField('value', DataType.DECIMAL, true)
11871
12089
  .withField('force', DataType.BOOLEAN, true)
11872
12090
  .schema
11873
12091
  );
11874
-
11875
- const income = new TransactionSchema(SchemaBuilder.withName(TransactionType.INCOME.code)
12092
+
12093
+ const delist = new TransactionSchema(SchemaBuilder.withName(TransactionType.DELIST.code)
12094
+ .withField('portfolio', DataType.STRING)
12095
+ .withField('position', DataType.STRING)
12096
+ .withField('sequence', DataType.NUMBER, true)
12097
+ .withField('type', DataType.forEnum(TransactionType, 'TransactionType'))
12098
+ .withField('date', DataType.DAY)
12099
+ .withField('force', DataType.BOOLEAN, true)
12100
+ .schema
12101
+ );
12102
+
12103
+ const income = new TransactionSchema(SchemaBuilder.withName(TransactionType.INCOME.code)
11876
12104
  .withField('portfolio', DataType.STRING)
11877
12105
  .withField('position', DataType.STRING)
11878
12106
  .withField('sequence', DataType.NUMBER, true)
@@ -11898,6 +12126,7 @@ module.exports = (() => {
11898
12126
  addSchemaToMap(TransactionType.DEPOSIT, deposit);
11899
12127
  addSchemaToMap(TransactionType.WITHDRAWAL, withdrawal);
11900
12128
  addSchemaToMap(TransactionType.VALUATION, valuation);
12129
+ addSchemaToMap(TransactionType.DELIST, delist);
11901
12130
  addSchemaToMap(TransactionType.INCOME, income);
11902
12131
 
11903
12132
  return TransactionSchema;
@@ -12030,7 +12259,7 @@ module.exports = function () {
12030
12259
  * containing the current instance
12031
12260
  *
12032
12261
  * @public
12033
- * @returns {Promise.<JwtGateway>}
12262
+ * @returns {Promise<JwtGateway>}
12034
12263
  */
12035
12264
 
12036
12265
 
@@ -12060,7 +12289,7 @@ module.exports = function () {
12060
12289
  * Retrieves a JWT token from the remote server.
12061
12290
  *
12062
12291
  * @public
12063
- * @returns {Promise.<String>}
12292
+ * @returns {Promise<String>}
12064
12293
  */
12065
12294
 
12066
12295
  }, {
@@ -12100,7 +12329,7 @@ module.exports = function () {
12100
12329
  var refreshToken = function refreshToken() {
12101
12330
  var refreshPromise = scheduler.backoff(function () {
12102
12331
  return _this4.readToken();
12103
- }, 100, 'Read JWT token', 3).then(function (token) {
12332
+ }, 0, 'Read JWT token', 3).then(function (token) {
12104
12333
  if (_this4._refreshInterval > 0) {
12105
12334
  cachePromise = refreshPromise;
12106
12335
 
@@ -12168,8 +12397,8 @@ module.exports = function () {
12168
12397
  *
12169
12398
  * @public
12170
12399
  * @static
12171
- * @param {Promise.<Endpoint>|Endpoint} endpoint - The endpoint which vends JWT tokens.
12172
- * @returns {Promise.<JwtGateway>}
12400
+ * @param {Promise<Endpoint>|Endpoint} endpoint - The endpoint which vends JWT tokens.
12401
+ * @returns {Promise<JwtGateway>}
12173
12402
  */
12174
12403
 
12175
12404
  }, {
@@ -12197,8 +12426,8 @@ module.exports = function () {
12197
12426
  *
12198
12427
  * @public
12199
12428
  * @static
12200
- * @param {Promise.<Endpoint>|Endpoint} endpoint - The endpoint which vends JWT tokens.
12201
- * @returns {Promise.<RequestInterceptor>}
12429
+ * @param {Promise<Endpoint>|Endpoint} endpoint - The endpoint which vends JWT tokens.
12430
+ * @returns {Promise<RequestInterceptor>}
12202
12431
  */
12203
12432
 
12204
12433
  }, {
@@ -12214,7 +12443,7 @@ module.exports = function () {
12214
12443
  *
12215
12444
  * @public
12216
12445
  * @static
12217
- * @returns {Promise.<JwtGateway>}
12446
+ * @returns {Promise<JwtGateway>}
12218
12447
  */
12219
12448
 
12220
12449
  }, {
@@ -12228,7 +12457,7 @@ module.exports = function () {
12228
12457
  *
12229
12458
  * @public
12230
12459
  * @static
12231
- * @returns {Promise.<RequestInterceptor>}
12460
+ * @returns {Promise<RequestInterceptor>}
12232
12461
  */
12233
12462
 
12234
12463
  }, {
@@ -12244,7 +12473,7 @@ module.exports = function () {
12244
12473
  *
12245
12474
  * @public
12246
12475
  * @static
12247
- * @returns {Promise.<JwtGateway>}
12476
+ * @returns {Promise<JwtGateway>}
12248
12477
  */
12249
12478
 
12250
12479
  }, {
@@ -12258,7 +12487,7 @@ module.exports = function () {
12258
12487
  *
12259
12488
  * @public
12260
12489
  * @static
12261
- * @returns {Promise.<RequestInterceptor>}
12490
+ * @returns {Promise<RequestInterceptor>}
12262
12491
  */
12263
12492
 
12264
12493
  }, {
@@ -12275,7 +12504,7 @@ module.exports = function () {
12275
12504
  * @public
12276
12505
  * @static
12277
12506
  * @param {Function} tokenGenerator - A function which returns the JWT token.
12278
- * @returns {Promise.<JwtGateway>}
12507
+ * @returns {Promise<JwtGateway>}
12279
12508
  */
12280
12509
 
12281
12510
  }, {
@@ -12292,7 +12521,7 @@ module.exports = function () {
12292
12521
  * @public
12293
12522
  * @static
12294
12523
  * @param {JwtGateway~tokenGenerator} tokenGenerator - A function which returns the JWT token.
12295
- * @returns {Promise.<RequestInterceptor>}
12524
+ * @returns {Promise<RequestInterceptor>}
12296
12525
  */
12297
12526
 
12298
12527
  }, {
@@ -12355,7 +12584,7 @@ module.exports = function () {
12355
12584
  * A function returns a JWT token (or a promise for a JWT token).
12356
12585
  *
12357
12586
  * @callback JwtGateway~tokenGenerator
12358
- * @returns {String|Promise.<String>}
12587
+ * @returns {String|Promise<String>}
12359
12588
  */
12360
12589
 
12361
12590
  return JwtGateway;
@@ -12368,14 +12597,13 @@ module.exports = function () {
12368
12597
  'use strict';
12369
12598
 
12370
12599
  return {
12371
- version: '1.0.42'
12600
+ version: '1.3.2'
12372
12601
  };
12373
12602
  }();
12374
12603
 
12375
12604
  },{}],63:[function(require,module,exports){
12376
12605
  module.exports = require('./lib/axios');
12377
12606
  },{"./lib/axios":65}],64:[function(require,module,exports){
12378
- (function (process){
12379
12607
  'use strict';
12380
12608
 
12381
12609
  var utils = require('./../utils');
@@ -12384,7 +12612,6 @@ var buildURL = require('./../helpers/buildURL');
12384
12612
  var parseHeaders = require('./../helpers/parseHeaders');
12385
12613
  var isURLSameOrigin = require('./../helpers/isURLSameOrigin');
12386
12614
  var createError = require('../core/createError');
12387
- var btoa = (typeof window !== 'undefined' && window.btoa && window.btoa.bind(window)) || require('./../helpers/btoa');
12388
12615
 
12389
12616
  module.exports = function xhrAdapter(config) {
12390
12617
  return new Promise(function dispatchXhrRequest(resolve, reject) {
@@ -12396,22 +12623,6 @@ module.exports = function xhrAdapter(config) {
12396
12623
  }
12397
12624
 
12398
12625
  var request = new XMLHttpRequest();
12399
- var loadEvent = 'onreadystatechange';
12400
- var xDomain = false;
12401
-
12402
- // For IE 8/9 CORS support
12403
- // Only supports POST and GET calls and doesn't returns the response headers.
12404
- // DON'T do this for testing b/c XMLHttpRequest is mocked, not XDomainRequest.
12405
- if (process.env.NODE_ENV !== 'test' &&
12406
- typeof window !== 'undefined' &&
12407
- window.XDomainRequest && !('withCredentials' in request) &&
12408
- !isURLSameOrigin(config.url)) {
12409
- request = new window.XDomainRequest();
12410
- loadEvent = 'onload';
12411
- xDomain = true;
12412
- request.onprogress = function handleProgress() {};
12413
- request.ontimeout = function handleTimeout() {};
12414
- }
12415
12626
 
12416
12627
  // HTTP basic authentication
12417
12628
  if (config.auth) {
@@ -12426,8 +12637,8 @@ module.exports = function xhrAdapter(config) {
12426
12637
  request.timeout = config.timeout;
12427
12638
 
12428
12639
  // Listen for ready state
12429
- request[loadEvent] = function handleLoad() {
12430
- if (!request || (request.readyState !== 4 && !xDomain)) {
12640
+ request.onreadystatechange = function handleLoad() {
12641
+ if (!request || request.readyState !== 4) {
12431
12642
  return;
12432
12643
  }
12433
12644
 
@@ -12444,9 +12655,8 @@ module.exports = function xhrAdapter(config) {
12444
12655
  var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response;
12445
12656
  var response = {
12446
12657
  data: responseData,
12447
- // IE sends 1223 instead of 204 (https://github.com/axios/axios/issues/201)
12448
- status: request.status === 1223 ? 204 : request.status,
12449
- statusText: request.status === 1223 ? 'No Content' : request.statusText,
12658
+ status: request.status,
12659
+ statusText: request.statusText,
12450
12660
  headers: responseHeaders,
12451
12661
  config: config,
12452
12662
  request: request
@@ -12458,6 +12668,18 @@ module.exports = function xhrAdapter(config) {
12458
12668
  request = null;
12459
12669
  };
12460
12670
 
12671
+ // Handle browser request cancellation (as opposed to a manual cancellation)
12672
+ request.onabort = function handleAbort() {
12673
+ if (!request) {
12674
+ return;
12675
+ }
12676
+
12677
+ reject(createError('Request aborted', config, 'ECONNABORTED', request));
12678
+
12679
+ // Clean up request
12680
+ request = null;
12681
+ };
12682
+
12461
12683
  // Handle low level network errors
12462
12684
  request.onerror = function handleError() {
12463
12685
  // Real errors are hidden from us by the browser
@@ -12485,8 +12707,8 @@ module.exports = function xhrAdapter(config) {
12485
12707
 
12486
12708
  // Add xsrf header
12487
12709
  var xsrfValue = (config.withCredentials || isURLSameOrigin(config.url)) && config.xsrfCookieName ?
12488
- cookies.read(config.xsrfCookieName) :
12489
- undefined;
12710
+ cookies.read(config.xsrfCookieName) :
12711
+ undefined;
12490
12712
 
12491
12713
  if (xsrfValue) {
12492
12714
  requestHeaders[config.xsrfHeaderName] = xsrfValue;
@@ -12557,13 +12779,13 @@ module.exports = function xhrAdapter(config) {
12557
12779
  });
12558
12780
  };
12559
12781
 
12560
- }).call(this,require('_process'))
12561
- },{"../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){
12782
+ },{"../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){
12562
12783
  'use strict';
12563
12784
 
12564
12785
  var utils = require('./utils');
12565
12786
  var bind = require('./helpers/bind');
12566
12787
  var Axios = require('./core/Axios');
12788
+ var mergeConfig = require('./core/mergeConfig');
12567
12789
  var defaults = require('./defaults');
12568
12790
 
12569
12791
  /**
@@ -12593,7 +12815,7 @@ axios.Axios = Axios;
12593
12815
 
12594
12816
  // Factory for creating new instances
12595
12817
  axios.create = function create(instanceConfig) {
12596
- return createInstance(utils.merge(defaults, instanceConfig));
12818
+ return createInstance(mergeConfig(axios.defaults, instanceConfig));
12597
12819
  };
12598
12820
 
12599
12821
  // Expose Cancel & CancelToken
@@ -12612,7 +12834,7 @@ module.exports = axios;
12612
12834
  // Allow use of default import syntax in TypeScript
12613
12835
  module.exports.default = axios;
12614
12836
 
12615
- },{"./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){
12837
+ },{"./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){
12616
12838
  'use strict';
12617
12839
 
12618
12840
  /**
@@ -12702,10 +12924,11 @@ module.exports = function isCancel(value) {
12702
12924
  },{}],69:[function(require,module,exports){
12703
12925
  'use strict';
12704
12926
 
12705
- var defaults = require('./../defaults');
12706
12927
  var utils = require('./../utils');
12928
+ var buildURL = require('../helpers/buildURL');
12707
12929
  var InterceptorManager = require('./InterceptorManager');
12708
12930
  var dispatchRequest = require('./dispatchRequest');
12931
+ var mergeConfig = require('./mergeConfig');
12709
12932
 
12710
12933
  /**
12711
12934
  * Create a new instance of Axios
@@ -12729,13 +12952,14 @@ Axios.prototype.request = function request(config) {
12729
12952
  /*eslint no-param-reassign:0*/
12730
12953
  // Allow for axios('example/url'[, config]) a la fetch API
12731
12954
  if (typeof config === 'string') {
12732
- config = utils.merge({
12733
- url: arguments[0]
12734
- }, arguments[1]);
12955
+ config = arguments[1] || {};
12956
+ config.url = arguments[0];
12957
+ } else {
12958
+ config = config || {};
12735
12959
  }
12736
12960
 
12737
- config = utils.merge(defaults, this.defaults, { method: 'get' }, config);
12738
- config.method = config.method.toLowerCase();
12961
+ config = mergeConfig(this.defaults, config);
12962
+ config.method = config.method ? config.method.toLowerCase() : 'get';
12739
12963
 
12740
12964
  // Hook up interceptors middleware
12741
12965
  var chain = [dispatchRequest, undefined];
@@ -12756,6 +12980,11 @@ Axios.prototype.request = function request(config) {
12756
12980
  return promise;
12757
12981
  };
12758
12982
 
12983
+ Axios.prototype.getUri = function getUri(config) {
12984
+ config = mergeConfig(this.defaults, config);
12985
+ return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, '');
12986
+ };
12987
+
12759
12988
  // Provide aliases for supported request methods
12760
12989
  utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
12761
12990
  /*eslint func-names:0*/
@@ -12780,7 +13009,7 @@ utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
12780
13009
 
12781
13010
  module.exports = Axios;
12782
13011
 
12783
- },{"./../defaults":76,"./../utils":87,"./InterceptorManager":70,"./dispatchRequest":72}],70:[function(require,module,exports){
13012
+ },{"../helpers/buildURL":79,"./../utils":87,"./InterceptorManager":70,"./dispatchRequest":72,"./mergeConfig":74}],70:[function(require,module,exports){
12784
13013
  'use strict';
12785
13014
 
12786
13015
  var utils = require('./../utils');
@@ -12942,7 +13171,7 @@ module.exports = function dispatchRequest(config) {
12942
13171
  });
12943
13172
  };
12944
13173
 
12945
- },{"../cancel/isCancel":68,"../defaults":76,"./../helpers/combineURLs":80,"./../helpers/isAbsoluteURL":82,"./../utils":87,"./transformData":75}],73:[function(require,module,exports){
13174
+ },{"../cancel/isCancel":68,"../defaults":77,"./../helpers/combineURLs":80,"./../helpers/isAbsoluteURL":82,"./../utils":87,"./transformData":76}],73:[function(require,module,exports){
12946
13175
  'use strict';
12947
13176
 
12948
13177
  /**
@@ -12960,14 +13189,88 @@ module.exports = function enhanceError(error, config, code, request, response) {
12960
13189
  if (code) {
12961
13190
  error.code = code;
12962
13191
  }
13192
+
12963
13193
  error.request = request;
12964
13194
  error.response = response;
13195
+ error.isAxiosError = true;
13196
+
13197
+ error.toJSON = function() {
13198
+ return {
13199
+ // Standard
13200
+ message: this.message,
13201
+ name: this.name,
13202
+ // Microsoft
13203
+ description: this.description,
13204
+ number: this.number,
13205
+ // Mozilla
13206
+ fileName: this.fileName,
13207
+ lineNumber: this.lineNumber,
13208
+ columnNumber: this.columnNumber,
13209
+ stack: this.stack,
13210
+ // Axios
13211
+ config: this.config,
13212
+ code: this.code
13213
+ };
13214
+ };
12965
13215
  return error;
12966
13216
  };
12967
13217
 
12968
13218
  },{}],74:[function(require,module,exports){
12969
13219
  'use strict';
12970
13220
 
13221
+ var utils = require('../utils');
13222
+
13223
+ /**
13224
+ * Config-specific merge-function which creates a new config-object
13225
+ * by merging two configuration objects together.
13226
+ *
13227
+ * @param {Object} config1
13228
+ * @param {Object} config2
13229
+ * @returns {Object} New object resulting from merging config2 to config1
13230
+ */
13231
+ module.exports = function mergeConfig(config1, config2) {
13232
+ // eslint-disable-next-line no-param-reassign
13233
+ config2 = config2 || {};
13234
+ var config = {};
13235
+
13236
+ utils.forEach(['url', 'method', 'params', 'data'], function valueFromConfig2(prop) {
13237
+ if (typeof config2[prop] !== 'undefined') {
13238
+ config[prop] = config2[prop];
13239
+ }
13240
+ });
13241
+
13242
+ utils.forEach(['headers', 'auth', 'proxy'], function mergeDeepProperties(prop) {
13243
+ if (utils.isObject(config2[prop])) {
13244
+ config[prop] = utils.deepMerge(config1[prop], config2[prop]);
13245
+ } else if (typeof config2[prop] !== 'undefined') {
13246
+ config[prop] = config2[prop];
13247
+ } else if (utils.isObject(config1[prop])) {
13248
+ config[prop] = utils.deepMerge(config1[prop]);
13249
+ } else if (typeof config1[prop] !== 'undefined') {
13250
+ config[prop] = config1[prop];
13251
+ }
13252
+ });
13253
+
13254
+ utils.forEach([
13255
+ 'baseURL', 'transformRequest', 'transformResponse', 'paramsSerializer',
13256
+ 'timeout', 'withCredentials', 'adapter', 'responseType', 'xsrfCookieName',
13257
+ 'xsrfHeaderName', 'onUploadProgress', 'onDownloadProgress', 'maxContentLength',
13258
+ 'validateStatus', 'maxRedirects', 'httpAgent', 'httpsAgent', 'cancelToken',
13259
+ 'socketPath'
13260
+ ], function defaultToConfig2(prop) {
13261
+ if (typeof config2[prop] !== 'undefined') {
13262
+ config[prop] = config2[prop];
13263
+ } else if (typeof config1[prop] !== 'undefined') {
13264
+ config[prop] = config1[prop];
13265
+ }
13266
+ });
13267
+
13268
+ return config;
13269
+ };
13270
+
13271
+ },{"../utils":87}],75:[function(require,module,exports){
13272
+ 'use strict';
13273
+
12971
13274
  var createError = require('./createError');
12972
13275
 
12973
13276
  /**
@@ -12979,8 +13282,7 @@ var createError = require('./createError');
12979
13282
  */
12980
13283
  module.exports = function settle(resolve, reject, response) {
12981
13284
  var validateStatus = response.config.validateStatus;
12982
- // Note: status is not exposed by XDomainRequest
12983
- if (!response.status || !validateStatus || validateStatus(response.status)) {
13285
+ if (!validateStatus || validateStatus(response.status)) {
12984
13286
  resolve(response);
12985
13287
  } else {
12986
13288
  reject(createError(
@@ -12993,7 +13295,7 @@ module.exports = function settle(resolve, reject, response) {
12993
13295
  }
12994
13296
  };
12995
13297
 
12996
- },{"./createError":71}],75:[function(require,module,exports){
13298
+ },{"./createError":71}],76:[function(require,module,exports){
12997
13299
  'use strict';
12998
13300
 
12999
13301
  var utils = require('./../utils');
@@ -13015,7 +13317,7 @@ module.exports = function transformData(data, headers, fns) {
13015
13317
  return data;
13016
13318
  };
13017
13319
 
13018
- },{"./../utils":87}],76:[function(require,module,exports){
13320
+ },{"./../utils":87}],77:[function(require,module,exports){
13019
13321
  (function (process){
13020
13322
  'use strict';
13021
13323
 
@@ -13034,12 +13336,13 @@ function setContentTypeIfUnset(headers, value) {
13034
13336
 
13035
13337
  function getDefaultAdapter() {
13036
13338
  var adapter;
13037
- if (typeof XMLHttpRequest !== 'undefined') {
13038
- // For browsers use XHR adapter
13039
- adapter = require('./adapters/xhr');
13040
- } else if (typeof process !== 'undefined') {
13339
+ // Only Node.JS has a process variable that is of [[Class]] process
13340
+ if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {
13041
13341
  // For node use HTTP adapter
13042
13342
  adapter = require('./adapters/http');
13343
+ } else if (typeof XMLHttpRequest !== 'undefined') {
13344
+ // For browsers use XHR adapter
13345
+ adapter = require('./adapters/xhr');
13043
13346
  }
13044
13347
  return adapter;
13045
13348
  }
@@ -13048,6 +13351,7 @@ var defaults = {
13048
13351
  adapter: getDefaultAdapter(),
13049
13352
 
13050
13353
  transformRequest: [function transformRequest(data, headers) {
13354
+ normalizeHeaderName(headers, 'Accept');
13051
13355
  normalizeHeaderName(headers, 'Content-Type');
13052
13356
  if (utils.isFormData(data) ||
13053
13357
  utils.isArrayBuffer(data) ||
@@ -13082,6 +13386,10 @@ var defaults = {
13082
13386
  return data;
13083
13387
  }],
13084
13388
 
13389
+ /**
13390
+ * A timeout in milliseconds to abort a request. If set to 0 (default) a
13391
+ * timeout is not created.
13392
+ */
13085
13393
  timeout: 0,
13086
13394
 
13087
13395
  xsrfCookieName: 'XSRF-TOKEN',
@@ -13111,7 +13419,7 @@ utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
13111
13419
  module.exports = defaults;
13112
13420
 
13113
13421
  }).call(this,require('_process'))
13114
- },{"./adapters/http":64,"./adapters/xhr":64,"./helpers/normalizeHeaderName":84,"./utils":87,"_process":89}],77:[function(require,module,exports){
13422
+ },{"./adapters/http":64,"./adapters/xhr":64,"./helpers/normalizeHeaderName":84,"./utils":87,"_process":89}],78:[function(require,module,exports){
13115
13423
  'use strict';
13116
13424
 
13117
13425
  module.exports = function bind(fn, thisArg) {
@@ -13124,44 +13432,6 @@ module.exports = function bind(fn, thisArg) {
13124
13432
  };
13125
13433
  };
13126
13434
 
13127
- },{}],78:[function(require,module,exports){
13128
- 'use strict';
13129
-
13130
- // btoa polyfill for IE<10 courtesy https://github.com/davidchambers/Base64.js
13131
-
13132
- var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
13133
-
13134
- function E() {
13135
- this.message = 'String contains an invalid character';
13136
- }
13137
- E.prototype = new Error;
13138
- E.prototype.code = 5;
13139
- E.prototype.name = 'InvalidCharacterError';
13140
-
13141
- function btoa(input) {
13142
- var str = String(input);
13143
- var output = '';
13144
- for (
13145
- // initialize result and counter
13146
- var block, charCode, idx = 0, map = chars;
13147
- // if the next str index does not exist:
13148
- // change the mapping table to "="
13149
- // check if d has no fractional digits
13150
- str.charAt(idx | 0) || (map = '=', idx % 1);
13151
- // "8 - idx % 1 * 8" generates the sequence 2, 4, 6, 8
13152
- output += map.charAt(63 & block >> 8 - idx % 1 * 8)
13153
- ) {
13154
- charCode = str.charCodeAt(idx += 3 / 4);
13155
- if (charCode > 0xFF) {
13156
- throw new E();
13157
- }
13158
- block = block << 8 | charCode;
13159
- }
13160
- return output;
13161
- }
13162
-
13163
- module.exports = btoa;
13164
-
13165
13435
  },{}],79:[function(require,module,exports){
13166
13436
  'use strict';
13167
13437
 
@@ -13206,9 +13476,7 @@ module.exports = function buildURL(url, params, paramsSerializer) {
13206
13476
 
13207
13477
  if (utils.isArray(val)) {
13208
13478
  key = key + '[]';
13209
- }
13210
-
13211
- if (!utils.isArray(val)) {
13479
+ } else {
13212
13480
  val = [val];
13213
13481
  }
13214
13482
 
@@ -13226,6 +13494,11 @@ module.exports = function buildURL(url, params, paramsSerializer) {
13226
13494
  }
13227
13495
 
13228
13496
  if (serializedParams) {
13497
+ var hashmarkIndex = url.indexOf('#');
13498
+ if (hashmarkIndex !== -1) {
13499
+ url = url.slice(0, hashmarkIndex);
13500
+ }
13501
+
13229
13502
  url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
13230
13503
  }
13231
13504
 
@@ -13257,50 +13530,50 @@ module.exports = (
13257
13530
  utils.isStandardBrowserEnv() ?
13258
13531
 
13259
13532
  // Standard browser envs support document.cookie
13260
- (function standardBrowserEnv() {
13261
- return {
13262
- write: function write(name, value, expires, path, domain, secure) {
13263
- var cookie = [];
13264
- cookie.push(name + '=' + encodeURIComponent(value));
13533
+ (function standardBrowserEnv() {
13534
+ return {
13535
+ write: function write(name, value, expires, path, domain, secure) {
13536
+ var cookie = [];
13537
+ cookie.push(name + '=' + encodeURIComponent(value));
13265
13538
 
13266
- if (utils.isNumber(expires)) {
13267
- cookie.push('expires=' + new Date(expires).toGMTString());
13268
- }
13539
+ if (utils.isNumber(expires)) {
13540
+ cookie.push('expires=' + new Date(expires).toGMTString());
13541
+ }
13269
13542
 
13270
- if (utils.isString(path)) {
13271
- cookie.push('path=' + path);
13272
- }
13543
+ if (utils.isString(path)) {
13544
+ cookie.push('path=' + path);
13545
+ }
13273
13546
 
13274
- if (utils.isString(domain)) {
13275
- cookie.push('domain=' + domain);
13276
- }
13547
+ if (utils.isString(domain)) {
13548
+ cookie.push('domain=' + domain);
13549
+ }
13277
13550
 
13278
- if (secure === true) {
13279
- cookie.push('secure');
13280
- }
13551
+ if (secure === true) {
13552
+ cookie.push('secure');
13553
+ }
13281
13554
 
13282
- document.cookie = cookie.join('; ');
13283
- },
13555
+ document.cookie = cookie.join('; ');
13556
+ },
13284
13557
 
13285
- read: function read(name) {
13286
- var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
13287
- return (match ? decodeURIComponent(match[3]) : null);
13288
- },
13558
+ read: function read(name) {
13559
+ var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
13560
+ return (match ? decodeURIComponent(match[3]) : null);
13561
+ },
13289
13562
 
13290
- remove: function remove(name) {
13291
- this.write(name, '', Date.now() - 86400000);
13292
- }
13293
- };
13294
- })() :
13563
+ remove: function remove(name) {
13564
+ this.write(name, '', Date.now() - 86400000);
13565
+ }
13566
+ };
13567
+ })() :
13295
13568
 
13296
13569
  // Non standard browser env (web workers, react-native) lack needed support.
13297
- (function nonStandardBrowserEnv() {
13298
- return {
13299
- write: function write() {},
13300
- read: function read() { return null; },
13301
- remove: function remove() {}
13302
- };
13303
- })()
13570
+ (function nonStandardBrowserEnv() {
13571
+ return {
13572
+ write: function write() {},
13573
+ read: function read() { return null; },
13574
+ remove: function remove() {}
13575
+ };
13576
+ })()
13304
13577
  );
13305
13578
 
13306
13579
  },{"./../utils":87}],82:[function(require,module,exports){
@@ -13329,64 +13602,64 @@ module.exports = (
13329
13602
 
13330
13603
  // Standard browser envs have full support of the APIs needed to test
13331
13604
  // whether the request URL is of the same origin as current location.
13332
- (function standardBrowserEnv() {
13333
- var msie = /(msie|trident)/i.test(navigator.userAgent);
13334
- var urlParsingNode = document.createElement('a');
13335
- var originURL;
13605
+ (function standardBrowserEnv() {
13606
+ var msie = /(msie|trident)/i.test(navigator.userAgent);
13607
+ var urlParsingNode = document.createElement('a');
13608
+ var originURL;
13336
13609
 
13337
- /**
13610
+ /**
13338
13611
  * Parse a URL to discover it's components
13339
13612
  *
13340
13613
  * @param {String} url The URL to be parsed
13341
13614
  * @returns {Object}
13342
13615
  */
13343
- function resolveURL(url) {
13344
- var href = url;
13616
+ function resolveURL(url) {
13617
+ var href = url;
13345
13618
 
13346
- if (msie) {
13619
+ if (msie) {
13347
13620
  // IE needs attribute set twice to normalize properties
13348
- urlParsingNode.setAttribute('href', href);
13349
- href = urlParsingNode.href;
13350
- }
13621
+ urlParsingNode.setAttribute('href', href);
13622
+ href = urlParsingNode.href;
13623
+ }
13351
13624
 
13352
- urlParsingNode.setAttribute('href', href);
13625
+ urlParsingNode.setAttribute('href', href);
13353
13626
 
13354
- // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
13355
- return {
13356
- href: urlParsingNode.href,
13357
- protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
13358
- host: urlParsingNode.host,
13359
- search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
13360
- hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
13361
- hostname: urlParsingNode.hostname,
13362
- port: urlParsingNode.port,
13363
- pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
13364
- urlParsingNode.pathname :
13365
- '/' + urlParsingNode.pathname
13366
- };
13367
- }
13627
+ // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
13628
+ return {
13629
+ href: urlParsingNode.href,
13630
+ protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
13631
+ host: urlParsingNode.host,
13632
+ search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
13633
+ hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
13634
+ hostname: urlParsingNode.hostname,
13635
+ port: urlParsingNode.port,
13636
+ pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
13637
+ urlParsingNode.pathname :
13638
+ '/' + urlParsingNode.pathname
13639
+ };
13640
+ }
13368
13641
 
13369
- originURL = resolveURL(window.location.href);
13642
+ originURL = resolveURL(window.location.href);
13370
13643
 
13371
- /**
13644
+ /**
13372
13645
  * Determine if a URL shares the same origin as the current location
13373
13646
  *
13374
13647
  * @param {String} requestURL The URL to test
13375
13648
  * @returns {boolean} True if URL shares the same origin, otherwise false
13376
13649
  */
13377
- return function isURLSameOrigin(requestURL) {
13378
- var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
13379
- return (parsed.protocol === originURL.protocol &&
13650
+ return function isURLSameOrigin(requestURL) {
13651
+ var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
13652
+ return (parsed.protocol === originURL.protocol &&
13380
13653
  parsed.host === originURL.host);
13381
- };
13382
- })() :
13654
+ };
13655
+ })() :
13383
13656
 
13384
13657
  // Non standard browser envs (web workers, react-native) lack needed support.
13385
- (function nonStandardBrowserEnv() {
13386
- return function isURLSameOrigin() {
13387
- return true;
13388
- };
13389
- })()
13658
+ (function nonStandardBrowserEnv() {
13659
+ return function isURLSameOrigin() {
13660
+ return true;
13661
+ };
13662
+ })()
13390
13663
  );
13391
13664
 
13392
13665
  },{"./../utils":87}],84:[function(require,module,exports){
@@ -13667,9 +13940,13 @@ function trim(str) {
13667
13940
  *
13668
13941
  * react-native:
13669
13942
  * navigator.product -> 'ReactNative'
13943
+ * nativescript
13944
+ * navigator.product -> 'NativeScript' or 'NS'
13670
13945
  */
13671
13946
  function isStandardBrowserEnv() {
13672
- if (typeof navigator !== 'undefined' && navigator.product === 'ReactNative') {
13947
+ if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' ||
13948
+ navigator.product === 'NativeScript' ||
13949
+ navigator.product === 'NS')) {
13673
13950
  return false;
13674
13951
  }
13675
13952
  return (
@@ -13750,6 +14027,32 @@ function merge(/* obj1, obj2, obj3, ... */) {
13750
14027
  return result;
13751
14028
  }
13752
14029
 
14030
+ /**
14031
+ * Function equal to merge with the difference being that no reference
14032
+ * to original objects is kept.
14033
+ *
14034
+ * @see merge
14035
+ * @param {Object} obj1 Object to merge
14036
+ * @returns {Object} Result of all merge properties
14037
+ */
14038
+ function deepMerge(/* obj1, obj2, obj3, ... */) {
14039
+ var result = {};
14040
+ function assignValue(val, key) {
14041
+ if (typeof result[key] === 'object' && typeof val === 'object') {
14042
+ result[key] = deepMerge(result[key], val);
14043
+ } else if (typeof val === 'object') {
14044
+ result[key] = deepMerge({}, val);
14045
+ } else {
14046
+ result[key] = val;
14047
+ }
14048
+ }
14049
+
14050
+ for (var i = 0, l = arguments.length; i < l; i++) {
14051
+ forEach(arguments[i], assignValue);
14052
+ }
14053
+ return result;
14054
+ }
14055
+
13753
14056
  /**
13754
14057
  * Extends object a by mutably adding to it the properties of object b.
13755
14058
  *
@@ -13788,11 +14091,12 @@ module.exports = {
13788
14091
  isStandardBrowserEnv: isStandardBrowserEnv,
13789
14092
  forEach: forEach,
13790
14093
  merge: merge,
14094
+ deepMerge: deepMerge,
13791
14095
  extend: extend,
13792
14096
  trim: trim
13793
14097
  };
13794
14098
 
13795
- },{"./helpers/bind":77,"is-buffer":90}],88:[function(require,module,exports){
14099
+ },{"./helpers/bind":78,"is-buffer":90}],88:[function(require,module,exports){
13796
14100
  /*
13797
14101
  * big.js v5.0.3
13798
14102
  * A small, fast, easy-to-use library for arbitrary-precision decimal arithmetic.
@@ -14927,19 +15231,9 @@ process.umask = function() { return 0; };
14927
15231
  * @license MIT
14928
15232
  */
14929
15233
 
14930
- // The _isBuffer check is for Safari 5-7 support, because it's missing
14931
- // Object.prototype.constructor. Remove this eventually
14932
- module.exports = function (obj) {
14933
- return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer)
14934
- }
14935
-
14936
- function isBuffer (obj) {
14937
- return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
14938
- }
14939
-
14940
- // For Node v0.10 support. Remove this eventually.
14941
- function isSlowBuffer (obj) {
14942
- return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0))
15234
+ module.exports = function isBuffer (obj) {
15235
+ return obj != null && obj.constructor != null &&
15236
+ typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
14943
15237
  }
14944
15238
 
14945
15239
  },{}],91:[function(require,module,exports){
@@ -18496,22 +18790,36 @@ moment.tz.load(require('./data/packed/latest.json'));
18496
18790
  function createDate (y, m, d, h, M, s, ms) {
18497
18791
  // can't just apply() to create a date:
18498
18792
  // https://stackoverflow.com/q/181348
18499
- var date = new Date(y, m, d, h, M, s, ms);
18500
-
18793
+ var date;
18501
18794
  // the date constructor remaps years 0-99 to 1900-1999
18502
- if (y < 100 && y >= 0 && isFinite(date.getFullYear())) {
18503
- date.setFullYear(y);
18795
+ if (y < 100 && y >= 0) {
18796
+ // preserve leap years using a full 400 year cycle, then reset
18797
+ date = new Date(y + 400, m, d, h, M, s, ms);
18798
+ if (isFinite(date.getFullYear())) {
18799
+ date.setFullYear(y);
18800
+ }
18801
+ } else {
18802
+ date = new Date(y, m, d, h, M, s, ms);
18504
18803
  }
18804
+
18505
18805
  return date;
18506
18806
  }
18507
18807
 
18508
18808
  function createUTCDate (y) {
18509
- var date = new Date(Date.UTC.apply(null, arguments));
18510
-
18809
+ var date;
18511
18810
  // the Date.UTC function remaps years 0-99 to 1900-1999
18512
- if (y < 100 && y >= 0 && isFinite(date.getUTCFullYear())) {
18513
- date.setUTCFullYear(y);
18811
+ if (y < 100 && y >= 0) {
18812
+ var args = Array.prototype.slice.call(arguments);
18813
+ // preserve leap years using a full 400 year cycle, then reset
18814
+ args[0] = y + 400;
18815
+ date = new Date(Date.UTC.apply(null, args));
18816
+ if (isFinite(date.getUTCFullYear())) {
18817
+ date.setUTCFullYear(y);
18818
+ }
18819
+ } else {
18820
+ date = new Date(Date.UTC.apply(null, arguments));
18514
18821
  }
18822
+
18515
18823
  return date;
18516
18824
  }
18517
18825
 
@@ -18613,7 +18921,7 @@ moment.tz.load(require('./data/packed/latest.json'));
18613
18921
 
18614
18922
  var defaultLocaleWeek = {
18615
18923
  dow : 0, // Sunday is the first day of the week.
18616
- doy : 6 // The week that contains Jan 1st is the first week of the year.
18924
+ doy : 6 // The week that contains Jan 6th is the first week of the year.
18617
18925
  };
18618
18926
 
18619
18927
  function localeFirstDayOfWeek () {
@@ -18722,25 +19030,28 @@ moment.tz.load(require('./data/packed/latest.json'));
18722
19030
  }
18723
19031
 
18724
19032
  // LOCALES
19033
+ function shiftWeekdays (ws, n) {
19034
+ return ws.slice(n, 7).concat(ws.slice(0, n));
19035
+ }
18725
19036
 
18726
19037
  var defaultLocaleWeekdays = 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_');
18727
19038
  function localeWeekdays (m, format) {
18728
- if (!m) {
18729
- return isArray(this._weekdays) ? this._weekdays :
18730
- this._weekdays['standalone'];
18731
- }
18732
- return isArray(this._weekdays) ? this._weekdays[m.day()] :
18733
- this._weekdays[this._weekdays.isFormat.test(format) ? 'format' : 'standalone'][m.day()];
19039
+ var weekdays = isArray(this._weekdays) ? this._weekdays :
19040
+ this._weekdays[(m && m !== true && this._weekdays.isFormat.test(format)) ? 'format' : 'standalone'];
19041
+ return (m === true) ? shiftWeekdays(weekdays, this._week.dow)
19042
+ : (m) ? weekdays[m.day()] : weekdays;
18734
19043
  }
18735
19044
 
18736
19045
  var defaultLocaleWeekdaysShort = 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_');
18737
19046
  function localeWeekdaysShort (m) {
18738
- return (m) ? this._weekdaysShort[m.day()] : this._weekdaysShort;
19047
+ return (m === true) ? shiftWeekdays(this._weekdaysShort, this._week.dow)
19048
+ : (m) ? this._weekdaysShort[m.day()] : this._weekdaysShort;
18739
19049
  }
18740
19050
 
18741
19051
  var defaultLocaleWeekdaysMin = 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_');
18742
19052
  function localeWeekdaysMin (m) {
18743
- return (m) ? this._weekdaysMin[m.day()] : this._weekdaysMin;
19053
+ return (m === true) ? shiftWeekdays(this._weekdaysMin, this._week.dow)
19054
+ : (m) ? this._weekdaysMin[m.day()] : this._weekdaysMin;
18744
19055
  }
18745
19056
 
18746
19057
  function handleStrictParse$1(weekdayName, format, strict) {
@@ -19489,13 +19800,13 @@ moment.tz.load(require('./data/packed/latest.json'));
19489
19800
  weekdayOverflow = true;
19490
19801
  }
19491
19802
  } else if (w.e != null) {
19492
- // local weekday -- counting starts from begining of week
19803
+ // local weekday -- counting starts from beginning of week
19493
19804
  weekday = w.e + dow;
19494
19805
  if (w.e < 0 || w.e > 6) {
19495
19806
  weekdayOverflow = true;
19496
19807
  }
19497
19808
  } else {
19498
- // default to begining of week
19809
+ // default to beginning of week
19499
19810
  weekday = dow;
19500
19811
  }
19501
19812
  }
@@ -20089,7 +20400,7 @@ moment.tz.load(require('./data/packed/latest.json'));
20089
20400
  years = normalizedInput.year || 0,
20090
20401
  quarters = normalizedInput.quarter || 0,
20091
20402
  months = normalizedInput.month || 0,
20092
- weeks = normalizedInput.week || 0,
20403
+ weeks = normalizedInput.week || normalizedInput.isoWeek || 0,
20093
20404
  days = normalizedInput.day || 0,
20094
20405
  hours = normalizedInput.hour || 0,
20095
20406
  minutes = normalizedInput.minute || 0,
@@ -20393,7 +20704,7 @@ moment.tz.load(require('./data/packed/latest.json'));
20393
20704
  ms : toInt(absRound(match[MILLISECOND] * 1000)) * sign // the millisecond decimal point is included in the match
20394
20705
  };
20395
20706
  } else if (!!(match = isoRegex.exec(input))) {
20396
- sign = (match[1] === '-') ? -1 : (match[1] === '+') ? 1 : 1;
20707
+ sign = (match[1] === '-') ? -1 : 1;
20397
20708
  duration = {
20398
20709
  y : parseIso(match[2], sign),
20399
20710
  M : parseIso(match[3], sign),
@@ -20435,7 +20746,7 @@ moment.tz.load(require('./data/packed/latest.json'));
20435
20746
  }
20436
20747
 
20437
20748
  function positiveMomentsDifference(base, other) {
20438
- var res = {milliseconds: 0, months: 0};
20749
+ var res = {};
20439
20750
 
20440
20751
  res.months = other.month() - base.month() +
20441
20752
  (other.year() - base.year()) * 12;
@@ -20544,7 +20855,7 @@ moment.tz.load(require('./data/packed/latest.json'));
20544
20855
  if (!(this.isValid() && localInput.isValid())) {
20545
20856
  return false;
20546
20857
  }
20547
- units = normalizeUnits(!isUndefined(units) ? units : 'millisecond');
20858
+ units = normalizeUnits(units) || 'millisecond';
20548
20859
  if (units === 'millisecond') {
20549
20860
  return this.valueOf() > localInput.valueOf();
20550
20861
  } else {
@@ -20557,7 +20868,7 @@ moment.tz.load(require('./data/packed/latest.json'));
20557
20868
  if (!(this.isValid() && localInput.isValid())) {
20558
20869
  return false;
20559
20870
  }
20560
- units = normalizeUnits(!isUndefined(units) ? units : 'millisecond');
20871
+ units = normalizeUnits(units) || 'millisecond';
20561
20872
  if (units === 'millisecond') {
20562
20873
  return this.valueOf() < localInput.valueOf();
20563
20874
  } else {
@@ -20566,9 +20877,14 @@ moment.tz.load(require('./data/packed/latest.json'));
20566
20877
  }
20567
20878
 
20568
20879
  function isBetween (from, to, units, inclusivity) {
20880
+ var localFrom = isMoment(from) ? from : createLocal(from),
20881
+ localTo = isMoment(to) ? to : createLocal(to);
20882
+ if (!(this.isValid() && localFrom.isValid() && localTo.isValid())) {
20883
+ return false;
20884
+ }
20569
20885
  inclusivity = inclusivity || '()';
20570
- return (inclusivity[0] === '(' ? this.isAfter(from, units) : !this.isBefore(from, units)) &&
20571
- (inclusivity[1] === ')' ? this.isBefore(to, units) : !this.isAfter(to, units));
20886
+ return (inclusivity[0] === '(' ? this.isAfter(localFrom, units) : !this.isBefore(localFrom, units)) &&
20887
+ (inclusivity[1] === ')' ? this.isBefore(localTo, units) : !this.isAfter(localTo, units));
20572
20888
  }
20573
20889
 
20574
20890
  function isSame (input, units) {
@@ -20577,7 +20893,7 @@ moment.tz.load(require('./data/packed/latest.json'));
20577
20893
  if (!(this.isValid() && localInput.isValid())) {
20578
20894
  return false;
20579
20895
  }
20580
- units = normalizeUnits(units || 'millisecond');
20896
+ units = normalizeUnits(units) || 'millisecond';
20581
20897
  if (units === 'millisecond') {
20582
20898
  return this.valueOf() === localInput.valueOf();
20583
20899
  } else {
@@ -20587,11 +20903,11 @@ moment.tz.load(require('./data/packed/latest.json'));
20587
20903
  }
20588
20904
 
20589
20905
  function isSameOrAfter (input, units) {
20590
- return this.isSame(input, units) || this.isAfter(input,units);
20906
+ return this.isSame(input, units) || this.isAfter(input, units);
20591
20907
  }
20592
20908
 
20593
20909
  function isSameOrBefore (input, units) {
20594
- return this.isSame(input, units) || this.isBefore(input,units);
20910
+ return this.isSame(input, units) || this.isBefore(input, units);
20595
20911
  }
20596
20912
 
20597
20913
  function diff (input, units, asFloat) {
@@ -20768,62 +21084,130 @@ moment.tz.load(require('./data/packed/latest.json'));
20768
21084
  return this._locale;
20769
21085
  }
20770
21086
 
21087
+ var MS_PER_SECOND = 1000;
21088
+ var MS_PER_MINUTE = 60 * MS_PER_SECOND;
21089
+ var MS_PER_HOUR = 60 * MS_PER_MINUTE;
21090
+ var MS_PER_400_YEARS = (365 * 400 + 97) * 24 * MS_PER_HOUR;
21091
+
21092
+ // actual modulo - handles negative numbers (for dates before 1970):
21093
+ function mod$1(dividend, divisor) {
21094
+ return (dividend % divisor + divisor) % divisor;
21095
+ }
21096
+
21097
+ function localStartOfDate(y, m, d) {
21098
+ // the date constructor remaps years 0-99 to 1900-1999
21099
+ if (y < 100 && y >= 0) {
21100
+ // preserve leap years using a full 400 year cycle, then reset
21101
+ return new Date(y + 400, m, d) - MS_PER_400_YEARS;
21102
+ } else {
21103
+ return new Date(y, m, d).valueOf();
21104
+ }
21105
+ }
21106
+
21107
+ function utcStartOfDate(y, m, d) {
21108
+ // Date.UTC remaps years 0-99 to 1900-1999
21109
+ if (y < 100 && y >= 0) {
21110
+ // preserve leap years using a full 400 year cycle, then reset
21111
+ return Date.UTC(y + 400, m, d) - MS_PER_400_YEARS;
21112
+ } else {
21113
+ return Date.UTC(y, m, d);
21114
+ }
21115
+ }
21116
+
20771
21117
  function startOf (units) {
21118
+ var time;
20772
21119
  units = normalizeUnits(units);
20773
- // the following switch intentionally omits break keywords
20774
- // to utilize falling through the cases.
21120
+ if (units === undefined || units === 'millisecond' || !this.isValid()) {
21121
+ return this;
21122
+ }
21123
+
21124
+ var startOfDate = this._isUTC ? utcStartOfDate : localStartOfDate;
21125
+
20775
21126
  switch (units) {
20776
21127
  case 'year':
20777
- this.month(0);
20778
- /* falls through */
21128
+ time = startOfDate(this.year(), 0, 1);
21129
+ break;
20779
21130
  case 'quarter':
21131
+ time = startOfDate(this.year(), this.month() - this.month() % 3, 1);
21132
+ break;
20780
21133
  case 'month':
20781
- this.date(1);
20782
- /* falls through */
21134
+ time = startOfDate(this.year(), this.month(), 1);
21135
+ break;
20783
21136
  case 'week':
21137
+ time = startOfDate(this.year(), this.month(), this.date() - this.weekday());
21138
+ break;
20784
21139
  case 'isoWeek':
21140
+ time = startOfDate(this.year(), this.month(), this.date() - (this.isoWeekday() - 1));
21141
+ break;
20785
21142
  case 'day':
20786
21143
  case 'date':
20787
- this.hours(0);
20788
- /* falls through */
21144
+ time = startOfDate(this.year(), this.month(), this.date());
21145
+ break;
20789
21146
  case 'hour':
20790
- this.minutes(0);
20791
- /* falls through */
21147
+ time = this._d.valueOf();
21148
+ time -= mod$1(time + (this._isUTC ? 0 : this.utcOffset() * MS_PER_MINUTE), MS_PER_HOUR);
21149
+ break;
20792
21150
  case 'minute':
20793
- this.seconds(0);
20794
- /* falls through */
21151
+ time = this._d.valueOf();
21152
+ time -= mod$1(time, MS_PER_MINUTE);
21153
+ break;
20795
21154
  case 'second':
20796
- this.milliseconds(0);
20797
- }
20798
-
20799
- // weeks are a special case
20800
- if (units === 'week') {
20801
- this.weekday(0);
20802
- }
20803
- if (units === 'isoWeek') {
20804
- this.isoWeekday(1);
20805
- }
20806
-
20807
- // quarters are also special
20808
- if (units === 'quarter') {
20809
- this.month(Math.floor(this.month() / 3) * 3);
21155
+ time = this._d.valueOf();
21156
+ time -= mod$1(time, MS_PER_SECOND);
21157
+ break;
20810
21158
  }
20811
21159
 
21160
+ this._d.setTime(time);
21161
+ hooks.updateOffset(this, true);
20812
21162
  return this;
20813
21163
  }
20814
21164
 
20815
21165
  function endOf (units) {
21166
+ var time;
20816
21167
  units = normalizeUnits(units);
20817
- if (units === undefined || units === 'millisecond') {
21168
+ if (units === undefined || units === 'millisecond' || !this.isValid()) {
20818
21169
  return this;
20819
21170
  }
20820
21171
 
20821
- // 'date' is an alias for 'day', so it should be considered as such.
20822
- if (units === 'date') {
20823
- units = 'day';
21172
+ var startOfDate = this._isUTC ? utcStartOfDate : localStartOfDate;
21173
+
21174
+ switch (units) {
21175
+ case 'year':
21176
+ time = startOfDate(this.year() + 1, 0, 1) - 1;
21177
+ break;
21178
+ case 'quarter':
21179
+ time = startOfDate(this.year(), this.month() - this.month() % 3 + 3, 1) - 1;
21180
+ break;
21181
+ case 'month':
21182
+ time = startOfDate(this.year(), this.month() + 1, 1) - 1;
21183
+ break;
21184
+ case 'week':
21185
+ time = startOfDate(this.year(), this.month(), this.date() - this.weekday() + 7) - 1;
21186
+ break;
21187
+ case 'isoWeek':
21188
+ time = startOfDate(this.year(), this.month(), this.date() - (this.isoWeekday() - 1) + 7) - 1;
21189
+ break;
21190
+ case 'day':
21191
+ case 'date':
21192
+ time = startOfDate(this.year(), this.month(), this.date() + 1) - 1;
21193
+ break;
21194
+ case 'hour':
21195
+ time = this._d.valueOf();
21196
+ time += MS_PER_HOUR - mod$1(time + (this._isUTC ? 0 : this.utcOffset() * MS_PER_MINUTE), MS_PER_HOUR) - 1;
21197
+ break;
21198
+ case 'minute':
21199
+ time = this._d.valueOf();
21200
+ time += MS_PER_MINUTE - mod$1(time, MS_PER_MINUTE) - 1;
21201
+ break;
21202
+ case 'second':
21203
+ time = this._d.valueOf();
21204
+ time += MS_PER_SECOND - mod$1(time, MS_PER_SECOND) - 1;
21205
+ break;
20824
21206
  }
20825
21207
 
20826
- return this.startOf(units).add(1, (units === 'isoWeek' ? 'week' : units)).subtract(1, 'ms');
21208
+ this._d.setTime(time);
21209
+ hooks.updateOffset(this, true);
21210
+ return this;
20827
21211
  }
20828
21212
 
20829
21213
  function valueOf () {
@@ -21529,10 +21913,14 @@ moment.tz.load(require('./data/packed/latest.json'));
21529
21913
 
21530
21914
  units = normalizeUnits(units);
21531
21915
 
21532
- if (units === 'month' || units === 'year') {
21533
- days = this._days + milliseconds / 864e5;
21916
+ if (units === 'month' || units === 'quarter' || units === 'year') {
21917
+ days = this._days + milliseconds / 864e5;
21534
21918
  months = this._months + daysToMonths(days);
21535
- return units === 'month' ? months : months / 12;
21919
+ switch (units) {
21920
+ case 'month': return months;
21921
+ case 'quarter': return months / 3;
21922
+ case 'year': return months / 12;
21923
+ }
21536
21924
  } else {
21537
21925
  // handle milliseconds separately because of floating point math errors (issue #1867)
21538
21926
  days = this._days + Math.round(monthsToDays(this._months));
@@ -21575,6 +21963,7 @@ moment.tz.load(require('./data/packed/latest.json'));
21575
21963
  var asDays = makeAs('d');
21576
21964
  var asWeeks = makeAs('w');
21577
21965
  var asMonths = makeAs('M');
21966
+ var asQuarters = makeAs('Q');
21578
21967
  var asYears = makeAs('y');
21579
21968
 
21580
21969
  function clone$1 () {
@@ -21766,6 +22155,7 @@ moment.tz.load(require('./data/packed/latest.json'));
21766
22155
  proto$2.asDays = asDays;
21767
22156
  proto$2.asWeeks = asWeeks;
21768
22157
  proto$2.asMonths = asMonths;
22158
+ proto$2.asQuarters = asQuarters;
21769
22159
  proto$2.asYears = asYears;
21770
22160
  proto$2.valueOf = valueOf$1;
21771
22161
  proto$2._bubble = bubble;
@@ -21810,7 +22200,7 @@ moment.tz.load(require('./data/packed/latest.json'));
21810
22200
  // Side effect imports
21811
22201
 
21812
22202
 
21813
- hooks.version = '2.22.2';
22203
+ hooks.version = '2.24.0';
21814
22204
 
21815
22205
  setHookCallback(createLocal);
21816
22206
 
@@ -21851,7 +22241,7 @@ moment.tz.load(require('./data/packed/latest.json'));
21851
22241
  TIME: 'HH:mm', // <input type="time" />
21852
22242
  TIME_SECONDS: 'HH:mm:ss', // <input type="time" step="1" />
21853
22243
  TIME_MS: 'HH:mm:ss.SSS', // <input type="time" step="0.001" />
21854
- WEEK: 'YYYY-[W]WW', // <input type="week" />
22244
+ WEEK: 'GGGG-[W]WW', // <input type="week" />
21855
22245
  MONTH: 'YYYY-MM' // <input type="month" />
21856
22246
  };
21857
22247