parse 6.2.0-alpha.3 → 7.0.0
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 +7151 -8412
- package/dist/parse.min.js +1 -1
- package/dist/parse.weapp.js +7189 -8478
- package/dist/parse.weapp.min.js +1 -1
- package/lib/browser/CoreManager.js +3 -4
- package/lib/browser/ObjectStateMutations.js +51 -9
- package/lib/browser/Parse.js +40 -43
- package/lib/browser/ParseFile.js +70 -50
- package/lib/browser/ParseObject.js +31 -28
- package/lib/browser/ParseOp.js +2 -2
- package/lib/browser/ParseQuery.js +14 -14
- package/lib/browser/RESTController.js +153 -129
- package/lib/browser/SingleInstanceStateController.js +28 -27
- package/lib/browser/UniqueInstanceStateController.js +19 -23
- package/lib/browser/Xhr.weapp.js +62 -102
- package/lib/browser/decode.js +8 -1
- package/lib/browser/encode.js +9 -1
- package/lib/browser/isDangerousKey.js +29 -0
- package/lib/node/CoreManager.js +3 -4
- package/lib/node/ObjectStateMutations.js +50 -9
- package/lib/node/Parse.js +40 -44
- package/lib/node/ParseFile.js +71 -66
- package/lib/node/ParseObject.js +28 -27
- package/lib/node/RESTController.js +151 -128
- package/lib/node/SingleInstanceStateController.js +26 -28
- package/lib/node/UniqueInstanceStateController.js +19 -24
- package/lib/node/Xhr.weapp.js +58 -81
- package/lib/node/decode.js +8 -1
- package/lib/node/encode.js +9 -1
- package/lib/node/isDangerousKey.js +25 -0
- package/lib/react-native/CoreManager.js +3 -4
- package/lib/react-native/ObjectStateMutations.js +40 -9
- package/lib/react-native/Parse.js +25 -36
- package/lib/react-native/ParseFile.js +59 -47
- package/lib/react-native/ParseObject.js +28 -27
- package/lib/react-native/ParseQuery.js +25 -25
- package/lib/react-native/RESTController.js +185 -150
- package/lib/react-native/SingleInstanceStateController.js +23 -28
- package/lib/react-native/UniqueInstanceStateController.js +19 -24
- package/lib/react-native/Xhr.weapp.js +63 -95
- package/lib/react-native/decode.js +7 -1
- package/lib/react-native/encode.js +7 -1
- package/lib/react-native/isDangerousKey.js +17 -0
- package/lib/weapp/CoreManager.js +3 -4
- package/lib/weapp/ObjectStateMutations.js +51 -9
- package/lib/weapp/Parse.js +40 -43
- package/lib/weapp/ParseFile.js +70 -51
- package/lib/weapp/ParseObject.js +31 -28
- package/lib/weapp/ParseOp.js +2 -2
- package/lib/weapp/ParseQuery.js +14 -14
- package/lib/weapp/RESTController.js +154 -130
- package/lib/weapp/SingleInstanceStateController.js +28 -27
- package/lib/weapp/UniqueInstanceStateController.js +19 -23
- package/lib/weapp/Xhr.weapp.js +62 -102
- package/lib/weapp/decode.js +8 -1
- package/lib/weapp/encode.js +9 -1
- package/lib/weapp/isDangerousKey.js +29 -0
- package/package.json +28 -29
- package/types/Parse.d.ts +16 -10
- package/types/ParseFile.d.ts +18 -4
- package/types/ParseObject.d.ts +1 -1
- package/types/RESTController.d.ts +2 -7
- package/types/SingleInstanceStateController.d.ts +3 -3
- package/types/Xhr.weapp.d.ts +1 -29
- package/types/isDangerousKey.d.ts +7 -0
|
@@ -15,11 +15,9 @@ const config = {
|
|
|
15
15
|
REQUEST_BATCH_SIZE: 20,
|
|
16
16
|
REQUEST_HEADERS: {},
|
|
17
17
|
SERVER_URL: 'https://api.parse.com/1',
|
|
18
|
-
SERVER_AUTH_TYPE: null,
|
|
19
|
-
SERVER_AUTH_TOKEN: null,
|
|
20
18
|
LIVEQUERY_SERVER_URL: null,
|
|
21
19
|
ENCRYPTED_KEY: null,
|
|
22
|
-
VERSION: 'js' + "
|
|
20
|
+
VERSION: 'js' + "7.0.0",
|
|
23
21
|
APPLICATION_ID: null,
|
|
24
22
|
JAVASCRIPT_KEY: null,
|
|
25
23
|
MAINTENANCE_KEY: null,
|
|
@@ -30,7 +28,8 @@ const config = {
|
|
|
30
28
|
ENCRYPTED_USER: false,
|
|
31
29
|
IDEMPOTENCY: false,
|
|
32
30
|
ALLOW_CUSTOM_OBJECT_ID: false,
|
|
33
|
-
PARSE_ERRORS: []
|
|
31
|
+
PARSE_ERRORS: [],
|
|
32
|
+
NODE_LOGGING: false
|
|
34
33
|
};
|
|
35
34
|
function requireMethods(name, methods, controller) {
|
|
36
35
|
(0, _forEach.default)(methods).call(methods, func => {
|
|
@@ -14,6 +14,7 @@ exports.popPendingState = popPendingState;
|
|
|
14
14
|
exports.pushPendingState = pushPendingState;
|
|
15
15
|
exports.setPendingOp = setPendingOp;
|
|
16
16
|
exports.setServerData = setServerData;
|
|
17
|
+
var _create = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/create"));
|
|
17
18
|
var _includes = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/includes"));
|
|
18
19
|
var _isArray = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/array/is-array"));
|
|
19
20
|
var _stringify = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/json/stringify"));
|
|
@@ -23,18 +24,27 @@ var _ParseFile = _interopRequireDefault(require("./ParseFile"));
|
|
|
23
24
|
var _ParseRelation = _interopRequireDefault(require("./ParseRelation"));
|
|
24
25
|
var _TaskQueue = _interopRequireDefault(require("./TaskQueue"));
|
|
25
26
|
var _ParseOp = require("./ParseOp");
|
|
27
|
+
var _isDangerousKey = require("./isDangerousKey");
|
|
26
28
|
function defaultState() {
|
|
27
29
|
return {
|
|
28
|
-
serverData:
|
|
29
|
-
pendingOps: [
|
|
30
|
-
objectCache:
|
|
30
|
+
serverData: (0, _create.default)(null),
|
|
31
|
+
pendingOps: [(0, _create.default)(null)],
|
|
32
|
+
objectCache: (0, _create.default)(null),
|
|
31
33
|
tasks: new _TaskQueue.default(),
|
|
32
34
|
existed: false
|
|
33
35
|
};
|
|
34
36
|
}
|
|
35
37
|
function setServerData(serverData, attributes) {
|
|
36
38
|
for (const attr in attributes) {
|
|
37
|
-
|
|
39
|
+
// Skip properties from prototype chain
|
|
40
|
+
if (!Object.prototype.hasOwnProperty.call(attributes, attr)) {
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
// Skip dangerous keys that could pollute prototypes
|
|
44
|
+
if ((0, _isDangerousKey.isDangerousKey)(attr)) {
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
if (typeof attributes[attr] !== "undefined") {
|
|
38
48
|
serverData[attr] = attributes[attr];
|
|
39
49
|
} else {
|
|
40
50
|
delete serverData[attr];
|
|
@@ -42,6 +52,10 @@ function setServerData(serverData, attributes) {
|
|
|
42
52
|
}
|
|
43
53
|
}
|
|
44
54
|
function setPendingOp(pendingOps, attr, op) {
|
|
55
|
+
// Skip dangerous keys that could pollute prototypes
|
|
56
|
+
if ((0, _isDangerousKey.isDangerousKey)(attr)) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
45
59
|
const last = pendingOps.length - 1;
|
|
46
60
|
if (op) {
|
|
47
61
|
pendingOps[last][attr] = op;
|
|
@@ -50,12 +64,12 @@ function setPendingOp(pendingOps, attr, op) {
|
|
|
50
64
|
}
|
|
51
65
|
}
|
|
52
66
|
function pushPendingState(pendingOps) {
|
|
53
|
-
pendingOps.push(
|
|
67
|
+
pendingOps.push((0, _create.default)(null));
|
|
54
68
|
}
|
|
55
69
|
function popPendingState(pendingOps) {
|
|
56
70
|
const first = pendingOps.shift();
|
|
57
71
|
if (!pendingOps.length) {
|
|
58
|
-
pendingOps[0] =
|
|
72
|
+
pendingOps[0] = (0, _create.default)(null);
|
|
59
73
|
}
|
|
60
74
|
return first;
|
|
61
75
|
}
|
|
@@ -63,6 +77,14 @@ function mergeFirstPendingState(pendingOps) {
|
|
|
63
77
|
const first = popPendingState(pendingOps);
|
|
64
78
|
const next = pendingOps[0];
|
|
65
79
|
for (const attr in first) {
|
|
80
|
+
// Skip properties from prototype chain
|
|
81
|
+
if (!Object.prototype.hasOwnProperty.call(first, attr)) {
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
// Skip dangerous keys that could pollute prototypes
|
|
85
|
+
if ((0, _isDangerousKey.isDangerousKey)(attr)) {
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
66
88
|
if (next[attr] && first[attr]) {
|
|
67
89
|
const merged = next[attr].mergeWith(first[attr]);
|
|
68
90
|
if (merged) {
|
|
@@ -74,6 +96,10 @@ function mergeFirstPendingState(pendingOps) {
|
|
|
74
96
|
}
|
|
75
97
|
}
|
|
76
98
|
function estimateAttribute(serverData, pendingOps, object, attr) {
|
|
99
|
+
// Skip dangerous keys that could pollute prototypes
|
|
100
|
+
if ((0, _isDangerousKey.isDangerousKey)(attr)) {
|
|
101
|
+
return undefined;
|
|
102
|
+
}
|
|
77
103
|
let value = serverData[attr];
|
|
78
104
|
for (let i = 0; i < pendingOps.length; i++) {
|
|
79
105
|
if (pendingOps[i][attr]) {
|
|
@@ -89,12 +115,20 @@ function estimateAttribute(serverData, pendingOps, object, attr) {
|
|
|
89
115
|
return value;
|
|
90
116
|
}
|
|
91
117
|
function estimateAttributes(serverData, pendingOps, object) {
|
|
92
|
-
const data =
|
|
118
|
+
const data = (0, _create.default)(null);
|
|
93
119
|
for (var attr in serverData) {
|
|
94
120
|
data[attr] = serverData[attr];
|
|
95
121
|
}
|
|
96
122
|
for (let i = 0; i < pendingOps.length; i++) {
|
|
97
123
|
for (attr in pendingOps[i]) {
|
|
124
|
+
// Skip properties from prototype chain
|
|
125
|
+
if (!Object.prototype.hasOwnProperty.call(pendingOps[i], attr)) {
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
// Skip dangerous keys that could pollute prototypes
|
|
129
|
+
if ((0, _isDangerousKey.isDangerousKey)(attr)) {
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
98
132
|
if (pendingOps[i][attr] instanceof _ParseOp.RelationOp) {
|
|
99
133
|
if (object.id) {
|
|
100
134
|
data[attr] = pendingOps[i][attr].applyTo(data[attr], object, attr);
|
|
@@ -112,7 +146,7 @@ function estimateAttributes(serverData, pendingOps, object) {
|
|
|
112
146
|
if (!isNaN(nextKey)) {
|
|
113
147
|
object[key] = [];
|
|
114
148
|
} else {
|
|
115
|
-
object[key] =
|
|
149
|
+
object[key] = (0, _create.default)(null);
|
|
116
150
|
}
|
|
117
151
|
} else {
|
|
118
152
|
if ((0, _isArray.default)(object[key])) {
|
|
@@ -154,7 +188,7 @@ function nestedSet(obj, key, value) {
|
|
|
154
188
|
if (!isNaN(nextPath)) {
|
|
155
189
|
obj[path] = [];
|
|
156
190
|
} else {
|
|
157
|
-
obj[path] =
|
|
191
|
+
obj[path] = (0, _create.default)(null);
|
|
158
192
|
}
|
|
159
193
|
}
|
|
160
194
|
obj = obj[path];
|
|
@@ -168,6 +202,14 @@ function nestedSet(obj, key, value) {
|
|
|
168
202
|
function commitServerChanges(serverData, objectCache, changes) {
|
|
169
203
|
const ParseObject = _CoreManager.default.getParseObject();
|
|
170
204
|
for (const attr in changes) {
|
|
205
|
+
// Skip properties from prototype chain
|
|
206
|
+
if (!Object.prototype.hasOwnProperty.call(changes, attr)) {
|
|
207
|
+
continue;
|
|
208
|
+
}
|
|
209
|
+
// Skip dangerous keys that could pollute prototypes
|
|
210
|
+
if ((0, _isDangerousKey.isDangerousKey)(attr)) {
|
|
211
|
+
continue;
|
|
212
|
+
}
|
|
171
213
|
const val = changes[attr];
|
|
172
214
|
nestedSet(serverData, attr, val);
|
|
173
215
|
if (val && typeof val === 'object' && !(val instanceof ParseObject) && !(val instanceof _ParseFile.default) && !(val instanceof _ParseRelation.default)) {
|
package/lib/browser/Parse.js
CHANGED
|
@@ -47,29 +47,25 @@ var _LiveQueryClient = _interopRequireDefault(require("./LiveQueryClient"));
|
|
|
47
47
|
var _LocalDatastoreController = _interopRequireDefault(require("./LocalDatastoreController"));
|
|
48
48
|
var _StorageController = _interopRequireDefault(require("./StorageController"));
|
|
49
49
|
var _WebSocketController = _interopRequireDefault(require("./WebSocketController"));
|
|
50
|
-
function
|
|
51
|
-
if ("function"
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
var i = _Object$defineProperty && _Object$getOwnPropertyDescriptor ? _Object$getOwnPropertyDescriptor(e, u) : null;
|
|
70
|
-
i && (i.get || i.set) ? _Object$defineProperty(n, u, i) : n[u] = e[u];
|
|
71
|
-
}
|
|
72
|
-
return n.default = e, t && t.set(e, n), n;
|
|
50
|
+
function _interopRequireWildcard(e, t) {
|
|
51
|
+
if ("function" == typeof _WeakMap) var r = new _WeakMap(),
|
|
52
|
+
n = new _WeakMap();
|
|
53
|
+
return (_interopRequireWildcard = function (e, t) {
|
|
54
|
+
if (!t && e && e.__esModule) return e;
|
|
55
|
+
var o,
|
|
56
|
+
i,
|
|
57
|
+
f = {
|
|
58
|
+
__proto__: null,
|
|
59
|
+
default: e
|
|
60
|
+
};
|
|
61
|
+
if (null === e || "object" != typeof e && "function" != typeof e) return f;
|
|
62
|
+
if (o = t ? n : r) {
|
|
63
|
+
if (o.has(e)) return o.get(e);
|
|
64
|
+
o.set(e, f);
|
|
65
|
+
}
|
|
66
|
+
for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = _Object$defineProperty) && _Object$getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]);
|
|
67
|
+
return f;
|
|
68
|
+
})(e, t);
|
|
73
69
|
}
|
|
74
70
|
const Parse = {
|
|
75
71
|
ACL: _ParseACL.default,
|
|
@@ -228,26 +224,6 @@ const Parse = {
|
|
|
228
224
|
get serverURL() {
|
|
229
225
|
return _CoreManager.default.get('SERVER_URL');
|
|
230
226
|
},
|
|
231
|
-
/**
|
|
232
|
-
* @property {string} Parse.serverAuthToken
|
|
233
|
-
* @static
|
|
234
|
-
*/
|
|
235
|
-
set serverAuthToken(value) {
|
|
236
|
-
_CoreManager.default.set('SERVER_AUTH_TOKEN', value);
|
|
237
|
-
},
|
|
238
|
-
get serverAuthToken() {
|
|
239
|
-
return _CoreManager.default.get('SERVER_AUTH_TOKEN');
|
|
240
|
-
},
|
|
241
|
-
/**
|
|
242
|
-
* @property {string} Parse.serverAuthType
|
|
243
|
-
* @static
|
|
244
|
-
*/
|
|
245
|
-
set serverAuthType(value) {
|
|
246
|
-
_CoreManager.default.set('SERVER_AUTH_TYPE', value);
|
|
247
|
-
},
|
|
248
|
-
get serverAuthType() {
|
|
249
|
-
return _CoreManager.default.get('SERVER_AUTH_TYPE');
|
|
250
|
-
},
|
|
251
227
|
/**
|
|
252
228
|
* @property {ParseLiveQuery} Parse.LiveQuery
|
|
253
229
|
* @static
|
|
@@ -308,6 +284,27 @@ const Parse = {
|
|
|
308
284
|
get allowCustomObjectId() {
|
|
309
285
|
return _CoreManager.default.get('ALLOW_CUSTOM_OBJECT_ID');
|
|
310
286
|
},
|
|
287
|
+
/**
|
|
288
|
+
* Setting this property to `true` enables enhanced logging for `Parse.Object`
|
|
289
|
+
* in Node.js environments. Specifically, it will log:
|
|
290
|
+
*
|
|
291
|
+
* ```
|
|
292
|
+
* ParseObject: className: <CLASS_NAME>, id: <OBJECT_ID>
|
|
293
|
+
* Attributes: <OBJECT_ATTRIBUTES>
|
|
294
|
+
* ```
|
|
295
|
+
*
|
|
296
|
+
* @warning This should not be enabled in production environments as this may
|
|
297
|
+
* expose sensitive information in server logs.
|
|
298
|
+
*
|
|
299
|
+
* @property {boolean} Parse.nodeLogging
|
|
300
|
+
* @static
|
|
301
|
+
*/
|
|
302
|
+
set nodeLogging(value) {
|
|
303
|
+
_CoreManager.default.set('NODE_LOGGING', value);
|
|
304
|
+
},
|
|
305
|
+
get nodeLogging() {
|
|
306
|
+
return _CoreManager.default.get('NODE_LOGGING');
|
|
307
|
+
},
|
|
311
308
|
_request() {
|
|
312
309
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
313
310
|
args[_key] = arguments[_key];
|
package/lib/browser/ParseFile.js
CHANGED
|
@@ -12,17 +12,11 @@ var _slice = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stab
|
|
|
12
12
|
var _forEach = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
|
|
13
13
|
var _keys = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/keys"));
|
|
14
14
|
var _promise = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/promise"));
|
|
15
|
-
var _indexOf = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
|
|
16
15
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
|
|
17
16
|
var _CoreManager = _interopRequireDefault(require("./CoreManager"));
|
|
18
17
|
var _ParseError = _interopRequireDefault(require("./ParseError"));
|
|
19
|
-
|
|
20
|
-
/* global XMLHttpRequest, Blob */
|
|
18
|
+
/* global Blob */
|
|
21
19
|
|
|
22
|
-
let XHR = null;
|
|
23
|
-
if (typeof XMLHttpRequest !== 'undefined') {
|
|
24
|
-
XHR = XMLHttpRequest;
|
|
25
|
-
}
|
|
26
20
|
function b64Digit(number) {
|
|
27
21
|
if (number < 26) {
|
|
28
22
|
return String.fromCharCode(65 + number);
|
|
@@ -133,19 +127,31 @@ class ParseFile {
|
|
|
133
127
|
* Data is present if initialized with Byte Array, Base64 or Saved with Uri.
|
|
134
128
|
* Data is cleared if saved with File object selected with a file upload control
|
|
135
129
|
*
|
|
130
|
+
* @param {object} options
|
|
131
|
+
* @param {function} [options.progress] callback for download progress
|
|
132
|
+
* <pre>
|
|
133
|
+
* const parseFile = new Parse.File(name, file);
|
|
134
|
+
* parseFile.getData({
|
|
135
|
+
* progress: (progressValue, loaded, total) => {
|
|
136
|
+
* if (progressValue !== null) {
|
|
137
|
+
* // Update the UI using progressValue
|
|
138
|
+
* }
|
|
139
|
+
* }
|
|
140
|
+
* });
|
|
141
|
+
* </pre>
|
|
136
142
|
* @returns {Promise} Promise that is resolve with base64 data
|
|
137
143
|
*/
|
|
138
|
-
async getData() {
|
|
144
|
+
async getData(options) {
|
|
145
|
+
options = options || {};
|
|
139
146
|
if (this._data) {
|
|
140
147
|
return this._data;
|
|
141
148
|
}
|
|
142
149
|
if (!this._url) {
|
|
143
150
|
throw new Error('Cannot retrieve data for unsaved ParseFile.');
|
|
144
151
|
}
|
|
152
|
+
options.requestTask = task => this._requestTask = task;
|
|
145
153
|
const controller = _CoreManager.default.getFileController();
|
|
146
|
-
const result = await controller.download(this._url,
|
|
147
|
-
requestTask: task => this._requestTask = task
|
|
148
|
-
});
|
|
154
|
+
const result = await controller.download(this._url, options);
|
|
149
155
|
this._data = result.base64;
|
|
150
156
|
return this._data;
|
|
151
157
|
}
|
|
@@ -208,12 +214,12 @@ class ParseFile {
|
|
|
208
214
|
* be used for this request.
|
|
209
215
|
* <li>sessionToken: A valid session token, used for making a request on
|
|
210
216
|
* behalf of a specific user.
|
|
211
|
-
* <li>progress:
|
|
217
|
+
* <li>progress: callback for upload progress. For example:
|
|
212
218
|
* <pre>
|
|
213
219
|
* let parseFile = new Parse.File(name, file);
|
|
214
220
|
* parseFile.save({
|
|
215
|
-
* progress: (progressValue, loaded, total
|
|
216
|
-
* if (
|
|
221
|
+
* progress: (progressValue, loaded, total) => {
|
|
222
|
+
* if (progressValue !== null) {
|
|
217
223
|
* // Update the UI using progressValue
|
|
218
224
|
* }
|
|
219
225
|
* }
|
|
@@ -445,37 +451,57 @@ const DefaultController = {
|
|
|
445
451
|
}
|
|
446
452
|
return _CoreManager.default.getRESTController().request('POST', 'files/' + name, data, options);
|
|
447
453
|
},
|
|
448
|
-
download: function (uri, options) {
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
|
|
454
|
+
download: async function (uri, options) {
|
|
455
|
+
const controller = new AbortController();
|
|
456
|
+
options.requestTask(controller);
|
|
457
|
+
const {
|
|
458
|
+
signal
|
|
459
|
+
} = controller;
|
|
460
|
+
try {
|
|
461
|
+
const response = await fetch(uri, {
|
|
462
|
+
signal
|
|
463
|
+
});
|
|
464
|
+
const reader = response.body.getReader();
|
|
465
|
+
const length = +response.headers.get('Content-Length') || 0;
|
|
466
|
+
const contentType = response.headers.get('Content-Type');
|
|
467
|
+
if (length === 0) {
|
|
468
|
+
options.progress?.(null, null, null);
|
|
469
|
+
return {
|
|
470
|
+
base64: '',
|
|
471
|
+
contentType
|
|
472
|
+
};
|
|
473
|
+
}
|
|
474
|
+
let recieved = 0;
|
|
475
|
+
const chunks = [];
|
|
476
|
+
while (true) {
|
|
477
|
+
const {
|
|
478
|
+
done,
|
|
479
|
+
value
|
|
480
|
+
} = await reader.read();
|
|
481
|
+
if (done) {
|
|
482
|
+
break;
|
|
469
483
|
}
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
484
|
+
chunks.push(value);
|
|
485
|
+
recieved += value?.length || 0;
|
|
486
|
+
options.progress?.(recieved / length, recieved, length);
|
|
487
|
+
}
|
|
488
|
+
const body = new Uint8Array(recieved);
|
|
489
|
+
let offset = 0;
|
|
490
|
+
for (const chunk of chunks) {
|
|
491
|
+
body.set(chunk, offset);
|
|
492
|
+
offset += chunk.length;
|
|
493
|
+
}
|
|
494
|
+
return {
|
|
495
|
+
base64: ParseFile.encodeBase64(body),
|
|
496
|
+
contentType
|
|
475
497
|
};
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
498
|
+
} catch (error) {
|
|
499
|
+
if (error.name === 'AbortError') {
|
|
500
|
+
return {};
|
|
501
|
+
} else {
|
|
502
|
+
throw error;
|
|
503
|
+
}
|
|
504
|
+
}
|
|
479
505
|
},
|
|
480
506
|
deleteFile: function (name, options) {
|
|
481
507
|
const headers = {
|
|
@@ -491,18 +517,12 @@ const DefaultController = {
|
|
|
491
517
|
url += 'files/' + name;
|
|
492
518
|
return _CoreManager.default.getRESTController().ajax('DELETE', url, '', headers).catch(response => {
|
|
493
519
|
// TODO: return JSON object in server
|
|
494
|
-
if (!response || response === 'SyntaxError: Unexpected end of JSON input') {
|
|
520
|
+
if (!response || response.toString() === 'SyntaxError: Unexpected end of JSON input') {
|
|
495
521
|
return _promise.default.resolve();
|
|
496
522
|
} else {
|
|
497
523
|
return _CoreManager.default.getRESTController().handleError(response);
|
|
498
524
|
}
|
|
499
525
|
});
|
|
500
|
-
},
|
|
501
|
-
_setXHR(xhr) {
|
|
502
|
-
XHR = xhr;
|
|
503
|
-
},
|
|
504
|
-
_getXHR() {
|
|
505
|
-
return XHR;
|
|
506
526
|
}
|
|
507
527
|
};
|
|
508
528
|
_CoreManager.default.setFileController(DefaultController);
|
|
@@ -9,18 +9,19 @@ _Object$defineProperty2(exports, "__esModule", {
|
|
|
9
9
|
});
|
|
10
10
|
exports.default = void 0;
|
|
11
11
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
|
|
12
|
+
var _create = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/create"));
|
|
12
13
|
var _indexOf = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
|
|
14
|
+
var _for = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/symbol/for"));
|
|
15
|
+
var _stringify = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/json/stringify"));
|
|
13
16
|
var _freeze = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/freeze"));
|
|
14
17
|
var _keys = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/keys"));
|
|
15
18
|
var _forEach = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
|
|
16
|
-
var _stringify = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/json/stringify"));
|
|
17
19
|
var _includes = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/includes"));
|
|
18
20
|
var _getPrototypeOf = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/get-prototype-of"));
|
|
19
21
|
var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
|
|
20
22
|
var _some = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/some"));
|
|
21
23
|
var _promise = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/promise"));
|
|
22
24
|
var _isArray = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/array/is-array"));
|
|
23
|
-
var _create = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/create"));
|
|
24
25
|
var _defineProperty3 = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/define-property"));
|
|
25
26
|
var _find = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/find"));
|
|
26
27
|
var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
|
|
@@ -42,33 +43,29 @@ var SingleInstanceStateController = _interopRequireWildcard(require("./SingleIns
|
|
|
42
43
|
var _unique = _interopRequireDefault(require("./unique"));
|
|
43
44
|
var UniqueInstanceStateController = _interopRequireWildcard(require("./UniqueInstanceStateController"));
|
|
44
45
|
var _unsavedChildren = _interopRequireDefault(require("./unsavedChildren"));
|
|
45
|
-
function
|
|
46
|
-
if ("function"
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
var i = _Object$defineProperty2 && _Object$getOwnPropertyDescriptor ? _Object$getOwnPropertyDescriptor(e, u) : null;
|
|
65
|
-
i && (i.get || i.set) ? _Object$defineProperty2(n, u, i) : n[u] = e[u];
|
|
66
|
-
}
|
|
67
|
-
return n.default = e, t && t.set(e, n), n;
|
|
46
|
+
function _interopRequireWildcard(e, t) {
|
|
47
|
+
if ("function" == typeof _WeakMap) var r = new _WeakMap(),
|
|
48
|
+
n = new _WeakMap();
|
|
49
|
+
return (_interopRequireWildcard = function (e, t) {
|
|
50
|
+
if (!t && e && e.__esModule) return e;
|
|
51
|
+
var o,
|
|
52
|
+
i,
|
|
53
|
+
f = {
|
|
54
|
+
__proto__: null,
|
|
55
|
+
default: e
|
|
56
|
+
};
|
|
57
|
+
if (null === e || "object" != typeof e && "function" != typeof e) return f;
|
|
58
|
+
if (o = t ? n : r) {
|
|
59
|
+
if (o.has(e)) return o.get(e);
|
|
60
|
+
o.set(e, f);
|
|
61
|
+
}
|
|
62
|
+
for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = _Object$defineProperty2) && _Object$getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]);
|
|
63
|
+
return f;
|
|
64
|
+
})(e, t);
|
|
68
65
|
}
|
|
69
66
|
// Mapping of class names to constructors, so we can populate objects from the
|
|
70
67
|
// server with appropriate subclasses of ParseObject
|
|
71
|
-
const classMap =
|
|
68
|
+
const classMap = (0, _create.default)(null);
|
|
72
69
|
|
|
73
70
|
// Global counter for generating unique Ids for non-single-instance objects
|
|
74
71
|
let objectCount = 0;
|
|
@@ -155,6 +152,11 @@ class ParseObject {
|
|
|
155
152
|
throw new Error("Can't create an invalid Parse Object");
|
|
156
153
|
}
|
|
157
154
|
}
|
|
155
|
+
if (_CoreManager.default.get('NODE_LOGGING')) {
|
|
156
|
+
this[(0, _for.default)('nodejs.util.inspect.custom')] = function () {
|
|
157
|
+
return `ParseObject: className: ${this.className}, id: ${this.id}\nAttributes: ${(0, _stringify.default)(this.attributes, null, 2)}`;
|
|
158
|
+
};
|
|
159
|
+
}
|
|
158
160
|
}
|
|
159
161
|
/* Prototype getters / setters */
|
|
160
162
|
|
|
@@ -434,6 +436,9 @@ class ParseObject {
|
|
|
434
436
|
static _getRequestOptions() {
|
|
435
437
|
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
436
438
|
const requestOptions = {};
|
|
439
|
+
if (Object.prototype.toString.call(options) !== '[object Object]') {
|
|
440
|
+
throw new Error('request options must be of type Object');
|
|
441
|
+
}
|
|
437
442
|
const {
|
|
438
443
|
hasOwn
|
|
439
444
|
} = Object;
|
|
@@ -2358,7 +2363,6 @@ const DefaultController = {
|
|
|
2358
2363
|
const status = responses[index]._status;
|
|
2359
2364
|
delete responses[index]._status;
|
|
2360
2365
|
delete responses[index]._headers;
|
|
2361
|
-
delete responses[index]._xhr;
|
|
2362
2366
|
mapIdForPin[objectId] = obj._localId;
|
|
2363
2367
|
obj._handleSaveResponse(responses[index].success, status);
|
|
2364
2368
|
} else {
|
|
@@ -2420,7 +2424,6 @@ const DefaultController = {
|
|
|
2420
2424
|
const status = response._status;
|
|
2421
2425
|
delete response._status;
|
|
2422
2426
|
delete response._headers;
|
|
2423
|
-
delete response._xhr;
|
|
2424
2427
|
targetCopy._handleSaveResponse(response, status);
|
|
2425
2428
|
}, error => {
|
|
2426
2429
|
targetCopy._handleSaveError();
|
package/lib/browser/ParseOp.js
CHANGED
|
@@ -423,8 +423,8 @@ class RelationOp extends Op {
|
|
|
423
423
|
};
|
|
424
424
|
}
|
|
425
425
|
if (this.relationsToRemove.length > 0) {
|
|
426
|
-
var
|
|
427
|
-
pointers = (0, _map.default)(
|
|
426
|
+
var _context0;
|
|
427
|
+
pointers = (0, _map.default)(_context0 = this.relationsToRemove).call(_context0, idToPointer);
|
|
428
428
|
removes = {
|
|
429
429
|
__op: 'RemoveRelation',
|
|
430
430
|
objects: pointers
|
|
@@ -1632,11 +1632,11 @@ class ParseQuery {
|
|
|
1632
1632
|
keys[_key4] = arguments[_key4];
|
|
1633
1633
|
}
|
|
1634
1634
|
(0, _forEach.default)(keys).call(keys, key => {
|
|
1635
|
-
var _context9,
|
|
1635
|
+
var _context9, _context0;
|
|
1636
1636
|
if ((0, _isArray.default)(key)) {
|
|
1637
1637
|
key = key.join();
|
|
1638
1638
|
}
|
|
1639
|
-
this._order = (0, _concat.default)(_context9 = this._order).call(_context9, (0, _map.default)(
|
|
1639
|
+
this._order = (0, _concat.default)(_context9 = this._order).call(_context9, (0, _map.default)(_context0 = key.replace(/\s/g, '').split(',')).call(_context0, k => {
|
|
1640
1640
|
return '-' + k;
|
|
1641
1641
|
}));
|
|
1642
1642
|
});
|
|
@@ -1709,8 +1709,8 @@ class ParseQuery {
|
|
|
1709
1709
|
}
|
|
1710
1710
|
(0, _forEach.default)(keys).call(keys, key => {
|
|
1711
1711
|
if ((0, _isArray.default)(key)) {
|
|
1712
|
-
var
|
|
1713
|
-
this._include = (0, _concat.default)(
|
|
1712
|
+
var _context1;
|
|
1713
|
+
this._include = (0, _concat.default)(_context1 = this._include).call(_context1, key);
|
|
1714
1714
|
} else {
|
|
1715
1715
|
this._include.push(key);
|
|
1716
1716
|
}
|
|
@@ -1746,8 +1746,8 @@ class ParseQuery {
|
|
|
1746
1746
|
}
|
|
1747
1747
|
(0, _forEach.default)(keys).call(keys, key => {
|
|
1748
1748
|
if ((0, _isArray.default)(key)) {
|
|
1749
|
-
var
|
|
1750
|
-
this._select = (0, _concat.default)(
|
|
1749
|
+
var _context10;
|
|
1750
|
+
this._select = (0, _concat.default)(_context10 = this._select).call(_context10, key);
|
|
1751
1751
|
} else {
|
|
1752
1752
|
this._select.push(key);
|
|
1753
1753
|
}
|
|
@@ -1770,8 +1770,8 @@ class ParseQuery {
|
|
|
1770
1770
|
}
|
|
1771
1771
|
(0, _forEach.default)(keys).call(keys, key => {
|
|
1772
1772
|
if ((0, _isArray.default)(key)) {
|
|
1773
|
-
var
|
|
1774
|
-
this._exclude = (0, _concat.default)(
|
|
1773
|
+
var _context11;
|
|
1774
|
+
this._exclude = (0, _concat.default)(_context11 = this._exclude).call(_context11, key);
|
|
1775
1775
|
} else {
|
|
1776
1776
|
this._exclude.push(key);
|
|
1777
1777
|
}
|
|
@@ -1793,8 +1793,8 @@ class ParseQuery {
|
|
|
1793
1793
|
}
|
|
1794
1794
|
(0, _forEach.default)(keys).call(keys, key => {
|
|
1795
1795
|
if ((0, _isArray.default)(key)) {
|
|
1796
|
-
var
|
|
1797
|
-
this._watch = (0, _concat.default)(
|
|
1796
|
+
var _context12;
|
|
1797
|
+
this._watch = (0, _concat.default)(_context12 = this._watch).call(_context12, key);
|
|
1798
1798
|
} else {
|
|
1799
1799
|
this._watch.push(key);
|
|
1800
1800
|
}
|
|
@@ -1874,8 +1874,8 @@ class ParseQuery {
|
|
|
1874
1874
|
* @returns {Parse.Query} The query that is the AND of the passed in queries.
|
|
1875
1875
|
*/
|
|
1876
1876
|
static and() {
|
|
1877
|
-
for (var
|
|
1878
|
-
queries[
|
|
1877
|
+
for (var _len0 = arguments.length, queries = new Array(_len0), _key0 = 0; _key0 < _len0; _key0++) {
|
|
1878
|
+
queries[_key0] = arguments[_key0];
|
|
1879
1879
|
}
|
|
1880
1880
|
const className = _getClassNameFromQueries(queries);
|
|
1881
1881
|
const query = new ParseQuery(className);
|
|
@@ -1896,8 +1896,8 @@ class ParseQuery {
|
|
|
1896
1896
|
* @returns {Parse.Query} The query that is the NOR of the passed in queries.
|
|
1897
1897
|
*/
|
|
1898
1898
|
static nor() {
|
|
1899
|
-
for (var
|
|
1900
|
-
queries[
|
|
1899
|
+
for (var _len1 = arguments.length, queries = new Array(_len1), _key1 = 0; _key1 < _len1; _key1++) {
|
|
1900
|
+
queries[_key1] = arguments[_key1];
|
|
1901
1901
|
}
|
|
1902
1902
|
const className = _getClassNameFromQueries(queries);
|
|
1903
1903
|
const query = new ParseQuery(className);
|