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
@@ -8,29 +8,21 @@ _Object$defineProperty(exports, "__esModule", {
8
8
  exports.default = void 0;
9
9
  var _promise = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/promise"));
10
10
  var _stringify = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/json/stringify"));
11
- var _typeof2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/typeof"));
12
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/classCallCheck"));
13
- var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/createClass"));
14
11
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
15
12
  var _CoreManager = _interopRequireDefault(require("./CoreManager"));
16
13
  var _decode = _interopRequireDefault(require("./decode"));
17
14
  var _encode = _interopRequireDefault(require("./encode"));
18
- var _escape2 = _interopRequireDefault(require("./escape"));
15
+ var _escape = _interopRequireDefault(require("./escape"));
19
16
  var _ParseError = _interopRequireDefault(require("./ParseError"));
20
17
  var _Storage = _interopRequireDefault(require("./Storage"));
21
- /**
22
- * @flow
23
- */
24
- /*:: import type { RequestOptions } from './RESTController';*/
25
18
  /**
26
19
  * Parse.Config is a local representation of configuration data that
27
20
  * can be set from the Parse dashboard.
28
21
  *
29
22
  * @alias Parse.Config
30
23
  */
31
- var ParseConfig = /*#__PURE__*/function () {
32
- function ParseConfig() {
33
- (0, _classCallCheck2.default)(this, ParseConfig);
24
+ class ParseConfig {
25
+ constructor() {
34
26
  (0, _defineProperty2.default)(this, "attributes", void 0);
35
27
  (0, _defineProperty2.default)(this, "_escapedAttributes", void 0);
36
28
  this.attributes = {};
@@ -43,132 +35,118 @@ var ParseConfig = /*#__PURE__*/function () {
43
35
  * @param {string} attr The name of an attribute.
44
36
  * @returns {*}
45
37
  */
46
- (0, _createClass2.default)(ParseConfig, [{
47
- key: "get",
48
- value: function (attr /*: string*/) /*: any*/{
49
- return this.attributes[attr];
50
- }
38
+ get(attr) {
39
+ return this.attributes[attr];
40
+ }
51
41
 
52
- /**
53
- * Gets the HTML-escaped value of an attribute.
54
- *
55
- * @param {string} attr The name of an attribute.
56
- * @returns {string}
57
- */
58
- }, {
59
- key: "escape",
60
- value: function (attr /*: string*/) /*: string*/{
61
- var html = this._escapedAttributes[attr];
62
- if (html) {
63
- return html;
64
- }
65
- var val = this.attributes[attr];
66
- var escaped = '';
67
- if (val != null) {
68
- escaped = (0, _escape2.default)(val.toString());
69
- }
70
- this._escapedAttributes[attr] = escaped;
71
- return escaped;
42
+ /**
43
+ * Gets the HTML-escaped value of an attribute.
44
+ *
45
+ * @param {string} attr The name of an attribute.
46
+ * @returns {string}
47
+ */
48
+ escape(attr) {
49
+ const html = this._escapedAttributes[attr];
50
+ if (html) {
51
+ return html;
72
52
  }
73
-
74
- /**
75
- * Retrieves the most recently-fetched configuration object, either from
76
- * memory or from local storage if necessary.
77
- *
78
- * @static
79
- * @returns {Parse.Config} The most recently-fetched Parse.Config if it
80
- * exists, else an empty Parse.Config.
81
- */
82
- }], [{
83
- key: "current",
84
- value: function () {
85
- var controller = _CoreManager.default.getConfigController();
86
- return controller.current();
53
+ const val = this.attributes[attr];
54
+ let escaped = '';
55
+ if (val != null) {
56
+ escaped = (0, _escape.default)(val.toString());
87
57
  }
58
+ this._escapedAttributes[attr] = escaped;
59
+ return escaped;
60
+ }
88
61
 
89
- /**
90
- * Gets a new configuration object from the server.
91
- *
92
- * @static
93
- * @param {object} options
94
- * Valid options are:<ul>
95
- * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
96
- * be used for this request.
97
- * </ul>
98
- * @returns {Promise} A promise that is resolved with a newly-created
99
- * configuration object when the get completes.
100
- */
101
- }, {
102
- key: "get",
103
- value: function () {
104
- var options /*: RequestOptions*/ = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
105
- var controller = _CoreManager.default.getConfigController();
106
- return controller.get(options);
107
- }
62
+ /**
63
+ * Retrieves the most recently-fetched configuration object, either from
64
+ * memory or from local storage if necessary.
65
+ *
66
+ * @static
67
+ * @returns {Parse.Config} The most recently-fetched Parse.Config if it
68
+ * exists, else an empty Parse.Config.
69
+ */
70
+ static current() {
71
+ const controller = _CoreManager.default.getConfigController();
72
+ return controller.current();
73
+ }
108
74
 
109
- /**
110
- * Save value keys to the server.
111
- *
112
- * @static
113
- * @param {object} attrs The config parameters and values.
114
- * @param {object} masterKeyOnlyFlags The flags that define whether config parameters listed
115
- * in `attrs` should be retrievable only by using the master key.
116
- * For example: `param1: true` makes `param1` only retrievable by using the master key.
117
- * If a parameter is not provided or set to `false`, it can be retrieved without
118
- * using the master key.
119
- * @returns {Promise} A promise that is resolved with a newly-created
120
- * configuration object or with the current with the update.
121
- */
122
- }, {
123
- key: "save",
124
- value: function (attrs /*: { [key: string]: any }*/, masterKeyOnlyFlags /*: { [key: string]: any }*/) {
125
- var controller = _CoreManager.default.getConfigController();
126
- //To avoid a mismatch with the local and the cloud config we get a new version
127
- return controller.save(attrs, masterKeyOnlyFlags).then(function () {
128
- return controller.get({
129
- useMasterKey: true
130
- });
131
- }, function (error) {
132
- return _promise.default.reject(error);
75
+ /**
76
+ * Gets a new configuration object from the server.
77
+ *
78
+ * @static
79
+ * @param {object} options
80
+ * Valid options are:<ul>
81
+ * <li>useMasterKey: In Cloud Code and Node only, causes the Master Key to
82
+ * be used for this request.
83
+ * </ul>
84
+ * @returns {Promise} A promise that is resolved with a newly-created
85
+ * configuration object when the get completes.
86
+ */
87
+ static get() {
88
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
89
+ const controller = _CoreManager.default.getConfigController();
90
+ return controller.get(options);
91
+ }
92
+
93
+ /**
94
+ * Save value keys to the server.
95
+ *
96
+ * @static
97
+ * @param {object} attrs The config parameters and values.
98
+ * @param {object} masterKeyOnlyFlags The flags that define whether config parameters listed
99
+ * in `attrs` should be retrievable only by using the master key.
100
+ * For example: `param1: true` makes `param1` only retrievable by using the master key.
101
+ * If a parameter is not provided or set to `false`, it can be retrieved without
102
+ * using the master key.
103
+ * @returns {Promise} A promise that is resolved with a newly-created
104
+ * configuration object or with the current with the update.
105
+ */
106
+ static save(attrs, masterKeyOnlyFlags) {
107
+ const controller = _CoreManager.default.getConfigController();
108
+ //To avoid a mismatch with the local and the cloud config we get a new version
109
+ return controller.save(attrs, masterKeyOnlyFlags).then(() => {
110
+ return controller.get({
111
+ useMasterKey: true
133
112
  });
134
- }
113
+ }, error => {
114
+ return _promise.default.reject(error);
115
+ });
116
+ }
135
117
 
136
- /**
137
- * Used for testing
138
- *
139
- * @private
140
- */
141
- }, {
142
- key: "_clearCache",
143
- value: function () {
144
- currentConfig = null;
145
- }
146
- }]);
147
- return ParseConfig;
148
- }();
149
- var currentConfig = null;
150
- var CURRENT_CONFIG_KEY = 'currentConfig';
118
+ /**
119
+ * Used for testing
120
+ *
121
+ * @private
122
+ */
123
+ static _clearCache() {
124
+ currentConfig = null;
125
+ }
126
+ }
127
+ let currentConfig = null;
128
+ const CURRENT_CONFIG_KEY = 'currentConfig';
151
129
  function decodePayload(data) {
152
130
  try {
153
- var json = JSON.parse(data);
154
- if (json && (0, _typeof2.default)(json) === 'object') {
131
+ const json = JSON.parse(data);
132
+ if (json && typeof json === 'object') {
155
133
  return (0, _decode.default)(json);
156
134
  }
157
135
  } catch (e) {
158
136
  return null;
159
137
  }
160
138
  }
161
- var DefaultController = {
162
- current: function () {
139
+ const DefaultController = {
140
+ current() {
163
141
  if (currentConfig) {
164
142
  return currentConfig;
165
143
  }
166
- var config = new ParseConfig();
167
- var storagePath = _Storage.default.generatePath(CURRENT_CONFIG_KEY);
144
+ const config = new ParseConfig();
145
+ const storagePath = _Storage.default.generatePath(CURRENT_CONFIG_KEY);
168
146
  if (!_Storage.default.async()) {
169
- var configData = _Storage.default.getItem(storagePath);
147
+ const configData = _Storage.default.getItem(storagePath);
170
148
  if (configData) {
171
- var attributes = decodePayload(configData);
149
+ const attributes = decodePayload(configData);
172
150
  if (attributes) {
173
151
  config.attributes = attributes;
174
152
  currentConfig = config;
@@ -177,57 +155,56 @@ var DefaultController = {
177
155
  return config;
178
156
  }
179
157
  // Return a promise for async storage controllers
180
- return _Storage.default.getItemAsync(storagePath).then(function (configData) {
158
+ return _Storage.default.getItemAsync(storagePath).then(configData => {
181
159
  if (configData) {
182
- var _attributes = decodePayload(configData);
183
- if (_attributes) {
184
- config.attributes = _attributes;
160
+ const attributes = decodePayload(configData);
161
+ if (attributes) {
162
+ config.attributes = attributes;
185
163
  currentConfig = config;
186
164
  }
187
165
  }
188
166
  return config;
189
167
  });
190
168
  },
191
- get: function () {
192
- var options /*: RequestOptions*/ = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
193
- var RESTController = _CoreManager.default.getRESTController();
194
- return RESTController.request('GET', 'config', {}, options).then(function (response) {
169
+ get() {
170
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
171
+ const RESTController = _CoreManager.default.getRESTController();
172
+ return RESTController.request('GET', 'config', {}, options).then(response => {
195
173
  if (!response || !response.params) {
196
- var error = new _ParseError.default(_ParseError.default.INVALID_JSON, 'Config JSON response invalid.');
174
+ const error = new _ParseError.default(_ParseError.default.INVALID_JSON, 'Config JSON response invalid.');
197
175
  return _promise.default.reject(error);
198
176
  }
199
- var config = new ParseConfig();
177
+ const config = new ParseConfig();
200
178
  config.attributes = {};
201
- for (var attr in response.params) {
179
+ for (const attr in response.params) {
202
180
  config.attributes[attr] = (0, _decode.default)(response.params[attr]);
203
181
  }
204
182
  currentConfig = config;
205
- return _Storage.default.setItemAsync(_Storage.default.generatePath(CURRENT_CONFIG_KEY), (0, _stringify.default)(response.params)).then(function () {
183
+ return _Storage.default.setItemAsync(_Storage.default.generatePath(CURRENT_CONFIG_KEY), (0, _stringify.default)(response.params)).then(() => {
206
184
  return config;
207
185
  });
208
186
  });
209
187
  },
210
- save: function (attrs /*: { [key: string]: any }*/, masterKeyOnlyFlags /*: { [key: string]: any }*/) {
211
- var RESTController = _CoreManager.default.getRESTController();
212
- var encodedAttrs = {};
213
- for (var _key in attrs) {
214
- encodedAttrs[_key] = (0, _encode.default)(attrs[_key]);
188
+ save(attrs, masterKeyOnlyFlags) {
189
+ const RESTController = _CoreManager.default.getRESTController();
190
+ const encodedAttrs = {};
191
+ for (const key in attrs) {
192
+ encodedAttrs[key] = (0, _encode.default)(attrs[key]);
215
193
  }
216
194
  return RESTController.request('PUT', 'config', {
217
195
  params: encodedAttrs,
218
196
  masterKeyOnly: masterKeyOnlyFlags
219
197
  }, {
220
198
  useMasterKey: true
221
- }).then(function (response) {
199
+ }).then(response => {
222
200
  if (response && response.result) {
223
201
  return _promise.default.resolve();
224
202
  } else {
225
- var error = new _ParseError.default(_ParseError.default.INTERNAL_SERVER_ERROR, 'Error occured updating Config.');
203
+ const error = new _ParseError.default(_ParseError.default.INTERNAL_SERVER_ERROR, 'Error occured updating Config.');
226
204
  return _promise.default.reject(error);
227
205
  }
228
206
  });
229
207
  }
230
208
  };
231
209
  _CoreManager.default.setConfigController(DefaultController);
232
- var _default = ParseConfig;
233
- exports.default = _default;
210
+ var _default = exports.default = ParseConfig;