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
@@ -7,24 +7,20 @@ _Object$defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.default = void 0;
9
9
  var _ParseUser = _interopRequireDefault(require("./ParseUser"));
10
- /**
11
- * @flow-weak
12
- */
13
10
  /* global FB */
14
11
 
15
- var initialized = false;
16
- var requestedPermissions;
17
- var initOptions;
18
- var provider = {
19
- authenticate: function (options) {
20
- var _this = this;
12
+ let initialized = false;
13
+ let requestedPermissions;
14
+ let initOptions;
15
+ const provider = {
16
+ authenticate(options) {
21
17
  if (typeof FB === 'undefined') {
22
18
  options.error(this, 'Facebook SDK not found.');
23
19
  }
24
- FB.login(function (response) {
20
+ FB.login(response => {
25
21
  if (response.authResponse) {
26
22
  if (options.success) {
27
- options.success(_this, {
23
+ options.success(this, {
28
24
  id: response.authResponse.userID,
29
25
  access_token: response.authResponse.accessToken,
30
26
  expiration_date: new Date(response.authResponse.expiresIn * 1000 + new Date().getTime()).toJSON()
@@ -32,18 +28,18 @@ var provider = {
32
28
  }
33
29
  } else {
34
30
  if (options.error) {
35
- options.error(_this, response);
31
+ options.error(this, response);
36
32
  }
37
33
  }
38
34
  }, {
39
35
  scope: requestedPermissions
40
36
  });
41
37
  },
42
- restoreAuthentication: function (authData) {
38
+ restoreAuthentication(authData) {
43
39
  if (authData) {
44
- var newOptions = {};
40
+ const newOptions = {};
45
41
  if (initOptions) {
46
- for (var key in initOptions) {
42
+ for (const key in initOptions) {
47
43
  newOptions[key] = initOptions[key];
48
44
  }
49
45
  }
@@ -54,7 +50,7 @@ var provider = {
54
50
  // Most of the time, the users will match -- it's only in cases where
55
51
  // the FB SDK knows of a different user than the one being restored
56
52
  // from a Parse User that logged in with username/password.
57
- var existingResponse = FB.getAuthResponse();
53
+ const existingResponse = FB.getAuthResponse();
58
54
  if (existingResponse && existingResponse.userID !== authData.id) {
59
55
  FB.logout();
60
56
  }
@@ -62,10 +58,10 @@ var provider = {
62
58
  }
63
59
  return true;
64
60
  },
65
- getAuthType: function () {
61
+ getAuthType() {
66
62
  return 'facebook';
67
63
  },
68
- deauthenticate: function () {
64
+ deauthenticate() {
69
65
  this.restoreAuthentication(null);
70
66
  }
71
67
  };
@@ -77,7 +73,7 @@ var provider = {
77
73
  * @static
78
74
  * @hideconstructor
79
75
  */
80
- var FacebookUtils = {
76
+ const FacebookUtils = {
81
77
  /**
82
78
  * Initializes Parse Facebook integration. Call this function after you
83
79
  * have loaded the Facebook Javascript SDK with the same parameters
@@ -96,18 +92,18 @@ var FacebookUtils = {
96
92
  * interferes with Parse Facebook integration. Call FB.getLoginStatus()
97
93
  * explicitly if this behavior is required by your application.
98
94
  */
99
- init: function (options) {
95
+ init(options) {
100
96
  if (typeof FB === 'undefined') {
101
97
  throw new Error('The Facebook JavaScript SDK must be loaded before calling init.');
102
98
  }
103
99
  initOptions = {};
104
100
  if (options) {
105
- for (var key in options) {
101
+ for (const key in options) {
106
102
  initOptions[key] = options[key];
107
103
  }
108
104
  }
109
105
  if (initOptions.status && typeof console !== 'undefined') {
110
- var warn = console.warn || console.log || function () {}; // eslint-disable-line no-console
106
+ const warn = console.warn || console.log || function () {}; // eslint-disable-line no-console
111
107
  warn.call(console, 'The "status" flag passed into' + ' FB.init, when set to true, can interfere with Parse Facebook' + ' integration, so it has been suppressed. Please call' + ' FB.getLoginStatus() explicitly if you require this behavior.');
112
108
  }
113
109
  initOptions.status = false;
@@ -125,7 +121,7 @@ var FacebookUtils = {
125
121
  * @returns {boolean} <code>true</code> if the user has their account
126
122
  * linked to Facebook.
127
123
  */
128
- isLinked: function (user) {
124
+ isLinked(user) {
129
125
  return user._isLinked('facebook');
130
126
  },
131
127
  /**
@@ -152,7 +148,7 @@ var FacebookUtils = {
152
148
  * @param {object} options MasterKey / SessionToken. Alternatively can be used for authData if permissions is a string
153
149
  * @returns {Promise}
154
150
  */
155
- logIn: function (permissions, options) {
151
+ logIn(permissions, options) {
156
152
  if (!permissions || typeof permissions === 'string') {
157
153
  if (!initialized) {
158
154
  throw new Error('You must initialize FacebookUtils before calling logIn.');
@@ -190,7 +186,7 @@ var FacebookUtils = {
190
186
  * @param {object} options MasterKey / SessionToken. Alternatively can be used for authData if permissions is a string
191
187
  * @returns {Promise}
192
188
  */
193
- link: function (user, permissions, options) {
189
+ link(user, permissions, options) {
194
190
  if (!permissions || typeof permissions === 'string') {
195
191
  if (!initialized) {
196
192
  throw new Error('You must initialize FacebookUtils before calling link.');
@@ -220,9 +216,8 @@ var FacebookUtils = {
220
216
  return user._unlinkFrom('facebook', options);
221
217
  },
222
218
  // Used for testing purposes
223
- _getAuthProvider: function () {
219
+ _getAuthProvider() {
224
220
  return provider;
225
221
  }
226
222
  };
227
- var _default = FacebookUtils;
228
- exports.default = _default;
223
+ var _default = exports.default = FacebookUtils;
@@ -1,39 +1,43 @@
1
1
  "use strict";
2
2
 
3
3
  var _keysInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/keys");
4
+ var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
5
+ _Object$defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = void 0;
4
9
  var _idbKeyval = require("idb-keyval");
5
- /**
6
- * @flow
7
- */
8
10
  /* global window */
9
11
 
12
+ let IndexedDBStorageController;
10
13
  if (typeof window !== 'undefined' && window.indexedDB) {
11
14
  try {
12
- var ParseStore = (0, _idbKeyval.createStore)('parseDB', 'parseStore');
13
- var IndexedDBStorageController = {
15
+ const ParseStore = (0, _idbKeyval.createStore)('parseDB', 'parseStore');
16
+ IndexedDBStorageController = {
14
17
  async: 1,
15
- getItemAsync: function (path /*: string*/) {
18
+ getItemAsync(path) {
16
19
  return (0, _idbKeyval.get)(path, ParseStore);
17
20
  },
18
- setItemAsync: function (path /*: string*/, value /*: string*/) {
21
+ setItemAsync(path, value) {
19
22
  return (0, _idbKeyval.set)(path, value, ParseStore);
20
23
  },
21
- removeItemAsync: function (path /*: string*/) {
24
+ removeItemAsync(path) {
22
25
  return (0, _idbKeyval.del)(path, ParseStore);
23
26
  },
24
- getAllKeysAsync: function () {
27
+ getAllKeysAsync() {
25
28
  return (0, _keysInstanceProperty(_idbKeyval))(ParseStore);
26
29
  },
27
- clear: function () {
30
+ clear() {
28
31
  return (0, _idbKeyval.clear)(ParseStore);
29
32
  }
30
33
  };
31
- module.exports = IndexedDBStorageController;
32
34
  } catch (_) {
33
35
  // IndexedDB not accessible
34
- module.exports = undefined;
36
+ IndexedDBStorageController = undefined;
35
37
  }
36
38
  } else {
37
39
  // IndexedDB not supported
38
- module.exports = undefined;
39
- }
40
+ IndexedDBStorageController = undefined;
41
+ }
42
+ module.exports = IndexedDBStorageController;
43
+ var _default = exports.default = IndexedDBStorageController;
@@ -6,143 +6,77 @@ _Object$defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports.default = void 0;
9
- var _regenerator = _interopRequireDefault(require("@babel/runtime-corejs3/regenerator"));
10
9
  var _stringify = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/json/stringify"));
11
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/asyncToGenerator"));
12
10
  var _CoreManager = _interopRequireDefault(require("./CoreManager"));
13
11
  var _Storage = _interopRequireDefault(require("./Storage"));
14
12
  var _ParseInstallation = _interopRequireDefault(require("./ParseInstallation"));
15
13
  var _uuid = _interopRequireDefault(require("./uuid"));
16
- var CURRENT_INSTALLATION_KEY = 'currentInstallation';
17
- var CURRENT_INSTALLATION_ID_KEY = 'currentInstallationId';
18
- var iidCache /*: string | null*/ = null;
19
- var currentInstallationCache = null;
20
- var currentInstallationCacheMatchesDisk = false;
21
- var InstallationController = {
22
- updateInstallationOnDisk: function (installation /*: ParseInstallation*/) /*: Promise<void>*/{
23
- var _this = this;
24
- return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
25
- var path;
26
- return _regenerator.default.wrap(function (_context) {
27
- while (1) switch (_context.prev = _context.next) {
28
- case 0:
29
- path = _Storage.default.generatePath(CURRENT_INSTALLATION_KEY);
30
- _context.next = 3;
31
- return _Storage.default.setItemAsync(path, (0, _stringify.default)(installation.toJSON()));
32
- case 3:
33
- _this._setCurrentInstallationCache(installation);
34
- case 4:
35
- case "end":
36
- return _context.stop();
37
- }
38
- }, _callee);
39
- }))();
14
+ const CURRENT_INSTALLATION_KEY = 'currentInstallation';
15
+ const CURRENT_INSTALLATION_ID_KEY = 'currentInstallationId';
16
+ let iidCache = null;
17
+ let currentInstallationCache = null;
18
+ let currentInstallationCacheMatchesDisk = false;
19
+ const InstallationController = {
20
+ async updateInstallationOnDisk(installation) {
21
+ const path = _Storage.default.generatePath(CURRENT_INSTALLATION_KEY);
22
+ await _Storage.default.setItemAsync(path, (0, _stringify.default)(installation.toJSON()));
23
+ this._setCurrentInstallationCache(installation);
40
24
  },
41
- currentInstallationId: function () /*: Promise<string>*/{
42
- return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
43
- var path, iid;
44
- return _regenerator.default.wrap(function (_context2) {
45
- while (1) switch (_context2.prev = _context2.next) {
46
- case 0:
47
- if (!(typeof iidCache === 'string')) {
48
- _context2.next = 2;
49
- break;
50
- }
51
- return _context2.abrupt("return", iidCache);
52
- case 2:
53
- path = _Storage.default.generatePath(CURRENT_INSTALLATION_ID_KEY);
54
- _context2.next = 5;
55
- return _Storage.default.getItemAsync(path);
56
- case 5:
57
- iid = _context2.sent;
58
- if (iid) {
59
- _context2.next = 9;
60
- break;
61
- }
62
- iid = (0, _uuid.default)();
63
- return _context2.abrupt("return", _Storage.default.setItemAsync(path, iid).then(function () {
64
- iidCache = iid;
65
- return iid;
66
- }));
67
- case 9:
68
- iidCache = iid;
69
- return _context2.abrupt("return", iid);
70
- case 11:
71
- case "end":
72
- return _context2.stop();
73
- }
74
- }, _callee2);
75
- }))();
25
+ async currentInstallationId() {
26
+ if (typeof iidCache === 'string') {
27
+ return iidCache;
28
+ }
29
+ const path = _Storage.default.generatePath(CURRENT_INSTALLATION_ID_KEY);
30
+ let iid = await _Storage.default.getItemAsync(path);
31
+ if (!iid) {
32
+ iid = (0, _uuid.default)();
33
+ return _Storage.default.setItemAsync(path, iid).then(() => {
34
+ iidCache = iid;
35
+ return iid;
36
+ });
37
+ }
38
+ iidCache = iid;
39
+ return iid;
76
40
  },
77
- currentInstallation: function () /*: Promise<ParseInstallation | null>*/{
78
- var _this2 = this;
79
- return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
80
- var path, installationData, current, installationId, installation;
81
- return _regenerator.default.wrap(function (_context3) {
82
- while (1) switch (_context3.prev = _context3.next) {
83
- case 0:
84
- if (!currentInstallationCache) {
85
- _context3.next = 2;
86
- break;
87
- }
88
- return _context3.abrupt("return", currentInstallationCache);
89
- case 2:
90
- if (!currentInstallationCacheMatchesDisk) {
91
- _context3.next = 4;
92
- break;
93
- }
94
- return _context3.abrupt("return", null);
95
- case 4:
96
- path = _Storage.default.generatePath(CURRENT_INSTALLATION_KEY);
97
- _context3.next = 7;
98
- return _Storage.default.getItemAsync(path);
99
- case 7:
100
- installationData = _context3.sent;
101
- currentInstallationCacheMatchesDisk = true;
102
- if (!installationData) {
103
- _context3.next = 15;
104
- break;
105
- }
106
- installationData = JSON.parse(installationData);
107
- installationData.className = '_Installation';
108
- current = _ParseInstallation.default.fromJSON(installationData);
109
- currentInstallationCache = current;
110
- return _context3.abrupt("return", current);
111
- case 15:
112
- _context3.next = 17;
113
- return _this2.currentInstallationId();
114
- case 17:
115
- installationId = _context3.sent;
116
- installation = new _ParseInstallation.default();
117
- installation.set('deviceType', _ParseInstallation.default.DEVICE_TYPES.WEB);
118
- installation.set('installationId', installationId);
119
- installation.set('parseVersion', _CoreManager.default.get('VERSION'));
120
- currentInstallationCache = installation;
121
- _context3.next = 25;
122
- return _Storage.default.setItemAsync(path, (0, _stringify.default)(installation.toJSON()));
123
- case 25:
124
- return _context3.abrupt("return", installation);
125
- case 26:
126
- case "end":
127
- return _context3.stop();
128
- }
129
- }, _callee3);
130
- }))();
41
+ async currentInstallation() {
42
+ if (currentInstallationCache) {
43
+ return currentInstallationCache;
44
+ }
45
+ if (currentInstallationCacheMatchesDisk) {
46
+ return null;
47
+ }
48
+ const path = _Storage.default.generatePath(CURRENT_INSTALLATION_KEY);
49
+ let installationData = await _Storage.default.getItemAsync(path);
50
+ currentInstallationCacheMatchesDisk = true;
51
+ if (installationData) {
52
+ installationData = JSON.parse(installationData);
53
+ installationData.className = '_Installation';
54
+ const current = _ParseInstallation.default.fromJSON(installationData);
55
+ currentInstallationCache = current;
56
+ return current;
57
+ }
58
+ const installationId = await this.currentInstallationId();
59
+ const installation = new _ParseInstallation.default();
60
+ installation.set('deviceType', _ParseInstallation.default.DEVICE_TYPES.WEB);
61
+ installation.set('installationId', installationId);
62
+ installation.set('parseVersion', _CoreManager.default.get('VERSION'));
63
+ currentInstallationCache = installation;
64
+ await _Storage.default.setItemAsync(path, (0, _stringify.default)(installation.toJSON()));
65
+ return installation;
131
66
  },
132
- _clearCache: function () {
67
+ _clearCache() {
133
68
  iidCache = null;
134
69
  currentInstallationCache = null;
135
70
  currentInstallationCacheMatchesDisk = false;
136
71
  },
137
- _setInstallationIdCache: function (iid /*: string*/) {
72
+ _setInstallationIdCache(iid) {
138
73
  iidCache = iid;
139
74
  },
140
- _setCurrentInstallationCache: function (installation /*: ParseInstallation*/) {
141
- var matchesDisk /*: boolean*/ = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
75
+ _setCurrentInstallationCache(installation) {
76
+ let matchesDisk = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
142
77
  currentInstallationCache = installation;
143
78
  currentInstallationCacheMatchesDisk = matchesDisk;
144
79
  }
145
80
  };
146
81
  module.exports = InstallationController;
147
- var _default = InstallationController;
148
- exports.default = _default;
82
+ var _default = exports.default = InstallationController;