parse 8.6.0 → 8.6.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 +1103 -30
- package/dist/parse.min.js +47 -20
- package/dist/parse.weapp.js +1103 -30
- package/dist/parse.weapp.min.js +47 -20
- package/lib/browser/Cloud.js +1 -2
- package/lib/browser/CoreManager.js +2 -4
- package/lib/browser/EventuallyQueue.js +3 -4
- package/lib/browser/InstallationController.js +1 -2
- package/lib/browser/LiveQueryClient.js +16 -27
- package/lib/browser/LiveQuerySubscription.js +1 -7
- package/lib/browser/LocalDatastore.js +4 -6
- package/lib/browser/ObjectStateMutations.js +3 -31
- package/lib/browser/OfflineQuery.js +15 -19
- package/lib/browser/Parse.js +4 -39
- package/lib/browser/ParseCLP.js +20 -48
- package/lib/browser/ParseFile.js +23 -54
- package/lib/browser/ParseInstallation.js +2 -8
- package/lib/browser/ParseLiveQuery.js +1 -7
- package/lib/browser/ParseObject.js +13 -43
- package/lib/browser/ParseQuery.js +37 -78
- package/lib/browser/ParseSchema.js +6 -7
- package/lib/browser/ParseUser.js +18 -62
- package/lib/browser/Push.js +3 -6
- package/lib/browser/RESTController.js +7 -35
- package/lib/node/CoreManager.js +1 -1
- package/lib/react-native/CoreManager.js +1 -1
- package/lib/weapp/Cloud.js +1 -2
- package/lib/weapp/CoreManager.js +2 -4
- package/lib/weapp/EventuallyQueue.js +3 -4
- package/lib/weapp/InstallationController.js +1 -2
- package/lib/weapp/LiveQueryClient.js +16 -27
- package/lib/weapp/LiveQuerySubscription.js +1 -7
- package/lib/weapp/LocalDatastore.js +4 -6
- package/lib/weapp/ObjectStateMutations.js +3 -31
- package/lib/weapp/OfflineQuery.js +15 -19
- package/lib/weapp/Parse.js +4 -39
- package/lib/weapp/ParseCLP.js +20 -48
- package/lib/weapp/ParseFile.js +23 -54
- package/lib/weapp/ParseInstallation.js +2 -8
- package/lib/weapp/ParseLiveQuery.js +1 -7
- package/lib/weapp/ParseObject.js +13 -43
- package/lib/weapp/ParseQuery.js +37 -78
- package/lib/weapp/ParseSchema.js +6 -7
- package/lib/weapp/ParseUser.js +18 -62
- package/lib/weapp/Push.js +3 -6
- package/lib/weapp/RESTController.js +7 -35
- package/package.json +15 -16
package/dist/parse.weapp.min.js
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
(function(t) {
|
|
2
2
|
"function" == typeof define && define.amd ? define([], t) : t();
|
|
3
3
|
})((function() {
|
|
4
|
-
var __create = Object.create, __defProp = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __getOwnPropNames = Object.getOwnPropertyNames, __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty, __esmMin = (t, e
|
|
4
|
+
var __create = Object.create, __defProp = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __getOwnPropNames = Object.getOwnPropertyNames, __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty, __esmMin = (t, e, r) => () => {
|
|
5
|
+
if (r) throw r[0];
|
|
6
|
+
try {
|
|
7
|
+
return t && (e = t(t = 0)), e;
|
|
8
|
+
} catch (t) {
|
|
9
|
+
throw r = [t], t;
|
|
10
|
+
}
|
|
11
|
+
}, __commonJSMin = (t, e) => () => (e || (t((e = { exports: {} }).exports, e), t = null), e.exports), __exportAll = (t, e) => {
|
|
5
12
|
let r = {};
|
|
6
13
|
for (var i in t) __defProp(r, i, {
|
|
7
14
|
get: t[i],
|
|
@@ -110,7 +117,7 @@
|
|
|
110
117
|
SERVER_URL: "https://api.parse.com/1",
|
|
111
118
|
LIVEQUERY_SERVER_URL: null,
|
|
112
119
|
ENCRYPTED_KEY: null,
|
|
113
|
-
VERSION: "js8.6.
|
|
120
|
+
VERSION: "js8.6.1",
|
|
114
121
|
APPLICATION_ID: null,
|
|
115
122
|
JAVASCRIPT_KEY: null,
|
|
116
123
|
MAINTENANCE_KEY: null,
|
|
@@ -3506,7 +3513,9 @@
|
|
|
3506
3513
|
var h, u = require_destroy$1(), f = require_state().getHighWaterMark, l = require_errors_browser().codes, c = l.ERR_INVALID_ARG_TYPE, d = l.ERR_METHOD_NOT_IMPLEMENTED, p = l.ERR_MULTIPLE_CALLBACK, m = l.ERR_STREAM_CANNOT_PIPE, g = l.ERR_STREAM_DESTROYED, y = l.ERR_STREAM_NULL_VALUES, b = l.ERR_STREAM_WRITE_AFTER_END, v = l.ERR_UNKNOWN_ENCODING, _ = u.errorOrDestroy;
|
|
3507
3514
|
function w() {}
|
|
3508
3515
|
function M(t, e, n) {
|
|
3509
|
-
i = i || require__stream_duplex$1(), t = t || {}, "boolean" != typeof n && (n = e instanceof i), this.objectMode = !!t.objectMode, n && (this.objectMode = this.objectMode || !!t.writableObjectMode), this.highWaterMark = f(this, t, "writableHighWaterMark", n), this.finalCalled = !1, this.needDrain = !1, this.ending = !1, this.ended = !1, this.finished = !1, this.destroyed = !1
|
|
3516
|
+
i = i || require__stream_duplex$1(), t = t || {}, "boolean" != typeof n && (n = e instanceof i), this.objectMode = !!t.objectMode, n && (this.objectMode = this.objectMode || !!t.writableObjectMode), this.highWaterMark = f(this, t, "writableHighWaterMark", n), this.finalCalled = !1, this.needDrain = !1, this.ending = !1, this.ended = !1, this.finished = !1, this.destroyed = !1;
|
|
3517
|
+
var o = !1 === t.decodeStrings;
|
|
3518
|
+
this.decodeStrings = !o, this.defaultEncoding = t.defaultEncoding || "utf8", this.length = 0, this.writing = !1, this.corked = 0, this.sync = !0, this.bufferProcessing = !1, this.onwrite = function(t) {
|
|
3510
3519
|
(function(t, e) {
|
|
3511
3520
|
var r = t._writableState, i = r.sync, n = r.writecb;
|
|
3512
3521
|
if ("function" != typeof n) throw new p();
|
|
@@ -4699,7 +4708,9 @@
|
|
|
4699
4708
|
if (t = t || {}, this._data) return this._data;
|
|
4700
4709
|
if ("buffer" === this._source?.format) return this._data = this._source.buffer.toString("base64"), this._data;
|
|
4701
4710
|
if (!this._url) throw new Error("Cannot retrieve data for unsaved ParseFile.");
|
|
4702
|
-
|
|
4711
|
+
t.requestTask = (t) => this._requestTask = t;
|
|
4712
|
+
const e = await CoreManager.getFileController().download(this._url, t);
|
|
4713
|
+
return this._data = e.base64, this._data;
|
|
4703
4714
|
}
|
|
4704
4715
|
name() {
|
|
4705
4716
|
return this._name;
|
|
@@ -8066,7 +8077,8 @@
|
|
|
8066
8077
|
return new e(t);
|
|
8067
8078
|
}, e;
|
|
8068
8079
|
}, i._cbcInit = function() {
|
|
8069
|
-
|
|
8080
|
+
var t = new n(this.options.iv);
|
|
8081
|
+
this._cbcState = t;
|
|
8070
8082
|
}, i._update = function(t, e, r, i) {
|
|
8071
8083
|
var n = this._cbcState, o = this.constructor.super_.prototype, s = n.iv;
|
|
8072
8084
|
if ("encrypt" === this.type) {
|
|
@@ -8113,7 +8125,9 @@
|
|
|
8113
8125
|
];
|
|
8114
8126
|
}
|
|
8115
8127
|
function a(t) {
|
|
8116
|
-
n.call(this, t)
|
|
8128
|
+
n.call(this, t);
|
|
8129
|
+
var e = new s(this.type, this.options.key);
|
|
8130
|
+
this._edeState = e;
|
|
8117
8131
|
}
|
|
8118
8132
|
i(a, n), e.exports = a, a.create = function(t) {
|
|
8119
8133
|
return new a(t);
|
|
@@ -11239,7 +11253,9 @@
|
|
|
11239
11253
|
var s = e instanceof n;
|
|
11240
11254
|
this.objectMode = !!t.objectMode, s && (this.objectMode = this.objectMode || !!t.writableObjectMode);
|
|
11241
11255
|
var a = t.highWaterMark, h = t.writableHighWaterMark, u = this.objectMode ? 16 : 16384;
|
|
11242
|
-
this.highWaterMark = a || 0 === a ? a : s && (h || 0 === h) ? h : u, this.highWaterMark = Math.floor(this.highWaterMark), this.finalCalled = !1, this.needDrain = !1, this.ending = !1, this.ended = !1, this.finished = !1, this.destroyed = !1
|
|
11256
|
+
this.highWaterMark = a || 0 === a ? a : s && (h || 0 === h) ? h : u, this.highWaterMark = Math.floor(this.highWaterMark), this.finalCalled = !1, this.needDrain = !1, this.ending = !1, this.ended = !1, this.finished = !1, this.destroyed = !1;
|
|
11257
|
+
var f = !1 === t.decodeStrings;
|
|
11258
|
+
this.decodeStrings = !f, this.defaultEncoding = t.defaultEncoding || "utf8", this.length = 0, this.writing = !1, this.corked = 0, this.sync = !0, this.bufferProcessing = !1, this.onwrite = function(t) {
|
|
11243
11259
|
(function(t, e) {
|
|
11244
11260
|
var i = t._writableState, n = i.sync, s = i.writecb;
|
|
11245
11261
|
if (function(t) {
|
|
@@ -20540,7 +20556,7 @@
|
|
|
20540
20556
|
var r = function() {
|
|
20541
20557
|
if (e) {
|
|
20542
20558
|
if ("function" == typeof e.getRandomValues) try {
|
|
20543
|
-
return e.getRandomValues(new Uint32Array(1))[0];
|
|
20559
|
+
return e.getRandomValues(/* @__PURE__ */ new Uint32Array(1))[0];
|
|
20544
20560
|
} catch (t) {}
|
|
20545
20561
|
if ("function" == typeof e.randomBytes) try {
|
|
20546
20562
|
return e.randomBytes(4).readInt32LE();
|
|
@@ -22795,7 +22811,11 @@
|
|
|
22795
22811
|
if ("function" != typeof t) throw new TypeError("A ParseQuery must be constructed with a ParseObject or class name.");
|
|
22796
22812
|
{
|
|
22797
22813
|
const e = t;
|
|
22798
|
-
"string" == typeof e.className
|
|
22814
|
+
if ("string" == typeof e.className) this.className = e.className;
|
|
22815
|
+
else {
|
|
22816
|
+
const t = new e();
|
|
22817
|
+
this.className = t.className;
|
|
22818
|
+
}
|
|
22799
22819
|
}
|
|
22800
22820
|
}
|
|
22801
22821
|
this._where = {}, this._watch = [], this._include = [], this._exclude = [], this._count = !1, this._limit = -1, this._skip = 0, this._readPreference = null, this._includeReadPreference = null, this._subqueryReadPreference = null, this._queriesLocalDatastore = !1, this._localDatastorePinName = null, this._extraOptions = {}, this._xhrRequest = {
|
|
@@ -23187,16 +23207,16 @@
|
|
|
23187
23207
|
return i.subscribePromise.then((() => i));
|
|
23188
23208
|
}
|
|
23189
23209
|
static or(...e) {
|
|
23190
|
-
const r = new t(
|
|
23191
|
-
return
|
|
23210
|
+
const r = _getClassNameFromQueries(e), i = new t(r);
|
|
23211
|
+
return i._orQuery(e), i;
|
|
23192
23212
|
}
|
|
23193
23213
|
static and(...e) {
|
|
23194
|
-
const r = new t(
|
|
23195
|
-
return
|
|
23214
|
+
const r = _getClassNameFromQueries(e), i = new t(r);
|
|
23215
|
+
return i._andQuery(e), i;
|
|
23196
23216
|
}
|
|
23197
23217
|
static nor(...e) {
|
|
23198
|
-
const r = new t(
|
|
23199
|
-
return
|
|
23218
|
+
const r = _getClassNameFromQueries(e), i = new t(r);
|
|
23219
|
+
return i._norQuery(e), i;
|
|
23200
23220
|
}
|
|
23201
23221
|
fromNetwork() {
|
|
23202
23222
|
return this._queriesLocalDatastore = !1, this._localDatastorePinName = null, this;
|
|
@@ -23399,7 +23419,9 @@
|
|
|
23399
23419
|
const i = indexedDB.open(t);
|
|
23400
23420
|
return i.onupgradeneeded = () => i.result.createObjectStore(e), r = promisifyRequest(i), r.then(((t) => {
|
|
23401
23421
|
t.onclose = () => r = void 0;
|
|
23402
|
-
}), (() => {
|
|
23422
|
+
}), (() => {
|
|
23423
|
+
r = void 0;
|
|
23424
|
+
})), r;
|
|
23403
23425
|
})().then(((t) => n(t.transaction(e, i).objectStore(e))));
|
|
23404
23426
|
}
|
|
23405
23427
|
function defaultGetStore() {
|
|
@@ -24623,7 +24645,7 @@
|
|
|
24623
24645
|
t._localId && (o._localId = t._localId), e[r] = o;
|
|
24624
24646
|
for (const t in e) n.push(t), i.push(this.pinWithName(t, [e[t]]));
|
|
24625
24647
|
}
|
|
24626
|
-
const o = this.fromPinWithName(r), [s] = await Promise.all([o, i]), a = [
|
|
24648
|
+
const o = this.fromPinWithName(r), [s] = await Promise.all([o, i]), a = [.../* @__PURE__ */ new Set([...s || [], ...n])];
|
|
24627
24649
|
return this.pinWithName(r, a);
|
|
24628
24650
|
},
|
|
24629
24651
|
async _handleUnPinAllWithName(t, e) {
|
|
@@ -24958,7 +24980,9 @@
|
|
|
24958
24980
|
} });
|
|
24959
24981
|
var LiveQuerySubscription = class {
|
|
24960
24982
|
constructor(t, e, r, i) {
|
|
24961
|
-
this.id = t, this.query = e, this.sessionToken = r, this.client = i, this.subscribePromise = resolvingPromise(), this.unsubscribePromise = resolvingPromise(), this.subscribed = !1
|
|
24983
|
+
this.id = t, this.query = e, this.sessionToken = r, this.client = i, this.subscribePromise = resolvingPromise(), this.unsubscribePromise = resolvingPromise(), this.subscribed = !1;
|
|
24984
|
+
const n = CoreManager.getEventEmitter();
|
|
24985
|
+
this.emitter = new n(), this.on = (t, e) => this.emitter.on(t, e), this.emit = (t, ...e) => this.emitter.emit(t, ...e), this.on("error", (() => {}));
|
|
24962
24986
|
}
|
|
24963
24987
|
unsubscribe() {
|
|
24964
24988
|
return CoreManager.getLiveQueryController().getDefaultLiveQueryClient().then(((t) => (this.emit("close"), t.unsubscribe(this))));
|
|
@@ -25012,7 +25036,9 @@
|
|
|
25012
25036
|
}, generateInterval = (t) => Math.random() * Math.min(30, Math.pow(2, t) - 1) * 1e3, LiveQueryClient = class {
|
|
25013
25037
|
constructor({ applicationId: t, serverURL: e, javascriptKey: r, masterKey: i, sessionToken: n, installationId: o }) {
|
|
25014
25038
|
if (!e || 0 !== e.indexOf("ws")) throw new Error("You need to set a proper Parse LiveQuery server url before using LiveQueryClient");
|
|
25015
|
-
this.reconnectHandle = null, this.attempts = 1, this.id = 0, this.requestId = 1, this.serverURL = e, this.applicationId = t, this.javascriptKey = r || void 0, this.masterKey = i || void 0, this.sessionToken = n || void 0, this.installationId = o || void 0, this.additionalProperties = !0, this.connectPromise = resolvingPromise(), this.subscriptions = /* @__PURE__ */ new Map(), this.state = CLIENT_STATE.INITIALIZED
|
|
25039
|
+
this.reconnectHandle = null, this.attempts = 1, this.id = 0, this.requestId = 1, this.serverURL = e, this.applicationId = t, this.javascriptKey = r || void 0, this.masterKey = i || void 0, this.sessionToken = n || void 0, this.installationId = o || void 0, this.additionalProperties = !0, this.connectPromise = resolvingPromise(), this.subscriptions = /* @__PURE__ */ new Map(), this.state = CLIENT_STATE.INITIALIZED;
|
|
25040
|
+
const s = CoreManager.getEventEmitter();
|
|
25041
|
+
this.emitter = new s(), this.on = (t, e) => this.emitter.on(t, e), this.emit = (t, ...e) => this.emitter.emit(t, ...e), this.on("error", (() => {}));
|
|
25016
25042
|
}
|
|
25017
25043
|
shouldOpen() {
|
|
25018
25044
|
return this.state === CLIENT_STATE.INITIALIZED || this.state === CLIENT_STATE.DISCONNECTED;
|
|
@@ -25169,7 +25195,8 @@
|
|
|
25169
25195
|
}
|
|
25170
25196
|
var LiveQuery = class {
|
|
25171
25197
|
constructor() {
|
|
25172
|
-
|
|
25198
|
+
const t = CoreManager.getEventEmitter();
|
|
25199
|
+
this.emitter = new t(), this.on = (t, e) => this.emitter.on(t, e), this.emit = (t, ...e) => this.emitter.emit(t, ...e), this.on("error", (() => {}));
|
|
25173
25200
|
}
|
|
25174
25201
|
async open() {
|
|
25175
25202
|
(await getLiveQueryClient()).open();
|
package/lib/browser/Cloud.js
CHANGED
|
@@ -125,12 +125,11 @@ const DefaultController = {
|
|
|
125
125
|
return RESTController.request('GET', 'cloud_code/jobs/data', null, options);
|
|
126
126
|
},
|
|
127
127
|
async startJob(name, data, options) {
|
|
128
|
-
var _response$_headers;
|
|
129
128
|
const RESTController = _CoreManager.default.getRESTController();
|
|
130
129
|
const payload = (0, _encode.default)(data, true);
|
|
131
130
|
options.returnStatus = true;
|
|
132
131
|
const response = await RESTController.request('POST', 'jobs/' + name, payload, options);
|
|
133
|
-
return
|
|
132
|
+
return response._headers?.['X-Parse-Job-Status-Id'];
|
|
134
133
|
}
|
|
135
134
|
};
|
|
136
135
|
_CoreManager.default.setCloudController(DefaultController);
|
|
@@ -7,7 +7,6 @@ _Object$defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports.default = void 0;
|
|
9
9
|
var _forEach = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
|
|
10
|
-
var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
|
|
11
10
|
/** Based on https://github.com/react-native-async-storage/async-storage/blob/main/packages/default-storage-backend/src/types.ts */
|
|
12
11
|
|
|
13
12
|
const config = {
|
|
@@ -18,7 +17,7 @@ const config = {
|
|
|
18
17
|
SERVER_URL: 'https://api.parse.com/1',
|
|
19
18
|
LIVEQUERY_SERVER_URL: null,
|
|
20
19
|
ENCRYPTED_KEY: null,
|
|
21
|
-
VERSION: 'js' + "8.6.
|
|
20
|
+
VERSION: 'js' + "8.6.1",
|
|
22
21
|
APPLICATION_ID: null,
|
|
23
22
|
JAVASCRIPT_KEY: null,
|
|
24
23
|
MAINTENANCE_KEY: null,
|
|
@@ -35,8 +34,7 @@ const config = {
|
|
|
35
34
|
function requireMethods(name, methods, controller) {
|
|
36
35
|
(0, _forEach.default)(methods).call(methods, func => {
|
|
37
36
|
if (typeof controller[func] !== 'function') {
|
|
38
|
-
|
|
39
|
-
throw new Error((0, _concat.default)(_context = "".concat(name, " must implement ")).call(_context, func, "()"));
|
|
37
|
+
throw new Error(`${name} must implement ${func}()`);
|
|
40
38
|
}
|
|
41
39
|
});
|
|
42
40
|
}
|
|
@@ -284,10 +284,9 @@ const EventuallyQueue = {
|
|
|
284
284
|
}
|
|
285
285
|
polling = (0, _setInterval2.default)(() => {
|
|
286
286
|
const RESTController = _CoreManager.default.getRESTController();
|
|
287
|
-
RESTController.request('GET', 'health').then(
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
} = _ref;
|
|
287
|
+
RESTController.request('GET', 'health').then(({
|
|
288
|
+
status
|
|
289
|
+
}) => {
|
|
291
290
|
if (status === 'ok') {
|
|
292
291
|
this.stopPoll();
|
|
293
292
|
return this.sendQueue();
|
|
@@ -72,8 +72,7 @@ const InstallationController = {
|
|
|
72
72
|
_setInstallationIdCache(iid) {
|
|
73
73
|
iidCache = iid;
|
|
74
74
|
},
|
|
75
|
-
_setCurrentInstallationCache(installation) {
|
|
76
|
-
let matchesDisk = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
75
|
+
_setCurrentInstallationCache(installation, matchesDisk = true) {
|
|
77
76
|
currentInstallationCache = installation;
|
|
78
77
|
currentInstallationCacheMatchesDisk = matchesDisk;
|
|
79
78
|
}
|
|
@@ -133,16 +133,14 @@ class LiveQueryClient {
|
|
|
133
133
|
* @param options.sessionToken - (Optional) Session token for authenticated requests
|
|
134
134
|
* @param options.installationId - (Optional) Installation ID for the client
|
|
135
135
|
*/
|
|
136
|
-
constructor(
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
installationId
|
|
145
|
-
} = _ref;
|
|
136
|
+
constructor({
|
|
137
|
+
applicationId,
|
|
138
|
+
serverURL,
|
|
139
|
+
javascriptKey,
|
|
140
|
+
masterKey,
|
|
141
|
+
sessionToken,
|
|
142
|
+
installationId
|
|
143
|
+
}) {
|
|
146
144
|
(0, _defineProperty2.default)(this, "attempts", void 0);
|
|
147
145
|
(0, _defineProperty2.default)(this, "id", void 0);
|
|
148
146
|
(0, _defineProperty2.default)(this, "requestId", void 0);
|
|
@@ -181,12 +179,7 @@ class LiveQueryClient {
|
|
|
181
179
|
const EventEmitter = _CoreManager.default.getEventEmitter();
|
|
182
180
|
this.emitter = new EventEmitter();
|
|
183
181
|
this.on = (eventName, listener) => this.emitter.on(eventName, listener);
|
|
184
|
-
this.emit =
|
|
185
|
-
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
186
|
-
args[_key - 1] = arguments[_key];
|
|
187
|
-
}
|
|
188
|
-
return _this.emitter.emit(eventName, ...args);
|
|
189
|
-
};
|
|
182
|
+
this.emit = (eventName, ...args) => this.emitter.emit(eventName, ...args);
|
|
190
183
|
// adding listener so process does not crash
|
|
191
184
|
// best practice is for developer to register their own listener
|
|
192
185
|
this.on('error', () => {});
|
|
@@ -210,15 +203,14 @@ class LiveQueryClient {
|
|
|
210
203
|
* @returns {LiveQuerySubscription | undefined}
|
|
211
204
|
*/
|
|
212
205
|
subscribe(query, sessionToken) {
|
|
213
|
-
var _queryJSON$keys, _queryJSON$watch;
|
|
214
206
|
if (!query) {
|
|
215
207
|
return;
|
|
216
208
|
}
|
|
217
209
|
const className = query.className;
|
|
218
210
|
const queryJSON = query.toJSON();
|
|
219
211
|
const where = queryJSON.where;
|
|
220
|
-
const keys = (
|
|
221
|
-
const watch =
|
|
212
|
+
const keys = (0, _keys.default)(queryJSON)?.split(',');
|
|
213
|
+
const watch = queryJSON.watch?.split(',');
|
|
222
214
|
const subscribeRequest = {
|
|
223
215
|
op: OP_TYPES.SUBSCRIBE,
|
|
224
216
|
requestId: this.requestId,
|
|
@@ -290,8 +282,7 @@ class LiveQueryClient {
|
|
|
290
282
|
this._handleWebSocketMessage(event);
|
|
291
283
|
};
|
|
292
284
|
this.socket.onclose = event => {
|
|
293
|
-
|
|
294
|
-
(_this$socket$closingP = this.socket.closingPromise) === null || _this$socket$closingP === void 0 || _this$socket$closingP.resolve(event);
|
|
285
|
+
this.socket.closingPromise?.resolve(event);
|
|
295
286
|
this._handleWebSocketClose();
|
|
296
287
|
};
|
|
297
288
|
this.socket.onerror = error => {
|
|
@@ -301,12 +292,11 @@ class LiveQueryClient {
|
|
|
301
292
|
resubscribe() {
|
|
302
293
|
var _context;
|
|
303
294
|
(0, _forEach.default)(_context = this.subscriptions).call(_context, (subscription, requestId) => {
|
|
304
|
-
var _queryJSON$keys2, _queryJSON$watch2;
|
|
305
295
|
const query = subscription.query;
|
|
306
296
|
const queryJSON = query.toJSON();
|
|
307
297
|
const where = queryJSON.where;
|
|
308
|
-
const keys = (
|
|
309
|
-
const watch =
|
|
298
|
+
const keys = (0, _keys.default)(queryJSON)?.split(',');
|
|
299
|
+
const watch = queryJSON.watch?.split(',');
|
|
310
300
|
const className = query.className;
|
|
311
301
|
const sessionToken = subscription.sessionToken;
|
|
312
302
|
const subscribeRequest = {
|
|
@@ -336,12 +326,11 @@ class LiveQueryClient {
|
|
|
336
326
|
* @returns {Promise | undefined} CloseEvent {@link https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/close_event}
|
|
337
327
|
*/
|
|
338
328
|
async close() {
|
|
339
|
-
var _this$socket, _this$socket2;
|
|
340
329
|
if (this.state === CLIENT_STATE.INITIALIZED || this.state === CLIENT_STATE.DISCONNECTED) {
|
|
341
330
|
return;
|
|
342
331
|
}
|
|
343
332
|
this.state = CLIENT_STATE.DISCONNECTED;
|
|
344
|
-
|
|
333
|
+
this.socket?.close();
|
|
345
334
|
// Notify each subscription about the close
|
|
346
335
|
for (const subscription of (0, _values.default)(_context2 = this.subscriptions).call(_context2)) {
|
|
347
336
|
var _context2;
|
|
@@ -350,7 +339,7 @@ class LiveQueryClient {
|
|
|
350
339
|
}
|
|
351
340
|
this._handleReset();
|
|
352
341
|
this.emit(CLIENT_EMMITER_TYPES.CLOSE);
|
|
353
|
-
return
|
|
342
|
+
return this.socket?.closingPromise;
|
|
354
343
|
}
|
|
355
344
|
|
|
356
345
|
// ensure we start with valid state if connect is called again after close
|
|
@@ -100,7 +100,6 @@ class LiveQuerySubscription {
|
|
|
100
100
|
* @param {object} client - LiveQueryClient instance
|
|
101
101
|
*/
|
|
102
102
|
constructor(id, query, sessionToken, client) {
|
|
103
|
-
var _this = this;
|
|
104
103
|
(0, _defineProperty2.default)(this, "id", void 0);
|
|
105
104
|
(0, _defineProperty2.default)(this, "query", void 0);
|
|
106
105
|
(0, _defineProperty2.default)(this, "sessionToken", void 0);
|
|
@@ -121,12 +120,7 @@ class LiveQuerySubscription {
|
|
|
121
120
|
const Emitter = _CoreManager.default.getEventEmitter();
|
|
122
121
|
this.emitter = new Emitter();
|
|
123
122
|
this.on = (eventName, listener) => this.emitter.on(eventName, listener);
|
|
124
|
-
this.emit =
|
|
125
|
-
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
126
|
-
args[_key - 1] = arguments[_key];
|
|
127
|
-
}
|
|
128
|
-
return _this.emitter.emit(eventName, ...args);
|
|
129
|
-
};
|
|
123
|
+
this.emit = (eventName, ...args) => this.emitter.emit(eventName, ...args);
|
|
130
124
|
// adding listener so process does not crash
|
|
131
125
|
// best practice is for developer to register their own listener
|
|
132
126
|
this.on('error', () => {});
|
|
@@ -269,11 +269,10 @@ const LocalDatastore = {
|
|
|
269
269
|
},
|
|
270
270
|
// Update pin and references of the unsaved object
|
|
271
271
|
async _updateLocalIdForObject(localId, object) {
|
|
272
|
-
var _context2, _context3;
|
|
273
272
|
if (!this.isEnabled) {
|
|
274
273
|
return;
|
|
275
274
|
}
|
|
276
|
-
const localKey =
|
|
275
|
+
const localKey = `${_LocalDatastoreUtils.OBJECT_PREFIX}${object.className}_${localId}`;
|
|
277
276
|
const objectKey = this.getKeyForObject(object);
|
|
278
277
|
const unsaved = await this.fromPinWithName(localKey);
|
|
279
278
|
if (!unsaved || unsaved.length === 0) {
|
|
@@ -306,7 +305,7 @@ const LocalDatastore = {
|
|
|
306
305
|
* @static
|
|
307
306
|
*/
|
|
308
307
|
async updateFromServer() {
|
|
309
|
-
var
|
|
308
|
+
var _context2;
|
|
310
309
|
if (!this.checkIfEnabled() || this.isSyncing) {
|
|
311
310
|
return;
|
|
312
311
|
}
|
|
@@ -339,7 +338,7 @@ const LocalDatastore = {
|
|
|
339
338
|
}
|
|
340
339
|
pointersHash[className].add(objectId);
|
|
341
340
|
}
|
|
342
|
-
const queryPromises = (0, _map.default)(
|
|
341
|
+
const queryPromises = (0, _map.default)(_context2 = (0, _keys.default)(pointersHash)).call(_context2, className => {
|
|
343
342
|
const objectIds = (0, _from.default)(pointersHash[className]);
|
|
344
343
|
const query = new _ParseQuery.default(className);
|
|
345
344
|
query.limit(objectIds.length);
|
|
@@ -365,9 +364,8 @@ const LocalDatastore = {
|
|
|
365
364
|
}
|
|
366
365
|
},
|
|
367
366
|
getKeyForObject(object) {
|
|
368
|
-
var _context5, _context6;
|
|
369
367
|
const objectId = object.objectId || object._getId();
|
|
370
|
-
return
|
|
368
|
+
return `${_LocalDatastoreUtils.OBJECT_PREFIX}${object.className}_${objectId}`;
|
|
371
369
|
},
|
|
372
370
|
getPinName(pinName) {
|
|
373
371
|
if (!pinName || pinName === _LocalDatastoreUtils.DEFAULT_PIN) {
|
|
@@ -1,12 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _Object$keys = require("@babel/runtime-corejs3/core-js-stable/object/keys");
|
|
4
|
-
var _Object$getOwnPropertySymbols = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols");
|
|
5
|
-
var _filterInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/filter");
|
|
6
|
-
var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
|
|
7
|
-
var _forEachInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/for-each");
|
|
8
|
-
var _Object$getOwnPropertyDescriptors = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors");
|
|
9
|
-
var _Object$defineProperties = require("@babel/runtime-corejs3/core-js-stable/object/define-properties");
|
|
10
3
|
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
|
11
4
|
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
12
5
|
_Object$defineProperty(exports, "__esModule", {
|
|
@@ -21,7 +14,6 @@ exports.popPendingState = popPendingState;
|
|
|
21
14
|
exports.pushPendingState = pushPendingState;
|
|
22
15
|
exports.setPendingOp = setPendingOp;
|
|
23
16
|
exports.setServerData = setServerData;
|
|
24
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
|
|
25
17
|
var _create = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/create"));
|
|
26
18
|
var _includes = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/includes"));
|
|
27
19
|
var _isArray = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/array/is-array"));
|
|
@@ -33,28 +25,6 @@ var _ParseRelation = _interopRequireDefault(require("./ParseRelation"));
|
|
|
33
25
|
var _TaskQueue = _interopRequireDefault(require("./TaskQueue"));
|
|
34
26
|
var _ParseOp = require("./ParseOp");
|
|
35
27
|
var _isDangerousKey = require("./isDangerousKey");
|
|
36
|
-
function ownKeys(e, r) {
|
|
37
|
-
var t = _Object$keys(e);
|
|
38
|
-
if (_Object$getOwnPropertySymbols) {
|
|
39
|
-
var o = _Object$getOwnPropertySymbols(e);
|
|
40
|
-
r && (o = _filterInstanceProperty(o).call(o, function (r) {
|
|
41
|
-
return _Object$getOwnPropertyDescriptor(e, r).enumerable;
|
|
42
|
-
})), t.push.apply(t, o);
|
|
43
|
-
}
|
|
44
|
-
return t;
|
|
45
|
-
}
|
|
46
|
-
function _objectSpread(e) {
|
|
47
|
-
for (var r = 1; r < arguments.length; r++) {
|
|
48
|
-
var _context, _context2;
|
|
49
|
-
var t = null != arguments[r] ? arguments[r] : {};
|
|
50
|
-
r % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(t), !0)).call(_context, function (r) {
|
|
51
|
-
(0, _defineProperty2.default)(e, r, t[r]);
|
|
52
|
-
}) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys(Object(t))).call(_context2, function (r) {
|
|
53
|
-
_Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r));
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
return e;
|
|
57
|
-
}
|
|
58
28
|
function defaultState() {
|
|
59
29
|
return {
|
|
60
30
|
serverData: (0, _create.default)(null),
|
|
@@ -182,7 +152,9 @@ function estimateAttributes(serverData, pendingOps, object) {
|
|
|
182
152
|
if ((0, _isArray.default)(object[key])) {
|
|
183
153
|
object[key] = [...object[key]];
|
|
184
154
|
} else {
|
|
185
|
-
object[key] =
|
|
155
|
+
object[key] = {
|
|
156
|
+
...object[key]
|
|
157
|
+
};
|
|
186
158
|
}
|
|
187
159
|
}
|
|
188
160
|
object = object[key];
|
|
@@ -11,7 +11,6 @@ var _indexOf = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-st
|
|
|
11
11
|
var _filter = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/filter"));
|
|
12
12
|
var _slice = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/slice"));
|
|
13
13
|
var _isInteger = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/number/is-integer"));
|
|
14
|
-
var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
|
|
15
14
|
var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
|
|
16
15
|
var _forEach = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
|
|
17
16
|
var _keys = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/keys"));
|
|
@@ -119,8 +118,7 @@ function equalObjectsGeneric(obj, compareTo, eqlFn) {
|
|
|
119
118
|
* @param {Date} [now] The date from which add or subtract. Default is now.
|
|
120
119
|
* @returns {RelativeTimeToDateResult}
|
|
121
120
|
*/
|
|
122
|
-
function relativeTimeToDate(text) {
|
|
123
|
-
let now = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new Date();
|
|
121
|
+
function relativeTimeToDate(text, now = new Date()) {
|
|
124
122
|
text = text.toLowerCase();
|
|
125
123
|
let parts = text.split(' ');
|
|
126
124
|
|
|
@@ -164,7 +162,7 @@ function relativeTimeToDate(text) {
|
|
|
164
162
|
if (!(0, _isInteger.default)(val)) {
|
|
165
163
|
return {
|
|
166
164
|
status: 'error',
|
|
167
|
-
info:
|
|
165
|
+
info: `'${num}' is not an integer.`
|
|
168
166
|
};
|
|
169
167
|
}
|
|
170
168
|
switch (interval) {
|
|
@@ -206,7 +204,7 @@ function relativeTimeToDate(text) {
|
|
|
206
204
|
default:
|
|
207
205
|
return {
|
|
208
206
|
status: 'error',
|
|
209
|
-
info:
|
|
207
|
+
info: `Invalid interval: '${interval}'`
|
|
210
208
|
};
|
|
211
209
|
}
|
|
212
210
|
}
|
|
@@ -284,7 +282,7 @@ function matchesKeyConstraints(className, object, objects, key, constraints) {
|
|
|
284
282
|
return false;
|
|
285
283
|
}
|
|
286
284
|
if (!/^[A-Za-z][0-9A-Za-z_]*$/.test(key)) {
|
|
287
|
-
throw new _ParseError.default(_ParseError.default.INVALID_KEY_NAME,
|
|
285
|
+
throw new _ParseError.default(_ParseError.default.INVALID_KEY_NAME, `Invalid Key: ${key}`);
|
|
288
286
|
}
|
|
289
287
|
// Equality (or Array contains) cases
|
|
290
288
|
if (typeof constraints !== 'object') {
|
|
@@ -305,17 +303,15 @@ function matchesKeyConstraints(className, object, objects, key, constraints) {
|
|
|
305
303
|
}
|
|
306
304
|
// More complex cases
|
|
307
305
|
for (const condition in constraints) {
|
|
308
|
-
var _compareTo, _compareTo2;
|
|
309
306
|
compareTo = constraints[condition];
|
|
310
|
-
if (
|
|
307
|
+
if (compareTo?.__type) {
|
|
311
308
|
compareTo = (0, _decode.default)(compareTo);
|
|
312
309
|
}
|
|
313
310
|
// is it a $relativeTime? convert to date
|
|
314
|
-
if (
|
|
311
|
+
if (compareTo?.['$relativeTime']) {
|
|
315
312
|
const parserResult = relativeTimeToDate(compareTo['$relativeTime']);
|
|
316
313
|
if (parserResult.status !== 'success') {
|
|
317
|
-
|
|
318
|
-
throw new _ParseError.default(_ParseError.default.INVALID_JSON, (0, _concat.default)(_context2 = "bad $relativeTime (".concat(key, ") value. ")).call(_context2, parserResult.info));
|
|
314
|
+
throw new _ParseError.default(_ParseError.default.INVALID_JSON, `bad $relativeTime (${key}) value. ${parserResult.info}`);
|
|
319
315
|
}
|
|
320
316
|
compareTo = parserResult.result;
|
|
321
317
|
}
|
|
@@ -361,8 +357,8 @@ function matchesKeyConstraints(className, object, objects, key, constraints) {
|
|
|
361
357
|
break;
|
|
362
358
|
case '$all':
|
|
363
359
|
for (i = 0; i < compareTo.length; i++) {
|
|
364
|
-
var
|
|
365
|
-
if ((0, _indexOf.default)(
|
|
360
|
+
var _context2;
|
|
361
|
+
if ((0, _indexOf.default)(_context2 = object[key]).call(_context2, compareTo[i]) < 0) {
|
|
366
362
|
return false;
|
|
367
363
|
}
|
|
368
364
|
}
|
|
@@ -499,8 +495,8 @@ function matchesKeyConstraints(className, object, objects, key, constraints) {
|
|
|
499
495
|
case '$geoWithin':
|
|
500
496
|
{
|
|
501
497
|
if (compareTo.$polygon) {
|
|
502
|
-
var
|
|
503
|
-
const points = (0, _map.default)(
|
|
498
|
+
var _context3;
|
|
499
|
+
const points = (0, _map.default)(_context3 = compareTo.$polygon).call(_context3, geoPoint => [geoPoint.latitude, geoPoint.longitude]);
|
|
504
500
|
const polygon = new _ParsePolygon.default(points);
|
|
505
501
|
return polygon.containsPoint(object[key]);
|
|
506
502
|
}
|
|
@@ -529,22 +525,22 @@ function matchesKeyConstraints(className, object, objects, key, constraints) {
|
|
|
529
525
|
return true;
|
|
530
526
|
}
|
|
531
527
|
function validateQuery(query) {
|
|
532
|
-
var
|
|
528
|
+
var _context4;
|
|
533
529
|
let q = query;
|
|
534
530
|
if (query.toJSON) {
|
|
535
531
|
q = query.toJSON().where;
|
|
536
532
|
}
|
|
537
533
|
const specialQuerykeys = ['$and', '$or', '$nor', '_rperm', '_wperm', '_perishable_token', '_email_verify_token', '_email_verify_token_expires_at', '_account_lockout_expires_at', '_failed_login_count'];
|
|
538
|
-
(0, _forEach.default)(
|
|
534
|
+
(0, _forEach.default)(_context4 = (0, _keys.default)(q)).call(_context4, key => {
|
|
539
535
|
if (q && q[key] && q[key].$regex) {
|
|
540
536
|
if (typeof q[key].$options === 'string') {
|
|
541
537
|
if (!q[key].$options.match(/^[imxs]+$/)) {
|
|
542
|
-
throw new _ParseError.default(_ParseError.default.INVALID_QUERY,
|
|
538
|
+
throw new _ParseError.default(_ParseError.default.INVALID_QUERY, `Bad $options value for query: ${q[key].$options}`);
|
|
543
539
|
}
|
|
544
540
|
}
|
|
545
541
|
}
|
|
546
542
|
if ((0, _indexOf.default)(specialQuerykeys).call(specialQuerykeys, key) < 0 && !key.match(/^[a-zA-Z][a-zA-Z0-9_\.]*$/)) {
|
|
547
|
-
throw new _ParseError.default(_ParseError.default.INVALID_KEY_NAME,
|
|
543
|
+
throw new _ParseError.default(_ParseError.default.INVALID_KEY_NAME, `Invalid key name: ${key}`);
|
|
548
544
|
}
|
|
549
545
|
});
|
|
550
546
|
}
|