parse 5.1.1-alpha.1 → 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.
- package/dist/parse.js +1411 -1216
- package/dist/parse.min.js +2 -2
- package/dist/parse.weapp.js +1414 -1219
- package/dist/parse.weapp.min.js +2 -2
- package/lib/browser/Cloud.js +7 -11
- package/lib/browser/CoreManager.js +1 -1
- package/lib/browser/EventuallyQueue.js +1 -1
- package/lib/browser/InstallationController.js +3 -3
- package/lib/browser/LiveQueryClient.js +102 -60
- package/lib/browser/LocalDatastore.js +189 -147
- package/lib/browser/LocalDatastoreController.default.js +14 -9
- package/lib/browser/LocalDatastoreController.react-native.js +14 -12
- package/lib/browser/LocalDatastoreUtils.js +0 -5
- package/lib/browser/ObjectStateMutations.js +57 -21
- package/lib/browser/Parse.js +2 -2
- package/lib/browser/ParseCLP.js +9 -17
- package/lib/browser/ParseFile.js +27 -31
- package/lib/browser/ParseGeoPoint.js +9 -3
- package/lib/browser/ParseHooks.js +13 -13
- package/lib/browser/ParseInstallation.js +14 -0
- package/lib/browser/ParseObject.js +15 -13
- package/lib/browser/ParseOp.js +17 -17
- package/lib/browser/ParsePolygon.js +1 -1
- package/lib/browser/ParseQuery.js +147 -149
- package/lib/browser/ParseRole.js +5 -9
- package/lib/browser/ParseSchema.js +1 -1
- package/lib/browser/ParseUser.js +66 -51
- package/lib/browser/Push.js +5 -10
- package/lib/browser/RESTController.js +1 -1
- package/lib/browser/SingleInstanceStateController.js +1 -1
- package/lib/browser/TaskQueue.js +10 -10
- package/lib/browser/UniqueInstanceStateController.js +1 -1
- package/lib/node/Cloud.js +7 -11
- package/lib/node/CoreManager.js +1 -1
- package/lib/node/EventuallyQueue.js +1 -1
- package/lib/node/InstallationController.js +3 -3
- package/lib/node/LiveQueryClient.js +14 -24
- package/lib/node/LocalDatastore.js +7 -11
- package/lib/node/LocalDatastoreController.default.js +12 -10
- package/lib/node/LocalDatastoreController.react-native.js +13 -12
- package/lib/node/LocalDatastoreUtils.js +0 -5
- package/lib/node/ObjectStateMutations.js +45 -19
- package/lib/node/Parse.js +2 -2
- package/lib/node/ParseCLP.js +8 -18
- package/lib/node/ParseFile.js +27 -40
- package/lib/node/ParseGeoPoint.js +9 -3
- package/lib/node/ParseHooks.js +13 -13
- package/lib/node/ParseInstallation.js +14 -0
- package/lib/node/ParseObject.js +15 -13
- package/lib/node/ParseOp.js +21 -21
- package/lib/node/ParsePolygon.js +1 -1
- package/lib/node/ParseQuery.js +84 -107
- package/lib/node/ParseRole.js +3 -8
- package/lib/node/ParseSchema.js +4 -4
- package/lib/node/ParseUser.js +42 -37
- package/lib/node/Push.js +3 -8
- package/lib/node/RESTController.js +1 -1
- package/lib/node/SingleInstanceStateController.js +1 -1
- package/lib/node/TaskQueue.js +9 -11
- package/lib/node/UniqueInstanceStateController.js +1 -1
- package/lib/react-native/Cloud.js +0 -1
- package/lib/react-native/CoreManager.js +1 -1
- package/lib/react-native/LiveQueryClient.js +49 -32
- package/lib/react-native/LocalDatastore.js +38 -14
- package/lib/react-native/LocalDatastoreController.default.js +7 -1
- package/lib/react-native/LocalDatastoreController.react-native.js +7 -1
- package/lib/react-native/ObjectStateMutations.js +30 -9
- package/lib/react-native/ParseCLP.js +3 -3
- package/lib/react-native/ParseFile.js +7 -6
- package/lib/react-native/ParseObject.js +4 -3
- package/lib/react-native/ParseQuery.js +45 -37
- package/lib/react-native/ParseRole.js +1 -1
- package/lib/react-native/ParseUser.js +22 -16
- package/lib/react-native/TaskQueue.js +8 -2
- package/lib/weapp/Cloud.js +7 -11
- package/lib/weapp/CoreManager.js +1 -1
- package/lib/weapp/EventuallyQueue.js +1 -1
- package/lib/weapp/InstallationController.js +3 -3
- package/lib/weapp/LiveQueryClient.js +102 -60
- package/lib/weapp/LocalDatastore.js +189 -147
- package/lib/weapp/LocalDatastoreController.default.js +14 -9
- package/lib/weapp/LocalDatastoreController.react-native.js +14 -12
- package/lib/weapp/LocalDatastoreUtils.js +0 -5
- package/lib/weapp/ObjectStateMutations.js +57 -21
- package/lib/weapp/Parse.js +2 -2
- package/lib/weapp/ParseCLP.js +9 -17
- package/lib/weapp/ParseFile.js +27 -31
- package/lib/weapp/ParseGeoPoint.js +9 -3
- package/lib/weapp/ParseHooks.js +13 -13
- package/lib/weapp/ParseInstallation.js +14 -0
- package/lib/weapp/ParseObject.js +15 -13
- package/lib/weapp/ParseOp.js +17 -17
- package/lib/weapp/ParsePolygon.js +1 -1
- package/lib/weapp/ParseQuery.js +147 -149
- package/lib/weapp/ParseRole.js +5 -9
- package/lib/weapp/ParseSchema.js +1 -1
- package/lib/weapp/ParseUser.js +66 -51
- package/lib/weapp/Push.js +5 -10
- package/lib/weapp/RESTController.js +1 -1
- package/lib/weapp/SingleInstanceStateController.js +1 -1
- package/lib/weapp/TaskQueue.js +10 -10
- package/lib/weapp/UniqueInstanceStateController.js +1 -1
- 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<
|
|
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 () /*:
|
|
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 () /*:
|
|
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<
|
|
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<
|
|
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<
|
|
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$
|
|
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$
|
|
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
|
|
52
|
+
var _context2, _context3;
|
|
47
53
|
var source = null != arguments[i] ? arguments[i] : {};
|
|
48
|
-
i % 2 ? _forEachInstanceProperty(
|
|
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(
|
|
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
|
|
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*/) /*:
|
|
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
|
-
//
|
|
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
|
-
|
|
157
|
+
var nextKey = fields[_i + 1];
|
|
158
|
+
if (!isNaN(nextKey)) {
|
|
159
|
+
_object[key] = [];
|
|
160
|
+
} else {
|
|
161
|
+
_object[key] = {};
|
|
162
|
+
}
|
|
155
163
|
} else {
|
|
156
|
-
|
|
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
|
|
171
|
-
for (var i = 0; i <
|
|
172
|
-
|
|
173
|
-
|
|
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
|
|
204
|
+
obj = obj[path];
|
|
176
205
|
}
|
|
177
206
|
if (typeof value === 'undefined') {
|
|
178
|
-
delete obj[
|
|
207
|
+
delete obj[paths[paths.length - 1]];
|
|
179
208
|
} else {
|
|
180
|
-
obj[
|
|
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);
|
package/lib/browser/Parse.js
CHANGED
|
@@ -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,
|
|
@@ -355,7 +355,7 @@ var Parse /*: ParseType*/ = {
|
|
|
355
355
|
*/
|
|
356
356
|
enableLocalDatastore: function () {
|
|
357
357
|
var polling = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
358
|
-
var ms
|
|
358
|
+
var ms = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2000;
|
|
359
359
|
if (!this.applicationId) {
|
|
360
360
|
console.log("'enableLocalDataStore' must be called after 'initialize'");
|
|
361
361
|
return;
|
package/lib/browser/ParseCLP.js
CHANGED
|
@@ -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
|
-
|
|
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 /*:
|
|
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
|
/**
|
package/lib/browser/ParseFile.js
CHANGED
|
@@ -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,18 +49,11 @@ 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
|
-
/*:: type Base64 = { base64: string };*/
|
|
61
|
-
/*:: type Uri = { uri: string };*/
|
|
62
|
-
/*:: type FileData = Array<number> | Base64 | Blob | Uri;*/
|
|
63
57
|
/*:: export type FileSaveOptions = FullOptions & {
|
|
64
58
|
metadata?: { [key: string]: any },
|
|
65
59
|
tags?: { [key: string]: any },
|
|
@@ -68,17 +62,17 @@ if (typeof XMLHttpRequest !== 'undefined') {
|
|
|
68
62
|
| {
|
|
69
63
|
format: 'file',
|
|
70
64
|
file: Blob,
|
|
71
|
-
type: string,
|
|
65
|
+
type: string | undefined,
|
|
72
66
|
}
|
|
73
67
|
| {
|
|
74
68
|
format: 'base64',
|
|
75
69
|
base64: string,
|
|
76
|
-
type: string,
|
|
70
|
+
type: string | undefined,
|
|
77
71
|
}
|
|
78
72
|
| {
|
|
79
73
|
format: 'uri',
|
|
80
74
|
uri: string,
|
|
81
|
-
type: string,
|
|
75
|
+
type: string | undefined,
|
|
82
76
|
};*/
|
|
83
77
|
function b64Digit(number /*: number*/) /*: string*/{
|
|
84
78
|
if (number < 26) {
|
|
@@ -133,10 +127,10 @@ var ParseFile = /*#__PURE__*/function () {
|
|
|
133
127
|
* @param type {String} Optional Content-Type header to use for the file. If
|
|
134
128
|
* this is omitted, the content type will be inferred from the name's
|
|
135
129
|
* extension.
|
|
136
|
-
* @param metadata {
|
|
137
|
-
* @param tags {
|
|
130
|
+
* @param metadata {object} Optional key value pairs to be stored with file object
|
|
131
|
+
* @param tags {object} Optional key value pairs to be stored with file object
|
|
138
132
|
*/
|
|
139
|
-
function ParseFile(name /*: string*/, data /*:: ?: FileData*/, type /*:: ?: string*/, metadata /*:: ?:
|
|
133
|
+
function ParseFile(name /*: string*/, data /*:: ?: FileData*/, type /*:: ?: string*/, metadata /*:: ?: object*/, tags /*:: ?: object*/) {
|
|
140
134
|
(0, _classCallCheck2.default)(this, ParseFile);
|
|
141
135
|
(0, _defineProperty2.default)(this, "_name", void 0);
|
|
142
136
|
(0, _defineProperty2.default)(this, "_url", void 0);
|
|
@@ -255,11 +249,12 @@ var ParseFile = /*#__PURE__*/function () {
|
|
|
255
249
|
* after you get the file from a Parse.Object.
|
|
256
250
|
*
|
|
257
251
|
* @param {object} options An object to specify url options
|
|
252
|
+
* @param {boolean} [options.forceSecure] force the url to be secure
|
|
258
253
|
* @returns {string | undefined}
|
|
259
254
|
*/
|
|
260
255
|
}, {
|
|
261
256
|
key: "url",
|
|
262
|
-
value: function (options /*:: ?: { forceSecure?: boolean }*/) /*:
|
|
257
|
+
value: function (options /*:: ?: { forceSecure?: boolean }*/) /*: string | undefined*/{
|
|
263
258
|
options = options || {};
|
|
264
259
|
if (!this._url) {
|
|
265
260
|
return;
|
|
@@ -278,7 +273,7 @@ var ParseFile = /*#__PURE__*/function () {
|
|
|
278
273
|
*/
|
|
279
274
|
}, {
|
|
280
275
|
key: "metadata",
|
|
281
|
-
value: function ()
|
|
276
|
+
value: function () {
|
|
282
277
|
return this._metadata;
|
|
283
278
|
}
|
|
284
279
|
|
|
@@ -289,7 +284,7 @@ var ParseFile = /*#__PURE__*/function () {
|
|
|
289
284
|
*/
|
|
290
285
|
}, {
|
|
291
286
|
key: "tags",
|
|
292
|
-
value: function ()
|
|
287
|
+
value: function () {
|
|
293
288
|
return this._tags;
|
|
294
289
|
}
|
|
295
290
|
|
|
@@ -318,7 +313,7 @@ var ParseFile = /*#__PURE__*/function () {
|
|
|
318
313
|
*/
|
|
319
314
|
}, {
|
|
320
315
|
key: "save",
|
|
321
|
-
value: function (options /*:: ?:
|
|
316
|
+
value: function (options /*:: ?: FileSaveOptions*/) /*: Promise<ParseFile> | undefined*/{
|
|
322
317
|
var _this2 = this;
|
|
323
318
|
options = options || {};
|
|
324
319
|
options.requestTask = function (task) {
|
|
@@ -349,7 +344,7 @@ var ParseFile = /*#__PURE__*/function () {
|
|
|
349
344
|
_this2._data = result.base64;
|
|
350
345
|
_this2._requestTask = null;
|
|
351
346
|
return controller.saveBase64(_this2._name, newSource, options);
|
|
352
|
-
}).then(function (res) {
|
|
347
|
+
}).then(function (res /*: { name?: string, url?: string }*/) {
|
|
353
348
|
_this2._name = res.name;
|
|
354
349
|
_this2._url = res.url;
|
|
355
350
|
_this2._requestTask = null;
|
|
@@ -397,26 +392,26 @@ var ParseFile = /*#__PURE__*/function () {
|
|
|
397
392
|
key: "destroy",
|
|
398
393
|
value: function () {
|
|
399
394
|
var _this3 = this;
|
|
400
|
-
var options
|
|
395
|
+
var options /*: FullOptions*/ = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
401
396
|
if (!this._name) {
|
|
402
|
-
throw new
|
|
397
|
+
throw new _ParseError.default(_ParseError.default.FILE_DELETE_UNNAMED_ERROR, 'Cannot delete an unnamed file.');
|
|
403
398
|
}
|
|
404
399
|
var destroyOptions = {
|
|
405
400
|
useMasterKey: true
|
|
406
401
|
};
|
|
407
402
|
if (options.hasOwnProperty('useMasterKey')) {
|
|
408
|
-
destroyOptions.useMasterKey = options.useMasterKey;
|
|
403
|
+
destroyOptions.useMasterKey = !!options.useMasterKey;
|
|
409
404
|
}
|
|
410
405
|
var controller = _CoreManager.default.getFileController();
|
|
411
406
|
return controller.deleteFile(this._name, destroyOptions).then(function () {
|
|
412
|
-
_this3._data =
|
|
407
|
+
_this3._data = undefined;
|
|
413
408
|
_this3._requestTask = null;
|
|
414
409
|
return _this3;
|
|
415
410
|
});
|
|
416
411
|
}
|
|
417
412
|
}, {
|
|
418
413
|
key: "toJSON",
|
|
419
|
-
value: function () /*: {
|
|
414
|
+
value: function () /*: { __type: 'File', name?: string, url?: string }*/{
|
|
420
415
|
return {
|
|
421
416
|
__type: 'File',
|
|
422
417
|
name: this._name,
|
|
@@ -425,7 +420,7 @@ var ParseFile = /*#__PURE__*/function () {
|
|
|
425
420
|
}
|
|
426
421
|
}, {
|
|
427
422
|
key: "equals",
|
|
428
|
-
value: function (other /*:
|
|
423
|
+
value: function (other /*: any*/) /*: boolean*/{
|
|
429
424
|
if (this === other) {
|
|
430
425
|
return true;
|
|
431
426
|
}
|
|
@@ -506,7 +501,7 @@ var ParseFile = /*#__PURE__*/function () {
|
|
|
506
501
|
}
|
|
507
502
|
}, {
|
|
508
503
|
key: "encodeBase64",
|
|
509
|
-
value: function (bytes /*: Array<number
|
|
504
|
+
value: function (bytes /*: Array<number> | Uint8Array*/) /*: string*/{
|
|
510
505
|
var chunks = [];
|
|
511
506
|
chunks.length = Math.ceil(bytes.length / 3);
|
|
512
507
|
for (var i = 0; i < chunks.length; i++) {
|
|
@@ -524,7 +519,7 @@ var ParseFile = /*#__PURE__*/function () {
|
|
|
524
519
|
}();
|
|
525
520
|
var DefaultController = {
|
|
526
521
|
saveFile: function () {
|
|
527
|
-
var _saveFile = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(name /*: string*/, source /*: FileSource*/, options /*:: ?:
|
|
522
|
+
var _saveFile = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(name /*: string*/, source /*: FileSource*/, options /*:: ?: FileSaveOptions*/) {
|
|
528
523
|
var base64Data, _base64Data$split, _base64Data$split2, first, second, data, newSource;
|
|
529
524
|
return _regenerator.default.wrap(function (_context7) {
|
|
530
525
|
while (1) switch (_context7.prev = _context7.next) {
|
|
@@ -557,7 +552,7 @@ var DefaultController = {
|
|
|
557
552
|
newSource = {
|
|
558
553
|
format: 'base64',
|
|
559
554
|
base64: data,
|
|
560
|
-
type: source.type || (source.file ? source.file.type :
|
|
555
|
+
type: source.type || (source.file ? source.file.type : undefined)
|
|
561
556
|
};
|
|
562
557
|
_context7.next = 10;
|
|
563
558
|
return DefaultController.saveBase64(name, newSource, options);
|
|
@@ -574,11 +569,12 @@ var DefaultController = {
|
|
|
574
569
|
}
|
|
575
570
|
return saveFile;
|
|
576
571
|
}(),
|
|
577
|
-
saveBase64: function (name /*: string*/, source /*: FileSource
|
|
572
|
+
saveBase64: function (name /*: string*/, source /*: FileSource*/) {
|
|
573
|
+
var options /*: FileSaveOptions*/ = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
578
574
|
if (source.format !== 'base64') {
|
|
579
575
|
throw new Error('saveBase64 can only be used with Base64-type sources.');
|
|
580
576
|
}
|
|
581
|
-
var data /*: { base64: any, _ContentType?: any, fileData:
|
|
577
|
+
var data /*: { base64: any, _ContentType?: any, fileData: any }*/ = {
|
|
582
578
|
base64: source.base64,
|
|
583
579
|
fileData: {
|
|
584
580
|
metadata: _objectSpread({}, options.metadata),
|
|
@@ -599,7 +595,7 @@ var DefaultController = {
|
|
|
599
595
|
return _promise.default.reject('Cannot make a request: No definition of XMLHttpRequest was found.');
|
|
600
596
|
}
|
|
601
597
|
},
|
|
602
|
-
downloadAjax: function (uri
|
|
598
|
+
downloadAjax: function (uri /*: string*/, options /*: any*/) {
|
|
603
599
|
return new _promise.default(function (resolve, reject) {
|
|
604
600
|
var xhr = new XHR();
|
|
605
601
|
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.
|
|
195
|
-
*
|
|
196
|
-
*
|
|
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
|
*/
|