parse 4.0.1 → 4.1.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/parse.js +17994 -26193
- package/dist/parse.min.js +2 -2
- package/dist/parse.weapp.js +8738 -17728
- package/dist/parse.weapp.min.js +2 -2
- package/lib/browser/Analytics.js +2 -20
- package/lib/browser/AnonymousUtils.js +6 -35
- package/lib/browser/Cloud.js +12 -70
- package/lib/browser/CloudCode.js +0 -3
- package/lib/browser/CoreManager.js +46 -184
- package/lib/browser/CryptoController.js +2 -16
- package/lib/browser/EventEmitter.js +1 -1
- package/lib/browser/EventuallyQueue.js +277 -824
- package/lib/browser/FacebookUtils.js +6 -35
- package/lib/browser/IndexedDBStorageController.js +3 -14
- package/lib/browser/InstallationController.js +2 -13
- package/lib/browser/LiveQueryClient.js +87 -204
- package/lib/browser/LiveQuerySubscription.js +10 -39
- package/lib/browser/LocalDatastore.js +451 -1081
- package/lib/browser/LocalDatastoreController.js +145 -602
- package/lib/browser/LocalDatastoreController.react-native.js +137 -573
- package/lib/browser/LocalDatastoreUtils.js +2 -12
- package/lib/browser/ObjectStateMutations.js +18 -121
- package/lib/browser/OfflineQuery.js +42 -222
- package/lib/browser/Parse.js +12 -106
- package/lib/browser/ParseACL.js +33 -141
- package/lib/browser/ParseCLP.js +96 -314
- package/lib/browser/ParseConfig.js +18 -88
- package/lib/browser/ParseError.js +63 -90
- package/lib/browser/ParseFile.js +128 -685
- package/lib/browser/ParseGeoPoint.js +23 -82
- package/lib/browser/ParseHooks.js +1 -34
- package/lib/browser/ParseInstallation.js +4 -32
- package/lib/browser/ParseLiveQuery.js +96 -505
- package/lib/browser/ParseObject.js +628 -1840
- package/lib/browser/ParseOp.js +41 -287
- package/lib/browser/ParsePolygon.js +13 -63
- package/lib/browser/ParseQuery.js +404 -1505
- package/lib/browser/ParseRelation.js +12 -61
- package/lib/browser/ParseRole.js +13 -75
- package/lib/browser/ParseSchema.js +49 -201
- package/lib/browser/ParseSession.js +11 -69
- package/lib/browser/ParseUser.js +274 -1127
- package/lib/browser/Push.js +7 -43
- package/lib/browser/RESTController.js +18 -140
- package/lib/browser/SingleInstanceStateController.js +19 -137
- package/lib/browser/Socket.weapp.js +2 -12
- package/lib/browser/Storage.js +10 -73
- package/lib/browser/StorageController.browser.js +4 -17
- package/lib/browser/StorageController.default.js +4 -17
- package/lib/browser/StorageController.react-native.js +6 -33
- package/lib/browser/StorageController.weapp.js +5 -16
- package/lib/browser/TaskQueue.js +1 -22
- package/lib/browser/UniqueInstanceStateController.js +19 -142
- package/lib/browser/Xhr.weapp.js +0 -17
- package/lib/browser/arrayContainsObject.js +2 -16
- package/lib/browser/canBeSerialized.js +3 -33
- package/lib/browser/decode.js +3 -33
- package/lib/browser/encode.js +9 -70
- package/lib/browser/equals.js +2 -25
- package/lib/browser/escape.js +1 -8
- package/lib/browser/isRevocableSession.js +2 -11
- package/lib/browser/parseDate.js +2 -13
- package/lib/browser/promiseUtils.js +3 -21
- package/lib/browser/unique.js +3 -17
- package/lib/browser/unsavedChildren.js +6 -50
- package/lib/browser/uuid.js +3 -1
- package/lib/node/Analytics.js +1 -18
- package/lib/node/AnonymousUtils.js +5 -37
- package/lib/node/Cloud.js +10 -66
- package/lib/node/CloudCode.js +0 -3
- package/lib/node/CoreManager.js +47 -220
- package/lib/node/CryptoController.js +2 -16
- package/lib/node/EventEmitter.js +1 -1
- package/lib/node/EventuallyQueue.js +16 -123
- package/lib/node/FacebookUtils.js +5 -37
- package/lib/node/IndexedDBStorageController.js +3 -19
- package/lib/node/InstallationController.js +2 -15
- package/lib/node/LiveQueryClient.js +56 -136
- package/lib/node/LiveQuerySubscription.js +7 -16
- package/lib/node/LocalDatastore.js +19 -175
- package/lib/node/LocalDatastoreController.js +6 -38
- package/lib/node/LocalDatastoreController.react-native.js +6 -45
- package/lib/node/LocalDatastoreUtils.js +1 -6
- package/lib/node/ObjectStateMutations.js +13 -93
- package/lib/node/OfflineQuery.js +20 -152
- package/lib/node/Parse.js +11 -99
- package/lib/node/ParseACL.js +32 -150
- package/lib/node/ParseCLP.js +69 -262
- package/lib/node/ParseConfig.js +16 -84
- package/lib/node/ParseError.js +61 -65
- package/lib/node/ParseFile.js +49 -205
- package/lib/node/ParseGeoPoint.js +21 -82
- package/lib/node/ParseHooks.js +0 -35
- package/lib/node/ParseInstallation.js +1 -10
- package/lib/node/ParseLiveQuery.js +10 -36
- package/lib/node/ParseObject.js +193 -939
- package/lib/node/ParseOp.js +31 -255
- package/lib/node/ParsePolygon.js +12 -62
- package/lib/node/ParseQuery.js +170 -882
- package/lib/node/ParseRelation.js +11 -61
- package/lib/node/ParseRole.js +10 -57
- package/lib/node/ParseSchema.js +46 -222
- package/lib/node/ParseSession.js +8 -50
- package/lib/node/ParseUser.js +107 -576
- package/lib/node/Push.js +4 -37
- package/lib/node/RESTController.js +8 -110
- package/lib/node/SingleInstanceStateController.js +17 -130
- package/lib/node/Socket.weapp.js +2 -9
- package/lib/node/Storage.js +10 -83
- package/lib/node/StorageController.browser.js +4 -23
- package/lib/node/StorageController.default.js +5 -21
- package/lib/node/StorageController.react-native.js +6 -40
- package/lib/node/StorageController.weapp.js +6 -21
- package/lib/node/TaskQueue.js +1 -17
- package/lib/node/UniqueInstanceStateController.js +16 -133
- package/lib/node/Xhr.weapp.js +0 -15
- package/lib/node/arrayContainsObject.js +1 -12
- package/lib/node/canBeSerialized.js +2 -28
- package/lib/node/decode.js +1 -26
- package/lib/node/encode.js +3 -54
- package/lib/node/equals.js +0 -18
- package/lib/node/escape.js +1 -6
- package/lib/node/isRevocableSession.js +1 -5
- package/lib/node/parseDate.js +1 -7
- package/lib/node/promiseUtils.js +2 -14
- package/lib/node/unique.js +1 -11
- package/lib/node/unsavedChildren.js +2 -38
- package/lib/node/uuid.js +6 -1
- package/lib/react-native/Analytics.js +0 -9
- package/lib/react-native/AnonymousUtils.js +0 -10
- package/lib/react-native/Cloud.js +0 -26
- package/lib/react-native/CoreManager.js +1 -5
- package/lib/react-native/CryptoController.js +0 -2
- package/lib/react-native/EventEmitter.js +0 -2
- package/lib/react-native/EventuallyQueue.js +4 -52
- package/lib/react-native/FacebookUtils.js +0 -22
- package/lib/react-native/IndexedDBStorageController.js +0 -1
- package/lib/react-native/InstallationController.js +0 -6
- package/lib/react-native/LiveQueryClient.js +24 -101
- package/lib/react-native/LiveQuerySubscription.js +3 -27
- package/lib/react-native/LocalDatastore.js +6 -113
- package/lib/react-native/LocalDatastoreController.js +0 -21
- package/lib/react-native/LocalDatastoreController.react-native.js +4 -31
- package/lib/react-native/LocalDatastoreUtils.js +0 -1
- package/lib/react-native/ObjectStateMutations.js +0 -34
- package/lib/react-native/OfflineQuery.js +2 -137
- package/lib/react-native/Parse.js +0 -65
- package/lib/react-native/ParseACL.js +0 -44
- package/lib/react-native/ParseCLP.js +32 -96
- package/lib/react-native/ParseConfig.js +0 -42
- package/lib/react-native/ParseError.js +1 -21
- package/lib/react-native/ParseFile.js +3 -72
- package/lib/react-native/ParseGeoPoint.js +0 -17
- package/lib/react-native/ParseHooks.js +0 -30
- package/lib/react-native/ParseInstallation.js +1 -23
- package/lib/react-native/ParseLiveQuery.js +3 -25
- package/lib/react-native/ParseObject.js +4 -371
- package/lib/react-native/ParseOp.js +1 -138
- package/lib/react-native/ParsePolygon.js +0 -24
- package/lib/react-native/ParseQuery.js +6 -262
- package/lib/react-native/ParseRelation.js +0 -25
- package/lib/react-native/ParseRole.js +1 -36
- package/lib/react-native/ParseSchema.js +0 -51
- package/lib/react-native/ParseSession.js +1 -40
- package/lib/react-native/ParseUser.js +1 -224
- package/lib/react-native/Push.js +0 -16
- package/lib/react-native/RESTController.js +1 -70
- package/lib/react-native/SingleInstanceStateController.js +0 -44
- package/lib/react-native/Socket.weapp.js +2 -12
- package/lib/react-native/Storage.js +0 -24
- package/lib/react-native/StorageController.browser.js +0 -2
- package/lib/react-native/StorageController.default.js +0 -1
- package/lib/react-native/StorageController.react-native.js +0 -2
- package/lib/react-native/TaskQueue.js +0 -15
- package/lib/react-native/UniqueInstanceStateController.js +0 -47
- package/lib/react-native/Xhr.weapp.js +0 -16
- package/lib/react-native/arrayContainsObject.js +0 -5
- package/lib/react-native/canBeSerialized.js +0 -18
- package/lib/react-native/decode.js +0 -21
- package/lib/react-native/encode.js +0 -25
- package/lib/react-native/equals.js +0 -18
- package/lib/react-native/escape.js +0 -1
- package/lib/react-native/isRevocableSession.js +0 -1
- package/lib/react-native/parseDate.js +0 -3
- package/lib/react-native/promiseUtils.js +0 -13
- package/lib/react-native/unique.js +0 -4
- package/lib/react-native/unsavedChildren.js +0 -21
- package/lib/react-native/uuid.js +3 -1
- package/lib/weapp/Analytics.js +2 -20
- package/lib/weapp/AnonymousUtils.js +6 -35
- package/lib/weapp/Cloud.js +12 -70
- package/lib/weapp/CloudCode.js +0 -3
- package/lib/weapp/CoreManager.js +46 -184
- package/lib/weapp/CryptoController.js +2 -16
- package/lib/weapp/EventEmitter.js +1 -1
- package/lib/weapp/EventuallyQueue.js +277 -824
- package/lib/weapp/FacebookUtils.js +6 -35
- package/lib/weapp/IndexedDBStorageController.js +3 -14
- package/lib/weapp/InstallationController.js +2 -13
- package/lib/weapp/LiveQueryClient.js +87 -204
- package/lib/weapp/LiveQuerySubscription.js +10 -39
- package/lib/weapp/LocalDatastore.js +451 -1081
- package/lib/weapp/LocalDatastoreController.js +145 -602
- package/lib/weapp/LocalDatastoreController.react-native.js +137 -573
- package/lib/weapp/LocalDatastoreUtils.js +2 -12
- package/lib/weapp/ObjectStateMutations.js +18 -121
- package/lib/weapp/OfflineQuery.js +42 -222
- package/lib/weapp/Parse.js +12 -106
- package/lib/weapp/ParseACL.js +33 -141
- package/lib/weapp/ParseCLP.js +96 -314
- package/lib/weapp/ParseConfig.js +18 -88
- package/lib/weapp/ParseError.js +63 -90
- package/lib/weapp/ParseFile.js +129 -686
- package/lib/weapp/ParseGeoPoint.js +23 -82
- package/lib/weapp/ParseHooks.js +1 -34
- package/lib/weapp/ParseInstallation.js +4 -32
- package/lib/weapp/ParseLiveQuery.js +96 -505
- package/lib/weapp/ParseObject.js +628 -1840
- package/lib/weapp/ParseOp.js +41 -287
- package/lib/weapp/ParsePolygon.js +13 -63
- package/lib/weapp/ParseQuery.js +404 -1505
- package/lib/weapp/ParseRelation.js +12 -61
- package/lib/weapp/ParseRole.js +13 -75
- package/lib/weapp/ParseSchema.js +49 -201
- package/lib/weapp/ParseSession.js +11 -69
- package/lib/weapp/ParseUser.js +274 -1127
- package/lib/weapp/Push.js +7 -43
- package/lib/weapp/RESTController.js +18 -140
- package/lib/weapp/SingleInstanceStateController.js +19 -137
- package/lib/weapp/Socket.weapp.js +2 -12
- package/lib/weapp/Storage.js +10 -73
- package/lib/weapp/StorageController.browser.js +4 -17
- package/lib/weapp/StorageController.default.js +4 -17
- package/lib/weapp/StorageController.react-native.js +6 -33
- package/lib/weapp/StorageController.weapp.js +5 -16
- package/lib/weapp/TaskQueue.js +1 -22
- package/lib/weapp/UniqueInstanceStateController.js +19 -142
- package/lib/weapp/Xhr.weapp.js +0 -17
- package/lib/weapp/arrayContainsObject.js +2 -16
- package/lib/weapp/canBeSerialized.js +3 -33
- package/lib/weapp/decode.js +3 -33
- package/lib/weapp/encode.js +9 -70
- package/lib/weapp/equals.js +2 -25
- package/lib/weapp/escape.js +1 -8
- package/lib/weapp/isRevocableSession.js +2 -11
- package/lib/weapp/parseDate.js +2 -13
- package/lib/weapp/promiseUtils.js +3 -21
- package/lib/weapp/unique.js +3 -17
- package/lib/weapp/unsavedChildren.js +6 -50
- package/lib/weapp/uuid.js +1 -6
- package/package.json +45 -43
package/lib/browser/uuid.js
CHANGED
package/lib/node/Analytics.js
CHANGED
|
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.track = track;
|
|
7
|
-
|
|
8
7
|
var _CoreManager = _interopRequireDefault(require("./CoreManager"));
|
|
9
|
-
|
|
10
8
|
function _interopRequireDefault(obj) {
|
|
11
9
|
return obj && obj.__esModule ? obj : {
|
|
12
10
|
default: obj
|
|
@@ -56,41 +54,26 @@ function _interopRequireDefault(obj) {
|
|
|
56
54
|
* @returns {Promise} A promise that is resolved when the round-trip
|
|
57
55
|
* to the server completes.
|
|
58
56
|
*/
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
function track(name
|
|
62
|
-
/*: string*/
|
|
63
|
-
, dimensions
|
|
64
|
-
/*: { [key: string]: string }*/
|
|
65
|
-
)
|
|
66
|
-
/*: Promise*/
|
|
67
|
-
{
|
|
57
|
+
function track(name /*: string*/, dimensions /*: { [key: string]: string }*/) /*: Promise*/{
|
|
68
58
|
name = name || '';
|
|
69
59
|
name = name.replace(/^\s*/, '');
|
|
70
60
|
name = name.replace(/\s*$/, '');
|
|
71
|
-
|
|
72
61
|
if (name.length === 0) {
|
|
73
62
|
throw new TypeError('A name for the custom event must be provided');
|
|
74
63
|
}
|
|
75
|
-
|
|
76
64
|
for (const key in dimensions) {
|
|
77
65
|
if (typeof key !== 'string' || typeof dimensions[key] !== 'string') {
|
|
78
66
|
throw new TypeError('track() dimensions expects keys and values of type "string".');
|
|
79
67
|
}
|
|
80
68
|
}
|
|
81
|
-
|
|
82
69
|
return _CoreManager.default.getAnalyticsController().track(name, dimensions);
|
|
83
70
|
}
|
|
84
|
-
|
|
85
71
|
const DefaultController = {
|
|
86
72
|
track(name, dimensions) {
|
|
87
73
|
const RESTController = _CoreManager.default.getRESTController();
|
|
88
|
-
|
|
89
74
|
return RESTController.request('POST', 'events/' + name, {
|
|
90
75
|
dimensions: dimensions
|
|
91
76
|
});
|
|
92
77
|
}
|
|
93
|
-
|
|
94
78
|
};
|
|
95
|
-
|
|
96
79
|
_CoreManager.default.setAnalyticsController(DefaultController);
|
|
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _ParseUser = _interopRequireDefault(require("./ParseUser"));
|
|
9
|
-
|
|
10
8
|
function _interopRequireDefault(obj) {
|
|
11
9
|
return obj && obj.__esModule ? obj : {
|
|
12
10
|
default: obj
|
|
@@ -16,10 +14,9 @@ function _interopRequireDefault(obj) {
|
|
|
16
14
|
* @flow-weak
|
|
17
15
|
*/
|
|
18
16
|
|
|
19
|
-
|
|
20
17
|
const uuidv4 = require('./uuid');
|
|
21
|
-
|
|
22
18
|
let registered = false;
|
|
19
|
+
|
|
23
20
|
/**
|
|
24
21
|
* Provides utility functions for working with Anonymously logged-in users. <br />
|
|
25
22
|
* Anonymous users have some unique characteristics:
|
|
@@ -48,7 +45,6 @@ let registered = false;
|
|
|
48
45
|
* @class Parse.AnonymousUtils
|
|
49
46
|
* @static
|
|
50
47
|
*/
|
|
51
|
-
|
|
52
48
|
const AnonymousUtils = {
|
|
53
49
|
/**
|
|
54
50
|
* Gets whether the user has their account linked to anonymous user.
|
|
@@ -61,14 +57,10 @@ const AnonymousUtils = {
|
|
|
61
57
|
* linked to an anonymous user.
|
|
62
58
|
* @static
|
|
63
59
|
*/
|
|
64
|
-
isLinked(user
|
|
65
|
-
/*: ParseUser*/
|
|
66
|
-
) {
|
|
60
|
+
isLinked(user /*: ParseUser*/) {
|
|
67
61
|
const provider = this._getAuthProvider();
|
|
68
|
-
|
|
69
62
|
return user._isLinked(provider.getAuthType());
|
|
70
63
|
},
|
|
71
|
-
|
|
72
64
|
/**
|
|
73
65
|
* Logs in a user Anonymously.
|
|
74
66
|
*
|
|
@@ -78,16 +70,10 @@ const AnonymousUtils = {
|
|
|
78
70
|
* @returns {Promise} Logged in user
|
|
79
71
|
* @static
|
|
80
72
|
*/
|
|
81
|
-
logIn(options
|
|
82
|
-
/*:: ?: RequestOptions*/
|
|
83
|
-
)
|
|
84
|
-
/*: Promise<ParseUser>*/
|
|
85
|
-
{
|
|
73
|
+
logIn(options /*:: ?: RequestOptions*/) /*: Promise<ParseUser>*/{
|
|
86
74
|
const provider = this._getAuthProvider();
|
|
87
|
-
|
|
88
75
|
return _ParseUser.default.logInWith(provider.getAuthType(), provider.getAuthData(), options);
|
|
89
76
|
},
|
|
90
|
-
|
|
91
77
|
/**
|
|
92
78
|
* Links Anonymous User to an existing PFUser.
|
|
93
79
|
*
|
|
@@ -98,18 +84,10 @@ const AnonymousUtils = {
|
|
|
98
84
|
* @returns {Promise} Linked with User
|
|
99
85
|
* @static
|
|
100
86
|
*/
|
|
101
|
-
link(user
|
|
102
|
-
/*: ParseUser*/
|
|
103
|
-
, options
|
|
104
|
-
/*:: ?: RequestOptions*/
|
|
105
|
-
)
|
|
106
|
-
/*: Promise<ParseUser>*/
|
|
107
|
-
{
|
|
87
|
+
link(user /*: ParseUser*/, options /*:: ?: RequestOptions*/) /*: Promise<ParseUser>*/{
|
|
108
88
|
const provider = this._getAuthProvider();
|
|
109
|
-
|
|
110
89
|
return user.linkWith(provider.getAuthType(), provider.getAuthData(), options);
|
|
111
90
|
},
|
|
112
|
-
|
|
113
91
|
/**
|
|
114
92
|
* Returns true if Authentication Provider has been registered for use.
|
|
115
93
|
*
|
|
@@ -118,22 +96,17 @@ const AnonymousUtils = {
|
|
|
118
96
|
* @returns {boolean}
|
|
119
97
|
* @static
|
|
120
98
|
*/
|
|
121
|
-
isRegistered()
|
|
122
|
-
/*: boolean*/
|
|
123
|
-
{
|
|
99
|
+
isRegistered() /*: boolean*/{
|
|
124
100
|
return registered;
|
|
125
101
|
},
|
|
126
|
-
|
|
127
102
|
_getAuthProvider() {
|
|
128
103
|
const provider = {
|
|
129
104
|
restoreAuthentication() {
|
|
130
105
|
return true;
|
|
131
106
|
},
|
|
132
|
-
|
|
133
107
|
getAuthType() {
|
|
134
108
|
return 'anonymous';
|
|
135
109
|
},
|
|
136
|
-
|
|
137
110
|
getAuthData() {
|
|
138
111
|
return {
|
|
139
112
|
authData: {
|
|
@@ -141,18 +114,13 @@ const AnonymousUtils = {
|
|
|
141
114
|
}
|
|
142
115
|
};
|
|
143
116
|
}
|
|
144
|
-
|
|
145
117
|
};
|
|
146
|
-
|
|
147
118
|
if (!registered) {
|
|
148
119
|
_ParseUser.default._registerAuthenticationProvider(provider);
|
|
149
|
-
|
|
150
120
|
registered = true;
|
|
151
121
|
}
|
|
152
|
-
|
|
153
122
|
return provider;
|
|
154
123
|
}
|
|
155
|
-
|
|
156
124
|
};
|
|
157
125
|
var _default = AnonymousUtils;
|
|
158
126
|
exports.default = _default;
|
package/lib/node/Cloud.js
CHANGED
|
@@ -7,19 +7,12 @@ exports.getJobStatus = getJobStatus;
|
|
|
7
7
|
exports.getJobsData = getJobsData;
|
|
8
8
|
exports.run = run;
|
|
9
9
|
exports.startJob = startJob;
|
|
10
|
-
|
|
11
10
|
var _CoreManager = _interopRequireDefault(require("./CoreManager"));
|
|
12
|
-
|
|
13
11
|
var _decode = _interopRequireDefault(require("./decode"));
|
|
14
|
-
|
|
15
12
|
var _encode = _interopRequireDefault(require("./encode"));
|
|
16
|
-
|
|
17
13
|
var _ParseError = _interopRequireDefault(require("./ParseError"));
|
|
18
|
-
|
|
19
14
|
var _ParseQuery = _interopRequireDefault(require("./ParseQuery"));
|
|
20
|
-
|
|
21
15
|
var _ParseObject = _interopRequireDefault(require("./ParseObject"));
|
|
22
|
-
|
|
23
16
|
function _interopRequireDefault(obj) {
|
|
24
17
|
return obj && obj.__esModule ? obj : {
|
|
25
18
|
default: obj
|
|
@@ -52,39 +45,24 @@ function _interopRequireDefault(obj) {
|
|
|
52
45
|
* @returns {Promise} A promise that will be resolved with the result
|
|
53
46
|
* of the function.
|
|
54
47
|
*/
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
function run(name
|
|
58
|
-
/*: string*/
|
|
59
|
-
, data
|
|
60
|
-
/*: mixed*/
|
|
61
|
-
, options
|
|
62
|
-
/*: RequestOptions*/
|
|
63
|
-
)
|
|
64
|
-
/*: Promise<mixed>*/
|
|
65
|
-
{
|
|
48
|
+
function run(name /*: string*/, data /*: mixed*/, options /*: RequestOptions*/) /*: Promise<mixed>*/{
|
|
66
49
|
options = options || {};
|
|
67
|
-
|
|
68
50
|
if (typeof name !== 'string' || name.length === 0) {
|
|
69
51
|
throw new TypeError('Cloud function name must be a string.');
|
|
70
52
|
}
|
|
71
|
-
|
|
72
53
|
const requestOptions = {};
|
|
73
|
-
|
|
74
54
|
if (options.useMasterKey) {
|
|
75
55
|
requestOptions.useMasterKey = options.useMasterKey;
|
|
76
56
|
}
|
|
77
|
-
|
|
78
57
|
if (options.sessionToken) {
|
|
79
58
|
requestOptions.sessionToken = options.sessionToken;
|
|
80
59
|
}
|
|
81
|
-
|
|
82
60
|
if (options.context && typeof options.context === 'object') {
|
|
83
61
|
requestOptions.context = options.context;
|
|
84
62
|
}
|
|
85
|
-
|
|
86
63
|
return _CoreManager.default.getCloudController().run(name, data, requestOptions);
|
|
87
64
|
}
|
|
65
|
+
|
|
88
66
|
/**
|
|
89
67
|
* Gets data for the current set of cloud jobs.
|
|
90
68
|
*
|
|
@@ -93,15 +71,12 @@ function run(name
|
|
|
93
71
|
* @returns {Promise} A promise that will be resolved with the result
|
|
94
72
|
* of the function.
|
|
95
73
|
*/
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
function getJobsData()
|
|
99
|
-
/*: Promise<Object>*/
|
|
100
|
-
{
|
|
74
|
+
function getJobsData() /*: Promise<Object>*/{
|
|
101
75
|
return _CoreManager.default.getCloudController().getJobsData({
|
|
102
76
|
useMasterKey: true
|
|
103
77
|
});
|
|
104
78
|
}
|
|
79
|
+
|
|
105
80
|
/**
|
|
106
81
|
* Starts a given cloud job, which will process asynchronously.
|
|
107
82
|
*
|
|
@@ -112,23 +87,15 @@ function getJobsData()
|
|
|
112
87
|
* @returns {Promise} A promise that will be resolved with the jobStatusId
|
|
113
88
|
* of the job.
|
|
114
89
|
*/
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
function startJob(name
|
|
118
|
-
/*: string*/
|
|
119
|
-
, data
|
|
120
|
-
/*: mixed*/
|
|
121
|
-
)
|
|
122
|
-
/*: Promise<string>*/
|
|
123
|
-
{
|
|
90
|
+
function startJob(name /*: string*/, data /*: mixed*/) /*: Promise<string>*/{
|
|
124
91
|
if (typeof name !== 'string' || name.length === 0) {
|
|
125
92
|
throw new TypeError('Cloud job name must be a string.');
|
|
126
93
|
}
|
|
127
|
-
|
|
128
94
|
return _CoreManager.default.getCloudController().startJob(name, data, {
|
|
129
95
|
useMasterKey: true
|
|
130
96
|
});
|
|
131
97
|
}
|
|
98
|
+
|
|
132
99
|
/**
|
|
133
100
|
* Gets job status by Id
|
|
134
101
|
*
|
|
@@ -137,59 +104,36 @@ function startJob(name
|
|
|
137
104
|
* @param {string} jobStatusId The Id of Job Status.
|
|
138
105
|
* @returns {Parse.Object} Status of Job.
|
|
139
106
|
*/
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
function getJobStatus(jobStatusId
|
|
143
|
-
/*: string*/
|
|
144
|
-
)
|
|
145
|
-
/*: Promise<ParseObject>*/
|
|
146
|
-
{
|
|
107
|
+
function getJobStatus(jobStatusId /*: string*/) /*: Promise<ParseObject>*/{
|
|
147
108
|
const query = new _ParseQuery.default('_JobStatus');
|
|
148
109
|
return query.get(jobStatusId, {
|
|
149
110
|
useMasterKey: true
|
|
150
111
|
});
|
|
151
112
|
}
|
|
152
|
-
|
|
153
113
|
const DefaultController = {
|
|
154
|
-
run(name, data, options
|
|
155
|
-
/*: RequestOptions*/
|
|
156
|
-
) {
|
|
114
|
+
run(name, data, options /*: RequestOptions*/) {
|
|
157
115
|
const RESTController = _CoreManager.default.getRESTController();
|
|
158
|
-
|
|
159
116
|
const payload = (0, _encode.default)(data, true);
|
|
160
117
|
const request = RESTController.request('POST', 'functions/' + name, payload, options);
|
|
161
118
|
return request.then(res => {
|
|
162
119
|
if (typeof res === 'object' && Object.keys(res).length > 0 && !res.hasOwnProperty('result')) {
|
|
163
120
|
throw new _ParseError.default(_ParseError.default.INVALID_JSON, 'The server returned an invalid response.');
|
|
164
121
|
}
|
|
165
|
-
|
|
166
122
|
const decoded = (0, _decode.default)(res);
|
|
167
|
-
|
|
168
123
|
if (decoded && decoded.hasOwnProperty('result')) {
|
|
169
124
|
return Promise.resolve(decoded.result);
|
|
170
125
|
}
|
|
171
|
-
|
|
172
126
|
return Promise.resolve(undefined);
|
|
173
127
|
});
|
|
174
128
|
},
|
|
175
|
-
|
|
176
|
-
getJobsData(options
|
|
177
|
-
/*: RequestOptions*/
|
|
178
|
-
) {
|
|
129
|
+
getJobsData(options /*: RequestOptions*/) {
|
|
179
130
|
const RESTController = _CoreManager.default.getRESTController();
|
|
180
|
-
|
|
181
131
|
return RESTController.request('GET', 'cloud_code/jobs/data', null, options);
|
|
182
132
|
},
|
|
183
|
-
|
|
184
|
-
startJob(name, data, options
|
|
185
|
-
/*: RequestOptions*/
|
|
186
|
-
) {
|
|
133
|
+
startJob(name, data, options /*: RequestOptions*/) {
|
|
187
134
|
const RESTController = _CoreManager.default.getRESTController();
|
|
188
|
-
|
|
189
135
|
const payload = (0, _encode.default)(data, true);
|
|
190
136
|
return RESTController.request('POST', 'jobs/' + name, payload, options);
|
|
191
137
|
}
|
|
192
|
-
|
|
193
138
|
};
|
|
194
|
-
|
|
195
139
|
_CoreManager.default.setCloudController(DefaultController);
|
package/lib/node/CloudCode.js
CHANGED
|
@@ -171,7 +171,6 @@
|
|
|
171
171
|
* @name Parse.Cloud.beforeConnect
|
|
172
172
|
* @param {Function} func The function to before connection is made. This function can be async and should take just one parameter, {@link Parse.Cloud.ConnectTriggerRequest}.
|
|
173
173
|
*/
|
|
174
|
-
|
|
175
174
|
/**
|
|
176
175
|
*
|
|
177
176
|
* Registers a before connect function.
|
|
@@ -194,7 +193,6 @@
|
|
|
194
193
|
* @param {(string | Parse.Object)} arg1 The Parse.Object subclass to register the before subscription function for. This can instead be a String that is the className of the subclass.
|
|
195
194
|
* @param {Function} func The function to run before a subscription. This function can be async and should take one parameter, a {@link Parse.Cloud.TriggerRequest}.
|
|
196
195
|
*/
|
|
197
|
-
|
|
198
196
|
/**
|
|
199
197
|
*
|
|
200
198
|
* Registers a before subscribe function.
|
|
@@ -247,7 +245,6 @@
|
|
|
247
245
|
* @name Parse.Cloud.job
|
|
248
246
|
* @param {string} name The name of the Background Job
|
|
249
247
|
* @param {Function} func The Background Job to register. This function should take two parameters a {@link Parse.Cloud.JobRequest} and a {@link Parse.Cloud.JobStatus}
|
|
250
|
-
*
|
|
251
248
|
*/
|
|
252
249
|
|
|
253
250
|
/**
|