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
|
@@ -5,22 +5,49 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
exports.default = void 0;
|
|
6
6
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
7
7
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
8
|
-
var
|
|
8
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
9
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
9
10
|
var _LiveQueryClient = _interopRequireDefault(require("./LiveQueryClient"));
|
|
10
11
|
var _CoreManager = _interopRequireDefault(require("./CoreManager"));
|
|
11
12
|
function getLiveQueryClient() {
|
|
12
13
|
return _CoreManager.default.getLiveQueryController().getDefaultLiveQueryClient();
|
|
13
14
|
}
|
|
14
|
-
var LiveQuery =
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
15
|
+
var LiveQuery = function () {
|
|
16
|
+
function LiveQuery() {
|
|
17
|
+
(0, _classCallCheck2.default)(this, LiveQuery);
|
|
18
|
+
var EventEmitter = _CoreManager.default.getEventEmitter();
|
|
19
|
+
this.emitter = new EventEmitter();
|
|
20
|
+
this.on = this.emitter.on;
|
|
21
|
+
this.emit = this.emitter.emit;
|
|
22
|
+
this.on('error', function () {});
|
|
23
|
+
}
|
|
24
|
+
(0, _createClass2.default)(LiveQuery, [{
|
|
25
|
+
key: "open",
|
|
26
|
+
value: function () {
|
|
27
|
+
var _open = (0, _asyncToGenerator2.default)(function* () {
|
|
28
|
+
var liveQueryClient = yield getLiveQueryClient();
|
|
29
|
+
liveQueryClient.open();
|
|
30
|
+
});
|
|
31
|
+
function open() {
|
|
32
|
+
return _open.apply(this, arguments);
|
|
33
|
+
}
|
|
34
|
+
return open;
|
|
35
|
+
}()
|
|
36
|
+
}, {
|
|
37
|
+
key: "close",
|
|
38
|
+
value: function () {
|
|
39
|
+
var _close = (0, _asyncToGenerator2.default)(function* () {
|
|
40
|
+
var liveQueryClient = yield getLiveQueryClient();
|
|
41
|
+
liveQueryClient.close();
|
|
42
|
+
});
|
|
43
|
+
function close() {
|
|
44
|
+
return _close.apply(this, arguments);
|
|
45
|
+
}
|
|
46
|
+
return close;
|
|
47
|
+
}()
|
|
48
|
+
}]);
|
|
49
|
+
return LiveQuery;
|
|
50
|
+
}();
|
|
24
51
|
var _default = LiveQuery;
|
|
25
52
|
exports.default = _default;
|
|
26
53
|
var defaultLiveQueryClient;
|
|
@@ -60,6 +87,7 @@ var DefaultLiveQueryController = {
|
|
|
60
87
|
sessionToken: sessionToken,
|
|
61
88
|
installationId: installationId
|
|
62
89
|
});
|
|
90
|
+
var LiveQuery = _CoreManager.default.getLiveQuery();
|
|
63
91
|
defaultLiveQueryClient.on('error', function (error) {
|
|
64
92
|
LiveQuery.emit('error', error);
|
|
65
93
|
});
|
|
@@ -131,6 +131,7 @@ var ParseQuery = function () {
|
|
|
131
131
|
throw new TypeError('A ParseQuery must be constructed with a ParseObject or class name.');
|
|
132
132
|
}
|
|
133
133
|
this._where = {};
|
|
134
|
+
this._watch = [];
|
|
134
135
|
this._include = [];
|
|
135
136
|
this._exclude = [];
|
|
136
137
|
this._count = false;
|
|
@@ -262,6 +263,9 @@ var ParseQuery = function () {
|
|
|
262
263
|
var params = {
|
|
263
264
|
where: this._where
|
|
264
265
|
};
|
|
266
|
+
if (this._watch.length) {
|
|
267
|
+
params.watch = this._watch.join(',');
|
|
268
|
+
}
|
|
265
269
|
if (this._include.length) {
|
|
266
270
|
params.include = this._include.join(',');
|
|
267
271
|
}
|
|
@@ -309,6 +313,9 @@ var ParseQuery = function () {
|
|
|
309
313
|
if (json.where) {
|
|
310
314
|
this._where = json.where;
|
|
311
315
|
}
|
|
316
|
+
if (json.watch) {
|
|
317
|
+
this._watch = json.watch.split(',');
|
|
318
|
+
}
|
|
312
319
|
if (json.include) {
|
|
313
320
|
this._include = json.include.split(',');
|
|
314
321
|
}
|
|
@@ -571,13 +578,10 @@ var ParseQuery = function () {
|
|
|
571
578
|
}
|
|
572
579
|
var query = new ParseQuery(this.className);
|
|
573
580
|
query._limit = options.batchSize || 100;
|
|
574
|
-
query._include = this._include
|
|
575
|
-
|
|
576
|
-
});
|
|
581
|
+
query._include = (0, _toConsumableArray2.default)(this._include);
|
|
582
|
+
query._exclude = (0, _toConsumableArray2.default)(this._exclude);
|
|
577
583
|
if (this._select) {
|
|
578
|
-
query._select = this._select
|
|
579
|
-
return s;
|
|
580
|
-
});
|
|
584
|
+
query._select = (0, _toConsumableArray2.default)(this._select);
|
|
581
585
|
}
|
|
582
586
|
query._hint = this._hint;
|
|
583
587
|
query._where = {};
|
|
@@ -1144,6 +1148,22 @@ var ParseQuery = function () {
|
|
|
1144
1148
|
});
|
|
1145
1149
|
return this;
|
|
1146
1150
|
}
|
|
1151
|
+
}, {
|
|
1152
|
+
key: "watch",
|
|
1153
|
+
value: function () {
|
|
1154
|
+
var _this14 = this;
|
|
1155
|
+
for (var _len8 = arguments.length, keys = new Array(_len8), _key12 = 0; _key12 < _len8; _key12++) {
|
|
1156
|
+
keys[_key12] = arguments[_key12];
|
|
1157
|
+
}
|
|
1158
|
+
keys.forEach(function (key) {
|
|
1159
|
+
if (Array.isArray(key)) {
|
|
1160
|
+
_this14._watch = _this14._watch.concat(key);
|
|
1161
|
+
} else {
|
|
1162
|
+
_this14._watch.push(key);
|
|
1163
|
+
}
|
|
1164
|
+
});
|
|
1165
|
+
return this;
|
|
1166
|
+
}
|
|
1147
1167
|
}, {
|
|
1148
1168
|
key: "readPreference",
|
|
1149
1169
|
value: function (_readPreference, includeReadPreference, subqueryReadPreference) {
|
|
@@ -1204,7 +1224,7 @@ var ParseQuery = function () {
|
|
|
1204
1224
|
}, {
|
|
1205
1225
|
key: "cancel",
|
|
1206
1226
|
value: function () {
|
|
1207
|
-
var
|
|
1227
|
+
var _this15 = this;
|
|
1208
1228
|
if (this._xhrRequest.task && typeof this._xhrRequest.task.abort === 'function') {
|
|
1209
1229
|
this._xhrRequest.task._aborted = true;
|
|
1210
1230
|
this._xhrRequest.task.abort();
|
|
@@ -1213,16 +1233,16 @@ var ParseQuery = function () {
|
|
|
1213
1233
|
return this;
|
|
1214
1234
|
}
|
|
1215
1235
|
return this._xhrRequest.onchange = function () {
|
|
1216
|
-
return
|
|
1236
|
+
return _this15.cancel();
|
|
1217
1237
|
};
|
|
1218
1238
|
}
|
|
1219
1239
|
}, {
|
|
1220
1240
|
key: "_setRequestTask",
|
|
1221
1241
|
value: function (options) {
|
|
1222
|
-
var
|
|
1242
|
+
var _this16 = this;
|
|
1223
1243
|
options.requestTask = function (task) {
|
|
1224
|
-
|
|
1225
|
-
|
|
1244
|
+
_this16._xhrRequest.task = task;
|
|
1245
|
+
_this16._xhrRequest.onchange();
|
|
1226
1246
|
};
|
|
1227
1247
|
}
|
|
1228
1248
|
}], [{
|
|
@@ -1234,8 +1254,8 @@ var ParseQuery = function () {
|
|
|
1234
1254
|
}, {
|
|
1235
1255
|
key: "or",
|
|
1236
1256
|
value: function () {
|
|
1237
|
-
for (var
|
|
1238
|
-
queries[
|
|
1257
|
+
for (var _len9 = arguments.length, queries = new Array(_len9), _key13 = 0; _key13 < _len9; _key13++) {
|
|
1258
|
+
queries[_key13] = arguments[_key13];
|
|
1239
1259
|
}
|
|
1240
1260
|
var className = _getClassNameFromQueries(queries);
|
|
1241
1261
|
var query = new ParseQuery(className);
|
|
@@ -1245,8 +1265,8 @@ var ParseQuery = function () {
|
|
|
1245
1265
|
}, {
|
|
1246
1266
|
key: "and",
|
|
1247
1267
|
value: function () {
|
|
1248
|
-
for (var
|
|
1249
|
-
queries[
|
|
1268
|
+
for (var _len10 = arguments.length, queries = new Array(_len10), _key14 = 0; _key14 < _len10; _key14++) {
|
|
1269
|
+
queries[_key14] = arguments[_key14];
|
|
1250
1270
|
}
|
|
1251
1271
|
var className = _getClassNameFromQueries(queries);
|
|
1252
1272
|
var query = new ParseQuery(className);
|
|
@@ -1256,8 +1276,8 @@ var ParseQuery = function () {
|
|
|
1256
1276
|
}, {
|
|
1257
1277
|
key: "nor",
|
|
1258
1278
|
value: function () {
|
|
1259
|
-
for (var
|
|
1260
|
-
queries[
|
|
1279
|
+
for (var _len11 = arguments.length, queries = new Array(_len11), _key15 = 0; _key15 < _len11; _key15++) {
|
|
1280
|
+
queries[_key15] = arguments[_key15];
|
|
1261
1281
|
}
|
|
1262
1282
|
var className = _getClassNameFromQueries(queries);
|
|
1263
1283
|
var query = new ParseQuery(className);
|
|
@@ -8,7 +8,7 @@ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/creat
|
|
|
8
8
|
var _CoreManager = _interopRequireDefault(require("./CoreManager"));
|
|
9
9
|
var _ParseObject = _interopRequireDefault(require("./ParseObject"));
|
|
10
10
|
var _ParseCLP = _interopRequireDefault(require("./ParseCLP"));
|
|
11
|
-
var FIELD_TYPES = ['String', 'Number', 'Boolean', 'Date', 'File', 'GeoPoint', 'Polygon', 'Array', 'Object', 'Pointer', 'Relation'];
|
|
11
|
+
var FIELD_TYPES = ['String', 'Number', 'Boolean', 'Bytes', 'Date', 'File', 'GeoPoint', 'Polygon', 'Array', 'Object', 'Pointer', 'Relation'];
|
|
12
12
|
var ParseSchema = function () {
|
|
13
13
|
function ParseSchema(className) {
|
|
14
14
|
(0, _classCallCheck2.default)(this, ParseSchema);
|
|
@@ -127,6 +127,14 @@ var ParseSchema = function () {
|
|
|
127
127
|
};
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
|
+
if (type === 'Bytes') {
|
|
131
|
+
if (options && options.defaultValue) {
|
|
132
|
+
fieldOptions.defaultValue = {
|
|
133
|
+
__type: 'Bytes',
|
|
134
|
+
base64: options.defaultValue
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
}
|
|
130
138
|
this._fields[name] = fieldOptions;
|
|
131
139
|
return this;
|
|
132
140
|
}
|
|
@@ -157,6 +165,11 @@ var ParseSchema = function () {
|
|
|
157
165
|
value: function (name, options) {
|
|
158
166
|
return this.addField(name, 'Boolean', options);
|
|
159
167
|
}
|
|
168
|
+
}, {
|
|
169
|
+
key: "addBytes",
|
|
170
|
+
value: function (name, options) {
|
|
171
|
+
return this.addField(name, 'Bytes', options);
|
|
172
|
+
}
|
|
160
173
|
}, {
|
|
161
174
|
key: "addDate",
|
|
162
175
|
value: function (name, options) {
|
|
@@ -103,8 +103,14 @@ var ParseUser = function (_ParseObject) {
|
|
|
103
103
|
throw new Error('Invalid type: authData field should be an object');
|
|
104
104
|
}
|
|
105
105
|
authData[authType] = options.authData;
|
|
106
|
+
var oldAnonymousData = authData.anonymous;
|
|
107
|
+
this.stripAnonymity();
|
|
106
108
|
var controller = _CoreManager.default.getUserController();
|
|
107
|
-
return controller.linkWith(this, authData, saveOpts)
|
|
109
|
+
return controller.linkWith(this, authData, saveOpts).catch(function (e) {
|
|
110
|
+
delete authData[authType];
|
|
111
|
+
_this2.restoreAnonimity(oldAnonymousData);
|
|
112
|
+
throw e;
|
|
113
|
+
});
|
|
108
114
|
} else {
|
|
109
115
|
return new Promise(function (resolve, reject) {
|
|
110
116
|
provider.authenticate({
|
|
@@ -254,6 +260,22 @@ var ParseUser = function (_ParseObject) {
|
|
|
254
260
|
}
|
|
255
261
|
return isCurrentAsync;
|
|
256
262
|
}()
|
|
263
|
+
}, {
|
|
264
|
+
key: "stripAnonymity",
|
|
265
|
+
value: function () {
|
|
266
|
+
var authData = this.get('authData');
|
|
267
|
+
if (authData && typeof authData === 'object' && authData.hasOwnProperty('anonymous')) {
|
|
268
|
+
authData.anonymous = null;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}, {
|
|
272
|
+
key: "restoreAnonimity",
|
|
273
|
+
value: function (anonymousData) {
|
|
274
|
+
if (anonymousData) {
|
|
275
|
+
var authData = this.get('authData');
|
|
276
|
+
authData.anonymous = anonymousData;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
257
279
|
}, {
|
|
258
280
|
key: "getUsername",
|
|
259
281
|
value: function () {
|
|
@@ -266,10 +288,7 @@ var ParseUser = function (_ParseObject) {
|
|
|
266
288
|
}, {
|
|
267
289
|
key: "setUsername",
|
|
268
290
|
value: function (username) {
|
|
269
|
-
|
|
270
|
-
if (authData && typeof authData === 'object' && authData.hasOwnProperty('anonymous')) {
|
|
271
|
-
authData.anonymous = null;
|
|
272
|
-
}
|
|
291
|
+
this.stripAnonymity();
|
|
273
292
|
this.set('username', username);
|
|
274
293
|
}
|
|
275
294
|
}, {
|
|
@@ -339,6 +358,9 @@ var ParseUser = function (_ParseObject) {
|
|
|
339
358
|
if (options.hasOwnProperty('usePost')) {
|
|
340
359
|
loginOptions.usePost = options.usePost;
|
|
341
360
|
}
|
|
361
|
+
if (options.hasOwnProperty('context') && Object.prototype.toString.call(options.context) === '[object Object]') {
|
|
362
|
+
loginOptions.context = options.context;
|
|
363
|
+
}
|
|
342
364
|
var controller = _CoreManager.default.getUserController();
|
|
343
365
|
return controller.logIn(this, loginOptions);
|
|
344
366
|
}
|
|
@@ -500,6 +522,36 @@ var ParseUser = function (_ParseObject) {
|
|
|
500
522
|
});
|
|
501
523
|
return user.logIn(options);
|
|
502
524
|
}
|
|
525
|
+
}, {
|
|
526
|
+
key: "logInWithAdditionalAuth",
|
|
527
|
+
value: function (username, password, authData, options) {
|
|
528
|
+
if (typeof username !== 'string') {
|
|
529
|
+
return Promise.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Username must be a string.'));
|
|
530
|
+
}
|
|
531
|
+
if (typeof password !== 'string') {
|
|
532
|
+
return Promise.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Password must be a string.'));
|
|
533
|
+
}
|
|
534
|
+
if (Object.prototype.toString.call(authData) !== '[object Object]') {
|
|
535
|
+
return Promise.reject(new _ParseError.default(_ParseError.default.OTHER_CAUSE, 'Auth must be an object.'));
|
|
536
|
+
}
|
|
537
|
+
var user = new this();
|
|
538
|
+
user._finishFetch({
|
|
539
|
+
username: username,
|
|
540
|
+
password: password,
|
|
541
|
+
authData: authData
|
|
542
|
+
});
|
|
543
|
+
return user.logIn(options);
|
|
544
|
+
}
|
|
545
|
+
}, {
|
|
546
|
+
key: "loginAs",
|
|
547
|
+
value: function (userId) {
|
|
548
|
+
if (!userId) {
|
|
549
|
+
throw new _ParseError.default(_ParseError.default.USERNAME_MISSING, 'Cannot log in as user with an empty user id');
|
|
550
|
+
}
|
|
551
|
+
var controller = _CoreManager.default.getUserController();
|
|
552
|
+
var user = new this();
|
|
553
|
+
return controller.loginAs(user, userId);
|
|
554
|
+
}
|
|
503
555
|
}, {
|
|
504
556
|
key: "become",
|
|
505
557
|
value: function (sessionToken, options) {
|
|
@@ -778,7 +830,8 @@ var DefaultController = {
|
|
|
778
830
|
var stateController = _CoreManager.default.getObjectStateController();
|
|
779
831
|
var auth = {
|
|
780
832
|
username: user.get('username'),
|
|
781
|
-
password: user.get('password')
|
|
833
|
+
password: user.get('password'),
|
|
834
|
+
authData: user.get('authData')
|
|
782
835
|
};
|
|
783
836
|
return RESTController.request(options.usePost ? 'POST' : 'GET', 'login', auth, options).then(function (response) {
|
|
784
837
|
user._migrateId(response.objectId);
|
|
@@ -793,6 +846,21 @@ var DefaultController = {
|
|
|
793
846
|
return DefaultController.setCurrentUser(user);
|
|
794
847
|
});
|
|
795
848
|
},
|
|
849
|
+
loginAs: function (user, userId) {
|
|
850
|
+
var RESTController = _CoreManager.default.getRESTController();
|
|
851
|
+
return RESTController.request('POST', 'loginAs', {
|
|
852
|
+
userId: userId
|
|
853
|
+
}, {
|
|
854
|
+
useMasterKey: true
|
|
855
|
+
}).then(function (response) {
|
|
856
|
+
user._finishFetch(response);
|
|
857
|
+
user._setExisted(true);
|
|
858
|
+
if (!canUseCurrentUser) {
|
|
859
|
+
return Promise.resolve(user);
|
|
860
|
+
}
|
|
861
|
+
return DefaultController.setCurrentUser(user);
|
|
862
|
+
});
|
|
863
|
+
},
|
|
796
864
|
become: function (user, options) {
|
|
797
865
|
var RESTController = _CoreManager.default.getRESTController();
|
|
798
866
|
return RESTController.request('GET', 'users/me', {}, options).then(function (response) {
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
exports.default = void 0;
|
|
2
6
|
var _CoreManager = _interopRequireDefault(require("./CoreManager"));
|
|
3
7
|
var Storage = {
|
|
4
8
|
async: function () {
|
|
@@ -81,4 +85,6 @@ var Storage = {
|
|
|
81
85
|
}
|
|
82
86
|
};
|
|
83
87
|
module.exports = Storage;
|
|
88
|
+
var _default = Storage;
|
|
89
|
+
exports.default = _default;
|
|
84
90
|
_CoreManager.default.setStorageController(require('./StorageController.react-native'));
|
package/lib/weapp/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
|
}
|
package/lib/weapp/CoreManager.js
CHANGED
|
@@ -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;
|