parse 5.2.0-alpha.1 → 5.2.0-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (247) hide show
  1. package/dist/parse.js +10519 -15246
  2. package/dist/parse.min.js +2 -2
  3. package/dist/parse.weapp.js +10499 -15371
  4. package/dist/parse.weapp.min.js +2 -2
  5. package/lib/browser/Analytics.js +7 -11
  6. package/lib/browser/AnonymousUtils.js +17 -22
  7. package/lib/browser/Cloud.js +23 -41
  8. package/lib/browser/CoreManager.js +71 -79
  9. package/lib/browser/CryptoController.js +14 -9
  10. package/lib/browser/EventEmitter.js +9 -2
  11. package/lib/browser/EventuallyQueue.js +156 -357
  12. package/lib/browser/FacebookUtils.js +23 -28
  13. package/lib/browser/IndexedDBStorageController.js +18 -14
  14. package/lib/browser/InstallationController.js +55 -121
  15. package/lib/browser/LiveQueryClient.js +312 -485
  16. package/lib/browser/LiveQuerySubscription.js +25 -28
  17. package/lib/browser/LocalDatastore.js +258 -624
  18. package/lib/browser/LocalDatastoreController.default.js +42 -226
  19. package/lib/browser/LocalDatastoreController.js +11 -1
  20. package/lib/browser/LocalDatastoreController.react-native.js +66 -160
  21. package/lib/browser/LocalDatastoreUtils.js +4 -7
  22. package/lib/browser/ObjectStateMutations.js +54 -96
  23. package/lib/browser/OfflineQuery.js +106 -198
  24. package/lib/browser/Parse.js +44 -60
  25. package/lib/browser/ParseACL.js +242 -288
  26. package/lib/browser/ParseCLP.js +372 -572
  27. package/lib/browser/ParseConfig.js +115 -138
  28. package/lib/browser/ParseError.js +85 -182
  29. package/lib/browser/ParseFile.js +294 -438
  30. package/lib/browser/ParseGeoPoint.js +121 -146
  31. package/lib/browser/ParseHooks.js +23 -25
  32. package/lib/browser/ParseInstallation.js +225 -367
  33. package/lib/browser/ParseLiveQuery.js +74 -148
  34. package/lib/browser/ParseObject.js +2014 -2621
  35. package/lib/browser/ParseOp.js +343 -484
  36. package/lib/browser/ParsePolygon.js +101 -120
  37. package/lib/browser/ParseQuery.js +1708 -2052
  38. package/lib/browser/ParseRelation.js +99 -118
  39. package/lib/browser/ParseRole.js +88 -140
  40. package/lib/browser/ParseSchema.js +372 -434
  41. package/lib/browser/ParseSession.js +62 -110
  42. package/lib/browser/ParseUser.js +941 -1284
  43. package/lib/browser/Push.js +15 -38
  44. package/lib/browser/RESTController.js +85 -124
  45. package/lib/browser/SingleInstanceStateController.js +57 -86
  46. package/lib/browser/Socket.weapp.js +50 -33
  47. package/lib/browser/Storage.js +23 -28
  48. package/lib/browser/StorageController.browser.js +16 -13
  49. package/lib/browser/StorageController.default.js +15 -14
  50. package/lib/browser/StorageController.js +14 -1
  51. package/lib/browser/StorageController.react-native.js +31 -30
  52. package/lib/browser/StorageController.weapp.js +19 -13
  53. package/lib/browser/TaskQueue.js +31 -43
  54. package/lib/browser/UniqueInstanceStateController.js +65 -86
  55. package/lib/browser/WebSocketController.js +11 -4
  56. package/lib/browser/Xhr.weapp.js +90 -78
  57. package/lib/browser/arrayContainsObject.js +3 -3
  58. package/lib/browser/canBeSerialized.js +10 -11
  59. package/lib/browser/decode.js +11 -11
  60. package/lib/browser/encode.js +11 -11
  61. package/lib/browser/equals.js +9 -10
  62. package/lib/browser/escape.js +2 -2
  63. package/lib/browser/isRevocableSession.js +1 -1
  64. package/lib/browser/parseDate.js +10 -10
  65. package/lib/browser/promiseUtils.js +19 -19
  66. package/lib/browser/unique.js +4 -4
  67. package/lib/browser/unsavedChildren.js +20 -21
  68. package/lib/browser/uuid.js +2 -4
  69. package/lib/node/Analytics.js +5 -9
  70. package/lib/node/AnonymousUtils.js +10 -15
  71. package/lib/node/Cloud.js +11 -11
  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 +20 -39
  76. package/lib/node/FacebookUtils.js +4 -8
  77. package/lib/node/IndexedDBStorageController.js +14 -10
  78. package/lib/node/InstallationController.js +12 -13
  79. package/lib/node/LiveQueryClient.js +23 -21
  80. package/lib/node/LiveQuerySubscription.js +6 -7
  81. package/lib/node/LocalDatastore.js +23 -23
  82. package/lib/node/LocalDatastoreController.default.js +11 -12
  83. package/lib/node/LocalDatastoreController.js +14 -1
  84. package/lib/node/LocalDatastoreController.react-native.js +25 -21
  85. package/lib/node/LocalDatastoreUtils.js +4 -7
  86. package/lib/node/ObjectStateMutations.js +12 -22
  87. package/lib/node/OfflineQuery.js +37 -23
  88. package/lib/node/Parse.js +36 -50
  89. package/lib/node/ParseACL.js +21 -30
  90. package/lib/node/ParseCLP.js +38 -40
  91. package/lib/node/ParseConfig.js +10 -17
  92. package/lib/node/ParseError.js +460 -461
  93. package/lib/node/ParseFile.js +27 -47
  94. package/lib/node/ParseGeoPoint.js +16 -17
  95. package/lib/node/ParseHooks.js +16 -18
  96. package/lib/node/ParseInstallation.js +10 -11
  97. package/lib/node/ParseLiveQuery.js +9 -14
  98. package/lib/node/ParseObject.js +142 -173
  99. package/lib/node/ParseOp.js +35 -47
  100. package/lib/node/ParsePolygon.js +14 -20
  101. package/lib/node/ParseQuery.js +100 -123
  102. package/lib/node/ParseRelation.js +10 -19
  103. package/lib/node/ParseRole.js +10 -11
  104. package/lib/node/ParseSchema.js +29 -42
  105. package/lib/node/ParseSession.js +10 -11
  106. package/lib/node/ParseUser.js +76 -87
  107. package/lib/node/Push.js +7 -12
  108. package/lib/node/RESTController.js +24 -36
  109. package/lib/node/SingleInstanceStateController.js +41 -69
  110. package/lib/node/Socket.weapp.js +23 -2
  111. package/lib/node/Storage.js +14 -19
  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 +20 -20
  116. package/lib/node/StorageController.weapp.js +14 -8
  117. package/lib/node/TaskQueue.js +2 -3
  118. package/lib/node/UniqueInstanceStateController.js +43 -63
  119. package/lib/node/WebSocketController.js +15 -2
  120. package/lib/node/Xhr.weapp.js +11 -2
  121. package/lib/node/arrayContainsObject.js +4 -4
  122. package/lib/node/canBeSerialized.js +5 -5
  123. package/lib/node/decode.js +4 -4
  124. package/lib/node/encode.js +5 -5
  125. package/lib/node/equals.js +4 -4
  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 +5 -5
  131. package/lib/node/unsavedChildren.js +5 -5
  132. package/lib/node/uuid.js +2 -4
  133. package/lib/react-native/Analytics.js +2 -2
  134. package/lib/react-native/AnonymousUtils.js +3 -4
  135. package/lib/react-native/CoreManager.js +2 -3
  136. package/lib/react-native/CryptoController.js +6 -1
  137. package/lib/react-native/EventEmitter.js +6 -1
  138. package/lib/react-native/EventuallyQueue.js +1 -2
  139. package/lib/react-native/FacebookUtils.js +1 -2
  140. package/lib/react-native/IndexedDBStorageController.js +11 -5
  141. package/lib/react-native/InstallationController.js +1 -2
  142. package/lib/react-native/LiveQueryClient.js +8 -7
  143. package/lib/react-native/LiveQuerySubscription.js +2 -4
  144. package/lib/react-native/LocalDatastore.js +3 -3
  145. package/lib/react-native/LocalDatastoreController.default.js +1 -2
  146. package/lib/react-native/LocalDatastoreController.js +11 -1
  147. package/lib/react-native/LocalDatastoreController.react-native.js +11 -12
  148. package/lib/react-native/LocalDatastoreUtils.js +3 -6
  149. package/lib/react-native/OfflineQuery.js +25 -20
  150. package/lib/react-native/Parse.js +24 -38
  151. package/lib/react-native/ParseACL.js +4 -6
  152. package/lib/react-native/ParseCLP.js +2 -4
  153. package/lib/react-native/ParseConfig.js +4 -6
  154. package/lib/react-native/ParseError.js +13 -31
  155. package/lib/react-native/ParseFile.js +3 -4
  156. package/lib/react-native/ParseGeoPoint.js +2 -4
  157. package/lib/react-native/ParseInstallation.js +13 -30
  158. package/lib/react-native/ParseLiveQuery.js +2 -4
  159. package/lib/react-native/ParseObject.js +77 -87
  160. package/lib/react-native/ParseOp.js +41 -79
  161. package/lib/react-native/ParsePolygon.js +2 -4
  162. package/lib/react-native/ParseQuery.js +43 -45
  163. package/lib/react-native/ParseRelation.js +2 -4
  164. package/lib/react-native/ParseRole.js +13 -30
  165. package/lib/react-native/ParseSchema.js +3 -5
  166. package/lib/react-native/ParseSession.js +12 -29
  167. package/lib/react-native/ParseUser.js +24 -49
  168. package/lib/react-native/RESTController.js +10 -4
  169. package/lib/react-native/SingleInstanceStateController.js +23 -37
  170. package/lib/react-native/Socket.weapp.js +9 -4
  171. package/lib/react-native/Storage.js +1 -2
  172. package/lib/react-native/StorageController.browser.js +6 -1
  173. package/lib/react-native/StorageController.default.js +6 -1
  174. package/lib/react-native/StorageController.js +13 -1
  175. package/lib/react-native/StorageController.react-native.js +11 -6
  176. package/lib/react-native/StorageController.weapp.js +6 -1
  177. package/lib/react-native/TaskQueue.js +2 -4
  178. package/lib/react-native/UniqueInstanceStateController.js +23 -37
  179. package/lib/react-native/WebSocketController.js +9 -1
  180. package/lib/react-native/Xhr.weapp.js +9 -4
  181. package/lib/react-native/unsavedChildren.js +3 -3
  182. package/lib/react-native/uuid.js +1 -2
  183. package/lib/weapp/Analytics.js +7 -11
  184. package/lib/weapp/AnonymousUtils.js +17 -22
  185. package/lib/weapp/Cloud.js +23 -41
  186. package/lib/weapp/CoreManager.js +71 -79
  187. package/lib/weapp/CryptoController.js +14 -9
  188. package/lib/weapp/EventEmitter.js +9 -2
  189. package/lib/weapp/EventuallyQueue.js +156 -357
  190. package/lib/weapp/FacebookUtils.js +23 -28
  191. package/lib/weapp/IndexedDBStorageController.js +18 -14
  192. package/lib/weapp/InstallationController.js +55 -121
  193. package/lib/weapp/LiveQueryClient.js +312 -485
  194. package/lib/weapp/LiveQuerySubscription.js +25 -28
  195. package/lib/weapp/LocalDatastore.js +258 -624
  196. package/lib/weapp/LocalDatastoreController.default.js +42 -226
  197. package/lib/weapp/LocalDatastoreController.js +11 -1
  198. package/lib/weapp/LocalDatastoreController.react-native.js +66 -160
  199. package/lib/weapp/LocalDatastoreUtils.js +4 -7
  200. package/lib/weapp/ObjectStateMutations.js +54 -96
  201. package/lib/weapp/OfflineQuery.js +106 -198
  202. package/lib/weapp/Parse.js +44 -59
  203. package/lib/weapp/ParseACL.js +242 -288
  204. package/lib/weapp/ParseCLP.js +372 -572
  205. package/lib/weapp/ParseConfig.js +115 -138
  206. package/lib/weapp/ParseError.js +85 -182
  207. package/lib/weapp/ParseFile.js +295 -440
  208. package/lib/weapp/ParseGeoPoint.js +121 -146
  209. package/lib/weapp/ParseHooks.js +23 -25
  210. package/lib/weapp/ParseInstallation.js +225 -367
  211. package/lib/weapp/ParseLiveQuery.js +74 -148
  212. package/lib/weapp/ParseObject.js +2014 -2621
  213. package/lib/weapp/ParseOp.js +343 -484
  214. package/lib/weapp/ParsePolygon.js +101 -120
  215. package/lib/weapp/ParseQuery.js +1708 -2052
  216. package/lib/weapp/ParseRelation.js +99 -118
  217. package/lib/weapp/ParseRole.js +88 -140
  218. package/lib/weapp/ParseSchema.js +372 -434
  219. package/lib/weapp/ParseSession.js +62 -110
  220. package/lib/weapp/ParseUser.js +941 -1284
  221. package/lib/weapp/Push.js +15 -38
  222. package/lib/weapp/RESTController.js +86 -125
  223. package/lib/weapp/SingleInstanceStateController.js +57 -86
  224. package/lib/weapp/Socket.weapp.js +50 -33
  225. package/lib/weapp/Storage.js +23 -28
  226. package/lib/weapp/StorageController.browser.js +16 -13
  227. package/lib/weapp/StorageController.default.js +15 -14
  228. package/lib/weapp/StorageController.js +14 -1
  229. package/lib/weapp/StorageController.react-native.js +31 -30
  230. package/lib/weapp/StorageController.weapp.js +19 -13
  231. package/lib/weapp/TaskQueue.js +31 -43
  232. package/lib/weapp/UniqueInstanceStateController.js +65 -86
  233. package/lib/weapp/WebSocketController.js +11 -4
  234. package/lib/weapp/Xhr.weapp.js +90 -78
  235. package/lib/weapp/arrayContainsObject.js +3 -3
  236. package/lib/weapp/canBeSerialized.js +10 -11
  237. package/lib/weapp/decode.js +11 -11
  238. package/lib/weapp/encode.js +11 -11
  239. package/lib/weapp/equals.js +9 -10
  240. package/lib/weapp/escape.js +2 -2
  241. package/lib/weapp/isRevocableSession.js +1 -1
  242. package/lib/weapp/parseDate.js +10 -10
  243. package/lib/weapp/promiseUtils.js +19 -19
  244. package/lib/weapp/unique.js +4 -4
  245. package/lib/weapp/unsavedChildren.js +20 -21
  246. package/lib/weapp/uuid.js +6 -8
  247. package/package.json +24 -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,47 +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
- }
12
+ var _ParseObject = _interopRequireDefault(require("./ParseObject"));
45
13
  /**
46
14
  * Represents a Role on the Parse server. Roles represent groupings of
47
15
  * Users for the purposes of granting permissions (e.g. specifying an ACL
@@ -55,24 +23,19 @@ function _isNativeReflectConstruct() {
55
23
  * @alias Parse.Role
56
24
  * @augments Parse.Object
57
25
  */
58
- var ParseRole = /*#__PURE__*/function (_ParseObject) {
59
- (0, _inherits2.default)(ParseRole, _ParseObject);
60
- var _super = _createSuper(ParseRole);
26
+ class ParseRole extends _ParseObject.default {
61
27
  /**
62
28
  * @param {string} name The name of the Role to create.
63
29
  * @param {Parse.ACL} acl The ACL for this role. Roles must have an ACL.
64
30
  * A Parse.Role is a local representation of a role persisted to the Parse
65
31
  * cloud.
66
32
  */
67
- function ParseRole(name /*: string*/, acl /*: ParseACL*/) {
68
- var _this;
69
- (0, _classCallCheck2.default)(this, ParseRole);
70
- _this = _super.call(this, '_Role');
33
+ constructor(name, acl) {
34
+ super('_Role');
71
35
  if (typeof name === 'string' && acl instanceof _ParseACL.default) {
72
- _this.setName(name);
73
- _this.setACL(acl);
36
+ this.setName(name);
37
+ this.setACL(acl);
74
38
  }
75
- return _this;
76
39
  }
77
40
 
78
41
  /**
@@ -80,110 +43,95 @@ var ParseRole = /*#__PURE__*/function (_ParseObject) {
80
43
  *
81
44
  * @returns {string} the name of the role.
82
45
  */
83
- (0, _createClass2.default)(ParseRole, [{
84
- key: "getName",
85
- value: function () /*: string | null*/{
86
- var name = this.get('name');
87
- if (name == null || typeof name === 'string') {
88
- return name;
89
- }
90
- return '';
46
+ getName() {
47
+ const name = this.get('name');
48
+ if (name == null || typeof name === 'string') {
49
+ return name;
91
50
  }
51
+ return '';
52
+ }
92
53
 
93
- /**
94
- * Sets the name for a role. This value must be set before the role has
95
- * been saved to the server, and cannot be set once the role has been
96
- * saved.
97
- *
98
- * <p>
99
- * A role's name can only contain alphanumeric characters, _, -, and
100
- * spaces.
101
- * </p>
102
- *
103
- * <p>This is equivalent to calling role.set("name", name)</p>
104
- *
105
- * @param {string} name The name of the role.
106
- * @param {object} options Standard options object with success and error
107
- * callbacks.
108
- * @returns {(ParseObject|boolean)} true if the set succeeded.
109
- */
110
- }, {
111
- key: "setName",
112
- value: function (name /*: string*/, options /*:: ?: any*/) /*: ParseObject | boolean*/{
113
- this._validateName(name);
114
- return this.set('name', name, options);
115
- }
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
+ }
116
75
 
117
- /**
118
- * Gets the Parse.Relation for the Parse.Users that are direct
119
- * children of this role. These users are granted any privileges that this
120
- * role has been granted (e.g. read or write access through ACLs). You can
121
- * add or remove users from the role through this relation.
122
- *
123
- * <p>This is equivalent to calling role.relation("users")</p>
124
- *
125
- * @returns {Parse.Relation} the relation for the users belonging to this
126
- * role.
127
- */
128
- }, {
129
- key: "getUsers",
130
- value: function () /*: ParseRelation*/{
131
- return this.relation('users');
132
- }
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
+ }
133
90
 
134
- /**
135
- * Gets the Parse.Relation for the Parse.Roles that are direct
136
- * children of this role. These roles' users are granted any privileges that
137
- * this role has been granted (e.g. read or write access through ACLs). You
138
- * can add or remove child roles from this role through this relation.
139
- *
140
- * <p>This is equivalent to calling role.relation("roles")</p>
141
- *
142
- * @returns {Parse.Relation} the relation for the roles belonging to this
143
- * role.
144
- */
145
- }, {
146
- key: "getRoles",
147
- value: function () /*: ParseRelation*/{
148
- 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.");
149
108
  }
150
- }, {
151
- key: "_validateName",
152
- value: function (newName) {
153
- if (typeof newName !== 'string') {
154
- throw new _ParseError.default(_ParseError.default.OTHER_CAUSE, "A role's name must be a String.");
155
- }
156
- if (!/^[0-9a-zA-Z\-_ ]+$/.test(newName)) {
157
- throw new _ParseError.default(_ParseError.default.OTHER_CAUSE, "A role's name can be only contain alphanumeric characters, _, " + '-, and spaces.');
158
- }
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;
159
117
  }
160
- }, {
161
- key: "validate",
162
- value: function (attrs /*: AttributeMap*/, options /*:: ?: any*/) /*: ParseError | boolean*/{
163
- var isInvalid = (0, _get2.default)((0, _getPrototypeOf2.default)(ParseRole.prototype), "validate", this)(attrs, options);
164
- if (isInvalid) {
165
- 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.");
166
125
  }
167
- if ('name' in attrs && attrs.name !== this.getName()) {
168
- var newName = attrs.name;
169
- if (this.id && this.id !== attrs.objectId) {
170
- // Check to see if the objectId being set matches this.id
171
- // This happens during a fetch -- the id is set before calling fetch
172
- // Let the name be set in this case
173
- return new _ParseError.default(_ParseError.default.OTHER_CAUSE, "A role's name can only be set before it has been saved.");
174
- }
175
- try {
176
- this._validateName(newName);
177
- } catch (e) {
178
- return e;
179
- }
126
+ try {
127
+ this._validateName(newName);
128
+ } catch (e) {
129
+ return e;
180
130
  }
181
- return false;
182
131
  }
183
- }]);
184
- return ParseRole;
185
- }(_ParseObject2.default);
132
+ return false;
133
+ }
134
+ }
186
135
  _CoreManager.default.setParseRole(ParseRole);
187
- _ParseObject2.default.registerSubclass('_Role', ParseRole);
188
- var _default = ParseRole;
189
- exports.default = _default;
136
+ _ParseObject.default.registerSubclass('_Role', ParseRole);
137
+ var _default = exports.default = ParseRole;