parse 4.0.1 → 4.1.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/dist/parse.js +17994 -26193
- package/dist/parse.min.js +2 -2
- package/dist/parse.weapp.js +8738 -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 +128 -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 +49 -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 +3 -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 +129 -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/browser/ParseACL.js
CHANGED
|
@@ -1,34 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
3
|
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
|
6
|
-
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
7
5
|
_Object$defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
10
|
-
|
|
11
8
|
exports.default = void 0;
|
|
12
|
-
|
|
13
9
|
var _keys = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/keys"));
|
|
14
|
-
|
|
15
10
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/typeof"));
|
|
16
|
-
|
|
17
11
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/classCallCheck"));
|
|
18
|
-
|
|
19
12
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/createClass"));
|
|
20
|
-
|
|
21
13
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
|
|
22
|
-
|
|
23
14
|
var _ParseRole = _interopRequireDefault(require("./ParseRole"));
|
|
24
|
-
|
|
25
15
|
var _ParseUser = _interopRequireDefault(require("./ParseUser"));
|
|
26
16
|
/**
|
|
27
17
|
* @flow
|
|
28
18
|
*/
|
|
29
19
|
|
|
30
|
-
|
|
31
20
|
var PUBLIC_KEY = '*';
|
|
21
|
+
|
|
32
22
|
/**
|
|
33
23
|
* Creates a new ACL.
|
|
34
24
|
* If no argument is given, the ACL has no permissions for anyone.
|
|
@@ -43,18 +33,14 @@ var PUBLIC_KEY = '*';
|
|
|
43
33
|
*
|
|
44
34
|
* @alias Parse.ACL
|
|
45
35
|
*/
|
|
46
|
-
|
|
47
36
|
var ParseACL = /*#__PURE__*/function () {
|
|
48
37
|
/**
|
|
49
38
|
* @param {(Parse.User | object)} arg1 The user to initialize the ACL for
|
|
50
39
|
*/
|
|
51
|
-
function ParseACL(arg1
|
|
52
|
-
/*: ParseUser | ByIdMap*/
|
|
53
|
-
) {
|
|
40
|
+
function ParseACL(arg1 /*: ParseUser | ByIdMap*/) {
|
|
54
41
|
(0, _classCallCheck2.default)(this, ParseACL);
|
|
55
42
|
(0, _defineProperty2.default)(this, "permissionsById", void 0);
|
|
56
43
|
this.permissionsById = {};
|
|
57
|
-
|
|
58
44
|
if (arg1 && (0, _typeof2.default)(arg1) === 'object') {
|
|
59
45
|
if (arg1 instanceof _ParseUser.default) {
|
|
60
46
|
this.setReadAccess(arg1, true);
|
|
@@ -63,18 +49,14 @@ var ParseACL = /*#__PURE__*/function () {
|
|
|
63
49
|
for (var _userId in arg1) {
|
|
64
50
|
var accessList = arg1[_userId];
|
|
65
51
|
this.permissionsById[_userId] = {};
|
|
66
|
-
|
|
67
52
|
for (var _permission in accessList) {
|
|
68
53
|
var allowed = accessList[_permission];
|
|
69
|
-
|
|
70
54
|
if (_permission !== 'read' && _permission !== 'write') {
|
|
71
55
|
throw new TypeError('Tried to create an ACL with an invalid permission type.');
|
|
72
56
|
}
|
|
73
|
-
|
|
74
57
|
if (typeof allowed !== 'boolean') {
|
|
75
58
|
throw new TypeError('Tried to create an ACL with an invalid permission value.');
|
|
76
59
|
}
|
|
77
|
-
|
|
78
60
|
this.permissionsById[_userId][_permission] = allowed;
|
|
79
61
|
}
|
|
80
62
|
}
|
|
@@ -83,98 +65,71 @@ var ParseACL = /*#__PURE__*/function () {
|
|
|
83
65
|
throw new TypeError('ParseACL constructed with a function. Did you forget ()?');
|
|
84
66
|
}
|
|
85
67
|
}
|
|
68
|
+
|
|
86
69
|
/**
|
|
87
70
|
* Returns a JSON-encoded version of the ACL.
|
|
88
71
|
*
|
|
89
72
|
* @returns {object}
|
|
90
73
|
*/
|
|
91
|
-
|
|
92
|
-
|
|
93
74
|
(0, _createClass2.default)(ParseACL, [{
|
|
94
75
|
key: "toJSON",
|
|
95
|
-
value: function ()
|
|
96
|
-
/*: ByIdMap*/
|
|
97
|
-
{
|
|
76
|
+
value: function () /*: ByIdMap*/{
|
|
98
77
|
var permissions = {};
|
|
99
|
-
|
|
100
78
|
for (var p in this.permissionsById) {
|
|
101
79
|
permissions[p] = this.permissionsById[p];
|
|
102
80
|
}
|
|
103
|
-
|
|
104
81
|
return permissions;
|
|
105
82
|
}
|
|
83
|
+
|
|
106
84
|
/**
|
|
107
85
|
* Returns whether this ACL is equal to another object
|
|
108
86
|
*
|
|
109
87
|
* @param {ParseACL} other The other object's ACL to compare to
|
|
110
88
|
* @returns {boolean}
|
|
111
89
|
*/
|
|
112
|
-
|
|
113
90
|
}, {
|
|
114
91
|
key: "equals",
|
|
115
|
-
value: function (other
|
|
116
|
-
/*: ParseACL*/
|
|
117
|
-
)
|
|
118
|
-
/*: boolean*/
|
|
119
|
-
{
|
|
92
|
+
value: function (other /*: ParseACL*/) /*: boolean*/{
|
|
120
93
|
if (!(other instanceof ParseACL)) {
|
|
121
94
|
return false;
|
|
122
95
|
}
|
|
123
|
-
|
|
124
96
|
var users = (0, _keys.default)(this.permissionsById);
|
|
125
97
|
var otherUsers = (0, _keys.default)(other.permissionsById);
|
|
126
|
-
|
|
127
98
|
if (users.length !== otherUsers.length) {
|
|
128
99
|
return false;
|
|
129
100
|
}
|
|
130
|
-
|
|
131
101
|
for (var u in this.permissionsById) {
|
|
132
102
|
if (!other.permissionsById[u]) {
|
|
133
103
|
return false;
|
|
134
104
|
}
|
|
135
|
-
|
|
136
105
|
if (this.permissionsById[u].read !== other.permissionsById[u].read) {
|
|
137
106
|
return false;
|
|
138
107
|
}
|
|
139
|
-
|
|
140
108
|
if (this.permissionsById[u].write !== other.permissionsById[u].write) {
|
|
141
109
|
return false;
|
|
142
110
|
}
|
|
143
111
|
}
|
|
144
|
-
|
|
145
112
|
return true;
|
|
146
113
|
}
|
|
147
114
|
}, {
|
|
148
115
|
key: "_setAccess",
|
|
149
|
-
value: function (accessType
|
|
150
|
-
/*: string*/
|
|
151
|
-
, userId
|
|
152
|
-
/*: ParseUser | ParseRole | string*/
|
|
153
|
-
, allowed
|
|
154
|
-
/*: boolean*/
|
|
155
|
-
) {
|
|
116
|
+
value: function (accessType /*: string*/, userId /*: ParseUser | ParseRole | string*/, allowed /*: boolean*/) {
|
|
156
117
|
if (userId instanceof _ParseUser.default) {
|
|
157
118
|
userId = userId.id;
|
|
158
119
|
} else if (userId instanceof _ParseRole.default) {
|
|
159
120
|
var name = userId.getName();
|
|
160
|
-
|
|
161
121
|
if (!name) {
|
|
162
122
|
throw new TypeError('Role must have a name');
|
|
163
123
|
}
|
|
164
|
-
|
|
165
124
|
userId = 'role:' + name;
|
|
166
125
|
}
|
|
167
|
-
|
|
168
126
|
if (typeof userId !== 'string') {
|
|
169
127
|
throw new TypeError('userId must be a string.');
|
|
170
128
|
}
|
|
171
|
-
|
|
172
129
|
if (typeof allowed !== 'boolean') {
|
|
173
130
|
throw new TypeError('allowed must be either true or false.');
|
|
174
131
|
}
|
|
175
|
-
|
|
176
132
|
var permissions = this.permissionsById[userId];
|
|
177
|
-
|
|
178
133
|
if (!permissions) {
|
|
179
134
|
if (!allowed) {
|
|
180
135
|
// The user already doesn't have this permission, so no action is needed
|
|
@@ -184,12 +139,10 @@ var ParseACL = /*#__PURE__*/function () {
|
|
|
184
139
|
this.permissionsById[userId] = permissions;
|
|
185
140
|
}
|
|
186
141
|
}
|
|
187
|
-
|
|
188
142
|
if (allowed) {
|
|
189
143
|
this.permissionsById[userId][accessType] = true;
|
|
190
144
|
} else {
|
|
191
145
|
delete permissions[accessType];
|
|
192
|
-
|
|
193
146
|
if ((0, _keys.default)(permissions).length === 0) {
|
|
194
147
|
delete this.permissionsById[userId];
|
|
195
148
|
}
|
|
@@ -197,53 +150,38 @@ var ParseACL = /*#__PURE__*/function () {
|
|
|
197
150
|
}
|
|
198
151
|
}, {
|
|
199
152
|
key: "_getAccess",
|
|
200
|
-
value: function (accessType
|
|
201
|
-
/*: string*/
|
|
202
|
-
, userId
|
|
203
|
-
/*: ParseUser | ParseRole | string*/
|
|
204
|
-
)
|
|
205
|
-
/*: boolean*/
|
|
206
|
-
{
|
|
153
|
+
value: function (accessType /*: string*/, userId /*: ParseUser | ParseRole | string*/) /*: boolean*/{
|
|
207
154
|
if (userId instanceof _ParseUser.default) {
|
|
208
155
|
userId = userId.id;
|
|
209
|
-
|
|
210
156
|
if (!userId) {
|
|
211
157
|
throw new Error('Cannot get access for a ParseUser without an ID');
|
|
212
158
|
}
|
|
213
159
|
} else if (userId instanceof _ParseRole.default) {
|
|
214
160
|
var name = userId.getName();
|
|
215
|
-
|
|
216
161
|
if (!name) {
|
|
217
162
|
throw new TypeError('Role must have a name');
|
|
218
163
|
}
|
|
219
|
-
|
|
220
164
|
userId = 'role:' + name;
|
|
221
165
|
}
|
|
222
|
-
|
|
223
166
|
var permissions = this.permissionsById[userId];
|
|
224
|
-
|
|
225
167
|
if (!permissions) {
|
|
226
168
|
return false;
|
|
227
169
|
}
|
|
228
|
-
|
|
229
170
|
return !!permissions[accessType];
|
|
230
171
|
}
|
|
172
|
+
|
|
231
173
|
/**
|
|
232
174
|
* Sets whether the given user is allowed to read this object.
|
|
233
175
|
*
|
|
234
176
|
* @param userId An instance of Parse.User or its objectId.
|
|
235
177
|
* @param {boolean} allowed Whether that user should have read access.
|
|
236
178
|
*/
|
|
237
|
-
|
|
238
179
|
}, {
|
|
239
180
|
key: "setReadAccess",
|
|
240
|
-
value: function (userId
|
|
241
|
-
/*: ParseUser | ParseRole | string*/
|
|
242
|
-
, allowed
|
|
243
|
-
/*: boolean*/
|
|
244
|
-
) {
|
|
181
|
+
value: function (userId /*: ParseUser | ParseRole | string*/, allowed /*: boolean*/) {
|
|
245
182
|
this._setAccess('read', userId, allowed);
|
|
246
183
|
}
|
|
184
|
+
|
|
247
185
|
/**
|
|
248
186
|
* Get whether the given user id is *explicitly* allowed to read this object.
|
|
249
187
|
* Even if this returns false, the user may still be able to access it if
|
|
@@ -253,32 +191,24 @@ var ParseACL = /*#__PURE__*/function () {
|
|
|
253
191
|
* @param userId An instance of Parse.User or its objectId, or a Parse.Role.
|
|
254
192
|
* @returns {boolean}
|
|
255
193
|
*/
|
|
256
|
-
|
|
257
194
|
}, {
|
|
258
195
|
key: "getReadAccess",
|
|
259
|
-
value: function (userId
|
|
260
|
-
/*: ParseUser | ParseRole | string*/
|
|
261
|
-
)
|
|
262
|
-
/*: boolean*/
|
|
263
|
-
{
|
|
196
|
+
value: function (userId /*: ParseUser | ParseRole | string*/) /*: boolean*/{
|
|
264
197
|
return this._getAccess('read', userId);
|
|
265
198
|
}
|
|
199
|
+
|
|
266
200
|
/**
|
|
267
201
|
* Sets whether the given user id is allowed to write this object.
|
|
268
202
|
*
|
|
269
203
|
* @param userId An instance of Parse.User or its objectId, or a Parse.Role..
|
|
270
204
|
* @param {boolean} allowed Whether that user should have write access.
|
|
271
205
|
*/
|
|
272
|
-
|
|
273
206
|
}, {
|
|
274
207
|
key: "setWriteAccess",
|
|
275
|
-
value: function (userId
|
|
276
|
-
/*: ParseUser | ParseRole | string*/
|
|
277
|
-
, allowed
|
|
278
|
-
/*: boolean*/
|
|
279
|
-
) {
|
|
208
|
+
value: function (userId /*: ParseUser | ParseRole | string*/, allowed /*: boolean*/) {
|
|
280
209
|
this._setAccess('write', userId, allowed);
|
|
281
210
|
}
|
|
211
|
+
|
|
282
212
|
/**
|
|
283
213
|
* Gets whether the given user id is *explicitly* allowed to write this object.
|
|
284
214
|
* Even if this returns false, the user may still be able to write it if
|
|
@@ -288,68 +218,56 @@ var ParseACL = /*#__PURE__*/function () {
|
|
|
288
218
|
* @param userId An instance of Parse.User or its objectId, or a Parse.Role.
|
|
289
219
|
* @returns {boolean}
|
|
290
220
|
*/
|
|
291
|
-
|
|
292
221
|
}, {
|
|
293
222
|
key: "getWriteAccess",
|
|
294
|
-
value: function (userId
|
|
295
|
-
/*: ParseUser | ParseRole | string*/
|
|
296
|
-
)
|
|
297
|
-
/*: boolean*/
|
|
298
|
-
{
|
|
223
|
+
value: function (userId /*: ParseUser | ParseRole | string*/) /*: boolean*/{
|
|
299
224
|
return this._getAccess('write', userId);
|
|
300
225
|
}
|
|
226
|
+
|
|
301
227
|
/**
|
|
302
228
|
* Sets whether the public is allowed to read this object.
|
|
303
229
|
*
|
|
304
230
|
* @param {boolean} allowed
|
|
305
231
|
*/
|
|
306
|
-
|
|
307
232
|
}, {
|
|
308
233
|
key: "setPublicReadAccess",
|
|
309
|
-
value: function (allowed
|
|
310
|
-
/*: boolean*/
|
|
311
|
-
) {
|
|
234
|
+
value: function (allowed /*: boolean*/) {
|
|
312
235
|
this.setReadAccess(PUBLIC_KEY, allowed);
|
|
313
236
|
}
|
|
237
|
+
|
|
314
238
|
/**
|
|
315
239
|
* Gets whether the public is allowed to read this object.
|
|
316
240
|
*
|
|
317
241
|
* @returns {boolean}
|
|
318
242
|
*/
|
|
319
|
-
|
|
320
243
|
}, {
|
|
321
244
|
key: "getPublicReadAccess",
|
|
322
|
-
value: function ()
|
|
323
|
-
/*: boolean*/
|
|
324
|
-
{
|
|
245
|
+
value: function () /*: boolean*/{
|
|
325
246
|
return this.getReadAccess(PUBLIC_KEY);
|
|
326
247
|
}
|
|
248
|
+
|
|
327
249
|
/**
|
|
328
250
|
* Sets whether the public is allowed to write this object.
|
|
329
251
|
*
|
|
330
252
|
* @param {boolean} allowed
|
|
331
253
|
*/
|
|
332
|
-
|
|
333
254
|
}, {
|
|
334
255
|
key: "setPublicWriteAccess",
|
|
335
|
-
value: function (allowed
|
|
336
|
-
/*: boolean*/
|
|
337
|
-
) {
|
|
256
|
+
value: function (allowed /*: boolean*/) {
|
|
338
257
|
this.setWriteAccess(PUBLIC_KEY, allowed);
|
|
339
258
|
}
|
|
259
|
+
|
|
340
260
|
/**
|
|
341
261
|
* Gets whether the public is allowed to write this object.
|
|
342
262
|
*
|
|
343
263
|
* @returns {boolean}
|
|
344
264
|
*/
|
|
345
|
-
|
|
346
265
|
}, {
|
|
347
266
|
key: "getPublicWriteAccess",
|
|
348
|
-
value: function ()
|
|
349
|
-
/*: boolean*/
|
|
350
|
-
{
|
|
267
|
+
value: function () /*: boolean*/{
|
|
351
268
|
return this.getWriteAccess(PUBLIC_KEY);
|
|
352
269
|
}
|
|
270
|
+
|
|
353
271
|
/**
|
|
354
272
|
* Gets whether users belonging to the given role are allowed
|
|
355
273
|
* to read this object. Even if this returns false, the role may
|
|
@@ -359,25 +277,19 @@ var ParseACL = /*#__PURE__*/function () {
|
|
|
359
277
|
* @returns {boolean} true if the role has read access. false otherwise.
|
|
360
278
|
* @throws {TypeError} If role is neither a Parse.Role nor a String.
|
|
361
279
|
*/
|
|
362
|
-
|
|
363
280
|
}, {
|
|
364
281
|
key: "getRoleReadAccess",
|
|
365
|
-
value: function (role
|
|
366
|
-
/*: ParseRole | string*/
|
|
367
|
-
)
|
|
368
|
-
/*: boolean*/
|
|
369
|
-
{
|
|
282
|
+
value: function (role /*: ParseRole | string*/) /*: boolean*/{
|
|
370
283
|
if (role instanceof _ParseRole.default) {
|
|
371
284
|
// Normalize to the String name
|
|
372
285
|
role = role.getName();
|
|
373
286
|
}
|
|
374
|
-
|
|
375
287
|
if (typeof role !== 'string') {
|
|
376
288
|
throw new TypeError('role must be a ParseRole or a String');
|
|
377
289
|
}
|
|
378
|
-
|
|
379
290
|
return this.getReadAccess('role:' + role);
|
|
380
291
|
}
|
|
292
|
+
|
|
381
293
|
/**
|
|
382
294
|
* Gets whether users belonging to the given role are allowed
|
|
383
295
|
* to write this object. Even if this returns false, the role may
|
|
@@ -387,25 +299,19 @@ var ParseACL = /*#__PURE__*/function () {
|
|
|
387
299
|
* @returns {boolean} true if the role has write access. false otherwise.
|
|
388
300
|
* @throws {TypeError} If role is neither a Parse.Role nor a String.
|
|
389
301
|
*/
|
|
390
|
-
|
|
391
302
|
}, {
|
|
392
303
|
key: "getRoleWriteAccess",
|
|
393
|
-
value: function (role
|
|
394
|
-
/*: ParseRole | string*/
|
|
395
|
-
)
|
|
396
|
-
/*: boolean*/
|
|
397
|
-
{
|
|
304
|
+
value: function (role /*: ParseRole | string*/) /*: boolean*/{
|
|
398
305
|
if (role instanceof _ParseRole.default) {
|
|
399
306
|
// Normalize to the String name
|
|
400
307
|
role = role.getName();
|
|
401
308
|
}
|
|
402
|
-
|
|
403
309
|
if (typeof role !== 'string') {
|
|
404
310
|
throw new TypeError('role must be a ParseRole or a String');
|
|
405
311
|
}
|
|
406
|
-
|
|
407
312
|
return this.getWriteAccess('role:' + role);
|
|
408
313
|
}
|
|
314
|
+
|
|
409
315
|
/**
|
|
410
316
|
* Sets whether users belonging to the given role are allowed
|
|
411
317
|
* to read this object.
|
|
@@ -414,25 +320,19 @@ var ParseACL = /*#__PURE__*/function () {
|
|
|
414
320
|
* @param {boolean} allowed Whether the given role can read this object.
|
|
415
321
|
* @throws {TypeError} If role is neither a Parse.Role nor a String.
|
|
416
322
|
*/
|
|
417
|
-
|
|
418
323
|
}, {
|
|
419
324
|
key: "setRoleReadAccess",
|
|
420
|
-
value: function (role
|
|
421
|
-
/*: ParseRole | string*/
|
|
422
|
-
, allowed
|
|
423
|
-
/*: boolean*/
|
|
424
|
-
) {
|
|
325
|
+
value: function (role /*: ParseRole | string*/, allowed /*: boolean*/) {
|
|
425
326
|
if (role instanceof _ParseRole.default) {
|
|
426
327
|
// Normalize to the String name
|
|
427
328
|
role = role.getName();
|
|
428
329
|
}
|
|
429
|
-
|
|
430
330
|
if (typeof role !== 'string') {
|
|
431
331
|
throw new TypeError('role must be a ParseRole or a String');
|
|
432
332
|
}
|
|
433
|
-
|
|
434
333
|
this.setReadAccess('role:' + role, allowed);
|
|
435
334
|
}
|
|
335
|
+
|
|
436
336
|
/**
|
|
437
337
|
* Sets whether users belonging to the given role are allowed
|
|
438
338
|
* to write this object.
|
|
@@ -441,28 +341,20 @@ var ParseACL = /*#__PURE__*/function () {
|
|
|
441
341
|
* @param {boolean} allowed Whether the given role can write this object.
|
|
442
342
|
* @throws {TypeError} If role is neither a Parse.Role nor a String.
|
|
443
343
|
*/
|
|
444
|
-
|
|
445
344
|
}, {
|
|
446
345
|
key: "setRoleWriteAccess",
|
|
447
|
-
value: function (role
|
|
448
|
-
/*: ParseRole | string*/
|
|
449
|
-
, allowed
|
|
450
|
-
/*: boolean*/
|
|
451
|
-
) {
|
|
346
|
+
value: function (role /*: ParseRole | string*/, allowed /*: boolean*/) {
|
|
452
347
|
if (role instanceof _ParseRole.default) {
|
|
453
348
|
// Normalize to the String name
|
|
454
349
|
role = role.getName();
|
|
455
350
|
}
|
|
456
|
-
|
|
457
351
|
if (typeof role !== 'string') {
|
|
458
352
|
throw new TypeError('role must be a ParseRole or a String');
|
|
459
353
|
}
|
|
460
|
-
|
|
461
354
|
this.setWriteAccess('role:' + role, allowed);
|
|
462
355
|
}
|
|
463
356
|
}]);
|
|
464
357
|
return ParseACL;
|
|
465
358
|
}();
|
|
466
|
-
|
|
467
359
|
var _default = ParseACL;
|
|
468
360
|
exports.default = _default;
|