parse 8.0.4-alpha.1 → 8.1.0-alpha.1
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 +44 -12
- package/dist/parse.min.js +1 -1
- package/dist/parse.weapp.js +44 -12
- package/dist/parse.weapp.min.js +1 -1
- package/lib/browser/CoreManager.js +1 -1
- package/lib/browser/LiveQueryClient.js +38 -18
- package/lib/browser/LiveQuerySubscription.js +20 -1
- package/lib/node/CoreManager.js +1 -1
- package/lib/node/LiveQueryClient.js +29 -11
- package/lib/node/LiveQuerySubscription.js +18 -1
- package/lib/react-native/CoreManager.js +1 -1
- package/lib/react-native/LiveQueryClient.js +20 -4
- package/lib/react-native/LiveQuerySubscription.js +15 -1
- package/lib/weapp/CoreManager.js +1 -1
- package/lib/weapp/LiveQueryClient.js +38 -18
- package/lib/weapp/LiveQuerySubscription.js +20 -1
- package/package.json +9 -9
- package/types/LiveQueryClient.d.ts +15 -13
- package/types/LiveQuerySubscription.d.ts +7 -1
package/dist/parse.js
CHANGED
|
@@ -191,7 +191,7 @@
|
|
|
191
191
|
SERVER_URL: "https://api.parse.com/1",
|
|
192
192
|
LIVEQUERY_SERVER_URL: null,
|
|
193
193
|
ENCRYPTED_KEY: null,
|
|
194
|
-
VERSION: "js8.0
|
|
194
|
+
VERSION: "js8.1.0-alpha.1",
|
|
195
195
|
APPLICATION_ID: null,
|
|
196
196
|
JAVASCRIPT_KEY: null,
|
|
197
197
|
MAINTENANCE_KEY: null,
|
|
@@ -58363,11 +58363,13 @@ Attributes: ${JSON.stringify(this.attributes, null, 2)}`;
|
|
|
58363
58363
|
* @param {string | number} id - subscription id
|
|
58364
58364
|
* @param {string} query - query to subscribe to
|
|
58365
58365
|
* @param {string} sessionToken - optional session token
|
|
58366
|
+
* @param {object} client - LiveQueryClient instance
|
|
58366
58367
|
*/
|
|
58367
|
-
constructor(id, query, sessionToken) {
|
|
58368
|
+
constructor(id, query, sessionToken, client) {
|
|
58368
58369
|
this.id = id;
|
|
58369
58370
|
this.query = query;
|
|
58370
58371
|
this.sessionToken = sessionToken;
|
|
58372
|
+
this.client = client;
|
|
58371
58373
|
this.subscribePromise = resolvingPromise();
|
|
58372
58374
|
this.unsubscribePromise = resolvingPromise();
|
|
58373
58375
|
this.subscribed = false;
|
|
@@ -58389,6 +58391,20 @@ Attributes: ${JSON.stringify(this.attributes, null, 2)}`;
|
|
|
58389
58391
|
return liveQueryClient.unsubscribe(this);
|
|
58390
58392
|
});
|
|
58391
58393
|
}
|
|
58394
|
+
/**
|
|
58395
|
+
* Execute a query on this subscription.
|
|
58396
|
+
* The results will be delivered via the 'result' event.
|
|
58397
|
+
*/
|
|
58398
|
+
find() {
|
|
58399
|
+
if (this.client) {
|
|
58400
|
+
this.client.connectPromise.then(() => {
|
|
58401
|
+
this.client.socket.send(JSON.stringify({
|
|
58402
|
+
op: "query",
|
|
58403
|
+
requestId: this.id
|
|
58404
|
+
}));
|
|
58405
|
+
});
|
|
58406
|
+
}
|
|
58407
|
+
}
|
|
58392
58408
|
}
|
|
58393
58409
|
const CLIENT_STATE = {
|
|
58394
58410
|
INITIALIZED: "initialized",
|
|
@@ -58407,7 +58423,8 @@ Attributes: ${JSON.stringify(this.attributes, null, 2)}`;
|
|
|
58407
58423
|
CONNECTED: "connected",
|
|
58408
58424
|
SUBSCRIBED: "subscribed",
|
|
58409
58425
|
UNSUBSCRIBED: "unsubscribed",
|
|
58410
|
-
ERROR: "error"
|
|
58426
|
+
ERROR: "error",
|
|
58427
|
+
RESULT: "result"
|
|
58411
58428
|
};
|
|
58412
58429
|
const CLIENT_EMMITER_TYPES = {
|
|
58413
58430
|
CLOSE: "close",
|
|
@@ -58417,20 +58434,23 @@ Attributes: ${JSON.stringify(this.attributes, null, 2)}`;
|
|
|
58417
58434
|
const SUBSCRIPTION_EMMITER_TYPES = {
|
|
58418
58435
|
OPEN: "open",
|
|
58419
58436
|
CLOSE: "close",
|
|
58420
|
-
ERROR: "error"
|
|
58437
|
+
ERROR: "error",
|
|
58438
|
+
RESULT: "result"
|
|
58421
58439
|
};
|
|
58422
58440
|
const generateInterval = (k) => {
|
|
58423
58441
|
return Math.random() * Math.min(30, Math.pow(2, k) - 1) * 1e3;
|
|
58424
58442
|
};
|
|
58425
58443
|
class LiveQueryClient {
|
|
58426
58444
|
/**
|
|
58427
|
-
*
|
|
58428
|
-
*
|
|
58429
|
-
* @param
|
|
58430
|
-
* @param
|
|
58431
|
-
* @param
|
|
58432
|
-
* @param
|
|
58433
|
-
* @param
|
|
58445
|
+
* Creates a new LiveQueryClient instance.
|
|
58446
|
+
*
|
|
58447
|
+
* @param options - Configuration options for the LiveQuery client
|
|
58448
|
+
* @param options.applicationId - The applicationId of your Parse app
|
|
58449
|
+
* @param options.serverURL - The URL of your LiveQuery server (must start with 'ws' or 'wss')
|
|
58450
|
+
* @param options.javascriptKey - (Optional) The JavaScript key for your Parse app
|
|
58451
|
+
* @param options.masterKey - (Optional) Your Parse Master Key (Node.js only!)
|
|
58452
|
+
* @param options.sessionToken - (Optional) Session token for authenticated requests
|
|
58453
|
+
* @param options.installationId - (Optional) Installation ID for the client
|
|
58434
58454
|
*/
|
|
58435
58455
|
constructor({
|
|
58436
58456
|
applicationId,
|
|
@@ -58506,7 +58526,7 @@ Attributes: ${JSON.stringify(this.attributes, null, 2)}`;
|
|
|
58506
58526
|
if (sessionToken) {
|
|
58507
58527
|
subscribeRequest.sessionToken = sessionToken;
|
|
58508
58528
|
}
|
|
58509
|
-
const subscription = new LiveQuerySubscription(this.requestId, query, sessionToken);
|
|
58529
|
+
const subscription = new LiveQuerySubscription(this.requestId, query, sessionToken, this);
|
|
58510
58530
|
this.subscriptions.set(this.requestId, subscription);
|
|
58511
58531
|
this.requestId += 1;
|
|
58512
58532
|
this.connectPromise.then(() => {
|
|
@@ -58697,6 +58717,18 @@ Attributes: ${JSON.stringify(this.attributes, null, 2)}`;
|
|
|
58697
58717
|
}
|
|
58698
58718
|
break;
|
|
58699
58719
|
}
|
|
58720
|
+
case OP_EVENTS.RESULT: {
|
|
58721
|
+
if (subscription) {
|
|
58722
|
+
const objects = data.results.map((json) => {
|
|
58723
|
+
if (!json.className && subscription.query) {
|
|
58724
|
+
json.className = subscription.query.className;
|
|
58725
|
+
}
|
|
58726
|
+
return ParseObject.fromJSON(json, false);
|
|
58727
|
+
});
|
|
58728
|
+
subscription.emit(SUBSCRIPTION_EMMITER_TYPES.RESULT, objects);
|
|
58729
|
+
}
|
|
58730
|
+
break;
|
|
58731
|
+
}
|
|
58700
58732
|
default: {
|
|
58701
58733
|
if (!subscription) {
|
|
58702
58734
|
break;
|