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