parse 3.5.1 → 4.0.0-alpha.10

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 +20 -7
  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 +18 -134
  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 +73 -302
  92. package/lib/node/ParseConfig.js +16 -91
  93. package/lib/node/ParseError.js +61 -74
  94. package/lib/node/ParseFile.js +55 -244
  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 +234 -997
  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 +19 -169
  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 +37 -30
  255. package/PATENTS +0 -37
@@ -4,36 +4,23 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _CoreManager = _interopRequireDefault(require("./CoreManager"));
9
-
10
8
  var _ParseObject = _interopRequireDefault(require("./ParseObject"));
11
-
12
9
  var _ParseCLP = _interopRequireDefault(require("./ParseCLP"));
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
 
30
-
31
19
  const FIELD_TYPES = ['String', 'Number', 'Boolean', 'Date', 'File', 'GeoPoint', 'Polygon', 'Array', 'Object', 'Pointer', 'Relation'];
32
20
  /*:: type FieldOptions = {
33
21
  required: boolean,
34
22
  defaultValue: mixed,
35
23
  };*/
36
-
37
24
  /**
38
25
  * A Parse.Schema object is for handling schema data from Parse.
39
26
  * <p>All the schemas methods require MasterKey.
@@ -51,22 +38,15 @@ const FIELD_TYPES = ['String', 'Number', 'Boolean', 'Date', 'File', 'GeoPoint',
51
38
  *
52
39
  * @alias Parse.Schema
53
40
  */
54
-
55
41
  class ParseSchema {
56
42
  /*:: className: string;*/
57
-
58
43
  /*:: _fields: { [key: string]: mixed };*/
59
-
60
44
  /*:: _indexes: { [key: string]: mixed };*/
61
-
62
45
  /*:: _clp: { [key: string]: mixed };*/
63
-
64
46
  /**
65
47
  * @param {string} className Parse Class string.
66
48
  */
67
- constructor(className
68
- /*: string*/
69
- ) {
49
+ constructor(className /*: string*/) {
70
50
  if (typeof className === 'string') {
71
51
  if (className === 'User' && _CoreManager.default.get('PERFORM_USER_REWRITE')) {
72
52
  this.className = '_User';
@@ -74,63 +54,52 @@ class ParseSchema {
74
54
  this.className = className;
75
55
  }
76
56
  }
77
-
78
57
  this._fields = {};
79
58
  this._indexes = {};
80
59
  }
60
+
81
61
  /**
82
62
  * Static method to get all schemas
83
63
  *
84
64
  * @returns {Promise} A promise that is resolved with the result when
85
65
  * the query completes.
86
66
  */
87
-
88
-
89
67
  static all() {
90
68
  const controller = _CoreManager.default.getSchemaController();
91
-
92
69
  return controller.get('').then(response => {
93
70
  if (response.results.length === 0) {
94
71
  throw new Error('Schema not found.');
95
72
  }
96
-
97
73
  return response.results;
98
74
  });
99
75
  }
76
+
100
77
  /**
101
78
  * Get the Schema from Parse
102
79
  *
103
80
  * @returns {Promise} A promise that is resolved with the result when
104
81
  * the query completes.
105
82
  */
106
-
107
-
108
83
  get() {
109
84
  this.assertClassName();
110
-
111
85
  const controller = _CoreManager.default.getSchemaController();
112
-
113
86
  return controller.get(this.className).then(response => {
114
87
  if (!response) {
115
88
  throw new Error('Schema not found.');
116
89
  }
117
-
118
90
  return response;
119
91
  });
120
92
  }
93
+
121
94
  /**
122
95
  * Create a new Schema on Parse
123
96
  *
124
97
  * @returns {Promise} A promise that is resolved with the result when
125
98
  * the query completes.
126
99
  */
127
-
128
-
129
100
  save() {
130
101
  this.assertClassName();
131
-
132
102
  const controller = _CoreManager.default.getSchemaController();
133
-
134
103
  const params = {
135
104
  className: this.className,
136
105
  fields: this._fields,
@@ -139,19 +108,16 @@ class ParseSchema {
139
108
  };
140
109
  return controller.create(this.className, params);
141
110
  }
111
+
142
112
  /**
143
113
  * Update a Schema on Parse
144
114
  *
145
115
  * @returns {Promise} A promise that is resolved with the result when
146
116
  * the query completes.
147
117
  */
148
-
149
-
150
118
  update() {
151
119
  this.assertClassName();
152
-
153
120
  const controller = _CoreManager.default.getSchemaController();
154
-
155
121
  const params = {
156
122
  className: this.className,
157
123
  fields: this._fields,
@@ -162,6 +128,7 @@ class ParseSchema {
162
128
  this._indexes = {};
163
129
  return controller.update(this.className, params);
164
130
  }
131
+
165
132
  /**
166
133
  * Removing a Schema from Parse
167
134
  * Can only be used on Schema without objects
@@ -169,15 +136,12 @@ class ParseSchema {
169
136
  * @returns {Promise} A promise that is resolved with the result when
170
137
  * the query completes.
171
138
  */
172
-
173
-
174
139
  delete() {
175
140
  this.assertClassName();
176
-
177
141
  const controller = _CoreManager.default.getSchemaController();
178
-
179
142
  return controller.delete(this.className);
180
143
  }
144
+
181
145
  /**
182
146
  * Removes all objects from a Schema (class) in Parse.
183
147
  * EXERCISE CAUTION, running this will delete all objects for this schema and cannot be reversed
@@ -185,27 +149,23 @@ class ParseSchema {
185
149
  * @returns {Promise} A promise that is resolved with the result when
186
150
  * the query completes.
187
151
  */
188
-
189
-
190
152
  purge() {
191
153
  this.assertClassName();
192
-
193
154
  const controller = _CoreManager.default.getSchemaController();
194
-
195
155
  return controller.purge(this.className);
196
156
  }
157
+
197
158
  /**
198
159
  * Assert if ClassName has been filled
199
160
  *
200
161
  * @private
201
162
  */
202
-
203
-
204
163
  assertClassName() {
205
164
  if (!this.className) {
206
165
  throw new Error('You must set a Class Name before making any request.');
207
166
  }
208
167
  }
168
+
209
169
  /**
210
170
  * Sets Class Level Permissions when creating / updating a Schema.
211
171
  * EXERCISE CAUTION, running this may override CLP for this schema and cannot be reversed
@@ -213,19 +173,15 @@ class ParseSchema {
213
173
  * @param {object | Parse.CLP} clp Class Level Permissions
214
174
  * @returns {Parse.Schema} Returns the schema, so you can chain this call.
215
175
  */
216
-
217
-
218
- setCLP(clp
219
- /*: PermissionsMap | ParseCLP*/
220
- ) {
176
+ setCLP(clp /*: PermissionsMap | ParseCLP*/) {
221
177
  if (clp instanceof _ParseCLP.default) {
222
178
  this._clp = clp.toJSON();
223
179
  } else {
224
180
  this._clp = clp;
225
181
  }
226
-
227
182
  return this;
228
183
  }
184
+
229
185
  /**
230
186
  * Adding a Field to Create / Update a Schema
231
187
  *
@@ -239,45 +195,29 @@ class ParseSchema {
239
195
  * </ul>
240
196
  * @returns {Parse.Schema} Returns the schema, so you can chain this call.
241
197
  */
242
-
243
-
244
- addField(name
245
- /*: string*/
246
- , type
247
- /*: string*/
248
- , options
249
- /*: FieldOptions*/
250
- = {}) {
198
+ addField(name /*: string*/, type /*: string*/, options /*: FieldOptions*/ = {}) {
251
199
  type = type || 'String';
252
-
253
200
  if (!name) {
254
201
  throw new Error('field name may not be null.');
255
202
  }
256
-
257
203
  if (FIELD_TYPES.indexOf(type) === -1) {
258
204
  throw new Error(`${type} is not a valid type.`);
259
205
  }
260
-
261
206
  if (type === 'Pointer') {
262
207
  return this.addPointer(name, options.targetClass, options);
263
208
  }
264
-
265
209
  if (type === 'Relation') {
266
210
  return this.addRelation(name, options.targetClass, options);
267
211
  }
268
-
269
212
  const fieldOptions = {
270
213
  type
271
214
  };
272
-
273
215
  if (typeof options.required === 'boolean') {
274
216
  fieldOptions.required = options.required;
275
217
  }
276
-
277
218
  if (options.defaultValue !== undefined) {
278
219
  fieldOptions.defaultValue = options.defaultValue;
279
220
  }
280
-
281
221
  if (type === 'Date') {
282
222
  if (options && options.defaultValue) {
283
223
  fieldOptions.defaultValue = {
@@ -286,10 +226,10 @@ class ParseSchema {
286
226
  };
287
227
  }
288
228
  }
289
-
290
229
  this._fields[name] = fieldOptions;
291
230
  return this;
292
231
  }
232
+
293
233
  /**
294
234
  * Adding an Index to Create / Update a Schema
295
235
  *
@@ -301,24 +241,17 @@ class ParseSchema {
301
241
  * schema.addIndex('index_name', { 'field': 1 });
302
242
  * </pre>
303
243
  */
304
-
305
-
306
- addIndex(name
307
- /*: string*/
308
- , index
309
- /*: any*/
310
- ) {
244
+ addIndex(name /*: string*/, index /*: any*/) {
311
245
  if (!name) {
312
246
  throw new Error('index name may not be null.');
313
247
  }
314
-
315
248
  if (!index) {
316
249
  throw new Error('index may not be null.');
317
250
  }
318
-
319
251
  this._indexes[name] = index;
320
252
  return this;
321
253
  }
254
+
322
255
  /**
323
256
  * Adding String Field
324
257
  *
@@ -326,15 +259,10 @@ class ParseSchema {
326
259
  * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
327
260
  * @returns {Parse.Schema} Returns the schema, so you can chain this call.
328
261
  */
329
-
330
-
331
- addString(name
332
- /*: string*/
333
- , options
334
- /*: FieldOptions*/
335
- ) {
262
+ addString(name /*: string*/, options /*: FieldOptions*/) {
336
263
  return this.addField(name, 'String', options);
337
264
  }
265
+
338
266
  /**
339
267
  * Adding Number Field
340
268
  *
@@ -342,15 +270,10 @@ class ParseSchema {
342
270
  * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
343
271
  * @returns {Parse.Schema} Returns the schema, so you can chain this call.
344
272
  */
345
-
346
-
347
- addNumber(name
348
- /*: string*/
349
- , options
350
- /*: FieldOptions*/
351
- ) {
273
+ addNumber(name /*: string*/, options /*: FieldOptions*/) {
352
274
  return this.addField(name, 'Number', options);
353
275
  }
276
+
354
277
  /**
355
278
  * Adding Boolean Field
356
279
  *
@@ -358,15 +281,10 @@ class ParseSchema {
358
281
  * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
359
282
  * @returns {Parse.Schema} Returns the schema, so you can chain this call.
360
283
  */
361
-
362
-
363
- addBoolean(name
364
- /*: string*/
365
- , options
366
- /*: FieldOptions*/
367
- ) {
284
+ addBoolean(name /*: string*/, options /*: FieldOptions*/) {
368
285
  return this.addField(name, 'Boolean', options);
369
286
  }
287
+
370
288
  /**
371
289
  * Adding Date Field
372
290
  *
@@ -374,15 +292,10 @@ class ParseSchema {
374
292
  * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
375
293
  * @returns {Parse.Schema} Returns the schema, so you can chain this call.
376
294
  */
377
-
378
-
379
- addDate(name
380
- /*: string*/
381
- , options
382
- /*: FieldOptions*/
383
- ) {
295
+ addDate(name /*: string*/, options /*: FieldOptions*/) {
384
296
  return this.addField(name, 'Date', options);
385
297
  }
298
+
386
299
  /**
387
300
  * Adding File Field
388
301
  *
@@ -390,15 +303,10 @@ class ParseSchema {
390
303
  * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
391
304
  * @returns {Parse.Schema} Returns the schema, so you can chain this call.
392
305
  */
393
-
394
-
395
- addFile(name
396
- /*: string*/
397
- , options
398
- /*: FieldOptions*/
399
- ) {
306
+ addFile(name /*: string*/, options /*: FieldOptions*/) {
400
307
  return this.addField(name, 'File', options);
401
308
  }
309
+
402
310
  /**
403
311
  * Adding GeoPoint Field
404
312
  *
@@ -406,15 +314,10 @@ class ParseSchema {
406
314
  * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
407
315
  * @returns {Parse.Schema} Returns the schema, so you can chain this call.
408
316
  */
409
-
410
-
411
- addGeoPoint(name
412
- /*: string*/
413
- , options
414
- /*: FieldOptions*/
415
- ) {
317
+ addGeoPoint(name /*: string*/, options /*: FieldOptions*/) {
416
318
  return this.addField(name, 'GeoPoint', options);
417
319
  }
320
+
418
321
  /**
419
322
  * Adding Polygon Field
420
323
  *
@@ -422,15 +325,10 @@ class ParseSchema {
422
325
  * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
423
326
  * @returns {Parse.Schema} Returns the schema, so you can chain this call.
424
327
  */
425
-
426
-
427
- addPolygon(name
428
- /*: string*/
429
- , options
430
- /*: FieldOptions*/
431
- ) {
328
+ addPolygon(name /*: string*/, options /*: FieldOptions*/) {
432
329
  return this.addField(name, 'Polygon', options);
433
330
  }
331
+
434
332
  /**
435
333
  * Adding Array Field
436
334
  *
@@ -438,15 +336,10 @@ class ParseSchema {
438
336
  * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
439
337
  * @returns {Parse.Schema} Returns the schema, so you can chain this call.
440
338
  */
441
-
442
-
443
- addArray(name
444
- /*: string*/
445
- , options
446
- /*: FieldOptions*/
447
- ) {
339
+ addArray(name /*: string*/, options /*: FieldOptions*/) {
448
340
  return this.addField(name, 'Array', options);
449
341
  }
342
+
450
343
  /**
451
344
  * Adding Object Field
452
345
  *
@@ -454,15 +347,10 @@ class ParseSchema {
454
347
  * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
455
348
  * @returns {Parse.Schema} Returns the schema, so you can chain this call.
456
349
  */
457
-
458
-
459
- addObject(name
460
- /*: string*/
461
- , options
462
- /*: FieldOptions*/
463
- ) {
350
+ addObject(name /*: string*/, options /*: FieldOptions*/) {
464
351
  return this.addField(name, 'Object', options);
465
352
  }
353
+
466
354
  /**
467
355
  * Adding Pointer Field
468
356
  *
@@ -471,43 +359,30 @@ class ParseSchema {
471
359
  * @param {object} options See {@link https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Schema.html#addField addField}
472
360
  * @returns {Parse.Schema} Returns the schema, so you can chain this call.
473
361
  */
474
-
475
-
476
- addPointer(name
477
- /*: string*/
478
- , targetClass
479
- /*: string*/
480
- , options
481
- /*: FieldOptions*/
482
- = {}) {
362
+ addPointer(name /*: string*/, targetClass /*: string*/, options /*: FieldOptions*/ = {}) {
483
363
  if (!name) {
484
364
  throw new Error('field name may not be null.');
485
365
  }
486
-
487
366
  if (!targetClass) {
488
367
  throw new Error('You need to set the targetClass of the Pointer.');
489
368
  }
490
-
491
369
  const fieldOptions = {
492
370
  type: 'Pointer',
493
371
  targetClass
494
372
  };
495
-
496
373
  if (typeof options.required === 'boolean') {
497
374
  fieldOptions.required = options.required;
498
375
  }
499
-
500
376
  if (options.defaultValue !== undefined) {
501
377
  fieldOptions.defaultValue = options.defaultValue;
502
-
503
378
  if (options.defaultValue instanceof _ParseObject.default) {
504
379
  fieldOptions.defaultValue = options.defaultValue.toPointer();
505
380
  }
506
381
  }
507
-
508
382
  this._fields[name] = fieldOptions;
509
383
  return this;
510
384
  }
385
+
511
386
  /**
512
387
  * Adding Relation Field
513
388
  *
@@ -515,130 +390,72 @@ class ParseSchema {
515
390
  * @param {string} targetClass Name of the target Pointer Class
516
391
  * @returns {Parse.Schema} Returns the schema, so you can chain this call.
517
392
  */
518
-
519
-
520
- addRelation(name
521
- /*: string*/
522
- , targetClass
523
- /*: string*/
524
- ) {
393
+ addRelation(name /*: string*/, targetClass /*: string*/) {
525
394
  if (!name) {
526
395
  throw new Error('field name may not be null.');
527
396
  }
528
-
529
397
  if (!targetClass) {
530
398
  throw new Error('You need to set the targetClass of the Relation.');
531
399
  }
532
-
533
400
  this._fields[name] = {
534
401
  type: 'Relation',
535
402
  targetClass
536
403
  };
537
404
  return this;
538
405
  }
406
+
539
407
  /**
540
408
  * Deleting a Field to Update on a Schema
541
409
  *
542
410
  * @param {string} name Name of the field
543
411
  * @returns {Parse.Schema} Returns the schema, so you can chain this call.
544
412
  */
545
-
546
-
547
- deleteField(name
548
- /*: string*/
549
- ) {
413
+ deleteField(name /*: string*/) {
550
414
  this._fields[name] = {
551
415
  __op: 'Delete'
552
416
  };
553
417
  return this;
554
418
  }
419
+
555
420
  /**
556
421
  * Deleting an Index to Update on a Schema
557
422
  *
558
423
  * @param {string} name Name of the field
559
424
  * @returns {Parse.Schema} Returns the schema, so you can chain this call.
560
425
  */
561
-
562
-
563
- deleteIndex(name
564
- /*: string*/
565
- ) {
426
+ deleteIndex(name /*: string*/) {
566
427
  this._indexes[name] = {
567
428
  __op: 'Delete'
568
429
  };
569
430
  return this;
570
431
  }
571
-
572
432
  }
573
-
574
433
  const DefaultController = {
575
- send(className
576
- /*: string*/
577
- , method
578
- /*: string*/
579
- , params
580
- /*: any*/
581
- = {})
582
- /*: Promise*/
583
- {
434
+ send(className /*: string*/, method /*: string*/, params /*: any*/ = {}) /*: Promise*/{
584
435
  const RESTController = _CoreManager.default.getRESTController();
585
-
586
436
  return RESTController.request(method, `schemas/${className}`, params, {
587
437
  useMasterKey: true
588
438
  });
589
439
  },
590
-
591
- get(className
592
- /*: string*/
593
- )
594
- /*: Promise*/
595
- {
440
+ get(className /*: string*/) /*: Promise*/{
596
441
  return this.send(className, 'GET');
597
442
  },
598
-
599
- create(className
600
- /*: string*/
601
- , params
602
- /*: any*/
603
- )
604
- /*: Promise*/
605
- {
443
+ create(className /*: string*/, params /*: any*/) /*: Promise*/{
606
444
  return this.send(className, 'POST', params);
607
445
  },
608
-
609
- update(className
610
- /*: string*/
611
- , params
612
- /*: any*/
613
- )
614
- /*: Promise*/
615
- {
446
+ update(className /*: string*/, params /*: any*/) /*: Promise*/{
616
447
  return this.send(className, 'PUT', params);
617
448
  },
618
-
619
- delete(className
620
- /*: string*/
621
- )
622
- /*: Promise*/
623
- {
449
+ delete(className /*: string*/) /*: Promise*/{
624
450
  return this.send(className, 'DELETE');
625
451
  },
626
-
627
- purge(className
628
- /*: string*/
629
- )
630
- /*: Promise*/
631
- {
452
+ purge(className /*: string*/) /*: Promise*/{
632
453
  const RESTController = _CoreManager.default.getRESTController();
633
-
634
454
  return RESTController.request('DELETE', `purge/${className}`, {}, {
635
455
  useMasterKey: true
636
456
  });
637
457
  }
638
-
639
458
  };
640
-
641
459
  _CoreManager.default.setSchemaController(DefaultController);
642
-
643
460
  var _default = ParseSchema;
644
461
  exports.default = _default;