parse 5.1.0-alpha.7 → 5.1.0-alpha.9
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.
- package/README.md +1 -1
- package/dist/parse.js +454 -247
- package/dist/parse.min.js +2 -2
- package/dist/parse.weapp.js +454 -247
- package/dist/parse.weapp.min.js +2 -2
- package/lib/browser/CoreManager.js +18 -183
- package/lib/browser/InstallationController.js +134 -23
- package/lib/browser/Parse.js +2 -2
- package/lib/browser/ParseFile.js +4 -0
- package/lib/browser/ParseHooks.js +2 -0
- package/lib/browser/ParseInstallation.js +274 -13
- package/lib/browser/ParseObject.js +19 -23
- package/lib/browser/ParseSession.js +1 -1
- package/lib/node/CoreManager.js +18 -183
- package/lib/node/InstallationController.js +65 -21
- package/lib/node/Parse.js +2 -2
- package/lib/node/ParseFile.js +4 -0
- package/lib/node/ParseHooks.js +2 -0
- package/lib/node/ParseInstallation.js +207 -7
- package/lib/node/ParseObject.js +0 -4
- package/lib/node/ParseSession.js +1 -1
- package/lib/react-native/CoreManager.js +9 -9
- package/lib/react-native/InstallationController.js +77 -9
- package/lib/react-native/Parse.js +2 -2
- package/lib/react-native/ParseInstallation.js +115 -10
- package/lib/react-native/ParseObject.js +19 -23
- package/lib/weapp/CoreManager.js +18 -183
- package/lib/weapp/InstallationController.js +134 -23
- package/lib/weapp/Parse.js +2 -2
- package/lib/weapp/ParseFile.js +4 -0
- package/lib/weapp/ParseHooks.js +2 -0
- package/lib/weapp/ParseInstallation.js +274 -13
- package/lib/weapp/ParseObject.js +19 -23
- package/lib/weapp/ParseSession.js +1 -1
- package/package.json +1 -1
|
@@ -7,12 +7,16 @@ _Object$defineProperty(exports, "__esModule", {
|
|
|
7
7
|
value: true
|
|
8
8
|
});
|
|
9
9
|
exports.default = void 0;
|
|
10
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime-corejs3/regenerator"));
|
|
11
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/asyncToGenerator"));
|
|
10
12
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/typeof"));
|
|
11
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/createClass"));
|
|
12
13
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/classCallCheck"));
|
|
14
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/createClass"));
|
|
15
|
+
var _get2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/get"));
|
|
13
16
|
var _inherits2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/inherits"));
|
|
14
17
|
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/possibleConstructorReturn"));
|
|
15
18
|
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/getPrototypeOf"));
|
|
19
|
+
var _CoreManager = _interopRequireDefault(require("./CoreManager"));
|
|
16
20
|
var _ParseObject2 = _interopRequireDefault(require("./ParseObject"));
|
|
17
21
|
function _createSuper(Derived) {
|
|
18
22
|
var hasNativeReflectConstruct = _isNativeReflectConstruct();
|
|
@@ -38,25 +42,282 @@ function _isNativeReflectConstruct() {
|
|
|
38
42
|
} catch (e) {
|
|
39
43
|
return false;
|
|
40
44
|
}
|
|
41
|
-
}
|
|
42
|
-
|
|
45
|
+
}
|
|
46
|
+
var DEVICE_TYPES /*: DeviceInterface*/ = {
|
|
47
|
+
IOS: 'ios',
|
|
48
|
+
MACOS: 'macos',
|
|
49
|
+
TVOS: 'tvos',
|
|
50
|
+
FCM: 'fcm',
|
|
51
|
+
ANDROID: 'android',
|
|
52
|
+
WEB: 'web'
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Parse.Installation is a local representation of installation data that can be saved and retrieved from the Parse cloud.
|
|
57
|
+
* 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.
|
|
58
|
+
*
|
|
59
|
+
* <p>A valid Parse.Installation can only be instantiated via <code>Parse.Installation.currentInstallation()</code>
|
|
60
|
+
*
|
|
61
|
+
* Parse.Installation objects which have a valid <code>deviceToken</code> and are saved to the Parse cloud can be used to target push notifications.
|
|
62
|
+
* </p>
|
|
63
|
+
*
|
|
64
|
+
* @alias Parse.Installation
|
|
65
|
+
*/
|
|
66
|
+
var ParseInstallation = /*#__PURE__*/function (_ParseObject) {
|
|
67
|
+
(0, _inherits2.default)(ParseInstallation, _ParseObject);
|
|
68
|
+
var _super = _createSuper(ParseInstallation);
|
|
69
|
+
/**
|
|
70
|
+
* @param {object} attributes The initial set of data to store in the object.
|
|
43
71
|
*/
|
|
44
|
-
|
|
45
|
-
var Installation = /*#__PURE__*/function (_ParseObject) {
|
|
46
|
-
(0, _inherits2.default)(Installation, _ParseObject);
|
|
47
|
-
var _super = _createSuper(Installation);
|
|
48
|
-
function Installation(attributes /*: ?AttributeMap*/) {
|
|
72
|
+
function ParseInstallation(attributes /*:: ?: AttributeMap*/) {
|
|
49
73
|
var _this;
|
|
50
|
-
(0, _classCallCheck2.default)(this,
|
|
74
|
+
(0, _classCallCheck2.default)(this, ParseInstallation);
|
|
51
75
|
_this = _super.call(this, '_Installation');
|
|
52
76
|
if (attributes && (0, _typeof2.default)(attributes) === 'object') {
|
|
53
|
-
if (!_this.set(attributes
|
|
77
|
+
if (!_this.set(attributes)) {
|
|
54
78
|
throw new Error("Can't create an invalid Installation");
|
|
55
79
|
}
|
|
56
80
|
}
|
|
57
81
|
return _this;
|
|
58
82
|
}
|
|
59
|
-
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* A unique identifier for this installation’s client application. In iOS, this is the Bundle Identifier.
|
|
86
|
+
*
|
|
87
|
+
* @property {string} appIdentifier
|
|
88
|
+
* @static
|
|
89
|
+
*/
|
|
90
|
+
(0, _createClass2.default)(ParseInstallation, [{
|
|
91
|
+
key: "appIdentifier",
|
|
92
|
+
get: function () {
|
|
93
|
+
return this.get('appIdentifier');
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* The version string of the client application to which this installation belongs.
|
|
98
|
+
*
|
|
99
|
+
* @property {string} appVersion
|
|
100
|
+
* @static
|
|
101
|
+
*/
|
|
102
|
+
}, {
|
|
103
|
+
key: "appVersion",
|
|
104
|
+
get: function () {
|
|
105
|
+
return this.get('appVersion');
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* The display name of the client application to which this installation belongs.
|
|
110
|
+
*
|
|
111
|
+
* @property {string} appName
|
|
112
|
+
* @static
|
|
113
|
+
*/
|
|
114
|
+
}, {
|
|
115
|
+
key: "appName",
|
|
116
|
+
get: function () {
|
|
117
|
+
return this.get('appName');
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* The current value of the icon badge for iOS apps.
|
|
122
|
+
* Changes to this value on the server will be used
|
|
123
|
+
* for future badge-increment push notifications.
|
|
124
|
+
*
|
|
125
|
+
* @property {number} badge
|
|
126
|
+
* @static
|
|
127
|
+
*/
|
|
128
|
+
}, {
|
|
129
|
+
key: "badge",
|
|
130
|
+
get: function () {
|
|
131
|
+
return this.get('badge');
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* An array of the channels to which a device is currently subscribed.
|
|
136
|
+
*
|
|
137
|
+
* @property {string[]} channels
|
|
138
|
+
* @static
|
|
139
|
+
*/
|
|
140
|
+
}, {
|
|
141
|
+
key: "channels",
|
|
142
|
+
get: function () {
|
|
143
|
+
return this.get('channels');
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Token used to deliver push notifications to the device.
|
|
148
|
+
*
|
|
149
|
+
* @property {string} deviceToken
|
|
150
|
+
* @static
|
|
151
|
+
*/
|
|
152
|
+
}, {
|
|
153
|
+
key: "deviceToken",
|
|
154
|
+
get: function () {
|
|
155
|
+
return this.get('deviceToken');
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* The type of device, “ios”, “android”, “web”, etc.
|
|
160
|
+
*
|
|
161
|
+
* @property {string} deviceType
|
|
162
|
+
* @static
|
|
163
|
+
*/
|
|
164
|
+
}, {
|
|
165
|
+
key: "deviceType",
|
|
166
|
+
get: function () {
|
|
167
|
+
return this.get('deviceType');
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Gets the GCM sender identifier for this installation
|
|
172
|
+
*
|
|
173
|
+
* @property {string} GCMSenderId
|
|
174
|
+
* @static
|
|
175
|
+
*/
|
|
176
|
+
}, {
|
|
177
|
+
key: "GCMSenderId",
|
|
178
|
+
get: function () {
|
|
179
|
+
return this.get('GCMSenderId');
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Universally Unique Identifier (UUID) for the device used by Parse. It must be unique across all of an app’s installations.
|
|
184
|
+
*
|
|
185
|
+
* @property {string} installationId
|
|
186
|
+
* @static
|
|
187
|
+
*/
|
|
188
|
+
}, {
|
|
189
|
+
key: "installationId",
|
|
190
|
+
get: function () {
|
|
191
|
+
return this.get('installationId');
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Gets the local identifier for this installation
|
|
196
|
+
*
|
|
197
|
+
* @property {string} localeIdentifier
|
|
198
|
+
* @static
|
|
199
|
+
*/
|
|
200
|
+
}, {
|
|
201
|
+
key: "localeIdentifier",
|
|
202
|
+
get: function () {
|
|
203
|
+
return this.get('localeIdentifier');
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Gets the parse server version for this installation
|
|
208
|
+
*
|
|
209
|
+
* @property {string} parseVersion
|
|
210
|
+
* @static
|
|
211
|
+
*/
|
|
212
|
+
}, {
|
|
213
|
+
key: "parseVersion",
|
|
214
|
+
get: function () {
|
|
215
|
+
return this.get('parseVersion');
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* This field is reserved for directing Parse to the push delivery network to be used.
|
|
220
|
+
*
|
|
221
|
+
* @property {string} pushType
|
|
222
|
+
* @static
|
|
223
|
+
*/
|
|
224
|
+
}, {
|
|
225
|
+
key: "pushType",
|
|
226
|
+
get: function () {
|
|
227
|
+
return this.get('pushType');
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Gets the time zone for this installation
|
|
232
|
+
*
|
|
233
|
+
* @property {string} timeZone
|
|
234
|
+
* @static
|
|
235
|
+
*/
|
|
236
|
+
}, {
|
|
237
|
+
key: "timeZone",
|
|
238
|
+
get: function () {
|
|
239
|
+
return this.get('timeZone');
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Returns the device types for used for Push Notifications.
|
|
244
|
+
*
|
|
245
|
+
* <pre>
|
|
246
|
+
* Parse.Installation.DEVICE_TYPES.IOS
|
|
247
|
+
* Parse.Installation.DEVICE_TYPES.MACOS
|
|
248
|
+
* Parse.Installation.DEVICE_TYPES.TVOS
|
|
249
|
+
* Parse.Installation.DEVICE_TYPES.FCM
|
|
250
|
+
* Parse.Installation.DEVICE_TYPES.ANDROID
|
|
251
|
+
* Parse.Installation.DEVICE_TYPES.WEB
|
|
252
|
+
* </pre
|
|
253
|
+
*
|
|
254
|
+
* @property {Object} DEVICE_TYPES
|
|
255
|
+
* @static
|
|
256
|
+
*/
|
|
257
|
+
}, {
|
|
258
|
+
key: "save",
|
|
259
|
+
value:
|
|
260
|
+
/**
|
|
261
|
+
* Wrap the default save behavior with functionality to save to local storage.
|
|
262
|
+
*
|
|
263
|
+
* @param {...any} args
|
|
264
|
+
* @returns {Promise}
|
|
265
|
+
*/
|
|
266
|
+
function () {
|
|
267
|
+
var _save = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
268
|
+
var _len,
|
|
269
|
+
args,
|
|
270
|
+
_key,
|
|
271
|
+
_args = arguments;
|
|
272
|
+
return _regenerator.default.wrap(function (_context) {
|
|
273
|
+
while (1) switch (_context.prev = _context.next) {
|
|
274
|
+
case 0:
|
|
275
|
+
for (_len = _args.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
276
|
+
args[_key] = _args[_key];
|
|
277
|
+
}
|
|
278
|
+
_context.next = 3;
|
|
279
|
+
return (0, _get2.default)((0, _getPrototypeOf2.default)(ParseInstallation.prototype), "save", this).apply(this, args);
|
|
280
|
+
case 3:
|
|
281
|
+
_context.next = 5;
|
|
282
|
+
return _CoreManager.default.getInstallationController().updateInstallationOnDisk(this);
|
|
283
|
+
case 5:
|
|
284
|
+
return _context.abrupt("return", this);
|
|
285
|
+
case 6:
|
|
286
|
+
case "end":
|
|
287
|
+
return _context.stop();
|
|
288
|
+
}
|
|
289
|
+
}, _callee, this);
|
|
290
|
+
}));
|
|
291
|
+
function save() {
|
|
292
|
+
return _save.apply(this, arguments);
|
|
293
|
+
}
|
|
294
|
+
return save;
|
|
295
|
+
}()
|
|
296
|
+
/**
|
|
297
|
+
* Get the current Parse.Installation from disk. If doesn't exists, create an new installation.
|
|
298
|
+
*
|
|
299
|
+
* <pre>
|
|
300
|
+
* const installation = await Parse.Installation.currentInstallation();
|
|
301
|
+
* installation.set('deviceToken', '123');
|
|
302
|
+
* await installation.save();
|
|
303
|
+
* </pre>
|
|
304
|
+
*
|
|
305
|
+
* @returns {Promise} A promise that resolves to the local installation object.
|
|
306
|
+
*/
|
|
307
|
+
}], [{
|
|
308
|
+
key: "DEVICE_TYPES",
|
|
309
|
+
get: function () /*: DeviceInterface*/{
|
|
310
|
+
return DEVICE_TYPES;
|
|
311
|
+
}
|
|
312
|
+
}, {
|
|
313
|
+
key: "currentInstallation",
|
|
314
|
+
value: function () /*: Promise<ParseInstallation>*/{
|
|
315
|
+
return _CoreManager.default.getInstallationController().currentInstallation();
|
|
316
|
+
}
|
|
317
|
+
}]);
|
|
318
|
+
return ParseInstallation;
|
|
60
319
|
}(_ParseObject2.default);
|
|
61
|
-
|
|
62
|
-
|
|
320
|
+
_ParseObject2.default.registerSubclass('_Installation', ParseInstallation);
|
|
321
|
+
module.exports = ParseInstallation;
|
|
322
|
+
var _default = ParseInstallation;
|
|
323
|
+
exports.default = _default;
|
|
@@ -623,10 +623,6 @@ var ParseObject = /*#__PURE__*/function () {
|
|
|
623
623
|
json[_attr5] = (0, _encode.default)(attrs[_attr5], false, false, seen, offline);
|
|
624
624
|
}
|
|
625
625
|
}
|
|
626
|
-
var pending = this._getPendingOps();
|
|
627
|
-
for (var _attr6 in pending[0]) {
|
|
628
|
-
json[_attr6] = pending[0][_attr6].toJSON(offline);
|
|
629
|
-
}
|
|
630
626
|
if (this.id) {
|
|
631
627
|
json.objectId = this.id;
|
|
632
628
|
}
|
|
@@ -695,13 +691,13 @@ var ParseObject = /*#__PURE__*/function () {
|
|
|
695
691
|
var pendingOps = this._getPendingOps();
|
|
696
692
|
var keys = {};
|
|
697
693
|
for (var i = 0; i < pendingOps.length; i++) {
|
|
698
|
-
for (var
|
|
699
|
-
keys[
|
|
694
|
+
for (var _attr6 in pendingOps[i]) {
|
|
695
|
+
keys[_attr6] = true;
|
|
700
696
|
}
|
|
701
697
|
}
|
|
702
698
|
var dirtyObjects = this._getDirtyObjectAttributes();
|
|
703
|
-
for (var
|
|
704
|
-
keys[
|
|
699
|
+
for (var _attr7 in dirtyObjects) {
|
|
700
|
+
keys[_attr7] = true;
|
|
705
701
|
}
|
|
706
702
|
return (0, _keys.default)(keys);
|
|
707
703
|
}
|
|
@@ -906,11 +902,11 @@ var ParseObject = /*#__PURE__*/function () {
|
|
|
906
902
|
|
|
907
903
|
// Calculate new values
|
|
908
904
|
var newValues = {};
|
|
909
|
-
for (var
|
|
910
|
-
if (newOps[
|
|
911
|
-
newValues[
|
|
912
|
-
} else if (!(newOps[
|
|
913
|
-
newValues[
|
|
905
|
+
for (var _attr8 in newOps) {
|
|
906
|
+
if (newOps[_attr8] instanceof _ParseOp.RelationOp) {
|
|
907
|
+
newValues[_attr8] = newOps[_attr8].applyTo(currentAttributes[_attr8], this, _attr8);
|
|
908
|
+
} else if (!(newOps[_attr8] instanceof _ParseOp.UnsetOp)) {
|
|
909
|
+
newValues[_attr8] = newOps[_attr8].applyTo(currentAttributes[_attr8]);
|
|
914
910
|
}
|
|
915
911
|
}
|
|
916
912
|
|
|
@@ -929,9 +925,9 @@ var ParseObject = /*#__PURE__*/function () {
|
|
|
929
925
|
var pendingOps = this._getPendingOps();
|
|
930
926
|
var last = pendingOps.length - 1;
|
|
931
927
|
var stateController = _CoreManager.default.getObjectStateController();
|
|
932
|
-
for (var
|
|
933
|
-
var nextOp = newOps[
|
|
934
|
-
stateController.setPendingOp(this._getStateIdentifier(),
|
|
928
|
+
for (var _attr9 in newOps) {
|
|
929
|
+
var nextOp = newOps[_attr9].mergeWith(pendingOps[last][_attr9]);
|
|
930
|
+
stateController.setPendingOp(this._getStateIdentifier(), _attr9, nextOp);
|
|
935
931
|
}
|
|
936
932
|
return this;
|
|
937
933
|
}
|
|
@@ -1345,9 +1341,9 @@ var ParseObject = /*#__PURE__*/function () {
|
|
|
1345
1341
|
if (typeof this.constructor.readOnlyAttributes === 'function') {
|
|
1346
1342
|
readonly = (0, _concat.default)(readonly).call(readonly, this.constructor.readOnlyAttributes());
|
|
1347
1343
|
}
|
|
1348
|
-
for (var
|
|
1349
|
-
if ((0, _indexOf.default)(readonly).call(readonly,
|
|
1350
|
-
erasable[
|
|
1344
|
+
for (var _attr10 in attributes) {
|
|
1345
|
+
if ((0, _indexOf.default)(readonly).call(readonly, _attr10) < 0) {
|
|
1346
|
+
erasable[_attr10] = true;
|
|
1351
1347
|
}
|
|
1352
1348
|
}
|
|
1353
1349
|
return this.set(erasable, {
|
|
@@ -2193,11 +2189,11 @@ var ParseObject = /*#__PURE__*/function () {
|
|
|
2193
2189
|
var constructor = classMap[json.className];
|
|
2194
2190
|
var o = constructor ? new constructor(json.className) : new ParseObject(json.className);
|
|
2195
2191
|
var otherAttributes = {};
|
|
2196
|
-
for (var
|
|
2197
|
-
if (
|
|
2198
|
-
otherAttributes[
|
|
2192
|
+
for (var _attr11 in json) {
|
|
2193
|
+
if (_attr11 !== 'className' && _attr11 !== '__type') {
|
|
2194
|
+
otherAttributes[_attr11] = json[_attr11];
|
|
2199
2195
|
if (dirty) {
|
|
2200
|
-
o.set(
|
|
2196
|
+
o.set(_attr11, json[_attr11]);
|
|
2201
2197
|
}
|
|
2202
2198
|
}
|
|
2203
2199
|
}
|
|
@@ -103,7 +103,7 @@ var ParseSession = /*#__PURE__*/function (_ParseObject) {
|
|
|
103
103
|
value: function (options /*: FullOptions*/) {
|
|
104
104
|
options = options || {};
|
|
105
105
|
var controller = _CoreManager.default.getSessionController();
|
|
106
|
-
var sessionOptions = {};
|
|
106
|
+
var sessionOptions /*: FullOptions*/ = {};
|
|
107
107
|
if (options.hasOwnProperty('useMasterKey')) {
|
|
108
108
|
sessionOptions.useMasterKey = options.useMasterKey;
|
|
109
109
|
}
|
package/lib/node/CoreManager.js
CHANGED
|
@@ -4,181 +4,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
*/
|
|
10
|
-
/*:: import type { AttributeMap, ObjectCache, OpsMap, State } from './ObjectStateMutations';*/
|
|
11
|
-
/*:: import type ParseFile from './ParseFile';*/
|
|
12
|
-
/*:: import type { FileSource } from './ParseFile';*/
|
|
13
|
-
/*:: import type { Op } from './ParseOp';*/
|
|
14
|
-
/*:: import type ParseObject, {SaveOptions} from './ParseObject';*/
|
|
15
|
-
/*:: import type { QueryJSON } from './ParseQuery';*/
|
|
16
|
-
/*:: import type ParseUser from './ParseUser';*/
|
|
17
|
-
/*:: import type { AuthData } from './ParseUser';*/
|
|
18
|
-
/*:: import type { PushData } from './Push';*/
|
|
19
|
-
/*:: import type { RequestOptions, FullOptions } from './RESTController';*/
|
|
20
|
-
/*:: type AnalyticsController = {
|
|
21
|
-
track: (name: string, dimensions: { [key: string]: string }) => Promise,
|
|
22
|
-
};*/
|
|
23
|
-
/*:: type CloudController = {
|
|
24
|
-
run: (name: string, data: mixed, options: RequestOptions) => Promise,
|
|
25
|
-
getJobsData: (options: RequestOptions) => Promise,
|
|
26
|
-
startJob: (name: string, data: mixed, options: RequestOptions) => Promise,
|
|
27
|
-
};*/
|
|
28
|
-
/*:: type ConfigController = {
|
|
29
|
-
current: () => Promise,
|
|
30
|
-
get: () => Promise,
|
|
31
|
-
save: (attrs: { [key: string]: any }) => Promise,
|
|
32
|
-
};*/
|
|
33
|
-
/*:: type CryptoController = {
|
|
34
|
-
encrypt: (obj: any, secretKey: string) => string,
|
|
35
|
-
decrypt: (encryptedText: string, secretKey: any) => string,
|
|
36
|
-
};*/
|
|
37
|
-
/*:: type FileController = {
|
|
38
|
-
saveFile: (name: string, source: FileSource, options: FullOptions) => Promise,
|
|
39
|
-
saveBase64: (name: string, source: FileSource, options: FullOptions) => Promise,
|
|
40
|
-
download: (uri: string) => Promise,
|
|
41
|
-
};*/
|
|
42
|
-
/*:: type InstallationController = {
|
|
43
|
-
currentInstallationId: () => Promise,
|
|
44
|
-
};*/
|
|
45
|
-
/*:: type ObjectController = {
|
|
46
|
-
fetch: (
|
|
47
|
-
object: ParseObject | Array<ParseObject>,
|
|
48
|
-
forceFetch: boolean,
|
|
49
|
-
options: RequestOptions
|
|
50
|
-
) => Promise,
|
|
51
|
-
save: (object: ParseObject | Array<ParseObject | ParseFile>, options: RequestOptions) => Promise,
|
|
52
|
-
destroy: (object: ParseObject | Array<ParseObject>, options: RequestOptions) => Promise,
|
|
53
|
-
};*/
|
|
54
|
-
/*:: type ObjectStateController = {
|
|
55
|
-
getState: (obj: any) => ?State,
|
|
56
|
-
initializeState: (obj: any, initial?: State) => State,
|
|
57
|
-
removeState: (obj: any) => ?State,
|
|
58
|
-
getServerData: (obj: any) => AttributeMap,
|
|
59
|
-
setServerData: (obj: any, attributes: AttributeMap) => void,
|
|
60
|
-
getPendingOps: (obj: any) => Array<OpsMap>,
|
|
61
|
-
setPendingOp: (obj: any, attr: string, op: ?Op) => void,
|
|
62
|
-
pushPendingState: (obj: any) => void,
|
|
63
|
-
popPendingState: (obj: any) => OpsMap,
|
|
64
|
-
mergeFirstPendingState: (obj: any) => void,
|
|
65
|
-
getObjectCache: (obj: any) => ObjectCache,
|
|
66
|
-
estimateAttribute: (obj: any, attr: string) => mixed,
|
|
67
|
-
estimateAttributes: (obj: any) => AttributeMap,
|
|
68
|
-
commitServerChanges: (obj: any, changes: AttributeMap) => void,
|
|
69
|
-
enqueueTask: (obj: any, task: () => Promise) => Promise,
|
|
70
|
-
clearAllState: () => void,
|
|
71
|
-
duplicateState: (source: any, dest: any) => void,
|
|
72
|
-
};*/
|
|
73
|
-
/*:: type PushController = {
|
|
74
|
-
send: (data: PushData) => Promise,
|
|
75
|
-
};*/
|
|
76
|
-
/*:: type QueryController = {
|
|
77
|
-
find: (className: string, params: QueryJSON, options: RequestOptions) => Promise,
|
|
78
|
-
aggregate: (className: string, params: any, options: RequestOptions) => Promise,
|
|
79
|
-
};*/
|
|
80
|
-
/*:: type EventuallyQueue = {
|
|
81
|
-
save: (object: ParseObject, serverOptions: SaveOptions) => Promise,
|
|
82
|
-
destroy: (object: ParseObject, serverOptions: RequestOptions) => Promise,
|
|
83
|
-
poll: (ms: number) => void
|
|
84
|
-
};*/
|
|
85
|
-
/*:: type RESTController = {
|
|
86
|
-
request: (method: string, path: string, data: mixed, options: RequestOptions) => Promise,
|
|
87
|
-
ajax: (method: string, url: string, data: any, headers?: any, options: FullOptions) => Promise,
|
|
88
|
-
};*/
|
|
89
|
-
/*:: type SchemaController = {
|
|
90
|
-
purge: (className: string) => Promise,
|
|
91
|
-
get: (className: string, options: RequestOptions) => Promise,
|
|
92
|
-
delete: (className: string, options: RequestOptions) => Promise,
|
|
93
|
-
create: (className: string, params: any, options: RequestOptions) => Promise,
|
|
94
|
-
update: (className: string, params: any, options: RequestOptions) => Promise,
|
|
95
|
-
send(className: string, method: string, params: any, options: RequestOptions): Promise,
|
|
96
|
-
};*/
|
|
97
|
-
/*:: type SessionController = {
|
|
98
|
-
getSession: (token: RequestOptions) => Promise,
|
|
99
|
-
};*/
|
|
100
|
-
/*:: type StorageController =
|
|
101
|
-
| {
|
|
102
|
-
async: 0,
|
|
103
|
-
getItem: (path: string) => ?string,
|
|
104
|
-
setItem: (path: string, value: string) => void,
|
|
105
|
-
removeItem: (path: string) => void,
|
|
106
|
-
getItemAsync?: (path: string) => Promise,
|
|
107
|
-
setItemAsync?: (path: string, value: string) => Promise,
|
|
108
|
-
removeItemAsync?: (path: string) => Promise,
|
|
109
|
-
clear: () => void,
|
|
110
|
-
}
|
|
111
|
-
| {
|
|
112
|
-
async: 1,
|
|
113
|
-
getItem?: (path: string) => ?string,
|
|
114
|
-
setItem?: (path: string, value: string) => void,
|
|
115
|
-
removeItem?: (path: string) => void,
|
|
116
|
-
getItemAsync: (path: string) => Promise,
|
|
117
|
-
setItemAsync: (path: string, value: string) => Promise,
|
|
118
|
-
removeItemAsync: (path: string) => Promise,
|
|
119
|
-
clear: () => void,
|
|
120
|
-
};*/
|
|
121
|
-
/*:: type LocalDatastoreController = {
|
|
122
|
-
fromPinWithName: (name: string) => ?any,
|
|
123
|
-
pinWithName: (name: string, objects: any) => void,
|
|
124
|
-
unPinWithName: (name: string) => void,
|
|
125
|
-
getAllContents: () => ?any,
|
|
126
|
-
clear: () => void,
|
|
127
|
-
};*/
|
|
128
|
-
/*:: type UserController = {
|
|
129
|
-
setCurrentUser: (user: ParseUser) => Promise,
|
|
130
|
-
currentUser: () => ?ParseUser,
|
|
131
|
-
currentUserAsync: () => Promise,
|
|
132
|
-
signUp: (user: ParseUser, attrs: AttributeMap, options: RequestOptions) => Promise,
|
|
133
|
-
logIn: (user: ParseUser, options: RequestOptions) => Promise,
|
|
134
|
-
become: (options: RequestOptions) => Promise,
|
|
135
|
-
hydrate: (userJSON: AttributeMap) => Promise,
|
|
136
|
-
logOut: (options: RequestOptions) => Promise,
|
|
137
|
-
me: (options: RequestOptions) => Promise,
|
|
138
|
-
requestPasswordReset: (email: string, options: RequestOptions) => Promise,
|
|
139
|
-
updateUserOnDisk: (user: ParseUser) => Promise,
|
|
140
|
-
upgradeToRevocableSession: (user: ParseUser, options: RequestOptions) => Promise,
|
|
141
|
-
linkWith: (user: ParseUser, authData: AuthData) => Promise,
|
|
142
|
-
removeUserFromDisk: () => Promise,
|
|
143
|
-
verifyPassword: (username: string, password: string, options: RequestOptions) => Promise,
|
|
144
|
-
requestEmailVerification: (email: string, options: RequestOptions) => Promise,
|
|
145
|
-
};*/
|
|
146
|
-
/*:: type HooksController = {
|
|
147
|
-
get: (type: string, functionName?: string, triggerName?: string) => Promise,
|
|
148
|
-
create: (hook: mixed) => Promise,
|
|
149
|
-
delete: (hook: mixed) => Promise,
|
|
150
|
-
update: (hook: mixed) => Promise,
|
|
151
|
-
send: (method: string, path: string, body?: mixed) => Promise,
|
|
152
|
-
};*/
|
|
153
|
-
/*:: type WebSocketController = {
|
|
7
|
+
/** Based on https://github.com/react-native-async-storage/async-storage/blob/main/packages/default-storage-backend/src/types.ts */
|
|
8
|
+
/*:: export type WebSocketController = {
|
|
154
9
|
onopen: () => void,
|
|
155
10
|
onmessage: (message: any) => void,
|
|
156
|
-
onclose: () => void,
|
|
11
|
+
onclose: (arg?: any) => void,
|
|
157
12
|
onerror: (error: any) => void,
|
|
158
13
|
send: (data: any) => void,
|
|
159
14
|
close: () => void,
|
|
160
15
|
};*/
|
|
161
|
-
|
|
162
|
-
AnalyticsController?: AnalyticsController,
|
|
163
|
-
CloudController?: CloudController,
|
|
164
|
-
ConfigController?: ConfigController,
|
|
165
|
-
FileController?: FileController,
|
|
166
|
-
InstallationController?: InstallationController,
|
|
167
|
-
ObjectController?: ObjectController,
|
|
168
|
-
ObjectStateController?: ObjectStateController,
|
|
169
|
-
PushController?: PushController,
|
|
170
|
-
QueryController?: QueryController,
|
|
171
|
-
RESTController?: RESTController,
|
|
172
|
-
SchemaController?: SchemaController,
|
|
173
|
-
SessionController?: SessionController,
|
|
174
|
-
StorageController?: StorageController,
|
|
175
|
-
LocalDatastoreController?: LocalDatastoreController,
|
|
176
|
-
UserController?: UserController,
|
|
177
|
-
HooksController?: HooksController,
|
|
178
|
-
WebSocketController?: WebSocketController,
|
|
179
|
-
};*/
|
|
180
|
-
const config /*: Config & { [key: string]: mixed }*/ = {
|
|
181
|
-
// Defaults
|
|
16
|
+
const config /*: Config & { [key: string]: any }*/ = {
|
|
182
17
|
IS_NODE: typeof process !== 'undefined' && !!process.versions && !!process.versions.node && !process.versions.electron,
|
|
183
18
|
REQUEST_ATTEMPT_LIMIT: 5,
|
|
184
19
|
REQUEST_BATCH_SIZE: 20,
|
|
@@ -188,7 +23,7 @@ const config /*: Config & { [key: string]: mixed }*/ = {
|
|
|
188
23
|
SERVER_AUTH_TOKEN: null,
|
|
189
24
|
LIVEQUERY_SERVER_URL: null,
|
|
190
25
|
ENCRYPTED_KEY: null,
|
|
191
|
-
VERSION: 'js' + "5.1.0-alpha.
|
|
26
|
+
VERSION: 'js' + "5.1.0-alpha.9",
|
|
192
27
|
APPLICATION_ID: null,
|
|
193
28
|
JAVASCRIPT_KEY: null,
|
|
194
29
|
MASTER_KEY: null,
|
|
@@ -263,11 +98,18 @@ const CoreManager = {
|
|
|
263
98
|
requireMethods('FileController', ['saveFile', 'saveBase64'], controller);
|
|
264
99
|
config['FileController'] = controller;
|
|
265
100
|
},
|
|
101
|
+
setEventuallyQueue(controller /*: EventuallyQueue*/) {
|
|
102
|
+
requireMethods('EventuallyQueue', ['poll', 'save', 'destroy'], controller);
|
|
103
|
+
config['EventuallyQueue'] = controller;
|
|
104
|
+
},
|
|
105
|
+
getEventuallyQueue() /*: EventuallyQueue*/{
|
|
106
|
+
return config['EventuallyQueue'];
|
|
107
|
+
},
|
|
266
108
|
getFileController() /*: FileController*/{
|
|
267
109
|
return config['FileController'];
|
|
268
110
|
},
|
|
269
111
|
setInstallationController(controller /*: InstallationController*/) {
|
|
270
|
-
requireMethods('InstallationController', ['currentInstallationId'], controller);
|
|
112
|
+
requireMethods('InstallationController', ['currentInstallationId', 'currentInstallation', 'updateInstallationOnDisk'], controller);
|
|
271
113
|
config['InstallationController'] = controller;
|
|
272
114
|
},
|
|
273
115
|
getInstallationController() /*: InstallationController*/{
|
|
@@ -314,13 +156,6 @@ const CoreManager = {
|
|
|
314
156
|
getRESTController() /*: RESTController*/{
|
|
315
157
|
return config['RESTController'];
|
|
316
158
|
},
|
|
317
|
-
setEventuallyQueue(controller /*: EventuallyQueue*/) {
|
|
318
|
-
requireMethods('EventuallyQueue', ['poll', 'save', 'destroy'], controller);
|
|
319
|
-
config['EventuallyQueue'] = controller;
|
|
320
|
-
},
|
|
321
|
-
getEventuallyQueue() /*: EventuallyQueue*/{
|
|
322
|
-
return config['EventuallyQueue'];
|
|
323
|
-
},
|
|
324
159
|
setSchemaController(controller /*: SchemaController*/) {
|
|
325
160
|
requireMethods('SchemaController', ['get', 'create', 'update', 'delete', 'send', 'purge'], controller);
|
|
326
161
|
config['SchemaController'] = controller;
|
|
@@ -359,16 +194,16 @@ const CoreManager = {
|
|
|
359
194
|
getStorageController() /*: StorageController*/{
|
|
360
195
|
return config['StorageController'];
|
|
361
196
|
},
|
|
362
|
-
setAsyncStorage(storage /*:
|
|
197
|
+
setAsyncStorage(storage /*: AsyncStorageType*/) {
|
|
363
198
|
config['AsyncStorage'] = storage;
|
|
364
199
|
},
|
|
365
200
|
getAsyncStorage() {
|
|
366
201
|
return config['AsyncStorage'];
|
|
367
202
|
},
|
|
368
|
-
setWebSocketController(controller /*: WebSocketController*/) {
|
|
203
|
+
setWebSocketController(controller /*: new (url: string | URL, protocols?: string | string[] | undefined) => WebSocketController*/) {
|
|
369
204
|
config['WebSocketController'] = controller;
|
|
370
205
|
},
|
|
371
|
-
getWebSocketController() /*: WebSocketController*/{
|
|
206
|
+
getWebSocketController() /*: new (url: string | URL, protocols?: string | string[] | undefined) => WebSocketController*/{
|
|
372
207
|
return config['WebSocketController'];
|
|
373
208
|
},
|
|
374
209
|
setUserController(controller /*: UserController*/) {
|
|
@@ -378,11 +213,11 @@ const CoreManager = {
|
|
|
378
213
|
getUserController() /*: UserController*/{
|
|
379
214
|
return config['UserController'];
|
|
380
215
|
},
|
|
381
|
-
setLiveQueryController(controller /*:
|
|
216
|
+
setLiveQueryController(controller /*: LiveQueryControllerType*/) {
|
|
382
217
|
requireMethods('LiveQueryController', ['setDefaultLiveQueryClient', 'getDefaultLiveQueryClient', '_clearCachedDefaultClient'], controller);
|
|
383
218
|
config['LiveQueryController'] = controller;
|
|
384
219
|
},
|
|
385
|
-
getLiveQueryController() /*:
|
|
220
|
+
getLiveQueryController() /*: LiveQueryControllerType*/{
|
|
386
221
|
return config['LiveQueryController'];
|
|
387
222
|
},
|
|
388
223
|
setHooksController(controller /*: HooksController*/) {
|