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