parse 5.1.1-alpha.1 → 5.2.0-alpha.2

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