parse 4.1.0 → 4.2.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.
- package/dist/parse.js +2123 -1542
- package/dist/parse.min.js +2 -2
- package/dist/parse.weapp.js +2105 -1524
- package/dist/parse.weapp.min.js +2 -2
- package/lib/browser/AnonymousUtils.js +1 -1
- package/lib/browser/Cloud.js +4 -2
- package/lib/browser/CoreManager.js +31 -4
- package/lib/browser/EventEmitter.js +7 -2
- package/lib/browser/EventuallyQueue.js +24 -4
- package/lib/browser/LiveQueryClient.js +59 -89
- package/lib/browser/LiveQuerySubscription.js +16 -51
- package/lib/browser/LocalDatastore.js +10 -1
- package/lib/browser/LocalDatastoreController.js +3 -1
- package/lib/browser/ObjectStateMutations.js +17 -2
- package/lib/browser/OfflineQuery.js +1 -1
- package/lib/browser/Parse.js +171 -135
- package/lib/browser/ParseACL.js +2 -1
- package/lib/browser/ParseCLP.js +6 -1
- package/lib/browser/ParseConfig.js +1 -0
- package/lib/browser/ParseError.js +12 -1
- package/lib/browser/ParseFile.js +5 -1
- package/lib/browser/ParseInstallation.js +4 -1
- package/lib/browser/ParseLiveQuery.js +79 -51
- package/lib/browser/ParseObject.js +11 -8
- package/lib/browser/ParseOp.js +3 -1
- package/lib/browser/ParseQuery.js +122 -72
- package/lib/browser/ParseRole.js +5 -1
- package/lib/browser/ParseSchema.js +23 -2
- package/lib/browser/ParseSession.js +1 -1
- package/lib/browser/ParseUser.js +107 -9
- package/lib/browser/Push.js +8 -2
- package/lib/browser/RESTController.js +20 -0
- package/lib/browser/SingleInstanceStateController.js +6 -1
- package/lib/browser/Storage.js +7 -0
- package/lib/browser/TaskQueue.js +4 -0
- package/lib/browser/UniqueInstanceStateController.js +3 -1
- package/lib/browser/unsavedChildren.js +4 -1
- package/lib/node/AnonymousUtils.js +1 -1
- package/lib/node/Cloud.js +4 -2
- package/lib/node/CoreManager.js +30 -4
- package/lib/node/EventEmitter.js +7 -1
- package/lib/node/EventuallyQueue.js +23 -4
- package/lib/node/LiveQueryClient.js +10 -7
- package/lib/node/LiveQuerySubscription.js +5 -7
- package/lib/node/LocalDatastore.js +7 -1
- package/lib/node/ObjectStateMutations.js +14 -2
- package/lib/node/OfflineQuery.js +1 -1
- package/lib/node/Parse.js +162 -126
- package/lib/node/ParseACL.js +2 -1
- package/lib/node/ParseCLP.js +3 -1
- package/lib/node/ParseConfig.js +1 -2
- package/lib/node/ParseError.js +15 -1
- package/lib/node/ParseFile.js +2 -1
- package/lib/node/ParseInstallation.js +1 -1
- package/lib/node/ParseLiveQuery.js +32 -24
- package/lib/node/ParseObject.js +3 -2
- package/lib/node/ParseQuery.js +53 -7
- package/lib/node/ParseRole.js +2 -1
- package/lib/node/ParseSchema.js +21 -2
- package/lib/node/ParseSession.js +1 -5
- package/lib/node/ParseUser.js +95 -9
- package/lib/node/Push.js +8 -2
- package/lib/node/RESTController.js +20 -0
- package/lib/node/SingleInstanceStateController.js +6 -1
- package/lib/node/Storage.js +6 -0
- package/lib/node/TaskQueue.js +4 -1
- package/lib/node/UniqueInstanceStateController.js +3 -1
- package/lib/node/unsavedChildren.js +4 -1
- package/lib/react-native/Cloud.js +3 -0
- package/lib/react-native/CoreManager.js +30 -4
- package/lib/react-native/EventEmitter.js +8 -5
- package/lib/react-native/EventuallyQueue.js +10 -3
- package/lib/react-native/LiveQueryClient.js +44 -70
- package/lib/react-native/LiveQuerySubscription.js +16 -46
- package/lib/react-native/LocalDatastore.js +6 -0
- package/lib/react-native/ObjectStateMutations.js +3 -1
- package/lib/react-native/OfflineQuery.js +1 -1
- package/lib/react-native/Parse.js +127 -90
- package/lib/react-native/ParseCLP.js +2 -2
- package/lib/react-native/ParseError.js +8 -1
- package/lib/react-native/ParseFile.js +1 -0
- package/lib/react-native/ParseLiveQuery.js +39 -11
- package/lib/react-native/ParseQuery.js +37 -17
- package/lib/react-native/ParseSchema.js +14 -1
- package/lib/react-native/ParseUser.js +74 -6
- package/lib/react-native/Storage.js +6 -0
- package/lib/weapp/AnonymousUtils.js +1 -1
- package/lib/weapp/Cloud.js +4 -2
- package/lib/weapp/CoreManager.js +31 -4
- package/lib/weapp/EventEmitter.js +7 -2
- package/lib/weapp/EventuallyQueue.js +24 -4
- package/lib/weapp/LiveQueryClient.js +59 -89
- package/lib/weapp/LiveQuerySubscription.js +16 -51
- package/lib/weapp/LocalDatastore.js +10 -1
- package/lib/weapp/LocalDatastoreController.js +3 -1
- package/lib/weapp/ObjectStateMutations.js +17 -2
- package/lib/weapp/OfflineQuery.js +1 -1
- package/lib/weapp/Parse.js +170 -134
- package/lib/weapp/ParseACL.js +2 -1
- package/lib/weapp/ParseCLP.js +6 -1
- package/lib/weapp/ParseConfig.js +1 -0
- package/lib/weapp/ParseError.js +12 -1
- package/lib/weapp/ParseFile.js +5 -1
- package/lib/weapp/ParseInstallation.js +4 -1
- package/lib/weapp/ParseLiveQuery.js +79 -51
- package/lib/weapp/ParseObject.js +11 -8
- package/lib/weapp/ParseOp.js +3 -1
- package/lib/weapp/ParseQuery.js +122 -72
- package/lib/weapp/ParseRole.js +5 -1
- package/lib/weapp/ParseSchema.js +23 -2
- package/lib/weapp/ParseSession.js +1 -1
- package/lib/weapp/ParseUser.js +107 -9
- package/lib/weapp/Push.js +8 -2
- package/lib/weapp/RESTController.js +20 -0
- package/lib/weapp/SingleInstanceStateController.js +6 -1
- package/lib/weapp/Storage.js +7 -0
- package/lib/weapp/TaskQueue.js +4 -0
- package/lib/weapp/UniqueInstanceStateController.js +3 -1
- package/lib/weapp/unsavedChildren.js +4 -1
- package/package.json +29 -25
package/lib/browser/Cloud.js
CHANGED
|
@@ -21,7 +21,7 @@ var _ParseObject = _interopRequireDefault(require("./ParseObject"));
|
|
|
21
21
|
/**
|
|
22
22
|
* @flow
|
|
23
23
|
*/
|
|
24
|
-
|
|
24
|
+
/*:: import type { RequestOptions } from './RESTController';*/
|
|
25
25
|
/**
|
|
26
26
|
* Contains functions for calling and declaring
|
|
27
27
|
* <a href="/docs/cloud_code_guide#functions">cloud functions</a>.
|
|
@@ -33,7 +33,6 @@ var _ParseObject = _interopRequireDefault(require("./ParseObject"));
|
|
|
33
33
|
* @static
|
|
34
34
|
* @hideconstructor
|
|
35
35
|
*/
|
|
36
|
-
|
|
37
36
|
/**
|
|
38
37
|
* Makes a call to a cloud function.
|
|
39
38
|
*
|
|
@@ -57,6 +56,9 @@ function run(name /*: string*/, data /*: mixed*/, options /*: RequestOptions*/)
|
|
|
57
56
|
if (options.sessionToken) {
|
|
58
57
|
requestOptions.sessionToken = options.sessionToken;
|
|
59
58
|
}
|
|
59
|
+
if (options.installationId) {
|
|
60
|
+
requestOptions.installationId = options.installationId;
|
|
61
|
+
}
|
|
60
62
|
if (options.context && (0, _typeof2.default)(options.context) === 'object') {
|
|
61
63
|
requestOptions.context = options.context;
|
|
62
64
|
}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
|
3
4
|
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
5
|
+
_Object$defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
4
9
|
var _forEach = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
|
|
5
10
|
var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
|
|
6
11
|
/*
|
|
@@ -182,7 +187,7 @@ var config /*: Config & { [key: string]: mixed }*/ = {
|
|
|
182
187
|
SERVER_AUTH_TOKEN: null,
|
|
183
188
|
LIVEQUERY_SERVER_URL: null,
|
|
184
189
|
ENCRYPTED_KEY: null,
|
|
185
|
-
VERSION: 'js' + "4.
|
|
190
|
+
VERSION: 'js' + "4.2.0-alpha.10",
|
|
186
191
|
APPLICATION_ID: null,
|
|
187
192
|
JAVASCRIPT_KEY: null,
|
|
188
193
|
MASTER_KEY: null,
|
|
@@ -191,7 +196,8 @@ var config /*: Config & { [key: string]: mixed }*/ = {
|
|
|
191
196
|
FORCE_REVOCABLE_SESSION: false,
|
|
192
197
|
ENCRYPTED_USER: false,
|
|
193
198
|
IDEMPOTENCY: false,
|
|
194
|
-
ALLOW_CUSTOM_OBJECT_ID: false
|
|
199
|
+
ALLOW_CUSTOM_OBJECT_ID: false,
|
|
200
|
+
PARSE_ERRORS: []
|
|
195
201
|
};
|
|
196
202
|
function requireMethods(name /*: string*/, methods /*: Array<string>*/, controller /*: any*/) {
|
|
197
203
|
(0, _forEach.default)(methods).call(methods, function (func) {
|
|
@@ -201,7 +207,7 @@ function requireMethods(name /*: string*/, methods /*: Array<string>*/, controll
|
|
|
201
207
|
}
|
|
202
208
|
});
|
|
203
209
|
}
|
|
204
|
-
|
|
210
|
+
var CoreManager = {
|
|
205
211
|
get: function (key /*: string*/) /*: any*/{
|
|
206
212
|
if (config.hasOwnProperty(key)) {
|
|
207
213
|
return config[key];
|
|
@@ -211,6 +217,12 @@ module.exports = {
|
|
|
211
217
|
set: function (key /*: string*/, value /*: any*/) /*: void*/{
|
|
212
218
|
config[key] = value;
|
|
213
219
|
},
|
|
220
|
+
setIfNeeded: function (key /*: string*/, value /*: any*/) /*: any*/{
|
|
221
|
+
if (!config.hasOwnProperty(key)) {
|
|
222
|
+
config[key] = value;
|
|
223
|
+
}
|
|
224
|
+
return config[key];
|
|
225
|
+
},
|
|
214
226
|
/* Specialized Controller Setters/Getters */setAnalyticsController: function (controller /*: AnalyticsController*/) {
|
|
215
227
|
requireMethods('AnalyticsController', ['track'], controller);
|
|
216
228
|
config['AnalyticsController'] = controller;
|
|
@@ -239,6 +251,12 @@ module.exports = {
|
|
|
239
251
|
getCryptoController: function () /*: CryptoController*/{
|
|
240
252
|
return config['CryptoController'];
|
|
241
253
|
},
|
|
254
|
+
setEventEmitter: function (eventEmitter /*: any*/) {
|
|
255
|
+
config['EventEmitter'] = eventEmitter;
|
|
256
|
+
},
|
|
257
|
+
getEventEmitter: function () /*: any*/{
|
|
258
|
+
return config['EventEmitter'];
|
|
259
|
+
},
|
|
242
260
|
setFileController: function (controller /*: FileController*/) {
|
|
243
261
|
requireMethods('FileController', ['saveFile', 'saveBase64'], controller);
|
|
244
262
|
config['FileController'] = controller;
|
|
@@ -253,6 +271,12 @@ module.exports = {
|
|
|
253
271
|
getInstallationController: function () /*: InstallationController*/{
|
|
254
272
|
return config['InstallationController'];
|
|
255
273
|
},
|
|
274
|
+
setLiveQuery: function (liveQuery /*: any*/) {
|
|
275
|
+
config['LiveQuery'] = liveQuery;
|
|
276
|
+
},
|
|
277
|
+
getLiveQuery: function () /*: any*/{
|
|
278
|
+
return config['LiveQuery'];
|
|
279
|
+
},
|
|
256
280
|
setObjectController: function (controller /*: ObjectController*/) {
|
|
257
281
|
requireMethods('ObjectController', ['save', 'fetch', 'destroy'], controller);
|
|
258
282
|
config['ObjectController'] = controller;
|
|
@@ -359,4 +383,7 @@ module.exports = {
|
|
|
359
383
|
getHooksController: function () /*: HooksController*/{
|
|
360
384
|
return config['HooksController'];
|
|
361
385
|
}
|
|
362
|
-
};
|
|
386
|
+
};
|
|
387
|
+
module.exports = CoreManager;
|
|
388
|
+
var _default = CoreManager;
|
|
389
|
+
exports.default = _default;
|
|
@@ -3,5 +3,10 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* This is a simple wrapper to unify EventEmitter implementations across platforms.
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
var EventEmitter;
|
|
7
|
+
try {
|
|
8
|
+
EventEmitter = require('events').EventEmitter;
|
|
9
|
+
} catch (_) {
|
|
10
|
+
// EventEmitter unavailable
|
|
11
|
+
}
|
|
12
|
+
module.exports = EventEmitter;
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
|
3
4
|
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
5
|
+
_Object$defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
4
9
|
var _stringify = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/json/stringify"));
|
|
5
10
|
var _splice = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/splice"));
|
|
6
11
|
var _findIndex = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/find-index"));
|
|
@@ -10,6 +15,7 @@ var _regenerator = _interopRequireDefault(require("@babel/runtime-corejs3/regene
|
|
|
10
15
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/toConsumableArray"));
|
|
11
16
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/asyncToGenerator"));
|
|
12
17
|
var _CoreManager = _interopRequireDefault(require("./CoreManager"));
|
|
18
|
+
var _ParseError = _interopRequireDefault(require("./ParseError"));
|
|
13
19
|
var _ParseObject = _interopRequireDefault(require("./ParseObject"));
|
|
14
20
|
var _ParseQuery = _interopRequireDefault(require("./ParseQuery"));
|
|
15
21
|
var _Storage = _interopRequireDefault(require("./Storage"));
|
|
@@ -18,7 +24,19 @@ var _Storage = _interopRequireDefault(require("./Storage"));
|
|
|
18
24
|
*
|
|
19
25
|
* @flow
|
|
20
26
|
*/
|
|
21
|
-
|
|
27
|
+
/*:: import type { SaveOptions } from './ParseObject';*/
|
|
28
|
+
/*:: import type { RequestOptions } from './RESTController';*/
|
|
29
|
+
/*:: type QueueObject = {
|
|
30
|
+
queueId: string,
|
|
31
|
+
action: string,
|
|
32
|
+
object: ParseObject,
|
|
33
|
+
serverOptions: SaveOptions | RequestOptions,
|
|
34
|
+
id: string,
|
|
35
|
+
className: string,
|
|
36
|
+
hash: string,
|
|
37
|
+
createdAt: Date,
|
|
38
|
+
};*/
|
|
39
|
+
/*:: type Queue = Array<QueueObject>;*/
|
|
22
40
|
var QUEUE_KEY = 'Parse/Eventually/Queue';
|
|
23
41
|
var queueCache = [];
|
|
24
42
|
var dirtyCache = true;
|
|
@@ -389,7 +407,7 @@ var EventuallyQueue = {
|
|
|
389
407
|
case 14:
|
|
390
408
|
_context6.prev = 14;
|
|
391
409
|
_context6.t1 = _context6["catch"](7);
|
|
392
|
-
if (!(_context6.t1.
|
|
410
|
+
if (!(_context6.t1.code !== _ParseError.default.CONNECTION_FAILED)) {
|
|
393
411
|
_context6.next = 19;
|
|
394
412
|
break;
|
|
395
413
|
}
|
|
@@ -410,7 +428,7 @@ var EventuallyQueue = {
|
|
|
410
428
|
case 27:
|
|
411
429
|
_context6.prev = 27;
|
|
412
430
|
_context6.t2 = _context6["catch"](20);
|
|
413
|
-
if (!(_context6.t2.
|
|
431
|
+
if (!(_context6.t2.code !== _ParseError.default.CONNECTION_FAILED)) {
|
|
414
432
|
_context6.next = 32;
|
|
415
433
|
break;
|
|
416
434
|
}
|
|
@@ -537,4 +555,6 @@ var EventuallyQueue = {
|
|
|
537
555
|
}
|
|
538
556
|
}
|
|
539
557
|
};
|
|
540
|
-
module.exports = EventuallyQueue;
|
|
558
|
+
module.exports = EventuallyQueue;
|
|
559
|
+
var _default = EventuallyQueue;
|
|
560
|
+
exports.default = _default;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _Reflect$construct = require("@babel/runtime-corejs3/core-js-stable/reflect/construct");
|
|
4
3
|
var _sliceInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/slice");
|
|
5
4
|
var _Array$from = require("@babel/runtime-corejs3/core-js-stable/array/from");
|
|
6
5
|
var _Symbol = require("@babel/runtime-corejs3/core-js-stable/symbol");
|
|
@@ -23,13 +22,8 @@ var _bind = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stabl
|
|
|
23
22
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/typeof"));
|
|
24
23
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/classCallCheck"));
|
|
25
24
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/createClass"));
|
|
26
|
-
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/assertThisInitialized"));
|
|
27
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/inherits"));
|
|
28
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/possibleConstructorReturn"));
|
|
29
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/getPrototypeOf"));
|
|
30
25
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
|
|
31
26
|
var _CoreManager = _interopRequireDefault(require("./CoreManager"));
|
|
32
|
-
var _EventEmitter2 = _interopRequireDefault(require("./EventEmitter"));
|
|
33
27
|
var _ParseObject = _interopRequireDefault(require("./ParseObject"));
|
|
34
28
|
var _LiveQuerySubscription = _interopRequireDefault(require("./LiveQuerySubscription"));
|
|
35
29
|
var _promiseUtils = require("./promiseUtils");
|
|
@@ -98,32 +92,7 @@ function _arrayLikeToArray(arr, len) {
|
|
|
98
92
|
if (len == null || len > arr.length) len = arr.length;
|
|
99
93
|
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
100
94
|
return arr2;
|
|
101
|
-
}
|
|
102
|
-
function _createSuper(Derived) {
|
|
103
|
-
var hasNativeReflectConstruct = _isNativeReflectConstruct();
|
|
104
|
-
return function () {
|
|
105
|
-
var Super = (0, _getPrototypeOf2.default)(Derived),
|
|
106
|
-
result;
|
|
107
|
-
if (hasNativeReflectConstruct) {
|
|
108
|
-
var NewTarget = (0, _getPrototypeOf2.default)(this).constructor;
|
|
109
|
-
result = _Reflect$construct(Super, arguments, NewTarget);
|
|
110
|
-
} else {
|
|
111
|
-
result = Super.apply(this, arguments);
|
|
112
|
-
}
|
|
113
|
-
return (0, _possibleConstructorReturn2.default)(this, result);
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
function _isNativeReflectConstruct() {
|
|
117
|
-
if (typeof Reflect === "undefined" || !_Reflect$construct) return false;
|
|
118
|
-
if (_Reflect$construct.sham) return false;
|
|
119
|
-
if (typeof Proxy === "function") return true;
|
|
120
|
-
try {
|
|
121
|
-
Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {}));
|
|
122
|
-
return true;
|
|
123
|
-
} catch (e) {
|
|
124
|
-
return false;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
95
|
+
} /* global WebSocket */
|
|
127
96
|
// The LiveQuery client inner state
|
|
128
97
|
var CLIENT_STATE = {
|
|
129
98
|
INITIALIZED: 'initialized',
|
|
@@ -179,7 +148,6 @@ var generateInterval = function (k) {
|
|
|
179
148
|
|
|
180
149
|
/**
|
|
181
150
|
* Creates a new LiveQueryClient.
|
|
182
|
-
* Extends events.EventEmitter
|
|
183
151
|
* <a href="https://nodejs.org/api/events.html#events_class_eventemitter">cloud functions</a>.
|
|
184
152
|
*
|
|
185
153
|
* A wrapper of a standard WebSocket client. We add several useful methods to
|
|
@@ -221,9 +189,7 @@ var generateInterval = function (k) {
|
|
|
221
189
|
*
|
|
222
190
|
* @alias Parse.LiveQueryClient
|
|
223
191
|
*/
|
|
224
|
-
var LiveQueryClient = /*#__PURE__*/function (
|
|
225
|
-
(0, _inherits2.default)(LiveQueryClient, _EventEmitter);
|
|
226
|
-
var _super = _createSuper(LiveQueryClient);
|
|
192
|
+
var LiveQueryClient = /*#__PURE__*/function () {
|
|
227
193
|
/**
|
|
228
194
|
* @param {object} options
|
|
229
195
|
* @param {string} options.applicationId - applicationId of your Parse app
|
|
@@ -234,7 +200,6 @@ var LiveQueryClient = /*#__PURE__*/function (_EventEmitter) {
|
|
|
234
200
|
* @param {string} options.installationId (optional)
|
|
235
201
|
*/
|
|
236
202
|
function LiveQueryClient(_ref) {
|
|
237
|
-
var _this;
|
|
238
203
|
var applicationId = _ref.applicationId,
|
|
239
204
|
serverURL = _ref.serverURL,
|
|
240
205
|
javascriptKey = _ref.javascriptKey,
|
|
@@ -242,43 +207,44 @@ var LiveQueryClient = /*#__PURE__*/function (_EventEmitter) {
|
|
|
242
207
|
sessionToken = _ref.sessionToken,
|
|
243
208
|
installationId = _ref.installationId;
|
|
244
209
|
(0, _classCallCheck2.default)(this, LiveQueryClient);
|
|
245
|
-
|
|
246
|
-
(0, _defineProperty2.default)(
|
|
247
|
-
(0, _defineProperty2.default)(
|
|
248
|
-
(0, _defineProperty2.default)(
|
|
249
|
-
(0, _defineProperty2.default)(
|
|
250
|
-
(0, _defineProperty2.default)(
|
|
251
|
-
(0, _defineProperty2.default)(
|
|
252
|
-
(0, _defineProperty2.default)(
|
|
253
|
-
(0, _defineProperty2.default)(
|
|
254
|
-
(0, _defineProperty2.default)(
|
|
255
|
-
(0, _defineProperty2.default)(
|
|
256
|
-
(0, _defineProperty2.default)(
|
|
257
|
-
(0, _defineProperty2.default)(
|
|
258
|
-
(0, _defineProperty2.default)(
|
|
259
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "state", void 0);
|
|
210
|
+
(0, _defineProperty2.default)(this, "attempts", void 0);
|
|
211
|
+
(0, _defineProperty2.default)(this, "id", void 0);
|
|
212
|
+
(0, _defineProperty2.default)(this, "requestId", void 0);
|
|
213
|
+
(0, _defineProperty2.default)(this, "applicationId", void 0);
|
|
214
|
+
(0, _defineProperty2.default)(this, "serverURL", void 0);
|
|
215
|
+
(0, _defineProperty2.default)(this, "javascriptKey", void 0);
|
|
216
|
+
(0, _defineProperty2.default)(this, "masterKey", void 0);
|
|
217
|
+
(0, _defineProperty2.default)(this, "sessionToken", void 0);
|
|
218
|
+
(0, _defineProperty2.default)(this, "installationId", void 0);
|
|
219
|
+
(0, _defineProperty2.default)(this, "additionalProperties", void 0);
|
|
220
|
+
(0, _defineProperty2.default)(this, "connectPromise", void 0);
|
|
221
|
+
(0, _defineProperty2.default)(this, "subscriptions", void 0);
|
|
222
|
+
(0, _defineProperty2.default)(this, "socket", void 0);
|
|
223
|
+
(0, _defineProperty2.default)(this, "state", void 0);
|
|
260
224
|
if (!serverURL || (0, _indexOf.default)(serverURL).call(serverURL, 'ws') !== 0) {
|
|
261
225
|
throw new Error('You need to set a proper Parse LiveQuery server url before using LiveQueryClient');
|
|
262
226
|
}
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
227
|
+
this.reconnectHandle = null;
|
|
228
|
+
this.attempts = 1;
|
|
229
|
+
this.id = 0;
|
|
230
|
+
this.requestId = 1;
|
|
231
|
+
this.serverURL = serverURL;
|
|
232
|
+
this.applicationId = applicationId;
|
|
233
|
+
this.javascriptKey = javascriptKey || undefined;
|
|
234
|
+
this.masterKey = masterKey || undefined;
|
|
235
|
+
this.sessionToken = sessionToken || undefined;
|
|
236
|
+
this.installationId = installationId || undefined;
|
|
237
|
+
this.additionalProperties = true;
|
|
238
|
+
this.connectPromise = (0, _promiseUtils.resolvingPromise)();
|
|
239
|
+
this.subscriptions = new _map.default();
|
|
240
|
+
this.state = CLIENT_STATE.INITIALIZED;
|
|
241
|
+
var EventEmitter = _CoreManager.default.getEventEmitter();
|
|
242
|
+
this.emitter = new EventEmitter();
|
|
243
|
+
this.on = this.emitter.on;
|
|
244
|
+
this.emit = this.emitter.emit;
|
|
278
245
|
// adding listener so process does not crash
|
|
279
246
|
// best practice is for developer to register their own listener
|
|
280
|
-
|
|
281
|
-
return _this;
|
|
247
|
+
this.on('error', function () {});
|
|
282
248
|
}
|
|
283
249
|
(0, _createClass2.default)(LiveQueryClient, [{
|
|
284
250
|
key: "shouldOpen",
|
|
@@ -303,21 +269,25 @@ var LiveQueryClient = /*#__PURE__*/function (_EventEmitter) {
|
|
|
303
269
|
}, {
|
|
304
270
|
key: "subscribe",
|
|
305
271
|
value: function (query /*: Object*/, sessionToken /*: ?string*/) /*: LiveQuerySubscription*/{
|
|
306
|
-
var
|
|
272
|
+
var _queryJSON$keys,
|
|
273
|
+
_queryJSON$watch,
|
|
274
|
+
_this = this;
|
|
307
275
|
if (!query) {
|
|
308
276
|
return;
|
|
309
277
|
}
|
|
310
278
|
var className = query.className;
|
|
311
279
|
var queryJSON = query.toJSON();
|
|
312
280
|
var where = queryJSON.where;
|
|
313
|
-
var fields = (0, _keys.default)(queryJSON) ?
|
|
281
|
+
var fields = (_queryJSON$keys = (0, _keys.default)(queryJSON)) === null || _queryJSON$keys === void 0 ? void 0 : _queryJSON$keys.split(',');
|
|
282
|
+
var watch = (_queryJSON$watch = queryJSON.watch) === null || _queryJSON$watch === void 0 ? void 0 : _queryJSON$watch.split(',');
|
|
314
283
|
var subscribeRequest = {
|
|
315
284
|
op: OP_TYPES.SUBSCRIBE,
|
|
316
285
|
requestId: this.requestId,
|
|
317
286
|
query: {
|
|
318
287
|
className: className,
|
|
319
288
|
where: where,
|
|
320
|
-
fields: fields
|
|
289
|
+
fields: fields,
|
|
290
|
+
watch: watch
|
|
321
291
|
}
|
|
322
292
|
};
|
|
323
293
|
if (sessionToken) {
|
|
@@ -327,7 +297,7 @@ var LiveQueryClient = /*#__PURE__*/function (_EventEmitter) {
|
|
|
327
297
|
this.subscriptions.set(this.requestId, subscription);
|
|
328
298
|
this.requestId += 1;
|
|
329
299
|
this.connectPromise.then(function () {
|
|
330
|
-
|
|
300
|
+
_this.socket.send((0, _stringify.default)(subscribeRequest));
|
|
331
301
|
}).catch(function (error) {
|
|
332
302
|
subscription.subscribePromise.reject(error);
|
|
333
303
|
});
|
|
@@ -343,7 +313,7 @@ var LiveQueryClient = /*#__PURE__*/function (_EventEmitter) {
|
|
|
343
313
|
}, {
|
|
344
314
|
key: "unsubscribe",
|
|
345
315
|
value: function (subscription /*: Object*/) /*: ?Promise*/{
|
|
346
|
-
var
|
|
316
|
+
var _this2 = this;
|
|
347
317
|
if (!subscription) {
|
|
348
318
|
return;
|
|
349
319
|
}
|
|
@@ -352,7 +322,7 @@ var LiveQueryClient = /*#__PURE__*/function (_EventEmitter) {
|
|
|
352
322
|
requestId: subscription.id
|
|
353
323
|
};
|
|
354
324
|
return this.connectPromise.then(function () {
|
|
355
|
-
return
|
|
325
|
+
return _this2.socket.send((0, _stringify.default)(unsubscribeRequest));
|
|
356
326
|
}).then(function () {
|
|
357
327
|
return subscription.unsubscribePromise;
|
|
358
328
|
});
|
|
@@ -366,7 +336,7 @@ var LiveQueryClient = /*#__PURE__*/function (_EventEmitter) {
|
|
|
366
336
|
}, {
|
|
367
337
|
key: "open",
|
|
368
338
|
value: function () {
|
|
369
|
-
var
|
|
339
|
+
var _this3 = this;
|
|
370
340
|
var WebSocketImplementation = _CoreManager.default.getWebSocketController();
|
|
371
341
|
if (!WebSocketImplementation) {
|
|
372
342
|
this.emit(CLIENT_EMMITER_TYPES.ERROR, 'Can not find WebSocket implementation');
|
|
@@ -380,24 +350,24 @@ var LiveQueryClient = /*#__PURE__*/function (_EventEmitter) {
|
|
|
380
350
|
|
|
381
351
|
// Bind WebSocket callbacks
|
|
382
352
|
this.socket.onopen = function () {
|
|
383
|
-
|
|
353
|
+
_this3._handleWebSocketOpen();
|
|
384
354
|
};
|
|
385
355
|
this.socket.onmessage = function (event) {
|
|
386
|
-
|
|
356
|
+
_this3._handleWebSocketMessage(event);
|
|
387
357
|
};
|
|
388
358
|
this.socket.onclose = function (event) {
|
|
389
|
-
|
|
390
|
-
|
|
359
|
+
_this3.socket.closingPromise.resolve(event);
|
|
360
|
+
_this3._handleWebSocketClose();
|
|
391
361
|
};
|
|
392
362
|
this.socket.onerror = function (error) {
|
|
393
|
-
|
|
363
|
+
_this3._handleWebSocketError(error);
|
|
394
364
|
};
|
|
395
365
|
}
|
|
396
366
|
}, {
|
|
397
367
|
key: "resubscribe",
|
|
398
368
|
value: function () {
|
|
399
369
|
var _context,
|
|
400
|
-
|
|
370
|
+
_this4 = this;
|
|
401
371
|
(0, _forEach.default)(_context = this.subscriptions).call(_context, function (subscription, requestId) {
|
|
402
372
|
var query = subscription.query;
|
|
403
373
|
var queryJSON = query.toJSON();
|
|
@@ -417,8 +387,8 @@ var LiveQueryClient = /*#__PURE__*/function (_EventEmitter) {
|
|
|
417
387
|
if (sessionToken) {
|
|
418
388
|
subscribeRequest.sessionToken = sessionToken;
|
|
419
389
|
}
|
|
420
|
-
|
|
421
|
-
|
|
390
|
+
_this4.connectPromise.then(function () {
|
|
391
|
+
_this4.socket.send((0, _stringify.default)(subscribeRequest));
|
|
422
392
|
});
|
|
423
393
|
});
|
|
424
394
|
}
|
|
@@ -630,7 +600,7 @@ var LiveQueryClient = /*#__PURE__*/function (_EventEmitter) {
|
|
|
630
600
|
key: "_handleReconnect",
|
|
631
601
|
value: function () {
|
|
632
602
|
var _context5,
|
|
633
|
-
|
|
603
|
+
_this5 = this;
|
|
634
604
|
// if closed or currently reconnecting we stop attempting to reconnect
|
|
635
605
|
if (this.state === CLIENT_STATE.DISCONNECTED) {
|
|
636
606
|
return;
|
|
@@ -647,14 +617,14 @@ var LiveQueryClient = /*#__PURE__*/function (_EventEmitter) {
|
|
|
647
617
|
clearTimeout(this.reconnectHandle);
|
|
648
618
|
}
|
|
649
619
|
this.reconnectHandle = (0, _setTimeout2.default)((0, _bind.default)(_context5 = function () {
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
620
|
+
_this5.attempts++;
|
|
621
|
+
_this5.connectPromise = (0, _promiseUtils.resolvingPromise)();
|
|
622
|
+
_this5.open();
|
|
653
623
|
}).call(_context5, this), time);
|
|
654
624
|
}
|
|
655
625
|
}]);
|
|
656
626
|
return LiveQueryClient;
|
|
657
|
-
}(
|
|
627
|
+
}();
|
|
658
628
|
_CoreManager.default.setWebSocketController(typeof WebSocket === 'function' || (typeof WebSocket === "undefined" ? "undefined" : (0, _typeof2.default)(WebSocket)) === 'object' ? WebSocket : null);
|
|
659
629
|
var _default = LiveQueryClient;
|
|
660
630
|
exports.default = _default;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _Reflect$construct = require("@babel/runtime-corejs3/core-js-stable/reflect/construct");
|
|
4
3
|
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
|
5
4
|
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
6
5
|
_Object$defineProperty(exports, "__esModule", {
|
|
@@ -9,40 +8,10 @@ _Object$defineProperty(exports, "__esModule", {
|
|
|
9
8
|
exports.default = void 0;
|
|
10
9
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/classCallCheck"));
|
|
11
10
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/createClass"));
|
|
12
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/inherits"));
|
|
13
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/possibleConstructorReturn"));
|
|
14
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/getPrototypeOf"));
|
|
15
|
-
var _EventEmitter2 = _interopRequireDefault(require("./EventEmitter"));
|
|
16
11
|
var _CoreManager = _interopRequireDefault(require("./CoreManager"));
|
|
17
12
|
var _promiseUtils = require("./promiseUtils");
|
|
18
|
-
function _createSuper(Derived) {
|
|
19
|
-
var hasNativeReflectConstruct = _isNativeReflectConstruct();
|
|
20
|
-
return function () {
|
|
21
|
-
var Super = (0, _getPrototypeOf2.default)(Derived),
|
|
22
|
-
result;
|
|
23
|
-
if (hasNativeReflectConstruct) {
|
|
24
|
-
var NewTarget = (0, _getPrototypeOf2.default)(this).constructor;
|
|
25
|
-
result = _Reflect$construct(Super, arguments, NewTarget);
|
|
26
|
-
} else {
|
|
27
|
-
result = Super.apply(this, arguments);
|
|
28
|
-
}
|
|
29
|
-
return (0, _possibleConstructorReturn2.default)(this, result);
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
function _isNativeReflectConstruct() {
|
|
33
|
-
if (typeof Reflect === "undefined" || !_Reflect$construct) return false;
|
|
34
|
-
if (_Reflect$construct.sham) return false;
|
|
35
|
-
if (typeof Proxy === "function") return true;
|
|
36
|
-
try {
|
|
37
|
-
Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {}));
|
|
38
|
-
return true;
|
|
39
|
-
} catch (e) {
|
|
40
|
-
return false;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
13
|
/**
|
|
44
14
|
* Creates a new LiveQuery Subscription.
|
|
45
|
-
* Extends events.EventEmitter
|
|
46
15
|
* <a href="https://nodejs.org/api/events.html#events_class_eventemitter">cloud functions</a>.
|
|
47
16
|
*
|
|
48
17
|
* <p>Response Object - Contains data from the client that made the request
|
|
@@ -122,32 +91,28 @@ function _isNativeReflectConstruct() {
|
|
|
122
91
|
* subscription.on('close', () => {
|
|
123
92
|
*
|
|
124
93
|
* });</pre></p>
|
|
125
|
-
*
|
|
126
|
-
* @alias Parse.LiveQuerySubscription
|
|
127
94
|
*/
|
|
128
|
-
var Subscription = /*#__PURE__*/function (
|
|
129
|
-
(0, _inherits2.default)(Subscription, _EventEmitter);
|
|
130
|
-
var _super = _createSuper(Subscription);
|
|
95
|
+
var Subscription = /*#__PURE__*/function () {
|
|
131
96
|
/*
|
|
132
97
|
* @param {string} id - subscription id
|
|
133
98
|
* @param {string} query - query to subscribe to
|
|
134
99
|
* @param {string} sessionToken - optional session token
|
|
135
100
|
*/
|
|
136
101
|
function Subscription(id, query, sessionToken) {
|
|
137
|
-
var _this;
|
|
138
102
|
(0, _classCallCheck2.default)(this, Subscription);
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
103
|
+
this.id = id;
|
|
104
|
+
this.query = query;
|
|
105
|
+
this.sessionToken = sessionToken;
|
|
106
|
+
this.subscribePromise = (0, _promiseUtils.resolvingPromise)();
|
|
107
|
+
this.unsubscribePromise = (0, _promiseUtils.resolvingPromise)();
|
|
108
|
+
this.subscribed = false;
|
|
109
|
+
var EventEmitter = _CoreManager.default.getEventEmitter();
|
|
110
|
+
this.emitter = new EventEmitter();
|
|
111
|
+
this.on = this.emitter.on;
|
|
112
|
+
this.emit = this.emitter.emit;
|
|
147
113
|
// adding listener so process does not crash
|
|
148
114
|
// best practice is for developer to register their own listener
|
|
149
|
-
|
|
150
|
-
return _this;
|
|
115
|
+
this.on('error', function () {});
|
|
151
116
|
}
|
|
152
117
|
|
|
153
118
|
/**
|
|
@@ -158,14 +123,14 @@ var Subscription = /*#__PURE__*/function (_EventEmitter) {
|
|
|
158
123
|
(0, _createClass2.default)(Subscription, [{
|
|
159
124
|
key: "unsubscribe",
|
|
160
125
|
value: function () /*: Promise*/{
|
|
161
|
-
var
|
|
126
|
+
var _this = this;
|
|
162
127
|
return _CoreManager.default.getLiveQueryController().getDefaultLiveQueryClient().then(function (liveQueryClient) {
|
|
163
|
-
|
|
164
|
-
return liveQueryClient.unsubscribe(
|
|
128
|
+
_this.emit('close');
|
|
129
|
+
return liveQueryClient.unsubscribe(_this);
|
|
165
130
|
});
|
|
166
131
|
}
|
|
167
132
|
}]);
|
|
168
133
|
return Subscription;
|
|
169
|
-
}(
|
|
134
|
+
}();
|
|
170
135
|
var _default = Subscription;
|
|
171
136
|
exports.default = _default;
|
|
@@ -5,7 +5,12 @@ var _Array$from2 = require("@babel/runtime-corejs3/core-js-stable/array/from");
|
|
|
5
5
|
var _Symbol = require("@babel/runtime-corejs3/core-js-stable/symbol");
|
|
6
6
|
var _getIteratorMethod = require("@babel/runtime-corejs3/core-js/get-iterator-method");
|
|
7
7
|
var _Array$isArray2 = require("@babel/runtime-corejs3/core-js-stable/array/is-array");
|
|
8
|
+
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
|
8
9
|
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
10
|
+
_Object$defineProperty(exports, "__esModule", {
|
|
11
|
+
value: true
|
|
12
|
+
});
|
|
13
|
+
exports.default = void 0;
|
|
9
14
|
var _regenerator = _interopRequireDefault(require("@babel/runtime-corejs3/regenerator"));
|
|
10
15
|
var _promise = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/promise"));
|
|
11
16
|
var _set = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/set"));
|
|
@@ -89,7 +94,9 @@ function _arrayLikeToArray(arr, len) {
|
|
|
89
94
|
if (len == null || len > arr.length) len = arr.length;
|
|
90
95
|
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
91
96
|
return arr2;
|
|
92
|
-
}
|
|
97
|
+
} /**
|
|
98
|
+
* @flow
|
|
99
|
+
*/ /*:: import type ParseObject from './ParseObject';*/
|
|
93
100
|
/**
|
|
94
101
|
* Provides a local datastore which can be used to store and retrieve <code>Parse.Object</code>. <br />
|
|
95
102
|
* To enable this functionality, call <code>Parse.enableLocalDatastore()</code>.
|
|
@@ -697,5 +704,7 @@ var LocalDatastore = {
|
|
|
697
704
|
}
|
|
698
705
|
};
|
|
699
706
|
module.exports = LocalDatastore;
|
|
707
|
+
var _default = LocalDatastore;
|
|
708
|
+
exports.default = _default;
|
|
700
709
|
_CoreManager.default.setLocalDatastoreController(require('./LocalDatastoreController'));
|
|
701
710
|
_CoreManager.default.setLocalDatastore(LocalDatastore);
|
|
@@ -78,7 +78,9 @@ function _arrayLikeToArray(arr, len) {
|
|
|
78
78
|
if (len == null || len > arr.length) len = arr.length;
|
|
79
79
|
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
80
80
|
return arr2;
|
|
81
|
-
}
|
|
81
|
+
} /**
|
|
82
|
+
* @flow
|
|
83
|
+
*/
|
|
82
84
|
var LocalDatastoreController = {
|
|
83
85
|
fromPinWithName: function (name /*: string*/) /*: Array<Object>*/{
|
|
84
86
|
return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|