parse 4.2.0-alpha.5 → 4.2.0-alpha.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Parse JavaScript SDK v4.2.0-alpha.5
2
+ * Parse JavaScript SDK v4.2.0-alpha.7
3
3
  *
4
4
  * The source tree of this library can be found at
5
5
  * https://github.com/ParsePlatform/Parse-SDK-JS
@@ -538,7 +538,7 @@ var config /*: Config & { [key: string]: mixed }*/ = {
538
538
  SERVER_AUTH_TOKEN: null,
539
539
  LIVEQUERY_SERVER_URL: null,
540
540
  ENCRYPTED_KEY: null,
541
- VERSION: 'js' + "4.2.0-alpha.5",
541
+ VERSION: 'js' + "4.2.0-alpha.7",
542
542
  APPLICATION_ID: null,
543
543
  JAVASCRIPT_KEY: null,
544
544
  MASTER_KEY: null,
@@ -3576,7 +3576,9 @@ function estimateAttributes(serverData /*: AttributeMap*/, pendingOps /*: Array<
3576
3576
  function nestedSet(obj, key, value) {
3577
3577
  var path = key.split('.');
3578
3578
  for (var i = 0; i < path.length - 1; i++) {
3579
- if (!(path[i] in obj)) obj[path[i]] = {};
3579
+ if (!(path[i] in obj)) {
3580
+ obj[path[i]] = {};
3581
+ }
3580
3582
  obj = obj[path[i]];
3581
3583
  }
3582
3584
  if (typeof value === 'undefined') {
@@ -4205,7 +4207,7 @@ function matchesKeyConstraints(className, object, objects, key, constraints) {
4205
4207
  var _distance = point.radiansTo(centerPoint);
4206
4208
  return _distance <= maxDistance;
4207
4209
  }
4208
- break;
4210
+ return false;
4209
4211
  }
4210
4212
  case '$geoIntersects':
4211
4213
  {
@@ -8982,7 +8984,7 @@ var ParseObject = /*#__PURE__*/function () {
8982
8984
  /**
8983
8985
  * Returns the ACL for this object.
8984
8986
  *
8985
- * @returns {Parse.ACL} An instance of Parse.ACL.
8987
+ * @returns {Parse.ACL|null} An instance of Parse.ACL.
8986
8988
  * @see Parse.Object#get
8987
8989
  */
8988
8990
  }, {
@@ -14291,7 +14293,7 @@ var _ParseCLP = _interopRequireDefault(_dereq_("./ParseCLP"));
14291
14293
  * @flow
14292
14294
  */
14293
14295
  /*:: import type { PermissionsMap } from './ParseCLP';*/
14294
- var FIELD_TYPES = ['String', 'Number', 'Boolean', 'Date', 'File', 'GeoPoint', 'Polygon', 'Array', 'Object', 'Pointer', 'Relation'];
14296
+ var FIELD_TYPES = ['String', 'Number', 'Boolean', 'Bytes', 'Date', 'File', 'GeoPoint', 'Polygon', 'Array', 'Object', 'Pointer', 'Relation'];
14295
14297
  /*:: type FieldOptions = {
14296
14298
  required: boolean,
14297
14299
  defaultValue: mixed,
@@ -14510,6 +14512,14 @@ var ParseSchema = /*#__PURE__*/function () {
14510
14512
  };
14511
14513
  }
14512
14514
  }
14515
+ if (type === 'Bytes') {
14516
+ if (options && options.defaultValue) {
14517
+ fieldOptions.defaultValue = {
14518
+ __type: 'Bytes',
14519
+ base64: options.defaultValue
14520
+ };
14521
+ }
14522
+ }
14513
14523
  this._fields[name] = fieldOptions;
14514
14524
  return this;
14515
14525
  }
@@ -14577,6 +14587,19 @@ var ParseSchema = /*#__PURE__*/function () {
14577
14587
  return this.addField(name, 'Boolean', options);
14578
14588
  }
14579
14589
 
14590
+ /**
14591
+ * Adding Bytes Field
14592
+ *
14593
+ * @param {string} name Name of the field that will be created on Parse
14594
+ * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
14595
+ * @returns {Parse.Schema} Returns the schema, so you can chain this call.
14596
+ */
14597
+ }, {
14598
+ key: "addBytes",
14599
+ value: function (name /*: string*/, options /*: FieldOptions*/) {
14600
+ return this.addField(name, 'Bytes', options);
14601
+ }
14602
+
14580
14603
  /**
14581
14604
  * Adding Date Field
14582
14605
  *
@@ -15100,8 +15123,14 @@ var ParseUser = /*#__PURE__*/function (_ParseObject) {
15100
15123
  throw new Error('Invalid type: authData field should be an object');
15101
15124
  }
15102
15125
  authData[authType] = options.authData;
15126
+ var oldAnonymousData = authData.anonymous;
15127
+ this.stripAnonymity();
15103
15128
  var controller = _CoreManager.default.getUserController();
15104
- return controller.linkWith(this, authData, saveOpts);
15129
+ return controller.linkWith(this, authData, saveOpts).catch(function (e) {
15130
+ delete authData[authType];
15131
+ _this2.restoreAnonimity(oldAnonymousData);
15132
+ throw e;
15133
+ });
15105
15134
  } else {
15106
15135
  return new _promise.default(function (resolve, reject) {
15107
15136
  provider.authenticate({
@@ -15332,6 +15361,24 @@ var ParseUser = /*#__PURE__*/function (_ParseObject) {
15332
15361
  }
15333
15362
  return isCurrentAsync;
15334
15363
  }()
15364
+ }, {
15365
+ key: "stripAnonymity",
15366
+ value: function () {
15367
+ var authData = this.get('authData');
15368
+ if (authData && (0, _typeof2.default)(authData) === 'object' && authData.hasOwnProperty('anonymous')) {
15369
+ // We need to set anonymous to null instead of deleting it in order to remove it from Parse.
15370
+ authData.anonymous = null;
15371
+ }
15372
+ }
15373
+ }, {
15374
+ key: "restoreAnonimity",
15375
+ value: function (anonymousData /*: any*/) {
15376
+ if (anonymousData) {
15377
+ var authData = this.get('authData');
15378
+ authData.anonymous = anonymousData;
15379
+ }
15380
+ }
15381
+
15335
15382
  /**
15336
15383
  * Returns get("username").
15337
15384
  *
@@ -15355,12 +15402,7 @@ var ParseUser = /*#__PURE__*/function (_ParseObject) {
15355
15402
  }, {
15356
15403
  key: "setUsername",
15357
15404
  value: function (username /*: string*/) {
15358
- // Strip anonymity
15359
- var authData = this.get('authData');
15360
- if (authData && (0, _typeof2.default)(authData) === 'object' && authData.hasOwnProperty('anonymous')) {
15361
- // We need to set anonymous to null instead of deleting it in order to remove it from Parse.
15362
- authData.anonymous = null;
15363
- }
15405
+ this.stripAnonymity();
15364
15406
  this.set('username', username);
15365
15407
  }
15366
15408
 
@@ -18704,7 +18746,10 @@ function _regeneratorRuntime() {
18704
18746
  if ("executing" === state) throw new Error("Generator is already running");
18705
18747
  if ("completed" === state) {
18706
18748
  if ("throw" === method) throw arg;
18707
- return doneResult();
18749
+ return {
18750
+ value: void 0,
18751
+ done: !0
18752
+ };
18708
18753
  }
18709
18754
  for (context.method = method, context.arg = arg;;) {
18710
18755
  var delegate = context.delegate;
@@ -18758,7 +18803,7 @@ function _regeneratorRuntime() {
18758
18803
  }], _forEachInstanceProperty(tryLocsList).call(tryLocsList, pushTryEntry, this), this.reset(!0);
18759
18804
  }
18760
18805
  function values(iterable) {
18761
- if (iterable) {
18806
+ if (iterable || "" === iterable) {
18762
18807
  var iteratorMethod = iterable[iteratorSymbol];
18763
18808
  if (iteratorMethod) return iteratorMethod.call(iterable);
18764
18809
  if ("function" == typeof iterable.next) return iterable;
@@ -18771,15 +18816,7 @@ function _regeneratorRuntime() {
18771
18816
  return next.next = next;
18772
18817
  }
18773
18818
  }
18774
- return {
18775
- next: doneResult
18776
- };
18777
- }
18778
- function doneResult() {
18779
- return {
18780
- value: undefined,
18781
- done: !0
18782
- };
18819
+ throw new TypeError(_typeof(iterable) + " is not iterable");
18783
18820
  }
18784
18821
  return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", {
18785
18822
  value: GeneratorFunctionPrototype,