parse 5.3.0 → 6.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -5
- package/dist/parse.js +822 -877
- package/dist/parse.min.js +2 -2
- package/dist/parse.weapp.js +822 -875
- package/dist/parse.weapp.min.js +2 -2
- package/lib/browser/Cloud.js +12 -16
- package/lib/browser/CoreManager.js +3 -3
- package/lib/browser/FacebookUtils.js +1 -1
- package/lib/browser/LocalDatastoreController.react-native.js +1 -1
- package/lib/browser/OfflineQuery.js +5 -9
- package/lib/browser/Parse.js +1 -3
- package/lib/browser/ParseConfig.js +1 -1
- package/lib/browser/ParseFile.js +1 -2
- package/lib/browser/ParseInstallation.js +3 -1
- package/lib/browser/ParseObject.js +160 -163
- package/lib/browser/ParseQuery.js +22 -89
- package/lib/browser/ParseSession.js +4 -6
- package/lib/browser/ParseUser.js +44 -58
- package/lib/browser/Push.js +2 -2
- package/lib/browser/RESTController.js +2 -2
- package/lib/browser/Storage.js +1 -1
- package/lib/browser/StorageController.default.js +2 -2
- package/lib/browser/StorageController.weapp.js +1 -1
- package/lib/node/Cloud.js +12 -16
- package/lib/node/CoreManager.js +3 -3
- package/lib/node/FacebookUtils.js +1 -1
- package/lib/node/LocalDatastoreController.react-native.js +1 -1
- package/lib/node/OfflineQuery.js +5 -9
- package/lib/node/Parse.js +1 -1
- package/lib/node/ParseConfig.js +1 -1
- package/lib/node/ParseFile.js +1 -2
- package/lib/node/ParseInstallation.js +3 -1
- package/lib/node/ParseObject.js +155 -158
- package/lib/node/ParseQuery.js +22 -89
- package/lib/node/ParseSession.js +4 -6
- package/lib/node/ParseUser.js +44 -58
- package/lib/node/Push.js +2 -2
- package/lib/node/RESTController.js +2 -2
- package/lib/node/Storage.js +1 -1
- package/lib/node/StorageController.default.js +2 -2
- package/lib/node/StorageController.weapp.js +1 -1
- package/lib/react-native/Cloud.js +4 -16
- package/lib/react-native/CoreManager.js +3 -3
- package/lib/react-native/LocalDatastoreController.react-native.js +1 -1
- package/lib/react-native/OfflineQuery.js +5 -5
- package/lib/react-native/ParseConfig.js +1 -1
- package/lib/react-native/ParseFile.js +1 -1
- package/lib/react-native/ParseInstallation.js +14 -6
- package/lib/react-native/ParseObject.js +147 -163
- package/lib/react-native/ParseQuery.js +21 -89
- package/lib/react-native/ParseRole.js +8 -2
- package/lib/react-native/ParseSession.js +4 -6
- package/lib/react-native/ParseUser.js +28 -63
- package/lib/react-native/Push.js +2 -2
- package/lib/react-native/RESTController.js +11 -10
- package/lib/react-native/Storage.js +1 -1
- package/lib/react-native/StorageController.default.js +2 -2
- package/lib/react-native/StorageController.weapp.js +1 -1
- package/lib/weapp/Cloud.js +12 -16
- package/lib/weapp/CoreManager.js +3 -3
- package/lib/weapp/FacebookUtils.js +1 -1
- package/lib/weapp/LocalDatastoreController.react-native.js +1 -1
- package/lib/weapp/OfflineQuery.js +5 -9
- package/lib/weapp/Parse.js +1 -1
- package/lib/weapp/ParseConfig.js +1 -1
- package/lib/weapp/ParseFile.js +1 -2
- package/lib/weapp/ParseInstallation.js +3 -1
- package/lib/weapp/ParseObject.js +160 -163
- package/lib/weapp/ParseQuery.js +22 -89
- package/lib/weapp/ParseSession.js +4 -6
- package/lib/weapp/ParseUser.js +44 -58
- package/lib/weapp/Push.js +2 -2
- package/lib/weapp/RESTController.js +2 -2
- package/lib/weapp/Storage.js +1 -1
- package/lib/weapp/StorageController.default.js +2 -2
- package/lib/weapp/StorageController.weapp.js +1 -1
- package/package.json +30 -28
package/lib/browser/Cloud.js
CHANGED
|
@@ -16,6 +16,7 @@ var _decode = _interopRequireDefault(require("./decode"));
|
|
|
16
16
|
var _encode = _interopRequireDefault(require("./encode"));
|
|
17
17
|
var _ParseError = _interopRequireDefault(require("./ParseError"));
|
|
18
18
|
var _ParseQuery = _interopRequireDefault(require("./ParseQuery"));
|
|
19
|
+
var _ParseObject = _interopRequireDefault(require("./ParseObject"));
|
|
19
20
|
/**
|
|
20
21
|
* Contains functions for calling and declaring
|
|
21
22
|
* <a href="/docs/cloud_code_guide#functions">cloud functions</a>.
|
|
@@ -36,27 +37,22 @@ var _ParseQuery = _interopRequireDefault(require("./ParseQuery"));
|
|
|
36
37
|
* @param {string} name The function name.
|
|
37
38
|
* @param {object} data The parameters to send to the cloud function.
|
|
38
39
|
* @param {object} options
|
|
40
|
+
* Valid options are:<ul>
|
|
41
|
+
* <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
|
|
42
|
+
* be used for this request.
|
|
43
|
+
* <li>sessionToken: A valid session token, used for making a request on
|
|
44
|
+
* behalf of a specific user.
|
|
45
|
+
* <li>installationId: the installationId which made the request
|
|
46
|
+
* <li>context: A dictionary that is accessible in Cloud Code triggers.
|
|
47
|
+
* </ul>
|
|
39
48
|
* @returns {Promise} A promise that will be resolved with the result
|
|
40
49
|
* of the function.
|
|
41
50
|
*/
|
|
42
51
|
function run(name, data, options) {
|
|
43
|
-
options = options || {};
|
|
44
52
|
if (typeof name !== 'string' || name.length === 0) {
|
|
45
53
|
throw new TypeError('Cloud function name must be a string.');
|
|
46
54
|
}
|
|
47
|
-
const requestOptions =
|
|
48
|
-
if (options.useMasterKey) {
|
|
49
|
-
requestOptions.useMasterKey = options.useMasterKey;
|
|
50
|
-
}
|
|
51
|
-
if (options.sessionToken) {
|
|
52
|
-
requestOptions.sessionToken = options.sessionToken;
|
|
53
|
-
}
|
|
54
|
-
if (options.installationId) {
|
|
55
|
-
requestOptions.installationId = options.installationId;
|
|
56
|
-
}
|
|
57
|
-
if (options.context && typeof options.context === 'object') {
|
|
58
|
-
requestOptions.context = options.context;
|
|
59
|
-
}
|
|
55
|
+
const requestOptions = _ParseObject.default._getRequestOptions(options);
|
|
60
56
|
return _CoreManager.default.getCloudController().run(name, data, requestOptions);
|
|
61
57
|
}
|
|
62
58
|
|
|
@@ -113,11 +109,11 @@ const DefaultController = {
|
|
|
113
109
|
const payload = (0, _encode.default)(data, true);
|
|
114
110
|
const request = RESTController.request('POST', 'functions/' + name, payload, options);
|
|
115
111
|
return request.then(res => {
|
|
116
|
-
if (typeof res === 'object' && (0, _keys.default)(res).length > 0 && !
|
|
112
|
+
if (typeof res === 'object' && (0, _keys.default)(res).length > 0 && !Object.hasOwn(res, 'result')) {
|
|
117
113
|
throw new _ParseError.default(_ParseError.default.INVALID_JSON, 'The server returned an invalid response.');
|
|
118
114
|
}
|
|
119
115
|
const decoded = (0, _decode.default)(res);
|
|
120
|
-
if (decoded &&
|
|
116
|
+
if (decoded && Object.hasOwn(decoded, 'result')) {
|
|
121
117
|
return _promise.default.resolve(decoded.result);
|
|
122
118
|
}
|
|
123
119
|
return _promise.default.resolve(undefined);
|
|
@@ -19,7 +19,7 @@ const config = {
|
|
|
19
19
|
SERVER_AUTH_TOKEN: null,
|
|
20
20
|
LIVEQUERY_SERVER_URL: null,
|
|
21
21
|
ENCRYPTED_KEY: null,
|
|
22
|
-
VERSION: 'js' + "
|
|
22
|
+
VERSION: 'js' + "6.0.0-alpha.1",
|
|
23
23
|
APPLICATION_ID: null,
|
|
24
24
|
JAVASCRIPT_KEY: null,
|
|
25
25
|
MASTER_KEY: null,
|
|
@@ -40,7 +40,7 @@ function requireMethods(name, methods, controller) {
|
|
|
40
40
|
}
|
|
41
41
|
const CoreManager = {
|
|
42
42
|
get: function (key) {
|
|
43
|
-
if (
|
|
43
|
+
if (Object.hasOwn(config, key)) {
|
|
44
44
|
return config[key];
|
|
45
45
|
}
|
|
46
46
|
throw new Error('Configuration key not found: ' + key);
|
|
@@ -49,7 +49,7 @@ const CoreManager = {
|
|
|
49
49
|
config[key] = value;
|
|
50
50
|
},
|
|
51
51
|
setIfNeeded: function (key, value) {
|
|
52
|
-
if (!
|
|
52
|
+
if (!Object.hasOwn(config, key)) {
|
|
53
53
|
config[key] = value;
|
|
54
54
|
}
|
|
55
55
|
return config[key];
|
|
@@ -103,7 +103,7 @@ const FacebookUtils = {
|
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
if (initOptions.status && typeof console !== 'undefined') {
|
|
106
|
-
const warn = console.warn || console.log || function () {};
|
|
106
|
+
const warn = console.warn || console.log || function () {};
|
|
107
107
|
warn.call(console, 'The "status" flag passed into' + ' FB.init, when set to true, can interfere with Parse Facebook' + ' integration, so it has been suppressed. Please call' + ' FB.getLoginStatus() explicitly if you require this behavior.');
|
|
108
108
|
}
|
|
109
109
|
initOptions.status = false;
|
|
@@ -317,11 +317,7 @@ function matchesKeyConstraints(className, object, objects, key, constraints) {
|
|
|
317
317
|
compareTo = parserResult.result;
|
|
318
318
|
}
|
|
319
319
|
// Compare Date Object or Date 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))) {
|
|
320
|
+
if (toString.call(compareTo) === '[object Date]' || typeof compareTo === 'string' && new Date(compareTo).toString() !== 'Invalid Date') {
|
|
325
321
|
object[key] = new Date(object[key].iso ? object[key].iso : object[key]);
|
|
326
322
|
}
|
|
327
323
|
switch (condition) {
|
|
@@ -442,7 +438,7 @@ function matchesKeyConstraints(className, object, objects, key, constraints) {
|
|
|
442
438
|
break;
|
|
443
439
|
case '$select':
|
|
444
440
|
{
|
|
445
|
-
const subQueryObjects = (0, _filter.default)(objects).call(objects, (obj,
|
|
441
|
+
const subQueryObjects = (0, _filter.default)(objects).call(objects, (obj, _index, arr) => {
|
|
446
442
|
return matchesQuery(compareTo.query.className, obj, arr, compareTo.query.where);
|
|
447
443
|
});
|
|
448
444
|
for (let i = 0; i < subQueryObjects.length; i += 1) {
|
|
@@ -453,7 +449,7 @@ function matchesKeyConstraints(className, object, objects, key, constraints) {
|
|
|
453
449
|
}
|
|
454
450
|
case '$dontSelect':
|
|
455
451
|
{
|
|
456
|
-
const subQueryObjects = (0, _filter.default)(objects).call(objects, (obj,
|
|
452
|
+
const subQueryObjects = (0, _filter.default)(objects).call(objects, (obj, _index, arr) => {
|
|
457
453
|
return matchesQuery(compareTo.query.className, obj, arr, compareTo.query.where);
|
|
458
454
|
});
|
|
459
455
|
for (let i = 0; i < subQueryObjects.length; i += 1) {
|
|
@@ -464,7 +460,7 @@ function matchesKeyConstraints(className, object, objects, key, constraints) {
|
|
|
464
460
|
}
|
|
465
461
|
case '$inQuery':
|
|
466
462
|
{
|
|
467
|
-
const subQueryObjects = (0, _filter.default)(objects).call(objects, (obj,
|
|
463
|
+
const subQueryObjects = (0, _filter.default)(objects).call(objects, (obj, _index, arr) => {
|
|
468
464
|
return matchesQuery(compareTo.className, obj, arr, compareTo.where);
|
|
469
465
|
});
|
|
470
466
|
for (let i = 0; i < subQueryObjects.length; i += 1) {
|
|
@@ -477,7 +473,7 @@ function matchesKeyConstraints(className, object, objects, key, constraints) {
|
|
|
477
473
|
}
|
|
478
474
|
case '$notInQuery':
|
|
479
475
|
{
|
|
480
|
-
const subQueryObjects = (0, _filter.default)(objects).call(objects, (obj,
|
|
476
|
+
const subQueryObjects = (0, _filter.default)(objects).call(objects, (obj, _index, arr) => {
|
|
481
477
|
return matchesQuery(compareTo.className, obj, arr, compareTo.where);
|
|
482
478
|
});
|
|
483
479
|
for (let i = 0; i < subQueryObjects.length; i += 1) {
|
package/lib/browser/Parse.js
CHANGED
|
@@ -137,9 +137,7 @@ const Parse = {
|
|
|
137
137
|
*/
|
|
138
138
|
initialize(applicationId, javaScriptKey) {
|
|
139
139
|
if ("browser" === 'browser' && _CoreManager.default.get('IS_NODE') && !process.env.SERVER_RENDERING) {
|
|
140
|
-
/* eslint-disable no-console */
|
|
141
140
|
console.log("It looks like you're using the browser version of the SDK in a " + "node.js environment. You should require('parse/node') instead.");
|
|
142
|
-
/* eslint-enable no-console */
|
|
143
141
|
}
|
|
144
142
|
Parse._initialize(applicationId, javaScriptKey);
|
|
145
143
|
},
|
|
@@ -373,7 +371,7 @@ const Parse = {
|
|
|
373
371
|
*/
|
|
374
372
|
dumpLocalDatastore() {
|
|
375
373
|
if (!this.LocalDatastore.isEnabled) {
|
|
376
|
-
console.log('Parse.enableLocalDatastore() must be called first');
|
|
374
|
+
console.log('Parse.enableLocalDatastore() must be called first');
|
|
377
375
|
return _promise.default.resolve({});
|
|
378
376
|
} else {
|
|
379
377
|
return Parse.LocalDatastore._getAllContents();
|
package/lib/browser/ParseFile.js
CHANGED
|
@@ -299,7 +299,7 @@ class ParseFile {
|
|
|
299
299
|
const destroyOptions = {
|
|
300
300
|
useMasterKey: true
|
|
301
301
|
};
|
|
302
|
-
if (
|
|
302
|
+
if (Object.hasOwn(options, 'useMasterKey')) {
|
|
303
303
|
destroyOptions.useMasterKey = !!options.useMasterKey;
|
|
304
304
|
}
|
|
305
305
|
const controller = _CoreManager.default.getFileController();
|
|
@@ -403,7 +403,6 @@ const DefaultController = {
|
|
|
403
403
|
throw new Error('saveFile can only be used with File-type sources.');
|
|
404
404
|
}
|
|
405
405
|
const base64Data = await new _promise.default((res, rej) => {
|
|
406
|
-
// eslint-disable-next-line no-undef
|
|
407
406
|
const reader = new FileReader();
|
|
408
407
|
reader.onload = () => res(reader.result);
|
|
409
408
|
reader.onerror = error => rej(error);
|
|
@@ -37,7 +37,9 @@ class ParseInstallation extends _ParseObject.default {
|
|
|
37
37
|
constructor(attributes) {
|
|
38
38
|
super('_Installation');
|
|
39
39
|
if (attributes && typeof attributes === 'object') {
|
|
40
|
-
|
|
40
|
+
try {
|
|
41
|
+
this.set(attributes || {});
|
|
42
|
+
} catch (_) {
|
|
41
43
|
throw new Error("Can't create an invalid Installation");
|
|
42
44
|
}
|
|
43
45
|
}
|