parse 4.0.1 → 4.1.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/parse.js +17995 -26193
- package/dist/parse.min.js +2 -2
- package/dist/parse.weapp.js +8739 -17728
- package/dist/parse.weapp.min.js +2 -2
- package/lib/browser/Analytics.js +2 -20
- package/lib/browser/AnonymousUtils.js +6 -35
- package/lib/browser/Cloud.js +12 -70
- package/lib/browser/CloudCode.js +0 -3
- package/lib/browser/CoreManager.js +46 -184
- package/lib/browser/CryptoController.js +2 -16
- package/lib/browser/EventEmitter.js +1 -1
- package/lib/browser/EventuallyQueue.js +277 -824
- package/lib/browser/FacebookUtils.js +6 -35
- package/lib/browser/IndexedDBStorageController.js +3 -14
- package/lib/browser/InstallationController.js +2 -13
- package/lib/browser/LiveQueryClient.js +87 -204
- package/lib/browser/LiveQuerySubscription.js +10 -39
- package/lib/browser/LocalDatastore.js +451 -1081
- package/lib/browser/LocalDatastoreController.js +145 -602
- package/lib/browser/LocalDatastoreController.react-native.js +137 -573
- package/lib/browser/LocalDatastoreUtils.js +2 -12
- package/lib/browser/ObjectStateMutations.js +18 -121
- package/lib/browser/OfflineQuery.js +42 -222
- package/lib/browser/Parse.js +12 -106
- package/lib/browser/ParseACL.js +33 -141
- package/lib/browser/ParseCLP.js +96 -314
- package/lib/browser/ParseConfig.js +18 -88
- package/lib/browser/ParseError.js +63 -90
- package/lib/browser/ParseFile.js +129 -685
- package/lib/browser/ParseGeoPoint.js +23 -82
- package/lib/browser/ParseHooks.js +1 -34
- package/lib/browser/ParseInstallation.js +4 -32
- package/lib/browser/ParseLiveQuery.js +96 -505
- package/lib/browser/ParseObject.js +628 -1840
- package/lib/browser/ParseOp.js +41 -287
- package/lib/browser/ParsePolygon.js +13 -63
- package/lib/browser/ParseQuery.js +404 -1505
- package/lib/browser/ParseRelation.js +12 -61
- package/lib/browser/ParseRole.js +13 -75
- package/lib/browser/ParseSchema.js +49 -201
- package/lib/browser/ParseSession.js +11 -69
- package/lib/browser/ParseUser.js +274 -1127
- package/lib/browser/Push.js +7 -43
- package/lib/browser/RESTController.js +18 -140
- package/lib/browser/SingleInstanceStateController.js +19 -137
- package/lib/browser/Socket.weapp.js +2 -12
- package/lib/browser/Storage.js +10 -73
- package/lib/browser/StorageController.browser.js +4 -17
- package/lib/browser/StorageController.default.js +4 -17
- package/lib/browser/StorageController.react-native.js +6 -33
- package/lib/browser/StorageController.weapp.js +5 -16
- package/lib/browser/TaskQueue.js +1 -22
- package/lib/browser/UniqueInstanceStateController.js +19 -142
- package/lib/browser/Xhr.weapp.js +0 -17
- package/lib/browser/arrayContainsObject.js +2 -16
- package/lib/browser/canBeSerialized.js +3 -33
- package/lib/browser/decode.js +3 -33
- package/lib/browser/encode.js +9 -70
- package/lib/browser/equals.js +2 -25
- package/lib/browser/escape.js +1 -8
- package/lib/browser/isRevocableSession.js +2 -11
- package/lib/browser/parseDate.js +2 -13
- package/lib/browser/promiseUtils.js +3 -21
- package/lib/browser/unique.js +3 -17
- package/lib/browser/unsavedChildren.js +6 -50
- package/lib/browser/uuid.js +3 -1
- package/lib/node/Analytics.js +1 -18
- package/lib/node/AnonymousUtils.js +5 -37
- package/lib/node/Cloud.js +10 -66
- package/lib/node/CloudCode.js +0 -3
- package/lib/node/CoreManager.js +47 -220
- package/lib/node/CryptoController.js +2 -16
- package/lib/node/EventEmitter.js +1 -1
- package/lib/node/EventuallyQueue.js +16 -123
- package/lib/node/FacebookUtils.js +5 -37
- package/lib/node/IndexedDBStorageController.js +3 -19
- package/lib/node/InstallationController.js +2 -15
- package/lib/node/LiveQueryClient.js +56 -136
- package/lib/node/LiveQuerySubscription.js +7 -16
- package/lib/node/LocalDatastore.js +19 -175
- package/lib/node/LocalDatastoreController.js +6 -38
- package/lib/node/LocalDatastoreController.react-native.js +6 -45
- package/lib/node/LocalDatastoreUtils.js +1 -6
- package/lib/node/ObjectStateMutations.js +13 -93
- package/lib/node/OfflineQuery.js +20 -152
- package/lib/node/Parse.js +11 -99
- package/lib/node/ParseACL.js +32 -150
- package/lib/node/ParseCLP.js +69 -262
- package/lib/node/ParseConfig.js +16 -84
- package/lib/node/ParseError.js +61 -65
- package/lib/node/ParseFile.js +50 -205
- package/lib/node/ParseGeoPoint.js +21 -82
- package/lib/node/ParseHooks.js +0 -35
- package/lib/node/ParseInstallation.js +1 -10
- package/lib/node/ParseLiveQuery.js +10 -36
- package/lib/node/ParseObject.js +193 -939
- package/lib/node/ParseOp.js +31 -255
- package/lib/node/ParsePolygon.js +12 -62
- package/lib/node/ParseQuery.js +170 -882
- package/lib/node/ParseRelation.js +11 -61
- package/lib/node/ParseRole.js +10 -57
- package/lib/node/ParseSchema.js +46 -222
- package/lib/node/ParseSession.js +8 -50
- package/lib/node/ParseUser.js +107 -576
- package/lib/node/Push.js +4 -37
- package/lib/node/RESTController.js +8 -110
- package/lib/node/SingleInstanceStateController.js +17 -130
- package/lib/node/Socket.weapp.js +2 -9
- package/lib/node/Storage.js +10 -83
- package/lib/node/StorageController.browser.js +4 -23
- package/lib/node/StorageController.default.js +5 -21
- package/lib/node/StorageController.react-native.js +6 -40
- package/lib/node/StorageController.weapp.js +6 -21
- package/lib/node/TaskQueue.js +1 -17
- package/lib/node/UniqueInstanceStateController.js +16 -133
- package/lib/node/Xhr.weapp.js +0 -15
- package/lib/node/arrayContainsObject.js +1 -12
- package/lib/node/canBeSerialized.js +2 -28
- package/lib/node/decode.js +1 -26
- package/lib/node/encode.js +3 -54
- package/lib/node/equals.js +0 -18
- package/lib/node/escape.js +1 -6
- package/lib/node/isRevocableSession.js +1 -5
- package/lib/node/parseDate.js +1 -7
- package/lib/node/promiseUtils.js +2 -14
- package/lib/node/unique.js +1 -11
- package/lib/node/unsavedChildren.js +2 -38
- package/lib/node/uuid.js +6 -1
- package/lib/react-native/Analytics.js +0 -9
- package/lib/react-native/AnonymousUtils.js +0 -10
- package/lib/react-native/Cloud.js +0 -26
- package/lib/react-native/CoreManager.js +1 -5
- package/lib/react-native/CryptoController.js +0 -2
- package/lib/react-native/EventEmitter.js +0 -2
- package/lib/react-native/EventuallyQueue.js +4 -52
- package/lib/react-native/FacebookUtils.js +0 -22
- package/lib/react-native/IndexedDBStorageController.js +0 -1
- package/lib/react-native/InstallationController.js +0 -6
- package/lib/react-native/LiveQueryClient.js +24 -101
- package/lib/react-native/LiveQuerySubscription.js +3 -27
- package/lib/react-native/LocalDatastore.js +6 -113
- package/lib/react-native/LocalDatastoreController.js +0 -21
- package/lib/react-native/LocalDatastoreController.react-native.js +4 -31
- package/lib/react-native/LocalDatastoreUtils.js +0 -1
- package/lib/react-native/ObjectStateMutations.js +0 -34
- package/lib/react-native/OfflineQuery.js +2 -137
- package/lib/react-native/Parse.js +0 -65
- package/lib/react-native/ParseACL.js +0 -44
- package/lib/react-native/ParseCLP.js +32 -96
- package/lib/react-native/ParseConfig.js +0 -42
- package/lib/react-native/ParseError.js +1 -21
- package/lib/react-native/ParseFile.js +4 -72
- package/lib/react-native/ParseGeoPoint.js +0 -17
- package/lib/react-native/ParseHooks.js +0 -30
- package/lib/react-native/ParseInstallation.js +1 -23
- package/lib/react-native/ParseLiveQuery.js +3 -25
- package/lib/react-native/ParseObject.js +4 -371
- package/lib/react-native/ParseOp.js +1 -138
- package/lib/react-native/ParsePolygon.js +0 -24
- package/lib/react-native/ParseQuery.js +6 -262
- package/lib/react-native/ParseRelation.js +0 -25
- package/lib/react-native/ParseRole.js +1 -36
- package/lib/react-native/ParseSchema.js +0 -51
- package/lib/react-native/ParseSession.js +1 -40
- package/lib/react-native/ParseUser.js +1 -224
- package/lib/react-native/Push.js +0 -16
- package/lib/react-native/RESTController.js +1 -70
- package/lib/react-native/SingleInstanceStateController.js +0 -44
- package/lib/react-native/Socket.weapp.js +2 -12
- package/lib/react-native/Storage.js +0 -24
- package/lib/react-native/StorageController.browser.js +0 -2
- package/lib/react-native/StorageController.default.js +0 -1
- package/lib/react-native/StorageController.react-native.js +0 -2
- package/lib/react-native/TaskQueue.js +0 -15
- package/lib/react-native/UniqueInstanceStateController.js +0 -47
- package/lib/react-native/Xhr.weapp.js +0 -16
- package/lib/react-native/arrayContainsObject.js +0 -5
- package/lib/react-native/canBeSerialized.js +0 -18
- package/lib/react-native/decode.js +0 -21
- package/lib/react-native/encode.js +0 -25
- package/lib/react-native/equals.js +0 -18
- package/lib/react-native/escape.js +0 -1
- package/lib/react-native/isRevocableSession.js +0 -1
- package/lib/react-native/parseDate.js +0 -3
- package/lib/react-native/promiseUtils.js +0 -13
- package/lib/react-native/unique.js +0 -4
- package/lib/react-native/unsavedChildren.js +0 -21
- package/lib/react-native/uuid.js +3 -1
- package/lib/weapp/Analytics.js +2 -20
- package/lib/weapp/AnonymousUtils.js +6 -35
- package/lib/weapp/Cloud.js +12 -70
- package/lib/weapp/CloudCode.js +0 -3
- package/lib/weapp/CoreManager.js +46 -184
- package/lib/weapp/CryptoController.js +2 -16
- package/lib/weapp/EventEmitter.js +1 -1
- package/lib/weapp/EventuallyQueue.js +277 -824
- package/lib/weapp/FacebookUtils.js +6 -35
- package/lib/weapp/IndexedDBStorageController.js +3 -14
- package/lib/weapp/InstallationController.js +2 -13
- package/lib/weapp/LiveQueryClient.js +87 -204
- package/lib/weapp/LiveQuerySubscription.js +10 -39
- package/lib/weapp/LocalDatastore.js +451 -1081
- package/lib/weapp/LocalDatastoreController.js +145 -602
- package/lib/weapp/LocalDatastoreController.react-native.js +137 -573
- package/lib/weapp/LocalDatastoreUtils.js +2 -12
- package/lib/weapp/ObjectStateMutations.js +18 -121
- package/lib/weapp/OfflineQuery.js +42 -222
- package/lib/weapp/Parse.js +12 -106
- package/lib/weapp/ParseACL.js +33 -141
- package/lib/weapp/ParseCLP.js +96 -314
- package/lib/weapp/ParseConfig.js +18 -88
- package/lib/weapp/ParseError.js +63 -90
- package/lib/weapp/ParseFile.js +130 -686
- package/lib/weapp/ParseGeoPoint.js +23 -82
- package/lib/weapp/ParseHooks.js +1 -34
- package/lib/weapp/ParseInstallation.js +4 -32
- package/lib/weapp/ParseLiveQuery.js +96 -505
- package/lib/weapp/ParseObject.js +628 -1840
- package/lib/weapp/ParseOp.js +41 -287
- package/lib/weapp/ParsePolygon.js +13 -63
- package/lib/weapp/ParseQuery.js +404 -1505
- package/lib/weapp/ParseRelation.js +12 -61
- package/lib/weapp/ParseRole.js +13 -75
- package/lib/weapp/ParseSchema.js +49 -201
- package/lib/weapp/ParseSession.js +11 -69
- package/lib/weapp/ParseUser.js +274 -1127
- package/lib/weapp/Push.js +7 -43
- package/lib/weapp/RESTController.js +18 -140
- package/lib/weapp/SingleInstanceStateController.js +19 -137
- package/lib/weapp/Socket.weapp.js +2 -12
- package/lib/weapp/Storage.js +10 -73
- package/lib/weapp/StorageController.browser.js +4 -17
- package/lib/weapp/StorageController.default.js +4 -17
- package/lib/weapp/StorageController.react-native.js +6 -33
- package/lib/weapp/StorageController.weapp.js +5 -16
- package/lib/weapp/TaskQueue.js +1 -22
- package/lib/weapp/UniqueInstanceStateController.js +19 -142
- package/lib/weapp/Xhr.weapp.js +0 -17
- package/lib/weapp/arrayContainsObject.js +2 -16
- package/lib/weapp/canBeSerialized.js +3 -33
- package/lib/weapp/decode.js +3 -33
- package/lib/weapp/encode.js +9 -70
- package/lib/weapp/equals.js +2 -25
- package/lib/weapp/escape.js +1 -8
- package/lib/weapp/isRevocableSession.js +2 -11
- package/lib/weapp/parseDate.js +2 -13
- package/lib/weapp/promiseUtils.js +3 -21
- package/lib/weapp/unique.js +3 -17
- package/lib/weapp/unsavedChildren.js +6 -50
- package/lib/weapp/uuid.js +1 -6
- package/package.json +45 -43
package/lib/node/encode.js
CHANGED
|
@@ -4,21 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = _default;
|
|
7
|
-
|
|
8
7
|
var _ParseACL = _interopRequireDefault(require("./ParseACL"));
|
|
9
|
-
|
|
10
8
|
var _ParseFile = _interopRequireDefault(require("./ParseFile"));
|
|
11
|
-
|
|
12
9
|
var _ParseGeoPoint = _interopRequireDefault(require("./ParseGeoPoint"));
|
|
13
|
-
|
|
14
10
|
var _ParsePolygon = _interopRequireDefault(require("./ParsePolygon"));
|
|
15
|
-
|
|
16
11
|
var _ParseObject = _interopRequireDefault(require("./ParseObject"));
|
|
17
|
-
|
|
18
12
|
var _ParseOp = require("./ParseOp");
|
|
19
|
-
|
|
20
13
|
var _ParseRelation = _interopRequireDefault(require("./ParseRelation"));
|
|
21
|
-
|
|
22
14
|
function _interopRequireDefault(obj) {
|
|
23
15
|
return obj && obj.__esModule ? obj : {
|
|
24
16
|
default: obj
|
|
@@ -28,99 +20,56 @@ function _interopRequireDefault(obj) {
|
|
|
28
20
|
* @flow
|
|
29
21
|
*/
|
|
30
22
|
|
|
31
|
-
|
|
32
|
-
function encode(value
|
|
33
|
-
/*: mixed*/
|
|
34
|
-
, disallowObjects
|
|
35
|
-
/*: boolean*/
|
|
36
|
-
, forcePointers
|
|
37
|
-
/*: boolean*/
|
|
38
|
-
, seen
|
|
39
|
-
/*: Array<mixed>*/
|
|
40
|
-
, offline
|
|
41
|
-
/*: boolean*/
|
|
42
|
-
)
|
|
43
|
-
/*: any*/
|
|
44
|
-
{
|
|
23
|
+
function encode(value /*: mixed*/, disallowObjects /*: boolean*/, forcePointers /*: boolean*/, seen /*: Array<mixed>*/, offline /*: boolean*/) /*: any*/{
|
|
45
24
|
if (value instanceof _ParseObject.default) {
|
|
46
25
|
if (disallowObjects) {
|
|
47
26
|
throw new Error('Parse Objects not allowed here');
|
|
48
27
|
}
|
|
49
|
-
|
|
50
28
|
const seenEntry = value.id ? value.className + ':' + value.id : value;
|
|
51
|
-
|
|
52
29
|
if (forcePointers || !seen || seen.indexOf(seenEntry) > -1 || value.dirty() || Object.keys(value._getServerData()).length < 1) {
|
|
53
30
|
if (offline && value._getId().startsWith('local')) {
|
|
54
31
|
return value.toOfflinePointer();
|
|
55
32
|
}
|
|
56
|
-
|
|
57
33
|
return value.toPointer();
|
|
58
34
|
}
|
|
59
|
-
|
|
60
35
|
seen = seen.concat(seenEntry);
|
|
61
36
|
return value._toFullJSON(seen, offline);
|
|
62
37
|
}
|
|
63
|
-
|
|
64
38
|
if (value instanceof _ParseOp.Op || value instanceof _ParseACL.default || value instanceof _ParseGeoPoint.default || value instanceof _ParsePolygon.default || value instanceof _ParseRelation.default) {
|
|
65
39
|
return value.toJSON();
|
|
66
40
|
}
|
|
67
|
-
|
|
68
41
|
if (value instanceof _ParseFile.default) {
|
|
69
42
|
if (!value.url()) {
|
|
70
43
|
throw new Error('Tried to encode an unsaved file.');
|
|
71
44
|
}
|
|
72
|
-
|
|
73
45
|
return value.toJSON();
|
|
74
46
|
}
|
|
75
|
-
|
|
76
47
|
if (Object.prototype.toString.call(value) === '[object Date]') {
|
|
77
48
|
if (isNaN(value)) {
|
|
78
49
|
throw new Error('Tried to encode an invalid date.');
|
|
79
50
|
}
|
|
80
|
-
|
|
81
51
|
return {
|
|
82
52
|
__type: 'Date',
|
|
83
|
-
iso: value
|
|
84
|
-
/*: any*/
|
|
85
|
-
.toJSON()
|
|
53
|
+
iso: value /*: any*/.toJSON()
|
|
86
54
|
};
|
|
87
55
|
}
|
|
88
|
-
|
|
89
56
|
if (Object.prototype.toString.call(value) === '[object RegExp]' && typeof value.source === 'string') {
|
|
90
57
|
return value.source;
|
|
91
58
|
}
|
|
92
|
-
|
|
93
59
|
if (Array.isArray(value)) {
|
|
94
60
|
return value.map(v => {
|
|
95
61
|
return encode(v, disallowObjects, forcePointers, seen, offline);
|
|
96
62
|
});
|
|
97
63
|
}
|
|
98
|
-
|
|
99
64
|
if (value && typeof value === 'object') {
|
|
100
65
|
const output = {};
|
|
101
|
-
|
|
102
66
|
for (const k in value) {
|
|
103
67
|
output[k] = encode(value[k], disallowObjects, forcePointers, seen, offline);
|
|
104
68
|
}
|
|
105
|
-
|
|
106
69
|
return output;
|
|
107
70
|
}
|
|
108
|
-
|
|
109
71
|
return value;
|
|
110
72
|
}
|
|
111
|
-
|
|
112
|
-
function _default(value
|
|
113
|
-
/*: mixed*/
|
|
114
|
-
, disallowObjects
|
|
115
|
-
/*:: ?: boolean*/
|
|
116
|
-
, forcePointers
|
|
117
|
-
/*:: ?: boolean*/
|
|
118
|
-
, seen
|
|
119
|
-
/*:: ?: Array<mixed>*/
|
|
120
|
-
, offline
|
|
121
|
-
/*:: ?: boolean*/
|
|
122
|
-
)
|
|
123
|
-
/*: any*/
|
|
124
|
-
{
|
|
73
|
+
function _default(value /*: mixed*/, disallowObjects /*:: ?: boolean*/, forcePointers /*:: ?: boolean*/, seen /*:: ?: Array<mixed>*/, offline /*:: ?: boolean*/) /*: any*/{
|
|
125
74
|
return encode(value, !!disallowObjects, !!forcePointers, seen || [], offline);
|
|
126
75
|
}
|
package/lib/node/equals.js
CHANGED
|
@@ -4,76 +4,58 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = equals;
|
|
7
|
-
|
|
8
7
|
var _ParseACL = _interopRequireDefault(require("./ParseACL"));
|
|
9
|
-
|
|
10
8
|
var _ParseFile = _interopRequireDefault(require("./ParseFile"));
|
|
11
|
-
|
|
12
9
|
var _ParseGeoPoint = _interopRequireDefault(require("./ParseGeoPoint"));
|
|
13
|
-
|
|
14
10
|
var _ParseObject = _interopRequireDefault(require("./ParseObject"));
|
|
15
|
-
|
|
16
11
|
function _interopRequireDefault(obj) {
|
|
17
12
|
return obj && obj.__esModule ? obj : {
|
|
18
13
|
default: obj
|
|
19
14
|
};
|
|
20
15
|
}
|
|
21
|
-
|
|
22
16
|
function equals(a, b) {
|
|
23
17
|
const toString = Object.prototype.toString;
|
|
24
|
-
|
|
25
18
|
if (toString.call(a) === '[object Date]' || toString.call(b) === '[object Date]') {
|
|
26
19
|
const dateA = new Date(a);
|
|
27
20
|
const dateB = new Date(b);
|
|
28
21
|
return +dateA === +dateB;
|
|
29
22
|
}
|
|
30
|
-
|
|
31
23
|
if (typeof a !== typeof b) {
|
|
32
24
|
return false;
|
|
33
25
|
}
|
|
34
|
-
|
|
35
26
|
if (!a || typeof a !== 'object') {
|
|
36
27
|
// a is a primitive
|
|
37
28
|
return a === b;
|
|
38
29
|
}
|
|
39
|
-
|
|
40
30
|
if (Array.isArray(a) || Array.isArray(b)) {
|
|
41
31
|
if (!Array.isArray(a) || !Array.isArray(b)) {
|
|
42
32
|
return false;
|
|
43
33
|
}
|
|
44
|
-
|
|
45
34
|
if (a.length !== b.length) {
|
|
46
35
|
return false;
|
|
47
36
|
}
|
|
48
|
-
|
|
49
37
|
for (let i = a.length; i--;) {
|
|
50
38
|
if (!equals(a[i], b[i])) {
|
|
51
39
|
return false;
|
|
52
40
|
}
|
|
53
41
|
}
|
|
54
|
-
|
|
55
42
|
return true;
|
|
56
43
|
}
|
|
57
|
-
|
|
58
44
|
if (a instanceof _ParseACL.default || a instanceof _ParseFile.default || a instanceof _ParseGeoPoint.default || a instanceof _ParseObject.default) {
|
|
59
45
|
return a.equals(b);
|
|
60
46
|
}
|
|
61
|
-
|
|
62
47
|
if (b instanceof _ParseObject.default) {
|
|
63
48
|
if (a.__type === 'Object' || a.__type === 'Pointer') {
|
|
64
49
|
return a.objectId === b.id && a.className === b.className;
|
|
65
50
|
}
|
|
66
51
|
}
|
|
67
|
-
|
|
68
52
|
if (Object.keys(a).length !== Object.keys(b).length) {
|
|
69
53
|
return false;
|
|
70
54
|
}
|
|
71
|
-
|
|
72
55
|
for (const k in a) {
|
|
73
56
|
if (!equals(a[k], b[k])) {
|
|
74
57
|
return false;
|
|
75
58
|
}
|
|
76
59
|
}
|
|
77
|
-
|
|
78
60
|
return true;
|
|
79
61
|
}
|
package/lib/node/escape.js
CHANGED
|
@@ -16,12 +16,7 @@ const encoded = {
|
|
|
16
16
|
"'": ''',
|
|
17
17
|
'"': '"'
|
|
18
18
|
};
|
|
19
|
-
|
|
20
|
-
function escape(str
|
|
21
|
-
/*: string*/
|
|
22
|
-
)
|
|
23
|
-
/*: string*/
|
|
24
|
-
{
|
|
19
|
+
function escape(str /*: string*/) /*: string*/{
|
|
25
20
|
return str.replace(/[&<>\/'"]/g, function (char) {
|
|
26
21
|
return encoded[char];
|
|
27
22
|
});
|
package/lib/node/parseDate.js
CHANGED
|
@@ -8,18 +8,12 @@ exports.default = parseDate;
|
|
|
8
8
|
* @flow
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
function parseDate(iso8601
|
|
12
|
-
/*: string*/
|
|
13
|
-
)
|
|
14
|
-
/*: ?Date*/
|
|
15
|
-
{
|
|
11
|
+
function parseDate(iso8601 /*: string*/) /*: ?Date*/{
|
|
16
12
|
const regexp = new RegExp('^([0-9]{1,4})-([0-9]{1,2})-([0-9]{1,2})' + 'T' + '([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})' + '(.([0-9]+))?' + 'Z$');
|
|
17
13
|
const match = regexp.exec(iso8601);
|
|
18
|
-
|
|
19
14
|
if (!match) {
|
|
20
15
|
return null;
|
|
21
16
|
}
|
|
22
|
-
|
|
23
17
|
const year = parseInt(match[1]) || 0;
|
|
24
18
|
const month = (parseInt(match[2]) || 1) - 1;
|
|
25
19
|
const day = parseInt(match[3]) || 0;
|
package/lib/node/promiseUtils.js
CHANGED
|
@@ -5,8 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.continueWhile = continueWhile;
|
|
7
7
|
exports.resolvingPromise = resolvingPromise;
|
|
8
|
-
exports.when = when;
|
|
9
|
-
|
|
8
|
+
exports.when = when;
|
|
9
|
+
// Create Deferred Promise
|
|
10
10
|
function resolvingPromise() {
|
|
11
11
|
let res;
|
|
12
12
|
let rej;
|
|
@@ -18,17 +18,14 @@ function resolvingPromise() {
|
|
|
18
18
|
promise.reject = rej;
|
|
19
19
|
return promise;
|
|
20
20
|
}
|
|
21
|
-
|
|
22
21
|
function when(promises) {
|
|
23
22
|
let objects;
|
|
24
23
|
const arrayArgument = Array.isArray(promises);
|
|
25
|
-
|
|
26
24
|
if (arrayArgument) {
|
|
27
25
|
objects = promises;
|
|
28
26
|
} else {
|
|
29
27
|
objects = arguments;
|
|
30
28
|
}
|
|
31
|
-
|
|
32
29
|
let total = objects.length;
|
|
33
30
|
let hadError = false;
|
|
34
31
|
const results = [];
|
|
@@ -36,16 +33,12 @@ function when(promises) {
|
|
|
36
33
|
const errors = [];
|
|
37
34
|
results.length = objects.length;
|
|
38
35
|
errors.length = objects.length;
|
|
39
|
-
|
|
40
36
|
if (total === 0) {
|
|
41
37
|
return Promise.resolve(returnValue);
|
|
42
38
|
}
|
|
43
|
-
|
|
44
39
|
const promise = new resolvingPromise();
|
|
45
|
-
|
|
46
40
|
const resolveOne = function () {
|
|
47
41
|
total--;
|
|
48
|
-
|
|
49
42
|
if (total <= 0) {
|
|
50
43
|
if (hadError) {
|
|
51
44
|
promise.reject(errors);
|
|
@@ -54,7 +47,6 @@ function when(promises) {
|
|
|
54
47
|
}
|
|
55
48
|
}
|
|
56
49
|
};
|
|
57
|
-
|
|
58
50
|
const chain = function (object, index) {
|
|
59
51
|
if (object && typeof object.then === 'function') {
|
|
60
52
|
object.then(function (result) {
|
|
@@ -70,20 +62,16 @@ function when(promises) {
|
|
|
70
62
|
resolveOne();
|
|
71
63
|
}
|
|
72
64
|
};
|
|
73
|
-
|
|
74
65
|
for (let i = 0; i < objects.length; i++) {
|
|
75
66
|
chain(objects[i], i);
|
|
76
67
|
}
|
|
77
|
-
|
|
78
68
|
return promise;
|
|
79
69
|
}
|
|
80
|
-
|
|
81
70
|
function continueWhile(test, emitter) {
|
|
82
71
|
if (test()) {
|
|
83
72
|
return emitter().then(() => {
|
|
84
73
|
return continueWhile(test, emitter);
|
|
85
74
|
});
|
|
86
75
|
}
|
|
87
|
-
|
|
88
76
|
return Promise.resolve();
|
|
89
77
|
}
|
package/lib/node/unique.js
CHANGED
|
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = unique;
|
|
7
|
-
|
|
8
7
|
var _arrayContainsObject = _interopRequireDefault(require("./arrayContainsObject"));
|
|
9
|
-
|
|
10
8
|
var _ParseObject = _interopRequireDefault(require("./ParseObject"));
|
|
11
|
-
|
|
12
9
|
function _interopRequireDefault(obj) {
|
|
13
10
|
return obj && obj.__esModule ? obj : {
|
|
14
11
|
default: obj
|
|
@@ -18,14 +15,7 @@ function _interopRequireDefault(obj) {
|
|
|
18
15
|
* @flow
|
|
19
16
|
*/
|
|
20
17
|
|
|
21
|
-
|
|
22
|
-
function unique
|
|
23
|
-
/*:: <T>*/
|
|
24
|
-
(arr
|
|
25
|
-
/*: Array<T>*/
|
|
26
|
-
)
|
|
27
|
-
/*: Array<T>*/
|
|
28
|
-
{
|
|
18
|
+
function unique /*:: <T>*/(arr /*: Array<T>*/) /*: Array<T>*/{
|
|
29
19
|
const uniques = [];
|
|
30
20
|
arr.forEach(value => {
|
|
31
21
|
if (value instanceof _ParseObject.default) {
|
|
@@ -4,13 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = unsavedChildren;
|
|
7
|
-
|
|
8
7
|
var _ParseFile = _interopRequireDefault(require("./ParseFile"));
|
|
9
|
-
|
|
10
8
|
var _ParseObject = _interopRequireDefault(require("./ParseObject"));
|
|
11
|
-
|
|
12
9
|
var _ParseRelation = _interopRequireDefault(require("./ParseRelation"));
|
|
13
|
-
|
|
14
10
|
function _interopRequireDefault(obj) {
|
|
15
11
|
return obj && obj.__esModule ? obj : {
|
|
16
12
|
default: obj
|
|
@@ -28,84 +24,53 @@ function _interopRequireDefault(obj) {
|
|
|
28
24
|
* @param {boolean} allowDeepUnsaved
|
|
29
25
|
* @returns {Array}
|
|
30
26
|
*/
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
function unsavedChildren(obj
|
|
34
|
-
/*: ParseObject*/
|
|
35
|
-
, allowDeepUnsaved
|
|
36
|
-
/*:: ?: boolean*/
|
|
37
|
-
)
|
|
38
|
-
/*: Array<ParseFile | ParseObject>*/
|
|
39
|
-
{
|
|
27
|
+
function unsavedChildren(obj /*: ParseObject*/, allowDeepUnsaved /*:: ?: boolean*/) /*: Array<ParseFile | ParseObject>*/{
|
|
40
28
|
const encountered = {
|
|
41
29
|
objects: {},
|
|
42
30
|
files: []
|
|
43
31
|
};
|
|
44
|
-
|
|
45
32
|
const identifier = obj.className + ':' + obj._getId();
|
|
46
|
-
|
|
47
33
|
encountered.objects[identifier] = obj.dirty() ? obj : true;
|
|
48
34
|
const attributes = obj.attributes;
|
|
49
|
-
|
|
50
35
|
for (const attr in attributes) {
|
|
51
36
|
if (typeof attributes[attr] === 'object') {
|
|
52
37
|
traverse(attributes[attr], encountered, false, !!allowDeepUnsaved);
|
|
53
38
|
}
|
|
54
39
|
}
|
|
55
|
-
|
|
56
40
|
const unsaved = [];
|
|
57
|
-
|
|
58
41
|
for (const id in encountered.objects) {
|
|
59
42
|
if (id !== identifier && encountered.objects[id] !== true) {
|
|
60
43
|
unsaved.push(encountered.objects[id]);
|
|
61
44
|
}
|
|
62
45
|
}
|
|
63
|
-
|
|
64
46
|
return unsaved.concat(encountered.files);
|
|
65
47
|
}
|
|
66
|
-
|
|
67
|
-
function traverse(obj
|
|
68
|
-
/*: ParseObject*/
|
|
69
|
-
, encountered
|
|
70
|
-
/*: EncounterMap*/
|
|
71
|
-
, shouldThrow
|
|
72
|
-
/*: boolean*/
|
|
73
|
-
, allowDeepUnsaved
|
|
74
|
-
/*: boolean*/
|
|
75
|
-
) {
|
|
48
|
+
function traverse(obj /*: ParseObject*/, encountered /*: EncounterMap*/, shouldThrow /*: boolean*/, allowDeepUnsaved /*: boolean*/) {
|
|
76
49
|
if (obj instanceof _ParseObject.default) {
|
|
77
50
|
if (!obj.id && shouldThrow) {
|
|
78
51
|
throw new Error('Cannot create a pointer to an unsaved Object.');
|
|
79
52
|
}
|
|
80
|
-
|
|
81
53
|
const identifier = obj.className + ':' + obj._getId();
|
|
82
|
-
|
|
83
54
|
if (!encountered.objects[identifier]) {
|
|
84
55
|
encountered.objects[identifier] = obj.dirty() ? obj : true;
|
|
85
56
|
const attributes = obj.attributes;
|
|
86
|
-
|
|
87
57
|
for (const attr in attributes) {
|
|
88
58
|
if (typeof attributes[attr] === 'object') {
|
|
89
59
|
traverse(attributes[attr], encountered, !allowDeepUnsaved, allowDeepUnsaved);
|
|
90
60
|
}
|
|
91
61
|
}
|
|
92
62
|
}
|
|
93
|
-
|
|
94
63
|
return;
|
|
95
64
|
}
|
|
96
|
-
|
|
97
65
|
if (obj instanceof _ParseFile.default) {
|
|
98
66
|
if (!obj.url() && encountered.files.indexOf(obj) < 0) {
|
|
99
67
|
encountered.files.push(obj);
|
|
100
68
|
}
|
|
101
|
-
|
|
102
69
|
return;
|
|
103
70
|
}
|
|
104
|
-
|
|
105
71
|
if (obj instanceof _ParseRelation.default) {
|
|
106
72
|
return;
|
|
107
73
|
}
|
|
108
|
-
|
|
109
74
|
if (Array.isArray(obj)) {
|
|
110
75
|
obj.forEach(el => {
|
|
111
76
|
if (typeof el === 'object') {
|
|
@@ -113,7 +78,6 @@ function traverse(obj
|
|
|
113
78
|
}
|
|
114
79
|
});
|
|
115
80
|
}
|
|
116
|
-
|
|
117
81
|
for (const k in obj) {
|
|
118
82
|
if (typeof obj[k] === 'object') {
|
|
119
83
|
traverse(obj[k], encountered, shouldThrow, allowDeepUnsaved);
|
package/lib/node/uuid.js
CHANGED
|
@@ -1,38 +1,29 @@
|
|
|
1
1
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
2
|
-
|
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
|
4
3
|
value: true
|
|
5
4
|
});
|
|
6
5
|
exports.track = track;
|
|
7
|
-
|
|
8
6
|
var _CoreManager = _interopRequireDefault(require("./CoreManager"));
|
|
9
|
-
|
|
10
7
|
function track(name, dimensions) {
|
|
11
8
|
name = name || '';
|
|
12
9
|
name = name.replace(/^\s*/, '');
|
|
13
10
|
name = name.replace(/\s*$/, '');
|
|
14
|
-
|
|
15
11
|
if (name.length === 0) {
|
|
16
12
|
throw new TypeError('A name for the custom event must be provided');
|
|
17
13
|
}
|
|
18
|
-
|
|
19
14
|
for (var _key in dimensions) {
|
|
20
15
|
if (typeof _key !== 'string' || typeof dimensions[_key] !== 'string') {
|
|
21
16
|
throw new TypeError('track() dimensions expects keys and values of type "string".');
|
|
22
17
|
}
|
|
23
18
|
}
|
|
24
|
-
|
|
25
19
|
return _CoreManager.default.getAnalyticsController().track(name, dimensions);
|
|
26
20
|
}
|
|
27
|
-
|
|
28
21
|
var DefaultController = {
|
|
29
22
|
track: function (name, dimensions) {
|
|
30
23
|
var RESTController = _CoreManager.default.getRESTController();
|
|
31
|
-
|
|
32
24
|
return RESTController.request('POST', 'events/' + name, {
|
|
33
25
|
dimensions: dimensions
|
|
34
26
|
});
|
|
35
27
|
}
|
|
36
28
|
};
|
|
37
|
-
|
|
38
29
|
_CoreManager.default.setAnalyticsController(DefaultController);
|
|
@@ -1,29 +1,22 @@
|
|
|
1
1
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
2
|
-
|
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
|
4
3
|
value: true
|
|
5
4
|
});
|
|
6
5
|
exports.default = void 0;
|
|
7
|
-
|
|
8
6
|
var _ParseUser = _interopRequireDefault(require("./ParseUser"));
|
|
9
|
-
|
|
10
7
|
var uuidv4 = require('./uuid');
|
|
11
|
-
|
|
12
8
|
var registered = false;
|
|
13
9
|
var AnonymousUtils = {
|
|
14
10
|
isLinked: function (user) {
|
|
15
11
|
var provider = this._getAuthProvider();
|
|
16
|
-
|
|
17
12
|
return user._isLinked(provider.getAuthType());
|
|
18
13
|
},
|
|
19
14
|
logIn: function (options) {
|
|
20
15
|
var provider = this._getAuthProvider();
|
|
21
|
-
|
|
22
16
|
return _ParseUser.default.logInWith(provider.getAuthType(), provider.getAuthData(), options);
|
|
23
17
|
},
|
|
24
18
|
link: function (user, options) {
|
|
25
19
|
var provider = this._getAuthProvider();
|
|
26
|
-
|
|
27
20
|
return user.linkWith(provider.getAuthType(), provider.getAuthData(), options);
|
|
28
21
|
},
|
|
29
22
|
isRegistered: function () {
|
|
@@ -45,13 +38,10 @@ var AnonymousUtils = {
|
|
|
45
38
|
};
|
|
46
39
|
}
|
|
47
40
|
};
|
|
48
|
-
|
|
49
41
|
if (!registered) {
|
|
50
42
|
_ParseUser.default._registerAuthenticationProvider(provider);
|
|
51
|
-
|
|
52
43
|
registered = true;
|
|
53
44
|
}
|
|
54
|
-
|
|
55
45
|
return provider;
|
|
56
46
|
}
|
|
57
47
|
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
2
|
-
|
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
|
4
3
|
value: true
|
|
5
4
|
});
|
|
@@ -7,97 +6,72 @@ exports.getJobStatus = getJobStatus;
|
|
|
7
6
|
exports.getJobsData = getJobsData;
|
|
8
7
|
exports.run = run;
|
|
9
8
|
exports.startJob = startJob;
|
|
10
|
-
|
|
11
9
|
var _CoreManager = _interopRequireDefault(require("./CoreManager"));
|
|
12
|
-
|
|
13
10
|
var _decode = _interopRequireDefault(require("./decode"));
|
|
14
|
-
|
|
15
11
|
var _encode = _interopRequireDefault(require("./encode"));
|
|
16
|
-
|
|
17
12
|
var _ParseError = _interopRequireDefault(require("./ParseError"));
|
|
18
|
-
|
|
19
13
|
var _ParseQuery = _interopRequireDefault(require("./ParseQuery"));
|
|
20
|
-
|
|
21
14
|
var _ParseObject = _interopRequireDefault(require("./ParseObject"));
|
|
22
|
-
|
|
23
15
|
function run(name, data, options) {
|
|
24
16
|
options = options || {};
|
|
25
|
-
|
|
26
17
|
if (typeof name !== 'string' || name.length === 0) {
|
|
27
18
|
throw new TypeError('Cloud function name must be a string.');
|
|
28
19
|
}
|
|
29
|
-
|
|
30
20
|
var requestOptions = {};
|
|
31
|
-
|
|
32
21
|
if (options.useMasterKey) {
|
|
33
22
|
requestOptions.useMasterKey = options.useMasterKey;
|
|
34
23
|
}
|
|
35
|
-
|
|
36
24
|
if (options.sessionToken) {
|
|
37
25
|
requestOptions.sessionToken = options.sessionToken;
|
|
38
26
|
}
|
|
39
|
-
|
|
40
27
|
if (options.context && typeof options.context === 'object') {
|
|
41
28
|
requestOptions.context = options.context;
|
|
42
29
|
}
|
|
43
|
-
|
|
44
30
|
return _CoreManager.default.getCloudController().run(name, data, requestOptions);
|
|
45
31
|
}
|
|
46
|
-
|
|
47
32
|
function getJobsData() {
|
|
48
33
|
return _CoreManager.default.getCloudController().getJobsData({
|
|
49
34
|
useMasterKey: true
|
|
50
35
|
});
|
|
51
36
|
}
|
|
52
|
-
|
|
53
37
|
function startJob(name, data) {
|
|
54
38
|
if (typeof name !== 'string' || name.length === 0) {
|
|
55
39
|
throw new TypeError('Cloud job name must be a string.');
|
|
56
40
|
}
|
|
57
|
-
|
|
58
41
|
return _CoreManager.default.getCloudController().startJob(name, data, {
|
|
59
42
|
useMasterKey: true
|
|
60
43
|
});
|
|
61
44
|
}
|
|
62
|
-
|
|
63
45
|
function getJobStatus(jobStatusId) {
|
|
64
46
|
var query = new _ParseQuery.default('_JobStatus');
|
|
65
47
|
return query.get(jobStatusId, {
|
|
66
48
|
useMasterKey: true
|
|
67
49
|
});
|
|
68
50
|
}
|
|
69
|
-
|
|
70
51
|
var DefaultController = {
|
|
71
52
|
run: function (name, data, options) {
|
|
72
53
|
var RESTController = _CoreManager.default.getRESTController();
|
|
73
|
-
|
|
74
54
|
var payload = (0, _encode.default)(data, true);
|
|
75
55
|
var request = RESTController.request('POST', 'functions/' + name, payload, options);
|
|
76
56
|
return request.then(function (res) {
|
|
77
57
|
if (typeof res === 'object' && Object.keys(res).length > 0 && !res.hasOwnProperty('result')) {
|
|
78
58
|
throw new _ParseError.default(_ParseError.default.INVALID_JSON, 'The server returned an invalid response.');
|
|
79
59
|
}
|
|
80
|
-
|
|
81
60
|
var decoded = (0, _decode.default)(res);
|
|
82
|
-
|
|
83
61
|
if (decoded && decoded.hasOwnProperty('result')) {
|
|
84
62
|
return Promise.resolve(decoded.result);
|
|
85
63
|
}
|
|
86
|
-
|
|
87
64
|
return Promise.resolve(undefined);
|
|
88
65
|
});
|
|
89
66
|
},
|
|
90
67
|
getJobsData: function (options) {
|
|
91
68
|
var RESTController = _CoreManager.default.getRESTController();
|
|
92
|
-
|
|
93
69
|
return RESTController.request('GET', 'cloud_code/jobs/data', null, options);
|
|
94
70
|
},
|
|
95
71
|
startJob: function (name, data, options) {
|
|
96
72
|
var RESTController = _CoreManager.default.getRESTController();
|
|
97
|
-
|
|
98
73
|
var payload = (0, _encode.default)(data, true);
|
|
99
74
|
return RESTController.request('POST', 'jobs/' + name, payload, options);
|
|
100
75
|
}
|
|
101
76
|
};
|
|
102
|
-
|
|
103
77
|
_CoreManager.default.setCloudController(DefaultController);
|
|
@@ -8,7 +8,7 @@ var config = {
|
|
|
8
8
|
SERVER_AUTH_TOKEN: null,
|
|
9
9
|
LIVEQUERY_SERVER_URL: null,
|
|
10
10
|
ENCRYPTED_KEY: null,
|
|
11
|
-
VERSION: 'js' + "4.0.
|
|
11
|
+
VERSION: 'js' + "4.1.0-alpha.2",
|
|
12
12
|
APPLICATION_ID: null,
|
|
13
13
|
JAVASCRIPT_KEY: null,
|
|
14
14
|
MASTER_KEY: null,
|
|
@@ -19,7 +19,6 @@ var config = {
|
|
|
19
19
|
IDEMPOTENCY: false,
|
|
20
20
|
ALLOW_CUSTOM_OBJECT_ID: false
|
|
21
21
|
};
|
|
22
|
-
|
|
23
22
|
function requireMethods(name, methods, controller) {
|
|
24
23
|
methods.forEach(function (func) {
|
|
25
24
|
if (typeof controller[func] !== 'function') {
|
|
@@ -27,13 +26,11 @@ function requireMethods(name, methods, controller) {
|
|
|
27
26
|
}
|
|
28
27
|
});
|
|
29
28
|
}
|
|
30
|
-
|
|
31
29
|
module.exports = {
|
|
32
30
|
get: function (key) {
|
|
33
31
|
if (config.hasOwnProperty(key)) {
|
|
34
32
|
return config[key];
|
|
35
33
|
}
|
|
36
|
-
|
|
37
34
|
throw new Error('Configuration key not found: ' + key);
|
|
38
35
|
},
|
|
39
36
|
set: function (key, value) {
|
|
@@ -136,7 +133,6 @@ module.exports = {
|
|
|
136
133
|
} else {
|
|
137
134
|
requireMethods('A synchronous StorageController', ['getItem', 'setItem', 'removeItem', 'getAllKeys'], controller);
|
|
138
135
|
}
|
|
139
|
-
|
|
140
136
|
config['StorageController'] = controller;
|
|
141
137
|
},
|
|
142
138
|
setLocalDatastoreController: function (controller) {
|