parse 5.2.0-alpha.1 → 5.2.0-alpha.3
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 +10519 -15246
- package/dist/parse.min.js +2 -2
- package/dist/parse.weapp.js +10499 -15371
- 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 +23 -41
- 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 -485
- package/lib/browser/LiveQuerySubscription.js +25 -28
- package/lib/browser/LocalDatastore.js +258 -624
- package/lib/browser/LocalDatastoreController.default.js +42 -226
- package/lib/browser/LocalDatastoreController.js +11 -1
- package/lib/browser/LocalDatastoreController.react-native.js +66 -160
- package/lib/browser/LocalDatastoreUtils.js +4 -7
- package/lib/browser/ObjectStateMutations.js +54 -96
- package/lib/browser/OfflineQuery.js +106 -198
- package/lib/browser/Parse.js +44 -60
- package/lib/browser/ParseACL.js +242 -288
- package/lib/browser/ParseCLP.js +372 -572
- package/lib/browser/ParseConfig.js +115 -138
- package/lib/browser/ParseError.js +85 -182
- package/lib/browser/ParseFile.js +294 -438
- package/lib/browser/ParseGeoPoint.js +121 -146
- package/lib/browser/ParseHooks.js +23 -25
- package/lib/browser/ParseInstallation.js +225 -367
- package/lib/browser/ParseLiveQuery.js +74 -148
- package/lib/browser/ParseObject.js +2014 -2621
- package/lib/browser/ParseOp.js +343 -484
- package/lib/browser/ParsePolygon.js +101 -120
- package/lib/browser/ParseQuery.js +1708 -2052
- package/lib/browser/ParseRelation.js +99 -118
- package/lib/browser/ParseRole.js +88 -140
- package/lib/browser/ParseSchema.js +372 -434
- package/lib/browser/ParseSession.js +62 -110
- package/lib/browser/ParseUser.js +941 -1284
- package/lib/browser/Push.js +15 -38
- 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 +31 -43
- 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 +5 -9
- package/lib/node/AnonymousUtils.js +10 -15
- package/lib/node/Cloud.js +11 -11
- 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 +20 -39
- package/lib/node/FacebookUtils.js +4 -8
- package/lib/node/IndexedDBStorageController.js +14 -10
- package/lib/node/InstallationController.js +12 -13
- package/lib/node/LiveQueryClient.js +23 -21
- package/lib/node/LiveQuerySubscription.js +6 -7
- package/lib/node/LocalDatastore.js +23 -23
- package/lib/node/LocalDatastoreController.default.js +11 -12
- package/lib/node/LocalDatastoreController.js +14 -1
- package/lib/node/LocalDatastoreController.react-native.js +25 -21
- package/lib/node/LocalDatastoreUtils.js +4 -7
- package/lib/node/ObjectStateMutations.js +12 -22
- package/lib/node/OfflineQuery.js +37 -23
- package/lib/node/Parse.js +36 -50
- package/lib/node/ParseACL.js +21 -30
- package/lib/node/ParseCLP.js +38 -40
- package/lib/node/ParseConfig.js +10 -17
- package/lib/node/ParseError.js +460 -461
- package/lib/node/ParseFile.js +27 -47
- package/lib/node/ParseGeoPoint.js +16 -17
- package/lib/node/ParseHooks.js +16 -18
- package/lib/node/ParseInstallation.js +10 -11
- package/lib/node/ParseLiveQuery.js +9 -14
- package/lib/node/ParseObject.js +142 -173
- package/lib/node/ParseOp.js +35 -47
- package/lib/node/ParsePolygon.js +14 -20
- package/lib/node/ParseQuery.js +100 -123
- package/lib/node/ParseRelation.js +10 -19
- package/lib/node/ParseRole.js +10 -11
- package/lib/node/ParseSchema.js +29 -42
- package/lib/node/ParseSession.js +10 -11
- package/lib/node/ParseUser.js +76 -87
- package/lib/node/Push.js +7 -12
- package/lib/node/RESTController.js +24 -36
- package/lib/node/SingleInstanceStateController.js +41 -69
- package/lib/node/Socket.weapp.js +23 -2
- package/lib/node/Storage.js +14 -19
- 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 +20 -20
- package/lib/node/StorageController.weapp.js +14 -8
- package/lib/node/TaskQueue.js +2 -3
- package/lib/node/UniqueInstanceStateController.js +43 -63
- package/lib/node/WebSocketController.js +15 -2
- package/lib/node/Xhr.weapp.js +11 -2
- package/lib/node/arrayContainsObject.js +4 -4
- package/lib/node/canBeSerialized.js +5 -5
- package/lib/node/decode.js +4 -4
- package/lib/node/encode.js +5 -5
- package/lib/node/equals.js +4 -4
- 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 +5 -5
- package/lib/node/unsavedChildren.js +5 -5
- 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/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 +8 -7
- package/lib/react-native/LiveQuerySubscription.js +2 -4
- package/lib/react-native/LocalDatastore.js +3 -3
- package/lib/react-native/LocalDatastoreController.default.js +1 -2
- package/lib/react-native/LocalDatastoreController.js +11 -1
- package/lib/react-native/LocalDatastoreController.react-native.js +11 -12
- package/lib/react-native/LocalDatastoreUtils.js +3 -6
- 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 +2 -4
- package/lib/react-native/ParseConfig.js +4 -6
- package/lib/react-native/ParseError.js +13 -31
- package/lib/react-native/ParseFile.js +3 -4
- 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 +77 -87
- package/lib/react-native/ParseOp.js +41 -79
- package/lib/react-native/ParsePolygon.js +2 -4
- package/lib/react-native/ParseQuery.js +43 -45
- package/lib/react-native/ParseRelation.js +2 -4
- package/lib/react-native/ParseRole.js +13 -30
- package/lib/react-native/ParseSchema.js +3 -5
- package/lib/react-native/ParseSession.js +12 -29
- package/lib/react-native/ParseUser.js +24 -49
- 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 +2 -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 +23 -41
- 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 -485
- package/lib/weapp/LiveQuerySubscription.js +25 -28
- package/lib/weapp/LocalDatastore.js +258 -624
- package/lib/weapp/LocalDatastoreController.default.js +42 -226
- package/lib/weapp/LocalDatastoreController.js +11 -1
- package/lib/weapp/LocalDatastoreController.react-native.js +66 -160
- package/lib/weapp/LocalDatastoreUtils.js +4 -7
- package/lib/weapp/ObjectStateMutations.js +54 -96
- package/lib/weapp/OfflineQuery.js +106 -198
- package/lib/weapp/Parse.js +44 -59
- package/lib/weapp/ParseACL.js +242 -288
- package/lib/weapp/ParseCLP.js +372 -572
- package/lib/weapp/ParseConfig.js +115 -138
- package/lib/weapp/ParseError.js +85 -182
- package/lib/weapp/ParseFile.js +295 -440
- package/lib/weapp/ParseGeoPoint.js +121 -146
- package/lib/weapp/ParseHooks.js +23 -25
- package/lib/weapp/ParseInstallation.js +225 -367
- package/lib/weapp/ParseLiveQuery.js +74 -148
- package/lib/weapp/ParseObject.js +2014 -2621
- package/lib/weapp/ParseOp.js +343 -484
- package/lib/weapp/ParsePolygon.js +101 -120
- package/lib/weapp/ParseQuery.js +1708 -2052
- package/lib/weapp/ParseRelation.js +99 -118
- package/lib/weapp/ParseRole.js +88 -140
- package/lib/weapp/ParseSchema.js +372 -434
- package/lib/weapp/ParseSession.js +62 -110
- package/lib/weapp/ParseUser.js +941 -1284
- package/lib/weapp/Push.js +15 -38
- 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 +31 -43
- 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 +24 -30
|
@@ -7,15 +7,8 @@ _Object$defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports.default = void 0;
|
|
9
9
|
var _isArray = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/array/is-array"));
|
|
10
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/classCallCheck"));
|
|
11
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/createClass"));
|
|
12
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
|
|
13
11
|
var _CoreManager = _interopRequireDefault(require("./CoreManager"));
|
|
14
|
-
/**
|
|
15
|
-
* @flow
|
|
16
|
-
*/
|
|
17
|
-
/*:: import type ParseObject from './ParseObject';*/
|
|
18
|
-
/*:: import type ParseQuery from './ParseQuery';*/
|
|
19
12
|
/**
|
|
20
13
|
* Creates a new Relation for the given parent object and key. This
|
|
21
14
|
* constructor should rarely be used directly, but rather created by
|
|
@@ -29,13 +22,12 @@ var _CoreManager = _interopRequireDefault(require("./CoreManager"));
|
|
|
29
22
|
*
|
|
30
23
|
* @alias Parse.Relation
|
|
31
24
|
*/
|
|
32
|
-
|
|
25
|
+
class ParseRelation {
|
|
33
26
|
/**
|
|
34
27
|
* @param {Parse.Object} parent The parent of this relation.
|
|
35
28
|
* @param {string} key The key for this relation on the parent.
|
|
36
29
|
*/
|
|
37
|
-
|
|
38
|
-
(0, _classCallCheck2.default)(this, ParseRelation);
|
|
30
|
+
constructor(parent, key) {
|
|
39
31
|
(0, _defineProperty2.default)(this, "parent", void 0);
|
|
40
32
|
(0, _defineProperty2.default)(this, "key", void 0);
|
|
41
33
|
(0, _defineProperty2.default)(this, "targetClassName", void 0);
|
|
@@ -47,125 +39,114 @@ var ParseRelation = /*#__PURE__*/function () {
|
|
|
47
39
|
/*
|
|
48
40
|
* Makes sure that this relation has the right parent and key.
|
|
49
41
|
*/
|
|
50
|
-
(
|
|
51
|
-
key
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
42
|
+
_ensureParentAndKey(parent, key) {
|
|
43
|
+
this.key = this.key || key;
|
|
44
|
+
if (this.key !== key) {
|
|
45
|
+
throw new Error('Internal Error. Relation retrieved from two different keys.');
|
|
46
|
+
}
|
|
47
|
+
if (this.parent) {
|
|
48
|
+
if (this.parent.className !== parent.className) {
|
|
49
|
+
throw new Error('Internal Error. Relation retrieved from two different Objects.');
|
|
56
50
|
}
|
|
57
|
-
if (this.parent) {
|
|
58
|
-
if (this.parent.
|
|
51
|
+
if (this.parent.id) {
|
|
52
|
+
if (this.parent.id !== parent.id) {
|
|
59
53
|
throw new Error('Internal Error. Relation retrieved from two different Objects.');
|
|
60
54
|
}
|
|
61
|
-
|
|
62
|
-
if (this.parent.id !== parent.id) {
|
|
63
|
-
throw new Error('Internal Error. Relation retrieved from two different Objects.');
|
|
64
|
-
}
|
|
65
|
-
} else if (parent.id) {
|
|
66
|
-
this.parent = parent;
|
|
67
|
-
}
|
|
68
|
-
} else {
|
|
55
|
+
} else if (parent.id) {
|
|
69
56
|
this.parent = parent;
|
|
70
57
|
}
|
|
58
|
+
} else {
|
|
59
|
+
this.parent = parent;
|
|
71
60
|
}
|
|
61
|
+
}
|
|
72
62
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
if (objects.length === 0) {
|
|
93
|
-
return parent;
|
|
94
|
-
}
|
|
95
|
-
parent.set(this.key, change);
|
|
96
|
-
this.targetClassName = change._targetClassName;
|
|
63
|
+
/**
|
|
64
|
+
* Adds a Parse.Object or an array of Parse.Objects to the relation.
|
|
65
|
+
*
|
|
66
|
+
* @param {(Parse.Object|Array)} objects The item or items to add.
|
|
67
|
+
* @returns {Parse.Object} The parent of the relation.
|
|
68
|
+
*/
|
|
69
|
+
add(objects) {
|
|
70
|
+
if (!(0, _isArray.default)(objects)) {
|
|
71
|
+
objects = [objects];
|
|
72
|
+
}
|
|
73
|
+
const {
|
|
74
|
+
RelationOp
|
|
75
|
+
} = _CoreManager.default.getParseOp();
|
|
76
|
+
const change = new RelationOp(objects, []);
|
|
77
|
+
const parent = this.parent;
|
|
78
|
+
if (!parent) {
|
|
79
|
+
throw new Error('Cannot add to a Relation without a parent');
|
|
80
|
+
}
|
|
81
|
+
if (objects.length === 0) {
|
|
97
82
|
return parent;
|
|
98
83
|
}
|
|
84
|
+
parent.set(this.key, change);
|
|
85
|
+
this.targetClassName = change._targetClassName;
|
|
86
|
+
return parent;
|
|
87
|
+
}
|
|
99
88
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
if (!(0, _isArray.default)(objects)) {
|
|
109
|
-
objects = [objects];
|
|
110
|
-
}
|
|
111
|
-
var _CoreManager$getParse2 = _CoreManager.default.getParseOp(),
|
|
112
|
-
RelationOp = _CoreManager$getParse2.RelationOp;
|
|
113
|
-
var change = new RelationOp([], objects);
|
|
114
|
-
if (!this.parent) {
|
|
115
|
-
throw new Error('Cannot remove from a Relation without a parent');
|
|
116
|
-
}
|
|
117
|
-
if (objects.length === 0) {
|
|
118
|
-
return;
|
|
119
|
-
}
|
|
120
|
-
this.parent.set(this.key, change);
|
|
121
|
-
this.targetClassName = change._targetClassName;
|
|
89
|
+
/**
|
|
90
|
+
* Removes a Parse.Object or an array of Parse.Objects from this relation.
|
|
91
|
+
*
|
|
92
|
+
* @param {(Parse.Object|Array)} objects The item or items to remove.
|
|
93
|
+
*/
|
|
94
|
+
remove(objects) {
|
|
95
|
+
if (!(0, _isArray.default)(objects)) {
|
|
96
|
+
objects = [objects];
|
|
122
97
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
return {
|
|
133
|
-
__type: 'Relation',
|
|
134
|
-
className: this.targetClassName
|
|
135
|
-
};
|
|
98
|
+
const {
|
|
99
|
+
RelationOp
|
|
100
|
+
} = _CoreManager.default.getParseOp();
|
|
101
|
+
const change = new RelationOp([], objects);
|
|
102
|
+
if (!this.parent) {
|
|
103
|
+
throw new Error('Cannot remove from a Relation without a parent');
|
|
104
|
+
}
|
|
105
|
+
if (objects.length === 0) {
|
|
106
|
+
return;
|
|
136
107
|
}
|
|
108
|
+
this.parent.set(this.key, change);
|
|
109
|
+
this.targetClassName = change._targetClassName;
|
|
110
|
+
}
|
|
137
111
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
query
|
|
165
|
-
|
|
112
|
+
/**
|
|
113
|
+
* Returns a JSON version of the object suitable for saving to disk.
|
|
114
|
+
*
|
|
115
|
+
* @returns {object} JSON representation of Relation
|
|
116
|
+
*/
|
|
117
|
+
toJSON() {
|
|
118
|
+
return {
|
|
119
|
+
__type: 'Relation',
|
|
120
|
+
className: this.targetClassName
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Returns a Parse.Query that is limited to objects in this
|
|
126
|
+
* relation.
|
|
127
|
+
*
|
|
128
|
+
* @returns {Parse.Query} Relation Query
|
|
129
|
+
*/
|
|
130
|
+
query() {
|
|
131
|
+
let query;
|
|
132
|
+
const parent = this.parent;
|
|
133
|
+
if (!parent) {
|
|
134
|
+
throw new Error('Cannot construct a query for a Relation without a parent');
|
|
135
|
+
}
|
|
136
|
+
const ParseQuery = _CoreManager.default.getParseQuery();
|
|
137
|
+
if (!this.targetClassName) {
|
|
138
|
+
query = new ParseQuery(parent.className);
|
|
139
|
+
query._extraOptions.redirectClassNameForKey = this.key;
|
|
140
|
+
} else {
|
|
141
|
+
query = new ParseQuery(this.targetClassName);
|
|
166
142
|
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
143
|
+
query._addCondition('$relatedTo', 'object', {
|
|
144
|
+
__type: 'Pointer',
|
|
145
|
+
className: parent.className,
|
|
146
|
+
objectId: parent.id
|
|
147
|
+
});
|
|
148
|
+
query._addCondition('$relatedTo', 'key', this.key);
|
|
149
|
+
return query;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
var _default = exports.default = ParseRelation;
|
package/lib/browser/ParseRole.js
CHANGED
|
@@ -1,47 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _Reflect$construct = require("@babel/runtime-corejs3/core-js-stable/reflect/construct");
|
|
4
3
|
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
|
5
4
|
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
6
5
|
_Object$defineProperty(exports, "__esModule", {
|
|
7
6
|
value: true
|
|
8
7
|
});
|
|
9
8
|
exports.default = void 0;
|
|
10
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/classCallCheck"));
|
|
11
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/createClass"));
|
|
12
|
-
var _get2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/get"));
|
|
13
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/inherits"));
|
|
14
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/possibleConstructorReturn"));
|
|
15
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/getPrototypeOf"));
|
|
16
9
|
var _CoreManager = _interopRequireDefault(require("./CoreManager"));
|
|
17
10
|
var _ParseACL = _interopRequireDefault(require("./ParseACL"));
|
|
18
11
|
var _ParseError = _interopRequireDefault(require("./ParseError"));
|
|
19
|
-
var
|
|
20
|
-
function _createSuper(Derived) {
|
|
21
|
-
var hasNativeReflectConstruct = _isNativeReflectConstruct();
|
|
22
|
-
return function () {
|
|
23
|
-
var Super = (0, _getPrototypeOf2.default)(Derived),
|
|
24
|
-
result;
|
|
25
|
-
if (hasNativeReflectConstruct) {
|
|
26
|
-
var NewTarget = (0, _getPrototypeOf2.default)(this).constructor;
|
|
27
|
-
result = _Reflect$construct(Super, arguments, NewTarget);
|
|
28
|
-
} else {
|
|
29
|
-
result = Super.apply(this, arguments);
|
|
30
|
-
}
|
|
31
|
-
return (0, _possibleConstructorReturn2.default)(this, result);
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
function _isNativeReflectConstruct() {
|
|
35
|
-
if (typeof Reflect === "undefined" || !_Reflect$construct) return false;
|
|
36
|
-
if (_Reflect$construct.sham) return false;
|
|
37
|
-
if (typeof Proxy === "function") return true;
|
|
38
|
-
try {
|
|
39
|
-
Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {}));
|
|
40
|
-
return true;
|
|
41
|
-
} catch (e) {
|
|
42
|
-
return false;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
12
|
+
var _ParseObject = _interopRequireDefault(require("./ParseObject"));
|
|
45
13
|
/**
|
|
46
14
|
* Represents a Role on the Parse server. Roles represent groupings of
|
|
47
15
|
* Users for the purposes of granting permissions (e.g. specifying an ACL
|
|
@@ -55,24 +23,19 @@ function _isNativeReflectConstruct() {
|
|
|
55
23
|
* @alias Parse.Role
|
|
56
24
|
* @augments Parse.Object
|
|
57
25
|
*/
|
|
58
|
-
|
|
59
|
-
(0, _inherits2.default)(ParseRole, _ParseObject);
|
|
60
|
-
var _super = _createSuper(ParseRole);
|
|
26
|
+
class ParseRole extends _ParseObject.default {
|
|
61
27
|
/**
|
|
62
28
|
* @param {string} name The name of the Role to create.
|
|
63
29
|
* @param {Parse.ACL} acl The ACL for this role. Roles must have an ACL.
|
|
64
30
|
* A Parse.Role is a local representation of a role persisted to the Parse
|
|
65
31
|
* cloud.
|
|
66
32
|
*/
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
(0, _classCallCheck2.default)(this, ParseRole);
|
|
70
|
-
_this = _super.call(this, '_Role');
|
|
33
|
+
constructor(name, acl) {
|
|
34
|
+
super('_Role');
|
|
71
35
|
if (typeof name === 'string' && acl instanceof _ParseACL.default) {
|
|
72
|
-
|
|
73
|
-
|
|
36
|
+
this.setName(name);
|
|
37
|
+
this.setACL(acl);
|
|
74
38
|
}
|
|
75
|
-
return _this;
|
|
76
39
|
}
|
|
77
40
|
|
|
78
41
|
/**
|
|
@@ -80,110 +43,95 @@ var ParseRole = /*#__PURE__*/function (_ParseObject) {
|
|
|
80
43
|
*
|
|
81
44
|
* @returns {string} the name of the role.
|
|
82
45
|
*/
|
|
83
|
-
(
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
if (name == null || typeof name === 'string') {
|
|
88
|
-
return name;
|
|
89
|
-
}
|
|
90
|
-
return '';
|
|
46
|
+
getName() {
|
|
47
|
+
const name = this.get('name');
|
|
48
|
+
if (name == null || typeof name === 'string') {
|
|
49
|
+
return name;
|
|
91
50
|
}
|
|
51
|
+
return '';
|
|
52
|
+
}
|
|
92
53
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
return this.set('name', name, options);
|
|
115
|
-
}
|
|
54
|
+
/**
|
|
55
|
+
* Sets the name for a role. This value must be set before the role has
|
|
56
|
+
* been saved to the server, and cannot be set once the role has been
|
|
57
|
+
* saved.
|
|
58
|
+
*
|
|
59
|
+
* <p>
|
|
60
|
+
* A role's name can only contain alphanumeric characters, _, -, and
|
|
61
|
+
* spaces.
|
|
62
|
+
* </p>
|
|
63
|
+
*
|
|
64
|
+
* <p>This is equivalent to calling role.set("name", name)</p>
|
|
65
|
+
*
|
|
66
|
+
* @param {string} name The name of the role.
|
|
67
|
+
* @param {object} options Standard options object with success and error
|
|
68
|
+
* callbacks.
|
|
69
|
+
* @returns {(ParseObject|boolean)} true if the set succeeded.
|
|
70
|
+
*/
|
|
71
|
+
setName(name, options) {
|
|
72
|
+
this._validateName(name);
|
|
73
|
+
return this.set('name', name, options);
|
|
74
|
+
}
|
|
116
75
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
return this.relation('users');
|
|
132
|
-
}
|
|
76
|
+
/**
|
|
77
|
+
* Gets the Parse.Relation for the Parse.Users that are direct
|
|
78
|
+
* children of this role. These users are granted any privileges that this
|
|
79
|
+
* role has been granted (e.g. read or write access through ACLs). You can
|
|
80
|
+
* add or remove users from the role through this relation.
|
|
81
|
+
*
|
|
82
|
+
* <p>This is equivalent to calling role.relation("users")</p>
|
|
83
|
+
*
|
|
84
|
+
* @returns {Parse.Relation} the relation for the users belonging to this
|
|
85
|
+
* role.
|
|
86
|
+
*/
|
|
87
|
+
getUsers() {
|
|
88
|
+
return this.relation('users');
|
|
89
|
+
}
|
|
133
90
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
91
|
+
/**
|
|
92
|
+
* Gets the Parse.Relation for the Parse.Roles that are direct
|
|
93
|
+
* children of this role. These roles' users are granted any privileges that
|
|
94
|
+
* this role has been granted (e.g. read or write access through ACLs). You
|
|
95
|
+
* can add or remove child roles from this role through this relation.
|
|
96
|
+
*
|
|
97
|
+
* <p>This is equivalent to calling role.relation("roles")</p>
|
|
98
|
+
*
|
|
99
|
+
* @returns {Parse.Relation} the relation for the roles belonging to this
|
|
100
|
+
* role.
|
|
101
|
+
*/
|
|
102
|
+
getRoles() {
|
|
103
|
+
return this.relation('roles');
|
|
104
|
+
}
|
|
105
|
+
_validateName(newName) {
|
|
106
|
+
if (typeof newName !== 'string') {
|
|
107
|
+
throw new _ParseError.default(_ParseError.default.OTHER_CAUSE, "A role's name must be a String.");
|
|
149
108
|
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
}
|
|
109
|
+
if (!/^[0-9a-zA-Z\-_ ]+$/.test(newName)) {
|
|
110
|
+
throw new _ParseError.default(_ParseError.default.OTHER_CAUSE, "A role's name can be only contain alphanumeric characters, _, " + '-, and spaces.');
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
validate(attrs, options) {
|
|
114
|
+
const isInvalid = super.validate(attrs, options);
|
|
115
|
+
if (isInvalid) {
|
|
116
|
+
return isInvalid;
|
|
159
117
|
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
118
|
+
if ('name' in attrs && attrs.name !== this.getName()) {
|
|
119
|
+
const newName = attrs.name;
|
|
120
|
+
if (this.id && this.id !== attrs.objectId) {
|
|
121
|
+
// Check to see if the objectId being set matches this.id
|
|
122
|
+
// This happens during a fetch -- the id is set before calling fetch
|
|
123
|
+
// Let the name be set in this case
|
|
124
|
+
return new _ParseError.default(_ParseError.default.OTHER_CAUSE, "A role's name can only be set before it has been saved.");
|
|
166
125
|
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
// This happens during a fetch -- the id is set before calling fetch
|
|
172
|
-
// Let the name be set in this case
|
|
173
|
-
return new _ParseError.default(_ParseError.default.OTHER_CAUSE, "A role's name can only be set before it has been saved.");
|
|
174
|
-
}
|
|
175
|
-
try {
|
|
176
|
-
this._validateName(newName);
|
|
177
|
-
} catch (e) {
|
|
178
|
-
return e;
|
|
179
|
-
}
|
|
126
|
+
try {
|
|
127
|
+
this._validateName(newName);
|
|
128
|
+
} catch (e) {
|
|
129
|
+
return e;
|
|
180
130
|
}
|
|
181
|
-
return false;
|
|
182
131
|
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
}
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
186
135
|
_CoreManager.default.setParseRole(ParseRole);
|
|
187
|
-
|
|
188
|
-
var _default = ParseRole;
|
|
189
|
-
exports.default = _default;
|
|
136
|
+
_ParseObject.default.registerSubclass('_Role', ParseRole);
|
|
137
|
+
var _default = exports.default = ParseRole;
|