parse 5.1.0 → 5.2.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/parse.js +1556 -1309
- package/dist/parse.min.js +2 -2
- package/dist/parse.weapp.js +1560 -1313
- package/dist/parse.weapp.min.js +2 -2
- package/lib/browser/Cloud.js +7 -11
- package/lib/browser/CoreManager.js +10 -10
- package/lib/browser/EventuallyQueue.js +1 -1
- package/lib/browser/InstallationController.js +3 -3
- package/lib/browser/LiveQueryClient.js +102 -60
- package/lib/browser/LocalDatastore.js +189 -147
- package/lib/browser/LocalDatastoreController.default.js +14 -9
- package/lib/browser/LocalDatastoreController.react-native.js +14 -12
- package/lib/browser/LocalDatastoreUtils.js +0 -5
- package/lib/browser/ObjectStateMutations.js +57 -21
- package/lib/browser/Parse.js +2 -2
- package/lib/browser/ParseCLP.js +9 -17
- package/lib/browser/ParseFile.js +27 -31
- package/lib/browser/ParseGeoPoint.js +9 -3
- package/lib/browser/ParseHooks.js +13 -13
- package/lib/browser/ParseInstallation.js +117 -9
- package/lib/browser/ParseObject.js +19 -17
- package/lib/browser/ParseOp.js +17 -17
- package/lib/browser/ParsePolygon.js +1 -1
- package/lib/browser/ParseQuery.js +147 -149
- package/lib/browser/ParseRole.js +5 -9
- package/lib/browser/ParseSchema.js +1 -1
- package/lib/browser/ParseUser.js +66 -51
- package/lib/browser/Push.js +5 -10
- package/lib/browser/RESTController.js +1 -1
- package/lib/browser/SingleInstanceStateController.js +1 -1
- package/lib/browser/TaskQueue.js +10 -10
- package/lib/browser/UniqueInstanceStateController.js +1 -1
- package/lib/browser/arrayContainsObject.js +0 -4
- package/lib/browser/canBeSerialized.js +0 -4
- package/lib/browser/decode.js +0 -7
- package/lib/browser/encode.js +3 -7
- package/lib/browser/equals.js +1 -1
- package/lib/browser/escape.js +0 -4
- package/lib/browser/isRevocableSession.js +0 -4
- package/lib/browser/parseDate.js +1 -5
- package/lib/browser/promiseUtils.js +11 -10
- package/lib/browser/unique.js +1 -5
- package/lib/browser/unsavedChildren.js +0 -8
- package/lib/browser/uuid.js +2 -2
- package/lib/node/Cloud.js +7 -11
- package/lib/node/CoreManager.js +10 -10
- package/lib/node/EventuallyQueue.js +1 -1
- package/lib/node/InstallationController.js +3 -3
- package/lib/node/LiveQueryClient.js +14 -24
- package/lib/node/LocalDatastore.js +7 -11
- package/lib/node/LocalDatastoreController.default.js +12 -10
- package/lib/node/LocalDatastoreController.react-native.js +13 -12
- package/lib/node/LocalDatastoreUtils.js +0 -5
- package/lib/node/ObjectStateMutations.js +45 -19
- package/lib/node/Parse.js +2 -2
- package/lib/node/ParseCLP.js +8 -18
- package/lib/node/ParseFile.js +27 -40
- package/lib/node/ParseGeoPoint.js +9 -3
- package/lib/node/ParseHooks.js +13 -13
- package/lib/node/ParseInstallation.js +60 -2
- package/lib/node/ParseObject.js +19 -17
- package/lib/node/ParseOp.js +21 -21
- package/lib/node/ParsePolygon.js +1 -1
- package/lib/node/ParseQuery.js +84 -107
- package/lib/node/ParseRole.js +3 -8
- package/lib/node/ParseSchema.js +4 -4
- package/lib/node/ParseUser.js +42 -37
- package/lib/node/Push.js +3 -8
- package/lib/node/RESTController.js +1 -1
- package/lib/node/SingleInstanceStateController.js +1 -1
- package/lib/node/TaskQueue.js +9 -11
- package/lib/node/UniqueInstanceStateController.js +1 -1
- package/lib/node/arrayContainsObject.js +0 -4
- package/lib/node/canBeSerialized.js +0 -4
- package/lib/node/decode.js +0 -7
- package/lib/node/encode.js +3 -7
- package/lib/node/equals.js +1 -1
- package/lib/node/escape.js +0 -4
- package/lib/node/isRevocableSession.js +0 -4
- package/lib/node/parseDate.js +1 -5
- package/lib/node/promiseUtils.js +11 -10
- package/lib/node/unique.js +1 -5
- package/lib/node/unsavedChildren.js +0 -8
- package/lib/node/uuid.js +2 -2
- package/lib/react-native/Cloud.js +0 -1
- package/lib/react-native/CoreManager.js +1 -1
- package/lib/react-native/LiveQueryClient.js +49 -32
- package/lib/react-native/LocalDatastore.js +38 -14
- package/lib/react-native/LocalDatastoreController.default.js +7 -1
- package/lib/react-native/LocalDatastoreController.react-native.js +7 -1
- package/lib/react-native/ObjectStateMutations.js +30 -9
- package/lib/react-native/ParseCLP.js +3 -3
- package/lib/react-native/ParseFile.js +7 -6
- package/lib/react-native/ParseInstallation.js +51 -3
- package/lib/react-native/ParseObject.js +6 -5
- package/lib/react-native/ParseQuery.js +45 -37
- package/lib/react-native/ParseRole.js +1 -1
- package/lib/react-native/ParseUser.js +22 -16
- package/lib/react-native/TaskQueue.js +8 -2
- package/lib/react-native/decode.js +0 -1
- package/lib/react-native/promiseUtils.js +5 -4
- package/lib/react-native/uuid.js +1 -2
- package/lib/weapp/Cloud.js +7 -11
- package/lib/weapp/CoreManager.js +10 -10
- package/lib/weapp/EventuallyQueue.js +1 -1
- package/lib/weapp/InstallationController.js +3 -3
- package/lib/weapp/LiveQueryClient.js +102 -60
- package/lib/weapp/LocalDatastore.js +189 -147
- package/lib/weapp/LocalDatastoreController.default.js +14 -9
- package/lib/weapp/LocalDatastoreController.react-native.js +14 -12
- package/lib/weapp/LocalDatastoreUtils.js +0 -5
- package/lib/weapp/ObjectStateMutations.js +57 -21
- package/lib/weapp/Parse.js +2 -2
- package/lib/weapp/ParseCLP.js +9 -17
- package/lib/weapp/ParseFile.js +27 -31
- package/lib/weapp/ParseGeoPoint.js +9 -3
- package/lib/weapp/ParseHooks.js +13 -13
- package/lib/weapp/ParseInstallation.js +117 -9
- package/lib/weapp/ParseObject.js +19 -17
- package/lib/weapp/ParseOp.js +17 -17
- package/lib/weapp/ParsePolygon.js +1 -1
- package/lib/weapp/ParseQuery.js +147 -149
- package/lib/weapp/ParseRole.js +5 -9
- package/lib/weapp/ParseSchema.js +1 -1
- package/lib/weapp/ParseUser.js +66 -51
- package/lib/weapp/Push.js +5 -10
- package/lib/weapp/RESTController.js +1 -1
- package/lib/weapp/SingleInstanceStateController.js +1 -1
- package/lib/weapp/TaskQueue.js +10 -10
- package/lib/weapp/UniqueInstanceStateController.js +1 -1
- package/lib/weapp/arrayContainsObject.js +0 -4
- package/lib/weapp/canBeSerialized.js +0 -4
- package/lib/weapp/decode.js +0 -7
- package/lib/weapp/encode.js +3 -7
- package/lib/weapp/equals.js +1 -1
- package/lib/weapp/escape.js +0 -4
- package/lib/weapp/isRevocableSession.js +0 -4
- package/lib/weapp/parseDate.js +1 -5
- package/lib/weapp/promiseUtils.js +11 -10
- package/lib/weapp/unique.js +1 -5
- package/lib/weapp/unsavedChildren.js +0 -8
- package/lib/weapp/uuid.js +3 -3
- package/package.json +5 -6
|
@@ -23,10 +23,6 @@ function _interopRequireDefault(obj) {
|
|
|
23
23
|
default: obj
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
|
-
/**
|
|
27
|
-
* @flow
|
|
28
|
-
*/
|
|
29
|
-
/*:: import type { Op } from './ParseOp';*/
|
|
30
26
|
/*:: export type AttributeMap = { [attr: string]: any };*/
|
|
31
27
|
/*:: export type OpsMap = { [attr: string]: Op };*/
|
|
32
28
|
/*:: export type ObjectCache = { [attr: string]: string };*/
|
|
@@ -55,7 +51,7 @@ function setServerData(serverData /*: AttributeMap*/, attributes /*: AttributeMa
|
|
|
55
51
|
}
|
|
56
52
|
}
|
|
57
53
|
}
|
|
58
|
-
function setPendingOp(pendingOps /*: Array<OpsMap>*/, attr /*: string*/, op
|
|
54
|
+
function setPendingOp(pendingOps /*: Array<OpsMap>*/, attr /*: string*/, op /*:: ?: Op*/) {
|
|
59
55
|
const last = pendingOps.length - 1;
|
|
60
56
|
if (op) {
|
|
61
57
|
pendingOps[last][attr] = op;
|
|
@@ -87,7 +83,7 @@ function mergeFirstPendingState(pendingOps /*: Array<OpsMap>*/) {
|
|
|
87
83
|
}
|
|
88
84
|
}
|
|
89
85
|
}
|
|
90
|
-
function estimateAttribute(serverData /*: AttributeMap*/, pendingOps /*: Array<OpsMap>*/, object /*: ParseObject*/, attr /*: string*/) /*:
|
|
86
|
+
function estimateAttribute(serverData /*: AttributeMap*/, pendingOps /*: Array<OpsMap>*/, object /*: ParseObject*/, attr /*: string*/) /*: any*/{
|
|
91
87
|
let value = serverData[attr];
|
|
92
88
|
for (let i = 0; i < pendingOps.length; i++) {
|
|
93
89
|
if (pendingOps[i][attr]) {
|
|
@@ -115,18 +111,27 @@ function estimateAttributes(serverData /*: AttributeMap*/, pendingOps /*: Array<
|
|
|
115
111
|
}
|
|
116
112
|
} else {
|
|
117
113
|
if (attr.includes('.')) {
|
|
118
|
-
//
|
|
114
|
+
// similar to nestedSet function
|
|
119
115
|
const fields = attr.split('.');
|
|
120
116
|
const last = fields[fields.length - 1];
|
|
121
117
|
let object = data;
|
|
122
118
|
for (let i = 0; i < fields.length - 1; i++) {
|
|
123
119
|
const key = fields[i];
|
|
124
120
|
if (!(key in object)) {
|
|
125
|
-
|
|
121
|
+
const nextKey = fields[i + 1];
|
|
122
|
+
if (!isNaN(nextKey)) {
|
|
123
|
+
object[key] = [];
|
|
124
|
+
} else {
|
|
125
|
+
object[key] = {};
|
|
126
|
+
}
|
|
126
127
|
} else {
|
|
127
|
-
object[key]
|
|
128
|
-
...object[key]
|
|
129
|
-
}
|
|
128
|
+
if (Array.isArray(object[key])) {
|
|
129
|
+
object[key] = [...object[key]];
|
|
130
|
+
} else {
|
|
131
|
+
object[key] = {
|
|
132
|
+
...object[key]
|
|
133
|
+
};
|
|
134
|
+
}
|
|
130
135
|
}
|
|
131
136
|
object = object[key];
|
|
132
137
|
}
|
|
@@ -139,24 +144,45 @@ function estimateAttributes(serverData /*: AttributeMap*/, pendingOps /*: Array<
|
|
|
139
144
|
}
|
|
140
145
|
return data;
|
|
141
146
|
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Allows setting properties/variables deep in an object.
|
|
150
|
+
* Converts a.b into { a: { b: value } } for dot notation on Objects
|
|
151
|
+
* Converts a.0.b into { a: [{ b: value }] } for dot notation on Arrays
|
|
152
|
+
*
|
|
153
|
+
* @param obj The object to assign the value to
|
|
154
|
+
* @param key The key to assign. If it's in a deeper path, then use dot notation (`prop1.prop2.prop3`)
|
|
155
|
+
* Note that intermediate object(s) in the nested path are automatically created if they don't exist.
|
|
156
|
+
* @param value The value to assign. If it's an `undefined` then the key is deleted.
|
|
157
|
+
*/
|
|
142
158
|
function nestedSet(obj, key, value) {
|
|
143
|
-
const
|
|
144
|
-
for (let i = 0; i <
|
|
145
|
-
|
|
146
|
-
|
|
159
|
+
const paths = key.split('.');
|
|
160
|
+
for (let i = 0; i < paths.length - 1; i++) {
|
|
161
|
+
const path = paths[i];
|
|
162
|
+
if (!(path in obj)) {
|
|
163
|
+
const nextPath = paths[i + 1];
|
|
164
|
+
if (!isNaN(nextPath)) {
|
|
165
|
+
obj[path] = [];
|
|
166
|
+
} else {
|
|
167
|
+
obj[path] = {};
|
|
168
|
+
}
|
|
147
169
|
}
|
|
148
|
-
obj = obj[path
|
|
170
|
+
obj = obj[path];
|
|
149
171
|
}
|
|
150
172
|
if (typeof value === 'undefined') {
|
|
151
|
-
delete obj[
|
|
173
|
+
delete obj[paths[paths.length - 1]];
|
|
152
174
|
} else {
|
|
153
|
-
obj[
|
|
175
|
+
obj[paths[paths.length - 1]] = value;
|
|
154
176
|
}
|
|
155
177
|
}
|
|
156
178
|
function commitServerChanges(serverData /*: AttributeMap*/, objectCache /*: ObjectCache*/, changes /*: AttributeMap*/) {
|
|
157
179
|
const ParseObject = _CoreManager.default.getParseObject();
|
|
158
180
|
for (const attr in changes) {
|
|
159
|
-
|
|
181
|
+
let val = changes[attr];
|
|
182
|
+
// Check for JSON array { '0': { something }, '1': { something } }
|
|
183
|
+
if (val && typeof val === 'object' && !Array.isArray(val) && Object.keys(val).length > 0 && Object.keys(val).some(k => !isNaN(parseInt(k)))) {
|
|
184
|
+
val = Object.values(val);
|
|
185
|
+
}
|
|
160
186
|
nestedSet(serverData, attr, val);
|
|
161
187
|
if (val && typeof val === 'object' && !(val instanceof ParseObject) && !(val instanceof _ParseFile.default) && !(val instanceof _ParseRelation.default)) {
|
|
162
188
|
const json = (0, _encode.default)(val, false, true);
|
package/lib/node/Parse.js
CHANGED
|
@@ -92,7 +92,7 @@ function _interopRequireDefault(obj) {
|
|
|
92
92
|
* @global
|
|
93
93
|
* @class
|
|
94
94
|
* @hideconstructor
|
|
95
|
-
*/
|
|
95
|
+
*/
|
|
96
96
|
|
|
97
97
|
const Parse /*: ParseType*/ = {
|
|
98
98
|
ACL: _ParseACL.default,
|
|
@@ -340,7 +340,7 @@ const Parse /*: ParseType*/ = {
|
|
|
340
340
|
* @param [ms] Milliseconds to ping the server. Default 2000ms
|
|
341
341
|
* @static
|
|
342
342
|
*/
|
|
343
|
-
enableLocalDatastore(polling = true, ms
|
|
343
|
+
enableLocalDatastore(polling = true, ms = 2000) {
|
|
344
344
|
if (!this.applicationId) {
|
|
345
345
|
console.log("'enableLocalDataStore' must be called after 'initialize'");
|
|
346
346
|
return;
|
package/lib/node/ParseCLP.js
CHANGED
|
@@ -11,16 +11,9 @@ function _interopRequireDefault(obj) {
|
|
|
11
11
|
default: obj
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
|
-
|
|
15
|
-
* @flow
|
|
16
|
-
*/
|
|
17
|
-
/*:: type Entity = Entity;*/
|
|
18
|
-
/*:: type UsersMap = { [userId: string]: boolean | any };*/
|
|
19
|
-
/*:: export type PermissionsMap = { [permission: string]: UsersMap };*/
|
|
14
|
+
/*:: export type PermissionsMap = { writeUserFields?: string[], readUserFields?: string[] } & { [permission: string]: UsersMap };*/
|
|
20
15
|
const PUBLIC_KEY = '*';
|
|
21
|
-
const VALID_PERMISSIONS /*: Map<string, UsersMap>*/ = new Map(
|
|
22
|
-
/*:: <string, UsersMap>*/
|
|
23
|
-
);
|
|
16
|
+
const VALID_PERMISSIONS /*: Map<string, UsersMap>*/ = new Map();
|
|
24
17
|
VALID_PERMISSIONS.set('get', {});
|
|
25
18
|
VALID_PERMISSIONS.set('find', {});
|
|
26
19
|
VALID_PERMISSIONS.set('count', {});
|
|
@@ -28,9 +21,7 @@ VALID_PERMISSIONS.set('create', {});
|
|
|
28
21
|
VALID_PERMISSIONS.set('update', {});
|
|
29
22
|
VALID_PERMISSIONS.set('delete', {});
|
|
30
23
|
VALID_PERMISSIONS.set('addField', {});
|
|
31
|
-
const VALID_PERMISSIONS_EXTENDED /*: Map<string, UsersMap>*/ = new Map(
|
|
32
|
-
/*:: <string, UsersMap>*/
|
|
33
|
-
);
|
|
24
|
+
const VALID_PERMISSIONS_EXTENDED /*: Map<string, UsersMap>*/ = new Map();
|
|
34
25
|
VALID_PERMISSIONS_EXTENDED.set('protectedFields', {});
|
|
35
26
|
|
|
36
27
|
/**
|
|
@@ -126,7 +117,6 @@ VALID_PERMISSIONS_EXTENDED.set('protectedFields', {});
|
|
|
126
117
|
* @alias Parse.CLP
|
|
127
118
|
*/
|
|
128
119
|
class ParseCLP {
|
|
129
|
-
/*:: permissionsMap: PermissionsMap;*/
|
|
130
120
|
/**
|
|
131
121
|
* @param {(Parse.User | Parse.Role | object)} userId The user to initialize the CLP for
|
|
132
122
|
*/
|
|
@@ -312,7 +302,7 @@ class ParseCLP {
|
|
|
312
302
|
}
|
|
313
303
|
return permissions;
|
|
314
304
|
}
|
|
315
|
-
_setArrayAccess(permission /*: string*/, userId /*: Entity*/, fields /*: string*/) {
|
|
305
|
+
_setArrayAccess(permission /*: string*/, userId /*: Entity*/, fields /*: string[]*/) {
|
|
316
306
|
userId = this._parseEntity(userId);
|
|
317
307
|
const permissions = this.permissionsMap[permission][userId];
|
|
318
308
|
if (!permissions) {
|
|
@@ -339,8 +329,8 @@ class ParseCLP {
|
|
|
339
329
|
throw new TypeError(`${operation}.pointerFields must be an array of strings or undefined.`);
|
|
340
330
|
}
|
|
341
331
|
}
|
|
342
|
-
_getGroupPointerPermissions(operation /*:
|
|
343
|
-
return this.permissionsMap[operation];
|
|
332
|
+
_getGroupPointerPermissions(operation /*: 'readUserFields' | 'writeUserFields'*/) /*: string[]*/{
|
|
333
|
+
return this.permissionsMap[operation] || [];
|
|
344
334
|
}
|
|
345
335
|
|
|
346
336
|
/**
|
|
@@ -356,7 +346,7 @@ class ParseCLP {
|
|
|
356
346
|
* @returns {string[]} User pointer fields
|
|
357
347
|
*/
|
|
358
348
|
getReadUserFields() /*: string[]*/{
|
|
359
|
-
return this._getGroupPointerPermissions('readUserFields');
|
|
349
|
+
return this._getGroupPointerPermissions('readUserFields') || [];
|
|
360
350
|
}
|
|
361
351
|
|
|
362
352
|
/**
|
|
@@ -372,7 +362,7 @@ class ParseCLP {
|
|
|
372
362
|
* @returns {string[]} User pointer fields
|
|
373
363
|
*/
|
|
374
364
|
getWriteUserFields() /*: string[]*/{
|
|
375
|
-
return this._getGroupPointerPermissions('writeUserFields');
|
|
365
|
+
return this._getGroupPointerPermissions('writeUserFields') || [];
|
|
376
366
|
}
|
|
377
367
|
|
|
378
368
|
/**
|
package/lib/node/ParseFile.js
CHANGED
|
@@ -5,24 +5,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _CoreManager = _interopRequireDefault(require("./CoreManager"));
|
|
8
|
+
var _ParseError = _interopRequireDefault(require("./ParseError"));
|
|
8
9
|
function _interopRequireDefault(obj) {
|
|
9
10
|
return obj && obj.__esModule ? obj : {
|
|
10
11
|
default: obj
|
|
11
12
|
};
|
|
12
13
|
}
|
|
13
|
-
/**
|
|
14
|
-
* @flow
|
|
15
|
-
*/
|
|
16
14
|
/* global XMLHttpRequest, Blob */
|
|
17
|
-
|
|
18
|
-
const ParseError = require('./ParseError').default;
|
|
15
|
+
|
|
19
16
|
let XHR = null;
|
|
20
17
|
if (typeof XMLHttpRequest !== 'undefined') {
|
|
21
18
|
XHR = XMLHttpRequest;
|
|
22
19
|
}
|
|
23
|
-
/*:: type Base64 = { base64: string };*/
|
|
24
|
-
/*:: type Uri = { uri: string };*/
|
|
25
|
-
/*:: type FileData = Array<number> | Base64 | Blob | Uri;*/
|
|
26
20
|
/*:: export type FileSaveOptions = FullOptions & {
|
|
27
21
|
metadata?: { [key: string]: any },
|
|
28
22
|
tags?: { [key: string]: any },
|
|
@@ -31,17 +25,17 @@ if (typeof XMLHttpRequest !== 'undefined') {
|
|
|
31
25
|
| {
|
|
32
26
|
format: 'file',
|
|
33
27
|
file: Blob,
|
|
34
|
-
type: string,
|
|
28
|
+
type: string | undefined,
|
|
35
29
|
}
|
|
36
30
|
| {
|
|
37
31
|
format: 'base64',
|
|
38
32
|
base64: string,
|
|
39
|
-
type: string,
|
|
33
|
+
type: string | undefined,
|
|
40
34
|
}
|
|
41
35
|
| {
|
|
42
36
|
format: 'uri',
|
|
43
37
|
uri: string,
|
|
44
|
-
type: string,
|
|
38
|
+
type: string | undefined,
|
|
45
39
|
};*/
|
|
46
40
|
function b64Digit(number /*: number*/) /*: string*/{
|
|
47
41
|
if (number < 26) {
|
|
@@ -69,14 +63,6 @@ function b64Digit(number /*: number*/) /*: string*/{
|
|
|
69
63
|
* @alias Parse.File
|
|
70
64
|
*/
|
|
71
65
|
class ParseFile {
|
|
72
|
-
/*:: _name: string;*/
|
|
73
|
-
/*:: _url: ?string;*/
|
|
74
|
-
/*:: _source: FileSource;*/
|
|
75
|
-
/*:: _previousSave: ?Promise<ParseFile>;*/
|
|
76
|
-
/*:: _data: ?string;*/
|
|
77
|
-
/*:: _requestTask: ?any;*/
|
|
78
|
-
/*:: _metadata: ?Object;*/
|
|
79
|
-
/*:: _tags: ?Object;*/
|
|
80
66
|
/**
|
|
81
67
|
* @param name {String} The file's name. This will be prefixed by a unique
|
|
82
68
|
* value once the file has finished saving. The file name must begin with
|
|
@@ -104,10 +90,10 @@ class ParseFile {
|
|
|
104
90
|
* @param type {String} Optional Content-Type header to use for the file. If
|
|
105
91
|
* this is omitted, the content type will be inferred from the name's
|
|
106
92
|
* extension.
|
|
107
|
-
* @param metadata {
|
|
108
|
-
* @param tags {
|
|
93
|
+
* @param metadata {object} Optional key value pairs to be stored with file object
|
|
94
|
+
* @param tags {object} Optional key value pairs to be stored with file object
|
|
109
95
|
*/
|
|
110
|
-
constructor(name /*: string*/, data /*:: ?: FileData*/, type /*:: ?: string*/, metadata /*:: ?:
|
|
96
|
+
constructor(name /*: string*/, data /*:: ?: FileData*/, type /*:: ?: string*/, metadata /*:: ?: object*/, tags /*:: ?: object*/) {
|
|
111
97
|
const specifiedType = type || '';
|
|
112
98
|
this._name = name;
|
|
113
99
|
this._metadata = metadata || {};
|
|
@@ -154,7 +140,7 @@ class ParseFile {
|
|
|
154
140
|
*
|
|
155
141
|
* @returns {Promise} Promise that is resolve with base64 data
|
|
156
142
|
*/
|
|
157
|
-
async getData() /*: Promise<
|
|
143
|
+
async getData() /*: Promise<string>*/{
|
|
158
144
|
if (this._data) {
|
|
159
145
|
return this._data;
|
|
160
146
|
}
|
|
@@ -185,9 +171,10 @@ class ParseFile {
|
|
|
185
171
|
* after you get the file from a Parse.Object.
|
|
186
172
|
*
|
|
187
173
|
* @param {object} options An object to specify url options
|
|
174
|
+
* @param {boolean} [options.forceSecure] force the url to be secure
|
|
188
175
|
* @returns {string | undefined}
|
|
189
176
|
*/
|
|
190
|
-
url(options /*:: ?: { forceSecure?: boolean }*/) /*:
|
|
177
|
+
url(options /*:: ?: { forceSecure?: boolean }*/) /*: string | undefined*/{
|
|
191
178
|
options = options || {};
|
|
192
179
|
if (!this._url) {
|
|
193
180
|
return;
|
|
@@ -204,7 +191,7 @@ class ParseFile {
|
|
|
204
191
|
*
|
|
205
192
|
* @returns {object}
|
|
206
193
|
*/
|
|
207
|
-
metadata()
|
|
194
|
+
metadata() {
|
|
208
195
|
return this._metadata;
|
|
209
196
|
}
|
|
210
197
|
|
|
@@ -213,7 +200,7 @@ class ParseFile {
|
|
|
213
200
|
*
|
|
214
201
|
* @returns {object}
|
|
215
202
|
*/
|
|
216
|
-
tags()
|
|
203
|
+
tags() {
|
|
217
204
|
return this._tags;
|
|
218
205
|
}
|
|
219
206
|
|
|
@@ -240,7 +227,7 @@ class ParseFile {
|
|
|
240
227
|
* </ul>
|
|
241
228
|
* @returns {Promise | undefined} Promise that is resolved when the save finishes.
|
|
242
229
|
*/
|
|
243
|
-
save(options /*:: ?:
|
|
230
|
+
save(options /*:: ?: FileSaveOptions*/) /*: Promise<ParseFile> | undefined*/{
|
|
244
231
|
options = options || {};
|
|
245
232
|
options.requestTask = task => this._requestTask = task;
|
|
246
233
|
options.metadata = this._metadata;
|
|
@@ -268,7 +255,7 @@ class ParseFile {
|
|
|
268
255
|
this._data = result.base64;
|
|
269
256
|
this._requestTask = null;
|
|
270
257
|
return controller.saveBase64(this._name, newSource, options);
|
|
271
|
-
}).then(res => {
|
|
258
|
+
}).then((res /*: { name?: string, url?: string }*/) => {
|
|
272
259
|
this._name = res.name;
|
|
273
260
|
this._url = res.url;
|
|
274
261
|
this._requestTask = null;
|
|
@@ -310,31 +297,31 @@ class ParseFile {
|
|
|
310
297
|
* <pre>
|
|
311
298
|
* @returns {Promise} Promise that is resolved when the delete finishes.
|
|
312
299
|
*/
|
|
313
|
-
destroy(options
|
|
300
|
+
destroy(options /*: FullOptions*/ = {}) {
|
|
314
301
|
if (!this._name) {
|
|
315
|
-
throw new
|
|
302
|
+
throw new _ParseError.default(_ParseError.default.FILE_DELETE_UNNAMED_ERROR, 'Cannot delete an unnamed file.');
|
|
316
303
|
}
|
|
317
304
|
const destroyOptions = {
|
|
318
305
|
useMasterKey: true
|
|
319
306
|
};
|
|
320
307
|
if (options.hasOwnProperty('useMasterKey')) {
|
|
321
|
-
destroyOptions.useMasterKey = options.useMasterKey;
|
|
308
|
+
destroyOptions.useMasterKey = !!options.useMasterKey;
|
|
322
309
|
}
|
|
323
310
|
const controller = _CoreManager.default.getFileController();
|
|
324
311
|
return controller.deleteFile(this._name, destroyOptions).then(() => {
|
|
325
|
-
this._data =
|
|
312
|
+
this._data = undefined;
|
|
326
313
|
this._requestTask = null;
|
|
327
314
|
return this;
|
|
328
315
|
});
|
|
329
316
|
}
|
|
330
|
-
toJSON() /*: {
|
|
317
|
+
toJSON() /*: { __type: 'File', name?: string, url?: string }*/{
|
|
331
318
|
return {
|
|
332
319
|
__type: 'File',
|
|
333
320
|
name: this._name,
|
|
334
321
|
url: this._url
|
|
335
322
|
};
|
|
336
323
|
}
|
|
337
|
-
equals(other /*:
|
|
324
|
+
equals(other /*: any*/) /*: boolean*/{
|
|
338
325
|
if (this === other) {
|
|
339
326
|
return true;
|
|
340
327
|
}
|
|
@@ -399,7 +386,7 @@ class ParseFile {
|
|
|
399
386
|
file._url = obj.url;
|
|
400
387
|
return file;
|
|
401
388
|
}
|
|
402
|
-
static encodeBase64(bytes /*: Array<number
|
|
389
|
+
static encodeBase64(bytes /*: Array<number> | Uint8Array*/) /*: string*/{
|
|
403
390
|
const chunks = [];
|
|
404
391
|
chunks.length = Math.ceil(bytes.length / 3);
|
|
405
392
|
for (let i = 0; i < chunks.length; i++) {
|
|
@@ -414,7 +401,7 @@ class ParseFile {
|
|
|
414
401
|
}
|
|
415
402
|
}
|
|
416
403
|
const DefaultController = {
|
|
417
|
-
saveFile: async function (name /*: string*/, source /*: FileSource*/, options /*:: ?:
|
|
404
|
+
saveFile: async function (name /*: string*/, source /*: FileSource*/, options /*:: ?: FileSaveOptions*/) {
|
|
418
405
|
if (source.format !== 'file') {
|
|
419
406
|
throw new Error('saveFile can only be used with File-type sources.');
|
|
420
407
|
}
|
|
@@ -434,15 +421,15 @@ const DefaultController = {
|
|
|
434
421
|
const newSource = {
|
|
435
422
|
format: 'base64',
|
|
436
423
|
base64: data,
|
|
437
|
-
type: source.type || (source.file ? source.file.type :
|
|
424
|
+
type: source.type || (source.file ? source.file.type : undefined)
|
|
438
425
|
};
|
|
439
426
|
return await DefaultController.saveBase64(name, newSource, options);
|
|
440
427
|
},
|
|
441
|
-
saveBase64: function (name /*: string*/, source /*: FileSource*/, options
|
|
428
|
+
saveBase64: function (name /*: string*/, source /*: FileSource*/, options /*: FileSaveOptions*/ = {}) {
|
|
442
429
|
if (source.format !== 'base64') {
|
|
443
430
|
throw new Error('saveBase64 can only be used with Base64-type sources.');
|
|
444
431
|
}
|
|
445
|
-
const data /*: { base64: any, _ContentType?: any, fileData:
|
|
432
|
+
const data /*: { base64: any, _ContentType?: any, fileData: any }*/ = {
|
|
446
433
|
base64: source.base64,
|
|
447
434
|
fileData: {
|
|
448
435
|
metadata: {
|
|
@@ -485,7 +472,7 @@ const DefaultController = {
|
|
|
485
472
|
});
|
|
486
473
|
}
|
|
487
474
|
},
|
|
488
|
-
downloadAjax: function (uri
|
|
475
|
+
downloadAjax: function (uri /*: string*/, options /*: any*/) {
|
|
489
476
|
return new Promise((resolve, reject) => {
|
|
490
477
|
const xhr = new XHR();
|
|
491
478
|
xhr.open('GET', uri, true);
|
|
@@ -164,9 +164,15 @@ class ParseGeoPoint {
|
|
|
164
164
|
* Creates a GeoPoint with the user's current location, if available.
|
|
165
165
|
*
|
|
166
166
|
* @param {object} options The options.
|
|
167
|
-
* @param {boolean} [options.enableHighAccuracy=false] A boolean value that indicates the application would like to receive the best possible results.
|
|
168
|
-
*
|
|
169
|
-
*
|
|
167
|
+
* @param {boolean} [options.enableHighAccuracy=false] A boolean value that indicates the application would like to receive the best possible results.
|
|
168
|
+
* If true and if the device is able to provide a more accurate position, it will do so.
|
|
169
|
+
* Note that this can result in slower response times or increased power consumption (with a GPS chip on a mobile device for example).
|
|
170
|
+
* On the other hand, if false, the device can take the liberty to save resources by responding more quickly and/or using less power. Default: false.
|
|
171
|
+
* @param {number} [options.timeout=Infinity] A positive long value representing the maximum length of time (in milliseconds) the device is allowed to take in order to return a position.
|
|
172
|
+
* The default value is Infinity, meaning that getCurrentPosition() won't return until the position is available.
|
|
173
|
+
* @param {number} [options.maximumAge=0] A positive long value indicating the maximum age in milliseconds of a possible cached position that is acceptable to return.
|
|
174
|
+
* If set to 0, it means that the device cannot use a cached position and must attempt to retrieve the real current position.
|
|
175
|
+
* If set to Infinity the device must return a cached position regardless of its age. Default: 0.
|
|
170
176
|
* @static
|
|
171
177
|
* @returns {Promise<Parse.GeoPoint>} User's current location
|
|
172
178
|
*/
|
package/lib/node/ParseHooks.js
CHANGED
|
@@ -32,60 +32,60 @@ function getFunctions() {
|
|
|
32
32
|
function getTriggers() {
|
|
33
33
|
return _CoreManager.default.getHooksController().get('triggers');
|
|
34
34
|
}
|
|
35
|
-
function getFunction(name) {
|
|
35
|
+
function getFunction(name /*: string*/) {
|
|
36
36
|
return _CoreManager.default.getHooksController().get('functions', name);
|
|
37
37
|
}
|
|
38
|
-
function getTrigger(className
|
|
38
|
+
function getTrigger(className /*: string*/, triggerName /*: string*/) {
|
|
39
39
|
return _CoreManager.default.getHooksController().get('triggers', className, triggerName);
|
|
40
40
|
}
|
|
41
|
-
function createFunction(functionName
|
|
41
|
+
function createFunction(functionName /*: string*/, url /*: string*/) {
|
|
42
42
|
return create({
|
|
43
43
|
functionName: functionName,
|
|
44
44
|
url: url
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
|
-
function createTrigger(className
|
|
47
|
+
function createTrigger(className /*: string*/, triggerName /*: string*/, url /*: string*/) {
|
|
48
48
|
return create({
|
|
49
49
|
className: className,
|
|
50
50
|
triggerName: triggerName,
|
|
51
51
|
url: url
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
|
-
function create(hook) {
|
|
54
|
+
function create(hook /*: HookDeclaration*/) {
|
|
55
55
|
return _CoreManager.default.getHooksController().create(hook);
|
|
56
56
|
}
|
|
57
|
-
function updateFunction(functionName
|
|
57
|
+
function updateFunction(functionName /*: string*/, url /*: string*/) {
|
|
58
58
|
return update({
|
|
59
59
|
functionName: functionName,
|
|
60
60
|
url: url
|
|
61
61
|
});
|
|
62
62
|
}
|
|
63
|
-
function updateTrigger(className
|
|
63
|
+
function updateTrigger(className /*: string*/, triggerName /*: string*/, url /*: string*/) {
|
|
64
64
|
return update({
|
|
65
65
|
className: className,
|
|
66
66
|
triggerName: triggerName,
|
|
67
67
|
url: url
|
|
68
68
|
});
|
|
69
69
|
}
|
|
70
|
-
function update(hook) {
|
|
70
|
+
function update(hook /*: HookDeclaration*/) {
|
|
71
71
|
return _CoreManager.default.getHooksController().update(hook);
|
|
72
72
|
}
|
|
73
|
-
function removeFunction(functionName) {
|
|
73
|
+
function removeFunction(functionName /*: string*/) {
|
|
74
74
|
return remove({
|
|
75
75
|
functionName: functionName
|
|
76
76
|
});
|
|
77
77
|
}
|
|
78
|
-
function removeTrigger(className
|
|
78
|
+
function removeTrigger(className /*: string*/, triggerName /*: string*/) {
|
|
79
79
|
return remove({
|
|
80
80
|
className: className,
|
|
81
81
|
triggerName: triggerName
|
|
82
82
|
});
|
|
83
83
|
}
|
|
84
|
-
function remove(hook) {
|
|
84
|
+
function remove(hook /*: HookDeleteArg*/) {
|
|
85
85
|
return _CoreManager.default.getHooksController().remove(hook);
|
|
86
86
|
}
|
|
87
87
|
const DefaultController = {
|
|
88
|
-
get(type
|
|
88
|
+
get(type /*: string*/, functionName /*:: ?: string*/, triggerName /*:: ?: string*/) {
|
|
89
89
|
let url = '/hooks/' + type;
|
|
90
90
|
if (functionName) {
|
|
91
91
|
url += '/' + functionName;
|
|
@@ -145,7 +145,7 @@ const DefaultController = {
|
|
|
145
145
|
}
|
|
146
146
|
return this.sendRequest('PUT', url, hook);
|
|
147
147
|
},
|
|
148
|
-
sendRequest(method
|
|
148
|
+
sendRequest(method /*: string*/, url /*: string*/, body /*:: ?: any*/) {
|
|
149
149
|
return _CoreManager.default.getRESTController().request(method, url, body, {
|
|
150
150
|
useMasterKey: true
|
|
151
151
|
}).then(res => {
|