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.
package/dist/parse.js CHANGED
@@ -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,
@@ -3611,7 +3611,9 @@ function estimateAttributes(serverData /*: AttributeMap*/, pendingOps /*: Array<
3611
3611
  function nestedSet(obj, key, value) {
3612
3612
  var path = key.split('.');
3613
3613
  for (var i = 0; i < path.length - 1; i++) {
3614
- if (!(path[i] in obj)) obj[path[i]] = {};
3614
+ if (!(path[i] in obj)) {
3615
+ obj[path[i]] = {};
3616
+ }
3615
3617
  obj = obj[path[i]];
3616
3618
  }
3617
3619
  if (typeof value === 'undefined') {
@@ -4240,7 +4242,7 @@ function matchesKeyConstraints(className, object, objects, key, constraints) {
4240
4242
  var _distance = point.radiansTo(centerPoint);
4241
4243
  return _distance <= maxDistance;
4242
4244
  }
4243
- break;
4245
+ return false;
4244
4246
  }
4245
4247
  case '$geoIntersects':
4246
4248
  {
@@ -9024,7 +9026,7 @@ var ParseObject = /*#__PURE__*/function () {
9024
9026
  /**
9025
9027
  * Returns the ACL for this object.
9026
9028
  *
9027
- * @returns {Parse.ACL} An instance of Parse.ACL.
9029
+ * @returns {Parse.ACL|null} An instance of Parse.ACL.
9028
9030
  * @see Parse.Object#get
9029
9031
  */
9030
9032
  }, {
@@ -14333,7 +14335,7 @@ var _ParseCLP = _interopRequireDefault(_dereq_("./ParseCLP"));
14333
14335
  * @flow
14334
14336
  */
14335
14337
  /*:: import type { PermissionsMap } from './ParseCLP';*/
14336
- var FIELD_TYPES = ['String', 'Number', 'Boolean', 'Date', 'File', 'GeoPoint', 'Polygon', 'Array', 'Object', 'Pointer', 'Relation'];
14338
+ var FIELD_TYPES = ['String', 'Number', 'Boolean', 'Bytes', 'Date', 'File', 'GeoPoint', 'Polygon', 'Array', 'Object', 'Pointer', 'Relation'];
14337
14339
  /*:: type FieldOptions = {
14338
14340
  required: boolean,
14339
14341
  defaultValue: mixed,
@@ -14552,6 +14554,14 @@ var ParseSchema = /*#__PURE__*/function () {
14552
14554
  };
14553
14555
  }
14554
14556
  }
14557
+ if (type === 'Bytes') {
14558
+ if (options && options.defaultValue) {
14559
+ fieldOptions.defaultValue = {
14560
+ __type: 'Bytes',
14561
+ base64: options.defaultValue
14562
+ };
14563
+ }
14564
+ }
14555
14565
  this._fields[name] = fieldOptions;
14556
14566
  return this;
14557
14567
  }
@@ -14619,6 +14629,19 @@ var ParseSchema = /*#__PURE__*/function () {
14619
14629
  return this.addField(name, 'Boolean', options);
14620
14630
  }
14621
14631
 
14632
+ /**
14633
+ * Adding Bytes Field
14634
+ *
14635
+ * @param {string} name Name of the field that will be created on Parse
14636
+ * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
14637
+ * @returns {Parse.Schema} Returns the schema, so you can chain this call.
14638
+ */
14639
+ }, {
14640
+ key: "addBytes",
14641
+ value: function (name /*: string*/, options /*: FieldOptions*/) {
14642
+ return this.addField(name, 'Bytes', options);
14643
+ }
14644
+
14622
14645
  /**
14623
14646
  * Adding Date Field
14624
14647
  *
@@ -15142,8 +15165,14 @@ var ParseUser = /*#__PURE__*/function (_ParseObject) {
15142
15165
  throw new Error('Invalid type: authData field should be an object');
15143
15166
  }
15144
15167
  authData[authType] = options.authData;
15168
+ var oldAnonymousData = authData.anonymous;
15169
+ this.stripAnonymity();
15145
15170
  var controller = _CoreManager.default.getUserController();
15146
- return controller.linkWith(this, authData, saveOpts);
15171
+ return controller.linkWith(this, authData, saveOpts).catch(function (e) {
15172
+ delete authData[authType];
15173
+ _this2.restoreAnonimity(oldAnonymousData);
15174
+ throw e;
15175
+ });
15147
15176
  } else {
15148
15177
  return new _promise.default(function (resolve, reject) {
15149
15178
  provider.authenticate({
@@ -15374,6 +15403,24 @@ var ParseUser = /*#__PURE__*/function (_ParseObject) {
15374
15403
  }
15375
15404
  return isCurrentAsync;
15376
15405
  }()
15406
+ }, {
15407
+ key: "stripAnonymity",
15408
+ value: function () {
15409
+ var authData = this.get('authData');
15410
+ if (authData && (0, _typeof2.default)(authData) === 'object' && authData.hasOwnProperty('anonymous')) {
15411
+ // We need to set anonymous to null instead of deleting it in order to remove it from Parse.
15412
+ authData.anonymous = null;
15413
+ }
15414
+ }
15415
+ }, {
15416
+ key: "restoreAnonimity",
15417
+ value: function (anonymousData /*: any*/) {
15418
+ if (anonymousData) {
15419
+ var authData = this.get('authData');
15420
+ authData.anonymous = anonymousData;
15421
+ }
15422
+ }
15423
+
15377
15424
  /**
15378
15425
  * Returns get("username").
15379
15426
  *
@@ -15397,12 +15444,7 @@ var ParseUser = /*#__PURE__*/function (_ParseObject) {
15397
15444
  }, {
15398
15445
  key: "setUsername",
15399
15446
  value: function (username /*: string*/) {
15400
- // Strip anonymity
15401
- var authData = this.get('authData');
15402
- if (authData && (0, _typeof2.default)(authData) === 'object' && authData.hasOwnProperty('anonymous')) {
15403
- // We need to set anonymous to null instead of deleting it in order to remove it from Parse.
15404
- authData.anonymous = null;
15405
- }
15447
+ this.stripAnonymity();
15406
15448
  this.set('username', username);
15407
15449
  }
15408
15450
 
@@ -18591,7 +18633,10 @@ function _regeneratorRuntime() {
18591
18633
  if ("executing" === state) throw new Error("Generator is already running");
18592
18634
  if ("completed" === state) {
18593
18635
  if ("throw" === method) throw arg;
18594
- return doneResult();
18636
+ return {
18637
+ value: void 0,
18638
+ done: !0
18639
+ };
18595
18640
  }
18596
18641
  for (context.method = method, context.arg = arg;;) {
18597
18642
  var delegate = context.delegate;
@@ -18645,7 +18690,7 @@ function _regeneratorRuntime() {
18645
18690
  }], _forEachInstanceProperty(tryLocsList).call(tryLocsList, pushTryEntry, this), this.reset(!0);
18646
18691
  }
18647
18692
  function values(iterable) {
18648
- if (iterable) {
18693
+ if (iterable || "" === iterable) {
18649
18694
  var iteratorMethod = iterable[iteratorSymbol];
18650
18695
  if (iteratorMethod) return iteratorMethod.call(iterable);
18651
18696
  if ("function" == typeof iterable.next) return iterable;
@@ -18658,15 +18703,7 @@ function _regeneratorRuntime() {
18658
18703
  return next.next = next;
18659
18704
  }
18660
18705
  }
18661
- return {
18662
- next: doneResult
18663
- };
18664
- }
18665
- function doneResult() {
18666
- return {
18667
- value: undefined,
18668
- done: !0
18669
- };
18706
+ throw new TypeError(_typeof(iterable) + " is not iterable");
18670
18707
  }
18671
18708
  return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", {
18672
18709
  value: GeneratorFunctionPrototype,