parse 5.1.0-alpha.1 → 5.1.0-alpha.10
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 +1452 -1043
- package/dist/parse.min.js +2 -2
- package/dist/parse.weapp.js +2355 -1082
- 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/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/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/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/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,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',
|
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
|
}
|
|
@@ -4,25 +4,225 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
+
var _CoreManager = _interopRequireDefault(require("./CoreManager"));
|
|
7
8
|
var _ParseObject = _interopRequireDefault(require("./ParseObject"));
|
|
8
9
|
function _interopRequireDefault(obj) {
|
|
9
10
|
return obj && obj.__esModule ? obj : {
|
|
10
11
|
default: obj
|
|
11
12
|
};
|
|
12
13
|
}
|
|
14
|
+
const DEVICE_TYPES /*: DeviceInterface*/ = {
|
|
15
|
+
IOS: 'ios',
|
|
16
|
+
MACOS: 'macos',
|
|
17
|
+
TVOS: 'tvos',
|
|
18
|
+
FCM: 'fcm',
|
|
19
|
+
ANDROID: 'android',
|
|
20
|
+
WEB: 'web'
|
|
21
|
+
};
|
|
22
|
+
|
|
13
23
|
/**
|
|
14
|
-
*
|
|
24
|
+
* Parse.Installation is a local representation of installation data that can be saved and retrieved from the Parse cloud.
|
|
25
|
+
* This class is a subclass of a Parse.Object, and retains the same functionality of a Parse.Object, but also extends it with installation-specific features.
|
|
26
|
+
*
|
|
27
|
+
* <p>A valid Parse.Installation can only be instantiated via <code>Parse.Installation.currentInstallation()</code>
|
|
28
|
+
*
|
|
29
|
+
* Parse.Installation objects which have a valid <code>deviceToken</code> and are saved to the Parse cloud can be used to target push notifications.
|
|
30
|
+
* </p>
|
|
31
|
+
*
|
|
32
|
+
* @alias Parse.Installation
|
|
15
33
|
*/
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
34
|
+
class ParseInstallation extends _ParseObject.default {
|
|
35
|
+
/**
|
|
36
|
+
* @param {object} attributes The initial set of data to store in the object.
|
|
37
|
+
*/
|
|
38
|
+
constructor(attributes /*:: ?: AttributeMap*/) {
|
|
19
39
|
super('_Installation');
|
|
20
40
|
if (attributes && typeof attributes === 'object') {
|
|
21
|
-
if (!this.set(attributes
|
|
41
|
+
if (!this.set(attributes)) {
|
|
22
42
|
throw new Error("Can't create an invalid Installation");
|
|
23
43
|
}
|
|
24
44
|
}
|
|
25
45
|
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* A unique identifier for this installation’s client application. In iOS, this is the Bundle Identifier.
|
|
49
|
+
*
|
|
50
|
+
* @property {string} appIdentifier
|
|
51
|
+
* @static
|
|
52
|
+
*/
|
|
53
|
+
get appIdentifier() {
|
|
54
|
+
return this.get('appIdentifier');
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* The version string of the client application to which this installation belongs.
|
|
59
|
+
*
|
|
60
|
+
* @property {string} appVersion
|
|
61
|
+
* @static
|
|
62
|
+
*/
|
|
63
|
+
get appVersion() {
|
|
64
|
+
return this.get('appVersion');
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* The display name of the client application to which this installation belongs.
|
|
69
|
+
*
|
|
70
|
+
* @property {string} appName
|
|
71
|
+
* @static
|
|
72
|
+
*/
|
|
73
|
+
get appName() {
|
|
74
|
+
return this.get('appName');
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* The current value of the icon badge for iOS apps.
|
|
79
|
+
* Changes to this value on the server will be used
|
|
80
|
+
* for future badge-increment push notifications.
|
|
81
|
+
*
|
|
82
|
+
* @property {number} badge
|
|
83
|
+
* @static
|
|
84
|
+
*/
|
|
85
|
+
get badge() {
|
|
86
|
+
return this.get('badge');
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* An array of the channels to which a device is currently subscribed.
|
|
91
|
+
*
|
|
92
|
+
* @property {string[]} channels
|
|
93
|
+
* @static
|
|
94
|
+
*/
|
|
95
|
+
get channels() {
|
|
96
|
+
return this.get('channels');
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Token used to deliver push notifications to the device.
|
|
101
|
+
*
|
|
102
|
+
* @property {string} deviceToken
|
|
103
|
+
* @static
|
|
104
|
+
*/
|
|
105
|
+
get deviceToken() {
|
|
106
|
+
return this.get('deviceToken');
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* The type of device, “ios”, “android”, “web”, etc.
|
|
111
|
+
*
|
|
112
|
+
* @property {string} deviceType
|
|
113
|
+
* @static
|
|
114
|
+
*/
|
|
115
|
+
get deviceType() {
|
|
116
|
+
return this.get('deviceType');
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Gets the GCM sender identifier for this installation
|
|
121
|
+
*
|
|
122
|
+
* @property {string} GCMSenderId
|
|
123
|
+
* @static
|
|
124
|
+
*/
|
|
125
|
+
get GCMSenderId() {
|
|
126
|
+
return this.get('GCMSenderId');
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Universally Unique Identifier (UUID) for the device used by Parse. It must be unique across all of an app’s installations.
|
|
131
|
+
*
|
|
132
|
+
* @property {string} installationId
|
|
133
|
+
* @static
|
|
134
|
+
*/
|
|
135
|
+
get installationId() {
|
|
136
|
+
return this.get('installationId');
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Gets the local identifier for this installation
|
|
141
|
+
*
|
|
142
|
+
* @property {string} localeIdentifier
|
|
143
|
+
* @static
|
|
144
|
+
*/
|
|
145
|
+
get localeIdentifier() {
|
|
146
|
+
return this.get('localeIdentifier');
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Gets the parse server version for this installation
|
|
151
|
+
*
|
|
152
|
+
* @property {string} parseVersion
|
|
153
|
+
* @static
|
|
154
|
+
*/
|
|
155
|
+
get parseVersion() {
|
|
156
|
+
return this.get('parseVersion');
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* This field is reserved for directing Parse to the push delivery network to be used.
|
|
161
|
+
*
|
|
162
|
+
* @property {string} pushType
|
|
163
|
+
* @static
|
|
164
|
+
*/
|
|
165
|
+
get pushType() {
|
|
166
|
+
return this.get('pushType');
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Gets the time zone for this installation
|
|
171
|
+
*
|
|
172
|
+
* @property {string} timeZone
|
|
173
|
+
* @static
|
|
174
|
+
*/
|
|
175
|
+
get timeZone() {
|
|
176
|
+
return this.get('timeZone');
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Returns the device types for used for Push Notifications.
|
|
181
|
+
*
|
|
182
|
+
* <pre>
|
|
183
|
+
* Parse.Installation.DEVICE_TYPES.IOS
|
|
184
|
+
* Parse.Installation.DEVICE_TYPES.MACOS
|
|
185
|
+
* Parse.Installation.DEVICE_TYPES.TVOS
|
|
186
|
+
* Parse.Installation.DEVICE_TYPES.FCM
|
|
187
|
+
* Parse.Installation.DEVICE_TYPES.ANDROID
|
|
188
|
+
* Parse.Installation.DEVICE_TYPES.WEB
|
|
189
|
+
* </pre
|
|
190
|
+
*
|
|
191
|
+
* @property {Object} DEVICE_TYPES
|
|
192
|
+
* @static
|
|
193
|
+
*/
|
|
194
|
+
static get DEVICE_TYPES() /*: DeviceInterface*/{
|
|
195
|
+
return DEVICE_TYPES;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Wrap the default save behavior with functionality to save to local storage.
|
|
200
|
+
*
|
|
201
|
+
* @param {...any} args
|
|
202
|
+
* @returns {Promise}
|
|
203
|
+
*/
|
|
204
|
+
async save(...args) /*: Promise<ParseInstallation>*/{
|
|
205
|
+
await super.save.apply(this, args);
|
|
206
|
+
await _CoreManager.default.getInstallationController().updateInstallationOnDisk(this);
|
|
207
|
+
return this;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Get the current Parse.Installation from disk. If doesn't exists, create an new installation.
|
|
212
|
+
*
|
|
213
|
+
* <pre>
|
|
214
|
+
* const installation = await Parse.Installation.currentInstallation();
|
|
215
|
+
* installation.set('deviceToken', '123');
|
|
216
|
+
* await installation.save();
|
|
217
|
+
* </pre>
|
|
218
|
+
*
|
|
219
|
+
* @returns {Promise} A promise that resolves to the local installation object.
|
|
220
|
+
*/
|
|
221
|
+
static currentInstallation() /*: Promise<ParseInstallation>*/{
|
|
222
|
+
return _CoreManager.default.getInstallationController().currentInstallation();
|
|
223
|
+
}
|
|
26
224
|
}
|
|
27
|
-
|
|
28
|
-
|
|
225
|
+
_ParseObject.default.registerSubclass('_Installation', ParseInstallation);
|
|
226
|
+
module.exports = ParseInstallation;
|
|
227
|
+
var _default = ParseInstallation;
|
|
228
|
+
exports.default = _default;
|
|
@@ -50,9 +50,8 @@ class LiveQuery {
|
|
|
50
50
|
constructor() {
|
|
51
51
|
const EventEmitter = _CoreManager.default.getEventEmitter();
|
|
52
52
|
this.emitter = new EventEmitter();
|
|
53
|
-
this.on = this.emitter.on;
|
|
54
|
-
this.emit = this.emitter.emit;
|
|
55
|
-
|
|
53
|
+
this.on = (eventName, listener) => this.emitter.on(eventName, listener);
|
|
54
|
+
this.emit = (eventName, ...args) => this.emitter.emit(eventName, ...args);
|
|
56
55
|
// adding listener so process does not crash
|
|
57
56
|
// best practice is for developer to register their own listener
|
|
58
57
|
this.on('error', () => {});
|
package/lib/node/ParseObject.js
CHANGED
|
@@ -9,7 +9,6 @@ var _canBeSerialized = _interopRequireDefault(require("./canBeSerialized"));
|
|
|
9
9
|
var _decode = _interopRequireDefault(require("./decode"));
|
|
10
10
|
var _encode = _interopRequireDefault(require("./encode"));
|
|
11
11
|
var _escape = _interopRequireDefault(require("./escape"));
|
|
12
|
-
var _EventuallyQueue = _interopRequireDefault(require("./EventuallyQueue"));
|
|
13
12
|
var _ParseACL = _interopRequireDefault(require("./ParseACL"));
|
|
14
13
|
var _parseDate = _interopRequireDefault(require("./parseDate"));
|
|
15
14
|
var _ParseError = _interopRequireDefault(require("./ParseError"));
|
|
@@ -17,7 +16,6 @@ var _ParseFile = _interopRequireDefault(require("./ParseFile"));
|
|
|
17
16
|
var _promiseUtils = require("./promiseUtils");
|
|
18
17
|
var _LocalDatastoreUtils = require("./LocalDatastoreUtils");
|
|
19
18
|
var _ParseOp = require("./ParseOp");
|
|
20
|
-
var _ParseQuery = _interopRequireDefault(require("./ParseQuery"));
|
|
21
19
|
var _ParseRelation = _interopRequireDefault(require("./ParseRelation"));
|
|
22
20
|
var SingleInstanceStateController = _interopRequireWildcard(require("./SingleInstanceStateController"));
|
|
23
21
|
var _unique = _interopRequireDefault(require("./unique"));
|
|
@@ -474,10 +472,6 @@ class ParseObject {
|
|
|
474
472
|
json[attr] = (0, _encode.default)(attrs[attr], false, false, seen, offline);
|
|
475
473
|
}
|
|
476
474
|
}
|
|
477
|
-
const pending = this._getPendingOps();
|
|
478
|
-
for (const attr in pending[0]) {
|
|
479
|
-
json[attr] = pending[0][attr].toJSON(offline);
|
|
480
|
-
}
|
|
481
475
|
if (this.id) {
|
|
482
476
|
json.objectId = this.id;
|
|
483
477
|
}
|
|
@@ -997,7 +991,8 @@ class ParseObject {
|
|
|
997
991
|
return false;
|
|
998
992
|
}
|
|
999
993
|
try {
|
|
1000
|
-
const
|
|
994
|
+
const ParseQuery = _CoreManager.default.getParseQuery();
|
|
995
|
+
const query = new ParseQuery(this.className);
|
|
1001
996
|
await query.get(this.id, options);
|
|
1002
997
|
return true;
|
|
1003
998
|
} catch (e) {
|
|
@@ -1207,8 +1202,8 @@ class ParseObject {
|
|
|
1207
1202
|
await this.save(null, options);
|
|
1208
1203
|
} catch (e) {
|
|
1209
1204
|
if (e.code === _ParseError.default.CONNECTION_FAILED) {
|
|
1210
|
-
await
|
|
1211
|
-
|
|
1205
|
+
await _CoreManager.default.getEventuallyQueue().save(this, options);
|
|
1206
|
+
_CoreManager.default.getEventuallyQueue().poll();
|
|
1212
1207
|
}
|
|
1213
1208
|
}
|
|
1214
1209
|
return this;
|
|
@@ -1348,8 +1343,8 @@ class ParseObject {
|
|
|
1348
1343
|
await this.destroy(options);
|
|
1349
1344
|
} catch (e) {
|
|
1350
1345
|
if (e.code === _ParseError.default.CONNECTION_FAILED) {
|
|
1351
|
-
await
|
|
1352
|
-
|
|
1346
|
+
await _CoreManager.default.getEventuallyQueue().destroy(this, options);
|
|
1347
|
+
_CoreManager.default.getEventuallyQueue().poll();
|
|
1353
1348
|
}
|
|
1354
1349
|
}
|
|
1355
1350
|
return this;
|
|
@@ -2187,7 +2182,8 @@ const DefaultController = {
|
|
|
2187
2182
|
if (error) {
|
|
2188
2183
|
return Promise.reject(error);
|
|
2189
2184
|
}
|
|
2190
|
-
const
|
|
2185
|
+
const ParseQuery = _CoreManager.default.getParseQuery();
|
|
2186
|
+
const query = new ParseQuery(className);
|
|
2191
2187
|
query.containedIn('objectId', ids);
|
|
2192
2188
|
if (options && options.include) {
|
|
2193
2189
|
query.include(options.include);
|
|
@@ -2449,6 +2445,7 @@ const DefaultController = {
|
|
|
2449
2445
|
return Promise.resolve();
|
|
2450
2446
|
}
|
|
2451
2447
|
};
|
|
2448
|
+
_CoreManager.default.setParseObject(ParseObject);
|
|
2452
2449
|
_CoreManager.default.setObjectController(DefaultController);
|
|
2453
2450
|
var _default = ParseObject;
|
|
2454
2451
|
exports.default = _default;
|