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