parse 5.1.0 → 5.2.0-alpha.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.
Files changed (143) hide show
  1. package/dist/parse.js +1556 -1309
  2. package/dist/parse.min.js +2 -2
  3. package/dist/parse.weapp.js +1560 -1313
  4. package/dist/parse.weapp.min.js +2 -2
  5. package/lib/browser/Cloud.js +7 -11
  6. package/lib/browser/CoreManager.js +10 -10
  7. package/lib/browser/EventuallyQueue.js +1 -1
  8. package/lib/browser/InstallationController.js +3 -3
  9. package/lib/browser/LiveQueryClient.js +102 -60
  10. package/lib/browser/LocalDatastore.js +189 -147
  11. package/lib/browser/LocalDatastoreController.default.js +14 -9
  12. package/lib/browser/LocalDatastoreController.react-native.js +14 -12
  13. package/lib/browser/LocalDatastoreUtils.js +0 -5
  14. package/lib/browser/ObjectStateMutations.js +57 -21
  15. package/lib/browser/Parse.js +2 -2
  16. package/lib/browser/ParseCLP.js +9 -17
  17. package/lib/browser/ParseFile.js +27 -31
  18. package/lib/browser/ParseGeoPoint.js +9 -3
  19. package/lib/browser/ParseHooks.js +13 -13
  20. package/lib/browser/ParseInstallation.js +117 -9
  21. package/lib/browser/ParseObject.js +19 -17
  22. package/lib/browser/ParseOp.js +17 -17
  23. package/lib/browser/ParsePolygon.js +1 -1
  24. package/lib/browser/ParseQuery.js +147 -149
  25. package/lib/browser/ParseRole.js +5 -9
  26. package/lib/browser/ParseSchema.js +1 -1
  27. package/lib/browser/ParseUser.js +66 -51
  28. package/lib/browser/Push.js +5 -10
  29. package/lib/browser/RESTController.js +1 -1
  30. package/lib/browser/SingleInstanceStateController.js +1 -1
  31. package/lib/browser/TaskQueue.js +10 -10
  32. package/lib/browser/UniqueInstanceStateController.js +1 -1
  33. package/lib/browser/arrayContainsObject.js +0 -4
  34. package/lib/browser/canBeSerialized.js +0 -4
  35. package/lib/browser/decode.js +0 -7
  36. package/lib/browser/encode.js +3 -7
  37. package/lib/browser/equals.js +1 -1
  38. package/lib/browser/escape.js +0 -4
  39. package/lib/browser/isRevocableSession.js +0 -4
  40. package/lib/browser/parseDate.js +1 -5
  41. package/lib/browser/promiseUtils.js +11 -10
  42. package/lib/browser/unique.js +1 -5
  43. package/lib/browser/unsavedChildren.js +0 -8
  44. package/lib/browser/uuid.js +2 -2
  45. package/lib/node/Cloud.js +7 -11
  46. package/lib/node/CoreManager.js +10 -10
  47. package/lib/node/EventuallyQueue.js +1 -1
  48. package/lib/node/InstallationController.js +3 -3
  49. package/lib/node/LiveQueryClient.js +14 -24
  50. package/lib/node/LocalDatastore.js +7 -11
  51. package/lib/node/LocalDatastoreController.default.js +12 -10
  52. package/lib/node/LocalDatastoreController.react-native.js +13 -12
  53. package/lib/node/LocalDatastoreUtils.js +0 -5
  54. package/lib/node/ObjectStateMutations.js +45 -19
  55. package/lib/node/Parse.js +2 -2
  56. package/lib/node/ParseCLP.js +8 -18
  57. package/lib/node/ParseFile.js +27 -40
  58. package/lib/node/ParseGeoPoint.js +9 -3
  59. package/lib/node/ParseHooks.js +13 -13
  60. package/lib/node/ParseInstallation.js +60 -2
  61. package/lib/node/ParseObject.js +19 -17
  62. package/lib/node/ParseOp.js +21 -21
  63. package/lib/node/ParsePolygon.js +1 -1
  64. package/lib/node/ParseQuery.js +84 -107
  65. package/lib/node/ParseRole.js +3 -8
  66. package/lib/node/ParseSchema.js +4 -4
  67. package/lib/node/ParseUser.js +42 -37
  68. package/lib/node/Push.js +3 -8
  69. package/lib/node/RESTController.js +1 -1
  70. package/lib/node/SingleInstanceStateController.js +1 -1
  71. package/lib/node/TaskQueue.js +9 -11
  72. package/lib/node/UniqueInstanceStateController.js +1 -1
  73. package/lib/node/arrayContainsObject.js +0 -4
  74. package/lib/node/canBeSerialized.js +0 -4
  75. package/lib/node/decode.js +0 -7
  76. package/lib/node/encode.js +3 -7
  77. package/lib/node/equals.js +1 -1
  78. package/lib/node/escape.js +0 -4
  79. package/lib/node/isRevocableSession.js +0 -4
  80. package/lib/node/parseDate.js +1 -5
  81. package/lib/node/promiseUtils.js +11 -10
  82. package/lib/node/unique.js +1 -5
  83. package/lib/node/unsavedChildren.js +0 -8
  84. package/lib/node/uuid.js +2 -2
  85. package/lib/react-native/Cloud.js +0 -1
  86. package/lib/react-native/CoreManager.js +1 -1
  87. package/lib/react-native/LiveQueryClient.js +49 -32
  88. package/lib/react-native/LocalDatastore.js +38 -14
  89. package/lib/react-native/LocalDatastoreController.default.js +7 -1
  90. package/lib/react-native/LocalDatastoreController.react-native.js +7 -1
  91. package/lib/react-native/ObjectStateMutations.js +30 -9
  92. package/lib/react-native/ParseCLP.js +3 -3
  93. package/lib/react-native/ParseFile.js +7 -6
  94. package/lib/react-native/ParseInstallation.js +51 -3
  95. package/lib/react-native/ParseObject.js +6 -5
  96. package/lib/react-native/ParseQuery.js +45 -37
  97. package/lib/react-native/ParseRole.js +1 -1
  98. package/lib/react-native/ParseUser.js +22 -16
  99. package/lib/react-native/TaskQueue.js +8 -2
  100. package/lib/react-native/decode.js +0 -1
  101. package/lib/react-native/promiseUtils.js +5 -4
  102. package/lib/react-native/uuid.js +1 -2
  103. package/lib/weapp/Cloud.js +7 -11
  104. package/lib/weapp/CoreManager.js +10 -10
  105. package/lib/weapp/EventuallyQueue.js +1 -1
  106. package/lib/weapp/InstallationController.js +3 -3
  107. package/lib/weapp/LiveQueryClient.js +102 -60
  108. package/lib/weapp/LocalDatastore.js +189 -147
  109. package/lib/weapp/LocalDatastoreController.default.js +14 -9
  110. package/lib/weapp/LocalDatastoreController.react-native.js +14 -12
  111. package/lib/weapp/LocalDatastoreUtils.js +0 -5
  112. package/lib/weapp/ObjectStateMutations.js +57 -21
  113. package/lib/weapp/Parse.js +2 -2
  114. package/lib/weapp/ParseCLP.js +9 -17
  115. package/lib/weapp/ParseFile.js +27 -31
  116. package/lib/weapp/ParseGeoPoint.js +9 -3
  117. package/lib/weapp/ParseHooks.js +13 -13
  118. package/lib/weapp/ParseInstallation.js +117 -9
  119. package/lib/weapp/ParseObject.js +19 -17
  120. package/lib/weapp/ParseOp.js +17 -17
  121. package/lib/weapp/ParsePolygon.js +1 -1
  122. package/lib/weapp/ParseQuery.js +147 -149
  123. package/lib/weapp/ParseRole.js +5 -9
  124. package/lib/weapp/ParseSchema.js +1 -1
  125. package/lib/weapp/ParseUser.js +66 -51
  126. package/lib/weapp/Push.js +5 -10
  127. package/lib/weapp/RESTController.js +1 -1
  128. package/lib/weapp/SingleInstanceStateController.js +1 -1
  129. package/lib/weapp/TaskQueue.js +10 -10
  130. package/lib/weapp/UniqueInstanceStateController.js +1 -1
  131. package/lib/weapp/arrayContainsObject.js +0 -4
  132. package/lib/weapp/canBeSerialized.js +0 -4
  133. package/lib/weapp/decode.js +0 -7
  134. package/lib/weapp/encode.js +3 -7
  135. package/lib/weapp/equals.js +1 -1
  136. package/lib/weapp/escape.js +0 -4
  137. package/lib/weapp/isRevocableSession.js +0 -4
  138. package/lib/weapp/parseDate.js +1 -5
  139. package/lib/weapp/promiseUtils.js +11 -10
  140. package/lib/weapp/unique.js +1 -5
  141. package/lib/weapp/unsavedChildren.js +0 -8
  142. package/lib/weapp/uuid.js +3 -3
  143. package/package.json +5 -6
@@ -5,7 +5,12 @@ var _Array$from = require("@babel/runtime-corejs3/core-js-stable/array/from");
5
5
  var _Symbol = require("@babel/runtime-corejs3/core-js-stable/symbol");
6
6
  var _getIteratorMethod = require("@babel/runtime-corejs3/core-js/get-iterator-method");
7
7
  var _Array$isArray = require("@babel/runtime-corejs3/core-js-stable/array/is-array");
8
+ var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
8
9
  var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
10
+ _Object$defineProperty(exports, "__esModule", {
11
+ value: true
12
+ });
13
+ exports.default = void 0;
9
14
  var _stringify = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/json/stringify"));
10
15
  var _reduce = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/reduce"));
11
16
  var _promise = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/promise"));
@@ -78,11 +83,9 @@ function _arrayLikeToArray(arr, len) {
78
83
  if (len == null || len > arr.length) len = arr.length;
79
84
  for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
80
85
  return arr2;
81
- } /**
82
- * @flow
83
- */
86
+ }
84
87
  var LocalDatastoreController = {
85
- fromPinWithName: function (name /*: string*/) /*: Array<Object>*/{
88
+ fromPinWithName: function (name /*: string*/) /*: Promise<Array<any>>*/{
86
89
  return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
87
90
  var values, objects;
88
91
  return _regenerator.default.wrap(function (_context) {
@@ -114,7 +117,7 @@ var LocalDatastoreController = {
114
117
  unPinWithName: function (name /*: string*/) {
115
118
  return _Storage.default.removeItemAsync(name);
116
119
  },
117
- getAllContents: function () /*: Object*/{
120
+ getAllContents: function () /*: Promise<any>*/{
118
121
  return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
119
122
  var keys;
120
123
  return _regenerator.default.wrap(function (_context3) {
@@ -167,7 +170,7 @@ var LocalDatastoreController = {
167
170
  }))();
168
171
  },
169
172
  // Used for testing
170
- getRawStorage: function () /*: Object*/{
173
+ getRawStorage: function () /*: Promise<any>*/{
171
174
  return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
172
175
  var keys;
173
176
  return _regenerator.default.wrap(function (_context5) {
@@ -210,7 +213,7 @@ var LocalDatastoreController = {
210
213
  }, _callee5);
211
214
  }))();
212
215
  },
213
- clear: function () /*: Promise*/{
216
+ clear: function () /*: Promise<any>*/{
214
217
  var _this = this;
215
218
  return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6() {
216
219
  var keys, toRemove, _iterator, _step, key, promises;
@@ -221,7 +224,7 @@ var LocalDatastoreController = {
221
224
  return _Storage.default.getAllKeysAsync();
222
225
  case 2:
223
226
  keys = _context6.sent;
224
- toRemove = [];
227
+ toRemove /*: string[]*/ = [];
225
228
  _iterator = _createForOfIteratorHelper(keys);
226
229
  try {
227
230
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
@@ -245,4 +248,6 @@ var LocalDatastoreController = {
245
248
  }))();
246
249
  }
247
250
  };
248
- module.exports = LocalDatastoreController;
251
+ module.exports = LocalDatastoreController;
252
+ var _default = LocalDatastoreController;
253
+ exports.default = _default;
@@ -1,6 +1,11 @@
1
1
  "use strict";
2
2
 
3
+ var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
3
4
  var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
5
+ _Object$defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = void 0;
4
9
  var _stringify = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/json/stringify"));
5
10
  var _forEach = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
6
11
  var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
@@ -8,14 +13,9 @@ var _regenerator = _interopRequireDefault(require("@babel/runtime-corejs3/regene
8
13
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/slicedToArray"));
9
14
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/asyncToGenerator"));
10
15
  var _LocalDatastoreUtils = require("./LocalDatastoreUtils");
11
- /**
12
- * @flow
13
- * @private
14
- */
15
-
16
16
  var RNStorage = require('./StorageController.react-native');
17
17
  var LocalDatastoreController = {
18
- fromPinWithName: function (name /*: string*/) /*: Promise<Array<Object>>*/{
18
+ fromPinWithName: function (name /*: string*/) /*: Promise<Array<any>>*/{
19
19
  return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
20
20
  var values, objects;
21
21
  return _regenerator.default.wrap(function (_context) {
@@ -68,7 +68,7 @@ var LocalDatastoreController = {
68
68
  unPinWithName: function (name /*: string*/) /*: Promise<void>*/{
69
69
  return RNStorage.removeItemAsync(name);
70
70
  },
71
- getAllContents: function () /*: Promise<Object>*/{
71
+ getAllContents: function () /*: Promise<any>*/{
72
72
  return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
73
73
  var keys, batch, i, key, LDS, results;
74
74
  return _regenerator.default.wrap(function (_context3) {
@@ -78,7 +78,7 @@ var LocalDatastoreController = {
78
78
  return RNStorage.getAllKeysAsync();
79
79
  case 2:
80
80
  keys = _context3.sent;
81
- batch = [];
81
+ batch /*: string[]*/ = [];
82
82
  for (i = 0; i < keys.length; i += 1) {
83
83
  key = keys[i];
84
84
  if ((0, _LocalDatastoreUtils.isLocalDatastoreKey)(key)) {
@@ -86,7 +86,7 @@ var LocalDatastoreController = {
86
86
  }
87
87
  }
88
88
  LDS = {};
89
- results = [];
89
+ results /*: any[]*/ = [];
90
90
  _context3.prev = 7;
91
91
  _context3.next = 10;
92
92
  return RNStorage.multiGet(batch);
@@ -119,7 +119,7 @@ var LocalDatastoreController = {
119
119
  }))();
120
120
  },
121
121
  // Used for testing
122
- getRawStorage: function () /*: Promise<Object>*/{
122
+ getRawStorage: function () /*: Promise<any>*/{
123
123
  return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
124
124
  var keys, storage, results;
125
125
  return _regenerator.default.wrap(function (_context4) {
@@ -158,7 +158,7 @@ var LocalDatastoreController = {
158
158
  return RNStorage.getAllKeysAsync();
159
159
  case 2:
160
160
  keys = _context5.sent;
161
- batch = [];
161
+ batch /*: string[]*/ = [];
162
162
  for (i = 0; i < keys.length; i += 1) {
163
163
  key = keys[i];
164
164
  if ((0, _LocalDatastoreUtils.isLocalDatastoreKey)(key)) {
@@ -176,4 +176,6 @@ var LocalDatastoreController = {
176
176
  }))();
177
177
  }
178
178
  };
179
- module.exports = LocalDatastoreController;
179
+ module.exports = LocalDatastoreController;
180
+ var _default = LocalDatastoreController;
181
+ exports.default = _default;
@@ -8,11 +8,6 @@ _Object$defineProperty(exports, "__esModule", {
8
8
  exports.PIN_PREFIX = exports.OBJECT_PREFIX = exports.DEFAULT_PIN = void 0;
9
9
  exports.isLocalDatastoreKey = isLocalDatastoreKey;
10
10
  var _startsWith = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/starts-with"));
11
- /**
12
- * @flow
13
- * @private
14
- */
15
-
16
11
  var DEFAULT_PIN = '_default';
17
12
  exports.DEFAULT_PIN = DEFAULT_PIN;
18
13
  var PIN_PREFIX = 'parsePin_';
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- var _Object$keys = require("@babel/runtime-corejs3/core-js-stable/object/keys");
3
+ var _Object$keys2 = require("@babel/runtime-corejs3/core-js-stable/object/keys");
4
4
  var _Object$getOwnPropertySymbols = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols");
5
5
  var _filterInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/filter");
6
6
  var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
@@ -23,7 +23,13 @@ exports.setPendingOp = setPendingOp;
23
23
  exports.setServerData = setServerData;
24
24
  var _typeof2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/typeof"));
25
25
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
26
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/toConsumableArray"));
26
27
  var _includes = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/includes"));
28
+ var _isArray = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/array/is-array"));
29
+ var _keys = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/keys"));
30
+ var _some = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/some"));
31
+ var _parseInt2 = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/parse-int"));
32
+ var _values = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/values"));
27
33
  var _stringify = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/json/stringify"));
28
34
  var _encode = _interopRequireDefault(require("./encode"));
29
35
  var _CoreManager = _interopRequireDefault(require("./CoreManager"));
@@ -32,7 +38,7 @@ var _ParseRelation = _interopRequireDefault(require("./ParseRelation"));
32
38
  var _TaskQueue = _interopRequireDefault(require("./TaskQueue"));
33
39
  var _ParseOp = require("./ParseOp");
34
40
  function ownKeys(object, enumerableOnly) {
35
- var keys = _Object$keys(object);
41
+ var keys = _Object$keys2(object);
36
42
  if (_Object$getOwnPropertySymbols) {
37
43
  var symbols = _Object$getOwnPropertySymbols(object);
38
44
  enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) {
@@ -43,19 +49,16 @@ function ownKeys(object, enumerableOnly) {
43
49
  }
44
50
  function _objectSpread(target) {
45
51
  for (var i = 1; i < arguments.length; i++) {
46
- var _context, _context2;
52
+ var _context2, _context3;
47
53
  var source = null != arguments[i] ? arguments[i] : {};
48
- i % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(source), !0)).call(_context, function (key) {
54
+ i % 2 ? _forEachInstanceProperty(_context2 = ownKeys(Object(source), !0)).call(_context2, function (key) {
49
55
  (0, _defineProperty2.default)(target, key, source[key]);
50
- }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) {
56
+ }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context3 = ownKeys(Object(source))).call(_context3, function (key) {
51
57
  _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key));
52
58
  });
53
59
  }
54
60
  return target;
55
- } /**
56
- * @flow
57
- */
58
- /*:: import type { Op } from './ParseOp';*/
61
+ }
59
62
  /*:: export type AttributeMap = { [attr: string]: any };*/
60
63
  /*:: export type OpsMap = { [attr: string]: Op };*/
61
64
  /*:: export type ObjectCache = { [attr: string]: string };*/
@@ -84,7 +87,7 @@ function setServerData(serverData /*: AttributeMap*/, attributes /*: AttributeMa
84
87
  }
85
88
  }
86
89
  }
87
- function setPendingOp(pendingOps /*: Array<OpsMap>*/, attr /*: string*/, op /*: ?Op*/) {
90
+ function setPendingOp(pendingOps /*: Array<OpsMap>*/, attr /*: string*/, op /*:: ?: Op*/) {
88
91
  var last = pendingOps.length - 1;
89
92
  if (op) {
90
93
  pendingOps[last][attr] = op;
@@ -116,7 +119,7 @@ function mergeFirstPendingState(pendingOps /*: Array<OpsMap>*/) {
116
119
  }
117
120
  }
118
121
  }
119
- function estimateAttribute(serverData /*: AttributeMap*/, pendingOps /*: Array<OpsMap>*/, object /*: ParseObject*/, attr /*: string*/) /*: mixed*/{
122
+ function estimateAttribute(serverData /*: AttributeMap*/, pendingOps /*: Array<OpsMap>*/, object /*: ParseObject*/, attr /*: string*/) /*: any*/{
120
123
  var value = serverData[attr];
121
124
  for (var i = 0; i < pendingOps.length; i++) {
122
125
  if (pendingOps[i][attr]) {
@@ -144,16 +147,25 @@ function estimateAttributes(serverData /*: AttributeMap*/, pendingOps /*: Array<
144
147
  }
145
148
  } else {
146
149
  if ((0, _includes.default)(attr).call(attr, '.')) {
147
- // convert a.b.c into { a: { b: { c: value } } }
150
+ // similar to nestedSet function
148
151
  var fields = attr.split('.');
149
152
  var last = fields[fields.length - 1];
150
153
  var _object = data;
151
154
  for (var _i = 0; _i < fields.length - 1; _i++) {
152
155
  var key = fields[_i];
153
156
  if (!(key in _object)) {
154
- _object[key] = {};
157
+ var nextKey = fields[_i + 1];
158
+ if (!isNaN(nextKey)) {
159
+ _object[key] = [];
160
+ } else {
161
+ _object[key] = {};
162
+ }
155
163
  } else {
156
- _object[key] = _objectSpread({}, _object[key]);
164
+ if ((0, _isArray.default)(_object[key])) {
165
+ _object[key] = (0, _toConsumableArray2.default)(_object[key]);
166
+ } else {
167
+ _object[key] = _objectSpread({}, _object[key]);
168
+ }
157
169
  }
158
170
  _object = _object[key];
159
171
  }
@@ -166,24 +178,48 @@ function estimateAttributes(serverData /*: AttributeMap*/, pendingOps /*: Array<
166
178
  }
167
179
  return data;
168
180
  }
181
+
182
+ /**
183
+ * Allows setting properties/variables deep in an object.
184
+ * Converts a.b into { a: { b: value } } for dot notation on Objects
185
+ * Converts a.0.b into { a: [{ b: value }] } for dot notation on Arrays
186
+ *
187
+ * @param obj The object to assign the value to
188
+ * @param key The key to assign. If it's in a deeper path, then use dot notation (`prop1.prop2.prop3`)
189
+ * Note that intermediate object(s) in the nested path are automatically created if they don't exist.
190
+ * @param value The value to assign. If it's an `undefined` then the key is deleted.
191
+ */
169
192
  function nestedSet(obj, key, value) {
170
- var path = key.split('.');
171
- for (var i = 0; i < path.length - 1; i++) {
172
- if (!(path[i] in obj)) {
173
- obj[path[i]] = {};
193
+ var paths = key.split('.');
194
+ for (var i = 0; i < paths.length - 1; i++) {
195
+ var path = paths[i];
196
+ if (!(path in obj)) {
197
+ var nextPath = paths[i + 1];
198
+ if (!isNaN(nextPath)) {
199
+ obj[path] = [];
200
+ } else {
201
+ obj[path] = {};
202
+ }
174
203
  }
175
- obj = obj[path[i]];
204
+ obj = obj[path];
176
205
  }
177
206
  if (typeof value === 'undefined') {
178
- delete obj[path[path.length - 1]];
207
+ delete obj[paths[paths.length - 1]];
179
208
  } else {
180
- obj[path[path.length - 1]] = value;
209
+ obj[paths[paths.length - 1]] = value;
181
210
  }
182
211
  }
183
212
  function commitServerChanges(serverData /*: AttributeMap*/, objectCache /*: ObjectCache*/, changes /*: AttributeMap*/) {
184
213
  var ParseObject = _CoreManager.default.getParseObject();
185
214
  for (var _attr3 in changes) {
215
+ var _context;
186
216
  var val = changes[_attr3];
217
+ // Check for JSON array { '0': { something }, '1': { something } }
218
+ if (val && (0, _typeof2.default)(val) === 'object' && !(0, _isArray.default)(val) && (0, _keys.default)(val).length > 0 && (0, _some.default)(_context = (0, _keys.default)(val)).call(_context, function (k) {
219
+ return !isNaN((0, _parseInt2.default)(k));
220
+ })) {
221
+ val = (0, _values.default)(val);
222
+ }
187
223
  nestedSet(serverData, _attr3, val);
188
224
  if (val && (0, _typeof2.default)(val) === 'object' && !(val instanceof ParseObject) && !(val instanceof _ParseFile.default) && !(val instanceof _ParseRelation.default)) {
189
225
  var json = (0, _encode.default)(val, false, true);
@@ -92,7 +92,7 @@ function _interopRequireWildcard(obj, nodeInterop) {
92
92
  * @global
93
93
  * @class
94
94
  * @hideconstructor
95
- */
95
+ */
96
96
 
97
97
  var Parse /*: ParseType*/ = {
98
98
  ACL: _ParseACL.default,
@@ -348,7 +348,7 @@ var Parse /*: ParseType*/ = {
348
348
  */
349
349
  enableLocalDatastore: function () {
350
350
  var polling = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
351
- var ms /*: number*/ = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2000;
351
+ var ms = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2000;
352
352
  if (!this.applicationId) {
353
353
  console.log("'enableLocalDataStore' must be called after 'initialize'");
354
354
  return;
@@ -119,16 +119,10 @@ function _arrayLikeToArray(arr, len) {
119
119
  if (len == null || len > arr.length) len = arr.length;
120
120
  for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
121
121
  return arr2;
122
- } /**
123
- * @flow
124
- */
125
- /*:: type Entity = Entity;*/
126
- /*:: type UsersMap = { [userId: string]: boolean | any };*/
127
- /*:: export type PermissionsMap = { [permission: string]: UsersMap };*/
122
+ }
123
+ /*:: export type PermissionsMap = { writeUserFields?: string[], readUserFields?: string[] } & { [permission: string]: UsersMap };*/
128
124
  var PUBLIC_KEY = '*';
129
- var VALID_PERMISSIONS /*: Map<string, UsersMap>*/ = new _map.default(
130
- /*:: <string, UsersMap>*/
131
- );
125
+ var VALID_PERMISSIONS /*: Map<string, UsersMap>*/ = new _map.default();
132
126
  VALID_PERMISSIONS.set('get', {});
133
127
  VALID_PERMISSIONS.set('find', {});
134
128
  VALID_PERMISSIONS.set('count', {});
@@ -136,9 +130,7 @@ VALID_PERMISSIONS.set('create', {});
136
130
  VALID_PERMISSIONS.set('update', {});
137
131
  VALID_PERMISSIONS.set('delete', {});
138
132
  VALID_PERMISSIONS.set('addField', {});
139
- var VALID_PERMISSIONS_EXTENDED /*: Map<string, UsersMap>*/ = new _map.default(
140
- /*:: <string, UsersMap>*/
141
- );
133
+ var VALID_PERMISSIONS_EXTENDED /*: Map<string, UsersMap>*/ = new _map.default();
142
134
  VALID_PERMISSIONS_EXTENDED.set('protectedFields', {});
143
135
 
144
136
  /**
@@ -463,7 +455,7 @@ var ParseCLP = /*#__PURE__*/function () {
463
455
  }
464
456
  }, {
465
457
  key: "_setArrayAccess",
466
- value: function _setArrayAccess(permission /*: string*/, userId /*: Entity*/, fields /*: string*/) {
458
+ value: function _setArrayAccess(permission /*: string*/, userId /*: Entity*/, fields /*: string[]*/) {
467
459
  userId = this._parseEntity(userId);
468
460
  var permissions = this.permissionsMap[permission][userId];
469
461
  if (!permissions) {
@@ -498,8 +490,8 @@ var ParseCLP = /*#__PURE__*/function () {
498
490
  }
499
491
  }, {
500
492
  key: "_getGroupPointerPermissions",
501
- value: function _getGroupPointerPermissions(operation /*: string*/) /*: string[]*/{
502
- return this.permissionsMap[operation];
493
+ value: function _getGroupPointerPermissions(operation /*: 'readUserFields' | 'writeUserFields'*/) /*: string[]*/{
494
+ return this.permissionsMap[operation] || [];
503
495
  }
504
496
 
505
497
  /**
@@ -519,7 +511,7 @@ var ParseCLP = /*#__PURE__*/function () {
519
511
  }, {
520
512
  key: "getReadUserFields",
521
513
  value: function getReadUserFields() /*: string[]*/{
522
- return this._getGroupPointerPermissions('readUserFields');
514
+ return this._getGroupPointerPermissions('readUserFields') || [];
523
515
  }
524
516
 
525
517
  /**
@@ -539,7 +531,7 @@ var ParseCLP = /*#__PURE__*/function () {
539
531
  }, {
540
532
  key: "getWriteUserFields",
541
533
  value: function getWriteUserFields() /*: string[]*/{
542
- return this._getGroupPointerPermissions('writeUserFields');
534
+ return this._getGroupPointerPermissions('writeUserFields') || [];
543
535
  }
544
536
 
545
537
  /**
@@ -27,6 +27,7 @@ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs3/he
27
27
  var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/createClass"));
28
28
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
29
29
  var _CoreManager = _interopRequireDefault(require("./CoreManager"));
30
+ var _ParseError = _interopRequireDefault(require("./ParseError"));
30
31
  function ownKeys(object, enumerableOnly) {
31
32
  var keys = _Object$keys2(object);
32
33
  if (_Object$getOwnPropertySymbols) {
@@ -48,20 +49,13 @@ function _objectSpread(target) {
48
49
  });
49
50
  }
50
51
  return target;
51
- } /**
52
- * @flow
53
- */ /* global XMLHttpRequest, Blob */
54
- /*:: import type { FullOptions } from './RESTController';*/
55
- var ParseError = require('./ParseError').default;
52
+ } /* global XMLHttpRequest, Blob */
56
53
  var XHR = null;
57
54
  if (typeof XMLHttpRequest !== 'undefined') {
58
55
  XHR = XMLHttpRequest;
59
56
  }
60
57
  XHR = require('./Xhr.weapp');
61
58
 
62
- /*:: type Base64 = { base64: string };*/
63
- /*:: type Uri = { uri: string };*/
64
- /*:: type FileData = Array<number> | Base64 | Blob | Uri;*/
65
59
  /*:: export type FileSaveOptions = FullOptions & {
66
60
  metadata?: { [key: string]: any },
67
61
  tags?: { [key: string]: any },
@@ -70,17 +64,17 @@ XHR = require('./Xhr.weapp');
70
64
  | {
71
65
  format: 'file',
72
66
  file: Blob,
73
- type: string,
67
+ type: string | undefined,
74
68
  }
75
69
  | {
76
70
  format: 'base64',
77
71
  base64: string,
78
- type: string,
72
+ type: string | undefined,
79
73
  }
80
74
  | {
81
75
  format: 'uri',
82
76
  uri: string,
83
- type: string,
77
+ type: string | undefined,
84
78
  };*/
85
79
  function b64Digit(number /*: number*/) /*: string*/{
86
80
  if (number < 26) {
@@ -135,10 +129,10 @@ var ParseFile = /*#__PURE__*/function () {
135
129
  * @param type {String} Optional Content-Type header to use for the file. If
136
130
  * this is omitted, the content type will be inferred from the name's
137
131
  * extension.
138
- * @param metadata {Object} Optional key value pairs to be stored with file object
139
- * @param tags {Object} Optional key value pairs to be stored with file object
132
+ * @param metadata {object} Optional key value pairs to be stored with file object
133
+ * @param tags {object} Optional key value pairs to be stored with file object
140
134
  */
141
- function ParseFile(name /*: string*/, data /*:: ?: FileData*/, type /*:: ?: string*/, metadata /*:: ?: Object*/, tags /*:: ?: Object*/) {
135
+ function ParseFile(name /*: string*/, data /*:: ?: FileData*/, type /*:: ?: string*/, metadata /*:: ?: object*/, tags /*:: ?: object*/) {
142
136
  (0, _classCallCheck2.default)(this, ParseFile);
143
137
  (0, _defineProperty2.default)(this, "_name", void 0);
144
138
  (0, _defineProperty2.default)(this, "_url", void 0);
@@ -257,11 +251,12 @@ var ParseFile = /*#__PURE__*/function () {
257
251
  * after you get the file from a Parse.Object.
258
252
  *
259
253
  * @param {object} options An object to specify url options
254
+ * @param {boolean} [options.forceSecure] force the url to be secure
260
255
  * @returns {string | undefined}
261
256
  */
262
257
  }, {
263
258
  key: "url",
264
- value: function (options /*:: ?: { forceSecure?: boolean }*/) /*: ?string*/{
259
+ value: function (options /*:: ?: { forceSecure?: boolean }*/) /*: string | undefined*/{
265
260
  options = options || {};
266
261
  if (!this._url) {
267
262
  return;
@@ -280,7 +275,7 @@ var ParseFile = /*#__PURE__*/function () {
280
275
  */
281
276
  }, {
282
277
  key: "metadata",
283
- value: function () /*: Object*/{
278
+ value: function () {
284
279
  return this._metadata;
285
280
  }
286
281
 
@@ -291,7 +286,7 @@ var ParseFile = /*#__PURE__*/function () {
291
286
  */
292
287
  }, {
293
288
  key: "tags",
294
- value: function () /*: Object*/{
289
+ value: function () {
295
290
  return this._tags;
296
291
  }
297
292
 
@@ -320,7 +315,7 @@ var ParseFile = /*#__PURE__*/function () {
320
315
  */
321
316
  }, {
322
317
  key: "save",
323
- value: function (options /*:: ?: FullOptions*/) /*: ?Promise*/{
318
+ value: function (options /*:: ?: FileSaveOptions*/) /*: Promise<ParseFile> | undefined*/{
324
319
  var _this2 = this;
325
320
  options = options || {};
326
321
  options.requestTask = function (task) {
@@ -351,7 +346,7 @@ var ParseFile = /*#__PURE__*/function () {
351
346
  _this2._data = result.base64;
352
347
  _this2._requestTask = null;
353
348
  return controller.saveBase64(_this2._name, newSource, options);
354
- }).then(function (res) {
349
+ }).then(function (res /*: { name?: string, url?: string }*/) {
355
350
  _this2._name = res.name;
356
351
  _this2._url = res.url;
357
352
  _this2._requestTask = null;
@@ -399,26 +394,26 @@ var ParseFile = /*#__PURE__*/function () {
399
394
  key: "destroy",
400
395
  value: function () {
401
396
  var _this3 = this;
402
- var options /*:: ?: FullOptions*/ = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
397
+ var options /*: FullOptions*/ = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
403
398
  if (!this._name) {
404
- throw new ParseError(ParseError.FILE_DELETE_UNNAMED_ERROR, 'Cannot delete an unnamed file.');
399
+ throw new _ParseError.default(_ParseError.default.FILE_DELETE_UNNAMED_ERROR, 'Cannot delete an unnamed file.');
405
400
  }
406
401
  var destroyOptions = {
407
402
  useMasterKey: true
408
403
  };
409
404
  if (options.hasOwnProperty('useMasterKey')) {
410
- destroyOptions.useMasterKey = options.useMasterKey;
405
+ destroyOptions.useMasterKey = !!options.useMasterKey;
411
406
  }
412
407
  var controller = _CoreManager.default.getFileController();
413
408
  return controller.deleteFile(this._name, destroyOptions).then(function () {
414
- _this3._data = null;
409
+ _this3._data = undefined;
415
410
  _this3._requestTask = null;
416
411
  return _this3;
417
412
  });
418
413
  }
419
414
  }, {
420
415
  key: "toJSON",
421
- value: function () /*: { name: ?string, url: ?string }*/{
416
+ value: function () /*: { __type: 'File', name?: string, url?: string }*/{
422
417
  return {
423
418
  __type: 'File',
424
419
  name: this._name,
@@ -427,7 +422,7 @@ var ParseFile = /*#__PURE__*/function () {
427
422
  }
428
423
  }, {
429
424
  key: "equals",
430
- value: function (other /*: mixed*/) /*: boolean*/{
425
+ value: function (other /*: any*/) /*: boolean*/{
431
426
  if (this === other) {
432
427
  return true;
433
428
  }
@@ -508,7 +503,7 @@ var ParseFile = /*#__PURE__*/function () {
508
503
  }
509
504
  }, {
510
505
  key: "encodeBase64",
511
- value: function (bytes /*: Array<number>*/) /*: string*/{
506
+ value: function (bytes /*: Array<number> | Uint8Array*/) /*: string*/{
512
507
  var chunks = [];
513
508
  chunks.length = Math.ceil(bytes.length / 3);
514
509
  for (var i = 0; i < chunks.length; i++) {
@@ -526,7 +521,7 @@ var ParseFile = /*#__PURE__*/function () {
526
521
  }();
527
522
  var DefaultController = {
528
523
  saveFile: function () {
529
- var _saveFile = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(name /*: string*/, source /*: FileSource*/, options /*:: ?: FullOptions*/) {
524
+ var _saveFile = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(name /*: string*/, source /*: FileSource*/, options /*:: ?: FileSaveOptions*/) {
530
525
  var base64Data, _base64Data$split, _base64Data$split2, first, second, data, newSource;
531
526
  return _regenerator.default.wrap(function (_context7) {
532
527
  while (1) switch (_context7.prev = _context7.next) {
@@ -559,7 +554,7 @@ var DefaultController = {
559
554
  newSource = {
560
555
  format: 'base64',
561
556
  base64: data,
562
- type: source.type || (source.file ? source.file.type : null)
557
+ type: source.type || (source.file ? source.file.type : undefined)
563
558
  };
564
559
  _context7.next = 10;
565
560
  return DefaultController.saveBase64(name, newSource, options);
@@ -576,11 +571,12 @@ var DefaultController = {
576
571
  }
577
572
  return saveFile;
578
573
  }(),
579
- saveBase64: function (name /*: string*/, source /*: FileSource*/, options /*:: ?: FullOptions*/) {
574
+ saveBase64: function (name /*: string*/, source /*: FileSource*/) {
575
+ var options /*: FileSaveOptions*/ = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
580
576
  if (source.format !== 'base64') {
581
577
  throw new Error('saveBase64 can only be used with Base64-type sources.');
582
578
  }
583
- var data /*: { base64: any, _ContentType?: any, fileData: Object }*/ = {
579
+ var data /*: { base64: any, _ContentType?: any, fileData: any }*/ = {
584
580
  base64: source.base64,
585
581
  fileData: {
586
582
  metadata: _objectSpread({}, options.metadata),
@@ -601,7 +597,7 @@ var DefaultController = {
601
597
  return _promise.default.reject('Cannot make a request: No definition of XMLHttpRequest was found.');
602
598
  }
603
599
  },
604
- downloadAjax: function (uri, options) {
600
+ downloadAjax: function (uri /*: string*/, options /*: any*/) {
605
601
  return new _promise.default(function (resolve, reject) {
606
602
  var xhr = new XHR();
607
603
  xhr.open('GET', uri, true);
@@ -191,9 +191,15 @@ var ParseGeoPoint = /*#__PURE__*/function () {
191
191
  * Creates a GeoPoint with the user's current location, if available.
192
192
  *
193
193
  * @param {object} options The options.
194
- * @param {boolean} [options.enableHighAccuracy=false] A boolean value that indicates the application would like to receive the best possible results. If true and if the device is able to provide a more accurate position, it will do so. Note that this can result in slower response times or increased power consumption (with a GPS chip on a mobile device for example). On the other hand, if false, the device can take the liberty to save resources by responding more quickly and/or using less power. Default: false.
195
- * @param {number} [options.timeout=Infinity] A positive long value representing the maximum length of time (in milliseconds) the device is allowed to take in order to return a position. The default value is Infinity, meaning that getCurrentPosition() won't return until the position is available.
196
- * @param {number} [options.maximumAge=0] A positive long value indicating the maximum age in milliseconds of a possible cached position that is acceptable to return. If set to 0, it means that the device cannot use a cached position and must attempt to retrieve the real current position. If set to Infinity the device must return a cached position regardless of its age. Default: 0.
194
+ * @param {boolean} [options.enableHighAccuracy=false] A boolean value that indicates the application would like to receive the best possible results.
195
+ * If true and if the device is able to provide a more accurate position, it will do so.
196
+ * Note that this can result in slower response times or increased power consumption (with a GPS chip on a mobile device for example).
197
+ * On the other hand, if false, the device can take the liberty to save resources by responding more quickly and/or using less power. Default: false.
198
+ * @param {number} [options.timeout=Infinity] A positive long value representing the maximum length of time (in milliseconds) the device is allowed to take in order to return a position.
199
+ * The default value is Infinity, meaning that getCurrentPosition() won't return until the position is available.
200
+ * @param {number} [options.maximumAge=0] A positive long value indicating the maximum age in milliseconds of a possible cached position that is acceptable to return.
201
+ * If set to 0, it means that the device cannot use a cached position and must attempt to retrieve the real current position.
202
+ * If set to Infinity the device must return a cached position regardless of its age. Default: 0.
197
203
  * @static
198
204
  * @returns {Promise<Parse.GeoPoint>} User's current location
199
205
  */