parse 5.1.1-alpha.1 → 5.2.0-alpha.2
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 +10186 -14918
- package/dist/parse.min.js +2 -2
- package/dist/parse.weapp.js +10180 -15057
- package/dist/parse.weapp.min.js +2 -2
- package/lib/browser/Analytics.js +7 -11
- package/lib/browser/AnonymousUtils.js +17 -22
- package/lib/browser/Cloud.js +24 -46
- package/lib/browser/CoreManager.js +71 -79
- package/lib/browser/CryptoController.js +14 -9
- package/lib/browser/EventEmitter.js +9 -2
- package/lib/browser/EventuallyQueue.js +156 -357
- package/lib/browser/FacebookUtils.js +23 -28
- package/lib/browser/IndexedDBStorageController.js +18 -14
- package/lib/browser/InstallationController.js +55 -121
- package/lib/browser/LiveQueryClient.js +312 -446
- package/lib/browser/LiveQuerySubscription.js +25 -28
- package/lib/browser/LocalDatastore.js +254 -578
- package/lib/browser/LocalDatastoreController.default.js +48 -227
- package/lib/browser/LocalDatastoreController.js +11 -1
- package/lib/browser/LocalDatastoreController.react-native.js +72 -164
- package/lib/browser/LocalDatastoreUtils.js +4 -12
- package/lib/browser/ObjectStateMutations.js +89 -95
- package/lib/browser/OfflineQuery.js +106 -198
- package/lib/browser/Parse.js +45 -61
- package/lib/browser/ParseACL.js +242 -288
- package/lib/browser/ParseCLP.js +372 -580
- package/lib/browser/ParseConfig.js +115 -138
- package/lib/browser/ParseError.js +85 -182
- package/lib/browser/ParseFile.js +296 -444
- package/lib/browser/ParseGeoPoint.js +121 -140
- package/lib/browser/ParseHooks.js +12 -14
- package/lib/browser/ParseInstallation.js +226 -354
- package/lib/browser/ParseLiveQuery.js +74 -148
- package/lib/browser/ParseObject.js +2017 -2622
- package/lib/browser/ParseOp.js +343 -484
- package/lib/browser/ParsePolygon.js +101 -120
- package/lib/browser/ParseQuery.js +1722 -2068
- package/lib/browser/ParseRelation.js +99 -118
- package/lib/browser/ParseRole.js +88 -144
- package/lib/browser/ParseSchema.js +372 -434
- package/lib/browser/ParseSession.js +62 -110
- package/lib/browser/ParseUser.js +942 -1270
- package/lib/browser/Push.js +16 -44
- package/lib/browser/RESTController.js +85 -124
- package/lib/browser/SingleInstanceStateController.js +57 -86
- package/lib/browser/Socket.weapp.js +50 -33
- package/lib/browser/Storage.js +23 -28
- package/lib/browser/StorageController.browser.js +16 -13
- package/lib/browser/StorageController.default.js +15 -14
- package/lib/browser/StorageController.js +14 -1
- package/lib/browser/StorageController.react-native.js +31 -30
- package/lib/browser/StorageController.weapp.js +19 -13
- package/lib/browser/TaskQueue.js +37 -49
- package/lib/browser/UniqueInstanceStateController.js +65 -86
- package/lib/browser/WebSocketController.js +11 -4
- package/lib/browser/Xhr.weapp.js +90 -78
- package/lib/browser/arrayContainsObject.js +3 -3
- package/lib/browser/canBeSerialized.js +10 -11
- package/lib/browser/decode.js +11 -11
- package/lib/browser/encode.js +11 -11
- package/lib/browser/equals.js +9 -10
- package/lib/browser/escape.js +2 -2
- package/lib/browser/isRevocableSession.js +1 -1
- package/lib/browser/parseDate.js +10 -10
- package/lib/browser/promiseUtils.js +19 -19
- package/lib/browser/unique.js +4 -4
- package/lib/browser/unsavedChildren.js +20 -21
- package/lib/browser/uuid.js +2 -4
- package/lib/node/Analytics.js +2 -6
- package/lib/node/AnonymousUtils.js +7 -12
- package/lib/node/Cloud.js +8 -12
- package/lib/node/CoreManager.js +59 -67
- package/lib/node/CryptoController.js +8 -3
- package/lib/node/EventEmitter.js +7 -1
- package/lib/node/EventuallyQueue.js +18 -37
- package/lib/node/FacebookUtils.js +1 -5
- package/lib/node/IndexedDBStorageController.js +14 -10
- package/lib/node/InstallationController.js +7 -8
- package/lib/node/LiveQueryClient.js +20 -32
- package/lib/node/LiveQuerySubscription.js +3 -4
- package/lib/node/LocalDatastore.js +20 -24
- package/lib/node/LocalDatastoreController.default.js +12 -11
- package/lib/node/LocalDatastoreController.js +14 -1
- package/lib/node/LocalDatastoreController.react-native.js +27 -22
- package/lib/node/LocalDatastoreUtils.js +4 -12
- package/lib/node/ObjectStateMutations.js +52 -36
- package/lib/node/OfflineQuery.js +37 -23
- package/lib/node/Parse.js +35 -49
- package/lib/node/ParseACL.js +18 -27
- package/lib/node/ParseCLP.js +38 -50
- package/lib/node/ParseConfig.js +7 -14
- package/lib/node/ParseError.js +457 -458
- package/lib/node/ParseFile.js +33 -66
- package/lib/node/ParseGeoPoint.js +22 -17
- package/lib/node/ParseHooks.js +0 -2
- package/lib/node/ParseInstallation.js +21 -8
- package/lib/node/ParseLiveQuery.js +6 -11
- package/lib/node/ParseObject.js +138 -167
- package/lib/node/ParseOp.js +32 -44
- package/lib/node/ParsePolygon.js +11 -17
- package/lib/node/ParseQuery.js +118 -164
- package/lib/node/ParseRelation.js +7 -16
- package/lib/node/ParseRole.js +7 -13
- package/lib/node/ParseSchema.js +26 -39
- package/lib/node/ParseSession.js +7 -8
- package/lib/node/ParseUser.js +70 -76
- package/lib/node/Push.js +5 -15
- package/lib/node/RESTController.js +21 -33
- package/lib/node/SingleInstanceStateController.js +41 -69
- package/lib/node/Socket.weapp.js +23 -2
- package/lib/node/Storage.js +11 -16
- package/lib/node/StorageController.browser.js +10 -8
- package/lib/node/StorageController.default.js +9 -9
- package/lib/node/StorageController.js +16 -1
- package/lib/node/StorageController.react-native.js +17 -17
- package/lib/node/StorageController.weapp.js +14 -8
- package/lib/node/TaskQueue.js +8 -11
- package/lib/node/UniqueInstanceStateController.js +40 -60
- package/lib/node/WebSocketController.js +15 -2
- package/lib/node/Xhr.weapp.js +11 -2
- package/lib/node/arrayContainsObject.js +1 -1
- package/lib/node/canBeSerialized.js +2 -2
- package/lib/node/decode.js +1 -1
- package/lib/node/encode.js +2 -2
- package/lib/node/equals.js +1 -1
- package/lib/node/escape.js +1 -1
- package/lib/node/isRevocableSession.js +1 -1
- package/lib/node/parseDate.js +1 -1
- package/lib/node/promiseUtils.js +7 -7
- package/lib/node/unique.js +2 -2
- package/lib/node/unsavedChildren.js +2 -2
- package/lib/node/uuid.js +2 -4
- package/lib/react-native/Analytics.js +2 -2
- package/lib/react-native/AnonymousUtils.js +3 -4
- package/lib/react-native/Cloud.js +0 -1
- package/lib/react-native/CoreManager.js +2 -3
- package/lib/react-native/CryptoController.js +6 -1
- package/lib/react-native/EventEmitter.js +6 -1
- package/lib/react-native/EventuallyQueue.js +1 -2
- package/lib/react-native/FacebookUtils.js +1 -2
- package/lib/react-native/IndexedDBStorageController.js +11 -5
- package/lib/react-native/InstallationController.js +1 -2
- package/lib/react-native/LiveQueryClient.js +51 -36
- package/lib/react-native/LiveQuerySubscription.js +2 -4
- package/lib/react-native/LocalDatastore.js +41 -17
- package/lib/react-native/LocalDatastoreController.default.js +6 -1
- package/lib/react-native/LocalDatastoreController.js +11 -1
- package/lib/react-native/LocalDatastoreController.react-native.js +16 -11
- package/lib/react-native/LocalDatastoreUtils.js +3 -6
- package/lib/react-native/ObjectStateMutations.js +30 -9
- package/lib/react-native/OfflineQuery.js +25 -20
- package/lib/react-native/Parse.js +24 -38
- package/lib/react-native/ParseACL.js +4 -6
- package/lib/react-native/ParseCLP.js +5 -7
- package/lib/react-native/ParseConfig.js +4 -6
- package/lib/react-native/ParseError.js +13 -31
- package/lib/react-native/ParseFile.js +10 -10
- package/lib/react-native/ParseGeoPoint.js +2 -4
- package/lib/react-native/ParseInstallation.js +13 -30
- package/lib/react-native/ParseLiveQuery.js +2 -4
- package/lib/react-native/ParseObject.js +81 -90
- package/lib/react-native/ParseOp.js +41 -79
- package/lib/react-native/ParsePolygon.js +2 -4
- package/lib/react-native/ParseQuery.js +87 -81
- package/lib/react-native/ParseRelation.js +2 -4
- package/lib/react-native/ParseRole.js +14 -31
- package/lib/react-native/ParseSchema.js +3 -5
- package/lib/react-native/ParseSession.js +12 -29
- package/lib/react-native/ParseUser.js +32 -51
- package/lib/react-native/RESTController.js +10 -4
- package/lib/react-native/SingleInstanceStateController.js +23 -37
- package/lib/react-native/Socket.weapp.js +9 -4
- package/lib/react-native/Storage.js +1 -2
- package/lib/react-native/StorageController.browser.js +6 -1
- package/lib/react-native/StorageController.default.js +6 -1
- package/lib/react-native/StorageController.js +13 -1
- package/lib/react-native/StorageController.react-native.js +11 -6
- package/lib/react-native/StorageController.weapp.js +6 -1
- package/lib/react-native/TaskQueue.js +8 -4
- package/lib/react-native/UniqueInstanceStateController.js +23 -37
- package/lib/react-native/WebSocketController.js +9 -1
- package/lib/react-native/Xhr.weapp.js +9 -4
- package/lib/react-native/unsavedChildren.js +3 -3
- package/lib/react-native/uuid.js +1 -2
- package/lib/weapp/Analytics.js +7 -11
- package/lib/weapp/AnonymousUtils.js +17 -22
- package/lib/weapp/Cloud.js +24 -46
- package/lib/weapp/CoreManager.js +71 -79
- package/lib/weapp/CryptoController.js +14 -9
- package/lib/weapp/EventEmitter.js +9 -2
- package/lib/weapp/EventuallyQueue.js +156 -357
- package/lib/weapp/FacebookUtils.js +23 -28
- package/lib/weapp/IndexedDBStorageController.js +18 -14
- package/lib/weapp/InstallationController.js +55 -121
- package/lib/weapp/LiveQueryClient.js +312 -446
- package/lib/weapp/LiveQuerySubscription.js +25 -28
- package/lib/weapp/LocalDatastore.js +254 -578
- package/lib/weapp/LocalDatastoreController.default.js +48 -227
- package/lib/weapp/LocalDatastoreController.js +11 -1
- package/lib/weapp/LocalDatastoreController.react-native.js +72 -164
- package/lib/weapp/LocalDatastoreUtils.js +4 -12
- package/lib/weapp/ObjectStateMutations.js +89 -95
- package/lib/weapp/OfflineQuery.js +106 -198
- package/lib/weapp/Parse.js +45 -60
- package/lib/weapp/ParseACL.js +242 -288
- package/lib/weapp/ParseCLP.js +372 -580
- package/lib/weapp/ParseConfig.js +115 -138
- package/lib/weapp/ParseError.js +85 -182
- package/lib/weapp/ParseFile.js +297 -446
- package/lib/weapp/ParseGeoPoint.js +121 -140
- package/lib/weapp/ParseHooks.js +12 -14
- package/lib/weapp/ParseInstallation.js +226 -354
- package/lib/weapp/ParseLiveQuery.js +74 -148
- package/lib/weapp/ParseObject.js +2017 -2622
- package/lib/weapp/ParseOp.js +343 -484
- package/lib/weapp/ParsePolygon.js +101 -120
- package/lib/weapp/ParseQuery.js +1722 -2068
- package/lib/weapp/ParseRelation.js +99 -118
- package/lib/weapp/ParseRole.js +88 -144
- package/lib/weapp/ParseSchema.js +372 -434
- package/lib/weapp/ParseSession.js +62 -110
- package/lib/weapp/ParseUser.js +942 -1270
- package/lib/weapp/Push.js +16 -44
- package/lib/weapp/RESTController.js +86 -125
- package/lib/weapp/SingleInstanceStateController.js +57 -86
- package/lib/weapp/Socket.weapp.js +50 -33
- package/lib/weapp/Storage.js +23 -28
- package/lib/weapp/StorageController.browser.js +16 -13
- package/lib/weapp/StorageController.default.js +15 -14
- package/lib/weapp/StorageController.js +14 -1
- package/lib/weapp/StorageController.react-native.js +31 -30
- package/lib/weapp/StorageController.weapp.js +19 -13
- package/lib/weapp/TaskQueue.js +37 -49
- package/lib/weapp/UniqueInstanceStateController.js +65 -86
- package/lib/weapp/WebSocketController.js +11 -4
- package/lib/weapp/Xhr.weapp.js +90 -78
- package/lib/weapp/arrayContainsObject.js +3 -3
- package/lib/weapp/canBeSerialized.js +10 -11
- package/lib/weapp/decode.js +11 -11
- package/lib/weapp/encode.js +11 -11
- package/lib/weapp/equals.js +9 -10
- package/lib/weapp/escape.js +2 -2
- package/lib/weapp/isRevocableSession.js +1 -1
- package/lib/weapp/parseDate.js +10 -10
- package/lib/weapp/promiseUtils.js +19 -19
- package/lib/weapp/unique.js +4 -4
- package/lib/weapp/unsavedChildren.js +20 -21
- package/lib/weapp/uuid.js +6 -8
- package/package.json +23 -30
|
@@ -1,12 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _Object$keys = require("@babel/runtime-corejs3/core-js-stable/object/keys");
|
|
4
|
-
var _Object$getOwnPropertySymbols = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols");
|
|
5
|
-
var _filterInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/filter");
|
|
6
|
-
var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
|
|
7
|
-
var _forEachInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/for-each");
|
|
8
|
-
var _Object$getOwnPropertyDescriptors = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors");
|
|
9
|
-
var _Object$defineProperties = require("@babel/runtime-corejs3/core-js-stable/object/define-properties");
|
|
10
3
|
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
|
11
4
|
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
12
5
|
_Object$defineProperty(exports, "__esModule", {
|
|
@@ -21,9 +14,12 @@ exports.popPendingState = popPendingState;
|
|
|
21
14
|
exports.pushPendingState = pushPendingState;
|
|
22
15
|
exports.setPendingOp = setPendingOp;
|
|
23
16
|
exports.setServerData = setServerData;
|
|
24
|
-
var _typeof2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/typeof"));
|
|
25
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
|
|
26
17
|
var _includes = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/includes"));
|
|
18
|
+
var _isArray = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/array/is-array"));
|
|
19
|
+
var _keys = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/keys"));
|
|
20
|
+
var _some = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/some"));
|
|
21
|
+
var _parseInt2 = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/parse-int"));
|
|
22
|
+
var _values = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/values"));
|
|
27
23
|
var _stringify = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/json/stringify"));
|
|
28
24
|
var _encode = _interopRequireDefault(require("./encode"));
|
|
29
25
|
var _CoreManager = _interopRequireDefault(require("./CoreManager"));
|
|
@@ -31,42 +27,7 @@ var _ParseFile = _interopRequireDefault(require("./ParseFile"));
|
|
|
31
27
|
var _ParseRelation = _interopRequireDefault(require("./ParseRelation"));
|
|
32
28
|
var _TaskQueue = _interopRequireDefault(require("./TaskQueue"));
|
|
33
29
|
var _ParseOp = require("./ParseOp");
|
|
34
|
-
function
|
|
35
|
-
var keys = _Object$keys(object);
|
|
36
|
-
if (_Object$getOwnPropertySymbols) {
|
|
37
|
-
var symbols = _Object$getOwnPropertySymbols(object);
|
|
38
|
-
enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) {
|
|
39
|
-
return _Object$getOwnPropertyDescriptor(object, sym).enumerable;
|
|
40
|
-
})), keys.push.apply(keys, symbols);
|
|
41
|
-
}
|
|
42
|
-
return keys;
|
|
43
|
-
}
|
|
44
|
-
function _objectSpread(target) {
|
|
45
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
46
|
-
var _context, _context2;
|
|
47
|
-
var source = null != arguments[i] ? arguments[i] : {};
|
|
48
|
-
i % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(source), !0)).call(_context, function (key) {
|
|
49
|
-
(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) {
|
|
51
|
-
_Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key));
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
return target;
|
|
55
|
-
} /**
|
|
56
|
-
* @flow
|
|
57
|
-
*/
|
|
58
|
-
/*:: import type { Op } from './ParseOp';*/
|
|
59
|
-
/*:: export type AttributeMap = { [attr: string]: any };*/
|
|
60
|
-
/*:: export type OpsMap = { [attr: string]: Op };*/
|
|
61
|
-
/*:: export type ObjectCache = { [attr: string]: string };*/
|
|
62
|
-
/*:: export type State = {
|
|
63
|
-
serverData: AttributeMap,
|
|
64
|
-
pendingOps: Array<OpsMap>,
|
|
65
|
-
objectCache: ObjectCache,
|
|
66
|
-
tasks: TaskQueue,
|
|
67
|
-
existed: boolean,
|
|
68
|
-
};*/
|
|
69
|
-
function defaultState() /*: State*/{
|
|
30
|
+
function defaultState() {
|
|
70
31
|
return {
|
|
71
32
|
serverData: {},
|
|
72
33
|
pendingOps: [{}],
|
|
@@ -75,50 +36,50 @@ function defaultState() /*: State*/{
|
|
|
75
36
|
existed: false
|
|
76
37
|
};
|
|
77
38
|
}
|
|
78
|
-
function setServerData(serverData
|
|
79
|
-
for (
|
|
80
|
-
if (typeof attributes[
|
|
81
|
-
serverData[
|
|
39
|
+
function setServerData(serverData, attributes) {
|
|
40
|
+
for (const attr in attributes) {
|
|
41
|
+
if (typeof attributes[attr] !== 'undefined') {
|
|
42
|
+
serverData[attr] = attributes[attr];
|
|
82
43
|
} else {
|
|
83
|
-
delete serverData[
|
|
44
|
+
delete serverData[attr];
|
|
84
45
|
}
|
|
85
46
|
}
|
|
86
47
|
}
|
|
87
|
-
function setPendingOp(pendingOps
|
|
88
|
-
|
|
48
|
+
function setPendingOp(pendingOps, attr, op) {
|
|
49
|
+
const last = pendingOps.length - 1;
|
|
89
50
|
if (op) {
|
|
90
51
|
pendingOps[last][attr] = op;
|
|
91
52
|
} else {
|
|
92
53
|
delete pendingOps[last][attr];
|
|
93
54
|
}
|
|
94
55
|
}
|
|
95
|
-
function pushPendingState(pendingOps
|
|
56
|
+
function pushPendingState(pendingOps) {
|
|
96
57
|
pendingOps.push({});
|
|
97
58
|
}
|
|
98
|
-
function popPendingState(pendingOps
|
|
99
|
-
|
|
59
|
+
function popPendingState(pendingOps) {
|
|
60
|
+
const first = pendingOps.shift();
|
|
100
61
|
if (!pendingOps.length) {
|
|
101
62
|
pendingOps[0] = {};
|
|
102
63
|
}
|
|
103
64
|
return first;
|
|
104
65
|
}
|
|
105
|
-
function mergeFirstPendingState(pendingOps
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
for (
|
|
109
|
-
if (next[
|
|
110
|
-
|
|
66
|
+
function mergeFirstPendingState(pendingOps) {
|
|
67
|
+
const first = popPendingState(pendingOps);
|
|
68
|
+
const next = pendingOps[0];
|
|
69
|
+
for (const attr in first) {
|
|
70
|
+
if (next[attr] && first[attr]) {
|
|
71
|
+
const merged = next[attr].mergeWith(first[attr]);
|
|
111
72
|
if (merged) {
|
|
112
|
-
next[
|
|
73
|
+
next[attr] = merged;
|
|
113
74
|
}
|
|
114
75
|
} else {
|
|
115
|
-
next[
|
|
76
|
+
next[attr] = first[attr];
|
|
116
77
|
}
|
|
117
78
|
}
|
|
118
79
|
}
|
|
119
|
-
function estimateAttribute(serverData
|
|
120
|
-
|
|
121
|
-
for (
|
|
80
|
+
function estimateAttribute(serverData, pendingOps, object, attr) {
|
|
81
|
+
let value = serverData[attr];
|
|
82
|
+
for (let i = 0; i < pendingOps.length; i++) {
|
|
122
83
|
if (pendingOps[i][attr]) {
|
|
123
84
|
if (pendingOps[i][attr] instanceof _ParseOp.RelationOp) {
|
|
124
85
|
if (object.id) {
|
|
@@ -131,12 +92,12 @@ function estimateAttribute(serverData /*: AttributeMap*/, pendingOps /*: Array<O
|
|
|
131
92
|
}
|
|
132
93
|
return value;
|
|
133
94
|
}
|
|
134
|
-
function estimateAttributes(serverData
|
|
135
|
-
|
|
95
|
+
function estimateAttributes(serverData, pendingOps, object) {
|
|
96
|
+
const data = {};
|
|
136
97
|
for (var attr in serverData) {
|
|
137
98
|
data[attr] = serverData[attr];
|
|
138
99
|
}
|
|
139
|
-
for (
|
|
100
|
+
for (let i = 0; i < pendingOps.length; i++) {
|
|
140
101
|
for (attr in pendingOps[i]) {
|
|
141
102
|
if (pendingOps[i][attr] instanceof _ParseOp.RelationOp) {
|
|
142
103
|
if (object.id) {
|
|
@@ -144,20 +105,31 @@ function estimateAttributes(serverData /*: AttributeMap*/, pendingOps /*: Array<
|
|
|
144
105
|
}
|
|
145
106
|
} else {
|
|
146
107
|
if ((0, _includes.default)(attr).call(attr, '.')) {
|
|
147
|
-
//
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
for (
|
|
152
|
-
|
|
153
|
-
if (!(key in
|
|
154
|
-
|
|
108
|
+
// similar to nestedSet function
|
|
109
|
+
const fields = attr.split('.');
|
|
110
|
+
const last = fields[fields.length - 1];
|
|
111
|
+
let object = data;
|
|
112
|
+
for (let i = 0; i < fields.length - 1; i++) {
|
|
113
|
+
const key = fields[i];
|
|
114
|
+
if (!(key in object)) {
|
|
115
|
+
const nextKey = fields[i + 1];
|
|
116
|
+
if (!isNaN(nextKey)) {
|
|
117
|
+
object[key] = [];
|
|
118
|
+
} else {
|
|
119
|
+
object[key] = {};
|
|
120
|
+
}
|
|
155
121
|
} else {
|
|
156
|
-
|
|
122
|
+
if ((0, _isArray.default)(object[key])) {
|
|
123
|
+
object[key] = [...object[key]];
|
|
124
|
+
} else {
|
|
125
|
+
object[key] = {
|
|
126
|
+
...object[key]
|
|
127
|
+
};
|
|
128
|
+
}
|
|
157
129
|
}
|
|
158
|
-
|
|
130
|
+
object = object[key];
|
|
159
131
|
}
|
|
160
|
-
|
|
132
|
+
object[last] = pendingOps[i][attr].applyTo(object[last]);
|
|
161
133
|
} else {
|
|
162
134
|
data[attr] = pendingOps[i][attr].applyTo(data[attr]);
|
|
163
135
|
}
|
|
@@ -166,28 +138,50 @@ function estimateAttributes(serverData /*: AttributeMap*/, pendingOps /*: Array<
|
|
|
166
138
|
}
|
|
167
139
|
return data;
|
|
168
140
|
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Allows setting properties/variables deep in an object.
|
|
144
|
+
* Converts a.b into { a: { b: value } } for dot notation on Objects
|
|
145
|
+
* Converts a.0.b into { a: [{ b: value }] } for dot notation on Arrays
|
|
146
|
+
*
|
|
147
|
+
* @param obj The object to assign the value to
|
|
148
|
+
* @param key The key to assign. If it's in a deeper path, then use dot notation (`prop1.prop2.prop3`)
|
|
149
|
+
* Note that intermediate object(s) in the nested path are automatically created if they don't exist.
|
|
150
|
+
* @param value The value to assign. If it's an `undefined` then the key is deleted.
|
|
151
|
+
*/
|
|
169
152
|
function nestedSet(obj, key, value) {
|
|
170
|
-
|
|
171
|
-
for (
|
|
172
|
-
|
|
173
|
-
|
|
153
|
+
const paths = key.split('.');
|
|
154
|
+
for (let i = 0; i < paths.length - 1; i++) {
|
|
155
|
+
const path = paths[i];
|
|
156
|
+
if (!(path in obj)) {
|
|
157
|
+
const nextPath = paths[i + 1];
|
|
158
|
+
if (!isNaN(nextPath)) {
|
|
159
|
+
obj[path] = [];
|
|
160
|
+
} else {
|
|
161
|
+
obj[path] = {};
|
|
162
|
+
}
|
|
174
163
|
}
|
|
175
|
-
obj = obj[path
|
|
164
|
+
obj = obj[path];
|
|
176
165
|
}
|
|
177
166
|
if (typeof value === 'undefined') {
|
|
178
|
-
delete obj[
|
|
167
|
+
delete obj[paths[paths.length - 1]];
|
|
179
168
|
} else {
|
|
180
|
-
obj[
|
|
169
|
+
obj[paths[paths.length - 1]] = value;
|
|
181
170
|
}
|
|
182
171
|
}
|
|
183
|
-
function commitServerChanges(serverData
|
|
184
|
-
|
|
185
|
-
for (
|
|
186
|
-
var
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
172
|
+
function commitServerChanges(serverData, objectCache, changes) {
|
|
173
|
+
const ParseObject = _CoreManager.default.getParseObject();
|
|
174
|
+
for (const attr in changes) {
|
|
175
|
+
var _context;
|
|
176
|
+
let val = changes[attr];
|
|
177
|
+
// Check for JSON array { '0': { something }, '1': { something } }
|
|
178
|
+
if (val && typeof val === 'object' && !(0, _isArray.default)(val) && (0, _keys.default)(val).length > 0 && (0, _some.default)(_context = (0, _keys.default)(val)).call(_context, k => !isNaN((0, _parseInt2.default)(k)))) {
|
|
179
|
+
val = (0, _values.default)(val);
|
|
180
|
+
}
|
|
181
|
+
nestedSet(serverData, attr, val);
|
|
182
|
+
if (val && typeof val === 'object' && !(val instanceof ParseObject) && !(val instanceof _ParseFile.default) && !(val instanceof _ParseRelation.default)) {
|
|
183
|
+
const json = (0, _encode.default)(val, false, true);
|
|
184
|
+
objectCache[attr] = (0, _stringify.default)(json);
|
|
191
185
|
}
|
|
192
186
|
}
|
|
193
187
|
}
|