parse 4.0.0-alpha.1 → 4.0.0-alpha.11

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 (255) hide show
  1. package/LICENSE +167 -25
  2. package/NOTICE +10 -0
  3. package/README.md +6 -5
  4. package/dist/parse.js +12838 -21190
  5. package/dist/parse.min.js +7 -6
  6. package/dist/parse.weapp.js +7921 -17062
  7. package/dist/parse.weapp.min.js +7 -6
  8. package/lib/browser/Analytics.js +2 -27
  9. package/lib/browser/AnonymousUtils.js +6 -42
  10. package/lib/browser/Cloud.js +12 -77
  11. package/lib/browser/CloudCode.js +0 -3
  12. package/lib/browser/CoreManager.js +46 -191
  13. package/lib/browser/CryptoController.js +2 -16
  14. package/lib/browser/EventEmitter.js +1 -8
  15. package/lib/browser/EventuallyQueue.js +277 -824
  16. package/lib/browser/FacebookUtils.js +6 -42
  17. package/lib/browser/IndexedDBStorageController.js +3 -14
  18. package/lib/browser/InstallationController.js +2 -20
  19. package/lib/browser/LiveQueryClient.js +105 -213
  20. package/lib/browser/LiveQuerySubscription.js +10 -39
  21. package/lib/browser/LocalDatastore.js +451 -1081
  22. package/lib/browser/LocalDatastoreController.js +145 -602
  23. package/lib/browser/LocalDatastoreController.react-native.js +137 -573
  24. package/lib/browser/LocalDatastoreUtils.js +2 -19
  25. package/lib/browser/ObjectStateMutations.js +18 -121
  26. package/lib/browser/OfflineQuery.js +61 -222
  27. package/lib/browser/Parse.js +12 -115
  28. package/lib/browser/ParseACL.js +33 -148
  29. package/lib/browser/ParseCLP.js +96 -314
  30. package/lib/browser/ParseConfig.js +18 -95
  31. package/lib/browser/ParseError.js +63 -99
  32. package/lib/browser/ParseFile.js +128 -685
  33. package/lib/browser/ParseGeoPoint.js +23 -89
  34. package/lib/browser/ParseHooks.js +1 -34
  35. package/lib/browser/ParseInstallation.js +4 -32
  36. package/lib/browser/ParseLiveQuery.js +96 -505
  37. package/lib/browser/ParseObject.js +665 -1845
  38. package/lib/browser/ParseOp.js +41 -287
  39. package/lib/browser/ParsePolygon.js +13 -70
  40. package/lib/browser/ParseQuery.js +403 -1504
  41. package/lib/browser/ParseRelation.js +12 -68
  42. package/lib/browser/ParseRole.js +13 -75
  43. package/lib/browser/ParseSchema.js +49 -208
  44. package/lib/browser/ParseSession.js +11 -69
  45. package/lib/browser/ParseUser.js +274 -1127
  46. package/lib/browser/Push.js +7 -50
  47. package/lib/browser/RESTController.js +28 -157
  48. package/lib/browser/SingleInstanceStateController.js +19 -144
  49. package/lib/browser/Socket.weapp.js +0 -10
  50. package/lib/browser/Storage.js +10 -80
  51. package/lib/browser/StorageController.browser.js +4 -24
  52. package/lib/browser/StorageController.default.js +4 -24
  53. package/lib/browser/StorageController.react-native.js +6 -40
  54. package/lib/browser/StorageController.weapp.js +5 -23
  55. package/lib/browser/TaskQueue.js +1 -29
  56. package/lib/browser/UniqueInstanceStateController.js +19 -149
  57. package/lib/browser/Xhr.weapp.js +0 -17
  58. package/lib/browser/arrayContainsObject.js +2 -23
  59. package/lib/browser/canBeSerialized.js +3 -40
  60. package/lib/browser/decode.js +3 -40
  61. package/lib/browser/encode.js +9 -77
  62. package/lib/browser/equals.js +2 -34
  63. package/lib/browser/escape.js +1 -15
  64. package/lib/browser/isRevocableSession.js +2 -18
  65. package/lib/browser/parseDate.js +2 -20
  66. package/lib/browser/promiseUtils.js +3 -21
  67. package/lib/browser/unique.js +3 -24
  68. package/lib/browser/unsavedChildren.js +6 -57
  69. package/lib/browser/uuid.js +3 -1
  70. package/lib/node/Analytics.js +1 -25
  71. package/lib/node/AnonymousUtils.js +5 -44
  72. package/lib/node/Cloud.js +10 -73
  73. package/lib/node/CloudCode.js +0 -3
  74. package/lib/node/CoreManager.js +47 -227
  75. package/lib/node/CryptoController.js +2 -16
  76. package/lib/node/EventEmitter.js +1 -8
  77. package/lib/node/EventuallyQueue.js +16 -123
  78. package/lib/node/FacebookUtils.js +5 -44
  79. package/lib/node/IndexedDBStorageController.js +3 -19
  80. package/lib/node/InstallationController.js +2 -22
  81. package/lib/node/LiveQueryClient.js +72 -154
  82. package/lib/node/LiveQuerySubscription.js +7 -26
  83. package/lib/node/LocalDatastore.js +19 -182
  84. package/lib/node/LocalDatastoreController.js +6 -45
  85. package/lib/node/LocalDatastoreController.react-native.js +6 -52
  86. package/lib/node/LocalDatastoreUtils.js +1 -13
  87. package/lib/node/ObjectStateMutations.js +13 -100
  88. package/lib/node/OfflineQuery.js +27 -151
  89. package/lib/node/Parse.js +11 -108
  90. package/lib/node/ParseACL.js +32 -157
  91. package/lib/node/ParseCLP.js +69 -269
  92. package/lib/node/ParseConfig.js +16 -91
  93. package/lib/node/ParseError.js +61 -74
  94. package/lib/node/ParseFile.js +49 -212
  95. package/lib/node/ParseGeoPoint.js +21 -89
  96. package/lib/node/ParseHooks.js +0 -35
  97. package/lib/node/ParseInstallation.js +1 -17
  98. package/lib/node/ParseLiveQuery.js +10 -43
  99. package/lib/node/ParseObject.js +229 -964
  100. package/lib/node/ParseOp.js +31 -262
  101. package/lib/node/ParsePolygon.js +12 -69
  102. package/lib/node/ParseQuery.js +169 -888
  103. package/lib/node/ParseRelation.js +11 -68
  104. package/lib/node/ParseRole.js +10 -64
  105. package/lib/node/ParseSchema.js +46 -229
  106. package/lib/node/ParseSession.js +8 -57
  107. package/lib/node/ParseUser.js +107 -583
  108. package/lib/node/Push.js +4 -44
  109. package/lib/node/RESTController.js +18 -127
  110. package/lib/node/SingleInstanceStateController.js +17 -137
  111. package/lib/node/Socket.weapp.js +0 -7
  112. package/lib/node/Storage.js +10 -90
  113. package/lib/node/StorageController.browser.js +4 -30
  114. package/lib/node/StorageController.default.js +5 -28
  115. package/lib/node/StorageController.react-native.js +6 -47
  116. package/lib/node/StorageController.weapp.js +6 -28
  117. package/lib/node/TaskQueue.js +1 -24
  118. package/lib/node/UniqueInstanceStateController.js +16 -140
  119. package/lib/node/Xhr.weapp.js +0 -15
  120. package/lib/node/arrayContainsObject.js +1 -19
  121. package/lib/node/canBeSerialized.js +2 -35
  122. package/lib/node/decode.js +1 -33
  123. package/lib/node/encode.js +3 -61
  124. package/lib/node/equals.js +0 -27
  125. package/lib/node/escape.js +1 -13
  126. package/lib/node/isRevocableSession.js +1 -12
  127. package/lib/node/parseDate.js +1 -14
  128. package/lib/node/promiseUtils.js +2 -14
  129. package/lib/node/unique.js +1 -18
  130. package/lib/node/unsavedChildren.js +2 -45
  131. package/lib/node/uuid.js +6 -1
  132. package/lib/react-native/Analytics.js +0 -9
  133. package/lib/react-native/AnonymousUtils.js +0 -10
  134. package/lib/react-native/Cloud.js +0 -26
  135. package/lib/react-native/CoreManager.js +2 -6
  136. package/lib/react-native/CryptoController.js +0 -2
  137. package/lib/react-native/EventEmitter.js +0 -2
  138. package/lib/react-native/EventuallyQueue.js +156 -711
  139. package/lib/react-native/FacebookUtils.js +0 -22
  140. package/lib/react-native/IndexedDBStorageController.js +0 -1
  141. package/lib/react-native/InstallationController.js +0 -6
  142. package/lib/react-native/LiveQueryClient.js +46 -157
  143. package/lib/react-native/LiveQuerySubscription.js +3 -27
  144. package/lib/react-native/LocalDatastore.js +281 -948
  145. package/lib/react-native/LocalDatastoreController.js +71 -552
  146. package/lib/react-native/LocalDatastoreController.react-native.js +91 -526
  147. package/lib/react-native/LocalDatastoreUtils.js +0 -1
  148. package/lib/react-native/ObjectStateMutations.js +2 -65
  149. package/lib/react-native/OfflineQuery.js +25 -196
  150. package/lib/react-native/Parse.js +0 -65
  151. package/lib/react-native/ParseACL.js +0 -44
  152. package/lib/react-native/ParseCLP.js +23 -161
  153. package/lib/react-native/ParseConfig.js +0 -42
  154. package/lib/react-native/ParseError.js +1 -21
  155. package/lib/react-native/ParseFile.js +55 -529
  156. package/lib/react-native/ParseGeoPoint.js +0 -17
  157. package/lib/react-native/ParseHooks.js +0 -30
  158. package/lib/react-native/ParseInstallation.js +1 -23
  159. package/lib/react-native/ParseLiveQuery.js +55 -472
  160. package/lib/react-native/ParseObject.js +245 -1246
  161. package/lib/react-native/ParseOp.js +1 -138
  162. package/lib/react-native/ParsePolygon.js +0 -24
  163. package/lib/react-native/ParseQuery.js +182 -874
  164. package/lib/react-native/ParseRelation.js +0 -25
  165. package/lib/react-native/ParseRole.js +1 -36
  166. package/lib/react-native/ParseSchema.js +3 -54
  167. package/lib/react-native/ParseSession.js +1 -40
  168. package/lib/react-native/ParseUser.js +95 -773
  169. package/lib/react-native/Push.js +0 -16
  170. package/lib/react-native/RESTController.js +12 -109
  171. package/lib/react-native/SingleInstanceStateController.js +0 -44
  172. package/lib/react-native/Socket.weapp.js +0 -10
  173. package/lib/react-native/Storage.js +0 -24
  174. package/lib/react-native/StorageController.browser.js +0 -2
  175. package/lib/react-native/StorageController.default.js +0 -1
  176. package/lib/react-native/StorageController.react-native.js +0 -2
  177. package/lib/react-native/TaskQueue.js +0 -15
  178. package/lib/react-native/UniqueInstanceStateController.js +0 -47
  179. package/lib/react-native/Xhr.weapp.js +0 -16
  180. package/lib/react-native/arrayContainsObject.js +0 -5
  181. package/lib/react-native/canBeSerialized.js +0 -18
  182. package/lib/react-native/decode.js +0 -21
  183. package/lib/react-native/encode.js +0 -25
  184. package/lib/react-native/equals.js +0 -18
  185. package/lib/react-native/escape.js +0 -1
  186. package/lib/react-native/isRevocableSession.js +0 -1
  187. package/lib/react-native/parseDate.js +0 -3
  188. package/lib/react-native/promiseUtils.js +0 -13
  189. package/lib/react-native/unique.js +0 -4
  190. package/lib/react-native/unsavedChildren.js +0 -21
  191. package/lib/react-native/uuid.js +3 -1
  192. package/lib/weapp/Analytics.js +2 -27
  193. package/lib/weapp/AnonymousUtils.js +6 -42
  194. package/lib/weapp/Cloud.js +12 -77
  195. package/lib/weapp/CloudCode.js +0 -3
  196. package/lib/weapp/CoreManager.js +46 -191
  197. package/lib/weapp/CryptoController.js +2 -16
  198. package/lib/weapp/EventEmitter.js +1 -8
  199. package/lib/weapp/EventuallyQueue.js +277 -824
  200. package/lib/weapp/FacebookUtils.js +6 -42
  201. package/lib/weapp/IndexedDBStorageController.js +3 -14
  202. package/lib/weapp/InstallationController.js +2 -20
  203. package/lib/weapp/LiveQueryClient.js +105 -213
  204. package/lib/weapp/LiveQuerySubscription.js +10 -39
  205. package/lib/weapp/LocalDatastore.js +451 -1081
  206. package/lib/weapp/LocalDatastoreController.js +145 -602
  207. package/lib/weapp/LocalDatastoreController.react-native.js +137 -573
  208. package/lib/weapp/LocalDatastoreUtils.js +2 -19
  209. package/lib/weapp/ObjectStateMutations.js +18 -121
  210. package/lib/weapp/OfflineQuery.js +61 -222
  211. package/lib/weapp/Parse.js +12 -115
  212. package/lib/weapp/ParseACL.js +33 -148
  213. package/lib/weapp/ParseCLP.js +96 -314
  214. package/lib/weapp/ParseConfig.js +18 -95
  215. package/lib/weapp/ParseError.js +63 -99
  216. package/lib/weapp/ParseFile.js +129 -686
  217. package/lib/weapp/ParseGeoPoint.js +23 -89
  218. package/lib/weapp/ParseHooks.js +1 -34
  219. package/lib/weapp/ParseInstallation.js +4 -32
  220. package/lib/weapp/ParseLiveQuery.js +96 -505
  221. package/lib/weapp/ParseObject.js +665 -1845
  222. package/lib/weapp/ParseOp.js +41 -287
  223. package/lib/weapp/ParsePolygon.js +13 -70
  224. package/lib/weapp/ParseQuery.js +403 -1504
  225. package/lib/weapp/ParseRelation.js +12 -68
  226. package/lib/weapp/ParseRole.js +13 -75
  227. package/lib/weapp/ParseSchema.js +49 -208
  228. package/lib/weapp/ParseSession.js +11 -69
  229. package/lib/weapp/ParseUser.js +274 -1127
  230. package/lib/weapp/Push.js +7 -50
  231. package/lib/weapp/RESTController.js +28 -157
  232. package/lib/weapp/SingleInstanceStateController.js +19 -144
  233. package/lib/weapp/Socket.weapp.js +0 -10
  234. package/lib/weapp/Storage.js +10 -80
  235. package/lib/weapp/StorageController.browser.js +4 -24
  236. package/lib/weapp/StorageController.default.js +4 -24
  237. package/lib/weapp/StorageController.react-native.js +6 -40
  238. package/lib/weapp/StorageController.weapp.js +5 -23
  239. package/lib/weapp/TaskQueue.js +1 -29
  240. package/lib/weapp/UniqueInstanceStateController.js +19 -149
  241. package/lib/weapp/Xhr.weapp.js +0 -17
  242. package/lib/weapp/arrayContainsObject.js +2 -23
  243. package/lib/weapp/canBeSerialized.js +3 -40
  244. package/lib/weapp/decode.js +3 -40
  245. package/lib/weapp/encode.js +9 -77
  246. package/lib/weapp/equals.js +2 -34
  247. package/lib/weapp/escape.js +1 -15
  248. package/lib/weapp/isRevocableSession.js +2 -18
  249. package/lib/weapp/parseDate.js +2 -20
  250. package/lib/weapp/promiseUtils.js +3 -21
  251. package/lib/weapp/unique.js +3 -24
  252. package/lib/weapp/unsavedChildren.js +6 -57
  253. package/lib/weapp/uuid.js +1 -6
  254. package/package.json +35 -31
  255. package/PATENTS +0 -37
@@ -4,26 +4,15 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _ParseOp = require("./ParseOp");
9
-
10
8
  var _ParseObject = _interopRequireDefault(require("./ParseObject"));
11
-
12
9
  var _ParseQuery = _interopRequireDefault(require("./ParseQuery"));
13
-
14
10
  function _interopRequireDefault(obj) {
15
11
  return obj && obj.__esModule ? obj : {
16
12
  default: obj
17
13
  };
18
14
  }
19
15
  /**
20
- * Copyright (c) 2015-present, Parse, LLC.
21
- * All rights reserved.
22
- *
23
- * This source code is licensed under the BSD-style license found in the
24
- * LICENSE file in the root directory of this source tree. An additional grant
25
- * of patent rights can be found in the PATENTS file in the same directory.
26
- *
27
16
  * @flow
28
17
  */
29
18
 
@@ -40,49 +29,32 @@ function _interopRequireDefault(obj) {
40
29
  *
41
30
  * @alias Parse.Relation
42
31
  */
43
-
44
-
45
32
  class ParseRelation {
46
33
  /*:: parent: ?ParseObject;*/
47
-
48
34
  /*:: key: ?string;*/
49
-
50
35
  /*:: targetClassName: ?string;*/
51
-
52
36
  /**
53
37
  * @param {Parse.Object} parent The parent of this relation.
54
38
  * @param {string} key The key for this relation on the parent.
55
39
  */
56
- constructor(parent
57
- /*: ?ParseObject*/
58
- , key
59
- /*: ?string*/
60
- ) {
40
+ constructor(parent /*: ?ParseObject*/, key /*: ?string*/) {
61
41
  this.parent = parent;
62
42
  this.key = key;
63
43
  this.targetClassName = null;
64
44
  }
45
+
65
46
  /*
66
47
  * Makes sure that this relation has the right parent and key.
67
48
  */
68
-
69
-
70
- _ensureParentAndKey(parent
71
- /*: ParseObject*/
72
- , key
73
- /*: string*/
74
- ) {
49
+ _ensureParentAndKey(parent /*: ParseObject*/, key /*: string*/) {
75
50
  this.key = this.key || key;
76
-
77
51
  if (this.key !== key) {
78
52
  throw new Error('Internal Error. Relation retrieved from two different keys.');
79
53
  }
80
-
81
54
  if (this.parent) {
82
55
  if (this.parent.className !== parent.className) {
83
56
  throw new Error('Internal Error. Relation retrieved from two different Objects.');
84
57
  }
85
-
86
58
  if (this.parent.id) {
87
59
  if (this.parent.id !== parent.id) {
88
60
  throw new Error('Internal Error. Relation retrieved from two different Objects.');
@@ -94,117 +66,88 @@ class ParseRelation {
94
66
  this.parent = parent;
95
67
  }
96
68
  }
69
+
97
70
  /**
98
71
  * Adds a Parse.Object or an array of Parse.Objects to the relation.
99
72
  *
100
73
  * @param {(Parse.Object|Array)} objects The item or items to add.
101
74
  * @returns {Parse.Object} The parent of the relation.
102
75
  */
103
-
104
-
105
- add(objects
106
- /*: ParseObject | Array<ParseObject | string>*/
107
- )
108
- /*: ParseObject*/
109
- {
76
+ add(objects /*: ParseObject | Array<ParseObject | string>*/) /*: ParseObject*/{
110
77
  if (!Array.isArray(objects)) {
111
78
  objects = [objects];
112
79
  }
113
-
114
80
  const change = new _ParseOp.RelationOp(objects, []);
115
81
  const parent = this.parent;
116
-
117
82
  if (!parent) {
118
83
  throw new Error('Cannot add to a Relation without a parent');
119
84
  }
120
-
121
85
  if (objects.length === 0) {
122
86
  return parent;
123
87
  }
124
-
125
88
  parent.set(this.key, change);
126
89
  this.targetClassName = change._targetClassName;
127
90
  return parent;
128
91
  }
92
+
129
93
  /**
130
94
  * Removes a Parse.Object or an array of Parse.Objects from this relation.
131
95
  *
132
96
  * @param {(Parse.Object|Array)} objects The item or items to remove.
133
97
  */
134
-
135
-
136
- remove(objects
137
- /*: ParseObject | Array<ParseObject | string>*/
138
- ) {
98
+ remove(objects /*: ParseObject | Array<ParseObject | string>*/) {
139
99
  if (!Array.isArray(objects)) {
140
100
  objects = [objects];
141
101
  }
142
-
143
102
  const change = new _ParseOp.RelationOp([], objects);
144
-
145
103
  if (!this.parent) {
146
104
  throw new Error('Cannot remove from a Relation without a parent');
147
105
  }
148
-
149
106
  if (objects.length === 0) {
150
107
  return;
151
108
  }
152
-
153
109
  this.parent.set(this.key, change);
154
110
  this.targetClassName = change._targetClassName;
155
111
  }
112
+
156
113
  /**
157
114
  * Returns a JSON version of the object suitable for saving to disk.
158
115
  *
159
116
  * @returns {object} JSON representation of Relation
160
117
  */
161
-
162
-
163
- toJSON()
164
- /*: { __type: 'Relation', className: ?string }*/
165
- {
118
+ toJSON() /*: { __type: 'Relation', className: ?string }*/{
166
119
  return {
167
120
  __type: 'Relation',
168
121
  className: this.targetClassName
169
122
  };
170
123
  }
124
+
171
125
  /**
172
126
  * Returns a Parse.Query that is limited to objects in this
173
127
  * relation.
174
128
  *
175
129
  * @returns {Parse.Query} Relation Query
176
130
  */
177
-
178
-
179
- query()
180
- /*: ParseQuery*/
181
- {
131
+ query() /*: ParseQuery*/{
182
132
  let query;
183
133
  const parent = this.parent;
184
-
185
134
  if (!parent) {
186
135
  throw new Error('Cannot construct a query for a Relation without a parent');
187
136
  }
188
-
189
137
  if (!this.targetClassName) {
190
138
  query = new _ParseQuery.default(parent.className);
191
139
  query._extraOptions.redirectClassNameForKey = this.key;
192
140
  } else {
193
141
  query = new _ParseQuery.default(this.targetClassName);
194
142
  }
195
-
196
143
  query._addCondition('$relatedTo', 'object', {
197
144
  __type: 'Pointer',
198
145
  className: parent.className,
199
146
  objectId: parent.id
200
147
  });
201
-
202
148
  query._addCondition('$relatedTo', 'key', this.key);
203
-
204
149
  return query;
205
150
  }
206
-
207
151
  }
208
-
209
152
  var _default = ParseRelation;
210
153
  exports.default = _default;
@@ -4,26 +4,15 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _ParseACL = _interopRequireDefault(require("./ParseACL"));
9
-
10
8
  var _ParseError = _interopRequireDefault(require("./ParseError"));
11
-
12
9
  var _ParseObject = _interopRequireDefault(require("./ParseObject"));
13
-
14
10
  function _interopRequireDefault(obj) {
15
11
  return obj && obj.__esModule ? obj : {
16
12
  default: obj
17
13
  };
18
14
  }
19
15
  /**
20
- * Copyright (c) 2015-present, Parse, LLC.
21
- * All rights reserved.
22
- *
23
- * This source code is licensed under the BSD-style license found in the
24
- * LICENSE file in the root directory of this source tree. An additional grant
25
- * of patent rights can be found in the PATENTS file in the same directory.
26
- *
27
16
  * @flow
28
17
  */
29
18
 
@@ -40,8 +29,6 @@ function _interopRequireDefault(obj) {
40
29
  * @alias Parse.Role
41
30
  * @augments Parse.Object
42
31
  */
43
-
44
-
45
32
  class ParseRole extends _ParseObject.default {
46
33
  /**
47
34
  * @param {string} name The name of the Role to create.
@@ -49,36 +36,27 @@ class ParseRole extends _ParseObject.default {
49
36
  * A Parse.Role is a local representation of a role persisted to the Parse
50
37
  * cloud.
51
38
  */
52
- constructor(name
53
- /*: string*/
54
- , acl
55
- /*: ParseACL*/
56
- ) {
39
+ constructor(name /*: string*/, acl /*: ParseACL*/) {
57
40
  super('_Role');
58
-
59
41
  if (typeof name === 'string' && acl instanceof _ParseACL.default) {
60
42
  this.setName(name);
61
43
  this.setACL(acl);
62
44
  }
63
45
  }
46
+
64
47
  /**
65
48
  * Gets the name of the role. You can alternatively call role.get("name")
66
49
  *
67
50
  * @returns {string} the name of the role.
68
51
  */
69
-
70
-
71
- getName()
72
- /*: ?string*/
73
- {
52
+ getName() /*: ?string*/{
74
53
  const name = this.get('name');
75
-
76
54
  if (name == null || typeof name === 'string') {
77
55
  return name;
78
56
  }
79
-
80
57
  return '';
81
58
  }
59
+
82
60
  /**
83
61
  * Sets the name for a role. This value must be set before the role has
84
62
  * been saved to the server, and cannot be set once the role has been
@@ -96,19 +74,11 @@ class ParseRole extends _ParseObject.default {
96
74
  * callbacks.
97
75
  * @returns {(ParseObject|boolean)} true if the set succeeded.
98
76
  */
99
-
100
-
101
- setName(name
102
- /*: string*/
103
- , options
104
- /*:: ?: mixed*/
105
- )
106
- /*: ParseObject | boolean*/
107
- {
77
+ setName(name /*: string*/, options /*:: ?: mixed*/) /*: ParseObject | boolean*/{
108
78
  this._validateName(name);
109
-
110
79
  return this.set('name', name, options);
111
80
  }
81
+
112
82
  /**
113
83
  * Gets the Parse.Relation for the Parse.Users that are direct
114
84
  * children of this role. These users are granted any privileges that this
@@ -120,13 +90,10 @@ class ParseRole extends _ParseObject.default {
120
90
  * @returns {Parse.Relation} the relation for the users belonging to this
121
91
  * role.
122
92
  */
123
-
124
-
125
- getUsers()
126
- /*: ParseRelation*/
127
- {
93
+ getUsers() /*: ParseRelation*/{
128
94
  return this.relation('users');
129
95
  }
96
+
130
97
  /**
131
98
  * Gets the Parse.Relation for the Parse.Roles that are direct
132
99
  * children of this role. These roles' users are granted any privileges that
@@ -138,60 +105,39 @@ class ParseRole extends _ParseObject.default {
138
105
  * @returns {Parse.Relation} the relation for the roles belonging to this
139
106
  * role.
140
107
  */
141
-
142
-
143
- getRoles()
144
- /*: ParseRelation*/
145
- {
108
+ getRoles() /*: ParseRelation*/{
146
109
  return this.relation('roles');
147
110
  }
148
-
149
111
  _validateName(newName) {
150
112
  if (typeof newName !== 'string') {
151
113
  throw new _ParseError.default(_ParseError.default.OTHER_CAUSE, "A role's name must be a String.");
152
114
  }
153
-
154
115
  if (!/^[0-9a-zA-Z\-_ ]+$/.test(newName)) {
155
116
  throw new _ParseError.default(_ParseError.default.OTHER_CAUSE, "A role's name can be only contain alphanumeric characters, _, " + '-, and spaces.');
156
117
  }
157
118
  }
158
-
159
- validate(attrs
160
- /*: AttributeMap*/
161
- , options
162
- /*:: ?: mixed*/
163
- )
164
- /*: ParseError | boolean*/
165
- {
119
+ validate(attrs /*: AttributeMap*/, options /*:: ?: mixed*/) /*: ParseError | boolean*/{
166
120
  const isInvalid = super.validate(attrs, options);
167
-
168
121
  if (isInvalid) {
169
122
  return isInvalid;
170
123
  }
171
-
172
124
  if ('name' in attrs && attrs.name !== this.getName()) {
173
125
  const newName = attrs.name;
174
-
175
126
  if (this.id && this.id !== attrs.objectId) {
176
127
  // Check to see if the objectId being set matches this.id
177
128
  // This happens during a fetch -- the id is set before calling fetch
178
129
  // Let the name be set in this case
179
130
  return new _ParseError.default(_ParseError.default.OTHER_CAUSE, "A role's name can only be set before it has been saved.");
180
131
  }
181
-
182
132
  try {
183
133
  this._validateName(newName);
184
134
  } catch (e) {
185
135
  return e;
186
136
  }
187
137
  }
188
-
189
138
  return false;
190
139
  }
191
-
192
140
  }
193
-
194
141
  _ParseObject.default.registerSubclass('_Role', ParseRole);
195
-
196
142
  var _default = ParseRole;
197
143
  exports.default = _default;