parse 5.1.0-alpha.1 → 5.1.0-alpha.11
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/README.md +13 -0
- package/dist/parse.js +1464 -1051
- package/dist/parse.min.js +2 -2
- package/dist/parse.weapp.js +2367 -1090
- package/dist/parse.weapp.min.js +2 -2
- package/lib/browser/CoreManager.js +48 -171
- package/lib/browser/InstallationController.js +134 -23
- package/lib/browser/LiveQueryClient.js +43 -35
- package/lib/browser/LiveQuerySubscription.js +15 -5
- package/lib/browser/LocalDatastoreController.default.js +248 -0
- package/lib/browser/LocalDatastoreController.js +1 -246
- package/lib/browser/ObjectStateMutations.js +6 -5
- package/lib/browser/OfflineQuery.js +3 -2
- package/lib/browser/Parse.js +31 -7
- package/lib/browser/ParseACL.js +21 -11
- package/lib/browser/ParseFile.js +4 -0
- package/lib/browser/ParseGeoPoint.js +12 -8
- package/lib/browser/ParseHooks.js +2 -0
- package/lib/browser/ParseInstallation.js +274 -13
- package/lib/browser/ParseLiveQuery.js +32 -23
- package/lib/browser/ParseObject.js +37 -40
- package/lib/browser/ParseOp.js +21 -7
- package/lib/browser/ParseQuery.js +1 -0
- package/lib/browser/ParseRelation.js +12 -7
- package/lib/browser/ParseRole.js +2 -0
- package/lib/browser/ParseSession.js +1 -1
- package/lib/browser/ParseUser.js +51 -15
- package/lib/browser/RESTController.js +6 -5
- package/lib/browser/SingleInstanceStateController.js +2 -4
- package/lib/browser/Storage.js +1 -2
- package/lib/browser/StorageController.js +3 -0
- package/lib/browser/WebSocketController.js +13 -0
- package/lib/browser/arrayContainsObject.js +4 -3
- package/lib/browser/canBeSerialized.js +6 -4
- package/lib/browser/decode.js +8 -5
- package/lib/browser/encode.js +6 -4
- package/lib/browser/equals.js +4 -3
- package/lib/browser/unique.js +3 -2
- package/lib/browser/unsavedChildren.js +4 -2
- package/lib/browser/uuid.js +11 -5
- package/lib/node/CoreManager.js +48 -171
- package/lib/node/InstallationController.js +65 -21
- package/lib/node/LiveQueryClient.js +2 -5
- package/lib/node/LiveQuerySubscription.js +2 -2
- package/lib/node/LocalDatastoreController.default.js +67 -0
- package/lib/node/LocalDatastoreController.js +1 -65
- package/lib/node/ObjectStateMutations.js +8 -9
- package/lib/node/OfflineQuery.js +3 -2
- package/lib/node/Parse.js +31 -7
- package/lib/node/ParseACL.js +21 -11
- package/lib/node/ParseFile.js +4 -0
- package/lib/node/ParseGeoPoint.js +11 -11
- package/lib/node/ParseHooks.js +2 -0
- package/lib/node/ParseInstallation.js +207 -7
- package/lib/node/ParseLiveQuery.js +2 -3
- package/lib/node/ParseObject.js +9 -12
- package/lib/node/ParseOp.js +21 -7
- package/lib/node/ParseQuery.js +1 -0
- package/lib/node/ParseRelation.js +14 -8
- package/lib/node/ParseRole.js +2 -0
- package/lib/node/ParseSession.js +1 -1
- package/lib/node/ParseUser.js +20 -13
- package/lib/node/RESTController.js +5 -5
- package/lib/node/SingleInstanceStateController.js +2 -8
- package/lib/node/Storage.js +1 -2
- package/lib/node/StorageController.js +3 -0
- package/lib/node/WebSocketController.js +10 -0
- package/lib/node/arrayContainsObject.js +4 -3
- package/lib/node/canBeSerialized.js +6 -4
- package/lib/node/decode.js +9 -5
- package/lib/node/encode.js +7 -4
- package/lib/node/equals.js +4 -3
- package/lib/node/unique.js +3 -2
- package/lib/node/unsavedChildren.js +4 -2
- package/lib/node/uuid.js +10 -8
- package/lib/react-native/CoreManager.js +39 -2
- package/lib/react-native/InstallationController.js +77 -9
- package/lib/react-native/LiveQueryClient.js +28 -20
- package/lib/react-native/LiveQuerySubscription.js +14 -5
- package/lib/react-native/LocalDatastoreController.default.js +91 -0
- package/lib/react-native/LocalDatastoreController.js +1 -91
- package/lib/react-native/ObjectStateMutations.js +6 -5
- package/lib/react-native/OfflineQuery.js +3 -2
- package/lib/react-native/Parse.js +23 -7
- package/lib/react-native/ParseACL.js +19 -11
- package/lib/react-native/ParseGeoPoint.js +5 -3
- package/lib/react-native/ParseInstallation.js +115 -10
- package/lib/react-native/ParseLiveQuery.js +11 -2
- package/lib/react-native/ParseObject.js +28 -31
- package/lib/react-native/ParseOp.js +20 -6
- package/lib/react-native/ParseQuery.js +1 -0
- package/lib/react-native/ParseRelation.js +10 -7
- package/lib/react-native/ParseRole.js +2 -0
- package/lib/react-native/ParseUser.js +6 -2
- package/lib/react-native/RESTController.js +5 -5
- package/lib/react-native/SingleInstanceStateController.js +0 -2
- package/lib/react-native/Storage.js +1 -2
- package/lib/react-native/StorageController.js +1 -0
- package/lib/react-native/WebSocketController.js +5 -0
- package/lib/react-native/arrayContainsObject.js +3 -2
- package/lib/react-native/canBeSerialized.js +5 -3
- package/lib/react-native/decode.js +7 -5
- package/lib/react-native/encode.js +6 -4
- package/lib/react-native/equals.js +4 -3
- package/lib/react-native/unique.js +3 -2
- package/lib/react-native/unsavedChildren.js +3 -2
- package/lib/react-native/uuid.js +9 -4
- package/lib/weapp/CoreManager.js +48 -171
- package/lib/weapp/InstallationController.js +134 -23
- package/lib/weapp/LiveQueryClient.js +43 -35
- package/lib/weapp/LiveQuerySubscription.js +15 -5
- package/lib/weapp/LocalDatastoreController.default.js +248 -0
- package/lib/weapp/LocalDatastoreController.js +1 -246
- package/lib/weapp/ObjectStateMutations.js +6 -5
- package/lib/weapp/OfflineQuery.js +3 -2
- package/lib/weapp/Parse.js +31 -7
- package/lib/weapp/ParseACL.js +21 -11
- package/lib/weapp/ParseFile.js +4 -0
- package/lib/weapp/ParseGeoPoint.js +12 -8
- package/lib/weapp/ParseHooks.js +2 -0
- package/lib/weapp/ParseInstallation.js +274 -13
- package/lib/weapp/ParseLiveQuery.js +32 -23
- package/lib/weapp/ParseObject.js +37 -40
- package/lib/weapp/ParseOp.js +21 -7
- package/lib/weapp/ParseQuery.js +1 -0
- package/lib/weapp/ParseRelation.js +12 -7
- package/lib/weapp/ParseRole.js +2 -0
- package/lib/weapp/ParseSession.js +1 -1
- package/lib/weapp/ParseUser.js +51 -15
- package/lib/weapp/RESTController.js +6 -5
- package/lib/weapp/SingleInstanceStateController.js +2 -4
- package/lib/weapp/Storage.js +1 -2
- package/lib/weapp/StorageController.js +3 -0
- package/lib/weapp/WebSocketController.js +13 -0
- package/lib/weapp/arrayContainsObject.js +4 -3
- package/lib/weapp/canBeSerialized.js +6 -4
- package/lib/weapp/decode.js +8 -5
- package/lib/weapp/encode.js +6 -4
- package/lib/weapp/equals.js +4 -3
- package/lib/weapp/unique.js +3 -2
- package/lib/weapp/unsavedChildren.js +4 -2
- package/lib/weapp/uuid.js +12 -5
- package/package.json +3 -1
|
@@ -1,40 +1,84 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _CoreManager = _interopRequireDefault(require("./CoreManager"));
|
|
3
8
|
var _Storage = _interopRequireDefault(require("./Storage"));
|
|
9
|
+
var _ParseInstallation = _interopRequireDefault(require("./ParseInstallation"));
|
|
10
|
+
var _uuid = _interopRequireDefault(require("./uuid"));
|
|
4
11
|
function _interopRequireDefault(obj) {
|
|
5
12
|
return obj && obj.__esModule ? obj : {
|
|
6
13
|
default: obj
|
|
7
14
|
};
|
|
8
15
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
let iidCache = null;
|
|
16
|
+
const CURRENT_INSTALLATION_KEY = 'currentInstallation';
|
|
17
|
+
const CURRENT_INSTALLATION_ID_KEY = 'currentInstallationId';
|
|
18
|
+
let iidCache /*: string | null*/ = null;
|
|
19
|
+
let currentInstallationCache = null;
|
|
20
|
+
let currentInstallationCacheMatchesDisk = false;
|
|
15
21
|
const InstallationController = {
|
|
16
|
-
|
|
22
|
+
async updateInstallationOnDisk(installation /*: ParseInstallation*/) /*: Promise<void>*/{
|
|
23
|
+
const path = _Storage.default.generatePath(CURRENT_INSTALLATION_KEY);
|
|
24
|
+
await _Storage.default.setItemAsync(path, JSON.stringify(installation.toJSON()));
|
|
25
|
+
this._setCurrentInstallationCache(installation);
|
|
26
|
+
},
|
|
27
|
+
async currentInstallationId() /*: Promise<string>*/{
|
|
17
28
|
if (typeof iidCache === 'string') {
|
|
18
|
-
return
|
|
29
|
+
return iidCache;
|
|
30
|
+
}
|
|
31
|
+
const path = _Storage.default.generatePath(CURRENT_INSTALLATION_ID_KEY);
|
|
32
|
+
let iid = await _Storage.default.getItemAsync(path);
|
|
33
|
+
if (!iid) {
|
|
34
|
+
iid = (0, _uuid.default)();
|
|
35
|
+
return _Storage.default.setItemAsync(path, iid).then(() => {
|
|
36
|
+
iidCache = iid;
|
|
37
|
+
return iid;
|
|
38
|
+
});
|
|
19
39
|
}
|
|
20
|
-
|
|
21
|
-
return
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
40
|
+
iidCache = iid;
|
|
41
|
+
return iid;
|
|
42
|
+
},
|
|
43
|
+
async currentInstallation() /*: Promise<ParseInstallation | null>*/{
|
|
44
|
+
if (currentInstallationCache) {
|
|
45
|
+
return currentInstallationCache;
|
|
46
|
+
}
|
|
47
|
+
if (currentInstallationCacheMatchesDisk) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
const path = _Storage.default.generatePath(CURRENT_INSTALLATION_KEY);
|
|
51
|
+
let installationData = await _Storage.default.getItemAsync(path);
|
|
52
|
+
currentInstallationCacheMatchesDisk = true;
|
|
53
|
+
if (installationData) {
|
|
54
|
+
installationData = JSON.parse(installationData);
|
|
55
|
+
installationData.className = '_Installation';
|
|
56
|
+
const current = _ParseInstallation.default.fromJSON(installationData);
|
|
57
|
+
currentInstallationCache = current;
|
|
58
|
+
return current;
|
|
59
|
+
}
|
|
60
|
+
const installationId = await this.currentInstallationId();
|
|
61
|
+
const installation = new _ParseInstallation.default();
|
|
62
|
+
installation.set('deviceType', _ParseInstallation.default.DEVICE_TYPES.WEB);
|
|
63
|
+
installation.set('installationId', installationId);
|
|
64
|
+
installation.set('parseVersion', _CoreManager.default.get('VERSION'));
|
|
65
|
+
currentInstallationCache = installation;
|
|
66
|
+
await _Storage.default.setItemAsync(path, JSON.stringify(installation.toJSON()));
|
|
67
|
+
return installation;
|
|
32
68
|
},
|
|
33
69
|
_clearCache() {
|
|
34
70
|
iidCache = null;
|
|
71
|
+
currentInstallationCache = null;
|
|
72
|
+
currentInstallationCacheMatchesDisk = false;
|
|
35
73
|
},
|
|
36
74
|
_setInstallationIdCache(iid /*: string*/) {
|
|
37
75
|
iidCache = iid;
|
|
76
|
+
},
|
|
77
|
+
_setCurrentInstallationCache(installation /*: ParseInstallation*/, matchesDisk /*: boolean*/ = true) {
|
|
78
|
+
currentInstallationCache = installation;
|
|
79
|
+
currentInstallationCacheMatchesDisk = matchesDisk;
|
|
38
80
|
}
|
|
39
81
|
};
|
|
40
|
-
module.exports = InstallationController;
|
|
82
|
+
module.exports = InstallationController;
|
|
83
|
+
var _default = InstallationController;
|
|
84
|
+
exports.default = _default;
|
|
@@ -14,8 +14,6 @@ function _interopRequireDefault(obj) {
|
|
|
14
14
|
default: obj
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
|
-
/* global WebSocket */
|
|
18
|
-
|
|
19
17
|
// The LiveQuery client inner state
|
|
20
18
|
const CLIENT_STATE = {
|
|
21
19
|
INITIALIZED: 'initialized',
|
|
@@ -163,8 +161,8 @@ class LiveQueryClient {
|
|
|
163
161
|
this.state = CLIENT_STATE.INITIALIZED;
|
|
164
162
|
const EventEmitter = _CoreManager.default.getEventEmitter();
|
|
165
163
|
this.emitter = new EventEmitter();
|
|
166
|
-
this.on = this.emitter.on;
|
|
167
|
-
this.emit = this.emitter.emit;
|
|
164
|
+
this.on = (eventName, listener) => this.emitter.on(eventName, listener);
|
|
165
|
+
this.emit = (eventName, ...args) => this.emitter.emit(eventName, ...args);
|
|
168
166
|
// adding listener so process does not crash
|
|
169
167
|
// best practice is for developer to register their own listener
|
|
170
168
|
this.on('error', () => {});
|
|
@@ -481,6 +479,5 @@ class LiveQueryClient {
|
|
|
481
479
|
}).bind(this), time);
|
|
482
480
|
}
|
|
483
481
|
}
|
|
484
|
-
_CoreManager.default.setWebSocketController(require('ws'));
|
|
485
482
|
var _default = LiveQueryClient;
|
|
486
483
|
exports.default = _default;
|
|
@@ -108,8 +108,8 @@ class Subscription {
|
|
|
108
108
|
this.subscribed = false;
|
|
109
109
|
const EventEmitter = _CoreManager.default.getEventEmitter();
|
|
110
110
|
this.emitter = new EventEmitter();
|
|
111
|
-
this.on = this.emitter.on;
|
|
112
|
-
this.emit = this.emitter.emit;
|
|
111
|
+
this.on = (eventName, listener) => this.emitter.on(eventName, listener);
|
|
112
|
+
this.emit = (eventName, ...args) => this.emitter.emit(eventName, ...args);
|
|
113
113
|
// adding listener so process does not crash
|
|
114
114
|
// best practice is for developer to register their own listener
|
|
115
115
|
this.on('error', () => {});
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _LocalDatastoreUtils = require("./LocalDatastoreUtils");
|
|
4
|
+
var _Storage = _interopRequireDefault(require("./Storage"));
|
|
5
|
+
function _interopRequireDefault(obj) {
|
|
6
|
+
return obj && obj.__esModule ? obj : {
|
|
7
|
+
default: obj
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* @flow
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
const LocalDatastoreController = {
|
|
15
|
+
async fromPinWithName(name /*: string*/) /*: Array<Object>*/{
|
|
16
|
+
const values = await _Storage.default.getItemAsync(name);
|
|
17
|
+
if (!values) {
|
|
18
|
+
return [];
|
|
19
|
+
}
|
|
20
|
+
const objects = JSON.parse(values);
|
|
21
|
+
return objects;
|
|
22
|
+
},
|
|
23
|
+
pinWithName(name /*: string*/, value /*: any*/) {
|
|
24
|
+
const values = JSON.stringify(value);
|
|
25
|
+
return _Storage.default.setItemAsync(name, values);
|
|
26
|
+
},
|
|
27
|
+
unPinWithName(name /*: string*/) {
|
|
28
|
+
return _Storage.default.removeItemAsync(name);
|
|
29
|
+
},
|
|
30
|
+
async getAllContents() /*: Object*/{
|
|
31
|
+
const keys = await _Storage.default.getAllKeysAsync();
|
|
32
|
+
return keys.reduce(async (previousPromise, key) => {
|
|
33
|
+
const LDS = await previousPromise;
|
|
34
|
+
if ((0, _LocalDatastoreUtils.isLocalDatastoreKey)(key)) {
|
|
35
|
+
const value = await _Storage.default.getItemAsync(key);
|
|
36
|
+
try {
|
|
37
|
+
LDS[key] = JSON.parse(value);
|
|
38
|
+
} catch (error) {
|
|
39
|
+
console.error('Error getAllContents: ', error);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return LDS;
|
|
43
|
+
}, Promise.resolve({}));
|
|
44
|
+
},
|
|
45
|
+
// Used for testing
|
|
46
|
+
async getRawStorage() /*: Object*/{
|
|
47
|
+
const keys = await _Storage.default.getAllKeysAsync();
|
|
48
|
+
return keys.reduce(async (previousPromise, key) => {
|
|
49
|
+
const LDS = await previousPromise;
|
|
50
|
+
const value = await _Storage.default.getItemAsync(key);
|
|
51
|
+
LDS[key] = value;
|
|
52
|
+
return LDS;
|
|
53
|
+
}, Promise.resolve({}));
|
|
54
|
+
},
|
|
55
|
+
async clear() /*: Promise*/{
|
|
56
|
+
const keys = await _Storage.default.getAllKeysAsync();
|
|
57
|
+
const toRemove = [];
|
|
58
|
+
for (const key of keys) {
|
|
59
|
+
if ((0, _LocalDatastoreUtils.isLocalDatastoreKey)(key)) {
|
|
60
|
+
toRemove.push(key);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
const promises = toRemove.map(this.unPinWithName);
|
|
64
|
+
return Promise.all(promises);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
module.exports = LocalDatastoreController;
|
|
@@ -1,67 +1,3 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
var _Storage = _interopRequireDefault(require("./Storage"));
|
|
5
|
-
function _interopRequireDefault(obj) {
|
|
6
|
-
return obj && obj.__esModule ? obj : {
|
|
7
|
-
default: obj
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* @flow
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
const LocalDatastoreController = {
|
|
15
|
-
async fromPinWithName(name /*: string*/) /*: Array<Object>*/{
|
|
16
|
-
const values = await _Storage.default.getItemAsync(name);
|
|
17
|
-
if (!values) {
|
|
18
|
-
return [];
|
|
19
|
-
}
|
|
20
|
-
const objects = JSON.parse(values);
|
|
21
|
-
return objects;
|
|
22
|
-
},
|
|
23
|
-
pinWithName(name /*: string*/, value /*: any*/) {
|
|
24
|
-
const values = JSON.stringify(value);
|
|
25
|
-
return _Storage.default.setItemAsync(name, values);
|
|
26
|
-
},
|
|
27
|
-
unPinWithName(name /*: string*/) {
|
|
28
|
-
return _Storage.default.removeItemAsync(name);
|
|
29
|
-
},
|
|
30
|
-
async getAllContents() /*: Object*/{
|
|
31
|
-
const keys = await _Storage.default.getAllKeysAsync();
|
|
32
|
-
return keys.reduce(async (previousPromise, key) => {
|
|
33
|
-
const LDS = await previousPromise;
|
|
34
|
-
if ((0, _LocalDatastoreUtils.isLocalDatastoreKey)(key)) {
|
|
35
|
-
const value = await _Storage.default.getItemAsync(key);
|
|
36
|
-
try {
|
|
37
|
-
LDS[key] = JSON.parse(value);
|
|
38
|
-
} catch (error) {
|
|
39
|
-
console.error('Error getAllContents: ', error);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
return LDS;
|
|
43
|
-
}, Promise.resolve({}));
|
|
44
|
-
},
|
|
45
|
-
// Used for testing
|
|
46
|
-
async getRawStorage() /*: Object*/{
|
|
47
|
-
const keys = await _Storage.default.getAllKeysAsync();
|
|
48
|
-
return keys.reduce(async (previousPromise, key) => {
|
|
49
|
-
const LDS = await previousPromise;
|
|
50
|
-
const value = await _Storage.default.getItemAsync(key);
|
|
51
|
-
LDS[key] = value;
|
|
52
|
-
return LDS;
|
|
53
|
-
}, Promise.resolve({}));
|
|
54
|
-
},
|
|
55
|
-
async clear() /*: Promise*/{
|
|
56
|
-
const keys = await _Storage.default.getAllKeysAsync();
|
|
57
|
-
const toRemove = [];
|
|
58
|
-
for (const key of keys) {
|
|
59
|
-
if ((0, _LocalDatastoreUtils.isLocalDatastoreKey)(key)) {
|
|
60
|
-
toRemove.push(key);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
const promises = toRemove.map(this.unPinWithName);
|
|
64
|
-
return Promise.all(promises);
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
module.exports = LocalDatastoreController;
|
|
3
|
+
module.exports = require('./LocalDatastoreController.default');
|
|
@@ -13,8 +13,8 @@ exports.pushPendingState = pushPendingState;
|
|
|
13
13
|
exports.setPendingOp = setPendingOp;
|
|
14
14
|
exports.setServerData = setServerData;
|
|
15
15
|
var _encode = _interopRequireDefault(require("./encode"));
|
|
16
|
+
var _CoreManager = _interopRequireDefault(require("./CoreManager"));
|
|
16
17
|
var _ParseFile = _interopRequireDefault(require("./ParseFile"));
|
|
17
|
-
var _ParseObject = _interopRequireDefault(require("./ParseObject"));
|
|
18
18
|
var _ParseRelation = _interopRequireDefault(require("./ParseRelation"));
|
|
19
19
|
var _TaskQueue = _interopRequireDefault(require("./TaskQueue"));
|
|
20
20
|
var _ParseOp = require("./ParseOp");
|
|
@@ -117,18 +117,16 @@ function estimateAttributes(serverData /*: AttributeMap*/, pendingOps /*: Array<
|
|
|
117
117
|
if (attr.includes('.')) {
|
|
118
118
|
// convert a.b.c into { a: { b: { c: value } } }
|
|
119
119
|
const fields = attr.split('.');
|
|
120
|
-
const first = fields[0];
|
|
121
120
|
const last = fields[fields.length - 1];
|
|
122
|
-
|
|
123
|
-
...serverData[first]
|
|
124
|
-
};
|
|
125
|
-
let object = {
|
|
126
|
-
...data
|
|
127
|
-
};
|
|
121
|
+
let object = data;
|
|
128
122
|
for (let i = 0; i < fields.length - 1; i++) {
|
|
129
123
|
const key = fields[i];
|
|
130
124
|
if (!(key in object)) {
|
|
131
125
|
object[key] = {};
|
|
126
|
+
} else {
|
|
127
|
+
object[key] = {
|
|
128
|
+
...object[key]
|
|
129
|
+
};
|
|
132
130
|
}
|
|
133
131
|
object = object[key];
|
|
134
132
|
}
|
|
@@ -156,10 +154,11 @@ function nestedSet(obj, key, value) {
|
|
|
156
154
|
}
|
|
157
155
|
}
|
|
158
156
|
function commitServerChanges(serverData /*: AttributeMap*/, objectCache /*: ObjectCache*/, changes /*: AttributeMap*/) {
|
|
157
|
+
const ParseObject = _CoreManager.default.getParseObject();
|
|
159
158
|
for (const attr in changes) {
|
|
160
159
|
const val = changes[attr];
|
|
161
160
|
nestedSet(serverData, attr, val);
|
|
162
|
-
if (val && typeof val === 'object' && !(val instanceof
|
|
161
|
+
if (val && typeof val === 'object' && !(val instanceof ParseObject) && !(val instanceof _ParseFile.default) && !(val instanceof _ParseRelation.default)) {
|
|
163
162
|
const json = (0, _encode.default)(val, false, true);
|
|
164
163
|
objectCache[attr] = JSON.stringify(json);
|
|
165
164
|
}
|
package/lib/node/OfflineQuery.js
CHANGED
|
@@ -288,12 +288,13 @@ function matchesKeyConstraints(className, object, objects, key, constraints) {
|
|
|
288
288
|
}
|
|
289
289
|
// More complex cases
|
|
290
290
|
for (const condition in constraints) {
|
|
291
|
+
var _compareTo, _compareTo2;
|
|
291
292
|
compareTo = constraints[condition];
|
|
292
|
-
if (compareTo.__type) {
|
|
293
|
+
if ((_compareTo = compareTo) !== null && _compareTo !== void 0 && _compareTo.__type) {
|
|
293
294
|
compareTo = decode(compareTo);
|
|
294
295
|
}
|
|
295
296
|
// is it a $relativeTime? convert to date
|
|
296
|
-
if (compareTo['$relativeTime']) {
|
|
297
|
+
if ((_compareTo2 = compareTo) !== null && _compareTo2 !== void 0 && _compareTo2['$relativeTime']) {
|
|
297
298
|
const parserResult = relativeTimeToDate(compareTo['$relativeTime']);
|
|
298
299
|
if (parserResult.status !== 'success') {
|
|
299
300
|
throw new ParseError(ParseError.INVALID_JSON, `bad $relativeTime (${key}) value. ${parserResult.info}`);
|
package/lib/node/Parse.js
CHANGED
|
@@ -38,6 +38,9 @@ var _Storage = _interopRequireDefault(require("./Storage"));
|
|
|
38
38
|
var _ParseUser = _interopRequireDefault(require("./ParseUser"));
|
|
39
39
|
var _ParseLiveQuery = _interopRequireDefault(require("./ParseLiveQuery"));
|
|
40
40
|
var _LiveQueryClient = _interopRequireDefault(require("./LiveQueryClient"));
|
|
41
|
+
var _LocalDatastoreController = _interopRequireDefault(require("./LocalDatastoreController"));
|
|
42
|
+
var _StorageController = _interopRequireDefault(require("./StorageController"));
|
|
43
|
+
var _WebSocketController = _interopRequireDefault(require("./WebSocketController"));
|
|
41
44
|
function _getRequireWildcardCache(nodeInterop) {
|
|
42
45
|
if (typeof WeakMap !== "function") return null;
|
|
43
46
|
var cacheBabelInterop = new WeakMap();
|
|
@@ -100,7 +103,6 @@ const Parse /*: ParseType*/ = {
|
|
|
100
103
|
CoreManager: _CoreManager.default,
|
|
101
104
|
Config: _ParseConfig.default,
|
|
102
105
|
Error: _ParseError.default,
|
|
103
|
-
EventuallyQueue: _EventuallyQueue.default,
|
|
104
106
|
FacebookUtils: _FacebookUtils.default,
|
|
105
107
|
File: _ParseFile.default,
|
|
106
108
|
GeoPoint: _ParseGeoPoint.default,
|
|
@@ -126,10 +128,19 @@ const Parse /*: ParseType*/ = {
|
|
|
126
128
|
Storage: _Storage.default,
|
|
127
129
|
User: _ParseUser.default,
|
|
128
130
|
LiveQueryClient: _LiveQueryClient.default,
|
|
129
|
-
LiveQuery: undefined,
|
|
130
131
|
IndexedDB: undefined,
|
|
131
132
|
Hooks: undefined,
|
|
132
133
|
Parse: undefined,
|
|
134
|
+
/**
|
|
135
|
+
* @member {EventuallyQueue} Parse.EventuallyQueue
|
|
136
|
+
* @static
|
|
137
|
+
*/
|
|
138
|
+
set EventuallyQueue(queue /*: EventuallyQueue*/) {
|
|
139
|
+
_CoreManager.default.setEventuallyQueue(queue);
|
|
140
|
+
},
|
|
141
|
+
get EventuallyQueue() {
|
|
142
|
+
return _CoreManager.default.getEventuallyQueue();
|
|
143
|
+
},
|
|
133
144
|
/**
|
|
134
145
|
* Call this method first to set up your authentication tokens for Parse.
|
|
135
146
|
*
|
|
@@ -147,8 +158,13 @@ const Parse /*: ParseType*/ = {
|
|
|
147
158
|
_CoreManager.default.set('MASTER_KEY', masterKey);
|
|
148
159
|
_CoreManager.default.set('USE_MASTER_KEY', false);
|
|
149
160
|
_CoreManager.default.setIfNeeded('EventEmitter', _EventEmitter.default);
|
|
150
|
-
|
|
151
|
-
_CoreManager.default.setIfNeeded('
|
|
161
|
+
_CoreManager.default.setIfNeeded('LiveQuery', new _ParseLiveQuery.default());
|
|
162
|
+
_CoreManager.default.setIfNeeded('CryptoController', _CryptoController.default);
|
|
163
|
+
_CoreManager.default.setIfNeeded('EventuallyQueue', _EventuallyQueue.default);
|
|
164
|
+
_CoreManager.default.setIfNeeded('InstallationController', _InstallationController.default);
|
|
165
|
+
_CoreManager.default.setIfNeeded('LocalDatastoreController', _LocalDatastoreController.default);
|
|
166
|
+
_CoreManager.default.setIfNeeded('StorageController', _StorageController.default);
|
|
167
|
+
_CoreManager.default.setIfNeeded('WebSocketController', _WebSocketController.default);
|
|
152
168
|
},
|
|
153
169
|
/**
|
|
154
170
|
* Call this method to set your AsyncStorage engine
|
|
@@ -240,6 +256,16 @@ const Parse /*: ParseType*/ = {
|
|
|
240
256
|
get serverAuthType() {
|
|
241
257
|
return _CoreManager.default.get('SERVER_AUTH_TYPE');
|
|
242
258
|
},
|
|
259
|
+
/**
|
|
260
|
+
* @member {ParseLiveQuery} Parse.LiveQuery
|
|
261
|
+
* @static
|
|
262
|
+
*/
|
|
263
|
+
set LiveQuery(liveQuery /*: ParseLiveQuery*/) {
|
|
264
|
+
_CoreManager.default.setLiveQuery(liveQuery);
|
|
265
|
+
},
|
|
266
|
+
get LiveQuery() {
|
|
267
|
+
return _CoreManager.default.getLiveQuery();
|
|
268
|
+
},
|
|
243
269
|
/**
|
|
244
270
|
* @member {string} Parse.liveQueryServerURL
|
|
245
271
|
* @static
|
|
@@ -322,7 +348,7 @@ const Parse /*: ParseType*/ = {
|
|
|
322
348
|
if (!this.LocalDatastore.isEnabled) {
|
|
323
349
|
this.LocalDatastore.isEnabled = true;
|
|
324
350
|
if (polling) {
|
|
325
|
-
|
|
351
|
+
_CoreManager.default.getEventuallyQueue().poll(ms);
|
|
326
352
|
}
|
|
327
353
|
}
|
|
328
354
|
},
|
|
@@ -372,8 +398,6 @@ const Parse /*: ParseType*/ = {
|
|
|
372
398
|
return this.encryptedUser;
|
|
373
399
|
}
|
|
374
400
|
};
|
|
375
|
-
_CoreManager.default.setCryptoController(_CryptoController.default);
|
|
376
|
-
_CoreManager.default.setInstallationController(_InstallationController.default);
|
|
377
401
|
_CoreManager.default.setRESTController(_RESTController.default);
|
|
378
402
|
Parse.initialize = Parse._initialize;
|
|
379
403
|
Parse.Cloud = Parse.Cloud || {};
|
package/lib/node/ParseACL.js
CHANGED
|
@@ -4,8 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var
|
|
8
|
-
var _ParseUser = _interopRequireDefault(require("./ParseUser"));
|
|
7
|
+
var _CoreManager = _interopRequireDefault(require("./CoreManager"));
|
|
9
8
|
function _interopRequireDefault(obj) {
|
|
10
9
|
return obj && obj.__esModule ? obj : {
|
|
11
10
|
default: obj
|
|
@@ -14,6 +13,8 @@ function _interopRequireDefault(obj) {
|
|
|
14
13
|
/**
|
|
15
14
|
* @flow
|
|
16
15
|
*/
|
|
16
|
+
/*:: import type ParseRole from './ParseRole';*/
|
|
17
|
+
/*:: import type ParseUser from './ParseUser';*/
|
|
17
18
|
/*:: type PermissionsMap = { [permission: string]: boolean };*/
|
|
18
19
|
/*:: type ByIdMap = { [userId: string]: PermissionsMap };*/
|
|
19
20
|
const PUBLIC_KEY = '*';
|
|
@@ -40,7 +41,8 @@ class ParseACL {
|
|
|
40
41
|
constructor(arg1 /*: ParseUser | ByIdMap*/) {
|
|
41
42
|
this.permissionsById = {};
|
|
42
43
|
if (arg1 && typeof arg1 === 'object') {
|
|
43
|
-
|
|
44
|
+
const ParseUser = _CoreManager.default.getParseUser();
|
|
45
|
+
if (arg1 instanceof ParseUser) {
|
|
44
46
|
this.setReadAccess(arg1, true);
|
|
45
47
|
this.setWriteAccess(arg1, true);
|
|
46
48
|
} else {
|
|
@@ -106,9 +108,11 @@ class ParseACL {
|
|
|
106
108
|
return true;
|
|
107
109
|
}
|
|
108
110
|
_setAccess(accessType /*: string*/, userId /*: ParseUser | ParseRole | string*/, allowed /*: boolean*/) {
|
|
109
|
-
|
|
111
|
+
const ParseRole = _CoreManager.default.getParseRole();
|
|
112
|
+
const ParseUser = _CoreManager.default.getParseUser();
|
|
113
|
+
if (userId instanceof ParseUser) {
|
|
110
114
|
userId = userId.id;
|
|
111
|
-
} else if (userId instanceof
|
|
115
|
+
} else if (userId instanceof ParseRole) {
|
|
112
116
|
const name = userId.getName();
|
|
113
117
|
if (!name) {
|
|
114
118
|
throw new TypeError('Role must have a name');
|
|
@@ -141,12 +145,14 @@ class ParseACL {
|
|
|
141
145
|
}
|
|
142
146
|
}
|
|
143
147
|
_getAccess(accessType /*: string*/, userId /*: ParseUser | ParseRole | string*/) /*: boolean*/{
|
|
144
|
-
|
|
148
|
+
const ParseRole = _CoreManager.default.getParseRole();
|
|
149
|
+
const ParseUser = _CoreManager.default.getParseUser();
|
|
150
|
+
if (userId instanceof ParseUser) {
|
|
145
151
|
userId = userId.id;
|
|
146
152
|
if (!userId) {
|
|
147
153
|
throw new Error('Cannot get access for a ParseUser without an ID');
|
|
148
154
|
}
|
|
149
|
-
} else if (userId instanceof
|
|
155
|
+
} else if (userId instanceof ParseRole) {
|
|
150
156
|
const name = userId.getName();
|
|
151
157
|
if (!name) {
|
|
152
158
|
throw new TypeError('Role must have a name');
|
|
@@ -252,7 +258,8 @@ class ParseACL {
|
|
|
252
258
|
* @throws {TypeError} If role is neither a Parse.Role nor a String.
|
|
253
259
|
*/
|
|
254
260
|
getRoleReadAccess(role /*: ParseRole | string*/) /*: boolean*/{
|
|
255
|
-
|
|
261
|
+
const ParseRole = _CoreManager.default.getParseRole();
|
|
262
|
+
if (role instanceof ParseRole) {
|
|
256
263
|
// Normalize to the String name
|
|
257
264
|
role = role.getName();
|
|
258
265
|
}
|
|
@@ -272,7 +279,8 @@ class ParseACL {
|
|
|
272
279
|
* @throws {TypeError} If role is neither a Parse.Role nor a String.
|
|
273
280
|
*/
|
|
274
281
|
getRoleWriteAccess(role /*: ParseRole | string*/) /*: boolean*/{
|
|
275
|
-
|
|
282
|
+
const ParseRole = _CoreManager.default.getParseRole();
|
|
283
|
+
if (role instanceof ParseRole) {
|
|
276
284
|
// Normalize to the String name
|
|
277
285
|
role = role.getName();
|
|
278
286
|
}
|
|
@@ -291,7 +299,8 @@ class ParseACL {
|
|
|
291
299
|
* @throws {TypeError} If role is neither a Parse.Role nor a String.
|
|
292
300
|
*/
|
|
293
301
|
setRoleReadAccess(role /*: ParseRole | string*/, allowed /*: boolean*/) {
|
|
294
|
-
|
|
302
|
+
const ParseRole = _CoreManager.default.getParseRole();
|
|
303
|
+
if (role instanceof ParseRole) {
|
|
295
304
|
// Normalize to the String name
|
|
296
305
|
role = role.getName();
|
|
297
306
|
}
|
|
@@ -310,7 +319,8 @@ class ParseACL {
|
|
|
310
319
|
* @throws {TypeError} If role is neither a Parse.Role nor a String.
|
|
311
320
|
*/
|
|
312
321
|
setRoleWriteAccess(role /*: ParseRole | string*/, allowed /*: boolean*/) {
|
|
313
|
-
|
|
322
|
+
const ParseRole = _CoreManager.default.getParseRole();
|
|
323
|
+
if (role instanceof ParseRole) {
|
|
314
324
|
// Normalize to the String name
|
|
315
325
|
role = role.getName();
|
|
316
326
|
}
|
package/lib/node/ParseFile.js
CHANGED
|
@@ -23,6 +23,10 @@ if (typeof XMLHttpRequest !== 'undefined') {
|
|
|
23
23
|
/*:: type Base64 = { base64: string };*/
|
|
24
24
|
/*:: type Uri = { uri: string };*/
|
|
25
25
|
/*:: type FileData = Array<number> | Base64 | Blob | Uri;*/
|
|
26
|
+
/*:: export type FileSaveOptions = FullOptions & {
|
|
27
|
+
metadata?: { [key: string]: any },
|
|
28
|
+
tags?: { [key: string]: any },
|
|
29
|
+
};*/
|
|
26
30
|
/*:: export type FileSource =
|
|
27
31
|
| {
|
|
28
32
|
format: 'file',
|
|
@@ -4,10 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
/**
|
|
8
|
-
* @flow
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
7
|
/**
|
|
12
8
|
* Creates a new GeoPoint with any of the following forms:<br>
|
|
13
9
|
* <pre>
|
|
@@ -33,8 +29,6 @@ exports.default = void 0;
|
|
|
33
29
|
*/
|
|
34
30
|
/* global navigator */
|
|
35
31
|
class ParseGeoPoint {
|
|
36
|
-
/*:: _latitude: number;*/
|
|
37
|
-
/*:: _longitude: number;*/
|
|
38
32
|
/**
|
|
39
33
|
* @param {(number[] | object | number)} arg1 Either a list of coordinate pairs, an object with `latitude`, `longitude`, or the latitude or the point.
|
|
40
34
|
* @param {number} arg2 The longitude of the GeoPoint
|
|
@@ -101,7 +95,7 @@ class ParseGeoPoint {
|
|
|
101
95
|
longitude: this._longitude
|
|
102
96
|
};
|
|
103
97
|
}
|
|
104
|
-
equals(other /*:
|
|
98
|
+
equals(other /*: any*/) /*: boolean*/{
|
|
105
99
|
return other instanceof ParseGeoPoint && this.latitude === other.latitude && this.longitude === other.longitude;
|
|
106
100
|
}
|
|
107
101
|
|
|
@@ -169,12 +163,18 @@ class ParseGeoPoint {
|
|
|
169
163
|
/**
|
|
170
164
|
* Creates a GeoPoint with the user's current location, if available.
|
|
171
165
|
*
|
|
166
|
+
* @param {object} options The options.
|
|
167
|
+
* @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.
|
|
168
|
+
* @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.
|
|
169
|
+
* @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.
|
|
172
170
|
* @static
|
|
173
|
-
* @returns {Parse.GeoPoint} User's current location
|
|
171
|
+
* @returns {Promise<Parse.GeoPoint>} User's current location
|
|
174
172
|
*/
|
|
175
|
-
static current() {
|
|
176
|
-
return
|
|
177
|
-
|
|
173
|
+
static current(options) /*: Promise<ParseGeoPoint>*/{
|
|
174
|
+
return new Promise((resolve, reject) => {
|
|
175
|
+
navigator.geolocation.getCurrentPosition(location => {
|
|
176
|
+
resolve(new ParseGeoPoint(location.coords.latitude, location.coords.longitude));
|
|
177
|
+
}, reject, options);
|
|
178
178
|
});
|
|
179
179
|
}
|
|
180
180
|
}
|
package/lib/node/ParseHooks.js
CHANGED
|
@@ -24,6 +24,8 @@ function _interopRequireDefault(obj) {
|
|
|
24
24
|
default: obj
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
|
+
/*:: export type HookDeclaration = { functionName: string, url: string } | { className: string, triggerName: string, url: string };*/
|
|
28
|
+
/*:: export type HookDeleteArg = { functionName: string } | { className: string, triggerName: string };*/
|
|
27
29
|
function getFunctions() {
|
|
28
30
|
return _CoreManager.default.getHooksController().get('functions');
|
|
29
31
|
}
|