parse 5.1.0-alpha.1 → 5.1.0-alpha.11

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 (143) hide show
  1. package/README.md +13 -0
  2. package/dist/parse.js +1464 -1051
  3. package/dist/parse.min.js +2 -2
  4. package/dist/parse.weapp.js +2367 -1090
  5. package/dist/parse.weapp.min.js +2 -2
  6. package/lib/browser/CoreManager.js +48 -171
  7. package/lib/browser/InstallationController.js +134 -23
  8. package/lib/browser/LiveQueryClient.js +43 -35
  9. package/lib/browser/LiveQuerySubscription.js +15 -5
  10. package/lib/browser/LocalDatastoreController.default.js +248 -0
  11. package/lib/browser/LocalDatastoreController.js +1 -246
  12. package/lib/browser/ObjectStateMutations.js +6 -5
  13. package/lib/browser/OfflineQuery.js +3 -2
  14. package/lib/browser/Parse.js +31 -7
  15. package/lib/browser/ParseACL.js +21 -11
  16. package/lib/browser/ParseFile.js +4 -0
  17. package/lib/browser/ParseGeoPoint.js +12 -8
  18. package/lib/browser/ParseHooks.js +2 -0
  19. package/lib/browser/ParseInstallation.js +274 -13
  20. package/lib/browser/ParseLiveQuery.js +32 -23
  21. package/lib/browser/ParseObject.js +37 -40
  22. package/lib/browser/ParseOp.js +21 -7
  23. package/lib/browser/ParseQuery.js +1 -0
  24. package/lib/browser/ParseRelation.js +12 -7
  25. package/lib/browser/ParseRole.js +2 -0
  26. package/lib/browser/ParseSession.js +1 -1
  27. package/lib/browser/ParseUser.js +51 -15
  28. package/lib/browser/RESTController.js +6 -5
  29. package/lib/browser/SingleInstanceStateController.js +2 -4
  30. package/lib/browser/Storage.js +1 -2
  31. package/lib/browser/StorageController.js +3 -0
  32. package/lib/browser/WebSocketController.js +13 -0
  33. package/lib/browser/arrayContainsObject.js +4 -3
  34. package/lib/browser/canBeSerialized.js +6 -4
  35. package/lib/browser/decode.js +8 -5
  36. package/lib/browser/encode.js +6 -4
  37. package/lib/browser/equals.js +4 -3
  38. package/lib/browser/unique.js +3 -2
  39. package/lib/browser/unsavedChildren.js +4 -2
  40. package/lib/browser/uuid.js +11 -5
  41. package/lib/node/CoreManager.js +48 -171
  42. package/lib/node/InstallationController.js +65 -21
  43. package/lib/node/LiveQueryClient.js +2 -5
  44. package/lib/node/LiveQuerySubscription.js +2 -2
  45. package/lib/node/LocalDatastoreController.default.js +67 -0
  46. package/lib/node/LocalDatastoreController.js +1 -65
  47. package/lib/node/ObjectStateMutations.js +8 -9
  48. package/lib/node/OfflineQuery.js +3 -2
  49. package/lib/node/Parse.js +31 -7
  50. package/lib/node/ParseACL.js +21 -11
  51. package/lib/node/ParseFile.js +4 -0
  52. package/lib/node/ParseGeoPoint.js +11 -11
  53. package/lib/node/ParseHooks.js +2 -0
  54. package/lib/node/ParseInstallation.js +207 -7
  55. package/lib/node/ParseLiveQuery.js +2 -3
  56. package/lib/node/ParseObject.js +9 -12
  57. package/lib/node/ParseOp.js +21 -7
  58. package/lib/node/ParseQuery.js +1 -0
  59. package/lib/node/ParseRelation.js +14 -8
  60. package/lib/node/ParseRole.js +2 -0
  61. package/lib/node/ParseSession.js +1 -1
  62. package/lib/node/ParseUser.js +20 -13
  63. package/lib/node/RESTController.js +5 -5
  64. package/lib/node/SingleInstanceStateController.js +2 -8
  65. package/lib/node/Storage.js +1 -2
  66. package/lib/node/StorageController.js +3 -0
  67. package/lib/node/WebSocketController.js +10 -0
  68. package/lib/node/arrayContainsObject.js +4 -3
  69. package/lib/node/canBeSerialized.js +6 -4
  70. package/lib/node/decode.js +9 -5
  71. package/lib/node/encode.js +7 -4
  72. package/lib/node/equals.js +4 -3
  73. package/lib/node/unique.js +3 -2
  74. package/lib/node/unsavedChildren.js +4 -2
  75. package/lib/node/uuid.js +10 -8
  76. package/lib/react-native/CoreManager.js +39 -2
  77. package/lib/react-native/InstallationController.js +77 -9
  78. package/lib/react-native/LiveQueryClient.js +28 -20
  79. package/lib/react-native/LiveQuerySubscription.js +14 -5
  80. package/lib/react-native/LocalDatastoreController.default.js +91 -0
  81. package/lib/react-native/LocalDatastoreController.js +1 -91
  82. package/lib/react-native/ObjectStateMutations.js +6 -5
  83. package/lib/react-native/OfflineQuery.js +3 -2
  84. package/lib/react-native/Parse.js +23 -7
  85. package/lib/react-native/ParseACL.js +19 -11
  86. package/lib/react-native/ParseGeoPoint.js +5 -3
  87. package/lib/react-native/ParseInstallation.js +115 -10
  88. package/lib/react-native/ParseLiveQuery.js +11 -2
  89. package/lib/react-native/ParseObject.js +28 -31
  90. package/lib/react-native/ParseOp.js +20 -6
  91. package/lib/react-native/ParseQuery.js +1 -0
  92. package/lib/react-native/ParseRelation.js +10 -7
  93. package/lib/react-native/ParseRole.js +2 -0
  94. package/lib/react-native/ParseUser.js +6 -2
  95. package/lib/react-native/RESTController.js +5 -5
  96. package/lib/react-native/SingleInstanceStateController.js +0 -2
  97. package/lib/react-native/Storage.js +1 -2
  98. package/lib/react-native/StorageController.js +1 -0
  99. package/lib/react-native/WebSocketController.js +5 -0
  100. package/lib/react-native/arrayContainsObject.js +3 -2
  101. package/lib/react-native/canBeSerialized.js +5 -3
  102. package/lib/react-native/decode.js +7 -5
  103. package/lib/react-native/encode.js +6 -4
  104. package/lib/react-native/equals.js +4 -3
  105. package/lib/react-native/unique.js +3 -2
  106. package/lib/react-native/unsavedChildren.js +3 -2
  107. package/lib/react-native/uuid.js +9 -4
  108. package/lib/weapp/CoreManager.js +48 -171
  109. package/lib/weapp/InstallationController.js +134 -23
  110. package/lib/weapp/LiveQueryClient.js +43 -35
  111. package/lib/weapp/LiveQuerySubscription.js +15 -5
  112. package/lib/weapp/LocalDatastoreController.default.js +248 -0
  113. package/lib/weapp/LocalDatastoreController.js +1 -246
  114. package/lib/weapp/ObjectStateMutations.js +6 -5
  115. package/lib/weapp/OfflineQuery.js +3 -2
  116. package/lib/weapp/Parse.js +31 -7
  117. package/lib/weapp/ParseACL.js +21 -11
  118. package/lib/weapp/ParseFile.js +4 -0
  119. package/lib/weapp/ParseGeoPoint.js +12 -8
  120. package/lib/weapp/ParseHooks.js +2 -0
  121. package/lib/weapp/ParseInstallation.js +274 -13
  122. package/lib/weapp/ParseLiveQuery.js +32 -23
  123. package/lib/weapp/ParseObject.js +37 -40
  124. package/lib/weapp/ParseOp.js +21 -7
  125. package/lib/weapp/ParseQuery.js +1 -0
  126. package/lib/weapp/ParseRelation.js +12 -7
  127. package/lib/weapp/ParseRole.js +2 -0
  128. package/lib/weapp/ParseSession.js +1 -1
  129. package/lib/weapp/ParseUser.js +51 -15
  130. package/lib/weapp/RESTController.js +6 -5
  131. package/lib/weapp/SingleInstanceStateController.js +2 -4
  132. package/lib/weapp/Storage.js +1 -2
  133. package/lib/weapp/StorageController.js +3 -0
  134. package/lib/weapp/WebSocketController.js +13 -0
  135. package/lib/weapp/arrayContainsObject.js +4 -3
  136. package/lib/weapp/canBeSerialized.js +6 -4
  137. package/lib/weapp/decode.js +8 -5
  138. package/lib/weapp/encode.js +6 -4
  139. package/lib/weapp/equals.js +4 -3
  140. package/lib/weapp/unique.js +3 -2
  141. package/lib/weapp/unsavedChildren.js +4 -2
  142. package/lib/weapp/uuid.js +12 -5
  143. package/package.json +3 -1
@@ -1,40 +1,84 @@
1
1
  "use strict";
2
2
 
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _CoreManager = _interopRequireDefault(require("./CoreManager"));
3
8
  var _Storage = _interopRequireDefault(require("./Storage"));
9
+ var _ParseInstallation = _interopRequireDefault(require("./ParseInstallation"));
10
+ var _uuid = _interopRequireDefault(require("./uuid"));
4
11
  function _interopRequireDefault(obj) {
5
12
  return obj && obj.__esModule ? obj : {
6
13
  default: obj
7
14
  };
8
15
  }
9
- /**
10
- * @flow
11
- */
12
-
13
- const uuidv4 = require('./uuid');
14
- let iidCache = null;
16
+ const CURRENT_INSTALLATION_KEY = 'currentInstallation';
17
+ const CURRENT_INSTALLATION_ID_KEY = 'currentInstallationId';
18
+ let iidCache /*: string | null*/ = null;
19
+ let currentInstallationCache = null;
20
+ let currentInstallationCacheMatchesDisk = false;
15
21
  const InstallationController = {
16
- currentInstallationId() /*: Promise<string>*/{
22
+ async updateInstallationOnDisk(installation /*: ParseInstallation*/) /*: Promise<void>*/{
23
+ const path = _Storage.default.generatePath(CURRENT_INSTALLATION_KEY);
24
+ await _Storage.default.setItemAsync(path, JSON.stringify(installation.toJSON()));
25
+ this._setCurrentInstallationCache(installation);
26
+ },
27
+ async currentInstallationId() /*: Promise<string>*/{
17
28
  if (typeof iidCache === 'string') {
18
- return Promise.resolve(iidCache);
29
+ return iidCache;
30
+ }
31
+ const path = _Storage.default.generatePath(CURRENT_INSTALLATION_ID_KEY);
32
+ let iid = await _Storage.default.getItemAsync(path);
33
+ if (!iid) {
34
+ iid = (0, _uuid.default)();
35
+ return _Storage.default.setItemAsync(path, iid).then(() => {
36
+ iidCache = iid;
37
+ return iid;
38
+ });
19
39
  }
20
- const path = _Storage.default.generatePath('installationId');
21
- return _Storage.default.getItemAsync(path).then(iid => {
22
- if (!iid) {
23
- iid = uuidv4();
24
- return _Storage.default.setItemAsync(path, iid).then(() => {
25
- iidCache = iid;
26
- return iid;
27
- });
28
- }
29
- iidCache = iid;
30
- return iid;
31
- });
40
+ iidCache = iid;
41
+ return iid;
42
+ },
43
+ async currentInstallation() /*: Promise<ParseInstallation | null>*/{
44
+ if (currentInstallationCache) {
45
+ return currentInstallationCache;
46
+ }
47
+ if (currentInstallationCacheMatchesDisk) {
48
+ return null;
49
+ }
50
+ const path = _Storage.default.generatePath(CURRENT_INSTALLATION_KEY);
51
+ let installationData = await _Storage.default.getItemAsync(path);
52
+ currentInstallationCacheMatchesDisk = true;
53
+ if (installationData) {
54
+ installationData = JSON.parse(installationData);
55
+ installationData.className = '_Installation';
56
+ const current = _ParseInstallation.default.fromJSON(installationData);
57
+ currentInstallationCache = current;
58
+ return current;
59
+ }
60
+ const installationId = await this.currentInstallationId();
61
+ const installation = new _ParseInstallation.default();
62
+ installation.set('deviceType', _ParseInstallation.default.DEVICE_TYPES.WEB);
63
+ installation.set('installationId', installationId);
64
+ installation.set('parseVersion', _CoreManager.default.get('VERSION'));
65
+ currentInstallationCache = installation;
66
+ await _Storage.default.setItemAsync(path, JSON.stringify(installation.toJSON()));
67
+ return installation;
32
68
  },
33
69
  _clearCache() {
34
70
  iidCache = null;
71
+ currentInstallationCache = null;
72
+ currentInstallationCacheMatchesDisk = false;
35
73
  },
36
74
  _setInstallationIdCache(iid /*: string*/) {
37
75
  iidCache = iid;
76
+ },
77
+ _setCurrentInstallationCache(installation /*: ParseInstallation*/, matchesDisk /*: boolean*/ = true) {
78
+ currentInstallationCache = installation;
79
+ currentInstallationCacheMatchesDisk = matchesDisk;
38
80
  }
39
81
  };
40
- module.exports = InstallationController;
82
+ module.exports = InstallationController;
83
+ var _default = InstallationController;
84
+ exports.default = _default;
@@ -14,8 +14,6 @@ function _interopRequireDefault(obj) {
14
14
  default: obj
15
15
  };
16
16
  }
17
- /* global WebSocket */
18
-
19
17
  // The LiveQuery client inner state
20
18
  const CLIENT_STATE = {
21
19
  INITIALIZED: 'initialized',
@@ -163,8 +161,8 @@ class LiveQueryClient {
163
161
  this.state = CLIENT_STATE.INITIALIZED;
164
162
  const EventEmitter = _CoreManager.default.getEventEmitter();
165
163
  this.emitter = new EventEmitter();
166
- this.on = this.emitter.on;
167
- this.emit = this.emitter.emit;
164
+ this.on = (eventName, listener) => this.emitter.on(eventName, listener);
165
+ this.emit = (eventName, ...args) => this.emitter.emit(eventName, ...args);
168
166
  // adding listener so process does not crash
169
167
  // best practice is for developer to register their own listener
170
168
  this.on('error', () => {});
@@ -481,6 +479,5 @@ class LiveQueryClient {
481
479
  }).bind(this), time);
482
480
  }
483
481
  }
484
- _CoreManager.default.setWebSocketController(require('ws'));
485
482
  var _default = LiveQueryClient;
486
483
  exports.default = _default;
@@ -108,8 +108,8 @@ class Subscription {
108
108
  this.subscribed = false;
109
109
  const EventEmitter = _CoreManager.default.getEventEmitter();
110
110
  this.emitter = new EventEmitter();
111
- this.on = this.emitter.on;
112
- this.emit = this.emitter.emit;
111
+ this.on = (eventName, listener) => this.emitter.on(eventName, listener);
112
+ this.emit = (eventName, ...args) => this.emitter.emit(eventName, ...args);
113
113
  // adding listener so process does not crash
114
114
  // best practice is for developer to register their own listener
115
115
  this.on('error', () => {});
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+
3
+ var _LocalDatastoreUtils = require("./LocalDatastoreUtils");
4
+ var _Storage = _interopRequireDefault(require("./Storage"));
5
+ function _interopRequireDefault(obj) {
6
+ return obj && obj.__esModule ? obj : {
7
+ default: obj
8
+ };
9
+ }
10
+ /**
11
+ * @flow
12
+ */
13
+
14
+ const LocalDatastoreController = {
15
+ async fromPinWithName(name /*: string*/) /*: Array<Object>*/{
16
+ const values = await _Storage.default.getItemAsync(name);
17
+ if (!values) {
18
+ return [];
19
+ }
20
+ const objects = JSON.parse(values);
21
+ return objects;
22
+ },
23
+ pinWithName(name /*: string*/, value /*: any*/) {
24
+ const values = JSON.stringify(value);
25
+ return _Storage.default.setItemAsync(name, values);
26
+ },
27
+ unPinWithName(name /*: string*/) {
28
+ return _Storage.default.removeItemAsync(name);
29
+ },
30
+ async getAllContents() /*: Object*/{
31
+ const keys = await _Storage.default.getAllKeysAsync();
32
+ return keys.reduce(async (previousPromise, key) => {
33
+ const LDS = await previousPromise;
34
+ if ((0, _LocalDatastoreUtils.isLocalDatastoreKey)(key)) {
35
+ const value = await _Storage.default.getItemAsync(key);
36
+ try {
37
+ LDS[key] = JSON.parse(value);
38
+ } catch (error) {
39
+ console.error('Error getAllContents: ', error);
40
+ }
41
+ }
42
+ return LDS;
43
+ }, Promise.resolve({}));
44
+ },
45
+ // Used for testing
46
+ async getRawStorage() /*: Object*/{
47
+ const keys = await _Storage.default.getAllKeysAsync();
48
+ return keys.reduce(async (previousPromise, key) => {
49
+ const LDS = await previousPromise;
50
+ const value = await _Storage.default.getItemAsync(key);
51
+ LDS[key] = value;
52
+ return LDS;
53
+ }, Promise.resolve({}));
54
+ },
55
+ async clear() /*: Promise*/{
56
+ const keys = await _Storage.default.getAllKeysAsync();
57
+ const toRemove = [];
58
+ for (const key of keys) {
59
+ if ((0, _LocalDatastoreUtils.isLocalDatastoreKey)(key)) {
60
+ toRemove.push(key);
61
+ }
62
+ }
63
+ const promises = toRemove.map(this.unPinWithName);
64
+ return Promise.all(promises);
65
+ }
66
+ };
67
+ module.exports = LocalDatastoreController;
@@ -1,67 +1,3 @@
1
1
  "use strict";
2
2
 
3
- var _LocalDatastoreUtils = require("./LocalDatastoreUtils");
4
- var _Storage = _interopRequireDefault(require("./Storage"));
5
- function _interopRequireDefault(obj) {
6
- return obj && obj.__esModule ? obj : {
7
- default: obj
8
- };
9
- }
10
- /**
11
- * @flow
12
- */
13
-
14
- const LocalDatastoreController = {
15
- async fromPinWithName(name /*: string*/) /*: Array<Object>*/{
16
- const values = await _Storage.default.getItemAsync(name);
17
- if (!values) {
18
- return [];
19
- }
20
- const objects = JSON.parse(values);
21
- return objects;
22
- },
23
- pinWithName(name /*: string*/, value /*: any*/) {
24
- const values = JSON.stringify(value);
25
- return _Storage.default.setItemAsync(name, values);
26
- },
27
- unPinWithName(name /*: string*/) {
28
- return _Storage.default.removeItemAsync(name);
29
- },
30
- async getAllContents() /*: Object*/{
31
- const keys = await _Storage.default.getAllKeysAsync();
32
- return keys.reduce(async (previousPromise, key) => {
33
- const LDS = await previousPromise;
34
- if ((0, _LocalDatastoreUtils.isLocalDatastoreKey)(key)) {
35
- const value = await _Storage.default.getItemAsync(key);
36
- try {
37
- LDS[key] = JSON.parse(value);
38
- } catch (error) {
39
- console.error('Error getAllContents: ', error);
40
- }
41
- }
42
- return LDS;
43
- }, Promise.resolve({}));
44
- },
45
- // Used for testing
46
- async getRawStorage() /*: Object*/{
47
- const keys = await _Storage.default.getAllKeysAsync();
48
- return keys.reduce(async (previousPromise, key) => {
49
- const LDS = await previousPromise;
50
- const value = await _Storage.default.getItemAsync(key);
51
- LDS[key] = value;
52
- return LDS;
53
- }, Promise.resolve({}));
54
- },
55
- async clear() /*: Promise*/{
56
- const keys = await _Storage.default.getAllKeysAsync();
57
- const toRemove = [];
58
- for (const key of keys) {
59
- if ((0, _LocalDatastoreUtils.isLocalDatastoreKey)(key)) {
60
- toRemove.push(key);
61
- }
62
- }
63
- const promises = toRemove.map(this.unPinWithName);
64
- return Promise.all(promises);
65
- }
66
- };
67
- module.exports = LocalDatastoreController;
3
+ module.exports = require('./LocalDatastoreController.default');
@@ -13,8 +13,8 @@ exports.pushPendingState = pushPendingState;
13
13
  exports.setPendingOp = setPendingOp;
14
14
  exports.setServerData = setServerData;
15
15
  var _encode = _interopRequireDefault(require("./encode"));
16
+ var _CoreManager = _interopRequireDefault(require("./CoreManager"));
16
17
  var _ParseFile = _interopRequireDefault(require("./ParseFile"));
17
- var _ParseObject = _interopRequireDefault(require("./ParseObject"));
18
18
  var _ParseRelation = _interopRequireDefault(require("./ParseRelation"));
19
19
  var _TaskQueue = _interopRequireDefault(require("./TaskQueue"));
20
20
  var _ParseOp = require("./ParseOp");
@@ -117,18 +117,16 @@ function estimateAttributes(serverData /*: AttributeMap*/, pendingOps /*: Array<
117
117
  if (attr.includes('.')) {
118
118
  // convert a.b.c into { a: { b: { c: value } } }
119
119
  const fields = attr.split('.');
120
- const first = fields[0];
121
120
  const last = fields[fields.length - 1];
122
- data[first] = {
123
- ...serverData[first]
124
- };
125
- let object = {
126
- ...data
127
- };
121
+ let object = data;
128
122
  for (let i = 0; i < fields.length - 1; i++) {
129
123
  const key = fields[i];
130
124
  if (!(key in object)) {
131
125
  object[key] = {};
126
+ } else {
127
+ object[key] = {
128
+ ...object[key]
129
+ };
132
130
  }
133
131
  object = object[key];
134
132
  }
@@ -156,10 +154,11 @@ function nestedSet(obj, key, value) {
156
154
  }
157
155
  }
158
156
  function commitServerChanges(serverData /*: AttributeMap*/, objectCache /*: ObjectCache*/, changes /*: AttributeMap*/) {
157
+ const ParseObject = _CoreManager.default.getParseObject();
159
158
  for (const attr in changes) {
160
159
  const val = changes[attr];
161
160
  nestedSet(serverData, attr, val);
162
- if (val && typeof val === 'object' && !(val instanceof _ParseObject.default) && !(val instanceof _ParseFile.default) && !(val instanceof _ParseRelation.default)) {
161
+ if (val && typeof val === 'object' && !(val instanceof ParseObject) && !(val instanceof _ParseFile.default) && !(val instanceof _ParseRelation.default)) {
163
162
  const json = (0, _encode.default)(val, false, true);
164
163
  objectCache[attr] = JSON.stringify(json);
165
164
  }
@@ -288,12 +288,13 @@ function matchesKeyConstraints(className, object, objects, key, constraints) {
288
288
  }
289
289
  // More complex cases
290
290
  for (const condition in constraints) {
291
+ var _compareTo, _compareTo2;
291
292
  compareTo = constraints[condition];
292
- if (compareTo.__type) {
293
+ if ((_compareTo = compareTo) !== null && _compareTo !== void 0 && _compareTo.__type) {
293
294
  compareTo = decode(compareTo);
294
295
  }
295
296
  // is it a $relativeTime? convert to date
296
- if (compareTo['$relativeTime']) {
297
+ if ((_compareTo2 = compareTo) !== null && _compareTo2 !== void 0 && _compareTo2['$relativeTime']) {
297
298
  const parserResult = relativeTimeToDate(compareTo['$relativeTime']);
298
299
  if (parserResult.status !== 'success') {
299
300
  throw new ParseError(ParseError.INVALID_JSON, `bad $relativeTime (${key}) value. ${parserResult.info}`);
package/lib/node/Parse.js CHANGED
@@ -38,6 +38,9 @@ var _Storage = _interopRequireDefault(require("./Storage"));
38
38
  var _ParseUser = _interopRequireDefault(require("./ParseUser"));
39
39
  var _ParseLiveQuery = _interopRequireDefault(require("./ParseLiveQuery"));
40
40
  var _LiveQueryClient = _interopRequireDefault(require("./LiveQueryClient"));
41
+ var _LocalDatastoreController = _interopRequireDefault(require("./LocalDatastoreController"));
42
+ var _StorageController = _interopRequireDefault(require("./StorageController"));
43
+ var _WebSocketController = _interopRequireDefault(require("./WebSocketController"));
41
44
  function _getRequireWildcardCache(nodeInterop) {
42
45
  if (typeof WeakMap !== "function") return null;
43
46
  var cacheBabelInterop = new WeakMap();
@@ -100,7 +103,6 @@ const Parse /*: ParseType*/ = {
100
103
  CoreManager: _CoreManager.default,
101
104
  Config: _ParseConfig.default,
102
105
  Error: _ParseError.default,
103
- EventuallyQueue: _EventuallyQueue.default,
104
106
  FacebookUtils: _FacebookUtils.default,
105
107
  File: _ParseFile.default,
106
108
  GeoPoint: _ParseGeoPoint.default,
@@ -126,10 +128,19 @@ const Parse /*: ParseType*/ = {
126
128
  Storage: _Storage.default,
127
129
  User: _ParseUser.default,
128
130
  LiveQueryClient: _LiveQueryClient.default,
129
- LiveQuery: undefined,
130
131
  IndexedDB: undefined,
131
132
  Hooks: undefined,
132
133
  Parse: undefined,
134
+ /**
135
+ * @member {EventuallyQueue} Parse.EventuallyQueue
136
+ * @static
137
+ */
138
+ set EventuallyQueue(queue /*: EventuallyQueue*/) {
139
+ _CoreManager.default.setEventuallyQueue(queue);
140
+ },
141
+ get EventuallyQueue() {
142
+ return _CoreManager.default.getEventuallyQueue();
143
+ },
133
144
  /**
134
145
  * Call this method first to set up your authentication tokens for Parse.
135
146
  *
@@ -147,8 +158,13 @@ const Parse /*: ParseType*/ = {
147
158
  _CoreManager.default.set('MASTER_KEY', masterKey);
148
159
  _CoreManager.default.set('USE_MASTER_KEY', false);
149
160
  _CoreManager.default.setIfNeeded('EventEmitter', _EventEmitter.default);
150
- Parse.LiveQuery = new _ParseLiveQuery.default();
151
- _CoreManager.default.setIfNeeded('LiveQuery', Parse.LiveQuery);
161
+ _CoreManager.default.setIfNeeded('LiveQuery', new _ParseLiveQuery.default());
162
+ _CoreManager.default.setIfNeeded('CryptoController', _CryptoController.default);
163
+ _CoreManager.default.setIfNeeded('EventuallyQueue', _EventuallyQueue.default);
164
+ _CoreManager.default.setIfNeeded('InstallationController', _InstallationController.default);
165
+ _CoreManager.default.setIfNeeded('LocalDatastoreController', _LocalDatastoreController.default);
166
+ _CoreManager.default.setIfNeeded('StorageController', _StorageController.default);
167
+ _CoreManager.default.setIfNeeded('WebSocketController', _WebSocketController.default);
152
168
  },
153
169
  /**
154
170
  * Call this method to set your AsyncStorage engine
@@ -240,6 +256,16 @@ const Parse /*: ParseType*/ = {
240
256
  get serverAuthType() {
241
257
  return _CoreManager.default.get('SERVER_AUTH_TYPE');
242
258
  },
259
+ /**
260
+ * @member {ParseLiveQuery} Parse.LiveQuery
261
+ * @static
262
+ */
263
+ set LiveQuery(liveQuery /*: ParseLiveQuery*/) {
264
+ _CoreManager.default.setLiveQuery(liveQuery);
265
+ },
266
+ get LiveQuery() {
267
+ return _CoreManager.default.getLiveQuery();
268
+ },
243
269
  /**
244
270
  * @member {string} Parse.liveQueryServerURL
245
271
  * @static
@@ -322,7 +348,7 @@ const Parse /*: ParseType*/ = {
322
348
  if (!this.LocalDatastore.isEnabled) {
323
349
  this.LocalDatastore.isEnabled = true;
324
350
  if (polling) {
325
- _EventuallyQueue.default.poll(ms);
351
+ _CoreManager.default.getEventuallyQueue().poll(ms);
326
352
  }
327
353
  }
328
354
  },
@@ -372,8 +398,6 @@ const Parse /*: ParseType*/ = {
372
398
  return this.encryptedUser;
373
399
  }
374
400
  };
375
- _CoreManager.default.setCryptoController(_CryptoController.default);
376
- _CoreManager.default.setInstallationController(_InstallationController.default);
377
401
  _CoreManager.default.setRESTController(_RESTController.default);
378
402
  Parse.initialize = Parse._initialize;
379
403
  Parse.Cloud = Parse.Cloud || {};
@@ -4,8 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- var _ParseRole = _interopRequireDefault(require("./ParseRole"));
8
- var _ParseUser = _interopRequireDefault(require("./ParseUser"));
7
+ var _CoreManager = _interopRequireDefault(require("./CoreManager"));
9
8
  function _interopRequireDefault(obj) {
10
9
  return obj && obj.__esModule ? obj : {
11
10
  default: obj
@@ -14,6 +13,8 @@ function _interopRequireDefault(obj) {
14
13
  /**
15
14
  * @flow
16
15
  */
16
+ /*:: import type ParseRole from './ParseRole';*/
17
+ /*:: import type ParseUser from './ParseUser';*/
17
18
  /*:: type PermissionsMap = { [permission: string]: boolean };*/
18
19
  /*:: type ByIdMap = { [userId: string]: PermissionsMap };*/
19
20
  const PUBLIC_KEY = '*';
@@ -40,7 +41,8 @@ class ParseACL {
40
41
  constructor(arg1 /*: ParseUser | ByIdMap*/) {
41
42
  this.permissionsById = {};
42
43
  if (arg1 && typeof arg1 === 'object') {
43
- if (arg1 instanceof _ParseUser.default) {
44
+ const ParseUser = _CoreManager.default.getParseUser();
45
+ if (arg1 instanceof ParseUser) {
44
46
  this.setReadAccess(arg1, true);
45
47
  this.setWriteAccess(arg1, true);
46
48
  } else {
@@ -106,9 +108,11 @@ class ParseACL {
106
108
  return true;
107
109
  }
108
110
  _setAccess(accessType /*: string*/, userId /*: ParseUser | ParseRole | string*/, allowed /*: boolean*/) {
109
- if (userId instanceof _ParseUser.default) {
111
+ const ParseRole = _CoreManager.default.getParseRole();
112
+ const ParseUser = _CoreManager.default.getParseUser();
113
+ if (userId instanceof ParseUser) {
110
114
  userId = userId.id;
111
- } else if (userId instanceof _ParseRole.default) {
115
+ } else if (userId instanceof ParseRole) {
112
116
  const name = userId.getName();
113
117
  if (!name) {
114
118
  throw new TypeError('Role must have a name');
@@ -141,12 +145,14 @@ class ParseACL {
141
145
  }
142
146
  }
143
147
  _getAccess(accessType /*: string*/, userId /*: ParseUser | ParseRole | string*/) /*: boolean*/{
144
- if (userId instanceof _ParseUser.default) {
148
+ const ParseRole = _CoreManager.default.getParseRole();
149
+ const ParseUser = _CoreManager.default.getParseUser();
150
+ if (userId instanceof ParseUser) {
145
151
  userId = userId.id;
146
152
  if (!userId) {
147
153
  throw new Error('Cannot get access for a ParseUser without an ID');
148
154
  }
149
- } else if (userId instanceof _ParseRole.default) {
155
+ } else if (userId instanceof ParseRole) {
150
156
  const name = userId.getName();
151
157
  if (!name) {
152
158
  throw new TypeError('Role must have a name');
@@ -252,7 +258,8 @@ class ParseACL {
252
258
  * @throws {TypeError} If role is neither a Parse.Role nor a String.
253
259
  */
254
260
  getRoleReadAccess(role /*: ParseRole | string*/) /*: boolean*/{
255
- if (role instanceof _ParseRole.default) {
261
+ const ParseRole = _CoreManager.default.getParseRole();
262
+ if (role instanceof ParseRole) {
256
263
  // Normalize to the String name
257
264
  role = role.getName();
258
265
  }
@@ -272,7 +279,8 @@ class ParseACL {
272
279
  * @throws {TypeError} If role is neither a Parse.Role nor a String.
273
280
  */
274
281
  getRoleWriteAccess(role /*: ParseRole | string*/) /*: boolean*/{
275
- if (role instanceof _ParseRole.default) {
282
+ const ParseRole = _CoreManager.default.getParseRole();
283
+ if (role instanceof ParseRole) {
276
284
  // Normalize to the String name
277
285
  role = role.getName();
278
286
  }
@@ -291,7 +299,8 @@ class ParseACL {
291
299
  * @throws {TypeError} If role is neither a Parse.Role nor a String.
292
300
  */
293
301
  setRoleReadAccess(role /*: ParseRole | string*/, allowed /*: boolean*/) {
294
- if (role instanceof _ParseRole.default) {
302
+ const ParseRole = _CoreManager.default.getParseRole();
303
+ if (role instanceof ParseRole) {
295
304
  // Normalize to the String name
296
305
  role = role.getName();
297
306
  }
@@ -310,7 +319,8 @@ class ParseACL {
310
319
  * @throws {TypeError} If role is neither a Parse.Role nor a String.
311
320
  */
312
321
  setRoleWriteAccess(role /*: ParseRole | string*/, allowed /*: boolean*/) {
313
- if (role instanceof _ParseRole.default) {
322
+ const ParseRole = _CoreManager.default.getParseRole();
323
+ if (role instanceof ParseRole) {
314
324
  // Normalize to the String name
315
325
  role = role.getName();
316
326
  }
@@ -23,6 +23,10 @@ if (typeof XMLHttpRequest !== 'undefined') {
23
23
  /*:: type Base64 = { base64: string };*/
24
24
  /*:: type Uri = { uri: string };*/
25
25
  /*:: type FileData = Array<number> | Base64 | Blob | Uri;*/
26
+ /*:: export type FileSaveOptions = FullOptions & {
27
+ metadata?: { [key: string]: any },
28
+ tags?: { [key: string]: any },
29
+ };*/
26
30
  /*:: export type FileSource =
27
31
  | {
28
32
  format: 'file',
@@ -4,10 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- /**
8
- * @flow
9
- */
10
-
11
7
  /**
12
8
  * Creates a new GeoPoint with any of the following forms:<br>
13
9
  * <pre>
@@ -33,8 +29,6 @@ exports.default = void 0;
33
29
  */
34
30
  /* global navigator */
35
31
  class ParseGeoPoint {
36
- /*:: _latitude: number;*/
37
- /*:: _longitude: number;*/
38
32
  /**
39
33
  * @param {(number[] | object | number)} arg1 Either a list of coordinate pairs, an object with `latitude`, `longitude`, or the latitude or the point.
40
34
  * @param {number} arg2 The longitude of the GeoPoint
@@ -101,7 +95,7 @@ class ParseGeoPoint {
101
95
  longitude: this._longitude
102
96
  };
103
97
  }
104
- equals(other /*: mixed*/) /*: boolean*/{
98
+ equals(other /*: any*/) /*: boolean*/{
105
99
  return other instanceof ParseGeoPoint && this.latitude === other.latitude && this.longitude === other.longitude;
106
100
  }
107
101
 
@@ -169,12 +163,18 @@ class ParseGeoPoint {
169
163
  /**
170
164
  * Creates a GeoPoint with the user's current location, if available.
171
165
  *
166
+ * @param {object} options The options.
167
+ * @param {boolean} [options.enableHighAccuracy=false] A boolean value that indicates the application would like to receive the best possible results. If true and if the device is able to provide a more accurate position, it will do so. Note that this can result in slower response times or increased power consumption (with a GPS chip on a mobile device for example). On the other hand, if false, the device can take the liberty to save resources by responding more quickly and/or using less power. Default: false.
168
+ * @param {number} [options.timeout=Infinity] A positive long value representing the maximum length of time (in milliseconds) the device is allowed to take in order to return a position. The default value is Infinity, meaning that getCurrentPosition() won't return until the position is available.
169
+ * @param {number} [options.maximumAge=0] A positive long value indicating the maximum age in milliseconds of a possible cached position that is acceptable to return. If set to 0, it means that the device cannot use a cached position and must attempt to retrieve the real current position. If set to Infinity the device must return a cached position regardless of its age. Default: 0.
172
170
  * @static
173
- * @returns {Parse.GeoPoint} User's current location
171
+ * @returns {Promise<Parse.GeoPoint>} User's current location
174
172
  */
175
- static current() {
176
- return navigator.geolocation.getCurrentPosition(location => {
177
- return new ParseGeoPoint(location.coords.latitude, location.coords.longitude);
173
+ static current(options) /*: Promise<ParseGeoPoint>*/{
174
+ return new Promise((resolve, reject) => {
175
+ navigator.geolocation.getCurrentPosition(location => {
176
+ resolve(new ParseGeoPoint(location.coords.latitude, location.coords.longitude));
177
+ }, reject, options);
178
178
  });
179
179
  }
180
180
  }
@@ -24,6 +24,8 @@ function _interopRequireDefault(obj) {
24
24
  default: obj
25
25
  };
26
26
  }
27
+ /*:: export type HookDeclaration = { functionName: string, url: string } | { className: string, triggerName: string, url: string };*/
28
+ /*:: export type HookDeleteArg = { functionName: string } | { className: string, triggerName: string };*/
27
29
  function getFunctions() {
28
30
  return _CoreManager.default.getHooksController().get('functions');
29
31
  }