parse 5.0.0 → 5.1.0-alpha.10

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 (139) hide show
  1. package/README.md +13 -0
  2. package/dist/parse.js +1462 -1051
  3. package/dist/parse.min.js +2 -2
  4. package/dist/parse.weapp.js +2361 -1086
  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/ParseHooks.js +2 -0
  18. package/lib/browser/ParseInstallation.js +274 -13
  19. package/lib/browser/ParseLiveQuery.js +32 -23
  20. package/lib/browser/ParseObject.js +45 -45
  21. package/lib/browser/ParseOp.js +21 -7
  22. package/lib/browser/ParseQuery.js +1 -0
  23. package/lib/browser/ParseRelation.js +12 -7
  24. package/lib/browser/ParseRole.js +2 -0
  25. package/lib/browser/ParseSession.js +1 -1
  26. package/lib/browser/ParseUser.js +52 -21
  27. package/lib/browser/RESTController.js +7 -2
  28. package/lib/browser/SingleInstanceStateController.js +2 -4
  29. package/lib/browser/Storage.js +1 -2
  30. package/lib/browser/StorageController.js +3 -0
  31. package/lib/browser/WebSocketController.js +13 -0
  32. package/lib/browser/arrayContainsObject.js +4 -3
  33. package/lib/browser/canBeSerialized.js +6 -4
  34. package/lib/browser/decode.js +8 -5
  35. package/lib/browser/encode.js +6 -4
  36. package/lib/browser/equals.js +4 -3
  37. package/lib/browser/unique.js +3 -2
  38. package/lib/browser/unsavedChildren.js +4 -2
  39. package/lib/browser/uuid.js +11 -5
  40. package/lib/node/CoreManager.js +48 -171
  41. package/lib/node/InstallationController.js +65 -21
  42. package/lib/node/LiveQueryClient.js +2 -5
  43. package/lib/node/LiveQuerySubscription.js +2 -2
  44. package/lib/node/LocalDatastoreController.default.js +67 -0
  45. package/lib/node/LocalDatastoreController.js +1 -65
  46. package/lib/node/ObjectStateMutations.js +8 -9
  47. package/lib/node/OfflineQuery.js +3 -2
  48. package/lib/node/Parse.js +31 -7
  49. package/lib/node/ParseACL.js +21 -11
  50. package/lib/node/ParseFile.js +4 -0
  51. package/lib/node/ParseHooks.js +2 -0
  52. package/lib/node/ParseInstallation.js +207 -7
  53. package/lib/node/ParseLiveQuery.js +2 -3
  54. package/lib/node/ParseObject.js +17 -17
  55. package/lib/node/ParseOp.js +21 -7
  56. package/lib/node/ParseQuery.js +1 -0
  57. package/lib/node/ParseRelation.js +14 -8
  58. package/lib/node/ParseRole.js +2 -0
  59. package/lib/node/ParseSession.js +1 -1
  60. package/lib/node/ParseUser.js +21 -19
  61. package/lib/node/RESTController.js +6 -2
  62. package/lib/node/SingleInstanceStateController.js +2 -8
  63. package/lib/node/Storage.js +1 -2
  64. package/lib/node/StorageController.js +3 -0
  65. package/lib/node/WebSocketController.js +10 -0
  66. package/lib/node/arrayContainsObject.js +4 -3
  67. package/lib/node/canBeSerialized.js +6 -4
  68. package/lib/node/decode.js +9 -5
  69. package/lib/node/encode.js +7 -4
  70. package/lib/node/equals.js +4 -3
  71. package/lib/node/unique.js +3 -2
  72. package/lib/node/unsavedChildren.js +4 -2
  73. package/lib/node/uuid.js +10 -8
  74. package/lib/react-native/CoreManager.js +39 -2
  75. package/lib/react-native/InstallationController.js +77 -9
  76. package/lib/react-native/LiveQueryClient.js +28 -20
  77. package/lib/react-native/LiveQuerySubscription.js +14 -5
  78. package/lib/react-native/LocalDatastoreController.default.js +91 -0
  79. package/lib/react-native/LocalDatastoreController.js +1 -91
  80. package/lib/react-native/ObjectStateMutations.js +6 -5
  81. package/lib/react-native/OfflineQuery.js +3 -2
  82. package/lib/react-native/Parse.js +23 -7
  83. package/lib/react-native/ParseACL.js +19 -11
  84. package/lib/react-native/ParseInstallation.js +115 -10
  85. package/lib/react-native/ParseLiveQuery.js +11 -2
  86. package/lib/react-native/ParseObject.js +36 -36
  87. package/lib/react-native/ParseOp.js +20 -6
  88. package/lib/react-native/ParseQuery.js +1 -0
  89. package/lib/react-native/ParseRelation.js +10 -7
  90. package/lib/react-native/ParseRole.js +2 -0
  91. package/lib/react-native/ParseUser.js +7 -8
  92. package/lib/react-native/RESTController.js +5 -2
  93. package/lib/react-native/SingleInstanceStateController.js +0 -2
  94. package/lib/react-native/Storage.js +1 -2
  95. package/lib/react-native/StorageController.js +1 -0
  96. package/lib/react-native/WebSocketController.js +5 -0
  97. package/lib/react-native/arrayContainsObject.js +3 -2
  98. package/lib/react-native/canBeSerialized.js +5 -3
  99. package/lib/react-native/decode.js +7 -5
  100. package/lib/react-native/encode.js +6 -4
  101. package/lib/react-native/equals.js +4 -3
  102. package/lib/react-native/unique.js +3 -2
  103. package/lib/react-native/unsavedChildren.js +3 -2
  104. package/lib/react-native/uuid.js +9 -4
  105. package/lib/weapp/CoreManager.js +48 -171
  106. package/lib/weapp/InstallationController.js +134 -23
  107. package/lib/weapp/LiveQueryClient.js +43 -35
  108. package/lib/weapp/LiveQuerySubscription.js +15 -5
  109. package/lib/weapp/LocalDatastoreController.default.js +248 -0
  110. package/lib/weapp/LocalDatastoreController.js +1 -246
  111. package/lib/weapp/ObjectStateMutations.js +6 -5
  112. package/lib/weapp/OfflineQuery.js +3 -2
  113. package/lib/weapp/Parse.js +31 -7
  114. package/lib/weapp/ParseACL.js +21 -11
  115. package/lib/weapp/ParseFile.js +4 -0
  116. package/lib/weapp/ParseHooks.js +2 -0
  117. package/lib/weapp/ParseInstallation.js +274 -13
  118. package/lib/weapp/ParseLiveQuery.js +32 -23
  119. package/lib/weapp/ParseObject.js +45 -45
  120. package/lib/weapp/ParseOp.js +21 -7
  121. package/lib/weapp/ParseQuery.js +1 -0
  122. package/lib/weapp/ParseRelation.js +12 -7
  123. package/lib/weapp/ParseRole.js +2 -0
  124. package/lib/weapp/ParseSession.js +1 -1
  125. package/lib/weapp/ParseUser.js +52 -21
  126. package/lib/weapp/RESTController.js +7 -2
  127. package/lib/weapp/SingleInstanceStateController.js +2 -4
  128. package/lib/weapp/Storage.js +1 -2
  129. package/lib/weapp/StorageController.js +3 -0
  130. package/lib/weapp/WebSocketController.js +13 -0
  131. package/lib/weapp/arrayContainsObject.js +4 -3
  132. package/lib/weapp/canBeSerialized.js +6 -4
  133. package/lib/weapp/decode.js +8 -5
  134. package/lib/weapp/encode.js +6 -4
  135. package/lib/weapp/equals.js +4 -3
  136. package/lib/weapp/unique.js +3 -2
  137. package/lib/weapp/unsavedChildren.js +4 -2
  138. package/lib/weapp/uuid.js +12 -5
  139. package/package.json +4 -2
@@ -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',
@@ -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
  }
@@ -4,25 +4,225 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
+ var _CoreManager = _interopRequireDefault(require("./CoreManager"));
7
8
  var _ParseObject = _interopRequireDefault(require("./ParseObject"));
8
9
  function _interopRequireDefault(obj) {
9
10
  return obj && obj.__esModule ? obj : {
10
11
  default: obj
11
12
  };
12
13
  }
14
+ const DEVICE_TYPES /*: DeviceInterface*/ = {
15
+ IOS: 'ios',
16
+ MACOS: 'macos',
17
+ TVOS: 'tvos',
18
+ FCM: 'fcm',
19
+ ANDROID: 'android',
20
+ WEB: 'web'
21
+ };
22
+
13
23
  /**
14
- * @flow
24
+ * Parse.Installation is a local representation of installation data that can be saved and retrieved from the Parse cloud.
25
+ * This class is a subclass of a Parse.Object, and retains the same functionality of a Parse.Object, but also extends it with installation-specific features.
26
+ *
27
+ * <p>A valid Parse.Installation can only be instantiated via <code>Parse.Installation.currentInstallation()</code>
28
+ *
29
+ * Parse.Installation objects which have a valid <code>deviceToken</code> and are saved to the Parse cloud can be used to target push notifications.
30
+ * </p>
31
+ *
32
+ * @alias Parse.Installation
15
33
  */
16
- /*:: import type { AttributeMap } from './ObjectStateMutations';*/
17
- class Installation extends _ParseObject.default {
18
- constructor(attributes /*: ?AttributeMap*/) {
34
+ class ParseInstallation extends _ParseObject.default {
35
+ /**
36
+ * @param {object} attributes The initial set of data to store in the object.
37
+ */
38
+ constructor(attributes /*:: ?: AttributeMap*/) {
19
39
  super('_Installation');
20
40
  if (attributes && typeof attributes === 'object') {
21
- if (!this.set(attributes || {})) {
41
+ if (!this.set(attributes)) {
22
42
  throw new Error("Can't create an invalid Installation");
23
43
  }
24
44
  }
25
45
  }
46
+
47
+ /**
48
+ * A unique identifier for this installation’s client application. In iOS, this is the Bundle Identifier.
49
+ *
50
+ * @property {string} appIdentifier
51
+ * @static
52
+ */
53
+ get appIdentifier() {
54
+ return this.get('appIdentifier');
55
+ }
56
+
57
+ /**
58
+ * The version string of the client application to which this installation belongs.
59
+ *
60
+ * @property {string} appVersion
61
+ * @static
62
+ */
63
+ get appVersion() {
64
+ return this.get('appVersion');
65
+ }
66
+
67
+ /**
68
+ * The display name of the client application to which this installation belongs.
69
+ *
70
+ * @property {string} appName
71
+ * @static
72
+ */
73
+ get appName() {
74
+ return this.get('appName');
75
+ }
76
+
77
+ /**
78
+ * The current value of the icon badge for iOS apps.
79
+ * Changes to this value on the server will be used
80
+ * for future badge-increment push notifications.
81
+ *
82
+ * @property {number} badge
83
+ * @static
84
+ */
85
+ get badge() {
86
+ return this.get('badge');
87
+ }
88
+
89
+ /**
90
+ * An array of the channels to which a device is currently subscribed.
91
+ *
92
+ * @property {string[]} channels
93
+ * @static
94
+ */
95
+ get channels() {
96
+ return this.get('channels');
97
+ }
98
+
99
+ /**
100
+ * Token used to deliver push notifications to the device.
101
+ *
102
+ * @property {string} deviceToken
103
+ * @static
104
+ */
105
+ get deviceToken() {
106
+ return this.get('deviceToken');
107
+ }
108
+
109
+ /**
110
+ * The type of device, “ios”, “android”, “web”, etc.
111
+ *
112
+ * @property {string} deviceType
113
+ * @static
114
+ */
115
+ get deviceType() {
116
+ return this.get('deviceType');
117
+ }
118
+
119
+ /**
120
+ * Gets the GCM sender identifier for this installation
121
+ *
122
+ * @property {string} GCMSenderId
123
+ * @static
124
+ */
125
+ get GCMSenderId() {
126
+ return this.get('GCMSenderId');
127
+ }
128
+
129
+ /**
130
+ * Universally Unique Identifier (UUID) for the device used by Parse. It must be unique across all of an app’s installations.
131
+ *
132
+ * @property {string} installationId
133
+ * @static
134
+ */
135
+ get installationId() {
136
+ return this.get('installationId');
137
+ }
138
+
139
+ /**
140
+ * Gets the local identifier for this installation
141
+ *
142
+ * @property {string} localeIdentifier
143
+ * @static
144
+ */
145
+ get localeIdentifier() {
146
+ return this.get('localeIdentifier');
147
+ }
148
+
149
+ /**
150
+ * Gets the parse server version for this installation
151
+ *
152
+ * @property {string} parseVersion
153
+ * @static
154
+ */
155
+ get parseVersion() {
156
+ return this.get('parseVersion');
157
+ }
158
+
159
+ /**
160
+ * This field is reserved for directing Parse to the push delivery network to be used.
161
+ *
162
+ * @property {string} pushType
163
+ * @static
164
+ */
165
+ get pushType() {
166
+ return this.get('pushType');
167
+ }
168
+
169
+ /**
170
+ * Gets the time zone for this installation
171
+ *
172
+ * @property {string} timeZone
173
+ * @static
174
+ */
175
+ get timeZone() {
176
+ return this.get('timeZone');
177
+ }
178
+
179
+ /**
180
+ * Returns the device types for used for Push Notifications.
181
+ *
182
+ * <pre>
183
+ * Parse.Installation.DEVICE_TYPES.IOS
184
+ * Parse.Installation.DEVICE_TYPES.MACOS
185
+ * Parse.Installation.DEVICE_TYPES.TVOS
186
+ * Parse.Installation.DEVICE_TYPES.FCM
187
+ * Parse.Installation.DEVICE_TYPES.ANDROID
188
+ * Parse.Installation.DEVICE_TYPES.WEB
189
+ * </pre
190
+ *
191
+ * @property {Object} DEVICE_TYPES
192
+ * @static
193
+ */
194
+ static get DEVICE_TYPES() /*: DeviceInterface*/{
195
+ return DEVICE_TYPES;
196
+ }
197
+
198
+ /**
199
+ * Wrap the default save behavior with functionality to save to local storage.
200
+ *
201
+ * @param {...any} args
202
+ * @returns {Promise}
203
+ */
204
+ async save(...args) /*: Promise<ParseInstallation>*/{
205
+ await super.save.apply(this, args);
206
+ await _CoreManager.default.getInstallationController().updateInstallationOnDisk(this);
207
+ return this;
208
+ }
209
+
210
+ /**
211
+ * Get the current Parse.Installation from disk. If doesn't exists, create an new installation.
212
+ *
213
+ * <pre>
214
+ * const installation = await Parse.Installation.currentInstallation();
215
+ * installation.set('deviceToken', '123');
216
+ * await installation.save();
217
+ * </pre>
218
+ *
219
+ * @returns {Promise} A promise that resolves to the local installation object.
220
+ */
221
+ static currentInstallation() /*: Promise<ParseInstallation>*/{
222
+ return _CoreManager.default.getInstallationController().currentInstallation();
223
+ }
26
224
  }
27
- exports.default = Installation;
28
- _ParseObject.default.registerSubclass('_Installation', Installation);
225
+ _ParseObject.default.registerSubclass('_Installation', ParseInstallation);
226
+ module.exports = ParseInstallation;
227
+ var _default = ParseInstallation;
228
+ exports.default = _default;
@@ -50,9 +50,8 @@ class LiveQuery {
50
50
  constructor() {
51
51
  const EventEmitter = _CoreManager.default.getEventEmitter();
52
52
  this.emitter = new EventEmitter();
53
- this.on = this.emitter.on;
54
- this.emit = this.emitter.emit;
55
-
53
+ this.on = (eventName, listener) => this.emitter.on(eventName, listener);
54
+ this.emit = (eventName, ...args) => this.emitter.emit(eventName, ...args);
56
55
  // adding listener so process does not crash
57
56
  // best practice is for developer to register their own listener
58
57
  this.on('error', () => {});