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/lib/weapp/ParseFile.js
CHANGED
|
@@ -1,12 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _Object$keys2 = 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 _forEachInstanceProperty2 = 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", {
|
|
@@ -23,28 +16,8 @@ var _stringify = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-
|
|
|
23
16
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
|
|
24
17
|
var _CoreManager = _interopRequireDefault(require("./CoreManager"));
|
|
25
18
|
var _ParseError = _interopRequireDefault(require("./ParseError"));
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
if (_Object$getOwnPropertySymbols) {
|
|
29
|
-
var o = _Object$getOwnPropertySymbols(e);
|
|
30
|
-
r && (o = _filterInstanceProperty(o).call(o, function (r) {
|
|
31
|
-
return _Object$getOwnPropertyDescriptor(e, r).enumerable;
|
|
32
|
-
})), t.push.apply(t, o);
|
|
33
|
-
}
|
|
34
|
-
return t;
|
|
35
|
-
}
|
|
36
|
-
function _objectSpread(e) {
|
|
37
|
-
for (var r = 1; r < arguments.length; r++) {
|
|
38
|
-
var _context6, _context7;
|
|
39
|
-
var t = null != arguments[r] ? arguments[r] : {};
|
|
40
|
-
r % 2 ? _forEachInstanceProperty2(_context6 = ownKeys(Object(t), !0)).call(_context6, function (r) {
|
|
41
|
-
(0, _defineProperty2.default)(e, r, t[r]);
|
|
42
|
-
}) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty2(_context7 = ownKeys(Object(t))).call(_context7, function (r) {
|
|
43
|
-
_Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r));
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
return e;
|
|
47
|
-
} /* global Blob */
|
|
19
|
+
/* global Blob */
|
|
20
|
+
|
|
48
21
|
let NodeReadable;
|
|
49
22
|
function b64Digit(number) {
|
|
50
23
|
if (number < 26) {
|
|
@@ -195,12 +168,11 @@ class ParseFile {
|
|
|
195
168
|
* @returns {Promise} Promise that is resolve with base64 data
|
|
196
169
|
*/
|
|
197
170
|
async getData(options) {
|
|
198
|
-
var _this$_source;
|
|
199
171
|
options = options || {};
|
|
200
172
|
if (this._data) {
|
|
201
173
|
return this._data;
|
|
202
174
|
}
|
|
203
|
-
if (
|
|
175
|
+
if (this._source?.format === 'buffer') {
|
|
204
176
|
this._data = this._source.buffer.toString('base64');
|
|
205
177
|
return this._data;
|
|
206
178
|
}
|
|
@@ -405,8 +377,7 @@ class ParseFile {
|
|
|
405
377
|
* <pre>
|
|
406
378
|
* @returns {Promise} Promise that is resolved when the delete finishes.
|
|
407
379
|
*/
|
|
408
|
-
destroy() {
|
|
409
|
-
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
380
|
+
destroy(options = {}) {
|
|
410
381
|
if (!this._name) {
|
|
411
382
|
throw new _ParseError.default(_ParseError.default.FILE_DELETE_UNNAMED_ERROR, 'Cannot delete an unnamed file.');
|
|
412
383
|
}
|
|
@@ -552,19 +523,23 @@ const DefaultController = {
|
|
|
552
523
|
};
|
|
553
524
|
return await DefaultController.saveBase64(name, newSource, options);
|
|
554
525
|
},
|
|
555
|
-
saveBase64: function (name, source) {
|
|
556
|
-
let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
526
|
+
saveBase64: function (name, source, options = {}) {
|
|
557
527
|
if (source.format !== 'base64') {
|
|
558
528
|
throw new Error('saveBase64 can only be used with Base64-type sources.');
|
|
559
529
|
}
|
|
560
530
|
const data = {
|
|
561
531
|
base64: source.base64,
|
|
562
|
-
fileData:
|
|
563
|
-
metadata:
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
532
|
+
fileData: {
|
|
533
|
+
metadata: {
|
|
534
|
+
...options.metadata
|
|
535
|
+
},
|
|
536
|
+
tags: {
|
|
537
|
+
...options.tags
|
|
538
|
+
},
|
|
539
|
+
...(options.directory ? {
|
|
540
|
+
directory: options.directory
|
|
541
|
+
} : {})
|
|
542
|
+
}
|
|
568
543
|
};
|
|
569
544
|
delete options.metadata;
|
|
570
545
|
delete options.tags;
|
|
@@ -574,8 +549,7 @@ const DefaultController = {
|
|
|
574
549
|
}
|
|
575
550
|
return _CoreManager.default.getRESTController().request('POST', 'files/' + name, data, options);
|
|
576
551
|
},
|
|
577
|
-
saveBinary: async function (name, source) {
|
|
578
|
-
let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
552
|
+
saveBinary: async function (name, source, options = {}) {
|
|
579
553
|
if (source.format !== 'buffer' && source.format !== 'stream') {
|
|
580
554
|
throw new Error('saveBinary can only be used with Buffer or Stream sources.');
|
|
581
555
|
}
|
|
@@ -642,12 +616,9 @@ const DefaultController = {
|
|
|
642
616
|
url += '/';
|
|
643
617
|
}
|
|
644
618
|
url += 'files/' + encodeURIComponent(name);
|
|
645
|
-
return _CoreManager.default.getRESTController().ajax('POST', url, body, headers, options).then(
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
} = _ref;
|
|
649
|
-
return response;
|
|
650
|
-
});
|
|
619
|
+
return _CoreManager.default.getRESTController().ajax('POST', url, body, headers, options).then(({
|
|
620
|
+
response
|
|
621
|
+
}) => response);
|
|
651
622
|
},
|
|
652
623
|
download: async function (uri, options) {
|
|
653
624
|
const controller = new AbortController();
|
|
@@ -663,8 +634,7 @@ const DefaultController = {
|
|
|
663
634
|
const length = +response.headers.get('Content-Length') || 0;
|
|
664
635
|
const contentType = response.headers.get('Content-Type');
|
|
665
636
|
if (length === 0) {
|
|
666
|
-
|
|
667
|
-
(_options$progress = options.progress) === null || _options$progress === void 0 || _options$progress.call(options, null, null, null);
|
|
637
|
+
options.progress?.(null, null, null);
|
|
668
638
|
return {
|
|
669
639
|
base64: '',
|
|
670
640
|
contentType
|
|
@@ -673,7 +643,6 @@ const DefaultController = {
|
|
|
673
643
|
let recieved = 0;
|
|
674
644
|
const chunks = [];
|
|
675
645
|
while (true) {
|
|
676
|
-
var _options$progress2;
|
|
677
646
|
const {
|
|
678
647
|
done,
|
|
679
648
|
value
|
|
@@ -682,8 +651,8 @@ const DefaultController = {
|
|
|
682
651
|
break;
|
|
683
652
|
}
|
|
684
653
|
chunks.push(value);
|
|
685
|
-
recieved +=
|
|
686
|
-
|
|
654
|
+
recieved += value?.length || 0;
|
|
655
|
+
options.progress?.(recieved / length, recieved, length);
|
|
687
656
|
}
|
|
688
657
|
const body = new Uint8Array(recieved);
|
|
689
658
|
let offset = 0;
|
|
@@ -217,10 +217,7 @@ class ParseInstallation extends _ParseObject.default {
|
|
|
217
217
|
* @param {...any} args
|
|
218
218
|
* @returns {Promise}
|
|
219
219
|
*/
|
|
220
|
-
async fetch() {
|
|
221
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
222
|
-
args[_key] = arguments[_key];
|
|
223
|
-
}
|
|
220
|
+
async fetch(...args) {
|
|
224
221
|
try {
|
|
225
222
|
await super.fetch.apply(this, args);
|
|
226
223
|
} catch (e) {
|
|
@@ -245,10 +242,7 @@ class ParseInstallation extends _ParseObject.default {
|
|
|
245
242
|
* @param {...any} args
|
|
246
243
|
* @returns {Promise}
|
|
247
244
|
*/
|
|
248
|
-
async save() {
|
|
249
|
-
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
250
|
-
args[_key2] = arguments[_key2];
|
|
251
|
-
}
|
|
245
|
+
async save(...args) {
|
|
252
246
|
try {
|
|
253
247
|
await super.save.apply(this, args);
|
|
254
248
|
} catch (e) {
|
|
@@ -44,19 +44,13 @@ function getLiveQueryClient() {
|
|
|
44
44
|
*/
|
|
45
45
|
class LiveQuery {
|
|
46
46
|
constructor() {
|
|
47
|
-
var _this = this;
|
|
48
47
|
(0, _defineProperty2.default)(this, "emitter", void 0);
|
|
49
48
|
(0, _defineProperty2.default)(this, "on", void 0);
|
|
50
49
|
(0, _defineProperty2.default)(this, "emit", void 0);
|
|
51
50
|
const Emitter = _CoreManager.default.getEventEmitter();
|
|
52
51
|
this.emitter = new Emitter();
|
|
53
52
|
this.on = (eventName, listener) => this.emitter.on(eventName, listener);
|
|
54
|
-
this.emit =
|
|
55
|
-
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
56
|
-
args[_key - 1] = arguments[_key];
|
|
57
|
-
}
|
|
58
|
-
return _this.emitter.emit(eventName, ...args);
|
|
59
|
-
};
|
|
53
|
+
this.emit = (eventName, ...args) => this.emitter.emit(eventName, ...args);
|
|
60
54
|
// adding listener so process does not crash
|
|
61
55
|
// best practice is for developer to register their own listener
|
|
62
56
|
this.on('error', () => {});
|
package/lib/weapp/ParseObject.js
CHANGED
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _Object$keys2 = 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 _forEachInstanceProperty2 = 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
|
-
var _Object$defineProperty2 = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
|
11
3
|
var _WeakMap = require("@babel/runtime-corejs3/core-js-stable/weak-map");
|
|
4
|
+
var _Object$defineProperty2 = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
|
5
|
+
var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
|
|
12
6
|
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
13
7
|
_Object$defineProperty2(exports, "__esModule", {
|
|
14
8
|
value: true
|
|
@@ -18,13 +12,13 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/he
|
|
|
18
12
|
var _create = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/create"));
|
|
19
13
|
var _indexOf = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
|
|
20
14
|
var _for = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/symbol/for"));
|
|
21
|
-
var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
|
|
22
15
|
var _stringify = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/json/stringify"));
|
|
23
16
|
var _freeze = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/freeze"));
|
|
24
17
|
var _keys = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/keys"));
|
|
25
18
|
var _forEach = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
|
|
26
19
|
var _includes = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/includes"));
|
|
27
20
|
var _getPrototypeOf = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/get-prototype-of"));
|
|
21
|
+
var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
|
|
28
22
|
var _some = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/some"));
|
|
29
23
|
var _promise = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/promise"));
|
|
30
24
|
var _isArray = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/array/is-array"));
|
|
@@ -69,28 +63,6 @@ function _interopRequireWildcard(e, t) {
|
|
|
69
63
|
return f;
|
|
70
64
|
})(e, t);
|
|
71
65
|
}
|
|
72
|
-
function ownKeys(e, r) {
|
|
73
|
-
var t = _Object$keys2(e);
|
|
74
|
-
if (_Object$getOwnPropertySymbols) {
|
|
75
|
-
var o = _Object$getOwnPropertySymbols(e);
|
|
76
|
-
r && (o = _filterInstanceProperty(o).call(o, function (r) {
|
|
77
|
-
return _Object$getOwnPropertyDescriptor(e, r).enumerable;
|
|
78
|
-
})), t.push.apply(t, o);
|
|
79
|
-
}
|
|
80
|
-
return t;
|
|
81
|
-
}
|
|
82
|
-
function _objectSpread(e) {
|
|
83
|
-
for (var r = 1; r < arguments.length; r++) {
|
|
84
|
-
var _context4, _context5;
|
|
85
|
-
var t = null != arguments[r] ? arguments[r] : {};
|
|
86
|
-
r % 2 ? _forEachInstanceProperty2(_context4 = ownKeys(Object(t), !0)).call(_context4, function (r) {
|
|
87
|
-
(0, _defineProperty2.default)(e, r, t[r]);
|
|
88
|
-
}) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty2(_context5 = ownKeys(Object(t))).call(_context5, function (r) {
|
|
89
|
-
_Object$defineProperty2(e, r, _Object$getOwnPropertyDescriptor(t, r));
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
return e;
|
|
93
|
-
}
|
|
94
66
|
/** Options for destroyAll batch operation */
|
|
95
67
|
|
|
96
68
|
/** Options for saveAll batch operation */
|
|
@@ -188,8 +160,7 @@ class ParseObject {
|
|
|
188
160
|
}
|
|
189
161
|
if (_CoreManager.default.get('NODE_LOGGING')) {
|
|
190
162
|
this[(0, _for.default)('nodejs.util.inspect.custom')] = function () {
|
|
191
|
-
|
|
192
|
-
return (0, _concat.default)(_context = (0, _concat.default)(_context2 = "ParseObject: className: ".concat(this.className, ", id: ")).call(_context2, this.id, "\nAttributes: ")).call(_context, (0, _stringify.default)(this.attributes, null, 2));
|
|
163
|
+
return `ParseObject: className: ${this.className}, id: ${this.id}\nAttributes: ${(0, _stringify.default)(this.attributes, null, 2)}`;
|
|
193
164
|
};
|
|
194
165
|
}
|
|
195
166
|
}
|
|
@@ -440,7 +411,10 @@ class ParseObject {
|
|
|
440
411
|
} else if (attr !== 'objectId') {
|
|
441
412
|
const val = (0, _decode.default)(response[attr]);
|
|
442
413
|
if (val && (0, _getPrototypeOf.default)(val) === Object.prototype) {
|
|
443
|
-
changes[attr] =
|
|
414
|
+
changes[attr] = {
|
|
415
|
+
...this.attributes[attr],
|
|
416
|
+
...val
|
|
417
|
+
};
|
|
444
418
|
} else {
|
|
445
419
|
changes[attr] = val;
|
|
446
420
|
}
|
|
@@ -465,8 +439,7 @@ class ParseObject {
|
|
|
465
439
|
static _getClassMap() {
|
|
466
440
|
return classMap;
|
|
467
441
|
}
|
|
468
|
-
static _getRequestOptions() {
|
|
469
|
-
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
442
|
+
static _getRequestOptions(options = {}) {
|
|
470
443
|
const requestOptions = {};
|
|
471
444
|
if (Object.prototype.toString.call(options) !== '[object Object]') {
|
|
472
445
|
throw new Error('request options must be of type Object');
|
|
@@ -1091,7 +1064,7 @@ class ParseObject {
|
|
|
1091
1064
|
}
|
|
1092
1065
|
for (const key in attrs) {
|
|
1093
1066
|
if (!/^[A-Za-z_][0-9A-Za-z_.]*$/.test(key)) {
|
|
1094
|
-
return new _ParseError.default(_ParseError.default.INVALID_KEY_NAME,
|
|
1067
|
+
return new _ParseError.default(_ParseError.default.INVALID_KEY_NAME, `Invalid key name: ${key}`);
|
|
1095
1068
|
}
|
|
1096
1069
|
}
|
|
1097
1070
|
return false;
|
|
@@ -1128,11 +1101,8 @@ class ParseObject {
|
|
|
1128
1101
|
*
|
|
1129
1102
|
* @param {string} [keys] - specify which fields to revert
|
|
1130
1103
|
*/
|
|
1131
|
-
revert() {
|
|
1104
|
+
revert(...keys) {
|
|
1132
1105
|
let keysToRevert;
|
|
1133
|
-
for (var _len = arguments.length, keys = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1134
|
-
keys[_key] = arguments[_key];
|
|
1135
|
-
}
|
|
1136
1106
|
if (keys.length) {
|
|
1137
1107
|
keysToRevert = [];
|
|
1138
1108
|
for (const key of keys) {
|
|
@@ -1662,8 +1632,8 @@ class ParseObject {
|
|
|
1662
1632
|
static handleIncludeOptions(options) {
|
|
1663
1633
|
let include = [];
|
|
1664
1634
|
if ((0, _isArray.default)(options.include)) {
|
|
1665
|
-
var
|
|
1666
|
-
(0, _forEach.default)(
|
|
1635
|
+
var _context;
|
|
1636
|
+
(0, _forEach.default)(_context = options.include).call(_context, key => {
|
|
1667
1637
|
if ((0, _isArray.default)(key)) {
|
|
1668
1638
|
include = (0, _concat.default)(include).call(include, key);
|
|
1669
1639
|
} else {
|
package/lib/weapp/ParseQuery.js
CHANGED
|
@@ -20,6 +20,7 @@ var _sort = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stabl
|
|
|
20
20
|
var _splice = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/splice"));
|
|
21
21
|
var _promise = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/promise"));
|
|
22
22
|
var _find = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/find"));
|
|
23
|
+
var _bind = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/bind"));
|
|
23
24
|
var _isArray = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/array/is-array"));
|
|
24
25
|
var _entries = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/entries"));
|
|
25
26
|
var _CoreManager = _interopRequireDefault(require("./CoreManager"));
|
|
@@ -146,7 +147,7 @@ function handleOfflineSort(a, b, sorts) {
|
|
|
146
147
|
order = 'updatedAt';
|
|
147
148
|
}
|
|
148
149
|
if (!/^[A-Za-z][0-9A-Za-z_]*$/.test(order) || order === 'password') {
|
|
149
|
-
throw new _ParseError.default(_ParseError.default.INVALID_KEY_NAME,
|
|
150
|
+
throw new _ParseError.default(_ParseError.default.INVALID_KEY_NAME, `Invalid Key: ${order}`);
|
|
150
151
|
}
|
|
151
152
|
const field1 = a.get(order);
|
|
152
153
|
const field2 = b.get(order);
|
|
@@ -600,12 +601,12 @@ class ParseQuery {
|
|
|
600
601
|
return this._handleOfflineQuery(this.toJSON());
|
|
601
602
|
}
|
|
602
603
|
return (0, _find.default)(controller).call(controller, this.className, this.toJSON(), findOptions).then(response => {
|
|
603
|
-
var
|
|
604
|
+
var _context4, _context5;
|
|
604
605
|
// Return generic object when explain is used
|
|
605
606
|
if (this._explain) {
|
|
606
607
|
return response.results;
|
|
607
608
|
}
|
|
608
|
-
const results = (
|
|
609
|
+
const results = ((_context4 = response.results) == null ? void 0 : (0, _bind.default)(_context5 = Function.call).call(_context5, (0, _map.default)(_context4), _context4))?.(data => {
|
|
609
610
|
// In cases of relations, the server may send back a className
|
|
610
611
|
// on the top level of the payload
|
|
611
612
|
const override = response.className || this.className;
|
|
@@ -752,10 +753,10 @@ class ParseQuery {
|
|
|
752
753
|
explain: this._explain,
|
|
753
754
|
readPreference: this._readPreference
|
|
754
755
|
};
|
|
755
|
-
if (
|
|
756
|
+
if (options?.rawValues !== undefined) {
|
|
756
757
|
params.rawValues = options.rawValues;
|
|
757
758
|
}
|
|
758
|
-
if (
|
|
759
|
+
if (options?.rawFieldNames !== undefined) {
|
|
759
760
|
params.rawFieldNames = options.rawFieldNames;
|
|
760
761
|
}
|
|
761
762
|
const aggregateOptions = _ParseObject.default._getRequestOptions(options);
|
|
@@ -785,8 +786,7 @@ class ParseQuery {
|
|
|
785
786
|
* @returns {Promise} A promise that is resolved with the object when
|
|
786
787
|
* the query completes.
|
|
787
788
|
*/
|
|
788
|
-
first() {
|
|
789
|
-
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
789
|
+
first(options = {}) {
|
|
790
790
|
const findOptions = _ParseObject.default._getRequestOptions(options);
|
|
791
791
|
this._setRequestTask(findOptions);
|
|
792
792
|
const controller = _CoreManager.default.getQueryController();
|
|
@@ -928,8 +928,7 @@ class ParseQuery {
|
|
|
928
928
|
* @param {boolean} explain Used to toggle the information on the query plan.
|
|
929
929
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
930
930
|
*/
|
|
931
|
-
explain() {
|
|
932
|
-
let explain = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
931
|
+
explain(explain = true) {
|
|
933
932
|
if (typeof explain !== 'boolean') {
|
|
934
933
|
throw new Error('You can only set explain to a boolean value');
|
|
935
934
|
}
|
|
@@ -1066,11 +1065,8 @@ class ParseQuery {
|
|
|
1066
1065
|
*/
|
|
1067
1066
|
equalTo(key, value) {
|
|
1068
1067
|
if (key && typeof key === 'object') {
|
|
1069
|
-
var
|
|
1070
|
-
(0, _forEach.default)(
|
|
1071
|
-
let [k, val] = _ref;
|
|
1072
|
-
return this.equalTo(k, val);
|
|
1073
|
-
});
|
|
1068
|
+
var _context6;
|
|
1069
|
+
(0, _forEach.default)(_context6 = (0, _entries.default)(key)).call(_context6, ([k, val]) => this.equalTo(k, val));
|
|
1074
1070
|
return this;
|
|
1075
1071
|
}
|
|
1076
1072
|
if (typeof value === 'undefined') {
|
|
@@ -1090,11 +1086,8 @@ class ParseQuery {
|
|
|
1090
1086
|
*/
|
|
1091
1087
|
notEqualTo(key, value) {
|
|
1092
1088
|
if (key && typeof key === 'object') {
|
|
1093
|
-
var
|
|
1094
|
-
(0, _forEach.default)(
|
|
1095
|
-
let [k, val] = _ref2;
|
|
1096
|
-
return this.notEqualTo(k, val);
|
|
1097
|
-
});
|
|
1089
|
+
var _context7;
|
|
1090
|
+
(0, _forEach.default)(_context7 = (0, _entries.default)(key)).call(_context7, ([k, val]) => this.notEqualTo(k, val));
|
|
1098
1091
|
return this;
|
|
1099
1092
|
}
|
|
1100
1093
|
return this._addCondition(key, '$ne', value);
|
|
@@ -1404,7 +1397,7 @@ class ParseQuery {
|
|
|
1404
1397
|
fullOptions.$diacriticSensitive = options[option];
|
|
1405
1398
|
break;
|
|
1406
1399
|
default:
|
|
1407
|
-
throw new Error(
|
|
1400
|
+
throw new Error(`Unknown option: ${option}`);
|
|
1408
1401
|
}
|
|
1409
1402
|
}
|
|
1410
1403
|
return this._addCondition(key, '$text', {
|
|
@@ -1594,11 +1587,8 @@ class ParseQuery {
|
|
|
1594
1587
|
* string of comma separated values, or an Array of keys, or multiple keys.
|
|
1595
1588
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1596
1589
|
*/
|
|
1597
|
-
ascending() {
|
|
1590
|
+
ascending(...keys) {
|
|
1598
1591
|
this._order = [];
|
|
1599
|
-
for (var _len = arguments.length, keys = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1600
|
-
keys[_key] = arguments[_key];
|
|
1601
|
-
}
|
|
1602
1592
|
return this.addAscending.apply(this, keys);
|
|
1603
1593
|
}
|
|
1604
1594
|
|
|
@@ -1610,19 +1600,16 @@ class ParseQuery {
|
|
|
1610
1600
|
* string of comma separated values, or an Array of keys, or multiple keys.
|
|
1611
1601
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1612
1602
|
*/
|
|
1613
|
-
addAscending() {
|
|
1603
|
+
addAscending(...keys) {
|
|
1614
1604
|
if (!this._order) {
|
|
1615
1605
|
this._order = [];
|
|
1616
1606
|
}
|
|
1617
|
-
for (var _len2 = arguments.length, keys = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
1618
|
-
keys[_key2] = arguments[_key2];
|
|
1619
|
-
}
|
|
1620
1607
|
(0, _forEach.default)(keys).call(keys, key => {
|
|
1621
|
-
var
|
|
1608
|
+
var _context8;
|
|
1622
1609
|
if ((0, _isArray.default)(key)) {
|
|
1623
1610
|
key = key.join();
|
|
1624
1611
|
}
|
|
1625
|
-
this._order = (0, _concat.default)(
|
|
1612
|
+
this._order = (0, _concat.default)(_context8 = this._order).call(_context8, key.replace(/\s/g, '').split(','));
|
|
1626
1613
|
});
|
|
1627
1614
|
return this;
|
|
1628
1615
|
}
|
|
@@ -1634,11 +1621,8 @@ class ParseQuery {
|
|
|
1634
1621
|
* string of comma separated values, or an Array of keys, or multiple keys.
|
|
1635
1622
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1636
1623
|
*/
|
|
1637
|
-
descending() {
|
|
1624
|
+
descending(...keys) {
|
|
1638
1625
|
this._order = [];
|
|
1639
|
-
for (var _len3 = arguments.length, keys = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
1640
|
-
keys[_key3] = arguments[_key3];
|
|
1641
|
-
}
|
|
1642
1626
|
return this.addDescending.apply(this, keys);
|
|
1643
1627
|
}
|
|
1644
1628
|
|
|
@@ -1650,19 +1634,16 @@ class ParseQuery {
|
|
|
1650
1634
|
* string of comma separated values, or an Array of keys, or multiple keys.
|
|
1651
1635
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1652
1636
|
*/
|
|
1653
|
-
addDescending() {
|
|
1637
|
+
addDescending(...keys) {
|
|
1654
1638
|
if (!this._order) {
|
|
1655
1639
|
this._order = [];
|
|
1656
1640
|
}
|
|
1657
|
-
for (var _len4 = arguments.length, keys = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
|
|
1658
|
-
keys[_key4] = arguments[_key4];
|
|
1659
|
-
}
|
|
1660
1641
|
(0, _forEach.default)(keys).call(keys, key => {
|
|
1661
|
-
var
|
|
1642
|
+
var _context9, _context0;
|
|
1662
1643
|
if ((0, _isArray.default)(key)) {
|
|
1663
1644
|
key = key.join();
|
|
1664
1645
|
}
|
|
1665
|
-
this._order = (0, _concat.default)(
|
|
1646
|
+
this._order = (0, _concat.default)(_context9 = this._order).call(_context9, (0, _map.default)(_context0 = key.replace(/\s/g, '').split(',')).call(_context0, k => {
|
|
1666
1647
|
return '-' + k;
|
|
1667
1648
|
}));
|
|
1668
1649
|
});
|
|
@@ -1710,8 +1691,7 @@ class ParseQuery {
|
|
|
1710
1691
|
* @param {boolean} includeCount false - disable, true - enable.
|
|
1711
1692
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1712
1693
|
*/
|
|
1713
|
-
withCount() {
|
|
1714
|
-
let includeCount = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
1694
|
+
withCount(includeCount = true) {
|
|
1715
1695
|
if (typeof includeCount !== 'boolean') {
|
|
1716
1696
|
throw new Error('You can only set withCount to a boolean value');
|
|
1717
1697
|
}
|
|
@@ -1729,14 +1709,11 @@ class ParseQuery {
|
|
|
1729
1709
|
* @param {...string|Array<string>} keys The name(s) of the key(s) to include.
|
|
1730
1710
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1731
1711
|
*/
|
|
1732
|
-
include() {
|
|
1733
|
-
for (var _len5 = arguments.length, keys = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
|
|
1734
|
-
keys[_key5] = arguments[_key5];
|
|
1735
|
-
}
|
|
1712
|
+
include(...keys) {
|
|
1736
1713
|
(0, _forEach.default)(keys).call(keys, key => {
|
|
1737
1714
|
if ((0, _isArray.default)(key)) {
|
|
1738
|
-
var
|
|
1739
|
-
this._include = (0, _concat.default)(
|
|
1715
|
+
var _context1;
|
|
1716
|
+
this._include = (0, _concat.default)(_context1 = this._include).call(_context1, key);
|
|
1740
1717
|
} else {
|
|
1741
1718
|
this._include.push(key);
|
|
1742
1719
|
}
|
|
@@ -1768,17 +1745,14 @@ class ParseQuery {
|
|
|
1768
1745
|
* @param {...string|Array<string>} keys The name(s) of the key(s) to include.
|
|
1769
1746
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1770
1747
|
*/
|
|
1771
|
-
select() {
|
|
1748
|
+
select(...keys) {
|
|
1772
1749
|
if (!this._select) {
|
|
1773
1750
|
this._select = [];
|
|
1774
1751
|
}
|
|
1775
|
-
for (var _len6 = arguments.length, keys = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
|
|
1776
|
-
keys[_key6] = arguments[_key6];
|
|
1777
|
-
}
|
|
1778
1752
|
(0, _forEach.default)(keys).call(keys, key => {
|
|
1779
1753
|
if ((0, _isArray.default)(key)) {
|
|
1780
|
-
var
|
|
1781
|
-
this._select = (0, _concat.default)(
|
|
1754
|
+
var _context10;
|
|
1755
|
+
this._select = (0, _concat.default)(_context10 = this._select).call(_context10, key);
|
|
1782
1756
|
} else {
|
|
1783
1757
|
this._select.push(key);
|
|
1784
1758
|
}
|
|
@@ -1795,14 +1769,11 @@ class ParseQuery {
|
|
|
1795
1769
|
* @param {...string|Array<string>} keys The name(s) of the key(s) to exclude.
|
|
1796
1770
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1797
1771
|
*/
|
|
1798
|
-
exclude() {
|
|
1799
|
-
for (var _len7 = arguments.length, keys = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
|
|
1800
|
-
keys[_key7] = arguments[_key7];
|
|
1801
|
-
}
|
|
1772
|
+
exclude(...keys) {
|
|
1802
1773
|
(0, _forEach.default)(keys).call(keys, key => {
|
|
1803
1774
|
if ((0, _isArray.default)(key)) {
|
|
1804
|
-
var
|
|
1805
|
-
this._exclude = (0, _concat.default)(
|
|
1775
|
+
var _context11;
|
|
1776
|
+
this._exclude = (0, _concat.default)(_context11 = this._exclude).call(_context11, key);
|
|
1806
1777
|
} else {
|
|
1807
1778
|
this._exclude.push(key);
|
|
1808
1779
|
}
|
|
@@ -1818,14 +1789,11 @@ class ParseQuery {
|
|
|
1818
1789
|
* @param {...string|Array<string>} keys The name(s) of the key(s) to watch.
|
|
1819
1790
|
* @returns {Parse.Query} Returns the query, so you can chain this call.
|
|
1820
1791
|
*/
|
|
1821
|
-
watch() {
|
|
1822
|
-
for (var _len8 = arguments.length, keys = new Array(_len8), _key8 = 0; _key8 < _len8; _key8++) {
|
|
1823
|
-
keys[_key8] = arguments[_key8];
|
|
1824
|
-
}
|
|
1792
|
+
watch(...keys) {
|
|
1825
1793
|
(0, _forEach.default)(keys).call(keys, key => {
|
|
1826
1794
|
if ((0, _isArray.default)(key)) {
|
|
1827
|
-
var
|
|
1828
|
-
this._watch = (0, _concat.default)(
|
|
1795
|
+
var _context12;
|
|
1796
|
+
this._watch = (0, _concat.default)(_context12 = this._watch).call(_context12, key);
|
|
1829
1797
|
} else {
|
|
1830
1798
|
this._watch.push(key);
|
|
1831
1799
|
}
|
|
@@ -1882,10 +1850,7 @@ class ParseQuery {
|
|
|
1882
1850
|
* @static
|
|
1883
1851
|
* @returns {Parse.Query} The query that is the OR of the passed in queries.
|
|
1884
1852
|
*/
|
|
1885
|
-
static or() {
|
|
1886
|
-
for (var _len9 = arguments.length, queries = new Array(_len9), _key9 = 0; _key9 < _len9; _key9++) {
|
|
1887
|
-
queries[_key9] = arguments[_key9];
|
|
1888
|
-
}
|
|
1853
|
+
static or(...queries) {
|
|
1889
1854
|
const className = _getClassNameFromQueries(queries);
|
|
1890
1855
|
const query = new ParseQuery(className);
|
|
1891
1856
|
query._orQuery(queries);
|
|
@@ -1904,10 +1869,7 @@ class ParseQuery {
|
|
|
1904
1869
|
* @static
|
|
1905
1870
|
* @returns {Parse.Query} The query that is the AND of the passed in queries.
|
|
1906
1871
|
*/
|
|
1907
|
-
static and() {
|
|
1908
|
-
for (var _len0 = arguments.length, queries = new Array(_len0), _key0 = 0; _key0 < _len0; _key0++) {
|
|
1909
|
-
queries[_key0] = arguments[_key0];
|
|
1910
|
-
}
|
|
1872
|
+
static and(...queries) {
|
|
1911
1873
|
const className = _getClassNameFromQueries(queries);
|
|
1912
1874
|
const query = new ParseQuery(className);
|
|
1913
1875
|
query._andQuery(queries);
|
|
@@ -1926,10 +1888,7 @@ class ParseQuery {
|
|
|
1926
1888
|
* @static
|
|
1927
1889
|
* @returns {Parse.Query} The query that is the NOR of the passed in queries.
|
|
1928
1890
|
*/
|
|
1929
|
-
static nor() {
|
|
1930
|
-
for (var _len1 = arguments.length, queries = new Array(_len1), _key1 = 0; _key1 < _len1; _key1++) {
|
|
1931
|
-
queries[_key1] = arguments[_key1];
|
|
1932
|
-
}
|
|
1891
|
+
static nor(...queries) {
|
|
1933
1892
|
const className = _getClassNameFromQueries(queries);
|
|
1934
1893
|
const query = new ParseQuery(className);
|
|
1935
1894
|
query._norQuery(queries);
|
package/lib/weapp/ParseSchema.js
CHANGED
|
@@ -194,7 +194,7 @@ class ParseSchema {
|
|
|
194
194
|
throw new Error('field name may not be null.');
|
|
195
195
|
}
|
|
196
196
|
if ((0, _indexOf.default)(FIELD_TYPES).call(FIELD_TYPES, type) === -1) {
|
|
197
|
-
throw new Error(
|
|
197
|
+
throw new Error(`${type} is not a valid type.`);
|
|
198
198
|
}
|
|
199
199
|
if (type === 'Pointer') {
|
|
200
200
|
return this.addPointer(name, options.targetClass, options);
|
|
@@ -382,10 +382,10 @@ class ParseSchema {
|
|
|
382
382
|
type: 'Pointer',
|
|
383
383
|
targetClass
|
|
384
384
|
};
|
|
385
|
-
if (typeof
|
|
385
|
+
if (typeof options?.required === 'boolean') {
|
|
386
386
|
fieldOptions.required = options.required;
|
|
387
387
|
}
|
|
388
|
-
if (
|
|
388
|
+
if (options?.defaultValue !== undefined) {
|
|
389
389
|
fieldOptions.defaultValue = options.defaultValue;
|
|
390
390
|
if (options.defaultValue instanceof _ParseObject.default) {
|
|
391
391
|
fieldOptions.defaultValue = options.defaultValue.toPointer();
|
|
@@ -443,10 +443,9 @@ class ParseSchema {
|
|
|
443
443
|
}
|
|
444
444
|
}
|
|
445
445
|
const DefaultController = {
|
|
446
|
-
send(className, method) {
|
|
447
|
-
let params = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
446
|
+
send(className, method, params = {}) {
|
|
448
447
|
const RESTController = _CoreManager.default.getRESTController();
|
|
449
|
-
return RESTController.request(method,
|
|
448
|
+
return RESTController.request(method, `schemas/${className}`, params, {
|
|
450
449
|
useMasterKey: true
|
|
451
450
|
});
|
|
452
451
|
},
|
|
@@ -464,7 +463,7 @@ const DefaultController = {
|
|
|
464
463
|
},
|
|
465
464
|
purge(className) {
|
|
466
465
|
const RESTController = _CoreManager.default.getRESTController();
|
|
467
|
-
return RESTController.request('DELETE',
|
|
466
|
+
return RESTController.request('DELETE', `purge/${className}`, {}, {
|
|
468
467
|
useMasterKey: true
|
|
469
468
|
});
|
|
470
469
|
}
|