parse 5.1.0-alpha.8 → 5.1.0-beta.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/README.md +1 -1
- package/dist/parse.js +675 -374
- package/dist/parse.min.js +2 -2
- package/dist/parse.weapp.js +1603 -438
- package/dist/parse.weapp.min.js +2 -2
- package/lib/browser/CoreManager.js +48 -183
- package/lib/browser/EventuallyQueue.js +1 -1
- package/lib/browser/InstallationController.js +134 -23
- package/lib/browser/ObjectStateMutations.js +3 -2
- package/lib/browser/Parse.js +2 -2
- 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/ParseObject.js +74 -68
- 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 +1 -0
- package/lib/browser/SingleInstanceStateController.js +2 -4
- 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 -183
- package/lib/node/EventuallyQueue.js +1 -1
- package/lib/node/InstallationController.js +65 -21
- package/lib/node/ObjectStateMutations.js +3 -2
- package/lib/node/Parse.js +2 -2
- 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/ParseObject.js +68 -66
- 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 +1 -0
- package/lib/node/SingleInstanceStateController.js +2 -8
- 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 -9
- package/lib/react-native/InstallationController.js +77 -9
- package/lib/react-native/ObjectStateMutations.js +3 -2
- package/lib/react-native/Parse.js +2 -2
- 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/ParseObject.js +8 -6
- 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 +1 -0
- package/lib/react-native/SingleInstanceStateController.js +0 -2
- 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 -183
- package/lib/weapp/EventuallyQueue.js +1 -1
- package/lib/weapp/InstallationController.js +134 -23
- package/lib/weapp/ObjectStateMutations.js +3 -2
- package/lib/weapp/Parse.js +2 -2
- 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/ParseObject.js +74 -68
- 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 +1 -0
- package/lib/weapp/SingleInstanceStateController.js +2 -4
- 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 +4 -1
|
@@ -7,17 +7,18 @@ _Object$defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports.default = arrayContainsObject;
|
|
9
9
|
var _indexOf = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
|
|
10
|
-
var
|
|
10
|
+
var _CoreManager = _interopRequireDefault(require("./CoreManager"));
|
|
11
11
|
/**
|
|
12
12
|
* @flow
|
|
13
13
|
*/
|
|
14
|
-
|
|
14
|
+
/*:: import type ParseObject from './ParseObject';*/
|
|
15
15
|
function arrayContainsObject(array /*: Array<any>*/, object /*: ParseObject*/) /*: boolean*/{
|
|
16
16
|
if ((0, _indexOf.default)(array).call(array, object) > -1) {
|
|
17
17
|
return true;
|
|
18
18
|
}
|
|
19
|
+
var ParseObject = _CoreManager.default.getParseObject();
|
|
19
20
|
for (var i = 0; i < array.length; i++) {
|
|
20
|
-
if (array[i] instanceof
|
|
21
|
+
if (array[i] instanceof ParseObject && array[i].className === object.className && array[i]._getId() === object._getId()) {
|
|
21
22
|
return true;
|
|
22
23
|
}
|
|
23
24
|
}
|
|
@@ -8,15 +8,16 @@ _Object$defineProperty(exports, "__esModule", {
|
|
|
8
8
|
exports.default = canBeSerialized;
|
|
9
9
|
var _isArray = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/array/is-array"));
|
|
10
10
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/typeof"));
|
|
11
|
+
var _CoreManager = _interopRequireDefault(require("./CoreManager"));
|
|
11
12
|
var _ParseFile = _interopRequireDefault(require("./ParseFile"));
|
|
12
|
-
var _ParseObject = _interopRequireDefault(require("./ParseObject"));
|
|
13
13
|
var _ParseRelation = _interopRequireDefault(require("./ParseRelation"));
|
|
14
14
|
/**
|
|
15
15
|
* @flow
|
|
16
16
|
*/
|
|
17
|
-
|
|
17
|
+
/*:: import type ParseObject from './ParseObject';*/
|
|
18
18
|
function canBeSerialized(obj /*: ParseObject*/) /*: boolean*/{
|
|
19
|
-
|
|
19
|
+
var ParseObject = _CoreManager.default.getParseObject();
|
|
20
|
+
if (!(obj instanceof ParseObject)) {
|
|
20
21
|
return true;
|
|
21
22
|
}
|
|
22
23
|
var attributes = obj.attributes;
|
|
@@ -35,7 +36,8 @@ function canBeSerializedHelper(value /*: any*/) /*: boolean*/{
|
|
|
35
36
|
if (value instanceof _ParseRelation.default) {
|
|
36
37
|
return true;
|
|
37
38
|
}
|
|
38
|
-
|
|
39
|
+
var ParseObject = _CoreManager.default.getParseObject();
|
|
40
|
+
if (value instanceof ParseObject) {
|
|
39
41
|
return !!value.id;
|
|
40
42
|
}
|
|
41
43
|
if (value instanceof _ParseFile.default) {
|
package/lib/browser/decode.js
CHANGED
|
@@ -9,16 +9,16 @@ exports.default = decode;
|
|
|
9
9
|
var _isArray = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/array/is-array"));
|
|
10
10
|
var _forEach = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
|
|
11
11
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/typeof"));
|
|
12
|
+
var _CoreManager = _interopRequireDefault(require("./CoreManager"));
|
|
12
13
|
var _ParseACL = _interopRequireDefault(require("./ParseACL"));
|
|
13
14
|
var _ParseFile = _interopRequireDefault(require("./ParseFile"));
|
|
14
15
|
var _ParseGeoPoint = _interopRequireDefault(require("./ParseGeoPoint"));
|
|
15
16
|
var _ParsePolygon = _interopRequireDefault(require("./ParsePolygon"));
|
|
16
|
-
var _ParseObject = _interopRequireDefault(require("./ParseObject"));
|
|
17
|
-
var _ParseOp = require("./ParseOp");
|
|
18
17
|
var _ParseRelation = _interopRequireDefault(require("./ParseRelation"));
|
|
19
18
|
/**
|
|
20
19
|
* @flow
|
|
21
20
|
*/
|
|
21
|
+
|
|
22
22
|
// eslint-disable-line no-unused-vars
|
|
23
23
|
|
|
24
24
|
function decode(value /*: any*/) /*: any*/{
|
|
@@ -33,13 +33,16 @@ function decode(value /*: any*/) /*: any*/{
|
|
|
33
33
|
return dup;
|
|
34
34
|
}
|
|
35
35
|
if (typeof value.__op === 'string') {
|
|
36
|
-
|
|
36
|
+
var _CoreManager$getParse = _CoreManager.default.getParseOp(),
|
|
37
|
+
opFromJSON = _CoreManager$getParse.opFromJSON;
|
|
38
|
+
return opFromJSON(value);
|
|
37
39
|
}
|
|
40
|
+
var ParseObject = _CoreManager.default.getParseObject();
|
|
38
41
|
if (value.__type === 'Pointer' && value.className) {
|
|
39
|
-
return
|
|
42
|
+
return ParseObject.fromJSON(value);
|
|
40
43
|
}
|
|
41
44
|
if (value.__type === 'Object' && value.className) {
|
|
42
|
-
return
|
|
45
|
+
return ParseObject.fromJSON(value);
|
|
43
46
|
}
|
|
44
47
|
if (value.__type === 'Relation') {
|
|
45
48
|
// The parent and key fields will be populated by the parent
|
package/lib/browser/encode.js
CHANGED
|
@@ -13,19 +13,19 @@ var _startsWith = _interopRequireDefault(require("@babel/runtime-corejs3/core-js
|
|
|
13
13
|
var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
|
|
14
14
|
var _isArray = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/array/is-array"));
|
|
15
15
|
var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
|
|
16
|
+
var _CoreManager = _interopRequireDefault(require("./CoreManager"));
|
|
16
17
|
var _ParseACL = _interopRequireDefault(require("./ParseACL"));
|
|
17
18
|
var _ParseFile = _interopRequireDefault(require("./ParseFile"));
|
|
18
19
|
var _ParseGeoPoint = _interopRequireDefault(require("./ParseGeoPoint"));
|
|
19
20
|
var _ParsePolygon = _interopRequireDefault(require("./ParsePolygon"));
|
|
20
|
-
var _ParseObject = _interopRequireDefault(require("./ParseObject"));
|
|
21
|
-
var _ParseOp = require("./ParseOp");
|
|
22
21
|
var _ParseRelation = _interopRequireDefault(require("./ParseRelation"));
|
|
23
22
|
/**
|
|
24
23
|
* @flow
|
|
25
24
|
*/
|
|
26
25
|
|
|
27
26
|
function encode(value /*: mixed*/, disallowObjects /*: boolean*/, forcePointers /*: boolean*/, seen /*: Array<mixed>*/, offline /*: boolean*/) /*: any*/{
|
|
28
|
-
|
|
27
|
+
var ParseObject = _CoreManager.default.getParseObject();
|
|
28
|
+
if (value instanceof ParseObject) {
|
|
29
29
|
if (disallowObjects) {
|
|
30
30
|
throw new Error('Parse Objects not allowed here');
|
|
31
31
|
}
|
|
@@ -40,7 +40,9 @@ function encode(value /*: mixed*/, disallowObjects /*: boolean*/, forcePointers
|
|
|
40
40
|
seen = (0, _concat.default)(seen).call(seen, seenEntry);
|
|
41
41
|
return value._toFullJSON(seen, offline);
|
|
42
42
|
}
|
|
43
|
-
|
|
43
|
+
var _CoreManager$getParse = _CoreManager.default.getParseOp(),
|
|
44
|
+
Op = _CoreManager$getParse.Op;
|
|
45
|
+
if (value instanceof Op || value instanceof _ParseACL.default || value instanceof _ParseGeoPoint.default || value instanceof _ParsePolygon.default || value instanceof _ParseRelation.default) {
|
|
44
46
|
return value.toJSON();
|
|
45
47
|
}
|
|
46
48
|
if (value instanceof _ParseFile.default) {
|
package/lib/browser/equals.js
CHANGED
|
@@ -9,10 +9,10 @@ exports.default = equals;
|
|
|
9
9
|
var _isArray = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/array/is-array"));
|
|
10
10
|
var _keys = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/keys"));
|
|
11
11
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/typeof"));
|
|
12
|
+
var _CoreManager = _interopRequireDefault(require("./CoreManager"));
|
|
12
13
|
var _ParseACL = _interopRequireDefault(require("./ParseACL"));
|
|
13
14
|
var _ParseFile = _interopRequireDefault(require("./ParseFile"));
|
|
14
15
|
var _ParseGeoPoint = _interopRequireDefault(require("./ParseGeoPoint"));
|
|
15
|
-
var _ParseObject = _interopRequireDefault(require("./ParseObject"));
|
|
16
16
|
function equals(a, b) {
|
|
17
17
|
var toString = Object.prototype.toString;
|
|
18
18
|
if (toString.call(a) === '[object Date]' || toString.call(b) === '[object Date]') {
|
|
@@ -41,10 +41,11 @@ function equals(a, b) {
|
|
|
41
41
|
}
|
|
42
42
|
return true;
|
|
43
43
|
}
|
|
44
|
-
|
|
44
|
+
var ParseObject = _CoreManager.default.getParseObject();
|
|
45
|
+
if (a instanceof _ParseACL.default || a instanceof _ParseFile.default || a instanceof _ParseGeoPoint.default || a instanceof ParseObject) {
|
|
45
46
|
return a.equals(b);
|
|
46
47
|
}
|
|
47
|
-
if (b instanceof
|
|
48
|
+
if (b instanceof ParseObject) {
|
|
48
49
|
if (a.__type === 'Object' || a.__type === 'Pointer') {
|
|
49
50
|
return a.objectId === b.id && a.className === b.className;
|
|
50
51
|
}
|
package/lib/browser/unique.js
CHANGED
|
@@ -9,7 +9,7 @@ exports.default = unique;
|
|
|
9
9
|
var _forEach = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
|
|
10
10
|
var _indexOf = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
|
|
11
11
|
var _arrayContainsObject = _interopRequireDefault(require("./arrayContainsObject"));
|
|
12
|
-
var
|
|
12
|
+
var _CoreManager = _interopRequireDefault(require("./CoreManager"));
|
|
13
13
|
/**
|
|
14
14
|
* @flow
|
|
15
15
|
*/
|
|
@@ -17,7 +17,8 @@ var _ParseObject = _interopRequireDefault(require("./ParseObject"));
|
|
|
17
17
|
function unique /*:: <T>*/(arr /*: Array<T>*/) /*: Array<T>*/{
|
|
18
18
|
var uniques = [];
|
|
19
19
|
(0, _forEach.default)(arr).call(arr, function (value) {
|
|
20
|
-
|
|
20
|
+
var ParseObject = _CoreManager.default.getParseObject();
|
|
21
|
+
if (value instanceof ParseObject) {
|
|
21
22
|
if (!(0, _arrayContainsObject.default)(uniques, value)) {
|
|
22
23
|
uniques.push(value);
|
|
23
24
|
}
|
|
@@ -11,12 +11,13 @@ var _indexOf = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-st
|
|
|
11
11
|
var _isArray = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/array/is-array"));
|
|
12
12
|
var _forEach = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
|
|
13
13
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/typeof"));
|
|
14
|
+
var _CoreManager = _interopRequireDefault(require("./CoreManager"));
|
|
14
15
|
var _ParseFile = _interopRequireDefault(require("./ParseFile"));
|
|
15
|
-
var _ParseObject = _interopRequireDefault(require("./ParseObject"));
|
|
16
16
|
var _ParseRelation = _interopRequireDefault(require("./ParseRelation"));
|
|
17
17
|
/**
|
|
18
18
|
* @flow
|
|
19
19
|
*/
|
|
20
|
+
/*:: import type ParseObject from './ParseObject';*/
|
|
20
21
|
/*:: type EncounterMap = {
|
|
21
22
|
objects: { [identifier: string]: ParseObject | boolean },
|
|
22
23
|
files: Array<ParseFile>,
|
|
@@ -51,7 +52,8 @@ function unsavedChildren(obj /*: ParseObject*/, allowDeepUnsaved /*:: ?: boolean
|
|
|
51
52
|
return (0, _concat.default)(unsaved).call(unsaved, encountered.files);
|
|
52
53
|
}
|
|
53
54
|
function traverse(obj /*: ParseObject*/, encountered /*: EncounterMap*/, shouldThrow /*: boolean*/, allowDeepUnsaved /*: boolean*/) {
|
|
54
|
-
|
|
55
|
+
var ParseObject = _CoreManager.default.getParseObject();
|
|
56
|
+
if (obj instanceof ParseObject) {
|
|
55
57
|
if (!obj.id && shouldThrow) {
|
|
56
58
|
throw new Error('Cannot create a pointer to an unsaved Object.');
|
|
57
59
|
}
|
package/lib/browser/uuid.js
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
|
4
|
+
_Object$defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _uuid = require("uuid");
|
|
9
|
+
var uuid /*: () => string*/ = null;
|
|
10
|
+
uuid = _uuid.v4;
|
|
11
|
+
module.exports = uuid;
|
|
12
|
+
var _default = uuid;
|
|
13
|
+
exports.default = _default;
|
package/lib/node/CoreManager.js
CHANGED
|
@@ -4,181 +4,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
*/
|
|
10
|
-
/*:: import type { AttributeMap, ObjectCache, OpsMap, State } from './ObjectStateMutations';*/
|
|
11
|
-
/*:: import type ParseFile from './ParseFile';*/
|
|
12
|
-
/*:: import type { FileSource } from './ParseFile';*/
|
|
13
|
-
/*:: import type { Op } from './ParseOp';*/
|
|
14
|
-
/*:: import type ParseObject, {SaveOptions} from './ParseObject';*/
|
|
15
|
-
/*:: import type { QueryJSON } from './ParseQuery';*/
|
|
16
|
-
/*:: import type ParseUser from './ParseUser';*/
|
|
17
|
-
/*:: import type { AuthData } from './ParseUser';*/
|
|
18
|
-
/*:: import type { PushData } from './Push';*/
|
|
19
|
-
/*:: import type { RequestOptions, FullOptions } from './RESTController';*/
|
|
20
|
-
/*:: type AnalyticsController = {
|
|
21
|
-
track: (name: string, dimensions: { [key: string]: string }) => Promise,
|
|
22
|
-
};*/
|
|
23
|
-
/*:: type CloudController = {
|
|
24
|
-
run: (name: string, data: mixed, options: RequestOptions) => Promise,
|
|
25
|
-
getJobsData: (options: RequestOptions) => Promise,
|
|
26
|
-
startJob: (name: string, data: mixed, options: RequestOptions) => Promise,
|
|
27
|
-
};*/
|
|
28
|
-
/*:: type ConfigController = {
|
|
29
|
-
current: () => Promise,
|
|
30
|
-
get: () => Promise,
|
|
31
|
-
save: (attrs: { [key: string]: any }) => Promise,
|
|
32
|
-
};*/
|
|
33
|
-
/*:: type CryptoController = {
|
|
34
|
-
encrypt: (obj: any, secretKey: string) => string,
|
|
35
|
-
decrypt: (encryptedText: string, secretKey: any) => string,
|
|
36
|
-
};*/
|
|
37
|
-
/*:: type FileController = {
|
|
38
|
-
saveFile: (name: string, source: FileSource, options: FullOptions) => Promise,
|
|
39
|
-
saveBase64: (name: string, source: FileSource, options: FullOptions) => Promise,
|
|
40
|
-
download: (uri: string) => Promise,
|
|
41
|
-
};*/
|
|
42
|
-
/*:: type InstallationController = {
|
|
43
|
-
currentInstallationId: () => Promise,
|
|
44
|
-
};*/
|
|
45
|
-
/*:: type ObjectController = {
|
|
46
|
-
fetch: (
|
|
47
|
-
object: ParseObject | Array<ParseObject>,
|
|
48
|
-
forceFetch: boolean,
|
|
49
|
-
options: RequestOptions
|
|
50
|
-
) => Promise,
|
|
51
|
-
save: (object: ParseObject | Array<ParseObject | ParseFile>, options: RequestOptions) => Promise,
|
|
52
|
-
destroy: (object: ParseObject | Array<ParseObject>, options: RequestOptions) => Promise,
|
|
53
|
-
};*/
|
|
54
|
-
/*:: type ObjectStateController = {
|
|
55
|
-
getState: (obj: any) => ?State,
|
|
56
|
-
initializeState: (obj: any, initial?: State) => State,
|
|
57
|
-
removeState: (obj: any) => ?State,
|
|
58
|
-
getServerData: (obj: any) => AttributeMap,
|
|
59
|
-
setServerData: (obj: any, attributes: AttributeMap) => void,
|
|
60
|
-
getPendingOps: (obj: any) => Array<OpsMap>,
|
|
61
|
-
setPendingOp: (obj: any, attr: string, op: ?Op) => void,
|
|
62
|
-
pushPendingState: (obj: any) => void,
|
|
63
|
-
popPendingState: (obj: any) => OpsMap,
|
|
64
|
-
mergeFirstPendingState: (obj: any) => void,
|
|
65
|
-
getObjectCache: (obj: any) => ObjectCache,
|
|
66
|
-
estimateAttribute: (obj: any, attr: string) => mixed,
|
|
67
|
-
estimateAttributes: (obj: any) => AttributeMap,
|
|
68
|
-
commitServerChanges: (obj: any, changes: AttributeMap) => void,
|
|
69
|
-
enqueueTask: (obj: any, task: () => Promise) => Promise,
|
|
70
|
-
clearAllState: () => void,
|
|
71
|
-
duplicateState: (source: any, dest: any) => void,
|
|
72
|
-
};*/
|
|
73
|
-
/*:: type PushController = {
|
|
74
|
-
send: (data: PushData) => Promise,
|
|
75
|
-
};*/
|
|
76
|
-
/*:: type QueryController = {
|
|
77
|
-
find: (className: string, params: QueryJSON, options: RequestOptions) => Promise,
|
|
78
|
-
aggregate: (className: string, params: any, options: RequestOptions) => Promise,
|
|
79
|
-
};*/
|
|
80
|
-
/*:: type EventuallyQueue = {
|
|
81
|
-
save: (object: ParseObject, serverOptions: SaveOptions) => Promise,
|
|
82
|
-
destroy: (object: ParseObject, serverOptions: RequestOptions) => Promise,
|
|
83
|
-
poll: (ms: number) => void
|
|
84
|
-
};*/
|
|
85
|
-
/*:: type RESTController = {
|
|
86
|
-
request: (method: string, path: string, data: mixed, options: RequestOptions) => Promise,
|
|
87
|
-
ajax: (method: string, url: string, data: any, headers?: any, options: FullOptions) => Promise,
|
|
88
|
-
};*/
|
|
89
|
-
/*:: type SchemaController = {
|
|
90
|
-
purge: (className: string) => Promise,
|
|
91
|
-
get: (className: string, options: RequestOptions) => Promise,
|
|
92
|
-
delete: (className: string, options: RequestOptions) => Promise,
|
|
93
|
-
create: (className: string, params: any, options: RequestOptions) => Promise,
|
|
94
|
-
update: (className: string, params: any, options: RequestOptions) => Promise,
|
|
95
|
-
send(className: string, method: string, params: any, options: RequestOptions): Promise,
|
|
96
|
-
};*/
|
|
97
|
-
/*:: type SessionController = {
|
|
98
|
-
getSession: (token: RequestOptions) => Promise,
|
|
99
|
-
};*/
|
|
100
|
-
/*:: type StorageController =
|
|
101
|
-
| {
|
|
102
|
-
async: 0,
|
|
103
|
-
getItem: (path: string) => ?string,
|
|
104
|
-
setItem: (path: string, value: string) => void,
|
|
105
|
-
removeItem: (path: string) => void,
|
|
106
|
-
getItemAsync?: (path: string) => Promise,
|
|
107
|
-
setItemAsync?: (path: string, value: string) => Promise,
|
|
108
|
-
removeItemAsync?: (path: string) => Promise,
|
|
109
|
-
clear: () => void,
|
|
110
|
-
}
|
|
111
|
-
| {
|
|
112
|
-
async: 1,
|
|
113
|
-
getItem?: (path: string) => ?string,
|
|
114
|
-
setItem?: (path: string, value: string) => void,
|
|
115
|
-
removeItem?: (path: string) => void,
|
|
116
|
-
getItemAsync: (path: string) => Promise,
|
|
117
|
-
setItemAsync: (path: string, value: string) => Promise,
|
|
118
|
-
removeItemAsync: (path: string) => Promise,
|
|
119
|
-
clear: () => void,
|
|
120
|
-
};*/
|
|
121
|
-
/*:: type LocalDatastoreController = {
|
|
122
|
-
fromPinWithName: (name: string) => ?any,
|
|
123
|
-
pinWithName: (name: string, objects: any) => void,
|
|
124
|
-
unPinWithName: (name: string) => void,
|
|
125
|
-
getAllContents: () => ?any,
|
|
126
|
-
clear: () => void,
|
|
127
|
-
};*/
|
|
128
|
-
/*:: type UserController = {
|
|
129
|
-
setCurrentUser: (user: ParseUser) => Promise,
|
|
130
|
-
currentUser: () => ?ParseUser,
|
|
131
|
-
currentUserAsync: () => Promise,
|
|
132
|
-
signUp: (user: ParseUser, attrs: AttributeMap, options: RequestOptions) => Promise,
|
|
133
|
-
logIn: (user: ParseUser, options: RequestOptions) => Promise,
|
|
134
|
-
become: (options: RequestOptions) => Promise,
|
|
135
|
-
hydrate: (userJSON: AttributeMap) => Promise,
|
|
136
|
-
logOut: (options: RequestOptions) => Promise,
|
|
137
|
-
me: (options: RequestOptions) => Promise,
|
|
138
|
-
requestPasswordReset: (email: string, options: RequestOptions) => Promise,
|
|
139
|
-
updateUserOnDisk: (user: ParseUser) => Promise,
|
|
140
|
-
upgradeToRevocableSession: (user: ParseUser, options: RequestOptions) => Promise,
|
|
141
|
-
linkWith: (user: ParseUser, authData: AuthData) => Promise,
|
|
142
|
-
removeUserFromDisk: () => Promise,
|
|
143
|
-
verifyPassword: (username: string, password: string, options: RequestOptions) => Promise,
|
|
144
|
-
requestEmailVerification: (email: string, options: RequestOptions) => Promise,
|
|
145
|
-
};*/
|
|
146
|
-
/*:: type HooksController = {
|
|
147
|
-
get: (type: string, functionName?: string, triggerName?: string) => Promise,
|
|
148
|
-
create: (hook: mixed) => Promise,
|
|
149
|
-
delete: (hook: mixed) => Promise,
|
|
150
|
-
update: (hook: mixed) => Promise,
|
|
151
|
-
send: (method: string, path: string, body?: mixed) => Promise,
|
|
152
|
-
};*/
|
|
153
|
-
/*:: type WebSocketController = {
|
|
7
|
+
/** Based on https://github.com/react-native-async-storage/async-storage/blob/main/packages/default-storage-backend/src/types.ts */
|
|
8
|
+
/*:: export type WebSocketController = {
|
|
154
9
|
onopen: () => void,
|
|
155
10
|
onmessage: (message: any) => void,
|
|
156
|
-
onclose: () => void,
|
|
11
|
+
onclose: (arg?: any) => void,
|
|
157
12
|
onerror: (error: any) => void,
|
|
158
13
|
send: (data: any) => void,
|
|
159
14
|
close: () => void,
|
|
160
15
|
};*/
|
|
161
|
-
|
|
162
|
-
AnalyticsController?: AnalyticsController,
|
|
163
|
-
CloudController?: CloudController,
|
|
164
|
-
ConfigController?: ConfigController,
|
|
165
|
-
FileController?: FileController,
|
|
166
|
-
InstallationController?: InstallationController,
|
|
167
|
-
ObjectController?: ObjectController,
|
|
168
|
-
ObjectStateController?: ObjectStateController,
|
|
169
|
-
PushController?: PushController,
|
|
170
|
-
QueryController?: QueryController,
|
|
171
|
-
RESTController?: RESTController,
|
|
172
|
-
SchemaController?: SchemaController,
|
|
173
|
-
SessionController?: SessionController,
|
|
174
|
-
StorageController?: StorageController,
|
|
175
|
-
LocalDatastoreController?: LocalDatastoreController,
|
|
176
|
-
UserController?: UserController,
|
|
177
|
-
HooksController?: HooksController,
|
|
178
|
-
WebSocketController?: WebSocketController,
|
|
179
|
-
};*/
|
|
180
|
-
const config /*: Config & { [key: string]: mixed }*/ = {
|
|
181
|
-
// Defaults
|
|
16
|
+
const config /*: Config & { [key: string]: any }*/ = {
|
|
182
17
|
IS_NODE: typeof process !== 'undefined' && !!process.versions && !!process.versions.node && !process.versions.electron,
|
|
183
18
|
REQUEST_ATTEMPT_LIMIT: 5,
|
|
184
19
|
REQUEST_BATCH_SIZE: 20,
|
|
@@ -188,7 +23,7 @@ const config /*: Config & { [key: string]: mixed }*/ = {
|
|
|
188
23
|
SERVER_AUTH_TOKEN: null,
|
|
189
24
|
LIVEQUERY_SERVER_URL: null,
|
|
190
25
|
ENCRYPTED_KEY: null,
|
|
191
|
-
VERSION: 'js' + "5.1.0-
|
|
26
|
+
VERSION: 'js' + "5.1.0-beta.1",
|
|
192
27
|
APPLICATION_ID: null,
|
|
193
28
|
JAVASCRIPT_KEY: null,
|
|
194
29
|
MASTER_KEY: null,
|
|
@@ -263,11 +98,18 @@ const CoreManager = {
|
|
|
263
98
|
requireMethods('FileController', ['saveFile', 'saveBase64'], controller);
|
|
264
99
|
config['FileController'] = controller;
|
|
265
100
|
},
|
|
101
|
+
setEventuallyQueue(controller /*: EventuallyQueue*/) {
|
|
102
|
+
requireMethods('EventuallyQueue', ['poll', 'save', 'destroy'], controller);
|
|
103
|
+
config['EventuallyQueue'] = controller;
|
|
104
|
+
},
|
|
105
|
+
getEventuallyQueue() /*: EventuallyQueue*/{
|
|
106
|
+
return config['EventuallyQueue'];
|
|
107
|
+
},
|
|
266
108
|
getFileController() /*: FileController*/{
|
|
267
109
|
return config['FileController'];
|
|
268
110
|
},
|
|
269
111
|
setInstallationController(controller /*: InstallationController*/) {
|
|
270
|
-
requireMethods('InstallationController', ['currentInstallationId'], controller);
|
|
112
|
+
requireMethods('InstallationController', ['currentInstallationId', 'currentInstallation', 'updateInstallationOnDisk'], controller);
|
|
271
113
|
config['InstallationController'] = controller;
|
|
272
114
|
},
|
|
273
115
|
getInstallationController() /*: InstallationController*/{
|
|
@@ -314,13 +156,6 @@ const CoreManager = {
|
|
|
314
156
|
getRESTController() /*: RESTController*/{
|
|
315
157
|
return config['RESTController'];
|
|
316
158
|
},
|
|
317
|
-
setEventuallyQueue(controller /*: EventuallyQueue*/) {
|
|
318
|
-
requireMethods('EventuallyQueue', ['poll', 'save', 'destroy'], controller);
|
|
319
|
-
config['EventuallyQueue'] = controller;
|
|
320
|
-
},
|
|
321
|
-
getEventuallyQueue() /*: EventuallyQueue*/{
|
|
322
|
-
return config['EventuallyQueue'];
|
|
323
|
-
},
|
|
324
159
|
setSchemaController(controller /*: SchemaController*/) {
|
|
325
160
|
requireMethods('SchemaController', ['get', 'create', 'update', 'delete', 'send', 'purge'], controller);
|
|
326
161
|
config['SchemaController'] = controller;
|
|
@@ -359,16 +194,16 @@ const CoreManager = {
|
|
|
359
194
|
getStorageController() /*: StorageController*/{
|
|
360
195
|
return config['StorageController'];
|
|
361
196
|
},
|
|
362
|
-
setAsyncStorage(storage /*:
|
|
197
|
+
setAsyncStorage(storage /*: AsyncStorageType*/) {
|
|
363
198
|
config['AsyncStorage'] = storage;
|
|
364
199
|
},
|
|
365
200
|
getAsyncStorage() {
|
|
366
201
|
return config['AsyncStorage'];
|
|
367
202
|
},
|
|
368
|
-
setWebSocketController(controller /*: WebSocketController*/) {
|
|
203
|
+
setWebSocketController(controller /*: new (url: string | URL, protocols?: string | string[] | undefined) => WebSocketController*/) {
|
|
369
204
|
config['WebSocketController'] = controller;
|
|
370
205
|
},
|
|
371
|
-
getWebSocketController() /*: WebSocketController*/{
|
|
206
|
+
getWebSocketController() /*: new (url: string | URL, protocols?: string | string[] | undefined) => WebSocketController*/{
|
|
372
207
|
return config['WebSocketController'];
|
|
373
208
|
},
|
|
374
209
|
setUserController(controller /*: UserController*/) {
|
|
@@ -378,11 +213,11 @@ const CoreManager = {
|
|
|
378
213
|
getUserController() /*: UserController*/{
|
|
379
214
|
return config['UserController'];
|
|
380
215
|
},
|
|
381
|
-
setLiveQueryController(controller /*:
|
|
216
|
+
setLiveQueryController(controller /*: LiveQueryControllerType*/) {
|
|
382
217
|
requireMethods('LiveQueryController', ['setDefaultLiveQueryClient', 'getDefaultLiveQueryClient', '_clearCachedDefaultClient'], controller);
|
|
383
218
|
config['LiveQueryController'] = controller;
|
|
384
219
|
},
|
|
385
|
-
getLiveQueryController() /*:
|
|
220
|
+
getLiveQueryController() /*: LiveQueryControllerType*/{
|
|
386
221
|
return config['LiveQueryController'];
|
|
387
222
|
},
|
|
388
223
|
setHooksController(controller /*: HooksController*/) {
|
|
@@ -391,6 +226,36 @@ const CoreManager = {
|
|
|
391
226
|
},
|
|
392
227
|
getHooksController() /*: HooksController*/{
|
|
393
228
|
return config['HooksController'];
|
|
229
|
+
},
|
|
230
|
+
setParseOp(op /*: typeof ParseOp*/) {
|
|
231
|
+
config['ParseOp'] = op;
|
|
232
|
+
},
|
|
233
|
+
getParseOp() {
|
|
234
|
+
return config['ParseOp'];
|
|
235
|
+
},
|
|
236
|
+
setParseObject(object /*: typeof ParseObject*/) {
|
|
237
|
+
config['ParseObject'] = object;
|
|
238
|
+
},
|
|
239
|
+
getParseObject() /*: ParseObject*/{
|
|
240
|
+
return config['ParseObject'];
|
|
241
|
+
},
|
|
242
|
+
setParseQuery(query /*: typeof ParseQuery*/) {
|
|
243
|
+
config['ParseQuery'] = query;
|
|
244
|
+
},
|
|
245
|
+
getParseQuery() /*: ParseQuery*/{
|
|
246
|
+
return config['ParseQuery'];
|
|
247
|
+
},
|
|
248
|
+
setParseRole(role /*: typeof ParseRole*/) {
|
|
249
|
+
config['ParseRole'] = role;
|
|
250
|
+
},
|
|
251
|
+
getParseRole() /*: ParseRole*/{
|
|
252
|
+
return config['ParseRole'];
|
|
253
|
+
},
|
|
254
|
+
setParseUser(user /*: typeof ParseUser*/) {
|
|
255
|
+
config['ParseUser'] = user;
|
|
256
|
+
},
|
|
257
|
+
getParseUser() /*: ParseUser*/{
|
|
258
|
+
return config['ParseUser'];
|
|
394
259
|
}
|
|
395
260
|
};
|
|
396
261
|
module.exports = CoreManager;
|
|
@@ -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;
|
|
@@ -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");
|
|
@@ -154,10 +154,11 @@ function nestedSet(obj, key, value) {
|
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
156
|
function commitServerChanges(serverData /*: AttributeMap*/, objectCache /*: ObjectCache*/, changes /*: AttributeMap*/) {
|
|
157
|
+
const ParseObject = _CoreManager.default.getParseObject();
|
|
157
158
|
for (const attr in changes) {
|
|
158
159
|
const val = changes[attr];
|
|
159
160
|
nestedSet(serverData, attr, val);
|
|
160
|
-
if (val && typeof val === 'object' && !(val instanceof
|
|
161
|
+
if (val && typeof val === 'object' && !(val instanceof ParseObject) && !(val instanceof _ParseFile.default) && !(val instanceof _ParseRelation.default)) {
|
|
161
162
|
const json = (0, _encode.default)(val, false, true);
|
|
162
163
|
objectCache[attr] = JSON.stringify(json);
|
|
163
164
|
}
|