parse 5.1.1-alpha.1 → 5.2.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 +10186 -14918
- package/dist/parse.min.js +2 -2
- package/dist/parse.weapp.js +10180 -15057
- package/dist/parse.weapp.min.js +2 -2
- package/lib/browser/Analytics.js +7 -11
- package/lib/browser/AnonymousUtils.js +17 -22
- package/lib/browser/Cloud.js +24 -46
- package/lib/browser/CoreManager.js +71 -79
- package/lib/browser/CryptoController.js +14 -9
- package/lib/browser/EventEmitter.js +9 -2
- package/lib/browser/EventuallyQueue.js +156 -357
- package/lib/browser/FacebookUtils.js +23 -28
- package/lib/browser/IndexedDBStorageController.js +18 -14
- package/lib/browser/InstallationController.js +55 -121
- package/lib/browser/LiveQueryClient.js +312 -446
- package/lib/browser/LiveQuerySubscription.js +25 -28
- package/lib/browser/LocalDatastore.js +254 -578
- package/lib/browser/LocalDatastoreController.default.js +48 -227
- package/lib/browser/LocalDatastoreController.js +11 -1
- package/lib/browser/LocalDatastoreController.react-native.js +72 -164
- package/lib/browser/LocalDatastoreUtils.js +4 -12
- package/lib/browser/ObjectStateMutations.js +89 -95
- package/lib/browser/OfflineQuery.js +106 -198
- package/lib/browser/Parse.js +45 -61
- package/lib/browser/ParseACL.js +242 -288
- package/lib/browser/ParseCLP.js +372 -580
- package/lib/browser/ParseConfig.js +115 -138
- package/lib/browser/ParseError.js +85 -182
- package/lib/browser/ParseFile.js +296 -444
- package/lib/browser/ParseGeoPoint.js +121 -140
- package/lib/browser/ParseHooks.js +12 -14
- package/lib/browser/ParseInstallation.js +226 -354
- package/lib/browser/ParseLiveQuery.js +74 -148
- package/lib/browser/ParseObject.js +2017 -2622
- package/lib/browser/ParseOp.js +343 -484
- package/lib/browser/ParsePolygon.js +101 -120
- package/lib/browser/ParseQuery.js +1722 -2068
- package/lib/browser/ParseRelation.js +99 -118
- package/lib/browser/ParseRole.js +88 -144
- package/lib/browser/ParseSchema.js +372 -434
- package/lib/browser/ParseSession.js +62 -110
- package/lib/browser/ParseUser.js +942 -1270
- package/lib/browser/Push.js +16 -44
- package/lib/browser/RESTController.js +85 -124
- package/lib/browser/SingleInstanceStateController.js +57 -86
- package/lib/browser/Socket.weapp.js +50 -33
- package/lib/browser/Storage.js +23 -28
- package/lib/browser/StorageController.browser.js +16 -13
- package/lib/browser/StorageController.default.js +15 -14
- package/lib/browser/StorageController.js +14 -1
- package/lib/browser/StorageController.react-native.js +31 -30
- package/lib/browser/StorageController.weapp.js +19 -13
- package/lib/browser/TaskQueue.js +37 -49
- package/lib/browser/UniqueInstanceStateController.js +65 -86
- package/lib/browser/WebSocketController.js +11 -4
- package/lib/browser/Xhr.weapp.js +90 -78
- package/lib/browser/arrayContainsObject.js +3 -3
- package/lib/browser/canBeSerialized.js +10 -11
- package/lib/browser/decode.js +11 -11
- package/lib/browser/encode.js +11 -11
- package/lib/browser/equals.js +9 -10
- package/lib/browser/escape.js +2 -2
- package/lib/browser/isRevocableSession.js +1 -1
- package/lib/browser/parseDate.js +10 -10
- package/lib/browser/promiseUtils.js +19 -19
- package/lib/browser/unique.js +4 -4
- package/lib/browser/unsavedChildren.js +20 -21
- package/lib/browser/uuid.js +2 -4
- package/lib/node/Analytics.js +2 -6
- package/lib/node/AnonymousUtils.js +7 -12
- package/lib/node/Cloud.js +8 -12
- package/lib/node/CoreManager.js +59 -67
- package/lib/node/CryptoController.js +8 -3
- package/lib/node/EventEmitter.js +7 -1
- package/lib/node/EventuallyQueue.js +18 -37
- package/lib/node/FacebookUtils.js +1 -5
- package/lib/node/IndexedDBStorageController.js +14 -10
- package/lib/node/InstallationController.js +7 -8
- package/lib/node/LiveQueryClient.js +20 -32
- package/lib/node/LiveQuerySubscription.js +3 -4
- package/lib/node/LocalDatastore.js +20 -24
- package/lib/node/LocalDatastoreController.default.js +12 -11
- package/lib/node/LocalDatastoreController.js +14 -1
- package/lib/node/LocalDatastoreController.react-native.js +27 -22
- package/lib/node/LocalDatastoreUtils.js +4 -12
- package/lib/node/ObjectStateMutations.js +52 -36
- package/lib/node/OfflineQuery.js +37 -23
- package/lib/node/Parse.js +35 -49
- package/lib/node/ParseACL.js +18 -27
- package/lib/node/ParseCLP.js +38 -50
- package/lib/node/ParseConfig.js +7 -14
- package/lib/node/ParseError.js +457 -458
- package/lib/node/ParseFile.js +33 -66
- package/lib/node/ParseGeoPoint.js +22 -17
- package/lib/node/ParseHooks.js +0 -2
- package/lib/node/ParseInstallation.js +21 -8
- package/lib/node/ParseLiveQuery.js +6 -11
- package/lib/node/ParseObject.js +138 -167
- package/lib/node/ParseOp.js +32 -44
- package/lib/node/ParsePolygon.js +11 -17
- package/lib/node/ParseQuery.js +118 -164
- package/lib/node/ParseRelation.js +7 -16
- package/lib/node/ParseRole.js +7 -13
- package/lib/node/ParseSchema.js +26 -39
- package/lib/node/ParseSession.js +7 -8
- package/lib/node/ParseUser.js +70 -76
- package/lib/node/Push.js +5 -15
- package/lib/node/RESTController.js +21 -33
- package/lib/node/SingleInstanceStateController.js +41 -69
- package/lib/node/Socket.weapp.js +23 -2
- package/lib/node/Storage.js +11 -16
- package/lib/node/StorageController.browser.js +10 -8
- package/lib/node/StorageController.default.js +9 -9
- package/lib/node/StorageController.js +16 -1
- package/lib/node/StorageController.react-native.js +17 -17
- package/lib/node/StorageController.weapp.js +14 -8
- package/lib/node/TaskQueue.js +8 -11
- package/lib/node/UniqueInstanceStateController.js +40 -60
- package/lib/node/WebSocketController.js +15 -2
- package/lib/node/Xhr.weapp.js +11 -2
- package/lib/node/arrayContainsObject.js +1 -1
- package/lib/node/canBeSerialized.js +2 -2
- package/lib/node/decode.js +1 -1
- package/lib/node/encode.js +2 -2
- package/lib/node/equals.js +1 -1
- package/lib/node/escape.js +1 -1
- package/lib/node/isRevocableSession.js +1 -1
- package/lib/node/parseDate.js +1 -1
- package/lib/node/promiseUtils.js +7 -7
- package/lib/node/unique.js +2 -2
- package/lib/node/unsavedChildren.js +2 -2
- package/lib/node/uuid.js +2 -4
- package/lib/react-native/Analytics.js +2 -2
- package/lib/react-native/AnonymousUtils.js +3 -4
- package/lib/react-native/Cloud.js +0 -1
- package/lib/react-native/CoreManager.js +2 -3
- package/lib/react-native/CryptoController.js +6 -1
- package/lib/react-native/EventEmitter.js +6 -1
- package/lib/react-native/EventuallyQueue.js +1 -2
- package/lib/react-native/FacebookUtils.js +1 -2
- package/lib/react-native/IndexedDBStorageController.js +11 -5
- package/lib/react-native/InstallationController.js +1 -2
- package/lib/react-native/LiveQueryClient.js +51 -36
- package/lib/react-native/LiveQuerySubscription.js +2 -4
- package/lib/react-native/LocalDatastore.js +41 -17
- package/lib/react-native/LocalDatastoreController.default.js +6 -1
- package/lib/react-native/LocalDatastoreController.js +11 -1
- package/lib/react-native/LocalDatastoreController.react-native.js +16 -11
- package/lib/react-native/LocalDatastoreUtils.js +3 -6
- package/lib/react-native/ObjectStateMutations.js +30 -9
- package/lib/react-native/OfflineQuery.js +25 -20
- package/lib/react-native/Parse.js +24 -38
- package/lib/react-native/ParseACL.js +4 -6
- package/lib/react-native/ParseCLP.js +5 -7
- package/lib/react-native/ParseConfig.js +4 -6
- package/lib/react-native/ParseError.js +13 -31
- package/lib/react-native/ParseFile.js +10 -10
- package/lib/react-native/ParseGeoPoint.js +2 -4
- package/lib/react-native/ParseInstallation.js +13 -30
- package/lib/react-native/ParseLiveQuery.js +2 -4
- package/lib/react-native/ParseObject.js +81 -90
- package/lib/react-native/ParseOp.js +41 -79
- package/lib/react-native/ParsePolygon.js +2 -4
- package/lib/react-native/ParseQuery.js +87 -81
- package/lib/react-native/ParseRelation.js +2 -4
- package/lib/react-native/ParseRole.js +14 -31
- package/lib/react-native/ParseSchema.js +3 -5
- package/lib/react-native/ParseSession.js +12 -29
- package/lib/react-native/ParseUser.js +32 -51
- package/lib/react-native/RESTController.js +10 -4
- package/lib/react-native/SingleInstanceStateController.js +23 -37
- package/lib/react-native/Socket.weapp.js +9 -4
- package/lib/react-native/Storage.js +1 -2
- package/lib/react-native/StorageController.browser.js +6 -1
- package/lib/react-native/StorageController.default.js +6 -1
- package/lib/react-native/StorageController.js +13 -1
- package/lib/react-native/StorageController.react-native.js +11 -6
- package/lib/react-native/StorageController.weapp.js +6 -1
- package/lib/react-native/TaskQueue.js +8 -4
- package/lib/react-native/UniqueInstanceStateController.js +23 -37
- package/lib/react-native/WebSocketController.js +9 -1
- package/lib/react-native/Xhr.weapp.js +9 -4
- package/lib/react-native/unsavedChildren.js +3 -3
- package/lib/react-native/uuid.js +1 -2
- package/lib/weapp/Analytics.js +7 -11
- package/lib/weapp/AnonymousUtils.js +17 -22
- package/lib/weapp/Cloud.js +24 -46
- package/lib/weapp/CoreManager.js +71 -79
- package/lib/weapp/CryptoController.js +14 -9
- package/lib/weapp/EventEmitter.js +9 -2
- package/lib/weapp/EventuallyQueue.js +156 -357
- package/lib/weapp/FacebookUtils.js +23 -28
- package/lib/weapp/IndexedDBStorageController.js +18 -14
- package/lib/weapp/InstallationController.js +55 -121
- package/lib/weapp/LiveQueryClient.js +312 -446
- package/lib/weapp/LiveQuerySubscription.js +25 -28
- package/lib/weapp/LocalDatastore.js +254 -578
- package/lib/weapp/LocalDatastoreController.default.js +48 -227
- package/lib/weapp/LocalDatastoreController.js +11 -1
- package/lib/weapp/LocalDatastoreController.react-native.js +72 -164
- package/lib/weapp/LocalDatastoreUtils.js +4 -12
- package/lib/weapp/ObjectStateMutations.js +89 -95
- package/lib/weapp/OfflineQuery.js +106 -198
- package/lib/weapp/Parse.js +45 -60
- package/lib/weapp/ParseACL.js +242 -288
- package/lib/weapp/ParseCLP.js +372 -580
- package/lib/weapp/ParseConfig.js +115 -138
- package/lib/weapp/ParseError.js +85 -182
- package/lib/weapp/ParseFile.js +297 -446
- package/lib/weapp/ParseGeoPoint.js +121 -140
- package/lib/weapp/ParseHooks.js +12 -14
- package/lib/weapp/ParseInstallation.js +226 -354
- package/lib/weapp/ParseLiveQuery.js +74 -148
- package/lib/weapp/ParseObject.js +2017 -2622
- package/lib/weapp/ParseOp.js +343 -484
- package/lib/weapp/ParsePolygon.js +101 -120
- package/lib/weapp/ParseQuery.js +1722 -2068
- package/lib/weapp/ParseRelation.js +99 -118
- package/lib/weapp/ParseRole.js +88 -144
- package/lib/weapp/ParseSchema.js +372 -434
- package/lib/weapp/ParseSession.js +62 -110
- package/lib/weapp/ParseUser.js +942 -1270
- package/lib/weapp/Push.js +16 -44
- package/lib/weapp/RESTController.js +86 -125
- package/lib/weapp/SingleInstanceStateController.js +57 -86
- package/lib/weapp/Socket.weapp.js +50 -33
- package/lib/weapp/Storage.js +23 -28
- package/lib/weapp/StorageController.browser.js +16 -13
- package/lib/weapp/StorageController.default.js +15 -14
- package/lib/weapp/StorageController.js +14 -1
- package/lib/weapp/StorageController.react-native.js +31 -30
- package/lib/weapp/StorageController.weapp.js +19 -13
- package/lib/weapp/TaskQueue.js +37 -49
- package/lib/weapp/UniqueInstanceStateController.js +65 -86
- package/lib/weapp/WebSocketController.js +11 -4
- package/lib/weapp/Xhr.weapp.js +90 -78
- package/lib/weapp/arrayContainsObject.js +3 -3
- package/lib/weapp/canBeSerialized.js +10 -11
- package/lib/weapp/decode.js +11 -11
- package/lib/weapp/encode.js +11 -11
- package/lib/weapp/equals.js +9 -10
- package/lib/weapp/escape.js +2 -2
- package/lib/weapp/isRevocableSession.js +1 -1
- package/lib/weapp/parseDate.js +10 -10
- package/lib/weapp/promiseUtils.js +19 -19
- package/lib/weapp/unique.js +4 -4
- package/lib/weapp/unsavedChildren.js +20 -21
- package/lib/weapp/uuid.js +6 -8
- package/package.json +23 -30
|
@@ -1,92 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var _Array$from = require("@babel/runtime-corejs3/core-js-stable/array/from");
|
|
5
|
-
var _Symbol = require("@babel/runtime-corejs3/core-js-stable/symbol");
|
|
6
|
-
var _getIteratorMethod = require("@babel/runtime-corejs3/core-js/get-iterator-method");
|
|
7
|
-
var _Array$isArray2 = require("@babel/runtime-corejs3/core-js-stable/array/is-array");
|
|
3
|
+
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
|
8
4
|
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
_Object$defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
11
9
|
var _isArray = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/array/is-array"));
|
|
12
10
|
var _indexOf = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
|
|
13
11
|
var _filter = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/filter"));
|
|
14
12
|
var _slice = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/slice"));
|
|
15
13
|
var _isInteger = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/number/is-integer"));
|
|
16
|
-
var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
|
|
17
14
|
var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
|
|
18
15
|
var _forEach = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
|
|
19
16
|
var _keys = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/keys"));
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
var i = 0;
|
|
26
|
-
var F = function () {};
|
|
27
|
-
return {
|
|
28
|
-
s: F,
|
|
29
|
-
n: function () {
|
|
30
|
-
if (i >= o.length) return {
|
|
31
|
-
done: true
|
|
32
|
-
};
|
|
33
|
-
return {
|
|
34
|
-
done: false,
|
|
35
|
-
value: o[i++]
|
|
36
|
-
};
|
|
37
|
-
},
|
|
38
|
-
e: function (_e) {
|
|
39
|
-
throw _e;
|
|
40
|
-
},
|
|
41
|
-
f: F
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
45
|
-
}
|
|
46
|
-
var normalCompletion = true,
|
|
47
|
-
didErr = false,
|
|
48
|
-
err;
|
|
49
|
-
return {
|
|
50
|
-
s: function () {
|
|
51
|
-
it = it.call(o);
|
|
52
|
-
},
|
|
53
|
-
n: function () {
|
|
54
|
-
var step = it.next();
|
|
55
|
-
normalCompletion = step.done;
|
|
56
|
-
return step;
|
|
57
|
-
},
|
|
58
|
-
e: function (_e2) {
|
|
59
|
-
didErr = true;
|
|
60
|
-
err = _e2;
|
|
61
|
-
},
|
|
62
|
-
f: function () {
|
|
63
|
-
try {
|
|
64
|
-
if (!normalCompletion && it.return != null) it.return();
|
|
65
|
-
} finally {
|
|
66
|
-
if (didErr) throw err;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
72
|
-
var _context6;
|
|
73
|
-
if (!o) return;
|
|
74
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
75
|
-
var n = _sliceInstanceProperty2(_context6 = Object.prototype.toString.call(o)).call(_context6, 8, -1);
|
|
76
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
77
|
-
if (n === "Map" || n === "Set") return _Array$from(o);
|
|
78
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
79
|
-
}
|
|
80
|
-
function _arrayLikeToArray(arr, len) {
|
|
81
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
82
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
83
|
-
return arr2;
|
|
84
|
-
}
|
|
85
|
-
var equalObjects = require('./equals').default;
|
|
86
|
-
var decode = require('./decode').default;
|
|
87
|
-
var ParseError = require('./ParseError').default;
|
|
88
|
-
var ParsePolygon = require('./ParsePolygon').default;
|
|
89
|
-
var ParseGeoPoint = require('./ParseGeoPoint').default;
|
|
17
|
+
var _equals = _interopRequireDefault(require("./equals"));
|
|
18
|
+
var _decode = _interopRequireDefault(require("./decode"));
|
|
19
|
+
var _ParseError = _interopRequireDefault(require("./ParseError"));
|
|
20
|
+
var _ParsePolygon = _interopRequireDefault(require("./ParsePolygon"));
|
|
21
|
+
var _ParseGeoPoint = _interopRequireDefault(require("./ParseGeoPoint"));
|
|
90
22
|
/**
|
|
91
23
|
* contains -- Determines if an object is contained in a list with special handling for Parse pointers.
|
|
92
24
|
*
|
|
@@ -97,8 +29,8 @@ var ParseGeoPoint = require('./ParseGeoPoint').default;
|
|
|
97
29
|
*/
|
|
98
30
|
function contains(haystack, needle) {
|
|
99
31
|
if (needle && needle.__type && (needle.__type === 'Pointer' || needle.__type === 'Object')) {
|
|
100
|
-
for (
|
|
101
|
-
|
|
32
|
+
for (const i in haystack) {
|
|
33
|
+
const ptr = haystack[i];
|
|
102
34
|
if (typeof ptr === 'string' && ptr === needle.objectId) {
|
|
103
35
|
return true;
|
|
104
36
|
}
|
|
@@ -109,19 +41,10 @@ function contains(haystack, needle) {
|
|
|
109
41
|
return false;
|
|
110
42
|
}
|
|
111
43
|
if ((0, _isArray.default)(needle)) {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
116
|
-
var need = _step.value;
|
|
117
|
-
if (contains(haystack, need)) {
|
|
118
|
-
return true;
|
|
119
|
-
}
|
|
44
|
+
for (const need of needle) {
|
|
45
|
+
if (contains(haystack, need)) {
|
|
46
|
+
return true;
|
|
120
47
|
}
|
|
121
|
-
} catch (err) {
|
|
122
|
-
_iterator.e(err);
|
|
123
|
-
} finally {
|
|
124
|
-
_iterator.f();
|
|
125
48
|
}
|
|
126
49
|
}
|
|
127
50
|
return (0, _indexOf.default)(haystack).call(haystack, needle) > -1;
|
|
@@ -150,8 +73,8 @@ function matchesQuery(className, object, objects, query) {
|
|
|
150
73
|
if (object.className !== className) {
|
|
151
74
|
return false;
|
|
152
75
|
}
|
|
153
|
-
|
|
154
|
-
|
|
76
|
+
let obj = object;
|
|
77
|
+
let q = query;
|
|
155
78
|
if (object.toJSON) {
|
|
156
79
|
obj = object.toJSON();
|
|
157
80
|
}
|
|
@@ -159,7 +82,7 @@ function matchesQuery(className, object, objects, query) {
|
|
|
159
82
|
q = query.toJSON().where;
|
|
160
83
|
}
|
|
161
84
|
obj.className = className;
|
|
162
|
-
for (
|
|
85
|
+
for (const field in q) {
|
|
163
86
|
if (!matchesKeyConstraints(className, obj, objects, field, q[field])) {
|
|
164
87
|
return false;
|
|
165
88
|
}
|
|
@@ -168,7 +91,7 @@ function matchesQuery(className, object, objects, query) {
|
|
|
168
91
|
}
|
|
169
92
|
function equalObjectsGeneric(obj, compareTo, eqlFn) {
|
|
170
93
|
if ((0, _isArray.default)(obj)) {
|
|
171
|
-
for (
|
|
94
|
+
for (let i = 0; i < obj.length; i++) {
|
|
172
95
|
if (eqlFn(obj[i], compareTo)) {
|
|
173
96
|
return true;
|
|
174
97
|
}
|
|
@@ -192,20 +115,18 @@ function equalObjectsGeneric(obj, compareTo, eqlFn) {
|
|
|
192
115
|
* relative to now.
|
|
193
116
|
*
|
|
194
117
|
* @param {string} text The text to convert.
|
|
195
|
-
* @param {Date} [now
|
|
118
|
+
* @param {Date} [now] The date from which add or subtract. Default is now.
|
|
196
119
|
* @returns {RelativeTimeToDateResult}
|
|
197
120
|
*/
|
|
198
121
|
function relativeTimeToDate(text) {
|
|
199
|
-
|
|
122
|
+
let now = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new Date();
|
|
200
123
|
text = text.toLowerCase();
|
|
201
|
-
|
|
124
|
+
let parts = text.split(' ');
|
|
202
125
|
|
|
203
126
|
// Filter out whitespace
|
|
204
|
-
parts = (0, _filter.default)(parts).call(parts,
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
var future = parts[0] === 'in';
|
|
208
|
-
var past = parts[parts.length - 1] === 'ago';
|
|
127
|
+
parts = (0, _filter.default)(parts).call(parts, part => part !== '');
|
|
128
|
+
const future = parts[0] === 'in';
|
|
129
|
+
const past = parts[parts.length - 1] === 'ago';
|
|
209
130
|
if (!future && !past && text !== 'now') {
|
|
210
131
|
return {
|
|
211
132
|
status: 'error',
|
|
@@ -232,20 +153,17 @@ function relativeTimeToDate(text) {
|
|
|
232
153
|
info: 'Invalid time string. Dangling unit or number.'
|
|
233
154
|
};
|
|
234
155
|
}
|
|
235
|
-
|
|
156
|
+
const pairs = [];
|
|
236
157
|
while (parts.length) {
|
|
237
158
|
pairs.push([parts.shift(), parts.shift()]);
|
|
238
159
|
}
|
|
239
|
-
|
|
240
|
-
for (
|
|
241
|
-
|
|
242
|
-
num = _pairs$_i[0],
|
|
243
|
-
interval = _pairs$_i[1];
|
|
244
|
-
var val = Number(num);
|
|
160
|
+
let seconds = 0;
|
|
161
|
+
for (const [num, interval] of pairs) {
|
|
162
|
+
const val = Number(num);
|
|
245
163
|
if (!(0, _isInteger.default)(val)) {
|
|
246
164
|
return {
|
|
247
165
|
status: 'error',
|
|
248
|
-
info:
|
|
166
|
+
info: `'${num}' is not an integer.`
|
|
249
167
|
};
|
|
250
168
|
}
|
|
251
169
|
switch (interval) {
|
|
@@ -287,11 +205,11 @@ function relativeTimeToDate(text) {
|
|
|
287
205
|
default:
|
|
288
206
|
return {
|
|
289
207
|
status: 'error',
|
|
290
|
-
info:
|
|
208
|
+
info: `Invalid interval: '${interval}'`
|
|
291
209
|
};
|
|
292
210
|
}
|
|
293
211
|
}
|
|
294
|
-
|
|
212
|
+
const milliseconds = seconds * 1000;
|
|
295
213
|
if (future) {
|
|
296
214
|
return {
|
|
297
215
|
status: 'success',
|
|
@@ -330,12 +248,12 @@ function matchesKeyConstraints(className, object, objects, key, constraints) {
|
|
|
330
248
|
}
|
|
331
249
|
if ((0, _indexOf.default)(key).call(key, '.') >= 0) {
|
|
332
250
|
// Key references a subobject
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
251
|
+
const keyComponents = key.split('.');
|
|
252
|
+
const subObjectKey = keyComponents[0];
|
|
253
|
+
const keyRemainder = (0, _slice.default)(keyComponents).call(keyComponents, 1).join('.');
|
|
336
254
|
return matchesKeyConstraints(className, object[subObjectKey] || {}, objects, keyRemainder, constraints);
|
|
337
255
|
}
|
|
338
|
-
|
|
256
|
+
let i;
|
|
339
257
|
if (key === '$or') {
|
|
340
258
|
for (i = 0; i < constraints.length; i++) {
|
|
341
259
|
if (matchesQuery(className, object, objects, constraints[i])) {
|
|
@@ -365,43 +283,45 @@ function matchesKeyConstraints(className, object, objects, key, constraints) {
|
|
|
365
283
|
return false;
|
|
366
284
|
}
|
|
367
285
|
if (!/^[A-Za-z][0-9A-Za-z_]*$/.test(key)) {
|
|
368
|
-
throw new
|
|
286
|
+
throw new _ParseError.default(_ParseError.default.INVALID_KEY_NAME, `Invalid Key: ${key}`);
|
|
369
287
|
}
|
|
370
288
|
// Equality (or Array contains) cases
|
|
371
|
-
if (
|
|
289
|
+
if (typeof constraints !== 'object') {
|
|
372
290
|
if ((0, _isArray.default)(object[key])) {
|
|
373
291
|
var _context;
|
|
374
292
|
return (0, _indexOf.default)(_context = object[key]).call(_context, constraints) > -1;
|
|
375
293
|
}
|
|
376
294
|
return object[key] === constraints;
|
|
377
295
|
}
|
|
378
|
-
|
|
296
|
+
let compareTo;
|
|
379
297
|
if (constraints.__type) {
|
|
380
298
|
if (constraints.__type === 'Pointer') {
|
|
381
299
|
return equalObjectsGeneric(object[key], constraints, function (obj, ptr) {
|
|
382
300
|
return typeof obj !== 'undefined' && ptr.className === obj.className && ptr.objectId === obj.objectId;
|
|
383
301
|
});
|
|
384
302
|
}
|
|
385
|
-
return equalObjectsGeneric(
|
|
303
|
+
return equalObjectsGeneric((0, _decode.default)(object[key]), (0, _decode.default)(constraints), _equals.default);
|
|
386
304
|
}
|
|
387
305
|
// More complex cases
|
|
388
|
-
for (
|
|
389
|
-
var _compareTo, _compareTo2;
|
|
306
|
+
for (const condition in constraints) {
|
|
390
307
|
compareTo = constraints[condition];
|
|
391
|
-
if (
|
|
392
|
-
compareTo =
|
|
308
|
+
if (compareTo?.__type) {
|
|
309
|
+
compareTo = (0, _decode.default)(compareTo);
|
|
393
310
|
}
|
|
394
311
|
// is it a $relativeTime? convert to date
|
|
395
|
-
if (
|
|
396
|
-
|
|
312
|
+
if (compareTo?.['$relativeTime']) {
|
|
313
|
+
const parserResult = relativeTimeToDate(compareTo['$relativeTime']);
|
|
397
314
|
if (parserResult.status !== 'success') {
|
|
398
|
-
|
|
399
|
-
throw new ParseError(ParseError.INVALID_JSON, (0, _concat.default)(_context2 = "bad $relativeTime (".concat(key, ") value. ")).call(_context2, parserResult.info));
|
|
315
|
+
throw new _ParseError.default(_ParseError.default.INVALID_JSON, `bad $relativeTime (${key}) value. ${parserResult.info}`);
|
|
400
316
|
}
|
|
401
317
|
compareTo = parserResult.result;
|
|
402
318
|
}
|
|
403
319
|
// Compare Date Object or Date String
|
|
404
|
-
if (toString.call(compareTo) === '[object Date]' || typeof compareTo === 'string' &&
|
|
320
|
+
if (toString.call(compareTo) === '[object Date]' || typeof compareTo === 'string' &&
|
|
321
|
+
// @ts-ignore
|
|
322
|
+
new Date(compareTo) !== 'Invalid Date' &&
|
|
323
|
+
// @ts-ignore
|
|
324
|
+
!isNaN(new Date(compareTo))) {
|
|
405
325
|
object[key] = new Date(object[key].iso ? object[key].iso : object[key]);
|
|
406
326
|
}
|
|
407
327
|
switch (condition) {
|
|
@@ -426,7 +346,7 @@ function matchesKeyConstraints(className, object, objects, key, constraints) {
|
|
|
426
346
|
}
|
|
427
347
|
break;
|
|
428
348
|
case '$ne':
|
|
429
|
-
if (
|
|
349
|
+
if ((0, _equals.default)(object[key], compareTo)) {
|
|
430
350
|
return false;
|
|
431
351
|
}
|
|
432
352
|
break;
|
|
@@ -442,16 +362,16 @@ function matchesKeyConstraints(className, object, objects, key, constraints) {
|
|
|
442
362
|
break;
|
|
443
363
|
case '$all':
|
|
444
364
|
for (i = 0; i < compareTo.length; i++) {
|
|
445
|
-
var
|
|
446
|
-
if ((0, _indexOf.default)(
|
|
365
|
+
var _context2;
|
|
366
|
+
if ((0, _indexOf.default)(_context2 = object[key]).call(_context2, compareTo[i]) < 0) {
|
|
447
367
|
return false;
|
|
448
368
|
}
|
|
449
369
|
}
|
|
450
370
|
break;
|
|
451
371
|
case '$exists':
|
|
452
372
|
{
|
|
453
|
-
|
|
454
|
-
|
|
373
|
+
const propertyExists = typeof object[key] !== 'undefined';
|
|
374
|
+
const existenceIsRequired = constraints['$exists'];
|
|
455
375
|
if (typeof constraints['$exists'] !== 'boolean') {
|
|
456
376
|
// The SDK will never submit a non-boolean for $exists, but if someone
|
|
457
377
|
// tries to submit a non-boolean for $exits outside the SDKs, just ignore it.
|
|
@@ -464,13 +384,13 @@ function matchesKeyConstraints(className, object, objects, key, constraints) {
|
|
|
464
384
|
}
|
|
465
385
|
case '$regex':
|
|
466
386
|
{
|
|
467
|
-
if (
|
|
387
|
+
if (typeof compareTo === 'object') {
|
|
468
388
|
return compareTo.test(object[key]);
|
|
469
389
|
}
|
|
470
390
|
// JS doesn't support perl-style escaping
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
391
|
+
let expString = '';
|
|
392
|
+
let escapeEnd = -2;
|
|
393
|
+
let escapeStart = (0, _indexOf.default)(compareTo).call(compareTo, '\\Q');
|
|
474
394
|
while (escapeStart > -1) {
|
|
475
395
|
// Add the unescaped portion
|
|
476
396
|
expString += compareTo.substring(escapeEnd + 2, escapeStart);
|
|
@@ -481,10 +401,10 @@ function matchesKeyConstraints(className, object, objects, key, constraints) {
|
|
|
481
401
|
escapeStart = (0, _indexOf.default)(compareTo).call(compareTo, '\\Q', escapeEnd);
|
|
482
402
|
}
|
|
483
403
|
expString += compareTo.substring(Math.max(escapeStart, escapeEnd + 2));
|
|
484
|
-
|
|
404
|
+
let modifiers = constraints.$options || '';
|
|
485
405
|
modifiers = modifiers.replace('x', '').replace('s', '');
|
|
486
406
|
// Parse Server / Mongo support x and s modifiers but JS RegExp doesn't
|
|
487
|
-
|
|
407
|
+
const exp = new RegExp(expString, modifiers);
|
|
488
408
|
if (!exp.test(object[key])) {
|
|
489
409
|
return false;
|
|
490
410
|
}
|
|
@@ -495,8 +415,8 @@ function matchesKeyConstraints(className, object, objects, key, constraints) {
|
|
|
495
415
|
if (!compareTo || !object[key]) {
|
|
496
416
|
return false;
|
|
497
417
|
}
|
|
498
|
-
|
|
499
|
-
|
|
418
|
+
const distance = compareTo.radiansTo(object[key]);
|
|
419
|
+
const max = constraints.$maxDistance || Infinity;
|
|
500
420
|
return distance <= max;
|
|
501
421
|
}
|
|
502
422
|
case '$within':
|
|
@@ -504,8 +424,8 @@ function matchesKeyConstraints(className, object, objects, key, constraints) {
|
|
|
504
424
|
if (!compareTo || !object[key]) {
|
|
505
425
|
return false;
|
|
506
426
|
}
|
|
507
|
-
|
|
508
|
-
|
|
427
|
+
const southWest = compareTo.$box[0];
|
|
428
|
+
const northEast = compareTo.$box[1];
|
|
509
429
|
if (southWest.latitude > northEast.latitude || southWest.longitude > northEast.longitude) {
|
|
510
430
|
// Invalid box, crosses the date line
|
|
511
431
|
return false;
|
|
@@ -522,34 +442,34 @@ function matchesKeyConstraints(className, object, objects, key, constraints) {
|
|
|
522
442
|
break;
|
|
523
443
|
case '$select':
|
|
524
444
|
{
|
|
525
|
-
|
|
445
|
+
const subQueryObjects = (0, _filter.default)(objects).call(objects, (obj, index, arr) => {
|
|
526
446
|
return matchesQuery(compareTo.query.className, obj, arr, compareTo.query.where);
|
|
527
447
|
});
|
|
528
|
-
for (
|
|
529
|
-
|
|
530
|
-
return
|
|
448
|
+
for (let i = 0; i < subQueryObjects.length; i += 1) {
|
|
449
|
+
const subObject = transformObject(subQueryObjects[i]);
|
|
450
|
+
return (0, _equals.default)(object[key], subObject[compareTo.key]);
|
|
531
451
|
}
|
|
532
452
|
return false;
|
|
533
453
|
}
|
|
534
454
|
case '$dontSelect':
|
|
535
455
|
{
|
|
536
|
-
|
|
456
|
+
const subQueryObjects = (0, _filter.default)(objects).call(objects, (obj, index, arr) => {
|
|
537
457
|
return matchesQuery(compareTo.query.className, obj, arr, compareTo.query.where);
|
|
538
458
|
});
|
|
539
|
-
for (
|
|
540
|
-
|
|
541
|
-
return !
|
|
459
|
+
for (let i = 0; i < subQueryObjects.length; i += 1) {
|
|
460
|
+
const subObject = transformObject(subQueryObjects[i]);
|
|
461
|
+
return !(0, _equals.default)(object[key], subObject[compareTo.key]);
|
|
542
462
|
}
|
|
543
463
|
return false;
|
|
544
464
|
}
|
|
545
465
|
case '$inQuery':
|
|
546
466
|
{
|
|
547
|
-
|
|
467
|
+
const subQueryObjects = (0, _filter.default)(objects).call(objects, (obj, index, arr) => {
|
|
548
468
|
return matchesQuery(compareTo.className, obj, arr, compareTo.where);
|
|
549
469
|
});
|
|
550
|
-
for (
|
|
551
|
-
|
|
552
|
-
if (object[key].className ===
|
|
470
|
+
for (let i = 0; i < subQueryObjects.length; i += 1) {
|
|
471
|
+
const subObject = transformObject(subQueryObjects[i]);
|
|
472
|
+
if (object[key].className === subObject.className && object[key].objectId === subObject.objectId) {
|
|
553
473
|
return true;
|
|
554
474
|
}
|
|
555
475
|
}
|
|
@@ -557,12 +477,12 @@ function matchesKeyConstraints(className, object, objects, key, constraints) {
|
|
|
557
477
|
}
|
|
558
478
|
case '$notInQuery':
|
|
559
479
|
{
|
|
560
|
-
|
|
480
|
+
const subQueryObjects = (0, _filter.default)(objects).call(objects, (obj, index, arr) => {
|
|
561
481
|
return matchesQuery(compareTo.className, obj, arr, compareTo.where);
|
|
562
482
|
});
|
|
563
|
-
for (
|
|
564
|
-
|
|
565
|
-
if (object[key].className ===
|
|
483
|
+
for (let i = 0; i < subQueryObjects.length; i += 1) {
|
|
484
|
+
const subObject = transformObject(subQueryObjects[i]);
|
|
485
|
+
if (object[key].className === subObject.className && object[key].objectId === subObject.objectId) {
|
|
566
486
|
return false;
|
|
567
487
|
}
|
|
568
488
|
}
|
|
@@ -570,51 +490,38 @@ function matchesKeyConstraints(className, object, objects, key, constraints) {
|
|
|
570
490
|
}
|
|
571
491
|
case '$containedBy':
|
|
572
492
|
{
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
577
|
-
var value = _step2.value;
|
|
578
|
-
if (!contains(compareTo, value)) {
|
|
579
|
-
return false;
|
|
580
|
-
}
|
|
493
|
+
for (const value of object[key]) {
|
|
494
|
+
if (!contains(compareTo, value)) {
|
|
495
|
+
return false;
|
|
581
496
|
}
|
|
582
|
-
} catch (err) {
|
|
583
|
-
_iterator2.e(err);
|
|
584
|
-
} finally {
|
|
585
|
-
_iterator2.f();
|
|
586
497
|
}
|
|
587
498
|
return true;
|
|
588
499
|
}
|
|
589
500
|
case '$geoWithin':
|
|
590
501
|
{
|
|
591
502
|
if (compareTo.$polygon) {
|
|
592
|
-
var
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
});
|
|
596
|
-
var polygon = new ParsePolygon(points);
|
|
503
|
+
var _context3;
|
|
504
|
+
const points = (0, _map.default)(_context3 = compareTo.$polygon).call(_context3, geoPoint => [geoPoint.latitude, geoPoint.longitude]);
|
|
505
|
+
const polygon = new _ParsePolygon.default(points);
|
|
597
506
|
return polygon.containsPoint(object[key]);
|
|
598
507
|
}
|
|
599
508
|
if (compareTo.$centerSphere) {
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
maxDistance = _compareTo$$centerSph[1];
|
|
603
|
-
var centerPoint = new ParseGeoPoint({
|
|
509
|
+
const [WGS84Point, maxDistance] = compareTo.$centerSphere;
|
|
510
|
+
const centerPoint = new _ParseGeoPoint.default({
|
|
604
511
|
latitude: WGS84Point[1],
|
|
605
512
|
longitude: WGS84Point[0]
|
|
606
513
|
});
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
return
|
|
514
|
+
const point = new _ParseGeoPoint.default(object[key]);
|
|
515
|
+
const distance = point.radiansTo(centerPoint);
|
|
516
|
+
return distance <= maxDistance;
|
|
610
517
|
}
|
|
611
518
|
return false;
|
|
612
519
|
}
|
|
613
520
|
case '$geoIntersects':
|
|
614
521
|
{
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
return
|
|
522
|
+
const polygon = new _ParsePolygon.default(object[key].coordinates);
|
|
523
|
+
const point = new _ParseGeoPoint.default(compareTo.$point);
|
|
524
|
+
return polygon.containsPoint(point);
|
|
618
525
|
}
|
|
619
526
|
default:
|
|
620
527
|
return false;
|
|
@@ -622,28 +529,29 @@ function matchesKeyConstraints(className, object, objects, key, constraints) {
|
|
|
622
529
|
}
|
|
623
530
|
return true;
|
|
624
531
|
}
|
|
625
|
-
function validateQuery(query
|
|
626
|
-
var
|
|
627
|
-
|
|
532
|
+
function validateQuery(query) {
|
|
533
|
+
var _context4;
|
|
534
|
+
let q = query;
|
|
628
535
|
if (query.toJSON) {
|
|
629
536
|
q = query.toJSON().where;
|
|
630
537
|
}
|
|
631
|
-
|
|
632
|
-
(0, _forEach.default)(
|
|
538
|
+
const specialQuerykeys = ['$and', '$or', '$nor', '_rperm', '_wperm', '_perishable_token', '_email_verify_token', '_email_verify_token_expires_at', '_account_lockout_expires_at', '_failed_login_count'];
|
|
539
|
+
(0, _forEach.default)(_context4 = (0, _keys.default)(q)).call(_context4, key => {
|
|
633
540
|
if (q && q[key] && q[key].$regex) {
|
|
634
541
|
if (typeof q[key].$options === 'string') {
|
|
635
542
|
if (!q[key].$options.match(/^[imxs]+$/)) {
|
|
636
|
-
throw new
|
|
543
|
+
throw new _ParseError.default(_ParseError.default.INVALID_QUERY, `Bad $options value for query: ${q[key].$options}`);
|
|
637
544
|
}
|
|
638
545
|
}
|
|
639
546
|
}
|
|
640
547
|
if ((0, _indexOf.default)(specialQuerykeys).call(specialQuerykeys, key) < 0 && !key.match(/^[a-zA-Z][a-zA-Z0-9_\.]*$/)) {
|
|
641
|
-
throw new
|
|
548
|
+
throw new _ParseError.default(_ParseError.default.INVALID_KEY_NAME, `Invalid key name: ${key}`);
|
|
642
549
|
}
|
|
643
550
|
});
|
|
644
551
|
}
|
|
645
|
-
|
|
552
|
+
const OfflineQuery = {
|
|
646
553
|
matchesQuery: matchesQuery,
|
|
647
554
|
validateQuery: validateQuery
|
|
648
555
|
};
|
|
649
|
-
module.exports = OfflineQuery;
|
|
556
|
+
module.exports = OfflineQuery;
|
|
557
|
+
var _default = exports.default = OfflineQuery;
|