parse 5.1.0 → 5.2.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/parse.js +1556 -1309
- package/dist/parse.min.js +2 -2
- package/dist/parse.weapp.js +1560 -1313
- package/dist/parse.weapp.min.js +2 -2
- package/lib/browser/Cloud.js +7 -11
- package/lib/browser/CoreManager.js +10 -10
- package/lib/browser/EventuallyQueue.js +1 -1
- package/lib/browser/InstallationController.js +3 -3
- package/lib/browser/LiveQueryClient.js +102 -60
- package/lib/browser/LocalDatastore.js +189 -147
- package/lib/browser/LocalDatastoreController.default.js +14 -9
- package/lib/browser/LocalDatastoreController.react-native.js +14 -12
- package/lib/browser/LocalDatastoreUtils.js +0 -5
- package/lib/browser/ObjectStateMutations.js +57 -21
- package/lib/browser/Parse.js +2 -2
- package/lib/browser/ParseCLP.js +9 -17
- package/lib/browser/ParseFile.js +27 -31
- package/lib/browser/ParseGeoPoint.js +9 -3
- package/lib/browser/ParseHooks.js +13 -13
- package/lib/browser/ParseInstallation.js +117 -9
- package/lib/browser/ParseObject.js +19 -17
- package/lib/browser/ParseOp.js +17 -17
- package/lib/browser/ParsePolygon.js +1 -1
- package/lib/browser/ParseQuery.js +147 -149
- package/lib/browser/ParseRole.js +5 -9
- package/lib/browser/ParseSchema.js +1 -1
- package/lib/browser/ParseUser.js +66 -51
- package/lib/browser/Push.js +5 -10
- package/lib/browser/RESTController.js +1 -1
- package/lib/browser/SingleInstanceStateController.js +1 -1
- package/lib/browser/TaskQueue.js +10 -10
- package/lib/browser/UniqueInstanceStateController.js +1 -1
- package/lib/browser/arrayContainsObject.js +0 -4
- package/lib/browser/canBeSerialized.js +0 -4
- package/lib/browser/decode.js +0 -7
- package/lib/browser/encode.js +3 -7
- package/lib/browser/equals.js +1 -1
- package/lib/browser/escape.js +0 -4
- package/lib/browser/isRevocableSession.js +0 -4
- package/lib/browser/parseDate.js +1 -5
- package/lib/browser/promiseUtils.js +11 -10
- package/lib/browser/unique.js +1 -5
- package/lib/browser/unsavedChildren.js +0 -8
- package/lib/browser/uuid.js +2 -2
- package/lib/node/Cloud.js +7 -11
- package/lib/node/CoreManager.js +10 -10
- package/lib/node/EventuallyQueue.js +1 -1
- package/lib/node/InstallationController.js +3 -3
- package/lib/node/LiveQueryClient.js +14 -24
- package/lib/node/LocalDatastore.js +7 -11
- package/lib/node/LocalDatastoreController.default.js +12 -10
- package/lib/node/LocalDatastoreController.react-native.js +13 -12
- package/lib/node/LocalDatastoreUtils.js +0 -5
- package/lib/node/ObjectStateMutations.js +45 -19
- package/lib/node/Parse.js +2 -2
- package/lib/node/ParseCLP.js +8 -18
- package/lib/node/ParseFile.js +27 -40
- package/lib/node/ParseGeoPoint.js +9 -3
- package/lib/node/ParseHooks.js +13 -13
- package/lib/node/ParseInstallation.js +60 -2
- package/lib/node/ParseObject.js +19 -17
- package/lib/node/ParseOp.js +21 -21
- package/lib/node/ParsePolygon.js +1 -1
- package/lib/node/ParseQuery.js +84 -107
- package/lib/node/ParseRole.js +3 -8
- package/lib/node/ParseSchema.js +4 -4
- package/lib/node/ParseUser.js +42 -37
- package/lib/node/Push.js +3 -8
- package/lib/node/RESTController.js +1 -1
- package/lib/node/SingleInstanceStateController.js +1 -1
- package/lib/node/TaskQueue.js +9 -11
- package/lib/node/UniqueInstanceStateController.js +1 -1
- package/lib/node/arrayContainsObject.js +0 -4
- package/lib/node/canBeSerialized.js +0 -4
- package/lib/node/decode.js +0 -7
- package/lib/node/encode.js +3 -7
- package/lib/node/equals.js +1 -1
- package/lib/node/escape.js +0 -4
- package/lib/node/isRevocableSession.js +0 -4
- package/lib/node/parseDate.js +1 -5
- package/lib/node/promiseUtils.js +11 -10
- package/lib/node/unique.js +1 -5
- package/lib/node/unsavedChildren.js +0 -8
- package/lib/node/uuid.js +2 -2
- package/lib/react-native/Cloud.js +0 -1
- package/lib/react-native/CoreManager.js +1 -1
- package/lib/react-native/LiveQueryClient.js +49 -32
- package/lib/react-native/LocalDatastore.js +38 -14
- package/lib/react-native/LocalDatastoreController.default.js +7 -1
- package/lib/react-native/LocalDatastoreController.react-native.js +7 -1
- package/lib/react-native/ObjectStateMutations.js +30 -9
- package/lib/react-native/ParseCLP.js +3 -3
- package/lib/react-native/ParseFile.js +7 -6
- package/lib/react-native/ParseInstallation.js +51 -3
- package/lib/react-native/ParseObject.js +6 -5
- package/lib/react-native/ParseQuery.js +45 -37
- package/lib/react-native/ParseRole.js +1 -1
- package/lib/react-native/ParseUser.js +22 -16
- package/lib/react-native/TaskQueue.js +8 -2
- package/lib/react-native/decode.js +0 -1
- package/lib/react-native/promiseUtils.js +5 -4
- package/lib/react-native/uuid.js +1 -2
- package/lib/weapp/Cloud.js +7 -11
- package/lib/weapp/CoreManager.js +10 -10
- package/lib/weapp/EventuallyQueue.js +1 -1
- package/lib/weapp/InstallationController.js +3 -3
- package/lib/weapp/LiveQueryClient.js +102 -60
- package/lib/weapp/LocalDatastore.js +189 -147
- package/lib/weapp/LocalDatastoreController.default.js +14 -9
- package/lib/weapp/LocalDatastoreController.react-native.js +14 -12
- package/lib/weapp/LocalDatastoreUtils.js +0 -5
- package/lib/weapp/ObjectStateMutations.js +57 -21
- package/lib/weapp/Parse.js +2 -2
- package/lib/weapp/ParseCLP.js +9 -17
- package/lib/weapp/ParseFile.js +27 -31
- package/lib/weapp/ParseGeoPoint.js +9 -3
- package/lib/weapp/ParseHooks.js +13 -13
- package/lib/weapp/ParseInstallation.js +117 -9
- package/lib/weapp/ParseObject.js +19 -17
- package/lib/weapp/ParseOp.js +17 -17
- package/lib/weapp/ParsePolygon.js +1 -1
- package/lib/weapp/ParseQuery.js +147 -149
- package/lib/weapp/ParseRole.js +5 -9
- package/lib/weapp/ParseSchema.js +1 -1
- package/lib/weapp/ParseUser.js +66 -51
- package/lib/weapp/Push.js +5 -10
- package/lib/weapp/RESTController.js +1 -1
- package/lib/weapp/SingleInstanceStateController.js +1 -1
- package/lib/weapp/TaskQueue.js +10 -10
- package/lib/weapp/UniqueInstanceStateController.js +1 -1
- package/lib/weapp/arrayContainsObject.js +0 -4
- package/lib/weapp/canBeSerialized.js +0 -4
- package/lib/weapp/decode.js +0 -7
- package/lib/weapp/encode.js +3 -7
- package/lib/weapp/equals.js +1 -1
- package/lib/weapp/escape.js +0 -4
- package/lib/weapp/isRevocableSession.js +0 -4
- package/lib/weapp/parseDate.js +1 -5
- package/lib/weapp/promiseUtils.js +11 -10
- package/lib/weapp/unique.js +1 -5
- package/lib/weapp/unsavedChildren.js +0 -8
- package/lib/weapp/uuid.js +3 -3
- package/package.json +5 -6
|
@@ -11,18 +11,19 @@ exports.when = when;
|
|
|
11
11
|
var _promise = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/promise"));
|
|
12
12
|
var _isArray = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/array/is-array"));
|
|
13
13
|
// Create Deferred Promise
|
|
14
|
-
function resolvingPromise() {
|
|
15
|
-
var res
|
|
16
|
-
var rej
|
|
14
|
+
function resolvingPromise /*:: <T = any>*/() {
|
|
15
|
+
var res /*: (value: T) => void*/;
|
|
16
|
+
var rej /*: (error: T) => void*/;
|
|
17
17
|
var promise = new _promise.default(function (resolve, reject) {
|
|
18
18
|
res = resolve;
|
|
19
19
|
rej = reject;
|
|
20
20
|
});
|
|
21
|
-
promise
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
var defer /*: typeof promise & { resolve: (res: T) => void, reject: (err: any) => void }*/ = promise;
|
|
22
|
+
defer.resolve = res;
|
|
23
|
+
defer.reject = rej;
|
|
24
|
+
return defer;
|
|
24
25
|
}
|
|
25
|
-
function when(promises) {
|
|
26
|
+
function when(promises /*: any*/) {
|
|
26
27
|
var objects;
|
|
27
28
|
var arrayArgument = (0, _isArray.default)(promises);
|
|
28
29
|
if (arrayArgument) {
|
|
@@ -40,7 +41,7 @@ function when(promises) {
|
|
|
40
41
|
if (total === 0) {
|
|
41
42
|
return _promise.default.resolve(returnValue);
|
|
42
43
|
}
|
|
43
|
-
var promise =
|
|
44
|
+
var promise = resolvingPromise();
|
|
44
45
|
var resolveOne = function () {
|
|
45
46
|
total--;
|
|
46
47
|
if (total <= 0) {
|
|
@@ -51,7 +52,7 @@ function when(promises) {
|
|
|
51
52
|
}
|
|
52
53
|
}
|
|
53
54
|
};
|
|
54
|
-
var chain = function (object
|
|
55
|
+
var chain = function (object /*: Promise<any>*/, index /*: number*/) {
|
|
55
56
|
if (object && typeof object.then === 'function') {
|
|
56
57
|
object.then(function (result) {
|
|
57
58
|
results[index] = result;
|
|
@@ -71,7 +72,7 @@ function when(promises) {
|
|
|
71
72
|
}
|
|
72
73
|
return promise;
|
|
73
74
|
}
|
|
74
|
-
function continueWhile(test
|
|
75
|
+
function continueWhile(test /*: () => any*/, emitter /*: () => Promise<any>*/) {
|
|
75
76
|
if (test()) {
|
|
76
77
|
return emitter().then(function () {
|
|
77
78
|
return continueWhile(test, emitter);
|
package/lib/browser/unique.js
CHANGED
|
@@ -10,12 +10,8 @@ var _forEach = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-st
|
|
|
10
10
|
var _indexOf = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
|
|
11
11
|
var _arrayContainsObject = _interopRequireDefault(require("./arrayContainsObject"));
|
|
12
12
|
var _CoreManager = _interopRequireDefault(require("./CoreManager"));
|
|
13
|
-
/**
|
|
14
|
-
* @flow
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
13
|
function unique /*:: <T>*/(arr /*: Array<T>*/) /*: Array<T>*/{
|
|
18
|
-
var uniques = [];
|
|
14
|
+
var uniques /*: T[]*/ = [];
|
|
19
15
|
(0, _forEach.default)(arr).call(arr, function (value) {
|
|
20
16
|
var ParseObject = _CoreManager.default.getParseObject();
|
|
21
17
|
if (value instanceof ParseObject) {
|
|
@@ -14,14 +14,6 @@ var _typeof2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/ty
|
|
|
14
14
|
var _CoreManager = _interopRequireDefault(require("./CoreManager"));
|
|
15
15
|
var _ParseFile = _interopRequireDefault(require("./ParseFile"));
|
|
16
16
|
var _ParseRelation = _interopRequireDefault(require("./ParseRelation"));
|
|
17
|
-
/**
|
|
18
|
-
* @flow
|
|
19
|
-
*/
|
|
20
|
-
/*:: import type ParseObject from './ParseObject';*/
|
|
21
|
-
/*:: type EncounterMap = {
|
|
22
|
-
objects: { [identifier: string]: ParseObject | boolean },
|
|
23
|
-
files: Array<ParseFile>,
|
|
24
|
-
};*/
|
|
25
17
|
/**
|
|
26
18
|
* Return an array of unsaved children, which are either Parse Objects or Files.
|
|
27
19
|
* If it encounters any dirty Objects without Ids, it will throw an exception.
|
package/lib/browser/uuid.js
CHANGED
|
@@ -6,8 +6,8 @@ _Object$defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _uuid = require("uuid");
|
|
9
|
-
var uuid /*: () => string
|
|
10
|
-
|
|
9
|
+
var uuid = _uuid.v4 /*: () => string*/;
|
|
10
|
+
|
|
11
11
|
module.exports = uuid;
|
|
12
12
|
var _default = uuid;
|
|
13
13
|
exports.default = _default;
|
package/lib/node/Cloud.js
CHANGED
|
@@ -12,16 +12,11 @@ var _decode = _interopRequireDefault(require("./decode"));
|
|
|
12
12
|
var _encode = _interopRequireDefault(require("./encode"));
|
|
13
13
|
var _ParseError = _interopRequireDefault(require("./ParseError"));
|
|
14
14
|
var _ParseQuery = _interopRequireDefault(require("./ParseQuery"));
|
|
15
|
-
var _ParseObject = _interopRequireDefault(require("./ParseObject"));
|
|
16
15
|
function _interopRequireDefault(obj) {
|
|
17
16
|
return obj && obj.__esModule ? obj : {
|
|
18
17
|
default: obj
|
|
19
18
|
};
|
|
20
19
|
}
|
|
21
|
-
/**
|
|
22
|
-
* @flow
|
|
23
|
-
*/
|
|
24
|
-
/*:: import type { RequestOptions } from './RESTController';*/
|
|
25
20
|
/**
|
|
26
21
|
* Contains functions for calling and declaring
|
|
27
22
|
* <a href="/docs/cloud_code_guide#functions">cloud functions</a>.
|
|
@@ -33,6 +28,7 @@ function _interopRequireDefault(obj) {
|
|
|
33
28
|
* @static
|
|
34
29
|
* @hideconstructor
|
|
35
30
|
*/
|
|
31
|
+
|
|
36
32
|
/**
|
|
37
33
|
* Makes a call to a cloud function.
|
|
38
34
|
*
|
|
@@ -44,12 +40,12 @@ function _interopRequireDefault(obj) {
|
|
|
44
40
|
* @returns {Promise} A promise that will be resolved with the result
|
|
45
41
|
* of the function.
|
|
46
42
|
*/
|
|
47
|
-
function run(name /*: string*/, data /*:
|
|
43
|
+
function run(name /*: string*/, data /*: any*/, options /*: RequestOptions*/) /*: Promise<any>*/{
|
|
48
44
|
options = options || {};
|
|
49
45
|
if (typeof name !== 'string' || name.length === 0) {
|
|
50
46
|
throw new TypeError('Cloud function name must be a string.');
|
|
51
47
|
}
|
|
52
|
-
const requestOptions = {};
|
|
48
|
+
const requestOptions /*: RequestOptions*/ = {};
|
|
53
49
|
if (options.useMasterKey) {
|
|
54
50
|
requestOptions.useMasterKey = options.useMasterKey;
|
|
55
51
|
}
|
|
@@ -73,7 +69,7 @@ function run(name /*: string*/, data /*: mixed*/, options /*: RequestOptions*/)
|
|
|
73
69
|
* @returns {Promise} A promise that will be resolved with the result
|
|
74
70
|
* of the function.
|
|
75
71
|
*/
|
|
76
|
-
function getJobsData() /*: Promise<
|
|
72
|
+
function getJobsData() /*: Promise<any>*/{
|
|
77
73
|
return _CoreManager.default.getCloudController().getJobsData({
|
|
78
74
|
useMasterKey: true
|
|
79
75
|
});
|
|
@@ -89,7 +85,7 @@ function getJobsData() /*: Promise<Object>*/{
|
|
|
89
85
|
* @returns {Promise} A promise that will be resolved with the jobStatusId
|
|
90
86
|
* of the job.
|
|
91
87
|
*/
|
|
92
|
-
function startJob(name /*: string*/, data /*:
|
|
88
|
+
function startJob(name /*: string*/, data /*: any*/) /*: Promise<string>*/{
|
|
93
89
|
if (typeof name !== 'string' || name.length === 0) {
|
|
94
90
|
throw new TypeError('Cloud job name must be a string.');
|
|
95
91
|
}
|
|
@@ -113,7 +109,7 @@ function getJobStatus(jobStatusId /*: string*/) /*: Promise<ParseObject>*/{
|
|
|
113
109
|
});
|
|
114
110
|
}
|
|
115
111
|
const DefaultController = {
|
|
116
|
-
run(name
|
|
112
|
+
run(name /*: string*/, data /*: any*/, options /*: RequestOptions*/) {
|
|
117
113
|
const RESTController = _CoreManager.default.getRESTController();
|
|
118
114
|
const payload = (0, _encode.default)(data, true);
|
|
119
115
|
const request = RESTController.request('POST', 'functions/' + name, payload, options);
|
|
@@ -132,7 +128,7 @@ const DefaultController = {
|
|
|
132
128
|
const RESTController = _CoreManager.default.getRESTController();
|
|
133
129
|
return RESTController.request('GET', 'cloud_code/jobs/data', null, options);
|
|
134
130
|
},
|
|
135
|
-
async startJob(name
|
|
131
|
+
async startJob(name /*: string*/, data /*: any*/, options /*: RequestOptions*/) {
|
|
136
132
|
var _response$_headers;
|
|
137
133
|
const RESTController = _CoreManager.default.getRESTController();
|
|
138
134
|
const payload = (0, _encode.default)(data, true);
|
package/lib/node/CoreManager.js
CHANGED
|
@@ -23,7 +23,7 @@ const config /*: Config & { [key: string]: any }*/ = {
|
|
|
23
23
|
SERVER_AUTH_TOKEN: null,
|
|
24
24
|
LIVEQUERY_SERVER_URL: null,
|
|
25
25
|
ENCRYPTED_KEY: null,
|
|
26
|
-
VERSION: 'js' + "5.
|
|
26
|
+
VERSION: 'js' + "5.2.0-alpha.1",
|
|
27
27
|
APPLICATION_ID: null,
|
|
28
28
|
JAVASCRIPT_KEY: null,
|
|
29
29
|
MASTER_KEY: null,
|
|
@@ -227,34 +227,34 @@ const CoreManager = {
|
|
|
227
227
|
getHooksController() /*: HooksController*/{
|
|
228
228
|
return config['HooksController'];
|
|
229
229
|
},
|
|
230
|
-
setParseOp(op /*:
|
|
230
|
+
setParseOp(op /*: any*/) {
|
|
231
231
|
config['ParseOp'] = op;
|
|
232
232
|
},
|
|
233
233
|
getParseOp() {
|
|
234
234
|
return config['ParseOp'];
|
|
235
235
|
},
|
|
236
|
-
setParseObject(object /*:
|
|
236
|
+
setParseObject(object /*: any*/) {
|
|
237
237
|
config['ParseObject'] = object;
|
|
238
238
|
},
|
|
239
|
-
getParseObject()
|
|
239
|
+
getParseObject() {
|
|
240
240
|
return config['ParseObject'];
|
|
241
241
|
},
|
|
242
|
-
setParseQuery(query /*:
|
|
242
|
+
setParseQuery(query /*: any*/) {
|
|
243
243
|
config['ParseQuery'] = query;
|
|
244
244
|
},
|
|
245
|
-
getParseQuery()
|
|
245
|
+
getParseQuery() {
|
|
246
246
|
return config['ParseQuery'];
|
|
247
247
|
},
|
|
248
|
-
setParseRole(role /*:
|
|
248
|
+
setParseRole(role /*: any*/) {
|
|
249
249
|
config['ParseRole'] = role;
|
|
250
250
|
},
|
|
251
|
-
getParseRole()
|
|
251
|
+
getParseRole() {
|
|
252
252
|
return config['ParseRole'];
|
|
253
253
|
},
|
|
254
|
-
setParseUser(user /*:
|
|
254
|
+
setParseUser(user /*: any*/) {
|
|
255
255
|
config['ParseUser'] = user;
|
|
256
256
|
},
|
|
257
|
-
getParseUser()
|
|
257
|
+
getParseUser() {
|
|
258
258
|
return config['ParseUser'];
|
|
259
259
|
}
|
|
260
260
|
};
|
|
@@ -16,7 +16,7 @@ function _interopRequireDefault(obj) {
|
|
|
16
16
|
const CURRENT_INSTALLATION_KEY = 'currentInstallation';
|
|
17
17
|
const CURRENT_INSTALLATION_ID_KEY = 'currentInstallationId';
|
|
18
18
|
let iidCache /*: string | null*/ = null;
|
|
19
|
-
let currentInstallationCache = null;
|
|
19
|
+
let currentInstallationCache /*: ParseInstallation | null*/ = null;
|
|
20
20
|
let currentInstallationCacheMatchesDisk = false;
|
|
21
21
|
const InstallationController = {
|
|
22
22
|
async updateInstallationOnDisk(installation /*: ParseInstallation*/) /*: Promise<void>*/{
|
|
@@ -48,7 +48,7 @@ const InstallationController = {
|
|
|
48
48
|
return null;
|
|
49
49
|
}
|
|
50
50
|
const path = _Storage.default.generatePath(CURRENT_INSTALLATION_KEY);
|
|
51
|
-
let installationData = await _Storage.default.getItemAsync(path);
|
|
51
|
+
let installationData /*: any*/ = await _Storage.default.getItemAsync(path);
|
|
52
52
|
currentInstallationCacheMatchesDisk = true;
|
|
53
53
|
if (installationData) {
|
|
54
54
|
installationData = JSON.parse(installationData);
|
|
@@ -74,7 +74,7 @@ const InstallationController = {
|
|
|
74
74
|
_setInstallationIdCache(iid /*: string*/) {
|
|
75
75
|
iidCache = iid;
|
|
76
76
|
},
|
|
77
|
-
_setCurrentInstallationCache(installation /*: ParseInstallation*/, matchesDisk
|
|
77
|
+
_setCurrentInstallationCache(installation /*: ParseInstallation*/, matchesDisk = true) {
|
|
78
78
|
currentInstallationCache = installation;
|
|
79
79
|
currentInstallationCacheMatchesDisk = matchesDisk;
|
|
80
80
|
}
|
|
@@ -111,20 +111,6 @@ const generateInterval = k => {
|
|
|
111
111
|
* @alias Parse.LiveQueryClient
|
|
112
112
|
*/
|
|
113
113
|
class LiveQueryClient {
|
|
114
|
-
/*:: attempts: number;*/
|
|
115
|
-
/*:: id: number;*/
|
|
116
|
-
/*:: requestId: number;*/
|
|
117
|
-
/*:: applicationId: string;*/
|
|
118
|
-
/*:: serverURL: string;*/
|
|
119
|
-
/*:: javascriptKey: ?string;*/
|
|
120
|
-
/*:: masterKey: ?string;*/
|
|
121
|
-
/*:: sessionToken: ?string;*/
|
|
122
|
-
/*:: installationId: ?string;*/
|
|
123
|
-
/*:: additionalProperties: boolean;*/
|
|
124
|
-
/*:: connectPromise: Promise;*/
|
|
125
|
-
/*:: subscriptions: Map;*/
|
|
126
|
-
/*:: socket: any;*/
|
|
127
|
-
/*:: state: string;*/
|
|
128
114
|
/**
|
|
129
115
|
* @param {object} options
|
|
130
116
|
* @param {string} options.applicationId - applicationId of your Parse app
|
|
@@ -181,11 +167,11 @@ class LiveQueryClient {
|
|
|
181
167
|
* <a href="https://github.com/parse-community/parse-server/wiki/Parse-LiveQuery-Protocol-Specification">here</a> for more details. The subscription you get is the same subscription you get
|
|
182
168
|
* from our Standard API.
|
|
183
169
|
*
|
|
184
|
-
* @param {
|
|
170
|
+
* @param {ParseQuery} query - the ParseQuery you want to subscribe to
|
|
185
171
|
* @param {string} sessionToken (optional)
|
|
186
172
|
* @returns {LiveQuerySubscription | undefined}
|
|
187
173
|
*/
|
|
188
|
-
subscribe(query /*:
|
|
174
|
+
subscribe(query /*: ParseQuery*/, sessionToken /*:: ?: string*/) /*: LiveQuerySubscription | undefined*/{
|
|
189
175
|
var _queryJSON$keys, _queryJSON$watch;
|
|
190
176
|
if (!query) {
|
|
191
177
|
return;
|
|
@@ -203,7 +189,8 @@ class LiveQueryClient {
|
|
|
203
189
|
where,
|
|
204
190
|
keys,
|
|
205
191
|
watch
|
|
206
|
-
}
|
|
192
|
+
},
|
|
193
|
+
sessionToken: undefined
|
|
207
194
|
};
|
|
208
195
|
if (sessionToken) {
|
|
209
196
|
subscribeRequest.sessionToken = sessionToken;
|
|
@@ -225,7 +212,7 @@ class LiveQueryClient {
|
|
|
225
212
|
* @param {object} subscription - subscription you would like to unsubscribe from.
|
|
226
213
|
* @returns {Promise | undefined}
|
|
227
214
|
*/
|
|
228
|
-
unsubscribe(subscription /*:
|
|
215
|
+
async unsubscribe(subscription /*: LiveQuerySubscription*/) /*: Promise<void>*/{
|
|
229
216
|
if (!subscription) {
|
|
230
217
|
return;
|
|
231
218
|
}
|
|
@@ -265,7 +252,8 @@ class LiveQueryClient {
|
|
|
265
252
|
this._handleWebSocketMessage(event);
|
|
266
253
|
};
|
|
267
254
|
this.socket.onclose = event => {
|
|
268
|
-
|
|
255
|
+
var _this$socket$closingP;
|
|
256
|
+
(_this$socket$closingP = this.socket.closingPromise) === null || _this$socket$closingP === void 0 ? void 0 : _this$socket$closingP.resolve(event);
|
|
269
257
|
this._handleWebSocketClose();
|
|
270
258
|
};
|
|
271
259
|
this.socket.onerror = error => {
|
|
@@ -287,7 +275,8 @@ class LiveQueryClient {
|
|
|
287
275
|
className,
|
|
288
276
|
where,
|
|
289
277
|
fields
|
|
290
|
-
}
|
|
278
|
+
},
|
|
279
|
+
sessionToken: undefined
|
|
291
280
|
};
|
|
292
281
|
if (sessionToken) {
|
|
293
282
|
subscribeRequest.sessionToken = sessionToken;
|
|
@@ -304,7 +293,7 @@ class LiveQueryClient {
|
|
|
304
293
|
*
|
|
305
294
|
* @returns {Promise | undefined} CloseEvent {@link https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/close_event}
|
|
306
295
|
*/
|
|
307
|
-
close() /*:
|
|
296
|
+
async close() /*: Promise<void>*/{
|
|
308
297
|
var _this$socket, _this$socket2;
|
|
309
298
|
if (this.state === CLIENT_STATE.INITIALIZED || this.state === CLIENT_STATE.DISCONNECTED) {
|
|
310
299
|
return;
|
|
@@ -336,7 +325,8 @@ class LiveQueryClient {
|
|
|
336
325
|
applicationId: this.applicationId,
|
|
337
326
|
javascriptKey: this.javascriptKey,
|
|
338
327
|
masterKey: this.masterKey,
|
|
339
|
-
sessionToken: this.sessionToken
|
|
328
|
+
sessionToken: this.sessionToken,
|
|
329
|
+
installationId: undefined
|
|
340
330
|
};
|
|
341
331
|
if (this.additionalProperties) {
|
|
342
332
|
connectRequest.installationId = this.installationId;
|
|
@@ -348,9 +338,9 @@ class LiveQueryClient {
|
|
|
348
338
|
if (typeof data === 'string') {
|
|
349
339
|
data = JSON.parse(data);
|
|
350
340
|
}
|
|
351
|
-
let subscription = null;
|
|
341
|
+
let subscription /*: null | LiveQuerySubscription*/ = null;
|
|
352
342
|
if (data.requestId) {
|
|
353
|
-
subscription = this.subscriptions.get(data.requestId);
|
|
343
|
+
subscription = this.subscriptions.get(data.requestId) || null;
|
|
354
344
|
}
|
|
355
345
|
const response = {
|
|
356
346
|
clientId: data.clientId,
|
|
@@ -12,10 +12,6 @@ function _interopRequireDefault(obj) {
|
|
|
12
12
|
default: obj
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
|
-
/**
|
|
16
|
-
* @flow
|
|
17
|
-
*/
|
|
18
|
-
/*:: import type ParseObject from './ParseObject';*/
|
|
19
15
|
/**
|
|
20
16
|
* Provides a local datastore which can be used to store and retrieve <code>Parse.Object</code>. <br />
|
|
21
17
|
* To enable this functionality, call <code>Parse.enableLocalDatastore()</code>.
|
|
@@ -39,28 +35,28 @@ function _interopRequireDefault(obj) {
|
|
|
39
35
|
const LocalDatastore = {
|
|
40
36
|
isEnabled: false,
|
|
41
37
|
isSyncing: false,
|
|
42
|
-
fromPinWithName(name /*: string*/) /*: Promise<Array<
|
|
38
|
+
fromPinWithName(name /*: string*/) /*: Promise<Array<any>>*/{
|
|
43
39
|
const controller = _CoreManager.default.getLocalDatastoreController();
|
|
44
40
|
return controller.fromPinWithName(name);
|
|
45
41
|
},
|
|
46
|
-
pinWithName(name /*: string*/, value /*: any*/) /*: Promise<void>*/{
|
|
42
|
+
async pinWithName(name /*: string*/, value /*: any*/) /*: Promise<void>*/{
|
|
47
43
|
const controller = _CoreManager.default.getLocalDatastoreController();
|
|
48
44
|
return controller.pinWithName(name, value);
|
|
49
45
|
},
|
|
50
|
-
unPinWithName(name /*: string*/) /*: Promise<void>*/{
|
|
46
|
+
async unPinWithName(name /*: string*/) /*: Promise<void>*/{
|
|
51
47
|
const controller = _CoreManager.default.getLocalDatastoreController();
|
|
52
48
|
return controller.unPinWithName(name);
|
|
53
49
|
},
|
|
54
|
-
_getAllContents() /*: Promise<
|
|
50
|
+
_getAllContents() /*: Promise<any>*/{
|
|
55
51
|
const controller = _CoreManager.default.getLocalDatastoreController();
|
|
56
52
|
return controller.getAllContents();
|
|
57
53
|
},
|
|
58
54
|
// Use for testing
|
|
59
|
-
_getRawStorage() /*: Promise<
|
|
55
|
+
async _getRawStorage() /*: Promise<any>*/{
|
|
60
56
|
const controller = _CoreManager.default.getLocalDatastoreController();
|
|
61
57
|
return controller.getRawStorage();
|
|
62
58
|
},
|
|
63
|
-
_clear() /*: Promise<void>*/{
|
|
59
|
+
async _clear() /*: Promise<void>*/{
|
|
64
60
|
const controller = _CoreManager.default.getLocalDatastoreController();
|
|
65
61
|
return controller.clear();
|
|
66
62
|
},
|
|
@@ -360,7 +356,7 @@ const LocalDatastore = {
|
|
|
360
356
|
const objectId = object.objectId || object._getId();
|
|
361
357
|
return `${_LocalDatastoreUtils.OBJECT_PREFIX}${object.className}_${objectId}`;
|
|
362
358
|
},
|
|
363
|
-
getPinName(pinName
|
|
359
|
+
getPinName(pinName /*:: ?: string*/) {
|
|
364
360
|
if (!pinName || pinName === _LocalDatastoreUtils.DEFAULT_PIN) {
|
|
365
361
|
return _LocalDatastoreUtils.DEFAULT_PIN;
|
|
366
362
|
}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
3
7
|
var _LocalDatastoreUtils = require("./LocalDatastoreUtils");
|
|
4
8
|
var _Storage = _interopRequireDefault(require("./Storage"));
|
|
5
9
|
function _interopRequireDefault(obj) {
|
|
@@ -7,12 +11,8 @@ function _interopRequireDefault(obj) {
|
|
|
7
11
|
default: obj
|
|
8
12
|
};
|
|
9
13
|
}
|
|
10
|
-
/**
|
|
11
|
-
* @flow
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
14
|
const LocalDatastoreController = {
|
|
15
|
-
async fromPinWithName(name /*: string*/) /*: Array<
|
|
15
|
+
async fromPinWithName(name /*: string*/) /*: Promise<Array<any>>*/{
|
|
16
16
|
const values = await _Storage.default.getItemAsync(name);
|
|
17
17
|
if (!values) {
|
|
18
18
|
return [];
|
|
@@ -27,7 +27,7 @@ const LocalDatastoreController = {
|
|
|
27
27
|
unPinWithName(name /*: string*/) {
|
|
28
28
|
return _Storage.default.removeItemAsync(name);
|
|
29
29
|
},
|
|
30
|
-
async getAllContents() /*:
|
|
30
|
+
async getAllContents() /*: Promise<any>*/{
|
|
31
31
|
const keys = await _Storage.default.getAllKeysAsync();
|
|
32
32
|
return keys.reduce(async (previousPromise, key) => {
|
|
33
33
|
const LDS = await previousPromise;
|
|
@@ -43,7 +43,7 @@ const LocalDatastoreController = {
|
|
|
43
43
|
}, Promise.resolve({}));
|
|
44
44
|
},
|
|
45
45
|
// Used for testing
|
|
46
|
-
async getRawStorage() /*:
|
|
46
|
+
async getRawStorage() /*: Promise<any>*/{
|
|
47
47
|
const keys = await _Storage.default.getAllKeysAsync();
|
|
48
48
|
return keys.reduce(async (previousPromise, key) => {
|
|
49
49
|
const LDS = await previousPromise;
|
|
@@ -52,9 +52,9 @@ const LocalDatastoreController = {
|
|
|
52
52
|
return LDS;
|
|
53
53
|
}, Promise.resolve({}));
|
|
54
54
|
},
|
|
55
|
-
async clear() /*: Promise
|
|
55
|
+
async clear() /*: Promise<any>*/{
|
|
56
56
|
const keys = await _Storage.default.getAllKeysAsync();
|
|
57
|
-
const toRemove = [];
|
|
57
|
+
const toRemove /*: string[]*/ = [];
|
|
58
58
|
for (const key of keys) {
|
|
59
59
|
if ((0, _LocalDatastoreUtils.isLocalDatastoreKey)(key)) {
|
|
60
60
|
toRemove.push(key);
|
|
@@ -64,4 +64,6 @@ const LocalDatastoreController = {
|
|
|
64
64
|
return Promise.all(promises);
|
|
65
65
|
}
|
|
66
66
|
};
|
|
67
|
-
module.exports = LocalDatastoreController;
|
|
67
|
+
module.exports = LocalDatastoreController;
|
|
68
|
+
var _default = LocalDatastoreController;
|
|
69
|
+
exports.default = _default;
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
3
7
|
var _LocalDatastoreUtils = require("./LocalDatastoreUtils");
|
|
4
|
-
/**
|
|
5
|
-
* @flow
|
|
6
|
-
* @private
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
8
|
const RNStorage = require('./StorageController.react-native');
|
|
10
9
|
const LocalDatastoreController = {
|
|
11
|
-
async fromPinWithName(name /*: string*/) /*: Promise<Array<
|
|
10
|
+
async fromPinWithName(name /*: string*/) /*: Promise<Array<any>>*/{
|
|
12
11
|
const values = await RNStorage.getItemAsync(name);
|
|
13
12
|
if (!values) {
|
|
14
13
|
return [];
|
|
@@ -28,9 +27,9 @@ const LocalDatastoreController = {
|
|
|
28
27
|
unPinWithName(name /*: string*/) /*: Promise<void>*/{
|
|
29
28
|
return RNStorage.removeItemAsync(name);
|
|
30
29
|
},
|
|
31
|
-
async getAllContents() /*: Promise<
|
|
30
|
+
async getAllContents() /*: Promise<any>*/{
|
|
32
31
|
const keys = await RNStorage.getAllKeysAsync();
|
|
33
|
-
const batch = [];
|
|
32
|
+
const batch /*: string[]*/ = [];
|
|
34
33
|
for (let i = 0; i < keys.length; i += 1) {
|
|
35
34
|
const key = keys[i];
|
|
36
35
|
if ((0, _LocalDatastoreUtils.isLocalDatastoreKey)(key)) {
|
|
@@ -38,7 +37,7 @@ const LocalDatastoreController = {
|
|
|
38
37
|
}
|
|
39
38
|
}
|
|
40
39
|
const LDS = {};
|
|
41
|
-
let results = [];
|
|
40
|
+
let results /*: any[]*/ = [];
|
|
42
41
|
try {
|
|
43
42
|
results = await RNStorage.multiGet(batch);
|
|
44
43
|
} catch (error) {
|
|
@@ -56,7 +55,7 @@ const LocalDatastoreController = {
|
|
|
56
55
|
return LDS;
|
|
57
56
|
},
|
|
58
57
|
// Used for testing
|
|
59
|
-
async getRawStorage() /*: Promise<
|
|
58
|
+
async getRawStorage() /*: Promise<any>*/{
|
|
60
59
|
const keys = await RNStorage.getAllKeysAsync();
|
|
61
60
|
const storage = {};
|
|
62
61
|
const results = await RNStorage.multiGet(keys);
|
|
@@ -68,7 +67,7 @@ const LocalDatastoreController = {
|
|
|
68
67
|
},
|
|
69
68
|
async clear() /*: Promise<void>*/{
|
|
70
69
|
const keys = await RNStorage.getAllKeysAsync();
|
|
71
|
-
const batch = [];
|
|
70
|
+
const batch /*: string[]*/ = [];
|
|
72
71
|
for (let i = 0; i < keys.length; i += 1) {
|
|
73
72
|
const key = keys[i];
|
|
74
73
|
if ((0, _LocalDatastoreUtils.isLocalDatastoreKey)(key)) {
|
|
@@ -78,4 +77,6 @@ const LocalDatastoreController = {
|
|
|
78
77
|
return RNStorage.multiRemove(batch).catch(error => console.error('Error clearing local datastore: ', error));
|
|
79
78
|
}
|
|
80
79
|
};
|
|
81
|
-
module.exports = LocalDatastoreController;
|
|
80
|
+
module.exports = LocalDatastoreController;
|
|
81
|
+
var _default = LocalDatastoreController;
|
|
82
|
+
exports.default = _default;
|
|
@@ -5,11 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.PIN_PREFIX = exports.OBJECT_PREFIX = exports.DEFAULT_PIN = void 0;
|
|
7
7
|
exports.isLocalDatastoreKey = isLocalDatastoreKey;
|
|
8
|
-
/**
|
|
9
|
-
* @flow
|
|
10
|
-
* @private
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
8
|
const DEFAULT_PIN = '_default';
|
|
14
9
|
exports.DEFAULT_PIN = DEFAULT_PIN;
|
|
15
10
|
const PIN_PREFIX = 'parsePin_';
|