parse 5.2.0-alpha.1 → 5.2.0-alpha.3

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