parse 5.2.0-alpha.1 → 5.2.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (247) hide show
  1. package/dist/parse.js +10102 -15029
  2. package/dist/parse.min.js +2 -2
  3. package/dist/parse.weapp.js +10093 -15165
  4. package/dist/parse.weapp.min.js +2 -2
  5. package/lib/browser/Analytics.js +7 -11
  6. package/lib/browser/AnonymousUtils.js +17 -22
  7. package/lib/browser/Cloud.js +23 -41
  8. package/lib/browser/CoreManager.js +71 -79
  9. package/lib/browser/CryptoController.js +14 -9
  10. package/lib/browser/EventEmitter.js +9 -2
  11. package/lib/browser/EventuallyQueue.js +156 -357
  12. package/lib/browser/FacebookUtils.js +23 -28
  13. package/lib/browser/IndexedDBStorageController.js +18 -14
  14. package/lib/browser/InstallationController.js +55 -121
  15. package/lib/browser/LiveQueryClient.js +308 -484
  16. package/lib/browser/LiveQuerySubscription.js +25 -28
  17. package/lib/browser/LocalDatastore.js +258 -624
  18. package/lib/browser/LocalDatastoreController.default.js +42 -226
  19. package/lib/browser/LocalDatastoreController.js +11 -1
  20. package/lib/browser/LocalDatastoreController.react-native.js +66 -160
  21. package/lib/browser/LocalDatastoreUtils.js +4 -7
  22. package/lib/browser/ObjectStateMutations.js +54 -96
  23. package/lib/browser/OfflineQuery.js +106 -198
  24. package/lib/browser/Parse.js +44 -60
  25. package/lib/browser/ParseACL.js +242 -288
  26. package/lib/browser/ParseCLP.js +372 -572
  27. package/lib/browser/ParseConfig.js +115 -138
  28. package/lib/browser/ParseError.js +85 -182
  29. package/lib/browser/ParseFile.js +294 -438
  30. package/lib/browser/ParseGeoPoint.js +121 -146
  31. package/lib/browser/ParseHooks.js +23 -25
  32. package/lib/browser/ParseInstallation.js +225 -367
  33. package/lib/browser/ParseLiveQuery.js +74 -148
  34. package/lib/browser/ParseObject.js +2014 -2621
  35. package/lib/browser/ParseOp.js +343 -484
  36. package/lib/browser/ParsePolygon.js +101 -120
  37. package/lib/browser/ParseQuery.js +1708 -2052
  38. package/lib/browser/ParseRelation.js +99 -118
  39. package/lib/browser/ParseRole.js +88 -140
  40. package/lib/browser/ParseSchema.js +372 -434
  41. package/lib/browser/ParseSession.js +62 -110
  42. package/lib/browser/ParseUser.js +941 -1284
  43. package/lib/browser/Push.js +15 -38
  44. package/lib/browser/RESTController.js +85 -124
  45. package/lib/browser/SingleInstanceStateController.js +57 -86
  46. package/lib/browser/Socket.weapp.js +50 -33
  47. package/lib/browser/Storage.js +23 -28
  48. package/lib/browser/StorageController.browser.js +16 -13
  49. package/lib/browser/StorageController.default.js +15 -14
  50. package/lib/browser/StorageController.js +14 -1
  51. package/lib/browser/StorageController.react-native.js +31 -30
  52. package/lib/browser/StorageController.weapp.js +19 -13
  53. package/lib/browser/TaskQueue.js +31 -43
  54. package/lib/browser/UniqueInstanceStateController.js +65 -86
  55. package/lib/browser/WebSocketController.js +11 -4
  56. package/lib/browser/Xhr.weapp.js +90 -78
  57. package/lib/browser/arrayContainsObject.js +3 -3
  58. package/lib/browser/canBeSerialized.js +10 -11
  59. package/lib/browser/decode.js +11 -11
  60. package/lib/browser/encode.js +11 -11
  61. package/lib/browser/equals.js +9 -10
  62. package/lib/browser/escape.js +2 -2
  63. package/lib/browser/isRevocableSession.js +1 -1
  64. package/lib/browser/parseDate.js +10 -10
  65. package/lib/browser/promiseUtils.js +19 -19
  66. package/lib/browser/unique.js +4 -4
  67. package/lib/browser/unsavedChildren.js +20 -21
  68. package/lib/browser/uuid.js +2 -4
  69. package/lib/node/Analytics.js +2 -6
  70. package/lib/node/AnonymousUtils.js +7 -12
  71. package/lib/node/Cloud.js +8 -8
  72. package/lib/node/CoreManager.js +59 -67
  73. package/lib/node/CryptoController.js +8 -3
  74. package/lib/node/EventEmitter.js +7 -1
  75. package/lib/node/EventuallyQueue.js +17 -36
  76. package/lib/node/FacebookUtils.js +1 -5
  77. package/lib/node/IndexedDBStorageController.js +14 -10
  78. package/lib/node/InstallationController.js +9 -10
  79. package/lib/node/LiveQueryClient.js +12 -14
  80. package/lib/node/LiveQuerySubscription.js +3 -4
  81. package/lib/node/LocalDatastore.js +20 -20
  82. package/lib/node/LocalDatastoreController.default.js +8 -9
  83. package/lib/node/LocalDatastoreController.js +14 -1
  84. package/lib/node/LocalDatastoreController.react-native.js +25 -21
  85. package/lib/node/LocalDatastoreUtils.js +4 -7
  86. package/lib/node/ObjectStateMutations.js +9 -19
  87. package/lib/node/OfflineQuery.js +37 -23
  88. package/lib/node/Parse.js +33 -47
  89. package/lib/node/ParseACL.js +18 -27
  90. package/lib/node/ParseCLP.js +35 -37
  91. package/lib/node/ParseConfig.js +7 -14
  92. package/lib/node/ParseError.js +457 -458
  93. package/lib/node/ParseFile.js +24 -44
  94. package/lib/node/ParseGeoPoint.js +16 -17
  95. package/lib/node/ParseHooks.js +13 -15
  96. package/lib/node/ParseInstallation.js +7 -8
  97. package/lib/node/ParseLiveQuery.js +6 -11
  98. package/lib/node/ParseObject.js +139 -170
  99. package/lib/node/ParseOp.js +32 -44
  100. package/lib/node/ParsePolygon.js +11 -17
  101. package/lib/node/ParseQuery.js +97 -120
  102. package/lib/node/ParseRelation.js +7 -16
  103. package/lib/node/ParseRole.js +7 -8
  104. package/lib/node/ParseSchema.js +26 -39
  105. package/lib/node/ParseSession.js +7 -8
  106. package/lib/node/ParseUser.js +73 -84
  107. package/lib/node/Push.js +4 -9
  108. package/lib/node/RESTController.js +21 -33
  109. package/lib/node/SingleInstanceStateController.js +41 -69
  110. package/lib/node/Socket.weapp.js +23 -2
  111. package/lib/node/Storage.js +11 -16
  112. package/lib/node/StorageController.browser.js +10 -8
  113. package/lib/node/StorageController.default.js +9 -9
  114. package/lib/node/StorageController.js +16 -1
  115. package/lib/node/StorageController.react-native.js +17 -17
  116. package/lib/node/StorageController.weapp.js +14 -8
  117. package/lib/node/TaskQueue.js +2 -3
  118. package/lib/node/UniqueInstanceStateController.js +40 -60
  119. package/lib/node/WebSocketController.js +15 -2
  120. package/lib/node/Xhr.weapp.js +11 -2
  121. package/lib/node/arrayContainsObject.js +1 -1
  122. package/lib/node/canBeSerialized.js +2 -2
  123. package/lib/node/decode.js +1 -1
  124. package/lib/node/encode.js +2 -2
  125. package/lib/node/equals.js +1 -1
  126. package/lib/node/escape.js +1 -1
  127. package/lib/node/isRevocableSession.js +1 -1
  128. package/lib/node/parseDate.js +1 -1
  129. package/lib/node/promiseUtils.js +7 -7
  130. package/lib/node/unique.js +2 -2
  131. package/lib/node/unsavedChildren.js +2 -2
  132. package/lib/node/uuid.js +2 -4
  133. package/lib/react-native/Analytics.js +2 -2
  134. package/lib/react-native/AnonymousUtils.js +3 -4
  135. package/lib/react-native/CoreManager.js +2 -3
  136. package/lib/react-native/CryptoController.js +6 -1
  137. package/lib/react-native/EventEmitter.js +6 -1
  138. package/lib/react-native/EventuallyQueue.js +1 -2
  139. package/lib/react-native/FacebookUtils.js +1 -2
  140. package/lib/react-native/IndexedDBStorageController.js +11 -5
  141. package/lib/react-native/InstallationController.js +1 -2
  142. package/lib/react-native/LiveQueryClient.js +2 -4
  143. package/lib/react-native/LiveQuerySubscription.js +2 -4
  144. package/lib/react-native/LocalDatastore.js +3 -3
  145. package/lib/react-native/LocalDatastoreController.default.js +1 -2
  146. package/lib/react-native/LocalDatastoreController.js +11 -1
  147. package/lib/react-native/LocalDatastoreController.react-native.js +11 -12
  148. package/lib/react-native/LocalDatastoreUtils.js +3 -6
  149. package/lib/react-native/OfflineQuery.js +25 -20
  150. package/lib/react-native/Parse.js +24 -38
  151. package/lib/react-native/ParseACL.js +4 -6
  152. package/lib/react-native/ParseCLP.js +2 -4
  153. package/lib/react-native/ParseConfig.js +4 -6
  154. package/lib/react-native/ParseError.js +13 -31
  155. package/lib/react-native/ParseFile.js +3 -4
  156. package/lib/react-native/ParseGeoPoint.js +2 -4
  157. package/lib/react-native/ParseInstallation.js +13 -30
  158. package/lib/react-native/ParseLiveQuery.js +2 -4
  159. package/lib/react-native/ParseObject.js +77 -87
  160. package/lib/react-native/ParseOp.js +41 -79
  161. package/lib/react-native/ParsePolygon.js +2 -4
  162. package/lib/react-native/ParseQuery.js +43 -45
  163. package/lib/react-native/ParseRelation.js +2 -4
  164. package/lib/react-native/ParseRole.js +13 -30
  165. package/lib/react-native/ParseSchema.js +3 -5
  166. package/lib/react-native/ParseSession.js +12 -29
  167. package/lib/react-native/ParseUser.js +24 -49
  168. package/lib/react-native/RESTController.js +10 -4
  169. package/lib/react-native/SingleInstanceStateController.js +23 -37
  170. package/lib/react-native/Socket.weapp.js +9 -4
  171. package/lib/react-native/Storage.js +1 -2
  172. package/lib/react-native/StorageController.browser.js +6 -1
  173. package/lib/react-native/StorageController.default.js +6 -1
  174. package/lib/react-native/StorageController.js +13 -1
  175. package/lib/react-native/StorageController.react-native.js +11 -6
  176. package/lib/react-native/StorageController.weapp.js +6 -1
  177. package/lib/react-native/TaskQueue.js +2 -4
  178. package/lib/react-native/UniqueInstanceStateController.js +23 -37
  179. package/lib/react-native/WebSocketController.js +9 -1
  180. package/lib/react-native/Xhr.weapp.js +9 -4
  181. package/lib/react-native/unsavedChildren.js +3 -3
  182. package/lib/react-native/uuid.js +1 -2
  183. package/lib/weapp/Analytics.js +7 -11
  184. package/lib/weapp/AnonymousUtils.js +17 -22
  185. package/lib/weapp/Cloud.js +23 -41
  186. package/lib/weapp/CoreManager.js +71 -79
  187. package/lib/weapp/CryptoController.js +14 -9
  188. package/lib/weapp/EventEmitter.js +9 -2
  189. package/lib/weapp/EventuallyQueue.js +156 -357
  190. package/lib/weapp/FacebookUtils.js +23 -28
  191. package/lib/weapp/IndexedDBStorageController.js +18 -14
  192. package/lib/weapp/InstallationController.js +55 -121
  193. package/lib/weapp/LiveQueryClient.js +308 -484
  194. package/lib/weapp/LiveQuerySubscription.js +25 -28
  195. package/lib/weapp/LocalDatastore.js +258 -624
  196. package/lib/weapp/LocalDatastoreController.default.js +42 -226
  197. package/lib/weapp/LocalDatastoreController.js +11 -1
  198. package/lib/weapp/LocalDatastoreController.react-native.js +66 -160
  199. package/lib/weapp/LocalDatastoreUtils.js +4 -7
  200. package/lib/weapp/ObjectStateMutations.js +54 -96
  201. package/lib/weapp/OfflineQuery.js +106 -198
  202. package/lib/weapp/Parse.js +44 -59
  203. package/lib/weapp/ParseACL.js +242 -288
  204. package/lib/weapp/ParseCLP.js +372 -572
  205. package/lib/weapp/ParseConfig.js +115 -138
  206. package/lib/weapp/ParseError.js +85 -182
  207. package/lib/weapp/ParseFile.js +295 -440
  208. package/lib/weapp/ParseGeoPoint.js +121 -146
  209. package/lib/weapp/ParseHooks.js +23 -25
  210. package/lib/weapp/ParseInstallation.js +225 -367
  211. package/lib/weapp/ParseLiveQuery.js +74 -148
  212. package/lib/weapp/ParseObject.js +2014 -2621
  213. package/lib/weapp/ParseOp.js +343 -484
  214. package/lib/weapp/ParsePolygon.js +101 -120
  215. package/lib/weapp/ParseQuery.js +1708 -2052
  216. package/lib/weapp/ParseRelation.js +99 -118
  217. package/lib/weapp/ParseRole.js +88 -140
  218. package/lib/weapp/ParseSchema.js +372 -434
  219. package/lib/weapp/ParseSession.js +62 -110
  220. package/lib/weapp/ParseUser.js +941 -1284
  221. package/lib/weapp/Push.js +15 -38
  222. package/lib/weapp/RESTController.js +86 -125
  223. package/lib/weapp/SingleInstanceStateController.js +57 -86
  224. package/lib/weapp/Socket.weapp.js +50 -33
  225. package/lib/weapp/Storage.js +23 -28
  226. package/lib/weapp/StorageController.browser.js +16 -13
  227. package/lib/weapp/StorageController.default.js +15 -14
  228. package/lib/weapp/StorageController.js +14 -1
  229. package/lib/weapp/StorageController.react-native.js +31 -30
  230. package/lib/weapp/StorageController.weapp.js +19 -13
  231. package/lib/weapp/TaskQueue.js +31 -43
  232. package/lib/weapp/UniqueInstanceStateController.js +65 -86
  233. package/lib/weapp/WebSocketController.js +11 -4
  234. package/lib/weapp/Xhr.weapp.js +90 -78
  235. package/lib/weapp/arrayContainsObject.js +3 -3
  236. package/lib/weapp/canBeSerialized.js +10 -11
  237. package/lib/weapp/decode.js +11 -11
  238. package/lib/weapp/encode.js +11 -11
  239. package/lib/weapp/equals.js +9 -10
  240. package/lib/weapp/escape.js +2 -2
  241. package/lib/weapp/isRevocableSession.js +1 -1
  242. package/lib/weapp/parseDate.js +10 -10
  243. package/lib/weapp/promiseUtils.js +19 -19
  244. package/lib/weapp/unique.js +4 -4
  245. package/lib/weapp/unsavedChildren.js +20 -21
  246. package/lib/weapp/uuid.js +6 -8
  247. package/package.json +19 -25
@@ -1,82 +1,29 @@
1
1
  "use strict";
2
2
 
3
- var _Object$keys2 = require("@babel/runtime-corejs3/core-js-stable/object/keys");
4
- var _Object$getOwnPropertySymbols = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols");
5
- var _filterInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/filter");
6
- var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
7
- var _forEachInstanceProperty2 = require("@babel/runtime-corejs3/core-js-stable/instance/for-each");
8
- var _Object$getOwnPropertyDescriptors = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors");
9
- var _Object$defineProperties = require("@babel/runtime-corejs3/core-js-stable/object/define-properties");
10
3
  var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
11
4
  var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
12
5
  _Object$defineProperty(exports, "__esModule", {
13
6
  value: true
14
7
  });
15
8
  exports.default = void 0;
16
- var _regenerator = _interopRequireDefault(require("@babel/runtime-corejs3/regenerator"));
17
9
  var _isArray = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/array/is-array"));
18
10
  var _slice = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/slice"));
19
11
  var _forEach = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
20
12
  var _keys = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/keys"));
21
13
  var _promise = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/promise"));
22
14
  var _indexOf = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
23
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/slicedToArray"));
24
- var _typeof2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/typeof"));
25
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/asyncToGenerator"));
26
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/classCallCheck"));
27
- var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/createClass"));
28
15
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
29
16
  var _CoreManager = _interopRequireDefault(require("./CoreManager"));
30
17
  var _ParseError = _interopRequireDefault(require("./ParseError"));
31
- function ownKeys(object, enumerableOnly) {
32
- var keys = _Object$keys2(object);
33
- if (_Object$getOwnPropertySymbols) {
34
- var symbols = _Object$getOwnPropertySymbols(object);
35
- enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) {
36
- return _Object$getOwnPropertyDescriptor(object, sym).enumerable;
37
- })), keys.push.apply(keys, symbols);
38
- }
39
- return keys;
40
- }
41
- function _objectSpread(target) {
42
- for (var i = 1; i < arguments.length; i++) {
43
- var _context8, _context9;
44
- var source = null != arguments[i] ? arguments[i] : {};
45
- i % 2 ? _forEachInstanceProperty2(_context8 = ownKeys(Object(source), !0)).call(_context8, function (key) {
46
- (0, _defineProperty2.default)(target, key, source[key]);
47
- }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty2(_context9 = ownKeys(Object(source))).call(_context9, function (key) {
48
- _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key));
49
- });
50
- }
51
- return target;
52
- } /* global XMLHttpRequest, Blob */
53
- var XHR = null;
18
+ var _Xhr = _interopRequireDefault(require("./Xhr.weapp"));
19
+ /* global XMLHttpRequest, Blob */
20
+
21
+ let XHR = null;
54
22
  if (typeof XMLHttpRequest !== 'undefined') {
55
23
  XHR = XMLHttpRequest;
56
24
  }
57
- XHR = require('./Xhr.weapp');
58
-
59
- /*:: export type FileSaveOptions = FullOptions & {
60
- metadata?: { [key: string]: any },
61
- tags?: { [key: string]: any },
62
- };*/
63
- /*:: export type FileSource =
64
- | {
65
- format: 'file',
66
- file: Blob,
67
- type: string | undefined,
68
- }
69
- | {
70
- format: 'base64',
71
- base64: string,
72
- type: string | undefined,
73
- }
74
- | {
75
- format: 'uri',
76
- uri: string,
77
- type: string | undefined,
78
- };*/
79
- function b64Digit(number /*: number*/) /*: string*/{
25
+ XHR = _Xhr.default;
26
+ function b64Digit(number) {
80
27
  if (number < 26) {
81
28
  return String.fromCharCode(65 + number);
82
29
  }
@@ -101,7 +48,7 @@ function b64Digit(number /*: number*/) /*: string*/{
101
48
  *
102
49
  * @alias Parse.File
103
50
  */
104
- var ParseFile = /*#__PURE__*/function () {
51
+ class ParseFile {
105
52
  /**
106
53
  * @param name {String} The file's name. This will be prefixed by a unique
107
54
  * value once the file has finished saving. The file name must begin with
@@ -132,8 +79,7 @@ var ParseFile = /*#__PURE__*/function () {
132
79
  * @param metadata {object} Optional key value pairs to be stored with file object
133
80
  * @param tags {object} Optional key value pairs to be stored with file object
134
81
  */
135
- function ParseFile(name /*: string*/, data /*:: ?: FileData*/, type /*:: ?: string*/, metadata /*:: ?: object*/, tags /*:: ?: object*/) {
136
- (0, _classCallCheck2.default)(this, ParseFile);
82
+ constructor(name, data, type, metadata, tags) {
137
83
  (0, _defineProperty2.default)(this, "_name", void 0);
138
84
  (0, _defineProperty2.default)(this, "_url", void 0);
139
85
  (0, _defineProperty2.default)(this, "_source", void 0);
@@ -142,7 +88,7 @@ var ParseFile = /*#__PURE__*/function () {
142
88
  (0, _defineProperty2.default)(this, "_requestTask", void 0);
143
89
  (0, _defineProperty2.default)(this, "_metadata", void 0);
144
90
  (0, _defineProperty2.default)(this, "_tags", void 0);
145
- var specifiedType = type || '';
91
+ const specifiedType = type || '';
146
92
  this._name = name;
147
93
  this._metadata = metadata || {};
148
94
  this._tags = tags || {};
@@ -168,12 +114,12 @@ var ParseFile = /*#__PURE__*/function () {
168
114
  };
169
115
  } else if (data && typeof data.base64 === 'string') {
170
116
  var _context, _context2, _context3;
171
- var base64 = (0, _slice.default)(_context = data.base64.split(',')).call(_context, -1)[0];
172
- var dataType = specifiedType || (0, _slice.default)(_context2 = (0, _slice.default)(_context3 = data.base64.split(';')).call(_context3, 0, 1)[0].split(':')).call(_context2, 1, 2)[0] || 'text/plain';
117
+ const base64 = (0, _slice.default)(_context = data.base64.split(',')).call(_context, -1)[0];
118
+ const dataType = specifiedType || (0, _slice.default)(_context2 = (0, _slice.default)(_context3 = data.base64.split(';')).call(_context3, 0, 1)[0].split(':')).call(_context2, 1, 2)[0] || 'text/plain';
173
119
  this._data = base64;
174
120
  this._source = {
175
121
  format: 'base64',
176
- base64: base64,
122
+ base64,
177
123
  type: dataType
178
124
  };
179
125
  } else {
@@ -189,398 +135,308 @@ var ParseFile = /*#__PURE__*/function () {
189
135
  *
190
136
  * @returns {Promise} Promise that is resolve with base64 data
191
137
  */
192
- (0, _createClass2.default)(ParseFile, [{
193
- key: "getData",
194
- value: function () {
195
- var _getData = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
196
- var _this = this;
197
- var options, controller, result;
198
- return _regenerator.default.wrap(function (_context4) {
199
- while (1) switch (_context4.prev = _context4.next) {
200
- case 0:
201
- if (!this._data) {
202
- _context4.next = 2;
203
- break;
204
- }
205
- return _context4.abrupt("return", this._data);
206
- case 2:
207
- if (this._url) {
208
- _context4.next = 4;
209
- break;
210
- }
211
- throw new Error('Cannot retrieve data for unsaved ParseFile.');
212
- case 4:
213
- options = {
214
- requestTask: function (task) {
215
- return _this._requestTask = task;
216
- }
217
- };
218
- controller = _CoreManager.default.getFileController();
219
- _context4.next = 8;
220
- return controller.download(this._url, options);
221
- case 8:
222
- result = _context4.sent;
223
- this._data = result.base64;
224
- return _context4.abrupt("return", this._data);
225
- case 11:
226
- case "end":
227
- return _context4.stop();
228
- }
229
- }, _callee, this);
230
- }));
231
- function getData() {
232
- return _getData.apply(this, arguments);
233
- }
234
- return getData;
235
- }()
236
- /**
237
- * Gets the name of the file. Before save is called, this is the filename
238
- * given by the user. After save is called, that name gets prefixed with a
239
- * unique identifier.
240
- *
241
- * @returns {string}
242
- */
243
- }, {
244
- key: "name",
245
- value: function () /*: string*/{
246
- return this._name;
138
+ async getData() {
139
+ if (this._data) {
140
+ return this._data;
247
141
  }
248
-
249
- /**
250
- * Gets the url of the file. It is only available after you save the file or
251
- * after you get the file from a Parse.Object.
252
- *
253
- * @param {object} options An object to specify url options
254
- * @param {boolean} [options.forceSecure] force the url to be secure
255
- * @returns {string | undefined}
256
- */
257
- }, {
258
- key: "url",
259
- value: function (options /*:: ?: { forceSecure?: boolean }*/) /*: string | undefined*/{
260
- options = options || {};
261
- if (!this._url) {
262
- return;
263
- }
264
- if (options.forceSecure) {
265
- return this._url.replace(/^http:\/\//i, 'https://');
266
- } else {
267
- return this._url;
268
- }
142
+ if (!this._url) {
143
+ throw new Error('Cannot retrieve data for unsaved ParseFile.');
269
144
  }
145
+ const controller = _CoreManager.default.getFileController();
146
+ const result = await controller.download(this._url, {
147
+ requestTask: task => this._requestTask = task
148
+ });
149
+ this._data = result.base64;
150
+ return this._data;
151
+ }
270
152
 
271
- /**
272
- * Gets the metadata of the file.
273
- *
274
- * @returns {object}
275
- */
276
- }, {
277
- key: "metadata",
278
- value: function () {
279
- return this._metadata;
280
- }
153
+ /**
154
+ * Gets the name of the file. Before save is called, this is the filename
155
+ * given by the user. After save is called, that name gets prefixed with a
156
+ * unique identifier.
157
+ *
158
+ * @returns {string}
159
+ */
160
+ name() {
161
+ return this._name;
162
+ }
281
163
 
282
- /**
283
- * Gets the tags of the file.
284
- *
285
- * @returns {object}
286
- */
287
- }, {
288
- key: "tags",
289
- value: function () {
290
- return this._tags;
164
+ /**
165
+ * Gets the url of the file. It is only available after you save the file or
166
+ * after you get the file from a Parse.Object.
167
+ *
168
+ * @param {object} options An object to specify url options
169
+ * @param {boolean} [options.forceSecure] force the url to be secure
170
+ * @returns {string | undefined}
171
+ */
172
+ url(options) {
173
+ options = options || {};
174
+ if (!this._url) {
175
+ return;
291
176
  }
177
+ if (options.forceSecure) {
178
+ return this._url.replace(/^http:\/\//i, 'https://');
179
+ } else {
180
+ return this._url;
181
+ }
182
+ }
292
183
 
293
- /**
294
- * Saves the file to the Parse cloud.
295
- *
296
- * @param {object} options
297
- * Valid options are:<ul>
298
- * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
299
- * be used for this request.
300
- * <li>sessionToken: A valid session token, used for making a request on
301
- * behalf of a specific user.
302
- * <li>progress: In Browser only, callback for upload progress. For example:
303
- * <pre>
304
- * let parseFile = new Parse.File(name, file);
305
- * parseFile.save({
306
- * progress: (progressValue, loaded, total, { type }) => {
307
- * if (type === "upload" && progressValue !== null) {
308
- * // Update the UI using progressValue
309
- * }
310
- * }
311
- * });
312
- * </pre>
313
- * </ul>
314
- * @returns {Promise | undefined} Promise that is resolved when the save finishes.
315
- */
316
- }, {
317
- key: "save",
318
- value: function (options /*:: ?: FileSaveOptions*/) /*: Promise<ParseFile> | undefined*/{
319
- var _this2 = this;
320
- options = options || {};
321
- options.requestTask = function (task) {
322
- return _this2._requestTask = task;
323
- };
324
- options.metadata = this._metadata;
325
- options.tags = this._tags;
326
- var controller = _CoreManager.default.getFileController();
327
- if (!this._previousSave) {
328
- if (this._source.format === 'file') {
329
- this._previousSave = controller.saveFile(this._name, this._source, options).then(function (res) {
330
- _this2._name = res.name;
331
- _this2._url = res.url;
332
- _this2._data = null;
333
- _this2._requestTask = null;
334
- return _this2;
335
- });
336
- } else if (this._source.format === 'uri') {
337
- this._previousSave = controller.download(this._source.uri, options).then(function (result) {
338
- if (!(result && result.base64)) {
339
- return {};
340
- }
341
- var newSource = {
342
- format: 'base64',
343
- base64: result.base64,
344
- type: result.contentType
345
- };
346
- _this2._data = result.base64;
347
- _this2._requestTask = null;
348
- return controller.saveBase64(_this2._name, newSource, options);
349
- }).then(function (res /*: { name?: string, url?: string }*/) {
350
- _this2._name = res.name;
351
- _this2._url = res.url;
352
- _this2._requestTask = null;
353
- return _this2;
354
- });
355
- } else {
356
- this._previousSave = controller.saveBase64(this._name, this._source, options).then(function (res) {
357
- _this2._name = res.name;
358
- _this2._url = res.url;
359
- _this2._requestTask = null;
360
- return _this2;
361
- });
362
- }
363
- }
364
- if (this._previousSave) {
365
- return this._previousSave;
184
+ /**
185
+ * Gets the metadata of the file.
186
+ *
187
+ * @returns {object}
188
+ */
189
+ metadata() {
190
+ return this._metadata;
191
+ }
192
+
193
+ /**
194
+ * Gets the tags of the file.
195
+ *
196
+ * @returns {object}
197
+ */
198
+ tags() {
199
+ return this._tags;
200
+ }
201
+
202
+ /**
203
+ * Saves the file to the Parse cloud.
204
+ *
205
+ * @param {object} options
206
+ * Valid options are:<ul>
207
+ * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
208
+ * be used for this request.
209
+ * <li>sessionToken: A valid session token, used for making a request on
210
+ * behalf of a specific user.
211
+ * <li>progress: In Browser only, callback for upload progress. For example:
212
+ * <pre>
213
+ * let parseFile = new Parse.File(name, file);
214
+ * parseFile.save({
215
+ * progress: (progressValue, loaded, total, { type }) => {
216
+ * if (type === "upload" && progressValue !== null) {
217
+ * // Update the UI using progressValue
218
+ * }
219
+ * }
220
+ * });
221
+ * </pre>
222
+ * </ul>
223
+ * @returns {Promise | undefined} Promise that is resolved when the save finishes.
224
+ */
225
+ save(options) {
226
+ options = options || {};
227
+ options.requestTask = task => this._requestTask = task;
228
+ options.metadata = this._metadata;
229
+ options.tags = this._tags;
230
+ const controller = _CoreManager.default.getFileController();
231
+ if (!this._previousSave) {
232
+ if (this._source.format === 'file') {
233
+ this._previousSave = controller.saveFile(this._name, this._source, options).then(res => {
234
+ this._name = res.name;
235
+ this._url = res.url;
236
+ this._data = null;
237
+ this._requestTask = null;
238
+ return this;
239
+ });
240
+ } else if (this._source.format === 'uri') {
241
+ this._previousSave = controller.download(this._source.uri, options).then(result => {
242
+ if (!(result && result.base64)) {
243
+ return {};
244
+ }
245
+ const newSource = {
246
+ format: 'base64',
247
+ base64: result.base64,
248
+ type: result.contentType
249
+ };
250
+ this._data = result.base64;
251
+ this._requestTask = null;
252
+ return controller.saveBase64(this._name, newSource, options);
253
+ }).then(res => {
254
+ this._name = res.name;
255
+ this._url = res.url;
256
+ this._requestTask = null;
257
+ return this;
258
+ });
259
+ } else {
260
+ this._previousSave = controller.saveBase64(this._name, this._source, options).then(res => {
261
+ this._name = res.name;
262
+ this._url = res.url;
263
+ this._requestTask = null;
264
+ return this;
265
+ });
366
266
  }
367
267
  }
268
+ if (this._previousSave) {
269
+ return this._previousSave;
270
+ }
271
+ }
368
272
 
369
- /**
370
- * Aborts the request if it has already been sent.
371
- */
372
- }, {
373
- key: "cancel",
374
- value: function () {
375
- if (this._requestTask && typeof this._requestTask.abort === 'function') {
376
- this._requestTask._aborted = true;
377
- this._requestTask.abort();
378
- }
379
- this._requestTask = null;
273
+ /**
274
+ * Aborts the request if it has already been sent.
275
+ */
276
+ cancel() {
277
+ if (this._requestTask && typeof this._requestTask.abort === 'function') {
278
+ this._requestTask._aborted = true;
279
+ this._requestTask.abort();
380
280
  }
281
+ this._requestTask = null;
282
+ }
381
283
 
382
- /**
383
- * Deletes the file from the Parse cloud.
384
- * In Cloud Code and Node only with Master Key.
385
- *
386
- * @param {object} options
387
- * Valid options are:<ul>
388
- * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
389
- * be used for this request.
390
- * <pre>
391
- * @returns {Promise} Promise that is resolved when the delete finishes.
392
- */
393
- }, {
394
- key: "destroy",
395
- value: function () {
396
- var _this3 = this;
397
- var options /*: FullOptions*/ = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
398
- if (!this._name) {
399
- throw new _ParseError.default(_ParseError.default.FILE_DELETE_UNNAMED_ERROR, 'Cannot delete an unnamed file.');
400
- }
401
- var destroyOptions = {
402
- useMasterKey: true
403
- };
404
- if (options.hasOwnProperty('useMasterKey')) {
405
- destroyOptions.useMasterKey = !!options.useMasterKey;
406
- }
407
- var controller = _CoreManager.default.getFileController();
408
- return controller.deleteFile(this._name, destroyOptions).then(function () {
409
- _this3._data = undefined;
410
- _this3._requestTask = null;
411
- return _this3;
412
- });
284
+ /**
285
+ * Deletes the file from the Parse cloud.
286
+ * In Cloud Code and Node only with Master Key.
287
+ *
288
+ * @param {object} options
289
+ * Valid options are:<ul>
290
+ * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
291
+ * be used for this request.
292
+ * <pre>
293
+ * @returns {Promise} Promise that is resolved when the delete finishes.
294
+ */
295
+ destroy() {
296
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
297
+ if (!this._name) {
298
+ throw new _ParseError.default(_ParseError.default.FILE_DELETE_UNNAMED_ERROR, 'Cannot delete an unnamed file.');
413
299
  }
414
- }, {
415
- key: "toJSON",
416
- value: function () /*: { __type: 'File', name?: string, url?: string }*/{
417
- return {
418
- __type: 'File',
419
- name: this._name,
420
- url: this._url
421
- };
300
+ const destroyOptions = {
301
+ useMasterKey: true
302
+ };
303
+ if (options.hasOwnProperty('useMasterKey')) {
304
+ destroyOptions.useMasterKey = !!options.useMasterKey;
422
305
  }
423
- }, {
424
- key: "equals",
425
- value: function (other /*: any*/) /*: boolean*/{
426
- if (this === other) {
427
- return true;
428
- }
429
- // Unsaved Files are never equal, since they will be saved to different URLs
430
- return other instanceof ParseFile && this.name() === other.name() && this.url() === other.url() && typeof this.url() !== 'undefined';
306
+ const controller = _CoreManager.default.getFileController();
307
+ return controller.deleteFile(this._name, destroyOptions).then(() => {
308
+ this._data = undefined;
309
+ this._requestTask = null;
310
+ return this;
311
+ });
312
+ }
313
+ toJSON() {
314
+ return {
315
+ __type: 'File',
316
+ name: this._name,
317
+ url: this._url
318
+ };
319
+ }
320
+ equals(other) {
321
+ if (this === other) {
322
+ return true;
431
323
  }
324
+ // Unsaved Files are never equal, since they will be saved to different URLs
325
+ return other instanceof ParseFile && this.name() === other.name() && this.url() === other.url() && typeof this.url() !== 'undefined';
326
+ }
432
327
 
433
- /**
434
- * Sets metadata to be saved with file object. Overwrites existing metadata
435
- *
436
- * @param {object} metadata Key value pairs to be stored with file object
437
- */
438
- }, {
439
- key: "setMetadata",
440
- value: function (metadata /*: any*/) {
441
- var _this4 = this;
442
- if (metadata && (0, _typeof2.default)(metadata) === 'object') {
443
- var _context5;
444
- (0, _forEach.default)(_context5 = (0, _keys.default)(metadata)).call(_context5, function (key) {
445
- _this4.addMetadata(key, metadata[key]);
446
- });
447
- }
328
+ /**
329
+ * Sets metadata to be saved with file object. Overwrites existing metadata
330
+ *
331
+ * @param {object} metadata Key value pairs to be stored with file object
332
+ */
333
+ setMetadata(metadata) {
334
+ if (metadata && typeof metadata === 'object') {
335
+ var _context4;
336
+ (0, _forEach.default)(_context4 = (0, _keys.default)(metadata)).call(_context4, key => {
337
+ this.addMetadata(key, metadata[key]);
338
+ });
448
339
  }
340
+ }
449
341
 
450
- /**
451
- * Sets metadata to be saved with file object. Adds to existing metadata.
452
- *
453
- * @param {string} key key to store the metadata
454
- * @param {*} value metadata
455
- */
456
- }, {
457
- key: "addMetadata",
458
- value: function (key /*: string*/, value /*: any*/) {
459
- if (typeof key === 'string') {
460
- this._metadata[key] = value;
461
- }
342
+ /**
343
+ * Sets metadata to be saved with file object. Adds to existing metadata.
344
+ *
345
+ * @param {string} key key to store the metadata
346
+ * @param {*} value metadata
347
+ */
348
+ addMetadata(key, value) {
349
+ if (typeof key === 'string') {
350
+ this._metadata[key] = value;
462
351
  }
352
+ }
463
353
 
464
- /**
465
- * Sets tags to be saved with file object. Overwrites existing tags
466
- *
467
- * @param {object} tags Key value pairs to be stored with file object
468
- */
469
- }, {
470
- key: "setTags",
471
- value: function (tags /*: any*/) {
472
- var _this5 = this;
473
- if (tags && (0, _typeof2.default)(tags) === 'object') {
474
- var _context6;
475
- (0, _forEach.default)(_context6 = (0, _keys.default)(tags)).call(_context6, function (key) {
476
- _this5.addTag(key, tags[key]);
477
- });
478
- }
354
+ /**
355
+ * Sets tags to be saved with file object. Overwrites existing tags
356
+ *
357
+ * @param {object} tags Key value pairs to be stored with file object
358
+ */
359
+ setTags(tags) {
360
+ if (tags && typeof tags === 'object') {
361
+ var _context5;
362
+ (0, _forEach.default)(_context5 = (0, _keys.default)(tags)).call(_context5, key => {
363
+ this.addTag(key, tags[key]);
364
+ });
479
365
  }
366
+ }
480
367
 
481
- /**
482
- * Sets tags to be saved with file object. Adds to existing tags.
483
- *
484
- * @param {string} key key to store tags
485
- * @param {*} value tag
486
- */
487
- }, {
488
- key: "addTag",
489
- value: function (key /*: string*/, value /*: string*/) {
490
- if (typeof key === 'string') {
491
- this._tags[key] = value;
492
- }
368
+ /**
369
+ * Sets tags to be saved with file object. Adds to existing tags.
370
+ *
371
+ * @param {string} key key to store tags
372
+ * @param {*} value tag
373
+ */
374
+ addTag(key, value) {
375
+ if (typeof key === 'string') {
376
+ this._tags[key] = value;
493
377
  }
494
- }], [{
495
- key: "fromJSON",
496
- value: function (obj) /*: ParseFile*/{
497
- if (obj.__type !== 'File') {
498
- throw new TypeError('JSON object does not represent a ParseFile');
499
- }
500
- var file = new ParseFile(obj.name);
501
- file._url = obj.url;
502
- return file;
378
+ }
379
+ static fromJSON(obj) {
380
+ if (obj.__type !== 'File') {
381
+ throw new TypeError('JSON object does not represent a ParseFile');
503
382
  }
504
- }, {
505
- key: "encodeBase64",
506
- value: function (bytes /*: Array<number> | Uint8Array*/) /*: string*/{
507
- var chunks = [];
508
- chunks.length = Math.ceil(bytes.length / 3);
509
- for (var i = 0; i < chunks.length; i++) {
510
- var b1 = bytes[i * 3];
511
- var b2 = bytes[i * 3 + 1] || 0;
512
- var b3 = bytes[i * 3 + 2] || 0;
513
- var has2 = i * 3 + 1 < bytes.length;
514
- var has3 = i * 3 + 2 < bytes.length;
515
- chunks[i] = [b64Digit(b1 >> 2 & 0x3f), b64Digit(b1 << 4 & 0x30 | b2 >> 4 & 0x0f), has2 ? b64Digit(b2 << 2 & 0x3c | b3 >> 6 & 0x03) : '=', has3 ? b64Digit(b3 & 0x3f) : '='].join('');
516
- }
517
- return chunks.join('');
383
+ const file = new ParseFile(obj.name);
384
+ file._url = obj.url;
385
+ return file;
386
+ }
387
+ static encodeBase64(bytes) {
388
+ const chunks = [];
389
+ chunks.length = Math.ceil(bytes.length / 3);
390
+ for (let i = 0; i < chunks.length; i++) {
391
+ const b1 = bytes[i * 3];
392
+ const b2 = bytes[i * 3 + 1] || 0;
393
+ const b3 = bytes[i * 3 + 2] || 0;
394
+ const has2 = i * 3 + 1 < bytes.length;
395
+ const has3 = i * 3 + 2 < bytes.length;
396
+ chunks[i] = [b64Digit(b1 >> 2 & 0x3f), b64Digit(b1 << 4 & 0x30 | b2 >> 4 & 0x0f), has2 ? b64Digit(b2 << 2 & 0x3c | b3 >> 6 & 0x03) : '=', has3 ? b64Digit(b3 & 0x3f) : '='].join('');
518
397
  }
519
- }]);
520
- return ParseFile;
521
- }();
522
- var DefaultController = {
523
- saveFile: function () {
524
- var _saveFile = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(name /*: string*/, source /*: FileSource*/, options /*:: ?: FileSaveOptions*/) {
525
- var base64Data, _base64Data$split, _base64Data$split2, first, second, data, newSource;
526
- return _regenerator.default.wrap(function (_context7) {
527
- while (1) switch (_context7.prev = _context7.next) {
528
- case 0:
529
- if (!(source.format !== 'file')) {
530
- _context7.next = 2;
531
- break;
532
- }
533
- throw new Error('saveFile can only be used with File-type sources.');
534
- case 2:
535
- _context7.next = 4;
536
- return new _promise.default(function (res, rej) {
537
- // eslint-disable-next-line no-undef
538
- var reader = new FileReader();
539
- reader.onload = function () {
540
- return res(reader.result);
541
- };
542
- reader.onerror = function (error) {
543
- return rej(error);
544
- };
545
- reader.readAsDataURL(source.file);
546
- });
547
- case 4:
548
- base64Data = _context7.sent;
549
- // we only want the data after the comma
550
- // For example: "data:application/pdf;base64,JVBERi0xLjQKJ..." we would only want "JVBERi0xLjQKJ..."
551
- _base64Data$split = base64Data.split(','), _base64Data$split2 = (0, _slicedToArray2.default)(_base64Data$split, 2), first = _base64Data$split2[0], second = _base64Data$split2[1]; // in the event there is no 'data:application/pdf;base64,' at the beginning of the base64 string
552
- // use the entire string instead
553
- data = second ? second : first;
554
- newSource = {
555
- format: 'base64',
556
- base64: data,
557
- type: source.type || (source.file ? source.file.type : undefined)
558
- };
559
- _context7.next = 10;
560
- return DefaultController.saveBase64(name, newSource, options);
561
- case 10:
562
- return _context7.abrupt("return", _context7.sent);
563
- case 11:
564
- case "end":
565
- return _context7.stop();
566
- }
567
- }, _callee2);
568
- }));
569
- function saveFile() {
570
- return _saveFile.apply(this, arguments);
398
+ return chunks.join('');
399
+ }
400
+ }
401
+ const DefaultController = {
402
+ saveFile: async function (name, source, options) {
403
+ if (source.format !== 'file') {
404
+ throw new Error('saveFile can only be used with File-type sources.');
571
405
  }
572
- return saveFile;
573
- }(),
574
- saveBase64: function (name /*: string*/, source /*: FileSource*/) {
575
- var options /*: FileSaveOptions*/ = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
406
+ const base64Data = await new _promise.default((res, rej) => {
407
+ // eslint-disable-next-line no-undef
408
+ const reader = new FileReader();
409
+ reader.onload = () => res(reader.result);
410
+ reader.onerror = error => rej(error);
411
+ reader.readAsDataURL(source.file);
412
+ });
413
+ // we only want the data after the comma
414
+ // For example: "data:application/pdf;base64,JVBERi0xLjQKJ..." we would only want "JVBERi0xLjQKJ..."
415
+ const [first, second] = base64Data.split(',');
416
+ // in the event there is no 'data:application/pdf;base64,' at the beginning of the base64 string
417
+ // use the entire string instead
418
+ const data = second ? second : first;
419
+ const newSource = {
420
+ format: 'base64',
421
+ base64: data,
422
+ type: source.type || (source.file ? source.file.type : undefined)
423
+ };
424
+ return await DefaultController.saveBase64(name, newSource, options);
425
+ },
426
+ saveBase64: function (name, source) {
427
+ let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
576
428
  if (source.format !== 'base64') {
577
429
  throw new Error('saveBase64 can only be used with Base64-type sources.');
578
430
  }
579
- var data /*: { base64: any, _ContentType?: any, fileData: any }*/ = {
431
+ const data = {
580
432
  base64: source.base64,
581
433
  fileData: {
582
- metadata: _objectSpread({}, options.metadata),
583
- tags: _objectSpread({}, options.tags)
434
+ metadata: {
435
+ ...options.metadata
436
+ },
437
+ tags: {
438
+ ...options.tags
439
+ }
584
440
  }
585
441
  };
586
442
  delete options.metadata;
@@ -597,9 +453,9 @@ var DefaultController = {
597
453
  return _promise.default.reject('Cannot make a request: No definition of XMLHttpRequest was found.');
598
454
  }
599
455
  },
600
- downloadAjax: function (uri /*: string*/, options /*: any*/) {
601
- return new _promise.default(function (resolve, reject) {
602
- var xhr = new XHR();
456
+ downloadAjax: function (uri, options) {
457
+ return new _promise.default((resolve, reject) => {
458
+ const xhr = new XHR();
603
459
  xhr.open('GET', uri, true);
604
460
  xhr.responseType = 'arraybuffer';
605
461
  xhr.onerror = function (e) {
@@ -612,7 +468,7 @@ var DefaultController = {
612
468
  if (!this.response) {
613
469
  return resolve({});
614
470
  }
615
- var bytes = new Uint8Array(this.response);
471
+ const bytes = new Uint8Array(this.response);
616
472
  resolve({
617
473
  base64: ParseFile.encodeBase64(bytes),
618
474
  contentType: xhr.getResponseHeader('content-type')
@@ -622,19 +478,19 @@ var DefaultController = {
622
478
  xhr.send();
623
479
  });
624
480
  },
625
- deleteFile: function (name /*: string*/, options /*:: ?: FullOptions*/) {
626
- var headers = {
481
+ deleteFile: function (name, options) {
482
+ const headers = {
627
483
  'X-Parse-Application-ID': _CoreManager.default.get('APPLICATION_ID')
628
484
  };
629
485
  if (options.useMasterKey) {
630
486
  headers['X-Parse-Master-Key'] = _CoreManager.default.get('MASTER_KEY');
631
487
  }
632
- var url = _CoreManager.default.get('SERVER_URL');
488
+ let url = _CoreManager.default.get('SERVER_URL');
633
489
  if (url[url.length - 1] !== '/') {
634
490
  url += '/';
635
491
  }
636
492
  url += 'files/' + name;
637
- return _CoreManager.default.getRESTController().ajax('DELETE', url, '', headers).catch(function (response) {
493
+ return _CoreManager.default.getRESTController().ajax('DELETE', url, '', headers).catch(response => {
638
494
  // TODO: return JSON object in server
639
495
  if (!response || response === 'SyntaxError: Unexpected end of JSON input') {
640
496
  return _promise.default.resolve();
@@ -643,14 +499,13 @@ var DefaultController = {
643
499
  }
644
500
  });
645
501
  },
646
- _setXHR: function (xhr /*: any*/) {
502
+ _setXHR(xhr) {
647
503
  XHR = xhr;
648
504
  },
649
- _getXHR: function () {
505
+ _getXHR() {
650
506
  return XHR;
651
507
  }
652
508
  };
653
509
  _CoreManager.default.setFileController(DefaultController);
654
- var _default = ParseFile;
655
- exports.default = _default;
510
+ var _default = exports.default = ParseFile;
656
511
  exports.b64Digit = b64Digit;