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