comprodls-sdk 2.69.1 → 2.70.1

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.
@@ -1150,7 +1150,7 @@ validator.validators.contains = function(value, options) {
1150
1150
  }
1151
1151
  }
1152
1152
  };
1153
- },{"./errors":7,"validate.js":53}],10:[function(require,module,exports){
1153
+ },{"./errors":7,"validate.js":50}],10:[function(require,module,exports){
1154
1154
  /*************************************************************************
1155
1155
  *
1156
1156
  * COMPRO CONFIDENTIAL
@@ -12010,9 +12010,10 @@ function getMicroEntitlementsForAUser(options) {
12010
12010
 
12011
12011
  }
12012
12012
 
12013
- // options= {
12014
- // stage: "", //stage number or version
12015
- // }
12013
+ /* options= {
12014
+ stage: "string", //optional, stage number or version
12015
+ target_role: "string" // optional
12016
+ } */
12016
12017
  function getAllBundles(options) {
12017
12018
  var self = this;
12018
12019
  var dfd = q.defer();
@@ -12023,7 +12024,14 @@ function getAllBundles(options) {
12023
12024
  url = helpers.api.constructAPIUrl(url, { accountId : self.accountId });
12024
12025
  //Contruct parameters
12025
12026
  var params = {};
12026
- if(options && options.stage) { params.stage = options.stage; }
12027
+ if(options) {
12028
+ if(options.stage){
12029
+ params.stage = options.stage;
12030
+ }
12031
+ if(options.target_role){
12032
+ params.target_role = options.target_role;
12033
+ }
12034
+ }
12027
12035
 
12028
12036
  //Setup request with URL and Post data
12029
12037
  var requestAPI = request.get(url).query(params);
@@ -12498,10 +12506,10 @@ function updateBundle(options) {
12498
12506
  return dfd.promise;
12499
12507
  }
12500
12508
 
12501
- // options= {
12502
- // stage: "", //stage number or version
12503
- // }
12504
-
12509
+ /* options= {
12510
+ stage: "string", //optional, stage number or version
12511
+ target_role: "string" // optional
12512
+ } */
12505
12513
  function getAllBundles(options) {
12506
12514
  var self = this;
12507
12515
  //Initializing promise
@@ -12513,7 +12521,14 @@ function getAllBundles(options) {
12513
12521
  url = helpers.api.constructAPIUrl(url, { orgid: self.orgId, });
12514
12522
  //Contruct parameters
12515
12523
  var params = {};
12516
- if(options && options.stage) { params.stage = options.stage; }
12524
+ if(options) {
12525
+ if(options.stage){
12526
+ params.stage = options.stage;
12527
+ }
12528
+ if(options.target_role){
12529
+ params.target_role = options.target_role;
12530
+ }
12531
+ }
12517
12532
 
12518
12533
  //Setup request with URL and Post data
12519
12534
  var requestAPI = request.get(url).query(params);
@@ -12816,7 +12831,7 @@ function pushX() {
12816
12831
  /*********************************
12817
12832
  * Public Function definitions
12818
12833
  **********************************/
12819
-
12834
+ // This is a dummy comment to test release.
12820
12835
  function _connect(pubnubCW, options) {
12821
12836
  var bpubnubV7 = true; // If pubnub v7 or higher in package.json, set it true
12822
12837
  if (bpubnubV7 && !options.userid) {
@@ -15657,6 +15672,7 @@ function workflows(accountId) {
15657
15672
  "address": {
15658
15673
  "city": "string",
15659
15674
  "country": "string",
15675
+ "line1": "string",
15660
15676
  "street1": "string",
15661
15677
  "street2": "string",
15662
15678
  "street3": "string",
@@ -16012,6 +16028,7 @@ function completeAWorkflow(options) {
16012
16028
  "address": {
16013
16029
  "city": "string",
16014
16030
  "country": "string",
16031
+ "line1": "string",
16015
16032
  "street1": "string",
16016
16033
  "street2": "string",
16017
16034
  "street3": "string",
@@ -16021,7 +16038,7 @@ function completeAWorkflow(options) {
16021
16038
  "display_name": "string",
16022
16039
  "school_key": "string"
16023
16040
  }
16024
- }
16041
+ }
16025
16042
  }
16026
16043
  */
16027
16044
  function updateWorkflowRequest(options) {
@@ -16060,7 +16077,8 @@ function updateWorkflowRequest(options) {
16060
16077
  dfd.reject(err);
16061
16078
  }
16062
16079
  return dfd.promise;
16063
- }
16080
+ }
16081
+
16064
16082
  },{"./../../helpers":3,"q":46,"superagent":49}],33:[function(require,module,exports){
16065
16083
  /*************************************************************************
16066
16084
  *
@@ -18237,181 +18255,167 @@ module.exports = Array.isArray || function (arr) {
18237
18255
  };
18238
18256
 
18239
18257
  },{}],40:[function(require,module,exports){
18240
-
18241
- /**
18242
- * Expose `Emitter`.
18243
- */
18244
-
18245
- if (typeof module !== 'undefined') {
18246
- module.exports = Emitter;
18247
- }
18248
-
18249
- /**
18250
- * Initialize a new `Emitter`.
18251
- *
18252
- * @api public
18253
- */
18254
-
18255
- function Emitter(obj) {
18256
- if (obj) return mixin(obj);
18257
- };
18258
-
18259
- /**
18260
- * Mixin the emitter properties.
18261
- *
18262
- * @param {Object} obj
18263
- * @return {Object}
18264
- * @api private
18265
- */
18266
-
18267
- function mixin(obj) {
18268
- for (var key in Emitter.prototype) {
18269
- obj[key] = Emitter.prototype[key];
18270
- }
18271
- return obj;
18272
- }
18273
-
18274
- /**
18275
- * Listen on the given `event` with `fn`.
18276
- *
18277
- * @param {String} event
18278
- * @param {Function} fn
18279
- * @return {Emitter}
18280
- * @api public
18281
- */
18282
-
18283
- Emitter.prototype.on =
18284
- Emitter.prototype.addEventListener = function(event, fn){
18285
- this._callbacks = this._callbacks || {};
18286
- (this._callbacks['$' + event] = this._callbacks['$' + event] || [])
18287
- .push(fn);
18288
- return this;
18289
- };
18290
-
18291
- /**
18292
- * Adds an `event` listener that will be invoked a single
18293
- * time then automatically removed.
18294
- *
18295
- * @param {String} event
18296
- * @param {Function} fn
18297
- * @return {Emitter}
18298
- * @api public
18299
- */
18300
-
18301
- Emitter.prototype.once = function(event, fn){
18302
- function on() {
18303
- this.off(event, on);
18304
- fn.apply(this, arguments);
18305
- }
18306
-
18307
- on.fn = fn;
18308
- this.on(event, on);
18309
- return this;
18310
- };
18311
-
18312
- /**
18313
- * Remove the given callback for `event` or all
18314
- * registered callbacks.
18315
- *
18316
- * @param {String} event
18317
- * @param {Function} fn
18318
- * @return {Emitter}
18319
- * @api public
18320
- */
18321
-
18322
- Emitter.prototype.off =
18323
- Emitter.prototype.removeListener =
18324
- Emitter.prototype.removeAllListeners =
18325
- Emitter.prototype.removeEventListener = function(event, fn){
18326
- this._callbacks = this._callbacks || {};
18327
-
18328
- // all
18329
- if (0 == arguments.length) {
18330
- this._callbacks = {};
18331
- return this;
18332
- }
18333
-
18334
- // specific event
18335
- var callbacks = this._callbacks['$' + event];
18336
- if (!callbacks) return this;
18337
-
18338
- // remove all handlers
18339
- if (1 == arguments.length) {
18340
- delete this._callbacks['$' + event];
18341
- return this;
18342
- }
18343
-
18344
- // remove specific handler
18345
- var cb;
18346
- for (var i = 0; i < callbacks.length; i++) {
18347
- cb = callbacks[i];
18348
- if (cb === fn || cb.fn === fn) {
18349
- callbacks.splice(i, 1);
18350
- break;
18351
- }
18352
- }
18353
-
18354
- // Remove event specific arrays for event types that no
18355
- // one is subscribed for to avoid memory leak.
18356
- if (callbacks.length === 0) {
18357
- delete this._callbacks['$' + event];
18358
- }
18359
-
18360
- return this;
18361
- };
18362
-
18363
- /**
18364
- * Emit `event` with the given args.
18365
- *
18366
- * @param {String} event
18367
- * @param {Mixed} ...
18368
- * @return {Emitter}
18369
- */
18370
-
18371
- Emitter.prototype.emit = function(event){
18372
- this._callbacks = this._callbacks || {};
18373
-
18374
- var args = new Array(arguments.length - 1)
18375
- , callbacks = this._callbacks['$' + event];
18376
-
18377
- for (var i = 1; i < arguments.length; i++) {
18378
- args[i - 1] = arguments[i];
18379
- }
18380
-
18381
- if (callbacks) {
18382
- callbacks = callbacks.slice(0);
18383
- for (var i = 0, len = callbacks.length; i < len; ++i) {
18384
- callbacks[i].apply(this, args);
18385
- }
18386
- }
18387
-
18388
- return this;
18389
- };
18390
-
18391
- /**
18392
- * Return array of callbacks for `event`.
18393
- *
18394
- * @param {String} event
18395
- * @return {Array}
18396
- * @api public
18397
- */
18398
-
18399
- Emitter.prototype.listeners = function(event){
18400
- this._callbacks = this._callbacks || {};
18401
- return this._callbacks['$' + event] || [];
18402
- };
18403
-
18404
- /**
18405
- * Check if this emitter has `event` handlers.
18406
- *
18407
- * @param {String} event
18408
- * @return {Boolean}
18409
- * @api public
18410
- */
18411
-
18412
- Emitter.prototype.hasListeners = function(event){
18413
- return !! this.listeners(event).length;
18414
- };
18258
+
18259
+ /**
18260
+ * Expose `Emitter`.
18261
+ */
18262
+
18263
+ module.exports = Emitter;
18264
+
18265
+ /**
18266
+ * Initialize a new `Emitter`.
18267
+ *
18268
+ * @api public
18269
+ */
18270
+
18271
+ function Emitter(obj) {
18272
+ if (obj) return mixin(obj);
18273
+ };
18274
+
18275
+ /**
18276
+ * Mixin the emitter properties.
18277
+ *
18278
+ * @param {Object} obj
18279
+ * @return {Object}
18280
+ * @api private
18281
+ */
18282
+
18283
+ function mixin(obj) {
18284
+ for (var key in Emitter.prototype) {
18285
+ obj[key] = Emitter.prototype[key];
18286
+ }
18287
+ return obj;
18288
+ }
18289
+
18290
+ /**
18291
+ * Listen on the given `event` with `fn`.
18292
+ *
18293
+ * @param {String} event
18294
+ * @param {Function} fn
18295
+ * @return {Emitter}
18296
+ * @api public
18297
+ */
18298
+
18299
+ Emitter.prototype.on =
18300
+ Emitter.prototype.addEventListener = function(event, fn){
18301
+ this._callbacks = this._callbacks || {};
18302
+ (this._callbacks['$' + event] = this._callbacks['$' + event] || [])
18303
+ .push(fn);
18304
+ return this;
18305
+ };
18306
+
18307
+ /**
18308
+ * Adds an `event` listener that will be invoked a single
18309
+ * time then automatically removed.
18310
+ *
18311
+ * @param {String} event
18312
+ * @param {Function} fn
18313
+ * @return {Emitter}
18314
+ * @api public
18315
+ */
18316
+
18317
+ Emitter.prototype.once = function(event, fn){
18318
+ function on() {
18319
+ this.off(event, on);
18320
+ fn.apply(this, arguments);
18321
+ }
18322
+
18323
+ on.fn = fn;
18324
+ this.on(event, on);
18325
+ return this;
18326
+ };
18327
+
18328
+ /**
18329
+ * Remove the given callback for `event` or all
18330
+ * registered callbacks.
18331
+ *
18332
+ * @param {String} event
18333
+ * @param {Function} fn
18334
+ * @return {Emitter}
18335
+ * @api public
18336
+ */
18337
+
18338
+ Emitter.prototype.off =
18339
+ Emitter.prototype.removeListener =
18340
+ Emitter.prototype.removeAllListeners =
18341
+ Emitter.prototype.removeEventListener = function(event, fn){
18342
+ this._callbacks = this._callbacks || {};
18343
+
18344
+ // all
18345
+ if (0 == arguments.length) {
18346
+ this._callbacks = {};
18347
+ return this;
18348
+ }
18349
+
18350
+ // specific event
18351
+ var callbacks = this._callbacks['$' + event];
18352
+ if (!callbacks) return this;
18353
+
18354
+ // remove all handlers
18355
+ if (1 == arguments.length) {
18356
+ delete this._callbacks['$' + event];
18357
+ return this;
18358
+ }
18359
+
18360
+ // remove specific handler
18361
+ var cb;
18362
+ for (var i = 0; i < callbacks.length; i++) {
18363
+ cb = callbacks[i];
18364
+ if (cb === fn || cb.fn === fn) {
18365
+ callbacks.splice(i, 1);
18366
+ break;
18367
+ }
18368
+ }
18369
+ return this;
18370
+ };
18371
+
18372
+ /**
18373
+ * Emit `event` with the given args.
18374
+ *
18375
+ * @param {String} event
18376
+ * @param {Mixed} ...
18377
+ * @return {Emitter}
18378
+ */
18379
+
18380
+ Emitter.prototype.emit = function(event){
18381
+ this._callbacks = this._callbacks || {};
18382
+ var args = [].slice.call(arguments, 1)
18383
+ , callbacks = this._callbacks['$' + event];
18384
+
18385
+ if (callbacks) {
18386
+ callbacks = callbacks.slice(0);
18387
+ for (var i = 0, len = callbacks.length; i < len; ++i) {
18388
+ callbacks[i].apply(this, args);
18389
+ }
18390
+ }
18391
+
18392
+ return this;
18393
+ };
18394
+
18395
+ /**
18396
+ * Return array of callbacks for `event`.
18397
+ *
18398
+ * @param {String} event
18399
+ * @return {Array}
18400
+ * @api public
18401
+ */
18402
+
18403
+ Emitter.prototype.listeners = function(event){
18404
+ this._callbacks = this._callbacks || {};
18405
+ return this._callbacks['$' + event] || [];
18406
+ };
18407
+
18408
+ /**
18409
+ * Check if this emitter has `event` handlers.
18410
+ *
18411
+ * @param {String} event
18412
+ * @return {Boolean}
18413
+ * @api public
18414
+ */
18415
+
18416
+ Emitter.prototype.hasListeners = function(event){
18417
+ return !! this.listeners(event).length;
18418
+ };
18415
18419
 
18416
18420
  },{}],41:[function(require,module,exports){
18417
18421
  // Copyright Joyent, Inc. and other Node contributors.
@@ -18717,8 +18721,6 @@ function isUndefined(arg) {
18717
18721
  }
18718
18722
 
18719
18723
  },{}],42:[function(require,module,exports){
18720
- 'use strict';
18721
-
18722
18724
  var hasOwn = Object.prototype.hasOwnProperty;
18723
18725
  var toStr = Object.prototype.toString;
18724
18726
  var defineProperty = Object.defineProperty;
@@ -18733,6 +18735,8 @@ var isArray = function isArray(arr) {
18733
18735
  };
18734
18736
 
18735
18737
  var isPlainObject = function isPlainObject(obj) {
18738
+ 'use strict';
18739
+
18736
18740
  if (!obj || toStr.call(obj) !== '[object Object]') {
18737
18741
  return false;
18738
18742
  }
@@ -18782,6 +18786,8 @@ var getProperty = function getProperty(obj, name) {
18782
18786
  };
18783
18787
 
18784
18788
  module.exports = function extend() {
18789
+ 'use strict';
18790
+
18785
18791
  var options, name, src, copy, copyIsArray, clone;
18786
18792
  var target = arguments[0];
18787
18793
  var i = 1;
@@ -21251,8 +21257,6 @@ function template(string) {
21251
21257
 
21252
21258
  var Emitter = require('emitter');
21253
21259
  var reduce = require('reduce');
21254
- var requestBase = require('./request-base');
21255
- var isObject = require('./is-object');
21256
21260
 
21257
21261
  /**
21258
21262
  * Root reference for iframes.
@@ -21274,10 +21278,28 @@ if (typeof window !== 'undefined') { // Browser window
21274
21278
  function noop(){};
21275
21279
 
21276
21280
  /**
21277
- * Expose `request`.
21281
+ * Check if `obj` is a host object,
21282
+ * we don't want to serialize these :)
21283
+ *
21284
+ * TODO: future proof, move to compoent land
21285
+ *
21286
+ * @param {Object} obj
21287
+ * @return {Boolean}
21288
+ * @api private
21278
21289
  */
21279
21290
 
21280
- var request = module.exports = require('./request').bind(null, Request);
21291
+ function isHost(obj) {
21292
+ var str = {}.toString.call(obj);
21293
+
21294
+ switch (str) {
21295
+ case '[object File]':
21296
+ case '[object Blob]':
21297
+ case '[object FormData]':
21298
+ return true;
21299
+ default:
21300
+ return false;
21301
+ }
21302
+ }
21281
21303
 
21282
21304
  /**
21283
21305
  * Determine XHR.
@@ -21309,6 +21331,18 @@ var trim = ''.trim
21309
21331
  ? function(s) { return s.trim(); }
21310
21332
  : function(s) { return s.replace(/(^\s*|\s*$)/g, ''); };
21311
21333
 
21334
+ /**
21335
+ * Check if `obj` is an object.
21336
+ *
21337
+ * @param {Object} obj
21338
+ * @return {Boolean}
21339
+ * @api private
21340
+ */
21341
+
21342
+ function isObject(obj) {
21343
+ return obj === Object(obj);
21344
+ }
21345
+
21312
21346
  /**
21313
21347
  * Serialize the given `obj`.
21314
21348
  *
@@ -21323,8 +21357,8 @@ function serialize(obj) {
21323
21357
  for (var key in obj) {
21324
21358
  if (null != obj[key]) {
21325
21359
  pushEncodedKeyValuePair(pairs, key, obj[key]);
21326
- }
21327
- }
21360
+ }
21361
+ }
21328
21362
  return pairs.join('&');
21329
21363
  }
21330
21364
 
@@ -21342,11 +21376,6 @@ function pushEncodedKeyValuePair(pairs, key, val) {
21342
21376
  return val.forEach(function(v) {
21343
21377
  pushEncodedKeyValuePair(pairs, key, v);
21344
21378
  });
21345
- } else if (isObject(val)) {
21346
- for(var subkey in val) {
21347
- pushEncodedKeyValuePair(pairs, key + '[' + subkey + ']', val[subkey]);
21348
- }
21349
- return;
21350
21379
  }
21351
21380
  pairs.push(encodeURIComponent(key)
21352
21381
  + '=' + encodeURIComponent(val));
@@ -21369,18 +21398,13 @@ function pushEncodedKeyValuePair(pairs, key, val) {
21369
21398
  function parseString(str) {
21370
21399
  var obj = {};
21371
21400
  var pairs = str.split('&');
21401
+ var parts;
21372
21402
  var pair;
21373
- var pos;
21374
21403
 
21375
21404
  for (var i = 0, len = pairs.length; i < len; ++i) {
21376
21405
  pair = pairs[i];
21377
- pos = pair.indexOf('=');
21378
- if (pos == -1) {
21379
- obj[decodeURIComponent(pair)] = '';
21380
- } else {
21381
- obj[decodeURIComponent(pair.slice(0, pos))] =
21382
- decodeURIComponent(pair.slice(pos + 1));
21383
- }
21406
+ parts = pair.split('=');
21407
+ obj[decodeURIComponent(parts[0])] = decodeURIComponent(parts[1]);
21384
21408
  }
21385
21409
 
21386
21410
  return obj;
@@ -21564,15 +21588,15 @@ function Response(req, options) {
21564
21588
  ? this.xhr.responseText
21565
21589
  : null;
21566
21590
  this.statusText = this.req.xhr.statusText;
21567
- this._setStatusProperties(this.xhr.status);
21591
+ this.setStatusProperties(this.xhr.status);
21568
21592
  this.header = this.headers = parseHeader(this.xhr.getAllResponseHeaders());
21569
21593
  // getAllResponseHeaders sometimes falsely returns "" for CORS requests, but
21570
21594
  // getResponseHeader still works. so we get content-type even if getting
21571
21595
  // other headers fails.
21572
21596
  this.header['content-type'] = this.xhr.getResponseHeader('content-type');
21573
- this._setHeaderProperties(this.header);
21597
+ this.setHeaderProperties(this.header);
21574
21598
  this.body = this.req.method != 'HEAD'
21575
- ? this._parseBody(this.text ? this.text : this.xhr.response)
21599
+ ? this.parseBody(this.text ? this.text : this.xhr.response)
21576
21600
  : null;
21577
21601
  }
21578
21602
 
@@ -21600,7 +21624,7 @@ Response.prototype.get = function(field){
21600
21624
  * @api private
21601
21625
  */
21602
21626
 
21603
- Response.prototype._setHeaderProperties = function(header){
21627
+ Response.prototype.setHeaderProperties = function(header){
21604
21628
  // content-type
21605
21629
  var ct = this.header['content-type'] || '';
21606
21630
  this.type = type(ct);
@@ -21621,11 +21645,8 @@ Response.prototype._setHeaderProperties = function(header){
21621
21645
  * @api private
21622
21646
  */
21623
21647
 
21624
- Response.prototype._parseBody = function(str){
21648
+ Response.prototype.parseBody = function(str){
21625
21649
  var parse = request.parse[this.type];
21626
- if (!parse && isJSON(this.type)) {
21627
- parse = request.parse['application/json'];
21628
- }
21629
21650
  return parse && str && (str.length || str instanceof Object)
21630
21651
  ? parse(str)
21631
21652
  : null;
@@ -21652,7 +21673,7 @@ Response.prototype._parseBody = function(str){
21652
21673
  * @api private
21653
21674
  */
21654
21675
 
21655
- Response.prototype._setStatusProperties = function(status){
21676
+ Response.prototype.setStatusProperties = function(status){
21656
21677
  // handle IE9 bug: http://stackoverflow.com/questions/10046972/msie-returns-status-code-of-1223-for-ajax-request
21657
21678
  if (status === 1223) {
21658
21679
  status = 204;
@@ -21720,11 +21741,12 @@ request.Response = Response;
21720
21741
 
21721
21742
  function Request(method, url) {
21722
21743
  var self = this;
21744
+ Emitter.call(this);
21723
21745
  this._query = this._query || [];
21724
21746
  this.method = method;
21725
21747
  this.url = url;
21726
- this.header = {}; // preserves header name case
21727
- this._header = {}; // coerces header names to lowercase
21748
+ this.header = {};
21749
+ this._header = {};
21728
21750
  this.on('end', function(){
21729
21751
  var err = null;
21730
21752
  var res = null;
@@ -21737,8 +21759,6 @@ function Request(method, url) {
21737
21759
  err.original = e;
21738
21760
  // issue #675: return the raw response if the response parsing fails
21739
21761
  err.rawResponse = self.xhr && self.xhr.responseText ? self.xhr.responseText : null;
21740
- // issue #876: return the http status code if the response parsing fails
21741
- err.statusCode = self.xhr && self.xhr.status ? self.xhr.status : null;
21742
21762
  return self.callback(err);
21743
21763
  }
21744
21764
 
@@ -21748,38 +21768,146 @@ function Request(method, url) {
21748
21768
  return self.callback(err, res);
21749
21769
  }
21750
21770
 
21751
- try {
21752
- if (res.status >= 200 && res.status < 300) {
21753
- return self.callback(err, res);
21754
- }
21771
+ if (res.status >= 200 && res.status < 300) {
21772
+ return self.callback(err, res);
21773
+ }
21755
21774
 
21756
- var new_err = new Error(res.statusText || 'Unsuccessful HTTP response');
21757
- new_err.original = err;
21758
- new_err.response = res;
21759
- new_err.status = res.status;
21775
+ var new_err = new Error(res.statusText || 'Unsuccessful HTTP response');
21776
+ new_err.original = err;
21777
+ new_err.response = res;
21778
+ new_err.status = res.status;
21760
21779
 
21761
- self.callback(new_err, res);
21762
- } catch(e) {
21763
- self.callback(e); // #985 touching res may cause INVALID_STATE_ERR on old Android
21764
- }
21780
+ self.callback(new_err, res);
21765
21781
  });
21766
21782
  }
21767
21783
 
21768
21784
  /**
21769
- * Mixin `Emitter` and `requestBase`.
21785
+ * Mixin `Emitter`.
21770
21786
  */
21771
21787
 
21772
21788
  Emitter(Request.prototype);
21773
- for (var key in requestBase) {
21774
- Request.prototype[key] = requestBase[key];
21789
+
21790
+ /**
21791
+ * Allow for extension
21792
+ */
21793
+
21794
+ Request.prototype.use = function(fn) {
21795
+ fn(this);
21796
+ return this;
21775
21797
  }
21776
21798
 
21777
21799
  /**
21778
- * Set Content-Type to `type`, mapping values from `request.types`.
21779
- *
21780
- * Examples:
21800
+ * Set timeout to `ms`.
21781
21801
  *
21782
- * superagent.types.xml = 'application/xml';
21802
+ * @param {Number} ms
21803
+ * @return {Request} for chaining
21804
+ * @api public
21805
+ */
21806
+
21807
+ Request.prototype.timeout = function(ms){
21808
+ this._timeout = ms;
21809
+ return this;
21810
+ };
21811
+
21812
+ /**
21813
+ * Clear previous timeout.
21814
+ *
21815
+ * @return {Request} for chaining
21816
+ * @api public
21817
+ */
21818
+
21819
+ Request.prototype.clearTimeout = function(){
21820
+ this._timeout = 0;
21821
+ clearTimeout(this._timer);
21822
+ return this;
21823
+ };
21824
+
21825
+ /**
21826
+ * Abort the request, and clear potential timeout.
21827
+ *
21828
+ * @return {Request}
21829
+ * @api public
21830
+ */
21831
+
21832
+ Request.prototype.abort = function(){
21833
+ if (this.aborted) return;
21834
+ this.aborted = true;
21835
+ this.xhr.abort();
21836
+ this.clearTimeout();
21837
+ this.emit('abort');
21838
+ return this;
21839
+ };
21840
+
21841
+ /**
21842
+ * Set header `field` to `val`, or multiple fields with one object.
21843
+ *
21844
+ * Examples:
21845
+ *
21846
+ * req.get('/')
21847
+ * .set('Accept', 'application/json')
21848
+ * .set('X-API-Key', 'foobar')
21849
+ * .end(callback);
21850
+ *
21851
+ * req.get('/')
21852
+ * .set({ Accept: 'application/json', 'X-API-Key': 'foobar' })
21853
+ * .end(callback);
21854
+ *
21855
+ * @param {String|Object} field
21856
+ * @param {String} val
21857
+ * @return {Request} for chaining
21858
+ * @api public
21859
+ */
21860
+
21861
+ Request.prototype.set = function(field, val){
21862
+ if (isObject(field)) {
21863
+ for (var key in field) {
21864
+ this.set(key, field[key]);
21865
+ }
21866
+ return this;
21867
+ }
21868
+ this._header[field.toLowerCase()] = val;
21869
+ this.header[field] = val;
21870
+ return this;
21871
+ };
21872
+
21873
+ /**
21874
+ * Remove header `field`.
21875
+ *
21876
+ * Example:
21877
+ *
21878
+ * req.get('/')
21879
+ * .unset('User-Agent')
21880
+ * .end(callback);
21881
+ *
21882
+ * @param {String} field
21883
+ * @return {Request} for chaining
21884
+ * @api public
21885
+ */
21886
+
21887
+ Request.prototype.unset = function(field){
21888
+ delete this._header[field.toLowerCase()];
21889
+ delete this.header[field];
21890
+ return this;
21891
+ };
21892
+
21893
+ /**
21894
+ * Get case-insensitive header `field` value.
21895
+ *
21896
+ * @param {String} field
21897
+ * @return {String}
21898
+ * @api private
21899
+ */
21900
+
21901
+ Request.prototype.getHeader = function(field){
21902
+ return this._header[field.toLowerCase()];
21903
+ };
21904
+
21905
+ /**
21906
+ * Set Content-Type to `type`, mapping values from `request.types`.
21907
+ *
21908
+ * Examples:
21909
+ *
21910
+ * superagent.types.xml = 'application/xml';
21783
21911
  *
21784
21912
  * request.post('/')
21785
21913
  * .type('xml')
@@ -21802,22 +21930,16 @@ Request.prototype.type = function(type){
21802
21930
  };
21803
21931
 
21804
21932
  /**
21805
- * Set responseType to `val`. Presently valid responseTypes are 'blob' and
21806
- * 'arraybuffer'.
21807
- *
21808
- * Examples:
21933
+ * Force given parser
21809
21934
  *
21810
- * req.get('/')
21811
- * .responseType('blob')
21812
- * .end(callback);
21935
+ * Sets the body parser no matter type.
21813
21936
  *
21814
- * @param {String} val
21815
- * @return {Request} for chaining
21937
+ * @param {Function}
21816
21938
  * @api public
21817
21939
  */
21818
21940
 
21819
- Request.prototype.responseType = function(val){
21820
- this._responseType = val;
21941
+ Request.prototype.parse = function(fn){
21942
+ this._parser = fn;
21821
21943
  return this;
21822
21944
  };
21823
21945
 
@@ -21851,29 +21973,13 @@ Request.prototype.accept = function(type){
21851
21973
  *
21852
21974
  * @param {String} user
21853
21975
  * @param {String} pass
21854
- * @param {Object} options with 'type' property 'auto' or 'basic' (default 'basic')
21855
21976
  * @return {Request} for chaining
21856
21977
  * @api public
21857
21978
  */
21858
21979
 
21859
- Request.prototype.auth = function(user, pass, options){
21860
- if (!options) {
21861
- options = {
21862
- type: 'basic'
21863
- }
21864
- }
21865
-
21866
- switch (options.type) {
21867
- case 'basic':
21868
- var str = btoa(user + ':' + pass);
21869
- this.set('Authorization', 'Basic ' + str);
21870
- break;
21871
-
21872
- case 'auto':
21873
- this.username = user;
21874
- this.password = pass;
21875
- break;
21876
- }
21980
+ Request.prototype.auth = function(user, pass){
21981
+ var str = btoa(user + ':' + pass);
21982
+ this.set('Authorization', 'Basic ' + str);
21877
21983
  return this;
21878
21984
  };
21879
21985
 
@@ -21897,13 +22003,35 @@ Request.prototype.query = function(val){
21897
22003
  return this;
21898
22004
  };
21899
22005
 
22006
+ /**
22007
+ * Write the field `name` and `val` for "multipart/form-data"
22008
+ * request bodies.
22009
+ *
22010
+ * ``` js
22011
+ * request.post('/upload')
22012
+ * .field('foo', 'bar')
22013
+ * .end(callback);
22014
+ * ```
22015
+ *
22016
+ * @param {String} name
22017
+ * @param {String|Blob|File} val
22018
+ * @return {Request} for chaining
22019
+ * @api public
22020
+ */
22021
+
22022
+ Request.prototype.field = function(name, val){
22023
+ if (!this._formData) this._formData = new root.FormData();
22024
+ this._formData.append(name, val);
22025
+ return this;
22026
+ };
22027
+
21900
22028
  /**
21901
22029
  * Queue the given `file` as an attachment to the specified `field`,
21902
22030
  * with optional `filename`.
21903
22031
  *
21904
22032
  * ``` js
21905
22033
  * request.post('/upload')
21906
- * .attach('content', new Blob(['<a id="a"><b id="b">hey!</b></a>'], { type: "text/html"}))
22034
+ * .attach(new Blob(['<a id="a"><b id="b">hey!</b></a>'], { type: "text/html"}))
21907
22035
  * .end(callback);
21908
22036
  * ```
21909
22037
  *
@@ -21915,15 +22043,77 @@ Request.prototype.query = function(val){
21915
22043
  */
21916
22044
 
21917
22045
  Request.prototype.attach = function(field, file, filename){
21918
- this._getFormData().append(field, file, filename || file.name);
22046
+ if (!this._formData) this._formData = new root.FormData();
22047
+ this._formData.append(field, file, filename || file.name);
21919
22048
  return this;
21920
22049
  };
21921
22050
 
21922
- Request.prototype._getFormData = function(){
21923
- if (!this._formData) {
21924
- this._formData = new root.FormData();
22051
+ /**
22052
+ * Send `data` as the request body, defaulting the `.type()` to "json" when
22053
+ * an object is given.
22054
+ *
22055
+ * Examples:
22056
+ *
22057
+ * // manual json
22058
+ * request.post('/user')
22059
+ * .type('json')
22060
+ * .send('{"name":"tj"}')
22061
+ * .end(callback)
22062
+ *
22063
+ * // auto json
22064
+ * request.post('/user')
22065
+ * .send({ name: 'tj' })
22066
+ * .end(callback)
22067
+ *
22068
+ * // manual x-www-form-urlencoded
22069
+ * request.post('/user')
22070
+ * .type('form')
22071
+ * .send('name=tj')
22072
+ * .end(callback)
22073
+ *
22074
+ * // auto x-www-form-urlencoded
22075
+ * request.post('/user')
22076
+ * .type('form')
22077
+ * .send({ name: 'tj' })
22078
+ * .end(callback)
22079
+ *
22080
+ * // defaults to x-www-form-urlencoded
22081
+ * request.post('/user')
22082
+ * .send('name=tobi')
22083
+ * .send('species=ferret')
22084
+ * .end(callback)
22085
+ *
22086
+ * @param {String|Object} data
22087
+ * @return {Request} for chaining
22088
+ * @api public
22089
+ */
22090
+
22091
+ Request.prototype.send = function(data){
22092
+ var obj = isObject(data);
22093
+ var type = this.getHeader('Content-Type');
22094
+
22095
+ // merge
22096
+ if (obj && isObject(this._data)) {
22097
+ for (var key in data) {
22098
+ this._data[key] = data[key];
22099
+ }
22100
+ } else if ('string' == typeof data) {
22101
+ if (!type) this.type('form');
22102
+ type = this.getHeader('Content-Type');
22103
+ if ('application/x-www-form-urlencoded' == type) {
22104
+ this._data = this._data
22105
+ ? this._data + '&' + data
22106
+ : data;
22107
+ } else {
22108
+ this._data = (this._data || '') + data;
22109
+ }
22110
+ } else {
22111
+ this._data = data;
21925
22112
  }
21926
- return this._formData;
22113
+
22114
+ if (!obj || isHost(data)) return this;
22115
+ if (!type) this.type('json');
22116
+ return this;
21927
22117
  };
21928
22118
 
21929
22119
  /**
@@ -21964,7 +22154,7 @@ Request.prototype.crossDomainError = function(){
21964
22154
  * @api private
21965
22155
  */
21966
22156
 
21967
- Request.prototype._timeoutError = function(){
22157
+ Request.prototype.timeoutError = function(){
21968
22158
  var timeout = this._timeout;
21969
22159
  var err = new Error('timeout of ' + timeout + 'ms exceeded');
21970
22160
  err.timeout = timeout;
@@ -21972,18 +22162,19 @@ Request.prototype._timeoutError = function(){
21972
22162
  };
21973
22163
 
21974
22164
  /**
21975
- * Compose querystring to append to req.url
22165
+ * Enable transmission of cookies with x-domain requests.
21976
22166
  *
21977
- * @api private
22167
+ * Note that for this to work the origin must not be
22168
+ * using "Access-Control-Allow-Origin" with a wildcard,
22169
+ * and also must set "Access-Control-Allow-Credentials"
22170
+ * to "true".
22171
+ *
22172
+ * @api public
21978
22173
  */
21979
22174
 
21980
- Request.prototype._appendQueryString = function(){
21981
- var query = this._query.join('&');
21982
- if (query) {
21983
- this.url += ~this.url.indexOf('?')
21984
- ? '&' + query
21985
- : '?' + query;
21986
- }
22175
+ Request.prototype.withCredentials = function(){
22176
+ this._withCredentials = true;
22177
+ return this;
21987
22178
  };
21988
22179
 
21989
22180
  /**
@@ -21998,6 +22189,7 @@ Request.prototype._appendQueryString = function(){
21998
22189
  Request.prototype.end = function(fn){
21999
22190
  var self = this;
22000
22191
  var xhr = this.xhr = request.getXHR();
22192
+ var query = this._query.join('&');
22001
22193
  var timeout = this._timeout;
22002
22194
  var data = this._formData || this._data;
22003
22195
 
@@ -22014,8 +22206,8 @@ Request.prototype.end = function(fn){
22014
22206
  try { status = xhr.status } catch(e) { status = 0; }
22015
22207
 
22016
22208
  if (0 == status) {
22017
- if (self.timedout) return self._timeoutError();
22018
- if (self._aborted) return;
22209
+ if (self.timedout) return self.timeoutError();
22210
+ if (self.aborted) return;
22019
22211
  return self.crossDomainError();
22020
22212
  }
22021
22213
  self.emit('end');
@@ -22051,23 +22243,24 @@ Request.prototype.end = function(fn){
22051
22243
  }
22052
22244
 
22053
22245
  // querystring
22054
- this._appendQueryString();
22246
+ if (query) {
22247
+ query = request.serializeObject(query);
22248
+ this.url += ~this.url.indexOf('?')
22249
+ ? '&' + query
22250
+ : '?' + query;
22251
+ }
22055
22252
 
22056
22253
  // initiate request
22057
- if (this.username && this.password) {
22058
- xhr.open(this.method, this.url, true, this.username, this.password);
22059
- } else {
22060
- xhr.open(this.method, this.url, true);
22061
- }
22254
+ xhr.open(this.method, this.url, true);
22062
22255
 
22063
22256
  // CORS
22064
22257
  if (this._withCredentials) xhr.withCredentials = true;
22065
22258
 
22066
22259
  // body
22067
- if ('GET' != this.method && 'HEAD' != this.method && 'string' != typeof data && !this._isHost(data)) {
22260
+ if ('GET' != this.method && 'HEAD' != this.method && 'string' != typeof data && !isHost(data)) {
22068
22261
  // serialize stuff
22069
- var contentType = this._header['content-type'];
22070
- var serialize = this._serializer || request.serialize[contentType ? contentType.split(';')[0] : ''];
22262
+ var contentType = this.getHeader('Content-Type');
22263
+ var serialize = this._parser || request.serialize[contentType ? contentType.split(';')[0] : ''];
22071
22264
  if (!serialize && isJSON(contentType)) serialize = request.serialize['application/json'];
22072
22265
  if (serialize) data = serialize(data);
22073
22266
  }
@@ -22078,10 +22271,6 @@ Request.prototype.end = function(fn){
22078
22271
  xhr.setRequestHeader(field, this.header[field]);
22079
22272
  }
22080
22273
 
22081
- if (this._responseType) {
22082
- xhr.responseType = this._responseType;
22083
- }
22084
-
22085
22274
  // send stuff
22086
22275
  this.emit('request', this);
22087
22276
 
@@ -22091,6 +22280,19 @@ Request.prototype.end = function(fn){
22091
22280
  return this;
22092
22281
  };
22093
22282
 
22283
+ /**
22284
+ * Faux promise support
22285
+ *
22286
+ * @param {Function} fulfill
22287
+ * @param {Function} reject
22288
+ * @return {Request}
22289
+ */
22290
+
22291
+ Request.prototype.then = function (fulfill, reject) {
22292
+ return this.end(function(err, res) {
22293
+ err ? reject(err) : fulfill(res);
22294
+ });
22295
+ }
22094
22296
 
22095
22297
  /**
22096
22298
  * Expose `Request`.
@@ -22099,25 +22301,36 @@ Request.prototype.end = function(fn){
22099
22301
  request.Request = Request;
22100
22302
 
22101
22303
  /**
22102
- * GET `url` with optional callback `fn(res)`.
22304
+ * Issue a request:
22103
22305
  *
22104
- * @param {String} url
22105
- * @param {Mixed|Function} data or fn
22106
- * @param {Function} fn
22306
+ * Examples:
22307
+ *
22308
+ * request('GET', '/users').end(callback)
22309
+ * request('/users').end(callback)
22310
+ * request('/users', callback)
22311
+ *
22312
+ * @param {String} method
22313
+ * @param {String|Function} url or callback
22107
22314
  * @return {Request}
22108
22315
  * @api public
22109
22316
  */
22110
22317
 
22111
- request.get = function(url, data, fn){
22112
- var req = request('GET', url);
22113
- if ('function' == typeof data) fn = data, data = null;
22114
- if (data) req.query(data);
22115
- if (fn) req.end(fn);
22116
- return req;
22117
- };
22318
+ function request(method, url) {
22319
+ // callback
22320
+ if ('function' == typeof url) {
22321
+ return new Request('GET', method).end(url);
22322
+ }
22323
+
22324
+ // url first
22325
+ if (1 == arguments.length) {
22326
+ return new Request('GET', method);
22327
+ }
22328
+
22329
+ return new Request(method, url);
22330
+ }
22118
22331
 
22119
22332
  /**
22120
- * HEAD `url` with optional callback `fn(res)`.
22333
+ * GET `url` with optional callback `fn(res)`.
22121
22334
  *
22122
22335
  * @param {String} url
22123
22336
  * @param {Mixed|Function} data or fn
@@ -22126,16 +22339,16 @@ request.get = function(url, data, fn){
22126
22339
  * @api public
22127
22340
  */
22128
22341
 
22129
- request.head = function(url, data, fn){
22130
- var req = request('HEAD', url);
22342
+ request.get = function(url, data, fn){
22343
+ var req = request('GET', url);
22131
22344
  if ('function' == typeof data) fn = data, data = null;
22132
- if (data) req.send(data);
22345
+ if (data) req.query(data);
22133
22346
  if (fn) req.end(fn);
22134
22347
  return req;
22135
22348
  };
22136
22349
 
22137
22350
  /**
22138
- * OPTIONS query to `url` with optional callback `fn(res)`.
22351
+ * HEAD `url` with optional callback `fn(res)`.
22139
22352
  *
22140
22353
  * @param {String} url
22141
22354
  * @param {Mixed|Function} data or fn
@@ -22144,8 +22357,8 @@ request.head = function(url, data, fn){
22144
22357
  * @api public
22145
22358
  */
22146
22359
 
22147
- request.options = function(url, data, fn){
22148
- var req = request('OPTIONS', url);
22360
+ request.head = function(url, data, fn){
22361
+ var req = request('HEAD', url);
22149
22362
  if ('function' == typeof data) fn = data, data = null;
22150
22363
  if (data) req.send(data);
22151
22364
  if (fn) req.end(fn);
@@ -22224,404 +22437,13 @@ request.put = function(url, data, fn){
22224
22437
  return req;
22225
22438
  };
22226
22439
 
22227
- },{"./is-object":50,"./request":52,"./request-base":51,"emitter":40,"reduce":47}],50:[function(require,module,exports){
22228
22440
  /**
22229
- * Check if `obj` is an object.
22230
- *
22231
- * @param {Object} obj
22232
- * @return {Boolean}
22233
- * @api private
22441
+ * Expose `request`.
22234
22442
  */
22235
22443
 
22236
- function isObject(obj) {
22237
- return null !== obj && 'object' === typeof obj;
22238
- }
22239
-
22240
- module.exports = isObject;
22241
-
22242
- },{}],51:[function(require,module,exports){
22243
- /**
22244
- * Module of mixed-in functions shared between node and client code
22245
- */
22246
- var isObject = require('./is-object');
22247
-
22248
- /**
22249
- * Clear previous timeout.
22250
- *
22251
- * @return {Request} for chaining
22252
- * @api public
22253
- */
22254
-
22255
- exports.clearTimeout = function _clearTimeout(){
22256
- this._timeout = 0;
22257
- clearTimeout(this._timer);
22258
- return this;
22259
- };
22260
-
22261
- /**
22262
- * Override default response body parser
22263
- *
22264
- * This function will be called to convert incoming data into request.body
22265
- *
22266
- * @param {Function}
22267
- * @api public
22268
- */
22269
-
22270
- exports.parse = function parse(fn){
22271
- this._parser = fn;
22272
- return this;
22273
- };
22274
-
22275
- /**
22276
- * Override default request body serializer
22277
- *
22278
- * This function will be called to convert data set via .send or .attach into payload to send
22279
- *
22280
- * @param {Function}
22281
- * @api public
22282
- */
22283
-
22284
- exports.serialize = function serialize(fn){
22285
- this._serializer = fn;
22286
- return this;
22287
- };
22288
-
22289
- /**
22290
- * Set timeout to `ms`.
22291
- *
22292
- * @param {Number} ms
22293
- * @return {Request} for chaining
22294
- * @api public
22295
- */
22296
-
22297
- exports.timeout = function timeout(ms){
22298
- this._timeout = ms;
22299
- return this;
22300
- };
22301
-
22302
- /**
22303
- * Promise support
22304
- *
22305
- * @param {Function} resolve
22306
- * @param {Function} reject
22307
- * @return {Request}
22308
- */
22309
-
22310
- exports.then = function then(resolve, reject) {
22311
- if (!this._fullfilledPromise) {
22312
- var self = this;
22313
- this._fullfilledPromise = new Promise(function(innerResolve, innerReject){
22314
- self.end(function(err, res){
22315
- if (err) innerReject(err); else innerResolve(res);
22316
- });
22317
- });
22318
- }
22319
- return this._fullfilledPromise.then(resolve, reject);
22320
- }
22321
-
22322
- /**
22323
- * Allow for extension
22324
- */
22325
-
22326
- exports.use = function use(fn) {
22327
- fn(this);
22328
- return this;
22329
- }
22330
-
22331
-
22332
- /**
22333
- * Get request header `field`.
22334
- * Case-insensitive.
22335
- *
22336
- * @param {String} field
22337
- * @return {String}
22338
- * @api public
22339
- */
22340
-
22341
- exports.get = function(field){
22342
- return this._header[field.toLowerCase()];
22343
- };
22344
-
22345
- /**
22346
- * Get case-insensitive header `field` value.
22347
- * This is a deprecated internal API. Use `.get(field)` instead.
22348
- *
22349
- * (getHeader is no longer used internally by the superagent code base)
22350
- *
22351
- * @param {String} field
22352
- * @return {String}
22353
- * @api private
22354
- * @deprecated
22355
- */
22356
-
22357
- exports.getHeader = exports.get;
22358
-
22359
- /**
22360
- * Set header `field` to `val`, or multiple fields with one object.
22361
- * Case-insensitive.
22362
- *
22363
- * Examples:
22364
- *
22365
- * req.get('/')
22366
- * .set('Accept', 'application/json')
22367
- * .set('X-API-Key', 'foobar')
22368
- * .end(callback);
22369
- *
22370
- * req.get('/')
22371
- * .set({ Accept: 'application/json', 'X-API-Key': 'foobar' })
22372
- * .end(callback);
22373
- *
22374
- * @param {String|Object} field
22375
- * @param {String} val
22376
- * @return {Request} for chaining
22377
- * @api public
22378
- */
22379
-
22380
- exports.set = function(field, val){
22381
- if (isObject(field)) {
22382
- for (var key in field) {
22383
- this.set(key, field[key]);
22384
- }
22385
- return this;
22386
- }
22387
- this._header[field.toLowerCase()] = val;
22388
- this.header[field] = val;
22389
- return this;
22390
- };
22391
-
22392
- /**
22393
- * Remove header `field`.
22394
- * Case-insensitive.
22395
- *
22396
- * Example:
22397
- *
22398
- * req.get('/')
22399
- * .unset('User-Agent')
22400
- * .end(callback);
22401
- *
22402
- * @param {String} field
22403
- */
22404
- exports.unset = function(field){
22405
- delete this._header[field.toLowerCase()];
22406
- delete this.header[field];
22407
- return this;
22408
- };
22409
-
22410
- /**
22411
- * Write the field `name` and `val` for "multipart/form-data"
22412
- * request bodies.
22413
- *
22414
- * ``` js
22415
- * request.post('/upload')
22416
- * .field('foo', 'bar')
22417
- * .end(callback);
22418
- * ```
22419
- *
22420
- * @param {String} name
22421
- * @param {String|Blob|File|Buffer|fs.ReadStream} val
22422
- * @return {Request} for chaining
22423
- * @api public
22424
- */
22425
- exports.field = function(name, val) {
22426
- this._getFormData().append(name, val);
22427
- return this;
22428
- };
22429
-
22430
- /**
22431
- * Abort the request, and clear potential timeout.
22432
- *
22433
- * @return {Request}
22434
- * @api public
22435
- */
22436
- exports.abort = function(){
22437
- if (this._aborted) {
22438
- return this;
22439
- }
22440
- this._aborted = true;
22441
- this.xhr && this.xhr.abort(); // browser
22442
- this.req && this.req.abort(); // node
22443
- this.clearTimeout();
22444
- this.emit('abort');
22445
- return this;
22446
- };
22447
-
22448
- /**
22449
- * Enable transmission of cookies with x-domain requests.
22450
- *
22451
- * Note that for this to work the origin must not be
22452
- * using "Access-Control-Allow-Origin" with a wildcard,
22453
- * and also must set "Access-Control-Allow-Credentials"
22454
- * to "true".
22455
- *
22456
- * @api public
22457
- */
22458
-
22459
- exports.withCredentials = function(){
22460
- // This is browser-only functionality. Node side is no-op.
22461
- this._withCredentials = true;
22462
- return this;
22463
- };
22464
-
22465
- /**
22466
- * Set the max redirects to `n`. Does noting in browser XHR implementation.
22467
- *
22468
- * @param {Number} n
22469
- * @return {Request} for chaining
22470
- * @api public
22471
- */
22472
-
22473
- exports.redirects = function(n){
22474
- this._maxRedirects = n;
22475
- return this;
22476
- };
22477
-
22478
- /**
22479
- * Convert to a plain javascript object (not JSON string) of scalar properties.
22480
- * Note as this method is designed to return a useful non-this value,
22481
- * it cannot be chained.
22482
- *
22483
- * @return {Object} describing method, url, and data of this request
22484
- * @api public
22485
- */
22486
-
22487
- exports.toJSON = function(){
22488
- return {
22489
- method: this.method,
22490
- url: this.url,
22491
- data: this._data
22492
- };
22493
- };
22494
-
22495
- /**
22496
- * Check if `obj` is a host object,
22497
- * we don't want to serialize these :)
22498
- *
22499
- * TODO: future proof, move to compoent land
22500
- *
22501
- * @param {Object} obj
22502
- * @return {Boolean}
22503
- * @api private
22504
- */
22505
-
22506
- exports._isHost = function _isHost(obj) {
22507
- var str = {}.toString.call(obj);
22508
-
22509
- switch (str) {
22510
- case '[object File]':
22511
- case '[object Blob]':
22512
- case '[object FormData]':
22513
- return true;
22514
- default:
22515
- return false;
22516
- }
22517
- }
22518
-
22519
- /**
22520
- * Send `data` as the request body, defaulting the `.type()` to "json" when
22521
- * an object is given.
22522
- *
22523
- * Examples:
22524
- *
22525
- * // manual json
22526
- * request.post('/user')
22527
- * .type('json')
22528
- * .send('{"name":"tj"}')
22529
- * .end(callback)
22530
- *
22531
- * // auto json
22532
- * request.post('/user')
22533
- * .send({ name: 'tj' })
22534
- * .end(callback)
22535
- *
22536
- * // manual x-www-form-urlencoded
22537
- * request.post('/user')
22538
- * .type('form')
22539
- * .send('name=tj')
22540
- * .end(callback)
22541
- *
22542
- * // auto x-www-form-urlencoded
22543
- * request.post('/user')
22544
- * .type('form')
22545
- * .send({ name: 'tj' })
22546
- * .end(callback)
22547
- *
22548
- * // defaults to x-www-form-urlencoded
22549
- * request.post('/user')
22550
- * .send('name=tobi')
22551
- * .send('species=ferret')
22552
- * .end(callback)
22553
- *
22554
- * @param {String|Object} data
22555
- * @return {Request} for chaining
22556
- * @api public
22557
- */
22558
-
22559
- exports.send = function(data){
22560
- var obj = isObject(data);
22561
- var type = this._header['content-type'];
22562
-
22563
- // merge
22564
- if (obj && isObject(this._data)) {
22565
- for (var key in data) {
22566
- this._data[key] = data[key];
22567
- }
22568
- } else if ('string' == typeof data) {
22569
- // default to x-www-form-urlencoded
22570
- if (!type) this.type('form');
22571
- type = this._header['content-type'];
22572
- if ('application/x-www-form-urlencoded' == type) {
22573
- this._data = this._data
22574
- ? this._data + '&' + data
22575
- : data;
22576
- } else {
22577
- this._data = (this._data || '') + data;
22578
- }
22579
- } else {
22580
- this._data = data;
22581
- }
22582
-
22583
- if (!obj || this._isHost(data)) return this;
22584
-
22585
- // default to json
22586
- if (!type) this.type('json');
22587
- return this;
22588
- };
22589
-
22590
- },{"./is-object":50}],52:[function(require,module,exports){
22591
- // The node and browser modules expose versions of this with the
22592
- // appropriate constructor function bound as first argument
22593
- /**
22594
- * Issue a request:
22595
- *
22596
- * Examples:
22597
- *
22598
- * request('GET', '/users').end(callback)
22599
- * request('/users').end(callback)
22600
- * request('/users', callback)
22601
- *
22602
- * @param {String} method
22603
- * @param {String|Function} url or callback
22604
- * @return {Request}
22605
- * @api public
22606
- */
22607
-
22608
- function request(RequestConstructor, method, url) {
22609
- // callback
22610
- if ('function' == typeof url) {
22611
- return new RequestConstructor('GET', method).end(url);
22612
- }
22613
-
22614
- // url first
22615
- if (2 == arguments.length) {
22616
- return new RequestConstructor('GET', method);
22617
- }
22618
-
22619
- return new RequestConstructor(method, url);
22620
- }
22621
-
22622
22444
  module.exports = request;
22623
22445
 
22624
- },{}],53:[function(require,module,exports){
22446
+ },{"emitter":40,"reduce":47}],50:[function(require,module,exports){
22625
22447
  /*!
22626
22448
  * validate.js 0.9.0
22627
22449
  *