parse 5.2.0-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.
Files changed (247) hide show
  1. package/dist/parse.js +10102 -15029
  2. package/dist/parse.min.js +2 -2
  3. package/dist/parse.weapp.js +10093 -15165
  4. package/dist/parse.weapp.min.js +2 -2
  5. package/lib/browser/Analytics.js +7 -11
  6. package/lib/browser/AnonymousUtils.js +17 -22
  7. package/lib/browser/Cloud.js +23 -41
  8. package/lib/browser/CoreManager.js +71 -79
  9. package/lib/browser/CryptoController.js +14 -9
  10. package/lib/browser/EventEmitter.js +9 -2
  11. package/lib/browser/EventuallyQueue.js +156 -357
  12. package/lib/browser/FacebookUtils.js +23 -28
  13. package/lib/browser/IndexedDBStorageController.js +18 -14
  14. package/lib/browser/InstallationController.js +55 -121
  15. package/lib/browser/LiveQueryClient.js +308 -484
  16. package/lib/browser/LiveQuerySubscription.js +25 -28
  17. package/lib/browser/LocalDatastore.js +258 -624
  18. package/lib/browser/LocalDatastoreController.default.js +42 -226
  19. package/lib/browser/LocalDatastoreController.js +11 -1
  20. package/lib/browser/LocalDatastoreController.react-native.js +66 -160
  21. package/lib/browser/LocalDatastoreUtils.js +4 -7
  22. package/lib/browser/ObjectStateMutations.js +54 -96
  23. package/lib/browser/OfflineQuery.js +106 -198
  24. package/lib/browser/Parse.js +44 -60
  25. package/lib/browser/ParseACL.js +242 -288
  26. package/lib/browser/ParseCLP.js +372 -572
  27. package/lib/browser/ParseConfig.js +115 -138
  28. package/lib/browser/ParseError.js +85 -182
  29. package/lib/browser/ParseFile.js +294 -438
  30. package/lib/browser/ParseGeoPoint.js +121 -146
  31. package/lib/browser/ParseHooks.js +23 -25
  32. package/lib/browser/ParseInstallation.js +225 -367
  33. package/lib/browser/ParseLiveQuery.js +74 -148
  34. package/lib/browser/ParseObject.js +2014 -2621
  35. package/lib/browser/ParseOp.js +343 -484
  36. package/lib/browser/ParsePolygon.js +101 -120
  37. package/lib/browser/ParseQuery.js +1708 -2052
  38. package/lib/browser/ParseRelation.js +99 -118
  39. package/lib/browser/ParseRole.js +88 -140
  40. package/lib/browser/ParseSchema.js +372 -434
  41. package/lib/browser/ParseSession.js +62 -110
  42. package/lib/browser/ParseUser.js +941 -1284
  43. package/lib/browser/Push.js +15 -38
  44. package/lib/browser/RESTController.js +85 -124
  45. package/lib/browser/SingleInstanceStateController.js +57 -86
  46. package/lib/browser/Socket.weapp.js +50 -33
  47. package/lib/browser/Storage.js +23 -28
  48. package/lib/browser/StorageController.browser.js +16 -13
  49. package/lib/browser/StorageController.default.js +15 -14
  50. package/lib/browser/StorageController.js +14 -1
  51. package/lib/browser/StorageController.react-native.js +31 -30
  52. package/lib/browser/StorageController.weapp.js +19 -13
  53. package/lib/browser/TaskQueue.js +31 -43
  54. package/lib/browser/UniqueInstanceStateController.js +65 -86
  55. package/lib/browser/WebSocketController.js +11 -4
  56. package/lib/browser/Xhr.weapp.js +90 -78
  57. package/lib/browser/arrayContainsObject.js +3 -3
  58. package/lib/browser/canBeSerialized.js +10 -11
  59. package/lib/browser/decode.js +11 -11
  60. package/lib/browser/encode.js +11 -11
  61. package/lib/browser/equals.js +9 -10
  62. package/lib/browser/escape.js +2 -2
  63. package/lib/browser/isRevocableSession.js +1 -1
  64. package/lib/browser/parseDate.js +10 -10
  65. package/lib/browser/promiseUtils.js +19 -19
  66. package/lib/browser/unique.js +4 -4
  67. package/lib/browser/unsavedChildren.js +20 -21
  68. package/lib/browser/uuid.js +2 -4
  69. package/lib/node/Analytics.js +2 -6
  70. package/lib/node/AnonymousUtils.js +7 -12
  71. package/lib/node/Cloud.js +8 -8
  72. package/lib/node/CoreManager.js +59 -67
  73. package/lib/node/CryptoController.js +8 -3
  74. package/lib/node/EventEmitter.js +7 -1
  75. package/lib/node/EventuallyQueue.js +17 -36
  76. package/lib/node/FacebookUtils.js +1 -5
  77. package/lib/node/IndexedDBStorageController.js +14 -10
  78. package/lib/node/InstallationController.js +9 -10
  79. package/lib/node/LiveQueryClient.js +12 -14
  80. package/lib/node/LiveQuerySubscription.js +3 -4
  81. package/lib/node/LocalDatastore.js +20 -20
  82. package/lib/node/LocalDatastoreController.default.js +8 -9
  83. package/lib/node/LocalDatastoreController.js +14 -1
  84. package/lib/node/LocalDatastoreController.react-native.js +25 -21
  85. package/lib/node/LocalDatastoreUtils.js +4 -7
  86. package/lib/node/ObjectStateMutations.js +9 -19
  87. package/lib/node/OfflineQuery.js +37 -23
  88. package/lib/node/Parse.js +33 -47
  89. package/lib/node/ParseACL.js +18 -27
  90. package/lib/node/ParseCLP.js +35 -37
  91. package/lib/node/ParseConfig.js +7 -14
  92. package/lib/node/ParseError.js +457 -458
  93. package/lib/node/ParseFile.js +24 -44
  94. package/lib/node/ParseGeoPoint.js +16 -17
  95. package/lib/node/ParseHooks.js +13 -15
  96. package/lib/node/ParseInstallation.js +7 -8
  97. package/lib/node/ParseLiveQuery.js +6 -11
  98. package/lib/node/ParseObject.js +139 -170
  99. package/lib/node/ParseOp.js +32 -44
  100. package/lib/node/ParsePolygon.js +11 -17
  101. package/lib/node/ParseQuery.js +97 -120
  102. package/lib/node/ParseRelation.js +7 -16
  103. package/lib/node/ParseRole.js +7 -8
  104. package/lib/node/ParseSchema.js +26 -39
  105. package/lib/node/ParseSession.js +7 -8
  106. package/lib/node/ParseUser.js +73 -84
  107. package/lib/node/Push.js +4 -9
  108. package/lib/node/RESTController.js +21 -33
  109. package/lib/node/SingleInstanceStateController.js +41 -69
  110. package/lib/node/Socket.weapp.js +23 -2
  111. package/lib/node/Storage.js +11 -16
  112. package/lib/node/StorageController.browser.js +10 -8
  113. package/lib/node/StorageController.default.js +9 -9
  114. package/lib/node/StorageController.js +16 -1
  115. package/lib/node/StorageController.react-native.js +17 -17
  116. package/lib/node/StorageController.weapp.js +14 -8
  117. package/lib/node/TaskQueue.js +2 -3
  118. package/lib/node/UniqueInstanceStateController.js +40 -60
  119. package/lib/node/WebSocketController.js +15 -2
  120. package/lib/node/Xhr.weapp.js +11 -2
  121. package/lib/node/arrayContainsObject.js +1 -1
  122. package/lib/node/canBeSerialized.js +2 -2
  123. package/lib/node/decode.js +1 -1
  124. package/lib/node/encode.js +2 -2
  125. package/lib/node/equals.js +1 -1
  126. package/lib/node/escape.js +1 -1
  127. package/lib/node/isRevocableSession.js +1 -1
  128. package/lib/node/parseDate.js +1 -1
  129. package/lib/node/promiseUtils.js +7 -7
  130. package/lib/node/unique.js +2 -2
  131. package/lib/node/unsavedChildren.js +2 -2
  132. package/lib/node/uuid.js +2 -4
  133. package/lib/react-native/Analytics.js +2 -2
  134. package/lib/react-native/AnonymousUtils.js +3 -4
  135. package/lib/react-native/CoreManager.js +2 -3
  136. package/lib/react-native/CryptoController.js +6 -1
  137. package/lib/react-native/EventEmitter.js +6 -1
  138. package/lib/react-native/EventuallyQueue.js +1 -2
  139. package/lib/react-native/FacebookUtils.js +1 -2
  140. package/lib/react-native/IndexedDBStorageController.js +11 -5
  141. package/lib/react-native/InstallationController.js +1 -2
  142. package/lib/react-native/LiveQueryClient.js +2 -4
  143. package/lib/react-native/LiveQuerySubscription.js +2 -4
  144. package/lib/react-native/LocalDatastore.js +3 -3
  145. package/lib/react-native/LocalDatastoreController.default.js +1 -2
  146. package/lib/react-native/LocalDatastoreController.js +11 -1
  147. package/lib/react-native/LocalDatastoreController.react-native.js +11 -12
  148. package/lib/react-native/LocalDatastoreUtils.js +3 -6
  149. package/lib/react-native/OfflineQuery.js +25 -20
  150. package/lib/react-native/Parse.js +24 -38
  151. package/lib/react-native/ParseACL.js +4 -6
  152. package/lib/react-native/ParseCLP.js +2 -4
  153. package/lib/react-native/ParseConfig.js +4 -6
  154. package/lib/react-native/ParseError.js +13 -31
  155. package/lib/react-native/ParseFile.js +3 -4
  156. package/lib/react-native/ParseGeoPoint.js +2 -4
  157. package/lib/react-native/ParseInstallation.js +13 -30
  158. package/lib/react-native/ParseLiveQuery.js +2 -4
  159. package/lib/react-native/ParseObject.js +77 -87
  160. package/lib/react-native/ParseOp.js +41 -79
  161. package/lib/react-native/ParsePolygon.js +2 -4
  162. package/lib/react-native/ParseQuery.js +43 -45
  163. package/lib/react-native/ParseRelation.js +2 -4
  164. package/lib/react-native/ParseRole.js +13 -30
  165. package/lib/react-native/ParseSchema.js +3 -5
  166. package/lib/react-native/ParseSession.js +12 -29
  167. package/lib/react-native/ParseUser.js +24 -49
  168. package/lib/react-native/RESTController.js +10 -4
  169. package/lib/react-native/SingleInstanceStateController.js +23 -37
  170. package/lib/react-native/Socket.weapp.js +9 -4
  171. package/lib/react-native/Storage.js +1 -2
  172. package/lib/react-native/StorageController.browser.js +6 -1
  173. package/lib/react-native/StorageController.default.js +6 -1
  174. package/lib/react-native/StorageController.js +13 -1
  175. package/lib/react-native/StorageController.react-native.js +11 -6
  176. package/lib/react-native/StorageController.weapp.js +6 -1
  177. package/lib/react-native/TaskQueue.js +2 -4
  178. package/lib/react-native/UniqueInstanceStateController.js +23 -37
  179. package/lib/react-native/WebSocketController.js +9 -1
  180. package/lib/react-native/Xhr.weapp.js +9 -4
  181. package/lib/react-native/unsavedChildren.js +3 -3
  182. package/lib/react-native/uuid.js +1 -2
  183. package/lib/weapp/Analytics.js +7 -11
  184. package/lib/weapp/AnonymousUtils.js +17 -22
  185. package/lib/weapp/Cloud.js +23 -41
  186. package/lib/weapp/CoreManager.js +71 -79
  187. package/lib/weapp/CryptoController.js +14 -9
  188. package/lib/weapp/EventEmitter.js +9 -2
  189. package/lib/weapp/EventuallyQueue.js +156 -357
  190. package/lib/weapp/FacebookUtils.js +23 -28
  191. package/lib/weapp/IndexedDBStorageController.js +18 -14
  192. package/lib/weapp/InstallationController.js +55 -121
  193. package/lib/weapp/LiveQueryClient.js +308 -484
  194. package/lib/weapp/LiveQuerySubscription.js +25 -28
  195. package/lib/weapp/LocalDatastore.js +258 -624
  196. package/lib/weapp/LocalDatastoreController.default.js +42 -226
  197. package/lib/weapp/LocalDatastoreController.js +11 -1
  198. package/lib/weapp/LocalDatastoreController.react-native.js +66 -160
  199. package/lib/weapp/LocalDatastoreUtils.js +4 -7
  200. package/lib/weapp/ObjectStateMutations.js +54 -96
  201. package/lib/weapp/OfflineQuery.js +106 -198
  202. package/lib/weapp/Parse.js +44 -59
  203. package/lib/weapp/ParseACL.js +242 -288
  204. package/lib/weapp/ParseCLP.js +372 -572
  205. package/lib/weapp/ParseConfig.js +115 -138
  206. package/lib/weapp/ParseError.js +85 -182
  207. package/lib/weapp/ParseFile.js +295 -440
  208. package/lib/weapp/ParseGeoPoint.js +121 -146
  209. package/lib/weapp/ParseHooks.js +23 -25
  210. package/lib/weapp/ParseInstallation.js +225 -367
  211. package/lib/weapp/ParseLiveQuery.js +74 -148
  212. package/lib/weapp/ParseObject.js +2014 -2621
  213. package/lib/weapp/ParseOp.js +343 -484
  214. package/lib/weapp/ParsePolygon.js +101 -120
  215. package/lib/weapp/ParseQuery.js +1708 -2052
  216. package/lib/weapp/ParseRelation.js +99 -118
  217. package/lib/weapp/ParseRole.js +88 -140
  218. package/lib/weapp/ParseSchema.js +372 -434
  219. package/lib/weapp/ParseSession.js +62 -110
  220. package/lib/weapp/ParseUser.js +941 -1284
  221. package/lib/weapp/Push.js +15 -38
  222. package/lib/weapp/RESTController.js +86 -125
  223. package/lib/weapp/SingleInstanceStateController.js +57 -86
  224. package/lib/weapp/Socket.weapp.js +50 -33
  225. package/lib/weapp/Storage.js +23 -28
  226. package/lib/weapp/StorageController.browser.js +16 -13
  227. package/lib/weapp/StorageController.default.js +15 -14
  228. package/lib/weapp/StorageController.js +14 -1
  229. package/lib/weapp/StorageController.react-native.js +31 -30
  230. package/lib/weapp/StorageController.weapp.js +19 -13
  231. package/lib/weapp/TaskQueue.js +31 -43
  232. package/lib/weapp/UniqueInstanceStateController.js +65 -86
  233. package/lib/weapp/WebSocketController.js +11 -4
  234. package/lib/weapp/Xhr.weapp.js +90 -78
  235. package/lib/weapp/arrayContainsObject.js +3 -3
  236. package/lib/weapp/canBeSerialized.js +10 -11
  237. package/lib/weapp/decode.js +11 -11
  238. package/lib/weapp/encode.js +11 -11
  239. package/lib/weapp/equals.js +9 -10
  240. package/lib/weapp/escape.js +2 -2
  241. package/lib/weapp/isRevocableSession.js +1 -1
  242. package/lib/weapp/parseDate.js +10 -10
  243. package/lib/weapp/promiseUtils.js +19 -19
  244. package/lib/weapp/unique.js +4 -4
  245. package/lib/weapp/unsavedChildren.js +20 -21
  246. package/lib/weapp/uuid.js +6 -8
  247. package/package.json +19 -25
@@ -1,128 +1,24 @@
1
1
  "use strict";
2
2
 
3
- var _sliceInstanceProperty2 = require("@babel/runtime-corejs3/core-js-stable/instance/slice");
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");
8
- var _Object$keys2 = require("@babel/runtime-corejs3/core-js-stable/object/keys");
9
- var _Object$getOwnPropertySymbols = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols");
10
- var _filterInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/filter");
11
- var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
12
- var _forEachInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/for-each");
13
- var _Object$getOwnPropertyDescriptors = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors");
14
- var _Object$defineProperties = require("@babel/runtime-corejs3/core-js-stable/object/define-properties");
15
3
  var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
16
4
  var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
17
5
  _Object$defineProperty(exports, "__esModule", {
18
6
  value: true
19
7
  });
20
8
  exports.default = void 0;
21
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/slicedToArray"));
22
- var _typeof2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/typeof"));
23
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/classCallCheck"));
24
- var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/createClass"));
25
9
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
26
10
  var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/map"));
27
- var _includes = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/includes"));
28
- var _every = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/every"));
29
11
  var _entries = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/entries"));
30
12
  var _assign = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/assign"));
31
13
  var _slice = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/slice"));
14
+ var _includes = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/includes"));
15
+ var _every = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/every"));
32
16
  var _keys = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/keys"));
33
17
  var _isArray = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/array/is-array"));
34
18
  var _ParseRole = _interopRequireDefault(require("./ParseRole"));
35
19
  var _ParseUser = _interopRequireDefault(require("./ParseUser"));
36
- function ownKeys(object, enumerableOnly) {
37
- var keys = _Object$keys2(object);
38
- if (_Object$getOwnPropertySymbols) {
39
- var symbols = _Object$getOwnPropertySymbols(object);
40
- enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) {
41
- return _Object$getOwnPropertyDescriptor(object, sym).enumerable;
42
- })), keys.push.apply(keys, symbols);
43
- }
44
- return keys;
45
- }
46
- function _objectSpread(target) {
47
- for (var i = 1; i < arguments.length; i++) {
48
- var _context3, _context4;
49
- var source = null != arguments[i] ? arguments[i] : {};
50
- i % 2 ? _forEachInstanceProperty(_context3 = ownKeys(Object(source), !0)).call(_context3, function (key) {
51
- (0, _defineProperty2.default)(target, key, source[key]);
52
- }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context4 = ownKeys(Object(source))).call(_context4, function (key) {
53
- _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key));
54
- });
55
- }
56
- return target;
57
- }
58
- function _createForOfIteratorHelper(o, allowArrayLike) {
59
- var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"];
60
- if (!it) {
61
- if (_Array$isArray2(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
62
- if (it) o = it;
63
- var i = 0;
64
- var F = function () {};
65
- return {
66
- s: F,
67
- n: function () {
68
- if (i >= o.length) return {
69
- done: true
70
- };
71
- return {
72
- done: false,
73
- value: o[i++]
74
- };
75
- },
76
- e: function (_e) {
77
- throw _e;
78
- },
79
- f: F
80
- };
81
- }
82
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
83
- }
84
- var normalCompletion = true,
85
- didErr = false,
86
- err;
87
- return {
88
- s: function () {
89
- it = it.call(o);
90
- },
91
- n: function () {
92
- var step = it.next();
93
- normalCompletion = step.done;
94
- return step;
95
- },
96
- e: function (_e2) {
97
- didErr = true;
98
- err = _e2;
99
- },
100
- f: function () {
101
- try {
102
- if (!normalCompletion && it.return != null) it.return();
103
- } finally {
104
- if (didErr) throw err;
105
- }
106
- }
107
- };
108
- }
109
- function _unsupportedIterableToArray(o, minLen) {
110
- var _context2;
111
- if (!o) return;
112
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
113
- var n = _sliceInstanceProperty2(_context2 = Object.prototype.toString.call(o)).call(_context2, 8, -1);
114
- if (n === "Object" && o.constructor) n = o.constructor.name;
115
- if (n === "Map" || n === "Set") return _Array$from(o);
116
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
117
- }
118
- function _arrayLikeToArray(arr, len) {
119
- if (len == null || len > arr.length) len = arr.length;
120
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
121
- return arr2;
122
- }
123
- /*:: export type PermissionsMap = { writeUserFields?: string[], readUserFields?: string[] } & { [permission: string]: UsersMap };*/
124
- var PUBLIC_KEY = '*';
125
- var VALID_PERMISSIONS /*: Map<string, UsersMap>*/ = new _map.default();
20
+ const PUBLIC_KEY = '*';
21
+ const VALID_PERMISSIONS = new _map.default();
126
22
  VALID_PERMISSIONS.set('get', {});
127
23
  VALID_PERMISSIONS.set('find', {});
128
24
  VALID_PERMISSIONS.set('count', {});
@@ -130,7 +26,7 @@ VALID_PERMISSIONS.set('create', {});
130
26
  VALID_PERMISSIONS.set('update', {});
131
27
  VALID_PERMISSIONS.set('delete', {});
132
28
  VALID_PERMISSIONS.set('addField', {});
133
- var VALID_PERMISSIONS_EXTENDED /*: Map<string, UsersMap>*/ = new _map.default();
29
+ const VALID_PERMISSIONS_EXTENDED = new _map.default();
134
30
  VALID_PERMISSIONS_EXTENDED.set('protectedFields', {});
135
31
 
136
32
  /**
@@ -225,80 +121,53 @@ VALID_PERMISSIONS_EXTENDED.set('protectedFields', {});
225
121
  *
226
122
  * @alias Parse.CLP
227
123
  */
228
- var ParseCLP = /*#__PURE__*/function () {
124
+ class ParseCLP {
229
125
  /**
230
126
  * @param {(Parse.User | Parse.Role | object)} userId The user to initialize the CLP for
231
127
  */
232
- function ParseCLP(userId /*: ParseUser | ParseRole | PermissionsMap*/) {
233
- var _this = this;
234
- (0, _classCallCheck2.default)(this, ParseCLP);
128
+ constructor(userId) {
235
129
  (0, _defineProperty2.default)(this, "permissionsMap", void 0);
236
130
  this.permissionsMap = {};
237
131
  // Initialize permissions Map with default permissions
238
- var _iterator = _createForOfIteratorHelper((0, _entries.default)(VALID_PERMISSIONS).call(VALID_PERMISSIONS)),
239
- _step;
240
- try {
241
- var _loop = function _loop() {
242
- var _step$value = (0, _slicedToArray2.default)(_step.value, 2),
243
- operation = _step$value[0],
244
- group = _step$value[1];
245
- _this.permissionsMap[operation] = (0, _assign.default)({}, group);
246
- var action = operation.charAt(0).toUpperCase() + (0, _slice.default)(operation).call(operation, 1);
247
- _this["get".concat(action, "RequiresAuthentication")] = function () {
248
- return this._getAccess(operation, 'requiresAuthentication');
249
- };
250
- _this["set".concat(action, "RequiresAuthentication")] = function (allowed) {
251
- this._setAccess(operation, 'requiresAuthentication', allowed);
252
- };
253
- _this["get".concat(action, "PointerFields")] = function () {
254
- return this._getAccess(operation, 'pointerFields', false);
255
- };
256
- _this["set".concat(action, "PointerFields")] = function (pointerFields) {
257
- this._setArrayAccess(operation, 'pointerFields', pointerFields);
258
- };
259
- _this["get".concat(action, "Access")] = function (entity) {
260
- return this._getAccess(operation, entity);
261
- };
262
- _this["set".concat(action, "Access")] = function (entity, allowed) {
263
- this._setAccess(operation, entity, allowed);
264
- };
265
- _this["getPublic".concat(action, "Access")] = function () {
266
- return this["get".concat(action, "Access")](PUBLIC_KEY);
267
- };
268
- _this["setPublic".concat(action, "Access")] = function (allowed) {
269
- this["set".concat(action, "Access")](PUBLIC_KEY, allowed);
270
- };
271
- _this["getRole".concat(action, "Access")] = function (role) {
272
- return this["get".concat(action, "Access")](this._getRoleName(role));
273
- };
274
- _this["setRole".concat(action, "Access")] = function (role, allowed) {
275
- this["set".concat(action, "Access")](this._getRoleName(role), allowed);
276
- };
132
+ for (const [operation, group] of (0, _entries.default)(VALID_PERMISSIONS).call(VALID_PERMISSIONS)) {
133
+ this.permissionsMap[operation] = (0, _assign.default)({}, group);
134
+ const action = operation.charAt(0).toUpperCase() + (0, _slice.default)(operation).call(operation, 1);
135
+ this[`get${action}RequiresAuthentication`] = function () {
136
+ return this._getAccess(operation, 'requiresAuthentication');
137
+ };
138
+ this[`set${action}RequiresAuthentication`] = function (allowed) {
139
+ this._setAccess(operation, 'requiresAuthentication', allowed);
140
+ };
141
+ this[`get${action}PointerFields`] = function () {
142
+ return this._getAccess(operation, 'pointerFields', false);
143
+ };
144
+ this[`set${action}PointerFields`] = function (pointerFields) {
145
+ this._setArrayAccess(operation, 'pointerFields', pointerFields);
146
+ };
147
+ this[`get${action}Access`] = function (entity) {
148
+ return this._getAccess(operation, entity);
149
+ };
150
+ this[`set${action}Access`] = function (entity, allowed) {
151
+ this._setAccess(operation, entity, allowed);
152
+ };
153
+ this[`getPublic${action}Access`] = function () {
154
+ return this[`get${action}Access`](PUBLIC_KEY);
155
+ };
156
+ this[`setPublic${action}Access`] = function (allowed) {
157
+ this[`set${action}Access`](PUBLIC_KEY, allowed);
158
+ };
159
+ this[`getRole${action}Access`] = function (role) {
160
+ return this[`get${action}Access`](this._getRoleName(role));
161
+ };
162
+ this[`setRole${action}Access`] = function (role, allowed) {
163
+ this[`set${action}Access`](this._getRoleName(role), allowed);
277
164
  };
278
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
279
- _loop();
280
- }
281
- // Initialize permissions Map with default extended permissions
282
- } catch (err) {
283
- _iterator.e(err);
284
- } finally {
285
- _iterator.f();
286
165
  }
287
- var _iterator2 = _createForOfIteratorHelper((0, _entries.default)(VALID_PERMISSIONS_EXTENDED).call(VALID_PERMISSIONS_EXTENDED)),
288
- _step2;
289
- try {
290
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
291
- var _step2$value = (0, _slicedToArray2.default)(_step2.value, 2),
292
- operation = _step2$value[0],
293
- group = _step2$value[1];
294
- this.permissionsMap[operation] = (0, _assign.default)({}, group);
295
- }
296
- } catch (err) {
297
- _iterator2.e(err);
298
- } finally {
299
- _iterator2.f();
166
+ // Initialize permissions Map with default extended permissions
167
+ for (const [operation, group] of (0, _entries.default)(VALID_PERMISSIONS_EXTENDED).call(VALID_PERMISSIONS_EXTENDED)) {
168
+ this.permissionsMap[operation] = (0, _assign.default)({}, group);
300
169
  }
301
- if (userId && (0, _typeof2.default)(userId) === 'object') {
170
+ if (userId && typeof userId === 'object') {
302
171
  if (userId instanceof _ParseUser.default) {
303
172
  this.setReadAccess(userId, true);
304
173
  this.setWriteAccess(userId, true);
@@ -306,31 +175,29 @@ var ParseCLP = /*#__PURE__*/function () {
306
175
  this.setRoleReadAccess(userId, true);
307
176
  this.setRoleWriteAccess(userId, true);
308
177
  } else {
309
- for (var _permission in userId) {
178
+ for (const permission in userId) {
310
179
  var _context;
311
- var users = userId[_permission];
312
- var isValidPermission = !!VALID_PERMISSIONS.get(_permission);
313
- var isValidPermissionExtended = !!VALID_PERMISSIONS_EXTENDED.get(_permission);
314
- var isValidGroupPermission = (0, _includes.default)(_context = ['readUserFields', 'writeUserFields']).call(_context, _permission);
315
- if (typeof _permission !== 'string' || !(isValidPermission || isValidPermissionExtended || isValidGroupPermission)) {
180
+ const users = userId[permission];
181
+ const isValidPermission = !!VALID_PERMISSIONS.get(permission);
182
+ const isValidPermissionExtended = !!VALID_PERMISSIONS_EXTENDED.get(permission);
183
+ const isValidGroupPermission = (0, _includes.default)(_context = ['readUserFields', 'writeUserFields']).call(_context, permission);
184
+ if (typeof permission !== 'string' || !(isValidPermission || isValidPermissionExtended || isValidGroupPermission)) {
316
185
  throw new TypeError('Tried to create an CLP with an invalid permission type.');
317
186
  }
318
187
  if (isValidGroupPermission) {
319
- if ((0, _every.default)(users).call(users, function (pointer) {
320
- return typeof pointer === 'string';
321
- })) {
322
- this.permissionsMap[_permission] = users;
188
+ if ((0, _every.default)(users).call(users, pointer => typeof pointer === 'string')) {
189
+ this.permissionsMap[permission] = users;
323
190
  continue;
324
191
  } else {
325
192
  throw new TypeError('Tried to create an CLP with an invalid permission value.');
326
193
  }
327
194
  }
328
- for (var user in users) {
329
- var allowed = users[user];
195
+ for (const user in users) {
196
+ const allowed = users[user];
330
197
  if (typeof allowed !== 'boolean' && !isValidPermissionExtended && user !== 'pointerFields') {
331
198
  throw new TypeError('Tried to create an CLP with an invalid permission value.');
332
199
  }
333
- this.permissionsMap[_permission][user] = allowed;
200
+ this.permissionsMap[permission][user] = allowed;
334
201
  }
335
202
  }
336
203
  }
@@ -344,433 +211,366 @@ var ParseCLP = /*#__PURE__*/function () {
344
211
  *
345
212
  * @returns {object}
346
213
  */
347
- (0, _createClass2.default)(ParseCLP, [{
348
- key: "toJSON",
349
- value: function toJSON() /*: PermissionsMap*/{
350
- return _objectSpread({}, this.permissionsMap);
351
- }
214
+ toJSON() {
215
+ return {
216
+ ...this.permissionsMap
217
+ };
218
+ }
352
219
 
353
- /**
354
- * Returns whether this CLP is equal to another object
355
- *
356
- * @param other The other object to compare to
357
- * @returns {boolean}
358
- */
359
- }, {
360
- key: "equals",
361
- value: function equals(other /*: ParseCLP*/) /*: boolean*/{
362
- if (!(other instanceof ParseCLP)) {
220
+ /**
221
+ * Returns whether this CLP is equal to another object
222
+ *
223
+ * @param other The other object to compare to
224
+ * @returns {boolean}
225
+ */
226
+ equals(other) {
227
+ if (!(other instanceof ParseCLP)) {
228
+ return false;
229
+ }
230
+ const permissions = (0, _keys.default)(this.permissionsMap);
231
+ const otherPermissions = (0, _keys.default)(other.permissionsMap);
232
+ if (permissions.length !== otherPermissions.length) {
233
+ return false;
234
+ }
235
+ for (const permission in this.permissionsMap) {
236
+ if (!other.permissionsMap[permission]) {
363
237
  return false;
364
238
  }
365
- var permissions = (0, _keys.default)(this.permissionsMap);
366
- var otherPermissions = (0, _keys.default)(other.permissionsMap);
367
- if (permissions.length !== otherPermissions.length) {
239
+ const users = (0, _keys.default)(this.permissionsMap[permission]);
240
+ const otherUsers = (0, _keys.default)(other.permissionsMap[permission]);
241
+ if (users.length !== otherUsers.length) {
368
242
  return false;
369
243
  }
370
- for (var _permission2 in this.permissionsMap) {
371
- if (!other.permissionsMap[_permission2]) {
244
+ for (const user in this.permissionsMap[permission]) {
245
+ if (!other.permissionsMap[permission][user]) {
372
246
  return false;
373
247
  }
374
- var users = (0, _keys.default)(this.permissionsMap[_permission2]);
375
- var otherUsers = (0, _keys.default)(other.permissionsMap[_permission2]);
376
- if (users.length !== otherUsers.length) {
248
+ if (this.permissionsMap[permission][user] !== other.permissionsMap[permission][user]) {
377
249
  return false;
378
250
  }
379
- for (var user in this.permissionsMap[_permission2]) {
380
- if (!other.permissionsMap[_permission2][user]) {
381
- return false;
382
- }
383
- if (this.permissionsMap[_permission2][user] !== other.permissionsMap[_permission2][user]) {
384
- return false;
385
- }
386
- }
387
251
  }
388
- return true;
389
252
  }
390
- }, {
391
- key: "_getRoleName",
392
- value: function _getRoleName(role /*: ParseRole | string*/) /*: string*/{
393
- var name = role;
394
- if (role instanceof _ParseRole.default) {
395
- // Normalize to the String name
396
- name = role.getName();
397
- }
398
- if (typeof name !== 'string') {
399
- throw new TypeError('role must be a Parse.Role or a String');
400
- }
401
- return "role:".concat(name);
253
+ return true;
254
+ }
255
+ _getRoleName(role) {
256
+ let name = role;
257
+ if (role instanceof _ParseRole.default) {
258
+ // Normalize to the String name
259
+ name = role.getName();
402
260
  }
403
- }, {
404
- key: "_parseEntity",
405
- value: function _parseEntity(entity /*: Entity*/) {
406
- var userId = entity;
407
- if (userId instanceof _ParseUser.default) {
408
- userId = userId.id;
409
- if (!userId) {
410
- throw new Error('Cannot get access for a Parse.User without an id.');
411
- }
412
- } else if (userId instanceof _ParseRole.default) {
413
- userId = this._getRoleName(userId);
414
- }
415
- if (typeof userId !== 'string') {
416
- throw new TypeError('userId must be a string.');
417
- }
418
- return userId;
261
+ if (typeof name !== 'string') {
262
+ throw new TypeError('role must be a Parse.Role or a String');
419
263
  }
420
- }, {
421
- key: "_setAccess",
422
- value: function _setAccess(permission /*: string*/, userId /*: Entity*/, allowed /*: boolean*/) {
423
- userId = this._parseEntity(userId);
424
- if (typeof allowed !== 'boolean') {
425
- throw new TypeError('allowed must be either true or false.');
426
- }
427
- var permissions = this.permissionsMap[permission][userId];
428
- if (!permissions) {
429
- if (!allowed) {
430
- // The user already doesn't have this permission, so no action is needed
431
- return;
432
- } else {
433
- this.permissionsMap[permission][userId] = {};
434
- }
264
+ return `role:${name}`;
265
+ }
266
+ _parseEntity(entity) {
267
+ let userId = entity;
268
+ if (userId instanceof _ParseUser.default) {
269
+ userId = userId.id;
270
+ if (!userId) {
271
+ throw new Error('Cannot get access for a Parse.User without an id.');
435
272
  }
436
- if (allowed) {
437
- this.permissionsMap[permission][userId] = true;
273
+ } else if (userId instanceof _ParseRole.default) {
274
+ userId = this._getRoleName(userId);
275
+ }
276
+ if (typeof userId !== 'string') {
277
+ throw new TypeError('userId must be a string.');
278
+ }
279
+ return userId;
280
+ }
281
+ _setAccess(permission, userId, allowed) {
282
+ userId = this._parseEntity(userId);
283
+ if (typeof allowed !== 'boolean') {
284
+ throw new TypeError('allowed must be either true or false.');
285
+ }
286
+ const permissions = this.permissionsMap[permission][userId];
287
+ if (!permissions) {
288
+ if (!allowed) {
289
+ // The user already doesn't have this permission, so no action is needed
290
+ return;
438
291
  } else {
439
- delete this.permissionsMap[permission][userId];
292
+ this.permissionsMap[permission][userId] = {};
440
293
  }
441
294
  }
442
- }, {
443
- key: "_getAccess",
444
- value: function _getAccess(permission /*: string*/, userId /*: Entity*/) /*: boolean | string[]*/{
445
- var returnBoolean = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
446
- userId = this._parseEntity(userId);
447
- var permissions = this.permissionsMap[permission][userId];
448
- if (returnBoolean) {
449
- if (!permissions) {
450
- return false;
451
- }
452
- return !!this.permissionsMap[permission][userId];
453
- }
454
- return permissions;
295
+ if (allowed) {
296
+ this.permissionsMap[permission][userId] = true;
297
+ } else {
298
+ delete this.permissionsMap[permission][userId];
455
299
  }
456
- }, {
457
- key: "_setArrayAccess",
458
- value: function _setArrayAccess(permission /*: string*/, userId /*: Entity*/, fields /*: string[]*/) {
459
- userId = this._parseEntity(userId);
460
- var permissions = this.permissionsMap[permission][userId];
300
+ }
301
+ _getAccess(permission, userId) {
302
+ let returnBoolean = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
303
+ userId = this._parseEntity(userId);
304
+ const permissions = this.permissionsMap[permission][userId];
305
+ if (returnBoolean) {
461
306
  if (!permissions) {
462
- this.permissionsMap[permission][userId] = [];
463
- }
464
- if (!fields || (0, _isArray.default)(fields) && fields.length === 0) {
465
- delete this.permissionsMap[permission][userId];
466
- } else if ((0, _isArray.default)(fields) && (0, _every.default)(fields).call(fields, function (field) {
467
- return typeof field === 'string';
468
- })) {
469
- this.permissionsMap[permission][userId] = fields;
470
- } else {
471
- throw new TypeError('fields must be an array of strings or undefined.');
307
+ return false;
472
308
  }
309
+ return !!this.permissionsMap[permission][userId];
473
310
  }
474
- }, {
475
- key: "_setGroupPointerPermission",
476
- value: function _setGroupPointerPermission(operation /*: string*/, pointerFields /*: string[]*/) {
477
- var fields = this.permissionsMap[operation];
478
- if (!fields) {
479
- this.permissionsMap[operation] = [];
480
- }
481
- if (!pointerFields || (0, _isArray.default)(pointerFields) && pointerFields.length === 0) {
482
- delete this.permissionsMap[operation];
483
- } else if ((0, _isArray.default)(pointerFields) && (0, _every.default)(pointerFields).call(pointerFields, function (field) {
484
- return typeof field === 'string';
485
- })) {
486
- this.permissionsMap[operation] = pointerFields;
487
- } else {
488
- throw new TypeError("".concat(operation, ".pointerFields must be an array of strings or undefined."));
489
- }
311
+ return permissions;
312
+ }
313
+ _setArrayAccess(permission, userId, fields) {
314
+ userId = this._parseEntity(userId);
315
+ const permissions = this.permissionsMap[permission][userId];
316
+ if (!permissions) {
317
+ this.permissionsMap[permission][userId] = [];
318
+ }
319
+ if (!fields || (0, _isArray.default)(fields) && fields.length === 0) {
320
+ delete this.permissionsMap[permission][userId];
321
+ } else if ((0, _isArray.default)(fields) && (0, _every.default)(fields).call(fields, field => typeof field === 'string')) {
322
+ this.permissionsMap[permission][userId] = fields;
323
+ } else {
324
+ throw new TypeError('fields must be an array of strings or undefined.');
490
325
  }
491
- }, {
492
- key: "_getGroupPointerPermissions",
493
- value: function _getGroupPointerPermissions(operation /*: 'readUserFields' | 'writeUserFields'*/) /*: string[]*/{
494
- return this.permissionsMap[operation] || [];
326
+ }
327
+ _setGroupPointerPermission(operation, pointerFields) {
328
+ const fields = this.permissionsMap[operation];
329
+ if (!fields) {
330
+ this.permissionsMap[operation] = [];
331
+ }
332
+ if (!pointerFields || (0, _isArray.default)(pointerFields) && pointerFields.length === 0) {
333
+ delete this.permissionsMap[operation];
334
+ } else if ((0, _isArray.default)(pointerFields) && (0, _every.default)(pointerFields).call(pointerFields, field => typeof field === 'string')) {
335
+ this.permissionsMap[operation] = pointerFields;
336
+ } else {
337
+ throw new TypeError(`${operation}.pointerFields must be an array of strings or undefined.`);
495
338
  }
339
+ }
340
+ _getGroupPointerPermissions(operation) {
341
+ return this.permissionsMap[operation] || [];
342
+ }
496
343
 
497
- /**
498
- * Sets user pointer fields to allow permission for get/count/find operations.
499
- *
500
- * @param {string[]} pointerFields User pointer fields
501
- */
502
- }, {
503
- key: "setReadUserFields",
504
- value: function setReadUserFields(pointerFields /*: string[]*/) {
505
- this._setGroupPointerPermission('readUserFields', pointerFields);
506
- }
344
+ /**
345
+ * Sets user pointer fields to allow permission for get/count/find operations.
346
+ *
347
+ * @param {string[]} pointerFields User pointer fields
348
+ */
349
+ setReadUserFields(pointerFields) {
350
+ this._setGroupPointerPermission('readUserFields', pointerFields);
351
+ }
507
352
 
508
- /**
509
- * @returns {string[]} User pointer fields
510
- */
511
- }, {
512
- key: "getReadUserFields",
513
- value: function getReadUserFields() /*: string[]*/{
514
- return this._getGroupPointerPermissions('readUserFields') || [];
515
- }
353
+ /**
354
+ * @returns {string[]} User pointer fields
355
+ */
356
+ getReadUserFields() {
357
+ return this._getGroupPointerPermissions('readUserFields') || [];
358
+ }
516
359
 
517
- /**
518
- * Sets user pointer fields to allow permission for create/delete/update/addField operations
519
- *
520
- * @param {string[]} pointerFields User pointer fields
521
- */
522
- }, {
523
- key: "setWriteUserFields",
524
- value: function setWriteUserFields(pointerFields /*: string[]*/) {
525
- this._setGroupPointerPermission('writeUserFields', pointerFields);
526
- }
360
+ /**
361
+ * Sets user pointer fields to allow permission for create/delete/update/addField operations
362
+ *
363
+ * @param {string[]} pointerFields User pointer fields
364
+ */
365
+ setWriteUserFields(pointerFields) {
366
+ this._setGroupPointerPermission('writeUserFields', pointerFields);
367
+ }
527
368
 
528
- /**
529
- * @returns {string[]} User pointer fields
530
- */
531
- }, {
532
- key: "getWriteUserFields",
533
- value: function getWriteUserFields() /*: string[]*/{
534
- return this._getGroupPointerPermissions('writeUserFields') || [];
535
- }
369
+ /**
370
+ * @returns {string[]} User pointer fields
371
+ */
372
+ getWriteUserFields() {
373
+ return this._getGroupPointerPermissions('writeUserFields') || [];
374
+ }
536
375
 
537
- /**
538
- * Sets whether the given user is allowed to retrieve fields from this class.
539
- *
540
- * @param userId An instance of Parse.User or its objectId.
541
- * @param {string[]} fields fields to be protected
542
- */
543
- }, {
544
- key: "setProtectedFields",
545
- value: function setProtectedFields(userId /*: Entity*/, fields /*: string[]*/) {
546
- this._setArrayAccess('protectedFields', userId, fields);
547
- }
376
+ /**
377
+ * Sets whether the given user is allowed to retrieve fields from this class.
378
+ *
379
+ * @param userId An instance of Parse.User or its objectId.
380
+ * @param {string[]} fields fields to be protected
381
+ */
382
+ setProtectedFields(userId, fields) {
383
+ this._setArrayAccess('protectedFields', userId, fields);
384
+ }
548
385
 
549
- /**
550
- * Returns array of fields are accessable to this user.
551
- *
552
- * @param userId An instance of Parse.User or its objectId, or a Parse.Role.
553
- * @returns {string[]}
554
- */
555
- }, {
556
- key: "getProtectedFields",
557
- value: function getProtectedFields(userId /*: Entity*/) /*: string[]*/{
558
- return this._getAccess('protectedFields', userId, false);
559
- }
386
+ /**
387
+ * Returns array of fields are accessable to this user.
388
+ *
389
+ * @param userId An instance of Parse.User or its objectId, or a Parse.Role.
390
+ * @returns {string[]}
391
+ */
392
+ getProtectedFields(userId) {
393
+ return this._getAccess('protectedFields', userId, false);
394
+ }
560
395
 
561
- /**
562
- * Sets whether the given user is allowed to read from this class.
563
- *
564
- * @param userId An instance of Parse.User or its objectId.
565
- * @param {boolean} allowed whether that user should have read access.
566
- */
567
- }, {
568
- key: "setReadAccess",
569
- value: function setReadAccess(userId /*: Entity*/, allowed /*: boolean*/) {
570
- this._setAccess('find', userId, allowed);
571
- this._setAccess('get', userId, allowed);
572
- this._setAccess('count', userId, allowed);
573
- }
396
+ /**
397
+ * Sets whether the given user is allowed to read from this class.
398
+ *
399
+ * @param userId An instance of Parse.User or its objectId.
400
+ * @param {boolean} allowed whether that user should have read access.
401
+ */
402
+ setReadAccess(userId, allowed) {
403
+ this._setAccess('find', userId, allowed);
404
+ this._setAccess('get', userId, allowed);
405
+ this._setAccess('count', userId, allowed);
406
+ }
574
407
 
575
- /**
576
- * Get whether the given user id is *explicitly* allowed to read from this class.
577
- * Even if this returns false, the user may still be able to access it if
578
- * getPublicReadAccess returns true or a role that the user belongs to has
579
- * write access.
580
- *
581
- * @param userId An instance of Parse.User or its objectId, or a Parse.Role.
582
- * @returns {boolean}
583
- */
584
- }, {
585
- key: "getReadAccess",
586
- value: function getReadAccess(userId /*: Entity*/) /*: boolean*/{
587
- return this._getAccess('find', userId) && this._getAccess('get', userId) && this._getAccess('count', userId);
588
- }
408
+ /**
409
+ * Get whether the given user id is *explicitly* allowed to read from this class.
410
+ * Even if this returns false, the user may still be able to access it if
411
+ * getPublicReadAccess returns true or a role that the user belongs to has
412
+ * write access.
413
+ *
414
+ * @param userId An instance of Parse.User or its objectId, or a Parse.Role.
415
+ * @returns {boolean}
416
+ */
417
+ getReadAccess(userId) {
418
+ return this._getAccess('find', userId) && this._getAccess('get', userId) && this._getAccess('count', userId);
419
+ }
589
420
 
590
- /**
591
- * Sets whether the given user id is allowed to write to this class.
592
- *
593
- * @param userId An instance of Parse.User or its objectId, or a Parse.Role..
594
- * @param {boolean} allowed Whether that user should have write access.
595
- */
596
- }, {
597
- key: "setWriteAccess",
598
- value: function setWriteAccess(userId /*: Entity*/, allowed /*: boolean*/) {
599
- this._setAccess('create', userId, allowed);
600
- this._setAccess('update', userId, allowed);
601
- this._setAccess('delete', userId, allowed);
602
- this._setAccess('addField', userId, allowed);
603
- }
421
+ /**
422
+ * Sets whether the given user id is allowed to write to this class.
423
+ *
424
+ * @param userId An instance of Parse.User or its objectId, or a Parse.Role..
425
+ * @param {boolean} allowed Whether that user should have write access.
426
+ */
427
+ setWriteAccess(userId, allowed) {
428
+ this._setAccess('create', userId, allowed);
429
+ this._setAccess('update', userId, allowed);
430
+ this._setAccess('delete', userId, allowed);
431
+ this._setAccess('addField', userId, allowed);
432
+ }
604
433
 
605
- /**
606
- * Gets whether the given user id is *explicitly* allowed to write to this class.
607
- * Even if this returns false, the user may still be able to write it if
608
- * getPublicWriteAccess returns true or a role that the user belongs to has
609
- * write access.
610
- *
611
- * @param userId An instance of Parse.User or its objectId, or a Parse.Role.
612
- * @returns {boolean}
613
- */
614
- }, {
615
- key: "getWriteAccess",
616
- value: function getWriteAccess(userId /*: Entity*/) /*: boolean*/{
617
- return this._getAccess('create', userId) && this._getAccess('update', userId) && this._getAccess('delete', userId) && this._getAccess('addField', userId);
618
- }
434
+ /**
435
+ * Gets whether the given user id is *explicitly* allowed to write to this class.
436
+ * Even if this returns false, the user may still be able to write it if
437
+ * getPublicWriteAccess returns true or a role that the user belongs to has
438
+ * write access.
439
+ *
440
+ * @param userId An instance of Parse.User or its objectId, or a Parse.Role.
441
+ * @returns {boolean}
442
+ */
443
+ getWriteAccess(userId) {
444
+ return this._getAccess('create', userId) && this._getAccess('update', userId) && this._getAccess('delete', userId) && this._getAccess('addField', userId);
445
+ }
619
446
 
620
- /**
621
- * Sets whether the public is allowed to read from this class.
622
- *
623
- * @param {boolean} allowed
624
- */
625
- }, {
626
- key: "setPublicReadAccess",
627
- value: function setPublicReadAccess(allowed /*: boolean*/) {
628
- this.setReadAccess(PUBLIC_KEY, allowed);
629
- }
447
+ /**
448
+ * Sets whether the public is allowed to read from this class.
449
+ *
450
+ * @param {boolean} allowed
451
+ */
452
+ setPublicReadAccess(allowed) {
453
+ this.setReadAccess(PUBLIC_KEY, allowed);
454
+ }
630
455
 
631
- /**
632
- * Gets whether the public is allowed to read from this class.
633
- *
634
- * @returns {boolean}
635
- */
636
- }, {
637
- key: "getPublicReadAccess",
638
- value: function getPublicReadAccess() /*: boolean*/{
639
- return this.getReadAccess(PUBLIC_KEY);
640
- }
456
+ /**
457
+ * Gets whether the public is allowed to read from this class.
458
+ *
459
+ * @returns {boolean}
460
+ */
461
+ getPublicReadAccess() {
462
+ return this.getReadAccess(PUBLIC_KEY);
463
+ }
641
464
 
642
- /**
643
- * Sets whether the public is allowed to write to this class.
644
- *
645
- * @param {boolean} allowed
646
- */
647
- }, {
648
- key: "setPublicWriteAccess",
649
- value: function setPublicWriteAccess(allowed /*: boolean*/) {
650
- this.setWriteAccess(PUBLIC_KEY, allowed);
651
- }
465
+ /**
466
+ * Sets whether the public is allowed to write to this class.
467
+ *
468
+ * @param {boolean} allowed
469
+ */
470
+ setPublicWriteAccess(allowed) {
471
+ this.setWriteAccess(PUBLIC_KEY, allowed);
472
+ }
652
473
 
653
- /**
654
- * Gets whether the public is allowed to write to this class.
655
- *
656
- * @returns {boolean}
657
- */
658
- }, {
659
- key: "getPublicWriteAccess",
660
- value: function getPublicWriteAccess() /*: boolean*/{
661
- return this.getWriteAccess(PUBLIC_KEY);
662
- }
474
+ /**
475
+ * Gets whether the public is allowed to write to this class.
476
+ *
477
+ * @returns {boolean}
478
+ */
479
+ getPublicWriteAccess() {
480
+ return this.getWriteAccess(PUBLIC_KEY);
481
+ }
663
482
 
664
- /**
665
- * Sets whether the public is allowed to protect fields in this class.
666
- *
667
- * @param {string[]} fields
668
- */
669
- }, {
670
- key: "setPublicProtectedFields",
671
- value: function setPublicProtectedFields(fields /*: string[]*/) {
672
- this.setProtectedFields(PUBLIC_KEY, fields);
673
- }
483
+ /**
484
+ * Sets whether the public is allowed to protect fields in this class.
485
+ *
486
+ * @param {string[]} fields
487
+ */
488
+ setPublicProtectedFields(fields) {
489
+ this.setProtectedFields(PUBLIC_KEY, fields);
490
+ }
674
491
 
675
- /**
676
- * Gets whether the public is allowed to read fields from this class.
677
- *
678
- * @returns {string[]}
679
- */
680
- }, {
681
- key: "getPublicProtectedFields",
682
- value: function getPublicProtectedFields() /*: string[]*/{
683
- return this.getProtectedFields(PUBLIC_KEY);
684
- }
492
+ /**
493
+ * Gets whether the public is allowed to read fields from this class.
494
+ *
495
+ * @returns {string[]}
496
+ */
497
+ getPublicProtectedFields() {
498
+ return this.getProtectedFields(PUBLIC_KEY);
499
+ }
685
500
 
686
- /**
687
- * Gets whether users belonging to the given role are allowed
688
- * to read from this class. Even if this returns false, the role may
689
- * still be able to write it if a parent role has read access.
690
- *
691
- * @param role The name of the role, or a Parse.Role object.
692
- * @returns {boolean} true if the role has read access. false otherwise.
693
- * @throws {TypeError} If role is neither a Parse.Role nor a String.
694
- */
695
- }, {
696
- key: "getRoleReadAccess",
697
- value: function getRoleReadAccess(role /*: ParseRole | string*/) /*: boolean*/{
698
- return this.getReadAccess(this._getRoleName(role));
699
- }
501
+ /**
502
+ * Gets whether users belonging to the given role are allowed
503
+ * to read from this class. Even if this returns false, the role may
504
+ * still be able to write it if a parent role has read access.
505
+ *
506
+ * @param role The name of the role, or a Parse.Role object.
507
+ * @returns {boolean} true if the role has read access. false otherwise.
508
+ * @throws {TypeError} If role is neither a Parse.Role nor a String.
509
+ */
510
+ getRoleReadAccess(role) {
511
+ return this.getReadAccess(this._getRoleName(role));
512
+ }
700
513
 
701
- /**
702
- * Gets whether users belonging to the given role are allowed
703
- * to write to this user. Even if this returns false, the role may
704
- * still be able to write it if a parent role has write access.
705
- *
706
- * @param role The name of the role, or a Parse.Role object.
707
- * @returns {boolean} true if the role has write access. false otherwise.
708
- * @throws {TypeError} If role is neither a Parse.Role nor a String.
709
- */
710
- }, {
711
- key: "getRoleWriteAccess",
712
- value: function getRoleWriteAccess(role /*: ParseRole | string*/) /*: boolean*/{
713
- return this.getWriteAccess(this._getRoleName(role));
714
- }
514
+ /**
515
+ * Gets whether users belonging to the given role are allowed
516
+ * to write to this user. Even if this returns false, the role may
517
+ * still be able to write it if a parent role has write access.
518
+ *
519
+ * @param role The name of the role, or a Parse.Role object.
520
+ * @returns {boolean} true if the role has write access. false otherwise.
521
+ * @throws {TypeError} If role is neither a Parse.Role nor a String.
522
+ */
523
+ getRoleWriteAccess(role) {
524
+ return this.getWriteAccess(this._getRoleName(role));
525
+ }
715
526
 
716
- /**
717
- * Sets whether users belonging to the given role are allowed
718
- * to read from this class.
719
- *
720
- * @param role The name of the role, or a Parse.Role object.
721
- * @param {boolean} allowed Whether the given role can read this object.
722
- * @throws {TypeError} If role is neither a Parse.Role nor a String.
723
- */
724
- }, {
725
- key: "setRoleReadAccess",
726
- value: function setRoleReadAccess(role /*: ParseRole | string*/, allowed /*: boolean*/) {
727
- this.setReadAccess(this._getRoleName(role), allowed);
728
- }
527
+ /**
528
+ * Sets whether users belonging to the given role are allowed
529
+ * to read from this class.
530
+ *
531
+ * @param role The name of the role, or a Parse.Role object.
532
+ * @param {boolean} allowed Whether the given role can read this object.
533
+ * @throws {TypeError} If role is neither a Parse.Role nor a String.
534
+ */
535
+ setRoleReadAccess(role, allowed) {
536
+ this.setReadAccess(this._getRoleName(role), allowed);
537
+ }
729
538
 
730
- /**
731
- * Sets whether users belonging to the given role are allowed
732
- * to write to this class.
733
- *
734
- * @param role The name of the role, or a Parse.Role object.
735
- * @param {boolean} allowed Whether the given role can write this object.
736
- * @throws {TypeError} If role is neither a Parse.Role nor a String.
737
- */
738
- }, {
739
- key: "setRoleWriteAccess",
740
- value: function setRoleWriteAccess(role /*: ParseRole | string*/, allowed /*: boolean*/) {
741
- this.setWriteAccess(this._getRoleName(role), allowed);
742
- }
539
+ /**
540
+ * Sets whether users belonging to the given role are allowed
541
+ * to write to this class.
542
+ *
543
+ * @param role The name of the role, or a Parse.Role object.
544
+ * @param {boolean} allowed Whether the given role can write this object.
545
+ * @throws {TypeError} If role is neither a Parse.Role nor a String.
546
+ */
547
+ setRoleWriteAccess(role, allowed) {
548
+ this.setWriteAccess(this._getRoleName(role), allowed);
549
+ }
743
550
 
744
- /**
745
- * Gets whether users belonging to the given role are allowed
746
- * to count to this user. Even if this returns false, the role may
747
- * still be able to count it if a parent role has count access.
748
- *
749
- * @param role The name of the role, or a Parse.Role object.
750
- * @returns {string[]}
751
- * @throws {TypeError} If role is neither a Parse.Role nor a String.
752
- */
753
- }, {
754
- key: "getRoleProtectedFields",
755
- value: function getRoleProtectedFields(role /*: ParseRole | string*/) /*: string[]*/{
756
- return this.getProtectedFields(this._getRoleName(role));
757
- }
551
+ /**
552
+ * Gets whether users belonging to the given role are allowed
553
+ * to count to this user. Even if this returns false, the role may
554
+ * still be able to count it if a parent role has count access.
555
+ *
556
+ * @param role The name of the role, or a Parse.Role object.
557
+ * @returns {string[]}
558
+ * @throws {TypeError} If role is neither a Parse.Role nor a String.
559
+ */
560
+ getRoleProtectedFields(role) {
561
+ return this.getProtectedFields(this._getRoleName(role));
562
+ }
758
563
 
759
- /**
760
- * Sets whether users belonging to the given role are allowed
761
- * to set access field in this class.
762
- *
763
- * @param role The name of the role, or a Parse.Role object.
764
- * @param {string[]} fields Fields to be protected by Role.
765
- * @throws {TypeError} If role is neither a Parse.Role nor a String.
766
- */
767
- }, {
768
- key: "setRoleProtectedFields",
769
- value: function setRoleProtectedFields(role /*: ParseRole | string*/, fields /*: string[]*/) {
770
- this.setProtectedFields(this._getRoleName(role), fields);
771
- }
772
- }]);
773
- return ParseCLP;
774
- }();
775
- var _default = ParseCLP;
776
- exports.default = _default;
564
+ /**
565
+ * Sets whether users belonging to the given role are allowed
566
+ * to set access field in this class.
567
+ *
568
+ * @param role The name of the role, or a Parse.Role object.
569
+ * @param {string[]} fields Fields to be protected by Role.
570
+ * @throws {TypeError} If role is neither a Parse.Role nor a String.
571
+ */
572
+ setRoleProtectedFields(role, fields) {
573
+ this.setProtectedFields(this._getRoleName(role), fields);
574
+ }
575
+ }
576
+ var _default = exports.default = ParseCLP;