@punks/backend-entity-manager 0.0.218 → 0.0.220

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.
package/dist/esm/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Log, csvParse, excelParse, excelBuild, csvBuild, isNullOrUndefined, addTime, newUuid as newUuid$1, buildObject, sort, byField, toDict, ensureTailingSlash, ensureStartSlash, removeUndefinedProps } from '@punks/backend-core';
2
- import { MoreThanOrEqual, In, Equal, Not, And, MoreThan, LessThanOrEqual, LessThan, Like, ILike } from 'typeorm';
2
+ import { MoreThanOrEqual, In, Equal, Not, And, MoreThan, LessThanOrEqual, LessThan, ILike, Like } from 'typeorm';
3
3
  import { applyDecorators, Injectable, SetMetadata, createParamDecorator, Global, Module, Scope, Logger, StreamableFile, HttpException, HttpStatus } from '@nestjs/common';
4
4
  import { Reflector } from '@nestjs/core';
5
5
  import { AsyncLocalStorage } from 'async_hooks';
@@ -14,6 +14,13 @@ import { getSignedUrl } from '@aws-sdk/s3-request-presigner';
14
14
  import { SendEmailCommand, SESClient } from '@aws-sdk/client-ses';
15
15
  import require$$2 from 'fs';
16
16
  import { MailService } from '@sendgrid/mail';
17
+ import require$$1 from 'http';
18
+ import require$$2$1 from 'https';
19
+ import require$$0 from 'url';
20
+ import require$$3 from 'stream';
21
+ import require$$4 from 'assert';
22
+ import require$$8 from 'zlib';
23
+ import { createClient as createClient$4 } from '@sanity/client';
17
24
  import { DescribeSecretCommand, CreateSecretCommand, UpdateSecretCommand, GetSecretValueCommand, SecretsManagerClient } from '@aws-sdk/client-secrets-manager';
18
25
 
19
26
  var BucketItemType;
@@ -2820,12 +2827,18 @@ class QueryClauseBuilder {
2820
2827
  if (!!filter?.eq) {
2821
2828
  clauses.push(Equal(filter.eq));
2822
2829
  }
2830
+ if (!!filter?.ieq) {
2831
+ clauses.push(ILike(filter.eq));
2832
+ }
2823
2833
  if (!!filter?.like) {
2824
2834
  clauses.push(Like(filter.like.replaceAll("*", "%")));
2825
2835
  }
2826
2836
  if (!!filter?.ne) {
2827
2837
  clauses.push(Not(Equal(filter.ne)));
2828
2838
  }
2839
+ if (!!filter?.ine) {
2840
+ clauses.push(Not(ILike(filter.ine)));
2841
+ }
2829
2842
  if (!!filter?.notIn) {
2830
2843
  clauses.push(Not(In(filter.notIn)));
2831
2844
  }
@@ -23088,7 +23101,7 @@ AuthenticationMiddleware = __decorate([
23088
23101
  ], AuthenticationMiddleware);
23089
23102
 
23090
23103
  var AuthenticationModule_1;
23091
- const ModuleData$5 = {
23104
+ const ModuleData$6 = {
23092
23105
  imports: [EntityManagerModule, JwtModule],
23093
23106
  providers: [
23094
23107
  AuthenticationServicesResolver,
@@ -23105,7 +23118,7 @@ let AuthenticationModule = AuthenticationModule_1 = class AuthenticationModule {
23105
23118
  authSettings.initialize(input);
23106
23119
  return {
23107
23120
  module: AuthenticationModule_1,
23108
- ...ModuleData$5,
23121
+ ...ModuleData$6,
23109
23122
  };
23110
23123
  }
23111
23124
  configure(consumer) {
@@ -23118,7 +23131,7 @@ let AuthenticationModule = AuthenticationModule_1 = class AuthenticationModule {
23118
23131
  };
23119
23132
  AuthenticationModule = AuthenticationModule_1 = __decorate([
23120
23133
  Module({
23121
- ...ModuleData$5,
23134
+ ...ModuleData$6,
23122
23135
  })
23123
23136
  ], AuthenticationModule);
23124
23137
 
@@ -23575,7 +23588,7 @@ AwsS3FileProvider = __decorate([
23575
23588
  ], AwsS3FileProvider);
23576
23589
 
23577
23590
  var AwsBucketModule_1;
23578
- const ModuleData$4 = {
23591
+ const ModuleData$5 = {
23579
23592
  providers: [AwsS3BucketProvider, AwsS3FileProvider],
23580
23593
  };
23581
23594
  let AwsBucketModule = AwsBucketModule_1 = class AwsBucketModule {
@@ -23583,13 +23596,13 @@ let AwsBucketModule = AwsBucketModule_1 = class AwsBucketModule {
23583
23596
  awsBucketSettings.initialize(input);
23584
23597
  return {
23585
23598
  module: AwsBucketModule_1,
23586
- ...ModuleData$4,
23599
+ ...ModuleData$5,
23587
23600
  };
23588
23601
  }
23589
23602
  };
23590
23603
  AwsBucketModule = AwsBucketModule_1 = __decorate([
23591
23604
  Module({
23592
- ...ModuleData$4,
23605
+ ...ModuleData$5,
23593
23606
  })
23594
23607
  ], AwsBucketModule);
23595
23608
 
@@ -23737,16 +23750,16 @@ var handlebars_runtime = {exports: {}};
23737
23750
 
23738
23751
  var base$1 = {};
23739
23752
 
23740
- var utils = {};
23753
+ var utils$g = {};
23741
23754
 
23742
- utils.__esModule = true;
23743
- utils.extend = extend;
23744
- utils.indexOf = indexOf;
23745
- utils.escapeExpression = escapeExpression;
23746
- utils.isEmpty = isEmpty;
23747
- utils.createFrame = createFrame;
23748
- utils.blockParams = blockParams;
23749
- utils.appendContextPath = appendContextPath;
23755
+ utils$g.__esModule = true;
23756
+ utils$g.extend = extend$1;
23757
+ utils$g.indexOf = indexOf;
23758
+ utils$g.escapeExpression = escapeExpression;
23759
+ utils$g.isEmpty = isEmpty;
23760
+ utils$g.createFrame = createFrame;
23761
+ utils$g.blockParams = blockParams;
23762
+ utils$g.appendContextPath = appendContextPath;
23750
23763
  var escape = {
23751
23764
  '&': '&',
23752
23765
  '<': '&lt;',
@@ -23764,7 +23777,7 @@ function escapeChar(chr) {
23764
23777
  return escape[chr];
23765
23778
  }
23766
23779
 
23767
- function extend(obj /* , ...source */) {
23780
+ function extend$1(obj /* , ...source */) {
23768
23781
  for (var i = 1; i < arguments.length; i++) {
23769
23782
  for (var key in arguments[i]) {
23770
23783
  if (Object.prototype.hasOwnProperty.call(arguments[i], key)) {
@@ -23776,32 +23789,32 @@ function extend(obj /* , ...source */) {
23776
23789
  return obj;
23777
23790
  }
23778
23791
 
23779
- var toString = Object.prototype.toString;
23792
+ var toString$1 = Object.prototype.toString;
23780
23793
 
23781
- utils.toString = toString;
23794
+ utils$g.toString = toString$1;
23782
23795
  // Sourced from lodash
23783
23796
  // https://github.com/bestiejs/lodash/blob/master/LICENSE.txt
23784
23797
  /* eslint-disable func-style */
23785
- var isFunction = function isFunction(value) {
23798
+ var isFunction$2 = function isFunction(value) {
23786
23799
  return typeof value === 'function';
23787
23800
  };
23788
23801
  // fallback for older versions of Chrome and Safari
23789
23802
  /* istanbul ignore next */
23790
- if (isFunction(/x/)) {
23791
- utils.isFunction = isFunction = function (value) {
23792
- return typeof value === 'function' && toString.call(value) === '[object Function]';
23803
+ if (isFunction$2(/x/)) {
23804
+ utils$g.isFunction = isFunction$2 = function (value) {
23805
+ return typeof value === 'function' && toString$1.call(value) === '[object Function]';
23793
23806
  };
23794
23807
  }
23795
- utils.isFunction = isFunction;
23808
+ utils$g.isFunction = isFunction$2;
23796
23809
 
23797
23810
  /* eslint-enable func-style */
23798
23811
 
23799
23812
  /* istanbul ignore next */
23800
- var isArray = Array.isArray || function (value) {
23801
- return value && typeof value === 'object' ? toString.call(value) === '[object Array]' : false;
23813
+ var isArray$1 = Array.isArray || function (value) {
23814
+ return value && typeof value === 'object' ? toString$1.call(value) === '[object Array]' : false;
23802
23815
  };
23803
23816
 
23804
- utils.isArray = isArray;
23817
+ utils$g.isArray = isArray$1;
23805
23818
  // Older IE versions do not directly support indexOf so we must implement our own, sadly.
23806
23819
 
23807
23820
  function indexOf(array, value) {
@@ -23839,7 +23852,7 @@ function escapeExpression(string) {
23839
23852
  function isEmpty(value) {
23840
23853
  if (!value && value !== 0) {
23841
23854
  return true;
23842
- } else if (isArray(value) && value.length === 0) {
23855
+ } else if (isArray$1(value) && value.length === 0) {
23843
23856
  return true;
23844
23857
  } else {
23845
23858
  return false;
@@ -23847,7 +23860,7 @@ function isEmpty(value) {
23847
23860
  }
23848
23861
 
23849
23862
  function createFrame(object) {
23850
- var frame = extend({}, object);
23863
+ var frame = extend$1({}, object);
23851
23864
  frame._parent = object;
23852
23865
  return frame;
23853
23866
  }
@@ -23937,7 +23950,7 @@ var blockHelperMissing = {exports: {}};
23937
23950
 
23938
23951
  exports.__esModule = true;
23939
23952
 
23940
- var _utils = utils;
23953
+ var _utils = utils$g;
23941
23954
 
23942
23955
  exports['default'] = function (instance) {
23943
23956
  instance.registerHelper('blockHelperMissing', function (context, options) {
@@ -23983,7 +23996,7 @@ exports.__esModule = true;
23983
23996
 
23984
23997
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
23985
23998
 
23986
- var _utils = utils;
23999
+ var _utils = utils$g;
23987
24000
 
23988
24001
  var _exception = exception.exports;
23989
24002
 
@@ -24120,7 +24133,7 @@ exports.__esModule = true;
24120
24133
 
24121
24134
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
24122
24135
 
24123
- var _utils = utils;
24136
+ var _utils = utils$g;
24124
24137
 
24125
24138
  var _exception = exception.exports;
24126
24139
 
@@ -24220,7 +24233,7 @@ exports.__esModule = true;
24220
24233
 
24221
24234
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
24222
24235
 
24223
- var _utils = utils;
24236
+ var _utils = utils$g;
24224
24237
 
24225
24238
  var _exception = exception.exports;
24226
24239
 
@@ -24320,7 +24333,7 @@ var inline = {exports: {}};
24320
24333
 
24321
24334
  exports.__esModule = true;
24322
24335
 
24323
- var _utils = utils;
24336
+ var _utils = utils$g;
24324
24337
 
24325
24338
  exports['default'] = function (instance) {
24326
24339
  instance.registerDecorator('inline', function (fn, props, container, options) {
@@ -24367,7 +24380,7 @@ var logger$1 = {exports: {}};
24367
24380
 
24368
24381
  exports.__esModule = true;
24369
24382
 
24370
- var _utils = utils;
24383
+ var _utils = utils$g;
24371
24384
 
24372
24385
  var logger = {
24373
24386
  methodMap: ['debug', 'info', 'warn', 'error'],
@@ -24419,7 +24432,7 @@ var createNewLookupObject$1 = {};
24419
24432
  createNewLookupObject$1.__esModule = true;
24420
24433
  createNewLookupObject$1.createNewLookupObject = createNewLookupObject;
24421
24434
 
24422
- var _utils$4 = utils;
24435
+ var _utils$4 = utils$g;
24423
24436
 
24424
24437
  /**
24425
24438
  * Create a new object with "null"-prototype to avoid truthy results on prototype properties.
@@ -24513,7 +24526,7 @@ base$1.HandlebarsEnvironment = HandlebarsEnvironment;
24513
24526
 
24514
24527
  function _interopRequireDefault$5(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
24515
24528
 
24516
- var _utils$3 = utils;
24529
+ var _utils$3 = utils$g;
24517
24530
 
24518
24531
  var _exception$3 = exception.exports;
24519
24532
 
@@ -24529,8 +24542,8 @@ var _logger2 = _interopRequireDefault$5(_logger);
24529
24542
 
24530
24543
  var _internalProtoAccess$1 = protoAccess;
24531
24544
 
24532
- var VERSION = '4.7.7';
24533
- base$1.VERSION = VERSION;
24545
+ var VERSION$2 = '4.7.7';
24546
+ base$1.VERSION = VERSION$2;
24534
24547
  var COMPILER_REVISION = 8;
24535
24548
  base$1.COMPILER_REVISION = COMPILER_REVISION;
24536
24549
  var LAST_COMPATIBLE_COMPILER_REVISION = 7;
@@ -24666,7 +24679,7 @@ runtime.template = template;
24666
24679
  runtime.wrapProgram = wrapProgram;
24667
24680
  runtime.resolvePartial = resolvePartial;
24668
24681
  runtime.invokePartial = invokePartial;
24669
- runtime.noop = noop;
24682
+ runtime.noop = noop$1;
24670
24683
  // istanbul ignore next
24671
24684
 
24672
24685
  function _interopRequireDefault$4(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
@@ -24675,7 +24688,7 @@ function _interopRequireDefault$4(obj) { return obj && obj.__esModule ? obj : {
24675
24688
 
24676
24689
  function _interopRequireWildcard$1(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
24677
24690
 
24678
- var _utils$2 = utils;
24691
+ var _utils$2 = utils$g;
24679
24692
 
24680
24693
  var Utils = _interopRequireWildcard$1(_utils$2);
24681
24694
 
@@ -24964,7 +24977,7 @@ function invokePartial(partial, context, options) {
24964
24977
  }
24965
24978
 
24966
24979
  var partialBlock = undefined;
24967
- if (options.fn && options.fn !== noop) {
24980
+ if (options.fn && options.fn !== noop$1) {
24968
24981
  (function () {
24969
24982
  options.data = _base.createFrame(options.data);
24970
24983
  // Wrapper function to get access to currentPartialBlock from the closure
@@ -24995,7 +25008,7 @@ function invokePartial(partial, context, options) {
24995
25008
  }
24996
25009
  }
24997
25010
 
24998
- function noop() {
25011
+ function noop$1() {
24999
25012
  return '';
25000
25013
  }
25001
25014
 
@@ -25079,7 +25092,7 @@ var _handlebarsException = exception.exports;
25079
25092
 
25080
25093
  var _handlebarsException2 = _interopRequireDefault(_handlebarsException);
25081
25094
 
25082
- var _handlebarsUtils = utils;
25095
+ var _handlebarsUtils = utils$g;
25083
25096
 
25084
25097
  var Utils = _interopRequireWildcard(_handlebarsUtils);
25085
25098
 
@@ -26453,7 +26466,7 @@ var _helpers = helpers;
26453
26466
 
26454
26467
  var Helpers = _interopRequireWildcard(_helpers);
26455
26468
 
26456
- var _utils$1 = utils;
26469
+ var _utils$1 = utils$g;
26457
26470
 
26458
26471
  base.parser = _parser2['default'];
26459
26472
 
@@ -26501,7 +26514,7 @@ var _exception = exception.exports;
26501
26514
 
26502
26515
  var _exception2 = _interopRequireDefault$1(_exception);
26503
26516
 
26504
- var _utils = utils;
26517
+ var _utils = utils$g;
26505
26518
 
26506
26519
  var _ast = ast.exports;
26507
26520
 
@@ -27061,7 +27074,7 @@ var codeGen = {exports: {}};
27061
27074
 
27062
27075
  exports.__esModule = true;
27063
27076
 
27064
- var _utils = utils;
27077
+ var _utils = utils$g;
27065
27078
 
27066
27079
  var SourceNode = undefined;
27067
27080
 
@@ -27239,7 +27252,7 @@ var _exception = exception.exports;
27239
27252
 
27240
27253
  var _exception2 = _interopRequireDefault(_exception);
27241
27254
 
27242
- var _utils = utils;
27255
+ var _utils = utils$g;
27243
27256
 
27244
27257
  var _codeGen = codeGen.exports;
27245
27258
 
@@ -28733,7 +28746,7 @@ AwsSesEmailProvider = __decorate([
28733
28746
  ], AwsSesEmailProvider);
28734
28747
 
28735
28748
  var AwsEmailModule_1;
28736
- const ModuleData$3 = {
28749
+ const ModuleData$4 = {
28737
28750
  providers: [AwsSesEmailProvider],
28738
28751
  };
28739
28752
  let AwsEmailModule = AwsEmailModule_1 = class AwsEmailModule {
@@ -28741,13 +28754,13 @@ let AwsEmailModule = AwsEmailModule_1 = class AwsEmailModule {
28741
28754
  awsSesSettings.initialize(input);
28742
28755
  return {
28743
28756
  module: AwsEmailModule_1,
28744
- ...ModuleData$3,
28757
+ ...ModuleData$4,
28745
28758
  };
28746
28759
  }
28747
28760
  };
28748
28761
  AwsEmailModule = AwsEmailModule_1 = __decorate([
28749
28762
  Module({
28750
- ...ModuleData$3,
28763
+ ...ModuleData$4,
28751
28764
  })
28752
28765
  ], AwsEmailModule);
28753
28766
 
@@ -28900,7 +28913,7 @@ SendgridEmailProvider = __decorate([
28900
28913
  ], SendgridEmailProvider);
28901
28914
 
28902
28915
  var SendgridEmailModule_1;
28903
- const ModuleData$2 = {
28916
+ const ModuleData$3 = {
28904
28917
  imports: [EntityManagerModule],
28905
28918
  providers: [SendgridEmailProvider],
28906
28919
  };
@@ -28909,13 +28922,13 @@ let SendgridEmailModule = SendgridEmailModule_1 = class SendgridEmailModule {
28909
28922
  sendgridSettings.initialize(input);
28910
28923
  return {
28911
28924
  module: SendgridEmailModule_1,
28912
- ...ModuleData$2,
28925
+ ...ModuleData$3,
28913
28926
  };
28914
28927
  }
28915
28928
  };
28916
28929
  SendgridEmailModule = SendgridEmailModule_1 = __decorate([
28917
28930
  Module({
28918
- ...ModuleData$2,
28931
+ ...ModuleData$3,
28919
28932
  })
28920
28933
  ], SendgridEmailModule);
28921
28934
 
@@ -28962,10 +28975,10 @@ const createClient$1 = (settings) => new S3Client({
28962
28975
  }
28963
28976
  : undefined,
28964
28977
  });
28965
- const buildRef = (bucket, path) => {
28978
+ const buildRef$1 = (bucket, path) => {
28966
28979
  return `s3://${bucket}/${path}`;
28967
28980
  };
28968
- const parseRef = (ref) => {
28981
+ const parseRef$1 = (ref) => {
28969
28982
  const parts = ref.split("/");
28970
28983
  return {
28971
28984
  bucket: parts[2],
@@ -28980,7 +28993,7 @@ let AwsS3MediaProvider = class AwsS3MediaProvider {
28980
28993
  return "awsS3";
28981
28994
  }
28982
28995
  getFileName(input) {
28983
- const parsedRef = parseRef(input.ref);
28996
+ const parsedRef = parseRef$1(input.ref);
28984
28997
  return parsedRef.path.split("/").pop() ?? "";
28985
28998
  }
28986
28999
  async mediaUpload(input) {
@@ -28995,7 +29008,7 @@ let AwsS3MediaProvider = class AwsS3MediaProvider {
28995
29008
  ACL: "public-read",
28996
29009
  }));
28997
29010
  return {
28998
- ref: buildRef(bucket, path),
29011
+ ref: buildRef$1(bucket, path),
28999
29012
  };
29000
29013
  }
29001
29014
  catch (e) {
@@ -29004,7 +29017,7 @@ let AwsS3MediaProvider = class AwsS3MediaProvider {
29004
29017
  }
29005
29018
  async mediaDelete(input) {
29006
29019
  try {
29007
- const parsedRef = parseRef(input.ref);
29020
+ const parsedRef = parseRef$1(input.ref);
29008
29021
  await this.client.send(new DeleteObjectCommand({
29009
29022
  Bucket: parsedRef.bucket,
29010
29023
  Key: parsedRef.path,
@@ -29016,7 +29029,7 @@ let AwsS3MediaProvider = class AwsS3MediaProvider {
29016
29029
  }
29017
29030
  async mediaDownload(input) {
29018
29031
  try {
29019
- const parsedRef = parseRef(input.ref);
29032
+ const parsedRef = parseRef$1(input.ref);
29020
29033
  const result = await this.client.send(new GetObjectCommand({
29021
29034
  Bucket: parsedRef.bucket,
29022
29035
  Key: parsedRef.path,
@@ -29042,7 +29055,7 @@ AwsS3MediaProvider = __decorate([
29042
29055
  ], AwsS3MediaProvider);
29043
29056
 
29044
29057
  var AwsS3MediaModule_1;
29045
- const ModuleData$1 = {
29058
+ const ModuleData$2 = {
29046
29059
  providers: [AwsS3MediaProvider],
29047
29060
  };
29048
29061
  let AwsS3MediaModule = AwsS3MediaModule_1 = class AwsS3MediaModule {
@@ -29050,16 +29063,2980 @@ let AwsS3MediaModule = AwsS3MediaModule_1 = class AwsS3MediaModule {
29050
29063
  awsMediaSettings.initialize(input);
29051
29064
  return {
29052
29065
  module: AwsS3MediaModule_1,
29053
- ...ModuleData$1,
29066
+ ...ModuleData$2,
29054
29067
  };
29055
29068
  }
29056
29069
  };
29057
29070
  AwsS3MediaModule = AwsS3MediaModule_1 = __decorate([
29058
29071
  Module({
29059
- ...ModuleData$1,
29072
+ ...ModuleData$2,
29060
29073
  })
29061
29074
  ], AwsS3MediaModule);
29062
29075
 
29076
+ class SanityMediaError extends Error {
29077
+ constructor(message) {
29078
+ super(message);
29079
+ this.name = "SanityMediaError";
29080
+ }
29081
+ }
29082
+
29083
+ var axios$2 = {exports: {}};
29084
+
29085
+ var bind$2 = function bind(fn, thisArg) {
29086
+ return function wrap() {
29087
+ var args = new Array(arguments.length);
29088
+ for (var i = 0; i < args.length; i++) {
29089
+ args[i] = arguments[i];
29090
+ }
29091
+ return fn.apply(thisArg, args);
29092
+ };
29093
+ };
29094
+
29095
+ var bind$1 = bind$2;
29096
+
29097
+ // utils is a library of generic helper functions non-specific to axios
29098
+
29099
+ var toString = Object.prototype.toString;
29100
+
29101
+ /**
29102
+ * Determine if a value is an Array
29103
+ *
29104
+ * @param {Object} val The value to test
29105
+ * @returns {boolean} True if value is an Array, otherwise false
29106
+ */
29107
+ function isArray(val) {
29108
+ return Array.isArray(val);
29109
+ }
29110
+
29111
+ /**
29112
+ * Determine if a value is undefined
29113
+ *
29114
+ * @param {Object} val The value to test
29115
+ * @returns {boolean} True if the value is undefined, otherwise false
29116
+ */
29117
+ function isUndefined(val) {
29118
+ return typeof val === 'undefined';
29119
+ }
29120
+
29121
+ /**
29122
+ * Determine if a value is a Buffer
29123
+ *
29124
+ * @param {Object} val The value to test
29125
+ * @returns {boolean} True if value is a Buffer, otherwise false
29126
+ */
29127
+ function isBuffer$1(val) {
29128
+ return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
29129
+ && typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val);
29130
+ }
29131
+
29132
+ /**
29133
+ * Determine if a value is an ArrayBuffer
29134
+ *
29135
+ * @param {Object} val The value to test
29136
+ * @returns {boolean} True if value is an ArrayBuffer, otherwise false
29137
+ */
29138
+ function isArrayBuffer(val) {
29139
+ return toString.call(val) === '[object ArrayBuffer]';
29140
+ }
29141
+
29142
+ /**
29143
+ * Determine if a value is a FormData
29144
+ *
29145
+ * @param {Object} val The value to test
29146
+ * @returns {boolean} True if value is an FormData, otherwise false
29147
+ */
29148
+ function isFormData(val) {
29149
+ return toString.call(val) === '[object FormData]';
29150
+ }
29151
+
29152
+ /**
29153
+ * Determine if a value is a view on an ArrayBuffer
29154
+ *
29155
+ * @param {Object} val The value to test
29156
+ * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
29157
+ */
29158
+ function isArrayBufferView(val) {
29159
+ var result;
29160
+ if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
29161
+ result = ArrayBuffer.isView(val);
29162
+ } else {
29163
+ result = (val) && (val.buffer) && (isArrayBuffer(val.buffer));
29164
+ }
29165
+ return result;
29166
+ }
29167
+
29168
+ /**
29169
+ * Determine if a value is a String
29170
+ *
29171
+ * @param {Object} val The value to test
29172
+ * @returns {boolean} True if value is a String, otherwise false
29173
+ */
29174
+ function isString$1(val) {
29175
+ return typeof val === 'string';
29176
+ }
29177
+
29178
+ /**
29179
+ * Determine if a value is a Number
29180
+ *
29181
+ * @param {Object} val The value to test
29182
+ * @returns {boolean} True if value is a Number, otherwise false
29183
+ */
29184
+ function isNumber(val) {
29185
+ return typeof val === 'number';
29186
+ }
29187
+
29188
+ /**
29189
+ * Determine if a value is an Object
29190
+ *
29191
+ * @param {Object} val The value to test
29192
+ * @returns {boolean} True if value is an Object, otherwise false
29193
+ */
29194
+ function isObject(val) {
29195
+ return val !== null && typeof val === 'object';
29196
+ }
29197
+
29198
+ /**
29199
+ * Determine if a value is a plain Object
29200
+ *
29201
+ * @param {Object} val The value to test
29202
+ * @return {boolean} True if value is a plain Object, otherwise false
29203
+ */
29204
+ function isPlainObject(val) {
29205
+ if (toString.call(val) !== '[object Object]') {
29206
+ return false;
29207
+ }
29208
+
29209
+ var prototype = Object.getPrototypeOf(val);
29210
+ return prototype === null || prototype === Object.prototype;
29211
+ }
29212
+
29213
+ /**
29214
+ * Determine if a value is a Date
29215
+ *
29216
+ * @param {Object} val The value to test
29217
+ * @returns {boolean} True if value is a Date, otherwise false
29218
+ */
29219
+ function isDate(val) {
29220
+ return toString.call(val) === '[object Date]';
29221
+ }
29222
+
29223
+ /**
29224
+ * Determine if a value is a File
29225
+ *
29226
+ * @param {Object} val The value to test
29227
+ * @returns {boolean} True if value is a File, otherwise false
29228
+ */
29229
+ function isFile(val) {
29230
+ return toString.call(val) === '[object File]';
29231
+ }
29232
+
29233
+ /**
29234
+ * Determine if a value is a Blob
29235
+ *
29236
+ * @param {Object} val The value to test
29237
+ * @returns {boolean} True if value is a Blob, otherwise false
29238
+ */
29239
+ function isBlob(val) {
29240
+ return toString.call(val) === '[object Blob]';
29241
+ }
29242
+
29243
+ /**
29244
+ * Determine if a value is a Function
29245
+ *
29246
+ * @param {Object} val The value to test
29247
+ * @returns {boolean} True if value is a Function, otherwise false
29248
+ */
29249
+ function isFunction$1(val) {
29250
+ return toString.call(val) === '[object Function]';
29251
+ }
29252
+
29253
+ /**
29254
+ * Determine if a value is a Stream
29255
+ *
29256
+ * @param {Object} val The value to test
29257
+ * @returns {boolean} True if value is a Stream, otherwise false
29258
+ */
29259
+ function isStream(val) {
29260
+ return isObject(val) && isFunction$1(val.pipe);
29261
+ }
29262
+
29263
+ /**
29264
+ * Determine if a value is a URLSearchParams object
29265
+ *
29266
+ * @param {Object} val The value to test
29267
+ * @returns {boolean} True if value is a URLSearchParams object, otherwise false
29268
+ */
29269
+ function isURLSearchParams(val) {
29270
+ return toString.call(val) === '[object URLSearchParams]';
29271
+ }
29272
+
29273
+ /**
29274
+ * Trim excess whitespace off the beginning and end of a string
29275
+ *
29276
+ * @param {String} str The String to trim
29277
+ * @returns {String} The String freed of excess whitespace
29278
+ */
29279
+ function trim(str) {
29280
+ return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g, '');
29281
+ }
29282
+
29283
+ /**
29284
+ * Determine if we're running in a standard browser environment
29285
+ *
29286
+ * This allows axios to run in a web worker, and react-native.
29287
+ * Both environments support XMLHttpRequest, but not fully standard globals.
29288
+ *
29289
+ * web workers:
29290
+ * typeof window -> undefined
29291
+ * typeof document -> undefined
29292
+ *
29293
+ * react-native:
29294
+ * navigator.product -> 'ReactNative'
29295
+ * nativescript
29296
+ * navigator.product -> 'NativeScript' or 'NS'
29297
+ */
29298
+ function isStandardBrowserEnv() {
29299
+ if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' ||
29300
+ navigator.product === 'NativeScript' ||
29301
+ navigator.product === 'NS')) {
29302
+ return false;
29303
+ }
29304
+ return (
29305
+ typeof window !== 'undefined' &&
29306
+ typeof document !== 'undefined'
29307
+ );
29308
+ }
29309
+
29310
+ /**
29311
+ * Iterate over an Array or an Object invoking a function for each item.
29312
+ *
29313
+ * If `obj` is an Array callback will be called passing
29314
+ * the value, index, and complete array for each item.
29315
+ *
29316
+ * If 'obj' is an Object callback will be called passing
29317
+ * the value, key, and complete object for each property.
29318
+ *
29319
+ * @param {Object|Array} obj The object to iterate
29320
+ * @param {Function} fn The callback to invoke for each item
29321
+ */
29322
+ function forEach(obj, fn) {
29323
+ // Don't bother if no value provided
29324
+ if (obj === null || typeof obj === 'undefined') {
29325
+ return;
29326
+ }
29327
+
29328
+ // Force an array if not already something iterable
29329
+ if (typeof obj !== 'object') {
29330
+ /*eslint no-param-reassign:0*/
29331
+ obj = [obj];
29332
+ }
29333
+
29334
+ if (isArray(obj)) {
29335
+ // Iterate over array values
29336
+ for (var i = 0, l = obj.length; i < l; i++) {
29337
+ fn.call(null, obj[i], i, obj);
29338
+ }
29339
+ } else {
29340
+ // Iterate over object keys
29341
+ for (var key in obj) {
29342
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
29343
+ fn.call(null, obj[key], key, obj);
29344
+ }
29345
+ }
29346
+ }
29347
+ }
29348
+
29349
+ /**
29350
+ * Accepts varargs expecting each argument to be an object, then
29351
+ * immutably merges the properties of each object and returns result.
29352
+ *
29353
+ * When multiple objects contain the same key the later object in
29354
+ * the arguments list will take precedence.
29355
+ *
29356
+ * Example:
29357
+ *
29358
+ * ```js
29359
+ * var result = merge({foo: 123}, {foo: 456});
29360
+ * console.log(result.foo); // outputs 456
29361
+ * ```
29362
+ *
29363
+ * @param {Object} obj1 Object to merge
29364
+ * @returns {Object} Result of all merge properties
29365
+ */
29366
+ function merge(/* obj1, obj2, obj3, ... */) {
29367
+ var result = {};
29368
+ function assignValue(val, key) {
29369
+ if (isPlainObject(result[key]) && isPlainObject(val)) {
29370
+ result[key] = merge(result[key], val);
29371
+ } else if (isPlainObject(val)) {
29372
+ result[key] = merge({}, val);
29373
+ } else if (isArray(val)) {
29374
+ result[key] = val.slice();
29375
+ } else {
29376
+ result[key] = val;
29377
+ }
29378
+ }
29379
+
29380
+ for (var i = 0, l = arguments.length; i < l; i++) {
29381
+ forEach(arguments[i], assignValue);
29382
+ }
29383
+ return result;
29384
+ }
29385
+
29386
+ /**
29387
+ * Extends object a by mutably adding to it the properties of object b.
29388
+ *
29389
+ * @param {Object} a The object to be extended
29390
+ * @param {Object} b The object to copy properties from
29391
+ * @param {Object} thisArg The object to bind function to
29392
+ * @return {Object} The resulting value of object a
29393
+ */
29394
+ function extend(a, b, thisArg) {
29395
+ forEach(b, function assignValue(val, key) {
29396
+ if (thisArg && typeof val === 'function') {
29397
+ a[key] = bind$1(val, thisArg);
29398
+ } else {
29399
+ a[key] = val;
29400
+ }
29401
+ });
29402
+ return a;
29403
+ }
29404
+
29405
+ /**
29406
+ * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
29407
+ *
29408
+ * @param {string} content with BOM
29409
+ * @return {string} content value without BOM
29410
+ */
29411
+ function stripBOM(content) {
29412
+ if (content.charCodeAt(0) === 0xFEFF) {
29413
+ content = content.slice(1);
29414
+ }
29415
+ return content;
29416
+ }
29417
+
29418
+ var utils$f = {
29419
+ isArray: isArray,
29420
+ isArrayBuffer: isArrayBuffer,
29421
+ isBuffer: isBuffer$1,
29422
+ isFormData: isFormData,
29423
+ isArrayBufferView: isArrayBufferView,
29424
+ isString: isString$1,
29425
+ isNumber: isNumber,
29426
+ isObject: isObject,
29427
+ isPlainObject: isPlainObject,
29428
+ isUndefined: isUndefined,
29429
+ isDate: isDate,
29430
+ isFile: isFile,
29431
+ isBlob: isBlob,
29432
+ isFunction: isFunction$1,
29433
+ isStream: isStream,
29434
+ isURLSearchParams: isURLSearchParams,
29435
+ isStandardBrowserEnv: isStandardBrowserEnv,
29436
+ forEach: forEach,
29437
+ merge: merge,
29438
+ extend: extend,
29439
+ trim: trim,
29440
+ stripBOM: stripBOM
29441
+ };
29442
+
29443
+ var utils$e = utils$f;
29444
+
29445
+ function encode(val) {
29446
+ return encodeURIComponent(val).
29447
+ replace(/%3A/gi, ':').
29448
+ replace(/%24/g, '$').
29449
+ replace(/%2C/gi, ',').
29450
+ replace(/%20/g, '+').
29451
+ replace(/%5B/gi, '[').
29452
+ replace(/%5D/gi, ']');
29453
+ }
29454
+
29455
+ /**
29456
+ * Build a URL by appending params to the end
29457
+ *
29458
+ * @param {string} url The base of the url (e.g., http://www.google.com)
29459
+ * @param {object} [params] The params to be appended
29460
+ * @returns {string} The formatted url
29461
+ */
29462
+ var buildURL$3 = function buildURL(url, params, paramsSerializer) {
29463
+ /*eslint no-param-reassign:0*/
29464
+ if (!params) {
29465
+ return url;
29466
+ }
29467
+
29468
+ var serializedParams;
29469
+ if (paramsSerializer) {
29470
+ serializedParams = paramsSerializer(params);
29471
+ } else if (utils$e.isURLSearchParams(params)) {
29472
+ serializedParams = params.toString();
29473
+ } else {
29474
+ var parts = [];
29475
+
29476
+ utils$e.forEach(params, function serialize(val, key) {
29477
+ if (val === null || typeof val === 'undefined') {
29478
+ return;
29479
+ }
29480
+
29481
+ if (utils$e.isArray(val)) {
29482
+ key = key + '[]';
29483
+ } else {
29484
+ val = [val];
29485
+ }
29486
+
29487
+ utils$e.forEach(val, function parseValue(v) {
29488
+ if (utils$e.isDate(v)) {
29489
+ v = v.toISOString();
29490
+ } else if (utils$e.isObject(v)) {
29491
+ v = JSON.stringify(v);
29492
+ }
29493
+ parts.push(encode(key) + '=' + encode(v));
29494
+ });
29495
+ });
29496
+
29497
+ serializedParams = parts.join('&');
29498
+ }
29499
+
29500
+ if (serializedParams) {
29501
+ var hashmarkIndex = url.indexOf('#');
29502
+ if (hashmarkIndex !== -1) {
29503
+ url = url.slice(0, hashmarkIndex);
29504
+ }
29505
+
29506
+ url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
29507
+ }
29508
+
29509
+ return url;
29510
+ };
29511
+
29512
+ var utils$d = utils$f;
29513
+
29514
+ function InterceptorManager$1() {
29515
+ this.handlers = [];
29516
+ }
29517
+
29518
+ /**
29519
+ * Add a new interceptor to the stack
29520
+ *
29521
+ * @param {Function} fulfilled The function to handle `then` for a `Promise`
29522
+ * @param {Function} rejected The function to handle `reject` for a `Promise`
29523
+ *
29524
+ * @return {Number} An ID used to remove interceptor later
29525
+ */
29526
+ InterceptorManager$1.prototype.use = function use(fulfilled, rejected, options) {
29527
+ this.handlers.push({
29528
+ fulfilled: fulfilled,
29529
+ rejected: rejected,
29530
+ synchronous: options ? options.synchronous : false,
29531
+ runWhen: options ? options.runWhen : null
29532
+ });
29533
+ return this.handlers.length - 1;
29534
+ };
29535
+
29536
+ /**
29537
+ * Remove an interceptor from the stack
29538
+ *
29539
+ * @param {Number} id The ID that was returned by `use`
29540
+ */
29541
+ InterceptorManager$1.prototype.eject = function eject(id) {
29542
+ if (this.handlers[id]) {
29543
+ this.handlers[id] = null;
29544
+ }
29545
+ };
29546
+
29547
+ /**
29548
+ * Iterate over all the registered interceptors
29549
+ *
29550
+ * This method is particularly useful for skipping over any
29551
+ * interceptors that may have become `null` calling `eject`.
29552
+ *
29553
+ * @param {Function} fn The function to call for each interceptor
29554
+ */
29555
+ InterceptorManager$1.prototype.forEach = function forEach(fn) {
29556
+ utils$d.forEach(this.handlers, function forEachHandler(h) {
29557
+ if (h !== null) {
29558
+ fn(h);
29559
+ }
29560
+ });
29561
+ };
29562
+
29563
+ var InterceptorManager_1 = InterceptorManager$1;
29564
+
29565
+ var utils$c = utils$f;
29566
+
29567
+ var normalizeHeaderName$1 = function normalizeHeaderName(headers, normalizedName) {
29568
+ utils$c.forEach(headers, function processHeader(value, name) {
29569
+ if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {
29570
+ headers[normalizedName] = value;
29571
+ delete headers[name];
29572
+ }
29573
+ });
29574
+ };
29575
+
29576
+ /**
29577
+ * Update an Error with the specified config, error code, and response.
29578
+ *
29579
+ * @param {Error} error The error to update.
29580
+ * @param {Object} config The config.
29581
+ * @param {string} [code] The error code (for example, 'ECONNABORTED').
29582
+ * @param {Object} [request] The request.
29583
+ * @param {Object} [response] The response.
29584
+ * @returns {Error} The error.
29585
+ */
29586
+ var enhanceError$3 = function enhanceError(error, config, code, request, response) {
29587
+ error.config = config;
29588
+ if (code) {
29589
+ error.code = code;
29590
+ }
29591
+
29592
+ error.request = request;
29593
+ error.response = response;
29594
+ error.isAxiosError = true;
29595
+
29596
+ error.toJSON = function toJSON() {
29597
+ return {
29598
+ // Standard
29599
+ message: this.message,
29600
+ name: this.name,
29601
+ // Microsoft
29602
+ description: this.description,
29603
+ number: this.number,
29604
+ // Mozilla
29605
+ fileName: this.fileName,
29606
+ lineNumber: this.lineNumber,
29607
+ columnNumber: this.columnNumber,
29608
+ stack: this.stack,
29609
+ // Axios
29610
+ config: this.config,
29611
+ code: this.code,
29612
+ status: this.response && this.response.status ? this.response.status : null
29613
+ };
29614
+ };
29615
+ return error;
29616
+ };
29617
+
29618
+ var transitional = {
29619
+ silentJSONParsing: true,
29620
+ forcedJSONParsing: true,
29621
+ clarifyTimeoutError: false
29622
+ };
29623
+
29624
+ var enhanceError$2 = enhanceError$3;
29625
+
29626
+ /**
29627
+ * Create an Error with the specified message, config, error code, request and response.
29628
+ *
29629
+ * @param {string} message The error message.
29630
+ * @param {Object} config The config.
29631
+ * @param {string} [code] The error code (for example, 'ECONNABORTED').
29632
+ * @param {Object} [request] The request.
29633
+ * @param {Object} [response] The response.
29634
+ * @returns {Error} The created error.
29635
+ */
29636
+ var createError$3 = function createError(message, config, code, request, response) {
29637
+ var error = new Error(message);
29638
+ return enhanceError$2(error, config, code, request, response);
29639
+ };
29640
+
29641
+ var createError$2 = createError$3;
29642
+
29643
+ /**
29644
+ * Resolve or reject a Promise based on response status.
29645
+ *
29646
+ * @param {Function} resolve A function that resolves the promise.
29647
+ * @param {Function} reject A function that rejects the promise.
29648
+ * @param {object} response The response.
29649
+ */
29650
+ var settle$2 = function settle(resolve, reject, response) {
29651
+ var validateStatus = response.config.validateStatus;
29652
+ if (!response.status || !validateStatus || validateStatus(response.status)) {
29653
+ resolve(response);
29654
+ } else {
29655
+ reject(createError$2(
29656
+ 'Request failed with status code ' + response.status,
29657
+ response.config,
29658
+ null,
29659
+ response.request,
29660
+ response
29661
+ ));
29662
+ }
29663
+ };
29664
+
29665
+ var utils$b = utils$f;
29666
+
29667
+ var cookies$1 = (
29668
+ utils$b.isStandardBrowserEnv() ?
29669
+
29670
+ // Standard browser envs support document.cookie
29671
+ (function standardBrowserEnv() {
29672
+ return {
29673
+ write: function write(name, value, expires, path, domain, secure) {
29674
+ var cookie = [];
29675
+ cookie.push(name + '=' + encodeURIComponent(value));
29676
+
29677
+ if (utils$b.isNumber(expires)) {
29678
+ cookie.push('expires=' + new Date(expires).toGMTString());
29679
+ }
29680
+
29681
+ if (utils$b.isString(path)) {
29682
+ cookie.push('path=' + path);
29683
+ }
29684
+
29685
+ if (utils$b.isString(domain)) {
29686
+ cookie.push('domain=' + domain);
29687
+ }
29688
+
29689
+ if (secure === true) {
29690
+ cookie.push('secure');
29691
+ }
29692
+
29693
+ document.cookie = cookie.join('; ');
29694
+ },
29695
+
29696
+ read: function read(name) {
29697
+ var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
29698
+ return (match ? decodeURIComponent(match[3]) : null);
29699
+ },
29700
+
29701
+ remove: function remove(name) {
29702
+ this.write(name, '', Date.now() - 86400000);
29703
+ }
29704
+ };
29705
+ })() :
29706
+
29707
+ // Non standard browser env (web workers, react-native) lack needed support.
29708
+ (function nonStandardBrowserEnv() {
29709
+ return {
29710
+ write: function write() {},
29711
+ read: function read() { return null; },
29712
+ remove: function remove() {}
29713
+ };
29714
+ })()
29715
+ );
29716
+
29717
+ /**
29718
+ * Determines whether the specified URL is absolute
29719
+ *
29720
+ * @param {string} url The URL to test
29721
+ * @returns {boolean} True if the specified URL is absolute, otherwise false
29722
+ */
29723
+ var isAbsoluteURL$1 = function isAbsoluteURL(url) {
29724
+ // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
29725
+ // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
29726
+ // by any combination of letters, digits, plus, period, or hyphen.
29727
+ return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
29728
+ };
29729
+
29730
+ /**
29731
+ * Creates a new URL by combining the specified URLs
29732
+ *
29733
+ * @param {string} baseURL The base URL
29734
+ * @param {string} relativeURL The relative URL
29735
+ * @returns {string} The combined URL
29736
+ */
29737
+ var combineURLs$1 = function combineURLs(baseURL, relativeURL) {
29738
+ return relativeURL
29739
+ ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
29740
+ : baseURL;
29741
+ };
29742
+
29743
+ var isAbsoluteURL = isAbsoluteURL$1;
29744
+ var combineURLs = combineURLs$1;
29745
+
29746
+ /**
29747
+ * Creates a new URL by combining the baseURL with the requestedURL,
29748
+ * only when the requestedURL is not already an absolute URL.
29749
+ * If the requestURL is absolute, this function returns the requestedURL untouched.
29750
+ *
29751
+ * @param {string} baseURL The base URL
29752
+ * @param {string} requestedURL Absolute or relative URL to combine
29753
+ * @returns {string} The combined full path
29754
+ */
29755
+ var buildFullPath$2 = function buildFullPath(baseURL, requestedURL) {
29756
+ if (baseURL && !isAbsoluteURL(requestedURL)) {
29757
+ return combineURLs(baseURL, requestedURL);
29758
+ }
29759
+ return requestedURL;
29760
+ };
29761
+
29762
+ var utils$a = utils$f;
29763
+
29764
+ // Headers whose duplicates are ignored by node
29765
+ // c.f. https://nodejs.org/api/http.html#http_message_headers
29766
+ var ignoreDuplicateOf = [
29767
+ 'age', 'authorization', 'content-length', 'content-type', 'etag',
29768
+ 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
29769
+ 'last-modified', 'location', 'max-forwards', 'proxy-authorization',
29770
+ 'referer', 'retry-after', 'user-agent'
29771
+ ];
29772
+
29773
+ /**
29774
+ * Parse headers into an object
29775
+ *
29776
+ * ```
29777
+ * Date: Wed, 27 Aug 2014 08:58:49 GMT
29778
+ * Content-Type: application/json
29779
+ * Connection: keep-alive
29780
+ * Transfer-Encoding: chunked
29781
+ * ```
29782
+ *
29783
+ * @param {String} headers Headers needing to be parsed
29784
+ * @returns {Object} Headers parsed into an object
29785
+ */
29786
+ var parseHeaders$1 = function parseHeaders(headers) {
29787
+ var parsed = {};
29788
+ var key;
29789
+ var val;
29790
+ var i;
29791
+
29792
+ if (!headers) { return parsed; }
29793
+
29794
+ utils$a.forEach(headers.split('\n'), function parser(line) {
29795
+ i = line.indexOf(':');
29796
+ key = utils$a.trim(line.substr(0, i)).toLowerCase();
29797
+ val = utils$a.trim(line.substr(i + 1));
29798
+
29799
+ if (key) {
29800
+ if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {
29801
+ return;
29802
+ }
29803
+ if (key === 'set-cookie') {
29804
+ parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);
29805
+ } else {
29806
+ parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
29807
+ }
29808
+ }
29809
+ });
29810
+
29811
+ return parsed;
29812
+ };
29813
+
29814
+ var utils$9 = utils$f;
29815
+
29816
+ var isURLSameOrigin$1 = (
29817
+ utils$9.isStandardBrowserEnv() ?
29818
+
29819
+ // Standard browser envs have full support of the APIs needed to test
29820
+ // whether the request URL is of the same origin as current location.
29821
+ (function standardBrowserEnv() {
29822
+ var msie = /(msie|trident)/i.test(navigator.userAgent);
29823
+ var urlParsingNode = document.createElement('a');
29824
+ var originURL;
29825
+
29826
+ /**
29827
+ * Parse a URL to discover it's components
29828
+ *
29829
+ * @param {String} url The URL to be parsed
29830
+ * @returns {Object}
29831
+ */
29832
+ function resolveURL(url) {
29833
+ var href = url;
29834
+
29835
+ if (msie) {
29836
+ // IE needs attribute set twice to normalize properties
29837
+ urlParsingNode.setAttribute('href', href);
29838
+ href = urlParsingNode.href;
29839
+ }
29840
+
29841
+ urlParsingNode.setAttribute('href', href);
29842
+
29843
+ // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
29844
+ return {
29845
+ href: urlParsingNode.href,
29846
+ protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
29847
+ host: urlParsingNode.host,
29848
+ search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
29849
+ hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
29850
+ hostname: urlParsingNode.hostname,
29851
+ port: urlParsingNode.port,
29852
+ pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
29853
+ urlParsingNode.pathname :
29854
+ '/' + urlParsingNode.pathname
29855
+ };
29856
+ }
29857
+
29858
+ originURL = resolveURL(window.location.href);
29859
+
29860
+ /**
29861
+ * Determine if a URL shares the same origin as the current location
29862
+ *
29863
+ * @param {String} requestURL The URL to test
29864
+ * @returns {boolean} True if URL shares the same origin, otherwise false
29865
+ */
29866
+ return function isURLSameOrigin(requestURL) {
29867
+ var parsed = (utils$9.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
29868
+ return (parsed.protocol === originURL.protocol &&
29869
+ parsed.host === originURL.host);
29870
+ };
29871
+ })() :
29872
+
29873
+ // Non standard browser envs (web workers, react-native) lack needed support.
29874
+ (function nonStandardBrowserEnv() {
29875
+ return function isURLSameOrigin() {
29876
+ return true;
29877
+ };
29878
+ })()
29879
+ );
29880
+
29881
+ /**
29882
+ * A `Cancel` is an object that is thrown when an operation is canceled.
29883
+ *
29884
+ * @class
29885
+ * @param {string=} message The message.
29886
+ */
29887
+ function Cancel$4(message) {
29888
+ this.message = message;
29889
+ }
29890
+
29891
+ Cancel$4.prototype.toString = function toString() {
29892
+ return 'Cancel' + (this.message ? ': ' + this.message : '');
29893
+ };
29894
+
29895
+ Cancel$4.prototype.__CANCEL__ = true;
29896
+
29897
+ var Cancel_1 = Cancel$4;
29898
+
29899
+ var utils$8 = utils$f;
29900
+ var settle$1 = settle$2;
29901
+ var cookies = cookies$1;
29902
+ var buildURL$2 = buildURL$3;
29903
+ var buildFullPath$1 = buildFullPath$2;
29904
+ var parseHeaders = parseHeaders$1;
29905
+ var isURLSameOrigin = isURLSameOrigin$1;
29906
+ var createError$1 = createError$3;
29907
+ var transitionalDefaults$2 = transitional;
29908
+ var Cancel$3 = Cancel_1;
29909
+
29910
+ var xhr = function xhrAdapter(config) {
29911
+ return new Promise(function dispatchXhrRequest(resolve, reject) {
29912
+ var requestData = config.data;
29913
+ var requestHeaders = config.headers;
29914
+ var responseType = config.responseType;
29915
+ var onCanceled;
29916
+ function done() {
29917
+ if (config.cancelToken) {
29918
+ config.cancelToken.unsubscribe(onCanceled);
29919
+ }
29920
+
29921
+ if (config.signal) {
29922
+ config.signal.removeEventListener('abort', onCanceled);
29923
+ }
29924
+ }
29925
+
29926
+ if (utils$8.isFormData(requestData)) {
29927
+ delete requestHeaders['Content-Type']; // Let the browser set it
29928
+ }
29929
+
29930
+ var request = new XMLHttpRequest();
29931
+
29932
+ // HTTP basic authentication
29933
+ if (config.auth) {
29934
+ var username = config.auth.username || '';
29935
+ var password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : '';
29936
+ requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);
29937
+ }
29938
+
29939
+ var fullPath = buildFullPath$1(config.baseURL, config.url);
29940
+ request.open(config.method.toUpperCase(), buildURL$2(fullPath, config.params, config.paramsSerializer), true);
29941
+
29942
+ // Set the request timeout in MS
29943
+ request.timeout = config.timeout;
29944
+
29945
+ function onloadend() {
29946
+ if (!request) {
29947
+ return;
29948
+ }
29949
+ // Prepare the response
29950
+ var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;
29951
+ var responseData = !responseType || responseType === 'text' || responseType === 'json' ?
29952
+ request.responseText : request.response;
29953
+ var response = {
29954
+ data: responseData,
29955
+ status: request.status,
29956
+ statusText: request.statusText,
29957
+ headers: responseHeaders,
29958
+ config: config,
29959
+ request: request
29960
+ };
29961
+
29962
+ settle$1(function _resolve(value) {
29963
+ resolve(value);
29964
+ done();
29965
+ }, function _reject(err) {
29966
+ reject(err);
29967
+ done();
29968
+ }, response);
29969
+
29970
+ // Clean up request
29971
+ request = null;
29972
+ }
29973
+
29974
+ if ('onloadend' in request) {
29975
+ // Use onloadend if available
29976
+ request.onloadend = onloadend;
29977
+ } else {
29978
+ // Listen for ready state to emulate onloadend
29979
+ request.onreadystatechange = function handleLoad() {
29980
+ if (!request || request.readyState !== 4) {
29981
+ return;
29982
+ }
29983
+
29984
+ // The request errored out and we didn't get a response, this will be
29985
+ // handled by onerror instead
29986
+ // With one exception: request that using file: protocol, most browsers
29987
+ // will return status as 0 even though it's a successful request
29988
+ if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
29989
+ return;
29990
+ }
29991
+ // readystate handler is calling before onerror or ontimeout handlers,
29992
+ // so we should call onloadend on the next 'tick'
29993
+ setTimeout(onloadend);
29994
+ };
29995
+ }
29996
+
29997
+ // Handle browser request cancellation (as opposed to a manual cancellation)
29998
+ request.onabort = function handleAbort() {
29999
+ if (!request) {
30000
+ return;
30001
+ }
30002
+
30003
+ reject(createError$1('Request aborted', config, 'ECONNABORTED', request));
30004
+
30005
+ // Clean up request
30006
+ request = null;
30007
+ };
30008
+
30009
+ // Handle low level network errors
30010
+ request.onerror = function handleError() {
30011
+ // Real errors are hidden from us by the browser
30012
+ // onerror should only fire if it's a network error
30013
+ reject(createError$1('Network Error', config, null, request));
30014
+
30015
+ // Clean up request
30016
+ request = null;
30017
+ };
30018
+
30019
+ // Handle timeout
30020
+ request.ontimeout = function handleTimeout() {
30021
+ var timeoutErrorMessage = config.timeout ? 'timeout of ' + config.timeout + 'ms exceeded' : 'timeout exceeded';
30022
+ var transitional = config.transitional || transitionalDefaults$2;
30023
+ if (config.timeoutErrorMessage) {
30024
+ timeoutErrorMessage = config.timeoutErrorMessage;
30025
+ }
30026
+ reject(createError$1(
30027
+ timeoutErrorMessage,
30028
+ config,
30029
+ transitional.clarifyTimeoutError ? 'ETIMEDOUT' : 'ECONNABORTED',
30030
+ request));
30031
+
30032
+ // Clean up request
30033
+ request = null;
30034
+ };
30035
+
30036
+ // Add xsrf header
30037
+ // This is only done if running in a standard browser environment.
30038
+ // Specifically not if we're in a web worker, or react-native.
30039
+ if (utils$8.isStandardBrowserEnv()) {
30040
+ // Add xsrf header
30041
+ var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ?
30042
+ cookies.read(config.xsrfCookieName) :
30043
+ undefined;
30044
+
30045
+ if (xsrfValue) {
30046
+ requestHeaders[config.xsrfHeaderName] = xsrfValue;
30047
+ }
30048
+ }
30049
+
30050
+ // Add headers to the request
30051
+ if ('setRequestHeader' in request) {
30052
+ utils$8.forEach(requestHeaders, function setRequestHeader(val, key) {
30053
+ if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {
30054
+ // Remove Content-Type if data is undefined
30055
+ delete requestHeaders[key];
30056
+ } else {
30057
+ // Otherwise add header to the request
30058
+ request.setRequestHeader(key, val);
30059
+ }
30060
+ });
30061
+ }
30062
+
30063
+ // Add withCredentials to request if needed
30064
+ if (!utils$8.isUndefined(config.withCredentials)) {
30065
+ request.withCredentials = !!config.withCredentials;
30066
+ }
30067
+
30068
+ // Add responseType to request if needed
30069
+ if (responseType && responseType !== 'json') {
30070
+ request.responseType = config.responseType;
30071
+ }
30072
+
30073
+ // Handle progress if needed
30074
+ if (typeof config.onDownloadProgress === 'function') {
30075
+ request.addEventListener('progress', config.onDownloadProgress);
30076
+ }
30077
+
30078
+ // Not all browsers support upload events
30079
+ if (typeof config.onUploadProgress === 'function' && request.upload) {
30080
+ request.upload.addEventListener('progress', config.onUploadProgress);
30081
+ }
30082
+
30083
+ if (config.cancelToken || config.signal) {
30084
+ // Handle cancellation
30085
+ // eslint-disable-next-line func-names
30086
+ onCanceled = function(cancel) {
30087
+ if (!request) {
30088
+ return;
30089
+ }
30090
+ reject(!cancel || (cancel && cancel.type) ? new Cancel$3('canceled') : cancel);
30091
+ request.abort();
30092
+ request = null;
30093
+ };
30094
+
30095
+ config.cancelToken && config.cancelToken.subscribe(onCanceled);
30096
+ if (config.signal) {
30097
+ config.signal.aborted ? onCanceled() : config.signal.addEventListener('abort', onCanceled);
30098
+ }
30099
+ }
30100
+
30101
+ if (!requestData) {
30102
+ requestData = null;
30103
+ }
30104
+
30105
+ // Send the request
30106
+ request.send(requestData);
30107
+ });
30108
+ };
30109
+
30110
+ var followRedirects = {exports: {}};
30111
+
30112
+ var debug$1;
30113
+
30114
+ var debug_1 = function () {
30115
+ if (!debug$1) {
30116
+ try {
30117
+ /* eslint global-require: off */
30118
+ debug$1 = require("debug")("follow-redirects");
30119
+ }
30120
+ catch (error) { /* */ }
30121
+ if (typeof debug$1 !== "function") {
30122
+ debug$1 = function () { /* */ };
30123
+ }
30124
+ }
30125
+ debug$1.apply(null, arguments);
30126
+ };
30127
+
30128
+ var url$1 = require$$0;
30129
+ var URL = url$1.URL;
30130
+ var http$1 = require$$1;
30131
+ var https$1 = require$$2$1;
30132
+ var Writable = require$$3.Writable;
30133
+ var assert = require$$4;
30134
+ var debug = debug_1;
30135
+
30136
+ // Create handlers that pass events from native requests
30137
+ var events = ["abort", "aborted", "connect", "error", "socket", "timeout"];
30138
+ var eventHandlers = Object.create(null);
30139
+ events.forEach(function (event) {
30140
+ eventHandlers[event] = function (arg1, arg2, arg3) {
30141
+ this._redirectable.emit(event, arg1, arg2, arg3);
30142
+ };
30143
+ });
30144
+
30145
+ var InvalidUrlError = createErrorType(
30146
+ "ERR_INVALID_URL",
30147
+ "Invalid URL",
30148
+ TypeError
30149
+ );
30150
+ // Error types with codes
30151
+ var RedirectionError = createErrorType(
30152
+ "ERR_FR_REDIRECTION_FAILURE",
30153
+ "Redirected request failed"
30154
+ );
30155
+ var TooManyRedirectsError = createErrorType(
30156
+ "ERR_FR_TOO_MANY_REDIRECTS",
30157
+ "Maximum number of redirects exceeded"
30158
+ );
30159
+ var MaxBodyLengthExceededError = createErrorType(
30160
+ "ERR_FR_MAX_BODY_LENGTH_EXCEEDED",
30161
+ "Request body larger than maxBodyLength limit"
30162
+ );
30163
+ var WriteAfterEndError = createErrorType(
30164
+ "ERR_STREAM_WRITE_AFTER_END",
30165
+ "write after end"
30166
+ );
30167
+
30168
+ // An HTTP(S) request that can be redirected
30169
+ function RedirectableRequest(options, responseCallback) {
30170
+ // Initialize the request
30171
+ Writable.call(this);
30172
+ this._sanitizeOptions(options);
30173
+ this._options = options;
30174
+ this._ended = false;
30175
+ this._ending = false;
30176
+ this._redirectCount = 0;
30177
+ this._redirects = [];
30178
+ this._requestBodyLength = 0;
30179
+ this._requestBodyBuffers = [];
30180
+
30181
+ // Attach a callback if passed
30182
+ if (responseCallback) {
30183
+ this.on("response", responseCallback);
30184
+ }
30185
+
30186
+ // React to responses of native requests
30187
+ var self = this;
30188
+ this._onNativeResponse = function (response) {
30189
+ self._processResponse(response);
30190
+ };
30191
+
30192
+ // Perform the first request
30193
+ this._performRequest();
30194
+ }
30195
+ RedirectableRequest.prototype = Object.create(Writable.prototype);
30196
+
30197
+ RedirectableRequest.prototype.abort = function () {
30198
+ abortRequest(this._currentRequest);
30199
+ this.emit("abort");
30200
+ };
30201
+
30202
+ // Writes buffered data to the current native request
30203
+ RedirectableRequest.prototype.write = function (data, encoding, callback) {
30204
+ // Writing is not allowed if end has been called
30205
+ if (this._ending) {
30206
+ throw new WriteAfterEndError();
30207
+ }
30208
+
30209
+ // Validate input and shift parameters if necessary
30210
+ if (!isString(data) && !isBuffer(data)) {
30211
+ throw new TypeError("data should be a string, Buffer or Uint8Array");
30212
+ }
30213
+ if (isFunction(encoding)) {
30214
+ callback = encoding;
30215
+ encoding = null;
30216
+ }
30217
+
30218
+ // Ignore empty buffers, since writing them doesn't invoke the callback
30219
+ // https://github.com/nodejs/node/issues/22066
30220
+ if (data.length === 0) {
30221
+ if (callback) {
30222
+ callback();
30223
+ }
30224
+ return;
30225
+ }
30226
+ // Only write when we don't exceed the maximum body length
30227
+ if (this._requestBodyLength + data.length <= this._options.maxBodyLength) {
30228
+ this._requestBodyLength += data.length;
30229
+ this._requestBodyBuffers.push({ data: data, encoding: encoding });
30230
+ this._currentRequest.write(data, encoding, callback);
30231
+ }
30232
+ // Error when we exceed the maximum body length
30233
+ else {
30234
+ this.emit("error", new MaxBodyLengthExceededError());
30235
+ this.abort();
30236
+ }
30237
+ };
30238
+
30239
+ // Ends the current native request
30240
+ RedirectableRequest.prototype.end = function (data, encoding, callback) {
30241
+ // Shift parameters if necessary
30242
+ if (isFunction(data)) {
30243
+ callback = data;
30244
+ data = encoding = null;
30245
+ }
30246
+ else if (isFunction(encoding)) {
30247
+ callback = encoding;
30248
+ encoding = null;
30249
+ }
30250
+
30251
+ // Write data if needed and end
30252
+ if (!data) {
30253
+ this._ended = this._ending = true;
30254
+ this._currentRequest.end(null, null, callback);
30255
+ }
30256
+ else {
30257
+ var self = this;
30258
+ var currentRequest = this._currentRequest;
30259
+ this.write(data, encoding, function () {
30260
+ self._ended = true;
30261
+ currentRequest.end(null, null, callback);
30262
+ });
30263
+ this._ending = true;
30264
+ }
30265
+ };
30266
+
30267
+ // Sets a header value on the current native request
30268
+ RedirectableRequest.prototype.setHeader = function (name, value) {
30269
+ this._options.headers[name] = value;
30270
+ this._currentRequest.setHeader(name, value);
30271
+ };
30272
+
30273
+ // Clears a header value on the current native request
30274
+ RedirectableRequest.prototype.removeHeader = function (name) {
30275
+ delete this._options.headers[name];
30276
+ this._currentRequest.removeHeader(name);
30277
+ };
30278
+
30279
+ // Global timeout for all underlying requests
30280
+ RedirectableRequest.prototype.setTimeout = function (msecs, callback) {
30281
+ var self = this;
30282
+
30283
+ // Destroys the socket on timeout
30284
+ function destroyOnTimeout(socket) {
30285
+ socket.setTimeout(msecs);
30286
+ socket.removeListener("timeout", socket.destroy);
30287
+ socket.addListener("timeout", socket.destroy);
30288
+ }
30289
+
30290
+ // Sets up a timer to trigger a timeout event
30291
+ function startTimer(socket) {
30292
+ if (self._timeout) {
30293
+ clearTimeout(self._timeout);
30294
+ }
30295
+ self._timeout = setTimeout(function () {
30296
+ self.emit("timeout");
30297
+ clearTimer();
30298
+ }, msecs);
30299
+ destroyOnTimeout(socket);
30300
+ }
30301
+
30302
+ // Stops a timeout from triggering
30303
+ function clearTimer() {
30304
+ // Clear the timeout
30305
+ if (self._timeout) {
30306
+ clearTimeout(self._timeout);
30307
+ self._timeout = null;
30308
+ }
30309
+
30310
+ // Clean up all attached listeners
30311
+ self.removeListener("abort", clearTimer);
30312
+ self.removeListener("error", clearTimer);
30313
+ self.removeListener("response", clearTimer);
30314
+ if (callback) {
30315
+ self.removeListener("timeout", callback);
30316
+ }
30317
+ if (!self.socket) {
30318
+ self._currentRequest.removeListener("socket", startTimer);
30319
+ }
30320
+ }
30321
+
30322
+ // Attach callback if passed
30323
+ if (callback) {
30324
+ this.on("timeout", callback);
30325
+ }
30326
+
30327
+ // Start the timer if or when the socket is opened
30328
+ if (this.socket) {
30329
+ startTimer(this.socket);
30330
+ }
30331
+ else {
30332
+ this._currentRequest.once("socket", startTimer);
30333
+ }
30334
+
30335
+ // Clean up on events
30336
+ this.on("socket", destroyOnTimeout);
30337
+ this.on("abort", clearTimer);
30338
+ this.on("error", clearTimer);
30339
+ this.on("response", clearTimer);
30340
+
30341
+ return this;
30342
+ };
30343
+
30344
+ // Proxy all other public ClientRequest methods
30345
+ [
30346
+ "flushHeaders", "getHeader",
30347
+ "setNoDelay", "setSocketKeepAlive",
30348
+ ].forEach(function (method) {
30349
+ RedirectableRequest.prototype[method] = function (a, b) {
30350
+ return this._currentRequest[method](a, b);
30351
+ };
30352
+ });
30353
+
30354
+ // Proxy all public ClientRequest properties
30355
+ ["aborted", "connection", "socket"].forEach(function (property) {
30356
+ Object.defineProperty(RedirectableRequest.prototype, property, {
30357
+ get: function () { return this._currentRequest[property]; },
30358
+ });
30359
+ });
30360
+
30361
+ RedirectableRequest.prototype._sanitizeOptions = function (options) {
30362
+ // Ensure headers are always present
30363
+ if (!options.headers) {
30364
+ options.headers = {};
30365
+ }
30366
+
30367
+ // Since http.request treats host as an alias of hostname,
30368
+ // but the url module interprets host as hostname plus port,
30369
+ // eliminate the host property to avoid confusion.
30370
+ if (options.host) {
30371
+ // Use hostname if set, because it has precedence
30372
+ if (!options.hostname) {
30373
+ options.hostname = options.host;
30374
+ }
30375
+ delete options.host;
30376
+ }
30377
+
30378
+ // Complete the URL object when necessary
30379
+ if (!options.pathname && options.path) {
30380
+ var searchPos = options.path.indexOf("?");
30381
+ if (searchPos < 0) {
30382
+ options.pathname = options.path;
30383
+ }
30384
+ else {
30385
+ options.pathname = options.path.substring(0, searchPos);
30386
+ options.search = options.path.substring(searchPos);
30387
+ }
30388
+ }
30389
+ };
30390
+
30391
+
30392
+ // Executes the next native request (initial or redirect)
30393
+ RedirectableRequest.prototype._performRequest = function () {
30394
+ // Load the native protocol
30395
+ var protocol = this._options.protocol;
30396
+ var nativeProtocol = this._options.nativeProtocols[protocol];
30397
+ if (!nativeProtocol) {
30398
+ this.emit("error", new TypeError("Unsupported protocol " + protocol));
30399
+ return;
30400
+ }
30401
+
30402
+ // If specified, use the agent corresponding to the protocol
30403
+ // (HTTP and HTTPS use different types of agents)
30404
+ if (this._options.agents) {
30405
+ var scheme = protocol.slice(0, -1);
30406
+ this._options.agent = this._options.agents[scheme];
30407
+ }
30408
+
30409
+ // Create the native request and set up its event handlers
30410
+ var request = this._currentRequest =
30411
+ nativeProtocol.request(this._options, this._onNativeResponse);
30412
+ request._redirectable = this;
30413
+ for (var event of events) {
30414
+ request.on(event, eventHandlers[event]);
30415
+ }
30416
+
30417
+ // RFC7230§5.3.1: When making a request directly to an origin server, […]
30418
+ // a client MUST send only the absolute path […] as the request-target.
30419
+ this._currentUrl = /^\//.test(this._options.path) ?
30420
+ url$1.format(this._options) :
30421
+ // When making a request to a proxy, […]
30422
+ // a client MUST send the target URI in absolute-form […].
30423
+ this._options.path;
30424
+
30425
+ // End a redirected request
30426
+ // (The first request must be ended explicitly with RedirectableRequest#end)
30427
+ if (this._isRedirect) {
30428
+ // Write the request entity and end
30429
+ var i = 0;
30430
+ var self = this;
30431
+ var buffers = this._requestBodyBuffers;
30432
+ (function writeNext(error) {
30433
+ // Only write if this request has not been redirected yet
30434
+ /* istanbul ignore else */
30435
+ if (request === self._currentRequest) {
30436
+ // Report any write errors
30437
+ /* istanbul ignore if */
30438
+ if (error) {
30439
+ self.emit("error", error);
30440
+ }
30441
+ // Write the next buffer if there are still left
30442
+ else if (i < buffers.length) {
30443
+ var buffer = buffers[i++];
30444
+ /* istanbul ignore else */
30445
+ if (!request.finished) {
30446
+ request.write(buffer.data, buffer.encoding, writeNext);
30447
+ }
30448
+ }
30449
+ // End the request if `end` has been called on us
30450
+ else if (self._ended) {
30451
+ request.end();
30452
+ }
30453
+ }
30454
+ }());
30455
+ }
30456
+ };
30457
+
30458
+ // Processes a response from the current native request
30459
+ RedirectableRequest.prototype._processResponse = function (response) {
30460
+ // Store the redirected response
30461
+ var statusCode = response.statusCode;
30462
+ if (this._options.trackRedirects) {
30463
+ this._redirects.push({
30464
+ url: this._currentUrl,
30465
+ headers: response.headers,
30466
+ statusCode: statusCode,
30467
+ });
30468
+ }
30469
+
30470
+ // RFC7231§6.4: The 3xx (Redirection) class of status code indicates
30471
+ // that further action needs to be taken by the user agent in order to
30472
+ // fulfill the request. If a Location header field is provided,
30473
+ // the user agent MAY automatically redirect its request to the URI
30474
+ // referenced by the Location field value,
30475
+ // even if the specific status code is not understood.
30476
+
30477
+ // If the response is not a redirect; return it as-is
30478
+ var location = response.headers.location;
30479
+ if (!location || this._options.followRedirects === false ||
30480
+ statusCode < 300 || statusCode >= 400) {
30481
+ response.responseUrl = this._currentUrl;
30482
+ response.redirects = this._redirects;
30483
+ this.emit("response", response);
30484
+
30485
+ // Clean up
30486
+ this._requestBodyBuffers = [];
30487
+ return;
30488
+ }
30489
+
30490
+ // The response is a redirect, so abort the current request
30491
+ abortRequest(this._currentRequest);
30492
+ // Discard the remainder of the response to avoid waiting for data
30493
+ response.destroy();
30494
+
30495
+ // RFC7231§6.4: A client SHOULD detect and intervene
30496
+ // in cyclical redirections (i.e., "infinite" redirection loops).
30497
+ if (++this._redirectCount > this._options.maxRedirects) {
30498
+ this.emit("error", new TooManyRedirectsError());
30499
+ return;
30500
+ }
30501
+
30502
+ // Store the request headers if applicable
30503
+ var requestHeaders;
30504
+ var beforeRedirect = this._options.beforeRedirect;
30505
+ if (beforeRedirect) {
30506
+ requestHeaders = Object.assign({
30507
+ // The Host header was set by nativeProtocol.request
30508
+ Host: response.req.getHeader("host"),
30509
+ }, this._options.headers);
30510
+ }
30511
+
30512
+ // RFC7231§6.4: Automatic redirection needs to done with
30513
+ // care for methods not known to be safe, […]
30514
+ // RFC7231§6.4.2–3: For historical reasons, a user agent MAY change
30515
+ // the request method from POST to GET for the subsequent request.
30516
+ var method = this._options.method;
30517
+ if ((statusCode === 301 || statusCode === 302) && this._options.method === "POST" ||
30518
+ // RFC7231§6.4.4: The 303 (See Other) status code indicates that
30519
+ // the server is redirecting the user agent to a different resource […]
30520
+ // A user agent can perform a retrieval request targeting that URI
30521
+ // (a GET or HEAD request if using HTTP) […]
30522
+ (statusCode === 303) && !/^(?:GET|HEAD)$/.test(this._options.method)) {
30523
+ this._options.method = "GET";
30524
+ // Drop a possible entity and headers related to it
30525
+ this._requestBodyBuffers = [];
30526
+ removeMatchingHeaders(/^content-/i, this._options.headers);
30527
+ }
30528
+
30529
+ // Drop the Host header, as the redirect might lead to a different host
30530
+ var currentHostHeader = removeMatchingHeaders(/^host$/i, this._options.headers);
30531
+
30532
+ // If the redirect is relative, carry over the host of the last request
30533
+ var currentUrlParts = url$1.parse(this._currentUrl);
30534
+ var currentHost = currentHostHeader || currentUrlParts.host;
30535
+ var currentUrl = /^\w+:/.test(location) ? this._currentUrl :
30536
+ url$1.format(Object.assign(currentUrlParts, { host: currentHost }));
30537
+
30538
+ // Determine the URL of the redirection
30539
+ var redirectUrl;
30540
+ try {
30541
+ redirectUrl = url$1.resolve(currentUrl, location);
30542
+ }
30543
+ catch (cause) {
30544
+ this.emit("error", new RedirectionError({ cause: cause }));
30545
+ return;
30546
+ }
30547
+
30548
+ // Create the redirected request
30549
+ debug("redirecting to", redirectUrl);
30550
+ this._isRedirect = true;
30551
+ var redirectUrlParts = url$1.parse(redirectUrl);
30552
+ Object.assign(this._options, redirectUrlParts);
30553
+
30554
+ // Drop confidential headers when redirecting to a less secure protocol
30555
+ // or to a different domain that is not a superdomain
30556
+ if (redirectUrlParts.protocol !== currentUrlParts.protocol &&
30557
+ redirectUrlParts.protocol !== "https:" ||
30558
+ redirectUrlParts.host !== currentHost &&
30559
+ !isSubdomain(redirectUrlParts.host, currentHost)) {
30560
+ removeMatchingHeaders(/^(?:authorization|cookie)$/i, this._options.headers);
30561
+ }
30562
+
30563
+ // Evaluate the beforeRedirect callback
30564
+ if (isFunction(beforeRedirect)) {
30565
+ var responseDetails = {
30566
+ headers: response.headers,
30567
+ statusCode: statusCode,
30568
+ };
30569
+ var requestDetails = {
30570
+ url: currentUrl,
30571
+ method: method,
30572
+ headers: requestHeaders,
30573
+ };
30574
+ try {
30575
+ beforeRedirect(this._options, responseDetails, requestDetails);
30576
+ }
30577
+ catch (err) {
30578
+ this.emit("error", err);
30579
+ return;
30580
+ }
30581
+ this._sanitizeOptions(this._options);
30582
+ }
30583
+
30584
+ // Perform the redirected request
30585
+ try {
30586
+ this._performRequest();
30587
+ }
30588
+ catch (cause) {
30589
+ this.emit("error", new RedirectionError({ cause: cause }));
30590
+ }
30591
+ };
30592
+
30593
+ // Wraps the key/value object of protocols with redirect functionality
30594
+ function wrap(protocols) {
30595
+ // Default settings
30596
+ var exports = {
30597
+ maxRedirects: 21,
30598
+ maxBodyLength: 10 * 1024 * 1024,
30599
+ };
30600
+
30601
+ // Wrap each protocol
30602
+ var nativeProtocols = {};
30603
+ Object.keys(protocols).forEach(function (scheme) {
30604
+ var protocol = scheme + ":";
30605
+ var nativeProtocol = nativeProtocols[protocol] = protocols[scheme];
30606
+ var wrappedProtocol = exports[scheme] = Object.create(nativeProtocol);
30607
+
30608
+ // Executes a request, following redirects
30609
+ function request(input, options, callback) {
30610
+ // Parse parameters
30611
+ if (isString(input)) {
30612
+ var parsed;
30613
+ try {
30614
+ parsed = urlToOptions(new URL(input));
30615
+ }
30616
+ catch (err) {
30617
+ /* istanbul ignore next */
30618
+ parsed = url$1.parse(input);
30619
+ }
30620
+ if (!isString(parsed.protocol)) {
30621
+ throw new InvalidUrlError({ input });
30622
+ }
30623
+ input = parsed;
30624
+ }
30625
+ else if (URL && (input instanceof URL)) {
30626
+ input = urlToOptions(input);
30627
+ }
30628
+ else {
30629
+ callback = options;
30630
+ options = input;
30631
+ input = { protocol: protocol };
30632
+ }
30633
+ if (isFunction(options)) {
30634
+ callback = options;
30635
+ options = null;
30636
+ }
30637
+
30638
+ // Set defaults
30639
+ options = Object.assign({
30640
+ maxRedirects: exports.maxRedirects,
30641
+ maxBodyLength: exports.maxBodyLength,
30642
+ }, input, options);
30643
+ options.nativeProtocols = nativeProtocols;
30644
+ if (!isString(options.host) && !isString(options.hostname)) {
30645
+ options.hostname = "::1";
30646
+ }
30647
+
30648
+ assert.equal(options.protocol, protocol, "protocol mismatch");
30649
+ debug("options", options);
30650
+ return new RedirectableRequest(options, callback);
30651
+ }
30652
+
30653
+ // Executes a GET request, following redirects
30654
+ function get(input, options, callback) {
30655
+ var wrappedRequest = wrappedProtocol.request(input, options, callback);
30656
+ wrappedRequest.end();
30657
+ return wrappedRequest;
30658
+ }
30659
+
30660
+ // Expose the properties on the wrapped protocol
30661
+ Object.defineProperties(wrappedProtocol, {
30662
+ request: { value: request, configurable: true, enumerable: true, writable: true },
30663
+ get: { value: get, configurable: true, enumerable: true, writable: true },
30664
+ });
30665
+ });
30666
+ return exports;
30667
+ }
30668
+
30669
+ /* istanbul ignore next */
30670
+ function noop() { /* empty */ }
30671
+
30672
+ // from https://github.com/nodejs/node/blob/master/lib/internal/url.js
30673
+ function urlToOptions(urlObject) {
30674
+ var options = {
30675
+ protocol: urlObject.protocol,
30676
+ hostname: urlObject.hostname.startsWith("[") ?
30677
+ /* istanbul ignore next */
30678
+ urlObject.hostname.slice(1, -1) :
30679
+ urlObject.hostname,
30680
+ hash: urlObject.hash,
30681
+ search: urlObject.search,
30682
+ pathname: urlObject.pathname,
30683
+ path: urlObject.pathname + urlObject.search,
30684
+ href: urlObject.href,
30685
+ };
30686
+ if (urlObject.port !== "") {
30687
+ options.port = Number(urlObject.port);
30688
+ }
30689
+ return options;
30690
+ }
30691
+
30692
+ function removeMatchingHeaders(regex, headers) {
30693
+ var lastValue;
30694
+ for (var header in headers) {
30695
+ if (regex.test(header)) {
30696
+ lastValue = headers[header];
30697
+ delete headers[header];
30698
+ }
30699
+ }
30700
+ return (lastValue === null || typeof lastValue === "undefined") ?
30701
+ undefined : String(lastValue).trim();
30702
+ }
30703
+
30704
+ function createErrorType(code, message, baseClass) {
30705
+ // Create constructor
30706
+ function CustomError(properties) {
30707
+ Error.captureStackTrace(this, this.constructor);
30708
+ Object.assign(this, properties || {});
30709
+ this.code = code;
30710
+ this.message = this.cause ? message + ": " + this.cause.message : message;
30711
+ }
30712
+
30713
+ // Attach constructor and set default properties
30714
+ CustomError.prototype = new (baseClass || Error)();
30715
+ CustomError.prototype.constructor = CustomError;
30716
+ CustomError.prototype.name = "Error [" + code + "]";
30717
+ return CustomError;
30718
+ }
30719
+
30720
+ function abortRequest(request) {
30721
+ for (var event of events) {
30722
+ request.removeListener(event, eventHandlers[event]);
30723
+ }
30724
+ request.on("error", noop);
30725
+ request.abort();
30726
+ }
30727
+
30728
+ function isSubdomain(subdomain, domain) {
30729
+ assert(isString(subdomain) && isString(domain));
30730
+ var dot = subdomain.length - domain.length - 1;
30731
+ return dot > 0 && subdomain[dot] === "." && subdomain.endsWith(domain);
30732
+ }
30733
+
30734
+ function isString(value) {
30735
+ return typeof value === "string" || value instanceof String;
30736
+ }
30737
+
30738
+ function isFunction(value) {
30739
+ return typeof value === "function";
30740
+ }
30741
+
30742
+ function isBuffer(value) {
30743
+ return typeof value === "object" && ("length" in value);
30744
+ }
30745
+
30746
+ // Exports
30747
+ followRedirects.exports = wrap({ http: http$1, https: https$1 });
30748
+ followRedirects.exports.wrap = wrap;
30749
+
30750
+ var data = {
30751
+ "version": "0.26.1"
30752
+ };
30753
+
30754
+ var utils$7 = utils$f;
30755
+ var settle = settle$2;
30756
+ var buildFullPath = buildFullPath$2;
30757
+ var buildURL$1 = buildURL$3;
30758
+ var http = require$$1;
30759
+ var https = require$$2$1;
30760
+ var httpFollow = followRedirects.exports.http;
30761
+ var httpsFollow = followRedirects.exports.https;
30762
+ var url = require$$0;
30763
+ var zlib = require$$8;
30764
+ var VERSION$1 = data.version;
30765
+ var createError = createError$3;
30766
+ var enhanceError$1 = enhanceError$3;
30767
+ var transitionalDefaults$1 = transitional;
30768
+ var Cancel$2 = Cancel_1;
30769
+
30770
+ var isHttps = /https:?/;
30771
+
30772
+ /**
30773
+ *
30774
+ * @param {http.ClientRequestArgs} options
30775
+ * @param {AxiosProxyConfig} proxy
30776
+ * @param {string} location
30777
+ */
30778
+ function setProxy(options, proxy, location) {
30779
+ options.hostname = proxy.host;
30780
+ options.host = proxy.host;
30781
+ options.port = proxy.port;
30782
+ options.path = location;
30783
+
30784
+ // Basic proxy authorization
30785
+ if (proxy.auth) {
30786
+ var base64 = Buffer.from(proxy.auth.username + ':' + proxy.auth.password, 'utf8').toString('base64');
30787
+ options.headers['Proxy-Authorization'] = 'Basic ' + base64;
30788
+ }
30789
+
30790
+ // If a proxy is used, any redirects must also pass through the proxy
30791
+ options.beforeRedirect = function beforeRedirect(redirection) {
30792
+ redirection.headers.host = redirection.host;
30793
+ setProxy(redirection, proxy, redirection.href);
30794
+ };
30795
+ }
30796
+
30797
+ /*eslint consistent-return:0*/
30798
+ var http_1 = function httpAdapter(config) {
30799
+ return new Promise(function dispatchHttpRequest(resolvePromise, rejectPromise) {
30800
+ var onCanceled;
30801
+ function done() {
30802
+ if (config.cancelToken) {
30803
+ config.cancelToken.unsubscribe(onCanceled);
30804
+ }
30805
+
30806
+ if (config.signal) {
30807
+ config.signal.removeEventListener('abort', onCanceled);
30808
+ }
30809
+ }
30810
+ var resolve = function resolve(value) {
30811
+ done();
30812
+ resolvePromise(value);
30813
+ };
30814
+ var rejected = false;
30815
+ var reject = function reject(value) {
30816
+ done();
30817
+ rejected = true;
30818
+ rejectPromise(value);
30819
+ };
30820
+ var data = config.data;
30821
+ var headers = config.headers;
30822
+ var headerNames = {};
30823
+
30824
+ Object.keys(headers).forEach(function storeLowerName(name) {
30825
+ headerNames[name.toLowerCase()] = name;
30826
+ });
30827
+
30828
+ // Set User-Agent (required by some servers)
30829
+ // See https://github.com/axios/axios/issues/69
30830
+ if ('user-agent' in headerNames) {
30831
+ // User-Agent is specified; handle case where no UA header is desired
30832
+ if (!headers[headerNames['user-agent']]) {
30833
+ delete headers[headerNames['user-agent']];
30834
+ }
30835
+ // Otherwise, use specified value
30836
+ } else {
30837
+ // Only set header if it hasn't been set in config
30838
+ headers['User-Agent'] = 'axios/' + VERSION$1;
30839
+ }
30840
+
30841
+ if (data && !utils$7.isStream(data)) {
30842
+ if (Buffer.isBuffer(data)) ; else if (utils$7.isArrayBuffer(data)) {
30843
+ data = Buffer.from(new Uint8Array(data));
30844
+ } else if (utils$7.isString(data)) {
30845
+ data = Buffer.from(data, 'utf-8');
30846
+ } else {
30847
+ return reject(createError(
30848
+ 'Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream',
30849
+ config
30850
+ ));
30851
+ }
30852
+
30853
+ if (config.maxBodyLength > -1 && data.length > config.maxBodyLength) {
30854
+ return reject(createError('Request body larger than maxBodyLength limit', config));
30855
+ }
30856
+
30857
+ // Add Content-Length header if data exists
30858
+ if (!headerNames['content-length']) {
30859
+ headers['Content-Length'] = data.length;
30860
+ }
30861
+ }
30862
+
30863
+ // HTTP basic authentication
30864
+ var auth = undefined;
30865
+ if (config.auth) {
30866
+ var username = config.auth.username || '';
30867
+ var password = config.auth.password || '';
30868
+ auth = username + ':' + password;
30869
+ }
30870
+
30871
+ // Parse url
30872
+ var fullPath = buildFullPath(config.baseURL, config.url);
30873
+ var parsed = url.parse(fullPath);
30874
+ var protocol = parsed.protocol || 'http:';
30875
+
30876
+ if (!auth && parsed.auth) {
30877
+ var urlAuth = parsed.auth.split(':');
30878
+ var urlUsername = urlAuth[0] || '';
30879
+ var urlPassword = urlAuth[1] || '';
30880
+ auth = urlUsername + ':' + urlPassword;
30881
+ }
30882
+
30883
+ if (auth && headerNames.authorization) {
30884
+ delete headers[headerNames.authorization];
30885
+ }
30886
+
30887
+ var isHttpsRequest = isHttps.test(protocol);
30888
+ var agent = isHttpsRequest ? config.httpsAgent : config.httpAgent;
30889
+
30890
+ try {
30891
+ buildURL$1(parsed.path, config.params, config.paramsSerializer).replace(/^\?/, '');
30892
+ } catch (err) {
30893
+ var customErr = new Error(err.message);
30894
+ customErr.config = config;
30895
+ customErr.url = config.url;
30896
+ customErr.exists = true;
30897
+ reject(customErr);
30898
+ }
30899
+
30900
+ var options = {
30901
+ path: buildURL$1(parsed.path, config.params, config.paramsSerializer).replace(/^\?/, ''),
30902
+ method: config.method.toUpperCase(),
30903
+ headers: headers,
30904
+ agent: agent,
30905
+ agents: { http: config.httpAgent, https: config.httpsAgent },
30906
+ auth: auth
30907
+ };
30908
+
30909
+ if (config.socketPath) {
30910
+ options.socketPath = config.socketPath;
30911
+ } else {
30912
+ options.hostname = parsed.hostname;
30913
+ options.port = parsed.port;
30914
+ }
30915
+
30916
+ var proxy = config.proxy;
30917
+ if (!proxy && proxy !== false) {
30918
+ var proxyEnv = protocol.slice(0, -1) + '_proxy';
30919
+ var proxyUrl = process.env[proxyEnv] || process.env[proxyEnv.toUpperCase()];
30920
+ if (proxyUrl) {
30921
+ var parsedProxyUrl = url.parse(proxyUrl);
30922
+ var noProxyEnv = process.env.no_proxy || process.env.NO_PROXY;
30923
+ var shouldProxy = true;
30924
+
30925
+ if (noProxyEnv) {
30926
+ var noProxy = noProxyEnv.split(',').map(function trim(s) {
30927
+ return s.trim();
30928
+ });
30929
+
30930
+ shouldProxy = !noProxy.some(function proxyMatch(proxyElement) {
30931
+ if (!proxyElement) {
30932
+ return false;
30933
+ }
30934
+ if (proxyElement === '*') {
30935
+ return true;
30936
+ }
30937
+ if (proxyElement[0] === '.' &&
30938
+ parsed.hostname.substr(parsed.hostname.length - proxyElement.length) === proxyElement) {
30939
+ return true;
30940
+ }
30941
+
30942
+ return parsed.hostname === proxyElement;
30943
+ });
30944
+ }
30945
+
30946
+ if (shouldProxy) {
30947
+ proxy = {
30948
+ host: parsedProxyUrl.hostname,
30949
+ port: parsedProxyUrl.port,
30950
+ protocol: parsedProxyUrl.protocol
30951
+ };
30952
+
30953
+ if (parsedProxyUrl.auth) {
30954
+ var proxyUrlAuth = parsedProxyUrl.auth.split(':');
30955
+ proxy.auth = {
30956
+ username: proxyUrlAuth[0],
30957
+ password: proxyUrlAuth[1]
30958
+ };
30959
+ }
30960
+ }
30961
+ }
30962
+ }
30963
+
30964
+ if (proxy) {
30965
+ options.headers.host = parsed.hostname + (parsed.port ? ':' + parsed.port : '');
30966
+ setProxy(options, proxy, protocol + '//' + parsed.hostname + (parsed.port ? ':' + parsed.port : '') + options.path);
30967
+ }
30968
+
30969
+ var transport;
30970
+ var isHttpsProxy = isHttpsRequest && (proxy ? isHttps.test(proxy.protocol) : true);
30971
+ if (config.transport) {
30972
+ transport = config.transport;
30973
+ } else if (config.maxRedirects === 0) {
30974
+ transport = isHttpsProxy ? https : http;
30975
+ } else {
30976
+ if (config.maxRedirects) {
30977
+ options.maxRedirects = config.maxRedirects;
30978
+ }
30979
+ transport = isHttpsProxy ? httpsFollow : httpFollow;
30980
+ }
30981
+
30982
+ if (config.maxBodyLength > -1) {
30983
+ options.maxBodyLength = config.maxBodyLength;
30984
+ }
30985
+
30986
+ if (config.insecureHTTPParser) {
30987
+ options.insecureHTTPParser = config.insecureHTTPParser;
30988
+ }
30989
+
30990
+ // Create the request
30991
+ var req = transport.request(options, function handleResponse(res) {
30992
+ if (req.aborted) return;
30993
+
30994
+ // uncompress the response body transparently if required
30995
+ var stream = res;
30996
+
30997
+ // return the last request in case of redirects
30998
+ var lastRequest = res.req || req;
30999
+
31000
+
31001
+ // if no content, is HEAD request or decompress disabled we should not decompress
31002
+ if (res.statusCode !== 204 && lastRequest.method !== 'HEAD' && config.decompress !== false) {
31003
+ switch (res.headers['content-encoding']) {
31004
+ /*eslint default-case:0*/
31005
+ case 'gzip':
31006
+ case 'compress':
31007
+ case 'deflate':
31008
+ // add the unzipper to the body stream processing pipeline
31009
+ stream = stream.pipe(zlib.createUnzip());
31010
+
31011
+ // remove the content-encoding in order to not confuse downstream operations
31012
+ delete res.headers['content-encoding'];
31013
+ break;
31014
+ }
31015
+ }
31016
+
31017
+ var response = {
31018
+ status: res.statusCode,
31019
+ statusText: res.statusMessage,
31020
+ headers: res.headers,
31021
+ config: config,
31022
+ request: lastRequest
31023
+ };
31024
+
31025
+ if (config.responseType === 'stream') {
31026
+ response.data = stream;
31027
+ settle(resolve, reject, response);
31028
+ } else {
31029
+ var responseBuffer = [];
31030
+ var totalResponseBytes = 0;
31031
+ stream.on('data', function handleStreamData(chunk) {
31032
+ responseBuffer.push(chunk);
31033
+ totalResponseBytes += chunk.length;
31034
+
31035
+ // make sure the content length is not over the maxContentLength if specified
31036
+ if (config.maxContentLength > -1 && totalResponseBytes > config.maxContentLength) {
31037
+ // stream.destoy() emit aborted event before calling reject() on Node.js v16
31038
+ rejected = true;
31039
+ stream.destroy();
31040
+ reject(createError('maxContentLength size of ' + config.maxContentLength + ' exceeded',
31041
+ config, null, lastRequest));
31042
+ }
31043
+ });
31044
+
31045
+ stream.on('aborted', function handlerStreamAborted() {
31046
+ if (rejected) {
31047
+ return;
31048
+ }
31049
+ stream.destroy();
31050
+ reject(createError('error request aborted', config, 'ERR_REQUEST_ABORTED', lastRequest));
31051
+ });
31052
+
31053
+ stream.on('error', function handleStreamError(err) {
31054
+ if (req.aborted) return;
31055
+ reject(enhanceError$1(err, config, null, lastRequest));
31056
+ });
31057
+
31058
+ stream.on('end', function handleStreamEnd() {
31059
+ try {
31060
+ var responseData = responseBuffer.length === 1 ? responseBuffer[0] : Buffer.concat(responseBuffer);
31061
+ if (config.responseType !== 'arraybuffer') {
31062
+ responseData = responseData.toString(config.responseEncoding);
31063
+ if (!config.responseEncoding || config.responseEncoding === 'utf8') {
31064
+ responseData = utils$7.stripBOM(responseData);
31065
+ }
31066
+ }
31067
+ response.data = responseData;
31068
+ } catch (err) {
31069
+ reject(enhanceError$1(err, config, err.code, response.request, response));
31070
+ }
31071
+ settle(resolve, reject, response);
31072
+ });
31073
+ }
31074
+ });
31075
+
31076
+ // Handle errors
31077
+ req.on('error', function handleRequestError(err) {
31078
+ if (req.aborted && err.code !== 'ERR_FR_TOO_MANY_REDIRECTS') return;
31079
+ reject(enhanceError$1(err, config, null, req));
31080
+ });
31081
+
31082
+ // set tcp keep alive to prevent drop connection by peer
31083
+ req.on('socket', function handleRequestSocket(socket) {
31084
+ // default interval of sending ack packet is 1 minute
31085
+ socket.setKeepAlive(true, 1000 * 60);
31086
+ });
31087
+
31088
+ // Handle request timeout
31089
+ if (config.timeout) {
31090
+ // This is forcing a int timeout to avoid problems if the `req` interface doesn't handle other types.
31091
+ var timeout = parseInt(config.timeout, 10);
31092
+
31093
+ if (isNaN(timeout)) {
31094
+ reject(createError(
31095
+ 'error trying to parse `config.timeout` to int',
31096
+ config,
31097
+ 'ERR_PARSE_TIMEOUT',
31098
+ req
31099
+ ));
31100
+
31101
+ return;
31102
+ }
31103
+
31104
+ // Sometime, the response will be very slow, and does not respond, the connect event will be block by event loop system.
31105
+ // And timer callback will be fired, and abort() will be invoked before connection, then get "socket hang up" and code ECONNRESET.
31106
+ // At this time, if we have a large number of request, nodejs will hang up some socket on background. and the number will up and up.
31107
+ // And then these socket which be hang up will devoring CPU little by little.
31108
+ // ClientRequest.setTimeout will be fired on the specify milliseconds, and can make sure that abort() will be fired after connect.
31109
+ req.setTimeout(timeout, function handleRequestTimeout() {
31110
+ req.abort();
31111
+ var timeoutErrorMessage = '';
31112
+ if (config.timeoutErrorMessage) {
31113
+ timeoutErrorMessage = config.timeoutErrorMessage;
31114
+ } else {
31115
+ timeoutErrorMessage = 'timeout of ' + config.timeout + 'ms exceeded';
31116
+ }
31117
+ var transitional = config.transitional || transitionalDefaults$1;
31118
+ reject(createError(
31119
+ timeoutErrorMessage,
31120
+ config,
31121
+ transitional.clarifyTimeoutError ? 'ETIMEDOUT' : 'ECONNABORTED',
31122
+ req
31123
+ ));
31124
+ });
31125
+ }
31126
+
31127
+ if (config.cancelToken || config.signal) {
31128
+ // Handle cancellation
31129
+ // eslint-disable-next-line func-names
31130
+ onCanceled = function(cancel) {
31131
+ if (req.aborted) return;
31132
+
31133
+ req.abort();
31134
+ reject(!cancel || (cancel && cancel.type) ? new Cancel$2('canceled') : cancel);
31135
+ };
31136
+
31137
+ config.cancelToken && config.cancelToken.subscribe(onCanceled);
31138
+ if (config.signal) {
31139
+ config.signal.aborted ? onCanceled() : config.signal.addEventListener('abort', onCanceled);
31140
+ }
31141
+ }
31142
+
31143
+
31144
+ // Send the request
31145
+ if (utils$7.isStream(data)) {
31146
+ data.on('error', function handleStreamError(err) {
31147
+ reject(enhanceError$1(err, config, null, req));
31148
+ }).pipe(req);
31149
+ } else {
31150
+ req.end(data);
31151
+ }
31152
+ });
31153
+ };
31154
+
31155
+ var utils$6 = utils$f;
31156
+ var normalizeHeaderName = normalizeHeaderName$1;
31157
+ var enhanceError = enhanceError$3;
31158
+ var transitionalDefaults = transitional;
31159
+
31160
+ var DEFAULT_CONTENT_TYPE = {
31161
+ 'Content-Type': 'application/x-www-form-urlencoded'
31162
+ };
31163
+
31164
+ function setContentTypeIfUnset(headers, value) {
31165
+ if (!utils$6.isUndefined(headers) && utils$6.isUndefined(headers['Content-Type'])) {
31166
+ headers['Content-Type'] = value;
31167
+ }
31168
+ }
31169
+
31170
+ function getDefaultAdapter() {
31171
+ var adapter;
31172
+ if (typeof XMLHttpRequest !== 'undefined') {
31173
+ // For browsers use XHR adapter
31174
+ adapter = xhr;
31175
+ } else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {
31176
+ // For node use HTTP adapter
31177
+ adapter = http_1;
31178
+ }
31179
+ return adapter;
31180
+ }
31181
+
31182
+ function stringifySafely(rawValue, parser, encoder) {
31183
+ if (utils$6.isString(rawValue)) {
31184
+ try {
31185
+ (parser || JSON.parse)(rawValue);
31186
+ return utils$6.trim(rawValue);
31187
+ } catch (e) {
31188
+ if (e.name !== 'SyntaxError') {
31189
+ throw e;
31190
+ }
31191
+ }
31192
+ }
31193
+
31194
+ return (encoder || JSON.stringify)(rawValue);
31195
+ }
31196
+
31197
+ var defaults$3 = {
31198
+
31199
+ transitional: transitionalDefaults,
31200
+
31201
+ adapter: getDefaultAdapter(),
31202
+
31203
+ transformRequest: [function transformRequest(data, headers) {
31204
+ normalizeHeaderName(headers, 'Accept');
31205
+ normalizeHeaderName(headers, 'Content-Type');
31206
+
31207
+ if (utils$6.isFormData(data) ||
31208
+ utils$6.isArrayBuffer(data) ||
31209
+ utils$6.isBuffer(data) ||
31210
+ utils$6.isStream(data) ||
31211
+ utils$6.isFile(data) ||
31212
+ utils$6.isBlob(data)
31213
+ ) {
31214
+ return data;
31215
+ }
31216
+ if (utils$6.isArrayBufferView(data)) {
31217
+ return data.buffer;
31218
+ }
31219
+ if (utils$6.isURLSearchParams(data)) {
31220
+ setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');
31221
+ return data.toString();
31222
+ }
31223
+ if (utils$6.isObject(data) || (headers && headers['Content-Type'] === 'application/json')) {
31224
+ setContentTypeIfUnset(headers, 'application/json');
31225
+ return stringifySafely(data);
31226
+ }
31227
+ return data;
31228
+ }],
31229
+
31230
+ transformResponse: [function transformResponse(data) {
31231
+ var transitional = this.transitional || defaults$3.transitional;
31232
+ var silentJSONParsing = transitional && transitional.silentJSONParsing;
31233
+ var forcedJSONParsing = transitional && transitional.forcedJSONParsing;
31234
+ var strictJSONParsing = !silentJSONParsing && this.responseType === 'json';
31235
+
31236
+ if (strictJSONParsing || (forcedJSONParsing && utils$6.isString(data) && data.length)) {
31237
+ try {
31238
+ return JSON.parse(data);
31239
+ } catch (e) {
31240
+ if (strictJSONParsing) {
31241
+ if (e.name === 'SyntaxError') {
31242
+ throw enhanceError(e, this, 'E_JSON_PARSE');
31243
+ }
31244
+ throw e;
31245
+ }
31246
+ }
31247
+ }
31248
+
31249
+ return data;
31250
+ }],
31251
+
31252
+ /**
31253
+ * A timeout in milliseconds to abort a request. If set to 0 (default) a
31254
+ * timeout is not created.
31255
+ */
31256
+ timeout: 0,
31257
+
31258
+ xsrfCookieName: 'XSRF-TOKEN',
31259
+ xsrfHeaderName: 'X-XSRF-TOKEN',
31260
+
31261
+ maxContentLength: -1,
31262
+ maxBodyLength: -1,
31263
+
31264
+ validateStatus: function validateStatus(status) {
31265
+ return status >= 200 && status < 300;
31266
+ },
31267
+
31268
+ headers: {
31269
+ common: {
31270
+ 'Accept': 'application/json, text/plain, */*'
31271
+ }
31272
+ }
31273
+ };
31274
+
31275
+ utils$6.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
31276
+ defaults$3.headers[method] = {};
31277
+ });
31278
+
31279
+ utils$6.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
31280
+ defaults$3.headers[method] = utils$6.merge(DEFAULT_CONTENT_TYPE);
31281
+ });
31282
+
31283
+ var defaults_1 = defaults$3;
31284
+
31285
+ var utils$5 = utils$f;
31286
+ var defaults$2 = defaults_1;
31287
+
31288
+ /**
31289
+ * Transform the data for a request or a response
31290
+ *
31291
+ * @param {Object|String} data The data to be transformed
31292
+ * @param {Array} headers The headers for the request or response
31293
+ * @param {Array|Function} fns A single function or Array of functions
31294
+ * @returns {*} The resulting transformed data
31295
+ */
31296
+ var transformData$1 = function transformData(data, headers, fns) {
31297
+ var context = this || defaults$2;
31298
+ /*eslint no-param-reassign:0*/
31299
+ utils$5.forEach(fns, function transform(fn) {
31300
+ data = fn.call(context, data, headers);
31301
+ });
31302
+
31303
+ return data;
31304
+ };
31305
+
31306
+ var isCancel$1 = function isCancel(value) {
31307
+ return !!(value && value.__CANCEL__);
31308
+ };
31309
+
31310
+ var utils$4 = utils$f;
31311
+ var transformData = transformData$1;
31312
+ var isCancel = isCancel$1;
31313
+ var defaults$1 = defaults_1;
31314
+ var Cancel$1 = Cancel_1;
31315
+
31316
+ /**
31317
+ * Throws a `Cancel` if cancellation has been requested.
31318
+ */
31319
+ function throwIfCancellationRequested(config) {
31320
+ if (config.cancelToken) {
31321
+ config.cancelToken.throwIfRequested();
31322
+ }
31323
+
31324
+ if (config.signal && config.signal.aborted) {
31325
+ throw new Cancel$1('canceled');
31326
+ }
31327
+ }
31328
+
31329
+ /**
31330
+ * Dispatch a request to the server using the configured adapter.
31331
+ *
31332
+ * @param {object} config The config that is to be used for the request
31333
+ * @returns {Promise} The Promise to be fulfilled
31334
+ */
31335
+ var dispatchRequest$1 = function dispatchRequest(config) {
31336
+ throwIfCancellationRequested(config);
31337
+
31338
+ // Ensure headers exist
31339
+ config.headers = config.headers || {};
31340
+
31341
+ // Transform request data
31342
+ config.data = transformData.call(
31343
+ config,
31344
+ config.data,
31345
+ config.headers,
31346
+ config.transformRequest
31347
+ );
31348
+
31349
+ // Flatten headers
31350
+ config.headers = utils$4.merge(
31351
+ config.headers.common || {},
31352
+ config.headers[config.method] || {},
31353
+ config.headers
31354
+ );
31355
+
31356
+ utils$4.forEach(
31357
+ ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
31358
+ function cleanHeaderConfig(method) {
31359
+ delete config.headers[method];
31360
+ }
31361
+ );
31362
+
31363
+ var adapter = config.adapter || defaults$1.adapter;
31364
+
31365
+ return adapter(config).then(function onAdapterResolution(response) {
31366
+ throwIfCancellationRequested(config);
31367
+
31368
+ // Transform response data
31369
+ response.data = transformData.call(
31370
+ config,
31371
+ response.data,
31372
+ response.headers,
31373
+ config.transformResponse
31374
+ );
31375
+
31376
+ return response;
31377
+ }, function onAdapterRejection(reason) {
31378
+ if (!isCancel(reason)) {
31379
+ throwIfCancellationRequested(config);
31380
+
31381
+ // Transform response data
31382
+ if (reason && reason.response) {
31383
+ reason.response.data = transformData.call(
31384
+ config,
31385
+ reason.response.data,
31386
+ reason.response.headers,
31387
+ config.transformResponse
31388
+ );
31389
+ }
31390
+ }
31391
+
31392
+ return Promise.reject(reason);
31393
+ });
31394
+ };
31395
+
31396
+ var utils$3 = utils$f;
31397
+
31398
+ /**
31399
+ * Config-specific merge-function which creates a new config-object
31400
+ * by merging two configuration objects together.
31401
+ *
31402
+ * @param {Object} config1
31403
+ * @param {Object} config2
31404
+ * @returns {Object} New object resulting from merging config2 to config1
31405
+ */
31406
+ var mergeConfig$2 = function mergeConfig(config1, config2) {
31407
+ // eslint-disable-next-line no-param-reassign
31408
+ config2 = config2 || {};
31409
+ var config = {};
31410
+
31411
+ function getMergedValue(target, source) {
31412
+ if (utils$3.isPlainObject(target) && utils$3.isPlainObject(source)) {
31413
+ return utils$3.merge(target, source);
31414
+ } else if (utils$3.isPlainObject(source)) {
31415
+ return utils$3.merge({}, source);
31416
+ } else if (utils$3.isArray(source)) {
31417
+ return source.slice();
31418
+ }
31419
+ return source;
31420
+ }
31421
+
31422
+ // eslint-disable-next-line consistent-return
31423
+ function mergeDeepProperties(prop) {
31424
+ if (!utils$3.isUndefined(config2[prop])) {
31425
+ return getMergedValue(config1[prop], config2[prop]);
31426
+ } else if (!utils$3.isUndefined(config1[prop])) {
31427
+ return getMergedValue(undefined, config1[prop]);
31428
+ }
31429
+ }
31430
+
31431
+ // eslint-disable-next-line consistent-return
31432
+ function valueFromConfig2(prop) {
31433
+ if (!utils$3.isUndefined(config2[prop])) {
31434
+ return getMergedValue(undefined, config2[prop]);
31435
+ }
31436
+ }
31437
+
31438
+ // eslint-disable-next-line consistent-return
31439
+ function defaultToConfig2(prop) {
31440
+ if (!utils$3.isUndefined(config2[prop])) {
31441
+ return getMergedValue(undefined, config2[prop]);
31442
+ } else if (!utils$3.isUndefined(config1[prop])) {
31443
+ return getMergedValue(undefined, config1[prop]);
31444
+ }
31445
+ }
31446
+
31447
+ // eslint-disable-next-line consistent-return
31448
+ function mergeDirectKeys(prop) {
31449
+ if (prop in config2) {
31450
+ return getMergedValue(config1[prop], config2[prop]);
31451
+ } else if (prop in config1) {
31452
+ return getMergedValue(undefined, config1[prop]);
31453
+ }
31454
+ }
31455
+
31456
+ var mergeMap = {
31457
+ 'url': valueFromConfig2,
31458
+ 'method': valueFromConfig2,
31459
+ 'data': valueFromConfig2,
31460
+ 'baseURL': defaultToConfig2,
31461
+ 'transformRequest': defaultToConfig2,
31462
+ 'transformResponse': defaultToConfig2,
31463
+ 'paramsSerializer': defaultToConfig2,
31464
+ 'timeout': defaultToConfig2,
31465
+ 'timeoutMessage': defaultToConfig2,
31466
+ 'withCredentials': defaultToConfig2,
31467
+ 'adapter': defaultToConfig2,
31468
+ 'responseType': defaultToConfig2,
31469
+ 'xsrfCookieName': defaultToConfig2,
31470
+ 'xsrfHeaderName': defaultToConfig2,
31471
+ 'onUploadProgress': defaultToConfig2,
31472
+ 'onDownloadProgress': defaultToConfig2,
31473
+ 'decompress': defaultToConfig2,
31474
+ 'maxContentLength': defaultToConfig2,
31475
+ 'maxBodyLength': defaultToConfig2,
31476
+ 'transport': defaultToConfig2,
31477
+ 'httpAgent': defaultToConfig2,
31478
+ 'httpsAgent': defaultToConfig2,
31479
+ 'cancelToken': defaultToConfig2,
31480
+ 'socketPath': defaultToConfig2,
31481
+ 'responseEncoding': defaultToConfig2,
31482
+ 'validateStatus': mergeDirectKeys
31483
+ };
31484
+
31485
+ utils$3.forEach(Object.keys(config1).concat(Object.keys(config2)), function computeConfigValue(prop) {
31486
+ var merge = mergeMap[prop] || mergeDeepProperties;
31487
+ var configValue = merge(prop);
31488
+ (utils$3.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
31489
+ });
31490
+
31491
+ return config;
31492
+ };
31493
+
31494
+ var VERSION = data.version;
31495
+
31496
+ var validators$1 = {};
31497
+
31498
+ // eslint-disable-next-line func-names
31499
+ ['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach(function(type, i) {
31500
+ validators$1[type] = function validator(thing) {
31501
+ return typeof thing === type || 'a' + (i < 1 ? 'n ' : ' ') + type;
31502
+ };
31503
+ });
31504
+
31505
+ var deprecatedWarnings = {};
31506
+
31507
+ /**
31508
+ * Transitional option validator
31509
+ * @param {function|boolean?} validator - set to false if the transitional option has been removed
31510
+ * @param {string?} version - deprecated version / removed since version
31511
+ * @param {string?} message - some message with additional info
31512
+ * @returns {function}
31513
+ */
31514
+ validators$1.transitional = function transitional(validator, version, message) {
31515
+ function formatMessage(opt, desc) {
31516
+ return '[Axios v' + VERSION + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : '');
31517
+ }
31518
+
31519
+ // eslint-disable-next-line func-names
31520
+ return function(value, opt, opts) {
31521
+ if (validator === false) {
31522
+ throw new Error(formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')));
31523
+ }
31524
+
31525
+ if (version && !deprecatedWarnings[opt]) {
31526
+ deprecatedWarnings[opt] = true;
31527
+ // eslint-disable-next-line no-console
31528
+ console.warn(
31529
+ formatMessage(
31530
+ opt,
31531
+ ' has been deprecated since v' + version + ' and will be removed in the near future'
31532
+ )
31533
+ );
31534
+ }
31535
+
31536
+ return validator ? validator(value, opt, opts) : true;
31537
+ };
31538
+ };
31539
+
31540
+ /**
31541
+ * Assert object's properties type
31542
+ * @param {object} options
31543
+ * @param {object} schema
31544
+ * @param {boolean?} allowUnknown
31545
+ */
31546
+
31547
+ function assertOptions(options, schema, allowUnknown) {
31548
+ if (typeof options !== 'object') {
31549
+ throw new TypeError('options must be an object');
31550
+ }
31551
+ var keys = Object.keys(options);
31552
+ var i = keys.length;
31553
+ while (i-- > 0) {
31554
+ var opt = keys[i];
31555
+ var validator = schema[opt];
31556
+ if (validator) {
31557
+ var value = options[opt];
31558
+ var result = value === undefined || validator(value, opt, options);
31559
+ if (result !== true) {
31560
+ throw new TypeError('option ' + opt + ' must be ' + result);
31561
+ }
31562
+ continue;
31563
+ }
31564
+ if (allowUnknown !== true) {
31565
+ throw Error('Unknown option ' + opt);
31566
+ }
31567
+ }
31568
+ }
31569
+
31570
+ var validator$1 = {
31571
+ assertOptions: assertOptions,
31572
+ validators: validators$1
31573
+ };
31574
+
31575
+ var utils$2 = utils$f;
31576
+ var buildURL = buildURL$3;
31577
+ var InterceptorManager = InterceptorManager_1;
31578
+ var dispatchRequest = dispatchRequest$1;
31579
+ var mergeConfig$1 = mergeConfig$2;
31580
+ var validator = validator$1;
31581
+
31582
+ var validators = validator.validators;
31583
+ /**
31584
+ * Create a new instance of Axios
31585
+ *
31586
+ * @param {Object} instanceConfig The default config for the instance
31587
+ */
31588
+ function Axios$1(instanceConfig) {
31589
+ this.defaults = instanceConfig;
31590
+ this.interceptors = {
31591
+ request: new InterceptorManager(),
31592
+ response: new InterceptorManager()
31593
+ };
31594
+ }
31595
+
31596
+ /**
31597
+ * Dispatch a request
31598
+ *
31599
+ * @param {Object} config The config specific for this request (merged with this.defaults)
31600
+ */
31601
+ Axios$1.prototype.request = function request(configOrUrl, config) {
31602
+ /*eslint no-param-reassign:0*/
31603
+ // Allow for axios('example/url'[, config]) a la fetch API
31604
+ if (typeof configOrUrl === 'string') {
31605
+ config = config || {};
31606
+ config.url = configOrUrl;
31607
+ } else {
31608
+ config = configOrUrl || {};
31609
+ }
31610
+
31611
+ config = mergeConfig$1(this.defaults, config);
31612
+
31613
+ // Set config.method
31614
+ if (config.method) {
31615
+ config.method = config.method.toLowerCase();
31616
+ } else if (this.defaults.method) {
31617
+ config.method = this.defaults.method.toLowerCase();
31618
+ } else {
31619
+ config.method = 'get';
31620
+ }
31621
+
31622
+ var transitional = config.transitional;
31623
+
31624
+ if (transitional !== undefined) {
31625
+ validator.assertOptions(transitional, {
31626
+ silentJSONParsing: validators.transitional(validators.boolean),
31627
+ forcedJSONParsing: validators.transitional(validators.boolean),
31628
+ clarifyTimeoutError: validators.transitional(validators.boolean)
31629
+ }, false);
31630
+ }
31631
+
31632
+ // filter out skipped interceptors
31633
+ var requestInterceptorChain = [];
31634
+ var synchronousRequestInterceptors = true;
31635
+ this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
31636
+ if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) {
31637
+ return;
31638
+ }
31639
+
31640
+ synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
31641
+
31642
+ requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
31643
+ });
31644
+
31645
+ var responseInterceptorChain = [];
31646
+ this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
31647
+ responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
31648
+ });
31649
+
31650
+ var promise;
31651
+
31652
+ if (!synchronousRequestInterceptors) {
31653
+ var chain = [dispatchRequest, undefined];
31654
+
31655
+ Array.prototype.unshift.apply(chain, requestInterceptorChain);
31656
+ chain = chain.concat(responseInterceptorChain);
31657
+
31658
+ promise = Promise.resolve(config);
31659
+ while (chain.length) {
31660
+ promise = promise.then(chain.shift(), chain.shift());
31661
+ }
31662
+
31663
+ return promise;
31664
+ }
31665
+
31666
+
31667
+ var newConfig = config;
31668
+ while (requestInterceptorChain.length) {
31669
+ var onFulfilled = requestInterceptorChain.shift();
31670
+ var onRejected = requestInterceptorChain.shift();
31671
+ try {
31672
+ newConfig = onFulfilled(newConfig);
31673
+ } catch (error) {
31674
+ onRejected(error);
31675
+ break;
31676
+ }
31677
+ }
31678
+
31679
+ try {
31680
+ promise = dispatchRequest(newConfig);
31681
+ } catch (error) {
31682
+ return Promise.reject(error);
31683
+ }
31684
+
31685
+ while (responseInterceptorChain.length) {
31686
+ promise = promise.then(responseInterceptorChain.shift(), responseInterceptorChain.shift());
31687
+ }
31688
+
31689
+ return promise;
31690
+ };
31691
+
31692
+ Axios$1.prototype.getUri = function getUri(config) {
31693
+ config = mergeConfig$1(this.defaults, config);
31694
+ return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, '');
31695
+ };
31696
+
31697
+ // Provide aliases for supported request methods
31698
+ utils$2.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
31699
+ /*eslint func-names:0*/
31700
+ Axios$1.prototype[method] = function(url, config) {
31701
+ return this.request(mergeConfig$1(config || {}, {
31702
+ method: method,
31703
+ url: url,
31704
+ data: (config || {}).data
31705
+ }));
31706
+ };
31707
+ });
31708
+
31709
+ utils$2.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
31710
+ /*eslint func-names:0*/
31711
+ Axios$1.prototype[method] = function(url, data, config) {
31712
+ return this.request(mergeConfig$1(config || {}, {
31713
+ method: method,
31714
+ url: url,
31715
+ data: data
31716
+ }));
31717
+ };
31718
+ });
31719
+
31720
+ var Axios_1 = Axios$1;
31721
+
31722
+ var Cancel = Cancel_1;
31723
+
31724
+ /**
31725
+ * A `CancelToken` is an object that can be used to request cancellation of an operation.
31726
+ *
31727
+ * @class
31728
+ * @param {Function} executor The executor function.
31729
+ */
31730
+ function CancelToken(executor) {
31731
+ if (typeof executor !== 'function') {
31732
+ throw new TypeError('executor must be a function.');
31733
+ }
31734
+
31735
+ var resolvePromise;
31736
+
31737
+ this.promise = new Promise(function promiseExecutor(resolve) {
31738
+ resolvePromise = resolve;
31739
+ });
31740
+
31741
+ var token = this;
31742
+
31743
+ // eslint-disable-next-line func-names
31744
+ this.promise.then(function(cancel) {
31745
+ if (!token._listeners) return;
31746
+
31747
+ var i;
31748
+ var l = token._listeners.length;
31749
+
31750
+ for (i = 0; i < l; i++) {
31751
+ token._listeners[i](cancel);
31752
+ }
31753
+ token._listeners = null;
31754
+ });
31755
+
31756
+ // eslint-disable-next-line func-names
31757
+ this.promise.then = function(onfulfilled) {
31758
+ var _resolve;
31759
+ // eslint-disable-next-line func-names
31760
+ var promise = new Promise(function(resolve) {
31761
+ token.subscribe(resolve);
31762
+ _resolve = resolve;
31763
+ }).then(onfulfilled);
31764
+
31765
+ promise.cancel = function reject() {
31766
+ token.unsubscribe(_resolve);
31767
+ };
31768
+
31769
+ return promise;
31770
+ };
31771
+
31772
+ executor(function cancel(message) {
31773
+ if (token.reason) {
31774
+ // Cancellation has already been requested
31775
+ return;
31776
+ }
31777
+
31778
+ token.reason = new Cancel(message);
31779
+ resolvePromise(token.reason);
31780
+ });
31781
+ }
31782
+
31783
+ /**
31784
+ * Throws a `Cancel` if cancellation has been requested.
31785
+ */
31786
+ CancelToken.prototype.throwIfRequested = function throwIfRequested() {
31787
+ if (this.reason) {
31788
+ throw this.reason;
31789
+ }
31790
+ };
31791
+
31792
+ /**
31793
+ * Subscribe to the cancel signal
31794
+ */
31795
+
31796
+ CancelToken.prototype.subscribe = function subscribe(listener) {
31797
+ if (this.reason) {
31798
+ listener(this.reason);
31799
+ return;
31800
+ }
31801
+
31802
+ if (this._listeners) {
31803
+ this._listeners.push(listener);
31804
+ } else {
31805
+ this._listeners = [listener];
31806
+ }
31807
+ };
31808
+
31809
+ /**
31810
+ * Unsubscribe from the cancel signal
31811
+ */
31812
+
31813
+ CancelToken.prototype.unsubscribe = function unsubscribe(listener) {
31814
+ if (!this._listeners) {
31815
+ return;
31816
+ }
31817
+ var index = this._listeners.indexOf(listener);
31818
+ if (index !== -1) {
31819
+ this._listeners.splice(index, 1);
31820
+ }
31821
+ };
31822
+
31823
+ /**
31824
+ * Returns an object that contains a new `CancelToken` and a function that, when called,
31825
+ * cancels the `CancelToken`.
31826
+ */
31827
+ CancelToken.source = function source() {
31828
+ var cancel;
31829
+ var token = new CancelToken(function executor(c) {
31830
+ cancel = c;
31831
+ });
31832
+ return {
31833
+ token: token,
31834
+ cancel: cancel
31835
+ };
31836
+ };
31837
+
31838
+ var CancelToken_1 = CancelToken;
31839
+
31840
+ /**
31841
+ * Syntactic sugar for invoking a function and expanding an array for arguments.
31842
+ *
31843
+ * Common use case would be to use `Function.prototype.apply`.
31844
+ *
31845
+ * ```js
31846
+ * function f(x, y, z) {}
31847
+ * var args = [1, 2, 3];
31848
+ * f.apply(null, args);
31849
+ * ```
31850
+ *
31851
+ * With `spread` this example can be re-written.
31852
+ *
31853
+ * ```js
31854
+ * spread(function(x, y, z) {})([1, 2, 3]);
31855
+ * ```
31856
+ *
31857
+ * @param {Function} callback
31858
+ * @returns {Function}
31859
+ */
31860
+ var spread = function spread(callback) {
31861
+ return function wrap(arr) {
31862
+ return callback.apply(null, arr);
31863
+ };
31864
+ };
31865
+
31866
+ var utils$1 = utils$f;
31867
+
31868
+ /**
31869
+ * Determines whether the payload is an error thrown by Axios
31870
+ *
31871
+ * @param {*} payload The value to test
31872
+ * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
31873
+ */
31874
+ var isAxiosError = function isAxiosError(payload) {
31875
+ return utils$1.isObject(payload) && (payload.isAxiosError === true);
31876
+ };
31877
+
31878
+ var utils = utils$f;
31879
+ var bind = bind$2;
31880
+ var Axios = Axios_1;
31881
+ var mergeConfig = mergeConfig$2;
31882
+ var defaults = defaults_1;
31883
+
31884
+ /**
31885
+ * Create an instance of Axios
31886
+ *
31887
+ * @param {Object} defaultConfig The default config for the instance
31888
+ * @return {Axios} A new instance of Axios
31889
+ */
31890
+ function createInstance(defaultConfig) {
31891
+ var context = new Axios(defaultConfig);
31892
+ var instance = bind(Axios.prototype.request, context);
31893
+
31894
+ // Copy axios.prototype to instance
31895
+ utils.extend(instance, Axios.prototype, context);
31896
+
31897
+ // Copy context to instance
31898
+ utils.extend(instance, context);
31899
+
31900
+ // Factory for creating new instances
31901
+ instance.create = function create(instanceConfig) {
31902
+ return createInstance(mergeConfig(defaultConfig, instanceConfig));
31903
+ };
31904
+
31905
+ return instance;
31906
+ }
31907
+
31908
+ // Create the default instance to be exported
31909
+ var axios$1 = createInstance(defaults);
31910
+
31911
+ // Expose Axios class to allow class inheritance
31912
+ axios$1.Axios = Axios;
31913
+
31914
+ // Expose Cancel & CancelToken
31915
+ axios$1.Cancel = Cancel_1;
31916
+ axios$1.CancelToken = CancelToken_1;
31917
+ axios$1.isCancel = isCancel$1;
31918
+ axios$1.VERSION = data.version;
31919
+
31920
+ // Expose all/spread
31921
+ axios$1.all = function all(promises) {
31922
+ return Promise.all(promises);
31923
+ };
31924
+ axios$1.spread = spread;
31925
+
31926
+ // Expose isAxiosError
31927
+ axios$1.isAxiosError = isAxiosError;
31928
+
31929
+ axios$2.exports = axios$1;
31930
+
31931
+ // Allow use of default import syntax in TypeScript
31932
+ axios$2.exports.default = axios$1;
31933
+
31934
+ var axios = axios$2.exports;
31935
+
31936
+ const sanityMediaSettings = new AppInMemorySettings();
31937
+
31938
+ const buildRef = ({ dataset, projectId, id, }) => {
31939
+ return `sanity://${projectId}/${dataset}/${id}`;
31940
+ };
31941
+ const parseRef = (ref) => {
31942
+ const parts = ref.split("/");
31943
+ return {
31944
+ projectId: parts[2],
31945
+ dataset: parts[3],
31946
+ id: parts.slice(4).join("/"),
31947
+ };
31948
+ };
31949
+ const isImage = (contentType) => {
31950
+ return contentType.startsWith("image/");
31951
+ };
31952
+ const buildFolderTag = (folderId) => {
31953
+ return folderId ? `folder:${folderId}` : "folder:root";
31954
+ };
31955
+ let SanityMediaProvider = class SanityMediaProvider {
31956
+ constructor() {
31957
+ this.client = createClient$4({
31958
+ projectId: sanityMediaSettings.value.projectId,
31959
+ dataset: sanityMediaSettings.value.dataset,
31960
+ token: sanityMediaSettings.value.token,
31961
+ apiVersion: sanityMediaSettings.value.apiVersion,
31962
+ });
31963
+ }
31964
+ getProviderId() {
31965
+ return "sanity";
31966
+ }
31967
+ getFileName(input) {
31968
+ const parsedRef = parseRef(input.ref);
31969
+ return parsedRef.id.replace("_", ".");
31970
+ }
31971
+ async mediaUpload(input) {
31972
+ try {
31973
+ const asses = await this.client.assets.upload(input.contentType && isImage(input.contentType) ? "image" : "file", input.content, {
31974
+ contentType: input.contentType,
31975
+ filename: input.fileName,
31976
+ tag: buildFolderTag(input.folderId),
31977
+ });
31978
+ return {
31979
+ ref: buildRef({
31980
+ dataset: sanityMediaSettings.value.dataset,
31981
+ projectId: sanityMediaSettings.value.projectId,
31982
+ id: asses._id,
31983
+ }),
31984
+ };
31985
+ }
31986
+ catch (e) {
31987
+ throw new SanityMediaError(`SanityMediaProvider | mediaUpload | ${input.fileName} | Error -> ${e.message}`);
31988
+ }
31989
+ }
31990
+ async mediaDelete(input) {
31991
+ try {
31992
+ const parsedRef = parseRef(input.ref);
31993
+ await this.client.delete(parsedRef.id);
31994
+ }
31995
+ catch (e) {
31996
+ throw new SanityMediaError(`SanityMediaProvider | mediaDelete | ${input.ref} | Error -> ${e.message}`);
31997
+ }
31998
+ }
31999
+ async mediaDownload(input) {
32000
+ try {
32001
+ const parsedRef = parseRef(input.ref);
32002
+ const asset = await this.client.getDocument(parsedRef.id);
32003
+ if (!asset) {
32004
+ throw new Error(`Asset not found id: ${parsedRef.id}`);
32005
+ }
32006
+ const response = await axios.get(asset.url, {
32007
+ responseType: "arraybuffer",
32008
+ });
32009
+ return Buffer.from(response.data, "binary");
32010
+ }
32011
+ catch (e) {
32012
+ throw new SanityMediaError(`SanityMediaProvider | mediaDownload | ${input.ref} | Error -> ${e.message}`);
32013
+ }
32014
+ }
32015
+ };
32016
+ SanityMediaProvider = __decorate([
32017
+ WpMediaProvider("sanity"),
32018
+ __metadata("design:paramtypes", [])
32019
+ ], SanityMediaProvider);
32020
+
32021
+ var SanityMediaModule_1;
32022
+ const ModuleData$1 = {
32023
+ providers: [SanityMediaProvider],
32024
+ };
32025
+ let SanityMediaModule = SanityMediaModule_1 = class SanityMediaModule {
32026
+ static forRoot(input) {
32027
+ sanityMediaSettings.initialize(input);
32028
+ return {
32029
+ module: SanityMediaModule_1,
32030
+ ...ModuleData$1,
32031
+ };
32032
+ }
32033
+ };
32034
+ SanityMediaModule = SanityMediaModule_1 = __decorate([
32035
+ Module({
32036
+ ...ModuleData$1,
32037
+ })
32038
+ ], SanityMediaModule);
32039
+
29063
32040
  let InMemoryMediaProvider = class InMemoryMediaProvider {
29064
32041
  constructor() {
29065
32042
  this.provider = new InMemoryBucketProvider();
@@ -29295,5 +32272,5 @@ AwsSecretsModule = AwsSecretsModule_1 = __decorate([
29295
32272
  })
29296
32273
  ], AwsSecretsModule);
29297
32274
 
29298
- export { AUTHENTICATION_EVENTS_NAMESPACE, AppExceptionsFilterBase, AppHashingService, AppInMemorySettings, AppSessionMiddleware, AppSessionService, AuthGuard, Authenticated, AuthenticationEmailTemplates, AuthenticationError, AuthenticationEvents, AuthenticationExtensionSymbols, AuthenticationModule, AuthenticationService, AwsBucketModule, AwsEmailModule, AwsS3BucketError, AwsS3BucketProvider, AwsS3MediaError, AwsS3MediaModule, AwsS3MediaProvider, AwsSecretsModule, AwsSecretsProvider, AwsSesEmailTemplate, BucketItemType, CacheService, CurrentUser, EmailService, EntityManagerConfigurationError, EntityManagerException, EntityManagerInitializer, EntityManagerModule, EntityManagerRegistry, EntityManagerService, EntityManagerSymbols, EntityManagerUnauthorizedException, EntityNotFoundException, EntityOperationType, EntityOperationUnauthorizedException, EntitySeeder, EntitySerializationFormat, EntitySerializer, EntitySnapshotService, EntityVersionOperation, EventsService, FilesService, IEntityVersionsCursor, InMemoryBucketProvider, InMemoryEmailProvider, InMemoryMediaProvider, InvalidCredentialsError, MediaLibraryService, MemberOf, MissingEntityIdError, ModulesContainerProvider, MultiTenancyModule, MultipleEntitiesFoundException, NestEntityActions, NestEntityAuthorizationMiddleware, NestEntityManager, NestEntitySerializer, NestEntitySnapshotService, NestPipelineTemplate, NestTypeOrmEntitySeeder, NestTypeOrmQueryBuilder, NestTypeOrmRepository, OperationTokenMismatchError, PLATFORM_EVENT_NAMESPACE, Permissions, PipelineController, PipelineErrorType, PipelineInvocationError, PipelineStatus, PipelineStepErrorType, PipelinesBuilder, PipelinesRunner, PlatformEvents, Public, QueryBuilderBase, QueryBuilderOperation, ReplicationMode, Roles, SecretsService, SendgridEmailModule, SendgridEmailTemplate, SortDirection, TrackingService, TypeOrmQueryBuilder, TypeOrmRepository, TypeormCacheInstance, UserCreationError, UserRegistrationError, WpAppInitializer, WpAwsSesEmailTemplate, WpBucketProvider, WpCacheInstance, WpEmailLogger, WpEmailProvider, WpEmailTemplate, WpEntity, WpEntityActions, WpEntityAdapter, WpEntityAuthMiddleware, WpEntityConnector, WpEntityConverter, WpEntityManager, WpEntityQueryBuilder, WpEntityRepository, WpEntitySeeder, WpEntitySerializer, WpEntitySnapshotService, WpEntityVersioningProvider, WpEventsTracker, WpFileProvider, WpFileReferenceRepository, WpGlobalAuthenticationMiddleware, WpMediaFolderRepository, WpMediaProvider, WpMediaReferenceRepository, WpPermissionsService, WpPipeline, WpRolesService, WpSendgridEmailTemplate, WpUserRolesService, WpUserService, buildPermissionsGuard, buildRolesGuard, createContainer, createExpressFileResponse, getLocalizedText, newUuid, renderHandlebarsTemplate, toEntitiesImportInput };
32275
+ export { AUTHENTICATION_EVENTS_NAMESPACE, AppExceptionsFilterBase, AppHashingService, AppInMemorySettings, AppSessionMiddleware, AppSessionService, AuthGuard, Authenticated, AuthenticationEmailTemplates, AuthenticationError, AuthenticationEvents, AuthenticationExtensionSymbols, AuthenticationModule, AuthenticationService, AwsBucketModule, AwsEmailModule, AwsS3BucketError, AwsS3BucketProvider, AwsS3MediaError, AwsS3MediaModule, AwsS3MediaProvider, AwsSecretsModule, AwsSecretsProvider, AwsSesEmailTemplate, BucketItemType, CacheService, CurrentUser, EmailService, EntityManagerConfigurationError, EntityManagerException, EntityManagerInitializer, EntityManagerModule, EntityManagerRegistry, EntityManagerService, EntityManagerSymbols, EntityManagerUnauthorizedException, EntityNotFoundException, EntityOperationType, EntityOperationUnauthorizedException, EntitySeeder, EntitySerializationFormat, EntitySerializer, EntitySnapshotService, EntityVersionOperation, EventsService, FilesService, IEntityVersionsCursor, InMemoryBucketProvider, InMemoryEmailProvider, InMemoryMediaProvider, InvalidCredentialsError, MediaLibraryService, MemberOf, MissingEntityIdError, ModulesContainerProvider, MultiTenancyModule, MultipleEntitiesFoundException, NestEntityActions, NestEntityAuthorizationMiddleware, NestEntityManager, NestEntitySerializer, NestEntitySnapshotService, NestPipelineTemplate, NestTypeOrmEntitySeeder, NestTypeOrmQueryBuilder, NestTypeOrmRepository, OperationTokenMismatchError, PLATFORM_EVENT_NAMESPACE, Permissions, PipelineController, PipelineErrorType, PipelineInvocationError, PipelineStatus, PipelineStepErrorType, PipelinesBuilder, PipelinesRunner, PlatformEvents, Public, QueryBuilderBase, QueryBuilderOperation, ReplicationMode, Roles, SanityMediaError, SanityMediaModule, SanityMediaProvider, SecretsService, SendgridEmailModule, SendgridEmailTemplate, SortDirection, TrackingService, TypeOrmQueryBuilder, TypeOrmRepository, TypeormCacheInstance, UserCreationError, UserRegistrationError, WpAppInitializer, WpAwsSesEmailTemplate, WpBucketProvider, WpCacheInstance, WpEmailLogger, WpEmailProvider, WpEmailTemplate, WpEntity, WpEntityActions, WpEntityAdapter, WpEntityAuthMiddleware, WpEntityConnector, WpEntityConverter, WpEntityManager, WpEntityQueryBuilder, WpEntityRepository, WpEntitySeeder, WpEntitySerializer, WpEntitySnapshotService, WpEntityVersioningProvider, WpEventsTracker, WpFileProvider, WpFileReferenceRepository, WpGlobalAuthenticationMiddleware, WpMediaFolderRepository, WpMediaProvider, WpMediaReferenceRepository, WpPermissionsService, WpPipeline, WpRolesService, WpSendgridEmailTemplate, WpUserRolesService, WpUserService, buildPermissionsGuard, buildRolesGuard, createContainer, createExpressFileResponse, getLocalizedText, newUuid, renderHandlebarsTemplate, toEntitiesImportInput };
29299
32276
  //# sourceMappingURL=index.js.map