parse 4.0.1-beta.1 → 4.1.0-alpha.1

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